Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp600503ybz; Fri, 24 Apr 2020 06:11:02 -0700 (PDT) X-Google-Smtp-Source: APiQypKni+2lam17KZUqwn1jeiRawTx07TPsY1+XsHp6Bc6j/5Y9KeggO6UVcNDxGZtbrt7NuDu6 X-Received: by 2002:a17:906:5003:: with SMTP id s3mr6790586ejj.266.1587733862015; Fri, 24 Apr 2020 06:11:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587733862; cv=none; d=google.com; s=arc-20160816; b=yXnlq5BdLnq71Bu62qZQ36KOPXQJ6T5JG++WjLepO/suT+HT9nXC5oIkllMFYfRVvm e6rIuevbQv16+wtc6nrYIuX/xOK0rU+k+gxQfzHED4W/jeLOWtFdGbUMVKQLo+aoemuu cTP604lSsonXRiP59sFOCXUHaicXB7qCJMKJqN5yeAfNHPG6YUl+YHc+B3pt+VdBmAc/ rhRWkMw0lSDUzjr1zkwLUwtsAYFnL1jj1Mygr62Zfibi+TS5078Ad/NIPrJJb6ex9OWj LSRiRwKGlV2sDbu33WbH+8q6Ykf6pnzUAEaAIIo3O5SQDWejpbcRlVtZG5kOAoqcfNF0 Yy2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=PattAk1YZLVlYOj2QDgW+PxE4iGQb/UXD6ejpGo4s+A=; b=wVUbs3LLo2bexzdyvv8dllqwaWv4E7L0Z9Q+n6N4r34cdzq8izsPtaAs1V+pdq8ore Q5RCgHAwTmq25cv0rWIVeuRqFT4a/kKOzNSd8G6SAA1e8Wh1l67RfXhHBR5quoEQGwWQ 36oaoaxMV5gTS7meweEGzZrbW8JsnHLyPYogEHkDxkmgD62jeeGYhLcfuIcSoR2oy5yD UXPKmAyVEVMdImKveI4mg3cyQlIZhuYBAZSfp30rryI2zY+p8pFUEPWCvQURcabvb4vt Ze07c7/PU5l/eqbcTg4oabkHQ1/VWla4kUXHbbk7uy+kjBN8ahBIdDnkM3DJEi6qGe+I vfcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jRdN4+I1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k16si2391896ejr.429.2020.04.24.06.10.34; Fri, 24 Apr 2020 06:11:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jRdN4+I1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728446AbgDXNIA (ORCPT + 99 others); Fri, 24 Apr 2020 09:08:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:57380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728103AbgDXNGt (ORCPT ); Fri, 24 Apr 2020 09:06:49 -0400 Received: from e123331-lin.home (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr [109.210.65.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7814E208E4; Fri, 24 Apr 2020 13:06:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587733609; bh=1WrbrzvZ9LXmWaooz3ri6pkY4Ib9PORA1CphY5O0EtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jRdN4+I17nDJhAJogCCssKFoij5s3wnqzm8l3IpgCd/W3YyXv3O6JWUHYCqls1Wvt uiaCwhK8fIlcBkiG87h+Z5nI0wJRj+sAws6wdD1mTA9wSIpknS7iAmhKiurnQcKg9V JdH8o6yWvjAq8X6f2OaotuNmxGPkijsSM49v6h3c= From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Arvind Sankar , Atish Patra , Palmer Dabbelt , Zou Wei Subject: [PATCH 17/33] efi/gop: Allow specifying depth as well as resolution Date: Fri, 24 Apr 2020 15:05:15 +0200 Message-Id: <20200424130531.30518-18-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200424130531.30518-1-ardb@kernel.org> References: <20200424130531.30518-1-ardb@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arvind Sankar Extend the video mode argument to handle an optional color depth specification of the form video=efifb:x[-(rgb|bgr|)] Signed-off-by: Arvind Sankar Link: https://lore.kernel.org/r/20200320020028.1936003-14-nivedita@alum.mit.edu Signed-off-by: Ard Biesheuvel --- Documentation/fb/efifb.rst | 8 +++-- drivers/firmware/efi/libstub/gop.c | 48 ++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/Documentation/fb/efifb.rst b/Documentation/fb/efifb.rst index 635275071307..eca38466487a 100644 --- a/Documentation/fb/efifb.rst +++ b/Documentation/fb/efifb.rst @@ -50,9 +50,11 @@ mode=n The EFI stub will set the mode of the display to mode number n if possible. -x +x[-(rgb|bgr|)] The EFI stub will search for a display mode that matches the specified - horizontal and vertical resolution, and set the mode of the display to - it if one is found. + horizontal and vertical resolution, and optionally bit depth, and set + the mode of the display to it if one is found. The bit depth can either + "rgb" or "bgr" to match specifically those pixel formats, or a number + for a mode with matching bits per pixel. Edgar Hucek diff --git a/drivers/firmware/efi/libstub/gop.c b/drivers/firmware/efi/libstub/gop.c index cc84e6a82f54..848cb605a9c4 100644 --- a/drivers/firmware/efi/libstub/gop.c +++ b/drivers/firmware/efi/libstub/gop.c @@ -27,6 +27,8 @@ static struct { u32 mode; struct { u32 width, height; + int format; + u8 depth; } res; }; } cmdline __efistub_global = { .option = EFI_CMDLINE_NONE }; @@ -50,7 +52,8 @@ static bool parse_modenum(char *option, char **next) static bool parse_res(char *option, char **next) { - u32 w, h; + u32 w, h, d = 0; + int pf = -1; if (!isdigit(*option)) return false; @@ -58,11 +61,26 @@ static bool parse_res(char *option, char **next) if (*option++ != 'x' || !isdigit(*option)) return false; h = simple_strtoull(option, &option, 10); + if (*option == '-') { + option++; + if (strstarts(option, "rgb")) { + option += strlen("rgb"); + pf = PIXEL_RGB_RESERVED_8BIT_PER_COLOR; + } else if (strstarts(option, "bgr")) { + option += strlen("bgr"); + pf = PIXEL_BGR_RESERVED_8BIT_PER_COLOR; + } else if (isdigit(*option)) + d = simple_strtoull(option, &option, 10); + else + return false; + } if (*option && *option++ != ',') return false; cmdline.option = EFI_CMDLINE_RES; cmdline.res.width = w; cmdline.res.height = h; + cmdline.res.format = pf; + cmdline.res.depth = d; *next = option; return true; @@ -123,6 +141,18 @@ static u32 choose_mode_modenum(efi_graphics_output_protocol_t *gop) return cmdline.mode; } +static u8 pixel_bpp(int pixel_format, efi_pixel_bitmask_t pixel_info) +{ + if (pixel_format == PIXEL_BIT_MASK) { + u32 mask = pixel_info.red_mask | pixel_info.green_mask | + pixel_info.blue_mask | pixel_info.reserved_mask; + if (!mask) + return 0; + return __fls(mask) - __ffs(mask) + 1; + } else + return 32; +} + static u32 choose_mode_res(efi_graphics_output_protocol_t *gop) { efi_status_t status; @@ -133,16 +163,21 @@ static u32 choose_mode_res(efi_graphics_output_protocol_t *gop) u32 max_mode, cur_mode; int pf; + efi_pixel_bitmask_t pi; u32 m, w, h; mode = efi_table_attr(gop, mode); cur_mode = efi_table_attr(mode, mode); info = efi_table_attr(mode, info); - w = info->horizontal_resolution; - h = info->vertical_resolution; + pf = info->pixel_format; + pi = info->pixel_information; + w = info->horizontal_resolution; + h = info->vertical_resolution; - if (w == cmdline.res.width && h == cmdline.res.height) + if (w == cmdline.res.width && h == cmdline.res.height && + (cmdline.res.format < 0 || cmdline.res.format == pf) && + (!cmdline.res.depth || cmdline.res.depth == pixel_bpp(pf, pi))) return cur_mode; max_mode = efi_table_attr(mode, max_mode); @@ -157,6 +192,7 @@ static u32 choose_mode_res(efi_graphics_output_protocol_t *gop) continue; pf = info->pixel_format; + pi = info->pixel_information; w = info->horizontal_resolution; h = info->vertical_resolution; @@ -164,7 +200,9 @@ static u32 choose_mode_res(efi_graphics_output_protocol_t *gop) if (pf == PIXEL_BLT_ONLY || pf >= PIXEL_FORMAT_MAX) continue; - if (w == cmdline.res.width && h == cmdline.res.height) + if (w == cmdline.res.width && h == cmdline.res.height && + (cmdline.res.format < 0 || cmdline.res.format == pf) && + (!cmdline.res.depth || cmdline.res.depth == pixel_bpp(pf, pi))) return m; } -- 2.17.1