lib/igt_kms: Fill the plane format/mod information for pre-blobifier drivers
PATCH 1/25 lib/igt_kms: Fill the plane format/mod information for pre-blobifier drivers
From: Ville Syrjälä <[email protected]>
For drivers that don't support the IN_FORMATS blob we should just consult the format list returned by getplane. Since we can't know which modifiers are supported we'll assume linear-only. Obviously that may not work for every driver out there, but not much more we can do unless we start to actually probing with addfb.
--- lib/igt_kms.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
lib/igt_kms.c +21 -1
@@ -4068,8 +4068,28 @@ static void igt_fill_plane_format_mod(igt_display_t *display, igt_plane_t *planeint idx =0 ;int count; -if (!igt_plane_has_prop (plane,IGT_PLANE_IN_FORMATS )) +if (!igt_plane_has_prop (plane,IGT_PLANE_IN_FORMATS )) { +drmModePlanePtr p = plane->drm_plane; + + count = p->count_formats; + + plane->format_mod_count = count; + plane->formats =calloc (count,sizeof (plane->formats[0 ])); +igt_assert (plane->formats); + plane->modifiers =calloc (count,sizeof (plane->modifiers[0 ])); +igt_assert (plane->modifiers); + +/* +* We don't know which modifiers are +* supported, so we'll assume linear only. +*/ +for (int i =0 ; i < count; i++) { + plane->formats[i] = p->formats[i]; + plane->modifiers[i] =DRM_FORMAT_MOD_LINEAR ; + } +return ; + } blob_id =igt_plane_get_prop (plane,IGT_PLANE_IN_FORMATS );
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 3/25 tests/kms_plane: Add validate-in-formats subtest
From: Ville Syrjälä <[email protected]>
Cross check the format list in the IN_FORMATS blob vs. the format list returned by getplane.
--- tests/kms_plane.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
tests/kms_plane.c +50 -0
@@ -366,6 +366,53 @@ test_plane_panning(data_t *data, enum pipe pipe, unsigned int flags)igt_skip_on (connected_outs ==0 ); } +static void validate_plane_in_formats (igt_plane_t *plane) +{ +drmModePlanePtr drm_plane = plane->drm_plane; + +igt_require (plane->format_mod_count); + +/* +* Make sure every format in the IN_FORMATS blob +* also appears in the getplane formats. +*/ +for (int i =0 ; i < plane->format_mod_count; i++) { +int j; + +for (j =0 ; j < drm_plane->count_formats; j++) { +if (plane->formats[i] == drm_plane->formats[j]) +break ; + } +igt_assert_lt (j, drm_plane->count_formats); + } + +/* +* Make sure every format in getplane also +* appears in the IN_FORMATS blob. +*/ +for (int i =0 ; i < drm_plane->count_formats; i++) { +int j; + +for (j =0 ; j < plane->format_mod_count; j++) { +if (drm_plane->formats[i] == plane->formats[j]) +break ; + } +igt_assert_lt (j, plane->format_mod_count); + } +} + +static void validate_in_formats (data_t *data) +{ +enum pipe pipe; + +for_each_pipe (&data->display, pipe) { +igt_plane_t *plane; + +for_each_plane_on_pipe (&data->display, pipe, plane) +validate_plane_in_formats (plane); + } +} +static const color_t colors[] = { {1.0f ,0.0f ,0.0f , }, {0.0f ,1.0f ,0.0f , },
@@ -592,6 +639,9 @@ igt_mainigt_display_init (&data.display, data.drm_fd); } + igt_subtest_f("validate-in-formats") +validate_in_formats (&data); +for_each_pipe_static (pipe)run_tests_for_pipe_plane (&data, pipe);
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 5/25 tests/gem_render_copy: Fix clipped height
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Assign the clipped height to 'h', not 'w'. This didn't cause any problems so far because we use square buffers.
Also get rid of the gcc variable shadowing warnings by not nesting the min()/max().
--- tests/gem_render_copy.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
tests/gem_render_copy.c +5 -2
@@ -254,8 +254,11 @@ scratch_buf_copy(data_t *data, linear_src =gem_mmap__gtt (data->drm_fd, src->bo->handle, src->bo->size,PROT_READ ); - w =min (w,min (width - sx, width - dx)); - w =min (h,min (height - sy, height - dy)); + w =min (w, width - sx); + w =min (w, width - dx); + + h =min (h, height - sy); + h =min (h, height - dy);for (int y =0 ; y < h; y++) { igt_memcpy_from_wc(&linear_dst[(dy+y) * width + dx],
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 6/25 lib/igt_fb: Respect the users choice of stride
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
We prented to allow the caller to specify the stride explicitly for the fb. But we don't actually use that user specified stride when we calculate the require bo size. Fix that oversight.
--- lib/igt_fb.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-)
lib/igt_fb.c +22 -15
@@ -215,11 +215,12 @@ static unsigned planar_height(struct format_desc_struct *format, unsigned heightstatic void calc_fb_size_planar (int fd,int width,int height,struct format_desc_struct *format, -uint64_t tiling,unsigned *size_ret, -unsigned *stride_ret,unsigned *offsets) +uint64_t tiling,unsigned stride, +unsigned *size_ret,unsigned *stride_ret, +unsigned *offsets) {int plane; -unsigned stride =0 , tile_width, tile_height; +unsigned max_stride =0 , tile_width, tile_height; *size_ret =0 ;
@@ -229,10 +230,13 @@ static void calc_fb_size_planar(int fd, int width, int height,igt_get_fb_tile_size (fd, tiling, format->plane_bpp[plane], &tile_width, &tile_height); plane_stride =ALIGN (planar_stride (format, width, plane), tile_width); -if (stride < plane_stride) - stride = plane_stride; +if (max_stride < plane_stride) + max_stride = plane_stride; } +if (!stride) + stride = max_stride; +for (plane =0 ; plane < format->num_planes; plane++) {if (offsets) offsets[plane] = *size_ret;
@@ -251,9 +255,9 @@ static void calc_fb_size_planar(int fd, int width, int height,static void calc_fb_size_packed (int fd,int width,int height,struct format_desc_struct *format,uint64_t tiling, -unsigned *size_ret,unsigned *stride_ret) +unsigned stride,unsigned *size_ret,unsigned *stride_ret) { -unsigned int tile_width, tile_height, stride, size; +unsigned int tile_width, tile_height, size;int byte_width = width * (format->plane_bpp[0 ] /8 );igt_get_fb_tile_size (fd, tiling, format->plane_bpp[0 ], &tile_width, &tile_height);
@@ -270,15 +274,18 @@ static void calc_fb_size_packed(int fd, int width, int height,* tiled. But then that failure is expected. */ - v = byte_width; -for (stride =512 ; stride < v; stride *=2 ) - ; +if (!stride) { + v = byte_width; +for (stride =512 ; stride < v; stride *=2 ) + ; + } v = stride * height;for (size =1024 *1024 ; size < v; size *=2 ) ; }else { - stride =ALIGN (byte_width, tile_width); +if (!stride) + stride =ALIGN (byte_width, tile_width); size = stride *ALIGN (height, tile_height); }
@@ -306,9 +313,9 @@ void igt_calc_fb_size(int fd, int width, int height, uint32_t drm_format, uint64igt_assert (format);if (format->num_planes >1 ) -calc_fb_size_planar (fd, width, height, format, tiling, size_ret, stride_ret,NULL ); +calc_fb_size_planar (fd, width, height, format, tiling,0 , size_ret, stride_ret,NULL );else -calc_fb_size_packed (fd, width, height, format, tiling, size_ret, stride_ret); +calc_fb_size_packed (fd, width, height, format, tiling,0 , size_ret, stride_ret); }/**
@@ -383,10 +390,10 @@ static int create_bo_for_fb(int fd, int width, int height,unsigned calculated_size, calculated_stride;if (format->num_planes >1 ) -calc_fb_size_planar (fd, width, height, format, tiling, +calc_fb_size_planar (fd, width, height, format, tiling, stride, &calculated_size, &calculated_stride, offsets);else -calc_fb_size_packed (fd, width, height, format, tiling, +calc_fb_size_packed (fd, width, height, format, tiling, stride, &calculated_size, &calculated_stride);if (stride ==0 )
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 2/25 tests/kms_ccs: Use igt_plane_has_format_mod()
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Replace the open coded IN_FORMATS parsing with igt_plane_has_format_mod() now that we have such a thing.
--- tests/kms_ccs.c | 50 +------------------------------------------------- 1 file changed, 1 insertion(+), 49 deletions(-)
tests/kms_ccs.c +1 -49
@@ -132,55 +132,7 @@ modifiers_ptr(struct local_drm_format_modifier_blob *blob)static bool plane_has_format_with_ccs (data_t *data,igt_plane_t *plane,uint32_t format) { -drmModePropertyBlobPtr blob; -struct local_drm_format_modifier_blob *blob_data; -struct local_drm_format_modifier *modifiers, *last_mod; -uint32_t *formats, *last_fmt; -uint64_t blob_id; -bool ret; -int fmt_idx =-1 ; - - ret =kmstest_get_property (data->drm_fd, plane->drm_plane->plane_id, -DRM_MODE_OBJECT_PLANE ,"IN_FORMATS" , -NULL , &blob_id,NULL ); -igt_skip_on_f (ret == false,"IN_FORMATS not supported by kernel\n" ); -igt_skip_on_f (blob_id ==0 ,"IN_FORMATS not supported by plane\n" ); - blob =drmModeGetPropertyBlob (data->drm_fd, blob_id); -igt_assert (blob); -igt_assert_lte (sizeof (struct local_drm_format_modifier_blob ), - blob->length); - - blob_data = (struct local_drm_format_modifier_blob *) blob->data; - formats =formats_ptr (blob_data); - last_fmt = &formats[blob_data->count_formats]; -igt_assert_lte (((char *) last_fmt - (char *) blob_data), blob->length); -for (int i =0 ; i < blob_data->count_formats; i++) { -if (formats[i] == format) { - fmt_idx = i; -break ; - } - } - -if (fmt_idx ==-1 ) -return false; - - modifiers =modifiers_ptr (blob_data); - last_mod = &modifiers[blob_data->count_modifiers]; -igt_assert_lte (((char *) last_mod - (char *) blob_data), blob->length); -for (int i =0 ; i < blob_data->count_modifiers; i++) { -if (modifiers[i].modifier !=LOCAL_I915_FORMAT_MOD_Y_TILED_CCS ) -continue ; - -if (modifiers[i].offset > fmt_idx || - fmt_idx > modifiers[i].offset +63 ) -continue ; - -if (modifiers[i].formats & - (1UL << (fmt_idx - modifiers[i].offset))) -return true; - } - -return false; +return igt_plane_has_format_mod (plane, format,LOCAL_I915_FORMAT_MOD_Y_TILED_CCS ); } static void render_fb(data_t *data, uint32_t gem_handle, unsigned int size,
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 7/25 lib: Add DIV_ROUND_UP()
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Add DIV_ROUND_UP() and replace some hand rolled versions with it.
--- lib/igt_aux.h | 2 ++ lib/igt_fb.c | 4 ++-- tests/i915_query.c | 2 -- 3 files changed, 4 insertions(+), 4 deletions(-)
lib/igt_aux.h +2 -0
@@ -287,4 +287,6 @@ void igt_lsof(const char *dpath);#define is_power_of_two (x) (((x) & ((x)-1)) == 0) +#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +#endif /* IGT_AUX_H */
lib/igt_fb.c +2 -2
@@ -193,7 +193,7 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,static unsigned planar_width (struct format_desc_struct *format,unsigned width,int plane) {if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) -return (width +1 ) /2 ; +return DIV_ROUND_UP (width,2 );return width; }
@@ -208,7 +208,7 @@ static unsigned planar_stride(struct format_desc_struct *format, unsigned width,static unsigned planar_height (struct format_desc_struct *format,unsigned height,int plane) {if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) -return (height +1 ) /2 ; +return DIV_ROUND_UP (height,2 );return height; }
tests/i915_query.c +0 -2
@@ -242,8 +242,6 @@ static void test_query_topology_unsupported(int fd)igt_assert_eq (item.length, -ENODEV ); } -#define DIV_ROUND_UP (val, div) (ALIGN(val, div) / div) -static bool slice_available (const struct drm_i915_query_topology_info *topo_info,int s)
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 4/25 tests/kms_addfb_basic: Check that addfb2 accepts/rejects the expected formats
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Try to create a bunch of fbs with different formats/modfifiers and make sure sure addfb2 accepts/rejects them in accordance with what the plane IN_FORMATS blobifiers are advertizing.
We only check "easy" formats (ie. RGB/C8, no YUV/planar etc.). We also assume that one can always create a 64x64 fb with stride of 64*8 bytes.
v2: Skip when blobifiers aren't supported
--- tests/kms_addfb_basic.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 104 insertions(+), 3 deletions(-)
tests/kms_addfb_basic.c +104 -3
@@ -41,6 +41,97 @@uint32_t gem_bo;uint32_t gem_bo_small; +static const uint64_t modifiers[] = { +DRM_FORMAT_MOD_LINEAR , +I915_FORMAT_MOD_X_TILED , +I915_FORMAT_MOD_Y_TILED , + I915_FORMAT_MOD_Yf_TILED, +I915_FORMAT_MOD_Y_TILED_CCS , + I915_FORMAT_MOD_Yf_TILED_CCS, +}; + +static const uint32_t formats[] = { +DRM_FORMAT_C8 , + +DRM_FORMAT_RGB565 , +DRM_FORMAT_BGR565 , + +DRM_FORMAT_RGB888 , +DRM_FORMAT_BGR888 , + +DRM_FORMAT_XRGB8888 , +DRM_FORMAT_XBGR8888 , +DRM_FORMAT_RGBX8888 , +DRM_FORMAT_BGRX8888 , +DRM_FORMAT_ARGB8888 , +DRM_FORMAT_ABGR8888 , +DRM_FORMAT_RGBA8888 , +DRM_FORMAT_BGRA8888 , + +DRM_FORMAT_XRGB2101010 , +DRM_FORMAT_XBGR2101010 , +DRM_FORMAT_RGBX1010102 , +DRM_FORMAT_BGRX1010102 , +DRM_FORMAT_ARGB2101010 , +DRM_FORMAT_ABGR2101010 , +DRM_FORMAT_RGBA1010102 , +DRM_FORMAT_BGRA1010102 , +}; + +#define IGT_FORMAT_FMT "%c%c%c%c (0x%08x)" +#define IGT_FORMAT_ARGS (f) ((f) >> 0) & 0xff, ((f) >> 8) & 0xff, \ + ((f) >> 16) & 0xff, ((f) >> 24) & 0xff, (f) + +/* +* make sure addfb2 accepts/rejects every format/modifier +* in accordance with the plane IN_FORMATS properties. +*/ +static void expected_formats (igt_display_t *display) +{ +int fd = display->drm_fd; +uint32_t handle; + +igt_require (display->format_mod_count); + + handle =gem_create (fd,64 *8 *64 ); +igt_assert (handle); + +for (int i =0 ; i <ARRAY_SIZE (formats); i++) { +uint32_t format = formats[i]; + +for (int j =0 ; j <ARRAY_SIZE (modifiers); j++) { +uint64_t modifier = modifiers[j]; +struct drm_mode_fb_cmd2 f = { + .width =64 , + .height =64 , + .pixel_format = format, + .handles[0 ] = handle, + .pitches[0 ] =64 *8 , + .modifier[0 ] = modifier, + .flags =DRM_MODE_FB_MODIFIERS , + }; +int ret; + +igt_info ("Testing format " IGT_FORMAT_FMT " / modifier 0x%" PRIx64"\n" , +IGT_FORMAT_ARGS (format), modifier); + + ret =drmIoctl (fd,DRM_IOCTL_MODE_ADDFB2 , &f); + +if (igt_display_has_format_mod (display, format, modifier)) { +igt_assert_eq (ret,0 ); +igt_assert_neq (f.fb_id,0 ); + }else { +igt_assert_neq (ret,0 ); +igt_assert_eq (f.fb_id,0 ); + } + +drmIoctl (fd,DRM_IOCTL_MODE_RMFB , &f.fb_id); + } + } + +gem_close (fd, handle); +} +static void invalid_tests (int fd) {struct local_drm_mode_fb_cmd2 f = {};
@@ -539,13 +630,17 @@ static void prop_tests(int fd) } -int fd; +static igt_display_t display; +static int fd;igt_main { -igt_fixture + igt_fixture { fd =drm_open_driver_master (DRIVER_ANY ); +igt_display_init (&display, fd); + } +invalid_tests (fd);pitch_tests (fd);
@@ -560,6 +655,12 @@ igt_mainprop_tests (fd); -igt_fixture + igt_subtest("expected-formats") +expected_formats (&display); + + igt_fixture { +igt_display_fini (&display); +close (fd); + } }
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 8/25 lib/igt_fb: Use fb_blit_upload as the base class for fb_convert_blit_upload
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
fb_blit_upload already has everything we need, so let's use it as the base class for fb_convert_blit_upload.
--- lib/igt_fb.c | 57 +++++++++++++++++++++++++++------------------------------ 1 file changed, 27 insertions(+), 30 deletions(-)
lib/igt_fb.c +27 -30
@@ -1368,15 +1368,12 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) }struct fb_convert_blit_upload { -int fd; -struct igt_fb *fb; +struct fb_blit_upload base;struct {uint8_t *map;unsigned stride, size; } rgb24; - -struct fb_blit_linear linear; };static uint8_t clamprgb (float val)
@@ -1404,8 +1401,8 @@ static void convert_nv12_to_rgb24(struct igt_fb *fb, struct fb_convert_blit_uploint i, j;const uint8_t *y, *uv;uint8_t *rgb24 = blit->rgb24.map; -unsigned rgb24_stride = blit->rgb24.stride, planar_stride = blit->linear.stride; -uint8_t *buf =malloc (blit->linear.size); +unsigned rgb24_stride = blit->rgb24.stride, planar_stride = blit->base.linear.stride; +uint8_t *buf =malloc (blit->base.linear.size);struct igt_mat4 m =igt_ycbcr_to_rgb_matrix (fb->color_encoding, fb->color_range);
@@ -1414,9 +1411,9 @@ static void convert_nv12_to_rgb24(struct igt_fb *fb, struct fb_convert_blit_uplo* it's faster to copy the whole BO to a temporary buffer and convert * from there. */ -igt_memcpy_from_wc (buf, blit->linear.map, blit->linear.size); - y = &buf[blit->linear.offsets[0 ]]; - uv = &buf[blit->linear.offsets[1 ]]; +igt_memcpy_from_wc (buf, blit->base.linear.map, blit->base.linear.size); + y = &buf[blit->base.linear.offsets[0 ]]; + uv = &buf[blit->base.linear.offsets[1 ]];for (i =0 ; i < fb->height /2 ; i++) {for (j =0 ; j < fb->width /2 ; j++) {
@@ -1510,11 +1507,11 @@ static void convert_nv12_to_rgb24(struct igt_fb *fb, struct fb_convert_blit_uplostatic void convert_rgb24_to_nv12 (struct igt_fb *fb,struct fb_convert_blit_upload *blit) {int i, j; -uint8_t *y = &blit->linear.map[blit->linear.offsets[0 ]]; -uint8_t *uv = &blit->linear.map[blit->linear.offsets[1 ]]; +uint8_t *y = &blit->base.linear.map[blit->base.linear.offsets[0 ]]; +uint8_t *uv = &blit->base.linear.map[blit->base.linear.offsets[1 ]];const uint8_t *rgb24 = blit->rgb24.map;unsigned rgb24_stride = blit->rgb24.stride; -unsigned planar_stride = blit->linear.stride; +unsigned planar_stride = blit->base.linear.stride;struct igt_mat4 m =igt_rgb_to_ycbcr_matrix (fb->color_encoding, fb->color_range);
@@ -1641,8 +1638,8 @@ static void convert_yuyv_to_rgb24(struct igt_fb *fb, struct fb_convert_blit_uploint i, j;const uint8_t *yuyv;uint8_t *rgb24 = blit->rgb24.map; -unsigned rgb24_stride = blit->rgb24.stride, yuyv_stride = blit->linear.stride; -uint8_t *buf =malloc (blit->linear.size); +unsigned rgb24_stride = blit->rgb24.stride, yuyv_stride = blit->base.linear.stride; +uint8_t *buf =malloc (blit->base.linear.size);struct igt_mat4 m =igt_ycbcr_to_rgb_matrix (fb->color_encoding, fb->color_range);
@@ -1651,7 +1648,7 @@ static void convert_yuyv_to_rgb24(struct igt_fb *fb, struct fb_convert_blit_uplo* it's faster to copy the whole BO to a temporary buffer and convert * from there. */ -igt_memcpy_from_wc (buf, blit->linear.map, blit->linear.size); +igt_memcpy_from_wc (buf, blit->base.linear.map, blit->base.linear.size); yuyv = buf;for (i =0 ; i < fb->height; i++) {
@@ -1698,10 +1695,10 @@ static void convert_rgb24_to_yuyv(struct igt_fb *fb, struct fb_convert_blit_uplo const unsigned char swz[4]) {int i, j; -uint8_t *yuyv = blit->linear.map; +uint8_t *yuyv = blit->base.linear.map;const uint8_t *rgb24 = blit->rgb24.map;unsigned rgb24_stride = blit->rgb24.stride; -unsigned yuyv_stride = blit->linear.stride; +unsigned yuyv_stride = blit->base.linear.stride;struct igt_mat4 m =igt_rgb_to_ycbcr_matrix (fb->color_encoding, fb->color_range);
@@ -1750,7 +1747,7 @@ static void convert_rgb24_to_yuyv(struct igt_fb *fb, struct fb_convert_blit_uplostatic void destroy_cairo_surface__convert (void *arg) {struct fb_convert_blit_upload *blit = arg; -struct igt_fb *fb = blit->fb; +struct igt_fb *fb = blit->base.fb;/* Convert linear rgb back! */ switch (fb->drm_format) {
@@ -1770,10 +1767,10 @@ static void destroy_cairo_surface__convert(void *arg)munmap (blit->rgb24.map, blit->rgb24.size); -if (blit->linear.handle) -free_linear_mapping (blit->fd, blit->fb, &blit->linear); +if (blit->base.linear.handle) +free_linear_mapping (blit->base.fd, blit->base.fb, &blit->base.linear);else -gem_munmap (blit->linear.map, fb->size); +gem_munmap (blit->base.linear.map, fb->size);free (blit);
@@ -1785,8 +1782,8 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)struct fb_convert_blit_upload *blit =malloc (sizeof (*blit));igt_assert (blit); - blit->fd = fd; - blit->fb = fb; + blit->base.fd = fd; + blit->base.fb = fb; blit->rgb24.stride =ALIGN (fb->width *4 ,16 ); blit->rgb24.size =ALIGN (blit->rgb24.stride * fb->height,sysconf (_SC_PAGESIZE)); blit->rgb24.map =mmap (NULL , blit->rgb24.size,PROT_READ |PROT_WRITE ,MAP_PRIVATE |MAP_ANONYMOUS ,-1 ,0 );
@@ -1794,15 +1791,15 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) { -setup_linear_mapping (fd, fb, &blit->linear); +setup_linear_mapping (fd, fb, &blit->base.linear); }else { - blit->linear.handle =0 ; - blit->linear.map =gem_mmap__gtt (fd, fb->gem_handle, fb->size, + blit->base.linear.handle =0 ; + blit->base.linear.map =gem_mmap__gtt (fd, fb->gem_handle, fb->size,PROT_READ |PROT_WRITE ); -igt_assert (blit->linear.map); - blit->linear.stride = fb->stride; - blit->linear.size = fb->size; -memcpy (blit->linear.offsets, fb->offsets,sizeof (fb->offsets)); +igt_assert (blit->base.linear.map); + blit->base.linear.stride = fb->stride; + blit->base.linear.size = fb->size; +memcpy (blit->base.linear.offsets, fb->offsets,sizeof (fb->offsets)); }/* Convert to linear rgb! */
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 10/25 lib/igt_fb: s/planar_foo/fb_plane_foo/
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Rename the planar_foo() functions to fb_plane_foo(). Makes it clear they're perfectly usable with non-planar formts too.
--- lib/igt_fb.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
lib/igt_fb.c +12 -9
@@ -190,7 +190,8 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, } } -static unsigned planar_width (struct format_desc_struct *format,unsigned width,int plane) +static unsigned fb_plane_width (struct format_desc_struct *format, +unsigned width,int plane) {if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 )return DIV_ROUND_UP (width,2 );
@@ -198,14 +199,16 @@ static unsigned planar_width(struct format_desc_struct *format, unsigned width,return width; } -static unsigned planar_stride (struct format_desc_struct *format,unsigned width,int plane) +static unsigned fb_plane_min_stride (struct format_desc_struct *format, +unsigned width,int plane) {unsigned cpp = format->plane_bpp[plane] /8 ; -return planar_width (format, width, plane) * cpp; +return fb_plane_width (format, width, plane) * cpp; } -static unsigned planar_height (struct format_desc_struct *format,unsigned height,int plane) +static unsigned fb_plane_height (struct format_desc_struct *format, +unsigned height,int plane) {if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 )return DIV_ROUND_UP (height,2 );
@@ -229,7 +232,7 @@ static void calc_fb_size_planar(int fd, int width, int height,igt_get_fb_tile_size (fd, tiling, format->plane_bpp[plane], &tile_width, &tile_height); - plane_stride =ALIGN (planar_stride (format, width, plane), tile_width); + plane_stride =ALIGN (fb_plane_min_stride (format, width, plane), tile_width);if (max_stride < plane_stride) max_stride = plane_stride; }
@@ -243,7 +246,7 @@ static void calc_fb_size_planar(int fd, int width, int height,igt_get_fb_tile_size (fd, tiling, format->plane_bpp[plane], &tile_width, &tile_height); - *size_ret += stride *ALIGN (planar_height (format, height, plane), tile_height); + *size_ret += stride *ALIGN (fb_plane_height (format, height, plane), tile_height); }if (offsets)
@@ -258,7 +261,7 @@ static void calc_fb_size_packed(int fd, int width, int height, unsigned stride, unsigned *size_ret, unsigned *stride_ret) { unsigned int tile_width, tile_height, size; -int byte_width = width * (format->plane_bpp[0 ] /8 ); +int byte_width =fb_plane_min_stride (format, width,0 );igt_get_fb_tile_size (fd, tiling, format->plane_bpp[0 ], &tile_width, &tile_height);
@@ -885,8 +888,8 @@ igt_create_fb_with_bo_size(int fd, int width, int height,for (i =0 ; i < f->num_planes; i++) { fb->plane_bpp[i] = f->plane_bpp[i]; - fb->plane_height[i] =planar_height (f, height, i); - fb->plane_width[i] =planar_width (f, width, i); + fb->plane_height[i] =fb_plane_height (f, height, i); + fb->plane_width[i] =fb_plane_width (f, width, i); }return fb_id;
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 13/25 lib/igt_fb: Extract calc_plane_stride()
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Extract the stride calculation from calc_fb_size_packed() to its own thing so that we can use it to calculate just the stride.
--- lib/igt_fb.c | 53 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 13 deletions(-)
lib/igt_fb.c +40 -13
@@ -226,6 +226,38 @@ static int fb_num_planes(struct format_desc_struct *format)return format->num_planes; } +static unsigned calc_plane_stride (int fd, +struct format_desc_struct *format, +int width,uint64_t tiling,int plane) +{ +uint32_t min_stride =fb_plane_min_stride (format, width, plane); + +if (tiling !=LOCAL_DRM_FORMAT_MOD_NONE && +intel_gen (intel_get_drm_devid (fd)) <=3 ) { +uint32_t stride; + +/* Round the tiling up to the next power-of-two and the region +* up to the next pot fence size so that this works on all +* generations. +* +* This can still fail if the framebuffer is too large to be +* tiled. But then that failure is expected. +*/ +for (stride =512 ; stride < min_stride; stride *=2 ) + ; + +return stride; + }else { +unsigned int tile_width, tile_height; + +igt_get_fb_tile_size (fd, tiling, +fb_plane_bpp (format, plane), + &tile_width, &tile_height); + +return ALIGN (min_stride, tile_width); + } +} + static void calc_fb_size_planar(int fd, int width, int height, struct format_desc_struct *format, uint64_t tiling, unsigned stride,
@@ -272,11 +304,10 @@ static void calc_fb_size_packed(int fd, int width, int height, struct format_desc_struct *format, uint64_t tiling, unsigned stride, unsigned *size_ret, unsigned *stride_ret) { - unsigned int tile_width, tile_height, size; -int byte_width =fb_plane_min_stride (format, width,0 ); + unsigned int size; -igt_get_fb_tile_size (fd, tiling,fb_plane_bpp (format,0 ), - &tile_width, &tile_height); +if (!stride) + stride =calc_plane_stride (fd, format, width, tiling,0 );if (tiling !=LOCAL_DRM_FORMAT_MOD_NONE &&intel_gen (intel_get_drm_devid (fd)) <=3 ) {
@@ -289,19 +320,15 @@ static void calc_fb_size_packed(int fd, int width, int height,* This can still fail if the framebuffer is too large to be * tiled. But then that failure is expected. */ - -if (!stride) { - v = byte_width; -for (stride =512 ; stride < v; stride *=2 ) - ; - } - v = stride * height;for (size =1024 *1024 ; size < v; size *=2 ) ; }else { -if (!stride) - stride =ALIGN (byte_width, tile_width); +unsigned int tile_width, tile_height; + +igt_get_fb_tile_size (fd, tiling,fb_plane_bpp (format,0 ), + &tile_width, &tile_height); + size = stride *ALIGN (height, tile_height); }
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 15/25 lib/kms: Pass strides[] to __kms_addfb
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Make __kms_addfb() usable with planar formats by passing in the stride for each plane.
--- lib/igt_fb.c | 7 ++++++- lib/ioctl_wrappers.c | 12 +++++++----- lib/ioctl_wrappers.h | 8 +++++--- tests/kms_available_modes_crc.c | 14 +++++++------- tests/kms_draw_crc.c | 6 +++--- tests/prime_vgem.c | 8 ++++++-- 6 files changed, 34 insertions(+), 21 deletions(-)
lib/igt_fb.c +6 -1
@@ -877,8 +877,13 @@ igt_create_fb_with_bo_size(int fd, int width, int height,if (tiling !=LOCAL_DRM_FORMAT_MOD_NONE && tiling !=LOCAL_I915_FORMAT_MOD_X_TILED ) { +uint32_t pitches[4 ]; + +for (i =0 ; i <fb_num_planes (f); i++) + pitches[i] = fb->stride; +do_or_die (__kms_addfb (fd, fb->gem_handle, width, height, - fb->stride, format, tiling, fb->offsets, + format, tiling, pitches, fb->offsets,LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id)); }else {uint32_t handles[4 ];
lib/ioctl_wrappers.c +7 -5
@@ -1670,9 +1670,11 @@ void igt_require_fb_modifiers(int fd)igt_require (has_modifiers); } -int __kms_addfb (int fd,uint32_t handle,uint32_t width,uint32_t height, -uint32_t stride,uint32_t pixel_format,uint64_t modifier, -uint32_t *offsets,uint32_t flags,uint32_t *buf_id) +int __kms_addfb (int fd,uint32_t handle, +uint32_t width,uint32_t height, +uint32_t pixel_format,uint64_t modifier, +uint32_t strides[4 ],uint32_t offsets[4 ], +uint32_t flags,uint32_t *buf_id) {struct drm_mode_fb_cmd2 f;int ret, i;
@@ -1686,12 +1688,12 @@ int __kms_addfb(int fd, uint32_t handle, uint32_t width, uint32_t height, f.pixel_format = pixel_format; f.flags = flags; f.handles[0 ] = handle; - f.pitches[0 ] = stride; + f.pitches[0 ] = strides[0 ]; f.modifier[0 ] = modifier;for (i =1 ; i <4 && offsets && offsets[i]; i++) { f.handles[i] = handle; - f.pitches[i] = stride; + f.pitches[i] = strides[i]; f.modifier[i] = modifier; f.offsets[i] = offsets[i]; }
lib/ioctl_wrappers.h +5 -3
@@ -235,9 +235,11 @@ void igt_require_fb_modifiers(int fd);* * Creates a framebuffer object. */ -int __kms_addfb (int fd,uint32_t handle,uint32_t width,uint32_t height, -uint32_t stride,uint32_t pixel_format,uint64_t modifier, -uint32_t *offsets,uint32_t flags,uint32_t *buf_id); +int __kms_addfb (int fd,uint32_t handle, +uint32_t width,uint32_t height, +uint32_t pixel_format,uint64_t modifier, +uint32_t strides[4 ],uint32_t offsets[4 ], +uint32_t flags,uint32_t *buf_id);/** * to_user_pointer:
tests/kms_available_modes_crc.c +7 -7
@@ -255,7 +255,8 @@ static bool setup_fb(data_t *data, igt_output_t *output, igt_plane_t *plane,drmModeModeInfo *mode;uint64_t w, h;signed ret, gemsize =0 ; -unsigned tile_width, tile_height, stride; +unsigned tile_width, tile_height; +uint32_t strides[4 ] = {};uint32_t offsets[4 ] = {};uint64_t tiling;int bpp =0 ;
@@ -296,8 +297,8 @@ static bool setup_fb(data_t *data, igt_output_t *output, igt_plane_t *plane,igt_get_fb_tile_size (data->gfx_fd, tiling, bpp, &tile_width, &tile_height); - stride =ALIGN (w * bpp /8 , tile_width); - gemsize = data->size = stride *ALIGN (h, tile_height); + strides[0 ] =ALIGN (w * bpp /8 , tile_width); + gemsize = data->size = strides[0 ] *ALIGN (h, tile_height);if (fillers[i].bpp ==P010 || fillers[i].bpp ==NV12 ) { offsets[1 ] = data->size;
@@ -306,14 +307,13 @@ static bool setup_fb(data_t *data, igt_output_t *output, igt_plane_t *plane, data->gem_handle =gem_create (data->gfx_fd, gemsize); ret =__gem_set_tiling (data->gfx_fd, data->gem_handle, -igt_fb_mod_to_tiling (tiling), stride); +igt_fb_mod_to_tiling (tiling), strides[0 ]);igt_assert_eq (ret,0 ); ret =__kms_addfb (data->gfx_fd, data->gem_handle, w, h, - stride, format, tiling, - offsets,LOCAL_DRM_MODE_FB_MODIFIERS , - &data->fb.fb_id); + format, tiling, strides, offsets, +LOCAL_DRM_MODE_FB_MODIFIERS , &data->fb.fb_id);if (ret <0 ) { igt_info("Creating fb for format %s failed, return code %d\n",
tests/kms_draw_crc.c +3 -3
@@ -156,14 +156,14 @@ static void get_method_crc(enum igt_draw_method method, uint32_t drm_format,static bool format_is_supported (uint32_t format,uint64_t modifier) {uint32_t gem_handle, fb_id; -unsigned int stride; +unsigned int strides[4 ] = {};int ret; gem_handle =igt_create_bo_with_dimensions (drm_fd,64 ,64 , format, modifier, -0 ,NULL , &stride,NULL ); +0 ,NULL , &strides[0 ],NULL ); ret =__kms_addfb (drm_fd, gem_handle,64 ,64 , - stride, format, modifier,NULL , + format, modifier, strides,NULL ,LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id);drmModeRmFB (drm_fd, fb_id);gem_close (drm_fd, gem_handle);
tests/prime_vgem.c +6 -2
@@ -709,6 +709,7 @@ static void test_flip(int i915, int vgem, unsigned hang)signal (SIGHUP , sighandler);for (int i =0 ; i <2 ; i++) { +uint32_t strides[4 ] = {};int fd; bo[i].width =1024 ;
@@ -721,9 +722,12 @@ static void test_flip(int i915, int vgem, unsigned hang)igt_assert (handle[i]);close (fd); + strides[0 ] = bo[i].pitch; +do_or_die (__kms_addfb (i915, handle[i], - bo[i].width, bo[i].height, bo[i].pitch, -DRM_FORMAT_XRGB8888 ,I915_TILING_NONE ,NULL , + bo[i].width, bo[i].height, +DRM_FORMAT_XRGB8888 ,I915_TILING_NONE , + strides,NULL ,LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id[i]));igt_assert (fb_id[i]); }
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 11/25 lib/igt_fb: Add fb_plane_bpp()
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Add another helper to get the bpp for a specific color plane. We'll need this for ccs support later.
--- lib/igt_fb.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
lib/igt_fb.c +14 -6
@@ -199,10 +199,15 @@ static unsigned fb_plane_width(struct format_desc_struct *format,return width; } +static unsigned fb_plane_bpp (struct format_desc_struct *format,int plane) +{ +return format->plane_bpp[plane]; +} +static unsigned fb_plane_min_stride (struct format_desc_struct *format,unsigned width,int plane) { -unsigned cpp = format->plane_bpp[plane] /8 ; +unsigned cpp =fb_plane_bpp (format, plane) /8 ;return fb_plane_width (format, width, plane) * cpp; }
@@ -230,7 +235,8 @@ static void calc_fb_size_planar(int fd, int width, int height,for (plane =0 ; plane < format->num_planes; plane++) {unsigned plane_stride; -igt_get_fb_tile_size (fd, tiling, format->plane_bpp[plane], &tile_width, &tile_height); +igt_get_fb_tile_size (fd, tiling,fb_plane_bpp (format, plane), + &tile_width, &tile_height); plane_stride =ALIGN (fb_plane_min_stride (format, width, plane), tile_width);if (max_stride < plane_stride)
@@ -244,7 +250,8 @@ static void calc_fb_size_planar(int fd, int width, int height,if (offsets) offsets[plane] = *size_ret; -igt_get_fb_tile_size (fd, tiling, format->plane_bpp[plane], &tile_width, &tile_height); +igt_get_fb_tile_size (fd, tiling,fb_plane_bpp (format, plane), + &tile_width, &tile_height); *size_ret += stride *ALIGN (fb_plane_height (format, height, plane), tile_height); }
@@ -263,7 +270,8 @@ static void calc_fb_size_packed(int fd, int width, int height,unsigned int tile_width, tile_height, size;int byte_width =fb_plane_min_stride (format, width,0 ); -igt_get_fb_tile_size (fd, tiling, format->plane_bpp[0 ], &tile_width, &tile_height); +igt_get_fb_tile_size (fd, tiling,fb_plane_bpp (format,0 ), + &tile_width, &tile_height);if (tiling !=LOCAL_DRM_FORMAT_MOD_NONE &&intel_gen (intel_get_drm_devid (fd)) <=3 ) {
@@ -456,7 +464,7 @@ static int create_bo_for_fb(int fd, int width, int height, *is_dumb = true;return kmstest_dumb_create (fd, width, height, - format->plane_bpp[0 ], +fb_plane_bpp (format,0 ), stride_ret, size_ret); } }
@@ -887,7 +895,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height, fb->color_range = color_range;for (i =0 ; i < f->num_planes; i++) { - fb->plane_bpp[i] = f->plane_bpp[i]; + fb->plane_bpp[i] =fb_plane_bpp (f, i); fb->plane_height[i] =fb_plane_height (f, height, i); fb->plane_width[i] =fb_plane_width (f, width, i); }
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 12/25 lib/igt_fb: Add fb_num_planes()
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Add a helper to return the number of color planes. We'll need this for ccs support later.
--- lib/igt_fb.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
lib/igt_fb.c +12 -7
@@ -221,6 +221,11 @@ static unsigned fb_plane_height(struct format_desc_struct *format,return height; } +static int fb_num_planes (struct format_desc_struct *format) +{ +return format->num_planes; +} + static void calc_fb_size_planar(int fd, int width, int height, struct format_desc_struct *format, uint64_t tiling, unsigned stride,
@@ -232,7 +237,7 @@ static void calc_fb_size_planar(int fd, int width, int height, *size_ret =0 ; -for (plane =0 ; plane < format->num_planes; plane++) { +for (plane =0 ; plane <fb_num_planes (format); plane++) {unsigned plane_stride; igt_get_fb_tile_size(fd, tiling, fb_plane_bpp(format, plane),
@@ -246,7 +251,7 @@ static void calc_fb_size_planar(int fd, int width, int height,if (!stride) stride = max_stride; -for (plane =0 ; plane < format->num_planes; plane++) { +for (plane =0 ; plane <fb_num_planes (format); plane++) {if (offsets) offsets[plane] = *size_ret;
@@ -323,7 +328,7 @@ void igt_calc_fb_size(int fd, int width, int height, uint32_t drm_format, uint64struct format_desc_struct *format =lookup_drm_format (drm_format);igt_assert (format); -if (format->num_planes >1 ) +if (fb_num_planes (format) >1 )calc_fb_size_planar (fd, width, height, format, tiling,0 , size_ret, stride_ret,NULL );else calc_fb_size_packed (fd, width, height, format, tiling,0 , size_ret, stride_ret);
@@ -400,7 +405,7 @@ static int create_bo_for_fb(int fd, int width, int height,if (tiling || size || stride ||igt_format_is_yuv (format->drm_id)) {unsigned calculated_size, calculated_stride; -if (format->num_planes >1 ) +if (fb_num_planes (format) >1 )calc_fb_size_planar (fd, width, height, format, tiling, stride, &calculated_size, &calculated_stride, offsets);else
@@ -874,7 +879,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height, handles[0 ] = fb->gem_handle; pitches[0 ] = fb->stride; -for (i =0 ; i < f->num_planes; i++) { +for (i =0 ; i <fb_num_planes (f); i++) { handles[i] = fb->gem_handle; pitches[i] = fb->stride; }
@@ -890,11 +895,11 @@ igt_create_fb_with_bo_size(int fd, int width, int height, fb->drm_format = format; fb->fb_id = fb_id; fb->fd = fd; - fb->num_planes = f->num_planes; + fb->num_planes =fb_num_planes (f); fb->color_encoding = color_encoding; fb->color_range = color_range; -for (i =0 ; i < f->num_planes; i++) { +for (i =0 ; i <fb_num_planes (f); i++) { fb->plane_bpp[i] =fb_plane_bpp (f, i); fb->plane_height[i] =fb_plane_height (f, height, i); fb->plane_width[i] =fb_plane_width (f, width, i);
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 16/25 lib/kms: Pass the number of planes explicitly to __kms_addfb()
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Currently __kms_addfb() assumes that only the first plane can be at offset 0. I don't particularly like such assumptions so let's just pass in the number of planes explicitly.
We'll also require offsets[] to be passed in always. Nothing really to gain by making it optional.
--- lib/igt_fb.c | 1 + lib/ioctl_wrappers.c | 9 +++------ lib/ioctl_wrappers.h | 2 +- tests/kms_available_modes_crc.c | 5 ++++- tests/kms_draw_crc.c | 3 ++- tests/prime_vgem.c | 3 ++- 6 files changed, 13 insertions(+), 10 deletions(-)
lib/igt_fb.c +1 -0
@@ -884,6 +884,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height,do_or_die (__kms_addfb (fd, fb->gem_handle, width, height, format, tiling, pitches, fb->offsets, +fb_num_planes (f),LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id)); }else {uint32_t handles[4 ];
lib/ioctl_wrappers.c +3 -6
@@ -1674,7 +1674,7 @@ int __kms_addfb(int fd, uint32_t handle, uint32_t width, uint32_t height, uint32_t pixel_format, uint64_t modifier, uint32_t strides[4], uint32_t offsets[4], - uint32_t flags, uint32_t *buf_id) + int num_planes, uint32_t flags, uint32_t *buf_id) { struct drm_mode_fb_cmd2 f;int ret, i;
@@ -1687,14 +1687,11 @@ int __kms_addfb(int fd, uint32_t handle, f.height = height; f.pixel_format = pixel_format; f.flags = flags; - f.handles[0 ] = handle; - f.pitches[0 ] = strides[0 ]; - f.modifier[0 ] = modifier; -for (i =1 ; i <4 && offsets && offsets[i]; i++) { +for (i =0 ; i < num_planes; i++) { f.handles[i] = handle; - f.pitches[i] = strides[i]; f.modifier[i] = modifier; + f.pitches[i] = strides[i]; f.offsets[i] = offsets[i]; }
lib/ioctl_wrappers.h +1 -1
@@ -239,7 +239,7 @@ int __kms_addfb(int fd, uint32_t handle, uint32_t width, uint32_t height, uint32_t pixel_format, uint64_t modifier, uint32_t strides[4], uint32_t offsets[4], - uint32_t flags, uint32_t *buf_id); + int num_planes, uint32_t flags, uint32_t *buf_id);/** * to_user_pointer:
tests/kms_available_modes_crc.c +4 -1
@@ -258,6 +258,7 @@ static bool setup_fb(data_t *data, igt_output_t *output, igt_plane_t *plane,unsigned tile_width, tile_height;uint32_t strides[4 ] = {};uint32_t offsets[4 ] = {}; +int num_planes =1 ;uint64_t tiling;int bpp =0 ;int i;
@@ -303,6 +304,7 @@ static bool setup_fb(data_t *data, igt_output_t *output, igt_plane_t *plane,if (fillers[i].bpp ==P010 || fillers[i].bpp ==NV12 ) { offsets[1 ] = data->size; gemsize = data->size *2 ; + num_planes =2 ; } data->gem_handle =gem_create (data->gfx_fd, gemsize);
@@ -313,7 +315,8 @@ static bool setup_fb(data_t *data, igt_output_t *output, igt_plane_t *plane, ret =__kms_addfb (data->gfx_fd, data->gem_handle, w, h, format, tiling, strides, offsets, -LOCAL_DRM_MODE_FB_MODIFIERS , &data->fb.fb_id); + num_planes,LOCAL_DRM_MODE_FB_MODIFIERS , + &data->fb.fb_id);if (ret <0 ) { igt_info("Creating fb for format %s failed, return code %d\n",
tests/kms_draw_crc.c +2 -1
@@ -156,6 +156,7 @@ static void get_method_crc(enum igt_draw_method method, uint32_t drm_format,static bool format_is_supported (uint32_t format,uint64_t modifier) {uint32_t gem_handle, fb_id; +unsigned int offsets[4 ] = {};unsigned int strides[4 ] = {};int ret;
@@ -163,7 +164,7 @@ static bool format_is_supported(uint32_t format, uint64_t modifier) format, modifier, 0, NULL, &strides[0], NULL); ret =__kms_addfb (drm_fd, gem_handle,64 ,64 , - format, modifier, strides,NULL , + format, modifier, strides, offsets,1 ,LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id);drmModeRmFB (drm_fd, fb_id);gem_close (drm_fd, gem_handle);
tests/prime_vgem.c +2 -1
@@ -710,6 +710,7 @@ static void test_flip(int i915, int vgem, unsigned hang)for (int i =0 ; i <2 ; i++) {uint32_t strides[4 ] = {}; +uint32_t offsets[4 ] = {};int fd; bo[i].width =1024 ;
@@ -727,7 +728,7 @@ static void test_flip(int i915, int vgem, unsigned hang)do_or_die (__kms_addfb (i915, handle[i], bo[i].width, bo[i].height,DRM_FORMAT_XRGB8888 ,I915_TILING_NONE , - strides,NULL , + strides, offsets,1 ,LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id[i]));igt_assert (fb_id[i]); }
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 17/25 lib/igt_fb: Remove the hand rolled addfb2
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Just use __kms_addfb() always instead of hand rolling another drmModeAddFB2() usage. __kms_addfb() demands support for modifiers but we've had that for a long time now so it's not a problem.
--- lib/igt_fb.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-)
lib/igt_fb.c +7 -28
@@ -856,6 +856,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height,enum igt_color_encoding color_encoding =IGT_COLOR_YCBCR_BT709 ;enum igt_color_range color_range =IGT_COLOR_YCBCR_LIMITED_RANGE ;struct format_desc_struct *f =lookup_drm_format (format); +uint32_t pitches[4 ];uint32_t fb_id;int i;
@@ -875,35 +876,13 @@ igt_create_fb_with_bo_size(int fd, int width, int height,igt_debug ("%s(handle=%d, pitch=%d)\n" , __func__, fb->gem_handle, fb->stride); -if (tiling !=LOCAL_DRM_FORMAT_MOD_NONE && - tiling !=LOCAL_I915_FORMAT_MOD_X_TILED ) { -uint32_t pitches[4 ]; - -for (i =0 ; i <fb_num_planes (f); i++) - pitches[i] = fb->stride; - -do_or_die (__kms_addfb (fd, fb->gem_handle, width, height, - format, tiling, pitches, fb->offsets, -fb_num_planes (f), -LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id)); - }else { -uint32_t handles[4 ]; -uint32_t pitches[4 ]; +for (i =0 ; i <fb_num_planes (f); i++) + pitches[i] = fb->stride; -memset (handles,0 ,sizeof (handles)); -memset (pitches,0 ,sizeof (pitches)); - - handles[0 ] = fb->gem_handle; - pitches[0 ] = fb->stride; -for (i =0 ; i <fb_num_planes (f); i++) { - handles[i] = fb->gem_handle; - pitches[i] = fb->stride; - } - -do_or_die (drmModeAddFB2 (fd, width, height, format, - handles, pitches, fb->offsets, - &fb_id,0 )); - } +do_or_die (__kms_addfb (fd, fb->gem_handle, width, height, + format, tiling, pitches, fb->offsets, +fb_num_planes (f), +LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id)); fb->width = width; fb->height = height;
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 18/25 lib/igt_fb: Constify format_desc_struct
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
We don't want anyone to modify the format description structures. Make them const.
--- lib/igt_fb.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-)
lib/igt_fb.c +22 -22
@@ -60,7 +60,7 @@*/ /* drm fourcc/cairo format maps */ -static struct format_desc_struct { +static const struct format_desc_struct { const char *name; uint32_t drm_id; cairo_format_t cairo_id;
@@ -108,9 +108,9 @@ static struct format_desc_struct {#define for_each_format (f) \ for (f = format_desc; f - format_desc < ARRAY_SIZE(format_desc); f++) -static struct format_desc_struct *lookup_drm_format (uint32_t drm_format) +static const struct format_desc_struct *lookup_drm_format (uint32_t drm_format) { -struct format_desc_struct *format; +const struct format_desc_struct *format;for_each_format (format) {if (format->drm_id != drm_format)
@@ -190,8 +190,8 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, } } -static unsigned fb_plane_width (struct format_desc_struct *format, -unsigned width,int plane) +static unsigned fb_plane_width (const struct format_desc_struct *format, +int plane,unsigned width) {if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 )return DIV_ROUND_UP (width,2 );
@@ -199,21 +199,21 @@ static unsigned fb_plane_width(struct format_desc_struct *format,return width; } -static unsigned fb_plane_bpp (struct format_desc_struct *format,int plane) +static unsigned fb_plane_bpp (const struct format_desc_struct *format,int plane) {return format->plane_bpp[plane]; } -static unsigned fb_plane_min_stride (struct format_desc_struct *format, -unsigned width,int plane) +static unsigned fb_plane_min_stride (const struct format_desc_struct *format, +int plane,unsigned width) {unsigned cpp =fb_plane_bpp (format, plane) /8 ;return fb_plane_width (format, width, plane) * cpp; } -static unsigned fb_plane_height (struct format_desc_struct *format, -unsigned height,int plane) +static unsigned fb_plane_height (const struct format_desc_struct *format, +int plane,unsigned height) {if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 )return DIV_ROUND_UP (height,2 );
@@ -221,13 +221,13 @@ static unsigned fb_plane_height(struct format_desc_struct *format,return height; } -static int fb_num_planes (struct format_desc_struct *format) +static int fb_num_planes (const struct format_desc_struct *format) {return format->num_planes; }static unsigned calc_plane_stride (int fd, -struct format_desc_struct *format, +const struct format_desc_struct *format,int width,uint64_t tiling,int plane) {uint32_t min_stride =fb_plane_min_stride (format, width, plane);
@@ -259,7 +259,7 @@ static unsigned calc_plane_stride(int fd, }static unsigned calc_plane_size (int fd,int width,int height, -struct format_desc_struct *format, +const struct format_desc_struct *format,uint64_t tiling,int plane,uint32_t stride) {
@@ -290,7 +290,7 @@ static unsigned calc_plane_size(int fd, int width, int height, }static unsigned calc_fb_size (int fd,int width,int height, -struct format_desc_struct *format, +const struct format_desc_struct *format,uint64_t tiling,uint32_t strides[4 ],uint32_t offsets[4 ]) {
@@ -335,7 +335,7 @@ static unsigned calc_fb_size(int fd, int width, int height,void igt_calc_fb_size (int fd,int width,int height,uint32_t drm_format,uint64_t tiling,unsigned *size_ret,unsigned *stride_ret) { -struct format_desc_struct *format =lookup_drm_format (drm_format); +const struct format_desc_struct *format =lookup_drm_format (drm_format);uint32_t strides[4 ] = {};igt_assert (format);
@@ -400,7 +400,7 @@ uint64_t igt_fb_tiling_to_mod(uint64_t tiling)static int create_bo_for_fb (int fd,int width,int height,enum igt_color_encoding color_encoding,enum igt_color_range color_range, -struct format_desc_struct *format, +const struct format_desc_struct *format,uint64_t tiling,unsigned size,unsigned stride,unsigned *size_ret,unsigned *stride_ret,uint32_t offsets[4 ],bool *is_dumb)
@@ -855,7 +855,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height,/* FIXME allow the caller to pass these in */ enum igt_color_encoding color_encoding =IGT_COLOR_YCBCR_BT709 ;enum igt_color_range color_range =IGT_COLOR_YCBCR_LIMITED_RANGE ; -struct format_desc_struct *f =lookup_drm_format (format); +const struct format_desc_struct *f =lookup_drm_format (format);uint32_t pitches[4 ];uint32_t fb_id;int i;
@@ -1195,7 +1195,7 @@ unsigned int igt_create_stereo_fb(int drm_fd, drmModeModeInfo *mode,static cairo_format_t drm_format_to_cairo (uint32_t drm_format) { -struct format_desc_struct *f; +const struct format_desc_struct *f;for_each_format (f)if (f->drm_id == drm_format)
@@ -1953,7 +1953,7 @@ void igt_remove_fb(int fd, struct igt_fb *fb)*/ uint32_t igt_bpp_depth_to_drm_format (int bpp,int depth) { -struct format_desc_struct *f; +const struct format_desc_struct *f;for_each_format (f)if (f->plane_bpp[0 ] == bpp && f->depth == depth)
@@ -1974,7 +1974,7 @@ uint32_t igt_bpp_depth_to_drm_format(int bpp, int depth)*/ uint32_t igt_drm_format_to_bpp (uint32_t drm_format) { -struct format_desc_struct *f =lookup_drm_format (drm_format); +const struct format_desc_struct *f =lookup_drm_format (drm_format);igt_assert_f (f,"can't find a bpp format for %08x (%s)\n" , drm_format,igt_format_str (drm_format));
@@ -1992,7 +1992,7 @@ uint32_t igt_drm_format_to_bpp(uint32_t drm_format)*/ const char *igt_format_str (uint32_t drm_format) { -struct format_desc_struct *f =lookup_drm_format (drm_format); +const struct format_desc_struct *f =lookup_drm_format (drm_format);return f ? f->name :"invalid" ; }
@@ -2006,7 +2006,7 @@ const char *igt_format_str(uint32_t drm_format)*/ bool igt_fb_supported_format (uint32_t drm_format) { -struct format_desc_struct *f; +const struct format_desc_struct *f;for_each_format (f)if (f->drm_id == drm_format)
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 14/25 lib/igt_fb: Consolidate fb size calculation to one function
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Eliminate the planar vs. packed size calculation differences and just use one function for the entire thing.
--- lib/igt_fb.c | 131 ++++++++++++++++++++++++++--------------------------------- 1 file changed, 57 insertions(+), 74 deletions(-)
lib/igt_fb.c +57 -74
@@ -258,60 +258,15 @@ static unsigned calc_plane_stride(int fd, } } -static void calc_fb_size_planar (int fd,int width,int height, +static unsigned calc_plane_size (int fd,int width,int height,struct format_desc_struct *format, -uint64_t tiling,unsigned stride, -unsigned *size_ret,unsigned *stride_ret, -unsigned *offsets) +uint64_t tiling,int plane, +uint32_t stride) { -int plane; -unsigned max_stride =0 , tile_width, tile_height; - - *size_ret =0 ; - -for (plane =0 ; plane <fb_num_planes (format); plane++) { -unsigned plane_stride; - -igt_get_fb_tile_size (fd, tiling,fb_plane_bpp (format, plane), - &tile_width, &tile_height); - - plane_stride =ALIGN (fb_plane_min_stride (format, width, plane), tile_width); -if (max_stride < plane_stride) - max_stride = plane_stride; - } - -if (!stride) - stride = max_stride; - -for (plane =0 ; plane <fb_num_planes (format); plane++) { -if (offsets) - offsets[plane] = *size_ret; - -igt_get_fb_tile_size (fd, tiling,fb_plane_bpp (format, plane), - &tile_width, &tile_height); - - *size_ret += stride *ALIGN (fb_plane_height (format, height, plane), tile_height); - } - -if (offsets) -for (; plane <ARRAY_SIZE (format->plane_bpp); plane++) - offsets[plane] =0 ; - - *stride_ret = stride; -} - -static void calc_fb_size_packed (int fd,int width,int height, -struct format_desc_struct *format,uint64_t tiling, -unsigned stride,unsigned *size_ret,unsigned *stride_ret) -{ -unsigned int size; - -if (!stride) - stride =calc_plane_stride (fd, format, width, tiling,0 ); -if (tiling !=LOCAL_DRM_FORMAT_MOD_NONE &&intel_gen (intel_get_drm_devid (fd)) <=3 ) { -int v; +unsigned int min_size = stride * height; +unsigned int size;/* Round the tiling up to the next power-of-two and the region * up to the next pot fence size so that this works on all
@@ -320,20 +275,48 @@ static void calc_fb_size_packed(int fd, int width, int height,* This can still fail if the framebuffer is too large to be * tiled. But then that failure is expected. */ - v = stride * height; -for (size =1024 *1024 ; size < v; size *=2 ) +for (size =1024 *1024 ; size < min_size; size *=2 ) ; + +return size; }else {unsigned int tile_width, tile_height; -igt_get_fb_tile_size (fd, tiling,fb_plane_bpp (format,0 ), +igt_get_fb_tile_size (fd, tiling,fb_plane_bpp (format, plane), &tile_width, &tile_height); - size = stride *ALIGN (height, tile_height); +return stride *ALIGN (height, tile_height); } +} + +static unsigned calc_fb_size (int fd,int width,int height, +struct format_desc_struct *format, +uint64_t tiling, +uint32_t strides[4 ],uint32_t offsets[4 ]) +{ +unsigned int size =0 ; +int plane; + +for (plane =0 ; plane <fb_num_planes (format); plane++) { +if (!strides[plane]) + strides[plane] =calc_plane_stride (fd, format, + width, tiling, plane); - *stride_ret = stride; - *size_ret = size; +if (offsets) + offsets[plane] = size; + + size +=calc_plane_size (fd, width, height, + format, tiling, plane, + strides[plane]); + } + +for (; plane <ARRAY_SIZE (format->plane_bpp); plane++) { + strides[plane] =0 ; +if (offsets) + offsets[plane] =0 ; + } + +return size; }/**
@@ -353,12 +336,12 @@ void igt_calc_fb_size(int fd, int width, int height, uint32_t drm_format, uint64 unsigned *size_ret, unsigned *stride_ret) { struct format_desc_struct *format = lookup_drm_format(drm_format); +uint32_t strides[4 ] = {}; +igt_assert (format); -if (fb_num_planes (format) >1 ) -calc_fb_size_planar (fd, width, height, format, tiling,0 , size_ret, stride_ret,NULL ); -else -calc_fb_size_packed (fd, width, height, format, tiling,0 , size_ret, stride_ret); + *size_ret =calc_fb_size (fd, width, height, format, tiling, strides,NULL ); + *stride_ret = strides[0 ]; }/**
@@ -420,7 +403,7 @@ static int create_bo_for_fb(int fd, int width, int height,struct format_desc_struct *format, uint64_t tiling, unsigned size, unsigned stride, unsigned *size_ret, unsigned *stride_ret, - uint32_t *offsets, bool *is_dumb) + uint32_t offsets[4], bool *is_dumb) { int bo;
@@ -430,17 +413,17 @@ static int create_bo_for_fb(int fd, int width, int height,memset (offsets,0 ,ARRAY_SIZE (format->plane_bpp) *sizeof (*offsets));if (tiling || size || stride ||igt_format_is_yuv (format->drm_id)) { -unsigned calculated_size, calculated_stride; +unsigned calculated_size; +uint32_t strides[4 ] = { + stride, + }; -if (fb_num_planes (format) >1 ) -calc_fb_size_planar (fd, width, height, format, tiling, stride, - &calculated_size, &calculated_stride, offsets); -else -calc_fb_size_packed (fd, width, height, format, tiling, stride, - &calculated_size, &calculated_stride); + calculated_size =calc_fb_size (fd, width, height, + format, tiling, + strides, offsets);if (stride ==0 ) - stride = calculated_stride; + stride = strides[0 ];if (size ==0 ) size = calculated_size;
@@ -461,19 +444,19 @@ static int create_bo_for_fb(int fd, int width, int height,switch (format->drm_id) {case DRM_FORMAT_NV12 :memset (ptr + offsets[0 ], full_range ?0x00 :0x10 , - calculated_stride * height); + strides[0 ] * height);memset (ptr + offsets[1 ],0x80 , - calculated_stride * height/2 ); + strides[1 ] * height/2 );break ;case DRM_FORMAT_YUYV :case DRM_FORMAT_YVYU :wmemset (ptr, full_range ?0x80008000 :0x80108010 , - calculated_stride * height /sizeof (wchar_t)); + strides[0 ] * height /sizeof (wchar_t));break ;case DRM_FORMAT_UYVY :case DRM_FORMAT_VYUY :wmemset (ptr, full_range ?0x00800080 :0x10801080 , - calculated_stride * height /sizeof (wchar_t)); + strides[0 ] * height /sizeof (wchar_t));break ; }gem_munmap (ptr, size);
@@ -482,7 +465,7 @@ static int create_bo_for_fb(int fd, int width, int height, *size_ret = size;if (stride_ret) - *stride_ret = stride; + *stride_ret = strides[0 ];return bo; }else {
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 20/25 lib/igt_fb: Refactor blitter usage
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Deduplicate the blitter code.
--- lib/igt_fb.c | 62 ++++++++++++++++++++++++++++-------------------------------- 1 file changed, 29 insertions(+), 33 deletions(-)
lib/igt_fb.c +29 -33
@@ -1206,32 +1206,44 @@ struct fb_blit_upload {struct fb_blit_linear linear; }; +static void blitcopy (const struct igt_fb *dst_fb, +const struct igt_fb *src_fb) +{ +igt_assert_eq (dst_fb->fd, src_fb->fd); +igt_assert_eq (dst_fb->num_planes, src_fb->num_planes); + +for (int i =0 ; i < dst_fb->num_planes; i++) { +igt_assert_eq (dst_fb->plane_bpp[i], src_fb->plane_bpp[i]); +igt_assert_eq (dst_fb->plane_width[i], src_fb->plane_width[i]); +igt_assert_eq (dst_fb->plane_height[i], src_fb->plane_height[i]); + +igt_blitter_fast_copy__raw (dst_fb->fd, + src_fb->gem_handle, + src_fb->offsets[i], + src_fb->strides[i], +igt_fb_mod_to_tiling (src_fb->tiling), +0 ,0 ,/* src_x, src_y */ + dst_fb->plane_width[i], dst_fb->plane_height[i], + dst_fb->plane_bpp[i], + dst_fb->gem_handle, + dst_fb->offsets[i], + dst_fb->strides[i], +igt_fb_mod_to_tiling (dst_fb->tiling), +0 ,0 /* dst_x, dst_y */ ); + } +} +static void free_linear_mapping (struct fb_blit_upload *blit) {int fd = blit->fd;struct igt_fb *fb = blit->fb;struct fb_blit_linear *linear = &blit->linear; -unsigned int obj_tiling =igt_fb_mod_to_tiling (fb->tiling); -int i;gem_munmap (linear->map, linear->fb.size);gem_set_domain (fd, linear->fb.gem_handle,I915_GEM_DOMAIN_GTT ,0 ); -for (i =0 ; i < fb->num_planes; i++) -igt_blitter_fast_copy__raw (fd, - linear->fb.gem_handle, - linear->fb.offsets[i], - linear->fb.strides[i], -I915_TILING_NONE , -0 ,0 ,/* src_x, src_y */ - fb->plane_width[i], fb->plane_height[i], - fb->plane_bpp[i], - fb->gem_handle, - fb->offsets[i], - fb->strides[i], - obj_tiling, -0 ,0 /* dst_x, dst_y */ ); +blitcopy (fb, &linear->fb);gem_sync (fd, linear->fb.gem_handle);gem_close (fd, linear->fb.gem_handle);
@@ -1250,9 +1262,6 @@ static void destroy_cairo_surface__blit(void *arg)static void setup_linear_mapping (int fd,struct igt_fb *fb,struct fb_blit_linear *linear) { -unsigned int obj_tiling =igt_fb_mod_to_tiling (fb->tiling); -int i; -/* * We create a linear BO that we'll map for the CPU to write to (using * cairo). This linear bo will be then blitted to its final
@@ -1271,20 +1280,7 @@ static void setup_linear_mapping(int fd, struct igt_fb *fb, struct fb_blit_lineagem_set_domain (fd, linear->fb.gem_handle,I915_GEM_DOMAIN_GTT ,0 ); -for (i =0 ; i < fb->num_planes; i++) -igt_blitter_fast_copy__raw (fd, - fb->gem_handle, - fb->offsets[i], - fb->strides[i], - obj_tiling, -0 ,0 ,/* src_x, src_y */ - fb->plane_width[i], fb->plane_height[i], - fb->plane_bpp[i], - linear->fb.gem_handle, - linear->fb.offsets[i], - linear->fb.strides[i], -I915_TILING_NONE , -0 ,0 /* dst_x, dst_y */ ); +blitcopy (&linear->fb, fb);gem_sync (fd, linear->fb.gem_handle);
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 21/25 lib/igt_fb: Don't use blitter for large buffers
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
The blitter stride is limited to <32k. Fall back to gtt mmap if we're about to exceed that.
--- lib/igt_fb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
lib/igt_fb.c +6 -4
@@ -1786,8 +1786,9 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb) blit->rgb24.map =mmap (NULL , blit->rgb24.size,PROT_READ |PROT_WRITE ,MAP_PRIVATE |MAP_ANONYMOUS ,-1 ,0 );igt_assert (blit->rgb24.map !=MAP_FAILED ); -if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || - fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) { +if ((fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || + fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) && + fb->strides[0 ] <32768 ) {setup_linear_mapping (fd, fb, &blit->base.linear); }else { blit->base.linear.fb.gem_handle =0 ;
@@ -1842,8 +1843,9 @@ cairo_surface_t *igt_get_cairo_surface(int fd, struct igt_fb *fb)if (fb->cairo_surface ==NULL ) {if (igt_format_is_yuv (fb->drm_format))create_cairo_surface__convert (fd, fb); -else if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || - fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) +else if ((fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || + fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) && + fb->strides[0 ] <32768 )create_cairo_surface__blit (fd, fb);else create_cairo_surface__gtt (fd, fb);
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 22/25 lib/rendercopy: Add support for Yf/Ys tiling to gen9 rendercopy
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Set up the surface state accordingly to support Yf/Ys tiling.
--- lib/gen8_render.h | 6 ++++-- lib/rendercopy_gen9.c | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-)
lib/gen8_render.h +4 -2
@@ -121,9 +121,11 @@ struct gen8_surface_statestruct {uint32_t mip_count:4 ;uint32_t min_lod:4 ; -uint32_t pad3:6 ; +uint32_t mip_tail_start_lod:4 ;/* gen9+ */ +uint32_t pad3:2 ;uint32_t coherency_type:1 ; -uint32_t pad2:5 ; +uint32_t pad2:3 ; +uint32_t trmode:2 ;/* gen9+ */ uint32_t ewa_disable_for_cube:1 ;uint32_t y_offset:3 ;uint32_t pad0:1 ;
lib/rendercopy_gen9.c +7 -1
@@ -168,9 +168,15 @@ gen8_bind_buf(struct intel_batchbuffer *batch, const struct igt_buf *buf, ss->ss0.horizontal_alignment =1 ;/* align 4 */ if (buf->tiling ==I915_TILING_X ) ss->ss0.tiled_mode =2 ; -else if (buf->tiling ==I915_TILING_Y ) +else if (buf->tiling !=I915_TILING_NONE ) ss->ss0.tiled_mode =3 ; +if (buf->tiling == I915_TILING_Yf) + ss->ss5.trmode =1 ; +else if (buf->tiling == I915_TILING_Ys) + ss->ss5.trmode =2 ; + ss->ss5.mip_tail_start_lod =1 ;/* needed with trmode */ + ss->ss8.base_addr = buf->bo->offset64; ss->ss9.base_addr_hi = buf->bo->offset64 >>32 ;
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 23/25 tests/gem_render_copy: Test Yf tiling
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Let's test Yf tiling now that rendercopy can handle it.
--- tests/gem_render_copy.c | 245 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 194 insertions(+), 51 deletions(-)
tests/gem_render_copy.c +194 -51
@@ -72,11 +72,85 @@ static const char *make_filename(const char *filename)return buf; } -static void *linear_copy (data_t *data,struct igt_buf *buf) +static void *yf_ptr (void *ptr, +unsigned int x,unsigned int y, +unsigned int stride,unsigned int cpp) { -void *map, *linear; + x *= cpp; + +return ptr + + ((y & ~0x1f ) * stride) + + ((y &0x10 ) *64 ) + + ((y &0x8 ) *32 ) + + ((y &0x7 ) *16 ) + + ((x & ~0x3f ) *32 ) + + ((x &0x20 ) *16 ) + + ((x &0x10 ) *8 ) + + (x &0xf ); +} -igt_assert_eq (posix_memalign (&linear,16 , buf->bo->size),0 ); +static void copy_linear_to_yf (data_t *data,struct igt_buf *buf,const uint32_t *linear) +{ +int height =igt_buf_height (buf); +int width =igt_buf_width (buf); +void *map; + +gem_set_domain (data->drm_fd, buf->bo->handle, +I915_GEM_DOMAIN_CPU ,I915_GEM_DOMAIN_CPU ); + map =gem_mmap__cpu (data->drm_fd, buf->bo->handle,0 , + buf->bo->size,PROT_READ |PROT_WRITE ); + +for (int y =0 ; y < height; y++) { +for (int x =0 ; x < width; x++) { +uint32_t *ptr =yf_ptr (map, x, y, buf->stride,4 ); + + *ptr = linear[y * width + x]; + } + } + +munmap (map, buf->bo->size); +} + +static void copy_yf_to_linear (data_t *data,struct igt_buf *buf,uint32_t *linear) +{ +int height =igt_buf_height (buf); +int width =igt_buf_width (buf); +void *map; + +gem_set_domain (data->drm_fd, buf->bo->handle, +I915_GEM_DOMAIN_CPU ,0 ); + map =gem_mmap__cpu (data->drm_fd, buf->bo->handle,0 , + buf->bo->size,PROT_READ ); + +for (int y =0 ; y < height; y++) { +for (int x =0 ; x < width; x++) { +uint32_t *ptr =yf_ptr (map, x, y, buf->stride,4 ); + + linear[y * width + x] = *ptr; + } + } + +munmap (map, buf->bo->size); +} + +static void copy_linear_to_gtt (data_t *data,struct igt_buf *buf,const uint32_t *linear) +{ +void *map; + +gem_set_domain (data->drm_fd, buf->bo->handle, +I915_GEM_DOMAIN_GTT ,I915_GEM_DOMAIN_GTT ); + + map =gem_mmap__gtt (data->drm_fd, buf->bo->handle, + buf->bo->size,PROT_READ |PROT_WRITE ); + +memcpy (map, linear, buf->bo->size); + +munmap (map, buf->bo->size); +} + +static void copy_gtt_to_linear (data_t *data,struct igt_buf *buf,uint32_t *linear) +{ +void *map;gem_set_domain (data->drm_fd, buf->bo->handle,I915_GEM_DOMAIN_GTT ,0 );
@@ -87,6 +161,18 @@ static void *linear_copy(data_t *data, struct igt_buf *buf)igt_memcpy_from_wc (linear, map, buf->bo->size);munmap (map, buf->bo->size); +} + +static void *linear_copy (data_t *data,struct igt_buf *buf) +{ +void *linear; + +igt_assert_eq (posix_memalign (&linear,16 , buf->bo->size),0 ); + +if (buf->tiling == I915_TILING_Yf) +copy_yf_to_linear (data, buf, linear); +else +copy_gtt_to_linear (data, buf, linear);return linear; }
@@ -175,7 +261,7 @@ static void scratch_buf_draw_pattern(data_t *data, struct igt_buf *buf,cairo_surface_t *surface;cairo_pattern_t *pat;cairo_t *cr; -void *map, *linear; +void *linear; linear =linear_copy (data, buf);
@@ -218,15 +304,10 @@ static void scratch_buf_draw_pattern(data_t *data, struct igt_buf *buf,cairo_surface_destroy (surface); -gem_set_domain (data->drm_fd, buf->bo->handle, -I915_GEM_DOMAIN_GTT ,I915_GEM_DOMAIN_GTT ); - - map =gem_mmap__gtt (data->drm_fd, buf->bo->handle, - buf->bo->size,PROT_READ |PROT_WRITE ); - -memcpy (map, linear, buf->bo->size); - -munmap (map, buf->bo->size); +if (buf->tiling == I915_TILING_Yf) +copy_linear_to_yf (data, buf, linear); +else +copy_linear_to_gtt (data, buf, linear);free (linear); }
@@ -238,36 +319,59 @@ scratch_buf_copy(data_t *data, {int width =igt_buf_width (dst);int height =igt_buf_height (dst); -uint32_t *linear_dst, *linear_src; +uint32_t *linear_dst;igt_assert_eq (igt_buf_width (dst),igt_buf_width (src));igt_assert_eq (igt_buf_height (dst),igt_buf_height (src));igt_assert_eq (dst->bo->size, src->bo->size); + w =min (w, width - sx); + w =min (w, width - dx); + + h =min (h, height - sy); + h =min (h, height - dy); +gem_set_domain (data->drm_fd, dst->bo->handle,I915_GEM_DOMAIN_GTT ,I915_GEM_DOMAIN_GTT ); -gem_set_domain (data->drm_fd, src->bo->handle, -I915_GEM_DOMAIN_GTT ,0 ); - linear_dst =gem_mmap__gtt (data->drm_fd, dst->bo->handle, dst->bo->size,PROT_WRITE ); - linear_src =gem_mmap__gtt (data->drm_fd, src->bo->handle, - src->bo->size,PROT_READ ); - w =min (w, width - sx); - w =min (w, width - dx); +if (src->tiling == I915_TILING_Yf) { +void *map; - h =min (h, height - sy); - h =min (h, height - dy); +gem_set_domain (data->drm_fd, src->bo->handle, +I915_GEM_DOMAIN_CPU ,0 ); + map =gem_mmap__cpu (data->drm_fd, src->bo->handle,0 , + src->bo->size,PROT_READ ); + +for (int y =0 ; y < h; y++) { +for (int x =0 ; x < w; x++) { +const uint32_t *ptr =yf_ptr (map, sx+x, sy+y, src->stride,4 ); + + linear_dst[(dy+y) * width + dx+x] = *ptr; + } + } + +munmap (map, src->bo->size); + }else { +uint32_t *linear_src; + +gem_set_domain (data->drm_fd, src->bo->handle, +I915_GEM_DOMAIN_GTT ,0 ); -for (int y =0 ; y < h; y++) { -igt_memcpy_from_wc (&linear_dst[(dy+y) * width + dx], - &linear_src[(sy+y) * width + sx], - w *4 ); + linear_src =gem_mmap__gtt (data->drm_fd, src->bo->handle, + src->bo->size,PROT_READ ); + +for (int y =0 ; y < h; y++) { +igt_memcpy_from_wc (&linear_dst[(dy+y) * width + dx], + &linear_src[(sy+y) * width + sx], + w *4 ); + } + +munmap (linear_src, src->bo->size); }munmap (linear_dst, dst->bo->size); -munmap (linear_src, src->bo->size); } static void scratch_buf_init(data_t *data, struct igt_buf *buf,
@@ -284,7 +388,8 @@ static void scratch_buf_init(data_t *data, struct igt_buf *buf,int size;igt_require (intel_gen (data->devid) >=9 ); -igt_assert_eq (tiling,I915_TILING_Y ); +igt_assert (tiling ==I915_TILING_Y || + tiling == I915_TILING_Yf); buf->stride =ALIGN (width *4 ,128 ); buf->size = buf->stride * height;
@@ -300,8 +405,20 @@ static void scratch_buf_init(data_t *data, struct igt_buf *buf, buf->bo =drm_intel_bo_alloc (data->bufmgr,"" , size,4096 ); -drm_intel_bo_set_tiling (buf->bo, &tiling, buf->stride); -igt_assert_eq (tiling, req_tiling); +if (tiling ==I915_TILING_Y ) { +drm_intel_bo_set_tiling (buf->bo, &tiling, buf->stride); +igt_assert_eq (tiling, req_tiling); + } + }else if (req_tiling == I915_TILING_Yf) { +int size; + + buf->stride =ALIGN (width *4 ,128 ); + buf->size = buf->stride * height; + buf->tiling = tiling; + + size = buf->stride *ALIGN (height,32 ); + + buf->bo =drm_intel_bo_alloc (data->bufmgr,"" , size,4096 ); }else { buf->bo = drm_intel_bo_alloc_tiled(data->bufmgr, "", width, height, 4,
@@ -396,7 +513,7 @@ static void scratch_buf_aux_check(data_t *data, "Aux surface indicates that nothing was compressed\n"); } -static void test (data_t *data,uint32_t tiling,bool test_ccs) +static void test (data_t *data,uint32_t tiling,uint64_t ccs_modifier) {struct igt_buf dst, ccs, ref;struct {
@@ -404,7 +521,7 @@ static void test(data_t *data, uint32_t tiling, bool test_ccs)const char *filename;uint32_t tiling;int x, y; - } src[3] = { + } src[] = { { .filename = "source-linear.png", .tiling = I915_TILING_NONE,
@@ -420,18 +537,31 @@ static void test(data_t *data, uint32_t tiling, bool test_ccs) .tiling = I915_TILING_Y, .x = WIDTH/2+1, .y = 1, }, + { + .filename = "source-yf-tiled.png", + .tiling = I915_TILING_Yf, + .x = 1, .y = 1, + }, };int opt_dump_aub =igt_aub_dump_enabled (); +int num_src =ARRAY_SIZE (src); + +/* no Yf before gen9 */ +if (intel_gen (data->devid) <9 ) + num_src--; + +if (tiling == I915_TILING_Yf || ccs_modifier) +igt_require (intel_gen (data->devid) >=9 ); -for (int i =0 ; i <ARRAY_SIZE (src); i++) +for (int i =0 ; i < num_src; i++)scratch_buf_init (data, &src[i].buf,WIDTH ,HEIGHT , src[i].tiling, false);scratch_buf_init (data, &dst,WIDTH ,HEIGHT , tiling, false); -if (test_ccs) -scratch_buf_init (data, &ccs,WIDTH ,HEIGHT ,I915_TILING_Y , true); +if (ccs_modifier) +scratch_buf_init (data, &ccs,WIDTH ,HEIGHT , ccs_modifier, true);scratch_buf_init (data, &ref,WIDTH ,HEIGHT ,I915_TILING_NONE , false); -for (int i =0 ; i <ARRAY_SIZE (src); i++) +for (int i =0 ; i < num_src; i++)scratch_buf_draw_pattern (data, &src[i].buf,0 ,0 ,WIDTH ,HEIGHT ,0 ,0 ,WIDTH ,HEIGHT , true);
@@ -442,13 +572,13 @@ static void test(data_t *data, uint32_t tiling, bool test_ccs)scratch_buf_copy (data, &dst,0 ,0 ,WIDTH ,HEIGHT , &ref,0 ,0 ); -for (int i =0 ; i <ARRAY_SIZE (src); i++) +for (int i =0 ; i < num_src; i++)scratch_buf_copy (data, &src[i].buf,WIDTH /4 ,HEIGHT /4 ,WIDTH /2 -2 ,HEIGHT /2 -2 , &ref, src[i].x, src[i].y);if (opt_dump_png) { -for (int i =0 ; i <ARRAY_SIZE (src); i++) +for (int i =0 ; i < num_src; i++)scratch_buf_write_to_png (data, &src[i].buf, src[i].filename);scratch_buf_write_to_png (data, &dst,"destination.png" );scratch_buf_write_to_png (data, &ref,"reference.png" );
@@ -468,24 +598,24 @@ static void test(data_t *data, uint32_t tiling, bool test_ccs)* |dst|src| * ------- */ -if (test_ccs) +if (ccs_modifier) data->render_copy (data->batch,NULL , &dst,0 ,0 ,WIDTH ,HEIGHT , &ccs,0 ,0 ); -for (int i =0 ; i <ARRAY_SIZE (src); i++) +for (int i =0 ; i < num_src; i++) data->render_copy (data->batch,NULL , &src[i].buf,WIDTH /4 ,HEIGHT /4 ,WIDTH /2 -2 ,HEIGHT /2 -2 , - test_ccs ? &ccs : &dst, src[i].x, src[i].y); + ccs_modifier ? &ccs : &dst, src[i].x, src[i].y); -if (test_ccs) +if (ccs_modifier) data->render_copy (data->batch,NULL , &ccs,0 ,0 ,WIDTH ,HEIGHT , &dst,0 ,0 );if (opt_dump_png){scratch_buf_write_to_png (data, &dst,"result.png" ); -if (test_ccs) { +if (ccs_modifier) {scratch_buf_write_to_png (data, &ccs,"compressed.png" );scratch_buf_aux_write_to_png (data, &ccs,"compressed-aux.png" ); }
@@ -505,7 +635,7 @@ static void test(data_t *data, uint32_t tiling, bool test_ccs)scratch_buf_check (data, &dst, &ref,WIDTH -10 ,HEIGHT -10 ); } -if (test_ccs) +if (ccs_modifier)scratch_buf_aux_check (data, &ccs); }
@@ -546,18 +676,31 @@ int main(int argc, char **argv) } igt_subtest("linear") -test (&data,I915_TILING_NONE , false); +test (&data,I915_TILING_NONE ,0 ); igt_subtest("x-tiled") -test (&data,I915_TILING_X , false); +test (&data,I915_TILING_X ,0 ); igt_subtest("y-tiled") -test (&data,I915_TILING_Y , false); +test (&data,I915_TILING_Y ,0 ); + igt_subtest("yf-tiled") +test (&data, I915_TILING_Yf,0 ); igt_subtest("y-tiled-ccs-to-linear") -test (&data,I915_TILING_NONE , true); +test (&data,I915_TILING_NONE ,I915_TILING_Y ); igt_subtest("y-tiled-ccs-to-x-tiled") -test (&data,I915_TILING_X , true); +test (&data,I915_TILING_X ,I915_TILING_Y ); igt_subtest("y-tiled-ccs-to-y-tiled") -test (&data,I915_TILING_Y , true); +test (&data,I915_TILING_Y ,I915_TILING_Y ); + igt_subtest("y-tiled-ccs-to-yf-tiled") +test (&data, I915_TILING_Yf,I915_TILING_Y ); + + igt_subtest("yf-tiled-ccs-to-linear") +test (&data,I915_TILING_NONE , I915_TILING_Yf); + igt_subtest("yf-tiled-ccs-to-x-tiled") +test (&data,I915_TILING_X , I915_TILING_Yf); + igt_subtest("yf-tiled-ccs-to-y-tiled") +test (&data,I915_TILING_Y , I915_TILING_Yf); + igt_subtest("yf-tiled-ccs-to-yf-tiled") +test (&data, I915_TILING_Yf, I915_TILING_Yf); igt_fixture {intel_batchbuffer_free (data.batch);
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 25/25 tests/kms_plane: Test all modifiers as well
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Instead of just testing each pixel format let's test every format+modifier combo.
Obviously testing with solid filled fbs isn't the most effective way to detect tiling problems, but we can't really do much more if we want to keep comparing YUV vs. RGB results (unless we start to render the RGB content in a way that matches the YUV subsampling behaviour of the hardware).
--- tests/kms_plane.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-)
tests/kms_plane.c +19 -11
@@ -453,14 +453,15 @@ static void set_legacy_lut(data_t *data, enum pipe pipe,static void test_format_plane_color (data_t *data,enum pipe pipe,igt_plane_t *plane, -uint32_t format,int width,int height, +uint32_t format,uint64_t modifier, +int width,int height,int color,igt_crc_t *crc,struct igt_fb *fb) {const color_t *c = &colors[color];struct igt_fb old_fb = *fb;igt_create_color_fb (data->drm_fd, width, height, - format,LOCAL_DRM_FORMAT_MOD_NONE , + format, modifier, c->red, c->green, c->blue, fb);igt_plane_set_fb (plane, fb);
@@ -483,6 +484,7 @@ static void test_format_plane(data_t *data, enum pipe pipe,struct igt_fb fb = {};drmModeModeInfo *mode;uint32_t format, ref_format; +uint64_t modifier, ref_modifier;uint64_t width, height;igt_crc_t ref_crc[ARRAY_SIZE (colors)];
@@ -491,6 +493,7 @@ static void test_format_plane(data_t *data, enum pipe pipe, width = mode->hdisplay; height = mode->vdisplay; ref_format = format =DRM_FORMAT_XRGB8888 ; + ref_modifier = modifier =DRM_FORMAT_MOD_NONE ; }else {if (!plane->drm_plane) {igt_debug ("Only legacy cursor ioctl supported, skipping cursor plane\n" );
@@ -499,6 +502,7 @@ static void test_format_plane(data_t *data, enum pipe pipe,do_or_die (drmGetCap (data->drm_fd,DRM_CAP_CURSOR_WIDTH , &width));do_or_die (drmGetCap (data->drm_fd,DRM_CAP_CURSOR_HEIGHT , &height)); ref_format = format =DRM_FORMAT_ARGB8888 ; + ref_modifier = modifier =DRM_FORMAT_MOD_NONE ; } igt_debug("Testing connector %s on %s plane %s.%u\n",
@@ -519,34 +523,38 @@ static void test_format_plane(data_t *data, enum pipe pipe,test_init (data, pipe);igt_pipe_crc_start (data->pipe_crc); -igt_info ("Testing format " IGT_FORMAT_FMT " on %s.%u\n" , -IGT_FORMAT_ARGS (format), +igt_info ("Testing format " IGT_FORMAT_FMT " / modifier 0x%" PRIx64" on %s.%u\n" , +IGT_FORMAT_ARGS (format), modifier,kmstest_pipe_name (pipe), plane->index);for (int i =0 ; i <ARRAY_SIZE (colors); i++) {test_format_plane_color (data, pipe, plane, - format, width, height, + format, modifier, + width, height, i, &ref_crc[i], &fb); } -for (int i =0 ; i < plane->drm_plane->count_formats; i++) { +for (int i =0 ; i < plane->format_mod_count; i++) {igt_crc_t crc; - format = plane->drm_plane->formats[i]; + format = plane->formats[i]; + modifier = plane->modifiers[i]; -if (format == ref_format) +if (format == ref_format && + modifier == ref_modifier)continue ;if (!igt_fb_supported_format (format))continue ; -igt_info ("Testing format " IGT_FORMAT_FMT " on %s.%u\n" , -IGT_FORMAT_ARGS (format), +igt_info ("Testing format " IGT_FORMAT_FMT " / modifier 0x%" PRIx64" on %s.%u\n" , +IGT_FORMAT_ARGS (format), modifier,kmstest_pipe_name (pipe), plane->index);for (int j =0 ; j <ARRAY_SIZE (colors); j++) {test_format_plane_color (data, pipe, plane, - format, width, height, + format, modifier, + width, height, j, &crc, &fb);igt_assert_crc_equal (&crc, &ref_crc[j]);
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 24/25 lib/igt_fb: Use rendercopy for rendering into compressed buffers
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Plug in rendercopy to the cairo surface stuff so that we can generate compressed buffers with cairo.
--- lib/igt_fb.c | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 130 insertions(+), 9 deletions(-)
lib/igt_fb.c +130 -9
@@ -152,6 +152,7 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, }break ;case LOCAL_I915_FORMAT_MOD_Y_TILED : +case LOCAL_I915_FORMAT_MOD_Y_TILED_CCS :igt_require_intel (fd);if (intel_gen (intel_get_drm_devid (fd)) ==2 ) { *width_ret =128 ;
@@ -165,6 +166,7 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, }break ;case LOCAL_I915_FORMAT_MOD_Yf_TILED: +case LOCAL_I915_FORMAT_MOD_Yf_TILED_CCS:igt_require_intel (fd);switch (fb_bpp) {case 8 :
@@ -190,8 +192,16 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, } } +static bool modifier_has_ccs (uint64_t modifier) +{ +return modifier ==LOCAL_I915_FORMAT_MOD_Y_TILED_CCS || + modifier == LOCAL_I915_FORMAT_MOD_Yf_TILED_CCS; +} +static unsigned fb_plane_width (const struct igt_fb *fb,int plane) { +if (modifier_has_ccs (fb->tiling) && plane ==1 ) +return DIV_ROUND_UP (fb->width,1024 ) *128 ;if (fb->drm_format ==DRM_FORMAT_NV12 && plane ==1 )return DIV_ROUND_UP (fb->width,2 );
@@ -202,11 +212,16 @@ static unsigned fb_plane_bpp(const struct igt_fb *fb, int plane) {const struct format_desc_struct *format =lookup_drm_format (fb->drm_format); -return format->plane_bpp[plane]; +if (modifier_has_ccs (fb->tiling) && plane ==1 ) +return 8 ; +else +return format->plane_bpp[plane]; }static unsigned fb_plane_height (const struct igt_fb *fb,int plane) { +if (modifier_has_ccs (fb->tiling) && plane ==1 ) +return DIV_ROUND_UP (fb->height,512 ) *32 ;if (fb->drm_format ==DRM_FORMAT_NV12 && plane ==1 )return DIV_ROUND_UP (fb->height,2 );
@@ -217,7 +232,10 @@ static int fb_num_planes(const struct igt_fb *fb) {const struct format_desc_struct *format =lookup_drm_format (fb->drm_format); -return format->num_planes; +if (modifier_has_ccs (fb->tiling)) +return 2 ; +else +return format->num_planes; } static void fb_init(struct igt_fb *fb,
@@ -374,8 +392,10 @@ uint64_t igt_fb_mod_to_tiling(uint64_t modifier)case LOCAL_I915_FORMAT_MOD_X_TILED :return I915_TILING_X ;case LOCAL_I915_FORMAT_MOD_Y_TILED : +case LOCAL_I915_FORMAT_MOD_Y_TILED_CCS :return I915_TILING_Y ;case LOCAL_I915_FORMAT_MOD_Yf_TILED: +case LOCAL_I915_FORMAT_MOD_Yf_TILED_CCS:return I915_TILING_Yf;default :igt_assert (0 );
@@ -1204,8 +1224,53 @@ struct fb_blit_upload {int fd;struct igt_fb *fb;struct fb_blit_linear linear; +drm_intel_bufmgr *bufmgr; +struct intel_batchbuffer *batch; }; +static void init_buf (struct fb_blit_upload *blit, +struct igt_buf *buf, +const struct igt_fb *fb, +const char *name) +{ +igt_assert_eq (fb->offsets[0 ],0 ); + + buf->bo =gem_handle_to_libdrm_bo (blit->bufmgr, blit->fd, + name, fb->gem_handle); + buf->tiling =igt_fb_mod_to_tiling (fb->tiling); + buf->stride = fb->strides[0 ]; + buf->size = fb->size; + +if (modifier_has_ccs (fb->tiling)) { +igt_assert_eq (fb->strides[0 ] &127 ,0 ); +igt_assert_eq (fb->strides[1 ] &127 ,0 ); + + buf->aux.offset = fb->offsets[1 ]; + buf->aux.stride = fb->strides[1 ]; + } +} + +static void rendercopy (struct fb_blit_upload *blit, +const struct igt_fb *dst_fb, +const struct igt_fb *src_fb) +{ +struct igt_buf src = {}, dst = {}; +igt_render_copyfunc_t render_copy = +igt_get_render_copyfunc (intel_get_drm_devid (blit->fd)); + +igt_require (render_copy); + +igt_assert_eq (dst_fb->offsets[0 ],0 ); +igt_assert_eq (src_fb->offsets[0 ],0 ); + +init_buf (blit, &src, src_fb,"cairo rendercopy src" ); +init_buf (blit, &dst, dst_fb,"cairo rendercopy dst" ); + +render_copy (blit->batch,NULL , + &src,0 ,0 , dst_fb->plane_width[0 ], dst_fb->plane_height[0 ], + &dst,0 ,0 ); +} +static void blitcopy (const struct igt_fb *dst_fb,const struct igt_fb *src_fb) {
@@ -1243,7 +1308,10 @@ static void free_linear_mapping(struct fb_blit_upload *blit)gem_set_domain (fd, linear->fb.gem_handle,I915_GEM_DOMAIN_GTT ,0 ); -blitcopy (fb, &linear->fb); +if (blit->batch) +rendercopy (blit, fb, &linear->fb); +else +blitcopy (fb, &linear->fb);gem_sync (fd, linear->fb.gem_handle);gem_close (fd, linear->fb.gem_handle);
@@ -1260,8 +1328,26 @@ static void destroy_cairo_surface__blit(void *arg)free (blit); } -static void setup_linear_mapping (int fd,struct igt_fb *fb,struct fb_blit_linear *linear) +static void destroy_cairo_surface__rendercopy (void *arg) +{ +struct fb_blit_upload *blit = arg; + + blit->fb->cairo_surface =NULL ; + +free_linear_mapping (blit); + +intel_batchbuffer_free (blit->batch); +drm_intel_bufmgr_destroy (blit->bufmgr); + +free (blit); +} + +static void setup_linear_mapping (struct fb_blit_upload *blit) { +int fd = blit->fd; +struct igt_fb *fb = blit->fb; +struct fb_blit_linear *linear = &blit->linear; +/* * We create a linear BO that we'll map for the CPU to write to (using * cairo). This linear bo will be then blitted to its final
@@ -1280,7 +1366,10 @@ static void setup_linear_mapping(int fd, struct igt_fb *fb, struct fb_blit_lineagem_set_domain (fd, linear->fb.gem_handle,I915_GEM_DOMAIN_GTT ,0 ); -blitcopy (&linear->fb, fb); +if (blit->batch) +rendercopy (blit, &linear->fb, fb); +else +blitcopy (&linear->fb, fb);gem_sync (fd, linear->fb.gem_handle);
@@ -1297,12 +1386,12 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb)struct fb_blit_upload *blit;cairo_format_t cairo_format; - blit =malloc (sizeof (*blit)); + blit =calloc (1 ,sizeof (*blit));igt_assert (blit); blit->fd = fd; blit->fb = fb; -setup_linear_mapping (fd, fb, &blit->linear); +setup_linear_mapping (blit); cairo_format =drm_format_to_cairo (fb->drm_format); fb->cairo_surface =
@@ -1317,6 +1406,36 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb) blit, destroy_cairo_surface__blit); } +static void create_cairo_surface__rendercopy (int fd,struct igt_fb *fb) +{ +struct fb_blit_upload *blit; +cairo_format_t cairo_format; + + blit =calloc (1 ,sizeof (*blit)); +igt_assert (blit); + + blit->fd = fd; + blit->fb = fb; + + blit->bufmgr =drm_intel_bufmgr_gem_init (fd,4096 ); + blit->batch =intel_batchbuffer_alloc (blit->bufmgr, +intel_get_drm_devid (fd)); + +setup_linear_mapping (blit); + + cairo_format =drm_format_to_cairo (fb->drm_format); + fb->cairo_surface = +cairo_image_surface_create_for_data (blit->linear.map, + cairo_format, + fb->width, fb->height, + blit->linear.fb.strides[0 ]); + fb->domain =I915_GEM_DOMAIN_GTT ; + +cairo_surface_set_user_data (fb->cairo_surface, + (cairo_user_data_key_t *)create_cairo_surface__rendercopy, + blit, destroy_cairo_surface__rendercopy); +} +/** * igt_dirty_fb: * @fd: open drm file descriptor
@@ -1776,7 +1895,7 @@ static void destroy_cairo_surface__convert(void *arg)static void create_cairo_surface__convert (int fd,struct igt_fb *fb) { -struct fb_convert_blit_upload *blit =malloc (sizeof (*blit)); +struct fb_convert_blit_upload *blit =calloc (1 ,sizeof (*blit));igt_assert (blit); blit->base.fd = fd;
@@ -1789,7 +1908,7 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)if ((fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) && fb->strides[0 ] <32768 ) { -setup_linear_mapping (fd, fb, &blit->base.linear); +setup_linear_mapping (&blit->base); }else { blit->base.linear.fb.gem_handle =0 ; blit->base.linear.map = gem_mmap__gtt(fd, fb->gem_handle, fb->size,
@@ -1843,6 +1962,8 @@ cairo_surface_t *igt_get_cairo_surface(int fd, struct igt_fb *fb)if (fb->cairo_surface ==NULL ) {if (igt_format_is_yuv (fb->drm_format))create_cairo_surface__convert (fd, fb); +else if (modifier_has_ccs (fb->tiling)) +create_cairo_surface__rendercopy (fd, fb);else if ((fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) && fb->strides[0 ] <32768 )
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 9/25 lib/igt_fb: Pass fb_blit_upload to free_linear_mapping()
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
With fb_blit_upload now being the base class of fb_convert_blit_upload we can pass the entire structure down to free_linear_mapping().
--- lib/igt_fb.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
lib/igt_fb.c +6 -3
@@ -1208,8 +1208,11 @@ struct fb_blit_upload {struct fb_blit_linear linear; }; -static void free_linear_mapping (int fd,struct igt_fb *fb,struct fb_blit_linear *linear) +static void free_linear_mapping (struct fb_blit_upload *blit) { +int fd = blit->fd; +struct igt_fb *fb = blit->fb; +struct fb_blit_linear *linear = &blit->linear;unsigned int obj_tiling =igt_fb_mod_to_tiling (fb->tiling);int i;
@@ -1242,7 +1245,7 @@ static void destroy_cairo_surface__blit(void *arg) blit->fb->cairo_surface =NULL ; -free_linear_mapping (blit->fd, blit->fb, &blit->linear); +free_linear_mapping (blit);free (blit); }
@@ -1768,7 +1771,7 @@ static void destroy_cairo_surface__convert(void *arg)munmap (blit->rgb24.map, blit->rgb24.size);if (blit->base.linear.handle) -free_linear_mapping (blit->base.fd, blit->base.fb, &blit->base.linear); +free_linear_mapping (&blit->base);else gem_munmap (blit->base.linear.map, fb->size);
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 19/25 lib/igt_fb: Pass around igt_fb internally
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Instead of passing around a boatload of integers everywhere let's just pass around the igt_fb struct. That obviously means we have to populate it first sufficiently, to which end we'll add a small helper. Later on the stride/size calculations will consult the already pre-populated igt_fb and fill in the rest as needed.
This makes the whole thing a lot less error prone as it's impossible to accidentally pass the arguments in the wrong order when there's just the one of them, and it's a pointer.
--- lib/igt_draw.c | 2 +- lib/igt_fb.c | 405 +++++++++++++++++++-------------------- lib/igt_fb.h | 4 +- tests/kms_ccs.c | 2 +- tests/kms_flip.c | 4 +- tests/kms_frontbuffer_tracking.c | 6 +- tests/pm_rpm.c | 2 +- 7 files changed, 206 insertions(+), 219 deletions(-)
lib/igt_draw.c +1 -1
@@ -720,7 +720,7 @@ void igt_draw_rect_fb(int fd, drm_intel_bufmgr *bufmgr, enum igt_draw_method method, int rect_x, int rect_y, int rect_w, int rect_h, uint32_t color) { - igt_draw_rect(fd, bufmgr, context, fb->gem_handle, fb->size, fb->stride, + igt_draw_rect(fd, bufmgr, context, fb->gem_handle, fb->size, fb->strides[0],method ,rect_x ,rect_y ,rect_w ,rect_h ,color , igt_drm_format_to_bpp(fb->drm_format)); }
lib/igt_fb.c +196 -209
635 lines not on this page · raw message
lib/igt_fb.h +2 -2
@@ -47,12 +47,12 @@* @drm_format: DRM FOURCC code * @width: width in pixels * @height: height in pixels -* @stride: line stride in bytes * @tiling: tiling mode as a DRM framebuffer modifier * @size: size in bytes of the underlying backing storage * @cairo_surface: optionally attached cairo drawing surface * @domain: current domain for cache flushing tracking on i915.ko * @num_planes: Amount of planes on this fb. >1 for planar formats. +* @strides: line stride for each plane in bytes * @offsets: Offset for each plane in bytes. * @plane_bpp: The bpp for each plane. * @plane_width: The width for each plane.
@@ -70,12 +70,12 @@ typedef struct igt_fb {int height;enum igt_color_encoding color_encoding;enum igt_color_range color_range; -unsigned int stride;uint64_t tiling;unsigned int size;cairo_surface_t *cairo_surface;unsigned int domain;unsigned int num_planes; +uint32_t strides[4 ];uint32_t offsets[4 ];unsigned int plane_bpp[4 ];unsigned int plane_width[4 ];
tests/kms_ccs.c +1 -1
@@ -330,7 +330,7 @@ static void generate_fb(data_t *data, struct igt_fb *fb, fb->drm_format = f.pixel_format; fb->width = f.width; fb->height = f.height; - fb->stride = f.pitches[0 ]; + fb->strides[0 ] = f.pitches[0 ]; fb->tiling = f.modifier[0 ]; fb->size = size[0 ]; fb->cairo_surface =NULL ;
tests/kms_flip.c +2 -2
@@ -592,7 +592,7 @@ static void recreate_fb(struct test_output *o)igt_assert (r);do_or_die (drmModeAddFB (drm_fd, o->fb_width, o->fb_height, o->depth, - o->bpp, fb_info->stride, + o->bpp, fb_info->strides[0 ], r->handle, &new_fb_id));gem_close (drm_fd, r->handle);
@@ -612,7 +612,7 @@ static void set_y_tiling(struct test_output *o, int fb_idx) r =drmModeGetFB (drm_fd, fb_info->fb_id);igt_assert (r);/* Newer kernels don't allow such shenagians any more, so skip the test. */ -igt_require (__gem_set_tiling (drm_fd, r->handle,I915_TILING_Y , fb_info->stride) ==0 ); +igt_require (__gem_set_tiling (drm_fd, r->handle,I915_TILING_Y , fb_info->strides[0 ]) ==0 );gem_close (drm_fd, r->handle);drmFree (r); }
tests/kms_frontbuffer_tracking.c +3 -3
@@ -1161,7 +1161,7 @@ static void start_busy_thread(struct igt_fb *fb) busy_thread.stop = false; busy_thread.handle = fb->gem_handle; busy_thread.size = fb->size; - busy_thread.stride = fb->stride; + busy_thread.stride = fb->strides[0 ]; busy_thread.width = fb->width; busy_thread.height = fb->height; busy_thread.color =pick_color (fb,COLOR_PRIM_BG );
@@ -2841,7 +2841,7 @@ static void badstride_subtest(const struct test_mode *t)create_fb (t->format, params->primary.fb->width +4096 , params->primary.fb->height, opt.tiling, t->plane, &wide_fb); -igt_assert (wide_fb.stride >16384 ); +igt_assert (wide_fb.strides[0 ] >16384 );fill_fb (&wide_fb,COLOR_PRIM_BG );
@@ -2910,7 +2910,7 @@ static void stridechange_subtest(const struct test_mode *t) opt.tiling, t->plane, &new_fb);fill_fb (&new_fb,COLOR_PRIM_BG ); -igt_assert (old_fb->stride != new_fb.stride); +igt_assert (old_fb->strides[0 ] != new_fb.strides[0 ]);/* We can't assert that FBC will be enabled since there may not be * enough space for the CFB, but we can check the CRC. */
tests/pm_rpm.c +1 -1
@@ -1518,7 +1518,7 @@ static void cursor_subtest(bool dpms)* hopefully it has some fences around it. */ rc =drmModeRmFB (drm_fd, cursor_fb3.fb_id);igt_assert_eq (rc,0 ); -gem_set_tiling (drm_fd, cursor_fb3.gem_handle, false, cursor_fb3.stride); +gem_set_tiling (drm_fd, cursor_fb3.gem_handle, false, cursor_fb3.strides[0 ]);igt_assert (wait_for_suspended ()); rc = drmModeSetCursor(drm_fd, crtc_id, cursor_fb3.gem_handle,
Signature · 6 lines
2.16.4 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,01/25] lib/igt_kms: Fill the plane format/mod information for pre-blobifier drivers
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: series starting with [i-g-t,01/25] lib/igt_kms: Fill the plane format/mod information for pre-blobifier drivers
URL : https://patchwork.freedesktop.org/series/46876/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4509 -> IGTPW_1607 =
== Summary - SUCCESS ==
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/46876/revisions/1/mbox/
== Known issues ==
Here are the changes found in IGTPW_1607 that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
fi-bxt-dsi: PASS -> INCOMPLETE (fdo#103927)fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
== Participating hosts (46 -> 41) ==
Additional (1): fi-kbl-7560u
Missing (6): fi-ilk-m540 fi-hsw-4200u fi-hsw-peppy fi-byt-squawks fi-bsw-cyan fi-ctg-p8600
== Build changes ==
* IGT: IGT_4567 -> IGTPW_1607
CI_DRM_4509: e84aa0b47beed78a5a12db93e76fb00eab5db160 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_1607: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1607/
IGT_4567: 7f85adc4050182f490c7a5c48db3d57cdb00af4e @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
== Testlist changes ==
+igt@gem_render_copy@yf-tiled
+igt@gem_render_copy@yf-tiled-ccs-to-linear
+igt@gem_render_copy@yf-tiled-ccs-to-x-tiled
+igt@gem_render_copy@yf-tiled-ccs-to-yf-tiled
+igt@gem_render_copy@yf-tiled-ccs-to-y-tiled
+igt@gem_render_copy@y-tiled-ccs-to-yf-tiled
+igt@kms_addfb_basic@expected-formats
+igt@kms_plane@validate-in-formats
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1607/issues.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,01/25] lib/igt_kms: Fill the plane format/mod information for pre-blobifier drivers
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: series starting with [i-g-t,01/25] lib/igt_kms: Fill the plane format/mod information for pre-blobifier drivers
URL : https://patchwork.freedesktop.org/series/46876/
State : success
== Summary ==
= CI Bug Log - changes from IGT_4567_full -> IGTPW_1607_full =
== Summary - WARNING ==
Minor unknown changes coming with IGTPW_1607_full need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in IGTPW_1607_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://patchwork.freedesktop.org/api/1.0/series/46876/revisions/1/mbox/
== Possible new issues ==
Here are the unknown changes that may have been introduced in IGTPW_1607_full:
=== IGT changes ===
==== Possible regressions ====
{igt@kms_addfb_basic@expected-formats}:
shard-kbl: NOTRUN -> FAIL
shard-apl: NOTRUN -> FAIL
shard-snb: NOTRUN -> FAIL
shard-glk: NOTRUN -> FAIL
shard-hsw: NOTRUN -> FAIL
==== Warnings ====
igt@gem_mocs_settings@mocs-rc6-bsd2:
shard-kbl: PASS -> SKIP
igt@kms_vblank@pipe-a-ts-continuation-suspend:
shard-snb: PASS -> SKIP
igt@perf_pmu@rc6:
shard-kbl: SKIP -> PASS== Known issues ==
Here are the changes found in IGTPW_1607_full that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@kms_available_modes_crc@available_mode_test_crc:
shard-glk: NOTRUN -> FAIL (fdo#106641)
igt@kms_cursor_legacy@pipe-b-torture-move:
shard-snb: PASS -> DMESG-WARN (fdo#107122)
shard-kbl: PASS -> DMESG-WARN (fdo#107122)
igt@kms_flip@plain-flip-fb-recreate-interruptible:
shard-glk: PASS -> FAIL (fdo#100368) +3
igt@kms_plane@pixel-format-pipe-c-planes:
shard-glk: PASS -> INCOMPLETE (fdo#103359, k.org#198133) +2
igt@kms_plane_multiple@atomic-pipe-a-tiling-x:
shard-snb: PASS -> FAIL (fdo#103166)
==== Possible fixes ====
igt@kms_rotation_crc@primary-rotation-180:
shard-snb: FAIL (fdo#103925) -> PASS
igt@kms_setmode@basic:
shard-apl: FAIL (fdo#99912) -> PASS
igt@kms_vblank@pipe-a-ts-continuation-suspend:
shard-hsw: FAIL (fdo#104894) -> PASS
igt@perf@polling:
shard-hsw: FAIL (fdo#102252) -> PASS {name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
fdo#103166 https://bugs.freedesktop.org/show_bug.cgi?id=103166
fdo#103359 https://bugs.freedesktop.org/show_bug.cgi?id=103359
fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925
fdo#104894 https://bugs.freedesktop.org/show_bug.cgi?id=104894
fdo#106641 https://bugs.freedesktop.org/show_bug.cgi?id=106641
fdo#107122 https://bugs.freedesktop.org/show_bug.cgi?id=107122
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
k.org#198133 https://bugzilla.kernel.org/show_bug.cgi?id=198133
== Participating hosts (5 -> 5) ==
No changes in participating hosts
== Build changes ==
* IGT: IGT_4567 -> IGTPW_1607
* Linux: CI_DRM_4507 -> CI_DRM_4509
CI_DRM_4507: 3bbfaebaf3ba21d866c7823d9e4febf47b4b7b39 @ git://anongit.freedesktop.org/gfx-ci/linux
CI_DRM_4509: e84aa0b47beed78a5a12db93e76fb00eab5db160 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_1607: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1607/
IGT_4567: 7f85adc4050182f490c7a5c48db3d57cdb00af4e @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1607/shards.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 05/25] tests/gem_render_copy: Fix clipped height
In reply to Ville SyrjalaQuoted 9 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
Assign the clipped height to 'h', not 'w'. This didn't cause any problems so far because we use square buffers.
Also get rid of the gcc variable shadowing warnings by not nesting the
min()/max().
Quoted 15 lines
Fixes aaa23eff21a1 ("tests/gem_render_copy: Use a more elaboratepattern of pixels")
Signed-off-by Ville Syrjälä <[email protected]>--- tests/gem_render_copy.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)tests/gem_render_copy.c +0
-0@@ -254,8 +254,11 @@ scratch_buf_copy(data_t *data, linear_src =gem_mmap__gtt (data->drm_fd, src->bo->handle, src->bo->size,PROT_READ );
tests/gem_render_copy.c scratch_buf_copy(data_t *data, · line 264
Quoted 10 lines
tests/gem_render_copy.c +5
-2- w =min (w,min (width - sx, width - dx)); - w =min (h,min (height - sy, height - dy)); + w =min (w, width - sx); + w =min (w, width - dx); + + h =min (h, height - sy); + h =min (h, height - dy);for (int y =0 ; y < h; y++) { igt_memcpy_from_wc(&linear_dst[(dy+y) * width + dx],
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 05/25] tests/gem_render_copy: Fix clipped height
Quoted 5 lines · Dhinakaran Pandiyan
Quoted 2 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
Quoted 8 lines
Quoted 7 lines
Assign the clipped height to 'h', not 'w'. This didn't cause any problems so far because we use square buffers.
Also get rid of the gcc variable shadowing warnings by not nesting the
min()/max().Reviewed-by Dhinakaran Pandiyan <[email protected]>
Thanks. Patch pushed.
Quoted 26 lines
Quoted 26 lines
Fixes aaa23eff21a1 ("tests/gem_render_copy: Use a more elaboratepattern of pixels")
Signed-off-by Ville Syrjälä <[email protected]>--- tests/gem_render_copy.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)tests/gem_render_copy.c +5
-2@@ -254,8 +254,11 @@ scratch_buf_copy(data_t *data, linear_src =gem_mmap__gtt (data->drm_fd, src->bo->handle, src->bo->size,PROT_READ ); - w =min (w,min (width - sx, width - dx)); - w =min (h,min (height - sy, height - dy)); + w =min (w, width - sx); + w =min (w, width - dx); + + h =min (h, height - sy); + h =min (h, height - dy);for (int y =0 ; y < h; y++) { igt_memcpy_from_wc(&linear_dst[(dy+y) * width + dx],
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 07/25] lib: Add DIV_ROUND_UP()
In reply to Ville SyrjalaEm Qui, 2018-07-19 às 18:03 +0300, Ville Syrjala escreveu:
Quoted 3 lines
From: Ville Syrjälä <[email protected]>
Add
DIV_ROUND_UP()and replace some hand rolled versions with it.
Please also remove the redefinition inside gem_render_copy.c.
With that:
Quoted 58 lines
Signed-off-by Ville Syrjälä <[email protected]>--- lib/igt_aux.h | 2 ++ lib/igt_fb.c | 4 ++-- tests/i915_query.c | 2 -- 3 files changed, 4 insertions(+), 4 deletions(-)lib/igt_aux.h +2
-0@@ -287,4 +287,6 @@ void igt_lsof(const char *dpath);#define is_power_of_two (x) (((x) & ((x)-1)) == 0) +#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +#endif /* IGT_AUX_H */ lib/igt_fb.c +1
-1@@ -193,7 +193,7 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, static unsigned planar_width(struct format_desc_struct *format,unsigned width,int plane) {if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) -return (width +1 ) /2 ; +return DIV_ROUND_UP (width,2 );lib/igt_fb.c +1
-1return width; }@@ -208,7 +208,7 @@ static unsigned planar_stride(struct format_desc_struct *format, unsigned width, static unsigned planar_height(struct format_desc_struct *format, unsigned height, int plane) { if (format->drm_id == DRM_FORMAT_NV12 && plane == 1) - return (height + 1) / 2; + return DIV_ROUND_UP(height, 2);lib/igt_fb.c +0
-0return height; }tests/i915_query.c +0
-2@@ -242,8 +242,6 @@ static void test_query_topology_unsupported(int fd) igt_assert_eq(item.length, -ENODEV); } -#define DIV_ROUND_UP (val, div) (ALIGN(val, div) / div) -static bool slice_available(const struct drm_i915_query_topology_info
Quoted 2 lines
*topo_info,
int s)
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Em Qui, 2018-07-19 às 18:03 +0300, Ville Syrjala escreveu:
Quoted 7 lines
From: Ville Syrjälä <[email protected]>
For drivers that don't support the
IN_FORMATSblob we should just consult the format list returned by getplane. Since we can't know which modifiers are supported we'll assume linear-only. Obviously that may not work for every driver out there, but not much more we can do unless we start to actually probing with addfb.
Can you please elaborate on why we need that change? What exactly do we gain from it? IMHO there's always the worry that this could be misused in the future, restricting tests to linear only when other formats are indeed possible. Having NULL buffers crashing the test is a good way to prevent misuse.
What if we populate plane->formats like we do here but leave plane-
Quoted 1 line
modifiers NULL? It would allow other pieces of the code to rely on the
format list while not exposing the risk of the "linear only" incorrect restriction.
That said, the patch is correct in the sense that it does what it proposes to do.
Quoted 34 lines
Cc Ulrich Hecht <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- lib/igt_kms.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)lib/igt_kms.c +0
-0@@ -4068,8 +4068,28 @@ static voidigt_fill_plane_format_mod(igt_display_t *display,
igt_plane_t*planelib/igt_kms.c +7
-1int idx =0 ;int count; -if (!igt_plane_has_prop (plane,IGT_PLANE_IN_FORMATS )) +if (!igt_plane_has_prop (plane,IGT_PLANE_IN_FORMATS )) { +drmModePlanePtr p = plane->drm_plane; + + count = p->count_formats; + + plane->format_mod_count = count; + plane->formats = calloc(count, sizeof(plane-Quoted 1 line
formats[0]));
lib/igt_kms.c +2
-0+igt_assert (plane->formats); + plane->modifiers = calloc(count, sizeof(plane-Quoted 1 line
modifiers[0]));
lib/igt_kms.c +5
-0+igt_assert (plane->modifiers); + +/* +* We don't know which modifiers are +* supported, so we'll assume linear only.
lib/igt_kms.c static void igt_fill_plane_format_mod(igt_display_t *display, igt_plane_t *plane · line 4094
Quoted 10 lines
lib/igt_kms.c +7
-0+*/ +for (int i =0 ; i < count; i++) { + plane->formats[i] = p->formats[i]; + plane->modifiers[i] =DRM_FORMAT_MOD_LINEAR ; + } +return ; + } blob_id =igt_plane_get_prop (plane,IGT_PLANE_IN_FORMATS );
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 02/25] tests/kms_ccs: Use igt_plane_has_format_mod()
In reply to Ville SyrjalaEm Qui, 2018-07-19 às 18:03 +0300, Ville Syrjala escreveu:
Quoted 4 lines
From: Ville Syrjälä <[email protected]>
Replace the open coded
IN_FORMATSparsing withigt_plane_has_format_mod()now that we have such a thing.
This patch removes a few of the igt_skip() and igt_assert() calls we had. Previously explicit messages such as "IN_FORMATS not supported by X" will become "requirement valid_tests == 0 failed", which IMHO is not exactly an improvement to the code base.
Can you please keep the first kmstest_get_property() and the two igt_skip_on() calls that follow it?
If we keep the assertions:
Quoted 79 lines
Signed-off-by Ville Syrjälä <[email protected]>--- tests/kms_ccs.c | 50 +-------------------------------------------- ----- 1 file changed, 1 insertion(+), 49 deletions(-)tests/kms_ccs.c +0
-12@@ -132,55 +132,7 @@ modifiers_ptr(struct local_drm_format_modifier_blob *blob)static bool plane_has_format_with_ccs (data_t *data,igt_plane_t *plane,uint32_t format) { -drmModePropertyBlobPtr blob; -struct local_drm_format_modifier_blob *blob_data; -struct local_drm_format_modifier *modifiers, *last_mod; -uint32_t *formats, *last_fmt; -uint64_t blob_id; -bool ret; -int fmt_idx =-1 ; - - ret =kmstest_get_property (data->drm_fd, plane->drm_plane- >plane_id, -DRM_MODE_OBJECT_PLANE , "IN_FORMATS", -NULL , &blob_id,NULL ); - igt_skip_on_f(ret == false, "IN_FORMATS not supported bykernel\n");
tests/kms_ccs.c +0
-1- igt_skip_on_f(blob_id == 0, "IN_FORMATS not supported byplane\n");
tests/kms_ccs.c +0
-3- blob =drmModeGetPropertyBlob (data->drm_fd, blob_id); -igt_assert (blob); - igt_assert_lte(sizeof(struct
local_drm_format_modifier_blob),tests/kms_ccs.c +0
-3- blob->length); - - blob_data = (struct local_drm_format_modifier_blob *) blob-Quoted 1 line
data;
tests/kms_ccs.c +0
-3- formats =formats_ptr (blob_data); - last_fmt = &formats[blob_data->count_formats]; - igt_assert_lte(((char *) last_fmt - (char *) blob_data),
blob->length);tests/kms_ccs.c +0
-13-for (int i =0 ; i < blob_data->count_formats; i++) { -if (formats[i] == format) { - fmt_idx = i; -break ; - } - } - -if (fmt_idx ==-1 ) -return false; - - modifiers =modifiers_ptr (blob_data); - last_mod = &modifiers[blob_data->count_modifiers]; - igt_assert_lte(((char *) last_mod - (char *) blob_data),
blob->length);tests/kms_ccs.c +0
-2-for (int i =0 ; i < blob_data->count_modifiers; i++) { - if (modifiers[i].modifier !=
LOCAL_I915_FORMAT_MOD_Y_TILED_CCS)tests/kms_ccs.c +1
-12-continue ; - -if (modifiers[i].offset > fmt_idx || - fmt_idx > modifiers[i].offset +63 ) -continue ; - -if (modifiers[i].formats & - (1UL << (fmt_idx - modifiers[i].offset))) -return true; - } - -return false; + return igt_plane_has_format_mod(plane, format,
LOCAL_I915_FORMAT_MOD_Y_TILED_CCS);
}
Quoted 2 lines
static void render_fb(data_t *data,
uint32_tgem_handle, unsigned
int size,
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 03/25] tests/kms_plane: Add validate-in-formats subtest
In reply to Ville SyrjalaEm Qui, 2018-07-19 às 18:03 +0300, Ville Syrjala escreveu:
Quoted 4 lines
From: Ville Syrjälä <[email protected]>
Cross check the format list in the
IN_FORMATSblob vs. the format list returned by getplane.
Bikeshed: unnecessary braces on the j loops.
By the way, this test won't break if you follow my suggestion from patch 01 of populating plane->formats while leaving plane->modifiers NULL.
Quoted 70 lines
Cc Ulrich Hecht <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- tests/kms_plane.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)tests/kms_plane.c +47
-0@@ -366,6 +366,53 @@ test_plane_panning(data_t *data, enum pipe pipe, unsigned int flags) igt_skip_on(connected_outs == 0); } +static void validate_plane_in_formats (igt_plane_t *plane) +{ +drmModePlanePtr drm_plane = plane->drm_plane; + +igt_require (plane->format_mod_count); + +/* +* Make sure every format in the IN_FORMATS blob +* also appears in the getplane formats. +*/ +for (int i =0 ; i < plane->format_mod_count; i++) { +int j; + +for (j =0 ; j < drm_plane->count_formats; j++) { +if (plane->formats[i] == drm_plane- >formats[j]) +break ; + } +igt_assert_lt (j, drm_plane->count_formats); + } + +/* +* Make sure every format in getplane also +* appears in the IN_FORMATS blob. +*/ +for (int i =0 ; i < drm_plane->count_formats; i++) { +int j; + +for (j =0 ; j < plane->format_mod_count; j++) { +if (drm_plane->formats[i] == plane- >formats[j]) +break ; + } +igt_assert_lt (j, plane->format_mod_count); + } +} + +static void validate_in_formats (data_t *data) +{ +enum pipe pipe; + +for_each_pipe (&data->display, pipe) { +igt_plane_t *plane; + +for_each_plane_on_pipe (&data->display, pipe, plane) +validate_plane_in_formats (plane); + } +} +static const
color_tcolors[] = {tests/kms_plane.c +0
-0{ 1.0f, 0.0f, 0.0f, }, { 0.0f, 1.0f, 0.0f, },
tests/kms_plane.c igt_main · line 647
Quoted 9 lines
tests/kms_plane.c +3
-0@@ -592,6 +639,9 @@ igt_mainigt_display_init (&data.display, data.drm_fd); } + igt_subtest_f("validate-in-formats") +validate_in_formats (&data); +for_each_pipe_static (pipe)run_tests_for_pipe_plane (&data, pipe);
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 04/25] tests/kms_addfb_basic: Check that addfb2 accepts/rejects the expected formats
In reply to Ville SyrjalaEm Qui, 2018-07-19 às 18:03 +0300, Ville Syrjala escreveu:
Quoted 11 lines
From: Ville Syrjälä <[email protected]>
Try to create a bunch of fbs with different formats/modfifiers and make sure sure addfb2 accepts/rejects them in accordance with what the plane
IN_FORMATSblobifiers are advertizing.We only check "easy" formats (ie. RGB/C8, no YUV/planar etc.). We also assume that one can always create a 64x64 fb with stride of 64*8 bytes.
v2: Skip when blobifiers aren't supported
Some trivial rebasing required.
More below.
Quoted 13 lines
Cc Ulrich Hecht <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- tests/kms_addfb_basic.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 104 insertions(+), 3 deletions(-)tests/kms_addfb_basic.c +0
-0
tests/kms_addfb_basic.c line 50
Quoted 10 lines
tests/kms_addfb_basic.c +7
-0@@ -41,6 +41,97 @@uint32_t gem_bo;uint32_t gem_bo_small; +static const uint64_t modifiers[] = { +DRM_FORMAT_MOD_LINEAR , +I915_FORMAT_MOD_X_TILED , +I915_FORMAT_MOD_Y_TILED , + I915_FORMAT_MOD_Yf_TILED, +I915_FORMAT_MOD_Y_TILED_CCS , + I915_FORMAT_MOD_Yf_TILED_CCS,
For the buffers that support CCS, I see the test failing with the Kernel complaining that we're not passing 2 planes (since .num_planes=2 in ccs_formats from intel_display.c). It looks like igt needs to craft the aux buffer too.
More below.
Quoted 34 lines
tests/kms_addfb_basic.c +34
-0+}; + +static const uint32_t formats[] = { +DRM_FORMAT_C8 , + +DRM_FORMAT_RGB565 , +DRM_FORMAT_BGR565 , + +DRM_FORMAT_RGB888 , +DRM_FORMAT_BGR888 , + +DRM_FORMAT_XRGB8888 , +DRM_FORMAT_XBGR8888 , +DRM_FORMAT_RGBX8888 , +DRM_FORMAT_BGRX8888 , +DRM_FORMAT_ARGB8888 , +DRM_FORMAT_ABGR8888 , +DRM_FORMAT_RGBA8888 , +DRM_FORMAT_BGRA8888 , + +DRM_FORMAT_XRGB2101010 , +DRM_FORMAT_XBGR2101010 , +DRM_FORMAT_RGBX1010102 , +DRM_FORMAT_BGRX1010102 , +DRM_FORMAT_ARGB2101010 , +DRM_FORMAT_ABGR2101010 , +DRM_FORMAT_RGBA1010102 , +DRM_FORMAT_BGRA1010102 , +}; + +#define IGT_FORMAT_FMT "%c%c%c%c (0x%08x)" +#define IGT_FORMAT_ARGS (f) ((f) >> 0) & 0xff, ((f) >> 8) & 0xff, \ + ((f) >> 16) & 0xff, ((f) >> 24) & 0xff, (f) +
tests/kms_addfb_basic.c line 94
Quoted 10 lines
tests/kms_addfb_basic.c +10
-0+/* +* make sure addfb2 accepts/rejects every format/modifier +* in accordance with the plane IN_FORMATS properties. +*/ +static void expected_formats (igt_display_t *display) +{ +int fd = display->drm_fd; +uint32_t handle; + +igt_require (display->format_mod_count);
After patch 01, this is really not skipping a lot.
Perhaps it would be better to igt_require(plane->modifiers) if you implement my suggestion from patch 01? :)
tests/kms_addfb_basic.c line 96
Quoted 2 lines
tests/kms_addfb_basic.c +2
-0+ + handle =gem_create (fd,64 *8 *64 );
I'm assuming you have checked that this is sane.
Quoted 24 lines
tests/kms_addfb_basic.c +22
-0+igt_assert (handle); + +for (int i =0 ; i <ARRAY_SIZE (formats); i++) { +uint32_t format = formats[i]; + +for (int j =0 ; j <ARRAY_SIZE (modifiers); j++) { +uint64_t modifier = modifiers[j]; +struct drm_mode_fb_cmd2 f = { + .width =64 , + .height =64 , + .pixel_format = format, + .handles[0 ] = handle, + .pitches[0 ] =64 *8 , + .modifier[0 ] = modifier, + .flags =DRM_MODE_FB_MODIFIERS , + }; +int ret; + + igt_info("Testing format " IGT_FORMAT_FMT " / modifier 0x%" PRIx64 "\n", +IGT_FORMAT_ARGS (format), modifier); + + ret =drmIoctl (fd,DRM_IOCTL_MODE_ADDFB2 , &f);
tests/kms_addfb_basic.c line 127
Quoted 10 lines
tests/kms_addfb_basic.c +9
-0+ +if (igt_display_has_format_mod (display, format, modifier)) { +igt_assert_eq (ret,0 ); +igt_assert_neq (f.fb_id,0 ); + }else { +igt_assert_neq (ret,0 ); +igt_assert_eq (f.fb_id,0 ); + } +
I was fine with this until I ran the test and it failed. My problem with this style is that once you hit one of these assertions you stop the test, so you don't get an idea of how bad your Kernel is. You could simply igt_info() the failures, failures++ (or false_positives++ and false_negatives++) and then igt_assert(failures == 0) outside the loop. This way we can see all the bad combinations in one run, without having to fix the first problem in order to uncover the next.
Everything else looks good.
Quoted 34 lines
tests/kms_addfb_basic.c +7
-0+drmIoctl (fd,DRM_IOCTL_MODE_RMFB , &f.fb_id); + } + } + +gem_close (fd, handle); +} +static void
invalid_tests(int fd)
{tests/kms_addfb_basic.c +6
-2struct local_drm_mode_fb_cmd2 f = {};@@ -539,13 +630,17 @@ static void prop_tests(int fd) } -int fd; +static igt_display_t display; +static int fd;igt_main { -igt_fixture + igt_fixture { fd =drm_open_driver_master (DRIVER_ANY ); +igt_display_init (&display, fd); + } +invalid_tests (fd);pitch_tests (fd);@@ -560,6 +655,12 @@ igt_mainprop_tests (fd);
tests/kms_addfb_basic.c igt_main · line 666
Quoted 10 lines
tests/kms_addfb_basic.c +7
-1-igt_fixture + igt_subtest("expected-formats") +expected_formats (&display); + + igt_fixture { +igt_display_fini (&display); +close (fd); + } }
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 06/25] lib/igt_fb: Respect the users choice of stride
In reply to Ville SyrjalaEm Qui, 2018-07-19 às 18:03 +0300, Ville Syrjala escreveu:
Quoted 7 lines
From: Ville Syrjälä <[email protected]>
We prented to allow the caller to specify the stride explicitly for the
fb. But we don't actually use that user specified stride when we calculate the require bo size. Fix that oversight.
Requires simple rebase.
Quoted 124 lines
Signed-off-by Ville Syrjälä <[email protected]>--- lib/igt_fb.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-)lib/igt_fb.c +0
-0@@ -215,11 +215,12 @@ static unsigned planar_height(struct
format_desc_struct*format, unsigned heightstatic void calc_fb_size_planar(int fd, int width, int height,
lib/igt_fb.c +0
-2struct format_desc_struct *format, - uint64_t tiling, unsigned *size_ret, - unsigned *stride_ret, unsigned*offsets)
lib/igt_fb.c +2
-0+ uint64_t tiling, unsigned stride, + unsigned *size_ret, unsigned
*stride_ret,lib/igt_fb.c +7
-3+ unsigned *offsets) {int plane; -unsigned stride =0 , tile_width, tile_height; +unsigned max_stride =0 , tile_width, tile_height; *size_ret =0 ;@@ -229,10 +230,13 @@ static void calc_fb_size_planar(int fd, int width, int height,igt_get_fb_tile_size (fd, tiling, format- >plane_bpp[plane], &tile_width, &tile_height); plane_stride =ALIGN (planar_stride (format, width, plane), tile_width); -if (stride < plane_stride) - stride = plane_stride; +if (max_stride < plane_stride) + max_stride = plane_stride; } +if (!stride) + stride = max_stride; +lib/igt_fb.c +2
-2for (plane =0 ; plane < format->num_planes; plane++) {if (offsets) offsets[plane] = *size_ret;@@ -251,9 +255,9 @@ static void calc_fb_size_planar(int fd, int width, int height, static void calc_fb_size_packed(int fd, int width, int height, struct format_desc_struct *format, uint64_t tiling, -unsigned *size_ret,unsigned *stride_ret) + unsigned stride, unsigned *size_ret, unsigned *stride_ret) { -unsigned int tile_width, tile_height, stride, size; +unsigned int tile_width, tile_height, size;int byte_width = width * (format->plane_bpp[0 ] /8 ); igt_get_fb_tile_size(fd, tiling, format->plane_bpp[0],
&tile_width,&tile_height);lib/igt_fb.c +7
-4@@ -270,15 +274,18 @@ static void calc_fb_size_packed(int fd, intwidth, int height, * tiled. But then that failure is expected. */ - v = byte_width; -for (stride =512 ; stride < v; stride *=2 ) - ; +if (!stride) { + v = byte_width; +for (stride =512 ; stride < v; stride *=2 ) + ; + } v = stride * height;for (size =1024 *1024 ; size < v; size *=2 ) ; }else { - stride =ALIGN (byte_width, tile_width); +if (!stride) + stride =ALIGN (byte_width, tile_width); size = stride *ALIGN (height, tile_height); }@@ -306,9 +313,9 @@ void igt_calc_fb_size(int fd, int width, intheight,
uint32_tdrm_format, uint64lib/igt_fb.c +0
-1igt_assert (format);if (format->num_planes >1 ) - calc_fb_size_planar(fd, width, height, format,tiling,
size_ret,stride_ret, NULL);lib/igt_fb.c +1
-0+ calc_fb_size_planar(fd, width, height, format,tiling, 0,
size_ret,stride_ret, NULL);lib/igt_fb.c +0
-1else - calc_fb_size_packed(fd, width, height, format,tiling,
size_ret,stride_ret);lib/igt_fb.c +1
-0+ calc_fb_size_packed(fd, width, height, format,tiling, 0,
size_ret,stride_ret);
}/**
lib/igt_fb.c +1
-2@@ -383,10 +390,10 @@ static int create_bo_for_fb(int fd, int width,int height, unsigned calculated_size, calculated_stride;if (format->num_planes >1 ) -calc_fb_size_planar (fd, width, height, format, tiling, +calc_fb_size_planar (fd, width, height, format, tiling, stride, &calculated_size, &calculated_stride, offsets);else - calc_fb_size_packed(fd, width, height,format, tiling,
lib/igt_fb.c +1
-0+ calc_fb_size_packed(fd, width, height,format, tiling, stride,
&calculated_size,&calculated_stride);
Quoted 1 line
if (stride == 0)
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 08/25] lib/igt_fb: Use fb_blit_upload as the base class for fb_convert_blit_upload
In reply to Ville SyrjalaEm Qui, 2018-07-19 às 18:03 +0300, Ville Syrjala escreveu:
Quoted 5 lines
From: Ville Syrjälä <[email protected]>
fb_blit_uploadalready has everything we need, so let's use it as the base class forfb_convert_blit_upload.
Quoted 194 lines
Signed-off-by Ville Syrjälä <[email protected]>--- lib/igt_fb.c | 57 +++++++++++++++++++++++++++----------------------- ------- 1 file changed, 27 insertions(+), 30 deletions(-)lib/igt_fb.c +1
-4@@ -1368,15 +1368,12 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) }struct fb_convert_blit_upload { -int fd; -struct igt_fb *fb; +struct fb_blit_upload base;struct {uint8_t *map;unsigned stride, size; } rgb24; - -struct fb_blit_linear linear; };static
uint8_tclamprgb(float val)lib/igt_fb.c +2
-2@@ -1404,8 +1401,8 @@ static void convert_nv12_to_rgb24(struct igt_fb *fb, struct fb_convert_blit_uploint i, j;const uint8_t *y, *uv;uint8_t *rgb24 = blit->rgb24.map; -unsigned rgb24_stride = blit->rgb24.stride, planar_stride = blit->linear.stride; -uint8_t *buf =malloc (blit->linear.size); +unsigned rgb24_stride = blit->rgb24.stride, planar_stride = blit->base.linear.stride; +uint8_t *buf =malloc (blit->base.linear.size);struct
igt_mat4m = igt_ycbcr_to_rgb_matrix(fb-Quoted 1 line
color_encoding,fb-
Quoted 1 line
color_range);lib/igt_fb.c +0
-0@@ -1414,9 +1411,9 @@ static void convert_nv12_to_rgb24(struct igt_fb *fb, struct fb_convert_blit_uplo * it's faster to copy the whole BO to a temporary bufferand convert
lib/igt_fb.c +0
-1* from there. */ - igt_memcpy_from_wc(buf, blit->linear.map, blit-Quoted 1 line
linear.size);
lib/igt_fb.c +1
-2- y = &buf[blit->linear.offsets[0 ]]; - uv = &buf[blit->linear.offsets[1 ]]; + igt_memcpy_from_wc(buf, blit->base.linear.map, blit-Quoted 1 line
base.linear.size);
lib/igt_fb.c +2
-0+ y = &buf[blit->base.linear.offsets[0 ]]; + uv = &buf[blit->base.linear.offsets[1 ]];for (i =0 ; i < fb->height /2 ; i++) {for (j =0 ; j < fb->width /2 ; j++) {@@ -1510,11 +1507,11 @@ static void convert_nv12_to_rgb24(struct
igt_fb*fb, structfb_convert_blit_uplo
static void convert_rgb24_to_nv12(structigt_fb*fb, structfb_convert_blit_upload*blit)
{lib/igt_fb.c +1
-2int i, j; -uint8_t *y = &blit->linear.map[blit->linear.offsets[0 ]]; -uint8_t *uv = &blit->linear.map[blit->linear.offsets[1 ]]; + uint8_t *y = &blit->base.linear.map[blit-Quoted 1 line
base.linear.offsets[0]];
lib/igt_fb.c +1
-0+ uint8_t *uv = &blit->base.linear.map[blit-Quoted 1 line
base.linear.offsets[1]];
lib/igt_fb.c +1
-1const uint8_t *rgb24 = blit->rgb24.map;unsigned rgb24_stride = blit->rgb24.stride; -unsigned planar_stride = blit->linear.stride; +unsigned planar_stride = blit->base.linear.stride; struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(fb-Quoted 1 line
color_encoding,fb-
Quoted 1 line
color_range);lib/igt_fb.c +2
-2@@ -1641,8 +1638,8 @@ static void convert_yuyv_to_rgb24(struct igt_fb *fb, struct fb_convert_blit_uploint i, j;const uint8_t *yuyv;uint8_t *rgb24 = blit->rgb24.map; -unsigned rgb24_stride = blit->rgb24.stride, yuyv_stride = blit->linear.stride; -uint8_t *buf =malloc (blit->linear.size); +unsigned rgb24_stride = blit->rgb24.stride, yuyv_stride = blit->base.linear.stride; +uint8_t *buf =malloc (blit->base.linear.size);struct
igt_mat4m = igt_ycbcr_to_rgb_matrix(fb-Quoted 1 line
color_encoding,fb-
Quoted 1 line
color_range);lib/igt_fb.c +0
-0@@ -1651,7 +1648,7 @@ static void convert_yuyv_to_rgb24(struct igt_fb *fb, struct fb_convert_blit_uplo * it's faster to copy the whole BO to a temporary bufferand convert
lib/igt_fb.c +0
-1* from there. */ - igt_memcpy_from_wc(buf, blit->linear.map, blit-Quoted 1 line
linear.size);
lib/igt_fb.c +1
-0+ igt_memcpy_from_wc(buf, blit->base.linear.map, blit-Quoted 1 line
base.linear.size);
lib/igt_fb.c +0
-0yuyv = buf;for (i =0 ; i < fb->height; i++) {@@ -1698,10 +1695,10 @@ static void convert_rgb24_to_yuyv(struct
igt_fb*fb, structfb_convert_blit_uplolib/igt_fb.c +2
-2const unsigned char swz[4]) {int i, j; -uint8_t *yuyv = blit->linear.map; +uint8_t *yuyv = blit->base.linear.map;const uint8_t *rgb24 = blit->rgb24.map;unsigned rgb24_stride = blit->rgb24.stride; -unsigned yuyv_stride = blit->linear.stride; +unsigned yuyv_stride = blit->base.linear.stride; struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(fb-Quoted 1 line
color_encoding,fb-
Quoted 1 line
color_range);lib/igt_fb.c +1
-1@@ -1750,7 +1747,7 @@ static void convert_rgb24_to_yuyv(struct igt_fb *fb, struct fb_convert_blit_uplostatic void destroy_cairo_surface__convert (void *arg) {struct fb_convert_blit_upload *blit = arg; -struct igt_fb *fb = blit->fb; +struct igt_fb *fb = blit->base.fb;/* Convert linear rgb back! */ lib/igt_fb.c +3
-3switch (fb->drm_format) {@@ -1770,10 +1767,10 @@ static void destroy_cairo_surface__convert(void *arg)munmap (blit->rgb24.map, blit->rgb24.size); -if (blit->linear.handle) -free_linear_mapping (blit->fd, blit->fb, &blit- >linear); +if (blit->base.linear.handle) +free_linear_mapping (blit->base.fd, blit->base.fb, &blit->base.linear);else - gem_munmap(blit->linear.map, fb->size); +gem_munmap (blit->base.linear.map, fb->size);lib/igt_fb.c +2
-2free (blit);@@ -1785,8 +1782,8 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)struct fb_convert_blit_upload *blit =malloc (sizeof (*blit));igt_assert (blit); - blit->fd = fd; - blit->fb = fb; + blit->base.fd = fd; + blit->base.fb = fb; blit->rgb24.stride =ALIGN (fb->width *4 ,16 ); blit->rgb24.size = ALIGN(blit->rgb24.stride * fb->height,
sysconf(_SC_PAGESIZE));
blit->rgb24.map= mmap(NULL,blit->rgb24.size,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);lib/igt_fb.c +3
-7@@ -1794,15 +1791,15 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) { -setup_linear_mapping (fd, fb, &blit->linear); +setup_linear_mapping (fd, fb, &blit->base.linear); }else { - blit->linear.handle =0 ; - blit->linear.map =gem_mmap__gtt (fd, fb->gem_handle, fb->size, + blit->base.linear.handle =0 ; + blit->base.linear.map =gem_mmap__gtt (fd, fb- >gem_handle, fb->size,PROT_READ |PROT_WRITE ); -igt_assert (blit->linear.map); - blit->linear.stride = fb->stride; - blit->linear.size = fb->size; - memcpy(blit->linear.offsets, fb->offsets, sizeof(fb-Quoted 1 line
offsets));
lib/igt_fb.c +4
-0+igt_assert (blit->base.linear.map); + blit->base.linear.stride = fb->stride; + blit->base.linear.size = fb->size; + memcpy(blit->base.linear.offsets, fb->offsets,
sizeof(fb->offsets));
lib/igt_fb.c static void create_cairo_surface__convert(int fd, struct igt_fb *fb) · line 1805
Quoted 3 lines
lib/igt_fb.c +0
-0}/* Convert to linear rgb! */
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 09/25] lib/igt_fb: Pass fb_blit_upload to free_linear_mapping()
In reply to Ville SyrjalaEm Qui, 2018-07-19 às 18:03 +0300, Ville Syrjala escreveu:
Quoted 5 lines
From: Ville Syrjälä <[email protected]>
With
fb_blit_uploadnow being the base class offb_convert_blit_upload
we can pass the entire structure down tofree_linear_mapping().
Quoted 43 lines
Signed-off-by Ville Syrjälä <[email protected]>--- lib/igt_fb.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)lib/igt_fb.c +5
-2@@ -1208,8 +1208,11 @@ struct fb_blit_upload {struct fb_blit_linear linear; }; -static void free_linear_mapping (int fd,struct igt_fb *fb,struct fb_blit_linear *linear) +static void free_linear_mapping (struct fb_blit_upload *blit) { +int fd = blit->fd; +struct igt_fb *fb = blit->fb; +struct fb_blit_linear *linear = &blit->linear;unsigned int obj_tiling =igt_fb_mod_to_tiling (fb->tiling);int i;@@ -1242,7 +1245,7 @@ static void destroy_cairo_surface__blit(void *arg) blit->fb->cairo_surface =NULL ; -free_linear_mapping (blit->fd, blit->fb, &blit->linear); +free_linear_mapping (blit);free (blit);}
lib/igt_fb.c +1
-1@@ -1768,7 +1771,7 @@ static void destroy_cairo_surface__convert(void *arg)munmap (blit->rgb24.map, blit->rgb24.size);if (blit->base.linear.handle) -free_linear_mapping (blit->base.fd, blit->base.fb, &blit->base.linear); +free_linear_mapping (&blit->base); else
Quoted 2 lines
gem_munmap(blit->base.linear.map, fb->size);
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Quoted 11 lines · Paulo Zanoni
Em Qui, 2018-07-19 às 18:03 +0300, Ville Syrjala escreveu:
Quoted 7 lines
From: Ville Syrjälä <[email protected]>
For drivers that don't support the
IN_FORMATSblob we should just consult the format list returned by getplane. Since we can't know which modifiers are supported we'll assume linear-only. Obviously that may not work for every driver out there, but not much more we can do unless we start to actually probing with addfb.Can you please elaborate on why we need that change? What exactly do we gain from it?
We gain the ability to write tests without worrying about IN_FORMATS everywhere.
Quoted 4 lines
IMHO there's always the worry that this could be misused
in the future, restricting tests to linear only when other formats are indeed possible. Having NULL buffers crashing the test is a good way to prevent misuse.
I don't know what kind of misuse you're thinking of. Actually not sure what misuse in this context would mean really.
Quoted 5 lines
What if we populate
plane->formatslike we do here but leave plane-Quoted 1 line
modifiers NULL? It would allow other pieces of the code to rely on the
format list while not exposing the risk of the "linear only" incorrect restriction.
So every test would have to check for !modifiers and come up with some kind of fallback mechanism? What would such a fallback mechanism even be other than "let's assume linear"? I see no reason to inflict that pain on every test that just wants to know "is this format supported?".
Also any driver that advertizes formats that don't support linear and doesn't expose IN_FORMATS clearly doesn't care about supporting driver/hw agnostic userspace, so having some tests fail for them seems perfectly reasonable to me.
Quoted 48 lines
That said, the patch is correct in the sense that it does what it proposes to do.
Quoted 44 lines
Cc Ulrich Hecht <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- lib/igt_kms.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)lib/igt_kms.c +0
-0@@ -4068,8 +4068,28 @@ static voidigt_fill_plane_format_mod(igt_display_t *display,
igt_plane_t*planelib/igt_kms.c +7
-1int idx =0 ;int count; -if (!igt_plane_has_prop (plane,IGT_PLANE_IN_FORMATS )) +if (!igt_plane_has_prop (plane,IGT_PLANE_IN_FORMATS )) { +drmModePlanePtr p = plane->drm_plane; + + count = p->count_formats; + + plane->format_mod_count = count; + plane->formats = calloc(count, sizeof(plane-Quoted 1 line
formats[0]));
lib/igt_kms.c +2
-0+igt_assert (plane->formats); + plane->modifiers = calloc(count, sizeof(plane-Quoted 1 line
modifiers[0]));
lib/igt_kms.c +12
-0+igt_assert (plane->modifiers); + +/* +* We don't know which modifiers are +* supported, so we'll assume linear only. +*/ +for (int i =0 ; i < count; i++) { + plane->formats[i] = p->formats[i]; + plane->modifiers[i] =DRM_FORMAT_MOD_LINEAR ; + } +return ; + } blob_id =igt_plane_get_prop (plane,IGT_PLANE_IN_FORMATS );
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 04/25] tests/kms_addfb_basic: Check that addfb2 accepts/rejects the expected formats
In reply to Paulo ZanoniQuoted 33 lines · Paulo Zanoni
Em Qui, 2018-07-19 às 18:03 +0300, Ville Syrjala escreveu:
Quoted 11 lines
From: Ville Syrjälä <[email protected]>
Try to create a bunch of fbs with different formats/modfifiers and make sure sure addfb2 accepts/rejects them in accordance with what the plane
IN_FORMATSblobifiers are advertizing.We only check "easy" formats (ie. RGB/C8, no YUV/planar etc.). We also assume that one can always create a 64x64 fb with stride of 64*8 bytes.
v2: Skip when blobifiers aren't supported
Some trivial rebasing required.
More below.
Quoted 16 lines
Cc Ulrich Hecht <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- tests/kms_addfb_basic.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 104 insertions(+), 3 deletions(-)tests/kms_addfb_basic.c +0
-0@@ -41,6 +41,97 @@uint32_t gem_bo;uint32_t gem_bo_small;
Quoted 12 lines
tests/kms_addfb_basic.c line 50
Quoted 7 lines
tests/kms_addfb_basic.c +7
-0+static const uint64_t modifiers[] = { +DRM_FORMAT_MOD_LINEAR , +I915_FORMAT_MOD_X_TILED , +I915_FORMAT_MOD_Y_TILED , + I915_FORMAT_MOD_Yf_TILED, +I915_FORMAT_MOD_Y_TILED_CCS , + I915_FORMAT_MOD_Yf_TILED_CCS,For the buffers that support CCS, I see the test failing with the Kernel complaining that we're not passing 2 planes (since .num_planes=2 in
ccs_formatsfromintel_display.c). It looks like igt needs to craft the aux buffer too.
I shouldn't have included CCS here, for the same reason I didn't include planar formats in formats[]. I guess I never ran this in skl+.
Quoted 41 lines
More below.
Quoted 38 lines
tests/kms_addfb_basic.c +38
-0+}; + +static const uint32_t formats[] = { +DRM_FORMAT_C8 , + +DRM_FORMAT_RGB565 , +DRM_FORMAT_BGR565 , + +DRM_FORMAT_RGB888 , +DRM_FORMAT_BGR888 , + +DRM_FORMAT_XRGB8888 , +DRM_FORMAT_XBGR8888 , +DRM_FORMAT_RGBX8888 , +DRM_FORMAT_BGRX8888 , +DRM_FORMAT_ARGB8888 , +DRM_FORMAT_ABGR8888 , +DRM_FORMAT_RGBA8888 , +DRM_FORMAT_BGRA8888 , + +DRM_FORMAT_XRGB2101010 , +DRM_FORMAT_XBGR2101010 , +DRM_FORMAT_RGBX1010102 , +DRM_FORMAT_BGRX1010102 , +DRM_FORMAT_ARGB2101010 , +DRM_FORMAT_ABGR2101010 , +DRM_FORMAT_RGBA1010102 , +DRM_FORMAT_BGRA1010102 , +}; + +#define IGT_FORMAT_FMT "%c%c%c%c (0x%08x)" +#define IGT_FORMAT_ARGS (f) ((f) >> 0) & 0xff, ((f) >> 8) & 0xff, \ + ((f) >> 16) & 0xff, ((f) >> 24) & 0xff, (f) + +/* +* make sure addfb2 accepts/rejects every format/modifier +* in accordance with the plane IN_FORMATS properties. +*/
Quoted 8 lines
tests/kms_addfb_basic.c line 94
Quoted 6 lines
tests/kms_addfb_basic.c +6
-0+static void expected_formats (igt_display_t *display) +{ +int fd = display->drm_fd; +uint32_t handle; + +igt_require (display->format_mod_count);After patch 01, this is really not skipping a lot.
Yeah, I wrote this before that patch probably.
Quoted 8 lines
Perhaps it would be better to
igt_require(plane->modifiers)if you implement my suggestion from patch 01? :)tests/kms_addfb_basic.c line 96
Quoted 2 lines
tests/kms_addfb_basic.c +2
-0+ + handle =gem_create (fd,64 *8 *64 );I'm assuming you have checked that this is sane.
Should be fairly reasonable.
Quoted 37 lines
Quoted 26 lines
tests/kms_addfb_basic.c +22
-0+igt_assert (handle); + +for (int i =0 ; i <ARRAY_SIZE (formats); i++) { +uint32_t format = formats[i]; + +for (int j =0 ; j <ARRAY_SIZE (modifiers); j++) { +uint64_t modifier = modifiers[j]; +struct drm_mode_fb_cmd2 f = { + .width =64 , + .height =64 , + .pixel_format = format, + .handles[0 ] = handle, + .pitches[0 ] =64 *8 , + .modifier[0 ] = modifier, + .flags =DRM_MODE_FB_MODIFIERS , + }; +int ret; + + igt_info("Testing format " IGT_FORMAT_FMT " / modifier 0x%" PRIx64 "\n", +IGT_FORMAT_ARGS (format), modifier); + + ret =drmIoctl (fd,DRM_IOCTL_MODE_ADDFB2 , &f);tests/kms_addfb_basic.c line 127
Quoted 10 lines
tests/kms_addfb_basic.c +9
-0+ +if (igt_display_has_format_mod (display, format, modifier)) { +igt_assert_eq (ret,0 ); +igt_assert_neq (f.fb_id,0 ); + }else { +igt_assert_neq (ret,0 ); +igt_assert_eq (f.fb_id,0 ); + } +
Quoted 7 lines
I was fine with this until I ran the test and it failed. My problem with this style is that once you hit one of these assertions you stop the test, so you don't get an idea of how bad your Kernel is. You could simply
igt_info()the failures, failures++ (or false_positives++ and false_negatives++) and thenigt_assert(failures == 0)outside the loop. This way we can see all the bad combinations in one run, without having to fix the first problem in order to uncover the next.
I prefer to assert on the first error. Then you can easily run it under gdb and examine the full state when the failure occurs.
Quoted 47 lines
Everything else looks good.
Quoted 44 lines
tests/kms_addfb_basic.c +7
-0+drmIoctl (fd,DRM_IOCTL_MODE_RMFB , &f.fb_id); + } + } + +gem_close (fd, handle); +} +static void
invalid_tests(int fd)
{tests/kms_addfb_basic.c +13
-3struct local_drm_mode_fb_cmd2 f = {};@@ -539,13 +630,17 @@ static void prop_tests(int fd) } -int fd; +static igt_display_t display; +static int fd;igt_main { -igt_fixture + igt_fixture { fd =drm_open_driver_master (DRIVER_ANY ); +igt_display_init (&display, fd); + } +invalid_tests (fd);pitch_tests (fd);@@ -560,6 +655,12 @@ igt_mainprop_tests (fd); -igt_fixture + igt_subtest("expected-formats") +expected_formats (&display); + + igt_fixture { +igt_display_fini (&display); +close (fd); + } }
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Em Sex, 2018-09-21 às 16:26 +0300, Ville Syrjälä escreveu:
Quoted 24 lines · Paulo Zanoni
Quoted 9 lines
Em Qui, 2018-07-19 às 18:03 +0300, Ville Syrjala escreveu:
Quoted 7 lines
From: Ville Syrjälä <[email protected]>
For drivers that don't support the
IN_FORMATSblob we should just consult the format list returned by getplane. Since we can't know which modifiers are supported we'll assume linear-only. Obviously that may not work for every driver out there, but not much more we can do unless we start to actually probing with addfb.Quoted 3 lines
Can you please elaborate on why we need that change? What exactly do we
gain from it?We gain the ability to write tests without worrying about
IN_FORMATSeverywhere.Quoted 6 lines
IMHO there's always the worry that this could be misused in the future, restricting tests to linear only when other formats are
indeed possible. Having NULL buffers crashing the test is a good way to
prevent misuse.
Quoted 2 lines
I don't know what kind of misuse you're thinking of. Actually not sure what misuse in this context would mean really.
Thinking that everything is linear only when in fact other formats are actually supported.
Quoted 6 lines
Quoted 6 lines
What if we populate
plane->formatslike we do here but leave plane-Quoted 2 lines
modifiers NULL? It would allow other pieces of the code to rely on the
Quoted 6 lines
Quoted 3 lines
format list while not exposing the risk of the "linear only" incorrect
restriction.So every test would have to check for !modifiers and come up with some kind of fallback mechanism?
Yes, if IN_FORMATS is not present you have to fallback to the old "try it until you don't get an EINVAL". Isn't this the old protocol?
Quoted 2 lines
What would such a fallback mechanism
even be other than "let's assume linear"?
The same mechanism we used before we created IN_FORMATS.
Quoted 3 lines
I see no reason to inflict
that pain on every test that just wants to know "is this format supported?".
The way I see, not populating a wrong table helps the test more than setting a table with data that may not reflect reality.
Quoted 5 lines
Also any driver that advertizes formats that don't support linear and doesn't expose
IN_FORMATSclearly doesn't care about supporting driver/hw agnostic userspace, so having some tests fail for them seems perfectly reasonable to me.
So older i915 didn't care about supporting driver/hw agnostic user space?
Quoted 51 lines
Quoted 51 lines
That said, the patch is correct in the sense that it does what it proposes to do.
Quoted 46 lines
Cc Ulrich Hecht <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- lib/igt_kms.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)lib/igt_kms.c +0
-0@@ -4068,8 +4068,28 @@ static voidigt_fill_plane_format_mod(igt_display_t *display,
igt_plane_t*planelib/igt_kms.c +7
-1int idx =0 ;int count; -if (!igt_plane_has_prop (plane,IGT_PLANE_IN_FORMATS )) +if (!igt_plane_has_prop (plane,IGT_PLANE_IN_FORMATS )) { +drmModePlanePtr p = plane->drm_plane; + + count = p->count_formats; + + plane->format_mod_count = count; + plane->formats = calloc(count, sizeof(plane-Quoted 1 line
formats[0]));
lib/igt_kms.c +2
-0+igt_assert (plane->formats); + plane->modifiers = calloc(count, sizeof(plane-Quoted 1 line
modifiers[0]));
lib/igt_kms.c +9
-0+igt_assert (plane->modifiers); + +/* +* We don't know which modifiers are +* supported, so we'll assume linear only. +*/ +for (int i =0 ; i < count; i++) { + plane->formats[i] = p->formats[i]; + plane->modifiers[i] =
DRM_FORMAT_MOD_LINEAR;lib/igt_kms.c +3
-0+ } +return ; + }
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
blob_id= igt_plane_get_prop(plane,IGT_PLANE_IN_FORMATS);
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 10/25] lib/igt_fb: s/planar_foo/fb_plane_foo/
In reply to Ville SyrjalaEm Qui, 2018-07-19 às 18:04 +0300, Ville Syrjala escreveu:
Quoted 4 lines
From: Ville Syrjälä <[email protected]>
Rename the
planar_foo()functions tofb_plane_foo(). Makes it clear they're perfectly usable with non-planar formts too.
s/formts/formats/
Quoted 95 lines
Signed-off-by Ville Syrjälä <[email protected]>--- lib/igt_fb.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)lib/igt_fb.c +2
-1@@ -190,7 +190,8 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, } } -static unsigned planar_width (struct format_desc_struct *format, unsigned width, int plane) +static unsigned fb_plane_width (struct format_desc_struct *format, +unsigned width,int plane) {lib/igt_fb.c +3
-3if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 )return DIV_ROUND_UP (width,2 );@@ -198,14 +199,16 @@ static unsigned planar_width(struct format_desc_struct *format, unsigned width, return width; } -static unsigned planar_stride (struct format_desc_struct *format, unsigned width, int plane) +static unsigned fb_plane_min_stride (struct format_desc_struct *format, +unsigned width,int plane) {unsigned cpp = format->plane_bpp[plane] /8 ; -return planar_width (format, width, plane) * cpp; +return fb_plane_width (format, width, plane) * cpp; } -static unsigned planar_height(struct format_desc_struct *format,unsigned height, int plane)
lib/igt_fb.c +3
-1+static unsigned fb_plane_height (struct format_desc_struct *format, +unsigned height,int plane) {if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 )return DIV_ROUND_UP (height,2 );@@ -229,7 +232,7 @@ static void calc_fb_size_planar(int fd, int width, int height,igt_get_fb_tile_size (fd, tiling, format- >plane_bpp[plane], &tile_width, &tile_height); - plane_stride =ALIGN (planar_stride (format, width, plane), tile_width); + plane_stride = ALIGN(fb_plane_min_stride(format,width, plane),
tile_width);lib/igt_fb.c +1
-1if (max_stride < plane_stride) max_stride = plane_stride; }@@ -243,7 +246,7 @@ static void calc_fb_size_planar(int fd, int width, int height,igt_get_fb_tile_size (fd, tiling, format- >plane_bpp[plane], &tile_width, &tile_height); - *size_ret += stride *ALIGN (planar_height (format, height, plane), tile_height); + *size_ret += stride * ALIGN(fb_plane_height(format,height, plane),
tile_height);lib/igt_fb.c +1
-1}if (offsets)@@ -258,7 +261,7 @@ static void calc_fb_size_packed(int fd, int width, int height, unsigned stride, unsigned *size_ret, unsigned *stride_ret) {unsigned int tile_width, tile_height, size; -int byte_width = width * (format->plane_bpp[0 ] /8 ); +int byte_width =fb_plane_min_stride (format, width,0 );igt_get_fb_tile_size(fd, tiling, format->plane_bpp[0],
&tile_width,&tile_height);lib/igt_fb.c +2
-2@@ -885,8 +888,8 @@ igt_create_fb_with_bo_size(int fd, int width, int height, for (i = 0; i < f->num_planes; i++) { fb->plane_bpp[i] = f->plane_bpp[i]; - fb->plane_height[i] =planar_height (f, height, i); - fb->plane_width[i] =planar_width (f, width, i); + fb->plane_height[i] =fb_plane_height (f, height, i); + fb->plane_width[i] =fb_plane_width (f, width, i); }
Quoted 1 line
return
fb_id;
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 11/25] lib/igt_fb: Add fb_plane_bpp()
In reply to Ville SyrjalaEm Qui, 2018-07-19 às 18:04 +0300, Ville Syrjala escreveu:
Quoted 4 lines
From: Ville Syrjälä <[email protected]>
Add another helper to get the bpp for a specific color plane. We'll need this for ccs support later.
Quoted 89 lines
Signed-off-by Ville Syrjälä <[email protected]>--- lib/igt_fb.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)lib/igt_fb.c +6
-1@@ -199,10 +199,15 @@ static unsigned fb_plane_width(structformat_desc_struct *format, return width; } +static unsigned fb_plane_bpp (struct format_desc_struct *format,int plane) +{ +return format->plane_bpp[plane]; +} +static unsigned fb_plane_min_stride (struct format_desc_struct *format,unsigned width,int plane) { -unsigned cpp = format->plane_bpp[plane] /8 ; +unsigned cpp =fb_plane_bpp (format, plane) /8 ;lib/igt_fb.c +2
-1return fb_plane_width (format, width, plane) * cpp; }@@ -230,7 +235,8 @@ static void calc_fb_size_planar(int fd, int width, int height, for (plane = 0; plane < format->num_planes; plane++) {unsigned plane_stride; -igt_get_fb_tile_size (fd, tiling, format- >plane_bpp[plane], &tile_width, &tile_height); +igt_get_fb_tile_size (fd, tiling,fb_plane_bpp (format, plane), + &tile_width, &tile_height);
plane_stride= ALIGN(fb_plane_min_stride(format,
width, plane),tile_width);lib/igt_fb.c +2
-1if (max_stride < plane_stride)@@ -244,7 +250,8 @@ static void calc_fb_size_planar(int fd, int width, int height, if (offsets) offsets[plane] = *size_ret; -igt_get_fb_tile_size (fd, tiling, format- >plane_bpp[plane], &tile_width, &tile_height); +igt_get_fb_tile_size (fd, tiling,fb_plane_bpp (format, plane), + &tile_width, &tile_height);
*size_ret+= stride * ALIGN(fb_plane_height(format,
height, plane),tile_height);lib/igt_fb.c +2
-1}@@ -263,7 +270,8 @@ static void calc_fb_size_packed(int fd, int width, int height, unsigned int tile_width, tile_height, size;int byte_width =fb_plane_min_stride (format, width,0 ); -igt_get_fb_tile_size (fd, tiling, format->plane_bpp[0 ], &tile_width, &tile_height); +igt_get_fb_tile_size (fd, tiling,fb_plane_bpp (format,0 ), + &tile_width, &tile_height);lib/igt_fb.c +1
-1if (tiling !=LOCAL_DRM_FORMAT_MOD_NONE &&intel_gen (intel_get_drm_devid (fd)) <=3 ) {@@ -456,7 +464,7 @@ static int create_bo_for_fb(int fd, int width,int height, *is_dumb = true;return kmstest_dumb_create (fd, width, height, - format->plane_bpp[0 ], +fb_plane_bpp (format,0 ), stride_ret, size_ret); }}
lib/igt_fb.c +1
-1@@ -887,7 +895,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height, fb->color_range = color_range;for (i =0 ; i < f->num_planes; i++) { - fb->plane_bpp[i] = f->plane_bpp[i]; + fb->plane_bpp[i] =fb_plane_bpp (f, i); fb->plane_height[i] =fb_plane_height (f, height, i); fb->plane_width[i] =fb_plane_width (f, width, i);
Quoted 1 line
}
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 12/25] lib/igt_fb: Add fb_num_planes()
In reply to Ville SyrjalaEm Qui, 2018-07-19 às 18:04 +0300, Ville Syrjala escreveu:
Quoted 4 lines
From: Ville Syrjälä <[email protected]>
Add a helper to return the number of color planes. We'll need this for ccs support later.
Quoted 94 lines
Signed-off-by Ville Syrjälä <[email protected]>--- lib/igt_fb.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)lib/igt_fb.c +5
-0@@ -221,6 +221,11 @@ static unsigned fb_plane_height(structformat_desc_struct *format, return height; } +static int fb_num_planes (struct format_desc_struct *format) +{ +return format->num_planes; +} + static void calc_fb_size_planar(int fd, int width, int height, struct format_desc_struct *format,lib/igt_fb.c +1
-1uint64_t tiling, unsigned stride,@@ -232,7 +237,7 @@ static void calc_fb_size_planar(int fd, int width, int height, *size_ret =0 ; -for (plane =0 ; plane < format->num_planes; plane++) { +for (plane =0 ; plane <fb_num_planes (format); plane++) {unsigned plane_stride;igt_get_fb_tile_size(fd, tiling,
fb_plane_bpp(format, plane),lib/igt_fb.c +1
-1@@ -246,7 +251,7 @@ static void calc_fb_size_planar(int fd, int width, int height, if (!stride) stride = max_stride; -for (plane =0 ; plane < format->num_planes; plane++) { +for (plane =0 ; plane <fb_num_planes (format); plane++) {if (offsets) offsets[plane] = *size_ret;@@ -323,7 +328,7 @@ void igt_calc_fb_size(int fd, int width, intheight,
uint32_tdrm_format, uint64
structformat_desc_struct*format =lookup_drm_format(drm_format);lib/igt_fb.c +1
-1igt_assert (format); -if (format->num_planes >1 ) +if (fb_num_planes (format) >1 ) calc_fb_size_planar(fd, width, height, format,tiling, 0,
size_ret,stride_ret, NULL);lib/igt_fb.c +0
-0else calc_fb_size_packed(fd, width, height, format,tiling, 0,
size_ret,stride_ret);lib/igt_fb.c +1
-1@@ -400,7 +405,7 @@ static int create_bo_for_fb(int fd, int width,int height, if (tiling || size || stride || igt_format_is_yuv(format- >drm_id)) { unsigned calculated_size, calculated_stride; - if (format->num_planes > 1) + if (fb_num_planes(format) > 1) calc_fb_size_planar(fd, width, height,format, tiling, stride,
&calculated_size,&calculated_stride, offsets);lib/igt_fb.c +1
-1else @@ -874,7 +879,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height, handles[0 ] = fb->gem_handle; pitches[0 ] = fb->stride; -for (i =0 ; i < f->num_planes; i++) { +for (i =0 ; i <fb_num_planes (f); i++) { handles[i] = fb->gem_handle; pitches[i] = fb->stride;lib/igt_fb.c +2
-2}@@ -890,11 +895,11 @@ igt_create_fb_with_bo_size(int fd, int width,int height, fb->drm_format = format; fb->fb_id = fb_id; fb->fd = fd; - fb->num_planes = f->num_planes; + fb->num_planes =fb_num_planes (f); fb->color_encoding = color_encoding; fb->color_range = color_range; -for (i =0 ; i < f->num_planes; i++) { +for (i =0 ; i <fb_num_planes (f); i++) { fb->plane_bpp[i] =fb_plane_bpp (f, i); fb->plane_height[i] =fb_plane_height (f, height, i);
Quoted 1 line
fb->plane_width[i] =
fb_plane_width(f, width, i);
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 13/25] lib/igt_fb: Extract calc_plane_stride()
In reply to Ville SyrjalaEm Qui, 2018-07-19 às 18:04 +0300, Ville Syrjala escreveu:
Quoted 4 lines
From: Ville Syrjälä <[email protected]>
Extract the stride calculation from
calc_fb_size_packed()to its own thing so that we can use it to calculate just the stride.
I think it makes more sense to wait for the rebased versions before giving r-b tags to patches 13 and 14. Patch 13 looks good, but 14 is starting to get hard to review without applying it locally.
Quoted 99 lines
Signed-off-by Ville Syrjälä <[email protected]>--- lib/igt_fb.c | 53 ++++++++++++++++++++++++++++++++++++++++-------- ----- 1 file changed, 40 insertions(+), 13 deletions(-)lib/igt_fb.c +11
-0@@ -226,6 +226,38 @@ static int fb_num_planes(struct format_desc_struct *format)return format->num_planes; } +static unsigned calc_plane_stride (int fd, +struct format_desc_struct *format, +int width,uint64_t tiling,int plane) +{ +uint32_t min_stride =fb_plane_min_stride (format, width, plane); + +if (tiling !=LOCAL_DRM_FORMAT_MOD_NONE && +intel_gen (intel_get_drm_devid (fd)) <=3 ) { +uint32_t stride; + +/* Round the tiling up to the next power-of-two and the region
lib/igt_fb.c +1
-0+* up to the next pot fence size so that this works on all
lib/igt_fb.c +3
-0+* generations. +* +* This can still fail if the framebuffer is too large to be
lib/igt_fb.c +20
-4+* tiled. But then that failure is expected. +*/ +for (stride =512 ; stride < min_stride; stride *=2 ) + ; + +return stride; + }else { +unsigned int tile_width, tile_height; + +igt_get_fb_tile_size (fd, tiling, +fb_plane_bpp (format, plane), + &tile_width, &tile_height); + +return ALIGN (min_stride, tile_width); + } +} + static void calc_fb_size_planar(int fd, int width, int height, struct format_desc_struct *format, uint64_t tiling, unsigned stride,@@ -272,11 +304,10 @@ static void calc_fb_size_packed(int fd, int width, int height, struct format_desc_struct *format, uint64_t tiling, unsigned stride, unsigned *size_ret, unsigned *stride_ret) { -unsigned int tile_width, tile_height, size; -int byte_width =fb_plane_min_stride (format, width,0 ); +unsigned int size; -igt_get_fb_tile_size (fd, tiling,fb_plane_bpp (format,0 ), - &tile_width, &tile_height); +if (!stride) + stride = calc_plane_stride(fd, format, width,tiling, 0);
lib/igt_fb.c +0
-0if (tiling !=LOCAL_DRM_FORMAT_MOD_NONE &&intel_gen (intel_get_drm_devid (fd)) <=3 ) {@@ -289,19 +320,15 @@ static void calc_fb_size_packed(int fd, int width, int height, * This can still fail if the framebuffer is toolarge to be
lib/igt_fb.c +3
-9* tiled. But then that failure is expected. */ - -if (!stride) { - v = byte_width; -for (stride =512 ; stride < v; stride *=2 ) - ; - } - v = stride * height;for (size =1024 *1024 ; size < v; size *=2 ) ; }else { -if (!stride) - stride =ALIGN (byte_width, tile_width); +unsigned int tile_width, tile_height; + + igt_get_fb_tile_size(fd, tiling,
fb_plane_bpp(format, 0),
lib/igt_fb.c static void calc_fb_size_packed(int fd, int width, int height, · line 333
Quoted 4 lines
lib/igt_fb.c +2
-0+ &tile_width, &tile_height); + size = stride *ALIGN (height, tile_height); }
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 15/25] lib/kms: Pass strides[] to __kms_addfb
In reply to Ville SyrjalaEm Qui, 2018-07-19 às 18:04 +0300, Ville Syrjala escreveu:
Quoted 4 lines
From: Ville Syrjälä <[email protected]>
Make
__kms_addfb()usable with planar formats by passing in the stride for each plane.
I'm hoping later in this series we'll just usedrmModeAddFB2WithModifiers() :)
Or at least unify the Y vs X/linear cases below.
Quoted 201 lines
Signed-off-by Ville Syrjälä <[email protected]>--- lib/igt_fb.c | 7 ++++++- lib/ioctl_wrappers.c | 12 +++++++----- lib/ioctl_wrappers.h | 8 +++++--- tests/kms_available_modes_crc.c | 14 +++++++------- tests/kms_draw_crc.c | 6 +++--- tests/prime_vgem.c | 8 ++++++-- 6 files changed, 34 insertions(+), 21 deletions(-)lib/igt_fb.c +6
-1@@ -877,8 +877,13 @@ igt_create_fb_with_bo_size(int fd, int width,int height, if (tiling != LOCAL_DRM_FORMAT_MOD_NONE && tiling != LOCAL_I915_FORMAT_MOD_X_TILED) { + uint32_t pitches[4]; + +for (i =0 ; i <fb_num_planes (f); i++) + pitches[i] = fb->stride; + do_or_die(__kms_addfb(fd, fb->gem_handle, width, height, - fb->stride, format, tiling, fb->offsets, + format, tiling, pitches, fb-Quoted 1 line
offsets,
LOCAL_DRM_MODE_FB_MODIFIERS,&fb_id));lib/igt_fb.c +0
-0}else {uint32_t handles[4 ];lib/ioctl_wrappers.c +5
-3@@ -1670,9 +1670,11 @@ void igt_require_fb_modifiers(int fd)igt_require (has_modifiers); } -int __kms_addfb (int fd,uint32_t handle,uint32_t width,uint32_t height, -uint32_t stride,uint32_t pixel_format,uint64_t modifier, -uint32_t *offsets,uint32_t flags,uint32_t *buf_id) +int __kms_addfb(int fd, uint32_t handle, + uint32_t width, uint32_t height, + uint32_t pixel_format, uint64_t modifier, + uint32_t strides[4], uint32_t offsets[4], + uint32_t flags, uint32_t *buf_id) {lib/ioctl_wrappers.c +2
-2struct drm_mode_fb_cmd2 f;int ret, i;@@ -1686,12 +1688,12 @@ int __kms_addfb(int fd, uint32_t handle, uint32_t width, uint32_t height, f.pixel_format = pixel_format; f.flags = flags; f.handles[0 ] = handle; - f.pitches[0 ] = stride; + f.pitches[0 ] = strides[0 ]; f.modifier[0 ] = modifier;for (i =1 ; i <4 && offsets && offsets[i]; i++) { f.handles[i] = handle; - f.pitches[i] = stride; + f.pitches[i] = strides[i]; f.modifier[i] = modifier; f.offsets[i] = offsets[i];lib/ioctl_wrappers.c +0
-0}lib/ioctl_wrappers.h +5
-3@@ -235,9 +235,11 @@ void igt_require_fb_modifiers(int fd);* * Creates a framebuffer object. */ -int __kms_addfb (int fd,uint32_t handle,uint32_t width,uint32_t height, -uint32_t stride,uint32_t pixel_format,uint64_t modifier, -uint32_t *offsets,uint32_t flags,uint32_t *buf_id); +int __kms_addfb (int fd,uint32_t handle, +uint32_t width,uint32_t height, +uint32_t pixel_format,uint64_t modifier, +uint32_t strides[4 ],uint32_t offsets[4 ], +uint32_t flags,uint32_t *buf_id);/**
*to_user_pointer:tests/kms_available_modes_crc.c +2
-1@@ -255,7 +255,8 @@ static bool setup_fb(data_t *data, igt_output_t *output, igt_plane_t *plane, drmModeModeInfo *mode;uint64_t w, h;signed ret, gemsize =0 ; -unsigned tile_width, tile_height, stride; +unsigned tile_width, tile_height; +uint32_t strides[4 ] = {};uint32_t offsets[4 ] = {};uint64_t tiling;tests/kms_available_modes_crc.c +2
-2int bpp =0 ;@@ -296,8 +297,8 @@ static bool setup_fb(data_t *data, igt_output_t *output, igt_plane_t *plane,igt_get_fb_tile_size (data->gfx_fd, tiling, bpp, &tile_width, &tile_height); - stride =ALIGN (w * bpp /8 , tile_width); - gemsize = data->size = stride *ALIGN (h, tile_height); + strides[0 ] =ALIGN (w * bpp /8 , tile_width); + gemsize = data->size = strides[0 ] *ALIGN (h, tile_height);if (fillers[i].bpp ==P010 || fillers[i].bpp ==NV12 ) {tests/kms_available_modes_crc.c +3
-4offsets[1 ] = data->size;@@ -306,14 +307,13 @@ static bool setup_fb(data_t *data, igt_output_t *output, igt_plane_t *plane, data->gem_handle =gem_create (data->gfx_fd, gemsize); ret =__gem_set_tiling (data->gfx_fd, data->gem_handle, -igt_fb_mod_to_tiling (tiling), stride); +igt_fb_mod_to_tiling (tiling), strides[0]);igt_assert_eq (ret,0 ); ret = __kms_addfb(data->gfx_fd, data->gem_handle, w, h, - stride, format, tiling, - offsets,LOCAL_DRM_MODE_FB_MODIFIERS , - &data->fb.fb_id); + format, tiling, strides, offsets, + LOCAL_DRM_MODE_FB_MODIFIERS, &data-Quoted 1 line
fb.fb_id);
tests/kms_available_modes_crc.c +0
-0if (ret <0 ) { igt_info("Creating fb for format %s failed, returncode %d\n",
tests/kms_draw_crc.c +3
-3@@ -156,14 +156,14 @@ static void get_method_crc(enum igt_draw_method method, uint32_t drm_format, static bool format_is_supported(uint32_t format, uint64_t modifier) {uint32_t gem_handle, fb_id; -unsigned int stride; +unsigned int strides[4 ] = {};int ret; gem_handle =igt_create_bo_with_dimensions (drm_fd,64 ,64 , format, modifier, -0 ,NULL , &stride,NULL ); +0 ,NULL , &strides[0], NULL); ret = __kms_addfb(drm_fd, gem_handle, 64, 64, - stride, format, modifier, NULL, + format, modifier, strides, NULL,tests/kms_draw_crc.c +0
-0LOCAL_DRM_MODE_FB_MODIFIERS, &fb_id);drmModeRmFB (drm_fd, fb_id);gem_close (drm_fd, gem_handle);tests/prime_vgem.c +1
-0@@ -709,6 +709,7 @@ static void test_flip(int i915, int vgem, unsigned hang)signal (SIGHUP ,sighandler );for (int i =0 ; i <2 ; i++) { +uint32_t strides[4 ] = {};int fd;tests/prime_vgem.c +4
-2bo[i].width =1024 ;@@ -721,9 +722,12 @@ static void test_flip(int i915, int vgem, unsigned hang)igt_assert (handle [i]);close (fd); + strides[0 ] = bo[i].pitch; + do_or_die(__kms_addfb(i915, handle[i], - bo[i].width, bo[i].height, bo[i].pitch, - DRM_FORMAT_XRGB8888, I915_TILING_NONE, NULL, + bo[i].width, bo[i].height, + DRM_FORMAT_XRGB8888,
I915_TILING_NONE,tests/prime_vgem.c +1
-0+ strides,NULL , LOCAL_DRM_MODE_FB_MODIFIERS,&fb_id[i]));
tests/prime_vgem.c static void test_flip(int i915, int vgem, unsigned hang) · line 733
Quoted 2 lines
tests/prime_vgem.c +0
-0igt_assert (fb_id[i]); }
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 16/25] lib/kms: Pass the number of planes explicitly to __kms_addfb()
In reply to Ville SyrjalaEm Qui, 2018-07-19 às 18:04 +0300, Ville Syrjala escreveu:
Quoted 8 lines
From: Ville Syrjälä <[email protected]>
Currently
__kms_addfb()assumes that only the first plane can be at offset 0. I don't particularly like such assumptions so let's just pass in the number of planes explicitly.We'll also require offsets[] to be passed in always. Nothing really to gain by making it optional.
Quoted 153 lines
Signed-off-by Ville Syrjälä <[email protected]>--- lib/igt_fb.c | 1 + lib/ioctl_wrappers.c | 9 +++------ lib/ioctl_wrappers.h | 2 +- tests/kms_available_modes_crc.c | 5 ++++- tests/kms_draw_crc.c | 3 ++- tests/prime_vgem.c | 3 ++- 6 files changed, 13 insertions(+), 10 deletions(-)lib/igt_fb.c +1
-0@@ -884,6 +884,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height, do_or_die(__kms_addfb(fd, fb->gem_handle, width, height, format, tiling, pitches, fb- >offsets, + fb_num_planes(f),
LOCAL_DRM_MODE_FB_MODIFIERS,&fb_id));lib/igt_fb.c +0
-0}else {uint32_t handles[4 ];lib/ioctl_wrappers.c +3
-6@@ -1674,7 +1674,7 @@ int __kms_addfb(int fd, uint32_t handle, uint32_t width, uint32_t height, uint32_t pixel_format, uint64_t modifier, uint32_t strides[4], uint32_t offsets[4], - uint32_t flags, uint32_t *buf_id) + int num_planes, uint32_t flags, uint32_t *buf_id) { struct drm_mode_fb_cmd2 f;int ret, i;@@ -1687,14 +1687,11 @@ int __kms_addfb(int fd, uint32_t handle, f.height = height; f.pixel_format = pixel_format; f.flags = flags; - f.handles[0 ] = handle; - f.pitches[0 ] = strides[0 ]; - f.modifier[0 ] = modifier; -for (i =1 ; i <4 && offsets && offsets[i]; i++) { +for (i =0 ; i < num_planes; i++) { f.handles[i] = handle; - f.pitches[i] = strides[i]; f.modifier[i] = modifier; + f.pitches[i] = strides[i]; f.offsets[i] = offsets[i]; }lib/ioctl_wrappers.h +1
-1@@ -239,7 +239,7 @@ int __kms_addfb(int fd, uint32_t handle, uint32_t width, uint32_t height, uint32_t pixel_format, uint64_t modifier, uint32_t strides[4], uint32_t offsets[4], - uint32_t flags, uint32_t *buf_id); + int num_planes, uint32_t flags, uint32_t *buf_id);/** * to_user_pointer: tests/kms_available_modes_crc.c +1
-0@@ -258,6 +258,7 @@ static bool setup_fb(data_t *data, igt_output_t *output, igt_plane_t *plane, unsigned tile_width, tile_height;uint32_t strides[4 ] = {};uint32_t offsets[4 ] = {}; +int num_planes =1 ;uint64_t tiling;int bpp =0 ;tests/kms_available_modes_crc.c +1
-0int i;@@ -303,6 +304,7 @@ static bool setup_fb(data_t *data, igt_output_t *output, igt_plane_t *plane, if (fillers[i].bpp == P010 || fillers[i].bpp == NV12) { offsets[1 ] = data->size; gemsize = data->size *2 ; + num_planes =2 ; }tests/kms_available_modes_crc.c +2
-1data->gem_handle =gem_create (data->gfx_fd, gemsize);@@ -313,7 +315,8 @@ static bool setup_fb(data_t *data, igt_output_t *output, igt_plane_t *plane, ret =__kms_addfb (data->gfx_fd, data->gem_handle, w, h, format, tiling, strides, offsets, -LOCAL_DRM_MODE_FB_MODIFIERS , &data- >fb.fb_id); + num_planes,LOCAL_DRM_MODE_FB_MODIFIERS , + &data->fb.fb_id);tests/kms_available_modes_crc.c +0
-0if (ret <0 ) { igt_info("Creating fb for format %s failed, returncode %d\n",
tests/kms_draw_crc.c +2
-1@@ -156,6 +156,7 @@ static void get_method_crc(enum igt_draw_method method, uint32_t drm_format, static bool format_is_supported(uint32_t format, uint64_t modifier) {uint32_t gem_handle, fb_id; +unsigned int offsets[4 ] = {};unsigned int strides[4 ] = {};int ret;@@ -163,7 +164,7 @@ static bool format_is_supported(uint32_t format, uint64_t modifier) format, modifier, 0, NULL, &strides[0], NULL); ret =__kms_addfb (drm_fd, gem_handle,64 ,64 , - format, modifier, strides,NULL , + format, modifier, strides, offsets,1 ,LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id);tests/kms_draw_crc.c +0
-0drmModeRmFB (drm_fd, fb_id);gem_close (drm_fd, gem_handle);tests/prime_vgem.c +1
-0@@ -710,6 +710,7 @@ static void test_flip(int i915, int vgem, unsigned hang)for (int i =0 ; i <2 ; i++) {uint32_t strides[4 ] = {}; +uint32_t offsets[4 ] = {};int fd;tests/prime_vgem.c +1
-1bo[i].width =1024 ;@@ -727,7 +728,7 @@ static void test_flip(int i915, int vgem, unsigned hang) do_or_die(__kms_addfb(i915, handle[i], bo[i].width, bo[i].height, DRM_FORMAT_XRGB8888, I915_TILING_NONE, - strides, NULL, + strides, offsets, 1, LOCAL_DRM_MODE_FB_MODIFIERS,&fb_id[i]));
tests/prime_vgem.c static void test_flip(int i915, int vgem, unsigned hang) · line 734
Quoted 2 lines
tests/prime_vgem.c +0
-0igt_assert (fb_id[i]); }
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 17/25] lib/igt_fb: Remove the hand rolled addfb2
In reply to Ville SyrjalaEm Qui, 2018-07-19 às 18:04 +0300, Ville Syrjala escreveu:
Quoted 5 lines
From: Ville Syrjälä <[email protected]>
Just use
__kms_addfb()always instead of hand rolling anotherdrmModeAddFB2()usage.__kms_addfb()demands support for modifiers but we've had that for a long time now so it's not a problem.
Dear IGT mainainers, do we have any specific rules/requirements about running new IGT in older Kernels? A minimum/maximum age?
Quoted 53 lines
Signed-off-by Ville Syrjälä <[email protected]>--- lib/igt_fb.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-)lib/igt_fb.c +1
-0@@ -856,6 +856,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height, enum igt_color_encoding color_encoding =IGT_COLOR_YCBCR_BT709 ;enum igt_color_range color_range =IGT_COLOR_YCBCR_LIMITED_RANGE ;struct format_desc_struct *f =lookup_drm_format (format); +uint32_t pitches[4 ];lib/igt_fb.c +2
-21uint32_t fb_id;int i;@@ -875,35 +876,13 @@ igt_create_fb_with_bo_size(int fd, int width, int height, igt_debug("%s(handle=%d, pitch=%d)\n", __func__, fb->gem_handle, fb->stride); -if (tiling !=LOCAL_DRM_FORMAT_MOD_NONE && - tiling !=LOCAL_I915_FORMAT_MOD_X_TILED ) { -uint32_t pitches[4 ]; - -for (i =0 ; i <fb_num_planes (f); i++) - pitches[i] = fb->stride; - -do_or_die (__kms_addfb (fd, fb->gem_handle, width, height, - format, tiling, pitches, fb- >offsets, -fb_num_planes (f), -LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id)); - }else { -uint32_t handles[4 ]; -uint32_t pitches[4 ]; +for (i =0 ; i <fb_num_planes (f); i++) + pitches[i] = fb->stride; -memset (handles,0 ,sizeof (handles)); -memset (pitches,0 ,sizeof (pitches)); - - handles[0 ] = fb->gem_handle; - pitches[0 ] = fb->stride; -for (i =0 ; i <fb_num_planes (f); i++) { - handles[i] = fb->gem_handle;
lib/igt_fb.c igt_create_fb_with_bo_size(int fd, int width, · line 883
Quoted 10 lines
lib/igt_fb.c +2
-7- pitches[i] = fb->stride; - } - -do_or_die (drmModeAddFB2 (fd, width, height, format, - handles, pitches, fb- >offsets, - &fb_id,0 )); - } + do_or_die(__kms_addfb(fd, fb->gem_handle, width, height, + format, tiling, pitches, fb->offsets,
So the real difference is that we now pass "tiling" as a modifier as opposed to nothing, for the X and linear formats. A quick look at intel_framebuffer_init() suggests that this is fine (and required).
As long as maintainers don't block it:
But now __kms_addfb() is almost a reimplementation of of drmModeAddFB2WithModifiers(), maybe we could use it instead.
lib/igt_fb.c igt_create_fb_with_bo_size(int fd, int width, int height, · line 888
Quoted 5 lines
lib/igt_fb.c +2
-0+fb_num_planes (f), + LOCAL_DRM_MODE_FB_MODIFIERS, &fb_id)); fb->width = width; fb->height = height;
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 18/25] lib/igt_fb: Constify format_desc_struct
In reply to Ville SyrjalaEm Qui, 2018-07-19 às 18:04 +0300, Ville Syrjala escreveu:
Quoted 5 lines
From: Ville Syrjälä <[email protected]>
We don't want anyone to modify the format description structures. Make
them const.
Quoted 203 lines
Signed-off-by Ville Syrjälä <[email protected]>--- lib/igt_fb.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-)lib/igt_fb.c +3
-3@@ -60,7 +60,7 @@*/ /* drm fourcc/cairo format maps */ -static struct format_desc_struct { +static const struct format_desc_struct { const char *name; uint32_t drm_id; cairo_format_t cairo_id;@@ -108,9 +108,9 @@ static struct format_desc_struct {#define for_each_format (f) \ for (f = format_desc; f - format_desc < ARRAY_SIZE(format_desc); f++) -static struct format_desc_struct *lookup_drm_format (uint32_t drm_format) +static const struct format_desc_struct *lookup_drm_format(uint32_t drm_format) { -struct format_desc_struct *format; +const struct format_desc_struct *format;lib/igt_fb.c +2
-2for_each_format (format) {if (format->drm_id != drm_format)@@ -190,8 +190,8 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, } } -static unsigned fb_plane_width (struct format_desc_struct *format, - unsigned width, int plane) +static unsigned fb_plane_width (const struct format_desc_struct *format, +int plane,unsigned width) {lib/igt_fb.c +4
-5if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 )return DIV_ROUND_UP (width,2 );@@ -199,21 +199,21 @@ static unsigned fb_plane_width(structformat_desc_struct *format, return width; } -static unsigned fb_plane_bpp (struct format_desc_struct *format,int plane) +static unsigned fb_plane_bpp(const struct format_desc_struct *format,int plane) {return format->plane_bpp[plane]; } -static unsigned fb_plane_min_stride (struct format_desc_struct *format, - unsigned width, int plane) +static unsigned fb_plane_min_stride(const struct format_desc_struct *format, +int plane,unsigned width) {unsigned cpp =fb_plane_bpp (format, plane) /8 ;return fb_plane_width (format, width, plane) * cpp; } -static unsigned fb_plane_height (struct format_desc_struct *format, -unsigned height,int plane) +static unsigned fb_plane_height(const struct format_desc_struct*format,
lib/igt_fb.c +3
-2+ int plane, unsigned height) {if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 )return DIV_ROUND_UP (height,2 );@@ -221,13 +221,13 @@ static unsigned fb_plane_height(structformat_desc_struct *format, return height; } -static int fb_num_planes (struct format_desc_struct *format) +static int fb_num_planes (const struct format_desc_struct *format) {return format->num_planes; }static unsigned calc_plane_stride (int fd, -struct format_desc_struct *format, +const struct format_desc_struct *format, int width, uint64_t tiling, intplane)
{
uint32_tmin_stride= fb_plane_min_stride(format, width,
plane);lib/igt_fb.c +1
-1@@ -259,7 +259,7 @@ static unsigned calc_plane_stride(int fd, }static unsigned calc_plane_size (int fd,int width,int height, -struct format_desc_struct *format, +const struct format_desc_struct *format,uint64_t tiling,int plane,uint32_t stride){
lib/igt_fb.c +1
-1@@ -290,7 +290,7 @@ static unsigned calc_plane_size(int fd, int width, int height, } static unsigned calc_fb_size(int fd, int width, int height, - struct format_desc_struct *format, + const struct format_desc_struct *format, uint64_t tiling,
uint32_tstrides[4],uint32_t
offsets[4])
{lib/igt_fb.c +1
-1@@ -335,7 +335,7 @@ static unsigned calc_fb_size(int fd, int width,int height, void igt_calc_fb_size(int fd, int width, int height, uint32_t drm_format, uint64_t tiling, unsigned *size_ret, unsigned *stride_ret) { - struct format_desc_struct *format =lookup_drm_format (drm_format ); + const struct format_desc_struct *format =
lookup_drm_format(drm_format);lib/igt_fb.c +1
-1uint32_t strides[4 ] = {};igt_assert (format);@@ -400,7 +400,7 @@ uint64_t igt_fb_tiling_to_mod(uint64_t tiling)static int create_bo_for_fb (int fd,int width,int height,enum igt_color_encoding color_encoding,enum igt_color_range color_range, -struct format_desc_struct *format, +const struct format_desc_struct *format,uint64_t tiling,unsigned size,unsigned stride, unsigned *size_ret, unsigned
*stride_ret,lib/igt_fb.c +1
-1uint32_t offsets[4], bool *is_dumb)@@ -855,7 +855,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height,/* FIXME allow the caller to pass these in */ enum igt_color_encoding color_encoding =IGT_COLOR_YCBCR_BT709 ;enum igt_color_range color_range =IGT_COLOR_YCBCR_LIMITED_RANGE ; -struct format_desc_struct *f =lookup_drm_format (format); + const struct format_desc_struct *f =
lookup_drm_format(format);lib/igt_fb.c +1
-1uint32_t pitches[4 ];uint32_t fb_id;int i;@@ -1195,7 +1195,7 @@ unsigned int igt_create_stereo_fb(int drm_fd,drmModeModeInfo *mode, static cairo_format_t drm_format_to_cairo(uint32_t drm_format) { - struct format_desc_struct *f; + const struct format_desc_struct *f;for_each_format (f)lib/igt_fb.c +2
-2if (f->drm_id == drm_format)@@ -1953,7 +1953,7 @@ void igt_remove_fb(int fd, struct igt_fb *fb)*/ uint32_t igt_bpp_depth_to_drm_format (int bpp,int depth) { -struct format_desc_struct *f; +const struct format_desc_struct *f;for_each_format (f)if (f->plane_bpp[0 ] == bpp && f->depth == depth)@@ -1974,7 +1974,7 @@ uint32_t igt_bpp_depth_to_drm_format(int bpp,int depth) */ uint32_t igt_drm_format_to_bpp (uint32_t drm_format) { -struct format_desc_struct *f =lookup_drm_format (drm_format); +const struct format_desc_struct *f =lookup_drm_format (drm_format);lib/igt_fb.c +1
-1igt_assert_f (f,"can't find a bpp format for %08x (%s)\n" , drm_format,igt_format_str (drm_format));@@ -1992,7 +1992,7 @@ uint32_t igt_drm_format_to_bpp(uint32_tdrm_format) */ const char *igt_format_str (uint32_t drm_format) { -struct format_desc_struct *f =lookup_drm_format (drm_format); +const struct format_desc_struct *f =lookup_drm_format (drm_format);lib/igt_fb.c +0
-0return f ? f->name :"invalid" ; }
lib/igt_fb.c const char *igt_format_str(uint32_t drm_format) · line 2012
Quoted 8 lines
lib/igt_fb.c +1
-1@@ -2006,7 +2006,7 @@ const char *igt_format_str(uint32_t drm_format)*/ bool igt_fb_supported_format (uint32_t drm_format) { -struct format_desc_struct *f; +const struct format_desc_struct *f;for_each_format (f)if (f->drm_id == drm_format)
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 20/25] lib/igt_fb: Refactor blitter usage
In reply to Ville SyrjalaEm Qui, 2018-07-19 às 18:04 +0300, Ville Syrjala escreveu:
Quoted 3 lines
From: Ville Syrjälä <[email protected]>
Deduplicate the blitter code.
Quoted 107 lines
Signed-off-by Ville Syrjälä <[email protected]>--- lib/igt_fb.c | 62 ++++++++++++++++++++++++++++-------------------- ------------ 1 file changed, 29 insertions(+), 33 deletions(-)lib/igt_fb.c +27
-10@@ -1206,32 +1206,44 @@ struct fb_blit_upload {struct fb_blit_linear linear; }; +static void blitcopy (const struct igt_fb *dst_fb, +const struct igt_fb *src_fb) +{ +igt_assert_eq (dst_fb->fd, src_fb->fd); +igt_assert_eq (dst_fb->num_planes, src_fb->num_planes); + +for (int i =0 ; i < dst_fb->num_planes; i++) { +igt_assert_eq (dst_fb->plane_bpp[i], src_fb- >plane_bpp[i]); +igt_assert_eq (dst_fb->plane_width[i], src_fb- >plane_width[i]); +igt_assert_eq (dst_fb->plane_height[i], src_fb- >plane_height[i]); + +igt_blitter_fast_copy__raw (dst_fb->fd, + src_fb->gem_handle, + src_fb->offsets[i], + src_fb->strides[i], +igt_fb_mod_to_tiling (src_ fb->tiling), +0 ,0 ,/* src_x, src_y */ + dst_fb->plane_width[i], dst_fb->plane_height[i], + dst_fb->plane_bpp[i], + dst_fb->gem_handle, + dst_fb->offsets[i], + dst_fb->strides[i], +igt_fb_mod_to_tiling (dst_ fb->tiling), +0 ,0 /* dst_x, dst_y */ ); + } +} +static void free_linear_mapping (struct fb_blit_upload *blit) {int fd = blit->fd;struct igt_fb *fb = blit->fb;struct fb_blit_linear *linear = &blit->linear; -unsigned int obj_tiling =igt_fb_mod_to_tiling (fb->tiling); -int i;gem_munmap (linear->map, linear->fb.size);gem_set_domain (fd, linear->fb.gem_handle,I915_GEM_DOMAIN_GTT ,0 ); -for (i =0 ; i < fb->num_planes; i++) - igt_blitter_fast_copy__raw(fd, - linear->fb.gem_handle, - linear->fb.offsets[i], - linear->fb.strides[i], - I915_TILING_NONE, - 0, 0, /* src_x, src_y */ - fb->plane_width[i], fb-Quoted 1 line
plane_height[i],
lib/igt_fb.c +1
-9- fb->plane_bpp[i], - fb->gem_handle, - fb->offsets[i], - fb->strides[i], - obj_tiling, - 0, 0 /* dst_x, dst_y */); +blitcopy (fb, &linear->fb);gem_sync (fd, linear->fb.gem_handle);gem_close (fd, linear->fb.gem_handle);@@ -1250,9 +1262,6 @@ static void destroy_cairo_surface__blit(void *arg)static void setup_linear_mapping (int fd,struct igt_fb *fb,struct fb_blit_linear *linear) { -unsigned int obj_tiling =igt_fb_mod_to_tiling (fb->tiling); -int i; -/* * We create a linear BO that we'll map for the CPU to write
to (usinglib/igt_fb.c +0
-0* cairo). This linear bo will be then blitted to its final @@ -1271,20 +1280,7 @@ static void setup_linear_mapping(int fd,struct
igt_fb*fb, structfb_blit_linealib/igt_fb.c +0
-8gem_set_domain (fd, linear->fb.gem_handle,I915_GEM_DOMAIN_GTT ,0 ); -for (i =0 ; i < fb->num_planes; i++) - igt_blitter_fast_copy__raw(fd, - fb->gem_handle, - fb->offsets[i], - fb->strides[i], - obj_tiling, - 0, 0, /* src_x, src_y */ - fb->plane_width[i], fb-Quoted 1 line
plane_height[i],
lib/igt_fb.c static void setup_linear_mapping(int fd, struct igt_fb *fb, struct fb_blit_linea · line 1285
Quoted 9 lines
lib/igt_fb.c +1
-6- fb->plane_bpp[i], - linear->fb.gem_handle, - linear->fb.offsets[i], - linear->fb.strides[i], -I915_TILING_NONE , - 0, 0 /* dst_x, dst_y */); +blitcopy (&linear->fb, fb);gem_sync (fd, linear->fb.gem_handle);
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 17/25] lib/igt_fb: Remove the hand rolled addfb2
In reply to Paulo ZanoniQuoted 9 lines · Paulo Zanoni
Em Qui, 2018-07-19 às 18:04 +0300, Ville Syrjala escreveu:
Quoted 5 lines
From: Ville Syrjälä <[email protected]>
Just use
__kms_addfb()always instead of hand rolling anotherdrmModeAddFB2()usage.__kms_addfb()demands support for modifiers but we've had that for a long time now so it's not a problem.Dear IGT mainainers, do we have any specific rules/requirements about running new IGT in older Kernels? A minimum/maximum age?
Nothing specific written down. The thumb rule is that tests must behave well on all kernels, and particularly well on at least linus/master and a couple of LTS kernels.
What behave means is the gist of the question. If the poked interface is not available, the test must skip, and otherwise it should produce a pass/fail based on the observed effects; when the interface is used like actual userspace would use it.
If I'm reading this right, this patch will change test results from pass to skip on really really old kernels (how long is "a long time" here?). In this particular case, Arek is telling me it's somewhere around 3.19 so hey.
In the general case, considering the main use of IGT tests is regression testing in CI, stable should already be in a working condition (YMMV) so close to zero coverage is lost by requiring modern stuff. As long as the change is towards skip, not towards failing.
tl;dr: Case-by-case basis, keep stuff working if you can, require more if you must for making improvements in tests.
Signature · 1 line
Petri Latvala
Quoted 72 lines
Quoted 54 lines
Signed-off-by Ville Syrjälä <[email protected]>--- lib/igt_fb.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-)lib/igt_fb.c +1
-0@@ -856,6 +856,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height, enum igt_color_encoding color_encoding =IGT_COLOR_YCBCR_BT709 ;enum igt_color_range color_range =IGT_COLOR_YCBCR_LIMITED_RANGE ;struct format_desc_struct *f =lookup_drm_format (format); +uint32_t pitches[4 ];lib/igt_fb.c +2
-21uint32_t fb_id;int i;@@ -875,35 +876,13 @@ igt_create_fb_with_bo_size(int fd, int width, int height, igt_debug("%s(handle=%d, pitch=%d)\n", __func__, fb->gem_handle, fb->stride); -if (tiling !=LOCAL_DRM_FORMAT_MOD_NONE && - tiling !=LOCAL_I915_FORMAT_MOD_X_TILED ) { -uint32_t pitches[4 ]; - -for (i =0 ; i <fb_num_planes (f); i++) - pitches[i] = fb->stride; - -do_or_die (__kms_addfb (fd, fb->gem_handle, width, height, - format, tiling, pitches, fb- >offsets, -fb_num_planes (f), -LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id)); - }else { -uint32_t handles[4 ]; -uint32_t pitches[4 ]; +for (i =0 ; i <fb_num_planes (f); i++) + pitches[i] = fb->stride; -memset (handles,0 ,sizeof (handles)); -memset (pitches,0 ,sizeof (pitches)); - - handles[0 ] = fb->gem_handle; - pitches[0 ] = fb->stride; -for (i =0 ; i <fb_num_planes (f); i++) { - handles[i] = fb->gem_handle;lib/igt_fb.c igt_create_fb_with_bo_size(int fd, int width, · line 883
Quoted 10 lines
lib/igt_fb.c +2
-7- pitches[i] = fb->stride; - } - -do_or_die (drmModeAddFB2 (fd, width, height, format, - handles, pitches, fb- >offsets, - &fb_id,0 )); - } + do_or_die(__kms_addfb(fd, fb->gem_handle, width, height, + format, tiling, pitches, fb->offsets,So the real difference is that we now pass "tiling" as a modifier as opposed to nothing, for the X and linear formats. A quick look at
intel_framebuffer_init()suggests that this is fine (and required).As long as maintainers don't block it:
Reviewed-by Paulo Zanoni <[email protected]>
Quoted 8 lines
But now
__kms_addfb()is almost a reimplementation of ofdrmModeAddFB2WithModifiers(), maybe we could use it instead.lib/igt_fb.c igt_create_fb_with_bo_size(int fd, int width, int height, · line 888
Quoted 5 lines
lib/igt_fb.c +2
-0+fb_num_planes (f), + LOCAL_DRM_MODE_FB_MODIFIERS, &fb_id)); fb->width = width; fb->height = height;
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Kazlauskas, Nicholas
Reviewed-byQuoted 64 lines · Paulo Zanoni
Em Sex, 2018-09-21 às 16:26 +0300, Ville Syrjälä escreveu:
Quoted 24 lines · Paulo Zanoni
Quoted 9 lines
Em Qui, 2018-07-19 às 18:03 +0300, Ville Syrjala escreveu:
Quoted 7 lines
From: Ville Syrjälä <[email protected]>
For drivers that don't support the
IN_FORMATSblob we should just consult the format list returned by getplane. Since we can't know which modifiers are supported we'll assume linear-only. Obviously that may not work for every driver out there, but not much more we can do unless we start to actually probing with addfb.Quoted 3 lines
Can you please elaborate on why we need that change? What exactly do we
gain from it?We gain the ability to write tests without worrying about
IN_FORMATSeverywhere.Quoted 6 lines
IMHO there's always the worry that this could be misused in the future, restricting tests to linear only when other formats are
indeed possible. Having NULL buffers crashing the test is a good way to
prevent misuse.Quoted 2 lines
I don't know what kind of misuse you're thinking of. Actually not sure what misuse in this context would mean really.
Thinking that everything is linear only when in fact other formats are actually supported.
Quoted 6 lines
Quoted 6 lines
What if we populate
plane->formatslike we do here but leave plane-Quoted 2 lines
modifiers NULL? It would allow other pieces of the code to rely on the
Quoted 6 lines
Quoted 3 lines
format list while not exposing the risk of the "linear only" incorrect
restriction.So every test would have to check for !modifiers and come up with some kind of fallback mechanism?
Yes, if
IN_FORMATSis not present you have to fallback to the old "try it until you don't get an EINVAL". Isn't this the old protocol?Quoted 2 lines
What would such a fallback mechanism
even be other than "let's assume linear"?The same mechanism we used before we created
IN_FORMATS.Quoted 3 lines
I see no reason to inflict
that pain on every test that just wants to know "is this format supported?".The way I see, not populating a wrong table helps the test more than setting a table with data that may not reflect reality.
Quoted 1 line
Quoted 16 lines
Quoted 4 lines
Also any driver that advertizes formats that don't support linear and doesn't expose
IN_FORMATSclearly doesn't care about supporting driver/hw agnostic userspace, so having some tests fail for them seems perfectly reasonable to me.So older i915 didn't care about supporting driver/hw agnostic user space?
Quoted 8 lines
Quoted 8 lines
That said, the patch is correct in the sense that it does what it proposes to do.
Quoted 3 lines
Cc Ulrich Hecht <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>
This patch allows for the igt_plane_has_format_mod and igt_display_has_format_mod helpers to be used on drivers that don't support IN_FORMATS (amdgpu being an example).
The helpers are really useful for fixing up IGT tests that run and fail on hardware that isn't i915 but use i915 tiling modifiers. This allows helps remove a lot of the genid checks to see if y/yf tiling is supported.
Without this patch the supported modifier list for these helpers is empty so everything ends up skipping.
I've tested this patch with amdgpu along with the helpers and it works well.
Quoted 48 lines
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
--- lib/igt_kms.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)lib/igt_kms.c +0
-0@@ -4068,8 +4068,28 @@ static voidigt_fill_plane_format_mod(igt_display_t *display,
igt_plane_t*plane
int idx = 0;
int count;lib/igt_kms.c +7
-1-if (!igt_plane_has_prop (plane,IGT_PLANE_IN_FORMATS )) +if (!igt_plane_has_prop (plane,IGT_PLANE_IN_FORMATS )) { +drmModePlanePtr p = plane->drm_plane; + + count = p->count_formats; + + plane->format_mod_count = count; + plane->formats = calloc(count, sizeof(plane-Quoted 1 line
formats[0]));
lib/igt_kms.c +2
-0+igt_assert (plane->formats); + plane->modifiers = calloc(count, sizeof(plane-Quoted 1 line
modifiers[0]));
lib/igt_kms.c +9
-0+igt_assert (plane->modifiers); + +/* +* We don't know which modifiers are +* supported, so we'll assume linear only. +*/ +for (int i =0 ; i < count; i++) { + plane->formats[i] = p->formats[i]; + plane->modifiers[i] =
DRM_FORMAT_MOD_LINEAR;lib/igt_kms.c +3
-0+ } +return ; + }Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
blob_id= igt_plane_get_prop(plane,IGT_PLANE_IN_FORMATS);
Quoted 5 lines
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Quoted 90 lines · Nicholas
Quoted 64 lines · Paulo Zanoni
Em Sex, 2018-09-21 às 16:26 +0300, Ville Syrjälä escreveu:
Quoted 24 lines · Paulo Zanoni
Quoted 9 lines
Em Qui, 2018-07-19 às 18:03 +0300, Ville Syrjala escreveu:
Quoted 7 lines
From: Ville Syrjälä <[email protected]>
For drivers that don't support the
IN_FORMATSblob we should just consult the format list returned by getplane. Since we can't know which modifiers are supported we'll assume linear-only. Obviously that may not work for every driver out there, but not much more we can do unless we start to actually probing with addfb.Quoted 3 lines
Can you please elaborate on why we need that change? What exactly do we
gain from it?We gain the ability to write tests without worrying about
IN_FORMATSeverywhere.Quoted 6 lines
IMHO there's always the worry that this could be misused in the future, restricting tests to linear only when other formats are
indeed possible. Having NULL buffers crashing the test is a good way to
prevent misuse.Quoted 2 lines
I don't know what kind of misuse you're thinking of. Actually not sure what misuse in this context would mean really.
Thinking that everything is linear only when in fact other formats are actually supported.
Quoted 6 lines
Quoted 6 lines
What if we populate
plane->formatslike we do here but leave plane-Quoted 2 lines
modifiers NULL? It would allow other pieces of the code to rely on the
Quoted 6 lines
Quoted 3 lines
format list while not exposing the risk of the "linear only" incorrect
restriction.So every test would have to check for !modifiers and come up with some kind of fallback mechanism?
Yes, if
IN_FORMATSis not present you have to fallback to the old "try it until you don't get an EINVAL". Isn't this the old protocol?Quoted 2 lines
What would such a fallback mechanism
even be other than "let's assume linear"?The same mechanism we used before we created
IN_FORMATS.Quoted 3 lines
I see no reason to inflict
that pain on every test that just wants to know "is this format supported?".The way I see, not populating a wrong table helps the test more than setting a table with data that may not reflect reality.
Quoted 1 line
Quoted 16 lines
Quoted 4 lines
Also any driver that advertizes formats that don't support linear and doesn't expose
IN_FORMATSclearly doesn't care about supporting driver/hw agnostic userspace, so having some tests fail for them seems perfectly reasonable to me.So older i915 didn't care about supporting driver/hw agnostic user space?
Quoted 8 lines
Quoted 8 lines
That said, the patch is correct in the sense that it does what it proposes to do.
Quoted 3 lines
Cc Ulrich Hecht <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>This patch allows for the
igt_plane_has_format_modandigt_display_has_format_modhelpers to be used on drivers that don't supportIN_FORMATS(amdgpu being an example).The helpers are really useful for fixing up IGT tests that run and fail on hardware that isn't i915 but use i915 tiling modifiers. This allows helps remove a lot of the genid checks to see if y/yf tiling is supported.
Quoted 6 lines
Without this patch the supported modifier list for these helpers is empty so everything ends up skipping.
I've tested this patch with amdgpu along with the helpers and it works well.
Reviewed-by Nicholas Kazlauskas <[email protected]>
Thanks. Pushed.
Quoted 55 lines
Quoted 54 lines
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
--- lib/igt_kms.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)lib/igt_kms.c +0
-0@@ -4068,8 +4068,28 @@ static voidigt_fill_plane_format_mod(igt_display_t *display,
igt_plane_t*plane
int idx = 0;
int count;lib/igt_kms.c +7
-1-if (!igt_plane_has_prop (plane,IGT_PLANE_IN_FORMATS )) +if (!igt_plane_has_prop (plane,IGT_PLANE_IN_FORMATS )) { +drmModePlanePtr p = plane->drm_plane; + + count = p->count_formats; + + plane->format_mod_count = count; + plane->formats = calloc(count, sizeof(plane-Quoted 1 line
formats[0]));
lib/igt_kms.c +2
-0+igt_assert (plane->formats); + plane->modifiers = calloc(count, sizeof(plane-Quoted 1 line
modifiers[0]));
lib/igt_kms.c +9
-0+igt_assert (plane->modifiers); + +/* +* We don't know which modifiers are +* supported, so we'll assume linear only. +*/ +for (int i =0 ; i < count; i++) { + plane->formats[i] = p->formats[i]; + plane->modifiers[i] =
DRM_FORMAT_MOD_LINEAR;lib/igt_kms.c +3
-0+ } +return ; + }Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
blob_id= igt_plane_get_prop(plane,IGT_PLANE_IN_FORMATS);_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev