L4T R28.3 Dynamic change of csi lane number

Hi all,

Is it possible to change, on the fly, the number of csi input lanes used?

Use case example:
Step 1- TX2 acquiring 1920x1080p25 video over 2-lane MIPI CSI.
Step 2- User send command to change input resolution acquisition to NTSC(720x480i60).
Step 3- TX2 reconfiguring itself (kernel driver or user space command) to aquire 720x480i60 video 1-lane MIPI CSI.

For 1920x1080p25 2-lane input, the csi configuration is set in device-tree like this:

host1x {
    vi@15700000 {
        num-channels = <1>;
        ports {
            #address-cells = <1>;
            #size-cells = <0>;
            port@0 {
                status = "okay";
                reg = <0>;
                csiconv_vi_in0: endpoint {
                    status = "okay";
                    csi-port = <0>;
                    bus-width = <2>;
                    remote-endpoint = <&csiconv_csi_out0>;
                };
            };
        };
    };

    nvcsi@150c0000 {
        num-channels = <2>;
        #address-cells = <1>;
        #size-cells = <0>;
        channel@0 {
            status = "okay";
            reg = <0>;
            ports {
                #address-cells = <1>;
                #size-cells = <0>;
                port@0 {
                    status = "okay";
                    reg = <0>;
                    csiconv_csi_in0: endpoint@0 {
                        status = "okay";
                        csi-port = <0>;
                        bus-width = <2>;
                        remote-endpoint = <&csiconv_out0>;
                    };
                };
                port@1 {
                    status = "okay";
                    reg = <1>;
                    csiconv_csi_out0: endpoint@1 {
                        status = "okay";
                        remote-endpoint = <&csiconv_vi_in0>;
                    };
                };
            };
        };
    };
};

...

i2c@3180000 {
    status = "okay";

    #address-cells = <1>;
    #size-cells = <0>;

    /* First input */
    csiconv@70 {
        status = "okay";
        compatible = "csiconv";
        reg = <0x70>;
        devnode = "video0";

        ...

        mode0 {
            num_lanes = "2";
            discontinuous_clk = "no";
            dpcm_enable = "false";
            cil_settletime = "0";
            dynamic_pixel_bit_depth = "16";
            csi_pixel_bit_depth = "16";
            mode_type = "yuv";
            pixel_phase = "uyvy";

            active_w = "1920";
            active_h = "1080";
            readout_orientation = "0";
            line_length = "2200";

            embedded_metadata_height = "0";
        };

        ports {
            #address-cells = <1>;
            #size-cells = <0>;

            port@0 {
                reg = <0>;
                csiconv_out0: endpoint {
                    csi-port = <0>;
                    bus-width = <2>;
                    remote-endpoint = <&csiconv_csi_in0>;
                };
            };
        };
    };
};

...

tcp: tegra-camera-platform {
    status = "okay";
    compatible = "nvidia, tegra-camera-platform";

    num_csi_lanes = <12>;
    max_lane_speed = <1500000>;
    min_bits_per_pixel = <8>;
    vi_peak_byte_per_pixel = <2>;
    vi_bw_margin_pct = <25>;
    max_pixel_rate = <408000>;
    isp_peak_byte_per_pixel = <2>;
    isp_bw_margin_pct = <25>;
    
    modules {
        module0 {
            status = "okay";
            badge = "csiconv_left_1111";
            position = "rear";
            orientation = "1";
            drivernode0 {
                status = "okay";
                /* Declare PCL support driver (classically known as guid)  */
                pcl_id = "v4l2_sensor";
                /* Driver's v4l2 device name */
                devname = "csiconv 2-0070";
                /* Declare the device-tree hierarchy to driver instance */
                proc-device-tree = "/proc/device-tree/i2c@3180000/csiconv_ef@70";
            };
        };
    };
};

I have looked different drivers/device-tree with several modes (mode0, mode1, etc.) but each mode have same number of lane.

From the device side, I have already implement methods to switch between 1, 2 and 4 lanes configuration.

My problem/question is about the capability of TX2 to reconfigure the lane number.
Q1 - First of all, is it possible?

Q2 - Is there an example? What is the tasks sequencing (reset DPHY, then NVCSI, etc.)?

Q3 - I think I should reconfigure or reset NVCSI and VI with the new parameters. How can I achieve this?

Q4 - How to send new parameters to NVCSI and VI?

Thanks

PS: It’s acceptable to have a video interruption during reconfiguration but I want to avoid TX2 restarting.

FYI, the device which generate MIPI CSI for TX2 isn’t able to generate 720x480i60 using 2-lane CSI (MIPI Clock is too slow for it).
That’s why I try to ‘dynamically’ change the number of CSI lane.

Sorry to tell don’t support dynamic lanes configure.
Why just use 4 lanes for all resolution?

Hi ShaneCCC,

Thanks for your answer.

As exposed in post #2, the device which generate MIPI CSI-2 data can’t generate data stream over 2 or 4 lanes for 720x480i60 because the mipi clock is too slow for the internal PLL (~54MHz).

In fact, it’s not a camera sensor, it’s an ADV748x.

I use it to grab two kind of video sources: (not at the same time, but alternately)

  • high definition digital video (1920x1080p25/30)
  • standard definition analog video (720x480i60)

Q1 - If I set 4-lanes in Device-Tree all the time, not depending which video input it is. What happens if the device send data only over 1 or 2 lanes? Is NVCSI able to catch and produce valid data to VI anyway?

Q2 - Is it possible to reset manually NVCSI and VI?

If the lanes number depend on the resolution you can try to modify the num_lanes in the modeX,
The NVCSI driver will load different mode(resolution) configure dynamically.

AurelienV, were you able to use mode in the dtsi to get it to switch lane count for different resolutions?