nu_lcd.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. /**************************************************************************//**
  2. * @file lcd.h
  3. * @version V1.00
  4. * @brief N9H30 LCD driver header file
  5. *
  6. * SPDX-License-Identifier: Apache-2.0
  7. * @copyright (C) 2018 Nuvoton Technology Corp. All rights reserved.
  8. *****************************************************************************/
  9. #ifndef __NU_LCD_H__
  10. #define __NU_LCD_H__
  11. #ifdef __cplusplus
  12. extern "C"
  13. {
  14. #endif
  15. /** @addtogroup N9H30_Device_Driver N9H30 Device Driver
  16. @{
  17. */
  18. /** @addtogroup N9H30_LCD_Driver LCD Driver
  19. @{
  20. */
  21. /** @addtogroup N9H30_LCD_EXPORTED_CONSTANTS LCD Exported Constants
  22. @{
  23. */
  24. /// @cond HIDDEN_SYMBOLS
  25. /* bit definition of REG_LCM_DCCS register */
  26. #define VPOSTB_HC_EN ((UINT32)1<<31)
  27. #define VPOSTB_DISP_ON (1<<25)
  28. #define VPOSTB_ITUEN (1<<15)
  29. #define VPOSTB_OSD_SRC_YUV422 (0<<12)
  30. #define VPOSTB_OSD_SRC_YCBCR422 (1<<12)
  31. #define VPOSTB_OSD_SRC_RGB888 (2<<12)
  32. #define VPOSTB_OSD_SRC_RGB666 (3<<12)
  33. #define VPOSTB_OSD_SRC_RGB565 (4<<12)
  34. #define VPOSTB_OSD_SRC_RGB444_LOW (5<<12)
  35. #define VPOSTB_OSD_SRC_RGB444_HIGH (7<<12)
  36. #define VPOSTB_VA_SRC_YUV422 (0<<8 )
  37. #define VPOSTB_VA_SRC_YCBCR422 (1<<8 )
  38. #define VPOSTB_VA_SRC_RGB888 (2<<8 )
  39. #define VPOSTB_VA_SRC_RGB666 (3<<8 )
  40. #define VPOSTB_VA_SRC_RGB565 (4<<8 )
  41. #define VPOSTB_VA_SRC_RGB444_LOW (5<<8 )
  42. #define VPOSTB_VA_SRC_RGB444_HIGH (7<<8 )
  43. #define VPOSTB_SINGLE (1<<7 )
  44. #define VPOSTB_FIELD_INTR (1<<6 )
  45. #define VPOSTB_CMD_ON (1<<5 )
  46. #define VPOSTB_DISP_INT_EN (1<<4 )
  47. #define VPOSTB_DISP_OUT_EN (1<<3 )
  48. #define VPOSTB_OSD_EN (1<<2 )
  49. #define VPOSTB_VA_EN (1<<1 )
  50. #define VPOSTB_ENG_RST (1)
  51. /* bit definition of REG_LCM_DEV_CTRL register */
  52. #define VPOSTB_CMDHIGH (0)
  53. #define VPOSTB_CMDLOW ((UINT32)1<<31)
  54. #define VPOSTB_CM16t18LOW (0)
  55. #define VPOSTB_CM16t18HIGH ((UINT32)1<<30)
  56. #define VPOSTB_CMD8 (0)
  57. #define VPOSTB_CMD16 ((UINT32)1<<29)
  58. #define VPOSTB_IM256K_9or18 (0)
  59. #define VPOSTB_IM256K_8or16 ((UINT32)1<<28)
  60. #define VPOSTB_MPU80 (0)
  61. #define VPOSTB_MPU68 (1<<27)
  62. #define VPOSTB_DATA8or9 (0)
  63. #define VPOSTB_DATA16or18 (1<<26)
  64. #define VPOSTB_COLORTYPE_4K (0)
  65. #define VPOSTB_COLORTYPE_64K (1<<24)
  66. #define VPOSTB_COLORTYPE_256K (2<<24)
  67. #define VPOSTB_COLORTYPE_16M (3<<24)
  68. #define VPOSTB_LACE (1<<23)
  69. #define VPOSTB_VR_LACE (1<<22)
  70. #define VPOSTB_V_POL (1<<21)
  71. #define VPOSTB_H_POL (1<<20)
  72. #define VPOSTB_FAL_D (1<<19)
  73. #define VPOSTB_YUV2CCIR (1<<16)
  74. #define VPOSTB_DEVICE_SYNC_YUV422 (0)
  75. #define VPOSTB_DEVICE_SYNC_UNIPAC (4<<5)
  76. #define VPOSTB_DEVICE_SYNC_EPSON (5<<5)
  77. #define VPOSTB_DEVICE_SYNC_HIGHCOLOR (6<<5)
  78. #define VPOSTB_DEVICE_MPU (7<<5)
  79. #define VPOSTB_SWAP_YUYV (1<<1)
  80. /* bit definition of REG_LCM_INT_CS register */
  81. #define VPOSTB_DISP_F_INT ((UINT32)1<<31)
  82. #define VPOSTB_DISP_F_STATUS (1<<30)
  83. #define VPOSTB_UNDERRUN_INT (1<<29)
  84. #define VPOSTB_BUS_ERROR_INT (1<<28)
  85. #define VPOSTB_FLY_ERR (1<<27)
  86. #define VPOSTB_UNDERRUN_EN (1<<1)
  87. #define VPOSTB_DISP_F_EN (1)
  88. /* bit definition of REG_LCM_VA_FBCTRL register */
  89. #define VPOSTB_DB_EN ((UINT32)1<<31)
  90. #define VPOSTB_FLY_EN (1<<12)
  91. /* bit definition of REG_LCM_OSD_OVERLAY register */
  92. #define VPOSTB_BLI_ON (1<<9)
  93. #define VPOSTB_CKEY_ON (1<<8)
  94. #define DISPLAY_VIDEO (0)
  95. #define DISPLAY_OSD (1)
  96. #define DISPLAY_SYNTHESIZED (2)
  97. /// @endcond HIDDEN_SYMBOLS
  98. #define VA_SRC_YUV422 (0<<8 ) /*!< YUV422 format */
  99. #define VA_SRC_YCBCR422 (1<<8 ) /*!< YCBCR422 format */
  100. #define VA_SRC_RGB888 (2<<8 ) /*!< RGB888 format */
  101. #define VA_SRC_RGB666 (3<<8 ) /*!< RGB666 format */
  102. #define VA_SRC_RGB565 (4<<8 ) /*!< RGB565 format */
  103. #define VA_SRC_RGB444_LOW (5<<8 ) /*!< RGB444 low nibble format */
  104. #define VA_SRC_RGB444_HIGH (7<<8 ) /*!< RGB444 high nibble format */
  105. #define OSD_SRC_YUV422 (0<<12) /*!< YUV422 format */
  106. #define OSD_SRC_YCBCR422 (1<<12) /*!< YCBCR422 format */
  107. #define OSD_SRC_RGB888 (2<<12) /*!< RGB888 format */
  108. #define OSD_SRC_RGB666 (3<<12) /*!< RGB666 format */
  109. #define OSD_SRC_RGB565 (4<<12) /*!< RGB565 format */
  110. #define OSD_SRC_RGB444_LOW (5<<12) /*!< RGB444 low nibble format */
  111. #define OSD_SRC_RGB444_HIGH (7<<12) /*!< RGB444 high nibble format */
  112. #define OSD_SRC_RGB332 (6<<12) /*!< RGB332 format */
  113. #define VPOST_DISPLAY_SINGLE 1 /*!< Single display mode */
  114. #define VPOST_DISPLAY_CONTINUOUS 0 /*!< Continuous display mode */
  115. #define VPOSTB_OSD_VUP_1X (0<<16) /*!< OSD vertical scale up 1x */
  116. #define VPOSTB_OSD_VUP_2X (1<<16) /*!< OSD vertical scale up 2x */
  117. #define VPOSTB_OSD_VUP_4X (2<<16) /*!< OSD vertical scale up 4x */
  118. #define DISPLAY_VIDEO (0) /*!< Display video data */
  119. #define DISPLAY_OSD (1) /*!< Display OSD data */
  120. #define DISPLAY_SYNTHESIZED (2) /*!< Display synthesized data */
  121. #define VA_SCALE_INTERPOLATION (0) /*!< Scale mode is interpolation */
  122. #define VA_SCALE_DUPLICATION (1<<15) /*!< Scale mode is duplication */
  123. #pragma anon_unions
  124. typedef enum va_hcmode_e
  125. {
  126. HC_MODE0, /*!< 32X32X2bpp 4 color */
  127. HC_MODE1, /*!< 32X32X2bpp 3 color and 1 transparent */
  128. HC_MODE2, /*!< 64X64X2bpp 4 color */
  129. HC_MODE3, /*!< 64X64X2bpp 3 color and 1 transparent */
  130. HC_MODE4, /*!< 128X128X1bpp 2 color */
  131. HC_MODE5 /*!< 128X128X1bpp 1 color and 1 transparent */
  132. } VA_HCMODE_E;
  133. typedef struct
  134. {
  135. uint32_t ucVASrcFormat; /*!< User input Display source format */
  136. uint32_t nScreenWidth; /*!< Driver output,LCD width */
  137. uint32_t nScreenHeight; /*!< Driver output,LCD height */
  138. uint32_t nFrameBufferSize; /*!< Driver output,Frame buffer size(malloc by driver) */
  139. uint8_t ucROT90; /*!< Rotate 90 degree or not */
  140. } LCDFORMATEX;
  141. typedef struct
  142. {
  143. uint32_t ucOSDSrcFormat; /*!< User input, OSD source format */
  144. uint32_t nXstart; /*!< User input, OSD X axis position */
  145. uint32_t nYstart; /*!< User input, OSD Y axis position */
  146. uint32_t nOSDWidth; /*!< User input, OSD width */
  147. uint32_t nOSDHeight; /*!< User input, OSD height */
  148. uint32_t nImageWidth; /*!< User input, The width of OSD source image width */
  149. uint32_t *pFrameBuffer; /*!< User input, The address of OSD source image */
  150. } OSDFORMATEX;
  151. enum DIS_PANEL
  152. {
  153. DIS_PANEL_E50A2V1 = 0,
  154. DIS_PANEL_ILI9341_MPU80,
  155. DIS_LSA40AT9001,
  156. DIS_PANEL_FW070TFT,
  157. DIS_PANEL_FW043TFT,
  158. DIS_PANEL_FW070TFT_WSVGA,
  159. DIS_PANEL_CNT
  160. };
  161. typedef struct
  162. {
  163. uint32_t u32DevWidth; /*!< Panel width */
  164. uint32_t u32DevHeight; /*!< Panel height */
  165. uint32_t u32CmdLow; /*!< MPU command line low indicator */
  166. uint32_t u32Cmd16t18; /*!< MPU command width */
  167. uint32_t u32CmdBusWidth; /*!< MPU bus width */
  168. uint32_t u32DataBusWidth; /*!< Display bus width */
  169. uint32_t u32MPU_Mode; /*!< MPU mode */
  170. uint32_t u32DisplayColors; /*!< Display colors */
  171. uint32_t u32DevType; /*!< Type of display panel */
  172. union
  173. {
  174. uint32_t u32Reg_CRTCSIZE; /*!< CRTCSIZE register value */
  175. struct
  176. {
  177. uint32_t HTT: 11; /*!< Horizontal Total Pixels */
  178. uint32_t : 5;
  179. uint32_t VTT: 11; /*!< Vertical Total Scan Lines */
  180. uint32_t : 5;
  181. } sCRTCSIZE;
  182. };
  183. union
  184. {
  185. uint32_t u32Reg_CRTCDEND; /*!< CRTCDEND register value */
  186. struct
  187. {
  188. uint32_t HDEND: 11; /*!< Horizontal Display Enable End */
  189. uint32_t : 5;
  190. uint32_t VDEND: 11; /*!< Vertical Display Enable End */
  191. uint32_t : 5;
  192. } sCRTCDEND;
  193. };
  194. union
  195. {
  196. uint32_t u32Reg_CRTCHR; /*!< CRTCHR register value */
  197. struct
  198. {
  199. uint32_t HRS: 11; /*!< Internal Horizontal Retrace Start Timing */
  200. uint32_t : 5;
  201. uint32_t HRE: 11; /*!< Internal Horizontal Retrace End Low */
  202. uint32_t : 5;
  203. } sCRTCHR;
  204. };
  205. union
  206. {
  207. uint32_t u32Reg_CRTCHSYNC; /*!< CRTCHSYNC register value */
  208. struct
  209. {
  210. uint32_t HSYNC_S: 11; /*!< Horizontal Sync Start Timing */
  211. uint32_t : 5;
  212. uint32_t HSYNC_E: 11; /*!< Horizontal Sync End Timing */
  213. uint32_t : 3;
  214. uint32_t HSYNC_SHIFT: 2; /*!< Hsync Signal Adjustment For Multi-Cycles Per Pixel Mode Of Sync-Based Unipac-LCD */
  215. } sCRTCHSYNC;
  216. };
  217. union
  218. {
  219. uint32_t u32Reg_CRTCVR; /*!< CRTCVR register value */
  220. struct
  221. {
  222. uint32_t VRS: 11; /*!< Vertical Internal Retrace Start Timing */
  223. uint32_t : 5;
  224. uint32_t VRE: 11; /*!< Vertical Internal Retrace End Low */
  225. uint32_t : 5;
  226. } sCRTCVR;
  227. };
  228. } VPOST_T;
  229. #define LCM_ERR_ID 0xFFFF0400 /*!< LCM library ID */
  230. /* error code */
  231. #define ERR_NULL_BUF (LCM_ERR_ID | 0x04) /*!< error memory location */
  232. #define ERR_NO_DEVICE (LCM_ERR_ID | 0x05) /*!< error no device */
  233. #define ERR_BAD_PARAMETER (LCM_ERR_ID | 0x06) /*!< error for bad parameter */
  234. #define ERR_POWER_STATE (LCM_ERR_ID | 0x07) /*!< error power state control */
  235. /*@}*/ /* end of group N9H30_LCD_EXPORTED_CONSTANTS */
  236. /** @addtogroup N9H30_LCD_EXPORTED_FUNCTIONS LCD Exported Functions
  237. @{
  238. */
  239. void vpostLCMInit(uint32_t u32DisplayPanelID);
  240. uint8_t *vpostGetFrameBuffer(void);
  241. uint8_t *vpostGetMultiFrameBuffer(uint32_t u32Cnt);
  242. void vpostLCMDeinit(void);
  243. void vpostSetDisplayMode(uint8_t u8DisplayMode);
  244. void vpostSetVASrc(uint32_t u32VASrcType);
  245. void vpostVAStartTrigger(void);
  246. void vpostVAStopTrigger(void);
  247. void vpostVAScalingCtrl(uint8_t u8HIntegral, uint16_t u16HDecimal, uint8_t u8VIntegral, uint16_t u16VDecimal, uint32_t u32Mode);
  248. void vpostOSDSetColKey(uint8_t u8CKeyColorR, uint8_t u8CKeyColorG, uint8_t u8CKeyColorB);
  249. void vpostOSDSetColMask(uint8_t u8MaskColorR, uint8_t u8MaskColorG, uint8_t u8MaskColorB);
  250. void vpostOSDSetBlinking(uint8_t u8OSDBlinkVcnt);
  251. void vpostOSDDisableBlinking(void);
  252. void vpostSetOSDSrc(uint32_t u32OSDSrcType);
  253. uint8_t *vpostGetOSDBuffer(void);
  254. void vpostOSDEnable(void);
  255. void vpostOSDDisable(void);
  256. void vpostOSDScalingCtrl(uint8_t u8HIntegral, uint16_t u16HDecimal, uint8_t u8VScall);
  257. void vpostOSDSetWindow(uint32_t u32XStart, uint32_t u32YStart, uint32_t u32Width, uint32_t u32Height);
  258. void vpostHCInit(uint32_t *u32CursorBMPBuff, VA_HCMODE_E ucMode);
  259. void vpostHCPosCtrl(uint32_t u32CursorX, uint32_t u32CursorY);
  260. void vpostOSDSetOverlay(uint8_t u8OSDDisplayMatch, uint8_t u8OSDDisplayUnMatch, uint8_t u8OSDSynW);
  261. void vpostMPUWriteAddr(uint16_t uscmd);
  262. void vpostMPUWriteData(uint16_t usdata);
  263. uint32_t vpostMPUReadData(void);
  264. VPOST_T *vpostLCMGetInstance(uint32_t u32DisplayPanelID);
  265. void vpostSetFrameBuffer(uint8_t *pu8BufPtr);
  266. void vpostSetOSDBuffer(uint8_t *pu8BufPtr);
  267. uint8_t *vpostGetMultiOSDBuffer(uint32_t u32Cnt);
  268. /*@}*/ /* end of group N9H30_LCD_EXPORTED_FUNCTIONS */
  269. /*@}*/ /* end of group N9H30_LCD_Driver */
  270. /*@}*/ /* end of group N9H30_Device_Driver */
  271. #ifdef __cplusplus
  272. }
  273. #endif
  274. #endif //__NU_LCD_H__