* [PATCH 0/6] Introduce drm sharpness property
@ 2025-01-10 6:32 Nemesa Garg
2025-01-10 6:32 ` [PATCH 1/6] drm: Introduce sharpness strength property Nemesa Garg
` (6 more replies)
0 siblings, 7 replies; 12+ messages in thread
From: Nemesa Garg @ 2025-01-10 6:32 UTC (permalink / raw)
To: intel-gfx, intel-xe; +Cc: Nemesa Garg
Many a times images are blurred or upscaled content is also not as
crisp as original rendered image. Traditional sharpening techniques often
apply a uniform level of enhancement across entire image, which sometimes
result in over-sharpening of some areas and potential loss of natural details.
Intel has come up with Display Engine based adaptive sharpening filter
with minimal power and performance impact. From LNL onwards, the Display
hardware can use one of the pipe scaler for adaptive sharpness filter.
This can be used for both gaming and non-gaming use cases like photos,
image viewing. It works on a region of pixels depending on the tap size.
This is an attempt to introduce an adaptive sharpness solution which
helps in improving the image quality. For this new CRTC property is added.
The user can set this property with desired sharpness strength value with
0-255. A value of 1 representing minimum sharpening strength and 255
representing maximum sharpness strength. A strength value of 0 means no
sharpening or sharpening feature disabled.
It works on a region of pixels depending on the tap size. The coefficients
are used to generate an alpha value which is used to blend the sharpened
image to original image.
Middleware MR link: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3665
IGT patchwork link: https://patchwork.freedesktop.org/series/130218/
Continuing discussions from: https://patchwork.freedesktop.org/series/129888/
Nemesa Garg (6):
drm: Introduce sharpness strength property
drm/i915/display: Compute the scaler filter coefficients
drm/i915/display: Configure the scaler
drm/i915/display: Enable the second scaler for sharpness
drm/i915/display: Add registers and compute the strength
drm/i915/display: Load the lut values and enable sharpness
drivers/gpu/drm/drm_atomic_uapi.c | 4 +
drivers/gpu/drm/drm_crtc.c | 35 +++
drivers/gpu/drm/i915/Makefile | 1 +
drivers/gpu/drm/i915/display/intel_casf.c | 259 ++++++++++++++++++
drivers/gpu/drm/i915/display/intel_casf.h | 24 ++
.../gpu/drm/i915/display/intel_casf_regs.h | 39 +++
drivers/gpu/drm/i915/display/intel_crtc.c | 3 +
drivers/gpu/drm/i915/display/intel_display.c | 19 +-
.../drm/i915/display/intel_display_types.h | 16 ++
drivers/gpu/drm/i915/display/intel_pfit.c | 6 +
drivers/gpu/drm/i915/display/skl_scaler.c | 100 ++++++-
drivers/gpu/drm/i915/display/skl_scaler.h | 1 +
drivers/gpu/drm/xe/Makefile | 1 +
include/drm/drm_crtc.h | 17 ++
14 files changed, 508 insertions(+), 17 deletions(-)
create mode 100644 drivers/gpu/drm/i915/display/intel_casf.c
create mode 100644 drivers/gpu/drm/i915/display/intel_casf.h
create mode 100644 drivers/gpu/drm/i915/display/intel_casf_regs.h
--
2.25.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/6] drm: Introduce sharpness strength property
2025-01-10 6:32 [PATCH 0/6] Introduce drm sharpness property Nemesa Garg
@ 2025-01-10 6:32 ` Nemesa Garg
2025-01-10 6:32 ` [PATCH v6 2/6] drm/i915/display: Compute the scaler filter coefficients Nemesa Garg
` (5 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Nemesa Garg @ 2025-01-10 6:32 UTC (permalink / raw)
To: intel-gfx, intel-xe; +Cc: Nemesa Garg
Introduces the new crtc property "SHARPNESS_STRENGTH" that allows
the user to set the intensity so as to get the sharpness effect.
The value of this property can be set from 0-255.
It is useful in scenario when the output is blurry and user
want to sharpen the pixels. User can increase/decrease the
sharpness level depending on the content displayed.
v2: Rename crtc property variable [Arun]
Add modeset detail in uapi doc[Uma]
v3: Fix build issue
Signed-off-by: Nemesa Garg <nemesa.garg@intel.com>
---
drivers/gpu/drm/drm_atomic_uapi.c | 4 ++++
drivers/gpu/drm/drm_crtc.c | 35 +++++++++++++++++++++++++++++++
include/drm/drm_crtc.h | 17 +++++++++++++++
3 files changed, 56 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index 370dc676e3aa..b482bc2b5d0a 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -417,6 +417,8 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
set_out_fence_for_crtc(state->state, crtc, fence_ptr);
} else if (property == crtc->scaling_filter_property) {
state->scaling_filter = val;
+ } else if (property == crtc->sharpness_strength_property) {
+ state->sharpness_strength = val;
} else if (crtc->funcs->atomic_set_property) {
return crtc->funcs->atomic_set_property(crtc, state, property, val);
} else {
@@ -454,6 +456,8 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
*val = 0;
else if (property == crtc->scaling_filter_property)
*val = state->scaling_filter;
+ else if (property == crtc->sharpness_strength_property)
+ *val = state->sharpness_strength;
else if (crtc->funcs->atomic_get_property)
return crtc->funcs->atomic_get_property(crtc, state, property, val);
else {
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 46655339003d..1b7ce99cea5e 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -229,6 +229,25 @@ struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc)
* Driver's default scaling filter
* Nearest Neighbor:
* Nearest Neighbor scaling filter
+ * SHARPNESS_STRENGTH:
+ * Atomic property for setting the sharpness strength/intensity by userspace.
+ *
+ * The value of this property is set as an integer value ranging
+ * from 0 - 255 where:
+ *
+ * 0 means feature is disabled.
+ *
+ * 1 means minimum sharpness.
+ *
+ * 255 means maximum sharpness.
+ *
+ * User can gradually increase or decrease the sharpness level and can
+ * set the optimum value depending on content and this value will be
+ * passed to kernel through the Uapi.
+ * The setting of this property does not require modeset.
+ * The sharpness effect takes place post blending on the final composed output.
+ * If the feature is disabled, the content remains same without any sharpening effect
+ * and when this feature is applied, it enhances the clarity of the content.
*/
__printf(6, 0)
@@ -940,6 +959,22 @@ int drm_crtc_create_scaling_filter_property(struct drm_crtc *crtc,
}
EXPORT_SYMBOL(drm_crtc_create_scaling_filter_property);
+int drm_crtc_create_sharpness_strength_property(struct drm_crtc *crtc)
+{
+ struct drm_device *dev = crtc->dev;
+ struct drm_property *prop =
+ drm_property_create_range(dev, 0, "SHARPNESS_STRENGTH", 0, 255);
+
+ if (!prop)
+ return -ENOMEM;
+
+ crtc->sharpness_strength_property = prop;
+ drm_object_attach_property(&crtc->base, prop, 0);
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_crtc_create_sharpness_strength_property);
+
/**
* drm_crtc_in_clone_mode - check if the given CRTC state is in clone mode
*
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index caa56e039da2..ffcfe5c50dab 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -317,6 +317,16 @@ struct drm_crtc_state {
*/
enum drm_scaling_filter scaling_filter;
+ /**
+ * @sharpness_strength
+ *
+ * Used by the user to set the sharpness intensity.
+ * The value ranges from 0-255.
+ * Any value greater than 0 means enabling the featuring
+ * along with setting the value for sharpness.
+ */
+ u8 sharpness_strength;
+
/**
* @event:
*
@@ -1088,6 +1098,12 @@ struct drm_crtc {
*/
struct drm_property *scaling_filter_property;
+ /**
+ * @sharpness_strength_prop: property to apply
+ * the intensity of the sharpness requested.
+ */
+ struct drm_property *sharpness_strength_property;
+
/**
* @state:
*
@@ -1324,4 +1340,5 @@ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
int drm_crtc_create_scaling_filter_property(struct drm_crtc *crtc,
unsigned int supported_filters);
bool drm_crtc_in_clone_mode(struct drm_crtc_state *crtc_state);
+int drm_crtc_create_sharpness_strength_property(struct drm_crtc *crtc);
#endif /* __DRM_CRTC_H__ */
--
2.25.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v6 2/6] drm/i915/display: Compute the scaler filter coefficients
2025-01-10 6:32 [PATCH 0/6] Introduce drm sharpness property Nemesa Garg
2025-01-10 6:32 ` [PATCH 1/6] drm: Introduce sharpness strength property Nemesa Garg
@ 2025-01-10 6:32 ` Nemesa Garg
2025-01-10 6:32 ` [PATCH 3/6] drm/i915/display: Configure the scaler Nemesa Garg
` (4 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Nemesa Garg @ 2025-01-10 6:32 UTC (permalink / raw)
To: intel-gfx, intel-xe; +Cc: Nemesa Garg, Naga Venkata Srikanth V
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 9490 bytes --]
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.
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]
Signed-off-by: Nemesa Garg <nemesa.garg@intel.com>
Reviewed-by: Naga Venkata Srikanth V <nagavenkata.srikanth.v@intel.com>
---
drivers/gpu/drm/i915/Makefile | 1 +
drivers/gpu/drm/i915/display/intel_casf.c | 142 ++++++++++++++++++
drivers/gpu/drm/i915/display/intel_casf.h | 16 ++
.../gpu/drm/i915/display/intel_casf_regs.h | 19 +++
drivers/gpu/drm/i915/display/intel_display.c | 3 +
.../drm/i915/display/intel_display_types.h | 13 ++
drivers/gpu/drm/xe/Makefile | 1 +
7 files changed, 195 insertions(+)
create mode 100644 drivers/gpu/drm/i915/display/intel_casf.c
create mode 100644 drivers/gpu/drm/i915/display/intel_casf.h
create mode 100644 drivers/gpu/drm/i915/display/intel_casf_regs.h
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 3dda9f0eda82..6f7f47af894e 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -286,6 +286,7 @@ i915-y += \
display/intel_pmdemand.o \
display/intel_psr.o \
display/intel_quirks.o \
+ display/intel_casf.o \
display/intel_sprite.o \
display/intel_sprite_uapi.o \
display/intel_tc.o \
diff --git a/drivers/gpu/drm/i915/display/intel_casf.c b/drivers/gpu/drm/i915/display/intel_casf.c
new file mode 100644
index 000000000000..b507401457bf
--- /dev/null
+++ b/drivers/gpu/drm/i915/display/intel_casf.c
@@ -0,0 +1,142 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2024 Intel Corporation
+ *
+ */
+#include "i915_reg.h"
+#include "intel_de.h"
+#include "intel_display_types.h"
+#include "intel_casf.h"
+#include "intel_casf_regs.h"
+#include "skl_scaler.h"
+
+#define FILTER_COEFF_0_125 125
+#define FILTER_COEFF_0_25 250
+#define FILTER_COEFF_0_5 500
+#define FILTER_COEFF_1_0 1000
+#define FILTER_COEFF_0_0 0
+#define SET_POSITIVE_SIGN(x) ((x) & (~SIGN))
+
+/**
+ * DOC: Content Adaptive Sharpness Filter (CASF)
+ *
+ * From LNL onwards the display engine based adaptive
+ * sharpening filter is supported. This helps in
+ * improving the image quality. The display hardware
+ * uses one of the pipe scaler for implementing casf.
+ * It works on a region of pixels depending on the
+ * tap size. The coefficients are used to generate an
+ * alpha value which is used to blend the sharpened image
+ * to original image.
+ */
+
+const u16 filtercoeff_1[] = {
+ FILTER_COEFF_0_0, FILTER_COEFF_0_0, FILTER_COEFF_0_5,
+ FILTER_COEFF_1_0, FILTER_COEFF_0_5, FILTER_COEFF_0_0,
+ FILTER_COEFF_0_0,
+ };
+
+const u16 filtercoeff_2[] = {
+ FILTER_COEFF_0_0, FILTER_COEFF_0_25, FILTER_COEFF_0_5,
+ FILTER_COEFF_1_0, FILTER_COEFF_0_5, FILTER_COEFF_0_25,
+ FILTER_COEFF_0_0,
+ };
+
+const u16 filtercoeff_3[] = {
+ FILTER_COEFF_0_125, FILTER_COEFF_0_25, FILTER_COEFF_0_5,
+ FILTER_COEFF_1_0, FILTER_COEFF_0_5, FILTER_COEFF_0_25,
+ FILTER_COEFF_0_125,
+ };
+
+static int casf_coef_tap(int i)
+{
+ return i % 7;
+}
+
+static u16 casf_coef(struct intel_crtc_state *crtc_state, int t)
+{
+ struct scaler_filter_coeff value;
+ u16 coeff;
+
+ value = crtc_state->hw.casf_params.coeff[t];
+ coeff = SET_POSITIVE_SIGN(0) | EXPONENT(value.exp) | MANTISSA(value.mantissa);
+
+ return coeff;
+}
+
+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;
+
+ intel_de_write_fw(display, GLK_PS_COEF_INDEX_SET(crtc->pipe, id, 0),
+ PS_COEF_INDEX_AUTO_INC);
+
+ intel_de_write_fw(display, GLK_PS_COEF_INDEX_SET(crtc->pipe, id, 1),
+ PS_COEF_INDEX_AUTO_INC);
+
+ for (i = 0; i < 17 * 7; i += 2) {
+ u32 tmp;
+ int t;
+
+ t = casf_coef_tap(i);
+ tmp = casf_coef(crtc_state, t);
+
+ t = casf_coef_tap(i + 1);
+ tmp |= casf_coef(crtc_state, t) << 16;
+
+ intel_de_write_fw(display, GLK_PS_COEF_DATA_SET(crtc->pipe, id, 0),
+ tmp);
+ intel_de_write_fw(display, GLK_PS_COEF_DATA_SET(crtc->pipe, id, 1),
+ tmp);
+ }
+}
+
+void intel_casf_enable(struct intel_crtc_state *crtc_state)
+{
+ intel_casf_write_coeff(crtc_state);
+}
+
+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;
+ u8 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]);
+ }
+}
diff --git a/drivers/gpu/drm/i915/display/intel_casf.h b/drivers/gpu/drm/i915/display/intel_casf.h
new file mode 100644
index 000000000000..8e0b67a2fd99
--- /dev/null
+++ b/drivers/gpu/drm/i915/display/intel_casf.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2024 Intel Corporation
+ */
+
+#ifndef __INTEL_CASF_H__
+#define __INTEL_CASF_H__
+
+#include <linux/types.h>
+
+struct intel_crtc_state;
+
+void intel_casf_enable(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_casf_regs.h b/drivers/gpu/drm/i915/display/intel_casf_regs.h
new file mode 100644
index 000000000000..0b3fcdb22c0c
--- /dev/null
+++ b/drivers/gpu/drm/i915/display/intel_casf_regs.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2024 Intel Corporation
+ */
+
+#ifndef __INTEL_CASF_REGS_H__
+#define __INTEL_CASF_REGS_H__
+
+#include "intel_display_reg_defs.h"
+
+/* Scaler Coefficient structure */
+#define SIGN REG_BIT(15)
+#define EXPONENT_MASK REG_GENMASK(13, 12)
+#define EXPONENT(x) REG_FIELD_PREP(EXPONENT_MASK, (x))
+#define MANTISSA_MASK REG_GENMASK(11, 3)
+#define MANTISSA(x) REG_FIELD_PREP(MANTISSA_MASK, (x))
+
+#endif /* __INTEL_CASF_REGS__ */
+
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 4271da219b41..413b7fd7e287 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -111,6 +111,7 @@
#include "intel_psr.h"
#include "intel_psr_regs.h"
#include "intel_sdvo.h"
+#include "intel_casf.h"
#include "intel_snps_phy.h"
#include "intel_tc.h"
#include "intel_tdf.h"
@@ -6176,6 +6177,8 @@ static int intel_atomic_check_planes(struct intel_atomic_state *state)
if (ret)
return ret;
+ intel_casf_scaler_compute_config(new_crtc_state);
+
/*
* On some platforms the number of active planes affects
* the planes' minimum cdclk calculation. Add such planes
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index 8271e50e3644..7cb58bf56907 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -929,6 +929,18 @@ 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 win_size;
+};
+
void intel_io_mmio_fw_write(void *ctx, i915_reg_t reg, u32 val);
typedef void (*intel_io_reg_write)(void *ctx, i915_reg_t reg, u32 val);
@@ -969,6 +981,7 @@ struct intel_crtc_state {
struct drm_property_blob *degamma_lut, *gamma_lut, *ctm;
struct drm_display_mode mode, pipe_mode, adjusted_mode;
enum drm_scaling_filter scaling_filter;
+ struct intel_casf casf_params;
} hw;
/* actual state of LUTs */
diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
index 5c97ad6ed738..fca8cdb70ce6 100644
--- a/drivers/gpu/drm/xe/Makefile
+++ b/drivers/gpu/drm/xe/Makefile
@@ -262,6 +262,7 @@ xe-$(CONFIG_DRM_XE_DISPLAY) += \
i915-display/intel_psr.o \
i915-display/intel_qp_tables.o \
i915-display/intel_quirks.o \
+ i915-display/intel_casf.o \
i915-display/intel_snps_phy.o \
i915-display/intel_tc.o \
i915-display/intel_vblank.o \
--
2.25.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/6] drm/i915/display: Configure the scaler
2025-01-10 6:32 [PATCH 0/6] Introduce drm sharpness property Nemesa Garg
2025-01-10 6:32 ` [PATCH 1/6] drm: Introduce sharpness strength property Nemesa Garg
2025-01-10 6:32 ` [PATCH v6 2/6] drm/i915/display: Compute the scaler filter coefficients Nemesa Garg
@ 2025-01-10 6:32 ` Nemesa Garg
2025-01-10 6:32 ` [PATCH v7 4/6] drm/i915/display: Enable the second scaler for sharpness Nemesa Garg
` (3 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Nemesa Garg @ 2025-01-10 6:32 UTC (permalink / raw)
To: intel-gfx, intel-xe; +Cc: Nemesa Garg
Write the scaler registers for sharpness.
Signed-off-by: Nemesa Garg <nemesa.garg@intel.com>
---
drivers/gpu/drm/i915/display/intel_casf.c | 2 +
drivers/gpu/drm/i915/display/skl_scaler.c | 45 ++++++++++++++++++++++-
drivers/gpu/drm/i915/display/skl_scaler.h | 1 +
3 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/display/intel_casf.c b/drivers/gpu/drm/i915/display/intel_casf.c
index b507401457bf..773abaad74ca 100644
--- a/drivers/gpu/drm/i915/display/intel_casf.c
+++ b/drivers/gpu/drm/i915/display/intel_casf.c
@@ -97,6 +97,8 @@ static void intel_casf_write_coeff(struct intel_crtc_state *crtc_state)
void intel_casf_enable(struct intel_crtc_state *crtc_state)
{
intel_casf_write_coeff(crtc_state);
+
+ skl_scaler_setup_casf(crtc_state);
}
static void convert_sharpness_coef_binary(struct scaler_filter_coeff *coeff,
diff --git a/drivers/gpu/drm/i915/display/skl_scaler.c b/drivers/gpu/drm/i915/display/skl_scaler.c
index ae21fce534dc..722d61959bb1 100644
--- a/drivers/gpu/drm/i915/display/skl_scaler.c
+++ b/drivers/gpu/drm/i915/display/skl_scaler.c
@@ -98,7 +98,12 @@ static u16 skl_scaler_calc_phase(int sub, int scale, bool chroma_cosited)
#define MTL_MAX_DST_H 8192
#define SKL_MIN_YUV_420_SRC_W 16
#define SKL_MIN_YUV_420_SRC_H 16
-
+#define SCALER_FILTER_SELECT \
+ (PS_FILTER_PROGRAMMED | \
+ PS_Y_VERT_FILTER_SELECT(1) | \
+ PS_Y_HORZ_FILTER_SELECT(0) | \
+ PS_UV_VERT_FILTER_SELECT(1) | \
+ PS_UV_HORZ_FILTER_SELECT(0))
static int
skl_update_scaler(struct intel_crtc_state *crtc_state, bool force_detach,
unsigned int scaler_user, int *scaler_id,
@@ -655,6 +660,44 @@ static void skl_scaler_setup_filter(struct intel_display *display, enum pipe pip
}
}
+void skl_scaler_setup_casf(struct intel_crtc_state *crtc_state)
+{
+ struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+ struct intel_display *display = to_intel_display(crtc);
+ struct drm_display_mode *adjusted_mode =
+ &crtc_state->hw.adjusted_mode;
+ struct intel_crtc_scaler_state *scaler_state =
+ &crtc_state->scaler_state;
+ struct drm_rect src, dest;
+ int id, width, height;
+ int x, y;
+ enum pipe pipe = crtc->pipe;
+ u32 ps_ctrl;
+
+ width = adjusted_mode->crtc_hdisplay;
+ height = adjusted_mode->crtc_vdisplay;
+
+ x = y = 0;
+ drm_rect_init(&dest, x, y, width, height);
+
+ width = drm_rect_width(&dest);
+ height = drm_rect_height(&dest);
+ id = scaler_state->scaler_id;
+
+ drm_rect_init(&src, 0, 0,
+ drm_rect_width(&crtc_state->pipe_src) << 16,
+ drm_rect_height(&crtc_state->pipe_src) << 16);
+
+ ps_ctrl = PS_SCALER_EN | PS_BINDING_PIPE | scaler_state->scalers[id].mode |
+ SCALER_FILTER_SELECT;
+
+ intel_de_write_fw(display, SKL_PS_CTRL(pipe, id), ps_ctrl);
+ intel_de_write_fw(display, SKL_PS_WIN_POS(pipe, id),
+ PS_WIN_XPOS(x) | PS_WIN_YPOS(y));
+ intel_de_write_fw(display, SKL_PS_WIN_SZ(pipe, id),
+ PS_WIN_XSIZE(width) | PS_WIN_YSIZE(height));
+}
+
void skl_pfit_enable(const struct intel_crtc_state *crtc_state)
{
struct intel_display *display = to_intel_display(crtc_state);
diff --git a/drivers/gpu/drm/i915/display/skl_scaler.h b/drivers/gpu/drm/i915/display/skl_scaler.h
index 4d2e2dbb1666..e1fe6a2d6c32 100644
--- a/drivers/gpu/drm/i915/display/skl_scaler.h
+++ b/drivers/gpu/drm/i915/display/skl_scaler.h
@@ -28,5 +28,6 @@ void skl_detach_scalers(const struct intel_crtc_state *crtc_state);
void skl_scaler_disable(const struct intel_crtc_state *old_crtc_state);
void skl_scaler_get_config(struct intel_crtc_state *crtc_state);
+void skl_scaler_setup_casf(struct intel_crtc_state *crtc_state);
#endif
--
2.25.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v7 4/6] drm/i915/display: Enable the second scaler for sharpness
2025-01-10 6:32 [PATCH 0/6] Introduce drm sharpness property Nemesa Garg
` (2 preceding siblings ...)
2025-01-10 6:32 ` [PATCH 3/6] drm/i915/display: Configure the scaler Nemesa Garg
@ 2025-01-10 6:32 ` Nemesa Garg
2025-01-10 6:32 ` [PATCH v6 5/6] drm/i915/display: Add registers and compute the strength Nemesa Garg
` (2 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Nemesa Garg @ 2025-01-10 6:32 UTC (permalink / raw)
To: intel-gfx, intel-xe; +Cc: Nemesa Garg
As only second scaler can be used for sharpness check if it
is available and also check if panel fitting is also not enabled,
then set the sharpness. Panel fitting will have the preference
over sharpness property.
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]
Signed-off-by: Nemesa Garg <nemesa.garg@intel.com>
---
drivers/gpu/drm/i915/display/intel_casf.c | 7 ++++
drivers/gpu/drm/i915/display/intel_casf.h | 1 +
drivers/gpu/drm/i915/display/intel_display.c | 8 ++--
.../drm/i915/display/intel_display_types.h | 1 +
drivers/gpu/drm/i915/display/intel_pfit.c | 6 +++
drivers/gpu/drm/i915/display/skl_scaler.c | 41 +++++++++++++------
6 files changed, 49 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_casf.c b/drivers/gpu/drm/i915/display/intel_casf.c
index 773abaad74ca..aff7aa6d3eb3 100644
--- a/drivers/gpu/drm/i915/display/intel_casf.c
+++ b/drivers/gpu/drm/i915/display/intel_casf.c
@@ -101,6 +101,13 @@ void intel_casf_enable(struct intel_crtc_state *crtc_state)
skl_scaler_setup_casf(crtc_state);
}
+int intel_casf_compute_config(struct intel_crtc_state *crtc_state)
+{
+ crtc_state->hw.casf_params.need_scaler = true;
+
+ return 0;
+}
+
static void convert_sharpness_coef_binary(struct scaler_filter_coeff *coeff,
u16 coefficient)
{
diff --git a/drivers/gpu/drm/i915/display/intel_casf.h b/drivers/gpu/drm/i915/display/intel_casf.h
index 8e0b67a2fd99..568e0f8083eb 100644
--- a/drivers/gpu/drm/i915/display/intel_casf.h
+++ b/drivers/gpu/drm/i915/display/intel_casf.h
@@ -12,5 +12,6 @@ struct intel_crtc_state;
void intel_casf_enable(struct intel_crtc_state *crtc_state);
void intel_casf_scaler_compute_config(struct intel_crtc_state *crtc_state);
+int intel_casf_compute_config(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 413b7fd7e287..beef3a76eba4 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -2137,7 +2137,7 @@ static void get_crtc_power_domains(struct intel_crtc_state *crtc_state,
set_bit(POWER_DOMAIN_PIPE(pipe), mask->bits);
set_bit(POWER_DOMAIN_TRANSCODER(cpu_transcoder), mask->bits);
if (crtc_state->pch_pfit.enabled ||
- crtc_state->pch_pfit.force_thru)
+ crtc_state->pch_pfit.force_thru || crtc_state->hw.casf_params.need_scaler)
set_bit(POWER_DOMAIN_PIPE_PANEL_FITTER(pipe), mask->bits);
drm_for_each_encoder_mask(encoder, &dev_priv->drm,
@@ -2386,7 +2386,7 @@ static u32 ilk_pipe_pixel_rate(const struct intel_crtc_state *crtc_state)
* PF-ID we'll need to adjust the pixel_rate here.
*/
- if (!crtc_state->pch_pfit.enabled)
+ if (!crtc_state->pch_pfit.enabled || crtc_state->hw.casf_params.need_scaler)
return pixel_rate;
drm_rect_init(&src, 0, 0,
@@ -4584,7 +4584,8 @@ static int intel_crtc_atomic_check(struct intel_atomic_state *state,
if (DISPLAY_VER(dev_priv) >= 9) {
if (intel_crtc_needs_modeset(crtc_state) ||
- intel_crtc_needs_fastset(crtc_state)) {
+ intel_crtc_needs_fastset(crtc_state) ||
+ crtc_state->hw.casf_params.need_scaler) {
ret = skl_update_scaler_crtc(crtc_state);
if (ret)
return ret;
@@ -5750,6 +5751,7 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
PIPE_CONF_CHECK_LLI(cmrr.cmrr_m);
PIPE_CONF_CHECK_LLI(cmrr.cmrr_n);
PIPE_CONF_CHECK_BOOL(cmrr.enable);
+ PIPE_CONF_CHECK_BOOL(hw.casf_params.need_scaler);
}
#undef PIPE_CONF_CHECK_X
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index 7cb58bf56907..e5d28377bd0b 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -939,6 +939,7 @@ struct intel_casf {
#define SCALER_FILTER_NUM_TAPS 7
struct scaler_filter_coeff coeff[SCALER_FILTER_NUM_TAPS];
u8 win_size;
+ bool need_scaler;
};
void intel_io_mmio_fw_write(void *ctx, i915_reg_t reg, u32 val);
diff --git a/drivers/gpu/drm/i915/display/intel_pfit.c b/drivers/gpu/drm/i915/display/intel_pfit.c
index 4ee03d9d14ad..dce86fb22c70 100644
--- a/drivers/gpu/drm/i915/display/intel_pfit.c
+++ b/drivers/gpu/drm/i915/display/intel_pfit.c
@@ -183,6 +183,9 @@ static int pch_panel_fitting(struct intel_crtc_state *crtc_state,
struct intel_display *display = to_intel_display(crtc_state);
const struct drm_display_mode *adjusted_mode =
&crtc_state->hw.adjusted_mode;
+ struct intel_atomic_state *state = to_intel_atomic_state(conn_state->state);
+ struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+ struct intel_crtc_state *old_crtc_state = intel_atomic_get_old_crtc_state(state, crtc);
int pipe_src_w = drm_rect_width(&crtc_state->pipe_src);
int pipe_src_h = drm_rect_height(&crtc_state->pipe_src);
int ret, x, y, width, height;
@@ -193,6 +196,9 @@ static int pch_panel_fitting(struct intel_crtc_state *crtc_state,
crtc_state->output_format != INTEL_OUTPUT_FORMAT_YCBCR420)
return 0;
+ if (old_crtc_state->hw.casf_params.need_scaler)
+ return -EINVAL;
+
switch (conn_state->scaling_mode) {
case DRM_MODE_SCALE_CENTER:
width = pipe_src_w;
diff --git a/drivers/gpu/drm/i915/display/skl_scaler.c b/drivers/gpu/drm/i915/display/skl_scaler.c
index 722d61959bb1..57396f610c89 100644
--- a/drivers/gpu/drm/i915/display/skl_scaler.c
+++ b/drivers/gpu/drm/i915/display/skl_scaler.c
@@ -259,7 +259,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 ||
+ crtc_state->hw.casf_params.need_scaler);
}
/**
@@ -298,7 +299,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;
@@ -306,6 +309,11 @@ static int intel_allocate_scaler(struct intel_crtc_scaler_state *scaler_state,
if (scaler_state->scalers[i].in_use)
continue;
+ if (!plane_state) {
+ if (casf_scaler && i != 1)
+ continue;
+ }
+
scaler_state->scalers[i].in_use = true;
return i;
@@ -318,19 +326,23 @@ static int intel_atomic_setup_scaler(struct intel_crtc_scaler_state *scaler_stat
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 drm_i915_private *dev_priv = to_i915(crtc->base.dev);
+ struct intel_crtc_state *crtc_state = to_intel_crtc_state(crtc->base.state);
u32 mode;
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))
return -EINVAL;
+ if (crtc_state->hw.casf_params.need_scaler)
+ mode = SKL_PS_SCALER_MODE_HQ;
+
/* set scaler mode */
if (plane_state && plane_state->hw.fb &&
plane_state->hw.fb->format->is_yuv &&
@@ -449,7 +461,8 @@ static int setup_crtc_scaler(struct intel_atomic_state *state,
return intel_atomic_setup_scaler(scaler_state,
hweight32(scaler_state->scaler_users),
crtc, "CRTC", crtc->base.base.id,
- NULL, &scaler_state->scaler_id);
+ NULL, &scaler_state->scaler_id,
+ crtc_state->hw.casf_params.need_scaler);
}
static int setup_plane_scaler(struct intel_atomic_state *state,
@@ -484,7 +497,8 @@ static int setup_plane_scaler(struct intel_atomic_state *state,
return intel_atomic_setup_scaler(scaler_state,
hweight32(scaler_state->scaler_users),
crtc, "PLANE", plane->base.base.id,
- plane_state, &plane_state->scaler_id);
+ plane_state, &plane_state->scaler_id,
+ crtc_state->hw.casf_params.need_scaler);
}
/**
@@ -868,16 +882,19 @@ void skl_scaler_get_config(struct intel_crtc_state *crtc_state)
continue;
id = i;
- crtc_state->pch_pfit.enabled = true;
+
+ if (!crtc_state->hw.casf_params.need_scaler)
+ crtc_state->pch_pfit.enabled = true;
pos = intel_de_read(display, SKL_PS_WIN_POS(crtc->pipe, i));
size = intel_de_read(display, SKL_PS_WIN_SZ(crtc->pipe, i));
- drm_rect_init(&crtc_state->pch_pfit.dst,
- REG_FIELD_GET(PS_WIN_XPOS_MASK, pos),
- REG_FIELD_GET(PS_WIN_YPOS_MASK, pos),
- REG_FIELD_GET(PS_WIN_XSIZE_MASK, size),
- REG_FIELD_GET(PS_WIN_YSIZE_MASK, size));
+ if (!crtc_state->hw.casf_params.need_scaler)
+ drm_rect_init(&crtc_state->pch_pfit.dst,
+ REG_FIELD_GET(PS_WIN_XPOS_MASK, pos),
+ REG_FIELD_GET(PS_WIN_YPOS_MASK, pos),
+ REG_FIELD_GET(PS_WIN_XSIZE_MASK, size),
+ REG_FIELD_GET(PS_WIN_YSIZE_MASK, size));
scaler_state->scalers[i].in_use = true;
break;
--
2.25.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v6 5/6] drm/i915/display: Add registers and compute the strength
2025-01-10 6:32 [PATCH 0/6] Introduce drm sharpness property Nemesa Garg
` (3 preceding siblings ...)
2025-01-10 6:32 ` [PATCH v7 4/6] drm/i915/display: Enable the second scaler for sharpness Nemesa Garg
@ 2025-01-10 6:32 ` Nemesa Garg
2025-01-10 6:32 ` [PATCH 6/6] drm/i915/display: Load the lut values and enable sharpness Nemesa Garg
2025-01-10 7:18 ` ✗ CI.Patch_applied: failure for Introduce drm sharpness property (rev4) Patchwork
6 siblings, 0 replies; 12+ messages in thread
From: Nemesa Garg @ 2025-01-10 6:32 UTC (permalink / raw)
To: intel-gfx, intel-xe; +Cc: Nemesa Garg
Add new registers and related bits. Compute the strength
value and tap value based on display mode.
v2: Replace i915/dev_priv with display[Jani]
v3: Create separate file for defining register[Jani]
Add display->drm in debug prints[Jani]
v4: Rebase
v5: Fix build issue
v6: Remove erraneous condition[Ankit]
Signed-off-by: Nemesa Garg <nemesa.garg@intel.com>
---
drivers/gpu/drm/i915/display/intel_casf.c | 108 ++++++++++++++++++
drivers/gpu/drm/i915/display/intel_casf.h | 7 ++
.../gpu/drm/i915/display/intel_casf_regs.h | 20 ++++
drivers/gpu/drm/i915/display/intel_display.c | 4 +-
4 files changed, 138 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/display/intel_casf.c b/drivers/gpu/drm/i915/display/intel_casf.c
index aff7aa6d3eb3..e918d6cb9911 100644
--- a/drivers/gpu/drm/i915/display/intel_casf.c
+++ b/drivers/gpu/drm/i915/display/intel_casf.c
@@ -17,6 +17,9 @@
#define FILTER_COEFF_0_0 0
#define SET_POSITIVE_SIGN(x) ((x) & (~SIGN))
+#define MAX_PIXELS_FOR_3_TAP_FILTER (1920 * 1080)
+#define MAX_PIXELS_FOR_5_TAP_FILTER (3840 * 2160)
+
/**
* DOC: Content Adaptive Sharpness Filter (CASF)
*
@@ -64,6 +67,84 @@ static u16 casf_coef(struct intel_crtc_state *crtc_state, int t)
return coeff;
}
+/* Default LUT values to be loaded one time. */
+static const u16 lut_data[] = {
+ 4095, 2047, 1364, 1022, 816, 678, 579,
+ 504, 444, 397, 357, 323, 293, 268, 244, 224,
+ 204, 187, 170, 154, 139, 125, 111, 98, 85,
+ 73, 60, 48, 36, 24, 12, 0
+};
+
+void intel_filter_lut_load(struct intel_crtc *crtc,
+ const struct intel_crtc_state *crtc_state)
+{
+ struct intel_display *display = to_intel_display(crtc_state);
+ int i;
+
+ intel_de_write(display, SHRPLUT_INDEX(crtc->pipe),
+ INDEX_AUTO_INCR | INDEX_VALUE(0));
+
+ for (i = 0; i < ARRAY_SIZE(lut_data); i++)
+ intel_de_write(display, SHRPLUT_DATA(crtc->pipe),
+ lut_data[i]);
+}
+
+static void intel_casf_size_compute(struct intel_crtc_state *crtc_state)
+{
+ const struct drm_display_mode *mode = &crtc_state->hw.adjusted_mode;
+ u16 total_pixels = mode->hdisplay * mode->vdisplay;
+
+ if (total_pixels <= MAX_PIXELS_FOR_3_TAP_FILTER)
+ crtc_state->hw.casf_params.win_size = 0;
+ else if (total_pixels <= MAX_PIXELS_FOR_5_TAP_FILTER)
+ crtc_state->hw.casf_params.win_size = 1;
+ else
+ crtc_state->hw.casf_params.win_size = 2;
+}
+
+bool intel_casf_strength_changed(struct intel_crtc_state *new_crtc_state,
+ const struct intel_crtc_state *old_crtc_state)
+{
+ if (new_crtc_state->uapi.sharpness_strength !=
+ old_crtc_state->uapi.sharpness_strength)
+ return true;
+
+ return false;
+}
+
+static void intel_casf_write_reg(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);
+ u32 sharpness_ctl;
+ u8 val;
+
+ if (crtc_state->uapi.sharpness_strength == 0 ||
+ crtc_state->pch_pfit.enabled) {
+ intel_casf_disable(crtc_state);
+
+ return;
+ }
+
+ /*
+ * HW takes a value in form (1.0 + strength) in 4.4 fixed format.
+ * Strength is from 0.0-14.9375 ie from 0-239.
+ * User can give value from 0-255 but is clamped to 239.
+ * Ex. User gives 85 which is 5.3125 and adding 1.0 gives 6.3125.
+ * 6.3125 in 4.4 format is 01100101 which is equal to 101.
+ * Also 85 + 16 = 101.
+ */
+ val = min(crtc_state->uapi.sharpness_strength, 0xEF) + 0x10;
+
+ drm_dbg(display->drm, "Filter strength value: %d\n", val);
+
+ sharpness_ctl = FILTER_EN | FILTER_STRENGTH(val) |
+ FILTER_SIZE(crtc_state->hw.casf_params.win_size);
+
+ intel_de_write(display, SHARPNESS_CTL(crtc->pipe),
+ sharpness_ctl);
+}
+
static void intel_casf_write_coeff(struct intel_crtc_state *crtc_state)
{
struct intel_display *display = to_intel_display(crtc_state);
@@ -96,6 +177,8 @@ static void intel_casf_write_coeff(struct intel_crtc_state *crtc_state)
void intel_casf_enable(struct intel_crtc_state *crtc_state)
{
+ intel_casf_write_reg(crtc_state);
+
intel_casf_write_coeff(crtc_state);
skl_scaler_setup_casf(crtc_state);
@@ -103,8 +186,24 @@ void intel_casf_enable(struct intel_crtc_state *crtc_state)
int intel_casf_compute_config(struct intel_crtc_state *crtc_state)
{
+ struct intel_display *display = to_intel_display(crtc_state);
+
+ if (crtc_state->uapi.sharpness_strength == 0) {
+ crtc_state->hw.casf_params.need_scaler = false;
+ return 0;
+ }
+
+ if (crtc_state->pch_pfit.enabled)
+ return -EINVAL;
+
crtc_state->hw.casf_params.need_scaler = true;
+ intel_casf_size_compute(crtc_state);
+ drm_dbg(display->drm, "Tap Size: %d\n",
+ crtc_state->hw.casf_params.win_size);
+
+ intel_casf_scaler_compute_config(crtc_state);
+
return 0;
}
@@ -149,3 +248,12 @@ void intel_casf_scaler_compute_config(struct intel_crtc_state *crtc_state)
filter_coeff[i]);
}
}
+
+void intel_casf_disable(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);
+
+ intel_de_write(display, SHARPNESS_CTL(crtc->pipe), 0);
+ drm_dbg(display->drm, "Filter strength value: %d\n", 0);
+}
diff --git a/drivers/gpu/drm/i915/display/intel_casf.h b/drivers/gpu/drm/i915/display/intel_casf.h
index 568e0f8083eb..43660e48ecff 100644
--- a/drivers/gpu/drm/i915/display/intel_casf.h
+++ b/drivers/gpu/drm/i915/display/intel_casf.h
@@ -9,9 +9,16 @@
#include <linux/types.h>
struct intel_crtc_state;
+struct intel_atomic_state;
+struct intel_crtc;
void intel_casf_enable(struct intel_crtc_state *crtc_state);
void intel_casf_scaler_compute_config(struct intel_crtc_state *crtc_state);
int intel_casf_compute_config(struct intel_crtc_state *crtc_state);
+void intel_filter_lut_load(struct intel_crtc *crtc,
+ const struct intel_crtc_state *crtc_state);
+bool intel_casf_strength_changed(struct intel_crtc_state *new_crtc_state,
+ const struct intel_crtc_state *old_crtc_state);
+void intel_casf_disable(struct intel_crtc_state *crtc_state);
#endif /* __INTEL_CASF_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_casf_regs.h b/drivers/gpu/drm/i915/display/intel_casf_regs.h
index 0b3fcdb22c0c..b4be252a9671 100644
--- a/drivers/gpu/drm/i915/display/intel_casf_regs.h
+++ b/drivers/gpu/drm/i915/display/intel_casf_regs.h
@@ -15,5 +15,25 @@
#define MANTISSA_MASK REG_GENMASK(11, 3)
#define MANTISSA(x) REG_FIELD_PREP(MANTISSA_MASK, (x))
+#define _SHARPNESS_CTL_A 0x682B0
+#define _SHARPNESS_CTL_B 0x68AB0
+#define SHARPNESS_CTL(pipe) _MMIO_PIPE(pipe, _SHARPNESS_CTL_A, _SHARPNESS_CTL_B)
+#define FILTER_EN REG_BIT(31)
+#define FILTER_STRENGTH_MASK REG_GENMASK(15, 8)
+#define FILTER_STRENGTH(x) REG_FIELD_PREP(FILTER_STRENGTH_MASK, (x))
+#define FILTER_SIZE_MASK REG_GENMASK(1, 0)
+#define FILTER_SIZE(x) REG_FIELD_PREP(FILTER_SIZE_MASK, (x))
+
+#define _SHRPLUT_DATA_A 0x682B8
+#define _SHRPLUT_DATA_B 0x68AB8
+#define SHRPLUT_DATA(pipe) _MMIO_PIPE(pipe, _SHRPLUT_DATA_A, _SHRPLUT_DATA_B)
+
+#define _SHRPLUT_INDEX_A 0x682B4
+#define _SHRPLUT_INDEX_B 0x68AB4
+#define SHRPLUT_INDEX(pipe) _MMIO_PIPE(pipe, _SHRPLUT_INDEX_A, _SHRPLUT_INDEX_B)
+#define INDEX_AUTO_INCR REG_BIT(10)
+#define INDEX_VALUE_MASK REG_GENMASK(4, 0)
+#define INDEX_VALUE(x) REG_FIELD_PREP(INDEX_VALUE_MASK, (x))
+
#endif /* __INTEL_CASF_REGS__ */
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index beef3a76eba4..67dfd428d85f 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -6179,7 +6179,9 @@ static int intel_atomic_check_planes(struct intel_atomic_state *state)
if (ret)
return ret;
- intel_casf_scaler_compute_config(new_crtc_state);
+ ret = intel_casf_compute_config(new_crtc_state);
+ if (ret)
+ return ret;
/*
* On some platforms the number of active planes affects
--
2.25.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 6/6] drm/i915/display: Load the lut values and enable sharpness
2025-01-10 6:32 [PATCH 0/6] Introduce drm sharpness property Nemesa Garg
` (4 preceding siblings ...)
2025-01-10 6:32 ` [PATCH v6 5/6] drm/i915/display: Add registers and compute the strength Nemesa Garg
@ 2025-01-10 6:32 ` Nemesa Garg
2025-01-10 7:18 ` ✗ CI.Patch_applied: failure for Introduce drm sharpness property (rev4) Patchwork
6 siblings, 0 replies; 12+ messages in thread
From: Nemesa Garg @ 2025-01-10 6:32 UTC (permalink / raw)
To: intel-gfx, intel-xe; +Cc: Nemesa Garg, Naga Venkata Srikanth V
Load the lut values during pipe enable.
v2: Add the display version check
v3: Fix build issue
Signed-off-by: Nemesa Garg <nemesa.garg@intel.com>
Reviewed-by: Naga Venkata Srikanth V <nagavenkata.srikanth.v@intel.com>
---
drivers/gpu/drm/i915/display/intel_crtc.c | 3 +++
drivers/gpu/drm/i915/display/intel_display.c | 6 ++++++
drivers/gpu/drm/i915/display/intel_display_types.h | 2 ++
drivers/gpu/drm/i915/display/skl_scaler.c | 14 +++++++++++++-
4 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c b/drivers/gpu/drm/i915/display/intel_crtc.c
index c910168602d2..f502530a98af 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -389,6 +389,9 @@ int intel_crtc_init(struct drm_i915_private *dev_priv, enum pipe pipe)
drm_WARN_ON(&dev_priv->drm, drm_crtc_index(&crtc->base) != crtc->pipe);
+ if (DISPLAY_VER(dev_priv) >= 20)
+ drm_crtc_create_sharpness_strength_property(&crtc->base);
+
return 0;
fail:
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 67dfd428d85f..0995881aecb8 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -1881,6 +1881,9 @@ static void hsw_crtc_enable(struct intel_atomic_state *state,
intel_crtc_wait_for_next_vblank(wa_crtc);
}
}
+
+ if (new_crtc_state->hw.casf_params.strength_changed)
+ intel_filter_lut_load(crtc, new_crtc_state);
}
void ilk_pfit_disable(const struct intel_crtc_state *old_crtc_state)
@@ -7182,6 +7185,9 @@ static void intel_pre_update_crtc(struct intel_atomic_state *state,
intel_vrr_set_transcoder_timings(new_crtc_state);
}
+ if (intel_casf_strength_changed(new_crtc_state, old_crtc_state))
+ intel_casf_enable(new_crtc_state);
+
intel_fbc_update(state, crtc);
drm_WARN_ON(&i915->drm, !intel_display_power_is_enabled(i915, POWER_DOMAIN_DC_OFF));
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index e5d28377bd0b..589596bfd8c3 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -940,6 +940,8 @@ struct intel_casf {
struct scaler_filter_coeff coeff[SCALER_FILTER_NUM_TAPS];
u8 win_size;
bool need_scaler;
+ bool strength_changed;
+ u8 strength;
};
void intel_io_mmio_fw_write(void *ctx, i915_reg_t reg, u32 val);
diff --git a/drivers/gpu/drm/i915/display/skl_scaler.c b/drivers/gpu/drm/i915/display/skl_scaler.c
index 57396f610c89..01b1cbaae28f 100644
--- a/drivers/gpu/drm/i915/display/skl_scaler.c
+++ b/drivers/gpu/drm/i915/display/skl_scaler.c
@@ -8,6 +8,7 @@
#include "intel_de.h"
#include "intel_display_types.h"
#include "intel_fb.h"
+#include "intel_casf_regs.h"
#include "skl_scaler.h"
#include "skl_universal_plane.h"
@@ -875,7 +876,7 @@ void skl_scaler_get_config(struct intel_crtc_state *crtc_state)
/* find scaler attached to this pipe */
for (i = 0; i < crtc->num_scalers; i++) {
- u32 ctl, pos, size;
+ u32 ctl, pos, size, sharp;
ctl = intel_de_read(display, SKL_PS_CTRL(crtc->pipe, i));
if ((ctl & (PS_SCALER_EN | PS_BINDING_MASK)) != (PS_SCALER_EN | PS_BINDING_PIPE))
@@ -883,6 +884,17 @@ void skl_scaler_get_config(struct intel_crtc_state *crtc_state)
id = i;
+ if (DISPLAY_VER(display) >= 20) {
+ sharp = intel_de_read(display, SHARPNESS_CTL(crtc->pipe));
+ if (sharp & FILTER_EN) {
+ crtc_state->hw.casf_params.strength =
+ REG_FIELD_GET(FILTER_STRENGTH_MASK, sharp) - 16;
+ crtc_state->hw.casf_params.need_scaler = true;
+ crtc_state->hw.casf_params.win_size =
+ REG_FIELD_GET(FILTER_SIZE_MASK, sharp);
+ }
+ }
+
if (!crtc_state->hw.casf_params.need_scaler)
crtc_state->pch_pfit.enabled = true;
--
2.25.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* ✗ CI.Patch_applied: failure for Introduce drm sharpness property (rev4)
2025-01-10 6:32 [PATCH 0/6] Introduce drm sharpness property Nemesa Garg
` (5 preceding siblings ...)
2025-01-10 6:32 ` [PATCH 6/6] drm/i915/display: Load the lut values and enable sharpness Nemesa Garg
@ 2025-01-10 7:18 ` Patchwork
6 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2025-01-10 7:18 UTC (permalink / raw)
To: Nemesa Garg; +Cc: intel-xe
== Series Details ==
Series: Introduce drm sharpness property (rev4)
URL : https://patchwork.freedesktop.org/series/139954/
State : failure
== Summary ==
=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: d84d114c03ee drm-tip: 2025y-01m-10d-07h-11m-56s UTC integration manifest
=== git am output follows ===
.git/rebase-apply/patch:220: new blank line at EOF.
+
warning: 1 line adds whitespace errors.
error: patch failed: drivers/gpu/drm/i915/display/skl_scaler.c:98
error: drivers/gpu/drm/i915/display/skl_scaler.c: patch does not apply
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Applying: drm: Introduce sharpness strength property
Applying: drm/i915/display: Compute the scaler filter coefficients
Applying: drm/i915/display: Configure the scaler
Patch failed at 0003 drm/i915/display: Configure the scaler
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/6] drm: Introduce sharpness strength property
2025-01-13 10:49 [PATCH 0/6] Introduce drm sharpness property Nemesa Garg
@ 2025-01-13 10:49 ` Nemesa Garg
0 siblings, 0 replies; 12+ messages in thread
From: Nemesa Garg @ 2025-01-13 10:49 UTC (permalink / raw)
To: intel-gfx, intel-xe; +Cc: Nemesa Garg
Introduces the new crtc property "SHARPNESS_STRENGTH" that allows
the user to set the intensity so as to get the sharpness effect.
The value of this property can be set from 0-255.
It is useful in scenario when the output is blurry and user
want to sharpen the pixels. User can increase/decrease the
sharpness level depending on the content displayed.
v2: Rename crtc property variable [Arun]
Add modeset detail in uapi doc[Uma]
v3: Fix build issue
Signed-off-by: Nemesa Garg <nemesa.garg@intel.com>
---
drivers/gpu/drm/drm_atomic_uapi.c | 4 ++++
drivers/gpu/drm/drm_crtc.c | 35 +++++++++++++++++++++++++++++++
include/drm/drm_crtc.h | 17 +++++++++++++++
3 files changed, 56 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index 370dc676e3aa..b482bc2b5d0a 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -417,6 +417,8 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
set_out_fence_for_crtc(state->state, crtc, fence_ptr);
} else if (property == crtc->scaling_filter_property) {
state->scaling_filter = val;
+ } else if (property == crtc->sharpness_strength_property) {
+ state->sharpness_strength = val;
} else if (crtc->funcs->atomic_set_property) {
return crtc->funcs->atomic_set_property(crtc, state, property, val);
} else {
@@ -454,6 +456,8 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
*val = 0;
else if (property == crtc->scaling_filter_property)
*val = state->scaling_filter;
+ else if (property == crtc->sharpness_strength_property)
+ *val = state->sharpness_strength;
else if (crtc->funcs->atomic_get_property)
return crtc->funcs->atomic_get_property(crtc, state, property, val);
else {
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 46655339003d..1b7ce99cea5e 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -229,6 +229,25 @@ struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc)
* Driver's default scaling filter
* Nearest Neighbor:
* Nearest Neighbor scaling filter
+ * SHARPNESS_STRENGTH:
+ * Atomic property for setting the sharpness strength/intensity by userspace.
+ *
+ * The value of this property is set as an integer value ranging
+ * from 0 - 255 where:
+ *
+ * 0 means feature is disabled.
+ *
+ * 1 means minimum sharpness.
+ *
+ * 255 means maximum sharpness.
+ *
+ * User can gradually increase or decrease the sharpness level and can
+ * set the optimum value depending on content and this value will be
+ * passed to kernel through the Uapi.
+ * The setting of this property does not require modeset.
+ * The sharpness effect takes place post blending on the final composed output.
+ * If the feature is disabled, the content remains same without any sharpening effect
+ * and when this feature is applied, it enhances the clarity of the content.
*/
__printf(6, 0)
@@ -940,6 +959,22 @@ int drm_crtc_create_scaling_filter_property(struct drm_crtc *crtc,
}
EXPORT_SYMBOL(drm_crtc_create_scaling_filter_property);
+int drm_crtc_create_sharpness_strength_property(struct drm_crtc *crtc)
+{
+ struct drm_device *dev = crtc->dev;
+ struct drm_property *prop =
+ drm_property_create_range(dev, 0, "SHARPNESS_STRENGTH", 0, 255);
+
+ if (!prop)
+ return -ENOMEM;
+
+ crtc->sharpness_strength_property = prop;
+ drm_object_attach_property(&crtc->base, prop, 0);
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_crtc_create_sharpness_strength_property);
+
/**
* drm_crtc_in_clone_mode - check if the given CRTC state is in clone mode
*
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index caa56e039da2..ffcfe5c50dab 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -317,6 +317,16 @@ struct drm_crtc_state {
*/
enum drm_scaling_filter scaling_filter;
+ /**
+ * @sharpness_strength
+ *
+ * Used by the user to set the sharpness intensity.
+ * The value ranges from 0-255.
+ * Any value greater than 0 means enabling the featuring
+ * along with setting the value for sharpness.
+ */
+ u8 sharpness_strength;
+
/**
* @event:
*
@@ -1088,6 +1098,12 @@ struct drm_crtc {
*/
struct drm_property *scaling_filter_property;
+ /**
+ * @sharpness_strength_prop: property to apply
+ * the intensity of the sharpness requested.
+ */
+ struct drm_property *sharpness_strength_property;
+
/**
* @state:
*
@@ -1324,4 +1340,5 @@ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
int drm_crtc_create_scaling_filter_property(struct drm_crtc *crtc,
unsigned int supported_filters);
bool drm_crtc_in_clone_mode(struct drm_crtc_state *crtc_state);
+int drm_crtc_create_sharpness_strength_property(struct drm_crtc *crtc);
#endif /* __DRM_CRTC_H__ */
--
2.25.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 1/6] drm: Introduce sharpness strength property
2025-02-14 15:11 [PATCH 0/6] Introduce drm sharpness property Nemesa Garg
@ 2025-02-14 15:11 ` Nemesa Garg
0 siblings, 0 replies; 12+ messages in thread
From: Nemesa Garg @ 2025-02-14 15:11 UTC (permalink / raw)
To: intel-xe, dri-devel; +Cc: Nemesa Garg
Introduces the new crtc property "SHARPNESS_STRENGTH" that allows
the user to set the intensity so as to get the sharpness effect.
The value of this property can be set from 0-255.
It is useful in scenario when the output is blurry and user
want to sharpen the pixels. User can increase/decrease the
sharpness level depending on the content displayed.
v2: Rename crtc property variable [Arun]
Add modeset detail in uapi doc[Uma]
v3: Fix build issue
Signed-off-by: Nemesa Garg <nemesa.garg@intel.com>
---
drivers/gpu/drm/drm_atomic_uapi.c | 4 ++++
drivers/gpu/drm/drm_crtc.c | 35 +++++++++++++++++++++++++++++++
include/drm/drm_crtc.h | 17 +++++++++++++++
3 files changed, 56 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index 370dc676e3aa..b482bc2b5d0a 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -417,6 +417,8 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
set_out_fence_for_crtc(state->state, crtc, fence_ptr);
} else if (property == crtc->scaling_filter_property) {
state->scaling_filter = val;
+ } else if (property == crtc->sharpness_strength_property) {
+ state->sharpness_strength = val;
} else if (crtc->funcs->atomic_set_property) {
return crtc->funcs->atomic_set_property(crtc, state, property, val);
} else {
@@ -454,6 +456,8 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
*val = 0;
else if (property == crtc->scaling_filter_property)
*val = state->scaling_filter;
+ else if (property == crtc->sharpness_strength_property)
+ *val = state->sharpness_strength;
else if (crtc->funcs->atomic_get_property)
return crtc->funcs->atomic_get_property(crtc, state, property, val);
else {
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 46655339003d..1b7ce99cea5e 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -229,6 +229,25 @@ struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc)
* Driver's default scaling filter
* Nearest Neighbor:
* Nearest Neighbor scaling filter
+ * SHARPNESS_STRENGTH:
+ * Atomic property for setting the sharpness strength/intensity by userspace.
+ *
+ * The value of this property is set as an integer value ranging
+ * from 0 - 255 where:
+ *
+ * 0 means feature is disabled.
+ *
+ * 1 means minimum sharpness.
+ *
+ * 255 means maximum sharpness.
+ *
+ * User can gradually increase or decrease the sharpness level and can
+ * set the optimum value depending on content and this value will be
+ * passed to kernel through the Uapi.
+ * The setting of this property does not require modeset.
+ * The sharpness effect takes place post blending on the final composed output.
+ * If the feature is disabled, the content remains same without any sharpening effect
+ * and when this feature is applied, it enhances the clarity of the content.
*/
__printf(6, 0)
@@ -940,6 +959,22 @@ int drm_crtc_create_scaling_filter_property(struct drm_crtc *crtc,
}
EXPORT_SYMBOL(drm_crtc_create_scaling_filter_property);
+int drm_crtc_create_sharpness_strength_property(struct drm_crtc *crtc)
+{
+ struct drm_device *dev = crtc->dev;
+ struct drm_property *prop =
+ drm_property_create_range(dev, 0, "SHARPNESS_STRENGTH", 0, 255);
+
+ if (!prop)
+ return -ENOMEM;
+
+ crtc->sharpness_strength_property = prop;
+ drm_object_attach_property(&crtc->base, prop, 0);
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_crtc_create_sharpness_strength_property);
+
/**
* drm_crtc_in_clone_mode - check if the given CRTC state is in clone mode
*
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index caa56e039da2..ffcfe5c50dab 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -317,6 +317,16 @@ struct drm_crtc_state {
*/
enum drm_scaling_filter scaling_filter;
+ /**
+ * @sharpness_strength
+ *
+ * Used by the user to set the sharpness intensity.
+ * The value ranges from 0-255.
+ * Any value greater than 0 means enabling the featuring
+ * along with setting the value for sharpness.
+ */
+ u8 sharpness_strength;
+
/**
* @event:
*
@@ -1088,6 +1098,12 @@ struct drm_crtc {
*/
struct drm_property *scaling_filter_property;
+ /**
+ * @sharpness_strength_prop: property to apply
+ * the intensity of the sharpness requested.
+ */
+ struct drm_property *sharpness_strength_property;
+
/**
* @state:
*
@@ -1324,4 +1340,5 @@ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
int drm_crtc_create_scaling_filter_property(struct drm_crtc *crtc,
unsigned int supported_filters);
bool drm_crtc_in_clone_mode(struct drm_crtc_state *crtc_state);
+int drm_crtc_create_sharpness_strength_property(struct drm_crtc *crtc);
#endif /* __DRM_CRTC_H__ */
--
2.25.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 1/6] drm: Introduce sharpness strength property
2025-02-19 11:53 [PATCH 0/6] Introduce drm sharpness property Nemesa Garg
@ 2025-02-19 11:53 ` Nemesa Garg
2025-02-20 8:20 ` kernel test robot
0 siblings, 1 reply; 12+ messages in thread
From: Nemesa Garg @ 2025-02-19 11:53 UTC (permalink / raw)
To: intel-gfx, intel-xe, dri-devel; +Cc: Nemesa Garg
Introduces the new crtc property "SHARPNESS_STRENGTH" that allows
the user to set the intensity so as to get the sharpness effect.
The value of this property can be set from 0-255.
It is useful in scenario when the output is blurry and user
want to sharpen the pixels. User can increase/decrease the
sharpness level depending on the content displayed.
v2: Rename crtc property variable [Arun]
Add modeset detail in uapi doc[Uma]
v3: Fix build issue
Signed-off-by: Nemesa Garg <nemesa.garg@intel.com>
---
drivers/gpu/drm/drm_atomic_uapi.c | 4 ++++
drivers/gpu/drm/drm_crtc.c | 35 +++++++++++++++++++++++++++++++
include/drm/drm_crtc.h | 17 +++++++++++++++
3 files changed, 56 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index 2765ba90ad8f..65eea6362fc0 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -418,6 +418,8 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
set_out_fence_for_crtc(state->state, crtc, fence_ptr);
} else if (property == crtc->scaling_filter_property) {
state->scaling_filter = val;
+ } else if (property == crtc->sharpness_strength_property) {
+ state->sharpness_strength = val;
} else if (crtc->funcs->atomic_set_property) {
return crtc->funcs->atomic_set_property(crtc, state, property, val);
} else {
@@ -455,6 +457,8 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
*val = 0;
else if (property == crtc->scaling_filter_property)
*val = state->scaling_filter;
+ else if (property == crtc->sharpness_strength_property)
+ *val = state->sharpness_strength;
else if (crtc->funcs->atomic_get_property)
return crtc->funcs->atomic_get_property(crtc, state, property, val);
else {
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 46655339003d..1b7ce99cea5e 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -229,6 +229,25 @@ struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc)
* Driver's default scaling filter
* Nearest Neighbor:
* Nearest Neighbor scaling filter
+ * SHARPNESS_STRENGTH:
+ * Atomic property for setting the sharpness strength/intensity by userspace.
+ *
+ * The value of this property is set as an integer value ranging
+ * from 0 - 255 where:
+ *
+ * 0 means feature is disabled.
+ *
+ * 1 means minimum sharpness.
+ *
+ * 255 means maximum sharpness.
+ *
+ * User can gradually increase or decrease the sharpness level and can
+ * set the optimum value depending on content and this value will be
+ * passed to kernel through the Uapi.
+ * The setting of this property does not require modeset.
+ * The sharpness effect takes place post blending on the final composed output.
+ * If the feature is disabled, the content remains same without any sharpening effect
+ * and when this feature is applied, it enhances the clarity of the content.
*/
__printf(6, 0)
@@ -940,6 +959,22 @@ int drm_crtc_create_scaling_filter_property(struct drm_crtc *crtc,
}
EXPORT_SYMBOL(drm_crtc_create_scaling_filter_property);
+int drm_crtc_create_sharpness_strength_property(struct drm_crtc *crtc)
+{
+ struct drm_device *dev = crtc->dev;
+ struct drm_property *prop =
+ drm_property_create_range(dev, 0, "SHARPNESS_STRENGTH", 0, 255);
+
+ if (!prop)
+ return -ENOMEM;
+
+ crtc->sharpness_strength_property = prop;
+ drm_object_attach_property(&crtc->base, prop, 0);
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_crtc_create_sharpness_strength_property);
+
/**
* drm_crtc_in_clone_mode - check if the given CRTC state is in clone mode
*
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index caa56e039da2..ffcfe5c50dab 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -317,6 +317,16 @@ struct drm_crtc_state {
*/
enum drm_scaling_filter scaling_filter;
+ /**
+ * @sharpness_strength
+ *
+ * Used by the user to set the sharpness intensity.
+ * The value ranges from 0-255.
+ * Any value greater than 0 means enabling the featuring
+ * along with setting the value for sharpness.
+ */
+ u8 sharpness_strength;
+
/**
* @event:
*
@@ -1088,6 +1098,12 @@ struct drm_crtc {
*/
struct drm_property *scaling_filter_property;
+ /**
+ * @sharpness_strength_prop: property to apply
+ * the intensity of the sharpness requested.
+ */
+ struct drm_property *sharpness_strength_property;
+
/**
* @state:
*
@@ -1324,4 +1340,5 @@ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
int drm_crtc_create_scaling_filter_property(struct drm_crtc *crtc,
unsigned int supported_filters);
bool drm_crtc_in_clone_mode(struct drm_crtc_state *crtc_state);
+int drm_crtc_create_sharpness_strength_property(struct drm_crtc *crtc);
#endif /* __DRM_CRTC_H__ */
--
2.25.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/6] drm: Introduce sharpness strength property
2025-02-19 11:53 ` [PATCH 1/6] drm: Introduce sharpness strength property Nemesa Garg
@ 2025-02-20 8:20 ` kernel test robot
0 siblings, 0 replies; 12+ messages in thread
From: kernel test robot @ 2025-02-20 8:20 UTC (permalink / raw)
To: Nemesa Garg, intel-gfx, intel-xe, dri-devel; +Cc: oe-kbuild-all, Nemesa Garg
Hi Nemesa,
kernel test robot noticed the following build warnings:
[auto build test WARNING on next-20250219]
[cannot apply to drm-xe/drm-xe-next drm-exynos/exynos-drm-next linus/master v6.14-rc3 v6.14-rc2 v6.14-rc1 v6.14-rc3]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Nemesa-Garg/drm-Introduce-sharpness-strength-property/20250219-200229
base: next-20250219
patch link: https://lore.kernel.org/r/20250219115359.2320992-2-nemesa.garg%40intel.com
patch subject: [PATCH 1/6] drm: Introduce sharpness strength property
config: s390-allyesconfig (https://download.01.org/0day-ci/archive/20250220/202502201640.Kv91RrH2-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250220/202502201640.Kv91RrH2-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502201640.Kv91RrH2-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> include/drm/drm_crtc.h:321: warning: Incorrect use of kernel-doc format: * @sharpness_strength
>> include/drm/drm_crtc.h:398: warning: Function parameter or struct member 'sharpness_strength' not described in 'drm_crtc_state'
>> include/drm/drm_crtc.h:1194: warning: Function parameter or struct member 'sharpness_strength_property' not described in 'drm_crtc'
>> include/drm/drm_crtc.h:1194: warning: Excess struct member 'sharpness_strength_prop' description in 'drm_crtc'
vim +321 include/drm/drm_crtc.h
65
66 /**
67 * struct drm_crtc_state - mutable CRTC state
68 *
69 * Note that the distinction between @enable and @active is rather subtle:
70 * Flipping @active while @enable is set without changing anything else may
71 * never return in a failure from the &drm_mode_config_funcs.atomic_check
72 * callback. Userspace assumes that a DPMS On will always succeed. In other
73 * words: @enable controls resource assignment, @active controls the actual
74 * hardware state.
75 *
76 * The three booleans active_changed, connectors_changed and mode_changed are
77 * intended to indicate whether a full modeset is needed, rather than strictly
78 * describing what has changed in a commit. See also:
79 * drm_atomic_crtc_needs_modeset()
80 */
81 struct drm_crtc_state {
82 /** @crtc: backpointer to the CRTC */
83 struct drm_crtc *crtc;
84
85 /**
86 * @enable: Whether the CRTC should be enabled, gates all other state.
87 * This controls reservations of shared resources. Actual hardware state
88 * is controlled by @active.
89 */
90 bool enable;
91
92 /**
93 * @active: Whether the CRTC is actively displaying (used for DPMS).
94 * Implies that @enable is set. The driver must not release any shared
95 * resources if @active is set to false but @enable still true, because
96 * userspace expects that a DPMS ON always succeeds.
97 *
98 * Hence drivers must not consult @active in their various
99 * &drm_mode_config_funcs.atomic_check callback to reject an atomic
100 * commit. They can consult it to aid in the computation of derived
101 * hardware state, since even in the DPMS OFF state the display hardware
102 * should be as much powered down as when the CRTC is completely
103 * disabled through setting @enable to false.
104 */
105 bool active;
106
107 /**
108 * @planes_changed: Planes on this crtc are updated. Used by the atomic
109 * helpers and drivers to steer the atomic commit control flow.
110 */
111 bool planes_changed : 1;
112
113 /**
114 * @mode_changed: @mode or @enable has been changed. Used by the atomic
115 * helpers and drivers to steer the atomic commit control flow. See also
116 * drm_atomic_crtc_needs_modeset().
117 *
118 * Drivers are supposed to set this for any CRTC state changes that
119 * require a full modeset. They can also reset it to false if e.g. a
120 * @mode change can be done without a full modeset by only changing
121 * scaler settings.
122 */
123 bool mode_changed : 1;
124
125 /**
126 * @active_changed: @active has been toggled. Used by the atomic
127 * helpers and drivers to steer the atomic commit control flow. See also
128 * drm_atomic_crtc_needs_modeset().
129 */
130 bool active_changed : 1;
131
132 /**
133 * @connectors_changed: Connectors to this crtc have been updated,
134 * either in their state or routing. Used by the atomic
135 * helpers and drivers to steer the atomic commit control flow. See also
136 * drm_atomic_crtc_needs_modeset().
137 *
138 * Drivers are supposed to set this as-needed from their own atomic
139 * check code, e.g. from &drm_encoder_helper_funcs.atomic_check
140 */
141 bool connectors_changed : 1;
142 /**
143 * @zpos_changed: zpos values of planes on this crtc have been updated.
144 * Used by the atomic helpers and drivers to steer the atomic commit
145 * control flow.
146 */
147 bool zpos_changed : 1;
148 /**
149 * @color_mgmt_changed: Color management properties have changed
150 * (@gamma_lut, @degamma_lut or @ctm). Used by the atomic helpers and
151 * drivers to steer the atomic commit control flow.
152 */
153 bool color_mgmt_changed : 1;
154
155 /**
156 * @no_vblank:
157 *
158 * Reflects the ability of a CRTC to send VBLANK events. This state
159 * usually depends on the pipeline configuration. If set to true, DRM
160 * atomic helpers will send out a fake VBLANK event during display
161 * updates after all hardware changes have been committed. This is
162 * implemented in drm_atomic_helper_fake_vblank().
163 *
164 * One usage is for drivers and/or hardware without support for VBLANK
165 * interrupts. Such drivers typically do not initialize vblanking
166 * (i.e., call drm_vblank_init() with the number of CRTCs). For CRTCs
167 * without initialized vblanking, this field is set to true in
168 * drm_atomic_helper_check_modeset(), and a fake VBLANK event will be
169 * send out on each update of the display pipeline by
170 * drm_atomic_helper_fake_vblank().
171 *
172 * Another usage is CRTCs feeding a writeback connector operating in
173 * oneshot mode. In this case the fake VBLANK event is only generated
174 * when a job is queued to the writeback connector, and we want the
175 * core to fake VBLANK events when this part of the pipeline hasn't
176 * changed but others had or when the CRTC and connectors are being
177 * disabled.
178 *
179 * __drm_atomic_helper_crtc_duplicate_state() will not reset the value
180 * from the current state, the CRTC driver is then responsible for
181 * updating this field when needed.
182 *
183 * Note that the combination of &drm_crtc_state.event == NULL and
184 * &drm_crtc_state.no_blank == true is valid and usually used when the
185 * writeback connector attached to the CRTC has a new job queued. In
186 * this case the driver will send the VBLANK event on its own when the
187 * writeback job is complete.
188 */
189 bool no_vblank : 1;
190
191 /**
192 * @plane_mask: Bitmask of drm_plane_mask(plane) of planes attached to
193 * this CRTC.
194 */
195 u32 plane_mask;
196
197 /**
198 * @connector_mask: Bitmask of drm_connector_mask(connector) of
199 * connectors attached to this CRTC.
200 */
201 u32 connector_mask;
202
203 /**
204 * @encoder_mask: Bitmask of drm_encoder_mask(encoder) of encoders
205 * attached to this CRTC.
206 */
207 u32 encoder_mask;
208
209 /**
210 * @adjusted_mode:
211 *
212 * Internal display timings which can be used by the driver to handle
213 * differences between the mode requested by userspace in @mode and what
214 * is actually programmed into the hardware.
215 *
216 * For drivers using &drm_bridge, this stores hardware display timings
217 * used between the CRTC and the first bridge. For other drivers, the
218 * meaning of the adjusted_mode field is purely driver implementation
219 * defined information, and will usually be used to store the hardware
220 * display timings used between the CRTC and encoder blocks.
221 */
222 struct drm_display_mode adjusted_mode;
223
224 /**
225 * @mode:
226 *
227 * Display timings requested by userspace. The driver should try to
228 * match the refresh rate as close as possible (but note that it's
229 * undefined what exactly is close enough, e.g. some of the HDMI modes
230 * only differ in less than 1% of the refresh rate). The active width
231 * and height as observed by userspace for positioning planes must match
232 * exactly.
233 *
234 * For external connectors where the sink isn't fixed (like with a
235 * built-in panel), this mode here should match the physical mode on the
236 * wire to the last details (i.e. including sync polarities and
237 * everything).
238 */
239 struct drm_display_mode mode;
240
241 /**
242 * @mode_blob: &drm_property_blob for @mode, for exposing the mode to
243 * atomic userspace.
244 */
245 struct drm_property_blob *mode_blob;
246
247 /**
248 * @degamma_lut:
249 *
250 * Lookup table for converting framebuffer pixel data before apply the
251 * color conversion matrix @ctm. See drm_crtc_enable_color_mgmt(). The
252 * blob (if not NULL) is an array of &struct drm_color_lut.
253 */
254 struct drm_property_blob *degamma_lut;
255
256 /**
257 * @ctm:
258 *
259 * Color transformation matrix. See drm_crtc_enable_color_mgmt(). The
260 * blob (if not NULL) is a &struct drm_color_ctm.
261 */
262 struct drm_property_blob *ctm;
263
264 /**
265 * @gamma_lut:
266 *
267 * Lookup table for converting pixel data after the color conversion
268 * matrix @ctm. See drm_crtc_enable_color_mgmt(). The blob (if not
269 * NULL) is an array of &struct drm_color_lut.
270 *
271 * Note that for mostly historical reasons stemming from Xorg heritage,
272 * this is also used to store the color map (also sometimes color lut,
273 * CLUT or color palette) for indexed formats like DRM_FORMAT_C8.
274 */
275 struct drm_property_blob *gamma_lut;
276
277 /**
278 * @target_vblank:
279 *
280 * Target vertical blank period when a page flip
281 * should take effect.
282 */
283 u32 target_vblank;
284
285 /**
286 * @async_flip:
287 *
288 * This is set when DRM_MODE_PAGE_FLIP_ASYNC is set in the legacy
289 * PAGE_FLIP IOCTL. It's not wired up for the atomic IOCTL itself yet.
290 */
291 bool async_flip;
292
293 /**
294 * @vrr_enabled:
295 *
296 * Indicates if variable refresh rate should be enabled for the CRTC.
297 * Support for the requested vrr state will depend on driver and
298 * hardware capabiltiy - lacking support is not treated as failure.
299 */
300 bool vrr_enabled;
301
302 /**
303 * @self_refresh_active:
304 *
305 * Used by the self refresh helpers to denote when a self refresh
306 * transition is occurring. This will be set on enable/disable callbacks
307 * when self refresh is being enabled or disabled. In some cases, it may
308 * not be desirable to fully shut off the crtc during self refresh.
309 * CRTC's can inspect this flag and determine the best course of action.
310 */
311 bool self_refresh_active;
312
313 /**
314 * @scaling_filter:
315 *
316 * Scaling filter to be applied
317 */
318 enum drm_scaling_filter scaling_filter;
319
320 /**
> 321 * @sharpness_strength
322 *
323 * Used by the user to set the sharpness intensity.
324 * The value ranges from 0-255.
325 * Any value greater than 0 means enabling the featuring
326 * along with setting the value for sharpness.
327 */
328 u8 sharpness_strength;
329
330 /**
331 * @event:
332 *
333 * Optional pointer to a DRM event to signal upon completion of the
334 * state update. The driver must send out the event when the atomic
335 * commit operation completes. There are two cases:
336 *
337 * - The event is for a CRTC which is being disabled through this
338 * atomic commit. In that case the event can be send out any time
339 * after the hardware has stopped scanning out the current
340 * framebuffers. It should contain the timestamp and counter for the
341 * last vblank before the display pipeline was shut off. The simplest
342 * way to achieve that is calling drm_crtc_send_vblank_event()
343 * somewhen after drm_crtc_vblank_off() has been called.
344 *
345 * - For a CRTC which is enabled at the end of the commit (even when it
346 * undergoes an full modeset) the vblank timestamp and counter must
347 * be for the vblank right before the first frame that scans out the
348 * new set of buffers. Again the event can only be sent out after the
349 * hardware has stopped scanning out the old buffers.
350 *
351 * - Events for disabled CRTCs are not allowed, and drivers can ignore
352 * that case.
353 *
354 * For very simple hardware without VBLANK interrupt, enabling
355 * &struct drm_crtc_state.no_vblank makes DRM's atomic commit helpers
356 * send a fake VBLANK event at the end of the display update after all
357 * hardware changes have been applied. See
358 * drm_atomic_helper_fake_vblank().
359 *
360 * For more complex hardware this
361 * can be handled by the drm_crtc_send_vblank_event() function,
362 * which the driver should call on the provided event upon completion of
363 * the atomic commit. Note that if the driver supports vblank signalling
364 * and timestamping the vblank counters and timestamps must agree with
365 * the ones returned from page flip events. With the current vblank
366 * helper infrastructure this can be achieved by holding a vblank
367 * reference while the page flip is pending, acquired through
368 * drm_crtc_vblank_get() and released with drm_crtc_vblank_put().
369 * Drivers are free to implement their own vblank counter and timestamp
370 * tracking though, e.g. if they have accurate timestamp registers in
371 * hardware.
372 *
373 * For hardware which supports some means to synchronize vblank
374 * interrupt delivery with committing display state there's also
375 * drm_crtc_arm_vblank_event(). See the documentation of that function
376 * for a detailed discussion of the constraints it needs to be used
377 * safely.
378 *
379 * If the device can't notify of flip completion in a race-free way
380 * at all, then the event should be armed just after the page flip is
381 * committed. In the worst case the driver will send the event to
382 * userspace one frame too late. This doesn't allow for a real atomic
383 * update, but it should avoid tearing.
384 */
385 struct drm_pending_vblank_event *event;
386
387 /**
388 * @commit:
389 *
390 * This tracks how the commit for this update proceeds through the
391 * various phases. This is never cleared, except when we destroy the
392 * state, so that subsequent commits can synchronize with previous ones.
393 */
394 struct drm_crtc_commit *commit;
395
396 /** @state: backpointer to global drm_atomic_state */
397 struct drm_atomic_state *state;
> 398 };
399
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-02-20 8:21 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-10 6:32 [PATCH 0/6] Introduce drm sharpness property Nemesa Garg
2025-01-10 6:32 ` [PATCH 1/6] drm: Introduce sharpness strength property Nemesa Garg
2025-01-10 6:32 ` [PATCH v6 2/6] drm/i915/display: Compute the scaler filter coefficients Nemesa Garg
2025-01-10 6:32 ` [PATCH 3/6] drm/i915/display: Configure the scaler Nemesa Garg
2025-01-10 6:32 ` [PATCH v7 4/6] drm/i915/display: Enable the second scaler for sharpness Nemesa Garg
2025-01-10 6:32 ` [PATCH v6 5/6] drm/i915/display: Add registers and compute the strength Nemesa Garg
2025-01-10 6:32 ` [PATCH 6/6] drm/i915/display: Load the lut values and enable sharpness Nemesa Garg
2025-01-10 7:18 ` ✗ CI.Patch_applied: failure for Introduce drm sharpness property (rev4) Patchwork
-- strict thread matches above, loose matches on Subject: below --
2025-01-13 10:49 [PATCH 0/6] Introduce drm sharpness property Nemesa Garg
2025-01-13 10:49 ` [PATCH 1/6] drm: Introduce sharpness strength property Nemesa Garg
2025-02-14 15:11 [PATCH 0/6] Introduce drm sharpness property Nemesa Garg
2025-02-14 15:11 ` [PATCH 1/6] drm: Introduce sharpness strength property Nemesa Garg
2025-02-19 11:53 [PATCH 0/6] Introduce drm sharpness property Nemesa Garg
2025-02-19 11:53 ` [PATCH 1/6] drm: Introduce sharpness strength property Nemesa Garg
2025-02-20 8:20 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox