diff mbox series

[4/8] drm/ssd13xx: Use drm_format_info_min_pitch() to calculate the dest_pitch

Message ID 20231009183522.543918-5-javierm@redhat.com (mailing list archive)
State Superseded
Headers show
Series drm/solomon: Add support for the SSD132x controller family | expand

Commit Message

Javier Martinez Canillas Oct. 9, 2023, 6:34 p.m. UTC
Don't assume bpp of 1 and instead compute the destination pitch using the
intermediate buffer pixel format info when doing a format conversion.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---

 drivers/gpu/drm/solomon/ssd13xx.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Geert Uytterhoeven Oct. 11, 2023, 7:59 a.m. UTC | #1
Hi Javier,

On Mon, Oct 9, 2023 at 8:36 PM Javier Martinez Canillas
<javierm@redhat.com> wrote:
> Don't assume bpp of 1 and instead compute the destination pitch using the
> intermediate buffer pixel format info when doing a format conversion.
>
> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>

Thanks for your patch!

> --- a/drivers/gpu/drm/solomon/ssd13xx.c
> +++ b/drivers/gpu/drm/solomon/ssd13xx.c
> @@ -148,6 +148,8 @@ struct ssd13xx_plane_state {
>         struct drm_shadow_plane_state base;
>         /* Intermediate buffer to convert pixels from XRGB8888 to HW format */
>         u8 *buffer;
> +       /* Pixel format info for the intermediate buffer */
> +       const struct drm_format_info *fi;

This is really intermediate, as it is removed again in the next patch :-)

In fact 60% of this patch is changed again in the next patch.
So perhaps combine this with the next patch?

Gr{oetje,eeting}s,

                        Geert
Javier Martinez Canillas Oct. 11, 2023, 8:37 a.m. UTC | #2
Geert Uytterhoeven <geert@linux-m68k.org> writes:

> Hi Javier,
>
> On Mon, Oct 9, 2023 at 8:36 PM Javier Martinez Canillas
> <javierm@redhat.com> wrote:
>> Don't assume bpp of 1 and instead compute the destination pitch using the
>> intermediate buffer pixel format info when doing a format conversion.
>>
>> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
>
> Thanks for your patch!
>
>> --- a/drivers/gpu/drm/solomon/ssd13xx.c
>> +++ b/drivers/gpu/drm/solomon/ssd13xx.c
>> @@ -148,6 +148,8 @@ struct ssd13xx_plane_state {
>>         struct drm_shadow_plane_state base;
>>         /* Intermediate buffer to convert pixels from XRGB8888 to HW format */
>>         u8 *buffer;
>> +       /* Pixel format info for the intermediate buffer */
>> +       const struct drm_format_info *fi;
>
> This is really intermediate, as it is removed again in the next patch :-)
>
> In fact 60% of this patch is changed again in the next patch.
> So perhaps combine this with the next patch?
>

I actually had it like that but then thought that maybe someone would say
that should be a separate patch :) I will squash it then.

> Gr{oetje,eeting}s,
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/solomon/ssd13xx.c b/drivers/gpu/drm/solomon/ssd13xx.c
index d29be17665b5..9747f8656636 100644
--- a/drivers/gpu/drm/solomon/ssd13xx.c
+++ b/drivers/gpu/drm/solomon/ssd13xx.c
@@ -148,6 +148,8 @@  struct ssd13xx_plane_state {
 	struct drm_shadow_plane_state base;
 	/* Intermediate buffer to convert pixels from XRGB8888 to HW format */
 	u8 *buffer;
+	/* Pixel format info for the intermediate buffer */
+	const struct drm_format_info *fi;
 };
 
 static inline struct ssd13xx_crtc_state *to_ssd13xx_crtc_state(struct drm_crtc_state *state)
@@ -602,8 +604,9 @@  static void ssd13xx_clear_screen(struct ssd13xx_device *ssd13xx, u8 *data_array)
 
 static int ssd13xx_fb_blit_rect(struct drm_framebuffer *fb,
 				const struct iosys_map *vmap,
-				struct drm_rect *rect,
-				u8 *buf, u8 *data_array)
+				struct drm_rect *rect, u8 *buf,
+				const struct drm_format_info *fi,
+				u8 *data_array)
 {
 	struct ssd13xx_device *ssd13xx = drm_to_ssd13xx(fb->dev);
 	struct iosys_map dst;
@@ -614,7 +617,7 @@  static int ssd13xx_fb_blit_rect(struct drm_framebuffer *fb,
 	rect->y1 = round_down(rect->y1, SSD130X_PAGE_HEIGHT);
 	rect->y2 = min_t(unsigned int, round_up(rect->y2, SSD130X_PAGE_HEIGHT), ssd13xx->height);
 
-	dst_pitch = DIV_ROUND_UP(drm_rect_width(rect), 8);
+	dst_pitch = drm_format_info_min_pitch(fi, 0, drm_rect_width(rect));
 
 	ret = drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE);
 	if (ret)
@@ -664,6 +667,8 @@  static int ssd13xx_primary_plane_atomic_check(struct drm_plane *plane,
 	if (!ssd13xx_state->buffer)
 		return -ENOMEM;
 
+	ssd13xx_state->fi = fi;
+
 	return 0;
 }
 
@@ -695,6 +700,7 @@  static void ssd13xx_primary_plane_atomic_update(struct drm_plane *plane,
 
 		ssd13xx_fb_blit_rect(fb, &shadow_plane_state->data[0], &dst_clip,
 				     ssd13xx_plane_state->buffer,
+				     ssd13xx_plane_state->fi,
 				     ssd13xx_crtc_state->data_array);
 	}