• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "cmsis_os2.h"
16 #include "hdf_log.h"
17 #include "lcd_abs_if.h"
18 #include "hdf_device_desc.h"
19 #include "hal_gpio.h"
20 #include "hal_iomux.h"
21 #include "hal_dsi.h"
22 #ifdef LOSCFG_DRIVERS_HDF_CONFIG_MACRO
23 #include "hcs_macro.h"
24 #include "hdf_config_macro.h"
25 #else
26 #include "device_resource_if.h"
27 #endif
28 
29 #ifdef CONFIG_DISPLAY_A064
30 #define WIDTH 480
31 #define HEIGHT 480
32 
33 static void PanelPowerControl(bool on);
34 static int32_t PanelCheckStatus(struct PanelData *panel);
35 static int32_t PanelReadId();
36 
37 static uint8_t cmd0[] = {0xF0, 0x55, 0xAA, 0x52, 0x08, 0x00};
38 static uint8_t cmd1[] = {0xF6, 0x5A, 0x87};
39 static uint8_t cmd2[] = {0x3A, 0x70};
40 static uint8_t cmd3[] = {0xC1, 0x3F};
41 static uint8_t cmd4[] = {0xC2, 0x0E};
42 static uint8_t cmd5[] = {0xC6, 0xF8};
43 static uint8_t cmd6[] = {0xC9, 0x10};
44 static uint8_t cmd7[] = {0xCD, 0x25};
45 static uint8_t cmd8[] = {0xF8, 0x8A};
46 static uint8_t cmd9[] = {0xAC, 0x65};
47 static uint8_t cmd10[] = {0xA0, 0xDD};
48 static uint8_t cmd11[] = {0xA7, 0x47};
49 static uint8_t cmd12[] = {0xFA, 0x00, 0x00, 0x00, 0x04};
50 static uint8_t cmd13[] = {0x86, 0x99, 0xa3, 0xa3, 0x51};
51 static uint8_t cmd14[] = {0xA3, 0xEE};
52 static uint8_t cmd15[] = {0xFD, 0x3c, 0x3c, 0x00};
53 static uint8_t cmd16[] = {0x71, 0x48};
54 static uint8_t cmd17[] = {0x72, 0x48};
55 static uint8_t cmd18[] = {0x73, 0x00, 0x44};
56 static uint8_t cmd19[] = {0x97, 0xEE};
57 static uint8_t cmd20[] = {0x83, 0x93};
58 static uint8_t cmd21[] = {0x9A, 0x79};
59 static uint8_t cmd22[] = {0x9B, 0x62};
60 static uint8_t cmd23[] = {0x82, 0x34, 0x34};
61 static uint8_t cmd24[] = {0xB1, 0x90}; // 10 REV-0-BGR-X-X-X-GS-SS   //mipi
62 static uint8_t cmd25[] = {0x6D, 0x00, 0x1F, 0x19, 0x1A, 0x10, 0x0e, 0x0c, 0x0a, 0x02, 0x07, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x08, 0x01, 0x09, 0x0b, 0x0D, 0x0F, 0x1a, 0x19, 0x1f, 0x00};
63 static uint8_t cmd26[] = {0x64, 0x38, 0x05, 0x01, 0xdb, 0x03, 0x03, 0x38, 0x04, 0x01, 0xdc, 0x03, 0x03, 0x7A, 0x7A, 0x7A, 0x7A};
64 static uint8_t cmd27[] = {0x65, 0x38, 0x03, 0x01, 0xdd, 0x03, 0x03, 0x38, 0x02, 0x01, 0xde, 0x03, 0x03, 0x7A, 0x7A, 0x7A, 0x7A};
65 static uint8_t cmd28[] = {0x66, 0x38, 0x01, 0x01, 0xdf, 0x03, 0x03, 0x38, 0x00, 0x01, 0xe0, 0x03, 0x03, 0x7A, 0x7A, 0x7A, 0x7A};
66 static uint8_t cmd29[] = {0x67, 0x30, 0x01, 0x01, 0xe1, 0x03, 0x03, 0x30, 0x02, 0x01, 0xe2, 0x03, 0x03, 0x7A, 0x7A, 0x7A, 0x7A};
67 static uint8_t cmd30[] = {0x68, 0x00, 0x08, 0x15, 0x08, 0x15, 0x7A, 0x7A, 0x08, 0x15, 0x08, 0x15, 0x7A, 0x7A};
68 static uint8_t cmd31[] = {0x60, 0x38, 0x07, 0x7A, 0x7A, 0x38, 0x08, 0x7A, 0x7A};
69 static uint8_t cmd32[] = {0x63, 0x31, 0xe4, 0x7A, 0x7A, 0x31, 0xe5, 0x7A, 0x7A};
70 static uint8_t cmd33[] = {0x69, 0x04, 0x22, 0x14, 0x22, 0x14, 0x22, 0x08};
71 static uint8_t cmd34[] = {0x6B, 0x07};
72 static uint8_t cmd35[] = {0x7A, 0x08, 0x13};
73 static uint8_t cmd36[] = {0x7B, 0x08, 0x13};
74 static uint8_t cmd37[] = {0xD1, 0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18, 0x00, 0x21, 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47, 0x00, 0x56, 0x00, 0x90, 0x00, 0xe5, 0x01, 0x68, 0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6, 0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba, 0x03, 0xc5, 0x03, 0xd0, 0x03, 0xE0, 0x03, 0xea, 0x03, 0xFa, 0x03, 0xFF};
75 static uint8_t cmd38[] = {0xD2, 0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18, 0x00, 0x21, 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47, 0x00, 0x56, 0x00, 0x90, 0x00, 0xe5, 0x01, 0x68, 0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6, 0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba, 0x03, 0xc5, 0x03, 0xd0, 0x03, 0xE0, 0x03, 0xea, 0x03, 0xFa, 0x03, 0xFF};
76 static uint8_t cmd39[] = {0xD3, 0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18, 0x00, 0x21, 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47, 0x00, 0x56, 0x00, 0x90, 0x00, 0xe5, 0x01, 0x68, 0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6, 0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba, 0x03, 0xc5, 0x03, 0xd0, 0x03, 0xE0, 0x03, 0xea, 0x03, 0xFa, 0x03, 0xFF};
77 static uint8_t cmd40[] = {0xD4, 0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18, 0x00, 0x21, 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47, 0x00, 0x56, 0x00, 0x90, 0x00, 0xe5, 0x01, 0x68, 0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6, 0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba, 0x03, 0xc5, 0x03, 0xd0, 0x03, 0xE0, 0x03, 0xea, 0x03, 0xFa, 0x03, 0xFF};
78 static uint8_t cmd41[] = {0xD5, 0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18, 0x00, 0x21, 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47, 0x00, 0x56, 0x00, 0x90, 0x00, 0xe5, 0x01, 0x68, 0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6, 0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba, 0x03, 0xc5, 0x03, 0xd0, 0x03, 0xE0, 0x03, 0xea, 0x03, 0xFa, 0x03, 0xFF};
79 static uint8_t cmd42[] = {0xD6, 0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18, 0x00, 0x21, 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47, 0x00, 0x56, 0x00, 0x90, 0x00, 0xe5, 0x01, 0x68, 0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6, 0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba, 0x03, 0xc5, 0x03, 0xd0, 0x03, 0xE0, 0x03, 0xea, 0x03, 0xFa, 0x03, 0xFF};
80 static uint8_t cmd43[] = {0x11};
81 static uint8_t cmd44[] = {0x29};
82 static uint8_t cmd45[] = {0x28};
83 static uint8_t cmd46[] = {0x10};
84 
85 static struct DsiCmdDesc g_OnCmd[] = {
86     {0x39, 0, sizeof(cmd0), cmd0},
87     {0x39, 0, sizeof(cmd1), cmd1},
88     {0x15, 0, sizeof(cmd2), cmd2},
89     {0x15, 0, sizeof(cmd3), cmd3},
90     {0x15, 0, sizeof(cmd4), cmd4},
91     {0x15, 0, sizeof(cmd5), cmd5},
92     {0x15, 0, sizeof(cmd6), cmd6},
93     {0x15, 0, sizeof(cmd7), cmd7},
94     {0x15, 0, sizeof(cmd8), cmd8},
95     {0x15, 0, sizeof(cmd9), cmd9},
96     {0x15, 0, sizeof(cmd10), cmd10},
97     {0x15, 0, sizeof(cmd11), cmd11},
98     {0x39, 0, sizeof(cmd12), cmd12},
99     {0x39, 0, sizeof(cmd13), cmd13},
100     {0x15, 0, sizeof(cmd14), cmd14},
101     {0x39, 0, sizeof(cmd15), cmd15},
102     {0x15, 0, sizeof(cmd16), cmd16},
103     {0x15, 0, sizeof(cmd17), cmd17},
104     {0x39, 0, sizeof(cmd18), cmd18},
105     {0x15, 0, sizeof(cmd19), cmd19},
106     {0x15, 0, sizeof(cmd20), cmd20},
107     {0x15, 0, sizeof(cmd21), cmd21},
108     {0x15, 0, sizeof(cmd22), cmd22},
109     {0x39, 0, sizeof(cmd23), cmd23},
110     {0x15, 0, sizeof(cmd24), cmd24},
111     {0x39, 0, sizeof(cmd25), cmd25},
112     {0x39, 0, sizeof(cmd26), cmd26},
113     {0x39, 0, sizeof(cmd27), cmd27},
114     {0x39, 0, sizeof(cmd28), cmd28},
115     {0x39, 0, sizeof(cmd29), cmd29},
116     {0x39, 0, sizeof(cmd30), cmd30},
117     {0x39, 0, sizeof(cmd31), cmd31},
118     {0x39, 0, sizeof(cmd32), cmd32},
119     {0x39, 0, sizeof(cmd33), cmd33},
120     {0x15, 0, sizeof(cmd34), cmd34},
121     {0x39, 0, sizeof(cmd35), cmd35},
122     {0x39, 0, sizeof(cmd36), cmd36},
123     {0x39, 0, sizeof(cmd37), cmd37},
124     {0x39, 0, sizeof(cmd38), cmd38},
125     {0x39, 0, sizeof(cmd39), cmd39},
126     {0x39, 0, sizeof(cmd40), cmd40},
127     {0x39, 0, sizeof(cmd41), cmd41},
128     {0x39, 0, sizeof(cmd42), cmd42},
129     {0x05, 120, sizeof(cmd43), cmd43},
130     {0x05, 20, sizeof(cmd44), cmd44},
131 };
132 
133 struct DsiCmdDesc g_offCmd[] = {
134     {0x05, 20, sizeof(cmd45), cmd45},
135     {0x05, 120, sizeof(cmd46), cmd46},
136 };
137 
138 struct PanelDevice {
139     struct PanelData panelData;
140     struct PanelInfo panelInfo;
141     struct PanelEsd panelEsd;
142     DevHandle mipiHandle;
143     struct HAL_IOMUX_PIN_FUNCTION_MAP pin_rst;
144     struct HAL_IOMUX_PIN_FUNCTION_MAP pin_te;
145     struct HAL_IOMUX_PIN_FUNCTION_MAP pin_led;
146 };
147 
148 static struct PanelDevice priv = {
149     .panelInfo = {
150         .width = WIDTH,
151         .height = HEIGHT,
152         .hbp = 10,
153         .hfp = 10,
154         .hsw = 8,
155         .vbp = 20,
156         .vfp = 20,
157         .vsw = 8,
158         .frameRate = 60,
159         .intfType = MIPI_DSI,
160         .intfSync = OUTPUT_USER,
161         .mipi = {DSI_2_LANES, DSI_VIDEO_MODE, VIDEO_BURST_MODE, FORMAT_RGB_24_BIT},
162     },
163     .panelEsd = {
164         .support = true,
165         .interval = 30 * 1000,
166         .recoveryNum = 5,
167         .checkFunc = PanelCheckStatus,
168     },
169     .pin_rst = {
170         HAL_GPIO_PIN_P0_3,
171         HAL_IOMUX_FUNC_AS_GPIO,
172         HAL_IOMUX_PIN_VOLTAGE_VIO,
173         HAL_IOMUX_PIN_NOPULL,
174     },
175     .pin_te = {
176         HAL_IOMUX_PIN_P2_1,
177         HAL_IOMUX_FUNC_DISPLAY_TE,
178         HAL_IOMUX_PIN_VOLTAGE_VIO,
179         HAL_IOMUX_PIN_NOPULL,
180     },
181     .pin_led = {
182         HAL_IOMUX_PIN_P2_6,
183         HAL_IOMUX_FUNC_AS_GPIO,
184         HAL_IOMUX_PIN_VOLTAGE_VIO,
185         HAL_IOMUX_PIN_NOPULL,
186     },
187 };
188 
PanelInit(struct PanelData * panel)189 static int32_t PanelInit(struct PanelData *panel)
190 {
191     if (panel == NULL || panel->info == NULL) {
192         return HDF_FAILURE;
193     }
194     priv.mipiHandle = MipiDsiOpen(0);
195     if (priv.mipiHandle == NULL) {
196         HDF_LOGE("%s: MipiDsiOpen failed", __func__);
197         return HDF_FAILURE;
198     }
199     HDF_LOGI("%s: width %d, height %d", __func__, WIDTH, HEIGHT);
200     PanelPowerControl(true);
201 
202     struct PanelInfo *panelInfo = panel->info;
203     struct MipiCfg cfg = {0};
204     cfg.lane = panelInfo->mipi.lane;
205     cfg.mode = panelInfo->mipi.mode;
206     cfg.format = panelInfo->mipi.format;
207     cfg.burstMode = panelInfo->mipi.burstMode;
208     cfg.timing.xPixels = panelInfo->width;
209     cfg.timing.hsaPixels = panelInfo->hsw;
210     cfg.timing.hbpPixels = panelInfo->hbp;
211     cfg.timing.hlinePixels = panelInfo->width + panelInfo->hbp + panelInfo->hfp + panelInfo->hsw;
212     cfg.timing.vsaLines = panelInfo->vsw;
213     cfg.timing.vbpLines = panelInfo->vbp;
214     cfg.timing.vfpLines = panelInfo->vfp;
215     cfg.timing.ylines = panelInfo->height;
216 
217     cfg.pixelClk = CalcPixelClk(panelInfo);
218     cfg.phyDataRate = CalcDataRate(panelInfo);
219     /* config mipi device */
220     if (MipiDsiSetCfg(priv.mipiHandle, &cfg) != HDF_SUCCESS) {
221         HDF_LOGE("%s: MipiDsiSetCfg failed", __func__);
222         return HDF_FAILURE;
223     }
224     PanelReadId();
225     return HDF_SUCCESS;
226 }
227 
PanelPowerControl(bool on)228 static void PanelPowerControl(bool on)
229 {
230     if (on) {
231         hal_iomux_init(&priv.pin_led, 1);
232         hal_iomux_init(&priv.pin_rst, 1);
233         hal_iomux_init(&priv.pin_te, 1);
234         hal_gpio_pin_set_dir(priv.pin_rst.pin, HAL_GPIO_DIR_OUT, 1);
235         osDelay(10);
236         hal_gpio_pin_clr(priv.pin_rst.pin);
237         osDelay(10);
238         hal_gpio_pin_set(priv.pin_rst.pin);
239         osDelay(10);
240     } else {
241         osDelay(20);
242         hal_gpio_pin_clr(priv.pin_rst.pin);
243         osDelay(120);
244         hal_gpio_pin_clr(priv.pin_led.pin);
245     }
246 }
247 
PanelReadId()248 static int32_t PanelReadId()
249 {
250     uint8_t read_id[3] = {0};
251     uint8_t payload[] = {0x04};
252     struct DsiCmdDesc cmd = {0x06, 0, sizeof(payload), payload};
253     int32_t ret = MipiDsiRx(priv.mipiHandle, &cmd, 3, read_id);
254     if (ret != HDF_SUCCESS) {
255         HDF_LOGE("%s: MipiDsiRx failed", __func__);
256         return HDF_FAILURE;
257     }
258     HDF_LOGI("%s: read id %02X-%02X-%02X", __func__, read_id[0], read_id[1], read_id[2]);
259     return HDF_SUCCESS;
260 }
261 #define DSI_INIT_DELAY 100
PanelCheckStatus(struct PanelData * panel)262 static int32_t PanelCheckStatus(struct PanelData *panel)
263 {
264     uint8_t powerMode = 0;
265     uint8_t payload[] = {0x0A};
266     struct DsiCmdDesc cmd = {0x06, 0, sizeof(payload), payload};
267     int64_t cnt = panel->esd->recoveryNum;
268     do {
269         int32_t ret = MipiDsiRx(priv.mipiHandle, &cmd, 1, &powerMode);
270         if (ret == HDF_SUCCESS) {
271             HDF_LOGD("%s: powerMode 0x%x ok", __func__, powerMode);
272             break;
273         }
274         HDF_LOGE("%s: reset", __func__);
275         hal_dsi_init(WIDTH);
276         osDelay(DSI_INIT_DELAY);
277         for (int32_t i = 0; i < sizeof(g_OnCmd) / sizeof(g_OnCmd[0]); i++) {
278             ret = MipiDsiTx(priv.mipiHandle, &(g_OnCmd[i]));
279             if (ret != HDF_SUCCESS) {
280                 HDF_LOGE("%s: MipiDsiTx failed", __func__);
281                 return HDF_FAILURE;
282             }
283         }
284     } while (--cnt > 0);
285     if (cnt < panel->esd->recoveryNum) {
286         hal_dsi_start();
287     }
288     return HDF_SUCCESS;
289 }
290 
PanelOn(struct PanelData * panel)291 static int32_t PanelOn(struct PanelData *panel)
292 {
293     /* send mipi power on code */
294     int32_t count = sizeof(g_OnCmd) / sizeof(g_OnCmd[0]);
295     int32_t i;
296     for (i = 0; i < count; i++) {
297         int32_t ret = MipiDsiTx(priv.mipiHandle, &(g_OnCmd[i]));
298         if (ret != HDF_SUCCESS) {
299             HDF_LOGE("%s: MipiDsiTx failed", __func__);
300             return HDF_FAILURE;
301         }
302     }
303     /* set mipi to hs mode */
304     MipiDsiSetHsMode(priv.mipiHandle);
305     PanelCheckStatus(panel);
306     hal_gpio_pin_set_dir(priv.pin_led.pin, HAL_GPIO_DIR_OUT, 1);
307     osDelay(20);
308     return HDF_SUCCESS;
309 }
310 
PanelOff(struct PanelData * panel)311 static int32_t PanelOff(struct PanelData *panel)
312 {
313     /* send mipi power off code */
314     int32_t count = sizeof(g_offCmd) / sizeof(g_offCmd[0]);
315     int32_t i;
316     for (i = 0; i < count; i++) {
317         int32_t ret = MipiDsiTx(priv.mipiHandle, &(g_offCmd[i]));
318         if (ret != HDF_SUCCESS) {
319             HDF_LOGE("%s: MipiDsiTx failed", __func__);
320             return HDF_FAILURE;
321         }
322     }
323     /* set mipi to lp mode */
324     MipiDsiSetLpMode(priv.mipiHandle);
325     return HDF_SUCCESS;
326 }
327 
PanelSetBacklight(struct PanelData * panel,uint32_t level)328 static int32_t PanelSetBacklight(struct PanelData *panel, uint32_t level)
329 {
330     (void)panel;
331     uint8_t payload[] = {0x51, level & 0xff};
332     struct DsiCmdDesc cmd = {0x15, 0, sizeof(payload), payload};
333     if (MipiDsiTx(priv.mipiHandle, &cmd) != HDF_SUCCESS) {
334         HDF_LOGE("%s: MipiDsiTx failed", __func__);
335         return HDF_FAILURE;
336     }
337     PanelCheckStatus(panel);
338     return HDF_SUCCESS;
339 }
340 #define REAL_PIN(n) (n / 10 * 8 + n % 10)
341 #ifdef LOSCFG_DRIVERS_HDF_CONFIG_MACRO
342 #define DISPLAY_PANEL_CONFIG HCS_NODE(HCS_NODE(HCS_NODE(HCS_ROOT, display), panel_config), a064_config)
PanelGetResource(struct PanelDevice * priv)343 static uint32_t PanelGetResource(struct PanelDevice *priv)
344 {
345     uint32_t temp;
346     temp = HCS_PROP(DISPLAY_PANEL_CONFIG, rst_pin);
347     priv->pin_rst.pin = REAL_PIN(temp);
348 
349     temp = HCS_PROP(DISPLAY_PANEL_CONFIG, te_pin);
350     priv->pin_te.pin = REAL_PIN(temp);
351 
352     temp = HCS_PROP(DISPLAY_PANEL_CONFIG, led_pin);
353     priv->pin_led.pin = REAL_PIN(temp);
354 
355     HDF_LOGD("%s: rst_pin=%d, te_pin=%d, led_pin=%d", __func__, priv->pin_rst.pin, priv->pin_te.pin, priv->pin_led.pin);
356     return HDF_SUCCESS;
357 }
358 #else
PanelGetResource(struct PanelDevice * priv,const struct DeviceResourceNode * resourceNode)359 static uint32_t PanelGetResource(struct PanelDevice *priv, const struct DeviceResourceNode *resourceNode)
360 {
361     struct DeviceResourceIface *res = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE);
362     if (res == NULL || res->GetUint32 == NULL) {
363         HDF_LOGE("DeviceResourceIface is invalid");
364         return HDF_FAILURE;
365     }
366     uint32_t temp = 0;
367     if (res->GetUint32(resourceNode, "rst_pin", &temp, 0) != HDF_SUCCESS) {
368         HDF_LOGE("%s: failed to get rst_pin", __func__);
369         return HDF_FAILURE;
370     }
371     priv->pin_rst.pin = REAL_PIN(temp);
372     if (res->GetUint32(resourceNode, "te_pin", &temp, 0) != HDF_SUCCESS) {
373         HDF_LOGE("%s: failed to get te_pin", __func__);
374         return HDF_FAILURE;
375     }
376     priv->pin_te.pin = REAL_PIN(temp);
377     if (res->GetUint32(resourceNode, "led_pin", &temp, 0) != HDF_SUCCESS) {
378         HDF_LOGE("%s: failed to get led_pin", __func__);
379         return HDF_FAILURE;
380     }
381     priv->pin_led.pin = REAL_PIN(temp);
382     HDF_LOGD("%s: rst_pin=%d, te_pin=%d, led_pin=%d", __func__, priv->pin_rst.pin, priv->pin_te.pin, priv->pin_led.pin);
383     return HDF_SUCCESS;
384 }
385 #endif
PanelDriverInit(struct HdfDeviceObject * object)386 static int32_t PanelDriverInit(struct HdfDeviceObject *object)
387 {
388     if (object == NULL) {
389         return HDF_FAILURE;
390     }
391 #ifdef LOSCFG_DRIVERS_HDF_CONFIG_MACRO
392     if (PanelGetResource(&priv) != HDF_SUCCESS) {
393         HDF_LOGE("%s: PanelGetResource failed", __func__);
394         return HDF_FAILURE;
395     }
396 #else
397     if (object->property) {
398         if (PanelGetResource(&priv, object->property) != HDF_SUCCESS) {
399             HDF_LOGE("%s: PanelGetResource failed", __func__);
400             return HDF_FAILURE;
401         }
402     }
403 #endif
404     priv.panelData.info = &priv.panelInfo;
405     priv.panelData.esd = &priv.panelEsd;
406     priv.panelData.init = PanelInit;
407     priv.panelData.on = PanelOn;
408     priv.panelData.off = PanelOff;
409     priv.panelData.setBacklight = PanelSetBacklight;
410     priv.panelData.object = object;
411     if (RegisterPanel(&priv.panelData) != HDF_SUCCESS) {
412         HDF_LOGE("%s: RegisterPanel failed", __func__);
413         return HDF_FAILURE;
414     }
415     return HDF_SUCCESS;
416 }
417 
PanelDriverBind(struct HdfDeviceObject * device)418 static int32_t PanelDriverBind(struct HdfDeviceObject *device)
419 {
420     (void)device;
421     return HDF_SUCCESS;
422 }
423 
PanelDriverRelease(struct HdfDeviceObject * device)424 static void PanelDriverRelease(struct HdfDeviceObject *device)
425 {
426     (void)device;
427 }
428 
429 static struct HdfDriverEntry g_A064DriverEntry = {
430     .moduleVersion = 1,
431     .moduleName = "HDF_PANEL_A064",
432     .Bind = PanelDriverBind,
433     .Init = PanelDriverInit,
434     .Release = PanelDriverRelease,
435 };
436 
437 HDF_INIT(g_A064DriverEntry);
438 #endif