From: "Nautiyal, Ankit K" <ankit.k.nautiyal@intel.com>
To: Nemesa Garg <nemesa.garg@intel.com>,
<intel-gfx@lists.freedesktop.org>,
<intel-xe@lists.freedesktop.org>,
<dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 05/10] drm/i915/display: Compute the scaler coefficients
Date: Thu, 9 Oct 2025 16:22:10 +0530 [thread overview]
Message-ID: <35451049-3933-431a-9603-aec868d1d105@intel.com> (raw)
In-Reply-To: <20251001063500.1259687-6-nemesa.garg@intel.com>
On 10/1/2025 12:04 PM, Nemesa Garg wrote:
> The sharpness property requires the use of one of the scaler
> so need to set the sharpness scaler coefficient values.
> These values are based on experiments and vary for different
> tap value/win size. These values are normalized by taking the
> sum of all values and then dividing each value with a sum.
>
> Add helper to compute and set the scaler coefficients.
>
> v2: Fix ifndef header naming issue reported by kernel test robot
> v3: Rename file name[Arun]
> Replace array size number with macro[Arun]
> v4: Correct the register format[Jani]
> Add brief comment and expalin about file[Jani]
> Remove coefficient value from crtc_state[Jani]
> v5: Fix build issue
> v6: Add new function for writing coefficients[Ankit]
> v7: Add cooments and add a scaler id check [Ankit]
> v8: Remove casf_enable from here[Ankit]
> v9: Removed REG and use shift operator[Jani]
> v10: Remove filter macros
> v11: Add casf_write_coeff funtion to casf_enable
>
> Signed-off-by: Nemesa Garg <nemesa.garg@intel.com>
Reviewed-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
> ---
> drivers/gpu/drm/i915/display/intel_casf.c | 99 +++++++++++++++++++
> drivers/gpu/drm/i915/display/intel_casf.h | 1 +
> .../drm/i915/display/intel_display_types.h | 8 ++
> 3 files changed, 108 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_casf.c b/drivers/gpu/drm/i915/display/intel_casf.c
> index 313ed6b10317..91f2362405b9 100644
> --- a/drivers/gpu/drm/i915/display/intel_casf.c
> +++ b/drivers/gpu/drm/i915/display/intel_casf.c
> @@ -133,6 +133,8 @@ int intel_casf_compute_config(struct intel_crtc_state *crtc_state)
>
> intel_casf_compute_win_size(crtc_state);
>
> + intel_casf_scaler_compute_config(crtc_state);
> +
> return 0;
> }
>
> @@ -156,6 +158,101 @@ void intel_casf_sharpness_get_config(struct intel_crtc_state *crtc_state)
> }
> }
>
> +static int casf_coeff_tap(int i)
> +{
> + return i % SCALER_FILTER_NUM_TAPS;
> +}
> +
> +static u32 casf_coeff(struct intel_crtc_state *crtc_state, int t)
> +{
> + struct scaler_filter_coeff value;
> + u32 coeff;
> +
> + value = crtc_state->hw.casf_params.coeff[t];
> + value.sign = 0;
> +
> + coeff = value.sign << 15 | value.exp << 12 | value.mantissa << 3;
> + return coeff;
> +}
> +
> +/*
> + * 17 phase of 7 taps requires 119 coefficients in 60 dwords per set.
> + * To enable casf: program scaler coefficients with the coeffients
> + * that are calculated and stored in hw.casf_params.coeff as per
> + * SCALER_COEFFICIENT_FORMAT
> + */
> +static void intel_casf_write_coeff(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);
> + int id = crtc_state->scaler_state.scaler_id;
> + int i;
> +
> + if (id != 1) {
> + drm_WARN(display->drm, 0, "Second scaler not enabled\n");
> + return;
> + }
> +
> + intel_de_write_fw(display, GLK_PS_COEF_INDEX_SET(crtc->pipe, id, 0),
> + PS_COEF_INDEX_AUTO_INC);
> +
> + for (i = 0; i < 17 * SCALER_FILTER_NUM_TAPS; i += 2) {
> + u32 tmp;
> + int t;
> +
> + t = casf_coeff_tap(i);
> + tmp = casf_coeff(crtc_state, t);
> +
> + t = casf_coeff_tap(i + 1);
> + tmp |= casf_coeff(crtc_state, t) << 16;
> +
> + intel_de_write_fw(display, GLK_PS_COEF_DATA_SET(crtc->pipe, id, 0),
> + tmp);
> + }
> +}
> +
> +static void convert_sharpness_coef_binary(struct scaler_filter_coeff *coeff,
> + u16 coefficient)
> +{
> + if (coefficient < 25) {
> + coeff->mantissa = (coefficient * 2048) / 100;
> + coeff->exp = 3;
> + } else if (coefficient < 50) {
> + coeff->mantissa = (coefficient * 1024) / 100;
> + coeff->exp = 2;
> + } else if (coefficient < 100) {
> + coeff->mantissa = (coefficient * 512) / 100;
> + coeff->exp = 1;
> + } else {
> + coeff->mantissa = (coefficient * 256) / 100;
> + coeff->exp = 0;
> + }
> +}
> +
> +void intel_casf_scaler_compute_config(struct intel_crtc_state *crtc_state)
> +{
> + const u16 *filtercoeff;
> + u16 filter_coeff[SCALER_FILTER_NUM_TAPS];
> + u16 sumcoeff = 0;
> + int i;
> +
> + if (crtc_state->hw.casf_params.win_size == 0)
> + filtercoeff = filtercoeff_1;
> + else if (crtc_state->hw.casf_params.win_size == 1)
> + filtercoeff = filtercoeff_2;
> + else
> + filtercoeff = filtercoeff_3;
> +
> + for (i = 0; i < SCALER_FILTER_NUM_TAPS; i++)
> + sumcoeff += *(filtercoeff + i);
> +
> + for (i = 0; i < SCALER_FILTER_NUM_TAPS; i++) {
> + filter_coeff[i] = (*(filtercoeff + i) * 100 / sumcoeff);
> + convert_sharpness_coef_binary(&crtc_state->hw.casf_params.coeff[i],
> + filter_coeff[i]);
> + }
> +}
> +
> void intel_casf_enable(struct intel_crtc_state *crtc_state)
> {
> struct intel_display *display = to_intel_display(crtc_state);
> @@ -164,6 +261,8 @@ void intel_casf_enable(struct intel_crtc_state *crtc_state)
>
> intel_casf_filter_lut_load(crtc, crtc_state);
>
> + intel_casf_write_coeff(crtc_state);
> +
> sharpness_ctl = FILTER_EN | FILTER_STRENGTH(crtc_state->hw.casf_params.strength);
>
> sharpness_ctl |= crtc_state->hw.casf_params.win_size;
> diff --git a/drivers/gpu/drm/i915/display/intel_casf.h b/drivers/gpu/drm/i915/display/intel_casf.h
> index e8432b4bc52b..13e5003a23fc 100644
> --- a/drivers/gpu/drm/i915/display/intel_casf.h
> +++ b/drivers/gpu/drm/i915/display/intel_casf.h
> @@ -16,5 +16,6 @@ void intel_casf_update_strength(struct intel_crtc_state *new_crtc_state);
> void intel_casf_sharpness_get_config(struct intel_crtc_state *crtc_state);
> void intel_casf_enable(struct intel_crtc_state *crtc_state);
> void intel_casf_disable(const struct intel_crtc_state *crtc_state);
> +void intel_casf_scaler_compute_config(struct intel_crtc_state *crtc_state);
>
> #endif /* __INTEL_CASF_H__ */
> diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
> index 771026f788d8..0eae95add055 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_types.h
> +++ b/drivers/gpu/drm/i915/display/intel_display_types.h
> @@ -946,7 +946,15 @@ struct intel_csc_matrix {
> u16 postoff[3];
> };
>
> +struct scaler_filter_coeff {
> + u16 sign;
> + u16 exp;
> + u16 mantissa;
> +};
> +
> struct intel_casf {
> +#define SCALER_FILTER_NUM_TAPS 7
> + struct scaler_filter_coeff coeff[SCALER_FILTER_NUM_TAPS];
> u8 strength;
> u8 win_size;
> bool casf_enable;
next prev parent reply other threads:[~2025-10-09 10:52 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-01 6:34 [PATCH 00/10] Introduce drm sharpness property Nemesa Garg
2025-10-01 6:34 ` [PATCH 01/10] drm/drm_crtc: Introduce sharpness strength property Nemesa Garg
2025-10-04 10:08 ` Dmitry Baryshkov
2025-10-08 7:22 ` Garg, Nemesa
2025-10-08 20:05 ` Dmitry Baryshkov
2025-10-09 11:00 ` Nautiyal, Ankit K
2025-10-01 6:34 ` [PATCH 02/10] drm/i915/display: Introduce HAS_CASF for sharpness support Nemesa Garg
2025-10-01 6:34 ` [PATCH 03/10] drm/i915/display: Add CASF strength and winsize Nemesa Garg
2025-10-09 10:51 ` Nautiyal, Ankit K
2025-10-01 6:34 ` [PATCH 04/10] drm/i915/display: Add filter lut values Nemesa Garg
2025-10-09 10:51 ` Nautiyal, Ankit K
2025-10-01 6:34 ` [PATCH 05/10] drm/i915/display: Compute the scaler coefficients Nemesa Garg
2025-10-09 10:52 ` Nautiyal, Ankit K [this message]
2025-10-01 6:34 ` [PATCH 06/10] drm/i915/display: Add and compute scaler parameter Nemesa Garg
2025-10-01 6:34 ` [PATCH 07/10] drm/i915/display: Configure the second scaler Nemesa Garg
2025-10-01 6:34 ` [PATCH 08/10] drm/i915/display: Set and get the casf config Nemesa Garg
2025-10-01 6:34 ` [PATCH 09/10] drm/i915/display: Enable/disable casf Nemesa Garg
2025-10-01 6:35 ` [PATCH 10/10] drm/i915/display: Expose sharpness strength property Nemesa Garg
2025-10-01 9:30 ` ✓ i915.CI.BAT: success for Introduce drm sharpness property (rev19) Patchwork
2025-10-09 11:02 ` [PATCH 00/10] Introduce drm sharpness property Nautiyal, Ankit K
2025-10-10 9:47 ` ✓ i915.CI.BAT: success for Introduce drm sharpness property (rev20) Patchwork
2025-10-12 16:06 ` ✗ i915.CI.Full: failure " Patchwork
2025-10-13 12:08 ` ✓ i915.CI.Full: success " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2025-10-26 17:26 [PATCH 00/10] Introduce drm sharpness property Nemesa Garg
2025-10-26 17:26 ` [PATCH 05/10] drm/i915/display: Compute the scaler coefficients Nemesa Garg
2025-09-26 11:37 [PATCH 00/10] Introduce drm sharpness property Nemesa Garg
2025-09-26 11:37 ` [PATCH 05/10] drm/i915/display: Compute the scaler coefficients Nemesa Garg
2025-08-07 9:28 [PATCH 00/10] Introduce drm sharpness property Nemesa Garg
2025-08-07 9:28 ` [PATCH 05/10] drm/i915/display: Compute the scaler coefficients Nemesa Garg
2025-07-24 13:45 [PATCH 00/10] Introduce drm sharpness property Nemesa Garg
2025-07-24 13:45 ` [PATCH 05/10] drm/i915/display: Compute the scaler coefficients Nemesa Garg
2025-05-19 12:26 [PATCH 00/10] Introduce drm sharpness property Nemesa Garg
2025-05-19 12:26 ` [PATCH 05/10] drm/i915/display: Compute the scaler coefficients Nemesa Garg
2025-05-19 12:52 ` Jani Nikula
2025-05-27 4:56 ` Garg, Nemesa
2025-04-08 10:24 [PATCH 00/10] Introduce drm sharpness property Nemesa Garg
2025-04-08 10:25 ` [PATCH 05/10] drm/i915/display: Compute the scaler coefficients Nemesa Garg
2025-04-02 12:56 [PATCH 00/10] Introduce drm sharpness property Nemesa Garg
2025-04-02 12:56 ` [PATCH 05/10] drm/i915/display: Compute the scaler coefficients Nemesa Garg
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=35451049-3933-431a-9603-aec868d1d105@intel.com \
--to=ankit.k.nautiyal@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=nemesa.garg@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