drm/vkms: zpos
cover drm/vkms: zpos
Hi all,
This patch adds support for the zpos plane prop in the VKMS driver.
It should be applied after the "drm/vkms: add support for multiple overlay planes" series [1] because this new patch takes advantage of the "num_overlay_planes" module parameter to set the maximum and minimum overlay plane zpos.
Thanks in advance,
José Expósito
[1] https://lore.kernel.org/dri-devel/[email protected]/T/
José Expósito (1):
drm/vkms: add zpos plane property
drivers/gpu/drm/vkms/vkms_crtc.c | 3 +-- drivers/gpu/drm/vkms/vkms_drv.c | 1 + drivers/gpu/drm/vkms/vkms_plane.c | 25 +++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/1 drm/vkms: add zpos plane property
Add support for the zpos plane property. Depending on the plane type:
- Primary and cursor planes: Create an immutable zpos property. The primary plane is always at the bottom and the cursor plane is always on the top.
- Overlay planes: Create a mutable zpos property allowing to change their order but always keep them between the primary and cursor planes.
As documented, "vkms_crtc_state.active_planes" must be sorted by zpos. This is achieved by inserting them in the array at their normalized_zpos index.
--- drivers/gpu/drm/vkms/vkms_crtc.c | 3 +-- drivers/gpu/drm/vkms/vkms_drv.c | 1 + drivers/gpu/drm/vkms/vkms_plane.c | 25 +++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-)
drivers/gpu/drm/vkms/vkms_crtc.c +1 -2
@@ -207,7 +207,6 @@ static int vkms_crtc_atomic_check(struct drm_crtc *crtc,return -ENOMEM ; vkms_state->num_active_planes = i; - i =0 ;drm_for_each_plane_mask (plane, crtc->dev, crtc_state->plane_mask) { plane_state =drm_atomic_get_existing_plane_state (crtc_state->state, plane);
@@ -215,7 +214,7 @@ static int vkms_crtc_atomic_check(struct drm_crtc *crtc,if (!plane_state->visible)continue ; - vkms_state->active_planes[i++] = + vkms_state->active_planes[plane_state->normalized_zpos] =to_vkms_plane_state (plane_state); }
drivers/gpu/drm/vkms/vkms_drv.c +1 -0
@@ -157,6 +157,7 @@ static int vkms_modeset_init(struct vkms_device *vkmsdev)* fbdev helpers. We have to go with 0, meaning "pick the default", * which ix XRGB8888 in all cases. */ dev->mode_config.preferred_depth =0 ; + dev->mode_config.normalize_zpos = true; dev->mode_config.helper_private = &vkms_mode_config_helpers;return vkms_output_init (vkmsdev,0 );
drivers/gpu/drm/vkms/vkms_plane.c +25 -0
@@ -81,6 +81,8 @@ static void vkms_plane_reset(struct drm_plane *plane) }__drm_gem_reset_shadow_plane (plane, &vkms_state->base); + vkms_state->base.base.zpos =drm_plane_index (plane); + vkms_state->base.base.normalized_zpos =drm_plane_index (plane); }static const struct drm_plane_funcs vkms_plane_funcs = {
@@ -158,6 +160,24 @@ static const struct drm_plane_helper_funcs vkms_primary_helper_funcs = { DRM_GEM_SHADOW_PLANE_HELPER_FUNCS, }; +static int vkms_plane_create_zpos_property (struct vkms_device *vkmsdev, +struct vkms_plane *plane) +{ +int ret; +unsigned int zpos =drm_plane_index (&plane->base); +int overlay_max_zpos = vkmsdev->config->num_overlay_planes; + +if (plane->base.type ==DRM_PLANE_TYPE_OVERLAY ) { + ret =drm_plane_create_zpos_property (&plane->base, zpos, +1 , overlay_max_zpos); + }else { + ret =drm_plane_create_zpos_immutable_property (&plane->base, + zpos); + } + +return ret; +} +struct vkms_plane *vkms_plane_init (struct vkms_device *vkmsdev,enum drm_plane_type type,int index) {
@@ -166,6 +186,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,struct vkms_plane *plane;const u32 *formats;int nformats; +int ret;switch (type) {case DRM_PLANE_TYPE_PRIMARY :
@@ -195,5 +216,9 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,drm_plane_helper_add (&plane->base, funcs); + ret =vkms_plane_create_zpos_property (vkmsdev, plane); +if (ret) +return ERR_PTR (ret); +return plane; }
Signature · 1 line
2.25.1