[PATCH v6 12/15] drm/client: splash: take the background colour from the image source
From: Màxim Pedraza Padilla
Date: Tue Oct 27 2026 - 09:57:26 EST
A logo designed for a light background looks wrong framed in black, and
products that share a board support package differ in their colours as
much as in their logos. The background colour belongs with the image,
so a device tree image takes it from the optional "background-color" of
its node. A value that is not one cell of RGB888 is reported and left
out.
CONFIG_DRM_CLIENT_SPLASH_BACKGROUND_COLOR remains the colour wherever
the source says nothing, as with the BGRT, which carries no colour, and
the BMP loaded as firmware.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Màxim Pedraza Padilla <maximpedraza@xxxxxxxxx>
---
drivers/gpu/drm/clients/Kconfig | 3 ++-
drivers/gpu/drm/clients/drm_splash.c | 33 +++++++++++++++++++++-------
2 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/clients/Kconfig b/drivers/gpu/drm/clients/Kconfig
index 172781bbc2d7..bb5fe5019756 100644
--- a/drivers/gpu/drm/clients/Kconfig
+++ b/drivers/gpu/drm/clients/Kconfig
@@ -104,7 +104,8 @@ config DRM_CLIENT_SPLASH_BACKGROUND_COLOR
default 0x000000
range 0x000000 0xffffff
help
- The splash background color, in RGB888 format.
+ The splash background color, in RGB888 format, unless the image
+ source has its own: a device tree image can carry its color.
config DRM_CLIENT_SPLASH_SRC_DT
bool "Device tree as splash source"
diff --git a/drivers/gpu/drm/clients/drm_splash.c b/drivers/gpu/drm/clients/drm_splash.c
index a50036155763..3f54bec87413 100644
--- a/drivers/gpu/drm/clients/drm_splash.c
+++ b/drivers/gpu/drm/clients/drm_splash.c
@@ -117,6 +117,8 @@ struct drm_splash {
s32 off_x, off_y;
/* One of DRM_MODE_ROTATE_*: turns the image, not the screen */
unsigned int rotation;
+ /* RGB888, from the image source or the kernel's default */
+ u32 bg_color;
};
static struct drm_splash *client_to_drm_splash(struct drm_client_dev *client)
@@ -272,12 +274,23 @@ static void drm_splash_dt_pair(struct drm_splash *splash,
*y = val[1];
}
-/* The optional placement properties of the node, read once */
-static void drm_splash_dt_placement(struct drm_splash *splash,
- struct device_node *np)
+/* The optional properties of the node, read once */
+static void drm_splash_dt_props(struct drm_splash *splash,
+ struct device_node *np)
{
u32 val;
+ /* The colour travels with the image; a bad one is reported */
+ if (of_property_present(np, "background-color")) {
+ if (of_property_count_u32_elems(np, "background-color") != 1 ||
+ of_property_read_u32(np, "background-color", &val) ||
+ val > 0xffffff)
+ drm_warn(splash->client.dev, "splash: %pOF: invalid %s\n",
+ np, "background-color");
+ else
+ splash->bg_color = val;
+ }
+
drm_splash_dt_pair(splash, np, "logo-position", -1, 65535,
&splash->pos_x, &splash->pos_y);
drm_splash_dt_pair(splash, np, "logo-offset", -65535, 65535,
@@ -375,8 +388,8 @@ static bool drm_splash_dt_open(struct drm_splash *splash)
return false;
}
-static void drm_splash_dt_placement(struct drm_splash *splash,
- struct device_node *np)
+static void drm_splash_dt_props(struct drm_splash *splash,
+ struct device_node *np)
{
}
@@ -802,13 +815,17 @@ static int drm_splash_image_load(struct drm_splash *splash, const u8 **img_data,
*/
static enum drm_splash_source drm_splash_pick_source(struct drm_splash *splash)
{
+ /* Unless the source says otherwise, the kernel's default colour */
+ splash->bg_color = CONFIG_DRM_CLIENT_SPLASH_BACKGROUND_COLOR;
+
if (drm_splash_dt_open(splash)) {
- drm_splash_dt_placement(splash, splash->dt_np);
+ drm_splash_dt_props(splash, splash->dt_np);
return DRM_SPLASH_SRC_DT;
}
if (drm_splash_bgrt_available(splash))
return DRM_SPLASH_SRC_BGRT;
+
if (IS_ENABLED(CONFIG_DRM_CLIENT_SPLASH_SRC_BMP))
return DRM_SPLASH_SRC_BMP;
@@ -875,8 +892,8 @@ static void drm_splash_work(struct work_struct *work)
continue;
if (!scanout->bg_drawn) {
- u32 rgb = CONFIG_DRM_CLIENT_SPLASH_BACKGROUND_COLOR;
- u32 color = drm_draw_color_from_xrgb8888(rgb, scanout->format);
+ u32 color = drm_draw_color_from_xrgb8888(splash->bg_color,
+ scanout->format);
/* Only success marks it done: a later pass retries */
ret = drm_splash_fill_solid_color(scanout->buffer, color);
--
2.39.5