Skip to content

Commit

Permalink
drm/vkms: Fix RGB565 pixel conversion
Browse files Browse the repository at this point in the history
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.

[v2]:
    * Use drm_fixp2int_round() to fix the pixel conversion instead of
      casting the values to s32 (Melissa Wen).

Fixes: 89b03ae ("drm/vkms: fix 32bit compilation error by replacing macros")
Signed-off-by: Maíra Canal <[email protected]>
Reviewed-by: Arthur Grillo <[email protected]>
Signed-off-by: Maíra Canal <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
  • Loading branch information
mairacanal committed May 15, 2023
1 parent 8b25320 commit ab87f55
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/gpu/drm/vkms/vkms_formats.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,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)
Expand Down Expand Up @@ -232,9 +232,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);
}
Expand Down

0 comments on commit ab87f55

Please sign in to comment.