huangcm
2025-07-03 c26084b3642f262f858535ab4e46c1e9b520d3a1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
/*
 * Allwinner SoCs display driver.
 *
 * Copyright (C) 2016 Allwinner.
 *
 * This file is licensed under the terms of the GNU General Public
 * License version 2.  This program is licensed "as is" without any
 * warranty of any kind, whether express or implied.
 */
 
#include "lcd_source.h"
 
/**
 * sunxi_lcd_delay_ms.
 * @ms: Delay time, unit: millisecond.
 */
s32 sunxi_lcd_delay_ms(u32 ms)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_delay_ms)
       return g_lcd_drv.src_ops.sunxi_lcd_delay_ms(ms);
 
   return -1;
}
 
/**
 * sunxi_lcd_delay_us.
 * @us: Delay time, unit: microsecond.
 */
s32 sunxi_lcd_delay_us(u32 us)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_delay_us)
       return g_lcd_drv.src_ops.sunxi_lcd_delay_us(us);
 
   return -1;
}
 
/**
 * sunxi_lcd_tcon_enable - enable timing controller.
 * @screen_id: The index of screen.
 */
void sunxi_lcd_tcon_enable(u32 screen_id)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_tcon_enable)
       g_lcd_drv.src_ops.sunxi_lcd_tcon_enable(screen_id);
}
 
 
/**
 * sunxi_lcd_dsi_mode_switch
 * @screen_id: The index of screen.
 * @cmd_en : enable command mode
 * @lp_en : enable low power mode for video mode
 */
void sunxi_lcd_dsi_mode_switch(u32 screen_id, u32 cmd_en, u32 lp_en)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_dsi_mode_switch)
       g_lcd_drv.src_ops.sunxi_lcd_dsi_mode_switch(screen_id, cmd_en,
                               lp_en);
}
 
/**
 * sunxi_lcd_tcon_disable - disable timing controller.
 * @screen_id: The index of screen.
 */
void sunxi_lcd_tcon_disable(u32 screen_id)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_tcon_disable)
       g_lcd_drv.src_ops.sunxi_lcd_tcon_disable(screen_id);
}
 
/**
 * sunxi_lcd_backlight_enable - enable the backlight of panel.
 * @screen_id: The index of screen.
 */
void sunxi_lcd_backlight_enable(u32 screen_id)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_backlight_enable)
       g_lcd_drv.src_ops.sunxi_lcd_backlight_enable(screen_id);
}
 
/**
 * sunxi_lcd_backlight_disable - disable the backlight of panel.
 * @screen_id: The index of screen.
 */
void sunxi_lcd_backlight_disable(u32 screen_id)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_backlight_disable)
       g_lcd_drv.src_ops.sunxi_lcd_backlight_disable(screen_id);
}
 
/**
 * sunxi_lcd_power_enable - enable the power of panel.
 * @screen_id: The index of screen.
 * @pwr_id:     The index of power
 */
void sunxi_lcd_power_enable(u32 screen_id, u32 pwr_id)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_power_enable)
       g_lcd_drv.src_ops.sunxi_lcd_power_enable(screen_id, pwr_id);
}
 
/**
 * sunxi_lcd_power_disable - disable the power of panel.
 * @screen_id: The index of screen.
 * @pwr_id:     The index of power
 */
void sunxi_lcd_power_disable(u32 screen_id, u32 pwr_id)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_power_disable)
       g_lcd_drv.src_ops.sunxi_lcd_power_disable(screen_id, pwr_id);
}
 
/**
 * sunxi_lcd_pwm_enable - enable pwm modules, start output pwm wave.
 * @screen_id: The index of screen.
 *
 * need to conifg gpio for pwm function
 */
s32 sunxi_lcd_pwm_enable(u32 screen_id)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_pwm_enable)
       return g_lcd_drv.src_ops.sunxi_lcd_pwm_enable(screen_id);
 
   return -1;
}
 
/**
 * sunxi_lcd_pwm_disable - disable pwm modules, stop output pwm wave.
 * @screen_id: The index of screen.
 */
s32 sunxi_lcd_pwm_disable(u32 screen_id)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_pwm_disable)
       return g_lcd_drv.src_ops.sunxi_lcd_pwm_disable(screen_id);
 
   return -1;
}
 
/**
 *
 * sunxi_lcd_cpu_set_auto_mode
 * @screen_id: The index of screen.
 */
s32 sunxi_lcd_cpu_set_auto_mode(u32 screen_id)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_cpu_set_auto_mode)
       return g_lcd_drv.src_ops.sunxi_lcd_cpu_set_auto_mode(screen_id);
 
   return -1;
}
 
/**
 * sunxi_lcd_cpu_write - write command and para to cpu panel.
 * @screen_id: The index of screen.
 * @command: Command to be transfer.
 * @para: The pointer to para
 * @para_num: The number of para
 */
s32 sunxi_lcd_cpu_write(u32 screen_id, u32 index, u32 data)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_cpu_write)
       return g_lcd_drv.src_ops.sunxi_lcd_cpu_write(screen_id,
                                index, data);
 
   return -1;
}
 
/**
 * sunxi_lcd_cpu_write_index - write command to cpu panel.
 * @screen_id: The index of screen.
 * @index: Command or index to be transfer.
 */
s32 sunxi_lcd_cpu_write_index(u32 screen_id, u32 index)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_cpu_write_index)
       return g_lcd_drv.src_ops.sunxi_lcd_cpu_write_index(screen_id,
                                  index);
 
   return -1;
}
 
/**
 * sunxi_lcd_cpu_write_data - write data to cpu panel.
 * @screen_id: The index of screen.
 * @data: Data to be transfer.
 */
s32 sunxi_lcd_cpu_write_data(u32 screen_id, u32 data)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_cpu_write_data)
       return g_lcd_drv.src_ops.sunxi_lcd_cpu_write_data(screen_id,
                                 data);
 
   return -1;
}
 
/**
 * sunxi_lcd_dsi_dcs_write - write command and para to mipi panel.
 * @screen_id: The index of screen.
 * @command: Command to be transfer.
 * @para: The pointer to para.
 * @para_num: The number of para
 */
s32 sunxi_lcd_dsi_dcs_write(u32 screen_id, u8 command, u8 *para, u32 para_num)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_dsi_dcs_write)
       return g_lcd_drv.src_ops.sunxi_lcd_dsi_dcs_write(screen_id,
                                command, para,
                                para_num);
 
   return -1;
}
 
/**
 * sunxi_lcd_dsi_dcs_write - write command and para to mipi panel.
 * @screen_id: The index of screen.
 * @command: Command to be transfer.
 */
s32 sunxi_lcd_dsi_dcs_write_0para(u32 screen_id, u8 command)
{
   u8 tmp[5];
 
   sunxi_lcd_dsi_dcs_write(screen_id, command, tmp, 0);
 
   return -1;
}
 
/**
 * sunxi_lcd_dsi_dcs_write_1para - write command and para to mipi panel.
 * @screen_id: The index of screen.
 * @command: Command to be transfer.
 * @paran: Para to be transfer.
 */
s32 sunxi_lcd_dsi_dcs_write_1para(u32 screen_id, u8 command, u8 para1)
{
   u8 tmp[5];
 
   tmp[0] = para1;
   sunxi_lcd_dsi_dcs_write(screen_id, command, tmp, 1);
 
   return -1;
}
 
s32 sunxi_lcd_dsi_dcs_write_2para(u32 screen_id, u8 command, u8 para1, u8 para2)
{
   u8 tmp[5];
 
   tmp[0] = para1;
   tmp[1] = para2;
   sunxi_lcd_dsi_dcs_write(screen_id, command, tmp, 2);
 
   return -1;
}
 
s32 sunxi_lcd_dsi_dcs_write_3para(u32 screen_id, u8 command, u8 para1, u8 para2,
                 u8 para3)
{
   u8 tmp[5];
 
   tmp[0] = para1;
   tmp[1] = para2;
   tmp[2] = para3;
   sunxi_lcd_dsi_dcs_write(screen_id, command, tmp, 3);
 
   return -1;
}
 
s32 sunxi_lcd_dsi_dcs_write_4para(u32 screen_id, u8 command, u8 para1, u8 para2,
                 u8 para3, u8 para4)
{
   u8 tmp[5];
 
   tmp[0] = para1;
   tmp[1] = para2;
   tmp[2] = para3;
   tmp[3] = para4;
   sunxi_lcd_dsi_dcs_write(screen_id, command, tmp, 4);
 
   return -1;
}
 
s32 sunxi_lcd_dsi_dcs_write_5para(u32 screen_id, u8 command, u8 para1, u8 para2,
                 u8 para3, u8 para4, u8 para5)
{
   u8 tmp[5];
 
   tmp[0] = para1;
   tmp[1] = para2;
   tmp[2] = para3;
   tmp[3] = para4;
   tmp[4] = para5;
   sunxi_lcd_dsi_dcs_write(screen_id, command, tmp, 5);
 
   return -1;
}
 
s32 sunxi_lcd_dsi_dcs_write_6para(u32 screen_id, u8 command, u8 para1, u8 para2,
                 u8 para3, u8 para4, u8 para5, u8 para6)
{
   u8 tmp[6];
 
   tmp[0] = para1;
   tmp[1] = para2;
   tmp[2] = para3;
   tmp[3] = para4;
   tmp[4] = para5;
   tmp[5] = para6;
   sunxi_lcd_dsi_dcs_write(screen_id, command, tmp, 6);
 
   return -1;
}
 
/**
 * sunxi_lcd_dsi_gen_write - write command and para to mipi panel.
 * @screen_id: The index of screen.
 * @command: Command to be transfer.
 * @para: The pointer to para.
 * @para_num: The number of para
 */
s32 sunxi_lcd_dsi_gen_write(u32 screen_id, u8 command, u8 *para, u32 para_num)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_dsi_gen_write)
       return g_lcd_drv.src_ops.sunxi_lcd_dsi_gen_write(screen_id,
                                command, para,
                                para_num);
 
   return -1;
}
 
/**
 * sunxi_lcd_dsi_gen_write - write command and para to mipi panel.
 * @screen_id: The index of screen.
 * @command: Command to be transfer.
 */
s32 sunxi_lcd_dsi_gen_write_0para(u32 screen_id, u8 command)
{
   u8 tmp[5];
 
   sunxi_lcd_dsi_gen_write(screen_id, command, tmp, 0);
 
   return -1;
}
 
/**
 * sunxi_lcd_dsi_gen_write_1para - write command and para to mipi panel.
 * @screen_id: The index of screen.
 * @command: Command to be transfer.
 * @paran: Para to be transfer.
 */
s32 sunxi_lcd_dsi_gen_write_1para(u32 screen_id, u8 command, u8 para1)
{
   u8 tmp[5];
 
   tmp[0] = para1;
   sunxi_lcd_dsi_gen_write(screen_id, command, tmp, 1);
 
   return -1;
}
 
s32 sunxi_lcd_dsi_gen_write_2para(u32 screen_id, u8 command, u8 para1, u8 para2)
{
   u8 tmp[5];
 
   tmp[0] = para1;
   tmp[1] = para2;
   sunxi_lcd_dsi_gen_write(screen_id, command, tmp, 2);
 
   return -1;
}
 
s32 sunxi_lcd_dsi_gen_write_3para(u32 screen_id, u8 command, u8 para1, u8 para2,
                 u8 para3)
{
   u8 tmp[5];
 
   tmp[0] = para1;
   tmp[1] = para2;
   tmp[2] = para3;
   sunxi_lcd_dsi_gen_write(screen_id, command, tmp, 3);
 
   return -1;
}
 
s32 sunxi_lcd_dsi_gen_write_4para(u32 screen_id, u8 command, u8 para1, u8 para2,
                 u8 para3, u8 para4)
{
   u8 tmp[5];
 
   tmp[0] = para1;
   tmp[1] = para2;
   tmp[2] = para3;
   tmp[3] = para4;
   sunxi_lcd_dsi_gen_write(screen_id, command, tmp, 4);
 
   return -1;
}
 
s32 sunxi_lcd_dsi_gen_write_5para(u32 screen_id, u8 command, u8 para1, u8 para2,
                 u8 para3, u8 para4, u8 para5)
{
   u8 tmp[5];
 
   tmp[0] = para1;
   tmp[1] = para2;
   tmp[2] = para3;
   tmp[3] = para4;
   tmp[4] = para5;
   sunxi_lcd_dsi_gen_write(screen_id, command, tmp, 5);
 
   return -1;
}
 
/**
 * sunxi_lcd_dsi_clk_enable - enable dsi clk.
 * @screen_id: The index of screen.
 */
s32 sunxi_lcd_dsi_clk_enable(u32 screen_id)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_dsi_clk_enable)
       return g_lcd_drv.src_ops.sunxi_lcd_dsi_clk_enable(screen_id, 1);
 
   return -1;
}
 
/**
 * sunxi_lcd_dsi_clk_disable - disable dsi clk.
 * @screen_id: The index of screen.
 */
s32 sunxi_lcd_dsi_clk_disable(u32 screen_id)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_dsi_clk_enable)
       return g_lcd_drv.src_ops.sunxi_lcd_dsi_clk_enable(screen_id, 0);
 
   return -1;
}
 
/**
 * sunxi_lcd_dsi_gen_read - generic short read
 * @screen_id: The index of screen.
 * @result: pointer that store the result
 */
static s32 sunxi_lcd_dsi_gen_short_read(u32 screen_id, u8 *para, u8 para_num,
                   u8 *result)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_dsi_gen_short_read)
       return g_lcd_drv.src_ops.sunxi_lcd_dsi_gen_short_read(screen_id,
                                para, para_num,
                                result);
   return -1;
}
 
/**
 * @name       :sunxi_lcd_dsi_set_max_ret_size
 * @brief      :set max ret size of dsi read
 * @param[IN]  :sel:index of dsi
 * @param[IN]  :size:number of byte of max size
 * @return     :0
 */
s32 sunxi_lcd_dsi_set_max_ret_size(u32 sel, u32 size)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_dsi_dcs_read)
       return g_lcd_drv.src_ops.sunxi_lcd_dsi_set_max_ret_size(sel,
                                   size);
   return 0;
}
 
/**
 * @name       :sunxi_lcd_dsi_dcs_read
 * @brief      :dcs read
 * @param[IN]  :sel:index of dsi
 * @param[IN]  :cmd: dcs command
 * @param[OUT] :result: pointer of read result,larger then max ret size
 * @param[OUT] :num_p: number of bytes have been readed
 * @return     :number of bytes have been readed
 */
s32 sunxi_lcd_dsi_dcs_read(u32 sel, u8 cmd, u8 *result, u32 *num_p)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_dsi_dcs_read)
       return g_lcd_drv.src_ops.sunxi_lcd_dsi_dcs_read(sel, cmd,
                               result, num_p);
   return 0;
}
 
/**
 * sunxi_lcd_dsi_gen_short_read0p - generic read without param
 * @screen_id: The index of screen.
 * @paran: Para to be transfer.
 * @result: pointer that store the result
 */
s32 sunxi_lcd_dsi_gen_short_read0p(u32 screen_id, u8 *result)
{
   u8 tmp[2];
 
   return sunxi_lcd_dsi_gen_short_read(screen_id, tmp, 0, result);
}
 
/**
 * sunxi_lcd_dsi_gen_short_read1p - generic read with 1 param
 * @screen_id: The index of screen.
 * @paran: Para to be transfer.
 * @result: pointer that store the result
 */
s32 sunxi_lcd_dsi_gen_short_read1p(u32 screen_id, u8 para0, u8 *result)
{
   u8 tmp[2];
 
   tmp[0] = para0;
   sunxi_lcd_dsi_gen_short_read(screen_id,  tmp, 1, result);
 
   return -1;
}
 
/**
 * sunxi_lcd_dsi_gen_short_read2p - generic read with 2 param
 * @screen_id: The index of screen.
 * @paran: Para to be transfer.
 * @result: pointer that store the result
 */
s32 sunxi_lcd_dsi_gen_short_read2p(u32 screen_id, u8 para0, u8 para1,
                  u8 *result)
{
   u8 tmp[2];
 
   tmp[0] = para0;
   tmp[1] = para1;
   return sunxi_lcd_dsi_gen_short_read(screen_id, tmp, 2, result);
}
 
/**
 * sunxi_lcd_set_panel_funs -  set panel functions.
 * @name: The panel driver name.
 * @lcd_cfg: The functions.
 */
s32 sunxi_lcd_set_panel_funs(char *name, struct disp_lcd_panel_fun *lcd_cfg)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_set_panel_funs)
       return g_lcd_drv.src_ops.sunxi_lcd_set_panel_funs(name,
                                 lcd_cfg);
 
   return -1;
}
 
/**
 * sunxi_lcd_pin_cfg - config pin panel used
 * @screen_id: The index of screen.
 * @bon:     1: config pin according to sys_config, 0: set disable state
 */
s32 sunxi_lcd_pin_cfg(u32 screen_id, u32 bon)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_pin_cfg)
       return g_lcd_drv.src_ops.sunxi_lcd_pin_cfg(screen_id, bon);
 
   return -1;
}
 
/**
 * sunxi_lcd_gpio_set_value
 * @screen_id: The index of screen.
 * @io_index:  the index of gpio
 * @value: value of gpio to be set
 */
s32 sunxi_lcd_gpio_set_value(u32 screen_id, u32 io_index, u32 value)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_gpio_set_value)
       return g_lcd_drv.src_ops.sunxi_lcd_gpio_set_value(screen_id,
                                 io_index,
                                 value);
 
   return -1;
}
 
/**
 * sunxi_lcd_gpio_set_direction
 * @screen_id: The index of screen.
 * @io_index:  the index of gpio
 * @direct: value of gpio to be set
 */
s32 sunxi_lcd_gpio_set_direction(u32 screen_id, u32 io_index, u32 direct)
{
   if (g_lcd_drv.src_ops.sunxi_lcd_gpio_set_direction)
       return g_lcd_drv.src_ops.sunxi_lcd_gpio_set_direction(screen_id,
                                     io_index,
                                     direct);
 
   return -1;
}