Skip to contentSkip to conversation

V4L2 fwnode framework and driver fixes

PATCH In review Sakari Ailus 4 participants 15 messages Mar 5, 2019 – Aug 21, 2019

Subsystems (2)
lore
Share & tools
lore

Sakari Ailus

author maintainer
#0 lore raw

cover V4L2 fwnode framework and driver fixes

Hi folks,

Here are a few fixes for the parsing fwnodes in the V4L2 framework as well as drivers using it.

Sakari Ailus (4):
v4l2-fwnode: Defaults may not override endpoint configuration in
firmware
v4l2-fwnode: The first default data lane is 0 on C-PHY
pxa-camera: Match with device node, not the port node
ti-vpe: Parse local endpoint for properties, not the remote one

 drivers/media/platform/pxa_camera.c   |  2 +-
 drivers/media/platform/ti-vpe/cal.c   | 11 ++---------
 drivers/media/v4l2-core/v4l2-fwnode.c | 12 ++++++++++--
 3 files changed, 13 insertions(+), 12 deletions(-)
Signature · 1 line
2.11.0
author maintainer
#1 lore raw

PATCH 1/4 v4l2-fwnode: Defaults may not override endpoint configuration in firmware

The lack of defaults provided by the caller to v4l2_fwnode_endpoint_parse() signals the use of the default lane mapping. The default lane mapping must not be used however if the firmmare contains the lane mapping. Disable the default lane mapping in that case, and improve the debug messages telling of the use of the defaults.

This was missed previously since the default mapping will only unsed in this case if the bus type is set, and no driver did both while still needing the lane mapping configuration.

Fixes b4357d21d674 ("media: v4l: fwnode: Support default CSI-2 lane mapping for drivers")
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-fwnode.c +5 -1
index 9bfedd7596a1..93d0547779df 100644
@@ -163,7 +163,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
 		}
 
 		if (use_default_lane_mapping)
-			pr_debug("using default lane mapping\n");
+			pr_debug("no lane mapping given, using defaults\n");
 	}
 
 	rval = fwnode_property_read_u32_array(fwnode, "data-lanes", NULL, 0);
@@ -175,6 +175,10 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
 					       num_data_lanes);
 
 		have_data_lanes = true;
+		if (use_default_lane_mapping) {
+			pr_debug("data-lanes property exists; disabling default mapping\n");
+			use_default_lane_mapping = false;
+		}
 	}
 
 	for (i = 0; i < num_data_lanes; i++) {
Signature · 1 line
2.11.0
author maintainer
#2 lore raw

PATCH 2/4 v4l2-fwnode: The first default data lane is 0 on C-PHY

In reply to Sakari Ailus

C-PHY has no clock lanes. Therefore the first data lane is 0 by default.

Fixes edc6d56c2e7e ("media: v4l: fwnode: Support parsing of CSI-2 C-PHY endpoints")
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-fwnode.c +5 -1
index 93d0547779df..6b990c78c73a 100644
@@ -229,6 +229,10 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
 	if (bus_type == V4L2_MBUS_CSI2_DPHY ||
 	    bus_type == V4L2_MBUS_CSI2_CPHY || lanes_used ||
 	    have_clk_lane || (flags & ~V4L2_MBUS_CSI2_CONTINUOUS_CLOCK)) {
+		/* Only D-PHY has a clock lane. */
+		unsigned int dfl_data_lane_index =
+			bus_type == V4L2_MBUS_CSI2_DPHY;
+
 		bus->flags = flags;
 		if (bus_type == V4L2_MBUS_UNKNOWN)
 			vep->bus_type = V4L2_MBUS_CSI2_DPHY;
@@ -237,7 +241,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
 		if (use_default_lane_mapping) {
 			bus->clock_lane = 0;
 			for (i = 0; i < num_data_lanes; i++)
-				bus->data_lanes[i] = 1 + i;
+				bus->data_lanes[i] = dfl_data_lane_index + i;
 		} else {
 			bus->clock_lane = clock_lane;
 			for (i = 0; i < num_data_lanes; i++)
Signature · 1 line
2.11.0
author maintainer
#3 lore raw

PATCH 3/4 pxa-camera: Match with device node, not the port node

In reply to Sakari Ailus

V4L2 fwnode matching right now still works based on device nodes, not port nodes. Fix this.

---
 drivers/media/platform/pxa_camera.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/pxa_camera.c +1 -1
index 3cf3c6390cc8..f729519f34e1 100644
@@ -2350,7 +2350,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev,
 		pcdev->platform_flags |= PXA_CAMERA_PCLK_EN;
 
 	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
-	remote = of_graph_get_remote_port(np);
+	remote = of_graph_get_remote_port_parent(np);
 	if (remote)
 		asd->match.fwnode = of_fwnode_handle(remote);
 	else
Signature · 1 line
2.11.0
#4 lore raw

Re: [PATCH 3/4] pxa-camera: Match with device node, not the port node

Quoted 2 lines · Sakari Ailus

V4L2 fwnode matching right now still works based on device nodes, not port nodes. Fix this.

Mmmh why does it need a fix, and what's wrong on device node matching ? This commit message is a bit too brief for me to understand why a fix is needed.

Moreover, does it have an impact on Documentation/devicetree/bindings/media/pxa-camera.txt ?

Cheers.

--
Robert

author maintainer
#5 lore raw

Re: [PATCH 3/4] pxa-camera: Match with device node, not the port node

Hi Robert,

Quoted 6 lines · Robert Jarzmik
Quoted 2 lines · Sakari Ailus

V4L2 fwnode matching right now still works based on device nodes, not port nodes. Fix this.

Mmmh why does it need a fix, and what's wrong on device node matching ? This commit message is a bit too brief for me to understand why a fix is needed.

The V4L2 async framework matches the async sub-devices based on their device nodes on fwnode matching which is used on DT-based systems. If a port node is provided instead, there won't be a match.

Quoted 3 lines

Moreover, does it have an impact on Documentation/devicetree/bindings/media/pxa-camera.txt ?

The bindings are fine.

Signature · 4 lines
Regards,

Sakari Ailus
[email protected]
author maintainer
#6 lore raw

PATCH 4/4 ti-vpe: Parse local endpoint for properties, not the remote one

In reply to Sakari Ailus

ti-vpe driver parsed the remote endpoints for properties but ignored the local ones. Fix this by parsing the local endpoint properties instead.

---
 drivers/media/platform/ti-vpe/cal.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/media/platform/ti-vpe/cal.c +2 -9
index fc3c212b96e1..576f5d0d5789 100644
@@ -1643,8 +1643,7 @@ of_get_next_endpoint(const struct device_node *parent,
 static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
 {
 	struct platform_device *pdev = ctx->dev->pdev;
-	struct device_node *ep_node, *port, *remote_ep,
-			*sensor_node, *parent;
+	struct device_node *ep_node, *port, *sensor_node, *parent;
 	struct v4l2_fwnode_endpoint *endpoint;
 	struct v4l2_async_subdev *asd;
 	u32 regval = 0;
@@ -1657,7 +1656,6 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
 
 	ep_node = NULL;
 	port = NULL;
-	remote_ep = NULL;
 	sensor_node = NULL;
 	ret = -EINVAL;
 
@@ -1703,12 +1701,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
 	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
 	asd->match.fwnode = of_fwnode_handle(sensor_node);
 
-	remote_ep = of_graph_get_remote_endpoint(ep_node);
-	if (!remote_ep) {
-		ctx_dbg(3, ctx, "can't get remote-endpoint\n");
-		goto cleanup_exit;
-	}
-	v4l2_fwnode_endpoint_parse(of_fwnode_handle(remote_ep), endpoint);
+	v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep_node), endpoint);
 
 	if (endpoint->bus_type != V4L2_MBUS_CSI2_DPHY) {
 		ctx_err(ctx, "Port:%d sub-device %pOFn is not a CSI2 device\n",
Signature · 1 line
2.11.0
author maintainer
#7 lore raw

PATCH 4/4 ti-vpe: Parse local endpoint for properties, not the remote one

ti-vpe driver parsed the remote endpoints for properties but ignored the local ones. Fix this by parsing the local endpoint properties instead.

---
since v1:

- Remove of_node_put(remote_ep) as well, the only remaining reference to it.

 drivers/media/platform/ti-vpe/cal.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/media/platform/ti-vpe/cal.c +2 -10
index fc3c212b96e1..8d075683e448 100644
@@ -1643,8 +1643,7 @@ of_get_next_endpoint(const struct device_node *parent,
 static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
 {
 	struct platform_device *pdev = ctx->dev->pdev;
-	struct device_node *ep_node, *port, *remote_ep,
-			*sensor_node, *parent;
+	struct device_node *ep_node, *port, *sensor_node, *parent;
 	struct v4l2_fwnode_endpoint *endpoint;
 	struct v4l2_async_subdev *asd;
 	u32 regval = 0;
@@ -1657,7 +1656,6 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
 
 	ep_node = NULL;
 	port = NULL;
-	remote_ep = NULL;
 	sensor_node = NULL;
 	ret = -EINVAL;
 
@@ -1703,12 +1701,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
 	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
 	asd->match.fwnode = of_fwnode_handle(sensor_node);
 
-	remote_ep = of_graph_get_remote_endpoint(ep_node);
-	if (!remote_ep) {
-		ctx_dbg(3, ctx, "can't get remote-endpoint\n");
-		goto cleanup_exit;
-	}
-	v4l2_fwnode_endpoint_parse(of_fwnode_handle(remote_ep), endpoint);
+	v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep_node), endpoint);
 
 	if (endpoint->bus_type != V4L2_MBUS_CSI2_DPHY) {
 		ctx_err(ctx, "Port:%d sub-device %pOFn is not a CSI2 device\n",
@@ -1759,7 +1752,6 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
 	sensor_node = NULL;
 
 cleanup_exit:
-	of_node_put(remote_ep);
 	of_node_put(sensor_node);
 	of_node_put(ep_node);
 	of_node_put(port);
Signature · 1 line
2.11.0
#8 lore raw

Re: [PATCH v1.1 4/4] ti-vpe: Parse local endpoint for properties, not the remote one

Sakari,

Thank you for the patch.

Sakari Ailus <[email protected]> wrote on Tue [2019-Mar-05 16:02:24 +0200]:

Quoted 2 lines

ti-vpe driver parsed the remote endpoints for properties but ignored the local ones. Fix this by parsing the local endpoint properties instead.

I am not sure I understand the logic here. For CSI2 sensor as far as I understand the lane mapping (clock and data) is driven from the sensor side. The bridge driver (in this case CAL) needs to setup the receiver side based on what the sensor (aka remote endpoint) can provide.

I failed to see how this fixes things here.

Are you suggesting that sensor relevant properties be set (and effectively duplicated) on the bridge/receiver side?

Some sensor can and do handle multiple data lanes configuration so the sensor driver also needs to use those properties at probe time, duplicating the lane data is just asking for a mismatch to happen, no?

Benoit

Quoted 57 lines

---
since v1:

- Remove of_node_put(remote_ep) as well, the only remaining reference to it.

 drivers/media/platform/ti-vpe/cal.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/media/platform/ti-vpe/cal.c +2 -10
index fc3c212b96e1..8d075683e448 100644
@@ -1643,8 +1643,7 @@ of_get_next_endpoint(const struct device_node *parent,
 static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
 {
 	struct platform_device *pdev = ctx->dev->pdev;
-	struct device_node *ep_node, *port, *remote_ep,
-			*sensor_node, *parent;
+	struct device_node *ep_node, *port, *sensor_node, *parent;
 	struct v4l2_fwnode_endpoint *endpoint;
 	struct v4l2_async_subdev *asd;
 	u32 regval = 0;
@@ -1657,7 +1656,6 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
 
 	ep_node = NULL;
 	port = NULL;
-	remote_ep = NULL;
 	sensor_node = NULL;
 	ret = -EINVAL;
 
@@ -1703,12 +1701,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
 	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
 	asd->match.fwnode = of_fwnode_handle(sensor_node);
 
-	remote_ep = of_graph_get_remote_endpoint(ep_node);
-	if (!remote_ep) {
-		ctx_dbg(3, ctx, "can't get remote-endpoint\n");
-		goto cleanup_exit;
-	}
-	v4l2_fwnode_endpoint_parse(of_fwnode_handle(remote_ep), endpoint);
+	v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep_node), endpoint);
 
 	if (endpoint->bus_type != V4L2_MBUS_CSI2_DPHY) {
 		ctx_err(ctx, "Port:%d sub-device %pOFn is not a CSI2 device\n",
@@ -1759,7 +1752,6 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
 	sensor_node = NULL;
 
 cleanup_exit:
-	of_node_put(remote_ep);
 	of_node_put(sensor_node);
 	of_node_put(ep_node);
 	of_node_put(port);
Signature · 1 line
2.11.0
author maintainer
#9 lore raw

Re: [PATCH v1.1 4/4] ti-vpe: Parse local endpoint for properties, not the remote one

Hi Benoit,

Quoted 13 lines · Benoit Parrot

Sakari,

Thank you for the patch.

Sakari Ailus <[email protected]> wrote on Tue [2019-Mar-05 16:02:24 +0200]:

Quoted 2 lines

ti-vpe driver parsed the remote endpoints for properties but ignored the local ones. Fix this by parsing the local endpoint properties instead.

I am not sure I understand the logic here. For CSI2 sensor as far as I understand the lane mapping (clock and data) is driven from the sensor side. The bridge driver (in this case CAL) needs to setup the receiver side based on what the sensor (aka remote endpoint) can provide.

Quoted 4 lines

I failed to see how this fixes things here.

Are you suggesting that sensor relevant properties be set (and effectively duplicated) on the bridge/receiver side?

Yes. The endpoint configuration in general is local to the device and should not be accessed from other device drivers.

The lane mapping, for instance, is specific to a given device --- and may differ even between for two connected endpoints. It's used to reorder the PHY lanes (if the device supports that). Same goes for the clock lane.

See e.g. arch/arm/boot/dts/omap3-n9.dts .

Quoted 4 lines

Some sensor can and do handle multiple data lanes configuration so the sensor driver also needs to use those properties at probe time, duplicating the lane data is just asking for a mismatch to happen, no?

It's a different configuration on the sensor side. We currently have no checks in place to verify that the two would match. I haven't heard of this would have really been a problem though.

The frame descriptors should be used for runtime configuration. Niklas and more recently Jacopo have been working on that.

Signature · 4 lines
Kind regards,

Sakari Ailus
[email protected]
#10 lore raw

Re: [PATCH v1.1 4/4] ti-vpe: Parse local endpoint for properties, not the remote one

Sakari Ailus <[email protected]> wrote on Tue [2019-Mar-05 18:32:40 +0200]:

Quoted 21 lines

Hi Benoit,

Quoted 13 lines · Benoit Parrot

Sakari,

Thank you for the patch.

Sakari Ailus <[email protected]> wrote on Tue [2019-Mar-05 16:02:24 +0200]:

Quoted 2 lines

ti-vpe driver parsed the remote endpoints for properties but ignored the local ones. Fix this by parsing the local endpoint properties instead.

I am not sure I understand the logic here. For CSI2 sensor as far as I understand the lane mapping (clock and data) is driven from the sensor side. The bridge driver (in this case CAL) needs to setup the receiver side based on what the sensor (aka remote endpoint) can provide.

Quoted 4 lines

I failed to see how this fixes things here.

Are you suggesting that sensor relevant properties be set (and effectively duplicated) on the bridge/receiver side?

Quoted 6 lines

Yes. The endpoint configuration in general is local to the device and should not be accessed from other device drivers.

The lane mapping, for instance, is specific to a given device --- and may differ even between for two connected endpoints. It's used to reorder the PHY lanes (if the device supports that). Same goes for the clock lane.

I did not see omap3isp having lane reorder capability, but I guess it would be possible for instance, that a sensor uses clock lane 0 and data lane 1 & 2 but the way it is wired on the board makes it that the receiver would see sensor lane 0 on device lane 2 and so on... Not sure why you would wire it up that way but who knows...

Quoted 11 lines

See e.g. arch/arm/boot/dts/omap3-n9.dts .

Quoted 4 lines

Some sensor can and do handle multiple data lanes configuration so the sensor driver also needs to use those properties at probe time, duplicating the lane data is just asking for a mismatch to happen, no?

It's a different configuration on the sensor side. We currently have no checks in place to verify that the two would match. I haven't heard of this would have really been a problem though.

I had just never thought about this cases, to me a single source of information is better than 2. But anyhow I guess I'll have to update all of my relevant dts files in the near future.

Benoit

Quoted 9 lines

The frame descriptors should be used for runtime configuration. Niklas and more recently Jacopo have been working on that.

Signature · 4 lines
Kind regards,

Sakari Ailus
[email protected]
author maintainer
#11 lore raw

Re: [PATCH v1.1 4/4] ti-vpe: Parse local endpoint for properties, not the remote one

Quoted 29 lines · Benoit Parrot

Sakari Ailus <[email protected]> wrote on Tue [2019-Mar-05 18:32:40 +0200]:

Quoted 21 lines

Hi Benoit,

Quoted 13 lines · Benoit Parrot

Sakari,

Thank you for the patch.

Sakari Ailus <[email protected]> wrote on Tue [2019-Mar-05 16:02:24 +0200]:

Quoted 2 lines

ti-vpe driver parsed the remote endpoints for properties but ignored the local ones. Fix this by parsing the local endpoint properties instead.

I am not sure I understand the logic here. For CSI2 sensor as far as I understand the lane mapping (clock and data) is driven from the sensor side. The bridge driver (in this case CAL) needs to setup the receiver side based on what the sensor (aka remote endpoint) can provide.

Quoted 4 lines

I failed to see how this fixes things here.

Are you suggesting that sensor relevant properties be set (and effectively duplicated) on the bridge/receiver side?

Quoted 6 lines

Yes. The endpoint configuration in general is local to the device and should not be accessed from other device drivers.

The lane mapping, for instance, is specific to a given device --- and may differ even between for two connected endpoints. It's used to reorder the PHY lanes (if the device supports that). Same goes for the clock lane.

Quoted 5 lines

I did not see omap3isp having lane reorder capability, but I guess it would be possible for instance, that a sensor uses clock lane 0 and data lane 1 & 2 but the way it is wired on the board makes it that the receiver would see sensor lane 0 on device lane 2 and so on... Not sure why you would wire it up that way but who knows...

I presume the feature is there to ease PCB design.

Quoted 3 lines
Quoted 3 lines

See e.g. arch/arm/boot/dts/omap3-n9.dts .

	     ^

There it is.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

Some sensor can and do handle multiple data lanes configuration so the sensor driver also needs to use those properties at probe time, duplicating the lane data is just asking for a mismatch to happen, no?

Quoted 7 lines
Quoted 3 lines

It's a different configuration on the sensor side. We currently have no checks in place to verify that the two would match. I haven't heard of this would have really been a problem though.

I had just never thought about this cases, to me a single source of information is better than 2. But anyhow I guess I'll have to update all of my relevant dts files in the near future.

Do you have in-kernel dts files using this? I presume the driver should then figure out whether the local endpoint has a configuration and if it doesn't, then look it up from the remote one. Otherwise old dts binaries will break. :-(

Signature · 4 lines
Regards,

Sakari Ailus
[email protected]
#12 lore raw

Re: [PATCH v1.1 4/4] ti-vpe: Parse local endpoint for properties, not the remote one

Sakari Ailus <[email protected]> wrote on Tue [2019-Mar-05 22:48:44 +0200]:

Quoted 40 lines · Benoit Parrot
Quoted 29 lines

Sakari Ailus <[email protected]> wrote on Tue [2019-Mar-05 18:32:40 +0200]:

Quoted 21 lines

Hi Benoit,

Quoted 13 lines · Benoit Parrot

Sakari,

Thank you for the patch.

Sakari Ailus <[email protected]> wrote on Tue [2019-Mar-05 16:02:24 +0200]:

Quoted 2 lines

ti-vpe driver parsed the remote endpoints for properties but ignored the local ones. Fix this by parsing the local endpoint properties instead.

I am not sure I understand the logic here. For CSI2 sensor as far as I understand the lane mapping (clock and data) is driven from the sensor side. The bridge driver (in this case CAL) needs to setup the receiver side based on what the sensor (aka remote endpoint) can provide.

Quoted 4 lines

I failed to see how this fixes things here.

Are you suggesting that sensor relevant properties be set (and effectively duplicated) on the bridge/receiver side?

Quoted 6 lines

Yes. The endpoint configuration in general is local to the device and should not be accessed from other device drivers.

The lane mapping, for instance, is specific to a given device --- and may differ even between for two connected endpoints. It's used to reorder the PHY lanes (if the device supports that). Same goes for the clock lane.

Quoted 5 lines

I did not see omap3isp having lane reorder capability, but I guess it would be possible for instance, that a sensor uses clock lane 0 and data lane 1 & 2 but the way it is wired on the board makes it that the receiver would see sensor lane 0 on device lane 2 and so on... Not sure why you would wire it up that way but who knows...

I presume the feature is there to ease PCB design.

Quoted 2 lines
Quoted 2 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

See e.g. arch/arm/boot/dts/omap3-n9.dts .

	     ^

There it is.

Yes I saw that the sensor describes its clock-lanes as 0 and data-lanes as 1 & 2. And that the OMAP3ISP receiver describes its clock-lanes as 2 and data-lanes as 1 & 3.

But when I looked at the driver code itself it just uses those lane config without doing anything else, so to me that just point to the way it's wired up on the board, nothing more. (although I have not looked into any schematics so I am just guessing here)

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines

Some sensor can and do handle multiple data lanes configuration so the sensor driver also needs to use those properties at probe time, duplicating the lane data is just asking for a mismatch to happen, no?

It's a different configuration on the sensor side. We currently have no checks in place to verify that the two would match. I haven't heard of this would have really been a problem though.

Quoted 8 lines
Quoted 3 lines

I had just never thought about this cases, to me a single source of information is better than 2. But anyhow I guess I'll have to update all of my relevant dts files in the near future.

Do you have in-kernel dts files using this? I presume the driver should then figure out whether the local endpoint has a configuration and if it doesn't, then look it up from the remote one. Otherwise old dts binaries will break. :-(

No I do not currently have any dts in mainline using this feature as of yet. It is used in several DT file in our own kernel tree so I'll have to update those for sure. But between our major releases we do not guarantee DTBs backward compatibility, so depending on when I merge this we may not need to add backward compat code.

I guess you are free to augment the patch to add backward support since this patch is changing the current DT parsing behavior for this driver.

I do have a backlog of patches for this driver I need to up-stream. If you prefer you can drop this patch from the series then I can include a version of it with my set. Up to you.

Benoit

Quoted 6 lines
Signature · 5 lines
-- 
Regards,

Sakari Ailus
[email protected]
author maintainer
#13 lore raw

Re: [PATCH v1.1 4/4] ti-vpe: Parse local endpoint for properties, not the remote one

Quoted 47 lines · Benoit Parrot

Sakari Ailus <[email protected]> wrote on Tue [2019-Mar-05 22:48:44 +0200]:

Quoted 40 lines · Benoit Parrot
Quoted 29 lines

Sakari Ailus <[email protected]> wrote on Tue [2019-Mar-05 18:32:40 +0200]:

Quoted 21 lines

Hi Benoit,

Quoted 13 lines · Benoit Parrot

Sakari,

Thank you for the patch.

Sakari Ailus <[email protected]> wrote on Tue [2019-Mar-05 16:02:24 +0200]:

Quoted 2 lines

ti-vpe driver parsed the remote endpoints for properties but ignored the local ones. Fix this by parsing the local endpoint properties instead.

I am not sure I understand the logic here. For CSI2 sensor as far as I understand the lane mapping (clock and data) is driven from the sensor side. The bridge driver (in this case CAL) needs to setup the receiver side based on what the sensor (aka remote endpoint) can provide.

Quoted 4 lines

I failed to see how this fixes things here.

Are you suggesting that sensor relevant properties be set (and effectively duplicated) on the bridge/receiver side?

Quoted 6 lines

Yes. The endpoint configuration in general is local to the device and should not be accessed from other device drivers.

The lane mapping, for instance, is specific to a given device --- and may differ even between for two connected endpoints. It's used to reorder the PHY lanes (if the device supports that). Same goes for the clock lane.

Quoted 5 lines

I did not see omap3isp having lane reorder capability, but I guess it would be possible for instance, that a sensor uses clock lane 0 and data lane 1 & 2 but the way it is wired on the board makes it that the receiver would see sensor lane 0 on device lane 2 and so on... Not sure why you would wire it up that way but who knows...

I presume the feature is there to ease PCB design.

Quoted 2 lines
Quoted 2 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

See e.g. arch/arm/boot/dts/omap3-n9.dts .

	     ^

There it is.

Quoted 8 lines

Yes I saw that the sensor describes its clock-lanes as 0 and data-lanes as 1 & 2. And that the OMAP3ISP receiver describes its clock-lanes as 2 and data-lanes as 1 & 3.

But when I looked at the driver code itself it just uses those lane config without doing anything else, so to me that just point to the way it's wired up on the board, nothing more. (although I have not looked into any schematics so I am just guessing here)

It is wired on the board... and that's the point here indeed. The register configured based on this is ISPCSI2_PHY_CFG (driver name, I don't know what the datasheet uses).

Quoted 27 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 7 lines

Some sensor can and do handle multiple data lanes configuration so the sensor driver also needs to use those properties at probe time, duplicating the lane data is just asking for a mismatch to happen, no?

It's a different configuration on the sensor side. We currently have no checks in place to verify that the two would match. I haven't heard of this would have really been a problem though.

Quoted 8 lines
Quoted 3 lines

I had just never thought about this cases, to me a single source of information is better than 2. But anyhow I guess I'll have to update all of my relevant dts files in the near future.

Do you have in-kernel dts files using this? I presume the driver should then figure out whether the local endpoint has a configuration and if it doesn't, then look it up from the remote one. Otherwise old dts binaries will break. :-(

No I do not currently have any dts in mainline using this feature as of yet. It is used in several DT file in our own kernel tree so I'll have to update those for sure. But between our major releases we do not guarantee DTBs backward compatibility, so depending on when I merge this we may not need to add backward compat code.

Quoted 6 lines

I guess you are free to augment the patch to add backward support since this patch is changing the current DT parsing behavior for this driver.

I do have a backlog of patches for this driver I need to up-stream. If you prefer you can drop this patch from the series then I can include a version of it with my set. Up to you.

I have an upcoming patch that changes the code again. :-) So I'll keep it in my set.

Btw. I checked Documentation/devicetree/bindings/media/ti-cal.txt and it seems a bit incomplete. There is no endpoint configuration on CAL side (which is understandable now), but there's also the "slave-mode" property which looks just inapplicable for this type or hardware.

Also "reg = <0>" can be omitted on ar0330 side. Is this btw. an Aptina image sensor or some lesser known TI chip with somewhat similar properties? :-) The binding file should describe relevant properties for the device as well as the valid values for them. (Excluding graph etc. documentation which already exists elsewhere.)

Would you like to address these? :-)

Thanks.

Signature · 4 lines
Kind regards,

Sakari Ailus
[email protected]
#14 lore raw

Re: [PATCH 4/4] ti-vpe: Parse local endpoint for properties, not the remote one

In reply to Sakari Ailus
I love your patch! Yet something to improve:

Hi Sakari,

I love your patch! Yet something to improve:

[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on v5.0 next-20190306]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Sakari-Ailus/V4L2-fwnode-framework-and-driver-fixes/20190308-042715
base:   git://linuxtv.org/media_tree.git master
config: sparc64-allyesconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 8.2.0-11) 8.2.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=8.2.0 make.cross ARCH=sparc64

All errors (new ones prefixed by >>):

drivers/media//platform/ti-vpe/cal.c: In function 'of_cal_create_instance':

>> drivers/media//platform/ti-vpe/cal.c:1755:14: error: 'remote_ep' undeclared (first use in this function)
     of_node_put(remote_ep);
                 ^~~~~~~~~

drivers/media//platform/ti-vpe/cal.c:1755:14: note: each undeclared identifier is reported only once for each function it appears in

vim +/remote_ep +1755 drivers/media//platform/ti-vpe/cal.c

343e89a79 Benoit Parrot         2016-01-06  1642  
343e89a79 Benoit Parrot         2016-01-06  1643  static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
343e89a79 Benoit Parrot         2016-01-06  1644  {
343e89a79 Benoit Parrot         2016-01-06  1645  	struct platform_device *pdev = ctx->dev->pdev;
e8013a352 Sakari Ailus          2019-03-05  1646  	struct device_node *ep_node, *port, *sensor_node, *parent;
859969b38 Sakari Ailus          2016-08-26  1647  	struct v4l2_fwnode_endpoint *endpoint;
343e89a79 Benoit Parrot         2016-01-06  1648  	struct v4l2_async_subdev *asd;
343e89a79 Benoit Parrot         2016-01-06  1649  	u32 regval = 0;
343e89a79 Benoit Parrot         2016-01-06  1650  	int ret, index, found_port = 0, lane;
343e89a79 Benoit Parrot         2016-01-06  1651  
343e89a79 Benoit Parrot         2016-01-06  1652  	parent = pdev->dev.of_node;
343e89a79 Benoit Parrot         2016-01-06  1653  
343e89a79 Benoit Parrot         2016-01-06  1654  	asd = &ctx->asd;
343e89a79 Benoit Parrot         2016-01-06  1655  	endpoint = &ctx->endpoint;
343e89a79 Benoit Parrot         2016-01-06  1656  
343e89a79 Benoit Parrot         2016-01-06  1657  	ep_node = NULL;
343e89a79 Benoit Parrot         2016-01-06  1658  	port = NULL;
343e89a79 Benoit Parrot         2016-01-06  1659  	sensor_node = NULL;
343e89a79 Benoit Parrot         2016-01-06  1660  	ret = -EINVAL;
343e89a79 Benoit Parrot         2016-01-06  1661  
343e89a79 Benoit Parrot         2016-01-06  1662  	ctx_dbg(3, ctx, "Scanning Port node for csi2 port: %d\n", inst);
343e89a79 Benoit Parrot         2016-01-06  1663  	for (index = 0; index < CAL_NUM_CSI2_PORTS; index++) {
343e89a79 Benoit Parrot         2016-01-06  1664  		port = of_get_next_port(parent, port);
343e89a79 Benoit Parrot         2016-01-06  1665  		if (!port) {
343e89a79 Benoit Parrot         2016-01-06  1666  			ctx_dbg(1, ctx, "No port node found for csi2 port:%d\n",
343e89a79 Benoit Parrot         2016-01-06  1667  				index);
343e89a79 Benoit Parrot         2016-01-06  1668  			goto cleanup_exit;
343e89a79 Benoit Parrot         2016-01-06  1669  		}
343e89a79 Benoit Parrot         2016-01-06  1670  
343e89a79 Benoit Parrot         2016-01-06  1671  		/* Match the slice number with <REG> */
343e89a79 Benoit Parrot         2016-01-06  1672  		of_property_read_u32(port, "reg", &regval);
343e89a79 Benoit Parrot         2016-01-06  1673  		ctx_dbg(3, ctx, "port:%d inst:%d <reg>:%d\n",
343e89a79 Benoit Parrot         2016-01-06  1674  			index, inst, regval);
343e89a79 Benoit Parrot         2016-01-06  1675  		if ((regval == inst) && (index == inst)) {
343e89a79 Benoit Parrot         2016-01-06  1676  			found_port = 1;
343e89a79 Benoit Parrot         2016-01-06  1677  			break;
343e89a79 Benoit Parrot         2016-01-06  1678  		}
343e89a79 Benoit Parrot         2016-01-06  1679  	}
343e89a79 Benoit Parrot         2016-01-06  1680  
343e89a79 Benoit Parrot         2016-01-06  1681  	if (!found_port) {
343e89a79 Benoit Parrot         2016-01-06  1682  		ctx_dbg(1, ctx, "No port node matches csi2 port:%d\n",
343e89a79 Benoit Parrot         2016-01-06  1683  			inst);
343e89a79 Benoit Parrot         2016-01-06  1684  		goto cleanup_exit;
343e89a79 Benoit Parrot         2016-01-06  1685  	}
343e89a79 Benoit Parrot         2016-01-06  1686  
343e89a79 Benoit Parrot         2016-01-06  1687  	ctx_dbg(3, ctx, "Scanning sub-device for csi2 port: %d\n",
343e89a79 Benoit Parrot         2016-01-06  1688  		inst);
343e89a79 Benoit Parrot         2016-01-06  1689  
343e89a79 Benoit Parrot         2016-01-06  1690  	ep_node = of_get_next_endpoint(port, ep_node);
343e89a79 Benoit Parrot         2016-01-06  1691  	if (!ep_node) {
343e89a79 Benoit Parrot         2016-01-06  1692  		ctx_dbg(3, ctx, "can't get next endpoint\n");
343e89a79 Benoit Parrot         2016-01-06  1693  		goto cleanup_exit;
343e89a79 Benoit Parrot         2016-01-06  1694  	}
343e89a79 Benoit Parrot         2016-01-06  1695  
343e89a79 Benoit Parrot         2016-01-06  1696  	sensor_node = of_graph_get_remote_port_parent(ep_node);
343e89a79 Benoit Parrot         2016-01-06  1697  	if (!sensor_node) {
343e89a79 Benoit Parrot         2016-01-06  1698  		ctx_dbg(3, ctx, "can't get remote parent\n");
343e89a79 Benoit Parrot         2016-01-06  1699  		goto cleanup_exit;
343e89a79 Benoit Parrot         2016-01-06  1700  	}
859969b38 Sakari Ailus          2016-08-26  1701  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
4e48afecd Mauro Carvalho Chehab 2017-09-27  1702  	asd->match.fwnode = of_fwnode_handle(sensor_node);
343e89a79 Benoit Parrot         2016-01-06  1703  
e8013a352 Sakari Ailus          2019-03-05  1704  	v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep_node), endpoint);
343e89a79 Benoit Parrot         2016-01-06  1705  
2d95e7ed0 Sakari Ailus          2018-07-03  1706  	if (endpoint->bus_type != V4L2_MBUS_CSI2_DPHY) {
f764e6d68 Rob Herring           2018-08-27  1707  		ctx_err(ctx, "Port:%d sub-device %pOFn is not a CSI2 device\n",
f764e6d68 Rob Herring           2018-08-27  1708  			inst, sensor_node);
343e89a79 Benoit Parrot         2016-01-06  1709  		goto cleanup_exit;
343e89a79 Benoit Parrot         2016-01-06  1710  	}
343e89a79 Benoit Parrot         2016-01-06  1711  
343e89a79 Benoit Parrot         2016-01-06  1712  	/* Store Virtual Channel number */
343e89a79 Benoit Parrot         2016-01-06  1713  	ctx->virtual_channel = endpoint->base.id;
343e89a79 Benoit Parrot         2016-01-06  1714  
343e89a79 Benoit Parrot         2016-01-06  1715  	ctx_dbg(3, ctx, "Port:%d v4l2-endpoint: CSI2\n", inst);
343e89a79 Benoit Parrot         2016-01-06  1716  	ctx_dbg(3, ctx, "Virtual Channel=%d\n", ctx->virtual_channel);
343e89a79 Benoit Parrot         2016-01-06  1717  	ctx_dbg(3, ctx, "flags=0x%08x\n", endpoint->bus.mipi_csi2.flags);
343e89a79 Benoit Parrot         2016-01-06  1718  	ctx_dbg(3, ctx, "clock_lane=%d\n", endpoint->bus.mipi_csi2.clock_lane);
343e89a79 Benoit Parrot         2016-01-06  1719  	ctx_dbg(3, ctx, "num_data_lanes=%d\n",
343e89a79 Benoit Parrot         2016-01-06  1720  		endpoint->bus.mipi_csi2.num_data_lanes);
343e89a79 Benoit Parrot         2016-01-06  1721  	ctx_dbg(3, ctx, "data_lanes= <\n");
343e89a79 Benoit Parrot         2016-01-06  1722  	for (lane = 0; lane < endpoint->bus.mipi_csi2.num_data_lanes; lane++)
343e89a79 Benoit Parrot         2016-01-06  1723  		ctx_dbg(3, ctx, "\t%d\n",
343e89a79 Benoit Parrot         2016-01-06  1724  			endpoint->bus.mipi_csi2.data_lanes[lane]);
343e89a79 Benoit Parrot         2016-01-06  1725  	ctx_dbg(3, ctx, "\t>\n");
343e89a79 Benoit Parrot         2016-01-06  1726  
f764e6d68 Rob Herring           2018-08-27  1727  	ctx_dbg(1, ctx, "Port: %d found sub-device %pOFn\n",
f764e6d68 Rob Herring           2018-08-27  1728  		inst, sensor_node);
343e89a79 Benoit Parrot         2016-01-06  1729  
d079f94c9 Steve Longerbeam      2018-09-29  1730  	v4l2_async_notifier_init(&ctx->notifier);
d079f94c9 Steve Longerbeam      2018-09-29  1731  
d079f94c9 Steve Longerbeam      2018-09-29  1732  	ret = v4l2_async_notifier_add_subdev(&ctx->notifier, asd);
d079f94c9 Steve Longerbeam      2018-09-29  1733  	if (ret) {
d079f94c9 Steve Longerbeam      2018-09-29  1734  		ctx_err(ctx, "Error adding asd\n");
d079f94c9 Steve Longerbeam      2018-09-29  1735  		goto cleanup_exit;
d079f94c9 Steve Longerbeam      2018-09-29  1736  	}
d079f94c9 Steve Longerbeam      2018-09-29  1737  
b6ee3f0dc Laurent Pinchart      2017-08-30  1738  	ctx->notifier.ops = &cal_async_ops;
343e89a79 Benoit Parrot         2016-01-06  1739  	ret = v4l2_async_notifier_register(&ctx->v4l2_dev,
343e89a79 Benoit Parrot         2016-01-06  1740  					   &ctx->notifier);
343e89a79 Benoit Parrot         2016-01-06  1741  	if (ret) {
343e89a79 Benoit Parrot         2016-01-06  1742  		ctx_err(ctx, "Error registering async notifier\n");
d079f94c9 Steve Longerbeam      2018-09-29  1743  		v4l2_async_notifier_cleanup(&ctx->notifier);
343e89a79 Benoit Parrot         2016-01-06  1744  		ret = -EINVAL;
343e89a79 Benoit Parrot         2016-01-06  1745  	}
343e89a79 Benoit Parrot         2016-01-06  1746  
d079f94c9 Steve Longerbeam      2018-09-29  1747  	/*
d079f94c9 Steve Longerbeam      2018-09-29  1748  	 * On success we need to keep reference on sensor_node, or
d079f94c9 Steve Longerbeam      2018-09-29  1749  	 * if notifier_cleanup was called above, sensor_node was
d079f94c9 Steve Longerbeam      2018-09-29  1750  	 * already put.
d079f94c9 Steve Longerbeam      2018-09-29  1751  	 */
d079f94c9 Steve Longerbeam      2018-09-29  1752  	sensor_node = NULL;
d079f94c9 Steve Longerbeam      2018-09-29  1753  
343e89a79 Benoit Parrot         2016-01-06  1754  cleanup_exit:
343e89a79 Benoit Parrot         2016-01-06 @1755  	of_node_put(remote_ep);
343e89a79 Benoit Parrot         2016-01-06  1756  	of_node_put(sensor_node);
343e89a79 Benoit Parrot         2016-01-06  1757  	of_node_put(ep_node);
343e89a79 Benoit Parrot         2016-01-06  1758  	of_node_put(port);
343e89a79 Benoit Parrot         2016-01-06  1759  
343e89a79 Benoit Parrot         2016-01-06  1760  	return ret;
343e89a79 Benoit Parrot         2016-01-06  1761  }
343e89a79 Benoit Parrot         2016-01-06  1762  

:::::: The code at line 1755 was first introduced by commit
:::::: 343e89a792a571b28b9c02850db7af2ef25ffb20 [media] media: ti-vpe: Add CAL v4l2 camera capture driver

:::::: TO: Benoit Parrot <[email protected]>
:::::: CC: Mauro Carvalho Chehab <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation