Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1473592ybh; Fri, 13 Mar 2020 01:46:33 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsPiugp/OKcXICocY4Gn0e+l2iZlKhjYarpCiZlRi3VojMSCFnwgGTDz3+gsRU3UTcsDSoT X-Received: by 2002:a05:6830:168b:: with SMTP id k11mr10357582otr.156.1584089193560; Fri, 13 Mar 2020 01:46:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584089193; cv=none; d=google.com; s=arc-20160816; b=wOGf2DaISS3mG+IXsdmfx0d/HFmllFuB86Run2dymEiexL3LUmROZ+aFmkOidij065 i3uJLJBr2KGkf9xKzVDMcpglbofdNc+2QVbbSxuXsZoD6t9S+N4GM9F5n8UTVOrJ4Kbh qw6tKJykaq/oinWkT7i/LYIgiI3KvUlgydVs0Ov4HxzUY/JmZ9PLazQ7tPt+9skjWQdf DwgR8I2jrvLxzStEXU4B79YIK2zNFqsNwLMx1RijgBfJ9OvEIo3vxjcG21FLVQvULFX4 9WTljrOmazLkliPBOIPZYeaL4Z+92vRXHUJnAlN4we75FAjQO/T0M9HlsFzNYiluRagQ Ttbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=yLhdXrmzlNQbefELYWzrzxYyGVYx6cV+CjpVWE7jktM=; b=OKhSDVojGsNNqhpsfyGZ0geiwk12oHM6BDFizgrP/BxAUG9CHFefxfeOBy4XpxdXN1 cFOwUSGD+lAGZ4HWs3hgfJMRLMlof4lpO+e9SqMDpbF2lpA5s17WU4vyMsCtSadRBAsX kxVEsuiOQPkou2V63vWClaF079Nl2x8Ie1q8X/xrPSq0xfTmAaYwxEzlIMt2whpAYcjV ZuOtTGHmdanok9VcYfge3JX7FE/Ny4z+aiWkEQUlNDV38zsmJiVFwgkcv1d+/Ph87ElQ zuAZsxQdLvIL3QfvLV4yV5POyid1TWfmomBnoecK5rJJNILCDgXlNvI6AkzHmHBlJvcR uPew== 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 z10si1830033otq.214.2020.03.13.01.46.21; Fri, 13 Mar 2020 01:46:33 -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 S1726475AbgCMIpo convert rfc822-to-8bit (ORCPT + 99 others); Fri, 13 Mar 2020 04:45:44 -0400 Received: from mga11.intel.com ([192.55.52.93]:28198 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726310AbgCMIpo (ORCPT ); Fri, 13 Mar 2020 04:45:44 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Mar 2020 01:45:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,548,1574150400"; d="scan'208";a="232354775" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga007.jf.intel.com with ESMTP; 13 Mar 2020 01:45:43 -0700 Received: from fmsmsx604.amr.corp.intel.com (10.18.126.84) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 13 Mar 2020 01:45:41 -0700 Received: from fmsmsx604.amr.corp.intel.com (10.18.126.84) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 13 Mar 2020 01:45:40 -0700 Received: from bgsmsx153.gar.corp.intel.com (10.224.23.4) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Fri, 13 Mar 2020 01:45:39 -0700 Received: from BGSMSX107.gar.corp.intel.com ([169.254.9.15]) by BGSMSX153.gar.corp.intel.com ([169.254.2.116]) with mapi id 14.03.0439.000; Fri, 13 Mar 2020 14:15:36 +0530 From: "Laxminarayan Bharadiya, Pankaj" To: =?iso-8859-1?Q?Ville_Syrj=E4l=E4?= 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 Thread-Topic: [RFC][PATCH 5/5] drm/i915/display: Add Nearest-neighbor based integer scaling support Thread-Index: AQHV66uZeA9shQKOjUiF9Sh/Uqx6m6hBuziAgAMGXKD///ZrAIABlqsQ Date: Fri, 13 Mar 2020 08:45:35 +0000 Message-ID: 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> In-Reply-To: <20200312135438.GF13686@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.223.10.10] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----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? > { > 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