coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ddp.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <device/mmio.h>
5 #include <edid.h>
6 #include <soc/addressmap.h>
7 #include <soc/ddp.h>
8 
9 #define MERGE_MODE 6
10 #define MERGE_SWAP 0
11 
13 {
14  /* ovl0 */
25 }
26 
27 static void disp_config_main_path_mutex(void)
28 {
30 
31  /* Clock source from DP_INTF0 */
34  write32(&disp_mutex->mutex[0].en, BIT(0));
35 }
36 
37 static void ovl_bgclr_in_sel(u32 idx)
38 {
39  setbits32(&disp_ovl[idx]->datapath_con, BIT(2));
40 }
41 
42 static void ovl_layer_smi_id_en(u32 idx)
43 {
44  setbits32(&disp_ovl[idx]->datapath_con, BIT(0));
45 }
46 
47 static void ovl_layer_gclast_en(u32 idx)
48 {
49  setbits32(&disp_ovl[idx]->datapath_con, BIT(24));
50  setbits32(&disp_ovl[idx]->datapath_con, BIT(25));
51 }
52 
54 {
55  setbits32(&disp_ovl[idx]->datapath_con, BIT(26));
56 }
57 
59 {
60  struct disp_ccorr_regs *const regs = disp_ccorr;
61 
62  write32(&regs->size, width << 16 | height);
64  write32(&regs->en, PQ_EN);
65 }
66 
67 static void aal_config(u32 width, u32 height)
68 {
69  struct disp_aal_regs *const regs = disp_aal;
70 
71  write32(&regs->size, width << 16 | height);
72  write32(&regs->output_size, width << 16 | height);
74  write32(&regs->en, PQ_EN);
75 }
76 
78 {
79  struct disp_gamma_regs *const regs = disp_gamma;
80 
81  write32(&regs->size, width << 16 | height);
83  write32(&regs->en, PQ_EN);
84 }
85 
87 {
88  struct disp_dither_regs *const regs = disp_dither;
89  write32(&regs->size, width << 16 | height);
91  write32(&regs->en, PQ_EN);
92 }
93 
94 static void dsc_config(void)
95 {
96  struct disp_dsc_regs *const regs = disp_dsc;
97 
98  /* Enable dsc bypass mode. */
99  write32(&regs->con, DISP_DSC0_CON);
100 }
101 
103 {
104  struct disp_merge_regs *const regs = disp_merge;
105 
106  write32(&regs->cfg0, height << 16 | width);
107  write32(&regs->cfg4, height << 16 | width);
108  write32(&regs->cfg25, height << 16 | width);
109  setbits32(&regs->cfg10, MERGE_SWAP);
110  setbits32(&regs->cfg12, MERGE_MODE);
111  write32(&regs->en, 0x1);
112 }
113 
114 static void main_disp_path_setup(u32 width, u32 height, u32 vrefresh)
115 {
116  u32 idx = 0;
117  u32 pixel_clk = width * height * vrefresh;
118 
119  for (idx = 0; idx < MAIN_PATH_OVL_NR; idx++) {
120  ovl_set_roi(idx, width, height, idx ? 0 : 0xff0000ff);
121  ovl_layer_smi_id_en(idx);
122  ovl_layer_gclast_en(idx);
124  }
125 
126  rdma_config(width, height, pixel_clk, 5 * KiB);
132  dsc_config();
136 }
137 
138 static void disp_clock_on(void)
139 {
143 }
144 
145 void mtk_ddp_init(void)
146 {
147  disp_clock_on();
148 
149  /* Turn off M4U port. */
151 }
152 
153 void mtk_ddp_mode_set(const struct edid *edid)
154 {
155  u32 fmt = OVL_INFMT_RGBA8888;
157  u32 width = edid->mode.ha;
158  u32 height = edid->mode.va;
159  u32 vrefresh = edid->mode.refresh;
160 
161  printk(BIOS_DEBUG, "%s: display resolution: %dx%d@%d bpp %d\n",
162  __func__, width, height, vrefresh, bpp);
163 
164  if (!vrefresh) {
165  if (!width || !height)
166  vrefresh = 60;
167  else
168  vrefresh = edid->mode.pixel_clock * 1000 /
169  ((width + edid->mode.hbl) *
170  (height + edid->mode.vbl));
171 
172  printk(BIOS_WARNING, "%s: vrefresh is not provided; using %d\n",
173  __func__, vrefresh);
174  }
175 
176  main_disp_path_setup(width, height, vrefresh);
177  rdma_start();
178  ovl_layer_config(fmt, bpp, width, height);
179  ovl_bgclr_in_sel(1);
180 }
static void write32(void *addr, uint32_t val)
Definition: mmio.h:40
static int width
Definition: bochs.c:42
#define KiB
Definition: helpers.h:75
void color_start(u32 width, u32 height)
Definition: ddp.c:47
void rdma_config(u32 width, u32 height, u32 pixel_clk, u32 fifo_size)
Definition: ddp.c:23
void ovl_set_roi(u32 idx, u32 width, u32 height, u32 color)
Definition: ddp.c:12
void rdma_start(void)
Definition: ddp.c:18
void ovl_layer_config(u32 fmt, u32 bpp, u32 width, u32 height)
Definition: ddp.c:56
#define printk(level,...)
Definition: stdlib.h:16
@ OVL_INFMT_RGBA8888
Definition: ddp_common.h:123
static struct disp_ovl_regs *const disp_ovl[2]
Definition: ddp_common.h:61
#define BIT(nr)
Definition: ec_commands.h:45
#define setbits32(addr, set)
Definition: mmio.h:21
#define clrsetbits32(addr, clear, set)
Definition: mmio.h:16
#define clrbits32(addr, clear)
Definition: mmio.h:26
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define BIOS_WARNING
BIOS_WARNING - Bad configuration.
Definition: loglevel.h:86
void mtk_ddp_init(void)
Definition: ddp.c:61
void mtk_ddp_mode_set(const struct edid *edid)
Definition: ddp.c:66
@ MUTEX_MOD_MAIN_PATH
Definition: ddp.h:240
static struct disp_mutex_regs *const disp_mutex
Definition: ddp.h:231
static struct mmsys_cfg_regs *const mmsys_cfg
Definition: ddp.h:133
static struct disp_pq_regs *const disp_ccorr
Definition: ddp.h:168
static struct disp_pq_regs *const disp_aal
Definition: ddp.h:170
static struct disp_pq_regs *const disp_gamma
Definition: ddp.h:172
@ CG_CON0_DISP_ALL
Definition: ddp.h:65
static struct disp_pq_regs *const disp_dither
Definition: ddp.h:174
#define MAIN_PATH_OVL_NR
Definition: ddp.h:10
#define PQ_ENGINE_EN
Definition: ddp.h:247
@ CG_CON2_DISP_ALL
Definition: ddp.h:195
#define SMI_LARB_PORT_L0_OVL_RDMA0
Definition: ddp.h:16
#define PQ_RELAY_MODE
Definition: ddp.h:246
#define PQ_EN
Definition: ddp.h:245
@ CG_CON1_DISP_ALL
Definition: ddp.h:100
#define MERGE_SWAP
Definition: ddp.c:10
static void ovl_layer_output_clamp_en(u32 idx)
Definition: ddp.c:53
static void ovl_layer_smi_id_en(u32 idx)
Definition: ddp.c:42
static void gamma_config(u32 width, u32 height)
Definition: ddp.c:77
static void dither_config(u32 width, u32 height)
Definition: ddp.c:86
static void dsc_config(void)
Definition: ddp.c:94
static void main_disp_path_setup(u32 width, u32 height, u32 vrefresh)
Definition: ddp.c:114
#define MERGE_MODE
Definition: ddp.c:9
static void aal_config(u32 width, u32 height)
Definition: ddp.c:67
static void merge_config(u32 width, u32 height)
Definition: ddp.c:102
static void ovl_bgclr_in_sel(u32 idx)
Definition: ddp.c:37
static void disp_config_main_path_connection(void)
Definition: ddp.c:12
static void disp_clock_on(void)
Definition: ddp.c:138
static void ovl_layer_gclast_en(u32 idx)
Definition: ddp.c:47
static void ccorr_config(u32 width, u32 height)
Definition: ddp.c:58
static void disp_config_main_path_mutex(void)
Definition: ddp.c:27
@ DISP_DSC0_CON
Definition: ddp.h:341
static struct disp_dsc_regs *const disp_dsc
Definition: ddp.h:361
static struct disp_merge_regs *const disp_merge
Definition: ddp.h:363
@ SEL_IN_VPP_MERGE_FROM_DSC_WRAP0_OUT
Definition: ddp.h:126
@ SEL_IN_DSC_WRAP0_IN_FROM_DISP_DITHER0
Definition: ddp.h:127
@ SEL_IN_DP_INTF0_FROM_VPP_MERGE
Definition: ddp.h:128
@ SEL_OUT_VPP_MERGE_TO_DP_INTF0
Definition: ddp.h:130
@ SEL_OUT_DSC_WRAP0_OUT_TO_VPP_MERGE
Definition: ddp.h:131
@ SEL_OUT_DISP_DITHER0_TO_DSC_WRAP0_IN
Definition: ddp.h:129
@ MUTEX_SOF_DP_INTF0
Definition: ddp.h:175
@ DISP_OVL0_TO_DISP_RDMA0
Definition: ddp.h:121
@ SMI_LARB0
Definition: addressmap.h:62
uint32_t u32
Definition: stdint.h:51
struct disp_mutex_regs::@798 mutex[6]
unsigned int refresh
Definition: edid.h:24
unsigned int hbl
Definition: edid.h:26
unsigned int va
Definition: edid.h:30
unsigned int ha
Definition: edid.h:25
unsigned int pixel_clock
Definition: edid.h:22
unsigned int vbl
Definition: edid.h:31
Definition: edid.h:49
unsigned int framebuffer_bits_per_pixel
Definition: edid.h:58
struct edid_mode mode
Definition: edid.h:72
u32 mmsys_sel_out
Definition: ddp.h:40
u32 mmsys_cg_con0
Definition: ddp.h:63
u32 mmsys_cg_con2
Definition: ddp.h:28
u32 mmsys_sel_in
Definition: ddp.h:39
u32 mmsys_ovl_mout_en
Definition: ddp.h:27
u32 mmsys_cg_con1
Definition: ddp.h:67
#define height