Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nemesa Garg <nemesa.garg@intel.com>
To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	intel-xe@lists.freedesktop.org
Cc: Nemesa Garg <nemesa.garg@intel.com>
Subject: [PATCH 07/10] drm/i915/display: Configure the second scaler
Date: Wed,  2 Apr 2025 18:26:44 +0530	[thread overview]
Message-ID: <20250402125647.361295-8-nemesa.garg@intel.com> (raw)
In-Reply-To: <20250402125647.361295-1-nemesa.garg@intel.com>

Both sharpness and panel fitter uses pipe scaler,
but only one can be enabled at a time. Furthermore
sharpness uses second scaler. So for CASF, check if
second scaler is available and make sure that only
either of panel fitter or sharpness is enabled at
a time.

v2: Add the panel fitting check before enabling sharpness
v3: Reframe commit message[Arun]
v4: Replace string based comparison with plane_state[Jani]
v5: Rebase
v6: Fix build issue
v7: Remove scaler id from verify_crtc_state[Ankit]
v8: Change the patch title. Add code comment.
    Move the config part in patch#6. [Ankit]
v9: Refactor the patch[Ankit]
v10: Modify the header of patch[Ankit]

Signed-off-by: Nemesa Garg <nemesa.garg@intel.com>
---
 drivers/gpu/drm/i915/display/intel_casf.c    |  8 +++++++
 drivers/gpu/drm/i915/display/intel_casf.h    |  1 +
 drivers/gpu/drm/i915/display/intel_display.c |  4 +++-
 drivers/gpu/drm/i915/display/skl_scaler.c    | 25 +++++++++++++++-----
 4 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_casf.c b/drivers/gpu/drm/i915/display/intel_casf.c
index c41c5b8b4e08..91ed12210e60 100644
--- a/drivers/gpu/drm/i915/display/intel_casf.c
+++ b/drivers/gpu/drm/i915/display/intel_casf.c
@@ -151,6 +151,14 @@ void intel_casf_sharpness_get_config(struct intel_crtc_state *crtc_state)
 	}
 }
 
+bool intel_casf_needs_scaler(const struct intel_crtc_state *crtc_state)
+{
+	if (crtc_state->hw.casf_params.casf_enable)
+		return true;
+
+	return false;
+}
+
 static int casf_coeff_tap(int i)
 {
 	return i % SCALER_FILTER_NUM_TAPS;
diff --git a/drivers/gpu/drm/i915/display/intel_casf.h b/drivers/gpu/drm/i915/display/intel_casf.h
index 381d5e10c70d..026a2b8348df 100644
--- a/drivers/gpu/drm/i915/display/intel_casf.h
+++ b/drivers/gpu/drm/i915/display/intel_casf.h
@@ -17,5 +17,6 @@ void intel_casf_sharpness_get_config(struct intel_crtc_state *crtc_state);
 void intel_filter_lut_load(struct intel_crtc *crtc,
 			   const struct intel_crtc_state *crtc_state);
 void intel_casf_scaler_compute_config(struct intel_crtc_state *crtc_state);
+bool intel_casf_needs_scaler(const struct intel_crtc_state *crtc_state);
 
 #endif /* __INTEL_CASF_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index c540e2cae1f0..4e84ee149fa2 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -60,6 +60,7 @@
 #include "intel_audio.h"
 #include "intel_bo.h"
 #include "intel_bw.h"
+#include "intel_casf.h"
 #include "intel_cdclk.h"
 #include "intel_clock_gating.h"
 #include "intel_color.h"
@@ -4241,7 +4242,8 @@ static int intel_crtc_atomic_check(struct intel_atomic_state *state,
 
 	if (DISPLAY_VER(display) >= 9) {
 		if (intel_crtc_needs_modeset(crtc_state) ||
-		    intel_crtc_needs_fastset(crtc_state)) {
+		    intel_crtc_needs_fastset(crtc_state) ||
+		    intel_casf_needs_scaler(crtc_state)) {
 			ret = skl_update_scaler_crtc(crtc_state);
 			if (ret)
 				return ret;
diff --git a/drivers/gpu/drm/i915/display/skl_scaler.c b/drivers/gpu/drm/i915/display/skl_scaler.c
index 39fc537e54f0..d816dae9cec4 100644
--- a/drivers/gpu/drm/i915/display/skl_scaler.c
+++ b/drivers/gpu/drm/i915/display/skl_scaler.c
@@ -5,6 +5,7 @@
 
 #include "i915_drv.h"
 #include "i915_reg.h"
+#include "intel_casf.h"
 #include "intel_casf_regs.h"
 #include "intel_de.h"
 #include "intel_display_trace.h"
@@ -272,7 +273,8 @@ int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state)
 				 drm_rect_width(&crtc_state->pipe_src),
 				 drm_rect_height(&crtc_state->pipe_src),
 				 width, height, NULL, 0,
-				 crtc_state->pch_pfit.enabled);
+				 crtc_state->pch_pfit.enabled ||
+				 intel_casf_needs_scaler(crtc_state));
 }
 
 /**
@@ -311,7 +313,9 @@ int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
 }
 
 static int intel_allocate_scaler(struct intel_crtc_scaler_state *scaler_state,
-				 struct intel_crtc *crtc)
+				 struct intel_crtc *crtc,
+				 struct intel_plane_state *plane_state,
+				 bool casf_scaler)
 {
 	int i;
 
@@ -319,6 +323,10 @@ static int intel_allocate_scaler(struct intel_crtc_scaler_state *scaler_state,
 		if (scaler_state->scalers[i].in_use)
 			continue;
 
+		/* CASF needs second scaler */
+		if (!plane_state && casf_scaler && i != 1)
+			continue;
+
 		scaler_state->scalers[i].in_use = true;
 
 		return i;
@@ -369,7 +377,7 @@ static int intel_atomic_setup_scaler(struct intel_crtc_state *crtc_state,
 				     int num_scalers_need, struct intel_crtc *crtc,
 				     const char *name, int idx,
 				     struct intel_plane_state *plane_state,
-				     int *scaler_id)
+				     int *scaler_id, bool casf_scaler)
 {
 	struct intel_display *display = to_intel_display(crtc);
 	struct intel_crtc_scaler_state *scaler_state = &crtc_state->scaler_state;
@@ -378,7 +386,7 @@ static int intel_atomic_setup_scaler(struct intel_crtc_state *crtc_state,
 	int vscale = 0;
 
 	if (*scaler_id < 0)
-		*scaler_id = intel_allocate_scaler(scaler_state, crtc);
+		*scaler_id = intel_allocate_scaler(scaler_state, crtc, plane_state, casf_scaler);
 
 	if (drm_WARN(display->drm, *scaler_id < 0,
 		     "Cannot find scaler for %s:%d\n", name, idx))
@@ -510,10 +518,14 @@ static int setup_crtc_scaler(struct intel_atomic_state *state,
 	struct intel_crtc_scaler_state *scaler_state =
 		&crtc_state->scaler_state;
 
+	if (intel_casf_needs_scaler(crtc_state) && crtc_state->pch_pfit.enabled)
+		return -EINVAL;
+
 	return intel_atomic_setup_scaler(crtc_state,
 					 hweight32(scaler_state->scaler_users),
 					 crtc, "CRTC", crtc->base.base.id,
-					 NULL, &scaler_state->scaler_id);
+					 NULL, &scaler_state->scaler_id,
+					 intel_casf_needs_scaler(crtc_state));
 }
 
 static int setup_plane_scaler(struct intel_atomic_state *state,
@@ -548,7 +560,8 @@ static int setup_plane_scaler(struct intel_atomic_state *state,
 	return intel_atomic_setup_scaler(crtc_state,
 					 hweight32(scaler_state->scaler_users),
 					 crtc, "PLANE", plane->base.base.id,
-					 plane_state, &plane_state->scaler_id);
+					 plane_state, &plane_state->scaler_id,
+					 false);
 }
 
 /**
-- 
2.25.1


  parent reply	other threads:[~2025-04-02 13:02 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-02 12:56 [PATCH 00/10] Introduce drm sharpness property Nemesa Garg
2025-04-02 12:56 ` [PATCH 01/10] drm/i915/display: Introduce sharpness strength property Nemesa Garg
2025-04-02 12:56 ` [PATCH 02/10] drm/i915/display: Introduce HAS_CASF for sharpness support Nemesa Garg
2025-04-02 12:56 ` [PATCH 03/10] drm/i915/display: Add strength and winsize register Nemesa Garg
2025-04-08  9:27   ` Nautiyal, Ankit K
2025-04-02 12:56 ` [PATCH 04/10] drm/i915/display: Add filter lut values Nemesa Garg
2025-04-02 12:56 ` [PATCH 05/10] drm/i915/display: Compute the scaler coefficients Nemesa Garg
2025-04-02 12:56 ` [PATCH 06/10] drm/i915/display: Add and compute scaler parameter Nemesa Garg
2025-04-02 12:56 ` Nemesa Garg [this message]
2025-04-07  6:26   ` [PATCH 07/10] drm/i915/display: Configure the second scaler Nautiyal, Ankit K
2025-04-02 12:56 ` [PATCH 08/10] drm/i915/display: Set and get the casf config Nemesa Garg
2025-04-07  6:30   ` Nautiyal, Ankit K
2025-04-02 12:56 ` [PATCH 09/10] drm/i915/display: Enable/disable casf Nemesa Garg
2025-04-08  9:25   ` Nautiyal, Ankit K
2025-04-02 12:56 ` [PATCH 10/10] drm/i915/display: Expose sharpness strength property Nemesa Garg
2025-04-03  7:10 ` ✓ CI.Patch_applied: success for Introduce drm sharpness property (rev12) Patchwork
2025-04-03  7:11 ` ✗ CI.checkpatch: warning " Patchwork
2025-04-03  7:12 ` ✓ CI.KUnit: success " Patchwork
2025-04-03  7:28 ` ✓ CI.Build: " Patchwork
2025-04-03  7:31 ` ✓ CI.Hooks: " Patchwork
2025-04-03  7:32 ` ✗ CI.checksparse: warning " Patchwork
2025-04-03  8:18 ` ✓ Xe.CI.BAT: success " Patchwork
2025-04-03 12:37 ` ✗ Xe.CI.Full: failure " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2025-04-08 10:24 [PATCH 00/10] Introduce drm sharpness property Nemesa Garg
2025-04-08 10:25 ` [PATCH 07/10] drm/i915/display: Configure the second scaler Nemesa Garg
2025-05-19 12:26 [PATCH 00/10] Introduce drm sharpness property Nemesa Garg
2025-05-19 12:26 ` [PATCH 07/10] drm/i915/display: Configure the second scaler Nemesa Garg
2025-07-24 13:45 [PATCH 00/10] Introduce drm sharpness property Nemesa Garg
2025-07-24 13:45 ` [PATCH 07/10] drm/i915/display: Configure the second scaler Nemesa Garg
2025-08-07  9:28 [PATCH 00/10] Introduce drm sharpness property Nemesa Garg
2025-08-07  9:28 ` [PATCH 07/10] drm/i915/display: Configure the second scaler Nemesa Garg
2025-09-26 11:37 [PATCH 00/10] Introduce drm sharpness property Nemesa Garg
2025-09-26 11:37 ` [PATCH 07/10] drm/i915/display: Configure the second scaler Nemesa Garg
2025-10-01  6:34 [PATCH 00/10] Introduce drm sharpness property Nemesa Garg
2025-10-01  6:34 ` [PATCH 07/10] drm/i915/display: Configure the second scaler Nemesa Garg
2025-10-26 17:26 [PATCH 00/10] Introduce drm sharpness property Nemesa Garg
2025-10-26 17:26 ` [PATCH 07/10] drm/i915/display: Configure the second scaler 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=20250402125647.361295-8-nemesa.garg@intel.com \
    --to=nemesa.garg@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@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