Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode
v4 cover Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode
This series introduces the required plumbing for allocating buffers in the VC4 T-tiled and SAND_tiled modes, along with helpers to convert to these tiling modes.
A new "checkerboard" comparison method is introduced to check whether captured frames match their references in cases where pixel-perfect results are not possible (e.g. with scaling) and the analog test does not provide reliable results.
With that in place, new tests for the Chamelium are introduced to perform testing of planes with randomized properties, both with a CRC and frame comparison fashion.
This series is based on version 4 of Maxime Ripard's series:
igt: chamelium: Test YUV buffers using the Chamelium
Changes since v3:
* Documented the chamelium_check enum;
* Documented the checkerboard algorithm;
* Added igt_assert after memory allocations;
* Added modifier support to igt_fb_convert;
* Dropped inline helpers for checking vc4 tiling support;
* Various requested minor changes;
* Rebased on v4 of Maxime Ripard's YUV series;
* Added collected Reviewed-By tags;
Changes since v2:
* Added support for SAND tiling;
* Generalized T-tiling to support both 16 and 32 bpp;
* Split the main test into more sub-functions;
* Removed explicit lists of DRM formats;
* Added helper to list known DRM formats;
* Various functional fixes in the main test;
* Removed unnecessary pointer init in map_bo;
* Rebased on v3 of Maxime Ripard's YUV series;
* Added collected Reviewed-By tags;
Changes since v1:
* Added collected Reviewed-by tags;
* Removed explicit size and constified tiling read order tables;
* Removed unnecessary MAP_FAILED addition in map_bo;
* Added pipe and output helpers to count and iterate planes of a given type;
* Moved CRC debug prints to the chamelium library;
* Fixed destination stride description for igt_fb_convert_with_stride;
* Split planes test into a few sub-routines;
* Removed explicit underrun detection since general error reporting is enough;
* Removed underrun detection bits due to ongoing Chamelium-specific issues;
* Deconfigured planes before removing their framebuffer, avoiding kmsg errors.
Paul Kocialkowski (21):
lib: drmtest: Add helpers to check and require the VC4 driver lib/igt_fb: Add checks on i915 for i915-specific tiled buffer
allocation
lib/igt_fb: Add support for allocating T-tiled VC4 buffers lib/igt_fb: Add support for VC4 SAND tiling modes lib/igt_fb: Allow interpreting the tile height as a stride equivalent lib/igt_fb: Add a stride-provisioned fashion of igt_fb_convert lib/igt_fb: Add a helper to retreive the plane bpp for a given format lib/igt_fb: Add a helper to fill-in the available DRM formats lib/igt_vc4: Add helpers for converting linear to T-tiled RGB buffers lib/igt_vc4: Add helpers for converting linear to SAND-tiled buffers lib/igt_fb: Pass the modifier to igt_fb_convert helpers lib/igt_fb: Support converting to VC4 modifiers in igt_fb_convert lib/igt_kms: Add helpers to count and iterate planes from pipe lib/igt_kms: Add helpers to count and iterate planes from output lib/igt_chamelium: Fixup resources liberation in comparison helpers lib/igt_chamelium: Split frames dump logic and rework surroundings lib/igt_chamelium: Generalize the frame match helper with check type lib/igt_frame: Add a checkerboard frame comparison method lib/igt_chamelium: Hook-in checkerboard comparison method in helpers
chamelium: Move the YUV tests over to the checkerboard checking method
chamelium: Add a display test for randomized planes
lib/drmtest.c | 10 + lib/drmtest.h | 2 + lib/igt_chamelium.c | 125 +++++++---- lib/igt_chamelium.h | 22 +- lib/igt_fb.c | 181 +++++++++++++++- lib/igt_fb.h | 9 +- lib/igt_frame.c | 135 ++++++++++++ lib/igt_frame.h | 2 + lib/igt_kms.c | 84 ++++++++ lib/igt_kms.h | 6 + lib/igt_vc4.c | 239 +++++++++++++++++++++ lib/igt_vc4.h | 8 + tests/kms_chamelium.c | 476 ++++++++++++++++++++++++++++++++++++++++-- 13 files changed, 1220 insertions(+), 79 deletions(-)
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 1/21 lib: drmtest: Add helpers to check and require the VC4 driver
In order to add support for features specific to the VC4 driver, add helpers for checking and requiring the driver like it's done for the i915 driver.
--- lib/drmtest.c | 10 ++++++++++ lib/drmtest.h | 2 ++ 2 files changed, 12 insertions(+)
lib/drmtest.c +10 -0
@@ -105,6 +105,11 @@ bool is_i915_device(int fd)return __is_device (fd,"i915" ); } +bool is_vc4_device (int fd) +{ +return __is_device (fd,"vc4" ); +} +static bool has_known_intel_chipset (int fd) {struct drm_i915_getparam gp;
@@ -482,3 +487,8 @@ void igt_require_intel(int fd) {igt_require (is_i915_device (fd) &&has_known_intel_chipset (fd)); } + +void igt_require_vc4 (int fd) +{ +igt_require (is_vc4_device (fd)); +}
lib/drmtest.h +2 -0
@@ -80,8 +80,10 @@ int __drm_open_driver(int chipset);void gem_quiescent_gpu (int fd);void igt_require_intel (int fd); +void igt_require_vc4 (int fd);bool is_i915_device (int fd); +bool is_vc4_device (int fd);/** * do_or_die:
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 2/21 lib/igt_fb: Add checks on i915 for i915-specific tiled buffer allocation
In reply to Paul KocialkowskiThe code path for allocating tiled buffers has a few i915-specific bits without checks for the i915 driver. Add these missing checks.
--- lib/igt_fb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
lib/igt_fb.c +5 -1
@@ -364,6 +364,7 @@ static uint32_t calc_plane_stride(struct igt_fb *fb, int plane) (fb->plane_bpp[plane] /8 );if (fb->tiling !=LOCAL_DRM_FORMAT_MOD_NONE && +is_i915_device (fb->fd) &&intel_gen (intel_get_drm_devid (fb->fd)) <=3 ) {uint32_t stride;
@@ -392,6 +393,7 @@ static uint32_t calc_plane_stride(struct igt_fb *fb, int plane)static uint64_t calc_plane_size (struct igt_fb *fb,int plane) {if (fb->tiling !=LOCAL_DRM_FORMAT_MOD_NONE && +is_i915_device (fb->fd) &&intel_gen (intel_get_drm_devid (fb->fd)) <=3 ) {uint64_t min_size = (uint64_t ) fb->strides[plane] * fb->plane_height[plane];
@@ -1505,9 +1507,11 @@ static void *map_bo(int fd, struct igt_fb *fb)if (fb->is_dumb) ptr =kmstest_dumb_map_buffer (fd, fb->gem_handle, fb->size,PROT_READ |PROT_WRITE ); -else +else if (is_i915_device (fd)) ptr =gem_mmap__gtt (fd, fb->gem_handle, fb->size,PROT_READ |PROT_WRITE ); +else +igt_assert (false);return ptr; }
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 3/21 lib/igt_fb: Add support for allocating T-tiled VC4 buffers
In reply to Paul KocialkowskiThis introduces the required bits for allocating buffers with a T-tiled disposition, that is specific to the VC4. It includes calculating the top-tile width and creating a buffer object with the VC4-specific helper. The tiling flag is set to the buffer object so that this can be reused for GPU tests if needed later.
--- lib/igt_fb.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
lib/igt_fb.c +19 -0
@@ -37,6 +37,7 @@#include "igt_fb.h" #include "igt_kms.h" #include "igt_matrix.h" +#include "igt_vc4.h" #include "igt_x86.h" #include "ioctl_wrappers.h" #include "intel_batchbuffer.h"
@@ -237,6 +238,9 @@ static const struct format_desc_struct *lookup_drm_format(uint32_t drm_format)void igt_get_fb_tile_size (int fd,uint64_t tiling,int fb_bpp,unsigned *width_ret,unsigned *height_ret) { +if (is_vc4_device (fd)) + tiling =fourcc_mod_broadcom_mod (tiling); +switch (tiling) {case LOCAL_DRM_FORMAT_MOD_NONE :if (is_i915_device (fd))
@@ -290,6 +294,11 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,igt_assert (false); }break ; +case DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED : +igt_require_vc4 (fd); + *width_ret =128 ; + *height_ret =32 ; +break ;default :igt_assert (false); }
@@ -583,6 +592,13 @@ static int create_bo_for_fb(struct igt_fb *fb)igt_fb_mod_to_tiling (fb->tiling), fb->strides[0]); + goto out; + }else if (is_vc4_device (fd)) { + fb->gem_handle =igt_vc4_create_bo (fd, fb->size); + +if (fb->tiling ==DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED ) +igt_vc4_set_tiling (fd, fb->gem_handle, fb->tiling); + goto out; }
@@ -1510,6 +1526,9 @@ static void *map_bo(int fd, struct igt_fb *fb)else if (is_i915_device (fd)) ptr =gem_mmap__gtt (fd, fb->gem_handle, fb->size,PROT_READ |PROT_WRITE ); +else if (is_vc4_device (fd)) + ptr =igt_vc4_mmap_bo (fd, fb->gem_handle, fb->size, +PROT_READ |PROT_WRITE );else igt_assert (false);
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 4/21 lib/igt_fb: Add support for VC4 SAND tiling modes
In reply to Paul KocialkowskiThis introduces support for the VC4 SAND tiling modes, that take a specific parameter indicating their column height. This parameter acts as a height-based stride equivalent, that shall be equal or greater than the displayed height.
The parameter is extracted and returned as tile height so that enough memory can be reserved for column heights containing extra padding.
--- lib/igt_fb.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
lib/igt_fb.c +25 -1
@@ -238,8 +238,12 @@ static const struct format_desc_struct *lookup_drm_format(uint32_t drm_format)void igt_get_fb_tile_size (int fd,uint64_t tiling,int fb_bpp,unsigned *width_ret,unsigned *height_ret) { -if (is_vc4_device (fd)) +uint32_t vc4_tiling_param =0 ; + +if (is_vc4_device (fd)) { + vc4_tiling_param =fourcc_mod_broadcom_param (tiling); tiling =fourcc_mod_broadcom_mod (tiling); + }switch (tiling) {case LOCAL_DRM_FORMAT_MOD_NONE :
@@ -299,6 +303,26 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, *width_ret =128 ; *height_ret =32 ;break ; +case DRM_FORMAT_MOD_BROADCOM_SAND32 : +igt_require_vc4 (fd); + *width_ret =32 ; + *height_ret = vc4_tiling_param; +break ; +case DRM_FORMAT_MOD_BROADCOM_SAND64 : +igt_require_vc4 (fd); + *width_ret =64 ; + *height_ret = vc4_tiling_param; +break ; +case DRM_FORMAT_MOD_BROADCOM_SAND128 : +igt_require_vc4 (fd); + *width_ret =128 ; + *height_ret = vc4_tiling_param; +break ; +case DRM_FORMAT_MOD_BROADCOM_SAND256 : +igt_require_vc4 (fd); + *width_ret =256 ; + *height_ret = vc4_tiling_param; +break ;default :igt_assert (false); }
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t v4 04/21] lib/igt_fb: Add support for VC4 SAND tiling modes
Quoted 9 lines · Paul Kocialkowski
This introduces support for the VC4 SAND tiling modes, that take a specific parameter indicating their column height. This parameter acts as a height-based stride equivalent, that shall be equal or greater than the displayed height.
The parameter is extracted and returned as tile height so that enough memory can be reserved for column heights containing extra padding.
Signed-off-by Paul Kocialkowski <[email protected]>
Maxime
Signature · 3 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t v4 04/21] lib/igt_fb: Add support for VC4 SAND tiling modes
In reply to Paul KocialkowskiQuoted 60 lines · Paul Kocialkowski
This introduces support for the VC4 SAND tiling modes, that take a specific parameter indicating their column height. This parameter acts as a height-based stride equivalent, that shall be equal or greater than the displayed height.
The parameter is extracted and returned as tile height so that enough memory can be reserved for column heights containing extra padding.
Signed-off-by Paul Kocialkowski <[email protected]>--- lib/igt_fb.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)lib/igt_fb.c +5
-1@@ -238,8 +238,12 @@ static const struct format_desc_struct *lookup_drm_format(uint32_t drm_format)void igt_get_fb_tile_size (int fd,uint64_t tiling,int fb_bpp,unsigned *width_ret,unsigned *height_ret) { -if (is_vc4_device (fd)) +uint32_t vc4_tiling_param =0 ; + +if (is_vc4_device (fd)) { + vc4_tiling_param =fourcc_mod_broadcom_param (tiling); tiling =fourcc_mod_broadcom_mod (tiling); + }switch (tiling) {lib/igt_fb.c +20
-0case LOCAL_DRM_FORMAT_MOD_NONE :@@ -299,6 +303,26 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, *width_ret =128 ; *height_ret =32 ;break ; +case DRM_FORMAT_MOD_BROADCOM_SAND32 : +igt_require_vc4 (fd); + *width_ret =32 ; + *height_ret = vc4_tiling_param; +break ; +case DRM_FORMAT_MOD_BROADCOM_SAND64 : +igt_require_vc4 (fd); + *width_ret =64 ; + *height_ret = vc4_tiling_param; +break ; +case DRM_FORMAT_MOD_BROADCOM_SAND128 : +igt_require_vc4 (fd); + *width_ret =128 ; + *height_ret = vc4_tiling_param; +break ; +case DRM_FORMAT_MOD_BROADCOM_SAND256 : +igt_require_vc4 (fd); + *width_ret =256 ; + *height_ret = vc4_tiling_param; +break ;default :igt_assert (false);}
Signature · 7 lines
Cheers, Lyude Paul _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 5/21 lib/igt_fb: Allow interpreting the tile height as a stride equivalent
In reply to Paul KocialkowskiThe VC4 SAND tiling modes are disposed in columns that follow each other in memory. The column height defines the number of fixed-width lines from the beginning of one column to the other, which may be greater than the display height. In this case, the extra lines are used as padding and the column height becomes a height-based stride equivalent.
Support this when calculating the plane size by using the tile height directly if it is greater than the plane height. This works better than alignment for non-power-of-two cases (no space is wasted) and it is equivalent to alignment for power-of-two tile heights.
--- lib/igt_fb.c | 7 +++++++ 1 file changed, 7 insertions(+)
lib/igt_fb.c +7 -0
@@ -450,6 +450,13 @@ static uint64_t calc_plane_size(struct igt_fb *fb, int plane)igt_get_fb_tile_size (fb->fd, fb->tiling, fb->plane_bpp[plane], &tile_width, &tile_height); +/* Special case where the "tile height" represents a +* height-based stride, such as with VC4 SAND tiling modes. +*/ + +if (tile_height > fb->plane_height[plane]) +return fb->strides[plane] * tile_height; +return (uint64_t ) fb->strides[plane] *ALIGN (fb->plane_height[plane], tile_height); }
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 6/21 lib/igt_fb: Add a stride-provisioned fashion of igt_fb_convert
In reply to Paul KocialkowskiThe current implementation of igt_fb_convert does not allow passing the destination stride, which is something we want to change for tests.
Add a new fashion of this function that allocates the desintation buffer with a given stride. Since the current function does the same thing with an unspecified stride (set to zero, which will be filled later), make it call our new fashion with the stride set to zero to avoid duplication.
--- lib/igt_fb.c | 38 ++++++++++++++++++++++++++++++++------ lib/igt_fb.h | 3 +++ 2 files changed, 35 insertions(+), 6 deletions(-)
lib/igt_fb.c +32 -6
@@ -2250,14 +2250,15 @@ void igt_remove_fb(int fd, struct igt_fb *fb) }/** -* igt_fb_convert: +* igt_fb_convert_with_stride: * @dst: pointer to the #igt_fb structure that will store the conversion result * @src: pointer to the #igt_fb structure that stores the frame we convert * @dst_fourcc: DRM format specifier to convert to +* @dst_stride: Stride for the resulting framebuffer (0 for automatic stride) * * This will convert a given @src content to the @dst_fourcc format, * storing the result in the @dst fb, allocating the @dst fb -* underlying buffer. +* underlying buffer with a stride of @dst_stride stride. * * Once done with @dst, the caller will have to call igt_remove_fb() * on it to free the associated resources.
@@ -2265,15 +2266,18 @@ void igt_remove_fb(int fd, struct igt_fb *fb)* Returns: * The kms id of the created framebuffer. */ -unsigned int igt_fb_convert (struct igt_fb *dst,struct igt_fb *src, -uint32_t dst_fourcc) +unsigned int igt_fb_convert_with_stride (struct igt_fb *dst,struct igt_fb *src, +uint32_t dst_fourcc, +unsigned int dst_stride) {struct fb_convert cvt = { };void *dst_ptr, *src_ptr;int fb_id; - fb_id =igt_create_fb (src->fd, src->width, src->height, - dst_fourcc,LOCAL_DRM_FORMAT_MOD_NONE , dst); + fb_id =igt_create_fb_with_bo_size (src->fd, src->width, src->height, + dst_fourcc, +LOCAL_DRM_FORMAT_MOD_NONE , + dst,0 , dst_stride);igt_assert (fb_id >0 ); src_ptr =igt_fb_map_buffer (src->fd, src);
@@ -2294,6 +2298,28 @@ unsigned int igt_fb_convert(struct igt_fb *dst, struct igt_fb *src,return fb_id; } +/** +* igt_fb_convert: +* @dst: pointer to the #igt_fb structure that will store the conversion result +* @src: pointer to the #igt_fb structure that stores the frame we convert +* @dst_fourcc: DRM format specifier to convert to +* +* This will convert a given @src content to the @dst_fourcc format, +* storing the result in the @dst fb, allocating the @dst fb +* underlying buffer. +* +* Once done with @dst, the caller will have to call igt_remove_fb() +* on it to free the associated resources. +* +* Returns: +* The kms id of the created framebuffer. +*/ +unsigned int igt_fb_convert (struct igt_fb *dst,struct igt_fb *src, +uint32_t dst_fourcc) +{ +return igt_fb_convert_with_stride (dst, src, dst_fourcc,0 ); +} +/** * igt_bpp_depth_to_drm_format: * @bpp: desired bits per pixel
lib/igt_fb.h +3 -0
@@ -130,6 +130,9 @@ unsigned int igt_create_image_fb(int drm_fd, int width, int height, struct igt_fb *fb /* out */);unsigned int igt_create_stereo_fb (int drm_fd,drmModeModeInfo *mode,uint32_t format,uint64_t tiling); +unsigned int igt_fb_convert_with_stride (struct igt_fb *dst,struct igt_fb *src, +uint32_t dst_fourcc, +unsigned int stride);unsigned int igt_fb_convert (struct igt_fb *dst,struct igt_fb *src,uint32_t dst_fourcc);void igt_remove_fb (int fd,struct igt_fb *fb);
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 7/21 lib/igt_fb: Add a helper to retreive the plane bpp for a given format
In reply to Paul KocialkowskiThe format bpp for a given plane is stored in the static format_desc structure and is not accessible to tests, which is inconvenient to get the minimum stride for a format when testing various strides.
Add a simple helper to expose the information.
--- lib/igt_fb.c | 16 ++++++++++++++++ lib/igt_fb.h | 1 + 2 files changed, 17 insertions(+)
lib/igt_fb.c +16 -0
@@ -2421,3 +2421,19 @@ bool igt_format_is_yuv(uint32_t drm_format)return false; } } + +/** +* igt_format_plane_bpp: +* @drm_format: drm fourcc +* @plane: format plane index +* +* This functions returns the number of bits per pixel for the given @plane +* index of the @drm_format. +*/ +int igt_format_plane_bpp (uint32_t drm_format,int plane) +{ +const struct format_desc_struct *format = +lookup_drm_format (drm_format); + +return format->plane_bpp[plane]; +}
lib/igt_fb.h +1 -0
@@ -175,6 +175,7 @@ uint32_t igt_drm_format_to_bpp(uint32_t drm_format);const char *igt_format_str (uint32_t drm_format);bool igt_fb_supported_format (uint32_t drm_format);bool igt_format_is_yuv (uint32_t drm_format); +int igt_format_plane_bpp (uint32_t drm_format,int plane);#endif /* __IGT_FB_H__ */
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 8/21 lib/igt_fb: Add a helper to fill-in the available DRM formats
In reply to Paul KocialkowskiIntroduce a helper to allocate and fill-in a list of available DRM formats, which is useful for picking one at random in tests.
--- lib/igt_fb.c | 35 +++++++++++++++++++++++++++++++++++ lib/igt_fb.h | 2 ++ 2 files changed, 37 insertions(+)
lib/igt_fb.c +35 -0
@@ -2437,3 +2437,38 @@ int igt_format_plane_bpp(uint32_t drm_format, int plane)return format->plane_bpp[plane]; } + +/** +* igt_format_array_fill: +* @formats_array: a pointer to the formats array pointer to be allocated +* @count: a pointer to the number of elements contained in the allocated array +* @allow_yuv: a boolean indicating whether YUV formats should be included +* +* This functions allocates and fills a @formats_array that lists the DRM +* formats current available. +*/ +void igt_format_array_fill (uint32_t **formats_array,unsigned int *count, +bool allow_yuv) +{ +const struct format_desc_struct *format; +unsigned int index =0 ; + + *count =0 ; + +for_each_format (format) { +if (!allow_yuv &&igt_format_is_yuv (format->drm_id)) +continue ; + + (*count)++; + } + + *formats_array =calloc (*count,sizeof (uint32_t )); +igt_assert (*formats_array); + +for_each_format (format) { +if (!allow_yuv &&igt_format_is_yuv (format->drm_id)) +continue ; + + (*formats_array)[index++] = format->drm_id; + } +}
lib/igt_fb.h +2 -0
@@ -176,6 +176,8 @@ const char *igt_format_str(uint32_t drm_format);bool igt_fb_supported_format (uint32_t drm_format);bool igt_format_is_yuv (uint32_t drm_format);int igt_format_plane_bpp (uint32_t drm_format,int plane); +void igt_format_array_fill (uint32_t **formats_array,unsigned int *count, +bool allow_yuv);#endif /* __IGT_FB_H__ */
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t v4 08/21] lib/igt_fb: Add a helper to fill-in the available DRM formats
Quoted 5 lines · Paul Kocialkowski
Introduce a helper to allocate and fill-in a list of available DRM formats, which is useful for picking one at random in tests.
Signed-off-by Paul Kocialkowski <[email protected]>Reviewed-by Lyude Paul <[email protected]>
Maxime
Signature · 3 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 9/21 lib/igt_vc4: Add helpers for converting linear to T-tiled RGB buffers
In reply to Paul KocialkowskiIn order to integrate testing of T-tiled buffers, the easiest path is to generate patterns (with the already-existing functions) in linear buffers and convert them to T-tiled subsequently.
Add helpers to do that conversion, with a first helper that returns the memory offset for a given position in a T-tiled buffer and a second helper that uses it for converting between framebuffers.
--- lib/igt_vc4.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_vc4.h | 4 ++ 2 files changed, 135 insertions(+)
lib/igt_vc4.c +131 -0
@@ -34,6 +34,7 @@#include "drmtest.h" #include "igt_aux.h" #include "igt_core.h" +#include "igt_fb.h" #include "igt_vc4.h" #include "ioctl_wrappers.h" #include "intel_reg.h"
@@ -176,3 +177,133 @@ bool igt_vc4_purgeable_bo(int fd, int handle, bool purgeable)return arg.retained; } + +unsigned int igt_vc4_fb_t_tiled_convert (struct igt_fb *dst,struct igt_fb *src) +{ +unsigned int fb_id; +unsigned int i, j; +void *src_buf; +void *dst_buf; +size_t bpp = src->plane_bpp[0 ]; +size_t dst_stride =ALIGN (src->strides[0 ],128 ); + + fb_id =igt_create_fb_with_bo_size (src->fd, src->width, src->height, + src->drm_format, +DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED , + dst,0 , dst_stride); +igt_assert (fb_id >0 ); + +igt_assert (bpp ==16 || bpp ==32 ); + + src_buf =igt_fb_map_buffer (src->fd, src); +igt_assert (src_buf); + + dst_buf =igt_fb_map_buffer (dst->fd, dst); +igt_assert (dst_buf); + +for (i =0 ; i < src->height; i++) { +for (j =0 ; j < src->width; j++) { +size_t src_offset = src->offsets[0 ]; +size_t dst_offset = dst->offsets[0 ]; + + src_offset += src->strides[0 ] * i + j * bpp /8 ; + dst_offset +=igt_vc4_t_tiled_offset (dst_stride, + src->height, + bpp, j, i); + +switch (bpp) { +case 16 : + *(uint16_t *)(dst_buf + dst_offset) = + *(uint16_t *)(src_buf + src_offset); +break ; +case 32 : + *(uint32_t *)(dst_buf + dst_offset) = + *(uint32_t *)(src_buf + src_offset); +break ; + } + } + } + +igt_fb_unmap_buffer (src, src_buf); +igt_fb_unmap_buffer (dst, dst_buf); + +return fb_id; +} + +/* Calculate the t-tile width so that size = width * height * bpp / 8. */ +#define VC4_T_TILE_W (size, height, bpp) ((size) / (height) / ((bpp) / 8)) + +size_t igt_vc4_t_tiled_offset (size_t stride,size_t height,size_t bpp, +size_t x,size_t y) +{ +const size_t t1k_map_even[] = {0 ,3 ,1 ,2 }; +const size_t t1k_map_odd[] = {2 ,1 ,3 ,0 }; +const size_t t4k_t_h =32 ; +const size_t t1k_t_h =16 ; +const size_t t64_t_h =4 ; +size_t offset =0 ; +size_t t4k_t_w, t4k_w, t4k_x, t4k_y; +size_t t1k_t_w, t1k_x, t1k_y; +size_t t64_t_w, t64_x, t64_y; +size_t pix_x, pix_y; +unsigned int index; + +/* T-tiling is only supported for 16 and 32 bpp. */ +igt_assert (bpp ==16 || bpp ==32 ); + +/* T-tiling stride must be aligned to the 4K tiles strides. */ +igt_assert ((stride % (4096 / t4k_t_h)) ==0 ); + +/* Calculate the tile width for the bpp. */ + t4k_t_w =VC4_T_TILE_W (4096 , t4k_t_h, bpp); + t1k_t_w =VC4_T_TILE_W (1024 , t1k_t_h, bpp); + t64_t_w =VC4_T_TILE_W (64 , t64_t_h, bpp); + +/* Aligned total width in number of 4K tiles. */ + t4k_w = (stride / (bpp /8 )) / t4k_t_w; + +/* X and y coordinates in number of 4K tiles. */ + t4k_x = x / t4k_t_w; + t4k_y = y / t4k_t_h; + +/* Increase offset to the beginning of the 4K tile row. */ + offset += t4k_y * t4k_w *4096 ; + +/* X and Y coordinates in number of 1K tiles within the 4K tile. */ + t1k_x = (x % t4k_t_w) / t1k_t_w; + t1k_y = (y % t4k_t_h) / t1k_t_h; + +/* Index for 1K tile map lookup. */ + index =2 * t1k_y + t1k_x; + +/* Odd rows start from the right, even rows from the left. */ +if (t4k_y %2 ) { +/* Increase offset to the 4K tile (starting from the right). */ + offset += (t4k_w - t4k_x -1 ) *4096 ; + +/* Incrase offset to the beginning of the (odd) 1K tile. */ + offset += t1k_map_odd[index] *1024 ; + }else { +/* Increase offset to the 4K tile (starting from the left). */ + offset += t4k_x *4096 ; + +/* Incrase offset to the beginning of the (even) 1K tile. */ + offset += t1k_map_even[index] *1024 ; + } + +/* X and Y coordinates in number of 64 byte tiles within the 1K tile. */ + t64_x = (x % t1k_t_w) / t64_t_w; + t64_y = (y % t1k_t_h) / t64_t_h; + +/* Increase offset to the beginning of the 64-byte tile. */ + offset += (t64_y * (t1k_t_w / t64_t_w) + t64_x) *64 ; + +/* X and Y coordinates in number of pixels within the 64-byte tile. */ + pix_x = x % t64_t_w; + pix_y = y % t64_t_h; + +/* Increase offset to the correct pixel. */ + offset += (pix_y * t64_t_w + pix_x) * bpp /8 ; + +return offset; +}
lib/igt_vc4.h +4 -0
@@ -33,4 +33,8 @@ bool igt_vc4_purgeable_bo(int fd, int handle, bool purgeable);void igt_vc4_set_tiling (int fd,uint32_t handle,uint64_t modifier);uint64_t igt_vc4_get_tiling (int fd,uint32_t handle); +unsigned int igt_vc4_fb_t_tiled_convert (struct igt_fb *dst,struct igt_fb *src); +size_t igt_vc4_t_tiled_offset (size_t stride,size_t height,size_t bpp, +size_t x,size_t y); +#endif /* IGT_VC4_H */
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t v4 09/21] lib/igt_vc4: Add helpers for converting linear to T-tiled RGB buffers
Quoted 10 lines · Paul Kocialkowski
In order to integrate testing of T-tiled buffers, the easiest path is to generate patterns (with the already-existing functions) in linear buffers and convert them to T-tiled subsequently.
Add helpers to do that conversion, with a first helper that returns the memory offset for a given position in a T-tiled buffer and a second helper that uses it for converting between framebuffers.
Signed-off-by Paul Kocialkowski <[email protected]>Acked-by Lyude Paul <[email protected]>
Maxime
Signature · 3 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 10/21 lib/igt_vc4: Add helpers for converting linear to SAND-tiled buffers
In reply to Paul KocialkowskiIn order to test buffers with SAND tiling, it is useful to convert linear buffers to SAND tiling mode.
Introduce helpers to assist in that direction, one that calculates the memory offset in the SAND-tiled buffer for a given pixel position and one that makes use of the latter for framebuffer conversion.
--- lib/igt_vc4.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_vc4.h | 4 ++ 2 files changed, 112 insertions(+)
lib/igt_vc4.c +108 -0
@@ -307,3 +307,111 @@ size_t igt_vc4_t_tiled_offset(size_t stride, size_t height, size_t bpp,return offset; } + +static void vc4_fb_sand_tiled_convert_plane (struct igt_fb *dst,void *dst_buf, +struct igt_fb *src,void *src_buf, +size_t column_width_bytes, +size_t column_height, +unsigned int plane) +{ +size_t bpp = dst->plane_bpp[plane]; +size_t column_width = column_width_bytes * dst->plane_width[plane] / + dst->width; +size_t column_size = column_width_bytes * column_height; +unsigned int i, j; + +for (i =0 ; i < dst->plane_height[plane]; i++) { +for (j =0 ; j < src->plane_width[plane]; j++) { +size_t src_offset = src->offsets[plane]; +size_t dst_offset = dst->offsets[plane]; + + src_offset += src->strides[plane] * i + j * bpp /8 ; + dst_offset +=vc4_sand_tiled_offset (column_width, + column_size, j, i, + bpp); + +switch (bpp) { +case 8 : + *(uint8_t *)(dst_buf + dst_offset) = + *(uint8_t *)(src_buf + src_offset); +break ; +case 16 : + *(uint16_t *)(dst_buf + dst_offset) = + *(uint16_t *)(src_buf + src_offset); +break ; +default : +igt_assert (false); + } + } + } +} + +unsigned int vc4_fb_sand_tiled_convert (struct igt_fb *dst,struct igt_fb *src, +uint64_t modifier) +{ +uint64_t modifier_base; +size_t column_width_bytes; +size_t column_height; +unsigned int fb_id; +unsigned int i; +void *src_buf; +void *dst_buf; + + modifier_base =fourcc_mod_broadcom_mod (modifier); + column_height =fourcc_mod_broadcom_param (modifier); + +switch (modifier_base) { +case DRM_FORMAT_MOD_BROADCOM_SAND32 : + column_width_bytes =32 ; +break ; +case DRM_FORMAT_MOD_BROADCOM_SAND64 : + column_width_bytes =64 ; +break ; +case DRM_FORMAT_MOD_BROADCOM_SAND128 : + column_width_bytes =128 ; +break ; +case DRM_FORMAT_MOD_BROADCOM_SAND256 : + column_width_bytes =256 ; +break ; +default : +igt_assert (false); + } + + fb_id =igt_create_fb (src->fd, src->width, src->height, src->drm_format, + modifier, dst); +igt_assert (fb_id >0 ); + + src_buf =igt_fb_map_buffer (src->fd, src); +igt_assert (src_buf); + + dst_buf =igt_fb_map_buffer (dst->fd, dst); +igt_assert (dst_buf); + +for (i =0 ; i < dst->num_planes; i++) +vc4_fb_sand_tiled_convert_plane (dst, dst_buf, src, src_buf, + column_width_bytes, + column_height, i); + +igt_fb_unmap_buffer (src, src_buf); +igt_fb_unmap_buffer (dst, dst_buf); + +return fb_id; +} + +size_t vc4_sand_tiled_offset (size_t column_width,size_t column_size,size_t x, +size_t y,size_t bpp) +{ +size_t offset =0 ; +size_t cols_x; +size_t pix_x; + +/* Offset to the beginning of the relevant column. */ + cols_x = x / column_width; + offset += cols_x * column_size; + +/* Offset to the relevant pixel. */ + pix_x = x % column_width; + offset += (column_width * y + pix_x) * bpp /8 ; + +return offset; +}
lib/igt_vc4.h +4 -0
@@ -36,5 +36,9 @@ uint64_t igt_vc4_get_tiling(int fd, uint32_t handle);unsigned int igt_vc4_fb_t_tiled_convert (struct igt_fb *dst,struct igt_fb *src);size_t igt_vc4_t_tiled_offset (size_t stride,size_t height,size_t bpp,size_t x,size_t y); +unsigned int vc4_fb_sand_tiled_convert (struct igt_fb *dst,struct igt_fb *src, +uint64_t modifier); +size_t vc4_sand_tiled_offset (size_t column_width,size_t column_size,size_t x, +size_t y,size_t bpp);#endif /* IGT_VC4_H */
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t v4 10/21] lib/igt_vc4: Add helpers for converting linear to SAND-tiled buffers
Quoted 9 lines · Paul Kocialkowski
In order to test buffers with SAND tiling, it is useful to convert linear buffers to SAND tiling mode.
Introduce helpers to assist in that direction, one that calculates the memory offset in the SAND-tiled buffer for a given pixel position and one that makes use of the latter for framebuffer conversion.
Signed-off-by Paul Kocialkowski <[email protected]>Acked-by Lyude Paul <[email protected]>
Maxime
Signature · 3 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 11/21 lib/igt_fb: Pass the modifier to igt_fb_convert helpers
In reply to Paul KocialkowskiThe modifier is part of how a frame is represented, so add it as an extra argument so that it can be specified when converting framebuffers.
For now, only a linear modifier is supported.
--- lib/igt_fb.c | 14 ++++++++++---- lib/igt_fb.h | 3 ++- tests/kms_chamelium.c | 3 ++- 3 files changed, 14 insertions(+), 6 deletions(-)
lib/igt_fb.c +10 -4
@@ -2254,6 +2254,7 @@ void igt_remove_fb(int fd, struct igt_fb *fb)* @dst: pointer to the #igt_fb structure that will store the conversion result * @src: pointer to the #igt_fb structure that stores the frame we convert * @dst_fourcc: DRM format specifier to convert to +* @dst_modifier: DRM format modifier to convert to * @dst_stride: Stride for the resulting framebuffer (0 for automatic stride) * * This will convert a given @src content to the @dst_fourcc format,
@@ -2268,6 +2269,7 @@ void igt_remove_fb(int fd, struct igt_fb *fb)*/ unsigned int igt_fb_convert_with_stride (struct igt_fb *dst,struct igt_fb *src,uint32_t dst_fourcc, +uint64_t dst_modifier,unsigned int dst_stride) {struct fb_convert cvt = { };
@@ -2276,8 +2278,8 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src, fb_id =igt_create_fb_with_bo_size (src->fd, src->width, src->height, dst_fourcc, -LOCAL_DRM_FORMAT_MOD_NONE , - dst,0 , dst_stride); +LOCAL_DRM_FORMAT_MOD_NONE , dst,0 , + dst_stride);igt_assert (fb_id >0 ); src_ptr =igt_fb_map_buffer (src->fd, src);
@@ -2295,6 +2297,8 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,igt_fb_unmap_buffer (dst, dst_ptr);igt_fb_unmap_buffer (src, src_ptr); +igt_assert (dst_modifier ==LOCAL_DRM_FORMAT_MOD_NONE ); +return fb_id; }
@@ -2303,6 +2307,7 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,* @dst: pointer to the #igt_fb structure that will store the conversion result * @src: pointer to the #igt_fb structure that stores the frame we convert * @dst_fourcc: DRM format specifier to convert to +* @dst_modifier: DRM format modifier to convert to * * This will convert a given @src content to the @dst_fourcc format, * storing the result in the @dst fb, allocating the @dst fb
@@ -2315,9 +2320,10 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,* The kms id of the created framebuffer. */ unsigned int igt_fb_convert (struct igt_fb *dst,struct igt_fb *src, -uint32_t dst_fourcc) +uint32_t dst_fourcc,uint64_t dst_modifier) { -return igt_fb_convert_with_stride (dst, src, dst_fourcc,0 ); +return igt_fb_convert_with_stride (dst, src, dst_fourcc, dst_modifier, +0 ); }/**
lib/igt_fb.h +2 -1
@@ -132,9 +132,10 @@ unsigned int igt_create_stereo_fb(int drm_fd, drmModeModeInfo *mode, uint32_t format, uint64_t tiling);unsigned int igt_fb_convert_with_stride (struct igt_fb *dst,struct igt_fb *src,uint32_t dst_fourcc, +uint64_t dst_modifier,unsigned int stride);unsigned int igt_fb_convert (struct igt_fb *dst,struct igt_fb *src, -uint32_t dst_fourcc); +uint32_t dst_fourcc,uint64_t dst_modifier);void igt_remove_fb (int fd,struct igt_fb *fb);int igt_dirty_fb (int fd,struct igt_fb *fb);void *igt_fb_map_buffer (int fd,struct igt_fb *fb);
tests/kms_chamelium.c +2 -1
@@ -546,7 +546,8 @@ static void do_test_display(data_t *data, struct chamelium_port *port, DRM_FORMAT_XRGB8888, 64, &fb);igt_assert (fb_id >0 ); - frame_id =igt_fb_convert (&frame_fb, &fb, fourcc); + frame_id =igt_fb_convert (&frame_fb, &fb, fourcc, +LOCAL_DRM_FORMAT_MOD_NONE );igt_assert (frame_id >0 );if (check ==CHAMELIUM_CHECK_CRC )
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t v4 11/21] lib/igt_fb: Pass the modifier to igt_fb_convert helpers
Quoted 6 lines · Paul Kocialkowski
The modifier is part of how a frame is represented, so add it as an extra argument so that it can be specified when converting framebuffers.
For now, only a linear modifier is supported.
Signed-off-by Paul Kocialkowski <[email protected]>
Maxime
Signature · 3 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Lyude Paul
Reviewed-byRe: [igt-dev] [PATCH i-g-t v4 11/21] lib/igt_fb: Pass the modifier to igt_fb_convert helpers
Quoted 12 lines · Maxime Ripard
Quoted 6 lines · Paul Kocialkowski
The modifier is part of how a frame is represented, so add it as an extra argument so that it can be specified when converting framebuffers.
For now, only a linear modifier is supported.
Signed-off-by Paul Kocialkowski <[email protected]>Reviewed-by Maxime Ripard <[email protected]>Maxime
Signature · 7 lines
Cheers, Lyude Paul _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 12/21 lib/igt_fb: Support converting to VC4 modifiers in igt_fb_convert
In reply to Paul KocialkowskiThis pipes-in support for the VC4 modifiers that we have conversion helpers for. A new temporary linear framebuffer is introduced, that is either freed later or copied to the destination framebuffer pointer.
--- lib/igt_fb.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-)
lib/igt_fb.c +31 -5
@@ -2273,23 +2273,30 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src, unsigned int dst_stride) {struct fb_convert cvt = { }; +struct igt_fb linear;void *dst_ptr, *src_ptr; +uint64_t base_modifier;int fb_id; +if (is_vc4_device (src->fd)) + base_modifier =fourcc_mod_broadcom_mod (dst_modifier); +else + base_modifier = dst_modifier; + fb_id =igt_create_fb_with_bo_size (src->fd, src->width, src->height, dst_fourcc, -LOCAL_DRM_FORMAT_MOD_NONE , dst,0 , - dst_stride); +LOCAL_DRM_FORMAT_MOD_NONE , &linear, +0 , dst_stride);igt_assert (fb_id >0 ); src_ptr =igt_fb_map_buffer (src->fd, src);igt_assert (src_ptr); - dst_ptr =igt_fb_map_buffer (dst->fd, dst); + dst_ptr =igt_fb_map_buffer (linear.fd, &linear);igt_assert (dst_ptr); cvt.dst.ptr = dst_ptr; - cvt.dst.fb = dst; + cvt.dst.fb = &linear; cvt.src.ptr = src_ptr; cvt.src.fb = src;fb_convert (&cvt);
@@ -2297,7 +2304,26 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,igt_fb_unmap_buffer (dst, dst_ptr);igt_fb_unmap_buffer (src, src_ptr); -igt_assert (dst_modifier ==LOCAL_DRM_FORMAT_MOD_NONE ); +switch (base_modifier) { +case DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED : + fb_id =igt_vc4_fb_t_tiled_convert (dst, &linear); +break ; +case DRM_FORMAT_MOD_BROADCOM_SAND32 : +case DRM_FORMAT_MOD_BROADCOM_SAND64 : +case DRM_FORMAT_MOD_BROADCOM_SAND128 : +case DRM_FORMAT_MOD_BROADCOM_SAND256 : + fb_id =vc4_fb_sand_tiled_convert (dst, &linear, dst_modifier); +break ; +default : +igt_assert (dst_modifier ==LOCAL_DRM_FORMAT_MOD_NONE ); + } + +igt_assert (fb_id >0 ); + +if (dst_modifier ==LOCAL_DRM_FORMAT_MOD_NONE ) + *dst = linear; +else +igt_remove_fb (linear.fd, &linear);return fb_id; }
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t v4 12/21] lib/igt_fb: Support converting to VC4 modifiers in igt_fb_convert
Quoted 6 lines · Paul Kocialkowski
This pipes-in support for the VC4 modifiers that we have conversion helpers for. A new temporary linear framebuffer is introduced, that is either freed later or copied to the destination framebuffer pointer.
Signed-off-by Paul Kocialkowski <[email protected]>
Maxime
Signature · 3 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t v4 12/21] lib/igt_fb: Support converting to VC4 modifiers in igt_fb_convert
In reply to Paul KocialkowskiQuoted 79 lines · Paul Kocialkowski
This pipes-in support for the VC4 modifiers that we have conversion helpers for. A new temporary linear framebuffer is introduced, that is either freed later or copied to the destination framebuffer pointer.
Signed-off-by Paul Kocialkowski <[email protected]>--- lib/igt_fb.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-)lib/igt_fb.c +11
-4@@ -2273,23 +2273,30 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src, unsigned int dst_stride) { struct fb_convert cvt = { }; +struct igt_fb linear;void *dst_ptr, *src_ptr; +uint64_t base_modifier;int fb_id; +if (is_vc4_device (src->fd)) + base_modifier =fourcc_mod_broadcom_mod (dst_modifier); +else + base_modifier = dst_modifier; + fb_id =igt_create_fb_with_bo_size (src->fd, src->width, src->height, dst_fourcc, -LOCAL_DRM_FORMAT_MOD_NONE , dst,0 , - dst_stride); +LOCAL_DRM_FORMAT_MOD_NONE , &linear, +0 , dst_stride);igt_assert (fb_id >0 ); src_ptr =igt_fb_map_buffer (src->fd, src);igt_assert (src_ptr); - dst_ptr =igt_fb_map_buffer (dst->fd, dst); + dst_ptr =igt_fb_map_buffer (linear.fd, &linear);igt_assert (dst_ptr); cvt.dst.ptr = dst_ptr; - cvt.dst.fb = dst; + cvt.dst.fb = &linear; cvt.src.ptr = src_ptr; cvt.src.fb = src;lib/igt_fb.c +20
-1fb_convert (&cvt);@@ -2297,7 +2304,26 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,igt_fb_unmap_buffer (dst, dst_ptr);igt_fb_unmap_buffer (src, src_ptr); -igt_assert (dst_modifier ==LOCAL_DRM_FORMAT_MOD_NONE ); +switch (base_modifier) { +case DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED : + fb_id =igt_vc4_fb_t_tiled_convert (dst, &linear); +break ; +case DRM_FORMAT_MOD_BROADCOM_SAND32 : +case DRM_FORMAT_MOD_BROADCOM_SAND64 : +case DRM_FORMAT_MOD_BROADCOM_SAND128 : +case DRM_FORMAT_MOD_BROADCOM_SAND256 : + fb_id =vc4_fb_sand_tiled_convert (dst, &linear, dst_modifier); +break ; +default : +igt_assert (dst_modifier ==LOCAL_DRM_FORMAT_MOD_NONE ); + } + +igt_assert (fb_id >0 ); + +if (dst_modifier ==LOCAL_DRM_FORMAT_MOD_NONE ) + *dst = linear; +else +igt_remove_fb (linear.fd, &linear);return fb_id;}
Signature · 7 lines
Cheers, Lyude Paul _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 13/21 lib/igt_kms: Add helpers to count and iterate planes from pipe
In reply to Paul KocialkowskiThis introduces helpers that allow counting how many planes of a given type are present from a pipe and getting the n-th plane of a given type.
--- lib/igt_kms.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_kms.h | 3 +++ 2 files changed, 51 insertions(+)
lib/igt_kms.c +48 -0
@@ -2277,6 +2277,54 @@ igt_plane_t *igt_pipe_get_plane_type(igt_pipe_t *pipe, int plane_type)return &pipe->planes[plane_idx]; } +/** +* igt_pipe_count_plane_type: +* @pipe: Target pipe +* @plane_type: Cursor, primary or an overlay plane +* +* Counts the number of planes of type @plane_type for the provided @pipe. +* +* Returns: The number of planes that match the requested plane type +*/ +int igt_pipe_count_plane_type (igt_pipe_t *pipe,int plane_type) +{ +int i, count =0 ; + +for (i =0 ; i < pipe->n_planes; i++) +if (pipe->planes[i].type == plane_type) + count++; + +return count; +} + +/** +* igt_pipe_get_plane_type_index: +* @pipe: Target pipe +* @plane_type: Cursor, primary or an overlay plane +* @index: the index of the plane among planes of the same type +* +* Get the @index th plane of type @plane_type for the provided @pipe. +* +* Returns: The @index th plane that matches the requested plane type +*/ +igt_plane_t *igt_pipe_get_plane_type_index (igt_pipe_t *pipe,int plane_type, +int index) +{ +int i, type_index =0 ; + +for (i =0 ; i < pipe->n_planes; i++) { +if (pipe->planes[i].type != plane_type) +continue ; + +if (type_index == index) +return &pipe->planes[i]; + + type_index++; + } + +return NULL ; +} +static bool output_is_internal_panel (igt_output_t *output) {switch (output->config.connector->connector_type) {
lib/igt_kms.h +3 -0
@@ -405,6 +405,9 @@ igt_output_t *igt_output_from_connector(igt_display_t *display, drmModeConnector *connector);igt_plane_t *igt_pipe_get_plane_type (igt_pipe_t *pipe,int plane_type); +int igt_pipe_count_plane_type (igt_pipe_t *pipe,int plane_type); +igt_plane_t *igt_pipe_get_plane_type_index (igt_pipe_t *pipe,int plane_type, +int index);igt_output_t *igt_get_single_output_for_pipe (igt_display_t *display,enum pipe pipe);void igt_pipe_request_out_fence (igt_pipe_t *pipe);
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 14/21 lib/igt_kms: Add helpers to count and iterate planes from output
In reply to Paul KocialkowskiWith helpers to count and iterate among planes of a given type from the pipe in place, we can use them with the current pipe for the output to make it possible for tests to use them (the pipe struct is not currently easily exposed to tests and exposing it adds unnecessary complexity).
--- lib/igt_kms.c | 36 ++++++++++++++++++++++++++++++++++++ lib/igt_kms.h | 3 +++ 2 files changed, 39 insertions(+)
lib/igt_kms.c +36 -0
@@ -3719,6 +3719,42 @@ igt_plane_t *igt_output_get_plane_type(igt_output_t *output, int plane_type)return igt_pipe_get_plane_type (pipe, plane_type); } +/** +* igt_output_count_plane_type: +* @output: Target output +* @plane_type: Cursor, primary or an overlay plane +* +* Counts the number of planes of type @plane_type for the provided @output. +* +* Returns: The number of planes that match the requested plane type +*/ +int igt_output_count_plane_type (igt_output_t *output,int plane_type) +{ +igt_pipe_t *pipe =igt_output_get_driving_pipe (output); +igt_assert (pipe); + +return igt_pipe_count_plane_type (pipe, plane_type); +} + +/** +* igt_output_get_plane_type_index: +* @output: Target output +* @plane_type: Cursor, primary or an overlay plane +* @index: the index of the plane among planes of the same type +* +* Get the @index th plane of type @plane_type for the provided @output. +* +* Returns: The @index th plane that matches the requested plane type +*/ +igt_plane_t *igt_output_get_plane_type_index (igt_output_t *output, +int plane_type,int index) +{ +igt_pipe_t *pipe =igt_output_get_driving_pipe (output); +igt_assert (pipe); + +return igt_pipe_get_plane_type_index (pipe, plane_type, index); +} +/** * igt_plane_set_fb: * @plane: Plane
lib/igt_kms.h +3 -0
@@ -401,6 +401,9 @@ void igt_output_override_mode(igt_output_t *output, drmModeModeInfo *mode);void igt_output_set_pipe (igt_output_t *output,enum pipe pipe);igt_plane_t *igt_output_get_plane (igt_output_t *output,int plane_idx);igt_plane_t *igt_output_get_plane_type (igt_output_t *output,int plane_type); +int igt_output_count_plane_type (igt_output_t *output,int plane_type); +igt_plane_t *igt_output_get_plane_type_index (igt_output_t *output, +int plane_type,int index);igt_output_t *igt_output_from_connector (igt_display_t *display,drmModeConnector *connector);
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 15/21 lib/igt_chamelium: Fixup resources liberation in comparison helpers
In reply to Paul KocialkowskiThis fixes a bunch of occurrences of memory not being properly liberated after its use in helpers revolving around frame/CRC comparison.
--- lib/igt_chamelium.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
lib/igt_chamelium.c +9 -4
@@ -1060,9 +1060,9 @@ void chamelium_assert_crc_eq_or_dump(struct chamelium *chamelium,free (reference_suffix);free (capture_suffix); -chamelium_destroy_frame_dump (frame); - +cairo_surface_destroy (reference);cairo_surface_destroy (capture); +chamelium_destroy_frame_dump (frame); }igt_assert (eq);
@@ -1120,11 +1120,14 @@ void chamelium_assert_analog_frame_match_or_dump(struct chamelium *chamelium,free (reference_suffix);free (capture_suffix); +free (reference_crc); +free (capture_crc); } -cairo_surface_destroy (capture); -igt_assert (match); + +cairo_surface_destroy (reference); +cairo_surface_destroy (capture); }
@@ -1323,6 +1326,8 @@ igt_crc_t *chamelium_calculate_fb_crc(int fd, struct igt_fb *fb)chamelium_do_calculate_fb_crc (fb_surface, ret); +cairo_surface_destroy (fb_surface); +return ret; }
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 16/21 lib/igt_chamelium: Split frames dump logic and rework surroundings
In reply to Paul KocialkowskiThe frame dump logic is the same for all comparison helpers, so split it to a dedicated function and adapt helpers using it to avoid duplicating operations.
--- lib/igt_chamelium.c | 87 +++++++++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 35 deletions(-)
lib/igt_chamelium.c +52 -35
@@ -124,6 +124,9 @@ struct chamelium {static struct chamelium *cleanup_instance; +static void chamelium_do_calculate_fb_crc (cairo_surface_t *fb_surface, +igt_crc_t *out); +/** * chamelium_get_ports: * @chamelium: The Chamelium instance to use
@@ -967,6 +970,39 @@ static cairo_surface_t *convert_frame_dump_argb32(const struct chamelium_frame_dreturn dump_surface; } +static void compared_frames_dump (cairo_surface_t *reference, +cairo_surface_t *capture, +igt_crc_t *reference_crc, +igt_crc_t *capture_crc) +{ +char *reference_suffix; +char *capture_suffix; +igt_crc_t local_reference_crc; +igt_crc_t local_capture_crc; + +igt_assert (reference && capture); + +if (!reference_crc) { +chamelium_do_calculate_fb_crc (reference, &local_reference_crc); + reference_crc = &local_reference_crc; + } + +if (!capture_crc) { +chamelium_do_calculate_fb_crc (reference, &local_capture_crc); + capture_crc = &local_capture_crc; + } + + reference_suffix =igt_crc_to_string_extended (reference_crc,'-' ,2 ); + capture_suffix =igt_crc_to_string_extended (capture_crc,'-' ,2 ); + +/* Write reference and capture frames to png. */ +igt_write_compared_frames_to_png (reference, capture, reference_suffix, + capture_suffix); + +free (reference_suffix); +free (capture_suffix); +} +/** * chamelium_assert_frame_eq: * @chamelium: The chamelium instance the frame dump belongs to
@@ -1029,8 +1065,6 @@ void chamelium_assert_crc_eq_or_dump(struct chamelium *chamelium,struct chamelium_frame_dump *frame;cairo_surface_t *reference;cairo_surface_t *capture; -char *reference_suffix; -char *capture_suffix;bool eq;igt_debug ("Reference CRC: %s\n" ,igt_crc_to_string (reference_crc));
@@ -1038,27 +1072,19 @@ void chamelium_assert_crc_eq_or_dump(struct chamelium *chamelium, eq =igt_check_crc_equal (reference_crc, capture_crc);if (!eq &&igt_frame_dump_is_enabled ()) { -/* Grab the reference frame from framebuffer */ +/* Convert the reference framebuffer to cairo. */ reference =igt_get_cairo_surface (chamelium->drm_fd, fb); -/* Grab the captured frame from chamelium */ +/* Grab the captured frame from the Chamelium. */ frame =chamelium_read_captured_frame (chamelium, index);igt_assert (frame); +/* Convert the captured frame to cairo. */ capture =convert_frame_dump_argb32 (frame); +igt_assert (capture); - reference_suffix =igt_crc_to_string_extended (reference_crc, -'-' ,2 ); - capture_suffix =igt_crc_to_string_extended (capture_crc,'-' , -2 ); - -/* Write reference and capture frames to png */ -igt_write_compared_frames_to_png (reference, capture, - reference_suffix, - capture_suffix); - -free (reference_suffix); -free (capture_suffix); +compared_frames_dump (reference, capture, reference_crc, + capture_crc);cairo_surface_destroy (reference);cairo_surface_destroy (capture);
@@ -1087,8 +1113,6 @@ void chamelium_assert_analog_frame_match_or_dump(struct chamelium *chamelium,cairo_surface_t *capture;igt_crc_t *reference_crc;igt_crc_t *capture_crc; -char *reference_suffix; -char *capture_suffix;bool match;/* Grab the reference frame from framebuffer */
@@ -1099,27 +1123,20 @@ void chamelium_assert_analog_frame_match_or_dump(struct chamelium *chamelium, match =igt_check_analog_frame_match (reference, capture);if (!match &&igt_frame_dump_is_enabled ()) { - reference_crc =chamelium_calculate_fb_crc (chamelium->drm_fd, - fb); - capture_crc =chamelium_get_crc_for_area (chamelium, port,0 ,0 , -0 ,0 ); + reference_crc =malloc (sizeof (igt_crc_t)); +igt_assert (reference_crc); -igt_debug ("Reference CRC: %s\n" , -igt_crc_to_string (reference_crc)); -igt_debug ("Captured CRC: %s\n" ,igt_crc_to_string (capture_crc)); +/* Calculate the reference frame CRC. */ +chamelium_do_calculate_fb_crc (reference, reference_crc); - reference_suffix =igt_crc_to_string_extended (reference_crc, -'-' ,2 ); - capture_suffix =igt_crc_to_string_extended (capture_crc,'-' , -2 ); +/* Get the captured frame CRC from the Chamelium. */ + capture_crc =chamelium_get_crc_for_area (chamelium, port,0 ,0 , +0 ,0 ); +igt_assert (capture_crc); -/* Write reference and capture frames to png */ -igt_write_compared_frames_to_png (reference, capture, - reference_suffix, - capture_suffix); +compared_frames_dump (reference, capture, reference_crc, + capture_crc); -free (reference_suffix); -free (capture_suffix);free (reference_crc);free (capture_crc); }
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 17/21 lib/igt_chamelium: Generalize the frame match helper with check type
In reply to Paul KocialkowskiIn prevision of adding support for another type of frame matching, rename chamelium_assert_analog_frame_match_or_dump to drop the analog part and feed it the check type. This way, the bulk of the helper can apply to other frame matching types.
This requires moving the chamelium_check enum from the test to the common chamelium header.
--- lib/igt_chamelium.c | 21 +++++++++++++++------ lib/igt_chamelium.h | 21 +++++++++++++++++---- tests/kms_chamelium.c | 9 ++------- 3 files changed, 34 insertions(+), 17 deletions(-)
lib/igt_chamelium.c +15 -6
@@ -1095,19 +1095,21 @@ void chamelium_assert_crc_eq_or_dump(struct chamelium *chamelium, }/** -* chamelium_assert_analog_frame_match_or_dump: +* chamelium_assert_frame_match_or_dump: * @chamelium: The chamelium instance the frame dump belongs to * @frame: The chamelium frame dump to match * @fb: pointer to an #igt_fb structure +* @check: the type of frame matching check to use * * Asserts that the provided captured frame matches the reference frame from * the framebuffer. If they do not, this saves the reference and captured frames * to a png file. */ -void chamelium_assert_analog_frame_match_or_dump (struct chamelium *chamelium, -struct chamelium_port *port, -const struct chamelium_frame_dump *frame, -struct igt_fb *fb) +void chamelium_assert_frame_match_or_dump (struct chamelium *chamelium, +struct chamelium_port *port, +const struct chamelium_frame_dump *frame, +struct igt_fb *fb, +enum chamelium_check check) {cairo_surface_t *reference;cairo_surface_t *capture;
@@ -1121,7 +1123,14 @@ void chamelium_assert_analog_frame_match_or_dump(struct chamelium *chamelium,/* Grab the captured frame from chamelium */ capture =convert_frame_dump_argb32 (frame); - match =igt_check_analog_frame_match (reference, capture); +switch (check) { +case CHAMELIUM_CHECK_ANALOG : + match =igt_check_analog_frame_match (reference, capture); +break ; +default : +igt_assert (false); + } +if (!match &&igt_frame_dump_is_enabled ()) { reference_crc =malloc (sizeof (igt_crc_t));igt_assert (reference_crc);
lib/igt_chamelium.h +17 -4
@@ -40,6 +40,18 @@ struct chamelium_port;struct chamelium_frame_dump ;struct chamelium_fb_crc_async_data ; +/** +* chamelium_check: +* @CHAMELIUM_CHECK_ANALOG: Fuzzy checking method for analog interfaces +* @CHAMELIUM_CHECK_CRC: CRC-based checking method for pixel-perfect interfaces +* +* Checking method for comparing between reference and captured frames. +*/ +enum chamelium_check { +CHAMELIUM_CHECK_ANALOG , +CHAMELIUM_CHECK_CRC , +}; +struct chamelium *chamelium_init (int drm_fd);void chamelium_deinit (struct chamelium *chamelium);void chamelium_reset (struct chamelium *chamelium);
@@ -110,10 +122,11 @@ void chamelium_assert_crc_eq_or_dump(struct chamelium *chamelium, igt_crc_t *reference_crc, igt_crc_t *capture_crc, struct igt_fb *fb, int index); -void chamelium_assert_analog_frame_match_or_dump (struct chamelium *chamelium, -struct chamelium_port *port, -const struct chamelium_frame_dump *frame, -struct igt_fb *fb); +void chamelium_assert_frame_match_or_dump (struct chamelium *chamelium, +struct chamelium_port *port, +const struct chamelium_frame_dump *frame, +struct igt_fb *fb, +enum chamelium_check check);void chamelium_crop_analog_frame (struct chamelium_frame_dump *dump,int width,int height);void chamelium_destroy_frame_dump (struct chamelium_frame_dump *dump);
tests/kms_chamelium.c +2 -7
@@ -527,11 +527,6 @@ static int chamelium_get_pattern_fb(data_t *data, size_t width, size_t height,return fb_id; } -enum chamelium_check { -CHAMELIUM_CHECK_ANALOG , -CHAMELIUM_CHECK_CRC , -}; - static void do_test_display(data_t *data, struct chamelium_port *port, igt_output_t *output, drmModeModeInfo *mode, uint32_t fourcc, enum chamelium_check check,
@@ -590,8 +585,8 @@ static void do_test_display(data_t *data, struct chamelium_port *port, 0, 0);chamelium_crop_analog_frame (dump, mode->hdisplay, mode->vdisplay); -chamelium_assert_analog_frame_match_or_dump (data->chamelium, - port, dump, &fb); +chamelium_assert_frame_match_or_dump (data->chamelium, port, + dump, &fb, check);chamelium_destroy_frame_dump (dump); }
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 18/21 lib/igt_frame: Add a checkerboard frame comparison method
In reply to Paul KocialkowskiThis introduces a new frame comparison method that was designed for patterns that follow a checkerboard style. These patterns are made of consecutive rectangular shapes with alternating solid colors. They are currently used for some Chamelium-based tests.
The method is particularly adapted for cases where the edges of the shapes might be blurred (e.g. due to scaling), which makes it impossible to use pixel-perfect or CRC-based comparisons to decide whether the captured frame matches the reference.
Overall, this test will first detect the edges of the pattern and later exclude them from comparison. Colors are compared between the reference and capture with a low threshold for error. A percentage of the faulty pixels is calculated and the captured frame is considered invalid if more than one percent of the pixels are erroneous.
--- lib/igt_frame.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_frame.h | 2 + 2 files changed, 137 insertions(+)
lib/igt_frame.c +135 -0
@@ -267,3 +267,138 @@ complete:return match; } + +#define XR24_COLOR_VALUE (data, stride, x, y, c) \ + *((uint8_t *)(data) + (y) * (stride) + 4 * (x) + (c)) + +/** +* igt_check_checkerboard_frame_match: +* @reference: The reference cairo surface +* @capture: The captured cairo surface +* +* Checks that the reference frame matches the captured frame using a +* method designed for checkerboard patterns. These patterns are made of +* consecutive rectangular shapes with alternating solid colors. +* +* The intent of this method is to cover cases where the captured result is +* not pixel-perfect due to features such as scaling or YUV conversion and +* subsampling. Such effects are mostly noticeable on the edges of the +* patterns, so they are detected and excluded from the comparison. +* +* The algorithm works with two major steps. First, the edges of the reference +* pattern are detected on the x and y axis independently. The detection is done +* by calculating an absolute difference with a span of a few pixels before and +* after the current position on the given axis, accumulated for each color +* component. If the sum is above a given threshold on one of the axis, the +* position is marked as an edge. In the second step, the pixel values are +* compared per-component, excluding positions that were marked as edges or +* that are at a transition between an edge and a non-edge. An error threshold +* (for each individual color component) is used to mark the position as +* erroneous or not. The ratio of erroneous pixels over compared pixels (that +* does not count excluded pixels) is then calculated and compared to the error +* rate threshold to determine whether the frames match or not. +* +* Returns: a boolean indicating whether the frames match +*/ +bool igt_check_checkerboard_frame_match (cairo_surface_t *reference, +cairo_surface_t *capture) +{ +unsigned int width, height, ref_stride, cap_stride; +void *ref_data, *cap_data; +unsigned char *edges_map; +unsigned int x, y, c; +unsigned int errors =0 , pixels =0 ; +unsigned int edge_threshold =100 ; +unsigned int color_error_threshold =24 ; +double error_rate_threshold =0.01 ; +double error_rate; +unsigned int span =2 ; +bool match = false; + + width =cairo_image_surface_get_width (reference); + height =cairo_image_surface_get_height (reference); + + ref_stride =cairo_image_surface_get_stride (reference); + ref_data =cairo_image_surface_get_data (reference); +igt_assert (ref_data); + + cap_stride =cairo_image_surface_get_stride (capture); + cap_data =cairo_image_surface_get_data (capture); +igt_assert (cap_data); + + edges_map =calloc (1 , width * height); +igt_assert (edges_map); + +/* First pass to detect the pattern edges. */ +for (y =0 ; y < height; y++) { +if (y < span || y > (height - span -1 )) +continue ; + +for (x =0 ; x < width; x++) { +unsigned int xdiff =0 , ydiff =0 ; + +if (x < span || x > (width - span -1 )) +continue ; + +for (c =0 ; c <3 ; c++) { + xdiff +=abs (XR24_COLOR_VALUE (ref_data, ref_stride, x + span, y, c) - +XR24_COLOR_VALUE (ref_data, ref_stride, x - span, y, c)); + ydiff +=abs (XR24_COLOR_VALUE (ref_data, ref_stride, x, y + span, c) - +XR24_COLOR_VALUE (ref_data, ref_stride, x, y - span, c)); + } + + edges_map[y * width + x] = (xdiff > edge_threshold || + ydiff > edge_threshold); + } + } + +/* Second pass to detect errors. */ +for (y =0 ; y < height; y++) { +for (x =0 ; x < width; x++) { +bool error = false; + +if (edges_map[y * width + x]) +continue ; + +for (c =0 ; c <3 ; c++) { +unsigned int diff; + +/* Compare the reference and capture values. */ + diff =abs (XR24_COLOR_VALUE (ref_data, ref_stride, x, y, c) - +XR24_COLOR_VALUE (cap_data, cap_stride, x, y, c)); + +if (diff > color_error_threshold) + error = true; + } + +/* Allow error if coming on or off an edge (on x). */ +if (error && x >= span && x <= (width - span -1 ) && + edges_map[y * width + (x - span)] != + edges_map[y * width + (x + span)]) +continue ; + +/* Allow error if coming on or off an edge (on y). */ +if (error && y >= span && y <= (height - span -1 ) && + edges_map[(y - span) * width + x] != + edges_map[(y + span) * width + x] && error) +continue ; + +if (error) + errors++; + + pixels++; + } + } + +free (edges_map); + + error_rate = (double ) errors / pixels; + +if (error_rate < error_rate_threshold) + match = true; + +igt_debug ("Checkerboard pattern %s with error rate %f %%\n" , + match ?"matched" :"not matched" , error_rate *100 ); + +return match; +}
lib/igt_frame.h +2 -0
@@ -38,5 +38,7 @@ void igt_write_compared_frames_to_png(cairo_surface_t *reference, const char *capture_suffix);bool igt_check_analog_frame_match (cairo_surface_t *reference,cairo_surface_t *capture); +bool igt_check_checkerboard_frame_match (cairo_surface_t *reference, +cairo_surface_t *capture);#endif
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t v4 18/21] lib/igt_frame: Add a checkerboard frame comparison method
Quoted 10 lines · Paul Kocialkowski
This introduces a new frame comparison method that was designed for patterns that follow a checkerboard style. These patterns are made of consecutive rectangular shapes with alternating solid colors. They are currently used for some Chamelium-based tests.
The method is particularly adapted for cases where the edges of the shapes might be blurred (e.g. due to scaling), which makes it impossible to use pixel-perfect or CRC-based comparisons to decide whether the captured frame matches the reference.
Quoted 8 lines
Overall, this test will first detect the edges of the pattern and later exclude them from comparison. Colors are compared between the reference and capture with a low threshold for error. A percentage of the faulty pixels is calculated and the captured frame is considered invalid if more than one percent of the pixels are erroneous.
Signed-off-by Paul Kocialkowski <[email protected]>Reviewed-by Lyude Paul <[email protected]>
Maxime
Signature · 3 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 19/21 lib/igt_chamelium: Hook-in checkerboard comparison method in helpers
In reply to Paul KocialkowskiThis introduces the checkerboard chamelium checking type and hooks the call to the associated igt_frame matching helper in the frame match chamelium helper.
--- lib/igt_chamelium.c | 4 +++- lib/igt_chamelium.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
lib/igt_chamelium.c +3 -1
@@ -1127,6 +1127,9 @@ void chamelium_assert_frame_match_or_dump(struct chamelium *chamelium,case CHAMELIUM_CHECK_ANALOG : match =igt_check_analog_frame_match (reference, capture);break ; +case CHAMELIUM_CHECK_CHECKERBOARD : + match =igt_check_checkerboard_frame_match (reference, capture); +break ;default :igt_assert (false); }
@@ -1156,7 +1159,6 @@ void chamelium_assert_frame_match_or_dump(struct chamelium *chamelium,cairo_surface_destroy (capture); } -/** * chamelium_analog_frame_crop: * @chamelium: The Chamelium instance to use
lib/igt_chamelium.h +1 -0
@@ -49,6 +49,7 @@ struct chamelium_fb_crc_async_data;*/ enum chamelium_check {CHAMELIUM_CHECK_ANALOG , +CHAMELIUM_CHECK_CHECKERBOARD ,CHAMELIUM_CHECK_CRC , };
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 20/21 chamelium: Move the YUV tests over to the checkerboard checking method
In reply to Paul KocialkowskiNow that the checkerboard frame checking method is available through the frame match helper, make use of it in YUV tests to increase the reliability of the results.
The analog test tends to provide false positives, which are properly detected by the checkerboard method in most instances.
--- tests/kms_chamelium.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
tests/kms_chamelium.c +15 -11
@@ -576,15 +576,19 @@ static void do_test_display(data_t *data, struct chamelium_port *port,free (expected_crc);free (crc); - }else if (check ==CHAMELIUM_CHECK_ANALOG ) { + }else if (check ==CHAMELIUM_CHECK_ANALOG || + check ==CHAMELIUM_CHECK_CHECKERBOARD ) {struct chamelium_frame_dump *dump;igt_assert (count ==1 ); dump =chamelium_port_dump_pixels (data->chamelium, port,0 ,0 ,0 ,0 ); -chamelium_crop_analog_frame (dump, mode->hdisplay, - mode->vdisplay); + +if (check ==CHAMELIUM_CHECK_ANALOG ) +chamelium_crop_analog_frame (dump, mode->hdisplay, + mode->vdisplay); +chamelium_assert_frame_match_or_dump (data->chamelium, port, dump, &fb, check);chamelium_destroy_frame_dump (dump);
@@ -975,35 +979,35 @@ igt_main connector_subtest("hdmi-cmp-nv12", HDMIA)test_display_one_mode (&data, port,DRM_FORMAT_NV12 , -CHAMELIUM_CHECK_ANALOG ,1 ); +CHAMELIUM_CHECK_CHECKERBOARD ,1 ); connector_subtest("hdmi-cmp-nv16", HDMIA)test_display_one_mode (&data, port,DRM_FORMAT_NV16 , -CHAMELIUM_CHECK_ANALOG ,1 ); +CHAMELIUM_CHECK_CHECKERBOARD ,1 ); connector_subtest("hdmi-cmp-nv21", HDMIA)test_display_one_mode (&data, port,DRM_FORMAT_NV21 , -CHAMELIUM_CHECK_ANALOG ,1 ); +CHAMELIUM_CHECK_CHECKERBOARD ,1 ); connector_subtest("hdmi-cmp-nv61", HDMIA)test_display_one_mode (&data, port,DRM_FORMAT_NV61 , -CHAMELIUM_CHECK_ANALOG ,1 ); +CHAMELIUM_CHECK_CHECKERBOARD ,1 ); connector_subtest("hdmi-cmp-yu12", HDMIA)test_display_one_mode (&data, port,DRM_FORMAT_YUV420 , -CHAMELIUM_CHECK_ANALOG ,1 ); +CHAMELIUM_CHECK_CHECKERBOARD ,1 ); connector_subtest("hdmi-cmp-yu16", HDMIA)test_display_one_mode (&data, port,DRM_FORMAT_YUV422 , -CHAMELIUM_CHECK_ANALOG ,1 ); +CHAMELIUM_CHECK_CHECKERBOARD ,1 ); connector_subtest("hdmi-cmp-yv12", HDMIA)test_display_one_mode (&data, port,DRM_FORMAT_YVU420 , -CHAMELIUM_CHECK_ANALOG ,1 ); +CHAMELIUM_CHECK_CHECKERBOARD ,1 ); connector_subtest("hdmi-cmp-yv16", HDMIA)test_display_one_mode (&data, port,DRM_FORMAT_YVU422 , -CHAMELIUM_CHECK_ANALOG ,1 ); +CHAMELIUM_CHECK_CHECKERBOARD ,1 ); connector_subtest("hdmi-frame-dump", HDMIA)test_display_frame_dump (&data, port);
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 21/21 chamelium: Add a display test for randomized planes
In reply to Paul KocialkowskiThis introduces a new test for the Chamelium, that sets up planes with randomized properties such as the format, dimensions, position, in-framebuffer offsets and stride. The Chamelium capture is checked against the reference generated by cairo with either a CRC or the checkerboard-specific comparison method.
This test also includes testing of the VC4-specific T-tiled and SAND-tiled modes, in all formats supported by the hardware.
Since this test does not share much with previous Chamelium display tests (especially regarding KMS configuration), most of the code is not shared with other tests.
This test can be derived with reproducible properties for regression testing in the future. For now, it serves as a fuzzing test
--- tests/kms_chamelium.c | 438 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 438 insertions(+)
tests/kms_chamelium.c +438 -0
@@ -26,6 +26,7 @@#include "config.h" #include "igt.h" +#include "igt_vc4.h" #include <fcntl.h> #include <string.h>
@@ -703,6 +704,435 @@ test_display_frame_dump(data_t *data, struct chamelium_port *port)drmModeFreeConnector (connector); } +static void select_tiled_modifier (igt_plane_t *plane,uint32_t width, +uint32_t height,uint32_t format, +uint64_t *modifier) +{ +if (igt_plane_has_format_mod (plane, format, +DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED )) { +igt_debug ("Selecting VC4 T-tiling\n" ); + + *modifier =DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED ; + }else if (igt_plane_has_format_mod (plane, format, +DRM_FORMAT_MOD_BROADCOM_SAND256 )) { +/* Randomize the column height to less than twice the minimum. */ +size_t column_height = (rand () % height) + height; + +igt_debug ("Selecting VC4 SAND256 tiling with column height %ld\n" , + column_height); + + *modifier =DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT (column_height); + }else { + *modifier =DRM_FORMAT_MOD_LINEAR ; + } +} + +static void randomize_plane_format_stride (igt_plane_t *plane, +uint32_t width,uint32_t height, +uint32_t *format,uint64_t *modifier, +size_t *stride,bool allow_yuv) +{ +size_t stride_min; +uint32_t *formats_array; +unsigned int formats_count; +unsigned int count =0 ; +unsigned int i; +bool tiled; +int index; + +igt_format_array_fill (&formats_array, &formats_count, allow_yuv); + +/* First pass to count the supported formats. */ +for (i =0 ; i < formats_count; i++) +if (igt_plane_has_format_mod (plane, formats_array[i], +DRM_FORMAT_MOD_LINEAR )) + count++; + +igt_assert (count >0 ); + + index =rand () % count; + +/* Second pass to get the index-th supported format. */ +for (i =0 ; i < formats_count; i++) { +if (!igt_plane_has_format_mod (plane, formats_array[i], +DRM_FORMAT_MOD_LINEAR )) +continue ; + +if (!index--) { + *format = formats_array[i]; +break ; + } + } + +free (formats_array); + +igt_assert (index <0 ); + + stride_min = width *igt_format_plane_bpp (*format,0 ) /8 ; + +/* Randomize the stride to less than twice the minimum. */ + *stride = (rand () % stride_min) + stride_min; + +/* Pixman requires the stride to be aligned to 32-byte words. */ + *stride =ALIGN (*stride,sizeof (uint32_t )); + +/* Randomize the use of a tiled mode with a 1/4 probability. */ + tiled = ((rand () %4 ) ==0 ); + +if (tiled) +select_tiled_modifier (plane, width, height, *format, modifier); +else + *modifier =DRM_FORMAT_MOD_LINEAR ; +} + +static void randomize_plane_dimensions (drmModeModeInfo *mode, +uint32_t *width,uint32_t *height, +uint32_t *src_w,uint32_t *src_h, +uint32_t *src_x,uint32_t *src_y, +uint32_t *crtc_w,uint32_t *crtc_h, +int32_t *crtc_x,int32_t *crtc_y, +bool allow_scaling) +{ +double ratio; + +/* Randomize width and height in the mode dimensions range. */ + *width = (rand () % mode->hdisplay) +1 ; + *height = (rand () % mode->vdisplay) +1 ; + +/* Randomize source offset in the first half of the original size. */ + *src_x =rand () % (*width /2 ); + *src_y =rand () % (*height /2 ); + +/* The source size only includes the active source area. */ + *src_w = *width - *src_x; + *src_h = *height - *src_y; + +if (allow_scaling) { + *crtc_w = (rand () % mode->hdisplay) +1 ; + *crtc_h = (rand () % mode->vdisplay) +1 ; + +/* +* Don't bother with scaling if dimensions are quite close in +* order to get non-scaling cases more frequently. Also limit +* scaling to 3x to avoid agressive filtering that makes +* comparison less reliable. +*/ + + ratio = ((double ) *crtc_w / *src_w); +if (ratio >0.8 && ratio <1.2 ) + *crtc_w = *src_w; +else if (ratio >3.0 ) + *crtc_w = *src_w *3 ; + + ratio = ((double ) *crtc_h / *src_h); +if (ratio >0.8 && ratio <1.2 ) + *crtc_h = *src_h; +else if (ratio >3.0 ) + *crtc_h = *src_h *3 ; + }else { + *crtc_w = *src_w; + *crtc_h = *src_h; + } + +if (*crtc_w != *src_w || *crtc_h != *src_h) { +/* +* When scaling is involved, make sure to not go off-bounds or +* scaled clipping may result in decimal dimensions, that most +* drivers don't support. +*/ + *crtc_x =rand () % (mode->hdisplay - *crtc_w); + *crtc_y =rand () % (mode->vdisplay - *crtc_h); + }else { +/* +* Randomize the on-crtc position and allow the plane to go +* off-display by less than half of its on-crtc dimensions. +*/ + *crtc_x = (rand () % mode->hdisplay) - *crtc_w /2 ; + *crtc_y = (rand () % mode->vdisplay) - *crtc_h /2 ; + } +} + +static void blit_plane_cairo (data_t *data,cairo_surface_t *result, +uint32_t src_w,uint32_t src_h, +uint32_t src_x,uint32_t src_y, +uint32_t crtc_w,uint32_t crtc_h, +int32_t crtc_x,int32_t crtc_y, +struct igt_fb *fb) +{ +cairo_surface_t *surface; +cairo_surface_t *clipped_surface; +cairo_t *cr; + + surface =igt_get_cairo_surface (data->drm_fd, fb); + +if (src_x || src_y) { + clipped_surface =cairo_image_surface_create (CAIRO_FORMAT_RGB24 , + src_w, src_h); + + cr =cairo_create (clipped_surface); + +cairo_translate (cr,-1. * src_x,-1. * src_y); + +cairo_set_source_surface (cr, surface,0 ,0 ); + +cairo_paint (cr); +cairo_surface_flush (clipped_surface); + +cairo_destroy (cr); + }else { + clipped_surface = surface; + } + + cr =cairo_create (result); + +cairo_translate (cr, crtc_x, crtc_y); + +if (src_w != crtc_w || src_h != crtc_h) { +cairo_scale (cr, (double ) crtc_w / src_w, + (double ) crtc_h / src_h); + } + +cairo_set_source_surface (cr, clipped_surface,0 ,0 ); +cairo_surface_destroy (clipped_surface); + +if (src_w != crtc_w || src_h != crtc_h) { +cairo_pattern_set_filter (cairo_get_source (cr), +CAIRO_FILTER_BILINEAR ); +cairo_pattern_set_extend (cairo_get_source (cr), +CAIRO_EXTEND_NONE ); + } + +cairo_paint (cr); +cairo_surface_flush (result); + +cairo_destroy (cr); +} + +static void configure_plane (igt_plane_t *plane,uint32_t src_w,uint32_t src_h, +uint32_t src_x,uint32_t src_y,uint32_t crtc_w, +uint32_t crtc_h,int32_t crtc_x,int32_t crtc_y, +struct igt_fb *fb) +{ +igt_plane_set_fb (plane, fb); + +igt_plane_set_position (plane, crtc_x, crtc_y); +igt_plane_set_size (plane, crtc_w, crtc_h); + +igt_fb_set_position (fb, plane, src_x, src_y); +igt_fb_set_size (fb, plane, src_w, src_h); +} + +static void prepare_randomized_plane (data_t *data, +drmModeModeInfo *mode, +igt_plane_t *plane, +struct igt_fb *overlay_fb, +unsigned int index, +cairo_surface_t *result_surface, +bool allow_scaling,bool allow_yuv) +{ +struct igt_fb pattern_fb; +uint32_t overlay_fb_w, overlay_fb_h; +uint32_t overlay_src_w, overlay_src_h; +uint32_t overlay_src_x, overlay_src_y; +int32_t overlay_crtc_x, overlay_crtc_y; +uint32_t overlay_crtc_w, overlay_crtc_h; +uint32_t format; +uint64_t modifier; +size_t stride; +bool tiled; +int fb_id; + +randomize_plane_dimensions (mode, &overlay_fb_w, &overlay_fb_h, + &overlay_src_w, &overlay_src_h, + &overlay_src_x, &overlay_src_y, + &overlay_crtc_w, &overlay_crtc_h, + &overlay_crtc_x, &overlay_crtc_y, + allow_scaling); + +igt_debug ("Plane %d: framebuffer size %dx%d\n" , index, + overlay_fb_w, overlay_fb_h); +igt_debug ("Plane %d: on-crtc size %dx%d\n" , index, + overlay_crtc_w, overlay_crtc_h); +igt_debug ("Plane %d: on-crtc position %dx%d\n" , index, + overlay_crtc_x, overlay_crtc_y); +igt_debug ("Plane %d: in-framebuffer size %dx%d\n" , index, + overlay_src_w, overlay_src_h); +igt_debug ("Plane %d: in-framebuffer position %dx%d\n" , index, + overlay_src_x, overlay_src_y); + +/* Get a pattern framebuffer for the overlay plane. */ + fb_id =chamelium_get_pattern_fb (data, overlay_fb_w, overlay_fb_h, +DRM_FORMAT_XRGB8888 ,32 , &pattern_fb); +igt_assert (fb_id >0 ); + +randomize_plane_format_stride (plane, overlay_fb_w, overlay_fb_h, + &format, &modifier, &stride, allow_yuv); + + tiled = (modifier !=LOCAL_DRM_FORMAT_MOD_NONE ); + +igt_debug ("Plane %d: %s format (%s) with stride %ld\n" , index, +igt_format_str (format), tiled ?"tiled" :"linear" , stride); + + fb_id =igt_fb_convert_with_stride (overlay_fb, &pattern_fb, format, + modifier, stride); +igt_assert (fb_id >0 ); + +blit_plane_cairo (data, result_surface, overlay_src_w, overlay_src_h, + overlay_src_x, overlay_src_y, + overlay_crtc_w, overlay_crtc_h, + overlay_crtc_x, overlay_crtc_y, &pattern_fb); + +configure_plane (plane, overlay_src_w, overlay_src_h, + overlay_src_x, overlay_src_y, + overlay_crtc_w, overlay_crtc_h, + overlay_crtc_x, overlay_crtc_y, overlay_fb); + +/* Remove the original pattern framebuffer. */ +igt_remove_fb (data->drm_fd, &pattern_fb); +} + +static void test_display_planes_random (data_t *data, +struct chamelium_port *port, +enum chamelium_check check) +{ +igt_output_t *output; +drmModeModeInfo *mode; +igt_plane_t *primary_plane; +struct igt_fb primary_fb; +struct igt_fb result_fb; +struct igt_fb *overlay_fbs; +igt_crc_t *crc; +igt_crc_t *expected_crc; +struct chamelium_fb_crc_async_data *fb_crc; +unsigned int overlay_planes_max =0 ; +unsigned int overlay_planes_count; +cairo_surface_t *result_surface; +int captured_frame_count; +bool allow_scaling; +bool allow_yuv; +unsigned int i; +unsigned int fb_id; + +switch (check) { +case CHAMELIUM_CHECK_CRC : + allow_scaling = false; + allow_yuv = false; +break ; +case CHAMELIUM_CHECK_CHECKERBOARD : + allow_scaling = true; + allow_yuv = true; +break ; +default : +igt_assert (false); + } + +srand (time (NULL )); + +reset_state (data, port); + +/* Find the connector and pipe. */ + output =prepare_output (data, port); + + mode =igt_output_get_mode (output); + +/* Get a framebuffer for the primary plane. */ + primary_plane =igt_output_get_plane_type (output,DRM_PLANE_TYPE_PRIMARY ); +igt_assert (primary_plane); + + fb_id =chamelium_get_pattern_fb (data, mode->hdisplay, mode->vdisplay, +DRM_FORMAT_XRGB8888 ,64 , &primary_fb); +igt_assert (fb_id >0 ); + +/* Get a framebuffer for the cairo composition result. */ + fb_id =igt_create_fb (data->drm_fd, mode->hdisplay, + mode->vdisplay,DRM_FORMAT_XRGB8888 , +LOCAL_DRM_FORMAT_MOD_NONE , &result_fb); +igt_assert (fb_id >0 ); + + result_surface =igt_get_cairo_surface (data->drm_fd, &result_fb); + +/* Paint the primary framebuffer on the result surface. */ +blit_plane_cairo (data, result_surface,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , + &primary_fb); + +/* Configure the primary plane. */ +igt_plane_set_fb (primary_plane, &primary_fb); + + overlay_planes_max = +igt_output_count_plane_type (output,DRM_PLANE_TYPE_OVERLAY ); + +/* Limit the number of planes to a reasonable scene. */ + overlay_planes_max =max (overlay_planes_max,4 ); + + overlay_planes_count = (rand () % overlay_planes_max) +1 ; +igt_debug ("Using %d overlay planes\n" , overlay_planes_count); + + overlay_fbs =calloc (sizeof (struct igt_fb ), overlay_planes_count); + +for (i =0 ; i < overlay_planes_count; i++) { +struct igt_fb *overlay_fb = &overlay_fbs[i]; +igt_plane_t *plane = +igt_output_get_plane_type_index (output, +DRM_PLANE_TYPE_OVERLAY , + i); +igt_assert (plane); + +prepare_randomized_plane (data, mode, plane, overlay_fb, i, + result_surface, allow_scaling, + allow_yuv); + } + +cairo_surface_destroy (result_surface); + +if (check ==CHAMELIUM_CHECK_CRC ) + fb_crc =chamelium_calculate_fb_crc_async_start (data->drm_fd, + &result_fb); + +igt_display_commit2 (&data->display,COMMIT_ATOMIC ); + +if (check ==CHAMELIUM_CHECK_CRC ) { +chamelium_capture (data->chamelium, port,0 ,0 ,0 ,0 ,1 ); + crc =chamelium_read_captured_crcs (data->chamelium, + &captured_frame_count); + +igt_assert (captured_frame_count ==1 ); + + expected_crc =chamelium_calculate_fb_crc_async_finish (fb_crc); + +chamelium_assert_crc_eq_or_dump (data->chamelium, + expected_crc, crc, + &result_fb,0 ); + +free (expected_crc); +free (crc); + }else if (check ==CHAMELIUM_CHECK_CHECKERBOARD ) { +struct chamelium_frame_dump *dump; + + dump =chamelium_port_dump_pixels (data->chamelium, port,0 ,0 , +0 ,0 ); +chamelium_assert_frame_match_or_dump (data->chamelium, port, + dump, &result_fb, check); +chamelium_destroy_frame_dump (dump); + } + +for (i =0 ; i < overlay_planes_count; i++) { +struct igt_fb *overlay_fb = &overlay_fbs[i]; +igt_plane_t *plane; + + plane =igt_output_get_plane_type_index (output, +DRM_PLANE_TYPE_OVERLAY , + i); +igt_assert (plane); + +igt_remove_fb (data->drm_fd, overlay_fb); + } + +free (overlay_fbs); + +igt_remove_fb (data->drm_fd, &primary_fb); +igt_remove_fb (data->drm_fd, &result_fb); +} +static void test_hpd_without_ddc (data_t *data,struct chamelium_port *port) {
@@ -977,6 +1407,10 @@ igt_maintest_display_one_mode (&data, port,DRM_FORMAT_XRGB1555 ,CHAMELIUM_CHECK_CRC ,1 ); + connector_subtest("hdmi-crc-planes-random", HDMIA) +test_display_planes_random (&data, port, +CHAMELIUM_CHECK_CRC ); + connector_subtest("hdmi-cmp-nv12", HDMIA)test_display_one_mode (&data, port,DRM_FORMAT_NV12 ,CHAMELIUM_CHECK_CHECKERBOARD ,1 );
@@ -1009,6 +1443,10 @@ igt_maintest_display_one_mode (&data, port,DRM_FORMAT_YVU422 ,CHAMELIUM_CHECK_CHECKERBOARD ,1 ); + connector_subtest("hdmi-cmp-planes-random", HDMIA) +test_display_planes_random (&data, port, +CHAMELIUM_CHECK_CHECKERBOARD ); + connector_subtest("hdmi-frame-dump", HDMIA)test_display_frame_dump (&data, port); }
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t v4 21/21] chamelium: Add a display test for randomized planes
Quoted 9 lines · Paul Kocialkowski
This introduces a new test for the Chamelium, that sets up planes with randomized properties such as the format, dimensions, position, in-framebuffer offsets and stride. The Chamelium capture is checked against the reference generated by cairo with either a CRC or the checkerboard-specific comparison method.
This test also includes testing of the VC4-specific T-tiled and SAND-tiled modes, in all formats supported by the hardware.
Quoted 8 lines
Since this test does not share much with previous Chamelium display tests (especially regarding KMS configuration), most of the code is not shared with other tests.
This test can be derived with reproducible properties for regression testing in the future. For now, it serves as a fuzzing test
Signed-off-by Paul Kocialkowski <[email protected]>
Maxime
Signature · 3 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t v4 21/21] chamelium: Add a display test for randomized planes
In reply to Paul KocialkowskiQuoted 510 lines · Paul Kocialkowski
This introduces a new test for the Chamelium, that sets up planes with randomized properties such as the format, dimensions, position, in-framebuffer offsets and stride. The Chamelium capture is checked against the reference generated by cairo with either a CRC or the checkerboard-specific comparison method.
This test also includes testing of the VC4-specific T-tiled and SAND-tiled modes, in all formats supported by the hardware.
Since this test does not share much with previous Chamelium display tests (especially regarding KMS configuration), most of the code is not shared with other tests.
This test can be derived with reproducible properties for regression testing in the future. For now, it serves as a fuzzing test
Signed-off-by Paul Kocialkowski <[email protected]>--- tests/kms_chamelium.c | 438 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 438 insertions(+)tests/kms_chamelium.c +16
-0@@ -26,6 +26,7 @@#include "config.h" #include "igt.h" +#include "igt_vc4.h" #include <fcntl.h> #include <string.h> @@ -703,6 +704,435 @@ test_display_frame_dump(data_t *data, struct chamelium_port *port)drmModeFreeConnector (connector ); } +static void select_tiled_modifier (igt_plane_t *plane,uint32_t width, +uint32_t height,uint32_t format, +uint64_t *modifier) +{ +if (igt_plane_has_format_mod (plane, format, +DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED )) { +igt_debug ("Selecting VC4 T-tiling\n" ); + + *modifier =DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED ; + }else if (igt_plane_has_format_mod (plane, format, +DRM_FORMAT_MOD_BROADCOM_SAND256 )) { +/* Randomize the column height to less than twice the minimum. */ +size_t column_height = (rand () % height) + height; + + igt_debug("Selecting VC4 SAND256 tiling with column height%ld\n",
tests/kms_chamelium.c +3
-0+ column_height); + + *modifier =
DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(column_height);tests/kms_chamelium.c +8
-0+ }else { + *modifier =DRM_FORMAT_MOD_LINEAR ; + } +} + +static void randomize_plane_format_stride (igt_plane_t *plane, +uint32_t width,uint32_t height, + uint32_t *format, uint64_t*modifier,
tests/kms_chamelium.c +51
-0+ size_t *stride, bool allow_yuv) +{ + size_t stride_min; +uint32_t *formats_array; +unsigned int formats_count; +unsigned int count =0 ; +unsigned int i; +bool tiled; +int index; + +igt_format_array_fill (&formats_array, &formats_count, allow_yuv); + +/* First pass to count the supported formats. */ +for (i =0 ; i < formats_count; i++) +if (igt_plane_has_format_mod (plane, formats_array[i], +DRM_FORMAT_MOD_LINEAR )) + count++; + +igt_assert (count >0 ); + + index =rand () % count; + +/* Second pass to get the index-th supported format. */ +for (i =0 ; i < formats_count; i++) { +if (!igt_plane_has_format_mod (plane, formats_array[i], +DRM_FORMAT_MOD_LINEAR )) +continue ; + +if (!index--) { + *format = formats_array[i]; +break ; + } + } + +free (formats_array); + +igt_assert (index <0 ); + + stride_min = width *igt_format_plane_bpp (*format,0 ) /8 ; + +/* Randomize the stride to less than twice the minimum. */ + *stride = (rand () % stride_min) + stride_min; + +/* Pixman requires the stride to be aligned to 32-byte words. */ + *stride =ALIGN (*stride,sizeof (uint32_t )); + +/* Randomize the use of a tiled mode with a 1/4 probability. */ + tiled = ((rand () %4 ) ==0 ); + + if (tiled) + select_tiled_modifier(plane, width, height, *format,modifier);
tests/kms_chamelium.c +86
-0+else + *modifier =DRM_FORMAT_MOD_LINEAR ; +} + +static void randomize_plane_dimensions (drmModeModeInfo *mode, +uint32_t *width,uint32_t *height, +uint32_t *src_w,uint32_t *src_h, +uint32_t *src_x,uint32_t *src_y, +uint32_t *crtc_w,uint32_t *crtc_h, +int32_t *crtc_x,int32_t *crtc_y, +bool allow_scaling) +{ +double ratio; + +/* Randomize width and height in the mode dimensions range. */ + *width = (rand () % mode->hdisplay) +1 ; + *height = (rand () % mode->vdisplay) +1 ; + +/* Randomize source offset in the first half of the original size. */ + *src_x =rand () % (*width /2 ); + *src_y =rand () % (*height /2 ); + +/* The source size only includes the active source area. */ + *src_w = *width - *src_x; + *src_h = *height - *src_y; + +if (allow_scaling) { + *crtc_w = (rand () % mode->hdisplay) +1 ; + *crtc_h = (rand () % mode->vdisplay) +1 ; + +/* +* Don't bother with scaling if dimensions are quite close in +* order to get non-scaling cases more frequently. Also limit +* scaling to 3x to avoid agressive filtering that makes +* comparison less reliable. +*/ + + ratio = ((double ) *crtc_w / *src_w); +if (ratio >0.8 && ratio <1.2 ) + *crtc_w = *src_w; +else if (ratio >3.0 ) + *crtc_w = *src_w *3 ; + + ratio = ((double ) *crtc_h / *src_h); +if (ratio >0.8 && ratio <1.2 ) + *crtc_h = *src_h; +else if (ratio >3.0 ) + *crtc_h = *src_h *3 ; + }else { + *crtc_w = *src_w; + *crtc_h = *src_h; + } + +if (*crtc_w != *src_w || *crtc_h != *src_h) { +/* +* When scaling is involved, make sure to not go off-bounds or +* scaled clipping may result in decimal dimensions, that most +* drivers don't support. +*/ + *crtc_x =rand () % (mode->hdisplay - *crtc_w); + *crtc_y =rand () % (mode->vdisplay - *crtc_h); + }else { +/* +* Randomize the on-crtc position and allow the plane to go +* off-display by less than half of its on-crtc dimensions. +*/ + *crtc_x = (rand () % mode->hdisplay) - *crtc_w /2 ; + *crtc_y = (rand () % mode->vdisplay) - *crtc_h /2 ; + } +} + +static void blit_plane_cairo (data_t *data,cairo_surface_t *result, +uint32_t src_w,uint32_t src_h, +uint32_t src_x,uint32_t src_y, +uint32_t crtc_w,uint32_t crtc_h, +int32_t crtc_x,int32_t crtc_y, +struct igt_fb *fb) +{ +cairo_surface_t *surface; +cairo_surface_t *clipped_surface; +cairo_t *cr; + + surface =igt_get_cairo_surface (data->drm_fd, fb); + +if (src_x || src_y) { + clipped_surface =cairo_image_surface_create(CAIRO_FORMAT_RGB24,
tests/kms_chamelium.c +42
-0+ src_w, src_h); + + cr =cairo_create (clipped_surface); + +cairo_translate (cr,-1. * src_x,-1. * src_y); + +cairo_set_source_surface (cr, surface,0 ,0 ); + +cairo_paint (cr); +cairo_surface_flush (clipped_surface); + +cairo_destroy (cr); + }else { + clipped_surface = surface; + } + + cr =cairo_create (result); + +cairo_translate (cr, crtc_x, crtc_y); + +if (src_w != crtc_w || src_h != crtc_h) { +cairo_scale (cr, (double ) crtc_w / src_w, + (double ) crtc_h / src_h); + } + +cairo_set_source_surface (cr, clipped_surface,0 ,0 ); +cairo_surface_destroy (clipped_surface); + +if (src_w != crtc_w || src_h != crtc_h) { +cairo_pattern_set_filter (cairo_get_source (cr), +CAIRO_FILTER_BILINEAR ); +cairo_pattern_set_extend (cairo_get_source (cr), +CAIRO_EXTEND_NONE ); + } + +cairo_paint (cr); +cairo_surface_flush (result); + +cairo_destroy (cr); +} + +static void configure_plane(igt_plane_t *plane, uint32_t src_w, uint32_t
src_h,tests/kms_chamelium.c +54
-0+ uint32_t src_x, uint32_t src_y, uint32_t crtc_w, + uint32_t crtc_h, int32_t crtc_x, int32_t crtc_y, + struct igt_fb *fb) +{ +igt_plane_set_fb (plane ,fb ); + +igt_plane_set_position (plane, crtc_x, crtc_y); +igt_plane_set_size (plane, crtc_w, crtc_h); + +igt_fb_set_position (fb, plane, src_x, src_y); +igt_fb_set_size (fb, plane, src_w, src_h); +} + +static void prepare_randomized_plane (data_t *data, +drmModeModeInfo *mode, +igt_plane_t *plane, +struct igt_fb *overlay_fb, +unsigned int index, +cairo_surface_t *result_surface, +bool allow_scaling,bool allow_yuv) +{ +struct igt_fb pattern_fb; +uint32_t overlay_fb_w, overlay_fb_h; +uint32_t overlay_src_w, overlay_src_h; +uint32_t overlay_src_x, overlay_src_y; +int32_t overlay_crtc_x, overlay_crtc_y; +uint32_t overlay_crtc_w, overlay_crtc_h; +uint32_t format; +uint64_t modifier; +size_t stride; +bool tiled; +int fb_id; + +randomize_plane_dimensions (mode, &overlay_fb_w, &overlay_fb_h, + &overlay_src_w, &overlay_src_h, + &overlay_src_x, &overlay_src_y, + &overlay_crtc_w, &overlay_crtc_h, + &overlay_crtc_x, &overlay_crtc_y, + allow_scaling); + +igt_debug ("Plane %d: framebuffer size %dx%d\n" , index, + overlay_fb_w, overlay_fb_h); +igt_debug ("Plane %d: on-crtc size %dx%d\n" , index, + overlay_crtc_w, overlay_crtc_h); +igt_debug ("Plane %d: on-crtc position %dx%d\n" , index, + overlay_crtc_x, overlay_crtc_y); +igt_debug ("Plane %d: in-framebuffer size %dx%d\n" , index, + overlay_src_w, overlay_src_h); +igt_debug ("Plane %d: in-framebuffer position %dx%d\n" , index, + overlay_src_x, overlay_src_y); + +/* Get a pattern framebuffer for the overlay plane. */ + fb_id = chamelium_get_pattern_fb(data, overlay_fb_w, overlay_fb_h, + DRM_FORMAT_XRGB8888, 32,
&pattern_fb);tests/kms_chamelium.c +74
-0+igt_assert (fb_id >0 ); + +randomize_plane_format_stride (plane, overlay_fb_w, overlay_fb_h, + &format, &modifier, &stride, allow_yuv); + + tiled = (modifier !=LOCAL_DRM_FORMAT_MOD_NONE ); + +igt_debug ("Plane %d: %s format (%s) with stride %ld\n" , index, +igt_format_str (format), tiled ?"tiled" :"linear" , stride); + + fb_id =igt_fb_convert_with_stride (overlay_fb, &pattern_fb, format, + modifier, stride); +igt_assert (fb_id >0 ); + +blit_plane_cairo (data, result_surface, overlay_src_w, overlay_src_h, + overlay_src_x, overlay_src_y, + overlay_crtc_w, overlay_crtc_h, + overlay_crtc_x, overlay_crtc_y, &pattern_fb); + +configure_plane (plane, overlay_src_w, overlay_src_h, + overlay_src_x, overlay_src_y, + overlay_crtc_w, overlay_crtc_h, + overlay_crtc_x, overlay_crtc_y, overlay_fb); + +/* Remove the original pattern framebuffer. */ +igt_remove_fb (data->drm_fd, &pattern_fb); +} + +static void test_display_planes_random (data_t *data, +struct chamelium_port *port, +enum chamelium_check check) +{ +igt_output_t *output; +drmModeModeInfo *mode; +igt_plane_t *primary_plane; +struct igt_fb primary_fb; +struct igt_fb result_fb; +struct igt_fb *overlay_fbs; +igt_crc_t *crc; +igt_crc_t *expected_crc; +struct chamelium_fb_crc_async_data *fb_crc; +unsigned int overlay_planes_max =0 ; +unsigned int overlay_planes_count; +cairo_surface_t *result_surface; +int captured_frame_count; +bool allow_scaling; +bool allow_yuv; +unsigned int i; +unsigned int fb_id; + +switch (check) { +case CHAMELIUM_CHECK_CRC : + allow_scaling = false; + allow_yuv = false; +break ; +case CHAMELIUM_CHECK_CHECKERBOARD : + allow_scaling = true; + allow_yuv = true; +break ; +default : +igt_assert (false); + } + +srand (time (NULL )); + +reset_state (data, port); + +/* Find the connector and pipe. */ + output =prepare_output (data, port); + + mode =igt_output_get_mode (output); + +/* Get a framebuffer for the primary plane. */ + primary_plane = igt_output_get_plane_type(output,
DRM_PLANE_TYPE_PRIMARY);tests/kms_chamelium.c +4
-0+igt_assert (primary_plane); + + fb_id = chamelium_get_pattern_fb(data, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, 64,
&primary_fb);tests/kms_chamelium.c +33
-0+igt_assert (fb_id >0 ); + +/* Get a framebuffer for the cairo composition result. */ + fb_id =igt_create_fb (data->drm_fd, mode->hdisplay, + mode->vdisplay,DRM_FORMAT_XRGB8888 , +LOCAL_DRM_FORMAT_MOD_NONE , &result_fb); +igt_assert (fb_id >0 ); + + result_surface =igt_get_cairo_surface (data->drm_fd, &result_fb); + +/* Paint the primary framebuffer on the result surface. */ +blit_plane_cairo (data, result_surface,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , + &primary_fb); + +/* Configure the primary plane. */ +igt_plane_set_fb (primary_plane, &primary_fb); + + overlay_planes_max = +igt_output_count_plane_type (output,DRM_PLANE_TYPE_OVERLAY ); + +/* Limit the number of planes to a reasonable scene. */ + overlay_planes_max =max (overlay_planes_max,4 ); + + overlay_planes_count = (rand () % overlay_planes_max) +1 ; +igt_debug ("Using %d overlay planes\n" , overlay_planes_count); + + overlay_fbs =calloc (sizeof (struct igt_fb ), overlay_planes_count); + +for (i =0 ; i < overlay_planes_count; i++) { +struct igt_fb *overlay_fb = &overlay_fbs[i]; +igt_plane_t *plane = +igt_output_get_plane_type_index (output, + DRM_PLANE_TYPE_OVERLAY,
tests/kms_chamelium.c +24
-0+ i); +igt_assert (plane); + +prepare_randomized_plane (data, mode, plane, overlay_fb, i, + result_surface, allow_scaling, + allow_yuv); + } + +cairo_surface_destroy (result_surface); + +if (check ==CHAMELIUM_CHECK_CRC ) + fb_crc =chamelium_calculate_fb_crc_async_start (data->drm_fd, + &result_fb); + +igt_display_commit2 (&data->display,COMMIT_ATOMIC ); + +if (check ==CHAMELIUM_CHECK_CRC ) { +chamelium_capture (data->chamelium, port,0 ,0 ,0 ,0 ,1 ); + crc =chamelium_read_captured_crcs (data->chamelium, + &captured_frame_count); + +igt_assert (captured_frame_count ==1 ); + + expected_crc =
chamelium_calculate_fb_crc_async_finish(fb_crc);tests/kms_chamelium.c +23
-0+ +chamelium_assert_crc_eq_or_dump (data->chamelium, + expected_crc, crc, + &result_fb,0 ); + +free (expected_crc); +free (crc); + }else if (check ==CHAMELIUM_CHECK_CHECKERBOARD ) { +struct chamelium_frame_dump *dump; + + dump =chamelium_port_dump_pixels (data->chamelium, port,0 ,0 , +0 ,0 ); +chamelium_assert_frame_match_or_dump (data->chamelium, port, + dump, &result_fb, check); +chamelium_destroy_frame_dump (dump); + } + +for (i =0 ; i < overlay_planes_count; i++) { +struct igt_fb *overlay_fb = &overlay_fbs[i]; +igt_plane_t *plane; + + plane =igt_output_get_plane_type_index (output, + DRM_PLANE_TYPE_OVERLAY,
tests/kms_chamelium.c +16
-0+ i); +igt_assert (plane); + +igt_remove_fb (data->drm_fd, overlay_fb); + } + +free (overlay_fbs); + +igt_remove_fb (data->drm_fd, &primary_fb); +igt_remove_fb (data->drm_fd, &result_fb); +} +static void test_hpd_without_ddc (data_t *data,struct chamelium_port *port) {@@ -977,6 +1407,10 @@ igt_maintest_display_one_mode (&data, port,DRM_FORMAT_XRGB1555 ,CHAMELIUM_CHECK_CRC ,1 ); + connector_subtest("hdmi-crc-planes-random", HDMIA) +test_display_planes_random (&data, port, +CHAMELIUM_CHECK_CRC ); + connector_subtest("hdmi-cmp-nv12", HDMIA) test_display_one_mode(&data, port, DRM_FORMAT_NV12,
CHAMELIUM_CHECK_CHECKERBOARD,
1);tests/kms_chamelium.c +4
-0@@ -1009,6 +1443,10 @@ igt_maintest_display_one_mode (&data, port,DRM_FORMAT_YVU422 ,CHAMELIUM_CHECK_CHECKERBOARD ,1 ); + connector_subtest("hdmi-cmp-planes-random", HDMIA) +test_display_planes_random (&data, port, +CHAMELIUM_CHECK_CHECKERBOAR D); +connector_subtest ("hdmi-frame-dump" ,HDMIA )tests/kms_chamelium.c +0
-0test_display_frame_dump (&data, port); }
Signature · 7 lines
Cheers, Lyude Paul _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✗ Fi.CI.BAT: failure for Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode (rev2)
In reply to Paul Kocialkowski== Series Details ==
== Series Details ==
Series: Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode (rev2)
URL : https://patchwork.freedesktop.org/series/55044/
State : failure
== Summary ==
Applying: lib: drmtest: Add helpers to check and require the VC4 driver
Applying: lib/igt_fb: Add checks on i915 for i915-specific tiled buffer allocation
Applying: lib/igt_fb: Add support for allocating T-tiled VC4 buffers Patch failed at 0003 lib/igt_fb: Add support for allocating T-tiled VC4 buffers When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev