V4L2 fwnode rework; support for default configuration
Subsystems (19)
Sakari Ailus
maintainercover V4L2 fwnode rework; support for default configuration
Hello everyone,
I've long thought the V4L2 fwnode framework requires some work (it's buggy and it does not adequately serve common needs). This set should address in particular these matters:
- Most devices support a particular media bus type but the V4L2 fwnode framework was not able to use such information, but instead tried to guess the bus type with varying levels of success while drivers generally ignored the results. This patchset makes that possible --- setting a bus type enables parsing configuration for only that bus. Failing that check results in returning -ENXIO to be returned.
- Support specifying default configuration. If the endpoint has no configuration, the defaults set by the driver (as documented in DT bindings) will prevail. Any available configuration will still be read from the endpoint as one could expect. A common use case for this is e.g. the number of CSI-2 lanes. Few devices support lane mapping, and default 1:1 mapping is provided in absence of a valid default or configuration read OF.
- Debugging information is greatly improved.
- Recognition of the differences between CSI-2 D-PHY and C-PHY. All currently supported hardware (or at least drivers) is D-PHY only, so this change is still easy.
The smiapp driver is converted to use the new functionality. This patchset does not address remaining issues such as supporting setting defaults for e.g. bridge drivers with multiple ports, but with Steve Longerbeam's patchset we're much closer with that goal. I've rebased this set on top of Steve's. Albeit the two deal with the same files, there were only a few trivial conflicts.
Note that I've only tested parsing endpoints for the CSI-2 bus (no parallel IF hardware). Testing in general would be beneficial: the code flows are rather convoluted and different hardware tends to excercise different flows while the use of the use of defaults has a similar effect.
Comments are welcome.
I've pushed the patches (including Steve's) here:
<URL:https://git.linuxtv.org/sailus/media_tree.git/log/?h=v4l2-fwnode>
Sakari Ailus (21):
v4l: fwnode: Add debug prints for V4L2 endpoint property parsing
v4l: fwnode: Use fwnode_graph_for_each_endpoint
v4l: fwnode: Detect bus type correctly
v4l: fwnode: The CSI-2 clock is continuous if it's not non-continuous
dt-bindings: media: Specify bus type for MIPI D-PHY, others,
explicitly
v4l: fwnode: Add definitions for CSI-2 D-PHY, parallel and Bt.656
busses
v4l: mediabus: Recognise CSI-2 D-PHY and C-PHY
v4l: fwnode: Make use of newly specified bus types
v4l: fwnode: Read lane inversion information despite lane numbering
v4l: fwnode: Only assign configuration if there is no error
v4l: fwnode: Support driver-defined lane mapping defaults
v4l: fwnode: Support default CSI-2 lane mapping for drivers
v4l: fwnode: Parse the graph endpoint as last
v4l: fwnode: Use default parallel flags
v4l: fwnode: Allow setting default parameters
v4l: fwnode: Use media bus type for bus parser selection
v4l: fwnode: Print bus type
v4l: fwnode: Use V4L2 fwnode endpoint media bus type if set
v4l: fwnode: Support parsing of CSI-2 C-PHY endpoints
v4l: fwnode: Update V4L2 fwnode endpoint parsing documentation
smiapp: Query the V4L2 endpoint for a specific bus type
.../devicetree/bindings/media/video-interfaces.txt | 4 +- drivers/gpu/ipu-v3/ipu-csi.c | 2 +- drivers/media/i2c/adv7180.c | 2 +- drivers/media/i2c/ov2659.c | 14 +- drivers/media/i2c/ov5640.c | 4 +- drivers/media/i2c/ov5645.c | 2 +- drivers/media/i2c/ov7251.c | 4 +- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 2 +- drivers/media/i2c/s5k5baf.c | 4 +- drivers/media/i2c/s5k6aa.c | 2 +- drivers/media/i2c/smiapp/smiapp-core.c | 34 +- drivers/media/i2c/soc_camera/ov5642.c | 2 +- drivers/media/i2c/tc358743.c | 28 +- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +- drivers/media/platform/cadence/cdns-csi2rx.c | 2 +- drivers/media/platform/cadence/cdns-csi2tx.c | 2 +- drivers/media/platform/marvell-ccic/mcam-core.c | 4 +- drivers/media/platform/marvell-ccic/mmp-driver.c | 2 +- drivers/media/platform/omap3isp/isp.c | 2 +- drivers/media/platform/pxa_camera.c | 2 +- drivers/media/platform/rcar-vin/rcar-csi2.c | 2 +- drivers/media/platform/soc_camera/soc_mediabus.c | 2 +- drivers/media/platform/stm32/stm32-dcmi.c | 2 +- drivers/media/platform/ti-vpe/cal.c | 2 +- drivers/media/v4l2-core/v4l2-fwnode.c | 510 ++++++++++++++++----- drivers/staging/media/imx/imx-media-csi.c | 2 +- drivers/staging/media/imx/imx6-mipi-csi2.c | 2 +- drivers/staging/media/imx074/imx074.c | 2 +- include/media/v4l2-fwnode.h | 33 +- include/media/v4l2-mediabus.h | 8 +- 30 files changed, 505 insertions(+), 180 deletions(-)
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 1/21 v4l: fwnode: Add debug prints for V4L2 endpoint property parsing
Print debug info as standard V4L2 endpoint are parsed.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 108 ++++++++++++++++++++++++++-------- 1 file changed, 85 insertions(+), 23 deletions(-)
drivers/media/v4l2-core/v4l2-fwnode.c +85 -23
@@ -66,6 +66,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, lanes_used |=BIT (array[i]); bus->data_lanes[i] = array[i]; +pr_debug ("lane %u position %u\n" , i, array[i]); } rval = fwnode_property_read_u32_array(fwnode,
@@ -82,8 +83,13 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,"lane-polarities" , array, 1 + bus->num_data_lanes); -for (i =0 ; i <1 + bus->num_data_lanes; i++) +for (i =0 ; i <1 + bus->num_data_lanes; i++) { bus->lane_polarities[i] = array[i]; +pr_debug ("lane %u polarity %sinverted" , + i, array[i] ?"" :"not " ); + } + }else { +pr_debug ("no lane polarities defined, assuming not inverted\n" ); } }
@@ -95,12 +101,15 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, bus->clock_lane = v; have_clk_lane = true; +pr_debug ("clock lane position %u\n" , v); } -if (fwnode_property_present (fwnode,"clock-noncontinuous" )) +if (fwnode_property_present (fwnode,"clock-noncontinuous" )) { flags |=V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK ; -else if (have_clk_lane || bus->num_data_lanes >0 ) +pr_debug ("non-continuous clock\n" ); + }else if (have_clk_lane || bus->num_data_lanes >0 ) { flags |=V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ; + } bus->flags = flags; vep->bus_type =V4L2_MBUS_CSI2 ;
@@ -115,48 +124,69 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(unsigned int flags =0 ;u32 v; -if (!fwnode_property_read_u32 (fwnode,"hsync-active" , &v)) +if (!fwnode_property_read_u32 (fwnode,"hsync-active" , &v)) { flags |= v ?V4L2_MBUS_HSYNC_ACTIVE_HIGH :V4L2_MBUS_HSYNC_ACTIVE_LOW ; +pr_debug ("hsync-active %s\n" , v ?"high" :"low" ); + } -if (!fwnode_property_read_u32 (fwnode,"vsync-active" , &v)) +if (!fwnode_property_read_u32 (fwnode,"vsync-active" , &v)) { flags |= v ?V4L2_MBUS_VSYNC_ACTIVE_HIGH :V4L2_MBUS_VSYNC_ACTIVE_LOW ; +pr_debug ("vsync-active %s\n" , v ?"high" :"low" ); + } -if (!fwnode_property_read_u32 (fwnode,"field-even-active" , &v)) +if (!fwnode_property_read_u32 (fwnode,"field-even-active" , &v)) { flags |= v ?V4L2_MBUS_FIELD_EVEN_HIGH :V4L2_MBUS_FIELD_EVEN_LOW ; +pr_debug ("field-even-active %s\n" , v ?"high" :"low" ); + } +if (flags) vep->bus_type =V4L2_MBUS_PARALLEL ;else vep->bus_type =V4L2_MBUS_BT656 ; -if (!fwnode_property_read_u32 (fwnode,"pclk-sample" , &v)) +if (!fwnode_property_read_u32 (fwnode,"pclk-sample" , &v)) { flags |= v ?V4L2_MBUS_PCLK_SAMPLE_RISING :V4L2_MBUS_PCLK_SAMPLE_FALLING ; +pr_debug ("pclk-sample %s\n" , v ?"high" :"low" ); + } -if (!fwnode_property_read_u32 (fwnode,"data-active" , &v)) +if (!fwnode_property_read_u32 (fwnode,"data-active" , &v)) { flags |= v ?V4L2_MBUS_DATA_ACTIVE_HIGH :V4L2_MBUS_DATA_ACTIVE_LOW ; +pr_debug ("data-active %s\n" , v ?"high" :"low" ); + } -if (fwnode_property_present (fwnode,"slave-mode" )) +if (fwnode_property_present (fwnode,"slave-mode" )) { +pr_debug ("slave mode\n" ); flags |=V4L2_MBUS_SLAVE ; -else + }else { flags |=V4L2_MBUS_MASTER ; + } -if (!fwnode_property_read_u32 (fwnode,"bus-width" , &v)) +if (!fwnode_property_read_u32 (fwnode,"bus-width" , &v)) { bus->bus_width = v; +pr_debug ("bus-width %u\n" , v); + } -if (!fwnode_property_read_u32 (fwnode,"data-shift" , &v)) +if (!fwnode_property_read_u32 (fwnode,"data-shift" , &v)) { bus->data_shift = v; +pr_debug ("data-shift %u\n" , v); + } -if (!fwnode_property_read_u32 (fwnode,"sync-on-green-active" , &v)) +if (!fwnode_property_read_u32 (fwnode,"sync-on-green-active" , &v)) { flags |= v ?V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH :V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW ; +pr_debug ("sync-on-green-active %s\n" , v ?"high" :"low" ); + } -if (!fwnode_property_read_u32 (fwnode,"data-enable-active" , &v)) +if (!fwnode_property_read_u32 (fwnode,"data-enable-active" , &v)) { flags |= v ?V4L2_MBUS_DATA_ENABLE_HIGH :V4L2_MBUS_DATA_ENABLE_LOW ; +pr_debug ("data-enable-active %s\n" , v ?"high" :"low" ); + } bus->flags = flags;
@@ -170,17 +200,25 @@ v4l2_fwnode_endpoint_parse_csi1_bus(struct fwnode_handle *fwnode,struct v4l2_fwnode_bus_mipi_csi1 *bus = &vep->bus.mipi_csi1;u32 v; -if (!fwnode_property_read_u32 (fwnode,"clock-inv" , &v)) +if (!fwnode_property_read_u32 (fwnode,"clock-inv" , &v)) { bus->clock_inv = v; +pr_debug ("clock-inv %u\n" , v); + } -if (!fwnode_property_read_u32 (fwnode,"strobe" , &v)) +if (!fwnode_property_read_u32 (fwnode,"strobe" , &v)) { bus->strobe = v; +pr_debug ("strobe %u\n" , v); + } -if (!fwnode_property_read_u32 (fwnode,"data-lanes" , &v)) +if (!fwnode_property_read_u32 (fwnode,"data-lanes" , &v)) { bus->data_lane = v; +pr_debug ("data-lanes %u\n" , v); + } -if (!fwnode_property_read_u32 (fwnode,"clock-lanes" , &v)) +if (!fwnode_property_read_u32 (fwnode,"clock-lanes" , &v)) { bus->clock_lane = v; +pr_debug ("clock-lanes %u\n" , v); + }if (bus_type ==V4L2_FWNODE_BUS_TYPE_CCP2 ) vep->bus_type =V4L2_MBUS_CCP2 ;
@@ -188,12 +226,14 @@ v4l2_fwnode_endpoint_parse_csi1_bus(struct fwnode_handle *fwnode, vep->bus_type =V4L2_MBUS_CSI1 ; } -int v4l2_fwnode_endpoint_parse (struct fwnode_handle *fwnode, -struct v4l2_fwnode_endpoint *vep) +static int __v4l2_fwnode_endpoint_parse (struct fwnode_handle *fwnode, +struct v4l2_fwnode_endpoint *vep) {u32 bus_type =0 ;int rval; +pr_debug ("===== begin V4L2 endpoint properties\n" ); +fwnode_graph_parse_endpoint (fwnode, &vep->base);/* Zero fields from bus_type to until the end */
@@ -214,16 +254,30 @@ int v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,if (vep->bus.mipi_csi2.flags ==0 )v4l2_fwnode_endpoint_parse_parallel_bus (fwnode, vep); -return 0 ; +break ;case V4L2_FWNODE_BUS_TYPE_CCP2 :case V4L2_FWNODE_BUS_TYPE_CSI1 :v4l2_fwnode_endpoint_parse_csi1_bus (fwnode, vep, bus_type); -return 0 ; +break ;default :pr_warn ("unsupported bus type %u\n" , bus_type);return -EINVAL ; } + +return 0 ; +} + +int v4l2_fwnode_endpoint_parse (struct fwnode_handle *fwnode, +struct v4l2_fwnode_endpoint *vep) +{ +int ret; + + ret =__v4l2_fwnode_endpoint_parse (fwnode, vep); + +pr_debug ("===== end V4L2 endpoint properties\n" ); + +return ret; }EXPORT_SYMBOL_GPL (v4l2_fwnode_endpoint_parse);
@@ -247,13 +301,15 @@ struct v4l2_fwnode_endpoint *v4l2_fwnode_endpoint_alloc_parse(if (!vep)return ERR_PTR (-ENOMEM ); - rval =v4l2_fwnode_endpoint_parse (fwnode, vep); + rval =__v4l2_fwnode_endpoint_parse (fwnode, vep);if (rval <0 ) goto out_err; rval =fwnode_property_read_u64_array (fwnode,"link-frequencies" ,NULL ,0 );if (rval >0 ) { +unsigned int i; + vep->link_frequencies =kmalloc_array (rval,sizeof (*vep->link_frequencies),GFP_KERNEL );
@@ -269,8 +325,14 @@ struct v4l2_fwnode_endpoint *v4l2_fwnode_endpoint_alloc_parse( vep->nr_of_link_frequencies);if (rval <0 ) goto out_err; + +for (i =0 ; i < vep->nr_of_link_frequencies; i++) +pr_info ("link-frequencies %u value %llu\n" , i, + vep->link_frequencies[i]); } +pr_debug ("===== end V4L2 endpoint properties\n" ); +return vep; out_err:
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 2/21 v4l: fwnode: Use fwnode_graph_for_each_endpoint
In reply to Sakari AilusUse fwnode_graph_for_each_endpoint iterator for better readability.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/v4l2-core/v4l2-fwnode.c +1 -2
@@ -456,8 +456,7 @@ static int __v4l2_async_notifier_parse_fwnode_endpoints(if (WARN_ON (asd_struct_size <sizeof (struct v4l2_async_subdev )))return -EINVAL ; -for (fwnode =NULL ; (fwnode =fwnode_graph_get_next_endpoint ( -dev_fwnode (dev), fwnode)); ) { +fwnode_graph_for_each_endpoint (dev_fwnode (dev), fwnode) {struct fwnode_handle *dev_fwnode;bool is_available;
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 3/21 v4l: fwnode: Detect bus type correctly
In reply to Sakari AilusIn case the device supports multiple video bus types on an endpoint, the V4L2 fwnode framework attempts to detect the type based on the available information. This wasn't working really well, and sometimes could lead to the V4L2 fwnode endpoint struct as being mishandled between the bus types.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 43 +++++++++++++++++++---------------- include/media/v4l2-mediabus.h | 2 ++ 2 files changed, 26 insertions(+), 19 deletions(-)
drivers/media/v4l2-core/v4l2-fwnode.c +24 -19
@@ -111,8 +111,10 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, flags |=V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ; } - bus->flags = flags; - vep->bus_type =V4L2_MBUS_CSI2 ; +if (lanes_used || have_clk_lane || flags) { + bus->flags = flags; + vep->bus_type =V4L2_MBUS_CSI2 ; + }return 0 ; }
@@ -122,6 +124,7 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus( {struct v4l2_fwnode_bus_parallel *bus = &vep->bus.parallel;unsigned int flags =0 ; +bool is_parallel = false;u32 v;if (!fwnode_property_read_u32 (fwnode,"hsync-active" , &v)) {
@@ -142,11 +145,6 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(pr_debug ("field-even-active %s\n" , v ?"high" :"low" ); } -if (flags) - vep->bus_type =V4L2_MBUS_PARALLEL ; -else - vep->bus_type =V4L2_MBUS_BT656 ; -if (!fwnode_property_read_u32 (fwnode,"pclk-sample" , &v)) { flags |= v ?V4L2_MBUS_PCLK_SAMPLE_RISING :V4L2_MBUS_PCLK_SAMPLE_FALLING ;
@@ -168,11 +166,13 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(if (!fwnode_property_read_u32 (fwnode,"bus-width" , &v)) { bus->bus_width = v; + is_parallel = true;pr_debug ("bus-width %u\n" , v); }if (!fwnode_property_read_u32 (fwnode,"data-shift" , &v)) { bus->data_shift = v; + is_parallel = true;pr_debug ("data-shift %u\n" , v); }
@@ -188,14 +188,24 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(pr_debug ("data-enable-active %s\n" , v ?"high" :"low" ); } - bus->flags = flags; - +if (flags || is_parallel) { + bus->flags = flags; +if (flags & (V4L2_MBUS_HSYNC_ACTIVE_HIGH | +V4L2_MBUS_HSYNC_ACTIVE_LOW | +V4L2_MBUS_VSYNC_ACTIVE_HIGH | +V4L2_MBUS_VSYNC_ACTIVE_LOW | +V4L2_MBUS_FIELD_EVEN_HIGH | +V4L2_MBUS_FIELD_EVEN_LOW )) + vep->bus_type =V4L2_MBUS_PARALLEL ; +else + vep->bus_type =V4L2_MBUS_BT656 ; + } }static void v4l2_fwnode_endpoint_parse_csi1_bus (struct fwnode_handle *fwnode,struct v4l2_fwnode_endpoint *vep, -u32 bus_type) +enum v4l2_fwnode_bus_type bus_type) {struct v4l2_fwnode_bus_mipi_csi1 *bus = &vep->bus.mipi_csi1;u32 v;
@@ -247,25 +257,20 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode, rval =v4l2_fwnode_endpoint_parse_csi2_bus (fwnode, vep);if (rval)return rval; -/* -* Parse the parallel video bus properties only if none -* of the MIPI CSI-2 specific properties were found. -*/ -if (vep->bus.mipi_csi2.flags ==0 ) + +if (vep->bus_type ==V4L2_MBUS_UNKNOWN )v4l2_fwnode_endpoint_parse_parallel_bus (fwnode, vep); -break ; +return vep->bus_type ==V4L2_MBUS_UNKNOWN ? -EINVAL :0 ;case V4L2_FWNODE_BUS_TYPE_CCP2 :case V4L2_FWNODE_BUS_TYPE_CSI1 :v4l2_fwnode_endpoint_parse_csi1_bus (fwnode, vep, bus_type); -break ; +return 0 ;default :pr_warn ("unsupported bus type %u\n" , bus_type);return -EINVAL ; } - -return 0 ; } int v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
include/media/v4l2-mediabus.h +2 -0
@@ -70,6 +70,7 @@/** * enum v4l2_mbus_type - media bus type +* @V4L2_MBUS_UNKNOWN: unknown bus type, no V4L2 mediabus configuration * @V4L2_MBUS_PARALLEL: parallel interface with hsync and vsync * @V4L2_MBUS_BT656: parallel interface with embedded synchronisation, can * also be used for BT.1120
@@ -78,6 +79,7 @@* @V4L2_MBUS_CSI2: MIPI CSI-2 serial interface */ enum v4l2_mbus_type { +V4L2_MBUS_UNKNOWN ,V4L2_MBUS_PARALLEL ,V4L2_MBUS_BT656 ,V4L2_MBUS_CSI1 ,
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 4/21 v4l: fwnode: The CSI-2 clock is continuous if it's not non-continuous
In reply to Sakari AilusThe continuous clock flag was only set if there was a clock or data lanes. This isn't needed as such a configuration is invalid to begin with. Always set the continuous clock flag if the non-continuous property is not found.
Still don't consider the continuous clock flag as an indication that this is CSI-2 as it's set in the absence of the property.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/v4l2-core/v4l2-fwnode.c +3 -2
@@ -107,11 +107,12 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,if (fwnode_property_present (fwnode,"clock-noncontinuous" )) { flags |=V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK ;pr_debug ("non-continuous clock\n" ); - }else if (have_clk_lane || bus->num_data_lanes >0 ) { + }else { flags |=V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ; } -if (lanes_used || have_clk_lane || flags) { +if (lanes_used || have_clk_lane || + (flags & ~V4L2_MBUS_CSI2_CONTINUOUS_CLOCK )) { bus->flags = flags; vep->bus_type =V4L2_MBUS_CSI2 ; }
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 5/21 dt-bindings: media: Specify bus type for MIPI D-PHY, others, explicitly
In reply to Sakari AilusAllow specifying the bus type explicitly for MIPI D-PHY, parallel and Bt.656 busses. This is useful for devices that can make use of different bus types. There are CSI-2 transmitters and receivers but the PHY selection needs to be made between C-PHY and D-PHY; many devices also support parallel and Bt.656 interfaces but the means to pass that information to software wasn't there.
Autodetection (value 0) is removed as an option as the property could be simply omitted in that case.
--- Documentation/devicetree/bindings/media/video-interfaces.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/media/video-interfaces.txt +3 -1
@@ -100,10 +100,12 @@ Optional endpoint properties slave device (data source) by the master device (data sink). In the master mode the data source device is also the source of the synchronization signals. - bus-type: data bus type. Possible values are: - 0 - autodetect based on other properties (MIPI CSI-2 D-PHY, parallel or Bt656) 1 - MIPI CSI-2 C-PHY 2 - MIPI CSI1 3 - CCP2 + 4 - MIPI CSI-2 D-PHY + 5 - Parallel + 6 - Bt.656 - bus-width: number of data lines actively used, valid for the parallel busses. - data-shift: on the parallel data busses, if bus-width is used to specify the number of data lines, data-shift can be used to specify which data lines are
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 6/21 v4l: fwnode: Add definitions for CSI-2 D-PHY, parallel and Bt.656 busses
In reply to Sakari AilusAdd definitions corresponding to DT bindings to the CSI-2 D-PHY, parallel and Bt.656 busses.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/v4l2-core/v4l2-fwnode.c +3 -0
@@ -36,6 +36,9 @@ enum v4l2_fwnode_bus_type {V4L2_FWNODE_BUS_TYPE_CSI2_CPHY ,V4L2_FWNODE_BUS_TYPE_CSI1 ,V4L2_FWNODE_BUS_TYPE_CCP2 , +V4L2_FWNODE_BUS_TYPE_CSI2_DPHY , +V4L2_FWNODE_BUS_TYPE_PARALLEL , +V4L2_FWNODE_BUS_TYPE_BT656 , NR_OF_V4L2_FWNODE_BUS_TYPE, };
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 7/21 v4l: mediabus: Recognise CSI-2 D-PHY and C-PHY
In reply to Sakari AilusThe CSI-2 bus may use either D-PHY or C-PHY. Make this visible in media bus enum.
--- drivers/gpu/ipu-v3/ipu-csi.c | 2 +- drivers/media/i2c/adv7180.c | 2 +- drivers/media/i2c/ov5640.c | 4 ++-- drivers/media/i2c/ov5645.c | 2 +- drivers/media/i2c/ov7251.c | 4 ++-- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 2 +- drivers/media/i2c/s5k5baf.c | 4 ++-- drivers/media/i2c/s5k6aa.c | 2 +- drivers/media/i2c/smiapp/smiapp-core.c | 2 +- drivers/media/i2c/soc_camera/ov5642.c | 2 +- drivers/media/i2c/tc358743.c | 4 ++-- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +- drivers/media/platform/cadence/cdns-csi2rx.c | 2 +- drivers/media/platform/cadence/cdns-csi2tx.c | 2 +- drivers/media/platform/marvell-ccic/mcam-core.c | 4 ++-- drivers/media/platform/marvell-ccic/mmp-driver.c | 2 +- drivers/media/platform/omap3isp/isp.c | 2 +- drivers/media/platform/pxa_camera.c | 2 +- drivers/media/platform/rcar-vin/rcar-csi2.c | 2 +- drivers/media/platform/soc_camera/soc_mediabus.c | 2 +- drivers/media/platform/stm32/stm32-dcmi.c | 2 +- drivers/media/platform/ti-vpe/cal.c | 2 +- drivers/media/v4l2-core/v4l2-fwnode.c | 2 +- drivers/staging/media/imx/imx-media-csi.c | 2 +- drivers/staging/media/imx/imx6-mipi-csi2.c | 2 +- drivers/staging/media/imx074/imx074.c | 2 +- include/media/v4l2-mediabus.h | 6 ++++-- 27 files changed, 35 insertions(+), 33 deletions(-)
drivers/gpu/ipu-v3/ipu-csi.c +1 -1
@@ -344,7 +344,7 @@ static void fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,else csicfg->clk_mode =IPU_CSI_CLK_MODE_CCIR656_PROGRESSIVE ;break ; -case V4L2_MBUS_CSI2 : +case V4L2_MBUS_CSI2_DPHY :/* * MIPI CSI-2 requires non gated clock mode, all other * parameters are not applicable for MIPI CSI-2 bus.
drivers/media/i2c/adv7180.c +1 -1
@@ -742,7 +742,7 @@ static int adv7180_g_mbus_config(struct v4l2_subdev *sd,struct adv7180_state *state =to_state (sd);if (state->chip_info->flags &ADV7180_FLAG_MIPI_CSI2 ) { - cfg->type =V4L2_MBUS_CSI2 ; + cfg->type =V4L2_MBUS_CSI2_DPHY ; cfg->flags =V4L2_MBUS_CSI2_1_LANE |V4L2_MBUS_CSI2_CHANNEL_0 |V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ;
drivers/media/i2c/ov5640.c +2 -2
@@ -1786,7 +1786,7 @@ static int ov5640_set_power(struct ov5640_dev *sensor, bool on)if (ret) goto power_off; -if (sensor->ep.bus_type ==V4L2_MBUS_CSI2 ) { +if (sensor->ep.bus_type ==V4L2_MBUS_CSI2_DPHY ) {/* * start streaming briefly followed by stream off in * order to coax the clock lane into LP-11 state.
@@ -2550,7 +2550,7 @@ static int ov5640_s_stream(struct v4l2_subdev *sd, int enable) goto out; } -if (sensor->ep.bus_type ==V4L2_MBUS_CSI2 ) +if (sensor->ep.bus_type ==V4L2_MBUS_CSI2_DPHY ) ret =ov5640_set_stream_mipi (sensor, enable);else ret =ov5640_set_stream_dvp (sensor, enable);
drivers/media/i2c/ov5645.c +1 -1
@@ -1127,7 +1127,7 @@ static int ov5645_probe(struct i2c_client *client,return ret; } -if (ov5645->ep.bus_type !=V4L2_MBUS_CSI2 ) { +if (ov5645->ep.bus_type !=V4L2_MBUS_CSI2_DPHY ) {dev_err (dev,"invalid bus type, must be CSI2\n" );return -EINVAL ; }
drivers/media/i2c/ov7251.c +2 -2
@@ -1279,9 +1279,9 @@ static int ov7251_probe(struct i2c_client *client)return ret; } -if (ov7251->ep.bus_type !=V4L2_MBUS_CSI2 ) { +if (ov7251->ep.bus_type !=V4L2_MBUS_CSI2_DPHY ) {dev_err (dev,"invalid bus type (%u), must be CSI2 (%u)\n" , - ov7251->ep.bus_type,V4L2_MBUS_CSI2 ); + ov7251->ep.bus_type,V4L2_MBUS_CSI2_DPHY );return -EINVAL ; }
drivers/media/i2c/s5c73m3/s5c73m3-core.c +1 -1
@@ -1644,7 +1644,7 @@ static int s5c73m3_get_platform_data(struct s5c73m3 *state)if (ret)return ret; -if (ep.bus_type !=V4L2_MBUS_CSI2 ) { +if (ep.bus_type !=V4L2_MBUS_CSI2_DPHY ) {dev_err (dev,"unsupported bus type\n" );return -EINVAL ; }
drivers/media/i2c/s5k5baf.c +2 -2
@@ -766,7 +766,7 @@ static int s5k5baf_hw_set_video_bus(struct s5k5baf *state) {u16 en_pkts; -if (state->bus_type ==V4L2_MBUS_CSI2 ) +if (state->bus_type ==V4L2_MBUS_CSI2_DPHY ) en_pkts =EN_PACKETS_CSI2 ;else en_pkts =0 ;
@@ -1875,7 +1875,7 @@ static int s5k5baf_parse_device_node(struct s5k5baf *state, struct device *dev) state->bus_type = ep.bus_type;switch (state->bus_type) { -case V4L2_MBUS_CSI2 : +case V4L2_MBUS_CSI2_DPHY : state->nlanes = ep.bus.mipi_csi2.num_data_lanes;break ;case V4L2_MBUS_PARALLEL :
drivers/media/i2c/s5k6aa.c +1 -1
@@ -688,7 +688,7 @@ static int s5k6aa_configure_video_bus(struct s5k6aa *s5k6aa,* but there is nothing indicating how to switch between both * in the datasheet. For now default BT.601 interface is assumed. */ -if (bus_type ==V4L2_MBUS_CSI2 ) +if (bus_type ==V4L2_MBUS_CSI2_DPHY ) cfg = nlanes;else if (bus_type !=V4L2_MBUS_PARALLEL )return -EINVAL ;
drivers/media/i2c/smiapp/smiapp-core.c +1 -1
@@ -2784,7 +2784,7 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev) goto out_err;switch (bus_cfg->bus_type) { -case V4L2_MBUS_CSI2 : +case V4L2_MBUS_CSI2_DPHY : hwcfg->csi_signalling_mode =SMIAPP_CSI_SIGNALLING_MODE_CSI2 ; hwcfg->lanes = bus_cfg->bus.mipi_csi2.num_data_lanes;break ;
drivers/media/i2c/soc_camera/ov5642.c +1 -1
@@ -913,7 +913,7 @@ static int ov5642_get_selection(struct v4l2_subdev *sd,static int ov5642_g_mbus_config (struct v4l2_subdev *sd,struct v4l2_mbus_config *cfg) { - cfg->type =V4L2_MBUS_CSI2 ; + cfg->type =V4L2_MBUS_CSI2_DPHY ; cfg->flags =V4L2_MBUS_CSI2_2_LANE |V4L2_MBUS_CSI2_CHANNEL_0 |V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ;
drivers/media/i2c/tc358743.c +2 -2
@@ -1607,7 +1607,7 @@ static int tc358743_g_mbus_config(struct v4l2_subdev *sd, {struct tc358743_state *state =to_state (sd); - cfg->type =V4L2_MBUS_CSI2 ; + cfg->type =V4L2_MBUS_CSI2_DPHY ;/* Support for non-continuous CSI-2 clock is missing in the driver */ cfg->flags =V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ;
@@ -1922,7 +1922,7 @@ static int tc358743_probe_of(struct tc358743_state *state) goto put_node; } -if (endpoint->bus_type !=V4L2_MBUS_CSI2 || +if (endpoint->bus_type !=V4L2_MBUS_CSI2_DPHY || endpoint->bus.mipi_csi2.num_data_lanes ==0 || endpoint->nr_of_link_frequencies ==0 ) {dev_err (dev,"missing CSI-2 properties in endpoint\n" );
drivers/media/pci/intel/ipu3/ipu3-cio2.c +1 -1
@@ -1484,7 +1484,7 @@ static int cio2_fwnode_parse(struct device *dev,struct sensor_async_subdev *s_asd = container_of(asd, struct sensor_async_subdev, asd); -if (vep->bus_type !=V4L2_MBUS_CSI2 ) { +if (vep->bus_type !=V4L2_MBUS_CSI2_DPHY ) {dev_err (dev,"Only CSI2 bus type is currently supported\n" );return -EINVAL ; }
drivers/media/platform/cadence/cdns-csi2rx.c +1 -1
@@ -378,7 +378,7 @@ static int csi2rx_parse_dt(struct csi2rx_priv *csi2rx)return ret; } -if (v4l2_ep.bus_type !=V4L2_MBUS_CSI2 ) { +if (v4l2_ep.bus_type !=V4L2_MBUS_CSI2_DPHY ) {dev_err (csi2rx->dev,"Unsupported media bus type: 0x%x\n" , v4l2_ep.bus_type);of_node_put (ep);
drivers/media/platform/cadence/cdns-csi2tx.c +1 -1
@@ -446,7 +446,7 @@ static int csi2tx_check_lanes(struct csi2tx_priv *csi2tx) goto out; } -if (v4l2_ep.bus_type !=V4L2_MBUS_CSI2 ) { +if (v4l2_ep.bus_type !=V4L2_MBUS_CSI2_DPHY ) {dev_err (csi2tx->dev,"Unsupported media bus type: 0x%x\n" , v4l2_ep.bus_type); ret = -EINVAL ;
drivers/media/platform/marvell-ccic/mcam-core.c +2 -2
@@ -794,7 +794,7 @@ static void mcam_ctlr_image(struct mcam_camera *cam)/* * This field controls the generation of EOF(DVP only) */ -if (cam->bus_type !=V4L2_MBUS_CSI2 ) +if (cam->bus_type !=V4L2_MBUS_CSI2_DPHY )mcam_reg_set_bit (cam,REG_CTRL0 ,C0_EOF_VSYNC |C0_VEDGE_CTRL ); }
@@ -1023,7 +1023,7 @@ static int mcam_read_setup(struct mcam_camera *cam) cam->calc_dphy (cam);cam_dbg (cam,"camera: DPHY sets: dphy3=0x%x, dphy5=0x%x, dphy6=0x%x\n" , cam->dphy[0 ], cam->dphy[1 ], cam->dphy[2 ]); -if (cam->bus_type ==V4L2_MBUS_CSI2 ) +if (cam->bus_type ==V4L2_MBUS_CSI2_DPHY )mcam_enable_mipi (cam);else mcam_disable_mipi (cam);
drivers/media/platform/marvell-ccic/mmp-driver.c +1 -1
@@ -362,7 +362,7 @@ static int mmpcam_probe(struct platform_device *pdev) mcam->mclk_div = pdata->mclk_div; mcam->bus_type = pdata->bus_type; mcam->dphy = pdata->dphy; -if (mcam->bus_type ==V4L2_MBUS_CSI2 ) { +if (mcam->bus_type ==V4L2_MBUS_CSI2_DPHY ) { cam->mipi_clk =devm_clk_get (mcam->dev,"mipi" );if ((IS_ERR (cam->mipi_clk) && mcam->dphy[2 ] ==0 ))return PTR_ERR (cam->mipi_clk);
drivers/media/platform/omap3isp/isp.c +1 -1
@@ -2054,7 +2054,7 @@ static int isp_fwnode_parse(struct device *dev,dev_dbg (dev,"CSI-1/CCP-2 configuration\n" ); csi1 = true;break ; -case V4L2_MBUS_CSI2 : +case V4L2_MBUS_CSI2_DPHY :dev_dbg (dev,"CSI-2 configuration\n" ); csi1 = false;break ;
drivers/media/platform/pxa_camera.c +1 -1
@@ -633,7 +633,7 @@ static unsigned int pxa_mbus_config_compatible(const struct v4l2_mbus_config *cf mode = common_flags & (V4L2_MBUS_MASTER |V4L2_MBUS_SLAVE );return (!hsync || !vsync || !pclk || !data || !mode) ?0 : common_flags; -case V4L2_MBUS_CSI2 : +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 );
drivers/media/platform/rcar-vin/rcar-csi2.c +1 -1
@@ -706,7 +706,7 @@ static int rcsi2_parse_v4l2(struct rcar_csi2 *priv,if (vep->base.port || vep->base.id)return -ENOTCONN ; -if (vep->bus_type !=V4L2_MBUS_CSI2 ) { +if (vep->bus_type !=V4L2_MBUS_CSI2_DPHY ) {dev_err (priv->dev,"Unsupported bus: %u\n" , vep->bus_type);return -EINVAL ; }
drivers/media/platform/soc_camera/soc_mediabus.c +1 -1
@@ -503,7 +503,7 @@ unsigned int soc_mbus_config_compatible(const struct v4l2_mbus_config *cfg, mode = common_flags & (V4L2_MBUS_MASTER |V4L2_MBUS_SLAVE );return (!hsync || !vsync || !pclk || !data || !mode) ?0 : common_flags; -case V4L2_MBUS_CSI2 : +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 );
drivers/media/platform/stm32/stm32-dcmi.c +1 -1
@@ -1663,7 +1663,7 @@ static int dcmi_probe(struct platform_device *pdev)return -ENODEV ; } -if (ep.bus_type ==V4L2_MBUS_CSI2 ) { +if (ep.bus_type ==V4L2_MBUS_CSI2_DPHY ) {dev_err (&pdev->dev,"CSI bus not supported\n" );return -ENODEV ; }
drivers/media/platform/ti-vpe/cal.c +1 -1
@@ -1711,7 +1711,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst) }v4l2_fwnode_endpoint_parse (of_fwnode_handle (remote_ep), endpoint); -if (endpoint->bus_type !=V4L2_MBUS_CSI2 ) { +if (endpoint->bus_type !=V4L2_MBUS_CSI2_DPHY ) {ctx_err (ctx,"Port:%d sub-device %s is not a CSI2 device\n" , inst, sensor_node->name); goto cleanup_exit;
drivers/media/v4l2-core/v4l2-fwnode.c +1 -1
@@ -117,7 +117,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,if (lanes_used || have_clk_lane || (flags & ~V4L2_MBUS_CSI2_CONTINUOUS_CLOCK )) { bus->flags = flags; - vep->bus_type =V4L2_MBUS_CSI2 ; + vep->bus_type =V4L2_MBUS_CSI2_DPHY ; }return 0 ;
drivers/staging/media/imx/imx-media-csi.c +1 -1
@@ -124,7 +124,7 @@ static inline struct csi_priv *sd_to_dev(struct v4l2_subdev *sdev)static inline bool is_parallel_bus (struct v4l2_fwnode_endpoint *ep) { -return ep->bus_type !=V4L2_MBUS_CSI2 ; +return ep->bus_type !=V4L2_MBUS_CSI2_DPHY ; }static inline bool is_parallel_16bit_bus (struct v4l2_fwnode_endpoint *ep)
drivers/staging/media/imx/imx6-mipi-csi2.c +1 -1
@@ -563,7 +563,7 @@ static int csi2_parse_endpoint(struct device *dev,return -EINVAL ; } -if (vep->bus_type !=V4L2_MBUS_CSI2 ) { +if (vep->bus_type !=V4L2_MBUS_CSI2_DPHY ) {v4l2_err (&csi2->sd,"invalid bus type, must be MIPI CSI2\n" );return -EINVAL ; }
drivers/staging/media/imx074/imx074.c +1 -1
@@ -263,7 +263,7 @@ static int imx074_s_power(struct v4l2_subdev *sd, int on)static int imx074_g_mbus_config (struct v4l2_subdev *sd,struct v4l2_mbus_config *cfg) { - cfg->type =V4L2_MBUS_CSI2 ; + cfg->type =V4L2_MBUS_CSI2_DPHY ; cfg->flags =V4L2_MBUS_CSI2_2_LANE |V4L2_MBUS_CSI2_CHANNEL_0 |V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ;
include/media/v4l2-mediabus.h +4 -2
@@ -76,7 +76,8 @@* also be used for BT.1120 * @V4L2_MBUS_CSI1: MIPI CSI-1 serial interface * @V4L2_MBUS_CCP2: CCP2 (Compact Camera Port 2) -* @V4L2_MBUS_CSI2: MIPI CSI-2 serial interface +* @V4L2_MBUS_CSI2_DPHY: MIPI CSI-2 serial interface, with D-PHY +* @V4L2_MBUS_CSI2_CPHY: MIPI CSI-2 serial interface, with C-PHY */ enum v4l2_mbus_type {V4L2_MBUS_UNKNOWN ,
@@ -84,7 +85,8 @@ enum v4l2_mbus_type {V4L2_MBUS_BT656 ,V4L2_MBUS_CSI1 ,V4L2_MBUS_CCP2 , - V4L2_MBUS_CSI2, +V4L2_MBUS_CSI2_DPHY , + V4L2_MBUS_CSI2_CPHY, };/**
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 8/21 v4l: fwnode: Make use of newly specified bus types
In reply to Sakari AilusMake use of bus type specified for an endpoint.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 48 ++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 12 deletions(-)
drivers/media/v4l2-core/v4l2-fwnode.c +36 -12
@@ -123,8 +123,16 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,return 0 ; } +#define PARALLEL_MBUS_FLAGS (V4L2_MBUS_HSYNC_ACTIVE_HIGH | \ + V4L2_MBUS_HSYNC_ACTIVE_LOW | \ + V4L2_MBUS_VSYNC_ACTIVE_HIGH | \ + V4L2_MBUS_VSYNC_ACTIVE_LOW | \ + V4L2_MBUS_FIELD_EVEN_HIGH | \ + V4L2_MBUS_FIELD_EVEN_LOW) +static void v4l2_fwnode_endpoint_parse_parallel_bus ( -struct fwnode_handle *fwnode,struct v4l2_fwnode_endpoint *vep) +struct fwnode_handle *fwnode,struct v4l2_fwnode_endpoint *vep, +enum v4l2_fwnode_bus_type bus_type) {struct v4l2_fwnode_bus_parallel *bus = &vep->bus.parallel;unsigned int flags =0 ;
@@ -192,17 +200,24 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(pr_debug ("data-enable-active %s\n" , v ?"high" :"low" ); } -if (flags || is_parallel) { +switch (bus_type) { +default : bus->flags = flags; -if (flags & (V4L2_MBUS_HSYNC_ACTIVE_HIGH | -V4L2_MBUS_HSYNC_ACTIVE_LOW | -V4L2_MBUS_VSYNC_ACTIVE_HIGH | -V4L2_MBUS_VSYNC_ACTIVE_LOW | -V4L2_MBUS_FIELD_EVEN_HIGH | -V4L2_MBUS_FIELD_EVEN_LOW )) - vep->bus_type =V4L2_MBUS_PARALLEL ; -else - vep->bus_type =V4L2_MBUS_BT656 ; +if (flags || is_parallel) { +if (flags &PARALLEL_MBUS_FLAGS ) + vep->bus_type =V4L2_MBUS_PARALLEL ; +else + vep->bus_type =V4L2_MBUS_BT656 ; + } +break ; +case V4L2_FWNODE_BUS_TYPE_PARALLEL : + vep->bus_type =V4L2_MBUS_PARALLEL ; + bus->flags = flags; +break ; +case V4L2_FWNODE_BUS_TYPE_BT656 : + vep->bus_type =V4L2_MBUS_BT656 ; + bus->flags = flags & ~PARALLEL_MBUS_FLAGS ; +break ; } }
@@ -263,7 +278,8 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,return rval;if (vep->bus_type ==V4L2_MBUS_UNKNOWN ) -v4l2_fwnode_endpoint_parse_parallel_bus (fwnode, vep); +v4l2_fwnode_endpoint_parse_parallel_bus ( + fwnode, vep,V4L2_MBUS_UNKNOWN );return vep->bus_type ==V4L2_MBUS_UNKNOWN ? -EINVAL :0 ;case V4L2_FWNODE_BUS_TYPE_CCP2 :
@@ -271,6 +287,14 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,v4l2_fwnode_endpoint_parse_csi1_bus (fwnode, vep, bus_type);return 0 ; +case V4L2_FWNODE_BUS_TYPE_CSI2_DPHY : + vep->bus_type =V4L2_MBUS_CSI2_DPHY ; +return v4l2_fwnode_endpoint_parse_csi2_bus (fwnode, vep); +case V4L2_FWNODE_BUS_TYPE_PARALLEL : +case V4L2_FWNODE_BUS_TYPE_BT656 : +v4l2_fwnode_endpoint_parse_parallel_bus (fwnode, vep, bus_type); + +return 0 ;default :pr_warn ("unsupported bus type %u\n" , bus_type);return -EINVAL ;
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 9/21 v4l: fwnode: Read lane inversion information despite lane numbering
In reply to Sakari AilusRead the lane inversion independently of whether the "data-lanes" property exists. This makes sense since the caller may pass the number of lanes as the default configuration while the lane inversion configuration may still be available in firmware.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 65 +++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 30 deletions(-)
drivers/media/v4l2-core/v4l2-fwnode.c +35 -30
@@ -43,26 +43,31 @@ enum v4l2_fwnode_bus_type { };static int v4l2_fwnode_endpoint_parse_csi2_bus (struct fwnode_handle *fwnode, -struct v4l2_fwnode_endpoint *vep) +struct v4l2_fwnode_endpoint *vep, +enum v4l2_fwnode_bus_type bus_type) {struct v4l2_fwnode_bus_mipi_csi2 *bus = &vep->bus.mipi_csi2;bool have_clk_lane = false;unsigned int flags =0 , lanes_used =0 ; +u32 array[1 +V4L2_FWNODE_CSI2_MAX_DATA_LANES ]; +unsigned int num_data_lanes =0 ;unsigned int i;u32 v;int rval; +if (bus_type ==V4L2_FWNODE_BUS_TYPE_CSI2_DPHY ) + num_data_lanes =min_t (u32, bus->num_data_lanes, +V4L2_FWNODE_CSI2_MAX_DATA_LANES ); + rval =fwnode_property_read_u32_array (fwnode,"data-lanes" ,NULL ,0 );if (rval >0 ) { -u32 array[1 +V4L2_FWNODE_CSI2_MAX_DATA_LANES ]; - - bus->num_data_lanes = + num_data_lanes =min_t (int,V4L2_FWNODE_CSI2_MAX_DATA_LANES , rval);fwnode_property_read_u32_array (fwnode,"data-lanes" , array, - bus->num_data_lanes); + num_data_lanes); -for (i =0 ; i < bus->num_data_lanes; i++) { +for (i =0 ; i < num_data_lanes; i++) {if (lanes_used &BIT (array[i]))pr_warn ("duplicated lane %u in data-lanes\n" , array[i]);
@@ -71,30 +76,27 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, bus->data_lanes[i] = array[i];pr_debug ("lane %u position %u\n" , i, array[i]); } + } - rval =fwnode_property_read_u32_array (fwnode, -"lane-polarities" ,NULL , -0 ); -if (rval >0 ) { -if (rval !=1 + bus->num_data_lanes/* clock+data */ ) { -pr_warn ("invalid number of lane-polarities entries (need %u, got %u)\n" , -1 + bus->num_data_lanes, rval); -return -EINVAL ; - } + rval =fwnode_property_read_u32_array (fwnode,"lane-polarities" ,NULL , +0 ); +if (rval >0 ) { +if (rval !=1 + num_data_lanes/* clock+data */ ) { +pr_warn ("invalid number of lane-polarities entries (need %u, got %u)\n" , +1 + num_data_lanes, rval); +return -EINVAL ; + } -fwnode_property_read_u32_array (fwnode, -"lane-polarities" , array, -1 + bus->num_data_lanes); +fwnode_property_read_u32_array (fwnode,"lane-polarities" , array, +1 + num_data_lanes); -for (i =0 ; i <1 + bus->num_data_lanes; i++) { - bus->lane_polarities[i] = array[i]; -pr_debug ("lane %u polarity %sinverted" , - i, array[i] ?"" :"not " ); - } - }else { -pr_debug ("no lane polarities defined, assuming not inverted\n" ); +for (i =0 ; i <1 + num_data_lanes; i++) { + bus->lane_polarities[i] = array[i]; +pr_debug ("lane %u polarity %sinverted" , + i, array[i] ?"" :"not " ); } - + }else { +pr_debug ("no lane polarities defined, assuming not inverted\n" ); }if (!fwnode_property_read_u32 (fwnode,"clock-lanes" , &v)) {
@@ -114,10 +116,11 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, flags |=V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ; } -if (lanes_used || have_clk_lane || - (flags & ~V4L2_MBUS_CSI2_CONTINUOUS_CLOCK )) { +if (bus_type ==V4L2_FWNODE_BUS_TYPE_CSI2_DPHY || lanes_used || + have_clk_lane || (flags & ~V4L2_MBUS_CSI2_CONTINUOUS_CLOCK )) { bus->flags = flags; vep->bus_type =V4L2_MBUS_CSI2_DPHY ; + bus->num_data_lanes = num_data_lanes; }return 0 ;
@@ -273,7 +276,8 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,switch (bus_type) {case V4L2_FWNODE_BUS_TYPE_GUESS : - rval =v4l2_fwnode_endpoint_parse_csi2_bus (fwnode, vep); + rval =v4l2_fwnode_endpoint_parse_csi2_bus (fwnode, vep, + bus_type);if (rval)return rval;
@@ -289,7 +293,8 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,return 0 ;case V4L2_FWNODE_BUS_TYPE_CSI2_DPHY : vep->bus_type =V4L2_MBUS_CSI2_DPHY ; -return v4l2_fwnode_endpoint_parse_csi2_bus (fwnode, vep); +return v4l2_fwnode_endpoint_parse_csi2_bus (fwnode, vep, + bus_type);case V4L2_FWNODE_BUS_TYPE_PARALLEL :case V4L2_FWNODE_BUS_TYPE_BT656 :v4l2_fwnode_endpoint_parse_parallel_bus (fwnode, vep, bus_type);
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 10/21 v4l: fwnode: Only assign configuration if there is no error
In reply to Sakari AilusOnly assign endpoint configuration if the endpoint is parsed successfully.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
drivers/media/v4l2-core/v4l2-fwnode.c +18 -12
@@ -47,7 +47,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, enum v4l2_fwnode_bus_type bus_type) {struct v4l2_fwnode_bus_mipi_csi2 *bus = &vep->bus.mipi_csi2; -bool have_clk_lane = false; +bool have_clk_lane = false, have_lane_polarities = false;unsigned int flags =0 , lanes_used =0 ;u32 array[1 +V4L2_FWNODE_CSI2_MAX_DATA_LANES ];unsigned int num_data_lanes =0 ;
@@ -73,7 +73,6 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, array[i]); lanes_used |=BIT (array[i]); - bus->data_lanes[i] = array[i];pr_debug ("lane %u position %u\n" , i, array[i]); } }
@@ -87,16 +86,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,return -EINVAL ; } -fwnode_property_read_u32_array (fwnode,"lane-polarities" , array, -1 + num_data_lanes); - -for (i =0 ; i <1 + num_data_lanes; i++) { - bus->lane_polarities[i] = array[i]; -pr_debug ("lane %u polarity %sinverted" , - i, array[i] ?"" :"not " ); - } - }else { -pr_debug ("no lane polarities defined, assuming not inverted\n" ); + have_lane_polarities = true; }if (!fwnode_property_read_u32 (fwnode,"clock-lanes" , &v)) {
@@ -121,6 +111,22 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, bus->flags = flags; vep->bus_type =V4L2_MBUS_CSI2_DPHY ; bus->num_data_lanes = num_data_lanes; +for (i =0 ; i < num_data_lanes; i++) + bus->data_lanes[i] = array[i]; + +if (have_lane_polarities) { +fwnode_property_read_u32_array (fwnode, +"lane-polarities" , array, +1 + num_data_lanes); + +for (i =0 ; i <1 + num_data_lanes; i++) { + bus->lane_polarities[i] = array[i]; +pr_debug ("lane %u polarity %sinverted" , + i, array[i] ?"" :"not " ); + } + }else { +pr_debug ("no lane polarities defined, assuming not inverted\n" ); + } }return 0 ;
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 11/21 v4l: fwnode: Support driver-defined lane mapping defaults
In reply to Sakari AilusMake use of the default CSI-2 lane mapping from caller-passed configuration.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/media/v4l2-core/v4l2-fwnode.c +12 -8
@@ -55,10 +55,14 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,u32 v;int rval; -if (bus_type ==V4L2_FWNODE_BUS_TYPE_CSI2_DPHY ) +if (bus_type ==V4L2_FWNODE_BUS_TYPE_CSI2_DPHY ) { num_data_lanes =min_t (u32, bus->num_data_lanes,V4L2_FWNODE_CSI2_MAX_DATA_LANES ); +for (i =0 ; i < num_data_lanes; i++) + array[i] = bus->data_lanes[i]; + } + rval =fwnode_property_read_u32_array (fwnode,"data-lanes" ,NULL ,0 );if (rval >0 ) { num_data_lanes =
@@ -66,15 +70,15 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,fwnode_property_read_u32_array (fwnode,"data-lanes" , array, num_data_lanes); + } -for (i =0 ; i < num_data_lanes; i++) { -if (lanes_used &BIT (array[i])) -pr_warn ("duplicated lane %u in data-lanes\n" , - array[i]); - lanes_used |=BIT (array[i]); +for (i =0 ; i < num_data_lanes; i++) { +if (lanes_used &BIT (array[i])) +pr_warn ("duplicated lane %u in data-lanes\n" , + array[i]); + lanes_used |=BIT (array[i]); -pr_debug ("lane %u position %u\n" , i, array[i]); - } +pr_debug ("lane %u position %u\n" , i, array[i]); } rval = fwnode_property_read_u32_array(fwnode, "lane-polarities", NULL,
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 12/21 v4l: fwnode: Support default CSI-2 lane mapping for drivers
In reply to Sakari AilusMost hardware doesn't support re-mapping of the CSI-2 lanes. Especially sensor drivers have a default number of lanes. Instead of requiring the caller (the driver) to provide such a unit mapping, provide one if no mapping is configured.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 60 +++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 14 deletions(-)
drivers/media/v4l2-core/v4l2-fwnode.c +46 -14
@@ -47,20 +47,35 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, enum v4l2_fwnode_bus_type bus_type) {struct v4l2_fwnode_bus_mipi_csi2 *bus = &vep->bus.mipi_csi2; -bool have_clk_lane = false, have_lane_polarities = false; +bool have_clk_lane = false, have_data_lanes = false, + have_lane_polarities = false;unsigned int flags =0 , lanes_used =0 ;u32 array[1 +V4L2_FWNODE_CSI2_MAX_DATA_LANES ]; +u32 clock_lane =0 ;unsigned int num_data_lanes =0 ; +bool use_default_lane_mapping = false;unsigned int i;u32 v;int rval;if (bus_type ==V4L2_FWNODE_BUS_TYPE_CSI2_DPHY ) { + use_default_lane_mapping = true; + num_data_lanes =min_t (u32, bus->num_data_lanes,V4L2_FWNODE_CSI2_MAX_DATA_LANES ); -for (i =0 ; i < num_data_lanes; i++) + clock_lane = bus->clock_lane; +if (clock_lane) + use_default_lane_mapping = false; + +for (i =0 ; i < num_data_lanes; i++) { array[i] = bus->data_lanes[i]; +if (array[i]) + use_default_lane_mapping = false; + } + +if (use_default_lane_mapping) +pr_debug ("using default lane mapping\n" ); } rval =fwnode_property_read_u32_array (fwnode,"data-lanes" ,NULL ,0 );
@@ -70,15 +85,21 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,fwnode_property_read_u32_array (fwnode,"data-lanes" , array, num_data_lanes); + + have_data_lanes = true; }for (i =0 ; i < num_data_lanes; i++) { -if (lanes_used &BIT (array[i])) -pr_warn ("duplicated lane %u in data-lanes\n" , - array[i]); +if (lanes_used &BIT (array[i])) { +if (have_data_lanes || !use_default_lane_mapping) +pr_warn ("duplicated lane %u in data-lanes, using defaults\n" , + array[i]); + use_default_lane_mapping = true; + } lanes_used |=BIT (array[i]); -pr_debug ("lane %u position %u\n" , i, array[i]); +if (have_data_lanes) +pr_debug ("lane %u position %u\n" , i, array[i]); } rval = fwnode_property_read_u32_array(fwnode, "lane-polarities", NULL,
@@ -94,13 +115,16 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, }if (!fwnode_property_read_u32 (fwnode,"clock-lanes" , &v)) { -if (lanes_used &BIT (v)) -pr_warn ("duplicated lane %u in clock-lanes\n" , v); - lanes_used |=BIT (v); - - bus->clock_lane = v; - have_clk_lane = true; + clock_lane = v;pr_debug ("clock lane position %u\n" , v); + have_clk_lane = true; + } + +if (lanes_used &BIT (clock_lane)) { +if (have_clk_lane || !use_default_lane_mapping) +pr_warn ("duplicated lane %u in clock-lanes, using defaults\n" , + v); + use_default_lane_mapping = true; }if (fwnode_property_present (fwnode,"clock-noncontinuous" )) {
@@ -115,8 +139,16 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, bus->flags = flags; vep->bus_type =V4L2_MBUS_CSI2_DPHY ; bus->num_data_lanes = num_data_lanes; -for (i =0 ; i < num_data_lanes; i++) - bus->data_lanes[i] = array[i]; + +if (use_default_lane_mapping) { + bus->clock_lane =0 ; +for (i =0 ; i < num_data_lanes; i++) + bus->data_lanes[i] =1 + i; + }else { + bus->clock_lane = clock_lane; +for (i =0 ; i < num_data_lanes; i++) + bus->data_lanes[i] = array[i]; + }if (have_lane_polarities) { fwnode_property_read_u32_array(fwnode,
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 14/21 v4l: fwnode: Use default parallel flags
In reply to Sakari AilusThe caller may provide default flags for the endpoint. Change the configuration based on what is available through the fwnode property API.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/media/v4l2-core/v4l2-fwnode.c +19 -0
@@ -184,31 +184,44 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(bool is_parallel = false;u32 v; +if (bus_type ==V4L2_MBUS_PARALLEL || bus_type ==V4L2_MBUS_BT656 ) + flags = bus->flags; +if (!fwnode_property_read_u32 (fwnode,"hsync-active" , &v)) { + flags &= ~(V4L2_MBUS_HSYNC_ACTIVE_HIGH | +V4L2_MBUS_HSYNC_ACTIVE_LOW ); flags |= v ?V4L2_MBUS_HSYNC_ACTIVE_HIGH :V4L2_MBUS_HSYNC_ACTIVE_LOW ;pr_debug ("hsync-active %s\n" , v ?"high" :"low" ); }if (!fwnode_property_read_u32 (fwnode,"vsync-active" , &v)) { + flags &= ~(V4L2_MBUS_VSYNC_ACTIVE_HIGH | +V4L2_MBUS_VSYNC_ACTIVE_LOW ); flags |= v ?V4L2_MBUS_VSYNC_ACTIVE_HIGH :V4L2_MBUS_VSYNC_ACTIVE_LOW ;pr_debug ("vsync-active %s\n" , v ?"high" :"low" ); }if (!fwnode_property_read_u32 (fwnode,"field-even-active" , &v)) { + flags &= ~(V4L2_MBUS_FIELD_EVEN_HIGH | +V4L2_MBUS_FIELD_EVEN_LOW ); flags |= v ?V4L2_MBUS_FIELD_EVEN_HIGH :V4L2_MBUS_FIELD_EVEN_LOW ;pr_debug ("field-even-active %s\n" , v ?"high" :"low" ); }if (!fwnode_property_read_u32 (fwnode,"pclk-sample" , &v)) { + flags &= ~(V4L2_MBUS_PCLK_SAMPLE_RISING | +V4L2_MBUS_PCLK_SAMPLE_FALLING ); flags |= v ?V4L2_MBUS_PCLK_SAMPLE_RISING :V4L2_MBUS_PCLK_SAMPLE_FALLING ;pr_debug ("pclk-sample %s\n" , v ?"high" :"low" ); }if (!fwnode_property_read_u32 (fwnode,"data-active" , &v)) { + flags &= ~(V4L2_MBUS_PCLK_SAMPLE_RISING | +V4L2_MBUS_PCLK_SAMPLE_FALLING ); flags |= v ?V4L2_MBUS_DATA_ACTIVE_HIGH :V4L2_MBUS_DATA_ACTIVE_LOW ;pr_debug ("data-active %s\n" , v ?"high" :"low" );
@@ -216,8 +229,10 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(if (fwnode_property_present (fwnode,"slave-mode" )) {pr_debug ("slave mode\n" ); + flags &= ~V4L2_MBUS_MASTER ; flags |=V4L2_MBUS_SLAVE ; }else { + flags &= ~V4L2_MBUS_SLAVE ; flags |=V4L2_MBUS_MASTER ; }
@@ -234,12 +249,16 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus( }if (!fwnode_property_read_u32 (fwnode,"sync-on-green-active" , &v)) { + flags &= ~(V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH | +V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW ); flags |= v ?V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH :V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW ;pr_debug ("sync-on-green-active %s\n" , v ?"high" :"low" ); }if (!fwnode_property_read_u32 (fwnode,"data-enable-active" , &v)) { + flags &= ~(V4L2_MBUS_DATA_ENABLE_HIGH | +V4L2_MBUS_DATA_ENABLE_LOW ); flags |= v ?V4L2_MBUS_DATA_ENABLE_HIGH :V4L2_MBUS_DATA_ENABLE_LOW ;pr_debug ("data-enable-active %s\n" , v ?"high" :"low" );
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 15/21 v4l: fwnode: Allow setting default parameters
In reply to Sakari AilusInstead of allocating the V4L2 fwnode endpoint in v4l2_fwnode_endpoint_alloc_parse, let the caller to do this. This allows setting default parameters for the endpoint which is a very common need for drivers.
--- drivers/media/i2c/ov2659.c | 14 ++++---- drivers/media/i2c/smiapp/smiapp-core.c | 26 +++++++-------- drivers/media/i2c/tc358743.c | 26 ++++++++------- drivers/media/v4l2-core/v4l2-fwnode.c | 59 ++++++++++++++-------------------- include/media/v4l2-fwnode.h | 7 ++-- 5 files changed, 65 insertions(+), 67 deletions(-)
drivers/media/i2c/ov2659.c +8 -6
@@ -1347,8 +1347,9 @@ static struct ov2659_platform_data * ov2659_get_pdata(struct i2c_client *client) {struct ov2659_platform_data *pdata; -struct v4l2_fwnode_endpoint *bus_cfg; +struct v4l2_fwnode_endpoint bus_cfg = { .bus_type =0 };struct device_node *endpoint; +int ret;if (!IS_ENABLED (CONFIG_OF ) || !client->dev.of_node)return client->dev.platform_data;
@@ -1357,8 +1358,9 @@ ov2659_get_pdata(struct i2c_client *client)if (!endpoint)return NULL ; - bus_cfg =v4l2_fwnode_endpoint_alloc_parse (of_fwnode_handle (endpoint)); -if (IS_ERR (bus_cfg)) { + ret =v4l2_fwnode_endpoint_alloc_parse (of_fwnode_handle (endpoint), + &bus_cfg); +if (ret) { pdata =NULL ; goto done; }
@@ -1367,17 +1369,17 @@ ov2659_get_pdata(struct i2c_client *client)if (!pdata) goto done; -if (!bus_cfg->nr_of_link_frequencies) { +if (!bus_cfg.nr_of_link_frequencies) {dev_err (&client->dev,"link-frequencies property not found or too many\n" ); pdata =NULL ; goto done; } - pdata->link_frequency = bus_cfg->link_frequencies[0 ]; + pdata->link_frequency = bus_cfg.link_frequencies[0 ]; done: -v4l2_fwnode_endpoint_free (bus_cfg); +v4l2_fwnode_endpoint_free (&bus_cfg);of_node_put (endpoint);return pdata; }
drivers/media/i2c/smiapp/smiapp-core.c +13 -13
@@ -2761,7 +2761,7 @@ static int __maybe_unused smiapp_resume(struct device *dev)static struct smiapp_hwconfig *smiapp_get_hwconfig (struct device *dev) {struct smiapp_hwconfig *hwcfg; -struct v4l2_fwnode_endpoint *bus_cfg; +struct v4l2_fwnode_endpoint bus_cfg = { .bus_type =0 };struct fwnode_handle *ep;struct fwnode_handle *fwnode =dev_fwnode (dev);u32 rotation;
@@ -2775,27 +2775,27 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)if (!ep)return NULL ; - bus_cfg =v4l2_fwnode_endpoint_alloc_parse (ep); -if (IS_ERR (bus_cfg)) + rval =v4l2_fwnode_endpoint_alloc_parse (ep, &bus_cfg); +if (rval) goto out_err; hwcfg =devm_kzalloc (dev,sizeof (*hwcfg),GFP_KERNEL );if (!hwcfg) goto out_err; -switch (bus_cfg->bus_type) { +switch (bus_cfg.bus_type) {case V4L2_MBUS_CSI2_DPHY : hwcfg->csi_signalling_mode =SMIAPP_CSI_SIGNALLING_MODE_CSI2 ; - hwcfg->lanes = bus_cfg->bus.mipi_csi2.num_data_lanes; + hwcfg->lanes = bus_cfg.bus.mipi_csi2.num_data_lanes;break ;case V4L2_MBUS_CCP2 : - hwcfg->csi_signalling_mode = (bus_cfg->bus.mipi_csi1.strobe) ? + hwcfg->csi_signalling_mode = (bus_cfg.bus.mipi_csi1.strobe) ?SMIAPP_CSI_SIGNALLING_MODE_CCP2_DATA_STROBE :SMIAPP_CSI_SIGNALLING_MODE_CCP2_DATA_CLOCK ; hwcfg->lanes =1 ;break ;default : -dev_err (dev,"unsupported bus %u\n" , bus_cfg->bus_type); +dev_err (dev,"unsupported bus %u\n" , bus_cfg.bus_type); goto out_err; }
@@ -2827,28 +2827,28 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)dev_dbg (dev,"nvm %d, clk %d, mode %d\n" , hwcfg->nvm_size, hwcfg->ext_clk, hwcfg->csi_signalling_mode); -if (!bus_cfg->nr_of_link_frequencies) { +if (!bus_cfg.nr_of_link_frequencies) {dev_warn (dev,"no link frequencies defined\n" ); goto out_err; } hwcfg->op_sys_clock =devm_kcalloc ( - dev, bus_cfg->nr_of_link_frequencies +1 /* guardian */ , + dev, bus_cfg.nr_of_link_frequencies +1 /* guardian */ ,sizeof (*hwcfg->op_sys_clock),GFP_KERNEL );if (!hwcfg->op_sys_clock) goto out_err; -for (i =0 ; i < bus_cfg->nr_of_link_frequencies; i++) { - hwcfg->op_sys_clock[i] = bus_cfg->link_frequencies[i]; +for (i =0 ; i < bus_cfg.nr_of_link_frequencies; i++) { + hwcfg->op_sys_clock[i] = bus_cfg.link_frequencies[i];dev_dbg (dev,"freq %d: %lld\n" , i, hwcfg->op_sys_clock[i]); } -v4l2_fwnode_endpoint_free (bus_cfg); +v4l2_fwnode_endpoint_free (&bus_cfg);fwnode_handle_put (ep);return hwcfg; out_err: -v4l2_fwnode_endpoint_free (bus_cfg); +v4l2_fwnode_endpoint_free (&bus_cfg);fwnode_handle_put (ep);return NULL ; }
drivers/media/i2c/tc358743.c +14 -12
@@ -1895,11 +1895,11 @@ static void tc358743_gpio_reset(struct tc358743_state *state)static int tc358743_probe_of (struct tc358743_state *state) {struct device *dev = &state->i2c_client->dev; -struct v4l2_fwnode_endpoint *endpoint; +struct v4l2_fwnode_endpoint endpoint = { .bus_type =0 };struct device_node *ep;struct clk *refclk;u32 bps_pr_lane; -int ret = -EINVAL ; +int ret; refclk =devm_clk_get (dev,"refclk" );if (IS_ERR (refclk)) {
@@ -1915,26 +1915,28 @@ static int tc358743_probe_of(struct tc358743_state *state)return -EINVAL ; } - endpoint =v4l2_fwnode_endpoint_alloc_parse (of_fwnode_handle (ep)); -if (IS_ERR (endpoint)) { + ret =v4l2_fwnode_endpoint_alloc_parse (of_fwnode_handle (ep), &endpoint); +if (ret) {dev_err (dev,"failed to parse endpoint\n" ); - ret =PTR_ERR (endpoint); + ret = ret; goto put_node; } -if (endpoint->bus_type !=V4L2_MBUS_CSI2_DPHY || - endpoint->bus.mipi_csi2.num_data_lanes ==0 || - endpoint->nr_of_link_frequencies ==0 ) { +if (endpoint.bus_type !=V4L2_MBUS_CSI2_DPHY || + endpoint.bus.mipi_csi2.num_data_lanes ==0 || + endpoint.nr_of_link_frequencies ==0 ) {dev_err (dev,"missing CSI-2 properties in endpoint\n" ); + ret = -EINVAL ; goto free_endpoint; } -if (endpoint->bus.mipi_csi2.num_data_lanes >4 ) { +if (endpoint.bus.mipi_csi2.num_data_lanes >4 ) {dev_err (dev,"invalid number of lanes\n" ); + ret = -EINVAL ; goto free_endpoint; } - state->bus = endpoint->bus.mipi_csi2; + state->bus = endpoint.bus.mipi_csi2; ret =clk_prepare_enable (refclk);if (ret) {
@@ -1967,7 +1969,7 @@ static int tc358743_probe_of(struct tc358743_state *state)* The CSI bps per lane must be between 62.5 Mbps and 1 Gbps. * The default is 594 Mbps for 4-lane 1080p60 or 2-lane 720p60. */ - bps_pr_lane =2 * endpoint->link_frequencies[0 ]; + bps_pr_lane =2 * endpoint.link_frequencies[0 ];if (bps_pr_lane <62500000U || bps_pr_lane >1000000000U ) {dev_err (dev,"unsupported bps per lane: %u bps\n" , bps_pr_lane); goto disable_clk;
@@ -2013,7 +2015,7 @@ static int tc358743_probe_of(struct tc358743_state *state) disable_clk:clk_disable_unprepare (refclk); free_endpoint: -v4l2_fwnode_endpoint_free (endpoint); +v4l2_fwnode_endpoint_free (&endpoint); put_node:of_node_put (ep);return ret;
drivers/media/v4l2-core/v4l2-fwnode.c +25 -34
125 lines not on this page · raw message
include/media/v4l2-fwnode.h +5 -2
@@ -161,6 +161,7 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep);/** * v4l2_fwnode_endpoint_alloc_parse() - parse all fwnode node properties * @fwnode: pointer to the endpoint's fwnode handle +* @vep: pointer to the V4L2 fwnode data structure * * All properties are optional. If none are found, we don't set any flags. This * means the port has a static configuration and no properties have to be
@@ -170,6 +171,8 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep);* set the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag. The caller should hold a * reference to @fwnode. * +* The caller must set the bus_type field of @vep to zero. +* * v4l2_fwnode_endpoint_alloc_parse() has two important differences to * v4l2_fwnode_endpoint_parse(): *
@@ -181,8 +184,8 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep);* Return: Pointer to v4l2_fwnode_endpoint if successful, on an error pointer * on error. */ -struct v4l2_fwnode_endpoint *v4l2_fwnode_endpoint_alloc_parse ( -struct fwnode_handle *fwnode); +int v4l2_fwnode_endpoint_alloc_parse ( +struct fwnode_handle *fwnode,struct v4l2_fwnode_endpoint *vep);/** * v4l2_fwnode_parse_link() - parse a link between two endpoints
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 16/21 v4l: fwnode: Use media bus type for bus parser selection
In reply to Sakari AilusUse the media bus types instead of the fwnode bus types internally. This is the interface to the drivers as well, making the use of the fwnode bus types more localised to the V4L2 fwnode framework.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 98 ++++++++++++++++++++++++++++------- 1 file changed, 79 insertions(+), 19 deletions(-)
drivers/media/v4l2-core/v4l2-fwnode.c +79 -19
@@ -42,9 +42,66 @@ enum v4l2_fwnode_bus_type { NR_OF_V4L2_FWNODE_BUS_TYPE, }; +static const struct v4l2_fwnode_bus_conv { +enum v4l2_fwnode_bus_type fwnode_bus_type; +enum v4l2_mbus_type mbus_type; +const char *name; +} busses[] = { + { +V4L2_FWNODE_BUS_TYPE_GUESS , +V4L2_MBUS_UNKNOWN , +"not specified" , + }, { +V4L2_FWNODE_BUS_TYPE_CSI2_CPHY , +V4L2_MBUS_CSI2_CPHY , +"MIPI CSI-2 C-PHY" , + }, { +V4L2_FWNODE_BUS_TYPE_CSI1 , +V4L2_MBUS_CSI1 , +"MIPI CSI-1" , + }, { +V4L2_FWNODE_BUS_TYPE_CCP2 , +V4L2_MBUS_CCP2 , +"compact camera port 2" , + }, { +V4L2_FWNODE_BUS_TYPE_CSI2_DPHY , +V4L2_MBUS_CSI2_DPHY , +"MIPI CSI-2 D-PHY" , + }, { +V4L2_FWNODE_BUS_TYPE_PARALLEL , +V4L2_MBUS_PARALLEL , +"parallel" , + }, { +V4L2_FWNODE_BUS_TYPE_BT656 , +V4L2_MBUS_BT656 , +"Bt.656" , + } +}; + +static const struct v4l2_fwnode_bus_conv * +get_v4l2_fwnode_bus_conv_by_fwnode_bus (enum v4l2_fwnode_bus_type type) +{ +unsigned int i; + +for (i =0 ; i <ARRAY_SIZE (busses); i++) +if (busses[i].fwnode_bus_type == type) +return &busses[i]; + +return NULL ; +} + +static enum v4l2_mbus_type +v4l2_fwnode_bus_type_to_mbus (enum v4l2_fwnode_bus_type type) +{ +const struct v4l2_fwnode_bus_conv *conv = +get_v4l2_fwnode_bus_conv_by_fwnode_bus (type); + +return conv ? conv->mbus_type :V4L2_MBUS_UNKNOWN ; +} +static int v4l2_fwnode_endpoint_parse_csi2_bus (struct fwnode_handle *fwnode,struct v4l2_fwnode_endpoint *vep, -enum v4l2_fwnode_bus_type bus_type) +enum v4l2_mbus_type bus_type) {struct v4l2_fwnode_bus_mipi_csi2 *bus = &vep->bus.mipi_csi2; bool have_clk_lane = false, have_data_lanes = false,
@@ -58,7 +115,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,u32 v;int rval; -if (bus_type ==V4L2_FWNODE_BUS_TYPE_CSI2_DPHY ) { +if (bus_type ==V4L2_MBUS_CSI2_DPHY ) { use_default_lane_mapping = true; num_data_lanes = min_t(u32, bus->num_data_lanes,
@@ -134,7 +191,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, flags |=V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ; } -if (bus_type ==V4L2_FWNODE_BUS_TYPE_CSI2_DPHY || lanes_used || +if (bus_type ==V4L2_MBUS_CSI2_DPHY || lanes_used || have_clk_lane || (flags & ~V4L2_MBUS_CSI2_CONTINUOUS_CLOCK )) { bus->flags = flags; vep->bus_type =V4L2_MBUS_CSI2_DPHY ;
@@ -177,7 +234,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,static void v4l2_fwnode_endpoint_parse_parallel_bus (struct fwnode_handle *fwnode,struct v4l2_fwnode_endpoint *vep, -enum v4l2_fwnode_bus_type bus_type) +enum v4l2_mbus_type bus_type) {struct v4l2_fwnode_bus_parallel *bus = &vep->bus.parallel;unsigned int flags =0 ;
@@ -274,11 +331,11 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus( vep->bus_type =V4L2_MBUS_BT656 ; }break ; -case V4L2_FWNODE_BUS_TYPE_PARALLEL : +case V4L2_MBUS_PARALLEL : vep->bus_type =V4L2_MBUS_PARALLEL ; bus->flags = flags;break ; -case V4L2_FWNODE_BUS_TYPE_BT656 : +case V4L2_MBUS_BT656 : vep->bus_type =V4L2_MBUS_BT656 ; bus->flags = flags & ~PARALLEL_MBUS_FLAGS ;break ;
@@ -288,7 +345,7 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(static void v4l2_fwnode_endpoint_parse_csi1_bus (struct fwnode_handle *fwnode,struct v4l2_fwnode_endpoint *vep, -enum v4l2_fwnode_bus_type bus_type) +enum v4l2_mbus_type bus_type) {struct v4l2_fwnode_bus_mipi_csi1 *bus = &vep->bus.mipi_csi1;u32 v;
@@ -313,7 +370,7 @@ v4l2_fwnode_endpoint_parse_csi1_bus(struct fwnode_handle *fwnode,pr_debug ("clock-lanes %u\n" , v); } -if (bus_type ==V4L2_FWNODE_BUS_TYPE_CCP2 ) +if (bus_type ==V4L2_MBUS_CCP2 ) vep->bus_type =V4L2_MBUS_CCP2 ;else vep->bus_type =V4L2_MBUS_CSI1 ;
@@ -323,6 +380,7 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode, struct v4l2_fwnode_endpoint *vep) {u32 bus_type =0 ; +enum v4l2_mbus_type mbus_type;int rval;if (vep->bus_type ==V4L2_MBUS_UNKNOWN ) {
@@ -341,10 +399,12 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,fwnode_property_read_u32 (fwnode,"bus-type" , &bus_type); -switch (bus_type) { -case V4L2_FWNODE_BUS_TYPE_GUESS : + mbus_type =v4l2_fwnode_bus_type_to_mbus (bus_type); + +switch (mbus_type) { +case V4L2_MBUS_UNKNOWN : rval =v4l2_fwnode_endpoint_parse_csi2_bus (fwnode, vep, - bus_type); + mbus_type);if (rval)return rval;
@@ -357,22 +417,22 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,break ; -case V4L2_FWNODE_BUS_TYPE_CCP2 : -case V4L2_FWNODE_BUS_TYPE_CSI1 : -v4l2_fwnode_endpoint_parse_csi1_bus (fwnode, vep, bus_type); +case V4L2_MBUS_CCP2 : +case V4L2_MBUS_CSI1 : +v4l2_fwnode_endpoint_parse_csi1_bus (fwnode, vep, mbus_type);break ; -case V4L2_FWNODE_BUS_TYPE_CSI2_DPHY : +case V4L2_MBUS_CSI2_DPHY : vep->bus_type =V4L2_MBUS_CSI2_DPHY ; rval =v4l2_fwnode_endpoint_parse_csi2_bus (fwnode, vep, - bus_type); + mbus_type);if (rval)return rval;break ; -case V4L2_FWNODE_BUS_TYPE_PARALLEL : -case V4L2_FWNODE_BUS_TYPE_BT656 : -v4l2_fwnode_endpoint_parse_parallel_bus (fwnode, vep, bus_type); +case V4L2_MBUS_PARALLEL : +case V4L2_MBUS_BT656 : +v4l2_fwnode_endpoint_parse_parallel_bus (fwnode, vep, mbus_type);break ;default :
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 17/21 v4l: fwnode: Print bus type
In reply to Sakari AilusPrint bus type either as set by the driver or as parsed from the bus-type property, as well as the guessed V4L2 media bus type.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
drivers/media/v4l2-core/v4l2-fwnode.c +38 -0
@@ -99,6 +99,36 @@ v4l2_fwnode_bus_type_to_mbus(enum v4l2_fwnode_bus_type type)return conv ? conv->mbus_type :V4L2_MBUS_UNKNOWN ; } +static const char * +v4l2_fwnode_bus_type_to_string (enum v4l2_fwnode_bus_type type) +{ +const struct v4l2_fwnode_bus_conv *conv = +get_v4l2_fwnode_bus_conv_by_fwnode_bus (type); + +return conv ? conv->name :"not found" ; +} + +static const struct v4l2_fwnode_bus_conv * +get_v4l2_fwnode_bus_conv_by_mbus (enum v4l2_mbus_type type) +{ +unsigned int i; + +for (i =0 ; i <ARRAY_SIZE (busses); i++) +if (busses[i].mbus_type == type) +return &busses[i]; + +return NULL ; +} + +static const char * +v4l2_fwnode_mbus_type_to_string (enum v4l2_mbus_type type) +{ +const struct v4l2_fwnode_bus_conv *conv = +get_v4l2_fwnode_bus_conv_by_mbus (type); + +return conv ? conv->name :"not found" ; +} +static int v4l2_fwnode_endpoint_parse_csi2_bus (struct fwnode_handle *fwnode,struct v4l2_fwnode_endpoint *vep,enum v4l2_mbus_type bus_type)
@@ -398,6 +428,10 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,memset (&vep->base,0 ,sizeof (vep->base));fwnode_property_read_u32 (fwnode,"bus-type" , &bus_type); +pr_debug ("fwnode video bus type %s (%u), mbus type %s (%u)\n" , +v4l2_fwnode_bus_type_to_string (bus_type), bus_type, +v4l2_fwnode_mbus_type_to_string (vep->bus_type), + vep->bus_type); mbus_type =v4l2_fwnode_bus_type_to_mbus (bus_type);
@@ -415,6 +449,10 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,if (vep->bus_type ==V4L2_MBUS_UNKNOWN )return -EINVAL ; +pr_debug ("assuming media bus type %s (%u)\n" , +v4l2_fwnode_mbus_type_to_string (vep->bus_type), + vep->bus_type); +break ;case V4L2_MBUS_CCP2 :
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 13/21 v4l: fwnode: Parse the graph endpoint as last
In reply to Sakari AilusParsing the graph endpoint is always successful; therefore parse it as last.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
drivers/media/v4l2-core/v4l2-fwnode.c +21 -5
@@ -308,7 +308,11 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,pr_debug ("===== begin V4L2 endpoint properties\n" ); -fwnode_graph_parse_endpoint (fwnode, &vep->base); +/* +* Zero the fwnode graph endpoint memory in case we don't end up parsing +* the endpoint. +*/ +memset (&vep->base,0 ,sizeof (vep->base));/* Zero fields from bus_type to until the end */ memset(&vep->bus_type, 0, sizeof(*vep) -
@@ -327,25 +331,37 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,v4l2_fwnode_endpoint_parse_parallel_bus ( fwnode, vep,V4L2_MBUS_UNKNOWN ); -return vep->bus_type ==V4L2_MBUS_UNKNOWN ? -EINVAL :0 ; +if (vep->bus_type ==V4L2_MBUS_UNKNOWN ) +return -EINVAL ; + +break ; +case V4L2_FWNODE_BUS_TYPE_CCP2 :case V4L2_FWNODE_BUS_TYPE_CSI1 :v4l2_fwnode_endpoint_parse_csi1_bus (fwnode, vep, bus_type); +break ; -return 0 ;case V4L2_FWNODE_BUS_TYPE_CSI2_DPHY : vep->bus_type =V4L2_MBUS_CSI2_DPHY ; -return v4l2_fwnode_endpoint_parse_csi2_bus (fwnode, vep, + rval =v4l2_fwnode_endpoint_parse_csi2_bus (fwnode, vep, bus_type); +if (rval) +return rval; + +break ;case V4L2_FWNODE_BUS_TYPE_PARALLEL :case V4L2_FWNODE_BUS_TYPE_BT656 :v4l2_fwnode_endpoint_parse_parallel_bus (fwnode, vep, bus_type); -return 0 ; +break ;default :pr_warn ("unsupported bus type %u\n" , bus_type);return -EINVAL ; } + +fwnode_graph_parse_endpoint (fwnode, &vep->base); + +return 0 ; } int v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 18/21 v4l: fwnode: Use V4L2 fwnode endpoint media bus type if set
In reply to Sakari AilusUse the given media bus type set by the caller. If none is given (i.e. the mbus type is V4L2_MBUS_UNKNOWN, or 0), fall back to the old behaviour. This is to obtain the information from the DT or try to guess the bus type.
-ENXIO is returned if the caller sets the bus type but that does not match with what's in DT.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
drivers/media/v4l2-core/v4l2-fwnode.c +18 -8
@@ -409,7 +409,7 @@ v4l2_fwnode_endpoint_parse_csi1_bus(struct fwnode_handle *fwnode,static int __v4l2_fwnode_endpoint_parse (struct fwnode_handle *fwnode,struct v4l2_fwnode_endpoint *vep) { -u32 bus_type =0 ; +u32 bus_type =V4L2_FWNODE_BUS_TYPE_GUESS ;enum v4l2_mbus_type mbus_type;int rval;
@@ -432,13 +432,24 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,v4l2_fwnode_bus_type_to_string (bus_type), bus_type,v4l2_fwnode_mbus_type_to_string (vep->bus_type), vep->bus_type); - mbus_type =v4l2_fwnode_bus_type_to_mbus (bus_type); -switch (mbus_type) { +if (vep->bus_type !=V4L2_MBUS_UNKNOWN ) { +if (mbus_type !=V4L2_MBUS_UNKNOWN && + vep->bus_type != mbus_type) { +pr_debug ("expecting bus type %s\n" , +v4l2_fwnode_mbus_type_to_string ( + vep->bus_type)); +return -ENXIO ; + } + }else { + vep->bus_type = mbus_type; + } + +switch (vep->bus_type) {case V4L2_MBUS_UNKNOWN : rval =v4l2_fwnode_endpoint_parse_csi2_bus (fwnode, vep, - mbus_type); +V4L2_MBUS_UNKNOWN );if (rval)return rval;
@@ -457,20 +468,19 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,case V4L2_MBUS_CCP2 :case V4L2_MBUS_CSI1 : -v4l2_fwnode_endpoint_parse_csi1_bus (fwnode, vep, mbus_type); +v4l2_fwnode_endpoint_parse_csi1_bus (fwnode, vep, vep->bus_type);break ;case V4L2_MBUS_CSI2_DPHY : - vep->bus_type =V4L2_MBUS_CSI2_DPHY ; rval =v4l2_fwnode_endpoint_parse_csi2_bus (fwnode, vep, - mbus_type); + vep->bus_type);if (rval)return rval;break ;case V4L2_MBUS_PARALLEL :case V4L2_MBUS_BT656 : -v4l2_fwnode_endpoint_parse_parallel_bus (fwnode, vep, mbus_type); +v4l2_fwnode_endpoint_parse_parallel_bus (fwnode, vep, vep->bus_type);break ;default :
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 19/21 v4l: fwnode: Support parsing of CSI-2 C-PHY endpoints
In reply to Sakari AilusThe V4L2 fwnode framework only parsed CSI-2 D-PHY endpoints while C-PHY support wasn't there. Also parse endpoints for media bus type V4L2_MBUS_CSI2_CPHY.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/media/v4l2-core/v4l2-fwnode.c +7 -3
@@ -145,7 +145,8 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,u32 v;int rval; -if (bus_type ==V4L2_MBUS_CSI2_DPHY ) { +if (bus_type ==V4L2_MBUS_CSI2_DPHY || + bus_type ==V4L2_MBUS_CSI2_CPHY ) { use_default_lane_mapping = true; num_data_lanes = min_t(u32, bus->num_data_lanes,
@@ -221,10 +222,12 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, flags |=V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ; } -if (bus_type ==V4L2_MBUS_CSI2_DPHY || lanes_used || +if (bus_type ==V4L2_MBUS_CSI2_DPHY || + bus_type ==V4L2_MBUS_CSI2_CPHY || lanes_used || have_clk_lane || (flags & ~V4L2_MBUS_CSI2_CONTINUOUS_CLOCK )) { bus->flags = flags; - vep->bus_type =V4L2_MBUS_CSI2_DPHY ; +if (bus_type ==V4L2_MBUS_UNKNOWN ) + vep->bus_type =V4L2_MBUS_CSI2_DPHY ; bus->num_data_lanes = num_data_lanes;if (use_default_lane_mapping) {
@@ -472,6 +475,7 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,break ;case V4L2_MBUS_CSI2_DPHY : +case V4L2_MBUS_CSI2_CPHY : rval =v4l2_fwnode_endpoint_parse_csi2_bus (fwnode, vep, vep->bus_type);if (rval)
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 20/21 v4l: fwnode: Update V4L2 fwnode endpoint parsing documentation
In reply to Sakari AilusThe semantics of v4l2_fwnode_endpoint_parse() and v4l2_fwnode_endpoint_alloc_parse() have changed slightly: they now take the bus type from the user as well as a default configuration for the bus that shall reflect the DT binding defaults. Document this.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 3 ++- include/media/v4l2-fwnode.h | 28 +++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-)
drivers/media/v4l2-core/v4l2-fwnode.c +2 -1
@@ -484,7 +484,8 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,break ;case V4L2_MBUS_PARALLEL :case V4L2_MBUS_BT656 : -v4l2_fwnode_endpoint_parse_parallel_bus (fwnode, vep, vep->bus_type); +v4l2_fwnode_endpoint_parse_parallel_bus (fwnode, vep, + vep->bus_type);break ;default :
include/media/v4l2-fwnode.h +27 -1
@@ -139,6 +139,20 @@ struct v4l2_fwnode_link {* set the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag. The caller should hold a * reference to @fwnode. * +* The caller is responsible for assigning @vep.bus_type to a valid media bus +* type, or alternatively V4L2_MBUS_UNKNOWN. Depending on the hardware, the +* information may also be read from the firmware. As a compatibility means +* guessing the bus type is also supported. Mismatching bus types in the V4L2 +* fwnode endpoint and in firmware will also yield an error (-ENXIO). +* +* The user may also set the default parameters for the bus if the bus type is +* explicitly set by the user. In particular, the user may set the default +* number of CSI-2 lanes but without assigning lane mapping, in which case the +* defaults (clock lane 0, data lanes from 1 onwards) will be used. The defaults +* shall reflect the defaults defined in the DT binding documentation. +* +* The function does not change the V4L2 fwnode endpoint state if it fails. +* * NOTE: This function does not parse properties the size of which is variable * without a low fixed limit. Please use v4l2_fwnode_endpoint_alloc_parse() in * new drivers instead.
@@ -171,7 +185,19 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep);* set the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag. The caller should hold a * reference to @fwnode. * -* The caller must set the bus_type field of @vep to zero. +* The caller is responsible for assigning @vep.bus_type to a valid media bus +* type, or alternatively V4L2_MBUS_UNKNOWN. Depending on the hardware, the +* information may also be read from the firmware. As a compatibility means +* guessing the bus type is also supported. Mismatching bus types in the V4L2 +* fwnode endpoint and in firmware will also yield an error (-ENXIO). +* +* The user may also set the default parameters for the bus if the bus type is +* explicitly set by the user. In particular, the user may set the default +* number of CSI-2 lanes but without assigning lane mapping, in which case the +* defaults (clock lane 0, data lanes from 1 onwards) will be used. The defaults +* shall reflect the defaults defined in the DT binding documentation. +* +* The function does not change the V4L2 fwnode endpoint state if it fails. * * v4l2_fwnode_endpoint_alloc_parse() has two important differences to * v4l2_fwnode_endpoint_parse():
Signature · 1 line
2.11.0
Sakari Ailus
maintainerPATCH 21/21 smiapp: Query the V4L2 endpoint for a specific bus type
In reply to Sakari AilusInstead of opportunistically trying to gather some information from the V4L2 endpoint, set the bus type and let the V4L2 fwnode framework figure out the configuration.
--- drivers/media/i2c/smiapp/smiapp-core.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/media/i2c/smiapp/smiapp-core.c +6 -0
@@ -2775,7 +2775,13 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)if (!ep)return NULL ; + bus_cfg.bus_type =V4L2_MBUS_CSI2_DPHY ; rval =v4l2_fwnode_endpoint_alloc_parse (ep, &bus_cfg); +if (rval == -ENXIO ) { + bus_cfg = (struct v4l2_fwnode_endpoint ) + { .bus_type =V4L2_MBUS_CCP2 }; + rval =v4l2_fwnode_endpoint_alloc_parse (ep, &bus_cfg); + }if (rval) goto out_err;
Signature · 1 line
2.11.0
Rob Herring
maintainerRe: [PATCH 05/21] dt-bindings: media: Specify bus type for MIPI D-PHY, others, explicitly
In reply to Sakari AilusQuoted 9 lines · Sakari Ailus
Allow specifying the bus type explicitly for MIPI D-PHY, parallel and Bt.656 busses. This is useful for devices that can make use of different bus types. There are CSI-2 transmitters and receivers but the PHY selection needs to be made between C-PHY and D-PHY; many devices also support parallel and Bt.656 interfaces but the means to pass that information to software wasn't there.
Autodetection (value 0) is removed as an option as the property could be simply omitted in that case.
Presumably there are users, so you can't remove it. But documenting behavior when absent would be good.
Quoted 11 lines
Signed-off-by Sakari Ailus <[email protected]>--- Documentation/devicetree/bindings/media/video-interfaces.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/media/video-interfaces.txt +0
-0
Documentation/devicetree/bindings/media/video-interfaces.txt Optional endpoint properties · line 107
Quoted 9 lines
Documentation/devicetree/bindings/media/video-interfaces.txt +2
-1@@ -100,10 +100,12 @@ Optional endpoint properties slave device (data source) by the master device (data sink). In the master mode the data source device is also the source of the synchronization signals. - bus-type: data bus type. Possible values are: - 0 - autodetect based on other properties (MIPI CSI-2 D-PHY, parallel or Bt656) 1 - MIPI CSI-2 C-PHY 2 - MIPI CSI1 3 - CCP2 + 4 - MIPI CSI-2 D-PHY + 5 - Parallel
Is that really specific enough to be useful?
Quoted 11 lines
Documentation/devicetree/bindings/media/video-interfaces.txt +1
-0+ 6 - Bt.656 - bus-width: number of data lines actively used, valid for the parallel busses. - data-shift: on the parallel data busses, if bus-width is used to specify the number of data lines, data-shift can be used to specify which data lines areSignature · 6 lines
2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Sakari Ailus
maintainerRe: [PATCH 05/21] dt-bindings: media: Specify bus type for MIPI D-PHY, others, explicitly
Hi Rob,
Thanks for the review.
Quoted 8 lines · Rob Herring
Quoted 7 lines · Sakari Ailus
Allow specifying the bus type explicitly for MIPI D-PHY, parallel and Bt.656 busses. This is useful for devices that can make use of different bus types. There are CSI-2 transmitters and receivers but the PHY selection needs to be made between C-PHY and D-PHY; many devices also support parallel and Bt.656 interfaces but the means to pass that information to software wasn't there.
Quoted 5 lines
Quoted 2 lines
Autodetection (value 0) is removed as an option as the property could be simply omitted in that case.
Presumably there are users, so you can't remove it. But documenting behavior when absent would be good.
Well, it's effectively the same as having no such property at all: the type is not specified. Generally there are two possibilities: the hardware supports just a single bus or it supports more than one. If there's just one, the type can be known by the driver. In that case there's no use for autodetection.
The second case is a bit more complicated: the bus type detection is solely based on properties available in the endpoint, and I think that may have been feasible approach when there were just parallel and Bt.656 busses that were supported, but with the additional busses, the V4L2 fwnode framework may no longer guess the bus in any meaningful way from the available properties. I'd think the only known-good option here is to specify the type explicitly in that case: there's no room for guessing. (This patchset makes it possible for drivers to explicitly define the bus type, but the autodetection support is maintained for backwards compatibility.)
One of the existing issues is that there are combined parallel/Bt.656 receivers that need to know the type of the bus. This is based on the existence parallel interface only properties: if any of these exist, then the interface is parallel, otherwise it is Bt.656. The DT bindings for the same devices also define the defaults for the parallel interface. This leaves the end result ambiguous: is it the parallel interface with the default configuration or is it Bt.656?
There will likely be similar issues for CSI-2 D-PHY and CSI-2 C-PHY. The question there would be: is this CSI-2 C-PHY or CSI-2 D-PHY with default clock lane configuration?
In either case the autodetection option for the bus type provides no useful information. If it exists in DT source, that's fine, there's just no use for it.
Let me know if you still think it should be maintained in binding documentation.
Quoted 7 lines
Quoted 7 lines
Signed-off-by Sakari Ailus <[email protected]>--- Documentation/devicetree/bindings/media/video-interfaces.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 16 lines
Quoted 5 lines
Documentation/devicetree/bindings/media/video-interfaces.txt +0
-0Documentation/devicetree/bindings/media/video-interfaces.txt Optional endpoint properties · line 107
Quoted 9 lines
Documentation/devicetree/bindings/media/video-interfaces.txt +2
-1@@ -100,10 +100,12 @@ Optional endpoint properties slave device (data source) by the master device (data sink). In the master mode the data source device is also the source of the synchronization signals. - bus-type: data bus type. Possible values are: - 0 - autodetect based on other properties (MIPI CSI-2 D-PHY, parallel or Bt656) 1 - MIPI CSI-2 C-PHY 2 - MIPI CSI1 3 - CCP2 + 4 - MIPI CSI-2 D-PHY + 5 - ParallelIs that really specific enough to be useful?
Yes; see above.
Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/media/video-interfaces.txt +1
-0+ 6 - Bt.656 - bus-width: number of data lines actively used, valid for the parallel busses. - data-shift: on the parallel data busses, if bus-width is used to specify the number of data lines, data-shift can be used to specify which data lines are
Signature · 4 lines
Kind regards, Sakari Ailus [email protected]
Hi Sakari,
thanks for this nice rework
Quoted 34 lines · Sakari Ailus
Hello everyone,
I've long thought the V4L2 fwnode framework requires some work (it's buggy and it does not adequately serve common needs). This set should address in particular these matters:
- Most devices support a particular media bus type but the V4L2 fwnode framework was not able to use such information, but instead tried to guess the bus type with varying levels of success while drivers generally ignored the results. This patchset makes that possible --- setting a bus type enables parsing configuration for only that bus. Failing that check results in returning
-ENXIOto be returned.- Support specifying default configuration. If the endpoint has no configuration, the defaults set by the driver (as documented in DT bindings) will prevail. Any available configuration will still be read from the endpoint as one could expect. A common use case for this is e.g. the number of CSI-2 lanes. Few devices support lane mapping, and default 1:1 mapping is provided in absence of a valid default or configuration read OF.
- Debugging information is greatly improved.
- Recognition of the differences between CSI-2 D-PHY and C-PHY. All currently supported hardware (or at least drivers) is D-PHY only, so this change is still easy.
The smiapp driver is converted to use the new functionality. This patchset does not address remaining issues such as supporting setting defaults for e.g. bridge drivers with multiple ports, but with Steve Longerbeam's patchset we're much closer with that goal. I've rebased this set on top of Steve's. Albeit the two deal with the same files, there were only a few trivial conflicts.
Quoted 6 lines
Note that I've only tested parsing endpoints for the CSI-2 bus (no parallel IF hardware). Testing in general would be beneficial: the code flows are rather convoluted and different hardware tends to excercise different flows while the use of the use of defaults has a similar effect.
I have tested on a parallel device, and so far it's all good. I would like to test default settings next, and see how they behave.
Quoted 2 lines
Comments are welcome.
In the meantine, looking at your (anticipated) v2, and in particular to this commit
https://git.linuxtv.org/sailus/media_tree.git/commit/?h=v4l2-fwnode-next&id=077d73a3e1b66f9fbb1227245b1332cc1c7871d4
I'm wondering if introducing an API to query the bus type from the firmware wouldn't be beneficial for bridge drivers (and possibly for sensor drivers too).
I see in that commit most drivers will set the bus type to 0 and rely on autoguessing, which is fine, but I'm thinking at peripheral that can support two different media busses (eg. Parallel and BT.656) or sensor that can work with parallel or CSI-2 interface, and in that case would you consider something like:
static int bridge_driver_parse_of(struct device_node *np):
struct v4l2_fwnode_endpoint bus_cfg ;
bus_type = v4l2_fwnode_get_bus_type(fwnode_handle(np);
if (bus_type != V4L2_MBUS_PARALLEL &&
bus_type != V4L2_MBUS_BT656)
return -ENXIO;
bus_cfg.bus_type = bus_type;
v4l2_fwnode_endpoint_parse(of_fwnode_handle(np), &bus_cfg);Adding a function to retrieve the bus type specified in firmware would make easier for drivers to check if the configuration is acceptable (as this is a device specific decision) and use this information later to provide to v4l2_fwnode_endpoint_parse() a v4l2_fwnode_endpoint with the bus_type initialized, so it does not need to rely on autoguessing.
Otherwise, if I got this right, the only way not to go with autoguessing is to restrict the supported media bus type to a single one, which for some devices is a limitation.
Does this makes sense to you?
Thanks
j
Quoted 63 lines
I've pushed the patches (including Steve's) here:
<URL:https://git.linuxtv.org/sailus/media_tree.git/log/?h=v4l2-fwnode>
Sakari Ailus (21):
v4l: fwnode: Add debug prints for V4L2 endpoint property parsing
v4l: fwnode: Usefwnode_graph_for_each_endpoint
v4l: fwnode: Detect bus type correctly
v4l: fwnode: The CSI-2 clock is continuous if it's not non-continuous
dt-bindings: media: Specify bus type for MIPI D-PHY, others,
explicitly
v4l: fwnode: Add definitions for CSI-2 D-PHY, parallel and Bt.656
busses
v4l: mediabus: Recognise CSI-2 D-PHY and C-PHY
v4l: fwnode: Make use of newly specified bus types
v4l: fwnode: Read lane inversion information despite lane numbering
v4l: fwnode: Only assign configuration if there is no error
v4l: fwnode: Support driver-defined lane mapping defaults
v4l: fwnode: Support default CSI-2 lane mapping for drivers
v4l: fwnode: Parse the graph endpoint as last
v4l: fwnode: Use default parallel flags
v4l: fwnode: Allow setting default parameters
v4l: fwnode: Use media bus type for bus parser selection
v4l: fwnode: Print bus type
v4l: fwnode: Use V4L2 fwnode endpoint media bus type if set
v4l: fwnode: Support parsing of CSI-2 C-PHY endpoints
v4l: fwnode: Update V4L2 fwnode endpoint parsing documentation
smiapp: Query the V4L2 endpoint for a specific bus type.../devicetree/bindings/media/video-interfaces.txt | 4 +- drivers/gpu/ipu-v3/ipu-csi.c | 2 +- drivers/media/i2c/adv7180.c | 2 +- drivers/media/i2c/ov2659.c | 14 +- drivers/media/i2c/ov5640.c | 4 +- drivers/media/i2c/ov5645.c | 2 +- drivers/media/i2c/ov7251.c | 4 +- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 2 +- drivers/media/i2c/s5k5baf.c | 4 +- drivers/media/i2c/s5k6aa.c | 2 +- drivers/media/i2c/smiapp/smiapp-core.c | 34 +- drivers/media/i2c/soc_camera/ov5642.c | 2 +- drivers/media/i2c/tc358743.c | 28 +- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +- drivers/media/platform/cadence/cdns-csi2rx.c | 2 +- drivers/media/platform/cadence/cdns-csi2tx.c | 2 +- drivers/media/platform/marvell-ccic/mcam-core.c | 4 +- drivers/media/platform/marvell-ccic/mmp-driver.c | 2 +- drivers/media/platform/omap3isp/isp.c | 2 +- drivers/media/platform/pxa_camera.c | 2 +- drivers/media/platform/rcar-vin/rcar-csi2.c | 2 +- drivers/media/platform/soc_camera/soc_mediabus.c | 2 +- drivers/media/platform/stm32/stm32-dcmi.c | 2 +- drivers/media/platform/ti-vpe/cal.c | 2 +- drivers/media/v4l2-core/v4l2-fwnode.c | 510 ++++++++++++++++----- drivers/staging/media/imx/imx-media-csi.c | 2 +- drivers/staging/media/imx/imx6-mipi-csi2.c | 2 +- drivers/staging/media/imx074/imx074.c | 2 +- include/media/v4l2-fwnode.h | 33 +- include/media/v4l2-mediabus.h | 8 +- 30 files changed, 505 insertions(+), 180 deletions(-)--
2.11.0
Sakari Ailus
maintainerHi Jacopo,
Quoted 45 lines · jacopo mondi
Hi Sakari,
thanks for this nice reworkQuoted 34 lines · Sakari Ailus
Hello everyone,
I've long thought the V4L2 fwnode framework requires some work (it's buggy and it does not adequately serve common needs). This set should address in particular these matters:
- Most devices support a particular media bus type but the V4L2 fwnode framework was not able to use such information, but instead tried to guess the bus type with varying levels of success while drivers generally ignored the results. This patchset makes that possible --- setting a bus type enables parsing configuration for only that bus. Failing that check results in returning
-ENXIOto be returned.- Support specifying default configuration. If the endpoint has no configuration, the defaults set by the driver (as documented in DT bindings) will prevail. Any available configuration will still be read from the endpoint as one could expect. A common use case for this is e.g. the number of CSI-2 lanes. Few devices support lane mapping, and default 1:1 mapping is provided in absence of a valid default or configuration read OF.
- Debugging information is greatly improved.
- Recognition of the differences between CSI-2 D-PHY and C-PHY. All currently supported hardware (or at least drivers) is D-PHY only, so this change is still easy.
The smiapp driver is converted to use the new functionality. This patchset does not address remaining issues such as supporting setting defaults for e.g. bridge drivers with multiple ports, but with Steve Longerbeam's patchset we're much closer with that goal. I've rebased this set on top of Steve's. Albeit the two deal with the same files, there were only a few trivial conflicts.
Quoted 6 lines
Note that I've only tested parsing endpoints for the CSI-2 bus (no parallel IF hardware). Testing in general would be beneficial: the code flows are rather convoluted and different hardware tends to excercise different flows while the use of the use of defaults has a similar effect.
Quoted 2 lines
I have tested on a parallel device, and so far it's all good. I would like to test default settings next, and see how they behave.
Thanks a lot!
Quoted 10 lines
Quoted 3 lines
Comments are welcome.
In the meantine, looking at your (anticipated) v2, and in particular to this commit
https://git.linuxtv.org/sailus/media_tree.git/commit/?h=v4l2-fwnode-next&id=077d73a3e1b66f9fbb1227245b1332cc1c7871d4
I'm wondering if introducing an API to query the bus type from the firmware wouldn't be beneficial for bridge drivers (and possibly for sensor drivers too).
The current API are basically gives you two options:
1. Try with a given bus type, in which case you'll be able to set default parameters as well. This is preferred as it allows setting defaults.
2. Let the fwnode framework decide.
Adding one more API function to tell the bus type to the driver wouldn't change much. To be useful, one of the inputs would need to be a list of possible bus types, and the fwnode framework would need to parse the properties once again.
The way I see it is that it'd be likely most practical to simply try: for hardware that supports more than one bus type, the bus-type property is quasi mandatory. If there's an error, i.e. -ENXIO, the driver simply tries a differen bus type --- with default parameters specific to that bus.
Usually there are just two possibilities, so there's not that many to choose from anyway.
Quoted 3 lines
I see in that commit most drivers will set the bus type to 0 and rely on autoguessing, which is fine, but I'm thinking at peripheral that
Yes, the patchset at least currently does not try to improve those drivers but just to maintain the functionality unchanged. There are quite few changes already in the patchset and I'm trying to avoid regressions.
Quoted 11 lines
can support two different media busses (eg. Parallel and BT.656) or sensor that can work with parallel or CSI-2 interface, and in that case would you consider something like:
static int
bridge_driver_parse_of(struct device_node *np):struct v4l2_fwnode_endpoint bus_cfg ; bus_type = v4l2_fwnode_get_bus_type(fwnode_handle(np); if (bus_type != V4L2_MBUS_PARALLEL && bus_type != V4L2_MBUS_BT656) return -ENXIO;
Very few drivers actually check the bus type currently, and then proceed with accessing parameters of the bus they support --- whether or not it was parsed by the V4L2 fwnode framework (or not).
Quoted 3 lines
bus_cfg.bus_type = bus_type;
v4l2_fwnode_endpoint_parse(of_fwnode_handle(np), &bus_cfg);Here, you'd set the default parameters for that bus.
Quoted 10 lines
Adding a function to retrieve the bus type specified in firmware would make easier for drivers to check if the configuration is acceptable (as this is a device specific decision) and use this information later to provide to
v4l2_fwnode_endpoint_parse()av4l2_fwnode_endpointwith thebus_typeinitialized, so it does not need to rely on autoguessing.Otherwise, if I got this right, the only way not to go with autoguessing is to restrict the supported media bus type to a single one, which for some devices is a limitation.
Not quite. You can call v4l2_fwnode_endpoint_parse() multiple times --- as the smiapp driver does.
For a driver point of view I don't see much difference whether you try all (one or two) options or if you first query the bus type and then proceed with parsing properties for that particular bus type.
Signature · 4 lines
Kind regards, Sakari Ailus [email protected]
Sakari Ailus
maintainerRe: [PATCH 05/21] dt-bindings: media: Specify bus type for MIPI D-PHY, others, explicitly
In reply to Sakari AilusPing?
Quoted 47 lines · Sakari Ailus
Hi Rob,
Thanks for the review.
Quoted 8 lines · Rob Herring
Quoted 7 lines · Sakari Ailus
Allow specifying the bus type explicitly for MIPI D-PHY, parallel and Bt.656 busses. This is useful for devices that can make use of different bus types. There are CSI-2 transmitters and receivers but the PHY selection needs to be made between C-PHY and D-PHY; many devices also support parallel and Bt.656 interfaces but the means to pass that information to software wasn't there.
Quoted 5 lines
Quoted 2 lines
Autodetection (value 0) is removed as an option as the property could be simply omitted in that case.
Presumably there are users, so you can't remove it. But documenting behavior when absent would be good.
Well, it's effectively the same as having no such property at all: the type is not specified. Generally there are two possibilities: the hardware supports just a single bus or it supports more than one. If there's just one, the type can be known by the driver. In that case there's no use for autodetection.
The second case is a bit more complicated: the bus type detection is solely based on properties available in the endpoint, and I think that may have been feasible approach when there were just parallel and Bt.656 busses that were supported, but with the additional busses, the V4L2 fwnode framework may no longer guess the bus in any meaningful way from the available properties. I'd think the only known-good option here is to specify the type explicitly in that case: there's no room for guessing. (This patchset makes it possible for drivers to explicitly define the bus type, but the autodetection support is maintained for backwards compatibility.)
One of the existing issues is that there are combined parallel/Bt.656 receivers that need to know the type of the bus. This is based on the existence parallel interface only properties: if any of these exist, then the interface is parallel, otherwise it is Bt.656. The DT bindings for the same devices also define the defaults for the parallel interface. This leaves the end result ambiguous: is it the parallel interface with the default configuration or is it Bt.656?
There will likely be similar issues for CSI-2 D-PHY and CSI-2 C-PHY. The question there would be: is this CSI-2 C-PHY or CSI-2 D-PHY with default clock lane configuration?
Quoted 6 lines
In either case the autodetection option for the bus type provides no useful information. If it exists in DT source, that's fine, there's just no use for it.
Let me know if you still think it should be maintained in binding documentation.
If you prefer to keep it, I'd propose to mark it as deprecated or something as it provides no information to software.
Quoted 33 lines
Quoted 8 lines
Quoted 8 lines
Signed-off-by Sakari Ailus <[email protected]>--- Documentation/devicetree/bindings/media/video-interfaces.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)Quoted 16 lines
Quoted 5 lines
Documentation/devicetree/bindings/media/video-interfaces.txt +0
-0Documentation/devicetree/bindings/media/video-interfaces.txt Optional endpoint properties · line 107
Quoted 9 lines
Documentation/devicetree/bindings/media/video-interfaces.txt +2
-1@@ -100,10 +100,12 @@ Optional endpoint properties slave device (data source) by the master device (data sink). In the master mode the data source device is also the source of the synchronization signals. - bus-type: data bus type. Possible values are: - 0 - autodetect based on other properties (MIPI CSI-2 D-PHY, parallel or Bt656) 1 - MIPI CSI-2 C-PHY 2 - MIPI CSI1 3 - CCP2 + 4 - MIPI CSI-2 D-PHY + 5 - ParallelIs that really specific enough to be useful?
Yes; see above.
Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/media/video-interfaces.txt +1
-0+ 6 - Bt.656 - bus-width: number of data lines actively used, valid for the parallel busses. - data-shift: on the parallel data busses, if bus-width is used to specify the number of data lines, data-shift can be used to specify which data lines are
Signature · 4 lines
Regards, Sakari Ailus [email protected]
Rob Herring
maintainerRe: [PATCH 05/21] dt-bindings: media: Specify bus type for MIPI D-PHY, others, explicitly
Quoted 55 lines · Sakari Ailus
Ping?
Quoted 51 lines · Sakari Ailus
Hi Rob,
Thanks for the review.
Quoted 8 lines · Rob Herring
Quoted 7 lines · Sakari Ailus
Allow specifying the bus type explicitly for MIPI D-PHY, parallel and Bt.656 busses. This is useful for devices that can make use of different bus types. There are CSI-2 transmitters and receivers but the PHY selection needs to be made between C-PHY and D-PHY; many devices also support parallel and Bt.656 interfaces but the means to pass that information to software wasn't there.
Quoted 5 lines
Quoted 2 lines
Autodetection (value 0) is removed as an option as the property could be simply omitted in that case.
Presumably there are users, so you can't remove it. But documenting behavior when absent would be good.
Well, it's effectively the same as having no such property at all: the type is not specified. Generally there are two possibilities: the hardware supports just a single bus or it supports more than one. If there's just one, the type can be known by the driver. In that case there's no use for autodetection.
The second case is a bit more complicated: the bus type detection is solely based on properties available in the endpoint, and I think that may have been feasible approach when there were just parallel and Bt.656 busses that were supported, but with the additional busses, the V4L2 fwnode framework may no longer guess the bus in any meaningful way from the available properties. I'd think the only known-good option here is to specify the type explicitly in that case: there's no room for guessing. (This patchset makes it possible for drivers to explicitly define the bus type, but the autodetection support is maintained for backwards compatibility.)
One of the existing issues is that there are combined parallel/Bt.656 receivers that need to know the type of the bus. This is based on the existence parallel interface only properties: if any of these exist, then the interface is parallel, otherwise it is Bt.656. The DT bindings for the same devices also define the defaults for the parallel interface. This leaves the end result ambiguous: is it the parallel interface with the default configuration or is it Bt.656?
There will likely be similar issues for CSI-2 D-PHY and CSI-2 C-PHY. The question there would be: is this CSI-2 C-PHY or CSI-2 D-PHY with default clock lane configuration?
In either case the autodetection option for the bus type provides no useful information. If it exists in DT source, that's fine, there's just no use for it.
Quoted 5 lines
Quoted 2 lines
Let me know if you still think it should be maintained in binding documentation.
If you prefer to keep it, I'd propose to mark it as deprecated or something as it provides no information to software.
Looks like there's only one user in tree:
arch/arm/boot/dts/omap3-n900.dts:
bus-type = <3>; /* CCP2 */arch/arm/boot/dts/omap3-n900.dts:
bus-type = <3>; /* CCP2 */
So I guess removing is okay.
Rob
Sakari Ailus
maintainerRe: [PATCH 05/21] dt-bindings: media: Specify bus type for MIPI D-PHY, others, explicitly
Hi Rob,
Quoted 63 lines · Rob Herring
Quoted 55 lines · Sakari Ailus
Ping?
Quoted 51 lines · Sakari Ailus
Hi Rob,
Thanks for the review.
Quoted 8 lines · Rob Herring
Quoted 7 lines · Sakari Ailus
Allow specifying the bus type explicitly for MIPI D-PHY, parallel and Bt.656 busses. This is useful for devices that can make use of different bus types. There are CSI-2 transmitters and receivers but the PHY selection needs to be made between C-PHY and D-PHY; many devices also support parallel and Bt.656 interfaces but the means to pass that information to software wasn't there.
Quoted 5 lines
Quoted 2 lines
Autodetection (value 0) is removed as an option as the property could be simply omitted in that case.
Presumably there are users, so you can't remove it. But documenting behavior when absent would be good.
Well, it's effectively the same as having no such property at all: the type is not specified. Generally there are two possibilities: the hardware supports just a single bus or it supports more than one. If there's just one, the type can be known by the driver. In that case there's no use for autodetection.
The second case is a bit more complicated: the bus type detection is solely based on properties available in the endpoint, and I think that may have been feasible approach when there were just parallel and Bt.656 busses that were supported, but with the additional busses, the V4L2 fwnode framework may no longer guess the bus in any meaningful way from the available properties. I'd think the only known-good option here is to specify the type explicitly in that case: there's no room for guessing. (This patchset makes it possible for drivers to explicitly define the bus type, but the autodetection support is maintained for backwards compatibility.)
One of the existing issues is that there are combined parallel/Bt.656 receivers that need to know the type of the bus. This is based on the existence parallel interface only properties: if any of these exist, then the interface is parallel, otherwise it is Bt.656. The DT bindings for the same devices also define the defaults for the parallel interface. This leaves the end result ambiguous: is it the parallel interface with the default configuration or is it Bt.656?
There will likely be similar issues for CSI-2 D-PHY and CSI-2 C-PHY. The question there would be: is this CSI-2 C-PHY or CSI-2 D-PHY with default clock lane configuration?
In either case the autodetection option for the bus type provides no useful information. If it exists in DT source, that's fine, there's just no use for it.
Quoted 5 lines
Quoted 2 lines
Let me know if you still think it should be maintained in binding documentation.
If you prefer to keep it, I'd propose to mark it as deprecated or something as it provides no information to software.
Quoted 8 lines
Looks like there's only one user in tree:
arch/arm/boot/dts/omap3-n900.dts:
bus-type = <3>; /* CCP2 */arch/arm/boot/dts/omap3-n900.dts:
bus-type = <3>; /* CCP2 */So I guess removing is okay.
Note that we're only discussing the value 0 --- autodetection. The rest of the values are good as they are, and indeed, necessary for unambiguous parsing of the endpoint configuration in cases where the hardware supports multiple bus types.
Signature · 2 lines
Sakari Ailus [email protected]