Skip to contentSkip to conversation

rcar_vin: propagate querystd() error upstream

PATCH Superseded Sergei Shtylyov 3 participants 6 messages Aug 19, 2015 – Aug 31, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rcar_vin: propagate querystd() error upstream

rcar_vin_set_fmt() defaults to PAL when the subdevice's querystd() method call fails (e.g. due to I2C error). This doesn't work very well when a camera being used outputs NTSC which has different order of fields and resolution. Let us stop pretending and return the actual error (which would prevent video capture on at least Renesas Henninger/Porter board where I2C seems particularly buggy).

---
The patch is against the 'media_tree.git' repo's 'fixes' branch.

 drivers/media/platform/soc_camera/rcar_vin.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: media_tree/drivers/media/platform/soc_camera/rcar_vin.c =================================--- media_tree.orig/drivers/media/platform/soc_camera/rcar_vin.c +++ media_tree/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1592,7 +1592,7 @@ static int rcar_vin_set_fmt(struct soc_c
/* Query for standard if not explicitly mentioned _TB/_BT */
ret = v4l2_subdev_call(sd, video, querystd, &std);
if (ret < 0)
- std = V4L2_STD_625_50;
+ return ret;

field = std & V4L2_STD_625_50 ? V4L2_FIELD_INTERLACED_TB :
V4L2_FIELD_INTERLACED_BT;

#1 lore raw

Hi Sergei,

Thank you for the patch.

Quoted 19 lines · On Thursday 20 August 2015 00:02:17 Sergei Shtylyov wrote:

rcar_vin_set_fmt() defaults to PAL when the subdevice's querystd() method call fails (e.g. due to I2C error). This doesn't work very well when a camera being used outputs NTSC which has different order of fields and resolution. Let us stop pretending and return the actual error (which would prevent video capture on at least Renesas Henninger/Porter board where I2C seems particularly buggy).

---
The patch is against the 'media_tree.git' repo's 'fixes' branch.

 drivers/media/platform/soc_camera/rcar_vin.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: media_tree/drivers/media/platform/soc_camera/rcar_vin.c =================================> --- media_tree.orig/drivers/media/platform/soc_camera/rcar_vin.c +++ media_tree/drivers/media/platform/soc_camera/rcar_vin.c

Review static int rcar_vin_set_fmt(struct soc_c · line 1595

Quoted 5 lines
(quoted diff) +1 -1
@@ -1592,7 +1592,7 @@ static int rcar_vin_set_fmt(struct soc_c
 		/* Query for standard if not explicitly mentioned _TB/_BT */
 		ret = v4l2_subdev_call(sd, video, querystd, &std);
 		if (ret < 0)
-			std = V4L2_STD_625_50;
+			return ret;

What if the subdev doesn't implement querystd ? That's the case of camera sensors for instance. In that case we should default to V4L2_FIELD_NONE.

Quoted 2 lines
(quoted diff) +0 -0
 		field = std & V4L2_STD_625_50 ? V4L2_FIELD_INTERLACED_TB :
 						V4L2_FIELD_INTERLACED_BT;
Signature · 3 lines
Regards,

Laurent Pinchart
#2 lore raw

hello.

Quoted 15 lines · Laurent Pinchart
Quoted 15 lines

rcar_vin_set_fmt() defaults to PAL when the subdevice's querystd() method call fails (e.g. due to I2C error). This doesn't work very well when a camera being used outputs NTSC which has different order of fields and resolution. Let us stop pretending and return the actual error (which would prevent video capture on at least Renesas Henninger/Porter board where I2C seems particularly buggy).

---
The patch is against the 'media_tree.git' repo's 'fixes' branch.

  drivers/media/platform/soc_camera/rcar_vin.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

Review static int rcar_vin_set_fmt(struct soc_c · line 1595

Quoted 9 lines

Index: media_tree/drivers/media/platform/soc_camera/rcar_vin.c =================================>> --- media_tree.orig/drivers/media/platform/soc_camera/rcar_vin.c +++ media_tree/drivers/media/platform/soc_camera/rcar_vin.c

(quoted diff) +1 -1
@@ -1592,7 +1592,7 @@ static int rcar_vin_set_fmt(struct soc_c
  		/* Query for standard if not explicitly mentioned _TB/_BT */
  		ret = v4l2_subdev_call(sd, video, querystd, &std);
  		if (ret < 0)
-			std = V4L2_STD_625_50;
+			return ret;

What if the subdev doesn't implement querystd ? That's the case of camera sensors for instance.

Indeed.

Quoted 1 line

In that case we should default to V4L2_FIELD_NONE.

Hmm, even if the set_fmt() method is called with V4L2_FIELD_INTERLACED
already, like in this case?

Quoted 2 lines

Review static int rcar_vin_set_fmt(struct soc_c · line 1597

Quoted 2 lines
(quoted diff) +0 -0
  		field = std & V4L2_STD_625_50 ? V4L2_FIELD_INTERLACED_TB :
  						V4L2_FIELD_INTERLACED_BT;

MBR, Sergei

#4 lore raw
In reply to Sergei Shtylyov
Quoted 18 lines · Sergei Shtylyov

rcar_vin_set_fmt() defaults to PAL when the subdevice's querystd() method call fails (e.g. due to I2C error). This doesn't work very well when a camera being used outputs NTSC which has different order of fields and resolution. Let us stop pretending and return the actual error (which would prevent video capture on at least Renesas Henninger/Porter board where I2C seems particularly buggy).

---
The patch is against the 'media_tree.git' repo's 'fixes' branch.

 drivers/media/platform/soc_camera/rcar_vin.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: media_tree/drivers/media/platform/soc_camera/rcar_vin.c =================================> --- media_tree.orig/drivers/media/platform/soc_camera/rcar_vin.c +++ media_tree/drivers/media/platform/soc_camera/rcar_vin.c

Review static int rcar_vin_set_fmt(struct soc_c · line 1593

Quoted 2 lines
(quoted diff) +0 -0
@@ -1592,7 +1592,7 @@ static int rcar_vin_set_fmt(struct soc_c
 		/* Query for standard if not explicitly mentioned _TB/_BT */
 		ret = v4l2_subdev_call(sd, video, querystd, &std);

Ouch, this should never be done like this.

Instead the decision should be made using the last set std, never by querying. So querystd should be replaced by g_std in the v4l2_subdev_call above.

The only place querystd can be called is in the QUERYSTD ioctl, all other ioctls should use the last set standard.

Regards,

Hans

Quoted 12 lines
(quoted diff) +1 -2
 		if (ret < 0)
-			std = V4L2_STD_625_50;
+			return ret;
 
 		field = std & V4L2_STD_625_50 ? V4L2_FIELD_INTERLACED_TB :
 						V4L2_FIELD_INTERLACED_BT;
 
--

To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to Sergei Shtylyov

Hi Sergei,

Quoted 30 lines · On Tuesday 25 August 2015 00:58:07 Sergei Shtylyov wrote:
Quoted 20 lines · Laurent Pinchart
Quoted 20 lines

rcar_vin_set_fmt() defaults to PAL when the subdevice's querystd() method call fails (e.g. due to I2C error). This doesn't work very well when a camera being used outputs NTSC which has different order of fields and resolution. Let us stop pretending and return the actual error (which would prevent video capture on at least Renesas Henninger/Porter board where I2C seems particularly buggy).

---
The patch is against the 'media_tree.git' repo's 'fixes' branch.

  drivers/media/platform/soc_camera/rcar_vin.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Index: media_tree/drivers/media/platform/soc_camera/rcar_vin.c =================================> >> --- media_tree.orig/drivers/media/platform/soc_camera/rcar_vin.c +++ media_tree/drivers/media/platform/soc_camera/rcar_vin.c

(quoted diff) +0 -0
@@ -1592,7 +1592,7 @@ static int rcar_vin_set_fmt(struct soc_c
 
Quoted 8 lines

Review static int rcar_vin_set_fmt(struct soc_c · line 1596

Quoted 5 lines
(quoted diff) +1 -1
  		/* Query for standard if not explicitly mentioned _TB/_BT */
  		ret = v4l2_subdev_call(sd, video, querystd, &std);
  		if (ret < 0)
-			std = V4L2_STD_625_50;
+			return ret;

What if the subdev doesn't implement querystd ? That's the case of camera sensors for instance.

Quoted 6 lines

Indeed.

Quoted 1 line

In that case we should default to V4L2_FIELD_NONE.

Hmm, even if the set_fmt() method is called with V4L2_FIELD_INTERLACED already, like in this case?

Yes. If the device doesn't support interlacing then the field passed to set_fmt() should be set to V4L2_FIELD_NONE. The V4L2 API requires drivers to fix unsupported parameters passed to the VIDIOC_S_FMT ioctl instead of returning an error like commonly done in such situation.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
(quoted diff) +0 -0
  		field = std & V4L2_STD_625_50 ? V4L2_FIELD_INTERLACED_TB :
  						V4L2_FIELD_INTERLACED_BT;
Signature · 3 lines
Regards,

Laurent Pinchart
#5 lore raw
In reply to Hans Verkuil

Hello.

Quoted 14 lines · Hans Verkuil
Quoted 14 lines

rcar_vin_set_fmt() defaults to PAL when the subdevice's querystd() method call fails (e.g. due to I2C error). This doesn't work very well when a camera being used outputs NTSC which has different order of fields and resolution. Let us stop pretending and return the actual error (which would prevent video capture on at least Renesas Henninger/Porter board where I2C seems particularly buggy).

---
The patch is against the 'media_tree.git' repo's 'fixes' branch.

  drivers/media/platform/soc_camera/rcar_vin.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 8 lines

Review static int rcar_vin_set_fmt(struct soc_c · line 1593

Quoted 6 lines

Index: media_tree/drivers/media/platform/soc_camera/rcar_vin.c =================================>> --- media_tree.orig/drivers/media/platform/soc_camera/rcar_vin.c +++ media_tree/drivers/media/platform/soc_camera/rcar_vin.c

(quoted diff) +0 -0
@@ -1592,7 +1592,7 @@ static int rcar_vin_set_fmt(struct soc_c
  		/* Query for standard if not explicitly mentioned _TB/_BT */
  		ret = v4l2_subdev_call(sd, video, querystd, &std);

Ouch, this should never be done like this.

    Too late. :-)
Quoted 2 lines

Instead the decision should be made using the last set std, never by querying. So querystd should be replaced by g_std in the v4l2_subdev_call above.

Hm, then this code will stop working, as adv7180.c and ml86v7667.c we use
don't support the g_std() method yet...

Quoted 2 lines

The only place querystd can be called is in the QUERYSTD ioctl, all other ioctls should use the last set standard.

OK, I'll have to fix all the drivers involved...

Quoted 2 lines

Regards,
Hans

MBR, Sergei