• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 #include "gpio_if.h"
20 #include "hdf_bl.h"
21 #include "hdf_disp.h"
22 #include "hdf_log.h"
23 #include "mipi_dsi_if.h"
24 #include "osal.h"
25 #include "pwm_if.h"
26 
27 #define RESET_GPIO                5
28 #define MIPI_DSI0                 0
29 #define BLK_PWM1                  1
30 #define PWM_MAX_PERIOD            100000
31 /* backlight setting */
32 #define MIN_LEVEL                 0
33 #define MAX_LEVEL                 255
34 #define DEFAULT_LEVEL             100
35 
36 #define WIDTH                     480
37 #define HEIGHT                    960
38 #define HORIZONTAL_BACK_PORCH     20
39 #define HORIZONTAL_FRONT_PORCH    20
40 #define HORIZONTAL_SYNC_WIDTH     10
41 #define VERTICAL_BACK_PORCH       14
42 #define VERTICAL_FRONT_PORCH      16
43 #define VERTICAL_SYNC_WIDTH       2
44 #define FRAME_RATE                60
45 
46 #define WIDTH1                    480
47 #define HEIGHT1                   960
48 #define HORIZONTAL_BACK_PORCH1    44
49 #define HORIZONTAL_FRONT_PORCH1   46
50 #define HORIZONTAL_SYNC_WIDTH1    4
51 #define VERTICAL_BACK_PORCH1      15
52 #define VERTICAL_FRONT_PORCH1     15
53 #define VERTICAL_SYNC_WIDTH1      2
54 #define FRAME_RATE1               60
55 
56 /* panel0 on command payload */
57 static uint8_t g_payLoad0[] = { 0xF0, 0x5A, 0x5A };
58 static uint8_t g_payLoad1[] = { 0xF1, 0xA5, 0xA5 };
59 static uint8_t g_payLoad2[] = { 0xB3, 0x03, 0x03, 0x03, 0x07, 0x05, 0x0D, 0x0F, 0x11, 0x13, 0x09, 0x0B };
60 static uint8_t g_payLoad3[] = { 0xB4, 0x03, 0x03, 0x03, 0x06, 0x04, 0x0C, 0x0E, 0x10, 0x12, 0x08, 0x0A };
61 static uint8_t g_payLoad4[] = { 0xB0, 0x54, 0x32, 0x23, 0x45, 0x44, 0x44, 0x44, 0x44, 0x60, 0x00, 0x60, 0x1C };
62 static uint8_t g_payLoad5[] = { 0xB1, 0x32, 0x84, 0x02, 0x87, 0x12, 0x00, 0x50, 0x1C };
63 static uint8_t g_payLoad6[] = { 0xB2, 0x73, 0x09, 0x08 };
64 static uint8_t g_payLoad7[] = { 0xB6, 0x5C, 0x5C, 0x05 };
65 static uint8_t g_payLoad8[] = { 0xB8, 0x23, 0x41, 0x32, 0x30, 0x03 };
66 static uint8_t g_payLoad9[] = { 0xBC, 0xD2, 0x0E, 0x63, 0x63, 0x5A, 0x32, 0x22, 0x14, 0x22, 0x03 };
67 static uint8_t g_payLoad10[] = { 0xb7, 0x41 };
68 static uint8_t g_payLoad11[] = { 0xC1, 0x0c, 0x10, 0x04, 0x0c, 0x10, 0x04 };
69 static uint8_t g_payLoad12[] = { 0xC2, 0x10, 0xE0 };
70 static uint8_t g_payLoad13[] = { 0xC3, 0x22, 0x11 };
71 static uint8_t g_payLoad14[] = { 0xD0, 0x07, 0xFF };
72 static uint8_t g_payLoad15[] = { 0xD2, 0x63, 0x0B, 0x08, 0x88 };
73 static uint8_t g_payLoad16[] = { 0xC6, 0x08, 0x15, 0xFF, 0x10, 0x16, 0x80, 0x60 };
74 static uint8_t g_payLoad17[] = { 0xc7, 0x04 };
75 static uint8_t g_payLoad18[] = {
76     0xC8, 0x7C, 0x50, 0x3B, 0x2C, 0x25, 0x16, 0x1C, 0x08, 0x27, 0x2B, 0x2F, 0x52, 0x43, 0x4C, 0x40,
77     0x3D, 0x30, 0x1E, 0x06, 0x7C, 0x50, 0x3B, 0x2C, 0x25, 0x16, 0x1C, 0x08, 0x27, 0x2B, 0x2F, 0x52,
78     0x43, 0x4C, 0x40, 0x3D, 0x30, 0x1E, 0x06
79 };
80 static uint8_t g_payLoad19[] = { 0x11 };
81 static uint8_t g_payLoad20[] = { 0x29 };
82 
83 struct DsiCmdDesc g_OnCmd0[] = {
84     { 0x29, 0, sizeof(g_payLoad0), g_payLoad0 },
85     { 0x29, 0, sizeof(g_payLoad1), g_payLoad1 },
86     { 0x29, 0, sizeof(g_payLoad2), g_payLoad2 },
87     { 0x29, 0, sizeof(g_payLoad3), g_payLoad3 },
88     { 0x29, 0, sizeof(g_payLoad4), g_payLoad4 },
89     { 0x29, 0, sizeof(g_payLoad5), g_payLoad5 },
90     { 0x29, 0, sizeof(g_payLoad6), g_payLoad6 },
91     { 0x29, 0, sizeof(g_payLoad7), g_payLoad7 },
92     { 0x29, 0, sizeof(g_payLoad8), g_payLoad8 },
93     { 0x29, 0, sizeof(g_payLoad9), g_payLoad9 },
94     { 0x23, 0, sizeof(g_payLoad10), g_payLoad10 },
95     { 0x29, 0, sizeof(g_payLoad11), g_payLoad11 },
96     { 0x29, 0, sizeof(g_payLoad12), g_payLoad12 },
97     { 0x29, 0, sizeof(g_payLoad13), g_payLoad13 },
98     { 0x29, 0, sizeof(g_payLoad14), g_payLoad14 },
99     { 0x29, 0, sizeof(g_payLoad15), g_payLoad15 },
100     { 0x29, 0, sizeof(g_payLoad16), g_payLoad16 },
101     { 0x23, 0, sizeof(g_payLoad17), g_payLoad17 },
102     { 0x29, 1, sizeof(g_payLoad18), g_payLoad18 },
103     { 0x05, 120, sizeof(g_payLoad19), g_payLoad19 },
104     { 0x05, 120, sizeof(g_payLoad20), g_payLoad20 },
105 };
106 
107 /* panel1 on command payload */
108 static uint8_t g_payLoad1_0[] = { 0xFF, 0x77, 0x01, 0x00, 0x00, 0x13 };
109 static uint8_t g_payLoad1_1[] = { 0xEF, 0x08 };
110 static uint8_t g_payLoad1_2[] = { 0xFF, 0x77, 0x01, 0x00, 0x00, 0x10 };
111 static uint8_t g_payLoad1_3[] = { 0xC0, 0xF7, 0x02 };
112 static uint8_t g_payLoad1_4[] = { 0xC1, 0x0C, 0x02 };
113 static uint8_t g_payLoad1_5[] = { 0xC2, 0x07, 0x02 };
114 static uint8_t g_payLoad1_6[] = { 0xC6, 0x21 };
115 static uint8_t g_payLoad1_7[] = { 0xCC, 0x30 };
116 static uint8_t g_payLoad1_8[] = {
117     0xB0, 0x00, 0x0B, 0x12, 0x0D, 0x11, 0x07, 0x04, 0x08, 0x07, 0x20, 0x05, 0x12, 0x0F, 0x28, 0x30, 0x1B
118 };
119 static uint8_t g_payLoad1_9[] = {
120     0xB1, 0x00, 0x0B, 0x12, 0x0D, 0x11, 0x05, 0x03, 0x08, 0x08, 0x20, 0x03, 0x10, 0x10, 0x29, 0x30, 0x1B
121 };
122 static uint8_t g_payLoad1_10[] = { 0xFF, 0x77, 0x01, 0x00, 0x00, 0x11 };
123 static uint8_t g_payLoad1_11[] = { 0xB0, 0x4D };
124 static uint8_t g_payLoad1_12[] = { 0xB1, 0x2A };
125 static uint8_t g_payLoad1_13[] = { 0xB2, 0x87 };
126 static uint8_t g_payLoad1_14[] = { 0xB3, 0x80 };
127 static uint8_t g_payLoad1_15[] = { 0xB5, 0x49 };
128 static uint8_t g_payLoad1_16[] = { 0xB7, 0x87 };
129 static uint8_t g_payLoad1_17[] = { 0xB8, 0x21 };
130 static uint8_t g_payLoad1_18[] = { 0xB9, 0x10 };
131 static uint8_t g_payLoad1_19[] = { 0xBB, 0x00 };
132 static uint8_t g_payLoad1_20[] = { 0xC0, 0x09 };
133 static uint8_t g_payLoad1_21[] = { 0xC1, 0x78 };
134 static uint8_t g_payLoad1_22[] = { 0xC2, 0x78 };
135 static uint8_t g_payLoad1_23[] = { 0xD0, 0x88 };
136 static uint8_t g_payLoad1_24[] = { 0xFF, 0x77, 0x01, 0x00, 0x00, 0x11 };
137 static uint8_t g_payLoad1_25[] = { 0xE0, 0x00, 0x19, 0x00 };
138 static uint8_t g_payLoad1_26[] = { 0xE1, 0x07, 0x82, 0x00, 0x82, 0x06, 0x82, 0x00, 0x82, 0x00, 0x40, 0x40 };
139 static uint8_t g_payLoad1_27[] = {
140     0xE2, 0x30, 0x30, 0x40, 0x40, 0xCC, 0x82, 0x00, 0x82, 0xCB, 0x82, 0x00, 0x82, 0x00
141 };
142 static uint8_t g_payLoad1_28[] = { 0xE3, 0x00, 0x00, 0x33, 0x33 };
143 static uint8_t g_payLoad1_29[] = { 0xE4, 0x44, 0x44 };
144 static uint8_t g_payLoad1_30[] = {
145     0xE5, 0x09, 0xC5, 0xAA, 0x82, 0x0B, 0xC7, 0xAA, 0x82, 0x0D, 0xC9, 0xAA, 0x82, 0x0F, 0xCB, 0xAA, 0x82
146 };
147 static uint8_t g_payLoad1_31[] = { 0xE6, 0x00, 0x00, 0x33, 0x33 };
148 static uint8_t g_payLoad1_32[] = { 0xE7, 0x44, 0x44 };
149 static uint8_t g_payLoad1_33[] = {
150     0xE8, 0x08, 0xC4, 0xAA, 0x82, 0x0A, 0xC6, 0xAA, 0x82, 0x0C, 0xC8, 0xAA, 0x82, 0x0E, 0xCA, 0xAA, 0x82
151 };
152 static uint8_t g_payLoad1_34[] = { 0xEB, 0x00, 0x00, 0xE4, 0xE4, 0x88, 0x00, 0x10 };
153 static uint8_t g_payLoad1_35[] = { 0xEC, 0x3D, 0x00 };
154 static uint8_t g_payLoad1_36[] = {
155     0xED, 0xAB, 0x98, 0x76, 0x54, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x45, 0x67, 0x89, 0xBA
156 };
157 static uint8_t g_payLoad1_37[] = { 0xEF, 0x08, 0x08, 0x08, 0x45, 0x3F, 0x54 };
158 static uint8_t g_payLoad1_38[] = { 0xFF, 0x77, 0x01, 0x00, 0x00, 0x00 };
159 static uint8_t g_payLoad1_42[] = { 0x11 };
160 static uint8_t g_payLoad1_43[] = { 0x29 };
161 
162 struct DsiCmdDesc g_OnCmd1[] = {
163     { 0x29, 0, sizeof(g_payLoad1_0), g_payLoad1_0 },
164     { 0x23, 0, sizeof(g_payLoad1_1), g_payLoad1_1 },
165     { 0x29, 0, sizeof(g_payLoad1_2), g_payLoad1_2 },
166     { 0x29, 0, sizeof(g_payLoad1_3), g_payLoad1_3 },
167     { 0x29, 0, sizeof(g_payLoad1_4), g_payLoad1_4 },
168     { 0x29, 0, sizeof(g_payLoad1_5), g_payLoad1_5 },
169     { 0x23, 0, sizeof(g_payLoad1_6), g_payLoad1_6 },
170     { 0x23, 0, sizeof(g_payLoad1_7), g_payLoad1_7 },
171     { 0x29, 0, sizeof(g_payLoad1_8), g_payLoad1_8 },
172     { 0x29, 0, sizeof(g_payLoad1_9), g_payLoad1_9 },
173     { 0x29, 0, sizeof(g_payLoad1_10), g_payLoad1_10 },
174     { 0x23, 0, sizeof(g_payLoad1_11), g_payLoad1_11 },
175     { 0x23, 0, sizeof(g_payLoad1_12), g_payLoad1_12 },
176     { 0x23, 0, sizeof(g_payLoad1_13), g_payLoad1_13 },
177     { 0x23, 0, sizeof(g_payLoad1_14), g_payLoad1_14 },
178     { 0x23, 0, sizeof(g_payLoad1_15), g_payLoad1_15 },
179     { 0x23, 0, sizeof(g_payLoad1_16), g_payLoad1_16 },
180     { 0x23, 0, sizeof(g_payLoad1_17), g_payLoad1_17 },
181     { 0x23, 0, sizeof(g_payLoad1_18), g_payLoad1_18 },
182     { 0x23, 0, sizeof(g_payLoad1_19), g_payLoad1_19 },
183     { 0x23, 0, sizeof(g_payLoad1_20), g_payLoad1_20 },
184     { 0x23, 0, sizeof(g_payLoad1_21), g_payLoad1_21 },
185     { 0x23, 0, sizeof(g_payLoad1_22), g_payLoad1_22 },
186     { 0x23, 0, sizeof(g_payLoad1_23), g_payLoad1_23 },
187     { 0x29, 0, sizeof(g_payLoad1_24), g_payLoad1_24 },
188     { 0x29, 0, sizeof(g_payLoad1_25), g_payLoad1_25 },
189     { 0x29, 0, sizeof(g_payLoad1_26), g_payLoad1_26 },
190     { 0x29, 0, sizeof(g_payLoad1_27), g_payLoad1_27 },
191     { 0x29, 0, sizeof(g_payLoad1_28), g_payLoad1_28 },
192     { 0x29, 0, sizeof(g_payLoad1_29), g_payLoad1_29 },
193     { 0x29, 0, sizeof(g_payLoad1_30), g_payLoad1_30 },
194     { 0x29, 0, sizeof(g_payLoad1_31), g_payLoad1_31 },
195     { 0x29, 0, sizeof(g_payLoad1_32), g_payLoad1_32 },
196     { 0x29, 0, sizeof(g_payLoad1_33), g_payLoad1_33 },
197     { 0x29, 0, sizeof(g_payLoad1_34), g_payLoad1_34 },
198     { 0x29, 0, sizeof(g_payLoad1_35), g_payLoad1_35 },
199     { 0x29, 0, sizeof(g_payLoad1_36), g_payLoad1_36 },
200     { 0x29, 0, sizeof(g_payLoad1_37), g_payLoad1_37 },
201     { 0x29, 0, sizeof(g_payLoad1_38), g_payLoad1_38 },
202     { 0x05, 120, sizeof(g_payLoad1_42), g_payLoad1_42 },
203     { 0x05, 50, sizeof(g_payLoad1_43), g_payLoad1_43 },
204 };
205 
206 /* panel off command payload */
207 static uint8_t g_offPayLoad0[] = { 0x28 };
208 static uint8_t g_offPayLoad1[] = { 0x10 };
209 struct DsiCmdDesc g_offCmd[] = {
210     { 0x05, 20, sizeof(g_offPayLoad0), g_offPayLoad0 },
211     { 0x05, 120, sizeof(g_offPayLoad1), g_offPayLoad1 },
212 };
213 
214 static uint8_t g_panelSolution = 0;  // 0-icn9700[default], 1-ST7701SN
215 
216 struct Icn9700Dev {
217     struct PanelData panel;
218     DevHandle mipiHandle;
219     uint16_t reset_gpio;
220     uint16_t reset_delay;
221 };
222 
LcdResetOn(struct Icn9700Dev * icn9700)223 static int32_t LcdResetOn(struct Icn9700Dev *icn9700)
224 {
225     int32_t ret;
226 
227     ret = GpioSetDir(icn9700->reset_gpio, GPIO_DIR_OUT);
228     if (ret != HDF_SUCCESS) {
229         HDF_LOGE("GpioSetDir failed, ret:%d", ret);
230         return HDF_FAILURE;
231     }
232     ret = GpioWrite(icn9700->reset_gpio, GPIO_VAL_HIGH);
233     if (ret != HDF_SUCCESS) {
234         HDF_LOGE("GpioWrite failed, ret:%d", ret);
235         return HDF_FAILURE;
236     }
237     /* delay 20ms */
238     OsalMSleep(icn9700->reset_delay);
239     return HDF_SUCCESS;
240 }
241 
LcdResetOff(struct Icn9700Dev * icn9700)242 static int32_t LcdResetOff(struct Icn9700Dev *icn9700)
243 {
244     int32_t ret;
245 
246     ret = GpioSetDir(icn9700->reset_gpio, GPIO_DIR_OUT);
247     if (ret != HDF_SUCCESS) {
248         HDF_LOGE("GpioSetDir failed, ret:%d", ret);
249         return HDF_FAILURE;
250     }
251     ret = GpioWrite(icn9700->reset_gpio, GPIO_VAL_LOW);
252     if (ret != HDF_SUCCESS) {
253         HDF_LOGE("GpioWrite failed, ret:%d", ret);
254         return HDF_FAILURE;
255     }
256     /* delay 20ms */
257     OsalMSleep(icn9700->reset_delay);
258     return HDF_SUCCESS;
259 }
260 
PanelToIcn9700Dev(const struct PanelData * panel)261 static struct Icn9700Dev *PanelToIcn9700Dev(const struct PanelData *panel)
262 {
263     struct Icn9700Dev *icn9700 = NULL;
264 
265     if (panel == NULL) {
266         HDF_LOGE("%s: panel is null", __func__);
267         return NULL;
268     }
269     if (panel->object == NULL) {
270         HDF_LOGE("%s: object is null", __func__);
271         return NULL;
272     }
273     icn9700 = (struct Icn9700Dev *)panel->object->priv;
274     return icn9700;
275 }
276 
LcdCheckChipId(struct PanelData * panel)277 static int32_t LcdCheckChipId(struct PanelData *panel)
278 {
279     int32_t ret;
280     struct Icn9700Dev *icn9700 = NULL;
281     uint8_t payload = 0xA1;
282     uint8_t bufRead[2] = { 0 };
283     struct DsiCmdDesc cmdRead = {
284         .dataType = 0x06,     /* 0x06: read data type */
285         .dataLen = 1,         /* 1: data len */
286         .delay = 0,
287         .payload = &payload,
288     };
289     icn9700 = PanelToIcn9700Dev(panel);
290     if ((icn9700 == NULL) || (icn9700->mipiHandle == NULL)) {
291         HDF_LOGE("%s: icn9700 || mipiHandle is null", __func__);
292         return HDF_FAILURE;
293     }
294     /* lcd reset power on */
295     ret = LcdResetOn(icn9700);
296     if (ret != HDF_SUCCESS) {
297         HDF_LOGE("%s: LcdResetOn failed", __func__);
298         return HDF_FAILURE;
299     }
300     ret = MipiDsiRx(icn9700->mipiHandle, &cmdRead, sizeof(bufRead), bufRead);
301     if (ret == HDF_SUCCESS) {
302         if (bufRead[0] == 0x99) {
303             HDF_LOGI("%s: OK: ST7701SN", __func__);
304             g_panelSolution = 1;
305         } else {
306             HDF_LOGI("%s: OK: ICN9700", __func__);
307             g_panelSolution = 0;
308         }
309     } else {
310         HDF_LOGE("%s: NG: def ICN9700", __func__);
311     }
312     /* lcd reset power off */
313     ret = LcdResetOff(icn9700);
314     return ret;
315 }
316 
Icn9700Init(struct PanelData * panel)317 static int32_t Icn9700Init(struct PanelData *panel)
318 {
319     struct Icn9700Dev *icn9700 = NULL;
320 
321     icn9700 = PanelToIcn9700Dev(panel);
322     if (icn9700 == NULL) {
323         HDF_LOGE("%s: icn9700 is null", __func__);
324         return HDF_FAILURE;
325     }
326     icn9700->mipiHandle = MipiDsiOpen(MIPI_DSI0);
327     if (icn9700->mipiHandle == NULL) {
328         HDF_LOGE("%s: MipiDsiOpen failed", __func__);
329         return HDF_FAILURE;
330     }
331     LcdCheckChipId(panel);
332     return HDF_SUCCESS;
333 }
334 
Icn9700On(struct PanelData * panel)335 static int32_t Icn9700On(struct PanelData *panel)
336 {
337     int32_t ret;
338     struct Icn9700Dev *icn9700 = NULL;
339 
340     icn9700 = PanelToIcn9700Dev(panel);
341     if (icn9700 == NULL) {
342         HDF_LOGE("%s: icn9700 is null", __func__);
343         return HDF_FAILURE;
344     }
345     /* lcd reset power on */
346     ret = LcdResetOn(icn9700);
347     if (ret != HDF_SUCCESS) {
348         HDF_LOGE("%s: LcdResetOn failed", __func__);
349         return HDF_FAILURE;
350     }
351     if (icn9700->mipiHandle == NULL) {
352         HDF_LOGE("%s: mipiHandle is null", __func__);
353         return HDF_FAILURE;
354     }
355     /* send mipi init code */
356     int32_t count = 0;
357     int32_t i;
358     struct DsiCmdDesc* g_OnCmd = NULL;
359     if (g_panelSolution == 1) {
360         count = sizeof(g_OnCmd1) / sizeof(g_OnCmd1[0]);
361         g_OnCmd = &(g_OnCmd1[0]);
362     } else {
363         count = sizeof(g_OnCmd0) / sizeof(g_OnCmd0[0]);
364         g_OnCmd = &(g_OnCmd0[0]);
365     }
366     /* set mipi to lp mode */
367     MipiDsiSetLpMode(icn9700->mipiHandle);
368     for (i = 0; i < count; i++) {
369         ret = MipiDsiTx(icn9700->mipiHandle, &(g_OnCmd[i]));
370         if (ret != HDF_SUCCESS) {
371             HDF_LOGE("%s: MipiDsiTx failed", __func__);
372             return HDF_FAILURE;
373         }
374     }
375     /* set mipi to hs mode */
376     MipiDsiSetHsMode(icn9700->mipiHandle);
377     return HDF_SUCCESS;
378 }
379 
Icn9700Off(struct PanelData * panel)380 static int32_t Icn9700Off(struct PanelData *panel)
381 {
382     int32_t ret;
383     struct Icn9700Dev *icn9700 = NULL;
384 
385     icn9700 = PanelToIcn9700Dev(panel);
386     if (icn9700 == NULL) {
387         HDF_LOGE("%s: icn9700 is null", __func__);
388         return HDF_FAILURE;
389     }
390     if (icn9700->mipiHandle == NULL) {
391         HDF_LOGE("%s: mipiHandle is null", __func__);
392         return HDF_FAILURE;
393     }
394     /* send mipi init code */
395     int32_t count = sizeof(g_offCmd) / sizeof(g_offCmd[0]);
396     int32_t i;
397     /* set mipi to lp mode */
398     MipiDsiSetLpMode(icn9700->mipiHandle);
399     for (i = 0; i < count; i++) {
400         ret = MipiDsiTx(icn9700->mipiHandle, &(g_offCmd[i]));
401         if (ret != HDF_SUCCESS) {
402             HDF_LOGE("%s: MipiDsiTx failed", __func__);
403             return HDF_FAILURE;
404         }
405     }
406     /* lcd reset power off */
407     ret = LcdResetOff(icn9700);
408     if (ret != HDF_SUCCESS) {
409         HDF_LOGE("%s: LcdResetOff failed", __func__);
410         return HDF_FAILURE;
411     }
412     return HDF_SUCCESS;
413 }
414 
Icn9700EsdCheckFunc(struct PanelData * panel)415 static int32_t Icn9700EsdCheckFunc(struct PanelData *panel)
416 {
417     struct Icn9700Dev *icn9700 = NULL;
418 
419     icn9700 = PanelToIcn9700Dev(panel);
420     if (icn9700 == NULL) {
421         HDF_LOGE("%s: icn9700 is null", __func__);
422         return HDF_FAILURE;
423     }
424     HDF_LOGE("%s: enter", __func__);
425     return HDF_SUCCESS;
426 }
427 
428 #define OUTPUT_USER 0 /* output timing type */
429 static struct PanelInfo g_panelInfo = {
430     .width = WIDTH1,                    /* width */
431     .height = HEIGHT1,                  /* height */
432     .hbp = HORIZONTAL_BACK_PORCH1,      /* horizontal back porch */
433     .hfp = HORIZONTAL_FRONT_PORCH1,     /* horizontal front porch */
434     .hsw = HORIZONTAL_SYNC_WIDTH1,      /* horizontal sync width */
435     .vbp = VERTICAL_BACK_PORCH1,        /* vertical back porch */
436     .vfp = VERTICAL_FRONT_PORCH1,       /* vertical front porch */
437     .vsw = VERTICAL_SYNC_WIDTH1,        /* vertical sync width */
438     .frameRate = FRAME_RATE1,           /* frame rate */
439     .intfType = MIPI_DSI,               /* panel interface type */
440     .intfSync = OUTPUT_USER,
441     /* mipi config info */
442     .mipi = { DSI_2_LANES, DSI_VIDEO_MODE, VIDEO_BURST_MODE, FORMAT_RGB_24_BIT },
443     /* backlight config info */
444     .blk = { BLK_PWM, MIN_LEVEL, MAX_LEVEL, DEFAULT_LEVEL },
445     .pwm = { BLK_PWM1, PWM_MAX_PERIOD },
446 };
447 
448 static struct PanelEsd g_panelEsd = {
449     .support = false,
450     .checkFunc = Icn9700EsdCheckFunc,
451 };
452 
Icn9700PanelInit(struct PanelData * panel)453 static void Icn9700PanelInit(struct PanelData *panel)
454 {
455     panel->info = &g_panelInfo;
456     panel->esd = &g_panelEsd;
457     panel->init = Icn9700Init;
458     panel->on = Icn9700On;
459     panel->off = Icn9700Off;
460 }
461 
Icn9700EntryInit(struct HdfDeviceObject * object)462 static int32_t Icn9700EntryInit(struct HdfDeviceObject *object)
463 {
464     struct Icn9700Dev *icn9700 = NULL;
465 
466     if (object == NULL) {
467         HDF_LOGE("%s: object is null", __func__);
468         return HDF_FAILURE;
469     }
470     icn9700 = (struct Icn9700Dev *)OsalMemCalloc(sizeof(struct Icn9700Dev));
471     if (icn9700 == NULL) {
472         HDF_LOGE("%s icn9700 malloc fail", __func__);
473         return HDF_FAILURE;
474     }
475     Icn9700PanelInit(&icn9700->panel);
476     icn9700->panel.object = object;
477     icn9700->reset_gpio = RESET_GPIO;
478     icn9700->reset_delay = 20; // delay 20ms
479     object->priv = (void *)icn9700;
480     icn9700->panel.blDev = GetBacklightDev("hdf_pwm");
481     if (icn9700->panel.blDev == NULL) {
482         HDF_LOGE("%s GetBacklightDev fail", __func__);
483         return HDF_FAILURE;
484     }
485     if (RegisterPanel(&icn9700->panel) != HDF_SUCCESS) {
486         HDF_LOGE("%s: RegisterPanel failed", __func__);
487         return HDF_FAILURE;
488     }
489     HDF_LOGI("%s: exit succ", __func__);
490     return HDF_SUCCESS;
491 }
492 
493 struct HdfDriverEntry g_icn9700DevEntry = {
494     .moduleVersion = 1,
495     .moduleName = "LCD_ICN9700",
496     .Init = Icn9700EntryInit,
497 };
498 
499 HDF_INIT(g_icn9700DevEntry);
500