Store the source-buffer parameters of drm_fb_xrgb8888_to_rgb332() in struct drm_pixmap. Update the function's interface and all of its callers. Callers of drm_fb_xrgb8888_to_rgb332() initialize the pixmap's instance from a pre-existing instance of struct drm_framebuffer. There's potential to simplify some of that code in a later patch. Signed-off-by: Thomas Zimmermann <tzimmermann@xxxxxxx> --- drivers/gpu/drm/drm_format_helper.c | 14 ++++---------- drivers/gpu/drm/gud/gud_pipe.c | 2 +- drivers/gpu/drm/solomon/ssd130x.c | 4 +++- drivers/gpu/drm/tests/drm_format_helper_test.c | 5 ++++- include/drm/drm_format_helper.h | 3 +-- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c index 6d53620f86f0d..3ce4567c32218 100644 --- a/drivers/gpu/drm/drm_format_helper.c +++ b/drivers/gpu/drm/drm_format_helper.c @@ -433,15 +433,13 @@ static void drm_fb_xrgb8888_to_rgb332_line(void *dbuf, const void *sbuf, unsigne * @dst: Array of RGB332 destination buffers * @dst_pitch: Array of numbers of bytes between the start of two consecutive scanlines * within @dst; can be NULL if scanlines are stored next to each other. - * @src: Array of XRGB8888 source buffers - * @fb: DRM framebuffer - * @clip: Clip rectangle area to copy + * @src_pix: Source pixmap to copy from * @state: Transform and conversion state * * This function copies parts of a framebuffer to display memory and converts the * color format during the process. Destination and framebuffer formats must match. The - * parameters @dst, @dst_pitch and @src refer to arrays. Each array must have at - * least as many entries as there are planes in @fb's format. Each entry stores the + * parameters @dst and @dst_pitch refer to arrays. Each array must have at + * least as many entries as there are planes in pixmap's format. Each entry stores the * value for the format's respective color plane at the same index. * * This function does not apply clipping on @dst (i.e. the destination is at the @@ -450,15 +448,11 @@ static void drm_fb_xrgb8888_to_rgb332_line(void *dbuf, const void *sbuf, unsigne * Drivers can use this function for RGB332 devices that don't support XRGB8888 natively. */ void drm_fb_xrgb8888_to_rgb332(struct iosys_map *dst, const unsigned int *dst_pitch, - const struct iosys_map *src, const struct drm_framebuffer *fb, - const struct drm_rect *clip, struct drm_format_conv_state *state) + const struct drm_pixmap *src_pix, struct drm_format_conv_state *state) { static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES] = { 1, }; - struct drm_pixmap pixmap; - struct drm_pixmap *src_pix = &pixmap; - drm_pixmap_init_from_framebuffer(src_pix, fb, src, clip); drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src_pix, false, state, drm_fb_xrgb8888_to_rgb332_line); diff --git a/drivers/gpu/drm/gud/gud_pipe.c b/drivers/gpu/drm/gud/gud_pipe.c index 89e491497210f..94c6da63cbff2 100644 --- a/drivers/gpu/drm/gud/gud_pipe.c +++ b/drivers/gpu/drm/gud/gud_pipe.c @@ -190,7 +190,7 @@ static int gud_prep_flush(struct gud_device *gdrm, struct drm_framebuffer *fb, } else if (format->format == DRM_FORMAT_R8) { drm_fb_xrgb8888_to_gray8(&dst, NULL, src, fb, rect, fmtcnv_state); } else if (format->format == DRM_FORMAT_RGB332) { - drm_fb_xrgb8888_to_rgb332(&dst, NULL, src, fb, rect, fmtcnv_state); + drm_fb_xrgb8888_to_rgb332(&dst, NULL, &src_pix, fmtcnv_state); } else if (format->format == DRM_FORMAT_RGB565) { drm_fb_xrgb8888_to_rgb565(&dst, NULL, src, fb, rect, fmtcnv_state, gud_is_big_endian()); diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c index ebd943b9e357b..05305c0788e17 100644 --- a/drivers/gpu/drm/solomon/ssd130x.c +++ b/drivers/gpu/drm/solomon/ssd130x.c @@ -1069,6 +1069,7 @@ static int ssd133x_fb_blit_rect(struct drm_framebuffer *fb, const struct drm_format_info *fi = drm_format_info(DRM_FORMAT_RGB332); unsigned int dst_pitch; struct iosys_map dst; + struct drm_pixmap src_pix; int ret = 0; if (!fi) @@ -1081,7 +1082,8 @@ static int ssd133x_fb_blit_rect(struct drm_framebuffer *fb, return ret; iosys_map_set_vaddr(&dst, data_array); - drm_fb_xrgb8888_to_rgb332(&dst, &dst_pitch, vmap, fb, rect, fmtcnv_state); + drm_pixmap_init_from_framebuffer(&src_pix, fb, vmap, rect); + drm_fb_xrgb8888_to_rgb332(&dst, &dst_pitch, &src_pix, fmtcnv_state); drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE); diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c index 3f27da79a9658..326a4fd3b6141 100644 --- a/drivers/gpu/drm/tests/drm_format_helper_test.c +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c @@ -646,6 +646,7 @@ static void drm_test_fb_xrgb8888_to_rgb332(struct kunit *test) u8 *buf = NULL; __le32 *xrgb8888 = NULL; struct iosys_map dst, src; + struct drm_pixmap src_pix; struct drm_framebuffer fb = { .format = drm_format_info(DRM_FORMAT_XRGB8888), @@ -667,7 +668,9 @@ static void drm_test_fb_xrgb8888_to_rgb332(struct kunit *test) const unsigned int *dst_pitch = (result->dst_pitch == TEST_USE_DEFAULT_PITCH) ? NULL : &result->dst_pitch; - drm_fb_xrgb8888_to_rgb332(&dst, dst_pitch, &src, &fb, ¶ms->clip, &fmtcnv_state); + drm_pixmap_init_from_framebuffer(&src_pix, &fb, &src, ¶ms->clip); + + drm_fb_xrgb8888_to_rgb332(&dst, dst_pitch, &src_pix, &fmtcnv_state); KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); } diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h index 6227545734bf9..ad4d63d8aa6a9 100644 --- a/include/drm/drm_format_helper.h +++ b/include/drm/drm_format_helper.h @@ -104,8 +104,7 @@ void drm_fb_swab(struct drm_device *dev, const struct drm_pixmap *src_pix, bool cached, struct drm_format_conv_state *state); void drm_fb_xrgb8888_to_rgb332(struct iosys_map *dst, const unsigned int *dst_pitch, - const struct iosys_map *src, const struct drm_framebuffer *fb, - const struct drm_rect *clip, struct drm_format_conv_state *state); + const struct drm_pixmap *src_pix, struct drm_format_conv_state *state); void drm_fb_xrgb8888_to_rgb565(struct iosys_map *dst, const unsigned int *dst_pitch, const struct iosys_map *src, const struct drm_framebuffer *fb, const struct drm_rect *clip, struct drm_format_conv_state *state, -- 2.43.0