|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Capture Engine Unit (CEU) driver implementation. More...
#include "ra8_ceu.h"#include <stdint.h>#include "ra8_attributes.h"#include "ra8_ceu_internal.h"#include "ra8_ceu_regs.h"#include "ra8_check.h"#include "ra8_dmac.h"#include "ra8_err.h"#include "ra8_hw_err.h"#include "ra8_log.h"#include "ra8_mstp.h"Go to the source code of this file.
Enumerations | |
| enum | ra8_ceu_timing_t : uint32_t { k_ra8_ceu_reset_spin = 256U } |
| Bounded spin budgets for host + target builds. More... | |
| enum | ra8_ceu_align_mask_t : uintptr_t { k_ra8_ceu_buffer_align_mask } |
| Buffer-alignment helper. More... | |
| enum | ra8_ceu_dma_align_t : uint32_t { k_ra8_ceu_dma_byte_align_mask = 3U , k_ra8_ceu_dma_count_shift = 2U } |
| DMAC-pump byte-count alignment. More... | |
Functions | |
| static ra8_err_t | internal_wait_idle (void) |
| Bounded spin until CSTSR.CPTON and CAPSR.CPKIL both clear. | |
| static bool | internal_is_aligned (const void *ptr) |
| True if ptr is non-NULL and 8-byte aligned. | |
| static ra8_err_t | internal_validate_buffers (const ra8_ceu_buffers_t *bufs) |
| Validate every non-NULL pointer in a buffer bundle. | |
| static void | internal_program_addresses (const ra8_ceu_buffers_t *bufs) |
| Program the CDAYR / CDACR / CDBYR / CDBCR family on Plane A. | |
| ra8_err_t | ra8_ceu_init (const ra8_ceu_config_t *cfg) |
| Power on the CEU and write the full configuration. | |
| ra8_err_t | ra8_ceu_deinit (void) |
| Stop the CEU and drop its module-stop bit. | |
| ra8_err_t | ra8_ceu_reset (void) |
| Issue a software reset of the capture state machine. | |
| ra8_err_t | ra8_ceu_get_status (uint32_t *out_mask) |
| Snapshot the CEU event-status register (CETCR). | |
| ra8_err_t | ra8_ceu_clear_status (uint32_t mask) |
| Clear the CETCR event flags identified by mask. | |
| ra8_err_t | ra8_ceu_status_snapshot (ra8_ceu_status_t *out) |
| Snapshot CSTSR + CDSSR + the active plane into one struct. | |
| ra8_err_t | ra8_ceu_data_size_get (uint32_t *out_bytes) |
| Return the byte count written by the last data-enable capture. | |
| ra8_err_t | ra8_ceu_interrupts_set (uint32_t mask) |
| Update the CEIER interrupt-enable bitmask. | |
| ra8_err_t | ra8_ceu_attach_handler (ra8_ceu_event_fn_t fn, void *ctx) |
| Register a callback invoked by ra8_ceu_dispatch. | |
| void | ra8_ceu_dispatch (void) |
| Drain CEU interrupt events and fire the registered callback. | |
| ra8_err_t | ra8_ceu_enter_stop (void) |
| Stop active captures and drop the CEU module-stop bit. | |
| ra8_err_t | ra8_ceu_exit_stop (void) |
| Exit the MSTP-gated stop entered by ra8_ceu_enter_stop. | |
| static ra8_err_t | internal_arm_capture (const ra8_ceu_buffers_t *bufs) |
| Common arming sequence for capture_start / capture_start_ex. | |
| ra8_err_t | ra8_ceu_capture_arm (uint8_t *buffer) |
| Arm a capture into the supplied buffer. | |
| ra8_err_t | ra8_ceu_capture_start_ex (const ra8_ceu_buffers_t *bufs) |
| Arm a capture using a full address bundle. | |
| ra8_err_t | ra8_ceu_capture_disarm (void) |
| Stop the running capture by clearing CAPSR.CE. | |
| static void | internal_plane_b_mirror_from_a (void) |
| Mirror every 3-plane register from Plane A to Plane B. | |
| static void | internal_plane_b_apply_overrides (const ra8_ceu_buffers_t *bufs) |
| Apply caller-supplied buffer overrides to Plane B. | |
| ra8_err_t | ra8_ceu_plane_b_program (const ra8_ceu_buffers_t *bufs) |
| Mirror the active configuration into Plane B and arm a swap. | |
| ra8_err_t | ra8_ceu_plane_swap_force (void) |
| Force an immediate plane swap (CRCMPR.RA). | |
| ra8_err_t | ra8_ceu_firewall_set (bool enable, uint32_t upper_bound) |
| Configure the CFWCR firewall window. | |
| ra8_err_t | ra8_ceu_byte_swap_set (const ra8_ceu_byte_swap_t *swap) |
| Replace CDOCR byte-swap configuration in-place. | |
| ra8_err_t | ra8_ceu_bundle_size_set (uint32_t size_bytes) |
| Configure the bundle-write size (CBDSR). | |
| ra8_err_t | ra8_ceu_low_pass_set (bool enable) |
| Enable or disable the input low-pass filter (CLFCR.LPF). | |
| ra8_err_t | ra8_ceu_capture_mode_set (ra8_ceu_capture_mode_t mode) |
| Enable or disable continuous-capture mode (CAPCR.CTNCP). | |
| ra8_err_t | ra8_ceu_frame_drop_set (uint8_t count) |
| Update the frame-drop counter (CAPCR.FDRP). | |
| ra8_err_t | ra8_ceu_dma_pump (uint8_t channel, const uint8_t *src, uint8_t *dst, uint32_t bytes) |
| Pump a finished CEU bundle into a downstream DMAC channel. | |
| ra8_err_t | ra8_ceu_set_dma_buffer (uint8_t *buf, uint32_t len) |
| Cache a DMAC-target framebuffer for the next ra8_ceu_capture_start call. | |
| ra8_err_t | ra8_ceu_capture_start (uint32_t num_frames) |
| Start a single or continuous capture into the cached DMA buffer. | |
| ra8_err_t | ra8_ceu_capture_stop (void) |
| Stop the in-flight capture started via ra8_ceu_capture_start. | |
Variables | |
| static const char * | s_tag = "CEU" |
| Component tag used for ra8_log_* calls from this module. | |
| static ra8_ceu_event_fn_t | s_ceu_fn |
| Module-scope event callback registered by ra8_ceu_attach_handler. | |
| static void * | s_ceu_ctx |
| Opaque context forwarded as the first argument to s_ceu_fn. | |
| static uint32_t | s_ceu_int_enable |
| Cached copy of CEIER – used to gate the dispatched event mask. | |
| static uint32_t | s_ceu_image_area |
| Cached image_area_size from the most recent ra8_ceu_init. | |
| static ra8_ceu_capture_format_t | s_ceu_capture_format |
| Cached CAMCR.JPG copy so capture_start can choose its path. | |
| static uint8_t * | s_ceu_dma_buf |
| Cached DMAC-target buffer set via ra8_ceu_set_dma_buffer. | |
| static uint32_t | s_ceu_dma_len |
| Cached buffer length (bytes) for the next capture. | |
Capture Engine Unit (CEU) driver implementation.
Full-coverage HAL driver for the RA8D2 Capture Engine Unit. See ra8_ceu.h for the per-API doxygen and the high-level state machine; this file implements every public entry point and cites the relevant register sequences out of HUM Ch 60 (p 3626-3682).
The driver covers all three CEU operating formats (image-capture 4:2:2 / 4:2:0, data-synchronous fetch, data-enable fetch), both capture modes (single-shot / continuous), interlace + bundle write, plane-B shadow programming with VD-synchronised swap, the TrustZone-style firewall, every CDOCR byte-swap permutation, scale-down + low-pass filter, the CAPCR frame-drop / burst-mode controls, and dispatch + acknowledgement of every CETCR event.
Definition in file ra8_ceu.c.
| enum ra8_ceu_align_mask_t : uintptr_t |
Buffer-alignment helper.
k_ra8_ceu_buffer_align_bytes is 8; the lowest 3 bits of an 8-byte-aligned address must be zero.
| Enumerator | |
|---|---|
| k_ra8_ceu_buffer_align_mask | RA8 CEU buffer align mask. |
| enum ra8_ceu_dma_align_t : uint32_t |
DMAC-pump byte-count alignment.
ra8_ceu_dma_pump requires a 4-byte multiple because the DMAC is configured for 32-bit transfers; this mask lets the helper test the lower bits cheaply.
| Enumerator | |
|---|---|
| k_ra8_ceu_dma_byte_align_mask | RA8 CEU DMA byte align mask. |
| k_ra8_ceu_dma_count_shift | divide-by-4 to convert bytes->words. |
| enum ra8_ceu_timing_t : uint32_t |
|
static |
Common arming sequence for capture_start / capture_start_ex.
See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.
| [in] | bufs | See header declaration for direction and constraints. |
| k_ra8_ok | Success path. |
| k_ra8_err_invalid_arg | Caller violated a precondition. |
Definition at line 478 of file ra8_ceu.c.
References internal_program_addresses(), k_ra8_ceu_capsr_mask_ce, k_ra8_ceu_capsr_mask_cpkil, k_ra8_ceu_cfwcr_mask_fwe, k_ra8_ceu_cfwcr_mask_fwv, k_ra8_ceu_cstsr_mask_cpton, k_ra8_ceu_fmt_data_enable, k_ra8_ceu_off_capsr, k_ra8_ceu_off_cetcr, k_ra8_ceu_off_cfwcr, k_ra8_ceu_off_cstsr, k_ra8_err_busy, k_ra8_ok, ra8_ceu_reg32(), s_ceu_capture_format, s_ceu_image_area, and ra8_ceu_buffers_t::y_top.
Referenced by ra8_ceu_capture_arm(), and ra8_ceu_capture_start_ex().
|
static |
True if ptr is non-NULL and 8-byte aligned.
See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.
| [in] | ptr | See header declaration for direction and constraints. |
| k_ra8_ok | Success path. |
| k_ra8_err_invalid_arg | Caller violated a precondition. |
Definition at line 194 of file ra8_ceu.c.
References k_ra8_ceu_buffer_align_mask.
Referenced by internal_validate_buffers().
|
static |
Apply caller-supplied buffer overrides to Plane B.
Each non-null pointer in bufs overwrites the matching CDxyR / CDxyR2 register in Plane B. bundle_size_bytes overrides CBDSR after rounding to the documented alignment mask.
| [in] | bufs | Caller-supplied buffer set; must not be nullptr. |
Definition at line 641 of file ra8_ceu.c.
References ra8_ceu_buffers_t::bundle_size_bytes, ra8_ceu_buffers_t::c_bottom, ra8_ceu_buffers_t::c_bottom_2, ra8_ceu_buffers_t::c_top, ra8_ceu_buffers_t::c_top_2, k_ra8_ceu_bundle_align_mask, k_ra8_ceu_off_cbdsr, k_ra8_ceu_off_cdacr, k_ra8_ceu_off_cdacr2, k_ra8_ceu_off_cdayr, k_ra8_ceu_off_cdayr2, k_ra8_ceu_off_cdbcr, k_ra8_ceu_off_cdbcr2, k_ra8_ceu_off_cdbyr, k_ra8_ceu_off_cdbyr2, k_ra8_ceu_plane_b_off, ra8_ceu_reg32_plane(), ra8_ceu_buffers_t::y_bottom, ra8_ceu_buffers_t::y_bottom_2, ra8_ceu_buffers_t::y_top, and ra8_ceu_buffers_t::y_top_2.
Referenced by ra8_ceu_plane_b_program().
|
static |
Mirror every 3-plane register from Plane A to Plane B.
HUM Ch 60.2 Table 60.4 "Register configuration of CEU" p 3629. Used by ra8_ceu_plane_b_program to build a clean baseline before the caller's per-bundle overrides are written on top.
Definition at line 594 of file ra8_ceu.c.
References k_ra8_ceu_off_camor, k_ra8_ceu_off_capwr, k_ra8_ceu_off_cbdsr, k_ra8_ceu_off_cdacr, k_ra8_ceu_off_cdacr2, k_ra8_ceu_off_cdayr, k_ra8_ceu_off_cdayr2, k_ra8_ceu_off_cdbcr, k_ra8_ceu_off_cdbcr2, k_ra8_ceu_off_cdbyr, k_ra8_ceu_off_cdbyr2, k_ra8_ceu_off_cdocr, k_ra8_ceu_off_cdwdr, k_ra8_ceu_off_cflcr, k_ra8_ceu_off_cfszr, k_ra8_ceu_off_clfcr, k_ra8_ceu_plane_a_off, k_ra8_ceu_plane_b_off, and ra8_ceu_reg32_plane().
Referenced by ra8_ceu_plane_b_program().
|
static |
Program the CDAYR / CDACR / CDBYR / CDBCR family on Plane A.
See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.
| [in] | bufs | See header declaration for direction and constraints. |
Definition at line 264 of file ra8_ceu.c.
References ra8_ceu_buffers_t::bundle_size_bytes, ra8_ceu_buffers_t::c_bottom, ra8_ceu_buffers_t::c_bottom_2, ra8_ceu_buffers_t::c_top, ra8_ceu_buffers_t::c_top_2, k_ra8_ceu_bundle_align_mask, k_ra8_ceu_off_cbdsr, k_ra8_ceu_off_cdacr, k_ra8_ceu_off_cdacr2, k_ra8_ceu_off_cdayr, k_ra8_ceu_off_cdayr2, k_ra8_ceu_off_cdbcr, k_ra8_ceu_off_cdbcr2, k_ra8_ceu_off_cdbyr, k_ra8_ceu_off_cdbyr2, ra8_ceu_reg32(), ra8_ceu_buffers_t::y_bottom, ra8_ceu_buffers_t::y_bottom_2, ra8_ceu_buffers_t::y_top, and ra8_ceu_buffers_t::y_top_2.
Referenced by internal_arm_capture().
|
static |
Validate every non-NULL pointer in a buffer bundle.
See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.
| [in] | bufs | See header declaration for direction and constraints. |
| k_ra8_ok | Success path. |
| k_ra8_err_invalid_arg | Caller violated a precondition. |
Definition at line 220 of file ra8_ceu.c.
References ra8_ceu_buffers_t::c_bottom, ra8_ceu_buffers_t::c_bottom_2, ra8_ceu_buffers_t::c_top, ra8_ceu_buffers_t::c_top_2, internal_is_aligned(), k_ra8_err_invalid_arg, k_ra8_ok, ra8_ceu_buffers_t::y_bottom, ra8_ceu_buffers_t::y_bottom_2, ra8_ceu_buffers_t::y_top, and ra8_ceu_buffers_t::y_top_2.
Referenced by ra8_ceu_capture_start_ex(), and ra8_ceu_plane_b_program().
|
static |
Bounded spin until CSTSR.CPTON and CAPSR.CPKIL both clear.
Polls the real two-register idle condition on every build. On host tests the loop-exit decision comes from the ra8_fake_mmio seam keyed on CSTSR (first-poll success unless a test arms a fault), so both the retry and the timeout legs are testable.
| k_ra8_ok | Success path. |
| k_ra8_err_hw_timeout | CPTON or CPKIL stuck past the budget. |
Definition at line 153 of file ra8_ceu.c.
References k_ra8_ceu_capsr_mask_cpkil, k_ra8_ceu_cstsr_mask_cpton, k_ra8_ceu_off_capsr, k_ra8_ceu_off_cstsr, k_ra8_ceu_reset_spin, k_ra8_err_hw_timeout, k_ra8_ok, and ra8_ceu_reg32().
Referenced by ra8_ceu_init(), and ra8_ceu_reset().
|
nodiscard |
Register a callback invoked by ra8_ceu_dispatch.
| [in] | fn | Callback function, or NULL to clear. |
| [in] | ctx | Opaque context forwarded as the first callback arg. |
| k_ra8_ok | Callback installed (or cleared). |
|
nodiscard |
Configure the bundle-write size (CBDSR).
HUM Ch 60.2.17 p 3660. The size is in bytes for data-enable mode or in lines for image / data-sync mode. The lower 3 bits are masked off by the hardware to enforce the 8-line/32-byte bundle alignment.
| [in] | size_bytes | Bundle size; aligned-down to 8 by the helper. |
| k_ra8_ok | Always. |
Definition at line 741 of file ra8_ceu.c.
References k_ra8_ceu_bundle_align_mask, k_ra8_ceu_off_cbdsr, k_ra8_ok, and ra8_ceu_reg32().
|
nodiscard |
Replace CDOCR byte-swap configuration in-place.
| [in] | swap | Non-NULL byte-swap descriptor. |
| k_ra8_ok | Updated. |
| k_ra8_err_null_ptr | swap was NULL. |
Definition at line 721 of file ra8_ceu.c.
References k_ra8_ceu_cdocr_mask_cobs, k_ra8_ceu_cdocr_mask_cols, k_ra8_ceu_cdocr_mask_cows, k_ra8_ceu_off_cdocr, k_ra8_ok, ra8_ceu_reg32(), RA8_CHECK_NULL_PTR, s_tag, ra8_ceu_byte_swap_t::swap_16_bit, ra8_ceu_byte_swap_t::swap_32_bit, and ra8_ceu_byte_swap_t::swap_8_bit.
|
nodiscard |
Arm a capture into the supplied buffer.
Writes the buffer base into CDAYR (and CDACR for image-capture mode), clears any pending CETCR flags, and finally sets CAPSR.CE=1. Capture begins on the next VD edge. The CETCR.CPE flag fires when the buffer is filled (single-shot) or at every frame boundary (continuous).
In data-enable-fetch mode the firewall (CFWCR) is automatically armed to image_area_size - 1 from the buffer base.
| [in] | buffer | Capture target. Must be non-NULL and 8-byte aligned. |
| k_ra8_ok | Capture armed; CE bit set. |
| k_ra8_err_null_ptr | buffer was NULL. |
| k_ra8_err_invalid_arg | buffer is not 8-byte aligned. |
| k_ra8_err_busy | A capture is already in progress (CSTSR.CPTON == 1) or a software reset is in flight (CAPSR.CPKIL == 1). |
Definition at line 521 of file ra8_ceu.c.
References internal_arm_capture(), k_ra8_ceu_buffer_align_mask, k_ra8_err_invalid_arg, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_log_info_val, and s_tag.
Referenced by ra8_ceu_capture_start().
|
nodiscard |
Stop the running capture by clearing CAPSR.CE.
Distinct from ra8_ceu_reset – this only clears the CE bit so the next VD does not start a new frame. Continuous-mode captures use this to break out cleanly without a CPKIL software reset.
| k_ra8_ok | Always. |
Definition at line 564 of file ra8_ceu.c.
References k_ra8_ceu_capsr_mask_ce, k_ra8_ceu_off_capsr, k_ra8_ok, and ra8_ceu_reg32().
Referenced by ra8_ceu_capture_stop().
|
nodiscard |
Enable or disable continuous-capture mode (CAPCR.CTNCP).
| [in] | mode | Single-shot or continuous. |
| k_ra8_ok | Always. |
Definition at line 759 of file ra8_ceu.c.
References k_ra8_ceu_capcr_mask_ctncp, k_ra8_ceu_capture_continuous, k_ra8_ceu_off_capcr, k_ra8_ok, and ra8_ceu_reg32().
|
nodiscard |
Start a single or continuous capture into the cached DMA buffer.
Wraps ra8_ceu_capture_arm with the buffer that was cached via ra8_ceu_set_dma_buffer. num_frames selects the capture mode:
| [in] | num_frames | 0 = continuous, otherwise number of frames. |
| k_ra8_ok | Capture armed. |
| k_ra8_err_invalid_state | No buffer cached via ra8_ceu_set_dma_buffer. |
| k_ra8_err_busy | CEU is already capturing. |
Definition at line 829 of file ra8_ceu.c.
References k_ra8_ceu_capcr_shift_ctncp, k_ra8_ceu_off_capcr, k_ra8_err_invalid_state, ra8_ceu_capture_arm(), ra8_ceu_reg32(), and s_ceu_dma_buf.
|
nodiscard |
Arm a capture using a full address bundle.
Like ra8_ceu_capture_start but lets the caller specify the C (chrominance) base, the bottom-field addresses (interlace), and the bundle-2 pair (ping-pong). Pointers left NULL leave the matching register at its previous value.
| [in] | bufs | Non-NULL buffer descriptor. |
| k_ra8_ok | Capture armed; CE set. |
| k_ra8_err_null_ptr | bufs was NULL or bufs->y_top NULL. |
| k_ra8_err_invalid_arg | Any non-NULL pointer fails 8-byte alignment. |
| k_ra8_err_busy | CSTSR.CPTON==1 or CAPSR.CPKIL==1. |
Definition at line 551 of file ra8_ceu.c.
References internal_arm_capture(), internal_validate_buffers(), k_ra8_ok, RA8_CHECK_NULL_PTR, s_tag, and ra8_ceu_buffers_t::y_top.
Referenced by internal_ceu_capture().
|
nodiscard |
Stop the in-flight capture started via ra8_ceu_capture_start.
Wraps ra8_ceu_capture_disarm so the high-level start/stop pair share matching names.
Definition at line 848 of file ra8_ceu.c.
References ra8_ceu_capture_disarm().
|
nodiscard |
Clear the CETCR event flags identified by mask.
CETCR is "write-0-to-clear" per HUM Ch 60.2.22 – writing the complement of mask clears exactly those bits. The driver does a read-modify-write so other in-flight flags survive.
| [in] | mask | Bitmask of k_ra8_ceu_evt_* values to clear. |
| k_ra8_ok | Always; mask of zero is a no-op. |
Definition at line 370 of file ra8_ceu.c.
References k_ra8_ceu_off_cetcr, k_ra8_ok, and ra8_ceu_reg32().
Referenced by internal_ceu_wait_for_frame().
|
nodiscard |
Return the byte count written by the last data-enable capture.
Reads CDSSR per HUM Ch 60.2.24 p 3674. Only meaningful after a data-enable-fetch capture completes; in image / data-sync modes this register stays at zero.
| [out] | out_bytes | Non-NULL byte-count receiver. |
| k_ra8_ok | Snapshot taken. |
| k_ra8_err_null_ptr | out_bytes was NULL. |
Definition at line 403 of file ra8_ceu.c.
References k_ra8_ceu_off_cdssr, k_ra8_ok, ra8_ceu_reg32(), RA8_CHECK_NULL_PTR, and s_tag.
|
nodiscard |
Stop the CEU and drop its module-stop bit.
Issues CAPSR.CPKIL=1 to abort any active capture, masks every interrupt source by writing 0 to CEIER, clears the registered callback, and finally calls ra8_mstp_disable(k_ra8_mstp_ceu).
| k_ra8_ok | Driver torn down, MSTP released. |
| k_ra8_err_hw_timeout | MSTP disable read-back failed. |
Definition at line 336 of file ra8_ceu.c.
References k_ra8_ceu_capsr_mask_cpkil, k_ra8_ceu_off_capsr, k_ra8_ceu_off_ceier, k_ra8_mstp_ceu, ra8_ceu_reg32(), ra8_mstp_disable(), s_ceu_ctx, s_ceu_dma_buf, s_ceu_dma_len, s_ceu_fn, s_ceu_image_area, and s_ceu_int_enable.
| void ra8_ceu_dispatch | ( | void | ) |
Drain CEU interrupt events and fire the registered callback.
Intended to be called from the CEU ISR (or from a soft-IRQ context fed by the ISR). Snapshots CETCR, clears the observed bits via write-0, and invokes the registered callback with the masked event set. The mask passed to the callback is gated by the currently-enabled CEIER bits.
Definition at line 427 of file ra8_ceu.c.
References k_ra8_ceu_off_cetcr, ra8_ceu_reg32(), s_ceu_ctx, s_ceu_fn, and s_ceu_int_enable.
|
nodiscard |
Pump a finished CEU bundle into a downstream DMAC channel.
The CEU writes pixels straight to SRAM/SDRAM via its own bus initiator, so it does not need the DMAC for the camera pixel path. This helper exists for the application-level pump that copies a completed CEU frame into a second buffer (e.g. ping-ponging frames into the GLCDC layer-2 framebuffer). It packages the existing ra8_dmac_start call with the CEU's preferred 32-bit / source+dest-incrementing layout.
| [in] | channel | DMAC channel index. |
| [in] | src | Source buffer (typically the CDAYR-pointed window). |
| [in] | dst | Destination buffer. |
| [in] | bytes | Bytes to copy (multiple of 4). |
| k_ra8_ok | DMAC channel armed. |
| k_ra8_err_null_ptr | src or dst was NULL. |
| k_ra8_err_invalid_arg | bytes not a multiple of 4 or 0. |
Definition at line 783 of file ra8_ceu.c.
References k_ra8_ceu_dma_byte_align_mask, k_ra8_ceu_dma_count_shift, k_ra8_dmac_width_word, k_ra8_err_invalid_arg, RA8_CHECK_NULL_PTR, ra8_dmac_start(), and s_tag.
|
nodiscard |
Stop active captures and drop the CEU module-stop bit.
| k_ra8_ok | CEU stopped + MSTP released. |
| k_ra8_err_hw_timeout | MSTP disable read-back failed. |
Definition at line 446 of file ra8_ceu.c.
References k_ra8_ceu_capsr_mask_cpkil, k_ra8_ceu_off_capsr, k_ra8_mstp_ceu, ra8_ceu_reg32(), and ra8_mstp_disable().
|
nodiscard |
Exit the MSTP-gated stop entered by ra8_ceu_enter_stop.
| k_ra8_ok | MSTP re-enabled, CEU window accessible. |
| k_ra8_err_hw_timeout | MSTP enable read-back failed. |
Definition at line 454 of file ra8_ceu.c.
References k_ra8_mstp_ceu, and ra8_mstp_enable().
|
nodiscard |
Configure the CFWCR firewall window.
HUM Ch 60.2.18 "CFWCR" p 3661. The firewall fires CETCR.FWF if the data-enable-fetch engine attempts a write past the supplied upper-bound address. Disabled if enable is false or the upper-bound is zero.
| [in] | enable | True to assert CFWCR.FWE. |
| [in] | upper_bound | Upper-bound address (lower 5 bits forced to 0x1F by the hardware). |
| k_ra8_ok | Always. |
Definition at line 709 of file ra8_ceu.c.
References k_ra8_ceu_cfwcr_mask_fwe, k_ra8_ceu_cfwcr_mask_fwv, k_ra8_ceu_off_cfwcr, k_ra8_ok, and ra8_ceu_reg32().
|
nodiscard |
Update the frame-drop counter (CAPCR.FDRP).
| [in] | count | Number of frames to skip between captures (0..255). |
| k_ra8_ok | Always. |
Definition at line 772 of file ra8_ceu.c.
References k_ra8_ceu_capcr_mask_fdrp, k_ra8_ceu_capcr_shift_fdrp, k_ra8_ceu_off_capcr, k_ra8_ok, and ra8_ceu_reg32().
|
nodiscard |
Snapshot the CEU event-status register (CETCR).
| [out] | out_mask | Receives the raw CETCR value. |
| k_ra8_ok | Snapshot taken. |
| k_ra8_err_null_ptr | out_mask was NULL. |
Definition at line 362 of file ra8_ceu.c.
References k_ra8_ceu_off_cetcr, k_ra8_ok, ra8_ceu_reg32(), RA8_CHECK_NULL_PTR, and s_tag.
|
nodiscard |
Power on the CEU and write the full configuration.
Steps performed:
| [in] | cfg | Non-NULL configuration descriptor. |
| k_ra8_ok | Capture engine powered + configured. |
| k_ra8_err_null_ptr | cfg was NULL. |
| k_ra8_err_invalid_arg | cfg->capture_mode is continuous in a non-image-capture format. |
| k_ra8_err_hw_timeout | MSTP enable failed or the reset-clear spin overran. |
Definition at line 300 of file ra8_ceu.c.
References ra8_ceu_config_t::capture_format, ra8_ceu_config_t::capture_mode, ra8_ceu_config_t::image_area_size, internal_wait_idle(), ra8_ceu_config_t::interrupts, k_ra8_ceu_capture_continuous, k_ra8_ceu_fmt_image_capture, k_ra8_ceu_off_ceier, k_ra8_err_invalid_arg, k_ra8_mstp_ceu, k_ra8_ok, priv_ra8_ceu_program_destination(), priv_ra8_ceu_program_format(), priv_ra8_ceu_program_geometry(), ra8_ceu_reg32(), RA8_CHECK_NULL_PTR, ra8_log_info_val, ra8_mstp_enable(), RA8_RETURN_ON_ERROR, s_ceu_capture_format, s_ceu_image_area, s_ceu_int_enable, s_tag, and ra8_ceu_config_t::width_px.
Referenced by ra8_camera_source_ceu_init().
|
nodiscard |
Update the CEIER interrupt-enable bitmask.
| [in] | mask | Bitwise-OR of k_ra8_ceu_evt_* values. |
| k_ra8_ok | Always. |
Definition at line 411 of file ra8_ceu.c.
References k_ra8_ceu_off_ceier, k_ra8_ok, ra8_ceu_reg32(), and s_ceu_int_enable.
|
nodiscard |
Enable or disable the input low-pass filter (CLFCR.LPF).
| [in] | enable | true => CLFCR.LPF = 1. |
| k_ra8_ok | Always. |
Definition at line 748 of file ra8_ceu.c.
References k_ra8_ceu_clfcr_mask_lpf, k_ra8_ceu_off_clfcr, k_ra8_ok, and ra8_ceu_reg32().
|
nodiscard |
Mirror the active configuration into Plane B and arm a swap.
Writes the current Plane A image of every 3-plane register into Plane B (offset +0x1000) and sets CRCNTR.RVS so the CEU swaps planes on the next VD edge. Used to apply a new geometry / new capture buffer without dropping a frame.
| [in] | bufs | Buffer bundle to install on Plane B; pass NULL to copy the existing Plane A addresses unchanged. |
| k_ra8_ok | Plane B armed. |
| k_ra8_err_invalid_arg | Any non-NULL pointer is misaligned. |
Definition at line 681 of file ra8_ceu.c.
References internal_plane_b_apply_overrides(), internal_plane_b_mirror_from_a(), internal_validate_buffers(), k_ra8_ceu_crcntr_mask_rc, k_ra8_ceu_crcntr_mask_rs, k_ra8_ceu_crcntr_mask_rvs, k_ra8_ceu_off_crcntr, k_ra8_ok, and ra8_ceu_reg32().
|
nodiscard |
Force an immediate plane swap (CRCMPR.RA).
HUM Ch 60.2.9 "CRCMPR" p 3649. Bypasses the VD-edge sync the normal Plane-B path uses; use only when a frame must be dropped.
| k_ra8_ok | Always. |
Definition at line 702 of file ra8_ceu.c.
References k_ra8_ceu_crcmpr_mask_ra, k_ra8_ceu_off_crcmpr, k_ra8_ok, and ra8_ceu_reg32().
|
nodiscard |
Issue a software reset of the capture state machine.
Sets CAPSR.CPKIL and spins on CSTSR.CPTON / CAPSR.CPKIL until both clear or the budget expires. Used to recover from a stuck capture (e.g. after a sensor stopped emitting VD edges).
| k_ra8_ok | Reset completed cleanly. |
| k_ra8_err_hw_timeout | Status bits did not clear in budget. |
Definition at line 355 of file ra8_ceu.c.
References internal_wait_idle(), k_ra8_ceu_capsr_mask_cpkil, k_ra8_ceu_off_capsr, and ra8_ceu_reg32().
Referenced by internal_ceu_wait_for_frame().
|
nodiscard |
Cache a DMAC-target framebuffer for the next ra8_ceu_capture_start call.
The CEU writes pixel data straight to memory via its own bus initiator, so the "DMA buffer" here is just the next CDAYR target the driver will arm when ra8_ceu_capture_start(num_frames) is called. The length is cached so the frame-end callback can hand the whole buffer back to the consumer.
| [in] | buf | Capture target (must be 8-byte aligned per HUM Ch 60.2.13 p 3656). |
| [in] | len | Buffer length in bytes (>0). |
| k_ra8_ok | Buffer cached. |
| k_ra8_err_null_ptr | buf was NULL. |
| k_ra8_err_invalid_arg | len was 0 or buf misaligned. |
Definition at line 814 of file ra8_ceu.c.
References k_ra8_ceu_buffer_align_mask, k_ra8_err_invalid_arg, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_log_info_val, s_ceu_dma_buf, s_ceu_dma_len, and s_tag.
|
nodiscard |
Snapshot CSTSR + CDSSR + the active plane into one struct.
| [out] | out | Non-NULL status struct to populate. |
| k_ra8_ok | Snapshot taken. |
| k_ra8_err_null_ptr | out was NULL. |
Definition at line 383 of file ra8_ceu.c.
References ra8_ceu_status_t::active_plane, ra8_ceu_status_t::capturing, ra8_ceu_status_t::data_size, ra8_ceu_status_t::events, k_ra8_ceu_capsr_mask_cpkil, k_ra8_ceu_cstsr_mask_cpfld, k_ra8_ceu_cstsr_mask_cpton, k_ra8_ceu_cstsr_mask_crst, k_ra8_ceu_off_capsr, k_ra8_ceu_off_cdssr, k_ra8_ceu_off_cetcr, k_ra8_ceu_off_cstsr, k_ra8_ceu_plane_a, k_ra8_ceu_plane_b, k_ra8_ok, ra8_ceu_reg32(), RA8_CHECK_NULL_PTR, ra8_ceu_status_t::reset_in_flight, s_tag, and ra8_ceu_status_t::top_field.
Referenced by internal_ceu_wait_for_frame().
|
static |
Cached CAMCR.JPG copy so capture_start can choose its path.
Definition at line 114 of file ra8_ceu.c.
Referenced by internal_arm_capture(), and ra8_ceu_init().
|
static |
Opaque context forwarded as the first argument to s_ceu_fn.
Definition at line 93 of file ra8_ceu.c.
Referenced by ra8_ceu_attach_handler(), ra8_ceu_deinit(), and ra8_ceu_dispatch().
|
static |
Cached DMAC-target buffer set via ra8_ceu_set_dma_buffer.
Definition at line 123 of file ra8_ceu.c.
Referenced by ra8_ceu_capture_start(), ra8_ceu_deinit(), and ra8_ceu_set_dma_buffer().
|
static |
Cached buffer length (bytes) for the next capture.
Definition at line 131 of file ra8_ceu.c.
Referenced by ra8_ceu_deinit(), and ra8_ceu_set_dma_buffer().
|
static |
Module-scope event callback registered by ra8_ceu_attach_handler.
Definition at line 87 of file ra8_ceu.c.
Referenced by ra8_ceu_attach_handler(), ra8_ceu_deinit(), and ra8_ceu_dispatch().
|
static |
Cached image_area_size from the most recent ra8_ceu_init.
Definition at line 108 of file ra8_ceu.c.
Referenced by internal_arm_capture(), ra8_ceu_deinit(), and ra8_ceu_init().
|
static |
Cached copy of CEIER – used to gate the dispatched event mask.
Definition at line 99 of file ra8_ceu.c.
Referenced by ra8_ceu_deinit(), ra8_ceu_dispatch(), ra8_ceu_init(), and ra8_ceu_interrupts_set().