1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2009 Nokia Corporation
6 * Some code and ideas taken from drivers/video/omap/ driver
10 #define DSS_SUBSYS_NAME "DISPC"
12 #include <linux/kernel.h>
13 #include <linux/dma-mapping.h>
14 #include <linux/vmalloc.h>
15 #include <linux/export.h>
16 #include <linux/clk.h>
18 #include <linux/jiffies.h>
19 #include <linux/seq_file.h>
20 #include <linux/delay.h>
21 #include <linux/workqueue.h>
22 #include <linux/hardirq.h>
23 #include <linux/platform_device.h>
24 #include <linux/pm_runtime.h>
25 #include <linux/property.h>
26 #include <linux/sizes.h>
27 #include <linux/mfd/syscon.h>
28 #include <linux/regmap.h>
30 #include <linux/component.h>
31 #include <linux/sys_soc.h>
32 #include <drm/drm_fourcc.h>
33 #include <drm/drm_blend.h>
42 #define DISPC_SZ_REGS SZ_4K
44 enum omap_burst_size {
50 #define REG_GET(dispc, idx, start, end) \
51 FLD_GET(dispc_read_reg(dispc, idx), start, end)
53 #define REG_FLD_MOD(dispc, idx, val, start, end) \
54 dispc_write_reg(dispc, idx, \
55 FLD_MOD(dispc_read_reg(dispc, idx), val, start, end))
57 /* DISPC has feature id */
58 enum dispc_feature_id {
68 /* Independent core clk divider */
70 FEAT_HANDLE_UV_SEPARATE,
75 FEAT_ALPHA_FIXED_ZORDER,
76 FEAT_ALPHA_FREE_ZORDER,
78 /* An unknown HW bug causing the normal FIFO thresholds not to work */
79 FEAT_OMAP3_DSI_FIFO_BUG,
84 struct dispc_features {
97 unsigned long max_lcd_pclk;
98 unsigned long max_tv_pclk;
99 unsigned int max_downscale;
100 unsigned int max_line_width;
101 unsigned int min_pcd;
102 int (*calc_scaling)(struct dispc_device *dispc,
103 unsigned long pclk, unsigned long lclk,
104 const struct videomode *vm,
105 u16 width, u16 height, u16 out_width, u16 out_height,
106 u32 fourcc, bool *five_taps,
107 int *x_predecim, int *y_predecim, int *decim_x, int *decim_y,
108 u16 pos_x, unsigned long *core_clk, bool mem_to_mem);
109 unsigned long (*calc_core_clk) (unsigned long pclk,
110 u16 width, u16 height, u16 out_width, u16 out_height,
113 const enum dispc_feature_id *features;
114 unsigned int num_features;
115 const struct dss_reg_field *reg_fields;
116 const unsigned int num_reg_fields;
117 const enum omap_overlay_caps *overlay_caps;
118 const u32 **supported_color_modes;
119 const u32 *supported_scaler_color_modes;
120 unsigned int num_mgrs;
121 unsigned int num_ovls;
122 unsigned int buffer_size_unit;
123 unsigned int burst_size_unit;
125 /* swap GFX & WB fifos */
126 bool gfx_fifo_workaround:1;
128 /* no DISPC_IRQ_FRAMEDONETV on this SoC */
129 bool no_framedone_tv:1;
131 /* revert to the OMAP4 mechanism of DISPC Smart Standby operation */
132 bool mstandby_workaround:1;
134 bool set_max_preload:1;
136 /* PIXEL_INC is not added to the last pixel of a line */
137 bool last_pixel_inc_missing:1;
139 /* POL_FREQ has ALIGN bit */
140 bool supports_sync_align:1;
142 bool has_writeback:1;
144 bool supports_double_pixel:1;
147 * Field order for VENC is different than HDMI. We should handle this in
148 * some intelligent manner, but as the SoCs have either HDMI or VENC,
149 * never both, we can just use this flag for now.
151 bool reverse_ilace_field_order:1;
153 bool has_gamma_table:1;
155 bool has_gamma_i734_bug:1;
158 #define DISPC_MAX_NR_FIFOS 5
159 #define DISPC_MAX_CHANNEL_GAMMA 4
161 struct dispc_device {
162 struct platform_device *pdev;
164 struct dss_device *dss;
166 struct dss_debugfs_entry *debugfs;
169 irq_handler_t user_handler;
172 unsigned long core_clk_rate;
173 unsigned long tv_pclk_rate;
175 u32 fifo_size[DISPC_MAX_NR_FIFOS];
176 /* maps which plane is using a fifo. fifo-id -> plane-id */
177 int fifo_assignment[DISPC_MAX_NR_FIFOS];
180 u32 ctx[DISPC_SZ_REGS / sizeof(u32)];
182 u32 *gamma_table[DISPC_MAX_CHANNEL_GAMMA];
184 const struct dispc_features *feat;
188 struct regmap *syscon_pol;
189 u32 syscon_pol_offset;
192 enum omap_color_component {
193 /* used for all color formats for OMAP3 and earlier
194 * and for RGB and Y color component on OMAP4
196 DISPC_COLOR_COMPONENT_RGB_Y = 1 << 0,
197 /* used for UV component for
198 * DRM_FORMAT_YUYV, DRM_FORMAT_UYVY, DRM_FORMAT_NV12
199 * color formats on OMAP4
201 DISPC_COLOR_COMPONENT_UV = 1 << 1,
204 enum mgr_reg_fields {
205 DISPC_MGR_FLD_ENABLE,
206 DISPC_MGR_FLD_STNTFT,
208 DISPC_MGR_FLD_TFTDATALINES,
209 DISPC_MGR_FLD_STALLMODE,
210 DISPC_MGR_FLD_TCKENABLE,
211 DISPC_MGR_FLD_TCKSELECTION,
213 DISPC_MGR_FLD_FIFOHANDCHECK,
214 /* used to maintain a count of the above fields */
218 /* DISPC register field id */
219 enum dispc_feat_reg_field {
222 FEAT_REG_FIFOHIGHTHRESHOLD,
223 FEAT_REG_FIFOLOWTHRESHOLD,
225 FEAT_REG_HORIZONTALACCU,
226 FEAT_REG_VERTICALACCU,
229 struct dispc_reg_field {
235 struct dispc_gamma_desc {
242 static const struct {
247 struct dispc_gamma_desc gamma;
248 struct dispc_reg_field reg_desc[DISPC_MGR_FLD_NUM];
250 [OMAP_DSS_CHANNEL_LCD] = {
252 .vsync_irq = DISPC_IRQ_VSYNC,
253 .framedone_irq = DISPC_IRQ_FRAMEDONE,
254 .sync_lost_irq = DISPC_IRQ_SYNC_LOST,
258 .reg = DISPC_GAMMA_TABLE0,
262 [DISPC_MGR_FLD_ENABLE] = { DISPC_CONTROL, 0, 0 },
263 [DISPC_MGR_FLD_STNTFT] = { DISPC_CONTROL, 3, 3 },
264 [DISPC_MGR_FLD_GO] = { DISPC_CONTROL, 5, 5 },
265 [DISPC_MGR_FLD_TFTDATALINES] = { DISPC_CONTROL, 9, 8 },
266 [DISPC_MGR_FLD_STALLMODE] = { DISPC_CONTROL, 11, 11 },
267 [DISPC_MGR_FLD_TCKENABLE] = { DISPC_CONFIG, 10, 10 },
268 [DISPC_MGR_FLD_TCKSELECTION] = { DISPC_CONFIG, 11, 11 },
269 [DISPC_MGR_FLD_CPR] = { DISPC_CONFIG, 15, 15 },
270 [DISPC_MGR_FLD_FIFOHANDCHECK] = { DISPC_CONFIG, 16, 16 },
273 [OMAP_DSS_CHANNEL_DIGIT] = {
275 .vsync_irq = DISPC_IRQ_EVSYNC_ODD | DISPC_IRQ_EVSYNC_EVEN,
276 .framedone_irq = DISPC_IRQ_FRAMEDONETV,
277 .sync_lost_irq = DISPC_IRQ_SYNC_LOST_DIGIT,
281 .reg = DISPC_GAMMA_TABLE2,
285 [DISPC_MGR_FLD_ENABLE] = { DISPC_CONTROL, 1, 1 },
286 [DISPC_MGR_FLD_STNTFT] = { },
287 [DISPC_MGR_FLD_GO] = { DISPC_CONTROL, 6, 6 },
288 [DISPC_MGR_FLD_TFTDATALINES] = { },
289 [DISPC_MGR_FLD_STALLMODE] = { },
290 [DISPC_MGR_FLD_TCKENABLE] = { DISPC_CONFIG, 12, 12 },
291 [DISPC_MGR_FLD_TCKSELECTION] = { DISPC_CONFIG, 13, 13 },
292 [DISPC_MGR_FLD_CPR] = { },
293 [DISPC_MGR_FLD_FIFOHANDCHECK] = { DISPC_CONFIG, 16, 16 },
296 [OMAP_DSS_CHANNEL_LCD2] = {
298 .vsync_irq = DISPC_IRQ_VSYNC2,
299 .framedone_irq = DISPC_IRQ_FRAMEDONE2,
300 .sync_lost_irq = DISPC_IRQ_SYNC_LOST2,
304 .reg = DISPC_GAMMA_TABLE1,
308 [DISPC_MGR_FLD_ENABLE] = { DISPC_CONTROL2, 0, 0 },
309 [DISPC_MGR_FLD_STNTFT] = { DISPC_CONTROL2, 3, 3 },
310 [DISPC_MGR_FLD_GO] = { DISPC_CONTROL2, 5, 5 },
311 [DISPC_MGR_FLD_TFTDATALINES] = { DISPC_CONTROL2, 9, 8 },
312 [DISPC_MGR_FLD_STALLMODE] = { DISPC_CONTROL2, 11, 11 },
313 [DISPC_MGR_FLD_TCKENABLE] = { DISPC_CONFIG2, 10, 10 },
314 [DISPC_MGR_FLD_TCKSELECTION] = { DISPC_CONFIG2, 11, 11 },
315 [DISPC_MGR_FLD_CPR] = { DISPC_CONFIG2, 15, 15 },
316 [DISPC_MGR_FLD_FIFOHANDCHECK] = { DISPC_CONFIG2, 16, 16 },
319 [OMAP_DSS_CHANNEL_LCD3] = {
321 .vsync_irq = DISPC_IRQ_VSYNC3,
322 .framedone_irq = DISPC_IRQ_FRAMEDONE3,
323 .sync_lost_irq = DISPC_IRQ_SYNC_LOST3,
327 .reg = DISPC_GAMMA_TABLE3,
331 [DISPC_MGR_FLD_ENABLE] = { DISPC_CONTROL3, 0, 0 },
332 [DISPC_MGR_FLD_STNTFT] = { DISPC_CONTROL3, 3, 3 },
333 [DISPC_MGR_FLD_GO] = { DISPC_CONTROL3, 5, 5 },
334 [DISPC_MGR_FLD_TFTDATALINES] = { DISPC_CONTROL3, 9, 8 },
335 [DISPC_MGR_FLD_STALLMODE] = { DISPC_CONTROL3, 11, 11 },
336 [DISPC_MGR_FLD_TCKENABLE] = { DISPC_CONFIG3, 10, 10 },
337 [DISPC_MGR_FLD_TCKSELECTION] = { DISPC_CONFIG3, 11, 11 },
338 [DISPC_MGR_FLD_CPR] = { DISPC_CONFIG3, 15, 15 },
339 [DISPC_MGR_FLD_FIFOHANDCHECK] = { DISPC_CONFIG3, 16, 16 },
344 static unsigned long dispc_fclk_rate(struct dispc_device *dispc);
345 static unsigned long dispc_core_clk_rate(struct dispc_device *dispc);
346 static unsigned long dispc_mgr_lclk_rate(struct dispc_device *dispc,
347 enum omap_channel channel);
348 static unsigned long dispc_mgr_pclk_rate(struct dispc_device *dispc,
349 enum omap_channel channel);
351 static unsigned long dispc_plane_pclk_rate(struct dispc_device *dispc,
352 enum omap_plane_id plane);
353 static unsigned long dispc_plane_lclk_rate(struct dispc_device *dispc,
354 enum omap_plane_id plane);
356 static inline void dispc_write_reg(struct dispc_device *dispc, u16 idx, u32 val)
358 __raw_writel(val, dispc->base + idx);
361 static inline u32 dispc_read_reg(struct dispc_device *dispc, u16 idx)
363 return __raw_readl(dispc->base + idx);
366 static u32 mgr_fld_read(struct dispc_device *dispc, enum omap_channel channel,
367 enum mgr_reg_fields regfld)
369 const struct dispc_reg_field *rfld = &mgr_desc[channel].reg_desc[regfld];
371 return REG_GET(dispc, rfld->reg, rfld->high, rfld->low);
374 static void mgr_fld_write(struct dispc_device *dispc, enum omap_channel channel,
375 enum mgr_reg_fields regfld, int val)
377 const struct dispc_reg_field *rfld = &mgr_desc[channel].reg_desc[regfld];
379 REG_FLD_MOD(dispc, rfld->reg, val, rfld->high, rfld->low);
382 int dispc_get_num_ovls(struct dispc_device *dispc)
384 return dispc->feat->num_ovls;
387 int dispc_get_num_mgrs(struct dispc_device *dispc)
389 return dispc->feat->num_mgrs;
392 static void dispc_get_reg_field(struct dispc_device *dispc,
393 enum dispc_feat_reg_field id,
396 BUG_ON(id >= dispc->feat->num_reg_fields);
398 *start = dispc->feat->reg_fields[id].start;
399 *end = dispc->feat->reg_fields[id].end;
402 static bool dispc_has_feature(struct dispc_device *dispc,
403 enum dispc_feature_id id)
407 for (i = 0; i < dispc->feat->num_features; i++) {
408 if (dispc->feat->features[i] == id)
415 #define SR(dispc, reg) \
416 dispc->ctx[DISPC_##reg / sizeof(u32)] = dispc_read_reg(dispc, DISPC_##reg)
417 #define RR(dispc, reg) \
418 dispc_write_reg(dispc, DISPC_##reg, dispc->ctx[DISPC_##reg / sizeof(u32)])
420 static void dispc_save_context(struct dispc_device *dispc)
424 DSSDBG("dispc_save_context\n");
426 SR(dispc, IRQENABLE);
429 SR(dispc, LINE_NUMBER);
430 if (dispc_has_feature(dispc, FEAT_ALPHA_FIXED_ZORDER) ||
431 dispc_has_feature(dispc, FEAT_ALPHA_FREE_ZORDER))
432 SR(dispc, GLOBAL_ALPHA);
433 if (dispc_has_feature(dispc, FEAT_MGR_LCD2)) {
437 if (dispc_has_feature(dispc, FEAT_MGR_LCD3)) {
442 for (i = 0; i < dispc_get_num_mgrs(dispc); i++) {
443 SR(dispc, DEFAULT_COLOR(i));
444 SR(dispc, TRANS_COLOR(i));
445 SR(dispc, SIZE_MGR(i));
446 if (i == OMAP_DSS_CHANNEL_DIGIT)
448 SR(dispc, TIMING_H(i));
449 SR(dispc, TIMING_V(i));
450 SR(dispc, POL_FREQ(i));
451 SR(dispc, DIVISORo(i));
453 SR(dispc, DATA_CYCLE1(i));
454 SR(dispc, DATA_CYCLE2(i));
455 SR(dispc, DATA_CYCLE3(i));
457 if (dispc_has_feature(dispc, FEAT_CPR)) {
458 SR(dispc, CPR_COEF_R(i));
459 SR(dispc, CPR_COEF_G(i));
460 SR(dispc, CPR_COEF_B(i));
464 for (i = 0; i < dispc_get_num_ovls(dispc); i++) {
465 SR(dispc, OVL_BA0(i));
466 SR(dispc, OVL_BA1(i));
467 SR(dispc, OVL_POSITION(i));
468 SR(dispc, OVL_SIZE(i));
469 SR(dispc, OVL_ATTRIBUTES(i));
470 SR(dispc, OVL_FIFO_THRESHOLD(i));
471 SR(dispc, OVL_ROW_INC(i));
472 SR(dispc, OVL_PIXEL_INC(i));
473 if (dispc_has_feature(dispc, FEAT_PRELOAD))
474 SR(dispc, OVL_PRELOAD(i));
475 if (i == OMAP_DSS_GFX) {
476 SR(dispc, OVL_WINDOW_SKIP(i));
477 SR(dispc, OVL_TABLE_BA(i));
480 SR(dispc, OVL_FIR(i));
481 SR(dispc, OVL_PICTURE_SIZE(i));
482 SR(dispc, OVL_ACCU0(i));
483 SR(dispc, OVL_ACCU1(i));
485 for (j = 0; j < 8; j++)
486 SR(dispc, OVL_FIR_COEF_H(i, j));
488 for (j = 0; j < 8; j++)
489 SR(dispc, OVL_FIR_COEF_HV(i, j));
491 for (j = 0; j < 5; j++)
492 SR(dispc, OVL_CONV_COEF(i, j));
494 if (dispc_has_feature(dispc, FEAT_FIR_COEF_V)) {
495 for (j = 0; j < 8; j++)
496 SR(dispc, OVL_FIR_COEF_V(i, j));
499 if (dispc_has_feature(dispc, FEAT_HANDLE_UV_SEPARATE)) {
500 SR(dispc, OVL_BA0_UV(i));
501 SR(dispc, OVL_BA1_UV(i));
502 SR(dispc, OVL_FIR2(i));
503 SR(dispc, OVL_ACCU2_0(i));
504 SR(dispc, OVL_ACCU2_1(i));
506 for (j = 0; j < 8; j++)
507 SR(dispc, OVL_FIR_COEF_H2(i, j));
509 for (j = 0; j < 8; j++)
510 SR(dispc, OVL_FIR_COEF_HV2(i, j));
512 for (j = 0; j < 8; j++)
513 SR(dispc, OVL_FIR_COEF_V2(i, j));
515 if (dispc_has_feature(dispc, FEAT_ATTR2))
516 SR(dispc, OVL_ATTRIBUTES2(i));
519 if (dispc_has_feature(dispc, FEAT_CORE_CLK_DIV))
522 dispc->ctx_valid = true;
524 DSSDBG("context saved\n");
527 static void dispc_restore_context(struct dispc_device *dispc)
531 DSSDBG("dispc_restore_context\n");
533 if (!dispc->ctx_valid)
536 /*RR(dispc, IRQENABLE);*/
537 /*RR(dispc, CONTROL);*/
539 RR(dispc, LINE_NUMBER);
540 if (dispc_has_feature(dispc, FEAT_ALPHA_FIXED_ZORDER) ||
541 dispc_has_feature(dispc, FEAT_ALPHA_FREE_ZORDER))
542 RR(dispc, GLOBAL_ALPHA);
543 if (dispc_has_feature(dispc, FEAT_MGR_LCD2))
545 if (dispc_has_feature(dispc, FEAT_MGR_LCD3))
548 for (i = 0; i < dispc_get_num_mgrs(dispc); i++) {
549 RR(dispc, DEFAULT_COLOR(i));
550 RR(dispc, TRANS_COLOR(i));
551 RR(dispc, SIZE_MGR(i));
552 if (i == OMAP_DSS_CHANNEL_DIGIT)
554 RR(dispc, TIMING_H(i));
555 RR(dispc, TIMING_V(i));
556 RR(dispc, POL_FREQ(i));
557 RR(dispc, DIVISORo(i));
559 RR(dispc, DATA_CYCLE1(i));
560 RR(dispc, DATA_CYCLE2(i));
561 RR(dispc, DATA_CYCLE3(i));
563 if (dispc_has_feature(dispc, FEAT_CPR)) {
564 RR(dispc, CPR_COEF_R(i));
565 RR(dispc, CPR_COEF_G(i));
566 RR(dispc, CPR_COEF_B(i));
570 for (i = 0; i < dispc_get_num_ovls(dispc); i++) {
571 RR(dispc, OVL_BA0(i));
572 RR(dispc, OVL_BA1(i));
573 RR(dispc, OVL_POSITION(i));
574 RR(dispc, OVL_SIZE(i));
575 RR(dispc, OVL_ATTRIBUTES(i));
576 RR(dispc, OVL_FIFO_THRESHOLD(i));
577 RR(dispc, OVL_ROW_INC(i));
578 RR(dispc, OVL_PIXEL_INC(i));
579 if (dispc_has_feature(dispc, FEAT_PRELOAD))
580 RR(dispc, OVL_PRELOAD(i));
581 if (i == OMAP_DSS_GFX) {
582 RR(dispc, OVL_WINDOW_SKIP(i));
583 RR(dispc, OVL_TABLE_BA(i));
586 RR(dispc, OVL_FIR(i));
587 RR(dispc, OVL_PICTURE_SIZE(i));
588 RR(dispc, OVL_ACCU0(i));
589 RR(dispc, OVL_ACCU1(i));
591 for (j = 0; j < 8; j++)
592 RR(dispc, OVL_FIR_COEF_H(i, j));
594 for (j = 0; j < 8; j++)
595 RR(dispc, OVL_FIR_COEF_HV(i, j));
597 for (j = 0; j < 5; j++)
598 RR(dispc, OVL_CONV_COEF(i, j));
600 if (dispc_has_feature(dispc, FEAT_FIR_COEF_V)) {
601 for (j = 0; j < 8; j++)
602 RR(dispc, OVL_FIR_COEF_V(i, j));
605 if (dispc_has_feature(dispc, FEAT_HANDLE_UV_SEPARATE)) {
606 RR(dispc, OVL_BA0_UV(i));
607 RR(dispc, OVL_BA1_UV(i));
608 RR(dispc, OVL_FIR2(i));
609 RR(dispc, OVL_ACCU2_0(i));
610 RR(dispc, OVL_ACCU2_1(i));
612 for (j = 0; j < 8; j++)
613 RR(dispc, OVL_FIR_COEF_H2(i, j));
615 for (j = 0; j < 8; j++)
616 RR(dispc, OVL_FIR_COEF_HV2(i, j));
618 for (j = 0; j < 8; j++)
619 RR(dispc, OVL_FIR_COEF_V2(i, j));
621 if (dispc_has_feature(dispc, FEAT_ATTR2))
622 RR(dispc, OVL_ATTRIBUTES2(i));
625 if (dispc_has_feature(dispc, FEAT_CORE_CLK_DIV))
628 /* enable last, because LCD & DIGIT enable are here */
630 if (dispc_has_feature(dispc, FEAT_MGR_LCD2))
632 if (dispc_has_feature(dispc, FEAT_MGR_LCD3))
634 /* clear spurious SYNC_LOST_DIGIT interrupts */
635 dispc_clear_irqstatus(dispc, DISPC_IRQ_SYNC_LOST_DIGIT);
638 * enable last so IRQs won't trigger before
639 * the context is fully restored
641 RR(dispc, IRQENABLE);
643 DSSDBG("context restored\n");
649 int dispc_runtime_get(struct dispc_device *dispc)
653 DSSDBG("dispc_runtime_get\n");
655 r = pm_runtime_get_sync(&dispc->pdev->dev);
656 if (WARN_ON(r < 0)) {
657 pm_runtime_put_noidle(&dispc->pdev->dev);
663 void dispc_runtime_put(struct dispc_device *dispc)
667 DSSDBG("dispc_runtime_put\n");
669 r = pm_runtime_put_sync(&dispc->pdev->dev);
670 WARN_ON(r < 0 && r != -ENOSYS);
673 u32 dispc_mgr_get_vsync_irq(struct dispc_device *dispc,
674 enum omap_channel channel)
676 return mgr_desc[channel].vsync_irq;
679 u32 dispc_mgr_get_framedone_irq(struct dispc_device *dispc,
680 enum omap_channel channel)
682 if (channel == OMAP_DSS_CHANNEL_DIGIT && dispc->feat->no_framedone_tv)
685 return mgr_desc[channel].framedone_irq;
688 u32 dispc_mgr_get_sync_lost_irq(struct dispc_device *dispc,
689 enum omap_channel channel)
691 return mgr_desc[channel].sync_lost_irq;
694 u32 dispc_wb_get_framedone_irq(struct dispc_device *dispc)
696 return DISPC_IRQ_FRAMEDONEWB;
699 void dispc_mgr_enable(struct dispc_device *dispc,
700 enum omap_channel channel, bool enable)
702 mgr_fld_write(dispc, channel, DISPC_MGR_FLD_ENABLE, enable);
703 /* flush posted write */
704 mgr_fld_read(dispc, channel, DISPC_MGR_FLD_ENABLE);
707 static bool dispc_mgr_is_enabled(struct dispc_device *dispc,
708 enum omap_channel channel)
710 return !!mgr_fld_read(dispc, channel, DISPC_MGR_FLD_ENABLE);
713 bool dispc_mgr_go_busy(struct dispc_device *dispc,
714 enum omap_channel channel)
716 return mgr_fld_read(dispc, channel, DISPC_MGR_FLD_GO) == 1;
719 void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel)
721 WARN_ON(!dispc_mgr_is_enabled(dispc, channel));
722 WARN_ON(dispc_mgr_go_busy(dispc, channel));
724 DSSDBG("GO %s\n", mgr_desc[channel].name);
726 mgr_fld_write(dispc, channel, DISPC_MGR_FLD_GO, 1);
729 bool dispc_wb_go_busy(struct dispc_device *dispc)
731 return REG_GET(dispc, DISPC_CONTROL2, 6, 6) == 1;
734 void dispc_wb_go(struct dispc_device *dispc)
736 enum omap_plane_id plane = OMAP_DSS_WB;
739 enable = REG_GET(dispc, DISPC_OVL_ATTRIBUTES(plane), 0, 0) == 1;
744 go = REG_GET(dispc, DISPC_CONTROL2, 6, 6) == 1;
746 DSSERR("GO bit not down for WB\n");
750 REG_FLD_MOD(dispc, DISPC_CONTROL2, 1, 6, 6);
753 static void dispc_ovl_write_firh_reg(struct dispc_device *dispc,
754 enum omap_plane_id plane, int reg,
757 dispc_write_reg(dispc, DISPC_OVL_FIR_COEF_H(plane, reg), value);
760 static void dispc_ovl_write_firhv_reg(struct dispc_device *dispc,
761 enum omap_plane_id plane, int reg,
764 dispc_write_reg(dispc, DISPC_OVL_FIR_COEF_HV(plane, reg), value);
767 static void dispc_ovl_write_firv_reg(struct dispc_device *dispc,
768 enum omap_plane_id plane, int reg,
771 dispc_write_reg(dispc, DISPC_OVL_FIR_COEF_V(plane, reg), value);
774 static void dispc_ovl_write_firh2_reg(struct dispc_device *dispc,
775 enum omap_plane_id plane, int reg,
778 BUG_ON(plane == OMAP_DSS_GFX);
780 dispc_write_reg(dispc, DISPC_OVL_FIR_COEF_H2(plane, reg), value);
783 static void dispc_ovl_write_firhv2_reg(struct dispc_device *dispc,
784 enum omap_plane_id plane, int reg,
787 BUG_ON(plane == OMAP_DSS_GFX);
789 dispc_write_reg(dispc, DISPC_OVL_FIR_COEF_HV2(plane, reg), value);
792 static void dispc_ovl_write_firv2_reg(struct dispc_device *dispc,
793 enum omap_plane_id plane, int reg,
796 BUG_ON(plane == OMAP_DSS_GFX);
798 dispc_write_reg(dispc, DISPC_OVL_FIR_COEF_V2(plane, reg), value);
801 static void dispc_ovl_set_scale_coef(struct dispc_device *dispc,
802 enum omap_plane_id plane, int fir_hinc,
803 int fir_vinc, int five_taps,
804 enum omap_color_component color_comp)
806 const struct dispc_coef *h_coef, *v_coef;
809 h_coef = dispc_ovl_get_scale_coef(fir_hinc, true);
810 v_coef = dispc_ovl_get_scale_coef(fir_vinc, five_taps);
812 if (!h_coef || !v_coef) {
813 dev_err(&dispc->pdev->dev, "%s: failed to find scale coefs\n",
818 for (i = 0; i < 8; i++) {
821 h = FLD_VAL(h_coef[i].hc0_vc00, 7, 0)
822 | FLD_VAL(h_coef[i].hc1_vc0, 15, 8)
823 | FLD_VAL(h_coef[i].hc2_vc1, 23, 16)
824 | FLD_VAL(h_coef[i].hc3_vc2, 31, 24);
825 hv = FLD_VAL(h_coef[i].hc4_vc22, 7, 0)
826 | FLD_VAL(v_coef[i].hc1_vc0, 15, 8)
827 | FLD_VAL(v_coef[i].hc2_vc1, 23, 16)
828 | FLD_VAL(v_coef[i].hc3_vc2, 31, 24);
830 if (color_comp == DISPC_COLOR_COMPONENT_RGB_Y) {
831 dispc_ovl_write_firh_reg(dispc, plane, i, h);
832 dispc_ovl_write_firhv_reg(dispc, plane, i, hv);
834 dispc_ovl_write_firh2_reg(dispc, plane, i, h);
835 dispc_ovl_write_firhv2_reg(dispc, plane, i, hv);
841 for (i = 0; i < 8; i++) {
843 v = FLD_VAL(v_coef[i].hc0_vc00, 7, 0)
844 | FLD_VAL(v_coef[i].hc4_vc22, 15, 8);
845 if (color_comp == DISPC_COLOR_COMPONENT_RGB_Y)
846 dispc_ovl_write_firv_reg(dispc, plane, i, v);
848 dispc_ovl_write_firv2_reg(dispc, plane, i, v);
853 struct csc_coef_yuv2rgb {
854 int ry, rcb, rcr, gy, gcb, gcr, by, bcb, bcr;
858 static void dispc_ovl_write_color_conv_coef(struct dispc_device *dispc,
859 enum omap_plane_id plane,
860 const struct csc_coef_yuv2rgb *ct)
862 #define CVAL(x, y) (FLD_VAL(x, 26, 16) | FLD_VAL(y, 10, 0))
864 dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 0), CVAL(ct->rcr, ct->ry));
865 dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 1), CVAL(ct->gy, ct->rcb));
866 dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 2), CVAL(ct->gcb, ct->gcr));
867 dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 3), CVAL(ct->bcr, ct->by));
868 dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 4), CVAL(0, ct->bcb));
870 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), ct->full_range, 11, 11);
875 /* YUV -> RGB, ITU-R BT.601, full range */
876 static const struct csc_coef_yuv2rgb coefs_yuv2rgb_bt601_full = {
877 256, 0, 358, /* ry, rcb, rcr |1.000 0.000 1.402|*/
878 256, -88, -182, /* gy, gcb, gcr |1.000 -0.344 -0.714|*/
879 256, 452, 0, /* by, bcb, bcr |1.000 1.772 0.000|*/
880 true, /* full range */
883 /* YUV -> RGB, ITU-R BT.601, limited range */
884 static const struct csc_coef_yuv2rgb coefs_yuv2rgb_bt601_lim = {
885 298, 0, 409, /* ry, rcb, rcr |1.164 0.000 1.596|*/
886 298, -100, -208, /* gy, gcb, gcr |1.164 -0.392 -0.813|*/
887 298, 516, 0, /* by, bcb, bcr |1.164 2.017 0.000|*/
888 false, /* limited range */
891 /* YUV -> RGB, ITU-R BT.709, full range */
892 static const struct csc_coef_yuv2rgb coefs_yuv2rgb_bt709_full = {
893 256, 0, 402, /* ry, rcb, rcr |1.000 0.000 1.570|*/
894 256, -48, -120, /* gy, gcb, gcr |1.000 -0.187 -0.467|*/
895 256, 475, 0, /* by, bcb, bcr |1.000 1.856 0.000|*/
896 true, /* full range */
899 /* YUV -> RGB, ITU-R BT.709, limited range */
900 static const struct csc_coef_yuv2rgb coefs_yuv2rgb_bt709_lim = {
901 298, 0, 459, /* ry, rcb, rcr |1.164 0.000 1.793|*/
902 298, -55, -136, /* gy, gcb, gcr |1.164 -0.213 -0.533|*/
903 298, 541, 0, /* by, bcb, bcr |1.164 2.112 0.000|*/
904 false, /* limited range */
907 static void dispc_ovl_set_csc(struct dispc_device *dispc,
908 enum omap_plane_id plane,
909 enum drm_color_encoding color_encoding,
910 enum drm_color_range color_range)
912 const struct csc_coef_yuv2rgb *csc;
914 switch (color_encoding) {
916 case DRM_COLOR_YCBCR_BT601:
917 if (color_range == DRM_COLOR_YCBCR_FULL_RANGE)
918 csc = &coefs_yuv2rgb_bt601_full;
920 csc = &coefs_yuv2rgb_bt601_lim;
922 case DRM_COLOR_YCBCR_BT709:
923 if (color_range == DRM_COLOR_YCBCR_FULL_RANGE)
924 csc = &coefs_yuv2rgb_bt709_full;
926 csc = &coefs_yuv2rgb_bt709_lim;
930 dispc_ovl_write_color_conv_coef(dispc, plane, csc);
933 static void dispc_ovl_set_ba0(struct dispc_device *dispc,
934 enum omap_plane_id plane, u32 paddr)
936 dispc_write_reg(dispc, DISPC_OVL_BA0(plane), paddr);
939 static void dispc_ovl_set_ba1(struct dispc_device *dispc,
940 enum omap_plane_id plane, u32 paddr)
942 dispc_write_reg(dispc, DISPC_OVL_BA1(plane), paddr);
945 static void dispc_ovl_set_ba0_uv(struct dispc_device *dispc,
946 enum omap_plane_id plane, u32 paddr)
948 dispc_write_reg(dispc, DISPC_OVL_BA0_UV(plane), paddr);
951 static void dispc_ovl_set_ba1_uv(struct dispc_device *dispc,
952 enum omap_plane_id plane, u32 paddr)
954 dispc_write_reg(dispc, DISPC_OVL_BA1_UV(plane), paddr);
957 static void dispc_ovl_set_pos(struct dispc_device *dispc,
958 enum omap_plane_id plane,
959 enum omap_overlay_caps caps, int x, int y)
963 if ((caps & OMAP_DSS_OVL_CAP_POS) == 0)
966 val = FLD_VAL(y, 26, 16) | FLD_VAL(x, 10, 0);
968 dispc_write_reg(dispc, DISPC_OVL_POSITION(plane), val);
971 static void dispc_ovl_set_input_size(struct dispc_device *dispc,
972 enum omap_plane_id plane, int width,
975 u32 val = FLD_VAL(height - 1, 26, 16) | FLD_VAL(width - 1, 10, 0);
977 if (plane == OMAP_DSS_GFX || plane == OMAP_DSS_WB)
978 dispc_write_reg(dispc, DISPC_OVL_SIZE(plane), val);
980 dispc_write_reg(dispc, DISPC_OVL_PICTURE_SIZE(plane), val);
983 static void dispc_ovl_set_output_size(struct dispc_device *dispc,
984 enum omap_plane_id plane, int width,
989 BUG_ON(plane == OMAP_DSS_GFX);
991 val = FLD_VAL(height - 1, 26, 16) | FLD_VAL(width - 1, 10, 0);
993 if (plane == OMAP_DSS_WB)
994 dispc_write_reg(dispc, DISPC_OVL_PICTURE_SIZE(plane), val);
996 dispc_write_reg(dispc, DISPC_OVL_SIZE(plane), val);
999 static void dispc_ovl_set_zorder(struct dispc_device *dispc,
1000 enum omap_plane_id plane,
1001 enum omap_overlay_caps caps, u8 zorder)
1003 if ((caps & OMAP_DSS_OVL_CAP_ZORDER) == 0)
1006 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), zorder, 27, 26);
1009 static void dispc_ovl_enable_zorder_planes(struct dispc_device *dispc)
1013 if (!dispc_has_feature(dispc, FEAT_ALPHA_FREE_ZORDER))
1016 for (i = 0; i < dispc_get_num_ovls(dispc); i++)
1017 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(i), 1, 25, 25);
1020 static void dispc_ovl_set_pre_mult_alpha(struct dispc_device *dispc,
1021 enum omap_plane_id plane,
1022 enum omap_overlay_caps caps,
1025 if ((caps & OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA) == 0)
1028 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), enable ? 1 : 0, 28, 28);
1031 static void dispc_ovl_setup_global_alpha(struct dispc_device *dispc,
1032 enum omap_plane_id plane,
1033 enum omap_overlay_caps caps,
1036 static const unsigned int shifts[] = { 0, 8, 16, 24, };
1039 if ((caps & OMAP_DSS_OVL_CAP_GLOBAL_ALPHA) == 0)
1042 shift = shifts[plane];
1043 REG_FLD_MOD(dispc, DISPC_GLOBAL_ALPHA, global_alpha, shift + 7, shift);
1046 static void dispc_ovl_set_pix_inc(struct dispc_device *dispc,
1047 enum omap_plane_id plane, s32 inc)
1049 dispc_write_reg(dispc, DISPC_OVL_PIXEL_INC(plane), inc);
1052 static void dispc_ovl_set_row_inc(struct dispc_device *dispc,
1053 enum omap_plane_id plane, s32 inc)
1055 dispc_write_reg(dispc, DISPC_OVL_ROW_INC(plane), inc);
1058 static void dispc_ovl_set_color_mode(struct dispc_device *dispc,
1059 enum omap_plane_id plane, u32 fourcc)
1062 if (plane != OMAP_DSS_GFX) {
1064 case DRM_FORMAT_NV12:
1066 case DRM_FORMAT_XRGB4444:
1068 case DRM_FORMAT_RGBA4444:
1070 case DRM_FORMAT_RGBX4444:
1072 case DRM_FORMAT_ARGB4444:
1074 case DRM_FORMAT_RGB565:
1076 case DRM_FORMAT_ARGB1555:
1078 case DRM_FORMAT_XRGB8888:
1080 case DRM_FORMAT_RGB888:
1082 case DRM_FORMAT_YUYV:
1084 case DRM_FORMAT_UYVY:
1086 case DRM_FORMAT_ARGB8888:
1088 case DRM_FORMAT_RGBA8888:
1090 case DRM_FORMAT_RGBX8888:
1092 case DRM_FORMAT_XRGB1555:
1099 case DRM_FORMAT_RGBX4444:
1101 case DRM_FORMAT_ARGB4444:
1103 case DRM_FORMAT_RGB565:
1105 case DRM_FORMAT_ARGB1555:
1107 case DRM_FORMAT_XRGB8888:
1109 case DRM_FORMAT_RGB888:
1111 case DRM_FORMAT_XRGB4444:
1113 case DRM_FORMAT_RGBA4444:
1115 case DRM_FORMAT_ARGB8888:
1117 case DRM_FORMAT_RGBA8888:
1119 case DRM_FORMAT_RGBX8888:
1121 case DRM_FORMAT_XRGB1555:
1128 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), m, 4, 1);
1131 static void dispc_ovl_configure_burst_type(struct dispc_device *dispc,
1132 enum omap_plane_id plane,
1133 enum omap_dss_rotation_type rotation)
1135 if (dispc_has_feature(dispc, FEAT_BURST_2D) == 0)
1138 if (rotation == OMAP_DSS_ROT_TILER)
1139 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), 1, 29, 29);
1141 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), 0, 29, 29);
1144 static void dispc_ovl_set_channel_out(struct dispc_device *dispc,
1145 enum omap_plane_id plane,
1146 enum omap_channel channel)
1150 int chan = 0, chan2 = 0;
1156 case OMAP_DSS_VIDEO1:
1157 case OMAP_DSS_VIDEO2:
1158 case OMAP_DSS_VIDEO3:
1166 val = dispc_read_reg(dispc, DISPC_OVL_ATTRIBUTES(plane));
1167 if (dispc_has_feature(dispc, FEAT_MGR_LCD2)) {
1169 case OMAP_DSS_CHANNEL_LCD:
1173 case OMAP_DSS_CHANNEL_DIGIT:
1177 case OMAP_DSS_CHANNEL_LCD2:
1181 case OMAP_DSS_CHANNEL_LCD3:
1182 if (dispc_has_feature(dispc, FEAT_MGR_LCD3)) {
1190 case OMAP_DSS_CHANNEL_WB:
1199 val = FLD_MOD(val, chan, shift, shift);
1200 val = FLD_MOD(val, chan2, 31, 30);
1202 val = FLD_MOD(val, channel, shift, shift);
1204 dispc_write_reg(dispc, DISPC_OVL_ATTRIBUTES(plane), val);
1207 static enum omap_channel dispc_ovl_get_channel_out(struct dispc_device *dispc,
1208 enum omap_plane_id plane)
1217 case OMAP_DSS_VIDEO1:
1218 case OMAP_DSS_VIDEO2:
1219 case OMAP_DSS_VIDEO3:
1227 val = dispc_read_reg(dispc, DISPC_OVL_ATTRIBUTES(plane));
1229 if (FLD_GET(val, shift, shift) == 1)
1230 return OMAP_DSS_CHANNEL_DIGIT;
1232 if (!dispc_has_feature(dispc, FEAT_MGR_LCD2))
1233 return OMAP_DSS_CHANNEL_LCD;
1235 switch (FLD_GET(val, 31, 30)) {
1238 return OMAP_DSS_CHANNEL_LCD;
1240 return OMAP_DSS_CHANNEL_LCD2;
1242 return OMAP_DSS_CHANNEL_LCD3;
1244 return OMAP_DSS_CHANNEL_WB;
1248 static void dispc_ovl_set_burst_size(struct dispc_device *dispc,
1249 enum omap_plane_id plane,
1250 enum omap_burst_size burst_size)
1252 static const unsigned int shifts[] = { 6, 14, 14, 14, 14, };
1255 shift = shifts[plane];
1256 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), burst_size,
1260 static void dispc_configure_burst_sizes(struct dispc_device *dispc)
1263 const int burst_size = BURST_SIZE_X8;
1265 /* Configure burst size always to maximum size */
1266 for (i = 0; i < dispc_get_num_ovls(dispc); ++i)
1267 dispc_ovl_set_burst_size(dispc, i, burst_size);
1268 if (dispc->feat->has_writeback)
1269 dispc_ovl_set_burst_size(dispc, OMAP_DSS_WB, burst_size);
1272 static u32 dispc_ovl_get_burst_size(struct dispc_device *dispc,
1273 enum omap_plane_id plane)
1275 /* burst multiplier is always x8 (see dispc_configure_burst_sizes()) */
1276 return dispc->feat->burst_size_unit * 8;
1279 bool dispc_ovl_color_mode_supported(struct dispc_device *dispc,
1280 enum omap_plane_id plane, u32 fourcc)
1285 modes = dispc->feat->supported_color_modes[plane];
1287 for (i = 0; modes[i]; ++i) {
1288 if (modes[i] == fourcc)
1295 const u32 *dispc_ovl_get_color_modes(struct dispc_device *dispc,
1296 enum omap_plane_id plane)
1298 return dispc->feat->supported_color_modes[plane];
1301 static void dispc_mgr_enable_cpr(struct dispc_device *dispc,
1302 enum omap_channel channel, bool enable)
1304 if (channel == OMAP_DSS_CHANNEL_DIGIT)
1307 mgr_fld_write(dispc, channel, DISPC_MGR_FLD_CPR, enable);
1310 static void dispc_mgr_set_cpr_coef(struct dispc_device *dispc,
1311 enum omap_channel channel,
1312 const struct omap_dss_cpr_coefs *coefs)
1314 u32 coef_r, coef_g, coef_b;
1316 if (!dss_mgr_is_lcd(channel))
1319 coef_r = FLD_VAL(coefs->rr, 31, 22) | FLD_VAL(coefs->rg, 20, 11) |
1320 FLD_VAL(coefs->rb, 9, 0);
1321 coef_g = FLD_VAL(coefs->gr, 31, 22) | FLD_VAL(coefs->gg, 20, 11) |
1322 FLD_VAL(coefs->gb, 9, 0);
1323 coef_b = FLD_VAL(coefs->br, 31, 22) | FLD_VAL(coefs->bg, 20, 11) |
1324 FLD_VAL(coefs->bb, 9, 0);
1326 dispc_write_reg(dispc, DISPC_CPR_COEF_R(channel), coef_r);
1327 dispc_write_reg(dispc, DISPC_CPR_COEF_G(channel), coef_g);
1328 dispc_write_reg(dispc, DISPC_CPR_COEF_B(channel), coef_b);
1331 static void dispc_ovl_set_vid_color_conv(struct dispc_device *dispc,
1332 enum omap_plane_id plane, bool enable)
1336 BUG_ON(plane == OMAP_DSS_GFX);
1338 val = dispc_read_reg(dispc, DISPC_OVL_ATTRIBUTES(plane));
1339 val = FLD_MOD(val, enable, 9, 9);
1340 dispc_write_reg(dispc, DISPC_OVL_ATTRIBUTES(plane), val);
1343 static void dispc_ovl_enable_replication(struct dispc_device *dispc,
1344 enum omap_plane_id plane,
1345 enum omap_overlay_caps caps,
1348 static const unsigned int shifts[] = { 5, 10, 10, 10 };
1351 if ((caps & OMAP_DSS_OVL_CAP_REPLICATION) == 0)
1354 shift = shifts[plane];
1355 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), enable, shift, shift);
1358 static void dispc_mgr_set_size(struct dispc_device *dispc,
1359 enum omap_channel channel, u16 width, u16 height)
1363 val = FLD_VAL(height - 1, dispc->feat->mgr_height_start, 16) |
1364 FLD_VAL(width - 1, dispc->feat->mgr_width_start, 0);
1366 dispc_write_reg(dispc, DISPC_SIZE_MGR(channel), val);
1369 static void dispc_init_fifos(struct dispc_device *dispc)
1377 unit = dispc->feat->buffer_size_unit;
1379 dispc_get_reg_field(dispc, FEAT_REG_FIFOSIZE, &start, &end);
1381 for (fifo = 0; fifo < dispc->feat->num_fifos; ++fifo) {
1382 size = REG_GET(dispc, DISPC_OVL_FIFO_SIZE_STATUS(fifo),
1385 dispc->fifo_size[fifo] = size;
1388 * By default fifos are mapped directly to overlays, fifo 0 to
1389 * ovl 0, fifo 1 to ovl 1, etc.
1391 dispc->fifo_assignment[fifo] = fifo;
1395 * The GFX fifo on OMAP4 is smaller than the other fifos. The small fifo
1396 * causes problems with certain use cases, like using the tiler in 2D
1397 * mode. The below hack swaps the fifos of GFX and WB planes, thus
1398 * giving GFX plane a larger fifo. WB but should work fine with a
1401 if (dispc->feat->gfx_fifo_workaround) {
1404 v = dispc_read_reg(dispc, DISPC_GLOBAL_BUFFER);
1406 v = FLD_MOD(v, 4, 2, 0); /* GFX BUF top to WB */
1407 v = FLD_MOD(v, 4, 5, 3); /* GFX BUF bottom to WB */
1408 v = FLD_MOD(v, 0, 26, 24); /* WB BUF top to GFX */
1409 v = FLD_MOD(v, 0, 29, 27); /* WB BUF bottom to GFX */
1411 dispc_write_reg(dispc, DISPC_GLOBAL_BUFFER, v);
1413 dispc->fifo_assignment[OMAP_DSS_GFX] = OMAP_DSS_WB;
1414 dispc->fifo_assignment[OMAP_DSS_WB] = OMAP_DSS_GFX;
1418 * Setup default fifo thresholds.
1420 for (i = 0; i < dispc_get_num_ovls(dispc); ++i) {
1422 const bool use_fifomerge = false;
1423 const bool manual_update = false;
1425 dispc_ovl_compute_fifo_thresholds(dispc, i, &low, &high,
1426 use_fifomerge, manual_update);
1428 dispc_ovl_set_fifo_threshold(dispc, i, low, high);
1431 if (dispc->feat->has_writeback) {
1433 const bool use_fifomerge = false;
1434 const bool manual_update = false;
1436 dispc_ovl_compute_fifo_thresholds(dispc, OMAP_DSS_WB,
1437 &low, &high, use_fifomerge,
1440 dispc_ovl_set_fifo_threshold(dispc, OMAP_DSS_WB, low, high);
1444 static u32 dispc_ovl_get_fifo_size(struct dispc_device *dispc,
1445 enum omap_plane_id plane)
1450 for (fifo = 0; fifo < dispc->feat->num_fifos; ++fifo) {
1451 if (dispc->fifo_assignment[fifo] == plane)
1452 size += dispc->fifo_size[fifo];
1458 void dispc_ovl_set_fifo_threshold(struct dispc_device *dispc,
1459 enum omap_plane_id plane,
1462 u8 hi_start, hi_end, lo_start, lo_end;
1465 unit = dispc->feat->buffer_size_unit;
1467 WARN_ON(low % unit != 0);
1468 WARN_ON(high % unit != 0);
1473 dispc_get_reg_field(dispc, FEAT_REG_FIFOHIGHTHRESHOLD,
1474 &hi_start, &hi_end);
1475 dispc_get_reg_field(dispc, FEAT_REG_FIFOLOWTHRESHOLD,
1476 &lo_start, &lo_end);
1478 DSSDBG("fifo(%d) threshold (bytes), old %u/%u, new %u/%u\n",
1480 REG_GET(dispc, DISPC_OVL_FIFO_THRESHOLD(plane),
1481 lo_start, lo_end) * unit,
1482 REG_GET(dispc, DISPC_OVL_FIFO_THRESHOLD(plane),
1483 hi_start, hi_end) * unit,
1484 low * unit, high * unit);
1486 dispc_write_reg(dispc, DISPC_OVL_FIFO_THRESHOLD(plane),
1487 FLD_VAL(high, hi_start, hi_end) |
1488 FLD_VAL(low, lo_start, lo_end));
1491 * configure the preload to the pipeline's high threhold, if HT it's too
1492 * large for the preload field, set the threshold to the maximum value
1493 * that can be held by the preload register
1495 if (dispc_has_feature(dispc, FEAT_PRELOAD) &&
1496 dispc->feat->set_max_preload && plane != OMAP_DSS_WB)
1497 dispc_write_reg(dispc, DISPC_OVL_PRELOAD(plane),
1501 void dispc_enable_fifomerge(struct dispc_device *dispc, bool enable)
1503 if (!dispc_has_feature(dispc, FEAT_FIFO_MERGE)) {
1508 DSSDBG("FIFO merge %s\n", enable ? "enabled" : "disabled");
1509 REG_FLD_MOD(dispc, DISPC_CONFIG, enable ? 1 : 0, 14, 14);
1512 void dispc_ovl_compute_fifo_thresholds(struct dispc_device *dispc,
1513 enum omap_plane_id plane,
1514 u32 *fifo_low, u32 *fifo_high,
1515 bool use_fifomerge, bool manual_update)
1518 * All sizes are in bytes. Both the buffer and burst are made of
1519 * buffer_units, and the fifo thresholds must be buffer_unit aligned.
1521 unsigned int buf_unit = dispc->feat->buffer_size_unit;
1522 unsigned int ovl_fifo_size, total_fifo_size, burst_size;
1525 burst_size = dispc_ovl_get_burst_size(dispc, plane);
1526 ovl_fifo_size = dispc_ovl_get_fifo_size(dispc, plane);
1528 if (use_fifomerge) {
1529 total_fifo_size = 0;
1530 for (i = 0; i < dispc_get_num_ovls(dispc); ++i)
1531 total_fifo_size += dispc_ovl_get_fifo_size(dispc, i);
1533 total_fifo_size = ovl_fifo_size;
1537 * We use the same low threshold for both fifomerge and non-fifomerge
1538 * cases, but for fifomerge we calculate the high threshold using the
1539 * combined fifo size
1542 if (manual_update && dispc_has_feature(dispc, FEAT_OMAP3_DSI_FIFO_BUG)) {
1543 *fifo_low = ovl_fifo_size - burst_size * 2;
1544 *fifo_high = total_fifo_size - burst_size;
1545 } else if (plane == OMAP_DSS_WB) {
1547 * Most optimal configuration for writeback is to push out data
1548 * to the interconnect the moment writeback pushes enough pixels
1549 * in the FIFO to form a burst
1552 *fifo_high = burst_size;
1554 *fifo_low = ovl_fifo_size - burst_size;
1555 *fifo_high = total_fifo_size - buf_unit;
1559 static void dispc_ovl_set_mflag(struct dispc_device *dispc,
1560 enum omap_plane_id plane, bool enable)
1564 if (plane == OMAP_DSS_GFX)
1569 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), enable, bit, bit);
1572 static void dispc_ovl_set_mflag_threshold(struct dispc_device *dispc,
1573 enum omap_plane_id plane,
1576 dispc_write_reg(dispc, DISPC_OVL_MFLAG_THRESHOLD(plane),
1577 FLD_VAL(high, 31, 16) | FLD_VAL(low, 15, 0));
1580 static void dispc_init_mflag(struct dispc_device *dispc)
1585 * HACK: NV12 color format and MFLAG seem to have problems working
1586 * together: using two displays, and having an NV12 overlay on one of
1587 * the displays will cause underflows/synclosts when MFLAG_CTRL=2.
1588 * Changing MFLAG thresholds and PRELOAD to certain values seem to
1589 * remove the errors, but there doesn't seem to be a clear logic on
1590 * which values work and which not.
1592 * As a work-around, set force MFLAG to always on.
1594 dispc_write_reg(dispc, DISPC_GLOBAL_MFLAG_ATTRIBUTE,
1595 (1 << 0) | /* MFLAG_CTRL = force always on */
1596 (0 << 2)); /* MFLAG_START = disable */
1598 for (i = 0; i < dispc_get_num_ovls(dispc); ++i) {
1599 u32 size = dispc_ovl_get_fifo_size(dispc, i);
1600 u32 unit = dispc->feat->buffer_size_unit;
1603 dispc_ovl_set_mflag(dispc, i, true);
1606 * Simulation team suggests below thesholds:
1607 * HT = fifosize * 5 / 8;
1608 * LT = fifosize * 4 / 8;
1611 low = size * 4 / 8 / unit;
1612 high = size * 5 / 8 / unit;
1614 dispc_ovl_set_mflag_threshold(dispc, i, low, high);
1617 if (dispc->feat->has_writeback) {
1618 u32 size = dispc_ovl_get_fifo_size(dispc, OMAP_DSS_WB);
1619 u32 unit = dispc->feat->buffer_size_unit;
1622 dispc_ovl_set_mflag(dispc, OMAP_DSS_WB, true);
1625 * Simulation team suggests below thesholds:
1626 * HT = fifosize * 5 / 8;
1627 * LT = fifosize * 4 / 8;
1630 low = size * 4 / 8 / unit;
1631 high = size * 5 / 8 / unit;
1633 dispc_ovl_set_mflag_threshold(dispc, OMAP_DSS_WB, low, high);
1637 static void dispc_ovl_set_fir(struct dispc_device *dispc,
1638 enum omap_plane_id plane,
1640 enum omap_color_component color_comp)
1644 if (color_comp == DISPC_COLOR_COMPONENT_RGB_Y) {
1645 u8 hinc_start, hinc_end, vinc_start, vinc_end;
1647 dispc_get_reg_field(dispc, FEAT_REG_FIRHINC,
1648 &hinc_start, &hinc_end);
1649 dispc_get_reg_field(dispc, FEAT_REG_FIRVINC,
1650 &vinc_start, &vinc_end);
1651 val = FLD_VAL(vinc, vinc_start, vinc_end) |
1652 FLD_VAL(hinc, hinc_start, hinc_end);
1654 dispc_write_reg(dispc, DISPC_OVL_FIR(plane), val);
1656 val = FLD_VAL(vinc, 28, 16) | FLD_VAL(hinc, 12, 0);
1657 dispc_write_reg(dispc, DISPC_OVL_FIR2(plane), val);
1661 static void dispc_ovl_set_vid_accu0(struct dispc_device *dispc,
1662 enum omap_plane_id plane, int haccu,
1666 u8 hor_start, hor_end, vert_start, vert_end;
1668 dispc_get_reg_field(dispc, FEAT_REG_HORIZONTALACCU,
1669 &hor_start, &hor_end);
1670 dispc_get_reg_field(dispc, FEAT_REG_VERTICALACCU,
1671 &vert_start, &vert_end);
1673 val = FLD_VAL(vaccu, vert_start, vert_end) |
1674 FLD_VAL(haccu, hor_start, hor_end);
1676 dispc_write_reg(dispc, DISPC_OVL_ACCU0(plane), val);
1679 static void dispc_ovl_set_vid_accu1(struct dispc_device *dispc,
1680 enum omap_plane_id plane, int haccu,
1684 u8 hor_start, hor_end, vert_start, vert_end;
1686 dispc_get_reg_field(dispc, FEAT_REG_HORIZONTALACCU,
1687 &hor_start, &hor_end);
1688 dispc_get_reg_field(dispc, FEAT_REG_VERTICALACCU,
1689 &vert_start, &vert_end);
1691 val = FLD_VAL(vaccu, vert_start, vert_end) |
1692 FLD_VAL(haccu, hor_start, hor_end);
1694 dispc_write_reg(dispc, DISPC_OVL_ACCU1(plane), val);
1697 static void dispc_ovl_set_vid_accu2_0(struct dispc_device *dispc,
1698 enum omap_plane_id plane, int haccu,
1703 val = FLD_VAL(vaccu, 26, 16) | FLD_VAL(haccu, 10, 0);
1704 dispc_write_reg(dispc, DISPC_OVL_ACCU2_0(plane), val);
1707 static void dispc_ovl_set_vid_accu2_1(struct dispc_device *dispc,
1708 enum omap_plane_id plane, int haccu,
1713 val = FLD_VAL(vaccu, 26, 16) | FLD_VAL(haccu, 10, 0);
1714 dispc_write_reg(dispc, DISPC_OVL_ACCU2_1(plane), val);
1717 static void dispc_ovl_set_scale_param(struct dispc_device *dispc,
1718 enum omap_plane_id plane,
1719 u16 orig_width, u16 orig_height,
1720 u16 out_width, u16 out_height,
1721 bool five_taps, u8 rotation,
1722 enum omap_color_component color_comp)
1724 int fir_hinc, fir_vinc;
1726 fir_hinc = 1024 * orig_width / out_width;
1727 fir_vinc = 1024 * orig_height / out_height;
1729 dispc_ovl_set_scale_coef(dispc, plane, fir_hinc, fir_vinc, five_taps,
1731 dispc_ovl_set_fir(dispc, plane, fir_hinc, fir_vinc, color_comp);
1734 static void dispc_ovl_set_accu_uv(struct dispc_device *dispc,
1735 enum omap_plane_id plane,
1736 u16 orig_width, u16 orig_height,
1737 u16 out_width, u16 out_height,
1738 bool ilace, u32 fourcc, u8 rotation)
1740 int h_accu2_0, h_accu2_1;
1741 int v_accu2_0, v_accu2_1;
1742 int chroma_hinc, chroma_vinc;
1752 const struct accu *accu_table;
1753 const struct accu *accu_val;
1755 static const struct accu accu_nv12[4] = {
1756 { 0, 1, 0, 1 , -1, 2, 0, 1 },
1757 { 1, 2, -3, 4 , 0, 1, 0, 1 },
1758 { -1, 1, 0, 1 , -1, 2, 0, 1 },
1759 { -1, 2, -1, 2 , -1, 1, 0, 1 },
1762 static const struct accu accu_nv12_ilace[4] = {
1763 { 0, 1, 0, 1 , -3, 4, -1, 4 },
1764 { -1, 4, -3, 4 , 0, 1, 0, 1 },
1765 { -1, 1, 0, 1 , -1, 4, -3, 4 },
1766 { -3, 4, -3, 4 , -1, 1, 0, 1 },
1769 static const struct accu accu_yuv[4] = {
1770 { 0, 1, 0, 1, 0, 1, 0, 1 },
1771 { 0, 1, 0, 1, 0, 1, 0, 1 },
1772 { -1, 1, 0, 1, 0, 1, 0, 1 },
1773 { 0, 1, 0, 1, -1, 1, 0, 1 },
1776 /* Note: DSS HW rotates clockwise, DRM_MODE_ROTATE_* counter-clockwise */
1777 switch (rotation & DRM_MODE_ROTATE_MASK) {
1779 case DRM_MODE_ROTATE_0:
1782 case DRM_MODE_ROTATE_90:
1785 case DRM_MODE_ROTATE_180:
1788 case DRM_MODE_ROTATE_270:
1794 case DRM_FORMAT_NV12:
1796 accu_table = accu_nv12_ilace;
1798 accu_table = accu_nv12;
1800 case DRM_FORMAT_YUYV:
1801 case DRM_FORMAT_UYVY:
1802 accu_table = accu_yuv;
1809 accu_val = &accu_table[idx];
1811 chroma_hinc = 1024 * orig_width / out_width;
1812 chroma_vinc = 1024 * orig_height / out_height;
1814 h_accu2_0 = (accu_val->h0_m * chroma_hinc / accu_val->h0_n) % 1024;
1815 h_accu2_1 = (accu_val->h1_m * chroma_hinc / accu_val->h1_n) % 1024;
1816 v_accu2_0 = (accu_val->v0_m * chroma_vinc / accu_val->v0_n) % 1024;
1817 v_accu2_1 = (accu_val->v1_m * chroma_vinc / accu_val->v1_n) % 1024;
1819 dispc_ovl_set_vid_accu2_0(dispc, plane, h_accu2_0, v_accu2_0);
1820 dispc_ovl_set_vid_accu2_1(dispc, plane, h_accu2_1, v_accu2_1);
1823 static void dispc_ovl_set_scaling_common(struct dispc_device *dispc,
1824 enum omap_plane_id plane,
1825 u16 orig_width, u16 orig_height,
1826 u16 out_width, u16 out_height,
1827 bool ilace, bool five_taps,
1828 bool fieldmode, u32 fourcc,
1835 dispc_ovl_set_scale_param(dispc, plane, orig_width, orig_height,
1836 out_width, out_height, five_taps,
1837 rotation, DISPC_COLOR_COMPONENT_RGB_Y);
1838 l = dispc_read_reg(dispc, DISPC_OVL_ATTRIBUTES(plane));
1840 /* RESIZEENABLE and VERTICALTAPS */
1841 l &= ~((0x3 << 5) | (0x1 << 21));
1842 l |= (orig_width != out_width) ? (1 << 5) : 0;
1843 l |= (orig_height != out_height) ? (1 << 6) : 0;
1844 l |= five_taps ? (1 << 21) : 0;
1846 /* VRESIZECONF and HRESIZECONF */
1847 if (dispc_has_feature(dispc, FEAT_RESIZECONF)) {
1849 l |= (orig_width <= out_width) ? 0 : (1 << 7);
1850 l |= (orig_height <= out_height) ? 0 : (1 << 8);
1853 /* LINEBUFFERSPLIT */
1854 if (dispc_has_feature(dispc, FEAT_LINEBUFFERSPLIT)) {
1856 l |= five_taps ? (1 << 22) : 0;
1859 dispc_write_reg(dispc, DISPC_OVL_ATTRIBUTES(plane), l);
1862 * field 0 = even field = bottom field
1863 * field 1 = odd field = top field
1865 if (ilace && !fieldmode) {
1867 accu0 = ((1024 * orig_height / out_height) / 2) & 0x3ff;
1868 if (accu0 >= 1024/2) {
1874 dispc_ovl_set_vid_accu0(dispc, plane, 0, accu0);
1875 dispc_ovl_set_vid_accu1(dispc, plane, 0, accu1);
1878 static void dispc_ovl_set_scaling_uv(struct dispc_device *dispc,
1879 enum omap_plane_id plane,
1880 u16 orig_width, u16 orig_height,
1881 u16 out_width, u16 out_height,
1882 bool ilace, bool five_taps,
1883 bool fieldmode, u32 fourcc,
1886 int scale_x = out_width != orig_width;
1887 int scale_y = out_height != orig_height;
1888 bool chroma_upscale = plane != OMAP_DSS_WB;
1889 const struct drm_format_info *info;
1891 info = drm_format_info(fourcc);
1893 if (!dispc_has_feature(dispc, FEAT_HANDLE_UV_SEPARATE))
1896 if (!info->is_yuv) {
1897 /* reset chroma resampling for RGB formats */
1898 if (plane != OMAP_DSS_WB)
1899 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES2(plane),
1904 dispc_ovl_set_accu_uv(dispc, plane, orig_width, orig_height, out_width,
1905 out_height, ilace, fourcc, rotation);
1908 case DRM_FORMAT_NV12:
1909 if (chroma_upscale) {
1910 /* UV is subsampled by 2 horizontally and vertically */
1914 /* UV is downsampled by 2 horizontally and vertically */
1920 case DRM_FORMAT_YUYV:
1921 case DRM_FORMAT_UYVY:
1922 /* For YUV422 with 90/270 rotation, we don't upsample chroma */
1923 if (!drm_rotation_90_or_270(rotation)) {
1925 /* UV is subsampled by 2 horizontally */
1928 /* UV is downsampled by 2 horizontally */
1932 /* must use FIR for YUV422 if rotated */
1933 if ((rotation & DRM_MODE_ROTATE_MASK) != DRM_MODE_ROTATE_0)
1934 scale_x = scale_y = true;
1942 if (out_width != orig_width)
1944 if (out_height != orig_height)
1947 dispc_ovl_set_scale_param(dispc, plane, orig_width, orig_height,
1948 out_width, out_height, five_taps,
1949 rotation, DISPC_COLOR_COMPONENT_UV);
1951 if (plane != OMAP_DSS_WB)
1952 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES2(plane),
1953 (scale_x || scale_y) ? 1 : 0, 8, 8);
1956 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), scale_x ? 1 : 0, 5, 5);
1958 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), scale_y ? 1 : 0, 6, 6);
1961 static void dispc_ovl_set_scaling(struct dispc_device *dispc,
1962 enum omap_plane_id plane,
1963 u16 orig_width, u16 orig_height,
1964 u16 out_width, u16 out_height,
1965 bool ilace, bool five_taps,
1966 bool fieldmode, u32 fourcc,
1969 BUG_ON(plane == OMAP_DSS_GFX);
1971 dispc_ovl_set_scaling_common(dispc, plane, orig_width, orig_height,
1972 out_width, out_height, ilace, five_taps,
1973 fieldmode, fourcc, rotation);
1975 dispc_ovl_set_scaling_uv(dispc, plane, orig_width, orig_height,
1976 out_width, out_height, ilace, five_taps,
1977 fieldmode, fourcc, rotation);
1980 static void dispc_ovl_set_rotation_attrs(struct dispc_device *dispc,
1981 enum omap_plane_id plane, u8 rotation,
1982 enum omap_dss_rotation_type rotation_type,
1985 bool row_repeat = false;
1988 /* Note: DSS HW rotates clockwise, DRM_MODE_ROTATE_* counter-clockwise */
1989 if (fourcc == DRM_FORMAT_YUYV || fourcc == DRM_FORMAT_UYVY) {
1991 if (rotation & DRM_MODE_REFLECT_X) {
1992 switch (rotation & DRM_MODE_ROTATE_MASK) {
1993 case DRM_MODE_ROTATE_0:
1996 case DRM_MODE_ROTATE_90:
1999 case DRM_MODE_ROTATE_180:
2002 case DRM_MODE_ROTATE_270:
2007 switch (rotation & DRM_MODE_ROTATE_MASK) {
2008 case DRM_MODE_ROTATE_0:
2011 case DRM_MODE_ROTATE_90:
2014 case DRM_MODE_ROTATE_180:
2017 case DRM_MODE_ROTATE_270:
2023 if (drm_rotation_90_or_270(rotation))
2030 * OMAP4/5 Errata i631:
2031 * NV12 in 1D mode must use ROTATION=1. Otherwise DSS will fetch extra
2032 * rows beyond the framebuffer, which may cause OCP error.
2034 if (fourcc == DRM_FORMAT_NV12 && rotation_type != OMAP_DSS_ROT_TILER)
2037 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), vidrot, 13, 12);
2038 if (dispc_has_feature(dispc, FEAT_ROWREPEATENABLE))
2039 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane),
2040 row_repeat ? 1 : 0, 18, 18);
2042 if (dispc_ovl_color_mode_supported(dispc, plane, DRM_FORMAT_NV12)) {
2044 fourcc == DRM_FORMAT_NV12 &&
2045 rotation_type == OMAP_DSS_ROT_TILER &&
2046 !drm_rotation_90_or_270(rotation);
2049 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane),
2050 doublestride, 22, 22);
2054 static int color_mode_to_bpp(u32 fourcc)
2057 case DRM_FORMAT_NV12:
2059 case DRM_FORMAT_RGBX4444:
2060 case DRM_FORMAT_RGB565:
2061 case DRM_FORMAT_ARGB4444:
2062 case DRM_FORMAT_YUYV:
2063 case DRM_FORMAT_UYVY:
2064 case DRM_FORMAT_RGBA4444:
2065 case DRM_FORMAT_XRGB4444:
2066 case DRM_FORMAT_ARGB1555:
2067 case DRM_FORMAT_XRGB1555:
2069 case DRM_FORMAT_RGB888:
2071 case DRM_FORMAT_XRGB8888:
2072 case DRM_FORMAT_ARGB8888:
2073 case DRM_FORMAT_RGBA8888:
2074 case DRM_FORMAT_RGBX8888:
2082 static s32 pixinc(int pixels, u8 ps)
2086 else if (pixels > 1)
2087 return 1 + (pixels - 1) * ps;
2088 else if (pixels < 0)
2089 return 1 - (-pixels + 1) * ps;
2094 static void calc_offset(u16 screen_width, u16 width,
2095 u32 fourcc, bool fieldmode, unsigned int field_offset,
2096 unsigned int *offset0, unsigned int *offset1,
2097 s32 *row_inc, s32 *pix_inc, int x_predecim, int y_predecim,
2098 enum omap_dss_rotation_type rotation_type, u8 rotation)
2102 ps = color_mode_to_bpp(fourcc) / 8;
2104 DSSDBG("scrw %d, width %d\n", screen_width, width);
2106 if (rotation_type == OMAP_DSS_ROT_TILER &&
2107 (fourcc == DRM_FORMAT_UYVY || fourcc == DRM_FORMAT_YUYV) &&
2108 drm_rotation_90_or_270(rotation)) {
2110 * HACK: ROW_INC needs to be calculated with TILER units.
2111 * We get such 'screen_width' that multiplying it with the
2112 * YUV422 pixel size gives the correct TILER container width.
2113 * However, 'width' is in pixels and multiplying it with YUV422
2114 * pixel size gives incorrect result. We thus multiply it here
2115 * with 2 to match the 32 bit TILER unit size.
2121 * field 0 = even field = bottom field
2122 * field 1 = odd field = top field
2124 *offset0 = field_offset * screen_width * ps;
2127 *row_inc = pixinc(1 + (y_predecim * screen_width - width * x_predecim) +
2128 (fieldmode ? screen_width : 0), ps);
2129 if (fourcc == DRM_FORMAT_YUYV || fourcc == DRM_FORMAT_UYVY)
2130 *pix_inc = pixinc(x_predecim, 2 * ps);
2132 *pix_inc = pixinc(x_predecim, ps);
2136 * This function is used to avoid synclosts in OMAP3, because of some
2137 * undocumented horizontal position and timing related limitations.
2139 static int check_horiz_timing_omap3(unsigned long pclk, unsigned long lclk,
2140 const struct videomode *vm, u16 pos_x,
2141 u16 width, u16 height, u16 out_width, u16 out_height,
2144 const int ds = DIV_ROUND_UP(height, out_height);
2145 unsigned long nonactive;
2146 static const u8 limits[3] = { 8, 10, 20 };
2150 nonactive = vm->hactive + vm->hfront_porch + vm->hsync_len +
2151 vm->hback_porch - out_width;
2154 if (out_height < height)
2156 if (out_width < width)
2158 blank = div_u64((u64)(vm->hback_porch + vm->hsync_len + vm->hfront_porch) *
2160 DSSDBG("blanking period + ppl = %llu (limit = %u)\n", blank, limits[i]);
2161 if (blank <= limits[i])
2164 /* FIXME add checks for 3-tap filter once the limitations are known */
2169 * Pixel data should be prepared before visible display point starts.
2170 * So, atleast DS-2 lines must have already been fetched by DISPC
2171 * during nonactive - pos_x period.
2173 val = div_u64((u64)(nonactive - pos_x) * lclk, pclk);
2174 DSSDBG("(nonactive - pos_x) * pcd = %llu max(0, DS - 2) * width = %d\n",
2175 val, max(0, ds - 2) * width);
2176 if (val < max(0, ds - 2) * width)
2180 * All lines need to be refilled during the nonactive period of which
2181 * only one line can be loaded during the active period. So, atleast
2182 * DS - 1 lines should be loaded during nonactive period.
2184 val = div_u64((u64)nonactive * lclk, pclk);
2185 DSSDBG("nonactive * pcd = %llu, max(0, DS - 1) * width = %d\n",
2186 val, max(0, ds - 1) * width);
2187 if (val < max(0, ds - 1) * width)
2193 static unsigned long calc_core_clk_five_taps(unsigned long pclk,
2194 const struct videomode *vm, u16 width,
2195 u16 height, u16 out_width, u16 out_height,
2201 if (height <= out_height && width <= out_width)
2202 return (unsigned long) pclk;
2204 if (height > out_height) {
2205 unsigned int ppl = vm->hactive;
2207 tmp = (u64)pclk * height * out_width;
2208 do_div(tmp, 2 * out_height * ppl);
2211 if (height > 2 * out_height) {
2212 if (ppl == out_width)
2215 tmp = (u64)pclk * (height - 2 * out_height) * out_width;
2216 do_div(tmp, 2 * out_height * (ppl - out_width));
2217 core_clk = max_t(u32, core_clk, tmp);
2221 if (width > out_width) {
2222 tmp = (u64)pclk * width;
2223 do_div(tmp, out_width);
2224 core_clk = max_t(u32, core_clk, tmp);
2226 if (fourcc == DRM_FORMAT_XRGB8888)
2233 static unsigned long calc_core_clk_24xx(unsigned long pclk, u16 width,
2234 u16 height, u16 out_width, u16 out_height, bool mem_to_mem)
2236 if (height > out_height && width > out_width)
2242 static unsigned long calc_core_clk_34xx(unsigned long pclk, u16 width,
2243 u16 height, u16 out_width, u16 out_height, bool mem_to_mem)
2245 unsigned int hf, vf;
2248 * FIXME how to determine the 'A' factor
2249 * for the no downscaling case ?
2252 if (width > 3 * out_width)
2254 else if (width > 2 * out_width)
2256 else if (width > out_width)
2260 if (height > out_height)
2265 return pclk * vf * hf;
2268 static unsigned long calc_core_clk_44xx(unsigned long pclk, u16 width,
2269 u16 height, u16 out_width, u16 out_height, bool mem_to_mem)
2272 * If the overlay/writeback is in mem to mem mode, there are no
2273 * downscaling limitations with respect to pixel clock, return 1 as
2274 * required core clock to represent that we have sufficient enough
2275 * core clock to do maximum downscaling
2280 if (width > out_width)
2281 return DIV_ROUND_UP(pclk, out_width) * width;
2286 static int dispc_ovl_calc_scaling_24xx(struct dispc_device *dispc,
2287 unsigned long pclk, unsigned long lclk,
2288 const struct videomode *vm,
2289 u16 width, u16 height,
2290 u16 out_width, u16 out_height,
2291 u32 fourcc, bool *five_taps,
2292 int *x_predecim, int *y_predecim,
2293 int *decim_x, int *decim_y,
2294 u16 pos_x, unsigned long *core_clk,
2298 u16 in_width, in_height;
2299 int min_factor = min(*decim_x, *decim_y);
2300 const int maxsinglelinewidth = dispc->feat->max_line_width;
2305 in_height = height / *decim_y;
2306 in_width = width / *decim_x;
2307 *core_clk = dispc->feat->calc_core_clk(pclk, in_width,
2308 in_height, out_width, out_height, mem_to_mem);
2309 error = (in_width > maxsinglelinewidth || !*core_clk ||
2310 *core_clk > dispc_core_clk_rate(dispc));
2312 if (*decim_x == *decim_y) {
2313 *decim_x = min_factor;
2316 swap(*decim_x, *decim_y);
2317 if (*decim_x < *decim_y)
2321 } while (*decim_x <= *x_predecim && *decim_y <= *y_predecim && error);
2324 DSSERR("failed to find scaling settings\n");
2328 if (in_width > maxsinglelinewidth) {
2329 DSSERR("Cannot scale max input width exceeded\n");
2335 static int dispc_ovl_calc_scaling_34xx(struct dispc_device *dispc,
2336 unsigned long pclk, unsigned long lclk,
2337 const struct videomode *vm,
2338 u16 width, u16 height,
2339 u16 out_width, u16 out_height,
2340 u32 fourcc, bool *five_taps,
2341 int *x_predecim, int *y_predecim,
2342 int *decim_x, int *decim_y,
2343 u16 pos_x, unsigned long *core_clk,
2347 u16 in_width, in_height;
2348 const int maxsinglelinewidth = dispc->feat->max_line_width;
2351 in_height = height / *decim_y;
2352 in_width = width / *decim_x;
2353 *five_taps = in_height > out_height;
2355 if (in_width > maxsinglelinewidth)
2356 if (in_height > out_height &&
2357 in_height < out_height * 2)
2361 *core_clk = calc_core_clk_five_taps(pclk, vm,
2362 in_width, in_height, out_width,
2363 out_height, fourcc);
2365 *core_clk = dispc->feat->calc_core_clk(pclk, in_width,
2366 in_height, out_width, out_height,
2369 error = check_horiz_timing_omap3(pclk, lclk, vm,
2370 pos_x, in_width, in_height, out_width,
2371 out_height, *five_taps);
2372 if (error && *five_taps) {
2377 error = (error || in_width > maxsinglelinewidth * 2 ||
2378 (in_width > maxsinglelinewidth && *five_taps) ||
2379 !*core_clk || *core_clk > dispc_core_clk_rate(dispc));
2382 /* verify that we're inside the limits of scaler */
2383 if (in_width / 4 > out_width)
2387 if (in_height / 4 > out_height)
2390 if (in_height / 2 > out_height)
2397 } while (*decim_x <= *x_predecim && *decim_y <= *y_predecim && error);
2400 DSSERR("failed to find scaling settings\n");
2404 if (check_horiz_timing_omap3(pclk, lclk, vm, pos_x, in_width,
2405 in_height, out_width, out_height, *five_taps)) {
2406 DSSERR("horizontal timing too tight\n");
2410 if (in_width > (maxsinglelinewidth * 2)) {
2411 DSSERR("Cannot setup scaling\n");
2412 DSSERR("width exceeds maximum width possible\n");
2416 if (in_width > maxsinglelinewidth && *five_taps) {
2417 DSSERR("cannot setup scaling with five taps\n");
2423 static int dispc_ovl_calc_scaling_44xx(struct dispc_device *dispc,
2424 unsigned long pclk, unsigned long lclk,
2425 const struct videomode *vm,
2426 u16 width, u16 height,
2427 u16 out_width, u16 out_height,
2428 u32 fourcc, bool *five_taps,
2429 int *x_predecim, int *y_predecim,
2430 int *decim_x, int *decim_y,
2431 u16 pos_x, unsigned long *core_clk,
2434 u16 in_width, in_width_max;
2435 int decim_x_min = *decim_x;
2436 u16 in_height = height / *decim_y;
2437 const int maxsinglelinewidth = dispc->feat->max_line_width;
2438 const int maxdownscale = dispc->feat->max_downscale;
2441 in_width_max = out_width * maxdownscale;
2443 in_width_max = dispc_core_clk_rate(dispc)
2444 / DIV_ROUND_UP(pclk, out_width);
2447 *decim_x = DIV_ROUND_UP(width, in_width_max);
2449 *decim_x = max(*decim_x, decim_x_min);
2450 if (*decim_x > *x_predecim)
2454 in_width = width / *decim_x;
2455 } while (*decim_x <= *x_predecim &&
2456 in_width > maxsinglelinewidth && ++*decim_x);
2458 if (in_width > maxsinglelinewidth) {
2459 DSSERR("Cannot scale width exceeds max line width\n");
2463 if (*decim_x > 4 && fourcc != DRM_FORMAT_NV12) {
2465 * Let's disable all scaling that requires horizontal
2466 * decimation with higher factor than 4, until we have
2467 * better estimates of what we can and can not
2468 * do. However, NV12 color format appears to work Ok
2469 * with all decimation factors.
2471 * When decimating horizontally by more that 4 the dss
2472 * is not able to fetch the data in burst mode. When
2473 * this happens it is hard to tell if there enough
2474 * bandwidth. Despite what theory says this appears to
2475 * be true also for 16-bit color formats.
2477 DSSERR("Not enough bandwidth, too much downscaling (x-decimation factor %d > 4)\n", *decim_x);
2482 *core_clk = dispc->feat->calc_core_clk(pclk, in_width, in_height,
2483 out_width, out_height, mem_to_mem);
2487 enum omap_overlay_caps dispc_ovl_get_caps(struct dispc_device *dispc, enum omap_plane_id plane)
2489 return dispc->feat->overlay_caps[plane];
2492 #define DIV_FRAC(dividend, divisor) \
2493 ((dividend) * 100 / (divisor) - ((dividend) / (divisor) * 100))
2495 static int dispc_ovl_calc_scaling(struct dispc_device *dispc,
2496 enum omap_plane_id plane,
2497 unsigned long pclk, unsigned long lclk,
2498 enum omap_overlay_caps caps,
2499 const struct videomode *vm,
2500 u16 width, u16 height,
2501 u16 out_width, u16 out_height,
2502 u32 fourcc, bool *five_taps,
2503 int *x_predecim, int *y_predecim, u16 pos_x,
2504 enum omap_dss_rotation_type rotation_type,
2507 int maxhdownscale = dispc->feat->max_downscale;
2508 int maxvdownscale = dispc->feat->max_downscale;
2509 const int max_decim_limit = 16;
2510 unsigned long core_clk = 0;
2511 int decim_x, decim_y, ret;
2513 if (width == out_width && height == out_height)
2516 if (dispc->feat->supported_scaler_color_modes) {
2517 const u32 *modes = dispc->feat->supported_scaler_color_modes;
2520 for (i = 0; modes[i]; ++i) {
2521 if (modes[i] == fourcc)
2529 if (plane == OMAP_DSS_WB) {
2531 case DRM_FORMAT_NV12:
2532 maxhdownscale = maxvdownscale = 2;
2534 case DRM_FORMAT_YUYV:
2535 case DRM_FORMAT_UYVY:
2543 if (!mem_to_mem && (pclk == 0 || vm->pixelclock == 0)) {
2544 DSSERR("cannot calculate scaling settings: pclk is zero\n");
2548 if ((caps & OMAP_DSS_OVL_CAP_SCALE) == 0)
2552 *x_predecim = *y_predecim = 1;
2554 *x_predecim = max_decim_limit;
2555 *y_predecim = (rotation_type == OMAP_DSS_ROT_TILER &&
2556 dispc_has_feature(dispc, FEAT_BURST_2D)) ?
2557 2 : max_decim_limit;
2560 decim_x = DIV_ROUND_UP(DIV_ROUND_UP(width, out_width), maxhdownscale);
2561 decim_y = DIV_ROUND_UP(DIV_ROUND_UP(height, out_height), maxvdownscale);
2563 if (decim_x > *x_predecim || out_width > width * 8)
2566 if (decim_y > *y_predecim || out_height > height * 8)
2569 ret = dispc->feat->calc_scaling(dispc, pclk, lclk, vm, width, height,
2570 out_width, out_height, fourcc,
2571 five_taps, x_predecim, y_predecim,
2572 &decim_x, &decim_y, pos_x, &core_clk,
2577 DSSDBG("%dx%d -> %dx%d (%d.%02d x %d.%02d), decim %dx%d %dx%d (%d.%02d x %d.%02d), taps %d, req clk %lu, cur clk %lu\n",
2579 out_width, out_height,
2580 out_width / width, DIV_FRAC(out_width, width),
2581 out_height / height, DIV_FRAC(out_height, height),
2584 width / decim_x, height / decim_y,
2585 out_width / (width / decim_x), DIV_FRAC(out_width, width / decim_x),
2586 out_height / (height / decim_y), DIV_FRAC(out_height, height / decim_y),
2589 core_clk, dispc_core_clk_rate(dispc));
2591 if (!core_clk || core_clk > dispc_core_clk_rate(dispc)) {
2592 DSSERR("failed to set up scaling, "
2593 "required core clk rate = %lu Hz, "
2594 "current core clk rate = %lu Hz\n",
2595 core_clk, dispc_core_clk_rate(dispc));
2599 *x_predecim = decim_x;
2600 *y_predecim = decim_y;
2604 void dispc_ovl_get_max_size(struct dispc_device *dispc, u16 *width, u16 *height)
2606 *width = dispc->feat->ovl_width_max;
2607 *height = dispc->feat->ovl_height_max;
2610 static int dispc_ovl_setup_common(struct dispc_device *dispc,
2611 enum omap_plane_id plane,
2612 enum omap_overlay_caps caps,
2613 u32 paddr, u32 p_uv_addr,
2614 u16 screen_width, int pos_x, int pos_y,
2615 u16 width, u16 height,
2616 u16 out_width, u16 out_height,
2617 u32 fourcc, u8 rotation, u8 zorder,
2618 u8 pre_mult_alpha, u8 global_alpha,
2619 enum omap_dss_rotation_type rotation_type,
2620 bool replication, const struct videomode *vm,
2622 enum drm_color_encoding color_encoding,
2623 enum drm_color_range color_range)
2625 bool five_taps = true;
2626 bool fieldmode = false;
2628 unsigned int offset0, offset1;
2632 unsigned int field_offset = 0;
2633 u16 in_height = height;
2634 u16 in_width = width;
2635 int x_predecim = 1, y_predecim = 1;
2636 bool ilace = !!(vm->flags & DISPLAY_FLAGS_INTERLACED);
2637 unsigned long pclk = dispc_plane_pclk_rate(dispc, plane);
2638 unsigned long lclk = dispc_plane_lclk_rate(dispc, plane);
2639 const struct drm_format_info *info;
2641 info = drm_format_info(fourcc);
2643 /* when setting up WB, dispc_plane_pclk_rate() returns 0 */
2644 if (plane == OMAP_DSS_WB)
2645 pclk = vm->pixelclock;
2647 if (paddr == 0 && rotation_type != OMAP_DSS_ROT_TILER)
2650 if (info->is_yuv && (in_width & 1)) {
2651 DSSERR("input width %d is not even for YUV format\n", in_width);
2655 out_width = out_width == 0 ? width : out_width;
2656 out_height = out_height == 0 ? height : out_height;
2658 if (plane != OMAP_DSS_WB) {
2659 if (ilace && height == out_height)
2668 DSSDBG("adjusting for ilace: height %d, pos_y %d, out_height %d\n",
2669 in_height, pos_y, out_height);
2673 if (!dispc_ovl_color_mode_supported(dispc, plane, fourcc))
2676 r = dispc_ovl_calc_scaling(dispc, plane, pclk, lclk, caps, vm, in_width,
2677 in_height, out_width, out_height, fourcc,
2678 &five_taps, &x_predecim, &y_predecim, pos_x,
2679 rotation_type, mem_to_mem);
2683 in_width = in_width / x_predecim;
2684 in_height = in_height / y_predecim;
2686 if (x_predecim > 1 || y_predecim > 1)
2687 DSSDBG("predecimation %d x %x, new input size %d x %d\n",
2688 x_predecim, y_predecim, in_width, in_height);
2690 if (info->is_yuv && (in_width & 1)) {
2691 DSSDBG("predecimated input width is not even for YUV format\n");
2692 DSSDBG("adjusting input width %d -> %d\n",
2693 in_width, in_width & ~1);
2701 if (ilace && !fieldmode) {
2703 * when downscaling the bottom field may have to start several
2704 * source lines below the top field. Unfortunately ACCUI
2705 * registers will only hold the fractional part of the offset
2706 * so the integer part must be added to the base address of the
2709 if (!in_height || in_height == out_height)
2712 field_offset = in_height / out_height / 2;
2715 /* Fields are independent but interleaved in memory. */
2724 if (plane == OMAP_DSS_WB)
2725 frame_width = out_width;
2727 frame_width = in_width;
2729 calc_offset(screen_width, frame_width,
2730 fourcc, fieldmode, field_offset,
2731 &offset0, &offset1, &row_inc, &pix_inc,
2732 x_predecim, y_predecim,
2733 rotation_type, rotation);
2735 DSSDBG("offset0 %u, offset1 %u, row_inc %d, pix_inc %d\n",
2736 offset0, offset1, row_inc, pix_inc);
2738 dispc_ovl_set_color_mode(dispc, plane, fourcc);
2740 dispc_ovl_configure_burst_type(dispc, plane, rotation_type);
2742 if (dispc->feat->reverse_ilace_field_order)
2743 swap(offset0, offset1);
2745 dispc_ovl_set_ba0(dispc, plane, paddr + offset0);
2746 dispc_ovl_set_ba1(dispc, plane, paddr + offset1);
2748 if (fourcc == DRM_FORMAT_NV12) {
2749 dispc_ovl_set_ba0_uv(dispc, plane, p_uv_addr + offset0);
2750 dispc_ovl_set_ba1_uv(dispc, plane, p_uv_addr + offset1);
2753 if (dispc->feat->last_pixel_inc_missing)
2754 row_inc += pix_inc - 1;
2756 dispc_ovl_set_row_inc(dispc, plane, row_inc);
2757 dispc_ovl_set_pix_inc(dispc, plane, pix_inc);
2759 DSSDBG("%d,%d %dx%d -> %dx%d\n", pos_x, pos_y, in_width,
2760 in_height, out_width, out_height);
2762 dispc_ovl_set_pos(dispc, plane, caps, pos_x, pos_y);
2764 dispc_ovl_set_input_size(dispc, plane, in_width, in_height);
2766 if (caps & OMAP_DSS_OVL_CAP_SCALE) {
2767 dispc_ovl_set_scaling(dispc, plane, in_width, in_height,
2768 out_width, out_height, ilace, five_taps,
2769 fieldmode, fourcc, rotation);
2770 dispc_ovl_set_output_size(dispc, plane, out_width, out_height);
2771 dispc_ovl_set_vid_color_conv(dispc, plane, cconv);
2773 if (plane != OMAP_DSS_WB)
2774 dispc_ovl_set_csc(dispc, plane, color_encoding, color_range);
2777 dispc_ovl_set_rotation_attrs(dispc, plane, rotation, rotation_type,
2780 dispc_ovl_set_zorder(dispc, plane, caps, zorder);
2781 dispc_ovl_set_pre_mult_alpha(dispc, plane, caps, pre_mult_alpha);
2782 dispc_ovl_setup_global_alpha(dispc, plane, caps, global_alpha);
2784 dispc_ovl_enable_replication(dispc, plane, caps, replication);
2789 int dispc_ovl_setup(struct dispc_device *dispc,
2790 enum omap_plane_id plane,
2791 const struct omap_overlay_info *oi,
2792 const struct videomode *vm, bool mem_to_mem,
2793 enum omap_channel channel)
2796 enum omap_overlay_caps caps = dispc->feat->overlay_caps[plane];
2797 const bool replication = true;
2799 DSSDBG("dispc_ovl_setup %d, pa %pad, pa_uv %pad, sw %d, %d,%d, %dx%d ->"
2800 " %dx%d, cmode %x, rot %d, chan %d repl %d\n",
2801 plane, &oi->paddr, &oi->p_uv_addr, oi->screen_width, oi->pos_x,
2802 oi->pos_y, oi->width, oi->height, oi->out_width, oi->out_height,
2803 oi->fourcc, oi->rotation, channel, replication);
2805 dispc_ovl_set_channel_out(dispc, plane, channel);
2807 r = dispc_ovl_setup_common(dispc, plane, caps, oi->paddr, oi->p_uv_addr,
2808 oi->screen_width, oi->pos_x, oi->pos_y, oi->width, oi->height,
2809 oi->out_width, oi->out_height, oi->fourcc, oi->rotation,
2810 oi->zorder, oi->pre_mult_alpha, oi->global_alpha,
2811 oi->rotation_type, replication, vm, mem_to_mem,
2812 oi->color_encoding, oi->color_range);
2817 int dispc_wb_setup(struct dispc_device *dispc,
2818 const struct omap_dss_writeback_info *wi,
2819 bool mem_to_mem, const struct videomode *vm,
2820 enum dss_writeback_channel channel_in)
2824 enum omap_plane_id plane = OMAP_DSS_WB;
2825 const int pos_x = 0, pos_y = 0;
2826 const u8 zorder = 0, global_alpha = 0;
2827 const bool replication = true;
2829 int in_width = vm->hactive;
2830 int in_height = vm->vactive;
2831 enum omap_overlay_caps caps =
2832 OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA;
2834 if (vm->flags & DISPLAY_FLAGS_INTERLACED)
2837 DSSDBG("dispc_wb_setup, pa %x, pa_uv %x, %d,%d -> %dx%d, cmode %x, "
2838 "rot %d\n", wi->paddr, wi->p_uv_addr, in_width,
2839 in_height, wi->width, wi->height, wi->fourcc, wi->rotation);
2841 r = dispc_ovl_setup_common(dispc, plane, caps, wi->paddr, wi->p_uv_addr,
2842 wi->buf_width, pos_x, pos_y, in_width, in_height, wi->width,
2843 wi->height, wi->fourcc, wi->rotation, zorder,
2844 wi->pre_mult_alpha, global_alpha, wi->rotation_type,
2845 replication, vm, mem_to_mem, DRM_COLOR_YCBCR_BT601,
2846 DRM_COLOR_YCBCR_LIMITED_RANGE);
2850 switch (wi->fourcc) {
2851 case DRM_FORMAT_RGB565:
2852 case DRM_FORMAT_RGB888:
2853 case DRM_FORMAT_ARGB4444:
2854 case DRM_FORMAT_RGBA4444:
2855 case DRM_FORMAT_RGBX4444:
2856 case DRM_FORMAT_ARGB1555:
2857 case DRM_FORMAT_XRGB1555:
2858 case DRM_FORMAT_XRGB4444:
2866 /* setup extra DISPC_WB_ATTRIBUTES */
2867 l = dispc_read_reg(dispc, DISPC_OVL_ATTRIBUTES(plane));
2868 l = FLD_MOD(l, truncation, 10, 10); /* TRUNCATIONENABLE */
2869 l = FLD_MOD(l, channel_in, 18, 16); /* CHANNELIN */
2870 l = FLD_MOD(l, mem_to_mem, 19, 19); /* WRITEBACKMODE */
2872 l = FLD_MOD(l, 1, 26, 24); /* CAPTUREMODE */
2874 l = FLD_MOD(l, 0, 26, 24); /* CAPTUREMODE */
2875 dispc_write_reg(dispc, DISPC_OVL_ATTRIBUTES(plane), l);
2879 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES2(plane), 0, 7, 0);
2883 if (channel_in == DSS_WB_TV_MGR)
2884 wbdelay = vm->vsync_len + vm->vback_porch;
2886 wbdelay = vm->vfront_porch + vm->vsync_len +
2889 if (vm->flags & DISPLAY_FLAGS_INTERLACED)
2892 wbdelay = min(wbdelay, 255u);
2895 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES2(plane), wbdelay, 7, 0);
2901 bool dispc_has_writeback(struct dispc_device *dispc)
2903 return dispc->feat->has_writeback;
2906 int dispc_ovl_enable(struct dispc_device *dispc,
2907 enum omap_plane_id plane, bool enable)
2909 DSSDBG("dispc_enable_plane %d, %d\n", plane, enable);
2911 REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), enable ? 1 : 0, 0, 0);
2916 static void dispc_lcd_enable_signal_polarity(struct dispc_device *dispc,
2919 if (!dispc_has_feature(dispc, FEAT_LCDENABLEPOL))
2922 REG_FLD_MOD(dispc, DISPC_CONTROL, act_high ? 1 : 0, 29, 29);
2925 void dispc_lcd_enable_signal(struct dispc_device *dispc, bool enable)
2927 if (!dispc_has_feature(dispc, FEAT_LCDENABLESIGNAL))
2930 REG_FLD_MOD(dispc, DISPC_CONTROL, enable ? 1 : 0, 28, 28);
2933 void dispc_pck_free_enable(struct dispc_device *dispc, bool enable)
2935 if (!dispc_has_feature(dispc, FEAT_PCKFREEENABLE))
2938 REG_FLD_MOD(dispc, DISPC_CONTROL, enable ? 1 : 0, 27, 27);
2941 static void dispc_mgr_enable_fifohandcheck(struct dispc_device *dispc,
2942 enum omap_channel channel,
2945 mgr_fld_write(dispc, channel, DISPC_MGR_FLD_FIFOHANDCHECK, enable);
2949 static void dispc_mgr_set_lcd_type_tft(struct dispc_device *dispc,
2950 enum omap_channel channel)
2952 mgr_fld_write(dispc, channel, DISPC_MGR_FLD_STNTFT, 1);
2955 static void dispc_set_loadmode(struct dispc_device *dispc,
2956 enum omap_dss_load_mode mode)
2958 REG_FLD_MOD(dispc, DISPC_CONFIG, mode, 2, 1);
2962 static void dispc_mgr_set_default_color(struct dispc_device *dispc,
2963 enum omap_channel channel, u32 color)
2965 dispc_write_reg(dispc, DISPC_DEFAULT_COLOR(channel), color);
2968 static void dispc_mgr_set_trans_key(struct dispc_device *dispc,
2969 enum omap_channel ch,
2970 enum omap_dss_trans_key_type type,
2973 mgr_fld_write(dispc, ch, DISPC_MGR_FLD_TCKSELECTION, type);
2975 dispc_write_reg(dispc, DISPC_TRANS_COLOR(ch), trans_key);
2978 static void dispc_mgr_enable_trans_key(struct dispc_device *dispc,
2979 enum omap_channel ch, bool enable)
2981 mgr_fld_write(dispc, ch, DISPC_MGR_FLD_TCKENABLE, enable);
2984 static void dispc_mgr_enable_alpha_fixed_zorder(struct dispc_device *dispc,
2985 enum omap_channel ch,
2988 if (!dispc_has_feature(dispc, FEAT_ALPHA_FIXED_ZORDER))
2991 if (ch == OMAP_DSS_CHANNEL_LCD)
2992 REG_FLD_MOD(dispc, DISPC_CONFIG, enable, 18, 18);
2993 else if (ch == OMAP_DSS_CHANNEL_DIGIT)
2994 REG_FLD_MOD(dispc, DISPC_CONFIG, enable, 19, 19);
2997 void dispc_mgr_setup(struct dispc_device *dispc,
2998 enum omap_channel channel,
2999 const struct omap_overlay_manager_info *info)
3001 dispc_mgr_set_default_color(dispc, channel, info->default_color);
3002 dispc_mgr_set_trans_key(dispc, channel, info->trans_key_type,
3004 dispc_mgr_enable_trans_key(dispc, channel, info->trans_enabled);
3005 dispc_mgr_enable_alpha_fixed_zorder(dispc, channel,
3006 info->partial_alpha_enabled);
3007 if (dispc_has_feature(dispc, FEAT_CPR)) {
3008 dispc_mgr_enable_cpr(dispc, channel, info->cpr_enable);
3009 dispc_mgr_set_cpr_coef(dispc, channel, &info->cpr_coefs);
3013 static void dispc_mgr_set_tft_data_lines(struct dispc_device *dispc,
3014 enum omap_channel channel,
3019 switch (data_lines) {
3037 mgr_fld_write(dispc, channel, DISPC_MGR_FLD_TFTDATALINES, code);
3040 static void dispc_mgr_set_io_pad_mode(struct dispc_device *dispc,
3041 enum dss_io_pad_mode mode)
3047 case DSS_IO_PAD_MODE_RESET:
3051 case DSS_IO_PAD_MODE_RFBI:
3055 case DSS_IO_PAD_MODE_BYPASS:
3064 l = dispc_read_reg(dispc, DISPC_CONTROL);
3065 l = FLD_MOD(l, gpout0, 15, 15);
3066 l = FLD_MOD(l, gpout1, 16, 16);
3067 dispc_write_reg(dispc, DISPC_CONTROL, l);
3070 static void dispc_mgr_enable_stallmode(struct dispc_device *dispc,
3071 enum omap_channel channel, bool enable)
3073 mgr_fld_write(dispc, channel, DISPC_MGR_FLD_STALLMODE, enable);
3076 void dispc_mgr_set_lcd_config(struct dispc_device *dispc,
3077 enum omap_channel channel,
3078 const struct dss_lcd_mgr_config *config)
3080 dispc_mgr_set_io_pad_mode(dispc, config->io_pad_mode);
3082 dispc_mgr_enable_stallmode(dispc, channel, config->stallmode);
3083 dispc_mgr_enable_fifohandcheck(dispc, channel, config->fifohandcheck);
3085 dispc_mgr_set_clock_div(dispc, channel, &config->clock_info);
3087 dispc_mgr_set_tft_data_lines(dispc, channel, config->video_port_width);
3089 dispc_lcd_enable_signal_polarity(dispc, config->lcden_sig_polarity);
3091 dispc_mgr_set_lcd_type_tft(dispc, channel);
3094 static bool _dispc_mgr_size_ok(struct dispc_device *dispc,
3095 u16 width, u16 height)
3097 return width <= dispc->feat->mgr_width_max &&
3098 height <= dispc->feat->mgr_height_max;
3101 static bool _dispc_lcd_timings_ok(struct dispc_device *dispc,
3102 int hsync_len, int hfp, int hbp,
3103 int vsw, int vfp, int vbp)
3105 if (hsync_len < 1 || hsync_len > dispc->feat->sw_max ||
3106 hfp < 1 || hfp > dispc->feat->hp_max ||
3107 hbp < 1 || hbp > dispc->feat->hp_max ||
3108 vsw < 1 || vsw > dispc->feat->sw_max ||
3109 vfp < 0 || vfp > dispc->feat->vp_max ||
3110 vbp < 0 || vbp > dispc->feat->vp_max)
3115 static bool _dispc_mgr_pclk_ok(struct dispc_device *dispc,
3116 enum omap_channel channel,
3119 if (dss_mgr_is_lcd(channel))
3120 return pclk <= dispc->feat->max_lcd_pclk;
3122 return pclk <= dispc->feat->max_tv_pclk;
3125 int dispc_mgr_check_timings(struct dispc_device *dispc,
3126 enum omap_channel channel,
3127 const struct videomode *vm)
3129 if (!_dispc_mgr_size_ok(dispc, vm->hactive, vm->vactive))
3132 if (!_dispc_mgr_pclk_ok(dispc, channel, vm->pixelclock))
3135 if (dss_mgr_is_lcd(channel)) {
3136 /* TODO: OMAP4+ supports interlace for LCD outputs */
3137 if (vm->flags & DISPLAY_FLAGS_INTERLACED)
3140 if (!_dispc_lcd_timings_ok(dispc, vm->hsync_len,
3141 vm->hfront_porch, vm->hback_porch,
3142 vm->vsync_len, vm->vfront_porch,
3150 static void _dispc_mgr_set_lcd_timings(struct dispc_device *dispc,
3151 enum omap_channel channel,
3152 const struct videomode *vm)
3154 u32 timing_h, timing_v, l;
3155 bool onoff, rf, ipc, vs, hs, de;
3157 timing_h = FLD_VAL(vm->hsync_len - 1, dispc->feat->sw_start, 0) |
3158 FLD_VAL(vm->hfront_porch - 1, dispc->feat->fp_start, 8) |
3159 FLD_VAL(vm->hback_porch - 1, dispc->feat->bp_start, 20);
3160 timing_v = FLD_VAL(vm->vsync_len - 1, dispc->feat->sw_start, 0) |
3161 FLD_VAL(vm->vfront_porch, dispc->feat->fp_start, 8) |
3162 FLD_VAL(vm->vback_porch, dispc->feat->bp_start, 20);
3164 dispc_write_reg(dispc, DISPC_TIMING_H(channel), timing_h);
3165 dispc_write_reg(dispc, DISPC_TIMING_V(channel), timing_v);
3167 vs = !!(vm->flags & DISPLAY_FLAGS_VSYNC_LOW);
3168 hs = !!(vm->flags & DISPLAY_FLAGS_HSYNC_LOW);
3169 de = !!(vm->flags & DISPLAY_FLAGS_DE_LOW);
3170 ipc = !!(vm->flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE);
3171 onoff = true; /* always use the 'rf' setting */
3172 rf = !!(vm->flags & DISPLAY_FLAGS_SYNC_POSEDGE);
3174 l = FLD_VAL(onoff, 17, 17) |
3175 FLD_VAL(rf, 16, 16) |
3176 FLD_VAL(de, 15, 15) |
3177 FLD_VAL(ipc, 14, 14) |
3178 FLD_VAL(hs, 13, 13) |
3179 FLD_VAL(vs, 12, 12);
3181 /* always set ALIGN bit when available */
3182 if (dispc->feat->supports_sync_align)
3185 dispc_write_reg(dispc, DISPC_POL_FREQ(channel), l);
3187 if (dispc->syscon_pol) {
3188 const int shifts[] = {
3189 [OMAP_DSS_CHANNEL_LCD] = 0,
3190 [OMAP_DSS_CHANNEL_LCD2] = 1,
3191 [OMAP_DSS_CHANNEL_LCD3] = 2,
3196 mask = (1 << 0) | (1 << 3) | (1 << 6);
3197 val = (rf << 0) | (ipc << 3) | (onoff << 6);
3199 mask <<= 16 + shifts[channel];
3200 val <<= 16 + shifts[channel];
3202 regmap_update_bits(dispc->syscon_pol, dispc->syscon_pol_offset,
3207 static int vm_flag_to_int(enum display_flags flags, enum display_flags high,
3208 enum display_flags low)
3217 /* change name to mode? */
3218 void dispc_mgr_set_timings(struct dispc_device *dispc,
3219 enum omap_channel channel,
3220 const struct videomode *vm)
3222 unsigned int xtot, ytot;
3223 unsigned long ht, vt;
3224 struct videomode t = *vm;
3226 DSSDBG("channel %d xres %u yres %u\n", channel, t.hactive, t.vactive);
3228 if (dispc_mgr_check_timings(dispc, channel, &t)) {
3233 if (dss_mgr_is_lcd(channel)) {
3234 _dispc_mgr_set_lcd_timings(dispc, channel, &t);
3236 xtot = t.hactive + t.hfront_porch + t.hsync_len + t.hback_porch;
3237 ytot = t.vactive + t.vfront_porch + t.vsync_len + t.vback_porch;
3239 ht = vm->pixelclock / xtot;
3240 vt = vm->pixelclock / xtot / ytot;
3242 DSSDBG("pck %lu\n", vm->pixelclock);
3243 DSSDBG("hsync_len %d hfp %d hbp %d vsw %d vfp %d vbp %d\n",
3244 t.hsync_len, t.hfront_porch, t.hback_porch,
3245 t.vsync_len, t.vfront_porch, t.vback_porch);
3246 DSSDBG("vsync_level %d hsync_level %d data_pclk_edge %d de_level %d sync_pclk_edge %d\n",
3247 vm_flag_to_int(t.flags, DISPLAY_FLAGS_VSYNC_HIGH, DISPLAY_FLAGS_VSYNC_LOW),
3248 vm_flag_to_int(t.flags, DISPLAY_FLAGS_HSYNC_HIGH, DISPLAY_FLAGS_HSYNC_LOW),
3249 vm_flag_to_int(t.flags, DISPLAY_FLAGS_PIXDATA_POSEDGE, DISPLAY_FLAGS_PIXDATA_NEGEDGE),
3250 vm_flag_to_int(t.flags, DISPLAY_FLAGS_DE_HIGH, DISPLAY_FLAGS_DE_LOW),
3251 vm_flag_to_int(t.flags, DISPLAY_FLAGS_SYNC_POSEDGE, DISPLAY_FLAGS_SYNC_NEGEDGE));
3253 DSSDBG("hsync %luHz, vsync %luHz\n", ht, vt);
3255 if (t.flags & DISPLAY_FLAGS_INTERLACED)
3258 if (dispc->feat->supports_double_pixel)
3259 REG_FLD_MOD(dispc, DISPC_CONTROL,
3260 !!(t.flags & DISPLAY_FLAGS_DOUBLECLK),
3264 dispc_mgr_set_size(dispc, channel, t.hactive, t.vactive);
3267 static void dispc_mgr_set_lcd_divisor(struct dispc_device *dispc,
3268 enum omap_channel channel, u16 lck_div,
3271 BUG_ON(lck_div < 1);
3272 BUG_ON(pck_div < 1);
3274 dispc_write_reg(dispc, DISPC_DIVISORo(channel),
3275 FLD_VAL(lck_div, 23, 16) | FLD_VAL(pck_div, 7, 0));
3277 if (!dispc_has_feature(dispc, FEAT_CORE_CLK_DIV) &&
3278 channel == OMAP_DSS_CHANNEL_LCD)
3279 dispc->core_clk_rate = dispc_fclk_rate(dispc) / lck_div;
3282 static void dispc_mgr_get_lcd_divisor(struct dispc_device *dispc,
3283 enum omap_channel channel, int *lck_div,
3287 l = dispc_read_reg(dispc, DISPC_DIVISORo(channel));
3288 *lck_div = FLD_GET(l, 23, 16);
3289 *pck_div = FLD_GET(l, 7, 0);
3292 static unsigned long dispc_fclk_rate(struct dispc_device *dispc)
3295 enum dss_clk_source src;
3297 src = dss_get_dispc_clk_source(dispc->dss);
3299 if (src == DSS_CLK_SRC_FCK) {
3300 r = dss_get_dispc_clk_rate(dispc->dss);
3302 struct dss_pll *pll;
3303 unsigned int clkout_idx;
3305 pll = dss_pll_find_by_src(dispc->dss, src);
3306 clkout_idx = dss_pll_get_clkout_idx_for_src(src);
3308 r = pll->cinfo.clkout[clkout_idx];
3314 static unsigned long dispc_mgr_lclk_rate(struct dispc_device *dispc,
3315 enum omap_channel channel)
3319 enum dss_clk_source src;
3321 /* for TV, LCLK rate is the FCLK rate */
3322 if (!dss_mgr_is_lcd(channel))
3323 return dispc_fclk_rate(dispc);
3325 src = dss_get_lcd_clk_source(dispc->dss, channel);
3327 if (src == DSS_CLK_SRC_FCK) {
3328 r = dss_get_dispc_clk_rate(dispc->dss);
3330 struct dss_pll *pll;
3331 unsigned int clkout_idx;
3333 pll = dss_pll_find_by_src(dispc->dss, src);
3334 clkout_idx = dss_pll_get_clkout_idx_for_src(src);
3336 r = pll->cinfo.clkout[clkout_idx];
3339 lcd = REG_GET(dispc, DISPC_DIVISORo(channel), 23, 16);
3344 static unsigned long dispc_mgr_pclk_rate(struct dispc_device *dispc,
3345 enum omap_channel channel)
3349 if (dss_mgr_is_lcd(channel)) {
3353 l = dispc_read_reg(dispc, DISPC_DIVISORo(channel));
3355 pcd = FLD_GET(l, 7, 0);
3357 r = dispc_mgr_lclk_rate(dispc, channel);
3361 return dispc->tv_pclk_rate;
3365 void dispc_set_tv_pclk(struct dispc_device *dispc, unsigned long pclk)
3367 dispc->tv_pclk_rate = pclk;
3370 static unsigned long dispc_core_clk_rate(struct dispc_device *dispc)
3372 return dispc->core_clk_rate;
3375 static unsigned long dispc_plane_pclk_rate(struct dispc_device *dispc,
3376 enum omap_plane_id plane)
3378 enum omap_channel channel;
3380 if (plane == OMAP_DSS_WB)
3383 channel = dispc_ovl_get_channel_out(dispc, plane);
3385 return dispc_mgr_pclk_rate(dispc, channel);
3388 static unsigned long dispc_plane_lclk_rate(struct dispc_device *dispc,
3389 enum omap_plane_id plane)
3391 enum omap_channel channel;
3393 if (plane == OMAP_DSS_WB)
3396 channel = dispc_ovl_get_channel_out(dispc, plane);
3398 return dispc_mgr_lclk_rate(dispc, channel);
3401 static void dispc_dump_clocks_channel(struct dispc_device *dispc,
3403 enum omap_channel channel)
3406 enum dss_clk_source lcd_clk_src;
3408 seq_printf(s, "- %s -\n", mgr_desc[channel].name);
3410 lcd_clk_src = dss_get_lcd_clk_source(dispc->dss, channel);
3412 seq_printf(s, "%s clk source = %s\n", mgr_desc[channel].name,
3413 dss_get_clk_source_name(lcd_clk_src));
3415 dispc_mgr_get_lcd_divisor(dispc, channel, &lcd, &pcd);
3417 seq_printf(s, "lck\t\t%-16lulck div\t%u\n",
3418 dispc_mgr_lclk_rate(dispc, channel), lcd);
3419 seq_printf(s, "pck\t\t%-16lupck div\t%u\n",
3420 dispc_mgr_pclk_rate(dispc, channel), pcd);
3423 void dispc_dump_clocks(struct dispc_device *dispc, struct seq_file *s)
3425 enum dss_clk_source dispc_clk_src;
3429 if (dispc_runtime_get(dispc))
3432 seq_printf(s, "- DISPC -\n");
3434 dispc_clk_src = dss_get_dispc_clk_source(dispc->dss);
3435 seq_printf(s, "dispc fclk source = %s\n",
3436 dss_get_clk_source_name(dispc_clk_src));
3438 seq_printf(s, "fck\t\t%-16lu\n", dispc_fclk_rate(dispc));
3440 if (dispc_has_feature(dispc, FEAT_CORE_CLK_DIV)) {
3441 seq_printf(s, "- DISPC-CORE-CLK -\n");
3442 l = dispc_read_reg(dispc, DISPC_DIVISOR);
3443 lcd = FLD_GET(l, 23, 16);
3445 seq_printf(s, "lck\t\t%-16lulck div\t%u\n",
3446 (dispc_fclk_rate(dispc)/lcd), lcd);
3449 dispc_dump_clocks_channel(dispc, s, OMAP_DSS_CHANNEL_LCD);
3451 if (dispc_has_feature(dispc, FEAT_MGR_LCD2))
3452 dispc_dump_clocks_channel(dispc, s, OMAP_DSS_CHANNEL_LCD2);
3453 if (dispc_has_feature(dispc, FEAT_MGR_LCD3))
3454 dispc_dump_clocks_channel(dispc, s, OMAP_DSS_CHANNEL_LCD3);
3456 dispc_runtime_put(dispc);
3459 static int dispc_dump_regs(struct seq_file *s, void *p)
3461 struct dispc_device *dispc = s->private;
3463 const char *mgr_names[] = {
3464 [OMAP_DSS_CHANNEL_LCD] = "LCD",
3465 [OMAP_DSS_CHANNEL_DIGIT] = "TV",
3466 [OMAP_DSS_CHANNEL_LCD2] = "LCD2",
3467 [OMAP_DSS_CHANNEL_LCD3] = "LCD3",
3469 const char *ovl_names[] = {
3470 [OMAP_DSS_GFX] = "GFX",
3471 [OMAP_DSS_VIDEO1] = "VID1",
3472 [OMAP_DSS_VIDEO2] = "VID2",
3473 [OMAP_DSS_VIDEO3] = "VID3",
3474 [OMAP_DSS_WB] = "WB",
3476 const char **p_names;
3478 #define DUMPREG(dispc, r) \
3479 seq_printf(s, "%-50s %08x\n", #r, dispc_read_reg(dispc, r))
3481 if (dispc_runtime_get(dispc))
3484 /* DISPC common registers */
3485 DUMPREG(dispc, DISPC_REVISION);
3486 DUMPREG(dispc, DISPC_SYSCONFIG);
3487 DUMPREG(dispc, DISPC_SYSSTATUS);
3488 DUMPREG(dispc, DISPC_IRQSTATUS);
3489 DUMPREG(dispc, DISPC_IRQENABLE);
3490 DUMPREG(dispc, DISPC_CONTROL);
3491 DUMPREG(dispc, DISPC_CONFIG);
3492 DUMPREG(dispc, DISPC_CAPABLE);
3493 DUMPREG(dispc, DISPC_LINE_STATUS);
3494 DUMPREG(dispc, DISPC_LINE_NUMBER);
3495 if (dispc_has_feature(dispc, FEAT_ALPHA_FIXED_ZORDER) ||
3496 dispc_has_feature(dispc, FEAT_ALPHA_FREE_ZORDER))
3497 DUMPREG(dispc, DISPC_GLOBAL_ALPHA);
3498 if (dispc_has_feature(dispc, FEAT_MGR_LCD2)) {
3499 DUMPREG(dispc, DISPC_CONTROL2);
3500 DUMPREG(dispc, DISPC_CONFIG2);
3502 if (dispc_has_feature(dispc, FEAT_MGR_LCD3)) {
3503 DUMPREG(dispc, DISPC_CONTROL3);
3504 DUMPREG(dispc, DISPC_CONFIG3);
3506 if (dispc_has_feature(dispc, FEAT_MFLAG))
3507 DUMPREG(dispc, DISPC_GLOBAL_MFLAG_ATTRIBUTE);
3511 #define DISPC_REG(i, name) name(i)
3512 #define DUMPREG(dispc, i, r) seq_printf(s, "%s(%s)%*s %08x\n", #r, p_names[i], \
3513 (int)(48 - strlen(#r) - strlen(p_names[i])), " ", \
3514 dispc_read_reg(dispc, DISPC_REG(i, r)))
3516 p_names = mgr_names;
3518 /* DISPC channel specific registers */
3519 for (i = 0; i < dispc_get_num_mgrs(dispc); i++) {
3520 DUMPREG(dispc, i, DISPC_DEFAULT_COLOR);
3521 DUMPREG(dispc, i, DISPC_TRANS_COLOR);
3522 DUMPREG(dispc, i, DISPC_SIZE_MGR);
3524 if (i == OMAP_DSS_CHANNEL_DIGIT)
3527 DUMPREG(dispc, i, DISPC_TIMING_H);
3528 DUMPREG(dispc, i, DISPC_TIMING_V);
3529 DUMPREG(dispc, i, DISPC_POL_FREQ);
3530 DUMPREG(dispc, i, DISPC_DIVISORo);
3532 DUMPREG(dispc, i, DISPC_DATA_CYCLE1);
3533 DUMPREG(dispc, i, DISPC_DATA_CYCLE2);
3534 DUMPREG(dispc, i, DISPC_DATA_CYCLE3);
3536 if (dispc_has_feature(dispc, FEAT_CPR)) {
3537 DUMPREG(dispc, i, DISPC_CPR_COEF_R);
3538 DUMPREG(dispc, i, DISPC_CPR_COEF_G);
3539 DUMPREG(dispc, i, DISPC_CPR_COEF_B);
3543 p_names = ovl_names;
3545 for (i = 0; i < dispc_get_num_ovls(dispc); i++) {
3546 DUMPREG(dispc, i, DISPC_OVL_BA0);
3547 DUMPREG(dispc, i, DISPC_OVL_BA1);
3548 DUMPREG(dispc, i, DISPC_OVL_POSITION);
3549 DUMPREG(dispc, i, DISPC_OVL_SIZE);
3550 DUMPREG(dispc, i, DISPC_OVL_ATTRIBUTES);
3551 DUMPREG(dispc, i, DISPC_OVL_FIFO_THRESHOLD);
3552 DUMPREG(dispc, i, DISPC_OVL_FIFO_SIZE_STATUS);
3553 DUMPREG(dispc, i, DISPC_OVL_ROW_INC);
3554 DUMPREG(dispc, i, DISPC_OVL_PIXEL_INC);
3556 if (dispc_has_feature(dispc, FEAT_PRELOAD))
3557 DUMPREG(dispc, i, DISPC_OVL_PRELOAD);
3558 if (dispc_has_feature(dispc, FEAT_MFLAG))
3559 DUMPREG(dispc, i, DISPC_OVL_MFLAG_THRESHOLD);
3561 if (i == OMAP_DSS_GFX) {
3562 DUMPREG(dispc, i, DISPC_OVL_WINDOW_SKIP);
3563 DUMPREG(dispc, i, DISPC_OVL_TABLE_BA);
3567 DUMPREG(dispc, i, DISPC_OVL_FIR);
3568 DUMPREG(dispc, i, DISPC_OVL_PICTURE_SIZE);
3569 DUMPREG(dispc, i, DISPC_OVL_ACCU0);
3570 DUMPREG(dispc, i, DISPC_OVL_ACCU1);
3571 if (dispc_has_feature(dispc, FEAT_HANDLE_UV_SEPARATE)) {
3572 DUMPREG(dispc, i, DISPC_OVL_BA0_UV);
3573 DUMPREG(dispc, i, DISPC_OVL_BA1_UV);
3574 DUMPREG(dispc, i, DISPC_OVL_FIR2);
3575 DUMPREG(dispc, i, DISPC_OVL_ACCU2_0);
3576 DUMPREG(dispc, i, DISPC_OVL_ACCU2_1);
3578 if (dispc_has_feature(dispc, FEAT_ATTR2))
3579 DUMPREG(dispc, i, DISPC_OVL_ATTRIBUTES2);
3582 if (dispc->feat->has_writeback) {
3584 DUMPREG(dispc, i, DISPC_OVL_BA0);
3585 DUMPREG(dispc, i, DISPC_OVL_BA1);
3586 DUMPREG(dispc, i, DISPC_OVL_SIZE);
3587 DUMPREG(dispc, i, DISPC_OVL_ATTRIBUTES);
3588 DUMPREG(dispc, i, DISPC_OVL_FIFO_THRESHOLD);
3589 DUMPREG(dispc, i, DISPC_OVL_FIFO_SIZE_STATUS);
3590 DUMPREG(dispc, i, DISPC_OVL_ROW_INC);
3591 DUMPREG(dispc, i, DISPC_OVL_PIXEL_INC);
3593 if (dispc_has_feature(dispc, FEAT_MFLAG))
3594 DUMPREG(dispc, i, DISPC_OVL_MFLAG_THRESHOLD);
3596 DUMPREG(dispc, i, DISPC_OVL_FIR);
3597 DUMPREG(dispc, i, DISPC_OVL_PICTURE_SIZE);
3598 DUMPREG(dispc, i, DISPC_OVL_ACCU0);
3599 DUMPREG(dispc, i, DISPC_OVL_ACCU1);
3600 if (dispc_has_feature(dispc, FEAT_HANDLE_UV_SEPARATE)) {
3601 DUMPREG(dispc, i, DISPC_OVL_BA0_UV);
3602 DUMPREG(dispc, i, DISPC_OVL_BA1_UV);
3603 DUMPREG(dispc, i, DISPC_OVL_FIR2);
3604 DUMPREG(dispc, i, DISPC_OVL_ACCU2_0);
3605 DUMPREG(dispc, i, DISPC_OVL_ACCU2_1);
3607 if (dispc_has_feature(dispc, FEAT_ATTR2))
3608 DUMPREG(dispc, i, DISPC_OVL_ATTRIBUTES2);
3614 #define DISPC_REG(plane, name, i) name(plane, i)
3615 #define DUMPREG(dispc, plane, name, i) \
3616 seq_printf(s, "%s_%d(%s)%*s %08x\n", #name, i, p_names[plane], \
3617 (int)(46 - strlen(#name) - strlen(p_names[plane])), " ", \
3618 dispc_read_reg(dispc, DISPC_REG(plane, name, i)))
3620 /* Video pipeline coefficient registers */
3622 /* start from OMAP_DSS_VIDEO1 */
3623 for (i = 1; i < dispc_get_num_ovls(dispc); i++) {
3624 for (j = 0; j < 8; j++)
3625 DUMPREG(dispc, i, DISPC_OVL_FIR_COEF_H, j);
3627 for (j = 0; j < 8; j++)
3628 DUMPREG(dispc, i, DISPC_OVL_FIR_COEF_HV, j);
3630 for (j = 0; j < 5; j++)
3631 DUMPREG(dispc, i, DISPC_OVL_CONV_COEF, j);
3633 if (dispc_has_feature(dispc, FEAT_FIR_COEF_V)) {
3634 for (j = 0; j < 8; j++)
3635 DUMPREG(dispc, i, DISPC_OVL_FIR_COEF_V, j);
3638 if (dispc_has_feature(dispc, FEAT_HANDLE_UV_SEPARATE)) {
3639 for (j = 0; j < 8; j++)
3640 DUMPREG(dispc, i, DISPC_OVL_FIR_COEF_H2, j);
3642 for (j = 0; j < 8; j++)
3643 DUMPREG(dispc, i, DISPC_OVL_FIR_COEF_HV2, j);
3645 for (j = 0; j < 8; j++)
3646 DUMPREG(dispc, i, DISPC_OVL_FIR_COEF_V2, j);
3650 dispc_runtime_put(dispc);
3658 /* calculate clock rates using dividers in cinfo */
3659 int dispc_calc_clock_rates(struct dispc_device *dispc,
3660 unsigned long dispc_fclk_rate,
3661 struct dispc_clock_info *cinfo)
3663 if (cinfo->lck_div > 255 || cinfo->lck_div == 0)
3665 if (cinfo->pck_div < 1 || cinfo->pck_div > 255)
3668 cinfo->lck = dispc_fclk_rate / cinfo->lck_div;
3669 cinfo->pck = cinfo->lck / cinfo->pck_div;
3674 bool dispc_div_calc(struct dispc_device *dispc, unsigned long dispc_freq,
3675 unsigned long pck_min, unsigned long pck_max,
3676 dispc_div_calc_func func, void *data)
3678 int lckd, lckd_start, lckd_stop;
3679 int pckd, pckd_start, pckd_stop;
3680 unsigned long pck, lck;
3681 unsigned long lck_max;
3682 unsigned long pckd_hw_min, pckd_hw_max;
3683 unsigned int min_fck_per_pck;
3686 #ifdef CONFIG_OMAP2_DSS_MIN_FCK_PER_PCK
3687 min_fck_per_pck = CONFIG_OMAP2_DSS_MIN_FCK_PER_PCK;
3689 min_fck_per_pck = 0;
3692 pckd_hw_min = dispc->feat->min_pcd;
3695 lck_max = dss_get_max_fck_rate(dispc->dss);
3697 pck_min = pck_min ? pck_min : 1;
3698 pck_max = pck_max ? pck_max : ULONG_MAX;
3700 lckd_start = max(DIV_ROUND_UP(dispc_freq, lck_max), 1ul);
3701 lckd_stop = min(dispc_freq / pck_min, 255ul);
3703 for (lckd = lckd_start; lckd <= lckd_stop; ++lckd) {
3704 lck = dispc_freq / lckd;
3706 pckd_start = max(DIV_ROUND_UP(lck, pck_max), pckd_hw_min);
3707 pckd_stop = min(lck / pck_min, pckd_hw_max);
3709 for (pckd = pckd_start; pckd <= pckd_stop; ++pckd) {
3713 * For OMAP2/3 the DISPC fclk is the same as LCD's logic
3714 * clock, which means we're configuring DISPC fclk here
3715 * also. Thus we need to use the calculated lck. For
3716 * OMAP4+ the DISPC fclk is a separate clock.
3718 if (dispc_has_feature(dispc, FEAT_CORE_CLK_DIV))
3719 fck = dispc_core_clk_rate(dispc);
3723 if (fck < pck * min_fck_per_pck)
3726 if (func(lckd, pckd, lck, pck, data))
3734 void dispc_mgr_set_clock_div(struct dispc_device *dispc,
3735 enum omap_channel channel,
3736 const struct dispc_clock_info *cinfo)
3738 DSSDBG("lck = %lu (%u)\n", cinfo->lck, cinfo->lck_div);
3739 DSSDBG("pck = %lu (%u)\n", cinfo->pck, cinfo->pck_div);
3741 dispc_mgr_set_lcd_divisor(dispc, channel, cinfo->lck_div,
3745 int dispc_mgr_get_clock_div(struct dispc_device *dispc,
3746 enum omap_channel channel,
3747 struct dispc_clock_info *cinfo)
3751 fck = dispc_fclk_rate(dispc);
3753 cinfo->lck_div = REG_GET(dispc, DISPC_DIVISORo(channel), 23, 16);
3754 cinfo->pck_div = REG_GET(dispc, DISPC_DIVISORo(channel), 7, 0);
3756 cinfo->lck = fck / cinfo->lck_div;
3757 cinfo->pck = cinfo->lck / cinfo->pck_div;
3762 u32 dispc_read_irqstatus(struct dispc_device *dispc)
3764 return dispc_read_reg(dispc, DISPC_IRQSTATUS);
3767 void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask)
3769 dispc_write_reg(dispc, DISPC_IRQSTATUS, mask);
3772 void dispc_write_irqenable(struct dispc_device *dispc, u32 mask)
3774 u32 old_mask = dispc_read_reg(dispc, DISPC_IRQENABLE);
3776 /* clear the irqstatus for newly enabled irqs */
3777 dispc_clear_irqstatus(dispc, (mask ^ old_mask) & mask);
3779 dispc_write_reg(dispc, DISPC_IRQENABLE, mask);
3781 /* flush posted write */
3782 dispc_read_reg(dispc, DISPC_IRQENABLE);
3785 void dispc_enable_sidle(struct dispc_device *dispc)
3787 /* SIDLEMODE: smart idle */
3788 REG_FLD_MOD(dispc, DISPC_SYSCONFIG, 2, 4, 3);
3791 void dispc_disable_sidle(struct dispc_device *dispc)
3793 REG_FLD_MOD(dispc, DISPC_SYSCONFIG, 1, 4, 3); /* SIDLEMODE: no idle */
3796 u32 dispc_mgr_gamma_size(struct dispc_device *dispc,
3797 enum omap_channel channel)
3799 const struct dispc_gamma_desc *gdesc = &mgr_desc[channel].gamma;
3801 if (!dispc->feat->has_gamma_table)
3807 static void dispc_mgr_write_gamma_table(struct dispc_device *dispc,
3808 enum omap_channel channel)
3810 const struct dispc_gamma_desc *gdesc = &mgr_desc[channel].gamma;
3811 u32 *table = dispc->gamma_table[channel];
3814 DSSDBG("%s: channel %d\n", __func__, channel);
3816 for (i = 0; i < gdesc->len; ++i) {
3819 if (gdesc->has_index)
3824 dispc_write_reg(dispc, gdesc->reg, v);
3828 static void dispc_restore_gamma_tables(struct dispc_device *dispc)
3830 DSSDBG("%s()\n", __func__);
3832 if (!dispc->feat->has_gamma_table)
3835 dispc_mgr_write_gamma_table(dispc, OMAP_DSS_CHANNEL_LCD);
3837 dispc_mgr_write_gamma_table(dispc, OMAP_DSS_CHANNEL_DIGIT);
3839 if (dispc_has_feature(dispc, FEAT_MGR_LCD2))
3840 dispc_mgr_write_gamma_table(dispc, OMAP_DSS_CHANNEL_LCD2);
3842 if (dispc_has_feature(dispc, FEAT_MGR_LCD3))
3843 dispc_mgr_write_gamma_table(dispc, OMAP_DSS_CHANNEL_LCD3);
3846 static const struct drm_color_lut dispc_mgr_gamma_default_lut[] = {
3847 { .red = 0, .green = 0, .blue = 0, },
3848 { .red = U16_MAX, .green = U16_MAX, .blue = U16_MAX, },
3851 void dispc_mgr_set_gamma(struct dispc_device *dispc,
3852 enum omap_channel channel,
3853 const struct drm_color_lut *lut,
3854 unsigned int length)
3856 const struct dispc_gamma_desc *gdesc = &mgr_desc[channel].gamma;
3857 u32 *table = dispc->gamma_table[channel];
3860 DSSDBG("%s: channel %d, lut len %u, hw len %u\n", __func__,
3861 channel, length, gdesc->len);
3863 if (!dispc->feat->has_gamma_table)
3866 if (lut == NULL || length < 2) {
3867 lut = dispc_mgr_gamma_default_lut;
3868 length = ARRAY_SIZE(dispc_mgr_gamma_default_lut);
3871 for (i = 0; i < length - 1; ++i) {
3872 uint first = i * (gdesc->len - 1) / (length - 1);
3873 uint last = (i + 1) * (gdesc->len - 1) / (length - 1);
3874 uint w = last - first;
3881 for (j = 0; j <= w; j++) {
3882 r = (lut[i].red * (w - j) + lut[i+1].red * j) / w;
3883 g = (lut[i].green * (w - j) + lut[i+1].green * j) / w;
3884 b = (lut[i].blue * (w - j) + lut[i+1].blue * j) / w;
3886 r >>= 16 - gdesc->bits;
3887 g >>= 16 - gdesc->bits;
3888 b >>= 16 - gdesc->bits;
3890 table[first + j] = (r << (gdesc->bits * 2)) |
3891 (g << gdesc->bits) | b;
3895 if (dispc->is_enabled)
3896 dispc_mgr_write_gamma_table(dispc, channel);
3899 static int dispc_init_gamma_tables(struct dispc_device *dispc)
3903 if (!dispc->feat->has_gamma_table)
3906 for (channel = 0; channel < ARRAY_SIZE(dispc->gamma_table); channel++) {
3907 const struct dispc_gamma_desc *gdesc = &mgr_desc[channel].gamma;
3910 if (channel == OMAP_DSS_CHANNEL_LCD2 &&
3911 !dispc_has_feature(dispc, FEAT_MGR_LCD2))
3914 if (channel == OMAP_DSS_CHANNEL_LCD3 &&
3915 !dispc_has_feature(dispc, FEAT_MGR_LCD3))
3918 gt = devm_kmalloc_array(&dispc->pdev->dev, gdesc->len,
3919 sizeof(u32), GFP_KERNEL);
3923 dispc->gamma_table[channel] = gt;
3925 dispc_mgr_set_gamma(dispc, channel, NULL, 0);
3930 static void _omap_dispc_initial_config(struct dispc_device *dispc)
3934 /* Exclusively enable DISPC_CORE_CLK and set divider to 1 */
3935 if (dispc_has_feature(dispc, FEAT_CORE_CLK_DIV)) {
3936 l = dispc_read_reg(dispc, DISPC_DIVISOR);
3937 /* Use DISPC_DIVISOR.LCD, instead of DISPC_DIVISOR1.LCD */
3938 l = FLD_MOD(l, 1, 0, 0);
3939 l = FLD_MOD(l, 1, 23, 16);
3940 dispc_write_reg(dispc, DISPC_DIVISOR, l);
3942 dispc->core_clk_rate = dispc_fclk_rate(dispc);
3945 /* Use gamma table mode, instead of palette mode */
3946 if (dispc->feat->has_gamma_table)
3947 REG_FLD_MOD(dispc, DISPC_CONFIG, 1, 3, 3);
3949 /* For older DSS versions (FEAT_FUNCGATED) this enables
3950 * func-clock auto-gating. For newer versions
3951 * (dispc->feat->has_gamma_table) this enables tv-out gamma tables.
3953 if (dispc_has_feature(dispc, FEAT_FUNCGATED) ||
3954 dispc->feat->has_gamma_table)
3955 REG_FLD_MOD(dispc, DISPC_CONFIG, 1, 9, 9);
3957 dispc_set_loadmode(dispc, OMAP_DSS_LOAD_FRAME_ONLY);
3959 dispc_init_fifos(dispc);
3961 dispc_configure_burst_sizes(dispc);
3963 dispc_ovl_enable_zorder_planes(dispc);
3965 if (dispc->feat->mstandby_workaround)
3966 REG_FLD_MOD(dispc, DISPC_MSTANDBY_CTRL, 1, 0, 0);
3968 if (dispc_has_feature(dispc, FEAT_MFLAG))
3969 dispc_init_mflag(dispc);
3972 static const enum dispc_feature_id omap2_dispc_features_list[] = {
3974 FEAT_LCDENABLESIGNAL,
3977 FEAT_ROWREPEATENABLE,
3981 static const enum dispc_feature_id omap3_dispc_features_list[] = {
3983 FEAT_LCDENABLESIGNAL,
3986 FEAT_LINEBUFFERSPLIT,
3987 FEAT_ROWREPEATENABLE,
3992 FEAT_ALPHA_FIXED_ZORDER,
3994 FEAT_OMAP3_DSI_FIFO_BUG,
3997 static const enum dispc_feature_id am43xx_dispc_features_list[] = {
3999 FEAT_LCDENABLESIGNAL,
4002 FEAT_LINEBUFFERSPLIT,
4003 FEAT_ROWREPEATENABLE,
4008 FEAT_ALPHA_FIXED_ZORDER,
4012 static const enum dispc_feature_id omap4_dispc_features_list[] = {
4015 FEAT_HANDLE_UV_SEPARATE,
4020 FEAT_ALPHA_FREE_ZORDER,
4025 static const enum dispc_feature_id omap5_dispc_features_list[] = {
4029 FEAT_HANDLE_UV_SEPARATE,
4034 FEAT_ALPHA_FREE_ZORDER,
4040 static const struct dss_reg_field omap2_dispc_reg_fields[] = {
4041 [FEAT_REG_FIRHINC] = { 11, 0 },
4042 [FEAT_REG_FIRVINC] = { 27, 16 },
4043 [FEAT_REG_FIFOLOWTHRESHOLD] = { 8, 0 },
4044 [FEAT_REG_FIFOHIGHTHRESHOLD] = { 24, 16 },
4045 [FEAT_REG_FIFOSIZE] = { 8, 0 },
4046 [FEAT_REG_HORIZONTALACCU] = { 9, 0 },
4047 [FEAT_REG_VERTICALACCU] = { 25, 16 },
4050 static const struct dss_reg_field omap3_dispc_reg_fields[] = {
4051 [FEAT_REG_FIRHINC] = { 12, 0 },
4052 [FEAT_REG_FIRVINC] = { 28, 16 },
4053 [FEAT_REG_FIFOLOWTHRESHOLD] = { 11, 0 },
4054 [FEAT_REG_FIFOHIGHTHRESHOLD] = { 27, 16 },
4055 [FEAT_REG_FIFOSIZE] = { 10, 0 },
4056 [FEAT_REG_HORIZONTALACCU] = { 9, 0 },
4057 [FEAT_REG_VERTICALACCU] = { 25, 16 },
4060 static const struct dss_reg_field omap4_dispc_reg_fields[] = {
4061 [FEAT_REG_FIRHINC] = { 12, 0 },
4062 [FEAT_REG_FIRVINC] = { 28, 16 },
4063 [FEAT_REG_FIFOLOWTHRESHOLD] = { 15, 0 },
4064 [FEAT_REG_FIFOHIGHTHRESHOLD] = { 31, 16 },
4065 [FEAT_REG_FIFOSIZE] = { 15, 0 },
4066 [FEAT_REG_HORIZONTALACCU] = { 10, 0 },
4067 [FEAT_REG_VERTICALACCU] = { 26, 16 },
4070 static const enum omap_overlay_caps omap2_dispc_overlay_caps[] = {
4072 OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
4074 /* OMAP_DSS_VIDEO1 */
4075 OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
4076 OMAP_DSS_OVL_CAP_REPLICATION,
4078 /* OMAP_DSS_VIDEO2 */
4079 OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
4080 OMAP_DSS_OVL_CAP_REPLICATION,
4083 static const enum omap_overlay_caps omap3430_dispc_overlay_caps[] = {
4085 OMAP_DSS_OVL_CAP_GLOBAL_ALPHA | OMAP_DSS_OVL_CAP_POS |
4086 OMAP_DSS_OVL_CAP_REPLICATION,
4088 /* OMAP_DSS_VIDEO1 */
4089 OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
4090 OMAP_DSS_OVL_CAP_REPLICATION,
4092 /* OMAP_DSS_VIDEO2 */
4093 OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
4094 OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
4097 static const enum omap_overlay_caps omap3630_dispc_overlay_caps[] = {
4099 OMAP_DSS_OVL_CAP_GLOBAL_ALPHA | OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA |
4100 OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
4102 /* OMAP_DSS_VIDEO1 */
4103 OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_POS |
4104 OMAP_DSS_OVL_CAP_REPLICATION,
4106 /* OMAP_DSS_VIDEO2 */
4107 OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
4108 OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_POS |
4109 OMAP_DSS_OVL_CAP_REPLICATION,
4112 static const enum omap_overlay_caps omap4_dispc_overlay_caps[] = {
4114 OMAP_DSS_OVL_CAP_GLOBAL_ALPHA | OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA |
4115 OMAP_DSS_OVL_CAP_ZORDER | OMAP_DSS_OVL_CAP_POS |
4116 OMAP_DSS_OVL_CAP_REPLICATION,
4118 /* OMAP_DSS_VIDEO1 */
4119 OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
4120 OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_ZORDER |
4121 OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
4123 /* OMAP_DSS_VIDEO2 */
4124 OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
4125 OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_ZORDER |
4126 OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
4128 /* OMAP_DSS_VIDEO3 */
4129 OMAP_DSS_OVL_CAP_SCALE | OMAP_DSS_OVL_CAP_GLOBAL_ALPHA |
4130 OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA | OMAP_DSS_OVL_CAP_ZORDER |
4131 OMAP_DSS_OVL_CAP_POS | OMAP_DSS_OVL_CAP_REPLICATION,
4134 #define COLOR_ARRAY(arr...) (const u32[]) { arr, 0 }
4136 static const u32 *omap2_dispc_supported_color_modes[] = {
4140 DRM_FORMAT_RGBX4444, DRM_FORMAT_RGB565,
4141 DRM_FORMAT_XRGB8888, DRM_FORMAT_RGB888),
4143 /* OMAP_DSS_VIDEO1 */
4145 DRM_FORMAT_RGB565, DRM_FORMAT_XRGB8888,
4146 DRM_FORMAT_RGB888, DRM_FORMAT_YUYV,
4149 /* OMAP_DSS_VIDEO2 */
4151 DRM_FORMAT_RGB565, DRM_FORMAT_XRGB8888,
4152 DRM_FORMAT_RGB888, DRM_FORMAT_YUYV,
4156 static const u32 *omap3_dispc_supported_color_modes[] = {
4159 DRM_FORMAT_RGBX4444, DRM_FORMAT_ARGB4444,
4160 DRM_FORMAT_RGB565, DRM_FORMAT_XRGB8888,
4161 DRM_FORMAT_RGB888, DRM_FORMAT_ARGB8888,
4162 DRM_FORMAT_RGBA8888, DRM_FORMAT_RGBX8888),
4164 /* OMAP_DSS_VIDEO1 */
4166 DRM_FORMAT_XRGB8888, DRM_FORMAT_RGB888,
4167 DRM_FORMAT_RGBX4444, DRM_FORMAT_RGB565,
4168 DRM_FORMAT_YUYV, DRM_FORMAT_UYVY),
4170 /* OMAP_DSS_VIDEO2 */
4172 DRM_FORMAT_RGBX4444, DRM_FORMAT_ARGB4444,
4173 DRM_FORMAT_RGB565, DRM_FORMAT_XRGB8888,
4174 DRM_FORMAT_RGB888, DRM_FORMAT_YUYV,
4175 DRM_FORMAT_UYVY, DRM_FORMAT_ARGB8888,
4176 DRM_FORMAT_RGBA8888, DRM_FORMAT_RGBX8888),
4179 static const u32 *omap4_dispc_supported_color_modes[] = {
4182 DRM_FORMAT_RGBX4444, DRM_FORMAT_ARGB4444,
4183 DRM_FORMAT_RGB565, DRM_FORMAT_XRGB8888,
4184 DRM_FORMAT_RGB888, DRM_FORMAT_ARGB8888,
4185 DRM_FORMAT_RGBA8888, DRM_FORMAT_RGBX8888,
4186 DRM_FORMAT_ARGB1555, DRM_FORMAT_XRGB4444,
4187 DRM_FORMAT_RGBA4444, DRM_FORMAT_XRGB1555),
4189 /* OMAP_DSS_VIDEO1 */
4191 DRM_FORMAT_RGB565, DRM_FORMAT_RGBX4444,
4192 DRM_FORMAT_YUYV, DRM_FORMAT_ARGB1555,
4193 DRM_FORMAT_RGBA8888, DRM_FORMAT_NV12,
4194 DRM_FORMAT_RGBA4444, DRM_FORMAT_XRGB8888,
4195 DRM_FORMAT_RGB888, DRM_FORMAT_UYVY,
4196 DRM_FORMAT_ARGB4444, DRM_FORMAT_XRGB1555,
4197 DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB4444,
4198 DRM_FORMAT_RGBX8888),
4200 /* OMAP_DSS_VIDEO2 */
4202 DRM_FORMAT_RGB565, DRM_FORMAT_RGBX4444,
4203 DRM_FORMAT_YUYV, DRM_FORMAT_ARGB1555,
4204 DRM_FORMAT_RGBA8888, DRM_FORMAT_NV12,
4205 DRM_FORMAT_RGBA4444, DRM_FORMAT_XRGB8888,
4206 DRM_FORMAT_RGB888, DRM_FORMAT_UYVY,
4207 DRM_FORMAT_ARGB4444, DRM_FORMAT_XRGB1555,
4208 DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB4444,
4209 DRM_FORMAT_RGBX8888),
4211 /* OMAP_DSS_VIDEO3 */
4213 DRM_FORMAT_RGB565, DRM_FORMAT_RGBX4444,
4214 DRM_FORMAT_YUYV, DRM_FORMAT_ARGB1555,
4215 DRM_FORMAT_RGBA8888, DRM_FORMAT_NV12,
4216 DRM_FORMAT_RGBA4444, DRM_FORMAT_XRGB8888,
4217 DRM_FORMAT_RGB888, DRM_FORMAT_UYVY,
4218 DRM_FORMAT_ARGB4444, DRM_FORMAT_XRGB1555,
4219 DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB4444,
4220 DRM_FORMAT_RGBX8888),
4224 DRM_FORMAT_RGB565, DRM_FORMAT_RGBX4444,
4225 DRM_FORMAT_YUYV, DRM_FORMAT_ARGB1555,
4226 DRM_FORMAT_RGBA8888, DRM_FORMAT_NV12,
4227 DRM_FORMAT_RGBA4444, DRM_FORMAT_XRGB8888,
4228 DRM_FORMAT_RGB888, DRM_FORMAT_UYVY,
4229 DRM_FORMAT_ARGB4444, DRM_FORMAT_XRGB1555,
4230 DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB4444,
4231 DRM_FORMAT_RGBX8888),
4234 static const u32 omap3_dispc_supported_scaler_color_modes[] = {
4235 DRM_FORMAT_XRGB8888, DRM_FORMAT_RGB565, DRM_FORMAT_YUYV,
4240 static const struct dispc_features omap24xx_dispc_feats = {
4247 .mgr_width_start = 10,
4248 .mgr_height_start = 26,
4249 .mgr_width_max = 2048,
4250 .mgr_height_max = 2048,
4251 .ovl_width_max = 2048,
4252 .ovl_height_max = 2048,
4253 .max_lcd_pclk = 66500000,
4256 * Assume the line width buffer to be 768 pixels as OMAP2 DISPC scaler
4257 * cannot scale an image width larger than 768.
4259 .max_line_width = 768,
4261 .calc_scaling = dispc_ovl_calc_scaling_24xx,
4262 .calc_core_clk = calc_core_clk_24xx,
4264 .features = omap2_dispc_features_list,
4265 .num_features = ARRAY_SIZE(omap2_dispc_features_list),
4266 .reg_fields = omap2_dispc_reg_fields,
4267 .num_reg_fields = ARRAY_SIZE(omap2_dispc_reg_fields),
4268 .overlay_caps = omap2_dispc_overlay_caps,
4269 .supported_color_modes = omap2_dispc_supported_color_modes,
4270 .supported_scaler_color_modes = COLOR_ARRAY(DRM_FORMAT_XRGB8888),
4273 .buffer_size_unit = 1,
4274 .burst_size_unit = 8,
4275 .no_framedone_tv = true,
4276 .set_max_preload = false,
4277 .last_pixel_inc_missing = true,
4280 static const struct dispc_features omap34xx_rev1_0_dispc_feats = {
4287 .mgr_width_start = 10,
4288 .mgr_height_start = 26,
4289 .mgr_width_max = 2048,
4290 .mgr_height_max = 2048,
4291 .ovl_width_max = 2048,
4292 .ovl_height_max = 2048,
4293 .max_lcd_pclk = 173000000,
4294 .max_tv_pclk = 59000000,
4296 .max_line_width = 1024,
4298 .calc_scaling = dispc_ovl_calc_scaling_34xx,
4299 .calc_core_clk = calc_core_clk_34xx,
4301 .features = omap3_dispc_features_list,
4302 .num_features = ARRAY_SIZE(omap3_dispc_features_list),
4303 .reg_fields = omap3_dispc_reg_fields,
4304 .num_reg_fields = ARRAY_SIZE(omap3_dispc_reg_fields),
4305 .overlay_caps = omap3430_dispc_overlay_caps,
4306 .supported_color_modes = omap3_dispc_supported_color_modes,
4307 .supported_scaler_color_modes = omap3_dispc_supported_scaler_color_modes,
4310 .buffer_size_unit = 1,
4311 .burst_size_unit = 8,
4312 .no_framedone_tv = true,
4313 .set_max_preload = false,
4314 .last_pixel_inc_missing = true,
4317 static const struct dispc_features omap34xx_rev3_0_dispc_feats = {
4324 .mgr_width_start = 10,
4325 .mgr_height_start = 26,
4326 .mgr_width_max = 2048,
4327 .mgr_height_max = 2048,
4328 .ovl_width_max = 2048,
4329 .ovl_height_max = 2048,
4330 .max_lcd_pclk = 173000000,
4331 .max_tv_pclk = 59000000,
4333 .max_line_width = 1024,
4335 .calc_scaling = dispc_ovl_calc_scaling_34xx,
4336 .calc_core_clk = calc_core_clk_34xx,
4338 .features = omap3_dispc_features_list,
4339 .num_features = ARRAY_SIZE(omap3_dispc_features_list),
4340 .reg_fields = omap3_dispc_reg_fields,
4341 .num_reg_fields = ARRAY_SIZE(omap3_dispc_reg_fields),
4342 .overlay_caps = omap3430_dispc_overlay_caps,
4343 .supported_color_modes = omap3_dispc_supported_color_modes,
4344 .supported_scaler_color_modes = omap3_dispc_supported_scaler_color_modes,
4347 .buffer_size_unit = 1,
4348 .burst_size_unit = 8,
4349 .no_framedone_tv = true,
4350 .set_max_preload = false,
4351 .last_pixel_inc_missing = true,
4354 static const struct dispc_features omap36xx_dispc_feats = {
4361 .mgr_width_start = 10,
4362 .mgr_height_start = 26,
4363 .mgr_width_max = 2048,
4364 .mgr_height_max = 2048,
4365 .ovl_width_max = 2048,
4366 .ovl_height_max = 2048,
4367 .max_lcd_pclk = 173000000,
4368 .max_tv_pclk = 59000000,
4370 .max_line_width = 1024,
4372 .calc_scaling = dispc_ovl_calc_scaling_34xx,
4373 .calc_core_clk = calc_core_clk_34xx,
4375 .features = omap3_dispc_features_list,
4376 .num_features = ARRAY_SIZE(omap3_dispc_features_list),
4377 .reg_fields = omap3_dispc_reg_fields,
4378 .num_reg_fields = ARRAY_SIZE(omap3_dispc_reg_fields),
4379 .overlay_caps = omap3630_dispc_overlay_caps,
4380 .supported_color_modes = omap3_dispc_supported_color_modes,
4381 .supported_scaler_color_modes = omap3_dispc_supported_scaler_color_modes,
4384 .buffer_size_unit = 1,
4385 .burst_size_unit = 8,
4386 .no_framedone_tv = true,
4387 .set_max_preload = false,
4388 .last_pixel_inc_missing = true,
4391 static const struct dispc_features am43xx_dispc_feats = {
4398 .mgr_width_start = 10,
4399 .mgr_height_start = 26,
4400 .mgr_width_max = 2048,
4401 .mgr_height_max = 2048,
4402 .ovl_width_max = 2048,
4403 .ovl_height_max = 2048,
4404 .max_lcd_pclk = 173000000,
4405 .max_tv_pclk = 59000000,
4407 .max_line_width = 1024,
4409 .calc_scaling = dispc_ovl_calc_scaling_34xx,
4410 .calc_core_clk = calc_core_clk_34xx,
4412 .features = am43xx_dispc_features_list,
4413 .num_features = ARRAY_SIZE(am43xx_dispc_features_list),
4414 .reg_fields = omap3_dispc_reg_fields,
4415 .num_reg_fields = ARRAY_SIZE(omap3_dispc_reg_fields),
4416 .overlay_caps = omap3430_dispc_overlay_caps,
4417 .supported_color_modes = omap3_dispc_supported_color_modes,
4418 .supported_scaler_color_modes = omap3_dispc_supported_scaler_color_modes,
4421 .buffer_size_unit = 1,
4422 .burst_size_unit = 8,
4423 .no_framedone_tv = true,
4424 .set_max_preload = false,
4425 .last_pixel_inc_missing = true,
4428 static const struct dispc_features omap44xx_dispc_feats = {
4435 .mgr_width_start = 10,
4436 .mgr_height_start = 26,
4437 .mgr_width_max = 2048,
4438 .mgr_height_max = 2048,
4439 .ovl_width_max = 2048,
4440 .ovl_height_max = 2048,
4441 .max_lcd_pclk = 170000000,
4442 .max_tv_pclk = 185625000,
4444 .max_line_width = 2048,
4446 .calc_scaling = dispc_ovl_calc_scaling_44xx,
4447 .calc_core_clk = calc_core_clk_44xx,
4449 .features = omap4_dispc_features_list,
4450 .num_features = ARRAY_SIZE(omap4_dispc_features_list),
4451 .reg_fields = omap4_dispc_reg_fields,
4452 .num_reg_fields = ARRAY_SIZE(omap4_dispc_reg_fields),
4453 .overlay_caps = omap4_dispc_overlay_caps,
4454 .supported_color_modes = omap4_dispc_supported_color_modes,
4457 .buffer_size_unit = 16,
4458 .burst_size_unit = 16,
4459 .gfx_fifo_workaround = true,
4460 .set_max_preload = true,
4461 .supports_sync_align = true,
4462 .has_writeback = true,
4463 .supports_double_pixel = true,
4464 .reverse_ilace_field_order = true,
4465 .has_gamma_table = true,
4466 .has_gamma_i734_bug = true,
4469 static const struct dispc_features omap54xx_dispc_feats = {
4476 .mgr_width_start = 11,
4477 .mgr_height_start = 27,
4478 .mgr_width_max = 4096,
4479 .mgr_height_max = 4096,
4480 .ovl_width_max = 2048,
4481 .ovl_height_max = 4096,
4482 .max_lcd_pclk = 170000000,
4483 .max_tv_pclk = 192000000,
4485 .max_line_width = 2048,
4487 .calc_scaling = dispc_ovl_calc_scaling_44xx,
4488 .calc_core_clk = calc_core_clk_44xx,
4490 .features = omap5_dispc_features_list,
4491 .num_features = ARRAY_SIZE(omap5_dispc_features_list),
4492 .reg_fields = omap4_dispc_reg_fields,
4493 .num_reg_fields = ARRAY_SIZE(omap4_dispc_reg_fields),
4494 .overlay_caps = omap4_dispc_overlay_caps,
4495 .supported_color_modes = omap4_dispc_supported_color_modes,
4498 .buffer_size_unit = 16,
4499 .burst_size_unit = 16,
4500 .gfx_fifo_workaround = true,
4501 .mstandby_workaround = true,
4502 .set_max_preload = true,
4503 .supports_sync_align = true,
4504 .has_writeback = true,
4505 .supports_double_pixel = true,
4506 .reverse_ilace_field_order = true,
4507 .has_gamma_table = true,
4508 .has_gamma_i734_bug = true,
4511 static irqreturn_t dispc_irq_handler(int irq, void *arg)
4513 struct dispc_device *dispc = arg;
4515 if (!dispc->is_enabled)
4518 return dispc->user_handler(irq, dispc->user_data);
4521 int dispc_request_irq(struct dispc_device *dispc, irq_handler_t handler,
4526 if (dispc->user_handler != NULL)
4529 dispc->user_handler = handler;
4530 dispc->user_data = dev_id;
4532 /* ensure the dispc_irq_handler sees the values above */
4535 r = devm_request_irq(&dispc->pdev->dev, dispc->irq, dispc_irq_handler,
4536 IRQF_SHARED, "OMAP DISPC", dispc);
4538 dispc->user_handler = NULL;
4539 dispc->user_data = NULL;
4545 void dispc_free_irq(struct dispc_device *dispc, void *dev_id)
4547 devm_free_irq(&dispc->pdev->dev, dispc->irq, dispc);
4549 dispc->user_handler = NULL;
4550 dispc->user_data = NULL;
4553 u32 dispc_get_memory_bandwidth_limit(struct dispc_device *dispc)
4557 /* Optional maximum memory bandwidth */
4558 of_property_read_u32(dispc->pdev->dev.of_node, "max-memory-bandwidth",
4565 * Workaround for errata i734 in DSS dispc
4566 * - LCD1 Gamma Correction Is Not Working When GFX Pipe Is Disabled
4568 * For gamma tables to work on LCD1 the GFX plane has to be used at
4569 * least once after DSS HW has come out of reset. The workaround
4570 * sets up a minimal LCD setup with GFX plane and waits for one
4571 * vertical sync irq before disabling the setup and continuing with
4572 * the context restore. The physical outputs are gated during the
4573 * operation. This workaround requires that gamma table's LOADMODE
4574 * is set to 0x2 in DISPC_CONTROL1 register.
4577 * OMAP543x Multimedia Device Silicon Revision 2.0 Silicon Errata
4578 * Literature Number: SWPZ037E
4579 * Or some other relevant errata document for the DSS IP version.
4582 static const struct dispc_errata_i734_data {
4583 struct videomode vm;
4584 struct omap_overlay_info ovli;
4585 struct omap_overlay_manager_info mgri;
4586 struct dss_lcd_mgr_config lcd_conf;
4589 .hactive = 8, .vactive = 1,
4590 .pixelclock = 16000000,
4591 .hsync_len = 8, .hfront_porch = 4, .hback_porch = 4,
4592 .vsync_len = 1, .vfront_porch = 1, .vback_porch = 1,
4594 .flags = DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW |
4595 DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_SYNC_POSEDGE |
4596 DISPLAY_FLAGS_PIXDATA_POSEDGE,
4600 .width = 1, .height = 1,
4601 .fourcc = DRM_FORMAT_XRGB8888,
4602 .rotation = DRM_MODE_ROTATE_0,
4603 .rotation_type = OMAP_DSS_ROT_NONE,
4604 .pos_x = 0, .pos_y = 0,
4605 .out_width = 0, .out_height = 0,
4606 .global_alpha = 0xff,
4607 .pre_mult_alpha = 0,
4612 .trans_enabled = false,
4613 .partial_alpha_enabled = false,
4614 .cpr_enable = false,
4617 .io_pad_mode = DSS_IO_PAD_MODE_BYPASS,
4619 .fifohandcheck = false,
4624 .video_port_width = 24,
4625 .lcden_sig_polarity = 0,
4629 static struct i734_buf {
4635 static int dispc_errata_i734_wa_init(struct dispc_device *dispc)
4637 if (!dispc->feat->has_gamma_i734_bug)
4640 i734_buf.size = i734.ovli.width * i734.ovli.height *
4641 color_mode_to_bpp(i734.ovli.fourcc) / 8;
4643 i734_buf.vaddr = dma_alloc_wc(&dispc->pdev->dev, i734_buf.size,
4644 &i734_buf.paddr, GFP_KERNEL);
4645 if (!i734_buf.vaddr) {
4646 dev_err(&dispc->pdev->dev, "%s: dma_alloc_wc failed\n",
4654 static void dispc_errata_i734_wa_fini(struct dispc_device *dispc)
4656 if (!dispc->feat->has_gamma_i734_bug)
4659 dma_free_wc(&dispc->pdev->dev, i734_buf.size, i734_buf.vaddr,
4663 static void dispc_errata_i734_wa(struct dispc_device *dispc)
4665 u32 framedone_irq = dispc_mgr_get_framedone_irq(dispc,
4666 OMAP_DSS_CHANNEL_LCD);
4667 struct omap_overlay_info ovli;
4668 struct dss_lcd_mgr_config lcd_conf;
4672 if (!dispc->feat->has_gamma_i734_bug)
4675 gatestate = REG_GET(dispc, DISPC_CONFIG, 8, 4);
4678 ovli.paddr = i734_buf.paddr;
4679 lcd_conf = i734.lcd_conf;
4681 /* Gate all LCD1 outputs */
4682 REG_FLD_MOD(dispc, DISPC_CONFIG, 0x1f, 8, 4);
4684 /* Setup and enable GFX plane */
4685 dispc_ovl_setup(dispc, OMAP_DSS_GFX, &ovli, &i734.vm, false,
4686 OMAP_DSS_CHANNEL_LCD);
4687 dispc_ovl_enable(dispc, OMAP_DSS_GFX, true);
4689 /* Set up and enable display manager for LCD1 */
4690 dispc_mgr_setup(dispc, OMAP_DSS_CHANNEL_LCD, &i734.mgri);
4691 dispc_calc_clock_rates(dispc, dss_get_dispc_clk_rate(dispc->dss),
4692 &lcd_conf.clock_info);
4693 dispc_mgr_set_lcd_config(dispc, OMAP_DSS_CHANNEL_LCD, &lcd_conf);
4694 dispc_mgr_set_timings(dispc, OMAP_DSS_CHANNEL_LCD, &i734.vm);
4696 dispc_clear_irqstatus(dispc, framedone_irq);
4698 /* Enable and shut the channel to produce just one frame */
4699 dispc_mgr_enable(dispc, OMAP_DSS_CHANNEL_LCD, true);
4700 dispc_mgr_enable(dispc, OMAP_DSS_CHANNEL_LCD, false);
4702 /* Busy wait for framedone. We can't fiddle with irq handlers
4703 * in PM resume. Typically the loop runs less than 5 times and
4704 * waits less than a micro second.
4707 while (!(dispc_read_irqstatus(dispc) & framedone_irq)) {
4708 if (count++ > 10000) {
4709 dev_err(&dispc->pdev->dev, "%s: framedone timeout\n",
4714 dispc_ovl_enable(dispc, OMAP_DSS_GFX, false);
4716 /* Clear all irq bits before continuing */
4717 dispc_clear_irqstatus(dispc, 0xffffffff);
4719 /* Restore the original state to LCD1 output gates */
4720 REG_FLD_MOD(dispc, DISPC_CONFIG, gatestate, 8, 4);
4723 /* DISPC HW IP initialisation */
4724 static const struct of_device_id dispc_of_match[] = {
4725 { .compatible = "ti,omap2-dispc", .data = &omap24xx_dispc_feats },
4726 { .compatible = "ti,omap3-dispc", .data = &omap36xx_dispc_feats },
4727 { .compatible = "ti,omap4-dispc", .data = &omap44xx_dispc_feats },
4728 { .compatible = "ti,omap5-dispc", .data = &omap54xx_dispc_feats },
4729 { .compatible = "ti,dra7-dispc", .data = &omap54xx_dispc_feats },
4733 static const struct soc_device_attribute dispc_soc_devices[] = {
4734 { .machine = "OMAP3[45]*",
4735 .revision = "ES[12].?", .data = &omap34xx_rev1_0_dispc_feats },
4736 { .machine = "OMAP3[45]*", .data = &omap34xx_rev3_0_dispc_feats },
4737 { .machine = "AM35*", .data = &omap34xx_rev3_0_dispc_feats },
4738 { .machine = "AM43*", .data = &am43xx_dispc_feats },
4742 static int dispc_bind(struct device *dev, struct device *master, void *data)
4744 struct platform_device *pdev = to_platform_device(dev);
4745 const struct soc_device_attribute *soc;
4746 struct dss_device *dss = dss_get_device(master);
4747 struct dispc_device *dispc;
4750 struct device_node *np = pdev->dev.of_node;
4752 dispc = kzalloc(sizeof(*dispc), GFP_KERNEL);
4757 platform_set_drvdata(pdev, dispc);
4761 * The OMAP3-based models can't be told apart using the compatible
4762 * string, use SoC device matching.
4764 soc = soc_device_match(dispc_soc_devices);
4766 dispc->feat = soc->data;
4768 dispc->feat = device_get_match_data(&pdev->dev);
4770 r = dispc_errata_i734_wa_init(dispc);
4774 dispc->base = devm_platform_ioremap_resource(pdev, 0);
4775 if (IS_ERR(dispc->base)) {
4776 r = PTR_ERR(dispc->base);
4780 dispc->irq = platform_get_irq(dispc->pdev, 0);
4781 if (dispc->irq < 0) {
4782 DSSERR("platform_get_irq failed\n");
4787 if (np && of_property_read_bool(np, "syscon-pol")) {
4788 dispc->syscon_pol = syscon_regmap_lookup_by_phandle(np, "syscon-pol");
4789 if (IS_ERR(dispc->syscon_pol)) {
4790 dev_err(&pdev->dev, "failed to get syscon-pol regmap\n");
4791 r = PTR_ERR(dispc->syscon_pol);
4795 if (of_property_read_u32_index(np, "syscon-pol", 1,
4796 &dispc->syscon_pol_offset)) {
4797 dev_err(&pdev->dev, "failed to get syscon-pol offset\n");
4803 r = dispc_init_gamma_tables(dispc);
4807 pm_runtime_enable(&pdev->dev);
4809 r = dispc_runtime_get(dispc);
4811 goto err_runtime_get;
4813 _omap_dispc_initial_config(dispc);
4815 rev = dispc_read_reg(dispc, DISPC_REVISION);
4816 dev_dbg(&pdev->dev, "OMAP DISPC rev %d.%d\n",
4817 FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
4819 dispc_runtime_put(dispc);
4823 dispc->debugfs = dss_debugfs_create_file(dss, "dispc", dispc_dump_regs,
4829 pm_runtime_disable(&pdev->dev);
4835 static void dispc_unbind(struct device *dev, struct device *master, void *data)
4837 struct dispc_device *dispc = dev_get_drvdata(dev);
4838 struct dss_device *dss = dispc->dss;
4840 dss_debugfs_remove_file(dispc->debugfs);
4844 pm_runtime_disable(dev);
4846 dispc_errata_i734_wa_fini(dispc);
4851 static const struct component_ops dispc_component_ops = {
4853 .unbind = dispc_unbind,
4856 static int dispc_probe(struct platform_device *pdev)
4858 return component_add(&pdev->dev, &dispc_component_ops);
4861 static void dispc_remove(struct platform_device *pdev)
4863 component_del(&pdev->dev, &dispc_component_ops);
4866 static __maybe_unused int dispc_runtime_suspend(struct device *dev)
4868 struct dispc_device *dispc = dev_get_drvdata(dev);
4870 dispc->is_enabled = false;
4871 /* ensure the dispc_irq_handler sees the is_enabled value */
4873 /* wait for current handler to finish before turning the DISPC off */
4874 synchronize_irq(dispc->irq);
4876 dispc_save_context(dispc);
4881 static __maybe_unused int dispc_runtime_resume(struct device *dev)
4883 struct dispc_device *dispc = dev_get_drvdata(dev);
4886 * The reset value for load mode is 0 (OMAP_DSS_LOAD_CLUT_AND_FRAME)
4887 * but we always initialize it to 2 (OMAP_DSS_LOAD_FRAME_ONLY) in
4888 * _omap_dispc_initial_config(). We can thus use it to detect if
4889 * we have lost register context.
4891 if (REG_GET(dispc, DISPC_CONFIG, 2, 1) != OMAP_DSS_LOAD_FRAME_ONLY) {
4892 _omap_dispc_initial_config(dispc);
4894 dispc_errata_i734_wa(dispc);
4896 dispc_restore_context(dispc);
4898 dispc_restore_gamma_tables(dispc);
4901 dispc->is_enabled = true;
4902 /* ensure the dispc_irq_handler sees the is_enabled value */
4908 static const struct dev_pm_ops dispc_pm_ops = {
4909 SET_RUNTIME_PM_OPS(dispc_runtime_suspend, dispc_runtime_resume, NULL)
4910 SET_LATE_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
4913 struct platform_driver omap_dispchw_driver = {
4914 .probe = dispc_probe,
4915 .remove_new = dispc_remove,
4917 .name = "omapdss_dispc",
4918 .pm = &dispc_pm_ops,
4919 .of_match_table = dispc_of_match,
4920 .suppress_bind_attrs = true,