]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/vkms: Support setting custom background color
authorCristian Ciocaltea <cristian.ciocaltea@collabora.com>
Tue, 3 Mar 2026 19:24:19 +0000 (21:24 +0200)
committerDaniel Stone <daniels@collabora.com>
Wed, 18 Mar 2026 09:59:57 +0000 (09:59 +0000)
Make use of the BACKGROUND_COLOR CRTC property when filling the
background during blending.  It already defaults to solid black.

Since the internal representation of the pixel color in VKMS relies on
16 bits of precision, use the newly introduced DRM_ARGB64_GET{R|G|B}()
helpers to access the individual components of the background color
property, which is compliant with DRM_FORMAT_ARGB16161616.

It's worth noting the alpha component is ignored, hence non-opaque
background colors are not supported.

Reviewed-by: NĂ­colas F. R. A. Prado <nfraprado@collabora.com>
Tested-by: Diederik de Haas <diederik@cknow-tech.com>
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Link: https://patch.msgid.link/20260303-rk3588-bgcolor-v8-3-fee377037ad1@collabora.com
Signed-off-by: Daniel Stone <daniels@collabora.com>
drivers/gpu/drm/vkms/vkms_composer.c
drivers/gpu/drm/vkms/vkms_crtc.c

index cd85de4ffd03d2c5045fc7e1e471151ca7380c5b..83d217085ad09128ab3afa1c00efa5d6219d95ed 100644 (file)
@@ -475,8 +475,14 @@ static void blend(struct vkms_writeback_job *wb,
 {
        struct vkms_plane_state **plane = crtc_state->active_planes;
        u32 n_active_planes = crtc_state->num_active_planes;
-
-       const struct pixel_argb_u16 background_color = { .a = 0xffff };
+       u64 bgcolor = crtc_state->base.background_color;
+
+       const struct pixel_argb_u16 background_color = {
+               .a = 0xffff,
+               .r = DRM_ARGB64_GETR(bgcolor),
+               .g = DRM_ARGB64_GETG(bgcolor),
+               .b = DRM_ARGB64_GETB(bgcolor),
+       };
 
        int crtc_y_limit = crtc_state->base.mode.vdisplay;
        int crtc_x_limit = crtc_state->base.mode.hdisplay;
index ba2ff353e1a9ac0d64062586242297a6c03c54fa..35ddc553a5e663368754e1b6dd0148d830fe53a8 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
+#include <drm/drm_blend.h>
 #include <drm/drm_managed.h>
 #include <drm/drm_print.h>
 #include <drm/drm_probe_helper.h>
@@ -227,6 +228,8 @@ struct vkms_output *vkms_crtc_init(struct drm_device *dev, struct drm_plane *pri
 
        drm_crtc_enable_color_mgmt(crtc, 0, false, VKMS_LUT_SIZE);
 
+       drm_crtc_attach_background_color_property(crtc);
+
        spin_lock_init(&vkms_out->lock);
        spin_lock_init(&vkms_out->composer_lock);