[PATCH 12/23] drm/format-helper: Use struct drm_pixmap for drm_fb_xrgb8888_to_argb8888()
Thomas Zimmermann
tzimmermann at suse.de
Tue Jan 30 09:53:47 UTC 2024
Store the source-buffer parameters of drm_fb_xrgb8888_to_argb8888()
in struct drm_pixmap. Update the function's interface and all of its
callers.
Callers of drm_fb_xrgb8888_to_argb8888() 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 at suse.de>
---
drivers/gpu/drm/drm_format_helper.c | 19 +++++++------------
.../gpu/drm/tests/drm_format_helper_test.c | 5 ++++-
include/drm/drm_format_helper.h | 4 ++--
3 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 1dd362a286d20..9798b77c4a2db 100644
--- a/drivers/gpu/drm/drm_format_helper.c
+++ b/drivers/gpu/drm/drm_format_helper.c
@@ -754,16 +754,14 @@ static void drm_fb_xrgb8888_to_argb8888_line(void *dbuf, const void *sbuf, unsig
* @dst: Array of ARGB8888 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 buffer
- * @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. The parameters @dst, @dst_pitch and @src refer
+ * color format during the process. The parameters @dst and @dst_pitch refer
* to arrays. Each array must have at least as many entries as there are planes in
- * @fb's format. Each entry stores the value for the format's respective color plane
- * at the same index.
+ * the 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
* top-left corner).
@@ -772,15 +770,12 @@ static void drm_fb_xrgb8888_to_argb8888_line(void *dbuf, const void *sbuf, unsig
* natively. It sets an opaque alpha channel as part of the conversion.
*/
void drm_fb_xrgb8888_to_argb8888(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] = {
4,
};
- 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_argb8888_line);
@@ -1091,7 +1086,7 @@ int drm_fb_blit(struct iosys_map *dst, const unsigned int *dst_pitch, uint32_t d
drm_fb_xrgb8888_to_rgb888(dst, dst_pitch, src_pix, state);
return 0;
} else if (dst_format == DRM_FORMAT_ARGB8888) {
- drm_fb_xrgb8888_to_argb8888(dst, dst_pitch, src, fb, clip, state);
+ drm_fb_xrgb8888_to_argb8888(dst, dst_pitch, src_pix, state);
return 0;
} else if (dst_format == DRM_FORMAT_XBGR8888) {
drm_fb_xrgb8888_to_xbgr8888(dst, dst_pitch, src, fb, clip, state);
diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
index 4c6523e7b5cc5..30dceba3d8ecf 100644
--- a/drivers/gpu/drm/tests/drm_format_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
@@ -937,6 +937,7 @@ static void drm_test_fb_xrgb8888_to_argb8888(struct kunit *test)
u32 *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),
@@ -958,7 +959,9 @@ static void drm_test_fb_xrgb8888_to_argb8888(struct kunit *test)
const unsigned int *dst_pitch = (result->dst_pitch == TEST_USE_DEFAULT_PITCH) ?
NULL : &result->dst_pitch;
- drm_fb_xrgb8888_to_argb8888(&dst, dst_pitch, &src, &fb, ¶ms->clip, &fmtcnv_state);
+ drm_pixmap_init_from_framebuffer(&src_pix, &fb, &src, ¶ms->clip);
+
+ drm_fb_xrgb8888_to_argb8888(&dst, dst_pitch, &src_pix, &fmtcnv_state);
buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32));
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 621052690ce3b..0f91234eb44c2 100644
--- a/include/drm/drm_format_helper.h
+++ b/include/drm/drm_format_helper.h
@@ -121,8 +121,8 @@ void drm_fb_xrgb8888_to_rgb888(struct iosys_map *dst, const unsigned int *dst_pi
const struct drm_pixmap *src_pix,
struct drm_format_conv_state *state);
void drm_fb_xrgb8888_to_argb8888(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_xrgb2101010(struct iosys_map *dst, const unsigned int *dst_pitch,
const struct iosys_map *src, const struct drm_framebuffer *fb,
const struct drm_rect *clip,
--
2.43.0
More information about the dri-devel
mailing list