Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2103652ybh; Fri, 13 Mar 2020 12:55:06 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuVJ9VCfnpj/dlBz6qNhurcrVgVvGnhAo8yvUr7sSock+jTq+D5xdVxuyQ1I/DHNrCiO2dt X-Received: by 2002:a9d:6c99:: with SMTP id c25mr11819105otr.124.1584129305943; Fri, 13 Mar 2020 12:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584129305; cv=none; d=google.com; s=arc-20160816; b=ohEJZKtq5XEATBuFSkhO2x08uO+JenbqpyGeu+3S8BycA16SXn2B+9su6lo4av4gga kuohg8QTmJJkQT293LqLAAMTrBgHYoNHFscgd4xHmgS0V6s9rPe/m1pVj1PhvNJGQTaD KK0lS68vYapiOd43r2Lyq+gRRdnb7gg79Nd9q5i9MriEN0tXht1/gYr4OTs4t14Q6spq iSrG94lVTKURE096rVnTKh2/uUo4h1xDSbgPK1xX9I+d0i89mgKosqIZ88BniYJxquvM OJHXgjhZ4Or+sRD9US6WpCCTwNEYN2vToBBmCq4awkAhDLKPmkyn1mz6Cdi91YqPmIII okXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=xY7NfSDUod2yxE1vkfG3w47n4tqab5mp/yBgqCbx8ds=; b=KIRbk2TfhpJXpbDAhRFZLFS03goIi9fXX9mFfUx1EOVdyPbkJHdh3bQBXiZ5Zm0dK6 Dp6CNuJu5h2SB1lY6clbU/0VTOb+HTEQkyJn1Z5z6/oL3TZDaBpeOo9UQgDZzIhrf/dZ N3COtJxkOAf0xK1EpcFl9sqlB2PEN+2vqJm3OIw4MRcM7VKHI5szcPOjEXLZwtNbN4pn ymb61387enK5BgDW8nIpZzEGFkejUTwdHDPpR6r2qaHXtNpymqPdbjatgcdpuKhgWpbY WI211PQRFlXd+FtyL3DVqQRvlzTFKLA8PgAynuuKAcKb1PsVPRjUNFcED6LLLw+6FUQB U61g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n62si5242303oig.196.2020.03.13.12.54.53; Fri, 13 Mar 2020 12:55:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727613AbgCMTxK (ORCPT + 99 others); Fri, 13 Mar 2020 15:53:10 -0400 Received: from mga11.intel.com ([192.55.52.93]:10904 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727386AbgCMTxI (ORCPT ); Fri, 13 Mar 2020 15:53:08 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Mar 2020 12:53:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,549,1574150400"; d="scan'208";a="278346361" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by fmsmga002.fm.intel.com with SMTP; 13 Mar 2020 12:53:02 -0700 Received: by stinkbox (sSMTP sendmail emulation); Fri, 13 Mar 2020 21:53:01 +0200 Date: Fri, 13 Mar 2020 21:53:01 +0200 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: "Laxminarayan Bharadiya, Pankaj" Cc: "jani.nikula@linux.intel.com" , "daniel@ffwll.ch" , "intel-gfx@lists.freedesktop.org" , "dri-devel@lists.freedesktop.org" , "airlied@linux.ie" , "maarten.lankhorst@linux.intel.com" , "tzimmermann@suse.de" , "mripard@kernel.org" , "mihail.atanassov@arm.com" , Joonas Lahtinen , "Vivi, Rodrigo" , Chris Wilson , "Souza, Jose" , "De Marchi, Lucas" , "Roper, Matthew D" , "Deak, Imre" , "Shankar, Uma" , "linux-kernel@vger.kernel.org" , "Nautiyal, Ankit K" Subject: Re: [RFC][PATCH 5/5] drm/i915/display: Add Nearest-neighbor based integer scaling support Message-ID: <20200313195301.GQ13686@intel.com> References: <20200225070545.4482-1-pankaj.laxminarayan.bharadiya@intel.com> <20200225070545.4482-6-pankaj.laxminarayan.bharadiya@intel.com> <20200310161723.GK13686@intel.com> <20200312135438.GF13686@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Patchwork-Hint: comment User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 13, 2020 at 08:45:35AM +0000, Laxminarayan Bharadiya, Pankaj wrote: > > > > -----Original Message----- > > From: Ville Syrj?l? > > Sent: 12 March 2020 19:25 > > To: Laxminarayan Bharadiya, Pankaj > > > > Cc: jani.nikula@linux.intel.com; daniel@ffwll.ch; intel- > > gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org; airlied@linux.ie; > > maarten.lankhorst@linux.intel.com; tzimmermann@suse.de; > > mripard@kernel.org; mihail.atanassov@arm.com; Joonas Lahtinen > > ; Vivi, Rodrigo ; > > Chris Wilson ; Souza, Jose ; > > De Marchi, Lucas ; Roper, Matthew D > > ; Deak, Imre ; Shankar, > > Uma ; linux-kernel@vger.kernel.org; Nautiyal, Ankit K > > > > Subject: Re: [RFC][PATCH 5/5] drm/i915/display: Add Nearest-neighbor based > > integer scaling support > > > > On Thu, Mar 12, 2020 at 09:13:24AM +0000, Laxminarayan Bharadiya, Pankaj > > wrote: > > > > > > > > > > -----Original Message----- > > > > From: Ville Syrj?l? > > > > Sent: 10 March 2020 21:47 > > > > To: Laxminarayan Bharadiya, Pankaj > > > > > > > > Cc: jani.nikula@linux.intel.com; daniel@ffwll.ch; intel- > > > > gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org; > > > > airlied@linux.ie; maarten.lankhorst@linux.intel.com; > > > > tzimmermann@suse.de; mripard@kernel.org; mihail.atanassov@arm.com; > > > > Joonas Lahtinen ; Vivi, Rodrigo > > > > ; Chris Wilson ; > > > > Souza, Jose ; De Marchi, Lucas > > > > ; Roper, Matthew D > > > > ; Deak, Imre ; > > > > Shankar, Uma ; linux- kernel@vger.kernel.org; > > > > Nautiyal, Ankit K > > > > Subject: Re: [RFC][PATCH 5/5] drm/i915/display: Add Nearest-neighbor > > > > based integer scaling support > > > > > > > > On Tue, Feb 25, 2020 at 12:35:45PM +0530, Pankaj Bharadiya wrote: > > > > > 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. > > > > > > > > > > Program the scaler filter coefficients to enable the NN filter if > > > > > scaling filter property is set to > > > > > DRM_SCALING_FILTER_NEAREST_NEIGHBOR > > > > > and enable integer scaling. > > > > > > > > > > Bspec: 49247 > > > > > > > > > > Signed-off-by: Pankaj Bharadiya > > > > > > > > > > Signed-off-by: Ankit Nautiyal > > > > > --- > > > > > drivers/gpu/drm/i915/display/intel_display.c | 83 > > > > > +++++++++++++++++++- drivers/gpu/drm/i915/display/intel_display.h > > > > > +++++++++++++++++++| > > > > > 2 + drivers/gpu/drm/i915/display/intel_sprite.c | 20 +++-- > > > > > 3 files changed, 97 insertions(+), 8 deletions(-) > > > > > > > > > > diff --git a/drivers/gpu/drm/i915/display/intel_display.c > > > > > b/drivers/gpu/drm/i915/display/intel_display.c > > > > > index b5903ef3c5a0..6d5f59203258 100644 > > > > > --- a/drivers/gpu/drm/i915/display/intel_display.c > > > > > +++ b/drivers/gpu/drm/i915/display/intel_display.c > > > > > @@ -6237,6 +6237,73 @@ 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_setup_nearest_neighbor_filter(struct drm_i915_private > > > > *dev_priv, > > > > > + enum pipe pipe, int scaler_id) > > > > > > > > skl_scaler_... > > > > > > > > > +{ > > > > > + > > > > > + int coeff = 0; > > > > > + int phase = 0; > > > > > + int tap; > > > > > + int val = 0; > > > > > > > > Needlessly wide scope for most of these. > > > > > > > > > + > > > > > + /*enable the index auto increment.*/ > > > > > + intel_de_write_fw(dev_priv, SKL_PS_COEF_INDEX_SET0(pipe, > > > > scaler_id), > > > > > + _PS_COEE_INDEX_AUTO_INC); > > > > > + > > > > > + for (phase = 0; phase < 17; phase++) { > > > > > + for (tap = 0; tap < 7; tap++) { > > > > > + coeff++; > > > > > > > > Can be part of the % check. > > > > > > OK. > > > > > > > > > > > > + if (tap == 3) > > > > > + val = (phase % 2) ? (0x800) : (0x800 << 16); > > > > > > > > Parens overload. > > > > > > OK. Will remove. > > > > > > > > > + > > > > > + if (coeff % 2 == 0) { > > > > > + intel_de_write_fw(dev_priv, > > > > SKL_PS_COEF_DATA_SET0(pipe, scaler_id), val); > > > > > + val = 0; > > > > > > > > Can drop this val=0 if you move the variable into tight scope and > > > > initialize there. > > > > > > Moving val=0 initialization to the tight scope will not work here as > > > we need to retain "val" and write only when 2 coefficients are ready > > > (since 2 coefficients are packed in 1 dword). > > > > > > e.g. for (12th , 11th) coefficients, coefficient reg value should be ( (0 << 16) | > > 0x800). > > > If we initialize val = 0 in tight loop, 0 will be written to coefficient register. > > > > Hmm, right. I guess I'd try to rearrange this to iterate the registers directly > > instead of the phases and taps. Something like this perhaps: > > > > static int cnl_coef_tap(int i) > > { > > return i % 7; > > } > > > > static u16 cnl_coef(int t) > > cnl_coef -> cnl_nearest_filter_coef. Right? Right. > > > { > > return t == 3 ? 0x0800 : 0x3000; > > } > > > > static void cnl_program_nearest_filter_coefs(void) > > { > > int i; > > > > for (i = 0; i < 17 * 7; i += 2) { > > uint32_t tmp; > > int t; > > > > t = cnl_coef_tap(i); > > tmp = cnl_nearest_filter_coef(t); > > > > t = cnl_coef_tap(i + 1); > > tmp |= cnl_nearest_filter_coef(t) << 16; > > > > intel_de_write_fw(tmp); > > } > > } > > > > More readable I think. The downside being all those modulo operations but > > hopefully that's all in the noise when it comes to performance. > > Looks better, thanks for spending time on this. > I will try this out. > > Thanks, > Pankaj > > > > -- > > Ville Syrj?l? > > Intel -- Ville Syrj?l? Intel