Modules (src/modules/): - common/error: App_Error struct with structured detail union, error codes, app_error_print(); designed for future upgrade to preprocessor-generated location codes - media_ctrl: media device enumeration, topology query (entities/pads/links), link enable/disable via Media Controller API (/dev/media*) - v4l2_ctrl: control enumeration (with menu item fetching), get/set via V4L2 ext controls API, device discovery (/dev/video*) All modules use -std=c11 -D_GNU_SOURCE, build artifacts go to build/ only. Kernel-version-dependent constants guarded with #ifdef + #warning. CLI drivers (dev/cli/): - media_ctrl_cli: list, info, topology, set-link subcommands - v4l2_ctrl_cli: list, controls, get, set subcommands Docs (docs/cli/): - media_ctrl_cli.md and v4l2_ctrl_cli.md with usage, examples, and context within the video routing system Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
76 lines
1.9 KiB
C
76 lines
1.9 KiB
C
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include "error.h"
|
|
|
|
/* Opaque handle — defined in v4l2_ctrl.c */
|
|
struct V4l2_Ctrl_Handle;
|
|
|
|
typedef enum V4l2_Ctrl_Type {
|
|
CTRL_TYPE_INTEGER = 1,
|
|
CTRL_TYPE_BOOLEAN = 2,
|
|
CTRL_TYPE_MENU = 3,
|
|
CTRL_TYPE_BUTTON = 4,
|
|
CTRL_TYPE_INTEGER64 = 5,
|
|
CTRL_TYPE_CTRL_CLASS = 6,
|
|
CTRL_TYPE_STRING = 7,
|
|
CTRL_TYPE_BITMASK = 8,
|
|
CTRL_TYPE_INTEGER_MENU = 9,
|
|
CTRL_TYPE_UNKNOWN = 0xff,
|
|
} V4l2_Ctrl_Type;
|
|
|
|
struct V4l2_Ctrl_Desc {
|
|
uint32_t id;
|
|
char name[32];
|
|
V4l2_Ctrl_Type type;
|
|
int32_t min;
|
|
int32_t max;
|
|
int32_t step;
|
|
int32_t default_value;
|
|
int32_t current_value;
|
|
uint32_t flags;
|
|
};
|
|
|
|
struct V4l2_Menu_Item {
|
|
uint32_t index;
|
|
char name[32]; /* for CTRL_TYPE_MENU */
|
|
int64_t value; /* for CTRL_TYPE_INTEGER_MENU */
|
|
};
|
|
|
|
/*
|
|
* Enumerate all /dev/video* device nodes present on the system.
|
|
*/
|
|
struct App_Error v4l2_ctrl_find_devices(
|
|
void (*callback)(const char *device_path, void *userdata),
|
|
void *userdata);
|
|
|
|
struct App_Error v4l2_ctrl_open(const char *device_path, struct V4l2_Ctrl_Handle **out);
|
|
void v4l2_ctrl_close(struct V4l2_Ctrl_Handle *handle);
|
|
|
|
/*
|
|
* Enumerate all controls on the device.
|
|
* For menu and integer-menu controls, menu_items is a non-NULL array of
|
|
* menu_count items. For all other types, menu_items is NULL and menu_count is 0.
|
|
*/
|
|
struct App_Error v4l2_ctrl_enumerate(
|
|
struct V4l2_Ctrl_Handle *handle,
|
|
void (*callback)(
|
|
const struct V4l2_Ctrl_Desc *desc,
|
|
uint32_t menu_count,
|
|
const struct V4l2_Menu_Item *menu_items,
|
|
void *userdata),
|
|
void *userdata);
|
|
|
|
struct App_Error v4l2_ctrl_get(
|
|
struct V4l2_Ctrl_Handle *handle,
|
|
uint32_t id,
|
|
int32_t *value_out);
|
|
|
|
struct App_Error v4l2_ctrl_set(
|
|
struct V4l2_Ctrl_Handle *handle,
|
|
uint32_t id,
|
|
int32_t value);
|
|
|
|
/* Human-readable name for a control type */
|
|
const char *v4l2_ctrl_type_name(V4l2_Ctrl_Type type);
|