Skip to content

Commit 8f5adfa

Browse files
committed
drm/rockchip: vop2: honor TV margins from CRTC state for overscan compensation
Replace the hard-coded percent values with pixel margins carried in struct rockchip_crtc_state, sourced from the standard DRM "left/right/top/bottom margin" connector properties (struct drm_connector_tv_margins) to pave way for HDMI overscan compensation support. Signed-off-by: Alexey Charkov <alchark@flipper.net>
1 parent 4fd22ab commit 8f5adfa

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

drivers/gpu/drm/rockchip/rockchip_drm_drv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define _ROCKCHIP_DRM_DRV_H
1111

1212
#include <drm/drm_atomic_helper.h>
13+
#include <drm/drm_connector.h>
1314
#include <drm/drm_gem.h>
1415

1516
#include <linux/bits.h>
@@ -54,6 +55,7 @@ struct rockchip_crtc_state {
5455
u32 bus_flags;
5556
int color_space;
5657
bool frl_enabled;
58+
struct drm_connector_tv_margins tv_margins;
5759
};
5860
#define to_rockchip_crtc_state(s) \
5961
container_of(s, struct rockchip_crtc_state, base)

drivers/gpu/drm/rockchip/rockchip_drm_vop2.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,30 +1577,35 @@ static void vop2_post_config(struct drm_crtc *crtc)
15771577
{
15781578
struct vop2_video_port *vp = to_vop2_video_port(crtc);
15791579
struct vop2 *vop2 = vp->vop2;
1580+
struct rockchip_crtc_state *vcstate = to_rockchip_crtc_state(crtc->state);
15801581
struct drm_display_mode *mode = &crtc->state->adjusted_mode;
1582+
const struct drm_connector_tv_margins *m = &vcstate->tv_margins;
15811583
u64 bgcolor = crtc->state->background_color;
15821584
u16 vtotal = mode->crtc_vtotal;
15831585
u16 hdisplay = mode->crtc_hdisplay;
15841586
u16 hact_st = mode->crtc_htotal - mode->crtc_hsync_start;
15851587
u16 vdisplay = mode->crtc_vdisplay;
15861588
u16 vact_st = mode->crtc_vtotal - mode->crtc_vsync_start;
1587-
u32 left_margin = 100, right_margin = 100;
1588-
u32 top_margin = 100, bottom_margin = 100;
1589-
u16 hsize = hdisplay * (left_margin + right_margin) / 200;
1590-
u16 vsize = vdisplay * (top_margin + bottom_margin) / 200;
1589+
u16 hsize = hdisplay;
1590+
u16 vsize = vdisplay;
15911591
u16 hact_end, vact_end;
15921592
u32 val;
15931593

15941594
vop2->ops->setup_bg_dly(vp);
15951595

1596+
if (m->left + m->right < hdisplay)
1597+
hsize = hdisplay - m->left - m->right;
1598+
if (m->top + m->bottom < vdisplay)
1599+
vsize = vdisplay - m->top - m->bottom;
1600+
15961601
vsize = rounddown(vsize, 2);
15971602
hsize = rounddown(hsize, 2);
1598-
hact_st += hdisplay * (100 - left_margin) / 200;
1603+
hact_st += m->left;
15991604
hact_end = hact_st + hsize;
16001605
val = hact_st << 16;
16011606
val |= hact_end;
16021607
vop2_vp_write(vp, RK3568_VP_POST_DSP_HACT_INFO, val);
1603-
vact_st += vdisplay * (100 - top_margin) / 200;
1608+
vact_st += m->top;
16041609
vact_end = vact_st + vsize;
16051610
val = vact_st << 16;
16061611
val |= vact_end;

0 commit comments

Comments
 (0)