From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ayan Halder Subject: [PATCH v4 08/10] drm/arm/malidp:- Use the newly introduced malidp_format_get_bpp() instead of relying on cpp for calculating framebuffer size Date: Tue, 12 Mar 2019 18:16:17 +0000 Message-ID: <1552414556-5756-8-git-send-email-ayan.halder@arm.com> References: <1552414556-5756-1-git-send-email-ayan.halder@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <1552414556-5756-1-git-send-email-ayan.halder@arm.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: Ayan Halder , Liviu Dudau , Brian Starkey , "malidp@foss.arm.com" , "maarten.lankhorst@linux.intel.com" , "maxime.ripard@bootlin.com" , "sean@poorly.run" , "airlied@linux.ie" , "daniel@ffwll.ch" , "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" , "alyssa@rosenzweig.io" Cc: nd List-Id: dri-devel@lists.freedesktop.org From: Ayan Kumar Halder Formats like DRM_FORMAT_VUY101010, DRM_FORMAT_YUV420_8BIT and DRM_FORMAT_YUV420_10BIT are expressed in bits per pixel as they have a non integer value of cpp (thus denoted as '0' in drm_format_info[]). Therefore, the calculation of AFBC framebuffer size needs to use malidp_format_get_bpp= (). Changes since v3 (series): - Added the ack - Rebased on the latest drm-misc-next Signed-off-by: Ayan Kumar halder Reviewed-by: Liviu Dudau Acked-by: Alyssa Rosenzweig --- drivers/gpu/drm/arm/malidp_drv.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_= drv.c index c697664..4106f5d 100644 --- a/drivers/gpu/drm/arm/malidp_drv.c +++ b/drivers/gpu/drm/arm/malidp_drv.c @@ -298,6 +298,7 @@ malidp_verify_afbc_framebuffer_size(struct drm_device *= dev, struct drm_gem_object *objs =3D NULL; u32 afbc_superblock_size =3D 0, afbc_superblock_height =3D 0; u32 afbc_superblock_width =3D 0, afbc_size =3D 0; + int bpp =3D 0; =20 switch (mode_cmd->modifier[0] & AFBC_SIZE_MASK) { case AFBC_SIZE_16X16: @@ -314,15 +315,19 @@ malidp_verify_afbc_framebuffer_size(struct drm_device= *dev, n_superblocks =3D (mode_cmd->width / afbc_superblock_width) * (mode_cmd->height / afbc_superblock_height); =20 - afbc_superblock_size =3D info->cpp[0] * afbc_superblock_width * - afbc_superblock_height; + bpp =3D malidp_format_get_bpp(info->format); + + afbc_superblock_size =3D (bpp * afbc_superblock_width * afbc_superblock_h= eight) + / BITS_PER_BYTE; =20 afbc_size =3D ALIGN(n_superblocks * AFBC_HEADER_SIZE, AFBC_SUPERBLK_ALIGN= MENT); afbc_size +=3D n_superblocks * ALIGN(afbc_superblock_size, AFBC_SUPERBLK_= ALIGNMENT); =20 - if (mode_cmd->width * info->cpp[0] !=3D mode_cmd->pitches[0]) { - DRM_DEBUG_KMS("Invalid value of pitch (=3D%u) should be same as width (= =3D%u) * cpp (=3D%u)\n", - mode_cmd->pitches[0], mode_cmd->width, info->cpp[0]); + if ((mode_cmd->width * bpp) !=3D (mode_cmd->pitches[0] * BITS_PER_BYTE)) = { + DRM_DEBUG_KMS("Invalid value of (pitch * BITS_PER_BYTE) (=3D%u) " + "should be same as width (=3D%u) * bpp (=3D%u)\n", + (mode_cmd->pitches[0] * BITS_PER_BYTE), + mode_cmd->width, bpp); return false; } =20 --=20 2.7.4