This source file includes following definitions.
- fill_backlight_transform_table
- fill_backlight_transform_table_v_2_2
- fill_iram_v_2
- fill_iram_v_2_2
- fill_iram_v_2_3
- dmcu_load_iram
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 #include "power_helpers.h"
26 #include "dc/inc/hw/dmcu.h"
27
28 #define DIV_ROUNDUP(a, b) (((a)+((b)/2))/(b))
29
30
31
32
33
34 static const unsigned char min_reduction_table[13] = {
35 0xff, 0xfa, 0xf0, 0xf0, 0xd9, 0xcd, 0xc0, 0xb1, 0x99, 0x93, 0x80, 0x82, 0x66};
36
37
38
39
40
41 static const unsigned char max_reduction_table[13] = {
42 0xf5, 0xe5, 0xd9, 0xcd, 0xb1, 0xa5, 0xa5, 0x80, 0x65, 0x4d, 0x4d, 0x4d, 0x32};
43
44
45
46
47
48 static const unsigned char min_reduction_table_v_2_2[13] = {
49 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xeb, 0xd4, 0xc0, 0xc0};
50
51
52
53
54
55 static const unsigned char max_reduction_table_v_2_2[13] = {
56 0xf5, 0xe5, 0xbf, 0xb1, 0xa5, 0x85, 0x7c, 0x65, 0x4d, 0x40, 0x32, 0x20, 0x20};
57
58
59
60
61 static const unsigned char abm_config[abm_defines_max_config][abm_defines_max_level] = {
62
63 { 2, 5, 7, 8 },
64 { 2, 5, 8, 11 },
65 { 0, 2, 4, 8 },
66 { 3, 6, 10, 12 },
67 };
68
69 struct abm_parameters {
70 unsigned char min_reduction;
71 unsigned char max_reduction;
72 unsigned char bright_pos_gain;
73 unsigned char dark_pos_gain;
74 unsigned char brightness_gain;
75 unsigned char contrast_factor;
76 unsigned char deviation_gain;
77 unsigned char min_knee;
78 unsigned char max_knee;
79 };
80
81 static const struct abm_parameters abm_settings_config0[abm_defines_max_level] = {
82
83 {0xff, 0xbf, 0x20, 0x00, 0xff, 0x99, 0xb3, 0x40, 0xE0},
84 {0xff, 0x85, 0x20, 0x00, 0xff, 0x90, 0xa8, 0x40, 0xE0},
85 {0xff, 0x40, 0x20, 0x00, 0xff, 0x90, 0x68, 0x40, 0xE0},
86 {0x82, 0x4d, 0x20, 0x00, 0x00, 0x90, 0xb3, 0x70, 0x70},
87 };
88
89 static const struct abm_parameters abm_settings_config1[abm_defines_max_level] = {
90
91 {0xf0, 0xd9, 0x20, 0x00, 0x00, 0xa8, 0xb3, 0x70, 0x70},
92 {0xcd, 0xa5, 0x20, 0x00, 0x00, 0xa8, 0xb3, 0x70, 0x70},
93 {0x99, 0x65, 0x20, 0x00, 0x00, 0xa8, 0xb3, 0x70, 0x70},
94 {0x82, 0x4d, 0x20, 0x00, 0x00, 0xa8, 0xb3, 0x70, 0x70},
95 };
96
97 static const struct abm_parameters * const abm_settings[] = {
98 abm_settings_config0,
99 abm_settings_config1,
100 };
101
102 #define NUM_AMBI_LEVEL 5
103 #define NUM_AGGR_LEVEL 4
104 #define NUM_POWER_FN_SEGS 8
105 #define NUM_BL_CURVE_SEGS 16
106 #define IRAM_SIZE 256
107
108 #define IRAM_RESERVE_AREA_START_V2 0xF0
109 #define IRAM_RESERVE_AREA_END_V2 0xF6
110
111 #define IRAM_RESERVE_AREA_START_V2_2 0xF0
112 #define IRAM_RESERVE_AREA_END_V2_2 0xFF
113
114 #pragma pack(push, 1)
115
116 struct iram_table_v_2 {
117
118 uint16_t min_abm_backlight;
119
120
121 uint8_t min_reduction[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL];
122 uint8_t max_reduction[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL];
123 uint8_t bright_pos_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL];
124 uint8_t bright_neg_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL];
125 uint8_t dark_pos_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL];
126 uint8_t dark_neg_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL];
127 uint8_t iir_curve[NUM_AMBI_LEVEL];
128 uint8_t deviation_gain;
129
130
131 uint16_t crgb_thresh[NUM_POWER_FN_SEGS];
132 uint16_t crgb_offset[NUM_POWER_FN_SEGS];
133 uint16_t crgb_slope[NUM_POWER_FN_SEGS];
134
135
136
137 uint16_t backlight_thresholds[NUM_BL_CURVE_SEGS];
138
139 uint16_t backlight_offsets[NUM_BL_CURVE_SEGS];
140
141
142 uint8_t psr_state;
143 uint8_t dmcu_mcp_interface_version;
144 uint8_t dmcu_abm_feature_version;
145 uint8_t dmcu_psr_feature_version;
146 uint16_t dmcu_version;
147 uint8_t dmcu_state;
148
149 uint16_t blRampReduction;
150 uint16_t blRampStart;
151 uint8_t dummy5;
152 uint8_t dummy6;
153 uint8_t dummy7;
154 uint8_t dummy8;
155 uint8_t dummy9;
156 };
157
158 struct iram_table_v_2_2 {
159
160 uint16_t flags;
161
162
163 uint8_t min_reduction[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL];
164 uint8_t max_reduction[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL];
165 uint8_t bright_pos_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL];
166 uint8_t dark_pos_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL];
167 uint8_t hybrid_factor[NUM_AGGR_LEVEL];
168 uint8_t contrast_factor[NUM_AGGR_LEVEL];
169 uint8_t deviation_gain[NUM_AGGR_LEVEL];
170 uint8_t iir_curve[NUM_AMBI_LEVEL];
171 uint8_t min_knee[NUM_AGGR_LEVEL];
172 uint8_t max_knee[NUM_AGGR_LEVEL];
173 uint16_t min_abm_backlight;
174 uint8_t pad[19];
175
176
177 uint16_t crgb_thresh[NUM_POWER_FN_SEGS];
178 uint16_t crgb_offset[NUM_POWER_FN_SEGS];
179 uint16_t crgb_slope[NUM_POWER_FN_SEGS];
180
181
182
183 uint16_t backlight_thresholds[NUM_BL_CURVE_SEGS];
184
185 uint16_t backlight_offsets[NUM_BL_CURVE_SEGS];
186
187
188 uint8_t psr_state;
189 uint8_t dmcu_mcp_interface_version;
190 uint8_t dmcu_abm_feature_version;
191 uint8_t dmcu_psr_feature_version;
192 uint16_t dmcu_version;
193 uint8_t dmcu_state;
194
195 uint8_t dummy1;
196 uint8_t dummy2;
197 uint8_t dummy3;
198 uint8_t dummy4;
199 uint8_t dummy5;
200 uint8_t dummy6;
201 uint8_t dummy7;
202 uint8_t dummy8;
203 uint8_t dummy9;
204 };
205 #pragma pack(pop)
206
207 static void fill_backlight_transform_table(struct dmcu_iram_parameters params,
208 struct iram_table_v_2 *table)
209 {
210 unsigned int i;
211 unsigned int num_entries = NUM_BL_CURVE_SEGS;
212 unsigned int lut_index;
213
214 table->backlight_thresholds[0] = 0;
215 table->backlight_offsets[0] = params.backlight_lut_array[0];
216 table->backlight_thresholds[num_entries-1] = 0xFFFF;
217 table->backlight_offsets[num_entries-1] =
218 params.backlight_lut_array[params.backlight_lut_array_size - 1];
219
220
221
222
223
224
225
226
227
228 for (i = 1; i+1 < num_entries; i++) {
229 lut_index = (params.backlight_lut_array_size - 1) * i / (num_entries - 1);
230 ASSERT(lut_index < params.backlight_lut_array_size);
231
232 table->backlight_thresholds[i] =
233 cpu_to_be16(DIV_ROUNDUP((i * 65536), num_entries));
234 table->backlight_offsets[i] =
235 cpu_to_be16(params.backlight_lut_array[lut_index]);
236 }
237 }
238
239 static void fill_backlight_transform_table_v_2_2(struct dmcu_iram_parameters params,
240 struct iram_table_v_2_2 *table)
241 {
242 unsigned int i;
243 unsigned int num_entries = NUM_BL_CURVE_SEGS;
244 unsigned int lut_index;
245
246 table->backlight_thresholds[0] = 0;
247 table->backlight_offsets[0] = params.backlight_lut_array[0];
248 table->backlight_thresholds[num_entries-1] = 0xFFFF;
249 table->backlight_offsets[num_entries-1] =
250 params.backlight_lut_array[params.backlight_lut_array_size - 1];
251
252
253
254
255
256
257
258
259
260 for (i = 1; i+1 < num_entries; i++) {
261 lut_index = (params.backlight_lut_array_size - 1) * i / (num_entries - 1);
262 ASSERT(lut_index < params.backlight_lut_array_size);
263
264 table->backlight_thresholds[i] =
265 cpu_to_be16(DIV_ROUNDUP((i * 65536), num_entries));
266 table->backlight_offsets[i] =
267 cpu_to_be16(params.backlight_lut_array[lut_index]);
268 }
269 }
270
271 void fill_iram_v_2(struct iram_table_v_2 *ram_table, struct dmcu_iram_parameters params)
272 {
273 unsigned int set = params.set;
274
275 ram_table->min_abm_backlight =
276 cpu_to_be16(params.min_abm_backlight);
277 ram_table->deviation_gain = 0xb3;
278
279 ram_table->blRampReduction =
280 cpu_to_be16(params.backlight_ramping_reduction);
281 ram_table->blRampStart =
282 cpu_to_be16(params.backlight_ramping_start);
283
284 ram_table->min_reduction[0][0] = min_reduction_table[abm_config[set][0]];
285 ram_table->min_reduction[1][0] = min_reduction_table[abm_config[set][0]];
286 ram_table->min_reduction[2][0] = min_reduction_table[abm_config[set][0]];
287 ram_table->min_reduction[3][0] = min_reduction_table[abm_config[set][0]];
288 ram_table->min_reduction[4][0] = min_reduction_table[abm_config[set][0]];
289 ram_table->max_reduction[0][0] = max_reduction_table[abm_config[set][0]];
290 ram_table->max_reduction[1][0] = max_reduction_table[abm_config[set][0]];
291 ram_table->max_reduction[2][0] = max_reduction_table[abm_config[set][0]];
292 ram_table->max_reduction[3][0] = max_reduction_table[abm_config[set][0]];
293 ram_table->max_reduction[4][0] = max_reduction_table[abm_config[set][0]];
294
295 ram_table->min_reduction[0][1] = min_reduction_table[abm_config[set][1]];
296 ram_table->min_reduction[1][1] = min_reduction_table[abm_config[set][1]];
297 ram_table->min_reduction[2][1] = min_reduction_table[abm_config[set][1]];
298 ram_table->min_reduction[3][1] = min_reduction_table[abm_config[set][1]];
299 ram_table->min_reduction[4][1] = min_reduction_table[abm_config[set][1]];
300 ram_table->max_reduction[0][1] = max_reduction_table[abm_config[set][1]];
301 ram_table->max_reduction[1][1] = max_reduction_table[abm_config[set][1]];
302 ram_table->max_reduction[2][1] = max_reduction_table[abm_config[set][1]];
303 ram_table->max_reduction[3][1] = max_reduction_table[abm_config[set][1]];
304 ram_table->max_reduction[4][1] = max_reduction_table[abm_config[set][1]];
305
306 ram_table->min_reduction[0][2] = min_reduction_table[abm_config[set][2]];
307 ram_table->min_reduction[1][2] = min_reduction_table[abm_config[set][2]];
308 ram_table->min_reduction[2][2] = min_reduction_table[abm_config[set][2]];
309 ram_table->min_reduction[3][2] = min_reduction_table[abm_config[set][2]];
310 ram_table->min_reduction[4][2] = min_reduction_table[abm_config[set][2]];
311 ram_table->max_reduction[0][2] = max_reduction_table[abm_config[set][2]];
312 ram_table->max_reduction[1][2] = max_reduction_table[abm_config[set][2]];
313 ram_table->max_reduction[2][2] = max_reduction_table[abm_config[set][2]];
314 ram_table->max_reduction[3][2] = max_reduction_table[abm_config[set][2]];
315 ram_table->max_reduction[4][2] = max_reduction_table[abm_config[set][2]];
316
317 ram_table->min_reduction[0][3] = min_reduction_table[abm_config[set][3]];
318 ram_table->min_reduction[1][3] = min_reduction_table[abm_config[set][3]];
319 ram_table->min_reduction[2][3] = min_reduction_table[abm_config[set][3]];
320 ram_table->min_reduction[3][3] = min_reduction_table[abm_config[set][3]];
321 ram_table->min_reduction[4][3] = min_reduction_table[abm_config[set][3]];
322 ram_table->max_reduction[0][3] = max_reduction_table[abm_config[set][3]];
323 ram_table->max_reduction[1][3] = max_reduction_table[abm_config[set][3]];
324 ram_table->max_reduction[2][3] = max_reduction_table[abm_config[set][3]];
325 ram_table->max_reduction[3][3] = max_reduction_table[abm_config[set][3]];
326 ram_table->max_reduction[4][3] = max_reduction_table[abm_config[set][3]];
327
328 ram_table->bright_pos_gain[0][0] = 0x20;
329 ram_table->bright_pos_gain[0][1] = 0x20;
330 ram_table->bright_pos_gain[0][2] = 0x20;
331 ram_table->bright_pos_gain[0][3] = 0x20;
332 ram_table->bright_pos_gain[1][0] = 0x20;
333 ram_table->bright_pos_gain[1][1] = 0x20;
334 ram_table->bright_pos_gain[1][2] = 0x20;
335 ram_table->bright_pos_gain[1][3] = 0x20;
336 ram_table->bright_pos_gain[2][0] = 0x20;
337 ram_table->bright_pos_gain[2][1] = 0x20;
338 ram_table->bright_pos_gain[2][2] = 0x20;
339 ram_table->bright_pos_gain[2][3] = 0x20;
340 ram_table->bright_pos_gain[3][0] = 0x20;
341 ram_table->bright_pos_gain[3][1] = 0x20;
342 ram_table->bright_pos_gain[3][2] = 0x20;
343 ram_table->bright_pos_gain[3][3] = 0x20;
344 ram_table->bright_pos_gain[4][0] = 0x20;
345 ram_table->bright_pos_gain[4][1] = 0x20;
346 ram_table->bright_pos_gain[4][2] = 0x20;
347 ram_table->bright_pos_gain[4][3] = 0x20;
348 ram_table->bright_neg_gain[0][1] = 0x00;
349 ram_table->bright_neg_gain[0][2] = 0x00;
350 ram_table->bright_neg_gain[0][3] = 0x00;
351 ram_table->bright_neg_gain[1][0] = 0x00;
352 ram_table->bright_neg_gain[1][1] = 0x00;
353 ram_table->bright_neg_gain[1][2] = 0x00;
354 ram_table->bright_neg_gain[1][3] = 0x00;
355 ram_table->bright_neg_gain[2][0] = 0x00;
356 ram_table->bright_neg_gain[2][1] = 0x00;
357 ram_table->bright_neg_gain[2][2] = 0x00;
358 ram_table->bright_neg_gain[2][3] = 0x00;
359 ram_table->bright_neg_gain[3][0] = 0x00;
360 ram_table->bright_neg_gain[3][1] = 0x00;
361 ram_table->bright_neg_gain[3][2] = 0x00;
362 ram_table->bright_neg_gain[3][3] = 0x00;
363 ram_table->bright_neg_gain[4][0] = 0x00;
364 ram_table->bright_neg_gain[4][1] = 0x00;
365 ram_table->bright_neg_gain[4][2] = 0x00;
366 ram_table->bright_neg_gain[4][3] = 0x00;
367 ram_table->dark_pos_gain[0][0] = 0x00;
368 ram_table->dark_pos_gain[0][1] = 0x00;
369 ram_table->dark_pos_gain[0][2] = 0x00;
370 ram_table->dark_pos_gain[0][3] = 0x00;
371 ram_table->dark_pos_gain[1][0] = 0x00;
372 ram_table->dark_pos_gain[1][1] = 0x00;
373 ram_table->dark_pos_gain[1][2] = 0x00;
374 ram_table->dark_pos_gain[1][3] = 0x00;
375 ram_table->dark_pos_gain[2][0] = 0x00;
376 ram_table->dark_pos_gain[2][1] = 0x00;
377 ram_table->dark_pos_gain[2][2] = 0x00;
378 ram_table->dark_pos_gain[2][3] = 0x00;
379 ram_table->dark_pos_gain[3][0] = 0x00;
380 ram_table->dark_pos_gain[3][1] = 0x00;
381 ram_table->dark_pos_gain[3][2] = 0x00;
382 ram_table->dark_pos_gain[3][3] = 0x00;
383 ram_table->dark_pos_gain[4][0] = 0x00;
384 ram_table->dark_pos_gain[4][1] = 0x00;
385 ram_table->dark_pos_gain[4][2] = 0x00;
386 ram_table->dark_pos_gain[4][3] = 0x00;
387 ram_table->dark_neg_gain[0][0] = 0x00;
388 ram_table->dark_neg_gain[0][1] = 0x00;
389 ram_table->dark_neg_gain[0][2] = 0x00;
390 ram_table->dark_neg_gain[0][3] = 0x00;
391 ram_table->dark_neg_gain[1][0] = 0x00;
392 ram_table->dark_neg_gain[1][1] = 0x00;
393 ram_table->dark_neg_gain[1][2] = 0x00;
394 ram_table->dark_neg_gain[1][3] = 0x00;
395 ram_table->dark_neg_gain[2][0] = 0x00;
396 ram_table->dark_neg_gain[2][1] = 0x00;
397 ram_table->dark_neg_gain[2][2] = 0x00;
398 ram_table->dark_neg_gain[2][3] = 0x00;
399 ram_table->dark_neg_gain[3][0] = 0x00;
400 ram_table->dark_neg_gain[3][1] = 0x00;
401 ram_table->dark_neg_gain[3][2] = 0x00;
402 ram_table->dark_neg_gain[3][3] = 0x00;
403 ram_table->dark_neg_gain[4][0] = 0x00;
404 ram_table->dark_neg_gain[4][1] = 0x00;
405 ram_table->dark_neg_gain[4][2] = 0x00;
406 ram_table->dark_neg_gain[4][3] = 0x00;
407
408 ram_table->iir_curve[0] = 0x65;
409 ram_table->iir_curve[1] = 0x65;
410 ram_table->iir_curve[2] = 0x65;
411 ram_table->iir_curve[3] = 0x65;
412 ram_table->iir_curve[4] = 0x65;
413
414
415 ram_table->crgb_thresh[0] = cpu_to_be16(0x13b6);
416 ram_table->crgb_thresh[1] = cpu_to_be16(0x1648);
417 ram_table->crgb_thresh[2] = cpu_to_be16(0x18e3);
418 ram_table->crgb_thresh[3] = cpu_to_be16(0x1b41);
419 ram_table->crgb_thresh[4] = cpu_to_be16(0x1d46);
420 ram_table->crgb_thresh[5] = cpu_to_be16(0x1f21);
421 ram_table->crgb_thresh[6] = cpu_to_be16(0x2167);
422 ram_table->crgb_thresh[7] = cpu_to_be16(0x2384);
423 ram_table->crgb_offset[0] = cpu_to_be16(0x2999);
424 ram_table->crgb_offset[1] = cpu_to_be16(0x3999);
425 ram_table->crgb_offset[2] = cpu_to_be16(0x4666);
426 ram_table->crgb_offset[3] = cpu_to_be16(0x5999);
427 ram_table->crgb_offset[4] = cpu_to_be16(0x6333);
428 ram_table->crgb_offset[5] = cpu_to_be16(0x7800);
429 ram_table->crgb_offset[6] = cpu_to_be16(0x8c00);
430 ram_table->crgb_offset[7] = cpu_to_be16(0xa000);
431 ram_table->crgb_slope[0] = cpu_to_be16(0x3147);
432 ram_table->crgb_slope[1] = cpu_to_be16(0x2978);
433 ram_table->crgb_slope[2] = cpu_to_be16(0x23a2);
434 ram_table->crgb_slope[3] = cpu_to_be16(0x1f55);
435 ram_table->crgb_slope[4] = cpu_to_be16(0x1c63);
436 ram_table->crgb_slope[5] = cpu_to_be16(0x1a0f);
437 ram_table->crgb_slope[6] = cpu_to_be16(0x178d);
438 ram_table->crgb_slope[7] = cpu_to_be16(0x15ab);
439
440 fill_backlight_transform_table(
441 params, ram_table);
442 }
443
444 void fill_iram_v_2_2(struct iram_table_v_2_2 *ram_table, struct dmcu_iram_parameters params)
445 {
446 unsigned int set = params.set;
447
448 ram_table->flags = 0x0;
449
450 ram_table->min_abm_backlight =
451 cpu_to_be16(params.min_abm_backlight);
452
453 ram_table->deviation_gain[0] = 0xb3;
454 ram_table->deviation_gain[1] = 0xa8;
455 ram_table->deviation_gain[2] = 0x98;
456 ram_table->deviation_gain[3] = 0x68;
457
458 ram_table->min_reduction[0][0] = min_reduction_table_v_2_2[abm_config[set][0]];
459 ram_table->min_reduction[1][0] = min_reduction_table_v_2_2[abm_config[set][0]];
460 ram_table->min_reduction[2][0] = min_reduction_table_v_2_2[abm_config[set][0]];
461 ram_table->min_reduction[3][0] = min_reduction_table_v_2_2[abm_config[set][0]];
462 ram_table->min_reduction[4][0] = min_reduction_table_v_2_2[abm_config[set][0]];
463 ram_table->max_reduction[0][0] = max_reduction_table_v_2_2[abm_config[set][0]];
464 ram_table->max_reduction[1][0] = max_reduction_table_v_2_2[abm_config[set][0]];
465 ram_table->max_reduction[2][0] = max_reduction_table_v_2_2[abm_config[set][0]];
466 ram_table->max_reduction[3][0] = max_reduction_table_v_2_2[abm_config[set][0]];
467 ram_table->max_reduction[4][0] = max_reduction_table_v_2_2[abm_config[set][0]];
468
469 ram_table->min_reduction[0][1] = min_reduction_table_v_2_2[abm_config[set][1]];
470 ram_table->min_reduction[1][1] = min_reduction_table_v_2_2[abm_config[set][1]];
471 ram_table->min_reduction[2][1] = min_reduction_table_v_2_2[abm_config[set][1]];
472 ram_table->min_reduction[3][1] = min_reduction_table_v_2_2[abm_config[set][1]];
473 ram_table->min_reduction[4][1] = min_reduction_table_v_2_2[abm_config[set][1]];
474 ram_table->max_reduction[0][1] = max_reduction_table_v_2_2[abm_config[set][1]];
475 ram_table->max_reduction[1][1] = max_reduction_table_v_2_2[abm_config[set][1]];
476 ram_table->max_reduction[2][1] = max_reduction_table_v_2_2[abm_config[set][1]];
477 ram_table->max_reduction[3][1] = max_reduction_table_v_2_2[abm_config[set][1]];
478 ram_table->max_reduction[4][1] = max_reduction_table_v_2_2[abm_config[set][1]];
479
480 ram_table->min_reduction[0][2] = min_reduction_table_v_2_2[abm_config[set][2]];
481 ram_table->min_reduction[1][2] = min_reduction_table_v_2_2[abm_config[set][2]];
482 ram_table->min_reduction[2][2] = min_reduction_table_v_2_2[abm_config[set][2]];
483 ram_table->min_reduction[3][2] = min_reduction_table_v_2_2[abm_config[set][2]];
484 ram_table->min_reduction[4][2] = min_reduction_table_v_2_2[abm_config[set][2]];
485 ram_table->max_reduction[0][2] = max_reduction_table_v_2_2[abm_config[set][2]];
486 ram_table->max_reduction[1][2] = max_reduction_table_v_2_2[abm_config[set][2]];
487 ram_table->max_reduction[2][2] = max_reduction_table_v_2_2[abm_config[set][2]];
488 ram_table->max_reduction[3][2] = max_reduction_table_v_2_2[abm_config[set][2]];
489 ram_table->max_reduction[4][2] = max_reduction_table_v_2_2[abm_config[set][2]];
490
491 ram_table->min_reduction[0][3] = min_reduction_table_v_2_2[abm_config[set][3]];
492 ram_table->min_reduction[1][3] = min_reduction_table_v_2_2[abm_config[set][3]];
493 ram_table->min_reduction[2][3] = min_reduction_table_v_2_2[abm_config[set][3]];
494 ram_table->min_reduction[3][3] = min_reduction_table_v_2_2[abm_config[set][3]];
495 ram_table->min_reduction[4][3] = min_reduction_table_v_2_2[abm_config[set][3]];
496 ram_table->max_reduction[0][3] = max_reduction_table_v_2_2[abm_config[set][3]];
497 ram_table->max_reduction[1][3] = max_reduction_table_v_2_2[abm_config[set][3]];
498 ram_table->max_reduction[2][3] = max_reduction_table_v_2_2[abm_config[set][3]];
499 ram_table->max_reduction[3][3] = max_reduction_table_v_2_2[abm_config[set][3]];
500 ram_table->max_reduction[4][3] = max_reduction_table_v_2_2[abm_config[set][3]];
501
502 ram_table->bright_pos_gain[0][0] = 0x20;
503 ram_table->bright_pos_gain[0][1] = 0x20;
504 ram_table->bright_pos_gain[0][2] = 0x20;
505 ram_table->bright_pos_gain[0][3] = 0x20;
506 ram_table->bright_pos_gain[1][0] = 0x20;
507 ram_table->bright_pos_gain[1][1] = 0x20;
508 ram_table->bright_pos_gain[1][2] = 0x20;
509 ram_table->bright_pos_gain[1][3] = 0x20;
510 ram_table->bright_pos_gain[2][0] = 0x20;
511 ram_table->bright_pos_gain[2][1] = 0x20;
512 ram_table->bright_pos_gain[2][2] = 0x20;
513 ram_table->bright_pos_gain[2][3] = 0x20;
514 ram_table->bright_pos_gain[3][0] = 0x20;
515 ram_table->bright_pos_gain[3][1] = 0x20;
516 ram_table->bright_pos_gain[3][2] = 0x20;
517 ram_table->bright_pos_gain[3][3] = 0x20;
518 ram_table->bright_pos_gain[4][0] = 0x20;
519 ram_table->bright_pos_gain[4][1] = 0x20;
520 ram_table->bright_pos_gain[4][2] = 0x20;
521 ram_table->bright_pos_gain[4][3] = 0x20;
522
523 ram_table->dark_pos_gain[0][0] = 0x00;
524 ram_table->dark_pos_gain[0][1] = 0x00;
525 ram_table->dark_pos_gain[0][2] = 0x00;
526 ram_table->dark_pos_gain[0][3] = 0x00;
527 ram_table->dark_pos_gain[1][0] = 0x00;
528 ram_table->dark_pos_gain[1][1] = 0x00;
529 ram_table->dark_pos_gain[1][2] = 0x00;
530 ram_table->dark_pos_gain[1][3] = 0x00;
531 ram_table->dark_pos_gain[2][0] = 0x00;
532 ram_table->dark_pos_gain[2][1] = 0x00;
533 ram_table->dark_pos_gain[2][2] = 0x00;
534 ram_table->dark_pos_gain[2][3] = 0x00;
535 ram_table->dark_pos_gain[3][0] = 0x00;
536 ram_table->dark_pos_gain[3][1] = 0x00;
537 ram_table->dark_pos_gain[3][2] = 0x00;
538 ram_table->dark_pos_gain[3][3] = 0x00;
539 ram_table->dark_pos_gain[4][0] = 0x00;
540 ram_table->dark_pos_gain[4][1] = 0x00;
541 ram_table->dark_pos_gain[4][2] = 0x00;
542 ram_table->dark_pos_gain[4][3] = 0x00;
543
544 ram_table->hybrid_factor[0] = 0xff;
545 ram_table->hybrid_factor[1] = 0xff;
546 ram_table->hybrid_factor[2] = 0xff;
547 ram_table->hybrid_factor[3] = 0xc0;
548
549 ram_table->contrast_factor[0] = 0x99;
550 ram_table->contrast_factor[1] = 0x99;
551 ram_table->contrast_factor[2] = 0x90;
552 ram_table->contrast_factor[3] = 0x80;
553
554 ram_table->iir_curve[0] = 0x65;
555 ram_table->iir_curve[1] = 0x65;
556 ram_table->iir_curve[2] = 0x65;
557 ram_table->iir_curve[3] = 0x65;
558 ram_table->iir_curve[4] = 0x65;
559
560
561 ram_table->crgb_thresh[0] = cpu_to_be16(0x127c);
562 ram_table->crgb_thresh[1] = cpu_to_be16(0x151b);
563 ram_table->crgb_thresh[2] = cpu_to_be16(0x17d5);
564 ram_table->crgb_thresh[3] = cpu_to_be16(0x1a56);
565 ram_table->crgb_thresh[4] = cpu_to_be16(0x1c83);
566 ram_table->crgb_thresh[5] = cpu_to_be16(0x1e72);
567 ram_table->crgb_thresh[6] = cpu_to_be16(0x20f0);
568 ram_table->crgb_thresh[7] = cpu_to_be16(0x232b);
569 ram_table->crgb_offset[0] = cpu_to_be16(0x2999);
570 ram_table->crgb_offset[1] = cpu_to_be16(0x3999);
571 ram_table->crgb_offset[2] = cpu_to_be16(0x4666);
572 ram_table->crgb_offset[3] = cpu_to_be16(0x5999);
573 ram_table->crgb_offset[4] = cpu_to_be16(0x6333);
574 ram_table->crgb_offset[5] = cpu_to_be16(0x7800);
575 ram_table->crgb_offset[6] = cpu_to_be16(0x8c00);
576 ram_table->crgb_offset[7] = cpu_to_be16(0xa000);
577 ram_table->crgb_slope[0] = cpu_to_be16(0x3609);
578 ram_table->crgb_slope[1] = cpu_to_be16(0x2dfa);
579 ram_table->crgb_slope[2] = cpu_to_be16(0x27ea);
580 ram_table->crgb_slope[3] = cpu_to_be16(0x235d);
581 ram_table->crgb_slope[4] = cpu_to_be16(0x2042);
582 ram_table->crgb_slope[5] = cpu_to_be16(0x1dc3);
583 ram_table->crgb_slope[6] = cpu_to_be16(0x1b1a);
584 ram_table->crgb_slope[7] = cpu_to_be16(0x1910);
585
586 fill_backlight_transform_table_v_2_2(
587 params, ram_table);
588 }
589
590 void fill_iram_v_2_3(struct iram_table_v_2_2 *ram_table, struct dmcu_iram_parameters params)
591 {
592 unsigned int i, j;
593 unsigned int set = params.set;
594
595 ram_table->flags = 0x0;
596
597 ram_table->min_abm_backlight =
598 cpu_to_be16(params.min_abm_backlight);
599
600 for (i = 0; i < NUM_AGGR_LEVEL; i++) {
601 ram_table->hybrid_factor[i] = abm_settings[set][i].brightness_gain;
602 ram_table->contrast_factor[i] = abm_settings[set][i].contrast_factor;
603 ram_table->deviation_gain[i] = abm_settings[set][i].deviation_gain;
604 ram_table->min_knee[i] = abm_settings[set][i].min_knee;
605 ram_table->max_knee[i] = abm_settings[set][i].max_knee;
606
607 for (j = 0; j < NUM_AMBI_LEVEL; j++) {
608 ram_table->min_reduction[j][i] = abm_settings[set][i].min_reduction;
609 ram_table->max_reduction[j][i] = abm_settings[set][i].max_reduction;
610 ram_table->bright_pos_gain[j][i] = abm_settings[set][i].bright_pos_gain;
611 ram_table->dark_pos_gain[j][i] = abm_settings[set][i].dark_pos_gain;
612 }
613 }
614
615 ram_table->iir_curve[0] = 0x65;
616 ram_table->iir_curve[1] = 0x65;
617 ram_table->iir_curve[2] = 0x65;
618 ram_table->iir_curve[3] = 0x65;
619 ram_table->iir_curve[4] = 0x65;
620
621
622 ram_table->crgb_thresh[0] = cpu_to_be16(0x127c);
623 ram_table->crgb_thresh[1] = cpu_to_be16(0x151b);
624 ram_table->crgb_thresh[2] = cpu_to_be16(0x17d5);
625 ram_table->crgb_thresh[3] = cpu_to_be16(0x1a56);
626 ram_table->crgb_thresh[4] = cpu_to_be16(0x1c83);
627 ram_table->crgb_thresh[5] = cpu_to_be16(0x1e72);
628 ram_table->crgb_thresh[6] = cpu_to_be16(0x20f0);
629 ram_table->crgb_thresh[7] = cpu_to_be16(0x232b);
630 ram_table->crgb_offset[0] = cpu_to_be16(0x2999);
631 ram_table->crgb_offset[1] = cpu_to_be16(0x3999);
632 ram_table->crgb_offset[2] = cpu_to_be16(0x4666);
633 ram_table->crgb_offset[3] = cpu_to_be16(0x5999);
634 ram_table->crgb_offset[4] = cpu_to_be16(0x6333);
635 ram_table->crgb_offset[5] = cpu_to_be16(0x7800);
636 ram_table->crgb_offset[6] = cpu_to_be16(0x8c00);
637 ram_table->crgb_offset[7] = cpu_to_be16(0xa000);
638 ram_table->crgb_slope[0] = cpu_to_be16(0x3609);
639 ram_table->crgb_slope[1] = cpu_to_be16(0x2dfa);
640 ram_table->crgb_slope[2] = cpu_to_be16(0x27ea);
641 ram_table->crgb_slope[3] = cpu_to_be16(0x235d);
642 ram_table->crgb_slope[4] = cpu_to_be16(0x2042);
643 ram_table->crgb_slope[5] = cpu_to_be16(0x1dc3);
644 ram_table->crgb_slope[6] = cpu_to_be16(0x1b1a);
645 ram_table->crgb_slope[7] = cpu_to_be16(0x1910);
646
647 fill_backlight_transform_table_v_2_2(
648 params, ram_table);
649 }
650
651 bool dmcu_load_iram(struct dmcu *dmcu,
652 struct dmcu_iram_parameters params)
653 {
654 unsigned char ram_table[IRAM_SIZE];
655 bool result = false;
656
657 if (dmcu == NULL)
658 return false;
659
660 if (!dmcu->funcs->is_dmcu_initialized(dmcu))
661 return true;
662
663 memset(&ram_table, 0, sizeof(ram_table));
664
665 if (dmcu->dmcu_version.abm_version == 0x23) {
666 fill_iram_v_2_3((struct iram_table_v_2_2 *)ram_table, params);
667
668 result = dmcu->funcs->load_iram(
669 dmcu, 0, (char *)(&ram_table), IRAM_RESERVE_AREA_START_V2_2);
670 } else if (dmcu->dmcu_version.abm_version == 0x22) {
671 fill_iram_v_2_2((struct iram_table_v_2_2 *)ram_table, params);
672
673 result = dmcu->funcs->load_iram(
674 dmcu, 0, (char *)(&ram_table), IRAM_RESERVE_AREA_START_V2_2);
675 } else {
676 fill_iram_v_2((struct iram_table_v_2 *)ram_table, params);
677
678 result = dmcu->funcs->load_iram(
679 dmcu, 0, (char *)(&ram_table), IRAM_RESERVE_AREA_START_V2);
680
681 if (result)
682 result = dmcu->funcs->load_iram(
683 dmcu, IRAM_RESERVE_AREA_END_V2 + 1,
684 (char *)(&ram_table) + IRAM_RESERVE_AREA_END_V2 + 1,
685 sizeof(ram_table) - IRAM_RESERVE_AREA_END_V2 - 1);
686 }
687
688 return result;
689 }