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

Capture Engine Unit (CEU) init-time register programming. More...

#include <stdint.h>
#include "ra8_attributes.h"
#include "ra8_ceu.h"
#include "ra8_ceu_internal.h"
#include "ra8_ceu_regs.h"
Include dependency graph for ra8_ceu_init_regs.c:

Go to the source code of this file.

Functions

static uint32_t internal_pack_camcr (const ra8_ceu_config_t *cfg)
 Build the CAMCR value from a configuration descriptor.
static uint32_t internal_pack_capcr (const ra8_ceu_config_t *cfg)
 Build the CAPCR value from a configuration descriptor.
static uint32_t internal_pack_caifr (const ra8_ceu_config_t *cfg)
 Build the CAIFR value from a configuration descriptor.
static uint32_t internal_pack_cflcr (const ra8_ceu_config_t *cfg)
 Build the CFLCR value from a configuration descriptor.
static uint32_t internal_pack_cfszr (const ra8_ceu_config_t *cfg)
 Build the CFSZR value from a configuration descriptor.
static uint32_t internal_pack_cdocr (const ra8_ceu_config_t *cfg)
 Build the CDOCR value from a configuration descriptor.
void priv_ra8_ceu_program_geometry (const ra8_ceu_config_t *cfg)
 Program the CMCYR/CAMOR/CAPWR geometry registers.
void priv_ra8_ceu_program_format (const ra8_ceu_config_t *cfg)
 Program filter / format / camera-interface registers.
void priv_ra8_ceu_program_destination (const ra8_ceu_config_t *cfg)
 Program destination / firewall / output / event registers.

Detailed Description

Capture Engine Unit (CEU) init-time register programming.

Tag
[Ring 3 / HAL] {World: NS}

Configuration-time half of the RA8D2 Capture Engine Unit driver, split out of ra8_ceu.c to keep both translation units under the file-size cap. This TU owns the ra8_ceu_config_t-to-register packing (CAMCR / CAPCR / CAIFR / CFLCR / CFSZR / CDOCR) and the three ra8_ceu_program_* phases that ra8_ceu_init drives. The runtime-control entry points (capture start/stop, plane-B shadow, status, dispatch) remain in ra8_ceu.c. Register sequences are cited out of HUM Ch 60 (p 3626-3682).

Definition in file ra8_ceu_init_regs.c.

Function Documentation

◆ internal_pack_caifr()

uint32_t internal_pack_caifr ( const ra8_ceu_config_t * cfg)
static

Build the CAIFR value from a configuration descriptor.

See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.

Parameters
[in]cfgSee header declaration for direction and constraints.
Returns
ra8_err_t error code (or void if the signature returns void).
Return values
k_ra8_okSuccess path.
k_ra8_err_invalid_argCaller violated a precondition.
Precondition
Driver state has been initialized by the matching *_init.
Caller has validated all pointer parameters.
Postcondition
Side effects are limited to those documented in the header.
No global state is modified on the error path.
Note
Thread safety: see the header declaration.
Since
0.1.0

Definition at line 111 of file ra8_ceu_init_regs.c.

References ra8_ceu_config_t::first_field, ra8_ceu_config_t::interlace, k_ra8_ceu_caifr_shift_cim, k_ra8_ceu_caifr_shift_fci, k_ra8_ceu_caifr_shift_ifs, and ra8_ceu_config_t::one_field_only.

Referenced by priv_ra8_ceu_program_format().

◆ internal_pack_camcr()

uint32_t internal_pack_camcr ( const ra8_ceu_config_t * cfg)
static

Build the CAMCR value from a configuration descriptor.

Parameters
[in]cfgNon-NULL config (caller already validated).
Returns
Packed CAMCR word.

See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.

Return values
k_ra8_okSuccess path.
k_ra8_err_invalid_argCaller violated a precondition.
Precondition
Driver state has been initialized by the matching *_init.
Caller has validated all pointer parameters.
Postcondition
Side effects are limited to those documented in the header.
No global state is modified on the error path.
Note
Thread safety: see the header declaration.
Since
0.1.0

Definition at line 48 of file ra8_ceu_init_regs.c.

References ra8_ceu_config_t::capture_format, ra8_ceu_edge_info_t::data, ra8_ceu_config_t::data_bus, ra8_ceu_config_t::edge, ra8_ceu_edge_info_t::field, ra8_ceu_config_t::field_polarity, ra8_ceu_edge_info_t::hsync, ra8_ceu_config_t::hsync_polarity, ra8_ceu_config_t::input_order, k_ra8_ceu_camcr_shift_dsel, k_ra8_ceu_camcr_shift_dtary, k_ra8_ceu_camcr_shift_dtif, k_ra8_ceu_camcr_shift_fldpol, k_ra8_ceu_camcr_shift_fldsel, k_ra8_ceu_camcr_shift_hdpol, k_ra8_ceu_camcr_shift_hdsel, k_ra8_ceu_camcr_shift_jpg, k_ra8_ceu_camcr_shift_vdpol, k_ra8_ceu_camcr_shift_vdsel, ra8_ceu_edge_info_t::vsync, and ra8_ceu_config_t::vsync_polarity.

Referenced by priv_ra8_ceu_program_format().

◆ internal_pack_capcr()

uint32_t internal_pack_capcr ( const ra8_ceu_config_t * cfg)
static

Build the CAPCR value from a configuration descriptor.

See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.

Parameters
[in]cfgSee header declaration for direction and constraints.
Returns
ra8_err_t error code (or void if the signature returns void).
Return values
k_ra8_okSuccess path.
k_ra8_err_invalid_argCaller violated a precondition.
Precondition
Driver state has been initialized by the matching *_init.
Caller has validated all pointer parameters.
Postcondition
Side effects are limited to those documented in the header.
No global state is modified on the error path.
Note
Thread safety: see the header declaration.
Since
0.1.0

Definition at line 82 of file ra8_ceu_init_regs.c.

References ra8_ceu_config_t::burst_mode, ra8_ceu_config_t::capture_mode, ra8_ceu_config_t::frame_drop, k_ra8_ceu_capcr_shift_ctncp, k_ra8_ceu_capcr_shift_fdrp, k_ra8_ceu_capcr_shift_mtcm, and k_ra8_ceu_capture_continuous.

Referenced by priv_ra8_ceu_program_format().

◆ internal_pack_cdocr()

uint32_t internal_pack_cdocr ( const ra8_ceu_config_t * cfg)
static

Build the CDOCR value from a configuration descriptor.

See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.

Parameters
[in]cfgSee header declaration for direction and constraints.
Returns
ra8_err_t error code (or void if the signature returns void).
Return values
k_ra8_okSuccess path.
k_ra8_err_invalid_argCaller violated a precondition.
Precondition
Driver state has been initialized by the matching *_init.
Caller has validated all pointer parameters.
Postcondition
Side effects are limited to those documented in the header.
No global state is modified on the error path.
Note
Thread safety: see the header declaration.
Since
0.1.0

Definition at line 202 of file ra8_ceu_init_regs.c.

References ra8_ceu_config_t::bundle_write, ra8_ceu_config_t::byte_swap, k_ra8_ceu_cdocr_mask_cbe, k_ra8_ceu_cdocr_mask_cds, k_ra8_ceu_cdocr_mask_cobs, k_ra8_ceu_cdocr_mask_cols, k_ra8_ceu_cdocr_mask_cows, k_ra8_ceu_cdocr_shift_cds, ra8_ceu_config_t::output_format, 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.

Referenced by priv_ra8_ceu_program_destination().

◆ internal_pack_cflcr()

uint32_t internal_pack_cflcr ( const ra8_ceu_config_t * cfg)
static

Build the CFLCR value from a configuration descriptor.

See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.

Parameters
[in]cfgSee header declaration for direction and constraints.
Returns
ra8_err_t error code (or void if the signature returns void).
Return values
k_ra8_okSuccess path.
k_ra8_err_invalid_argCaller violated a precondition.
Precondition
Driver state has been initialized by the matching *_init.
Caller has validated all pointer parameters.
Postcondition
Side effects are limited to those documented in the header.
No global state is modified on the error path.
Note
Thread safety: see the header declaration.
Since
0.1.0

Definition at line 142 of file ra8_ceu_init_regs.c.

References ra8_ceu_scale_t::h_fraction, ra8_ceu_scale_t::h_mantissa, k_ra8_ceu_cflcr_mask_hfrac, k_ra8_ceu_cflcr_mask_hmant, k_ra8_ceu_cflcr_mask_vfrac, k_ra8_ceu_cflcr_mask_vmant, k_ra8_ceu_cflcr_shift_hfrac, k_ra8_ceu_cflcr_shift_hmant, k_ra8_ceu_cflcr_shift_vfrac, k_ra8_ceu_cflcr_shift_vmant, ra8_ceu_config_t::scale, ra8_ceu_scale_t::v_fraction, and ra8_ceu_scale_t::v_mantissa.

Referenced by priv_ra8_ceu_program_format().

◆ internal_pack_cfszr()

uint32_t internal_pack_cfszr ( const ra8_ceu_config_t * cfg)
static

Build the CFSZR value from a configuration descriptor.

See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.

Parameters
[in]cfgSee header declaration for direction and constraints.
Returns
ra8_err_t error code (or void if the signature returns void).
Return values
k_ra8_okSuccess path.
k_ra8_err_invalid_argCaller violated a precondition.
Precondition
Driver state has been initialized by the matching *_init.
Caller has validated all pointer parameters.
Postcondition
Side effects are limited to those documented in the header.
No global state is modified on the error path.
Note
Thread safety: see the header declaration.
Since
0.1.0

Definition at line 174 of file ra8_ceu_init_regs.c.

References ra8_ceu_scale_t::h_output_clip, k_ra8_ceu_cfszr_mask_hfclp, k_ra8_ceu_cfszr_mask_vfclp, k_ra8_ceu_cfszr_shift_hfclp, k_ra8_ceu_cfszr_shift_vfclp, ra8_ceu_config_t::scale, and ra8_ceu_scale_t::v_output_clip.

Referenced by priv_ra8_ceu_program_destination().

◆ priv_ra8_ceu_program_destination()

void priv_ra8_ceu_program_destination ( const ra8_ceu_config_t * cfg)

Program destination / firewall / output / event registers.

HUM Ch 60.2.11-60.2.22 pp 3651-3664. Post-geometry phase of ra8_ceu_init. Promoted from a TU-private static so ra8_ceu_init (in ra8_ceu.c) can call it while the implementation lives in ra8_ceu_init_regs.c.

Parameters
[in]cfgValidated config; must not be nullptr.
Precondition
Module clock ungated, geometry registers programmed.
Caller has validated cfg is non-nullptr.
Postcondition
Listed registers reflect cfg.
No other module state is modified.
Note
Internal helper, not thread-safe.
Since
0.1.0

Definition at line 264 of file ra8_ceu_init_regs.c.

References ra8_ceu_config_t::dst_stride, internal_pack_cdocr(), internal_pack_cfszr(), k_ra8_ceu_off_cdocr, k_ra8_ceu_off_cdwdr, k_ra8_ceu_off_cetcr, k_ra8_ceu_off_cfszr, k_ra8_ceu_off_cfwcr, k_ra8_ceu_off_clfcr, ra8_ceu_config_t::low_pass_filter, and ra8_ceu_reg32().

Referenced by ra8_ceu_init().

◆ priv_ra8_ceu_program_format()

void priv_ra8_ceu_program_format ( const ra8_ceu_config_t * cfg)

Program filter / format / camera-interface registers.

HUM Ch 60.2.10 (CFLCR), 60.2.7 (CAIFR), 60.2.2 (CAPCR), 60.2.3 (CAMCR). Pre-geometry phase of ra8_ceu_init. Promoted from a TU-private static so ra8_ceu_init (in ra8_ceu.c) can call it while the implementation lives in ra8_ceu_init_regs.c.

Parameters
[in]cfgValidated config; must not be nullptr.
Precondition
Module clock ungated, engine idle.
Caller has validated cfg is non-nullptr.
Postcondition
Listed registers reflect cfg.
No other module state is modified.
Note
Internal helper, not thread-safe.
Since
0.1.0

Definition at line 256 of file ra8_ceu_init_regs.c.

References internal_pack_caifr(), internal_pack_camcr(), internal_pack_capcr(), internal_pack_cflcr(), k_ra8_ceu_off_caifr, k_ra8_ceu_off_camcr, k_ra8_ceu_off_capcr, k_ra8_ceu_off_cflcr, and ra8_ceu_reg32().

Referenced by ra8_ceu_init().

◆ priv_ra8_ceu_program_geometry()

void priv_ra8_ceu_program_geometry ( const ra8_ceu_config_t * cfg)

Program the CMCYR/CAMOR/CAPWR geometry registers.

HUM Ch 60.2.4 (CMCYR p 3641), 60.2.5 (CAMOR p 3645) and 60.2.6 (CAPWR p 3646). Falls back to width_px / height_px when the caller leaves x_capture_px / y_capture_lines at zero. Promoted from a TU-private static so ra8_ceu_init (in ra8_ceu.c) can call it while the implementation lives in ra8_ceu_init_regs.c.

Parameters
[in]cfgCaller-supplied config; must not be nullptr.
Precondition
Module clock ungated, engine idle.
Caller has validated cfg is non-nullptr.
Postcondition
Geometry registers reflect cfg.
No other module state is modified.
Note
Internal helper, not thread-safe.
Since
0.1.0

Definition at line 221 of file ra8_ceu_init_regs.c.

References ra8_ceu_config_t::capture_format, ra8_ceu_config_t::height_px, k_ra8_ceu_camor_shift_vofst, k_ra8_ceu_capwr_shift_vwdth, k_ra8_ceu_cmcyr_shift_vcyl, k_ra8_ceu_fmt_data_enable, k_ra8_ceu_off_camor, k_ra8_ceu_off_capwr, k_ra8_ceu_off_cmcyr, ra8_ceu_reg32(), ra8_ceu_config_t::width_px, ra8_ceu_config_t::x_capture_px, ra8_ceu_config_t::x_start_px, ra8_ceu_config_t::y_capture_lines, and ra8_ceu_config_t::y_start_px.

Referenced by ra8_ceu_init().