Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/rockchip: vop2: Set YUV/RGB overlay mode

Set overlay mode register according to the
output mode is yuv or rgb.

Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20231211115805.1785073-1-andyshrk@163.com

authored by

Andy Yan and committed by
Heiko Stuebner
dd49ee46 d1f8face

+16 -3
+1
drivers/gpu/drm/rockchip/rockchip_drm_drv.h
··· 48 48 int output_bpc; 49 49 int output_flags; 50 50 bool enable_afbc; 51 + bool yuv_overlay; 51 52 u32 bus_format; 52 53 u32 bus_flags; 53 54 int color_space;
+14 -3
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
··· 1623 1623 1624 1624 vop2->enable_count++; 1625 1625 1626 + vcstate->yuv_overlay = is_yuv_output(vcstate->bus_format); 1627 + 1626 1628 vop2_crtc_enable_irq(vp, VP_INT_POST_BUF_EMPTY); 1627 1629 1628 1630 polflags = 0; ··· 1652 1650 if (vop2_output_uv_swap(vcstate->bus_format, vcstate->output_mode)) 1653 1651 dsp_ctrl |= RK3568_VP_DSP_CTRL__DSP_RB_SWAP; 1654 1652 1655 - if (is_yuv_output(vcstate->bus_format)) 1653 + if (vcstate->yuv_overlay) 1656 1654 dsp_ctrl |= RK3568_VP_DSP_CTRL__POST_DSP_OUT_R2Y; 1657 1655 1658 1656 vop2_dither_setup(crtc, &dsp_ctrl); ··· 1961 1959 u16 hdisplay; 1962 1960 u32 bg_dly; 1963 1961 u32 pre_scan_dly; 1962 + u32 ovl_ctrl; 1964 1963 int i; 1965 1964 struct vop2_video_port *vp0 = &vop2->vps[0]; 1966 1965 struct vop2_video_port *vp1 = &vop2->vps[1]; 1967 1966 struct vop2_video_port *vp2 = &vop2->vps[2]; 1967 + struct rockchip_crtc_state *vcstate = to_rockchip_crtc_state(vp->crtc.state); 1968 1968 1969 1969 adjusted_mode = &vp->crtc.state->adjusted_mode; 1970 1970 hsync_len = adjusted_mode->crtc_hsync_end - adjusted_mode->crtc_hsync_start; ··· 1979 1975 pre_scan_dly = ((bg_dly + (hdisplay >> 1) - 1) << 16) | hsync_len; 1980 1976 vop2_vp_write(vp, RK3568_VP_PRE_SCAN_HTIMING, pre_scan_dly); 1981 1977 1982 - vop2_writel(vop2, RK3568_OVL_CTRL, 0); 1978 + ovl_ctrl = vop2_readl(vop2, RK3568_OVL_CTRL); 1979 + ovl_ctrl |= RK3568_OVL_CTRL__LAYERSEL_REGDONE_IMD; 1980 + if (vcstate->yuv_overlay) 1981 + ovl_ctrl |= RK3568_OVL_CTRL__YUV_MODE(vp->id); 1982 + else 1983 + ovl_ctrl &= ~RK3568_OVL_CTRL__YUV_MODE(vp->id); 1984 + 1985 + vop2_writel(vop2, RK3568_OVL_CTRL, ovl_ctrl); 1986 + 1983 1987 port_sel = vop2_readl(vop2, RK3568_OVL_PORT_SEL); 1984 1988 port_sel &= RK3568_OVL_PORT_SEL__SEL_PORT; 1985 1989 ··· 2061 2049 2062 2050 vop2_writel(vop2, RK3568_OVL_LAYER_SEL, layer_sel); 2063 2051 vop2_writel(vop2, RK3568_OVL_PORT_SEL, port_sel); 2064 - vop2_writel(vop2, RK3568_OVL_CTRL, RK3568_OVL_CTRL__LAYERSEL_REGDONE_IMD); 2065 2052 } 2066 2053 2067 2054 static void vop2_setup_dly_for_windows(struct vop2 *vop2)
+1
drivers/gpu/drm/rockchip/rockchip_drm_vop2.h
··· 401 401 #define VOP2_COLOR_KEY_MASK BIT(31) 402 402 403 403 #define RK3568_OVL_CTRL__LAYERSEL_REGDONE_IMD BIT(28) 404 + #define RK3568_OVL_CTRL__YUV_MODE(vp) BIT(vp) 404 405 405 406 #define RK3568_VP_BG_MIX_CTRL__BG_DLY GENMASK(31, 24) 406 407