From: Maarten Lankhorst <dev@lankhorst.se>
To: intel-xe@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org,
Maarten Lankhorst <dev@lankhorst.se>,
Chandra Konduru <chandra.konduru@intel.com>,
dri-devel@lists.freedesktop.org,
Matt Roper <matthew.d.roper@intel.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Subject: [PATCH] drm/intel/display: Add support for pipe background color (v4)
Date: Tue, 5 May 2026 22:01:34 +0200 [thread overview]
Message-ID: <20260505200133.636584-2-dev@lankhorst.se> (raw)
Gen9 platforms allow CRTC's to be programmed with a background/canvas
color below the programmable planes. Let's expose this as a property to
allow userspace to program a desired value.
This patch is based on earlier work by Chandra Konduru and Matt Roper.
Between 2018 and now, intel/display has changed so much that another
rewrite was necessary.
v2:
- Set initial background color (black) via proper helper function (Bob)
- Fix debugfs output
- General rebasing
v3 (Maarten):
- Rebase on top of recent changes.
v4 (Maarten):
- Complete rewrite based on the solution that went upstream, and
on the new intel color management features.
Cc: Chandra Konduru <chandra.konduru@intel.com>
Cc: dri-devel@lists.freedesktop.org
Co-developed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
Corresponding IGT: https://patchwork.freedesktop.org/series/166016/
drivers/gpu/drm/i915/display/intel_color.c | 47 ++++++++++++-------
drivers/gpu/drm/i915/display/intel_color.h | 3 ++
drivers/gpu/drm/i915/display/intel_crtc.c | 4 ++
drivers/gpu/drm/i915/display/intel_display.c | 5 ++
.../drm/i915/display/intel_display_debugfs.c | 6 +++
.../drm/i915/display/intel_display_types.h | 1 +
.../drm/i915/display/intel_modeset_setup.c | 2 +
7 files changed, 52 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_color.c b/drivers/gpu/drm/i915/display/intel_color.c
index 0531c60e5e5d5..2365cf06cd514 100644
--- a/drivers/gpu/drm/i915/display/intel_color.c
+++ b/drivers/gpu/drm/i915/display/intel_color.c
@@ -1102,19 +1102,37 @@ static void skl_get_config(struct intel_crtc_state *crtc_state)
{
struct intel_display *display = to_intel_display(crtc_state);
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+ u32 color;
crtc_state->gamma_mode = hsw_read_gamma_mode(crtc);
crtc_state->csc_mode = ilk_read_csc_mode(crtc);
+ color = intel_de_read(display, SKL_BOTTOM_COLOR(crtc->pipe));
if (DISPLAY_VER(display) < 35) {
- u32 tmp = intel_de_read(display, SKL_BOTTOM_COLOR(crtc->pipe));
-
- if (tmp & SKL_BOTTOM_COLOR_GAMMA_ENABLE)
+ if (color & SKL_BOTTOM_COLOR_GAMMA_ENABLE)
crtc_state->gamma_enable = true;
- if (tmp & SKL_BOTTOM_COLOR_CSC_ENABLE)
+ if (color & SKL_BOTTOM_COLOR_CSC_ENABLE)
crtc_state->csc_enable = true;
}
+
+ crtc_state->hw.background_color = color & GENMASK(29, 0);
+}
+
+u32 intel_color_hw_background_color(u64 drm_background_color)
+{
+ return (DRM_ARGB64_GETR_BPC(drm_background_color, 10) << 20) |
+ (DRM_ARGB64_GETG_BPC(drm_background_color, 10) << 10) |
+ (DRM_ARGB64_GETB_BPC(drm_background_color, 10));
+}
+
+u64 intel_color_drm_background_color(u32 hw_background_color)
+{
+ uint16_t r = (hw_background_color >> 20) & 0x3ff;
+ uint16_t g = (hw_background_color >> 10) & 0x3ff;
+ uint16_t b = hw_background_color & 0x3ff;
+
+ return DRM_ARGB64_PREP_BPC(0x3ff, r, g, b, 10);
}
static void skl_color_commit_arm(struct intel_dsb *dsb,
@@ -1123,16 +1141,11 @@ static void skl_color_commit_arm(struct intel_dsb *dsb,
struct intel_display *display = to_intel_display(crtc_state);
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
enum pipe pipe = crtc->pipe;
- u32 val = 0;
+ u32 val = crtc_state->hw.background_color;
if (crtc_state->has_psr)
ilk_load_csc_matrix(dsb, crtc_state);
- /*
- * We don't (yet) allow userspace to control the pipe background color,
- * so force it to black, but apply pipe gamma and CSC appropriately
- * so that its handling will match how we program our planes.
- */
if (crtc_state->gamma_enable)
val |= SKL_BOTTOM_COLOR_GAMMA_ENABLE;
if (crtc_state->csc_enable)
@@ -1151,11 +1164,7 @@ static void icl_color_commit_arm(struct intel_dsb *dsb,
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
enum pipe pipe = crtc->pipe;
- /*
- * We don't (yet) allow userspace to control the pipe background color,
- * so force it to black.
- */
- intel_de_write_dsb(display, dsb, SKL_BOTTOM_COLOR(pipe), 0);
+ intel_de_write_dsb(display, dsb, SKL_BOTTOM_COLOR(pipe), crtc_state->hw.background_color);
intel_de_write_dsb(display, dsb, GAMMA_MODE(crtc->pipe), crtc_state->gamma_mode);
@@ -2107,9 +2116,15 @@ int intel_color_check(struct intel_atomic_state *state,
* May need to update pipe gamma enable bits
* when C8 planes are getting enabled/disabled.
*/
- if (!old_crtc_state->c8_planes != !new_crtc_state->c8_planes)
+ if (!old_crtc_state->c8_planes != !new_crtc_state->c8_planes ||
+ old_crtc_state->hw.background_color != new_crtc_state->hw.background_color)
new_crtc_state->uapi.color_mgmt_changed = true;
+ if (DRM_ARGB64_GETA(new_crtc_state->uapi.background_color) != 0xffff) {
+ drm_dbg_kms(display->drm, "New background not completely opaque\n");
+ return -EINVAL;
+ }
+
if (!intel_crtc_needs_color_update(new_crtc_state))
return 0;
diff --git a/drivers/gpu/drm/i915/display/intel_color.h b/drivers/gpu/drm/i915/display/intel_color.h
index c21b9bdf7bb8a..f2cbce57b63d7 100644
--- a/drivers/gpu/drm/i915/display/intel_color.h
+++ b/drivers/gpu/drm/i915/display/intel_color.h
@@ -47,4 +47,7 @@ void intel_color_plane_program_pipeline(struct intel_dsb *dsb,
void intel_color_plane_commit_arm(struct intel_dsb *dsb,
const struct intel_plane_state *plane_state);
bool intel_color_crtc_has_3dlut(struct intel_display *display, enum pipe pipe);
+u32 intel_color_hw_background_color(u64 drm_background_color);
+u64 intel_color_drm_background_color(u32 hw_background_color);
+
#endif /* __INTEL_COLOR_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c b/drivers/gpu/drm/i915/display/intel_crtc.c
index 03de219f7a645..b7600cecafc85 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -7,6 +7,7 @@
#include <linux/slab.h>
#include <drm/drm_atomic_helper.h>
+#include <drm/drm_blend.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_plane.h>
#include <drm/drm_print.h>
@@ -405,6 +406,9 @@ static int __intel_crtc_init(struct intel_display *display, enum pipe pipe)
BIT(DRM_SCALING_FILTER_DEFAULT) |
BIT(DRM_SCALING_FILTER_NEAREST_NEIGHBOR));
+ if (DISPLAY_VER(display) >= 9)
+ drm_crtc_attach_background_color_property(&crtc->base);
+
intel_color_crtc_init(crtc);
intel_drrs_crtc_init(crtc);
intel_crtc_crc_init(crtc);
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 2fa10f8582794..306908f20b5a0 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -4505,6 +4505,8 @@ intel_crtc_copy_uapi_to_hw_state_nomodeset(struct intel_atomic_state *state,
crtc_state->uapi.gamma_lut);
drm_property_replace_blob(&crtc_state->hw.ctm,
crtc_state->uapi.ctm);
+ crtc_state->hw.background_color =
+ intel_color_hw_background_color(crtc_state->uapi.background_color);
}
static void
@@ -4544,6 +4546,7 @@ copy_joiner_crtc_state_nomodeset(struct intel_atomic_state *state,
primary_crtc_state->hw.gamma_lut);
drm_property_replace_blob(&secondary_crtc_state->hw.ctm,
primary_crtc_state->hw.ctm);
+ secondary_crtc_state->hw.background_color = primary_crtc_state->hw.background_color;
secondary_crtc_state->uapi.color_mgmt_changed = primary_crtc_state->uapi.color_mgmt_changed;
}
@@ -5356,6 +5359,8 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
else
PIPE_CONF_CHECK_X(csc_mode);
PIPE_CONF_CHECK_BOOL(gamma_enable);
+
+ PIPE_CONF_CHECK_X(hw.background_color);
PIPE_CONF_CHECK_BOOL(csc_enable);
PIPE_CONF_CHECK_BOOL(wgc_enable);
diff --git a/drivers/gpu/drm/i915/display/intel_display_debugfs.c b/drivers/gpu/drm/i915/display/intel_display_debugfs.c
index 81bef000a4e3e..336ef29d0c5b5 100644
--- a/drivers/gpu/drm/i915/display/intel_display_debugfs.c
+++ b/drivers/gpu/drm/i915/display/intel_display_debugfs.c
@@ -572,6 +572,12 @@ static void intel_crtc_info(struct seq_file *m, struct intel_crtc *crtc)
intel_scaler_info(m, crtc);
+ if (DISPLAY_VER(display) >= 9) {
+ u32 background = crtc_state->hw.background_color;
+
+ seq_printf(m, "\tbackground color (10bpc XRGB210101010): %08x\n", background);
+ }
+
if (crtc_state->joiner_pipes)
seq_printf(m, "\tLinked to 0x%x pipes as a %s\n",
crtc_state->joiner_pipes,
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index c819167618502..aa07be41648c4 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -1034,6 +1034,7 @@ struct intel_crtc_state {
/* logical state of LUTs */
struct drm_property_blob *degamma_lut, *gamma_lut, *ctm;
struct drm_display_mode mode, pipe_mode, adjusted_mode;
+ u32 background_color;
enum drm_scaling_filter scaling_filter;
u8 sharpness_strength;
} hw;
diff --git a/drivers/gpu/drm/i915/display/intel_modeset_setup.c b/drivers/gpu/drm/i915/display/intel_modeset_setup.c
index 4c646b1bd0ee0..d3b2433eae791 100644
--- a/drivers/gpu/drm/i915/display/intel_modeset_setup.c
+++ b/drivers/gpu/drm/i915/display/intel_modeset_setup.c
@@ -334,6 +334,8 @@ static void intel_crtc_copy_hw_to_uapi_state(struct intel_crtc_state *crtc_state
crtc_state->uapi.adjusted_mode = crtc_state->hw.adjusted_mode;
crtc_state->uapi.scaling_filter = crtc_state->hw.scaling_filter;
crtc_state->uapi.sharpness_strength = crtc_state->hw.sharpness_strength;
+ crtc_state->uapi.background_color =
+ intel_color_drm_background_color(crtc_state->hw.background_color);
if (DISPLAY_INFO(display)->color.degamma_lut_size) {
/* assume 1:1 mapping */
--
2.53.0
next reply other threads:[~2026-05-05 20:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-05 20:01 Maarten Lankhorst [this message]
2026-05-05 20:07 ` ✗ CI.checkpatch: warning for drm/intel/display: Add support for pipe background color (v4) Patchwork
2026-05-05 20:08 ` ✓ CI.KUnit: success " Patchwork
2026-05-07 15:16 ` ✗ CI.checkpatch: warning for drm/intel/display: Add support for pipe background color (v4) (rev2) Patchwork
2026-05-07 15:17 ` ✓ CI.KUnit: success " Patchwork
2026-05-07 16:31 ` ✓ Xe.CI.BAT: " Patchwork
2026-05-08 2:19 ` ✗ Xe.CI.FULL: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260505200133.636584-2-dev@lankhorst.se \
--to=dev@lankhorst.se \
--cc=chandra.konduru@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.d.roper@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox