Skip to contentSkip to conversation

media: i2c: ov7740: implement get_mbus_config

PATCH In review Eugen Hristev 3 participants 5 messages Nov 2, 2021 – Nov 3, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: i2c: ov7740: implement get_mbus_config

Implement the get_mbus_config callback.
ov7740 is a parallel sensor, and according to datasheet, the register REG12 controls the CCIR656 mode. This register is written to 0 in yuyv mode. According to REG12[5] , CCIR656 mode, the behavior is:
CCIR656: disabled
REG28 controls the polarity of the signals. This register is unused. The default behavior is then:
HSYNC polarity : positive
VSYNC polarity : positive
HREF polarity: positive

---
 drivers/media/i2c/ov7740.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/media/i2c/ov7740.c +14 -0
index 2539cfee85c8..f8a717aecb6f 100644
@@ -873,12 +873,26 @@ static int ov7740_get_fmt(struct v4l2_subdev *sd,
 	return ret;
 }
 
+static int ov7740_get_mbus_config(struct v4l2_subdev *sd,
+				  unsigned int pad,
+				  struct v4l2_mbus_config *cfg)
+{
+	cfg->type = V4L2_MBUS_PARALLEL;
+	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
+		     V4L2_MBUS_VSYNC_ACTIVE_HIGH |
+		     V4L2_MBUS_PCLK_SAMPLE_RISING |
+		     V4L2_MBUS_FIELD_EVEN_LOW | V4L2_MBUS_DATA_ACTIVE_HIGH;
+
+	return 0;
+}
+
 static const struct v4l2_subdev_pad_ops ov7740_subdev_pad_ops = {
 	.enum_frame_interval = ov7740_enum_frame_interval,
 	.enum_frame_size = ov7740_enum_frame_size,
 	.enum_mbus_code = ov7740_enum_mbus_code,
 	.get_fmt = ov7740_get_fmt,
 	.set_fmt = ov7740_set_fmt,
+	.get_mbus_config = ov7740_get_mbus_config,
 };
 
 static const struct v4l2_subdev_ops ov7740_subdev_ops = {
Signature · 1 line
2.25.1
maintainer
#1 lore raw

Hi Eugen,

Thanks for the patch.

Quoted 11 lines · Eugen Hristev

Implement the get_mbus_config callback.
ov7740 is a parallel sensor, and according to datasheet, the register REG12 controls the CCIR656 mode. This register is written to 0 in yuyv mode. According to REG12[5] , CCIR656 mode, the behavior is:
CCIR656: disabled
REG28 controls the polarity of the signals. This register is unused. The default behavior is then:
HSYNC polarity : positive
VSYNC polarity : positive
HREF polarity: positive

Doesn't the receiver driver get this information from DT?

Quoted 36 lines
---
 drivers/media/i2c/ov7740.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/media/i2c/ov7740.c +14 -0
index 2539cfee85c8..f8a717aecb6f 100644
@@ -873,12 +873,26 @@ static int ov7740_get_fmt(struct v4l2_subdev *sd,
 	return ret;
 }
 
+static int ov7740_get_mbus_config(struct v4l2_subdev *sd,
+				  unsigned int pad,
+				  struct v4l2_mbus_config *cfg)
+{
+	cfg->type = V4L2_MBUS_PARALLEL;
+	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
+		     V4L2_MBUS_VSYNC_ACTIVE_HIGH |
+		     V4L2_MBUS_PCLK_SAMPLE_RISING |
+		     V4L2_MBUS_FIELD_EVEN_LOW | V4L2_MBUS_DATA_ACTIVE_HIGH;
+
+	return 0;
+}
+
 static const struct v4l2_subdev_pad_ops ov7740_subdev_pad_ops = {
 	.enum_frame_interval = ov7740_enum_frame_interval,
 	.enum_frame_size = ov7740_enum_frame_size,
 	.enum_mbus_code = ov7740_enum_mbus_code,
 	.get_fmt = ov7740_get_fmt,
 	.set_fmt = ov7740_set_fmt,
+	.get_mbus_config = ov7740_get_mbus_config,
 };
 
 static const struct v4l2_subdev_ops ov7740_subdev_ops = {
Signature · 3 lines
Regards,

Sakari Ailus
#2 lore raw
Quoted 17 lines · Sakari Ailus

Hi Eugen,

Thanks for the patch.

Quoted 11 lines · Eugen Hristev

Implement the get_mbus_config callback.
ov7740 is a parallel sensor, and according to datasheet, the register REG12 controls the CCIR656 mode. This register is written to 0 in yuyv mode. According to REG12[5] , CCIR656 mode, the behavior is:
CCIR656: disabled
REG28 controls the polarity of the signals. This register is unused. The default behavior is then:
HSYNC polarity : positive
VSYNC polarity : positive
HREF polarity: positive

Quoted 2 lines

Doesn't the receiver driver get this information from DT?

Hi Sakari,

This patch comes as a result of my discussions with Jacopo, he advised to get mbus configuration via the get_mbus_config . I agree that this information can be taken from DT as you said.
In the end , my understanding is that get_mbus_config should be used only for runtime configuration which can change.
Thus, if all this information is static, then, I will proceed with obtaining it from DT, and you can disregard this patch, as it is not useful.

Thanks,
Eugen

Quoted 42 lines
Quoted 26 lines
---
  drivers/media/i2c/ov7740.c | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
drivers/media/i2c/ov7740.c +13 -0
index 2539cfee85c8..f8a717aecb6f 100644
@@ -873,12 +873,26 @@ static int ov7740_get_fmt(struct v4l2_subdev *sd,
       return ret;
  }
 
+static int ov7740_get_mbus_config(struct v4l2_subdev *sd,
+                               unsigned int pad,
+                               struct v4l2_mbus_config *cfg)
+{
+     cfg->type = V4L2_MBUS_PARALLEL;
+     cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
+                  V4L2_MBUS_VSYNC_ACTIVE_HIGH |
+                  V4L2_MBUS_PCLK_SAMPLE_RISING |
+                  V4L2_MBUS_FIELD_EVEN_LOW | V4L2_MBUS_DATA_ACTIVE_HIGH;
+
+     return 0;
+}
+

drivers/media/i2c/ov7740.c static int ov7740_get_fmt(struct v4l2_subdev *sd, · line 898

Quoted 10 lines
drivers/media/i2c/ov7740.c +1 -0
  static const struct v4l2_subdev_pad_ops ov7740_subdev_pad_ops = {
       .enum_frame_interval = ov7740_enum_frame_interval,
       .enum_frame_size = ov7740_enum_frame_size,
       .enum_mbus_code = ov7740_enum_mbus_code,
       .get_fmt = ov7740_get_fmt,
       .set_fmt = ov7740_set_fmt,
+     .get_mbus_config = ov7740_get_mbus_config,
  };
 
  static const struct v4l2_subdev_ops ov7740_subdev_ops = {

--
Regards,

Sakari Ailus

#3 lore raw

Hello,

for a bit more of context

Quoted 18 lines · On Wed, Nov 03, 2021 at 12:39:52PM +0000, [email protected] wrote:
Quoted 17 lines · Sakari Ailus

Hi Eugen,

Thanks for the patch.

Quoted 11 lines · Eugen Hristev

Implement the get_mbus_config callback.
ov7740 is a parallel sensor, and according to datasheet, the register REG12 controls the CCIR656 mode. This register is written to 0 in yuyv mode. According to REG12[5] , CCIR656 mode, the behavior is:
CCIR656: disabled
REG28 controls the polarity of the signals. This register is unused. The default behavior is then:
HSYNC polarity : positive
VSYNC polarity : positive
HREF polarity: positive

Quoted 7 lines
Quoted 2 lines

Doesn't the receiver driver get this information from DT?

Hi Sakari,

This patch comes as a result of my discussions with Jacopo, he advised to get mbus configuration via the get_mbus_config . I agree that this

That's where getting info at runtime was suggested

https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/#122336

Quoted 5 lines

information can be taken from DT as you said.
In the end , my understanding is that get_mbus_config should be used only for runtime configuration which can change.
Thus, if all this information is static, then, I will proceed with obtaining it from DT, and you can disregard this patch, as it is not useful.

And the latest comment where getting it from DTS was suggested

https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/#132605

Thanks
j

Quoted 47 lines

Thanks,
Eugen

Quoted 42 lines
Quoted 26 lines
---
  drivers/media/i2c/ov7740.c | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
drivers/media/i2c/ov7740.c +13 -0
index 2539cfee85c8..f8a717aecb6f 100644
@@ -873,12 +873,26 @@ static int ov7740_get_fmt(struct v4l2_subdev *sd,
       return ret;
  }
 
+static int ov7740_get_mbus_config(struct v4l2_subdev *sd,
+                               unsigned int pad,
+                               struct v4l2_mbus_config *cfg)
+{
+     cfg->type = V4L2_MBUS_PARALLEL;
+     cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
+                  V4L2_MBUS_VSYNC_ACTIVE_HIGH |
+                  V4L2_MBUS_PCLK_SAMPLE_RISING |
+                  V4L2_MBUS_FIELD_EVEN_LOW | V4L2_MBUS_DATA_ACTIVE_HIGH;
+
+     return 0;
+}
+

drivers/media/i2c/ov7740.c static int ov7740_get_fmt(struct v4l2_subdev *sd, · line 898

Quoted 10 lines
drivers/media/i2c/ov7740.c +1 -0
  static const struct v4l2_subdev_pad_ops ov7740_subdev_pad_ops = {
       .enum_frame_interval = ov7740_enum_frame_interval,
       .enum_frame_size = ov7740_enum_frame_size,
       .enum_mbus_code = ov7740_enum_mbus_code,
       .get_fmt = ov7740_get_fmt,
       .set_fmt = ov7740_set_fmt,
+     .get_mbus_config = ov7740_get_mbus_config,
  };
 
  static const struct v4l2_subdev_ops ov7740_subdev_ops = {

--
Regards,

Sakari Ailus

maintainer
#4 lore raw
In reply to [email protected]
Quoted 23 lines · On Wed, Nov 03, 2021 at 12:39:52PM +0000, [email protected] wrote:
Quoted 17 lines · Sakari Ailus

Hi Eugen,

Thanks for the patch.

Quoted 11 lines · Eugen Hristev

Implement the get_mbus_config callback.
ov7740 is a parallel sensor, and according to datasheet, the register REG12 controls the CCIR656 mode. This register is written to 0 in yuyv mode. According to REG12[5] , CCIR656 mode, the behavior is:
CCIR656: disabled
REG28 controls the polarity of the signals. This register is unused. The default behavior is then:
HSYNC polarity : positive
VSYNC polarity : positive
HREF polarity: positive

Quoted 2 lines

Doesn't the receiver driver get this information from DT?

Hi Sakari,

Quoted 7 lines

This patch comes as a result of my discussions with Jacopo, he advised to get mbus configuration via the get_mbus_config . I agree that this information can be taken from DT as you said.
In the end , my understanding is that get_mbus_config should be used only for runtime configuration which can change.
Thus, if all this information is static, then, I will proceed with obtaining it from DT, and you can disregard this patch, as it is not useful.

Yes, please.

Getting this from DT is preferred if no dynamic configuration is needed.

Signature · 1 line
Sakari Ailus