Skip to content

Commit 45643f5

Browse files
cristicc6by9
authored andcommitted
drm/rockchip: vop2: Support setting custom background color
VOP2 allows configuring the background color of each video output port. Since a previous patch introduced the BACKGROUND_COLOR CRTC property, which defaults to solid black, take it into account when programming the hardware. Note that only the 10 least significant bits of each color component are used, as this is the maximum precision supported by the display controller. Signed-off-by: Cristian Ciocaltea <[email protected]>
1 parent e90bee2 commit 45643f5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

drivers/gpu/drm/rockchip/rockchip_drm_vop2.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1544,6 +1544,7 @@ static void vop2_post_config(struct drm_crtc *crtc)
15441544
{
15451545
struct vop2_video_port *vp = to_vop2_video_port(crtc);
15461546
struct drm_display_mode *mode = &crtc->state->adjusted_mode;
1547+
u64 bgcolor = crtc->state->background_color;
15471548
u16 vtotal = mode->crtc_vtotal;
15481549
u16 hdisplay = mode->crtc_hdisplay;
15491550
u16 hact_st = mode->crtc_htotal - mode->crtc_hsync_start;
@@ -1597,7 +1598,11 @@ static void vop2_post_config(struct drm_crtc *crtc)
15971598
vop2_vp_write(vp, RK3568_VP_POST_DSP_VACT_INFO_F1, val);
15981599
}
15991600

1600-
vop2_vp_write(vp, RK3568_VP_DSP_BG, 0);
1601+
/* Background color is programmed with 10 bits of precision */
1602+
val = FIELD_PREP(RK3568_VP_DSP_BG__DSP_BG_RED, DRM_ARGB64_RED(bgcolor));
1603+
val |= FIELD_PREP(RK3568_VP_DSP_BG__DSP_BG_GREEN, DRM_ARGB64_GREEN(bgcolor));
1604+
val |= FIELD_PREP(RK3568_VP_DSP_BG__DSP_BG_BLUE, DRM_ARGB64_BLUE(bgcolor));
1605+
vop2_vp_write(vp, RK3568_VP_DSP_BG, val);
16011606
}
16021607

16031608
static unsigned long rk3568_set_intf_mux(struct vop2_video_port *vp, int id, u32 polflags)
@@ -2884,6 +2889,8 @@ static int vop2_create_crtcs(struct vop2 *vop2)
28842889
return ret;
28852890
}
28862891

2892+
drm_crtc_attach_background_color_property(&vp->crtc);
2893+
28872894
drm_crtc_helper_add(&vp->crtc, &vop2_crtc_helper_funcs);
28882895

28892896
init_completion(&vp->dsp_hold_completion);

drivers/gpu/drm/rockchip/rockchip_drm_vop2.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,10 @@ enum dst_factor_mode {
421421
#define RK3588_VP_CLK_CTRL__DCLK_OUT_DIV GENMASK(3, 2)
422422
#define RK3588_VP_CLK_CTRL__DCLK_CORE_DIV GENMASK(1, 0)
423423

424+
#define RK3568_VP_DSP_BG__DSP_BG_RED GENMASK(29, 20)
425+
#define RK3568_VP_DSP_BG__DSP_BG_GREEN GENMASK(19, 10)
426+
#define RK3568_VP_DSP_BG__DSP_BG_BLUE GENMASK(9, 0)
427+
424428
#define RK3568_VP_POST_SCL_CTRL__VSCALEDOWN BIT(1)
425429
#define RK3568_VP_POST_SCL_CTRL__HSCALEDOWN BIT(0)
426430

0 commit comments

Comments
 (0)