Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp771253imw; Fri, 8 Jul 2022 11:22:33 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vbFXeY61i11MbY4dpWa4WYbzBnVKSoHCQatV7W+2i/bSVke5BX2jdn0Yi6cF+1mxnzk4NW X-Received: by 2002:a63:e758:0:b0:412:28d8:6c85 with SMTP id j24-20020a63e758000000b0041228d86c85mr4284834pgk.283.1657304553455; Fri, 08 Jul 2022 11:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657304553; cv=none; d=google.com; s=arc-20160816; b=kgQplMwP5m9c+5BQ5MtStUiet3LQAfdxjkEamvl/scPNXJnNtkvWevR+JHf1OyAU0m SOAzTGWCgycPN0hY7+Iouxwy2hLM0rtNVEq10DmJo9BlyRnjmdD0qzpZQo82S2LGIFFE 1uy+1Wxe8NRl20w5cDVICYrYDo4spwfCbWEqcRnFdYb3BtzR1Tm9u6I97d2OGepZk4Of klfIpsrym+nLZE+H1JLJZCQVxGJ7gZd3crn8MADxWO9npztBUJg+QXWs1WYK28+gaOyp snpRtRY3+y9OaNHMNfp+MxTGCR/S3whPMvppYSPD7b730vLx/1jUolhAgKYTiWqWFUU/ cZsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ltFBDxYt6fD9VGkYPTL6iIF/WjIXvctu00pJcZtnj5E=; b=WDa+zk7VYru5knZWefJOYwjZQFQ0PGMh5DOpfWqklt7GSmngdULwlk5md40ds+qc7u cg29X1+8TdJEr6qcPpFYv09QQ0SdgY1HtGaCk7wB4RdK83mBc872hEgcTM31Ok6ihPu1 dZdMoDguO89sFS2u3saDLL57MglzXoWFH9MYkUl5p7Xv76FHWpYB2dWsEkmIZ7bd5Js5 cZd0wASpEoUOECZYXNXDG9h/TR4DCb9vFHKUqcgFHm22Go6cf1BlIW0viSHTeSqUPtL/ mb4uHNbn4Nf0zSJTBT56fOL5fxauHs0RjALT8IzjhNb3N0VYWufXk1ZA5gOvng2KtiYt 9Urg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y186-20020a638ac3000000b0040d5dc5b896si7783740pgd.519.2022.07.08.11.22.20; Fri, 08 Jul 2022 11:22:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239043AbiGHSVc (ORCPT + 99 others); Fri, 8 Jul 2022 14:21:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239113AbiGHSVP (ORCPT ); Fri, 8 Jul 2022 14:21:15 -0400 Received: from michel.telenet-ops.be (michel.telenet-ops.be [IPv6:2a02:1800:110:4::f00:18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE3CA8238D for ; Fri, 8 Jul 2022 11:21:10 -0700 (PDT) Received: from ramsan.of.borg ([84.195.186.194]) by michel.telenet-ops.be with bizsmtp id siM72700H4C55Sk06iM7fj; Fri, 08 Jul 2022 20:21:08 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1o9sbC-002fGo-U2; Fri, 08 Jul 2022 20:21:06 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1o9sbC-00BtJo-H9; Fri, 08 Jul 2022 20:21:06 +0200 From: Geert Uytterhoeven To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-m68k@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven , Javier Martinez Canillas Subject: [PATCH v3 07/10] drm/gem-fb-helper: Use actual bpp for size calculations Date: Fri, 8 Jul 2022 20:20:52 +0200 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The AFBC helpers derive the number of bits per pixel from the deprecated drm_format_info.cpp[] field, which does not take into account block sizes. Fix this by using the actual number of bits per pixel instead. Signed-off-by: Geert Uytterhoeven Reviewed-by: Javier Martinez Canillas --- Compile-tested only. v3: - Add Reviewed-by, v2: - Replace FIXME by TODO comment. --- drivers/gpu/drm/drm_gem_framebuffer_helper.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_framebuffer_helper.c b/drivers/gpu/drm/drm_gem_framebuffer_helper.c index f4619803acd01e96..6b680ca8c0cfd8d7 100644 --- a/drivers/gpu/drm/drm_gem_framebuffer_helper.c +++ b/drivers/gpu/drm/drm_gem_framebuffer_helper.c @@ -492,6 +492,8 @@ void drm_gem_fb_end_cpu_access(struct drm_framebuffer *fb, enum dma_data_directi } EXPORT_SYMBOL(drm_gem_fb_end_cpu_access); +// TODO Drop this function and replace by drm_format_info_bpp() once all +// DRM_FORMAT_* provide proper block info in drivers/gpu/drm/drm_fourcc.c static __u32 drm_gem_afbc_get_bpp(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cmd) { @@ -499,11 +501,6 @@ static __u32 drm_gem_afbc_get_bpp(struct drm_device *dev, info = drm_get_format_info(dev, mode_cmd); - /* use whatever a driver has set */ - if (info->cpp[0]) - return info->cpp[0] * 8; - - /* guess otherwise */ switch (info->format) { case DRM_FORMAT_YUV420_8BIT: return 12; @@ -512,11 +509,8 @@ static __u32 drm_gem_afbc_get_bpp(struct drm_device *dev, case DRM_FORMAT_VUY101010: return 30; default: - break; + return drm_format_info_bpp(info, 0); } - - /* all attempts failed */ - return 0; } static int drm_gem_afbc_min_size(struct drm_device *dev, -- 2.25.1