From: Jay Liu <jay.liu@mediatek.com>
To: <igt-dev@lists.freedesktop.org>
Cc: Jason-JH Lin <jason-jh.lin@mediatek.com>,
Paul-PL Chen <paul-pl.chen@mediatek.com>,
Nancy Lin <nancy.lin@mediatek.com>,
Singo Chang <singo.chang@mediatek.com>,
Gil Dekel <gildekel@google.com>, Yacoub <markyacoub@chromium.org>,
Sharma Swati2 <swati2.sharma@intel.com>,
<Project_Global_Chrome_Upstream_Group@mediatek.com>,
Jay Liu <jay.liu@mediatek.com>
Subject: [PATCH v5 1/1] tests/kms_color: Add 10-bit color depth support to gamma test for MediaTek
Date: Sat, 6 Jun 2026 17:05:36 +0800 [thread overview]
Message-ID: <20260606090557.8879-2-jay.liu@mediatek.com> (raw)
In-Reply-To: <20260606090557.8879-1-jay.liu@mediatek.com>
MediaTek display hardware has specific color processing requirements that
differ from other vendors. This patch addresses two key aspects:
1. MediaTek devices require a 10-bit color pipeline to achieve bit-accurate
(bit-true) gamma test results. Unlike other devices that work correctly
with 8-bit color depth (DRM_FORMAT_XRGB8888), MediaTek hardware needs
10-bit color depth (DRM_FORMAT_XRGB2101010) to properly validate gamma
LUT operations without precision loss.
2. MediaTek's Gamma LUT maps 10-bit input data (0-1023) to 12-bit output
(0-4095). When gamma correction is disabled, the hardware defaults to
outputting 4092 for maximum input values. To pass the legacy gamma test
which expects consistent behavior, the LUT maximum entry must be set to
0xffd0 (which maps to 4092 in 12-bit) instead of 0xffff. This ensures
the test produces bit-true results matching the hardware behavior.
The test now automatically detects MediaTek devices and applies the
appropriate color depth and LUT configuration.
Signed-off-by: Jay Liu <jay.liu@mediatek.com>
---
tests/kms_color.c | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/tests/kms_color.c b/tests/kms_color.c
index 565edb2dc..dc3432df5 100644
--- a/tests/kms_color.c
+++ b/tests/kms_color.c
@@ -265,6 +265,7 @@ static bool test_pipe_legacy_gamma(data_t *data,
drmModeCrtc *drm_crtc;
uint32_t i, legacy_lut_size;
uint16_t *red_lut, *green_lut, *blue_lut;
+ uint16_t lut_value;
drmModeModeInfo *mode = data->mode;
struct igt_fb fb_modeset, fb;
igt_crc_t crc_fullgamma, crc_fullcolors;
@@ -288,7 +289,7 @@ static bool test_pipe_legacy_gamma(data_t *data,
fb_id = igt_create_fb(data->drm_fd,
mode->hdisplay,
mode->vdisplay,
- DRM_FORMAT_XRGB8888,
+ data->drm_format,
DRM_FORMAT_MOD_LINEAR,
&fb);
igt_assert(fb_id);
@@ -296,7 +297,7 @@ static bool test_pipe_legacy_gamma(data_t *data,
fb_modeset_id = igt_create_fb(data->drm_fd,
mode->hdisplay,
mode->vdisplay,
- DRM_FORMAT_XRGB8888,
+ data->drm_format,
DRM_FORMAT_MOD_LINEAR,
&fb_modeset);
igt_assert(fb_modeset_id);
@@ -321,9 +322,22 @@ static bool test_pipe_legacy_gamma(data_t *data,
paint_gradient_rectangles(data, mode, red_green_blue, &fb);
igt_plane_set_fb(primary, &fb);
+ /*
+ * The MediaTek Gamma LUT maps 10bit input data to 12bit output.
+ * In this test case, the maximum input value is 1023.
+ * When the Gamma function is disabled, the data defaults to a 4092 output.
+ * To achieve bit true results, the Gamma LUT maximum must be set to 4092.
+ * Note that 0xffd0 represents 16-bit, which maps to 4092 in 12-bit depth.
+ */
+ if (is_mtk_device(data->drm_fd))
+ lut_value = 0xffd0;
+ else
+ lut_value = 0xffff;
+
red_lut[0] = green_lut[0] = blue_lut[0] = 0;
for (i = 1; i < legacy_lut_size; i++)
- red_lut[i] = green_lut[i] = blue_lut[i] = 0xffff;
+ red_lut[i] = green_lut[i] = blue_lut[i] = lut_value;
+
igt_assert_eq(drmModeCrtcSetGamma(data->drm_fd, primary->crtc->crtc_id,
legacy_lut_size, red_lut, green_lut, blue_lut), 0);
igt_display_commit(&data->display);
@@ -752,14 +766,17 @@ static void
run_gamma_degamma_tests_for_crtc(data_t *data, igt_crtc_t *crtc,
bool (*test_t)(data_t*, igt_plane_t*))
{
+ bool depth_10bit = is_mtk_device(data->drm_fd);
+
test_setup(data, crtc);
/*
- * We assume an 8bits depth per color for degamma/gamma LUTs
+ * We assume an 8bits or 10bits depth per color for degamma/gamma LUTs
* for CRC checks with framebuffer references.
+ * MediaTek requires 10-bit pipeline for accurate (bit true) color processing.
*/
- data->color_depth = 8;
- data->drm_format = DRM_FORMAT_XRGB8888;
+ data->color_depth = depth_10bit ? 10 : 8;
+ data->drm_format = depth_10bit ? DRM_FORMAT_XRGB2101010 : DRM_FORMAT_XRGB8888;
data->mode = igt_output_get_mode(data->output);
igt_require(crtc_output_combo_valid(data, crtc));
--
2.45.2
next prev parent reply other threads:[~2026-06-06 9:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-06 9:05 [PATCH i-g-t v5 0/1] tests/kms_color: Add 10-bit color depth support to gamma test for MediaTek Jay Liu
2026-06-06 9:05 ` Jay Liu [this message]
2026-06-06 9:50 ` ✓ Xe.CI.BAT: success for " Patchwork
2026-06-06 10:25 ` ✓ i915.CI.BAT: " Patchwork
2026-06-06 16:23 ` ✗ i915.CI.Full: failure " Patchwork
2026-06-06 17:09 ` ✓ Xe.CI.FULL: success " 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=20260606090557.8879-2-jay.liu@mediatek.com \
--to=jay.liu@mediatek.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=gildekel@google.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=jason-jh.lin@mediatek.com \
--cc=markyacoub@chromium.org \
--cc=nancy.lin@mediatek.com \
--cc=paul-pl.chen@mediatek.com \
--cc=singo.chang@mediatek.com \
--cc=swati2.sharma@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