tests/kms_plane_multiple: CRC based atomic correctness test
PATCH v4 1/1 tests/kms_plane_multiple: CRC based atomic correctness test
This is a testcase with multiple planes. The idea here is the following
- draw a uniform frame with blue color
- grab crc for reference
- put planes randomly on top with the same blue color
- punch holes with black color into the primary framebuffer
- ideally the planes should cover these holes so that the output is the identical to reference crc
- composite all with one ioctl call
- grab crc and verify that the reference crc is equal
- repeat this for dozen iterations to maximize coverage
v4: For atomic test enable crc capturing before entering into a
iteration loop. After each iteration, check that page flip didn't take no more than 1 vblank, fetch all crc's and check the values.
Introduce new command line parameter for the number of iterations. The test run from 1 to 256 iterations.
v3: Cleanup by removing separate plane array
For atomic, pass DRM_MODE_PAGE_FLIP_EVENT
Grab crc by using igt_pipe_crc_get_crc instead of igt_pipe_crc_collect_crc Rename nplanes variable to max_planes
To optimize test execution, run iterations after the modeset
v2: Keep a logfile on random number seeds per subtest that are not skipped
due to unmet test requirements
--- tests/Makefile.sources | 1 + tests/kms_plane_multiple.c | 475 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 476 insertions(+) create mode 100644 tests/kms_plane_multiple.c
tests/Makefile.sources +1 -0
@@ -105,6 +105,7 @@ TESTS_progs_M = \ kms_pipe_color \ kms_pipe_crc_basic \ kms_plane \ + kms_plane_multiple \ kms_properties \ kms_psr_sink_crc \ kms_render \
tests/kms_plane_multiple.c new file +475 -0
475 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 12 lines · Mika Kahola
This is a testcase with multiple planes. The idea here is the following
- draw a uniform frame with blue color
- grab crc for reference
- put planes randomly on top with the same blue color
- punch holes with black color into the primary framebuffer
- ideally the planes should cover these holes so that the output is the identical to reference crc
- composite all with one ioctl call
- grab crc and verify that the reference crc is equal
- repeat this for dozen iterations to maximize coverage
Quoted 7 lines
v4: For atomic test enable crc capturing before entering into a
iteration loop. After each iteration, check that page flip didn't take no more than 1 vblank, fetch all crc's and check the values.Introduce new command line parameter for the number of iterations. The test run from 1 to 256 iterations.
This seems real low. Screens run at usuall 50-60Hz, which means you just allow for a few seconds. I'd say for a normal validation run timing it to be 1 second (for each subtest) is a reasonable start.
But for the knob we probably want to make this virtually unlimited, e.g. -1 == never stop. This would be useful for chasing hard-to-reproduct underruns and errors: Run testcase with unlimited iterations, it will die as soon as the first error shows up. Then try with next hack/debug trick until the test survives for hours and it all looks good ;-)
For the testcode itself I think it'd be good if at least Ville and Maarten review it, since this will be the groundwork for adding all kinds of atomic tests (rotation, yuv, scaling, anything else really). -Daniel
Quoted 513 lines
v3: Cleanup by removing separate plane array
For atomic, passDRM_MODE_PAGE_FLIP_EVENT
Grab crc by usingigt_pipe_crc_get_crcinstead ofigt_pipe_crc_collect_crcRename nplanes variable tomax_planes
To optimize test execution, run iterations after the modesetv2: Keep a logfile on random number seeds per subtest that are not skipped
due to unmet test requirementsSigned-off-by Mika Kahola <[email protected]>--- tests/Makefile.sources | 1 + tests/kms_plane_multiple.c | 475 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 476 insertions(+) create mode 100644 tests/kms_plane_multiple.ctests/Makefile.sources +1
-0@@ -105,6 +105,7 @@ TESTS_progs_M = \ kms_pipe_color \ kms_pipe_crc_basic \ kms_plane \ + kms_plane_multiple \ kms_properties \ kms_psr_sink_crc \ kms_render \tests/kms_plane_multiple.c new file +475
-0@@ -0,0 +1,475 @@ +/* +* Copyright © 2016 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +* +*/ + +#include "igt.h" +#include "drmtest.h" +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <string.h> +#include <time.h> + +IGT_TEST_DESCRIPTION ("Test atomic mode setting with multiple planes " ); + +#define MAX_CRCS 1 +#define SIZE 128 + +#define IN_RANGE (X ,MIN ,MAX ) ((X) < (MIN) || (X) > (MAX) ? 16 : X) + +typedef struct { +float red; +float green; +float blue; +}color_t ; + +typedef struct { +int drm_fd; +igt_display_t display; +igt_pipe_crc_t *pipe_crc; +igt_plane_t *plane[IGT_MAX_PLANES ]; +struct igt_fb fb[IGT_MAX_PLANES ]; +}data_t ; + +typedef struct { +data_t *data; +igt_crc_t reference_crc; +}test_position_t ; + +/* Command line parameters. */ +struct { +unsigned iterations; +bool user_seed; +int seed; +bool user_logfile; +char logfile[SIZE ]; +} opt = { + .iterations =16 , + .user_seed = false, + .seed =1 , + .user_logfile = false, + .logfile ="kms_plane_multiple.log" , +}; + +static inline uint32_t pipe_select (int pipe) +{ +if (pipe >1 ) +return pipe <<DRM_VBLANK_HIGH_CRTC_SHIFT ; +else if (pipe >0 ) +return DRM_VBLANK_SECONDARY ; +else +return 0 ; +} + +static unsigned get_vblank (int fd,int pipe,unsigned flags) +{ +union drm_wait_vblank vbl; + +memset (&vbl,0 ,sizeof (vbl)); + vbl.request.type =DRM_VBLANK_RELATIVE |pipe_select (pipe) | flags; +if (drmIoctl (fd,DRM_IOCTL_WAIT_VBLANK , &vbl)) +return 0 ; + +return vbl.reply.sequence; +} + +static int logwrite (const char *testname) +{ +time_t curr_time; +FILE *fid; +char *time_str; + + fid =fopen (opt.logfile,"a" ); + +if (fid ==NULL ) { +igt_debug ("Could not open file %s\n" , opt.logfile); +return -1 ; + } + + curr_time =time (NULL ); + + time_str =ctime (&curr_time); + time_str[strlen (time_str)-1 ] ='\0' ; + +fprintf (fid,"%s: kms_plane_multiple --run-subtest %s --seed %d\n" , + time_str, testname, opt.seed); + +fclose (fid); + +return 0 ; +} + +/* +* Common code across all tests, acting on data_t +*/ +static void test_init (data_t *data,enum pipe pipe) +{ + data->pipe_crc =igt_pipe_crc_new (pipe,INTEL_PIPE_CRC_SOURCE_AUTO ); +} + +static void test_fini (data_t *data,igt_output_t *output,int max_planes) +{ +igt_plane_set_fb (data->plane[IGT_PLANE_PRIMARY ],NULL ); + +for (int i =IGT_PLANE_2 ; i <= max_planes; i++) +igt_plane_set_fb (data->plane[i],NULL ); + +/* reset the constraint on the pipe */ +igt_output_set_pipe (output,PIPE_ANY ); + +igt_pipe_crc_free (data->pipe_crc); +} + +static bool test_is_atomic (const char *testname) +{ +if (strncmp (testname,"atomic" ,6 ) ==0 ) +return true; + +return false; +} + +static void +test_grab_crc (data_t *data,igt_output_t *output,enum pipe pipe, +color_t *color,uint64_t tiling,igt_crc_t *crc/* out */ ) +{ +struct igt_fb fb; +drmModeModeInfo *mode; +igt_plane_t *primary; +int n; +bool test_atomic =test_is_atomic (igt_subtest_name ()); + +igt_output_set_pipe (output, pipe); + + primary =igt_output_get_plane (output,IGT_PLANE_PRIMARY ); + + mode =igt_output_get_mode (output); + +igt_create_color_fb (data->drm_fd, mode->hdisplay, mode->vdisplay, +DRM_FORMAT_XRGB8888 , +LOCAL_DRM_FORMAT_MOD_NONE , + color->red, color->green, color->blue, + &fb); + +igt_plane_set_fb (primary, &fb); + +igt_display_commit2 (&data->display, + test_atomic ?COMMIT_ATOMIC :COMMIT_LEGACY ); + +igt_pipe_crc_start (data->pipe_crc); + n =igt_pipe_crc_get_crcs (data->pipe_crc,1 , &crc); +igt_assert_eq (n,1 ); +igt_pipe_crc_stop (data->pipe_crc); + +igt_plane_set_fb (primary,NULL ); + +igt_display_commit2 (&data->display, + test_atomic ?COMMIT_ATOMIC :COMMIT_LEGACY ); + +igt_remove_fb (data->drm_fd, &fb); +} + +/* +* Multiple plane position test. +* - We start by grabbing a reference CRC of a full blue fb being scanned +* out on the primary plane +* - Then we scannout number of planes: +* * the primary plane uses a blue fb with a black rectangle hole +* * planes, on top of the primary plane, with a blue fb that is set-up +* to cover the black rectangles of the primary plane fb +* The resulting CRC should be identical to the reference CRC +*/ + +static void +create_fb_for_mode_position (data_t *data,drmModeModeInfo *mode, +color_t *color,int *rect_x,int *rect_y, +int rect_w,int rect_h,uint64_t tiling, +int max_planes) +{ +unsigned int fb_id; +cairo_t *cr; + + fb_id =igt_create_fb (data->drm_fd, + mode->hdisplay, mode->vdisplay, +DRM_FORMAT_XRGB8888 , + tiling, + &data->fb[IGT_PLANE_PRIMARY ]); +igt_assert (fb_id); + + cr =igt_get_cairo_ctx (data->drm_fd, &data->fb[IGT_PLANE_PRIMARY ]); +igt_paint_color (cr, rect_x[0 ], rect_y[0 ], + mode->hdisplay, mode->vdisplay, + color->red, color->green, color->blue); + +for (int i =IGT_PLANE_2 ; i <= max_planes; i++) +igt_paint_color (cr, rect_x[i], rect_y[i], + rect_w, rect_h,0.0 ,0.0 ,0.0 ); + +igt_assert (cairo_status (cr) ==0 ); +cairo_destroy (cr); +} + + +static void +test_planes (data_t *data,enum pipe pipe,color_t *color, +uint64_t tiling,int max_planes,igt_output_t *output) +{ +drmModeModeInfo *mode; +int x[IGT_MAX_PLANES ]; +int y[IGT_MAX_PLANES ]; +int i; + +igt_output_set_pipe (output, pipe); + + mode =igt_output_get_mode (output); + +/* sprite planes with random positions */ + x[IGT_PLANE_PRIMARY ] =0 ; + y[IGT_PLANE_PRIMARY ] =0 ; +for (i =IGT_PLANE_2 ; i <= max_planes; i++) { + x[i] =rand () % (mode->hdisplay -SIZE ); + y[i] =rand () % (mode->vdisplay -SIZE ); + + data->plane[i] =igt_output_get_plane (output, i); + +igt_create_color_fb (data->drm_fd, +SIZE ,SIZE ,/* width, height */ + data->plane[i]->is_cursor ?DRM_FORMAT_ARGB8888 :DRM_FORMAT_XRGB8888 , + tiling, + color->red, color->green, color->blue, + &data->fb[i]); + +igt_plane_set_position (data->plane[i], x[i], y[i]); +igt_plane_set_fb (data->plane[i], &data->fb[i]); + } + +/* primary plane */ + data->plane[IGT_PLANE_PRIMARY ] =igt_output_get_plane (output,IGT_PLANE_PRIMARY ); +create_fb_for_mode_position (data, mode, color, x, y, +SIZE ,SIZE , tiling, max_planes); +igt_plane_set_fb (data->plane[IGT_PLANE_PRIMARY ], &data->fb[IGT_PLANE_PRIMARY ]); +} + +static void +test_plane_position_with_output (data_t *data,enum pipe pipe,igt_output_t *output, +int max_planes,uint64_t tiling) +{ +char buf[SIZE ]; +struct drm_event *e = (void *)buf; +test_position_t test = { .data = data }; +color_t blue = {0.0f ,0.0f ,1.0f }; +bool test_atomic =test_is_atomic (igt_subtest_name ()); +igt_crc_t *crc =NULL ; +igt_crc_t crc_legacy; +unsigned vblank_start; +int n, ret; + +if (test_atomic) +igt_require (data->display.is_atomic); + +igt_info ("Testing connector %s using pipe %s with %d planes for %d %s\n" , +igt_output_name (output),kmstest_pipe_name (pipe), max_planes, + opt.iterations, opt.iterations >1 ?"iterations" :"iteration" ); + +test_init (data, pipe); + +test_grab_crc (data, output, pipe, &blue, tiling, + &test.reference_crc); + +if (test_atomic) +igt_pipe_crc_start (data->pipe_crc); + +for (int i =0 ; i < opt.iterations; i++) { +test_planes (data, pipe, &blue, tiling, max_planes, output); + +if (test_atomic) { + vblank_start =get_vblank (data->display.drm_fd, pipe,DRM_VBLANK_NEXTONMISS ); + +igt_display_commit_atomic (&data->display, +DRM_MODE_PAGE_FLIP_EVENT , + &data->display); + + ret =read (data->display.drm_fd, buf,sizeof (buf)); + +igt_assert_eq (get_vblank (data->display.drm_fd, pipe,0 ), vblank_start +1 ); +igt_set_timeout (1 ,"Stuck on page flip" ); +igt_assert_neq (errno,EINTR ); +igt_assert_neq (errno,EAGAIN ); +igt_assert (ret >=0 ); +igt_assert_eq (e->type,DRM_EVENT_FLIP_COMPLETE ); + + n =igt_pipe_crc_get_crcs (data->pipe_crc,MAX_CRCS , &crc); + +igt_assert_eq (n,MAX_CRCS ); + }else { +igt_display_commit2 (&data->display,COMMIT_LEGACY ); + +igt_pipe_crc_collect_crc (data->pipe_crc, &crc_legacy); + crc = &crc_legacy; + } + +igt_assert_crc_equal (&test.reference_crc, crc); + } + +if (test_atomic) +igt_pipe_crc_stop (data->pipe_crc); + +test_fini (data, output, max_planes); +} + +static void +test_plane_position (data_t *data,enum pipe pipe,int max_planes, +uint64_t tiling) +{ +igt_output_t *output; +int connected_outs; + +igt_skip_on (pipe >= data->display.n_pipes); +igt_skip_on (max_planes >= data->display.pipes[pipe].n_planes); + +if (!opt.user_seed) + opt.seed =time (NULL ); + +srand (opt.seed); +logwrite (igt_subtest_name ()); + + connected_outs =0 ; +for_each_connected_output (&data->display, output) { +test_plane_position_with_output (data, pipe, output, + max_planes, tiling); + connected_outs++; + } + +igt_skip_on (connected_outs ==0 ); + +} + +static void +run_tests_for_pipe_plane (data_t *data,enum pipe pipe,int max_planes) +{ +igt_subtest_f ("legacy-pipe-%s-tiling-none-planes-%d" , + kmstest_pipe_name(pipe), max_planes) +test_plane_position (data, pipe, max_planes,LOCAL_DRM_FORMAT_MOD_NONE ); + +igt_subtest_f ("atomic-pipe-%s-tiling-none-planes-%d" , + kmstest_pipe_name(pipe), max_planes) +test_plane_position (data, pipe, max_planes,LOCAL_I915_FORMAT_MOD_X_TILED ); + +igt_subtest_f ("legacy-pipe-%s-tiling-x-planes-%d" , + kmstest_pipe_name(pipe), max_planes) +test_plane_position (data, pipe, max_planes,LOCAL_I915_FORMAT_MOD_X_TILED ); + +igt_subtest_f ("atomic-pipe-%s-tiling-x-planes-%d" , + kmstest_pipe_name(pipe), max_planes) +test_plane_position (data, pipe, max_planes,LOCAL_I915_FORMAT_MOD_X_TILED ); + +igt_subtest_f ("legacy-pipe-%s-tiling-y-planes-%d" , + kmstest_pipe_name(pipe), max_planes) +test_plane_position (data, pipe, max_planes,LOCAL_I915_FORMAT_MOD_Y_TILED ); + +igt_subtest_f ("atomic-pipe-%s-tiling-y-planes-%d" , + kmstest_pipe_name(pipe), max_planes) +test_plane_position (data, pipe, max_planes,LOCAL_I915_FORMAT_MOD_Y_TILED ); + +igt_subtest_f ("legacy-pipe-%s-tiling-yf-planes-%d" , + kmstest_pipe_name(pipe), max_planes) +test_plane_position (data, pipe, max_planes, LOCAL_I915_FORMAT_MOD_Yf_TILED); + +igt_subtest_f ("atomic-pipe-%s-tiling-yf-planes-%d" , + kmstest_pipe_name(pipe), max_planes) +test_plane_position (data, pipe, max_planes, LOCAL_I915_FORMAT_MOD_Yf_TILED); +} + +static void +run_tests_for_pipe (data_t *data,enum pipe pipe) +{ +for (int planes =1 ; planes <IGT_MAX_PLANES ; planes++) +run_tests_for_pipe_plane (data, pipe, planes); +} + +static data_t data; + +static int opt_handler (int option,int option_index,void *input) +{ +switch (option) { +case 'i' : + opt.iterations =IN_RANGE (strtol (optarg,NULL ,0 ),1 ,256 ); +break ; +case 's' : + opt.user_seed = true; + opt.seed =strtol (optarg,NULL ,0 ); +break ; +case 'l' : + opt.user_logfile = true; +strcpy (opt.logfile, optarg); +break ; +default : +igt_assert (false); + } + +return 0 ; +} + +const char *help_str = +" --iterations Number of iterations for test coverage. min 1, max 256, default 16 iterations \n" +" --seed Seed for random number generator\n" +" --logfile Logfile to store seeds for random number generator, default 'kms_plane_multiple.log'\n" ; + +int main (int argc,char *argv[]) +{ +time_t t =time (NULL ); +struct tm tm = *localtime (&t); + +struct option long_options[] = { + {"iterations" , required_argument,NULL ,'i' }, + {"seed" , required_argument,NULL ,'s' }, + {"logfile" , required_argument,NULL ,'l' }, + {0 ,0 ,0 ,0 } + }; + +igt_subtest_init_parse_opts (&argc, argv,"" , long_options, help_str, + opt_handler,NULL ); + +if (!opt.user_logfile) +sprintf (opt.logfile,"kms_plane_multiple-%4d-%2d-%2d.log" , + tm.tm_year +1900 , tm.tm_mon +1 , tm.tm_mday); + +igt_skip_on_simulation (); + + igt_fixture { + data.drm_fd =drm_open_driver_master (DRIVER_INTEL ); + +kmstest_set_vt_graphics_mode (); + +igt_require_pipe_crc (); +igt_display_init (&data.display, data.drm_fd); + } + +for (int pipe =0 ; pipe <I915_MAX_PIPES ; pipe++) +run_tests_for_pipe (&data, pipe); + + igt_fixture { +igt_display_fini (&data.display); + } + +igt_exit (); +}Signature · 1 line
2.7.4
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 30 lines · Daniel Vetter
Quoted 15 lines · Mika Kahola
This is a testcase with multiple planes. The idea here is the following
- draw a uniform frame with blue color
- grab crc for reference
- put planes randomly on top with the same blue color
- punch holes with black color into the primary framebuffer
- ideally the planes should cover these holes so that the output is the
identical to reference crc
- composite all with one ioctl call
- grab crc and verify that the reference crc is equal
- repeat this for dozen iterations to maximize coverageQuoted 8 lines
v4: For atomic test enable crc capturing before entering into a iteration loop. After each iteration, check that page flip didn't take no more than 1 vblank, fetch all crc's and check the values.
Introduce new command line parameter for the number of iterations.
The test run from 1 to 256 iterations.This seems real low. Screens run at usuall 50-60Hz, which means you just
allow for a few seconds. I'd say for a normal validation run timing it to
be 1 second (for each subtest) is a reasonable start.
Quoted 9 lines
But for the knob we probably want to make this virtually unlimited, e.g.
-1 == never stop. This would be useful for chasing hard-to-reproduct underruns and errors: Run testcase with unlimited iterations, it will die
as soon as the first error shows up. Then try with next hack/debug trick
until the test survives for hours and it all looks good ;-)
I was thinking this unlimited option too but then I thought it would be safer if the test would stop at some point. Anyway, I can add this option to the test.
Quoted 594 lines
For the testcode itself I think it'd be good if at least Ville and Maarten
review it, since this will be the groundwork for adding all kinds of atomic tests (rotation, yuv, scaling, anything else really). -DanielQuoted 588 lines
v3: Cleanup by removing separate plane array
For atomic, passDRM_MODE_PAGE_FLIP_EVENT
Grab crc by usingigt_pipe_crc_get_crcinstead ofigt_pipe_crc_collect_crc
Rename nplanes variable tomax_planes
To optimize test execution, run iterations after the modesetv2: Keep a logfile on random number seeds per subtest that are not skipped
due to unmet test requirementsSigned-off-by Mika Kahola <[email protected]>---
tests/Makefile.sources | 1 +
tests/kms_plane_multiple.c | 475
+++++++++++++++++++++++++++++++++++++++++++++2 files changed, 476 insertions(+)create mode 100644
tests/kms_plane_multiple.ctests/Makefile.sources +1
-0@@ -105,6 +105,7 @@ TESTS_progs_M = \ kms_pipe_color \ kms_pipe_crc_basic \ kms_plane \ + kms_plane_multiple \ kms_properties \ kms_psr_sink_crc \ kms_render \tests/kms_plane_multiple.c new file +4
-0@@ -0,0 +1,475 @@ +/* +* Copyright © 2016 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */tests/kms_plane_multiple.c new file +10
-0+ +#include "igt.h" +#include "drmtest.h" +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <string.h> +#include <time.h> + +IGT_TEST_DESCRIPTION("Test atomic mode setting with multipleplanes ");
tests/kms_plane_multiple.c new file +5
-0+ +#define MAX_CRCS 1 +#define SIZE 128 + +#define IN_RANGE (X ,MIN ,MAX ) ((X) < (MIN) || (X) > (MAX) ? 16 :X)
tests/kms_plane_multiple.c new file +51
-0+ +typedef struct { +float red; +float green; +float blue; +}color_t ; + +typedef struct { +int drm_fd; +igt_display_t display; +igt_pipe_crc_t *pipe_crc; +igt_plane_t *plane[IGT_MAX_PLANES ]; +struct igt_fb fb[IGT_MAX_PLANES ]; +}data_t ; + +typedef struct { +data_t *data; +igt_crc_t reference_crc; +}test_position_t ; + +/* Command line parameters. */ +struct { +unsigned iterations; +bool user_seed; +int seed; +bool user_logfile; +char logfile[SIZE ]; +} opt = { + .iterations =16 , + .user_seed = false, + .seed =1 , + .user_logfile = false, + .logfile ="kms_plane_multiple.log" , +}; + +static inline uint32_t pipe_select (int pipe) +{ +if (pipe >1 ) +return pipe <<DRM_VBLANK_HIGH_CRTC_SHIFT ; +else if (pipe >0 ) +return DRM_VBLANK_SECONDARY ; +else +return 0 ; +} + +static unsigned get_vblank (int fd,int pipe,unsigned flags) +{ +union drm_wait_vblank vbl; + +memset (&vbl,0 ,sizeof (vbl)); + vbl.request.type =DRM_VBLANK_RELATIVE |pipe_select (pipe)| flags;
tests/kms_plane_multiple.c new file +16
-0+if (drmIoctl (fd,DRM_IOCTL_WAIT_VBLANK , &vbl)) +return 0 ; + +return vbl.reply.sequence; +} + +static int logwrite (const char *testname) +{ +time_t curr_time; +FILE *fid; +char *time_str; + + fid =fopen (opt.logfile,"a" ); + +if (fid ==NULL ) { + igt_debug("Could not open file %s\n",opt.logfile);
tests/kms_plane_multiple.c new file +9
-0+return -1 ; + } + + curr_time =time (NULL ); + + time_str =ctime (&curr_time); + time_str[strlen (time_str)-1 ] ='\0' ; + + fprintf(fid, "%s: kms_plane_multiple --run-subtest %s --seed %d\n",
tests/kms_plane_multiple.c new file +13
-0+ time_str, testname, opt.seed); + +fclose (fid); + +return 0 ; +} + +/* +* Common code across all tests, acting on data_t +*/ +static void test_init (data_t *data,enum pipe pipe) +{ + data->pipe_crc = igt_pipe_crc_new(pipe,
INTEL_PIPE_CRC_SOURCE_AUTO);tests/kms_plane_multiple.c new file +3
-0+} + +static void test_fini(data_t *data, igt_output_t *output, int
max_planes)tests/kms_plane_multiple.c new file +23
-0+{ +igt_plane_set_fb (data->plane[IGT_PLANE_PRIMARY ],NULL ); + +for (int i =IGT_PLANE_2 ; i <= max_planes; i++) +igt_plane_set_fb (data->plane[i],NULL ); + +/* reset the constraint on the pipe */ +igt_output_set_pipe (output,PIPE_ANY ); + +igt_pipe_crc_free (data->pipe_crc); +} + +static bool test_is_atomic (const char *testname) +{ +if (strncmp (testname,"atomic" ,6 ) ==0 ) +return true; + +return false; +} + +static void +test_grab_crc (data_t *data,igt_output_t *output,enum pipe pipe, + color_t *color, uint64_t tiling, igt_crc_t *crc /*out */)
tests/kms_plane_multiple.c new file +14
-0+{ +struct igt_fb fb; +drmModeModeInfo *mode; +igt_plane_t *primary; +int n; +bool test_atomic =test_is_atomic (igt_subtest_name ()); + +igt_output_set_pipe (output, pipe); + + primary =igt_output_get_plane (output,IGT_PLANE_PRIMARY ); + + mode =igt_output_get_mode (output); + + igt_create_color_fb(data->drm_fd, mode->hdisplay, mode-Quoted 1 line
vdisplay,
tests/kms_plane_multiple.c new file +9
-0+ DRM_FORMAT_XRGB8888, + LOCAL_DRM_FORMAT_MOD_NONE, + color->red, color->green, color->blue, + &fb); + +igt_plane_set_fb (primary, &fb); + + igt_display_commit2(&data->display, + test_atomic ? COMMIT_ATOMIC :
COMMIT_LEGACY);tests/kms_plane_multiple.c new file +10
-0+ +igt_pipe_crc_start (data->pipe_crc); + n =igt_pipe_crc_get_crcs (data->pipe_crc,1 , &crc); +igt_assert_eq (n,1 ); +igt_pipe_crc_stop (data->pipe_crc); + +igt_plane_set_fb (primary,NULL ); + + igt_display_commit2(&data->display, + test_atomic ? COMMIT_ATOMIC :
COMMIT_LEGACY);tests/kms_plane_multiple.c new file +7
-0+ +igt_remove_fb (data->drm_fd, &fb); +} + +/* +* Multiple plane position test. +* - We start by grabbing a reference CRC of a full blue fb being scanned
+ * out on the primary plane
+ * - Then we scannout number of planes:
+ * * the primary plane uses a blue fb with a black rectangle hole
+ * * planes, on top of the primary plane, with a blue fb that is set-up
+ * to cover the black rectangles of the primary plane fb
+ * The resulting CRC should be identical to the reference CRC
+ */tests/kms_plane_multiple.c new file +4
-0+ +static void +create_fb_for_mode_position (data_t *data,drmModeModeInfo *mode, + color_t *color, int *rect_x, int
*rect_y,tests/kms_plane_multiple.c new file +1
-0+ int rect_w, int rect_h, uint64_ttiling,
tests/kms_plane_multiple.c new file +13
-0+ int max_planes) +{ +unsigned int fb_id; +cairo_t *cr; + + fb_id =igt_create_fb (data->drm_fd, + mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, + tiling, + &data->fb[IGT_PLANE_PRIMARY]); +igt_assert (fb_id); + + cr = igt_get_cairo_ctx(data->drm_fd, &data-Quoted 1 line
fb[IGT_PLANE_PRIMARY]);
tests/kms_plane_multiple.c new file +37
-0+igt_paint_color (cr, rect_x[0 ], rect_y[0 ], + mode->hdisplay, mode->vdisplay, + color->red, color->green, color->blue); + +for (int i =IGT_PLANE_2 ; i <= max_planes; i++) +igt_paint_color (cr, rect_x[i], rect_y[i], + rect_w, rect_h,0.0 ,0.0 ,0.0 ); + +igt_assert (cairo_status (cr) ==0 ); +cairo_destroy (cr); +} + + +static void +test_planes (data_t *data,enum pipe pipe,color_t *color, + uint64_t tiling, int max_planes, igt_output_t *output) +{ +drmModeModeInfo *mode; +int x[IGT_MAX_PLANES ]; +int y[IGT_MAX_PLANES ]; +int i; + +igt_output_set_pipe (output, pipe); + + mode =igt_output_get_mode (output); + +/* sprite planes with random positions */ + x[IGT_PLANE_PRIMARY ] =0 ; + y[IGT_PLANE_PRIMARY ] =0 ; +for (i =IGT_PLANE_2 ; i <= max_planes; i++) { + x[i] =rand () % (mode->hdisplay -SIZE ); + y[i] =rand () % (mode->vdisplay -SIZE ); + + data->plane[i] =igt_output_get_plane (output, i); + + igt_create_color_fb(data->drm_fd, + SIZE, SIZE, /* width, height*/
tests/kms_plane_multiple.c new file +1
-0+ data->plane[i]->is_cursor ?
DRM_FORMAT_ARGB8888:DRM_FORMAT_XRGB8888,tests/kms_plane_multiple.c new file +2
-0+ tiling, + color->red, color->green,
color->blue,tests/kms_plane_multiple.c new file +3
-0+ &data->fb[i]); + + igt_plane_set_position(data->plane[i], x[i],y[i]);
tests/kms_plane_multiple.c new file +5
-0+igt_plane_set_fb (data->plane[i], &data->fb[i]); + } + +/* primary plane */ + data->plane[IGT_PLANE_PRIMARY] =
igt_output_get_plane(output, IGT_PLANE_PRIMARY);tests/kms_plane_multiple.c new file +2
-0+ create_fb_for_mode_position(data, mode, color, x, y, + SIZE, SIZE, tiling,
max_planes);tests/kms_plane_multiple.c new file +1
-0+ igt_plane_set_fb(data->plane[IGT_PLANE_PRIMARY], &data-Quoted 1 line
fb[IGT_PLANE_PRIMARY]);
tests/kms_plane_multiple.c new file +4
-0+} + +static void +test_plane_position_with_output(data_t *data, enum pipe pipe,
igt_output_t*output,tests/kms_plane_multiple.c new file +16
-0+ int max_planes, uint64_t tiling) +{ + char buf[SIZE]; +struct drm_event *e = (void *)buf; +test_position_t test = { .data = data }; + color_t blue = { 0.0f, 0.0f, 1.0f }; +bool test_atomic =test_is_atomic (igt_subtest_name ()); +igt_crc_t *crc =NULL ; +igt_crc_t crc_legacy; +unsigned vblank_start; +int n, ret; + +if (test_atomic) +igt_require (data->display.is_atomic); + + igt_info("Testing connector %s using pipe %s with %dplanes for %d %s\n",
tests/kms_plane_multiple.c new file +1
-0+ igt_output_name(output), kmstest_pipe_name(pipe),
max_planes,tests/kms_plane_multiple.c new file +1
-0+ opt.iterations, opt.iterations > 1 ? "iterations": "iteration");
tests/kms_plane_multiple.c new file +11
-0+ +test_init (data, pipe); + +test_grab_crc (data, output, pipe, &blue, tiling, + &test.reference_crc); + +if (test_atomic) +igt_pipe_crc_start (data->pipe_crc); + +for (int i =0 ; i < opt.iterations; i++) { + test_planes(data, pipe, &blue, tiling, max_planes,output);
tests/kms_plane_multiple.c new file +3
-0+ +if (test_atomic) { + vblank_start = get_vblank(data-Quoted 1 line
display.drm_fd, pipe,
DRM_VBLANK_NEXTONMISS);tests/kms_plane_multiple.c new file +3
-0+ +igt_display_commit_atomic (&data->display, + DRM_MODE_PAGE_FL
IP_EVENT,tests/kms_plane_multiple.c new file +3
-0+ &data->display); + + ret = read(data->display.drm_fd, buf,sizeof(buf));
tests/kms_plane_multiple.c new file +2
-0+ + igt_assert_eq(get_vblank(data-Quoted 1 line
display.drm_fd, pipe, 0),
vblank_start+ 1);tests/kms_plane_multiple.c new file +5
-0+igt_set_timeout (1 ,"Stuck on page flip" ); +igt_assert_neq (errno,EINTR ); +igt_assert_neq (errno,EAGAIN ); +igt_assert (ret >=0 ); + igt_assert_eq(e->type,
DRM_EVENT_FLIP_COMPLETE);tests/kms_plane_multiple.c new file +2
-0+ + n = igt_pipe_crc_get_crcs(data->pipe_crc,
MAX_CRCS, &crc);tests/kms_plane_multiple.c new file +4
-0+ +igt_assert_eq (n,MAX_CRCS ); + }else { + igt_display_commit2(&data->display,
COMMIT_LEGACY);tests/kms_plane_multiple.c new file +2
-0+ + igt_pipe_crc_collect_crc(data->pipe_crc,
&crc_legacy);tests/kms_plane_multiple.c new file +21
-0+ crc = &crc_legacy; + } + +igt_assert_crc_equal (&test.reference_crc, crc); + } + +if (test_atomic) +igt_pipe_crc_stop (data->pipe_crc); + +test_fini (data, output, max_planes); +} + +static void +test_plane_position(data_t *data, enum pipe pipe, int max_planes, + uint64_t tiling) +{ + igt_output_t *output; + int connected_outs; + + igt_skip_on(pipe >= data->display.n_pipes); + igt_skip_on(max_planes >= data-Quoted 1 line
display.pipes[pipe].n_planes);
tests/kms_plane_multiple.c new file +10
-0+ +if (!opt.user_seed) + opt.seed =time (NULL ); + +srand (opt.seed); +logwrite (igt_subtest_name ()); + + connected_outs =0 ; +for_each_connected_output (&data->display, output) { + test_plane_position_with_output(data, pipe,output,
tests/kms_plane_multiple.c new file +1
-0+ max_planes,tiling);
tests/kms_plane_multiple.c new file +9
-0+ connected_outs++; + } + +igt_skip_on (connected_outs ==0 ); + +} + +static void +run_tests_for_pipe_plane(data_t *data, enum pipe pipe, int
max_planes)tests/kms_plane_multiple.c new file +4
-0+{ +igt_subtest_f ("legacy-pipe-%s-tiling-none-planes-%d" , + kmstest_pipe_name(pipe), max_planes) + test_plane_position(data, pipe, max_planes,
LOCAL_DRM_FORMAT_MOD_NONE);tests/kms_plane_multiple.c new file +4
-0+ +igt_subtest_f ("atomic-pipe-%s-tiling-none-planes-%d" , + kmstest_pipe_name(pipe), max_planes) + test_plane_position(data, pipe, max_planes,
LOCAL_I915_FORMAT_MOD_X_TILED);tests/kms_plane_multiple.c new file +4
-0+ +igt_subtest_f ("legacy-pipe-%s-tiling-x-planes-%d" , + kmstest_pipe_name(pipe), max_planes) + test_plane_position(data, pipe, max_planes,
LOCAL_I915_FORMAT_MOD_X_TILED);tests/kms_plane_multiple.c new file +4
-0+ +igt_subtest_f ("atomic-pipe-%s-tiling-x-planes-%d" , + kmstest_pipe_name(pipe), max_planes) + test_plane_position(data, pipe, max_planes,
LOCAL_I915_FORMAT_MOD_X_TILED);tests/kms_plane_multiple.c new file +4
-0+ +igt_subtest_f ("legacy-pipe-%s-tiling-y-planes-%d" , + kmstest_pipe_name(pipe), max_planes) + test_plane_position(data, pipe, max_planes,
LOCAL_I915_FORMAT_MOD_Y_TILED);tests/kms_plane_multiple.c new file +4
-0+ +igt_subtest_f ("atomic-pipe-%s-tiling-y-planes-%d" , + kmstest_pipe_name(pipe), max_planes) + test_plane_position(data, pipe, max_planes,
LOCAL_I915_FORMAT_MOD_Y_TILED);tests/kms_plane_multiple.c new file +4
-0+ +igt_subtest_f ("legacy-pipe-%s-tiling-yf-planes-%d" , + kmstest_pipe_name(pipe), max_planes) + test_plane_position(data, pipe, max_planes,
LOCAL_I915_FORMAT_MOD_Yf_TILED);tests/kms_plane_multiple.c new file +4
-0+ +igt_subtest_f ("atomic-pipe-%s-tiling-yf-planes-%d" , + kmstest_pipe_name(pipe), max_planes) + test_plane_position(data, pipe, max_planes,
LOCAL_I915_FORMAT_MOD_Yf_TILED);tests/kms_plane_multiple.c new file +16
-0+} + +static void +run_tests_for_pipe (data_t *data,enum pipe pipe) +{ +for (int planes =1 ; planes <IGT_MAX_PLANES ; planes++) +run_tests_for_pipe_plane (data, pipe, planes); +} + +static data_t data; + +static int opt_handler (int option,int option_index,void *input) +{ +switch (option) { +case 'i' : + opt.iterations = IN_RANGE(strtol(optarg, NULL, 0),1, 256);
tests/kms_plane_multiple.c new file +18
-0+break ; +case 's' : + opt.user_seed = true; + opt.seed =strtol (optarg,NULL ,0 ); +break ; +case 'l' : + opt.user_logfile = true; +strcpy (opt.logfile, optarg); +break ; +default : +igt_assert (false); + } + +return 0 ; +} + +const char *help_str = + " --iterations Number of iterations for test coverage.min 1, max 256, default 16 iterations \n"
tests/kms_plane_multiple.c new file +2
-0+" --seed Seed for random number generator\n" + " --logfile Logfile to store seeds for random numbergenerator, default 'kms_plane_multiple.log'\n";
tests/kms_plane_multiple.c new file +14
-0+ +int main (int argc,char *argv[]) +{ +time_t t =time (NULL ); +struct tm tm = *localtime (&t); + +struct option long_options[] = { + {"iterations" , required_argument,NULL ,'i' }, + { "seed", required_argument, NULL, 's'}, + {"logfile" , required_argument,NULL ,'l' }, + {0 ,0 ,0 ,0 } + }; + + igt_subtest_init_parse_opts(&argc, argv, "", long_options,
help_str,tests/kms_plane_multiple.c new file +4
-0+ opt_handler, NULL); + +if (!opt.user_logfile) + sprintf(opt.logfile, "kms_plane_multiple-%4d-%2d-%2d.log",
tests/kms_plane_multiple.c new file +1
-0+ tm.tm_year + 1900, tm.tm_mon + 1,tm.tm_mday);
tests/kms_plane_multiple.c new file +5
-0+ +igt_skip_on_simulation (); + + igt_fixture { + data.drm_fd =
drm_open_driver_master(DRIVER_INTEL);tests/kms_plane_multiple.c new file +16
-0+ +kmstest_set_vt_graphics_mode (); + +igt_require_pipe_crc (); +igt_display_init (&data.display, data.drm_fd); + } + +for (int pipe =0 ; pipe <I915_MAX_PIPES ; pipe++) +run_tests_for_pipe (&data, pipe); + + igt_fixture { +igt_display_fini (&data.display); + } + +igt_exit (); +}--
2.7.4
Signature · 6 lines
Mika Kahola - Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Op 20-10-16 om 11:27 schreef Mika Kahola:
Quoted 82 lines
This is a testcase with multiple planes. The idea here is the following
- draw a uniform frame with blue color
- grab crc for reference
- put planes randomly on top with the same blue color
- punch holes with black color into the primary framebuffer
- ideally the planes should cover these holes so that the output is the identical to reference crc
- composite all with one ioctl call
- grab crc and verify that the reference crc is equal
- repeat this for dozen iterations to maximize coveragev4: For atomic test enable crc capturing before entering into a
iteration loop. After each iteration, check that page flip didn't take no more than 1 vblank, fetch all crc's and check the values.Introduce new command line parameter for the number of iterations. The test run from 1 to 256 iterations.
v3: Cleanup by removing separate plane array
For atomic, passDRM_MODE_PAGE_FLIP_EVENT
Grab crc by usingigt_pipe_crc_get_crcinstead ofigt_pipe_crc_collect_crcRename nplanes variable tomax_planes
To optimize test execution, run iterations after the modesetv2: Keep a logfile on random number seeds per subtest that are not skipped
due to unmet test requirementsSigned-off-by Mika Kahola <[email protected]>--- tests/Makefile.sources | 1 + tests/kms_plane_multiple.c | 475 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 476 insertions(+) create mode 100644 tests/kms_plane_multiple.ctests/Makefile.sources +1
-0@@ -105,6 +105,7 @@ TESTS_progs_M = \ kms_pipe_color \ kms_pipe_crc_basic \ kms_plane \ + kms_plane_multiple \ kms_properties \ kms_psr_sink_crc \ kms_render \tests/kms_plane_multiple.c new file +28
-0@@ -0,0 +1,475 @@ +/* +* Copyright © 2016 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +* +*/ + +#include "igt.h" +#include "drmtest.h" +#include <errno.h> +#include <stdbool.h>
tests/kms_plane_multiple.c line 38
Quoted 10 lines
tests/kms_plane_multiple.c new file +10
-0+#include <stdio.h> +#include <string.h> +#include <time.h> + +IGT_TEST_DESCRIPTION ("Test atomic mode setting with multiple planes " ); + +#define MAX_CRCS 1 +#define SIZE 128 + +#define IN_RANGE (X ,MIN ,MAX ) ((X) < (MIN) || (X) > (MAX) ? 16 : X)
16 or MAX? anyway it's only used in one place, so might as well remove the macro.
Quoted 16 lines
tests/kms_plane_multiple.c new file +16
-0+typedef struct { +float red; +float green; +float blue; +}color_t ; + +typedef struct { +int drm_fd; +igt_display_t display; +igt_pipe_crc_t *pipe_crc; +igt_plane_t *plane[IGT_MAX_PLANES ]; +struct igt_fb fb[IGT_MAX_PLANES ]; +}data_t ; + +typedef struct { + data_t *data;
tests/kms_plane_multiple.c line 65
Quoted 10 lines
tests/kms_plane_multiple.c new file +10
-0+igt_crc_t reference_crc; +} test_position_t; + +/* Command line parameters. */ +struct { +unsigned iterations; +bool user_seed; +int seed; +bool user_logfile; +char logfile[SIZE ];
The logfile and its infrastructure could be removed if you print the seed in with igt_debug so you get it when you run with --debug, or igt_info if you always want to print it.
In general, it's best to keep tests as dumb as possible. It's easier to include a normal test log than a specially crafted file.
Quoted 60 lines
tests/kms_plane_multiple.c new file +60
-0+} opt = { + .iterations = 16, + .user_seed = false, + .seed = 1, + .user_logfile = false, + .logfile = "kms_plane_multiple.log", +}; + +static inline uint32_t pipe_select (int pipe) +{ +if (pipe >1 ) +return pipe <<DRM_VBLANK_HIGH_CRTC_SHIFT ; +else if (pipe >0 ) +return DRM_VBLANK_SECONDARY ; +else +return 0 ; +} + +static unsigned get_vblank (int fd,int pipe,unsigned flags) +{ +union drm_wait_vblank vbl; + +memset (&vbl,0 ,sizeof (vbl)); + vbl.request.type =DRM_VBLANK_RELATIVE |pipe_select (pipe) | flags; +if (drmIoctl (fd,DRM_IOCTL_WAIT_VBLANK , &vbl)) +return 0 ; + +return vbl.reply.sequence; +} + +static int logwrite (const char *testname) +{ +time_t curr_time; +FILE *fid; +char *time_str; + + fid =fopen (opt.logfile,"a" ); + +if (fid ==NULL ) { +igt_debug ("Could not open file %s\n" , opt.logfile); +return -1 ; + } + + curr_time =time (NULL ); + + time_str =ctime (&curr_time); + time_str[strlen (time_str)-1 ] ='\0' ; + +fprintf (fid,"%s: kms_plane_multiple --run-subtest %s --seed %d\n" , + time_str, testname, opt.seed); + +fclose (fid); + +return 0 ; +} + +/* +* Common code across all tests, acting on data_t +*/ +static void test_init (data_t *data,enum pipe pipe)
tests/kms_plane_multiple.c line 135
Quoted 10 lines
tests/kms_plane_multiple.c new file +10
-0+{ + data->pipe_crc =igt_pipe_crc_new (pipe,INTEL_PIPE_CRC_SOURCE_AUTO ); +} + +static void test_fini (data_t *data,igt_output_t *output,int max_planes) +{ +igt_plane_set_fb (data->plane[IGT_PLANE_PRIMARY ],NULL ); + +for (int i =IGT_PLANE_2 ; i <= max_planes; i++) +igt_plane_set_fb (data->plane[i],NULL );
Start with IGT_PLANE_PRIMARY?
Quoted 13 lines
tests/kms_plane_multiple.c new file +13
-0+/* reset the constraint on the pipe */ +igt_output_set_pipe (output,PIPE_ANY ); + +igt_pipe_crc_free (data->pipe_crc); +} + +static bool test_is_atomic (const char *testname) +{ +if (strncmp (testname,"atomic" ,6 ) ==0 ) +return true; + +return false; +}
tests/kms_plane_multiple.c line 159
Quoted 10 lines
tests/kms_plane_multiple.c new file +10
-0+ +static void +test_grab_crc (data_t *data,igt_output_t *output,enum pipe pipe, +color_t *color,uint64_t tiling,igt_crc_t *crc/* out */ ) +{ +struct igt_fb fb; +drmModeModeInfo *mode; +igt_plane_t *primary; +int n; +bool test_atomic =test_is_atomic (igt_subtest_name ());
Surely you can just pass test_atomic as parameter to the tests? This looks like magic to me...
Or 2 separate functions for legacy vs atomic.
Quoted 19 lines
tests/kms_plane_multiple.c new file +19
-0+igt_output_set_pipe (output, pipe); + + primary =igt_output_get_plane (output,IGT_PLANE_PRIMARY ); + + mode =igt_output_get_mode (output); + +igt_create_color_fb (data->drm_fd, mode->hdisplay, mode->vdisplay, +DRM_FORMAT_XRGB8888 , +LOCAL_DRM_FORMAT_MOD_NONE , + color->red, color->green, color->blue, + &fb); + +igt_plane_set_fb (primary, &fb); + +igt_display_commit2 (&data->display, + test_atomic ?COMMIT_ATOMIC :COMMIT_LEGACY ); + +igt_pipe_crc_start (data->pipe_crc); + n =igt_pipe_crc_get_crcs (data->pipe_crc,1 , &crc);
tests/kms_plane_multiple.c line 189
Quoted 10 lines
tests/kms_plane_multiple.c new file +10
-0+igt_assert_eq (n,1 ); +igt_pipe_crc_stop (data->pipe_crc); + +igt_plane_set_fb (primary,NULL ); + +igt_display_commit2 (&data->display, + test_atomic ?COMMIT_ATOMIC :COMMIT_LEGACY ); + +igt_remove_fb (data->drm_fd, &fb); +}
This will force a modeset disable with legacy commit.
Quoted 55 lines
tests/kms_plane_multiple.c new file +55
-0+/* +* Multiple plane position test. +* - We start by grabbing a reference CRC of a full blue fb being scanned +* out on the primary plane +* - Then we scannout number of planes: +* * the primary plane uses a blue fb with a black rectangle hole +* * planes, on top of the primary plane, with a blue fb that is set-up +* to cover the black rectangles of the primary plane fb +* The resulting CRC should be identical to the reference CRC +*/ + +static void +create_fb_for_mode_position (data_t *data,drmModeModeInfo *mode, +color_t *color,int *rect_x,int *rect_y, +int rect_w,int rect_h,uint64_t tiling, +int max_planes) +{ +unsigned int fb_id; +cairo_t *cr; + + fb_id =igt_create_fb (data->drm_fd, + mode->hdisplay, mode->vdisplay, +DRM_FORMAT_XRGB8888 , + tiling, + &data->fb[IGT_PLANE_PRIMARY ]); +igt_assert (fb_id); + + cr =igt_get_cairo_ctx (data->drm_fd, &data->fb[IGT_PLANE_PRIMARY ]); +igt_paint_color (cr, rect_x[0 ], rect_y[0 ], + mode->hdisplay, mode->vdisplay, + color->red, color->green, color->blue); + +for (int i =IGT_PLANE_2 ; i <= max_planes; i++) +igt_paint_color (cr, rect_x[i], rect_y[i], + rect_w, rect_h,0.0 ,0.0 ,0.0 ); + +igt_assert (cairo_status (cr) ==0 ); +cairo_destroy (cr); +} + + +static void +test_planes (data_t *data,enum pipe pipe,color_t *color, +uint64_t tiling,int max_planes,igt_output_t *output) +{ +drmModeModeInfo *mode; +int x[IGT_MAX_PLANES ]; +int y[IGT_MAX_PLANES ]; +int i; + +igt_output_set_pipe (output, pipe); + + mode =igt_output_get_mode (output); + +/* sprite planes with random positions */
tests/kms_plane_multiple.c line 255
Quoted 10 lines
tests/kms_plane_multiple.c new file +10
-0+ x[IGT_PLANE_PRIMARY ] =0 ; + y[IGT_PLANE_PRIMARY ] =0 ; +for (i =IGT_PLANE_2 ; i <= max_planes; i++) { + x[i] =rand () % (mode->hdisplay -SIZE ); + y[i] =rand () % (mode->vdisplay -SIZE ); + + data->plane[i] =igt_output_get_plane (output, i); + + igt_create_color_fb(data->drm_fd, + SIZE, SIZE, /* width, height */
Overloading SIZE seems inappropriate here, you were already using it for some buffer sizes.
Also why use 128 here?
It's ok for cursor, but might want to set it to something bigger (or more random) for other planes.
Quoted 52 lines
tests/kms_plane_multiple.c new file +52
-0+ data->plane[i]->is_cursor ?DRM_FORMAT_ARGB8888 :DRM_FORMAT_XRGB8888 , + tiling, + color->red, color->green, color->blue, + &data->fb[i]); + +igt_plane_set_position (data->plane[i], x[i], y[i]); +igt_plane_set_fb (data->plane[i], &data->fb[i]); + } + +/* primary plane */ + data->plane[IGT_PLANE_PRIMARY ] =igt_output_get_plane (output,IGT_PLANE_PRIMARY ); +create_fb_for_mode_position (data, mode, color, x, y, +SIZE ,SIZE , tiling, max_planes); +igt_plane_set_fb (data->plane[IGT_PLANE_PRIMARY ], &data->fb[IGT_PLANE_PRIMARY ]); +} + +static void +test_plane_position_with_output (data_t *data,enum pipe pipe,igt_output_t *output, +int max_planes,uint64_t tiling) +{ +char buf[SIZE ]; +struct drm_event *e = (void *)buf; +test_position_t test = { .data = data }; +color_t blue = {0.0f ,0.0f ,1.0f }; +bool test_atomic =test_is_atomic (igt_subtest_name ()); +igt_crc_t *crc =NULL ; +igt_crc_t crc_legacy; +unsigned vblank_start; +int n, ret; + +if (test_atomic) +igt_require (data->display.is_atomic); + +igt_info ("Testing connector %s using pipe %s with %d planes for %d %s\n" , +igt_output_name (output),kmstest_pipe_name (pipe), max_planes, + opt.iterations, opt.iterations >1 ?"iterations" :"iteration" ); + +test_init (data, pipe); + +test_grab_crc (data, output, pipe, &blue, tiling, + &test.reference_crc); + +if (test_atomic) +igt_pipe_crc_start (data->pipe_crc); + +for (int i =0 ; i < opt.iterations; i++) { +test_planes (data, pipe, &blue, tiling, max_planes, output); + +if (test_atomic) { + vblank_start =get_vblank (data->display.drm_fd, pipe,DRM_VBLANK_NEXTONMISS ); + + igt_display_commit_atomic(&data->display,
tests/kms_plane_multiple.c line 317
Quoted 10 lines
tests/kms_plane_multiple.c new file +10
-0+DRM_MODE_PAGE_FLIP_EVENT , + &data->display); + + ret =read (data->display.drm_fd, buf,sizeof (buf)); + +igt_assert_eq (get_vblank (data->display.drm_fd, pipe,0 ), vblank_start +1 ); +igt_set_timeout (1 ,"Stuck on page flip" ); +igt_assert_neq (errno,EINTR ); +igt_assert_neq (errno,EAGAIN ); +igt_assert (ret >=0 );
This looks a bit funny.
On error, ret < 0 and errno is printed. I'm not sure what you're trying to accomplish here. This should probably be igt_assert(ret == sizeof(*e));
The timeout is set after the read as well, which is weird too. Should be reset there, and armed before the read. :)
Quoted 148 lines
tests/kms_plane_multiple.c new file +148
-0+igt_assert_eq (e->type,DRM_EVENT_FLIP_COMPLETE ); + + n =igt_pipe_crc_get_crcs (data->pipe_crc,MAX_CRCS , &crc); + +igt_assert_eq (n,MAX_CRCS ); + }else { +igt_display_commit2 (&data->display,COMMIT_LEGACY ); + +igt_pipe_crc_collect_crc (data->pipe_crc, &crc_legacy); + crc = &crc_legacy; + } + +igt_assert_crc_equal (&test.reference_crc, crc); + } + +if (test_atomic) +igt_pipe_crc_stop (data->pipe_crc); + +test_fini (data, output, max_planes); +} + +static void +test_plane_position (data_t *data,enum pipe pipe,int max_planes, +uint64_t tiling) +{ +igt_output_t *output; +int connected_outs; + +igt_skip_on (pipe >= data->display.n_pipes); +igt_skip_on (max_planes >= data->display.pipes[pipe].n_planes); + +if (!opt.user_seed) + opt.seed =time (NULL ); + +srand (opt.seed); +logwrite (igt_subtest_name ()); + + connected_outs =0 ; +for_each_connected_output (&data->display, output) { +test_plane_position_with_output (data, pipe, output, + max_planes, tiling); + connected_outs++; + } + +igt_skip_on (connected_outs ==0 ); + +} + +static void +run_tests_for_pipe_plane (data_t *data,enum pipe pipe,int max_planes) +{ +igt_subtest_f ("legacy-pipe-%s-tiling-none-planes-%d" , + kmstest_pipe_name(pipe), max_planes) +test_plane_position (data, pipe, max_planes,LOCAL_DRM_FORMAT_MOD_NONE ); + +igt_subtest_f ("atomic-pipe-%s-tiling-none-planes-%d" , + kmstest_pipe_name(pipe), max_planes) +test_plane_position (data, pipe, max_planes,LOCAL_I915_FORMAT_MOD_X_TILED ); + +igt_subtest_f ("legacy-pipe-%s-tiling-x-planes-%d" , + kmstest_pipe_name(pipe), max_planes) +test_plane_position (data, pipe, max_planes,LOCAL_I915_FORMAT_MOD_X_TILED ); + +igt_subtest_f ("atomic-pipe-%s-tiling-x-planes-%d" , + kmstest_pipe_name(pipe), max_planes) +test_plane_position (data, pipe, max_planes,LOCAL_I915_FORMAT_MOD_X_TILED ); + +igt_subtest_f ("legacy-pipe-%s-tiling-y-planes-%d" , + kmstest_pipe_name(pipe), max_planes) +test_plane_position (data, pipe, max_planes,LOCAL_I915_FORMAT_MOD_Y_TILED ); + +igt_subtest_f ("atomic-pipe-%s-tiling-y-planes-%d" , + kmstest_pipe_name(pipe), max_planes) +test_plane_position (data, pipe, max_planes,LOCAL_I915_FORMAT_MOD_Y_TILED ); + +igt_subtest_f ("legacy-pipe-%s-tiling-yf-planes-%d" , + kmstest_pipe_name(pipe), max_planes) +test_plane_position (data, pipe, max_planes, LOCAL_I915_FORMAT_MOD_Yf_TILED); + +igt_subtest_f ("atomic-pipe-%s-tiling-yf-planes-%d" , + kmstest_pipe_name(pipe), max_planes) +test_plane_position (data, pipe, max_planes, LOCAL_I915_FORMAT_MOD_Yf_TILED); +} + +static void +run_tests_for_pipe (data_t *data,enum pipe pipe) +{ +for (int planes =1 ; planes <IGT_MAX_PLANES ; planes++) +run_tests_for_pipe_plane (data, pipe, planes); +} + +static data_t data; + +static int opt_handler (int option,int option_index,void *input) +{ +switch (option) { +case 'i' : + opt.iterations =IN_RANGE (strtol (optarg,NULL ,0 ),1 ,256 ); +break ; +case 's' : + opt.user_seed = true; + opt.seed =strtol (optarg,NULL ,0 ); +break ; +case 'l' : + opt.user_logfile = true; +strcpy (opt.logfile, optarg); +break ; +default : +igt_assert (false); + } + +return 0 ; +} + +const char *help_str = +" --iterations Number of iterations for test coverage. min 1, max 256, default 16 iterations \n" +" --seed Seed for random number generator\n" +" --logfile Logfile to store seeds for random number generator, default 'kms_plane_multiple.log'\n" ; + +int main (int argc,char *argv[]) +{ +time_t t =time (NULL ); +struct tm tm = *localtime (&t); + +struct option long_options[] = { + {"iterations" , required_argument,NULL ,'i' }, + {"seed" , required_argument,NULL ,'s' }, + {"logfile" , required_argument,NULL ,'l' }, + {0 ,0 ,0 ,0 } + }; + +igt_subtest_init_parse_opts (&argc, argv,"" , long_options, help_str, + opt_handler,NULL ); + +if (!opt.user_logfile) +sprintf (opt.logfile,"kms_plane_multiple-%4d-%2d-%2d.log" , + tm.tm_year +1900 , tm.tm_mon +1 , tm.tm_mday); + +igt_skip_on_simulation (); + + igt_fixture { + data.drm_fd =drm_open_driver_master (DRIVER_INTEL ); + +kmstest_set_vt_graphics_mode (); + +igt_require_pipe_crc (); +igt_display_init (&data.display, data.drm_fd); + }
tests/kms_plane_multiple.c line 475
Quoted 10 lines
tests/kms_plane_multiple.c new file +10
-0+ +for (int pipe =0 ; pipe <I915_MAX_PIPES ; pipe++) +run_tests_for_pipe (&data, pipe); + + igt_fixture { +igt_display_fini (&data.display); + } + +igt_exit (); +}
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 150 lines · Maarten Lankhorst
Op 20-10-16 om 11:27 schreef Mika Kahola:
Quoted 115 lines
This is a testcase with multiple planes. The idea here is the following
- draw a uniform frame with blue color
- grab crc for reference
- put planes randomly on top with the same blue color
- punch holes with black color into the primary framebuffer
- ideally the planes should cover these holes so that the output is the
identical to reference crc
- composite all with one ioctl call
- grab crc and verify that the reference crc is equal
- repeat this for dozen iterations to maximize coveragev4: For atomic test enable crc capturing before entering into a iteration loop. After each iteration, check that page flip didn't take no more than 1 vblank, fetch all crc's and check the values.
Introduce new command line parameter for the number of iterations.
The test run from 1 to 256 iterations.v3: Cleanup by removing separate plane array
For atomic, passDRM_MODE_PAGE_FLIP_EVENT
Grab crc by usingigt_pipe_crc_get_crcinstead ofigt_pipe_crc_collect_crc
Rename nplanes variable tomax_planes
To optimize test execution, run iterations after the modesetv2: Keep a logfile on random number seeds per subtest that are not skipped
due to unmet test requirementsSigned-off-by Mika Kahola <[email protected]>---
tests/Makefile.sources | 1 +
tests/kms_plane_multiple.c | 475
+++++++++++++++++++++++++++++++++++++++++++++2 files changed, 476 insertions(+)create mode 100644
tests/kms_plane_multiple.ctests/Makefile.sources +1
-0@@ -105,6 +105,7 @@ TESTS_progs_M = \ kms_pipe_color \ kms_pipe_crc_basic \ kms_plane \ + kms_plane_multiple \ kms_properties \ kms_psr_sink_crc \ kms_render \tests/kms_plane_multiple.c new file +4
-0@@ -0,0 +1,475 @@ +/* +* Copyright © 2016 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */tests/kms_plane_multiple.c new file +10
-0+ +#include "igt.h" +#include "drmtest.h" +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <string.h> +#include <time.h> + +IGT_TEST_DESCRIPTION("Test atomic mode setting with multipleplanes ");
tests/kms_plane_multiple.c new file +5
-0+ +#define MAX_CRCS 1 +#define SIZE 128 + +#define IN_RANGE (X ,MIN ,MAX ) ((X) < (MIN) || (X) > (MAX) ? 16 :Quoted 1 line
X)
16 or MAX? anyway it's only used in one place, so might as well remove the macro.
Quoted 17 lines
tests/kms_plane_multiple.c new file +16
-0+typedef struct { +float red; +float green; +float blue; +}color_t ; + +typedef struct { +int drm_fd; +igt_display_t display; +igt_pipe_crc_t *pipe_crc; +igt_plane_t *plane[IGT_MAX_PLANES ]; +struct igt_fb fb[IGT_MAX_PLANES ]; +}data_t ; + +typedef struct { + data_t *data;tests/kms_plane_multiple.c line 65
Quoted 10 lines
tests/kms_plane_multiple.c new file +10
-0+igt_crc_t reference_crc; +} test_position_t; + +/* Command line parameters. */ +struct { +unsigned iterations; +bool user_seed; +int seed; +bool user_logfile; +char logfile[SIZE ];The logfile and its infrastructure could be removed if you print the seed in with
igt_debugso you get it when you run with --debug, origt_infoif you always want to print it.
Quoted 2 lines
In general, it's best to keep tests as dumb as possible. It's easier to include a normal test log than a specially crafted file.
The idea here was to log seed values in case we need to replicate the test. Maybe printing the seed value at the beginning of the test is enough and I can remove the log file completely.
Quoted 69 lines
Quoted 69 lines
tests/kms_plane_multiple.c new file +24
-0+} opt = { + .iterations = 16, + .user_seed = false, + .seed = 1, + .user_logfile = false, + .logfile = "kms_plane_multiple.log", +}; + +static inline uint32_t pipe_select (int pipe) +{ +if (pipe >1 ) +return pipe <<DRM_VBLANK_HIGH_CRTC_SHIFT ; +else if (pipe >0 ) +return DRM_VBLANK_SECONDARY ; +else +return 0 ; +} + +static unsigned get_vblank (int fd,int pipe,unsigned flags) +{ +union drm_wait_vblank vbl; + +memset (&vbl,0 ,sizeof (vbl)); + vbl.request.type =DRM_VBLANK_RELATIVE |pipe_select (pipe)| flags;
tests/kms_plane_multiple.c new file +16
-0+if (drmIoctl (fd,DRM_IOCTL_WAIT_VBLANK , &vbl)) +return 0 ; + +return vbl.reply.sequence; +} + +static int logwrite (const char *testname) +{ +time_t curr_time; +FILE *fid; +char *time_str; + + fid =fopen (opt.logfile,"a" ); + +if (fid ==NULL ) { + igt_debug("Could not open file %s\n",opt.logfile);
tests/kms_plane_multiple.c new file +9
-0+return -1 ; + } + + curr_time =time (NULL ); + + time_str =ctime (&curr_time); + time_str[strlen (time_str)-1 ] ='\0' ; + + fprintf(fid, "%s: kms_plane_multiple --run-subtest %s --seed %d\n",
tests/kms_plane_multiple.c new file +13
-0+ time_str, testname, opt.seed); + +fclose (fid); + +return 0 ; +} + +/* +* Common code across all tests, acting on data_t +*/ +static void test_init (data_t *data,enum pipe pipe) +{ + data->pipe_crc = igt_pipe_crc_new(pipe,
INTEL_PIPE_CRC_SOURCE_AUTO);tests/kms_plane_multiple.c new file +2
-0+} +
Quoted 8 lines
tests/kms_plane_multiple.c line 135
Quoted 7 lines
+static void
test_fini(data_t *data, igt_output_t *output, int max_planes)tests/kms_plane_multiple.c new file +5
-0+{ +igt_plane_set_fb (data->plane[IGT_PLANE_PRIMARY ],NULL ); + +for (int i =IGT_PLANE_2 ; i <= max_planes; i++) +igt_plane_set_fb (data->plane[i],NULL );Start with
IGT_PLANE_PRIMARY?
True.
Quoted 28 lines
Quoted 19 lines
tests/kms_plane_multiple.c new file +17
-0+/* reset the constraint on the pipe */ +igt_output_set_pipe (output,PIPE_ANY ); + +igt_pipe_crc_free (data->pipe_crc); +} + +static bool test_is_atomic (const char *testname) +{ +if (strncmp (testname,"atomic" ,6 ) ==0 ) +return true; + +return false; +} + +static void +test_grab_crc (data_t *data,igt_output_t *output,enum pipe pipe, + color_t *color, uint64_t tiling, igt_crc_t *crc /*out */)
tests/kms_plane_multiple.c line 159
Quoted 6 lines
tests/kms_plane_multiple.c new file +6
-0+{ +struct igt_fb fb; +drmModeModeInfo *mode; +igt_plane_t *primary; +int n; +bool test_atomic =test_is_atomic (igt_subtest_name ());Surely you can just pass
test_atomicas parameter to the tests? This looks like magic to me...
Quoted 1 line
Or 2 separate functions for legacy vs atomic.
Maybe I go here for two separate function. It might be cleaner that way even though it produces a bit of repetitive code.
Quoted 26 lines
Quoted 26 lines
tests/kms_plane_multiple.c new file +7
-0+igt_output_set_pipe (output, pipe); + + primary =igt_output_get_plane (output,IGT_PLANE_PRIMARY ); + + mode =igt_output_get_mode (output); + + igt_create_color_fb(data->drm_fd, mode->hdisplay, mode-Quoted 1 line
vdisplay,
tests/kms_plane_multiple.c new file +9
-0+ DRM_FORMAT_XRGB8888, + LOCAL_DRM_FORMAT_MOD_NONE, + color->red, color->green, color->blue, + &fb); + +igt_plane_set_fb (primary, &fb); + + igt_display_commit2(&data->display, + test_atomic ? COMMIT_ATOMIC :
COMMIT_LEGACY);tests/kms_plane_multiple.c new file +7
-0+ +igt_pipe_crc_start (data->pipe_crc); + n =igt_pipe_crc_get_crcs (data->pipe_crc,1 , &crc); +igt_assert_eq (n,1 ); +igt_pipe_crc_stop (data->pipe_crc); + +igt_plane_set_fb (primary,NULL );
Quoted 8 lines
tests/kms_plane_multiple.c line 189
Quoted 7 lines
tests/kms_plane_multiple.c new file +3
-0+ + igt_display_commit2(&data->display, + test_atomic ? COMMIT_ATOMIC :
COMMIT_LEGACY);tests/kms_plane_multiple.c new file +3
-0+ +igt_remove_fb (data->drm_fd, &fb); +}This will force a modeset disable with legacy commit.
ok.
Quoted 76 lines
Quoted 72 lines
+/*
+ * Multiple plane position test.
+ * - We start by grabbing a reference CRC of a full blue fb being scanned
+ * out on the primary plane
+ * - Then we scannout number of planes:
+ * * the primary plane uses a blue fb with a black rectangle hole
+ * * planes, on top of the primary plane, with a blue fb that is set-up
+ * to cover the black rectangles of the primary plane fb
+ * The resulting CRC should be identical to the reference CRC
+ */tests/kms_plane_multiple.c new file +4
-0+ +static void +create_fb_for_mode_position (data_t *data,drmModeModeInfo *mode, + color_t *color, int *rect_x, int
*rect_y,tests/kms_plane_multiple.c new file +1
-0+ int rect_w, int rect_h, uint64_ttiling,
tests/kms_plane_multiple.c new file +13
-0+ int max_planes) +{ +unsigned int fb_id; +cairo_t *cr; + + fb_id =igt_create_fb (data->drm_fd, + mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, + tiling, + &data->fb[IGT_PLANE_PRIMARY]); +igt_assert (fb_id); + + cr = igt_get_cairo_ctx(data->drm_fd, &data-Quoted 1 line
fb[IGT_PLANE_PRIMARY]);
tests/kms_plane_multiple.c new file +37
-0+igt_paint_color (cr, rect_x[0 ], rect_y[0 ], + mode->hdisplay, mode->vdisplay, + color->red, color->green, color->blue); + +for (int i =IGT_PLANE_2 ; i <= max_planes; i++) +igt_paint_color (cr, rect_x[i], rect_y[i], + rect_w, rect_h,0.0 ,0.0 ,0.0 ); + +igt_assert (cairo_status (cr) ==0 ); +cairo_destroy (cr); +} + + +static void +test_planes (data_t *data,enum pipe pipe,color_t *color, + uint64_t tiling, int max_planes, igt_output_t *output) +{ +drmModeModeInfo *mode; +int x[IGT_MAX_PLANES ]; +int y[IGT_MAX_PLANES ]; +int i; + +igt_output_set_pipe (output, pipe); + + mode =igt_output_get_mode (output); + +/* sprite planes with random positions */ + x[IGT_PLANE_PRIMARY ] =0 ; + y[IGT_PLANE_PRIMARY ] =0 ; +for (i =IGT_PLANE_2 ; i <= max_planes; i++) { + x[i] =rand () % (mode->hdisplay -SIZE ); + y[i] =rand () % (mode->vdisplay -SIZE ); + + data->plane[i] =igt_output_get_plane (output, i); + + igt_create_color_fb(data->drm_fd, + SIZE, SIZE, /* width, heightQuoted 1 line
*/
Overloading SIZE seems inappropriate here, you were already using it for some buffer sizes.
Quoted 1 line
Also why use 128 here?
It's just a value that I picked. I had to pick something so I chose this one.
Quoted 3 lines
It's ok for cursor, but might want to set it to something bigger (or more random) for other planes.
Maybe bigger size of other planes. Otherwise, we need to log the sizes too in order replicate the test if needed.
Quoted 80 lines
Quoted 74 lines
tests/kms_plane_multiple.c new file +1
-0+ data->plane[i]->is_cursor ?
DRM_FORMAT_ARGB8888:DRM_FORMAT_XRGB8888,tests/kms_plane_multiple.c new file +2
-0+ tiling, + color->red, color->green,
color->blue,tests/kms_plane_multiple.c new file +3
-0+ &data->fb[i]); + + igt_plane_set_position(data->plane[i], x[i],y[i]);
tests/kms_plane_multiple.c new file +5
-0+igt_plane_set_fb (data->plane[i], &data->fb[i]); + } + +/* primary plane */ + data->plane[IGT_PLANE_PRIMARY] =
igt_output_get_plane(output, IGT_PLANE_PRIMARY);tests/kms_plane_multiple.c new file +2
-0+ create_fb_for_mode_position(data, mode, color, x, y, + SIZE, SIZE, tiling,
max_planes);tests/kms_plane_multiple.c new file +1
-0+ igt_plane_set_fb(data->plane[IGT_PLANE_PRIMARY], &data-Quoted 1 line
fb[IGT_PLANE_PRIMARY]);
tests/kms_plane_multiple.c new file +4
-0+} + +static void +test_plane_position_with_output(data_t *data, enum pipe pipe,
igt_output_t*output,tests/kms_plane_multiple.c new file +16
-0+ int max_planes, uint64_t tiling) +{ + char buf[SIZE]; +struct drm_event *e = (void *)buf; +test_position_t test = { .data = data }; + color_t blue = { 0.0f, 0.0f, 1.0f }; +bool test_atomic =test_is_atomic (igt_subtest_name ()); +igt_crc_t *crc =NULL ; +igt_crc_t crc_legacy; +unsigned vblank_start; +int n, ret; + +if (test_atomic) +igt_require (data->display.is_atomic); + + igt_info("Testing connector %s using pipe %s with %dplanes for %d %s\n",
tests/kms_plane_multiple.c new file +1
-0+ igt_output_name(output), kmstest_pipe_name(pipe),
max_planes,tests/kms_plane_multiple.c new file +1
-0+ opt.iterations, opt.iterations > 1 ? "iterations": "iteration");
tests/kms_plane_multiple.c new file +11
-0+ +test_init (data, pipe); + +test_grab_crc (data, output, pipe, &blue, tiling, + &test.reference_crc); + +if (test_atomic) +igt_pipe_crc_start (data->pipe_crc); + +for (int i =0 ; i < opt.iterations; i++) { + test_planes(data, pipe, &blue, tiling, max_planes,output);
tests/kms_plane_multiple.c new file +3
-0+ +if (test_atomic) { + vblank_start = get_vblank(data-Quoted 1 line
display.drm_fd, pipe,
DRM_VBLANK_NEXTONMISS);tests/kms_plane_multiple.c new file +3
-0+ +igt_display_commit_atomic (&data->display, + DRM_MODE_PAGE_FL
IP_EVENT,tests/kms_plane_multiple.c new file +3
-0+ &data->display); + + ret = read(data->display.drm_fd, buf,sizeof(buf));
tests/kms_plane_multiple.c new file +2
-0+ + igt_assert_eq(get_vblank(data-Quoted 1 line
display.drm_fd, pipe, 0),
vblank_start+ 1);tests/kms_plane_multiple.c line 317
Quoted 4 lines
tests/kms_plane_multiple.c new file +4
-0+igt_set_timeout (1 ,"Stuck on page flip" ); +igt_assert_neq (errno,EINTR ); +igt_assert_neq (errno,EAGAIN ); +igt_assert (ret >=0 );This looks a bit funny.
Quoted 6 lines
On error, ret < 0 and errno is printed. I'm not sure what you're trying to accomplish here.
This should probably beigt_assert(ret == sizeof(*e));The timeout is set after the read as well, which is weird too. Should be reset there, and armed before the read. :)
Now, that I looked at it, it does seem a bit odd. I'll fix this.
Quoted 183 lines
Quoted 182 lines
tests/kms_plane_multiple.c new file +1
-0+ igt_assert_eq(e->type,
DRM_EVENT_FLIP_COMPLETE);tests/kms_plane_multiple.c new file +2
-0+ + n = igt_pipe_crc_get_crcs(data->pipe_crc,
MAX_CRCS, &crc);tests/kms_plane_multiple.c new file +4
-0+ +igt_assert_eq (n,MAX_CRCS ); + }else { + igt_display_commit2(&data->display,
COMMIT_LEGACY);tests/kms_plane_multiple.c new file +2
-0+ + igt_pipe_crc_collect_crc(data->pipe_crc,
&crc_legacy);tests/kms_plane_multiple.c new file +21
-0+ crc = &crc_legacy; + } + +igt_assert_crc_equal (&test.reference_crc, crc); + } + +if (test_atomic) +igt_pipe_crc_stop (data->pipe_crc); + +test_fini (data, output, max_planes); +} + +static void +test_plane_position(data_t *data, enum pipe pipe, int max_planes, + uint64_t tiling) +{ + igt_output_t *output; + int connected_outs; + + igt_skip_on(pipe >= data->display.n_pipes); + igt_skip_on(max_planes >= data-Quoted 1 line
display.pipes[pipe].n_planes);
tests/kms_plane_multiple.c new file +10
-0+ +if (!opt.user_seed) + opt.seed =time (NULL ); + +srand (opt.seed); +logwrite (igt_subtest_name ()); + + connected_outs =0 ; +for_each_connected_output (&data->display, output) { + test_plane_position_with_output(data, pipe,output,
tests/kms_plane_multiple.c new file +1
-0+ max_planes,tiling);
tests/kms_plane_multiple.c new file +9
-0+ connected_outs++; + } + +igt_skip_on (connected_outs ==0 ); + +} + +static void +run_tests_for_pipe_plane(data_t *data, enum pipe pipe, int
max_planes)tests/kms_plane_multiple.c new file +4
-0+{ +igt_subtest_f ("legacy-pipe-%s-tiling-none-planes-%d" , + kmstest_pipe_name(pipe), max_planes) + test_plane_position(data, pipe, max_planes,
LOCAL_DRM_FORMAT_MOD_NONE);tests/kms_plane_multiple.c new file +4
-0+ +igt_subtest_f ("atomic-pipe-%s-tiling-none-planes-%d" , + kmstest_pipe_name(pipe), max_planes) + test_plane_position(data, pipe, max_planes,
LOCAL_I915_FORMAT_MOD_X_TILED);tests/kms_plane_multiple.c new file +4
-0+ +igt_subtest_f ("legacy-pipe-%s-tiling-x-planes-%d" , + kmstest_pipe_name(pipe), max_planes) + test_plane_position(data, pipe, max_planes,
LOCAL_I915_FORMAT_MOD_X_TILED);tests/kms_plane_multiple.c new file +4
-0+ +igt_subtest_f ("atomic-pipe-%s-tiling-x-planes-%d" , + kmstest_pipe_name(pipe), max_planes) + test_plane_position(data, pipe, max_planes,
LOCAL_I915_FORMAT_MOD_X_TILED);tests/kms_plane_multiple.c new file +4
-0+ +igt_subtest_f ("legacy-pipe-%s-tiling-y-planes-%d" , + kmstest_pipe_name(pipe), max_planes) + test_plane_position(data, pipe, max_planes,
LOCAL_I915_FORMAT_MOD_Y_TILED);tests/kms_plane_multiple.c new file +4
-0+ +igt_subtest_f ("atomic-pipe-%s-tiling-y-planes-%d" , + kmstest_pipe_name(pipe), max_planes) + test_plane_position(data, pipe, max_planes,
LOCAL_I915_FORMAT_MOD_Y_TILED);tests/kms_plane_multiple.c new file +4
-0+ +igt_subtest_f ("legacy-pipe-%s-tiling-yf-planes-%d" , + kmstest_pipe_name(pipe), max_planes) + test_plane_position(data, pipe, max_planes,
LOCAL_I915_FORMAT_MOD_Yf_TILED);tests/kms_plane_multiple.c new file +4
-0+ +igt_subtest_f ("atomic-pipe-%s-tiling-yf-planes-%d" , + kmstest_pipe_name(pipe), max_planes) + test_plane_position(data, pipe, max_planes,
LOCAL_I915_FORMAT_MOD_Yf_TILED);tests/kms_plane_multiple.c new file +16
-0+} + +static void +run_tests_for_pipe (data_t *data,enum pipe pipe) +{ +for (int planes =1 ; planes <IGT_MAX_PLANES ; planes++) +run_tests_for_pipe_plane (data, pipe, planes); +} + +static data_t data; + +static int opt_handler (int option,int option_index,void *input) +{ +switch (option) { +case 'i' : + opt.iterations = IN_RANGE(strtol(optarg, NULL, 0),1, 256);
tests/kms_plane_multiple.c new file +18
-0+break ; +case 's' : + opt.user_seed = true; + opt.seed =strtol (optarg,NULL ,0 ); +break ; +case 'l' : + opt.user_logfile = true; +strcpy (opt.logfile, optarg); +break ; +default : +igt_assert (false); + } + +return 0 ; +} + +const char *help_str = + " --iterations Number of iterations for test coverage.min 1, max 256, default 16 iterations \n"
tests/kms_plane_multiple.c new file +2
-0+" --seed Seed for random number generator\n" + " --logfile Logfile to store seeds for random numbergenerator, default 'kms_plane_multiple.log'\n";
tests/kms_plane_multiple.c new file +14
-0+ +int main (int argc,char *argv[]) +{ +time_t t =time (NULL ); +struct tm tm = *localtime (&t); + +struct option long_options[] = { + {"iterations" , required_argument,NULL ,'i' }, + { "seed", required_argument, NULL, 's'}, + {"logfile" , required_argument,NULL ,'l' }, + {0 ,0 ,0 ,0 } + }; + + igt_subtest_init_parse_opts(&argc, argv, "", long_options,
help_str,tests/kms_plane_multiple.c new file +4
-0+ opt_handler, NULL); + +if (!opt.user_logfile) + sprintf(opt.logfile, "kms_plane_multiple-%4d-%2d-%2d.log",
tests/kms_plane_multiple.c new file +1
-0+ tm.tm_year + 1900, tm.tm_mon + 1,tm.tm_mday);
tests/kms_plane_multiple.c new file +5
-0+ +igt_skip_on_simulation (); + + igt_fixture { + data.drm_fd =
drm_open_driver_master(DRIVER_INTEL);tests/kms_plane_multiple.c new file +16
-0+ +kmstest_set_vt_graphics_mode (); + +igt_require_pipe_crc (); +igt_display_init (&data.display, data.drm_fd); + } + +for (int pipe =0 ; pipe <I915_MAX_PIPES ; pipe++) +run_tests_for_pipe (&data, pipe); + + igt_fixture { +igt_display_fini (&data.display); + } + +igt_exit (); +}
Signature · 6 lines
Mika Kahola - Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx