How to set lane polarity for CAM0

I’m trying to make my ADV7282-m work with Jetson Orin nano Dev kit (with nvidia carrier board)

I have this device tree, that is working on CAM1, but it doesn’t work on CAM0, as CAM0 has swapped CSI1_D0 lanes (which i use as single data lane).

I managed get CAM0 working with hardware lane swap on ADV board side, but i need help to swap those lanes in device tree.

I have tried setting lane_polarity with different values, but it has no effect. May be i’m missing something?

Any help setting lane polarity via device tree is appreciated.

dual_camera-device_tree.txt (4.9 KB)

*** Please note that this reply is generated by LLM automatically ***

To address the issue of swapping CSI1D0 lanes on CAM0 for the ADV7282m device to work with the Jetson Orin Nano Dev kit and NVIDIA carrier board, we need to delve into the device tree configuration.

The device tree is a data structure that describes the hardware components of a system, including the CSI (Camera Serial Interface) lanes. In your case, you’re experiencing issues with CAM0 due to the swapped CSI1D0 lanes.

To swap the lanes in the device tree, you’ll need to modify the lanepolarity property. However, as you’ve mentioned, setting lanepolarity with different values hasn’t had the desired effect.

Let’s take a closer look at the lanepolarity property and its possible values:

  • lanepolarity is a property that defines the polarity of the CSI lanes.
  • The possible values for lanepolarity are:
    • normal (default): The CSI lanes are not inverted.
    • inverted: The CSI lanes are inverted.

To swap the CSI1D0 lanes, you’ll need to set the lanepolarity property to inverted for the specific lane. However, since you’ve already tried setting lanepolarity with different values without success, it’s possible that the issue lies elsewhere.

Here are a few potential solutions you can try:

  1. Verify the device tree syntax: Ensure that the device tree syntax is correct and that the lanepolarity property is properly defined.
  2. Check the CSI lane configuration: Verify that the CSI lane configuration is correct and that the lanes are properly connected to the ADV7282m device.
  3. Use the csi-lane-swap property: Instead of using lanepolarity, try using the csi-lane-swap property to swap the CSI lanes. This property is specific to the NVIDIA Tegra platform and allows you to swap the CSI lanes.
  4. Consult the NVIDIA documentation: Refer to the NVIDIA documentation for the Jetson Orin Nano and NVIDIA carrier board to ensure that you’re using the correct device tree properties and syntax.

To provide a more comprehensive solution, I’d like to compare the device tree configuration for CAM0 and CAM1. Could you please provide the device tree configuration for both CAM0 and CAM1, including the lanepolarity property and any other relevant configuration options?

Additionally, have you tried using the csi-lane-swap property to swap the CSI lanes? If so, what were the results?

By comparing the device tree configurations and exploring alternative solutions, we can work together to resolve the issue and get the ADV7282m device working with the Jetson Orin Nano Dev kit and NVIDIA carrier board.

*** Please give the thumbs up if you get answers you like. Or provide feedback to help us improve the answer. ***

Hi K3nz032,

Changing the polarity is done the mode section of the device tree, next to where you would define the number of lanes.

bus@0 {
  /*...*/
			adv7282m_j20: adv7282-m@21 {
                /* ... */
					active_w = "720";
					active_h = "576";
					pixel_t = "yuv_uyvy16";
					num_lanes = "1";
					discontinuous_clk = "yes";
					cil_settletime = "0";
					lane_polarity = "0"; /* No Swapping */
                    
                    /* ... */
				};

Also take note that the default for working would be to have this on “6" per this.

hello k3nz032,

please see-also reference driver for more details.
for instance,
$public_sources/kernel_src/hardware/nvidia/t23x/nv-public/overlay/tegra234-p3767-camera-p3768-imx477-A.dts

* lane_polarity
* Based on the camera connector pin.
* CSIx_D0 | CSIx_D1 | CSI(X+1)_D0 | CSI(X+1)CSIx_D1
*    LSB  |   BIT1  |     BIT2    |      MSB
* if there is a polarity swap on any lane, the bit corrsponding
* to the lane should be set
* e.g. polarity swap on CSIx_D0 only -> lane_polarity = "1"; 0001
* e.g. polarity swap on CSIx_D1 and CSI(X+1)_D0 -> lane_polarity = "6"; 0110

@JerryChang @emmanuel.madrigal Thx 4 replies, but I have already tried to apply lane_polarity and this has no effect at all at my setup. I will try to provide more info:

As i have hardware swap to make my setup work on CAM0 (pin 20 and 21 are swapped on ADV board) i’m testing software changes on CAM1, i assume software swap will rollback the hardware one

so my current tree looks like this for CAM1 port

/* chan_id 1 == Linux i2c-9 == physical J21 */
i2c@1 {
    status = "okay";
    reg = <1>;
    #address-cells = <1>;
    #size-cells = <0>;

    rbpcv2_imx219_a@10 {
       status = "disabled";
    };

    adv7282m_j21: adv7282-m@21 {
       compatible = "adi,adv7282-m";
       reg = <0x21>;
       devnode = "video1";
       physical_w = "3.680";
       physical_h = "2.760";
       sensor_model = "adv7282-m";
       use_sensor_mode_id = "true";
       active_w = "720";
       active_h = "576";
       pixel_t = "yuv_uyvy16";
       num_lanes = "1";
       discontinuous_clk = "yes";
       cil_settletime = "0";
       lane_polarity = "1";  <---- i tried using different bitmask from 0 to 6
       ports {
          #address-cells = <1>;
          #size-cells = <0>;
          port@0 {
             reg = <0>;
             adv_out_j21: endpoint@1 {
                status = "okay";
                port-index = <2>;
                bus-width = <1>;
                remote-endpoint = <&csi_in_j21>;
             };
          };
       };
    };
};

I use this driver linux/drivers/media/i2c/adv7180.c at master · torvalds/linux · GitHub

Jetsonpack 6.2

Still, polarity changes have no effect, as i see my device is detected, but i have no video stream. Any chance lane_polarity option is skipped? Or any advice how to debug it?

hello k3nz032,

it looks you don’t have tegra_sinterface in the sensor nodes?
please refer to developer guide, Property-Value Pairs, also the reference driver to update your sensor device tree.

besides, please also follow the steps below to enable VI tracing logs.
it’ll show more details of frame packet status.

modprobe rtcpu_debug
echo 1 > /sys/kernel/debug/tracing/tracing_on
echo 30720 > /sys/kernel/debug/tracing/buffer_size_kb
echo 1 > /sys/kernel/debug/tracing/events/tegra_rtcpu/enable
echo 1 > /sys/kernel/debug/tracing/events/freertos/enable
echo 2 > /sys/kernel/debug/camrtc/log-level
echo > /sys/kernel/debug/tracing/trace
cat /sys/kernel/debug/tracing/trace