Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5799428rwe; Tue, 18 Apr 2023 11:40:35 -0700 (PDT) X-Google-Smtp-Source: AKy350Ys46kYpBksbHvD97WvcVAZ5TXvr37ZQtofl8g2rxy7fa55vGPfxMw6BnqrFy0fXir0LAWk X-Received: by 2002:a17:90b:3103:b0:23d:4229:f7cf with SMTP id gc3-20020a17090b310300b0023d4229f7cfmr440150pjb.41.1681843235349; Tue, 18 Apr 2023 11:40:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681843235; cv=none; d=google.com; s=arc-20160816; b=Wq06sK3iq2ChqnuGTHL0/UcilaQ24Q8FX7UpoMA7Xjs2lsUxgnj8yV+CIrHssbkvz3 s3x92l6pblgYnP0TnVpHXHhakw1iMKuYDVSQtb/auUgf68s1NuI14Ksc+lz0FwpnCIO0 Hz2BNIhPKW8Ew4kFMt4y4WmwbQwllpAnSu420sOGLkliN8D1eZNaBRrc4p/J59Z8/oq+ GJ2xd6xEajLqZcXCBNY3socWVYSmTZrM+R8iDE4jRgYlgwsWRaQG13YoeIywIlEwAjVw /9OJiZi3kgBQ8hpfbSqRDbbm+1uRCi+8nkBtd6Xg+F58g31ryTEYF0BWXYDCbEnw8VHY 8jwA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=ua0oo9eeXc9zXhS//M1rf4SXnH1LROxKXjpcRua2DPo=; b=fjo9M18ieS+9VvXi3L83/zbIlU79j41rnAJWtsQd7xIDkEQBqiXqyHtPMtbLDykGoo T78z3gSnePFkgu8z6almyUNVa1gs1N2Z0h9UuoRFqEJCmP9FudJWgKJTGtMsmO/8m7Fn PYkVY5sCdYcXqsKLiohc6RIKVJODR8Ti9JxUzpTIufTn+omUTbmcQJTl9pAbJ6lGdWdf yQfXIT6WuLqzijkWf0I4KU82vTxLJNgti5/dmX5EVfbYsUilbGarlB/IwR4h7qPPDU+w Sq2lNScfm6aEj+LJb/OhcOOnmkC8XWZA5BwXQA3jZBvm1Sr3gO2aWi7Ihbj6vrFaWQd2 G8dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@panix.com header.s=panix header.b=ZYCWUMKC; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=panix.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a17090ad14800b0023e066d4e2dsi14077010pjw.184.2023.04.18.11.39.58; Tue, 18 Apr 2023 11:40:35 -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; dkim=fail header.i=@panix.com header.s=panix header.b=ZYCWUMKC; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=panix.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232700AbjDRSew (ORCPT + 99 others); Tue, 18 Apr 2023 14:34:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232692AbjDRSev (ORCPT ); Tue, 18 Apr 2023 14:34:51 -0400 Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AEBC59FE for ; Tue, 18 Apr 2023 11:34:50 -0700 (PDT) Received: from localhost.localdomain (dynamic-acs-24-144-188-133.zoominternet.net [24.144.188.133]) by mailbackend.panix.com (Postfix) with ESMTPSA id 4Q1CJS0Dh5z3vh7; Tue, 18 Apr 2023 14:34:47 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=panix.com; s=panix; t=1681842888; bh=HVoOAOXiW8FIexKIWfy7EdgUgQ8uzlULpDO2G8mraJI=; h=From:To:Cc:Subject:Date; b=ZYCWUMKCkO+hDrx6755Jtj/I8kTXaA8G5kNO5NjR/stDlUW0YIteInSz3MPoq5Q1T zNe6UIXNKeOph1Bolao0DCHHtzFkjp2l6SPCh856BaLFpfNGzbMc5L1QmAe1nNkMqe ZdO9peT/rKUnE2Nkg8zmZLWkZj/KuB2yXEcewlc4= From: Pierre Asselin To: dri-devel@lists.freedesktop.org Cc: Pierre Asselin , Javier Martinez Canillas , Thomas Zimmermann , Daniel Vetter , Ard Biesheuvel , Hans de Goede , linux-kernel@vger.kernel.org Subject: [PATCH] firmware/sysfb: Fix VESA format selection Date: Tue, 18 Apr 2023 14:33:25 -0400 Message-Id: <20230418183325.2327-1-pa@panix.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham 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 Some legacy BIOSes report no reserved bits in their 32-bit rgb mode, breaking the calculation of bits_per_pixel in commit f35cd3fa7729 [firmware/sysfb: Fix EFI/VESA format selection]. However they report lfb_depth correctly for those modes. Recompute bits_per_pixel from the color and reserved bit numbers and positions, but also from lfb_depth, keeping the larger result. Link: https://lore.kernel.org/r/4Psm6B6Lqkz1QXM@panix3.panix.com Link: https://lore.kernel.org/r/20230412150225.3757223-1-javierm@redhat.com Fixes: f35cd3fa7729 [firmware/sysfb: Fix EFI/VESA format selection] Signed-off-by: Pierre Asselin --- drivers/firmware/sysfb_simplefb.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/sysfb_simplefb.c b/drivers/firmware/sysfb_simplefb.c index 82c64cb9f531..05dc25a524c8 100644 --- a/drivers/firmware/sysfb_simplefb.c +++ b/drivers/firmware/sysfb_simplefb.c @@ -51,15 +51,17 @@ __init bool sysfb_parse_mode(const struct screen_info *si, * * It's not easily possible to fix this in struct screen_info, * as this could break UAPI. The best solution is to compute - * bits_per_pixel here and ignore lfb_depth. In the loop below, + * bits_per_pixel from the color bits, reserved bits and + * reported lfb_depth, whichever is highest. In the loop below, * ignore simplefb formats with alpha bits, as EFI and VESA * don't specify alpha channels. */ if (si->lfb_depth > 8) { - bits_per_pixel = max(max3(si->red_size + si->red_pos, + bits_per_pixel = max3(max3(si->red_size + si->red_pos, si->green_size + si->green_pos, si->blue_size + si->blue_pos), - si->rsvd_size + si->rsvd_pos); + si->rsvd_size + si->rsvd_pos, + si->lfb_depth); } else { bits_per_pixel = si->lfb_depth; } -- 2.39.2