mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Javier Martinez Canillas <javierm@redhat.com>,
	Pierre Asselin <pa@panix.com>
Cc: jfalempe@redhat.com, daniel.vetter@ffwll.ch,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	hdegoede@redhat.com, ardb@kernel.org
Subject: Re: [PATCH] firmware/sysfb: Fix wrong stride when bits-per-pixel is calculated
Date: Mon, 17 Apr 2023 11:15:53 +0200	[thread overview]
Message-ID: <60b7cad3-8923-98b1-2c0f-71bfabd0b2e9@suse.de> (raw)
In-Reply-To: <87zg76evh3.fsf@minerva.mail-host-address-is-not-set>


[-- Attachment #1.1: Type: text/plain, Size: 3889 bytes --]

Hi

Am 17.04.23 um 10:58 schrieb Javier Martinez Canillas:
> Thomas Zimmermann <tzimmermann@suse.de> writes:
> 
>> Hi,
>>
>> thanks a lot to both of you for this bug fix.
>>
>> Am 13.04.23 um 03:34 schrieb Pierre Asselin:
>>>> (not tested)
>>>
>>> Tested.  It fixes the regression on my laptop.
>>>
>>>> diff --git a/drivers/firmware/sysfb_simplefb.c
>>>> b/drivers/firmware/sysfb_simplefb.c
>>>> index 82c64cb9f531..9f5299d54732 100644
>>>> --- a/drivers/firmware/sysfb_simplefb.c
>>>> +++ b/drivers/firmware/sysfb_simplefb.c
>>>> @@ -56,10 +56,11 @@ __init bool sysfb_parse_mode(const struct screen_info
>>>> *si,
>>>>    	 * don't specify alpha channels.
>>>>    	 */
>>>>    	if (si->lfb_depth > 8) {
>>>> -		bits_per_pixel = max(max3(si->red_size + si->red_pos,
>>>> +		bits_per_pixel = max3(max3(si->red_size + si->red_pos,
>>>>    					  si->green_size + si->green_pos,
>>>>    					  si->blue_size + si->blue_pos),
>>>> -				     si->rsvd_size + si->rsvd_pos);
>>>> +				     si->rsvd_size + si->rsvd_pos,
>>>> +				     si->lfb_depth);
>>
>> I'm OK with this change. There's a comment
>>
>>    "The best solution is to compute bits_per_pixel here and ignore
>> lfb_depth."
>>
>> I'd change this to
>>
>>    "The best solution is to compute bits_per_pixel here from the color
>> bits, the reserved bits and the reported color depth; whatever is highest."
>>
>> That will hopefully clarify the meaning of these max3() statements. They
>> are not obvious at first.
>>
> 
> I'm OK with this as well but then should probably also apply my patch [1]
> that computed the stride too. Since if we don't trust the lfb_depth and
> calculate the BPP, then we shouldn't trust the reported line length too.
> 
> As Pierre reported in the thread [2], when the wrong BPP was calculated (and
> wrong pixel format chosen), the line lenght didn't match the BPP * lfb_width.
> 
> He mentioned that it was like this:
> 
>   format=r8g8b8, mode=1024x768x24, linelength=4096
> 
> Instead of the expected:
> 
>   format=r8g8b8, mode=1024x768x24, linelength=3072
> 
> My patch in [1], fixed the linelength calculation so it was internally
> consistent (but still wrong since the pixel format was really xr8g8b8).
> 
> In other words, I think that we should either:
> 
> a) Trust the lfb_linelength and lfb_width (we are already doing that since
>     mode->stride and mode->width are set to those once the format matches).
>     
>     If we decided to trust those, then the bits-per-pixel could just be
>     calculated as: bits_per_pixel = si->lfb_linelength * 8 / si->lfb_width
> 
>     which is what I do on my v2 patch [3].
> 
> b) Not trust lfb_linelength, since that would need to be recalculated after
>     the BPP was calcualted. That's why I mentioned that we need Pierre's fix +
>     my patch [1] that did:
> 
>     stride = DIV_ROUND_UP(si->lfb_width * bits_per_pixel, 8)

I'd rather keep the code as-is until we get an actual bug report.

For example, DRM framebuffer sizes are often multiples of 64. Creating a 
framebuffer of 800x600 will create a framebuffer with 
stride/pitch/linelength of 832.  I can imagine that some BIOSes out 
there do something similar with the system framebuffer. Messing with the 
stride would break them.

Best regards
Thomas

> 
> But calculating a BPP yet blindly using linelength doens't make sense to me.
> 
> [1]: https://lists.freedesktop.org/archives/dri-devel/2023-April/399963.html
> [2]: https://lore.kernel.org/dri-devel/dfb4f25ca8dfb0d81d778d6315f104ad.squirrel@mail.panix.com/
> [3]: https://lists.freedesktop.org/archives/dri-devel/2023-April/400088.html
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

  reply	other threads:[~2023-04-17  9:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-12 15:02 Javier Martinez Canillas
2023-04-12 16:18 ` Pierre Asselin
2023-04-12 17:31   ` Javier Martinez Canillas
2023-04-12 18:12     ` Pierre Asselin
2023-04-12 18:24       ` Javier Martinez Canillas
2023-04-12 18:51         ` Pierre Asselin
2023-04-12 21:04           ` Javier Martinez Canillas
2023-04-12 21:40             ` Javier Martinez Canillas
2023-04-12 21:53               ` Pierre Asselin
2023-04-12 22:09                 ` Javier Martinez Canillas
2023-04-12 23:13                   ` Pierre Asselin
2023-04-13  1:13                     ` Pierre Asselin
2023-04-13  1:34                       ` Pierre Asselin
2023-04-17  8:15                         ` Thomas Zimmermann
2023-04-17  8:58                           ` Javier Martinez Canillas
2023-04-17  9:15                             ` Thomas Zimmermann [this message]
2023-04-17  9:29                               ` Javier Martinez Canillas
2023-04-13  7:08                       ` Javier Martinez Canillas
2023-04-13 16:24                         ` Pierre Asselin
2023-04-13 16:34                           ` Javier Martinez Canillas
2023-04-13 17:17                         ` Pierre Asselin
2023-04-13 18:04                           ` Javier Martinez Canillas
2023-04-13  6:54                     ` Javier Martinez Canillas

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=60b7cad3-8923-98b1-2c0f-71bfabd0b2e9@suse.de \
    --to=tzimmermann@suse.de \
    --cc=ardb@kernel.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hdegoede@redhat.com \
    --cc=javierm@redhat.com \
    --cc=jfalempe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pa@panix.com \
    /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®