Store the source-buffer parameters of drm_fb_blit() in struct drm_pixmap. Update the function's interface and all of its callers. Callers of drm_fb_blit() 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 | 24 +++++------- .../gpu/drm/tests/drm_format_helper_test.c | 38 ++++++++++--------- drivers/gpu/drm/tiny/cirrus.c | 6 ++- drivers/gpu/drm/tiny/ofdrm.c | 6 ++- drivers/gpu/drm/tiny/simpledrm.c | 6 ++- include/drm/drm_format_helper.h | 7 ++-- 6 files changed, 47 insertions(+), 40 deletions(-) diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c index 1dc59c750c3b4..6b80be55cc5c0 100644 --- a/drivers/gpu/drm/drm_format_helper.c +++ b/drivers/gpu/drm/drm_format_helper.c @@ -999,19 +999,18 @@ EXPORT_SYMBOL(drm_fb_xrgb8888_to_gray8); /** * drm_fb_blit - Copy parts of a framebuffer to display memory + * @dev: DRM device * @dst: Array of display-memory addresses to copy to * @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. * @dst_format: FOURCC code of the display's color format - * @src: The framebuffer memory to copy from - * @fb: The framebuffer to copy from - * @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. If the * formats of the display and the framebuffer mismatch, the blit function - * will attempt to convert between them during the process. The parameters @dst, - * @dst_pitch and @src refer to arrays. Each array must have at least as many + * will attempt to convert between them 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 @dst_format's format. Each entry stores the * value for the format's respective color plane at the same index. * @@ -1023,15 +1022,12 @@ EXPORT_SYMBOL(drm_fb_xrgb8888_to_gray8); * -EINVAL if the color-format conversion failed, or * a negative error code otherwise. */ -int drm_fb_blit(struct iosys_map *dst, const unsigned int *dst_pitch, uint32_t dst_format, - const struct iosys_map *src, const struct drm_framebuffer *fb, - const struct drm_rect *clip, struct drm_format_conv_state *state) +int drm_fb_blit(struct drm_device *dev, + struct iosys_map *dst, const unsigned int *dst_pitch, uint32_t dst_format, + const struct drm_pixmap *src_pix, + struct drm_format_conv_state *state) { - struct drm_device *dev = fb->dev; - uint32_t fb_format = fb->format->format; - struct drm_pixmap pixmap; - struct drm_pixmap *src_pix = &pixmap; - drm_pixmap_init_from_framebuffer(src_pix, fb, src, clip); + uint32_t fb_format = src_pix->format->format; if (fb_format == dst_format) { drm_fb_memcpy(dst, dst_pitch, src_pix); @@ -1079,7 +1075,7 @@ int drm_fb_blit(struct iosys_map *dst, const unsigned int *dst_pitch, uint32_t d } } - drm_warn_once(fb->dev, "No conversion helper from %p4cc to %p4cc found.\n", + drm_warn_once(dev, "No conversion helper from %p4cc to %p4cc found.\n", &fb_format, &dst_format); return -EINVAL; diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c index 8c3de91191006..568d6aecc1776 100644 --- a/drivers/gpu/drm/tests/drm_format_helper_test.c +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c @@ -723,7 +723,7 @@ static void drm_test_fb_xrgb8888_to_rgb565(struct kunit *test) int blit_result = 0; - blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_RGB565, &src, &fb, ¶ms->clip, + blit_result = drm_fb_blit(NULL, &dst, dst_pitch, DRM_FORMAT_RGB565, &src_pix, &fmtcnv_state); buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); @@ -772,7 +772,7 @@ static void drm_test_fb_xrgb8888_to_xrgb1555(struct kunit *test) int blit_result = 0; - blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_XRGB1555, &src, &fb, ¶ms->clip, + blit_result = drm_fb_blit(NULL, &dst, dst_pitch, DRM_FORMAT_XRGB1555, &src_pix, &fmtcnv_state); buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); @@ -822,7 +822,7 @@ static void drm_test_fb_xrgb8888_to_argb1555(struct kunit *test) int blit_result = 0; - blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_ARGB1555, &src, &fb, ¶ms->clip, + blit_result = drm_fb_blit(NULL, &dst, dst_pitch, DRM_FORMAT_ARGB1555, &src_pix, &fmtcnv_state); buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); @@ -872,7 +872,7 @@ static void drm_test_fb_xrgb8888_to_rgba5551(struct kunit *test) int blit_result = 0; - blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_RGBA5551, &src, &fb, ¶ms->clip, + blit_result = drm_fb_blit(NULL, &dst, dst_pitch, DRM_FORMAT_RGBA5551, &src_pix, &fmtcnv_state); buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); @@ -925,7 +925,7 @@ static void drm_test_fb_xrgb8888_to_rgb888(struct kunit *test) int blit_result = 0; - blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_RGB888, &src, &fb, ¶ms->clip, + blit_result = drm_fb_blit(NULL, &dst, dst_pitch, DRM_FORMAT_RGB888, &src_pix, &fmtcnv_state); KUNIT_EXPECT_FALSE(test, blit_result); @@ -973,7 +973,7 @@ static void drm_test_fb_xrgb8888_to_argb8888(struct kunit *test) int blit_result = 0; - blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_ARGB8888, &src, &fb, ¶ms->clip, + blit_result = drm_fb_blit(NULL, &dst, dst_pitch, DRM_FORMAT_ARGB8888, &src_pix, &fmtcnv_state); buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); @@ -1023,8 +1023,8 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test) int blit_result = 0; - blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_XRGB2101010, &src, &fb, - ¶ms->clip, &fmtcnv_state); + blit_result = drm_fb_blit(NULL, &dst, dst_pitch, DRM_FORMAT_XRGB2101010, &src_pix, + &fmtcnv_state); KUNIT_EXPECT_FALSE(test, blit_result); KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); @@ -1071,8 +1071,8 @@ static void drm_test_fb_xrgb8888_to_argb2101010(struct kunit *test) int blit_result = 0; - blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_ARGB2101010, &src, &fb, - ¶ms->clip, &fmtcnv_state); + blit_result = drm_fb_blit(NULL, &dst, dst_pitch, DRM_FORMAT_ARGB2101010, &src_pix, + &fmtcnv_state); buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); @@ -1157,8 +1157,8 @@ static void drm_test_fb_swab(struct kunit *test) int blit_result; - blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_XRGB8888 | DRM_FORMAT_BIG_ENDIAN, - &src, &fb, ¶ms->clip, &fmtcnv_state); + blit_result = drm_fb_blit(NULL, &dst, dst_pitch, DRM_FORMAT_XRGB8888 | DRM_FORMAT_BIG_ENDIAN, + &src_pix, &fmtcnv_state); buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); KUNIT_EXPECT_FALSE(test, blit_result); @@ -1167,7 +1167,7 @@ static void drm_test_fb_swab(struct kunit *test) buf = dst.vaddr; memset(buf, 0, dst_size); - blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_BGRX8888, &src, &fb, ¶ms->clip, + blit_result = drm_fb_blit(NULL, &dst, dst_pitch, DRM_FORMAT_BGRX8888, &src_pix, &fmtcnv_state); buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); @@ -1182,7 +1182,7 @@ static void drm_test_fb_swab(struct kunit *test) mock_format.format |= DRM_FORMAT_BIG_ENDIAN; fb.format = &mock_format; - blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_XRGB8888, &src, &fb, ¶ms->clip, + blit_result = drm_fb_blit(NULL, &dst, dst_pitch, DRM_FORMAT_XRGB8888, &src_pix, &fmtcnv_state); buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); @@ -1198,6 +1198,7 @@ static void drm_test_fb_xrgb8888_to_abgr8888(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), @@ -1221,7 +1222,8 @@ static void drm_test_fb_xrgb8888_to_abgr8888(struct kunit *test) int blit_result = 0; - blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_ABGR8888, &src, &fb, ¶ms->clip, + drm_pixmap_init_from_framebuffer(&src_pix, &fb, &src, ¶ms->clip); + blit_result = drm_fb_blit(NULL, &dst, dst_pitch, DRM_FORMAT_ABGR8888, &src_pix, &fmtcnv_state); buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); @@ -1238,6 +1240,7 @@ static void drm_test_fb_xrgb8888_to_xbgr8888(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), @@ -1261,7 +1264,8 @@ static void drm_test_fb_xrgb8888_to_xbgr8888(struct kunit *test) int blit_result = 0; - blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_XBGR8888, &src, &fb, ¶ms->clip, + drm_pixmap_init_from_framebuffer(&src_pix, &fb, &src, ¶ms->clip); + blit_result = drm_fb_blit(NULL, &dst, dst_pitch, DRM_FORMAT_XBGR8888, &src_pix, &fmtcnv_state); buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); @@ -1868,7 +1872,7 @@ static void drm_test_fb_memcpy(struct kunit *test) int blit_result; - blit_result = drm_fb_blit(dst, dst_pitches, params->format, src, &fb, ¶ms->clip, + blit_result = drm_fb_blit(NULL, dst, dst_pitches, params->format, &src_pix, &fmtcnv_state); KUNIT_EXPECT_FALSE(test, blit_result); diff --git a/drivers/gpu/drm/tiny/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c index 4e3a152f897ac..07dae69613733 100644 --- a/drivers/gpu/drm/tiny/cirrus.c +++ b/drivers/gpu/drm/tiny/cirrus.c @@ -410,9 +410,11 @@ static void cirrus_primary_plane_helper_atomic_update(struct drm_plane *plane, drm_atomic_for_each_plane_damage(&iter, &damage) { unsigned int offset = drm_fb_clip_offset(pitch, format, &damage); struct iosys_map dst = IOSYS_MAP_INIT_OFFSET(&vaddr, offset); + struct drm_pixmap src_pix; - drm_fb_blit(&dst, &pitch, format->format, shadow_plane_state->data, fb, - &damage, &shadow_plane_state->fmtcnv_state); + drm_pixmap_init_from_framebuffer(&src_pix, fb, shadow_plane_state->data, &damage); + drm_fb_blit(plane->dev, &dst, &pitch, format->format, &src_pix, + &shadow_plane_state->fmtcnv_state); } drm_dev_exit(idx); diff --git a/drivers/gpu/drm/tiny/ofdrm.c b/drivers/gpu/drm/tiny/ofdrm.c index ab89b7fc7bf61..d99bcdcdbc6b8 100644 --- a/drivers/gpu/drm/tiny/ofdrm.c +++ b/drivers/gpu/drm/tiny/ofdrm.c @@ -824,13 +824,15 @@ static void ofdrm_primary_plane_helper_atomic_update(struct drm_plane *plane, drm_atomic_for_each_plane_damage(&iter, &damage) { struct iosys_map dst = odev->screen_base; struct drm_rect dst_clip = plane_state->dst; + struct drm_pixmap src_pix; if (!drm_rect_intersect(&dst_clip, &damage)) continue; iosys_map_incr(&dst, drm_fb_clip_offset(dst_pitch, dst_format, &dst_clip)); - drm_fb_blit(&dst, &dst_pitch, dst_format->format, shadow_plane_state->data, fb, - &damage, &shadow_plane_state->fmtcnv_state); + drm_pixmap_init_from_framebuffer(&src_pix, fb, shadow_plane_state->data, &damage); + drm_fb_blit(dev, &dst, &dst_pitch, dst_format->format, &src_pix, + &shadow_plane_state->fmtcnv_state); } drm_dev_exit(idx); diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c index 7ce1c46176750..7ea2b28652715 100644 --- a/drivers/gpu/drm/tiny/simpledrm.c +++ b/drivers/gpu/drm/tiny/simpledrm.c @@ -641,13 +641,15 @@ static void simpledrm_primary_plane_helper_atomic_update(struct drm_plane *plane drm_atomic_for_each_plane_damage(&iter, &damage) { struct drm_rect dst_clip = plane_state->dst; struct iosys_map dst = sdev->screen_base; + struct drm_pixmap src_pix; if (!drm_rect_intersect(&dst_clip, &damage)) continue; iosys_map_incr(&dst, drm_fb_clip_offset(sdev->pitch, sdev->format, &dst_clip)); - drm_fb_blit(&dst, &sdev->pitch, sdev->format->format, shadow_plane_state->data, - fb, &damage, &shadow_plane_state->fmtcnv_state); + drm_pixmap_init_from_framebuffer(&src_pix, fb, shadow_plane_state->data, &damage); + drm_fb_blit(dev, &dst, &sdev->pitch, sdev->format->format, &src_pix, + &shadow_plane_state->fmtcnv_state); } drm_dev_exit(idx); diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h index 5e188bcc18b7f..a78360e229a45 100644 --- a/include/drm/drm_format_helper.h +++ b/include/drm/drm_format_helper.h @@ -133,9 +133,10 @@ void drm_fb_xrgb8888_to_gray8(struct iosys_map *dst, const unsigned int *dst_pit const struct drm_pixmap *src_pix, struct drm_format_conv_state *state); -int drm_fb_blit(struct iosys_map *dst, const unsigned int *dst_pitch, uint32_t dst_format, - const struct iosys_map *src, const struct drm_framebuffer *fb, - const struct drm_rect *clip, struct drm_format_conv_state *state); +int drm_fb_blit(struct drm_device *dev, + struct iosys_map *dst, const unsigned int *dst_pitch, uint32_t dst_format, + const struct drm_pixmap *src_pix, + struct drm_format_conv_state *state); void drm_fb_xrgb8888_to_mono(struct drm_device *dev, struct iosys_map *dst, const unsigned int *dst_pitch, -- 2.43.0