lin
2025-01-10 2e0fe69425adee0529756dc3381ac1838197f3ac
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
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
/*
 * disp2/disp/de/disp_enhance.c
 *
 * Copyright (c) 2007-2019 Allwinnertech Co., Ltd.
 * Author: zhengxiaobin <zhengxiaobin@allwinnertech.com>
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */
#if defined(CONFIG_DISP2_SUNXI_SUPPORT_ENAHNCE)
#include "disp_enhance.h"
 
struct disp_enhance_private_data
{
   u32                       reg_base;
   u32                       enabled;
   bool                      applied;
 
   struct disp_enhance_config config;
 
   s32 (*shadow_protect)(u32 sel, bool protect);
};
static spinlock_t enhance_data_lock;
 
static struct disp_enhance *enhances = NULL;
static struct disp_enhance_private_data *enhance_private;
 
struct disp_enhance* disp_get_enhance(u32 disp)
{
   u32 num_screens;
 
   num_screens = bsp_disp_feat_get_num_screens();
   if (disp >= num_screens) {
       DE_WRN("disp %d out of range\n", disp);
       return NULL;
   }
 
   return &enhances[disp];
}
 
static struct disp_enhance_private_data *disp_enhance_get_priv(struct disp_enhance *enhance)
{
   if (NULL == enhance) {
       DE_INF("NULL hdl!\n");
       return NULL;
   }
 
   return &enhance_private[enhance->disp];
}
 
static s32 disp_enhance_sync(struct disp_enhance* enhance)
{
   struct disp_enhance_private_data *enhancep = disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   enhance->update_regs(enhance);
   if (enhancep->enabled)
   {
       disp_al_enhance_sync(enhance->disp);
   }
 
   return 0;
}
 
static s32 disp_enhance_tasklet(struct disp_enhance* enhance)
{
   //unsigned long flags;
   struct disp_enhance_private_data *enhancep = disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   if (enhancep->enabled)
   {
       disp_al_enhance_tasklet(enhance->disp);
   }
 
   return 0;
}
 
static s32 disp_enhance_update_regs(struct disp_enhance* enhance)
{
   unsigned long flags;
   struct disp_enhance_private_data *enhancep = disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   /* size likely change while it depend on layer size */
   //if (enhancep->applied) {
   {
       //DE_INF("enhance %d, enable=%d\n", enhance->disp, enhancep->config.info.enable);
       disp_al_enhance_update_regs(enhance->disp);
   }
 
   spin_lock_irqsave(&enhance_data_lock, flags);
   enhancep->applied = false;
   spin_unlock_irqrestore(&enhance_data_lock, flags);
 
   return 0;
}
 
static s32 disp_enhance_apply(struct disp_enhance* enhance)
{
   unsigned long flags;
   struct disp_enhance_private_data *enhancep = disp_enhance_get_priv(enhance);
   struct disp_enhance_config config;
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
   DE_INF("disp_enhance_apply, screen %d\n", enhance->disp);
   memset(&config, 0, sizeof(struct disp_enhance_config));
   spin_lock_irqsave(&enhance_data_lock, flags);
   if (0 != enhancep->config.flags) {
       memcpy(&config, &enhancep->config, sizeof(struct disp_enhance_config));
       enhancep->applied = true;
   }
   spin_unlock_irqrestore(&enhance_data_lock, flags);
 
   if (ENH_NONE_DIRTY != config.flags) {
       disp_enhance_shadow_protect(enhance, 1);
       disp_al_enhance_apply(enhance->disp, &config);
       disp_enhance_shadow_protect(enhance, 0);
   }
 
   spin_lock_irqsave(&enhance_data_lock, flags);
   if (0 != config.flags)
       enhancep->applied = true;
   enhancep->config.flags = ENH_NONE_DIRTY;
   spin_unlock_irqrestore(&enhance_data_lock, flags);
 
   return 0;
}
 
static s32 disp_enhance_force_apply(struct disp_enhance* enhance)
{
   unsigned long flags;
   struct disp_enhance_private_data *enhancep = disp_enhance_get_priv(enhance);
   struct disp_device *dispdev = NULL;
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
   if (enhance->manager)
       dispdev = enhance->manager->device;
   if (dispdev)
       dispdev->get_resolution(dispdev, &enhancep->config.info.size.width,
           &enhancep->config.info.size.height);
 
   spin_lock_irqsave(&enhance_data_lock, flags);
   enhancep->config.flags |= ENH_ALL_DIRTY;
   spin_unlock_irqrestore(&enhance_data_lock, flags);
   disp_enhance_apply(enhance);
   disp_enhance_update_regs(enhance);
   disp_enhance_sync(enhance);
 
   return 0;
}
 
/* seem no meaning */
static bool disp_enhance_is_enabled(struct disp_enhance* enhance)
{
   struct disp_enhance_private_data *enhancep = disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return false;
   }
 
   return enhancep->enabled;
}
 
static s32 disp_enhance_enable(struct disp_enhance* enhance)
{
   unsigned long flags;
   struct disp_enhance_private_data *enhancep = disp_enhance_get_priv(enhance);
   struct disp_device *dispdev = NULL;
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
   if (enhance->manager)
       dispdev = enhance->manager->device;
   if (dispdev) {
       dispdev->get_resolution(dispdev, &enhancep->config.info.size.width,
           &enhancep->config.info.size.height);
       if (DISP_OUTPUT_TYPE_HDMI == dispdev->type)
           enhancep->config.info.mode = (enhancep->config.info.mode & 0xffff0000)  | (1); //hdmi
       else
           enhancep->config.info.mode = (enhancep->config.info.mode & 0xffff0000)  | (0); //lcd
   }
 
   spin_lock_irqsave(&enhance_data_lock, flags);
   enhancep->config.info.enable = 1;
   enhancep->config.flags |= ENH_ENABLE_DIRTY | ENH_SIZE_DIRTY;
 
   if ((0 == enhancep->config.info.window.width) || (0 == enhancep->config.info.window.height)) {
       enhancep->config.info.window.width = enhancep->config.info.size.width;
       enhancep->config.info.window.height = enhancep->config.info.size.height;
   }
 
   enhancep->enabled = 1;
   spin_unlock_irqrestore(&enhance_data_lock, flags);
 
   disp_enhance_apply(enhance);
   return 0;
}
 
static s32 disp_enhance_disable(struct disp_enhance* enhance)
{
   unsigned long flags;
   struct disp_enhance_private_data *enhancep = disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   spin_lock_irqsave(&enhance_data_lock, flags);
   enhancep->config.info.enable = 0;
   enhancep->config.flags |= ENH_ENABLE_DIRTY;
 
   enhancep->enabled = 0;
   spin_unlock_irqrestore(&enhance_data_lock, flags);
 
   disp_enhance_apply(enhance);
 
   return 0;
}
 
static s32 disp_enhance_demo_enable(struct disp_enhance* enhance)
{
   unsigned long flags;
   struct disp_enhance_private_data *enhancep = disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   spin_lock_irqsave(&enhance_data_lock, flags);
   enhancep->config.info.demo_enable = 1;
   spin_unlock_irqrestore(&enhance_data_lock, flags);
 
   disp_enhance_apply(enhance);
   return 0;
}
 
static s32 disp_enhance_demo_disable(struct disp_enhance* enhance)
{
   unsigned long flags;
   struct disp_enhance_private_data *enhancep = disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   spin_lock_irqsave(&enhance_data_lock, flags);
   enhancep->config.info.demo_enable = 0;
   spin_unlock_irqrestore(&enhance_data_lock, flags);
 
   disp_enhance_apply(enhance);
   return 0;
}
 
static s32 disp_enhance_set_mode(struct disp_enhance* enhance, u32 mode)
{
   unsigned long flags;
   struct disp_enhance_private_data *enhancep = disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   spin_lock_irqsave(&enhance_data_lock, flags);
   enhancep->config.info.mode = (enhancep->config.info.mode & 0xffff)  | (mode << 16);
   enhancep->config.flags |= ENH_MODE_DIRTY;
   spin_unlock_irqrestore(&enhance_data_lock, flags);
 
   disp_enhance_apply(enhance);
   return 0;
}
 
static s32 disp_enhance_get_mode(struct disp_enhance* enhance)
{
   struct disp_enhance_private_data *enhancep = disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return 0;
   }
 
   return enhancep->config.info.mode >> 16;
}
 
static s32 disp_enhance_set_bright(struct disp_enhance *enhance, u32 value)
{
   unsigned long flags;
   struct disp_enhance_private_data *enhancep =
       disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   spin_lock_irqsave(&enhance_data_lock, flags);
   enhancep->config.info.bright = value;
   enhancep->config.flags |= ENH_BRIGHT_DIRTY;
   spin_unlock_irqrestore(&enhance_data_lock, flags);
 
   disp_enhance_apply(enhance);
 
   return 0;
}
 
static s32 disp_enhance_get_bright(struct disp_enhance *enhance)
{
   struct disp_enhance_private_data *enhancep =
       disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return 0;
   }
 
   return enhancep->config.info.bright;
}
 
static s32 disp_enhance_set_saturation(struct disp_enhance *enhance, u32 value)
{
   unsigned long flags;
   struct disp_enhance_private_data *enhancep =
       disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   spin_lock_irqsave(&enhance_data_lock, flags);
   enhancep->config.info.saturation = value;
   enhancep->config.flags |= ENH_SAT_DIRTY;
   spin_unlock_irqrestore(&enhance_data_lock, flags);
 
   disp_enhance_apply(enhance);
 
   return 0;
}
 
static s32 disp_enhance_get_saturation(struct disp_enhance *enhance)
{
   struct disp_enhance_private_data *enhancep =
       disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return 0;
   }
 
   return enhancep->config.info.saturation;
}
 
static s32 disp_enhance_set_contrast(struct disp_enhance *enhance, u32 value)
{
   unsigned long flags;
   struct disp_enhance_private_data *enhancep =
       disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   spin_lock_irqsave(&enhance_data_lock, flags);
   enhancep->config.info.contrast = value;
   enhancep->config.flags |= ENH_CONTRAST_DIRTY;
   spin_unlock_irqrestore(&enhance_data_lock, flags);
 
   disp_enhance_apply(enhance);
 
   return 0;
}
 
static s32 disp_enhance_get_contrast(struct disp_enhance *enhance)
{
   struct disp_enhance_private_data *enhancep =
       disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return 0;
   }
 
   return enhancep->config.info.contrast;
}
 
static s32 disp_enhance_set_edge(struct disp_enhance *enhance, u32 value)
{
   unsigned long flags;
   struct disp_enhance_private_data *enhancep =
       disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   spin_lock_irqsave(&enhance_data_lock, flags);
   enhancep->config.info.edge = value;
   enhancep->config.flags |= ENH_EDGE_DIRTY;
   spin_unlock_irqrestore(&enhance_data_lock, flags);
 
   disp_enhance_apply(enhance);
 
   return 0;
}
 
static s32 disp_enhance_get_edge(struct disp_enhance *enhance)
{
   struct disp_enhance_private_data *enhancep =
       disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return 0;
   }
 
   return enhancep->config.info.edge;
}
 
static s32 disp_enhance_set_detail(struct disp_enhance *enhance, u32 value)
{
   unsigned long flags;
   struct disp_enhance_private_data *enhancep =
       disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   spin_lock_irqsave(&enhance_data_lock, flags);
   enhancep->config.info.detail = value;
   enhancep->config.flags |= ENH_DETAIL_DIRTY;
   spin_unlock_irqrestore(&enhance_data_lock, flags);
 
   disp_enhance_apply(enhance);
 
   return 0;
}
 
static s32 disp_enhance_get_detail(struct disp_enhance *enhance)
{
   struct disp_enhance_private_data *enhancep =
       disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return 0;
   }
 
   return enhancep->config.info.detail;
}
 
static s32 disp_enhance_set_denoise(struct disp_enhance *enhance, u32 value)
{
   unsigned long flags;
   struct disp_enhance_private_data *enhancep =
       disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   spin_lock_irqsave(&enhance_data_lock, flags);
   enhancep->config.info.denoise = value;
   enhancep->config.flags |= ENH_DNS_DIRTY;
   spin_unlock_irqrestore(&enhance_data_lock, flags);
 
   disp_enhance_apply(enhance);
 
   return 0;
}
 
static s32 disp_enhance_get_denoise(struct disp_enhance *enhance)
{
   struct disp_enhance_private_data *enhancep =
       disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return 0;
   }
 
   return enhancep->config.info.denoise;
}
 
static s32 disp_enhance_set_manager(struct disp_enhance* enhance, struct disp_manager *mgr)
{
   unsigned long flags;
   if ((NULL == enhance) || (NULL == mgr)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   spin_lock_irqsave(&enhance_data_lock, flags);
   enhance->manager = mgr;
   mgr->enhance = enhance;
   spin_unlock_irqrestore(&enhance_data_lock, flags);
 
   return 0;
}
 
static s32 disp_enhance_unset_manager(struct disp_enhance* enhance)
{
   unsigned long flags;
   if ((NULL == enhance)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   spin_lock_irqsave(&enhance_data_lock, flags);
   if (enhance->manager)
       enhance->manager->enhance = NULL;
   enhance->manager = NULL;
   spin_unlock_irqrestore(&enhance_data_lock, flags);
 
   return 0;
}
 
 
static s32 disp_enhance_shadow_protect(struct disp_enhance *enhance, bool protect)
{
   struct disp_enhance_private_data *enhancep = disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   if (enhancep->shadow_protect)
       return enhancep->shadow_protect(enhance->disp, protect);
 
   return -1;
}
 
static s32 disp_enhance_dump(struct disp_enhance *enhance, char* buf)
{
   struct disp_enhance_config config;
   struct disp_enhance_private_data *enhancep = disp_enhance_get_priv(enhance);
   u32 count = 0;
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   memcpy(&config, &enhancep->config, sizeof(struct disp_enhance_config));
 
   count += sprintf(buf + count, "enhance %d: %s, %s\n",
       enhance->disp, (config.info.enable==1)?"enable":"disable",
       (config.info.demo_enable==1)?"demo":"normal");
 
   return count;
}
 
static s32 disp_enhance_init(struct disp_enhance *enhance)
{
   struct disp_enhance_private_data *enhancep = disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   return 0;
}
 
static s32 disp_enhance_exit(struct disp_enhance *enhance)
{
   struct disp_enhance_private_data *enhancep = disp_enhance_get_priv(enhance);
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
 
   return 0;
}
 
//for inner debug
s32 disp_enhance_set_para(struct disp_enhance* enhance, disp_enhance_para *para)
{
   unsigned long flags;
   struct disp_enhance_private_data *enhancep = disp_enhance_get_priv(enhance);
   struct disp_device *dispdev = NULL;
 
   if ((NULL == enhance) || (NULL == enhancep)) {
       DE_INF("NULL hdl!\n");
       return -1;
   }
   if (enhance->manager)
       dispdev = enhance->manager->device;
   if (dispdev)
       dispdev->get_resolution(dispdev, &enhancep->config.info.size.width,
           &enhancep->config.info.size.height);
 
   spin_lock_irqsave(&enhance_data_lock, flags);
   memcpy(&enhancep->config.info.window, &para->window, sizeof(struct disp_rect));
   enhancep->config.info.enable = para->enable;
   enhancep->config.flags |= ENH_ENABLE_DIRTY | ENH_SIZE_DIRTY;
 
   if ((0 == enhancep->config.info.window.width) || (0 == enhancep->config.info.window.height)) {
       enhancep->config.info.window.width = enhancep->config.info.size.width;
       enhancep->config.info.window.height = enhancep->config.info.size.height;
   }
 
 
   enhancep->config.info.bright = para->bright;
   enhancep->config.info.contrast= para->contrast;
   enhancep->config.info.saturation= para->saturation;
   enhancep->config.info.hue = para->hue;
   enhancep->config.info.sharp = para->sharp;
   enhancep->config.info.auto_contrast = para->auto_contrast;
 
   enhancep->config.info.auto_color = para->auto_color;
   enhancep->config.info.fancycolor_red = para->fancycolor_red;
   enhancep->config.info.fancycolor_blue = para->fancycolor_blue;
   enhancep->config.info.fancycolor_green = para->fancycolor_green;
 
   enhancep->enabled = para->enable;
   spin_unlock_irqrestore(&enhance_data_lock, flags);
   DE_INF("en=%d, para=<%d,%d,%d,%d>, sharp=%d, auto_para=<%d,%d>, fancycolor=<%d,%d,%d>\n", enhancep->config.info.enable,
   enhancep->config.info.bright,enhancep->config.info.contrast,
   enhancep->config.info.saturation, enhancep->config.info.hue,
   enhancep->config.info.sharp, enhancep->config.info.auto_color,
   enhancep->config.info.auto_contrast, enhancep->config.info.fancycolor_red,
   enhancep->config.info.fancycolor_green, enhancep->config.info.fancycolor_blue);
 
   disp_enhance_apply(enhance);
   return 0;
}
 
s32 disp_init_enhance(disp_bsp_init_para * para)
{
   u32 num_enhances;
   u32 disp;
   struct disp_enhance *enhance;
   struct disp_enhance_private_data *enhancep;
 
   DE_INF("disp_init_enhance\n");
 
   spin_lock_init(&enhance_data_lock);
   num_enhances = bsp_disp_feat_get_num_screens();//bsp_disp_feat_get_num_smart_backlights();
   enhances = (struct disp_enhance *)kmalloc(sizeof(struct disp_enhance) * num_enhances, GFP_KERNEL | __GFP_ZERO);
   if (NULL == enhances) {
       DE_WRN("malloc memory fail!\n");
       return DIS_FAIL;
   }
   enhance_private = (struct disp_enhance_private_data *)kmalloc(sizeof(struct disp_enhance_private_data)\
       * num_enhances, GFP_KERNEL | __GFP_ZERO);
   if (NULL == enhance_private) {
       DE_WRN("malloc memory fail!\n");
       return DIS_FAIL;
   }
 
   for (disp=0; disp<num_enhances; disp++) {
       enhance = &enhances[disp];
       enhancep = &enhance_private[disp];
 
       switch(disp) {
       case 0:
           enhance->name = "enhance0";
           enhance->disp = 0;
           break;
       case 1:
           enhance->name = "enhance1";
           enhance->disp = 1;
           break;
       case 2:
           enhance->name = "enhance2";
           enhance->disp = 2;
 
           break;
       }
       enhancep->shadow_protect = para->shadow_protect;
 
       enhance->enable = disp_enhance_enable;
       enhance->disable = disp_enhance_disable;
       enhance->is_enabled = disp_enhance_is_enabled;
       enhance->init = disp_enhance_init;
       enhance->exit = disp_enhance_exit;
       enhance->apply = disp_enhance_apply;
       enhance->update_regs = disp_enhance_update_regs;
       enhance->force_apply = disp_enhance_force_apply;
       enhance->sync = disp_enhance_sync;
       enhance->tasklet = disp_enhance_tasklet;
       enhance->set_manager = disp_enhance_set_manager;
       enhance->unset_manager = disp_enhance_unset_manager;
       enhance->set_para = disp_enhance_set_para;
       enhance->dump = disp_enhance_dump;
       enhance->demo_enable = disp_enhance_demo_enable;
       enhance->demo_disable = disp_enhance_demo_disable;
       enhance->set_mode = disp_enhance_set_mode;
       enhance->get_mode = disp_enhance_get_mode;
       enhance->set_bright = disp_enhance_set_bright;
       enhance->get_bright = disp_enhance_get_bright;
       enhance->set_saturation = disp_enhance_set_saturation;
       enhance->get_saturation = disp_enhance_get_saturation;
       enhance->set_contrast = disp_enhance_set_contrast;
       enhance->get_contrast = disp_enhance_get_contrast;
       enhance->set_edge = disp_enhance_set_edge;
       enhance->get_edge = disp_enhance_get_edge;
       enhance->set_detail = disp_enhance_set_detail;
       enhance->get_detail = disp_enhance_get_detail;
       enhance->set_denoise = disp_enhance_set_denoise;
       enhance->get_denoise = disp_enhance_get_denoise;
 
       enhance->init(enhance);
   }
 
   return 0;
}
#endif