Skip to contentSkip to conversation

media: saa7115: allow input standard autodetection for SAA7113

PATCH Superseded Anatolij Gustschin 2 participants 6 messages Dec 13, 2010 – Dec 22, 2010 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 media: saa7115: allow input standard autodetection for SAA7113

Autodetect input's standard using field frequency detection feature (FIDT in status byte at 0x1F) of the SAA7113.

---
 drivers/media/video/saa7115.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
drivers/media/video/saa7115.c +12 -0
index 301c62b..f28a4c7 100644
@@ -1348,6 +1348,18 @@ static int saa711x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std)
 	int reg1e;
 
 	*std = V4L2_STD_ALL;
+
+	if (state->ident == V4L2_IDENT_SAA7113) {
+		int reg1f = saa711x_read(sd, R_1F_STATUS_BYTE_2_VD_DEC);
+
+		if (reg1f & 0x20)
+			*std = V4L2_STD_NTSC;
+		else
+			*std = V4L2_STD_PAL;
+
+		return 0;
+	}
+
 	if (state->ident != V4L2_IDENT_SAA7115)
 		return 0;
 	reg1e = saa711x_read(sd, R_1E_STATUS_BYTE_1_VD_DEC);
Signature · 1 line
1.7.1
#1 lore raw

PATCH 2/2 media: fsl_viu: add VIDIOC_QUERYSTD and VIDIOC_G_STD support

VIDIOC_QUERYSTD and VIDIOC_G_STD ioctls are currently not supported in the FSL VIU driver. The decoder subdevice driver saa7115 extended by previous patch supports QUERYSTD for saa7113, so we add the appropriate ioctls to the VIU driver to be able to determine the video input's standard.

---
 drivers/media/video/fsl-viu.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
drivers/media/video/fsl-viu.c +21 -0
index b8faff2..04be6eb 100644
@@ -194,6 +194,8 @@ struct viu_dev {
 
 	/* decoder */
 	struct v4l2_subdev	*decoder;
+
+	v4l2_std_id		std;
 };
 
 struct viu_fh {
@@ -933,14 +935,31 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
 #define decoder_call(viu, o, f, args...) \
 	v4l2_subdev_call(viu->decoder, o, f, ##args)
 
+static int vidioc_querystd(struct file *file, void *priv, v4l2_std_id *std_id)
+{
+	struct viu_fh *fh = priv;
+
+	decoder_call(fh->dev, video, querystd, std_id);
+	return 0;
+}
+
 static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *id)
 {
 	struct viu_fh *fh = priv;
 
+	fh->dev->std = *id;
 	decoder_call(fh->dev, core, s_std, *id);
 	return 0;
 }
 
+static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *std_id)
+{
+	struct viu_fh *fh = priv;
+
+	*std_id = fh->dev->std;
+	return 0;
+}
+
 /* only one input in this driver */
 static int vidioc_enum_input(struct file *file, void *priv,
 					struct v4l2_input *inp)
@@ -1397,7 +1416,9 @@ static const struct v4l2_ioctl_ops viu_ioctl_ops = {
 	.vidioc_querybuf      = vidioc_querybuf,
 	.vidioc_qbuf          = vidioc_qbuf,
 	.vidioc_dqbuf         = vidioc_dqbuf,
+	.vidioc_g_std         = vidioc_g_std,
 	.vidioc_s_std         = vidioc_s_std,
+	.vidioc_querystd      = vidioc_querystd,
 	.vidioc_enum_input    = vidioc_enum_input,
 	.vidioc_g_input       = vidioc_g_input,
 	.vidioc_s_input       = vidioc_s_input,
Signature · 1 line
1.7.1
#2 lore raw

Re: [2/2] media: fsl_viu: add VIDIOC_QUERYSTD and VIDIOC_G_STD support

Em 13-12-2010 16:19, Anatolij Gustschin escreveu:

Quoted 5 lines

VIDIOC_QUERYSTD and VIDIOC_G_STD ioctls are currently not supported in the FSL VIU driver. The decoder subdevice driver saa7115 extended by previous patch supports QUERYSTD for saa7113, so we add the appropriate ioctls to the VIU driver to be able to determine the video input's standard.

This patch looks ok, but as it is somewhat dependent on the saa7113 patch, please re-send it together with the other patch for me to pull both together.

Quoted 63 lines

---
drivers/media/video/fsl-viu.c | 21 +++++++++++++++++++++

 1 files changed, 21 insertions(+), 0 deletions(-)
drivers/media/video/fsl-viu.c +21 -0
index b8faff2..04be6eb 100644
@@ -194,6 +194,8 @@ struct viu_dev {
 
 	/* decoder */
 	struct v4l2_subdev	*decoder;
+
+	v4l2_std_id		std;
 };
 
 struct viu_fh {
@@ -933,14 +935,31 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
 #define decoder_call(viu, o, f, args...) \
 	v4l2_subdev_call(viu->decoder, o, f, ##args)
 
+static int vidioc_querystd(struct file *file, void *priv, v4l2_std_id *std_id)
+{
+	struct viu_fh *fh = priv;
+
+	decoder_call(fh->dev, video, querystd, std_id);
+	return 0;
+}
+
 static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *id)
 {
 	struct viu_fh *fh = priv;
 
+	fh->dev->std = *id;
 	decoder_call(fh->dev, core, s_std, *id);
 	return 0;
 }
 
+static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *std_id)
+{
+	struct viu_fh *fh = priv;
+
+	*std_id = fh->dev->std;
+	return 0;
+}
+
 /* only one input in this driver */
 static int vidioc_enum_input(struct file *file, void *priv,
 					struct v4l2_input *inp)
@@ -1397,7 +1416,9 @@ static const struct v4l2_ioctl_ops viu_ioctl_ops = {
 	.vidioc_querybuf      = vidioc_querybuf,
 	.vidioc_qbuf          = vidioc_qbuf,
 	.vidioc_dqbuf         = vidioc_dqbuf,
+	.vidioc_g_std         = vidioc_g_std,
 	.vidioc_s_std         = vidioc_s_std,
+	.vidioc_querystd      = vidioc_querystd,
 	.vidioc_enum_input    = vidioc_enum_input,
 	.vidioc_g_input       = vidioc_g_input,
 	.vidioc_s_input       = vidioc_s_input,
#3 lore raw
In reply to Anatolij Gustschin

Em 13-12-2010 16:19, Anatolij Gustschin escreveu:

Quoted 15 lines

Autodetect input's standard using field frequency detection feature (FIDT in status byte at 0x1F) of the SAA7113.

---
drivers/media/video/saa7115.c | 12 ++++++++++++

 1 files changed, 12 insertions(+), 0 deletions(-)
drivers/media/video/saa7115.c +0 -0
index 301c62b..f28a4c7 100644
@@ -1348,6 +1348,18 @@ static int saa711x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std)
 	int reg1e;

drivers/media/video/saa7115.c static int saa711x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) · line 1358

Quoted 10 lines
drivers/media/video/saa7115.c +8 -0
 
 	*std = V4L2_STD_ALL;
+
+	if (state->ident == V4L2_IDENT_SAA7113) {
+		int reg1f = saa711x_read(sd, R_1F_STATUS_BYTE_2_VD_DEC);
+
+		if (reg1f & 0x20)
+			*std = V4L2_STD_NTSC;
+		else
+			*std = V4L2_STD_PAL;

This is wrong. The meaning of bit 5 of reg 0x1f is if the standard is 50Hz or 60Hz based (so, it detects the monocromatic standard, not the color standard). So, instead, it should be doing:

	if (reg1f & 0x20)
		*std = V4L2_STD_525_60;
	else
		*std = V4L2_STD_625_50;

Also, this kind of detection could be used also for the other supported chips on this driver (I checked datasheets of saa7111/saa7111a/saa7114/saa7118).

So, the better is to code it as:

 	if (state->ident != V4L2_IDENT_SAA7115) {
		int reg1f = saa711x_read(sd, R_1F_STATUS_BYTE_2_VD_DEC);
		if (reg1f & 0x20)
			*std = V4L2_STD_525_60;
		else
			*std = V4L2_STD_625_50;
 		return 0;
	}
Quoted 8 lines
drivers/media/video/saa7115.c +4 -0
+
+		return 0;
+	}
+
 	if (state->ident != V4L2_IDENT_SAA7115)
 		return 0;
 	reg1e = saa711x_read(sd, R_1E_STATUS_BYTE_1_VD_DEC);
#4 lore raw

PATCH v2 1/2 media: saa7115: allow input standard autodetection for more chips

Autodetect input's standard using field frequency detection feature (FIDT in status byte at 0x1F) of the chips saa7111/ saa7111a/saa7113/saa7114/saa7118.

---
Changes since first patch version:
- reworked for chips other than saa7115
- fixed to return V4L2_STD_525_60 / V4L2_STD_625_50 instead of V4L2_STD_NTSC / V4L2_STD_PAL
- adapted the commit message

 drivers/media/video/saa7115.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
drivers/media/video/saa7115.c +10 -1
index 301c62b..f35459d 100644
@@ -1348,8 +1348,17 @@ static int saa711x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std)
 	int reg1e;
 
 	*std = V4L2_STD_ALL;
-	if (state->ident != V4L2_IDENT_SAA7115)
+	if (state->ident != V4L2_IDENT_SAA7115) {
+		int reg1f = saa711x_read(sd, R_1F_STATUS_BYTE_2_VD_DEC);
+
+		if (reg1f & 0x20)
+			*std = V4L2_STD_525_60;
+		else
+			*std = V4L2_STD_625_50;
+
 		return 0;
+	}
+
 	reg1e = saa711x_read(sd, R_1E_STATUS_BYTE_1_VD_DEC);
 
 	switch (reg1e & 0x03) {
Signature · 1 line
1.7.1
#5 lore raw

PATCH v2 2/2 media: fsl_viu: add VIDIOC_QUERYSTD and VIDIOC_G_STD support

In reply to Mauro Carvalho Chehab

VIDIOC_QUERYSTD and VIDIOC_G_STD ioctls are currently not supported in the FSL VIU driver. The decoder subdevice driver saa7115 extended by previous patch supports QUERYSTD for saa711x, so we add the appropriate ioctls to the VIU driver to be able to determine the video input's standard.

---
Changes since first patch version:
- fixed the commit message and rebased

 drivers/media/video/fsl-viu.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
drivers/media/video/fsl-viu.c +21 -0
index 693e9c0..e4bba88 100644
@@ -194,6 +194,8 @@ struct viu_dev {
 
 	/* decoder */
 	struct v4l2_subdev	*decoder;
+
+	v4l2_std_id		std;
 };
 
 struct viu_fh {
@@ -937,14 +939,31 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
 #define decoder_call(viu, o, f, args...) \
 	v4l2_subdev_call(viu->decoder, o, f, ##args)
 
+static int vidioc_querystd(struct file *file, void *priv, v4l2_std_id *std_id)
+{
+	struct viu_fh *fh = priv;
+
+	decoder_call(fh->dev, video, querystd, std_id);
+	return 0;
+}
+
 static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *id)
 {
 	struct viu_fh *fh = priv;
 
+	fh->dev->std = *id;
 	decoder_call(fh->dev, core, s_std, *id);
 	return 0;
 }
 
+static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *std_id)
+{
+	struct viu_fh *fh = priv;
+
+	*std_id = fh->dev->std;
+	return 0;
+}
+
 /* only one input in this driver */
 static int vidioc_enum_input(struct file *file, void *priv,
 					struct v4l2_input *inp)
@@ -1402,7 +1421,9 @@ static const struct v4l2_ioctl_ops viu_ioctl_ops = {
 	.vidioc_querybuf      = vidioc_querybuf,
 	.vidioc_qbuf          = vidioc_qbuf,
 	.vidioc_dqbuf         = vidioc_dqbuf,
+	.vidioc_g_std         = vidioc_g_std,
 	.vidioc_s_std         = vidioc_s_std,
+	.vidioc_querystd      = vidioc_querystd,
 	.vidioc_enum_input    = vidioc_enum_input,
 	.vidioc_g_input       = vidioc_g_input,
 	.vidioc_s_input       = vidioc_s_input,
Signature · 1 line
1.7.1