lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2016, ZIXC Corporation. |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | #ifndef _LCD_H_ |
| 7 | #define _LCD_H_ |
| 8 | |
| 9 | #include <common.h> |
| 10 | |
| 11 | //#include "types.h" |
| 12 | /* return code */ |
| 13 | #define DRV_SUCCESS 0 /* successed */ |
| 14 | #define DRV_ERROR -1 /* failed */ |
| 15 | #define DRV_ERR_NOT_OPENED -9 /* the device to operate hasn't been opened yet */ |
| 16 | #define DRV_ERR_OPEN_TIMES -10 /* try to open a device which has been opened already */ |
| 17 | |
| 18 | typedef unsigned int UINT32; |
| 19 | |
| 20 | typedef enum |
| 21 | { |
| 22 | LCD_DCX_CMD = 0, // µÍµçƽÃüÁî |
| 23 | LCD_DCX_DATA, // ¸ßµçƽ²ÎÊý»òÊý¾Ý |
| 24 | |
| 25 | MAX_LCD_DCX_TYPE |
| 26 | } T_ZDrvLcd_DcxType; // transmission byte type |
| 27 | |
| 28 | typedef enum |
| 29 | { |
| 30 | LCD_XFER_POLL = 0, // ÂÖѯ·½Ê½ |
| 31 | LCD_XFER_INT, // ÖжϷ½Ê½ |
| 32 | LCD_XFER_DMA, // DMA·½Ê½ |
| 33 | LCD_XFER_CPU, |
| 34 | |
| 35 | MAX_LCD_XFER_TYPE |
| 36 | } T_ZDrvLcd_XferType; |
| 37 | |
| 38 | typedef enum zx297520_lcd_vendor |
| 39 | { |
| 40 | VENDOR_YS = 0, |
| 41 | VENDOR_LD = 1, |
| 42 | VENDOR_TM = 2, |
| 43 | VENDOR_NUM = 3, |
| 44 | }; |
| 45 | |
| 46 | /* lcd mode */ |
| 47 | typedef enum |
| 48 | { |
| 49 | LCD_NORMAL, /* normal mode */ |
| 50 | LCD_SLEEP, /* sleep mode */ |
| 51 | |
| 52 | MAX_LCD_MODE |
| 53 | } T_ZDrvLcd_Mode; |
| 54 | |
| 55 | /* lcd instance */ |
| 56 | typedef struct |
| 57 | { |
| 58 | bool bOpen; /* status: open, close */ |
| 59 | T_ZDrvLcd_Mode eMode; /* working mode: normal, sleep */ |
| 60 | T_ZDrvLcd_XferType eXferType; /* poll, interrupt or DMA */ |
| 61 | T_ZDrvLcd_DcxType eDcxType; /* command or parameter/data */ |
| 62 | } T_ZDrvLcd_Instance; |
| 63 | |
| 64 | |
| 65 | typedef enum |
| 66 | { |
| 67 | LCD_BACKLIGHT_OFF = 0, |
| 68 | LCD_BACKLIGHT_ON, |
| 69 | |
| 70 | } T_ZDrvLcd_BacklightStatus; |
| 71 | |
| 72 | typedef unsigned int T_ZDrvLcd_Brightness; /* [0, 255]: 0 - darkest; 255 - brightest */ |
| 73 | |
| 74 | /* lcd module list */ |
| 75 | typedef enum |
| 76 | { |
| 77 | ZGD_ST7735_128x160=0, |
| 78 | ZGD_GC910x_128x160, |
| 79 | ZGD_GC930x_240x320, |
| 80 | ZGD_GC9306_240x320, |
| 81 | ST7789V_240x320, |
| 82 | ST7567_128x64, |
| 83 | LEAD_ST7735_128x128, |
| 84 | LEAD_ST7735_128x128_F231E, |
| 85 | S93521A_128x128, |
| 86 | BOE7735S_128x128, |
| 87 | ST7789V_240x240, |
| 88 | ILI9342C_320x240, |
| 89 | |
| 90 | MAX_LCD_ITEM |
| 91 | } T_ZDrvLcd_Module_List; |
| 92 | |
| 93 | |
| 94 | struct T_ZDrvLcd_Lcm_Id |
| 95 | { |
| 96 | unsigned short dev_id; |
| 97 | unsigned char man_id; |
| 98 | T_ZDrvLcd_Module_List lcd_item; |
| 99 | char *name; |
| 100 | }; |
| 101 | |
| 102 | struct T_ZDrvLcd_gpio_define |
| 103 | { |
| 104 | UINT32 spi_cs_gpio; |
| 105 | UINT32 spi_scl_gpio; |
| 106 | UINT32 spi_sda_gpio; |
| 107 | UINT32 spi_dcx_gpio; |
| 108 | |
| 109 | UINT32 spi_cs_func_sel; |
| 110 | UINT32 spi_scl_func_sel; |
| 111 | UINT32 spi_sda_func_sel; |
| 112 | UINT32 spi_dcx_func_sel; |
| 113 | |
| 114 | UINT32 spi_cs_gpio_sel; |
| 115 | UINT32 spi_scl_gpio_sel; |
| 116 | UINT32 spi_sda_gpio_sel; |
| 117 | UINT32 spi_dcx_gpio_sel; |
| 118 | UINT32 lcd_reset_gpio; |
| 119 | UINT32 lcd_reset_gpio_sel; |
| 120 | |
| 121 | UINT32 lcd_blg_gpio; |
| 122 | UINT32 lcd_blg_gpio_sel; |
| 123 | }; |
| 124 | |
| 125 | typedef struct |
| 126 | { |
| 127 | unsigned short width; |
| 128 | unsigned short height; |
| 129 | unsigned short bitsPerPixel; |
| 130 | unsigned short rMask; |
| 131 | unsigned short gMask; |
| 132 | unsigned short bMask; |
| 133 | T_ZDrvLcd_Instance instance; |
| 134 | T_ZDrvLcd_BacklightStatus backlight; |
| 135 | T_ZDrvLcd_Brightness brightness; |
| 136 | struct T_ZDrvLcd_Lcm_Id lcm_info; |
| 137 | struct T_ZDrvLcd_gpio_define gpio_def; |
| 138 | } T_ZDrvLcd_Info; |
| 139 | |
| 140 | struct lcd_opt{ |
| 141 | int (*get_info)(T_ZDrvLcd_Info* lcd_info); |
| 142 | int (*lcm_init)(void); |
| 143 | int (*update_rect)(unsigned char *pBuf, unsigned short uiLeft, unsigned short uiTop, unsigned short uiWidth, unsigned short uiHeight); |
| 144 | }; |
| 145 | |
| 146 | int zDrvLcd_BootPicFromRes(void); |
| 147 | int zDrvLcd_PowerOnLogo(void); |
| 148 | int zDrvLcd_ShowCharging(void); |
| 149 | int zDrvLcd_ShowUpdateWait(void); |
| 150 | int zDrvLcd_ShowUpdateSucc(void); |
| 151 | int zDrvLcd_ShowUpdateFail(void); |
| 152 | int zDrvLcd_ShowLowBattery(void); |
| 153 | int zDrvLcd_ShowNoBattery(void); |
| 154 | int zDrvLcd_TurnBacklightOnOff(unsigned int enable); |
| 155 | |
| 156 | int zDrvLcd_Initiate(void); |
| 157 | int lcd_init(void); |
| 158 | |
| 159 | #endif |
| 160 | |