ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_camera_source_memory.c File Reference

Fixed-frame memory source backend implementation. More...

#include "ra8_camera_source_memory.h"
#include <stddef.h>
#include <string.h>
#include "ra8_attributes.h"
#include "ra8_camera_internal.h"
#include "ra8_err.h"
Include dependency graph for ra8_camera_source_memory.c:

Go to the source code of this file.

Functions

static ra8_err_t internal_memory_get_info (void *ctx, ra8_camera_source_info_t *out_info)
 Query the fixed frame's native geometry.
static ra8_err_t internal_memory_capture (void *ctx, const ra8_camera_buffer_t *buffer, ra8_camera_frame_t *out_frame)
 Copy the fixed frame into the caller's capture buffer.
ra8_err_t ra8_camera_source_memory_init (ra8_camera_source_t *source, ra8_camera_source_memory_state_t *state, const ra8_camera_frame_t *frame)
 Bind a repeatable source backed by one immutable frame.

Variables

static const ra8_camera_source_iface_t s_memory_source_iface
 Fixed-frame source vtable.

Detailed Description

Fixed-frame memory source backend implementation.

Tag
[Ring 4 / Service] {World: NS}

Implements the private source vtable with bounds-checked metadata queries and a byte-for-byte copy into caller-owned capture storage.

Since
0.1.0

Definition in file ra8_camera_source_memory.c.

Function Documentation

◆ internal_memory_capture()

ra8_err_t internal_memory_capture ( void * ctx,
const ra8_camera_buffer_t * buffer,
ra8_camera_frame_t * out_frame )
static

Copy the fixed frame into the caller's capture buffer.

Implements source capture as a bounded byte-for-byte copy.

Parameters
[in]ctxBound memory-source state.
[in]bufferCaller-owned writable capture storage.
[out]out_frameReceives a view of copied bytes.
Returns
ra8_err_t Error code.
Return values
k_ra8_okFrame copied.
k_ra8_err_null_ptrState, buffer, or output pointer is NULL.
k_ra8_err_invalid_sizeBuffer cannot hold the fixed frame.
Precondition
ctx was populated by ra8_camera_source_memory_init.
buffer->data covers buffer->capacity writable bytes.
Postcondition
On success out_frame->data == buffer->data.
Source state is unchanged.
Note
Not thread-safe with respect to the capture buffer.
Since
0.1.0

Definition at line 81 of file ra8_camera_source_memory.c.

References ra8_camera_frame_t::bytes, ra8_camera_buffer_t::capacity, ra8_camera_buffer_t::data, ra8_camera_frame_t::data, ra8_camera_source_memory_state_t::frame, k_ra8_err_invalid_size, k_ra8_err_null_ptr, k_ra8_ok, and memcpy().

◆ internal_memory_get_info()

ra8_err_t internal_memory_get_info ( void * ctx,
ra8_camera_source_info_t * out_info )
static

Query the fixed frame's native geometry.

Copies immutable metadata from the memory-source state.

Parameters
[in]ctxBound memory-source state.
[out]out_infoReceives source geometry and capacity.
Returns
ra8_err_t Error code.
Return values
k_ra8_okInformation returned.
k_ra8_err_null_ptrState or output pointer is NULL.
Precondition
ctx was populated by ra8_camera_source_memory_init.
out_info is writable.
Postcondition
On success out_info describes the fixed frame.
Source state is unchanged.
Note
Thread-safe because the state is read-only after initialization.
Since
0.1.0

Definition at line 42 of file ra8_camera_source_memory.c.

References ra8_camera_frame_t::bytes, ra8_camera_frame_t::format, ra8_camera_source_memory_state_t::frame, ra8_camera_frame_t::height, k_ra8_err_null_ptr, k_ra8_ok, RA8_INTERNAL, ra8_camera_frame_t::stride_bytes, and ra8_camera_frame_t::width.

◆ ra8_camera_source_memory_init()

ra8_err_t ra8_camera_source_memory_init ( ra8_camera_source_t * source,
ra8_camera_source_memory_state_t * state,
const ra8_camera_frame_t * frame )
nodiscard

Bind a repeatable source backed by one immutable frame.

Parameters
[out]sourceCaller-owned source handle to bind.
[out]stateCaller-owned backend state to populate.
[in]frameValid immutable frame to replay.
Returns
ra8_err_t Error code.
Return values
k_ra8_okSource bound.
k_ra8_err_null_ptrAn argument or frame->data was NULL.
otherPropagated from ra8_camera_frame_validate.
Precondition
source and state out-live every source operation.
frame->data remains readable for the source lifetime.
Postcondition
On success captures copy the fixed bytes into caller storage.
On error source and state are unchanged.
Note
Not thread-safe with respect to the same source state.
Since
0.1.0

Definition at line 108 of file ra8_camera_source_memory.c.

References ra8_camera_source_t::ctx, ra8_camera_source_memory_state_t::frame, ra8_camera_source_t::iface, k_ra8_err_null_ptr, k_ra8_ok, ra8_camera_frame_validate(), and s_memory_source_iface.

Variable Documentation

◆ s_memory_source_iface

const ra8_camera_source_iface_t s_memory_source_iface
static
Initial value:
= {
}
static ra8_err_t internal_memory_get_info(void *ctx, ra8_audio_source_info_t *out_info)
Report metadata for the fixed memory frame.
static ra8_err_t internal_memory_capture(void *ctx, const ra8_audio_buffer_t *buffer, ra8_audio_frame_t *out_frame)
Copy the fixed memory frame into a caller buffer.

Fixed-frame source vtable.

Definition at line 103 of file ra8_camera_source_memory.c.