How to support a MIPI camera with both 8 and 16 bit formats (2 and 4 lanes) with a single device tree

Using a custom MIPI camera that supports both 8 bit and 16 bit per pixel imaging. The 16 bit format needs 4 MIPI lanes while the 8 bit format only needs two. I can capture both formats by using different device trees because I needed to set “bus-width” to 4 for 4 lanes and to 2 for 2 lanes. Is there a way to have a single device tree that can support both the 8 bit and 16 bit per pixel formats (i.e., either programmatically via the camera driver or by somehow confining the format differences to the sensor “modes”)?

hello james.basso,

it should be possible by defining those 2-lane/4-lane settings within different sensor modes.
you should also adding use_sensor_mode_id device tree property, please refer to developer guide, Device Properties.
here’s an example of mode selection.
$ v4l2-ctl -d /dev/video0 --set-fmt-video=width=1280,height=720,pixelformat=RG10 --set-ctrl bypass_mode=0 --set-ctrl sensor_mode=4 --stream-mmap --stream-count=100

The port definitions all have a definition of “bus-width” that is not sensor-mode-specific. I need to set “bus-width” to 4 to get 4-lanes, 16 bit to work. However, if I leave the “bus-width” = 4 then 8 bit doesn’t work (even if I change the num lanes and bit depth in modes)

For example:

                        tegra-capture-vi  {
                                num-channels = <2>;
                                ports {
                                        #address-cells = <1>;
                                        #size-cells = <0>;
                                        vi_port0: port@0 {
                                                reg = <0>;
                                                custom_cam_vi_in0: endpoint {
                                                        port-index = <1>;
                                                        bus-width = <4>;
                                                        remote-endpoint = <&custom_cam_csi_out0>;
                                                };
                                        };

                                        port@1 {
                                                reg = <1>;
                                                custom_cam_vi_in1: endpoint {
                                                        port-index = <2>;
                                                        bus-width = <4>;
                                                        remote-endpoint = <&custom_cam_csi_out1>;
                                                };
                                        };
                                };
                        };

hello james.basso,

you may revise the 8 bit format as 4-lane setting by lower the pixel clock rate.

Unfortunately our camera only uses 2 lanes when in 8 bit pixel mode

hello james.basso,

camera software stack loads the device tree settings to initialize camera.
currently, it doesn’t support same camera device with different lane configuration.

Could you point me to the code that uses the “bus-width” (i.e., number of lanes). Maybe I can override the dev-tree on the fly?

hello james.basso,

you may refer to below for sending numlanes to camera software stack,
$public_sources/kernel_src/kernel/nvidia/drivers/media/platform/tegra/camera/camera_common.c

int camera_common_parse_ports(..)
{
        err = of_property_read_u32(ep, "bus-width", &bus_width);
        s_data->numlanes = bus_width;

Thanks Jerry. I will take a look but I will need to find the CSI register that actually uses this to make sure it gets updated. Do you know which register it is? Is it NVCSI_PHY__NVCSI_CIL_CONFIG_0?

hello james.basso,

yes.

or,
may I double check which L4T version you’re using?
you may refer to Topic 285027, which shared debug version rce-fw on JP-5.1.1/r35.3.1
it reports NVCSI stream configuration upon running with debug version rce-fw.

Thanks Jerry, We are using r36.3

hello james.basso,

here’s debug version rce-fw of JP-6.0/r36.3, Topic308937_Oct18.zip (249.8 KB).

you may follow that previous mentioned topic, Topic 285027 for the update steps on AGX Orin.
if you’re based-on Orin NX/Orin Nano series, please check Topic 260583 for steps to execute with l4t_initrd_flash.sh for replacing the camera debug firmware.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.