linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 00/14] QUERYSTD fixes
@ 2013-05-29 14:18 Hans Verkuil
  2013-05-29 14:18 ` [RFC PATCH 01/14] adv7183: fix querystd Hans Verkuil
                   ` (13 more replies)
  0 siblings, 14 replies; 17+ messages in thread
From: Hans Verkuil @ 2013-05-29 14:18 UTC (permalink / raw)
  To: linux-media

This patch series cleans up various drivers with respect to their
VIDIOC_QUERYSTD behavior. The main reason for doing this is to ensure
that the correct std value is returned when there is no signal detected.
It should return V4L2_STD_UNKNOWN. Due to a poorly worded specification
several drivers returned STD_ALL.

As mentioned in an old RFC the current behavior is inconsistent:

- saa7115, ks0127, saa7191 return 0 with std set to V4L2_STD_ALL
- adv7180, vpx3220 return 0 with std set to V4L2_STD_UNKNOWN
- saa7110 returns 0 with std set to the current std
- bt819 and bttv do not handle this case at all, and just pick 50 Hz or 60 Hz
- tvp514x returns -EINVAL.

Besides fixing this I also update the documentation and fix the misuse
of s_std(V4L2_STD_ALL) in several drivers. V4L2_STD_ALL is sometimes used
to enable autodetect mode, which is non-standard and in general should not
be done: if a receiver switches from a 60 Hz to a 50 Hz format automatically,
then this can in theory lead to buffer overruns in a DMA engine since a 50 Hz
frame is larger than the 60 Hz frame.

This behavior is removed in those drivers where it is clearly bogus.

After this patch series the following drivers still have problems:

- adv7180: supports the non-standard autodetect mode
- sta2x11: ditto (uses adv7180)

The adv7180 driver should implement querystd in the same manner as the adv7183
driver, and then the sta2x11 can be fixed as well.

- timblogiw: this calls querystd whenever a video node is opened. That's
  obviously a bad idea, but it's a fair amount of work to fix this and nobody
  I know can test this driver.

Regards,

	Hans


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [RFC PATCH 01/14] adv7183: fix querystd
  2013-05-29 14:18 [RFC PATCH 00/14] QUERYSTD fixes Hans Verkuil
@ 2013-05-29 14:18 ` Hans Verkuil
  2013-05-31  7:50   ` Scott Jiang
  2013-05-29 14:18 ` [RFC PATCH 02/14] bt819: " Hans Verkuil
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 17+ messages in thread
From: Hans Verkuil @ 2013-05-29 14:18 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil, Scott Jiang

From: Hans Verkuil <hans.verkuil@cisco.com>

If no signal is detected, return V4L2_STD_UNKNOWN. Otherwise AND the standard
with the detected standards.

Note that the v4l2 core initializes the std with tvnorms before calling the
querystd ioctl.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Scott Jiang <scott.jiang.linux@gmail.com>
---
 drivers/media/i2c/adv7183.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/i2c/adv7183.c b/drivers/media/i2c/adv7183.c
index 7c48e22..b5e51d8 100644
--- a/drivers/media/i2c/adv7183.c
+++ b/drivers/media/i2c/adv7183.c
@@ -375,28 +375,28 @@ static int adv7183_querystd(struct v4l2_subdev *sd, v4l2_std_id *std)
 	reg = adv7183_read(sd, ADV7183_STATUS_1);
 	switch ((reg >> 0x4) & 0x7) {
 	case 0:
-		*std = V4L2_STD_NTSC;
+		*std &= V4L2_STD_NTSC;
 		break;
 	case 1:
-		*std = V4L2_STD_NTSC_443;
+		*std &= V4L2_STD_NTSC_443;
 		break;
 	case 2:
-		*std = V4L2_STD_PAL_M;
+		*std &= V4L2_STD_PAL_M;
 		break;
 	case 3:
-		*std = V4L2_STD_PAL_60;
+		*std &= V4L2_STD_PAL_60;
 		break;
 	case 4:
-		*std = V4L2_STD_PAL;
+		*std &= V4L2_STD_PAL;
 		break;
 	case 5:
-		*std = V4L2_STD_SECAM;
+		*std &= V4L2_STD_SECAM;
 		break;
 	case 6:
-		*std = V4L2_STD_PAL_Nc;
+		*std &= V4L2_STD_PAL_Nc;
 		break;
 	case 7:
-		*std = V4L2_STD_SECAM;
+		*std &= V4L2_STD_SECAM;
 		break;
 	default:
 		*std = V4L2_STD_UNKNOWN;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RFC PATCH 02/14] bt819: fix querystd
  2013-05-29 14:18 [RFC PATCH 00/14] QUERYSTD fixes Hans Verkuil
  2013-05-29 14:18 ` [RFC PATCH 01/14] adv7183: fix querystd Hans Verkuil
@ 2013-05-29 14:18 ` Hans Verkuil
  2013-05-29 14:18 ` [RFC PATCH 03/14] ks0127: " Hans Verkuil
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2013-05-29 14:18 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Return V4L2_STD_UNKNOWN if no signal is detected.
Otherwise AND the standard mask with the detected standards.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/i2c/bt819.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/bt819.c b/drivers/media/i2c/bt819.c
index ee9ed67..3c0a5ab 100644
--- a/drivers/media/i2c/bt819.c
+++ b/drivers/media/i2c/bt819.c
@@ -217,15 +217,17 @@ static int bt819_status(struct v4l2_subdev *sd, u32 *pstatus, v4l2_std_id *pstd)
 	struct bt819 *decoder = to_bt819(sd);
 	int status = bt819_read(decoder, 0x00);
 	int res = V4L2_IN_ST_NO_SIGNAL;
-	v4l2_std_id std;
+	v4l2_std_id std = pstd ? *pstd : V4L2_STD_ALL;
 
 	if ((status & 0x80))
 		res = 0;
+	else
+		std = V4L2_STD_UNKNOWN;
 
 	if ((status & 0x10))
-		std = V4L2_STD_PAL;
+		std &= V4L2_STD_PAL;
 	else
-		std = V4L2_STD_NTSC;
+		std &= V4L2_STD_NTSC;
 	if (pstd)
 		*pstd = std;
 	if (pstatus)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RFC PATCH 03/14] ks0127: fix querystd
  2013-05-29 14:18 [RFC PATCH 00/14] QUERYSTD fixes Hans Verkuil
  2013-05-29 14:18 ` [RFC PATCH 01/14] adv7183: fix querystd Hans Verkuil
  2013-05-29 14:18 ` [RFC PATCH 02/14] bt819: " Hans Verkuil
@ 2013-05-29 14:18 ` Hans Verkuil
  2013-05-29 14:18 ` [RFC PATCH 04/14] saa7110: " Hans Verkuil
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2013-05-29 14:18 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Return V4L2_STD_UNKNOWN if no signal is detected.
Otherwise AND the standard mask with the detected standards.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/i2c/ks0127.c |   17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/ks0127.c b/drivers/media/i2c/ks0127.c
index c722776..f7250e5 100644
--- a/drivers/media/i2c/ks0127.c
+++ b/drivers/media/i2c/ks0127.c
@@ -616,17 +616,24 @@ static int ks0127_status(struct v4l2_subdev *sd, u32 *pstatus, v4l2_std_id *pstd
 {
 	int stat = V4L2_IN_ST_NO_SIGNAL;
 	u8 status;
-	v4l2_std_id std = V4L2_STD_ALL;
+	v4l2_std_id std = pstd ? *pstd : V4L2_STD_ALL;
 
 	status = ks0127_read(sd, KS_STAT);
 	if (!(status & 0x20))		 /* NOVID not set */
 		stat = 0;
-	if (!(status & 0x01))		      /* CLOCK set */
+	if (!(status & 0x01)) {		      /* CLOCK set */
 		stat |= V4L2_IN_ST_NO_COLOR;
-	if ((status & 0x08))		   /* PALDET set */
-		std = V4L2_STD_PAL;
+		std = V4L2_STD_UNKNOWN;
+	} else {
+		if ((status & 0x08))		   /* PALDET set */
+			std &= V4L2_STD_PAL;
+		else
+			std &= V4L2_STD_NTSC;
+	}
+	if ((status & 0x10))		   /* PALDET set */
+		std &= V4L2_STD_525_60;
 	else
-		std = V4L2_STD_NTSC;
+		std &= V4L2_STD_625_50;
 	if (pstd)
 		*pstd = std;
 	if (pstatus)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RFC PATCH 04/14] saa7110: fix querystd
  2013-05-29 14:18 [RFC PATCH 00/14] QUERYSTD fixes Hans Verkuil
                   ` (2 preceding siblings ...)
  2013-05-29 14:18 ` [RFC PATCH 03/14] ks0127: " Hans Verkuil
@ 2013-05-29 14:18 ` Hans Verkuil
  2013-05-29 14:18 ` [RFC PATCH 05/14] saa7115: " Hans Verkuil
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2013-05-29 14:18 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Return V4L2_STD_UNKNOWN if no signal is detected.
Otherwise AND the standard mask with the detected standards.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/i2c/saa7110.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/saa7110.c b/drivers/media/i2c/saa7110.c
index e4026aa..5480a18 100644
--- a/drivers/media/i2c/saa7110.c
+++ b/drivers/media/i2c/saa7110.c
@@ -203,7 +203,7 @@ static v4l2_std_id determine_norm(struct v4l2_subdev *sd)
 	status = saa7110_read(sd);
 	if (status & 0x40) {
 		v4l2_dbg(1, debug, sd, "status=0x%02x (no signal)\n", status);
-		return decoder->norm;	/* no change*/
+		return V4L2_STD_UNKNOWN;
 	}
 	if ((status & 3) == 0) {
 		saa7110_write(sd, 0x06, 0x83);
@@ -265,7 +265,7 @@ static int saa7110_g_input_status(struct v4l2_subdev *sd, u32 *pstatus)
 
 static int saa7110_querystd(struct v4l2_subdev *sd, v4l2_std_id *std)
 {
-	*(v4l2_std_id *)std = determine_norm(sd);
+	*std &= determine_norm(sd);
 	return 0;
 }
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RFC PATCH 05/14] saa7115: fix querystd
  2013-05-29 14:18 [RFC PATCH 00/14] QUERYSTD fixes Hans Verkuil
                   ` (3 preceding siblings ...)
  2013-05-29 14:18 ` [RFC PATCH 04/14] saa7110: " Hans Verkuil
@ 2013-05-29 14:18 ` Hans Verkuil
  2013-05-29 14:18 ` [RFC PATCH 06/14] saa7191: " Hans Verkuil
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2013-05-29 14:18 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Return V4L2_STD_UNKNOWN if no signal is detected.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/i2c/saa7115.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
index 18cf0bf..e247fdd 100644
--- a/drivers/media/i2c/saa7115.c
+++ b/drivers/media/i2c/saa7115.c
@@ -1420,6 +1420,7 @@ static int saa711x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std)
 			*std &= V4L2_STD_SECAM;
 			break;
 		default:
+			*std = V4L2_STD_UNKNOWN;
 			/* Can't detect anything */
 			break;
 		}
@@ -1428,8 +1429,10 @@ static int saa711x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std)
 	v4l2_dbg(1, debug, sd, "Status byte 2 (0x1f)=0x%02x\n", reg1f);
 
 	/* horizontal/vertical not locked */
-	if (reg1f & 0x40)
+	if (reg1f & 0x40) {
+		*std = V4L2_STD_UNKNOWN;
 		goto ret;
+	}
 
 	if (reg1f & 0x20)
 		*std &= V4L2_STD_525_60;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RFC PATCH 06/14] saa7191: fix querystd
  2013-05-29 14:18 [RFC PATCH 00/14] QUERYSTD fixes Hans Verkuil
                   ` (4 preceding siblings ...)
  2013-05-29 14:18 ` [RFC PATCH 05/14] saa7115: " Hans Verkuil
@ 2013-05-29 14:18 ` Hans Verkuil
  2013-05-29 14:19 ` [RFC PATCH 07/14] tvp514x: " Hans Verkuil
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2013-05-29 14:18 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Return V4L2_STD_UNKNOWN if no signal is detected.
Otherwise AND the standard mask with the detected standards.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/i2c/saa7191.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/media/i2c/saa7191.c b/drivers/media/i2c/saa7191.c
index 84f7899..9d8ea2a 100644
--- a/drivers/media/i2c/saa7191.c
+++ b/drivers/media/i2c/saa7191.c
@@ -272,7 +272,7 @@ static int saa7191_querystd(struct v4l2_subdev *sd, v4l2_std_id *norm)
 
 	dprintk("SAA7191 extended signal auto-detection...\n");
 
-	*norm = V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM;
+	*norm &= V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM;
 	stdc &= ~SAA7191_STDC_SECS;
 	ctl3 &= ~(SAA7191_CTL3_FSEL);
 
@@ -303,7 +303,7 @@ static int saa7191_querystd(struct v4l2_subdev *sd, v4l2_std_id *norm)
 	if (status & SAA7191_STATUS_FIDT) {
 		/* 60Hz signal -> NTSC */
 		dprintk("60Hz signal: NTSC\n");
-		*norm = V4L2_STD_NTSC;
+		*norm &= V4L2_STD_NTSC;
 		return 0;
 	}
 
@@ -325,12 +325,13 @@ static int saa7191_querystd(struct v4l2_subdev *sd, v4l2_std_id *norm)
 	if (status & SAA7191_STATUS_FIDT) {
 		dprintk("No 50Hz signal\n");
 		saa7191_s_std(sd, old_norm);
-		return -EAGAIN;
+		*norm = V4L2_STD_UNKNOWN;
+		return 0;
 	}
 
 	if (status & SAA7191_STATUS_CODE) {
 		dprintk("PAL\n");
-		*norm = V4L2_STD_PAL;
+		*norm &= V4L2_STD_PAL;
 		return saa7191_s_std(sd, old_norm);
 	}
 
@@ -350,18 +351,19 @@ static int saa7191_querystd(struct v4l2_subdev *sd, v4l2_std_id *norm)
 	/* not 50Hz ? */
 	if (status & SAA7191_STATUS_FIDT) {
 		dprintk("No 50Hz signal\n");
-		err = -EAGAIN;
+		*norm = V4L2_STD_UNKNOWN;
 		goto out;
 	}
 
 	if (status & SAA7191_STATUS_CODE) {
 		/* Color detected -> SECAM */
 		dprintk("SECAM\n");
-		*norm = V4L2_STD_SECAM;
+		*norm &= V4L2_STD_SECAM;
 		return saa7191_s_std(sd, old_norm);
 	}
 
 	dprintk("No color detected with SECAM - Going back to PAL.\n");
+	*norm = V4L2_STD_UNKNOWN;
 
 out:
 	return saa7191_s_std(sd, old_norm);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RFC PATCH 07/14] tvp514x: fix querystd
  2013-05-29 14:18 [RFC PATCH 00/14] QUERYSTD fixes Hans Verkuil
                   ` (5 preceding siblings ...)
  2013-05-29 14:18 ` [RFC PATCH 06/14] saa7191: " Hans Verkuil
@ 2013-05-29 14:19 ` Hans Verkuil
  2013-05-30  7:07   ` Prabhakar Lad
  2013-05-29 14:19 ` [RFC PATCH 08/14] vpx3220: " Hans Verkuil
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 17+ messages in thread
From: Hans Verkuil @ 2013-05-29 14:19 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Return V4L2_STD_UNKNOWN if no signal is detected.
Otherwise AND the standard mask with the detected standards.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/i2c/tvp514x.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
index 7438e01..c2b343b 100644
--- a/drivers/media/i2c/tvp514x.c
+++ b/drivers/media/i2c/tvp514x.c
@@ -543,8 +543,6 @@ static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id)
 	if (std_id == NULL)
 		return -EINVAL;
 
-	*std_id = V4L2_STD_UNKNOWN;
-
 	/* To query the standard the TVP514x must power on the ADCs. */
 	if (!decoder->streaming) {
 		tvp514x_s_stream(sd, 1);
@@ -553,8 +551,10 @@ static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id)
 
 	/* query the current standard */
 	current_std = tvp514x_query_current_std(sd);
-	if (current_std == STD_INVALID)
+	if (current_std == STD_INVALID) {
+		*std_id = V4L2_STD_UNKNOWN;
 		return 0;
+	}
 
 	input_sel = decoder->input;
 
@@ -595,10 +595,12 @@ static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id)
 	}
 	/* check whether signal is locked */
 	sync_lock_status = tvp514x_read_reg(sd, REG_STATUS1);
-	if (lock_mask != (sync_lock_status & lock_mask))
+	if (lock_mask != (sync_lock_status & lock_mask)) {
+		*std_id = V4L2_STD_UNKNOWN;
 		return 0;	/* No input detected */
+	}
 
-	*std_id = decoder->std_list[current_std].standard.id;
+	*std_id &= decoder->std_list[current_std].standard.id;
 
 	v4l2_dbg(1, debug, sd, "Current STD: %s\n",
 			decoder->std_list[current_std].standard.name);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RFC PATCH 08/14] vpx3220: fix querystd
  2013-05-29 14:18 [RFC PATCH 00/14] QUERYSTD fixes Hans Verkuil
                   ` (6 preceding siblings ...)
  2013-05-29 14:19 ` [RFC PATCH 07/14] tvp514x: " Hans Verkuil
@ 2013-05-29 14:19 ` Hans Verkuil
  2013-05-29 14:19 ` [RFC PATCH 09/14] bttv: " Hans Verkuil
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2013-05-29 14:19 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Return V4L2_STD_UNKNOWN if no signal is detected.
Otherwise AND the standard mask with the detected standards.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/i2c/vpx3220.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/vpx3220.c b/drivers/media/i2c/vpx3220.c
index f02e74b..02c1e39 100644
--- a/drivers/media/i2c/vpx3220.c
+++ b/drivers/media/i2c/vpx3220.c
@@ -297,7 +297,7 @@ static int vpx3220_init(struct v4l2_subdev *sd, u32 val)
 static int vpx3220_status(struct v4l2_subdev *sd, u32 *pstatus, v4l2_std_id *pstd)
 {
 	int res = V4L2_IN_ST_NO_SIGNAL, status;
-	v4l2_std_id std = 0;
+	v4l2_std_id std = pstd ? *pstd : V4L2_STD_ALL;
 
 	status = vpx3220_fp_read(sd, 0x0f3);
 
@@ -314,19 +314,21 @@ static int vpx3220_status(struct v4l2_subdev *sd, u32 *pstatus, v4l2_std_id *pst
 		case 0x10:
 		case 0x14:
 		case 0x18:
-			std = V4L2_STD_PAL;
+			std &= V4L2_STD_PAL;
 			break;
 
 		case 0x08:
-			std = V4L2_STD_SECAM;
+			std &= V4L2_STD_SECAM;
 			break;
 
 		case 0x04:
 		case 0x0c:
 		case 0x1c:
-			std = V4L2_STD_NTSC;
+			std &= V4L2_STD_NTSC;
 			break;
 		}
+	} else {
+		std = V4L2_STD_UNKNOWN;
 	}
 	if (pstd)
 		*pstd = std;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RFC PATCH 09/14] bttv: fix querystd
  2013-05-29 14:18 [RFC PATCH 00/14] QUERYSTD fixes Hans Verkuil
                   ` (7 preceding siblings ...)
  2013-05-29 14:19 ` [RFC PATCH 08/14] vpx3220: " Hans Verkuil
@ 2013-05-29 14:19 ` Hans Verkuil
  2013-05-29 14:19 ` [RFC PATCH 10/14] zoran: remove bogus autodetect mode in set_norm Hans Verkuil
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2013-05-29 14:19 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

AND the standard mask with the detected standards.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/pci/bt8xx/bttv-driver.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index a334c94..555d37c 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -1761,9 +1761,9 @@ static int bttv_querystd(struct file *file, void *f, v4l2_std_id *id)
 	struct bttv *btv = fh->btv;
 
 	if (btread(BT848_DSTATUS) & BT848_DSTATUS_NUML)
-		*id = V4L2_STD_625_50;
+		*id &= V4L2_STD_625_50;
 	else
-		*id = V4L2_STD_525_60;
+		*id &= V4L2_STD_525_60;
 	return 0;
 }
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RFC PATCH 10/14] zoran: remove bogus autodetect mode in set_norm
  2013-05-29 14:18 [RFC PATCH 00/14] QUERYSTD fixes Hans Verkuil
                   ` (8 preceding siblings ...)
  2013-05-29 14:19 ` [RFC PATCH 09/14] bttv: " Hans Verkuil
@ 2013-05-29 14:19 ` Hans Verkuil
  2013-05-29 14:19 ` [RFC PATCH 11/14] v4l2-ioctl: clarify querystd comment Hans Verkuil
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2013-05-29 14:19 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Currently, if the norm set is V4L2_STD_ALL, then autodetect the current
standard and use that. This is non-standard behavior, and in fact it hasn't
worked for a very long time: before s_std is called in this driver, the
v4l2 core will mask it with the tvnorms field. So even if the application
passes V4L2_STD_ALL, the zoran driver will always see a subset of that.

Since nobody ever complained about this we just remove this non-standard
functionality.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/pci/zoran/zoran_driver.c |   23 -----------------------
 1 file changed, 23 deletions(-)

diff --git a/drivers/media/pci/zoran/zoran_driver.c b/drivers/media/pci/zoran/zoran_driver.c
index 1168a84..4ec2708 100644
--- a/drivers/media/pci/zoran/zoran_driver.c
+++ b/drivers/media/pci/zoran/zoran_driver.c
@@ -1456,29 +1456,6 @@ zoran_set_norm (struct zoran *zr,
 		return -EINVAL;
 	}
 
-	if (norm == V4L2_STD_ALL) {
-		unsigned int status = 0;
-		v4l2_std_id std = 0;
-
-		decoder_call(zr, video, querystd, &std);
-		decoder_call(zr, core, s_std, std);
-
-		/* let changes come into effect */
-		ssleep(2);
-
-		decoder_call(zr, video, g_input_status, &status);
-		if (status & V4L2_IN_ST_NO_SIGNAL) {
-			dprintk(1,
-				KERN_ERR
-				"%s: %s - no norm detected\n",
-				ZR_DEVNAME(zr), __func__);
-			/* reset norm */
-			decoder_call(zr, core, s_std, zr->norm);
-			return -EIO;
-		}
-
-		norm = std;
-	}
 	if (norm & V4L2_STD_SECAM)
 		zr->timing = zr->card.tvn[2];
 	else if (norm & V4L2_STD_NTSC)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RFC PATCH 11/14] v4l2-ioctl: clarify querystd comment.
  2013-05-29 14:18 [RFC PATCH 00/14] QUERYSTD fixes Hans Verkuil
                   ` (9 preceding siblings ...)
  2013-05-29 14:19 ` [RFC PATCH 10/14] zoran: remove bogus autodetect mode in set_norm Hans Verkuil
@ 2013-05-29 14:19 ` Hans Verkuil
  2013-05-29 14:19 ` [RFC PATCH 12/14] DocBook/media/v4l: clarify the QUERYSTD documentation Hans Verkuil
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2013-05-29 14:19 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Improve the querystd comment.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/v4l2-core/v4l2-ioctl.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index f81bda1..768f606 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1407,10 +1407,10 @@ static int v4l_querystd(const struct v4l2_ioctl_ops *ops,
 	v4l2_std_id *p = arg;
 
 	/*
-	 * If nothing detected, it should return all supported
-	 * standard.
-	 * Drivers just need to mask the std argument, in order
-	 * to remove the standards that don't apply from the mask.
+	 * If no signal is detected, then the driver should return
+	 * V4L2_STD_UNKNOWN. Otherwise it should return tvnorms with
+	 * any standards that do not apply removed.
+	 *
 	 * This means that tuners, audio and video decoders can join
 	 * their efforts to improve the standards detection.
 	 */
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RFC PATCH 12/14] DocBook/media/v4l: clarify the QUERYSTD documentation.
  2013-05-29 14:18 [RFC PATCH 00/14] QUERYSTD fixes Hans Verkuil
                   ` (10 preceding siblings ...)
  2013-05-29 14:19 ` [RFC PATCH 11/14] v4l2-ioctl: clarify querystd comment Hans Verkuil
@ 2013-05-29 14:19 ` Hans Verkuil
  2013-05-29 14:19 ` [RFC PATCH 13/14] tvp5150: fix s_std support Hans Verkuil
  2013-05-29 14:19 ` [RFC PATCH 14/14] cx23885: don't implement querystd if it doesn't do anything Hans Verkuil
  13 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2013-05-29 14:19 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Explicitly mention that this ioctl should return V4L2_STD_UNKNOWN if
not signal was detected.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 Documentation/DocBook/media/v4l/vidioc-querystd.xml |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/media/v4l/vidioc-querystd.xml b/Documentation/DocBook/media/v4l/vidioc-querystd.xml
index fe80a18..2223485 100644
--- a/Documentation/DocBook/media/v4l/vidioc-querystd.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-querystd.xml
@@ -54,7 +54,8 @@ standard automatically. To do so, applications call <constant>
 VIDIOC_QUERYSTD</constant> with a pointer to a &v4l2-std-id; type. The
 driver stores here a set of candidates, this can be a single flag or a
 set of supported standards if for example the hardware can only
-distinguish between 50 and 60 Hz systems. When detection is not
+distinguish between 50 and 60 Hz systems. If no signal was detected,
+then the driver will return V4L2_STD_UNKNOWN. When detection is not
 possible or fails, the set must contain all standards supported by the
 current video input or output.</para>
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RFC PATCH 13/14] tvp5150: fix s_std support
  2013-05-29 14:18 [RFC PATCH 00/14] QUERYSTD fixes Hans Verkuil
                   ` (11 preceding siblings ...)
  2013-05-29 14:19 ` [RFC PATCH 12/14] DocBook/media/v4l: clarify the QUERYSTD documentation Hans Verkuil
@ 2013-05-29 14:19 ` Hans Verkuil
  2013-05-29 14:19 ` [RFC PATCH 14/14] cx23885: don't implement querystd if it doesn't do anything Hans Verkuil
  13 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2013-05-29 14:19 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

- do exact matching for special formats like PAL-M
- drop autodetect support: it's non-standard, and it is bogus as well since there
  is no way to get back the detected standard since neither g_std nor querystd are
  implemented.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/i2c/tvp5150.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index b3cf266..0e95e5e 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -727,13 +727,11 @@ static int tvp5150_set_std(struct v4l2_subdev *sd, v4l2_std_id std)
 
 	/* First tests should be against specific std */
 
-	if (std == V4L2_STD_ALL) {
-		fmt = VIDEO_STD_AUTO_SWITCH_BIT;	/* Autodetect mode */
-	} else if (std & V4L2_STD_NTSC_443) {
+	if (std == V4L2_STD_NTSC_443) {
 		fmt = VIDEO_STD_NTSC_4_43_BIT;
-	} else if (std & V4L2_STD_PAL_M) {
+	} else if (std == V4L2_STD_PAL_M) {
 		fmt = VIDEO_STD_PAL_M_BIT;
-	} else if (std & (V4L2_STD_PAL_N | V4L2_STD_PAL_Nc)) {
+	} else if (std == V4L2_STD_PAL_N || std == V4L2_STD_PAL_Nc) {
 		fmt = VIDEO_STD_PAL_COMBINATION_N_BIT;
 	} else {
 		/* Then, test against generic ones */
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RFC PATCH 14/14] cx23885: don't implement querystd if it doesn't do anything.
  2013-05-29 14:18 [RFC PATCH 00/14] QUERYSTD fixes Hans Verkuil
                   ` (12 preceding siblings ...)
  2013-05-29 14:19 ` [RFC PATCH 13/14] tvp5150: fix s_std support Hans Verkuil
@ 2013-05-29 14:19 ` Hans Verkuil
  13 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2013-05-29 14:19 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

cx23885 redirects querystd to g_std. That's pointless, just drop querystd
support.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/pci/cx23885/cx23885-417.c   |    1 -
 drivers/media/pci/cx23885/cx23885-video.c |    1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/media/pci/cx23885/cx23885-417.c b/drivers/media/pci/cx23885/cx23885-417.c
index 6dea11a..0a5f81d 100644
--- a/drivers/media/pci/cx23885/cx23885-417.c
+++ b/drivers/media/pci/cx23885/cx23885-417.c
@@ -1661,7 +1661,6 @@ static struct v4l2_file_operations mpeg_fops = {
 };
 
 static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
-	.vidioc_querystd	 = vidioc_g_std,
 	.vidioc_g_std		 = vidioc_g_std,
 	.vidioc_s_std		 = vidioc_s_std,
 	.vidioc_enum_input	 = vidioc_enum_input,
diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c
index ed08c89..776e553 100644
--- a/drivers/media/pci/cx23885/cx23885-video.c
+++ b/drivers/media/pci/cx23885/cx23885-video.c
@@ -1743,7 +1743,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
 	.vidioc_dqbuf         = vidioc_dqbuf,
 	.vidioc_s_std         = vidioc_s_std,
 	.vidioc_g_std         = vidioc_g_std,
-	.vidioc_querystd      = vidioc_g_std,
 	.vidioc_enum_input    = vidioc_enum_input,
 	.vidioc_g_input       = vidioc_g_input,
 	.vidioc_s_input       = vidioc_s_input,
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [RFC PATCH 07/14] tvp514x: fix querystd
  2013-05-29 14:19 ` [RFC PATCH 07/14] tvp514x: " Hans Verkuil
@ 2013-05-30  7:07   ` Prabhakar Lad
  0 siblings, 0 replies; 17+ messages in thread
From: Prabhakar Lad @ 2013-05-30  7:07 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

Hi Hans,

Thanks for the patch.

On Wed, May 29, 2013 at 7:49 PM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Return V4L2_STD_UNKNOWN if no signal is detected.
> Otherwise AND the standard mask with the detected standards.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>

Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>

Regards,
--Prabhakar Lad

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC PATCH 01/14] adv7183: fix querystd
  2013-05-29 14:18 ` [RFC PATCH 01/14] adv7183: fix querystd Hans Verkuil
@ 2013-05-31  7:50   ` Scott Jiang
  0 siblings, 0 replies; 17+ messages in thread
From: Scott Jiang @ 2013-05-31  7:50 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: LMML, Hans Verkuil

2013/5/29 Hans Verkuil <hverkuil@xs4all.nl>:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> If no signal is detected, return V4L2_STD_UNKNOWN. Otherwise AND the standard
> with the detected standards.
>
> Note that the v4l2 core initializes the std with tvnorms before calling the
> querystd ioctl.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> Cc: Scott Jiang <scott.jiang.linux@gmail.com>
> ---
>  drivers/media/i2c/adv7183.c |   16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>

Acked-by: Scott Jiang <scott.jiang.linux@gmail.com>

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2013-05-31  7:50 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-29 14:18 [RFC PATCH 00/14] QUERYSTD fixes Hans Verkuil
2013-05-29 14:18 ` [RFC PATCH 01/14] adv7183: fix querystd Hans Verkuil
2013-05-31  7:50   ` Scott Jiang
2013-05-29 14:18 ` [RFC PATCH 02/14] bt819: " Hans Verkuil
2013-05-29 14:18 ` [RFC PATCH 03/14] ks0127: " Hans Verkuil
2013-05-29 14:18 ` [RFC PATCH 04/14] saa7110: " Hans Verkuil
2013-05-29 14:18 ` [RFC PATCH 05/14] saa7115: " Hans Verkuil
2013-05-29 14:18 ` [RFC PATCH 06/14] saa7191: " Hans Verkuil
2013-05-29 14:19 ` [RFC PATCH 07/14] tvp514x: " Hans Verkuil
2013-05-30  7:07   ` Prabhakar Lad
2013-05-29 14:19 ` [RFC PATCH 08/14] vpx3220: " Hans Verkuil
2013-05-29 14:19 ` [RFC PATCH 09/14] bttv: " Hans Verkuil
2013-05-29 14:19 ` [RFC PATCH 10/14] zoran: remove bogus autodetect mode in set_norm Hans Verkuil
2013-05-29 14:19 ` [RFC PATCH 11/14] v4l2-ioctl: clarify querystd comment Hans Verkuil
2013-05-29 14:19 ` [RFC PATCH 12/14] DocBook/media/v4l: clarify the QUERYSTD documentation Hans Verkuil
2013-05-29 14:19 ` [RFC PATCH 13/14] tvp5150: fix s_std support Hans Verkuil
2013-05-29 14:19 ` [RFC PATCH 14/14] cx23885: don't implement querystd if it doesn't do anything Hans Verkuil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).