![]() |
|
|||
File indexing completed on 2025-05-11 08:23:00
0001 /* 0002 * Copyright 2019-2022 NXP 0003 * All rights reserved. 0004 * 0005 * 0006 * SPDX-License-Identifier: BSD-3-Clause 0007 */ 0008 0009 #ifndef _FSL_LCDIFV2_H_ 0010 #define _FSL_LCDIFV2_H_ 0011 0012 #include "fsl_common.h" 0013 0014 #if (defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && (0 != FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET)) 0015 #include "fsl_memory.h" 0016 #endif 0017 0018 /*! 0019 * @addtogroup lcdifv2 0020 * @{ 0021 */ 0022 0023 /******************************************************************************* 0024 * Definitions 0025 ******************************************************************************/ 0026 0027 /*! @name Driver version */ 0028 /*@{*/ 0029 /*! @brief LCDIF v2 driver version */ 0030 #define FSL_LCDIFV2_DRIVER_VERSION (MAKE_VERSION(2, 3, 2)) 0031 /*@}*/ 0032 0033 #if defined(FSL_FEATURE_LCDIFV2_LAYER_COUNT) && (!defined(LCDIFV2_LAYER_COUNT)) 0034 #define LCDIFV2_LAYER_COUNT FSL_FEATURE_LCDIFV2_LAYER_COUNT 0035 #endif 0036 0037 #if defined(FSL_FEATURE_LCDIFV2_LAYER_CSC_COUNT) && (!defined(LCDIFV2_LAYER_CSC_COUNT)) 0038 #define LCDIFV2_LAYER_CSC_COUNT FSL_FEATURE_LCDIFV2_LAYER_CSC_COUNT 0039 #endif 0040 0041 #if (defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && (0 != FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET)) 0042 #define LCDIFV2_ADDR_CPU_2_IP(addr) (MEMORY_ConvertMemoryMapAddress((uint32_t)(addr), kMEMORY_Local2DMA)) 0043 #else 0044 #define LCDIFV2_ADDR_CPU_2_IP(addr) (addr) 0045 #endif /* FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET */ 0046 0047 /*! @brief LCDIF v2 FIFO empty interrupt. */ 0048 #define LCDIFV2_MAKE_FIFO_EMPTY_INTERRUPT(layer) (1UL << ((uint32_t)(layer) + 24U)) 0049 /*! @brief LCDIF v2 DMA done interrupt. */ 0050 #define LCDIFV2_MAKE_DMA_DONE_INTERRUPT(layer) (1UL << ((uint32_t)(layer) + 16U)) 0051 /*! @brief LCDIF v2 DMA error interrupt. */ 0052 #define LCDIFV2_MAKE_DMA_ERROR_INTERRUPT(layer) (1UL << ((uint32_t)(layer) + 8U)) 0053 0054 /* LUT memory entery number. */ 0055 #define LCDIFV2_LUT_ENTRY_NUM 256U 0056 0057 /*! 0058 * @brief LCDIF v2 signal polarity flags 0059 */ 0060 enum _lcdifv2_polarity_flags 0061 { 0062 kLCDIFV2_VsyncActiveHigh = 0U, /*!< VSYNC active high. */ 0063 kLCDIFV2_HsyncActiveHigh = 0U, /*!< HSYNC active high. */ 0064 kLCDIFV2_DataEnableActiveHigh = 0U, /*!< Data enable line active high. */ 0065 kLCDIFV2_DriveDataOnRisingClkEdge = 0U, /*!< Output data on rising clock edge, capture data 0066 on falling clock edge. */ 0067 kLCDIFV2_DataActiveHigh = 0U, /*!< Data active high. */ 0068 0069 kLCDIFV2_VsyncActiveLow = LCDIFV2_CTRL_INV_VS_MASK, /*!< VSYNC active low. */ 0070 kLCDIFV2_HsyncActiveLow = LCDIFV2_CTRL_INV_HS_MASK, /*!< HSYNC active low. */ 0071 kLCDIFV2_DataEnableActiveLow = LCDIFV2_CTRL_INV_DE_MASK, /*!< Data enable line active low. */ 0072 kLCDIFV2_DriveDataOnFallingClkEdge = LCDIFV2_CTRL_INV_PXCK_MASK, /*!< Output data on falling clock edge, capture 0073 data on rising clock edge. */ 0074 kLCDIFV2_DataActiveLow = LCDIFV2_CTRL_NEG_MASK, /*!< Data active high. */ 0075 }; 0076 0077 /*! 0078 * @brief The LCDIF v2 interrupts. 0079 */ 0080 enum _lcdifv2_interrupt 0081 { 0082 kLCDIFV2_Layer0FifoEmptyInterrupt = LCDIFV2_MAKE_FIFO_EMPTY_INTERRUPT(0), /*!< Layer 0 FIFO empty. */ 0083 kLCDIFV2_Layer1FifoEmptyInterrupt = LCDIFV2_MAKE_FIFO_EMPTY_INTERRUPT(1), /*!< Layer 1 FIFO empty. */ 0084 kLCDIFV2_Layer2FifoEmptyInterrupt = LCDIFV2_MAKE_FIFO_EMPTY_INTERRUPT(2), /*!< Layer 2 FIFO empty. */ 0085 kLCDIFV2_Layer3FifoEmptyInterrupt = LCDIFV2_MAKE_FIFO_EMPTY_INTERRUPT(3), /*!< Layer 3 FIFO empty. */ 0086 kLCDIFV2_Layer4FifoEmptyInterrupt = LCDIFV2_MAKE_FIFO_EMPTY_INTERRUPT(4), /*!< Layer 4 FIFO empty. */ 0087 kLCDIFV2_Layer5FifoEmptyInterrupt = LCDIFV2_MAKE_FIFO_EMPTY_INTERRUPT(5), /*!< Layer 5 FIFO empty. */ 0088 kLCDIFV2_Layer6FifoEmptyInterrupt = LCDIFV2_MAKE_FIFO_EMPTY_INTERRUPT(6), /*!< Layer 6 FIFO empty. */ 0089 kLCDIFV2_Layer7FifoEmptyInterrupt = LCDIFV2_MAKE_FIFO_EMPTY_INTERRUPT(7), /*!< Layer 7 FIFO empty. */ 0090 kLCDIFV2_Layer0DmaDoneInterrupt = LCDIFV2_MAKE_DMA_DONE_INTERRUPT(0), /*!< Layer 0 DMA done. */ 0091 kLCDIFV2_Layer1DmaDoneInterrupt = LCDIFV2_MAKE_DMA_DONE_INTERRUPT(1), /*!< Layer 1 DMA done. */ 0092 kLCDIFV2_Layer2DmaDoneInterrupt = LCDIFV2_MAKE_DMA_DONE_INTERRUPT(2), /*!< Layer 2 DMA done. */ 0093 kLCDIFV2_Layer3DmaDoneInterrupt = LCDIFV2_MAKE_DMA_DONE_INTERRUPT(3), /*!< Layer 3 DMA done. */ 0094 kLCDIFV2_Layer4DmaDoneInterrupt = LCDIFV2_MAKE_DMA_DONE_INTERRUPT(4), /*!< Layer 4 DMA done. */ 0095 kLCDIFV2_Layer5DmaDoneInterrupt = LCDIFV2_MAKE_DMA_DONE_INTERRUPT(5), /*!< Layer 5 DMA done. */ 0096 kLCDIFV2_Layer6DmaDoneInterrupt = LCDIFV2_MAKE_DMA_DONE_INTERRUPT(6), /*!< Layer 6 DMA done. */ 0097 kLCDIFV2_Layer7DmaDoneInterrupt = LCDIFV2_MAKE_DMA_DONE_INTERRUPT(7), /*!< Layer 7 DMA done. */ 0098 kLCDIFV2_Layer0DmaErrorInterrupt = LCDIFV2_MAKE_DMA_ERROR_INTERRUPT(0), /*!< Layer 0 DMA error. */ 0099 kLCDIFV2_Layer1DmaErrorInterrupt = LCDIFV2_MAKE_DMA_ERROR_INTERRUPT(1), /*!< Layer 1 DMA error. */ 0100 kLCDIFV2_Layer2DmaErrorInterrupt = LCDIFV2_MAKE_DMA_ERROR_INTERRUPT(2), /*!< Layer 2 DMA error. */ 0101 kLCDIFV2_Layer3DmaErrorInterrupt = LCDIFV2_MAKE_DMA_ERROR_INTERRUPT(3), /*!< Layer 3 DMA error. */ 0102 kLCDIFV2_Layer4DmaErrorInterrupt = LCDIFV2_MAKE_DMA_ERROR_INTERRUPT(4), /*!< Layer 4 DMA error. */ 0103 kLCDIFV2_Layer5DmaErrorInterrupt = LCDIFV2_MAKE_DMA_ERROR_INTERRUPT(5), /*!< Layer 5 DMA error. */ 0104 kLCDIFV2_Layer6DmaErrorInterrupt = LCDIFV2_MAKE_DMA_ERROR_INTERRUPT(6), /*!< Layer 6 DMA error. */ 0105 kLCDIFV2_Layer7DmaErrorInterrupt = LCDIFV2_MAKE_DMA_ERROR_INTERRUPT(7), /*!< Layer 7 DMA error. */ 0106 kLCDIFV2_VerticalBlankingInterrupt = (1U << 2U), /*!< Start of vertical blanking period. */ 0107 kLCDIFV2_OutputUnderrunInterrupt = (1U << 1U), /*!< Output buffer underrun. */ 0108 kLCDIFV2_VsyncEdgeInterrupt = (1U << 0U), /*!< Interrupt at VSYNC edge. */ 0109 }; 0110 0111 /*! @brief The LCDIF v2 output line order. */ 0112 typedef enum _lcdifv2_line_order 0113 { 0114 kLCDIFV2_LineOrderRGB = 0, /*!< RGB */ 0115 kLCDIFV2_LineOrderRBG, /*!< RBG */ 0116 kLCDIFV2_LineOrderGBR, /*!< GBR */ 0117 kLCDIFV2_LineOrderGRB, /*!< GRB */ 0118 kLCDIFV2_LineOrderBRG, /*!< BRG */ 0119 kLCDIFV2_LineOrderBGR, /*!< BGR */ 0120 } lcdifv2_line_order_t; 0121 0122 /*! 0123 * @brief LCDIF v2 display configure structure. 0124 */ 0125 typedef struct _lcdifv2_display_config 0126 { 0127 uint16_t panelWidth; /*!< Display panel width, pixels per line. */ 0128 uint16_t panelHeight; /*!< Display panel height, how many lines per panel. */ 0129 uint8_t hsw; /*!< HSYNC pulse width. */ 0130 uint8_t hfp; /*!< Horizontal front porch. */ 0131 uint8_t hbp; /*!< Horizontal back porch. */ 0132 uint8_t vsw; /*!< VSYNC pulse width. */ 0133 uint8_t vfp; /*!< Vrtical front porch. */ 0134 uint8_t vbp; /*!< Vertical back porch. */ 0135 uint32_t polarityFlags; /*!< OR'ed value of @ref _lcdifv2_polarity_flags, used to contol the signal polarity. */ 0136 lcdifv2_line_order_t lineOrder; /*!< Line order. */ 0137 } lcdifv2_display_config_t; 0138 0139 /*! @brief LCDIF v2 color space conversion mode. */ 0140 typedef enum _lcdifv2_csc_mode 0141 { 0142 kLCDIFV2_CscDisable = 0U, /*!< Disable the CSC. */ 0143 kLCDIFV2_CscYUV2RGB, /*!< YUV to RGB. */ 0144 kLCDIFV2_CscYCbCr2RGB, /*!< YCbCr to RGB. */ 0145 } lcdifv2_csc_mode_t; 0146 0147 /*! @brief LCDIF v2 pixel format. */ 0148 typedef enum _lcdifv2_pixel_format 0149 { 0150 kLCDIFV2_PixelFormatIndex1BPP = LCDIFV2_CTRLDESCL5_BPP(0U), /*!< LUT index 1 bit. */ 0151 kLCDIFV2_PixelFormatIndex2BPP = LCDIFV2_CTRLDESCL5_BPP(1U), /*!< LUT index 2 bit. */ 0152 kLCDIFV2_PixelFormatIndex4BPP = LCDIFV2_CTRLDESCL5_BPP(2U), /*!< LUT index 4 bit. */ 0153 kLCDIFV2_PixelFormatIndex8BPP = LCDIFV2_CTRLDESCL5_BPP(3U), /*!< LUT index 8 bit. */ 0154 kLCDIFV2_PixelFormatRGB565 = LCDIFV2_CTRLDESCL5_BPP(4U), /*!< RGB565, two pixels use 32 bits. */ 0155 kLCDIFV2_PixelFormatARGB1555 = LCDIFV2_CTRLDESCL5_BPP(5U), /*!< ARGB1555, two pixels use 32 bits. */ 0156 kLCDIFV2_PixelFormatARGB4444 = LCDIFV2_CTRLDESCL5_BPP(6U), /*!< ARGB4444, two pixels use 32 bits. */ 0157 kLCDIFV2_PixelFormatUYVY = LCDIFV2_CTRLDESCL5_BPP(7U) | 0158 LCDIFV2_CTRLDESCL5_YUV_FORMAT(0U), /*!< UYVY, only layer 0 and layer 1 support this. */ 0159 kLCDIFV2_PixelFormatVYUY = LCDIFV2_CTRLDESCL5_BPP(7U) | 0160 LCDIFV2_CTRLDESCL5_YUV_FORMAT(1U), /*!< VYUY, only layer 0 and layer 1 support this. */ 0161 kLCDIFV2_PixelFormatYUYV = LCDIFV2_CTRLDESCL5_BPP(7U) | 0162 LCDIFV2_CTRLDESCL5_YUV_FORMAT(2U), /*!< YUYV, only layer 0 and layer 1 support this. */ 0163 kLCDIFV2_PixelFormatYVYU = LCDIFV2_CTRLDESCL5_BPP(7U) | 0164 LCDIFV2_CTRLDESCL5_YUV_FORMAT(3U), /*!< YVYU, only layer 0 and layer 1 support this. */ 0165 kLCDIFV2_PixelFormatRGB888 = LCDIFV2_CTRLDESCL5_BPP(8U), /*!< RGB888 packed, one pixel uses 24 bits. */ 0166 kLCDIFV2_PixelFormatARGB8888 = LCDIFV2_CTRLDESCL5_BPP(9U), /*!< ARGB8888 unpacked, one pixel uses 32 bits. */ 0167 kLCDIFV2_PixelFormatABGR8888 = LCDIFV2_CTRLDESCL5_BPP(10U), /*!< ABGR8888 unpacked, one pixel uses 32 bits. */ 0168 } lcdifv2_pixel_format_t; 0169 0170 /*! @brief LCDIF v2 source buffer configuration. */ 0171 typedef struct _lcdifv2_buffer_config 0172 { 0173 uint16_t strideBytes; /*!< Number of bytes between two vertically adjacent pixels, suggest 64-bit aligned. */ 0174 lcdifv2_pixel_format_t pixelFormat; /*!< Source buffer pixel format. */ 0175 } lcdifv2_buffer_config_t; 0176 0177 /*! 0178 * @brief LCDIF v2 layer alpha blending mode. 0179 */ 0180 typedef enum _lcdifv2_alpha_mode 0181 { 0182 kLCDIFV2_AlphaDisable, /*!< Disable alpha blend. */ 0183 kLCDIFV2_AlphaOverride, /*!< Use the gobal alpha value, pixel defined alpha value is overridden. */ 0184 kLCDIFV2_AlphaEmbedded, /*!< Use the pixel defined alpha value. */ 0185 kLCDIFV2_AlphaPoterDuff, /*!< Use the PoterDuff alpha blending. */ 0186 } lcdifv2_alpha_mode_t; 0187 0188 /*! 0189 * @brief LCDIF v2 PoterDuff alpha mode. 0190 */ 0191 typedef enum _lcdifv2_pd_alpha_mode 0192 { 0193 kLCDIFV2_PD_AlphaStraight = 0, /*!< Straight mode. */ 0194 kLCDIFV2_PD_AlphaInversed = 1, /*!< Inversed mode. */ 0195 } lcdifv2_pd_alpha_mode_t; 0196 0197 /*! 0198 * @brief LCDIF v2 PoterDuff color mode. 0199 */ 0200 typedef enum _lcdifv2_pd_color_mode 0201 { 0202 kLCDIFV2_PD_ColorNoAlpha = 0, /*!< Output color directly. */ 0203 kLCDIFV2_PD_ColorWithAlpha = 1, /*!< Output color multiples alpha. */ 0204 } lcdifv2_pd_color_mode_t; 0205 0206 /*! 0207 * @brief LCDIF v2 PoterDuff global alpha mode. 0208 */ 0209 typedef enum _lcdifv2_pd_global_alpha_mode 0210 { 0211 kLCDIFV2_PD_GlobalAlpha = 0, /*!< Use global alpha. */ 0212 kLCDIFV2_PD_LocalAlpha = 1, /*!< Use local alpha. */ 0213 kLCDIFV2_PD_ScaledAlpha = 2, /*!< Use scaled alpha. */ 0214 } lcdifv2_pd_global_alpha_mode_t; 0215 0216 /*! 0217 * @brief LCDIF v2 PoterDuff factor mode. 0218 */ 0219 typedef enum _lcdifv2_pd_factor_mode 0220 { 0221 kLCDIFV2_PD_FactorOne = 0, /*!< Use 1. */ 0222 kLCDIFV2_PD_FactorZero = 1, /*!< Use 0. */ 0223 kLCDIFV2_PD_FactorStraightAlpha = 2, /*!< Use straight alpha. */ 0224 kLCDIFV2_PD_FactorInversedAlpha = 3, /*!< Use inversed alpha. */ 0225 } lcdifv2_pd_factor_mode_t; 0226 0227 /*! 0228 * @brief LCDIF v2 layer alpha blending configuration. 0229 */ 0230 typedef struct _lcdifv2_blend_config 0231 { 0232 uint8_t globalAlpha; /*!< Global alpha value, only used when 0233 @ref alphaMode is @ref kLCDIFV2_AlphaOverride or 0234 @ref kLCDIFV2_AlphaPoterDuff */ 0235 lcdifv2_alpha_mode_t alphaMode; /*!< Alpha mode. */ 0236 lcdifv2_pd_alpha_mode_t pdAlphaMode; /*!< PoterDuff alpha mode, only used when @ref alphaMode is @ref 0237 kLCDIFV2_AlphaPoterDuff */ 0238 lcdifv2_pd_color_mode_t pdColorMode; /*!< PoterDuff color mode, only used when @ref alphaMode is @ref 0239 kLCDIFV2_AlphaPoterDuff */ 0240 lcdifv2_pd_global_alpha_mode_t pdGlobalAlphaMode; /*!< PoterDuff global alpha mode, only used when @ref alphaMode is 0241 @ref kLCDIFV2_AlphaPoterDuff */ 0242 lcdifv2_pd_factor_mode_t pdFactorMode; /*!< PoterDuff factor mode, only used when @ref alphaMode is @ref 0243 kLCDIFV2_AlphaPoterDuff */ 0244 } lcdifv2_blend_config_t; 0245 0246 /*! @brief LCDIFv2 Porter Duff blend mode. Note: Don't change the enum item value */ 0247 typedef enum _lcdifv2_pd_blend_mode 0248 { 0249 kLCDIFV2_PD_Src = 0, /*!< Source Only */ 0250 kLCDIFV2_PD_Atop, /*!< Source Atop */ 0251 kLCDIFV2_PD_Over, /*!< Source Over */ 0252 kLCDIFV2_PD_In, /*!< Source In. */ 0253 kLCDIFV2_PD_Out, /*!< Source Out. */ 0254 kLCDIFV2_PD_Dst, /*!< Destination Only. */ 0255 kLCDIFV2_PD_DstAtop, /*!< Destination Atop. */ 0256 kLCDIFV2_PD_DstOver, /*!< Destination Over. */ 0257 kLCDIFV2_PD_DstIn, /*!< Destination In. */ 0258 kLCDIFV2_PD_DstOut, /*!< Destination Out. */ 0259 kLCDIFV2_PD_Xor, /*!< XOR. */ 0260 kLCDIFV2_PD_Clear, /*!< Clear. */ 0261 kLCDIFV2_PD_Max, /*!< Used for boarder detection. */ 0262 } lcdifv2_pd_blend_mode_t; 0263 0264 /*! @brief LCDIFv2 Porter Duff layer. Note: Don't change the enum item value */ 0265 typedef enum _lcdifv2_pd_layer 0266 { 0267 kLCDIFV2_PD_SrcLayer = 0, /*!< Source layer. */ 0268 kLCDIFV2_PD_DestLayer = 1, /*!< Destination layer. */ 0269 kLCDIFV2_PD_LayerMax = 2, /*!< Used for boarder detection. */ 0270 } lcdifv2_pd_layer_t; 0271 0272 /******************************************************************************* 0273 * APIs 0274 ******************************************************************************/ 0275 0276 #if defined(__cplusplus) 0277 extern "C" { 0278 #endif /* __cplusplus */ 0279 0280 /*! 0281 * @name LCDIF v2 initialization and de-initialization 0282 * @{ 0283 */ 0284 0285 /*! 0286 * @brief Initializes the LCDIF v2. 0287 * 0288 * This function ungates the LCDIF v2 clock and release the peripheral reset. 0289 * 0290 * @param base LCDIF v2 peripheral base address. 0291 */ 0292 void LCDIFV2_Init(LCDIFV2_Type *base); 0293 0294 /*! 0295 * @brief Deinitializes the LCDIF peripheral. 0296 * 0297 * @param base LCDIF peripheral base address. 0298 */ 0299 void LCDIFV2_Deinit(LCDIFV2_Type *base); 0300 0301 /*! 0302 * @brief Reset the LCDIF v2. 0303 * 0304 * @param base LCDIF peripheral base address. 0305 */ 0306 void LCDIFV2_Reset(LCDIFV2_Type *base); 0307 0308 /* @} */ 0309 0310 /*! 0311 * @name Display 0312 * @{ 0313 */ 0314 0315 /*! 0316 * @brief Gets the LCDIF display default configuration structure. 0317 * 0318 * This function sets the configuration structure to default values. 0319 * The default configuration is set to the following values. 0320 * @code 0321 config->panelWidth = 0U; 0322 config->panelHeight = 0U; 0323 config->hsw = 3U; 0324 config->hfp = 3U; 0325 config->hbp = 3U; 0326 config->vsw = 3U; 0327 config->vfp = 3U; 0328 config->vbp = 3U; 0329 config->polarityFlags = kLCDIFV2_VsyncActiveHigh | kLCDIFV2_HsyncActiveHigh | kLCDIFV2_DataEnableActiveHigh | 0330 kLCDIFV2_DriveDataOnRisingClkEdge | kLCDIFV2_DataActiveHigh; 0331 config->lineOrder = kLCDIFV2_LineOrderRGB; 0332 @endcode 0333 * 0334 * @param config Pointer to the LCDIF configuration structure. 0335 */ 0336 void LCDIFV2_DisplayGetDefaultConfig(lcdifv2_display_config_t *config); 0337 0338 /*! 0339 * @brief Set the LCDIF v2 display configurations. 0340 * 0341 * @param base LCDIF peripheral base address. 0342 * @param config Pointer to the LCDIF configuration structure. 0343 */ 0344 void LCDIFV2_SetDisplayConfig(LCDIFV2_Type *base, const lcdifv2_display_config_t *config); 0345 0346 /*! 0347 * @brief Enable or disable the display 0348 * 0349 * @param base LCDIF peripheral base address. 0350 * @param enable Enable or disable. 0351 */ 0352 static inline void LCDIFV2_EnableDisplay(LCDIFV2_Type *base, bool enable) 0353 { 0354 if (enable) 0355 { 0356 base->DISP_PARA |= LCDIFV2_DISP_PARA_DISP_ON_MASK; 0357 } 0358 else 0359 { 0360 base->DISP_PARA &= ~LCDIFV2_DISP_PARA_DISP_ON_MASK; 0361 } 0362 } 0363 0364 /* @} */ 0365 0366 /*! 0367 * @name Interrupts 0368 * @{ 0369 */ 0370 0371 /*! 0372 * @brief Enables LCDIF interrupt requests. 0373 * 0374 * @param base LCDIF peripheral base address. 0375 * @param domain CPU domain the interrupt signal routed to. 0376 * @param mask interrupt source, OR'ed value of _lcdifv2_interrupt. 0377 */ 0378 static inline void LCDIFV2_EnableInterrupts(LCDIFV2_Type *base, uint8_t domain, uint32_t mask) 0379 { 0380 base->INT[domain].INT_ENABLE |= mask; 0381 } 0382 0383 /*! 0384 * @brief Disables LCDIF interrupt requests. 0385 * 0386 * @param base LCDIF peripheral base address. 0387 * @param domain CPU domain the interrupt signal routed to. 0388 * @param mask interrupt source, OR'ed value of _lcdifv2_interrupt. 0389 */ 0390 static inline void LCDIFV2_DisableInterrupts(LCDIFV2_Type *base, uint8_t domain, uint32_t mask) 0391 { 0392 base->INT[domain].INT_ENABLE &= ~mask; 0393 } 0394 0395 /*! 0396 * @brief Get LCDIF interrupt peding status. 0397 * 0398 * @param base LCDIF peripheral base address. 0399 * @param domain CPU domain the interrupt signal routed to. 0400 * @return Interrupt pending status, OR'ed value of _lcdifv2_interrupt. 0401 */ 0402 static inline uint32_t LCDIFV2_GetInterruptStatus(LCDIFV2_Type *base, uint8_t domain) 0403 { 0404 return base->INT[domain].INT_STATUS; 0405 } 0406 0407 /*! 0408 * @brief Clear LCDIF interrupt peding status. 0409 * 0410 * @param base LCDIF peripheral base address. 0411 * @param domain CPU domain the interrupt signal routed to. 0412 * @param mask of the flags to clear, OR'ed value of _lcdifv2_interrupt. 0413 */ 0414 static inline void LCDIFV2_ClearInterruptStatus(LCDIFV2_Type *base, uint8_t domain, uint32_t mask) 0415 { 0416 base->INT[domain].INT_STATUS = mask; 0417 } 0418 0419 /* @} */ 0420 0421 /*! 0422 * @name LUT 0423 * @{ 0424 */ 0425 0426 /*! 0427 * @brief Set the LUT data. 0428 * 0429 * This function sets the specific layer LUT data, if @p useShadowLoad is true, 0430 * call @ref LCDIFV2_TriggerLayerShadowLoad after this function, the 0431 * LUT will be loaded to the hardware during next vertical blanking period. 0432 * If @p useShadowLoad is false, the LUT data is loaded to hardware directly. 0433 * 0434 * @param base LCDIF v2 peripheral base address. 0435 * @param layerIndex Which layer to set. 0436 * @param lutData The LUT data to load. 0437 * @param count Count of @p lutData. 0438 * @param useShadowLoad Use shadow load. 0439 * @retval kStatus_Success Set success. 0440 * @retval kStatus_Fail Previous LUT data is not loaded to hardware yet. 0441 */ 0442 status_t LCDIFV2_SetLut( 0443 LCDIFV2_Type *base, uint8_t layerIndex, const uint32_t *lutData, uint16_t count, bool useShadowLoad); 0444 0445 /* @} */ 0446 0447 /*! 0448 * @name Layer operation 0449 * @{ 0450 */ 0451 0452 /*! 0453 * @brief Set the layer dimension. 0454 * 0455 * @param base LCDIFv2 peripheral base address. 0456 * @param layerIndex Layer layerIndex. 0457 * @param width Layer width in pixel. 0458 * @param height Layer height. 0459 * 0460 * @note The layer width must be in multiples of the number of pixels that can be stored in 32 bits 0461 */ 0462 static inline void LCDIFV2_SetLayerSize(LCDIFV2_Type *base, uint8_t layerIndex, uint16_t width, uint16_t height) 0463 { 0464 base->LAYER[layerIndex].CTRLDESCL1 = 0465 ((uint32_t)height << LCDIFV2_CTRLDESCL1_HEIGHT_SHIFT) | ((uint32_t)width << LCDIFV2_CTRLDESCL1_WIDTH_SHIFT); 0466 } 0467 0468 /*! 0469 * @brief Set the layer position in output frame. 0470 * 0471 * @param base LCDIFv2 peripheral base address. 0472 * @param layerIndex Layer layerIndex. 0473 * @param offsetX Horizontal offset, start from 0. 0474 * @param offsetY Vertical offset, start from 0. 0475 */ 0476 static inline void LCDIFV2_SetLayerOffset(LCDIFV2_Type *base, uint8_t layerIndex, uint16_t offsetX, uint16_t offsetY) 0477 { 0478 base->LAYER[layerIndex].CTRLDESCL2 = 0479 ((uint32_t)offsetX << LCDIFV2_CTRLDESCL2_POSX_SHIFT) | ((uint32_t)offsetY << LCDIFV2_CTRLDESCL2_POSY_SHIFT); 0480 } 0481 0482 /*! 0483 * @brief Set the layer source buffer configuration. 0484 * 0485 * @param base LCDIFv2 peripheral base address. 0486 * @param layerIndex Layer layerIndex. 0487 * @param config Pointer to the configuration. 0488 */ 0489 void LCDIFV2_SetLayerBufferConfig(LCDIFV2_Type *base, uint8_t layerIndex, const lcdifv2_buffer_config_t *config); 0490 0491 /*! 0492 * @brief Set the layer source buffer address. 0493 * 0494 * This function is used for fast runtime source buffer change. 0495 * 0496 * @param base LCDIFv2 peripheral base address. 0497 * @param layerIndex Layer layerIndex. 0498 * @param addr The new source buffer address passed to the layer, should be 64-bit aligned. 0499 */ 0500 static inline void LCDIFV2_SetLayerBufferAddr(LCDIFV2_Type *base, uint8_t layerIndex, uint32_t addr) 0501 { 0502 base->LAYER[layerIndex].CTRLDESCL4 = LCDIFV2_ADDR_CPU_2_IP(addr); 0503 } 0504 0505 /*! 0506 * @brief Enable or disable the layer. 0507 * 0508 * @param base LCDIFv2 peripheral base address. 0509 * @param layerIndex Layer layerIndex. 0510 * @param enable Pass in true to enable, false to disable. 0511 */ 0512 static inline void LCDIFV2_EnableLayer(LCDIFV2_Type *base, uint8_t layerIndex, bool enable) 0513 { 0514 if (enable) 0515 { 0516 base->LAYER[layerIndex].CTRLDESCL5 |= LCDIFV2_CTRLDESCL5_EN_MASK; 0517 } 0518 else 0519 { 0520 base->LAYER[layerIndex].CTRLDESCL5 &= ~LCDIFV2_CTRLDESCL5_EN_MASK; 0521 } 0522 } 0523 0524 /*! 0525 * @brief Trigger the layer configuration shadow load. 0526 * 0527 * The new layer configurations are written to the shadow registers first, 0528 * When all configurations written finished, call this function, then shadowed 0529 * control registers are updated to the active control registers on VSYNC of 0530 * next frame. 0531 * 0532 * @param base LCDIFv2 peripheral base address. 0533 * @param layerIndex Layer layerIndex. 0534 */ 0535 static inline void LCDIFV2_TriggerLayerShadowLoad(LCDIFV2_Type *base, uint8_t layerIndex) 0536 { 0537 base->LAYER[layerIndex].CTRLDESCL5 |= LCDIFV2_CTRLDESCL5_SHADOW_LOAD_EN_MASK; 0538 } 0539 0540 /*! 0541 * @brief Set the layer back ground color. 0542 * 0543 * The back ground color is used when layer not actived. 0544 * 0545 * @param base LCDIFv2 peripheral base address. 0546 * @param layerIndex Index of the layer. 0547 * @param backGroundColor Background color to use when this layer is not active. 0548 */ 0549 static inline void LCDIFV2_SetLayerBackGroundColor(LCDIFV2_Type *base, uint8_t layerIndex, uint32_t backGroundColor) 0550 { 0551 base->LAYER[layerIndex].CTRLDESCL6 = backGroundColor; 0552 } 0553 0554 /*! 0555 * @brief Set the layer alpha blend mode. 0556 * 0557 * @param base LCDIFv2 peripheral base address. 0558 * @param layerIndex Index of the CSC unit. 0559 * @param config Pointer to the blend configuration. 0560 */ 0561 void LCDIFV2_SetLayerBlendConfig(LCDIFV2_Type *base, uint8_t layerIndex, const lcdifv2_blend_config_t *config); 0562 0563 /*! 0564 * @brief Set the color space conversion mode. 0565 * 0566 * Supports YUV2RGB and YCbCr2RGB. 0567 * 0568 * @param base LCDIFv2 peripheral base address. 0569 * @param layerIndex Index of the layer. 0570 * @param mode The conversion mode. 0571 */ 0572 void LCDIFV2_SetCscMode(LCDIFV2_Type *base, uint8_t layerIndex, lcdifv2_csc_mode_t mode); 0573 0574 /* @} */ 0575 0576 /*! 0577 * @name Porter Duff 0578 * @{ 0579 */ 0580 0581 /*! 0582 * @brief Get the blend configuration for Porter Duff blend. 0583 * 0584 * This function gets the blend configuration for Porter Duff blend, 0585 * config->pdFactorMode is set according to @p layer and @p mode, 0586 * other blend configurations are set to: 0587 * 0588 * @code 0589 config->pdAlphaMode = kLCDIFV2_PD_AlphaStraight; 0590 config->pdColorMode = kLCDIFV2_PD_ColorStraight; 0591 config->pdGlobalAlphaMode = kLCDIFV2_PD_LocalAlpha; 0592 config->alphaMode = kLCDIFV2_AlphaPoterDuff; 0593 @endcode 0594 * 0595 * This is the basic Porter Duff blend configuration, user still could 0596 * modify the configurations after this function. 0597 * 0598 * @param mode Porter Duff blend mode. 0599 * @param layer The configuration for source layer or destination layer. 0600 * @param config Pointer to the configuration. 0601 * @retval kStatus_Success Get the configuration successfully. 0602 * @retval kStatus_InvalidArgument The argument is invalid. 0603 */ 0604 status_t LCDIFV2_GetPorterDuffConfig(lcdifv2_pd_blend_mode_t mode, 0605 lcdifv2_pd_layer_t layer, 0606 lcdifv2_blend_config_t *config); 0607 0608 /* @} */ 0609 0610 /*! 0611 * @name Misc 0612 * @{ 0613 */ 0614 0615 /*! 0616 * @brief Get the global alpha values for multiple layer blend. 0617 * 0618 * This function calculates the global alpha value for each layer based on the 0619 * desired blended alpha. 0620 * 0621 * When all layers use the global alpha, the relationship of blended alpha 0622 * and global alpha of each layer is: 0623 * 0624 * Layer 7: ba7 = ga7 0625 * Layer 6: ba6 = ga6 * (1-ga7) 0626 * Layer 5: ba5 = ga5 * (1-ga6) * (1-ga7) 0627 * Layer 4: ba4 = ga4 * (1-ga5) * (1-ga6) * (1-ga7) 0628 * Layer 3: ba3 = ga3 * (1-ga4) * (1-ga5) * (1-ga6) * (1-ga7) 0629 * Layer 2: ba2 = ga2 * (1-ga3) * (1-ga4) * (1-ga5) * (1-ga6) * (1-ga7) 0630 * Layer 1: ba1 = ga1 * (1-ga2) * (1-ga3) * (1-ga4) * (1-ga5) * (1-ga6) * (1-ga7) 0631 * Layer 0: ba0 = 1 * (1-ga1) * (1-ga2) * (1-ga3) * (1-ga4) * (1-ga5) * (1-ga6) * (1-ga7) 0632 * 0633 * Here baN is the blended alpha of layer N, gaN is the global alpha configured to layer N. 0634 * 0635 * This function calculates the global alpha based on the blended alpha. The @p blendedAlpha and 0636 * @p globalAlpha are all arrays of size @p layerCount. The first layer is a background layer, 0637 * so blendedAlpha[0] is useless, globalAlpha[0] is always 255. 0638 * 0639 * @param[in] blendedAlpha The desired blended alpha value, alpha range 0~255. 0640 * @param[out] globalAlpha Calculated global alpha set to each layer register. 0641 * @param[in] layerCount Total layer count. 0642 * @retval kStatus_Success Get successfully. 0643 * @retval kStatus_InvalidArgument The argument is invalid. 0644 */ 0645 status_t LCDIFV2_GetMultiLayerGlobalAlpha(const uint8_t blendedAlpha[], uint8_t globalAlpha[], uint8_t layerCount); 0646 0647 /* @} */ 0648 0649 #if defined(__cplusplus) 0650 } 0651 #endif /* __cplusplus */ 0652 0653 /* @} */ 0654 0655 #endif /*_FSL_LCDIFV2_H_*/
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |