linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/9] v4l2-subdev: Introduce [g|s]et_mbus_format pad op
@ 2020-07-14 13:58 Jacopo Mondi
  2020-07-14 13:58 ` [PATCH v6 1/9] media: v4l2-subdev: Introduce [get|set]_mbus_config pad ops Jacopo Mondi
                   ` (8 more replies)
  0 siblings, 9 replies; 21+ messages in thread
From: Jacopo Mondi @ 2020-07-14 13:58 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, sakari.ailus, laurent.pinchart
  Cc: Jacopo Mondi, niklas.soderlund+renesas, kieran.bingham,
	dave.stevenson, hyun.kwon, jmkrzyszt, robert.jarzmik,
	linux-media, linux-renesas-soc

Minor update to the ov6650 to address some of Janusz's comments there.
(now in Cc with Robert for the pxa part. Sorry for missing that in the
previous versions).

Quoting the previous cover letters:

-------------------------------------------------------------------------------
Most of the existing users are i2c camera drivers reporting a static media bus
configuration though g_mbus_config. Porting them is performed in a single
hopefully not controversial patch [2/8]

Two existing users stand-out, and they've probably been developed together:
pxa_camera and ov6650. Those have bee ported separately in single patches
with extensive change logs as their operations semantic had to change to port
them to use the new operations. Not having any of those two platforms, the
changes have been compile-tested only.

The only existing users of the s|g_mbus_config ops are now the soc_camera based
drivers currently living in staging.

The last three patches are similar to the ones posted in v2, with the exception
that they have been updated to use the V4L2_MBUS_* flags as well.
-------------------------------------------------------------------------------

Will report again the use cases I'm trying to address here:
------------------------------------------------------------------------------
Quoting:
https://patchwork.kernel.org/cover/10855919/
"The use case this series cover is the following one:
the Gen-3 R-Car boards include an ADV748x HDMI/CVBS to CSI-2 converter
connected to its CSI-2 receivers. The ADV748x chip has recently gained support
for routing both HDMI and analogue video streams through its 4 lanes TXA
transmitter, specifically to support the Ebisu board that has a single CSI-2
receiver, compared to all other Gen-3 board where the ADV748x TXes are connected
to different CSI-2 receivers, and where analogue video is streamed out from the
ADV748x single lane TXB transmitter.
To properly support transmission of analogue video through TXA, the number of
data lanes shall be dynamically reduced to 1, in order to comply with the MIPI
CSI-2 minimum clock frequency requirements"

During the discussion of the RFC, Dave reported another use case for media
bus parameter negotiation on his platform:
https://patchwork.kernel.org/patch/10855923/#22569149

Hyun is now using this series to configure GMSL devices.
------------------------------------------------------------------------------

Thanks
   j

v5->v6:
- Report V4L2_MBUS_DATA_ACTIVE_HIGH in ov6650 get_mbus_config
- Check for the return value of get_mbus_config() at the end of
  set_mbus_config() in ov6650 driver

v4->v5:
- Address Sakari's comment on documentation (s/should/shall)
- Use a local variable for the number of active lanes in 9/9
- Add Kieran's tags to 7/9 and 8/9
- Fix a warning on operator precedence on 3/9

v3->v4:
- Remove g/s_mbus_config video operation
- Adjust pxa quick capture interface to properly handle bus mastering
- Reword the two new operations documentation

v2->v3:
- Re-use v4l2_mbus_config and V4L2_MBUS_* flags
- Port existing drivers
- Update adv748x and rcar-csi2 patches to use V4L2_MBUS_* flags

v1->v2:
- Address Sakari's comment to use unsigned int in place of bools
- Add two new patches to address documentation
- Adjust rcar-csi2 patch as much as possible according to Niklas comments
- Add Niklas's tags



Jacopo Mondi (9):
  media: v4l2-subdev: Introduce [get|set]_mbus_config pad ops
  media: i2c: Use the new get_mbus_config pad op
  media: i2c: ov6650: Use new [get|set]_mbus_config ops
  media: pxa_camera: Use the new set_mbus_config op
  media: v4l2-subdev: Remove [s|g]_mbus_config video ops
  staging: media: imx: Update TODO entry
  media: i2c: adv748x: Adjust TXA data lanes number
  media: i2c: adv748x: Implement get_mbus_config
  media: rcar-csi2: Negotiate data lanes number

 drivers/media/i2c/adv7180.c                 |   7 +-
 drivers/media/i2c/adv748x/adv748x-core.c    |  31 +++-
 drivers/media/i2c/adv748x/adv748x-csi2.c    |  31 ++++
 drivers/media/i2c/adv748x/adv748x.h         |   1 +
 drivers/media/i2c/ml86v7667.c               |   7 +-
 drivers/media/i2c/mt9m001.c                 |   7 +-
 drivers/media/i2c/mt9m111.c                 |   7 +-
 drivers/media/i2c/ov6650.c                  |  56 ++++--
 drivers/media/i2c/ov9640.c                  |   7 +-
 drivers/media/i2c/tc358743.c                |   7 +-
 drivers/media/i2c/tvp5150.c                 |   7 +-
 drivers/media/platform/pxa_camera.c         | 189 ++++++--------------
 drivers/media/platform/rcar-vin/rcar-csi2.c |  74 +++++++-
 drivers/staging/media/imx/TODO              |   4 +
 include/media/v4l2-subdev.h                 |  37 ++--
 15 files changed, 271 insertions(+), 201 deletions(-)

--
2.27.0


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

* [PATCH v6 1/9] media: v4l2-subdev: Introduce [get|set]_mbus_config pad ops
  2020-07-14 13:58 [PATCH v6 0/9] v4l2-subdev: Introduce [g|s]et_mbus_format pad op Jacopo Mondi
@ 2020-07-14 13:58 ` Jacopo Mondi
  2020-07-15 15:08   ` Hans Verkuil
  2020-07-14 13:58 ` [PATCH v6 2/9] media: i2c: Use the new get_mbus_config pad op Jacopo Mondi
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 21+ messages in thread
From: Jacopo Mondi @ 2020-07-14 13:58 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, sakari.ailus, laurent.pinchart
  Cc: Jacopo Mondi, niklas.soderlund+renesas, kieran.bingham,
	dave.stevenson, hyun.kwon, jmkrzyszt, robert.jarzmik,
	linux-media, linux-renesas-soc

Introduce two new pad operations to allow retrieving and configuring the
media bus parameters on a subdevice pad.

The newly introduced operations aims to replace the s/g_mbus_config video
operations, which have been on their way for deprecation since a long
time.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 include/media/v4l2-subdev.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index f7fe78a6f65a..d8b9d5735307 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -670,6 +670,29 @@ struct v4l2_subdev_pad_config {
  *
  * @set_frame_desc: set the low level media bus frame parameters, @fd array
  *                  may be adjusted by the subdev driver to device capabilities.
+ *
+ * @get_mbus_config: get the media bus configuration of a remote sub-device.
+ *		     The media bus configuration is usually retrieved from the
+ *		     firmware interface at sub-device probe time, immediately
+ *		     applied to the hardware and eventually adjusted by the
+ *		     driver. Remote sub-devices (usually video receivers) shall
+ *		     use this operation to query the transmitting end bus
+ *		     configuration in order to adjust their own one accordingly.
+ *		     Callers should make sure they get the most up-to-date as
+ *		     possible configuration from the remote end, likely calling
+ *		     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.
+ *
+ * @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.
  */
 struct v4l2_subdev_pad_ops {
 	int (*init_cfg)(struct v4l2_subdev *sd,
@@ -710,6 +733,10 @@ struct v4l2_subdev_pad_ops {
 			      struct v4l2_mbus_frame_desc *fd);
 	int (*set_frame_desc)(struct v4l2_subdev *sd, unsigned int pad,
 			      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);
 };
 
 /**
-- 
2.27.0


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

* [PATCH v6 2/9] media: i2c: Use the new get_mbus_config pad op
  2020-07-14 13:58 [PATCH v6 0/9] v4l2-subdev: Introduce [g|s]et_mbus_format pad op Jacopo Mondi
  2020-07-14 13:58 ` [PATCH v6 1/9] media: v4l2-subdev: Introduce [get|set]_mbus_config pad ops Jacopo Mondi
@ 2020-07-14 13:58 ` Jacopo Mondi
  2020-07-14 13:58 ` [PATCH v6 3/9] media: i2c: ov6650: Use new [get|set]_mbus_config ops Jacopo Mondi
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 21+ messages in thread
From: Jacopo Mondi @ 2020-07-14 13:58 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, sakari.ailus, laurent.pinchart
  Cc: Jacopo Mondi, niklas.soderlund+renesas, kieran.bingham,
	dave.stevenson, hyun.kwon, jmkrzyszt, robert.jarzmik,
	linux-media, linux-renesas-soc

Move the existing users of the g_mbus_config video operation to use the
newly introduced get_mbus_config pad operations.

All the ported drivers report a static media bus configuration and do no
support s_mbus_config so the operation implementation has not changed.

Bridge drivers needs to call the new pad operation and will receive an
-ENOICTLCMD when calling the old g_mbus_config video operation

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 drivers/media/i2c/adv7180.c   | 7 ++++---
 drivers/media/i2c/ml86v7667.c | 7 ++++---
 drivers/media/i2c/mt9m001.c   | 7 ++++---
 drivers/media/i2c/mt9m111.c   | 7 ++++---
 drivers/media/i2c/ov9640.c    | 7 ++++---
 drivers/media/i2c/tc358743.c  | 7 ++++---
 drivers/media/i2c/tvp5150.c   | 7 ++++---
 7 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 00159daa6fcd..e8744efe3cf0 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -760,8 +760,9 @@ static int adv7180_init_cfg(struct v4l2_subdev *sd,
 	return adv7180_set_pad_format(sd, cfg, &fmt);
 }
 
-static int adv7180_g_mbus_config(struct v4l2_subdev *sd,
-				 struct v4l2_mbus_config *cfg)
+static int adv7180_get_mbus_config(struct v4l2_subdev *sd,
+				   unsigned int pad,
+				   struct v4l2_mbus_config *cfg)
 {
 	struct adv7180_state *state = to_state(sd);
 
@@ -852,7 +853,6 @@ static const struct v4l2_subdev_video_ops adv7180_video_ops = {
 	.querystd = adv7180_querystd,
 	.g_input_status = adv7180_g_input_status,
 	.s_routing = adv7180_s_routing,
-	.g_mbus_config = adv7180_g_mbus_config,
 	.g_pixelaspect = adv7180_g_pixelaspect,
 	.g_tvnorms = adv7180_g_tvnorms,
 	.s_stream = adv7180_s_stream,
@@ -869,6 +869,7 @@ static const struct v4l2_subdev_pad_ops adv7180_pad_ops = {
 	.enum_mbus_code = adv7180_enum_mbus_code,
 	.set_fmt = adv7180_set_pad_format,
 	.get_fmt = adv7180_get_pad_format,
+	.get_mbus_config = adv7180_get_mbus_config,
 };
 
 static const struct v4l2_subdev_sensor_ops adv7180_sensor_ops = {
diff --git a/drivers/media/i2c/ml86v7667.c b/drivers/media/i2c/ml86v7667.c
index c444bd6a0658..ff212335326a 100644
--- a/drivers/media/i2c/ml86v7667.c
+++ b/drivers/media/i2c/ml86v7667.c
@@ -219,8 +219,9 @@ static int ml86v7667_fill_fmt(struct v4l2_subdev *sd,
 	return 0;
 }
 
-static int ml86v7667_g_mbus_config(struct v4l2_subdev *sd,
-				   struct v4l2_mbus_config *cfg)
+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;
@@ -291,13 +292,13 @@ static const struct v4l2_subdev_video_ops ml86v7667_subdev_video_ops = {
 	.s_std = ml86v7667_s_std,
 	.querystd = ml86v7667_querystd,
 	.g_input_status = ml86v7667_g_input_status,
-	.g_mbus_config = ml86v7667_g_mbus_config,
 };
 
 static const struct v4l2_subdev_pad_ops ml86v7667_subdev_pad_ops = {
 	.enum_mbus_code = ml86v7667_enum_mbus_code,
 	.get_fmt = ml86v7667_fill_fmt,
 	.set_fmt = ml86v7667_fill_fmt,
+	.get_mbus_config = ml86v7667_get_mbus_config,
 };
 
 static const struct v4l2_subdev_core_ops ml86v7667_subdev_core_ops = {
diff --git a/drivers/media/i2c/mt9m001.c b/drivers/media/i2c/mt9m001.c
index 210ea76adb53..3b0ba8ed5233 100644
--- a/drivers/media/i2c/mt9m001.c
+++ b/drivers/media/i2c/mt9m001.c
@@ -689,8 +689,9 @@ static int mt9m001_enum_mbus_code(struct v4l2_subdev *sd,
 	return 0;
 }
 
-static int mt9m001_g_mbus_config(struct v4l2_subdev *sd,
-				struct v4l2_mbus_config *cfg)
+static int mt9m001_get_mbus_config(struct v4l2_subdev *sd,
+				   unsigned int pad,
+				   struct v4l2_mbus_config *cfg)
 {
 	/* MT9M001 has all capture_format parameters fixed */
 	cfg->flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
@@ -703,7 +704,6 @@ static int mt9m001_g_mbus_config(struct v4l2_subdev *sd,
 
 static const struct v4l2_subdev_video_ops mt9m001_subdev_video_ops = {
 	.s_stream	= mt9m001_s_stream,
-	.g_mbus_config	= mt9m001_g_mbus_config,
 };
 
 static const struct v4l2_subdev_sensor_ops mt9m001_subdev_sensor_ops = {
@@ -717,6 +717,7 @@ static const struct v4l2_subdev_pad_ops mt9m001_subdev_pad_ops = {
 	.set_selection	= mt9m001_set_selection,
 	.get_fmt	= mt9m001_get_fmt,
 	.set_fmt	= mt9m001_set_fmt,
+	.get_mbus_config = mt9m001_get_mbus_config,
 };
 
 static const struct v4l2_subdev_ops mt9m001_subdev_ops = {
diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
index 17e8253f5748..69697386ffcd 100644
--- a/drivers/media/i2c/mt9m111.c
+++ b/drivers/media/i2c/mt9m111.c
@@ -1137,8 +1137,9 @@ static int mt9m111_init_cfg(struct v4l2_subdev *sd,
 	return 0;
 }
 
-static int mt9m111_g_mbus_config(struct v4l2_subdev *sd,
-				struct v4l2_mbus_config *cfg)
+static int mt9m111_get_mbus_config(struct v4l2_subdev *sd,
+				   unsigned int pad,
+				   struct v4l2_mbus_config *cfg)
 {
 	struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev);
 
@@ -1155,7 +1156,6 @@ static int mt9m111_g_mbus_config(struct v4l2_subdev *sd,
 }
 
 static const struct v4l2_subdev_video_ops mt9m111_subdev_video_ops = {
-	.g_mbus_config	= mt9m111_g_mbus_config,
 	.s_stream	= mt9m111_s_stream,
 	.g_frame_interval = mt9m111_g_frame_interval,
 	.s_frame_interval = mt9m111_s_frame_interval,
@@ -1168,6 +1168,7 @@ static const struct v4l2_subdev_pad_ops mt9m111_subdev_pad_ops = {
 	.set_selection	= mt9m111_set_selection,
 	.get_fmt	= mt9m111_get_fmt,
 	.set_fmt	= mt9m111_set_fmt,
+	.get_mbus_config = mt9m111_get_mbus_config,
 };
 
 static const struct v4l2_subdev_ops mt9m111_subdev_ops = {
diff --git a/drivers/media/i2c/ov9640.c b/drivers/media/i2c/ov9640.c
index 3a21f51d9325..fbd5d7b75811 100644
--- a/drivers/media/i2c/ov9640.c
+++ b/drivers/media/i2c/ov9640.c
@@ -648,8 +648,9 @@ static const struct v4l2_subdev_core_ops ov9640_core_ops = {
 };
 
 /* Request bus settings on camera side */
-static int ov9640_g_mbus_config(struct v4l2_subdev *sd,
-				struct v4l2_mbus_config *cfg)
+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 |
@@ -661,13 +662,13 @@ static int ov9640_g_mbus_config(struct v4l2_subdev *sd,
 
 static const struct v4l2_subdev_video_ops ov9640_video_ops = {
 	.s_stream	= ov9640_s_stream,
-	.g_mbus_config	= ov9640_g_mbus_config,
 };
 
 static const struct v4l2_subdev_pad_ops ov9640_pad_ops = {
 	.enum_mbus_code = ov9640_enum_mbus_code,
 	.get_selection	= ov9640_get_selection,
 	.set_fmt	= ov9640_set_fmt,
+	.get_mbus_config = ov9640_get_mbus_config,
 };
 
 static const struct v4l2_subdev_ops ov9640_subdev_ops = {
diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index dbbab75f135e..a03dcab5ce61 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -1602,8 +1602,9 @@ static int tc358743_dv_timings_cap(struct v4l2_subdev *sd,
 	return 0;
 }
 
-static int tc358743_g_mbus_config(struct v4l2_subdev *sd,
-			     struct v4l2_mbus_config *cfg)
+static int tc358743_get_mbus_config(struct v4l2_subdev *sd,
+				    unsigned int pad,
+				    struct v4l2_mbus_config *cfg)
 {
 	struct tc358743_state *state = to_state(sd);
 
@@ -1836,7 +1837,6 @@ static const struct v4l2_subdev_video_ops tc358743_video_ops = {
 	.s_dv_timings = tc358743_s_dv_timings,
 	.g_dv_timings = tc358743_g_dv_timings,
 	.query_dv_timings = tc358743_query_dv_timings,
-	.g_mbus_config = tc358743_g_mbus_config,
 	.s_stream = tc358743_s_stream,
 };
 
@@ -1848,6 +1848,7 @@ static const struct v4l2_subdev_pad_ops tc358743_pad_ops = {
 	.set_edid = tc358743_s_edid,
 	.enum_dv_timings = tc358743_enum_dv_timings,
 	.dv_timings_cap = tc358743_dv_timings_cap,
+	.get_mbus_config = tc358743_get_mbus_config,
 };
 
 static const struct v4l2_subdev_ops tc358743_ops = {
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 9df575238952..1c2050944b92 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -1191,8 +1191,9 @@ static int tvp5150_get_selection(struct v4l2_subdev *sd,
 	}
 }
 
-static int tvp5150_g_mbus_config(struct v4l2_subdev *sd,
-				 struct v4l2_mbus_config *cfg)
+static int tvp5150_get_mbus_config(struct v4l2_subdev *sd,
+				   unsigned int pad,
+				   struct v4l2_mbus_config *cfg)
 {
 	struct tvp5150 *decoder = to_tvp5150(sd);
 
@@ -1721,7 +1722,6 @@ static const struct v4l2_subdev_video_ops tvp5150_video_ops = {
 	.querystd = tvp5150_querystd,
 	.s_stream = tvp5150_s_stream,
 	.s_routing = tvp5150_s_routing,
-	.g_mbus_config = tvp5150_g_mbus_config,
 };
 
 static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = {
@@ -1739,6 +1739,7 @@ static const struct v4l2_subdev_pad_ops tvp5150_pad_ops = {
 	.get_fmt = tvp5150_fill_fmt,
 	.get_selection = tvp5150_get_selection,
 	.set_selection = tvp5150_set_selection,
+	.get_mbus_config = tvp5150_get_mbus_config,
 };
 
 static const struct v4l2_subdev_ops tvp5150_ops = {
-- 
2.27.0


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

* [PATCH v6 3/9] media: i2c: ov6650: Use new [get|set]_mbus_config ops
  2020-07-14 13:58 [PATCH v6 0/9] v4l2-subdev: Introduce [g|s]et_mbus_format pad op Jacopo Mondi
  2020-07-14 13:58 ` [PATCH v6 1/9] media: v4l2-subdev: Introduce [get|set]_mbus_config pad ops Jacopo Mondi
  2020-07-14 13:58 ` [PATCH v6 2/9] media: i2c: Use the new get_mbus_config pad op Jacopo Mondi
@ 2020-07-14 13:58 ` Jacopo Mondi
  2020-07-14 13:58 ` [PATCH v6 4/9] media: pxa_camera: Use the new set_mbus_config op Jacopo Mondi
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 21+ messages in thread
From: Jacopo Mondi @ 2020-07-14 13:58 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, sakari.ailus, laurent.pinchart
  Cc: Jacopo Mondi, niklas.soderlund+renesas, kieran.bingham,
	dave.stevenson, hyun.kwon, jmkrzyszt, robert.jarzmik,
	linux-media, linux-renesas-soc

Use the new get_mbus_config and set_mbus_config pad operations in place
of the video operations currently in use.

Compared to other drivers where the same conversion has been performed,
ov6650 proved to be a bit more tricky, as the existing g_mbus_config
implementation did not report the currently applied configuration but
the set of all possible configuration options.

Adapt the driver to support the semantic of the two newly introduced
operations:
- get_mbus_config reports the current media bus configuration
- set_mbus_config applies only changes explicitly requested and updates
  the provided cfg parameter to report what has actually been applied to
  the hardware.

Compile-tested only.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 drivers/media/i2c/ov6650.c | 56 ++++++++++++++++++++++++++------------
 1 file changed, 38 insertions(+), 18 deletions(-)

diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
index 91906b94f978..b349a9d5986a 100644
--- a/drivers/media/i2c/ov6650.c
+++ b/drivers/media/i2c/ov6650.c
@@ -921,55 +921,73 @@ static const struct v4l2_subdev_core_ops ov6650_core_ops = {
 };
 
 /* Request bus settings on camera side */
-static int ov6650_g_mbus_config(struct v4l2_subdev *sd,
-				struct v4l2_mbus_config *cfg)
+static int ov6650_get_mbus_config(struct v4l2_subdev *sd,
+				  unsigned int pad,
+				  struct v4l2_mbus_config *cfg)
 {
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	u8 comj, comf;
+	int ret;
+
+	ret = ov6650_reg_read(client, REG_COMJ, &comj);
+	if (ret)
+		return ret;
 
-	cfg->flags = V4L2_MBUS_MASTER |
-		V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_PCLK_SAMPLE_FALLING |
-		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_LOW |
-		V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_LOW |
-		V4L2_MBUS_DATA_ACTIVE_HIGH;
+	ret = ov6650_reg_read(client, REG_COMF, &comf);
+	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;
 
 	return 0;
 }
 
 /* Alter bus settings on camera side */
-static int ov6650_s_mbus_config(struct v4l2_subdev *sd,
-				const struct v4l2_mbus_config *cfg)
+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;
+	int ret = 0;
 
 	if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
 		ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_PCLK_RISING, 0);
-	else
+	else if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
 		ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_PCLK_RISING);
 	if (ret)
-		return ret;
+		goto error;
 
 	if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
 		ret = ov6650_reg_rmw(client, REG_COMF, COMF_HREF_LOW, 0);
-	else
+	else if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
 		ret = ov6650_reg_rmw(client, REG_COMF, 0, COMF_HREF_LOW);
 	if (ret)
-		return ret;
+		goto error;
 
 	if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
 		ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_VSYNC_HIGH, 0);
-	else
+	else if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
 		ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_VSYNC_HIGH);
 
-	return ret;
+error:
+	/*
+	 * 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,
 	.s_frame_interval = ov6650_s_frame_interval,
-	.g_mbus_config	= ov6650_g_mbus_config,
-	.s_mbus_config	= ov6650_s_mbus_config,
 };
 
 static const struct v4l2_subdev_pad_ops ov6650_pad_ops = {
@@ -978,6 +996,8 @@ static const struct v4l2_subdev_pad_ops ov6650_pad_ops = {
 	.set_selection	= ov6650_set_selection,
 	.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 = {
-- 
2.27.0


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

* [PATCH v6 4/9] media: pxa_camera: Use the new set_mbus_config op
  2020-07-14 13:58 [PATCH v6 0/9] v4l2-subdev: Introduce [g|s]et_mbus_format pad op Jacopo Mondi
                   ` (2 preceding siblings ...)
  2020-07-14 13:58 ` [PATCH v6 3/9] media: i2c: ov6650: Use new [get|set]_mbus_config ops Jacopo Mondi
@ 2020-07-14 13:58 ` Jacopo Mondi
  2020-07-14 13:58 ` [PATCH v6 5/9] media: v4l2-subdev: Remove [s|g]_mbus_config video ops Jacopo Mondi
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 21+ messages in thread
From: Jacopo Mondi @ 2020-07-14 13:58 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, sakari.ailus, laurent.pinchart
  Cc: Jacopo Mondi, niklas.soderlund+renesas, kieran.bingham,
	dave.stevenson, hyun.kwon, jmkrzyszt, robert.jarzmik,
	linux-media, linux-renesas-soc

Move the PXA camera driver to use the new set_mbus_config pad operation.
For this platform the change is not only cosmetic, as the pxa driver is
currently the only driver in mainline to make use of the g_mbus_config
and s_mbus_config video operations.

The existing driver semantic is the following:
- Collect all supported mbus config flags from the remote end
- Match them with the supported PXA mbus configuration flags
- If the remote subdevice allows multiple options for for VSYNC, HSYNC
  and PCLK polarity, use platform data requested settings

The semantic of the new get_mbus_config and set_mbus_config differs from
the corresponding video ops, particularly in the fact get_mbus_config
reports the current mbus configuration and not the set of supported
configuration options, with set_mbus_config always reporting the actual
mbus configuration applied to the remote subdevice.

Adapt the driver to perform the following
- Set the remote subdevice mbus configuration according to the PXA
  platform data preferences.
- If the applied configuration differs from the requested one (i.e. the
  remote subdevice does not allow changing one setting) make sure that
  - The remote end does not claim for DATA_ACTIVE_LOW, which seems not
    supported by the platform
  - The bus mastering roles match

While at there remove a few checks performed on the media bus
configuration at get_format() time as they do not belong there.

Compile-tested only.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 drivers/media/platform/pxa_camera.c | 189 ++++++++--------------------
 1 file changed, 51 insertions(+), 138 deletions(-)

diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
index 6dce33f35041..0366c4a813ce 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -605,42 +605,6 @@ static const struct pxa_mbus_pixelfmt *pxa_mbus_get_fmtdesc(
 	return pxa_mbus_find_fmtdesc(code, mbus_fmt, ARRAY_SIZE(mbus_fmt));
 }
 
-static unsigned int pxa_mbus_config_compatible(const struct v4l2_mbus_config *cfg,
-					unsigned int flags)
-{
-	unsigned long common_flags;
-	bool hsync = true, vsync = true, pclk, data, mode;
-	bool mipi_lanes, mipi_clock;
-
-	common_flags = cfg->flags & flags;
-
-	switch (cfg->type) {
-	case V4L2_MBUS_PARALLEL:
-		hsync = common_flags & (V4L2_MBUS_HSYNC_ACTIVE_HIGH |
-					V4L2_MBUS_HSYNC_ACTIVE_LOW);
-		vsync = common_flags & (V4L2_MBUS_VSYNC_ACTIVE_HIGH |
-					V4L2_MBUS_VSYNC_ACTIVE_LOW);
-		/* fall through */
-	case V4L2_MBUS_BT656:
-		pclk = common_flags & (V4L2_MBUS_PCLK_SAMPLE_RISING |
-				       V4L2_MBUS_PCLK_SAMPLE_FALLING);
-		data = common_flags & (V4L2_MBUS_DATA_ACTIVE_HIGH |
-				       V4L2_MBUS_DATA_ACTIVE_LOW);
-		mode = common_flags & (V4L2_MBUS_MASTER | V4L2_MBUS_SLAVE);
-		return (!hsync || !vsync || !pclk || !data || !mode) ?
-			0 : common_flags;
-	case V4L2_MBUS_CSI2_DPHY:
-		mipi_lanes = common_flags & V4L2_MBUS_CSI2_LANES;
-		mipi_clock = common_flags & (V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK |
-					     V4L2_MBUS_CSI2_CONTINUOUS_CLOCK);
-		return (!mipi_lanes || !mipi_clock) ? 0 : common_flags;
-	default:
-		WARN_ON(1);
-		return -EINVAL;
-	}
-	return 0;
-}
-
 /**
  * struct pxa_camera_format_xlate - match between host and sensor formats
  * @code: code of a sensor provided format
@@ -1231,31 +1195,6 @@ static irqreturn_t pxa_camera_irq(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static int test_platform_param(struct pxa_camera_dev *pcdev,
-			       unsigned char buswidth, unsigned long *flags)
-{
-	/*
-	 * Platform specified synchronization and pixel clock polarities are
-	 * only a recommendation and are only used during probing. The PXA270
-	 * quick capture interface supports both.
-	 */
-	*flags = (pcdev->platform_flags & PXA_CAMERA_MASTER ?
-		  V4L2_MBUS_MASTER : V4L2_MBUS_SLAVE) |
-		V4L2_MBUS_HSYNC_ACTIVE_HIGH |
-		V4L2_MBUS_HSYNC_ACTIVE_LOW |
-		V4L2_MBUS_VSYNC_ACTIVE_HIGH |
-		V4L2_MBUS_VSYNC_ACTIVE_LOW |
-		V4L2_MBUS_DATA_ACTIVE_HIGH |
-		V4L2_MBUS_PCLK_SAMPLE_RISING |
-		V4L2_MBUS_PCLK_SAMPLE_FALLING;
-
-	/* If requested data width is supported by the platform, use it */
-	if ((1 << (buswidth - 1)) & pcdev->width_flags)
-		return 0;
-
-	return -EINVAL;
-}
-
 static void pxa_camera_setup_cicr(struct pxa_camera_dev *pcdev,
 				  unsigned long flags, __u32 pixfmt)
 {
@@ -1598,99 +1537,78 @@ static int pxa_camera_init_videobuf2(struct pxa_camera_dev *pcdev)
  */
 static int pxa_camera_set_bus_param(struct pxa_camera_dev *pcdev)
 {
+	unsigned int bus_width = pcdev->current_fmt->host_fmt->bits_per_sample;
 	struct v4l2_mbus_config cfg = {.type = V4L2_MBUS_PARALLEL,};
 	u32 pixfmt = pcdev->current_fmt->host_fmt->fourcc;
-	unsigned long bus_flags, common_flags;
+	int mbus_config;
 	int ret;
 
-	ret = test_platform_param(pcdev,
-				  pcdev->current_fmt->host_fmt->bits_per_sample,
-				  &bus_flags);
-	if (ret < 0)
-		return ret;
-
-	ret = sensor_call(pcdev, video, g_mbus_config, &cfg);
-	if (!ret) {
-		common_flags = pxa_mbus_config_compatible(&cfg,
-							  bus_flags);
-		if (!common_flags) {
-			dev_warn(pcdev_to_dev(pcdev),
-				 "Flags incompatible: camera 0x%x, host 0x%lx\n",
-				 cfg.flags, bus_flags);
-			return -EINVAL;
-		}
-	} else if (ret != -ENOIOCTLCMD) {
-		return ret;
-	} else {
-		common_flags = bus_flags;
+	if (!((1 << (bus_width - 1)) & pcdev->width_flags)) {
+		dev_err(pcdev_to_dev(pcdev), "Unsupported bus width %u",
+			bus_width);
+		return -EINVAL;
 	}
 
 	pcdev->channels = 1;
 
 	/* Make choices, based on platform preferences */
-	if ((common_flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) &&
-	    (common_flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)) {
-		if (pcdev->platform_flags & PXA_CAMERA_HSP)
-			common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_HIGH;
-		else
-			common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_LOW;
-	}
+	mbus_config = 0;
+	if (pcdev->platform_flags & PXA_CAMERA_MASTER)
+		mbus_config |= V4L2_MBUS_MASTER;
+	else
+		mbus_config |= V4L2_MBUS_SLAVE;
 
-	if ((common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) &&
-	    (common_flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)) {
-		if (pcdev->platform_flags & PXA_CAMERA_VSP)
-			common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_HIGH;
-		else
-			common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_LOW;
-	}
+	if (pcdev->platform_flags & PXA_CAMERA_HSP)
+		mbus_config |= V4L2_MBUS_HSYNC_ACTIVE_HIGH;
+	else
+		mbus_config |= V4L2_MBUS_HSYNC_ACTIVE_LOW;
 
-	if ((common_flags & V4L2_MBUS_PCLK_SAMPLE_RISING) &&
-	    (common_flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)) {
-		if (pcdev->platform_flags & PXA_CAMERA_PCP)
-			common_flags &= ~V4L2_MBUS_PCLK_SAMPLE_RISING;
-		else
-			common_flags &= ~V4L2_MBUS_PCLK_SAMPLE_FALLING;
-	}
+	if (pcdev->platform_flags & PXA_CAMERA_VSP)
+		mbus_config |= V4L2_MBUS_VSYNC_ACTIVE_HIGH;
+	else
+		mbus_config |= V4L2_MBUS_VSYNC_ACTIVE_LOW;
 
-	cfg.flags = common_flags;
-	ret = sensor_call(pcdev, video, s_mbus_config, &cfg);
+	if (pcdev->platform_flags & PXA_CAMERA_PCP)
+		mbus_config |= V4L2_MBUS_PCLK_SAMPLE_RISING;
+	else
+		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);
 	if (ret < 0 && ret != -ENOIOCTLCMD) {
-		dev_dbg(pcdev_to_dev(pcdev),
-			"camera s_mbus_config(0x%lx) returned %d\n",
-			common_flags, ret);
+		dev_err(pcdev_to_dev(pcdev),
+			"Failed to call set_mbus_config: %d\n", ret);
 		return ret;
 	}
 
-	pxa_camera_setup_cicr(pcdev, common_flags, pixfmt);
-
-	return 0;
-}
-
-static int pxa_camera_try_bus_param(struct pxa_camera_dev *pcdev,
-				    unsigned char buswidth)
-{
-	struct v4l2_mbus_config cfg = {.type = V4L2_MBUS_PARALLEL,};
-	unsigned long bus_flags, common_flags;
-	int ret = test_platform_param(pcdev, buswidth, &bus_flags);
-
-	if (ret < 0)
-		return ret;
+	/*
+	 * If the requested media bus configuration has not been fully applied
+	 * make sure it is supported by the platform.
+	 *
+	 * PXA does not support V4L2_MBUS_DATA_ACTIVE_LOW and the bus mastering
+	 * roles should match.
+	 */
+	if (cfg.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))) {
+			dev_err(pcdev_to_dev(pcdev),
+				"Unsupported mbus configuration: bus mastering\n");
+			return -EINVAL;
+		}
 
-	ret = sensor_call(pcdev, video, g_mbus_config, &cfg);
-	if (!ret) {
-		common_flags = pxa_mbus_config_compatible(&cfg,
-							  bus_flags);
-		if (!common_flags) {
-			dev_warn(pcdev_to_dev(pcdev),
-				 "Flags incompatible: camera 0x%x, host 0x%lx\n",
-				 cfg.flags, bus_flags);
+		if (cfg.flags & V4L2_MBUS_DATA_ACTIVE_LOW) {
+			dev_err(pcdev_to_dev(pcdev),
+				"Unsupported mbus configuration: DATA_ACTIVE_LOW\n");
 			return -EINVAL;
 		}
-	} else if (ret == -ENOIOCTLCMD) {
-		ret = 0;
 	}
 
-	return ret;
+	pxa_camera_setup_cicr(pcdev, cfg.flags, pixfmt);
+
+	return 0;
 }
 
 static const struct pxa_mbus_pixelfmt pxa_camera_formats[] = {
@@ -1738,11 +1656,6 @@ static int pxa_camera_get_formats(struct v4l2_device *v4l2_dev,
 		return 0;
 	}
 
-	/* This also checks support for the requested bits-per-sample */
-	ret = pxa_camera_try_bus_param(pcdev, fmt->bits_per_sample);
-	if (ret < 0)
-		return 0;
-
 	switch (code.code) {
 	case MEDIA_BUS_FMT_UYVY8_2X8:
 		formats++;
-- 
2.27.0


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

* [PATCH v6 5/9] media: v4l2-subdev: Remove [s|g]_mbus_config video ops
  2020-07-14 13:58 [PATCH v6 0/9] v4l2-subdev: Introduce [g|s]et_mbus_format pad op Jacopo Mondi
                   ` (3 preceding siblings ...)
  2020-07-14 13:58 ` [PATCH v6 4/9] media: pxa_camera: Use the new set_mbus_config op Jacopo Mondi
@ 2020-07-14 13:58 ` Jacopo Mondi
  2020-07-14 13:58 ` [PATCH v6 6/9] staging: media: imx: Update TODO entry Jacopo Mondi
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 21+ messages in thread
From: Jacopo Mondi @ 2020-07-14 13:58 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, sakari.ailus, laurent.pinchart
  Cc: Jacopo Mondi, niklas.soderlund+renesas, kieran.bingham,
	dave.stevenson, hyun.kwon, jmkrzyszt, robert.jarzmik,
	linux-media, linux-renesas-soc

With all sensor and platform drivers now converted to use the new
get_mbus_config and set_mbus_config pad operations, remove the
deprecated video operations g_mbus_config and s_mbus_config.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 include/media/v4l2-subdev.h | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index d8b9d5735307..98975248a033 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -402,12 +402,6 @@ struct v4l2_mbus_frame_desc {
  *
  * @query_dv_timings: callback for VIDIOC_QUERY_DV_TIMINGS() ioctl handler code.
  *
- * @g_mbus_config: get supported mediabus configurations
- *
- * @s_mbus_config: set a certain mediabus configuration. This operation is added
- *	for compatibility with soc-camera drivers and should not be used by new
- *	software.
- *
  * @s_rx_buffer: set a host allocated memory buffer for the subdev. The subdev
  *	can adjust @size to a lower value and must not write more data to the
  *	buffer starting at @data than the original value of @size.
@@ -435,10 +429,6 @@ struct v4l2_subdev_video_ops {
 			struct v4l2_dv_timings *timings);
 	int (*query_dv_timings)(struct v4l2_subdev *sd,
 			struct v4l2_dv_timings *timings);
-	int (*g_mbus_config)(struct v4l2_subdev *sd,
-			     struct v4l2_mbus_config *cfg);
-	int (*s_mbus_config)(struct v4l2_subdev *sd,
-			     const struct v4l2_mbus_config *cfg);
 	int (*s_rx_buffer)(struct v4l2_subdev *sd, void *buf,
 			   unsigned int *size);
 };
-- 
2.27.0


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

* [PATCH v6 6/9] staging: media: imx: Update TODO entry
  2020-07-14 13:58 [PATCH v6 0/9] v4l2-subdev: Introduce [g|s]et_mbus_format pad op Jacopo Mondi
                   ` (4 preceding siblings ...)
  2020-07-14 13:58 ` [PATCH v6 5/9] media: v4l2-subdev: Remove [s|g]_mbus_config video ops Jacopo Mondi
@ 2020-07-14 13:58 ` Jacopo Mondi
  2020-07-14 13:58 ` [PATCH v6 7/9] media: i2c: adv748x: Adjust TXA data lanes number Jacopo Mondi
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 21+ messages in thread
From: Jacopo Mondi @ 2020-07-14 13:58 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, sakari.ailus, laurent.pinchart
  Cc: Jacopo Mondi, niklas.soderlund+renesas, kieran.bingham,
	dave.stevenson, hyun.kwon, jmkrzyszt, robert.jarzmik,
	linux-media, linux-renesas-soc

Update the TODO entry that mentioned a potential use case for the now
removed g_mbus_config video operation.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 drivers/staging/media/imx/TODO | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/media/imx/TODO b/drivers/staging/media/imx/TODO
index a371cdedcdb0..9cfc1c1e78dc 100644
--- a/drivers/staging/media/imx/TODO
+++ b/drivers/staging/media/imx/TODO
@@ -10,6 +10,10 @@
   driver uses the parsed DT bus config method until this issue is
   resolved.
 
+  2020-06: g_mbus has been removed in favour of the get_mbus_config pad
+  operation which should be used to avoid parsing the remote endpoint
+  configuration.
+
 - This media driver supports inheriting V4L2 controls to the
   video capture devices, from the subdevices in the capture device's
   pipeline. The controls for each capture device are updated in the
-- 
2.27.0


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

* [PATCH v6 7/9] media: i2c: adv748x: Adjust TXA data lanes number
  2020-07-14 13:58 [PATCH v6 0/9] v4l2-subdev: Introduce [g|s]et_mbus_format pad op Jacopo Mondi
                   ` (5 preceding siblings ...)
  2020-07-14 13:58 ` [PATCH v6 6/9] staging: media: imx: Update TODO entry Jacopo Mondi
@ 2020-07-14 13:58 ` Jacopo Mondi
  2020-07-14 13:58 ` [PATCH v6 8/9] media: i2c: adv748x: Implement get_mbus_config Jacopo Mondi
  2020-07-14 13:58 ` [PATCH v6 9/9] media: rcar-csi2: Negotiate data lanes number Jacopo Mondi
  8 siblings, 0 replies; 21+ messages in thread
From: Jacopo Mondi @ 2020-07-14 13:58 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, sakari.ailus, laurent.pinchart
  Cc: Jacopo Mondi, niklas.soderlund+renesas, kieran.bingham,
	dave.stevenson, hyun.kwon, jmkrzyszt, robert.jarzmik,
	linux-media, linux-renesas-soc, Kieran Bingham

When outputting SD-Core output through the TXA MIPI CSI-2 interface,
the number of enabled data lanes should be reduced in order to guarantee
that the two video formats produced by the SD-Core (480i and 576i)
generate a MIPI CSI-2 link clock frequency compatible with the MIPI D-PHY
specifications.

Limit the number of enabled data lanes to 2, which is guaranteed to
support 480i and 576i formats.

Cache the number of enabled data lanes to be able to report it through
the new get_mbus_config operation.

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 drivers/media/i2c/adv748x/adv748x-core.c | 31 ++++++++++++++++++------
 drivers/media/i2c/adv748x/adv748x.h      |  1 +
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
index 23e02ff27b17..1fe7f97c6d52 100644
--- a/drivers/media/i2c/adv748x/adv748x-core.c
+++ b/drivers/media/i2c/adv748x/adv748x-core.c
@@ -241,10 +241,10 @@ static int adv748x_power_up_tx(struct adv748x_csi2 *tx)
 	int ret = 0;
 
 	/* Enable n-lane MIPI */
-	adv748x_write_check(state, page, 0x00, 0x80 | tx->num_lanes, &ret);
+	adv748x_write_check(state, page, 0x00, 0x80 | tx->active_lanes, &ret);
 
 	/* Set Auto DPHY Timing */
-	adv748x_write_check(state, page, 0x00, 0xa0 | tx->num_lanes, &ret);
+	adv748x_write_check(state, page, 0x00, 0xa0 | tx->active_lanes, &ret);
 
 	/* ADI Required Write */
 	if (tx->src == &state->hdmi.sd) {
@@ -270,7 +270,7 @@ static int adv748x_power_up_tx(struct adv748x_csi2 *tx)
 	usleep_range(2000, 2500);
 
 	/* Power-up CSI-TX */
-	adv748x_write_check(state, page, 0x00, 0x20 | tx->num_lanes, &ret);
+	adv748x_write_check(state, page, 0x00, 0x20 | tx->active_lanes, &ret);
 	usleep_range(1000, 1500);
 
 	/* ADI Required Writes */
@@ -292,7 +292,7 @@ static int adv748x_power_down_tx(struct adv748x_csi2 *tx)
 	adv748x_write_check(state, page, 0x1e, 0x00, &ret);
 
 	/* Enable n-lane MIPI */
-	adv748x_write_check(state, page, 0x00, 0x80 | tx->num_lanes, &ret);
+	adv748x_write_check(state, page, 0x00, 0x80 | tx->active_lanes, &ret);
 
 	/* i2c_mipi_pll_en - 1'b1 */
 	adv748x_write_check(state, page, 0xda, 0x01, &ret);
@@ -357,14 +357,29 @@ static int adv748x_link_setup(struct media_entity *entity,
 	if (state->afe.tx) {
 		/* AFE Requires TXA enabled, even when output to TXB */
 		io10 |= ADV748X_IO_10_CSI4_EN;
-		if (is_txa(tx))
+		if (is_txa(tx)) {
+			/*
+			 * Output from the SD-core (480i and 576i) from the TXA
+			 * interface requires reducing the number of enabled
+			 * data lanes in order to guarantee a valid link
+			 * frequency.
+			 */
+			tx->active_lanes = min(tx->num_lanes, 2U);
 			io10 |= ADV748X_IO_10_CSI4_IN_SEL_AFE;
-		else
+		} else {
+			/* TXB has a single data lane, no need to adjust. */
 			io10 |= ADV748X_IO_10_CSI1_EN;
+		}
 	}
 
-	if (state->hdmi.tx)
+	if (state->hdmi.tx) {
+		/*
+		 * Restore the number of active lanes, in case we have gone
+		 * through an AFE->TXA streaming sessions.
+		 */
+		tx->active_lanes = tx->num_lanes;
 		io10 |= ADV748X_IO_10_CSI4_EN;
+	}
 
 	return io_clrset(state, ADV748X_IO_10, io10_mask, io10);
 }
@@ -596,6 +611,7 @@ static int adv748x_parse_csi2_lanes(struct adv748x_state *state,
 		}
 
 		state->txa.num_lanes = num_lanes;
+		state->txa.active_lanes = num_lanes;
 		adv_dbg(state, "TXA: using %u lanes\n", state->txa.num_lanes);
 	}
 
@@ -607,6 +623,7 @@ static int adv748x_parse_csi2_lanes(struct adv748x_state *state,
 		}
 
 		state->txb.num_lanes = num_lanes;
+		state->txb.active_lanes = num_lanes;
 		adv_dbg(state, "TXB: using %u lanes\n", state->txb.num_lanes);
 	}
 
diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h
index fccb388ce179..1061f425ece5 100644
--- a/drivers/media/i2c/adv748x/adv748x.h
+++ b/drivers/media/i2c/adv748x/adv748x.h
@@ -79,6 +79,7 @@ struct adv748x_csi2 {
 	unsigned int page;
 	unsigned int port;
 	unsigned int num_lanes;
+	unsigned int active_lanes;
 
 	struct media_pad pads[ADV748X_CSI2_NR_PADS];
 	struct v4l2_ctrl_handler ctrl_hdl;
-- 
2.27.0


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

* [PATCH v6 8/9] media: i2c: adv748x: Implement get_mbus_config
  2020-07-14 13:58 [PATCH v6 0/9] v4l2-subdev: Introduce [g|s]et_mbus_format pad op Jacopo Mondi
                   ` (6 preceding siblings ...)
  2020-07-14 13:58 ` [PATCH v6 7/9] media: i2c: adv748x: Adjust TXA data lanes number Jacopo Mondi
@ 2020-07-14 13:58 ` Jacopo Mondi
  2020-07-14 13:58 ` [PATCH v6 9/9] media: rcar-csi2: Negotiate data lanes number Jacopo Mondi
  8 siblings, 0 replies; 21+ messages in thread
From: Jacopo Mondi @ 2020-07-14 13:58 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, sakari.ailus, laurent.pinchart
  Cc: Jacopo Mondi, niklas.soderlund+renesas, kieran.bingham,
	dave.stevenson, hyun.kwon, jmkrzyszt, robert.jarzmik,
	linux-media, linux-renesas-soc, Kieran Bingham

Implement the newly introduced get_mbus_config operation to report the
number of currently used data lanes on the MIPI CSI-2 interface.

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 drivers/media/i2c/adv748x/adv748x-csi2.c | 31 ++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c
index 2091cda50935..99bb63d05eef 100644
--- a/drivers/media/i2c/adv748x/adv748x-csi2.c
+++ b/drivers/media/i2c/adv748x/adv748x-csi2.c
@@ -214,9 +214,40 @@ static int adv748x_csi2_set_format(struct v4l2_subdev *sd,
 	return ret;
 }
 
+static int adv748x_csi2_get_mbus_config(struct v4l2_subdev *sd, unsigned int pad,
+					struct v4l2_mbus_config *config)
+{
+	struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd);
+
+	if (pad != ADV748X_CSI2_SOURCE)
+		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;
+	}
+
+	return 0;
+}
+
 static const struct v4l2_subdev_pad_ops adv748x_csi2_pad_ops = {
 	.get_fmt = adv748x_csi2_get_format,
 	.set_fmt = adv748x_csi2_set_format,
+	.get_mbus_config = adv748x_csi2_get_mbus_config,
 };
 
 /* -----------------------------------------------------------------------------
-- 
2.27.0


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

* [PATCH v6 9/9] media: rcar-csi2: Negotiate data lanes number
  2020-07-14 13:58 [PATCH v6 0/9] v4l2-subdev: Introduce [g|s]et_mbus_format pad op Jacopo Mondi
                   ` (7 preceding siblings ...)
  2020-07-14 13:58 ` [PATCH v6 8/9] media: i2c: adv748x: Implement get_mbus_config Jacopo Mondi
@ 2020-07-14 13:58 ` Jacopo Mondi
  2020-07-15  6:55   ` Niklas Söderlund
  2020-07-15 14:38   ` [PATCH v6.1 " Jacopo Mondi
  8 siblings, 2 replies; 21+ messages in thread
From: Jacopo Mondi @ 2020-07-14 13:58 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, sakari.ailus, laurent.pinchart
  Cc: Jacopo Mondi, niklas.soderlund+renesas, kieran.bingham,
	dave.stevenson, hyun.kwon, jmkrzyszt, robert.jarzmik,
	linux-media, linux-renesas-soc

Use the newly introduced get_mbus_config() subdevice pad operation to
retrieve the remote subdevice MIPI CSI-2 bus configuration and configure
the number of active data lanes accordingly.

In order to be able to call the remote subdevice operation cache the
index of the remote pad connected to the single CSI-2 input port.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 drivers/media/platform/rcar-vin/rcar-csi2.c | 74 +++++++++++++++++++--
 1 file changed, 67 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
index c6cc4f473a07..d39f312ebff9 100644
--- a/drivers/media/platform/rcar-vin/rcar-csi2.c
+++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
@@ -364,6 +364,7 @@ struct rcar_csi2 {
 	struct v4l2_async_notifier notifier;
 	struct v4l2_async_subdev asd;
 	struct v4l2_subdev *remote;
+	unsigned int remote_pad;
 
 	struct v4l2_mbus_framefmt mf;
 
@@ -409,13 +410,14 @@ static void rcsi2_exit_standby(struct rcar_csi2 *priv)
 	reset_control_deassert(priv->rstc);
 }
 
-static int rcsi2_wait_phy_start(struct rcar_csi2 *priv)
+static int rcsi2_wait_phy_start(struct rcar_csi2 *priv,
+				unsigned int active_lanes)
 {
 	unsigned int timeout;
 
 	/* Wait for the clock and data lanes to enter LP-11 state. */
 	for (timeout = 0; timeout <= 20; timeout++) {
-		const u32 lane_mask = (1 << priv->lanes) - 1;
+		const u32 lane_mask = (1 << active_lanes) - 1;
 
 		if ((rcsi2_read(priv, PHCLM_REG) & PHCLM_STOPSTATECKL)  &&
 		    (rcsi2_read(priv, PHDLM_REG) & lane_mask) == lane_mask)
@@ -447,7 +449,8 @@ static int rcsi2_set_phypll(struct rcar_csi2 *priv, unsigned int mbps)
 	return 0;
 }
 
-static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp)
+static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp,
+			   unsigned int active_lanes)
 {
 	struct v4l2_subdev *source;
 	struct v4l2_ctrl *ctrl;
@@ -472,15 +475,63 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp)
 	 * bps = link_freq * 2
 	 */
 	mbps = v4l2_ctrl_g_ctrl_int64(ctrl) * bpp;
-	do_div(mbps, priv->lanes * 1000000);
+	do_div(mbps, active_lanes * 1000000);
 
 	return mbps;
 }
 
+static int rcsi2_config_active_lanes(struct rcar_csi2 *priv,
+				     unsigned int *active_lanes)
+{
+	struct v4l2_mbus_config mbus_config = { 0 };
+	unsigned int num_lanes = (-1U);
+	int ret;
+
+	*active_lanes = priv->lanes;
+	ret = v4l2_subdev_call(priv->remote, pad, get_mbus_config,
+			       priv->remote_pad, &mbus_config);
+	if (ret == -ENOIOCTLCMD) {
+		dev_dbg(priv->dev, "No remote mbus configuration available\n");
+		return 0;
+	}
+
+	if (ret) {
+		dev_err(priv->dev, "Failed to get remote mbus configuration\n");
+		return ret;
+	}
+
+	if (mbus_config.type != V4L2_MBUS_CSI2_DPHY) {
+		dev_err(priv->dev, "Unsupported media bus type %u\n",
+			mbus_config.type);
+		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) {
+		dev_err(priv->dev,
+			"Unsupported mbus config: too many data lanes %u\n",
+			num_lanes);
+		return -EINVAL;
+	}
+
+	*active_lanes = num_lanes;
+
+	return 0;
+}
+
 static int rcsi2_start_receiver(struct rcar_csi2 *priv)
 {
 	const struct rcar_csi2_format *format;
 	u32 phycnt, vcdt = 0, vcdt2 = 0, fld = 0;
+	unsigned int active_lanes;
 	unsigned int i;
 	int mbps, ret;
 
@@ -522,10 +573,18 @@ static int rcsi2_start_receiver(struct rcar_csi2 *priv)
 			fld |= FLD_FLD_NUM(1);
 	}
 
+	/*
+	 * Get the number of active data lanes inspecting the remote mbus
+	 * configuration.
+	 */
+	ret = rcsi2_config_active_lanes(priv, &active_lanes);
+	if (ret)
+		return ret;
+
 	phycnt = PHYCNT_ENABLECLK;
-	phycnt |= (1 << priv->lanes) - 1;
+	phycnt |= (1 << active_lanes) - 1;
 
-	mbps = rcsi2_calc_mbps(priv, format->bpp);
+	mbps = rcsi2_calc_mbps(priv, format->bpp, active_lanes);
 	if (mbps < 0)
 		return mbps;
 
@@ -572,7 +631,7 @@ static int rcsi2_start_receiver(struct rcar_csi2 *priv)
 	rcsi2_write(priv, PHYCNT_REG, phycnt | PHYCNT_SHUTDOWNZ);
 	rcsi2_write(priv, PHYCNT_REG, phycnt | PHYCNT_SHUTDOWNZ | PHYCNT_RSTZ);
 
-	ret = rcsi2_wait_phy_start(priv);
+	ret = rcsi2_wait_phy_start(priv, active_lanes);
 	if (ret)
 		return ret;
 
@@ -749,6 +808,7 @@ static int rcsi2_notify_bound(struct v4l2_async_notifier *notifier,
 	}
 
 	priv->remote = subdev;
+	priv->remote_pad = pad;
 
 	dev_dbg(priv->dev, "Bound %s pad: %d\n", subdev->name, pad);
 
-- 
2.27.0


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

* Re: [PATCH v6 9/9] media: rcar-csi2: Negotiate data lanes number
  2020-07-14 13:58 ` [PATCH v6 9/9] media: rcar-csi2: Negotiate data lanes number Jacopo Mondi
@ 2020-07-15  6:55   ` Niklas Söderlund
  2020-07-15  7:13     ` Jacopo Mondi
  2020-07-15 14:38   ` [PATCH v6.1 " Jacopo Mondi
  1 sibling, 1 reply; 21+ messages in thread
From: Niklas Söderlund @ 2020-07-15  6:55 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: mchehab, hverkuil-cisco, sakari.ailus, laurent.pinchart,
	kieran.bingham, dave.stevenson, hyun.kwon, jmkrzyszt,
	robert.jarzmik, linux-media, linux-renesas-soc

Hi Jacopo,

Thanks for your work.

On 2020-07-14 15:58:12 +0200, Jacopo Mondi wrote:
> Use the newly introduced get_mbus_config() subdevice pad operation to
> retrieve the remote subdevice MIPI CSI-2 bus configuration and configure
> the number of active data lanes accordingly.
> 
> In order to be able to call the remote subdevice operation cache the
> index of the remote pad connected to the single CSI-2 input port.
> 
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> ---
>  drivers/media/platform/rcar-vin/rcar-csi2.c | 74 +++++++++++++++++++--
>  1 file changed, 67 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
> index c6cc4f473a07..d39f312ebff9 100644
> --- a/drivers/media/platform/rcar-vin/rcar-csi2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
> @@ -364,6 +364,7 @@ struct rcar_csi2 {
>  	struct v4l2_async_notifier notifier;
>  	struct v4l2_async_subdev asd;
>  	struct v4l2_subdev *remote;
> +	unsigned int remote_pad;
>  
>  	struct v4l2_mbus_framefmt mf;
>  
> @@ -409,13 +410,14 @@ static void rcsi2_exit_standby(struct rcar_csi2 *priv)
>  	reset_control_deassert(priv->rstc);
>  }
>  
> -static int rcsi2_wait_phy_start(struct rcar_csi2 *priv)
> +static int rcsi2_wait_phy_start(struct rcar_csi2 *priv,
> +				unsigned int active_lanes)

Maybe s/active_lanes/lanes/ here and below?

>  {
>  	unsigned int timeout;
>  
>  	/* Wait for the clock and data lanes to enter LP-11 state. */
>  	for (timeout = 0; timeout <= 20; timeout++) {
> -		const u32 lane_mask = (1 << priv->lanes) - 1;
> +		const u32 lane_mask = (1 << active_lanes) - 1;
>  
>  		if ((rcsi2_read(priv, PHCLM_REG) & PHCLM_STOPSTATECKL)  &&
>  		    (rcsi2_read(priv, PHDLM_REG) & lane_mask) == lane_mask)
> @@ -447,7 +449,8 @@ static int rcsi2_set_phypll(struct rcar_csi2 *priv, unsigned int mbps)
>  	return 0;
>  }
>  
> -static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp)
> +static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp,
> +			   unsigned int active_lanes)
>  {
>  	struct v4l2_subdev *source;
>  	struct v4l2_ctrl *ctrl;
> @@ -472,15 +475,63 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp)
>  	 * bps = link_freq * 2
>  	 */
>  	mbps = v4l2_ctrl_g_ctrl_int64(ctrl) * bpp;
> -	do_div(mbps, priv->lanes * 1000000);
> +	do_div(mbps, active_lanes * 1000000);
>  
>  	return mbps;
>  }
>  
> +static int rcsi2_config_active_lanes(struct rcar_csi2 *priv,
> +				     unsigned int *active_lanes)

I would name this rcsi2_get_active_lanes() as it does not configure 
anything just queries the subdevice for information.

> +{
> +	struct v4l2_mbus_config mbus_config = { 0 };
> +	unsigned int num_lanes = (-1U);

This looks odd and could just be set 0 with the same effect but clearer 
to read.

> +	int ret;
> +
> +	*active_lanes = priv->lanes;
> +	ret = v4l2_subdev_call(priv->remote, pad, get_mbus_config,
> +			       priv->remote_pad, &mbus_config);
> +	if (ret == -ENOIOCTLCMD) {
> +		dev_dbg(priv->dev, "No remote mbus configuration available\n");
> +		return 0;
> +	}
> +
> +	if (ret) {
> +		dev_err(priv->dev, "Failed to get remote mbus configuration\n");
> +		return ret;
> +	}
> +
> +	if (mbus_config.type != V4L2_MBUS_CSI2_DPHY) {
> +		dev_err(priv->dev, "Unsupported media bus type %u\n",
> +			mbus_config.type);
> +		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) {
> +		dev_err(priv->dev,
> +			"Unsupported mbus config: too many data lanes %u\n",
> +			num_lanes);
> +		return -EINVAL;
> +	}
> +
> +	*active_lanes = num_lanes;
> +
> +	return 0;
> +}
> +
>  static int rcsi2_start_receiver(struct rcar_csi2 *priv)
>  {
>  	const struct rcar_csi2_format *format;
>  	u32 phycnt, vcdt = 0, vcdt2 = 0, fld = 0;
> +	unsigned int active_lanes;
>  	unsigned int i;
>  	int mbps, ret;
>  
> @@ -522,10 +573,18 @@ static int rcsi2_start_receiver(struct rcar_csi2 *priv)
>  			fld |= FLD_FLD_NUM(1);
>  	}
>  
> +	/*
> +	 * Get the number of active data lanes inspecting the remote mbus
> +	 * configuration.
> +	 */
> +	ret = rcsi2_config_active_lanes(priv, &active_lanes);
> +	if (ret)
> +		return ret;
> +
>  	phycnt = PHYCNT_ENABLECLK;
> -	phycnt |= (1 << priv->lanes) - 1;
> +	phycnt |= (1 << active_lanes) - 1;
>  
> -	mbps = rcsi2_calc_mbps(priv, format->bpp);
> +	mbps = rcsi2_calc_mbps(priv, format->bpp, active_lanes);
>  	if (mbps < 0)
>  		return mbps;
>  
> @@ -572,7 +631,7 @@ static int rcsi2_start_receiver(struct rcar_csi2 *priv)
>  	rcsi2_write(priv, PHYCNT_REG, phycnt | PHYCNT_SHUTDOWNZ);
>  	rcsi2_write(priv, PHYCNT_REG, phycnt | PHYCNT_SHUTDOWNZ | PHYCNT_RSTZ);
>  
> -	ret = rcsi2_wait_phy_start(priv);
> +	ret = rcsi2_wait_phy_start(priv, active_lanes);
>  	if (ret)
>  		return ret;
>  
> @@ -749,6 +808,7 @@ static int rcsi2_notify_bound(struct v4l2_async_notifier *notifier,
>  	}
>  
>  	priv->remote = subdev;
> +	priv->remote_pad = pad;
>  
>  	dev_dbg(priv->dev, "Bound %s pad: %d\n", subdev->name, pad);
>  
> -- 
> 2.27.0
> 

-- 
Regards,
Niklas Söderlund

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

* Re: [PATCH v6 9/9] media: rcar-csi2: Negotiate data lanes number
  2020-07-15  6:55   ` Niklas Söderlund
@ 2020-07-15  7:13     ` Jacopo Mondi
  2020-07-15  8:20       ` Niklas Söderlund
  0 siblings, 1 reply; 21+ messages in thread
From: Jacopo Mondi @ 2020-07-15  7:13 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Jacopo Mondi, mchehab, hverkuil-cisco, sakari.ailus,
	laurent.pinchart, kieran.bingham, dave.stevenson, hyun.kwon,
	jmkrzyszt, robert.jarzmik, linux-media, linux-renesas-soc

Hi Niklas,

On Wed, Jul 15, 2020 at 08:55:38AM +0200, Niklas Söderlund wrote:
> Hi Jacopo,
>
> Thanks for your work.
>
> On 2020-07-14 15:58:12 +0200, Jacopo Mondi wrote:
> > Use the newly introduced get_mbus_config() subdevice pad operation to
> > retrieve the remote subdevice MIPI CSI-2 bus configuration and configure
> > the number of active data lanes accordingly.
> >
> > In order to be able to call the remote subdevice operation cache the
> > index of the remote pad connected to the single CSI-2 input port.
> >
> > Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> > ---
> >  drivers/media/platform/rcar-vin/rcar-csi2.c | 74 +++++++++++++++++++--
> >  1 file changed, 67 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
> > index c6cc4f473a07..d39f312ebff9 100644
> > --- a/drivers/media/platform/rcar-vin/rcar-csi2.c
> > +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
> > @@ -364,6 +364,7 @@ struct rcar_csi2 {
> >  	struct v4l2_async_notifier notifier;
> >  	struct v4l2_async_subdev asd;
> >  	struct v4l2_subdev *remote;
> > +	unsigned int remote_pad;
> >
> >  	struct v4l2_mbus_framefmt mf;
> >
> > @@ -409,13 +410,14 @@ static void rcsi2_exit_standby(struct rcar_csi2 *priv)
> >  	reset_control_deassert(priv->rstc);
> >  }
> >
> > -static int rcsi2_wait_phy_start(struct rcar_csi2 *priv)
> > +static int rcsi2_wait_phy_start(struct rcar_csi2 *priv,
> > +				unsigned int active_lanes)
>
> Maybe s/active_lanes/lanes/ here and below?
>

ok, I guess it's not important to convey the distinction between
active and available lanes here.

> >  {
> >  	unsigned int timeout;
> >
> >  	/* Wait for the clock and data lanes to enter LP-11 state. */
> >  	for (timeout = 0; timeout <= 20; timeout++) {
> > -		const u32 lane_mask = (1 << priv->lanes) - 1;
> > +		const u32 lane_mask = (1 << active_lanes) - 1;
> >
> >  		if ((rcsi2_read(priv, PHCLM_REG) & PHCLM_STOPSTATECKL)  &&
> >  		    (rcsi2_read(priv, PHDLM_REG) & lane_mask) == lane_mask)
> > @@ -447,7 +449,8 @@ static int rcsi2_set_phypll(struct rcar_csi2 *priv, unsigned int mbps)
> >  	return 0;
> >  }
> >
> > -static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp)
> > +static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp,
> > +			   unsigned int active_lanes)
> >  {
> >  	struct v4l2_subdev *source;
> >  	struct v4l2_ctrl *ctrl;
> > @@ -472,15 +475,63 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp)
> >  	 * bps = link_freq * 2
> >  	 */
> >  	mbps = v4l2_ctrl_g_ctrl_int64(ctrl) * bpp;
> > -	do_div(mbps, priv->lanes * 1000000);
> > +	do_div(mbps, active_lanes * 1000000);
> >
> >  	return mbps;
> >  }
> >
> > +static int rcsi2_config_active_lanes(struct rcar_csi2 *priv,
> > +				     unsigned int *active_lanes)
>
> I would name this rcsi2_get_active_lanes() as it does not configure
> anything just queries the subdevice for information.
>

ack

> > +{
> > +	struct v4l2_mbus_config mbus_config = { 0 };
> > +	unsigned int num_lanes = (-1U);
>
> This looks odd and could just be set 0 with the same effect but clearer
> to read.
>

Not really.

Have a look at this part:

	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) {

        ^^ I should then change this one to:

        if (!num_lanes)

But this does not protect against the case num_lanes is actually set
to a meaningful value, but it's larger than the number of actually
available lanes (which is held by priv->lanes).

I would keep this one as it is.

Thanks
  j

> > +	int ret;
> > +
> > +	*active_lanes = priv->lanes;
> > +	ret = v4l2_subdev_call(priv->remote, pad, get_mbus_config,
> > +			       priv->remote_pad, &mbus_config);
> > +	if (ret == -ENOIOCTLCMD) {
> > +		dev_dbg(priv->dev, "No remote mbus configuration available\n");
> > +		return 0;
> > +	}
> > +
> > +	if (ret) {
> > +		dev_err(priv->dev, "Failed to get remote mbus configuration\n");
> > +		return ret;
> > +	}
> > +
> > +	if (mbus_config.type != V4L2_MBUS_CSI2_DPHY) {
> > +		dev_err(priv->dev, "Unsupported media bus type %u\n",
> > +			mbus_config.type);
> > +		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) {
> > +		dev_err(priv->dev,
> > +			"Unsupported mbus config: too many data lanes %u\n",
> > +			num_lanes);
> > +		return -EINVAL;
> > +	}
> > +
> > +	*active_lanes = num_lanes;
> > +
> > +	return 0;
> > +}
> > +
> >  static int rcsi2_start_receiver(struct rcar_csi2 *priv)
> >  {
> >  	const struct rcar_csi2_format *format;
> >  	u32 phycnt, vcdt = 0, vcdt2 = 0, fld = 0;
> > +	unsigned int active_lanes;
> >  	unsigned int i;
> >  	int mbps, ret;
> >
> > @@ -522,10 +573,18 @@ static int rcsi2_start_receiver(struct rcar_csi2 *priv)
> >  			fld |= FLD_FLD_NUM(1);
> >  	}
> >
> > +	/*
> > +	 * Get the number of active data lanes inspecting the remote mbus
> > +	 * configuration.
> > +	 */
> > +	ret = rcsi2_config_active_lanes(priv, &active_lanes);
> > +	if (ret)
> > +		return ret;
> > +
> >  	phycnt = PHYCNT_ENABLECLK;
> > -	phycnt |= (1 << priv->lanes) - 1;
> > +	phycnt |= (1 << active_lanes) - 1;
> >
> > -	mbps = rcsi2_calc_mbps(priv, format->bpp);
> > +	mbps = rcsi2_calc_mbps(priv, format->bpp, active_lanes);
> >  	if (mbps < 0)
> >  		return mbps;
> >
> > @@ -572,7 +631,7 @@ static int rcsi2_start_receiver(struct rcar_csi2 *priv)
> >  	rcsi2_write(priv, PHYCNT_REG, phycnt | PHYCNT_SHUTDOWNZ);
> >  	rcsi2_write(priv, PHYCNT_REG, phycnt | PHYCNT_SHUTDOWNZ | PHYCNT_RSTZ);
> >
> > -	ret = rcsi2_wait_phy_start(priv);
> > +	ret = rcsi2_wait_phy_start(priv, active_lanes);
> >  	if (ret)
> >  		return ret;
> >
> > @@ -749,6 +808,7 @@ static int rcsi2_notify_bound(struct v4l2_async_notifier *notifier,
> >  	}
> >
> >  	priv->remote = subdev;
> > +	priv->remote_pad = pad;
> >
> >  	dev_dbg(priv->dev, "Bound %s pad: %d\n", subdev->name, pad);
> >
> > --
> > 2.27.0
> >
>
> --
> Regards,
> Niklas Söderlund

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

* Re: [PATCH v6 9/9] media: rcar-csi2: Negotiate data lanes number
  2020-07-15  7:13     ` Jacopo Mondi
@ 2020-07-15  8:20       ` Niklas Söderlund
  0 siblings, 0 replies; 21+ messages in thread
From: Niklas Söderlund @ 2020-07-15  8:20 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: Jacopo Mondi, mchehab, hverkuil-cisco, sakari.ailus,
	laurent.pinchart, kieran.bingham, dave.stevenson, hyun.kwon,
	jmkrzyszt, robert.jarzmik, linux-media, linux-renesas-soc

Hi Jacopo,

On 2020-07-15 09:13:25 +0200, Jacopo Mondi wrote:
> Hi Niklas,
> 
> On Wed, Jul 15, 2020 at 08:55:38AM +0200, Niklas Söderlund wrote:
> > Hi Jacopo,
> >
> > Thanks for your work.
> >
> > On 2020-07-14 15:58:12 +0200, Jacopo Mondi wrote:
> > > Use the newly introduced get_mbus_config() subdevice pad operation to
> > > retrieve the remote subdevice MIPI CSI-2 bus configuration and configure
> > > the number of active data lanes accordingly.
> > >
> > > In order to be able to call the remote subdevice operation cache the
> > > index of the remote pad connected to the single CSI-2 input port.
> > >
> > > Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> > > ---
> > >  drivers/media/platform/rcar-vin/rcar-csi2.c | 74 +++++++++++++++++++--
> > >  1 file changed, 67 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
> > > index c6cc4f473a07..d39f312ebff9 100644
> > > --- a/drivers/media/platform/rcar-vin/rcar-csi2.c
> > > +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
> > > @@ -364,6 +364,7 @@ struct rcar_csi2 {
> > >  	struct v4l2_async_notifier notifier;
> > >  	struct v4l2_async_subdev asd;
> > >  	struct v4l2_subdev *remote;
> > > +	unsigned int remote_pad;
> > >
> > >  	struct v4l2_mbus_framefmt mf;
> > >
> > > @@ -409,13 +410,14 @@ static void rcsi2_exit_standby(struct rcar_csi2 *priv)
> > >  	reset_control_deassert(priv->rstc);
> > >  }
> > >
> > > -static int rcsi2_wait_phy_start(struct rcar_csi2 *priv)
> > > +static int rcsi2_wait_phy_start(struct rcar_csi2 *priv,
> > > +				unsigned int active_lanes)
> >
> > Maybe s/active_lanes/lanes/ here and below?
> >
> 
> ok, I guess it's not important to convey the distinction between
> active and available lanes here.
> 
> > >  {
> > >  	unsigned int timeout;
> > >
> > >  	/* Wait for the clock and data lanes to enter LP-11 state. */
> > >  	for (timeout = 0; timeout <= 20; timeout++) {
> > > -		const u32 lane_mask = (1 << priv->lanes) - 1;
> > > +		const u32 lane_mask = (1 << active_lanes) - 1;
> > >
> > >  		if ((rcsi2_read(priv, PHCLM_REG) & PHCLM_STOPSTATECKL)  &&
> > >  		    (rcsi2_read(priv, PHDLM_REG) & lane_mask) == lane_mask)
> > > @@ -447,7 +449,8 @@ static int rcsi2_set_phypll(struct rcar_csi2 *priv, unsigned int mbps)
> > >  	return 0;
> > >  }
> > >
> > > -static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp)
> > > +static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp,
> > > +			   unsigned int active_lanes)
> > >  {
> > >  	struct v4l2_subdev *source;
> > >  	struct v4l2_ctrl *ctrl;
> > > @@ -472,15 +475,63 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp)
> > >  	 * bps = link_freq * 2
> > >  	 */
> > >  	mbps = v4l2_ctrl_g_ctrl_int64(ctrl) * bpp;
> > > -	do_div(mbps, priv->lanes * 1000000);
> > > +	do_div(mbps, active_lanes * 1000000);
> > >
> > >  	return mbps;
> > >  }
> > >
> > > +static int rcsi2_config_active_lanes(struct rcar_csi2 *priv,
> > > +				     unsigned int *active_lanes)
> >
> > I would name this rcsi2_get_active_lanes() as it does not configure
> > anything just queries the subdevice for information.
> >
> 
> ack
> 
> > > +{
> > > +	struct v4l2_mbus_config mbus_config = { 0 };
> > > +	unsigned int num_lanes = (-1U);
> >
> > This looks odd and could just be set 0 with the same effect but clearer
> > to read.
> >
> 
> Not really.
> 
> Have a look at this part:
> 
> 	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) {
> 
>         ^^ I should then change this one to:
> 
>         if (!num_lanes)
> 
> But this does not protect against the case num_lanes is actually set
> to a meaningful value, but it's larger than the number of actually
> available lanes (which is held by priv->lanes).
> 
> I would keep this one as it is.

I see your point but please initialize it to UINT_MAX instead of -1U 
then :-)

> 
> Thanks
>   j
> 
> > > +	int ret;
> > > +
> > > +	*active_lanes = priv->lanes;
> > > +	ret = v4l2_subdev_call(priv->remote, pad, get_mbus_config,
> > > +			       priv->remote_pad, &mbus_config);
> > > +	if (ret == -ENOIOCTLCMD) {
> > > +		dev_dbg(priv->dev, "No remote mbus configuration available\n");
> > > +		return 0;
> > > +	}
> > > +
> > > +	if (ret) {
> > > +		dev_err(priv->dev, "Failed to get remote mbus configuration\n");
> > > +		return ret;
> > > +	}
> > > +
> > > +	if (mbus_config.type != V4L2_MBUS_CSI2_DPHY) {
> > > +		dev_err(priv->dev, "Unsupported media bus type %u\n",
> > > +			mbus_config.type);
> > > +		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) {
> > > +		dev_err(priv->dev,
> > > +			"Unsupported mbus config: too many data lanes %u\n",
> > > +			num_lanes);
> > > +		return -EINVAL;
> > > +	}
> > > +
> > > +	*active_lanes = num_lanes;
> > > +
> > > +	return 0;
> > > +}
> > > +
> > >  static int rcsi2_start_receiver(struct rcar_csi2 *priv)
> > >  {
> > >  	const struct rcar_csi2_format *format;
> > >  	u32 phycnt, vcdt = 0, vcdt2 = 0, fld = 0;
> > > +	unsigned int active_lanes;
> > >  	unsigned int i;
> > >  	int mbps, ret;
> > >
> > > @@ -522,10 +573,18 @@ static int rcsi2_start_receiver(struct rcar_csi2 *priv)
> > >  			fld |= FLD_FLD_NUM(1);
> > >  	}
> > >
> > > +	/*
> > > +	 * Get the number of active data lanes inspecting the remote mbus
> > > +	 * configuration.
> > > +	 */
> > > +	ret = rcsi2_config_active_lanes(priv, &active_lanes);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > >  	phycnt = PHYCNT_ENABLECLK;
> > > -	phycnt |= (1 << priv->lanes) - 1;
> > > +	phycnt |= (1 << active_lanes) - 1;
> > >
> > > -	mbps = rcsi2_calc_mbps(priv, format->bpp);
> > > +	mbps = rcsi2_calc_mbps(priv, format->bpp, active_lanes);
> > >  	if (mbps < 0)
> > >  		return mbps;
> > >
> > > @@ -572,7 +631,7 @@ static int rcsi2_start_receiver(struct rcar_csi2 *priv)
> > >  	rcsi2_write(priv, PHYCNT_REG, phycnt | PHYCNT_SHUTDOWNZ);
> > >  	rcsi2_write(priv, PHYCNT_REG, phycnt | PHYCNT_SHUTDOWNZ | PHYCNT_RSTZ);
> > >
> > > -	ret = rcsi2_wait_phy_start(priv);
> > > +	ret = rcsi2_wait_phy_start(priv, active_lanes);
> > >  	if (ret)
> > >  		return ret;
> > >
> > > @@ -749,6 +808,7 @@ static int rcsi2_notify_bound(struct v4l2_async_notifier *notifier,
> > >  	}
> > >
> > >  	priv->remote = subdev;
> > > +	priv->remote_pad = pad;
> > >
> > >  	dev_dbg(priv->dev, "Bound %s pad: %d\n", subdev->name, pad);
> > >
> > > --
> > > 2.27.0
> > >
> >
> > --
> > Regards,
> > Niklas Söderlund

-- 
Regards,
Niklas Söderlund

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

* [PATCH v6.1 9/9] media: rcar-csi2: Negotiate data lanes number
  2020-07-14 13:58 ` [PATCH v6 9/9] media: rcar-csi2: Negotiate data lanes number Jacopo Mondi
  2020-07-15  6:55   ` Niklas Söderlund
@ 2020-07-15 14:38   ` Jacopo Mondi
  2020-07-15 15:14     ` Niklas Söderlund
  1 sibling, 1 reply; 21+ messages in thread
From: Jacopo Mondi @ 2020-07-15 14:38 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, sakari.ailus, laurent.pinchart
  Cc: Jacopo Mondi, niklas.soderlund+renesas, kieran.bingham,
	dave.stevenson, hyun.kwon, jmkrzyszt, robert.jarzmik,
	linux-media, linux-renesas-soc

Use the newly introduced get_mbus_config() subdevice pad operation to
retrieve the remote subdevice MIPI CSI-2 bus configuration and configure
the number of active data lanes accordingly.

In order to be able to call the remote subdevice operation cache the
index of the remote pad connected to the single CSI-2 input port.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
v6.1 diff to address Niklas' comments:

- s/rcsi2_config_active_lanes()/rcsi2_get_active_lanes()
- s/unsigned int num_lanes = (-1U);/unsigned int num_lanes = UINT_MAX;/
- s/active_lanes/lanes

---
 drivers/media/platform/rcar-vin/rcar-csi2.c | 74 +++++++++++++++++++--
 1 file changed, 67 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
index c6cc4f473a07..5dac8ea66358 100644
--- a/drivers/media/platform/rcar-vin/rcar-csi2.c
+++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
@@ -364,6 +364,7 @@ struct rcar_csi2 {
 	struct v4l2_async_notifier notifier;
 	struct v4l2_async_subdev asd;
 	struct v4l2_subdev *remote;
+	unsigned int remote_pad;

 	struct v4l2_mbus_framefmt mf;

@@ -409,13 +410,14 @@ static void rcsi2_exit_standby(struct rcar_csi2 *priv)
 	reset_control_deassert(priv->rstc);
 }

-static int rcsi2_wait_phy_start(struct rcar_csi2 *priv)
+static int rcsi2_wait_phy_start(struct rcar_csi2 *priv,
+				unsigned int lanes)
 {
 	unsigned int timeout;

 	/* Wait for the clock and data lanes to enter LP-11 state. */
 	for (timeout = 0; timeout <= 20; timeout++) {
-		const u32 lane_mask = (1 << priv->lanes) - 1;
+		const u32 lane_mask = (1 << lanes) - 1;

 		if ((rcsi2_read(priv, PHCLM_REG) & PHCLM_STOPSTATECKL)  &&
 		    (rcsi2_read(priv, PHDLM_REG) & lane_mask) == lane_mask)
@@ -447,7 +449,8 @@ static int rcsi2_set_phypll(struct rcar_csi2 *priv, unsigned int mbps)
 	return 0;
 }

-static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp)
+static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp,
+			   unsigned int lanes)
 {
 	struct v4l2_subdev *source;
 	struct v4l2_ctrl *ctrl;
@@ -472,15 +475,63 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp)
 	 * bps = link_freq * 2
 	 */
 	mbps = v4l2_ctrl_g_ctrl_int64(ctrl) * bpp;
-	do_div(mbps, priv->lanes * 1000000);
+	do_div(mbps, lanes * 1000000);

 	return mbps;
 }

+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;
+	ret = v4l2_subdev_call(priv->remote, pad, get_mbus_config,
+			       priv->remote_pad, &mbus_config);
+	if (ret == -ENOIOCTLCMD) {
+		dev_dbg(priv->dev, "No remote mbus configuration available\n");
+		return 0;
+	}
+
+	if (ret) {
+		dev_err(priv->dev, "Failed to get remote mbus configuration\n");
+		return ret;
+	}
+
+	if (mbus_config.type != V4L2_MBUS_CSI2_DPHY) {
+		dev_err(priv->dev, "Unsupported media bus type %u\n",
+			mbus_config.type);
+		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) {
+		dev_err(priv->dev,
+			"Unsupported mbus config: too many data lanes %u\n",
+			num_lanes);
+		return -EINVAL;
+	}
+
+	*lanes = num_lanes;
+
+	return 0;
+}
+
 static int rcsi2_start_receiver(struct rcar_csi2 *priv)
 {
 	const struct rcar_csi2_format *format;
 	u32 phycnt, vcdt = 0, vcdt2 = 0, fld = 0;
+	unsigned int lanes;
 	unsigned int i;
 	int mbps, ret;

@@ -522,10 +573,18 @@ static int rcsi2_start_receiver(struct rcar_csi2 *priv)
 			fld |= FLD_FLD_NUM(1);
 	}

+	/*
+	 * Get the number of active data lanes inspecting the remote mbus
+	 * configuration.
+	 */
+	ret = rcsi2_get_active_lanes(priv, &lanes);
+	if (ret)
+		return ret;
+
 	phycnt = PHYCNT_ENABLECLK;
-	phycnt |= (1 << priv->lanes) - 1;
+	phycnt |= (1 << lanes) - 1;

-	mbps = rcsi2_calc_mbps(priv, format->bpp);
+	mbps = rcsi2_calc_mbps(priv, format->bpp, lanes);
 	if (mbps < 0)
 		return mbps;

@@ -572,7 +631,7 @@ static int rcsi2_start_receiver(struct rcar_csi2 *priv)
 	rcsi2_write(priv, PHYCNT_REG, phycnt | PHYCNT_SHUTDOWNZ);
 	rcsi2_write(priv, PHYCNT_REG, phycnt | PHYCNT_SHUTDOWNZ | PHYCNT_RSTZ);

-	ret = rcsi2_wait_phy_start(priv);
+	ret = rcsi2_wait_phy_start(priv, lanes);
 	if (ret)
 		return ret;

@@ -749,6 +808,7 @@ static int rcsi2_notify_bound(struct v4l2_async_notifier *notifier,
 	}

 	priv->remote = subdev;
+	priv->remote_pad = pad;

 	dev_dbg(priv->dev, "Bound %s pad: %d\n", subdev->name, pad);

--
2.27.0


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

* Re: [PATCH v6 1/9] media: v4l2-subdev: Introduce [get|set]_mbus_config pad ops
  2020-07-14 13:58 ` [PATCH v6 1/9] media: v4l2-subdev: Introduce [get|set]_mbus_config pad ops Jacopo Mondi
@ 2020-07-15 15:08   ` Hans Verkuil
  2020-07-19 11:18     ` Janusz Krzysztofik
  0 siblings, 1 reply; 21+ messages in thread
From: Hans Verkuil @ 2020-07-15 15:08 UTC (permalink / raw)
  To: Jacopo Mondi, mchehab, sakari.ailus, laurent.pinchart
  Cc: niklas.soderlund+renesas, kieran.bingham, dave.stevenson,
	hyun.kwon, jmkrzyszt, robert.jarzmik, linux-media,
	linux-renesas-soc

On 14/07/2020 15:58, Jacopo Mondi wrote:
> Introduce two new pad operations to allow retrieving and configuring the
> media bus parameters on a subdevice pad.
> 
> The newly introduced operations aims to replace the s/g_mbus_config video
> operations, which have been on their way for deprecation since a long
> time.
> 
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> ---
>  include/media/v4l2-subdev.h | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> index f7fe78a6f65a..d8b9d5735307 100644
> --- a/include/media/v4l2-subdev.h
> +++ b/include/media/v4l2-subdev.h
> @@ -670,6 +670,29 @@ struct v4l2_subdev_pad_config {
>   *
>   * @set_frame_desc: set the low level media bus frame parameters, @fd array
>   *                  may be adjusted by the subdev driver to device capabilities.
> + *
> + * @get_mbus_config: get the media bus configuration of a remote sub-device.
> + *		     The media bus configuration is usually retrieved from the
> + *		     firmware interface at sub-device probe time, immediately
> + *		     applied to the hardware and eventually adjusted by the
> + *		     driver. Remote sub-devices (usually video receivers) shall
> + *		     use this operation to query the transmitting end bus
> + *		     configuration in order to adjust their own one accordingly.
> + *		     Callers should make sure they get the most up-to-date as
> + *		     possible configuration from the remote end, likely calling
> + *		     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.
> + *
> + * @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.
>   */

Hm, I'd hoped I could merge this, but I think include/media/v4l2-mediabus.h
also needs to be updated.

So the old g_mbus_config returned all supported configurations, while the
new get_mbus_config returns the *current* configuration.

That's fine, but that means that the meaning of the struct v4l2_mbus_config
flags field changes as well and several comments in v4l2-mediabus.h need to
be updated to reflect this.

E.g. instead of '/* How many lanes the client can use */' it becomes
'/* How many lanes the client uses */'.

Frankly, these flags can be redesigned now since you only need a single
e.g. V4L2_MBUS_HSYNC_ACTIVE_HIGH flag since if it is not set, then that
means ACTIVE_LOW. And since it is now a single bit, it is also easy to
make each flag a bit field.

The CSI2 lanes/channels can just be a bit field for the number of lanes/channels,
which is much easier to read. I strongly recommend making this change at the minimum.

Now all this can be done in a follow-up series, but the v4l2-mediabus.h
definitely needs to be updated to reflect the new code.

This can be done as a v6 5.5/9 patch (since it should come right after the
g/s_mbus_config removal).

Regards,

	Hans

>  struct v4l2_subdev_pad_ops {
>  	int (*init_cfg)(struct v4l2_subdev *sd,
> @@ -710,6 +733,10 @@ struct v4l2_subdev_pad_ops {
>  			      struct v4l2_mbus_frame_desc *fd);
>  	int (*set_frame_desc)(struct v4l2_subdev *sd, unsigned int pad,
>  			      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);
>  };
>  
>  /**
> 


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

* Re: [PATCH v6.1 9/9] media: rcar-csi2: Negotiate data lanes number
  2020-07-15 14:38   ` [PATCH v6.1 " Jacopo Mondi
@ 2020-07-15 15:14     ` Niklas Söderlund
  0 siblings, 0 replies; 21+ messages in thread
From: Niklas Söderlund @ 2020-07-15 15:14 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: mchehab, hverkuil-cisco, sakari.ailus, laurent.pinchart,
	kieran.bingham, dave.stevenson, hyun.kwon, jmkrzyszt,
	robert.jarzmik, linux-media, linux-renesas-soc

Hi Jacopo,

Thanks for your work.

On 2020-07-15 16:38:20 +0200, Jacopo Mondi wrote:
> Use the newly introduced get_mbus_config() subdevice pad operation to
> retrieve the remote subdevice MIPI CSI-2 bus configuration and configure
> the number of active data lanes accordingly.
> 
> In order to be able to call the remote subdevice operation cache the
> index of the remote pad connected to the single CSI-2 input port.
> 
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> ---
> v6.1 diff to address Niklas' comments:
> 
> - s/rcsi2_config_active_lanes()/rcsi2_get_active_lanes()
> - s/unsigned int num_lanes = (-1U);/unsigned int num_lanes = UINT_MAX;/
> - s/active_lanes/lanes
> 
> ---
>  drivers/media/platform/rcar-vin/rcar-csi2.c | 74 +++++++++++++++++++--
>  1 file changed, 67 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
> index c6cc4f473a07..5dac8ea66358 100644
> --- a/drivers/media/platform/rcar-vin/rcar-csi2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
> @@ -364,6 +364,7 @@ struct rcar_csi2 {
>  	struct v4l2_async_notifier notifier;
>  	struct v4l2_async_subdev asd;
>  	struct v4l2_subdev *remote;
> +	unsigned int remote_pad;
> 
>  	struct v4l2_mbus_framefmt mf;
> 
> @@ -409,13 +410,14 @@ static void rcsi2_exit_standby(struct rcar_csi2 *priv)
>  	reset_control_deassert(priv->rstc);
>  }
> 
> -static int rcsi2_wait_phy_start(struct rcar_csi2 *priv)
> +static int rcsi2_wait_phy_start(struct rcar_csi2 *priv,
> +				unsigned int lanes)
>  {
>  	unsigned int timeout;
> 
>  	/* Wait for the clock and data lanes to enter LP-11 state. */
>  	for (timeout = 0; timeout <= 20; timeout++) {
> -		const u32 lane_mask = (1 << priv->lanes) - 1;
> +		const u32 lane_mask = (1 << lanes) - 1;
> 
>  		if ((rcsi2_read(priv, PHCLM_REG) & PHCLM_STOPSTATECKL)  &&
>  		    (rcsi2_read(priv, PHDLM_REG) & lane_mask) == lane_mask)
> @@ -447,7 +449,8 @@ static int rcsi2_set_phypll(struct rcar_csi2 *priv, unsigned int mbps)
>  	return 0;
>  }
> 
> -static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp)
> +static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp,
> +			   unsigned int lanes)
>  {
>  	struct v4l2_subdev *source;
>  	struct v4l2_ctrl *ctrl;
> @@ -472,15 +475,63 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp)
>  	 * bps = link_freq * 2
>  	 */
>  	mbps = v4l2_ctrl_g_ctrl_int64(ctrl) * bpp;
> -	do_div(mbps, priv->lanes * 1000000);
> +	do_div(mbps, lanes * 1000000);
> 
>  	return mbps;
>  }
> 
> +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;

I would add a blank line here as assigning *lanes is quiet different 
from trying to updated it bellow. With this fixed,

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> +	ret = v4l2_subdev_call(priv->remote, pad, get_mbus_config,
> +			       priv->remote_pad, &mbus_config);
> +	if (ret == -ENOIOCTLCMD) {
> +		dev_dbg(priv->dev, "No remote mbus configuration available\n");
> +		return 0;
> +	}
> +
> +	if (ret) {
> +		dev_err(priv->dev, "Failed to get remote mbus configuration\n");
> +		return ret;
> +	}
> +
> +	if (mbus_config.type != V4L2_MBUS_CSI2_DPHY) {
> +		dev_err(priv->dev, "Unsupported media bus type %u\n",
> +			mbus_config.type);
> +		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) {
> +		dev_err(priv->dev,
> +			"Unsupported mbus config: too many data lanes %u\n",
> +			num_lanes);
> +		return -EINVAL;
> +	}
> +
> +	*lanes = num_lanes;
> +
> +	return 0;
> +}
> +
>  static int rcsi2_start_receiver(struct rcar_csi2 *priv)
>  {
>  	const struct rcar_csi2_format *format;
>  	u32 phycnt, vcdt = 0, vcdt2 = 0, fld = 0;
> +	unsigned int lanes;
>  	unsigned int i;
>  	int mbps, ret;
> 
> @@ -522,10 +573,18 @@ static int rcsi2_start_receiver(struct rcar_csi2 *priv)
>  			fld |= FLD_FLD_NUM(1);
>  	}
> 
> +	/*
> +	 * Get the number of active data lanes inspecting the remote mbus
> +	 * configuration.
> +	 */
> +	ret = rcsi2_get_active_lanes(priv, &lanes);
> +	if (ret)
> +		return ret;
> +
>  	phycnt = PHYCNT_ENABLECLK;
> -	phycnt |= (1 << priv->lanes) - 1;
> +	phycnt |= (1 << lanes) - 1;
> 
> -	mbps = rcsi2_calc_mbps(priv, format->bpp);
> +	mbps = rcsi2_calc_mbps(priv, format->bpp, lanes);
>  	if (mbps < 0)
>  		return mbps;
> 
> @@ -572,7 +631,7 @@ static int rcsi2_start_receiver(struct rcar_csi2 *priv)
>  	rcsi2_write(priv, PHYCNT_REG, phycnt | PHYCNT_SHUTDOWNZ);
>  	rcsi2_write(priv, PHYCNT_REG, phycnt | PHYCNT_SHUTDOWNZ | PHYCNT_RSTZ);
> 
> -	ret = rcsi2_wait_phy_start(priv);
> +	ret = rcsi2_wait_phy_start(priv, lanes);
>  	if (ret)
>  		return ret;
> 
> @@ -749,6 +808,7 @@ static int rcsi2_notify_bound(struct v4l2_async_notifier *notifier,
>  	}
> 
>  	priv->remote = subdev;
> +	priv->remote_pad = pad;
> 
>  	dev_dbg(priv->dev, "Bound %s pad: %d\n", subdev->name, pad);
> 
> --
> 2.27.0
> 

-- 
Regards,
Niklas Söderlund

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

* Re: [PATCH v6 1/9] media: v4l2-subdev: Introduce [get|set]_mbus_config pad ops
  2020-07-15 15:08   ` Hans Verkuil
@ 2020-07-19 11:18     ` Janusz Krzysztofik
  2020-07-20  8:48       ` Hans Verkuil
  0 siblings, 1 reply; 21+ messages in thread
From: Janusz Krzysztofik @ 2020-07-19 11:18 UTC (permalink / raw)
  To: Jacopo Mondi, mchehab, sakari.ailus, laurent.pinchart, Hans Verkuil
  Cc: niklas.soderlund+renesas, kieran.bingham, dave.stevenson,
	hyun.kwon, robert.jarzmik, linux-media, linux-renesas-soc,
	Janusz Krzysztofik

Hi Hans,

On Wednesday, July 15, 2020 5:08:05 P.M. CEST Hans Verkuil wrote:
> On 14/07/2020 15:58, Jacopo Mondi wrote:
> > Introduce two new pad operations to allow retrieving and configuring the
> > media bus parameters on a subdevice pad.
> > 
> > The newly introduced operations aims to replace the s/g_mbus_config video
> > operations, which have been on their way for deprecation since a long
> > time.
> > 
> > Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> > ---
> >  include/media/v4l2-subdev.h | 27 +++++++++++++++++++++++++++
> >  1 file changed, 27 insertions(+)
> > 
> > diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> > index f7fe78a6f65a..d8b9d5735307 100644
> > --- a/include/media/v4l2-subdev.h
> > +++ b/include/media/v4l2-subdev.h
> > @@ -670,6 +670,29 @@ struct v4l2_subdev_pad_config {
> >   *
> >   * @set_frame_desc: set the low level media bus frame parameters, @fd array
> >   *                  may be adjusted by the subdev driver to device capabilities.
> > + *
> > + * @get_mbus_config: get the media bus configuration of a remote sub-device.
> > + *		     The media bus configuration is usually retrieved from the
> > + *		     firmware interface at sub-device probe time, immediately
> > + *		     applied to the hardware and eventually adjusted by the
> > + *		     driver. Remote sub-devices (usually video receivers) shall
> > + *		     use this operation to query the transmitting end bus
> > + *		     configuration in order to adjust their own one accordingly.
> > + *		     Callers should make sure they get the most up-to-date as
> > + *		     possible configuration from the remote end, likely calling
> > + *		     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.
> > + *
> > + * @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.
> >   */
> 
> Hm, I'd hoped I could merge this, but I think include/media/v4l2-mediabus.h
> also needs to be updated.
> 
> So the old g_mbus_config returned all supported configurations, while the
> new get_mbus_config returns the *current* configuration.
> 
> That's fine, but that means that the meaning of the struct v4l2_mbus_config
> flags field changes as well and several comments in v4l2-mediabus.h need to
> be updated to reflect this.
> 
> E.g. instead of '/* How many lanes the client can use */' it becomes
> '/* How many lanes the client uses */'.
> 
> Frankly, these flags can be redesigned now since you only need a single
> e.g. V4L2_MBUS_HSYNC_ACTIVE_HIGH flag since if it is not set, then that
> means ACTIVE_LOW. And since it is now a single bit, it is also easy to
> make each flag a bit field.

Even if this makes sense for .get_mbus_config() which returns current 
configuration, how about keeping the old semantics of the flags and let 
.set_mbus_config() accept a potentially incomplete or redundant set of flags 
specified by the caller to select a supported configuration from?  That approach 
was actually proposed before by Jacopo when he argued against my suggestion to 
add a wrapper with a check for mutually exclusive flags[1], and I found it a 
very good alternative to my other rejected suggestion of adding TRY support.

[1] https://www.spinics.net/lists/linux-media/msg171878.html

Thanks,
Janusz

> 
> The CSI2 lanes/channels can just be a bit field for the number of lanes/channels,
> which is much easier to read. I strongly recommend making this change at the minimum.
> 
> Now all this can be done in a follow-up series, but the v4l2-mediabus.h
> definitely needs to be updated to reflect the new code.
> 
> This can be done as a v6 5.5/9 patch (since it should come right after the
> g/s_mbus_config removal).
> 
> Regards,
> 
> 	Hans
> 
> >  struct v4l2_subdev_pad_ops {
> >  	int (*init_cfg)(struct v4l2_subdev *sd,
> > @@ -710,6 +733,10 @@ struct v4l2_subdev_pad_ops {
> >  			      struct v4l2_mbus_frame_desc *fd);
> >  	int (*set_frame_desc)(struct v4l2_subdev *sd, unsigned int pad,
> >  			      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);
> >  };
> >  
> >  /**
> > 
> 
> 





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

* Re: [PATCH v6 1/9] media: v4l2-subdev: Introduce [get|set]_mbus_config pad ops
  2020-07-19 11:18     ` Janusz Krzysztofik
@ 2020-07-20  8:48       ` Hans Verkuil
  2020-07-20 18:44         ` Janusz Krzysztofik
  2020-07-29  7:35         ` Robert Jarzmik
  0 siblings, 2 replies; 21+ messages in thread
From: Hans Verkuil @ 2020-07-20  8:48 UTC (permalink / raw)
  To: Janusz Krzysztofik, Jacopo Mondi, mchehab, sakari.ailus,
	laurent.pinchart
  Cc: niklas.soderlund+renesas, kieran.bingham, dave.stevenson,
	hyun.kwon, robert.jarzmik, linux-media, linux-renesas-soc

On 19/07/2020 13:18, Janusz Krzysztofik wrote:
> Hi Hans,
> 
> On Wednesday, July 15, 2020 5:08:05 P.M. CEST Hans Verkuil wrote:
>> On 14/07/2020 15:58, Jacopo Mondi wrote:
>>> Introduce two new pad operations to allow retrieving and configuring the
>>> media bus parameters on a subdevice pad.
>>>
>>> The newly introduced operations aims to replace the s/g_mbus_config video
>>> operations, which have been on their way for deprecation since a long
>>> time.
>>>
>>> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
>>> ---
>>>  include/media/v4l2-subdev.h | 27 +++++++++++++++++++++++++++
>>>  1 file changed, 27 insertions(+)
>>>
>>> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
>>> index f7fe78a6f65a..d8b9d5735307 100644
>>> --- a/include/media/v4l2-subdev.h
>>> +++ b/include/media/v4l2-subdev.h
>>> @@ -670,6 +670,29 @@ struct v4l2_subdev_pad_config {
>>>   *
>>>   * @set_frame_desc: set the low level media bus frame parameters, @fd array
>>>   *                  may be adjusted by the subdev driver to device capabilities.
>>> + *
>>> + * @get_mbus_config: get the media bus configuration of a remote sub-device.
>>> + *		     The media bus configuration is usually retrieved from the
>>> + *		     firmware interface at sub-device probe time, immediately
>>> + *		     applied to the hardware and eventually adjusted by the
>>> + *		     driver. Remote sub-devices (usually video receivers) shall
>>> + *		     use this operation to query the transmitting end bus
>>> + *		     configuration in order to adjust their own one accordingly.
>>> + *		     Callers should make sure they get the most up-to-date as
>>> + *		     possible configuration from the remote end, likely calling
>>> + *		     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.
>>> + *
>>> + * @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.
>>>   */
>>
>> Hm, I'd hoped I could merge this, but I think include/media/v4l2-mediabus.h
>> also needs to be updated.
>>
>> So the old g_mbus_config returned all supported configurations, while the
>> new get_mbus_config returns the *current* configuration.
>>
>> That's fine, but that means that the meaning of the struct v4l2_mbus_config
>> flags field changes as well and several comments in v4l2-mediabus.h need to
>> be updated to reflect this.
>>
>> E.g. instead of '/* How many lanes the client can use */' it becomes
>> '/* How many lanes the client uses */'.
>>
>> Frankly, these flags can be redesigned now since you only need a single
>> e.g. V4L2_MBUS_HSYNC_ACTIVE_HIGH flag since if it is not set, then that
>> means ACTIVE_LOW. And since it is now a single bit, it is also easy to
>> make each flag a bit field.
> 
> Even if this makes sense for .get_mbus_config() which returns current 
> configuration, how about keeping the old semantics of the flags and let 
> .set_mbus_config() accept a potentially incomplete or redundant set of flags 
> specified by the caller to select a supported configuration from?  That approach 
> was actually proposed before by Jacopo when he argued against my suggestion to 
> add a wrapper with a check for mutually exclusive flags[1], and I found it a 
> very good alternative to my other rejected suggestion of adding TRY support.

The information on how a sensor (or similar device) is wired up is not something
that should be negotiated. Even if a combination is theoretically possible, it
may not have been tested by the board designer and in fact it might not work.
(Yes, that happens)

It is just a bad design trying to negotiate this.

In fact, the only values that can be set as far as I am concerned are lanes and
channels. I wouldn't mind if the other settings are purely read-only. The only
driver that actively sets this is the pxa_camera driver and I wish it didn't.

But there are still two pxa boards that use this mechanism, so I guess we still
have to allow this.

Anyway, do you have a specific use-case in mind? Note that this is an internal
API, so it can always be changed later.

Regards,

	Hans

> 
> [1] https://www.spinics.net/lists/linux-media/msg171878.html
> 
> Thanks,
> Janusz
> 
>>
>> The CSI2 lanes/channels can just be a bit field for the number of lanes/channels,
>> which is much easier to read. I strongly recommend making this change at the minimum.
>>
>> Now all this can be done in a follow-up series, but the v4l2-mediabus.h
>> definitely needs to be updated to reflect the new code.
>>
>> This can be done as a v6 5.5/9 patch (since it should come right after the
>> g/s_mbus_config removal).
>>
>> Regards,
>>
>> 	Hans
>>
>>>  struct v4l2_subdev_pad_ops {
>>>  	int (*init_cfg)(struct v4l2_subdev *sd,
>>> @@ -710,6 +733,10 @@ struct v4l2_subdev_pad_ops {
>>>  			      struct v4l2_mbus_frame_desc *fd);
>>>  	int (*set_frame_desc)(struct v4l2_subdev *sd, unsigned int pad,
>>>  			      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);
>>>  };
>>>  
>>>  /**
>>>
>>
>>
> 
> 
> 
> 


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

* Re: [PATCH v6 1/9] media: v4l2-subdev: Introduce [get|set]_mbus_config pad ops
  2020-07-20  8:48       ` Hans Verkuil
@ 2020-07-20 18:44         ` Janusz Krzysztofik
  2020-07-21  7:46           ` Hans Verkuil
  2020-07-29  7:35         ` Robert Jarzmik
  1 sibling, 1 reply; 21+ messages in thread
From: Janusz Krzysztofik @ 2020-07-20 18:44 UTC (permalink / raw)
  To: Jacopo Mondi, mchehab, sakari.ailus, laurent.pinchart, Hans Verkuil
  Cc: niklas.soderlund+renesas, kieran.bingham, dave.stevenson,
	hyun.kwon, robert.jarzmik, linux-media, linux-renesas-soc,
	Janusz Krzysztofik

On Monday, July 20, 2020 10:48:36 A.M. CEST Hans Verkuil wrote:
> On 19/07/2020 13:18, Janusz Krzysztofik wrote:
> > Hi Hans,
> > 
> > On Wednesday, July 15, 2020 5:08:05 P.M. CEST Hans Verkuil wrote:
> >> On 14/07/2020 15:58, Jacopo Mondi wrote:
> >>> Introduce two new pad operations to allow retrieving and configuring the
> >>> media bus parameters on a subdevice pad.
> >>>
> >>> The newly introduced operations aims to replace the s/g_mbus_config video
> >>> operations, which have been on their way for deprecation since a long
> >>> time.
> >>>
> >>> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> >>> ---
> >>>  include/media/v4l2-subdev.h | 27 +++++++++++++++++++++++++++
> >>>  1 file changed, 27 insertions(+)
> >>>
> >>> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> >>> index f7fe78a6f65a..d8b9d5735307 100644
> >>> --- a/include/media/v4l2-subdev.h
> >>> +++ b/include/media/v4l2-subdev.h
> >>> @@ -670,6 +670,29 @@ struct v4l2_subdev_pad_config {
> >>>   *
> >>>   * @set_frame_desc: set the low level media bus frame parameters, @fd 
array
> >>>   *                  may be adjusted by the subdev driver to device 
capabilities.
> >>> + *
> >>> + * @get_mbus_config: get the media bus configuration of a remote sub-
device.
> >>> + *		     The media bus configuration is usually retrieved 
from the
> >>> + *		     firmware interface at sub-device probe time, 
immediately
> >>> + *		     applied to the hardware and eventually adjusted 
by the
> >>> + *		     driver. Remote sub-devices (usually video 
receivers) shall
> >>> + *		     use this operation to query the transmitting end 
bus
> >>> + *		     configuration in order to adjust their own one 
accordingly.
> >>> + *		     Callers should make sure they get the most up-to-
date as
> >>> + *		     possible configuration from the remote end, likely 
calling
> >>> + *		     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.
> >>> + *
> >>> + * @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.
> >>>   */
> >>
> >> Hm, I'd hoped I could merge this, but I think include/media/v4l2-
mediabus.h
> >> also needs to be updated.
> >>
> >> So the old g_mbus_config returned all supported configurations, while the
> >> new get_mbus_config returns the *current* configuration.
> >>
> >> That's fine, but that means that the meaning of the struct v4l2_mbus_config
> >> flags field changes as well and several comments in v4l2-mediabus.h need to
> >> be updated to reflect this.
> >>
> >> E.g. instead of '/* How many lanes the client can use */' it becomes
> >> '/* How many lanes the client uses */'.
> >>
> >> Frankly, these flags can be redesigned now since you only need a single
> >> e.g. V4L2_MBUS_HSYNC_ACTIVE_HIGH flag since if it is not set, then that
> >> means ACTIVE_LOW. And since it is now a single bit, it is also easy to
> >> make each flag a bit field.
> > 
> > Even if this makes sense for .get_mbus_config() which returns current 
> > configuration, how about keeping the old semantics of the flags and let 
> > .set_mbus_config() accept a potentially incomplete or redundant set of flags 
> > specified by the caller to select a supported configuration from?  That 
approach 
> > was actually proposed before by Jacopo when he argued against my 
suggestion to 
> > add a wrapper with a check for mutually exclusive flags[1], and I found it 
a 
> > very good alternative to my other rejected suggestion of adding TRY 
support.
> 
> The information on how a sensor (or similar device) is wired up is not 
something
> that should be negotiated. Even if a combination is theoretically possible, 
it
> may not have been tested by the board designer and in fact it might not 
work.
> (Yes, that happens)
> 
> It is just a bad design trying to negotiate this.
> 
> In fact, the only values that can be set as far as I am concerned are lanes 
and
> channels. I wouldn't mind if the other settings are purely read-only. The 
only
> driver that actively sets this is the pxa_camera driver and I wish it 
didn't.
> 
> But there are still two pxa boards that use this mechanism, so I guess we 
still
> have to allow this.
> 
> Anyway, do you have a specific use-case in mind?

Non-DT platforms in general.  You repeat quite often that configuration 
should come from DT.  While that's obvious, does that mean media is soon going 
to drop non-DT support completely?  If not then I think that it may be better 
to allow negotiation where possible than require each platform driver that 
still wishes to support non-DT platforms to define its own platform data 
structure.  At least parallel link settings seem to be a good candidate to me.

Anyway, as long as .set_mbus_config() is going to be supported, it is still 
possible for a platform driver to iterate through its supported configurations 
if passing incomplete or redundant flags and let the sensor handle that is not 
allowed.  More complicated, more time consuming, more error prone, I believe, 
but still possible.

Thanks,
Janusz


> Note that this is an internal
> API, so it can always be changed later.
> 
> Regards,
> 
> 	Hans
> 
> > 
> > [1] https://www.spinics.net/lists/linux-media/msg171878.html
> > 
> > Thanks,
> > Janusz
> > 
> >>
> >> The CSI2 lanes/channels can just be a bit field for the number of lanes/
channels,
> >> which is much easier to read. I strongly recommend making this change at 
the minimum.
> >>
> >> Now all this can be done in a follow-up series, but the v4l2-mediabus.h
> >> definitely needs to be updated to reflect the new code.
> >>
> >> This can be done as a v6 5.5/9 patch (since it should come right after 
the
> >> g/s_mbus_config removal).
> >>
> >> Regards,
> >>
> >> 	Hans
> >>
> >>>  struct v4l2_subdev_pad_ops {
> >>>  	int (*init_cfg)(struct v4l2_subdev *sd,
> >>> @@ -710,6 +733,10 @@ struct v4l2_subdev_pad_ops {
> >>>  			      struct v4l2_mbus_frame_desc *fd);
> >>>  	int (*set_frame_desc)(struct v4l2_subdev *sd, unsigned int pad,
> >>>  			      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);
> >>>  };
> >>>  
> >>>  /**
> >>>
> >>
> >>
> > 
> > 
> > 
> > 
> 
> 





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

* Re: [PATCH v6 1/9] media: v4l2-subdev: Introduce [get|set]_mbus_config pad ops
  2020-07-20 18:44         ` Janusz Krzysztofik
@ 2020-07-21  7:46           ` Hans Verkuil
  0 siblings, 0 replies; 21+ messages in thread
From: Hans Verkuil @ 2020-07-21  7:46 UTC (permalink / raw)
  To: Janusz Krzysztofik, Jacopo Mondi, mchehab, sakari.ailus,
	laurent.pinchart
  Cc: niklas.soderlund+renesas, kieran.bingham, dave.stevenson,
	hyun.kwon, robert.jarzmik, linux-media, linux-renesas-soc

On 20/07/2020 20:44, Janusz Krzysztofik wrote:
> On Monday, July 20, 2020 10:48:36 A.M. CEST Hans Verkuil wrote:
>> On 19/07/2020 13:18, Janusz Krzysztofik wrote:
>>> Hi Hans,
>>>
>>> On Wednesday, July 15, 2020 5:08:05 P.M. CEST Hans Verkuil wrote:
>>>> On 14/07/2020 15:58, Jacopo Mondi wrote:
>>>>> Introduce two new pad operations to allow retrieving and configuring the
>>>>> media bus parameters on a subdevice pad.
>>>>>
>>>>> The newly introduced operations aims to replace the s/g_mbus_config video
>>>>> operations, which have been on their way for deprecation since a long
>>>>> time.
>>>>>
>>>>> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
>>>>> ---
>>>>>  include/media/v4l2-subdev.h | 27 +++++++++++++++++++++++++++
>>>>>  1 file changed, 27 insertions(+)
>>>>>
>>>>> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
>>>>> index f7fe78a6f65a..d8b9d5735307 100644
>>>>> --- a/include/media/v4l2-subdev.h
>>>>> +++ b/include/media/v4l2-subdev.h
>>>>> @@ -670,6 +670,29 @@ struct v4l2_subdev_pad_config {
>>>>>   *
>>>>>   * @set_frame_desc: set the low level media bus frame parameters, @fd 
> array
>>>>>   *                  may be adjusted by the subdev driver to device 
> capabilities.
>>>>> + *
>>>>> + * @get_mbus_config: get the media bus configuration of a remote sub-
> device.
>>>>> + *		     The media bus configuration is usually retrieved 
> from the
>>>>> + *		     firmware interface at sub-device probe time, 
> immediately
>>>>> + *		     applied to the hardware and eventually adjusted 
> by the
>>>>> + *		     driver. Remote sub-devices (usually video 
> receivers) shall
>>>>> + *		     use this operation to query the transmitting end 
> bus
>>>>> + *		     configuration in order to adjust their own one 
> accordingly.
>>>>> + *		     Callers should make sure they get the most up-to-
> date as
>>>>> + *		     possible configuration from the remote end, likely 
> calling
>>>>> + *		     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.
>>>>> + *
>>>>> + * @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.
>>>>>   */
>>>>
>>>> Hm, I'd hoped I could merge this, but I think include/media/v4l2-
> mediabus.h
>>>> also needs to be updated.
>>>>
>>>> So the old g_mbus_config returned all supported configurations, while the
>>>> new get_mbus_config returns the *current* configuration.
>>>>
>>>> That's fine, but that means that the meaning of the struct v4l2_mbus_config
>>>> flags field changes as well and several comments in v4l2-mediabus.h need to
>>>> be updated to reflect this.
>>>>
>>>> E.g. instead of '/* How many lanes the client can use */' it becomes
>>>> '/* How many lanes the client uses */'.
>>>>
>>>> Frankly, these flags can be redesigned now since you only need a single
>>>> e.g. V4L2_MBUS_HSYNC_ACTIVE_HIGH flag since if it is not set, then that
>>>> means ACTIVE_LOW. And since it is now a single bit, it is also easy to
>>>> make each flag a bit field.
>>>
>>> Even if this makes sense for .get_mbus_config() which returns current 
>>> configuration, how about keeping the old semantics of the flags and let 
>>> .set_mbus_config() accept a potentially incomplete or redundant set of flags 
>>> specified by the caller to select a supported configuration from?  That 
> approach 
>>> was actually proposed before by Jacopo when he argued against my 
> suggestion to 
>>> add a wrapper with a check for mutually exclusive flags[1], and I found it 
> a 
>>> very good alternative to my other rejected suggestion of adding TRY 
> support.
>>
>> The information on how a sensor (or similar device) is wired up is not 
> something
>> that should be negotiated. Even if a combination is theoretically possible, 
> it
>> may not have been tested by the board designer and in fact it might not 
> work.
>> (Yes, that happens)
>>
>> It is just a bad design trying to negotiate this.
>>
>> In fact, the only values that can be set as far as I am concerned are lanes 
> and
>> channels. I wouldn't mind if the other settings are purely read-only. The 
> only
>> driver that actively sets this is the pxa_camera driver and I wish it 
> didn't.
>>
>> But there are still two pxa boards that use this mechanism, so I guess we 
> still
>> have to allow this.
>>
>> Anyway, do you have a specific use-case in mind?
> 
> Non-DT platforms in general.  You repeat quite often that configuration 
> should come from DT.  While that's obvious, does that mean media is soon going 
> to drop non-DT support completely?  If not then I think that it may be better 

It's close to dropping non-DT already. The ov6650 is the only sensor driver that
supports s_mbus_config today, so trying to negotiate these settings is only possible
with that sensor. In any case, this is really not something that should be negotiated,
regardless of DT vs platform. Negotiating this was and is a bad idea and instead you
should have a well defined and tested configuration defined in either the DT or in
platform data.

> to allow negotiation where possible than require each platform driver that 
> still wishes to support non-DT platforms to define its own platform data 
> structure.  At least parallel link settings seem to be a good candidate to me.
> 
> Anyway, as long as .set_mbus_config() is going to be supported, it is still 
> possible for a platform driver to iterate through its supported configurations 
> if passing incomplete or redundant flags and let the sensor handle that is not 
> allowed.  More complicated, more time consuming, more error prone, I believe, 
> but still possible.

It's possible, but it is just not a good idea. As I mentioned before, typically
only one combination is actually tested, and negotiating this might end up
choosing a combination of settings that, while valid, is actually not working
due to HW bugs that were never noticed because the designer never tested that
combination. The other reason is that this makes things so much more complicated.

It is much easier and safer to just be explicit in the dts or platform data.

Regards,

	Hans

> 
> Thanks,
> Janusz

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

* Re: [PATCH v6 1/9] media: v4l2-subdev: Introduce [get|set]_mbus_config pad ops
  2020-07-20  8:48       ` Hans Verkuil
  2020-07-20 18:44         ` Janusz Krzysztofik
@ 2020-07-29  7:35         ` Robert Jarzmik
  1 sibling, 0 replies; 21+ messages in thread
From: Robert Jarzmik @ 2020-07-29  7:35 UTC (permalink / raw)
  To: Hans Verkuil, Jacopo Mondi
  Cc: Janusz Krzysztofik, mchehab, sakari.ailus, laurent.pinchart,
	niklas.soderlund+renesas, kieran.bingham, dave.stevenson,
	hyun.kwon, linux-media, linux-renesas-soc

Hans Verkuil <hverkuil-cisco@xs4all.nl> writes:

> The information on how a sensor (or similar device) is wired up is not something
> that should be negotiated. Even if a combination is theoretically possible, it
> may not have been tested by the board designer and in fact it might not work.
> (Yes, that happens)
>
> It is just a bad design trying to negotiate this.
I quite agree on that one (on the wiring defined by configuration).

> In fact, the only values that can be set as far as I am concerned are lanes and
> channels. I wouldn't mind if the other settings are purely read-only. The only
> driver that actively sets this is the pxa_camera driver and I wish it didn't.
>
> But there are still two pxa boards that use this mechanism, so I guess we still
> have to allow this.
There are 4 :
rj@belgarion:~/mio_linux/kernel/arch/arm/mach-pxa$ grep -rs pxa_set_camera * | grep -v devices.c
ezx.c:		pxa_set_camera_info(&a780_pxacamera_platform_data);
ezx.c:		pxa_set_camera_info(&a910_pxacamera_platform_data);
mioa701.c:	pxa_set_camera_info(&mioa701_pxacamera_platform_data);
palmz72.c:	pxa_set_camera_info(&palmz72_pxacamera_platform_data);
pcm990-baseboard.c:	pxa_set_camera_info(&pcm990_pxacamera_platform_data);

I wouldn't mind that the bus parameters are made "static" by forcing them in the
platform data field (struct pxacamera_platform_data), and not doing the bus
compatibility matching.

I thing Jacopo's work is going this way, as I read that his patch takes first
the platform data flags, and only if none are defined goes to the matchup. That
looks very sensible to me.

Cheers.

--
Robert

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

end of thread, other threads:[~2020-07-29  7:35 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-14 13:58 [PATCH v6 0/9] v4l2-subdev: Introduce [g|s]et_mbus_format pad op Jacopo Mondi
2020-07-14 13:58 ` [PATCH v6 1/9] media: v4l2-subdev: Introduce [get|set]_mbus_config pad ops Jacopo Mondi
2020-07-15 15:08   ` Hans Verkuil
2020-07-19 11:18     ` Janusz Krzysztofik
2020-07-20  8:48       ` Hans Verkuil
2020-07-20 18:44         ` Janusz Krzysztofik
2020-07-21  7:46           ` Hans Verkuil
2020-07-29  7:35         ` Robert Jarzmik
2020-07-14 13:58 ` [PATCH v6 2/9] media: i2c: Use the new get_mbus_config pad op Jacopo Mondi
2020-07-14 13:58 ` [PATCH v6 3/9] media: i2c: ov6650: Use new [get|set]_mbus_config ops Jacopo Mondi
2020-07-14 13:58 ` [PATCH v6 4/9] media: pxa_camera: Use the new set_mbus_config op Jacopo Mondi
2020-07-14 13:58 ` [PATCH v6 5/9] media: v4l2-subdev: Remove [s|g]_mbus_config video ops Jacopo Mondi
2020-07-14 13:58 ` [PATCH v6 6/9] staging: media: imx: Update TODO entry Jacopo Mondi
2020-07-14 13:58 ` [PATCH v6 7/9] media: i2c: adv748x: Adjust TXA data lanes number Jacopo Mondi
2020-07-14 13:58 ` [PATCH v6 8/9] media: i2c: adv748x: Implement get_mbus_config Jacopo Mondi
2020-07-14 13:58 ` [PATCH v6 9/9] media: rcar-csi2: Negotiate data lanes number Jacopo Mondi
2020-07-15  6:55   ` Niklas Söderlund
2020-07-15  7:13     ` Jacopo Mondi
2020-07-15  8:20       ` Niklas Söderlund
2020-07-15 14:38   ` [PATCH v6.1 " Jacopo Mondi
2020-07-15 15:14     ` Niklas Söderlund

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