fsl_lcdifv2.h 23 KB

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