mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jocelyn Falempe <jfalempe@redhat.com>
To: Thomas Zimmermann <tzimmermann@suse.de>,
	Javier Martinez Canillas <javierm@redhat.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/log: Add an automatic integer scaling
Date: Mon, 30 Nov 2026 14:25:47 +0100	[thread overview]
Message-ID: <30d29eb2-310c-42e8-a3aa-302b878b093f@redhat.com> (raw)
In-Reply-To: <0b2ba699-e686-46cf-a392-220946452963@suse.de>

On 11/26/26 10:56, Thomas Zimmermann wrote:
> 
> 
> Am 24.11.26 um 23:42 schrieb Jocelyn Falempe:
>> On HiDPI screen, the default font might be too small, so if no
>> scaling is specified, try to upscale reasonably.
>> The auto scaling is computed for each display.
>>
>> Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
> 
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
> 
> I think this change could be merged, but please see my thoughts on 
> picking the optimal sizes.

Thanks, I think that's close to what is implemented (scaling is the same 
for x and y).
I just pushed it to drm-misc-next. I fixed a checkpatch warning, that 
scale is static and doesn't need to be explicitly set to 0.

Best regards,

-- 

Jocelyn

> 
> 
>> ---
>>   drivers/gpu/drm/clients/drm_log.c | 36 ++++++++++++++++++++-----------
>>   1 file changed, 24 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/clients/drm_log.c b/drivers/gpu/drm/ 
>> clients/drm_log.c
>> index 4654091fe11a..7a0db2690b55 100644
>> --- a/drivers/gpu/drm/clients/drm_log.c
>> +++ b/drivers/gpu/drm/clients/drm_log.c
>> @@ -25,9 +25,9 @@ MODULE_AUTHOR("Jocelyn Falempe");
>>   MODULE_DESCRIPTION("DRM boot logger");
>>   MODULE_LICENSE("GPL");
>> -static unsigned int scale = 1;
>> +static unsigned int scale = 0;
>>   module_param(scale, uint, 0444);
>> -MODULE_PARM_DESC(scale, "Integer scaling factor for drm_log, default 
>> is 1");
>> +MODULE_PARM_DESC(scale, "Integer scaling factor for drm_log, default 
>> is 0 (auto)");
>>   /**
>>    * DOC: overview
>> @@ -42,6 +42,7 @@ struct drm_log_scanout {
>>       const struct font_desc *font;
>>       u32 rows;
>>       u32 columns;
>> +    u32 scale;
>>       u32 scaled_font_h;
>>       u32 scaled_font_w;
>>       u32 line;
>> @@ -72,17 +73,17 @@ 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 px_width, u32 color)
>> +             u32 height, u32 width, u32 blit_scale, u32 px_width, u32 
>> color)
>>   {
>>       switch (px_width) {
>>       case 2:
>> -        drm_draw_blit16(dst, dst_pitch, src, src_pitch, height, 
>> width, scale, color);
>> +        drm_draw_blit16(dst, dst_pitch, src, src_pitch, height, 
>> width, blit_scale, color);
>>           break;
>>       case 3:
>> -        drm_draw_blit24(dst, dst_pitch, src, src_pitch, height, 
>> width, scale, color);
>> +        drm_draw_blit24(dst, dst_pitch, src, src_pitch, height, 
>> width, blit_scale, color);
>>           break;
>>       case 4:
>> -        drm_draw_blit32(dst, dst_pitch, src, src_pitch, height, 
>> width, scale, color);
>> +        drm_draw_blit32(dst, dst_pitch, src, src_pitch, height, 
>> width, blit_scale, color);
>>           break;
>>       default:
>>           WARN_ONCE(1, "Can't blit with pixel width %d\n", px_width);
>> @@ -122,7 +123,7 @@ static void drm_log_draw_line(struct 
>> drm_log_scanout *scanout, const char *s,
>>           if (src)
>>               drm_log_blit(&map, fb->pitches[0], src, font_pitch,
>>                        scanout->scaled_font_h, scanout->scaled_font_w,
>> -                     px_width, color);
>> +                     scanout->scale, px_width, color);
>>           iosys_map_incr(&map, scanout->scaled_font_w * px_width);
>>       }
>> @@ -206,6 +207,15 @@ static u32 drm_log_find_usable_format(struct 
>> drm_plane *plane)
>>       return DRM_FORMAT_INVALID;
>>   }
>> +/* Find the biggest integer scaling to get about 120x50 chars on the 
>> screen */
>> +static int auto_scale(unsigned int cols, unsigned int rows)
>> +{
>> +    unsigned int scale_w = DIV_ROUND_CLOSEST(cols, 120);
>> +    unsigned int scale_h = DIV_ROUND_CLOSEST(rows, 50);
>> +
>> +    return max(min(scale_w, scale_h), 1);
>> +}
>> +
>>   static int drm_log_setup_modeset(struct drm_client_dev *client,
>>                    struct drm_mode_set *mode_set,
>>                    struct drm_log_scanout *scanout)
>> @@ -230,8 +240,13 @@ static int drm_log_setup_modeset(struct 
>> drm_client_dev *client,
>>           return -ENOMEM;
>>       }
>>       mode_set->fb = scanout->buffer->fb;
>> -    scanout->scaled_font_h = scanout->font->height * scale;
>> -    scanout->scaled_font_w = scanout->font->width * scale;
>> +    if (scale)
>> +        scanout->scale = scale;
>> +    else
>> +        scanout->scale = auto_scale(width / scanout->font->width,
>> +                                height / scanout->font->height);
>> +    scanout->scaled_font_h = scanout->font->height * scanout->scale;
>> +    scanout->scaled_font_w = scanout->font->width * scanout->scale;
>>       scanout->rows = height / scanout->scaled_font_h;
>>       scanout->columns = width / scanout->scaled_font_w;
>>       if (!scanout->rows || !scanout->columns) {
>> @@ -444,9 +459,6 @@ void drm_log_register(struct drm_device *dev)
>>   {
>>       struct drm_log *new;
>> -    if (!scale)
>> -        scale = 1;
>> -
>>       new = kzalloc_obj(*new);
>>       if (!new)
>>           goto err_warn;
>>
>> base-commit: bcf5c42d6ed136cc407cea896f131d6893c830af
> 


      reply	other threads:[~2026-11-30 13:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 22:42 Jocelyn Falempe
2026-11-26  7:47 ` Thomas Zimmermann
2026-11-26  9:02   ` Jocelyn Falempe
2026-11-26  9:54     ` Thomas Zimmermann
2026-11-26 15:45       ` Jocelyn Falempe
2026-11-26  9:56 ` Thomas Zimmermann
2026-11-30 13:25   ` Jocelyn Falempe [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=30d29eb2-310c-42e8-a3aa-302b878b093f@redhat.com \
    --to=jfalempe@redhat.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®