From: Jani Nikula <jani.nikula@linux.intel.com>
To: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>,
intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 1/2] drm/i915/color: Add function to load degamma LUT in MTL
Date: Mon, 26 Jun 2023 15:21:37 +0300 [thread overview]
Message-ID: <87mt0mv2ge.fsf@intel.com> (raw)
In-Reply-To: <20230626055444.1113796-2-chaitanya.kumar.borah@intel.com>
On Mon, 26 Jun 2023, Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com> wrote:
> MTL onwards Degamma LUT/PRE-CSC LUT precision has been increased from
> 16 bits to 24 bits. Currently, drm framework only supports LUTs up to 16
> bit precision. Until a new uapi comes along to support higher bitdepth,
> upscale the values sent from userland to 24 bit before writing into the
> HW to continue supporting degamma on MTL.
>
> Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
> ---
> drivers/gpu/drm/i915/display/intel_color.c | 42 ++++++++++++++++++++--
> 1 file changed, 40 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_color.c b/drivers/gpu/drm/i915/display/intel_color.c
> index 8966e6560516..25c73e2e6fa3 100644
> --- a/drivers/gpu/drm/i915/display/intel_color.c
> +++ b/drivers/gpu/drm/i915/display/intel_color.c
> @@ -1498,6 +1498,38 @@ static void glk_load_degamma_lut(const struct intel_crtc_state *crtc_state,
> ilk_lut_write(crtc_state, PRE_CSC_GAMC_INDEX(pipe), 0);
> }
>
> +static void mtl_load_degamma_lut(const struct intel_crtc_state *crtc_state,
> + const struct drm_property_blob *blob)
> +{
> + struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> + struct drm_i915_private *i915 = to_i915(crtc->base.dev);
> + struct drm_color_lut *degamma_lut = blob->data;
> + enum pipe pipe = crtc->pipe;
> + int i, lut_size = drm_color_lut_size(blob);
> +
> + /*
> + * When setting the auto-increment bit, the hardware seems to
> + * ignore the index bits, so we need to reset it to index 0
> + * separately.
> + */
> + intel_de_write_fw(i915, PRE_CSC_GAMC_INDEX(pipe), 0);
> + intel_de_write_fw(i915, PRE_CSC_GAMC_INDEX(pipe),
> + PRE_CSC_GAMC_AUTO_INCREMENT);
> +
> + for (i = 0; i < lut_size; i++) {
> + u64 word = mul_u32_u32(degamma_lut[i].green, (1 << 24)) / (1 << 16);
> + u32 lut_val = (word & 0xffffff);
> +
> + intel_de_write_fw(i915, PRE_CSC_GAMC_DATA(pipe),
> + lut_val);
> + }
> + /* Clamp values > 1.0. */
> + while (i++ < glk_degamma_lut_size(i915))
> + intel_de_write_fw(i915, PRE_CSC_GAMC_DATA(pipe), 1 << 24);
> +
> + intel_de_write_fw(i915, PRE_CSC_GAMC_INDEX(pipe), 0);
> +}
Please adjust glk_load_degamma_lut() instead of copy-pasting the entire
thing with small modifications. One of which is breaking dsb use.
You'll probably also want to add small conversion helpers between 16 and
24 bits instead of doing them inline.
BR,
Jani.
> +
> static void glk_load_luts(const struct intel_crtc_state *crtc_state)
> {
> const struct drm_property_blob *pre_csc_lut = crtc_state->pre_csc_lut;
> @@ -1635,11 +1667,17 @@ icl_program_gamma_multi_segment(const struct intel_crtc_state *crtc_state)
>
> static void icl_load_luts(const struct intel_crtc_state *crtc_state)
> {
> + struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> + struct drm_i915_private *i915 = to_i915(crtc->base.dev);
> const struct drm_property_blob *pre_csc_lut = crtc_state->pre_csc_lut;
> const struct drm_property_blob *post_csc_lut = crtc_state->post_csc_lut;
>
> - if (pre_csc_lut)
> - glk_load_degamma_lut(crtc_state, pre_csc_lut);
> + if (pre_csc_lut) {
> + if (DISPLAY_VER(i915) >= 14)
> + mtl_load_degamma_lut(crtc_state, pre_csc_lut);
> + else
> + glk_load_degamma_lut(crtc_state, pre_csc_lut);
> + }
>
> switch (crtc_state->gamma_mode & GAMMA_MODE_MODE_MASK) {
> case GAMMA_MODE_MODE_8BIT:
--
Jani Nikula, Intel Open Source Graphics Center
next prev parent reply other threads:[~2023-06-26 12:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-26 5:54 [Intel-gfx] [PATCH 0/2] MTL Degamma implementation Chaitanya Kumar Borah
2023-06-26 5:54 ` [Intel-gfx] [PATCH 1/2] drm/i915/color: Add function to load degamma LUT in MTL Chaitanya Kumar Borah
2023-06-26 12:21 ` Jani Nikula [this message]
2023-07-10 13:46 ` Borah, Chaitanya Kumar
2023-06-26 5:54 ` [Intel-gfx] [PATCH 2/2] drm/i915/color: For MTL convert 24 bit lut values to 16 bit Chaitanya Kumar Borah
2023-06-26 12:23 ` Jani Nikula
2023-07-10 13:47 ` Borah, Chaitanya Kumar
2023-06-26 8:27 ` [Intel-gfx] ✓ Fi.CI.BAT: success for MTL Degamma implementation Patchwork
2023-06-26 14:06 ` [Intel-gfx] ✗ Fi.CI.IGT: 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=87mt0mv2ge.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=chaitanya.kumar.borah@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/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