From: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com> To: jani.nikula@linux.intel.com, daniel@ffwll.ch, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ville.syrjala@linux.intel.com, daniels@collabora.com, "Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>, "Rodrigo Vivi" <rodrigo.vivi@intel.com>, "David Airlie" <airlied@linux.ie>, "Chris Wilson" <chris@chris-wilson.co.uk>, "Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>, "José Roberto de Souza" <jose.souza@intel.com>, "Imre Deak" <imre.deak@intel.com>, "Lucas De Marchi" <lucas.demarchi@intel.com>, "Matt Roper" <matthew.d.roper@intel.com> Cc: pankaj.laxminarayan.bharadiya@intel.com Subject: [PATCH 4/5] drm/i915/display: Add Nearest-neighbor based integer scaling support Date: Thu, 12 Mar 2020 16:44:48 +0530 [thread overview] Message-ID: <20200312111449.21202-5-pankaj.laxminarayan.bharadiya@intel.com> (raw) In-Reply-To: <20200312111449.21202-1-pankaj.laxminarayan.bharadiya@intel.com> Integer scaling (IS) is a nearest-neighbor upscaling technique that simply scales up the existing pixels by an integer (i.e., whole number) multiplier.Nearest-neighbor (NN) interpolation works by filling in the missing color values in the upscaled image with that of the coordinate-mapped nearest source pixel value. Both IS and NN preserve the clarity of the original image. Integer scaling is particularly useful for pixel art games that rely on sharp, blocky images to deliver their distinctive look. Introduce skl_scaler_setup_nearest_neighbor_filter() function which configures the scaler filter coefficients to enable nearest-neighbor filtering. Bspec: 49247 changes since RFC: * Refine the skl_scaler_setup_nearest_neighbor_filter() logic (Ville) Signed-off-by: Shashank Sharma <shashank.sharma@intel.com> Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com> Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com> --- drivers/gpu/drm/i915/display/intel_display.c | 66 ++++++++++++++++++++ drivers/gpu/drm/i915/display/intel_display.h | 2 + 2 files changed, 68 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index 8f23c4d51c33..1f88fd5208e8 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -6237,6 +6237,72 @@ void skl_scaler_disable(const struct intel_crtc_state *old_crtc_state) skl_detach_scaler(crtc, i); } +/** + * Theory behind setting nearest-neighbor integer scaling: + * + * 17 phase of 7 taps requires 119 coefficients in 60 dwords per set. + * The letter represents the filter tap (D is the center tap) and the number + * represents the coefficient set for a phase (0-16). + * + * +------------+------------------------+------------------------+ + * |Index value | Data value coeffient 1 | Data value coeffient 2 | + * +------------+------------------------+------------------------+ + * | 00h | B0 | A0 | + * +------------+------------------------+------------------------+ + * | 01h | D0 | C0 | + * +------------+------------------------+------------------------+ + * | 02h | F0 | E0 | + * +------------+------------------------+------------------------+ + * | 03h | A1 | G0 | + * +------------+------------------------+------------------------+ + * | 04h | C1 | B1 | + * +------------+------------------------+------------------------+ + * | ... | ... | ... | + * +------------+------------------------+------------------------+ + * | 38h | B16 | A16 | + * +------------+------------------------+------------------------+ + * | 39h | D16 | C16 | + * +------------+------------------------+------------------------+ + * | 3Ah | F16 | C16 | + * +------------+------------------------+------------------------+ + * | 3Bh | Reserved | G16 | + * +------------+------------------------+------------------------+ + * + * To enable nearest-neighbor scaling: program scaler coefficents with + * the center tap (Dxx) values set to 1 and all other values set to 0 as per + * SCALER_COEFFICIENT_FORMAT + * + */ +void skl_scaler_setup_nearest_neighbor_filter(struct drm_i915_private *dev_priv, + enum pipe pipe, int id, int set) +{ + + int phase; + int coeff = 0; + int val = 0; + + /*enable the index auto increment.*/ + intel_de_write_fw(dev_priv, + SKL_PS_COEF_INDEX_SET(pipe, id, set), + PS_COEE_INDEX_AUTO_INC); + + for (phase = 0; phase < 17; phase++) { + int tap; + + for (tap = 0; tap < 7; tap++) { + if (tap == 3) + val = phase % 2 ? 0x800 : 0x800 << 16; + + if (++coeff % 2 == 0) { + intel_de_write_fw(dev_priv, SKL_PS_COEF_DATA_SET(pipe, id, set), val); + val = 0; + } + } + } + + intel_de_write_fw(dev_priv, SKL_PS_COEF_DATA_SET(pipe, id, set), 0); +} + static void skl_pfit_enable(const struct intel_crtc_state *crtc_state) { struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); diff --git a/drivers/gpu/drm/i915/display/intel_display.h b/drivers/gpu/drm/i915/display/intel_display.h index adb1225a3480..88f3c77f6806 100644 --- a/drivers/gpu/drm/i915/display/intel_display.h +++ b/drivers/gpu/drm/i915/display/intel_display.h @@ -587,6 +587,8 @@ void intel_crtc_arm_fifo_underrun(struct intel_crtc *crtc, u16 skl_scaler_calc_phase(int sub, int scale, bool chroma_center); int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state); void skl_scaler_disable(const struct intel_crtc_state *old_crtc_state); +void skl_scaler_setup_nearest_neighbor_filter(struct drm_i915_private *dev_priv, + enum pipe pipe, int id, int set); void ilk_pfit_disable(const struct intel_crtc_state *old_crtc_state); u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state, const struct intel_plane_state *plane_state); -- 2.23.0 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
WARNING: multiple messages have this Message-ID (diff)
From: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com> To: jani.nikula@linux.intel.com, daniel@ffwll.ch, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ville.syrjala@linux.intel.com, daniels@collabora.com, "Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>, "Rodrigo Vivi" <rodrigo.vivi@intel.com>, "David Airlie" <airlied@linux.ie>, "Chris Wilson" <chris@chris-wilson.co.uk>, "Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>, "José Roberto de Souza" <jose.souza@intel.com>, "Imre Deak" <imre.deak@intel.com>, "Lucas De Marchi" <lucas.demarchi@intel.com>, "Matt Roper" <matthew.d.roper@intel.com> Subject: [Intel-gfx] [PATCH 4/5] drm/i915/display: Add Nearest-neighbor based integer scaling support Date: Thu, 12 Mar 2020 16:44:48 +0530 [thread overview] Message-ID: <20200312111449.21202-5-pankaj.laxminarayan.bharadiya@intel.com> (raw) In-Reply-To: <20200312111449.21202-1-pankaj.laxminarayan.bharadiya@intel.com> Integer scaling (IS) is a nearest-neighbor upscaling technique that simply scales up the existing pixels by an integer (i.e., whole number) multiplier.Nearest-neighbor (NN) interpolation works by filling in the missing color values in the upscaled image with that of the coordinate-mapped nearest source pixel value. Both IS and NN preserve the clarity of the original image. Integer scaling is particularly useful for pixel art games that rely on sharp, blocky images to deliver their distinctive look. Introduce skl_scaler_setup_nearest_neighbor_filter() function which configures the scaler filter coefficients to enable nearest-neighbor filtering. Bspec: 49247 changes since RFC: * Refine the skl_scaler_setup_nearest_neighbor_filter() logic (Ville) Signed-off-by: Shashank Sharma <shashank.sharma@intel.com> Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com> Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com> --- drivers/gpu/drm/i915/display/intel_display.c | 66 ++++++++++++++++++++ drivers/gpu/drm/i915/display/intel_display.h | 2 + 2 files changed, 68 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index 8f23c4d51c33..1f88fd5208e8 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -6237,6 +6237,72 @@ void skl_scaler_disable(const struct intel_crtc_state *old_crtc_state) skl_detach_scaler(crtc, i); } +/** + * Theory behind setting nearest-neighbor integer scaling: + * + * 17 phase of 7 taps requires 119 coefficients in 60 dwords per set. + * The letter represents the filter tap (D is the center tap) and the number + * represents the coefficient set for a phase (0-16). + * + * +------------+------------------------+------------------------+ + * |Index value | Data value coeffient 1 | Data value coeffient 2 | + * +------------+------------------------+------------------------+ + * | 00h | B0 | A0 | + * +------------+------------------------+------------------------+ + * | 01h | D0 | C0 | + * +------------+------------------------+------------------------+ + * | 02h | F0 | E0 | + * +------------+------------------------+------------------------+ + * | 03h | A1 | G0 | + * +------------+------------------------+------------------------+ + * | 04h | C1 | B1 | + * +------------+------------------------+------------------------+ + * | ... | ... | ... | + * +------------+------------------------+------------------------+ + * | 38h | B16 | A16 | + * +------------+------------------------+------------------------+ + * | 39h | D16 | C16 | + * +------------+------------------------+------------------------+ + * | 3Ah | F16 | C16 | + * +------------+------------------------+------------------------+ + * | 3Bh | Reserved | G16 | + * +------------+------------------------+------------------------+ + * + * To enable nearest-neighbor scaling: program scaler coefficents with + * the center tap (Dxx) values set to 1 and all other values set to 0 as per + * SCALER_COEFFICIENT_FORMAT + * + */ +void skl_scaler_setup_nearest_neighbor_filter(struct drm_i915_private *dev_priv, + enum pipe pipe, int id, int set) +{ + + int phase; + int coeff = 0; + int val = 0; + + /*enable the index auto increment.*/ + intel_de_write_fw(dev_priv, + SKL_PS_COEF_INDEX_SET(pipe, id, set), + PS_COEE_INDEX_AUTO_INC); + + for (phase = 0; phase < 17; phase++) { + int tap; + + for (tap = 0; tap < 7; tap++) { + if (tap == 3) + val = phase % 2 ? 0x800 : 0x800 << 16; + + if (++coeff % 2 == 0) { + intel_de_write_fw(dev_priv, SKL_PS_COEF_DATA_SET(pipe, id, set), val); + val = 0; + } + } + } + + intel_de_write_fw(dev_priv, SKL_PS_COEF_DATA_SET(pipe, id, set), 0); +} + static void skl_pfit_enable(const struct intel_crtc_state *crtc_state) { struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); diff --git a/drivers/gpu/drm/i915/display/intel_display.h b/drivers/gpu/drm/i915/display/intel_display.h index adb1225a3480..88f3c77f6806 100644 --- a/drivers/gpu/drm/i915/display/intel_display.h +++ b/drivers/gpu/drm/i915/display/intel_display.h @@ -587,6 +587,8 @@ void intel_crtc_arm_fifo_underrun(struct intel_crtc *crtc, u16 skl_scaler_calc_phase(int sub, int scale, bool chroma_center); int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state); void skl_scaler_disable(const struct intel_crtc_state *old_crtc_state); +void skl_scaler_setup_nearest_neighbor_filter(struct drm_i915_private *dev_priv, + enum pipe pipe, int id, int set); void ilk_pfit_disable(const struct intel_crtc_state *old_crtc_state); u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state, const struct intel_plane_state *plane_state); -- 2.23.0 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2020-03-12 11:25 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-12 11:14 [PATCH 0/5] Introduce drm scaling filter property Pankaj Bharadiya 2020-03-12 11:14 ` [Intel-gfx] " Pankaj Bharadiya 2020-03-12 11:14 ` [PATCH 1/5] drm: Introduce plane and CRTC scaling filter properties Pankaj Bharadiya 2020-03-12 11:14 ` [Intel-gfx] " Pankaj Bharadiya 2020-03-12 11:14 ` [PATCH 2/5] drm/drm-kms.rst: Add plane and CRTC scaling filter property documentation Pankaj Bharadiya 2020-03-12 11:14 ` [Intel-gfx] " Pankaj Bharadiya 2020-03-12 11:14 ` [PATCH 3/5] drm/i915: Introduce scaling filter related registers and bit fields Pankaj Bharadiya 2020-03-12 11:14 ` [Intel-gfx] " Pankaj Bharadiya 2020-03-12 11:14 ` Pankaj Bharadiya [this message] 2020-03-12 11:14 ` [Intel-gfx] [PATCH 4/5] drm/i915/display: Add Nearest-neighbor based integer scaling support Pankaj Bharadiya 2020-03-12 11:14 ` [PATCH 5/5] drm/i915: Enable scaling filter for plane and CRTC Pankaj Bharadiya 2020-03-12 11:14 ` [Intel-gfx] " Pankaj Bharadiya 2020-03-12 12:39 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Introduce drm scaling filter property (rev2) Patchwork 2020-03-12 13:07 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200312111449.21202-5-pankaj.laxminarayan.bharadiya@intel.com \ --to=pankaj.laxminarayan.bharadiya@intel.com \ --cc=airlied@linux.ie \ --cc=chris@chris-wilson.co.uk \ --cc=daniel@ffwll.ch \ --cc=daniels@collabora.com \ --cc=dri-devel@lists.freedesktop.org \ --cc=imre.deak@intel.com \ --cc=intel-gfx@lists.freedesktop.org \ --cc=jani.nikula@linux.intel.com \ --cc=joonas.lahtinen@linux.intel.com \ --cc=jose.souza@intel.com \ --cc=lucas.demarchi@intel.com \ --cc=maarten.lankhorst@linux.intel.com \ --cc=matthew.d.roper@intel.com \ --cc=rodrigo.vivi@intel.com \ --cc=ville.syrjala@linux.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.