From: Arun Iyengar <[email protected]>

Damon Ding asked for POST_BUF_EMPTY to be fixed in the layer setup. On
RK3588 Cluster0/1 fetch through AXI0 and Cluster2/3 through AXI1. Each
video port takes the first free primary window, so VP0 and VP2 get
Cluster0 and Cluster1, both on AXI0. A 4K120 and a 4K60 XR24 primary
need about 6 GB/s there, one port delivers about 4.5 GB/s, and VP0
underflows in every frame. aclk_vop at 750 or 850 MHz is the same.

On RK3588 give VP N Cluster N as primary plane. Boards that skip a lower
video port get a different primary: without VP1, VP2 gets Cluster2
instead of Cluster1. VP0 and VP1 still share AXI0, and overlay planes
can still go on any video port. RK3568 and RK3576 are unchanged.

A skipped cluster would default below VP2's primary, so give primary
planes the lowest default zpos.

Signed-off-by: Arun Iyengar <[email protected]>
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index bbe86aecf9039..4d054c41baca1 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -2526,7 +2526,7 @@ static irqreturn_t vop2_isr(int irq, void *data)
 }
 
 static int vop2_plane_init(struct vop2 *vop2, struct vop2_win *win,
-                          unsigned long possible_crtcs)
+                          unsigned long possible_crtcs, unsigned int zpos)
 {
        const struct vop2_win_data *win_data = win->data;
        unsigned int blend_caps = BIT(DRM_MODE_BLEND_PIXEL_NONE) |
@@ -2552,7 +2552,7 @@ static int vop2_plane_init(struct vop2 *vop2, struct 
vop2_win *win,
                                                   
win->data->supported_rotations);
        drm_plane_create_alpha_property(&win->base);
        drm_plane_create_blend_mode_property(&win->base, blend_caps);
-       drm_plane_create_zpos_property(&win->base, win->win_id, 0,
+       drm_plane_create_zpos_property(&win->base, zpos, 0,
                                       vop2->registered_num_wins - 1);
 
        return 0;
@@ -2583,6 +2583,11 @@ static bool vop2_is_mirror_win(struct vop2_win *win)
        }
 }
 
+static const u8 rk3588_vp_primary[] = {
+       ROCKCHIP_VOP2_CLUSTER0, ROCKCHIP_VOP2_CLUSTER1,
+       ROCKCHIP_VOP2_CLUSTER2, ROCKCHIP_VOP2_CLUSTER3,
+};
+
 static int vop2_create_crtcs(struct vop2 *vop2)
 {
        const struct vop2_data *vop2_data = vop2->data;
@@ -2594,6 +2599,7 @@ static int vop2_create_crtcs(struct vop2 *vop2)
        struct vop2_win *win;
        u32 possible_crtcs;
        int i, j, nvp, nvps = 0;
+       unsigned int zpos;
        int ret;
 
        for (i = 0; i < vop2_data->nr_vps; i++) {
@@ -2655,13 +2661,17 @@ static int vop2_create_crtcs(struct vop2 *vop2)
                        if (!(win->data->possible_vp_mask & BIT(vp->id)))
                                continue;
 
+                       if (vop2->version == VOP_VERSION_RK3588 &&
+                           win->data->phys_id != rk3588_vp_primary[vp->id])
+                               continue;
+
                        if (vop2_is_mirror_win(win))
                                continue;
 
                        if (win->type == DRM_PLANE_TYPE_PRIMARY) {
                                possible_crtcs = BIT(nvp);
                                vp->primary_plane = win;
-                               ret = vop2_plane_init(vop2, win, 
possible_crtcs);
+                               ret = vop2_plane_init(vop2, win, 
possible_crtcs, nvp);
                                if (ret)
                                        return dev_err_probe(drm->dev, ret,
                                                             "failed to init 
primary plane %s\n",
@@ -2677,6 +2687,7 @@ static int vop2_create_crtcs(struct vop2 *vop2)
        }
 
        /* Register all unused window as overlay plane */
+       zpos = nvp;
        for (i = 0; i < vop2->registered_num_wins; i++) {
                win = &vop2->win[i];
 
@@ -2702,7 +2713,7 @@ static int vop2_create_crtcs(struct vop2 *vop2)
                        nvp++;
                }
 
-               ret = vop2_plane_init(vop2, win, possible_crtcs);
+               ret = vop2_plane_init(vop2, win, possible_crtcs, zpos++);
                if (ret)
                        return dev_err_probe(drm->dev, ret, "failed to init 
overlay plane %s\n",
                                             win->data->name);

-- 
2.55.0


Reply via email to