Nvcamerasrc sensor-id mapping

Hi,
I have a system that may change the camera configuration from boot to boot.
I am trying to capture video from the cameras using gstreamer and nvcamerasrc. We can get this to work, but it seems the sensor-id changes depending on how many cameras are attached.

The device tree is programmed to indicate 5 cameras attached and the camera modules have the correct names to indicate their position.

For example: When I have a single camera attached it comes up as sensor-id=0

When I have 5 cameras attached that same camera from before uses sensor-id=4

The sensor in question is listed in the device tree using position centerright. Shouldn’t it be sensor-id=2 in both cases? It seems the sensor id that produces successful capture is based on the order in which they are successfully probed by nvcamera-daemon.

If that is the case, how can I know programmatically, which sensor-id to use?

Here is a snip from the nvcamera-daemon log when 1 camera is attached:>

NvPclHwPrintModuleDefinition – Name: <camera model 2>_centerright_li<camera model 2>
NvPclHwPrintModuleDefinition – Position: 2
NvPclHwPrintModuleDefinition – CalibrationData Found: 1
NvPclHwPrintCameraSubModule – HwCamSubModule[0].Name: v4l2_sensor
NvPclHwPrintCameraSubModule – HwCamSubModule[0].DevName: <camera model 2> 2-0010
NvPclModuleListInitialize: NvPclModule list[0]: <camera model 2>_centerright_li<camera model 2> position2

Here is a snip from the nvcamera-daemon log when 5 cameras are attached:

NvPclHwPrintModuleDefinition -- Name: <camera model 1>_bottomleft_nav3
NvPclHwPrintModuleDefinition -- Position: 0
NvPclHwPrintModuleDefinition -- CalibrationData Found: 1
NvPclHwPrintCameraSubModule -- HwCamSubModule[0].Name: v4l2_sensor
NvPclHwPrintCameraSubModule -- HwCamSubModule[0].DevName: <camera model 1> 2-001c
NvPclHwGetModuleList: WARNING: Could not map module to ISP config string
NvPclHwGetModuleList: No module data found
NvPclHwPrintModuleDefinition -- Name: <camera model 1>_topleft_nav2                                                                                                                                                                          
NvPclHwPrintModuleDefinition -- Position: 3
NvPclHwPrintModuleDefinition -- CalibrationData Found: 1
NvPclHwPrintCameraSubModule -- HwCamSubModule[0].Name: v4l2_sensor
NvPclHwPrintCameraSubModule -- HwCamSubModule[0].DevName: <camera model 1> 2-001b
NvPclHwGetModuleList: WARNING: Could not map module to ISP config string
NvPclHwGetModuleList: No module data found
NvPclHwPrintModuleDefinition -- Name: <camera model 1>_topright_nav1
NvPclHwPrintModuleDefinition -- Position: 5
NvPclHwPrintModuleDefinition -- CalibrationData Found: 1
NvPclHwPrintCameraSubModule -- HwCamSubModule[0].Name: v4l2_sensor
NvPclHwPrintCameraSubModule -- HwCamSubModule[0].DevName: <camera model 1> 2-001a
NvPclHwGetModuleList: WARNING: Could not map module to ISP config string
NvPclHwGetModuleList: No module data found
NvPclHwPrintModuleDefinition -- Name: <camera model 1>_bottomright_nav0
NvPclHwPrintModuleDefinition -- Position: 4
NvPclHwPrintModuleDefinition -- CalibrationData Found: 1
NvPclHwPrintCameraSubModule -- HwCamSubModule[0].Name: v4l2_sensor
NvPclHwPrintCameraSubModule -- HwCamSubModule[0].DevName: <camera model 1> 2-0019
NvPclHwGetModuleList: WARNING: Could not map module to ISP config string
NvPclHwGetModuleList: No module data found
NvPclHwPrintModuleDefinition -- Name: <camera model 2>_centerright_li<camera model 2>
NvPclHwPrintModuleDefinition -- Position: 2
NvPclHwPrintModuleDefinition -- CalibrationData Found: 1
NvPclHwPrintCameraSubModule -- HwCamSubModule[0].Name: v4l2_sensor
NvPclHwPrintCameraSubModule -- HwCamSubModule[0].DevName: <camera model 2> 2-0010
NvPclHwGetModuleList: OFParserListModules Succeeded
NvPclModuleListInitialize: NvPclModule list[0]: <camera model 1>_bottomleft_nav3 position0
NvPclModuleListInitialize: NvPclModule list[1]: <camera model 1>_topleft_nav2 position3
NvPclModuleListInitialize: NvPclModule list[2]: <camera model 1>_topright_nav1 position5
NvPclModuleListInitialize: NvPclModule list[3]: <camera model 1>_bottomright_nav0 position4
NvPclModuleListInitialize: NvPclModule list[4]: <camera model 2>_centerright_li<camera model 2> position2

The point to emphasize is that the device tree entries for positions are constant in all configurations. The positions don’t change. Just the presence of various cameras change, but it seems the sensor-id changes.

The sensor-id are follow the position as below link.

https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%2520Linux%2520Driver%2520Package%2520Development%2520Guide%2Fcamera_sensor_prog.html%23wwpID0E0UBB0HA

But as indicated above, I do use those names for the positions, but for some reason when I have one camera attached, the sensor-id no longer matches what it is when all the sensors are attached.

For example, the camera that uses ‘position=centerright’ comes up as sensor-id=0 when the other cameras are not attached.

Yes, they will shift if some device not present.

My follow up question, how can I programmatically determine what sensor-id to use?

The sensor-id depend on the position in the device tree.

Thanks for verifying that.
I ended up making my program parse the device tree in the filesystem to determine which modules are marked as status “okay”, then enumerate accordingly. On my system we were seeing the sensor id was enumerated in reverse order of module entry.

E.g.
module0: status = okay → sensor-id=2
module1: status = disabled →
module2: status = okay → sensor-id=1
module3: status = okay → sensor-id=0