1 /*
2 * Copyright 2019-2021 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9 #ifndef _FSL_LCDIFV2_H_
10 #define _FSL_LCDIFV2_H_
11
12 #include "fsl_common.h"
13
14 #if defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET
15 #include "fsl_memory.h"
16 #endif
17
18 /*!
19 * @addtogroup lcdifv2
20 * @{
21 */
22
23 /*******************************************************************************
24 * Definitions
25 ******************************************************************************/
26
27 /*! @name Driver version */
28 /*@{*/
29 /*! @brief LCDIF v2 driver version */
30 #define FSL_LCDIFV2_DRIVER_VERSION (MAKE_VERSION(2, 2, 3))
31 /*@}*/
32
33 #if defined(FSL_FEATURE_LCDIFV2_LAYER_COUNT) && (!defined(LCDIFV2_LAYER_COUNT))
34 #define LCDIFV2_LAYER_COUNT FSL_FEATURE_LCDIFV2_LAYER_COUNT
35 #endif
36
37 #if defined(FSL_FEATURE_LCDIFV2_LAYER_CSC_COUNT) && (!defined(LCDIFV2_LAYER_CSC_COUNT))
38 #define LCDIFV2_LAYER_CSC_COUNT FSL_FEATURE_LCDIFV2_LAYER_CSC_COUNT
39 #endif
40
41 #if defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET
42 #define LCDIFV2_ADDR_CPU_2_IP(addr) (MEMORY_ConvertMemoryMapAddress((uint32_t)(addr), kMEMORY_Local2DMA))
43 #else
44 #define LCDIFV2_ADDR_CPU_2_IP(addr) (addr)
45 #endif /* FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET */
46
47 /*! @brief LCDIF v2 FIFO empty interrupt. */
48 #define LCDIFV2_MAKE_FIFO_EMPTY_INTERRUPT(layer) (1U << ((uint32_t)(layer) + 24U))
49 /*! @brief LCDIF v2 DMA done interrupt. */
50 #define LCDIFV2_MAKE_DMA_DONE_INTERRUPT(layer) (1U << ((uint32_t)(layer) + 16U))
51 /*! @brief LCDIF v2 DMA error interrupt. */
52 #define LCDIFV2_MAKE_DMA_ERROR_INTERRUPT(layer) (1U << ((uint32_t)(layer) + 8U))
53
54 /* LUT memory entery number. */
55 #define LCDIFV2_LUT_ENTRY_NUM 256U
56
57 /*!
58 * @brief LCDIF v2 signal polarity flags
59 */
60 enum _lcdifv2_polarity_flags
61 {
62 kLCDIFV2_VsyncActiveLow = LCDIFV2_CTRL_INV_VS_MASK, /*!< VSYNC active low. */
63 kLCDIFV2_VsyncActiveHigh = 0U, /*!< VSYNC active high. */
64 kLCDIFV2_HsyncActiveLow = LCDIFV2_CTRL_INV_HS_MASK, /*!< HSYNC active low. */
65 kLCDIFV2_HsyncActiveHigh = 0U, /*!< HSYNC active high. */
66 kLCDIFV2_DataEnableActiveLow = LCDIFV2_CTRL_INV_DE_MASK, /*!< Data enable line active low. */
67 kLCDIFV2_DataEnableActiveHigh = 0U, /*!< Data enable line active high. */
68 kLCDIFV2_DriveDataOnFallingClkEdge = LCDIFV2_CTRL_INV_PXCK_MASK, /*!< Output data on falling clock edge, capture
69 data on rising clock edge. */
70 kLCDIFV2_DriveDataOnRisingClkEdge = 0U, /*!< Output data on rising clock edge, capture data
71 on falling clock edge. */
72 kLCDIFV2_DataActiveLow = LCDIFV2_CTRL_NEG_MASK, /*!< Data active high. */
73 kLCDIFV2_DataActiveHigh = 0U, /*!< Data active high. */
74 };
75
76 /*!
77 * @brief The LCDIF v2 interrupts.
78 */
79 enum _lcdifv2_interrupt
80 {
81 kLCDIFV2_Layer0FifoEmptyInterrupt = LCDIFV2_MAKE_FIFO_EMPTY_INTERRUPT(0), /*!< Layer 0 FIFO empty. */
82 kLCDIFV2_Layer1FifoEmptyInterrupt = LCDIFV2_MAKE_FIFO_EMPTY_INTERRUPT(1), /*!< Layer 1 FIFO empty. */
83 kLCDIFV2_Layer2FifoEmptyInterrupt = LCDIFV2_MAKE_FIFO_EMPTY_INTERRUPT(2), /*!< Layer 2 FIFO empty. */
84 kLCDIFV2_Layer3FifoEmptyInterrupt = LCDIFV2_MAKE_FIFO_EMPTY_INTERRUPT(3), /*!< Layer 3 FIFO empty. */
85 kLCDIFV2_Layer4FifoEmptyInterrupt = LCDIFV2_MAKE_FIFO_EMPTY_INTERRUPT(4), /*!< Layer 4 FIFO empty. */
86 kLCDIFV2_Layer5FifoEmptyInterrupt = LCDIFV2_MAKE_FIFO_EMPTY_INTERRUPT(5), /*!< Layer 5 FIFO empty. */
87 kLCDIFV2_Layer6FifoEmptyInterrupt = LCDIFV2_MAKE_FIFO_EMPTY_INTERRUPT(6), /*!< Layer 6 FIFO empty. */
88 kLCDIFV2_Layer7FifoEmptyInterrupt = LCDIFV2_MAKE_FIFO_EMPTY_INTERRUPT(7), /*!< Layer 7 FIFO empty. */
89 kLCDIFV2_Layer0DmaDoneInterrupt = LCDIFV2_MAKE_DMA_DONE_INTERRUPT(0), /*!< Layer 0 DMA done. */
90 kLCDIFV2_Layer1DmaDoneInterrupt = LCDIFV2_MAKE_DMA_DONE_INTERRUPT(1), /*!< Layer 1 DMA done. */
91 kLCDIFV2_Layer2DmaDoneInterrupt = LCDIFV2_MAKE_DMA_DONE_INTERRUPT(2), /*!< Layer 2 DMA done. */
92 kLCDIFV2_Layer3DmaDoneInterrupt = LCDIFV2_MAKE_DMA_DONE_INTERRUPT(3), /*!< Layer 3 DMA done. */
93 kLCDIFV2_Layer4DmaDoneInterrupt = LCDIFV2_MAKE_DMA_DONE_INTERRUPT(4), /*!< Layer 4 DMA done. */
94 kLCDIFV2_Layer5DmaDoneInterrupt = LCDIFV2_MAKE_DMA_DONE_INTERRUPT(5), /*!< Layer 5 DMA done. */
95 kLCDIFV2_Layer6DmaDoneInterrupt = LCDIFV2_MAKE_DMA_DONE_INTERRUPT(6), /*!< Layer 6 DMA done. */
96 kLCDIFV2_Layer7DmaDoneInterrupt = LCDIFV2_MAKE_DMA_DONE_INTERRUPT(7), /*!< Layer 7 DMA done. */
97 kLCDIFV2_Layer0DmaErrorInterrupt = LCDIFV2_MAKE_DMA_ERROR_INTERRUPT(0), /*!< Layer 0 DMA error. */
98 kLCDIFV2_Layer1DmaErrorInterrupt = LCDIFV2_MAKE_DMA_ERROR_INTERRUPT(1), /*!< Layer 1 DMA error. */
99 kLCDIFV2_Layer2DmaErrorInterrupt = LCDIFV2_MAKE_DMA_ERROR_INTERRUPT(2), /*!< Layer 2 DMA error. */
100 kLCDIFV2_Layer3DmaErrorInterrupt = LCDIFV2_MAKE_DMA_ERROR_INTERRUPT(3), /*!< Layer 3 DMA error. */
101 kLCDIFV2_Layer4DmaErrorInterrupt = LCDIFV2_MAKE_DMA_ERROR_INTERRUPT(4), /*!< Layer 4 DMA error. */
102 kLCDIFV2_Layer5DmaErrorInterrupt = LCDIFV2_MAKE_DMA_ERROR_INTERRUPT(5), /*!< Layer 5 DMA error. */
103 kLCDIFV2_Layer6DmaErrorInterrupt = LCDIFV2_MAKE_DMA_ERROR_INTERRUPT(6), /*!< Layer 6 DMA error. */
104 kLCDIFV2_Layer7DmaErrorInterrupt = LCDIFV2_MAKE_DMA_ERROR_INTERRUPT(7), /*!< Layer 7 DMA error. */
105 kLCDIFV2_VerticalBlankingInterrupt = (1U << 2U), /*!< Start of vertical blanking period. */
106 kLCDIFV2_OutputUnderrunInterrupt = (1U << 1U), /*!< Output buffer underrun. */
107 kLCDIFV2_VsyncEdgeInterrupt = (1U << 0U), /*!< Interrupt at VSYNC edge. */
108 };
109
110 /*! @brief The LCDIF v2 output line order. */
111 typedef enum _lcdifv2_line_order
112 {
113 kLCDIFV2_LineOrderRGB = 0, /*!< RGB */
114 kLCDIFV2_LineOrderRBG, /*!< RBG */
115 kLCDIFV2_LineOrderGBR, /*!< GBR */
116 kLCDIFV2_LineOrderGRB, /*!< GRB */
117 kLCDIFV2_LineOrderBRG, /*!< BRG */
118 kLCDIFV2_LineOrderBGR, /*!< BGR */
119 } lcdifv2_line_order_t;
120
121 /*!
122 * @brief LCDIF v2 display configure structure.
123 */
124 typedef struct _lcdifv2_display_config
125 {
126 uint16_t panelWidth; /*!< Display panel width, pixels per line. */
127 uint16_t panelHeight; /*!< Display panel height, how many lines per panel. */
128 uint8_t hsw; /*!< HSYNC pulse width. */
129 uint8_t hfp; /*!< Horizontal front porch. */
130 uint8_t hbp; /*!< Horizontal back porch. */
131 uint8_t vsw; /*!< VSYNC pulse width. */
132 uint8_t vfp; /*!< Vrtical front porch. */
133 uint8_t vbp; /*!< Vertical back porch. */
134 uint32_t polarityFlags; /*!< OR'ed value of @ref _lcdifv2_polarity_flags, used to contol the signal polarity. */
135 lcdifv2_line_order_t lineOrder; /*!< Line order. */
136 } lcdifv2_display_config_t;
137
138 /*! @brief LCDIF v2 color space conversion mode. */
139 typedef enum _lcdifv2_csc_mode
140 {
141 kLCDIFV2_CscDisable = 0U, /*!< Disable the CSC. */
142 kLCDIFV2_CscYUV2RGB, /*!< YUV to RGB. */
143 kLCDIFV2_CscYCbCr2RGB, /*!< YCbCr to RGB. */
144 } lcdifv2_csc_mode_t;
145
146 /*! @brief LCDIF v2 pixel format. */
147 typedef enum _lcdifv2_pixel_format
148 {
149 kLCDIFV2_PixelFormatIndex1BPP = LCDIFV2_CTRLDESCL5_BPP(0U), /*!< LUT index 1 bit. */
150 kLCDIFV2_PixelFormatIndex2BPP = LCDIFV2_CTRLDESCL5_BPP(1U), /*!< LUT index 2 bit. */
151 kLCDIFV2_PixelFormatIndex4BPP = LCDIFV2_CTRLDESCL5_BPP(2U), /*!< LUT index 4 bit. */
152 kLCDIFV2_PixelFormatIndex8BPP = LCDIFV2_CTRLDESCL5_BPP(3U), /*!< LUT index 8 bit. */
153 kLCDIFV2_PixelFormatRGB565 = LCDIFV2_CTRLDESCL5_BPP(4U), /*!< RGB565, two pixels use 32 bits. */
154 kLCDIFV2_PixelFormatARGB1555 = LCDIFV2_CTRLDESCL5_BPP(5U), /*!< ARGB1555, two pixels use 32 bits. */
155 kLCDIFV2_PixelFormatARGB4444 = LCDIFV2_CTRLDESCL5_BPP(6U), /*!< ARGB4444, two pixels use 32 bits. */
156 kLCDIFV2_PixelFormatUYVY = LCDIFV2_CTRLDESCL5_BPP(7U) |
157 LCDIFV2_CTRLDESCL5_YUV_FORMAT(0U), /*!< UYVY, only layer 0 and layer 1 support this. */
158 kLCDIFV2_PixelFormatVYUY = LCDIFV2_CTRLDESCL5_BPP(7U) |
159 LCDIFV2_CTRLDESCL5_YUV_FORMAT(1U), /*!< VYUY, only layer 0 and layer 1 support this. */
160 kLCDIFV2_PixelFormatYUYV = LCDIFV2_CTRLDESCL5_BPP(7U) |
161 LCDIFV2_CTRLDESCL5_YUV_FORMAT(2U), /*!< YUYV, only layer 0 and layer 1 support this. */
162 kLCDIFV2_PixelFormatYVYU = LCDIFV2_CTRLDESCL5_BPP(7U) |
163 LCDIFV2_CTRLDESCL5_YUV_FORMAT(3U), /*!< YVYU, only layer 0 and layer 1 support this. */
164 kLCDIFV2_PixelFormatRGB888 = LCDIFV2_CTRLDESCL5_BPP(8U), /*!< RGB888 packed, one pixel uses 24 bits. */
165 kLCDIFV2_PixelFormatARGB8888 = LCDIFV2_CTRLDESCL5_BPP(9U), /*!< ARGB8888 unpacked, one pixel uses 32 bits. */
166 kLCDIFV2_PixelFormatABGR8888 = LCDIFV2_CTRLDESCL5_BPP(10U), /*!< ABGR8888 unpacked, one pixel uses 32 bits. */
167 } lcdifv2_pixel_format_t;
168
169 /*! @brief LCDIF v2 source buffer configuration. */
170 typedef struct _lcdifv2_buffer_config
171 {
172 uint16_t strideBytes; /*!< Number of bytes between two vertically adjacent pixels, suggest 64-bit aligned. */
173 lcdifv2_pixel_format_t pixelFormat; /*!< Source buffer pixel format. */
174 } lcdifv2_buffer_config_t;
175
176 /*!
177 * @brief LCDIF v2 layer alpha blending mode.
178 */
179 typedef enum _lcdifv2_alpha_mode
180 {
181 kLCDIFV2_AlphaDisable, /*!< Disable alpha blend. */
182 kLCDIFV2_AlphaOverride, /*!< Use the gobal alpha value, pixel defined alpha value is overridden. */
183 kLCDIFV2_AlphaEmbedded, /*!< Use the pixel defined alpha value. */
184 kLCDIFV2_AlphaPoterDuff, /*!< Use the PoterDuff alpha blending. */
185 } lcdifv2_alpha_mode_t;
186
187 /*!
188 * @brief LCDIF v2 PoterDuff alpha mode.
189 */
190 typedef enum _lcdifv2_pd_alpha_mode
191 {
192 kLCDIFV2_PD_AlphaStraight = 0, /*!< Straight mode. */
193 kLCDIFV2_PD_AlphaInversed = 1, /*!< Inversed mode. */
194 } lcdifv2_pd_alpha_mode_t;
195
196 /*!
197 * @brief LCDIF v2 PoterDuff color mode.
198 */
199 typedef enum _lcdifv2_pd_color_mode
200 {
201 kLCDIFV2_PD_ColorNoAlpha = 0, /*!< Output color directly. */
202 kLCDIFV2_PD_ColorWithAlpha = 1, /*!< Output color multiples alpha. */
203 } lcdifv2_pd_color_mode_t;
204
205 /*!
206 * @brief LCDIF v2 PoterDuff global alpha mode.
207 */
208 typedef enum _lcdifv2_pd_global_alpha_mode
209 {
210 kLCDIFV2_PD_GlobalAlpha = 0, /*!< Use global alpha. */
211 kLCDIFV2_PD_LocalAlpha = 1, /*!< Use local alpha. */
212 kLCDIFV2_PD_ScaledAlpha = 2, /*!< Use scaled alpha. */
213 } lcdifv2_pd_global_alpha_mode_t;
214
215 /*!
216 * @brief LCDIF v2 PoterDuff factor mode.
217 */
218 typedef enum _lcdifv2_pd_factor_mode
219 {
220 kLCDIFV2_PD_FactorOne = 0, /*!< Use 1. */
221 kLCDIFV2_PD_FactorZero = 1, /*!< Use 0. */
222 kLCDIFV2_PD_FactorStraightAlpha = 2, /*!< Use straight alpha. */
223 kLCDIFV2_PD_FactorInversedAlpha = 3, /*!< Use inversed alpha. */
224 } lcdifv2_pd_factor_mode_t;
225
226 /*!
227 * @brief LCDIF v2 layer alpha blending configuration.
228 */
229 typedef struct _lcdifv2_blend_config
230 {
231 uint8_t globalAlpha; /*!< Global alpha value, only used when
232 @ref alphaMode is @ref kLCDIFV2_AlphaOverride or
233 @ref kLCDIFV2_AlphaPoterDuff */
234 lcdifv2_alpha_mode_t alphaMode; /*!< Alpha mode. */
235 lcdifv2_pd_alpha_mode_t pdAlphaMode; /*!< PoterDuff alpha mode, only used when @ref alphaMode is @ref
236 kLCDIFV2_AlphaPoterDuff */
237 lcdifv2_pd_color_mode_t pdColorMode; /*!< PoterDuff color mode, only used when @ref alphaMode is @ref
238 kLCDIFV2_AlphaPoterDuff */
239 lcdifv2_pd_global_alpha_mode_t pdGlobalAlphaMode; /*!< PoterDuff global alpha mode, only used when @ref alphaMode is
240 @ref kLCDIFV2_AlphaPoterDuff */
241 lcdifv2_pd_factor_mode_t pdFactorMode; /*!< PoterDuff factor mode, only used when @ref alphaMode is @ref
242 kLCDIFV2_AlphaPoterDuff */
243 } lcdifv2_blend_config_t;
244
245 /*! @brief LCDIFv2 Porter Duff blend mode. Note: Don't change the enum item value */
246 typedef enum _lcdifv2_pd_blend_mode
247 {
248 kLCDIFV2_PD_Src = 0, /*!< Source Only */
249 kLCDIFV2_PD_Atop, /*!< Source Atop */
250 kLCDIFV2_PD_Over, /*!< Source Over */
251 kLCDIFV2_PD_In, /*!< Source In. */
252 kLCDIFV2_PD_Out, /*!< Source Out. */
253 kLCDIFV2_PD_Dst, /*!< Destination Only. */
254 kLCDIFV2_PD_DstAtop, /*!< Destination Atop. */
255 kLCDIFV2_PD_DstOver, /*!< Destination Over. */
256 kLCDIFV2_PD_DstIn, /*!< Destination In. */
257 kLCDIFV2_PD_DstOut, /*!< Destination Out. */
258 kLCDIFV2_PD_Xor, /*!< XOR. */
259 kLCDIFV2_PD_Clear, /*!< Clear. */
260 kLCDIFV2_PD_Max, /*!< Used for boarder detection. */
261 } lcdifv2_pd_blend_mode_t;
262
263 /*! @brief LCDIFv2 Porter Duff layer. Note: Don't change the enum item value */
264 typedef enum _lcdifv2_pd_layer
265 {
266 kLCDIFV2_PD_SrcLayer = 0, /*!< Source layer. */
267 kLCDIFV2_PD_DestLayer = 1, /*!< Destination layer. */
268 kLCDIFV2_PD_LayerMax = 2, /*!< Used for boarder detection. */
269 } lcdifv2_pd_layer_t;
270
271 /*******************************************************************************
272 * APIs
273 ******************************************************************************/
274
275 #if defined(__cplusplus)
276 extern "C" {
277 #endif /* __cplusplus */
278
279 /*!
280 * @name LCDIF v2 initialization and de-initialization
281 * @{
282 */
283
284 /*!
285 * @brief Initializes the LCDIF v2.
286 *
287 * This function ungates the LCDIF v2 clock and release the peripheral reset.
288 *
289 * @param base LCDIF v2 peripheral base address.
290 */
291 void LCDIFV2_Init(LCDIFV2_Type *base);
292
293 /*!
294 * @brief Deinitializes the LCDIF peripheral.
295 *
296 * @param base LCDIF peripheral base address.
297 */
298 void LCDIFV2_Deinit(LCDIFV2_Type *base);
299
300 /*!
301 * @brief Reset the LCDIF v2.
302 *
303 * @param base LCDIF peripheral base address.
304 */
305 void LCDIFV2_Reset(LCDIFV2_Type *base);
306
307 /* @} */
308
309 /*!
310 * @name Display
311 * @{
312 */
313
314 /*!
315 * @brief Gets the LCDIF display default configuration structure.
316 *
317 * This function sets the configuration structure to default values.
318 * The default configuration is set to the following values.
319 * @code
320 config->panelWidth = 0U;
321 config->panelHeight = 0U;
322 config->hsw = 3U;
323 config->hfp = 3U;
324 config->hbp = 3U;
325 config->vsw = 3U;
326 config->vfp = 3U;
327 config->vbp = 3U;
328 config->polarityFlags = kLCDIFV2_VsyncActiveHigh | kLCDIFV2_HsyncActiveHigh | kLCDIFV2_DataEnableActiveHigh |
329 kLCDIFV2_DriveDataOnRisingClkEdge | kLCDIFV2_DataActiveHigh;
330 config->lineOrder = kLCDIFV2_LineOrderRGB;
331 @endcode
332 *
333 * @param config Pointer to the LCDIF configuration structure.
334 */
335 void LCDIFV2_DisplayGetDefaultConfig(lcdifv2_display_config_t *config);
336
337 /*!
338 * @brief Set the LCDIF v2 display configurations.
339 *
340 * @param base LCDIF peripheral base address.
341 * @param config Pointer to the LCDIF configuration structure.
342 */
343 void LCDIFV2_SetDisplayConfig(LCDIFV2_Type *base, const lcdifv2_display_config_t *config);
344
345 /*!
346 * @brief Enable or disable the display
347 *
348 * @param base LCDIF peripheral base address.
349 * @param enable Enable or disable.
350 */
LCDIFV2_EnableDisplay(LCDIFV2_Type * base,bool enable)351 static inline void LCDIFV2_EnableDisplay(LCDIFV2_Type *base, bool enable)
352 {
353 if (enable)
354 {
355 base->DISP_PARA |= LCDIFV2_DISP_PARA_DISP_ON_MASK;
356 }
357 else
358 {
359 base->DISP_PARA &= ~LCDIFV2_DISP_PARA_DISP_ON_MASK;
360 }
361 }
362
363 /* @} */
364
365 /*!
366 * @name Interrupts
367 * @{
368 */
369
370 /*!
371 * @brief Enables LCDIF interrupt requests.
372 *
373 * @param base LCDIF peripheral base address.
374 * @param domain CPU domain the interrupt signal routed to.
375 * @param mask interrupt source, OR'ed value of _lcdifv2_interrupt.
376 */
LCDIFV2_EnableInterrupts(LCDIFV2_Type * base,uint8_t domain,uint32_t mask)377 static inline void LCDIFV2_EnableInterrupts(LCDIFV2_Type *base, uint8_t domain, uint32_t mask)
378 {
379 base->INT[domain].INT_ENABLE |= mask;
380 }
381
382 /*!
383 * @brief Disables LCDIF interrupt requests.
384 *
385 * @param base LCDIF peripheral base address.
386 * @param domain CPU domain the interrupt signal routed to.
387 * @param mask interrupt source, OR'ed value of _lcdifv2_interrupt.
388 */
LCDIFV2_DisableInterrupts(LCDIFV2_Type * base,uint8_t domain,uint32_t mask)389 static inline void LCDIFV2_DisableInterrupts(LCDIFV2_Type *base, uint8_t domain, uint32_t mask)
390 {
391 base->INT[domain].INT_ENABLE &= ~mask;
392 }
393
394 /*!
395 * @brief Get LCDIF interrupt peding status.
396 *
397 * @param base LCDIF peripheral base address.
398 * @param domain CPU domain the interrupt signal routed to.
399 * @return Interrupt pending status, OR'ed value of _lcdifv2_interrupt.
400 */
LCDIFV2_GetInterruptStatus(LCDIFV2_Type * base,uint8_t domain)401 static inline uint32_t LCDIFV2_GetInterruptStatus(LCDIFV2_Type *base, uint8_t domain)
402 {
403 return base->INT[domain].INT_STATUS;
404 }
405
406 /*!
407 * @brief Clear LCDIF interrupt peding status.
408 *
409 * @param base LCDIF peripheral base address.
410 * @param domain CPU domain the interrupt signal routed to.
411 * @param mask of the flags to clear, OR'ed value of _lcdifv2_interrupt.
412 */
LCDIFV2_ClearInterruptStatus(LCDIFV2_Type * base,uint8_t domain,uint32_t mask)413 static inline void LCDIFV2_ClearInterruptStatus(LCDIFV2_Type *base, uint8_t domain, uint32_t mask)
414 {
415 base->INT[domain].INT_STATUS = mask;
416 }
417
418 /* @} */
419
420 /*!
421 * @name LUT
422 * @{
423 */
424
425 /*!
426 * @brief Set the LUT data.
427 *
428 * This function sets the specific layer LUT data, if @p useShadowLoad is true,
429 * call @ref LCDIFV2_TriggerLayerShadowLoad after this function, the
430 * LUT will be loaded to the hardware during next vertical blanking period.
431 * If @p useShadowLoad is false, the LUT data is loaded to hardware directly.
432 *
433 * @param base LCDIF v2 peripheral base address.
434 * @param layerIndex Which layer to set.
435 * @param lutData The LUT data to load.
436 * @param count Count of @p lutData.
437 * @param useShadowLoad Use shadow load.
438 * @retval kStatus_Success Set success.
439 * @retval kStatus_Fail Previous LUT data is not loaded to hardware yet.
440 */
441 status_t LCDIFV2_SetLut(
442 LCDIFV2_Type *base, uint8_t layerIndex, const uint32_t *lutData, uint16_t count, bool useShadowLoad);
443
444 /* @} */
445
446 /*!
447 * @name Layer operation
448 * @{
449 */
450
451 /*!
452 * @brief Set the layer dimension.
453 *
454 * @param base LCDIFv2 peripheral base address.
455 * @param layerIndex Layer layerIndex.
456 * @param width Layer width in pixel.
457 * @param height Layer height.
458 *
459 * @note The layer width must be in multiples of the number of pixels that can be stored in 32 bits
460 */
LCDIFV2_SetLayerSize(LCDIFV2_Type * base,uint8_t layerIndex,uint16_t width,uint16_t height)461 static inline void LCDIFV2_SetLayerSize(LCDIFV2_Type *base, uint8_t layerIndex, uint16_t width, uint16_t height)
462 {
463 base->LAYER[layerIndex].CTRLDESCL1 =
464 ((uint32_t)height << LCDIFV2_CTRLDESCL1_HEIGHT_SHIFT) | ((uint32_t)width << LCDIFV2_CTRLDESCL1_WIDTH_SHIFT);
465 }
466
467 /*!
468 * @brief Set the layer position in output frame.
469 *
470 * @param base LCDIFv2 peripheral base address.
471 * @param layerIndex Layer layerIndex.
472 * @param offsetX Horizontal offset, start from 0.
473 * @param offsetY Vertical offset, start from 0.
474 */
LCDIFV2_SetLayerOffset(LCDIFV2_Type * base,uint8_t layerIndex,uint16_t offsetX,uint16_t offsetY)475 static inline void LCDIFV2_SetLayerOffset(LCDIFV2_Type *base, uint8_t layerIndex, uint16_t offsetX, uint16_t offsetY)
476 {
477 base->LAYER[layerIndex].CTRLDESCL2 =
478 ((uint32_t)offsetX << LCDIFV2_CTRLDESCL2_POSX_SHIFT) | ((uint32_t)offsetY << LCDIFV2_CTRLDESCL2_POSY_SHIFT);
479 }
480
481 /*!
482 * @brief Set the layer source buffer configuration.
483 *
484 * @param base LCDIFv2 peripheral base address.
485 * @param layerIndex Layer layerIndex.
486 * @param config Pointer to the configuration.
487 */
488 void LCDIFV2_SetLayerBufferConfig(LCDIFV2_Type *base, uint8_t layerIndex, const lcdifv2_buffer_config_t *config);
489
490 /*!
491 * @brief Set the layer source buffer address.
492 *
493 * This function is used for fast runtime source buffer change.
494 *
495 * @param base LCDIFv2 peripheral base address.
496 * @param layerIndex Layer layerIndex.
497 * @param addr The new source buffer address passed to the layer, should be 64-bit aligned.
498 */
LCDIFV2_SetLayerBufferAddr(LCDIFV2_Type * base,uint8_t layerIndex,uint32_t addr)499 static inline void LCDIFV2_SetLayerBufferAddr(LCDIFV2_Type *base, uint8_t layerIndex, uint32_t addr)
500 {
501 base->LAYER[layerIndex].CTRLDESCL4 = LCDIFV2_ADDR_CPU_2_IP(addr);
502 }
503
504 /*!
505 * @brief Enable or disable the layer.
506 *
507 * @param base LCDIFv2 peripheral base address.
508 * @param layerIndex Layer layerIndex.
509 * @param enable Pass in true to enable, false to disable.
510 */
LCDIFV2_EnableLayer(LCDIFV2_Type * base,uint8_t layerIndex,bool enable)511 static inline void LCDIFV2_EnableLayer(LCDIFV2_Type *base, uint8_t layerIndex, bool enable)
512 {
513 if (enable)
514 {
515 base->LAYER[layerIndex].CTRLDESCL5 |= LCDIFV2_CTRLDESCL5_EN_MASK;
516 }
517 else
518 {
519 base->LAYER[layerIndex].CTRLDESCL5 &= ~LCDIFV2_CTRLDESCL5_EN_MASK;
520 }
521 }
522
523 /*!
524 * @brief Trigger the layer configuration shadow load.
525 *
526 * The new layer configurations are written to the shadow registers first,
527 * When all configurations written finished, call this function, then shadowed
528 * control registers are updated to the active control registers on VSYNC of
529 * next frame.
530 *
531 * @param base LCDIFv2 peripheral base address.
532 * @param layerIndex Layer layerIndex.
533 */
LCDIFV2_TriggerLayerShadowLoad(LCDIFV2_Type * base,uint8_t layerIndex)534 static inline void LCDIFV2_TriggerLayerShadowLoad(LCDIFV2_Type *base, uint8_t layerIndex)
535 {
536 base->LAYER[layerIndex].CTRLDESCL5 |= LCDIFV2_CTRLDESCL5_SHADOW_LOAD_EN_MASK;
537 }
538
539 /*!
540 * @brief Set the layer back ground color.
541 *
542 * The back ground color is used when layer not actived.
543 *
544 * @param base LCDIFv2 peripheral base address.
545 * @param layerIndex Index of the layer.
546 * @param backGroundColor Background color to use when this layer is not active.
547 */
LCDIFV2_SetLayerBackGroundColor(LCDIFV2_Type * base,uint8_t layerIndex,uint32_t backGroundColor)548 static inline void LCDIFV2_SetLayerBackGroundColor(LCDIFV2_Type *base, uint8_t layerIndex, uint32_t backGroundColor)
549 {
550 base->LAYER[layerIndex].CTRLDESCL6 = backGroundColor;
551 }
552
553 /*!
554 * @brief Set the layer alpha blend mode.
555 *
556 * @param base LCDIFv2 peripheral base address.
557 * @param layerIndex Index of the CSC unit.
558 * @param config Pointer to the blend configuration.
559 */
560 void LCDIFV2_SetLayerBlendConfig(LCDIFV2_Type *base, uint8_t layerIndex, const lcdifv2_blend_config_t *config);
561
562 /*!
563 * @brief Set the color space conversion mode.
564 *
565 * Supports YUV2RGB and YCbCr2RGB.
566 *
567 * @param base LCDIFv2 peripheral base address.
568 * @param layerIndex Index of the layer.
569 * @param mode The conversion mode.
570 */
571 void LCDIFV2_SetCscMode(LCDIFV2_Type *base, uint8_t layerIndex, lcdifv2_csc_mode_t mode);
572
573 /* @} */
574
575 /*!
576 * @name Porter Duff
577 * @{
578 */
579
580 /*!
581 * @brief Get the blend configuration for Porter Duff blend.
582 *
583 * This function gets the blend configuration for Porter Duff blend,
584 * config->pdFactorMode is set according to @p layer and @p mode,
585 * other blend configurations are set to:
586 *
587 * @code
588 config->pdAlphaMode = kLCDIFV2_PD_AlphaStraight;
589 config->pdColorMode = kLCDIFV2_PD_ColorStraight;
590 config->pdGlobalAlphaMode = kLCDIFV2_PD_LocalAlpha;
591 config->alphaMode = kLCDIFV2_AlphaPoterDuff;
592 @endcode
593 *
594 * This is the basic Porter Duff blend configuration, user still could
595 * modify the configurations after this function.
596 *
597 * @param mode Porter Duff blend mode.
598 * @param layer The configuration for source layer or destination layer.
599 * @param config Pointer to the configuration.
600 * @retval kStatus_Success Get the configuration successfully.
601 * @retval kStatus_InvalidArgument The argument is invalid.
602 */
603 status_t LCDIFV2_GetPorterDuffConfig(lcdifv2_pd_blend_mode_t mode,
604 lcdifv2_pd_layer_t layer,
605 lcdifv2_blend_config_t *config);
606
607 /* @} */
608
609 #if defined(__cplusplus)
610 }
611 #endif /* __cplusplus */
612
613 /* @} */
614
615 #endif /*_FSL_LCDIFV2_H_*/
616