drm/rockchip: vop2: RK3588 clocking, sync polarity and window fixes
Subsystems (5)
v3 cover drm/rockchip: vop2: RK3588 clocking, sync polarity and window fixes
Fixes for the RK3588 VOP2 found while bringing up HDMI and DisplayPort on an Orange Pi 5 (RK3588S).
Tested on an Orange Pi 5 with an HDMI 2.1 TV and a DisplayPort monitor, pictures judged with a camera, v7.3 based kernel: VP_CLK_CTRL reads back without the garbage divider; the HDMI controller sees the sync polarities of +/+ and mixed modes; HDMI from 148.5 to 1188 MHz (TMDS and FRL) and DP show a correct picture; RGB565 on the Cluster windows scans out without YTR; NV12 in two GEM objects and an AFBC overlay at x=1001 show correctly. Not tested: -HSync/-VSync modes (none in the TV's list), BGR565, HDMI1, eDP, MIPI DSI and DPI (no hardware).
Developed with Claude (Anthropic), which wrote the code and the commit messages. I reviewed every change.
---
Changes in v3:
- Dropped v2 patch 5, which balanced the windows of a video port across both AXI ports: the TRM doesn't allow one port's layers on AXI0 and AXI1 (Chaoyi Chen). He pointed to the VP merge series for that case [1].
- Patch 1: dropped the comment (Chaoyi Chen).
- Patch 2: no common initialisation; every interface sets the dividers it doesn't use to 1, and an unused dclk_out is no longer kept at the dclk_core rate (Damon Ding).
- Patch 3: commit message corrected (Damon Ding); Reviewed-by added (Chaoyi Chen, Damon Ding); Cc Cristian Ciocaltea.
- New patch 4: the HDMI vsync and hsync polarity bits were swapped.
- Patch 5: YTR is only accepted for the 8 bit RGB formats, as the TRM says (Chaoyi Chen); comment dropped; new subject.
- Dropped v2 patch 6, which reported POST_BUF_EMPTY at most once per
frame: it hides an underflow instead of fixing its cause (Damon Ding).
- Patch 6: Reviewed-by added (Chaoyi Chen, Damon Ding).
- Patch 7: Reviewed-by added (Damon Ding).
- Shorter commit messages and comments, no code change otherwise.
- [1] https://lore.kernel.org/all/[email protected]/
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- New patch 1: UV plane address from fb->obj[1] (Sashiko).
- Mixer search: bounded by the new ROCKCHIP_VOP2_MAX_LAYER_ID (Chaoyi Chen); Fixes: tag (Sashiko).
- LUT_PORT_SEL: Fixes: tag (Sashiko), Reviewed-by (Chaoyi Chen).
- AFBC offsets: x offset modulo the superblock width, 32 with AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 (Sashiko); Fixes: tag (Sashiko).
- Cc Piotr Zalewski (author of the commit the LUT_PORT_SEL patch fixes).
- Link to v1: https://patch.msgid.link/[email protected]
---
Arun Iyengar (8):
drm/rockchip: vop2: Take the UV plane address from the second GEM object drm/rockchip: vop2: Don't use uninitialised dividers on RK3588 drm/rockchip: vop2: Fix the HDMI sync polarity on RK3588 drm/rockchip: vop2: Fix the HDMI sync polarity bit order on RK3588 drm/rockchip: vop2: Only accept AFBC YTR for 8 bit RGB on RK3588 drm/rockchip: vop2: Find the first mixer of a video port with Esmart3 too drm/rockchip: vop2: Keep the other LUT_PORT_SEL fields on gamma LUT updates drm/rockchip: vop2: Fix the AFBC offsets of a source that starts inside a superblock
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 23 +++++++++++++++-------- drivers/gpu/drm/rockchip/rockchip_drm_vop2.h | 1 + drivers/gpu/drm/rockchip/rockchip_vop2_reg.c | 17 +++++++++++++---- 3 files changed, 29 insertions(+), 12 deletions(-)
---
base-commit: 8deaade4a5a4ff635df91e246e42139ab2b33f6d
change-id: 20261110-vop2-fixes-fa45142799c1
Best regards,
Signature · 1 line
Arun Iyengar <[email protected]>
PATCH v3 1/8 drm/rockchip: vop2: Take the UV plane address from the second GEM object
vop2_plane_atomic_update() takes the chroma plane address from fb->obj[0]. The planes of a framebuffer can be in different GEM objects (ADDFB2 with two handles, e.g. NV12M from a V4L2 decoder), and the window then fetches the chroma plane from the luma buffer.
Use fb->obj[1] for formats with more than one plane.
--- drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +2 -1
@@ -1369,7 +1369,8 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,if ((pstate->rotation &DRM_MODE_REFLECT_Y ) && !afbc_en) offset += fb->pitches[1 ] * ((pstate->src_h >>16 ) -2 ) / vsub; - rk_obj =to_rockchip_obj (fb->obj[0 ]); +if (fb->format->num_planes >1 ) + rk_obj =to_rockchip_obj (fb->obj[1 ]); uv_mst = rk_obj->dma_addr + offset + fb->offsets[1 ]; }
Signature · 1 line
2.55.0
Re: [PATCH v3 1/8] drm/rockchip: vop2: Take the UV plane address from the second GEM object
Quoted 24 lines · On 11/14/2026 12:39 AM, Arun Iyengar via B4 Relay wrote:
From: Arun Iyengar <[email protected]>
vop2_plane_atomic_update()takes the chroma plane address from fb->obj[0]. The planes of a framebuffer can be in different GEM objects (ADDFB2 with two handles, e.g. NV12M from a V4L2 decoder), and the window then fetches the chroma plane from the luma buffer.Use fb->obj[1] for formats with more than one plane.
Fixes 604be85547ce ("drm/rockchip: Add VOP2 driver")Reported-by Sashiko <[email protected]>Signed-off-by Arun Iyengar <[email protected]>--- drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +0
-0
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c static void vop2_plane_atomic_update(struct drm_plane *plane, · line 1376
Quoted 9 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +2
-1@@ -1369,7 +1369,8 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,if ((pstate->rotation &DRM_MODE_REFLECT_Y ) && !afbc_en) offset += fb->pitches[1 ] * ((pstate->src_h >>16 ) -2 ) / vsub; - rk_obj =to_rockchip_obj (fb->obj[0 ]); +if (fb->format->num_planes >1 ) + rk_obj =to_rockchip_obj (fb->obj[1 ]); uv_mst = rk_obj->dma_addr + offset + fb->offsets[1 ]; }
Best regards,
Damon
PATCH v3 2/8 drm/rockchip: vop2: Don't use uninitialised dividers on RK3588
In reply to Arun Iyengarrk3588_calc_cru_cfg() converts all four dividers with ilog2(), but every interface only sets the ones it uses: dclk_out_div is left uninitialised for HDMI, eDP and DPI, if_dclk_div for DP, MIPI and DPI, and if_pixclk_div for DP and DPI. For HDMI and eDP the uninitialised dclk_out_div is then written to RK3588_VP_CLK_CTRL.
Set the dividers an interface doesn't use to 1.
--- drivers/gpu/drm/rockchip/rockchip_vop2_reg.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/rockchip/rockchip_vop2_reg.c +8 -0
@@ -1597,6 +1597,7 @@ static unsigned long rk3588_calc_cru_cfg(struct vop2_video_port *vp, int id,*/ *if_pixclk_div =2 ; *if_dclk_div =4 ; + *dclk_out_div =1 ; }else if (vop2_output_if_is_edp (id)) {/* * edp_pixclk = edp_dclk > dclk_core
@@ -1609,6 +1610,7 @@ static unsigned long rk3588_calc_cru_cfg(struct vop2_video_port *vp, int id,*/ *if_pixclk_div =K ; *if_dclk_div =K ; + *dclk_out_div =1 ; }else if (vop2_output_if_is_dp (id)) {if (output_mode ==ROCKCHIP_OUT_MODE_YUV420 ) dclk_out_rate = v_pixclk >>3 ;
@@ -1622,6 +1624,8 @@ static unsigned long rk3588_calc_cru_cfg(struct vop2_video_port *vp, int id,return 0 ; } *dclk_out_div = dclk_rate / dclk_out_rate; + *if_pixclk_div =1 ; + *if_dclk_div =1 ; }else if (vop2_output_if_is_mipi (id)) { if_pixclk_rate = dclk_core_rate /K ;/*
@@ -1643,8 +1647,12 @@ static unsigned long rk3588_calc_cru_cfg(struct vop2_video_port *vp, int id,* mipi pixclk == dclk_out */ *if_pixclk_div =1 ; + *if_dclk_div =1 ; }else if (vop2_output_if_is_dpi (id)) { dclk_rate = v_pixclk; + *dclk_out_div =1 ; + *if_pixclk_div =1 ; + *if_dclk_div =1 ; } *dclk_core_div = dclk_rate / dclk_core_rate;
Signature · 1 line
2.55.0
Re: [PATCH v3 2/8] drm/rockchip: vop2: Don't use uninitialised dividers on RK3588
Quoted 50 lines · On 11/14/2026 12:39 AM, Arun Iyengar via B4 Relay wrote:
From: Arun Iyengar <[email protected]>
rk3588_calc_cru_cfg()converts all four dividers withilog2(), but every interface only sets the ones it uses:dclk_out_divis left uninitialised for HDMI, eDP and DPI,if_dclk_divfor DP, MIPI and DPI, andif_pixclk_divfor DP and DPI. For HDMI and eDP the uninitialiseddclk_out_divis then written toRK3588_VP_CLK_CTRL.Set the dividers an interface doesn't use to 1.
Fixes 5a028e8f062f ("drm/rockchip: vop2: Add support for rk3588")Suggested-by Damon Ding <[email protected]>Signed-off-by Arun Iyengar <[email protected]>--- drivers/gpu/drm/rockchip/rockchip_vop2_reg.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/gpu/drm/rockchip/rockchip_vop2_reg.c +4
-0@@ -1597,6 +1597,7 @@ static unsigned long rk3588_calc_cru_cfg(struct vop2_video_port *vp, int id,*/ *if_pixclk_div =2 ; *if_dclk_div =4 ; + *dclk_out_div =1 ; }else if (vop2_output_if_is_edp (id)) {/* * edp_pixclk = edp_dclk > dclk_core @@ -1609,6 +1610,7 @@ static unsigned long rk3588_calc_cru_cfg(struct vop2_video_port *vp, int id,*/ *if_pixclk_div =K ; *if_dclk_div =K ; + *dclk_out_div =1 ; }else if (vop2_output_if_is_dp (id)) {if (output_mode ==ROCKCHIP_OUT_MODE_YUV420 ) dclk_out_rate = v_pixclk >>3 ;@@ -1622,6 +1624,8 @@ static unsigned long rk3588_calc_cru_cfg(struct vop2_video_port *vp, int id,return 0 ; } *dclk_out_div = dclk_rate / dclk_out_rate; + *if_pixclk_div =1 ; + *if_dclk_div =1 ; }else if (vop2_output_if_is_mipi (id)) { if_pixclk_rate = dclk_core_rate /K ;/* @@ -1643,8 +1647,12 @@ static unsigned long rk3588_calc_cru_cfg(struct vop2_video_port *vp, int id,* mipi pixclk == dclk_out */
drivers/gpu/drm/rockchip/rockchip_vop2_reg.c static unsigned long rk3588_calc_cru_cfg(struct vop2_video_port *vp, int id, · line 1658
Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_vop2_reg.c +4
-0*if_pixclk_div =1 ; + *if_dclk_div =1 ; }else if (vop2_output_if_is_dpi (id)) { dclk_rate = v_pixclk; + *dclk_out_div =1 ; + *if_pixclk_div =1 ; + *if_dclk_div =1 ; } *dclk_core_div = dclk_rate / dclk_core_rate;
Best regards,
Damon
PATCH v3 3/8 drm/rockchip: vop2: Fix the HDMI sync polarity on RK3588
In reply to Arun Iyengarrk3588_get_hdmi_pol() is passed the POLFLAG bits of the mode but tests them as DRM mode flags, so the HDMI sync polarity bits in GRF_VO1_CON0 come out wrong: +HSync/+VSync modes get one of them set and -HSync/-VSync modes none.
The bits are set for a negative sync. Test the POLFLAG bits instead.
--- drivers/gpu/drm/rockchip/rockchip_vop2_reg.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/rockchip/rockchip_vop2_reg.c +4 -3
@@ -1683,12 +1683,13 @@ static u32 rk3588_get_mipi_port_mux(int vp_id)return 0 ; } -static u32 rk3588_get_hdmi_pol (u32 flags) +/* The sync polarity bits in GRF_VO1_CON0 are set for a negative sync */ +static u32 rk3588_get_hdmi_pol (u32 polflags) {u32 val; - val = (flags &DRM_MODE_FLAG_NHSYNC ) ?BIT (HSYNC_POSITIVE ) :0 ; - val |= (flags &DRM_MODE_FLAG_NVSYNC ) ?BIT (VSYNC_POSITIVE ) :0 ; + val = (polflags &BIT (HSYNC_POSITIVE )) ?0 :BIT (HSYNC_POSITIVE ); + val |= (polflags &BIT (VSYNC_POSITIVE )) ?0 :BIT (VSYNC_POSITIVE );return val; }
Signature · 1 line
2.55.0
PATCH v3 4/8 drm/rockchip: vop2: Fix the HDMI sync polarity bit order on RK3588
In reply to Arun IyengarIn GRF_VO1_CON0 the HDMI vsync polarity bit comes before the hsync one (bits 5 and 6 for HDMI0, 7 and 8 for HDMI1), but rk3588_get_hdmi_pol() puts hsync first. Modes with mixed sync polarities go out with both syncs inverted: the HDMI controller sees 1920x1080@144 +HSync -VSync as -HSync +VSync in VIDEO_INTERFACE_STATUS0.
--- drivers/gpu/drm/rockchip/rockchip_vop2_reg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/rockchip/rockchip_vop2_reg.c +3 -3
@@ -1683,13 +1683,13 @@ static u32 rk3588_get_mipi_port_mux(int vp_id)return 0 ; } -/* The sync polarity bits in GRF_VO1_CON0 are set for a negative sync */ +/* GRF_VO1_CON0: vsync bit below the hsync bit, each set for a negative sync */ static u32 rk3588_get_hdmi_pol (u32 polflags) {u32 val; - val = (polflags &BIT (HSYNC_POSITIVE )) ?0 :BIT (HSYNC_POSITIVE ); - val |= (polflags &BIT (VSYNC_POSITIVE )) ?0 :BIT (VSYNC_POSITIVE ); + val = (polflags &BIT (VSYNC_POSITIVE )) ?0 :BIT (0 ); + val |= (polflags &BIT (HSYNC_POSITIVE )) ?0 :BIT (1 );return val; }
Signature · 1 line
2.55.0
Re: [PATCH v3 4/8] drm/rockchip: vop2: Fix the HDMI sync polarity bit order on RK3588
Hi Arun,
Quoted 26 lines · On 11/14/2026 12:39 AM, Arun Iyengar via B4 Relay wrote:
From: Arun Iyengar <[email protected]>
In
GRF_VO1_CON0the HDMI vsync polarity bit comes before the hsync one (bits 5 and 6 for HDMI0, 7 and 8 for HDMI1), butrk3588_get_hdmi_pol()puts hsync first. Modes with mixed sync polarities go out with both syncs inverted: the HDMI controller sees 1920x1080@144 +HSync -VSync as -HSync +VSync inVIDEO_INTERFACE_STATUS0.Fixes 5a028e8f062f ("drm/rockchip: vop2: Add support for rk3588")Signed-off-by Arun Iyengar <[email protected]>--- drivers/gpu/drm/rockchip/rockchip_vop2_reg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/gpu/drm/rockchip/rockchip_vop2_reg.c +1
-1@@ -1683,13 +1683,13 @@ static u32 rk3588_get_mipi_port_mux(int vp_id)return 0 ; } -/* The sync polarity bits in GRF_VO1_CON0 are set for a negative sync */ +/* GRF_VO1_CON0: vsync bit below the hsync bit, each set for a negative sync */ static u32 rk3588_get_hdmi_pol (u32 polflags)
drivers/gpu/drm/rockchip/rockchip_vop2_reg.c static u32 rk3588_get_mipi_port_mux(int vp_id) · line 1695
Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_vop2_reg.c +2
-2{u32 val; - val = (polflags &BIT (HSYNC_POSITIVE )) ?0 :BIT (HSYNC_POSITIVE ); - val |= (polflags &BIT (VSYNC_POSITIVE )) ?0 :BIT (VSYNC_POSITIVE ); + val = (polflags &BIT (VSYNC_POSITIVE )) ?0 :BIT (0 ); + val |= (polflags &BIT (HSYNC_POSITIVE )) ?0 :BIT (1 );return val; }
Oh, this is a good catch. I verified the RK3588 HDMI sync polarity bits are arranged differently from other interfaces.
Would it make sense to add two macros for these bits under RK3588_GRF_VO1_CON0 in rockchip_drm_vop2.h:
#define RK3588_HDMI_VSYNC_INVERT BIT(0)
#define RK3588_HDMI_HSYNC_INVERT BIT(1)
rather than using raw BIT(0) and BIT(1)?
Best regards,
Damon
PATCH v3 5/8 drm/rockchip: vop2: Only accept AFBC YTR for 8 bit RGB on RK3588
In reply to Arun IyengarAccording to the TRM, the AFBC decoder of the RK3588 Cluster windows supports the lossless colour transform (YTR) only for the 8 bit RGB formats. An RGB565 buffer with YTR gives a black picture and POST_BUF_EMPTY, while the same buffer without YTR displays fine.
Don't accept YTR for any other format on RK3588.
--- drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +5 -0
@@ -404,6 +404,11 @@ static bool rockchip_vop2_mod_supported(struct drm_plane *plane, u32 format,if (vop2_convert_afbc_format (format) ==VOP2_AFBC_FMT_INVALID )return false; +if (vop2->version ==VOP_VERSION_RK3588 && (modifier &AFBC_FORMAT_MOD_YTR ) && +vop2_convert_afbc_format (format) !=VOP2_AFBC_FMT_ARGB8888 && +vop2_convert_afbc_format (format) !=VOP2_AFBC_FMT_RGB888 ) +return false; +/* Different windows have different format/modifier support */ for (i =0 ; i < plane->modifier_count; i++) {if (plane->modifiers[i] == modifier)
Signature · 1 line
2.55.0
Re: [PATCH v3 5/8] drm/rockchip: vop2: Only accept AFBC YTR for 8 bit RGB on RK3588
Hi Arun,
Quoted 22 lines · On 11/14/2026 12:39 AM, Arun Iyengar via B4 Relay wrote:
From: Arun Iyengar <[email protected]>
According to the TRM, the AFBC decoder of the RK3588 Cluster windows supports the lossless colour transform (YTR) only for the 8 bit RGB formats. An RGB565 buffer with YTR gives a black picture and
POST_BUF_EMPTY, while the same buffer without YTR displays fine.Don't accept YTR for any other format on RK3588.
Fixes 5a028e8f062f ("drm/rockchip: vop2: Add support for rk3588")Signed-off-by Arun Iyengar <[email protected]>--- drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +0
-0@@ -404,6 +404,11 @@ static bool rockchip_vop2_mod_supported(struct drm_plane *plane, u32 format,if (vop2_convert_afbc_format (format) ==VOP2_AFBC_FMT_INVALID )
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c static bool rockchip_vop2_mod_supported(struct drm_plane *plane, u32 format, · line 414
Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +5
-0return false; +if (vop2->version ==VOP_VERSION_RK3588 && (modifier &AFBC_FORMAT_MOD_YTR ) && +vop2_convert_afbc_format (format) !=VOP2_AFBC_FMT_ARGB8888 && +vop2_convert_afbc_format (format) !=VOP2_AFBC_FMT_RGB888 ) +return false; +/* Different windows have different format/modifier support */ for (i =0 ; i < plane->modifier_count; i++) {if (plane->modifiers[i] == modifier)
Yes, RK3588 only supports VOP2_AFBC_FMT_ARGB8888/VOP2_AFBC_FMT_RGB888 with AFBC_FORMAT_MOD_YTR.
Shall we move this new check a bit earlier, right after the RK3588 10bpc formats check? Also add a comment and a drm_dbg_kms trace for it.
Best regards,
Damon
PATCH v3 6/8 drm/rockchip: vop2: Find the first mixer of a video port with Esmart3 too
In reply to Arun Iyengarvop2_find_start_mixer_id_for_vp() passes ROCKCHIP_VOP2_ESMART3, the highest window id, as the bit count to for_each_set_bit(), so Esmart3 is never found and a video port whose bottom layer is Esmart3 programs the mixers of other video ports.
Add ROCKCHIP_VOP2_MAX_LAYER_ID after the last window id and search up to it.
--- drivers/gpu/drm/rockchip/rockchip_drm_vop2.h | 1 + drivers/gpu/drm/rockchip/rockchip_vop2_reg.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop2.h +1 -0
@@ -805,6 +805,7 @@ enum vop2_layer_phy_id {ROCKCHIP_VOP2_CLUSTER3 ,ROCKCHIP_VOP2_ESMART2 ,ROCKCHIP_VOP2_ESMART3 , +ROCKCHIP_VOP2_MAX_LAYER_ID , ROCKCHIP_VOP2_PHY_ID_INVALID = -1, };
drivers/gpu/drm/rockchip/rockchip_vop2_reg.c +1 -1
@@ -1882,7 +1882,7 @@ static int vop2_find_start_mixer_id_for_vp(struct vop2_video_port *vp)for (i =0 ; i <31 ; i +=4 ) { match = false; -for_each_set_bit (phys_id, &win_mask,ROCKCHIP_VOP2_ESMART3 ) { +for_each_set_bit (phys_id, &win_mask,ROCKCHIP_VOP2_MAX_LAYER_ID ) { win =vop2_find_win_by_phys_id (vop2, phys_id);if (win->data->layer_sel_id[vp->id] == ((layer_sel >> i) &0xf )) { match = true;
Signature · 1 line
2.55.0
PATCH v3 7/8 drm/rockchip: vop2: Keep the other LUT_PORT_SEL fields on gamma LUT updates
In reply to Arun IyengarOn RK3588 the gamma LUT update writes the whole LUT_PORT_SEL register to select the write port, which clears the dclk source selection of video ports 0 and 2 and the VP0/VP1 merge enable held in the same register.
Only update the write select field.
--- drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +3 -2
@@ -1621,8 +1621,9 @@ static void vop2_crtc_atomic_set_gamma_seamless(struct vop2 *vop2,struct vop2_video_port *vp, struct drm_crtc *crtc) { -vop2_writel (vop2 ,RK3568_LUT_PORT_SEL , - FIELD_PREP(RK3588_LUT_PORT_SEL__GAMMA_AHB_WRITE_SEL, vp->id)); + regmap_update_bits(vop2->map, RK3568_LUT_PORT_SEL, +RK3588_LUT_PORT_SEL__GAMMA_AHB_WRITE_SEL , + FIELD_PREP(RK3588_LUT_PORT_SEL__GAMMA_AHB_WRITE_SEL, vp->id));vop2_vp_dsp_lut_enable (vp);vop2_crtc_write_gamma_lut (vop2, crtc);vop2_vp_dsp_lut_update_enable (vp);
Signature · 1 line
2.55.0
PATCH v3 8/8 drm/rockchip: vop2: Fix the AFBC offsets of a source that starts inside a superblock
In reply to Arun IyengarFor an AFBC source that starts inside a superblock, AFBC_TILE_NUM misses the first, partial superblock column, and the transform offset is the whole x position (truncated to 8 bits) instead of the offset inside the superblock.
Count the columns from the first one the source touches and take the x offset modulo the superblock width, as the vendor kernel does.
--- drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +5 -5
@@ -431,7 +431,7 @@ static bool vop2_half_block_enable(struct drm_plane_state *pstate) }static u32 vop2_afbc_transform_offset (struct drm_plane_state *pstate, -bool afbc_half_block_en) +bool afbc_half_block_en,u32 block_w) {struct drm_rect *src = &pstate->src;struct drm_framebuffer *fb = pstate->fb;
@@ -479,7 +479,7 @@ static u32 vop2_afbc_transform_offset(struct drm_plane_state *pstate, ty = act_yoffset;break ;case DRM_MODE_REFLECT_Y : - tx = act_xoffset; + tx = act_xoffset % block_w; ty = bottom_crop_line_num - act_yoffset;break ;case DRM_MODE_ROTATE_90 :
@@ -491,7 +491,7 @@ static u32 vop2_afbc_transform_offset(struct drm_plane_state *pstate, ty = vir_width - width - act_xoffset;break ;case 0 : - tx = act_xoffset; + tx = act_xoffset % block_w; ty = act_yoffset;break ; }
@@ -1433,7 +1433,7 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,if (fb->modifier &AFBC_FORMAT_MOD_YTR ) afbc_format |= (1 <<4 ); - afbc_tile_num =ALIGN (src_w, block_w) / block_w; + afbc_tile_num =ALIGN (src_w + (src->x1 >>16 ) % block_w, block_w) / block_w;/* * AFBC pic_vir_width is count by pixel, this is different
@@ -1484,7 +1484,7 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,vop2_win_write (win,VOP2_WIN_AFBC_PLD_OFFSET , yrgb_mst); } - transform_offset =vop2_afbc_transform_offset (pstate, half_block_en); + transform_offset =vop2_afbc_transform_offset (pstate, half_block_en, block_w);vop2_win_write (win,VOP2_WIN_AFBC_HDR_PTR , yrgb_mst);vop2_win_write (win,VOP2_WIN_AFBC_PIC_SIZE , act_info);vop2_win_write (win,VOP2_WIN_TRANSFORM_OFFSET , transform_offset);
Signature · 1 line
2.55.0