drm/tests: Add multi-plane support to conversion_buf_size()

The drm_fb_memcpy() supports multi-plane formats. To fully test it in
the future, add multi-plane support to the conversion_buf_size() helper.

Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>
Reviewed-by: Maíra Canal <mairacanal@riseup.net>
Signed-off-by: Maíra Canal <mairacanal@riseup.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20230814-gsoc-drm-format-test-v2-v3-5-bd3e9f9bc2fb@riseup.net
This commit is contained in:
Arthur Grillo 2023-08-14 19:12:04 -03:00 committed by Maíra Canal
parent 371e0b186a
commit af4fd86a5c
No known key found for this signature in database
GPG Key ID: B02EE8FD76781ED5

View File

@ -472,7 +472,7 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
* The size of the destination buffer or negative value on error.
*/
static size_t conversion_buf_size(u32 dst_format, unsigned int dst_pitch,
const struct drm_rect *clip)
const struct drm_rect *clip, int plane)
{
const struct drm_format_info *dst_fi = drm_format_info(dst_format);
@ -480,7 +480,7 @@ static size_t conversion_buf_size(u32 dst_format, unsigned int dst_pitch,
return -EINVAL;
if (!dst_pitch)
dst_pitch = drm_format_info_min_pitch(dst_fi, 0, drm_rect_width(clip));
dst_pitch = drm_format_info_min_pitch(dst_fi, plane, drm_rect_width(clip));
return dst_pitch * drm_rect_height(clip);
}
@ -554,7 +554,7 @@ static void drm_test_fb_xrgb8888_to_gray8(struct kunit *test)
};
dst_size = conversion_buf_size(DRM_FORMAT_R8, result->dst_pitch,
&params->clip);
&params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
@ -588,7 +588,7 @@ static void drm_test_fb_xrgb8888_to_rgb332(struct kunit *test)
};
dst_size = conversion_buf_size(DRM_FORMAT_RGB332, result->dst_pitch,
&params->clip);
&params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
@ -621,7 +621,7 @@ static void drm_test_fb_xrgb8888_to_rgb565(struct kunit *test)
};
dst_size = conversion_buf_size(DRM_FORMAT_RGB565, result->dst_pitch,
&params->clip);
&params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
@ -660,7 +660,7 @@ static void drm_test_fb_xrgb8888_to_xrgb1555(struct kunit *test)
};
dst_size = conversion_buf_size(DRM_FORMAT_XRGB1555, result->dst_pitch,
&params->clip);
&params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
@ -694,7 +694,7 @@ static void drm_test_fb_xrgb8888_to_argb1555(struct kunit *test)
};
dst_size = conversion_buf_size(DRM_FORMAT_ARGB1555, result->dst_pitch,
&params->clip);
&params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
@ -728,7 +728,7 @@ static void drm_test_fb_xrgb8888_to_rgba5551(struct kunit *test)
};
dst_size = conversion_buf_size(DRM_FORMAT_RGBA5551, result->dst_pitch,
&params->clip);
&params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
@ -762,7 +762,7 @@ static void drm_test_fb_xrgb8888_to_rgb888(struct kunit *test)
};
dst_size = conversion_buf_size(DRM_FORMAT_RGB888, result->dst_pitch,
&params->clip);
&params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
@ -799,7 +799,7 @@ static void drm_test_fb_xrgb8888_to_argb8888(struct kunit *test)
};
dst_size = conversion_buf_size(DRM_FORMAT_ARGB8888,
result->dst_pitch, &params->clip);
result->dst_pitch, &params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
@ -833,7 +833,7 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test)
};
dst_size = conversion_buf_size(DRM_FORMAT_XRGB2101010,
result->dst_pitch, &params->clip);
result->dst_pitch, &params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
@ -867,7 +867,7 @@ static void drm_test_fb_xrgb8888_to_argb2101010(struct kunit *test)
};
dst_size = conversion_buf_size(DRM_FORMAT_ARGB2101010,
result->dst_pitch, &params->clip);
result->dst_pitch, &params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
@ -900,7 +900,7 @@ static void drm_test_fb_xrgb8888_to_mono(struct kunit *test)
.pitches = { params->pitch, 0, 0 },
};
dst_size = conversion_buf_size(DRM_FORMAT_C1, result->dst_pitch, &params->clip);
dst_size = conversion_buf_size(DRM_FORMAT_C1, result->dst_pitch, &params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0);
@ -933,7 +933,7 @@ static void drm_test_fb_swab(struct kunit *test)
.pitches = { params->pitch, 0, 0 },
};
dst_size = conversion_buf_size(DRM_FORMAT_XRGB8888, result->dst_pitch, &params->clip);
dst_size = conversion_buf_size(DRM_FORMAT_XRGB8888, result->dst_pitch, &params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0);