Skip to content

Commit 9f717ba

Browse files
Danh DoanKhiemNguyenT
authored andcommitted
hal: renesas: ra: Initial support for display controller
Add commit to support these features: - Add support for r_glcdc - Add support for r_icu Signed-off-by: Danh Doan <[email protected]>
1 parent 16a7547 commit 9f717ba

File tree

8 files changed

+3431
-0
lines changed

8 files changed

+3431
-0
lines changed

drivers/ra/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ zephyr_library_sources_ifdef(CONFIG_USE_RA_FSP_OSPI_B_NOR_FLASH
5959
fsp/src/r_ospi_b/r_ospi_b.c)
6060
zephyr_library_sources_ifdef(CONFIG_USE_RA_FSP_SDRAM
6161
fsp/src/bsp/mcu/all/bsp_sdram.c)
62+
zephyr_library_sources_ifdef(CONFIG_USE_RA_FSP_DISPLAY
63+
fsp/src/r_glcdc/r_glcdc.c)
6264

6365
if(CONFIG_USE_RA_FSP_SCE)
6466
zephyr_include_directories(

drivers/ra/fsp/inc/api/r_display_api.h

Lines changed: 453 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
/*
2+
* Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
/*******************************************************************************************************************//**
8+
* @ingroup RENESAS_INPUT_INTERFACES
9+
* @defgroup EXTERNAL_IRQ_API External IRQ Interface
10+
* @brief Interface for detecting external interrupts.
11+
*
12+
* @section EXTERNAL_IRQ_API_Summary Summary
13+
* The External IRQ Interface is for configuring interrupts to fire when a trigger condition is detected on an
14+
* external IRQ pin.
15+
*
16+
*
17+
* @{
18+
**********************************************************************************************************************/
19+
20+
#ifndef R_EXTERNAL_IRQ_API_H
21+
#define R_EXTERNAL_IRQ_API_H
22+
23+
/***********************************************************************************************************************
24+
* Includes
25+
**********************************************************************************************************************/
26+
27+
/* Includes board and MCU related header files. */
28+
#include "bsp_api.h"
29+
30+
/* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */
31+
FSP_HEADER
32+
33+
/**********************************************************************************************************************
34+
* Macro definitions
35+
*********************************************************************************************************************/
36+
37+
/*********************************************************************************************************************
38+
* Typedef definitions
39+
*********************************************************************************************************************/
40+
41+
/** Callback function parameter data */
42+
typedef struct st_external_irq_callback_args
43+
{
44+
/** Placeholder for user data. Set in @ref external_irq_api_t::open function in @ref external_irq_cfg_t. */
45+
void const * p_context;
46+
uint32_t channel; ///< The physical hardware channel that caused the interrupt.
47+
} external_irq_callback_args_t;
48+
49+
#ifndef BSP_OVERRIDE_EXTERNAL_IRQ_TRIGGER_T
50+
51+
/** Condition that will trigger an interrupt when detected. */
52+
typedef enum e_external_irq_trigger
53+
{
54+
EXTERNAL_IRQ_TRIG_FALLING = 0, ///< Falling edge trigger
55+
EXTERNAL_IRQ_TRIG_RISING = 1, ///< Rising edge trigger
56+
EXTERNAL_IRQ_TRIG_BOTH_EDGE = 2, ///< Both edges trigger
57+
EXTERNAL_IRQ_TRIG_LEVEL_LOW = 3, ///< Low level trigger
58+
EXTERNAL_IRQ_TRIG_LEVEL_HIGH = 4 ///< High level trigger
59+
} external_irq_trigger_t;
60+
#endif
61+
62+
#ifndef BSP_OVERRIDE_EXTERNAL_IRQ_PCLK_DIV_T
63+
64+
/** External IRQ input pin digital filtering sample clock divisor settings. The digital filter rejects trigger
65+
* conditions that are shorter than 3 periods of the filter clock.
66+
*/
67+
typedef enum e_external_irq_clock_source_div
68+
{
69+
EXTERNAL_IRQ_CLOCK_SOURCE_DIV_1 = 0, ///< Filter using clock source divided by 1
70+
EXTERNAL_IRQ_CLOCK_SOURCE_DIV_8 = 1, ///< Filter using clock source divided by 8
71+
EXTERNAL_IRQ_CLOCK_SOURCE_DIV_32 = 2, ///< Filter using clock source divided by 32
72+
EXTERNAL_IRQ_CLOCK_SOURCE_DIV_64 = 3, ///< Filter using clock source divided by 64
73+
} external_irq_clock_source_div_t;
74+
#endif
75+
76+
/** User configuration structure, used in open function */
77+
typedef struct st_external_irq_cfg
78+
{
79+
uint8_t channel; ///< Hardware channel used.
80+
uint8_t ipl; ///< Interrupt priority
81+
IRQn_Type irq; ///< Interrupt number assigned to this instance
82+
external_irq_trigger_t trigger; ///< Trigger setting.
83+
external_irq_clock_source_div_t clock_source_div; ///< Digital filter clock divisor setting.
84+
bool filter_enable; ///< Digital filter enable/disable setting.
85+
86+
/** Callback provided external input trigger occurs. */
87+
void (* p_callback)(external_irq_callback_args_t * p_args);
88+
89+
/** Placeholder for user data. Passed to the user callback in @ref external_irq_callback_args_t. */
90+
void const * p_context;
91+
void const * p_extend; ///< External IRQ hardware dependent configuration.
92+
} external_irq_cfg_t;
93+
94+
/** External IRQ control block. Allocate an instance specific control block to pass into the external IRQ API calls.
95+
*/
96+
typedef void external_irq_ctrl_t;
97+
98+
/** External interrupt driver structure. External interrupt functions implemented at the HAL layer will follow this API. */
99+
typedef struct st_external_irq_api
100+
{
101+
/** Initial configuration.
102+
*
103+
* @param[out] p_ctrl Pointer to control block. Must be declared by user. Value set here.
104+
* @param[in] p_cfg Pointer to configuration structure. All elements of the structure must be set by user.
105+
*/
106+
fsp_err_t (* open)(external_irq_ctrl_t * const p_ctrl, external_irq_cfg_t const * const p_cfg);
107+
108+
/** Enable callback when an external trigger condition occurs.
109+
*
110+
* @param[in] p_ctrl Control block set in Open call for this external interrupt.
111+
*/
112+
fsp_err_t (* enable)(external_irq_ctrl_t * const p_ctrl);
113+
114+
/** Disable callback when external trigger condition occurs.
115+
*
116+
* @param[in] p_ctrl Control block set in Open call for this external interrupt.
117+
*/
118+
fsp_err_t (* disable)(external_irq_ctrl_t * const p_ctrl);
119+
120+
/**
121+
* Specify callback function and optional context pointer and working memory pointer.
122+
*
123+
* @param[in] p_ctrl Pointer to the External IRQ control block.
124+
* @param[in] p_callback Callback function
125+
* @param[in] p_context Pointer to send to callback function
126+
* @param[in] p_working_memory Pointer to volatile memory where callback structure can be allocated.
127+
* Callback arguments allocated here are only valid during the callback.
128+
*/
129+
fsp_err_t (* callbackSet)(external_irq_ctrl_t * const p_ctrl, void (* p_callback)(external_irq_callback_args_t *),
130+
void const * const p_context, external_irq_callback_args_t * const p_callback_memory);
131+
132+
/** Allow driver to be reconfigured. May reduce power consumption.
133+
*
134+
* @param[in] p_ctrl Control block set in Open call for this external interrupt.
135+
*/
136+
fsp_err_t (* close)(external_irq_ctrl_t * const p_ctrl);
137+
} external_irq_api_t;
138+
139+
/** This structure encompasses everything that is needed to use an instance of this interface. */
140+
typedef struct st_external_irq_instance
141+
{
142+
external_irq_ctrl_t * p_ctrl; ///< Pointer to the control structure for this instance
143+
external_irq_cfg_t const * p_cfg; ///< Pointer to the configuration structure for this instance
144+
external_irq_api_t const * p_api; ///< Pointer to the API structure for this instance
145+
} external_irq_instance_t;
146+
147+
/* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */
148+
FSP_FOOTER
149+
150+
/*******************************************************************************************************************//**
151+
* @} (end defgroup EXTERNAL_IRQ_API)
152+
**********************************************************************************************************************/
153+
154+
#endif
Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
/*
2+
* Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
/*******************************************************************************************************************//**
8+
* @addtogroup GLCDC
9+
* @{
10+
**********************************************************************************************************************/
11+
12+
#ifndef R_GLCDC_H
13+
#define R_GLCDC_H
14+
15+
/***********************************************************************************************************************
16+
* Includes
17+
**********************************************************************************************************************/
18+
#include "bsp_api.h"
19+
#include "r_display_api.h"
20+
21+
/* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */
22+
FSP_HEADER
23+
24+
/***********************************************************************************************************************
25+
* Macro definitions
26+
**********************************************************************************************************************/
27+
28+
/***********************************************************************************************************************
29+
* Typedef definitions
30+
**********************************************************************************************************************/
31+
32+
/** Display control block. DO NOT INITIALIZE. */
33+
typedef struct st_glcdc_instance_ctrl
34+
{
35+
display_state_t state; // Status of GLCDC module
36+
37+
/* Parameters to Event processing for display devices */
38+
void (* p_callback)(display_callback_args_t * p_args); // Pointer to callback function
39+
void const * p_context; // Pointer to the higher level device context
40+
const display_cfg_t * p_cfg; // Pointer to initial configurations
41+
} glcdc_instance_ctrl_t;
42+
43+
/** Clock source select */
44+
typedef enum e_glcdc_clk_src
45+
{
46+
GLCDC_CLK_SRC_INTERNAL, ///< Internal
47+
GLCDC_CLK_SRC_EXTERNAL, ///< External
48+
} glcdc_clk_src_t;
49+
50+
/** Clock frequency division ratio */
51+
typedef enum e_glcdc_panel_clk_div
52+
{
53+
GLCDC_PANEL_CLK_DIVISOR_1 = 1, ///< Division Ratio 1/1
54+
GLCDC_PANEL_CLK_DIVISOR_2 = 2, ///< Division Ratio 1/2
55+
GLCDC_PANEL_CLK_DIVISOR_3 = 3, ///< Division Ratio 1/3
56+
GLCDC_PANEL_CLK_DIVISOR_4 = 4, ///< Division Ratio 1/4
57+
GLCDC_PANEL_CLK_DIVISOR_5 = 5, ///< Division Ratio 1/5
58+
GLCDC_PANEL_CLK_DIVISOR_6 = 6, ///< Division Ratio 1/6
59+
GLCDC_PANEL_CLK_DIVISOR_7 = 7, ///< Division Ratio 1/7
60+
GLCDC_PANEL_CLK_DIVISOR_8 = 8, ///< Division Ratio 1/8
61+
GLCDC_PANEL_CLK_DIVISOR_9 = 9, ///< Division Ratio 1/9
62+
GLCDC_PANEL_CLK_DIVISOR_12 = 12, ///< Division Ratio 1/12
63+
GLCDC_PANEL_CLK_DIVISOR_16 = 16, ///< Division Ratio 1/16
64+
GLCDC_PANEL_CLK_DIVISOR_24 = 24, ///< Division Ratio 1/24
65+
GLCDC_PANEL_CLK_DIVISOR_32 = 32, ///< Division Ratio 1/32
66+
} glcdc_panel_clk_div_t;
67+
68+
/** LCD TCON output pin select */
69+
typedef enum e_glcdc_tcon_pin
70+
{
71+
GLCDC_TCON_PIN_NONE = -1, ///< No output
72+
GLCDC_TCON_PIN_0, ///< LCD_TCON0
73+
GLCDC_TCON_PIN_1, ///< LCD_TCON1
74+
GLCDC_TCON_PIN_2, ///< LCD_TCON2
75+
GLCDC_TCON_PIN_3, ///< LCD_TCON3
76+
} glcdc_tcon_pin_t;
77+
78+
/** Bus Arbitration setting */
79+
typedef enum e_glcdc_bus_arbitraion
80+
{
81+
GLCDC_BUS_ARBITRATION_ROUNDROBIN, ///< Round robin
82+
GLCDC_BUS_ARBITRATION_FIX_PRIORITY ///< Fixed
83+
} glcdc_bus_arbitration_t;
84+
85+
/** Correction circuit sequence control */
86+
typedef enum e_glcdc_correction_proc_order
87+
{
88+
GLCDC_CORRECTION_PROC_ORDER_BRIGHTNESS_CONTRAST2GAMMA, ///< Brightness -> contrast -> gamma correction
89+
GLCDC_CORRECTION_PROC_ORDER_GAMMA2BRIGHTNESS_CONTRAST ///< Gamma correction -> brightness -> contrast
90+
} glcdc_correction_proc_order_t;
91+
92+
/** Timing signals for driving the LCD panel */
93+
typedef enum e_glcdc_tcon_signal_select
94+
{
95+
GLCDC_TCON_SIGNAL_SELECT_STVA_VS = 0, ///< STVA/VS
96+
GLCDC_TCON_SIGNAL_SELECT_STVB_VE = 1, ///< STVB/VE
97+
GLCDC_TCON_SIGNAL_SELECT_STHA_HS = 2, ///< STH/SP/HS
98+
GLCDC_TCON_SIGNAL_SELECT_STHB_HE = 3, ///< STB/LP/HE
99+
GLCDC_TCON_SIGNAL_SELECT_DE = 7 ///< DE
100+
} glcdc_tcon_signal_select_t;
101+
102+
/** Clock phase adjustment for serial RGB output */
103+
typedef enum e_glcdc_clut_plane
104+
{
105+
GLCDC_CLUT_PLANE_0 = 0, ///< GLCDC CLUT plane 0
106+
GLCDC_CLUT_PLANE_1 = 1, ///< GLCDC CLUT plane 1
107+
} glcdc_clut_plane_t;
108+
109+
/** Dithering mode */
110+
typedef enum e_glcdc_dithering_mode
111+
{
112+
GLCDC_DITHERING_MODE_TRUNCATE = 0, ///< No dithering (truncate)
113+
GLCDC_DITHERING_MODE_ROUND_OFF = 1, ///< Dithering with round off
114+
GLCDC_DITHERING_MODE_2X2PATTERN = 2, ///< Dithering with 2x2 pattern
115+
GLCDC_DITHERING_MODE_SETTING_MAX
116+
} glcdc_dithering_mode_t;
117+
118+
/** Dithering mode */
119+
typedef enum e_glcdc_dithering_pattern
120+
{
121+
GLCDC_DITHERING_PATTERN_00 = 0, ///< 2x2 pattern '00'
122+
GLCDC_DITHERING_PATTERN_01 = 1, ///< 2x2 pattern '01'
123+
GLCDC_DITHERING_PATTERN_10 = 2, ///< 2x2 pattern '10'
124+
GLCDC_DITHERING_PATTERN_11 = 3, ///< 2x2 pattern '11'
125+
} glcdc_dithering_pattern_t;
126+
127+
/** Output interface format */
128+
typedef enum e_glcdc_input_interface_format
129+
{
130+
GLCDC_INPUT_INTERFACE_FORMAT_RGB565 = 0, ///< Input interface format RGB565
131+
GLCDC_INPUT_INTERFACE_FORMAT_RGB888 = 1, ///< Input interface format RGB888
132+
GLCDC_INPUT_INTERFACE_FORMAT_ARGB1555 = 2, ///< Input interface format ARGB1555
133+
GLCDC_INPUT_INTERFACE_FORMAT_ARGB4444 = 3, ///< Input interface format ARGB4444
134+
GLCDC_INPUT_INTERFACE_FORMAT_ARGB8888 = 4, ///< Input interface format ARGB8888
135+
GLCDC_INPUT_INTERFACE_FORMAT_CLUT8 = 5, ///< Input interface format CLUT8
136+
GLCDC_INPUT_INTERFACE_FORMAT_CLUT4 = 6, ///< Input interface format CLUT4
137+
GLCDC_INPUT_INTERFACE_FORMAT_CLUT1 = 7, ///< Input interface format CLUT1
138+
} glcdc_input_interface_format_t;
139+
140+
/** Output interface format */
141+
typedef enum e_glcdc_output_interface_format
142+
{
143+
GLCDC_OUTPUT_INTERFACE_FORMAT_RGB888 = 0, ///< Output interface format RGB888
144+
GLCDC_OUTPUT_INTERFACE_FORMAT_RGB666 = 1, ///< Output interface format RGB666
145+
GLCDC_OUTPUT_INTERFACE_FORMAT_RGB565 = 2, ///< Output interface format RGB565
146+
GLCDC_OUTPUT_INTERFACE_FORMAT_SERIAL_RGB = 3, ///< Output interface format Serial RGB
147+
} glcdc_output_interface_format_t;
148+
149+
/** Dithering output format */
150+
typedef enum e_glcdc_dithering_output_format
151+
{
152+
GLCDC_DITHERING_OUTPUT_FORMAT_RGB888 = 0, ///< Dithering output format RGB888
153+
GLCDC_DITHERING_OUTPUT_FORMAT_RGB666 = 1, ///< Dithering output format RGB666
154+
GLCDC_DITHERING_OUTPUT_FORMAT_RGB565 = 2, ///< Dithering output format RGB565
155+
} glcdc_dithering_output_format_t;
156+
157+
/** GLCDC hardware specific configuration */
158+
typedef struct st_glcdc_extended_cfg
159+
{
160+
glcdc_tcon_pin_t tcon_hsync; ///< GLCDC TCON output pin select
161+
glcdc_tcon_pin_t tcon_vsync; ///< GLCDC TCON output pin select
162+
glcdc_tcon_pin_t tcon_de; ///< GLCDC TCON output pin select
163+
glcdc_correction_proc_order_t correction_proc_order; ///< Correction control route select
164+
glcdc_clk_src_t clksrc; ///< Clock Source selection
165+
glcdc_panel_clk_div_t clock_div_ratio; ///< Clock divide ratio for dot clock
166+
glcdc_dithering_mode_t dithering_mode; ///< Dithering mode
167+
glcdc_dithering_pattern_t dithering_pattern_A; ///< Dithering pattern A
168+
glcdc_dithering_pattern_t dithering_pattern_B; ///< Dithering pattern B
169+
glcdc_dithering_pattern_t dithering_pattern_C; ///< Dithering pattern C
170+
glcdc_dithering_pattern_t dithering_pattern_D; ///< Dithering pattern D
171+
void * phy_layer; ///< Alternate PHY layer, such as MIPI DSI.
172+
} glcdc_extended_cfg_t;
173+
174+
/* GLCDC hardware specific control block */
175+
typedef struct st_glcdc_ctrl
176+
{
177+
display_coordinate_t back_porch; ///< Zero coordinate for graphics plane(Back porch end)
178+
uint16_t hsize; ///< Horizontal pixel size in a line
179+
uint16_t vsize; ///< Vertical pixel size in a frame
180+
void * p_context; ///< Pointer to the function level device context
181+
// (e.g. display_ctrl_t type data)
182+
} glcdc_ctrl_t;
183+
184+
/**********************************************************************************************************************
185+
* Exported global variables
186+
**********************************************************************************************************************/
187+
188+
/* @cond INC_HEADER_DEFS_SEC */
189+
/* Filled in Interface API structure for this Instance. */
190+
extern const display_api_t g_display_on_glcdc;
191+
192+
/* @endcond */
193+
194+
/**********************************************************************************************************************
195+
* Public APIs
196+
**********************************************************************************************************************/
197+
198+
fsp_err_t R_GLCDC_Open(display_ctrl_t * const p_api_ctrl, display_cfg_t const * const p_cfg);
199+
fsp_err_t R_GLCDC_Close(display_ctrl_t * const p_api_ctrl);
200+
fsp_err_t R_GLCDC_Start(display_ctrl_t * const p_api_ctrl);
201+
fsp_err_t R_GLCDC_Stop(display_ctrl_t * const p_api_ctrl);
202+
fsp_err_t R_GLCDC_LayerChange(display_ctrl_t const * const p_api_ctrl,
203+
display_runtime_cfg_t const * const p_cfg,
204+
display_frame_layer_t layer);
205+
fsp_err_t R_GLCDC_BufferChange(display_ctrl_t const * const p_api_ctrl,
206+
uint8_t * const framebuffer,
207+
display_frame_layer_t layer);
208+
fsp_err_t R_GLCDC_ColorCorrection(display_ctrl_t const * const p_api_ctrl,
209+
display_correction_t const * const p_correction);
210+
fsp_err_t R_GLCDC_ClutUpdate(display_ctrl_t const * const p_api_ctrl,
211+
display_clut_cfg_t const * const p_clut_cfg,
212+
display_frame_layer_t layer);
213+
fsp_err_t R_GLCDC_ClutEdit(display_ctrl_t const * const p_api_ctrl,
214+
display_frame_layer_t layer,
215+
uint8_t index,
216+
uint32_t color);
217+
fsp_err_t R_GLCDC_ColorKeySet(display_ctrl_t const * const p_api_ctrl,
218+
display_colorkeying_layer_t key_cfg,
219+
display_frame_layer_t layer);
220+
fsp_err_t R_GLCDC_StatusGet(display_ctrl_t const * const p_api_ctrl, display_status_t * const status);
221+
222+
/*******************************************************************************************************************//**
223+
* @} (end defgroup GLCDC)
224+
**********************************************************************************************************************/
225+
226+
/* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */
227+
FSP_FOOTER
228+
229+
#endif

0 commit comments

Comments
 (0)