media: v4l: add support for Virtual Channel IDs
Subsystems (6)
v2 cover media: v4l: add support for Virtual Channel IDs
Multi-camera systems often have issues with receiving video streams from multiple cameras at the same time because the cameras use the same Virtual Channel IDs.
CSI bridges might not support remapping the Virtual Channel IDs, making it impossible to receive the separate video streams at the same time, while the CSI receiver is able to de-mux streams based on VC IDs.
Cameras sometimes have support for changing the VC IDs they output themselves.
For a practical example, GMSL2 deserializer chips do not support VC ID remapping in tunnel mode, and neither do the serializers. Allowing the cameras to have their VC IDs configured would allow multi-camera setups to use tunnel mode.
Add support for specifying these Virtual Channel IDs in Video Interface Endpoints.
Add support for parsing VC IDs in v4l2_fwnode_endpoint_parse(). This allows us to retrieve the specified VC IDs in camera drivers and configure the hardware to use them.
The supported values are 0 to 3, with a maximum of 4 values. Although the CSI-2 specification allows for up to 32 virtual channels, most hardware doesn't support more than 4. This can be extended later if need be.
The driver must validate the number of VC IDs and the VC IDs themselves.
Add an example implementation for IMX219.
V2:
* goto err_rpm_put on failure to configure VC ID in imx219, and print error
Cosmin Tanislav (5):
dt-bindings: media: video-interfaces: add support for Virtual Channel
IDs
media: v4l: fwnode: parse Virtual Channel IDs for CSI2 buses
dt-bindings: media: imx219: add support for Virtual Channel IDs
media: i2c: imx219: pass format's code to imx219_get_format_bpp()
media: i2c: imx219: implement configurable VC ID
Laurent Pinchart (1):
media: i2c: imx219: Report streams using frame descriptors
.../devicetree/bindings/media/i2c/imx219.yaml | 2 + .../bindings/media/video-interfaces.yaml | 11 ++++ drivers/media/i2c/imx219.c | 56 ++++++++++++++++++- drivers/media/v4l2-core/v4l2-fwnode.c | 15 +++++ include/media/v4l2-mediabus.h | 5 ++ 5 files changed, 86 insertions(+), 3 deletions(-)
Signature · 1 line
2.48.1
PATCH v2 1/6 dt-bindings: media: video-interfaces: add support for Virtual Channel IDs
Multi-camera systems often have issues with receiving video streams from multiple cameras at the same time because the cameras use the same Virtual Channel IDs.
CSI bridges might not support remapping the Virtual Channel IDs, making it impossible to receive the separate video streams at the same time, while the CSI receiver is able to de-mux streams based on VC IDs.
Cameras sometimes have support for changing the VC IDs they output themselves.
For a practical example, GMSL2 deserializer chips do not support VC ID remapping in tunnel mode, and neither do the serializers. Allowing the cameras to have their VC IDs configured would allow multi-camera setups to use tunnel mode.
Add support for specifying these Virtual Channel IDs in Video Interface Endpoints. The supported values are 0 to 3, with a maximum of 4 values. Although the CSI-2 specification allows for up to 32 virtual channels, most hardware doesn't support more than 4. This can be extended later if need be.
--- .../devicetree/bindings/media/video-interfaces.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+)
Documentation/devicetree/bindings/media/video-interfaces.yaml +11 -0
@@ -231,6 +231,17 @@ properties: shall be interpreted as 0 (ABC). This property is valid for CSI-2 C-PHY busses only. + vc-ids: + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 1 + maxItems: 4 + items: + maximum: 3 + description: + An array of Virtual Channel IDs. These are unsigned integers that specify + the VC IDs used by the device for its data streams. This property is valid + for MIPI CSI-2 only. + strobe: $ref: /schemas/types.yaml#/definitions/uint32 enum: [ 0, 1 ]
Signature · 1 line
2.48.1
Sakari Ailus
maintainerRe: [PATCH v2 1/6] dt-bindings: media: video-interfaces: add support for Virtual Channel IDs
Hi Cosmin,
Thanks for the patches.
Quoted 8 lines · Cosmin Tanislav
Multi-camera systems often have issues with receiving video streams from multiple cameras at the same time because the cameras use the same Virtual Channel IDs.
CSI bridges might not support remapping the Virtual Channel IDs, making it impossible to receive the separate video streams at the same time, while the CSI receiver is able to de-mux streams based on VC IDs.
Quoted 7 lines
Cameras sometimes have support for changing the VC IDs they output themselves.
For a practical example, GMSL2 deserializer chips do not support VC ID remapping in tunnel mode, and neither do the serializers. Allowing the cameras to have their VC IDs configured would allow multi-camera setups to use tunnel mode.
We've tried to avoid having virtual channels in firmware and in UAPI, I'm not yet entirely convinced we need to depart from the established practices. Let's see. Apart from that, please see my comments below.
Quoted 17 lines
Add support for specifying these Virtual Channel IDs in Video Interface Endpoints. The supported values are 0 to 3, with a maximum of 4 values. Although the CSI-2 specification allows for up to 32 virtual channels, most hardware doesn't support more than 4. This can be extended later if need be.
Signed-off-by Cosmin Tanislav <[email protected]>--- .../devicetree/bindings/media/video-interfaces.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+)Documentation/devicetree/bindings/media/video-interfaces.yaml +0
-0
Documentation/devicetree/bindings/media/video-interfaces.yaml properties: · line 234
Quoted 4 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +1
-0@@ -231,6 +231,17 @@ properties: shall be interpreted as 0 (ABC). This property is valid for CSI-2 C-PHY busses only. + vc-ids:
Other properties aren't using abbreviations, at least most of them. How about "virtual-channels"?
Documentation/devicetree/bindings/media/video-interfaces.yaml properties: · line 237
Quoted 3 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +3
-0+ $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 1 + maxItems: 4
Shouldn't this be 32?
Documentation/devicetree/bindings/media/video-interfaces.yaml properties: · line 239
Quoted 2 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +2
-0+ items: + maximum: 3
31 here, too.
Documentation/devicetree/bindings/media/video-interfaces.yaml properties: · line 241
Quoted 2 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +2
-0+ description: + An array of Virtual Channel IDs. These are unsigned integers that specify
I'd leave out the explanation on the data type. It's redundant.
Quoted 6 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +3
-0+ the VC IDs used by the device for its data streams. This property is valid + for MIPI CSI-2 only. + strobe: $ref: /schemas/types.yaml#/definitions/uint32 enum: [ 0, 1 ]
Signature · 3 lines
Kind regards, Sakari Ailus
Re: [PATCH v2 1/6] dt-bindings: media: video-interfaces: add support for Virtual Channel IDs
Quoted 16 lines · Sakari Ailus
Hi Cosmin,
Thanks for the patches.
Quoted 11 lines · Cosmin Tanislav
Multi-camera systems often have issues with receiving video streams from multiple cameras at the same time because the cameras use the same Virtual Channel IDs.
CSI bridges might not support remapping the Virtual Channel IDs, making it impossible to receive the separate video streams at the same time, while the CSI receiver is able to de-mux streams based on VC IDs.
Cameras sometimes have support for changing the VC IDs they output themselves.
Quoted 9 lines
Quoted 4 lines
For a practical example, GMSL2 deserializer chips do not support VC ID remapping in tunnel mode, and neither do the serializers. Allowing the cameras to have their VC IDs configured would allow multi-camera setups to use tunnel mode.
We've tried to avoid having virtual channels in firmware and in UAPI, I'm not yet entirely convinced we need to depart from the established practices. Let's see. Apart from that, please see my comments below.
Sadly there's no other way to handle multi-camera support for GMSL devices that don't support VC ID remapping. And upcomming GMSL3 devices only support tunnel mode which doesn't support any type of remapping.
Quoted 20 lines
Quoted 20 lines
Add support for specifying these Virtual Channel IDs in Video Interface Endpoints. The supported values are 0 to 3, with a maximum of 4 values. Although the CSI-2 specification allows for up to 32 virtual channels, most hardware doesn't support more than 4. This can be extended later if need be.
Signed-off-by Cosmin Tanislav <[email protected]>--- .../devicetree/bindings/media/video-interfaces.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+)Documentation/devicetree/bindings/media/video-interfaces.yaml +0
-0@@ -231,6 +231,17 @@ properties: shall be interpreted as 0 (ABC). This property is valid for CSI-2 C-PHY busses only.
Quoted 5 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml properties: · line 234
Quoted 1 line
Documentation/devicetree/bindings/media/video-interfaces.yaml +1
-0+ vc-ids:Other properties aren't using abbreviations, at least most of them. How about "virtual-channels"?
That works for me.
Quoted 6 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml properties: · line 237
Quoted 3 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +3
-0+ $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 1 + maxItems: 4Shouldn't this be 32?
For the moment I picked 4 VC IDs (2 bits per VC ID) because any more than that doesn't seem to be supported by CSI receivers, since most do not support extended VC IDs.
Also, from the MIPI specification:
The Data Identifier byte contains the Virtual Channel Identifier (VC) value and the Data Type (DT) value as illustrated in Figure 32.
The Virtual Channel Identifier is contained in the two MS bits of the Data Identifier Byte. The Data Type value is contained in the six LS bits of the Data Identifier Byte.
Quoted 17 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml properties: · line 239
Quoted 2 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +2
-0+ items: + maximum: 331 here, too.
Documentation/devicetree/bindings/media/video-interfaces.yaml properties: · line 241
Quoted 2 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +2
-0+ description: + An array of Virtual Channel IDs. These are unsigned integers that specifyI'd leave out the explanation on the data type. It's redundant.
Quoted 6 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +3
-0+ the VC IDs used by the device for its data streams. This property is valid + for MIPI CSI-2 only. + strobe: $ref: /schemas/types.yaml#/definitions/uint32 enum: [ 0, 1 ]
Re: [PATCH v2 1/6] dt-bindings: media: video-interfaces: add support for Virtual Channel IDs
In reply to Sakari AilusQuoted 16 lines · Sakari Ailus
Hi Cosmin,
Thanks for the patches.
Quoted 11 lines · Cosmin Tanislav
Multi-camera systems often have issues with receiving video streams from multiple cameras at the same time because the cameras use the same Virtual Channel IDs.
CSI bridges might not support remapping the Virtual Channel IDs, making it impossible to receive the separate video streams at the same time, while the CSI receiver is able to de-mux streams based on VC IDs.
Cameras sometimes have support for changing the VC IDs they output themselves.
Quoted 9 lines
Quoted 4 lines
For a practical example, GMSL2 deserializer chips do not support VC ID remapping in tunnel mode, and neither do the serializers. Allowing the cameras to have their VC IDs configured would allow multi-camera setups to use tunnel mode.
We've tried to avoid having virtual channels in firmware and in UAPI, I'm not yet entirely convinced we need to depart from the established practices. Let's see. Apart from that, please see my comments below.
Can you think if any other way of handling this? The most useful way would be to have it accessible at runtime so that devices upstream of the cameras could assign the VC IDs dynamically.
This would be useful when having more cameras than the maximum supported number of VC IDs (4, without extended VC IDs), and streaming from them selectively.
For example, for 8 cameras, you'd have to prepare your VC IDs in advance to fit the streaming selection you want to make. If the cameras 0 to 7 have the VC IDs 0, 1, 2, 3, 0, 1, 2, 3, you wouldn't be able to stream camera 0 together with camera 4.
Dynamic configuration of the VC IDs would solve that usecase since it would assign VC IDs based on the routed streams.
v4l2_subdev_pad_ops has a .set_frame_desc() that could be used to apply an updated v4l2_mbus_frame_desc, after retrieving it using .get_frame_desc(). Cameras that don't support VC ID remapping would just modify the v4l2_mbus_frame_desc to restore the VC ID to the original one (similar to how set_fmt() can modify the passed in format to what it supports) and the caller would have to handle that situation how it sees fit.
Does that sound better than sticking the VC ID in device tree?
Quoted 48 lines
Quoted 17 lines
Add support for specifying these Virtual Channel IDs in Video Interface Endpoints. The supported values are 0 to 3, with a maximum of 4 values. Although the CSI-2 specification allows for up to 32 virtual channels, most hardware doesn't support more than 4. This can be extended later if need be.
Signed-off-by Cosmin Tanislav <[email protected]>--- .../devicetree/bindings/media/video-interfaces.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+)Documentation/devicetree/bindings/media/video-interfaces.yaml +0
-0Documentation/devicetree/bindings/media/video-interfaces.yaml properties: · line 234
Quoted 4 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +1
-0@@ -231,6 +231,17 @@ properties: shall be interpreted as 0 (ABC). This property is valid for CSI-2 C-PHY busses only. + vc-ids:Other properties aren't using abbreviations, at least most of them. How about "virtual-channels"?
Documentation/devicetree/bindings/media/video-interfaces.yaml properties: · line 237
Quoted 3 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +3
-0+ $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 1 + maxItems: 4Shouldn't this be 32?
Documentation/devicetree/bindings/media/video-interfaces.yaml properties: · line 239
Quoted 2 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +2
-0+ items: + maximum: 331 here, too.
Documentation/devicetree/bindings/media/video-interfaces.yaml properties: · line 241
Quoted 2 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +2
-0+ description: + An array of Virtual Channel IDs. These are unsigned integers that specifyI'd leave out the explanation on the data type. It's redundant.
Quoted 6 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +3
-0+ the VC IDs used by the device for its data streams. This property is valid + for MIPI CSI-2 only. + strobe: $ref: /schemas/types.yaml#/definitions/uint32 enum: [ 0, 1 ]
Re: [PATCH v2 1/6] dt-bindings: media: video-interfaces: add support for Virtual Channel IDs
Hi Cosmin,
Quoted 46 lines · Cosmin Tanislav
Quoted 12 lines · Sakari Ailus
Quoted 11 lines · Cosmin Tanislav
Multi-camera systems often have issues with receiving video streams from multiple cameras at the same time because the cameras use the same Virtual Channel IDs.
CSI bridges might not support remapping the Virtual Channel IDs, making it impossible to receive the separate video streams at the same time, while the CSI receiver is able to de-mux streams based on VC IDs.
Cameras sometimes have support for changing the VC IDs they output themselves.
Quoted 8 lines
Quoted 4 lines
For a practical example, GMSL2 deserializer chips do not support VC ID remapping in tunnel mode, and neither do the serializers. Allowing the cameras to have their VC IDs configured would allow multi-camera setups to use tunnel mode.
We've tried to avoid having virtual channels in firmware and in UAPI, I'm not yet entirely convinced we need to depart from the established practices. Let's see. Apart from that, please see my comments below.
Can you think if any other way of handling this? The most useful way would be to have it accessible at runtime so that devices upstream of the cameras could assign the VC IDs dynamically.
This would be useful when having more cameras than the maximum supported number of VC IDs (4, without extended VC IDs), and streaming from them selectively.
For example, for 8 cameras, you'd have to prepare your VC IDs in advance to fit the streaming selection you want to make. If the cameras 0 to 7 have the VC IDs 0, 1, 2, 3, 0, 1, 2, 3, you wouldn't be able to stream camera 0 together with camera 4.
Dynamic configuration of the VC IDs would solve that usecase since it would assign VC IDs based on the routed streams.
v4l2_subdev_pad_opshas a .set_frame_desc() that could be used to apply an updatedv4l2_mbus_frame_desc, after retrieving it using .get_frame_desc(). Cameras that don't support VC ID remapping would just modify thev4l2_mbus_frame_descto restore the VC ID to the original one (similar to howset_fmt()can modify the passed in format to what it supports) and the caller would have to handle that situation how it sees fit.
Quoted 1 line
Does that sound better than sticking the VC ID in device tree?
I think a VC allocator would be very interesting development. It's probably a bit more complex than hardcoding the information in DT, but it would also be much nicer :-) I haven't really thought about how this could be implemented though, but I'd be happy to discuss it.
The timing is slightly unfortunate, as I'll be travelling on weeks 11 and 12 and will have limited time then, but I'm sure Sakari and Tomi can also provide guidelines.
Quoted 46 lines
Quoted 46 lines
Quoted 16 lines
Add support for specifying these Virtual Channel IDs in Video Interface Endpoints. The supported values are 0 to 3, with a maximum of 4 values. Although the CSI-2 specification allows for up to 32 virtual channels, most hardware doesn't support more than 4. This can be extended later if need be.
Signed-off-by Cosmin Tanislav <[email protected]>--- .../devicetree/bindings/media/video-interfaces.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+)Documentation/devicetree/bindings/media/video-interfaces.yaml +0
-0Documentation/devicetree/bindings/media/video-interfaces.yaml properties: · line 234
Quoted 4 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +1
-0@@ -231,6 +231,17 @@ properties: shall be interpreted as 0 (ABC). This property is valid for CSI-2 C-PHY busses only. + vc-ids:Other properties aren't using abbreviations, at least most of them. How about "virtual-channels"?
Documentation/devicetree/bindings/media/video-interfaces.yaml properties: · line 237
Quoted 3 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +3
-0+ $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 1 + maxItems: 4Shouldn't this be 32?
Documentation/devicetree/bindings/media/video-interfaces.yaml properties: · line 239
Quoted 2 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +2
-0+ items: + maximum: 331 here, too.
Documentation/devicetree/bindings/media/video-interfaces.yaml properties: · line 241
Quoted 2 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +2
-0+ description: + An array of Virtual Channel IDs. These are unsigned integers that specifyI'd leave out the explanation on the data type. It's redundant.
Quoted 6 lines
Documentation/devicetree/bindings/media/video-interfaces.yaml +3
-0+ the VC IDs used by the device for its data streams. This property is valid + for MIPI CSI-2 only. + strobe: $ref: /schemas/types.yaml#/definitions/uint32 enum: [ 0, 1 ]
Signature · 3 lines
Regards, Laurent Pinchart
PATCH v2 2/6 media: v4l: fwnode: parse Virtual Channel IDs for CSI2 buses
In reply to Cosmin TanislavMulti-camera systems often have issues with receiving video streams from multiple cameras at the same time because the cameras use the same Virtual Channel IDs.
CSI bridges might not support remapping the Virtual Channel IDs, making it impossible to receive the separate video streams at the same time, while the CSI receiver is able to de-mux streams based on VC IDs.
Cameras sometimes have support for changing the VC IDs they output themselves.
For a practical example, GMSL2 deserializer chips do not support VC ID remapping in tunnel mode, and neither do the serializers. Allowing the cameras to have their VC IDs configured would allow multi-camera setups to use tunnel mode.
Add support for parsing VC IDs in v4l2_fwnode_endpoint_parse(). This allows us to retrieve the specified VC IDs in camera drivers and configure the hardware to use them.
The supported values are 0 to 3, with a maximum of 4 values. Although the CSI-2 specification allows for up to 32 virtual channels, most hardware doesn't support more than 4. This can be extended later if need be.
The driver must validate the number of VC IDs and the VC IDs themselves.
--- drivers/media/v4l2-core/v4l2-fwnode.c | 15 +++++++++++++++ include/media/v4l2-mediabus.h | 5 +++++ 2 files changed, 20 insertions(+)
drivers/media/v4l2-core/v4l2-fwnode.c +15 -0
@@ -129,8 +129,10 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,bool have_clk_lane = false, have_data_lanes = false, have_lane_polarities = false, have_line_orders = false;unsigned int flags =0 , lanes_used =0 ; +u32 vc_ids_array[V4L2_MBUS_CSI2_MAX_VC_IDS ];u32 array[1 +V4L2_MBUS_CSI2_MAX_DATA_LANES ];u32 clock_lane =0 ; +unsigned int num_vc_ids =0 ;unsigned int num_data_lanes =0 ;bool use_default_lane_mapping = false;unsigned int i;
@@ -208,6 +210,15 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, have_line_orders = true; } + rval =fwnode_property_count_u32 (fwnode,"vc-ids" ); +if (rval >0 ) { + num_vc_ids = + min_t(unsigned int, V4L2_MBUS_CSI2_MAX_VC_IDS, rval); + +fwnode_property_read_u32_array (fwnode,"vc-ids" , vc_ids_array, + num_vc_ids); + } +if (!fwnode_property_read_u32 (fwnode,"clock-lanes" , &v)) { clock_lane = v;pr_debug ("clock lane position %u\n" , v);
@@ -248,6 +259,10 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, bus->data_lanes[i] = array[i]; } + bus->num_vc_ids = num_vc_ids; +for (i =0 ; i < num_vc_ids; i++) + bus->vc_ids[i] = vc_ids_array[i]; +if (have_lane_polarities) { fwnode_property_read_u32_array(fwnode, "lane-polarities", array,
include/media/v4l2-mediabus.h +5 -0
@@ -72,6 +72,7 @@#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK BIT(0)#define V4L2_MBUS_CSI2_MAX_DATA_LANES 8 +#define V4L2_MBUS_CSI2_MAX_VC_IDS 4/** * enum v4l2_mbus_csi2_cphy_line_orders_type - CSI-2 C-PHY line order
@@ -94,8 +95,10 @@ enum v4l2_mbus_csi2_cphy_line_orders_type {/** * struct v4l2_mbus_config_mipi_csi2 - MIPI CSI-2 data bus configuration * @flags: media bus (V4L2_MBUS_*) flags +* @vc_ids: an array of Virtual Channel IDs * @data_lanes: an array of physical data lane indexes * @clock_lane: physical lane index of the clock lane +* @num_vc_ids: number of Virtual Channel IDs * @num_data_lanes: number of data lanes * @lane_polarities: polarity of the lanes. The order is the same of * the physical lanes.
@@ -104,8 +107,10 @@ enum v4l2_mbus_csi2_cphy_line_orders_type {*/ struct v4l2_mbus_config_mipi_csi2 {unsigned int flags; +unsigned char vc_ids[V4L2_MBUS_CSI2_MAX_VC_IDS ];unsigned char data_lanes[V4L2_MBUS_CSI2_MAX_DATA_LANES ];unsigned char clock_lane; +unsigned char num_vc_ids;unsigned char num_data_lanes;bool lane_polarities[1 +V4L2_MBUS_CSI2_MAX_DATA_LANES ];enum v4l2_mbus_csi2_cphy_line_orders_type line_orders[V4L2_MBUS_CSI2_MAX_DATA_LANES ];
Signature · 1 line
2.48.1
PATCH v2 3/6 dt-bindings: media: imx219: add support for Virtual Channel IDs
In reply to Cosmin TanislavIMX219 supports configuring the Virtual Channel ID used for image and embedded data streams.
--- Documentation/devicetree/bindings/media/i2c/imx219.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/media/i2c/imx219.yaml +2 -0
@@ -66,6 +66,8 @@ properties: clock-noncontinuous: true link-frequencies: true + vc-ids: + maxItems: 1 required: - link-frequencies
Signature · 1 line
2.48.1
PATCH v2 4/6 media: i2c: imx219: pass format's code to imx219_get_format_bpp()
In reply to Cosmin Tanislavimx219_get_format_bpp() only uses the code of the format, pass it instead of the whole format to allow usage when the whole format is not available.
--- drivers/media/i2c/imx219.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/i2c/imx219.c +3 -3
@@ -387,9 +387,9 @@ static u32 imx219_get_format_code(struct imx219 *imx219, u32 code)return imx219_mbus_formats[i]; } -static u32 imx219_get_format_bpp (const struct v4l2_mbus_framefmt *format) +static u32 imx219_get_format_bpp (u32 code) { -switch (format->code) { +switch (code) {case MEDIA_BUS_FMT_SRGGB8_1X8 :case MEDIA_BUS_FMT_SGRBG8_1X8 :case MEDIA_BUS_FMT_SGBRG8_1X8 :
@@ -680,7 +680,7 @@ static int imx219_set_framefmt(struct imx219 *imx219, format =v4l2_subdev_state_get_format (state,0 ); crop =v4l2_subdev_state_get_crop (state,0 ); - bpp =imx219_get_format_bpp (format); + bpp =imx219_get_format_bpp (format->code);cci_write (imx219->regmap,IMX219_REG_X_ADD_STA_A , crop->left -IMX219_PIXEL_ARRAY_LEFT , &ret);
Signature · 1 line
2.48.1
Re: [PATCH v2 4/6] media: i2c: imx219: pass format's code to imx219_get_format_bpp()
Hi Cosmin,
Thanks for the patch.
Quoted 5 lines · Cosmin Tanislav
imx219_get_format_bpp()only uses the code of the format, pass it instead of the whole format to allow usage when the whole format is not available.Signed-off-by Cosmin Tanislav <[email protected]>
Quoted 32 lines
--- drivers/media/i2c/imx219.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/media/i2c/imx219.c +3
-3@@ -387,9 +387,9 @@ static u32 imx219_get_format_code(struct imx219 *imx219, u32 code)return imx219_mbus_formats[i]; } -static u32 imx219_get_format_bpp (const struct v4l2_mbus_framefmt *format) +static u32 imx219_get_format_bpp (u32 code) { -switch (format->code) { +switch (code) {case MEDIA_BUS_FMT_SRGGB8_1X8 :case MEDIA_BUS_FMT_SGRBG8_1X8 :case MEDIA_BUS_FMT_SGBRG8_1X8 :@@ -680,7 +680,7 @@ static int imx219_set_framefmt(struct imx219 *imx219, format =v4l2_subdev_state_get_format (state,0 ); crop =v4l2_subdev_state_get_crop (state,0 ); - bpp =imx219_get_format_bpp (format); + bpp =imx219_get_format_bpp (format->code);cci_write (imx219->regmap,IMX219_REG_X_ADD_STA_A , crop->left -IMX219_PIXEL_ARRAY_LEFT , &ret);Signature · 1 line
2.48.1
Signature · 2 lines
Thanks, Jai
PATCH v2 5/6 media: i2c: imx219: Report streams using frame descriptors
In reply to Cosmin TanislavFrom: Laurent Pinchart <[email protected]>
Implement the .get_frame_desc() subdev operation to report information about streams to the connected CSI-2 receiver. This is required to let the CSI-2 receiver driver know about virtual channels and data types for each stream.
--- drivers/media/i2c/imx219.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/media/i2c/imx219.c +24 -0
@@ -23,6 +23,7 @@#include <linux/pm_runtime.h> #include <linux/regulator/consumer.h> +#include <media/mipi-csi2.h> #include <media/v4l2-cci.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h>
@@ -990,6 +991,28 @@ static int imx219_init_state(struct v4l2_subdev *sd,return 0 ; } +static int imx219_get_frame_desc (struct v4l2_subdev *sd,unsigned int pad, +struct v4l2_mbus_frame_desc *fd) +{ +struct v4l2_subdev_state *state; +u32 code; + + state =v4l2_subdev_lock_and_get_active_state (sd); + code =v4l2_subdev_state_get_format (state,0 )->code; +v4l2_subdev_unlock_state (state); + + fd->type =V4L2_MBUS_FRAME_DESC_TYPE_CSI2 ; + fd->num_entries =1 ; + + fd->entry[0 ].pixelcode = code; + fd->entry[0 ].stream =0 ; + fd->entry[0 ].bus.csi2.vc =0 ; + fd->entry[0 ].bus.csi2.dt =imx219_get_format_bpp (code) ==8 + ?MIPI_CSI2_DT_RAW8 :MIPI_CSI2_DT_RAW10 ; + +return 0 ; +} +static const struct v4l2_subdev_video_ops imx219_video_ops = { .s_stream = imx219_set_stream, };
@@ -1000,6 +1023,7 @@ static const struct v4l2_subdev_pad_ops imx219_pad_ops = { .set_fmt = imx219_set_pad_format, .get_selection = imx219_get_selection, .enum_frame_size = imx219_enum_frame_size, + .get_frame_desc = imx219_get_frame_desc, };static const struct v4l2_subdev_ops imx219_subdev_ops = {
Signature · 1 line
2.48.1
Sakari Ailus
maintainerRe: [PATCH v2 5/6] media: i2c: imx219: Report streams using frame descriptors
Hi Cosmin,
Quoted 8 lines · Cosmin Tanislav
From: Laurent Pinchart <[email protected]>
Implement the .get_frame_desc() subdev operation to report information about streams to the connected CSI-2 receiver. This is required to let the CSI-2 receiver driver know about virtual channels and data types for each stream.
Signed-off-by Laurent Pinchart <[email protected]>
In addition to this, the idea has been that the set_frame_desc() could be used to set aspects of the frame descriptor. My thinking has been that you could modify the entries, up to the degree supported by the driver, but not add or remove them. This should be properly documented in v4l2-subdev.h.
Signature · 3 lines
Regards, Sakari Ailus
PATCH v2 6/6 media: i2c: imx219: implement configurable VC ID
In reply to Cosmin TanislavIMX219 supports configuring the Virtual Channel ID used for image and embedded data streams.
--- drivers/media/i2c/imx219.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/media/i2c/imx219.c +27 -1
@@ -38,6 +38,8 @@#define IMX219_MODE_STANDBY 0x00#define IMX219_MODE_STREAMING 0x01 +#define IMX219_REG_CSI_CH_ID CCI_REG8(0x0110) +#define IMX219_REG_CSI_LANE_MODE CCI_REG8(0x0114)#define IMX219_CSI_2_LANE_MODE 0x01#define IMX219_CSI_4_LANE_MODE 0x03
@@ -363,6 +365,9 @@ struct imx219 {/* Two or Four lanes */ u8 lanes; + +/* Virtual channel ID */ +u8 vc_id; };static inline struct imx219 *to_imx219 (struct v4l2_subdev *_sd)
@@ -724,6 +729,12 @@ static int imx219_configure_lanes(struct imx219 *imx219) ARRAY_SIZE(imx219_4lane_regs), NULL); }; +static int imx219_configure_vc (struct imx219 *imx219) +{ +return cci_write (imx219->regmap,IMX219_REG_CSI_CH_ID , + imx219->vc_id,NULL ); +} +static int imx219_start_streaming (struct imx219 *imx219,struct v4l2_subdev_state *state) {
@@ -749,6 +760,13 @@ static int imx219_start_streaming(struct imx219 *imx219, goto err_rpm_put; } +/* Configure Virtual Channel ID */ + ret =imx219_configure_vc (imx219); +if (ret) { +dev_err (&client->dev,"%s failed to configure vc\n" , __func__); + goto err_rpm_put; + } +/* Apply format and crop settings. */ ret =imx219_set_framefmt (imx219, state);if (ret) {
@@ -994,6 +1012,7 @@ static int imx219_init_state(struct v4l2_subdev *sd,static int imx219_get_frame_desc (struct v4l2_subdev *sd,unsigned int pad,struct v4l2_mbus_frame_desc *fd) { +struct imx219 *imx219 =to_imx219 (sd);struct v4l2_subdev_state *state;u32 code;
@@ -1006,7 +1025,7 @@ static int imx219_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, fd->entry[0 ].pixelcode = code; fd->entry[0 ].stream =0 ; - fd->entry[0 ].bus.csi2.vc =0 ; + fd->entry[0 ].bus.csi2.vc = imx219->vc_id; fd->entry[0 ].bus.csi2.dt =imx219_get_format_bpp (code) ==8 ?MIPI_CSI2_DT_RAW8 :MIPI_CSI2_DT_RAW10 ;
@@ -1149,6 +1168,13 @@ static int imx219_check_hwcfg(struct device *dev, struct imx219 *imx219) } imx219->lanes = ep_cfg.bus.mipi_csi2.num_data_lanes; +if (ep_cfg.bus.mipi_csi2.num_vc_ids >1 ) { +dev_err_probe (dev, -EINVAL , +"only 1 virtual channel id is supported\n" ); + goto error_out; + } + imx219->vc_id = ep_cfg.bus.mipi_csi2.vc_ids[0 ]; +/* Check the link frequency set in device tree */ switch (imx219->lanes) {case 2 :
Signature · 1 line
2.48.1