nvcamerasrc sensor-id=1 or sensor-id=0 give the same images

I have two imx264 connected to our custom board using spi, named “imx264 spi0.0” and “imx264 spi1.0”. The first one is connected to /dev/video0, the second one to /dev/video1. I can verify using standard v4l2 commands like v4l2-ctl or v4l2src that I get different images on /dev/video0 and /dev/video1. I have described them in the dt as follows :

tegra-camera-platform {
  compatible = "nvidia, tegra-camera-platform";
  num_csi_lanes = <8>;
  max_lane_speed = <1500000>;
  min_bits_per_pixel = <12>;
  vi_peak_byte_per_pixel = <2>;
  vi_bw_margin_pct = <25>;
  max_pixel_rate = <1500000>;
  isp_peak_byte_per_pixel = <2>;
  isp_bw_margin_pct = <25>;

  modules {
   module0 {
    badge = "imx264_left_2174";
    position = "left";
    orientation = "1";
    drivernode0 {
     pcl_id = "v4l2_sensor";
     devname = "imx264 spi0.0";
     proc-device-tree = "/proc/device-tree/spi@7000d400/imx264@0";
    };
   };

   module1 {
    badge = "imx264_right_2176";
    position = "right";
    orientation = "1";
    drivernode0 {
     pcl_id = "v4l2_sensor";
     devname = "imx264 spi1.0";
     proc-device-tree = "/proc/device-tree/spi@7000d600/imx264@0";
    };
   };
  };
 };

Unfortunately, when I use nvcamerasrc with sensor-id=0 or sensor-id=1 it always uses the sensor bound to /dev/video0, never the one connected to /dev/video1. And if I use “sensor-id=2”, nvcamera-daemon crashes.

How does nvcamera-daemon/nvcamerasrc decide which sensor is “sensor-id=0” and which one is “sensor-id=1”. Which entries does it look at in the dt ?

hello phdm,

please update the camera-facing information in your sensor device tree.
please refer to [Sensor Driver Programming Guide] in the [L4T Documentation] and please read the [Module Properties] session for the position property.
thanks

I read there ‘The positions supported depends on the number of cameras in the system:
Two-camera system: rear and front’

Does that mean that I cannot choose freely that part of the ‘badge’ property or the ‘position’ property and that I must name them ‘rear’ and ‘front’ even if that does not match a physical reality ?

hello phdm,

yes, please have corresponding camera-facing information for your multiple cameras definitions.
thanks

Thank you, JerryChang,

I have set the ‘position’ properties to “rear” and “front”

tegra-camera-platform {
  compatible = "nvidia, tegra-camera-platform";
  num_csi_lanes = <8>;
  max_lane_speed = <1500000>;
  min_bits_per_pixel = <12>;
  vi_peak_byte_per_pixel = <2>;
  vi_bw_margin_pct = <25>;
  max_pixel_rate = <1500000>;
  isp_peak_byte_per_pixel = <2>;
  isp_bw_margin_pct = <25>;

  modules {
   module0 {
    badge = "imx264_left_2174";
    position = "rear";
    orientation = "1";
    drivernode0 {
     pcl_id = "v4l2_sensor";
     devname = "imx264 spi0.0";
     proc-device-tree = "/proc/device-tree/spi@7000d400/imx264@0";
    };
   };

   module1 {
    badge = "imx264_right_2176";
    position = "front";
    orientation = "1";
    drivernode0 {
     pcl_id = "v4l2_sensor";
     devname = "imx264 spi1.0";
     proc-device-tree = "/proc/device-tree/spi@7000d600/imx264@0";
    };
   };
  };
 };

Now, sensor-id works to select my sensors : sensor-id=0 selects the “front” camera, sensor-id=1 selects the “rear” camera.

I would like to have sensor-id=0 use /dev/video0 and sensor-id=1 use /dev/video1, but that’s not what happens, regardless of if I put position=“rear” in module0 and position=“front” in module1, or the opposite.

How can I configure that sensor-id=0 uses /dev/video0 and sensor-id=1 uses /dev/video1 ?

@phdm
The video0 is from the bottom of the modules.
Below case will set the spi0.0 as video0 and spi1.0 as video1.

tegra-camera-platform {
  compatible = "nvidia, tegra-camera-platform";
  num_csi_lanes = <8>;
  max_lane_speed = <1500000>;
  min_bits_per_pixel = <12>;
  vi_peak_byte_per_pixel = <2>;
  vi_bw_margin_pct = <25>;
  max_pixel_rate = <1500000>;
  isp_peak_byte_per_pixel = <2>;
  isp_bw_margin_pct = <25>;

  modules {
   module0 {
    badge = "imx264_left_2174";
    position = "rear";
    orientation = "1";
    drivernode0 {
     pcl_id = "v4l2_sensor";
     devname = "imx264 spi1.0";
     proc-device-tree = "/proc/device-tree/spi@7000d600/imx264@0";
    };
   };

   module1 {
    badge = "imx264_right_2176";
    position = "front";
    orientation = "1";
    drivernode0 {
     pcl_id = "v4l2_sensor";
     devname = "imx264 spi0.0";
     proc-device-tree = "/proc/device-tree/spi@7000d400/imx264@0";
    };
   };
  };
 };

You actually meant “Below case will set the spi0.0 as SENSOR-ID=0 and spi1.0 as SENSOR-ID=1 (module0 will be given sensor-id=1 and module1 will be given sensor-id=0)” ?

Yes, that works.

Than you ShaneCCC