From: Matthew Schwartz <matthew.schwartz@linux.dev>
To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Cc: uma.shankar@intel.com, chaitanya.kumar.borah@intel.com,
Matthew Schwartz <matthew.schwartz@linux.dev>,
Jani Nikula <jani.nikula@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Tvrtko Ursulin <tursulin@ursulin.net>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Suraj Kandpal <suraj.kandpal@intel.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 2/2] drm/i915/color: load the 3D LUT in the order the hardware indexes it
Date: Wed, 18 Nov 2026 11:15:13 -0800 [thread overview]
Message-ID: <20261118191514.2931270-3-matthew.schwartz@linux.dev> (raw)
In-Reply-To: <20261118191514.2931270-1-matthew.schwartz@linux.dev>
The 3D LUT colorop blob is laid out with red as the fastest axis,
index = R + n * (G + n * B). glk_load_lut_3d() writes the blob to
LUT_3D_DATA front to back, but the hardware walks its table with blue as
the fastest axis and red as the slowest. Every entry whose red and blue
coordinates differ lands at the node with the two exchanged.
Measured on Lunar Lake by programming the pipe-bound LUT through
LUT_3D_INDEX and LUT_3D_DATA directly and decoding the pipe CRC of solid
color frames. A table holding each node's own stream position reads back
position B + 17 * G + 289 * R, and an identity table written in that
order reproduces all of 70 sampled colors exactly.
Write the table in hardware order.
Fixes: 65db7a1f9cf7 ("drm/i915/color: Add 3D LUT to color pipeline")
Signed-off-by: Matthew Schwartz <matthew.schwartz@linux.dev>
---
drivers/gpu/drm/i915/display/intel_color.c | 18 +++++++++++++++---
drivers/gpu/drm/i915/display/intel_color.h | 2 ++
.../drm/i915/display/intel_color_pipeline.c | 2 +-
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_color.c b/drivers/gpu/drm/i915/display/intel_color.c
index 742ae471540d..ea4e6c9f0309 100644
--- a/drivers/gpu/drm/i915/display/intel_color.c
+++ b/drivers/gpu/drm/i915/display/intel_color.c
@@ -4112,8 +4112,8 @@ static void glk_load_lut_3d(struct intel_dsb *dsb,
{
struct intel_display *display = to_intel_display(crtc->base.dev);
const struct drm_color_lut32 *lut = blob->data;
- int i, lut_size = drm_color_lut32_size(blob);
enum pipe pipe = crtc->pipe;
+ int r, g, b;
if (!dsb && intel_de_read(display, LUT_3D_CTL(pipe)) & LUT_3D_READY) {
drm_err(display->drm, "[CRTC:%d:%s] 3D LUT not ready, not loading LUTs\n",
@@ -4121,9 +4121,21 @@ static void glk_load_lut_3d(struct intel_dsb *dsb,
return;
}
+ /*
+ * The hardware walks the table with blue as the fastest axis, the
+ * colorop blob with red.
+ */
intel_de_write_dsb(display, dsb, LUT_3D_INDEX(pipe), LUT_3D_AUTO_INCREMENT);
- for (i = 0; i < lut_size; i++)
- intel_de_write_dsb(display, dsb, LUT_3D_DATA(pipe), glk_3dlut_10(&lut[i]));
+ for (r = 0; r < LUT_3D_SIZE; r++) {
+ for (g = 0; g < LUT_3D_SIZE; g++) {
+ for (b = 0; b < LUT_3D_SIZE; b++) {
+ int i = r + LUT_3D_SIZE * (g + LUT_3D_SIZE * b);
+
+ intel_de_write_dsb(display, dsb, LUT_3D_DATA(pipe),
+ glk_3dlut_10(&lut[i]));
+ }
+ }
+ }
intel_de_write_dsb(display, dsb, LUT_3D_INDEX(pipe), 0);
}
diff --git a/drivers/gpu/drm/i915/display/intel_color.h b/drivers/gpu/drm/i915/display/intel_color.h
index 9d11741423ef..02ef30390558 100644
--- a/drivers/gpu/drm/i915/display/intel_color.h
+++ b/drivers/gpu/drm/i915/display/intel_color.h
@@ -18,6 +18,8 @@ struct drm_property_blob;
enum pipe;
enum plane_id;
+#define LUT_3D_SIZE 17
+
void intel_color_init_hooks(struct intel_display *display);
int intel_color_init(struct intel_display *display);
void intel_color_crtc_init(struct intel_crtc *crtc);
diff --git a/drivers/gpu/drm/i915/display/intel_color_pipeline.c b/drivers/gpu/drm/i915/display/intel_color_pipeline.c
index 77f65182e3e3..0c73072819fb 100644
--- a/drivers/gpu/drm/i915/display/intel_color_pipeline.c
+++ b/drivers/gpu/drm/i915/display/intel_color_pipeline.c
@@ -88,7 +88,7 @@ struct intel_colorop *intel_color_pipeline_plane_add_colorop(struct drm_plane *p
break;
case INTEL_PLANE_CB_3DLUT:
ret = drm_plane_colorop_3dlut_init(dev, &colorop->base, plane,
- &intel_colorop_funcs, 17,
+ &intel_colorop_funcs, LUT_3D_SIZE,
DRM_COLOROP_LUT3D_INTERPOLATION_TETRAHEDRAL,
true);
break;
--
2.56.1
prev parent reply other threads:[~2026-11-18 19:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261118191514.2931270-1-matthew.schwartz@linux.dev>
2026-11-18 19:15 ` [RFC PATCH 1/2] drm/i915/color: only let the owning plane program the 3D LUT Matthew Schwartz
2026-11-18 19:15 ` Matthew Schwartz [this message]
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=20261118191514.2931270-3-matthew.schwartz@linux.dev \
--to=matthew.schwartz@linux.dev \
--cc=airlied@gmail.com \
--cc=chaitanya.kumar.borah@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=suraj.kandpal@intel.com \
--cc=tursulin@ursulin.net \
--cc=uma.shankar@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