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
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
|
/* linux/drivers/video/exynos_decon/panel/lcd_sysfs.c
*
* Header file for Samsung MIPI-DSI Panel SYSFS driver.
*
* Copyright (c) 2013 Samsung Electronics
* JiHoon Kim <jihoonn.kim@samsung.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/lcd.h>
#include "../dsim.h"
#include "dsim_panel.h"
#include "panel_info.h"
#include "dsim_backlight.h"
#include "../decon.h"
#ifdef CONFIG_FB_DSU
#include <linux/sec_debug.h>
#endif
#if defined(CONFIG_EXYNOS_DECON_MDNIE_LITE)
#include "mdnie.h"
#endif
enum weakness_hbm_state {
W_HBM_GALLERY = 0,
W_HBM_OFF = 1
};
#define W_HBM_STEP (5)
#if defined(CONFIG_SEC_FACTORY) && defined(CONFIG_EXYNOS_DECON_LCD_MCD)
#ifdef CONFIG_PANEL_S6E3HF3_DYNAMIC // only edge panel
void mcd_mode_set(struct dsim_device *dsim)
{
struct panel_private *panel = &dsim->priv;
dsim_write_hl_data(dsim, SEQ_TEST_KEY_ON_F0, ARRAY_SIZE(SEQ_TEST_KEY_ON_F0));
if(panel->mcd_on == 0) // mcd_off
{
pr_info("%s MCD off : %d\n", __func__, panel->mcd_on);
dsim_write_hl_data(dsim, SEQ_MCD_OFF_SET1, ARRAY_SIZE(SEQ_MCD_OFF_SET1));
dsim_write_hl_data(dsim, SEQ_MCD_OFF_SET2, ARRAY_SIZE(SEQ_MCD_OFF_SET2));
dsim_write_hl_data(dsim, SEQ_MCD_OFF_SET3, ARRAY_SIZE(SEQ_MCD_OFF_SET3));
dsim_write_hl_data(dsim, SEQ_GAMMA_UPDATE, ARRAY_SIZE(SEQ_GAMMA_UPDATE));
dsim_write_hl_data(dsim, SEQ_MCD_OFF_SET4, ARRAY_SIZE(SEQ_MCD_OFF_SET4));
} else { // mcd on
pr_info("%s MCD on : %d\n", __func__, panel->mcd_on);
dsim_write_hl_data(dsim, SEQ_MCD_ON_SET1, ARRAY_SIZE(SEQ_MCD_ON_SET1));
dsim_write_hl_data(dsim, SEQ_MCD_ON_SET2, ARRAY_SIZE(SEQ_MCD_ON_SET2));
dsim_write_hl_data(dsim, SEQ_MCD_ON_SET3, ARRAY_SIZE(SEQ_MCD_ON_SET3));
dsim_write_hl_data(dsim, SEQ_GAMMA_UPDATE, ARRAY_SIZE(SEQ_GAMMA_UPDATE));
dsim_write_hl_data(dsim, SEQ_MCD_ON_SET4, ARRAY_SIZE(SEQ_MCD_ON_SET4));
}
dsim_write_hl_data(dsim, SEQ_TEST_KEY_OFF_F0, ARRAY_SIZE(SEQ_TEST_KEY_OFF_F0));
}
#else
void mcd_mode_set(struct dsim_device *dsim)
{
int i = 0;
struct panel_private *panel = &dsim->priv;
dsim_write_hl_data(dsim, SEQ_TEST_KEY_ON_F0, ARRAY_SIZE(SEQ_TEST_KEY_ON_F0));
dsim_write_hl_data(dsim, SEQ_TEST_KEY_ON_F1, ARRAY_SIZE(SEQ_TEST_KEY_ON_F1));
dsim_write_hl_data(dsim, SEQ_TEST_KEY_ON_FC, ARRAY_SIZE(SEQ_TEST_KEY_ON_FC));
if(panel->mcd_on == 0) // mcd_off
{
pr_info("%s MCD off : %d\n", __func__, panel->mcd_on);
for(i = 0; i < (sizeof(SEQ_MCD_OFF_SET1) / sizeof(SEQ_MCD_OFF_SET1[0])); i++)
dsim_write_hl_data(dsim, SEQ_MCD_OFF_SET1[i], ARRAY_SIZE(SEQ_MCD_OFF_SET1[i]));
dsim_write_hl_data(dsim, SEQ_GAMMA_UPDATE, ARRAY_SIZE(SEQ_GAMMA_UPDATE));
msleep(100);
for(i = 0; i < (sizeof(SEQ_MCD_OFF_SET2) / sizeof(SEQ_MCD_OFF_SET2[0])); i++)
dsim_write_hl_data(dsim, SEQ_MCD_OFF_SET2[i], ARRAY_SIZE(SEQ_MCD_OFF_SET2[i]));
} else { // mcd on
pr_info("%s MCD on : %d\n", __func__, panel->mcd_on);
for(i = 0; i < (sizeof(SEQ_MCD_ON_SET1) / sizeof(SEQ_MCD_ON_SET1[0])); i++)
dsim_write_hl_data(dsim, SEQ_MCD_ON_SET1[i], ARRAY_SIZE(SEQ_MCD_ON_SET1[i]));
dsim_write_hl_data(dsim, SEQ_GAMMA_UPDATE, ARRAY_SIZE(SEQ_GAMMA_UPDATE));
msleep(100);
for(i = 0; i < (sizeof(SEQ_MCD_ON_SET2) / sizeof(SEQ_MCD_ON_SET2[0])); i++)
dsim_write_hl_data(dsim, SEQ_MCD_ON_SET2[i], ARRAY_SIZE(SEQ_MCD_ON_SET2[i]));
}
dsim_write_hl_data(dsim, SEQ_TEST_KEY_OFF_FC, ARRAY_SIZE(SEQ_TEST_KEY_OFF_FC));
dsim_write_hl_data(dsim, SEQ_TEST_KEY_OFF_F1, ARRAY_SIZE(SEQ_TEST_KEY_OFF_F1));
dsim_write_hl_data(dsim, SEQ_TEST_KEY_OFF_F0, ARRAY_SIZE(SEQ_TEST_KEY_OFF_F0));
}
#endif
static ssize_t mcd_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_private *priv = dev_get_drvdata(dev);
sprintf(buf, "%u\n", priv->mcd_on);
return strlen(buf);
}
static ssize_t mcd_mode_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct dsim_device *dsim;
struct panel_private *priv = dev_get_drvdata(dev);
int value;
int rc;
dsim = container_of(priv, struct dsim_device, priv);
rc = kstrtouint(buf, (unsigned int)0, &value);
if (rc < 0)
return rc;
if ((priv->state == PANEL_STATE_RESUMED) && (priv->mcd_on != value)) {
priv->mcd_on = value;
mcd_mode_set(dsim);
}
dev_info(dev, "%s: %d\n", __func__, priv->mcd_on);
return size;
}
static DEVICE_ATTR(mcd_mode, 0664, mcd_mode_show, mcd_mode_store);
#endif
#ifdef CONFIG_LCD_HMT
#if defined(CONFIG_PANEL_S6E3HF2_DYNAMIC)
static struct lcd_seq_info SEQ_HMT_AID_FORWARD_SET[] = {
{(u8 *)SEQ_HMT_AID_FORWARD1, ARRAY_SIZE(SEQ_HMT_AID_FORWARD1), 0},
{(u8 *)SEQ_HMT_AID_FORWARD2, ARRAY_SIZE(SEQ_HMT_AID_FORWARD2), 0},
};
static struct lcd_seq_info SEQ_HMT_REVERSE_SET[] = {
{(u8 *)SEQ_HMT_AID_REVERSE1, ARRAY_SIZE(SEQ_HMT_AID_REVERSE1), 0},
{(u8 *)SEQ_HMT_AID_REVERSE2, ARRAY_SIZE(SEQ_HMT_AID_REVERSE2), 0},
};
static struct lcd_seq_info SEQ_HMT_ON_SET[] = {
{(u8 *)SEQ_HMT_ON1, ARRAY_SIZE(SEQ_HMT_ON1), 0},
{(u8 *)SEQ_HMT_ON2, ARRAY_SIZE(SEQ_HMT_ON2), 0},
{(u8 *)SEQ_HMT_ON3, ARRAY_SIZE(SEQ_HMT_ON3), 0},
};
static struct lcd_seq_info SEQ_HMT_OFF_SET[] = {
{(u8 *)SEQ_HMT_OFF1, ARRAY_SIZE(SEQ_HMT_OFF1), 0},
};
#elif defined(CONFIG_PANEL_S6E3HA2_DYNAMIC)
static struct lcd_seq_info SEQ_HMT_AID_FORWARD_SET[] = {
{(u8 *)SEQ_HMT_AID_FORWARD1, ARRAY_SIZE(SEQ_HMT_AID_FORWARD1), 0},
{(u8 *)SEQ_HMT_AID_FORWARD2, ARRAY_SIZE(SEQ_HMT_AID_FORWARD2), 0},
};
static struct lcd_seq_info SEQ_HMT_REVERSE_SET[] = {
{(u8 *)SEQ_HMT_AID_REVERSE1, ARRAY_SIZE(SEQ_HMT_AID_REVERSE1), 0},
{(u8 *)SEQ_HMT_AID_REVERSE2, ARRAY_SIZE(SEQ_HMT_AID_REVERSE2), 0},
};
static struct lcd_seq_info SEQ_HMT_ON_SET[] = {
{(u8 *)SEQ_HMT_ON1, ARRAY_SIZE(SEQ_HMT_ON1), 0},
{(u8 *)SEQ_HMT_ON2, ARRAY_SIZE(SEQ_HMT_ON2), 0},
{(u8 *)SEQ_HMT_ON3, ARRAY_SIZE(SEQ_HMT_ON3), 0},
};
static struct lcd_seq_info SEQ_HMT_OFF_SET[] = {
{(u8 *)SEQ_HMT_OFF1, ARRAY_SIZE(SEQ_HMT_OFF1), 0},
{(u8 *)SEQ_HMT_OFF2, ARRAY_SIZE(SEQ_HMT_OFF2), 0},
};
#elif defined(CONFIG_PANEL_S6E3HF3_DYNAMIC) || defined(CONFIG_PANEL_S6E3HA3_DYNAMIC)
static struct lcd_seq_info SEQ_HMT_AID_FORWARD_SET[] = {
{(u8 *)SEQ_HMT_AID_FORWARD1, ARRAY_SIZE(SEQ_HMT_AID_FORWARD1), 0},
};
static struct lcd_seq_info SEQ_HMT_REVERSE_SET[] = {
{(u8 *)SEQ_HMT_AID_REVERSE1, ARRAY_SIZE(SEQ_HMT_AID_REVERSE1), 0},
};
static struct lcd_seq_info SEQ_HMT_ON_SET[] = {
{(u8 *)SEQ_HMT_ON1, ARRAY_SIZE(SEQ_HMT_ON1), 0},
};
static struct lcd_seq_info SEQ_HMT_OFF_SET[] = {
{(u8 *)SEQ_HMT_OFF1, ARRAY_SIZE(SEQ_HMT_OFF1), 0},
};
#endif
static ssize_t hmt_brightness_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_private *priv = dev_get_drvdata(dev);
sprintf(buf, "index : %d, brightenss : %d\n", priv->hmt_br_index, priv->hmt_brightness);
return strlen(buf);
}
static ssize_t hmt_brightness_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct dsim_device *dsim;
struct panel_private *priv = dev_get_drvdata(dev);
int value;
int rc;
dsim = container_of(priv, struct dsim_device, priv);
rc = kstrtouint(buf, (unsigned int)0, &value);
if (rc < 0)
return rc;
if (priv->state != PANEL_STATE_RESUMED) {
dev_info(dev, "%s: panel is off\n", __func__);
return -EINVAL;
}
if (priv->hmt_on == HMT_OFF) {
dev_info(dev, "%s: hmt is not on\n", __func__);
return -EINVAL;
}
if (priv->hmt_brightness != value) {
mutex_lock(&priv->lock);
priv->hmt_brightness = value;
mutex_unlock(&priv->lock);
dsim_panel_set_brightness_for_hmt(dsim, 0);
}
dev_info(dev, "%s: %d\n", __func__, value);
return size;
}
static int hmt_write_set(struct dsim_device *dsim, struct lcd_seq_info *seq, u32 num)
{
int ret = 0, i;
for (i = 0; i < num; i++) {
if (seq[i].cmd) {
ret = dsim_write_hl_data(dsim, seq[i].cmd, seq[i].len);
if (ret != 0) {
dsim_err("%s failed.\n", __func__);
return ret;
}
}
if (seq[i].sleep)
usleep_range(seq[i].sleep * 1000 , seq[i].sleep * 1000);
}
return ret;
}
int hmt_set_mode(struct dsim_device *dsim, bool wakeup)
{
struct panel_private *priv = &(dsim->priv);
mutex_lock(&priv->lock);
dsim_write_hl_data(dsim, SEQ_TEST_KEY_ON_F0, ARRAY_SIZE(SEQ_TEST_KEY_ON_F0));
dsim_write_hl_data(dsim, SEQ_TEST_KEY_ON_FC, ARRAY_SIZE(SEQ_TEST_KEY_ON_FC));
if(priv->hmt_on == HMT_ON) {
// on set
hmt_write_set(dsim, SEQ_HMT_ON_SET, ARRAY_SIZE(SEQ_HMT_ON_SET));
hmt_write_set(dsim, SEQ_HMT_REVERSE_SET, ARRAY_SIZE(SEQ_HMT_REVERSE_SET));
if(wakeup) {
dsim_write_hl_data(dsim, SEQ_GAMMA_UPDATE, ARRAY_SIZE(SEQ_GAMMA_UPDATE));
dsim_write_hl_data(dsim, SEQ_GAMMA_UPDATE_L, ARRAY_SIZE(SEQ_GAMMA_UPDATE_L));
msleep(120);
}
} else if(priv->hmt_on == HMT_OFF) {
// off set
hmt_write_set(dsim, SEQ_HMT_OFF_SET, ARRAY_SIZE(SEQ_HMT_OFF_SET));
hmt_write_set(dsim, SEQ_HMT_AID_FORWARD_SET, ARRAY_SIZE(SEQ_HMT_AID_FORWARD_SET));
} else {
pr_info("hmt state is invalid %d !\n", priv->hmt_on);
}
dsim_write_hl_data(dsim, SEQ_TEST_KEY_OFF_F0, ARRAY_SIZE(SEQ_TEST_KEY_OFF_F0));
dsim_write_hl_data(dsim, SEQ_TEST_KEY_OFF_FC, ARRAY_SIZE(SEQ_TEST_KEY_OFF_FC));
mutex_unlock(&priv->lock);
if(priv->hmt_on == HMT_ON)
dsim_panel_set_brightness_for_hmt(dsim, 1);
else if (priv->hmt_on == HMT_OFF)
dsim_panel_set_brightness(dsim, 1);
else ;
return 0;
}
static ssize_t hmt_on_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_private *priv = dev_get_drvdata(dev);
sprintf(buf, "%u\n", priv->hmt_on);
return strlen(buf);
}
static ssize_t hmt_on_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct dsim_device *dsim;
struct panel_private *priv = dev_get_drvdata(dev);
int value;
int rc;
dsim = container_of(priv, struct dsim_device, priv);
rc = kstrtoint(buf, 0, &value);
if (rc < 0)
return rc;
if (priv->state != PANEL_STATE_RESUMED) {
dev_info(dev, "%s: panel is off\n", __func__);
return -EINVAL;
}
if (priv->hmt_on != value) {
mutex_lock(&priv->lock);
priv->hmt_on = value;
mutex_unlock(&priv->lock);
dev_info(dev, "++%s: %d\n", __func__, priv->hmt_on);
hmt_set_mode(dsim, false);
dev_info(dev, "--%s: %d\n", __func__, priv->hmt_on);
} else
dev_info(dev, "%s: hmt already %s\n", __func__, value ? "on" : "off");
return size;
}
static DEVICE_ATTR(hmt_bright, 0664, hmt_brightness_show, hmt_brightness_store);
static DEVICE_ATTR(hmt_on, 0664, hmt_on_show, hmt_on_store);
#endif
#ifdef CONFIG_LCD_ALPM
#if defined(CONFIG_PANEL_S6E3HF3_DYNAMIC)
int alpm_set_mode(struct dsim_device *dsim, int enable)
{
struct panel_private *priv = &(dsim->priv);
if(priv->alpm_support != 1) {
pr_info("%s this panel do not support alpm %d!\n", __func__, priv->alpm_support);
return 0;
}
if((enable != ALPM_ON) && (enable != ALPM_OFF)) {
pr_info("alpm state is invalid %d !\n", priv->alpm);
return 0;
}
dsim_write_hl_data(dsim, SEQ_DISPLAY_OFF, ARRAY_SIZE(SEQ_DISPLAY_OFF));
usleep_range(17000, 17000);
dsim_write_hl_data(dsim, SEQ_TEST_KEY_ON_F0, ARRAY_SIZE(SEQ_TEST_KEY_ON_F0));
if(enable == ALPM_ON) {
dsim_write_hl_data(dsim, SEQ_ALPM2NIT_MODE_ON, ARRAY_SIZE(SEQ_ALPM2NIT_MODE_ON));
} else if(enable == ALPM_OFF) {
dsim_write_hl_data(dsim, SEQ_NORMAL_MODE_ON, ARRAY_SIZE(SEQ_NORMAL_MODE_ON));
}
dsim_write_hl_data(dsim, SEQ_GAMMA_UPDATE, ARRAY_SIZE(SEQ_GAMMA_UPDATE));
dsim_write_hl_data(dsim, SEQ_GAMMA_UPDATE_L, ARRAY_SIZE(SEQ_GAMMA_UPDATE_L));
dsim_write_hl_data(dsim, SEQ_TEST_KEY_OFF_F0, ARRAY_SIZE(SEQ_TEST_KEY_OFF_F0));
dsim_write_hl_data(dsim, SEQ_DISPLAY_ON, ARRAY_SIZE(SEQ_DISPLAY_ON)); /* (workaround) DDI 0x0A register : DISP_ON bit not upset */
usleep_range(17000, 17000);
dsim_write_hl_data(dsim, SEQ_DISPLAY_ON, ARRAY_SIZE(SEQ_DISPLAY_ON));
priv->current_alpm = dsim->alpm = enable;
return 0;
}
#else
int alpm_set_mode(struct dsim_device *dsim, int enable)
{
struct panel_private *priv = &(dsim->priv);
if((enable != ALPM_ON) && (enable != ALPM_OFF)) {
pr_info("alpm state is invalid %d !\n", priv->alpm);
return 0;
}
dsim_write_hl_data(dsim, SEQ_DISPLAY_OFF, ARRAY_SIZE(SEQ_DISPLAY_OFF));
usleep_range(17000, 17000);
dsim_write_hl_data(dsim, SEQ_TEST_KEY_ON_F0, ARRAY_SIZE(SEQ_TEST_KEY_ON_F0));
if(enable == ALPM_ON) {
priv->mtpForALPM[34] = priv->mtpForALPM[35]= 0;
dsim_write_hl_data(dsim, priv->mtpForALPM, ARRAY_SIZE(priv->mtpForALPM));
dsim_write_hl_data(dsim, SEQ_ALPM2NIT_MODE_ON, ARRAY_SIZE(SEQ_ALPM2NIT_MODE_ON));
} else if(enable == ALPM_OFF) {
priv->mtpForALPM[34] = priv->prev_VT[0];
priv->mtpForALPM[35] = priv->prev_VT[1];
dsim_write_hl_data(dsim, priv->mtpForALPM, ARRAY_SIZE(priv->mtpForALPM));
dsim_write_hl_data(dsim, SEQ_NORMAL_MODE_ON, ARRAY_SIZE(SEQ_NORMAL_MODE_ON));
}
dsim_write_hl_data(dsim, SEQ_GAMMA_UPDATE, ARRAY_SIZE(SEQ_GAMMA_UPDATE));
dsim_write_hl_data(dsim, SEQ_GAMMA_UPDATE_L, ARRAY_SIZE(SEQ_GAMMA_UPDATE_L));
dsim_write_hl_data(dsim, SEQ_TEST_KEY_OFF_F0, ARRAY_SIZE(SEQ_TEST_KEY_OFF_F0));
usleep_range(17000, 17000);
dsim_write_hl_data(dsim, SEQ_DISPLAY_ON, ARRAY_SIZE(SEQ_DISPLAY_ON));
priv->current_alpm = dsim->alpm = enable;
return 0;
}
#endif
static ssize_t alpm_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_private *priv = dev_get_drvdata(dev);
sprintf(buf, "%d\n", priv->alpm);
dev_info(dev, "%s: %d\n", __func__, priv->alpm);
return strlen(buf);
}
#if defined (CONFIG_SEC_FACTORY)
static int prev_brightness = 0;
#endif
static ssize_t alpm_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct dsim_device *dsim;
struct panel_private *priv = dev_get_drvdata(dev);
int value;
dsim = container_of(priv, struct dsim_device, priv);
sscanf(buf, "%9d", &value);
dev_info(dev, "%s: %d \n", __func__, value);
mutex_lock(&priv->alpm_lock);
#if defined (CONFIG_SEC_FACTORY)
if (value) {
if ((priv->state == PANEL_STATE_RESUMED) && !priv->current_alpm) {
prev_brightness = priv->bd->props.brightness;
priv->bd->props.brightness = UI_MIN_BRIGHTNESS;
dsim_panel_set_brightness(dsim, 1);
alpm_set_mode(dsim, ALPM_ON);
}
} else {
if ((priv->state == PANEL_STATE_RESUMED) && priv->current_alpm) {
priv->bd->props.brightness = prev_brightness;
alpm_set_mode(dsim, ALPM_OFF);
dsim_panel_set_brightness(dsim, 1);
}
}
#else
if (value) {
if ((priv->state == PANEL_STATE_RESUMED) && !priv->current_alpm)
alpm_set_mode(dsim, ALPM_ON);
} else {
if ((priv->state == PANEL_STATE_RESUMED)&& priv->current_alpm)
alpm_set_mode(dsim, ALPM_OFF);
#if defined(CONFIG_PANEL_S6E3HF3_DYNAMIC)
usleep_range(17000, 17000);
dsim_panel_set_brightness(dsim, 1);
#endif
}
#endif
priv->alpm = value;
mutex_unlock(&priv->alpm_lock);
dev_info(dev, "%s: %d %d\n", __func__, priv->alpm, dsim->alpm);
return size;
}
static DEVICE_ATTR(alpm, 0664, alpm_show, alpm_store);
#endif
#ifdef CONFIG_LCD_DOZE_MODE
#if defined (CONFIG_SEC_FACTORY)
static int prev_brightness = 0;
static int current_alpm_mode = 0;
#endif
static ssize_t alpm_doze_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
int value;
struct dsim_device *dsim;
struct panel_private *priv = dev_get_drvdata(dev);
struct decon_device *decon = NULL;
struct mutex *output_lock = NULL;
dsim = container_of(priv, struct dsim_device, priv);
sscanf(buf, "%9d", &value);
dsim_err("%s: sysfs alpm value: %d", __func__, value);
decon = (struct decon_device *)dsim->decon;
if (decon != NULL)
output_lock = &decon->output_lock;
#ifdef CONFIG_SEC_FACTORY
dsim_info("%s: %d\n", __func__, value);
current_alpm_mode = priv->alpm_mode;
switch (value) {
case ALPM_OFF:
priv->alpm_mode = value;
if ((dsim->dsim_doze == DSIM_DOZE_STATE_DOZE) ||
(dsim->dsim_doze == DSIM_DOZE_STATE_NORMAL)) {
call_panel_ops(dsim, exitalpm, dsim);
usleep_range(17000, 17000);
if (prev_brightness) {
priv->bd->props.brightness = prev_brightness - 1;
dsim_panel_set_brightness(dsim, 1);
prev_brightness = 0;
}
call_panel_ops(dsim, displayon, dsim);
}
break;
case ALPM_ON_LOW:
case HLPM_ON_LOW:
case ALPM_ON_HIGH:
case HLPM_ON_HIGH:
priv->alpm_mode = value;
if ((dsim->dsim_doze == DSIM_DOZE_STATE_DOZE) ||
(dsim->dsim_doze == DSIM_DOZE_STATE_NORMAL)) {
if(current_alpm_mode == ALPM_OFF) {
prev_brightness = priv->bd->props.brightness + 1;
priv->bd->props.brightness = UI_MIN_BRIGHTNESS;
dsim_panel_set_brightness(dsim, 1);
}
call_panel_ops(dsim, enteralpm, dsim);
usleep_range(17000, 17000);
dsim_write_hl_data(dsim, SEQ_DISPLAY_ON, ARRAY_SIZE(SEQ_DISPLAY_ON));
}
break;
default:
dsim_err("ERR:%s:undefined alpm mode : %d\n", __func__, value);
break;
}
#else
switch (value) {
case ALPM_ON_LOW:
case HLPM_ON_LOW:
case ALPM_ON_HIGH:
case HLPM_ON_HIGH:
if (output_lock != NULL)
mutex_lock(output_lock);
dsim_info("%s: %d\n", __func__, priv->alpm_mode);
if (value != priv->alpm_mode) {
priv->alpm_mode = value;
if (dsim->dsim_doze == DSIM_DOZE_STATE_DOZE) {
call_panel_ops(dsim, enteralpm, dsim);
}
}
if (output_lock != NULL)
mutex_unlock(output_lock);
break;
default:
dsim_err("ERR:%s:undefined alpm mode : %d\n", __func__, value);
break;
}
#endif
return size;
}
static ssize_t alpm_doze_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_private *priv = dev_get_drvdata(dev);
dsim_info("%s: %d\n", __func__, priv->alpm_mode);
sprintf(buf, "%d\n", priv->alpm_mode);
return strlen(buf);
}
static DEVICE_ATTR(alpm, 0664, alpm_doze_show, alpm_doze_store);
#endif
static ssize_t lcd_type_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_private *priv = dev_get_drvdata(dev);
sprintf(buf, "SDC_%02X%02X%02X\n", priv->id[0], priv->id[1], priv->id[2]);
return strlen(buf);
}
static ssize_t window_type_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_private *priv = dev_get_drvdata(dev);
sprintf(buf, "%02x %02x %02x\n", priv->id[0], priv->id[1], priv->id[2]);
return strlen(buf);
}
static ssize_t brightness_table_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_private *panel = dev_get_drvdata(dev);
char *pos = buf;
int nit, i, br_index;
struct dsim_device *dsim;
dsim = container_of(panel, struct dsim_device, priv);
for (i = 0; i <= EXTEND_BRIGHTNESS; i++) {
nit = (panel->gallery_br_tbl && !panel->adaptive_control) ? panel->gallery_br_tbl[i] : panel->br_tbl[i];
br_index = get_acutal_br_index(dsim, nit);
nit = get_actual_br_value(dsim, br_index);
pos += sprintf(pos, "%3d %3d\n", i, nit);
}
return pos - buf;
}
static ssize_t siop_enable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_private *priv = dev_get_drvdata(dev);
sprintf(buf, "%u\n", priv->siop_enable);
return strlen(buf);
}
static ssize_t siop_enable_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct dsim_device *dsim;
struct panel_private *priv = dev_get_drvdata(dev);
int value;
int rc;
dsim = container_of(priv, struct dsim_device, priv);
rc = kstrtouint(buf, (unsigned int)0, &value);
if (rc < 0)
return rc;
else {
if (priv->siop_enable != value) {
dev_info(dev, "%s: %d, %d\n", __func__, priv->siop_enable, value);
mutex_lock(&priv->lock);
priv->siop_enable = value;
mutex_unlock(&priv->lock);
#ifdef CONFIG_LCD_HMT
if(priv->hmt_on == HMT_ON)
dsim_panel_set_brightness_for_hmt(dsim, 1);
else
#endif
dsim_panel_set_brightness(dsim, 1);
}
}
return size;
}
static ssize_t temperature_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
char temp[] = "-20, -19, 0, 1\n";
strcat(buf, temp);
return strlen(buf);
}
static ssize_t temperature_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct dsim_device *dsim;
struct panel_private *priv = dev_get_drvdata(dev);
int value;
int rc;
dsim = container_of(priv, struct dsim_device, priv);
rc = kstrtoint(buf, 10, &value);
if (rc < 0)
return rc;
else {
mutex_lock(&priv->lock);
priv->temperature = value;
mutex_unlock(&priv->lock);
#ifdef CONFIG_LCD_HMT
if(priv->hmt_on == HMT_ON)
dsim_panel_set_brightness_for_hmt(dsim, 1);
else
#endif
dsim_panel_set_brightness(dsim, 1);
dev_info(dev, "%s: %d, %d\n", __func__, value, priv->temperature);
}
return size;
}
static ssize_t color_coordinate_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_private *priv = dev_get_drvdata(dev);
sprintf(buf, "%u, %u\n", priv->coordinate[0], priv->coordinate[1]);
return strlen(buf);
}
static ssize_t manufacture_date_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_private *priv = dev_get_drvdata(dev);
u16 year;
u8 month, day, hour, min;
year = ((priv->date[0] & 0xF0) >> 4) + 2011;
month = priv->date[0] & 0xF;
day = priv->date[1] & 0x1F;
hour = priv->date[2] & 0x1F;
min = priv->date[3] & 0x3F;
sprintf(buf, "%d, %d, %d, %d:%d\n", year, month, day, hour, min);
return strlen(buf);
}
static ssize_t read_mtp_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return strlen(buf);
}
static ssize_t read_mtp_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct dsim_device *dsim;
struct panel_private *priv = dev_get_drvdata(dev);
unsigned int reg, pos, length, i;
unsigned char readbuf[256] = {0xff, };
unsigned char writebuf[2] = {0xB0, };
dsim = container_of(priv, struct dsim_device, priv);
sscanf(buf, "%x %d %d", ®, &pos, &length);
if (!reg || !length || pos < 0 || reg > 0xff || length > 255 || pos > 255)
return -EINVAL;
if (priv->state != PANEL_STATE_RESUMED)
return -EINVAL;
writebuf[1] = pos;
if (dsim_write_hl_data(dsim, SEQ_TEST_KEY_ON_F0, ARRAY_SIZE(SEQ_TEST_KEY_ON_F0)) < 0)
dsim_err("fail to write F0 on command.\n");
if (dsim_write_hl_data(dsim, SEQ_TEST_KEY_ON_FC, ARRAY_SIZE(SEQ_TEST_KEY_ON_FC)) < 0)
dsim_err("fail to write test on fc command.\n");
if (dsim_write_hl_data(dsim, writebuf, ARRAY_SIZE(writebuf)) < 0)
dsim_err("fail to write global command.\n");
if (dsim_read_hl_data(dsim, reg, length, readbuf) < 0)
dsim_err("fail to read id on command.\n");
if (dsim_write_hl_data(dsim, SEQ_TEST_KEY_OFF_F0, ARRAY_SIZE(SEQ_TEST_KEY_OFF_F0)) < 0)
dsim_err("fail to write F0 on command.\n");
if (dsim_write_hl_data(dsim, SEQ_TEST_KEY_OFF_FC, ARRAY_SIZE(SEQ_TEST_KEY_OFF_FC)) < 0)
dsim_err("fail to write test on fc command.\n");
dsim_info("READ_Reg addr : %02x, start pos : %d len : %d \n", reg, pos, length);
for (i = 0; i < length; i++)
dsim_info("READ_Reg %dth : %02x \n", i + 1, readbuf[i]);
return size;
}
#ifdef CONFIG_LCD_BURNIN_CORRECTION
static ssize_t ldu_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_private *priv = dev_get_drvdata(dev);
sprintf(buf, "%u\n", priv->ldu_correction_state);
return strlen(buf);
}
static ssize_t ldu_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct dsim_device *dsim;
struct panel_private *priv = dev_get_drvdata(dev);
int rc;
int value;
dsim = container_of(priv, struct dsim_device, priv);
rc = kstrtouint(buf, 0, &value);
if (rc < 0)
return rc;
if (priv->ldu_correction_state != value) {
dev_info(dev, "%s: %d, %d\n", __func__, priv->ldu_correction_state, value);
priv->ldu_correction_state = value;
}
return size;
}
static DEVICE_ATTR(ldu, 0000, ldu_show, ldu_store);
#endif
#ifdef CONFIG_PANEL_AID_DIMMING
static void show_aid_log(struct dsim_device *dsim)
{
int i, j, k;
struct dim_data *dim_data = NULL;
struct SmtDimInfo *dimming_info = NULL;
#ifdef CONFIG_LCD_HMT
struct SmtDimInfo *hmt_dimming_info = NULL;
#endif
struct panel_private *panel = &dsim->priv;
u8 temp[256];
if (panel == NULL) {
dsim_err("%s:panel is NULL\n", __func__);
return;
}
dim_data = (struct dim_data*)(panel->dim_data);
if (dim_data == NULL) {
dsim_info("%s:dimming is NULL\n", __func__);
return;
}
dimming_info = (struct SmtDimInfo*)(panel->dim_info);
if (dimming_info == NULL) {
dsim_info("%s:dimming is NULL\n", __func__);
return;
}
dsim_info("MTP VT : %d %d %d\n",
dim_data->vt_mtp[CI_RED], dim_data->vt_mtp[CI_GREEN], dim_data->vt_mtp[CI_BLUE] );
for(i = 0; i < VMAX; i++) {
dsim_info("MTP V%d : %4d %4d %4d \n",
vref_index[i], dim_data->mtp[i][CI_RED], dim_data->mtp[i][CI_GREEN], dim_data->mtp[i][CI_BLUE] );
}
for(i = 0; i < MAX_BR_INFO; i++) {
memset(temp, 0, sizeof(temp));
for(j = 1; j < OLED_CMD_GAMMA_CNT; j++) {
if (j == 1 || j == 3 || j == 5)
k = dimming_info[i].gamma[j++] * 256;
else
k = 0;
snprintf(temp + strnlen(temp, 256), 256, " %d", dimming_info[i].gamma[j] + k);
}
dsim_info("nit :%3d %s\n", dimming_info[i].br, temp);
}
#ifdef CONFIG_LCD_HMT
hmt_dimming_info = (struct SmtDimInfo*)(panel->hmt_dim_info);
if (hmt_dimming_info == NULL) {
dsim_info("%s:dimming is NULL\n", __func__);
return;
}
for(i = 0; i < HMT_MAX_BR_INFO; i++) {
memset(temp, 0, sizeof(temp));
for(j = 1; j < OLED_CMD_GAMMA_CNT; j++) {
if (j == 1 || j == 3 || j == 5)
k = hmt_dimming_info[i].gamma[j++] * 256;
else
k = 0;
snprintf(temp + strnlen(temp, 256), 256, " %d", hmt_dimming_info[i].gamma[j] + k);
}
dsim_info("nit :%3d %s\n", hmt_dimming_info[i].br, temp);
}
#endif
}
static ssize_t aid_log_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct dsim_device *dsim;
struct panel_private *priv = dev_get_drvdata(dev);
dsim = container_of(priv, struct dsim_device, priv);
show_aid_log(dsim);
return strlen(buf);
}
#endif
static ssize_t manufacture_code_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_private *priv = dev_get_drvdata(dev);
sprintf(buf, "%02X%02X%02X%02X%02X\n",
priv->code[0], priv->code[1], priv->code[2], priv->code[3], priv->code[4]);
return strlen(buf);
}
static ssize_t cell_id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_private *priv = dev_get_drvdata(dev);
sprintf(buf, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\n",
priv->date[0] , priv->date[1], priv->date[2], priv->date[3], priv->date[4],
priv->date[5],priv->date[6], (priv->coordinate[0] &0xFF00)>>8,priv->coordinate[0] &0x00FF,
(priv->coordinate[1]&0xFF00)>>8,priv->coordinate[1]&0x00FF);
return strlen(buf);
}
#if defined(CONFIG_PANEL_S6E3HF2_DYNAMIC) || defined(CONFIG_PANEL_S6E3HA2_DYNAMIC) //only zero
static int find_hbm_table(struct dsim_device *dsim, int nit)
{
int retVal = 0;
int i;
int current_gap;
int minVal = 20000;
for (i = 0; i < 256; i++) {
current_gap = nit - dsim->priv.gallery_br_tbl[i];
if (current_gap < 0)
current_gap *= -1;
if (minVal > current_gap) {
minVal = current_gap;
retVal = i;
}
}
return retVal;
}
#endif
static ssize_t adaptive_control_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_private *priv = dev_get_drvdata(dev);
sprintf(buf, "%d\n", priv->adaptive_control);
return strlen(buf);
}
#if defined(CONFIG_PANEL_S6E3HF2_DYNAMIC) || defined(CONFIG_PANEL_S6E3HA2_DYNAMIC) //only zero
static ssize_t adaptive_control_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
{
int rc;
int value, i;
int hbm_nit, origin_nit, p_br, gap_nit;
int index_array[W_HBM_STEP];
int update_br;
int final_br;
struct dsim_device *dsim;
struct panel_private *priv = dev_get_drvdata(dev);
dsim = container_of(priv, struct dsim_device, priv);
rc = kstrtouint(buf, (unsigned int)0, &value);
if (rc < 0)
return rc;
if (priv->adaptive_control != value) {
dev_info(dev, "%s: %d, %d\n", __func__, priv->adaptive_control, value);
if (priv->accessibility || priv->ldu_correction_state) {
pr_info("%s: don't support gallery change if color blind(%d) or ldu(%d) is already enabled\n", __func__, priv->accessibility, priv->ldu_correction_state);
return size;
}
p_br = priv->bd->props.brightness;
final_br = priv->bd->props.brightness;
/* OFF->Gallery or Gallery->OFF */
hbm_nit = priv->gallery_br_tbl[p_br];
// index_array[0](=normal_br) ~ index_array[high](=hbm_br) //
origin_nit = priv->br_tbl[p_br];
gap_nit = (hbm_nit - origin_nit) / W_HBM_STEP;
for (i = 0; i < W_HBM_STEP; i++) {
index_array[i] = find_hbm_table(dsim, origin_nit);
origin_nit += gap_nit;
}
if (value != W_HBM_OFF) {
mutex_lock(&priv->lock);
priv->adaptive_control = value;
mutex_unlock(&priv->lock);
}
priv->is_br_override = true;
for (i = 1; i < W_HBM_STEP; i++) {
if (value != W_HBM_OFF)
update_br = index_array[i];
else
update_br = index_array[W_HBM_STEP - i];
priv->override_br_value = update_br;
priv->bd->props.brightness = update_br;
dsim_panel_set_brightness(dsim, 0);
msleep(20);
if (priv->bd->props.brightness != update_br)
final_br = priv->bd->props.brightness;
}
priv->is_br_override = false;
if (value == W_HBM_OFF) {
mutex_lock(&priv->lock);
priv->adaptive_control = value;
mutex_unlock(&priv->lock);
}
priv->bd->props.brightness = final_br;
dsim_panel_set_brightness(dsim, 0);
}
return size;
}
#else
static ssize_t adaptive_control_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
int rc;
int value;
struct dsim_device *dsim;
struct panel_private *priv = dev_get_drvdata(dev);
dsim = container_of(priv, struct dsim_device, priv);
rc = kstrtouint(buf, 0, &value);
if (rc < 0)
return rc;
else {
if (priv->adaptive_control != value) {
dev_info(dev, "%s: %d, %d\n", __func__, priv->adaptive_control, value);
mutex_lock(&priv->lock);
priv->adaptive_control = value;
mutex_unlock(&priv->lock);
dsim_panel_set_brightness(dsim, 1);
}
}
return size;
}
#endif
static ssize_t lux_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_private *priv = dev_get_drvdata(dev);
sprintf(buf, "%d\n", priv->lux);
return strlen(buf);
}
static ssize_t lux_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
int rc;
int value;
struct panel_private *priv = dev_get_drvdata(dev);
rc = kstrtoint(buf, 0, &value);
if (rc < 0)
return rc;
else {
dev_info(dev, "%s: %d, %d\n", __func__, priv->lux, value);
if (priv->lux != value) {
mutex_lock(&priv->lock);
priv->lux = value;
mutex_unlock(&priv->lock);
attr_store_for_each(priv->mdnie_class, attr->attr.name, buf, size);
}
}
return size;
}
static ssize_t accessibility_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_private *priv = dev_get_drvdata(dev);
return sprintf(buf, "%d\n", priv->accessibility);
}
static ssize_t accessibility_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
int rc;
int value;
struct dsim_device *dsim;
struct panel_private *priv = dev_get_drvdata(dev);
dsim = container_of(priv, struct dsim_device, priv);
rc = kstrtouint(buf, 0, &value);
if (rc < 0)
return rc;
else {
if (priv->accessibility != value) {
dev_info(dev, "%s: %d, %d\n", __func__, priv->accessibility, value);
priv->accessibility = value;
}
}
return count;
}
#ifdef CONFIG_CHECK_OCTA_CHIP_ID
static ssize_t octa_id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct panel_private *priv = dev_get_drvdata(dev);
int site, rework, poc;
char cell_id[16];
int i;
unsigned char* octa_id;
octa_id = &(priv->octa_id[1]);
site = octa_id[0] & 0xf0;
site >>= 4;
rework = octa_id[0] & 0x0f;
poc = octa_id[1] & 0x0f;
dsim_info("site (%d), rework (%d), poc (%d)\n",
site, rework, poc);
dsim_info("<CELL ID>\n");
for(i = 0; i < 16; i++) {
cell_id[i] = octa_id[i+4];
dsim_info("%x -> %c\n",octa_id[i+4], cell_id[i]);
}
sprintf(buf, "%d%d%d%02x%02x%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
site, rework, poc, octa_id[2], octa_id[3],
cell_id[0], cell_id[1], cell_id[2], cell_id[3],
cell_id[4], cell_id[5], cell_id[6], cell_id[7],
cell_id[8], cell_id[9], cell_id[10], cell_id[11],
cell_id[12], cell_id[13], cell_id[14], cell_id[15]);
return strlen(buf);
}
static DEVICE_ATTR(octa_id, 0444, octa_id_show, NULL);
#endif
#ifdef CONFIG_FB_DSU
static ssize_t resolution_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
int i;
struct dsim_device *dsim;
struct panel_private *priv = dev_get_drvdata(dev);
dsim = container_of(priv, struct dsim_device, priv);
for( i=0; i<ARRAY_SIZE(dsu_config); i++ ) {
if( dsu_config[i].value == dsim->dsu_param_value ) {
strcpy( buf, dsu_config[i].id_str );
pr_info( "%s:%s,%d\n", __func__, dsu_config[i].id_str, dsu_config[i].value );
return strlen(buf);
break;
}
}
strcpy(buf, "WQHD" );
pr_err( "%s:(default)%s,%d\n", __func__, buf, DSU_CONFIG_WQHD );
return strlen(buf);
}
static ssize_t resolution_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct dsim_device *dsim;
struct panel_private *priv = dev_get_drvdata(dev);
int ret;
int i;
dsim = container_of(priv, struct dsim_device, priv);
if( dsim->dsu_param_offset==0 ) {
pr_err( "%s: failed. offset not exist\n", __func__ );
}
for( i=0; i<ARRAY_SIZE(dsu_config); i++ ) {
if( !strncmp(dsu_config[i].id_str, buf, strlen(dsu_config[i].id_str)) ) {
dsim->dsu_param_value = dsu_config[i].value;
ret = sec_set_param((unsigned long) dsim->dsu_param_offset, dsim->dsu_param_value);
pr_info( "%s:%s,%d,%d\n", __func__, dsu_config[i].id_str, dsim->dsu_param_value, ret );
return size;
}
}
pr_err( "%s: failed (%s)\n", __func__, buf );
return size;
}
static DEVICE_ATTR(resolution, 0664, resolution_show, resolution_store);
#endif
static DEVICE_ATTR(accessibility, 0000, accessibility_show, accessibility_store);
static DEVICE_ATTR(adaptive_control, 0664, adaptive_control_show, adaptive_control_store);
static DEVICE_ATTR(lcd_type, 0444, lcd_type_show, NULL);
static DEVICE_ATTR(window_type, 0444, window_type_show, NULL);
static DEVICE_ATTR(manufacture_code, 0444, manufacture_code_show, NULL);
static DEVICE_ATTR(cell_id, 0444, cell_id_show, NULL);
static DEVICE_ATTR(brightness_table, 0444, brightness_table_show, NULL);
static DEVICE_ATTR(siop_enable, 0664, siop_enable_show, siop_enable_store);
static DEVICE_ATTR(temperature, 0664, temperature_show, temperature_store);
static DEVICE_ATTR(color_coordinate, 0444, color_coordinate_show, NULL);
static DEVICE_ATTR(manufacture_date, 0444, manufacture_date_show, NULL);
static DEVICE_ATTR(read_mtp, 0664, read_mtp_show, read_mtp_store);
#ifdef CONFIG_PANEL_AID_DIMMING
static DEVICE_ATTR(aid_log, 0444, aid_log_show, NULL);
#endif
static DEVICE_ATTR(lux, 0644, lux_show, lux_store);
static struct attribute *lcd_sysfs_attributes[] = {
&dev_attr_lcd_type.attr,
&dev_attr_window_type.attr,
&dev_attr_manufacture_code.attr,
&dev_attr_cell_id.attr,
&dev_attr_brightness_table.attr,
&dev_attr_siop_enable.attr,
&dev_attr_temperature.attr,
&dev_attr_color_coordinate.attr,
&dev_attr_manufacture_date.attr,
#ifdef CONFIG_PANEL_AID_DIMMING
&dev_attr_aid_log.attr,
#endif
&dev_attr_read_mtp.attr,
#if defined(CONFIG_SEC_FACTORY) && defined(CONFIG_EXYNOS_DECON_LCD_MCD)
&dev_attr_mcd_mode.attr,
#endif
#ifdef CONFIG_LCD_HMT
#ifdef CONFIG_PANEL_AID_DIMMING
&dev_attr_hmt_bright.attr,
#endif
&dev_attr_hmt_on.attr,
#endif
#if defined(CONFIG_LCD_ALPM) || defined(CONFIG_LCD_DOZE_MODE)
&dev_attr_alpm.attr,
#endif
&dev_attr_adaptive_control.attr,
&dev_attr_lux.attr,
#ifdef CONFIG_LCD_BURNIN_CORRECTION
&dev_attr_ldu.attr,
#endif
&dev_attr_accessibility.attr,
#ifdef CONFIG_CHECK_OCTA_CHIP_ID
&dev_attr_octa_id.attr,
#endif
#ifdef CONFIG_FB_DSU
&dev_attr_resolution.attr,
#endif
NULL,
};
static const struct attribute_group lcd_sysfs_attr_group = {
.attrs = lcd_sysfs_attributes,
};
static const struct attribute_group *lcd_sysfs_attr_groups[] = {
&lcd_sysfs_attr_group,
NULL,
};
void lcd_init_sysfs(struct dsim_device *dsim)
{
int ret = -1;
ret = sysfs_create_group(&dsim->lcd->dev.kobj, &lcd_sysfs_attr_group);
if (ret < 0)
dev_err(&dsim->lcd->dev, "failed to add lcd sysfs\n");
dsim->lcd->dev.groups = lcd_sysfs_attr_groups;
}
|