Files
video-setup/include/error.h
mikael-lovqvists-claude-agent a29c556851 Add common, media_ctrl and v4l2_ctrl modules with CLI drivers and docs
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>
2026-03-25 21:40:37 +00:00

60 lines
1.0 KiB
C

#pragma once
#include <errno.h>
typedef enum Error_Code {
ERR_NONE = 0,
ERR_SYSCALL = 1,
ERR_INVALID = 2,
ERR_NOT_FOUND = 3,
} Error_Code;
struct Syscall_Error_Detail {
int err_no;
};
struct Invalid_Error_Detail {
/* fields added as concrete cases arise */
int placeholder;
};
struct App_Error {
Error_Code code;
const char *file;
int line;
union {
struct Syscall_Error_Detail syscall;
struct Invalid_Error_Detail invalid;
} detail;
};
void app_error_print(struct App_Error *e);
#define APP_OK \
((struct App_Error){ .code = ERR_NONE })
#define APP_IS_OK(e) \
((e).code == ERR_NONE)
#define APP_SYSCALL_ERROR() \
((struct App_Error){ \
.code = ERR_SYSCALL, \
.file = __FILE__, \
.line = __LINE__, \
.detail = { .syscall = { .err_no = errno } }, \
})
#define APP_INVALID_ERROR() \
((struct App_Error){ \
.code = ERR_INVALID, \
.file = __FILE__, \
.line = __LINE__, \
})
#define APP_NOT_FOUND_ERROR() \
((struct App_Error){ \
.code = ERR_NOT_FOUND, \
.file = __FILE__, \
.line = __LINE__, \
})