aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-02-15 04:12:58 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-05 13:37:10 -0500
commit469af77a178510ed43d4d527b1b7a607c5c18bcb (patch)
treec961a3cb84e0249db90f4e00b062c57c5a3f18c2
parent39696009d0d4472606b7fb90fc635a0d0fecba60 (diff)
[media] s2255: fixes in the way standards are handled
Instead of comparing against STD_NTSC and STD_PAL compare against 60 and 50 Hz formats. That's what you really want. When the standard is changed, make sure the width and height of the format are also updated to reflect the current standard. Also replace the deprecated current_norm by the g_std ioctl. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/usb/s2255/s2255drv.c61
1 files changed, 39 insertions, 22 deletions
diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
index 9cb832517040..88f728d3b24f 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -225,6 +225,7 @@ struct s2255_channel {
225 struct s2255_dmaqueue vidq; 225 struct s2255_dmaqueue vidq;
226 struct s2255_bufferi buffer; 226 struct s2255_bufferi buffer;
227 struct s2255_mode mode; 227 struct s2255_mode mode;
228 v4l2_std_id std;
228 /* jpeg compression */ 229 /* jpeg compression */
229 unsigned jpegqual; 230 unsigned jpegqual;
230 /* capture parameters (for high quality mode full size) */ 231 /* capture parameters (for high quality mode full size) */
@@ -312,7 +313,7 @@ struct s2255_fh {
312/* Need DSP version 5+ for video status feature */ 313/* Need DSP version 5+ for video status feature */
313#define S2255_MIN_DSP_STATUS 5 314#define S2255_MIN_DSP_STATUS 5
314#define S2255_MIN_DSP_COLORFILTER 8 315#define S2255_MIN_DSP_COLORFILTER 8
315#define S2255_NORMS (V4L2_STD_PAL | V4L2_STD_NTSC) 316#define S2255_NORMS (V4L2_STD_ALL)
316 317
317/* private V4L2 controls */ 318/* private V4L2 controls */
318 319
@@ -443,27 +444,27 @@ static const struct s2255_fmt formats[] = {
443 } 444 }
444}; 445};
445 446
446static int norm_maxw(struct video_device *vdev) 447static int norm_maxw(struct s2255_channel *channel)
447{ 448{
448 return (vdev->current_norm & V4L2_STD_NTSC) ? 449 return (channel->std & V4L2_STD_525_60) ?
449 LINE_SZ_4CIFS_NTSC : LINE_SZ_4CIFS_PAL; 450 LINE_SZ_4CIFS_NTSC : LINE_SZ_4CIFS_PAL;
450} 451}
451 452
452static int norm_maxh(struct video_device *vdev) 453static int norm_maxh(struct s2255_channel *channel)
453{ 454{
454 return (vdev->current_norm & V4L2_STD_NTSC) ? 455 return (channel->std & V4L2_STD_525_60) ?
455 (NUM_LINES_1CIFS_NTSC * 2) : (NUM_LINES_1CIFS_PAL * 2); 456 (NUM_LINES_1CIFS_NTSC * 2) : (NUM_LINES_1CIFS_PAL * 2);
456} 457}
457 458
458static int norm_minw(struct video_device *vdev) 459static int norm_minw(struct s2255_channel *channel)
459{ 460{
460 return (vdev->current_norm & V4L2_STD_NTSC) ? 461 return (channel->std & V4L2_STD_525_60) ?
461 LINE_SZ_1CIFS_NTSC : LINE_SZ_1CIFS_PAL; 462 LINE_SZ_1CIFS_NTSC : LINE_SZ_1CIFS_PAL;
462} 463}
463 464
464static int norm_minh(struct video_device *vdev) 465static int norm_minh(struct s2255_channel *channel)
465{ 466{
466 return (vdev->current_norm & V4L2_STD_NTSC) ? 467 return (channel->std & V4L2_STD_525_60) ?
467 (NUM_LINES_1CIFS_NTSC) : (NUM_LINES_1CIFS_PAL); 468 (NUM_LINES_1CIFS_NTSC) : (NUM_LINES_1CIFS_PAL);
468} 469}
469 470
@@ -725,10 +726,10 @@ static int buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
725 if (channel->fmt == NULL) 726 if (channel->fmt == NULL)
726 return -EINVAL; 727 return -EINVAL;
727 728
728 if ((w < norm_minw(&channel->vdev)) || 729 if ((w < norm_minw(channel)) ||
729 (w > norm_maxw(&channel->vdev)) || 730 (w > norm_maxw(channel)) ||
730 (h < norm_minh(&channel->vdev)) || 731 (h < norm_minh(channel)) ||
731 (h > norm_maxh(&channel->vdev))) { 732 (h > norm_maxh(channel))) {
732 dprintk(4, "invalid buffer prepare\n"); 733 dprintk(4, "invalid buffer prepare\n");
733 return -EINVAL; 734 return -EINVAL;
734 } 735 }
@@ -870,8 +871,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
870 struct s2255_fh *fh = priv; 871 struct s2255_fh *fh = priv;
871 struct s2255_channel *channel = fh->channel; 872 struct s2255_channel *channel = fh->channel;
872 int is_ntsc; 873 int is_ntsc;
873 is_ntsc = 874 is_ntsc = (channel->std & V4L2_STD_525_60) ? 1 : 0;
874 (channel->vdev.current_norm & V4L2_STD_NTSC) ? 1 : 0;
875 875
876 fmt = format_by_fourcc(f->fmt.pix.pixelformat); 876 fmt = format_by_fourcc(f->fmt.pix.pixelformat);
877 877
@@ -998,8 +998,8 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
998 channel->height = f->fmt.pix.height; 998 channel->height = f->fmt.pix.height;
999 fh->vb_vidq.field = f->fmt.pix.field; 999 fh->vb_vidq.field = f->fmt.pix.field;
1000 fh->type = f->type; 1000 fh->type = f->type;
1001 if (channel->width > norm_minw(&channel->vdev)) { 1001 if (channel->width > norm_minw(channel)) {
1002 if (channel->height > norm_minh(&channel->vdev)) { 1002 if (channel->height > norm_minh(channel)) {
1003 if (channel->cap_parm.capturemode & 1003 if (channel->cap_parm.capturemode &
1004 V4L2_MODE_HIGHQUALITY) 1004 V4L2_MODE_HIGHQUALITY)
1005 mode.scale = SCALE_4CIFSI; 1005 mode.scale = SCALE_4CIFSI;
@@ -1323,7 +1323,9 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *i)
1323 struct s2255_fh *fh = priv; 1323 struct s2255_fh *fh = priv;
1324 struct s2255_mode mode; 1324 struct s2255_mode mode;
1325 struct videobuf_queue *q = &fh->vb_vidq; 1325 struct videobuf_queue *q = &fh->vb_vidq;
1326 struct s2255_channel *channel = fh->channel;
1326 int ret = 0; 1327 int ret = 0;
1328
1327 mutex_lock(&q->vb_lock); 1329 mutex_lock(&q->vb_lock);
1328 if (videobuf_queue_is_busy(q)) { 1330 if (videobuf_queue_is_busy(q)) {
1329 dprintk(1, "queue busy\n"); 1331 dprintk(1, "queue busy\n");
@@ -1336,24 +1338,30 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *i)
1336 goto out_s_std; 1338 goto out_s_std;
1337 } 1339 }
1338 mode = fh->channel->mode; 1340 mode = fh->channel->mode;
1339 if (*i & V4L2_STD_NTSC) { 1341 if (*i & V4L2_STD_525_60) {
1340 dprintk(4, "%s NTSC\n", __func__); 1342 dprintk(4, "%s 60 Hz\n", __func__);
1341 /* if changing format, reset frame decimation/intervals */ 1343 /* if changing format, reset frame decimation/intervals */
1342 if (mode.format != FORMAT_NTSC) { 1344 if (mode.format != FORMAT_NTSC) {
1343 mode.restart = 1; 1345 mode.restart = 1;
1344 mode.format = FORMAT_NTSC; 1346 mode.format = FORMAT_NTSC;
1345 mode.fdec = FDEC_1; 1347 mode.fdec = FDEC_1;
1348 channel->width = LINE_SZ_4CIFS_NTSC;
1349 channel->height = NUM_LINES_4CIFS_NTSC * 2;
1346 } 1350 }
1347 } else if (*i & V4L2_STD_PAL) { 1351 } else if (*i & V4L2_STD_625_50) {
1348 dprintk(4, "%s PAL\n", __func__); 1352 dprintk(4, "%s 50 Hz\n", __func__);
1349 if (mode.format != FORMAT_PAL) { 1353 if (mode.format != FORMAT_PAL) {
1350 mode.restart = 1; 1354 mode.restart = 1;
1351 mode.format = FORMAT_PAL; 1355 mode.format = FORMAT_PAL;
1352 mode.fdec = FDEC_1; 1356 mode.fdec = FDEC_1;
1357 channel->width = LINE_SZ_4CIFS_PAL;
1358 channel->height = NUM_LINES_4CIFS_PAL * 2;
1353 } 1359 }
1354 } else { 1360 } else {
1355 ret = -EINVAL; 1361 ret = -EINVAL;
1362 goto out_s_std;
1356 } 1363 }
1364 fh->channel->std = *i;
1357 if (mode.restart) 1365 if (mode.restart)
1358 s2255_set_mode(fh->channel, &mode); 1366 s2255_set_mode(fh->channel, &mode);
1359out_s_std: 1367out_s_std:
@@ -1361,6 +1369,14 @@ out_s_std:
1361 return ret; 1369 return ret;
1362} 1370}
1363 1371
1372static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *i)
1373{
1374 struct s2255_fh *fh = priv;
1375
1376 *i = fh->channel->std;
1377 return 0;
1378}
1379
1364/* Sensoray 2255 is a multiple channel capture device. 1380/* Sensoray 2255 is a multiple channel capture device.
1365 It does not have a "crossbar" of inputs. 1381 It does not have a "crossbar" of inputs.
1366 We use one V4L device per channel. The user must 1382 We use one V4L device per channel. The user must
@@ -1815,6 +1831,7 @@ static const struct v4l2_ioctl_ops s2255_ioctl_ops = {
1815 .vidioc_qbuf = vidioc_qbuf, 1831 .vidioc_qbuf = vidioc_qbuf,
1816 .vidioc_dqbuf = vidioc_dqbuf, 1832 .vidioc_dqbuf = vidioc_dqbuf,
1817 .vidioc_s_std = vidioc_s_std, 1833 .vidioc_s_std = vidioc_s_std,
1834 .vidioc_g_std = vidioc_g_std,
1818 .vidioc_enum_input = vidioc_enum_input, 1835 .vidioc_enum_input = vidioc_enum_input,
1819 .vidioc_g_input = vidioc_g_input, 1836 .vidioc_g_input = vidioc_g_input,
1820 .vidioc_s_input = vidioc_s_input, 1837 .vidioc_s_input = vidioc_s_input,
@@ -1851,7 +1868,6 @@ static struct video_device template = {
1851 .ioctl_ops = &s2255_ioctl_ops, 1868 .ioctl_ops = &s2255_ioctl_ops,
1852 .release = s2255_video_device_release, 1869 .release = s2255_video_device_release,
1853 .tvnorms = S2255_NORMS, 1870 .tvnorms = S2255_NORMS,
1854 .current_norm = V4L2_STD_NTSC_M,
1855}; 1871};
1856 1872
1857static const struct v4l2_ctrl_ops s2255_ctrl_ops = { 1873static const struct v4l2_ctrl_ops s2255_ctrl_ops = {
@@ -2265,6 +2281,7 @@ static int s2255_board_init(struct s2255_dev *dev)
2265 channel->jpegqual = S2255_DEF_JPEG_QUAL; 2281 channel->jpegqual = S2255_DEF_JPEG_QUAL;
2266 channel->width = LINE_SZ_4CIFS_NTSC; 2282 channel->width = LINE_SZ_4CIFS_NTSC;
2267 channel->height = NUM_LINES_4CIFS_NTSC * 2; 2283 channel->height = NUM_LINES_4CIFS_NTSC * 2;
2284 channel->std = V4L2_STD_NTSC_M;
2268 channel->fmt = &formats[0]; 2285 channel->fmt = &formats[0];
2269 channel->mode.restart = 1; 2286 channel->mode.restart = 1;
2270 channel->req_image_size = get_transfer_size(&mode_def); 2287 channel->req_image_size = get_transfer_size(&mode_def);