1 /* 2 * Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved. 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 16 #ifndef LCD_ABS_IF_H 17 #define LCD_ABS_IF_H 18 19 #include "disp_common.h" 20 #include "mipi_dsi_if.h" 21 22 /* support max panel number */ 23 #define PANEL_MAX 1 24 25 enum LcdIntfType { 26 MIPI_DSI, 27 LCD_6BIT, 28 LCD_8BIT, 29 LCD_16BIT, 30 LCD_18BIT, 31 LCD_24BIT, 32 }; 33 34 enum BacklightType { 35 BLK_PWM, 36 BLK_MIPI, 37 }; 38 39 struct MipiDsiDesc { 40 enum DsiLane lane; 41 enum DsiMode mode; /* output mode: DSI_VIDEO/DSI_CMD */ 42 enum DsiBurstMode burstMode; 43 enum DsiOutFormat format; 44 }; 45 46 enum PowerStatus { 47 POWER_STATUS_ON, /* The power status is on */ 48 POWER_STATUS_STANDBY, /* The power status is standby */ 49 POWER_STATUS_SUSPEND, /* The power status is suspend */ 50 POWER_STATUS_OFF, /* The power status is off */ 51 POWER_STATUS_BUTT 52 }; 53 54 struct BlkDesc { 55 uint32_t type; 56 uint32_t minLevel; 57 uint32_t maxLevel; 58 uint32_t defLevel; 59 }; 60 61 struct PwmCfg { 62 uint32_t dev; 63 uint32_t period; 64 }; 65 66 struct PanelInfo { 67 uint32_t width; 68 uint32_t height; 69 uint32_t hbp; 70 uint32_t hfp; 71 uint32_t hsw; 72 uint32_t vbp; 73 uint32_t vfp; 74 uint32_t vsw; 75 uint32_t frameRate; 76 enum LcdIntfType intfType; 77 enum IntfSync intfSync; 78 struct MipiDsiDesc mipi; 79 struct BlkDesc blk; 80 struct PwmCfg pwm; 81 }; 82 83 struct PanelStatus { 84 enum PowerStatus powerStatus; 85 uint32_t currLevel; 86 }; 87 88 struct PanelData; 89 struct PanelEsd { 90 bool support; 91 uint32_t interval; 92 uint32_t state; 93 uint32_t recoveryNum; 94 uint32_t cmpMode; 95 int32_t (*checkFunc)(struct PanelData *panel); 96 void *expect_data; 97 }; 98 99 struct PanelData { 100 struct HdfDeviceObject *object; 101 int32_t (*init)(struct PanelData *panel); 102 int32_t (*on)(struct PanelData *panel); 103 int32_t (*off)(struct PanelData *panel); 104 int32_t (*setBacklight)(struct PanelData *panel, uint32_t level); 105 struct PanelInfo *info; 106 struct PanelStatus status; 107 struct PanelEsd *esd; 108 }; 109 110 struct PanelManager { 111 struct PanelData *panel[PANEL_MAX]; 112 uint32_t panelNum; 113 }; 114 115 int32_t RegisterPanel(struct PanelData *data); 116 struct PanelManager *GetPanelManager(void); 117 struct PanelData *GetPanel(int32_t index); 118 119 int32_t GetBitsPerPixel(enum DsiOutFormat format); 120 uint32_t CalcPixelClk(struct PanelInfo *info); 121 uint32_t CalcDataRate(struct PanelInfo *info); 122 123 #endif /* LCD_ABS_IF_H */ 124