Add support for media topology on Raspberry Pi 5

HDMI input over CSI2 on RPi5 requires quite a bit more setup, because
/dev/video0 (or other /dev/video*) isn't automatically routed to the
video source. This needs finding relevant source media entity, and then
a route to requested video device (usually /dev/video0). Setting video
format gets more complicated too, because it needs to be set on all
involved nodes (aka "pads").

V4L2_EVENT_SOURCE_CHANGE is delivered on a different FD than reading
stream from, so both needs to be select()ed in this case.

From the user perspective, this adds two new options: --media-device and
--media-entity-name. When provided, ustreamer will find requested entity
and route it to the device given in --device option.
This commit is contained in:
Marek Marczykowski-Górecki
2026-06-30 00:58:43 +02:00
parent 730cc3c89e
commit 2c515eeea5
3 changed files with 408 additions and 11 deletions

View File

@@ -51,8 +51,15 @@ typedef struct {
atomic_int refs;
} us_capture_hwbuf_s;
typedef struct {
int fd;
uint pad;
} us_media_pad_s;
typedef struct {
int fd;
int dv_timings_fd;
us_media_pad_s media_pads[3]; // for VIDIOC_SUBDEV_S_FMT
uint width;
uint height;
uint format;
@@ -76,7 +83,7 @@ typedef enum {
CTL_MODE_DEFAULT,
} us_control_mode_e;
typedef struct {
typedef struct _FD{
us_control_mode_e mode;
int value;
} us_control_s;
@@ -103,6 +110,8 @@ typedef struct {
uint width;
uint height;
uint format;
char *media_path;
char *media_entity_name;
bool format_swap_rgb;
uint jpeg_quality;