From patchwork Wed Jun 12 13:54:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13695049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CCF20C27C7B for ; Wed, 12 Jun 2024 13:54:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8C2F110E854; Wed, 12 Jun 2024 13:54:23 +0000 (UTC) Received: from gauss.telenet-ops.be (gauss.telenet-ops.be [195.130.132.49]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3483D10E857 for ; Wed, 12 Jun 2024 13:54:20 +0000 (UTC) Received: from baptiste.telenet-ops.be (baptiste.telenet-ops.be [IPv6:2a02:1800:120:4::f00:13]) by gauss.telenet-ops.be (Postfix) with ESMTPS id 4Vzn8V6sf9z4wyrZ for ; Wed, 12 Jun 2024 15:54:18 +0200 (CEST) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:170b:1b4a:247:a009]) by baptiste.telenet-ops.be with bizsmtp id aduH2C0083axqkY01duHp4; Wed, 12 Jun 2024 15:54:18 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1sHOPX-008eJj-SD; Wed, 12 Jun 2024 15:54:17 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1sHOQa-00EdFh-W8; Wed, 12 Jun 2024 15:54:16 +0200 From: Geert Uytterhoeven To: Jocelyn Falempe , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: Helge Deller , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 1/3] drm/panic: Fix off-by-one logo size checks Date: Wed, 12 Jun 2024 15:54:08 +0200 Message-Id: <653cc7f0ab18c1eadd8128debedefa5174591c90.1718199918.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Logos that are either just as wide or just as high as the display work fine. Fixes: bf9fb17c6672868d ("drm/panic: Add a drm panic handler") Signed-off-by: Geert Uytterhoeven --- drivers/gpu/drm/drm_panic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_panic.c b/drivers/gpu/drm/drm_panic.c index 7ece67086cecb79f..52d8a96b7dedff2c 100644 --- a/drivers/gpu/drm/drm_panic.c +++ b/drivers/gpu/drm/drm_panic.c @@ -444,7 +444,7 @@ static void draw_panic_static(struct drm_scanout_buffer *sb) bg_color, sb->format->cpp[0]); if ((r_msg.x1 >= drm_rect_width(&r_logo) || r_msg.y1 >= drm_rect_height(&r_logo)) && - drm_rect_width(&r_logo) < sb->width && drm_rect_height(&r_logo) < sb->height) { + drm_rect_width(&r_logo) <= sb->width && drm_rect_height(&r_logo) <= sb->height) { draw_txt_rectangle(sb, font, logo, logo_lines, false, &r_logo, fg_color, bg_color); } draw_txt_rectangle(sb, font, panic_msg, msg_lines, true, &r_msg, fg_color, bg_color); From patchwork Wed Jun 12 13:54:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13695051 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7CB12C27C53 for ; Wed, 12 Jun 2024 13:54:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6B27E10E85F; Wed, 12 Jun 2024 13:54:32 +0000 (UTC) Received: from riemann.telenet-ops.be (riemann.telenet-ops.be [195.130.137.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7F39410E858 for ; Wed, 12 Jun 2024 13:54:20 +0000 (UTC) Received: from xavier.telenet-ops.be (xavier.telenet-ops.be [IPv6:2a02:1800:120:4::f00:14]) by riemann.telenet-ops.be (Postfix) with ESMTPS id 4Vzn8V6Z6gz4x0NH for ; Wed, 12 Jun 2024 15:54:18 +0200 (CEST) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:170b:1b4a:247:a009]) by xavier.telenet-ops.be with bizsmtp id aduH2C0043axqkY01duH1A; Wed, 12 Jun 2024 15:54:18 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1sHOPX-008eJl-SV; Wed, 12 Jun 2024 15:54:17 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1sHOQb-00EdFk-0V; Wed, 12 Jun 2024 15:54:17 +0200 From: Geert Uytterhoeven To: Jocelyn Falempe , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: Helge Deller , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 2/3] drm/panic: Rename logo to logo_ascii Date: Wed, 12 Jun 2024 15:54:09 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Rename variables related to the ASCII logo, to prepare for the advent of support for graphical logos. Signed-off-by: Geert Uytterhoeven --- drivers/gpu/drm/drm_panic.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_panic.c b/drivers/gpu/drm/drm_panic.c index 52d8a96b7dedff2c..05b406a7034bb295 100644 --- a/drivers/gpu/drm/drm_panic.c +++ b/drivers/gpu/drm/drm_panic.c @@ -71,7 +71,7 @@ static struct drm_panic_line panic_msg[] = { PANIC_LINE("Please reboot your computer."), }; -static const struct drm_panic_line logo[] = { +static const struct drm_panic_line logo_ascii[] = { PANIC_LINE(" .--. _"), PANIC_LINE(" |o_o | | |"), PANIC_LINE(" |:_/ | | |"), @@ -417,7 +417,7 @@ static void draw_txt_rectangle(struct drm_scanout_buffer *sb, static void draw_panic_static(struct drm_scanout_buffer *sb) { size_t msg_lines = ARRAY_SIZE(panic_msg); - size_t logo_lines = ARRAY_SIZE(logo); + size_t logo_ascii_lines = ARRAY_SIZE(logo_ascii); u32 fg_color = CONFIG_DRM_PANIC_FOREGROUND_COLOR; u32 bg_color = CONFIG_DRM_PANIC_BACKGROUND_COLOR; const struct font_desc *font = get_default_font(sb->width, sb->height, NULL, NULL); @@ -430,8 +430,8 @@ static void draw_panic_static(struct drm_scanout_buffer *sb) bg_color = convert_from_xrgb8888(bg_color, sb->format->format); r_logo = DRM_RECT_INIT(0, 0, - get_max_line_len(logo, logo_lines) * font->width, - logo_lines * font->height); + get_max_line_len(logo_ascii, logo_ascii_lines) * font->width, + logo_ascii_lines * font->height); r_msg = DRM_RECT_INIT(0, 0, min(get_max_line_len(panic_msg, msg_lines) * font->width, sb->width), min(msg_lines * font->height, sb->height)); @@ -445,7 +445,8 @@ static void draw_panic_static(struct drm_scanout_buffer *sb) if ((r_msg.x1 >= drm_rect_width(&r_logo) || r_msg.y1 >= drm_rect_height(&r_logo)) && drm_rect_width(&r_logo) <= sb->width && drm_rect_height(&r_logo) <= sb->height) { - draw_txt_rectangle(sb, font, logo, logo_lines, false, &r_logo, fg_color, bg_color); + draw_txt_rectangle(sb, font, logo_ascii, logo_ascii_lines, false, &r_logo, + fg_color, bg_color); } draw_txt_rectangle(sb, font, panic_msg, msg_lines, true, &r_msg, fg_color, bg_color); } From patchwork Wed Jun 12 13:54:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13695050 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 84F2DC27C53 for ; Wed, 12 Jun 2024 13:54:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 760E710E857; Wed, 12 Jun 2024 13:54:28 +0000 (UTC) Received: from gauss.telenet-ops.be (gauss.telenet-ops.be [195.130.132.49]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3433210E854 for ; Wed, 12 Jun 2024 13:54:20 +0000 (UTC) Received: from xavier.telenet-ops.be (xavier.telenet-ops.be [IPv6:2a02:1800:120:4::f00:14]) by gauss.telenet-ops.be (Postfix) with ESMTPS id 4Vzn8V6LNVz4wyqv for ; Wed, 12 Jun 2024 15:54:18 +0200 (CEST) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:170b:1b4a:247:a009]) by xavier.telenet-ops.be with bizsmtp id aduH2C0023axqkY01duH18; Wed, 12 Jun 2024 15:54:18 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1sHOPX-008eJo-TK; Wed, 12 Jun 2024 15:54:17 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1sHOQb-00EdFn-1W; Wed, 12 Jun 2024 15:54:17 +0200 From: Geert Uytterhoeven To: Jocelyn Falempe , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: Helge Deller , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 3/3] drm/panic: Add support for drawing a monochrome graphical logo Date: Wed, 12 Jun 2024 15:54:10 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Re-use the existing support for boot-up logos to draw a monochrome graphical logo in the DRM panic handler. When no suitable graphical logo is available, the code falls back to the ASCII art penguin logo. Note that all graphical boot-up logos are freed during late kernel initialization, hence a copy must be made for later use. Signed-off-by: Geert Uytterhoeven --- drivers/gpu/drm/drm_panic.c | 78 +++++++++++++++++++++++++++++++++---- drivers/video/logo/Kconfig | 2 + 2 files changed, 73 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_panic.c b/drivers/gpu/drm/drm_panic.c index 05b406a7034bb295..f2d7484eff43f5a8 100644 --- a/drivers/gpu/drm/drm_panic.c +++ b/drivers/gpu/drm/drm_panic.c @@ -7,11 +7,15 @@ */ #include +#include #include #include #include +#include #include +#include #include +#include #include #include @@ -81,6 +85,42 @@ static const struct drm_panic_line logo_ascii[] = { PANIC_LINE(" \\___)=(___/"), }; +#ifdef CONFIG_LOGO +static const struct linux_logo *logo_mono; + +static int drm_panic_setup_logo(void) +{ + const struct linux_logo *logo = fb_find_logo(1); + const unsigned char *logo_data; + struct linux_logo *logo_dup; + + if (!logo || logo->type != LINUX_LOGO_MONO) + return 0; + + /* The logo is __init, so we must make a copy for later use */ + logo_data = kmemdup(logo->data, + size_mul(DIV_ROUND_UP(logo->width, BITS_PER_BYTE), logo->height), + GFP_KERNEL); + if (!logo_data) + return -ENOMEM; + + logo_dup = kmemdup(logo, sizeof(*logo), GFP_KERNEL); + if (!logo_dup) { + kfree(logo_data); + return -ENOMEM; + } + + logo_dup->data = logo_data; + logo_mono = logo_dup; + + return 0; +} + +device_initcall(drm_panic_setup_logo); +#else +#define logo_mono ((const struct linux_logo *)NULL) +#endif + /* * Color conversion */ @@ -357,6 +397,20 @@ static void drm_panic_fill(struct iosys_map *dmap, unsigned int dpitch, } } +/* + * Draw a monochrome logo on a framebuffer. + */ +static void draw_logo_mono(struct drm_scanout_buffer *sb, const struct linux_logo *logo, + struct drm_rect *clip, u32 fg_color, u32 bg_color) +{ + unsigned int px_width = sb->format->cpp[0]; + struct iosys_map dst = sb->map[0]; + + iosys_map_incr(&dst, clip->y1 * sb->pitch[0] + clip->x1 * px_width); + drm_panic_blit(&dst, sb->pitch[0], logo->data, DIV_ROUND_UP(logo->width, 8), + logo->height, logo->width, fg_color, bg_color, px_width); +} + static const u8 *get_char_bitmap(const struct font_desc *font, char c, size_t font_pitch) { return font->data + (c * font->height) * font_pitch; @@ -421,6 +475,7 @@ static void draw_panic_static(struct drm_scanout_buffer *sb) u32 fg_color = CONFIG_DRM_PANIC_FOREGROUND_COLOR; u32 bg_color = CONFIG_DRM_PANIC_BACKGROUND_COLOR; const struct font_desc *font = get_default_font(sb->width, sb->height, NULL, NULL); + unsigned int logo_width, logo_height; struct drm_rect r_logo, r_msg; if (!font) @@ -429,9 +484,15 @@ static void draw_panic_static(struct drm_scanout_buffer *sb) fg_color = convert_from_xrgb8888(fg_color, sb->format->format); bg_color = convert_from_xrgb8888(bg_color, sb->format->format); - r_logo = DRM_RECT_INIT(0, 0, - get_max_line_len(logo_ascii, logo_ascii_lines) * font->width, - logo_ascii_lines * font->height); + if (logo_mono) { + logo_width = logo_mono->width; + logo_height = logo_mono->height; + } else { + logo_width = get_max_line_len(logo_ascii, logo_ascii_lines) * font->width; + logo_height = logo_ascii_lines * font->height; + } + + r_logo = DRM_RECT_INIT(0, 0, logo_width, logo_height); r_msg = DRM_RECT_INIT(0, 0, min(get_max_line_len(panic_msg, msg_lines) * font->width, sb->width), min(msg_lines * font->height, sb->height)); @@ -443,10 +504,13 @@ static void draw_panic_static(struct drm_scanout_buffer *sb) drm_panic_fill(&sb->map[0], sb->pitch[0], sb->height, sb->width, bg_color, sb->format->cpp[0]); - if ((r_msg.x1 >= drm_rect_width(&r_logo) || r_msg.y1 >= drm_rect_height(&r_logo)) && - drm_rect_width(&r_logo) <= sb->width && drm_rect_height(&r_logo) <= sb->height) { - draw_txt_rectangle(sb, font, logo_ascii, logo_ascii_lines, false, &r_logo, - fg_color, bg_color); + if ((r_msg.x1 >= logo_width || r_msg.y1 >= logo_height) && + logo_width <= sb->width && logo_height <= sb->height) { + if (logo_mono) + draw_logo_mono(sb, logo_mono, &r_logo, fg_color, bg_color); + else + draw_txt_rectangle(sb, font, logo_ascii, logo_ascii_lines, false, &r_logo, + fg_color, bg_color); } draw_txt_rectangle(sb, font, panic_msg, msg_lines, true, &r_msg, fg_color, bg_color); } diff --git a/drivers/video/logo/Kconfig b/drivers/video/logo/Kconfig index b7d94d1dd1585a84..ce6bb753522d215d 100644 --- a/drivers/video/logo/Kconfig +++ b/drivers/video/logo/Kconfig @@ -8,6 +8,8 @@ menuconfig LOGO depends on FB_CORE || SGI_NEWPORT_CONSOLE help Enable and select frame buffer bootup logos. + Monochrome logos will also be used by the DRM panic handler, if + enabled. if LOGO