• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef HDF_DISP_H
10 #define HDF_DISP_H
11 
12 #include "hdf_base.h"
13 #include "hdf_device_desc.h"
14 #include "hdf_log.h"
15 #include "hdf_sbuf.h"
16 #include "hdf_workqueue.h"
17 #include "mipi_dsi_if.h"
18 #include "osal_mem.h"
19 #include "osal_mutex.h"
20 #include "osal_timer.h"
21 
22 #ifdef HDF_LOG_TAG
23 #undef HDF_LOG_TAG
24 #endif
25 #define HDF_LOG_TAG HDF_DISP
26 #define ESD_DEFAULT_INTERVAL   5000
27 #define ESD_MAX_RECOVERY       10
28 /* support max panel number */
29 #define PANEL_MAX 2
30 
31 enum LcdIntfType {
32     MIPI_DSI,
33     LCD_6BIT,
34     LCD_8BIT,
35     LCD_16BIT,
36     LCD_18BIT,
37     LCD_24BIT,
38 };
39 
40 enum BacklightType {
41     BLK_PWM,
42     BLK_MIPI,
43 };
44 
45 struct MipiDsiDesc {
46     enum DsiLane lane;
47     enum DsiMode mode;             /* output mode: DSI_VIDEO/DSI_CMD */
48     enum DsiBurstMode burstMode;
49     enum DsiOutFormat format;
50 };
51 
52 enum PowerStatus {
53     POWER_STATUS_ON,              /* The power status is on */
54     POWER_STATUS_STANDBY,         /* The power status is standby */
55     POWER_STATUS_SUSPEND,         /* The power status is suspend */
56     POWER_STATUS_OFF,             /* The power status is off */
57     POWER_STATUS_BUTT
58 };
59 
60 struct BlkDesc {
61     uint32_t type;
62     uint32_t minLevel;
63     uint32_t maxLevel;
64     uint32_t defLevel;
65 };
66 
67 struct PwmCfg {
68     uint32_t dev;
69     uint32_t period;
70 };
71 
72 struct PanelInfo {
73     uint32_t width;
74     uint32_t height;
75     uint32_t hbp;
76     uint32_t hfp;
77     uint32_t hsw;
78     uint32_t vbp;
79     uint32_t vfp;
80     uint32_t vsw;
81     uint32_t frameRate;
82     uint32_t clockFreq;
83     uint32_t pWidth;
84     uint32_t pHeight;
85     enum LcdIntfType intfType;
86     uint32_t intfSync;
87     struct MipiDsiDesc mipi;
88     struct BlkDesc blk;
89     struct PwmCfg pwm;
90 };
91 
92 struct PanelData;
93 struct PanelEsd {
94     bool support;
95     uint32_t interval;
96     uint32_t state;
97     uint32_t recoveryNum;
98     uint32_t cmpMode;
99     int32_t (*checkFunc)(struct PanelData *panel);
100     void *expect_data;
101 };
102 
103 struct PanelData {
104     struct HdfDeviceObject *object;
105     int32_t (*init)(struct PanelData *panel);
106     int32_t (*on)(struct PanelData *panel);
107     int32_t (*off)(struct PanelData *panel);
108     struct PanelInfo *info;
109     enum PowerStatus powerStatus;
110     struct PanelEsd *esd;
111     struct BacklightDev *blDev;
112     void *priv;
113 };
114 
115 struct PanelManager {
116     struct PanelData *panel[PANEL_MAX];
117     uint32_t panelNum;
118 };
119 
120 typedef int32_t (*DispCmdHandle)(struct HdfDeviceObject *device, struct HdfSBuf *reqData, struct HdfSBuf *rspData);
121 
122 struct DispInfo {
123     uint32_t width;
124     uint32_t hbp;
125     uint32_t hfp;
126     uint32_t hsw;
127     uint32_t height;
128     uint32_t vbp;
129     uint32_t vfp;
130     uint32_t vsw;
131     uint32_t frameRate;
132     uint32_t intfType;
133     uint32_t intfSync;
134     uint32_t minLevel;
135     uint32_t maxLevel;
136     uint32_t defLevel;
137 };
138 
139 struct DispOperations {
140     int32_t (*init)(uint32_t devId);
141     int32_t (*on)(uint32_t devId);
142     int32_t (*off)(uint32_t devId);
143     int32_t (*setBacklight)(uint32_t devId, uint32_t level);
144     int32_t (*getDispInfo)(uint32_t devId, struct DispInfo *info);
145 };
146 
147 enum EsdState {
148     ESD_READY = 1,
149     ESD_RUNNING,
150 };
151 
152 struct DispEsd {
153     struct PanelEsd **panelEsd;
154     HdfWork **work;
155     bool *workInit;
156     OsalTimer **timer;
157     uint32_t panelNum;
158 };
159 
160 struct DispManager {
161     struct PanelManager *panelManager;
162     struct OsalMutex dispMutex;
163     HdfWorkQueue dispWorkQueue;
164     bool initialzed;
165     struct DispEsd *esd;
166 };
167 
168 int32_t RegisterPanel(struct PanelData *data);
169 struct PanelManager *GetPanelManager(void);
170 struct DispManager *GetDispManager(void);
171 
172 #endif /* HDF_DISP_H */
173