2 * linux/drivers/video/omap2/dss/dispc.c
4 * Copyright (C) 2009 Nokia Corporation
5 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
7 * Some code and ideas taken from drivers/video/omap/ driver
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published by
12 * the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
23 #define DSS_SUBSYS_NAME "DISPC"
25 #include <linux/kernel.h>
26 #include <linux/dma-mapping.h>
27 #include <linux/vmalloc.h>
28 #include <linux/clk.h>
30 #include <linux/jiffies.h>
31 #include <linux/seq_file.h>
32 #include <linux/delay.h>
33 #include <linux/workqueue.h>
34 #include <linux/hardirq.h>
36 #include <plat/sram.h>
37 #include <plat/clock.h>
39 #include <plat/display.h>
42 #include "dss_features.h"
45 #define DISPC_BASE 0x48050400
47 #define DISPC_SZ_REGS SZ_4K
49 struct dispc_reg { u16 idx; };
51 #define DISPC_REG(idx) ((const struct dispc_reg) { idx })
54 * DISPC common registers and
55 * DISPC channel registers , ch = 0 for LCD, ch = 1 for
56 * DIGIT, and ch = 2 for LCD2
58 #define DISPC_REVISION DISPC_REG(0x0000)
59 #define DISPC_SYSCONFIG DISPC_REG(0x0010)
60 #define DISPC_SYSSTATUS DISPC_REG(0x0014)
61 #define DISPC_IRQSTATUS DISPC_REG(0x0018)
62 #define DISPC_IRQENABLE DISPC_REG(0x001C)
63 #define DISPC_CONTROL DISPC_REG(0x0040)
64 #define DISPC_CONTROL2 DISPC_REG(0x0238)
65 #define DISPC_CONFIG DISPC_REG(0x0044)
66 #define DISPC_CONFIG2 DISPC_REG(0x0620)
67 #define DISPC_CAPABLE DISPC_REG(0x0048)
68 #define DISPC_DEFAULT_COLOR(ch) DISPC_REG(ch == 0 ? 0x004C : \
69 (ch == 1 ? 0x0050 : 0x03AC))
70 #define DISPC_TRANS_COLOR(ch) DISPC_REG(ch == 0 ? 0x0054 : \
71 (ch == 1 ? 0x0058 : 0x03B0))
72 #define DISPC_LINE_STATUS DISPC_REG(0x005C)
73 #define DISPC_LINE_NUMBER DISPC_REG(0x0060)
74 #define DISPC_TIMING_H(ch) DISPC_REG(ch != 2 ? 0x0064 : 0x0400)
75 #define DISPC_TIMING_V(ch) DISPC_REG(ch != 2 ? 0x0068 : 0x0404)
76 #define DISPC_POL_FREQ(ch) DISPC_REG(ch != 2 ? 0x006C : 0x0408)
77 #define DISPC_DIVISOR(ch) DISPC_REG(ch != 2 ? 0x0070 : 0x040C)
78 #define DISPC_GLOBAL_ALPHA DISPC_REG(0x0074)
79 #define DISPC_SIZE_DIG DISPC_REG(0x0078)
80 #define DISPC_SIZE_LCD(ch) DISPC_REG(ch != 2 ? 0x007C : 0x03CC)
83 #define DISPC_GFX_BA0 DISPC_REG(0x0080)
84 #define DISPC_GFX_BA1 DISPC_REG(0x0084)
85 #define DISPC_GFX_POSITION DISPC_REG(0x0088)
86 #define DISPC_GFX_SIZE DISPC_REG(0x008C)
87 #define DISPC_GFX_ATTRIBUTES DISPC_REG(0x00A0)
88 #define DISPC_GFX_FIFO_THRESHOLD DISPC_REG(0x00A4)
89 #define DISPC_GFX_FIFO_SIZE_STATUS DISPC_REG(0x00A8)
90 #define DISPC_GFX_ROW_INC DISPC_REG(0x00AC)
91 #define DISPC_GFX_PIXEL_INC DISPC_REG(0x00B0)
92 #define DISPC_GFX_WINDOW_SKIP DISPC_REG(0x00B4)
93 #define DISPC_GFX_TABLE_BA DISPC_REG(0x00B8)
95 #define DISPC_DATA_CYCLE1(ch) DISPC_REG(ch != 2 ? 0x01D4 : 0x03C0)
96 #define DISPC_DATA_CYCLE2(ch) DISPC_REG(ch != 2 ? 0x01D8 : 0x03C4)
97 #define DISPC_DATA_CYCLE3(ch) DISPC_REG(ch != 2 ? 0x01DC : 0x03C8)
98 #define DISPC_CPR_COEF_R(ch) DISPC_REG(ch != 2 ? 0x0220 : 0x03BC)
99 #define DISPC_CPR_COEF_G(ch) DISPC_REG(ch != 2 ? 0x0224 : 0x03B8)
100 #define DISPC_CPR_COEF_B(ch) DISPC_REG(ch != 2 ? 0x0228 : 0x03B4)
102 #define DISPC_GFX_PRELOAD DISPC_REG(0x022C)
104 /* DISPC Video plane, n = 0 for VID1 and n = 1 for VID2 */
105 #define DISPC_VID_REG(n, idx) DISPC_REG(0x00BC + (n)*0x90 + idx)
107 #define DISPC_VID_BA0(n) DISPC_VID_REG(n, 0x0000)
108 #define DISPC_VID_BA1(n) DISPC_VID_REG(n, 0x0004)
109 #define DISPC_VID_POSITION(n) DISPC_VID_REG(n, 0x0008)
110 #define DISPC_VID_SIZE(n) DISPC_VID_REG(n, 0x000C)
111 #define DISPC_VID_ATTRIBUTES(n) DISPC_VID_REG(n, 0x0010)
112 #define DISPC_VID_FIFO_THRESHOLD(n) DISPC_VID_REG(n, 0x0014)
113 #define DISPC_VID_FIFO_SIZE_STATUS(n) DISPC_VID_REG(n, 0x0018)
114 #define DISPC_VID_ROW_INC(n) DISPC_VID_REG(n, 0x001C)
115 #define DISPC_VID_PIXEL_INC(n) DISPC_VID_REG(n, 0x0020)
116 #define DISPC_VID_FIR(n) DISPC_VID_REG(n, 0x0024)
117 #define DISPC_VID_PICTURE_SIZE(n) DISPC_VID_REG(n, 0x0028)
118 #define DISPC_VID_ACCU0(n) DISPC_VID_REG(n, 0x002C)
119 #define DISPC_VID_ACCU1(n) DISPC_VID_REG(n, 0x0030)
121 /* coef index i = {0, 1, 2, 3, 4, 5, 6, 7} */
122 #define DISPC_VID_FIR_COEF_H(n, i) DISPC_REG(0x00F0 + (n)*0x90 + (i)*0x8)
123 /* coef index i = {0, 1, 2, 3, 4, 5, 6, 7} */
124 #define DISPC_VID_FIR_COEF_HV(n, i) DISPC_REG(0x00F4 + (n)*0x90 + (i)*0x8)
125 /* coef index i = {0, 1, 2, 3, 4} */
126 #define DISPC_VID_CONV_COEF(n, i) DISPC_REG(0x0130 + (n)*0x90 + (i)*0x4)
127 /* coef index i = {0, 1, 2, 3, 4, 5, 6, 7} */
128 #define DISPC_VID_FIR_COEF_V(n, i) DISPC_REG(0x01E0 + (n)*0x20 + (i)*0x4)
130 #define DISPC_VID_PRELOAD(n) DISPC_REG(0x230 + (n)*0x04)
133 #define DISPC_IRQ_MASK_ERROR (DISPC_IRQ_GFX_FIFO_UNDERFLOW | \
134 DISPC_IRQ_OCP_ERR | \
135 DISPC_IRQ_VID1_FIFO_UNDERFLOW | \
136 DISPC_IRQ_VID2_FIFO_UNDERFLOW | \
137 DISPC_IRQ_SYNC_LOST | \
138 DISPC_IRQ_SYNC_LOST_DIGIT)
140 #define DISPC_MAX_NR_ISRS 8
142 struct omap_dispc_isr_data {
143 omap_dispc_isr_t isr;
148 struct dispc_h_coef {
156 struct dispc_v_coef {
164 #define REG_GET(idx, start, end) \
165 FLD_GET(dispc_read_reg(idx), start, end)
167 #define REG_FLD_MOD(idx, val, start, end) \
168 dispc_write_reg(idx, FLD_MOD(dispc_read_reg(idx), val, start, end))
170 static const struct dispc_reg dispc_reg_att[] = { DISPC_GFX_ATTRIBUTES,
171 DISPC_VID_ATTRIBUTES(0),
172 DISPC_VID_ATTRIBUTES(1) };
174 struct dispc_irq_stats {
175 unsigned long last_reset;
187 struct omap_dispc_isr_data registered_isr[DISPC_MAX_NR_ISRS];
189 struct work_struct error_work;
191 u32 ctx[DISPC_SZ_REGS / sizeof(u32)];
193 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
194 spinlock_t irq_stats_lock;
195 struct dispc_irq_stats irq_stats;
199 static void _omap_dispc_set_irqs(void);
201 static inline void dispc_write_reg(const struct dispc_reg idx, u32 val)
203 __raw_writel(val, dispc.base + idx.idx);
206 static inline u32 dispc_read_reg(const struct dispc_reg idx)
208 return __raw_readl(dispc.base + idx.idx);
212 dispc.ctx[(DISPC_##reg).idx / sizeof(u32)] = dispc_read_reg(DISPC_##reg)
214 dispc_write_reg(DISPC_##reg, dispc.ctx[(DISPC_##reg).idx / sizeof(u32)])
216 void dispc_save_context(void)
218 if (cpu_is_omap24xx())
225 SR(DEFAULT_COLOR(0));
226 SR(DEFAULT_COLOR(1));
243 SR(GFX_FIFO_THRESHOLD);
264 SR(VID_ATTRIBUTES(0));
265 SR(VID_FIFO_THRESHOLD(0));
267 SR(VID_PIXEL_INC(0));
269 SR(VID_PICTURE_SIZE(0));
273 SR(VID_FIR_COEF_H(0, 0));
274 SR(VID_FIR_COEF_H(0, 1));
275 SR(VID_FIR_COEF_H(0, 2));
276 SR(VID_FIR_COEF_H(0, 3));
277 SR(VID_FIR_COEF_H(0, 4));
278 SR(VID_FIR_COEF_H(0, 5));
279 SR(VID_FIR_COEF_H(0, 6));
280 SR(VID_FIR_COEF_H(0, 7));
282 SR(VID_FIR_COEF_HV(0, 0));
283 SR(VID_FIR_COEF_HV(0, 1));
284 SR(VID_FIR_COEF_HV(0, 2));
285 SR(VID_FIR_COEF_HV(0, 3));
286 SR(VID_FIR_COEF_HV(0, 4));
287 SR(VID_FIR_COEF_HV(0, 5));
288 SR(VID_FIR_COEF_HV(0, 6));
289 SR(VID_FIR_COEF_HV(0, 7));
291 SR(VID_CONV_COEF(0, 0));
292 SR(VID_CONV_COEF(0, 1));
293 SR(VID_CONV_COEF(0, 2));
294 SR(VID_CONV_COEF(0, 3));
295 SR(VID_CONV_COEF(0, 4));
297 SR(VID_FIR_COEF_V(0, 0));
298 SR(VID_FIR_COEF_V(0, 1));
299 SR(VID_FIR_COEF_V(0, 2));
300 SR(VID_FIR_COEF_V(0, 3));
301 SR(VID_FIR_COEF_V(0, 4));
302 SR(VID_FIR_COEF_V(0, 5));
303 SR(VID_FIR_COEF_V(0, 6));
304 SR(VID_FIR_COEF_V(0, 7));
313 SR(VID_ATTRIBUTES(1));
314 SR(VID_FIFO_THRESHOLD(1));
316 SR(VID_PIXEL_INC(1));
318 SR(VID_PICTURE_SIZE(1));
322 SR(VID_FIR_COEF_H(1, 0));
323 SR(VID_FIR_COEF_H(1, 1));
324 SR(VID_FIR_COEF_H(1, 2));
325 SR(VID_FIR_COEF_H(1, 3));
326 SR(VID_FIR_COEF_H(1, 4));
327 SR(VID_FIR_COEF_H(1, 5));
328 SR(VID_FIR_COEF_H(1, 6));
329 SR(VID_FIR_COEF_H(1, 7));
331 SR(VID_FIR_COEF_HV(1, 0));
332 SR(VID_FIR_COEF_HV(1, 1));
333 SR(VID_FIR_COEF_HV(1, 2));
334 SR(VID_FIR_COEF_HV(1, 3));
335 SR(VID_FIR_COEF_HV(1, 4));
336 SR(VID_FIR_COEF_HV(1, 5));
337 SR(VID_FIR_COEF_HV(1, 6));
338 SR(VID_FIR_COEF_HV(1, 7));
340 SR(VID_CONV_COEF(1, 0));
341 SR(VID_CONV_COEF(1, 1));
342 SR(VID_CONV_COEF(1, 2));
343 SR(VID_CONV_COEF(1, 3));
344 SR(VID_CONV_COEF(1, 4));
346 SR(VID_FIR_COEF_V(1, 0));
347 SR(VID_FIR_COEF_V(1, 1));
348 SR(VID_FIR_COEF_V(1, 2));
349 SR(VID_FIR_COEF_V(1, 3));
350 SR(VID_FIR_COEF_V(1, 4));
351 SR(VID_FIR_COEF_V(1, 5));
352 SR(VID_FIR_COEF_V(1, 6));
353 SR(VID_FIR_COEF_V(1, 7));
358 void dispc_restore_context(void)
364 RR(DEFAULT_COLOR(0));
365 RR(DEFAULT_COLOR(1));
382 RR(GFX_FIFO_THRESHOLD);
403 RR(VID_ATTRIBUTES(0));
404 RR(VID_FIFO_THRESHOLD(0));
406 RR(VID_PIXEL_INC(0));
408 RR(VID_PICTURE_SIZE(0));
412 RR(VID_FIR_COEF_H(0, 0));
413 RR(VID_FIR_COEF_H(0, 1));
414 RR(VID_FIR_COEF_H(0, 2));
415 RR(VID_FIR_COEF_H(0, 3));
416 RR(VID_FIR_COEF_H(0, 4));
417 RR(VID_FIR_COEF_H(0, 5));
418 RR(VID_FIR_COEF_H(0, 6));
419 RR(VID_FIR_COEF_H(0, 7));
421 RR(VID_FIR_COEF_HV(0, 0));
422 RR(VID_FIR_COEF_HV(0, 1));
423 RR(VID_FIR_COEF_HV(0, 2));
424 RR(VID_FIR_COEF_HV(0, 3));
425 RR(VID_FIR_COEF_HV(0, 4));
426 RR(VID_FIR_COEF_HV(0, 5));
427 RR(VID_FIR_COEF_HV(0, 6));
428 RR(VID_FIR_COEF_HV(0, 7));
430 RR(VID_CONV_COEF(0, 0));
431 RR(VID_CONV_COEF(0, 1));
432 RR(VID_CONV_COEF(0, 2));
433 RR(VID_CONV_COEF(0, 3));
434 RR(VID_CONV_COEF(0, 4));
436 RR(VID_FIR_COEF_V(0, 0));
437 RR(VID_FIR_COEF_V(0, 1));
438 RR(VID_FIR_COEF_V(0, 2));
439 RR(VID_FIR_COEF_V(0, 3));
440 RR(VID_FIR_COEF_V(0, 4));
441 RR(VID_FIR_COEF_V(0, 5));
442 RR(VID_FIR_COEF_V(0, 6));
443 RR(VID_FIR_COEF_V(0, 7));
452 RR(VID_ATTRIBUTES(1));
453 RR(VID_FIFO_THRESHOLD(1));
455 RR(VID_PIXEL_INC(1));
457 RR(VID_PICTURE_SIZE(1));
461 RR(VID_FIR_COEF_H(1, 0));
462 RR(VID_FIR_COEF_H(1, 1));
463 RR(VID_FIR_COEF_H(1, 2));
464 RR(VID_FIR_COEF_H(1, 3));
465 RR(VID_FIR_COEF_H(1, 4));
466 RR(VID_FIR_COEF_H(1, 5));
467 RR(VID_FIR_COEF_H(1, 6));
468 RR(VID_FIR_COEF_H(1, 7));
470 RR(VID_FIR_COEF_HV(1, 0));
471 RR(VID_FIR_COEF_HV(1, 1));
472 RR(VID_FIR_COEF_HV(1, 2));
473 RR(VID_FIR_COEF_HV(1, 3));
474 RR(VID_FIR_COEF_HV(1, 4));
475 RR(VID_FIR_COEF_HV(1, 5));
476 RR(VID_FIR_COEF_HV(1, 6));
477 RR(VID_FIR_COEF_HV(1, 7));
479 RR(VID_CONV_COEF(1, 0));
480 RR(VID_CONV_COEF(1, 1));
481 RR(VID_CONV_COEF(1, 2));
482 RR(VID_CONV_COEF(1, 3));
483 RR(VID_CONV_COEF(1, 4));
485 RR(VID_FIR_COEF_V(1, 0));
486 RR(VID_FIR_COEF_V(1, 1));
487 RR(VID_FIR_COEF_V(1, 2));
488 RR(VID_FIR_COEF_V(1, 3));
489 RR(VID_FIR_COEF_V(1, 4));
490 RR(VID_FIR_COEF_V(1, 5));
491 RR(VID_FIR_COEF_V(1, 6));
492 RR(VID_FIR_COEF_V(1, 7));
496 /* enable last, because LCD & DIGIT enable are here */
499 /* clear spurious SYNC_LOST_DIGIT interrupts */
500 dispc_write_reg(DISPC_IRQSTATUS, DISPC_IRQ_SYNC_LOST_DIGIT);
503 * enable last so IRQs won't trigger before
504 * the context is fully restored
512 static inline void enable_clocks(bool enable)
515 dss_clk_enable(DSS_CLK_ICK | DSS_CLK_FCK1);
517 dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK1);
520 bool dispc_go_busy(enum omap_channel channel)
524 if (channel == OMAP_DSS_CHANNEL_LCD)
527 bit = 6; /* GODIGIT */
529 return REG_GET(DISPC_CONTROL, bit, bit) == 1;
532 void dispc_go(enum omap_channel channel)
538 if (channel == OMAP_DSS_CHANNEL_LCD)
539 bit = 0; /* LCDENABLE */
541 bit = 1; /* DIGITALENABLE */
543 /* if the channel is not enabled, we don't need GO */
544 if (REG_GET(DISPC_CONTROL, bit, bit) == 0)
547 if (channel == OMAP_DSS_CHANNEL_LCD)
550 bit = 6; /* GODIGIT */
552 if (REG_GET(DISPC_CONTROL, bit, bit) == 1) {
553 DSSERR("GO bit not down for channel %d\n", channel);
557 DSSDBG("GO %s\n", channel == OMAP_DSS_CHANNEL_LCD ? "LCD" : "DIGIT");
559 REG_FLD_MOD(DISPC_CONTROL, 1, bit, bit);
564 static void _dispc_write_firh_reg(enum omap_plane plane, int reg, u32 value)
566 BUG_ON(plane == OMAP_DSS_GFX);
568 dispc_write_reg(DISPC_VID_FIR_COEF_H(plane-1, reg), value);
571 static void _dispc_write_firhv_reg(enum omap_plane plane, int reg, u32 value)
573 BUG_ON(plane == OMAP_DSS_GFX);
575 dispc_write_reg(DISPC_VID_FIR_COEF_HV(plane-1, reg), value);
578 static void _dispc_write_firv_reg(enum omap_plane plane, int reg, u32 value)
580 BUG_ON(plane == OMAP_DSS_GFX);
582 dispc_write_reg(DISPC_VID_FIR_COEF_V(plane-1, reg), value);
585 static void _dispc_set_scale_coef(enum omap_plane plane, int hscaleup,
586 int vscaleup, int five_taps)
588 /* Coefficients for horizontal up-sampling */
589 static const struct dispc_h_coef coef_hup[8] = {
591 { -1, 13, 124, -8, 0 },
592 { -2, 30, 112, -11, -1 },
593 { -5, 51, 95, -11, -2 },
594 { 0, -9, 73, 73, -9 },
595 { -2, -11, 95, 51, -5 },
596 { -1, -11, 112, 30, -2 },
597 { 0, -8, 124, 13, -1 },
600 /* Coefficients for vertical up-sampling */
601 static const struct dispc_v_coef coef_vup_3tap[8] = {
604 { 0, 12, 111, 5, 0 },
608 { 0, 5, 111, 12, 0 },
612 static const struct dispc_v_coef coef_vup_5tap[8] = {
614 { -1, 13, 124, -8, 0 },
615 { -2, 30, 112, -11, -1 },
616 { -5, 51, 95, -11, -2 },
617 { 0, -9, 73, 73, -9 },
618 { -2, -11, 95, 51, -5 },
619 { -1, -11, 112, 30, -2 },
620 { 0, -8, 124, 13, -1 },
623 /* Coefficients for horizontal down-sampling */
624 static const struct dispc_h_coef coef_hdown[8] = {
625 { 0, 36, 56, 36, 0 },
626 { 4, 40, 55, 31, -2 },
627 { 8, 44, 54, 27, -5 },
628 { 12, 48, 53, 22, -7 },
629 { -9, 17, 52, 51, 17 },
630 { -7, 22, 53, 48, 12 },
631 { -5, 27, 54, 44, 8 },
632 { -2, 31, 55, 40, 4 },
635 /* Coefficients for vertical down-sampling */
636 static const struct dispc_v_coef coef_vdown_3tap[8] = {
637 { 0, 36, 56, 36, 0 },
638 { 0, 40, 57, 31, 0 },
639 { 0, 45, 56, 27, 0 },
640 { 0, 50, 55, 23, 0 },
641 { 0, 18, 55, 55, 0 },
642 { 0, 23, 55, 50, 0 },
643 { 0, 27, 56, 45, 0 },
644 { 0, 31, 57, 40, 0 },
647 static const struct dispc_v_coef coef_vdown_5tap[8] = {
648 { 0, 36, 56, 36, 0 },
649 { 4, 40, 55, 31, -2 },
650 { 8, 44, 54, 27, -5 },
651 { 12, 48, 53, 22, -7 },
652 { -9, 17, 52, 51, 17 },
653 { -7, 22, 53, 48, 12 },
654 { -5, 27, 54, 44, 8 },
655 { -2, 31, 55, 40, 4 },
658 const struct dispc_h_coef *h_coef;
659 const struct dispc_v_coef *v_coef;
668 v_coef = five_taps ? coef_vup_5tap : coef_vup_3tap;
670 v_coef = five_taps ? coef_vdown_5tap : coef_vdown_3tap;
672 for (i = 0; i < 8; i++) {
675 h = FLD_VAL(h_coef[i].hc0, 7, 0)
676 | FLD_VAL(h_coef[i].hc1, 15, 8)
677 | FLD_VAL(h_coef[i].hc2, 23, 16)
678 | FLD_VAL(h_coef[i].hc3, 31, 24);
679 hv = FLD_VAL(h_coef[i].hc4, 7, 0)
680 | FLD_VAL(v_coef[i].vc0, 15, 8)
681 | FLD_VAL(v_coef[i].vc1, 23, 16)
682 | FLD_VAL(v_coef[i].vc2, 31, 24);
684 _dispc_write_firh_reg(plane, i, h);
685 _dispc_write_firhv_reg(plane, i, hv);
689 for (i = 0; i < 8; i++) {
691 v = FLD_VAL(v_coef[i].vc00, 7, 0)
692 | FLD_VAL(v_coef[i].vc22, 15, 8);
693 _dispc_write_firv_reg(plane, i, v);
698 static void _dispc_setup_color_conv_coef(void)
700 const struct color_conv_coef {
701 int ry, rcr, rcb, gy, gcr, gcb, by, bcr, bcb;
704 298, 409, 0, 298, -208, -100, 298, 0, 517, 0,
707 const struct color_conv_coef *ct;
709 #define CVAL(x, y) (FLD_VAL(x, 26, 16) | FLD_VAL(y, 10, 0))
713 dispc_write_reg(DISPC_VID_CONV_COEF(0, 0), CVAL(ct->rcr, ct->ry));
714 dispc_write_reg(DISPC_VID_CONV_COEF(0, 1), CVAL(ct->gy, ct->rcb));
715 dispc_write_reg(DISPC_VID_CONV_COEF(0, 2), CVAL(ct->gcb, ct->gcr));
716 dispc_write_reg(DISPC_VID_CONV_COEF(0, 3), CVAL(ct->bcr, ct->by));
717 dispc_write_reg(DISPC_VID_CONV_COEF(0, 4), CVAL(0, ct->bcb));
719 dispc_write_reg(DISPC_VID_CONV_COEF(1, 0), CVAL(ct->rcr, ct->ry));
720 dispc_write_reg(DISPC_VID_CONV_COEF(1, 1), CVAL(ct->gy, ct->rcb));
721 dispc_write_reg(DISPC_VID_CONV_COEF(1, 2), CVAL(ct->gcb, ct->gcr));
722 dispc_write_reg(DISPC_VID_CONV_COEF(1, 3), CVAL(ct->bcr, ct->by));
723 dispc_write_reg(DISPC_VID_CONV_COEF(1, 4), CVAL(0, ct->bcb));
727 REG_FLD_MOD(DISPC_VID_ATTRIBUTES(0), ct->full_range, 11, 11);
728 REG_FLD_MOD(DISPC_VID_ATTRIBUTES(1), ct->full_range, 11, 11);
732 static void _dispc_set_plane_ba0(enum omap_plane plane, u32 paddr)
734 const struct dispc_reg ba0_reg[] = { DISPC_GFX_BA0,
738 dispc_write_reg(ba0_reg[plane], paddr);
741 static void _dispc_set_plane_ba1(enum omap_plane plane, u32 paddr)
743 const struct dispc_reg ba1_reg[] = { DISPC_GFX_BA1,
747 dispc_write_reg(ba1_reg[plane], paddr);
750 static void _dispc_set_plane_pos(enum omap_plane plane, int x, int y)
752 const struct dispc_reg pos_reg[] = { DISPC_GFX_POSITION,
753 DISPC_VID_POSITION(0),
754 DISPC_VID_POSITION(1) };
756 u32 val = FLD_VAL(y, 26, 16) | FLD_VAL(x, 10, 0);
757 dispc_write_reg(pos_reg[plane], val);
760 static void _dispc_set_pic_size(enum omap_plane plane, int width, int height)
762 const struct dispc_reg siz_reg[] = { DISPC_GFX_SIZE,
763 DISPC_VID_PICTURE_SIZE(0),
764 DISPC_VID_PICTURE_SIZE(1) };
765 u32 val = FLD_VAL(height - 1, 26, 16) | FLD_VAL(width - 1, 10, 0);
766 dispc_write_reg(siz_reg[plane], val);
769 static void _dispc_set_vid_size(enum omap_plane plane, int width, int height)
772 const struct dispc_reg vsi_reg[] = { DISPC_VID_SIZE(0),
775 BUG_ON(plane == OMAP_DSS_GFX);
777 val = FLD_VAL(height - 1, 26, 16) | FLD_VAL(width - 1, 10, 0);
778 dispc_write_reg(vsi_reg[plane-1], val);
781 static void _dispc_set_pre_mult_alpha(enum omap_plane plane, bool enable)
783 if (!dss_has_feature(FEAT_PRE_MULT_ALPHA))
786 if (!dss_has_feature(FEAT_GLOBAL_ALPHA_VID1) &&
787 plane == OMAP_DSS_VIDEO1)
790 REG_FLD_MOD(dispc_reg_att[plane], enable ? 1 : 0, 28, 28);
793 static void _dispc_setup_global_alpha(enum omap_plane plane, u8 global_alpha)
795 if (!dss_has_feature(FEAT_GLOBAL_ALPHA))
798 if (!dss_has_feature(FEAT_GLOBAL_ALPHA_VID1) &&
799 plane == OMAP_DSS_VIDEO1)
802 if (plane == OMAP_DSS_GFX)
803 REG_FLD_MOD(DISPC_GLOBAL_ALPHA, global_alpha, 7, 0);
804 else if (plane == OMAP_DSS_VIDEO2)
805 REG_FLD_MOD(DISPC_GLOBAL_ALPHA, global_alpha, 23, 16);
808 static void _dispc_set_pix_inc(enum omap_plane plane, s32 inc)
810 const struct dispc_reg ri_reg[] = { DISPC_GFX_PIXEL_INC,
811 DISPC_VID_PIXEL_INC(0),
812 DISPC_VID_PIXEL_INC(1) };
814 dispc_write_reg(ri_reg[plane], inc);
817 static void _dispc_set_row_inc(enum omap_plane plane, s32 inc)
819 const struct dispc_reg ri_reg[] = { DISPC_GFX_ROW_INC,
820 DISPC_VID_ROW_INC(0),
821 DISPC_VID_ROW_INC(1) };
823 dispc_write_reg(ri_reg[plane], inc);
826 static void _dispc_set_color_mode(enum omap_plane plane,
827 enum omap_color_mode color_mode)
831 switch (color_mode) {
832 case OMAP_DSS_COLOR_CLUT1:
834 case OMAP_DSS_COLOR_CLUT2:
836 case OMAP_DSS_COLOR_CLUT4:
838 case OMAP_DSS_COLOR_CLUT8:
840 case OMAP_DSS_COLOR_RGB12U:
842 case OMAP_DSS_COLOR_ARGB16:
844 case OMAP_DSS_COLOR_RGB16:
846 case OMAP_DSS_COLOR_RGB24U:
848 case OMAP_DSS_COLOR_RGB24P:
850 case OMAP_DSS_COLOR_YUV2:
852 case OMAP_DSS_COLOR_UYVY:
854 case OMAP_DSS_COLOR_ARGB32:
856 case OMAP_DSS_COLOR_RGBA32:
858 case OMAP_DSS_COLOR_RGBX32:
864 REG_FLD_MOD(dispc_reg_att[plane], m, 4, 1);
867 static void _dispc_set_channel_out(enum omap_plane plane,
868 enum omap_channel channel)
877 case OMAP_DSS_VIDEO1:
878 case OMAP_DSS_VIDEO2:
886 val = dispc_read_reg(dispc_reg_att[plane]);
887 val = FLD_MOD(val, channel, shift, shift);
888 dispc_write_reg(dispc_reg_att[plane], val);
891 void dispc_set_burst_size(enum omap_plane plane,
892 enum omap_burst_size burst_size)
903 case OMAP_DSS_VIDEO1:
904 case OMAP_DSS_VIDEO2:
912 val = dispc_read_reg(dispc_reg_att[plane]);
913 val = FLD_MOD(val, burst_size, shift+1, shift);
914 dispc_write_reg(dispc_reg_att[plane], val);
919 static void _dispc_set_vid_color_conv(enum omap_plane plane, bool enable)
923 BUG_ON(plane == OMAP_DSS_GFX);
925 val = dispc_read_reg(dispc_reg_att[plane]);
926 val = FLD_MOD(val, enable, 9, 9);
927 dispc_write_reg(dispc_reg_att[plane], val);
930 void dispc_enable_replication(enum omap_plane plane, bool enable)
934 if (plane == OMAP_DSS_GFX)
940 REG_FLD_MOD(dispc_reg_att[plane], enable, bit, bit);
944 void dispc_set_lcd_size(enum omap_channel channel, u16 width, u16 height)
947 BUG_ON((width > (1 << 11)) || (height > (1 << 11)));
948 val = FLD_VAL(height - 1, 26, 16) | FLD_VAL(width - 1, 10, 0);
950 dispc_write_reg(DISPC_SIZE_LCD(channel), val);
954 void dispc_set_digit_size(u16 width, u16 height)
957 BUG_ON((width > (1 << 11)) || (height > (1 << 11)));
958 val = FLD_VAL(height - 1, 26, 16) | FLD_VAL(width - 1, 10, 0);
960 dispc_write_reg(DISPC_SIZE_DIG, val);
964 static void dispc_read_plane_fifo_sizes(void)
966 const struct dispc_reg fsz_reg[] = { DISPC_GFX_FIFO_SIZE_STATUS,
967 DISPC_VID_FIFO_SIZE_STATUS(0),
968 DISPC_VID_FIFO_SIZE_STATUS(1) };
975 dss_feat_get_reg_field(FEAT_REG_FIFOSIZE, &start, &end);
977 for (plane = 0; plane < ARRAY_SIZE(dispc.fifo_size); ++plane) {
978 size = FLD_GET(dispc_read_reg(fsz_reg[plane]), start, end);
979 dispc.fifo_size[plane] = size;
985 u32 dispc_get_plane_fifo_size(enum omap_plane plane)
987 return dispc.fifo_size[plane];
990 void dispc_setup_plane_fifo(enum omap_plane plane, u32 low, u32 high)
992 const struct dispc_reg ftrs_reg[] = { DISPC_GFX_FIFO_THRESHOLD,
993 DISPC_VID_FIFO_THRESHOLD(0),
994 DISPC_VID_FIFO_THRESHOLD(1) };
995 u8 hi_start, hi_end, lo_start, lo_end;
999 DSSDBG("fifo(%d) low/high old %u/%u, new %u/%u\n",
1001 REG_GET(ftrs_reg[plane], 11, 0),
1002 REG_GET(ftrs_reg[plane], 27, 16),
1005 dss_feat_get_reg_field(FEAT_REG_FIFOHIGHTHRESHOLD, &hi_start, &hi_end);
1006 dss_feat_get_reg_field(FEAT_REG_FIFOLOWTHRESHOLD, &lo_start, &lo_end);
1008 dispc_write_reg(ftrs_reg[plane],
1009 FLD_VAL(high, hi_start, hi_end) |
1010 FLD_VAL(low, lo_start, lo_end));
1015 void dispc_enable_fifomerge(bool enable)
1019 DSSDBG("FIFO merge %s\n", enable ? "enabled" : "disabled");
1020 REG_FLD_MOD(DISPC_CONFIG, enable ? 1 : 0, 14, 14);
1025 static void _dispc_set_fir(enum omap_plane plane, int hinc, int vinc)
1028 const struct dispc_reg fir_reg[] = { DISPC_VID_FIR(0),
1030 u8 hinc_start, hinc_end, vinc_start, vinc_end;
1032 BUG_ON(plane == OMAP_DSS_GFX);
1034 dss_feat_get_reg_field(FEAT_REG_FIRHINC, &hinc_start, &hinc_end);
1035 dss_feat_get_reg_field(FEAT_REG_FIRVINC, &vinc_start, &vinc_end);
1037 val = FLD_VAL(vinc, vinc_start, vinc_end) |
1038 FLD_VAL(hinc, hinc_start, hinc_end);
1040 dispc_write_reg(fir_reg[plane-1], val);
1043 static void _dispc_set_vid_accu0(enum omap_plane plane, int haccu, int vaccu)
1046 const struct dispc_reg ac0_reg[] = { DISPC_VID_ACCU0(0),
1047 DISPC_VID_ACCU0(1) };
1049 BUG_ON(plane == OMAP_DSS_GFX);
1051 val = FLD_VAL(vaccu, 25, 16) | FLD_VAL(haccu, 9, 0);
1052 dispc_write_reg(ac0_reg[plane-1], val);
1055 static void _dispc_set_vid_accu1(enum omap_plane plane, int haccu, int vaccu)
1058 const struct dispc_reg ac1_reg[] = { DISPC_VID_ACCU1(0),
1059 DISPC_VID_ACCU1(1) };
1061 BUG_ON(plane == OMAP_DSS_GFX);
1063 val = FLD_VAL(vaccu, 25, 16) | FLD_VAL(haccu, 9, 0);
1064 dispc_write_reg(ac1_reg[plane-1], val);
1068 static void _dispc_set_scaling(enum omap_plane plane,
1069 u16 orig_width, u16 orig_height,
1070 u16 out_width, u16 out_height,
1071 bool ilace, bool five_taps,
1076 int hscaleup, vscaleup;
1081 BUG_ON(plane == OMAP_DSS_GFX);
1083 hscaleup = orig_width <= out_width;
1084 vscaleup = orig_height <= out_height;
1086 _dispc_set_scale_coef(plane, hscaleup, vscaleup, five_taps);
1088 if (!orig_width || orig_width == out_width)
1091 fir_hinc = 1024 * orig_width / out_width;
1093 if (!orig_height || orig_height == out_height)
1096 fir_vinc = 1024 * orig_height / out_height;
1098 _dispc_set_fir(plane, fir_hinc, fir_vinc);
1100 l = dispc_read_reg(dispc_reg_att[plane]);
1101 l &= ~((0x0f << 5) | (0x3 << 21));
1103 l |= fir_hinc ? (1 << 5) : 0;
1104 l |= fir_vinc ? (1 << 6) : 0;
1106 l |= hscaleup ? 0 : (1 << 7);
1107 l |= vscaleup ? 0 : (1 << 8);
1109 l |= five_taps ? (1 << 21) : 0;
1110 l |= five_taps ? (1 << 22) : 0;
1112 dispc_write_reg(dispc_reg_att[plane], l);
1115 * field 0 = even field = bottom field
1116 * field 1 = odd field = top field
1118 if (ilace && !fieldmode) {
1120 accu0 = (fir_vinc / 2) & 0x3ff;
1121 if (accu0 >= 1024/2) {
1127 _dispc_set_vid_accu0(plane, 0, accu0);
1128 _dispc_set_vid_accu1(plane, 0, accu1);
1131 static void _dispc_set_rotation_attrs(enum omap_plane plane, u8 rotation,
1132 bool mirroring, enum omap_color_mode color_mode)
1134 if (color_mode == OMAP_DSS_COLOR_YUV2 ||
1135 color_mode == OMAP_DSS_COLOR_UYVY) {
1140 case OMAP_DSS_ROT_0:
1143 case OMAP_DSS_ROT_90:
1146 case OMAP_DSS_ROT_180:
1149 case OMAP_DSS_ROT_270:
1155 case OMAP_DSS_ROT_0:
1158 case OMAP_DSS_ROT_90:
1161 case OMAP_DSS_ROT_180:
1164 case OMAP_DSS_ROT_270:
1170 REG_FLD_MOD(dispc_reg_att[plane], vidrot, 13, 12);
1172 if (rotation == OMAP_DSS_ROT_90 || rotation == OMAP_DSS_ROT_270)
1173 REG_FLD_MOD(dispc_reg_att[plane], 0x1, 18, 18);
1175 REG_FLD_MOD(dispc_reg_att[plane], 0x0, 18, 18);
1177 REG_FLD_MOD(dispc_reg_att[plane], 0, 13, 12);
1178 REG_FLD_MOD(dispc_reg_att[plane], 0, 18, 18);
1182 static int color_mode_to_bpp(enum omap_color_mode color_mode)
1184 switch (color_mode) {
1185 case OMAP_DSS_COLOR_CLUT1:
1187 case OMAP_DSS_COLOR_CLUT2:
1189 case OMAP_DSS_COLOR_CLUT4:
1191 case OMAP_DSS_COLOR_CLUT8:
1193 case OMAP_DSS_COLOR_RGB12U:
1194 case OMAP_DSS_COLOR_RGB16:
1195 case OMAP_DSS_COLOR_ARGB16:
1196 case OMAP_DSS_COLOR_YUV2:
1197 case OMAP_DSS_COLOR_UYVY:
1199 case OMAP_DSS_COLOR_RGB24P:
1201 case OMAP_DSS_COLOR_RGB24U:
1202 case OMAP_DSS_COLOR_ARGB32:
1203 case OMAP_DSS_COLOR_RGBA32:
1204 case OMAP_DSS_COLOR_RGBX32:
1211 static s32 pixinc(int pixels, u8 ps)
1215 else if (pixels > 1)
1216 return 1 + (pixels - 1) * ps;
1217 else if (pixels < 0)
1218 return 1 - (-pixels + 1) * ps;
1223 static void calc_vrfb_rotation_offset(u8 rotation, bool mirror,
1225 u16 width, u16 height,
1226 enum omap_color_mode color_mode, bool fieldmode,
1227 unsigned int field_offset,
1228 unsigned *offset0, unsigned *offset1,
1229 s32 *row_inc, s32 *pix_inc)
1233 /* FIXME CLUT formats */
1234 switch (color_mode) {
1235 case OMAP_DSS_COLOR_CLUT1:
1236 case OMAP_DSS_COLOR_CLUT2:
1237 case OMAP_DSS_COLOR_CLUT4:
1238 case OMAP_DSS_COLOR_CLUT8:
1241 case OMAP_DSS_COLOR_YUV2:
1242 case OMAP_DSS_COLOR_UYVY:
1246 ps = color_mode_to_bpp(color_mode) / 8;
1250 DSSDBG("calc_rot(%d): scrw %d, %dx%d\n", rotation, screen_width,
1254 * field 0 = even field = bottom field
1255 * field 1 = odd field = top field
1257 switch (rotation + mirror * 4) {
1258 case OMAP_DSS_ROT_0:
1259 case OMAP_DSS_ROT_180:
1261 * If the pixel format is YUV or UYVY divide the width
1262 * of the image by 2 for 0 and 180 degree rotation.
1264 if (color_mode == OMAP_DSS_COLOR_YUV2 ||
1265 color_mode == OMAP_DSS_COLOR_UYVY)
1267 case OMAP_DSS_ROT_90:
1268 case OMAP_DSS_ROT_270:
1271 *offset0 = field_offset * screen_width * ps;
1275 *row_inc = pixinc(1 + (screen_width - width) +
1276 (fieldmode ? screen_width : 0),
1278 *pix_inc = pixinc(1, ps);
1281 case OMAP_DSS_ROT_0 + 4:
1282 case OMAP_DSS_ROT_180 + 4:
1283 /* If the pixel format is YUV or UYVY divide the width
1284 * of the image by 2 for 0 degree and 180 degree
1286 if (color_mode == OMAP_DSS_COLOR_YUV2 ||
1287 color_mode == OMAP_DSS_COLOR_UYVY)
1289 case OMAP_DSS_ROT_90 + 4:
1290 case OMAP_DSS_ROT_270 + 4:
1293 *offset0 = field_offset * screen_width * ps;
1296 *row_inc = pixinc(1 - (screen_width + width) -
1297 (fieldmode ? screen_width : 0),
1299 *pix_inc = pixinc(1, ps);
1307 static void calc_dma_rotation_offset(u8 rotation, bool mirror,
1309 u16 width, u16 height,
1310 enum omap_color_mode color_mode, bool fieldmode,
1311 unsigned int field_offset,
1312 unsigned *offset0, unsigned *offset1,
1313 s32 *row_inc, s32 *pix_inc)
1318 /* FIXME CLUT formats */
1319 switch (color_mode) {
1320 case OMAP_DSS_COLOR_CLUT1:
1321 case OMAP_DSS_COLOR_CLUT2:
1322 case OMAP_DSS_COLOR_CLUT4:
1323 case OMAP_DSS_COLOR_CLUT8:
1327 ps = color_mode_to_bpp(color_mode) / 8;
1331 DSSDBG("calc_rot(%d): scrw %d, %dx%d\n", rotation, screen_width,
1334 /* width & height are overlay sizes, convert to fb sizes */
1336 if (rotation == OMAP_DSS_ROT_0 || rotation == OMAP_DSS_ROT_180) {
1345 * field 0 = even field = bottom field
1346 * field 1 = odd field = top field
1348 switch (rotation + mirror * 4) {
1349 case OMAP_DSS_ROT_0:
1352 *offset0 = *offset1 + field_offset * screen_width * ps;
1354 *offset0 = *offset1;
1355 *row_inc = pixinc(1 + (screen_width - fbw) +
1356 (fieldmode ? screen_width : 0),
1358 *pix_inc = pixinc(1, ps);
1360 case OMAP_DSS_ROT_90:
1361 *offset1 = screen_width * (fbh - 1) * ps;
1363 *offset0 = *offset1 + field_offset * ps;
1365 *offset0 = *offset1;
1366 *row_inc = pixinc(screen_width * (fbh - 1) + 1 +
1367 (fieldmode ? 1 : 0), ps);
1368 *pix_inc = pixinc(-screen_width, ps);
1370 case OMAP_DSS_ROT_180:
1371 *offset1 = (screen_width * (fbh - 1) + fbw - 1) * ps;
1373 *offset0 = *offset1 - field_offset * screen_width * ps;
1375 *offset0 = *offset1;
1376 *row_inc = pixinc(-1 -
1377 (screen_width - fbw) -
1378 (fieldmode ? screen_width : 0),
1380 *pix_inc = pixinc(-1, ps);
1382 case OMAP_DSS_ROT_270:
1383 *offset1 = (fbw - 1) * ps;
1385 *offset0 = *offset1 - field_offset * ps;
1387 *offset0 = *offset1;
1388 *row_inc = pixinc(-screen_width * (fbh - 1) - 1 -
1389 (fieldmode ? 1 : 0), ps);
1390 *pix_inc = pixinc(screen_width, ps);
1394 case OMAP_DSS_ROT_0 + 4:
1395 *offset1 = (fbw - 1) * ps;
1397 *offset0 = *offset1 + field_offset * screen_width * ps;
1399 *offset0 = *offset1;
1400 *row_inc = pixinc(screen_width * 2 - 1 +
1401 (fieldmode ? screen_width : 0),
1403 *pix_inc = pixinc(-1, ps);
1406 case OMAP_DSS_ROT_90 + 4:
1409 *offset0 = *offset1 + field_offset * ps;
1411 *offset0 = *offset1;
1412 *row_inc = pixinc(-screen_width * (fbh - 1) + 1 +
1413 (fieldmode ? 1 : 0),
1415 *pix_inc = pixinc(screen_width, ps);
1418 case OMAP_DSS_ROT_180 + 4:
1419 *offset1 = screen_width * (fbh - 1) * ps;
1421 *offset0 = *offset1 - field_offset * screen_width * ps;
1423 *offset0 = *offset1;
1424 *row_inc = pixinc(1 - screen_width * 2 -
1425 (fieldmode ? screen_width : 0),
1427 *pix_inc = pixinc(1, ps);
1430 case OMAP_DSS_ROT_270 + 4:
1431 *offset1 = (screen_width * (fbh - 1) + fbw - 1) * ps;
1433 *offset0 = *offset1 - field_offset * ps;
1435 *offset0 = *offset1;
1436 *row_inc = pixinc(screen_width * (fbh - 1) - 1 -
1437 (fieldmode ? 1 : 0),
1439 *pix_inc = pixinc(-screen_width, ps);
1447 static unsigned long calc_fclk_five_taps(u16 width, u16 height,
1448 u16 out_width, u16 out_height, enum omap_color_mode color_mode)
1451 /* FIXME venc pclk? */
1452 u64 tmp, pclk = dispc_pclk_rate();
1454 if (height > out_height) {
1455 /* FIXME get real display PPL */
1456 unsigned int ppl = 800;
1458 tmp = pclk * height * out_width;
1459 do_div(tmp, 2 * out_height * ppl);
1462 if (height > 2 * out_height) {
1463 if (ppl == out_width)
1466 tmp = pclk * (height - 2 * out_height) * out_width;
1467 do_div(tmp, 2 * out_height * (ppl - out_width));
1468 fclk = max(fclk, (u32) tmp);
1472 if (width > out_width) {
1474 do_div(tmp, out_width);
1475 fclk = max(fclk, (u32) tmp);
1477 if (color_mode == OMAP_DSS_COLOR_RGB24U)
1484 static unsigned long calc_fclk(u16 width, u16 height,
1485 u16 out_width, u16 out_height)
1487 unsigned int hf, vf;
1490 * FIXME how to determine the 'A' factor
1491 * for the no downscaling case ?
1494 if (width > 3 * out_width)
1496 else if (width > 2 * out_width)
1498 else if (width > out_width)
1503 if (height > out_height)
1508 /* FIXME venc pclk? */
1509 return dispc_pclk_rate() * vf * hf;
1512 void dispc_set_channel_out(enum omap_plane plane, enum omap_channel channel_out)
1515 _dispc_set_channel_out(plane, channel_out);
1519 static int _dispc_setup_plane(enum omap_plane plane,
1520 u32 paddr, u16 screen_width,
1521 u16 pos_x, u16 pos_y,
1522 u16 width, u16 height,
1523 u16 out_width, u16 out_height,
1524 enum omap_color_mode color_mode,
1526 enum omap_dss_rotation_type rotation_type,
1527 u8 rotation, int mirror,
1531 const int maxdownscale = cpu_is_omap34xx() ? 4 : 2;
1535 unsigned offset0, offset1;
1538 u16 frame_height = height;
1539 unsigned int field_offset = 0;
1544 if (ilace && height == out_height)
1553 DSSDBG("adjusting for ilace: height %d, pos_y %d, "
1555 height, pos_y, out_height);
1558 if (!dss_feat_color_mode_supported(plane, color_mode))
1561 if (plane == OMAP_DSS_GFX) {
1562 if (width != out_width || height != out_height)
1567 unsigned long fclk = 0;
1569 if (out_width < width / maxdownscale ||
1570 out_width > width * 8)
1573 if (out_height < height / maxdownscale ||
1574 out_height > height * 8)
1577 if (color_mode == OMAP_DSS_COLOR_YUV2 ||
1578 color_mode == OMAP_DSS_COLOR_UYVY)
1581 /* Must use 5-tap filter? */
1582 five_taps = height > out_height * 2;
1585 fclk = calc_fclk(width, height,
1586 out_width, out_height);
1588 /* Try 5-tap filter if 3-tap fclk is too high */
1589 if (cpu_is_omap34xx() && height > out_height &&
1590 fclk > dispc_fclk_rate())
1594 if (width > (2048 >> five_taps)) {
1595 DSSERR("failed to set up scaling, fclk too low\n");
1600 fclk = calc_fclk_five_taps(width, height,
1601 out_width, out_height, color_mode);
1603 DSSDBG("required fclk rate = %lu Hz\n", fclk);
1604 DSSDBG("current fclk rate = %lu Hz\n", dispc_fclk_rate());
1606 if (!fclk || fclk > dispc_fclk_rate()) {
1607 DSSERR("failed to set up scaling, "
1608 "required fclk rate = %lu Hz, "
1609 "current fclk rate = %lu Hz\n",
1610 fclk, dispc_fclk_rate());
1615 if (ilace && !fieldmode) {
1617 * when downscaling the bottom field may have to start several
1618 * source lines below the top field. Unfortunately ACCUI
1619 * registers will only hold the fractional part of the offset
1620 * so the integer part must be added to the base address of the
1623 if (!height || height == out_height)
1626 field_offset = height / out_height / 2;
1629 /* Fields are independent but interleaved in memory. */
1633 if (rotation_type == OMAP_DSS_ROT_DMA)
1634 calc_dma_rotation_offset(rotation, mirror,
1635 screen_width, width, frame_height, color_mode,
1636 fieldmode, field_offset,
1637 &offset0, &offset1, &row_inc, &pix_inc);
1639 calc_vrfb_rotation_offset(rotation, mirror,
1640 screen_width, width, frame_height, color_mode,
1641 fieldmode, field_offset,
1642 &offset0, &offset1, &row_inc, &pix_inc);
1644 DSSDBG("offset0 %u, offset1 %u, row_inc %d, pix_inc %d\n",
1645 offset0, offset1, row_inc, pix_inc);
1647 _dispc_set_color_mode(plane, color_mode);
1649 _dispc_set_plane_ba0(plane, paddr + offset0);
1650 _dispc_set_plane_ba1(plane, paddr + offset1);
1652 _dispc_set_row_inc(plane, row_inc);
1653 _dispc_set_pix_inc(plane, pix_inc);
1655 DSSDBG("%d,%d %dx%d -> %dx%d\n", pos_x, pos_y, width, height,
1656 out_width, out_height);
1658 _dispc_set_plane_pos(plane, pos_x, pos_y);
1660 _dispc_set_pic_size(plane, width, height);
1662 if (plane != OMAP_DSS_GFX) {
1663 _dispc_set_scaling(plane, width, height,
1664 out_width, out_height,
1665 ilace, five_taps, fieldmode);
1666 _dispc_set_vid_size(plane, out_width, out_height);
1667 _dispc_set_vid_color_conv(plane, cconv);
1670 _dispc_set_rotation_attrs(plane, rotation, mirror, color_mode);
1672 _dispc_set_pre_mult_alpha(plane, pre_mult_alpha);
1673 _dispc_setup_global_alpha(plane, global_alpha);
1678 static void _dispc_enable_plane(enum omap_plane plane, bool enable)
1680 REG_FLD_MOD(dispc_reg_att[plane], enable ? 1 : 0, 0, 0);
1683 static void dispc_disable_isr(void *data, u32 mask)
1685 struct completion *compl = data;
1689 static void _enable_lcd_out(bool enable)
1691 REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 0, 0);
1694 static void dispc_enable_lcd_out(bool enable)
1696 struct completion frame_done_completion;
1702 /* When we disable LCD output, we need to wait until frame is done.
1703 * Otherwise the DSS is still working, and turning off the clocks
1704 * prevents DSS from going to OFF mode */
1705 is_on = REG_GET(DISPC_CONTROL, 0, 0);
1707 if (!enable && is_on) {
1708 init_completion(&frame_done_completion);
1710 r = omap_dispc_register_isr(dispc_disable_isr,
1711 &frame_done_completion,
1712 DISPC_IRQ_FRAMEDONE);
1715 DSSERR("failed to register FRAMEDONE isr\n");
1718 _enable_lcd_out(enable);
1720 if (!enable && is_on) {
1721 if (!wait_for_completion_timeout(&frame_done_completion,
1722 msecs_to_jiffies(100)))
1723 DSSERR("timeout waiting for FRAME DONE\n");
1725 r = omap_dispc_unregister_isr(dispc_disable_isr,
1726 &frame_done_completion,
1727 DISPC_IRQ_FRAMEDONE);
1730 DSSERR("failed to unregister FRAMEDONE isr\n");
1736 static void _enable_digit_out(bool enable)
1738 REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 1, 1);
1741 static void dispc_enable_digit_out(bool enable)
1743 struct completion frame_done_completion;
1748 if (REG_GET(DISPC_CONTROL, 1, 1) == enable) {
1754 unsigned long flags;
1755 /* When we enable digit output, we'll get an extra digit
1756 * sync lost interrupt, that we need to ignore */
1757 spin_lock_irqsave(&dispc.irq_lock, flags);
1758 dispc.irq_error_mask &= ~DISPC_IRQ_SYNC_LOST_DIGIT;
1759 _omap_dispc_set_irqs();
1760 spin_unlock_irqrestore(&dispc.irq_lock, flags);
1763 /* When we disable digit output, we need to wait until fields are done.
1764 * Otherwise the DSS is still working, and turning off the clocks
1765 * prevents DSS from going to OFF mode. And when enabling, we need to
1766 * wait for the extra sync losts */
1767 init_completion(&frame_done_completion);
1769 r = omap_dispc_register_isr(dispc_disable_isr, &frame_done_completion,
1770 DISPC_IRQ_EVSYNC_EVEN | DISPC_IRQ_EVSYNC_ODD);
1772 DSSERR("failed to register EVSYNC isr\n");
1774 _enable_digit_out(enable);
1776 /* XXX I understand from TRM that we should only wait for the
1777 * current field to complete. But it seems we have to wait
1778 * for both fields */
1779 if (!wait_for_completion_timeout(&frame_done_completion,
1780 msecs_to_jiffies(100)))
1781 DSSERR("timeout waiting for EVSYNC\n");
1783 if (!wait_for_completion_timeout(&frame_done_completion,
1784 msecs_to_jiffies(100)))
1785 DSSERR("timeout waiting for EVSYNC\n");
1787 r = omap_dispc_unregister_isr(dispc_disable_isr,
1788 &frame_done_completion,
1789 DISPC_IRQ_EVSYNC_EVEN | DISPC_IRQ_EVSYNC_ODD);
1791 DSSERR("failed to unregister EVSYNC isr\n");
1794 unsigned long flags;
1795 spin_lock_irqsave(&dispc.irq_lock, flags);
1796 dispc.irq_error_mask = DISPC_IRQ_MASK_ERROR;
1797 dispc_write_reg(DISPC_IRQSTATUS, DISPC_IRQ_SYNC_LOST_DIGIT);
1798 _omap_dispc_set_irqs();
1799 spin_unlock_irqrestore(&dispc.irq_lock, flags);
1805 bool dispc_is_channel_enabled(enum omap_channel channel)
1807 if (channel == OMAP_DSS_CHANNEL_LCD)
1808 return !!REG_GET(DISPC_CONTROL, 0, 0);
1809 else if (channel == OMAP_DSS_CHANNEL_DIGIT)
1810 return !!REG_GET(DISPC_CONTROL, 1, 1);
1815 void dispc_enable_channel(enum omap_channel channel, bool enable)
1817 if (channel == OMAP_DSS_CHANNEL_LCD)
1818 dispc_enable_lcd_out(enable);
1819 else if (channel == OMAP_DSS_CHANNEL_DIGIT)
1820 dispc_enable_digit_out(enable);
1825 void dispc_lcd_enable_signal_polarity(bool act_high)
1828 REG_FLD_MOD(DISPC_CONTROL, act_high ? 1 : 0, 29, 29);
1832 void dispc_lcd_enable_signal(bool enable)
1835 REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 28, 28);
1839 void dispc_pck_free_enable(bool enable)
1842 REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 27, 27);
1846 void dispc_enable_fifohandcheck(enum omap_channel channel, bool enable)
1849 REG_FLD_MOD(DISPC_CONFIG, enable ? 1 : 0, 16, 16);
1854 void dispc_set_lcd_display_type(enum omap_channel channel,
1855 enum omap_lcd_display_type type)
1860 case OMAP_DSS_LCD_DISPLAY_STN:
1864 case OMAP_DSS_LCD_DISPLAY_TFT:
1874 REG_FLD_MOD(DISPC_CONTROL, mode, 3, 3);
1878 void dispc_set_loadmode(enum omap_dss_load_mode mode)
1881 REG_FLD_MOD(DISPC_CONFIG, mode, 2, 1);
1886 void dispc_set_default_color(enum omap_channel channel, u32 color)
1889 dispc_write_reg(DISPC_DEFAULT_COLOR(channel), color);
1893 u32 dispc_get_default_color(enum omap_channel channel)
1897 BUG_ON(channel != OMAP_DSS_CHANNEL_DIGIT &&
1898 channel != OMAP_DSS_CHANNEL_LCD);
1901 l = dispc_read_reg(DISPC_DEFAULT_COLOR(channel));
1907 void dispc_set_trans_key(enum omap_channel ch,
1908 enum omap_dss_trans_key_type type,
1912 if (ch == OMAP_DSS_CHANNEL_LCD)
1913 REG_FLD_MOD(DISPC_CONFIG, type, 11, 11);
1914 else /* OMAP_DSS_CHANNEL_DIGIT */
1915 REG_FLD_MOD(DISPC_CONFIG, type, 13, 13);
1917 dispc_write_reg(DISPC_TRANS_COLOR(ch), trans_key);
1921 void dispc_get_trans_key(enum omap_channel ch,
1922 enum omap_dss_trans_key_type *type,
1927 if (ch == OMAP_DSS_CHANNEL_LCD)
1928 *type = REG_GET(DISPC_CONFIG, 11, 11);
1929 else if (ch == OMAP_DSS_CHANNEL_DIGIT)
1930 *type = REG_GET(DISPC_CONFIG, 13, 13);
1936 *trans_key = dispc_read_reg(DISPC_TRANS_COLOR(ch));
1940 void dispc_enable_trans_key(enum omap_channel ch, bool enable)
1943 if (ch == OMAP_DSS_CHANNEL_LCD)
1944 REG_FLD_MOD(DISPC_CONFIG, enable, 10, 10);
1945 else /* OMAP_DSS_CHANNEL_DIGIT */
1946 REG_FLD_MOD(DISPC_CONFIG, enable, 12, 12);
1949 void dispc_enable_alpha_blending(enum omap_channel ch, bool enable)
1951 if (!dss_has_feature(FEAT_GLOBAL_ALPHA))
1955 if (ch == OMAP_DSS_CHANNEL_LCD)
1956 REG_FLD_MOD(DISPC_CONFIG, enable, 18, 18);
1957 else /* OMAP_DSS_CHANNEL_DIGIT */
1958 REG_FLD_MOD(DISPC_CONFIG, enable, 19, 19);
1961 bool dispc_alpha_blending_enabled(enum omap_channel ch)
1965 if (!dss_has_feature(FEAT_GLOBAL_ALPHA))
1969 if (ch == OMAP_DSS_CHANNEL_LCD)
1970 enabled = REG_GET(DISPC_CONFIG, 18, 18);
1971 else if (ch == OMAP_DSS_CHANNEL_DIGIT)
1972 enabled = REG_GET(DISPC_CONFIG, 19, 19);
1981 bool dispc_trans_key_enabled(enum omap_channel ch)
1986 if (ch == OMAP_DSS_CHANNEL_LCD)
1987 enabled = REG_GET(DISPC_CONFIG, 10, 10);
1988 else if (ch == OMAP_DSS_CHANNEL_DIGIT)
1989 enabled = REG_GET(DISPC_CONFIG, 12, 12);
1998 void dispc_set_tft_data_lines(enum omap_channel channel, u8 data_lines)
2002 switch (data_lines) {
2021 REG_FLD_MOD(DISPC_CONTROL, code, 9, 8);
2025 void dispc_set_parallel_interface_mode(enum omap_channel channel,
2026 enum omap_parallel_interface_mode mode)
2034 case OMAP_DSS_PARALLELMODE_BYPASS:
2039 case OMAP_DSS_PARALLELMODE_RFBI:
2044 case OMAP_DSS_PARALLELMODE_DSI:
2056 l = dispc_read_reg(DISPC_CONTROL);
2058 l = FLD_MOD(l, stallmode, 11, 11);
2060 if (channel == OMAP_DSS_CHANNEL_LCD) {
2061 l = FLD_MOD(l, gpout0, 15, 15);
2062 l = FLD_MOD(l, gpout1, 16, 16);
2064 dispc_write_reg(DISPC_CONTROL, l);
2069 static bool _dispc_lcd_timings_ok(int hsw, int hfp, int hbp,
2070 int vsw, int vfp, int vbp)
2072 if (cpu_is_omap24xx() || omap_rev() < OMAP3430_REV_ES3_0) {
2073 if (hsw < 1 || hsw > 64 ||
2074 hfp < 1 || hfp > 256 ||
2075 hbp < 1 || hbp > 256 ||
2076 vsw < 1 || vsw > 64 ||
2077 vfp < 0 || vfp > 255 ||
2078 vbp < 0 || vbp > 255)
2081 if (hsw < 1 || hsw > 256 ||
2082 hfp < 1 || hfp > 4096 ||
2083 hbp < 1 || hbp > 4096 ||
2084 vsw < 1 || vsw > 256 ||
2085 vfp < 0 || vfp > 4095 ||
2086 vbp < 0 || vbp > 4095)
2093 bool dispc_lcd_timings_ok(struct omap_video_timings *timings)
2095 return _dispc_lcd_timings_ok(timings->hsw, timings->hfp,
2096 timings->hbp, timings->vsw,
2097 timings->vfp, timings->vbp);
2100 static void _dispc_set_lcd_timings(enum omap_channel channel, int hsw,
2101 int hfp, int hbp, int vsw, int vfp, int vbp)
2103 u32 timing_h, timing_v;
2105 if (cpu_is_omap24xx() || omap_rev() < OMAP3430_REV_ES3_0) {
2106 timing_h = FLD_VAL(hsw-1, 5, 0) | FLD_VAL(hfp-1, 15, 8) |
2107 FLD_VAL(hbp-1, 27, 20);
2109 timing_v = FLD_VAL(vsw-1, 5, 0) | FLD_VAL(vfp, 15, 8) |
2110 FLD_VAL(vbp, 27, 20);
2112 timing_h = FLD_VAL(hsw-1, 7, 0) | FLD_VAL(hfp-1, 19, 8) |
2113 FLD_VAL(hbp-1, 31, 20);
2115 timing_v = FLD_VAL(vsw-1, 7, 0) | FLD_VAL(vfp, 19, 8) |
2116 FLD_VAL(vbp, 31, 20);
2120 dispc_write_reg(DISPC_TIMING_H(channel), timing_h);
2121 dispc_write_reg(DISPC_TIMING_V(channel), timing_v);
2125 /* change name to mode? */
2126 void dispc_set_lcd_timings(enum omap_channel channel,
2127 struct omap_video_timings *timings)
2129 unsigned xtot, ytot;
2130 unsigned long ht, vt;
2132 if (!_dispc_lcd_timings_ok(timings->hsw, timings->hfp,
2133 timings->hbp, timings->vsw,
2134 timings->vfp, timings->vbp))
2137 _dispc_set_lcd_timings(channel, timings->hsw, timings->hfp,
2138 timings->hbp, timings->vsw, timings->vfp,
2141 dispc_set_lcd_size(channel, timings->x_res, timings->y_res);
2143 xtot = timings->x_res + timings->hfp + timings->hsw + timings->hbp;
2144 ytot = timings->y_res + timings->vfp + timings->vsw + timings->vbp;
2146 ht = (timings->pixel_clock * 1000) / xtot;
2147 vt = (timings->pixel_clock * 1000) / xtot / ytot;
2149 DSSDBG("xres %u yres %u\n", timings->x_res, timings->y_res);
2150 DSSDBG("pck %u\n", timings->pixel_clock);
2151 DSSDBG("hsw %d hfp %d hbp %d vsw %d vfp %d vbp %d\n",
2152 timings->hsw, timings->hfp, timings->hbp,
2153 timings->vsw, timings->vfp, timings->vbp);
2155 DSSDBG("hsync %luHz, vsync %luHz\n", ht, vt);
2158 static void dispc_set_lcd_divisor(u16 lck_div, u16 pck_div)
2160 BUG_ON(lck_div < 1);
2161 BUG_ON(pck_div < 2);
2164 dispc_write_reg(DISPC_DIVISOR(OMAP_DSS_CHANNEL_LCD),
2165 FLD_VAL(lck_div, 23, 16) | FLD_VAL(pck_div, 7, 0));
2169 static void dispc_get_lcd_divisor(int *lck_div, int *pck_div)
2172 l = dispc_read_reg(DISPC_DIVISOR(OMAP_DSS_CHANNEL_LCD));
2173 *lck_div = FLD_GET(l, 23, 16);
2174 *pck_div = FLD_GET(l, 7, 0);
2177 unsigned long dispc_fclk_rate(void)
2179 unsigned long r = 0;
2181 if (dss_get_dispc_clk_source() == DSS_SRC_DSS1_ALWON_FCLK)
2182 r = dss_clk_get_rate(DSS_CLK_FCK1);
2184 #ifdef CONFIG_OMAP2_DSS_DSI
2185 r = dsi_get_dsi1_pll_rate();
2192 unsigned long dispc_lclk_rate(void)
2198 l = dispc_read_reg(DISPC_DIVISOR(OMAP_DSS_CHANNEL_LCD));
2200 lcd = FLD_GET(l, 23, 16);
2202 r = dispc_fclk_rate();
2207 unsigned long dispc_pclk_rate(void)
2213 l = dispc_read_reg(DISPC_DIVISOR(OMAP_DSS_CHANNEL_LCD));
2215 lcd = FLD_GET(l, 23, 16);
2216 pcd = FLD_GET(l, 7, 0);
2218 r = dispc_fclk_rate();
2220 return r / lcd / pcd;
2223 void dispc_dump_clocks(struct seq_file *s)
2229 dispc_get_lcd_divisor(&lcd, &pcd);
2231 seq_printf(s, "- DISPC -\n");
2233 seq_printf(s, "dispc fclk source = %s\n",
2234 dss_get_dispc_clk_source() == DSS_SRC_DSS1_ALWON_FCLK ?
2235 "dss1_alwon_fclk" : "dsi1_pll_fclk");
2237 seq_printf(s, "fck\t\t%-16lu\n", dispc_fclk_rate());
2238 seq_printf(s, "lck\t\t%-16lulck div\t%u\n", dispc_lclk_rate(), lcd);
2239 seq_printf(s, "pck\t\t%-16lupck div\t%u\n", dispc_pclk_rate(), pcd);
2244 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
2245 void dispc_dump_irqs(struct seq_file *s)
2247 unsigned long flags;
2248 struct dispc_irq_stats stats;
2250 spin_lock_irqsave(&dispc.irq_stats_lock, flags);
2252 stats = dispc.irq_stats;
2253 memset(&dispc.irq_stats, 0, sizeof(dispc.irq_stats));
2254 dispc.irq_stats.last_reset = jiffies;
2256 spin_unlock_irqrestore(&dispc.irq_stats_lock, flags);
2258 seq_printf(s, "period %u ms\n",
2259 jiffies_to_msecs(jiffies - stats.last_reset));
2261 seq_printf(s, "irqs %d\n", stats.irq_count);
2263 seq_printf(s, "%-20s %10d\n", #x, stats.irqs[ffs(DISPC_IRQ_##x)-1]);
2269 PIS(ACBIAS_COUNT_STAT);
2271 PIS(GFX_FIFO_UNDERFLOW);
2273 PIS(PAL_GAMMA_MASK);
2275 PIS(VID1_FIFO_UNDERFLOW);
2277 PIS(VID2_FIFO_UNDERFLOW);
2280 PIS(SYNC_LOST_DIGIT);
2286 void dispc_dump_regs(struct seq_file *s)
2288 #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dispc_read_reg(r))
2290 dss_clk_enable(DSS_CLK_ICK | DSS_CLK_FCK1);
2292 DUMPREG(DISPC_REVISION);
2293 DUMPREG(DISPC_SYSCONFIG);
2294 DUMPREG(DISPC_SYSSTATUS);
2295 DUMPREG(DISPC_IRQSTATUS);
2296 DUMPREG(DISPC_IRQENABLE);
2297 DUMPREG(DISPC_CONTROL);
2298 DUMPREG(DISPC_CONFIG);
2299 DUMPREG(DISPC_CAPABLE);
2300 DUMPREG(DISPC_DEFAULT_COLOR(0));
2301 DUMPREG(DISPC_DEFAULT_COLOR(1));
2302 DUMPREG(DISPC_TRANS_COLOR(0));
2303 DUMPREG(DISPC_TRANS_COLOR(1));
2304 DUMPREG(DISPC_LINE_STATUS);
2305 DUMPREG(DISPC_LINE_NUMBER);
2306 DUMPREG(DISPC_TIMING_H(0));
2307 DUMPREG(DISPC_TIMING_V(0));
2308 DUMPREG(DISPC_POL_FREQ(0));
2309 DUMPREG(DISPC_DIVISOR(0));
2310 DUMPREG(DISPC_GLOBAL_ALPHA);
2311 DUMPREG(DISPC_SIZE_DIG);
2312 DUMPREG(DISPC_SIZE_LCD(0));
2314 DUMPREG(DISPC_GFX_BA0);
2315 DUMPREG(DISPC_GFX_BA1);
2316 DUMPREG(DISPC_GFX_POSITION);
2317 DUMPREG(DISPC_GFX_SIZE);
2318 DUMPREG(DISPC_GFX_ATTRIBUTES);
2319 DUMPREG(DISPC_GFX_FIFO_THRESHOLD);
2320 DUMPREG(DISPC_GFX_FIFO_SIZE_STATUS);
2321 DUMPREG(DISPC_GFX_ROW_INC);
2322 DUMPREG(DISPC_GFX_PIXEL_INC);
2323 DUMPREG(DISPC_GFX_WINDOW_SKIP);
2324 DUMPREG(DISPC_GFX_TABLE_BA);
2326 DUMPREG(DISPC_DATA_CYCLE1(0));
2327 DUMPREG(DISPC_DATA_CYCLE2(0));
2328 DUMPREG(DISPC_DATA_CYCLE3(0));
2330 DUMPREG(DISPC_CPR_COEF_R(0));
2331 DUMPREG(DISPC_CPR_COEF_G(0));
2332 DUMPREG(DISPC_CPR_COEF_B(0));
2334 DUMPREG(DISPC_GFX_PRELOAD);
2336 DUMPREG(DISPC_VID_BA0(0));
2337 DUMPREG(DISPC_VID_BA1(0));
2338 DUMPREG(DISPC_VID_POSITION(0));
2339 DUMPREG(DISPC_VID_SIZE(0));
2340 DUMPREG(DISPC_VID_ATTRIBUTES(0));
2341 DUMPREG(DISPC_VID_FIFO_THRESHOLD(0));
2342 DUMPREG(DISPC_VID_FIFO_SIZE_STATUS(0));
2343 DUMPREG(DISPC_VID_ROW_INC(0));
2344 DUMPREG(DISPC_VID_PIXEL_INC(0));
2345 DUMPREG(DISPC_VID_FIR(0));
2346 DUMPREG(DISPC_VID_PICTURE_SIZE(0));
2347 DUMPREG(DISPC_VID_ACCU0(0));
2348 DUMPREG(DISPC_VID_ACCU1(0));
2350 DUMPREG(DISPC_VID_BA0(1));
2351 DUMPREG(DISPC_VID_BA1(1));
2352 DUMPREG(DISPC_VID_POSITION(1));
2353 DUMPREG(DISPC_VID_SIZE(1));
2354 DUMPREG(DISPC_VID_ATTRIBUTES(1));
2355 DUMPREG(DISPC_VID_FIFO_THRESHOLD(1));
2356 DUMPREG(DISPC_VID_FIFO_SIZE_STATUS(1));
2357 DUMPREG(DISPC_VID_ROW_INC(1));
2358 DUMPREG(DISPC_VID_PIXEL_INC(1));
2359 DUMPREG(DISPC_VID_FIR(1));
2360 DUMPREG(DISPC_VID_PICTURE_SIZE(1));
2361 DUMPREG(DISPC_VID_ACCU0(1));
2362 DUMPREG(DISPC_VID_ACCU1(1));
2364 DUMPREG(DISPC_VID_FIR_COEF_H(0, 0));
2365 DUMPREG(DISPC_VID_FIR_COEF_H(0, 1));
2366 DUMPREG(DISPC_VID_FIR_COEF_H(0, 2));
2367 DUMPREG(DISPC_VID_FIR_COEF_H(0, 3));
2368 DUMPREG(DISPC_VID_FIR_COEF_H(0, 4));
2369 DUMPREG(DISPC_VID_FIR_COEF_H(0, 5));
2370 DUMPREG(DISPC_VID_FIR_COEF_H(0, 6));
2371 DUMPREG(DISPC_VID_FIR_COEF_H(0, 7));
2372 DUMPREG(DISPC_VID_FIR_COEF_HV(0, 0));
2373 DUMPREG(DISPC_VID_FIR_COEF_HV(0, 1));
2374 DUMPREG(DISPC_VID_FIR_COEF_HV(0, 2));
2375 DUMPREG(DISPC_VID_FIR_COEF_HV(0, 3));
2376 DUMPREG(DISPC_VID_FIR_COEF_HV(0, 4));
2377 DUMPREG(DISPC_VID_FIR_COEF_HV(0, 5));
2378 DUMPREG(DISPC_VID_FIR_COEF_HV(0, 6));
2379 DUMPREG(DISPC_VID_FIR_COEF_HV(0, 7));
2380 DUMPREG(DISPC_VID_CONV_COEF(0, 0));
2381 DUMPREG(DISPC_VID_CONV_COEF(0, 1));
2382 DUMPREG(DISPC_VID_CONV_COEF(0, 2));
2383 DUMPREG(DISPC_VID_CONV_COEF(0, 3));
2384 DUMPREG(DISPC_VID_CONV_COEF(0, 4));
2385 DUMPREG(DISPC_VID_FIR_COEF_V(0, 0));
2386 DUMPREG(DISPC_VID_FIR_COEF_V(0, 1));
2387 DUMPREG(DISPC_VID_FIR_COEF_V(0, 2));
2388 DUMPREG(DISPC_VID_FIR_COEF_V(0, 3));
2389 DUMPREG(DISPC_VID_FIR_COEF_V(0, 4));
2390 DUMPREG(DISPC_VID_FIR_COEF_V(0, 5));
2391 DUMPREG(DISPC_VID_FIR_COEF_V(0, 6));
2392 DUMPREG(DISPC_VID_FIR_COEF_V(0, 7));
2394 DUMPREG(DISPC_VID_FIR_COEF_H(1, 0));
2395 DUMPREG(DISPC_VID_FIR_COEF_H(1, 1));
2396 DUMPREG(DISPC_VID_FIR_COEF_H(1, 2));
2397 DUMPREG(DISPC_VID_FIR_COEF_H(1, 3));
2398 DUMPREG(DISPC_VID_FIR_COEF_H(1, 4));
2399 DUMPREG(DISPC_VID_FIR_COEF_H(1, 5));
2400 DUMPREG(DISPC_VID_FIR_COEF_H(1, 6));
2401 DUMPREG(DISPC_VID_FIR_COEF_H(1, 7));
2402 DUMPREG(DISPC_VID_FIR_COEF_HV(1, 0));
2403 DUMPREG(DISPC_VID_FIR_COEF_HV(1, 1));
2404 DUMPREG(DISPC_VID_FIR_COEF_HV(1, 2));
2405 DUMPREG(DISPC_VID_FIR_COEF_HV(1, 3));
2406 DUMPREG(DISPC_VID_FIR_COEF_HV(1, 4));
2407 DUMPREG(DISPC_VID_FIR_COEF_HV(1, 5));
2408 DUMPREG(DISPC_VID_FIR_COEF_HV(1, 6));
2409 DUMPREG(DISPC_VID_FIR_COEF_HV(1, 7));
2410 DUMPREG(DISPC_VID_CONV_COEF(1, 0));
2411 DUMPREG(DISPC_VID_CONV_COEF(1, 1));
2412 DUMPREG(DISPC_VID_CONV_COEF(1, 2));
2413 DUMPREG(DISPC_VID_CONV_COEF(1, 3));
2414 DUMPREG(DISPC_VID_CONV_COEF(1, 4));
2415 DUMPREG(DISPC_VID_FIR_COEF_V(1, 0));
2416 DUMPREG(DISPC_VID_FIR_COEF_V(1, 1));
2417 DUMPREG(DISPC_VID_FIR_COEF_V(1, 2));
2418 DUMPREG(DISPC_VID_FIR_COEF_V(1, 3));
2419 DUMPREG(DISPC_VID_FIR_COEF_V(1, 4));
2420 DUMPREG(DISPC_VID_FIR_COEF_V(1, 5));
2421 DUMPREG(DISPC_VID_FIR_COEF_V(1, 6));
2422 DUMPREG(DISPC_VID_FIR_COEF_V(1, 7));
2424 DUMPREG(DISPC_VID_PRELOAD(0));
2425 DUMPREG(DISPC_VID_PRELOAD(1));
2427 dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK1);
2431 static void _dispc_set_pol_freq(bool onoff, bool rf, bool ieo, bool ipc,
2432 bool ihs, bool ivs, u8 acbi, u8 acb)
2436 DSSDBG("onoff %d rf %d ieo %d ipc %d ihs %d ivs %d acbi %d acb %d\n",
2437 onoff, rf, ieo, ipc, ihs, ivs, acbi, acb);
2439 l |= FLD_VAL(onoff, 17, 17);
2440 l |= FLD_VAL(rf, 16, 16);
2441 l |= FLD_VAL(ieo, 15, 15);
2442 l |= FLD_VAL(ipc, 14, 14);
2443 l |= FLD_VAL(ihs, 13, 13);
2444 l |= FLD_VAL(ivs, 12, 12);
2445 l |= FLD_VAL(acbi, 11, 8);
2446 l |= FLD_VAL(acb, 7, 0);
2449 dispc_write_reg(DISPC_POL_FREQ(OMAP_DSS_CHANNEL_LCD), l);
2453 void dispc_set_pol_freq(enum omap_panel_config config, u8 acbi, u8 acb)
2455 _dispc_set_pol_freq((config & OMAP_DSS_LCD_ONOFF) != 0,
2456 (config & OMAP_DSS_LCD_RF) != 0,
2457 (config & OMAP_DSS_LCD_IEO) != 0,
2458 (config & OMAP_DSS_LCD_IPC) != 0,
2459 (config & OMAP_DSS_LCD_IHS) != 0,
2460 (config & OMAP_DSS_LCD_IVS) != 0,
2464 /* with fck as input clock rate, find dispc dividers that produce req_pck */
2465 void dispc_find_clk_divs(bool is_tft, unsigned long req_pck, unsigned long fck,
2466 struct dispc_clock_info *cinfo)
2468 u16 pcd_min = is_tft ? 2 : 3;
2469 unsigned long best_pck;
2470 u16 best_ld, cur_ld;
2471 u16 best_pd, cur_pd;
2477 for (cur_ld = 1; cur_ld <= 255; ++cur_ld) {
2478 unsigned long lck = fck / cur_ld;
2480 for (cur_pd = pcd_min; cur_pd <= 255; ++cur_pd) {
2481 unsigned long pck = lck / cur_pd;
2482 long old_delta = abs(best_pck - req_pck);
2483 long new_delta = abs(pck - req_pck);
2485 if (best_pck == 0 || new_delta < old_delta) {
2498 if (lck / pcd_min < req_pck)
2503 cinfo->lck_div = best_ld;
2504 cinfo->pck_div = best_pd;
2505 cinfo->lck = fck / cinfo->lck_div;
2506 cinfo->pck = cinfo->lck / cinfo->pck_div;
2509 /* calculate clock rates using dividers in cinfo */
2510 int dispc_calc_clock_rates(unsigned long dispc_fclk_rate,
2511 struct dispc_clock_info *cinfo)
2513 if (cinfo->lck_div > 255 || cinfo->lck_div == 0)
2515 if (cinfo->pck_div < 2 || cinfo->pck_div > 255)
2518 cinfo->lck = dispc_fclk_rate / cinfo->lck_div;
2519 cinfo->pck = cinfo->lck / cinfo->pck_div;
2524 int dispc_set_clock_div(struct dispc_clock_info *cinfo)
2526 DSSDBG("lck = %lu (%u)\n", cinfo->lck, cinfo->lck_div);
2527 DSSDBG("pck = %lu (%u)\n", cinfo->pck, cinfo->pck_div);
2529 dispc_set_lcd_divisor(cinfo->lck_div, cinfo->pck_div);
2534 int dispc_get_clock_div(struct dispc_clock_info *cinfo)
2538 fck = dispc_fclk_rate();
2540 cinfo->lck_div = REG_GET(DISPC_DIVISOR(OMAP_DSS_CHANNEL_LCD), 23, 16);
2541 cinfo->pck_div = REG_GET(DISPC_DIVISOR(OMAP_DSS_CHANNEL_LCD), 7, 0);
2543 cinfo->lck = fck / cinfo->lck_div;
2544 cinfo->pck = cinfo->lck / cinfo->pck_div;
2549 /* dispc.irq_lock has to be locked by the caller */
2550 static void _omap_dispc_set_irqs(void)
2555 struct omap_dispc_isr_data *isr_data;
2557 mask = dispc.irq_error_mask;
2559 for (i = 0; i < DISPC_MAX_NR_ISRS; i++) {
2560 isr_data = &dispc.registered_isr[i];
2562 if (isr_data->isr == NULL)
2565 mask |= isr_data->mask;
2570 old_mask = dispc_read_reg(DISPC_IRQENABLE);
2571 /* clear the irqstatus for newly enabled irqs */
2572 dispc_write_reg(DISPC_IRQSTATUS, (mask ^ old_mask) & mask);
2574 dispc_write_reg(DISPC_IRQENABLE, mask);
2579 int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask)
2583 unsigned long flags;
2584 struct omap_dispc_isr_data *isr_data;
2589 spin_lock_irqsave(&dispc.irq_lock, flags);
2591 /* check for duplicate entry */
2592 for (i = 0; i < DISPC_MAX_NR_ISRS; i++) {
2593 isr_data = &dispc.registered_isr[i];
2594 if (isr_data->isr == isr && isr_data->arg == arg &&
2595 isr_data->mask == mask) {
2604 for (i = 0; i < DISPC_MAX_NR_ISRS; i++) {
2605 isr_data = &dispc.registered_isr[i];
2607 if (isr_data->isr != NULL)
2610 isr_data->isr = isr;
2611 isr_data->arg = arg;
2612 isr_data->mask = mask;
2618 _omap_dispc_set_irqs();
2620 spin_unlock_irqrestore(&dispc.irq_lock, flags);
2624 spin_unlock_irqrestore(&dispc.irq_lock, flags);
2628 EXPORT_SYMBOL(omap_dispc_register_isr);
2630 int omap_dispc_unregister_isr(omap_dispc_isr_t isr, void *arg, u32 mask)
2633 unsigned long flags;
2635 struct omap_dispc_isr_data *isr_data;
2637 spin_lock_irqsave(&dispc.irq_lock, flags);
2639 for (i = 0; i < DISPC_MAX_NR_ISRS; i++) {
2640 isr_data = &dispc.registered_isr[i];
2641 if (isr_data->isr != isr || isr_data->arg != arg ||
2642 isr_data->mask != mask)
2645 /* found the correct isr */
2647 isr_data->isr = NULL;
2648 isr_data->arg = NULL;
2656 _omap_dispc_set_irqs();
2658 spin_unlock_irqrestore(&dispc.irq_lock, flags);
2662 EXPORT_SYMBOL(omap_dispc_unregister_isr);
2665 static void print_irq_status(u32 status)
2667 if ((status & dispc.irq_error_mask) == 0)
2670 printk(KERN_DEBUG "DISPC IRQ: 0x%x: ", status);
2673 if (status & DISPC_IRQ_##x) \
2675 PIS(GFX_FIFO_UNDERFLOW);
2677 PIS(VID1_FIFO_UNDERFLOW);
2678 PIS(VID2_FIFO_UNDERFLOW);
2680 PIS(SYNC_LOST_DIGIT);
2687 /* Called from dss.c. Note that we don't touch clocks here,
2688 * but we presume they are on because we got an IRQ. However,
2689 * an irq handler may turn the clocks off, so we may not have
2690 * clock later in the function. */
2691 void dispc_irq_handler(void)
2695 u32 handledirqs = 0;
2696 u32 unhandled_errors;
2697 struct omap_dispc_isr_data *isr_data;
2698 struct omap_dispc_isr_data registered_isr[DISPC_MAX_NR_ISRS];
2700 spin_lock(&dispc.irq_lock);
2702 irqstatus = dispc_read_reg(DISPC_IRQSTATUS);
2704 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
2705 spin_lock(&dispc.irq_stats_lock);
2706 dispc.irq_stats.irq_count++;
2707 dss_collect_irq_stats(irqstatus, dispc.irq_stats.irqs);
2708 spin_unlock(&dispc.irq_stats_lock);
2713 print_irq_status(irqstatus);
2715 /* Ack the interrupt. Do it here before clocks are possibly turned
2717 dispc_write_reg(DISPC_IRQSTATUS, irqstatus);
2718 /* flush posted write */
2719 dispc_read_reg(DISPC_IRQSTATUS);
2721 /* make a copy and unlock, so that isrs can unregister
2723 memcpy(registered_isr, dispc.registered_isr,
2724 sizeof(registered_isr));
2726 spin_unlock(&dispc.irq_lock);
2728 for (i = 0; i < DISPC_MAX_NR_ISRS; i++) {
2729 isr_data = ®istered_isr[i];
2734 if (isr_data->mask & irqstatus) {
2735 isr_data->isr(isr_data->arg, irqstatus);
2736 handledirqs |= isr_data->mask;
2740 spin_lock(&dispc.irq_lock);
2742 unhandled_errors = irqstatus & ~handledirqs & dispc.irq_error_mask;
2744 if (unhandled_errors) {
2745 dispc.error_irqs |= unhandled_errors;
2747 dispc.irq_error_mask &= ~unhandled_errors;
2748 _omap_dispc_set_irqs();
2750 schedule_work(&dispc.error_work);
2753 spin_unlock(&dispc.irq_lock);
2756 static void dispc_error_worker(struct work_struct *work)
2760 unsigned long flags;
2762 spin_lock_irqsave(&dispc.irq_lock, flags);
2763 errors = dispc.error_irqs;
2764 dispc.error_irqs = 0;
2765 spin_unlock_irqrestore(&dispc.irq_lock, flags);
2767 if (errors & DISPC_IRQ_GFX_FIFO_UNDERFLOW) {
2768 DSSERR("GFX_FIFO_UNDERFLOW, disabling GFX\n");
2769 for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
2770 struct omap_overlay *ovl;
2771 ovl = omap_dss_get_overlay(i);
2773 if (!(ovl->caps & OMAP_DSS_OVL_CAP_DISPC))
2777 dispc_enable_plane(ovl->id, 0);
2778 dispc_go(ovl->manager->id);
2785 if (errors & DISPC_IRQ_VID1_FIFO_UNDERFLOW) {
2786 DSSERR("VID1_FIFO_UNDERFLOW, disabling VID1\n");
2787 for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
2788 struct omap_overlay *ovl;
2789 ovl = omap_dss_get_overlay(i);
2791 if (!(ovl->caps & OMAP_DSS_OVL_CAP_DISPC))
2795 dispc_enable_plane(ovl->id, 0);
2796 dispc_go(ovl->manager->id);
2803 if (errors & DISPC_IRQ_VID2_FIFO_UNDERFLOW) {
2804 DSSERR("VID2_FIFO_UNDERFLOW, disabling VID2\n");
2805 for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
2806 struct omap_overlay *ovl;
2807 ovl = omap_dss_get_overlay(i);
2809 if (!(ovl->caps & OMAP_DSS_OVL_CAP_DISPC))
2813 dispc_enable_plane(ovl->id, 0);
2814 dispc_go(ovl->manager->id);
2821 if (errors & DISPC_IRQ_SYNC_LOST) {
2822 struct omap_overlay_manager *manager = NULL;
2823 bool enable = false;
2825 DSSERR("SYNC_LOST, disabling LCD\n");
2827 for (i = 0; i < omap_dss_get_num_overlay_managers(); ++i) {
2828 struct omap_overlay_manager *mgr;
2829 mgr = omap_dss_get_overlay_manager(i);
2831 if (mgr->id == OMAP_DSS_CHANNEL_LCD) {
2833 enable = mgr->device->state ==
2834 OMAP_DSS_DISPLAY_ACTIVE;
2835 mgr->device->driver->disable(mgr->device);
2841 struct omap_dss_device *dssdev = manager->device;
2842 for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
2843 struct omap_overlay *ovl;
2844 ovl = omap_dss_get_overlay(i);
2846 if (!(ovl->caps & OMAP_DSS_OVL_CAP_DISPC))
2849 if (ovl->id != 0 && ovl->manager == manager)
2850 dispc_enable_plane(ovl->id, 0);
2853 dispc_go(manager->id);
2856 dssdev->driver->enable(dssdev);
2860 if (errors & DISPC_IRQ_SYNC_LOST_DIGIT) {
2861 struct omap_overlay_manager *manager = NULL;
2862 bool enable = false;
2864 DSSERR("SYNC_LOST_DIGIT, disabling TV\n");
2866 for (i = 0; i < omap_dss_get_num_overlay_managers(); ++i) {
2867 struct omap_overlay_manager *mgr;
2868 mgr = omap_dss_get_overlay_manager(i);
2870 if (mgr->id == OMAP_DSS_CHANNEL_DIGIT) {
2872 enable = mgr->device->state ==
2873 OMAP_DSS_DISPLAY_ACTIVE;
2874 mgr->device->driver->disable(mgr->device);
2880 struct omap_dss_device *dssdev = manager->device;
2881 for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
2882 struct omap_overlay *ovl;
2883 ovl = omap_dss_get_overlay(i);
2885 if (!(ovl->caps & OMAP_DSS_OVL_CAP_DISPC))
2888 if (ovl->id != 0 && ovl->manager == manager)
2889 dispc_enable_plane(ovl->id, 0);
2892 dispc_go(manager->id);
2895 dssdev->driver->enable(dssdev);
2899 if (errors & DISPC_IRQ_OCP_ERR) {
2900 DSSERR("OCP_ERR\n");
2901 for (i = 0; i < omap_dss_get_num_overlay_managers(); ++i) {
2902 struct omap_overlay_manager *mgr;
2903 mgr = omap_dss_get_overlay_manager(i);
2905 if (mgr->caps & OMAP_DSS_OVL_CAP_DISPC)
2906 mgr->device->driver->disable(mgr->device);
2910 spin_lock_irqsave(&dispc.irq_lock, flags);
2911 dispc.irq_error_mask |= errors;
2912 _omap_dispc_set_irqs();
2913 spin_unlock_irqrestore(&dispc.irq_lock, flags);
2916 int omap_dispc_wait_for_irq_timeout(u32 irqmask, unsigned long timeout)
2918 void dispc_irq_wait_handler(void *data, u32 mask)
2920 complete((struct completion *)data);
2924 DECLARE_COMPLETION_ONSTACK(completion);
2926 r = omap_dispc_register_isr(dispc_irq_wait_handler, &completion,
2932 timeout = wait_for_completion_timeout(&completion, timeout);
2934 omap_dispc_unregister_isr(dispc_irq_wait_handler, &completion, irqmask);
2939 if (timeout == -ERESTARTSYS)
2940 return -ERESTARTSYS;
2945 int omap_dispc_wait_for_irq_interruptible_timeout(u32 irqmask,
2946 unsigned long timeout)
2948 void dispc_irq_wait_handler(void *data, u32 mask)
2950 complete((struct completion *)data);
2954 DECLARE_COMPLETION_ONSTACK(completion);
2956 r = omap_dispc_register_isr(dispc_irq_wait_handler, &completion,
2962 timeout = wait_for_completion_interruptible_timeout(&completion,
2965 omap_dispc_unregister_isr(dispc_irq_wait_handler, &completion, irqmask);
2970 if (timeout == -ERESTARTSYS)
2971 return -ERESTARTSYS;
2976 #ifdef CONFIG_OMAP2_DSS_FAKE_VSYNC
2977 void dispc_fake_vsync_irq(void)
2979 u32 irqstatus = DISPC_IRQ_VSYNC;
2982 WARN_ON(!in_interrupt());
2984 for (i = 0; i < DISPC_MAX_NR_ISRS; i++) {
2985 struct omap_dispc_isr_data *isr_data;
2986 isr_data = &dispc.registered_isr[i];
2991 if (isr_data->mask & irqstatus)
2992 isr_data->isr(isr_data->arg, irqstatus);
2997 static void _omap_dispc_initialize_irq(void)
2999 unsigned long flags;
3001 spin_lock_irqsave(&dispc.irq_lock, flags);
3003 memset(dispc.registered_isr, 0, sizeof(dispc.registered_isr));
3005 dispc.irq_error_mask = DISPC_IRQ_MASK_ERROR;
3007 /* there's SYNC_LOST_DIGIT waiting after enabling the DSS,
3009 dispc_write_reg(DISPC_IRQSTATUS, dispc_read_reg(DISPC_IRQSTATUS));
3011 _omap_dispc_set_irqs();
3013 spin_unlock_irqrestore(&dispc.irq_lock, flags);
3016 void dispc_enable_sidle(void)
3018 REG_FLD_MOD(DISPC_SYSCONFIG, 2, 4, 3); /* SIDLEMODE: smart idle */
3021 void dispc_disable_sidle(void)
3023 REG_FLD_MOD(DISPC_SYSCONFIG, 1, 4, 3); /* SIDLEMODE: no idle */
3026 static void _omap_dispc_initial_config(void)
3030 l = dispc_read_reg(DISPC_SYSCONFIG);
3031 l = FLD_MOD(l, 2, 13, 12); /* MIDLEMODE: smart standby */
3032 l = FLD_MOD(l, 2, 4, 3); /* SIDLEMODE: smart idle */
3033 l = FLD_MOD(l, 1, 2, 2); /* ENWAKEUP */
3034 l = FLD_MOD(l, 1, 0, 0); /* AUTOIDLE */
3035 dispc_write_reg(DISPC_SYSCONFIG, l);
3038 REG_FLD_MOD(DISPC_CONFIG, 1, 9, 9);
3040 /* L3 firewall setting: enable access to OCM RAM */
3041 /* XXX this should be somewhere in plat-omap */
3042 if (cpu_is_omap24xx())
3043 __raw_writel(0x402000b0, OMAP2_L3_IO_ADDRESS(0x680050a0));
3045 _dispc_setup_color_conv_coef();
3047 dispc_set_loadmode(OMAP_DSS_LOAD_FRAME_ONLY);
3049 dispc_read_plane_fifo_sizes();
3052 int dispc_init(void)
3056 spin_lock_init(&dispc.irq_lock);
3058 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
3059 spin_lock_init(&dispc.irq_stats_lock);
3060 dispc.irq_stats.last_reset = jiffies;
3063 INIT_WORK(&dispc.error_work, dispc_error_worker);
3065 dispc.base = ioremap(DISPC_BASE, DISPC_SZ_REGS);
3067 DSSERR("can't ioremap DISPC\n");
3073 _omap_dispc_initial_config();
3075 _omap_dispc_initialize_irq();
3077 dispc_save_context();
3079 rev = dispc_read_reg(DISPC_REVISION);
3080 printk(KERN_INFO "OMAP DISPC rev %d.%d\n",
3081 FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
3088 void dispc_exit(void)
3090 iounmap(dispc.base);
3093 int dispc_enable_plane(enum omap_plane plane, bool enable)
3095 DSSDBG("dispc_enable_plane %d, %d\n", plane, enable);
3098 _dispc_enable_plane(plane, enable);
3104 int dispc_setup_plane(enum omap_plane plane,
3105 u32 paddr, u16 screen_width,
3106 u16 pos_x, u16 pos_y,
3107 u16 width, u16 height,
3108 u16 out_width, u16 out_height,
3109 enum omap_color_mode color_mode,
3111 enum omap_dss_rotation_type rotation_type,
3112 u8 rotation, bool mirror, u8 global_alpha,
3117 DSSDBG("dispc_setup_plane %d, pa %x, sw %d, %d,%d, %dx%d -> "
3118 "%dx%d, ilace %d, cmode %x, rot %d, mir %d\n",
3119 plane, paddr, screen_width, pos_x, pos_y,
3121 out_width, out_height,
3127 r = _dispc_setup_plane(plane,
3128 paddr, screen_width,
3131 out_width, out_height,