diff options
author | Dean Anderson <linux-dev@sensoray.com> | 2014-02-05 15:38:42 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-02-28 12:27:35 -0500 |
commit | 92cde477c0cb7fc46c4428145d91f53bb5ffc46a (patch) | |
tree | 6401291ff707dd971c95ac5849ea541c095a8069 /drivers/media/usb/s2255 | |
parent | 6a5b63b3cbf774f6a576133fccb92f54cc8a23e1 (diff) |
[media] s2255drv: cleanup of s2255_fh
Removal of unnecessary parameters from s2255_fh.
Signed-off-by: Dean Anderson <linux-dev@sensoray.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/usb/s2255')
-rw-r--r-- | drivers/media/usb/s2255/s2255drv.c | 94 |
1 files changed, 44 insertions, 50 deletions
diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c index 787b591be3cf..e0663ce7f261 100644 --- a/drivers/media/usb/s2255/s2255drv.c +++ b/drivers/media/usb/s2255/s2255drv.c | |||
@@ -298,9 +298,7 @@ struct s2255_buffer { | |||
298 | struct s2255_fh { | 298 | struct s2255_fh { |
299 | /* this must be the first field in this struct */ | 299 | /* this must be the first field in this struct */ |
300 | struct v4l2_fh fh; | 300 | struct v4l2_fh fh; |
301 | struct s2255_dev *dev; | ||
302 | struct videobuf_queue vb_vidq; | 301 | struct videobuf_queue vb_vidq; |
303 | enum v4l2_buf_type type; | ||
304 | struct s2255_vc *vc; | 302 | struct s2255_vc *vc; |
305 | int resources; | 303 | int resources; |
306 | }; | 304 | }; |
@@ -673,6 +671,7 @@ static int buffer_setup(struct videobuf_queue *vq, unsigned int *nbuffers, | |||
673 | { | 671 | { |
674 | struct s2255_fh *fh = vq->priv_data; | 672 | struct s2255_fh *fh = vq->priv_data; |
675 | struct s2255_vc *vc = fh->vc; | 673 | struct s2255_vc *vc = fh->vc; |
674 | |||
676 | *size = vc->width * vc->height * (vc->fmt->depth >> 3); | 675 | *size = vc->width * vc->height * (vc->fmt->depth >> 3); |
677 | 676 | ||
678 | if (*nbuffers < S2255_MIN_BUFS) | 677 | if (*nbuffers < S2255_MIN_BUFS) |
@@ -696,7 +695,7 @@ static int buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, | |||
696 | int rc; | 695 | int rc; |
697 | int w = vc->width; | 696 | int w = vc->width; |
698 | int h = vc->height; | 697 | int h = vc->height; |
699 | dprintk(fh->dev, 4, "%s, field=%d\n", __func__, field); | 698 | dprintk(vc->dev, 4, "%s, field=%d\n", __func__, field); |
700 | if (vc->fmt == NULL) | 699 | if (vc->fmt == NULL) |
701 | return -EINVAL; | 700 | return -EINVAL; |
702 | 701 | ||
@@ -704,12 +703,12 @@ static int buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, | |||
704 | (w > norm_maxw(vc)) || | 703 | (w > norm_maxw(vc)) || |
705 | (h < norm_minh(vc)) || | 704 | (h < norm_minh(vc)) || |
706 | (h > norm_maxh(vc))) { | 705 | (h > norm_maxh(vc))) { |
707 | dprintk(fh->dev, 4, "invalid buffer prepare\n"); | 706 | dprintk(vc->dev, 4, "invalid buffer prepare\n"); |
708 | return -EINVAL; | 707 | return -EINVAL; |
709 | } | 708 | } |
710 | buf->vb.size = w * h * (vc->fmt->depth >> 3); | 709 | buf->vb.size = w * h * (vc->fmt->depth >> 3); |
711 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) { | 710 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) { |
712 | dprintk(fh->dev, 4, "invalid buffer prepare\n"); | 711 | dprintk(vc->dev, 4, "invalid buffer prepare\n"); |
713 | return -EINVAL; | 712 | return -EINVAL; |
714 | } | 713 | } |
715 | 714 | ||
@@ -735,7 +734,7 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | |||
735 | struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb); | 734 | struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb); |
736 | struct s2255_fh *fh = vq->priv_data; | 735 | struct s2255_fh *fh = vq->priv_data; |
737 | struct s2255_vc *vc = fh->vc; | 736 | struct s2255_vc *vc = fh->vc; |
738 | dprintk(fh->dev, 1, "%s\n", __func__); | 737 | dprintk(vc->dev, 1, "%s\n", __func__); |
739 | buf->vb.state = VIDEOBUF_QUEUED; | 738 | buf->vb.state = VIDEOBUF_QUEUED; |
740 | list_add_tail(&buf->vb.queue, &vc->buf_list); | 739 | list_add_tail(&buf->vb.queue, &vc->buf_list); |
741 | } | 740 | } |
@@ -745,7 +744,8 @@ static void buffer_release(struct videobuf_queue *vq, | |||
745 | { | 744 | { |
746 | struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb); | 745 | struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb); |
747 | struct s2255_fh *fh = vq->priv_data; | 746 | struct s2255_fh *fh = vq->priv_data; |
748 | dprintk(fh->dev, 4, "%s %d\n", __func__, fh->vc->idx); | 747 | struct s2255_vc *vc = fh->vc; |
748 | dprintk(vc->dev, 4, "%s %d\n", __func__, vc->idx); | ||
749 | free_buffer(vq, buf); | 749 | free_buffer(vq, buf); |
750 | } | 750 | } |
751 | 751 | ||
@@ -766,7 +766,7 @@ static int res_get(struct s2255_fh *fh) | |||
766 | /* it's free, grab it */ | 766 | /* it's free, grab it */ |
767 | vc->resources = 1; | 767 | vc->resources = 1; |
768 | fh->resources = 1; | 768 | fh->resources = 1; |
769 | dprintk(fh->dev, 1, "s2255: res: get\n"); | 769 | dprintk(vc->dev, 1, "s2255: res: get\n"); |
770 | return 1; | 770 | return 1; |
771 | } | 771 | } |
772 | 772 | ||
@@ -792,7 +792,7 @@ static int vidioc_querycap(struct file *file, void *priv, | |||
792 | struct v4l2_capability *cap) | 792 | struct v4l2_capability *cap) |
793 | { | 793 | { |
794 | struct s2255_fh *fh = file->private_data; | 794 | struct s2255_fh *fh = file->private_data; |
795 | struct s2255_dev *dev = fh->dev; | 795 | struct s2255_dev *dev = fh->vc->dev; |
796 | 796 | ||
797 | strlcpy(cap->driver, "s2255", sizeof(cap->driver)); | 797 | strlcpy(cap->driver, "s2255", sizeof(cap->driver)); |
798 | strlcpy(cap->card, "s2255", sizeof(cap->card)); | 798 | strlcpy(cap->card, "s2255", sizeof(cap->card)); |
@@ -855,7 +855,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
855 | 855 | ||
856 | field = f->fmt.pix.field; | 856 | field = f->fmt.pix.field; |
857 | 857 | ||
858 | dprintk(fh->dev, 50, "%s NTSC: %d suggested width: %d, height: %d\n", | 858 | dprintk(vc->dev, 50, "%s NTSC: %d suggested width: %d, height: %d\n", |
859 | __func__, is_ntsc, f->fmt.pix.width, f->fmt.pix.height); | 859 | __func__, is_ntsc, f->fmt.pix.width, f->fmt.pix.height); |
860 | if (is_ntsc) { | 860 | if (is_ntsc) { |
861 | /* NTSC */ | 861 | /* NTSC */ |
@@ -897,7 +897,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
897 | f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; | 897 | f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; |
898 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | 898 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; |
899 | f->fmt.pix.priv = 0; | 899 | f->fmt.pix.priv = 0; |
900 | dprintk(fh->dev, 50, "%s: set width %d height %d field %d\n", __func__, | 900 | dprintk(vc->dev, 50, "%s: set width %d height %d field %d\n", __func__, |
901 | f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field); | 901 | f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field); |
902 | return 0; | 902 | return 0; |
903 | } | 903 | } |
@@ -925,13 +925,13 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
925 | mutex_lock(&q->vb_lock); | 925 | mutex_lock(&q->vb_lock); |
926 | 926 | ||
927 | if (videobuf_queue_is_busy(&fh->vb_vidq)) { | 927 | if (videobuf_queue_is_busy(&fh->vb_vidq)) { |
928 | dprintk(fh->dev, 1, "queue busy\n"); | 928 | dprintk(vc->dev, 1, "queue busy\n"); |
929 | ret = -EBUSY; | 929 | ret = -EBUSY; |
930 | goto out_s_fmt; | 930 | goto out_s_fmt; |
931 | } | 931 | } |
932 | 932 | ||
933 | if (res_locked(fh)) { | 933 | if (res_locked(fh)) { |
934 | dprintk(fh->dev, 1, "%s: channel busy\n", __func__); | 934 | dprintk(vc->dev, 1, "%s: channel busy\n", __func__); |
935 | ret = -EBUSY; | 935 | ret = -EBUSY; |
936 | goto out_s_fmt; | 936 | goto out_s_fmt; |
937 | } | 937 | } |
@@ -940,7 +940,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
940 | vc->width = f->fmt.pix.width; | 940 | vc->width = f->fmt.pix.width; |
941 | vc->height = f->fmt.pix.height; | 941 | vc->height = f->fmt.pix.height; |
942 | fh->vb_vidq.field = f->fmt.pix.field; | 942 | fh->vb_vidq.field = f->fmt.pix.field; |
943 | fh->type = f->type; | ||
944 | if (vc->width > norm_minw(vc)) { | 943 | if (vc->width > norm_minw(vc)) { |
945 | if (vc->height > norm_minh(vc)) { | 944 | if (vc->height > norm_minh(vc)) { |
946 | if (vc->cap_parm.capturemode & | 945 | if (vc->cap_parm.capturemode & |
@@ -1204,15 +1203,12 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | |||
1204 | { | 1203 | { |
1205 | int res; | 1204 | int res; |
1206 | struct s2255_fh *fh = priv; | 1205 | struct s2255_fh *fh = priv; |
1207 | struct s2255_dev *dev = fh->dev; | ||
1208 | struct s2255_vc *vc = fh->vc; | 1206 | struct s2255_vc *vc = fh->vc; |
1207 | struct s2255_dev *dev = vc->dev; | ||
1209 | int j; | 1208 | int j; |
1209 | |||
1210 | dprintk(dev, 4, "%s\n", __func__); | 1210 | dprintk(dev, 4, "%s\n", __func__); |
1211 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { | 1211 | if (i != V4L2_BUF_TYPE_VIDEO_CAPTURE) { |
1212 | dev_err(&dev->udev->dev, "invalid fh type0\n"); | ||
1213 | return -EINVAL; | ||
1214 | } | ||
1215 | if (i != fh->type) { | ||
1216 | dev_err(&dev->udev->dev, "invalid fh type1\n"); | 1212 | dev_err(&dev->udev->dev, "invalid fh type1\n"); |
1217 | return -EINVAL; | 1213 | return -EINVAL; |
1218 | } | 1214 | } |
@@ -1246,14 +1242,12 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | |||
1246 | static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | 1242 | static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) |
1247 | { | 1243 | { |
1248 | struct s2255_fh *fh = priv; | 1244 | struct s2255_fh *fh = priv; |
1249 | dprintk(fh->dev, 4, "%s\n, channel: %d", __func__, fh->vc->idx); | 1245 | struct s2255_vc *vc = fh->vc; |
1250 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { | 1246 | dprintk(vc->dev, 4, "%s\n, channel: %d", __func__, vc->idx); |
1251 | dprintk(fh->dev, 1, "invalid fh type0\n"); | 1247 | |
1252 | return -EINVAL; | 1248 | if (i != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
1253 | } | ||
1254 | if (i != fh->type) | ||
1255 | return -EINVAL; | 1249 | return -EINVAL; |
1256 | s2255_stop_acquire(fh->vc); | 1250 | s2255_stop_acquire(vc); |
1257 | videobuf_streamoff(&fh->vb_vidq); | 1251 | videobuf_streamoff(&fh->vb_vidq); |
1258 | res_free(fh); | 1252 | res_free(fh); |
1259 | return 0; | 1253 | return 0; |
@@ -1269,13 +1263,13 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id i) | |||
1269 | 1263 | ||
1270 | mutex_lock(&q->vb_lock); | 1264 | mutex_lock(&q->vb_lock); |
1271 | if (res_locked(fh)) { | 1265 | if (res_locked(fh)) { |
1272 | dprintk(fh->dev, 1, "can't change standard after started\n"); | 1266 | dprintk(vc->dev, 1, "can't change standard after started\n"); |
1273 | ret = -EBUSY; | 1267 | ret = -EBUSY; |
1274 | goto out_s_std; | 1268 | goto out_s_std; |
1275 | } | 1269 | } |
1276 | mode = fh->vc->mode; | 1270 | mode = vc->mode; |
1277 | if (i & V4L2_STD_525_60) { | 1271 | if (i & V4L2_STD_525_60) { |
1278 | dprintk(fh->dev, 4, "%s 60 Hz\n", __func__); | 1272 | dprintk(vc->dev, 4, "%s 60 Hz\n", __func__); |
1279 | /* if changing format, reset frame decimation/intervals */ | 1273 | /* if changing format, reset frame decimation/intervals */ |
1280 | if (mode.format != FORMAT_NTSC) { | 1274 | if (mode.format != FORMAT_NTSC) { |
1281 | mode.restart = 1; | 1275 | mode.restart = 1; |
@@ -1285,7 +1279,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id i) | |||
1285 | vc->height = NUM_LINES_4CIFS_NTSC * 2; | 1279 | vc->height = NUM_LINES_4CIFS_NTSC * 2; |
1286 | } | 1280 | } |
1287 | } else if (i & V4L2_STD_625_50) { | 1281 | } else if (i & V4L2_STD_625_50) { |
1288 | dprintk(fh->dev, 4, "%s 50 Hz\n", __func__); | 1282 | dprintk(vc->dev, 4, "%s 50 Hz\n", __func__); |
1289 | if (mode.format != FORMAT_PAL) { | 1283 | if (mode.format != FORMAT_PAL) { |
1290 | mode.restart = 1; | 1284 | mode.restart = 1; |
1291 | mode.format = FORMAT_PAL; | 1285 | mode.format = FORMAT_PAL; |
@@ -1297,9 +1291,9 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id i) | |||
1297 | ret = -EINVAL; | 1291 | ret = -EINVAL; |
1298 | goto out_s_std; | 1292 | goto out_s_std; |
1299 | } | 1293 | } |
1300 | fh->vc->std = i; | 1294 | vc->std = i; |
1301 | if (mode.restart) | 1295 | if (mode.restart) |
1302 | s2255_set_mode(fh->vc, &mode); | 1296 | s2255_set_mode(vc, &mode); |
1303 | out_s_std: | 1297 | out_s_std: |
1304 | mutex_unlock(&q->vb_lock); | 1298 | mutex_unlock(&q->vb_lock); |
1305 | return ret; | 1299 | return ret; |
@@ -1308,8 +1302,9 @@ out_s_std: | |||
1308 | static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *i) | 1302 | static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *i) |
1309 | { | 1303 | { |
1310 | struct s2255_fh *fh = priv; | 1304 | struct s2255_fh *fh = priv; |
1305 | struct s2255_vc *vc = fh->vc; | ||
1311 | 1306 | ||
1312 | *i = fh->vc->std; | 1307 | *i = vc->std; |
1313 | return 0; | 1308 | return 0; |
1314 | } | 1309 | } |
1315 | 1310 | ||
@@ -1324,9 +1319,10 @@ static int vidioc_enum_input(struct file *file, void *priv, | |||
1324 | struct v4l2_input *inp) | 1319 | struct v4l2_input *inp) |
1325 | { | 1320 | { |
1326 | struct s2255_fh *fh = priv; | 1321 | struct s2255_fh *fh = priv; |
1327 | struct s2255_dev *dev = fh->dev; | ||
1328 | struct s2255_vc *vc = fh->vc; | 1322 | struct s2255_vc *vc = fh->vc; |
1323 | struct s2255_dev *dev = vc->dev; | ||
1329 | u32 status = 0; | 1324 | u32 status = 0; |
1325 | |||
1330 | if (inp->index != 0) | 1326 | if (inp->index != 0) |
1331 | return -EINVAL; | 1327 | return -EINVAL; |
1332 | inp->type = V4L2_INPUT_TYPE_CAMERA; | 1328 | inp->type = V4L2_INPUT_TYPE_CAMERA; |
@@ -1334,7 +1330,7 @@ static int vidioc_enum_input(struct file *file, void *priv, | |||
1334 | inp->status = 0; | 1330 | inp->status = 0; |
1335 | if (dev->dsp_fw_ver >= S2255_MIN_DSP_STATUS) { | 1331 | if (dev->dsp_fw_ver >= S2255_MIN_DSP_STATUS) { |
1336 | int rc; | 1332 | int rc; |
1337 | rc = s2255_cmd_status(fh->vc, &status); | 1333 | rc = s2255_cmd_status(vc, &status); |
1338 | dprintk(dev, 4, "s2255_cmd_status rc: %d status %x\n", | 1334 | dprintk(dev, 4, "s2255_cmd_status rc: %d status %x\n", |
1339 | rc, status); | 1335 | rc, status); |
1340 | if (rc == 0) | 1336 | if (rc == 0) |
@@ -1413,7 +1409,7 @@ static int vidioc_g_jpegcomp(struct file *file, void *priv, | |||
1413 | 1409 | ||
1414 | memset(jc, 0, sizeof(*jc)); | 1410 | memset(jc, 0, sizeof(*jc)); |
1415 | jc->quality = vc->jpegqual; | 1411 | jc->quality = vc->jpegqual; |
1416 | dprintk(fh->dev, 2, "%s: quality %d\n", __func__, jc->quality); | 1412 | dprintk(vc->dev, 2, "%s: quality %d\n", __func__, jc->quality); |
1417 | return 0; | 1413 | return 0; |
1418 | } | 1414 | } |
1419 | 1415 | ||
@@ -1425,7 +1421,7 @@ static int vidioc_s_jpegcomp(struct file *file, void *priv, | |||
1425 | if (jc->quality < 0 || jc->quality > 100) | 1421 | if (jc->quality < 0 || jc->quality > 100) |
1426 | return -EINVAL; | 1422 | return -EINVAL; |
1427 | v4l2_ctrl_s_ctrl(vc->jpegqual_ctrl, jc->quality); | 1423 | v4l2_ctrl_s_ctrl(vc->jpegqual_ctrl, jc->quality); |
1428 | dprintk(fh->dev, 2, "%s: quality %d\n", __func__, jc->quality); | 1424 | dprintk(vc->dev, 2, "%s: quality %d\n", __func__, jc->quality); |
1429 | return 0; | 1425 | return 0; |
1430 | } | 1426 | } |
1431 | 1427 | ||
@@ -1457,7 +1453,7 @@ static int vidioc_g_parm(struct file *file, void *priv, | |||
1457 | sp->parm.capture.timeperframe.numerator = def_num * 5; | 1453 | sp->parm.capture.timeperframe.numerator = def_num * 5; |
1458 | break; | 1454 | break; |
1459 | } | 1455 | } |
1460 | dprintk(fh->dev, 4, "%s capture mode, %d timeperframe %d/%d\n", | 1456 | dprintk(vc->dev, 4, "%s capture mode, %d timeperframe %d/%d\n", |
1461 | __func__, | 1457 | __func__, |
1462 | sp->parm.capture.capturemode, | 1458 | sp->parm.capture.capturemode, |
1463 | sp->parm.capture.timeperframe.numerator, | 1459 | sp->parm.capture.timeperframe.numerator, |
@@ -1499,7 +1495,7 @@ static int vidioc_s_parm(struct file *file, void *priv, | |||
1499 | mode.fdec = fdec; | 1495 | mode.fdec = fdec; |
1500 | sp->parm.capture.timeperframe.denominator = def_dem; | 1496 | sp->parm.capture.timeperframe.denominator = def_dem; |
1501 | s2255_set_mode(vc, &mode); | 1497 | s2255_set_mode(vc, &mode); |
1502 | dprintk(fh->dev, 4, "%s capture mode, %d timeperframe %d/%d, fdec %d\n", | 1498 | dprintk(vc->dev, 4, "%s capture mode, %d timeperframe %d/%d, fdec %d\n", |
1503 | __func__, | 1499 | __func__, |
1504 | sp->parm.capture.capturemode, | 1500 | sp->parm.capture.capturemode, |
1505 | sp->parm.capture.timeperframe.numerator, | 1501 | sp->parm.capture.timeperframe.numerator, |
@@ -1568,7 +1564,7 @@ static int vidioc_enum_frameintervals(struct file *file, void *priv, | |||
1568 | fe->type = V4L2_FRMIVAL_TYPE_DISCRETE; | 1564 | fe->type = V4L2_FRMIVAL_TYPE_DISCRETE; |
1569 | fe->discrete.denominator = is_ntsc ? 30000 : 25000; | 1565 | fe->discrete.denominator = is_ntsc ? 30000 : 25000; |
1570 | fe->discrete.numerator = (is_ntsc ? 1001 : 1000) * frm_dec[fe->index]; | 1566 | fe->discrete.numerator = (is_ntsc ? 1001 : 1000) * frm_dec[fe->index]; |
1571 | dprintk(fh->dev, 4, "%s discrete %d/%d\n", __func__, | 1567 | dprintk(vc->dev, 4, "%s discrete %d/%d\n", __func__, |
1572 | fe->discrete.numerator, | 1568 | fe->discrete.numerator, |
1573 | fe->discrete.denominator); | 1569 | fe->discrete.denominator); |
1574 | return 0; | 1570 | return 0; |
@@ -1652,8 +1648,6 @@ static int __s2255_open(struct file *file) | |||
1652 | v4l2_fh_init(&fh->fh, vdev); | 1648 | v4l2_fh_init(&fh->fh, vdev); |
1653 | v4l2_fh_add(&fh->fh); | 1649 | v4l2_fh_add(&fh->fh); |
1654 | file->private_data = &fh->fh; | 1650 | file->private_data = &fh->fh; |
1655 | fh->dev = dev; | ||
1656 | fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
1657 | fh->vc = vc; | 1651 | fh->vc = vc; |
1658 | if (!vc->configured) { | 1652 | if (!vc->configured) { |
1659 | /* configure channel to default state */ | 1653 | /* configure channel to default state */ |
@@ -1669,7 +1663,7 @@ static int __s2255_open(struct file *file) | |||
1669 | list_empty(&vc->buf_list)); | 1663 | list_empty(&vc->buf_list)); |
1670 | videobuf_queue_vmalloc_init(&fh->vb_vidq, &s2255_video_qops, | 1664 | videobuf_queue_vmalloc_init(&fh->vb_vidq, &s2255_video_qops, |
1671 | NULL, &dev->slock, | 1665 | NULL, &dev->slock, |
1672 | fh->type, | 1666 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
1673 | V4L2_FIELD_INTERLACED, | 1667 | V4L2_FIELD_INTERLACED, |
1674 | sizeof(struct s2255_buffer), | 1668 | sizeof(struct s2255_buffer), |
1675 | fh, vdev->lock); | 1669 | fh, vdev->lock); |
@@ -1692,12 +1686,10 @@ static unsigned int s2255_poll(struct file *file, | |||
1692 | struct poll_table_struct *wait) | 1686 | struct poll_table_struct *wait) |
1693 | { | 1687 | { |
1694 | struct s2255_fh *fh = file->private_data; | 1688 | struct s2255_fh *fh = file->private_data; |
1695 | struct s2255_dev *dev = fh->dev; | 1689 | struct s2255_dev *dev = fh->vc->dev; |
1696 | int rc = v4l2_ctrl_poll(file, wait); | 1690 | int rc = v4l2_ctrl_poll(file, wait); |
1697 | 1691 | ||
1698 | dprintk(dev, 100, "%s\n", __func__); | 1692 | dprintk(dev, 100, "%s\n", __func__); |
1699 | if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type) | ||
1700 | return POLLERR; | ||
1701 | mutex_lock(&dev->lock); | 1693 | mutex_lock(&dev->lock); |
1702 | rc |= videobuf_poll_stream(file, &fh->vb_vidq, wait); | 1694 | rc |= videobuf_poll_stream(file, &fh->vb_vidq, wait); |
1703 | mutex_unlock(&dev->lock); | 1695 | mutex_unlock(&dev->lock); |
@@ -1731,16 +1723,17 @@ static void s2255_destroy(struct s2255_dev *dev) | |||
1731 | static int s2255_release(struct file *file) | 1723 | static int s2255_release(struct file *file) |
1732 | { | 1724 | { |
1733 | struct s2255_fh *fh = file->private_data; | 1725 | struct s2255_fh *fh = file->private_data; |
1734 | struct s2255_dev *dev = fh->dev; | ||
1735 | struct video_device *vdev = video_devdata(file); | 1726 | struct video_device *vdev = video_devdata(file); |
1736 | struct s2255_vc *vc = fh->vc; | 1727 | struct s2255_vc *vc = fh->vc; |
1728 | struct s2255_dev *dev = vc->dev; | ||
1729 | |||
1737 | if (!dev) | 1730 | if (!dev) |
1738 | return -ENODEV; | 1731 | return -ENODEV; |
1739 | mutex_lock(&dev->lock); | 1732 | mutex_lock(&dev->lock); |
1740 | /* turn off stream */ | 1733 | /* turn off stream */ |
1741 | if (res_check(fh)) { | 1734 | if (res_check(fh)) { |
1742 | if (vc->b_acquire) | 1735 | if (vc->b_acquire) |
1743 | s2255_stop_acquire(fh->vc); | 1736 | s2255_stop_acquire(vc); |
1744 | videobuf_streamoff(&fh->vb_vidq); | 1737 | videobuf_streamoff(&fh->vb_vidq); |
1745 | res_free(fh); | 1738 | res_free(fh); |
1746 | } | 1739 | } |
@@ -1758,9 +1751,10 @@ static int s2255_mmap_v4l(struct file *file, struct vm_area_struct *vma) | |||
1758 | struct s2255_fh *fh = file->private_data; | 1751 | struct s2255_fh *fh = file->private_data; |
1759 | struct s2255_dev *dev; | 1752 | struct s2255_dev *dev; |
1760 | int ret; | 1753 | int ret; |
1754 | |||
1761 | if (!fh) | 1755 | if (!fh) |
1762 | return -ENODEV; | 1756 | return -ENODEV; |
1763 | dev = fh->dev; | 1757 | dev = fh->vc->dev; |
1764 | dprintk(dev, 4, "%s, vma=0x%08lx\n", __func__, (unsigned long)vma); | 1758 | dprintk(dev, 4, "%s, vma=0x%08lx\n", __func__, (unsigned long)vma); |
1765 | if (mutex_lock_interruptible(&dev->lock)) | 1759 | if (mutex_lock_interruptible(&dev->lock)) |
1766 | return -ERESTARTSYS; | 1760 | return -ERESTARTSYS; |