All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config()
@ 2022-01-03 16:24 Laurent Pinchart
  2022-01-03 16:24 ` [RFC PATCH 1/8] media: pxa_camera: Drop usage of .set_mbus_config() Laurent Pinchart
                   ` (9 more replies)
  0 siblings, 10 replies; 36+ messages in thread
From: Laurent Pinchart @ 2022-01-03 16:24 UTC (permalink / raw)
  To: linux-media
  Cc: linux-renesas-soc, Sakari Ailus, Hans Verkuil, Kieran Bingham,
	Jacopo Mondi, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik

Hello,

This patch series reworks the V4L2 subdev .get_mbus_config() and
.set_mbus_config() operations to improve the former and drop the latter.

These subdev operations originate from soc-camera (for those who
remember the framework), and were designed to let a transmitter and a
receiver negotiate the physical configuration of the bus that connects
them. The operations use bitflags to represent bus parameters, with
supported options set by the caller of .set_mbus_config(), and selected
options among those returned by the callee. This mechanism is
deprecated, as selection of the bus configuration has long been moved to
the firmware interface (DT or ACPI), and usage of bitflags prevents from
adding more complex configuration parameters (timings in particular).

As .set_mbus_config() is deprecated and used by one pair of drivers only
(pxa_camera and ov6650), it wasn't difficult to drop usage of that
operation in patches 1/8 and 2/8, and remove the operation itself in
patch 3/8.

With that operation gone, .get_mbus_config() can be moved from bitflags
to structures. It turned out that the needed data structures were
already present in v4l2_fwnode.h. Patch 4/8 moves them to
v4l2_mediabus.h (and renames them to drop the fwnode mention, as they're
not specific to the fwnode API), and patch 5/8 makes use of them.
Patches 6/8 to 8/8 then removes media bus configuration bitflags that
are unneeded (and now unused).

The series is an RFC as not everything has been converted from bitflags
to named fields in structures. In particular, the parallel bus flags
haven't been touched at all. Patch 8/8 shows how mutually exclusive
flags can be reworked to drop one of them. We then need to decide
whether to keep expressing the flag as macros, or move to C bitfields
with dedicated structure member names. I didn't want to include this
change in the RFC before getting feedback on the general approach
(feedback on those specific questions will also be appreciated).

Laurent Pinchart (8):
  media: pxa_camera: Drop usage of .set_mbus_config()
  media: i2c: ov6650: Drop implementation of .set_mbus_config()
  media: v4l2-subdev: Drop .set_mbus_config() operation
  media: v4l2-fwnode: Move bus config structure to v4l2_mediabus.h
  media: v4l2-mediabus: Use structures to describe bus configuration
  media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_*_LANE flags
  media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_CHANNEL_* flags
  media: v4l2-mediabus: Drop V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag

 drivers/gpu/ipu-v3/ipu-csi.c                  |   6 +-
 drivers/media/i2c/adv7180.c                   |  10 +-
 drivers/media/i2c/adv748x/adv748x-csi2.c      |  18 +--
 drivers/media/i2c/ml86v7667.c                 |   5 +-
 drivers/media/i2c/mt9m001.c                   |   8 +-
 drivers/media/i2c/mt9m111.c                   |  16 +--
 drivers/media/i2c/ov5648.c                    |   4 +-
 drivers/media/i2c/ov6650.c                    |  51 ++-------
 drivers/media/i2c/ov8865.c                    |   4 +-
 drivers/media/i2c/ov9640.c                    |   8 +-
 drivers/media/i2c/tc358743.c                  |  26 +----
 drivers/media/i2c/tvp5150.c                   |   6 +-
 drivers/media/platform/pxa_camera.c           |  21 ++--
 drivers/media/platform/qcom/camss/camss.c     |   2 +-
 drivers/media/platform/rcar-vin/rcar-csi2.c   |  16 +--
 drivers/media/platform/rcar-vin/rcar-vin.h    |   2 +-
 drivers/media/platform/stm32/stm32-dcmi.c     |   2 +-
 .../platform/sunxi/sun4i-csi/sun4i_csi.h      |   2 +-
 .../platform/sunxi/sun4i-csi/sun4i_dma.c      |   2 +-
 drivers/media/platform/ti-vpe/cal-camerarx.c  |   6 +-
 drivers/media/v4l2-core/v4l2-fwnode.c         |  16 ++-
 drivers/media/v4l2-core/v4l2-subdev.c         |   8 --
 drivers/staging/media/imx/imx-media-csi.c     |   7 +-
 drivers/staging/media/imx/imx6-mipi-csi2.c    |  25 +----
 drivers/staging/media/imx/imx7-mipi-csis.c    |   2 +-
 drivers/staging/media/imx/imx8mq-mipi-csi2.c  |   2 +-
 drivers/staging/media/max96712/max96712.c     |   2 +-
 include/media/v4l2-fwnode.h                   |  61 +---------
 include/media/v4l2-mediabus.h                 | 104 ++++++++++++------
 include/media/v4l2-subdev.h                   |  13 ---
 30 files changed, 168 insertions(+), 287 deletions(-)


base-commit: 68b9bcc8a534cd11fe55f8bc82f948aae7d81b3c
-- 
Regards,

Laurent Pinchart


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

* [RFC PATCH 1/8] media: pxa_camera: Drop usage of .set_mbus_config()
  2022-01-03 16:24 [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config() Laurent Pinchart
@ 2022-01-03 16:24 ` Laurent Pinchart
  2022-01-03 16:24 ` [RFC PATCH 2/8] media: i2c: ov6650: Drop implementation " Laurent Pinchart
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 36+ messages in thread
From: Laurent Pinchart @ 2022-01-03 16:24 UTC (permalink / raw)
  To: linux-media
  Cc: linux-renesas-soc, Sakari Ailus, Hans Verkuil, Kieran Bingham,
	Jacopo Mondi, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik

The subdev .set_mbus_config() operation is deprecated and will be
dropped. Drop its usage from the pxa_camera driver, querying the sensor
bus configuration instead of setting it. Only the ov6650 driver supports
the operation, any platform that experiences issues with this change
should update the ov6650 configuration to match what pxa_camera
supports.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/platform/pxa_camera.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
index 3ba00b0f9320..b5644cf37fe9 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -1573,17 +1573,16 @@ static int pxa_camera_set_bus_param(struct pxa_camera_dev *pcdev)
 		mbus_config |= V4L2_MBUS_PCLK_SAMPLE_FALLING;
 	mbus_config |= V4L2_MBUS_DATA_ACTIVE_HIGH;
 
-	cfg.flags = mbus_config;
-	ret = sensor_call(pcdev, pad, set_mbus_config, 0, &cfg);
+	ret = sensor_call(pcdev, pad, get_mbus_config, 0, &cfg);
 	if (ret < 0 && ret != -ENOIOCTLCMD) {
 		dev_err(pcdev_to_dev(pcdev),
-			"Failed to call set_mbus_config: %d\n", ret);
+			"Failed to call get_mbus_config: %d\n", ret);
 		return ret;
 	}
 
 	/*
-	 * If the requested media bus configuration has not been fully applied
-	 * make sure it is supported by the platform.
+	 * If the media bus configuration of the sensor differs, make sure it
+	 * is supported by the platform.
 	 *
 	 * PXA does not support V4L2_MBUS_DATA_ACTIVE_LOW and the bus mastering
 	 * roles should match.
-- 
Regards,

Laurent Pinchart


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

* [RFC PATCH 2/8] media: i2c: ov6650: Drop implementation of .set_mbus_config()
  2022-01-03 16:24 [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config() Laurent Pinchart
  2022-01-03 16:24 ` [RFC PATCH 1/8] media: pxa_camera: Drop usage of .set_mbus_config() Laurent Pinchart
@ 2022-01-03 16:24 ` Laurent Pinchart
  2022-01-05 18:04   ` Sakari Ailus
  2022-01-03 16:24 ` [RFC PATCH 3/8] media: v4l2-subdev: Drop .set_mbus_config() operation Laurent Pinchart
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 36+ messages in thread
From: Laurent Pinchart @ 2022-01-03 16:24 UTC (permalink / raw)
  To: linux-media
  Cc: linux-renesas-soc, Sakari Ailus, Hans Verkuil, Kieran Bingham,
	Jacopo Mondi, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik

The subdev .set_mbus_config() operation is deprecated. No code in the
kernel calls it, so drop its implementation from the ov6650 driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/i2c/ov6650.c | 37 -------------------------------------
 1 file changed, 37 deletions(-)

diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
index f67412150b16..455a627e35a0 100644
--- a/drivers/media/i2c/ov6650.c
+++ b/drivers/media/i2c/ov6650.c
@@ -944,42 +944,6 @@ static int ov6650_get_mbus_config(struct v4l2_subdev *sd,
 	return 0;
 }
 
-/* Alter bus settings on camera side */
-static int ov6650_set_mbus_config(struct v4l2_subdev *sd,
-				  unsigned int pad,
-				  struct v4l2_mbus_config *cfg)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret = 0;
-
-	if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
-		ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_PCLK_RISING, 0);
-	else if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
-		ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_PCLK_RISING);
-	if (ret)
-		return ret;
-
-	if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
-		ret = ov6650_reg_rmw(client, REG_COMF, COMF_HREF_LOW, 0);
-	else if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
-		ret = ov6650_reg_rmw(client, REG_COMF, 0, COMF_HREF_LOW);
-	if (ret)
-		return ret;
-
-	if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
-		ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_VSYNC_HIGH, 0);
-	else if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
-		ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_VSYNC_HIGH);
-	if (ret)
-		return ret;
-
-	/*
-	 * Update the configuration to report what is actually applied to
-	 * the hardware.
-	 */
-	return ov6650_get_mbus_config(sd, pad, cfg);
-}
-
 static const struct v4l2_subdev_video_ops ov6650_video_ops = {
 	.s_stream	= ov6650_s_stream,
 	.g_frame_interval = ov6650_g_frame_interval,
@@ -993,7 +957,6 @@ static const struct v4l2_subdev_pad_ops ov6650_pad_ops = {
 	.get_fmt	= ov6650_get_fmt,
 	.set_fmt	= ov6650_set_fmt,
 	.get_mbus_config = ov6650_get_mbus_config,
-	.set_mbus_config = ov6650_set_mbus_config,
 };
 
 static const struct v4l2_subdev_ops ov6650_subdev_ops = {
-- 
Regards,

Laurent Pinchart


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

* [RFC PATCH 3/8] media: v4l2-subdev: Drop .set_mbus_config() operation
  2022-01-03 16:24 [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config() Laurent Pinchart
  2022-01-03 16:24 ` [RFC PATCH 1/8] media: pxa_camera: Drop usage of .set_mbus_config() Laurent Pinchart
  2022-01-03 16:24 ` [RFC PATCH 2/8] media: i2c: ov6650: Drop implementation " Laurent Pinchart
@ 2022-01-03 16:24 ` Laurent Pinchart
  2022-01-03 16:24 ` [RFC PATCH 4/8] media: v4l2-fwnode: Move bus config structure to v4l2_mediabus.h Laurent Pinchart
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 36+ messages in thread
From: Laurent Pinchart @ 2022-01-03 16:24 UTC (permalink / raw)
  To: linux-media
  Cc: linux-renesas-soc, Sakari Ailus, Hans Verkuil, Kieran Bingham,
	Jacopo Mondi, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik

The .set_mbus_config() operation is deprecated, and nothing in the
kernel uses it. Drop it.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/v4l2-core/v4l2-subdev.c |  8 --------
 include/media/v4l2-mediabus.h         | 15 +++++++--------
 include/media/v4l2-subdev.h           | 13 -------------
 3 files changed, 7 insertions(+), 29 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 5d27a27cc2f2..30eb50407db5 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -318,13 +318,6 @@ static int call_get_mbus_config(struct v4l2_subdev *sd, unsigned int pad,
 	       sd->ops->pad->get_mbus_config(sd, pad, config);
 }
 
-static int call_set_mbus_config(struct v4l2_subdev *sd, unsigned int pad,
-				struct v4l2_mbus_config *config)
-{
-	return check_pad(sd, pad) ? :
-	       sd->ops->pad->get_mbus_config(sd, pad, config);
-}
-
 static const struct v4l2_subdev_pad_ops v4l2_subdev_call_pad_wrappers = {
 	.get_fmt		= call_get_fmt,
 	.set_fmt		= call_set_fmt,
@@ -338,7 +331,6 @@ static const struct v4l2_subdev_pad_ops v4l2_subdev_call_pad_wrappers = {
 	.dv_timings_cap		= call_dv_timings_cap,
 	.enum_dv_timings	= call_enum_dv_timings,
 	.get_mbus_config	= call_get_mbus_config,
-	.set_mbus_config	= call_set_mbus_config,
 };
 
 static const struct v4l2_subdev_video_ops v4l2_subdev_call_video_wrappers = {
diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 841e190aedd9..96af9cedacde 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -15,15 +15,14 @@
  * How to use the V4L2_MBUS_* flags:
  * Flags are defined for each of the possible states and values of a media
  * bus configuration parameter. One and only one bit of each group of flags
- * shall be set by the users of the v4l2_subdev_pad_ops.get_mbus_config and
- * v4l2_subdev_pad_ops.set_mbus_config operations to ensure that no
- * conflicting settings are specified when reporting and setting the media bus
- * configuration with the two operations respectively. For example, it is
- * invalid to set or clear both the V4L2_MBUS_HSYNC_ACTIVE_HIGH and the
+ * shall be set by the users of the v4l2_subdev_pad_ops.get_mbus_config
+ * operation to ensure that no conflicting settings are specified when
+ * reporting the media bus configuration. For example, it is invalid to set or
+ * clear both the V4L2_MBUS_HSYNC_ACTIVE_HIGH and the
  * V4L2_MBUS_HSYNC_ACTIVE_LOW flag at the same time. Instead either flag
- * V4L2_MBUS_HSYNC_ACTIVE_HIGH or flag V4L2_MBUS_HSYNC_ACTIVE_LOW shall be
- * set. The same is true for the V4L2_MBUS_CSI2_1/2/3/4_LANE flags group: only
- * one of these four bits shall be set.
+ * V4L2_MBUS_HSYNC_ACTIVE_HIGH or flag V4L2_MBUS_HSYNC_ACTIVE_LOW shall be set.
+ * The same is true for the V4L2_MBUS_CSI2_1/2/3/4_LANE flags group: only one
+ * of these four bits shall be set.
  *
  * TODO: replace the existing V4L2_MBUS_* flags with structures of fields
  * to avoid conflicting settings.
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 95ec18c2f49c..6c153b33bb04 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -715,17 +715,6 @@ struct v4l2_subdev_state {
  *		     this operation as close as possible to stream on time. The
  *		     operation shall fail if the pad index it has been called on
  *		     is not valid or in case of unrecoverable failures.
- *
- * @set_mbus_config: set the media bus configuration of a remote sub-device.
- *		     This operations is intended to allow, in combination with
- *		     the get_mbus_config operation, the negotiation of media bus
- *		     configuration parameters between media sub-devices. The
- *		     operation shall not fail if the requested configuration is
- *		     not supported, but the driver shall update the content of
- *		     the %config argument to reflect what has been actually
- *		     applied to the hardware. The operation shall fail if the
- *		     pad index it has been called on is not valid or in case of
- *		     unrecoverable failures.
  */
 struct v4l2_subdev_pad_ops {
 	int (*init_cfg)(struct v4l2_subdev *sd,
@@ -768,8 +757,6 @@ struct v4l2_subdev_pad_ops {
 			      struct v4l2_mbus_frame_desc *fd);
 	int (*get_mbus_config)(struct v4l2_subdev *sd, unsigned int pad,
 			       struct v4l2_mbus_config *config);
-	int (*set_mbus_config)(struct v4l2_subdev *sd, unsigned int pad,
-			       struct v4l2_mbus_config *config);
 };
 
 /**
-- 
Regards,

Laurent Pinchart


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

* [RFC PATCH 4/8] media: v4l2-fwnode: Move bus config structure to v4l2_mediabus.h
  2022-01-03 16:24 [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config() Laurent Pinchart
                   ` (2 preceding siblings ...)
  2022-01-03 16:24 ` [RFC PATCH 3/8] media: v4l2-subdev: Drop .set_mbus_config() operation Laurent Pinchart
@ 2022-01-03 16:24 ` Laurent Pinchart
  2022-01-03 16:24 ` [RFC PATCH 5/8] media: v4l2-mediabus: Use structures to describe bus configuration Laurent Pinchart
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 36+ messages in thread
From: Laurent Pinchart @ 2022-01-03 16:24 UTC (permalink / raw)
  To: linux-media
  Cc: linux-renesas-soc, Sakari Ailus, Hans Verkuil, Kieran Bingham,
	Jacopo Mondi, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik, Mats Randgaard, Robert Foss, Hugues Fruchet,
	Maxime Ripard, Rui Miguel Silva, Steve Longerbeam, Philipp Zabel,
	Shawn Guo, Sascha Hauer

To prepare for usage of the v4l2_fwnode_bus_* data structures to
describe bus configuration in the subdev .get_mbus_config() operation,
rename the structures with a v4l2_mbus_config_ prefix instead of
v4l2_fwnode_bus_, and move them to v4l2_mediabus.h.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/i2c/ov5648.c                    |  4 +-
 drivers/media/i2c/ov8865.c                    |  4 +-
 drivers/media/i2c/tc358743.c                  |  2 +-
 drivers/media/platform/qcom/camss/camss.c     |  2 +-
 drivers/media/platform/rcar-vin/rcar-vin.h    |  2 +-
 drivers/media/platform/stm32/stm32-dcmi.c     |  2 +-
 .../platform/sunxi/sun4i-csi/sun4i_csi.h      |  2 +-
 .../platform/sunxi/sun4i-csi/sun4i_dma.c      |  2 +-
 drivers/media/platform/ti-vpe/cal-camerarx.c  |  6 +-
 drivers/media/v4l2-core/v4l2-fwnode.c         | 12 ++--
 drivers/staging/media/imx/imx7-mipi-csis.c    |  2 +-
 drivers/staging/media/imx/imx8mq-mipi-csi2.c  |  2 +-
 drivers/staging/media/max96712/max96712.c     |  2 +-
 include/media/v4l2-fwnode.h                   | 61 ++-----------------
 include/media/v4l2-mediabus.h                 | 49 +++++++++++++++
 15 files changed, 77 insertions(+), 77 deletions(-)

diff --git a/drivers/media/i2c/ov5648.c b/drivers/media/i2c/ov5648.c
index 947d437ed0ef..87f9b724cd7f 100644
--- a/drivers/media/i2c/ov5648.c
+++ b/drivers/media/i2c/ov5648.c
@@ -1112,7 +1112,7 @@ static int ov5648_pad_configure(struct ov5648_sensor *sensor)
 
 static int ov5648_mipi_configure(struct ov5648_sensor *sensor)
 {
-	struct v4l2_fwnode_bus_mipi_csi2 *bus_mipi_csi2 =
+	struct v4l2_mbus_config_mipi_csi2 *bus_mipi_csi2 =
 		&sensor->endpoint.bus.mipi_csi2;
 	unsigned int lanes_count = bus_mipi_csi2->num_data_lanes;
 	int ret;
@@ -1692,7 +1692,7 @@ static int ov5648_state_mipi_configure(struct ov5648_sensor *sensor,
 				       u32 mbus_code)
 {
 	struct ov5648_ctrls *ctrls = &sensor->ctrls;
-	struct v4l2_fwnode_bus_mipi_csi2 *bus_mipi_csi2 =
+	struct v4l2_mbus_config_mipi_csi2 *bus_mipi_csi2 =
 		&sensor->endpoint.bus.mipi_csi2;
 	unsigned long mipi_clk_rate;
 	unsigned int bits_per_sample;
diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c
index d9d016cfa9ac..2b18d8e54098 100644
--- a/drivers/media/i2c/ov8865.c
+++ b/drivers/media/i2c/ov8865.c
@@ -1471,7 +1471,7 @@ static int ov8865_charge_pump_configure(struct ov8865_sensor *sensor)
 
 static int ov8865_mipi_configure(struct ov8865_sensor *sensor)
 {
-	struct v4l2_fwnode_bus_mipi_csi2 *bus_mipi_csi2 =
+	struct v4l2_mbus_config_mipi_csi2 *bus_mipi_csi2 =
 		&sensor->endpoint.bus.mipi_csi2;
 	unsigned int lanes_count = bus_mipi_csi2->num_data_lanes;
 	int ret;
@@ -2241,7 +2241,7 @@ static int ov8865_state_mipi_configure(struct ov8865_sensor *sensor,
 				       u32 mbus_code)
 {
 	struct ov8865_ctrls *ctrls = &sensor->ctrls;
-	struct v4l2_fwnode_bus_mipi_csi2 *bus_mipi_csi2 =
+	struct v4l2_mbus_config_mipi_csi2 *bus_mipi_csi2 =
 		&sensor->endpoint.bus.mipi_csi2;
 	unsigned long mipi_clk_rate;
 	unsigned int bits_per_sample;
diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index 3205cd8298dd..40512004afba 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -69,7 +69,7 @@ static const struct v4l2_dv_timings_cap tc358743_timings_cap = {
 
 struct tc358743_state {
 	struct tc358743_platform_data pdata;
-	struct v4l2_fwnode_bus_mipi_csi2 bus;
+	struct v4l2_mbus_config_mipi_csi2 bus;
 	struct v4l2_subdev sd;
 	struct media_pad pad;
 	struct v4l2_ctrl_handler hdl;
diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index be091c50a3c0..76bd3d4eabb6 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -832,7 +832,7 @@ static int camss_of_parse_endpoint_node(struct device *dev,
 					struct camss_async_subdev *csd)
 {
 	struct csiphy_lanes_cfg *lncfg = &csd->interface.csi2.lane_cfg;
-	struct v4l2_fwnode_bus_mipi_csi2 *mipi_csi2;
+	struct v4l2_mbus_config_mipi_csi2 *mipi_csi2;
 	struct v4l2_fwnode_endpoint vep = { { 0 } };
 	unsigned int i;
 
diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h b/drivers/media/platform/rcar-vin/rcar-vin.h
index 6c06320174a2..7e86e35ca42b 100644
--- a/drivers/media/platform/rcar-vin/rcar-vin.h
+++ b/drivers/media/platform/rcar-vin/rcar-vin.h
@@ -118,7 +118,7 @@ struct rvin_parallel_entity {
 	struct v4l2_subdev *subdev;
 
 	enum v4l2_mbus_type mbus_type;
-	struct v4l2_fwnode_bus_parallel bus;
+	struct v4l2_mbus_config_parallel bus;
 
 	unsigned int source_pad;
 	unsigned int sink_pad;
diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
index e1b17c05229c..7694ffef5c00 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -150,7 +150,7 @@ struct stm32_dcmi {
 	struct mutex			lock;
 	struct vb2_queue		queue;
 
-	struct v4l2_fwnode_bus_parallel	bus;
+	struct v4l2_mbus_config_parallel	bus;
 	enum v4l2_mbus_type		bus_type;
 	struct completion		complete;
 	struct clk			*mclk;
diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.h b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.h
index a5f61ee0ec4d..8eeed87bfb13 100644
--- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.h
+++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.h
@@ -124,7 +124,7 @@ struct sun4i_csi {
 		dma_addr_t		paddr;
 	} scratch;
 
-	struct v4l2_fwnode_bus_parallel	bus;
+	struct v4l2_mbus_config_parallel	bus;
 
 	/* Main Device */
 	struct v4l2_device		v4l;
diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c b/drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c
index 2c39cd7f2862..0912a1b6d525 100644
--- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c
+++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c
@@ -226,7 +226,7 @@ static void return_all_buffers(struct sun4i_csi *csi,
 static int sun4i_csi_start_streaming(struct vb2_queue *vq, unsigned int count)
 {
 	struct sun4i_csi *csi = vb2_get_drv_priv(vq);
-	struct v4l2_fwnode_bus_parallel *bus = &csi->bus;
+	struct v4l2_mbus_config_parallel *bus = &csi->bus;
 	const struct sun4i_csi_format *csi_fmt;
 	unsigned long href_pol, pclk_pol, vref_pol;
 	unsigned long flags;
diff --git a/drivers/media/platform/ti-vpe/cal-camerarx.c b/drivers/media/platform/ti-vpe/cal-camerarx.c
index 4bf7a8c2e711..6b43a1525b45 100644
--- a/drivers/media/platform/ti-vpe/cal-camerarx.c
+++ b/drivers/media/platform/ti-vpe/cal-camerarx.c
@@ -47,7 +47,7 @@ static inline void camerarx_write(struct cal_camerarx *phy, u32 offset, u32 val)
 
 static s64 cal_camerarx_get_ext_link_freq(struct cal_camerarx *phy)
 {
-	struct v4l2_fwnode_bus_mipi_csi2 *mipi_csi2 = &phy->endpoint.bus.mipi_csi2;
+	struct v4l2_mbus_config_mipi_csi2 *mipi_csi2 = &phy->endpoint.bus.mipi_csi2;
 	u32 num_lanes = mipi_csi2->num_data_lanes;
 	const struct cal_format_info *fmtinfo;
 	u32 bpp;
@@ -76,7 +76,7 @@ static void cal_camerarx_lane_config(struct cal_camerarx *phy)
 	u32 val = cal_read(phy->cal, CAL_CSI2_COMPLEXIO_CFG(phy->instance));
 	u32 lane_mask = CAL_CSI2_COMPLEXIO_CFG_CLOCK_POSITION_MASK;
 	u32 polarity_mask = CAL_CSI2_COMPLEXIO_CFG_CLOCK_POL_MASK;
-	struct v4l2_fwnode_bus_mipi_csi2 *mipi_csi2 =
+	struct v4l2_mbus_config_mipi_csi2 *mipi_csi2 =
 		&phy->endpoint.bus.mipi_csi2;
 	int lane;
 
@@ -518,7 +518,7 @@ static int cal_camerarx_regmap_init(struct cal_dev *cal,
 static int cal_camerarx_parse_dt(struct cal_camerarx *phy)
 {
 	struct v4l2_fwnode_endpoint *endpoint = &phy->endpoint;
-	char data_lanes[V4L2_FWNODE_CSI2_MAX_DATA_LANES * 2];
+	char data_lanes[V4L2_MBUS_CSI2_MAX_DATA_LANES * 2];
 	struct device_node *ep_node;
 	unsigned int i;
 	int ret;
diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
index 00457e1e93f6..9ff3ebb230e7 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -119,11 +119,11 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
 					       struct v4l2_fwnode_endpoint *vep,
 					       enum v4l2_mbus_type bus_type)
 {
-	struct v4l2_fwnode_bus_mipi_csi2 *bus = &vep->bus.mipi_csi2;
+	struct v4l2_mbus_config_mipi_csi2 *bus = &vep->bus.mipi_csi2;
 	bool have_clk_lane = false, have_data_lanes = false,
 		have_lane_polarities = false;
 	unsigned int flags = 0, lanes_used = 0;
-	u32 array[1 + V4L2_FWNODE_CSI2_MAX_DATA_LANES];
+	u32 array[1 + V4L2_MBUS_CSI2_MAX_DATA_LANES];
 	u32 clock_lane = 0;
 	unsigned int num_data_lanes = 0;
 	bool use_default_lane_mapping = false;
@@ -136,7 +136,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
 		use_default_lane_mapping = true;
 
 		num_data_lanes = min_t(u32, bus->num_data_lanes,
-				       V4L2_FWNODE_CSI2_MAX_DATA_LANES);
+				       V4L2_MBUS_CSI2_MAX_DATA_LANES);
 
 		clock_lane = bus->clock_lane;
 		if (clock_lane)
@@ -155,7 +155,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
 	rval = fwnode_property_count_u32(fwnode, "data-lanes");
 	if (rval > 0) {
 		num_data_lanes =
-			min_t(int, V4L2_FWNODE_CSI2_MAX_DATA_LANES, rval);
+			min_t(int, V4L2_MBUS_CSI2_MAX_DATA_LANES, rval);
 
 		fwnode_property_read_u32_array(fwnode, "data-lanes", array,
 					       num_data_lanes);
@@ -263,7 +263,7 @@ v4l2_fwnode_endpoint_parse_parallel_bus(struct fwnode_handle *fwnode,
 					struct v4l2_fwnode_endpoint *vep,
 					enum v4l2_mbus_type bus_type)
 {
-	struct v4l2_fwnode_bus_parallel *bus = &vep->bus.parallel;
+	struct v4l2_mbus_config_parallel *bus = &vep->bus.parallel;
 	unsigned int flags = 0;
 	u32 v;
 
@@ -369,7 +369,7 @@ v4l2_fwnode_endpoint_parse_csi1_bus(struct fwnode_handle *fwnode,
 				    struct v4l2_fwnode_endpoint *vep,
 				    enum v4l2_mbus_type bus_type)
 {
-	struct v4l2_fwnode_bus_mipi_csi1 *bus = &vep->bus.mipi_csi1;
+	struct v4l2_mbus_config_mipi_csi1 *bus = &vep->bus.mipi_csi1;
 	u32 v;
 
 	if (!fwnode_property_read_u32(fwnode, "clock-inv", &v)) {
diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c
index 2b73fa55c938..b7afa5351634 100644
--- a/drivers/staging/media/imx/imx7-mipi-csis.c
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -318,7 +318,7 @@ struct csi_state {
 	struct v4l2_async_notifier notifier;
 	struct v4l2_subdev *src_sd;
 
-	struct v4l2_fwnode_bus_mipi_csi2 bus;
+	struct v4l2_mbus_config_mipi_csi2 bus;
 	u32 clk_frequency;
 	u32 hs_settle;
 	u32 clk_settle;
diff --git a/drivers/staging/media/imx/imx8mq-mipi-csi2.c b/drivers/staging/media/imx/imx8mq-mipi-csi2.c
index 7adbdd14daa9..5facf1b140a3 100644
--- a/drivers/staging/media/imx/imx8mq-mipi-csi2.c
+++ b/drivers/staging/media/imx/imx8mq-mipi-csi2.c
@@ -117,7 +117,7 @@ struct csi_state {
 	struct v4l2_async_notifier notifier;
 	struct v4l2_subdev *src_sd;
 
-	struct v4l2_fwnode_bus_mipi_csi2 bus;
+	struct v4l2_mbus_config_mipi_csi2 bus;
 
 	struct mutex lock; /* Protect csi2_fmt, format_mbus, state, hs_settle */
 	const struct csi2_pix_format *csi2_fmt;
diff --git a/drivers/staging/media/max96712/max96712.c b/drivers/staging/media/max96712/max96712.c
index 9bc72d9a858b..6b5abd958bff 100644
--- a/drivers/staging/media/max96712/max96712.c
+++ b/drivers/staging/media/max96712/max96712.c
@@ -30,7 +30,7 @@ struct max96712_priv {
 	struct regmap *regmap;
 	struct gpio_desc *gpiod_pwdn;
 
-	struct v4l2_fwnode_bus_mipi_csi2 mipi;
+	struct v4l2_mbus_config_mipi_csi2 mipi;
 
 	struct v4l2_subdev sd;
 	struct v4l2_ctrl_handler ctrl_handler;
diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h
index 9c97f1dbd1c6..feb132df45a3 100644
--- a/include/media/v4l2-fwnode.h
+++ b/include/media/v4l2-fwnode.h
@@ -25,68 +25,19 @@ struct fwnode_handle;
 struct v4l2_async_notifier;
 struct v4l2_async_subdev;
 
-#define V4L2_FWNODE_CSI2_MAX_DATA_LANES	8
-
-/**
- * struct v4l2_fwnode_bus_mipi_csi2 - MIPI CSI-2 bus data structure
- * @flags: media bus (V4L2_MBUS_*) flags
- * @data_lanes: an array of physical data lane indexes
- * @clock_lane: physical lane index of the clock lane
- * @num_data_lanes: number of data lanes
- * @lane_polarities: polarity of the lanes. The order is the same of
- *		   the physical lanes.
- */
-struct v4l2_fwnode_bus_mipi_csi2 {
-	unsigned int flags;
-	unsigned char data_lanes[V4L2_FWNODE_CSI2_MAX_DATA_LANES];
-	unsigned char clock_lane;
-	unsigned char num_data_lanes;
-	bool lane_polarities[1 + V4L2_FWNODE_CSI2_MAX_DATA_LANES];
-};
-
-/**
- * struct v4l2_fwnode_bus_parallel - parallel data bus data structure
- * @flags: media bus (V4L2_MBUS_*) flags
- * @bus_width: bus width in bits
- * @data_shift: data shift in bits
- */
-struct v4l2_fwnode_bus_parallel {
-	unsigned int flags;
-	unsigned char bus_width;
-	unsigned char data_shift;
-};
-
-/**
- * struct v4l2_fwnode_bus_mipi_csi1 - CSI-1/CCP2 data bus structure
- * @clock_inv: polarity of clock/strobe signal
- *	       false - not inverted, true - inverted
- * @strobe: false - data/clock, true - data/strobe
- * @lane_polarity: the polarities of the clock (index 0) and data lanes
- *		   index (1)
- * @data_lane: the number of the data lane
- * @clock_lane: the number of the clock lane
- */
-struct v4l2_fwnode_bus_mipi_csi1 {
-	unsigned char clock_inv:1;
-	unsigned char strobe:1;
-	bool lane_polarity[2];
-	unsigned char data_lane;
-	unsigned char clock_lane;
-};
-
 /**
  * struct v4l2_fwnode_endpoint - the endpoint data structure
  * @base: fwnode endpoint of the v4l2_fwnode
  * @bus_type: bus type
  * @bus: bus configuration data structure
- * @bus.parallel: embedded &struct v4l2_fwnode_bus_parallel.
+ * @bus.parallel: embedded &struct v4l2_mbus_config_parallel.
  *		  Used if the bus is parallel.
- * @bus.mipi_csi1: embedded &struct v4l2_fwnode_bus_mipi_csi1.
+ * @bus.mipi_csi1: embedded &struct v4l2_mbus_config_mipi_csi1.
  *		   Used if the bus is MIPI Alliance's Camera Serial
  *		   Interface version 1 (MIPI CSI1) or Standard
  *		   Mobile Imaging Architecture's Compact Camera Port 2
  *		   (SMIA CCP2).
- * @bus.mipi_csi2: embedded &struct v4l2_fwnode_bus_mipi_csi2.
+ * @bus.mipi_csi2: embedded &struct v4l2_mbus_config_mipi_csi2.
  *		   Used if the bus is MIPI Alliance's Camera Serial
  *		   Interface version 2 (MIPI CSI2).
  * @link_frequencies: array of supported link frequencies
@@ -100,9 +51,9 @@ struct v4l2_fwnode_endpoint {
 	 */
 	enum v4l2_mbus_type bus_type;
 	struct {
-		struct v4l2_fwnode_bus_parallel parallel;
-		struct v4l2_fwnode_bus_mipi_csi1 mipi_csi1;
-		struct v4l2_fwnode_bus_mipi_csi2 mipi_csi2;
+		struct v4l2_mbus_config_parallel parallel;
+		struct v4l2_mbus_config_mipi_csi1 mipi_csi1;
+		struct v4l2_mbus_config_mipi_csi2 mipi_csi2;
 	} bus;
 	u64 *link_frequencies;
 	unsigned int nr_of_link_frequencies;
diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 96af9cedacde..9c4970fbd8ea 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -92,6 +92,55 @@
 					 V4L2_MBUS_CSI2_CHANNEL_2 | \
 					 V4L2_MBUS_CSI2_CHANNEL_3)
 
+#define V4L2_MBUS_CSI2_MAX_DATA_LANES		8
+
+/**
+ * struct v4l2_mbus_config_mipi_csi2 - MIPI CSI-2 data bus configuration
+ * @flags: media bus (V4L2_MBUS_*) flags
+ * @data_lanes: an array of physical data lane indexes
+ * @clock_lane: physical lane index of the clock lane
+ * @num_data_lanes: number of data lanes
+ * @lane_polarities: polarity of the lanes. The order is the same of
+ *		   the physical lanes.
+ */
+struct v4l2_mbus_config_mipi_csi2 {
+	unsigned int flags;
+	unsigned char data_lanes[V4L2_MBUS_CSI2_MAX_DATA_LANES];
+	unsigned char clock_lane;
+	unsigned char num_data_lanes;
+	bool lane_polarities[1 + V4L2_MBUS_CSI2_MAX_DATA_LANES];
+};
+
+/**
+ * struct v4l2_mbus_config_parallel - parallel data bus configuration
+ * @flags: media bus (V4L2_MBUS_*) flags
+ * @bus_width: bus width in bits
+ * @data_shift: data shift in bits
+ */
+struct v4l2_mbus_config_parallel {
+	unsigned int flags;
+	unsigned char bus_width;
+	unsigned char data_shift;
+};
+
+/**
+ * struct v4l2_mbus_config_mipi_csi1 - CSI-1/CCP2 data bus configuration
+ * @clock_inv: polarity of clock/strobe signal
+ *	       false - not inverted, true - inverted
+ * @strobe: false - data/clock, true - data/strobe
+ * @lane_polarity: the polarities of the clock (index 0) and data lanes
+ *		   index (1)
+ * @data_lane: the number of the data lane
+ * @clock_lane: the number of the clock lane
+ */
+struct v4l2_mbus_config_mipi_csi1 {
+	unsigned char clock_inv:1;
+	unsigned char strobe:1;
+	bool lane_polarity[2];
+	unsigned char data_lane;
+	unsigned char clock_lane;
+};
+
 /**
  * enum v4l2_mbus_type - media bus type
  * @V4L2_MBUS_UNKNOWN:	unknown bus type, no V4L2 mediabus configuration
-- 
Regards,

Laurent Pinchart


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

* [RFC PATCH 5/8] media: v4l2-mediabus: Use structures to describe bus configuration
  2022-01-03 16:24 [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config() Laurent Pinchart
                   ` (3 preceding siblings ...)
  2022-01-03 16:24 ` [RFC PATCH 4/8] media: v4l2-fwnode: Move bus config structure to v4l2_mediabus.h Laurent Pinchart
@ 2022-01-03 16:24 ` Laurent Pinchart
  2022-02-15 11:13   ` Jacopo Mondi
  2022-01-03 16:24 ` [RFC PATCH 6/8] media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_*_LANE flags Laurent Pinchart
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 36+ messages in thread
From: Laurent Pinchart @ 2022-01-03 16:24 UTC (permalink / raw)
  To: linux-media
  Cc: linux-renesas-soc, Sakari Ailus, Hans Verkuil, Kieran Bingham,
	Jacopo Mondi, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik, Philipp Zabel, Lars-Peter Clausen, Petr Cvek,
	Mats Randgaard, Steve Longerbeam, Shawn Guo, Sascha Hauer

The media bus configuration is specified through a set of flags, some of
which being mutually exclusive. This doesn't scale to express more
complex configurations. Improve the API by replacing the single flags
field in v4l2_mbus_config by a union of v4l2_mbus_config_* structures.
The flags themselves are still used in those structures, so they are
kept here. Drivers are however updated to use structure fields instead
of flags when already possible.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/gpu/ipu-v3/ipu-csi.c                |  6 ++---
 drivers/media/i2c/adv7180.c                 |  8 ++++---
 drivers/media/i2c/adv748x/adv748x-csi2.c    | 18 +--------------
 drivers/media/i2c/ml86v7667.c               |  5 +++--
 drivers/media/i2c/mt9m001.c                 |  8 ++++---
 drivers/media/i2c/mt9m111.c                 | 16 +++++++------
 drivers/media/i2c/ov6650.c                  | 14 ++++++------
 drivers/media/i2c/ov9640.c                  |  8 ++++---
 drivers/media/i2c/tc358743.c                | 20 ++---------------
 drivers/media/i2c/tvp5150.c                 |  6 +++--
 drivers/media/platform/pxa_camera.c         | 12 +++++-----
 drivers/media/platform/rcar-vin/rcar-csi2.c | 16 +++----------
 drivers/staging/media/imx/imx-media-csi.c   |  7 +++---
 drivers/staging/media/imx/imx6-mipi-csi2.c  | 25 +++------------------
 include/media/v4l2-mediabus.h               | 20 ++++++++++++++---
 15 files changed, 78 insertions(+), 111 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
index a9639d098893..778bc26d3ba5 100644
--- a/drivers/gpu/ipu-v3/ipu-csi.c
+++ b/drivers/gpu/ipu-v3/ipu-csi.c
@@ -357,11 +357,11 @@ static int fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
 	switch (mbus_cfg->type) {
 	case V4L2_MBUS_PARALLEL:
 		csicfg->ext_vsync = 1;
-		csicfg->vsync_pol = (mbus_cfg->flags &
+		csicfg->vsync_pol = (mbus_cfg->bus.parallel.flags &
 				     V4L2_MBUS_VSYNC_ACTIVE_LOW) ? 1 : 0;
-		csicfg->hsync_pol = (mbus_cfg->flags &
+		csicfg->hsync_pol = (mbus_cfg->bus.parallel.flags &
 				     V4L2_MBUS_HSYNC_ACTIVE_LOW) ? 1 : 0;
-		csicfg->pixclk_pol = (mbus_cfg->flags &
+		csicfg->pixclk_pol = (mbus_cfg->bus.parallel.flags &
 				      V4L2_MBUS_PCLK_SAMPLE_FALLING) ? 1 : 0;
 		csicfg->clk_mode = IPU_CSI_CLK_MODE_GATED_CLK;
 		break;
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index d9a99fcfacb1..286f5017d9c3 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -784,7 +784,8 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
 
 	if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
 		cfg->type = V4L2_MBUS_CSI2_DPHY;
-		cfg->flags = V4L2_MBUS_CSI2_1_LANE |
+		cfg->bus.mipi_csi2.num_data_lanes = 1;
+		cfg->bus.mipi_csi2.flags =
 				V4L2_MBUS_CSI2_CHANNEL_0 |
 				V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
 	} else {
@@ -792,8 +793,9 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
 		 * The ADV7180 sensor supports BT.601/656 output modes.
 		 * The BT.656 is default and not yet configurable by s/w.
 		 */
-		cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
-				 V4L2_MBUS_DATA_ACTIVE_HIGH;
+		cfg->bus.parallel.flags = V4L2_MBUS_MASTER |
+					  V4L2_MBUS_PCLK_SAMPLE_RISING |
+					  V4L2_MBUS_DATA_ACTIVE_HIGH;
 		cfg->type = V4L2_MBUS_BT656;
 	}
 
diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c
index 589e9644fcdc..bd4f3fe0e309 100644
--- a/drivers/media/i2c/adv748x/adv748x-csi2.c
+++ b/drivers/media/i2c/adv748x/adv748x-csi2.c
@@ -222,23 +222,7 @@ static int adv748x_csi2_get_mbus_config(struct v4l2_subdev *sd, unsigned int pad
 		return -EINVAL;
 
 	config->type = V4L2_MBUS_CSI2_DPHY;
-	switch (tx->active_lanes) {
-	case 1:
-		config->flags = V4L2_MBUS_CSI2_1_LANE;
-		break;
-
-	case 2:
-		config->flags = V4L2_MBUS_CSI2_2_LANE;
-		break;
-
-	case 3:
-		config->flags = V4L2_MBUS_CSI2_3_LANE;
-		break;
-
-	case 4:
-		config->flags = V4L2_MBUS_CSI2_4_LANE;
-		break;
-	}
+	config->bus.mipi_csi2.num_data_lanes = tx->active_lanes;
 
 	return 0;
 }
diff --git a/drivers/media/i2c/ml86v7667.c b/drivers/media/i2c/ml86v7667.c
index 4a1410ebb4c8..48cc0b0922f4 100644
--- a/drivers/media/i2c/ml86v7667.c
+++ b/drivers/media/i2c/ml86v7667.c
@@ -223,9 +223,10 @@ static int ml86v7667_get_mbus_config(struct v4l2_subdev *sd,
 				     unsigned int pad,
 				     struct v4l2_mbus_config *cfg)
 {
-	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
-		     V4L2_MBUS_DATA_ACTIVE_HIGH;
 	cfg->type = V4L2_MBUS_BT656;
+	cfg->bus.parallel.flags = V4L2_MBUS_MASTER |
+				  V4L2_MBUS_PCLK_SAMPLE_RISING |
+				  V4L2_MBUS_DATA_ACTIVE_HIGH;
 
 	return 0;
 }
diff --git a/drivers/media/i2c/mt9m001.c b/drivers/media/i2c/mt9m001.c
index c9f0bd997ea7..ad13b0c890c0 100644
--- a/drivers/media/i2c/mt9m001.c
+++ b/drivers/media/i2c/mt9m001.c
@@ -695,10 +695,12 @@ static int mt9m001_get_mbus_config(struct v4l2_subdev *sd,
 				   struct v4l2_mbus_config *cfg)
 {
 	/* MT9M001 has all capture_format parameters fixed */
-	cfg->flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
-		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
-		V4L2_MBUS_DATA_ACTIVE_HIGH | V4L2_MBUS_MASTER;
 	cfg->type = V4L2_MBUS_PARALLEL;
+	cfg->bus.parallel.flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
+				  V4L2_MBUS_HSYNC_ACTIVE_HIGH |
+				  V4L2_MBUS_VSYNC_ACTIVE_HIGH |
+				  V4L2_MBUS_DATA_ACTIVE_HIGH |
+				  V4L2_MBUS_MASTER;
 
 	return 0;
 }
diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
index 91a44359bcd3..6cf3ccf85d27 100644
--- a/drivers/media/i2c/mt9m111.c
+++ b/drivers/media/i2c/mt9m111.c
@@ -1143,15 +1143,17 @@ static int mt9m111_get_mbus_config(struct v4l2_subdev *sd,
 {
 	struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev);
 
-	cfg->flags = V4L2_MBUS_MASTER |
-		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
-		V4L2_MBUS_DATA_ACTIVE_HIGH;
-
-	cfg->flags |= mt9m111->pclk_sample ? V4L2_MBUS_PCLK_SAMPLE_RISING :
-		V4L2_MBUS_PCLK_SAMPLE_FALLING;
-
 	cfg->type = V4L2_MBUS_PARALLEL;
 
+	cfg->bus.parallel.flags = V4L2_MBUS_MASTER |
+				  V4L2_MBUS_HSYNC_ACTIVE_HIGH |
+				  V4L2_MBUS_VSYNC_ACTIVE_HIGH |
+				  V4L2_MBUS_DATA_ACTIVE_HIGH;
+
+	cfg->bus.parallel.flags |= mt9m111->pclk_sample ?
+				   V4L2_MBUS_PCLK_SAMPLE_RISING :
+				   V4L2_MBUS_PCLK_SAMPLE_FALLING;
+
 	return 0;
 }
 
diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
index 455a627e35a0..b2654b32bc62 100644
--- a/drivers/media/i2c/ov6650.c
+++ b/drivers/media/i2c/ov6650.c
@@ -932,15 +932,15 @@ static int ov6650_get_mbus_config(struct v4l2_subdev *sd,
 	if (ret)
 		return ret;
 
-	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_DATA_ACTIVE_HIGH
-		   | ((comj & COMJ_VSYNC_HIGH)  ? V4L2_MBUS_VSYNC_ACTIVE_HIGH
-						: V4L2_MBUS_VSYNC_ACTIVE_LOW)
-		   | ((comf & COMF_HREF_LOW)    ? V4L2_MBUS_HSYNC_ACTIVE_LOW
-						: V4L2_MBUS_HSYNC_ACTIVE_HIGH)
-		   | ((comj & COMJ_PCLK_RISING) ? V4L2_MBUS_PCLK_SAMPLE_RISING
-						: V4L2_MBUS_PCLK_SAMPLE_FALLING);
 	cfg->type = V4L2_MBUS_PARALLEL;
 
+	cfg->bus.parallel.flags = V4L2_MBUS_MASTER | V4L2_MBUS_DATA_ACTIVE_HIGH
+		| ((comj & COMJ_VSYNC_HIGH)  ? V4L2_MBUS_VSYNC_ACTIVE_HIGH
+					     : V4L2_MBUS_VSYNC_ACTIVE_LOW)
+		| ((comf & COMF_HREF_LOW)    ? V4L2_MBUS_HSYNC_ACTIVE_LOW
+					     : V4L2_MBUS_HSYNC_ACTIVE_HIGH)
+		| ((comj & COMJ_PCLK_RISING) ? V4L2_MBUS_PCLK_SAMPLE_RISING
+					     : V4L2_MBUS_PCLK_SAMPLE_FALLING);
 	return 0;
 }
 
diff --git a/drivers/media/i2c/ov9640.c b/drivers/media/i2c/ov9640.c
index 0bab8c2cf160..9f44ed52d164 100644
--- a/drivers/media/i2c/ov9640.c
+++ b/drivers/media/i2c/ov9640.c
@@ -652,10 +652,12 @@ static int ov9640_get_mbus_config(struct v4l2_subdev *sd,
 				  unsigned int pad,
 				  struct v4l2_mbus_config *cfg)
 {
-	cfg->flags = V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_MASTER |
-		V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
-		V4L2_MBUS_DATA_ACTIVE_HIGH;
 	cfg->type = V4L2_MBUS_PARALLEL;
+	cfg->bus.parallel.flags = V4L2_MBUS_PCLK_SAMPLE_RISING |
+				  V4L2_MBUS_MASTER |
+				  V4L2_MBUS_VSYNC_ACTIVE_HIGH |
+				  V4L2_MBUS_HSYNC_ACTIVE_HIGH |
+				  V4L2_MBUS_DATA_ACTIVE_HIGH;
 
 	return 0;
 }
diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index 40512004afba..dfbc42675143 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -1613,24 +1613,8 @@ static int tc358743_get_mbus_config(struct v4l2_subdev *sd,
 	cfg->type = V4L2_MBUS_CSI2_DPHY;
 
 	/* Support for non-continuous CSI-2 clock is missing in the driver */
-	cfg->flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
-
-	switch (state->csi_lanes_in_use) {
-	case 1:
-		cfg->flags |= V4L2_MBUS_CSI2_1_LANE;
-		break;
-	case 2:
-		cfg->flags |= V4L2_MBUS_CSI2_2_LANE;
-		break;
-	case 3:
-		cfg->flags |= V4L2_MBUS_CSI2_3_LANE;
-		break;
-	case 4:
-		cfg->flags |= V4L2_MBUS_CSI2_4_LANE;
-		break;
-	default:
-		return -EINVAL;
-	}
+	cfg->bus.mipi_csi2.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
+	cfg->bus.mipi_csi2.num_data_lanes = state->csi_lanes_in_use;
 
 	return 0;
 }
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 4b16ffcaef98..65472438444b 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -1198,8 +1198,10 @@ static int tvp5150_get_mbus_config(struct v4l2_subdev *sd,
 	struct tvp5150 *decoder = to_tvp5150(sd);
 
 	cfg->type = decoder->mbus_type;
-	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING
-		   | V4L2_MBUS_FIELD_EVEN_LOW | V4L2_MBUS_DATA_ACTIVE_HIGH;
+	cfg->bus.parallel.flags = V4L2_MBUS_MASTER
+				| V4L2_MBUS_PCLK_SAMPLE_RISING
+				| V4L2_MBUS_FIELD_EVEN_LOW
+				| V4L2_MBUS_DATA_ACTIVE_HIGH;
 
 	return 0;
 }
diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
index b5644cf37fe9..35145e3348f0 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -1587,24 +1587,26 @@ static int pxa_camera_set_bus_param(struct pxa_camera_dev *pcdev)
 	 * PXA does not support V4L2_MBUS_DATA_ACTIVE_LOW and the bus mastering
 	 * roles should match.
 	 */
-	if (cfg.flags != mbus_config) {
+	if (cfg.bus.parallel.flags != mbus_config) {
 		unsigned int pxa_mbus_role = mbus_config & (V4L2_MBUS_MASTER |
 							    V4L2_MBUS_SLAVE);
-		if (pxa_mbus_role != (cfg.flags & (V4L2_MBUS_MASTER |
-						   V4L2_MBUS_SLAVE))) {
+		unsigned int flags = cfg.bus.parallel.flags;
+
+		if (pxa_mbus_role != (flags & (V4L2_MBUS_MASTER |
+					       V4L2_MBUS_SLAVE))) {
 			dev_err(pcdev_to_dev(pcdev),
 				"Unsupported mbus configuration: bus mastering\n");
 			return -EINVAL;
 		}
 
-		if (cfg.flags & V4L2_MBUS_DATA_ACTIVE_LOW) {
+		if (flags & V4L2_MBUS_DATA_ACTIVE_LOW) {
 			dev_err(pcdev_to_dev(pcdev),
 				"Unsupported mbus configuration: DATA_ACTIVE_LOW\n");
 			return -EINVAL;
 		}
 	}
 
-	pxa_camera_setup_cicr(pcdev, cfg.flags, pixfmt);
+	pxa_camera_setup_cicr(pcdev, cfg.bus.parallel.flags, pixfmt);
 
 	return 0;
 }
diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
index 8c939cb3073d..cbac5801720b 100644
--- a/drivers/media/platform/rcar-vin/rcar-csi2.c
+++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
@@ -603,7 +603,6 @@ static int rcsi2_get_active_lanes(struct rcar_csi2 *priv,
 				  unsigned int *lanes)
 {
 	struct v4l2_mbus_config mbus_config = { 0 };
-	unsigned int num_lanes = UINT_MAX;
 	int ret;
 
 	*lanes = priv->lanes;
@@ -626,23 +625,14 @@ static int rcsi2_get_active_lanes(struct rcar_csi2 *priv,
 		return -EINVAL;
 	}
 
-	if (mbus_config.flags & V4L2_MBUS_CSI2_1_LANE)
-		num_lanes = 1;
-	else if (mbus_config.flags & V4L2_MBUS_CSI2_2_LANE)
-		num_lanes = 2;
-	else if (mbus_config.flags & V4L2_MBUS_CSI2_3_LANE)
-		num_lanes = 3;
-	else if (mbus_config.flags & V4L2_MBUS_CSI2_4_LANE)
-		num_lanes = 4;
-
-	if (num_lanes > priv->lanes) {
+	if (mbus_config.bus.mipi_csi2.num_data_lanes > priv->lanes) {
 		dev_err(priv->dev,
 			"Unsupported mbus config: too many data lanes %u\n",
-			num_lanes);
+			mbus_config.bus.mipi_csi2.num_data_lanes);
 		return -EINVAL;
 	}
 
-	*lanes = num_lanes;
+	*lanes = mbus_config.bus.mipi_csi2.num_data_lanes;
 
 	return 0;
 }
diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c
index bd7f156f2d52..b2b1f4dd41d7 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -718,9 +718,10 @@ static int csi_setup(struct csi_priv *priv)
 
 	/* compose mbus_config from the upstream endpoint */
 	mbus_cfg.type = priv->upstream_ep.bus_type;
-	mbus_cfg.flags = is_parallel_bus(&priv->upstream_ep) ?
-		priv->upstream_ep.bus.parallel.flags :
-		priv->upstream_ep.bus.mipi_csi2.flags;
+	if (is_parallel_bus(&priv->upstream_ep))
+		mbus_cfg.bus.parallel = priv->upstream_ep.bus.parallel;
+	else
+		mbus_cfg.bus.mipi_csi2 = priv->upstream_ep.bus.mipi_csi2;
 
 	if_fmt = *infmt;
 	crop = priv->crop;
diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c
index 558b256ac935..c4cb558a85c6 100644
--- a/drivers/staging/media/imx/imx6-mipi-csi2.c
+++ b/drivers/staging/media/imx/imx6-mipi-csi2.c
@@ -303,7 +303,6 @@ static void csi2ipu_gasket_init(struct csi2_dev *csi2)
 static int csi2_get_active_lanes(struct csi2_dev *csi2, unsigned int *lanes)
 {
 	struct v4l2_mbus_config mbus_config = { 0 };
-	unsigned int num_lanes = UINT_MAX;
 	int ret;
 
 	*lanes = csi2->data_lanes;
@@ -326,32 +325,14 @@ static int csi2_get_active_lanes(struct csi2_dev *csi2, unsigned int *lanes)
 		return -EINVAL;
 	}
 
-	switch (mbus_config.flags & V4L2_MBUS_CSI2_LANES) {
-	case V4L2_MBUS_CSI2_1_LANE:
-		num_lanes = 1;
-		break;
-	case V4L2_MBUS_CSI2_2_LANE:
-		num_lanes = 2;
-		break;
-	case V4L2_MBUS_CSI2_3_LANE:
-		num_lanes = 3;
-		break;
-	case V4L2_MBUS_CSI2_4_LANE:
-		num_lanes = 4;
-		break;
-	default:
-		num_lanes = csi2->data_lanes;
-		break;
-	}
-
-	if (num_lanes > csi2->data_lanes) {
+	if (mbus_config.bus.mipi_csi2.num_data_lanes > csi2->data_lanes) {
 		dev_err(csi2->dev,
 			"Unsupported mbus config: too many data lanes %u\n",
-			num_lanes);
+			mbus_config.bus.mipi_csi2.num_data_lanes);
 		return -EINVAL;
 	}
 
-	*lanes = num_lanes;
+	*lanes = mbus_config.bus.mipi_csi2.num_data_lanes;
 
 	return 0;
 }
diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 9c4970fbd8ea..269aaf57ba32 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -166,12 +166,26 @@ enum v4l2_mbus_type {
 
 /**
  * struct v4l2_mbus_config - media bus configuration
- * @type:	in: interface type
- * @flags:	in / out: configuration flags, depending on @type
+ * @type: interface type
+ * @bus: bus configuration data structure
+ * @bus.parallel: embedded &struct v4l2_mbus_config_parallel.
+ *		  Used if the bus is parallel or BT.656.
+ * @bus.mipi_csi1: embedded &struct v4l2_mbus_config_mipi_csi1.
+ *		   Used if the bus is MIPI Alliance's Camera Serial
+ *		   Interface version 1 (MIPI CSI1) or Standard
+ *		   Mobile Imaging Architecture's Compact Camera Port 2
+ *		   (SMIA CCP2).
+ * @bus.mipi_csi2: embedded &struct v4l2_mbus_config_mipi_csi2.
+ *		   Used if the bus is MIPI Alliance's Camera Serial
+ *		   Interface version 2 (MIPI CSI2).
  */
 struct v4l2_mbus_config {
 	enum v4l2_mbus_type type;
-	unsigned int flags;
+	union {
+		struct v4l2_mbus_config_parallel parallel;
+		struct v4l2_mbus_config_mipi_csi1 mipi_csi1;
+		struct v4l2_mbus_config_mipi_csi2 mipi_csi2;
+	} bus;
 };
 
 /**
-- 
Regards,

Laurent Pinchart


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

* [RFC PATCH 6/8] media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_*_LANE flags
  2022-01-03 16:24 [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config() Laurent Pinchart
                   ` (4 preceding siblings ...)
  2022-01-03 16:24 ` [RFC PATCH 5/8] media: v4l2-mediabus: Use structures to describe bus configuration Laurent Pinchart
@ 2022-01-03 16:24 ` Laurent Pinchart
  2022-02-15 11:14   ` Jacopo Mondi
  2022-01-03 16:24 ` [RFC PATCH 7/8] media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_CHANNEL_* flags Laurent Pinchart
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 36+ messages in thread
From: Laurent Pinchart @ 2022-01-03 16:24 UTC (permalink / raw)
  To: linux-media
  Cc: linux-renesas-soc, Sakari Ailus, Hans Verkuil, Kieran Bingham,
	Jacopo Mondi, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik

The V4L2_MBUS_CSI2_*_LANE flags are a legacy API and are unused. Drop
them.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 include/media/v4l2-mediabus.h | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 269aaf57ba32..44195ceeccca 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -21,8 +21,6 @@
  * clear both the V4L2_MBUS_HSYNC_ACTIVE_HIGH and the
  * V4L2_MBUS_HSYNC_ACTIVE_LOW flag at the same time. Instead either flag
  * V4L2_MBUS_HSYNC_ACTIVE_HIGH or flag V4L2_MBUS_HSYNC_ACTIVE_LOW shall be set.
- * The same is true for the V4L2_MBUS_CSI2_1/2/3/4_LANE flags group: only one
- * of these four bits shall be set.
  *
  * TODO: replace the existing V4L2_MBUS_* flags with structures of fields
  * to avoid conflicting settings.
@@ -69,11 +67,6 @@
 #define V4L2_MBUS_DATA_ENABLE_LOW		BIT(15)
 
 /* Serial flags */
-/* CSI-2 D-PHY number of data lanes. */
-#define V4L2_MBUS_CSI2_1_LANE			BIT(0)
-#define V4L2_MBUS_CSI2_2_LANE			BIT(1)
-#define V4L2_MBUS_CSI2_3_LANE			BIT(2)
-#define V4L2_MBUS_CSI2_4_LANE			BIT(3)
 /* CSI-2 Virtual Channel identifiers. */
 #define V4L2_MBUS_CSI2_CHANNEL_0		BIT(4)
 #define V4L2_MBUS_CSI2_CHANNEL_1		BIT(5)
@@ -83,10 +76,6 @@
 #define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK		BIT(8)
 #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(9)
 
-#define V4L2_MBUS_CSI2_LANES		(V4L2_MBUS_CSI2_1_LANE | \
-					 V4L2_MBUS_CSI2_2_LANE | \
-					 V4L2_MBUS_CSI2_3_LANE | \
-					 V4L2_MBUS_CSI2_4_LANE)
 #define V4L2_MBUS_CSI2_CHANNELS		(V4L2_MBUS_CSI2_CHANNEL_0 | \
 					 V4L2_MBUS_CSI2_CHANNEL_1 | \
 					 V4L2_MBUS_CSI2_CHANNEL_2 | \
-- 
Regards,

Laurent Pinchart


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

* [RFC PATCH 7/8] media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_CHANNEL_* flags
  2022-01-03 16:24 [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config() Laurent Pinchart
                   ` (5 preceding siblings ...)
  2022-01-03 16:24 ` [RFC PATCH 6/8] media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_*_LANE flags Laurent Pinchart
@ 2022-01-03 16:24 ` Laurent Pinchart
  2022-02-15 11:01   ` Jacopo Mondi
  2022-01-03 16:24 ` [RFC PATCH 8/8] media: v4l2-mediabus: Drop V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag Laurent Pinchart
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 36+ messages in thread
From: Laurent Pinchart @ 2022-01-03 16:24 UTC (permalink / raw)
  To: linux-media
  Cc: linux-renesas-soc, Sakari Ailus, Hans Verkuil, Kieran Bingham,
	Jacopo Mondi, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik, Lars-Peter Clausen

The V4L2_MBUS_CSI2_CHANNEL_* flags are a legacy API. Only
V4L2_MBUS_CSI2_CHANNEL_0 is used, set in a single driver, and never
read. Drop those flags. Virtual channel information should be conveyed
through frame descriptors instead.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/i2c/adv7180.c   |  1 -
 include/media/v4l2-mediabus.h | 10 ----------
 2 files changed, 11 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 286f5017d9c3..3ff37a550810 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -786,7 +786,6 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
 		cfg->type = V4L2_MBUS_CSI2_DPHY;
 		cfg->bus.mipi_csi2.num_data_lanes = 1;
 		cfg->bus.mipi_csi2.flags =
-				V4L2_MBUS_CSI2_CHANNEL_0 |
 				V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
 	} else {
 		/*
diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 44195ceeccca..c6626a22b394 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -67,20 +67,10 @@
 #define V4L2_MBUS_DATA_ENABLE_LOW		BIT(15)
 
 /* Serial flags */
-/* CSI-2 Virtual Channel identifiers. */
-#define V4L2_MBUS_CSI2_CHANNEL_0		BIT(4)
-#define V4L2_MBUS_CSI2_CHANNEL_1		BIT(5)
-#define V4L2_MBUS_CSI2_CHANNEL_2		BIT(6)
-#define V4L2_MBUS_CSI2_CHANNEL_3		BIT(7)
 /* Clock non-continuous mode support. */
 #define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK		BIT(8)
 #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(9)
 
-#define V4L2_MBUS_CSI2_CHANNELS		(V4L2_MBUS_CSI2_CHANNEL_0 | \
-					 V4L2_MBUS_CSI2_CHANNEL_1 | \
-					 V4L2_MBUS_CSI2_CHANNEL_2 | \
-					 V4L2_MBUS_CSI2_CHANNEL_3)
-
 #define V4L2_MBUS_CSI2_MAX_DATA_LANES		8
 
 /**
-- 
Regards,

Laurent Pinchart


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

* [RFC PATCH 8/8] media: v4l2-mediabus: Drop V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag
  2022-01-03 16:24 [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config() Laurent Pinchart
                   ` (6 preceding siblings ...)
  2022-01-03 16:24 ` [RFC PATCH 7/8] media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_CHANNEL_* flags Laurent Pinchart
@ 2022-01-03 16:24 ` Laurent Pinchart
  2022-01-05 19:02   ` Sakari Ailus
  2022-01-09 14:36 ` [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config() Jacopo Mondi
  2022-02-15  8:37 ` Laurent Pinchart
  9 siblings, 1 reply; 36+ messages in thread
From: Laurent Pinchart @ 2022-01-03 16:24 UTC (permalink / raw)
  To: linux-media
  Cc: linux-renesas-soc, Sakari Ailus, Hans Verkuil, Kieran Bingham,
	Jacopo Mondi, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik, Lars-Peter Clausen, Mats Randgaard

MIPI CSI-2 continuous and non-continuous clock modes are mutually
exclusive. Drop the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag and use
V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK only.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/i2c/adv7180.c           | 3 +--
 drivers/media/i2c/tc358743.c          | 6 +++---
 drivers/media/v4l2-core/v4l2-fwnode.c | 4 +---
 include/media/v4l2-mediabus.h         | 3 +--
 4 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 3ff37a550810..4f5db195e66d 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -785,8 +785,7 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
 	if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
 		cfg->type = V4L2_MBUS_CSI2_DPHY;
 		cfg->bus.mipi_csi2.num_data_lanes = 1;
-		cfg->bus.mipi_csi2.flags =
-				V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
+		cfg->bus.mipi_csi2.flags = 0;
 	} else {
 		/*
 		 * The ADV7180 sensor supports BT.601/656 output modes.
diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index dfbc42675143..e18b8947ad7e 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -717,7 +717,7 @@ static void tc358743_set_csi(struct v4l2_subdev *sd)
 			((lanes > 3) ? MASK_D3M_HSTXVREGEN : 0x0));
 
 	i2c_wr32(sd, TXOPTIONCNTRL, (state->bus.flags &
-		 V4L2_MBUS_CSI2_CONTINUOUS_CLOCK) ? MASK_CONTCLKMODE : 0);
+		 V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK) ? 0 : MASK_CONTCLKMODE);
 	i2c_wr32(sd, STARTCNTRL, MASK_START);
 	i2c_wr32(sd, CSI_START, MASK_STRT);
 
@@ -1613,7 +1613,7 @@ static int tc358743_get_mbus_config(struct v4l2_subdev *sd,
 	cfg->type = V4L2_MBUS_CSI2_DPHY;
 
 	/* Support for non-continuous CSI-2 clock is missing in the driver */
-	cfg->bus.mipi_csi2.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
+	cfg->bus.mipi_csi2.flags = 0;
 	cfg->bus.mipi_csi2.num_data_lanes = state->csi_lanes_in_use;
 
 	return 0;
@@ -2039,7 +2039,7 @@ static int tc358743_probe(struct i2c_client *client)
 	/* platform data */
 	if (pdata) {
 		state->pdata = *pdata;
-		state->bus.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
+		state->bus.flags = 0;
 	} else {
 		err = tc358743_probe_of(state);
 		if (err == -ENODEV)
diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
index 9ff3ebb230e7..9aad860cde6c 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -207,13 +207,11 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
 	if (fwnode_property_present(fwnode, "clock-noncontinuous")) {
 		flags |= V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK;
 		pr_debug("non-continuous clock\n");
-	} else {
-		flags |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
 	}
 
 	if (bus_type == V4L2_MBUS_CSI2_DPHY ||
 	    bus_type == V4L2_MBUS_CSI2_CPHY || lanes_used ||
-	    have_clk_lane || (flags & ~V4L2_MBUS_CSI2_CONTINUOUS_CLOCK)) {
+	    have_clk_lane || (flags & V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK)) {
 		/* Only D-PHY has a clock lane. */
 		unsigned int dfl_data_lane_index =
 			bus_type == V4L2_MBUS_CSI2_DPHY;
diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index c6626a22b394..e0db3bcff9ed 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -68,8 +68,7 @@
 
 /* Serial flags */
 /* Clock non-continuous mode support. */
-#define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK		BIT(8)
-#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(9)
+#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(0)
 
 #define V4L2_MBUS_CSI2_MAX_DATA_LANES		8
 
-- 
Regards,

Laurent Pinchart


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

* Re: [RFC PATCH 2/8] media: i2c: ov6650: Drop implementation of .set_mbus_config()
  2022-01-03 16:24 ` [RFC PATCH 2/8] media: i2c: ov6650: Drop implementation " Laurent Pinchart
@ 2022-01-05 18:04   ` Sakari Ailus
  2022-01-05 20:19     ` Laurent Pinchart
  0 siblings, 1 reply; 36+ messages in thread
From: Sakari Ailus @ 2022-01-05 18:04 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-media, linux-renesas-soc, Hans Verkuil, Kieran Bingham,
	Jacopo Mondi, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik

Hi Laurent,

Thanks for the set.

On Mon, Jan 03, 2022 at 06:24:08PM +0200, Laurent Pinchart wrote:
> The subdev .set_mbus_config() operation is deprecated. No code in the
> kernel calls it, so drop its implementation from the ov6650 driver.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  drivers/media/i2c/ov6650.c | 37 -------------------------------------
>  1 file changed, 37 deletions(-)
> 
> diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
> index f67412150b16..455a627e35a0 100644
> --- a/drivers/media/i2c/ov6650.c
> +++ b/drivers/media/i2c/ov6650.c
> @@ -944,42 +944,6 @@ static int ov6650_get_mbus_config(struct v4l2_subdev *sd,
>  	return 0;
>  }
>  
> -/* Alter bus settings on camera side */
> -static int ov6650_set_mbus_config(struct v4l2_subdev *sd,
> -				  unsigned int pad,
> -				  struct v4l2_mbus_config *cfg)
> -{
> -	struct i2c_client *client = v4l2_get_subdevdata(sd);
> -	int ret = 0;
> -
> -	if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
> -		ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_PCLK_RISING, 0);
> -	else if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
> -		ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_PCLK_RISING);

I think this configuration should come from the endpoint which the driver
currently does not parse. In fact, there are no even DT bindings for the
device.

I wonder what kind of environment it is used in --- assuming it works
somewhere.

> -	if (ret)
> -		return ret;
> -
> -	if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
> -		ret = ov6650_reg_rmw(client, REG_COMF, COMF_HREF_LOW, 0);
> -	else if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
> -		ret = ov6650_reg_rmw(client, REG_COMF, 0, COMF_HREF_LOW);
> -	if (ret)
> -		return ret;
> -
> -	if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
> -		ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_VSYNC_HIGH, 0);
> -	else if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
> -		ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_VSYNC_HIGH);
> -	if (ret)
> -		return ret;
> -
> -	/*
> -	 * Update the configuration to report what is actually applied to
> -	 * the hardware.
> -	 */
> -	return ov6650_get_mbus_config(sd, pad, cfg);
> -}
> -
>  static const struct v4l2_subdev_video_ops ov6650_video_ops = {
>  	.s_stream	= ov6650_s_stream,
>  	.g_frame_interval = ov6650_g_frame_interval,
> @@ -993,7 +957,6 @@ static const struct v4l2_subdev_pad_ops ov6650_pad_ops = {
>  	.get_fmt	= ov6650_get_fmt,
>  	.set_fmt	= ov6650_set_fmt,
>  	.get_mbus_config = ov6650_get_mbus_config,
> -	.set_mbus_config = ov6650_set_mbus_config,
>  };
>  
>  static const struct v4l2_subdev_ops ov6650_subdev_ops = {

-- 
Kind regards,

Sakari Ailus

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

* Re: [RFC PATCH 8/8] media: v4l2-mediabus: Drop V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag
  2022-01-03 16:24 ` [RFC PATCH 8/8] media: v4l2-mediabus: Drop V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag Laurent Pinchart
@ 2022-01-05 19:02   ` Sakari Ailus
  2022-01-05 20:15     ` [PATCH v1.1 " Laurent Pinchart
  0 siblings, 1 reply; 36+ messages in thread
From: Sakari Ailus @ 2022-01-05 19:02 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-media, linux-renesas-soc, Hans Verkuil, Kieran Bingham,
	Jacopo Mondi, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik, Lars-Peter Clausen, Mats Randgaard

Hi Laurent,

On Mon, Jan 03, 2022 at 06:24:14PM +0200, Laurent Pinchart wrote:
> MIPI CSI-2 continuous and non-continuous clock modes are mutually
> exclusive. Drop the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag and use
> V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK only.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  drivers/media/i2c/adv7180.c           | 3 +--
>  drivers/media/i2c/tc358743.c          | 6 +++---
>  drivers/media/v4l2-core/v4l2-fwnode.c | 4 +---
>  include/media/v4l2-mediabus.h         | 3 +--
>  4 files changed, 6 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
> index 3ff37a550810..4f5db195e66d 100644
> --- a/drivers/media/i2c/adv7180.c
> +++ b/drivers/media/i2c/adv7180.c
> @@ -785,8 +785,7 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
>  	if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
>  		cfg->type = V4L2_MBUS_CSI2_DPHY;
>  		cfg->bus.mipi_csi2.num_data_lanes = 1;
> -		cfg->bus.mipi_csi2.flags =
> -				V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> +		cfg->bus.mipi_csi2.flags = 0;
>  	} else {
>  		/*
>  		 * The ADV7180 sensor supports BT.601/656 output modes.
> diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
> index dfbc42675143..e18b8947ad7e 100644
> --- a/drivers/media/i2c/tc358743.c
> +++ b/drivers/media/i2c/tc358743.c
> @@ -717,7 +717,7 @@ static void tc358743_set_csi(struct v4l2_subdev *sd)
>  			((lanes > 3) ? MASK_D3M_HSTXVREGEN : 0x0));
>  
>  	i2c_wr32(sd, TXOPTIONCNTRL, (state->bus.flags &
> -		 V4L2_MBUS_CSI2_CONTINUOUS_CLOCK) ? MASK_CONTCLKMODE : 0);
> +		 V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK) ? 0 : MASK_CONTCLKMODE);
>  	i2c_wr32(sd, STARTCNTRL, MASK_START);
>  	i2c_wr32(sd, CSI_START, MASK_STRT);
>  
> @@ -1613,7 +1613,7 @@ static int tc358743_get_mbus_config(struct v4l2_subdev *sd,
>  	cfg->type = V4L2_MBUS_CSI2_DPHY;
>  
>  	/* Support for non-continuous CSI-2 clock is missing in the driver */
> -	cfg->bus.mipi_csi2.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> +	cfg->bus.mipi_csi2.flags = 0;
>  	cfg->bus.mipi_csi2.num_data_lanes = state->csi_lanes_in_use;
>  
>  	return 0;
> @@ -2039,7 +2039,7 @@ static int tc358743_probe(struct i2c_client *client)
>  	/* platform data */
>  	if (pdata) {
>  		state->pdata = *pdata;
> -		state->bus.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> +		state->bus.flags = 0;
>  	} else {
>  		err = tc358743_probe_of(state);
>  		if (err == -ENODEV)
> diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
> index 9ff3ebb230e7..9aad860cde6c 100644
> --- a/drivers/media/v4l2-core/v4l2-fwnode.c
> +++ b/drivers/media/v4l2-core/v4l2-fwnode.c
> @@ -207,13 +207,11 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
>  	if (fwnode_property_present(fwnode, "clock-noncontinuous")) {
>  		flags |= V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK;
>  		pr_debug("non-continuous clock\n");
> -	} else {
> -		flags |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
>  	}
>  
>  	if (bus_type == V4L2_MBUS_CSI2_DPHY ||
>  	    bus_type == V4L2_MBUS_CSI2_CPHY || lanes_used ||
> -	    have_clk_lane || (flags & ~V4L2_MBUS_CSI2_CONTINUOUS_CLOCK)) {
> +	    have_clk_lane || (flags & V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK)) {

This should be just plains flags (i.e. without bitwise and) as we're just
figuring out whether any properties related to CSI-2 were found.

>  		/* Only D-PHY has a clock lane. */
>  		unsigned int dfl_data_lane_index =
>  			bus_type == V4L2_MBUS_CSI2_DPHY;
> diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
> index c6626a22b394..e0db3bcff9ed 100644
> --- a/include/media/v4l2-mediabus.h
> +++ b/include/media/v4l2-mediabus.h
> @@ -68,8 +68,7 @@
>  
>  /* Serial flags */
>  /* Clock non-continuous mode support. */
> -#define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK		BIT(8)
> -#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(9)
> +#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(0)
>  
>  #define V4L2_MBUS_CSI2_MAX_DATA_LANES		8
>  

-- 
Kind regards,

Sakari Ailus

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

* [PATCH v1.1 8/8] media: v4l2-mediabus: Drop V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag
  2022-01-05 19:02   ` Sakari Ailus
@ 2022-01-05 20:15     ` Laurent Pinchart
  2022-02-15 11:04       ` Jacopo Mondi
  0 siblings, 1 reply; 36+ messages in thread
From: Laurent Pinchart @ 2022-01-05 20:15 UTC (permalink / raw)
  To: linux-media
  Cc: linux-renesas-soc, Sakari Ailus, Hans Verkuil, Kieran Bingham,
	Jacopo Mondi, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik, Lars-Peter Clausen, Mats Randgaard

MIPI CSI-2 continuous and non-continuous clock modes are mutually
exclusive. Drop the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag and use
V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK only.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
Changes since v1:

- Check all CSI2 flags in v4l2_fwnode_endpoint_parse_csi2_bus()
---
 drivers/media/i2c/adv7180.c           | 3 +--
 drivers/media/i2c/tc358743.c          | 6 +++---
 drivers/media/v4l2-core/v4l2-fwnode.c | 6 ++----
 include/media/v4l2-mediabus.h         | 3 +--
 4 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 3ff37a550810..4f5db195e66d 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -785,8 +785,7 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
 	if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
 		cfg->type = V4L2_MBUS_CSI2_DPHY;
 		cfg->bus.mipi_csi2.num_data_lanes = 1;
-		cfg->bus.mipi_csi2.flags =
-				V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
+		cfg->bus.mipi_csi2.flags = 0;
 	} else {
 		/*
 		 * The ADV7180 sensor supports BT.601/656 output modes.
diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index dfbc42675143..e18b8947ad7e 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -717,7 +717,7 @@ static void tc358743_set_csi(struct v4l2_subdev *sd)
 			((lanes > 3) ? MASK_D3M_HSTXVREGEN : 0x0));
 
 	i2c_wr32(sd, TXOPTIONCNTRL, (state->bus.flags &
-		 V4L2_MBUS_CSI2_CONTINUOUS_CLOCK) ? MASK_CONTCLKMODE : 0);
+		 V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK) ? 0 : MASK_CONTCLKMODE);
 	i2c_wr32(sd, STARTCNTRL, MASK_START);
 	i2c_wr32(sd, CSI_START, MASK_STRT);
 
@@ -1613,7 +1613,7 @@ static int tc358743_get_mbus_config(struct v4l2_subdev *sd,
 	cfg->type = V4L2_MBUS_CSI2_DPHY;
 
 	/* Support for non-continuous CSI-2 clock is missing in the driver */
-	cfg->bus.mipi_csi2.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
+	cfg->bus.mipi_csi2.flags = 0;
 	cfg->bus.mipi_csi2.num_data_lanes = state->csi_lanes_in_use;
 
 	return 0;
@@ -2039,7 +2039,7 @@ static int tc358743_probe(struct i2c_client *client)
 	/* platform data */
 	if (pdata) {
 		state->pdata = *pdata;
-		state->bus.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
+		state->bus.flags = 0;
 	} else {
 		err = tc358743_probe_of(state);
 		if (err == -ENODEV)
diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
index 9ff3ebb230e7..71dcc9a96535 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -207,13 +207,11 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
 	if (fwnode_property_present(fwnode, "clock-noncontinuous")) {
 		flags |= V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK;
 		pr_debug("non-continuous clock\n");
-	} else {
-		flags |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
 	}
 
 	if (bus_type == V4L2_MBUS_CSI2_DPHY ||
-	    bus_type == V4L2_MBUS_CSI2_CPHY || lanes_used ||
-	    have_clk_lane || (flags & ~V4L2_MBUS_CSI2_CONTINUOUS_CLOCK)) {
+	    bus_type == V4L2_MBUS_CSI2_CPHY ||
+	    lanes_used || have_clk_lane || flags) {
 		/* Only D-PHY has a clock lane. */
 		unsigned int dfl_data_lane_index =
 			bus_type == V4L2_MBUS_CSI2_DPHY;
diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index c6626a22b394..e0db3bcff9ed 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -68,8 +68,7 @@
 
 /* Serial flags */
 /* Clock non-continuous mode support. */
-#define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK		BIT(8)
-#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(9)
+#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(0)
 
 #define V4L2_MBUS_CSI2_MAX_DATA_LANES		8
 

base-commit: 68b9bcc8a534cd11fe55f8bc82f948aae7d81b3c
prerequisite-patch-id: cc085f7de462ead19772e3f64e1b1d13bb92d5b7
prerequisite-patch-id: d6943d1780603964a753d571e26bad98b4954a8a
prerequisite-patch-id: c63eaa2a61aeea6d4be238644f1324f0170d981c
prerequisite-patch-id: 797385e385b3f71f0bafe7eb8e712d52628c23d7
prerequisite-patch-id: 2f7fe0901f79ac1d445e443b5d3ee7ab9ae41525
prerequisite-patch-id: 70ddd068308b5758872349ec6e0f03e8c9427dc0
prerequisite-patch-id: 987cc8f39cb63badf2d6ceba946deffafba9a249
-- 
Regards,

Laurent Pinchart


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

* Re: [RFC PATCH 2/8] media: i2c: ov6650: Drop implementation of .set_mbus_config()
  2022-01-05 18:04   ` Sakari Ailus
@ 2022-01-05 20:19     ` Laurent Pinchart
  2022-01-05 21:31       ` Janusz Krzysztofik
  0 siblings, 1 reply; 36+ messages in thread
From: Laurent Pinchart @ 2022-01-05 20:19 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: linux-media, linux-renesas-soc, Hans Verkuil, Kieran Bingham,
	Jacopo Mondi, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik

Hi Sakari,

On Wed, Jan 05, 2022 at 08:04:24PM +0200, Sakari Ailus wrote:
> On Mon, Jan 03, 2022 at 06:24:08PM +0200, Laurent Pinchart wrote:
> > The subdev .set_mbus_config() operation is deprecated. No code in the
> > kernel calls it, so drop its implementation from the ov6650 driver.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> >  drivers/media/i2c/ov6650.c | 37 -------------------------------------
> >  1 file changed, 37 deletions(-)
> > 
> > diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
> > index f67412150b16..455a627e35a0 100644
> > --- a/drivers/media/i2c/ov6650.c
> > +++ b/drivers/media/i2c/ov6650.c
> > @@ -944,42 +944,6 @@ static int ov6650_get_mbus_config(struct v4l2_subdev *sd,
> >  	return 0;
> >  }
> >  
> > -/* Alter bus settings on camera side */
> > -static int ov6650_set_mbus_config(struct v4l2_subdev *sd,
> > -				  unsigned int pad,
> > -				  struct v4l2_mbus_config *cfg)
> > -{
> > -	struct i2c_client *client = v4l2_get_subdevdata(sd);
> > -	int ret = 0;
> > -
> > -	if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
> > -		ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_PCLK_RISING, 0);
> > -	else if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
> > -		ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_PCLK_RISING);
> 
> I think this configuration should come from the endpoint which the driver
> currently does not parse. In fact, there are no even DT bindings for the
> device.

There's also no OF match table. While this isn't strictly required, it
may indicate that the sensor hasn't been tested much on DT-based
systems.

I agree that the configuration should come from the device tree, but I
can't test that, so I'm tempted to let someone else implement it if the
driver is actually still in use (I can also write a patch if someone can
test it).

> I wonder what kind of environment it is used in --- assuming it works
> somewhere.
> 
> > -	if (ret)
> > -		return ret;
> > -
> > -	if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
> > -		ret = ov6650_reg_rmw(client, REG_COMF, COMF_HREF_LOW, 0);
> > -	else if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
> > -		ret = ov6650_reg_rmw(client, REG_COMF, 0, COMF_HREF_LOW);
> > -	if (ret)
> > -		return ret;
> > -
> > -	if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
> > -		ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_VSYNC_HIGH, 0);
> > -	else if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
> > -		ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_VSYNC_HIGH);
> > -	if (ret)
> > -		return ret;
> > -
> > -	/*
> > -	 * Update the configuration to report what is actually applied to
> > -	 * the hardware.
> > -	 */
> > -	return ov6650_get_mbus_config(sd, pad, cfg);
> > -}
> > -
> >  static const struct v4l2_subdev_video_ops ov6650_video_ops = {
> >  	.s_stream	= ov6650_s_stream,
> >  	.g_frame_interval = ov6650_g_frame_interval,
> > @@ -993,7 +957,6 @@ static const struct v4l2_subdev_pad_ops ov6650_pad_ops = {
> >  	.get_fmt	= ov6650_get_fmt,
> >  	.set_fmt	= ov6650_set_fmt,
> >  	.get_mbus_config = ov6650_get_mbus_config,
> > -	.set_mbus_config = ov6650_set_mbus_config,
> >  };
> >  
> >  static const struct v4l2_subdev_ops ov6650_subdev_ops = {

-- 
Regards,

Laurent Pinchart

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

* Re: [RFC PATCH 2/8] media: i2c: ov6650: Drop implementation of .set_mbus_config()
  2022-01-05 20:19     ` Laurent Pinchart
@ 2022-01-05 21:31       ` Janusz Krzysztofik
  2022-01-05 21:42         ` Laurent Pinchart
  2022-01-07 13:41         ` Sakari Ailus
  0 siblings, 2 replies; 36+ messages in thread
From: Janusz Krzysztofik @ 2022-01-05 21:31 UTC (permalink / raw)
  To: Sakari Ailus, Laurent Pinchart
  Cc: Linux Media Mailing List, linux-renesas-soc, Hans Verkuil,
	Kieran Bingham, Jacopo Mondi, Niklas Söderlund,
	Tomi Valkeinen

Hi Laurent,

On Wednesday, 5 January 2022 21:19:49 CET Laurent Pinchart wrote:
> Hi Sakari,
>
> On Wed, Jan 05, 2022 at 08:04:24PM +0200, Sakari Ailus wrote:
> > On Mon, Jan 03, 2022 at 06:24:08PM +0200, Laurent Pinchart wrote:
> > > The subdev .set_mbus_config() operation is deprecated. No code in the
> > > kernel calls it, so drop its implementation from the ov6650 driver.
> > >
> > > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > > ---
> > >  drivers/media/i2c/ov6650.c | 37 -------------------------------------
> > >  1 file changed, 37 deletions(-)
> > >
> > > diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
> > > index f67412150b16..455a627e35a0 100644
> > > --- a/drivers/media/i2c/ov6650.c
> > > +++ b/drivers/media/i2c/ov6650.c
> > > @@ -944,42 +944,6 @@ static int ov6650_get_mbus_config(struct v4l2_subdev *sd,
> > >   return 0;
> > >  }
> > >
> > > -/* Alter bus settings on camera side */
> > > -static int ov6650_set_mbus_config(struct v4l2_subdev *sd,
> > > -                           unsigned int pad,
> > > -                           struct v4l2_mbus_config *cfg)
> > > -{
> > > - struct i2c_client *client = v4l2_get_subdevdata(sd);
> > > - int ret = 0;
> > > -
> > > - if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
> > > -         ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_PCLK_RISING, 0);
> > > - else if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
> > > -         ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_PCLK_RISING);
> >
> > I think this configuration should come from the endpoint which the driver
> > currently does not parse. In fact, there are no even DT bindings for the
> > device.
>
> There's also no OF match table. While this isn't strictly required, it
> may indicate that the sensor hasn't been tested much on DT-based
> systems.
>
> I agree that the configuration should come from the device tree, but I
> can't test that, so I'm tempted to let someone else implement it if the
> driver is actually still in use (I can also write a patch if someone can
> test it).

This driver was used with omap1_camera, removed from the tree a few years
ago by Hans, despite my attempts to refresh it.  I tried to keep ov6650
updated but I gave up due to lack of response to my submissions.  That also
blocked my attempts to rework and reintroduce omap1_camera.

I think I'm still able to update my local (v4l2, non-mc) version of
omap1_camera to the extent required to test any changes to ov6650.
However, the OMAP1 platform does not support DT, and will probably never
do.  Then,  I think that it makes sense to spend my time on that only if
you (media maintainers) are not going to depreciate non-DT support any
soon.  Are you?

Thanks,
Janusz


>
> > I wonder what kind of environment it is used in --- assuming it works
> > somewhere.
> >
> > > - if (ret)
> > > -         return ret;
> > > -
> > > - if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
> > > -         ret = ov6650_reg_rmw(client, REG_COMF, COMF_HREF_LOW, 0);
> > > - else if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
> > > -         ret = ov6650_reg_rmw(client, REG_COMF, 0, COMF_HREF_LOW);
> > > - if (ret)
> > > -         return ret;
> > > -
> > > - if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
> > > -         ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_VSYNC_HIGH, 0);
> > > - else if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
> > > -         ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_VSYNC_HIGH);
> > > - if (ret)
> > > -         return ret;
> > > -
> > > - /*
> > > -  * Update the configuration to report what is actually applied to
> > > -  * the hardware.
> > > -  */
> > > - return ov6650_get_mbus_config(sd, pad, cfg);
> > > -}
> > > -
> > >  static const struct v4l2_subdev_video_ops ov6650_video_ops = {
> > >   .s_stream       = ov6650_s_stream,
> > >   .g_frame_interval = ov6650_g_frame_interval,
> > > @@ -993,7 +957,6 @@ static const struct v4l2_subdev_pad_ops ov6650_pad_ops = {
> > >   .get_fmt        = ov6650_get_fmt,
> > >   .set_fmt        = ov6650_set_fmt,
> > >   .get_mbus_config = ov6650_get_mbus_config,
> > > - .set_mbus_config = ov6650_set_mbus_config,
> > >  };
> > >
> > >  static const struct v4l2_subdev_ops ov6650_subdev_ops = {
>
>

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

* Re: [RFC PATCH 2/8] media: i2c: ov6650: Drop implementation of .set_mbus_config()
  2022-01-05 21:31       ` Janusz Krzysztofik
@ 2022-01-05 21:42         ` Laurent Pinchart
  2022-01-06  0:13           ` Janusz Krzysztofik
  2022-01-07 13:41         ` Sakari Ailus
  1 sibling, 1 reply; 36+ messages in thread
From: Laurent Pinchart @ 2022-01-05 21:42 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Sakari Ailus, Linux Media Mailing List, linux-renesas-soc,
	Hans Verkuil, Kieran Bingham, Jacopo Mondi,
	Niklas Söderlund, Tomi Valkeinen

Hi Janusz,

On Wed, Jan 05, 2022 at 10:31:41PM +0100, Janusz Krzysztofik wrote:
> On Wednesday, 5 January 2022 21:19:49 CET Laurent Pinchart wrote:
> > On Wed, Jan 05, 2022 at 08:04:24PM +0200, Sakari Ailus wrote:
> > > On Mon, Jan 03, 2022 at 06:24:08PM +0200, Laurent Pinchart wrote:
> > > > The subdev .set_mbus_config() operation is deprecated. No code in the
> > > > kernel calls it, so drop its implementation from the ov6650 driver.
> > > >
> > > > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > > > ---
> > > >  drivers/media/i2c/ov6650.c | 37 -------------------------------------
> > > >  1 file changed, 37 deletions(-)
> > > >
> > > > diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
> > > > index f67412150b16..455a627e35a0 100644
> > > > --- a/drivers/media/i2c/ov6650.c
> > > > +++ b/drivers/media/i2c/ov6650.c
> > > > @@ -944,42 +944,6 @@ static int ov6650_get_mbus_config(struct v4l2_subdev *sd,
> > > >   return 0;
> > > >  }
> > > >
> > > > -/* Alter bus settings on camera side */
> > > > -static int ov6650_set_mbus_config(struct v4l2_subdev *sd,
> > > > -                           unsigned int pad,
> > > > -                           struct v4l2_mbus_config *cfg)
> > > > -{
> > > > - struct i2c_client *client = v4l2_get_subdevdata(sd);
> > > > - int ret = 0;
> > > > -
> > > > - if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
> > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_PCLK_RISING, 0);
> > > > - else if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
> > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_PCLK_RISING);
> > >
> > > I think this configuration should come from the endpoint which the driver
> > > currently does not parse. In fact, there are no even DT bindings for the
> > > device.
> >
> > There's also no OF match table. While this isn't strictly required, it
> > may indicate that the sensor hasn't been tested much on DT-based
> > systems.
> >
> > I agree that the configuration should come from the device tree, but I
> > can't test that, so I'm tempted to let someone else implement it if the
> > driver is actually still in use (I can also write a patch if someone can
> > test it).
> 
> This driver was used with omap1_camera, removed from the tree a few years
> ago by Hans, despite my attempts to refresh it.  I tried to keep ov6650
> updated but I gave up due to lack of response to my submissions.  That also
> blocked my attempts to rework and reintroduce omap1_camera.
> 
> I think I'm still able to update my local (v4l2, non-mc) version of
> omap1_camera to the extent required to test any changes to ov6650.
> However, the OMAP1 platform does not support DT, and will probably never
> do.  Then,  I think that it makes sense to spend my time on that only if
> you (media maintainers) are not going to depreciate non-DT support any
> soon.  Are you?

Thank you for the quick reply, and for the offer to test this. I
understand your frustration, and the impossibility (with reasonable
effort) to move OMAP1 to DT. This means that we would need to add
platform data support to the ov6650 driver, and specify the platform
data in the corresponding board file. On the ov6650 driver side I have
no issue with that, and while platform data is deprecated for new
platforms, it can be kept around for older ones as long as needed. I
however don't know if changes to board files in arch/arm/mach-omap1
would be accepted. I also don't see any mention of ov6650 there, leading
me to believe nobody can use this driver with the mainline kernel
without resurecting the omap1_camera driver. I'm thus wondering if this
would be a good use of your time, or if we should just merge this patch
as-is.

> > > I wonder what kind of environment it is used in --- assuming it works
> > > somewhere.
> > >
> > > > - if (ret)
> > > > -         return ret;
> > > > -
> > > > - if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
> > > > -         ret = ov6650_reg_rmw(client, REG_COMF, COMF_HREF_LOW, 0);
> > > > - else if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
> > > > -         ret = ov6650_reg_rmw(client, REG_COMF, 0, COMF_HREF_LOW);
> > > > - if (ret)
> > > > -         return ret;
> > > > -
> > > > - if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
> > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_VSYNC_HIGH, 0);
> > > > - else if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
> > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_VSYNC_HIGH);
> > > > - if (ret)
> > > > -         return ret;
> > > > -
> > > > - /*
> > > > -  * Update the configuration to report what is actually applied to
> > > > -  * the hardware.
> > > > -  */
> > > > - return ov6650_get_mbus_config(sd, pad, cfg);
> > > > -}
> > > > -
> > > >  static const struct v4l2_subdev_video_ops ov6650_video_ops = {
> > > >   .s_stream       = ov6650_s_stream,
> > > >   .g_frame_interval = ov6650_g_frame_interval,
> > > > @@ -993,7 +957,6 @@ static const struct v4l2_subdev_pad_ops ov6650_pad_ops = {
> > > >   .get_fmt        = ov6650_get_fmt,
> > > >   .set_fmt        = ov6650_set_fmt,
> > > >   .get_mbus_config = ov6650_get_mbus_config,
> > > > - .set_mbus_config = ov6650_set_mbus_config,
> > > >  };
> > > >
> > > >  static const struct v4l2_subdev_ops ov6650_subdev_ops = {

-- 
Regards,

Laurent Pinchart

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

* Re: [RFC PATCH 2/8] media: i2c: ov6650: Drop implementation of .set_mbus_config()
  2022-01-05 21:42         ` Laurent Pinchart
@ 2022-01-06  0:13           ` Janusz Krzysztofik
  2022-01-09  2:37             ` Laurent Pinchart
  0 siblings, 1 reply; 36+ messages in thread
From: Janusz Krzysztofik @ 2022-01-06  0:13 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Sakari Ailus, Linux Media Mailing List, linux-renesas-soc,
	Hans Verkuil, Kieran Bingham, Jacopo Mondi,
	Niklas Söderlund, Tomi Valkeinen

On Wednesday, 5 January 2022 22:42:38 CET Laurent Pinchart wrote:
> Hi Janusz,
>
> On Wed, Jan 05, 2022 at 10:31:41PM +0100, Janusz Krzysztofik wrote:
> > On Wednesday, 5 January 2022 21:19:49 CET Laurent Pinchart wrote:
> > > On Wed, Jan 05, 2022 at 08:04:24PM +0200, Sakari Ailus wrote:
> > > > On Mon, Jan 03, 2022 at 06:24:08PM +0200, Laurent Pinchart wrote:
> > > > > The subdev .set_mbus_config() operation is deprecated. No code in
the
> > > > > kernel calls it, so drop its implementation from the ov6650
driver.
> > > > >
> > > > > Signed-off-by: Laurent Pinchart
<laurent.pinchart+renesas@ideasonboard.com>
> > > > > ---
> > > > >  drivers/media/i2c/ov6650.c | 37
-------------------------------------
> > > > >  1 file changed, 37 deletions(-)
> > > > >
> > > > > diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/
ov6650.c
> > > > > index f67412150b16..455a627e35a0 100644
> > > > > --- a/drivers/media/i2c/ov6650.c
> > > > > +++ b/drivers/media/i2c/ov6650.c
> > > > > @@ -944,42 +944,6 @@ static int ov6650_get_mbus_config(struct
v4l2_subdev *sd,
> > > > >   return 0;
> > > > >  }
> > > > >
> > > > > -/* Alter bus settings on camera side */
> > > > > -static int ov6650_set_mbus_config(struct v4l2_subdev *sd,
> > > > > -                           unsigned int pad,
> > > > > -                           struct v4l2_mbus_config *cfg)
> > > > > -{
> > > > > - struct i2c_client *client = v4l2_get_subdevdata(sd);
> > > > > - int ret = 0;
> > > > > -
> > > > > - if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
> > > > > -         ret = ov6650_reg_rmw(client, REG_COMJ,
COMJ_PCLK_RISING, 0);
> > > > > - else if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
> > > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, 0,
COMJ_PCLK_RISING);
> > > >
> > > > I think this configuration should come from the endpoint which the
driver
> > > > currently does not parse. In fact, there are no even DT bindings
for the
> > > > device.
> > >
> > > There's also no OF match table. While this isn't strictly required,
it
> > > may indicate that the sensor hasn't been tested much on DT-based
> > > systems.
> > >
> > > I agree that the configuration should come from the device tree, but I
> > > can't test that, so I'm tempted to let someone else implement it if
the
> > > driver is actually still in use (I can also write a patch if someone
can
> > > test it).
> >
> > This driver was used with omap1_camera, removed from the tree a few
years
> > ago by Hans, despite my attempts to refresh it.  I tried to keep ov6650
> > updated but I gave up due to lack of response to my submissions.  That
also
> > blocked my attempts to rework and reintroduce omap1_camera.
> >
> > I think I'm still able to update my local (v4l2, non-mc) version of
> > omap1_camera to the extent required to test any changes to ov6650.
> > However, the OMAP1 platform does not support DT, and will probably
never
> > do.  Then,  I think that it makes sense to spend my time on that only
if
> > you (media maintainers) are not going to depreciate non-DT support any
> > soon.  Are you?
>
> Thank you for the quick reply, and for the offer to test this. I
> understand your frustration, and the impossibility (with reasonable
> effort) to move OMAP1 to DT.

I forgot to mention one more limitation of OMAP1 platform: it does not
support CCF.  With removal of v4l2-clk support from ov6650 a year ago, the
driver is probably no longer usable with OMAP1 boards.

> This means that we would need to add
> platform data support to the ov6650 driver, and specify the platform
> data in the corresponding board file. On the ov6650 driver side I have
> no issue with that, and while platform data is deprecated for new
> platforms, it can be kept around for older ones as long as needed. I
> however don't know if changes to board files in arch/arm/mach-omap1
> would be accepted.

I think that shouldn't be a problem, I could take care.

> I also don't see any mention of ov6650 there,

Respective i2c_board_info was removed from arch/arm/mach-omap1/board-ams-
delta.c together with removal of soc_camera support.  I had a patch in my
queue that was registering the sensor info with I2C sybsystem at boot time
for v4l2_async use but that alone wouldn't help much.

> leading
> me to believe nobody can use this driver with the mainline kernel
> without resurecting the omap1_camera driver. I'm thus wondering if this
> would be a good use of your time, or if we should just merge this patch
> as-is.

Yes, please feel free to merge it.

Acked-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>

Thanks,
Janusz


>
> > > > I wonder what kind of environment it is used in --- assuming it
works
> > > > somewhere.
> > > >
> > > > > - if (ret)
> > > > > -         return ret;
> > > > > -
> > > > > - if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
> > > > > -         ret = ov6650_reg_rmw(client, REG_COMF, COMF_HREF_LOW,
0);
> > > > > - else if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
> > > > > -         ret = ov6650_reg_rmw(client, REG_COMF, 0,
COMF_HREF_LOW);
> > > > > - if (ret)
> > > > > -         return ret;
> > > > > -
> > > > > - if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
> > > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_VSYNC_HIGH,
0);
> > > > > - else if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
> > > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, 0,
COMJ_VSYNC_HIGH);
> > > > > - if (ret)
> > > > > -         return ret;
> > > > > -
> > > > > - /*
> > > > > -  * Update the configuration to report what is actually applied
to
> > > > > -  * the hardware.
> > > > > -  */
> > > > > - return ov6650_get_mbus_config(sd, pad, cfg);
> > > > > -}
> > > > > -
> > > > >  static const struct v4l2_subdev_video_ops ov6650_video_ops = {
> > > > >   .s_stream       = ov6650_s_stream,
> > > > >   .g_frame_interval = ov6650_g_frame_interval,
> > > > > @@ -993,7 +957,6 @@ static const struct v4l2_subdev_pad_ops
ov6650_pad_ops = {
> > > > >   .get_fmt        = ov6650_get_fmt,
> > > > >   .set_fmt        = ov6650_set_fmt,
> > > > >   .get_mbus_config = ov6650_get_mbus_config,
> > > > > - .set_mbus_config = ov6650_set_mbus_config,
> > > > >  };
> > > > >
> > > > >  static const struct v4l2_subdev_ops ov6650_subdev_ops = {
>
>

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

* Re: [RFC PATCH 2/8] media: i2c: ov6650: Drop implementation of .set_mbus_config()
  2022-01-05 21:31       ` Janusz Krzysztofik
  2022-01-05 21:42         ` Laurent Pinchart
@ 2022-01-07 13:41         ` Sakari Ailus
  2022-01-10 18:11           ` Janusz Krzysztofik
  1 sibling, 1 reply; 36+ messages in thread
From: Sakari Ailus @ 2022-01-07 13:41 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Laurent Pinchart, Linux Media Mailing List, linux-renesas-soc,
	Hans Verkuil, Kieran Bingham, Jacopo Mondi,
	Niklas Söderlund, Tomi Valkeinen

Hi Janusz,

On Wed, Jan 05, 2022 at 10:31:41PM +0100, Janusz Krzysztofik wrote:
> Hi Laurent,
> 
> On Wednesday, 5 January 2022 21:19:49 CET Laurent Pinchart wrote:
> > Hi Sakari,
> >
> > On Wed, Jan 05, 2022 at 08:04:24PM +0200, Sakari Ailus wrote:
> > > On Mon, Jan 03, 2022 at 06:24:08PM +0200, Laurent Pinchart wrote:
> > > > The subdev .set_mbus_config() operation is deprecated. No code in the
> > > > kernel calls it, so drop its implementation from the ov6650 driver.
> > > >
> > > > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > > > ---
> > > >  drivers/media/i2c/ov6650.c | 37 -------------------------------------
> > > >  1 file changed, 37 deletions(-)
> > > >
> > > > diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
> > > > index f67412150b16..455a627e35a0 100644
> > > > --- a/drivers/media/i2c/ov6650.c
> > > > +++ b/drivers/media/i2c/ov6650.c
> > > > @@ -944,42 +944,6 @@ static int ov6650_get_mbus_config(struct v4l2_subdev *sd,
> > > >   return 0;
> > > >  }
> > > >
> > > > -/* Alter bus settings on camera side */
> > > > -static int ov6650_set_mbus_config(struct v4l2_subdev *sd,
> > > > -                           unsigned int pad,
> > > > -                           struct v4l2_mbus_config *cfg)
> > > > -{
> > > > - struct i2c_client *client = v4l2_get_subdevdata(sd);
> > > > - int ret = 0;
> > > > -
> > > > - if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
> > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_PCLK_RISING, 0);
> > > > - else if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
> > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_PCLK_RISING);
> > >
> > > I think this configuration should come from the endpoint which the driver
> > > currently does not parse. In fact, there are no even DT bindings for the
> > > device.
> >
> > There's also no OF match table. While this isn't strictly required, it
> > may indicate that the sensor hasn't been tested much on DT-based
> > systems.
> >
> > I agree that the configuration should come from the device tree, but I
> > can't test that, so I'm tempted to let someone else implement it if the
> > driver is actually still in use (I can also write a patch if someone can
> > test it).
> 
> This driver was used with omap1_camera, removed from the tree a few years
> ago by Hans, despite my attempts to refresh it.  I tried to keep ov6650
> updated but I gave up due to lack of response to my submissions.  That also
> blocked my attempts to rework and reintroduce omap1_camera.

My apologies for this --- I indeed to see a set of unreviewed ov6650 patches
from you. Please do ping me if you expect an answer but do not get one.

> 
> I think I'm still able to update my local (v4l2, non-mc) version of
> omap1_camera to the extent required to test any changes to ov6650.
> However, the OMAP1 platform does not support DT, and will probably never
> do.  Then,  I think that it makes sense to spend my time on that only if
> you (media maintainers) are not going to depreciate non-DT support any
> soon.  Are you?

Commenting just this and not the discussion later in this thread --- it is
possible to support such sensor drivers without DT or ACPI nowadays,
through software nodes. See e.g. drivers/media/pci/intel/ipu3/cio2-bridge.c
.

-- 
Kind regards,

Sakari Ailus

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

* Re: [RFC PATCH 2/8] media: i2c: ov6650: Drop implementation of .set_mbus_config()
  2022-01-06  0:13           ` Janusz Krzysztofik
@ 2022-01-09  2:37             ` Laurent Pinchart
  0 siblings, 0 replies; 36+ messages in thread
From: Laurent Pinchart @ 2022-01-09  2:37 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Sakari Ailus, Linux Media Mailing List, linux-renesas-soc,
	Hans Verkuil, Kieran Bingham, Jacopo Mondi,
	Niklas Söderlund, Tomi Valkeinen

Hi Janusz,

On Thu, Jan 06, 2022 at 01:13:56AM +0100, Janusz Krzysztofik wrote:
> On Wednesday, 5 January 2022 22:42:38 CET Laurent Pinchart wrote:
> > On Wed, Jan 05, 2022 at 10:31:41PM +0100, Janusz Krzysztofik wrote:
> > > On Wednesday, 5 January 2022 21:19:49 CET Laurent Pinchart wrote:
> > > > On Wed, Jan 05, 2022 at 08:04:24PM +0200, Sakari Ailus wrote:
> > > > > On Mon, Jan 03, 2022 at 06:24:08PM +0200, Laurent Pinchart wrote:
> > > > > > The subdev .set_mbus_config() operation is deprecated. No code in the
> > > > > > kernel calls it, so drop its implementation from the ov6650 driver.
> > > > > >
> > > > > > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > > > > > ---
> > > > > >  drivers/media/i2c/ov6650.c | 37 -------------------------------------
> > > > > >  1 file changed, 37 deletions(-)
> > > > > >
> > > > > > diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ ov6650.c
> > > > > > index f67412150b16..455a627e35a0 100644
> > > > > > --- a/drivers/media/i2c/ov6650.c
> > > > > > +++ b/drivers/media/i2c/ov6650.c
> > > > > > @@ -944,42 +944,6 @@ static int ov6650_get_mbus_config(struct v4l2_subdev *sd,
> > > > > >   return 0;
> > > > > >  }
> > > > > >
> > > > > > -/* Alter bus settings on camera side */
> > > > > > -static int ov6650_set_mbus_config(struct v4l2_subdev *sd,
> > > > > > -                           unsigned int pad,
> > > > > > -                           struct v4l2_mbus_config *cfg)
> > > > > > -{
> > > > > > - struct i2c_client *client = v4l2_get_subdevdata(sd);
> > > > > > - int ret = 0;
> > > > > > -
> > > > > > - if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
> > > > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_PCLK_RISING, 0);
> > > > > > - else if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
> > > > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_PCLK_RISING);
> > > > >
> > > > > I think this configuration should come from the endpoint which the driver
> > > > > currently does not parse. In fact, there are no even DT bindings for the
> > > > > device.
> > > >
> > > > There's also no OF match table. While this isn't strictly required, it
> > > > may indicate that the sensor hasn't been tested much on DT-based
> > > > systems.
> > > >
> > > > I agree that the configuration should come from the device tree, but I
> > > > can't test that, so I'm tempted to let someone else implement it if the
> > > > driver is actually still in use (I can also write a patch if someone can
> > > > test it).
> > >
> > > This driver was used with omap1_camera, removed from the tree a few years
> > > ago by Hans, despite my attempts to refresh it.  I tried to keep ov6650
> > > updated but I gave up due to lack of response to my submissions.  That also
> > > blocked my attempts to rework and reintroduce omap1_camera.
> > >
> > > I think I'm still able to update my local (v4l2, non-mc) version of
> > > omap1_camera to the extent required to test any changes to ov6650.
> > > However, the OMAP1 platform does not support DT, and will probably never
> > > do.  Then,  I think that it makes sense to spend my time on that only if
> > > you (media maintainers) are not going to depreciate non-DT support any
> > > soon.  Are you?
> >
> > Thank you for the quick reply, and for the offer to test this. I
> > understand your frustration, and the impossibility (with reasonable
> > effort) to move OMAP1 to DT.
> 
> I forgot to mention one more limitation of OMAP1 platform: it does not
> support CCF.  With removal of v4l2-clk support from ov6650 a year ago, the
> driver is probably no longer usable with OMAP1 boards.

Ouch, that's even worse indeed :-(

> > This means that we would need to add
> > platform data support to the ov6650 driver, and specify the platform
> > data in the corresponding board file. On the ov6650 driver side I have
> > no issue with that, and while platform data is deprecated for new
> > platforms, it can be kept around for older ones as long as needed. I
> > however don't know if changes to board files in arch/arm/mach-omap1
> > would be accepted.
> 
> I think that shouldn't be a problem, I could take care.
> 
> > I also don't see any mention of ov6650 there,
> 
> Respective i2c_board_info was removed from arch/arm/mach-omap1/board-ams-
> delta.c together with removal of soc_camera support.  I had a patch in my
> queue that was registering the sensor info with I2C sybsystem at boot time
> for v4l2_async use but that alone wouldn't help much.
> 
> > leading
> > me to believe nobody can use this driver with the mainline kernel
> > without resurecting the omap1_camera driver. I'm thus wondering if this
> > would be a good use of your time, or if we should just merge this patch
> > as-is.
> 
> Yes, please feel free to merge it.
> 
> Acked-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>

Thank you.

> > > > > I wonder what kind of environment it is used in --- assuming it works
> > > > > somewhere.
> > > > >
> > > > > > - if (ret)
> > > > > > -         return ret;
> > > > > > -
> > > > > > - if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
> > > > > > -         ret = ov6650_reg_rmw(client, REG_COMF, COMF_HREF_LOW, 0);
> > > > > > - else if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
> > > > > > -         ret = ov6650_reg_rmw(client, REG_COMF, 0, COMF_HREF_LOW);
> > > > > > - if (ret)
> > > > > > -         return ret;
> > > > > > -
> > > > > > - if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
> > > > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_VSYNC_HIGH, 0);
> > > > > > - else if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
> > > > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_VSYNC_HIGH);
> > > > > > - if (ret)
> > > > > > -         return ret;
> > > > > > -
> > > > > > - /*
> > > > > > -  * Update the configuration to report what is actually applied to
> > > > > > -  * the hardware.
> > > > > > -  */
> > > > > > - return ov6650_get_mbus_config(sd, pad, cfg);
> > > > > > -}
> > > > > > -
> > > > > >  static const struct v4l2_subdev_video_ops ov6650_video_ops = {
> > > > > >   .s_stream       = ov6650_s_stream,
> > > > > >   .g_frame_interval = ov6650_g_frame_interval,
> > > > > > @@ -993,7 +957,6 @@ static const struct v4l2_subdev_pad_ops ov6650_pad_ops = {
> > > > > >   .get_fmt        = ov6650_get_fmt,
> > > > > >   .set_fmt        = ov6650_set_fmt,
> > > > > >   .get_mbus_config = ov6650_get_mbus_config,
> > > > > > - .set_mbus_config = ov6650_set_mbus_config,
> > > > > >  };
> > > > > >
> > > > > >  static const struct v4l2_subdev_ops ov6650_subdev_ops = {

-- 
Regards,

Laurent Pinchart

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

* Re: [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config()
  2022-01-03 16:24 [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config() Laurent Pinchart
                   ` (7 preceding siblings ...)
  2022-01-03 16:24 ` [RFC PATCH 8/8] media: v4l2-mediabus: Drop V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag Laurent Pinchart
@ 2022-01-09 14:36 ` Jacopo Mondi
  2022-01-09 22:55   ` Laurent Pinchart
  2022-02-15  8:37 ` Laurent Pinchart
  9 siblings, 1 reply; 36+ messages in thread
From: Jacopo Mondi @ 2022-01-09 14:36 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-media, linux-renesas-soc, Sakari Ailus, Hans Verkuil,
	Kieran Bingham, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik

Hi Laurent,

On Mon, Jan 03, 2022 at 06:24:06PM +0200, Laurent Pinchart wrote:
> Hello,
>
> This patch series reworks the V4L2 subdev .get_mbus_config() and
> .set_mbus_config() operations to improve the former and drop the latter.
>
> These subdev operations originate from soc-camera (for those who
> remember the framework), and were designed to let a transmitter and a
> receiver negotiate the physical configuration of the bus that connects
> them. The operations use bitflags to represent bus parameters, with
> supported options set by the caller of .set_mbus_config(), and selected
> options among those returned by the callee. This mechanism is
> deprecated, as selection of the bus configuration has long been moved to
> the firmware interface (DT or ACPI), and usage of bitflags prevents from
> adding more complex configuration parameters (timings in particular).
>
> As .set_mbus_config() is deprecated and used by one pair of drivers only
> (pxa_camera and ov6650), it wasn't difficult to drop usage of that
> operation in patches 1/8 and 2/8, and remove the operation itself in
> patch 3/8.
>
> With that operation gone, .get_mbus_config() can be moved from bitflags
> to structures. It turned out that the needed data structures were
> already present in v4l2_fwnode.h. Patch 4/8 moves them to
> v4l2_mediabus.h (and renames them to drop the fwnode mention, as they're
> not specific to the fwnode API), and patch 5/8 makes use of them.

great, when the soc_camera version was dropped, the next thing to do
was to move away from bitflags and move to structure fields...

> Patches 6/8 to 8/8 then removes media bus configuration bitflags that
> are unneeded (and now unused).

Parallel might require a bit more of work, but csi2 already has a
single flag

/* Clock non-continuous mode support. */
#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(0)

so it should be trivial to replace 'flags' with a boolean
'clock_noncontinuous' field.

One things leaves me a bit confused: we're now mixing run-time
configurable paramters (eg the number of data lanes in use in the
current streaming sessions) and paramters which come from DT and are
usually fixed by the HW design like lanes ordering.

Is this ok in your opinion ?

>
> The series is an RFC as not everything has been converted from bitflags
> to named fields in structures. In particular, the parallel bus flags
> haven't been touched at all. Patch 8/8 shows how mutually exclusive
> flags can be reworked to drop one of them. We then need to decide
> whether to keep expressing the flag as macros, or move to C bitfields
> with dedicated structure member names. I didn't want to include this
> change in the RFC before getting feedback on the general approach
> (feedback on those specific questions will also be appreciated).
>

There's also an opportunity to use v4l2_mbus_config as part of
v4l2_fwnode_endpoint instead of repeating the same fields ?

struct v4l2_fwnode_endpoint {
	struct fwnode_endpoint base;
	/*
	 * Fields below this line will be zeroed by
	 * v4l2_fwnode_endpoint_parse()
	 */
        -------------------------------------------------------------
	enum v4l2_mbus_type bus_type;
	struct {
		struct v4l2_mbus_config_parallel parallel;
		struct v4l2_mbus_config_mipi_csi1 mipi_csi1;
		struct v4l2_mbus_config_mipi_csi2 mipi_csi2;
	} bus;
        -------------------------------------------------------------
	u64 *link_frequencies;
	unsigned int nr_of_link_frequencies;
};

struct v4l2_mbus_config {
	enum v4l2_mbus_type type;
	union {
		struct v4l2_mbus_config_parallel parallel;
		struct v4l2_mbus_config_mipi_csi1 mipi_csi1;
		struct v4l2_mbus_config_mipi_csi2 mipi_csi2;
	} bus;
};


> Laurent Pinchart (8):
>   media: pxa_camera: Drop usage of .set_mbus_config()
>   media: i2c: ov6650: Drop implementation of .set_mbus_config()
>   media: v4l2-subdev: Drop .set_mbus_config() operation
>   media: v4l2-fwnode: Move bus config structure to v4l2_mediabus.h
>   media: v4l2-mediabus: Use structures to describe bus configuration
>   media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_*_LANE flags
>   media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_CHANNEL_* flags
>   media: v4l2-mediabus: Drop V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag
>
>  drivers/gpu/ipu-v3/ipu-csi.c                  |   6 +-
>  drivers/media/i2c/adv7180.c                   |  10 +-
>  drivers/media/i2c/adv748x/adv748x-csi2.c      |  18 +--
>  drivers/media/i2c/ml86v7667.c                 |   5 +-
>  drivers/media/i2c/mt9m001.c                   |   8 +-
>  drivers/media/i2c/mt9m111.c                   |  16 +--
>  drivers/media/i2c/ov5648.c                    |   4 +-
>  drivers/media/i2c/ov6650.c                    |  51 ++-------
>  drivers/media/i2c/ov8865.c                    |   4 +-
>  drivers/media/i2c/ov9640.c                    |   8 +-
>  drivers/media/i2c/tc358743.c                  |  26 +----
>  drivers/media/i2c/tvp5150.c                   |   6 +-
>  drivers/media/platform/pxa_camera.c           |  21 ++--
>  drivers/media/platform/qcom/camss/camss.c     |   2 +-
>  drivers/media/platform/rcar-vin/rcar-csi2.c   |  16 +--
>  drivers/media/platform/rcar-vin/rcar-vin.h    |   2 +-
>  drivers/media/platform/stm32/stm32-dcmi.c     |   2 +-
>  .../platform/sunxi/sun4i-csi/sun4i_csi.h      |   2 +-
>  .../platform/sunxi/sun4i-csi/sun4i_dma.c      |   2 +-
>  drivers/media/platform/ti-vpe/cal-camerarx.c  |   6 +-
>  drivers/media/v4l2-core/v4l2-fwnode.c         |  16 ++-
>  drivers/media/v4l2-core/v4l2-subdev.c         |   8 --
>  drivers/staging/media/imx/imx-media-csi.c     |   7 +-
>  drivers/staging/media/imx/imx6-mipi-csi2.c    |  25 +----
>  drivers/staging/media/imx/imx7-mipi-csis.c    |   2 +-
>  drivers/staging/media/imx/imx8mq-mipi-csi2.c  |   2 +-
>  drivers/staging/media/max96712/max96712.c     |   2 +-
>  include/media/v4l2-fwnode.h                   |  61 +---------
>  include/media/v4l2-mediabus.h                 | 104 ++++++++++++------
>  include/media/v4l2-subdev.h                   |  13 ---
>  30 files changed, 168 insertions(+), 287 deletions(-)
>
>
> base-commit: 68b9bcc8a534cd11fe55f8bc82f948aae7d81b3c
> --
> Regards,
>
> Laurent Pinchart
>

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

* Re: [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config()
  2022-01-09 14:36 ` [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config() Jacopo Mondi
@ 2022-01-09 22:55   ` Laurent Pinchart
  2022-01-10  8:42     ` Sakari Ailus
  0 siblings, 1 reply; 36+ messages in thread
From: Laurent Pinchart @ 2022-01-09 22:55 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: linux-media, linux-renesas-soc, Sakari Ailus, Hans Verkuil,
	Kieran Bingham, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik

Hi Jacopo,

On Sun, Jan 09, 2022 at 03:36:24PM +0100, Jacopo Mondi wrote:
> On Mon, Jan 03, 2022 at 06:24:06PM +0200, Laurent Pinchart wrote:
> > Hello,
> >
> > This patch series reworks the V4L2 subdev .get_mbus_config() and
> > .set_mbus_config() operations to improve the former and drop the latter.
> >
> > These subdev operations originate from soc-camera (for those who
> > remember the framework), and were designed to let a transmitter and a
> > receiver negotiate the physical configuration of the bus that connects
> > them. The operations use bitflags to represent bus parameters, with
> > supported options set by the caller of .set_mbus_config(), and selected
> > options among those returned by the callee. This mechanism is
> > deprecated, as selection of the bus configuration has long been moved to
> > the firmware interface (DT or ACPI), and usage of bitflags prevents from
> > adding more complex configuration parameters (timings in particular).
> >
> > As .set_mbus_config() is deprecated and used by one pair of drivers only
> > (pxa_camera and ov6650), it wasn't difficult to drop usage of that
> > operation in patches 1/8 and 2/8, and remove the operation itself in
> > patch 3/8.
> >
> > With that operation gone, .get_mbus_config() can be moved from bitflags
> > to structures. It turned out that the needed data structures were
> > already present in v4l2_fwnode.h. Patch 4/8 moves them to
> > v4l2_mediabus.h (and renames them to drop the fwnode mention, as they're
> > not specific to the fwnode API), and patch 5/8 makes use of them.
> 
> great, when the soc_camera version was dropped, the next thing to do
> was to move away from bitflags and move to structure fields...

There's an endless supply of cleanups to be done.

> > Patches 6/8 to 8/8 then removes media bus configuration bitflags that
> > are unneeded (and now unused).
> 
> Parallel might require a bit more of work, but csi2 already has a
> single flag
> 
> /* Clock non-continuous mode support. */
> #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(0)
> 
> so it should be trivial to replace 'flags' with a boolean
> 'clock_noncontinuous' field.
> 
> One things leaves me a bit confused: we're now mixing run-time
> configurable paramters (eg the number of data lanes in use in the
> current streaming sessions) and paramters which come from DT and are
> usually fixed by the HW design like lanes ordering.
> 
> Is this ok in your opinion ?

The .get_mbus_config() operation is meant to report the runtime
configuration, which is constrained by hardware limitations (for
instance the number of data lanes routed on the board, as expressed in
DT, or the ability to support non-continuous clock mode, which is an
intrinsic property of the device, known by the driver). When multiple
options are possible within the constraints of the platform, how to
select between them is currently unspecified. If the need arises, we'll
have to study the use cases and find a solution.

> > The series is an RFC as not everything has been converted from bitflags
> > to named fields in structures. In particular, the parallel bus flags
> > haven't been touched at all. Patch 8/8 shows how mutually exclusive
> > flags can be reworked to drop one of them. We then need to decide
> > whether to keep expressing the flag as macros, or move to C bitfields
> > with dedicated structure member names. I didn't want to include this
> > change in the RFC before getting feedback on the general approach
> > (feedback on those specific questions will also be appreciated).
> 
> There's also an opportunity to use v4l2_mbus_config as part of
> v4l2_fwnode_endpoint instead of repeating the same fields ?
> 
> struct v4l2_fwnode_endpoint {
> 	struct fwnode_endpoint base;
> 	/*
> 	 * Fields below this line will be zeroed by
> 	 * v4l2_fwnode_endpoint_parse()
> 	 */
>         -------------------------------------------------------------
> 	enum v4l2_mbus_type bus_type;
> 	struct {
> 		struct v4l2_mbus_config_parallel parallel;
> 		struct v4l2_mbus_config_mipi_csi1 mipi_csi1;
> 		struct v4l2_mbus_config_mipi_csi2 mipi_csi2;
> 	} bus;
>         -------------------------------------------------------------
> 	u64 *link_frequencies;
> 	unsigned int nr_of_link_frequencies;
> };
> 
> struct v4l2_mbus_config {
> 	enum v4l2_mbus_type type;
> 	union {
> 		struct v4l2_mbus_config_parallel parallel;
> 		struct v4l2_mbus_config_mipi_csi1 mipi_csi1;
> 		struct v4l2_mbus_config_mipi_csi2 mipi_csi2;
> 	} bus;
> };

I've thought about it, but not that the former groups the bus-specific
data in a struct, while the latter uses a union. Whether or not we could
use the same in both cases is an issue I have decided not to think about
at this stage :-)

> > Laurent Pinchart (8):
> >   media: pxa_camera: Drop usage of .set_mbus_config()
> >   media: i2c: ov6650: Drop implementation of .set_mbus_config()
> >   media: v4l2-subdev: Drop .set_mbus_config() operation
> >   media: v4l2-fwnode: Move bus config structure to v4l2_mediabus.h
> >   media: v4l2-mediabus: Use structures to describe bus configuration
> >   media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_*_LANE flags
> >   media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_CHANNEL_* flags
> >   media: v4l2-mediabus: Drop V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag
> >
> >  drivers/gpu/ipu-v3/ipu-csi.c                  |   6 +-
> >  drivers/media/i2c/adv7180.c                   |  10 +-
> >  drivers/media/i2c/adv748x/adv748x-csi2.c      |  18 +--
> >  drivers/media/i2c/ml86v7667.c                 |   5 +-
> >  drivers/media/i2c/mt9m001.c                   |   8 +-
> >  drivers/media/i2c/mt9m111.c                   |  16 +--
> >  drivers/media/i2c/ov5648.c                    |   4 +-
> >  drivers/media/i2c/ov6650.c                    |  51 ++-------
> >  drivers/media/i2c/ov8865.c                    |   4 +-
> >  drivers/media/i2c/ov9640.c                    |   8 +-
> >  drivers/media/i2c/tc358743.c                  |  26 +----
> >  drivers/media/i2c/tvp5150.c                   |   6 +-
> >  drivers/media/platform/pxa_camera.c           |  21 ++--
> >  drivers/media/platform/qcom/camss/camss.c     |   2 +-
> >  drivers/media/platform/rcar-vin/rcar-csi2.c   |  16 +--
> >  drivers/media/platform/rcar-vin/rcar-vin.h    |   2 +-
> >  drivers/media/platform/stm32/stm32-dcmi.c     |   2 +-
> >  .../platform/sunxi/sun4i-csi/sun4i_csi.h      |   2 +-
> >  .../platform/sunxi/sun4i-csi/sun4i_dma.c      |   2 +-
> >  drivers/media/platform/ti-vpe/cal-camerarx.c  |   6 +-
> >  drivers/media/v4l2-core/v4l2-fwnode.c         |  16 ++-
> >  drivers/media/v4l2-core/v4l2-subdev.c         |   8 --
> >  drivers/staging/media/imx/imx-media-csi.c     |   7 +-
> >  drivers/staging/media/imx/imx6-mipi-csi2.c    |  25 +----
> >  drivers/staging/media/imx/imx7-mipi-csis.c    |   2 +-
> >  drivers/staging/media/imx/imx8mq-mipi-csi2.c  |   2 +-
> >  drivers/staging/media/max96712/max96712.c     |   2 +-
> >  include/media/v4l2-fwnode.h                   |  61 +---------
> >  include/media/v4l2-mediabus.h                 | 104 ++++++++++++------
> >  include/media/v4l2-subdev.h                   |  13 ---
> >  30 files changed, 168 insertions(+), 287 deletions(-)
> >
> >
> > base-commit: 68b9bcc8a534cd11fe55f8bc82f948aae7d81b3c

-- 
Regards,

Laurent Pinchart

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

* Re: [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config()
  2022-01-09 22:55   ` Laurent Pinchart
@ 2022-01-10  8:42     ` Sakari Ailus
  0 siblings, 0 replies; 36+ messages in thread
From: Sakari Ailus @ 2022-01-10  8:42 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Jacopo Mondi, linux-media, linux-renesas-soc, Hans Verkuil,
	Kieran Bingham, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik

Hi Laurent, Jacopo,

On Mon, Jan 10, 2022 at 12:55:48AM +0200, Laurent Pinchart wrote:
> Hi Jacopo,
> 
> On Sun, Jan 09, 2022 at 03:36:24PM +0100, Jacopo Mondi wrote:
> > On Mon, Jan 03, 2022 at 06:24:06PM +0200, Laurent Pinchart wrote:
> > > Hello,
> > >
> > > This patch series reworks the V4L2 subdev .get_mbus_config() and
> > > .set_mbus_config() operations to improve the former and drop the latter.
> > >
> > > These subdev operations originate from soc-camera (for those who
> > > remember the framework), and were designed to let a transmitter and a
> > > receiver negotiate the physical configuration of the bus that connects
> > > them. The operations use bitflags to represent bus parameters, with
> > > supported options set by the caller of .set_mbus_config(), and selected
> > > options among those returned by the callee. This mechanism is
> > > deprecated, as selection of the bus configuration has long been moved to
> > > the firmware interface (DT or ACPI), and usage of bitflags prevents from
> > > adding more complex configuration parameters (timings in particular).
> > >
> > > As .set_mbus_config() is deprecated and used by one pair of drivers only
> > > (pxa_camera and ov6650), it wasn't difficult to drop usage of that
> > > operation in patches 1/8 and 2/8, and remove the operation itself in
> > > patch 3/8.
> > >
> > > With that operation gone, .get_mbus_config() can be moved from bitflags
> > > to structures. It turned out that the needed data structures were
> > > already present in v4l2_fwnode.h. Patch 4/8 moves them to
> > > v4l2_mediabus.h (and renames them to drop the fwnode mention, as they're
> > > not specific to the fwnode API), and patch 5/8 makes use of them.
> > 
> > great, when the soc_camera version was dropped, the next thing to do
> > was to move away from bitflags and move to structure fields...
> 
> There's an endless supply of cleanups to be done.
> 
> > > Patches 6/8 to 8/8 then removes media bus configuration bitflags that
> > > are unneeded (and now unused).
> > 
> > Parallel might require a bit more of work, but csi2 already has a
> > single flag
> > 
> > /* Clock non-continuous mode support. */
> > #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(0)
> > 
> > so it should be trivial to replace 'flags' with a boolean
> > 'clock_noncontinuous' field.
> > 
> > One things leaves me a bit confused: we're now mixing run-time
> > configurable paramters (eg the number of data lanes in use in the
> > current streaming sessions) and paramters which come from DT and are
> > usually fixed by the HW design like lanes ordering.
> > 
> > Is this ok in your opinion ?
> 
> The .get_mbus_config() operation is meant to report the runtime
> configuration, which is constrained by hardware limitations (for
> instance the number of data lanes routed on the board, as expressed in
> DT, or the ability to support non-continuous clock mode, which is an
> intrinsic property of the device, known by the driver). When multiple
> options are possible within the constraints of the platform, how to
> select between them is currently unspecified. If the need arises, we'll
> have to study the use cases and find a solution.
> 
> > > The series is an RFC as not everything has been converted from bitflags
> > > to named fields in structures. In particular, the parallel bus flags
> > > haven't been touched at all. Patch 8/8 shows how mutually exclusive
> > > flags can be reworked to drop one of them. We then need to decide
> > > whether to keep expressing the flag as macros, or move to C bitfields
> > > with dedicated structure member names. I didn't want to include this
> > > change in the RFC before getting feedback on the general approach
> > > (feedback on those specific questions will also be appreciated).
> > 
> > There's also an opportunity to use v4l2_mbus_config as part of
> > v4l2_fwnode_endpoint instead of repeating the same fields ?
> > 
> > struct v4l2_fwnode_endpoint {
> > 	struct fwnode_endpoint base;
> > 	/*
> > 	 * Fields below this line will be zeroed by
> > 	 * v4l2_fwnode_endpoint_parse()
> > 	 */
> >         -------------------------------------------------------------
> > 	enum v4l2_mbus_type bus_type;
> > 	struct {
> > 		struct v4l2_mbus_config_parallel parallel;
> > 		struct v4l2_mbus_config_mipi_csi1 mipi_csi1;
> > 		struct v4l2_mbus_config_mipi_csi2 mipi_csi2;
> > 	} bus;
> >         -------------------------------------------------------------
> > 	u64 *link_frequencies;
> > 	unsigned int nr_of_link_frequencies;
> > };
> > 
> > struct v4l2_mbus_config {
> > 	enum v4l2_mbus_type type;
> > 	union {
> > 		struct v4l2_mbus_config_parallel parallel;
> > 		struct v4l2_mbus_config_mipi_csi1 mipi_csi1;
> > 		struct v4l2_mbus_config_mipi_csi2 mipi_csi2;
> > 	} bus;
> > };
> 
> I've thought about it, but not that the former groups the bus-specific
> data in a struct, while the latter uses a union. Whether or not we could
> use the same in both cases is an issue I have decided not to think about
> at this stage :-)

I think it should be possible to replace that struct by an union. In the
past that probably was not the case.

The defaults for a bus type should be set just before enumerating it.
Drivers should be verified of course.

-- 
Regards,

Sakari Ailus

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

* Re: [RFC PATCH 2/8] media: i2c: ov6650: Drop implementation of .set_mbus_config()
  2022-01-07 13:41         ` Sakari Ailus
@ 2022-01-10 18:11           ` Janusz Krzysztofik
  2022-01-11 11:52             ` Sakari Ailus
  0 siblings, 1 reply; 36+ messages in thread
From: Janusz Krzysztofik @ 2022-01-10 18:11 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Laurent Pinchart, Linux Media Mailing List, linux-renesas-soc,
	Hans Verkuil, Kieran Bingham, Jacopo Mondi,
	Niklas Söderlund, Tomi Valkeinen

Hi Sakari,

On Friday, 7 January 2022 14:41:51 CET Sakari Ailus wrote:
> Hi Janusz,
> 
> On Wed, Jan 05, 2022 at 10:31:41PM +0100, Janusz Krzysztofik wrote:
> > Hi Laurent,
> > 
> > On Wednesday, 5 January 2022 21:19:49 CET Laurent Pinchart wrote:
> > > Hi Sakari,
> > >
> > > On Wed, Jan 05, 2022 at 08:04:24PM +0200, Sakari Ailus wrote:
> > > > On Mon, Jan 03, 2022 at 06:24:08PM +0200, Laurent Pinchart wrote:
> > > > > The subdev .set_mbus_config() operation is deprecated. No code in the
> > > > > kernel calls it, so drop its implementation from the ov6650 driver.
> > > > >
> > > > > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > > > > ---
> > > > >  drivers/media/i2c/ov6650.c | 37 -------------------------------------
> > > > >  1 file changed, 37 deletions(-)
> > > > >
> > > > > diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
> > > > > index f67412150b16..455a627e35a0 100644
> > > > > --- a/drivers/media/i2c/ov6650.c
> > > > > +++ b/drivers/media/i2c/ov6650.c
> > > > > @@ -944,42 +944,6 @@ static int ov6650_get_mbus_config(struct v4l2_subdev *sd,
> > > > >   return 0;
> > > > >  }
> > > > >
> > > > > -/* Alter bus settings on camera side */
> > > > > -static int ov6650_set_mbus_config(struct v4l2_subdev *sd,
> > > > > -                           unsigned int pad,
> > > > > -                           struct v4l2_mbus_config *cfg)
> > > > > -{
> > > > > - struct i2c_client *client = v4l2_get_subdevdata(sd);
> > > > > - int ret = 0;
> > > > > -
> > > > > - if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
> > > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_PCLK_RISING, 0);
> > > > > - else if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
> > > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_PCLK_RISING);
> > > >
> > > > I think this configuration should come from the endpoint which the driver
> > > > currently does not parse. In fact, there are no even DT bindings for the
> > > > device.
> > >
> > > There's also no OF match table. While this isn't strictly required, it
> > > may indicate that the sensor hasn't been tested much on DT-based
> > > systems.
> > >
> > > I agree that the configuration should come from the device tree, but I
> > > can't test that, so I'm tempted to let someone else implement it if the
> > > driver is actually still in use (I can also write a patch if someone can
> > > test it).
> > 
> > This driver was used with omap1_camera, removed from the tree a few years
> > ago by Hans, despite my attempts to refresh it.  I tried to keep ov6650
> > updated but I gave up due to lack of response to my submissions.  That also
> > blocked my attempts to rework and reintroduce omap1_camera.
> 
> My apologies for this --- I indeed to see a set of unreviewed ov6650 patches
> from you. Please do ping me if you expect an answer but do not get one.

OK, thanks.

> > I think I'm still able to update my local (v4l2, non-mc) version of
> > omap1_camera to the extent required to test any changes to ov6650.
> > However, the OMAP1 platform does not support DT, and will probably never
> > do.  Then,  I think that it makes sense to spend my time on that only if
> > you (media maintainers) are not going to depreciate non-DT support any
> > soon.  Are you?
> 
> Commenting just this and not the discussion later in this thread --- it is
> possible to support such sensor drivers without DT or ACPI nowadays,
> through software nodes. See e.g. drivers/media/pci/intel/ipu3/cio2-bridge.c

Thanks for bringing this possibility to my awareness, I didn't know it 
existed.  AFAICS, I2C sensor drivers like ov6650 can now be provided by 
board files with device properties via i2c_board_info.swnode.

If I find a solution to implement a non-v4l2-clk clock device in 
omap1_camera driver, I'll try to get back to updating ov6650 as time 
permits.

Thanks,
Janusz



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

* Re: [RFC PATCH 2/8] media: i2c: ov6650: Drop implementation of .set_mbus_config()
  2022-01-10 18:11           ` Janusz Krzysztofik
@ 2022-01-11 11:52             ` Sakari Ailus
  2022-01-11 20:37               ` Janusz Krzysztofik
  0 siblings, 1 reply; 36+ messages in thread
From: Sakari Ailus @ 2022-01-11 11:52 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Laurent Pinchart, Linux Media Mailing List, linux-renesas-soc,
	Hans Verkuil, Kieran Bingham, Jacopo Mondi,
	Niklas Söderlund, Tomi Valkeinen

Hi Janusz,

On Mon, Jan 10, 2022 at 07:11:45PM +0100, Janusz Krzysztofik wrote:
> Hi Sakari,
> 
> On Friday, 7 January 2022 14:41:51 CET Sakari Ailus wrote:
> > Hi Janusz,
> > 
> > On Wed, Jan 05, 2022 at 10:31:41PM +0100, Janusz Krzysztofik wrote:
> > > Hi Laurent,
> > > 
> > > On Wednesday, 5 January 2022 21:19:49 CET Laurent Pinchart wrote:
> > > > Hi Sakari,
> > > >
> > > > On Wed, Jan 05, 2022 at 08:04:24PM +0200, Sakari Ailus wrote:
> > > > > On Mon, Jan 03, 2022 at 06:24:08PM +0200, Laurent Pinchart wrote:
> > > > > > The subdev .set_mbus_config() operation is deprecated. No code in the
> > > > > > kernel calls it, so drop its implementation from the ov6650 driver.
> > > > > >
> > > > > > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > > > > > ---
> > > > > >  drivers/media/i2c/ov6650.c | 37 -------------------------------------
> > > > > >  1 file changed, 37 deletions(-)
> > > > > >
> > > > > > diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
> > > > > > index f67412150b16..455a627e35a0 100644
> > > > > > --- a/drivers/media/i2c/ov6650.c
> > > > > > +++ b/drivers/media/i2c/ov6650.c
> > > > > > @@ -944,42 +944,6 @@ static int ov6650_get_mbus_config(struct v4l2_subdev *sd,
> > > > > >   return 0;
> > > > > >  }
> > > > > >
> > > > > > -/* Alter bus settings on camera side */
> > > > > > -static int ov6650_set_mbus_config(struct v4l2_subdev *sd,
> > > > > > -                           unsigned int pad,
> > > > > > -                           struct v4l2_mbus_config *cfg)
> > > > > > -{
> > > > > > - struct i2c_client *client = v4l2_get_subdevdata(sd);
> > > > > > - int ret = 0;
> > > > > > -
> > > > > > - if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
> > > > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_PCLK_RISING, 0);
> > > > > > - else if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
> > > > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_PCLK_RISING);
> > > > >
> > > > > I think this configuration should come from the endpoint which the driver
> > > > > currently does not parse. In fact, there are no even DT bindings for the
> > > > > device.
> > > >
> > > > There's also no OF match table. While this isn't strictly required, it
> > > > may indicate that the sensor hasn't been tested much on DT-based
> > > > systems.
> > > >
> > > > I agree that the configuration should come from the device tree, but I
> > > > can't test that, so I'm tempted to let someone else implement it if the
> > > > driver is actually still in use (I can also write a patch if someone can
> > > > test it).
> > > 
> > > This driver was used with omap1_camera, removed from the tree a few years
> > > ago by Hans, despite my attempts to refresh it.  I tried to keep ov6650
> > > updated but I gave up due to lack of response to my submissions.  That also
> > > blocked my attempts to rework and reintroduce omap1_camera.
> > 
> > My apologies for this --- I indeed to see a set of unreviewed ov6650 patches
> > from you. Please do ping me if you expect an answer but do not get one.
> 
> OK, thanks.
> 
> > > I think I'm still able to update my local (v4l2, non-mc) version of
> > > omap1_camera to the extent required to test any changes to ov6650.
> > > However, the OMAP1 platform does not support DT, and will probably never
> > > do.  Then,  I think that it makes sense to spend my time on that only if
> > > you (media maintainers) are not going to depreciate non-DT support any
> > > soon.  Are you?
> > 
> > Commenting just this and not the discussion later in this thread --- it is
> > possible to support such sensor drivers without DT or ACPI nowadays,
> > through software nodes. See e.g. drivers/media/pci/intel/ipu3/cio2-bridge.c
> 
> Thanks for bringing this possibility to my awareness, I didn't know it 
> existed.  AFAICS, I2C sensor drivers like ov6650 can now be provided by 
> board files with device properties via i2c_board_info.swnode.

Looking at i2c_new_client_device(), it only takes a single software node.
For an endpoint at least three are required, meaning you'll need to do that
separately. At least that seems to be the case at the moment.

> 
> If I find a solution to implement a non-v4l2-clk clock device in 
> omap1_camera driver, I'll try to get back to updating ov6650 as time 
> permits.

Looking forward to that. Btw. I've taken the four patches you posted
earlier, rebased them a little and pushed them here:

<URL:https://git.linuxtv.org/sailus/media_tree.git/log/>

Let me know if they're (not) fine.

-- 
Kind regards,

Sakari Ailus

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

* Re: [RFC PATCH 2/8] media: i2c: ov6650: Drop implementation of .set_mbus_config()
  2022-01-11 11:52             ` Sakari Ailus
@ 2022-01-11 20:37               ` Janusz Krzysztofik
  0 siblings, 0 replies; 36+ messages in thread
From: Janusz Krzysztofik @ 2022-01-11 20:37 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Laurent Pinchart, Linux Media Mailing List, linux-renesas-soc,
	Hans Verkuil, Kieran Bingham, Jacopo Mondi,
	Niklas Söderlund, Tomi Valkeinen

Hi Sakari,

On Tuesday, 11 January 2022 12:52:38 CET Sakari Ailus wrote:
> Hi Janusz,
> 
> On Mon, Jan 10, 2022 at 07:11:45PM +0100, Janusz Krzysztofik wrote:
> > Hi Sakari,
> > 
> > On Friday, 7 January 2022 14:41:51 CET Sakari Ailus wrote:
> > > Hi Janusz,
> > > 
> > > On Wed, Jan 05, 2022 at 10:31:41PM +0100, Janusz Krzysztofik wrote:
> > > > Hi Laurent,
> > > > 
> > > > On Wednesday, 5 January 2022 21:19:49 CET Laurent Pinchart wrote:
> > > > > Hi Sakari,
> > > > >
> > > > > On Wed, Jan 05, 2022 at 08:04:24PM +0200, Sakari Ailus wrote:
> > > > > > On Mon, Jan 03, 2022 at 06:24:08PM +0200, Laurent Pinchart wrote:
> > > > > > > The subdev .set_mbus_config() operation is deprecated. No code in the
> > > > > > > kernel calls it, so drop its implementation from the ov6650 driver.
> > > > > > >
> > > > > > > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > > > > > > ---
> > > > > > >  drivers/media/i2c/ov6650.c | 37 -------------------------------------
> > > > > > >  1 file changed, 37 deletions(-)
> > > > > > >
> > > > > > > diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
> > > > > > > index f67412150b16..455a627e35a0 100644
> > > > > > > --- a/drivers/media/i2c/ov6650.c
> > > > > > > +++ b/drivers/media/i2c/ov6650.c
> > > > > > > @@ -944,42 +944,6 @@ static int ov6650_get_mbus_config(struct v4l2_subdev *sd,
> > > > > > >   return 0;
> > > > > > >  }
> > > > > > >
> > > > > > > -/* Alter bus settings on camera side */
> > > > > > > -static int ov6650_set_mbus_config(struct v4l2_subdev *sd,
> > > > > > > -                           unsigned int pad,
> > > > > > > -                           struct v4l2_mbus_config *cfg)
> > > > > > > -{
> > > > > > > - struct i2c_client *client = v4l2_get_subdevdata(sd);
> > > > > > > - int ret = 0;
> > > > > > > -
> > > > > > > - if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
> > > > > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_PCLK_RISING, 0);
> > > > > > > - else if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
> > > > > > > -         ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_PCLK_RISING);
> > > > > >
> > > > > > I think this configuration should come from the endpoint which the driver
> > > > > > currently does not parse. In fact, there are no even DT bindings for the
> > > > > > device.
> > > > >
> > > > > There's also no OF match table. While this isn't strictly required, it
> > > > > may indicate that the sensor hasn't been tested much on DT-based
> > > > > systems.
> > > > >
> > > > > I agree that the configuration should come from the device tree, but I
> > > > > can't test that, so I'm tempted to let someone else implement it if the
> > > > > driver is actually still in use (I can also write a patch if someone can
> > > > > test it).
> > > > 
> > > > This driver was used with omap1_camera, removed from the tree a few years
> > > > ago by Hans, despite my attempts to refresh it.  I tried to keep ov6650
> > > > updated but I gave up due to lack of response to my submissions.  That also
> > > > blocked my attempts to rework and reintroduce omap1_camera.
> > > 
> > > My apologies for this --- I indeed to see a set of unreviewed ov6650 patches
> > > from you. Please do ping me if you expect an answer but do not get one.
> > 
> > OK, thanks.
> > 
> > > > I think I'm still able to update my local (v4l2, non-mc) version of
> > > > omap1_camera to the extent required to test any changes to ov6650.
> > > > However, the OMAP1 platform does not support DT, and will probably never
> > > > do.  Then,  I think that it makes sense to spend my time on that only if
> > > > you (media maintainers) are not going to depreciate non-DT support any
> > > > soon.  Are you?
> > > 
> > > Commenting just this and not the discussion later in this thread --- it is
> > > possible to support such sensor drivers without DT or ACPI nowadays,
> > > through software nodes. See e.g. drivers/media/pci/intel/ipu3/cio2-bridge.c
> > 
> > Thanks for bringing this possibility to my awareness, I didn't know it 
> > existed.  AFAICS, I2C sensor drivers like ov6650 can now be provided by 
> > board files with device properties via i2c_board_info.swnode.
> 
> Looking at i2c_new_client_device(), it only takes a single software node.
> For an endpoint at least three are required, meaning you'll need to do that
> separately. At least that seems to be the case at the moment.

Thanks, I'll take a closer look.

> > 
> > If I find a solution to implement a non-v4l2-clk clock device in 
> > omap1_camera driver, I'll try to get back to updating ov6650 as time 
> > permits.
> 
> Looking forward to that. Btw. I've taken the four patches you posted
> earlier, rebased them a little and pushed them here:
> 
> <URL:https://git.linuxtv.org/sailus/media_tree.git/log/>
> 
> Let me know if they're (not) fine.

Should be fine, thank you.

Janusz

> 
> 





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

* Re: [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config()
  2022-01-03 16:24 [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config() Laurent Pinchart
                   ` (8 preceding siblings ...)
  2022-01-09 14:36 ` [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config() Jacopo Mondi
@ 2022-02-15  8:37 ` Laurent Pinchart
  9 siblings, 0 replies; 36+ messages in thread
From: Laurent Pinchart @ 2022-02-15  8:37 UTC (permalink / raw)
  To: linux-media
  Cc: linux-renesas-soc, Sakari Ailus, Hans Verkuil, Kieran Bingham,
	Jacopo Mondi, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik

Hello,

Reviews or 5/8 to 8/8 would be nice :-) Thanks.

On Mon, Jan 03, 2022 at 06:24:06PM +0200, Laurent Pinchart wrote:
> Hello,
> 
> This patch series reworks the V4L2 subdev .get_mbus_config() and
> .set_mbus_config() operations to improve the former and drop the latter.
> 
> These subdev operations originate from soc-camera (for those who
> remember the framework), and were designed to let a transmitter and a
> receiver negotiate the physical configuration of the bus that connects
> them. The operations use bitflags to represent bus parameters, with
> supported options set by the caller of .set_mbus_config(), and selected
> options among those returned by the callee. This mechanism is
> deprecated, as selection of the bus configuration has long been moved to
> the firmware interface (DT or ACPI), and usage of bitflags prevents from
> adding more complex configuration parameters (timings in particular).
> 
> As .set_mbus_config() is deprecated and used by one pair of drivers only
> (pxa_camera and ov6650), it wasn't difficult to drop usage of that
> operation in patches 1/8 and 2/8, and remove the operation itself in
> patch 3/8.
> 
> With that operation gone, .get_mbus_config() can be moved from bitflags
> to structures. It turned out that the needed data structures were
> already present in v4l2_fwnode.h. Patch 4/8 moves them to
> v4l2_mediabus.h (and renames them to drop the fwnode mention, as they're
> not specific to the fwnode API), and patch 5/8 makes use of them.
> Patches 6/8 to 8/8 then removes media bus configuration bitflags that
> are unneeded (and now unused).
> 
> The series is an RFC as not everything has been converted from bitflags
> to named fields in structures. In particular, the parallel bus flags
> haven't been touched at all. Patch 8/8 shows how mutually exclusive
> flags can be reworked to drop one of them. We then need to decide
> whether to keep expressing the flag as macros, or move to C bitfields
> with dedicated structure member names. I didn't want to include this
> change in the RFC before getting feedback on the general approach
> (feedback on those specific questions will also be appreciated).
> 
> Laurent Pinchart (8):
>   media: pxa_camera: Drop usage of .set_mbus_config()
>   media: i2c: ov6650: Drop implementation of .set_mbus_config()
>   media: v4l2-subdev: Drop .set_mbus_config() operation
>   media: v4l2-fwnode: Move bus config structure to v4l2_mediabus.h
>   media: v4l2-mediabus: Use structures to describe bus configuration
>   media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_*_LANE flags
>   media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_CHANNEL_* flags
>   media: v4l2-mediabus: Drop V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag
> 
>  drivers/gpu/ipu-v3/ipu-csi.c                  |   6 +-
>  drivers/media/i2c/adv7180.c                   |  10 +-
>  drivers/media/i2c/adv748x/adv748x-csi2.c      |  18 +--
>  drivers/media/i2c/ml86v7667.c                 |   5 +-
>  drivers/media/i2c/mt9m001.c                   |   8 +-
>  drivers/media/i2c/mt9m111.c                   |  16 +--
>  drivers/media/i2c/ov5648.c                    |   4 +-
>  drivers/media/i2c/ov6650.c                    |  51 ++-------
>  drivers/media/i2c/ov8865.c                    |   4 +-
>  drivers/media/i2c/ov9640.c                    |   8 +-
>  drivers/media/i2c/tc358743.c                  |  26 +----
>  drivers/media/i2c/tvp5150.c                   |   6 +-
>  drivers/media/platform/pxa_camera.c           |  21 ++--
>  drivers/media/platform/qcom/camss/camss.c     |   2 +-
>  drivers/media/platform/rcar-vin/rcar-csi2.c   |  16 +--
>  drivers/media/platform/rcar-vin/rcar-vin.h    |   2 +-
>  drivers/media/platform/stm32/stm32-dcmi.c     |   2 +-
>  .../platform/sunxi/sun4i-csi/sun4i_csi.h      |   2 +-
>  .../platform/sunxi/sun4i-csi/sun4i_dma.c      |   2 +-
>  drivers/media/platform/ti-vpe/cal-camerarx.c  |   6 +-
>  drivers/media/v4l2-core/v4l2-fwnode.c         |  16 ++-
>  drivers/media/v4l2-core/v4l2-subdev.c         |   8 --
>  drivers/staging/media/imx/imx-media-csi.c     |   7 +-
>  drivers/staging/media/imx/imx6-mipi-csi2.c    |  25 +----
>  drivers/staging/media/imx/imx7-mipi-csis.c    |   2 +-
>  drivers/staging/media/imx/imx8mq-mipi-csi2.c  |   2 +-
>  drivers/staging/media/max96712/max96712.c     |   2 +-
>  include/media/v4l2-fwnode.h                   |  61 +---------
>  include/media/v4l2-mediabus.h                 | 104 ++++++++++++------
>  include/media/v4l2-subdev.h                   |  13 ---
>  30 files changed, 168 insertions(+), 287 deletions(-)
> 
> 
> base-commit: 68b9bcc8a534cd11fe55f8bc82f948aae7d81b3c

-- 
Regards,

Laurent Pinchart

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

* Re: [RFC PATCH 7/8] media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_CHANNEL_* flags
  2022-01-03 16:24 ` [RFC PATCH 7/8] media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_CHANNEL_* flags Laurent Pinchart
@ 2022-02-15 11:01   ` Jacopo Mondi
  2022-02-15 11:10     ` Laurent Pinchart
  0 siblings, 1 reply; 36+ messages in thread
From: Jacopo Mondi @ 2022-02-15 11:01 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-media, linux-renesas-soc, Sakari Ailus, Hans Verkuil,
	Kieran Bingham, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik, Lars-Peter Clausen

Hi Laurent

On Mon, Jan 03, 2022 at 06:24:13PM +0200, Laurent Pinchart wrote:
> The V4L2_MBUS_CSI2_CHANNEL_* flags are a legacy API. Only
> V4L2_MBUS_CSI2_CHANNEL_0 is used, set in a single driver, and never
> read. Drop those flags. Virtual channel information should be conveyed
> through frame descriptors instead.

I see one more user in the latest media master
drivers/media/platform/atmel/microchip-csi2dc.c:        if (mbus_config.flags & V4L2_MBUS_CSI2_CHANNEL_0)

With that fixed
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

Thanks
  j

>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  drivers/media/i2c/adv7180.c   |  1 -
>  include/media/v4l2-mediabus.h | 10 ----------
>  2 files changed, 11 deletions(-)
>
> diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
> index 286f5017d9c3..3ff37a550810 100644
> --- a/drivers/media/i2c/adv7180.c
> +++ b/drivers/media/i2c/adv7180.c
> @@ -786,7 +786,6 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
>  		cfg->type = V4L2_MBUS_CSI2_DPHY;
>  		cfg->bus.mipi_csi2.num_data_lanes = 1;
>  		cfg->bus.mipi_csi2.flags =
> -				V4L2_MBUS_CSI2_CHANNEL_0 |
>  				V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
>  	} else {
>  		/*
> diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
> index 44195ceeccca..c6626a22b394 100644
> --- a/include/media/v4l2-mediabus.h
> +++ b/include/media/v4l2-mediabus.h
> @@ -67,20 +67,10 @@
>  #define V4L2_MBUS_DATA_ENABLE_LOW		BIT(15)
>
>  /* Serial flags */
> -/* CSI-2 Virtual Channel identifiers. */
> -#define V4L2_MBUS_CSI2_CHANNEL_0		BIT(4)
> -#define V4L2_MBUS_CSI2_CHANNEL_1		BIT(5)
> -#define V4L2_MBUS_CSI2_CHANNEL_2		BIT(6)
> -#define V4L2_MBUS_CSI2_CHANNEL_3		BIT(7)
>  /* Clock non-continuous mode support. */
>  #define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK		BIT(8)
>  #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(9)
>
> -#define V4L2_MBUS_CSI2_CHANNELS		(V4L2_MBUS_CSI2_CHANNEL_0 | \
> -					 V4L2_MBUS_CSI2_CHANNEL_1 | \
> -					 V4L2_MBUS_CSI2_CHANNEL_2 | \
> -					 V4L2_MBUS_CSI2_CHANNEL_3)
> -
>  #define V4L2_MBUS_CSI2_MAX_DATA_LANES		8
>
>  /**
> --
> Regards,
>
> Laurent Pinchart
>

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

* Re: [PATCH v1.1 8/8] media: v4l2-mediabus: Drop V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag
  2022-01-05 20:15     ` [PATCH v1.1 " Laurent Pinchart
@ 2022-02-15 11:04       ` Jacopo Mondi
  2022-02-15 11:12         ` Laurent Pinchart
  0 siblings, 1 reply; 36+ messages in thread
From: Jacopo Mondi @ 2022-02-15 11:04 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-media, linux-renesas-soc, Sakari Ailus, Hans Verkuil,
	Kieran Bingham, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik, Lars-Peter Clausen, Mats Randgaard

Hi Laurent,

On Wed, Jan 05, 2022 at 10:15:58PM +0200, Laurent Pinchart wrote:
> MIPI CSI-2 continuous and non-continuous clock modes are mutually
> exclusive. Drop the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag and use
> V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK only.
>

As continuous clock is the default configuration for CSI-2, wouldn't
it be easier to add a boolean clock_non_cont (or similar) to
v4l2_mbus_config_mipi_csi2 ?

> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> Changes since v1:
>
> - Check all CSI2 flags in v4l2_fwnode_endpoint_parse_csi2_bus()
> ---
>  drivers/media/i2c/adv7180.c           | 3 +--
>  drivers/media/i2c/tc358743.c          | 6 +++---
>  drivers/media/v4l2-core/v4l2-fwnode.c | 6 ++----
>  include/media/v4l2-mediabus.h         | 3 +--
>  4 files changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
> index 3ff37a550810..4f5db195e66d 100644
> --- a/drivers/media/i2c/adv7180.c
> +++ b/drivers/media/i2c/adv7180.c
> @@ -785,8 +785,7 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
>  	if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
>  		cfg->type = V4L2_MBUS_CSI2_DPHY;
>  		cfg->bus.mipi_csi2.num_data_lanes = 1;
> -		cfg->bus.mipi_csi2.flags =
> -				V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> +		cfg->bus.mipi_csi2.flags = 0;
>  	} else {
>  		/*
>  		 * The ADV7180 sensor supports BT.601/656 output modes.
> diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
> index dfbc42675143..e18b8947ad7e 100644
> --- a/drivers/media/i2c/tc358743.c
> +++ b/drivers/media/i2c/tc358743.c
> @@ -717,7 +717,7 @@ static void tc358743_set_csi(struct v4l2_subdev *sd)
>  			((lanes > 3) ? MASK_D3M_HSTXVREGEN : 0x0));
>
>  	i2c_wr32(sd, TXOPTIONCNTRL, (state->bus.flags &
> -		 V4L2_MBUS_CSI2_CONTINUOUS_CLOCK) ? MASK_CONTCLKMODE : 0);
> +		 V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK) ? 0 : MASK_CONTCLKMODE);
>  	i2c_wr32(sd, STARTCNTRL, MASK_START);
>  	i2c_wr32(sd, CSI_START, MASK_STRT);
>
> @@ -1613,7 +1613,7 @@ static int tc358743_get_mbus_config(struct v4l2_subdev *sd,
>  	cfg->type = V4L2_MBUS_CSI2_DPHY;
>
>  	/* Support for non-continuous CSI-2 clock is missing in the driver */
> -	cfg->bus.mipi_csi2.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> +	cfg->bus.mipi_csi2.flags = 0;
>  	cfg->bus.mipi_csi2.num_data_lanes = state->csi_lanes_in_use;
>
>  	return 0;
> @@ -2039,7 +2039,7 @@ static int tc358743_probe(struct i2c_client *client)
>  	/* platform data */
>  	if (pdata) {
>  		state->pdata = *pdata;
> -		state->bus.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> +		state->bus.flags = 0;
>  	} else {
>  		err = tc358743_probe_of(state);
>  		if (err == -ENODEV)
> diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
> index 9ff3ebb230e7..71dcc9a96535 100644
> --- a/drivers/media/v4l2-core/v4l2-fwnode.c
> +++ b/drivers/media/v4l2-core/v4l2-fwnode.c
> @@ -207,13 +207,11 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
>  	if (fwnode_property_present(fwnode, "clock-noncontinuous")) {
>  		flags |= V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK;
>  		pr_debug("non-continuous clock\n");
> -	} else {
> -		flags |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
>  	}
>
>  	if (bus_type == V4L2_MBUS_CSI2_DPHY ||
> -	    bus_type == V4L2_MBUS_CSI2_CPHY || lanes_used ||
> -	    have_clk_lane || (flags & ~V4L2_MBUS_CSI2_CONTINUOUS_CLOCK)) {
> +	    bus_type == V4L2_MBUS_CSI2_CPHY ||
> +	    lanes_used || have_clk_lane || flags) {
>  		/* Only D-PHY has a clock lane. */
>  		unsigned int dfl_data_lane_index =
>  			bus_type == V4L2_MBUS_CSI2_DPHY;
> diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
> index c6626a22b394..e0db3bcff9ed 100644
> --- a/include/media/v4l2-mediabus.h
> +++ b/include/media/v4l2-mediabus.h
> @@ -68,8 +68,7 @@
>
>  /* Serial flags */
>  /* Clock non-continuous mode support. */
> -#define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK		BIT(8)
> -#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(9)
> +#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(0)
>
>  #define V4L2_MBUS_CSI2_MAX_DATA_LANES		8
>
>
> base-commit: 68b9bcc8a534cd11fe55f8bc82f948aae7d81b3c
> prerequisite-patch-id: cc085f7de462ead19772e3f64e1b1d13bb92d5b7
> prerequisite-patch-id: d6943d1780603964a753d571e26bad98b4954a8a
> prerequisite-patch-id: c63eaa2a61aeea6d4be238644f1324f0170d981c
> prerequisite-patch-id: 797385e385b3f71f0bafe7eb8e712d52628c23d7
> prerequisite-patch-id: 2f7fe0901f79ac1d445e443b5d3ee7ab9ae41525
> prerequisite-patch-id: 70ddd068308b5758872349ec6e0f03e8c9427dc0
> prerequisite-patch-id: 987cc8f39cb63badf2d6ceba946deffafba9a249
> --
> Regards,
>
> Laurent Pinchart
>

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

* Re: [RFC PATCH 7/8] media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_CHANNEL_* flags
  2022-02-15 11:01   ` Jacopo Mondi
@ 2022-02-15 11:10     ` Laurent Pinchart
  0 siblings, 0 replies; 36+ messages in thread
From: Laurent Pinchart @ 2022-02-15 11:10 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: linux-media, linux-renesas-soc, Sakari Ailus, Hans Verkuil,
	Kieran Bingham, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik, Lars-Peter Clausen

Hi Jacopo,

On Tue, Feb 15, 2022 at 12:01:41PM +0100, Jacopo Mondi wrote:
> On Mon, Jan 03, 2022 at 06:24:13PM +0200, Laurent Pinchart wrote:
> > The V4L2_MBUS_CSI2_CHANNEL_* flags are a legacy API. Only
> > V4L2_MBUS_CSI2_CHANNEL_0 is used, set in a single driver, and never
> > read. Drop those flags. Virtual channel information should be conveyed
> > through frame descriptors instead.
> 
> I see one more user in the latest media master
> drivers/media/platform/atmel/microchip-csi2dc.c:        if (mbus_config.flags & V4L2_MBUS_CSI2_CHANNEL_0)

Sakari has sent
https://lore.kernel.org/linux-media/20220202153609.240387-1-sakari.ailus@linux.intel.com
to address this.

Sakari, will you take the remainder of this series in your tree ?

> With that fixed
> Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> >  drivers/media/i2c/adv7180.c   |  1 -
> >  include/media/v4l2-mediabus.h | 10 ----------
> >  2 files changed, 11 deletions(-)
> >
> > diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
> > index 286f5017d9c3..3ff37a550810 100644
> > --- a/drivers/media/i2c/adv7180.c
> > +++ b/drivers/media/i2c/adv7180.c
> > @@ -786,7 +786,6 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
> >  		cfg->type = V4L2_MBUS_CSI2_DPHY;
> >  		cfg->bus.mipi_csi2.num_data_lanes = 1;
> >  		cfg->bus.mipi_csi2.flags =
> > -				V4L2_MBUS_CSI2_CHANNEL_0 |
> >  				V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> >  	} else {
> >  		/*
> > diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
> > index 44195ceeccca..c6626a22b394 100644
> > --- a/include/media/v4l2-mediabus.h
> > +++ b/include/media/v4l2-mediabus.h
> > @@ -67,20 +67,10 @@
> >  #define V4L2_MBUS_DATA_ENABLE_LOW		BIT(15)
> >
> >  /* Serial flags */
> > -/* CSI-2 Virtual Channel identifiers. */
> > -#define V4L2_MBUS_CSI2_CHANNEL_0		BIT(4)
> > -#define V4L2_MBUS_CSI2_CHANNEL_1		BIT(5)
> > -#define V4L2_MBUS_CSI2_CHANNEL_2		BIT(6)
> > -#define V4L2_MBUS_CSI2_CHANNEL_3		BIT(7)
> >  /* Clock non-continuous mode support. */
> >  #define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK		BIT(8)
> >  #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(9)
> >
> > -#define V4L2_MBUS_CSI2_CHANNELS		(V4L2_MBUS_CSI2_CHANNEL_0 | \
> > -					 V4L2_MBUS_CSI2_CHANNEL_1 | \
> > -					 V4L2_MBUS_CSI2_CHANNEL_2 | \
> > -					 V4L2_MBUS_CSI2_CHANNEL_3)
> > -
> >  #define V4L2_MBUS_CSI2_MAX_DATA_LANES		8
> >
> >  /**

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH v1.1 8/8] media: v4l2-mediabus: Drop V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag
  2022-02-15 11:04       ` Jacopo Mondi
@ 2022-02-15 11:12         ` Laurent Pinchart
  2022-02-15 11:29           ` Jacopo Mondi
  0 siblings, 1 reply; 36+ messages in thread
From: Laurent Pinchart @ 2022-02-15 11:12 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: linux-media, linux-renesas-soc, Sakari Ailus, Hans Verkuil,
	Kieran Bingham, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik, Lars-Peter Clausen, Mats Randgaard

Hi Jacopo,

On Tue, Feb 15, 2022 at 12:04:20PM +0100, Jacopo Mondi wrote:
> On Wed, Jan 05, 2022 at 10:15:58PM +0200, Laurent Pinchart wrote:
> > MIPI CSI-2 continuous and non-continuous clock modes are mutually
> > exclusive. Drop the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag and use
> > V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK only.
> 
> As continuous clock is the default configuration for CSI-2, wouldn't
> it be easier to add a boolean clock_non_cont (or similar) to
> v4l2_mbus_config_mipi_csi2 ?

That would be functionally equivalent, but flags will take less memory
compared to multiple booleans. I don't mind much though, and another
option would be to use a bitfield.

> > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> > Changes since v1:
> >
> > - Check all CSI2 flags in v4l2_fwnode_endpoint_parse_csi2_bus()
> > ---
> >  drivers/media/i2c/adv7180.c           | 3 +--
> >  drivers/media/i2c/tc358743.c          | 6 +++---
> >  drivers/media/v4l2-core/v4l2-fwnode.c | 6 ++----
> >  include/media/v4l2-mediabus.h         | 3 +--
> >  4 files changed, 7 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
> > index 3ff37a550810..4f5db195e66d 100644
> > --- a/drivers/media/i2c/adv7180.c
> > +++ b/drivers/media/i2c/adv7180.c
> > @@ -785,8 +785,7 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
> >  	if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
> >  		cfg->type = V4L2_MBUS_CSI2_DPHY;
> >  		cfg->bus.mipi_csi2.num_data_lanes = 1;
> > -		cfg->bus.mipi_csi2.flags =
> > -				V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > +		cfg->bus.mipi_csi2.flags = 0;
> >  	} else {
> >  		/*
> >  		 * The ADV7180 sensor supports BT.601/656 output modes.
> > diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
> > index dfbc42675143..e18b8947ad7e 100644
> > --- a/drivers/media/i2c/tc358743.c
> > +++ b/drivers/media/i2c/tc358743.c
> > @@ -717,7 +717,7 @@ static void tc358743_set_csi(struct v4l2_subdev *sd)
> >  			((lanes > 3) ? MASK_D3M_HSTXVREGEN : 0x0));
> >
> >  	i2c_wr32(sd, TXOPTIONCNTRL, (state->bus.flags &
> > -		 V4L2_MBUS_CSI2_CONTINUOUS_CLOCK) ? MASK_CONTCLKMODE : 0);
> > +		 V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK) ? 0 : MASK_CONTCLKMODE);
> >  	i2c_wr32(sd, STARTCNTRL, MASK_START);
> >  	i2c_wr32(sd, CSI_START, MASK_STRT);
> >
> > @@ -1613,7 +1613,7 @@ static int tc358743_get_mbus_config(struct v4l2_subdev *sd,
> >  	cfg->type = V4L2_MBUS_CSI2_DPHY;
> >
> >  	/* Support for non-continuous CSI-2 clock is missing in the driver */
> > -	cfg->bus.mipi_csi2.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > +	cfg->bus.mipi_csi2.flags = 0;
> >  	cfg->bus.mipi_csi2.num_data_lanes = state->csi_lanes_in_use;
> >
> >  	return 0;
> > @@ -2039,7 +2039,7 @@ static int tc358743_probe(struct i2c_client *client)
> >  	/* platform data */
> >  	if (pdata) {
> >  		state->pdata = *pdata;
> > -		state->bus.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > +		state->bus.flags = 0;
> >  	} else {
> >  		err = tc358743_probe_of(state);
> >  		if (err == -ENODEV)
> > diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
> > index 9ff3ebb230e7..71dcc9a96535 100644
> > --- a/drivers/media/v4l2-core/v4l2-fwnode.c
> > +++ b/drivers/media/v4l2-core/v4l2-fwnode.c
> > @@ -207,13 +207,11 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
> >  	if (fwnode_property_present(fwnode, "clock-noncontinuous")) {
> >  		flags |= V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK;
> >  		pr_debug("non-continuous clock\n");
> > -	} else {
> > -		flags |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> >  	}
> >
> >  	if (bus_type == V4L2_MBUS_CSI2_DPHY ||
> > -	    bus_type == V4L2_MBUS_CSI2_CPHY || lanes_used ||
> > -	    have_clk_lane || (flags & ~V4L2_MBUS_CSI2_CONTINUOUS_CLOCK)) {
> > +	    bus_type == V4L2_MBUS_CSI2_CPHY ||
> > +	    lanes_used || have_clk_lane || flags) {
> >  		/* Only D-PHY has a clock lane. */
> >  		unsigned int dfl_data_lane_index =
> >  			bus_type == V4L2_MBUS_CSI2_DPHY;
> > diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
> > index c6626a22b394..e0db3bcff9ed 100644
> > --- a/include/media/v4l2-mediabus.h
> > +++ b/include/media/v4l2-mediabus.h
> > @@ -68,8 +68,7 @@
> >
> >  /* Serial flags */
> >  /* Clock non-continuous mode support. */
> > -#define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK		BIT(8)
> > -#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(9)
> > +#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(0)
> >
> >  #define V4L2_MBUS_CSI2_MAX_DATA_LANES		8
> >
> >
> > base-commit: 68b9bcc8a534cd11fe55f8bc82f948aae7d81b3c
> > prerequisite-patch-id: cc085f7de462ead19772e3f64e1b1d13bb92d5b7
> > prerequisite-patch-id: d6943d1780603964a753d571e26bad98b4954a8a
> > prerequisite-patch-id: c63eaa2a61aeea6d4be238644f1324f0170d981c
> > prerequisite-patch-id: 797385e385b3f71f0bafe7eb8e712d52628c23d7
> > prerequisite-patch-id: 2f7fe0901f79ac1d445e443b5d3ee7ab9ae41525
> > prerequisite-patch-id: 70ddd068308b5758872349ec6e0f03e8c9427dc0
> > prerequisite-patch-id: 987cc8f39cb63badf2d6ceba946deffafba9a249

-- 
Regards,

Laurent Pinchart

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

* Re: [RFC PATCH 5/8] media: v4l2-mediabus: Use structures to describe bus configuration
  2022-01-03 16:24 ` [RFC PATCH 5/8] media: v4l2-mediabus: Use structures to describe bus configuration Laurent Pinchart
@ 2022-02-15 11:13   ` Jacopo Mondi
  2022-02-15 11:15     ` Laurent Pinchart
  0 siblings, 1 reply; 36+ messages in thread
From: Jacopo Mondi @ 2022-02-15 11:13 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-media, linux-renesas-soc, Sakari Ailus, Hans Verkuil,
	Kieran Bingham, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik, Philipp Zabel, Lars-Peter Clausen, Petr Cvek,
	Mats Randgaard, Steve Longerbeam, Shawn Guo, Sascha Hauer

Hi Laurent

On Mon, Jan 03, 2022 at 06:24:11PM +0200, Laurent Pinchart wrote:
> The media bus configuration is specified through a set of flags, some of
> which being mutually exclusive. This doesn't scale to express more
> complex configurations. Improve the API by replacing the single flags
> field in v4l2_mbus_config by a union of v4l2_mbus_config_* structures.
> The flags themselves are still used in those structures, so they are
> kept here. Drivers are however updated to use structure fields instead
> of flags when already possible.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  drivers/gpu/ipu-v3/ipu-csi.c                |  6 ++---
>  drivers/media/i2c/adv7180.c                 |  8 ++++---
>  drivers/media/i2c/adv748x/adv748x-csi2.c    | 18 +--------------
>  drivers/media/i2c/ml86v7667.c               |  5 +++--
>  drivers/media/i2c/mt9m001.c                 |  8 ++++---
>  drivers/media/i2c/mt9m111.c                 | 16 +++++++------
>  drivers/media/i2c/ov6650.c                  | 14 ++++++------
>  drivers/media/i2c/ov9640.c                  |  8 ++++---
>  drivers/media/i2c/tc358743.c                | 20 ++---------------
>  drivers/media/i2c/tvp5150.c                 |  6 +++--
>  drivers/media/platform/pxa_camera.c         | 12 +++++-----
>  drivers/media/platform/rcar-vin/rcar-csi2.c | 16 +++----------
>  drivers/staging/media/imx/imx-media-csi.c   |  7 +++---
>  drivers/staging/media/imx/imx6-mipi-csi2.c  | 25 +++------------------

drivers conversions looks good to me

>  include/media/v4l2-mediabus.h               | 20 ++++++++++++++---
>  15 files changed, 78 insertions(+), 111 deletions(-)
>
> diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
> index a9639d098893..778bc26d3ba5 100644
> --- a/drivers/gpu/ipu-v3/ipu-csi.c
> +++ b/drivers/gpu/ipu-v3/ipu-csi.c
> @@ -357,11 +357,11 @@ static int fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
>  	switch (mbus_cfg->type) {
>  	case V4L2_MBUS_PARALLEL:
>  		csicfg->ext_vsync = 1;
> -		csicfg->vsync_pol = (mbus_cfg->flags &
> +		csicfg->vsync_pol = (mbus_cfg->bus.parallel.flags &
>  				     V4L2_MBUS_VSYNC_ACTIVE_LOW) ? 1 : 0;
> -		csicfg->hsync_pol = (mbus_cfg->flags &
> +		csicfg->hsync_pol = (mbus_cfg->bus.parallel.flags &
>  				     V4L2_MBUS_HSYNC_ACTIVE_LOW) ? 1 : 0;
> -		csicfg->pixclk_pol = (mbus_cfg->flags &
> +		csicfg->pixclk_pol = (mbus_cfg->bus.parallel.flags &
>  				      V4L2_MBUS_PCLK_SAMPLE_FALLING) ? 1 : 0;
>  		csicfg->clk_mode = IPU_CSI_CLK_MODE_GATED_CLK;
>  		break;
> diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
> index d9a99fcfacb1..286f5017d9c3 100644
> --- a/drivers/media/i2c/adv7180.c
> +++ b/drivers/media/i2c/adv7180.c
> @@ -784,7 +784,8 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
>
>  	if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
>  		cfg->type = V4L2_MBUS_CSI2_DPHY;
> -		cfg->flags = V4L2_MBUS_CSI2_1_LANE |
> +		cfg->bus.mipi_csi2.num_data_lanes = 1;
> +		cfg->bus.mipi_csi2.flags =
>  				V4L2_MBUS_CSI2_CHANNEL_0 |
>  				V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
>  	} else {
> @@ -792,8 +793,9 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
>  		 * The ADV7180 sensor supports BT.601/656 output modes.
>  		 * The BT.656 is default and not yet configurable by s/w.
>  		 */
> -		cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
> -				 V4L2_MBUS_DATA_ACTIVE_HIGH;
> +		cfg->bus.parallel.flags = V4L2_MBUS_MASTER |
> +					  V4L2_MBUS_PCLK_SAMPLE_RISING |
> +					  V4L2_MBUS_DATA_ACTIVE_HIGH;
>  		cfg->type = V4L2_MBUS_BT656;
>  	}
>
> diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c
> index 589e9644fcdc..bd4f3fe0e309 100644
> --- a/drivers/media/i2c/adv748x/adv748x-csi2.c
> +++ b/drivers/media/i2c/adv748x/adv748x-csi2.c
> @@ -222,23 +222,7 @@ static int adv748x_csi2_get_mbus_config(struct v4l2_subdev *sd, unsigned int pad
>  		return -EINVAL;
>
>  	config->type = V4L2_MBUS_CSI2_DPHY;
> -	switch (tx->active_lanes) {
> -	case 1:
> -		config->flags = V4L2_MBUS_CSI2_1_LANE;
> -		break;
> -
> -	case 2:
> -		config->flags = V4L2_MBUS_CSI2_2_LANE;
> -		break;
> -
> -	case 3:
> -		config->flags = V4L2_MBUS_CSI2_3_LANE;
> -		break;
> -
> -	case 4:
> -		config->flags = V4L2_MBUS_CSI2_4_LANE;
> -		break;
> -	}
> +	config->bus.mipi_csi2.num_data_lanes = tx->active_lanes;
>
>  	return 0;
>  }
> diff --git a/drivers/media/i2c/ml86v7667.c b/drivers/media/i2c/ml86v7667.c
> index 4a1410ebb4c8..48cc0b0922f4 100644
> --- a/drivers/media/i2c/ml86v7667.c
> +++ b/drivers/media/i2c/ml86v7667.c
> @@ -223,9 +223,10 @@ static int ml86v7667_get_mbus_config(struct v4l2_subdev *sd,
>  				     unsigned int pad,
>  				     struct v4l2_mbus_config *cfg)
>  {
> -	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
> -		     V4L2_MBUS_DATA_ACTIVE_HIGH;
>  	cfg->type = V4L2_MBUS_BT656;
> +	cfg->bus.parallel.flags = V4L2_MBUS_MASTER |
> +				  V4L2_MBUS_PCLK_SAMPLE_RISING |
> +				  V4L2_MBUS_DATA_ACTIVE_HIGH;
>
>  	return 0;
>  }
> diff --git a/drivers/media/i2c/mt9m001.c b/drivers/media/i2c/mt9m001.c
> index c9f0bd997ea7..ad13b0c890c0 100644
> --- a/drivers/media/i2c/mt9m001.c
> +++ b/drivers/media/i2c/mt9m001.c
> @@ -695,10 +695,12 @@ static int mt9m001_get_mbus_config(struct v4l2_subdev *sd,
>  				   struct v4l2_mbus_config *cfg)
>  {
>  	/* MT9M001 has all capture_format parameters fixed */
> -	cfg->flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
> -		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> -		V4L2_MBUS_DATA_ACTIVE_HIGH | V4L2_MBUS_MASTER;
>  	cfg->type = V4L2_MBUS_PARALLEL;
> +	cfg->bus.parallel.flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
> +				  V4L2_MBUS_HSYNC_ACTIVE_HIGH |
> +				  V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> +				  V4L2_MBUS_DATA_ACTIVE_HIGH |
> +				  V4L2_MBUS_MASTER;
>
>  	return 0;
>  }
> diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
> index 91a44359bcd3..6cf3ccf85d27 100644
> --- a/drivers/media/i2c/mt9m111.c
> +++ b/drivers/media/i2c/mt9m111.c
> @@ -1143,15 +1143,17 @@ static int mt9m111_get_mbus_config(struct v4l2_subdev *sd,
>  {
>  	struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev);
>
> -	cfg->flags = V4L2_MBUS_MASTER |
> -		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> -		V4L2_MBUS_DATA_ACTIVE_HIGH;
> -
> -	cfg->flags |= mt9m111->pclk_sample ? V4L2_MBUS_PCLK_SAMPLE_RISING :
> -		V4L2_MBUS_PCLK_SAMPLE_FALLING;
> -
>  	cfg->type = V4L2_MBUS_PARALLEL;
>
> +	cfg->bus.parallel.flags = V4L2_MBUS_MASTER |
> +				  V4L2_MBUS_HSYNC_ACTIVE_HIGH |
> +				  V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> +				  V4L2_MBUS_DATA_ACTIVE_HIGH;
> +
> +	cfg->bus.parallel.flags |= mt9m111->pclk_sample ?
> +				   V4L2_MBUS_PCLK_SAMPLE_RISING :
> +				   V4L2_MBUS_PCLK_SAMPLE_FALLING;
> +
>  	return 0;
>  }
>
> diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
> index 455a627e35a0..b2654b32bc62 100644
> --- a/drivers/media/i2c/ov6650.c
> +++ b/drivers/media/i2c/ov6650.c
> @@ -932,15 +932,15 @@ static int ov6650_get_mbus_config(struct v4l2_subdev *sd,
>  	if (ret)
>  		return ret;
>
> -	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_DATA_ACTIVE_HIGH
> -		   | ((comj & COMJ_VSYNC_HIGH)  ? V4L2_MBUS_VSYNC_ACTIVE_HIGH
> -						: V4L2_MBUS_VSYNC_ACTIVE_LOW)
> -		   | ((comf & COMF_HREF_LOW)    ? V4L2_MBUS_HSYNC_ACTIVE_LOW
> -						: V4L2_MBUS_HSYNC_ACTIVE_HIGH)
> -		   | ((comj & COMJ_PCLK_RISING) ? V4L2_MBUS_PCLK_SAMPLE_RISING
> -						: V4L2_MBUS_PCLK_SAMPLE_FALLING);
>  	cfg->type = V4L2_MBUS_PARALLEL;
>
> +	cfg->bus.parallel.flags = V4L2_MBUS_MASTER | V4L2_MBUS_DATA_ACTIVE_HIGH
> +		| ((comj & COMJ_VSYNC_HIGH)  ? V4L2_MBUS_VSYNC_ACTIVE_HIGH
> +					     : V4L2_MBUS_VSYNC_ACTIVE_LOW)
> +		| ((comf & COMF_HREF_LOW)    ? V4L2_MBUS_HSYNC_ACTIVE_LOW
> +					     : V4L2_MBUS_HSYNC_ACTIVE_HIGH)
> +		| ((comj & COMJ_PCLK_RISING) ? V4L2_MBUS_PCLK_SAMPLE_RISING
> +					     : V4L2_MBUS_PCLK_SAMPLE_FALLING);
>  	return 0;
>  }
>
> diff --git a/drivers/media/i2c/ov9640.c b/drivers/media/i2c/ov9640.c
> index 0bab8c2cf160..9f44ed52d164 100644
> --- a/drivers/media/i2c/ov9640.c
> +++ b/drivers/media/i2c/ov9640.c
> @@ -652,10 +652,12 @@ static int ov9640_get_mbus_config(struct v4l2_subdev *sd,
>  				  unsigned int pad,
>  				  struct v4l2_mbus_config *cfg)
>  {
> -	cfg->flags = V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_MASTER |
> -		V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
> -		V4L2_MBUS_DATA_ACTIVE_HIGH;
>  	cfg->type = V4L2_MBUS_PARALLEL;
> +	cfg->bus.parallel.flags = V4L2_MBUS_PCLK_SAMPLE_RISING |
> +				  V4L2_MBUS_MASTER |
> +				  V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> +				  V4L2_MBUS_HSYNC_ACTIVE_HIGH |
> +				  V4L2_MBUS_DATA_ACTIVE_HIGH;
>
>  	return 0;
>  }
> diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
> index 40512004afba..dfbc42675143 100644
> --- a/drivers/media/i2c/tc358743.c
> +++ b/drivers/media/i2c/tc358743.c
> @@ -1613,24 +1613,8 @@ static int tc358743_get_mbus_config(struct v4l2_subdev *sd,
>  	cfg->type = V4L2_MBUS_CSI2_DPHY;
>
>  	/* Support for non-continuous CSI-2 clock is missing in the driver */
> -	cfg->flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> -
> -	switch (state->csi_lanes_in_use) {
> -	case 1:
> -		cfg->flags |= V4L2_MBUS_CSI2_1_LANE;
> -		break;
> -	case 2:
> -		cfg->flags |= V4L2_MBUS_CSI2_2_LANE;
> -		break;
> -	case 3:
> -		cfg->flags |= V4L2_MBUS_CSI2_3_LANE;
> -		break;
> -	case 4:
> -		cfg->flags |= V4L2_MBUS_CSI2_4_LANE;
> -		break;
> -	default:
> -		return -EINVAL;
> -	}
> +	cfg->bus.mipi_csi2.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> +	cfg->bus.mipi_csi2.num_data_lanes = state->csi_lanes_in_use;
>
>  	return 0;
>  }
> diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
> index 4b16ffcaef98..65472438444b 100644
> --- a/drivers/media/i2c/tvp5150.c
> +++ b/drivers/media/i2c/tvp5150.c
> @@ -1198,8 +1198,10 @@ static int tvp5150_get_mbus_config(struct v4l2_subdev *sd,
>  	struct tvp5150 *decoder = to_tvp5150(sd);
>
>  	cfg->type = decoder->mbus_type;
> -	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING
> -		   | V4L2_MBUS_FIELD_EVEN_LOW | V4L2_MBUS_DATA_ACTIVE_HIGH;
> +	cfg->bus.parallel.flags = V4L2_MBUS_MASTER
> +				| V4L2_MBUS_PCLK_SAMPLE_RISING
> +				| V4L2_MBUS_FIELD_EVEN_LOW
> +				| V4L2_MBUS_DATA_ACTIVE_HIGH;
>
>  	return 0;
>  }
> diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
> index b5644cf37fe9..35145e3348f0 100644
> --- a/drivers/media/platform/pxa_camera.c
> +++ b/drivers/media/platform/pxa_camera.c
> @@ -1587,24 +1587,26 @@ static int pxa_camera_set_bus_param(struct pxa_camera_dev *pcdev)
>  	 * PXA does not support V4L2_MBUS_DATA_ACTIVE_LOW and the bus mastering
>  	 * roles should match.
>  	 */
> -	if (cfg.flags != mbus_config) {
> +	if (cfg.bus.parallel.flags != mbus_config) {
>  		unsigned int pxa_mbus_role = mbus_config & (V4L2_MBUS_MASTER |
>  							    V4L2_MBUS_SLAVE);
> -		if (pxa_mbus_role != (cfg.flags & (V4L2_MBUS_MASTER |
> -						   V4L2_MBUS_SLAVE))) {
> +		unsigned int flags = cfg.bus.parallel.flags;
> +
> +		if (pxa_mbus_role != (flags & (V4L2_MBUS_MASTER |
> +					       V4L2_MBUS_SLAVE))) {
>  			dev_err(pcdev_to_dev(pcdev),
>  				"Unsupported mbus configuration: bus mastering\n");
>  			return -EINVAL;
>  		}
>
> -		if (cfg.flags & V4L2_MBUS_DATA_ACTIVE_LOW) {
> +		if (flags & V4L2_MBUS_DATA_ACTIVE_LOW) {
>  			dev_err(pcdev_to_dev(pcdev),
>  				"Unsupported mbus configuration: DATA_ACTIVE_LOW\n");
>  			return -EINVAL;
>  		}
>  	}
>
> -	pxa_camera_setup_cicr(pcdev, cfg.flags, pixfmt);
> +	pxa_camera_setup_cicr(pcdev, cfg.bus.parallel.flags, pixfmt);
>
>  	return 0;
>  }
> diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
> index 8c939cb3073d..cbac5801720b 100644
> --- a/drivers/media/platform/rcar-vin/rcar-csi2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
> @@ -603,7 +603,6 @@ static int rcsi2_get_active_lanes(struct rcar_csi2 *priv,
>  				  unsigned int *lanes)
>  {
>  	struct v4l2_mbus_config mbus_config = { 0 };
> -	unsigned int num_lanes = UINT_MAX;
>  	int ret;
>
>  	*lanes = priv->lanes;
> @@ -626,23 +625,14 @@ static int rcsi2_get_active_lanes(struct rcar_csi2 *priv,
>  		return -EINVAL;
>  	}
>
> -	if (mbus_config.flags & V4L2_MBUS_CSI2_1_LANE)
> -		num_lanes = 1;
> -	else if (mbus_config.flags & V4L2_MBUS_CSI2_2_LANE)
> -		num_lanes = 2;
> -	else if (mbus_config.flags & V4L2_MBUS_CSI2_3_LANE)
> -		num_lanes = 3;
> -	else if (mbus_config.flags & V4L2_MBUS_CSI2_4_LANE)
> -		num_lanes = 4;
> -
> -	if (num_lanes > priv->lanes) {
> +	if (mbus_config.bus.mipi_csi2.num_data_lanes > priv->lanes) {
>  		dev_err(priv->dev,
>  			"Unsupported mbus config: too many data lanes %u\n",
> -			num_lanes);
> +			mbus_config.bus.mipi_csi2.num_data_lanes);
>  		return -EINVAL;
>  	}
>
> -	*lanes = num_lanes;
> +	*lanes = mbus_config.bus.mipi_csi2.num_data_lanes;
>
>  	return 0;
>  }
> diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c
> index bd7f156f2d52..b2b1f4dd41d7 100644
> --- a/drivers/staging/media/imx/imx-media-csi.c
> +++ b/drivers/staging/media/imx/imx-media-csi.c
> @@ -718,9 +718,10 @@ static int csi_setup(struct csi_priv *priv)
>
>  	/* compose mbus_config from the upstream endpoint */
>  	mbus_cfg.type = priv->upstream_ep.bus_type;
> -	mbus_cfg.flags = is_parallel_bus(&priv->upstream_ep) ?
> -		priv->upstream_ep.bus.parallel.flags :
> -		priv->upstream_ep.bus.mipi_csi2.flags;
> +	if (is_parallel_bus(&priv->upstream_ep))
> +		mbus_cfg.bus.parallel = priv->upstream_ep.bus.parallel;
> +	else
> +		mbus_cfg.bus.mipi_csi2 = priv->upstream_ep.bus.mipi_csi2;
>
>  	if_fmt = *infmt;
>  	crop = priv->crop;
> diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c
> index 558b256ac935..c4cb558a85c6 100644
> --- a/drivers/staging/media/imx/imx6-mipi-csi2.c
> +++ b/drivers/staging/media/imx/imx6-mipi-csi2.c
> @@ -303,7 +303,6 @@ static void csi2ipu_gasket_init(struct csi2_dev *csi2)
>  static int csi2_get_active_lanes(struct csi2_dev *csi2, unsigned int *lanes)
>  {
>  	struct v4l2_mbus_config mbus_config = { 0 };
> -	unsigned int num_lanes = UINT_MAX;
>  	int ret;
>
>  	*lanes = csi2->data_lanes;
> @@ -326,32 +325,14 @@ static int csi2_get_active_lanes(struct csi2_dev *csi2, unsigned int *lanes)
>  		return -EINVAL;
>  	}
>
> -	switch (mbus_config.flags & V4L2_MBUS_CSI2_LANES) {
> -	case V4L2_MBUS_CSI2_1_LANE:
> -		num_lanes = 1;
> -		break;
> -	case V4L2_MBUS_CSI2_2_LANE:
> -		num_lanes = 2;
> -		break;
> -	case V4L2_MBUS_CSI2_3_LANE:
> -		num_lanes = 3;
> -		break;
> -	case V4L2_MBUS_CSI2_4_LANE:
> -		num_lanes = 4;
> -		break;
> -	default:
> -		num_lanes = csi2->data_lanes;
> -		break;
> -	}
> -
> -	if (num_lanes > csi2->data_lanes) {
> +	if (mbus_config.bus.mipi_csi2.num_data_lanes > csi2->data_lanes) {
>  		dev_err(csi2->dev,
>  			"Unsupported mbus config: too many data lanes %u\n",
> -			num_lanes);
> +			mbus_config.bus.mipi_csi2.num_data_lanes);
>  		return -EINVAL;
>  	}
>
> -	*lanes = num_lanes;
> +	*lanes = mbus_config.bus.mipi_csi2.num_data_lanes;
>
>  	return 0;
>  }
> diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
> index 9c4970fbd8ea..269aaf57ba32 100644
> --- a/include/media/v4l2-mediabus.h
> +++ b/include/media/v4l2-mediabus.h
> @@ -166,12 +166,26 @@ enum v4l2_mbus_type {
>
>  /**
>   * struct v4l2_mbus_config - media bus configuration
> - * @type:	in: interface type
> - * @flags:	in / out: configuration flags, depending on @type
> + * @type: interface type
> + * @bus: bus configuration data structure
> + * @bus.parallel: embedded &struct v4l2_mbus_config_parallel.
> + *		  Used if the bus is parallel or BT.656.
> + * @bus.mipi_csi1: embedded &struct v4l2_mbus_config_mipi_csi1.
> + *		   Used if the bus is MIPI Alliance's Camera Serial
> + *		   Interface version 1 (MIPI CSI1) or Standard
> + *		   Mobile Imaging Architecture's Compact Camera Port 2
> + *		   (SMIA CCP2).
> + * @bus.mipi_csi2: embedded &struct v4l2_mbus_config_mipi_csi2.
> + *		   Used if the bus is MIPI Alliance's Camera Serial
> + *		   Interface version 2 (MIPI CSI2).
>   */
>  struct v4l2_mbus_config {
>  	enum v4l2_mbus_type type;
> -	unsigned int flags;
> +	union {
> +		struct v4l2_mbus_config_parallel parallel;
> +		struct v4l2_mbus_config_mipi_csi1 mipi_csi1;
> +		struct v4l2_mbus_config_mipi_csi2 mipi_csi2;

I wonder if we would be able to use a single structure for D-PHY and
C-PHY. The clock lane index does not make much sense for the latter,
but it was already there, so it can be changed on top in case it is
required

Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

Thanks
  j

> +	} bus;
>  };
>
>  /**
> --
> Regards,
>
> Laurent Pinchart
>

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

* Re: [RFC PATCH 6/8] media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_*_LANE flags
  2022-01-03 16:24 ` [RFC PATCH 6/8] media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_*_LANE flags Laurent Pinchart
@ 2022-02-15 11:14   ` Jacopo Mondi
  0 siblings, 0 replies; 36+ messages in thread
From: Jacopo Mondi @ 2022-02-15 11:14 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-media, linux-renesas-soc, Sakari Ailus, Hans Verkuil,
	Kieran Bingham, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik

Hi Laurent,

On Mon, Jan 03, 2022 at 06:24:12PM +0200, Laurent Pinchart wrote:
> The V4L2_MBUS_CSI2_*_LANE flags are a legacy API and are unused. Drop
> them.
>

Nice removing these

Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

Thanks
  j

> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  include/media/v4l2-mediabus.h | 11 -----------
>  1 file changed, 11 deletions(-)
>
> diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
> index 269aaf57ba32..44195ceeccca 100644
> --- a/include/media/v4l2-mediabus.h
> +++ b/include/media/v4l2-mediabus.h
> @@ -21,8 +21,6 @@
>   * clear both the V4L2_MBUS_HSYNC_ACTIVE_HIGH and the
>   * V4L2_MBUS_HSYNC_ACTIVE_LOW flag at the same time. Instead either flag
>   * V4L2_MBUS_HSYNC_ACTIVE_HIGH or flag V4L2_MBUS_HSYNC_ACTIVE_LOW shall be set.
> - * The same is true for the V4L2_MBUS_CSI2_1/2/3/4_LANE flags group: only one
> - * of these four bits shall be set.
>   *
>   * TODO: replace the existing V4L2_MBUS_* flags with structures of fields
>   * to avoid conflicting settings.
> @@ -69,11 +67,6 @@
>  #define V4L2_MBUS_DATA_ENABLE_LOW		BIT(15)
>
>  /* Serial flags */
> -/* CSI-2 D-PHY number of data lanes. */
> -#define V4L2_MBUS_CSI2_1_LANE			BIT(0)
> -#define V4L2_MBUS_CSI2_2_LANE			BIT(1)
> -#define V4L2_MBUS_CSI2_3_LANE			BIT(2)
> -#define V4L2_MBUS_CSI2_4_LANE			BIT(3)
>  /* CSI-2 Virtual Channel identifiers. */
>  #define V4L2_MBUS_CSI2_CHANNEL_0		BIT(4)
>  #define V4L2_MBUS_CSI2_CHANNEL_1		BIT(5)
> @@ -83,10 +76,6 @@
>  #define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK		BIT(8)
>  #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(9)
>
> -#define V4L2_MBUS_CSI2_LANES		(V4L2_MBUS_CSI2_1_LANE | \
> -					 V4L2_MBUS_CSI2_2_LANE | \
> -					 V4L2_MBUS_CSI2_3_LANE | \
> -					 V4L2_MBUS_CSI2_4_LANE)
>  #define V4L2_MBUS_CSI2_CHANNELS		(V4L2_MBUS_CSI2_CHANNEL_0 | \
>  					 V4L2_MBUS_CSI2_CHANNEL_1 | \
>  					 V4L2_MBUS_CSI2_CHANNEL_2 | \
> --
> Regards,
>
> Laurent Pinchart
>

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

* Re: [RFC PATCH 5/8] media: v4l2-mediabus: Use structures to describe bus configuration
  2022-02-15 11:13   ` Jacopo Mondi
@ 2022-02-15 11:15     ` Laurent Pinchart
  2022-02-15 11:28       ` Jacopo Mondi
  0 siblings, 1 reply; 36+ messages in thread
From: Laurent Pinchart @ 2022-02-15 11:15 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: linux-media, linux-renesas-soc, Sakari Ailus, Hans Verkuil,
	Kieran Bingham, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik, Philipp Zabel, Lars-Peter Clausen, Petr Cvek,
	Mats Randgaard, Steve Longerbeam, Shawn Guo, Sascha Hauer

Hi Jacopo,

On Tue, Feb 15, 2022 at 12:13:16PM +0100, Jacopo Mondi wrote:
> On Mon, Jan 03, 2022 at 06:24:11PM +0200, Laurent Pinchart wrote:
> > The media bus configuration is specified through a set of flags, some of
> > which being mutually exclusive. This doesn't scale to express more
> > complex configurations. Improve the API by replacing the single flags
> > field in v4l2_mbus_config by a union of v4l2_mbus_config_* structures.
> > The flags themselves are still used in those structures, so they are
> > kept here. Drivers are however updated to use structure fields instead
> > of flags when already possible.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> >  drivers/gpu/ipu-v3/ipu-csi.c                |  6 ++---
> >  drivers/media/i2c/adv7180.c                 |  8 ++++---
> >  drivers/media/i2c/adv748x/adv748x-csi2.c    | 18 +--------------
> >  drivers/media/i2c/ml86v7667.c               |  5 +++--
> >  drivers/media/i2c/mt9m001.c                 |  8 ++++---
> >  drivers/media/i2c/mt9m111.c                 | 16 +++++++------
> >  drivers/media/i2c/ov6650.c                  | 14 ++++++------
> >  drivers/media/i2c/ov9640.c                  |  8 ++++---
> >  drivers/media/i2c/tc358743.c                | 20 ++---------------
> >  drivers/media/i2c/tvp5150.c                 |  6 +++--
> >  drivers/media/platform/pxa_camera.c         | 12 +++++-----
> >  drivers/media/platform/rcar-vin/rcar-csi2.c | 16 +++----------
> >  drivers/staging/media/imx/imx-media-csi.c   |  7 +++---
> >  drivers/staging/media/imx/imx6-mipi-csi2.c  | 25 +++------------------
> 
> drivers conversions looks good to me
> 
> >  include/media/v4l2-mediabus.h               | 20 ++++++++++++++---
> >  15 files changed, 78 insertions(+), 111 deletions(-)
> >
> > diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
> > index a9639d098893..778bc26d3ba5 100644
> > --- a/drivers/gpu/ipu-v3/ipu-csi.c
> > +++ b/drivers/gpu/ipu-v3/ipu-csi.c
> > @@ -357,11 +357,11 @@ static int fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
> >  	switch (mbus_cfg->type) {
> >  	case V4L2_MBUS_PARALLEL:
> >  		csicfg->ext_vsync = 1;
> > -		csicfg->vsync_pol = (mbus_cfg->flags &
> > +		csicfg->vsync_pol = (mbus_cfg->bus.parallel.flags &
> >  				     V4L2_MBUS_VSYNC_ACTIVE_LOW) ? 1 : 0;
> > -		csicfg->hsync_pol = (mbus_cfg->flags &
> > +		csicfg->hsync_pol = (mbus_cfg->bus.parallel.flags &
> >  				     V4L2_MBUS_HSYNC_ACTIVE_LOW) ? 1 : 0;
> > -		csicfg->pixclk_pol = (mbus_cfg->flags &
> > +		csicfg->pixclk_pol = (mbus_cfg->bus.parallel.flags &
> >  				      V4L2_MBUS_PCLK_SAMPLE_FALLING) ? 1 : 0;
> >  		csicfg->clk_mode = IPU_CSI_CLK_MODE_GATED_CLK;
> >  		break;
> > diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
> > index d9a99fcfacb1..286f5017d9c3 100644
> > --- a/drivers/media/i2c/adv7180.c
> > +++ b/drivers/media/i2c/adv7180.c
> > @@ -784,7 +784,8 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
> >
> >  	if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
> >  		cfg->type = V4L2_MBUS_CSI2_DPHY;
> > -		cfg->flags = V4L2_MBUS_CSI2_1_LANE |
> > +		cfg->bus.mipi_csi2.num_data_lanes = 1;
> > +		cfg->bus.mipi_csi2.flags =
> >  				V4L2_MBUS_CSI2_CHANNEL_0 |
> >  				V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> >  	} else {
> > @@ -792,8 +793,9 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
> >  		 * The ADV7180 sensor supports BT.601/656 output modes.
> >  		 * The BT.656 is default and not yet configurable by s/w.
> >  		 */
> > -		cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
> > -				 V4L2_MBUS_DATA_ACTIVE_HIGH;
> > +		cfg->bus.parallel.flags = V4L2_MBUS_MASTER |
> > +					  V4L2_MBUS_PCLK_SAMPLE_RISING |
> > +					  V4L2_MBUS_DATA_ACTIVE_HIGH;
> >  		cfg->type = V4L2_MBUS_BT656;
> >  	}
> >
> > diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c
> > index 589e9644fcdc..bd4f3fe0e309 100644
> > --- a/drivers/media/i2c/adv748x/adv748x-csi2.c
> > +++ b/drivers/media/i2c/adv748x/adv748x-csi2.c
> > @@ -222,23 +222,7 @@ static int adv748x_csi2_get_mbus_config(struct v4l2_subdev *sd, unsigned int pad
> >  		return -EINVAL;
> >
> >  	config->type = V4L2_MBUS_CSI2_DPHY;
> > -	switch (tx->active_lanes) {
> > -	case 1:
> > -		config->flags = V4L2_MBUS_CSI2_1_LANE;
> > -		break;
> > -
> > -	case 2:
> > -		config->flags = V4L2_MBUS_CSI2_2_LANE;
> > -		break;
> > -
> > -	case 3:
> > -		config->flags = V4L2_MBUS_CSI2_3_LANE;
> > -		break;
> > -
> > -	case 4:
> > -		config->flags = V4L2_MBUS_CSI2_4_LANE;
> > -		break;
> > -	}
> > +	config->bus.mipi_csi2.num_data_lanes = tx->active_lanes;
> >
> >  	return 0;
> >  }
> > diff --git a/drivers/media/i2c/ml86v7667.c b/drivers/media/i2c/ml86v7667.c
> > index 4a1410ebb4c8..48cc0b0922f4 100644
> > --- a/drivers/media/i2c/ml86v7667.c
> > +++ b/drivers/media/i2c/ml86v7667.c
> > @@ -223,9 +223,10 @@ static int ml86v7667_get_mbus_config(struct v4l2_subdev *sd,
> >  				     unsigned int pad,
> >  				     struct v4l2_mbus_config *cfg)
> >  {
> > -	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
> > -		     V4L2_MBUS_DATA_ACTIVE_HIGH;
> >  	cfg->type = V4L2_MBUS_BT656;
> > +	cfg->bus.parallel.flags = V4L2_MBUS_MASTER |
> > +				  V4L2_MBUS_PCLK_SAMPLE_RISING |
> > +				  V4L2_MBUS_DATA_ACTIVE_HIGH;
> >
> >  	return 0;
> >  }
> > diff --git a/drivers/media/i2c/mt9m001.c b/drivers/media/i2c/mt9m001.c
> > index c9f0bd997ea7..ad13b0c890c0 100644
> > --- a/drivers/media/i2c/mt9m001.c
> > +++ b/drivers/media/i2c/mt9m001.c
> > @@ -695,10 +695,12 @@ static int mt9m001_get_mbus_config(struct v4l2_subdev *sd,
> >  				   struct v4l2_mbus_config *cfg)
> >  {
> >  	/* MT9M001 has all capture_format parameters fixed */
> > -	cfg->flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
> > -		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> > -		V4L2_MBUS_DATA_ACTIVE_HIGH | V4L2_MBUS_MASTER;
> >  	cfg->type = V4L2_MBUS_PARALLEL;
> > +	cfg->bus.parallel.flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
> > +				  V4L2_MBUS_HSYNC_ACTIVE_HIGH |
> > +				  V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> > +				  V4L2_MBUS_DATA_ACTIVE_HIGH |
> > +				  V4L2_MBUS_MASTER;
> >
> >  	return 0;
> >  }
> > diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
> > index 91a44359bcd3..6cf3ccf85d27 100644
> > --- a/drivers/media/i2c/mt9m111.c
> > +++ b/drivers/media/i2c/mt9m111.c
> > @@ -1143,15 +1143,17 @@ static int mt9m111_get_mbus_config(struct v4l2_subdev *sd,
> >  {
> >  	struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev);
> >
> > -	cfg->flags = V4L2_MBUS_MASTER |
> > -		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> > -		V4L2_MBUS_DATA_ACTIVE_HIGH;
> > -
> > -	cfg->flags |= mt9m111->pclk_sample ? V4L2_MBUS_PCLK_SAMPLE_RISING :
> > -		V4L2_MBUS_PCLK_SAMPLE_FALLING;
> > -
> >  	cfg->type = V4L2_MBUS_PARALLEL;
> >
> > +	cfg->bus.parallel.flags = V4L2_MBUS_MASTER |
> > +				  V4L2_MBUS_HSYNC_ACTIVE_HIGH |
> > +				  V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> > +				  V4L2_MBUS_DATA_ACTIVE_HIGH;
> > +
> > +	cfg->bus.parallel.flags |= mt9m111->pclk_sample ?
> > +				   V4L2_MBUS_PCLK_SAMPLE_RISING :
> > +				   V4L2_MBUS_PCLK_SAMPLE_FALLING;
> > +
> >  	return 0;
> >  }
> >
> > diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
> > index 455a627e35a0..b2654b32bc62 100644
> > --- a/drivers/media/i2c/ov6650.c
> > +++ b/drivers/media/i2c/ov6650.c
> > @@ -932,15 +932,15 @@ static int ov6650_get_mbus_config(struct v4l2_subdev *sd,
> >  	if (ret)
> >  		return ret;
> >
> > -	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_DATA_ACTIVE_HIGH
> > -		   | ((comj & COMJ_VSYNC_HIGH)  ? V4L2_MBUS_VSYNC_ACTIVE_HIGH
> > -						: V4L2_MBUS_VSYNC_ACTIVE_LOW)
> > -		   | ((comf & COMF_HREF_LOW)    ? V4L2_MBUS_HSYNC_ACTIVE_LOW
> > -						: V4L2_MBUS_HSYNC_ACTIVE_HIGH)
> > -		   | ((comj & COMJ_PCLK_RISING) ? V4L2_MBUS_PCLK_SAMPLE_RISING
> > -						: V4L2_MBUS_PCLK_SAMPLE_FALLING);
> >  	cfg->type = V4L2_MBUS_PARALLEL;
> >
> > +	cfg->bus.parallel.flags = V4L2_MBUS_MASTER | V4L2_MBUS_DATA_ACTIVE_HIGH
> > +		| ((comj & COMJ_VSYNC_HIGH)  ? V4L2_MBUS_VSYNC_ACTIVE_HIGH
> > +					     : V4L2_MBUS_VSYNC_ACTIVE_LOW)
> > +		| ((comf & COMF_HREF_LOW)    ? V4L2_MBUS_HSYNC_ACTIVE_LOW
> > +					     : V4L2_MBUS_HSYNC_ACTIVE_HIGH)
> > +		| ((comj & COMJ_PCLK_RISING) ? V4L2_MBUS_PCLK_SAMPLE_RISING
> > +					     : V4L2_MBUS_PCLK_SAMPLE_FALLING);
> >  	return 0;
> >  }
> >
> > diff --git a/drivers/media/i2c/ov9640.c b/drivers/media/i2c/ov9640.c
> > index 0bab8c2cf160..9f44ed52d164 100644
> > --- a/drivers/media/i2c/ov9640.c
> > +++ b/drivers/media/i2c/ov9640.c
> > @@ -652,10 +652,12 @@ static int ov9640_get_mbus_config(struct v4l2_subdev *sd,
> >  				  unsigned int pad,
> >  				  struct v4l2_mbus_config *cfg)
> >  {
> > -	cfg->flags = V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_MASTER |
> > -		V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
> > -		V4L2_MBUS_DATA_ACTIVE_HIGH;
> >  	cfg->type = V4L2_MBUS_PARALLEL;
> > +	cfg->bus.parallel.flags = V4L2_MBUS_PCLK_SAMPLE_RISING |
> > +				  V4L2_MBUS_MASTER |
> > +				  V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> > +				  V4L2_MBUS_HSYNC_ACTIVE_HIGH |
> > +				  V4L2_MBUS_DATA_ACTIVE_HIGH;
> >
> >  	return 0;
> >  }
> > diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
> > index 40512004afba..dfbc42675143 100644
> > --- a/drivers/media/i2c/tc358743.c
> > +++ b/drivers/media/i2c/tc358743.c
> > @@ -1613,24 +1613,8 @@ static int tc358743_get_mbus_config(struct v4l2_subdev *sd,
> >  	cfg->type = V4L2_MBUS_CSI2_DPHY;
> >
> >  	/* Support for non-continuous CSI-2 clock is missing in the driver */
> > -	cfg->flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > -
> > -	switch (state->csi_lanes_in_use) {
> > -	case 1:
> > -		cfg->flags |= V4L2_MBUS_CSI2_1_LANE;
> > -		break;
> > -	case 2:
> > -		cfg->flags |= V4L2_MBUS_CSI2_2_LANE;
> > -		break;
> > -	case 3:
> > -		cfg->flags |= V4L2_MBUS_CSI2_3_LANE;
> > -		break;
> > -	case 4:
> > -		cfg->flags |= V4L2_MBUS_CSI2_4_LANE;
> > -		break;
> > -	default:
> > -		return -EINVAL;
> > -	}
> > +	cfg->bus.mipi_csi2.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > +	cfg->bus.mipi_csi2.num_data_lanes = state->csi_lanes_in_use;
> >
> >  	return 0;
> >  }
> > diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
> > index 4b16ffcaef98..65472438444b 100644
> > --- a/drivers/media/i2c/tvp5150.c
> > +++ b/drivers/media/i2c/tvp5150.c
> > @@ -1198,8 +1198,10 @@ static int tvp5150_get_mbus_config(struct v4l2_subdev *sd,
> >  	struct tvp5150 *decoder = to_tvp5150(sd);
> >
> >  	cfg->type = decoder->mbus_type;
> > -	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING
> > -		   | V4L2_MBUS_FIELD_EVEN_LOW | V4L2_MBUS_DATA_ACTIVE_HIGH;
> > +	cfg->bus.parallel.flags = V4L2_MBUS_MASTER
> > +				| V4L2_MBUS_PCLK_SAMPLE_RISING
> > +				| V4L2_MBUS_FIELD_EVEN_LOW
> > +				| V4L2_MBUS_DATA_ACTIVE_HIGH;
> >
> >  	return 0;
> >  }
> > diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
> > index b5644cf37fe9..35145e3348f0 100644
> > --- a/drivers/media/platform/pxa_camera.c
> > +++ b/drivers/media/platform/pxa_camera.c
> > @@ -1587,24 +1587,26 @@ static int pxa_camera_set_bus_param(struct pxa_camera_dev *pcdev)
> >  	 * PXA does not support V4L2_MBUS_DATA_ACTIVE_LOW and the bus mastering
> >  	 * roles should match.
> >  	 */
> > -	if (cfg.flags != mbus_config) {
> > +	if (cfg.bus.parallel.flags != mbus_config) {
> >  		unsigned int pxa_mbus_role = mbus_config & (V4L2_MBUS_MASTER |
> >  							    V4L2_MBUS_SLAVE);
> > -		if (pxa_mbus_role != (cfg.flags & (V4L2_MBUS_MASTER |
> > -						   V4L2_MBUS_SLAVE))) {
> > +		unsigned int flags = cfg.bus.parallel.flags;
> > +
> > +		if (pxa_mbus_role != (flags & (V4L2_MBUS_MASTER |
> > +					       V4L2_MBUS_SLAVE))) {
> >  			dev_err(pcdev_to_dev(pcdev),
> >  				"Unsupported mbus configuration: bus mastering\n");
> >  			return -EINVAL;
> >  		}
> >
> > -		if (cfg.flags & V4L2_MBUS_DATA_ACTIVE_LOW) {
> > +		if (flags & V4L2_MBUS_DATA_ACTIVE_LOW) {
> >  			dev_err(pcdev_to_dev(pcdev),
> >  				"Unsupported mbus configuration: DATA_ACTIVE_LOW\n");
> >  			return -EINVAL;
> >  		}
> >  	}
> >
> > -	pxa_camera_setup_cicr(pcdev, cfg.flags, pixfmt);
> > +	pxa_camera_setup_cicr(pcdev, cfg.bus.parallel.flags, pixfmt);
> >
> >  	return 0;
> >  }
> > diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
> > index 8c939cb3073d..cbac5801720b 100644
> > --- a/drivers/media/platform/rcar-vin/rcar-csi2.c
> > +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
> > @@ -603,7 +603,6 @@ static int rcsi2_get_active_lanes(struct rcar_csi2 *priv,
> >  				  unsigned int *lanes)
> >  {
> >  	struct v4l2_mbus_config mbus_config = { 0 };
> > -	unsigned int num_lanes = UINT_MAX;
> >  	int ret;
> >
> >  	*lanes = priv->lanes;
> > @@ -626,23 +625,14 @@ static int rcsi2_get_active_lanes(struct rcar_csi2 *priv,
> >  		return -EINVAL;
> >  	}
> >
> > -	if (mbus_config.flags & V4L2_MBUS_CSI2_1_LANE)
> > -		num_lanes = 1;
> > -	else if (mbus_config.flags & V4L2_MBUS_CSI2_2_LANE)
> > -		num_lanes = 2;
> > -	else if (mbus_config.flags & V4L2_MBUS_CSI2_3_LANE)
> > -		num_lanes = 3;
> > -	else if (mbus_config.flags & V4L2_MBUS_CSI2_4_LANE)
> > -		num_lanes = 4;
> > -
> > -	if (num_lanes > priv->lanes) {
> > +	if (mbus_config.bus.mipi_csi2.num_data_lanes > priv->lanes) {
> >  		dev_err(priv->dev,
> >  			"Unsupported mbus config: too many data lanes %u\n",
> > -			num_lanes);
> > +			mbus_config.bus.mipi_csi2.num_data_lanes);
> >  		return -EINVAL;
> >  	}
> >
> > -	*lanes = num_lanes;
> > +	*lanes = mbus_config.bus.mipi_csi2.num_data_lanes;
> >
> >  	return 0;
> >  }
> > diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c
> > index bd7f156f2d52..b2b1f4dd41d7 100644
> > --- a/drivers/staging/media/imx/imx-media-csi.c
> > +++ b/drivers/staging/media/imx/imx-media-csi.c
> > @@ -718,9 +718,10 @@ static int csi_setup(struct csi_priv *priv)
> >
> >  	/* compose mbus_config from the upstream endpoint */
> >  	mbus_cfg.type = priv->upstream_ep.bus_type;
> > -	mbus_cfg.flags = is_parallel_bus(&priv->upstream_ep) ?
> > -		priv->upstream_ep.bus.parallel.flags :
> > -		priv->upstream_ep.bus.mipi_csi2.flags;
> > +	if (is_parallel_bus(&priv->upstream_ep))
> > +		mbus_cfg.bus.parallel = priv->upstream_ep.bus.parallel;
> > +	else
> > +		mbus_cfg.bus.mipi_csi2 = priv->upstream_ep.bus.mipi_csi2;
> >
> >  	if_fmt = *infmt;
> >  	crop = priv->crop;
> > diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c
> > index 558b256ac935..c4cb558a85c6 100644
> > --- a/drivers/staging/media/imx/imx6-mipi-csi2.c
> > +++ b/drivers/staging/media/imx/imx6-mipi-csi2.c
> > @@ -303,7 +303,6 @@ static void csi2ipu_gasket_init(struct csi2_dev *csi2)
> >  static int csi2_get_active_lanes(struct csi2_dev *csi2, unsigned int *lanes)
> >  {
> >  	struct v4l2_mbus_config mbus_config = { 0 };
> > -	unsigned int num_lanes = UINT_MAX;
> >  	int ret;
> >
> >  	*lanes = csi2->data_lanes;
> > @@ -326,32 +325,14 @@ static int csi2_get_active_lanes(struct csi2_dev *csi2, unsigned int *lanes)
> >  		return -EINVAL;
> >  	}
> >
> > -	switch (mbus_config.flags & V4L2_MBUS_CSI2_LANES) {
> > -	case V4L2_MBUS_CSI2_1_LANE:
> > -		num_lanes = 1;
> > -		break;
> > -	case V4L2_MBUS_CSI2_2_LANE:
> > -		num_lanes = 2;
> > -		break;
> > -	case V4L2_MBUS_CSI2_3_LANE:
> > -		num_lanes = 3;
> > -		break;
> > -	case V4L2_MBUS_CSI2_4_LANE:
> > -		num_lanes = 4;
> > -		break;
> > -	default:
> > -		num_lanes = csi2->data_lanes;
> > -		break;
> > -	}
> > -
> > -	if (num_lanes > csi2->data_lanes) {
> > +	if (mbus_config.bus.mipi_csi2.num_data_lanes > csi2->data_lanes) {
> >  		dev_err(csi2->dev,
> >  			"Unsupported mbus config: too many data lanes %u\n",
> > -			num_lanes);
> > +			mbus_config.bus.mipi_csi2.num_data_lanes);
> >  		return -EINVAL;
> >  	}
> >
> > -	*lanes = num_lanes;
> > +	*lanes = mbus_config.bus.mipi_csi2.num_data_lanes;
> >
> >  	return 0;
> >  }
> > diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
> > index 9c4970fbd8ea..269aaf57ba32 100644
> > --- a/include/media/v4l2-mediabus.h
> > +++ b/include/media/v4l2-mediabus.h
> > @@ -166,12 +166,26 @@ enum v4l2_mbus_type {
> >
> >  /**
> >   * struct v4l2_mbus_config - media bus configuration
> > - * @type:	in: interface type
> > - * @flags:	in / out: configuration flags, depending on @type
> > + * @type: interface type
> > + * @bus: bus configuration data structure
> > + * @bus.parallel: embedded &struct v4l2_mbus_config_parallel.
> > + *		  Used if the bus is parallel or BT.656.
> > + * @bus.mipi_csi1: embedded &struct v4l2_mbus_config_mipi_csi1.
> > + *		   Used if the bus is MIPI Alliance's Camera Serial
> > + *		   Interface version 1 (MIPI CSI1) or Standard
> > + *		   Mobile Imaging Architecture's Compact Camera Port 2
> > + *		   (SMIA CCP2).
> > + * @bus.mipi_csi2: embedded &struct v4l2_mbus_config_mipi_csi2.
> > + *		   Used if the bus is MIPI Alliance's Camera Serial
> > + *		   Interface version 2 (MIPI CSI2).
> >   */
> >  struct v4l2_mbus_config {
> >  	enum v4l2_mbus_type type;
> > -	unsigned int flags;
> > +	union {
> > +		struct v4l2_mbus_config_parallel parallel;
> > +		struct v4l2_mbus_config_mipi_csi1 mipi_csi1;
> > +		struct v4l2_mbus_config_mipi_csi2 mipi_csi2;
> 
> I wonder if we would be able to use a single structure for D-PHY and
> C-PHY. The clock lane index does not make much sense for the latter,
> but it was already there, so it can be changed on top in case it is
> required

I'm not sure to follow you here. CSI1 and CSI2 are not D-PHY versus
C-PHY.

> Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> 
> > +	} bus;
> >  };
> >
> >  /**

-- 
Regards,

Laurent Pinchart

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

* Re: [RFC PATCH 5/8] media: v4l2-mediabus: Use structures to describe bus configuration
  2022-02-15 11:15     ` Laurent Pinchart
@ 2022-02-15 11:28       ` Jacopo Mondi
  2022-02-15 11:32         ` Laurent Pinchart
  0 siblings, 1 reply; 36+ messages in thread
From: Jacopo Mondi @ 2022-02-15 11:28 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-media, linux-renesas-soc, Sakari Ailus, Hans Verkuil,
	Kieran Bingham, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik, Philipp Zabel, Lars-Peter Clausen, Petr Cvek,
	Mats Randgaard, Steve Longerbeam, Shawn Guo, Sascha Hauer

On Tue, Feb 15, 2022 at 01:15:40PM +0200, Laurent Pinchart wrote:
> Hi Jacopo,
>
> On Tue, Feb 15, 2022 at 12:13:16PM +0100, Jacopo Mondi wrote:
> > On Mon, Jan 03, 2022 at 06:24:11PM +0200, Laurent Pinchart wrote:
> > > The media bus configuration is specified through a set of flags, some of
> > > which being mutually exclusive. This doesn't scale to express more
> > > complex configurations. Improve the API by replacing the single flags
> > > field in v4l2_mbus_config by a union of v4l2_mbus_config_* structures.
> > > The flags themselves are still used in those structures, so they are
> > > kept here. Drivers are however updated to use structure fields instead
> > > of flags when already possible.
> > >
> > > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > > ---
> > >  drivers/gpu/ipu-v3/ipu-csi.c                |  6 ++---
> > >  drivers/media/i2c/adv7180.c                 |  8 ++++---
> > >  drivers/media/i2c/adv748x/adv748x-csi2.c    | 18 +--------------
> > >  drivers/media/i2c/ml86v7667.c               |  5 +++--
> > >  drivers/media/i2c/mt9m001.c                 |  8 ++++---
> > >  drivers/media/i2c/mt9m111.c                 | 16 +++++++------
> > >  drivers/media/i2c/ov6650.c                  | 14 ++++++------
> > >  drivers/media/i2c/ov9640.c                  |  8 ++++---
> > >  drivers/media/i2c/tc358743.c                | 20 ++---------------
> > >  drivers/media/i2c/tvp5150.c                 |  6 +++--
> > >  drivers/media/platform/pxa_camera.c         | 12 +++++-----
> > >  drivers/media/platform/rcar-vin/rcar-csi2.c | 16 +++----------
> > >  drivers/staging/media/imx/imx-media-csi.c   |  7 +++---
> > >  drivers/staging/media/imx/imx6-mipi-csi2.c  | 25 +++------------------
> >
> > drivers conversions looks good to me
> >
> > >  include/media/v4l2-mediabus.h               | 20 ++++++++++++++---
> > >  15 files changed, 78 insertions(+), 111 deletions(-)
> > >
> > > diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
> > > index a9639d098893..778bc26d3ba5 100644
> > > --- a/drivers/gpu/ipu-v3/ipu-csi.c
> > > +++ b/drivers/gpu/ipu-v3/ipu-csi.c
> > > @@ -357,11 +357,11 @@ static int fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
> > >  	switch (mbus_cfg->type) {
> > >  	case V4L2_MBUS_PARALLEL:
> > >  		csicfg->ext_vsync = 1;
> > > -		csicfg->vsync_pol = (mbus_cfg->flags &
> > > +		csicfg->vsync_pol = (mbus_cfg->bus.parallel.flags &
> > >  				     V4L2_MBUS_VSYNC_ACTIVE_LOW) ? 1 : 0;
> > > -		csicfg->hsync_pol = (mbus_cfg->flags &
> > > +		csicfg->hsync_pol = (mbus_cfg->bus.parallel.flags &
> > >  				     V4L2_MBUS_HSYNC_ACTIVE_LOW) ? 1 : 0;
> > > -		csicfg->pixclk_pol = (mbus_cfg->flags &
> > > +		csicfg->pixclk_pol = (mbus_cfg->bus.parallel.flags &
> > >  				      V4L2_MBUS_PCLK_SAMPLE_FALLING) ? 1 : 0;
> > >  		csicfg->clk_mode = IPU_CSI_CLK_MODE_GATED_CLK;
> > >  		break;
> > > diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
> > > index d9a99fcfacb1..286f5017d9c3 100644
> > > --- a/drivers/media/i2c/adv7180.c
> > > +++ b/drivers/media/i2c/adv7180.c
> > > @@ -784,7 +784,8 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
> > >
> > >  	if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
> > >  		cfg->type = V4L2_MBUS_CSI2_DPHY;
> > > -		cfg->flags = V4L2_MBUS_CSI2_1_LANE |
> > > +		cfg->bus.mipi_csi2.num_data_lanes = 1;
> > > +		cfg->bus.mipi_csi2.flags =
> > >  				V4L2_MBUS_CSI2_CHANNEL_0 |
> > >  				V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > >  	} else {
> > > @@ -792,8 +793,9 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
> > >  		 * The ADV7180 sensor supports BT.601/656 output modes.
> > >  		 * The BT.656 is default and not yet configurable by s/w.
> > >  		 */
> > > -		cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
> > > -				 V4L2_MBUS_DATA_ACTIVE_HIGH;
> > > +		cfg->bus.parallel.flags = V4L2_MBUS_MASTER |
> > > +					  V4L2_MBUS_PCLK_SAMPLE_RISING |
> > > +					  V4L2_MBUS_DATA_ACTIVE_HIGH;
> > >  		cfg->type = V4L2_MBUS_BT656;
> > >  	}
> > >
> > > diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c
> > > index 589e9644fcdc..bd4f3fe0e309 100644
> > > --- a/drivers/media/i2c/adv748x/adv748x-csi2.c
> > > +++ b/drivers/media/i2c/adv748x/adv748x-csi2.c
> > > @@ -222,23 +222,7 @@ static int adv748x_csi2_get_mbus_config(struct v4l2_subdev *sd, unsigned int pad
> > >  		return -EINVAL;
> > >
> > >  	config->type = V4L2_MBUS_CSI2_DPHY;
> > > -	switch (tx->active_lanes) {
> > > -	case 1:
> > > -		config->flags = V4L2_MBUS_CSI2_1_LANE;
> > > -		break;
> > > -
> > > -	case 2:
> > > -		config->flags = V4L2_MBUS_CSI2_2_LANE;
> > > -		break;
> > > -
> > > -	case 3:
> > > -		config->flags = V4L2_MBUS_CSI2_3_LANE;
> > > -		break;
> > > -
> > > -	case 4:
> > > -		config->flags = V4L2_MBUS_CSI2_4_LANE;
> > > -		break;
> > > -	}
> > > +	config->bus.mipi_csi2.num_data_lanes = tx->active_lanes;
> > >
> > >  	return 0;
> > >  }
> > > diff --git a/drivers/media/i2c/ml86v7667.c b/drivers/media/i2c/ml86v7667.c
> > > index 4a1410ebb4c8..48cc0b0922f4 100644
> > > --- a/drivers/media/i2c/ml86v7667.c
> > > +++ b/drivers/media/i2c/ml86v7667.c
> > > @@ -223,9 +223,10 @@ static int ml86v7667_get_mbus_config(struct v4l2_subdev *sd,
> > >  				     unsigned int pad,
> > >  				     struct v4l2_mbus_config *cfg)
> > >  {
> > > -	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
> > > -		     V4L2_MBUS_DATA_ACTIVE_HIGH;
> > >  	cfg->type = V4L2_MBUS_BT656;
> > > +	cfg->bus.parallel.flags = V4L2_MBUS_MASTER |
> > > +				  V4L2_MBUS_PCLK_SAMPLE_RISING |
> > > +				  V4L2_MBUS_DATA_ACTIVE_HIGH;
> > >
> > >  	return 0;
> > >  }
> > > diff --git a/drivers/media/i2c/mt9m001.c b/drivers/media/i2c/mt9m001.c
> > > index c9f0bd997ea7..ad13b0c890c0 100644
> > > --- a/drivers/media/i2c/mt9m001.c
> > > +++ b/drivers/media/i2c/mt9m001.c
> > > @@ -695,10 +695,12 @@ static int mt9m001_get_mbus_config(struct v4l2_subdev *sd,
> > >  				   struct v4l2_mbus_config *cfg)
> > >  {
> > >  	/* MT9M001 has all capture_format parameters fixed */
> > > -	cfg->flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
> > > -		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> > > -		V4L2_MBUS_DATA_ACTIVE_HIGH | V4L2_MBUS_MASTER;
> > >  	cfg->type = V4L2_MBUS_PARALLEL;
> > > +	cfg->bus.parallel.flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
> > > +				  V4L2_MBUS_HSYNC_ACTIVE_HIGH |
> > > +				  V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> > > +				  V4L2_MBUS_DATA_ACTIVE_HIGH |
> > > +				  V4L2_MBUS_MASTER;
> > >
> > >  	return 0;
> > >  }
> > > diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
> > > index 91a44359bcd3..6cf3ccf85d27 100644
> > > --- a/drivers/media/i2c/mt9m111.c
> > > +++ b/drivers/media/i2c/mt9m111.c
> > > @@ -1143,15 +1143,17 @@ static int mt9m111_get_mbus_config(struct v4l2_subdev *sd,
> > >  {
> > >  	struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev);
> > >
> > > -	cfg->flags = V4L2_MBUS_MASTER |
> > > -		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> > > -		V4L2_MBUS_DATA_ACTIVE_HIGH;
> > > -
> > > -	cfg->flags |= mt9m111->pclk_sample ? V4L2_MBUS_PCLK_SAMPLE_RISING :
> > > -		V4L2_MBUS_PCLK_SAMPLE_FALLING;
> > > -
> > >  	cfg->type = V4L2_MBUS_PARALLEL;
> > >
> > > +	cfg->bus.parallel.flags = V4L2_MBUS_MASTER |
> > > +				  V4L2_MBUS_HSYNC_ACTIVE_HIGH |
> > > +				  V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> > > +				  V4L2_MBUS_DATA_ACTIVE_HIGH;
> > > +
> > > +	cfg->bus.parallel.flags |= mt9m111->pclk_sample ?
> > > +				   V4L2_MBUS_PCLK_SAMPLE_RISING :
> > > +				   V4L2_MBUS_PCLK_SAMPLE_FALLING;
> > > +
> > >  	return 0;
> > >  }
> > >
> > > diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
> > > index 455a627e35a0..b2654b32bc62 100644
> > > --- a/drivers/media/i2c/ov6650.c
> > > +++ b/drivers/media/i2c/ov6650.c
> > > @@ -932,15 +932,15 @@ static int ov6650_get_mbus_config(struct v4l2_subdev *sd,
> > >  	if (ret)
> > >  		return ret;
> > >
> > > -	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_DATA_ACTIVE_HIGH
> > > -		   | ((comj & COMJ_VSYNC_HIGH)  ? V4L2_MBUS_VSYNC_ACTIVE_HIGH
> > > -						: V4L2_MBUS_VSYNC_ACTIVE_LOW)
> > > -		   | ((comf & COMF_HREF_LOW)    ? V4L2_MBUS_HSYNC_ACTIVE_LOW
> > > -						: V4L2_MBUS_HSYNC_ACTIVE_HIGH)
> > > -		   | ((comj & COMJ_PCLK_RISING) ? V4L2_MBUS_PCLK_SAMPLE_RISING
> > > -						: V4L2_MBUS_PCLK_SAMPLE_FALLING);
> > >  	cfg->type = V4L2_MBUS_PARALLEL;
> > >
> > > +	cfg->bus.parallel.flags = V4L2_MBUS_MASTER | V4L2_MBUS_DATA_ACTIVE_HIGH
> > > +		| ((comj & COMJ_VSYNC_HIGH)  ? V4L2_MBUS_VSYNC_ACTIVE_HIGH
> > > +					     : V4L2_MBUS_VSYNC_ACTIVE_LOW)
> > > +		| ((comf & COMF_HREF_LOW)    ? V4L2_MBUS_HSYNC_ACTIVE_LOW
> > > +					     : V4L2_MBUS_HSYNC_ACTIVE_HIGH)
> > > +		| ((comj & COMJ_PCLK_RISING) ? V4L2_MBUS_PCLK_SAMPLE_RISING
> > > +					     : V4L2_MBUS_PCLK_SAMPLE_FALLING);
> > >  	return 0;
> > >  }
> > >
> > > diff --git a/drivers/media/i2c/ov9640.c b/drivers/media/i2c/ov9640.c
> > > index 0bab8c2cf160..9f44ed52d164 100644
> > > --- a/drivers/media/i2c/ov9640.c
> > > +++ b/drivers/media/i2c/ov9640.c
> > > @@ -652,10 +652,12 @@ static int ov9640_get_mbus_config(struct v4l2_subdev *sd,
> > >  				  unsigned int pad,
> > >  				  struct v4l2_mbus_config *cfg)
> > >  {
> > > -	cfg->flags = V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_MASTER |
> > > -		V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
> > > -		V4L2_MBUS_DATA_ACTIVE_HIGH;
> > >  	cfg->type = V4L2_MBUS_PARALLEL;
> > > +	cfg->bus.parallel.flags = V4L2_MBUS_PCLK_SAMPLE_RISING |
> > > +				  V4L2_MBUS_MASTER |
> > > +				  V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> > > +				  V4L2_MBUS_HSYNC_ACTIVE_HIGH |
> > > +				  V4L2_MBUS_DATA_ACTIVE_HIGH;
> > >
> > >  	return 0;
> > >  }
> > > diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
> > > index 40512004afba..dfbc42675143 100644
> > > --- a/drivers/media/i2c/tc358743.c
> > > +++ b/drivers/media/i2c/tc358743.c
> > > @@ -1613,24 +1613,8 @@ static int tc358743_get_mbus_config(struct v4l2_subdev *sd,
> > >  	cfg->type = V4L2_MBUS_CSI2_DPHY;
> > >
> > >  	/* Support for non-continuous CSI-2 clock is missing in the driver */
> > > -	cfg->flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > > -
> > > -	switch (state->csi_lanes_in_use) {
> > > -	case 1:
> > > -		cfg->flags |= V4L2_MBUS_CSI2_1_LANE;
> > > -		break;
> > > -	case 2:
> > > -		cfg->flags |= V4L2_MBUS_CSI2_2_LANE;
> > > -		break;
> > > -	case 3:
> > > -		cfg->flags |= V4L2_MBUS_CSI2_3_LANE;
> > > -		break;
> > > -	case 4:
> > > -		cfg->flags |= V4L2_MBUS_CSI2_4_LANE;
> > > -		break;
> > > -	default:
> > > -		return -EINVAL;
> > > -	}
> > > +	cfg->bus.mipi_csi2.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > > +	cfg->bus.mipi_csi2.num_data_lanes = state->csi_lanes_in_use;
> > >
> > >  	return 0;
> > >  }
> > > diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
> > > index 4b16ffcaef98..65472438444b 100644
> > > --- a/drivers/media/i2c/tvp5150.c
> > > +++ b/drivers/media/i2c/tvp5150.c
> > > @@ -1198,8 +1198,10 @@ static int tvp5150_get_mbus_config(struct v4l2_subdev *sd,
> > >  	struct tvp5150 *decoder = to_tvp5150(sd);
> > >
> > >  	cfg->type = decoder->mbus_type;
> > > -	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING
> > > -		   | V4L2_MBUS_FIELD_EVEN_LOW | V4L2_MBUS_DATA_ACTIVE_HIGH;
> > > +	cfg->bus.parallel.flags = V4L2_MBUS_MASTER
> > > +				| V4L2_MBUS_PCLK_SAMPLE_RISING
> > > +				| V4L2_MBUS_FIELD_EVEN_LOW
> > > +				| V4L2_MBUS_DATA_ACTIVE_HIGH;
> > >
> > >  	return 0;
> > >  }
> > > diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
> > > index b5644cf37fe9..35145e3348f0 100644
> > > --- a/drivers/media/platform/pxa_camera.c
> > > +++ b/drivers/media/platform/pxa_camera.c
> > > @@ -1587,24 +1587,26 @@ static int pxa_camera_set_bus_param(struct pxa_camera_dev *pcdev)
> > >  	 * PXA does not support V4L2_MBUS_DATA_ACTIVE_LOW and the bus mastering
> > >  	 * roles should match.
> > >  	 */
> > > -	if (cfg.flags != mbus_config) {
> > > +	if (cfg.bus.parallel.flags != mbus_config) {
> > >  		unsigned int pxa_mbus_role = mbus_config & (V4L2_MBUS_MASTER |
> > >  							    V4L2_MBUS_SLAVE);
> > > -		if (pxa_mbus_role != (cfg.flags & (V4L2_MBUS_MASTER |
> > > -						   V4L2_MBUS_SLAVE))) {
> > > +		unsigned int flags = cfg.bus.parallel.flags;
> > > +
> > > +		if (pxa_mbus_role != (flags & (V4L2_MBUS_MASTER |
> > > +					       V4L2_MBUS_SLAVE))) {
> > >  			dev_err(pcdev_to_dev(pcdev),
> > >  				"Unsupported mbus configuration: bus mastering\n");
> > >  			return -EINVAL;
> > >  		}
> > >
> > > -		if (cfg.flags & V4L2_MBUS_DATA_ACTIVE_LOW) {
> > > +		if (flags & V4L2_MBUS_DATA_ACTIVE_LOW) {
> > >  			dev_err(pcdev_to_dev(pcdev),
> > >  				"Unsupported mbus configuration: DATA_ACTIVE_LOW\n");
> > >  			return -EINVAL;
> > >  		}
> > >  	}
> > >
> > > -	pxa_camera_setup_cicr(pcdev, cfg.flags, pixfmt);
> > > +	pxa_camera_setup_cicr(pcdev, cfg.bus.parallel.flags, pixfmt);
> > >
> > >  	return 0;
> > >  }
> > > diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
> > > index 8c939cb3073d..cbac5801720b 100644
> > > --- a/drivers/media/platform/rcar-vin/rcar-csi2.c
> > > +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
> > > @@ -603,7 +603,6 @@ static int rcsi2_get_active_lanes(struct rcar_csi2 *priv,
> > >  				  unsigned int *lanes)
> > >  {
> > >  	struct v4l2_mbus_config mbus_config = { 0 };
> > > -	unsigned int num_lanes = UINT_MAX;
> > >  	int ret;
> > >
> > >  	*lanes = priv->lanes;
> > > @@ -626,23 +625,14 @@ static int rcsi2_get_active_lanes(struct rcar_csi2 *priv,
> > >  		return -EINVAL;
> > >  	}
> > >
> > > -	if (mbus_config.flags & V4L2_MBUS_CSI2_1_LANE)
> > > -		num_lanes = 1;
> > > -	else if (mbus_config.flags & V4L2_MBUS_CSI2_2_LANE)
> > > -		num_lanes = 2;
> > > -	else if (mbus_config.flags & V4L2_MBUS_CSI2_3_LANE)
> > > -		num_lanes = 3;
> > > -	else if (mbus_config.flags & V4L2_MBUS_CSI2_4_LANE)
> > > -		num_lanes = 4;
> > > -
> > > -	if (num_lanes > priv->lanes) {
> > > +	if (mbus_config.bus.mipi_csi2.num_data_lanes > priv->lanes) {
> > >  		dev_err(priv->dev,
> > >  			"Unsupported mbus config: too many data lanes %u\n",
> > > -			num_lanes);
> > > +			mbus_config.bus.mipi_csi2.num_data_lanes);
> > >  		return -EINVAL;
> > >  	}
> > >
> > > -	*lanes = num_lanes;
> > > +	*lanes = mbus_config.bus.mipi_csi2.num_data_lanes;
> > >
> > >  	return 0;
> > >  }
> > > diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c
> > > index bd7f156f2d52..b2b1f4dd41d7 100644
> > > --- a/drivers/staging/media/imx/imx-media-csi.c
> > > +++ b/drivers/staging/media/imx/imx-media-csi.c
> > > @@ -718,9 +718,10 @@ static int csi_setup(struct csi_priv *priv)
> > >
> > >  	/* compose mbus_config from the upstream endpoint */
> > >  	mbus_cfg.type = priv->upstream_ep.bus_type;
> > > -	mbus_cfg.flags = is_parallel_bus(&priv->upstream_ep) ?
> > > -		priv->upstream_ep.bus.parallel.flags :
> > > -		priv->upstream_ep.bus.mipi_csi2.flags;
> > > +	if (is_parallel_bus(&priv->upstream_ep))
> > > +		mbus_cfg.bus.parallel = priv->upstream_ep.bus.parallel;
> > > +	else
> > > +		mbus_cfg.bus.mipi_csi2 = priv->upstream_ep.bus.mipi_csi2;
> > >
> > >  	if_fmt = *infmt;
> > >  	crop = priv->crop;
> > > diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c
> > > index 558b256ac935..c4cb558a85c6 100644
> > > --- a/drivers/staging/media/imx/imx6-mipi-csi2.c
> > > +++ b/drivers/staging/media/imx/imx6-mipi-csi2.c
> > > @@ -303,7 +303,6 @@ static void csi2ipu_gasket_init(struct csi2_dev *csi2)
> > >  static int csi2_get_active_lanes(struct csi2_dev *csi2, unsigned int *lanes)
> > >  {
> > >  	struct v4l2_mbus_config mbus_config = { 0 };
> > > -	unsigned int num_lanes = UINT_MAX;
> > >  	int ret;
> > >
> > >  	*lanes = csi2->data_lanes;
> > > @@ -326,32 +325,14 @@ static int csi2_get_active_lanes(struct csi2_dev *csi2, unsigned int *lanes)
> > >  		return -EINVAL;
> > >  	}
> > >
> > > -	switch (mbus_config.flags & V4L2_MBUS_CSI2_LANES) {
> > > -	case V4L2_MBUS_CSI2_1_LANE:
> > > -		num_lanes = 1;
> > > -		break;
> > > -	case V4L2_MBUS_CSI2_2_LANE:
> > > -		num_lanes = 2;
> > > -		break;
> > > -	case V4L2_MBUS_CSI2_3_LANE:
> > > -		num_lanes = 3;
> > > -		break;
> > > -	case V4L2_MBUS_CSI2_4_LANE:
> > > -		num_lanes = 4;
> > > -		break;
> > > -	default:
> > > -		num_lanes = csi2->data_lanes;
> > > -		break;
> > > -	}
> > > -
> > > -	if (num_lanes > csi2->data_lanes) {
> > > +	if (mbus_config.bus.mipi_csi2.num_data_lanes > csi2->data_lanes) {
> > >  		dev_err(csi2->dev,
> > >  			"Unsupported mbus config: too many data lanes %u\n",
> > > -			num_lanes);
> > > +			mbus_config.bus.mipi_csi2.num_data_lanes);
> > >  		return -EINVAL;
> > >  	}
> > >
> > > -	*lanes = num_lanes;
> > > +	*lanes = mbus_config.bus.mipi_csi2.num_data_lanes;
> > >
> > >  	return 0;
> > >  }
> > > diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
> > > index 9c4970fbd8ea..269aaf57ba32 100644
> > > --- a/include/media/v4l2-mediabus.h
> > > +++ b/include/media/v4l2-mediabus.h
> > > @@ -166,12 +166,26 @@ enum v4l2_mbus_type {
> > >
> > >  /**
> > >   * struct v4l2_mbus_config - media bus configuration
> > > - * @type:	in: interface type
> > > - * @flags:	in / out: configuration flags, depending on @type
> > > + * @type: interface type
> > > + * @bus: bus configuration data structure
> > > + * @bus.parallel: embedded &struct v4l2_mbus_config_parallel.
> > > + *		  Used if the bus is parallel or BT.656.
> > > + * @bus.mipi_csi1: embedded &struct v4l2_mbus_config_mipi_csi1.
> > > + *		   Used if the bus is MIPI Alliance's Camera Serial
> > > + *		   Interface version 1 (MIPI CSI1) or Standard
> > > + *		   Mobile Imaging Architecture's Compact Camera Port 2
> > > + *		   (SMIA CCP2).
> > > + * @bus.mipi_csi2: embedded &struct v4l2_mbus_config_mipi_csi2.
> > > + *		   Used if the bus is MIPI Alliance's Camera Serial
> > > + *		   Interface version 2 (MIPI CSI2).
> > >   */
> > >  struct v4l2_mbus_config {
> > >  	enum v4l2_mbus_type type;
> > > -	unsigned int flags;
> > > +	union {
> > > +		struct v4l2_mbus_config_parallel parallel;
> > > +		struct v4l2_mbus_config_mipi_csi1 mipi_csi1;
> > > +		struct v4l2_mbus_config_mipi_csi2 mipi_csi2;
> >
> > I wonder if we would be able to use a single structure for D-PHY and
> > C-PHY. The clock lane index does not make much sense for the latter,
> > but it was already there, so it can be changed on top in case it is
> > required
>
> I'm not sure to follow you here. CSI1 and CSI2 are not D-PHY versus
> C-PHY.
>

I meant if we will be able to correctly represent CSI-2 on C-PHY with
struct v4l2_mbus_config_mipi_csi2.

> > Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> >
> > > +	} bus;
> > >  };
> > >
> > >  /**
>
> --
> Regards,
>
> Laurent Pinchart

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

* Re: [PATCH v1.1 8/8] media: v4l2-mediabus: Drop V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag
  2022-02-15 11:12         ` Laurent Pinchart
@ 2022-02-15 11:29           ` Jacopo Mondi
  2022-02-15 11:34             ` Laurent Pinchart
  0 siblings, 1 reply; 36+ messages in thread
From: Jacopo Mondi @ 2022-02-15 11:29 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-media, linux-renesas-soc, Sakari Ailus, Hans Verkuil,
	Kieran Bingham, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik, Lars-Peter Clausen, Mats Randgaard

Hi Laurent

On Tue, Feb 15, 2022 at 01:12:42PM +0200, Laurent Pinchart wrote:
> Hi Jacopo,
>
> On Tue, Feb 15, 2022 at 12:04:20PM +0100, Jacopo Mondi wrote:
> > On Wed, Jan 05, 2022 at 10:15:58PM +0200, Laurent Pinchart wrote:
> > > MIPI CSI-2 continuous and non-continuous clock modes are mutually
> > > exclusive. Drop the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag and use
> > > V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK only.
> >
> > As continuous clock is the default configuration for CSI-2, wouldn't
> > it be easier to add a boolean clock_non_cont (or similar) to
> > v4l2_mbus_config_mipi_csi2 ?
>
> That would be functionally equivalent, but flags will take less memory
> compared to multiple booleans. I don't mind much though, and another
> option would be to use a bitfield.
>

In the long term, shouldn't flags be removed completely ?
Or some of them will stay ?

Anyway, for now this is fine
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

Thanks
  j

> > > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > > ---
> > > Changes since v1:
> > >
> > > - Check all CSI2 flags in v4l2_fwnode_endpoint_parse_csi2_bus()
> > > ---
> > >  drivers/media/i2c/adv7180.c           | 3 +--
> > >  drivers/media/i2c/tc358743.c          | 6 +++---
> > >  drivers/media/v4l2-core/v4l2-fwnode.c | 6 ++----
> > >  include/media/v4l2-mediabus.h         | 3 +--
> > >  4 files changed, 7 insertions(+), 11 deletions(-)
> > >
> > > diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
> > > index 3ff37a550810..4f5db195e66d 100644
> > > --- a/drivers/media/i2c/adv7180.c
> > > +++ b/drivers/media/i2c/adv7180.c
> > > @@ -785,8 +785,7 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
> > >  	if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
> > >  		cfg->type = V4L2_MBUS_CSI2_DPHY;
> > >  		cfg->bus.mipi_csi2.num_data_lanes = 1;
> > > -		cfg->bus.mipi_csi2.flags =
> > > -				V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > > +		cfg->bus.mipi_csi2.flags = 0;
> > >  	} else {
> > >  		/*
> > >  		 * The ADV7180 sensor supports BT.601/656 output modes.
> > > diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
> > > index dfbc42675143..e18b8947ad7e 100644
> > > --- a/drivers/media/i2c/tc358743.c
> > > +++ b/drivers/media/i2c/tc358743.c
> > > @@ -717,7 +717,7 @@ static void tc358743_set_csi(struct v4l2_subdev *sd)
> > >  			((lanes > 3) ? MASK_D3M_HSTXVREGEN : 0x0));
> > >
> > >  	i2c_wr32(sd, TXOPTIONCNTRL, (state->bus.flags &
> > > -		 V4L2_MBUS_CSI2_CONTINUOUS_CLOCK) ? MASK_CONTCLKMODE : 0);
> > > +		 V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK) ? 0 : MASK_CONTCLKMODE);
> > >  	i2c_wr32(sd, STARTCNTRL, MASK_START);
> > >  	i2c_wr32(sd, CSI_START, MASK_STRT);
> > >
> > > @@ -1613,7 +1613,7 @@ static int tc358743_get_mbus_config(struct v4l2_subdev *sd,
> > >  	cfg->type = V4L2_MBUS_CSI2_DPHY;
> > >
> > >  	/* Support for non-continuous CSI-2 clock is missing in the driver */
> > > -	cfg->bus.mipi_csi2.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > > +	cfg->bus.mipi_csi2.flags = 0;
> > >  	cfg->bus.mipi_csi2.num_data_lanes = state->csi_lanes_in_use;
> > >
> > >  	return 0;
> > > @@ -2039,7 +2039,7 @@ static int tc358743_probe(struct i2c_client *client)
> > >  	/* platform data */
> > >  	if (pdata) {
> > >  		state->pdata = *pdata;
> > > -		state->bus.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > > +		state->bus.flags = 0;
> > >  	} else {
> > >  		err = tc358743_probe_of(state);
> > >  		if (err == -ENODEV)
> > > diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
> > > index 9ff3ebb230e7..71dcc9a96535 100644
> > > --- a/drivers/media/v4l2-core/v4l2-fwnode.c
> > > +++ b/drivers/media/v4l2-core/v4l2-fwnode.c
> > > @@ -207,13 +207,11 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
> > >  	if (fwnode_property_present(fwnode, "clock-noncontinuous")) {
> > >  		flags |= V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK;
> > >  		pr_debug("non-continuous clock\n");
> > > -	} else {
> > > -		flags |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > >  	}
> > >
> > >  	if (bus_type == V4L2_MBUS_CSI2_DPHY ||
> > > -	    bus_type == V4L2_MBUS_CSI2_CPHY || lanes_used ||
> > > -	    have_clk_lane || (flags & ~V4L2_MBUS_CSI2_CONTINUOUS_CLOCK)) {
> > > +	    bus_type == V4L2_MBUS_CSI2_CPHY ||
> > > +	    lanes_used || have_clk_lane || flags) {
> > >  		/* Only D-PHY has a clock lane. */
> > >  		unsigned int dfl_data_lane_index =
> > >  			bus_type == V4L2_MBUS_CSI2_DPHY;
> > > diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
> > > index c6626a22b394..e0db3bcff9ed 100644
> > > --- a/include/media/v4l2-mediabus.h
> > > +++ b/include/media/v4l2-mediabus.h
> > > @@ -68,8 +68,7 @@
> > >
> > >  /* Serial flags */
> > >  /* Clock non-continuous mode support. */
> > > -#define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK		BIT(8)
> > > -#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(9)
> > > +#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(0)
> > >
> > >  #define V4L2_MBUS_CSI2_MAX_DATA_LANES		8
> > >
> > >
> > > base-commit: 68b9bcc8a534cd11fe55f8bc82f948aae7d81b3c
> > > prerequisite-patch-id: cc085f7de462ead19772e3f64e1b1d13bb92d5b7
> > > prerequisite-patch-id: d6943d1780603964a753d571e26bad98b4954a8a
> > > prerequisite-patch-id: c63eaa2a61aeea6d4be238644f1324f0170d981c
> > > prerequisite-patch-id: 797385e385b3f71f0bafe7eb8e712d52628c23d7
> > > prerequisite-patch-id: 2f7fe0901f79ac1d445e443b5d3ee7ab9ae41525
> > > prerequisite-patch-id: 70ddd068308b5758872349ec6e0f03e8c9427dc0
> > > prerequisite-patch-id: 987cc8f39cb63badf2d6ceba946deffafba9a249
>
> --
> Regards,
>
> Laurent Pinchart

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

* Re: [RFC PATCH 5/8] media: v4l2-mediabus: Use structures to describe bus configuration
  2022-02-15 11:28       ` Jacopo Mondi
@ 2022-02-15 11:32         ` Laurent Pinchart
  0 siblings, 0 replies; 36+ messages in thread
From: Laurent Pinchart @ 2022-02-15 11:32 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: linux-media, linux-renesas-soc, Sakari Ailus, Hans Verkuil,
	Kieran Bingham, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik, Philipp Zabel, Lars-Peter Clausen, Petr Cvek,
	Mats Randgaard, Steve Longerbeam, Shawn Guo, Sascha Hauer

Hi Jacopo,

On Tue, Feb 15, 2022 at 12:28:28PM +0100, Jacopo Mondi wrote:
> On Tue, Feb 15, 2022 at 01:15:40PM +0200, Laurent Pinchart wrote:
> > On Tue, Feb 15, 2022 at 12:13:16PM +0100, Jacopo Mondi wrote:
> > > On Mon, Jan 03, 2022 at 06:24:11PM +0200, Laurent Pinchart wrote:
> > > > The media bus configuration is specified through a set of flags, some of
> > > > which being mutually exclusive. This doesn't scale to express more
> > > > complex configurations. Improve the API by replacing the single flags
> > > > field in v4l2_mbus_config by a union of v4l2_mbus_config_* structures.
> > > > The flags themselves are still used in those structures, so they are
> > > > kept here. Drivers are however updated to use structure fields instead
> > > > of flags when already possible.
> > > >
> > > > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > > > ---
> > > >  drivers/gpu/ipu-v3/ipu-csi.c                |  6 ++---
> > > >  drivers/media/i2c/adv7180.c                 |  8 ++++---
> > > >  drivers/media/i2c/adv748x/adv748x-csi2.c    | 18 +--------------
> > > >  drivers/media/i2c/ml86v7667.c               |  5 +++--
> > > >  drivers/media/i2c/mt9m001.c                 |  8 ++++---
> > > >  drivers/media/i2c/mt9m111.c                 | 16 +++++++------
> > > >  drivers/media/i2c/ov6650.c                  | 14 ++++++------
> > > >  drivers/media/i2c/ov9640.c                  |  8 ++++---
> > > >  drivers/media/i2c/tc358743.c                | 20 ++---------------
> > > >  drivers/media/i2c/tvp5150.c                 |  6 +++--
> > > >  drivers/media/platform/pxa_camera.c         | 12 +++++-----
> > > >  drivers/media/platform/rcar-vin/rcar-csi2.c | 16 +++----------
> > > >  drivers/staging/media/imx/imx-media-csi.c   |  7 +++---
> > > >  drivers/staging/media/imx/imx6-mipi-csi2.c  | 25 +++------------------
> > >
> > > drivers conversions looks good to me
> > >
> > > >  include/media/v4l2-mediabus.h               | 20 ++++++++++++++---
> > > >  15 files changed, 78 insertions(+), 111 deletions(-)
> > > >
> > > > diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
> > > > index a9639d098893..778bc26d3ba5 100644
> > > > --- a/drivers/gpu/ipu-v3/ipu-csi.c
> > > > +++ b/drivers/gpu/ipu-v3/ipu-csi.c
> > > > @@ -357,11 +357,11 @@ static int fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
> > > >  	switch (mbus_cfg->type) {
> > > >  	case V4L2_MBUS_PARALLEL:
> > > >  		csicfg->ext_vsync = 1;
> > > > -		csicfg->vsync_pol = (mbus_cfg->flags &
> > > > +		csicfg->vsync_pol = (mbus_cfg->bus.parallel.flags &
> > > >  				     V4L2_MBUS_VSYNC_ACTIVE_LOW) ? 1 : 0;
> > > > -		csicfg->hsync_pol = (mbus_cfg->flags &
> > > > +		csicfg->hsync_pol = (mbus_cfg->bus.parallel.flags &
> > > >  				     V4L2_MBUS_HSYNC_ACTIVE_LOW) ? 1 : 0;
> > > > -		csicfg->pixclk_pol = (mbus_cfg->flags &
> > > > +		csicfg->pixclk_pol = (mbus_cfg->bus.parallel.flags &
> > > >  				      V4L2_MBUS_PCLK_SAMPLE_FALLING) ? 1 : 0;
> > > >  		csicfg->clk_mode = IPU_CSI_CLK_MODE_GATED_CLK;
> > > >  		break;
> > > > diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
> > > > index d9a99fcfacb1..286f5017d9c3 100644
> > > > --- a/drivers/media/i2c/adv7180.c
> > > > +++ b/drivers/media/i2c/adv7180.c
> > > > @@ -784,7 +784,8 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
> > > >
> > > >  	if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
> > > >  		cfg->type = V4L2_MBUS_CSI2_DPHY;
> > > > -		cfg->flags = V4L2_MBUS_CSI2_1_LANE |
> > > > +		cfg->bus.mipi_csi2.num_data_lanes = 1;
> > > > +		cfg->bus.mipi_csi2.flags =
> > > >  				V4L2_MBUS_CSI2_CHANNEL_0 |
> > > >  				V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > > >  	} else {
> > > > @@ -792,8 +793,9 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
> > > >  		 * The ADV7180 sensor supports BT.601/656 output modes.
> > > >  		 * The BT.656 is default and not yet configurable by s/w.
> > > >  		 */
> > > > -		cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
> > > > -				 V4L2_MBUS_DATA_ACTIVE_HIGH;
> > > > +		cfg->bus.parallel.flags = V4L2_MBUS_MASTER |
> > > > +					  V4L2_MBUS_PCLK_SAMPLE_RISING |
> > > > +					  V4L2_MBUS_DATA_ACTIVE_HIGH;
> > > >  		cfg->type = V4L2_MBUS_BT656;
> > > >  	}
> > > >
> > > > diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c
> > > > index 589e9644fcdc..bd4f3fe0e309 100644
> > > > --- a/drivers/media/i2c/adv748x/adv748x-csi2.c
> > > > +++ b/drivers/media/i2c/adv748x/adv748x-csi2.c
> > > > @@ -222,23 +222,7 @@ static int adv748x_csi2_get_mbus_config(struct v4l2_subdev *sd, unsigned int pad
> > > >  		return -EINVAL;
> > > >
> > > >  	config->type = V4L2_MBUS_CSI2_DPHY;
> > > > -	switch (tx->active_lanes) {
> > > > -	case 1:
> > > > -		config->flags = V4L2_MBUS_CSI2_1_LANE;
> > > > -		break;
> > > > -
> > > > -	case 2:
> > > > -		config->flags = V4L2_MBUS_CSI2_2_LANE;
> > > > -		break;
> > > > -
> > > > -	case 3:
> > > > -		config->flags = V4L2_MBUS_CSI2_3_LANE;
> > > > -		break;
> > > > -
> > > > -	case 4:
> > > > -		config->flags = V4L2_MBUS_CSI2_4_LANE;
> > > > -		break;
> > > > -	}
> > > > +	config->bus.mipi_csi2.num_data_lanes = tx->active_lanes;
> > > >
> > > >  	return 0;
> > > >  }
> > > > diff --git a/drivers/media/i2c/ml86v7667.c b/drivers/media/i2c/ml86v7667.c
> > > > index 4a1410ebb4c8..48cc0b0922f4 100644
> > > > --- a/drivers/media/i2c/ml86v7667.c
> > > > +++ b/drivers/media/i2c/ml86v7667.c
> > > > @@ -223,9 +223,10 @@ static int ml86v7667_get_mbus_config(struct v4l2_subdev *sd,
> > > >  				     unsigned int pad,
> > > >  				     struct v4l2_mbus_config *cfg)
> > > >  {
> > > > -	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
> > > > -		     V4L2_MBUS_DATA_ACTIVE_HIGH;
> > > >  	cfg->type = V4L2_MBUS_BT656;
> > > > +	cfg->bus.parallel.flags = V4L2_MBUS_MASTER |
> > > > +				  V4L2_MBUS_PCLK_SAMPLE_RISING |
> > > > +				  V4L2_MBUS_DATA_ACTIVE_HIGH;
> > > >
> > > >  	return 0;
> > > >  }
> > > > diff --git a/drivers/media/i2c/mt9m001.c b/drivers/media/i2c/mt9m001.c
> > > > index c9f0bd997ea7..ad13b0c890c0 100644
> > > > --- a/drivers/media/i2c/mt9m001.c
> > > > +++ b/drivers/media/i2c/mt9m001.c
> > > > @@ -695,10 +695,12 @@ static int mt9m001_get_mbus_config(struct v4l2_subdev *sd,
> > > >  				   struct v4l2_mbus_config *cfg)
> > > >  {
> > > >  	/* MT9M001 has all capture_format parameters fixed */
> > > > -	cfg->flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
> > > > -		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> > > > -		V4L2_MBUS_DATA_ACTIVE_HIGH | V4L2_MBUS_MASTER;
> > > >  	cfg->type = V4L2_MBUS_PARALLEL;
> > > > +	cfg->bus.parallel.flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
> > > > +				  V4L2_MBUS_HSYNC_ACTIVE_HIGH |
> > > > +				  V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> > > > +				  V4L2_MBUS_DATA_ACTIVE_HIGH |
> > > > +				  V4L2_MBUS_MASTER;
> > > >
> > > >  	return 0;
> > > >  }
> > > > diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
> > > > index 91a44359bcd3..6cf3ccf85d27 100644
> > > > --- a/drivers/media/i2c/mt9m111.c
> > > > +++ b/drivers/media/i2c/mt9m111.c
> > > > @@ -1143,15 +1143,17 @@ static int mt9m111_get_mbus_config(struct v4l2_subdev *sd,
> > > >  {
> > > >  	struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev);
> > > >
> > > > -	cfg->flags = V4L2_MBUS_MASTER |
> > > > -		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> > > > -		V4L2_MBUS_DATA_ACTIVE_HIGH;
> > > > -
> > > > -	cfg->flags |= mt9m111->pclk_sample ? V4L2_MBUS_PCLK_SAMPLE_RISING :
> > > > -		V4L2_MBUS_PCLK_SAMPLE_FALLING;
> > > > -
> > > >  	cfg->type = V4L2_MBUS_PARALLEL;
> > > >
> > > > +	cfg->bus.parallel.flags = V4L2_MBUS_MASTER |
> > > > +				  V4L2_MBUS_HSYNC_ACTIVE_HIGH |
> > > > +				  V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> > > > +				  V4L2_MBUS_DATA_ACTIVE_HIGH;
> > > > +
> > > > +	cfg->bus.parallel.flags |= mt9m111->pclk_sample ?
> > > > +				   V4L2_MBUS_PCLK_SAMPLE_RISING :
> > > > +				   V4L2_MBUS_PCLK_SAMPLE_FALLING;
> > > > +
> > > >  	return 0;
> > > >  }
> > > >
> > > > diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
> > > > index 455a627e35a0..b2654b32bc62 100644
> > > > --- a/drivers/media/i2c/ov6650.c
> > > > +++ b/drivers/media/i2c/ov6650.c
> > > > @@ -932,15 +932,15 @@ static int ov6650_get_mbus_config(struct v4l2_subdev *sd,
> > > >  	if (ret)
> > > >  		return ret;
> > > >
> > > > -	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_DATA_ACTIVE_HIGH
> > > > -		   | ((comj & COMJ_VSYNC_HIGH)  ? V4L2_MBUS_VSYNC_ACTIVE_HIGH
> > > > -						: V4L2_MBUS_VSYNC_ACTIVE_LOW)
> > > > -		   | ((comf & COMF_HREF_LOW)    ? V4L2_MBUS_HSYNC_ACTIVE_LOW
> > > > -						: V4L2_MBUS_HSYNC_ACTIVE_HIGH)
> > > > -		   | ((comj & COMJ_PCLK_RISING) ? V4L2_MBUS_PCLK_SAMPLE_RISING
> > > > -						: V4L2_MBUS_PCLK_SAMPLE_FALLING);
> > > >  	cfg->type = V4L2_MBUS_PARALLEL;
> > > >
> > > > +	cfg->bus.parallel.flags = V4L2_MBUS_MASTER | V4L2_MBUS_DATA_ACTIVE_HIGH
> > > > +		| ((comj & COMJ_VSYNC_HIGH)  ? V4L2_MBUS_VSYNC_ACTIVE_HIGH
> > > > +					     : V4L2_MBUS_VSYNC_ACTIVE_LOW)
> > > > +		| ((comf & COMF_HREF_LOW)    ? V4L2_MBUS_HSYNC_ACTIVE_LOW
> > > > +					     : V4L2_MBUS_HSYNC_ACTIVE_HIGH)
> > > > +		| ((comj & COMJ_PCLK_RISING) ? V4L2_MBUS_PCLK_SAMPLE_RISING
> > > > +					     : V4L2_MBUS_PCLK_SAMPLE_FALLING);
> > > >  	return 0;
> > > >  }
> > > >
> > > > diff --git a/drivers/media/i2c/ov9640.c b/drivers/media/i2c/ov9640.c
> > > > index 0bab8c2cf160..9f44ed52d164 100644
> > > > --- a/drivers/media/i2c/ov9640.c
> > > > +++ b/drivers/media/i2c/ov9640.c
> > > > @@ -652,10 +652,12 @@ static int ov9640_get_mbus_config(struct v4l2_subdev *sd,
> > > >  				  unsigned int pad,
> > > >  				  struct v4l2_mbus_config *cfg)
> > > >  {
> > > > -	cfg->flags = V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_MASTER |
> > > > -		V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
> > > > -		V4L2_MBUS_DATA_ACTIVE_HIGH;
> > > >  	cfg->type = V4L2_MBUS_PARALLEL;
> > > > +	cfg->bus.parallel.flags = V4L2_MBUS_PCLK_SAMPLE_RISING |
> > > > +				  V4L2_MBUS_MASTER |
> > > > +				  V4L2_MBUS_VSYNC_ACTIVE_HIGH |
> > > > +				  V4L2_MBUS_HSYNC_ACTIVE_HIGH |
> > > > +				  V4L2_MBUS_DATA_ACTIVE_HIGH;
> > > >
> > > >  	return 0;
> > > >  }
> > > > diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
> > > > index 40512004afba..dfbc42675143 100644
> > > > --- a/drivers/media/i2c/tc358743.c
> > > > +++ b/drivers/media/i2c/tc358743.c
> > > > @@ -1613,24 +1613,8 @@ static int tc358743_get_mbus_config(struct v4l2_subdev *sd,
> > > >  	cfg->type = V4L2_MBUS_CSI2_DPHY;
> > > >
> > > >  	/* Support for non-continuous CSI-2 clock is missing in the driver */
> > > > -	cfg->flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > > > -
> > > > -	switch (state->csi_lanes_in_use) {
> > > > -	case 1:
> > > > -		cfg->flags |= V4L2_MBUS_CSI2_1_LANE;
> > > > -		break;
> > > > -	case 2:
> > > > -		cfg->flags |= V4L2_MBUS_CSI2_2_LANE;
> > > > -		break;
> > > > -	case 3:
> > > > -		cfg->flags |= V4L2_MBUS_CSI2_3_LANE;
> > > > -		break;
> > > > -	case 4:
> > > > -		cfg->flags |= V4L2_MBUS_CSI2_4_LANE;
> > > > -		break;
> > > > -	default:
> > > > -		return -EINVAL;
> > > > -	}
> > > > +	cfg->bus.mipi_csi2.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > > > +	cfg->bus.mipi_csi2.num_data_lanes = state->csi_lanes_in_use;
> > > >
> > > >  	return 0;
> > > >  }
> > > > diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
> > > > index 4b16ffcaef98..65472438444b 100644
> > > > --- a/drivers/media/i2c/tvp5150.c
> > > > +++ b/drivers/media/i2c/tvp5150.c
> > > > @@ -1198,8 +1198,10 @@ static int tvp5150_get_mbus_config(struct v4l2_subdev *sd,
> > > >  	struct tvp5150 *decoder = to_tvp5150(sd);
> > > >
> > > >  	cfg->type = decoder->mbus_type;
> > > > -	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING
> > > > -		   | V4L2_MBUS_FIELD_EVEN_LOW | V4L2_MBUS_DATA_ACTIVE_HIGH;
> > > > +	cfg->bus.parallel.flags = V4L2_MBUS_MASTER
> > > > +				| V4L2_MBUS_PCLK_SAMPLE_RISING
> > > > +				| V4L2_MBUS_FIELD_EVEN_LOW
> > > > +				| V4L2_MBUS_DATA_ACTIVE_HIGH;
> > > >
> > > >  	return 0;
> > > >  }
> > > > diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
> > > > index b5644cf37fe9..35145e3348f0 100644
> > > > --- a/drivers/media/platform/pxa_camera.c
> > > > +++ b/drivers/media/platform/pxa_camera.c
> > > > @@ -1587,24 +1587,26 @@ static int pxa_camera_set_bus_param(struct pxa_camera_dev *pcdev)
> > > >  	 * PXA does not support V4L2_MBUS_DATA_ACTIVE_LOW and the bus mastering
> > > >  	 * roles should match.
> > > >  	 */
> > > > -	if (cfg.flags != mbus_config) {
> > > > +	if (cfg.bus.parallel.flags != mbus_config) {
> > > >  		unsigned int pxa_mbus_role = mbus_config & (V4L2_MBUS_MASTER |
> > > >  							    V4L2_MBUS_SLAVE);
> > > > -		if (pxa_mbus_role != (cfg.flags & (V4L2_MBUS_MASTER |
> > > > -						   V4L2_MBUS_SLAVE))) {
> > > > +		unsigned int flags = cfg.bus.parallel.flags;
> > > > +
> > > > +		if (pxa_mbus_role != (flags & (V4L2_MBUS_MASTER |
> > > > +					       V4L2_MBUS_SLAVE))) {
> > > >  			dev_err(pcdev_to_dev(pcdev),
> > > >  				"Unsupported mbus configuration: bus mastering\n");
> > > >  			return -EINVAL;
> > > >  		}
> > > >
> > > > -		if (cfg.flags & V4L2_MBUS_DATA_ACTIVE_LOW) {
> > > > +		if (flags & V4L2_MBUS_DATA_ACTIVE_LOW) {
> > > >  			dev_err(pcdev_to_dev(pcdev),
> > > >  				"Unsupported mbus configuration: DATA_ACTIVE_LOW\n");
> > > >  			return -EINVAL;
> > > >  		}
> > > >  	}
> > > >
> > > > -	pxa_camera_setup_cicr(pcdev, cfg.flags, pixfmt);
> > > > +	pxa_camera_setup_cicr(pcdev, cfg.bus.parallel.flags, pixfmt);
> > > >
> > > >  	return 0;
> > > >  }
> > > > diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
> > > > index 8c939cb3073d..cbac5801720b 100644
> > > > --- a/drivers/media/platform/rcar-vin/rcar-csi2.c
> > > > +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
> > > > @@ -603,7 +603,6 @@ static int rcsi2_get_active_lanes(struct rcar_csi2 *priv,
> > > >  				  unsigned int *lanes)
> > > >  {
> > > >  	struct v4l2_mbus_config mbus_config = { 0 };
> > > > -	unsigned int num_lanes = UINT_MAX;
> > > >  	int ret;
> > > >
> > > >  	*lanes = priv->lanes;
> > > > @@ -626,23 +625,14 @@ static int rcsi2_get_active_lanes(struct rcar_csi2 *priv,
> > > >  		return -EINVAL;
> > > >  	}
> > > >
> > > > -	if (mbus_config.flags & V4L2_MBUS_CSI2_1_LANE)
> > > > -		num_lanes = 1;
> > > > -	else if (mbus_config.flags & V4L2_MBUS_CSI2_2_LANE)
> > > > -		num_lanes = 2;
> > > > -	else if (mbus_config.flags & V4L2_MBUS_CSI2_3_LANE)
> > > > -		num_lanes = 3;
> > > > -	else if (mbus_config.flags & V4L2_MBUS_CSI2_4_LANE)
> > > > -		num_lanes = 4;
> > > > -
> > > > -	if (num_lanes > priv->lanes) {
> > > > +	if (mbus_config.bus.mipi_csi2.num_data_lanes > priv->lanes) {
> > > >  		dev_err(priv->dev,
> > > >  			"Unsupported mbus config: too many data lanes %u\n",
> > > > -			num_lanes);
> > > > +			mbus_config.bus.mipi_csi2.num_data_lanes);
> > > >  		return -EINVAL;
> > > >  	}
> > > >
> > > > -	*lanes = num_lanes;
> > > > +	*lanes = mbus_config.bus.mipi_csi2.num_data_lanes;
> > > >
> > > >  	return 0;
> > > >  }
> > > > diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c
> > > > index bd7f156f2d52..b2b1f4dd41d7 100644
> > > > --- a/drivers/staging/media/imx/imx-media-csi.c
> > > > +++ b/drivers/staging/media/imx/imx-media-csi.c
> > > > @@ -718,9 +718,10 @@ static int csi_setup(struct csi_priv *priv)
> > > >
> > > >  	/* compose mbus_config from the upstream endpoint */
> > > >  	mbus_cfg.type = priv->upstream_ep.bus_type;
> > > > -	mbus_cfg.flags = is_parallel_bus(&priv->upstream_ep) ?
> > > > -		priv->upstream_ep.bus.parallel.flags :
> > > > -		priv->upstream_ep.bus.mipi_csi2.flags;
> > > > +	if (is_parallel_bus(&priv->upstream_ep))
> > > > +		mbus_cfg.bus.parallel = priv->upstream_ep.bus.parallel;
> > > > +	else
> > > > +		mbus_cfg.bus.mipi_csi2 = priv->upstream_ep.bus.mipi_csi2;
> > > >
> > > >  	if_fmt = *infmt;
> > > >  	crop = priv->crop;
> > > > diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c
> > > > index 558b256ac935..c4cb558a85c6 100644
> > > > --- a/drivers/staging/media/imx/imx6-mipi-csi2.c
> > > > +++ b/drivers/staging/media/imx/imx6-mipi-csi2.c
> > > > @@ -303,7 +303,6 @@ static void csi2ipu_gasket_init(struct csi2_dev *csi2)
> > > >  static int csi2_get_active_lanes(struct csi2_dev *csi2, unsigned int *lanes)
> > > >  {
> > > >  	struct v4l2_mbus_config mbus_config = { 0 };
> > > > -	unsigned int num_lanes = UINT_MAX;
> > > >  	int ret;
> > > >
> > > >  	*lanes = csi2->data_lanes;
> > > > @@ -326,32 +325,14 @@ static int csi2_get_active_lanes(struct csi2_dev *csi2, unsigned int *lanes)
> > > >  		return -EINVAL;
> > > >  	}
> > > >
> > > > -	switch (mbus_config.flags & V4L2_MBUS_CSI2_LANES) {
> > > > -	case V4L2_MBUS_CSI2_1_LANE:
> > > > -		num_lanes = 1;
> > > > -		break;
> > > > -	case V4L2_MBUS_CSI2_2_LANE:
> > > > -		num_lanes = 2;
> > > > -		break;
> > > > -	case V4L2_MBUS_CSI2_3_LANE:
> > > > -		num_lanes = 3;
> > > > -		break;
> > > > -	case V4L2_MBUS_CSI2_4_LANE:
> > > > -		num_lanes = 4;
> > > > -		break;
> > > > -	default:
> > > > -		num_lanes = csi2->data_lanes;
> > > > -		break;
> > > > -	}
> > > > -
> > > > -	if (num_lanes > csi2->data_lanes) {
> > > > +	if (mbus_config.bus.mipi_csi2.num_data_lanes > csi2->data_lanes) {
> > > >  		dev_err(csi2->dev,
> > > >  			"Unsupported mbus config: too many data lanes %u\n",
> > > > -			num_lanes);
> > > > +			mbus_config.bus.mipi_csi2.num_data_lanes);
> > > >  		return -EINVAL;
> > > >  	}
> > > >
> > > > -	*lanes = num_lanes;
> > > > +	*lanes = mbus_config.bus.mipi_csi2.num_data_lanes;
> > > >
> > > >  	return 0;
> > > >  }
> > > > diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
> > > > index 9c4970fbd8ea..269aaf57ba32 100644
> > > > --- a/include/media/v4l2-mediabus.h
> > > > +++ b/include/media/v4l2-mediabus.h
> > > > @@ -166,12 +166,26 @@ enum v4l2_mbus_type {
> > > >
> > > >  /**
> > > >   * struct v4l2_mbus_config - media bus configuration
> > > > - * @type:	in: interface type
> > > > - * @flags:	in / out: configuration flags, depending on @type
> > > > + * @type: interface type
> > > > + * @bus: bus configuration data structure
> > > > + * @bus.parallel: embedded &struct v4l2_mbus_config_parallel.
> > > > + *		  Used if the bus is parallel or BT.656.
> > > > + * @bus.mipi_csi1: embedded &struct v4l2_mbus_config_mipi_csi1.
> > > > + *		   Used if the bus is MIPI Alliance's Camera Serial
> > > > + *		   Interface version 1 (MIPI CSI1) or Standard
> > > > + *		   Mobile Imaging Architecture's Compact Camera Port 2
> > > > + *		   (SMIA CCP2).
> > > > + * @bus.mipi_csi2: embedded &struct v4l2_mbus_config_mipi_csi2.
> > > > + *		   Used if the bus is MIPI Alliance's Camera Serial
> > > > + *		   Interface version 2 (MIPI CSI2).
> > > >   */
> > > >  struct v4l2_mbus_config {
> > > >  	enum v4l2_mbus_type type;
> > > > -	unsigned int flags;
> > > > +	union {
> > > > +		struct v4l2_mbus_config_parallel parallel;
> > > > +		struct v4l2_mbus_config_mipi_csi1 mipi_csi1;
> > > > +		struct v4l2_mbus_config_mipi_csi2 mipi_csi2;
> > >
> > > I wonder if we would be able to use a single structure for D-PHY and
> > > C-PHY. The clock lane index does not make much sense for the latter,
> > > but it was already there, so it can be changed on top in case it is
> > > required
> >
> > I'm not sure to follow you here. CSI1 and CSI2 are not D-PHY versus
> > C-PHY.
> 
> I meant if we will be able to correctly represent CSI-2 on C-PHY with
> struct v4l2_mbus_config_mipi_csi2.

I suppose we can split it into two structures later if the need arises.

> > > Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> > >
> > > > +	} bus;
> > > >  };
> > > >
> > > >  /**

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH v1.1 8/8] media: v4l2-mediabus: Drop V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag
  2022-02-15 11:29           ` Jacopo Mondi
@ 2022-02-15 11:34             ` Laurent Pinchart
  0 siblings, 0 replies; 36+ messages in thread
From: Laurent Pinchart @ 2022-02-15 11:34 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: linux-media, linux-renesas-soc, Sakari Ailus, Hans Verkuil,
	Kieran Bingham, Niklas Söderlund, Tomi Valkeinen,
	Janusz Krzysztofik, Lars-Peter Clausen, Mats Randgaard

Hi Jacopo,

On Tue, Feb 15, 2022 at 12:29:25PM +0100, Jacopo Mondi wrote:
> On Tue, Feb 15, 2022 at 01:12:42PM +0200, Laurent Pinchart wrote:
> > On Tue, Feb 15, 2022 at 12:04:20PM +0100, Jacopo Mondi wrote:
> > > On Wed, Jan 05, 2022 at 10:15:58PM +0200, Laurent Pinchart wrote:
> > > > MIPI CSI-2 continuous and non-continuous clock modes are mutually
> > > > exclusive. Drop the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag and use
> > > > V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK only.
> > >
> > > As continuous clock is the default configuration for CSI-2, wouldn't
> > > it be easier to add a boolean clock_non_cont (or similar) to
> > > v4l2_mbus_config_mipi_csi2 ?
> >
> > That would be functionally equivalent, but flags will take less memory
> > compared to multiple booleans. I don't mind much though, and another
> > option would be to use a bitfield.
> 
> In the long term, shouldn't flags be removed completely ?
> Or some of them will stay ?

Part of the config will be boolean information. That can be stored as
bools, as a bitfield, or as an integer with macros (or an enum) to
define flags. The first option would consume more memory. I don't have a
preference between the second and third options.

> Anyway, for now this is fine
> Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> 
> > > > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > > > ---
> > > > Changes since v1:
> > > >
> > > > - Check all CSI2 flags in v4l2_fwnode_endpoint_parse_csi2_bus()
> > > > ---
> > > >  drivers/media/i2c/adv7180.c           | 3 +--
> > > >  drivers/media/i2c/tc358743.c          | 6 +++---
> > > >  drivers/media/v4l2-core/v4l2-fwnode.c | 6 ++----
> > > >  include/media/v4l2-mediabus.h         | 3 +--
> > > >  4 files changed, 7 insertions(+), 11 deletions(-)
> > > >
> > > > diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
> > > > index 3ff37a550810..4f5db195e66d 100644
> > > > --- a/drivers/media/i2c/adv7180.c
> > > > +++ b/drivers/media/i2c/adv7180.c
> > > > @@ -785,8 +785,7 @@ static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
> > > >  	if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
> > > >  		cfg->type = V4L2_MBUS_CSI2_DPHY;
> > > >  		cfg->bus.mipi_csi2.num_data_lanes = 1;
> > > > -		cfg->bus.mipi_csi2.flags =
> > > > -				V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > > > +		cfg->bus.mipi_csi2.flags = 0;
> > > >  	} else {
> > > >  		/*
> > > >  		 * The ADV7180 sensor supports BT.601/656 output modes.
> > > > diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
> > > > index dfbc42675143..e18b8947ad7e 100644
> > > > --- a/drivers/media/i2c/tc358743.c
> > > > +++ b/drivers/media/i2c/tc358743.c
> > > > @@ -717,7 +717,7 @@ static void tc358743_set_csi(struct v4l2_subdev *sd)
> > > >  			((lanes > 3) ? MASK_D3M_HSTXVREGEN : 0x0));
> > > >
> > > >  	i2c_wr32(sd, TXOPTIONCNTRL, (state->bus.flags &
> > > > -		 V4L2_MBUS_CSI2_CONTINUOUS_CLOCK) ? MASK_CONTCLKMODE : 0);
> > > > +		 V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK) ? 0 : MASK_CONTCLKMODE);
> > > >  	i2c_wr32(sd, STARTCNTRL, MASK_START);
> > > >  	i2c_wr32(sd, CSI_START, MASK_STRT);
> > > >
> > > > @@ -1613,7 +1613,7 @@ static int tc358743_get_mbus_config(struct v4l2_subdev *sd,
> > > >  	cfg->type = V4L2_MBUS_CSI2_DPHY;
> > > >
> > > >  	/* Support for non-continuous CSI-2 clock is missing in the driver */
> > > > -	cfg->bus.mipi_csi2.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > > > +	cfg->bus.mipi_csi2.flags = 0;
> > > >  	cfg->bus.mipi_csi2.num_data_lanes = state->csi_lanes_in_use;
> > > >
> > > >  	return 0;
> > > > @@ -2039,7 +2039,7 @@ static int tc358743_probe(struct i2c_client *client)
> > > >  	/* platform data */
> > > >  	if (pdata) {
> > > >  		state->pdata = *pdata;
> > > > -		state->bus.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > > > +		state->bus.flags = 0;
> > > >  	} else {
> > > >  		err = tc358743_probe_of(state);
> > > >  		if (err == -ENODEV)
> > > > diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
> > > > index 9ff3ebb230e7..71dcc9a96535 100644
> > > > --- a/drivers/media/v4l2-core/v4l2-fwnode.c
> > > > +++ b/drivers/media/v4l2-core/v4l2-fwnode.c
> > > > @@ -207,13 +207,11 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
> > > >  	if (fwnode_property_present(fwnode, "clock-noncontinuous")) {
> > > >  		flags |= V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK;
> > > >  		pr_debug("non-continuous clock\n");
> > > > -	} else {
> > > > -		flags |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
> > > >  	}
> > > >
> > > >  	if (bus_type == V4L2_MBUS_CSI2_DPHY ||
> > > > -	    bus_type == V4L2_MBUS_CSI2_CPHY || lanes_used ||
> > > > -	    have_clk_lane || (flags & ~V4L2_MBUS_CSI2_CONTINUOUS_CLOCK)) {
> > > > +	    bus_type == V4L2_MBUS_CSI2_CPHY ||
> > > > +	    lanes_used || have_clk_lane || flags) {
> > > >  		/* Only D-PHY has a clock lane. */
> > > >  		unsigned int dfl_data_lane_index =
> > > >  			bus_type == V4L2_MBUS_CSI2_DPHY;
> > > > diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
> > > > index c6626a22b394..e0db3bcff9ed 100644
> > > > --- a/include/media/v4l2-mediabus.h
> > > > +++ b/include/media/v4l2-mediabus.h
> > > > @@ -68,8 +68,7 @@
> > > >
> > > >  /* Serial flags */
> > > >  /* Clock non-continuous mode support. */
> > > > -#define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK		BIT(8)
> > > > -#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(9)
> > > > +#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(0)
> > > >
> > > >  #define V4L2_MBUS_CSI2_MAX_DATA_LANES		8
> > > >
> > > >
> > > > base-commit: 68b9bcc8a534cd11fe55f8bc82f948aae7d81b3c
> > > > prerequisite-patch-id: cc085f7de462ead19772e3f64e1b1d13bb92d5b7
> > > > prerequisite-patch-id: d6943d1780603964a753d571e26bad98b4954a8a
> > > > prerequisite-patch-id: c63eaa2a61aeea6d4be238644f1324f0170d981c
> > > > prerequisite-patch-id: 797385e385b3f71f0bafe7eb8e712d52628c23d7
> > > > prerequisite-patch-id: 2f7fe0901f79ac1d445e443b5d3ee7ab9ae41525
> > > > prerequisite-patch-id: 70ddd068308b5758872349ec6e0f03e8c9427dc0
> > > > prerequisite-patch-id: 987cc8f39cb63badf2d6ceba946deffafba9a249

-- 
Regards,

Laurent Pinchart

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

end of thread, other threads:[~2022-02-15 11:34 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-03 16:24 [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config() Laurent Pinchart
2022-01-03 16:24 ` [RFC PATCH 1/8] media: pxa_camera: Drop usage of .set_mbus_config() Laurent Pinchart
2022-01-03 16:24 ` [RFC PATCH 2/8] media: i2c: ov6650: Drop implementation " Laurent Pinchart
2022-01-05 18:04   ` Sakari Ailus
2022-01-05 20:19     ` Laurent Pinchart
2022-01-05 21:31       ` Janusz Krzysztofik
2022-01-05 21:42         ` Laurent Pinchart
2022-01-06  0:13           ` Janusz Krzysztofik
2022-01-09  2:37             ` Laurent Pinchart
2022-01-07 13:41         ` Sakari Ailus
2022-01-10 18:11           ` Janusz Krzysztofik
2022-01-11 11:52             ` Sakari Ailus
2022-01-11 20:37               ` Janusz Krzysztofik
2022-01-03 16:24 ` [RFC PATCH 3/8] media: v4l2-subdev: Drop .set_mbus_config() operation Laurent Pinchart
2022-01-03 16:24 ` [RFC PATCH 4/8] media: v4l2-fwnode: Move bus config structure to v4l2_mediabus.h Laurent Pinchart
2022-01-03 16:24 ` [RFC PATCH 5/8] media: v4l2-mediabus: Use structures to describe bus configuration Laurent Pinchart
2022-02-15 11:13   ` Jacopo Mondi
2022-02-15 11:15     ` Laurent Pinchart
2022-02-15 11:28       ` Jacopo Mondi
2022-02-15 11:32         ` Laurent Pinchart
2022-01-03 16:24 ` [RFC PATCH 6/8] media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_*_LANE flags Laurent Pinchart
2022-02-15 11:14   ` Jacopo Mondi
2022-01-03 16:24 ` [RFC PATCH 7/8] media: v4l2-mediabus: Drop legacy V4L2_MBUS_CSI2_CHANNEL_* flags Laurent Pinchart
2022-02-15 11:01   ` Jacopo Mondi
2022-02-15 11:10     ` Laurent Pinchart
2022-01-03 16:24 ` [RFC PATCH 8/8] media: v4l2-mediabus: Drop V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag Laurent Pinchart
2022-01-05 19:02   ` Sakari Ailus
2022-01-05 20:15     ` [PATCH v1.1 " Laurent Pinchart
2022-02-15 11:04       ` Jacopo Mondi
2022-02-15 11:12         ` Laurent Pinchart
2022-02-15 11:29           ` Jacopo Mondi
2022-02-15 11:34             ` Laurent Pinchart
2022-01-09 14:36 ` [RFC PATCH 0/8] media: Drop .set_mbus_config(), improve .get_mbus_config() Jacopo Mondi
2022-01-09 22:55   ` Laurent Pinchart
2022-01-10  8:42     ` Sakari Ailus
2022-02-15  8:37 ` Laurent Pinchart

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.