[PATCH RFC v2 07/18] drm/vkms: Introduce config for plane color encoding
Louis Chauvet
louis.chauvet at bootlin.com
Fri Nov 22 17:20:11 UTC 2024
VKMS driver supports all the color encoding on planes, but for testing it
can be useful to only advertise few of them. This new configuration
interface will allow configuring the color encoding per planes.
Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
---
drivers/gpu/drm/vkms/vkms_config.c | 15 +++++++++++++++
drivers/gpu/drm/vkms/vkms_config.h | 4 ++++
drivers/gpu/drm/vkms/vkms_plane.c | 6 ++----
3 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index 6a2e5f0c580a348effc12b474a7f87dcd4e36642..9f9ebe674f6cbe03ac15e5380e4584c40a8bdea7 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -84,6 +84,11 @@ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_conf
vkms_config_overlay->type = DRM_PLANE_TYPE_OVERLAY;
vkms_config_overlay->supported_rotations = DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK;
vkms_config_overlay->default_rotation = DRM_MODE_ROTATE_0;
+ vkms_config_overlay->supported_color_encoding = BIT(DRM_COLOR_YCBCR_BT601) |
+ BIT(DRM_COLOR_YCBCR_BT709) |
+ BIT(DRM_COLOR_YCBCR_BT2020);
+ vkms_config_overlay->default_color_encoding = DRM_COLOR_YCBCR_BT601;
+
list_add(&vkms_config_overlay->link, &vkms_config->planes);
@@ -125,6 +130,12 @@ bool vkms_config_is_valid(struct vkms_config *config)
config_plane->default_rotation)
return false;
+ // Default color range not in supported color range
+ if ((BIT(config_plane->default_color_encoding) &
+ config_plane->supported_color_encoding) !=
+ BIT(config_plane->default_color_encoding))
+ return false;
+
if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) {
// Multiple primary planes for only one CRTC
if (has_primary)
@@ -160,6 +171,10 @@ static int vkms_config_show(struct seq_file *m, void *data)
seq_printf(m, "\ttype: %d\n", config_plane->type);
seq_printf(m, "\tsupported rotations: 0x%x\n", config_plane->supported_rotations);
seq_printf(m, "\tdefault rotation: 0x%x\n", config_plane->default_rotation);
+ seq_printf(m, "\tsupported color encoding: 0x%x\n",
+ config_plane->supported_color_encoding);
+ seq_printf(m, "\tdefault color encoding: %d\n",
+ config_plane->default_color_encoding);
}
return 0;
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index fd5e0df11647f145d53e71a1b6a244951af3ec0d..6cc9b89a996fe26c04951981cfeff7b603c6aec4 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -32,6 +32,8 @@ struct vkms_config {
* plane is primary.
* @default_rotation: Default rotation that should be used by this plane
* @supported_rotation: Rotation that this plane will support
+ * @default_color_encoding: Default color encoding that should be used by this plane
+ * @supported_color_encoding: Color encoding that this plane will support
* @plane: Internal usage. This pointer should never be considered as valid. It can be used to
* store a temporary reference to a vkms plane during device creation. This pointer is
* not managed by the configuration and must be managed by other means.
@@ -43,6 +45,8 @@ struct vkms_config_plane {
enum drm_plane_type type;
unsigned int default_rotation;
unsigned int supported_rotations;
+ enum drm_color_encoding default_color_encoding;
+ unsigned int supported_color_encoding;
/* Internal usage */
struct vkms_plane *plane;
diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
index 306af498543cbc39b8af3e5b5879f8b3972d5a4a..77704ee2d49d2ce1551f67cab6308dc69b329ef5 100644
--- a/drivers/gpu/drm/vkms/vkms_plane.c
+++ b/drivers/gpu/drm/vkms/vkms_plane.c
@@ -239,12 +239,10 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
config->supported_rotations);
drm_plane_create_color_properties(&plane->base,
- BIT(DRM_COLOR_YCBCR_BT601) |
- BIT(DRM_COLOR_YCBCR_BT709) |
- BIT(DRM_COLOR_YCBCR_BT2020),
+ config->supported_color_encoding,
BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
BIT(DRM_COLOR_YCBCR_FULL_RANGE),
- DRM_COLOR_YCBCR_BT601,
+ config->default_color_encoding,
DRM_COLOR_YCBCR_FULL_RANGE);
return plane;
--
2.47.0
More information about the dri-devel
mailing list