aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci/saa7134/saa7134-video.c
diff options
context:
space:
mode:
authorMikhail Domrachev <mihail.domrychev@comexp.ru>2014-04-01 08:28:17 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-05-23 11:56:01 -0400
commit707b7f80b5873da7728979ba1b81c0daae736762 (patch)
tree6fb9d84722c00ef48b1f98b9a5f63f4960b405eb /drivers/media/pci/saa7134/saa7134-video.c
parenta112fbaf782f08cc837ee6bbd10ca8900d0e4b91 (diff)
[media] saa7134: add vidioc_querystd
Signed-off-by: Mikhail Domrachev <mihail.domrychev@comexp.ru> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/pci/saa7134/saa7134-video.c')
-rw-r--r--drivers/media/pci/saa7134/saa7134-video.c41
1 files changed, 39 insertions, 2 deletions
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c
index e5b2bebaf010..16140ad6ffb3 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -452,19 +452,26 @@ static void video_mux(struct saa7134_dev *dev, int input)
452 452
453static void saa7134_set_decoder(struct saa7134_dev *dev) 453static void saa7134_set_decoder(struct saa7134_dev *dev)
454{ 454{
455 int luma_control, sync_control, mux; 455 int luma_control, sync_control, chroma_ctrl1, mux;
456 456
457 struct saa7134_tvnorm *norm = dev->tvnorm; 457 struct saa7134_tvnorm *norm = dev->tvnorm;
458 mux = card_in(dev, dev->ctl_input).vmux; 458 mux = card_in(dev, dev->ctl_input).vmux;
459 459
460 luma_control = norm->luma_control; 460 luma_control = norm->luma_control;
461 sync_control = norm->sync_control; 461 sync_control = norm->sync_control;
462 chroma_ctrl1 = norm->chroma_ctrl1;
462 463
463 if (mux > 5) 464 if (mux > 5)
464 luma_control |= 0x80; /* svideo */ 465 luma_control |= 0x80; /* svideo */
465 if (noninterlaced || dev->nosignal) 466 if (noninterlaced || dev->nosignal)
466 sync_control |= 0x20; 467 sync_control |= 0x20;
467 468
469 /* switch on auto standard detection */
470 sync_control |= SAA7134_SYNC_CTRL_AUFD;
471 chroma_ctrl1 |= SAA7134_CHROMA_CTRL1_AUTO0;
472 chroma_ctrl1 &= ~SAA7134_CHROMA_CTRL1_FCTC;
473 luma_control &= ~SAA7134_LUMA_CTRL_LDEL;
474
468 /* setup video decoder */ 475 /* setup video decoder */
469 saa_writeb(SAA7134_INCR_DELAY, 0x08); 476 saa_writeb(SAA7134_INCR_DELAY, 0x08);
470 saa_writeb(SAA7134_ANALOG_IN_CTRL1, 0xc0 | mux); 477 saa_writeb(SAA7134_ANALOG_IN_CTRL1, 0xc0 | mux);
@@ -487,7 +494,7 @@ static void saa7134_set_decoder(struct saa7134_dev *dev)
487 dev->ctl_invert ? -dev->ctl_saturation : dev->ctl_saturation); 494 dev->ctl_invert ? -dev->ctl_saturation : dev->ctl_saturation);
488 495
489 saa_writeb(SAA7134_DEC_CHROMA_HUE, dev->ctl_hue); 496 saa_writeb(SAA7134_DEC_CHROMA_HUE, dev->ctl_hue);
490 saa_writeb(SAA7134_CHROMA_CTRL1, norm->chroma_ctrl1); 497 saa_writeb(SAA7134_CHROMA_CTRL1, chroma_ctrl1);
491 saa_writeb(SAA7134_CHROMA_GAIN, norm->chroma_gain); 498 saa_writeb(SAA7134_CHROMA_GAIN, norm->chroma_gain);
492 499
493 saa_writeb(SAA7134_CHROMA_CTRL2, norm->chroma_ctrl2); 500 saa_writeb(SAA7134_CHROMA_CTRL2, norm->chroma_ctrl2);
@@ -1686,6 +1693,35 @@ int saa7134_g_std(struct file *file, void *priv, v4l2_std_id *id)
1686} 1693}
1687EXPORT_SYMBOL_GPL(saa7134_g_std); 1694EXPORT_SYMBOL_GPL(saa7134_g_std);
1688 1695
1696static v4l2_std_id saa7134_read_std(struct saa7134_dev *dev)
1697{
1698 static v4l2_std_id stds[] = {
1699 V4L2_STD_UNKNOWN,
1700 V4L2_STD_NTSC,
1701 V4L2_STD_PAL,
1702 V4L2_STD_SECAM };
1703
1704 v4l2_std_id result = 0;
1705
1706 u8 st1 = saa_readb(SAA7134_STATUS_VIDEO1);
1707 u8 st2 = saa_readb(SAA7134_STATUS_VIDEO2);
1708
1709 if (!(st2 & 0x1)) /* RDCAP == 0 */
1710 result = V4L2_STD_UNKNOWN;
1711 else
1712 result = stds[st1 & 0x03];
1713
1714 return result;
1715}
1716
1717int saa7134_querystd(struct file *file, void *priv, v4l2_std_id *std)
1718{
1719 struct saa7134_dev *dev = video_drvdata(file);
1720 *std &= saa7134_read_std(dev);
1721 return 0;
1722}
1723EXPORT_SYMBOL_GPL(saa7134_querystd);
1724
1689static int saa7134_cropcap(struct file *file, void *priv, 1725static int saa7134_cropcap(struct file *file, void *priv,
1690 struct v4l2_cropcap *cap) 1726 struct v4l2_cropcap *cap)
1691{ 1727{
@@ -2079,6 +2115,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
2079 .vidioc_dqbuf = saa7134_dqbuf, 2115 .vidioc_dqbuf = saa7134_dqbuf,
2080 .vidioc_s_std = saa7134_s_std, 2116 .vidioc_s_std = saa7134_s_std,
2081 .vidioc_g_std = saa7134_g_std, 2117 .vidioc_g_std = saa7134_g_std,
2118 .vidioc_querystd = saa7134_querystd,
2082 .vidioc_enum_input = saa7134_enum_input, 2119 .vidioc_enum_input = saa7134_enum_input,
2083 .vidioc_g_input = saa7134_g_input, 2120 .vidioc_g_input = saa7134_g_input,
2084 .vidioc_s_input = saa7134_s_input, 2121 .vidioc_s_input = saa7134_s_input,