drm/tests: Update format-helper tests for sysfb
Subsystems (3)
Thomas Zimmermann
maintainerv3 cover drm/tests: Update format-helper tests for sysfb
The helpers drm_fb_blit() and drm_fb_build_fourcc_list() will be integrated into sysfb helpers. Update the DRM format-helper tests accordingly in patches 1 and 2.
The change to drm_fb_build_fourcc_list() is simple enough that we can apply it here in patch 3.
v3:
- rename symbols (José)
v2:
- fix test filename (Maxime)
- fix dependencies (kernel test robot)
Thomas Zimmermann (3):
drm/tests: Do not use drm_fb_blit() in format-helper tests drm/tests: Test drm_fb_build_fourcc_list() in separate test suite drm/format-helper: Move drm_fb_build_fourcc_list() to sysfb helpers
drivers/gpu/drm/Kconfig.debug | 1 + drivers/gpu/drm/drm_format_helper.c | 246 +++++++---------- drivers/gpu/drm/drm_format_internal.h | 8 + drivers/gpu/drm/sysfb/drm_sysfb_helper.h | 4 + drivers/gpu/drm/sysfb/drm_sysfb_modeset.c | 138 ++++++++++ drivers/gpu/drm/sysfb/efidrm.c | 4 +- drivers/gpu/drm/sysfb/ofdrm.c | 5 +- drivers/gpu/drm/sysfb/simpledrm.c | 5 +- drivers/gpu/drm/sysfb/vesadrm.c | 4 +- drivers/gpu/drm/tests/Makefile | 3 +- .../gpu/drm/tests/drm_format_helper_test.c | 250 ++---------------- .../gpu/drm/tests/drm_sysfb_modeset_test.c | 168 ++++++++++++ include/drm/drm_format_helper.h | 13 +- 13 files changed, 452 insertions(+), 397 deletions(-) create mode 100644 drivers/gpu/drm/tests/drm_sysfb_modeset_test.c
Signature · 1 line
2.49.0
Thomas Zimmermann
maintainerPATCH v3 1/3 drm/tests: Do not use drm_fb_blit() in format-helper tests
Export additional helpers from the format-helper library and open-code drm_fb_blit() in tests. Prepares for the removal of drm_fb_blit(). Only sysfb drivers use drm_fb_blit(). The function will soon be removed from format helpers and be refactored within sysfb helpers.
--- drivers/gpu/drm/drm_format_helper.c | 108 ++++++++++++++++-- drivers/gpu/drm/drm_format_internal.h | 8 ++ .../gpu/drm/tests/drm_format_helper_test.c | 108 +++--------------- include/drm/drm_format_helper.h | 9 ++ 4 files changed, 131 insertions(+), 102 deletions(-)
drivers/gpu/drm/drm_format_helper.c +98 -10
@@ -858,11 +858,33 @@ static void drm_fb_xrgb8888_to_abgr8888_line(void *dbuf, const void *sbuf, unsigdrm_fb_xfrm_line_32to32 (dbuf, sbuf, pixels, drm_pixel_xrgb8888_to_abgr8888); } -static void drm_fb_xrgb8888_to_abgr8888 (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) +/** +* drm_fb_xrgb8888_to_abgr8888 - Convert XRGB8888 to ABGR8888 clip buffer +* @dst: Array of ABGR8888 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 +* @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 +* 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. +* +* This function does not apply clipping on @dst (i.e. the destination is at the +* top-left corner). +* +* Drivers can use this function for ABGR8888 devices that don't support XRGB8888 +* natively. It sets an opaque alpha channel as part of the conversion. +*/ +void drm_fb_xrgb8888_to_abgr8888 (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) {static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES ] = {4 ,
@@ -871,17 +893,40 @@ static void drm_fb_xrgb8888_to_abgr8888(struct iosys_map *dst, const unsigned indrm_fb_xfrm (dst, dst_pitch, dst_pixsize, src, fb, clip, false, state, drm_fb_xrgb8888_to_abgr8888_line); } +EXPORT_SYMBOL (drm_fb_xrgb8888_to_abgr8888);static void drm_fb_xrgb8888_to_xbgr8888_line (void *dbuf,const void *sbuf,unsigned int pixels) {drm_fb_xfrm_line_32to32 (dbuf, sbuf, pixels, drm_pixel_xrgb8888_to_xbgr8888); } -static void drm_fb_xrgb8888_to_xbgr8888 (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) +/** +* drm_fb_xrgb8888_to_xbgr8888 - Convert XRGB8888 to XBGR8888 clip buffer +* @dst: Array of XBGR8888 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 +* @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 +* 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. +* +* This function does not apply clipping on @dst (i.e. the destination is at the +* top-left corner). +* +* Drivers can use this function for XBGR8888 devices that don't support XRGB8888 +* natively. +*/ +void drm_fb_xrgb8888_to_xbgr8888 (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) {static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES ] = {4 ,
@@ -890,6 +935,49 @@ static void drm_fb_xrgb8888_to_xbgr8888(struct iosys_map *dst, const unsigned indrm_fb_xfrm (dst, dst_pitch, dst_pixsize, src, fb, clip, false, state, drm_fb_xrgb8888_to_xbgr8888_line); } +EXPORT_SYMBOL (drm_fb_xrgb8888_to_xbgr8888); + +static void drm_fb_xrgb8888_to_bgrx8888_line (void *dbuf,const void *sbuf,unsigned int pixels) +{ +drm_fb_xfrm_line_32to32 (dbuf, sbuf, pixels, drm_pixel_xrgb8888_to_bgrx8888); +} + +/** +* drm_fb_xrgb8888_to_bgrx8888 - Convert XRGB8888 to BGRX8888 clip buffer +* @dst: Array of BGRX8888 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 +* @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 +* 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. +* +* This function does not apply clipping on @dst (i.e. the destination is at the +* top-left corner). +* +* Drivers can use this function for BGRX8888 devices that don't support XRGB8888 +* natively. +*/ +void drm_fb_xrgb8888_to_bgrx8888 (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) +{ +static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES ] = { +4 , + }; + +drm_fb_xfrm (dst, dst_pitch, dst_pixsize, src, fb, clip, false, state, + drm_fb_xrgb8888_to_bgrx8888_line); +} +EXPORT_SYMBOL (drm_fb_xrgb8888_to_bgrx8888);static void drm_fb_xrgb8888_to_xrgb2101010_line (void *dbuf,const void *sbuf,unsigned int pixels) {
drivers/gpu/drm/drm_format_internal.h +8 -0
@@ -111,6 +111,14 @@ static inline u32 drm_pixel_xrgb8888_to_xbgr8888(u32 pix) ((pix &0x000000ff ) <<16 ); } +static inline u32 drm_pixel_xrgb8888_to_bgrx8888 (u32 pix) +{ +return ((pix &0xff000000 ) >>24 ) |/* also copy filler bits */ + ((pix &0x00ff0000 ) >>8 ) | + ((pix &0x0000ff00 ) <<8 ) | + ((pix &0x000000ff ) <<24 ); +} +static inline u32 drm_pixel_xrgb8888_to_abgr8888 (u32 pix) { return GENMASK(31, 24) | /* fill alpha bits */
drivers/gpu/drm/tests/drm_format_helper_test.c +16 -92
210 lines not on this page · raw message
include/drm/drm_format_helper.h +9 -0
@@ -102,6 +102,15 @@ void drm_fb_xrgb8888_to_bgr888(struct iosys_map *dst, const unsigned int *dst_pivoid 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); +void drm_fb_xrgb8888_to_abgr8888 (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); +void drm_fb_xrgb8888_to_xbgr8888 (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); +void drm_fb_xrgb8888_to_bgrx8888 (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); 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,
Signature · 1 line
2.49.0
Thomas Zimmermann
maintainerPATCH v3 2/3 drm/tests: Test drm_fb_build_fourcc_list() in separate test suite
In reply to Thomas ZimmermannOnly sysfb drivers use drm_fb_build_fourcc_list(). The helper will be moved from format helpers to sysfb helpers. Moving the related tests to their own test suite.
v3:
- rename tests according to filename (José)
v2:
- rename filename to match tested code (Maxime)
--- drivers/gpu/drm/tests/Makefile | 3 +- .../gpu/drm/tests/drm_format_helper_test.c | 142 --------------- .../gpu/drm/tests/drm_sysfb_modeset_test.c | 166 ++++++++++++++++++ 3 files changed, 168 insertions(+), 143 deletions(-) create mode 100644 drivers/gpu/drm/tests/drm_sysfb_modeset_test.c
drivers/gpu/drm/tests/Makefile +2 -1
@@ -23,6 +23,7 @@ obj-$(CONFIG_DRM_KUNIT_TEST) += \ drm_modes_test.o \ drm_plane_helper_test.o \ drm_probe_helper_test.o \ - drm_rect_test.o + drm_rect_test.o \ + drm_sysfb_modeset_test.o CFLAGS_drm_mm_test.o := $(DISABLE_STRUCTLEAK_PLUGIN)
drivers/gpu/drm/tests/drm_format_helper_test.c +0 -142
154 lines not on this page · raw message
drivers/gpu/drm/tests/drm_sysfb_modeset_test.c new file +166 -0
166 lines not on this page · raw message
Signature · 1 line
2.49.0
Thomas Zimmermann
maintainerPATCH v3 3/3 drm/format-helper: Move drm_fb_build_fourcc_list() to sysfb helpers
In reply to Thomas ZimmermannOnly sysfb drivers use drm_fb_build_fourcc_list(). Move the function to sysfb helpers and rename it accordingly. Update drivers and tests.
v3:
- update naming in tests
v2:
- select DRM_SYSFB_HELPER (kernel test robot)
--- drivers/gpu/drm/Kconfig.debug | 1 + drivers/gpu/drm/drm_format_helper.c | 138 ------------------ drivers/gpu/drm/sysfb/drm_sysfb_helper.h | 4 + drivers/gpu/drm/sysfb/drm_sysfb_modeset.c | 138 ++++++++++++++++++ drivers/gpu/drm/sysfb/efidrm.c | 4 +- drivers/gpu/drm/sysfb/ofdrm.c | 5 +- drivers/gpu/drm/sysfb/simpledrm.c | 5 +- drivers/gpu/drm/sysfb/vesadrm.c | 4 +- .../gpu/drm/tests/drm_sysfb_modeset_test.c | 24 +-- include/drm/drm_format_helper.h | 4 - 10 files changed, 164 insertions(+), 163 deletions(-)
drivers/gpu/drm/Kconfig.debug +1 -0
@@ -70,6 +70,7 @@ config DRM_KUNIT_TEST select DRM_GEM_SHMEM_HELPER select DRM_KUNIT_TEST_HELPERS select DRM_LIB_RANDOM + select DRM_SYSFB_HELPER select PRIME_NUMBERS default KUNIT_ALL_TESTS help
drivers/gpu/drm/drm_format_helper.c +0 -138
141 lines not on this page · raw message
drivers/gpu/drm/sysfb/drm_sysfb_helper.h +4 -0
@@ -93,6 +93,10 @@ static inline struct drm_sysfb_device *to_drm_sysfb_device(struct drm_device *de* Plane */ +size_t drm_sysfb_build_fourcc_list (struct drm_device *dev, +const u32 *native_fourccs,size_t native_nfourccs, +u32 *fourccs_out,size_t nfourccs_out); +int drm_sysfb_plane_helper_atomic_check (struct drm_plane *plane,struct drm_atomic_state *new_state); void drm_sysfb_plane_helper_atomic_update(struct drm_plane *plane,
drivers/gpu/drm/sysfb/drm_sysfb_modeset.c +138 -0
144 lines not on this page · raw message
drivers/gpu/drm/sysfb/efidrm.c +2 -2
@@ -271,8 +271,8 @@ static struct efidrm_device *efidrm_device_create(struct drm_driver *drv,/* Primary plane */ - nformats =drm_fb_build_fourcc_list (dev, &format->format,1 , - efi->formats,ARRAY_SIZE (efi->formats)); + nformats =drm_sysfb_build_fourcc_list (dev, &format->format,1 , + efi->formats,ARRAY_SIZE (efi->formats)); primary_plane = &efi->primary_plane; ret = drm_universal_plane_init(dev, primary_plane, 0, &efidrm_primary_plane_funcs,
drivers/gpu/drm/sysfb/ofdrm.c +2 -3
@@ -15,7 +15,6 @@#include <drm/drm_drv.h> #include <drm/drm_edid.h> #include <drm/drm_fbdev_shmem.h> -#include <drm/drm_format_helper.h> #include <drm/drm_framebuffer.h> #include <drm/drm_gem_atomic_helper.h> #include <drm/drm_gem_framebuffer_helper.h>
@@ -1015,8 +1014,8 @@ static struct ofdrm_device *ofdrm_device_create(struct drm_driver *drv,/* Primary plane */ - nformats =drm_fb_build_fourcc_list (dev, &format->format,1 , - odev->formats,ARRAY_SIZE (odev->formats)); + nformats =drm_sysfb_build_fourcc_list (dev, &format->format,1 , + odev->formats,ARRAY_SIZE (odev->formats)); primary_plane = &odev->primary_plane; ret = drm_universal_plane_init(dev, primary_plane, 0, &ofdrm_primary_plane_funcs,
drivers/gpu/drm/sysfb/simpledrm.c +2 -3
@@ -18,7 +18,6 @@#include <drm/drm_device.h> #include <drm/drm_drv.h> #include <drm/drm_fbdev_shmem.h> -#include <drm/drm_format_helper.h> #include <drm/drm_framebuffer.h> #include <drm/drm_gem_atomic_helper.h> #include <drm/drm_gem_framebuffer_helper.h>
@@ -765,8 +764,8 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,/* Primary plane */ - nformats =drm_fb_build_fourcc_list (dev, &format->format,1 , - sdev->formats,ARRAY_SIZE (sdev->formats)); + nformats =drm_sysfb_build_fourcc_list (dev, &format->format,1 , + sdev->formats,ARRAY_SIZE (sdev->formats)); primary_plane = &sdev->primary_plane; ret = drm_universal_plane_init(dev, primary_plane, 0, &simpledrm_primary_plane_funcs,
drivers/gpu/drm/sysfb/vesadrm.c +2 -2
@@ -402,8 +402,8 @@ static struct vesadrm_device *vesadrm_device_create(struct drm_driver *drv,/* Primary plane */ - nformats =drm_fb_build_fourcc_list (dev, &format->format,1 , - vesa->formats,ARRAY_SIZE (vesa->formats)); + nformats =drm_sysfb_build_fourcc_list (dev, &format->format,1 , + vesa->formats,ARRAY_SIZE (vesa->formats)); primary_plane = &vesa->primary_plane; ret = drm_universal_plane_init(dev, primary_plane, 0, &vesadrm_primary_plane_funcs,
drivers/gpu/drm/tests/drm_sysfb_modeset_test.c +13 -11
@@ -2,13 +2,14 @@#include <kunit/test.h> -#include <drm/drm_format_helper.h> #include <drm/drm_fourcc.h> #include <drm/drm_kunit_helpers.h> +#include "../sysfb/drm_sysfb_helper.h" +#define TEST_BUF_SIZE 50 -struct fb_build_fourcc_list_case { +struct sysfb_build_fourcc_list_case {const char *name;u32 native_fourccs[TEST_BUF_SIZE ];size_t native_fourccs_size;
@@ -16,7 +17,7 @@ struct fb_build_fourcc_list_case {size_t expected_fourccs_size; }; -static struct fb_build_fourcc_list_case fb_build_fourcc_list_cases[] = { +static struct sysfb_build_fourcc_list_case sysfb_build_fourcc_list_cases[] = { { .name ="no native formats" , .native_fourccs = { },
@@ -120,16 +121,17 @@ static struct fb_build_fourcc_list_case fb_build_fourcc_list_cases[] = { }, }; -static void fb_build_fourcc_list_case_desc (struct fb_build_fourcc_list_case *t,char *desc) +static void sysfb_build_fourcc_list_case_desc (struct sysfb_build_fourcc_list_case *t,char *desc) {strscpy (desc, t->name,KUNIT_PARAM_DESC_SIZE ); } -KUNIT_ARRAY_PARAM (fb_build_fourcc_list, fb_build_fourcc_list_cases, fb_build_fourcc_list_case_desc); +KUNIT_ARRAY_PARAM (sysfb_build_fourcc_list, sysfb_build_fourcc_list_cases, + sysfb_build_fourcc_list_case_desc); -static void drm_test_fb_build_fourcc_list (struct kunit *test) +static void drm_test_sysfb_build_fourcc_list (struct kunit *test) { -const struct fb_build_fourcc_list_case *params = test->param_value; +const struct sysfb_build_fourcc_list_case *params = test->param_value;u32 fourccs_out[TEST_BUF_SIZE ] = {0 };size_t nfourccs_out;struct drm_device *drm;
@@ -141,16 +143,16 @@ static void drm_test_fb_build_fourcc_list(struct kunit *test) drm =__drm_kunit_helper_alloc_drm_device (test, dev,sizeof (*drm),0 ,DRIVER_MODESET );KUNIT_ASSERT_NOT_ERR_OR_NULL (test, drm); - nfourccs_out =drm_fb_build_fourcc_list (drm, params->native_fourccs, - params->native_fourccs_size, - fourccs_out,TEST_BUF_SIZE ); + nfourccs_out =drm_sysfb_build_fourcc_list (drm, params->native_fourccs, + params->native_fourccs_size, + fourccs_out,TEST_BUF_SIZE );KUNIT_EXPECT_EQ (test, nfourccs_out, params->expected_fourccs_size);KUNIT_EXPECT_MEMEQ (test, fourccs_out, params->expected,TEST_BUF_SIZE ); }static struct kunit_case drm_sysfb_modeset_test_cases[] = { -KUNIT_CASE_PARAM (drm_test_fb_build_fourcc_list, fb_build_fourcc_list_gen_params), +KUNIT_CASE_PARAM (drm_test_sysfb_build_fourcc_list, sysfb_build_fourcc_list_gen_params), {} };
include/drm/drm_format_helper.h +0 -4
@@ -134,8 +134,4 @@ void drm_fb_xrgb8888_to_mono(struct iosys_map *dst, const unsigned int *dst_pitc const struct iosys_map *src, const struct drm_framebuffer *fb, const struct drm_rect *clip, struct drm_format_conv_state *state); -size_t drm_fb_build_fourcc_list (struct drm_device *dev, -const u32 *native_fourccs,size_t native_nfourccs, -u32 *fourccs_out,size_t nfourccs_out); -#endif /* __LINUX_DRM_FORMAT_HELPER_H */
Signature · 1 line
2.49.0