Commit af4fd86a authored by Arthur Grillo's avatar Arthur Grillo Committed by Maíra Canal

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: default avatarArthur Grillo <arthurgrillo@riseup.net>
Reviewed-by: default avatarMaíra Canal <mairacanal@riseup.net>
Signed-off-by: default avatarMaíra Canal <mairacanal@riseup.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20230814-gsoc-drm-format-test-v2-v3-5-bd3e9f9bc2fb@riseup.net
parent 371e0b18
...@@ -472,7 +472,7 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { ...@@ -472,7 +472,7 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
* The size of the destination buffer or negative value on error. * The size of the destination buffer or negative value on error.
*/ */
static size_t conversion_buf_size(u32 dst_format, unsigned int dst_pitch, 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); 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, ...@@ -480,7 +480,7 @@ static size_t conversion_buf_size(u32 dst_format, unsigned int dst_pitch,
return -EINVAL; return -EINVAL;
if (!dst_pitch) 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); return dst_pitch * drm_rect_height(clip);
} }
...@@ -554,7 +554,7 @@ static void drm_test_fb_xrgb8888_to_gray8(struct kunit *test) ...@@ -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, dst_size = conversion_buf_size(DRM_FORMAT_R8, result->dst_pitch,
&params->clip); &params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0); KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL); buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
...@@ -588,7 +588,7 @@ static void drm_test_fb_xrgb8888_to_rgb332(struct kunit *test) ...@@ -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, dst_size = conversion_buf_size(DRM_FORMAT_RGB332, result->dst_pitch,
&params->clip); &params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0); KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL); buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
...@@ -621,7 +621,7 @@ static void drm_test_fb_xrgb8888_to_rgb565(struct kunit *test) ...@@ -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, dst_size = conversion_buf_size(DRM_FORMAT_RGB565, result->dst_pitch,
&params->clip); &params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0); KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL); buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
...@@ -660,7 +660,7 @@ static void drm_test_fb_xrgb8888_to_xrgb1555(struct kunit *test) ...@@ -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, dst_size = conversion_buf_size(DRM_FORMAT_XRGB1555, result->dst_pitch,
&params->clip); &params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0); KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL); buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
...@@ -694,7 +694,7 @@ static void drm_test_fb_xrgb8888_to_argb1555(struct kunit *test) ...@@ -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, dst_size = conversion_buf_size(DRM_FORMAT_ARGB1555, result->dst_pitch,
&params->clip); &params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0); KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL); buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
...@@ -728,7 +728,7 @@ static void drm_test_fb_xrgb8888_to_rgba5551(struct kunit *test) ...@@ -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, dst_size = conversion_buf_size(DRM_FORMAT_RGBA5551, result->dst_pitch,
&params->clip); &params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0); KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL); buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
...@@ -762,7 +762,7 @@ static void drm_test_fb_xrgb8888_to_rgb888(struct kunit *test) ...@@ -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, dst_size = conversion_buf_size(DRM_FORMAT_RGB888, result->dst_pitch,
&params->clip); &params->clip, 0);
KUNIT_ASSERT_GT(test, dst_size, 0); KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL); buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
...@@ -799,7 +799,7 @@ static void drm_test_fb_xrgb8888_to_argb8888(struct kunit *test) ...@@ -799,7 +799,7 @@ static void drm_test_fb_xrgb8888_to_argb8888(struct kunit *test)
}; };
dst_size = conversion_buf_size(DRM_FORMAT_ARGB8888, 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); KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL); buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
...@@ -833,7 +833,7 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test) ...@@ -833,7 +833,7 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test)
}; };
dst_size = conversion_buf_size(DRM_FORMAT_XRGB2101010, 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); KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL); buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
...@@ -867,7 +867,7 @@ static void drm_test_fb_xrgb8888_to_argb2101010(struct kunit *test) ...@@ -867,7 +867,7 @@ static void drm_test_fb_xrgb8888_to_argb2101010(struct kunit *test)
}; };
dst_size = conversion_buf_size(DRM_FORMAT_ARGB2101010, 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); KUNIT_ASSERT_GT(test, dst_size, 0);
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL); buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
...@@ -900,7 +900,7 @@ static void drm_test_fb_xrgb8888_to_mono(struct kunit *test) ...@@ -900,7 +900,7 @@ static void drm_test_fb_xrgb8888_to_mono(struct kunit *test)
.pitches = { params->pitch, 0, 0 }, .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); KUNIT_ASSERT_GT(test, dst_size, 0);
...@@ -933,7 +933,7 @@ static void drm_test_fb_swab(struct kunit *test) ...@@ -933,7 +933,7 @@ static void drm_test_fb_swab(struct kunit *test)
.pitches = { params->pitch, 0, 0 }, .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); KUNIT_ASSERT_GT(test, dst_size, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment