1 // Copyright (C) 2022 Beken Corporation 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 #include <driver/media_types.h> 22 23 #define USE_LCD_REGISTER_CALLBACKS 1 24 typedef void (*lcd_isr_t)(void); 25 26 typedef enum { 27 LCD_DEVICE_UNKNOW, 28 LCD_DEVICE_ST7282, /**< 480X270 RGB */ 29 LCD_DEVICE_HX8282, /**< 1024X600 RGB */ 30 LCD_DEVICE_GC9503V, /**< 480X800 RGB */ 31 LCD_DEVICE_ST7796S, /**< 320X480 MCU */ 32 } lcd_device_id_t; 33 34 typedef enum { 35 LCD_TYPE_RGB565, /**< lcd devicd output data hardware interface is RGB565 format */ 36 LCD_TYPE_MCU8080, /**< lcd devicd output data hardware interface is MCU 8BIT format */ 37 } lcd_type_t; 38 39 typedef enum { 40 RGB_OUTPUT_EOF =1 << 5 , /**< reg end of frame int,*/ 41 RGB_OUTPUT_SOF =1 << 4, /**< reg display output start of frame */ 42 I8080_OUTPUT_SOF =1 << 6, /**< 8080 display output start of frame */ 43 I8080_OUTPUT_EOF = 1 << 7, /**< 8080 display output end of frame */ 44 }lcd_int_type_t; 45 46 /** rgb lcd clk select, infulence pfs, user should select according to lcd device spec*/ 47 typedef enum { 48 LCD_320M = 0, /**< diaplay module clk config 320MHz*/ 49 LCD_160M, 50 LCD_120M, 51 LCD_80M, 52 LCD_60M, 53 LCD_54M, //5 54 LCD_40M, 55 LCD_32M, 56 LCD_26M, 57 LCD_20M, 58 LCD_12M,//10 59 LCD_10M, 60 LCD_8M //12 61 }lcd_clk_t; 62 63 /** rgb data output in clk rising or falling */ 64 typedef enum { 65 POSEDGE_OUTPUT = 0, /**< output in clk falling*/ 66 NEGEDGE_OUTPUT, /**< output in clk rising*/ 67 }rgb_out_clk_edge_t; 68 69 70 /** rgb lcd input data format, data save in mem is little endian, like VUYY format is [bit31-bit0] is [V U Y Y]*/ 71 typedef enum { 72 LCD_FMT_RGB565 = 0, /**< input data format is rgb565*/ 73 LCD_FMT_ORGINAL_YUYV, /**< input data is yuyv format, diaplay module internal may convert to rgb565 data*/ 74 LCD_FMT_UYVY, 75 LCD_FMT_YYUV, /**< input data is yyuv format */ 76 LCD_FMT_UVYY, /**< input data is uvyy format*/ 77 LCD_FMT_VUYY, /**< input data is vuyy format */ 78 LCD_FMT_YVYU, 79 LCD_FMT_VYUY, 80 LCD_FMT_YYVU 81 }lcd_data_format_t; 82 83 84 typedef struct { 85 uint16_t x; 86 uint16_t y; 87 uint16_t width; 88 uint16_t height; 89 }lcd_rect_t; 90 91 typedef struct 92 { 93 void *buffer; 94 lcd_rect_t rect; 95 } lcd_disp_framebuf_t; 96 97 98 /** rgb config param */ 99 typedef struct 100 { 101 lcd_clk_t clk; /**< config lcd clk */ 102 rgb_out_clk_edge_t data_out_clk_edge; /**< rgb data output in clk edge, should refer lcd device spec*/ 103 104 uint16_t hsync_back_porch; /**< rgb hsync back porch, should refer lcd device spec*/ 105 uint16_t hsync_front_porch; /**< rgb hsync front porch, should refer lcd device spec*/ 106 uint16_t vsync_back_porch; /**< rgb vsyn back porch, should refer lcd device spec*/ 107 uint16_t vsync_front_porch; /**< rgb vsyn front porch, should refer lcd device spec*/ 108 } lcd_rgb_t; 109 110 typedef struct 111 { 112 lcd_clk_t clk; /**< config lcd clk */ 113 void (*set_display_area)(uint16 xs, uint16 xe, uint16 ys, uint16 ye); /**< if lcd size is smaller then image, 114 and set api bk_lcd_pixel_config is image x y, should set partical display */ 115 } lcd_mcu_t; 116 117 118 119 typedef struct 120 { 121 lcd_device_id_t id; /**< lcd device type, user can add if you want to add another lcd device */ 122 char *name; /**< lcd device name */ 123 lcd_type_t type; /**< lcd device hw interface */ 124 media_ppi_t ppi; /**< lcd device x y size */ 125 union { 126 const lcd_rgb_t *rgb; /**< RGB interface lcd device config */ 127 const lcd_mcu_t *mcu; /**< MCU interface lcd device config */ 128 }; 129 void (*init)(void); /**< lcd device initial function */ 130 } lcd_device_t; 131 132 133 typedef struct 134 { 135 const lcd_device_t *device; /**< lcd device config */ 136 lcd_data_format_t fmt; /**< display module input data format */ 137 uint16_t pixel_x; /**< lcd display src picture size */ 138 uint16_t pixel_y; /**< lcd display src picture size */ 139 #if (USE_LCD_REGISTER_CALLBACKS == 1) 140 void (*complete_callback)(void); /**< lcd display a frame complete callbace */ 141 #endif 142 } lcd_config_t; 143 144 145 146 /* 147 * @} 148 */ 149 150 #ifdef __cplusplus 151 } 152 #endif 153 154 155