From patchwork Wed Oct 23 12:00:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jocelyn Falempe X-Patchwork-Id: 13847004 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 A0541CDDE79 for ; Wed, 23 Oct 2024 12:12:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 272C510E7AA; Wed, 23 Oct 2024 12:12:31 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="fe+KQB8M"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 96F1610E7BB for ; Wed, 23 Oct 2024 12:12:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729685548; 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=6QeAiyBCD1TvyoxIk01Elbt1ycRGYwM+endPA4qBmSc=; b=fe+KQB8M6/O33pRAvUDfZ8D197lH93SDAIfdqtRwP/PWkO1rbkBS0SHznAIO1PiDypKMkD t1zrLgqBKydkkgEFqOHAC8woUt/f8kSh9jXltODdg7bRHXXYRgUNovIm4Att4GKFce1Ckz bMbet/Dtz+Y0uYKv69jmP8g8Q1/6ZEk= 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-164-k25ousiPPUWCTYzsO1jEHA-1; Wed, 23 Oct 2024 08:12:25 -0400 X-MC-Unique: k25ousiPPUWCTYzsO1jEHA-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 66C701955EAC; Wed, 23 Oct 2024 12:12:23 +0000 (UTC) Received: from hydra.redhat.com (unknown [10.39.193.145]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D744230001A5; Wed, 23 Oct 2024 12:12:19 +0000 (UTC) From: Jocelyn Falempe To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , John Ogness , Javier Martinez Canillas , "Guilherme G . Piccoli" , bluescreen_avenger@verizon.net, Caleb Connolly , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Jocelyn Falempe Subject: [PATCH v5 6/6] drm/log: Add integer scaling support Date: Wed, 23 Oct 2024 14:00:14 +0200 Message-ID: <20241023121145.1321921-7-jfalempe@redhat.com> In-Reply-To: <20241023121145.1321921-1-jfalempe@redhat.com> References: <20241023121145.1321921-1-jfalempe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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" Add a module parameter, to increase the font size for HiDPI screen. Even with CONFIG_FONT_TER16x32, it can still be a bit small to read. In this case, adding drm_log.scale=2 to your kernel command line will double the character size. Signed-off-by: Jocelyn Falempe --- v5: * Change scale parameter to unsigned int (Jani Nikula) drivers/gpu/drm/drm_log.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_log.c b/drivers/gpu/drm/drm_log.c index 07d1513001468..2f378bc953bd9 100644 --- a/drivers/gpu/drm/drm_log.c +++ b/drivers/gpu/drm/drm_log.c @@ -25,6 +25,10 @@ MODULE_AUTHOR("Jocelyn Falempe"); MODULE_DESCRIPTION("DRM boot logger"); MODULE_LICENSE("GPL"); +static unsigned int scale = 1; +module_param(scale, uint, 0444); +MODULE_PARM_DESC(scale, "Integer scaling factor for drm_log, default is 1"); + /** * DOC: overview * @@ -38,6 +42,8 @@ struct drm_log_scanout { const struct font_desc *font; u32 rows; u32 columns; + u32 scaled_font_h; + u32 scaled_font_w; u32 line; u32 format; u32 px_width; @@ -67,7 +73,7 @@ static struct drm_log *console_to_drm_log(struct console *con) static void drm_log_blit(struct iosys_map *dst, unsigned int dst_pitch, const u8 *src, unsigned int src_pitch, - u32 height, u32 width, u32 scale, u32 px_width, u32 color) + u32 height, u32 width, u32 px_width, u32 color) { switch (px_width) { case 2: @@ -87,7 +93,7 @@ static void drm_log_blit(struct iosys_map *dst, unsigned int dst_pitch, static void drm_log_clear_line(struct drm_log_scanout *scanout, u32 line) { struct drm_framebuffer *fb = scanout->buffer->fb; - unsigned long height = scanout->font->height; + unsigned long height = scanout->scaled_font_h; struct iosys_map map; struct drm_rect r = DRM_RECT_INIT(0, line * height, fb->width, height); @@ -107,8 +113,8 @@ static void drm_log_draw_line(struct drm_log_scanout *scanout, const char *s, size_t font_pitch = DIV_ROUND_UP(font->width, 8); const u8 *src; u32 px_width = fb->format->cpp[0]; - struct drm_rect r = DRM_RECT_INIT(0, scanout->line * font->height, - fb->width, (scanout->line + 1) * font->height); + struct drm_rect r = DRM_RECT_INIT(0, scanout->line * scanout->scaled_font_h, + fb->width, (scanout->line + 1) * scanout->scaled_font_h); u32 i; if (drm_client_buffer_vmap_local(scanout->buffer, &map)) @@ -118,9 +124,10 @@ static void drm_log_draw_line(struct drm_log_scanout *scanout, const char *s, for (i = 0; i < len && i < scanout->columns; i++) { u32 color = (i < prefix_len) ? scanout->prefix_color : scanout->front_color; src = drm_draw_get_char_bitmap(font, s[i], font_pitch); - drm_log_blit(&map, fb->pitches[0], src, font_pitch, font->height, font->width, - 1, px_width, color); - iosys_map_incr(&map, font->width * px_width); + drm_log_blit(&map, fb->pitches[0], src, font_pitch, + scanout->scaled_font_h, scanout->scaled_font_w, + px_width, color); + iosys_map_incr(&map, scanout->scaled_font_w * px_width); } scanout->line++; @@ -205,8 +212,10 @@ static int drm_log_setup_modeset(struct drm_client_dev *client, return -ENOMEM; } mode_set->fb = scanout->buffer->fb; - scanout->rows = height / scanout->font->height; - scanout->columns = width / scanout->font->width; + scanout->scaled_font_h = scanout->font->height * scale; + scanout->scaled_font_w = scanout->font->width * scale; + scanout->rows = height / scanout->scaled_font_h; + scanout->columns = width / scanout->scaled_font_w; scanout->front_color = drm_draw_color_from_xrgb8888(0xffffff, format); scanout->prefix_color = drm_draw_color_from_xrgb8888(0x4e9a06, format); return 0;