aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
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
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')
-rw-r--r--drivers/media/pci/saa7134/saa7134-empress.c1
-rw-r--r--drivers/media/pci/saa7134/saa7134-reg.h5
-rw-r--r--drivers/media/pci/saa7134/saa7134-video.c41
-rw-r--r--drivers/media/pci/saa7134/saa7134.h1
4 files changed, 46 insertions, 2 deletions
diff --git a/drivers/media/pci/saa7134/saa7134-empress.c b/drivers/media/pci/saa7134/saa7134-empress.c
index 7d4d39036009..3ae5e2c48357 100644
--- a/drivers/media/pci/saa7134/saa7134-empress.c
+++ b/drivers/media/pci/saa7134/saa7134-empress.c
@@ -264,6 +264,7 @@ static const struct v4l2_ioctl_ops ts_ioctl_ops = {
264 .vidioc_s_input = saa7134_s_input, 264 .vidioc_s_input = saa7134_s_input,
265 .vidioc_s_std = saa7134_s_std, 265 .vidioc_s_std = saa7134_s_std,
266 .vidioc_g_std = saa7134_g_std, 266 .vidioc_g_std = saa7134_g_std,
267 .vidioc_querystd = saa7134_querystd,
267 .vidioc_log_status = v4l2_ctrl_log_status, 268 .vidioc_log_status = v4l2_ctrl_log_status,
268 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, 269 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
269 .vidioc_unsubscribe_event = v4l2_event_unsubscribe, 270 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
diff --git a/drivers/media/pci/saa7134/saa7134-reg.h b/drivers/media/pci/saa7134/saa7134-reg.h
index b28b1515c8aa..b6ea6f4f9b6c 100644
--- a/drivers/media/pci/saa7134/saa7134-reg.h
+++ b/drivers/media/pci/saa7134/saa7134-reg.h
@@ -167,17 +167,22 @@
167#define SAA7134_HSYNC_START 0x106 167#define SAA7134_HSYNC_START 0x106
168#define SAA7134_HSYNC_STOP 0x107 168#define SAA7134_HSYNC_STOP 0x107
169#define SAA7134_SYNC_CTRL 0x108 169#define SAA7134_SYNC_CTRL 0x108
170#define SAA7134_SYNC_CTRL_AUFD (1 << 7)
170#define SAA7134_LUMA_CTRL 0x109 171#define SAA7134_LUMA_CTRL 0x109
172#define SAA7134_LUMA_CTRL_LDEL (1 << 5)
171#define SAA7134_DEC_LUMA_BRIGHT 0x10a 173#define SAA7134_DEC_LUMA_BRIGHT 0x10a
172#define SAA7134_DEC_LUMA_CONTRAST 0x10b 174#define SAA7134_DEC_LUMA_CONTRAST 0x10b
173#define SAA7134_DEC_CHROMA_SATURATION 0x10c 175#define SAA7134_DEC_CHROMA_SATURATION 0x10c
174#define SAA7134_DEC_CHROMA_HUE 0x10d 176#define SAA7134_DEC_CHROMA_HUE 0x10d
175#define SAA7134_CHROMA_CTRL1 0x10e 177#define SAA7134_CHROMA_CTRL1 0x10e
178#define SAA7134_CHROMA_CTRL1_AUTO0 (1 << 1)
179#define SAA7134_CHROMA_CTRL1_FCTC (1 << 2)
176#define SAA7134_CHROMA_GAIN 0x10f 180#define SAA7134_CHROMA_GAIN 0x10f
177#define SAA7134_CHROMA_CTRL2 0x110 181#define SAA7134_CHROMA_CTRL2 0x110
178#define SAA7134_MODE_DELAY_CTRL 0x111 182#define SAA7134_MODE_DELAY_CTRL 0x111
179 183
180#define SAA7134_ANALOG_ADC 0x114 184#define SAA7134_ANALOG_ADC 0x114
185#define SAA7134_ANALOG_ADC_AUTO1 (1 << 2)
181#define SAA7134_VGATE_START 0x115 186#define SAA7134_VGATE_START 0x115
182#define SAA7134_VGATE_STOP 0x116 187#define SAA7134_VGATE_STOP 0x116
183#define SAA7134_MISC_VGATE_MSB 0x117 188#define SAA7134_MISC_VGATE_MSB 0x117
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,
diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h
index 482489a682cc..968a10a860e7 100644
--- a/drivers/media/pci/saa7134/saa7134.h
+++ b/drivers/media/pci/saa7134/saa7134.h
@@ -782,6 +782,7 @@ extern struct video_device saa7134_radio_template;
782 782
783int saa7134_s_std(struct file *file, void *priv, v4l2_std_id id); 783int saa7134_s_std(struct file *file, void *priv, v4l2_std_id id);
784int saa7134_g_std(struct file *file, void *priv, v4l2_std_id *id); 784int saa7134_g_std(struct file *file, void *priv, v4l2_std_id *id);
785int saa7134_querystd(struct file *file, void *priv, v4l2_std_id *std);
785int saa7134_enum_input(struct file *file, void *priv, struct v4l2_input *i); 786int saa7134_enum_input(struct file *file, void *priv, struct v4l2_input *i);
786int saa7134_g_input(struct file *file, void *priv, unsigned int *i); 787int saa7134_g_input(struct file *file, void *priv, unsigned int *i);
787int saa7134_s_input(struct file *file, void *priv, unsigned int i); 788int saa7134_s_input(struct file *file, void *priv, unsigned int i);