Skip to content

rs-enum: use media-ctl for Tegra stream type identification#14908

Merged
Nir-Az merged 7 commits into
realsenseai:developmentfrom
Nir-Az:rs-enum-media-ctl
Apr 9, 2026
Merged

rs-enum: use media-ctl for Tegra stream type identification#14908
Nir-Az merged 7 commits into
realsenseai:developmentfrom
Nir-Az:rs-enum-media-ctl

Conversation

@Nir-Az

@Nir-Az Nir-Az commented Apr 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Replace pixel format heuristics with media-ctl entity name discovery for identifying stream types on Tegra/Jetson.

Problem

The previous approach identified streams by pixel format (Z16=depth, GREY=ir, etc.). This is fragile:

  • D585S safety stream uses GREY format → misidentified as IR
  • Some IR streams produce color formats → misidentified as color
  • Every new format requires script changes

Solution

Parse D4XX entity names from the media controller graph (media-ctl --print-dot). The driver registers entities like D4XX depth, D4XX rgb, D4XX ir, D4XX imu which unambiguously identify the stream type.

Changes

  • get_stream_types() — new function replacing identify_dev_type(). Queries media-ctl for D4XX entity names and their DS5 mux port connections. Returns stream types in port order. Handles multi-cam on single deserializer by discovering all I2C addresses on the same bus.
  • process_rs_video_devices() — uses get_stream_types() for positional stream type assignment (streaming nodes only, skipping metadata). On Tegra, individual /dev/videoN nodes aren't linked to specific D4XX entities in the media graph — the driver creates them in deterministic DS5 mux port order.
  • create_dfu_link() — fixed DFU device matching by I2C address instead of alphabetical ls order, which could swap DFU assignments when bus numbers don't sort lexically (e.g. bus 10 before bus 9).
  • IPU6 path is untouched.

Adding new stream types (e.g. safety)

When the driver registers a new entity (e.g. D4XX safety), support requires:

  1. scripts/rs-enum.sh: Add the mapping to camera_names (e.g. [safety]=safety), add a counter (safety_dev_counter), and update get_dev_num()/increment_dev_num(). The media-ctl discovery picks up the new entity automatically.
  2. src/linux/backend-v4l2.cpp: Add "safety" to the video_sensors vector in get_mipi_rs_enum_nodes() (line 1282) and set the appropriate info.mi value.

Test plan

  • Single cam, single deserializer (D457 on Intel Des)
  • Multi-cam, single deserializer (2× D457 on FangZhu)
  • Multi-cam, multi deserializer (2× D457 on separate FangZhu deserializers)
  • DFU links correctly matched by I2C address
  • Verify no regression on IPU6 platform (code path untouched)

Test results

D457 on single Intel Des
image

FangZhu with 2 cam on 1 des
● Both cameras enumerated correctly:

  • Camera 0 (9-001a): depth, color, ir, imu + metadata + DFU
  • Camera 1 (9-002a): depth, color, ir, imu + metadata + DFU
image

FungZhu 2 cam each on a different des
image

Copilot AI review requested due to automatic review settings April 5, 2026 19:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates rs-enum.sh’s Tegra/Jetson stream-type identification to prefer media-ctl media-graph entity names (e.g., D4XX depth, D4XX rgb) over pixel-format heuristics, with a fallback to the existing heuristic when media-ctl data is unavailable.

Changes:

  • Add discover_stream_types() to infer depth/color/ir/imu ordering from cached media-ctl --print-dot output per I2C address.
  • Update Tegra device processing to use discovered stream types when available, falling back to identify_dev_type() otherwise.
  • Cache Tegra media-ctl DOT output once to avoid repeated media-ctl invocations per device.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/rs-enum.sh Outdated
Comment thread scripts/rs-enum.sh Outdated
@Nir-Az Nir-Az requested a review from ejgoldik April 5, 2026 21:24
@Nir-Az Nir-Az force-pushed the rs-enum-media-ctl branch from b0047c5 to 5b799de Compare April 6, 2026 07:01
@Nir-Az Nir-Az requested a review from ev-mp April 6, 2026 14:02
@Nir-Az Nir-Az merged commit 94509e5 into realsenseai:development Apr 9, 2026
29 checks passed
Nir-Az added a commit that referenced this pull request Apr 29, 2026
Nir-Az added a commit that referenced this pull request Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants