All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arthur Grillo Queiroz Cabral <arthurgrillo@riseup.net>
To: "Maíra Canal" <mcanal@igalia.com>,
	"David Airlie" <airlied@gmail.com>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Rodrigo Siqueira" <rodrigosiqueiramelo@gmail.com>,
	"Melissa Wen" <mwen@igalia.com>,
	"Haneen Mohammed" <hamohammed.sa@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 2/2] drm/vkms: Fix RGB565 pixel conversion
Date: Thu, 11 May 2023 16:41:23 -0300	[thread overview]
Message-ID: <87fb8f63-ae38-33eb-08ef-7410b52b4f98@riseup.net> (raw)
In-Reply-To: <20230507202848.207608-2-mcanal@igalia.com>



On 07/05/23 17:28, Maíra Canal wrote:
> Currently, the pixel conversion isn't rounding the fixed-point values
> before assigning it to the RGB coefficients, which is causing the IGT
> pixel-format tests to fail. So, use the drm_fixp2int_round() fixed-point
> helper to round the values when assigning it to the RGB coefficients.
> 
> Tested with igt@kms_plane@pixel-format and igt@kms_plane@pixel-format-source-clamping.
> 
> Fixes: 89b03aeaef16 ("drm/vkms: fix 32bit compilation error by replacing macros")
> Signed-off-by: Maíra Canal <mcanal@igalia.com>
> ---

Reviewed-by: Arthur Grillo <arthurgrillo@riseup.net>

Best Regards,
~Arthur Grillo

> 
> v1 -> v2: https://lore.kernel.org/dri-devel/20230425153353.238844-1-mcanal@igalia.com/T/
> 
> * Use drm_fixp2int_round() to fix the pixel conversion instead of casting
>   the values to s32 (Melissa Wen).
> 
> ---
>  drivers/gpu/drm/vkms/vkms_formats.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c
> index 8d948c73741e..b11342026485 100644
> --- a/drivers/gpu/drm/vkms/vkms_formats.c
> +++ b/drivers/gpu/drm/vkms/vkms_formats.c
> @@ -97,9 +97,9 @@ static void RGB565_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_pixel)
>  	s64 fp_b = drm_int2fixp(rgb_565 & 0x1f);
>  
>  	out_pixel->a = (u16)0xffff;
> -	out_pixel->r = drm_fixp2int(drm_fixp_mul(fp_r, fp_rb_ratio));
> -	out_pixel->g = drm_fixp2int(drm_fixp_mul(fp_g, fp_g_ratio));
> -	out_pixel->b = drm_fixp2int(drm_fixp_mul(fp_b, fp_rb_ratio));
> +	out_pixel->r = drm_fixp2int_round(drm_fixp_mul(fp_r, fp_rb_ratio));
> +	out_pixel->g = drm_fixp2int_round(drm_fixp_mul(fp_g, fp_g_ratio));
> +	out_pixel->b = drm_fixp2int_round(drm_fixp_mul(fp_b, fp_rb_ratio));
>  }
>  
>  void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state *plane, int y)
> @@ -216,9 +216,9 @@ static void argb_u16_to_RGB565(struct vkms_frame_info *frame_info,
>  		s64 fp_g = drm_int2fixp(in_pixels[x].g);
>  		s64 fp_b = drm_int2fixp(in_pixels[x].b);
>  
> -		u16 r = drm_fixp2int(drm_fixp_div(fp_r, fp_rb_ratio));
> -		u16 g = drm_fixp2int(drm_fixp_div(fp_g, fp_g_ratio));
> -		u16 b = drm_fixp2int(drm_fixp_div(fp_b, fp_rb_ratio));
> +		u16 r = drm_fixp2int_round(drm_fixp_div(fp_r, fp_rb_ratio));
> +		u16 g = drm_fixp2int_round(drm_fixp_div(fp_g, fp_g_ratio));
> +		u16 b = drm_fixp2int_round(drm_fixp_div(fp_b, fp_rb_ratio));
>  
>  		*dst_pixels = cpu_to_le16(r << 11 | g << 5 | b);
>  	}

  reply	other threads:[~2023-05-11 19:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-07 20:28 [PATCH v2 1/2] drm: Add fixed-point helper to get rounded integer values Maíra Canal
2023-05-07 20:28 ` [PATCH v2 2/2] drm/vkms: Fix RGB565 pixel conversion Maíra Canal
2023-05-11 19:41   ` Arthur Grillo Queiroz Cabral [this message]
2023-05-11 19:35 ` [PATCH v2 1/2] drm: Add fixed-point helper to get rounded integer values Arthur Grillo Queiroz Cabral

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=87fb8f63-ae38-33eb-08ef-7410b52b4f98@riseup.net \
    --to=arthurgrillo@riseup.net \
    --cc=airlied@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hamohammed.sa@gmail.com \
    --cc=mcanal@igalia.com \
    --cc=mwen@igalia.com \
    --cc=rodrigosiqueiramelo@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.