11
11
#include <linux/of_device.h>
12
12
#include <linux/of_irq.h>
13
13
#include <linux/platform_device.h>
14
+ #include <linux/soc/mediatek/mtk-cmdq.h>
14
15
15
16
#include "mtk_drm_crtc.h"
16
17
#include "mtk_drm_ddp_comp.h"
@@ -124,14 +125,15 @@ static void mtk_ovl_stop(struct mtk_ddp_comp *comp)
124
125
125
126
static void mtk_ovl_config (struct mtk_ddp_comp * comp , unsigned int w ,
126
127
unsigned int h , unsigned int vrefresh ,
127
- unsigned int bpc )
128
+ unsigned int bpc , struct cmdq_pkt * cmdq_pkt )
128
129
{
129
130
if (w != 0 && h != 0 )
130
- writel_relaxed (h << 16 | w , comp -> regs + DISP_REG_OVL_ROI_SIZE );
131
- writel_relaxed (0x0 , comp -> regs + DISP_REG_OVL_ROI_BGCLR );
131
+ mtk_ddp_write_relaxed (cmdq_pkt , h << 16 | w , comp ,
132
+ DISP_REG_OVL_ROI_SIZE );
133
+ mtk_ddp_write_relaxed (cmdq_pkt , 0x0 , comp , DISP_REG_OVL_ROI_BGCLR );
132
134
133
- writel ( 0x1 , comp -> regs + DISP_REG_OVL_RST );
134
- writel ( 0x0 , comp -> regs + DISP_REG_OVL_RST );
135
+ mtk_ddp_write ( cmdq_pkt , 0x1 , comp , DISP_REG_OVL_RST );
136
+ mtk_ddp_write ( cmdq_pkt , 0x0 , comp , DISP_REG_OVL_RST );
135
137
}
136
138
137
139
static unsigned int mtk_ovl_layer_nr (struct mtk_ddp_comp * comp )
@@ -175,16 +177,16 @@ static int mtk_ovl_layer_check(struct mtk_ddp_comp *comp, unsigned int idx,
175
177
return 0 ;
176
178
}
177
179
178
- static void mtk_ovl_layer_on (struct mtk_ddp_comp * comp , unsigned int idx )
180
+ static void mtk_ovl_layer_on (struct mtk_ddp_comp * comp , unsigned int idx ,
181
+ struct cmdq_pkt * cmdq_pkt )
179
182
{
180
- unsigned int reg ;
181
183
unsigned int gmc_thrshd_l ;
182
184
unsigned int gmc_thrshd_h ;
183
185
unsigned int gmc_value ;
184
186
struct mtk_disp_ovl * ovl = comp_to_ovl (comp );
185
187
186
- writel ( 0x1 , comp -> regs + DISP_REG_OVL_RDMA_CTRL ( idx ));
187
-
188
+ mtk_ddp_write ( cmdq_pkt , 0x1 , comp ,
189
+ DISP_REG_OVL_RDMA_CTRL ( idx ));
188
190
gmc_thrshd_l = GMC_THRESHOLD_LOW >>
189
191
(GMC_THRESHOLD_BITS - ovl -> data -> gmc_bits );
190
192
gmc_thrshd_h = GMC_THRESHOLD_HIGH >>
@@ -194,22 +196,19 @@ static void mtk_ovl_layer_on(struct mtk_ddp_comp *comp, unsigned int idx)
194
196
else
195
197
gmc_value = gmc_thrshd_l | gmc_thrshd_l << 8 |
196
198
gmc_thrshd_h << 16 | gmc_thrshd_h << 24 ;
197
- writel (gmc_value , comp -> regs + DISP_REG_OVL_RDMA_GMC (idx ));
198
-
199
- reg = readl (comp -> regs + DISP_REG_OVL_SRC_CON );
200
- reg = reg | BIT (idx );
201
- writel (reg , comp -> regs + DISP_REG_OVL_SRC_CON );
199
+ mtk_ddp_write (cmdq_pkt , gmc_value ,
200
+ comp , DISP_REG_OVL_RDMA_GMC (idx ));
201
+ mtk_ddp_write_mask (cmdq_pkt , BIT (idx ), comp ,
202
+ DISP_REG_OVL_SRC_CON , BIT (idx ));
202
203
}
203
204
204
- static void mtk_ovl_layer_off (struct mtk_ddp_comp * comp , unsigned int idx )
205
+ static void mtk_ovl_layer_off (struct mtk_ddp_comp * comp , unsigned int idx ,
206
+ struct cmdq_pkt * cmdq_pkt )
205
207
{
206
- unsigned int reg ;
207
-
208
- reg = readl (comp -> regs + DISP_REG_OVL_SRC_CON );
209
- reg = reg & ~BIT (idx );
210
- writel (reg , comp -> regs + DISP_REG_OVL_SRC_CON );
211
-
212
- writel (0x0 , comp -> regs + DISP_REG_OVL_RDMA_CTRL (idx ));
208
+ mtk_ddp_write_mask (cmdq_pkt , 0 , comp ,
209
+ DISP_REG_OVL_SRC_CON , BIT (idx ));
210
+ mtk_ddp_write (cmdq_pkt , 0 , comp ,
211
+ DISP_REG_OVL_RDMA_CTRL (idx ));
213
212
}
214
213
215
214
static unsigned int ovl_fmt_convert (struct mtk_disp_ovl * ovl , unsigned int fmt )
@@ -249,7 +248,8 @@ static unsigned int ovl_fmt_convert(struct mtk_disp_ovl *ovl, unsigned int fmt)
249
248
}
250
249
251
250
static void mtk_ovl_layer_config (struct mtk_ddp_comp * comp , unsigned int idx ,
252
- struct mtk_plane_state * state )
251
+ struct mtk_plane_state * state ,
252
+ struct cmdq_pkt * cmdq_pkt )
253
253
{
254
254
struct mtk_disp_ovl * ovl = comp_to_ovl (comp );
255
255
struct mtk_plane_pending_state * pending = & state -> pending ;
@@ -260,11 +260,13 @@ static void mtk_ovl_layer_config(struct mtk_ddp_comp *comp, unsigned int idx,
260
260
unsigned int src_size = (pending -> height << 16 ) | pending -> width ;
261
261
unsigned int con ;
262
262
263
- if (!pending -> enable )
264
- mtk_ovl_layer_off (comp , idx );
263
+ if (!pending -> enable ) {
264
+ mtk_ovl_layer_off (comp , idx , cmdq_pkt );
265
+ return ;
266
+ }
265
267
266
268
con = ovl_fmt_convert (ovl , fmt );
267
- if (idx != 0 )
269
+ if (state -> base . fb -> format -> has_alpha )
268
270
con |= OVL_CON_AEN | OVL_CON_ALPHA ;
269
271
270
272
if (pending -> rotation & DRM_MODE_REFLECT_Y ) {
@@ -277,14 +279,18 @@ static void mtk_ovl_layer_config(struct mtk_ddp_comp *comp, unsigned int idx,
277
279
addr += pending -> pitch - 1 ;
278
280
}
279
281
280
- writel_relaxed (con , comp -> regs + DISP_REG_OVL_CON (idx ));
281
- writel_relaxed (pitch , comp -> regs + DISP_REG_OVL_PITCH (idx ));
282
- writel_relaxed (src_size , comp -> regs + DISP_REG_OVL_SRC_SIZE (idx ));
283
- writel_relaxed (offset , comp -> regs + DISP_REG_OVL_OFFSET (idx ));
284
- writel_relaxed (addr , comp -> regs + DISP_REG_OVL_ADDR (ovl , idx ));
285
-
286
- if (pending -> enable )
287
- mtk_ovl_layer_on (comp , idx );
282
+ mtk_ddp_write_relaxed (cmdq_pkt , con , comp ,
283
+ DISP_REG_OVL_CON (idx ));
284
+ mtk_ddp_write_relaxed (cmdq_pkt , pitch , comp ,
285
+ DISP_REG_OVL_PITCH (idx ));
286
+ mtk_ddp_write_relaxed (cmdq_pkt , src_size , comp ,
287
+ DISP_REG_OVL_SRC_SIZE (idx ));
288
+ mtk_ddp_write_relaxed (cmdq_pkt , offset , comp ,
289
+ DISP_REG_OVL_OFFSET (idx ));
290
+ mtk_ddp_write_relaxed (cmdq_pkt , addr , comp ,
291
+ DISP_REG_OVL_ADDR (ovl , idx ));
292
+
293
+ mtk_ovl_layer_on (comp , idx , cmdq_pkt );
288
294
}
289
295
290
296
static void mtk_ovl_bgclr_in_on (struct mtk_ddp_comp * comp )
@@ -313,8 +319,6 @@ static const struct mtk_ddp_comp_funcs mtk_disp_ovl_funcs = {
313
319
.disable_vblank = mtk_ovl_disable_vblank ,
314
320
.supported_rotations = mtk_ovl_supported_rotations ,
315
321
.layer_nr = mtk_ovl_layer_nr ,
316
- .layer_on = mtk_ovl_layer_on ,
317
- .layer_off = mtk_ovl_layer_off ,
318
322
.layer_check = mtk_ovl_layer_check ,
319
323
.layer_config = mtk_ovl_layer_config ,
320
324
.bgclr_in_on = mtk_ovl_bgclr_in_on ,
0 commit comments