[U-Boot,1/2] video: bmp: Fix video_splash_align_axis()
diff mbox series

Message ID 20191120104418.1179-2-patrice.chotard@st.com
State Superseded
Headers show
Series
  • Fix BMP decode when BMP size is bigger than framebuffer
Related show

Commit Message

Patrice CHOTARD Nov. 20, 2019, 10:44 a.m. UTC
In case the panel_size is smaller than picture_size, we must insure
that panel_picture_delta stores the absolute value of difference
between panel_size and picture_size.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
CC: Yannick Fertré <yannick.fertre@st.com>
---

 drivers/video/video_bmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Patrick Delaunay Nov. 20, 2019, 11:06 a.m. UTC | #1
Hi,

> From: Patrice CHOTARD <patrice.chotard@st.com>
> Sent: mercredi 20 novembre 2019 11:44
> 
> In case the panel_size is smaller than picture_size, we must insure that
> panel_picture_delta stores the absolute value of difference between panel_size
> and picture_size.
> 
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> CC: Yannick Fertré <yannick.fertre@st.com>
> ---
> 
>  drivers/video/video_bmp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c index
> 193f37d275..dc6258ce78 100644
> --- a/drivers/video/video_bmp.c
> +++ b/drivers/video/video_bmp.c
> @@ -157,7 +157,7 @@ __weak void fb_put_word(uchar **fb, uchar **from)
> static void video_splash_align_axis(int *axis, unsigned long panel_size,
>  				    unsigned long picture_size)
>  {
> -	unsigned long panel_picture_delta = panel_size - picture_size;
> +	unsigned long panel_picture_delta = abs(panel_size - picture_size);

I think this patch cause alignment issue if picture_size > panel_size. (not alligne a the left/up corner).

I think it is beeter to change type:

+ long panel_picture_delta = panel_size - picture_size;

As value is cropped to 0 in the next lines:

*axis = max(0, (int)axis_alignment);



>  	unsigned long axis_alignment;
> 
>  	if (*axis == BMP_ALIGN_CENTER)
> --
> 2.17.1


Regards

Patrick
Patrice CHOTARD Nov. 20, 2019, 1:09 p.m. UTC | #2
On 11/20/19 12:06 PM, Patrick DELAUNAY wrote:
> Hi,
>
>> From: Patrice CHOTARD <patrice.chotard@st.com>
>> Sent: mercredi 20 novembre 2019 11:44
>>
>> In case the panel_size is smaller than picture_size, we must insure that
>> panel_picture_delta stores the absolute value of difference between panel_size
>> and picture_size.
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
>> CC: Yannick Fertré <yannick.fertre@st.com>
>> ---
>>
>>  drivers/video/video_bmp.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c index
>> 193f37d275..dc6258ce78 100644
>> --- a/drivers/video/video_bmp.c
>> +++ b/drivers/video/video_bmp.c
>> @@ -157,7 +157,7 @@ __weak void fb_put_word(uchar **fb, uchar **from)
>> static void video_splash_align_axis(int *axis, unsigned long panel_size,
>>  				    unsigned long picture_size)
>>  {
>> -	unsigned long panel_picture_delta = panel_size - picture_size;
>> +	unsigned long panel_picture_delta = abs(panel_size - picture_size);
> I think this patch cause alignment issue if picture_size > panel_size. (not alligne a the left/up corner).
>
> I think it is beeter to change type:
>
> + long panel_picture_delta = panel_size - picture_size;
>
> As value is cropped to 0 in the next lines:
>
> *axis = max(0, (int)axis_alignment);
>
Agree, i will update this in V2

Thanks

>
>>  	unsigned long axis_alignment;
>>
>>  	if (*axis == BMP_ALIGN_CENTER)
>> --
>> 2.17.1
>
> Regards
>
> Patrick

Patch
diff mbox series

diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c
index 193f37d275..dc6258ce78 100644
--- a/drivers/video/video_bmp.c
+++ b/drivers/video/video_bmp.c
@@ -157,7 +157,7 @@  __weak void fb_put_word(uchar **fb, uchar **from)
 static void video_splash_align_axis(int *axis, unsigned long panel_size,
 				    unsigned long picture_size)
 {
-	unsigned long panel_picture_delta = panel_size - picture_size;
+	unsigned long panel_picture_delta = abs(panel_size - picture_size);
 	unsigned long axis_alignment;
 
 	if (*axis == BMP_ALIGN_CENTER)