Skip to main content

<alp/camera.h> — Image Capture

Streaming frame capture from a camera sensor — MIPI CSI-2 on V2N / V2M (Linux) and AEN (Zephyr), through whichever backend the active silicon selects.

#include <alp/camera.h>
#include <alp/e1m_pinout.h>

Capture a frame​

alp_camera_config_t cfg = ALP_CAMERA_CONFIG_DEFAULT(ALP_E1M_CAM0);
cfg.width = 640; /* width / height default to 0 — you must choose */
cfg.height = 480;

alp_camera_t *cam = alp_camera_open(&cfg);
if (cam == NULL) return alp_last_error();

uint32_t fps_x1000;
if (alp_camera_get_fps(cam, &fps_x1000) == ALP_OK) {
printf("settled at %u.%03u fps\n", fps_x1000 / 1000u, fps_x1000 % 1000u);
}

alp_camera_start(cam);

alp_camera_frame_t frame;
if (alp_camera_capture(cam, &frame, /* timeout_ms */ 1000u) == ALP_OK) {
process_frame(frame.data, frame.size, frame.timestamp_us);
alp_camera_release(cam, &frame);
}

alp_camera_stop(cam);
alp_camera_close(cam);

Config struct​

FieldTypeNotes
camera_iduint32_tCamera instance, e.g. ALP_E1M_CAM0.
width / heightuint16_tRequested stream size.
fpsuint8_tRequested frame rate. 0 = backend default. A non-zero value is a request, not a guarantee: the backend settles on the nearest rate the sensor / mode supports (some sensors have one fixed rate and ignore it). Read the settled rate back with alp_camera_get_fps().
formatalp_pixfmt_tRequested pixel format.

ALP_CAMERA_CONFIG_DEFAULT(id) sets camera_id from id plus width = 0, height = 0, fps = 30, format = ALP_PIXFMT_RGB565. The zero size is a deliberate "you must choose" sentinel — set width / height before opening. See the shared macro contract for the C++ compound-literal caveat.

Functions​

CallNotes
alp_camera_open(cfg)Returns NULL with alp_last_error() set on failure (see the backend notes below for backend-specific codes).
alp_camera_start(c) / alp_camera_stop(c)Start / stop streaming. start is idempotent; frames captured before stop stay valid until released.
alp_camera_capture(c, &frame, timeout_ms)Blocks for the next frame; UINT32_MAX waits indefinitely. The caller does not own the buffer. ALP_ERR_NOT_READY if the stream is not started, ALP_ERR_TIMEOUT on timeout.
alp_camera_release(c, &frame)Returns the buffer; frame.data is invalid afterwards.
alp_camera_get_fps(c, &fps_x1000)v0.17.0. The rate actually programmed at open, in thousandths of a frame per second (29.97 fps = 29970). Read once at open; later sensor-side changes are not tracked. ALP_ERR_NOSUPPORT when the backend or driver cannot read its frame interval back.
alp_camera_configure_isp(c, &isp)On-die ISP toggles — see below.
alp_camera_capabilities(c)Per-instance capability descriptor.
alp_camera_close(c)Idempotent; in-flight frames are implicitly released.

alp_camera_frame_t carries void *data, size_t size and uint64_t timestamp_us.

Backend status​

Zephyr backends are each gated by their own Kconfig symbol, and all depend on CONFIG_VIDEO — without it only the stub links.

BackendPrioritySilicon matchStatus
zephyr_video50"*"Portable wrapper over Zephyr drivers/video/ (CONFIG_ALP_SDK_CAMERA_ZEPHYR_VIDEO). Real capture on any board with a video_* sensor driver; configure_isp is ALP_ERR_NOSUPPORT.
alif_isp_pico100alif:ensemble:e8Opt-in, CONFIG_ALP_SDK_CAMERA_ALIF_ISP (default n, depends on VIDEO_ISP_VSI). Drives the E8 VeriSilicon ISP-Pico: negotiates a YUV output (converted to RGB565 on the CPU if you asked for RGB565), runs AWB / AE through the Zephyr video controls. Bench-proven through this portable header on E1M-AEN803 with an OV5647 (aen-isp-ov5647-viewfinder).
v2n_n44_isp100renesas:rzv2n:n44Zephyr-side V2N path; its MIPI CSI-2 port has not landed. configure_isp validates and returns ALP_ERR_NOSUPPORT — the A55 owns the camera blocks, so the CM33 writes no ISP register.
yocto_drv100"*" (Linux only)New in v0.17.0. V4L2 + media-controller, SoC-agnostic — see below.
zephyr_stub0"*"Fallback for silicon with no real backend; every op returns ALP_ERR_NOT_IMPLEMENTED. On baremetal this is the only backend linked.

Linux V4L2 backend (yocto_drv)​

On Yocto / Linux, camera_id N is the devicetree alias alp-camera<N> (e.g. aliases { alp-camera0 = &sensor; };). The sensor → CSI-2 → capture-node chain is discovered from the media graph, so any sensor with a mainline V4L2 subdev driver works without per-sensor code.

  • Formats: ALP_PIXFMT_GREY8, ALP_PIXFMT_RAW8 and ALP_PIXFMT_RAW10 only — colour formats return ALP_ERR_NOSUPPORT.
  • Verified: RAW10 on E1M-V2M103 with an IMX296LQ (30.00 fps at a 30 fps request). RAW8 and the direct Y8 path are not bench-verified.
  • Open errors: ALP_ERR_NOT_READY (no alp-camera<N> alias, or no matching sensor / capture chain in any media device); ALP_ERR_NOSUPPORT (colour format, or no media-bus code for the requested format); ALP_ERR_INVAL (a size the sensor does not produce natively, or a pipeline element adjusted the format); ALP_ERR_IO / ALP_ERR_NOMEM (V4L2 ioctl, buffer allocation or mmap failure). An out-of-range fps is not an error — it settles on the nearest rate.

Before v0.17.0 every camera call on Yocto returned ALP_ERR_NOT_IMPLEMENTED.

ISP configuration​

alp_camera_configure_isp(camera, &isp) applies coarse on-die ISP toggles — auto_exposure, auto_white_balance, auto_focus, lens_shading, dead_pixel_correction, noise_reduction — plus brightness, contrast and saturation offsets (-128..+127). All-zero means bypass. Backends without an on-die ISP return ALP_ERR_NOSUPPORT; that includes V2N today and AEN E3 / E5 / E7 silicon without the optional ISP fabric.

note
<alp/ext/renesas/camera.h> is validate-only

The Renesas extension calls (alp_renesas_camera_isp_3a_window_set(), alp_renesas_camera_isp_gain_table_load() and the lens-shading LUT load) now validate their arguments and then return ALP_ERR_NOSUPPORT. No ISP register is written and no table is retained: on RZ/V2N the A55 owns the camera blocks, not the CM33.

Camera mux (E1M EVK)​

The E1M EVK carries a PI3WVR626 2:1 MIPI CSI multiplexer, driven by EVK_PIN_CAM_MUX_SEL through <alp/chips/cam_mux_pi3wvr626.h> (cam_mux_pi3wvr626_init() / cam_mux_pi3wvr626_select()); input A is the default. The E1M-X EVK has no PI3WVR626 — it exposes dedicated CAM0 / CAM1 connectors instead.

ABI status​

[ABI-EXPERIMENTAL] — ALP_ABI_STATUS_CAMERA. The base capture path is stable in practice; the ISP block is experimental.

See also​

Questions about this page? Email contact@alplab.ai