Skip to content

Commit ec648d8

Browse files
Andy Yangregkh
authored andcommitted
drm/rockchip: vop2: Use OVL_LAYER_SEL configuration instead of use win_mask calculate used layers
commit d3fe9aa upstream. When there are multiple Video Ports, and only one of them is working (for example, VP1 is working while VP0 is not), in this case, the win_mask of VP0 is 0. However, we have already set the port mux for VP0 according to vp0->nlayers, and at the same time, in the OVL_LAYER_SEL register, there are windows will also be assigned to layers which will map to the inactive VPs. In this situation, vp0->win_mask is zero as it now working, it is more reliable to calculate the used layers based on the configuration of the OVL_LAYER_SEL register. Note: as the configuration of OVL_LAYER_SEL is take effect when the vsync is come, so we use the value backup in vop2->old_layer_sel instead of read OVL_LAYER_SEL directly. Fixes: 3e89a8c ("drm/rockchip: vop2: Fix the update of LAYER/PORT select registers when there are multi display output on rk3588/rk3568") Cc: stable@vger.kernel.org Reported-by: Diederik de Haas <diederik@cknow-tech.com> Closes: https://bugs.kde.org/show_bug.cgi?id=511274 Signed-off-by: Andy Yan <andy.yan@rock-chips.com> Tested-by: Dang Huynh <dang.huynh@mainlining.org> Tested-by: Diederik de Haas <diederik@cknow-tech.com> Signed-off-by: Heiko Stuebner <heiko@sntech.de> Link: https://lore.kernel.org/r/20251112085024.2480111-1-andyshrk@163.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 355d4d4 commit ec648d8

1 file changed

Lines changed: 42 additions & 7 deletions

File tree

drivers/gpu/drm/rockchip/rockchip_vop2_reg.c

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,25 @@ static const struct vop2_regs_dump rk3588_regs_dump[] = {
13691369
},
13701370
};
13711371

1372+
/*
1373+
* phys_id is used to identify a main window(Cluster Win/Smart Win, not
1374+
* include the sub win of a cluster or the multi area) that can do overlay
1375+
* in main overlay stage.
1376+
*/
1377+
static struct vop2_win *vop2_find_win_by_phys_id(struct vop2 *vop2, uint8_t phys_id)
1378+
{
1379+
struct vop2_win *win;
1380+
int i;
1381+
1382+
for (i = 0; i < vop2->data->win_size; i++) {
1383+
win = &vop2->win[i];
1384+
if (win->data->phys_id == phys_id)
1385+
return win;
1386+
}
1387+
1388+
return NULL;
1389+
}
1390+
13721391
static unsigned long rk3568_set_intf_mux(struct vop2_video_port *vp, int id, u32 polflags)
13731392
{
13741393
struct vop2 *vop2 = vp->vop2;
@@ -1842,15 +1861,31 @@ static void vop2_parse_alpha(struct vop2_alpha_config *alpha_config,
18421861
alpha->dst_alpha_ctrl.bits.factor_mode = ALPHA_SRC_INVERSE;
18431862
}
18441863

1845-
static int vop2_find_start_mixer_id_for_vp(struct vop2 *vop2, u8 port_id)
1864+
static int vop2_find_start_mixer_id_for_vp(struct vop2_video_port *vp)
18461865
{
1847-
struct vop2_video_port *vp;
1848-
int used_layer = 0;
1866+
struct vop2 *vop2 = vp->vop2;
1867+
struct vop2_win *win;
1868+
u32 layer_sel = vop2->old_layer_sel;
1869+
u32 used_layer = 0;
1870+
unsigned long win_mask = vp->win_mask;
1871+
unsigned long phys_id;
1872+
bool match;
18491873
int i;
18501874

1851-
for (i = 0; i < port_id; i++) {
1852-
vp = &vop2->vps[i];
1853-
used_layer += hweight32(vp->win_mask);
1875+
for (i = 0; i < 31; i += 4) {
1876+
match = false;
1877+
for_each_set_bit(phys_id, &win_mask, ROCKCHIP_VOP2_ESMART3) {
1878+
win = vop2_find_win_by_phys_id(vop2, phys_id);
1879+
if (win->data->layer_sel_id[vp->id] == ((layer_sel >> i) & 0xf)) {
1880+
match = true;
1881+
break;
1882+
}
1883+
}
1884+
1885+
if (!match)
1886+
used_layer += 1;
1887+
else
1888+
break;
18541889
}
18551890

18561891
return used_layer;
@@ -1935,7 +1970,7 @@ static void vop2_setup_alpha(struct vop2_video_port *vp)
19351970
u32 dst_global_alpha = DRM_BLEND_ALPHA_OPAQUE;
19361971

19371972
if (vop2->version <= VOP_VERSION_RK3588)
1938-
mixer_id = vop2_find_start_mixer_id_for_vp(vop2, vp->id);
1973+
mixer_id = vop2_find_start_mixer_id_for_vp(vp);
19391974
else
19401975
mixer_id = 0;
19411976

0 commit comments

Comments
 (0)