blob: c8cf833f308836aa9205f4ed2148e41075b83c29 [file] [log] [blame]
Stefan Bosch87088142020-07-10 19:07:33 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2016 Nexell Co., Ltd.
4 *
5 * Author: junghyun, kim <jhkim@nexell.co.kr>
6 */
7
8#include <linux/types.h>
9#include <linux/io.h>
10
11#include "s5pxx18_soc_mlc.h"
12
13static struct {
14 struct nx_mlc_register_set *pregister;
15} __g_module_variables[NUMBER_OF_MLC_MODULE] = { { NULL, },};
16
17int nx_mlc_initialize(void)
18{
19 static int binit;
20 u32 i;
21
22 if (binit == 0) {
23 for (i = 0; i < NUMBER_OF_MLC_MODULE; i++)
24 __g_module_variables[i].pregister = NULL;
25 binit = 1;
26 }
27 return 1;
28}
29
30u32 nx_mlc_get_physical_address(u32 module_index)
31{
32 const u32 physical_addr[] = PHY_BASEADDR_MLC_LIST;
33
34 return physical_addr[module_index];
35}
36
37void nx_mlc_set_base_address(u32 module_index, void *base_address)
38{
39 __g_module_variables[module_index].pregister =
40 (struct nx_mlc_register_set *)base_address;
41}
42
43void *nx_mlc_get_base_address(u32 module_index)
44{
45 return (void *)__g_module_variables[module_index].pregister;
46}
47
48void nx_mlc_set_clock_pclk_mode(u32 module_index, enum nx_pclkmode mode)
49{
50 const u32 pclkmode_pos = 3;
51 u32 clkmode = 0;
52
53 register u32 regvalue;
54 register struct nx_mlc_register_set *pregister;
55
56 pregister = __g_module_variables[module_index].pregister;
57 switch (mode) {
58 case nx_pclkmode_dynamic:
59 clkmode = 0;
60 break;
61 case nx_pclkmode_always:
62 clkmode = 1;
63 break;
64 default:
65 break;
66 }
67 regvalue = pregister->mlcclkenb;
68 regvalue &= ~(1ul << pclkmode_pos);
69 regvalue |= (clkmode & 0x01) << pclkmode_pos;
70
71 writel(regvalue, &pregister->mlcclkenb);
72}
73
74enum nx_pclkmode nx_mlc_get_clock_pclk_mode(u32 module_index)
75{
76 const u32 pclkmode_pos = 3;
77
78 if (__g_module_variables[module_index].pregister->mlcclkenb &
79 (1ul << pclkmode_pos)) {
80 return nx_pclkmode_always;
81 }
82 return nx_pclkmode_dynamic;
83}
84
85void nx_mlc_set_clock_bclk_mode(u32 module_index, enum nx_bclkmode mode)
86{
87 register u32 regvalue;
88 register struct nx_mlc_register_set *pregister;
89 u32 clkmode = 0;
90
91 pregister = __g_module_variables[module_index].pregister;
92 switch (mode) {
93 case nx_bclkmode_disable:
94 clkmode = 0;
95 break;
96 case nx_bclkmode_dynamic:
97 clkmode = 2;
98 break;
99 case nx_bclkmode_always:
100 clkmode = 3;
101 break;
102 default:
103 break;
104 }
105 regvalue = pregister->mlcclkenb;
106 regvalue &= ~(0x3);
107 regvalue |= clkmode & 0x3;
108
109 writel(regvalue, &pregister->mlcclkenb);
110}
111
112enum nx_bclkmode nx_mlc_get_clock_bclk_mode(u32 module_index)
113{
114 const u32 bclkmode = 3ul << 0;
115
116 switch (__g_module_variables[module_index].pregister->mlcclkenb &
117 bclkmode) {
118 case 0:
119 return nx_bclkmode_disable;
120 case 2:
121 return nx_bclkmode_dynamic;
122 case 3:
123 return nx_bclkmode_always;
124 }
125 return nx_bclkmode_disable;
126}
127
128void nx_mlc_set_top_power_mode(u32 module_index, int bpower)
129{
130 const u32 pixelbuffer_pwd_pos = 11;
131 const u32 pixelbuffer_pwd_mask = 1ul << pixelbuffer_pwd_pos;
132 const u32 dittyflag_mask = 1ul << 3;
133 register struct nx_mlc_register_set *pregister;
134 register u32 regvalue;
135
136 pregister = __g_module_variables[module_index].pregister;
137 regvalue = pregister->mlccontrolt;
138 regvalue &= ~(pixelbuffer_pwd_mask | dittyflag_mask);
139 regvalue |= (bpower << pixelbuffer_pwd_pos);
140
141 writel(regvalue, &pregister->mlccontrolt);
142}
143
144int nx_mlc_get_top_power_mode(u32 module_index)
145{
146 const u32 pixelbuffer_pwd_pos = 11;
147 const u32 pixelbuffer_pwd_mask = 1ul << pixelbuffer_pwd_pos;
148
149 return (int)((__g_module_variables[module_index].pregister->mlccontrolt
150 & pixelbuffer_pwd_mask) >>
151 pixelbuffer_pwd_pos);
152}
153
154void nx_mlc_set_top_sleep_mode(u32 module_index, int bsleep)
155{
156 const u32 pixelbuffer_sld_pos = 10;
157 const u32 pixelbuffer_sld_mask = 1ul << pixelbuffer_sld_pos;
158 const u32 dittyflag_mask = 1ul << 3;
159 register struct nx_mlc_register_set *pregister;
160 register u32 regvalue;
161
162 bsleep = (int)((u32)bsleep ^ 1);
163 pregister = __g_module_variables[module_index].pregister;
164 regvalue = pregister->mlccontrolt;
165 regvalue &= ~(pixelbuffer_sld_mask | dittyflag_mask);
166 regvalue |= (bsleep << pixelbuffer_sld_pos);
167
168 writel(regvalue, &pregister->mlccontrolt);
169}
170
171int nx_mlc_get_top_sleep_mode(u32 module_index)
172{
173 const u32 pixelbuffer_sld_pos = 11;
174 const u32 pixelbuffer_sld_mask = 1ul << pixelbuffer_sld_pos;
175
176 return (int)(((__g_module_variables[module_index].pregister->mlccontrolt
177 & pixelbuffer_sld_mask) >>
178 pixelbuffer_sld_pos) ^ 0x01);
179}
180
181void nx_mlc_set_top_dirty_flag(u32 module_index)
182{
183 const u32 dirtyflag = 1ul << 3;
184 register struct nx_mlc_register_set *pregister;
185 register u32 regvalue;
186
187 pregister = __g_module_variables[module_index].pregister;
188 regvalue = pregister->mlccontrolt;
189 regvalue |= dirtyflag;
190
191 writel(regvalue, &pregister->mlccontrolt);
192}
193
194int nx_mlc_get_top_dirty_flag(u32 module_index)
195{
196 const u32 dirtyflag_pos = 3;
197 const u32 dirtyflag_mask = 1ul << dirtyflag_pos;
198
199 return (int)((readl(&__g_module_variables[module_index]
200 .pregister->mlccontrolt) &
201 dirtyflag_mask) >> dirtyflag_pos);
202}
203
204void nx_mlc_set_mlc_enable(u32 module_index, int benb)
205{
206 const u32 mlcenb_pos = 1;
207 const u32 mlcenb_mask = 1ul << mlcenb_pos;
208 const u32 dirtyflag_pos = 3;
209 const u32 dirtyflag_mask = 1ul << dirtyflag_pos;
210 register u32 regvalue;
211 register struct nx_mlc_register_set *pregister;
212
213 pregister = __g_module_variables[module_index].pregister;
214 regvalue = pregister->mlccontrolt;
215 regvalue &= ~(mlcenb_mask | dirtyflag_mask);
216 regvalue |= (benb << mlcenb_pos);
217
218 writel(regvalue, &pregister->mlccontrolt);
219}
220
221int nx_mlc_get_mlc_enable(u32 module_index)
222{
223 const u32 mlcenb_pos = 1;
224 const u32 mlcenb_mask = 1ul << mlcenb_pos;
225
226 return (int)((__g_module_variables[module_index].pregister->mlccontrolt
227 & mlcenb_mask) >> mlcenb_pos);
228}
229
230void nx_mlc_set_field_enable(u32 module_index, int benb)
231{
232 const u32 fieldenb_pos = 0;
233 const u32 fieldenb_mask = 1ul << fieldenb_pos;
234 const u32 dirtyflag_pos = 3;
235 const u32 dirtyflag_mask = 1ul << dirtyflag_pos;
236 register u32 regvalue;
237 register struct nx_mlc_register_set *pregister;
238
239 pregister = __g_module_variables[module_index].pregister;
240 regvalue = pregister->mlccontrolt;
241 regvalue &= ~(fieldenb_mask | dirtyflag_mask);
242 regvalue |= (benb << fieldenb_pos);
243
244 writel(regvalue, &pregister->mlccontrolt);
245}
246
247int nx_mlc_get_field_enable(u32 module_index)
248{
249 const u32 fieldenb_pos = 0;
250 const u32 fieldenb_mask = 1ul << fieldenb_pos;
251
252 return (int)(__g_module_variables[module_index].pregister->mlccontrolt &
253 fieldenb_mask);
254}
255
256void nx_mlc_set_layer_priority(u32 module_index, enum nx_mlc_priority priority)
257{
258 const u32 priority_pos = 8;
259 const u32 priority_mask = 0x03 << priority_pos;
260 const u32 dirtyflag_pos = 3;
261 const u32 dirtyflag_mask = 1ul << dirtyflag_pos;
262 register struct nx_mlc_register_set *pregister;
263 register u32 regvalue;
264
265 pregister = __g_module_variables[module_index].pregister;
266 regvalue = pregister->mlccontrolt;
267 regvalue &= ~(priority_mask | dirtyflag_mask);
268 regvalue |= (priority << priority_pos);
269
270 writel(regvalue, &pregister->mlccontrolt);
271}
272
273void nx_mlc_set_screen_size(u32 module_index, u32 width, u32 height)
274{
275 register struct nx_mlc_register_set *pregister;
276 register u32 regvalue;
277
278 pregister = __g_module_variables[module_index].pregister;
279 regvalue = ((height - 1) << 16) | (width - 1);
280
281 writel(regvalue, &pregister->mlcscreensize);
282}
283
284void nx_mlc_get_screen_size(u32 module_index, u32 *pwidth, u32 *pheight)
285{
286 register struct nx_mlc_register_set *pregister;
287
288 pregister = __g_module_variables[module_index].pregister;
289
290 if (pwidth)
291 *pwidth = (pregister->mlcscreensize & 0x0fff) + 1;
292
293 if (pheight)
294 *pheight = ((pregister->mlcscreensize >> 16) & 0x0fff) + 1;
295}
296
297void nx_mlc_set_background(u32 module_index, u32 color)
298{
299 register struct nx_mlc_register_set *pregister;
300
301 pregister = __g_module_variables[module_index].pregister;
302 writel(color, &pregister->mlcbgcolor);
303}
304
305void nx_mlc_set_dirty_flag(u32 module_index, u32 layer)
306{
307 register struct nx_mlc_register_set *pregister;
308 register u32 regvalue;
309 const u32 dirtyflg_mask = 1ul << 4;
310
311 pregister = __g_module_variables[module_index].pregister;
312 if (layer == 0 || layer == 1) {
313 regvalue = pregister->mlcrgblayer[layer].mlccontrol;
314 regvalue |= dirtyflg_mask;
315
316 writel(regvalue, &pregister->mlcrgblayer[layer].mlccontrol);
317 } else if (layer == 3) {
318 regvalue = pregister->mlcvideolayer.mlccontrol;
319 regvalue |= dirtyflg_mask;
320
321 writel(regvalue, &pregister->mlcvideolayer.mlccontrol);
322 }
323}
324
325int nx_mlc_get_dirty_flag(u32 module_index, u32 layer)
326{
327 const u32 dirtyflg_pos = 4;
328 const u32 dirtyflg_mask = 1ul << dirtyflg_pos;
329
330 if (layer == 0 || layer == 1) {
331 return (int)((__g_module_variables[module_index]
332 .pregister->mlcrgblayer[layer]
333 .mlccontrol & dirtyflg_mask) >> dirtyflg_pos);
334 } else if (layer == 2) {
335 return (int)((__g_module_variables[module_index]
336 .pregister->mlcrgblayer2.mlccontrol &
337 dirtyflg_mask) >> dirtyflg_pos);
338 } else if (layer == 3) {
339 return (int)((__g_module_variables[module_index]
340 .pregister->mlcvideolayer.mlccontrol &
341 dirtyflg_mask) >> dirtyflg_pos);
342 }
343 return 0;
344}
345
346void nx_mlc_set_layer_enable(u32 module_index, u32 layer, int benb)
347{
348 const u32 layerenb_pos = 5;
349 const u32 layerenb_mask = 0x01 << layerenb_pos;
350 const u32 dirtyflag_pos = 4;
351 const u32 dirtyflag_mask = 1ul << dirtyflag_pos;
352 register u32 regvalue;
353 register struct nx_mlc_register_set *pregister;
354
355 pregister = __g_module_variables[module_index].pregister;
356 if (layer == 0 || layer == 1) {
357 regvalue = pregister->mlcrgblayer[layer].mlccontrol;
358 regvalue &= ~(layerenb_mask | dirtyflag_mask);
359 regvalue |= (benb << layerenb_pos);
360
361 writel(regvalue, &pregister->mlcrgblayer[layer].mlccontrol);
362 } else if (layer == 3) {
363 regvalue = pregister->mlcvideolayer.mlccontrol;
364 regvalue &= ~(layerenb_mask | dirtyflag_mask);
365 regvalue |= (benb << layerenb_pos);
366
367 writel(regvalue, &pregister->mlcvideolayer.mlccontrol);
368 }
369}
370
371int nx_mlc_get_layer_enable(u32 module_index, u32 layer)
372{
373 const u32 layerenb_pos = 5;
374 const u32 layerenb_mask = 0x01 << layerenb_pos;
375
376 if (layer == 0 || layer == 1) {
377 return (int)((__g_module_variables[module_index]
378 .pregister->mlcrgblayer[layer]
379 .mlccontrol & layerenb_mask) >> layerenb_pos);
380 } else if (layer == 3) {
381 return (int)((__g_module_variables[module_index]
382 .pregister->mlcvideolayer.mlccontrol &
383 layerenb_mask) >> layerenb_pos);
384 }
385 return 0;
386}
387
388void nx_mlc_set_lock_size(u32 module_index, u32 layer, u32 locksize)
389{
390 const u32 locksize_mask = 3ul << 12;
391 const u32 dirtyflag_pos = 4;
392 const u32 dirtyflag_mask = 1ul << dirtyflag_pos;
393 register struct nx_mlc_register_set *pregister;
394 register u32 regvalue;
395
396 pregister = __g_module_variables[module_index].pregister;
397 locksize >>= 3;
398 if (layer == 0 || layer == 1) {
399 regvalue = pregister->mlcrgblayer[layer].mlccontrol;
400 regvalue &= ~(locksize_mask | dirtyflag_mask);
401 regvalue |= (locksize << 12);
402
403 writel(regvalue, &pregister->mlcrgblayer[layer].mlccontrol);
404 }
405}
406
407void nx_mlc_set_alpha_blending(u32 module_index, u32 layer, int benb, u32 alpha)
408{
409 const u32 blendenb_pos = 2;
410 const u32 blendenb_mask = 0x01 << blendenb_pos;
411 const u32 dirtyflag_pos = 4;
412 const u32 dirtyflag_mask = 1ul << dirtyflag_pos;
413 const u32 alpha_pos = 28;
414 const u32 alpha_mask = 0xf << alpha_pos;
415 register u32 regvalue;
416 register struct nx_mlc_register_set *pregister;
417
418 pregister = __g_module_variables[module_index].pregister;
419 if (layer == 0 || layer == 1) {
420 regvalue = pregister->mlcrgblayer[layer].mlccontrol;
421 regvalue &= ~(blendenb_mask | dirtyflag_mask);
422 regvalue |= (benb << blendenb_pos);
423
424 writel(regvalue, &pregister->mlcrgblayer[layer].mlccontrol);
425 regvalue = pregister->mlcrgblayer[layer].mlctpcolor;
426 regvalue &= ~alpha_mask;
427 regvalue |= alpha << alpha_pos;
428
429 writel(regvalue, &pregister->mlcrgblayer[layer].mlctpcolor);
430 } else if (layer == 3) {
431 regvalue = pregister->mlcvideolayer.mlccontrol;
432 regvalue &= ~(blendenb_mask | dirtyflag_mask);
433 regvalue |= (benb << blendenb_pos);
434
435 writel(regvalue, &pregister->mlcvideolayer.mlccontrol);
436
437 writel(alpha << alpha_pos,
438 &pregister->mlcvideolayer.mlctpcolor);
439 }
440}
441
442void nx_mlc_set_transparency(u32 module_index, u32 layer, int benb, u32 color)
443{
444 const u32 tpenb_pos = 0;
445 const u32 tpenb_mask = 0x01 << tpenb_pos;
446 const u32 dirtyflag_pos = 4;
447 const u32 dirtyflag_mask = 1ul << dirtyflag_pos;
448 const u32 tpcolor_pos = 0;
449 const u32 tpcolor_mask = ((1 << 24) - 1) << tpcolor_pos;
450 register u32 regvalue;
451 register struct nx_mlc_register_set *pregister;
452
453 pregister = __g_module_variables[module_index].pregister;
454 if (layer == 0 || layer == 1) {
455 regvalue = pregister->mlcrgblayer[layer].mlccontrol;
456 regvalue &= ~(tpenb_mask | dirtyflag_mask);
457 regvalue |= (benb << tpenb_pos);
458
459 writel(regvalue, &pregister->mlcrgblayer[layer].mlccontrol);
460 regvalue = pregister->mlcrgblayer[layer].mlctpcolor;
461 regvalue &= ~tpcolor_mask;
462 regvalue |= (color & tpcolor_mask);
463
464 writel(regvalue, &pregister->mlcrgblayer[layer].mlctpcolor);
465 }
466}
467
468void nx_mlc_set_color_inversion(u32 module_index, u32 layer, int benb,
469 u32 color)
470{
471 const u32 invenb_pos = 1;
472 const u32 invenb_mask = 0x01 << invenb_pos;
473 const u32 dirtyflag_pos = 4;
474 const u32 dirtyflag_mask = 1ul << dirtyflag_pos;
475 const u32 invcolor_pos = 0;
476 const u32 invcolor_mask = ((1 << 24) - 1) << invcolor_pos;
477 register u32 regvalue;
478 register struct nx_mlc_register_set *pregister;
479
480 pregister = __g_module_variables[module_index].pregister;
481 if (layer == 0 || layer == 1) {
482 regvalue = pregister->mlcrgblayer[layer].mlccontrol;
483 regvalue &= ~(invenb_mask | dirtyflag_mask);
484 regvalue |= (benb << invenb_pos);
485
486 writel(regvalue, &pregister->mlcrgblayer[layer].mlccontrol);
487 regvalue = pregister->mlcrgblayer[layer].mlcinvcolor;
488 regvalue &= ~invcolor_mask;
489 regvalue |= (color & invcolor_mask);
490
491 writel(regvalue, &pregister->mlcrgblayer[layer].mlcinvcolor);
492 }
493}
494
495u32 nx_mlc_get_extended_color(u32 module_index, u32 color,
496 enum nx_mlc_rgbfmt format)
497{
498 u32 rgb[3] = {
499 0,
500 };
501 u32 bw[3] = {
502 0,
503 };
504 u32 bp[3] = {
505 0,
506 };
507 u32 blank = 0;
508 u32 fill = 0;
509 u32 i = 0;
510
511 switch (format) {
512 case nx_mlc_rgbfmt_r5g6b5:
513 bw[0] = 5;
514 bw[1] = 6;
515 bw[2] = 5;
516 bp[0] = 11;
517 bp[1] = 5;
518 bp[2] = 0;
519 break;
520 case nx_mlc_rgbfmt_b5g6r5:
521 bw[0] = 5;
522 bw[1] = 6;
523 bw[2] = 5;
524 bp[0] = 0;
525 bp[1] = 5;
526 bp[2] = 11;
527 break;
528 case nx_mlc_rgbfmt_x1r5g5b5:
529 case nx_mlc_rgbfmt_a1r5g5b5:
530 bw[0] = 5;
531 bw[1] = 5;
532 bw[2] = 5;
533 bp[0] = 10;
534 bp[1] = 5;
535 bp[2] = 0;
536 break;
537 case nx_mlc_rgbfmt_x1b5g5r5:
538 case nx_mlc_rgbfmt_a1b5g5r5:
539 bw[0] = 5;
540 bw[1] = 5;
541 bw[2] = 5;
542 bp[0] = 0;
543 bp[1] = 5;
544 bp[2] = 10;
545 break;
546 case nx_mlc_rgbfmt_x4r4g4b4:
547 case nx_mlc_rgbfmt_a4r4g4b4:
548 bw[0] = 4;
549 bw[1] = 4;
550 bw[2] = 4;
551 bp[0] = 8;
552 bp[1] = 4;
553 bp[2] = 0;
554 break;
555 case nx_mlc_rgbfmt_x4b4g4r4:
556 case nx_mlc_rgbfmt_a4b4g4r4:
557 bw[0] = 4;
558 bw[1] = 4;
559 bw[2] = 4;
560 bp[0] = 0;
561 bp[1] = 4;
562 bp[2] = 8;
563 break;
564 case nx_mlc_rgbfmt_x8r3g3b2:
565 case nx_mlc_rgbfmt_a8r3g3b2:
566 bw[0] = 3;
567 bw[1] = 3;
568 bw[2] = 2;
569 bp[0] = 5;
570 bp[1] = 2;
571 bp[2] = 0;
572 break;
573 case nx_mlc_rgbfmt_x8b3g3r2:
574 case nx_mlc_rgbfmt_a8b3g3r2:
575 bw[0] = 2;
576 bw[1] = 3;
577 bw[2] = 3;
578 bp[0] = 0;
579 bp[1] = 2;
580 bp[2] = 5;
581 break;
582 case nx_mlc_rgbfmt_r8g8b8:
583 case nx_mlc_rgbfmt_a8r8g8b8:
584 bw[0] = 8;
585 bw[1] = 8;
586 bw[2] = 8;
587 bp[0] = 16;
588 bp[1] = 8;
589 bp[2] = 0;
590 break;
591 case nx_mlc_rgbfmt_b8g8r8:
592 case nx_mlc_rgbfmt_a8b8g8r8:
593 bw[0] = 8;
594 bw[1] = 8;
595 bw[2] = 8;
596 bp[0] = 0;
597 bp[1] = 8;
598 bp[2] = 16;
599 break;
600 default:
601 break;
602 }
603 for (i = 0; i < 3; i++) {
604 rgb[i] = (color >> bp[i]) & ((u32)(1 << bw[i]) - 1);
605 fill = bw[i];
606 blank = 8 - fill;
607 rgb[i] <<= blank;
608 while (blank > 0) {
609 rgb[i] |= (rgb[i] >> fill);
610 blank -= fill;
611 fill += fill;
612 }
613 }
614
615 return (rgb[0] << 16) | (rgb[1] << 8) | (rgb[2] << 0);
616}
617
618void nx_mlc_set_format_rgb(u32 module_index, u32 layer,
619 enum nx_mlc_rgbfmt format)
620{
621 const u32 dirtyflag_pos = 4;
622 const u32 dirtyflag_mask = 1ul << dirtyflag_pos;
623 const u32 format_mask = 0xffff0000ul;
624 register u32 regvalue;
625 register struct nx_mlc_register_set *pregister;
626
627 pregister = __g_module_variables[module_index].pregister;
628 if (layer == 0 || layer == 1) {
629 regvalue = pregister->mlcrgblayer[layer].mlccontrol;
630 regvalue &= ~(format_mask | dirtyflag_mask);
631 regvalue |= (u32)format;
632
633 writel(regvalue, &pregister->mlcrgblayer[layer].mlccontrol);
634 }
635}
636
637void nx_mlc_set_format_yuv(u32 module_index, enum nx_mlc_yuvfmt format)
638{
639 const u32 format_mask = 0xffff0000ul;
640 register u32 temp;
641 register struct nx_mlc_register_set *pregister;
642
643 pregister = __g_module_variables[module_index].pregister;
644 temp = pregister->mlcvideolayer.mlccontrol;
645 temp &= ~format_mask;
646 temp |= (u32)format;
647
648 writel(temp, &pregister->mlcvideolayer.mlccontrol);
649}
650
651void nx_mlc_set_position(u32 module_index, u32 layer, s32 sx, s32 sy,
652 s32 ex, s32 ey)
653{
654 register struct nx_mlc_register_set *pregister;
655
656 pregister = __g_module_variables[module_index].pregister;
657 if (layer == 0 || layer == 1) {
658 writel((((u32)sx & 0xffful) << 16) | ((u32)ex & 0xffful),
659 &pregister->mlcrgblayer[layer].mlcleftright);
660
661 writel((((u32)sy & 0xffful) << 16) | ((u32)ey & 0xffful),
662 &pregister->mlcrgblayer[layer].mlctopbottom);
663 } else if (layer == 2) {
664 writel((((u32)sx & 0xffful) << 16) | ((u32)ex & 0xffful),
665 &pregister->mlcrgblayer2.mlcleftright);
666
667 writel((((u32)sy & 0xffful) << 16) | ((u32)ey & 0xffful),
668 &pregister->mlcrgblayer2.mlctopbottom);
669 } else if (layer == 3) {
670 writel((((u32)sx & 0xffful) << 16) | ((u32)ex & 0xffful),
671 &pregister->mlcvideolayer.mlcleftright);
672
673 writel((((u32)sy & 0xffful) << 16) | ((u32)ey & 0xffful),
674 &pregister->mlcvideolayer.mlctopbottom);
675 }
676}
677
678void nx_mlc_set_dither_enable_when_using_gamma(u32 module_index, int benable)
679{
680 const u32 ditherenb_bitpos = 0;
681 const u32 ditherenb_mask = 1 << ditherenb_bitpos;
682 register struct nx_mlc_register_set *pregister;
683 register u32 read_value;
684
685 pregister = __g_module_variables[module_index].pregister;
686 read_value = pregister->mlcgammacont;
687 read_value &= ~ditherenb_mask;
688 read_value |= ((u32)benable << ditherenb_bitpos);
689
690 writel(read_value, &pregister->mlcgammacont);
691}
692
693int nx_mlc_get_dither_enable_when_using_gamma(u32 module_index)
694{
695 const u32 ditherenb_bitpos = 0;
696 const u32 ditherenb_mask = 1 << ditherenb_bitpos;
697
698 return (int)(__g_module_variables[module_index].pregister->mlcgammacont
699 & ditherenb_mask);
700}
701
702void nx_mlc_set_gamma_priority(u32 module_index, int bvideolayer)
703{
704 const u32 alphaselect_bitpos = 5;
705 const u32 alphaselect_mask = 1 << alphaselect_bitpos;
706 register struct nx_mlc_register_set *pregister;
707 register u32 read_value;
708
709 pregister = __g_module_variables[module_index].pregister;
710 read_value = pregister->mlcgammacont;
711 read_value &= ~alphaselect_mask;
712 read_value |= ((u32)bvideolayer << alphaselect_bitpos);
713
714 writel(read_value, &pregister->mlcgammacont);
715}
716
717int nx_mlc_get_gamma_priority(u32 module_index)
718{
719 const u32 alphaselect_bitpos = 5;
720 const u32 alphaselect_mask = 1 << alphaselect_bitpos;
721
722 return (int)((__g_module_variables[module_index].pregister->mlcgammacont
723 & alphaselect_mask) >> alphaselect_bitpos);
724}
725
726void nx_mlc_set_rgblayer_invalid_position(u32 module_index, u32 layer,
727 u32 region, s32 sx, s32 sy,
728 s32 ex, s32 ey, int benb)
729{
730 const u32 invalidenb_pos = 28;
731 register struct nx_mlc_register_set *pregister;
732
733 pregister = __g_module_variables[module_index].pregister;
734 if (layer == 0 || layer == 1) {
735 if (region == 0) {
736 writel(((benb << invalidenb_pos) |
737 ((sx & 0x7ff) << 16) | (ex & 0x7ff)),
738 &pregister->mlcrgblayer[layer]
739 .mlcinvalidleftright0);
740
741 writel((((sy & 0x7ff) << 16) | (ey & 0x7ff)),
742 &pregister->mlcrgblayer[layer]
743 .mlcinvalidtopbottom0);
744 } else {
745 writel(((benb << invalidenb_pos) |
746 ((sx & 0x7ff) << 16) | (ex & 0x7ff)),
747 &pregister->mlcrgblayer[layer]
748 .mlcinvalidleftright1);
749
750 writel((((sy & 0x7ff) << 16) | (ey & 0x7ff)),
751 &pregister->mlcrgblayer[layer]
752 .mlcinvalidtopbottom1);
753 }
754 }
755}
756
757void nx_mlc_set_rgblayer_stride(u32 module_index, u32 layer, s32 hstride,
758 s32 vstride)
759{
760 register struct nx_mlc_register_set *pregister;
761
762 pregister = __g_module_variables[module_index].pregister;
763 if (layer == 0 || layer == 1) {
764 writel(hstride, &pregister->mlcrgblayer[layer].mlchstride);
765 writel(vstride, &pregister->mlcrgblayer[layer].mlcvstride);
766 } else if (layer == 2) {
767 writel(hstride, &pregister->mlcrgblayer2.mlchstride);
768 writel(vstride, &pregister->mlcrgblayer2.mlcvstride);
769 }
770}
771
772void nx_mlc_set_rgblayer_address(u32 module_index, u32 layer, u32 addr)
773{
774 register struct nx_mlc_register_set *pregister;
775
776 pregister = __g_module_variables[module_index].pregister;
777 if (layer == 0 || layer == 1)
778 writel(addr, &pregister->mlcrgblayer[layer].mlcaddress);
779 else if (layer == 2)
780 writel(addr, &pregister->mlcrgblayer2.mlcaddress);
781}
782
783void nx_mlc_set_rgblayer_gama_table_power_mode(u32 module_index, int bred,
784 int bgreen, int bblue)
785{
786 const u32 bgammatable_pwd_bitpos = 11;
787 const u32 ggammatable_pwd_bitpos = 9;
788 const u32 rgammatable_pwd_bitpos = 3;
789 const u32 bgammatable_pwd_mask = (1 << bgammatable_pwd_bitpos);
790 const u32 ggammatable_pwd_mask = (1 << ggammatable_pwd_bitpos);
791 const u32 rgammatable_pwd_mask = (1 << rgammatable_pwd_bitpos);
792 register u32 read_value;
793 register struct nx_mlc_register_set *pregister;
794
795 pregister = __g_module_variables[module_index].pregister;
796 read_value = pregister->mlcgammacont;
797 read_value &= ~(bgammatable_pwd_mask | ggammatable_pwd_mask |
798 rgammatable_pwd_mask);
799 read_value |= (((u32)bred << rgammatable_pwd_bitpos) |
800 ((u32)bgreen << ggammatable_pwd_bitpos) |
801 ((u32)bblue << bgammatable_pwd_bitpos));
802
803 writel(read_value, &pregister->mlcgammacont);
804}
805
806void nx_mlc_get_rgblayer_gama_table_power_mode(u32 module_index, int *pbred,
807 int *pbgreen, int *pbblue)
808{
809 const u32 bgammatable_pwd_bitpos = 11;
810 const u32 ggammatable_pwd_bitpos = 9;
811 const u32 rgammatable_pwd_bitpos = 3;
812 const u32 bgammatable_pwd_mask = (1 << bgammatable_pwd_bitpos);
813 const u32 ggammatable_pwd_mask = (1 << ggammatable_pwd_bitpos);
814 const u32 rgammatable_pwd_mask = (1 << rgammatable_pwd_bitpos);
815 register u32 read_value;
816 register struct nx_mlc_register_set *pregister;
817
818 pregister = __g_module_variables[module_index].pregister;
819 read_value = pregister->mlcgammacont;
820 if (pbred)
821 *pbred = (read_value & rgammatable_pwd_mask) ? 1 : 0;
822
823 if (pbgreen)
824 *pbgreen = (read_value & ggammatable_pwd_mask) ? 1 : 0;
825
826 if (pbblue)
827 *pbblue = (read_value & bgammatable_pwd_mask) ? 1 : 0;
828}
829
830void nx_mlc_set_rgblayer_gama_table_sleep_mode(u32 module_index, int bred,
831 int bgreen, int bblue)
832{
833 const u32 bgammatable_sld_bitpos = 10;
834 const u32 ggammatable_sld_bitpos = 8;
835 const u32 rgammatable_sld_bitpos = 2;
836 const u32 bgammatable_sld_mask = (1 << bgammatable_sld_bitpos);
837 const u32 ggammatable_sld_mask = (1 << ggammatable_sld_bitpos);
838 const u32 rgammatable_sld_mask = (1 << rgammatable_sld_bitpos);
839 register u32 read_value;
840 register struct nx_mlc_register_set *pregister;
841
842 pregister = __g_module_variables[module_index].pregister;
843 read_value = pregister->mlcgammacont;
844 if (bred)
845 read_value &= ~rgammatable_sld_mask;
846 else
847 read_value |= rgammatable_sld_mask;
848
849 if (bgreen)
850 read_value &= ~ggammatable_sld_mask;
851 else
852 read_value |= ggammatable_sld_mask;
853
854 if (bblue)
855 read_value &= ~bgammatable_sld_mask;
856 else
857 read_value |= bgammatable_sld_mask;
858
859 writel(read_value, &pregister->mlcgammacont);
860}
861
862void nx_mlc_get_rgblayer_gama_table_sleep_mode(u32 module_index, int *pbred,
863 int *pbgreen, int *pbblue)
864{
865 const u32 bgammatable_sld_bitpos = 10;
866 const u32 ggammatable_sld_bitpos = 8;
867 const u32 rgammatable_sld_bitpos = 2;
868 const u32 bgammatable_sld_mask = (1 << bgammatable_sld_bitpos);
869 const u32 ggammatable_sld_mask = (1 << ggammatable_sld_bitpos);
870 const u32 rgammatable_sld_mask = (1 << rgammatable_sld_bitpos);
871 register u32 read_value;
872 register struct nx_mlc_register_set *pregister;
873
874 pregister = __g_module_variables[module_index].pregister;
875 read_value = pregister->mlcgammacont;
876
877 if (pbred)
878 *pbred = (read_value & rgammatable_sld_mask) ? 0 : 1;
879
880 if (pbgreen)
881 *pbgreen = (read_value & ggammatable_sld_mask) ? 0 : 1;
882
883 if (pbblue)
884 *pbblue = (read_value & bgammatable_sld_mask) ? 0 : 1;
885}
886
887void nx_mlc_set_rgblayer_rgamma_table(u32 module_index, u32 dwaddress,
888 u32 dwdata)
889{
890 register struct nx_mlc_register_set *pregister;
891 const u32 tableaddr_bitpos = 24;
892
893 pregister = __g_module_variables[module_index].pregister;
894 writel(((dwaddress << tableaddr_bitpos) | dwdata),
895 &pregister->mlcrgammatablewrite);
896}
897
898void nx_mlc_set_rgblayer_ggamma_table(u32 module_index, u32 dwaddress,
899 u32 dwdata)
900{
901 register struct nx_mlc_register_set *pregister;
902 const u32 tableaddr_bitpos = 24;
903
904 pregister = __g_module_variables[module_index].pregister;
905 writel(((dwaddress << tableaddr_bitpos) | dwdata),
906 &pregister->mlcggammatablewrite);
907}
908
909void nx_mlc_set_rgblayer_bgamma_table(u32 module_index, u32 dwaddress,
910 u32 dwdata)
911{
912 register struct nx_mlc_register_set *pregister;
913 const u32 tableaddr_bitpos = 24;
914
915 pregister = __g_module_variables[module_index].pregister;
916 writel(((dwaddress << tableaddr_bitpos) | dwdata),
917 &pregister->mlcbgammatablewrite);
918}
919
920void nx_mlc_set_rgblayer_gamma_enable(u32 module_index, int benable)
921{
922 const u32 rgbgammaemb_bitpos = 1;
923 const u32 rgbgammaemb_mask = 1 << rgbgammaemb_bitpos;
924 register u32 read_value;
925 register struct nx_mlc_register_set *pregister;
926
927 pregister = __g_module_variables[module_index].pregister;
928 read_value = pregister->mlcgammacont;
929 read_value &= ~rgbgammaemb_mask;
930 read_value |= (u32)benable << rgbgammaemb_bitpos;
931
932 writel(read_value, &pregister->mlcgammacont);
933}
934
935int nx_mlc_get_rgblayer_gamma_enable(u32 module_index)
936{
937 const u32 rgbgammaemb_bitpos = 1;
938 const u32 rgbgammaemb_mask = 1 << rgbgammaemb_bitpos;
939
940 return (int)((__g_module_variables[module_index].pregister->mlcgammacont
941 & rgbgammaemb_mask) >> rgbgammaemb_bitpos);
942}
943
944void nx_mlc_set_video_layer_stride(u32 module_index, s32 lu_stride,
945 s32 cb_stride, s32 cr_stride)
946{
947 register struct nx_mlc_register_set *pregister;
948
949 pregister = __g_module_variables[module_index].pregister;
950
951 writel(lu_stride, &pregister->mlcvideolayer.mlcvstride);
952 writel(cb_stride, &pregister->mlcvideolayer.mlcvstridecb);
953 writel(cr_stride, &pregister->mlcvideolayer.mlcvstridecr);
954}
955
956void nx_mlc_set_video_layer_address(u32 module_index, u32 lu_addr, u32 cb_addr,
957 u32 cr_addr)
958{
959 register struct nx_mlc_register_set *pregister;
960
961 pregister = __g_module_variables[module_index].pregister;
962 writel(lu_addr, &pregister->mlcvideolayer.mlcaddress);
963 writel(cb_addr, &pregister->mlcvideolayer.mlcaddresscb);
964 writel(cr_addr, &pregister->mlcvideolayer.mlcaddresscr);
965}
966
967void nx_mlc_set_video_layer_address_yuyv(u32 module_index, u32 addr,
968 s32 stride)
969{
970 register struct nx_mlc_register_set *pregister;
971
972 pregister = __g_module_variables[module_index].pregister;
973 writel(addr, &pregister->mlcvideolayer.mlcaddress);
974 writel(stride, &pregister->mlcvideolayer.mlcvstride);
975}
976
977void nx_mlc_set_video_layer_scale_factor(u32 module_index, u32 hscale,
978 u32 vscale, int bhlumaenb,
979 int bhchromaenb, int bvlumaenb,
980 int bvchromaenb)
981{
982 const u32 filter_luma_pos = 28;
983 const u32 filter_choma_pos = 29;
984 const u32 scale_mask = ((1 << 23) - 1);
985 register struct nx_mlc_register_set *pregister;
986
987 pregister = __g_module_variables[module_index].pregister;
988
989 writel(((bhlumaenb << filter_luma_pos) |
990 (bhchromaenb << filter_choma_pos) | (hscale & scale_mask)),
991 &pregister->mlcvideolayer.mlchscale);
992
993 writel(((bvlumaenb << filter_luma_pos) |
994 (bvchromaenb << filter_choma_pos) | (vscale & scale_mask)),
995 &pregister->mlcvideolayer.mlcvscale);
996}
997
998void nx_mlc_set_video_layer_scale_filter(u32 module_index, int bhlumaenb,
999 int bhchromaenb, int bvlumaenb,
1000 int bvchromaenb)
1001{
1002 const u32 filter_luma_pos = 28;
1003 const u32 filter_choma_pos = 29;
1004 const u32 scale_mask = ((1 << 23) - 1);
1005 register struct nx_mlc_register_set *pregister;
1006 register u32 read_value;
1007
1008 pregister = __g_module_variables[module_index].pregister;
1009 read_value = pregister->mlcvideolayer.mlchscale;
1010 read_value &= scale_mask;
1011 read_value |=
1012 (bhlumaenb << filter_luma_pos) | (bhchromaenb << filter_choma_pos);
1013
1014 writel(read_value, &pregister->mlcvideolayer.mlchscale);
1015 read_value = pregister->mlcvideolayer.mlcvscale;
1016 read_value &= scale_mask;
1017 read_value |=
1018 (bvlumaenb << filter_luma_pos) | (bvchromaenb << filter_choma_pos);
1019
1020 writel(read_value, &pregister->mlcvideolayer.mlcvscale);
1021}
1022
1023void nx_mlc_get_video_layer_scale_filter(u32 module_index, int *bhlumaenb,
1024 int *bhchromaenb, int *bvlumaenb,
1025 int *bvchromaenb)
1026{
1027 const u32 filter_luma_pos = 28;
1028 const u32 filter_choma_pos = 29;
1029 const u32 filter_mask = 1ul;
1030 register struct nx_mlc_register_set *pregister;
1031 register u32 read_value;
1032
1033 pregister = __g_module_variables[module_index].pregister;
1034 read_value = pregister->mlcvideolayer.mlchscale;
1035 *bhlumaenb = (read_value >> filter_luma_pos) & filter_mask;
1036 *bhchromaenb = (read_value >> filter_choma_pos) & filter_mask;
1037 read_value = pregister->mlcvideolayer.mlcvscale;
1038 *bvlumaenb = (read_value >> filter_luma_pos) & filter_mask;
1039 *bvchromaenb = (read_value >> filter_choma_pos) & filter_mask;
1040}
1041
1042void nx_mlc_set_video_layer_scale(u32 module_index, u32 sw, u32 sh, u32 dw,
1043 u32 dh, int bhlumaenb, int bhchromaenb,
1044 int bvlumaenb, int bvchromaenb)
1045{
1046 const u32 filter_luma_pos = 28;
1047 const u32 filter_choma_pos = 29;
1048 const u32 scale_mask = ((1 << 23) - 1);
1049 register u32 hscale, vscale, cal_sh;
1050 register struct nx_mlc_register_set *pregister;
1051
1052 pregister = __g_module_variables[module_index].pregister;
1053
1054 if ((bhlumaenb || bhchromaenb) && dw > sw) {
1055 sw--;
1056 dw--;
1057 }
1058 hscale = (sw << 11) / dw;
1059
1060 if ((bvlumaenb || bvchromaenb) && dh > sh) {
1061 sh--;
1062 dh--;
1063 vscale = (sh << 11) / dh;
1064
1065 cal_sh = ((vscale * dh) >> 11);
1066 if (sh <= cal_sh)
1067 vscale--;
1068
1069 } else {
1070 vscale = (sh << 11) / dh;
1071 }
1072
1073 writel(((bhlumaenb << filter_luma_pos) |
1074 (bhchromaenb << filter_choma_pos) | (hscale & scale_mask)),
1075 &pregister->mlcvideolayer.mlchscale);
1076
1077 writel(((bvlumaenb << filter_luma_pos) |
1078 (bvchromaenb << filter_choma_pos) | (vscale & scale_mask)),
1079 &pregister->mlcvideolayer.mlcvscale);
1080}
1081
1082void nx_mlc_set_video_layer_luma_enhance(u32 module_index, u32 contrast,
1083 s32 brightness)
1084{
1085 register struct nx_mlc_register_set *pregister;
1086
1087 pregister = __g_module_variables[module_index].pregister;
1088
1089 writel((((u32)brightness & 0xfful) << 8) | contrast,
1090 &pregister->mlcvideolayer.mlcluenh);
1091}
1092
1093void nx_mlc_set_video_layer_chroma_enhance(u32 module_index, u32 quadrant,
1094 s32 cb_a, s32 cb_b,
1095 s32 cr_a, s32 cr_b)
1096{
1097 register struct nx_mlc_register_set *pregister;
1098 register u32 temp;
1099
1100 pregister = __g_module_variables[module_index].pregister;
1101 temp = (((u32)cr_b & 0xfful) << 24) | (((u32)cr_a & 0xfful) << 16) |
1102 (((u32)cb_b & 0xfful) << 8) | (((u32)cb_a & 0xfful) << 0);
1103 if (quadrant > 0) {
1104 writel(temp, &pregister->mlcvideolayer.mlcchenh[quadrant - 1]);
1105 } else {
1106 writel(temp, &pregister->mlcvideolayer.mlcchenh[0]);
1107 writel(temp, &pregister->mlcvideolayer.mlcchenh[1]);
1108 writel(temp, &pregister->mlcvideolayer.mlcchenh[2]);
1109 writel(temp, &pregister->mlcvideolayer.mlcchenh[3]);
1110 }
1111}
1112
1113void nx_mlc_set_video_layer_line_buffer_power_mode(u32 module_index,
1114 int benable)
1115{
1116 const u32 linebuff_pwd_pos = 15;
1117 const u32 linebuff_pwd_mask = 1ul << linebuff_pwd_pos;
1118 const u32 dirtyflag_mask = 1ul << 4;
1119 register u32 regvalue;
1120 register struct nx_mlc_register_set *pregister;
1121
1122 pregister = __g_module_variables[module_index].pregister;
1123 regvalue = pregister->mlcvideolayer.mlccontrol;
1124 regvalue &= ~(linebuff_pwd_mask | dirtyflag_mask);
1125 regvalue |= ((u32)benable << linebuff_pwd_pos);
1126
1127 writel(regvalue, &pregister->mlcvideolayer.mlccontrol);
1128}
1129
1130int nx_mlc_get_video_layer_line_buffer_power_mode(u32 module_index)
1131{
1132 const u32 linebuff_pwd_pos = 15;
1133 const u32 linebuff_pwd_mask = 1ul << linebuff_pwd_pos;
1134
1135 return (int)((__g_module_variables[module_index]
1136 .pregister->mlcvideolayer.mlccontrol &
1137 linebuff_pwd_mask) >> linebuff_pwd_pos);
1138}
1139
1140void nx_mlc_set_video_layer_line_buffer_sleep_mode(u32 module_index,
1141 int benable)
1142{
1143 const u32 linebuff_slmd_pos = 14;
1144 const u32 linebuff_slmd_mask = 1ul << linebuff_slmd_pos;
1145 const u32 dirtyflag_mask = 1ul << 4;
1146 register u32 regvalue;
1147 register struct nx_mlc_register_set *pregister;
1148
1149 benable = (int)((u32)benable ^ 1);
1150 pregister = __g_module_variables[module_index].pregister;
1151 regvalue = pregister->mlcvideolayer.mlccontrol;
1152 regvalue &= ~(linebuff_slmd_mask | dirtyflag_mask);
1153 regvalue |= (benable << linebuff_slmd_pos);
1154
1155 writel(regvalue, &pregister->mlcvideolayer.mlccontrol);
1156}
1157
1158int nx_mlc_get_video_layer_line_buffer_sleep_mode(u32 module_index)
1159{
1160 const u32 linebuff_slmd_pos = 14;
1161 const u32 linebuff_slmd_mask = 1ul << linebuff_slmd_pos;
1162 register struct nx_mlc_register_set *pregister;
1163
1164 pregister = __g_module_variables[module_index].pregister;
1165 if (linebuff_slmd_mask & pregister->mlcvideolayer.mlccontrol)
1166 return 0;
1167 else
1168 return 1;
1169}
1170
1171void nx_mlc_set_video_layer_gama_table_power_mode(u32 module_index, int by,
1172 int bu, int bv)
1173{
1174 const u32 vgammatable_pwd_bitpos = 17;
1175 const u32 ugammatable_pwd_bitpos = 15;
1176 const u32 ygammatable_pwd_bitpos = 13;
1177 const u32 vgammatable_pwd_mask = (1 << vgammatable_pwd_bitpos);
1178 const u32 ugammatable_pwd_mask = (1 << ugammatable_pwd_bitpos);
1179 const u32 ygammatable_pwd_mask = (1 << ygammatable_pwd_bitpos);
1180 register u32 read_value;
1181 register struct nx_mlc_register_set *pregister;
1182
1183 pregister = __g_module_variables[module_index].pregister;
1184 read_value = pregister->mlcgammacont;
1185 read_value &= ~(ygammatable_pwd_mask | ugammatable_pwd_mask |
1186 vgammatable_pwd_mask);
1187 read_value |= (((u32)by << ygammatable_pwd_bitpos) |
1188 ((u32)bu << ugammatable_pwd_bitpos) |
1189 ((u32)bv << vgammatable_pwd_bitpos));
1190
1191 writel(read_value, &pregister->mlcgammacont);
1192}
1193
1194void nx_mlc_get_video_layer_gama_table_power_mode(u32 module_index, int *pby,
1195 int *pbu, int *pbv)
1196{
1197 const u32 vgammatable_pwd_bitpos = 17;
1198 const u32 ugammatable_pwd_bitpos = 15;
1199 const u32 ygammatable_pwd_bitpos = 13;
1200 const u32 vgammatable_pwd_mask = (1 << vgammatable_pwd_bitpos);
1201 const u32 ugammatable_pwd_mask = (1 << ugammatable_pwd_bitpos);
1202 const u32 ygammatable_pwd_mask = (1 << ygammatable_pwd_bitpos);
1203 register u32 read_value;
1204 register struct nx_mlc_register_set *pregister;
1205
1206 pregister = __g_module_variables[module_index].pregister;
1207 read_value = pregister->mlcgammacont;
1208 if (pby)
1209 *pby = (read_value & ygammatable_pwd_mask) ? 1 : 0;
1210
1211 if (pbu)
1212 *pbu = (read_value & ugammatable_pwd_mask) ? 1 : 0;
1213
1214 if (pbv)
1215 *pbv = (read_value & vgammatable_pwd_mask) ? 1 : 0;
1216}
1217
1218void nx_mlc_set_video_layer_gama_table_sleep_mode(u32 module_index, int by,
1219 int bu, int bv)
1220{
1221 const u32 vgammatable_sld_bitpos = 16;
1222 const u32 ugammatable_sld_bitpos = 14;
1223 const u32 ygammatable_sld_bitpos = 12;
1224 const u32 vgammatable_sld_mask = (1 << vgammatable_sld_bitpos);
1225 const u32 ugammatable_sld_mask = (1 << ugammatable_sld_bitpos);
1226 const u32 ygammatable_sld_mask = (1 << ygammatable_sld_bitpos);
1227 register u32 read_value;
1228 register struct nx_mlc_register_set *pregister;
1229
1230 pregister = __g_module_variables[module_index].pregister;
1231 read_value = pregister->mlcgammacont;
1232 if (by)
1233 read_value &= ~ygammatable_sld_mask;
1234 else
1235 read_value |= ygammatable_sld_mask;
1236
1237 if (bu)
1238 read_value &= ~ugammatable_sld_mask;
1239 else
1240 read_value |= ugammatable_sld_mask;
1241
1242 if (bv)
1243 read_value &= ~vgammatable_sld_mask;
1244 else
1245 read_value |= vgammatable_sld_mask;
1246
1247 writel(read_value, &pregister->mlcgammacont);
1248}
1249
1250void nx_mlc_get_video_layer_gama_table_sleep_mode(u32 module_index, int *pby,
1251 int *pbu, int *pbv)
1252{
1253 const u32 vgammatable_sld_bitpos = 16;
1254 const u32 ugammatable_sld_bitpos = 14;
1255 const u32 ygammatable_sld_bitpos = 12;
1256 const u32 vgammatable_sld_mask = (1 << vgammatable_sld_bitpos);
1257 const u32 ugammatable_sld_mask = (1 << ugammatable_sld_bitpos);
1258 const u32 ygammatable_sld_mask = (1 << ygammatable_sld_bitpos);
1259 register u32 read_value;
1260 register struct nx_mlc_register_set *pregister;
1261
1262 pregister = __g_module_variables[module_index].pregister;
1263 read_value = pregister->mlcgammacont;
1264
1265 if (pby)
1266 *pby = (read_value & vgammatable_sld_mask) ? 0 : 1;
1267
1268 if (pbu)
1269 *pbu = (read_value & ugammatable_sld_mask) ? 0 : 1;
1270
1271 if (pbv)
1272 *pbv = (read_value & ygammatable_sld_mask) ? 0 : 1;
1273}
1274
1275void nx_mlc_set_video_layer_gamma_enable(u32 module_index, int benable)
1276{
1277 const u32 yuvgammaemb_bitpos = 4;
1278 const u32 yuvgammaemb_mask = 1 << yuvgammaemb_bitpos;
1279 register u32 read_value;
1280 register struct nx_mlc_register_set *pregister;
1281
1282 pregister = __g_module_variables[module_index].pregister;
1283 read_value = pregister->mlcgammacont;
1284 read_value &= ~yuvgammaemb_mask;
1285 read_value |= (u32)benable << yuvgammaemb_bitpos;
1286
1287 writel(read_value, &pregister->mlcgammacont);
1288}
1289
1290int nx_mlc_get_video_layer_gamma_enable(u32 module_index)
1291{
1292 const u32 yuvgammaemb_bitpos = 4;
1293 const u32 yuvgammaemb_mask = 1 << yuvgammaemb_bitpos;
1294
1295 return (int)((__g_module_variables[module_index].pregister->mlcgammacont
1296 & yuvgammaemb_mask) >> yuvgammaemb_bitpos);
1297}
1298
1299void nx_mlc_set_gamma_table_poweroff(u32 module_index, int enb)
1300{
1301 register struct nx_mlc_register_set *pregister;
1302 u32 regvalue;
1303
1304 pregister = __g_module_variables[module_index].pregister;
1305 if (enb == 1) {
1306 regvalue = pregister->mlcgammacont;
1307 regvalue = regvalue & 0xf3;
1308 writel(regvalue, &pregister->mlcgammacont);
1309 }
1310}
1311
1312void nx_mlc_set_mlctop_control_parameter(u32 module_index, int field_enable,
1313 int mlcenable, u8 priority,
1314 enum g3daddrchangeallowed
1315 g3daddr_change_allowed)
1316{
1317 register u32 mlctopcontrolreg;
1318 register struct nx_mlc_register_set *pregister;
1319
1320 pregister = __g_module_variables[module_index].pregister;
1321 mlctopcontrolreg = (readl(&pregister->mlccontrolt)) & 0xfffffcfc;
1322 mlctopcontrolreg = (u32)(mlctopcontrolreg |
1323 ((priority << 8) | ((mlcenable == 1) << 1) |
1324 (1 ==
1325 field_enable)) | (g3daddr_change_allowed <<
1326 12));
1327 writel(mlctopcontrolreg, &pregister->mlccontrolt);
1328}
1329
1330void nx_mlc_set_rgb0layer_control_parameter(u32 module_index, int layer_enable,
1331 int grp3denable, int tp_enable,
1332 u32 transparency_color,
1333 int inv_enable, u32 inverse_color,
1334 int blend_enable, u8 alpha_value,
1335 enum mlc_rgbfmt rbgformat,
1336 enum locksizesel lock_size_select)
1337{
1338 u32 layer_format;
1339 u32 control_enb;
1340 u32 alpha_argument;
1341 u32 lock_size = (u32)(lock_size_select & 0x3);
1342 u32 rgb0controlreg;
1343 u32 regvalue;
1344 register struct nx_mlc_register_set *pregister;
1345
1346 layer_format = nx_mlc_get_rgbformat(rbgformat);
1347 pregister = __g_module_variables[module_index].pregister;
1348 control_enb =
1349 (u32)((grp3denable << 8) | (layer_enable << 5) |
1350 (blend_enable << 2) | (inv_enable << 1) | tp_enable) & 0x127;
1351 alpha_argument = (u32)(alpha_value & 0xf);
1352
1353 rgb0controlreg = readl(&pregister->mlcrgblayer[0].mlccontrol) & 0x10;
1354 regvalue =
1355 (u32)(((layer_format << 16) | control_enb | (lock_size << 12)) |
1356 rgb0controlreg);
1357 writel(regvalue, &pregister->mlcrgblayer[0].mlccontrol);
1358
1359 regvalue = (u32)((alpha_argument << 28) | transparency_color);
1360 writel(regvalue, &pregister->mlcrgblayer[0].mlctpcolor);
1361 regvalue = inverse_color;
1362 writel(regvalue, &pregister->mlcrgblayer[0].mlcinvcolor);
1363}
1364
1365u32 nx_mlc_get_rgbformat(enum mlc_rgbfmt rbgformat)
1366{
1367 u32 rgbformatvalue;
1368 const u32 format_table[] = {
1369 0x4432ul, 0x4342ul, 0x4211ul, 0x4120ul, 0x4003ul, 0x4554ul,
1370 0x3342ul, 0x2211ul, 0x1120ul, 0x1003ul, 0x4653ul, 0x4653ul,
1371 0x0653ul, 0x4ed3ul, 0x4f84ul, 0xc432ul, 0xc342ul, 0xc211ul,
1372 0xc120ul, 0xb342ul, 0xa211ul, 0x9120ul, 0xc653ul, 0xc653ul,
1373 0x8653ul, 0xced3ul, 0xcf84ul, 0x443aul
1374 };
1375
1376 return rgbformatvalue = format_table[rbgformat];
1377}
1378
1379void nx_mlc_set_rgb1layer_control_parameter(u32 module_index, int layer_enable,
1380 int grp3denable, int tp_enable,
1381 u32 transparency_color,
1382 int inv_enable, u32 inverse_color,
1383 int blend_enable, u8 alpha_value,
1384 enum mlc_rgbfmt rbgformat,
1385 enum locksizesel lock_size_select)
1386{
1387 u32 layer_format;
1388 u32 control_enb;
1389 u32 alpha_argument;
1390 u32 lock_size = (u32)(lock_size_select & 0x3);
1391 u32 rgb0controlreg;
1392 u32 regvalue;
1393 register struct nx_mlc_register_set *pregister;
1394
1395 layer_format = nx_mlc_get_rgbformat(rbgformat);
1396 pregister = __g_module_variables[module_index].pregister;
1397
1398 rgb0controlreg = readl(&pregister->mlcrgblayer[1].mlccontrol) & 0x10;
1399 control_enb =
1400 (u32)((grp3denable << 8) | (layer_enable << 5) |
1401 (blend_enable << 2) | (inv_enable << 1) | tp_enable) & 0x127;
1402 alpha_argument = (u32)(alpha_value & 0xf);
1403 regvalue =
1404 (u32)(((layer_format << 16) | control_enb | (lock_size << 12)) |
1405 rgb0controlreg);
1406 writel(regvalue, &pregister->mlcrgblayer[1].mlccontrol);
1407 regvalue = (u32)((alpha_argument << 28) | transparency_color);
1408 writel(regvalue, &pregister->mlcrgblayer[1].mlctpcolor);
1409 regvalue = inverse_color;
1410 writel(regvalue, &pregister->mlcrgblayer[1].mlcinvcolor);
1411}
1412
1413void nx_mlc_set_rgb2layer_control_parameter(u32 module_index, int layer_enable,
1414 int grp3denable, int tp_enable,
1415 u32 transparency_color,
1416 int inv_enable, u32 inverse_color,
1417 int blend_enable, u8 alpha_value,
1418 enum mlc_rgbfmt rbgformat,
1419 enum locksizesel lock_size_select)
1420{
1421 u32 layer_format;
1422 u32 control_enb;
1423 u32 alpha_argument;
1424 u32 lock_size = (u32)(lock_size_select & 0x3);
1425 u32 rgb0controlreg;
1426 u32 regvalue;
1427 register struct nx_mlc_register_set *pregister;
1428
1429 layer_format = nx_mlc_get_rgbformat(rbgformat);
1430 pregister = __g_module_variables[module_index].pregister;
1431
1432 rgb0controlreg = readl(&pregister->mlcrgblayer2.mlccontrol) & 0x10;
1433 control_enb =
1434 (u32)((grp3denable << 8) | (layer_enable << 5) |
1435 (blend_enable << 2) | (inv_enable << 1) | tp_enable) & 0x127;
1436 alpha_argument = (u32)(alpha_value & 0xf);
1437 regvalue =
1438 (u32)(((layer_format << 16) | control_enb | (lock_size << 12)) |
1439 rgb0controlreg);
1440 writel(regvalue, &pregister->mlcrgblayer2.mlccontrol);
1441 regvalue = (u32)((alpha_argument << 28) | transparency_color);
1442 writel(regvalue, &pregister->mlcrgblayer2.mlctpcolor);
1443 regvalue = inverse_color;
1444 writel(regvalue, &pregister->mlcrgblayer2.mlcinvcolor);
1445}
1446
1447void nx_mlc_set_video_layer_control_parameter(u32 module_index,
1448 int layer_enable, int tp_enable,
1449 u32 transparency_color,
1450 int inv_enable, u32 inverse_color,
1451 int blend_enable, u8 alpha_value,
1452 enum nx_mlc_yuvfmt yuvformat)
1453{
1454 u32 control_enb;
1455 u32 alpha_argument;
1456 u32 regvalue;
1457 register struct nx_mlc_register_set *pregister;
1458 u32 video_control_reg;
1459
1460 pregister = __g_module_variables[module_index].pregister;
1461
1462 video_control_reg = readl(&pregister->mlcvideolayer.mlccontrol);
1463 control_enb =
1464 (u32)((yuvformat) | (layer_enable << 5) | (blend_enable << 2) |
1465 (inv_enable << 1) | tp_enable) & 0x30027;
1466 alpha_argument = (u32)(alpha_value & 0xf);
1467 regvalue = (u32)(control_enb | video_control_reg);
1468 writel(regvalue, &pregister->mlcvideolayer.mlccontrol);
1469 regvalue = (u32)((alpha_argument << 28) | transparency_color);
1470 writel(regvalue, &pregister->mlcvideolayer.mlctpcolor);
1471 regvalue = (u32)((alpha_argument << 28) | transparency_color);
1472 writel(regvalue, &pregister->mlcvideolayer.mlcinvcolor);
1473}
1474
1475void nx_mlc_set_srammode(u32 module_index, enum latyername layer_name,
1476 enum srammode sram_mode)
1477{
1478 u32 control_reg_value;
1479 register struct nx_mlc_register_set *pregister;
1480
1481 pregister = __g_module_variables[module_index].pregister;
1482 switch (layer_name) {
1483 case topmlc:
1484 control_reg_value = readl(&pregister->mlccontrolt);
1485 writel((u32)(control_reg_value | (sram_mode << 10)),
1486 &pregister->mlccontrolt);
1487 control_reg_value = 0;
1488 break;
1489 case rgb0:
1490 control_reg_value =
1491 readl(&pregister->mlcrgblayer[0].mlccontrol);
1492 writel((u32)(control_reg_value | (sram_mode << 14)),
1493 &pregister->mlcrgblayer[0].mlccontrol);
1494 control_reg_value = 0;
1495 break;
1496 case rgb1:
1497 control_reg_value =
1498 readl(&pregister->mlcrgblayer[1].mlccontrol);
1499 writel((u32)(control_reg_value | (sram_mode << 14)),
1500 &pregister->mlcrgblayer[1].mlccontrol);
1501 control_reg_value = 0;
1502 break;
1503 case rgb2:
1504 control_reg_value = readl(&pregister->mlcrgblayer2.mlccontrol);
1505 writel((u32)(control_reg_value | (sram_mode << 14)),
1506 &pregister->mlcrgblayer2.mlccontrol);
1507 control_reg_value = 0;
1508 break;
1509 case video:
1510 control_reg_value = readl(&pregister->mlcvideolayer.mlccontrol);
1511 writel((u32)(control_reg_value | (sram_mode << 14)),
1512 &pregister->mlcvideolayer.mlccontrol);
1513 control_reg_value = 0;
1514 break;
1515 default:
1516 break;
1517 }
1518}
1519
1520void nx_mlc_set_layer_reg_finish(u32 module_index, enum latyername layer_name)
1521{
1522 u32 control_reg_value;
1523 register struct nx_mlc_register_set *pregister;
1524
1525 pregister = __g_module_variables[module_index].pregister;
1526
1527 switch (layer_name) {
1528 case topmlc:
1529 control_reg_value = readl(&pregister->mlccontrolt);
1530 writel((u32)(control_reg_value | (1ul << 3)),
1531 &pregister->mlccontrolt);
1532 control_reg_value = 0;
1533 break;
1534 case rgb0:
1535 control_reg_value =
1536 readl(&pregister->mlcrgblayer[0].mlccontrol);
1537 writel((u32)(control_reg_value | (1ul << 4)),
1538 &pregister->mlcrgblayer[0].mlccontrol);
1539 control_reg_value = 0;
1540 break;
1541 case rgb1:
1542 control_reg_value =
1543 readl(&pregister->mlcrgblayer[1].mlccontrol);
1544 writel((u32)(control_reg_value | (1ul << 4)),
1545 &pregister->mlcrgblayer[1].mlccontrol);
1546 control_reg_value = 0;
1547 break;
1548 case rgb2:
1549 control_reg_value = readl(&pregister->mlcrgblayer2.mlccontrol);
1550 writel((u32)(control_reg_value | (1ul << 4)),
1551 &pregister->mlcrgblayer2.mlccontrol);
1552 control_reg_value = 0;
1553 break;
1554 case video:
1555 control_reg_value = readl(&pregister->mlcvideolayer.mlccontrol);
1556 writel((u32)(control_reg_value | (1ul << 4)),
1557 &pregister->mlcvideolayer.mlccontrol);
1558 control_reg_value = 0;
1559 break;
1560 default:
1561 break;
1562 }
1563}
1564
1565void nx_mlc_set_video_layer_coordinate(u32 module_index, int vfilterenable,
1566 int hfilterenable, int vfilterenable_c,
1567 int hfilterenable_c,
1568 u16 video_layer_with,
1569 u16 video_layer_height, s16 left,
1570 s16 right, s16 top,
1571 s16 bottom)
1572{
1573 s32 source_width, source_height;
1574 s32 destination_width;
1575 s32 destination_height;
1576 s32 hscale, vscale;
1577 s32 hfilterenb, vfilterenb;
1578 register struct nx_mlc_register_set *pregister;
1579
1580 pregister = __g_module_variables[module_index].pregister;
1581 writel((s32)(((left & 0x0fff) << 16) | (right & 0x0fff)),
1582 &pregister->mlcvideolayer.mlcleftright);
1583 writel((s32)(((top & 0x0fff) << 16) | (bottom & 0x0fff)),
1584 &pregister->mlcvideolayer.mlctopbottom);
1585 source_width = (s32)(video_layer_with - 1);
1586 source_height = (s32)(video_layer_height - 1);
1587 destination_width = (s32)(right - left);
1588 destination_height = (s32)(bottom - top);
1589
1590 hscale =
1591 (s32)((source_width * (1ul << 11) + (destination_width / 2)) /
1592 destination_width);
1593 vscale =
1594 (s32)((source_height * (1ul << 11) +
1595 (destination_height / 2)) / destination_height);
1596
1597 hfilterenb = (u32)(((hfilterenable_c << 29) | (hfilterenable) << 28)) &
1598 0x30000000;
1599 vfilterenb = (u32)(((vfilterenable_c << 29) | (vfilterenable) << 28)) &
1600 0x30000000;
1601 writel((u32)(hfilterenb | (hscale & 0x00ffffff)),
1602 &pregister->mlcvideolayer.mlchscale);
1603 writel((u32)(vfilterenb | (vscale & 0x00ffffff)),
1604 &pregister->mlcvideolayer.mlcvscale);
1605}
1606
1607void nx_mlc_set_video_layer_filter_scale(u32 module_index, u32 hscale,
1608 u32 vscale)
1609{
1610 register struct nx_mlc_register_set *pregister;
1611 u32 mlchscale = 0;
1612 u32 mlcvscale = 0;
1613
1614 pregister = __g_module_variables[module_index].pregister;
1615 mlchscale = readl(&pregister->mlcvideolayer.mlchscale) & (~0x00ffffff);
1616 mlcvscale = readl(&pregister->mlcvideolayer.mlcvscale) & (~0x00ffffff);
1617
1618 writel((u32)(mlchscale | (hscale & 0x00ffffff)),
1619 &pregister->mlcvideolayer.mlchscale);
1620 writel((u32)(mlcvscale | (vscale & 0x00ffffff)),
1621 &pregister->mlcvideolayer.mlcvscale);
1622}
1623
1624void nx_mlc_set_gamma_control_parameter(u32 module_index, int rgbgammaenb,
1625 int yuvgammaenb, int yuvalphaarray,
1626 int dither_enb)
1627{
1628 u32 register_data;
1629 register struct nx_mlc_register_set *pregister;
1630
1631 pregister = __g_module_variables[module_index].pregister;
1632 register_data = readl(&pregister->mlcgammacont);
1633 register_data = (register_data & 0xf0c) |
1634 ((yuvalphaarray << 5) | (yuvgammaenb << 4) |
1635 (rgbgammaenb << 1) | (dither_enb << 0));
1636 writel(register_data, &pregister->mlcgammacont);
1637}
1638
1639void nx_mlc_set_layer_alpha256(u32 module_index, u32 layer, u32 alpha)
1640{
1641 u32 register_data;
1642 register struct nx_mlc_register_set *pregister;
1643
1644 if (alpha < 0)
1645 alpha = 0;
1646 if (alpha > 255)
1647 alpha = 255;
1648
1649 pregister = __g_module_variables[module_index].pregister;
1650 if (layer == 0) {
1651 register_data =
1652 readl(&pregister->mlcrgblayer[0].mlctpcolor) & 0x00ffffff;
1653 register_data = register_data | (alpha << 24);
1654 writel(register_data, &pregister->mlcrgblayer[0].mlctpcolor);
1655 } else if (layer == 1) {
1656 register_data =
1657 readl(&pregister->mlcrgblayer[1].mlctpcolor) & 0x00ffffff;
1658 register_data = register_data | (alpha << 24);
1659 writel(register_data, &pregister->mlcrgblayer[1].mlctpcolor);
1660 } else if (layer == 2) {
1661 register_data =
1662 readl(&pregister->mlcrgblayer[1].mlctpcolor) & 0x00ffffff;
1663 register_data = register_data | (alpha << 24);
1664 writel(register_data, &pregister->mlcrgblayer2.mlctpcolor);
1665 } else {
1666 register_data =
1667 readl(&pregister->mlcvideolayer.mlctpcolor) & 0x00ffffff;
1668 register_data = register_data | (alpha << 24);
1669 writel(register_data, &pregister->mlcvideolayer.mlctpcolor);
1670 }
1671}
1672
1673int nx_mlc_is_under_flow(u32 module_index)
1674{
1675 const u32 underflow_pend_pos = 31;
1676 const u32 underflow_pend_mask = 1ul << underflow_pend_pos;
1677
1678 return (int)((__g_module_variables[module_index].pregister->mlccontrolt
1679 & underflow_pend_mask) >> underflow_pend_pos);
1680}
1681
1682void nx_mlc_set_gamma_table(u32 module_index, int enb,
1683 struct nx_mlc_gamma_table_parameter *p_gammatable)
1684{
1685 register struct nx_mlc_register_set *pregister;
1686 u32 i, regval = 0;
1687
1688 pregister = __g_module_variables[module_index].pregister;
1689 if (enb == 1) {
1690 regval = readl(&pregister->mlcgammacont);
1691
1692 regval = (1 << 11) | (1 << 9) | (1 << 3);
1693 writel(regval, &pregister->mlcgammacont);
1694
1695 regval = regval | (1 << 10) | (1 << 8) | (1 << 2);
1696 writel(regval, &pregister->mlcgammacont);
1697
1698 for (i = 0; i < 256; i++) {
1699 nx_mlc_set_rgblayer_rgamma_table(module_index, i,
1700 p_gammatable->r_table[i]);
1701 nx_mlc_set_rgblayer_ggamma_table(module_index, i,
1702 p_gammatable->g_table[i]);
1703 nx_mlc_set_rgblayer_bgamma_table(module_index, i,
1704 p_gammatable->b_table[i]);
1705 }
1706
1707 regval = regval | (p_gammatable->alphaselect << 5) |
1708 (p_gammatable->yuvgammaenb << 4 |
1709 p_gammatable->allgammaenb << 4) |
1710 (p_gammatable->rgbgammaenb << 1 |
1711 p_gammatable->allgammaenb << 1) |
1712 (p_gammatable->ditherenb << 1);
1713 writel(regval, &pregister->mlcgammacont);
1714 } else {
1715 regval = regval & ~(1 << 10) & ~(1 << 8) & ~(1 << 2);
1716 writel(regval, &pregister->mlcgammacont);
1717
1718 regval = regval & ~(1 << 11) & ~(1 << 9) & ~(1 << 3);
1719 writel(regval, &pregister->mlcgammacont);
1720 }
1721}
1722
1723void nx_mlc_get_rgblayer_stride(u32 module_index, u32 layer, s32 *hstride,
1724 s32 *vstride)
1725{
1726 unsigned int hs, vs;
1727 register struct nx_mlc_register_set *pregister;
1728
1729 pregister = __g_module_variables[module_index].pregister;
1730
1731 hs = readl(&pregister->mlcrgblayer[layer].mlchstride);
1732 vs = readl(&pregister->mlcrgblayer[layer].mlcvstride);
1733
1734 if (hstride)
1735 *(s32 *)hstride = hs;
1736
1737 if (vstride)
1738 *(s32 *)vstride = vs;
1739}
1740
1741void nx_mlc_get_rgblayer_address(u32 module_index, u32 layer,
1742 u32 *phys_address)
1743{
1744 u32 pa;
1745 register struct nx_mlc_register_set *pregister;
1746
1747 pregister = __g_module_variables[module_index].pregister;
1748 pa = readl(&pregister->mlcrgblayer[layer].mlcaddress);
1749
1750 if (phys_address)
1751 *(u32 *)phys_address = pa;
1752}
1753
1754void nx_mlc_get_position(u32 module_index, u32 layer, int *left, int *top,
1755 int *right, int *bottom)
1756{
1757 int lr, tb;
1758 register struct nx_mlc_register_set *pregister;
1759
1760 pregister = __g_module_variables[module_index].pregister;
1761
1762 lr = readl(&pregister->mlcrgblayer[layer].mlcleftright);
1763 tb = readl(&pregister->mlcrgblayer[layer].mlctopbottom);
1764
1765 if (left)
1766 *(int *)left = ((lr >> 16) & 0xFFUL);
1767
1768 if (top)
1769 *(int *)top = ((tb >> 16) & 0xFFUL);
1770
1771 if (right)
1772 *(int *)right = ((lr >> 0) & 0xFFUL);
1773
1774 if (bottom)
1775 *(int *)bottom = ((tb >> 0) & 0xFFUL);
1776}
1777
1778void nx_mlc_get_video_layer_address_yuyv(u32 module_index, u32 *address,
1779 u32 *stride)
1780{
1781 u32 a, s;
1782 register struct nx_mlc_register_set *pregister;
1783
1784 pregister = __g_module_variables[module_index].pregister;
1785 a = readl(&pregister->mlcvideolayer.mlcaddress);
1786 s = readl(&pregister->mlcvideolayer.mlcvstride);
1787
1788 if (address)
1789 *(u32 *)address = a;
1790
1791 if (stride)
1792 *(u32 *)stride = s;
1793}
1794
1795void nx_mlc_get_video_layer_address(u32 module_index, u32 *lu_address,
1796 u32 *cb_address, u32 *cr_address)
1797{
1798 u32 lua, cba, cra;
1799 register struct nx_mlc_register_set *pregister;
1800
1801 pregister = __g_module_variables[module_index].pregister;
1802
1803 lua = readl(&pregister->mlcvideolayer.mlcaddress);
1804 cba = readl(&pregister->mlcvideolayer.mlcaddresscb);
1805 cra = readl(&pregister->mlcvideolayer.mlcaddresscr);
1806
1807 if (lu_address)
1808 *(u32 *)lu_address = lua;
1809
1810 if (cb_address)
1811 *(u32 *)cb_address = cba;
1812
1813 if (cr_address)
1814 *(u32 *)cr_address = cra;
1815}
1816
1817void nx_mlc_get_video_layer_stride(u32 module_index, u32 *lu_stride,
1818 u32 *cb_stride, u32 *cr_stride)
1819{
1820 u32 lus, cbs, crs;
1821 register struct nx_mlc_register_set *pregister;
1822
1823 pregister = __g_module_variables[module_index].pregister;
1824
1825 lus = readl(&pregister->mlcvideolayer.mlcvstride);
1826 cbs = readl(&pregister->mlcvideolayer.mlcvstridecb);
1827 crs = readl(&pregister->mlcvideolayer.mlcvstridecr);
1828
1829 if (lu_stride)
1830 *(u32 *)lu_stride = lus;
1831
1832 if (cb_stride)
1833 *(u32 *)cb_stride = cbs;
1834
1835 if (cr_stride)
1836 *(u32 *)cr_stride = crs;
1837}
1838
1839void nx_mlc_get_video_position(u32 module_index, int *left, int *top,
1840 int *right, int *bottom)
1841{
1842 int lr, tb;
1843 register struct nx_mlc_register_set *pregister;
1844
1845 pregister = __g_module_variables[module_index].pregister;
1846
1847 lr = readl(&pregister->mlcvideolayer.mlcleftright);
1848 tb = readl(&pregister->mlcvideolayer.mlctopbottom);
1849
1850 if (left)
1851 *(int *)left = ((lr >> 16) & 0xFFUL);
1852
1853 if (top)
1854 *(int *)top = ((tb >> 16) & 0xFFUL);
1855
1856 if (right)
1857 *(int *)right = ((lr >> 0) & 0xFFUL);
1858
1859 if (bottom)
1860 *(int *)bottom = ((tb >> 0) & 0xFFUL);
1861}