|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
GLCDC piecewise-linear gamma correction driver. More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_check.h"#include "ra8_err.h"#include "ra8_glcdc.h"#include "ra8_glcdc_regs.h"#include "ra8_log.h"Go to the source code of this file.
Enumerations | |
| enum | ra8_glcdc_gam_reg_count_t : uint8_t { k_ra8_glcdc_gam_reg_count = 8U , k_ra8_glcdc_gam_pair_step = 2U } |
| Number of LUT and AREA registers per gamma channel block. More... | |
Functions | |
| static void | internal_write_lut (volatile ra8_glcdc_gam_t *gam, const uint16_t *gain) |
| Write one channel's 8 LUT (gain-pair) registers. | |
| static void | internal_write_area (volatile ra8_glcdc_gam_t *gam, const uint16_t *threshold) |
| Write one channel's 8 AREA (threshold-pair) registers. | |
| ra8_err_t | ra8_glcdc_set_gamma (ra8_glcdc_color_channel_t channel, const uint16_t *gain, const uint16_t *threshold, uint8_t count) |
| Programme the piecewise-linear gamma correction table for one channel. | |
| ra8_err_t | ra8_glcdc_gamma_enable (bool enable) |
| Enable or disable the GLCDC gamma correction pipeline. | |
Variables | |
| static const char * | s_tag = "GLCDC" |
GLCDC piecewise-linear gamma correction driver.
Implements per-channel gamma correction for the RA8D2 GLCDC output pipeline. The hardware provides three independent 16-segment piecewise-linear correction blocks (GAM[0]=R, GAM[1]=G, GAM[2]=B). Each block exposes eight 32-bit LUT registers (two 11-bit gain coefficients each) and eight 32-bit AREA registers (two 10-bit boundary thresholds each), together defining a 16-point correction curve per channel. The global enable/disable switch lives in the shared OUT block at k_ra8_glcdc_off_out_gamsw.
Every register access is preceded by a HUM Ch 63 citation.
Definition in file ra8_glcdc_gamma.c.
| enum ra8_glcdc_gam_reg_count_t : uint8_t |
Number of LUT and AREA registers per gamma channel block.
HUM Ch 63 "GAMx_LUTn Gamma Correction LUT Register" p 3790 lists LUT[0..7] (eight registers, two gains per register = 16 gain values). HUM Ch 63 "GAMx_AREAn Gamma Correction Area Register" p 3793 lists AREA[0..7] (eight registers, two thresholds per register = 16 values). k_ra8_glcdc_gamma_lut_depth / 2 = 8 gives the register count.
| Enumerator | |
|---|---|
| k_ra8_glcdc_gam_reg_count | LUT/AREA registers per channel (depth/2). |
| k_ra8_glcdc_gam_pair_step | Entries packed per register (2 per reg). |
Definition at line 51 of file ra8_glcdc_gamma.c.
|
static |
Write one channel's 8 AREA (threshold-pair) registers.
Packs successive pairs from threshold[] into GAMx_AREA[0..7]. The high 16-bit field (TH1, bits[25:16]) receives threshold[2*i]; the low 10-bit field (TH2, bits[9:0]) receives threshold[2*i+1].
| [in] | gam | Pointer to the channel's gamma register block. |
| [in] | threshold | Array of k_ra8_glcdc_gamma_lut_depth 10-bit threshold values. |
Definition at line 113 of file ra8_glcdc_gamma.c.
References ra8_glcdc_gam_t::AREA, k_ra8_glcdc_gam_area_th_h_shift, k_ra8_glcdc_gam_area_th_l_mask, k_ra8_glcdc_gam_pair_step, and k_ra8_glcdc_gam_reg_count.
Referenced by ra8_glcdc_set_gamma().
|
static |
Write one channel's 8 LUT (gain-pair) registers.
Packs successive pairs from gain[] into GAMx_LUT[0..7]. The high 16-bit field (GAIN0, bits[26:16]) receives gain[2*i]; the low 11-bit field (GAIN1, bits[10:0]) receives gain[2*i+1].
| [in] | gam | Pointer to the channel's gamma register block. |
| [in] | gain | Array of k_ra8_glcdc_gamma_lut_depth 11-bit gain values. |
Definition at line 81 of file ra8_glcdc_gamma.c.
References k_ra8_glcdc_gam_lut_gain_h_shift, k_ra8_glcdc_gam_lut_gain_l_mask, k_ra8_glcdc_gam_pair_step, k_ra8_glcdc_gam_reg_count, and ra8_glcdc_gam_t::LUT.
Referenced by ra8_glcdc_set_gamma().
|
nodiscard |
Enable or disable the GLCDC gamma correction pipeline.
Writes the GAMSW.GAMON bit (bit 0) in the output-control block, which gates the piecewise-linear correction circuit for all three colour channels. Call after programming all three channel tables with ra8_glcdc_set_gamma().
| [in] | enable | true to activate gamma correction; false to bypass it. |
| k_ra8_ok | GAMSW register updated. |
| k_ra8_err_null_ptr | GAMSW register address could not be resolved (should not occur in normal operation). |
Definition at line 155 of file ra8_glcdc_gamma.c.
References k_ra8_glcdc_gamsw_gamon, k_ra8_glcdc_off_out_gamsw, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_glcdc_reg32(), ra8_log_info_val, and s_tag.
|
nodiscard |
Programme the piecewise-linear gamma correction table for one channel.
Writes the 8 GAMx_LUTn gain-pair registers and the 8 GAMx_AREAn threshold-pair registers for the selected colour channel. Each LUT register packs two 11-bit gain coefficients (GAIN0 in bits[26:16], GAIN1 in bits[10:0]); each AREA register packs two 10-bit boundary values (TH1 in bits[25:16], TH2 in bits[9:0]). Call ra8_glcdc_gamma_enable(true) after programming all three channels to activate the correction pipeline.
| [in] | channel | Colour channel to program (R, G, or B). |
| [in] | gain | Array of k_ra8_glcdc_gamma_lut_depth 11-bit gain values (0..2047). gain[0] corresponds to GAIN0 of LUT[0]. |
| [in] | threshold | Array of k_ra8_glcdc_gamma_lut_depth 10-bit boundary values (0..1023). threshold[0] corresponds to TH1 of AREA[0]. |
| [in] | count | Must equal k_ra8_glcdc_gamma_lut_depth (16); enforced. |
| k_ra8_ok | LUT and AREA registers written. |
| k_ra8_err_null_ptr | gain or threshold is NULL. |
| k_ra8_err_invalid_arg | channel >= k_ra8_glcdc_ch_count, or count != k_ra8_glcdc_gamma_lut_depth. |
Definition at line 131 of file ra8_glcdc_gamma.c.
References internal_write_area(), internal_write_lut(), k_ra8_err_invalid_arg, k_ra8_glcdc_ch_count, k_ra8_glcdc_gamma_lut_depth, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_glcdc_gam_regs(), ra8_log_info_val, and s_tag.
|
static |
Definition at line 33 of file ra8_glcdc_gamma.c.