drv_lcd.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /* This software is supplied "AS IS" without any warranties.
  2. * RDA assumes no responsibility or liability for the use of the software,
  3. * conveys no license or title under any patent, copyright, or mask work
  4. * right to the product. RDA reserves the right to make changes in the
  5. * software without notification. RDA also make no representation or
  6. * warranty that such application will be suitable for the specified use
  7. * without further testing or modification.
  8. */
  9. #ifndef _DRV_LCD_H_
  10. #define _DRV_LCD_H_
  11. #include "osi_compiler.h"
  12. OSI_EXTERN_C_BEGIN
  13. #include "hal_gouda.h"
  14. #include "quec_proj_config.h"
  15. #ifdef CONFIG_QUEC_PROJECT_FEATURE_LCD
  16. extern uint8_t g_lcd_index;
  17. extern int8_t ql_lcd_bwscreen_index;
  18. #endif
  19. typedef enum
  20. {
  21. LCD_ANGLE_0,
  22. LCD_ANGLE_90,
  23. LCD_ANGLE_180,
  24. LCD_ANGLE_270
  25. } lcdAngle_t;
  26. typedef enum
  27. {
  28. LCD_DIRECT_NORMAL = 0x00,
  29. LCD_DIRECT_ROT_90, // Rotation 90
  30. } lcdDirect_t;
  31. // LCD Contrller type
  32. typedef enum
  33. {
  34. LCD_CTRL_SPI = 0, //
  35. LCD_CTRL_CSI
  36. } LCD_CTRL_MODULE_E;
  37. //Block Configuration
  38. typedef struct
  39. {
  40. uint16_t start_x;
  41. uint16_t start_y;
  42. uint16_t end_x;
  43. uint16_t end_y;
  44. uint16_t colorkey;
  45. uint16_t width; //real data width in SDRAM
  46. uint8_t resolution; //0:RGB888; 1:RGB666; 2:RGB565(RGB555 if OSD)
  47. uint8_t type; //0:OSD; 1:image
  48. uint8_t alpha;
  49. uint8_t colorkey_en;
  50. uint32_t rotation;
  51. } lcdBlockCfg_t;
  52. typedef struct
  53. {
  54. void (*init)(void);
  55. void (*enterSleep)(bool is_sleep);
  56. void (*checkEsd)(void);
  57. void (*setDisplayWindow)(uint16_t left, uint16_t top, uint16_t right, uint16_t bottom);
  58. void (*invlaidateRect)(uint16_t left, uint16_t top, uint16_t right, uint16_t bottom);
  59. void (*invalidate)(void);
  60. void (*close)(void);
  61. void (*rotationInvalidateRect)(uint16_t left, uint16_t top, uint16_t right, uint16_t bottom, lcdAngle_t angle);
  62. void (*setBrushDirection)(lcdDirect_t direct_type);
  63. uint32_t (*readId)(void);
  64. } lcdOperations_t;
  65. typedef struct
  66. {
  67. uint32_t dev_id;
  68. uint32_t width;
  69. uint32_t height;
  70. HAL_GOUDA_SPI_LINE_T bus_mode;
  71. LCD_CTRL_MODULE_E controller;
  72. lcdOperations_t *operation;
  73. bool is_use_fmark;
  74. uint32_t fmark_delay;
  75. uint32_t freq;
  76. } lcdSpec_t;
  77. //=============================================================================
  78. // lcdDisplay_t
  79. //-----------------------------------------------------------------------------
  80. /// Region of interest in a LCD screen or a buffer.
  81. //=============================================================================
  82. typedef struct
  83. {
  84. /// x coordinate of the top left corner of the lcd.
  85. uint16_t x;
  86. /// y coordinate of the top left corner of the lcd.
  87. uint16_t y;
  88. /// width of the lcd dislay area.
  89. uint16_t width;
  90. /// height of the lcd display area.
  91. uint16_t height;
  92. } lcdDisplay_t;
  93. typedef struct
  94. {
  95. /// Width of the region.
  96. uint16_t width;
  97. /// Height of the region.
  98. uint16_t height;
  99. } lcdRoi_t;
  100. #ifdef CONFIG_QUEC_PROJECT_FEATURE_LCD
  101. typedef struct
  102. {
  103. uint16_t start_x_offset;
  104. uint16_t start_y_offset;
  105. int16_t width_offset;
  106. int16_t height_offset;
  107. } ql_lcd_offset_cfg_s;
  108. extern ql_lcd_offset_cfg_s ql_lcd_offset_cfg;
  109. typedef struct
  110. {
  111. uint16_t lcdrotation; //LCD rotation
  112. uint16_t widthoriginal; //width of display
  113. uint8_t lcdcolorformat; //LCD color format
  114. bool clean_screen; //clean_screen
  115. uint8_t bus_mode; // driver busmode
  116. uint32_t freq; // driver frequence
  117. } ql_lcd_config_s;
  118. extern ql_lcd_config_s ql_lcd_config;
  119. #endif
  120. //resolution of lcd data
  121. #define LCD_RESOLUTION_RGB565 2
  122. #define LCD_RESOLUTION_YUV422_UYVY 5
  123. #define LCD_RESOLUTION_YUV420 6
  124. #define LCD_RESOLUTION_YUV422_YUYV 9
  125. //inBufFormat
  126. #define YUYV 0
  127. #define YVYU 1
  128. #define UYVY 2
  129. //=============================================================================
  130. // lcdFrameBuffer_t
  131. //-----------------------------------------------------------------------------
  132. /// Frame buffer type: this type describes a frame buffer through its dimensions
  133. /// and a pointer to the data of the buffer. It is mandatory for the buffer to
  134. /// be able to hold the data describing all the pixels at the color format
  135. /// choosen.
  136. ///(ie sizeof(buffer) = width*height*NbOfBytesPerPixelAtTheFormat(format))
  137. // colorFormat : support LCD_RESOLUTION_RGB565 ,LCD_RESOLUTION_YUV422 LCD_RESOLUTION_YUV420
  138. //widthOrignal : the width of the original image buffer,it will just be used to caculate the stribe
  139. //width : the width will convert to. Normal is will equal with widthOrignal,unless zoom,rotation.
  140. //height : the height will convert to.
  141. //=============================================================================
  142. typedef struct
  143. {
  144. uint16_t *buffer;
  145. /// x coordinate of the layer. If only use one layer,normal set 0.
  146. uint16_t region_x;
  147. /// y coordinate of the layer. If only use one layer,normal set 0.
  148. uint16_t region_y;
  149. ///the width of after convert. if don't need rotation and zoom ,set to roginal width.
  150. uint16_t width;
  151. ///the height of after convert. if don't need rotation and zoom ,set to roginal height.
  152. uint16_t height;
  153. ///image buffer width.
  154. uint16_t widthOriginal;
  155. uint16_t colorFormat;
  156. ///0 no rotation. 1 rotate 90 degree.
  157. uint16_t rotation;
  158. /// enable the color mask function.
  159. bool keyMaskEnable;
  160. /// mask color value
  161. uint16_t maskColor;
  162. } lcdFrameBuffer_t;
  163. /**
  164. * @brief Init the LCD moudle.
  165. * @return
  166. * false failure
  167. * true success.
  168. */
  169. bool drvLcdInit(void);
  170. /**
  171. * @brief The function is used to close lcd when power off.
  172. */
  173. void drvLcdClose(void);
  174. /**
  175. * @brief This function provides the basic bit-block transfer capabilities.
  176. * copies the data (such as characters/bmp) on the LCD directly
  177. * as a (rectangular) block. The data is drawn in the active window.
  178. * The buffer has to be properly aligned
  179. * @param dataBufferWin set the buffer address , height, width .
  180. * @param lcdRec set the position of lcd region.
  181. * @return
  182. * - true on success else false
  183. */
  184. bool drvLcdBlockTransfer(const lcdFrameBuffer_t *dataBufferWin, const lcdDisplay_t *lcdRec);
  185. /**
  186. * @brief This function to config the belower layer/vedio layer.
  187. * @param dataBufferWin set the buffer address , height, width,etc .
  188. * @return
  189. * - true on success else false
  190. */
  191. bool drvLcdBlockSetOverLay(const lcdFrameBuffer_t *dataBufferWin);
  192. /**
  193. * @brief This function get the basic information of lcd.
  194. * @param lcd_info_ptr point to store lcd information
  195. */
  196. void drvLcdGetLcdInfo(lcdSpec_t *lcd_info_ptr);
  197. #ifdef CONFIG_QUEC_PROJECT_FEATURE_LCD
  198. void quec_drvLcdGetLcdInfo(lcdSpec_t **lcd_info_ptr);
  199. #endif
  200. /**
  201. * @brief Set the lcd display window.
  202. * @param left of the display window
  203. * @param top of the display window
  204. * @param right of the display window
  205. * @param bottom of the display window
  206. * @return
  207. * - true on success else false
  208. */
  209. bool drvLcdSetDisplayWindow(uint16_t left, uint16_t top, uint16_t right, uint16_t bottom);
  210. /**
  211. * @brief Enable/Disable the lcd module low power mode.
  212. * @param left of the display window
  213. * @param top of the display window
  214. * @param right of the display window
  215. * @param bottom of the display window
  216. * @return
  217. * - true on success else false
  218. */
  219. void drvLcdEnterSleep(bool is_sleep);
  220. /**
  221. * @brief Set video layer parameter
  222. * @width the orign pic buffer width, if rotation 90 degree, should set the height of origin pic .
  223. * @height the orign pic buffer height, if rotation 90 degree, should set the width of origin pic .
  224. * @return
  225. * - true on success else false
  226. */
  227. bool drvLcdSetImageLayerSize(uint32_t width, uint32_t height, uint32_t imageBufWidth);
  228. #ifdef CONFIG_QUEC_PROJECT_FEATURE_LCD
  229. void quec_lcd_clear_offset(uint8_t index);
  230. void quec_lcd_set_offset(uint8_t index);
  231. #endif
  232. /*
  233. src fmt ::
  234. #define LCD_RESOLUTION_RGB888 0
  235. #define LCD_RESOLUTION_RGB666 1
  236. #define LCD_RESOLUTION_RGB565 2
  237. #define LCD_RESOLUTION_RGB555 3
  238. #define LCD_RESOLUTION_GREY 4
  239. #define LCD_RESOLUTION_YUV422 5
  240. #define LCD_RESOLUTION_YUV420 6
  241. #define LCD_RESOLUTION_YUV400 7
  242. #define LCD_RESOLUTION_YUV420_3PLANE 8
  243. dst format :
  244. must be LCD_RESOLUTION_RGB565
  245. rotation :
  246. //0: 0; 1: 90; 2: 180; 3: 270;
  247. note: mocor player_display_v1.c
  248. */
  249. void drvLcdPictrueConverter(uint8_t src_fmt, uint32_t *src_addr, uint32_t src_w, uint32_t src_h, uint32_t stride,
  250. uint32_t *dst_addr, uint32_t dst_w, uint32_t dst_h, uint8_t rotation);
  251. /**---------------------------------------------------------------------------*
  252. ** Compiler Flag *
  253. **---------------------------------------------------------------------------*/
  254. int convert_yuyv_to_rgb(unsigned char *inBuf, unsigned char *outBuf, int imgWidth, int imgHeight, int inBufFormat);
  255. OSI_EXTERN_C_END
  256. #endif //_DAL_LCD_H