From nobody Wed Dec 17 05:27:02 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EB811607A5 for ; Thu, 22 Aug 2024 07:39:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724312377; cv=none; b=L8ikWd99tJxXBJ9smkGxPXz70AmX+uMjodvNzNisR1drHy2jmyY9wxuDucX0iG3AmlhqxMKYF7V9Rv7tPRfgub+ZmA9HRfSHv7mz+XpU8gXVy83f02f3OJwrp5QbrFftM4LJBzby6fjAoIeUJmIESHm3CRxlCwD5bHASajcDqqY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724312377; c=relaxed/simple; bh=LN/5/xOFLT/3GfZH+V4wNx5jF2OlkWThCduzVlFKeHg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HdGejzWqthL0I40rG51bED6h7FYIidVcAOsNhvjMthha6Vsjg7Uol9D9oPFt0voEv4kCwEK3yxCn2ZuwcW3uYxWlRv+lrm3bD3oXqQ2fzj05iwat5/V+GrWSmg7qufalC47VzwG+65x5BdACH01eknD7aoZyyb425DCrFSdB4sc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Cims6j+m; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Cims6j+m" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724312374; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zFdtMpyoluZDIf8+YBntleODDii1i8IV6WVFQmjpatk=; b=Cims6j+mGNorpfB7QZ1p4KWn5q20IQS0+atLVwA20yBvivS/+ePg4G5jqLCD9Rrfeptmf2 OdWN5QxAujeCE3j/9BPIjHAErIqKQvehRexNcA0H6+6Aj9zpA6mcli1ugARW7WcnSxSJus F6SXhcOe0HqNeCXTCz72GaAlMFmSimU= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-VCGBpAjBP9mz7a0egnQ89g-1; Thu, 22 Aug 2024 03:39:29 -0400 X-MC-Unique: VCGBpAjBP9mz7a0egnQ89g-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BD56A19540EF; Thu, 22 Aug 2024 07:39:26 +0000 (UTC) Received: from hydra.redhat.com (unknown [10.39.193.88]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1F0411955DD6; Thu, 22 Aug 2024 07:39:20 +0000 (UTC) From: Jocelyn Falempe To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , "Bjorn Roy Baron" , Benno Lossin , Andreas Hindborg , Alice Ryhl , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org, Danilo Krummrich Cc: Jocelyn Falempe Subject: [PATCH v7 3/4] drm/panic: Simplify logo handling Date: Thu, 22 Aug 2024 09:33:56 +0200 Message-ID: <20240822073852.562286-4-jfalempe@redhat.com> In-Reply-To: <20240822073852.562286-1-jfalempe@redhat.com> References: <20240822073852.562286-1-jfalempe@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" Move logo rectangle initialisation, and logo drawing in separate functions, so they can be re-used by different panic screens. It prepares the introduction of the QR code panic screen. Signed-off-by: Jocelyn Falempe Reviewed-by: Thomas Zimmermann --- v6: * rebase, and handle conflict with 5d45c01dea6f ("drm/panic: Add panic des= cription") drivers/gpu/drm/drm_panic.c | 58 +++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/drm_panic.c b/drivers/gpu/drm/drm_panic.c index 59fba23e5fd7a..473db5fafb617 100644 --- a/drivers/gpu/drm/drm_panic.c +++ b/drivers/gpu/drm/drm_panic.c @@ -85,7 +85,7 @@ static struct drm_panic_line panic_msg[] =3D { PANIC_LINE(""), /* will be replaced by the panic description */ }; =20 -#define PANIC_MSG_LINES ARRAY_SIZE(panic_msg) +static const int panic_msg_lines =3D ARRAY_SIZE(panic_msg); =20 static const struct drm_panic_line logo_ascii[] =3D { PANIC_LINE(" .--. _"), @@ -97,7 +97,7 @@ static const struct drm_panic_line logo_ascii[] =3D { PANIC_LINE(" \\___)=3D(___/"), }; =20 -#define PANIC_LOGO_LINES ARRAY_SIZE(logo_ascii) +static const int logo_ascii_lines =3D ARRAY_SIZE(logo_ascii); =20 #if defined(CONFIG_LOGO) && !defined(MODULE) static const struct linux_logo *logo_mono; @@ -496,31 +496,44 @@ static void draw_txt_rectangle(struct drm_scanout_buf= fer *sb, } } =20 +static void drm_panic_logo_rect(struct drm_rect *rect, const struct font_d= esc *font) +{ + if (logo_mono) + drm_rect_init(rect, 0, 0, logo_mono->width, logo_mono->height); + else { + int logo_width =3D get_max_line_len(logo_ascii, logo_ascii_lines) * font= ->width; + + drm_rect_init(rect, 0, 0, logo_width, logo_ascii_lines * font->height); + } +} + +static void drm_panic_logo_draw(struct drm_scanout_buffer *sb, struct drm_= rect *rect, + const struct font_desc *font, u32 fg_color) +{ + if (logo_mono) + drm_panic_blit(sb, rect, logo_mono->data, + DIV_ROUND_UP(drm_rect_width(rect), 8), 1, fg_color); + else + draw_txt_rectangle(sb, font, logo_ascii, logo_ascii_lines, false, rect, + fg_color); +} + static void draw_panic_static_user(struct drm_scanout_buffer *sb) { u32 fg_color =3D convert_from_xrgb8888(CONFIG_DRM_PANIC_FOREGROUND_COLOR,= sb->format->format); u32 bg_color =3D convert_from_xrgb8888(CONFIG_DRM_PANIC_BACKGROUND_COLOR,= sb->format->format); const struct font_desc *font =3D get_default_font(sb->width, sb->height, = NULL, NULL); struct drm_rect r_screen, r_logo, r_msg; - unsigned int logo_width, logo_height; unsigned int msg_width, msg_height; =20 if (!font) return; =20 r_screen =3D DRM_RECT_INIT(0, 0, sb->width, sb->height); + drm_panic_logo_rect(&r_logo, font); =20 - if (logo_mono) { - logo_width =3D logo_mono->width; - logo_height =3D logo_mono->height; - } else { - logo_width =3D get_max_line_len(logo_ascii, PANIC_LOGO_LINES) * font->wi= dth; - logo_height =3D PANIC_LOGO_LINES * font->height; - } - r_logo =3D DRM_RECT_INIT(0, 0, logo_width, logo_height); - - msg_width =3D min(get_max_line_len(panic_msg, PANIC_MSG_LINES) * font->wi= dth, sb->width); - msg_height =3D min(PANIC_MSG_LINES * font->height, sb->height); + msg_width =3D min(get_max_line_len(panic_msg, panic_msg_lines) * font->wi= dth, sb->width); + msg_height =3D min(panic_msg_lines * font->height, sb->height); r_msg =3D DRM_RECT_INIT(0, 0, msg_width, msg_height); =20 /* Center the panic message */ @@ -529,15 +542,10 @@ static void draw_panic_static_user(struct drm_scanout= _buffer *sb) /* Fill with the background color, and draw text on top */ drm_panic_fill(sb, &r_screen, bg_color); =20 - if (!drm_rect_overlap(&r_logo, &r_msg)) { - if (logo_mono) - drm_panic_blit(sb, &r_logo, logo_mono->data, DIV_ROUND_UP(logo_width, 8= ), - fg_color); - else - draw_txt_rectangle(sb, font, logo_ascii, PANIC_LOGO_LINES, false, &r_lo= go, - fg_color); - } - draw_txt_rectangle(sb, font, panic_msg, PANIC_MSG_LINES, true, &r_msg, fg= _color); + if (!drm_rect_overlap(&r_logo, &r_msg)) + drm_panic_logo_draw(sb, &r_logo, font, fg_color); + + draw_txt_rectangle(sb, font, panic_msg, panic_msg_lines, true, &r_msg, fg= _color); } =20 /* @@ -647,7 +655,7 @@ static void drm_panic_set_description(const char *descr= iption) u32 len; =20 if (description) { - struct drm_panic_line *desc_line =3D &panic_msg[PANIC_MSG_LINES - 1]; + struct drm_panic_line *desc_line =3D &panic_msg[panic_msg_lines - 1]; =20 desc_line->txt =3D description; len =3D strlen(description); @@ -660,7 +668,7 @@ static void drm_panic_set_description(const char *descr= iption) =20 static void drm_panic_clear_description(void) { - struct drm_panic_line *desc_line =3D &panic_msg[PANIC_MSG_LINES - 1]; + struct drm_panic_line *desc_line =3D &panic_msg[panic_msg_lines - 1]; =20 desc_line->len =3D 0; desc_line->txt =3D NULL; --=20 2.46.0