Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8535707imu; Tue, 4 Dec 2018 09:51:36 -0800 (PST) X-Google-Smtp-Source: AFSGD/VmS3jx6drTAL1BzybXqm0z7fHDE2fVd1NFE1a3cQngXc+UEDnwcQ4eNzTzvmifFum6RJ4d X-Received: by 2002:a63:dc54:: with SMTP id f20mr17752689pgj.410.1543945896592; Tue, 04 Dec 2018 09:51:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543945896; cv=none; d=google.com; s=arc-20160816; b=Pchkc2+LseW4hBnSGX4hknSvLOcIO4WrpCqBOFoiOBDP6jX0nVPIyA/3XzL5naVPdM OjfgDV8no+p5FGVd3TbosEYKuE9Wl06U16QvEp92cky94I/x77qrcYEZquxqlutax/qA AM6VDxLi+isLeeSUflxAnO7s8An1873MZVRXbR4d7/YBzZSMahFzMGzE3s7YVM2EnTf2 KjeLb3vT8DZ/7Ef6XFtg7ZGz6U+UBzoBzzH9TAJSJZcl4CyTrMVQ0b5DaCuEy8BvTFDf sb/HAyWOWmk/4pF6Wb2gwphbrAc3Qc8ZPUakaB1Pgonj5x+cwgXNoUiov+e90pFdqJFp zeDA== 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=Dl/9aQHgKCmC98o+uBw4jHNtfW2m7AHv+Wru3OrYQqc=; b=j8riHWLafT/Ab6BJi2RGjiBR5apC5wnjlhYM8uAE/cAQGSZJxT3u7c0HyZEFtOHGTc QyrziRw4meJ4C3csIq7BRw3Af0Lmxpk+mQlt8XNa/BYGVIEkXQPTNbdjn0pTFaebMfwp n9Q77SGF09Kt45zdibJQZ4YQx7suEaFqStM+JHMCnu1FNrnRB3R5wib8pG8iV1JVHBq8 sZAZPCJBOmnCuaD4SCrFEbeqa+JBwSuJbAcuZzMUnnDxdRFHp4SDDVex2sdthGqlwRbg A1nmpmamDFtcDAdiq6mpGbuS3/iMRR97vEZBJciwzFQBoBrwAurimey+yQbyvIhzau3c 4xLQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j20si15098346pgg.162.2018.12.04.09.51.20; Tue, 04 Dec 2018 09:51:36 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726906AbeLDRuk (ORCPT + 99 others); Tue, 4 Dec 2018 12:50:40 -0500 Received: from foss.arm.com ([217.140.101.70]:38054 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726038AbeLDRuk (ORCPT ); Tue, 4 Dec 2018 12:50:40 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 75552A78; Tue, 4 Dec 2018 09:50:39 -0800 (PST) Received: from e110455-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 216F13F59C; Tue, 4 Dec 2018 09:50:39 -0800 (PST) Received: by e110455-lin.cambridge.arm.com (Postfix, from userid 1000) id 7E6A86801C3; Tue, 4 Dec 2018 17:50:37 +0000 (GMT) Date: Tue, 4 Dec 2018 17:50:37 +0000 From: Liviu Dudau To: Ayan Halder Cc: Brian Starkey , "malidp@foss.arm.com" , "airlied@linux.ie" , "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" , "maxime.ripard@bootlin.com" , "sean@poorly.run" , "maarten.lankhorst@linux.intel.com" , "corbet@lwn.net" , "mchehab+samsung@kernel.org" , "gregkh@linuxfoundation.org" , "davem@davemloft.net" , "akpm@linux-foundation.org" , "nicolas.ferre@microchip.com" , "arnd@arndb.de" , "linux-doc@vger.kernel.org" , nd Subject: Re: [RFC AFBC 08/12] drm/arm/malidp: Specified the rotation memory requirements for AFBC YUV formats Message-ID: <20181204175037.GP988@e110455-lin.cambridge.arm.com> References: <1543836703-8491-1-git-send-email-ayan.halder@arm.com> <1543836703-8491-9-git-send-email-ayan.halder@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1543836703-8491-9-git-send-email-ayan.halder@arm.com> User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 03, 2018 at 11:32:02AM +0000, Ayan Halder wrote: > The newly supported AFBC YUV formats have the following rotation memory > constraints (in DP550/DP650). > 1. DRM_FORMAT_VUY888/DRM_FORMAT_VUY101010 :- It can rotate upto 8 > horizontal lines in the AFBC output buffer. > 2. DRM_FORMAT_YUV420_8BIT :- It can rotate upto 16 horizontal lines > in the AFBC output buffer. > > Also some of the pixel formats are specified in bits per pixel (rather > than bytes per pixel), so the calculation needs to take note of this. > > Besides there are some difference between DP550 and DP650 and these are > as follows:- > 1. DRM_FORMAT_X0L2 (in uncompressed format) does not support rotation in DP550. > For DP650, it can rotate upto 16 horizontal lines in the AFBC output buffer, > whereas in DP550 (with AFBC), it can rotate upto 8 horizontal lines. > 2. DRM_FORMAT_YUV420_10BIT :- It can rotate upto 8 horizontal lines in > dp550 and 16 horizontal lines in DP650. > > Signed-off-by: Ayan Kumar halder Reviewed-by: Liviu Dudau Best regards, Liviu > --- > drivers/gpu/drm/arm/malidp_hw.c | 101 ++++++++++++++++++++++++++++++++---- > drivers/gpu/drm/arm/malidp_hw.h | 5 +- > drivers/gpu/drm/arm/malidp_planes.c | 3 +- > 3 files changed, 98 insertions(+), 11 deletions(-) > > diff --git a/drivers/gpu/drm/arm/malidp_hw.c b/drivers/gpu/drm/arm/malidp_hw.c > index 4a774be..d9866a8 100644 > --- a/drivers/gpu/drm/arm/malidp_hw.c > +++ b/drivers/gpu/drm/arm/malidp_hw.c > @@ -375,14 +375,39 @@ static void malidp500_modeset(struct malidp_hw_device *hwdev, struct videomode * > malidp_hw_clearbits(hwdev, MALIDP_DISP_FUNC_ILACED, MALIDP_DE_DISPLAY_FUNC); > } > > -static int malidp500_rotmem_required(struct malidp_hw_device *hwdev, u16 w, u16 h, u32 fmt) > +int malidp_format_get_bpp(u32 fmt) > +{ > + int bpp = drm_format_plane_cpp(fmt, 0) * 8; > + > + if (bpp == 0) { > + switch (fmt) { > + case DRM_FORMAT_VUY101010: > + bpp = 30; > + case DRM_FORMAT_YUV420_10BIT: > + bpp = 15; > + break; > + case DRM_FORMAT_YUV420_8BIT: > + bpp = 12; > + break; > + default: > + bpp = 0; > + } > + } > + > + return bpp; > +} > + > +static int malidp500_rotmem_required(struct malidp_hw_device *hwdev, u16 w, > + u16 h, u32 fmt, bool has_modifier) > { > /* > * Each layer needs enough rotation memory to fit 8 lines > * worth of pixel data. Required size is then: > * size = rotated_width * (bpp / 8) * 8; > */ > - return w * drm_format_plane_cpp(fmt, 0) * 8; > + int bpp = malidp_format_get_bpp(fmt); > + > + return w * bpp; > } > > static void malidp500_se_write_pp_coefftab(struct malidp_hw_device *hwdev, > @@ -660,9 +685,9 @@ static void malidp550_modeset(struct malidp_hw_device *hwdev, struct videomode * > malidp_hw_clearbits(hwdev, MALIDP_DISP_FUNC_ILACED, MALIDP_DE_DISPLAY_FUNC); > } > > -static int malidp550_rotmem_required(struct malidp_hw_device *hwdev, u16 w, u16 h, u32 fmt) > +static int malidpx50_get_bytes_per_column(u32 fmt) > { > - u32 bytes_per_col; > + u32 bytes_per_column; > > switch (fmt) { > /* 8 lines at 4 bytes per pixel */ > @@ -688,19 +713,77 @@ static int malidp550_rotmem_required(struct malidp_hw_device *hwdev, u16 w, u16 > case DRM_FORMAT_UYVY: > case DRM_FORMAT_YUYV: > case DRM_FORMAT_X0L0: > - case DRM_FORMAT_X0L2: > - bytes_per_col = 32; > + bytes_per_column = 32; > break; > /* 16 lines at 1.5 bytes per pixel */ > case DRM_FORMAT_NV12: > case DRM_FORMAT_YUV420: > - bytes_per_col = 24; > + /* 8 lines at 3 bytes per pixel */ > + case DRM_FORMAT_VUY888: > + /* 16 lines at 12 bits per pixel */ > + case DRM_FORMAT_YUV420_8BIT: > + /* 8 lines at 3 bytes per pixel */ > + case DRM_FORMAT_P010: > + bytes_per_column = 24; > + break; > + /* 8 lines at 30 bits per pixel */ > + case DRM_FORMAT_VUY101010: > + /* 16 lines at 15 bits per pixel */ > + case DRM_FORMAT_YUV420_10BIT: > + bytes_per_column = 30; > break; > default: > return -EINVAL; > } > > - return w * bytes_per_col; > + return bytes_per_column; > +} > + > +static int malidp550_rotmem_required(struct malidp_hw_device *hwdev, u16 w, > + u16 h, u32 fmt, bool has_modifier) > +{ > + int bytes_per_column = 0; > + > + switch (fmt) { > + /* 8 lines at 15 bits per pixel */ > + case DRM_FORMAT_YUV420_10BIT: > + bytes_per_column = 15; > + break; > + /* Uncompressed YUV 420 10 bit single plane cannot be rotated */ > + case DRM_FORMAT_X0L2: > + if (has_modifier) > + bytes_per_column = 8; > + else > + return -EINVAL; > + break; > + default: > + bytes_per_column = malidpx50_get_bytes_per_column(fmt); > + } > + > + if (bytes_per_column == -EINVAL) > + return bytes_per_column; > + > + return w * bytes_per_column; > +} > + > +static int malidp650_rotmem_required(struct malidp_hw_device *hwdev, u16 w, > + u16 h, u32 fmt, bool has_modifier) > +{ > + int bytes_per_column = 0; > + > + switch (fmt) { > + /* 16 lines at 2 bytes per pixel */ > + case DRM_FORMAT_X0L2: > + bytes_per_column = 32; > + break; > + default: > + bytes_per_column = malidpx50_get_bytes_per_column(fmt); > + } > + > + if (bytes_per_column == -EINVAL) > + return bytes_per_column; > + > + return w * bytes_per_column; > } > > static int malidp550_se_set_scaling_coeffs(struct malidp_hw_device *hwdev, > @@ -979,7 +1062,7 @@ const struct malidp_hw malidp_device[MALIDP_MAX_DEVICES] = { > .in_config_mode = malidp550_in_config_mode, > .set_config_valid = malidp550_set_config_valid, > .modeset = malidp550_modeset, > - .rotmem_required = malidp550_rotmem_required, > + .rotmem_required = malidp650_rotmem_required, > .se_set_scaling_coeffs = malidp550_se_set_scaling_coeffs, > .se_calc_mclk = malidp550_se_calc_mclk, > .enable_memwrite = malidp550_enable_memwrite, > diff --git a/drivers/gpu/drm/arm/malidp_hw.h b/drivers/gpu/drm/arm/malidp_hw.h > index 52188f0..e89a06a 100644 > --- a/drivers/gpu/drm/arm/malidp_hw.h > +++ b/drivers/gpu/drm/arm/malidp_hw.h > @@ -184,7 +184,8 @@ struct malidp_hw { > * Calculate the required rotation memory given the active area > * and the buffer format. > */ > - int (*rotmem_required)(struct malidp_hw_device *hwdev, u16 w, u16 h, u32 fmt); > + int (*rotmem_required)(struct malidp_hw_device *hwdev, u16 w, u16 h, > + u32 fmt, bool has_modifier); > > int (*se_set_scaling_coeffs)(struct malidp_hw_device *hwdev, > struct malidp_se_config *se_config, > @@ -326,6 +327,8 @@ void malidp_se_irq_fini(struct malidp_hw_device *hwdev); > u8 malidp_hw_get_format_id(const struct malidp_hw_regmap *map, > u8 layer_id, u32 format, bool has_modifier); > > +int malidp_format_get_bpp(u32 fmt); > + > static inline u8 malidp_hw_get_pitch_align(struct malidp_hw_device *hwdev, bool rotated) > { > /* > diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c > index 0765cee..d0a00ee 100644 > --- a/drivers/gpu/drm/arm/malidp_planes.c > +++ b/drivers/gpu/drm/arm/malidp_planes.c > @@ -595,7 +595,8 @@ static int malidp_de_plane_check(struct drm_plane *plane, > > val = mp->hwdev->hw->rotmem_required(mp->hwdev, state->crtc_w, > state->crtc_h, > - fb->format->format); > + fb->format->format, > + !!(fb->modifier)); > if (val < 0) > return val; > > -- > 2.7.4 > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯