PSR-SU test cases for cursor movement
v2 cover PSR-SU test cases for cursor movement
changes in v2:
-------------------
- add test case to validate PSR-SU w/ MPO + cursor move scenario
- refactoring the cursor PSR-SU test function to make it compatible to test/validate two scenarios:
1. static background + cursor movement
2. MPO + cursor movement
David Zhang (4):
tests/amdgpu/amd_psr: add helper to draw cursor pattern tests/amdgpu/amd_psr: set visual-confirm option required argument tests/amdgpu/amd_psr: add PSR-SU cursor movement test case tests/amdgpu/amd_psr: add PSR-SU test case for cursor move + MPO
scenario
tests/amdgpu/amd_psr.c | 167 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 166 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1
PATCH v2 1/4 tests/amdgpu/amd_psr: add helper to draw cursor pattern
[why & how]
For amdgpu PSR-SU validation, we'd create and test cursor update use case as well. To emulate a mouse-like cursor movement, we'd define a helper to draw a cursor pattern.
- helper draw the cursor pattern as an 45-degrees rotated arrow
- for the region of arrow, set alpha to 1 to make cursor foreground and always on the top
- for rest of the non-arrow region, set alpha to 0 to make it as background
--- tests/amdgpu/amd_psr.c | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
tests/amdgpu/amd_psr.c +47 -0
@@ -81,6 +81,53 @@ static void draw_color_alpha(igt_fb_t *fb, int x, int y, int w, int h,igt_put_cairo_ctx (cr); } +/* draw a cursor pattern assuming the FB given is square w/ FORMAT ARGB */ +static void draw_color_cursor (igt_fb_t *fb,int size,double r,double g,double b) +{ +cairo_t *cr =igt_get_cairo_ctx (fb->fd, fb); +int x, y, line_w; + +cairo_set_operator (cr,CAIRO_OPERATOR_SOURCE ); + +/* +* draw cursor +* recall that alpha blending value: +* - 0, output pixel is the background +* - 1, output pixel is simply the foreground +* - (0, 1), mix of background + foreground +*/ + +/* set cursor FB to background first */ +igt_paint_color_alpha (cr,0 ,0 , size, size,1.0 ,1.0 ,1.0 ,.0 ); + +/* +* draw cursur pattern w/ alpha set to 1 +* - 1. draw triangle part +* - 2. draw rectangle part +*/ +for (x = y =0 , line_w = size /2 ; line_w >0 ; ++y, --line_w) +igt_paint_color_alpha (cr, x, y, line_w,1 , r, g, b,1.0 ); + +/* +* draw rectangle part, split into three geometry parts +* - triangle +* - rhombus +* - reversed triangle +*/ +for (x = size *3 /8 , y = size /8 , line_w =1 ; y < size *3 /8 ; --x, ++y, line_w +=2 ) +igt_paint_color_alpha (cr, x, y, line_w,1 , r, g, b,1.0 ); + +for (x = size /8 , y = size *3 /8 ; y < size *3 /4 ; ++x, ++y) +igt_paint_color_alpha (cr, x, y, line_w,1 , r, g, b,1.0 ); + +for (; line_w >0 ; ++x, ++y, line_w -=2 ) +igt_paint_color_alpha (cr, x, y, line_w,1 , r, g, b,1.0 ); + +cairo_set_operator (cr,CAIRO_OPERATOR_OVER ); + +igt_put_cairo_ctx (cr); +} +/* Common test setup. */ static void test_init (data_t *data) {
Signature · 1 line
2.25.1
PATCH v2 2/4 tests/amdgpu/amd_psr: set visual-confirm option required argument
In reply to David Zhang[why & how]
previously set to optional argument, and the command line argument set for visual confirm debug option would cause NULL optarg string and thus hit system segmentation fault.
set the "visual-confirm" from optional to required argument.
--- tests/amdgpu/amd_psr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/amdgpu/amd_psr.c +1 -1
@@ -474,7 +474,7 @@ const char *help_str =" --visual-confirm PSR visual confirm debug option enable\n" ;struct option long_options[] = { - {"visual-confirm" , optional_argument,NULL ,'v' }, + {"visual-confirm" , required_argument,NULL ,'v' }, {0 ,0 ,0 ,0 } };
Signature · 1 line
2.25.1
PATCH v2 3/4 tests/amdgpu/amd_psr: add PSR-SU cursor movement test case
In reply to David Zhang[why]
We'd have a test case to validate PSR-SU enablement and selective region update when cursor movement occurs by visual confirm. This is to emulate the scenario of usermode behavior that only the cursor is moving on top of the static screen.
[how]
create overlay plane w/ screen size and primary plane w/ quarter of screen size and positioned at the top-left of screen. create a cursor plane w/ size of (currently set to) 128 pixels.
move the cursor plane along horizonal/vertical/diagonal three directions w/ the incremental step of 16 pixels for a couple of seconds to allow visual confirm of PSR-SU update.
--- tests/amdgpu/amd_psr.c | 106 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+)
tests/amdgpu/amd_psr.c +106 -0
@@ -63,6 +63,13 @@ typedef struct data {int h; } data_t; +enum cursor_move { +HORIZONTAL , +VERTICAL , +DIAGONAL , +INVALID +}; +struct {bool visual_confirm; } opt = {
@@ -470,6 +477,101 @@ static void run_check_psr_su_ffu(data_t *data)test_fini (data); } +static void test_cursor_movement (data_t *data,int iters,igt_fb_t * pfb,int cs_size,enum cursor_move move_type) +{ +int i, pos_x, pos_y; +int ret; + +/* incremental step == cursor size / 16 */ +for (i =0 , pos_y =0 , pos_x =0 ; i < iters; ++i) { +if (move_type ==HORIZONTAL && (pos_x + cs_size > data->w)) + pos_x =0 ; +else if (move_type ==VERTICAL && (pos_y + cs_size > data->h)) + pos_y =0 ; +else if (move_type ==DIAGONAL && ((pos_y + cs_size > data->h) || (pos_x + cs_size > data->w))) + pos_x = pos_y =0 ; + +igt_plane_set_position (data->cursor, pos_x, pos_y); +igt_plane_set_fb (data->primary, pfb); + + ret =igt_display_try_commit_atomic (&data->display,DRM_MODE_PAGE_FLIP_EVENT ,NULL ); +igt_require (ret ==0 ); +kmstest_wait_for_pageflip (data->fd); + +/* update position */ +if (move_type ==HORIZONTAL ) + pos_x += cs_size /16 ; +else if (move_type ==VERTICAL ) + pos_y += cs_size /16 ; +else if (move_type ==DIAGONAL ) { + pos_x += cs_size /16 ; + pos_y += cs_size /16 ; + } + } +} + +static void run_check_psr_su_cursor (data_t *data) +{ +int edp_idx =check_conn_type (data, DRM_MODE_CONNECTOR_eDP); +igt_fb_t rect_fb;// primary FB +igt_fb_t cs_fb;// cursor FB +const int cs_size =128 ; +const int delay_sec =5 ;// seconds +int frame_rate =0 ; +int pb_w, pb_h, ob_w, ob_h; + +igt_skip_on_f (edp_idx ==-1 ,"no eDP connector found\n" ); + +test_init (data); +igt_skip_on (!psr_su_supported (data)); + + ob_w = data->w; + ob_h = data->h; + pb_w = data->w /2 ; + pb_h = data->h /2 ; + frame_rate = data->mode->vrefresh; + +/* primary & overlay FB creation and set alpha region of overlay to show */ +igt_create_color_fb (data->fd, pb_w, pb_h,DRM_FORMAT_XRGB8888 ,DRM_FORMAT_MOD_LINEAR , +.0 ,.0 ,1.0 , &rect_fb); +igt_create_color_fb (data->fd, ob_w, ob_h,DRM_FORMAT_ARGB8888 ,DRM_FORMAT_MOD_LINEAR , +1.0 ,1.0 ,1.0 , &data->ov_fb[0 ]); +draw_color_alpha (&data->ov_fb[0 ],0 ,0 , pb_w, pb_h,1.0 ,1.0 ,1.0 ,.0 ); + +/* cursor FB creation, draw cursor pattern/set alpha regions */ +igt_create_fb (data->fd, cs_size, cs_size,DRM_FORMAT_ARGB8888 ,DRM_FORMAT_MOD_LINEAR , &cs_fb); +draw_color_cursor (&cs_fb, cs_size,1.0 ,.0 ,1.0 ); + +igt_plane_set_fb (data->primary, &rect_fb); +igt_plane_set_fb (data->overlay, &data->ov_fb[0 ]); +igt_plane_set_fb (data->cursor, &cs_fb); +igt_plane_set_position (data->cursor,0 ,0 ); + +igt_output_set_pipe (data->output, data->pipe_id); +igt_display_commit_atomic (&data->display,DRM_MODE_ATOMIC_ALLOW_MODESET ,NULL ); + +/* +* test by setting different cursor position in screen +* - horizontal movement +* - vertial movement +* - diagonal movement +*/ + +/* horizontal */ +test_cursor_movement (data, frame_rate * delay_sec, &rect_fb, cs_size,HORIZONTAL ); + +/* vertical */ +test_cursor_movement (data, frame_rate * delay_sec, &rect_fb, cs_size,VERTICAL ); + +/* diagonal */ +test_cursor_movement (data, frame_rate * delay_sec, &rect_fb, cs_size,DIAGONAL ); + +igt_remove_fb (data->fd, &rect_fb); +igt_remove_fb (data->fd, &cs_fb); +igt_remove_fb (data->fd, &data->ov_fb[0 ]); +test_fini (data); +} +const char *help_str =" --visual-confirm PSR visual confirm debug option enable\n" ;
@@ -533,6 +635,10 @@ igt_main_args("", long_options, help_str, opt_handler, NULL) "and to validate Full Frame Update scenario"); igt_subtest("psr_su_ffu") run_check_psr_su_ffu(&data); +igt_describe ("Test to validate PSR SU enablement with Visual Confirm " +"and to validate cursor movement + static background scenario" ); + igt_subtest("psr_su_cursor") run_check_psr_su_cursor(&data); + igt_fixture {if (opt.visual_confirm) {
Signature · 1 line
2.25.1
PATCH v2 4/4 tests/amdgpu/amd_psr: add PSR-SU test case for cursor move + MPO scenario
In reply to David Zhang[why & how]
Besides the static background + cursor movement, a more generic use case from usermode is MPO + cursor movement, e.g. a video stream is playing on screen and user moves the cursor randomly. We'd have a test case to validate PSR-SU enablement and SU region updates by visual confirm for MPO + cursor movement scenario.
Refactoring the function for static background + cursor movement test case by adding a flag indicating to test MPO or not. Adding primary FBs as member of data structure used in PSR-SU test cases.
For MPO + cursormovement test case, create two primary FBs w/ diff color and fix the position, and during iteration, flip the primary FB together w/ cursor positon update. By enabling visual confirm debug option, the equivalent dirty rectangle region fo SU update is the combination of the old cursor position, new cursor position, and the dirty rectangle for MPO plane. It is expected to observe a green bar on the right side of the screen with height of the combinated dirty rectangle.
--- tests/amdgpu/amd_psr.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)
tests/amdgpu/amd_psr.c +22 -10
@@ -55,6 +55,7 @@ typedef struct data {igt_pipe_t *pipe;igt_pipe_crc_t *pipe_crc;igt_fb_t ov_fb[2 ]; +igt_fb_t pm_fb[2 ];drmModeModeInfo *mode;enum pipe pipe_id;int fd;
@@ -477,10 +478,11 @@ static void run_check_psr_su_ffu(data_t *data)test_fini (data); } -static void test_cursor_movement (data_t *data,int iters,igt_fb_t * pfb,int cs_size,enum cursor_move move_type) +static void test_cursor_movement (data_t *data,int iters,int cs_size,enum cursor_move move_type,bool test_mpo) {int i, pos_x, pos_y;int ret; +igt_fb_t *pfb;/* incremental step == cursor size / 16 */ for (i =0 , pos_y =0 , pos_x =0 ; i < iters; ++i) {
@@ -491,7 +493,11 @@ static void test_cursor_movement(data_t *data, int iters, igt_fb_t * pfb, int cselse if (move_type ==DIAGONAL && ((pos_y + cs_size > data->h) || (pos_x + cs_size > data->w))) pos_x = pos_y =0 ; +/* move cursor */ igt_plane_set_position (data->cursor, pos_x, pos_y); + +/* flip primary FB if MPO flag set */ + pfb = test_mpo ? &data->pm_fb[i %2 ] : &data->pm_fb[0 ];igt_plane_set_fb (data->primary, pfb); ret =igt_display_try_commit_atomic (&data->display,DRM_MODE_PAGE_FLIP_EVENT ,NULL );
@@ -510,10 +516,9 @@ static void test_cursor_movement(data_t *data, int iters, igt_fb_t * pfb, int cs } } -static void run_check_psr_su_cursor (data_t *data) +static void run_check_psr_su_cursor (data_t *data,bool test_mpo) {int edp_idx =check_conn_type (data, DRM_MODE_CONNECTOR_eDP); -igt_fb_t rect_fb;// primary FB igt_fb_t cs_fb;// cursor FB const int cs_size =128 ;const int delay_sec =5 ;// seconds
@@ -533,7 +538,9 @@ static void run_check_psr_su_cursor(data_t *data)/* primary & overlay FB creation and set alpha region of overlay to show */ igt_create_color_fb (data->fd, pb_w, pb_h,DRM_FORMAT_XRGB8888 ,DRM_FORMAT_MOD_LINEAR , -.0 ,.0 ,1.0 , &rect_fb); +.0 ,.0 ,1.0 , &data->pm_fb[0 ]); +igt_create_color_fb (data->fd, pb_w, pb_h,DRM_FORMAT_XRGB8888 ,DRM_FORMAT_MOD_LINEAR , +.0 ,1.0 ,.0 , &data->pm_fb[1 ]);igt_create_color_fb (data->fd, ob_w, ob_h,DRM_FORMAT_ARGB8888 ,DRM_FORMAT_MOD_LINEAR ,1.0 ,1.0 ,1.0 , &data->ov_fb[0 ]);draw_color_alpha (&data->ov_fb[0 ],0 ,0 , pb_w, pb_h,1.0 ,1.0 ,1.0 ,.0 );
@@ -542,7 +549,7 @@ static void run_check_psr_su_cursor(data_t *data)igt_create_fb (data->fd, cs_size, cs_size,DRM_FORMAT_ARGB8888 ,DRM_FORMAT_MOD_LINEAR , &cs_fb);draw_color_cursor (&cs_fb, cs_size,1.0 ,.0 ,1.0 ); -igt_plane_set_fb (data->primary, &rect_fb); +igt_plane_set_fb (data->primary, &data->pm_fb[0 ]);igt_plane_set_fb (data->overlay, &data->ov_fb[0 ]);igt_plane_set_fb (data->cursor, &cs_fb);igt_plane_set_position (data->cursor,0 ,0 );
@@ -558,15 +565,16 @@ static void run_check_psr_su_cursor(data_t *data)*/ /* horizontal */ -test_cursor_movement (data, frame_rate * delay_sec, &rect_fb, cs_size,HORIZONTAL ); +test_cursor_movement (data, frame_rate * delay_sec, cs_size,HORIZONTAL , test_mpo);/* vertical */ -test_cursor_movement (data, frame_rate * delay_sec, &rect_fb, cs_size,VERTICAL ); +test_cursor_movement (data, frame_rate * delay_sec, cs_size,VERTICAL , test_mpo);/* diagonal */ -test_cursor_movement (data, frame_rate * delay_sec, &rect_fb, cs_size,DIAGONAL ); +test_cursor_movement (data, frame_rate * delay_sec, cs_size,DIAGONAL , test_mpo); -igt_remove_fb (data->fd, &rect_fb); +igt_remove_fb (data->fd, &data->pm_fb[0 ]); +igt_remove_fb (data->fd, &data->pm_fb[1 ]);igt_remove_fb (data->fd, &cs_fb);igt_remove_fb (data->fd, &data->ov_fb[0 ]);test_fini (data);
@@ -637,7 +645,11 @@ igt_main_args("", long_options, help_str, opt_handler, NULL)igt_describe ("Test to validate PSR SU enablement with Visual Confirm " "and to validate cursor movement + static background scenario" ); - igt_subtest("psr_su_cursor") run_check_psr_su_cursor(&data); + igt_subtest("psr_su_cursor") run_check_psr_su_cursor(&data, false); + +igt_describe ("Test to validate PSR SU enablement with Visual Confirm " +"and to validate cursor movement + MPO scenario" ); + igt_subtest("psr_su_cursor_mpo") run_check_psr_su_cursor(&data, true); igt_fixture {
Signature · 1 line
2.25.1
Patchwork
CI[igt-dev] ✗ Fi.CI.BUILD: failure for PSR-SU test cases for cursor movement
In reply to David Zhang== Series Details ==
== Series Details ==
Series: PSR-SU test cases for cursor movement
URL : https://patchwork.freedesktop.org/series/102674/
State : failure
== Summary ==
Applying: tests/amdgpu/amd_psr: add helper to draw cursor pattern
Applying: tests/amdgpu/amd_psr: set visual-confirm option required argument Patch failed at 0002 tests/amdgpu/amd_psr: set visual-confirm option required argument When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".