Skip to content

Commit f8d9b91

Browse files
dangowrtChun-Kuang Hu
authored andcommitted
drm/mediatek: Only touch DISP_REG_OVL_PITCH_MSB if AFBC is supported
Touching DISP_REG_OVL_PITCH_MSB leads to video overlay on MT2701, MT7623N and probably other older SoCs being broken. Move setting up AFBC layer configuration into a separate function only being called on hardware which actually supports AFBC which restores the behavior as it was before commit c410fa9 ("drm/mediatek: Add AFBC support to Mediatek DRM driver") on non-AFBC hardware. Fixes: c410fa9 ("drm/mediatek: Add AFBC support to Mediatek DRM driver") Cc: [email protected] Signed-off-by: Daniel Golle <[email protected]> Reviewed-by: CK Hu <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/c7fbd3c3e633c0b7dd6d1cd78ccbdded31e1ca0f.1734397800.git.daniel@makrotopia.org/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent da03801 commit f8d9b91

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

drivers/gpu/drm/mediatek/mtk_disp_ovl.c

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -460,32 +460,43 @@ static unsigned int mtk_ovl_fmt_convert(struct mtk_disp_ovl *ovl,
460460
}
461461
}
462462

463+
static void mtk_ovl_afbc_layer_config(struct mtk_disp_ovl *ovl,
464+
unsigned int idx,
465+
struct mtk_plane_pending_state *pending,
466+
struct cmdq_pkt *cmdq_pkt)
467+
{
468+
unsigned int pitch_msb = pending->pitch >> 16;
469+
unsigned int hdr_pitch = pending->hdr_pitch;
470+
unsigned int hdr_addr = pending->hdr_addr;
471+
472+
if (pending->modifier != DRM_FORMAT_MOD_LINEAR) {
473+
mtk_ddp_write_relaxed(cmdq_pkt, hdr_addr, &ovl->cmdq_reg, ovl->regs,
474+
DISP_REG_OVL_HDR_ADDR(ovl, idx));
475+
mtk_ddp_write_relaxed(cmdq_pkt,
476+
OVL_PITCH_MSB_2ND_SUBBUF | pitch_msb,
477+
&ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_PITCH_MSB(idx));
478+
mtk_ddp_write_relaxed(cmdq_pkt, hdr_pitch, &ovl->cmdq_reg, ovl->regs,
479+
DISP_REG_OVL_HDR_PITCH(ovl, idx));
480+
} else {
481+
mtk_ddp_write_relaxed(cmdq_pkt, pitch_msb,
482+
&ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_PITCH_MSB(idx));
483+
}
484+
}
485+
463486
void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
464487
struct mtk_plane_state *state,
465488
struct cmdq_pkt *cmdq_pkt)
466489
{
467490
struct mtk_disp_ovl *ovl = dev_get_drvdata(dev);
468491
struct mtk_plane_pending_state *pending = &state->pending;
469492
unsigned int addr = pending->addr;
470-
unsigned int hdr_addr = pending->hdr_addr;
471-
unsigned int pitch = pending->pitch;
472-
unsigned int hdr_pitch = pending->hdr_pitch;
493+
unsigned int pitch_lsb = pending->pitch & GENMASK(15, 0);
473494
unsigned int fmt = pending->format;
474495
unsigned int offset = (pending->y << 16) | pending->x;
475496
unsigned int src_size = (pending->height << 16) | pending->width;
476497
unsigned int blend_mode = state->base.pixel_blend_mode;
477498
unsigned int ignore_pixel_alpha = 0;
478499
unsigned int con;
479-
bool is_afbc = pending->modifier != DRM_FORMAT_MOD_LINEAR;
480-
union overlay_pitch {
481-
struct split_pitch {
482-
u16 lsb;
483-
u16 msb;
484-
} split_pitch;
485-
u32 pitch;
486-
} overlay_pitch;
487-
488-
overlay_pitch.pitch = pitch;
489500

490501
if (!pending->enable) {
491502
mtk_ovl_layer_off(dev, idx, cmdq_pkt);
@@ -524,11 +535,12 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
524535
}
525536

526537
if (ovl->data->supports_afbc)
527-
mtk_ovl_set_afbc(ovl, cmdq_pkt, idx, is_afbc);
538+
mtk_ovl_set_afbc(ovl, cmdq_pkt, idx,
539+
pending->modifier != DRM_FORMAT_MOD_LINEAR);
528540

529541
mtk_ddp_write_relaxed(cmdq_pkt, con, &ovl->cmdq_reg, ovl->regs,
530542
DISP_REG_OVL_CON(idx));
531-
mtk_ddp_write_relaxed(cmdq_pkt, overlay_pitch.split_pitch.lsb | ignore_pixel_alpha,
543+
mtk_ddp_write_relaxed(cmdq_pkt, pitch_lsb | ignore_pixel_alpha,
532544
&ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_PITCH(idx));
533545
mtk_ddp_write_relaxed(cmdq_pkt, src_size, &ovl->cmdq_reg, ovl->regs,
534546
DISP_REG_OVL_SRC_SIZE(idx));
@@ -537,19 +549,8 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
537549
mtk_ddp_write_relaxed(cmdq_pkt, addr, &ovl->cmdq_reg, ovl->regs,
538550
DISP_REG_OVL_ADDR(ovl, idx));
539551

540-
if (is_afbc) {
541-
mtk_ddp_write_relaxed(cmdq_pkt, hdr_addr, &ovl->cmdq_reg, ovl->regs,
542-
DISP_REG_OVL_HDR_ADDR(ovl, idx));
543-
mtk_ddp_write_relaxed(cmdq_pkt,
544-
OVL_PITCH_MSB_2ND_SUBBUF | overlay_pitch.split_pitch.msb,
545-
&ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_PITCH_MSB(idx));
546-
mtk_ddp_write_relaxed(cmdq_pkt, hdr_pitch, &ovl->cmdq_reg, ovl->regs,
547-
DISP_REG_OVL_HDR_PITCH(ovl, idx));
548-
} else {
549-
mtk_ddp_write_relaxed(cmdq_pkt,
550-
overlay_pitch.split_pitch.msb,
551-
&ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_PITCH_MSB(idx));
552-
}
552+
if (ovl->data->supports_afbc)
553+
mtk_ovl_afbc_layer_config(ovl, idx, pending, cmdq_pkt);
553554

554555
mtk_ovl_set_bit_depth(dev, idx, fmt, cmdq_pkt);
555556
mtk_ovl_layer_on(dev, idx, cmdq_pkt);

0 commit comments

Comments
 (0)