VKMS can render plane in any order. Introduce the appropriate configuration.
Signed-off-by: Louis Chauvet <[email protected]> --- drivers/gpu/drm/vkms/tests/vkms_config_test.c | 3 + drivers/gpu/drm/vkms/vkms_config.c | 21 ++++ drivers/gpu/drm/vkms/vkms_config.h | 142 ++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_plane.c | 11 ++ 4 files changed, 177 insertions(+) diff --git a/drivers/gpu/drm/vkms/tests/vkms_config_test.c b/drivers/gpu/drm/vkms/tests/vkms_config_test.c index d75a6252e4d2..f2b38b436252 100644 --- a/drivers/gpu/drm/vkms/tests/vkms_config_test.c +++ b/drivers/gpu/drm/vkms/tests/vkms_config_test.c @@ -172,6 +172,9 @@ static void vkms_config_test_default_config(struct kunit *test) n_possible_crtcs++; } KUNIT_EXPECT_EQ(test, n_possible_crtcs, 1); + KUNIT_EXPECT_EQ(test, vkms_config_plane_get_zpos_enabled(plane_cfg), false); + // No need to test the other zpos configurations as they are discarded if + // the zpos property is not created. } /* Encoders */ diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 0b975a0d47aa..5da34a3e8114 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -86,6 +86,7 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor, if (IS_ERR(plane_cfg)) goto err_alloc; vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_PRIMARY); + vkms_config_plane_set_zpos_enabled(plane_cfg, false); crtc_cfg = vkms_config_create_crtc(config); if (IS_ERR(crtc_cfg)) @@ -103,6 +104,7 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor, vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_OVERLAY); + vkms_config_plane_set_zpos_enabled(plane_cfg, false); if (vkms_config_plane_attach_crtc(plane_cfg, crtc_cfg)) goto err_alloc; @@ -115,6 +117,7 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor, goto err_alloc; vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_CURSOR); + vkms_config_plane_set_zpos_enabled(plane_cfg, false); if (vkms_config_plane_attach_crtc(plane_cfg, crtc_cfg)) goto err_alloc; @@ -206,6 +209,24 @@ static bool valid_plane_properties(const struct vkms_config *config) drm_info(dev, "Configured default color range is not supported by the plane\n"); return false; } + if (vkms_config_plane_get_zpos_initial(plane_cfg) > + vkms_config_plane_get_zpos_max(plane_cfg)) { + drm_info(dev, "Configured initial zpos value bigger than zpos max\n"); + return false; + } + + if (vkms_config_plane_get_zpos_max(plane_cfg) < + vkms_config_plane_get_zpos_min(plane_cfg)) { + drm_info(dev, "Configured zpos max value smaller than zpos min\n"); + return false; + } + + if (vkms_config_plane_get_zpos_initial(plane_cfg) < + vkms_config_plane_get_zpos_min(plane_cfg)) { + drm_info(dev, "Configured initial zpos value smaller than zpos min\n"); + return false; + } + } return true; } diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 0b7067508e5f..267e45f5a617 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -49,6 +49,11 @@ struct vkms_config { * @supported_color_encoding: Color encoding that this plane will support * @default_color_range: Default color range that should be used by this plane * @supported_color_range: Color range that this plane will support + * @zpos_enable: Enable or disable the zpos property + * @zpos_mutable: Make the zpos property mutable or not (ignored if @zpos_enable is false) + * @zpos_initial: Initial value for zpos property (ignored if @zpos_enable is false) + * @zpos_min: Minimal value for zpos property (ignored if @zpos_enable is false) + * @zpos_max: Maximal value for zpos property (ignored if @zpos_enable is false) */ struct vkms_config_plane { struct list_head link; @@ -65,6 +70,11 @@ struct vkms_config_plane { u32 *supported_formats; unsigned int supported_formats_count; struct xarray possible_crtcs; + bool zpos_enabled; + bool zpos_mutable; + unsigned int zpos_initial; + unsigned int zpos_min; + unsigned int zpos_max; /* Internal usage */ struct vkms_plane *plane; @@ -477,6 +487,138 @@ vkms_config_plane_get_name(struct vkms_config_plane *plane_cfg) return plane_cfg->name; } +/** + * vkms_config_plane_set_zpos_enabled() - Enable or disable zpos property for a plane + * @plane_cfg: Plane configuration to modify + * @zpos_enabled: Whether to enable the zpos property + */ +static inline +void vkms_config_plane_set_zpos_enabled(struct vkms_config_plane *plane_cfg, + bool zpos_enabled) +{ + plane_cfg->zpos_enabled = zpos_enabled; +} + +/** + * vkms_config_plane_set_zpos_mutable() - Set whether zpos property is mutable + * @plane_cfg: Plane configuration to modify + * @zpos_mutable: Whether the zpos property should be mutable + */ +static inline +void vkms_config_plane_set_zpos_mutable(struct vkms_config_plane *plane_cfg, + bool zpos_mutable) +{ + plane_cfg->zpos_mutable = zpos_mutable; +} + +/** + * vkms_config_plane_set_zpos_initial() - Set the initial zpos value + * @plane_cfg: Plane configuration to modify + * @zpos_initial: Initial zpos value + */ +static inline +void vkms_config_plane_set_zpos_initial(struct vkms_config_plane *plane_cfg, + unsigned int zpos_initial) +{ + plane_cfg->zpos_initial = zpos_initial; +} + +/** + * vkms_config_plane_set_zpos_min() - Set the minimum zpos value + * @plane_cfg: Plane configuration to modify + * @zpos_min: Minimum zpos value + */ +static inline +void vkms_config_plane_set_zpos_min(struct vkms_config_plane *plane_cfg, + unsigned int zpos_min) +{ + plane_cfg->zpos_min = zpos_min; +} + +/** + * vkms_config_plane_set_zpos_max() - Set the maximum zpos value + * @plane_cfg: Plane configuration to modify + * @zpos_max: Maximum zpos value + * + * Sets the maximum allowed value for the zpos property. This setting is + * ignored if zpos is disabled. + */ +static inline +void vkms_config_plane_set_zpos_max(struct vkms_config_plane *plane_cfg, + unsigned int zpos_max) +{ + plane_cfg->zpos_max = zpos_max; +} + +/** + * vkms_config_plane_get_zpos_enabled() - Check if zpos property is enabled + * @plane_cfg: Plane configuration to check + * + * Returns: + * True if the zpos property is enabled for this plane, false otherwise. + */ +static inline +bool vkms_config_plane_get_zpos_enabled(struct vkms_config_plane *plane_cfg) +{ + return plane_cfg->zpos_enabled; +} + +/** + * vkms_config_plane_get_zpos_mutable() - Check if zpos property is mutable + * @plane_cfg: Plane configuration to check + * + * Returns: + * True if the zpos property is mutable for this plane, false otherwise. + * Returns false if zpos is disabled. + */ +static inline +bool vkms_config_plane_get_zpos_mutable(struct vkms_config_plane *plane_cfg) +{ + return plane_cfg->zpos_mutable; +} + +/** + * vkms_config_plane_get_zpos_initial() - Get the initial zpos value + * @plane_cfg: Plane configuration to check + * + * Returns: + * The initial zpos value for this plane. The return value is undefined if + * zpos is disabled. + */ +static inline +unsigned int vkms_config_plane_get_zpos_initial(struct vkms_config_plane *plane_cfg) +{ + return plane_cfg->zpos_initial; +} + +/** + * vkms_config_plane_get_zpos_min() - Get the minimum zpos value + * @plane_cfg: Plane configuration to check + * + * Returns: + * The minimum allowed zpos value for this plane. The return value is undefined + * if zpos is disabled. + */ +static inline +unsigned int vkms_config_plane_get_zpos_min(struct vkms_config_plane *plane_cfg) +{ + return plane_cfg->zpos_min; +} + +/** + * vkms_config_plane_get_zpos_max() - Get the maximum zpos value + * @plane_cfg: Plane configuration to check + * + * Returns: + * The maximum allowed zpos value for this plane. The return value is undefined + * if zpos is disabled. + */ +static inline +unsigned int vkms_config_plane_get_zpos_max(struct vkms_config_plane *plane_cfg) +{ + return plane_cfg->zpos_max; +} + /** * vkms_config_plane_attach_crtc - Attach a plane to a CRTC * @plane_cfg: Plane to attach diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 0414865915d8..51f6372a6f72 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -209,5 +209,16 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, vkms_config_plane_get_default_color_encoding(config), vkms_config_plane_get_default_color_range(config)); + if (vkms_config_plane_get_zpos_enabled(config)) { + if (vkms_config_plane_get_zpos_mutable(config)) + drm_plane_create_zpos_property(&plane->base, + vkms_config_plane_get_zpos_initial(config), + vkms_config_plane_get_zpos_min(config), + vkms_config_plane_get_zpos_max(config)); + else + drm_plane_create_zpos_immutable_property(&plane->base, + vkms_config_plane_get_zpos_initial(config)); + } + return plane; } -- 2.51.0
