lib/igt_kms: Rewrite property handling to better match atomic.
cover lib/igt_kms: Rewrite property handling to better match atomic.
The future is atomic!
Currently when we add new properties, each one requires new API to be added, even though the core wouldn't have to know anything about it. This can easily be fixed by making everything a property, and having the core functions handle some properties like fb and position separately.
Even with this in place it still makes sense to allow direct control of properties, so add some new API to allow this manipulation. How powerful it is can be seen in kms_atomic, which can finally be rewritten to use the new api.
We also extend the legacy paths to handle custom properties, so any tests aren't required to use the atomic api.
Maarten Lankhorst (12):
lib/igt_kms: Rework connector properties to be more atomic, v2. lib/igt_kms: Rework plane properties to be more atomic, v5. lib/igt_kms: Rework pipe properties to be more atomic, v7. lib/igt_kms: Allow setting any plane property through the universal
path
lib/igt_kms: Allow setting any output property through the !atomic
paths
lib/igt_kms: Export property blob functions for output/pipe/plane lib/igt_kms: Unexport broadcast rgb API.
lib/igt_kms: Add igt_$obj_has_prop functions
lib/igt_kms: Add igt_$obj_get_prop functions tests/kms_color: Rework tests slightly to work better with new atomic
api
lib/igt_kms: Remove igt_pipe_get_property tests/kms_atomic: Convert/rewrite tests to use igt_kms framework
lib/igt_kms.c | 878 ++++++++++--------- lib/igt_kms.h | 266 +++--- tests/chamelium.c | 3 - tests/kms_atomic.c | 1668 ++++++++++++------------------------- tests/kms_atomic_interruptible.c | 24 +- tests/kms_atomic_transition.c | 2 +- tests/kms_color.c | 229 ++--- tests/kms_crtc_background_color.c | 2 +- tests/kms_panel_fitting.c | 2 +- tests/kms_rotation_crc.c | 10 +- 10 files changed, 1278 insertions(+), 1806 deletions(-)
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/12 lib/igt_kms: Rework connector properties to be more atomic, v2.
In the future I want to allow tests to commit more properties, but for this to work I have to fix all properties to work better with atomic commit. Instead of special casing each property make a bitmask for all property changed flags, and try to commit all properties.
Changs since v1:
- Mention which properties we set to what.
- Assert the property to be set is valid.
--- lib/igt_kms.c | 44 +++++++++++++++++++--------------------- lib/igt_kms.h | 35 +++++++++++++++++++------------- tests/kms_atomic_interruptible.c | 4 ++-- tests/kms_panel_fitting.c | 2 +- 4 files changed, 45 insertions(+), 40 deletions(-)
lib/igt_kms.c +21 -23
@@ -248,7 +248,7 @@ igt_atomic_fill_connector_props(igt_display_t *display, igt_output_t *output,if (strcmp (prop->name, conn_prop_names[j]) !=0 )continue ; - output->config.atomic_props_connector[j] = props->props[i]; + output->props[j] = props->props[i];break ; }
@@ -1834,7 +1834,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)igt_output_refresh (output); - output->config.pipe_changed = true; +igt_output_set_prop_changed (output,IGT_CONNECTOR_CRTC_ID ); }drmModeFreePlaneResources (plane_resources);
@@ -2514,23 +2514,24 @@ static void igt_atomic_prepare_crtc_commit(igt_pipe_t *pipe_obj, drmModeAtomicRestatic void igt_atomic_prepare_connector_commit (igt_output_t *output,drmModeAtomicReq *req) { -struct kmstest_connector_config *config = &output->config; +int i; -if (config->connector_scaling_mode_changed) -igt_atomic_populate_connector_req (req, output,IGT_CONNECTOR_SCALING_MODE , config->connector_scaling_mode); +for (i =0 ; i <IGT_NUM_CONNECTOR_PROPS ; i++) { +if (!igt_output_is_prop_changed (output, i)) +continue ; -if (config->pipe_changed) { -uint32_t crtc_id =0 ; +/* it's an error to try an unsupported feature */ +igt_assert (output->props[i]); -if (output->config.pipe !=PIPE_NONE ) - crtc_id = output->config.crtc->crtc_id; +igt_debug ("%s: Setting property \"%s\" to 0x%" PRIx64"/%" PRIi64"\n" , +igt_output_name (output), igt_connector_prop_names[i], + output->values[i], output->values[i]); -igt_atomic_populate_connector_req (req, output,IGT_CONNECTOR_CRTC_ID , crtc_id); +igt_assert_lt (0 ,drmModeAtomicAddProperty (req, + output->config.connector->connector_id, + output->props[i], + output->values[i])); } -/* -* TODO: Add all other connector level properties here -*/ - }/*
@@ -2625,11 +2626,10 @@ display_commit_changed(igt_display_t *display, enum igt_commit_style s)for (i =0 ; i < display->n_outputs; i++) {igt_output_t *output = &display->outputs[i]; -if (s !=COMMIT_UNIVERSAL ) - output->config.pipe_changed = false; -if (s ==COMMIT_ATOMIC ) - output->config.connector_scaling_mode_changed = false; + output->changed =0 ; +else if (s !=COMMIT_UNIVERSAL ) +igt_output_clear_prop_changed (output,IGT_CONNECTOR_CRTC_ID ); } }
@@ -2873,18 +2873,16 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe)if (pipe !=PIPE_NONE ) display->pipes[pipe].mode_changed = true; - output->config.pipe_changed = true; +igt_output_set_prop_value (output,IGT_CONNECTOR_CRTC_ID , pipe ==PIPE_NONE ?0 : display->pipes[pipe].crtc_id);igt_output_refresh (output); }void igt_output_set_scaling_mode (igt_output_t *output,uint64_t scaling_mode) { - output->config.connector_scaling_mode_changed = true; - - output->config.connector_scaling_mode = scaling_mode; +igt_output_set_prop_value (output,IGT_CONNECTOR_SCALING_MODE , scaling_mode); -igt_require (output->config.atomic_props_connector[IGT_CONNECTOR_SCALING_MODE ]); +igt_require (output->props[IGT_CONNECTOR_SCALING_MODE ]); }igt_plane_t *igt_output_get_plane (igt_output_t *output,int plane_idx)
lib/igt_kms.h +21 -14
@@ -131,10 +131,7 @@ struct kmstest_connector_config {drmModeConnector *connector;drmModeEncoder *encoder;drmModeModeInfo default_mode; -uint64_t connector_scaling_mode; -bool connector_scaling_mode_changed; -bool pipe_changed; -uint32_t atomic_props_connector[IGT_NUM_CONNECTOR_PROPS ]; +int pipe;unsigned valid_crtc_idx_mask; };
@@ -364,6 +361,12 @@ typedef struct {enum pipe pending_pipe;bool use_override_mode;drmModeModeInfo override_mode; + +/* bitmask of changed properties */ +uint64_t changed; + +uint32_t props[IGT_NUM_CONNECTOR_PROPS ]; +uint64_t values[IGT_NUM_CONNECTOR_PROPS ]; } igt_output_t;struct igt_display {
@@ -545,16 +548,20 @@ static inline bool igt_output_is_connected(igt_output_t *output)#define igt_atomic_populate_crtc_req (req, pipe, prop, value) \ igt_assert_lt(0, drmModeAtomicAddProperty(req, pipe->crtc_id,\ pipe->atomic_props_crtc[prop], value)) -/** -* igt_atomic_populate_connector_req: -* @req: A pointer to drmModeAtomicReq -* @output: A pointer igt_output_t -* @prop: one of igt_atomic_connector_properties -* @value: the value to add -*/ -#define igt_atomic_populate_connector_req (req, output, prop, value) \ - igt_assert_lt(0, drmModeAtomicAddProperty(req, output->config.connector->connector_id,\ - output->config.atomic_props_connector[prop], value)) + +#define igt_output_is_prop_changed (output, prop) \ + (!!((output)->changed & (1 << (prop)))) +#define igt_output_set_prop_changed (output, prop) \ + (output)->changed |= 1 << (prop) + +#define igt_output_clear_prop_changed (output, prop) \ + (output)->changed &= ~(1 << (prop)) + +#define igt_output_set_prop_value (output, prop, value) \ + do { \ + (output)->values[prop] = (value); \ + igt_output_set_prop_changed(output, prop); \ + } while (0)/* * igt_pipe_refresh:
tests/kms_atomic_interruptible.c +2 -2
@@ -161,7 +161,7 @@ static void run_plane_test(igt_display_t *display, enum pipe pipe, igt_output_t plane->pipe->atomic_props_crtc[IGT_CRTC_MODE_ID ], plane->pipe->atomic_props_crtc[IGT_CRTC_ACTIVE ],/* connector: 1 prop */ - output->config.atomic_props_connector[IGT_CONNECTOR_CRTC_ID ], + output->props[IGT_CONNECTOR_CRTC_ID ],/* plane: remainder props */ plane->atomic_props_plane[IGT_PLANE_CRTC_ID ], plane->atomic_props_plane[IGT_PLANE_FB_ID],
@@ -206,7 +206,7 @@ static void run_plane_test(igt_display_t *display, enum pipe pipe, igt_output_tcase test_legacy_dpms: {struct drm_mode_connector_set_property prop = { .value =DRM_MODE_DPMS_OFF , - .prop_id = output->config.atomic_props_connector[IGT_CONNECTOR_DPMS ], + .prop_id = output->props[IGT_CONNECTOR_DPMS ], .connector_id = output->id, };
tests/kms_panel_fitting.c +1 -1
@@ -275,7 +275,7 @@ static void test_atomic_fastset(igt_display_t *display)igt_require (intel_gen (intel_get_drm_devid (display->drm_fd)) >=5 );for_each_pipe_with_valid_output (display, pipe, output) { -if (!output->config.atomic_props_connector[IGT_CONNECTOR_SCALING_MODE ]) +if (!output->props[IGT_CONNECTOR_SCALING_MODE ])continue ;test_panel_fitting_fastset (display, pipe, output);
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/12 lib/igt_kms: Rework plane properties to be more atomic, v5.
In reply to Maarten LankhorstIn the future I want to allow tests to commit more properties, but for this to work I have to fix all properties to work better with atomic commit. Instead of special casing each property make a bitmask for all property changed flags, and try to commit all properties.
Changes since v1:
- Remove special dumping of src and crtc coordinates.
- Dump all modified coordinates.
Changes since v2:
- Move igt_plane_set_prop_changed up slightly.
Changes since v3:
- Fix wrong ordering of set_position in kms_plane_lowres causing a test failure. Changes since v4:
- Back out resetting crtc position in igt_plane_set_fb() and document it during init. Tests appear to rely on it being preserved.
--- lib/igt_kms.c | 299 +++++++++++++++++---------------------- lib/igt_kms.h | 59 ++++---- tests/kms_atomic_interruptible.c | 12 +- tests/kms_rotation_crc.c | 4 +- 4 files changed, 165 insertions(+), 209 deletions(-)
lib/igt_kms.c +133 -166
@@ -192,11 +192,11 @@ const char *igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {/* * Retrieve all the properies specified in props_name and store them into -* plane->atomic_props_plane. +* plane->props. */ static void -igt_atomic_fill_plane_props (igt_display_t *display,igt_plane_t *plane, -int num_props,const char **prop_names) +igt_fill_plane_props (igt_display_t *display,igt_plane_t *plane, +int num_props,const char **prop_names) {drmModeObjectPropertiesPtr props;int i, j, fd;
@@ -214,7 +214,7 @@ igt_atomic_fill_plane_props(igt_display_t *display, igt_plane_t *plane,if (strcmp (prop->name, prop_names[j]) !=0 )continue ; - plane->atomic_props_plane[j] = props->props[i]; + plane->props[j] = props->props[i];break ; }
@@ -1659,7 +1659,6 @@ void igt_display_init(igt_display_t *display, int drm_fd)drmModeRes *resources;drmModePlaneRes *plane_resources;int i; -int is_atomic =0 ;memset (display,0 ,sizeof (igt_display_t));
@@ -1679,7 +1678,9 @@ void igt_display_init(igt_display_t *display, int drm_fd)igt_assert_f (display->pipes,"Failed to allocate memory for %d pipes\n" , display->n_pipes);drmSetClientCap (drm_fd,DRM_CLIENT_CAP_UNIVERSAL_PLANES ,1 ); - is_atomic =drmSetClientCap (drm_fd,DRM_CLIENT_CAP_ATOMIC ,1 ); +if (drmSetClientCap (drm_fd,DRM_CLIENT_CAP_ATOMIC ,1 ) ==0 ) + display->is_atomic =1 ; + plane_resources =drmModeGetPlaneResources (display->drm_fd);igt_assert (plane_resources);
@@ -1776,19 +1777,27 @@ void igt_display_init(igt_display_t *display, int drm_fd) plane->type = type; plane->pipe = pipe; plane->drm_plane = drm_plane; - plane->fence_fd =-1 ; + plane->values[IGT_PLANE_IN_FENCE_FD ] = ~0ULL ; -if (is_atomic ==0 ) { - display->is_atomic =1 ; -igt_atomic_fill_plane_props (display, plane,IGT_NUM_PLANE_PROPS , igt_plane_prop_names); - } +igt_fill_plane_props (display, plane,IGT_NUM_PLANE_PROPS , igt_plane_prop_names);get_plane_property (display->drm_fd, drm_plane->plane_id,"rotation" , - &plane->rotation_property, - &prop_value, + &plane->props[IGT_PLANE_ROTATION ], + &plane->values[IGT_PLANE_ROTATION ],NULL ); - plane->rotation = (igt_rotation_t )prop_value; + +/* Clear any residual framebuffer info on first commit. */ +igt_plane_set_prop_changed (plane,IGT_PLANE_FB_ID ); +igt_plane_set_prop_changed (plane,IGT_PLANE_CRTC_ID ); + +/* +* CRTC_X/Y are not changed in igt_plane_set_fb, so +* force them to be sanitized in case they contain +* garbage. +*/ +igt_plane_set_prop_changed (plane,IGT_PLANE_CRTC_X ); +igt_plane_set_prop_changed (plane,IGT_PLANE_CRTC_Y ); }/*
@@ -1805,9 +1814,6 @@ void igt_display_init(igt_display_t *display, int drm_fd) pipe->n_planes = n_planes; -for_each_plane_on_pipe (display, i, plane) - plane->fb_changed = true; - pipe->mode_changed = true; }
@@ -2070,18 +2076,7 @@ bool igt_pipe_get_property(igt_pipe_t *pipe, const char *name,static uint32_t igt_plane_get_fb_id (igt_plane_t *plane) { -if (plane->fb) -return plane->fb->fb_id; -else -return 0 ; -} - -static uint32_t igt_plane_get_fb_gem_handle (igt_plane_t *plane) -{ -if (plane->fb) -return plane->fb->gem_handle; -else -return 0 ; +return plane->values[IGT_PLANE_FB_ID ]; }#define CHECK_RETURN (r, fail) { \
@@ -2090,9 +2085,6 @@ static uint32_t igt_plane_get_fb_gem_handle(igt_plane_t *plane)igt_assert_eq (r,0 ); \ } - - -/* * Add position and fb changes of a plane to the atomic property set */
@@ -2101,63 +2093,31 @@ igt_atomic_prepare_plane_commit(igt_plane_t *plane, igt_pipe_t *pipe, drmModeAtomicReq *req) {igt_display_t *display = pipe->display; -uint32_t fb_id, crtc_id; +int i;igt_assert (plane->drm_plane); -/* it's an error to try an unsupported feature */ -igt_assert (igt_plane_supports_rotation (plane) || - !plane->rotation_changed); - - fb_id =igt_plane_get_fb_id (plane); - crtc_id = pipe->crtc_id; -LOG (display,"populating plane data: %s.%d, fb %u\n" ,kmstest_pipe_name (pipe->pipe), plane->index, - fb_id); - -if (plane->fence_fd >=0 ) { -uint64_t fence_fd = (int64_t ) plane->fence_fd; -igt_atomic_populate_plane_req (req, plane,IGT_PLANE_IN_FENCE_FD , fence_fd); - } +igt_plane_get_fb_id (plane)); -if (plane->fb_changed) { -igt_atomic_populate_plane_req (req, plane,IGT_PLANE_CRTC_ID , fb_id ? crtc_id :0 ); -igt_atomic_populate_plane_req (req, plane,IGT_PLANE_FB_ID , fb_id); - } - -if (plane->position_changed || plane->size_changed) { -uint32_t src_x =IGT_FIXED (plane->src_x,0 );/* src_x */ -uint32_t src_y =IGT_FIXED (plane->src_y,0 );/* src_y */ -uint32_t src_w =IGT_FIXED (plane->src_w,0 );/* src_w */ -uint32_t src_h =IGT_FIXED (plane->src_h,0 );/* src_h */ -int32_t crtc_x = plane->crtc_x; -int32_t crtc_y = plane->crtc_y; -uint32_t crtc_w = plane->crtc_w; -uint32_t crtc_h = plane->crtc_h; +for (i =0 ; i <IGT_NUM_PLANE_PROPS ; i++) { +if (!igt_plane_is_prop_changed (plane, i)) +continue ; -LOG (display, -"src = (%d, %d) %u x %u " -"dst = (%d, %d) %u x %u\n" , - src_x >>16 , src_y >>16 , src_w >>16 , src_h >>16 , - crtc_x, crtc_y, crtc_w, crtc_h); +/* it's an error to try an unsupported feature */ +igt_assert (plane->props[i]); -igt_atomic_populate_plane_req (req, plane,IGT_PLANE_SRC_X , src_x); -igt_atomic_populate_plane_req (req, plane,IGT_PLANE_SRC_Y , src_y); -igt_atomic_populate_plane_req (req, plane,IGT_PLANE_SRC_W , src_w); -igt_atomic_populate_plane_req (req, plane,IGT_PLANE_SRC_H , src_h); +igt_debug ("plane %s.%d: Setting property \"%s\" to 0x%" PRIx64"/%" PRIi64"\n" , +kmstest_pipe_name (pipe->pipe), plane->index, igt_plane_prop_names[i], + plane->values[i], plane->values[i]); -igt_atomic_populate_plane_req (req, plane,IGT_PLANE_CRTC_X , crtc_x); -igt_atomic_populate_plane_req (req, plane,IGT_PLANE_CRTC_Y , crtc_y); -igt_atomic_populate_plane_req (req, plane,IGT_PLANE_CRTC_W , crtc_w); -igt_atomic_populate_plane_req (req, plane,IGT_PLANE_CRTC_H , crtc_h); +igt_assert_lt (0 ,drmModeAtomicAddProperty (req, plane->drm_plane->plane_id, + plane->props[i], + plane->values[i])); } - -if (plane->rotation_changed) -igt_atomic_populate_plane_req (req, plane, -IGT_PLANE_ROTATION , plane->rotation); }
@@ -2183,17 +2143,20 @@ static int igt_drm_plane_commit(igt_plane_t *plane,int32_t crtc_y;uint32_t crtc_w;uint32_t crtc_h; +bool setplane = +igt_plane_is_prop_changed (plane,IGT_PLANE_FB_ID ) || + plane->changed &IGT_PLANE_COORD_CHANGED_MASK ;igt_assert (plane->drm_plane);/* it's an error to try an unsupported feature */ igt_assert (igt_plane_supports_rotation (plane) || - !plane->rotation_changed); + !igt_plane_is_prop_changed (plane,IGT_PLANE_ROTATION )); fb_id =igt_plane_get_fb_id (plane); crtc_id = pipe->crtc_id; -if ((plane->fb_changed || plane->size_changed) && fb_id ==0 ) { +if (setplane && fb_id ==0 ) { LOG(display, "SetPlane pipe %s, plane %d, disabling\n", kmstest_pipe_name(pipe->pipe),
@@ -2212,16 +2175,15 @@ static int igt_drm_plane_commit(igt_plane_t *plane, IGT_FIXED(0,0) /* src_h */);CHECK_RETURN (ret, fail_on_error); - }else if (plane->fb_changed || plane->position_changed || - plane->size_changed) { - src_x =IGT_FIXED (plane->src_x,0 );/* src_x */ - src_y =IGT_FIXED (plane->src_y,0 );/* src_y */ - src_w =IGT_FIXED (plane->src_w,0 );/* src_w */ - src_h =IGT_FIXED (plane->src_h,0 );/* src_h */ - crtc_x = plane->crtc_x; - crtc_y = plane->crtc_y; - crtc_w = plane->crtc_w; - crtc_h = plane->crtc_h; + }else if (setplane) { + src_x = plane->values[IGT_PLANE_SRC_X ]; + src_y = plane->values[IGT_PLANE_SRC_Y ]; + src_w = plane->values[IGT_PLANE_SRC_W ]; + src_h = plane->values[IGT_PLANE_SRC_H ]; + crtc_x = plane->values[IGT_PLANE_CRTC_X ]; + crtc_y = plane->values[IGT_PLANE_CRTC_Y ]; + crtc_w = plane->values[IGT_PLANE_CRTC_W ]; + crtc_h = plane->values[IGT_PLANE_CRTC_H ];LOG (display, "SetPlane %s.%d, fb %u, src = (%d, %d) "
@@ -2245,9 +2207,10 @@ static int igt_drm_plane_commit(igt_plane_t *plane,CHECK_RETURN (ret, fail_on_error); } -if (plane->rotation_changed) { - ret =igt_plane_set_property (plane, plane->rotation_property, - plane->rotation); +if (igt_plane_is_prop_changed (plane,IGT_PLANE_ROTATION )) { + ret =igt_plane_set_property (plane, + plane->props[IGT_PLANE_ROTATION ], + plane->values[IGT_PLANE_ROTATION ]);CHECK_RETURN (ret, fail_on_error); }
@@ -2269,35 +2232,30 @@ static int igt_cursor_commit_legacy(igt_plane_t *cursor,uint32_t crtc_id = pipe->crtc_id;int ret; -if (cursor->fb_changed) { -uint32_t gem_handle =igt_plane_get_fb_gem_handle (cursor); - -if (gem_handle) { +if (igt_plane_is_prop_changed (cursor,IGT_PLANE_FB_ID )) { +if (cursor->gem_handle)LOG (display,"SetCursor pipe %s, fb %u %dx%d\n" ,kmstest_pipe_name (pipe->pipe), - gem_handle, - cursor->crtc_w, cursor->crtc_h); - - ret =drmModeSetCursor (display->drm_fd, crtc_id, - gem_handle, - cursor->crtc_w, - cursor->crtc_h); - }else { + cursor->gem_handle, + (unsigned )cursor->values[IGT_PLANE_CRTC_W ], + (unsigned )cursor->values[IGT_PLANE_CRTC_H ]); +else LOG (display,"SetCursor pipe %s, disabling\n" ,kmstest_pipe_name (pipe->pipe)); - ret =drmModeSetCursor (display->drm_fd, crtc_id, -0 ,0 ,0 ); - } - + ret =drmModeSetCursor (display->drm_fd, crtc_id, + cursor->gem_handle, + cursor->values[IGT_PLANE_CRTC_W ], + cursor->values[IGT_PLANE_CRTC_H ]);CHECK_RETURN (ret, fail_on_error); } -if (cursor->position_changed) { -int x = cursor->crtc_x; -int y = cursor->crtc_y; +if (igt_plane_is_prop_changed (cursor,IGT_PLANE_CRTC_X ) || +igt_plane_is_prop_changed (cursor,IGT_PLANE_CRTC_Y )) { +int x = cursor->values[IGT_PLANE_CRTC_X ]; +int y = cursor->values[IGT_PLANE_CRTC_Y ]; LOG(display, "MoveCursor pipe %s, (%d, %d)\n",
@@ -2326,13 +2284,14 @@ static int igt_primary_plane_commit_legacy(igt_plane_t *primary,int ret;/* Primary planes can't be windowed when using a legacy commit */ -igt_assert ((primary->crtc_x ==0 && primary->crtc_y ==0 )); +igt_assert ((primary->values[IGT_PLANE_CRTC_X ] ==0 && primary->values[IGT_PLANE_CRTC_Y ] ==0 ));/* nor rotated */ -igt_assert (!primary->rotation_changed); +igt_assert (!igt_plane_is_prop_changed (primary,IGT_PLANE_ROTATION )); -if (!primary->fb_changed && !primary->position_changed && - !primary->size_changed && !primary->pipe->mode_changed) +if (!igt_plane_is_prop_changed (primary,IGT_PLANE_FB_ID ) && + !(primary->changed &IGT_PLANE_COORD_CHANGED_MASK ) && + !primary->pipe->mode_changed)return 0 ; crtc_id = pipe->crtc_id;
@@ -2343,19 +2302,22 @@ static int igt_primary_plane_commit_legacy(igt_plane_t *primary, mode =NULL ;if (fb_id) { +uint32_t src_x = primary->values[IGT_PLANE_SRC_X ] >>16 ; +uint32_t src_y = primary->values[IGT_PLANE_SRC_Y ] >>16 ; +LOG (display,"%s: SetCrtc pipe %s, fb %u, src (%d, %d), " "mode %dx%d\n" ,igt_output_name (output),kmstest_pipe_name (pipe->pipe), fb_id, - primary->src_x, primary->src_y, + src_x, src_y, mode->hdisplay, mode->vdisplay); ret =drmModeSetCrtc (display->drm_fd, crtc_id, fb_id, - primary->src_x, primary->src_y, + src_x, src_y, &output->id,1 , mode);
@@ -2608,18 +2570,27 @@ display_commit_changed(igt_display_t *display, enum igt_commit_style s) }for_each_plane_on_pipe (display, pipe, plane) { - plane->fb_changed = false; - plane->position_changed = false; - plane->size_changed = false; +if (s ==COMMIT_ATOMIC ) { +int fd; + plane->changed =0 ; -if (s !=COMMIT_LEGACY || - !(plane->type ==DRM_PLANE_TYPE_PRIMARY || - plane->type ==DRM_PLANE_TYPE_CURSOR )) - plane->rotation_changed = false; + fd = plane->values[IGT_PLANE_IN_FENCE_FD ]; +if (fd !=-1 ) +close (fd); -if (s ==COMMIT_ATOMIC )/* reset fence_fd to prevent it from being set for the next commit */ -igt_plane_set_fence_fd (plane,-1 ); + plane->values[IGT_PLANE_IN_FENCE_FD ] =-1 ; + }else { + plane->changed &= ~IGT_PLANE_COORD_CHANGED_MASK ; + +igt_plane_clear_prop_changed (plane,IGT_PLANE_CRTC_ID ); +igt_plane_clear_prop_changed (plane,IGT_PLANE_FB_ID ); + +if (s !=COMMIT_LEGACY || + !(plane->type ==DRM_PLANE_TYPE_PRIMARY || + plane->type ==DRM_PLANE_TYPE_CURSOR )) +igt_plane_clear_prop_changed (plane,IGT_PLANE_ROTATION ); + } } }
@@ -2913,30 +2884,29 @@ void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb *fb)LOG (display,"%s.%d: plane_set_fb(%d)\n" ,kmstest_pipe_name (pipe->pipe), plane->index, fb ? fb->fb_id :0 ); - plane->fb = fb; +igt_plane_set_prop_value (plane,IGT_PLANE_CRTC_ID , fb ? pipe->crtc_id :0 ); +igt_plane_set_prop_value (plane,IGT_PLANE_FB_ID , fb ? fb->fb_id :0 ); + +if (plane->type ==DRM_PLANE_TYPE_CURSOR && fb) + plane->gem_handle = fb->gem_handle; +else + plane->gem_handle =0 ; +/* hack to keep tests working that don't call igt_plane_set_size() */ if (fb) {/* set default plane size as fb size */ - plane->crtc_w = fb->width; - plane->crtc_h = fb->height; +igt_plane_set_size (plane, fb->width, fb->height);/* set default src pos/size as fb size */ - plane->src_x =0 ; - plane->src_y =0 ; - plane->src_w = fb->width; - plane->src_h = fb->height; +igt_fb_set_position (fb, plane,0 ,0 ); +igt_fb_set_size (fb, plane, fb->width, fb->height); }else { - plane->src_x =0 ; - plane->src_y =0 ; - plane->src_w =0 ; - plane->src_h =0 ; +igt_plane_set_size (plane,0 ,0 ); - plane->crtc_w =0 ; - plane->crtc_h =0 ; +/* set default src pos/size as fb size */ +igt_fb_set_position (fb, plane,0 ,0 ); +igt_fb_set_size (fb, plane,0 ,0 ); } - - plane->fb_changed = true; - plane->size_changed = true; }/**
@@ -2949,12 +2919,19 @@ void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb *fb)*/ void igt_plane_set_fence_fd (igt_plane_t *plane,int fence_fd) { -close (plane->fence_fd); +int64_t fd; -if (fcntl (fence_fd,F_GETFD ) !=-1 ) - plane->fence_fd =dup (fence_fd); -else - plane->fence_fd =-1 ; + fd = plane->values[IGT_PLANE_IN_FENCE_FD ]; +if (fd !=-1 ) +close (fd); + +if (fence_fd !=-1 ) { + fd =dup (fence_fd); +igt_fail_on (fd ==-1 ); + }else + fd =-1 ; + +igt_plane_set_prop_value (plane,IGT_PLANE_IN_FENCE_FD , fd); }void igt_plane_set_position (igt_plane_t *plane,int x,int y)
@@ -2965,10 +2942,8 @@ void igt_plane_set_position(igt_plane_t *plane, int x, int y)LOG (display,"%s.%d: plane_set_position(%d,%d)\n" ,kmstest_pipe_name (pipe->pipe), plane->index, x, y); - plane->crtc_x = x; - plane->crtc_y = y; - - plane->position_changed = true; +igt_plane_set_prop_value (plane,IGT_PLANE_CRTC_X , x); +igt_plane_set_prop_value (plane,IGT_PLANE_CRTC_Y , y); }/**
@@ -2989,10 +2964,8 @@ void igt_plane_set_size(igt_plane_t *plane, int w, int h)LOG (display,"%s.%d: plane_set_size (%dx%d)\n" ,kmstest_pipe_name (pipe->pipe), plane->index, w, h); - plane->crtc_w = w; - plane->crtc_h = h; - - plane->size_changed = true; +igt_plane_set_prop_value (plane,IGT_PLANE_CRTC_W , w); +igt_plane_set_prop_value (plane,IGT_PLANE_CRTC_H , h); }/**
@@ -3014,10 +2987,8 @@ void igt_fb_set_position(struct igt_fb *fb, igt_plane_t *plane,LOG (display,"%s.%d: fb_set_position(%d,%d)\n" ,kmstest_pipe_name (pipe->pipe), plane->index, x, y); - plane->src_x = x; - plane->src_y = y; - - plane->fb_changed = true; +igt_plane_set_prop_value (plane,IGT_PLANE_SRC_X ,IGT_FIXED (x,0 )); +igt_plane_set_prop_value (plane,IGT_PLANE_SRC_Y ,IGT_FIXED (y,0 )); }/**
@@ -3040,10 +3011,8 @@ void igt_fb_set_size(struct igt_fb *fb, igt_plane_t *plane,LOG (display,"%s.%d: fb_set_size(%dx%d)\n" ,kmstest_pipe_name (pipe->pipe), plane->index, w, h); - plane->src_w = w; - plane->src_h = h; - - plane->fb_changed = true; +igt_plane_set_prop_value (plane,IGT_PLANE_SRC_W ,IGT_FIXED (w,0 )); +igt_plane_set_prop_value (plane,IGT_PLANE_SRC_H ,IGT_FIXED (h,0 )); }static const char *rotation_name (igt_rotation_t rotation)
@@ -3071,9 +3040,7 @@ void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation)kmstest_pipe_name (pipe->pipe), plane->index, rotation_name(rotation)); - plane->rotation = rotation; - - plane->rotation_changed = true; +igt_plane_set_prop_value (plane,IGT_PLANE_ROTATION , rotation); }/**
lib/igt_kms.h +24 -35
90 lines not on this page · raw message
tests/kms_atomic_interruptible.c +6 -6
@@ -163,12 +163,12 @@ static void run_plane_test(igt_display_t *display, enum pipe pipe, igt_output_t/* connector: 1 prop */ output->props[IGT_CONNECTOR_CRTC_ID ],/* plane: remainder props */ - plane->atomic_props_plane[IGT_PLANE_CRTC_ID ], - plane->atomic_props_plane[IGT_PLANE_FB_ID ], - plane->atomic_props_plane[IGT_PLANE_SRC_W ], - plane->atomic_props_plane[IGT_PLANE_SRC_H ], - plane->atomic_props_plane[IGT_PLANE_CRTC_W ], - plane->atomic_props_plane[IGT_PLANE_CRTC_H ] + plane->props[IGT_PLANE_CRTC_ID ], + plane->props[IGT_PLANE_FB_ID ], + plane->props[IGT_PLANE_SRC_W ], + plane->props[IGT_PLANE_SRC_H ], + plane->props[IGT_PLANE_CRTC_W ], + plane->props[IGT_PLANE_CRTC_H ] };uint64_t prop_vals[] = { /* crtc */
tests/kms_rotation_crc.c +2 -2
@@ -122,11 +122,11 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,igt_plane_set_fb (primary, &data->fb_modeset);if (commit <COMMIT_ATOMIC ) { - primary->rotation_changed = false; +igt_plane_clear_prop_changed (primary,IGT_PLANE_ROTATION );igt_display_commit (display);if (plane->type ==DRM_PLANE_TYPE_PRIMARY ) - primary->rotation_changed = true; +igt_plane_set_prop_changed (primary,IGT_PLANE_ROTATION ); }igt_plane_set_fb (plane,NULL );
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/12 lib/igt_kms: Rework pipe properties to be more atomic, v7.
In reply to Maarten LankhorstIn the future I want to allow tests to commit more properties, but for this to work I have to fix all properties to work better with atomic commit. Instead of special casing each property make a bitmask for all property changed flags, and try to commit all properties.
This has been the most involved one, since legacy pipe commit still handles a lot of the properties differently from the rest.
Changes since v1:
- Dump all changed properties on commit.
- Fix bug in igt_pipe_refresh().
Changes since v2:
- Set pipe ACTIVE property changed flag on init. Changes since v3:
- Add a missing igt_pipe_refresh() to kms_atomic_interruptible. Changes since v4:
- Perform error handling when setting custom crtc properties. Changes since v5:
- Only attempt to commit changes properties.
Changes since v6:
- Clear OUT_FENCE_PTR on succesful commit.
--- lib/igt_kms.c | 231 ++++++++++++++++++++------------------ lib/igt_kms.h | 77 +++++-------- tests/kms_atomic_interruptible.c | 8 +- tests/kms_atomic_transition.c | 2 +- tests/kms_crtc_background_color.c | 2 +- 5 files changed, 159 insertions(+), 161 deletions(-)
lib/igt_kms.c +121 -110
@@ -259,8 +259,8 @@ igt_atomic_fill_connector_props(igt_display_t *display, igt_output_t *output, }static void -igt_atomic_fill_pipe_props (igt_display_t *display,igt_pipe_t *pipe, -int num_crtc_props,const char **crtc_prop_names) +igt_fill_pipe_props (igt_display_t *display,igt_pipe_t *pipe, +int num_crtc_props,const char **crtc_prop_names) {drmModeObjectPropertiesPtr props;int i, j, fd;
@@ -278,7 +278,7 @@ igt_atomic_fill_pipe_props(igt_display_t *display, igt_pipe_t *pipe,if (strcmp (prop->name, crtc_prop_names[j]) !=0 )continue ; - pipe->atomic_props_crtc[j] = props->props[i]; + pipe->props[j] = props->props[i];break ; }
@@ -1620,13 +1620,6 @@ get_crtc_property(int drm_fd, uint32_t crtc_id, const char *name, name, prop_id, value, prop); } -static void -igt_crtc_set_property (igt_pipe_t *pipe,uint32_t prop_id,uint64_t value) -{ -drmModeObjectSetProperty (pipe->display->drm_fd, - pipe->crtc_id,DRM_MODE_OBJECT_CRTC , prop_id, value); -} -/* * Walk a plane's property list to determine its type. If we don't * find a type property, then the kernel doesn't support universal
@@ -1690,7 +1683,6 @@ void igt_display_init(igt_display_t *display, int drm_fd)int p =1 ;int j, type;uint8_t last_plane =0 , n_planes =0 ; -uint64_t prop_value; pipe->crtc_id = resources->crtcs[i]; pipe->display = display;
@@ -1700,29 +1692,16 @@ void igt_display_init(igt_display_t *display, int drm_fd) pipe->planes =NULL ; pipe->out_fence_fd =-1 ; +igt_fill_pipe_props (display, pipe,IGT_NUM_CRTC_PROPS , igt_crtc_prop_names); + +/* Force modeset disable on first commit */ +igt_pipe_obj_set_prop_changed (pipe,IGT_CRTC_MODE_ID ); +igt_pipe_obj_set_prop_changed (pipe,IGT_CRTC_ACTIVE ); +get_crtc_property (display->drm_fd, pipe->crtc_id, -"background_color" , - &pipe->background_property, - &prop_value, +"background_color" ,NULL , + &pipe->values[IGT_CRTC_BACKGROUND ],NULL ); - pipe->background = (uint32_t )prop_value; -get_crtc_property (display->drm_fd, pipe->crtc_id, -"DEGAMMA_LUT" , - &pipe->degamma_property, -NULL , -NULL ); -get_crtc_property (display->drm_fd, pipe->crtc_id, -"CTM" , - &pipe->ctm_property, -NULL , -NULL ); -get_crtc_property (display->drm_fd, pipe->crtc_id, -"GAMMA_LUT" , - &pipe->gamma_property, -NULL , -NULL ); - -igt_atomic_fill_pipe_props (display, pipe,IGT_NUM_CRTC_PROPS , igt_crtc_prop_names);/* count number of valid planes */ for (j =0 ; j < plane_resources->count_planes; j++) {
@@ -1813,8 +1792,6 @@ void igt_display_init(igt_display_t *display, int drm_fd)igt_assert_eq (p, n_planes); pipe->n_planes = n_planes; - - pipe->mode_changed = true; }/*
@@ -2291,7 +2268,7 @@ static int igt_primary_plane_commit_legacy(igt_plane_t *primary,if (!igt_plane_is_prop_changed (primary,IGT_PLANE_FB_ID ) && !(primary->changed &IGT_PLANE_COORD_CHANGED_MASK ) && - !primary->pipe->mode_changed) + !igt_pipe_obj_is_prop_changed (primary->pipe,IGT_CRTC_MODE_ID ))return 0 ; crtc_id = pipe->crtc_id;
@@ -2360,6 +2337,16 @@ static int igt_plane_commit(igt_plane_t *plane, } } +static bool is_atomic_prop (enum igt_atomic_crtc_properties prop) +{ +if (prop ==IGT_CRTC_MODE_ID || + prop ==IGT_CRTC_ACTIVE || + prop ==IGT_CRTC_OUT_FENCE_PTR ) +return true; + +return false; +} +/* * Commit all plane changes to an output. Note that if @s is COMMIT_LEGACY, * enabling/disabling the primary plane will also enable/disable the CRTC.
@@ -2377,19 +2364,17 @@ static int igt_pipe_commit(igt_pipe_t *pipe,int i;int ret; -if (pipe->background_changed) { -igt_crtc_set_property (pipe, pipe->background_property, - pipe->background); - } +for (i =0 ; i <IGT_NUM_CRTC_PROPS ; i++) +if (igt_pipe_obj_is_prop_changed (pipe, i) && + !is_atomic_prop (i)) { +igt_assert (pipe->props[i]); -if (pipe->color_mgmt_changed) { -igt_crtc_set_property (pipe, pipe->degamma_property, - pipe->degamma_blob); -igt_crtc_set_property (pipe, pipe->ctm_property, - pipe->ctm_blob); -igt_crtc_set_property (pipe, pipe->gamma_property, - pipe->gamma_blob); - } + ret =drmModeObjectSetProperty (pipe->display->drm_fd, + pipe->crtc_id,DRM_MODE_OBJECT_CRTC , + pipe->props[i], pipe->values[i]); + +CHECK_RETURN (ret, fail_on_error); + }for (i =0 ; i < pipe->n_planes; i++) {igt_plane_t *plane = &pipe->planes[i];
@@ -2402,9 +2387,10 @@ static int igt_pipe_commit(igt_pipe_t *pipe, }static void -igt_pipe_replace_blob (igt_pipe_t *pipe,uint64_t *blob,void *ptr,size_t length) +igt_pipe_replace_blob (igt_pipe_t *pipe,enum igt_atomic_crtc_properties prop,void *ptr,size_t length) {igt_display_t *display = pipe->display; +uint64_t *blob = &pipe->values[prop];uint32_t blob_id =0 ;if (*blob !=0 )
@@ -2416,6 +2402,7 @@ igt_pipe_replace_blob(igt_pipe_t *pipe, uint64_t *blob, void *ptr, size_t length ptr, length, &blob_id) == 0); *blob = blob_id; +igt_pipe_obj_set_prop_changed (pipe, prop); }/*
@@ -2423,51 +2410,23 @@ igt_pipe_replace_blob(igt_pipe_t *pipe, uint64_t *blob, void *ptr, size_t length*/ static void igt_atomic_prepare_crtc_commit (igt_pipe_t *pipe_obj,drmModeAtomicReq *req) { -if (pipe_obj->background_changed) -igt_atomic_populate_crtc_req (req, pipe_obj,IGT_CRTC_BACKGROUND , pipe_obj->background); - -if (pipe_obj->color_mgmt_changed) { -igt_atomic_populate_crtc_req (req, pipe_obj,IGT_CRTC_DEGAMMA_LUT , pipe_obj->degamma_blob); -igt_atomic_populate_crtc_req (req, pipe_obj,IGT_CRTC_CTM , pipe_obj->ctm_blob); -igt_atomic_populate_crtc_req (req, pipe_obj,IGT_CRTC_GAMMA_LUT , pipe_obj->gamma_blob); - } - -if (pipe_obj->mode_changed) { -igt_output_t *output =igt_pipe_get_output (pipe_obj); - -if (!output) { -igt_pipe_replace_blob (pipe_obj, &pipe_obj->mode_blob,NULL ,0 ); - -LOG (pipe_obj->display,"%s: Setting NULL mode\n" , -kmstest_pipe_name (pipe_obj->pipe)); - }else { -drmModeModeInfo *mode =igt_output_get_mode (output); +int i; -igt_pipe_replace_blob (pipe_obj, &pipe_obj->mode_blob, mode,sizeof (*mode)); +for (i =0 ; i <IGT_NUM_CRTC_PROPS ; i++) { +if (!igt_pipe_obj_is_prop_changed (pipe_obj, i)) +continue ; -LOG (pipe_obj->display,"%s: Setting mode %s from %s\n" , -kmstest_pipe_name (pipe_obj->pipe), - mode->name,igt_output_name (output)); - } +igt_debug ("Pipe %s: Setting property \"%s\" to 0x%" PRIx64"/%" PRIi64"\n" , +kmstest_pipe_name (pipe_obj->pipe), igt_crtc_prop_names[i], + pipe_obj->values[i], pipe_obj->values[i]); -igt_atomic_populate_crtc_req (req, pipe_obj,IGT_CRTC_MODE_ID , pipe_obj->mode_blob); -igt_atomic_populate_crtc_req (req, pipe_obj,IGT_CRTC_ACTIVE , !!output); +igt_assert_lt (0 ,drmModeAtomicAddProperty (req, pipe_obj->crtc_id, pipe_obj->props[i], pipe_obj->values[i])); }if (pipe_obj->out_fence_fd !=-1 ) {close (pipe_obj->out_fence_fd); pipe_obj->out_fence_fd =-1 ; } - -if (pipe_obj->out_fence_requested) - { -igt_atomic_populate_crtc_req (req, pipe_obj,IGT_CRTC_OUT_FENCE_PTR , - (uint64_t )(uintptr_t ) &pipe_obj->out_fence_fd); - } - -/* -* TODO: Add all crtc level properties here -*/ }/*
@@ -2558,15 +2517,22 @@ display_commit_changed(igt_display_t *display, enum igt_commit_style s)igt_pipe_t *pipe_obj = &display->pipes[pipe];igt_plane_t *plane; - pipe_obj->color_mgmt_changed = false; - pipe_obj->background_changed = false; +if (s ==COMMIT_ATOMIC ) { +if (igt_pipe_obj_is_prop_changed (pipe_obj,IGT_CRTC_OUT_FENCE_PTR )) +igt_assert (pipe_obj->out_fence_fd >=0 ); -if (s !=COMMIT_UNIVERSAL ) - pipe_obj->mode_changed = false; - -if (s ==COMMIT_ATOMIC && pipe_obj->out_fence_requested) { - pipe_obj->out_fence_requested = false; -igt_assert (pipe_obj->out_fence_fd >=0 ); + pipe_obj->values[IGT_CRTC_OUT_FENCE_PTR ] =0 ; + pipe_obj->changed =0 ; + }else { +igt_pipe_obj_clear_prop_changed (pipe_obj,IGT_CRTC_BACKGROUND ); +igt_pipe_obj_clear_prop_changed (pipe_obj,IGT_CRTC_CTM ); +igt_pipe_obj_clear_prop_changed (pipe_obj,IGT_CRTC_DEGAMMA_LUT ); +igt_pipe_obj_clear_prop_changed (pipe_obj,IGT_CRTC_GAMMA_LUT ); + +if (s !=COMMIT_UNIVERSAL ) { +igt_pipe_obj_clear_prop_changed (pipe_obj,IGT_CRTC_MODE_ID ); +igt_pipe_obj_clear_prop_changed (pipe_obj,IGT_CRTC_ACTIVE ); + } }for_each_plane_on_pipe (display, pipe, plane) {
@@ -2820,33 +2786,83 @@ void igt_output_override_mode(igt_output_t *output, drmModeModeInfo *mode) output->use_override_mode = !!mode; -if (pipe) - pipe->mode_changed = true; +if (pipe) { +if (output->display->is_atomic) +igt_pipe_replace_blob (pipe,IGT_CRTC_MODE_ID ,igt_output_get_mode (output),sizeof (*mode)); +else +igt_pipe_obj_set_prop_changed (pipe,IGT_CRTC_MODE_ID ); + } }void igt_output_set_pipe (igt_output_t *output,enum pipe pipe) {igt_display_t *display = output->display; -igt_pipe_t *old_pipe; +igt_pipe_t *old_pipe =NULL , *pipe_obj =NULL ;;igt_assert (output->name); -if (output->pending_pipe !=PIPE_NONE ) { +if (output->pending_pipe !=PIPE_NONE ) old_pipe =igt_output_get_driving_pipe (output); - old_pipe->mode_changed = true; - } +if (pipe !=PIPE_NONE ) + pipe_obj = &display->pipes[pipe];LOG (display,"%s: set_pipe(%s)\n" ,igt_output_name (output),kmstest_pipe_name (pipe)); output->pending_pipe = pipe; -if (pipe !=PIPE_NONE ) - display->pipes[pipe].mode_changed = true; +if (old_pipe) { +igt_output_t *old_output; + + old_output =igt_pipe_get_output (old_pipe); +if (!old_output) { +if (display->is_atomic) +igt_pipe_replace_blob (old_pipe,IGT_CRTC_MODE_ID ,NULL ,0 ); +else +igt_pipe_obj_set_prop_changed (old_pipe,IGT_CRTC_MODE_ID ); + +igt_pipe_obj_set_prop_value (old_pipe,IGT_CRTC_ACTIVE ,0 ); + } + }igt_output_set_prop_value (output,IGT_CONNECTOR_CRTC_ID , pipe ==PIPE_NONE ?0 : display->pipes[pipe].crtc_id);igt_output_refresh (output); + +if (pipe_obj) { +if (display->is_atomic) +igt_pipe_replace_blob (pipe_obj,IGT_CRTC_MODE_ID ,igt_output_get_mode (output),sizeof (drmModeModeInfo)); +else +igt_pipe_obj_set_prop_changed (pipe_obj,IGT_CRTC_MODE_ID ); + +igt_pipe_obj_set_prop_value (pipe_obj,IGT_CRTC_ACTIVE ,1 ); + } +} + +/* +* igt_pipe_refresh: +* @display: a pointer to an #igt_display_t structure +* @pipe: Pipe to refresh +* @force: Should be set to true if mode_blob is no longer considered +* to be valid, for example after doing an atomic commit during fork or closing display fd. +* +* Requests the pipe to be part of the state on next update. +* This is useful when state may have been out of sync after +* a fork, or we just want to be sure the pipe is included +* in the next commit. +*/ +void igt_pipe_refresh (igt_display_t *display,enum pipe pipe,bool force) +{ +igt_pipe_t *pipe_obj = &display->pipes[pipe]; + +if (force && display->is_atomic) { +igt_output_t *output =igt_pipe_get_output (pipe_obj); + + pipe_obj->values[IGT_CRTC_MODE_ID ] =0 ; +if (output) +igt_pipe_replace_blob (pipe_obj,IGT_CRTC_MODE_ID ,igt_output_get_mode (output),sizeof (drmModeModeInfo)); + }else +igt_pipe_obj_set_prop_changed (pipe_obj,IGT_CRTC_MODE_ID ); }void igt_output_set_scaling_mode (igt_output_t *output,uint64_t scaling_mode)
@@ -3052,28 +3068,25 @@ void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation)*/ void igt_pipe_request_out_fence (igt_pipe_t *pipe) { - pipe->out_fence_requested = true; +igt_pipe_obj_set_prop_value (pipe,IGT_CRTC_OUT_FENCE_PTR , (ptrdiff_t )&pipe->out_fence_fd); }void igt_pipe_set_degamma_lut (igt_pipe_t *pipe,void *ptr,size_t length) { -igt_pipe_replace_blob (pipe, &pipe->degamma_blob, ptr, length); - pipe->color_mgmt_changed =1 ; +igt_pipe_replace_blob (pipe,IGT_CRTC_DEGAMMA_LUT , ptr, length); }void igt_pipe_set_ctm_matrix (igt_pipe_t *pipe,void *ptr,size_t length) { -igt_pipe_replace_blob (pipe, &pipe->ctm_blob, ptr, length); - pipe->color_mgmt_changed =1 ; +igt_pipe_replace_blob (pipe,IGT_CRTC_CTM , ptr, length); }void igt_pipe_set_gamma_lut (igt_pipe_t *pipe,void *ptr,size_t length) { -igt_pipe_replace_blob (pipe, &pipe->gamma_blob, ptr, length); - pipe->color_mgmt_changed =1 ; +igt_pipe_replace_blob (pipe,IGT_CRTC_GAMMA_LUT , ptr, length); }/**
@@ -3094,9 +3107,7 @@ void igt_crtc_set_background(igt_pipe_t *pipe, uint64_t background)kmstest_pipe_name (pipe->pipe), pipe->pipe, background); - pipe->background = background; - - pipe->background_changed = true; +igt_pipe_obj_set_prop_value (pipe,IGT_CRTC_BACKGROUND , background); }void igt_wait_for_vblank_count (int drm_fd,enum pipe pipe,int count)
lib/igt_kms.h +30 -47
100 lines not on this page · raw message
tests/kms_atomic_interruptible.c +6 -2
@@ -158,8 +158,8 @@ static void run_plane_test(igt_display_t *display, enum pipe pipe, igt_output_tuint32_t count_props[3 ] = {2 ,1 ,6 };uint32_t props[] = {/* crtc: 2 props */ - plane->pipe->atomic_props_crtc[IGT_CRTC_MODE_ID ], - plane->pipe->atomic_props_crtc[IGT_CRTC_ACTIVE ], + plane->pipe->props[IGT_CRTC_MODE_ID ], + plane->pipe->props[IGT_CRTC_ACTIVE ],/* connector: 1 prop */ output->props[IGT_CONNECTOR_CRTC_ID ],/* plane: remainder props */
@@ -255,6 +255,10 @@ static void run_plane_test(igt_display_t *display, enum pipe pipe, igt_output_tigt_waitchildren (); +/* The mode is unset by the forked helper, force a refresh here */ +if (test_type == test_legacy_modeset || test_type == test_atomic_modeset) +igt_pipe_refresh (display, pipe, true); +igt_plane_set_fb (plane,NULL );igt_plane_set_fb (primary,NULL );igt_output_set_pipe (output,PIPE_NONE );
tests/kms_atomic_transition.c +1 -1
@@ -633,7 +633,7 @@ static unsigned set_combinations(igt_display_t *display, unsigned mask, struct idrmModeModeInfo *mode =NULL ;if (!(mask & (1 << pipe))) { -if (display->pipes[pipe].mode_blob) { +if (igt_pipe_is_prop_changed (display, pipe,IGT_CRTC_ACTIVE )) { event_mask |=1 << pipe;igt_plane_set_fb (plane,NULL ); }
tests/kms_crtc_background_color.c +1 -1
@@ -137,7 +137,7 @@ static void test_crtc_background(data_t *data)igt_output_set_pipe (output, pipe); plane =igt_output_get_plane_type (output,DRM_PLANE_TYPE_PRIMARY ); -igt_require (plane->pipe->background_property); +igt_require (plane->pipe->props[IGT_CRTC_BACKGROUND ]);prepare_crtc (data, output, pipe, plane,1 ,PURPLE ,BLACK64 );
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/12 lib/igt_kms: Allow setting any plane property through the universal path
In reply to Maarten LankhorstBlacklist some explicit atomic properties. We could theoretically set them but that's not what the legacy path is for. :)
When adding new properties, this means we could test those through the legacy commit.
--- lib/igt_kms.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-)
lib/igt_kms.c +33 -6
@@ -2097,7 +2097,22 @@ igt_atomic_prepare_plane_commit(igt_plane_t *plane, igt_pipe_t *pipe, } } - +/* +* Properties that can be changed through legacy SetProperty: +* - Obviously not the XYWH SRC/CRTC coordinates. +* - Not CRTC_ID or FENCE_ID, done through SetPlane. +* - Can't set IN_FENCE_FD, that would be silly. +* +* Theoretically the above can all be set through the legacy path +* with the atomic cap set, but that's not how our legacy plane +* commit behaves, so blacklist it by default. +*/ +#define LEGACY_PLANE_COMMIT_MASK \ + (((1ULL << IGT_NUM_PLANE_PROPS) - 1) & \ + ~(IGT_PLANE_COORD_CHANGED_MASK | \ + (1ULL << IGT_PLANE_FB_ID) | \ + (1ULL << IGT_PLANE_CRTC_ID) | \ + (1ULL << IGT_PLANE_IN_FENCE_FD)))/* * Commit position and fb changes to a DRM plane via the SetPlane ioctl; if the
@@ -2111,7 +2126,7 @@ static int igt_drm_plane_commit(igt_plane_t *plane, {igt_display_t *display = pipe->display;uint32_t fb_id, crtc_id; -int ret; +int ret, i;uint32_t src_x;uint32_t src_y;uint32_t src_w;
@@ -2120,6 +2135,7 @@ static int igt_drm_plane_commit(igt_plane_t *plane,int32_t crtc_y;uint32_t crtc_w;uint32_t crtc_h; +uint64_t changed_mask;bool setplane =igt_plane_is_prop_changed (plane,IGT_PLANE_FB_ID ) || plane->changed &IGT_PLANE_COORD_CHANGED_MASK ;
@@ -2184,10 +2200,21 @@ static int igt_drm_plane_commit(igt_plane_t *plane,CHECK_RETURN (ret, fail_on_error); } -if (igt_plane_is_prop_changed (plane,IGT_PLANE_ROTATION )) { + changed_mask = plane->changed &LEGACY_PLANE_COMMIT_MASK ; + +for (i =0 ; i <IGT_NUM_PLANE_PROPS ; i++) { +if (!(changed_mask & (1 << i))) +continue ; + +LOG (display,"SetProp plane %s.%d \"%s\" to 0x%" PRIx64"/%" PRIi64"\n" , +kmstest_pipe_name (pipe->pipe), plane->index, igt_plane_prop_names[i], + plane->values[i], plane->values[i]); + +igt_assert (plane->props[i]); + ret =igt_plane_set_property (plane, - plane->props[IGT_PLANE_ROTATION ], - plane->values[IGT_PLANE_ROTATION ]); + plane->props[i], + plane->values[i]);CHECK_RETURN (ret, fail_on_error); }
@@ -2555,7 +2582,7 @@ display_commit_changed(igt_display_t *display, enum igt_commit_style s)if (s !=COMMIT_LEGACY || !(plane->type ==DRM_PLANE_TYPE_PRIMARY || plane->type ==DRM_PLANE_TYPE_CURSOR )) -igt_plane_clear_prop_changed (plane,IGT_PLANE_ROTATION ); + plane->changed &= ~LEGACY_PLANE_COMMIT_MASK ; } } }
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/12 lib/igt_kms: Allow setting any output property through the !atomic paths
In reply to Maarten LankhorstEverything except CRTC_ID can be set in the legacy paths, we even have 2, the legacy and universal path. Excercise both. :D
--- lib/igt_kms.c | 53 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 16 deletions(-)
lib/igt_kms.c +37 -16
@@ -2413,6 +2413,36 @@ static int igt_pipe_commit(igt_pipe_t *pipe,return 0 ; } +static int igt_output_commit (igt_output_t *output, +enum igt_commit_style s, +bool fail_on_error) +{ +int i, ret; + +for (i =0 ; i <IGT_NUM_CONNECTOR_PROPS ; i++) { +if (!igt_output_is_prop_changed (output, i)) +continue ; + +/* CRTC_ID is set by calling drmModeSetCrtc in the legacy path. */ +if (i ==IGT_CONNECTOR_CRTC_ID ) +continue ; + +igt_assert (output->props[i]); + +if (s ==COMMIT_LEGACY ) + ret =drmModeConnectorSetProperty (output->display->drm_fd, output->id, + output->props[i], output->values[i]); +else + ret =drmModeObjectSetProperty (output->display->drm_fd, output->id, +DRM_MODE_OBJECT_CONNECTOR , + output->props[i], output->values[i]); + +CHECK_RETURN (ret, fail_on_error); + } + +return 0 ; +} +static void igt_pipe_replace_blob (igt_pipe_t *pipe,enum igt_atomic_crtc_properties prop,void *ptr,size_t length) {
@@ -2590,10 +2620,11 @@ display_commit_changed(igt_display_t *display, enum igt_commit_style s)for (i =0 ; i < display->n_outputs; i++) {igt_output_t *output = &display->outputs[i]; -if (s ==COMMIT_ATOMIC ) +if (s !=COMMIT_UNIVERSAL ) output->changed =0 ; -else if (s !=COMMIT_UNIVERSAL ) -igt_output_clear_prop_changed (output,IGT_CONNECTOR_CRTC_ID ); +else +/* no modeset in universal commit, no change to crtc. */ + output->changed &=1 <<IGT_CONNECTOR_CRTC_ID ; } }
@@ -2610,7 +2641,7 @@ static int do_display_commit(igt_display_t *display,enum igt_commit_style s, bool fail_on_error) { - int ret; + int i, ret = 0;enum pipe pipe;LOG_INDENT (display,"commit" );
@@ -2619,28 +2650,18 @@ static int do_display_commit(igt_display_t *display,if (s ==COMMIT_ATOMIC ) { ret =igt_atomic_commit (display,DRM_MODE_ATOMIC_ALLOW_MODESET ,NULL ); }else { -int valid_outs =0 ; -for_each_pipe (display, pipe) {igt_pipe_t *pipe_obj = &display->pipes[pipe]; -igt_output_t *output =igt_pipe_get_output (pipe_obj); - -if (output) - valid_outs++; ret =igt_pipe_commit (pipe_obj, s, fail_on_error);if (ret)break ; } -if (valid_outs ==0 ) { -LOG_UNINDENT (display); - -return -1 ; - } +for (i =0 ; !ret && i < display->n_outputs; i++) + ret =igt_output_commit (&display->outputs[i], s, fail_on_error); } -LOG_UNINDENT (display);CHECK_RETURN (ret, fail_on_error);
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 6/12 lib/igt_kms: Export property blob functions for output/pipe/plane
In reply to Maarten LankhorstWith the replace_prop_blob functions we can safely replace the blob for any property, without having to care about error handling ourselves.
This will for example allow overriding color management blobs, or for kms_atomic set invalid mode blobs.
The color management blob functions are removed, they can now be replaced by direct calls to replace the properties.
--- lib/igt_kms.c | 117 +++++++++++++++++++++++++++++++++++++++--------------- lib/igt_kms.h | 19 +++++++-- tests/kms_color.c | 12 +++--- 3 files changed, 107 insertions(+), 41 deletions(-)
lib/igt_kms.c +86 -31
@@ -2443,8 +2443,88 @@ static int igt_output_commit(igt_output_t *output,return 0 ; } -static void -igt_pipe_replace_blob (igt_pipe_t *pipe,enum igt_atomic_crtc_properties prop,void *ptr,size_t length) +/** +* igt_plane_replace_prop_blob: +* @plane: plane to set property on. +* @prop: property for which the blob will be replaced. +* @ptr: Pointer to contents for the property. +* @length: Length of contents. +* +* This function will destroy the old property blob for the given property, +* and will create a new property blob with the values passed to this function. +* +* The new property blob will be committed when you call igt_display_commit(), +* igt_display_commit2() or igt_display_commit_atomic(). +*/ +void +igt_plane_replace_prop_blob (igt_plane_t *plane,enum igt_atomic_plane_properties prop,const void *ptr,size_t length) +{ +igt_display_t *display = plane->pipe->display; +uint64_t *blob = &plane->values[prop]; +uint32_t blob_id =0 ; + +if (*blob !=0 ) +igt_assert (drmModeDestroyPropertyBlob (display->drm_fd, + *blob) ==0 ); + +if (length >0 ) +igt_assert (drmModeCreatePropertyBlob (display->drm_fd, + ptr, length, &blob_id) ==0 ); + + *blob = blob_id; +igt_plane_set_prop_changed (plane, prop); +} + +/** +* igt_output_replace_prop_blob: +* @output: output to set property on. +* @prop: property for which the blob will be replaced. +* @ptr: Pointer to contents for the property. +* @length: Length of contents. +* +* This function will destroy the old property blob for the given property, +* and will create a new property blob with the values passed to this function. +* +* The new property blob will be committed when you call igt_display_commit(), +* igt_display_commit2() or igt_display_commit_atomic(). +*/ +void +igt_output_replace_prop_blob (igt_output_t *output,enum igt_atomic_connector_properties prop,const void *ptr,size_t length) +{ +igt_display_t *display = output->display; +uint64_t *blob = &output->values[prop]; +uint32_t blob_id =0 ; + +if (*blob !=0 ) +igt_assert (drmModeDestroyPropertyBlob (display->drm_fd, + *blob) ==0 ); + +if (length >0 ) +igt_assert (drmModeCreatePropertyBlob (display->drm_fd, + ptr, length, &blob_id) ==0 ); + + *blob = blob_id; +igt_output_set_prop_changed (output, prop); +} + +/** +* igt_pipe_obj_replace_prop_blob: +* @pipe: pipe to set property on. +* @prop: property for which the blob will be replaced. +* @ptr: Pointer to contents for the property. +* @length: Length of contents. +* +* This function will destroy the old property blob for the given property, +* and will create a new property blob with the values passed to this function. +* +* The new property blob will be committed when you call igt_display_commit(), +* igt_display_commit2() or igt_display_commit_atomic(). +* +* Please use igt_output_override_mode() if you want to set #IGT_CRTC_MODE_ID, +* it works better with legacy commit. +*/ +void +igt_pipe_obj_replace_prop_blob (igt_pipe_t *pipe,enum igt_atomic_crtc_properties prop,const void *ptr,size_t length) {igt_display_t *display = pipe->display;uint64_t *blob = &pipe->values[prop];
@@ -2836,7 +2916,7 @@ void igt_output_override_mode(igt_output_t *output, drmModeModeInfo *mode)if (pipe) {if (output->display->is_atomic) -igt_pipe_replace_blob (pipe,IGT_CRTC_MODE_ID ,igt_output_get_mode (output),sizeof (*mode)); +igt_pipe_obj_replace_prop_blob (pipe,IGT_CRTC_MODE_ID ,igt_output_get_mode (output),sizeof (*mode));else igt_pipe_obj_set_prop_changed (pipe,IGT_CRTC_MODE_ID ); }
@@ -2865,7 +2945,7 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe) old_output =igt_pipe_get_output (old_pipe);if (!old_output) {if (display->is_atomic) -igt_pipe_replace_blob (old_pipe,IGT_CRTC_MODE_ID ,NULL ,0 ); +igt_pipe_obj_replace_prop_blob (old_pipe,IGT_CRTC_MODE_ID ,NULL ,0 );else igt_pipe_obj_set_prop_changed (old_pipe,IGT_CRTC_MODE_ID );
@@ -2879,7 +2959,7 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe)if (pipe_obj) {if (display->is_atomic) -igt_pipe_replace_blob (pipe_obj,IGT_CRTC_MODE_ID ,igt_output_get_mode (output),sizeof (drmModeModeInfo)); +igt_pipe_obj_replace_prop_blob (pipe_obj,IGT_CRTC_MODE_ID ,igt_output_get_mode (output),sizeof (drmModeModeInfo));else igt_pipe_obj_set_prop_changed (pipe_obj,IGT_CRTC_MODE_ID );
@@ -2908,18 +2988,11 @@ void igt_pipe_refresh(igt_display_t *display, enum pipe pipe, bool force) pipe_obj->values[IGT_CRTC_MODE_ID ] =0 ;if (output) -igt_pipe_replace_blob (pipe_obj,IGT_CRTC_MODE_ID ,igt_output_get_mode (output),sizeof (drmModeModeInfo)); +igt_pipe_obj_replace_prop_blob (pipe_obj,IGT_CRTC_MODE_ID ,igt_output_get_mode (output),sizeof (drmModeModeInfo)); }else igt_pipe_obj_set_prop_changed (pipe_obj,IGT_CRTC_MODE_ID ); } -void igt_output_set_scaling_mode (igt_output_t *output,uint64_t scaling_mode) -{ -igt_output_set_prop_value (output,IGT_CONNECTOR_SCALING_MODE , scaling_mode); - -igt_require (output->props[IGT_CONNECTOR_SCALING_MODE ]); -} -igt_plane_t *igt_output_get_plane (igt_output_t *output,int plane_idx) {igt_pipe_t *pipe;
@@ -3119,24 +3192,6 @@ void igt_pipe_request_out_fence(igt_pipe_t *pipe)igt_pipe_obj_set_prop_value (pipe,IGT_CRTC_OUT_FENCE_PTR , (ptrdiff_t )&pipe->out_fence_fd); } -void -igt_pipe_set_degamma_lut (igt_pipe_t *pipe,void *ptr,size_t length) -{ -igt_pipe_replace_blob (pipe,IGT_CRTC_DEGAMMA_LUT , ptr, length); -} - -void -igt_pipe_set_ctm_matrix (igt_pipe_t *pipe,void *ptr,size_t length) -{ -igt_pipe_replace_blob (pipe,IGT_CRTC_CTM , ptr, length); -} - -void -igt_pipe_set_gamma_lut (igt_pipe_t *pipe,void *ptr,size_t length) -{ -igt_pipe_replace_blob (pipe,IGT_CRTC_GAMMA_LUT , ptr, length); -} -/** * igt_crtc_set_background: * @pipe: pipe pointer to which background color to be set
lib/igt_kms.h +15 -4
@@ -366,7 +366,6 @@ const char *igt_output_name(igt_output_t *output);drmModeModeInfo *igt_output_get_mode (igt_output_t *output);void igt_output_override_mode (igt_output_t *output,drmModeModeInfo *mode);void igt_output_set_pipe (igt_output_t *output,enum pipe pipe); -void igt_output_set_scaling_mode (igt_output_t *output,uint64_t scaling_mode);igt_plane_t *igt_output_get_plane (igt_output_t *output,int plane_idx);igt_plane_t *igt_output_get_plane_type (igt_output_t *output,int plane_type); igt_output_t *igt_output_from_connector(igt_display_t *display,
@@ -381,9 +380,6 @@ static inline bool igt_plane_supports_rotation(igt_plane_t *plane)return plane->props[IGT_PLANE_ROTATION ] !=0 ; }void igt_pipe_request_out_fence (igt_pipe_t *pipe); -void igt_pipe_set_degamma_lut (igt_pipe_t *pipe,void *ptr,size_t length); -void igt_pipe_set_ctm_matrix (igt_pipe_t *pipe,void *ptr,size_t length); -void igt_pipe_set_gamma_lut (igt_pipe_t *pipe,void *ptr,size_t length);void igt_plane_set_fb (igt_plane_t *plane,struct igt_fb *fb);void igt_plane_set_fence_fd (igt_plane_t *plane,int fence_fd);
@@ -513,6 +509,10 @@ static inline bool igt_output_is_connected(igt_output_t *output)igt_plane_set_prop_changed (plane, prop); \ }while (0 ) +extern void igt_plane_replace_prop_blob(igt_plane_t *plane, +enum igt_atomic_plane_properties prop, +const void *ptr,size_t length); +#define igt_output_is_prop_changed (output, prop) \ (!!((output)->changed & (1 << (prop))))#define igt_output_set_prop_changed (output, prop) \
@@ -527,6 +527,10 @@ static inline bool igt_output_is_connected(igt_output_t *output)igt_output_set_prop_changed (output, prop); \ }while (0 ) +extern void igt_output_replace_prop_blob(igt_output_t *output, +enum igt_atomic_connector_properties prop, +const void *ptr,size_t length); +#define igt_pipe_obj_is_prop_changed (pipe_obj, prop) \ (!!((pipe_obj)->changed & (1 << (prop))))
@@ -554,6 +558,13 @@ static inline bool igt_output_is_connected(igt_output_t *output)#define igt_pipe_set_prop_value (display, pipe, prop, value) \ igt_pipe_obj_set_prop_value(&(display)->pipes[(pipe)], prop, value) +extern void igt_pipe_obj_replace_prop_blob (igt_pipe_t *pipe_obj, +enum igt_atomic_crtc_properties prop, +const void *ptr,size_t length); + +#define igt_pipe_replace_prop_blob (display, pipe, prop, ptr, length) \ + igt_pipe_obj_replace_prop_blob(&(display)->pipes[(pipe)], prop, ptr, length) +void igt_pipe_refresh (igt_display_t *display,enum pipe pipe,bool force);void igt_enable_connectors (void );
tests/kms_color.c +6 -6
@@ -189,7 +189,7 @@ static void set_degamma(data_t *data, data->degamma_lut_size, data->color_depth, 0); -igt_pipe_set_degamma_lut (pipe, lut, size); +igt_pipe_obj_replace_prop_blob (pipe,IGT_CRTC_DEGAMMA_LUT , lut, size);free (lut); }
@@ -204,7 +204,7 @@ static void set_gamma(data_t *data, data->gamma_lut_size, data->color_depth, 0); -igt_pipe_set_gamma_lut (pipe, lut, size); +igt_pipe_obj_replace_prop_blob (pipe,IGT_CRTC_GAMMA_LUT , lut, size);free (lut); }
@@ -224,12 +224,12 @@ static void set_ctm(igt_pipe_t *pipe, const double *coefficients) (int64_t ) (coefficients[i] * ((int64_t )1L <<32 )); } -igt_pipe_set_ctm_matrix (pipe, &ctm,sizeof (ctm)); +igt_pipe_obj_replace_prop_blob (pipe,IGT_CRTC_CTM , &ctm,sizeof (ctm)); } -#define disable_degamma (pipe) igt_pipe_set_degamma_lut(pipe, NULL, 0) -#define disable_gamma (pipe) igt_pipe_set_gamma_lut(pipe, NULL, 0) -#define disable_ctm (pipe) igt_pipe_set_ctm_matrix(pipe, NULL, 0) +#define disable_degamma (pipe) igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_DEGAMMA_LUT, NULL, 0) +#define disable_gamma (pipe) igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_GAMMA_LUT, NULL, 0) +#define disable_ctm (pipe) igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_CTM, NULL, 0) static void output_set_property_enum(igt_output_t *output, const char *property,
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/2 lib/igt_kms: Export property blob functions for output/pipe/plane, v2.
With the replace_prop_blob functions we can safely replace the blob for any property, without having to care about error handling ourselves.
This will for example allow overriding color management blobs, or for kms_atomic set invalid mode blobs.
The color management blob functions are removed, they can now be replaced by direct calls to replace the properties.
Changes since v1:
- Fix chamelium tests.
--- lib/igt_kms.c | 117 +++++++++++++++++++++++++++++++++++++++--------------- lib/igt_kms.h | 19 +++++++-- tests/chamelium.c | 6 +-- tests/kms_color.c | 12 +++--- 4 files changed, 110 insertions(+), 44 deletions(-)
lib/igt_kms.c +86 -31
@@ -2443,8 +2443,88 @@ static int igt_output_commit(igt_output_t *output,return 0 ; } -static void -igt_pipe_replace_blob (igt_pipe_t *pipe,enum igt_atomic_crtc_properties prop,void *ptr,size_t length) +/** +* igt_plane_replace_prop_blob: +* @plane: plane to set property on. +* @prop: property for which the blob will be replaced. +* @ptr: Pointer to contents for the property. +* @length: Length of contents. +* +* This function will destroy the old property blob for the given property, +* and will create a new property blob with the values passed to this function. +* +* The new property blob will be committed when you call igt_display_commit(), +* igt_display_commit2() or igt_display_commit_atomic(). +*/ +void +igt_plane_replace_prop_blob (igt_plane_t *plane,enum igt_atomic_plane_properties prop,const void *ptr,size_t length) +{ +igt_display_t *display = plane->pipe->display; +uint64_t *blob = &plane->values[prop]; +uint32_t blob_id =0 ; + +if (*blob !=0 ) +igt_assert (drmModeDestroyPropertyBlob (display->drm_fd, + *blob) ==0 ); + +if (length >0 ) +igt_assert (drmModeCreatePropertyBlob (display->drm_fd, + ptr, length, &blob_id) ==0 ); + + *blob = blob_id; +igt_plane_set_prop_changed (plane, prop); +} + +/** +* igt_output_replace_prop_blob: +* @output: output to set property on. +* @prop: property for which the blob will be replaced. +* @ptr: Pointer to contents for the property. +* @length: Length of contents. +* +* This function will destroy the old property blob for the given property, +* and will create a new property blob with the values passed to this function. +* +* The new property blob will be committed when you call igt_display_commit(), +* igt_display_commit2() or igt_display_commit_atomic(). +*/ +void +igt_output_replace_prop_blob (igt_output_t *output,enum igt_atomic_connector_properties prop,const void *ptr,size_t length) +{ +igt_display_t *display = output->display; +uint64_t *blob = &output->values[prop]; +uint32_t blob_id =0 ; + +if (*blob !=0 ) +igt_assert (drmModeDestroyPropertyBlob (display->drm_fd, + *blob) ==0 ); + +if (length >0 ) +igt_assert (drmModeCreatePropertyBlob (display->drm_fd, + ptr, length, &blob_id) ==0 ); + + *blob = blob_id; +igt_output_set_prop_changed (output, prop); +} + +/** +* igt_pipe_obj_replace_prop_blob: +* @pipe: pipe to set property on. +* @prop: property for which the blob will be replaced. +* @ptr: Pointer to contents for the property. +* @length: Length of contents. +* +* This function will destroy the old property blob for the given property, +* and will create a new property blob with the values passed to this function. +* +* The new property blob will be committed when you call igt_display_commit(), +* igt_display_commit2() or igt_display_commit_atomic(). +* +* Please use igt_output_override_mode() if you want to set #IGT_CRTC_MODE_ID, +* it works better with legacy commit. +*/ +void +igt_pipe_obj_replace_prop_blob (igt_pipe_t *pipe,enum igt_atomic_crtc_properties prop,const void *ptr,size_t length) {igt_display_t *display = pipe->display;uint64_t *blob = &pipe->values[prop];
@@ -2836,7 +2916,7 @@ void igt_output_override_mode(igt_output_t *output, drmModeModeInfo *mode)if (pipe) {if (output->display->is_atomic) -igt_pipe_replace_blob (pipe,IGT_CRTC_MODE_ID ,igt_output_get_mode (output),sizeof (*mode)); +igt_pipe_obj_replace_prop_blob (pipe,IGT_CRTC_MODE_ID ,igt_output_get_mode (output),sizeof (*mode));else igt_pipe_obj_set_prop_changed (pipe,IGT_CRTC_MODE_ID ); }
@@ -2865,7 +2945,7 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe) old_output =igt_pipe_get_output (old_pipe);if (!old_output) {if (display->is_atomic) -igt_pipe_replace_blob (old_pipe,IGT_CRTC_MODE_ID ,NULL ,0 ); +igt_pipe_obj_replace_prop_blob (old_pipe,IGT_CRTC_MODE_ID ,NULL ,0 );else igt_pipe_obj_set_prop_changed (old_pipe,IGT_CRTC_MODE_ID );
@@ -2879,7 +2959,7 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe)if (pipe_obj) {if (display->is_atomic) -igt_pipe_replace_blob (pipe_obj,IGT_CRTC_MODE_ID ,igt_output_get_mode (output),sizeof (drmModeModeInfo)); +igt_pipe_obj_replace_prop_blob (pipe_obj,IGT_CRTC_MODE_ID ,igt_output_get_mode (output),sizeof (drmModeModeInfo));else igt_pipe_obj_set_prop_changed (pipe_obj,IGT_CRTC_MODE_ID );
@@ -2908,18 +2988,11 @@ void igt_pipe_refresh(igt_display_t *display, enum pipe pipe, bool force) pipe_obj->values[IGT_CRTC_MODE_ID ] =0 ;if (output) -igt_pipe_replace_blob (pipe_obj,IGT_CRTC_MODE_ID ,igt_output_get_mode (output),sizeof (drmModeModeInfo)); +igt_pipe_obj_replace_prop_blob (pipe_obj,IGT_CRTC_MODE_ID ,igt_output_get_mode (output),sizeof (drmModeModeInfo)); }else igt_pipe_obj_set_prop_changed (pipe_obj,IGT_CRTC_MODE_ID ); } -void igt_output_set_scaling_mode (igt_output_t *output,uint64_t scaling_mode) -{ -igt_output_set_prop_value (output,IGT_CONNECTOR_SCALING_MODE , scaling_mode); - -igt_require (output->props[IGT_CONNECTOR_SCALING_MODE ]); -} -igt_plane_t *igt_output_get_plane (igt_output_t *output,int plane_idx) {igt_pipe_t *pipe;
@@ -3119,24 +3192,6 @@ void igt_pipe_request_out_fence(igt_pipe_t *pipe)igt_pipe_obj_set_prop_value (pipe,IGT_CRTC_OUT_FENCE_PTR , (ptrdiff_t )&pipe->out_fence_fd); } -void -igt_pipe_set_degamma_lut (igt_pipe_t *pipe,void *ptr,size_t length) -{ -igt_pipe_replace_blob (pipe,IGT_CRTC_DEGAMMA_LUT , ptr, length); -} - -void -igt_pipe_set_ctm_matrix (igt_pipe_t *pipe,void *ptr,size_t length) -{ -igt_pipe_replace_blob (pipe,IGT_CRTC_CTM , ptr, length); -} - -void -igt_pipe_set_gamma_lut (igt_pipe_t *pipe,void *ptr,size_t length) -{ -igt_pipe_replace_blob (pipe,IGT_CRTC_GAMMA_LUT , ptr, length); -} -/** * igt_crtc_set_background: * @pipe: pipe pointer to which background color to be set
lib/igt_kms.h +15 -4
@@ -366,7 +366,6 @@ const char *igt_output_name(igt_output_t *output);drmModeModeInfo *igt_output_get_mode (igt_output_t *output);void igt_output_override_mode (igt_output_t *output,drmModeModeInfo *mode);void igt_output_set_pipe (igt_output_t *output,enum pipe pipe); -void igt_output_set_scaling_mode (igt_output_t *output,uint64_t scaling_mode);igt_plane_t *igt_output_get_plane (igt_output_t *output,int plane_idx);igt_plane_t *igt_output_get_plane_type (igt_output_t *output,int plane_type); igt_output_t *igt_output_from_connector(igt_display_t *display,
@@ -381,9 +380,6 @@ static inline bool igt_plane_supports_rotation(igt_plane_t *plane)return plane->props[IGT_PLANE_ROTATION ] !=0 ; }void igt_pipe_request_out_fence (igt_pipe_t *pipe); -void igt_pipe_set_degamma_lut (igt_pipe_t *pipe,void *ptr,size_t length); -void igt_pipe_set_ctm_matrix (igt_pipe_t *pipe,void *ptr,size_t length); -void igt_pipe_set_gamma_lut (igt_pipe_t *pipe,void *ptr,size_t length);void igt_plane_set_fb (igt_plane_t *plane,struct igt_fb *fb);void igt_plane_set_fence_fd (igt_plane_t *plane,int fence_fd);
@@ -513,6 +509,10 @@ static inline bool igt_output_is_connected(igt_output_t *output)igt_plane_set_prop_changed (plane, prop); \ }while (0 ) +extern void igt_plane_replace_prop_blob(igt_plane_t *plane, +enum igt_atomic_plane_properties prop, +const void *ptr,size_t length); +#define igt_output_is_prop_changed (output, prop) \ (!!((output)->changed & (1 << (prop))))#define igt_output_set_prop_changed (output, prop) \
@@ -527,6 +527,10 @@ static inline bool igt_output_is_connected(igt_output_t *output)igt_output_set_prop_changed (output, prop); \ }while (0 ) +extern void igt_output_replace_prop_blob(igt_output_t *output, +enum igt_atomic_connector_properties prop, +const void *ptr,size_t length); +#define igt_pipe_obj_is_prop_changed (pipe_obj, prop) \ (!!((pipe_obj)->changed & (1 << (prop))))
@@ -554,6 +558,13 @@ static inline bool igt_output_is_connected(igt_output_t *output)#define igt_pipe_set_prop_value (display, pipe, prop, value) \ igt_pipe_obj_set_prop_value(&(display)->pipes[(pipe)], prop, value) +extern void igt_pipe_obj_replace_prop_blob (igt_pipe_t *pipe_obj, +enum igt_atomic_crtc_properties prop, +const void *ptr,size_t length); + +#define igt_pipe_replace_prop_blob (display, pipe, prop, ptr, length) \ + igt_pipe_obj_replace_prop_blob(&(display)->pipes[(pipe)], prop, ptr, length) +void igt_pipe_refresh (igt_display_t *display,enum pipe pipe,bool force);void igt_enable_connectors (void );
tests/chamelium.c +3 -3
@@ -462,9 +462,9 @@ enable_output(data_t *data,igt_output_set_pipe (output, output->config.pipe);/* Clear any color correction values that might be enabled */ -igt_pipe_set_degamma_lut (primary->pipe,NULL ,0 ); -igt_pipe_set_gamma_lut (primary->pipe,NULL ,0 ); -igt_pipe_set_ctm_matrix (primary->pipe,NULL ,0 ); +igt_pipe_obj_replace_prop_blob (primary->pipe,IGT_CRTC_DEGAMMA_LUT ,NULL ,0 ); +igt_pipe_obj_replace_prop_blob (primary->pipe,IGT_CRTC_GAMMA_LUT ,NULL ,0 ); +igt_pipe_obj_replace_prop_blob (primary->pipe,IGT_CRTC_CTM ,NULL ,0 );kmstest_set_connector_broadcast_rgb (display->drm_fd, connector,BROADCAST_RGB_FULL );
tests/kms_color.c +6 -6
@@ -189,7 +189,7 @@ static void set_degamma(data_t *data, data->degamma_lut_size, data->color_depth, 0); -igt_pipe_set_degamma_lut (pipe, lut, size); +igt_pipe_obj_replace_prop_blob (pipe,IGT_CRTC_DEGAMMA_LUT , lut, size);free (lut); }
@@ -204,7 +204,7 @@ static void set_gamma(data_t *data, data->gamma_lut_size, data->color_depth, 0); -igt_pipe_set_gamma_lut (pipe, lut, size); +igt_pipe_obj_replace_prop_blob (pipe,IGT_CRTC_GAMMA_LUT , lut, size);free (lut); }
@@ -224,12 +224,12 @@ static void set_ctm(igt_pipe_t *pipe, const double *coefficients) (int64_t ) (coefficients[i] * ((int64_t )1L <<32 )); } -igt_pipe_set_ctm_matrix (pipe, &ctm,sizeof (ctm)); +igt_pipe_obj_replace_prop_blob (pipe,IGT_CRTC_CTM , &ctm,sizeof (ctm)); } -#define disable_degamma (pipe) igt_pipe_set_degamma_lut(pipe, NULL, 0) -#define disable_gamma (pipe) igt_pipe_set_gamma_lut(pipe, NULL, 0) -#define disable_ctm (pipe) igt_pipe_set_ctm_matrix(pipe, NULL, 0) +#define disable_degamma (pipe) igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_DEGAMMA_LUT, NULL, 0) +#define disable_gamma (pipe) igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_GAMMA_LUT, NULL, 0) +#define disable_ctm (pipe) igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_CTM, NULL, 0) static void output_set_property_enum(igt_output_t *output, const char *property,
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 tests/chamelium: Remove reliance on output->config.pipe
IGT has an api that can find a matching pipe for a given connector, so use that.
igt_output_override_mode already forces a modeset on an affected pipe since an earlier commit, so the second call to igt_output_set_pipe can be removed.
--- tests/chamelium.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
tests/chamelium.c +14 -3
@@ -416,6 +416,8 @@ prepare_output(data_t *data,drmModeRes *res;drmModeConnector *connector =chamelium_port_get_connector (data->chamelium, port, false); +enum pipe pipe; +bool found = false;igt_assert (res =drmModeGetResources (data->drm_fd));kmstest_unset_all_crtcs (data->drm_fd, res);
@@ -433,7 +435,18 @@ prepare_output(data_t *data,igt_assert (kmstest_probe_connector_config ( data->drm_fd, connector->connector_id, ~0 , &output->config)); -igt_output_set_pipe (output, output->config.pipe); + +for_each_pipe (display, pipe) { +if (!igt_pipe_connector_valid (pipe, output)) +continue ; + + found = true; +break ; + } + +igt_assert_f (found,"No pipe found for output %s\n" ,igt_output_name (output)); + +igt_output_set_pipe (output, pipe);drmModeFreeConnector (connector);drmModeFreeResources (res);
@@ -459,8 +472,6 @@ enable_output(data_t *data,igt_plane_set_fb (primary, fb);igt_output_override_mode (output, mode); -igt_output_set_pipe (output, output->config.pipe); -/* Clear any color correction values that might be enabled */ igt_pipe_obj_replace_prop_blob (primary->pipe,IGT_CRTC_DEGAMMA_LUT ,NULL ,0 );igt_pipe_obj_replace_prop_blob (primary->pipe,IGT_CRTC_GAMMA_LUT ,NULL ,0 );
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 7/12 lib/igt_kms: Unexport broadcast rgb API.
In reply to Maarten LankhorstSetting broadcast rgb was only used by chamelium, but is now handled in igt_display by default. This means that chamelium doesn't need to set it, and this can be hidden. The broadcast RGB property is intel connector specific, so rename the enum to intel_broadcast_rgb_mode.
Keep the property and enum public in case someone wants to test the property later.
--- lib/igt_kms.c | 44 ++++++-------------------------------------- lib/igt_kms.h | 7 +++---- tests/chamelium.c | 3 --- 3 files changed, 9 insertions(+), 45 deletions(-)
lib/igt_kms.c +6 -38
@@ -187,7 +187,8 @@ const char *igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {const char *igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS ] = {"scaling mode" ,"CRTC_ID" , -"DPMS" +"DPMS" , +"Broadcast RGB" };/*
@@ -1037,40 +1038,6 @@ void kmstest_set_connector_dpms(int fd, drmModeConnector *connector, int mode) dpms, mode) == 0); } -/** -* kmstest_set_connector_broadcast_rgb: -* @fd: DRM fd -* @connector: libdrm connector -* @mode: Broadcast RGB mode -* -* This function sets the Broadcast RGB prop of @connector to @mode, if there -* is one. -* -* Returns: true if we found and set the Broadcast RGB prop, false otherwise -*/ -bool kmstest_set_connector_broadcast_rgb (int fd,drmModeConnector *connector, -enum kmstest_broadcast_rgb_mode mode) -{ -uint32_t prop_id; -int ret; - - ret =kmstest_get_property (fd, connector->connector_id, -DRM_MODE_OBJECT_CONNECTOR ,"Broadcast RGB" , - &prop_id,NULL ,NULL ); -if (!ret) { -igt_debug ("Broadcast RGB property not found on %d\n" , - connector->connector_id); -return false; - } - -igt_debug ("Setting Broadcast RGB mode on connector %d to %d\n" , - connector->connector_id, mode); - ret =drmModeConnectorSetProperty (fd, connector->connector_id, prop_id, - mode); - -return ret ==0 ; -} -/** * kmstest_get_property: * @drm_fd: drm file descriptor
@@ -1583,9 +1550,10 @@ static void igt_output_refresh(igt_output_t *output)igt_atomic_fill_connector_props (display, output,IGT_NUM_CONNECTOR_PROPS , igt_connector_prop_names); -kmstest_set_connector_broadcast_rgb (display->drm_fd, - output->config.connector, -BROADCAST_RGB_FULL ); +if (output->props[IGT_CONNECTOR_BROADCAST_RGB ]) +igt_output_set_prop_value (output, +IGT_CONNECTOR_BROADCAST_RGB , +BROADCAST_RGB_FULL ); } LOG(display, "%s: Selecting pipe %s\n", output->name,
lib/igt_kms.h +3 -4
@@ -115,6 +115,7 @@ enum igt_atomic_connector_properties {IGT_CONNECTOR_SCALING_MODE =0 ,IGT_CONNECTOR_CRTC_ID ,IGT_CONNECTOR_DPMS , +IGT_CONNECTOR_BROADCAST_RGB , IGT_NUM_CONNECTOR_PROPS };
@@ -171,13 +172,13 @@ enum kmstest_force_connector_state { };/** -* kmstest_broadcast_rgb_mode: +* intel_broadcast_rgb_mode: * @BROADCAST_RGB_AUTO: Choose the color range to use automatically * @BROADCAST_RGB_FULL: Force the connector to use full color range * @BROADCAST_RGB_16_235: Force the connector to use a limited 16:235 color * range */ -enum kmstest_broadcast_rgb_mode { +enum intel_broadcast_rgb_mode {BROADCAST_RGB_AUTO =0 ,BROADCAST_RGB_FULL ,BROADCAST_RGB_16_235
@@ -203,8 +204,6 @@ bool kmstest_probe_connector_config(int drm_fd, uint32_t connector_id,void kmstest_free_connector_config (struct kmstest_connector_config *config);void kmstest_set_connector_dpms (int fd,drmModeConnector *connector,int mode); -bool kmstest_set_connector_broadcast_rgb (int fd,drmModeConnector *connector, -enum kmstest_broadcast_rgb_mode mode);bool kmstest_get_property (int drm_fd,uint32_t object_id,uint32_t object_type,const char *name,uint32_t *prop_id,uint64_t *value,drmModePropertyPtr *prop);
tests/chamelium.c +0 -3
@@ -466,9 +466,6 @@ enable_output(data_t *data,igt_pipe_set_gamma_lut (primary->pipe,NULL ,0 );igt_pipe_set_ctm_matrix (primary->pipe,NULL ,0 ); -kmstest_set_connector_broadcast_rgb (display->drm_fd, connector, -BROADCAST_RGB_FULL ); -igt_display_commit (display);if (chamelium_port_get_type (port) ==DRM_MODE_CONNECTOR_VGA )
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 8/12 lib/igt_kms: Add igt_$obj_has_prop functions
In reply to Maarten LankhorstThis allows test to test whether a property is supported, in a nice and clean way. It removes the need for special case functions like igt_plane_supports_rotation.
Convert the users of igt_plane_supports_rotation and remove the extra check in drm_plane_commit, this is already checked below when setting plane properties.
--- lib/igt_kms.c | 4 --- lib/igt_kms.h | 62 ++++++++++++++++++++++++++++++++++++--- tests/kms_crtc_background_color.c | 2 +- tests/kms_rotation_crc.c | 6 ++-- 4 files changed, 62 insertions(+), 12 deletions(-)
lib/igt_kms.c +0 -4
@@ -2110,10 +2110,6 @@ static int igt_drm_plane_commit(igt_plane_t *plane,igt_assert (plane->drm_plane); -/* it's an error to try an unsupported feature */ -igt_assert (igt_plane_supports_rotation (plane) || - !igt_plane_is_prop_changed (plane,IGT_PLANE_ROTATION )); - fb_id =igt_plane_get_fb_id (plane); crtc_id = pipe->crtc_id;
lib/igt_kms.h +58 -4
86 lines not on this page · raw message
tests/kms_crtc_background_color.c +1 -1
@@ -137,7 +137,7 @@ static void test_crtc_background(data_t *data)igt_output_set_pipe (output, pipe); plane =igt_output_get_plane_type (output,DRM_PLANE_TYPE_PRIMARY ); -igt_require (plane->pipe->props[IGT_CRTC_BACKGROUND ]); +igt_require (igt_plane_has_prop (plane,IGT_CRTC_BACKGROUND ));prepare_crtc (data, output, pipe, plane,1 ,PURPLE ,BLACK64 );
tests/kms_rotation_crc.c +3 -3
@@ -351,7 +351,7 @@ static void test_plane_rotation(data_t *data, int plane_type)igt_output_set_pipe (output, pipe); plane =igt_output_get_plane_type (output, plane_type); -igt_require (igt_plane_supports_rotation (plane)); +igt_require (igt_plane_has_prop (plane,IGT_PLANE_ROTATION ));prepare_crtc (data, output, pipe, plane, commit);
@@ -438,7 +438,7 @@ static void test_plane_rotation_ytiled_obj(data_t *data,int ret; plane =igt_output_get_plane_type (output, plane_type); -igt_require (igt_plane_supports_rotation (plane)); +igt_require (igt_plane_has_prop (plane,IGT_PLANE_ROTATION ));if (plane_type ==DRM_PLANE_TYPE_PRIMARY || plane_type ==DRM_PLANE_TYPE_CURSOR ) commit =COMMIT_UNIVERSAL ;
@@ -504,7 +504,7 @@ static void test_plane_rotation_exhaust_fences(data_t *data,int i, ret; plane =igt_output_get_plane_type (output, plane_type); -igt_require (igt_plane_supports_rotation (plane)); +igt_require (igt_plane_has_prop (plane,IGT_PLANE_ROTATION ));if (plane_type ==DRM_PLANE_TYPE_PRIMARY || plane_type ==DRM_PLANE_TYPE_CURSOR ) commit =COMMIT_UNIVERSAL ;
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 9/12 lib/igt_kms: Add igt_$obj_get_prop functions
In reply to Maarten LankhorstSome tests need to get the current kernel value for properties as part of the test. Add get_prop functions that will retrieve the current kernel value.
--- lib/igt_kms.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_kms.h | 24 ++++++++++++++++++ 2 files changed, 105 insertions(+)
lib/igt_kms.c +81 -0
@@ -2407,6 +2407,51 @@ static int igt_output_commit(igt_output_t *output,return 0 ; } +static uint64_t igt_mode_object_get_prop (igt_display_t *display, +uint32_t object_type, +uint32_t object_id, +uint32_t prop) +{ +drmModeObjectPropertiesPtr proplist; +bool found = false; +int i; +uint64_t ret; + + proplist =drmModeObjectGetProperties (display->drm_fd, object_id, object_type); +for (i =0 ; i < proplist->count_props; i++) { +if (proplist->props[i] != prop) +continue ; + + found = true; +break ; + } + +igt_assert (found); + + ret = proplist->prop_values[i]; + +drmModeFreeObjectProperties (proplist); +return ret; +} + +/** +* igt_plane_get_prop - Return current value on a plane for a given property. +* +* @plane: Target plane. +* @prop: Property to check. +* +* Returns: The value the property is set to, if this +* is a blob, the blob id is returned. This can be passed +* to drmModeGetPropertyBlob() to get the contents of the blob. +*/ +uint64_t igt_plane_get_prop (igt_plane_t *plane,enum igt_atomic_plane_properties prop) +{ +igt_assert (igt_plane_has_prop (plane, prop)); + +return igt_mode_object_get_prop (plane->pipe->display,DRM_MODE_OBJECT_PLANE , + plane->drm_plane->plane_id, plane->props[prop]); +} +/** * igt_plane_replace_prop_blob: * @plane: plane to set property on.
@@ -2439,6 +2484,24 @@ igt_plane_replace_prop_blob(igt_plane_t *plane, enum igt_atomic_plane_propertiesigt_plane_set_prop_changed (plane, prop); } +/** +* igt_output_get_prop - Return current value on an output for a given property. +* +* @output: Target output. +* @prop: Property to return. +* +* Returns: The value the property is set to, if this +* is a blob, the blob id is returned. This can be passed +* to drmModeGetPropertyBlob() to get the contents of the blob. +*/ +uint64_t igt_output_get_prop (igt_output_t *output,enum igt_atomic_connector_properties prop) +{ +igt_assert (igt_output_has_prop (output, prop)); + +return igt_mode_object_get_prop (output->display,DRM_MODE_OBJECT_CONNECTOR , + output->id, output->props[prop]); +} +/** * igt_output_replace_prop_blob: * @output: output to set property on.
@@ -2471,6 +2534,24 @@ igt_output_replace_prop_blob(igt_output_t *output, enum igt_atomic_connector_proigt_output_set_prop_changed (output, prop); } +/** +* igt_pipe_obj_get_prop - Return current value on a pipe for a given property. +* +* @pipe: Target pipe. +* @prop: Property to return. +* +* Returns: The value the property is set to, if this +* is a blob, the blob id is returned. This can be passed +* to drmModeGetPropertyBlob() to get the contents of the blob. +*/ +uint64_t igt_pipe_obj_get_prop (igt_pipe_t *pipe,enum igt_atomic_crtc_properties prop) +{ +igt_assert (igt_pipe_obj_has_prop (pipe, prop)); + +return igt_mode_object_get_prop (pipe->display,DRM_MODE_OBJECT_CRTC , + pipe->crtc_id, pipe->props[prop]); +} +/** * igt_pipe_obj_replace_prop_blob: * @pipe: pipe to set property on.
lib/igt_kms.h +24 -0
@@ -503,6 +503,8 @@ igt_plane_has_prop(igt_plane_t *plane, enum igt_atomic_plane_properties prop)return plane->props[prop]; } +uint64_t igt_plane_get_prop (igt_plane_t *plane,enum igt_atomic_plane_properties prop); +#define igt_plane_is_prop_changed (plane, prop) \ (!!((plane)->changed & (1 << (prop))))
@@ -536,6 +538,8 @@ igt_output_has_prop(igt_output_t *output, enum igt_atomic_connector_properties preturn output->props[prop]; } +uint64_t igt_output_get_prop (igt_output_t *output,enum igt_atomic_connector_properties prop); +#define igt_output_is_prop_changed (output, prop) \ (!!((output)->changed & (1 << (prop))))#define igt_output_set_prop_changed (output, prop) \
@@ -568,6 +572,26 @@ igt_pipe_obj_has_prop(igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop)return pipe->props[prop]; } +uint64_t igt_pipe_obj_get_prop (igt_pipe_t *pipe,enum igt_atomic_crtc_properties prop); + +/** +* igt_pipe_get_prop - Return current value on a pipe for a given property. +* +* @display: Pointer to display. +* @pipe: Target pipe. +* @prop: Property to return. +* +* Returns: The value the property is set to, if this +* is a blob, the blob id is returned. This can be passed +* to drmModeGetPropertyBlob() to get the contents of the blob. +*/ +static inline uint64_t +igt_pipe_get_prop (igt_display_t *display,enum pipe pipe, +enum igt_atomic_crtc_properties prop) +{ +return igt_pipe_obj_get_prop (&display->pipes[pipe], prop); +} +/** * igt_pipe_has_prop - Check whether pipe supports a given property. *
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 10/12 tests/kms_color: Rework tests slightly to work better with new atomic api
In reply to Maarten Lankhorstigt_pipe_get_property is about to be removed, so use igt_pipe_obj_get_prop instead. This requires adding 2 more properties to the crtc property list. Also get rid of the Broadcast RGB call, this is already handled in igt_kms.
Change order for DEGAMMA_LUT and GAMMA_LUT around, else this test will fail if legacy gamma is set. In the legacy path, this will update GAMMA_LUT to the new size before DEGAMMA_LUT is set.
--- lib/igt_kms.c | 4 +- lib/igt_kms.h | 4 +- tests/kms_color.c | 217 +++++++++++++++++++----------------------------------- 3 files changed, 83 insertions(+), 142 deletions(-)
lib/igt_kms.c +3 -1
@@ -177,8 +177,10 @@ const char *igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {const char *igt_crtc_prop_names[IGT_NUM_CRTC_PROPS ] = {"background_color" ,"CTM" , -"DEGAMMA_LUT" ,"GAMMA_LUT" , +"GAMMA_LUT_SIZE" , +"DEGAMMA_LUT" , +"DEGAMMA_LUT_SIZE" ,"MODE_ID" ,"ACTIVE" ,"OUT_FENCE_PTR"
lib/igt_kms.h +3 -1
@@ -95,8 +95,10 @@ void kmstest_restore_vt_mode(void);enum igt_atomic_crtc_properties {IGT_CRTC_BACKGROUND =0 ,IGT_CRTC_CTM , -IGT_CRTC_DEGAMMA_LUT ,IGT_CRTC_GAMMA_LUT , +IGT_CRTC_GAMMA_LUT_SIZE , +IGT_CRTC_DEGAMMA_LUT , +IGT_CRTC_DEGAMMA_LUT_SIZE ,IGT_CRTC_MODE_ID ,IGT_CRTC_ACTIVE ,IGT_CRTC_OUT_FENCE_PTR ,
tests/kms_color.c +77 -140
384 lines not on this page · raw message
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 11/12 lib/igt_kms: Remove igt_pipe_get_property
In reply to Maarten Lankhorstigt_pipe_get_property has been replaced by igt_pipe_obj_get_prop.
--- lib/igt_kms.c | 10 ---------- lib/igt_kms.h | 3 --- 2 files changed, 13 deletions(-)
lib/igt_kms.c +0 -10
@@ -2011,16 +2011,6 @@ static igt_output_t *igt_pipe_get_output(igt_pipe_t *pipe)return NULL ; } -bool igt_pipe_get_property (igt_pipe_t *pipe,const char *name, -uint32_t *prop_id,uint64_t *value, -drmModePropertyPtr *prop) -{ -return get_crtc_property (pipe->display->drm_fd, - pipe->crtc_id, - name, - prop_id, value, prop); -} -static uint32_t igt_plane_get_fb_id (igt_plane_t *plane) {return plane->values[IGT_PLANE_FB_ID ];
lib/igt_kms.h +0 -3
@@ -372,9 +372,6 @@ igt_plane_t *igt_output_get_plane_type(igt_output_t *output, int plane_type);igt_output_t *igt_output_from_connector (igt_display_t *display,drmModeConnector *connector);igt_plane_t *igt_pipe_get_plane_type (igt_pipe_t *pipe,int plane_type); -bool igt_pipe_get_property (igt_pipe_t *pipe,const char *name, -uint32_t *prop_id,uint64_t *value, -drmModePropertyPtr *prop);void igt_pipe_request_out_fence (igt_pipe_t *pipe);
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 12/12 tests/kms_atomic: Convert/rewrite tests to use igt_kms framework
In reply to Maarten LankhorstNow that we can set individual properties through the igt_kms api, we no longer need to duplicate functionality from igt_kms. Set invalid properties directly, and rewrite kms_atomic.c to use igt_display. This will allow us to remove a lot of code in kms_atomic.c, and benefit from how igt_kms can set up a valid configuration, instead of having to inherit it from fbcon.
--- tests/kms_atomic.c | 1668 ++++++++++++++++------------------------------------ 1 file changed, 510 insertions(+), 1158 deletions(-)
tests/kms_atomic.c +510 -1158
@@ -46,10 +46,6 @@#include "igt_aux.h" #include "sw_sync.h" -#ifndef DRM_CLIENT_CAP_ATOMIC -#define DRM_CLIENT_CAP_ATOMIC 3 -#endif -#ifndef DRM_CAP_CURSOR_WIDTH #define DRM_CAP_CURSOR_WIDTH 0x8#endif
@@ -58,23 +54,6 @@#define DRM_CAP_CURSOR_HEIGHT 0x9#endif -#ifndef DRM_MODE_ATOMIC_TEST_ONLY -#define DRM_MODE_ATOMIC_TEST_ONLY 0x0100 -#define DRM_MODE_ATOMIC_NONBLOCK 0x0200 -#define DRM_MODE_ATOMIC_ALLOW_MODESET 0x0400 - -struct drm_mode_atomic { -__u32 flags; -__u32 count_objs; -__u64 objs_ptr; -__u64 count_props_ptr; -__u64 props_ptr; -__u64 prop_values_ptr; -__u64 reserved; -__u64 user_data; -}; -#endif -IGT_TEST_DESCRIPTION ("Test atomic modesetting API" );enum kms_atomic_check_relax {
@@ -83,1259 +62,652 @@ enum kms_atomic_check_relax {PLANE_RELAX_FB = (1 <<1 ) }; -/** -* KMS plane type enum -* -* KMS plane types are represented by enums, which do not have stable numeric -* values, but must be looked up by their string value each time. -* -* To make the code more simple, we define a plane_type enum which maps to -* each KMS enum value. These values must be looked up through the map, and -* cannot be passed directly to KMS functions. -*/ -enum plane_type { -PLANE_TYPE_PRIMARY =0 , -PLANE_TYPE_OVERLAY , -PLANE_TYPE_CURSOR , -NUM_PLANE_TYPE_PROPS -}; - -static const char *plane_type_prop_names[NUM_PLANE_TYPE_PROPS ] = { -"Primary" , -"Overlay" , -"Cursor" -}; - -struct kms_atomic_blob { -uint32_t id;/* 0 if not already allocated */ -size_t len; -void *data; -}; - -struct kms_atomic_connector_state { -struct kms_atomic_state *state; -uint32_t obj; -uint32_t crtc_id; -}; - -struct kms_atomic_plane_state { -struct kms_atomic_state *state; -uint32_t obj; -enum plane_type type; -uint32_t crtc_mask; -uint32_t crtc_id;/* 0 to disable */ -uint32_t fb_id;/* 0 to disable */ -uint32_t src_x, src_y, src_w, src_h;/* 16.16 fixed-point */ -uint32_t crtc_x, crtc_y, crtc_w, crtc_h;/* normal integers */ -int32_t fence_fd; -}; - -struct kms_atomic_crtc_state { -struct kms_atomic_state *state; -uint32_t obj; -int idx; -bool active; -int32_t *out_fence_ptr; -struct kms_atomic_blob mode; -}; - -struct kms_atomic_state { -struct kms_atomic_connector_state *connectors; -int num_connectors; -struct kms_atomic_crtc_state *crtcs; -int num_crtcs; -struct kms_atomic_plane_state *planes; -int num_planes; -struct kms_atomic_desc *desc; -}; - -struct kms_atomic_desc { -int fd; -uint32_t props_connector[IGT_NUM_CONNECTOR_PROPS ]; -uint32_t props_crtc[IGT_NUM_CRTC_PROPS ]; -uint32_t props_plane[IGT_NUM_PLANE_PROPS ]; -uint64_t props_plane_type[NUM_PLANE_TYPE_PROPS ]; -}; - -static uint32_t blob_duplicate (int fd,uint32_t id_orig) +static bool plane_filter (enum igt_atomic_plane_properties prop) { -drmModePropertyBlobPtr orig =drmModeGetPropertyBlob (fd, id_orig); -uint32_t id_new; - -igt_assert (orig); -do_or_die (drmModeCreatePropertyBlob (fd, orig->data, orig->length, - &id_new)); -drmModeFreePropertyBlob (orig); +if ((1 << prop) &IGT_PLANE_COORD_CHANGED_MASK ) +return false; -return id_new; -} - -#define crtc_set_prop (req, crtc, prop, value) \ - igt_assert_lt(0, drmModeAtomicAddProperty(req, crtc->obj, \ - crtc->state->desc->props_crtc[prop], \ - value)); - -#define plane_set_prop (req, plane, prop, value) \ - igt_assert_lt(0, drmModeAtomicAddProperty(req, plane->obj, \ - plane->state->desc->props_plane[prop], \ - value)); - -#define do_atomic_commit (fd, req, flags) \ - do_or_die(drmModeAtomicCommit(fd, req, flags, NULL)); +if (prop ==IGT_PLANE_CRTC_ID || prop ==IGT_PLANE_FB_ID ) +return false; -#define do_atomic_commit_err (fd, req, flags, err) { \ - igt_assert_neq(drmModeAtomicCommit(fd, req, flags, NULL), 0); \ - igt_assert_eq(errno, err); \ -} - -#define crtc_commit_atomic (crtc, plane, req, relax, flags) { \ - drmModeAtomicSetCursor(req, 0); \ - crtc_populate_req(crtc, req); \ - plane_populate_req(plane, req); \ - do_atomic_commit((crtc)->state->desc->fd, req, flags); \ - if (!(flags & DRM_MODE_ATOMIC_TEST_ONLY)) { \ - crtc_check_current_state(crtc, plane, relax); \ - plane_check_current_state(plane, relax); \ - } \ -} +if (prop ==IGT_PLANE_IN_FENCE_FD ) +return false; -#define crtc_commit_atomic_err (crtc, plane, crtc_old, plane_old, req, flags, relax, e) { \ - drmModeAtomicSetCursor(req, 0); \ - crtc_populate_req(crtc, req); \ - plane_populate_req(plane, req); \ - do_atomic_commit_err((crtc)->state->desc->fd, req, flags, e); \ - crtc_check_current_state(crtc_old, plane_old, relax); \ - plane_check_current_state(plane_old, relax); \ +/* Don't care about other properties */ +return true; } -#define plane_commit_atomic (plane, req, relax) { \ - drmModeAtomicSetCursor(req, 0); \ - plane_populate_req(plane, req); \ - do_atomic_commit((plane)->state->desc->fd, req, 0); \ - plane_check_current_state(plane, relax); \ -} - -#define plane_commit_atomic_err (plane, plane_old, req, relax, e) { \ - drmModeAtomicSetCursor(req, 0); \ - plane_populate_req(plane, req); \ - do_atomic_commit_err((plane)->state->desc->fd, req, 0, e); \ - plane_check_current_state(plane_old, relax); \ -} - -static void -connector_get_current_state (struct kms_atomic_connector_state *connector) -{ -drmModeObjectPropertiesPtr props; -int i; - - props =drmModeObjectGetProperties (connector->state->desc->fd, - connector->obj, -DRM_MODE_OBJECT_CONNECTOR ); -igt_assert (props); - -for (i =0 ; i < props->count_props; i++) { -uint32_t *prop_ids = connector->state->desc->props_connector; - -if (props->props[i] == prop_ids[IGT_CONNECTOR_CRTC_ID ]) - connector->crtc_id = props->prop_values[i]; - } -drmModeFreeObjectProperties (props); -} - -#if 0 -/* XXX: Checking this repeatedly actually hangs the GPU. I have literally no -* idea why. */ -static void -connector_check_current_state (struct kms_atomic_connector_state *connector) -{ -struct kms_atomic_connector_state connector_kernel; -drmModeConnectorPtr legacy; -uint32_t crtc_id; - - legacy =drmModeGetConnectorCurrent (connector->state->desc->fd, - connector->obj); -igt_assert (legacy); - -if (legacy->encoder_id) { -drmModeEncoderPtr legacy_enc; - - legacy_enc =drmModeGetEncoder (connector->state->desc->fd, - legacy->encoder_id); -igt_assert (legacy_enc); - - crtc_id = legacy_enc->crtc_id; -drmModeFreeEncoder (legacy_enc); - }else { - crtc_id =0 ; - } - -igt_assert_eq_u32 (crtc_id, connector->crtc_id); - -memcpy (&connector_kernel, connector,sizeof (connector_kernel)); -connector_get_current_state (&connector_kernel); -do_or_die (memcmp (&connector_kernel, connector, -sizeof (connector_kernel))); - -drmModeFreeConnector (legacy); -} -#endif - -static struct kms_atomic_connector_state * -find_connector (struct kms_atomic_state *state, -struct kms_atomic_crtc_state *crtc) +static void plane_get_current_state (igt_plane_t *plane,uint64_t *values) {int i; -for (i =0 ; i < state->num_connectors; i++) { -struct kms_atomic_connector_state *connector = - &state->connectors[i]; - -if (!connector->obj) +for (i =0 ; i <IGT_NUM_PLANE_PROPS ; i++) { +if (plane_filter (i)) { + values[i] =0 ;continue ; -if (crtc && connector->crtc_id != crtc->obj) -continue ; - -return connector; - } - -return NULL ; -} - -static void plane_populate_req (struct kms_atomic_plane_state *plane, -drmModeAtomicReq *req) -{ -if (plane->fence_fd) -plane_set_prop (req, plane,IGT_PLANE_IN_FENCE_FD , plane->fence_fd); - -plane_set_prop (req, plane,IGT_PLANE_CRTC_ID , plane->crtc_id); -plane_set_prop (req, plane,IGT_PLANE_FB_ID , plane->fb_id); -plane_set_prop (req, plane,IGT_PLANE_SRC_X , plane->src_x); -plane_set_prop (req, plane,IGT_PLANE_SRC_Y , plane->src_y); -plane_set_prop (req, plane,IGT_PLANE_SRC_W , plane->src_w); -plane_set_prop (req, plane,IGT_PLANE_SRC_H , plane->src_h); -plane_set_prop (req, plane,IGT_PLANE_CRTC_X , plane->crtc_x); -plane_set_prop (req, plane,IGT_PLANE_CRTC_Y , plane->crtc_y); -plane_set_prop (req, plane,IGT_PLANE_CRTC_W , plane->crtc_w); -plane_set_prop (req, plane,IGT_PLANE_CRTC_H , plane->crtc_h); -} - -static void plane_get_current_state (struct kms_atomic_plane_state *plane) -{ -struct kms_atomic_desc *desc = plane->state->desc; -drmModeObjectPropertiesPtr props; -int i; - - props =drmModeObjectGetProperties (desc->fd, plane->obj, -DRM_MODE_OBJECT_PLANE ); -igt_assert (props); - -for (i =0 ; i < props->count_props; i++) { -uint32_t *prop_ids = desc->props_plane; - -if (props->props[i] == prop_ids[IGT_PLANE_CRTC_ID ]) - plane->crtc_id = props->prop_values[i]; -else if (props->props[i] == prop_ids[IGT_PLANE_FB_ID ]) - plane->fb_id = props->prop_values[i]; -else if (props->props[i] == prop_ids[IGT_PLANE_CRTC_X ]) - plane->crtc_x = props->prop_values[i]; -else if (props->props[i] == prop_ids[IGT_PLANE_CRTC_Y ]) - plane->crtc_y = props->prop_values[i]; -else if (props->props[i] == prop_ids[IGT_PLANE_CRTC_W ]) - plane->crtc_w = props->prop_values[i]; -else if (props->props[i] == prop_ids[IGT_PLANE_CRTC_H ]) - plane->crtc_h = props->prop_values[i]; -else if (props->props[i] == prop_ids[IGT_PLANE_SRC_X ]) - plane->src_x = props->prop_values[i]; -else if (props->props[i] == prop_ids[IGT_PLANE_SRC_Y ]) - plane->src_y = props->prop_values[i]; -else if (props->props[i] == prop_ids[IGT_PLANE_SRC_W ]) - plane->src_w = props->prop_values[i]; -else if (props->props[i] == prop_ids[IGT_PLANE_SRC_H ]) - plane->src_h = props->prop_values[i]; -else if (props->props[i] == prop_ids[IGT_PLANE_TYPE ]) { -int j; - -for (j =0 ; j <ARRAY_SIZE (desc->props_plane_type); j++) { -if (props->prop_values[i] == desc->props_plane_type[j]) { - plane->type = j; -break ; - } - } } - } -drmModeFreeObjectProperties (props); + values[i] =igt_plane_get_prop (plane, i); + } } -static void plane_check_current_state (struct kms_atomic_plane_state *plane, +static void plane_check_current_state (igt_plane_t *plane,const uint64_t *values,enum kms_atomic_check_relax relax) {drmModePlanePtr legacy; -struct kms_atomic_plane_state plane_kernel; +uint64_t current_values[IGT_NUM_PLANE_PROPS ]; +int i; - legacy =drmModeGetPlane (plane->state->desc->fd, plane->obj); + legacy =drmModeGetPlane (plane->pipe->display->drm_fd, plane->drm_plane->plane_id);igt_assert (legacy); -igt_assert_eq_u32 (legacy->crtc_id, plane->crtc_id); +igt_assert_eq_u32 (legacy->crtc_id, values[IGT_PLANE_CRTC_ID ]);if (!(relax &PLANE_RELAX_FB )) -igt_assert_eq_u32 (legacy->fb_id, plane->fb_id); +igt_assert_eq_u32 (legacy->fb_id, values[IGT_PLANE_FB_ID ]); -memcpy (&plane_kernel, plane,sizeof (plane_kernel)); -plane_get_current_state (&plane_kernel); +plane_get_current_state (plane, current_values);/* Legacy cursor ioctls create their own, unknowable, internal * framebuffer which we can't reason about. */ if (relax &PLANE_RELAX_FB ) - plane_kernel.fb_id = plane->fb_id; -do_or_die (memcmp (&plane_kernel, plane,sizeof (plane_kernel))); + current_values[IGT_PLANE_FB_ID ] = values[IGT_PLANE_FB_ID ]; + +for (i =0 ; i <IGT_NUM_PLANE_PROPS ; i++) +if (!plane_filter (i)) +igt_assert_eq_u64 (current_values[i], values[i]);drmModeFreePlane (legacy); } -static void plane_commit_legacy (struct kms_atomic_plane_state *plane, +static void plane_commit (igt_plane_t *plane,enum igt_commit_style s,enum kms_atomic_check_relax relax) { -do_or_die (drmModeSetPlane (plane->state->desc->fd, plane->obj, - plane->crtc_id, - plane->fb_id,0 , - plane->crtc_x, plane->crtc_y, - plane->crtc_w, plane->crtc_h, - plane->src_x, plane->src_y, - plane->src_w, plane->src_h)); -plane_check_current_state (plane, relax); +igt_display_commit2 (plane->pipe->display, s); +plane_check_current_state (plane, plane->values, relax); } -static struct kms_atomic_plane_state * -find_plane (struct kms_atomic_state *state,enum plane_type type, -struct kms_atomic_crtc_state *crtc) +static void plane_commit_atomic_err (igt_plane_t *plane, +enum kms_atomic_check_relax relax, +int err) { -struct kms_atomic_plane_state *ret =NULL ; -int i; - -for (i =0 ; i < state->num_planes; i++) { -struct kms_atomic_plane_state *plane = &state->planes[i]; - -if (!plane->obj) -continue ; -if (type !=NUM_PLANE_TYPE_PROPS && plane->type != type) -continue ; -if (crtc && !(plane->crtc_mask & (1 << crtc->idx))) -continue ; +uint64_t current_values[IGT_NUM_PLANE_PROPS ]; -plane_get_current_state (plane); +plane_get_current_state (plane, current_values); -/* Try to find a plane that's already on this CRTC. In -* particular, this ensures that for special (primary/cursor) -* planes that can be on multiple CRTCs, we find the same -* one that the legacy ioctls will. */ -if (!crtc || plane->crtc_id == crtc->obj) -return plane; - - ret = plane; - } +igt_assert_eq (-err,igt_display_try_commit2 (plane->pipe->display,COMMIT_ATOMIC )); -return ret; +plane_check_current_state (plane, current_values, relax); } -static void crtc_populate_req (struct kms_atomic_crtc_state *crtc, -drmModeAtomicReq *req) +static bool crtc_filter (enum igt_atomic_crtc_properties prop) { -if (crtc->out_fence_ptr) -crtc_set_prop (req, crtc,IGT_CRTC_OUT_FENCE_PTR , -to_user_pointer (crtc->out_fence_ptr)); +if (prop ==IGT_CRTC_MODE_ID || prop ==IGT_CRTC_ACTIVE ) +return false; -crtc_set_prop (req, crtc,IGT_CRTC_MODE_ID , crtc->mode.id); -crtc_set_prop (req, crtc,IGT_CRTC_ACTIVE , crtc->active); +return true; } -static void crtc_get_current_state (struct kms_atomic_crtc_state *crtc) +static void crtc_get_current_state (igt_pipe_t *pipe,uint64_t *values) { -drmModeObjectPropertiesPtr props;int i; - props =drmModeObjectGetProperties (crtc->state->desc->fd, crtc->obj, -DRM_MODE_OBJECT_CRTC ); -igt_assert (props); - -for (i =0 ; i < props->count_props; i++) { -uint32_t *prop_ids = crtc->state->desc->props_crtc; - -if (props->props[i] == prop_ids[IGT_CRTC_MODE_ID ]) { -drmModePropertyBlobPtr blob; - - crtc->mode.id = props->prop_values[i]; -if (!crtc->mode.id) { - crtc->mode.len =0 ; -continue ; - } - - blob =drmModeGetPropertyBlob (crtc->state->desc->fd, - crtc->mode.id); -igt_assert (blob); -igt_assert_eq_u32 (blob->length, -sizeof (struct drm_mode_modeinfo )); - -if (!crtc->mode.data || -memcmp (crtc->mode.data, blob->data, blob->length) !=0 ) - crtc->mode.data = blob->data; - crtc->mode.len = blob->length; - } -else if (props->props[i] == prop_ids[IGT_CRTC_ACTIVE ]) { - crtc->active = props->prop_values[i]; +for (i =0 ; i <IGT_NUM_CRTC_PROPS ; i++) { +if (crtc_filter (i)) { + values[i] =0 ; +continue ; } - } -drmModeFreeObjectProperties (props); + values[i] =igt_pipe_obj_get_prop (pipe, i); + } } -static void crtc_check_current_state (struct kms_atomic_crtc_state *crtc, -struct kms_atomic_plane_state *primary, +static void crtc_check_current_state (igt_pipe_t *pipe, +const uint64_t *pipe_values, +const uint64_t *primary_values,enum kms_atomic_check_relax relax) { -struct kms_atomic_crtc_state crtc_kernel; +uint64_t current_pipe_values[IGT_NUM_CRTC_PROPS ];drmModeCrtcPtr legacy; +drmModePropertyBlobRes *mode_prop =NULL ; +struct drm_mode_modeinfo *mode =NULL ; - legacy =drmModeGetCrtc (crtc->state->desc->fd, crtc->obj); -igt_assert (legacy); - -igt_assert_eq_u32 (legacy->crtc_id, crtc->obj); -igt_assert_eq_u32 (legacy->x, primary->src_x >>16 ); -igt_assert_eq_u32 (legacy->y, primary->src_y >>16 ); - -if (crtc->active) -igt_assert_eq_u32 (legacy->buffer_id, primary->fb_id); -else -igt_assert_eq_u32 (legacy->buffer_id,0 ); +if (pipe_values[IGT_CRTC_MODE_ID ]) { + mode_prop =drmModeGetPropertyBlob (pipe->display->drm_fd, + pipe_values[IGT_CRTC_MODE_ID ]); -if (legacy->mode_valid) { -igt_assert_neq (legacy->mode_valid,0 ); -igt_assert_eq (crtc->mode.len, -sizeof (struct drm_mode_modeinfo )); -do_or_die (memcmp (&legacy->mode, crtc->mode.data, - crtc->mode.len)); -igt_assert_eq (legacy->width, legacy->mode.hdisplay); -igt_assert_eq (legacy->height, legacy->mode.vdisplay); - }else { -igt_assert_eq (legacy->mode_valid,0 ); - } +igt_assert (mode_prop); -memcpy (&crtc_kernel, crtc,sizeof (crtc_kernel)); -crtc_get_current_state (&crtc_kernel); - -if (crtc_kernel.mode.id !=0 ) -igt_assert_eq (crtc_kernel.mode.len, +igt_assert_eq (mode_prop->length,sizeof (struct drm_mode_modeinfo )); - -/* Optionally relax the check for MODE_ID: using the legacy SetCrtc -* API can potentially change MODE_ID even if the mode itself remains -* unchanged. */ -if (((relax &CRTC_RELAX_MODE ) && - (crtc_kernel.mode.id != crtc->mode.id && - crtc_kernel.mode.id !=0 && crtc->mode.id !=0 )) && -memcmp (crtc_kernel.mode.data, crtc->mode.data, -sizeof (struct drm_mode_modeinfo )) ==0 ) { - crtc_kernel.mode.id = crtc->mode.id; - crtc_kernel.mode.data = crtc->mode.data; - } - -do_or_die (memcmp (&crtc_kernel, crtc,sizeof (crtc_kernel))); - -drmModeFreeCrtc (legacy); -} - -static void crtc_commit_legacy (struct kms_atomic_crtc_state *crtc, -struct kms_atomic_plane_state *plane, -enum kms_atomic_check_relax relax) -{ -drmModeObjectPropertiesPtr props; -uint32_t *connectors; -int num_connectors =0 ; -int i; - -if (!crtc->active) { -do_or_die (drmModeSetCrtc (crtc->state->desc->fd, - crtc->obj,0 ,0 ,0 ,NULL ,0 ,NULL )); -return ; - } - - connectors =calloc (crtc->state->num_connectors, -sizeof (*connectors)); -igt_assert (connectors); - -igt_assert_neq_u32 (crtc->mode.id,0 ); - -for (i =0 ; i < crtc->state->num_connectors; i++) { -struct kms_atomic_connector_state *connector = - &crtc->state->connectors[i]; - -if (connector->crtc_id != crtc->obj) -continue ; - - connectors[num_connectors++] = connector->obj; + mode = mode_prop->data; } -do_or_die (drmModeSetCrtc (crtc->state->desc->fd, crtc->obj, - plane->fb_id, - plane->src_x >>16 , plane->src_y >>16 , - (num_connectors) ? connectors :NULL , - num_connectors, - crtc->mode.data)); -/* When doing a legacy commit, the core may update MODE_ID to be a new -* blob implicitly created by the legacy request. Hence we backfill -* the value in the state object to ensure they match. */ - props =drmModeObjectGetProperties (crtc->state->desc->fd, crtc->obj, -DRM_MODE_OBJECT_CRTC ); -igt_assert (props); - -for (i =0 ; i < props->count_props; i++) { -if (props->props[i] != - crtc->state->desc->props_crtc[IGT_CRTC_MODE_ID ]) -continue ; - crtc->mode.id = props->prop_values[i]; -break ; - } + legacy =drmModeGetCrtc (pipe->display->drm_fd, pipe->crtc_id); +igt_assert (legacy); -drmModeFreeObjectProperties (props); +igt_assert_eq_u32 (legacy->crtc_id, pipe->crtc_id); +igt_assert_eq_u32 (legacy->x, primary_values[IGT_PLANE_SRC_X ] >>16 ); +igt_assert_eq_u32 (legacy->y, primary_values[IGT_PLANE_SRC_Y ] >>16 ); -crtc_check_current_state (crtc, plane, relax); -plane_check_current_state (plane, relax); -} +igt_assert_eq_u32 (legacy->buffer_id, primary_values[IGT_PLANE_FB_ID ]); -static struct kms_atomic_crtc_state *find_crtc (struct kms_atomic_state *state, -bool must_be_enabled) -{ -int i; +if (legacy->mode_valid) { +igt_assert (mode_prop); -for (i =0 ; i < state->num_crtcs; i++) { -struct kms_atomic_crtc_state *crtc = &state->crtcs[i]; +do_or_die (memcmp (&legacy->mode, mode,sizeof (*mode))); -if (!crtc->obj) -continue ; -if (must_be_enabled && !crtc->active) -continue ; +igt_assert_eq (legacy->width, legacy->mode.hdisplay); +igt_assert_eq (legacy->height, legacy->mode.vdisplay); -crtc_get_current_state (crtc); -return crtc; +igt_assert_neq (pipe_values[IGT_CRTC_MODE_ID ],0 ); + }else { +igt_assert (!mode_prop); } -return NULL ; -} - -static void fill_obj_props (int fd,uint32_t id,int type,int num_props, -const char **prop_names,uint32_t *prop_ids) -{ -drmModeObjectPropertiesPtr props; -int i, j; +crtc_get_current_state (pipe, current_pipe_values); - props =drmModeObjectGetProperties (fd, id, type); -igt_assert (props); +/* Optionally relax the check for MODE_ID: using the legacy SetCrtc +* API can potentially change MODE_ID even if the mode itself remains +* unchanged. */ +if (relax &CRTC_RELAX_MODE && mode && current_pipe_values[IGT_CRTC_MODE_ID ] && + current_pipe_values[IGT_CRTC_MODE_ID ] != pipe_values[IGT_CRTC_MODE_ID ]) { +drmModePropertyBlobRes *cur_prop = +drmModeGetPropertyBlob (pipe->display->drm_fd, + current_pipe_values[IGT_CRTC_MODE_ID ]); -for (i =0 ; i < props->count_props; i++) { -drmModePropertyPtr prop = -drmModeGetProperty (fd, props->props[i]); +igt_assert (cur_prop); +igt_assert_eq (cur_prop->length,sizeof (struct drm_mode_modeinfo )); -for (j =0 ; j < num_props; j++) { -if (strcmp (prop->name, prop_names[j]) !=0 ) -continue ; - prop_ids[j] = props->props[i]; -break ; - } +if (!memcmp (cur_prop->data, mode,sizeof (*mode))) + current_pipe_values[IGT_CRTC_MODE_ID ] = pipe_values[IGT_CRTC_MODE_ID ]; -drmModeFreeProperty (prop); +drmModeFreePropertyBlob (cur_prop); } -drmModeFreeObjectProperties (props); -} - -static void fill_obj_prop_map (int fd,uint32_t id,int type,const char *name, -int num_enums,const char **enum_names, -uint64_t *enum_ids) -{ -drmModeObjectPropertiesPtr props; -int i, j, k; - - props =drmModeObjectGetProperties (fd, id, type); -igt_assert (props); - -for (i =0 ; i < props->count_props; i++) { -drmModePropertyPtr prop = -drmModeGetProperty (fd, props->props[i]); - -igt_assert (prop); - -if (strcmp (prop->name, name) !=0 ) { -drmModeFreeProperty (prop); -continue ; - } - -for (j =0 ; j < prop->count_enums; j++) { -struct drm_mode_property_enum *e = &prop->enums[j]; - -for (k =0 ; k < num_enums; k++) { -if (strcmp (e->name, enum_names[k]) !=0 ) -continue ; - - enum_ids[k] = e->value; -break ; - } - } +do_or_die (memcmp (pipe_values, current_pipe_values,sizeof (current_pipe_values))); -drmModeFreeProperty (prop); - } +drmModeFreeCrtc (legacy); +drmModeFreePropertyBlob (mode_prop); } -static void atomic_setup (struct kms_atomic_state *state) +static void crtc_commit (igt_pipe_t *pipe,igt_plane_t *plane, +enum igt_commit_style s, +enum kms_atomic_check_relax relax) { -struct kms_atomic_desc *desc = state->desc; -drmModeResPtr res; -drmModePlaneResPtr res_plane; -int i; - - desc->fd =drm_open_driver_master (DRIVER_ANY ); -igt_assert_fd (desc->fd); - -igt_skip_on (drmSetClientCap (desc->fd,DRM_CLIENT_CAP_ATOMIC ,1 )); - - res =drmModeGetResources (desc->fd); - res_plane =drmModeGetPlaneResources (desc->fd); -igt_assert (res); -igt_assert (res_plane); - -igt_assert_lt (0 , res->count_crtcs); - state->num_crtcs = res->count_crtcs; - state->crtcs =calloc (state->num_crtcs,sizeof (*state->crtcs)); -igt_assert (state->crtcs); - -igt_assert_lt (0 , res_plane->count_planes); - state->num_planes = res_plane->count_planes; - state->planes =calloc (state->num_planes,sizeof (*state->planes)); -igt_assert (state->planes); - -igt_assert_lt (0 , res->count_connectors); - state->num_connectors = res->count_connectors; - state->connectors =calloc (state->num_connectors, -sizeof (*state->connectors)); -igt_assert (state->connectors); - -fill_obj_props (desc->fd, res->crtcs[0 ], -DRM_MODE_OBJECT_CRTC ,IGT_NUM_CRTC_PROPS , - igt_crtc_prop_names, desc->props_crtc); - -fill_obj_props (desc->fd, res_plane->planes[0 ], -DRM_MODE_OBJECT_PLANE ,IGT_NUM_PLANE_PROPS , - igt_plane_prop_names, desc->props_plane); -fill_obj_prop_map (desc->fd, res_plane->planes[0 ], -DRM_MODE_OBJECT_PLANE ,"type" , -NUM_PLANE_TYPE_PROPS , plane_type_prop_names, - desc->props_plane_type); - -fill_obj_props (desc->fd, res->connectors[0 ], -DRM_MODE_OBJECT_CONNECTOR ,IGT_NUM_CONNECTOR_PROPS , - igt_connector_prop_names, desc->props_connector); - -for (i =0 ; i < state->num_crtcs; i++) { -struct kms_atomic_crtc_state *crtc = &state->crtcs[i]; - - crtc->state = state; - crtc->obj = res->crtcs[i]; - crtc->idx = i; -crtc_get_current_state (crtc); - -/* The blob pointed to by MODE_ID could well be transient, -* and lose its last reference as we switch away from it. -* Duplicate the blob here so we have a reference we know we -* own. */ -if (crtc->mode.id !=0 ) - crtc->mode.id =blob_duplicate (desc->fd, crtc->mode.id); - } - -for (i =0 ; i < state->num_planes; i++) { -drmModePlanePtr plane = -drmModeGetPlane (desc->fd, res_plane->planes[i]); -igt_assert (plane); - - state->planes[i].state = state; - state->planes[i].obj = res_plane->planes[i]; - state->planes[i].crtc_mask = plane->possible_crtcs; -plane_get_current_state (&state->planes[i]); - } +igt_display_commit2 (pipe->display, s); -for (i =0 ; i < state->num_connectors; i++) { - state->connectors[i].state = state; - state->connectors[i].obj = res->connectors[i]; -connector_get_current_state (&state->connectors[i]); - } - -drmModeFreePlaneResources (res_plane); -drmModeFreeResources (res); +crtc_check_current_state (pipe, pipe->values, plane->values, relax); +plane_check_current_state (plane, plane->values, relax); } -static struct kms_atomic_state * -atomic_state_dup (const struct kms_atomic_state *state) +static void crtc_commit_atomic_flags_err (igt_pipe_t *pipe,igt_plane_t *plane, +unsigned flags, +enum kms_atomic_check_relax relax, +int err) { -struct kms_atomic_state *ret =calloc (1 ,sizeof (*ret)); - -igt_assert (ret); - *ret = *state; - - ret->crtcs =calloc (ret->num_crtcs,sizeof (*ret->crtcs)); -igt_assert (ret->crtcs); -memcpy (ret->crtcs, state->crtcs, ret->num_crtcs *sizeof (*ret->crtcs)); +uint64_t current_pipe_values[IGT_NUM_CRTC_PROPS ]; +uint64_t current_plane_values[IGT_NUM_PLANE_PROPS ]; - ret->planes =calloc (ret->num_planes,sizeof (*ret->planes)); -igt_assert (ret->planes); -memcpy (ret->planes, state->planes, - ret->num_planes *sizeof (*ret->planes)); +crtc_get_current_state (pipe, current_pipe_values); +plane_get_current_state (plane, current_plane_values); - ret->connectors =calloc (ret->num_connectors,sizeof (*ret->connectors)); -igt_assert (ret->connectors); -memcpy (ret->connectors, state->connectors, - ret->num_connectors *sizeof (*ret->connectors)); +igt_assert_eq (-err,igt_display_try_commit_atomic (pipe->display, flags,NULL )); -return ret; +crtc_check_current_state (pipe, current_pipe_values, current_plane_values, relax); +plane_check_current_state (plane, current_plane_values, relax); } -static void atomic_state_free (struct kms_atomic_state *state) -{ -free (state->crtcs); -free (state->planes); -free (state->connectors); -free (state); -} +#define crtc_commit_atomic_err (pipe, plane, relax, err) \ + crtc_commit_atomic_flags_err(pipe, plane, DRM_MODE_ATOMIC_ALLOW_MODESET, relax, err) -static uint32_t plane_get_igt_format (struct kms_atomic_plane_state *plane) +static uint32_t plane_get_igt_format (igt_plane_t *plane) {drmModePlanePtr plane_kms;const uint32_t *igt_formats; -uint32_t ret =0 ;int num_igt_formats;int i; - plane_kms =drmModeGetPlane (plane->state->desc->fd, plane->obj); -igt_assert (plane_kms); + plane_kms = plane->drm_plane;igt_get_all_cairo_formats (&igt_formats, &num_igt_formats);for (i =0 ; i < num_igt_formats; i++) {int j;for (j =0 ; j < plane_kms->count_formats; j++) { -if (plane_kms->formats[j] == igt_formats[i]) { - ret = plane_kms->formats[j]; -break ; - } +if (plane_kms->formats[j] == igt_formats[i]) +return plane_kms->formats[j]; } } -drmModeFreePlane (plane_kms); -return ret; +return 0 ; }static void -set_dpms (int fd,int mode) +set_dpms (igt_output_t *output,int mode) { -int i; -drmModeConnector *connector; -uint32_t id; -drmModeRes *resources =drmModeGetResources (fd); - -for (i =0 ; i < resources->count_connectors; i++) { - id = resources->connectors[i]; - - connector =drmModeGetConnectorCurrent (fd, id); - -kmstest_set_connector_dpms (fd, connector, mode); - -drmModeFreeConnector (connector); - } +do_or_die (drmModeConnectorSetProperty (output->display->drm_fd, output->id, + output->props[IGT_CONNECTOR_DPMS ], mode)); } -static void plane_overlay (struct kms_atomic_crtc_state *crtc, -struct kms_atomic_plane_state *plane_old) +static void plane_overlay (igt_pipe_t *pipe,igt_output_t *output,igt_plane_t *plane) { -struct drm_mode_modeinfo *mode = crtc->mode.data; -struct kms_atomic_plane_state plane = *plane_old; -uint32_t format =plane_get_igt_format (&plane); -drmModeAtomicReq *req =drmModeAtomicAlloc (); +drmModeModeInfo *mode =igt_output_get_mode (output); +uint32_t format =plane_get_igt_format (plane);struct igt_fb fb; +uint32_t w = mode->hdisplay /2 ; +uint32_t h = mode->vdisplay /2 ; -igt_require (req);igt_require (format !=0 ); - plane.src_x =0 ; - plane.src_y =0 ; - plane.src_w = (mode->hdisplay /2 ) <<16 ; - plane.src_h = (mode->vdisplay /2 ) <<16 ; - plane.crtc_x = mode->hdisplay /4 ; - plane.crtc_y = mode->vdisplay /4 ; - plane.crtc_w = mode->hdisplay /2 ; - plane.crtc_h = mode->vdisplay /2 ; - plane.crtc_id = crtc->obj; - plane.fb_id =igt_create_pattern_fb (plane.state->desc->fd, - plane.crtc_w, plane.crtc_h, - format,I915_TILING_NONE , &fb); +igt_create_pattern_fb (pipe->display->drm_fd, w, h, + format,I915_TILING_NONE , &fb); + +igt_plane_set_fb (plane, &fb); +igt_plane_set_position (plane, w/2 , h/2 );/* Enable the overlay plane using the atomic API, and double-check * state is what we think it should be. */ -plane_commit_atomic (&plane, req,ATOMIC_RELAX_NONE ); +plane_commit (plane,COMMIT_ATOMIC ,ATOMIC_RELAX_NONE );/* Disable the plane and check the state matches the old. */ -plane_commit_atomic (plane_old, req,ATOMIC_RELAX_NONE ); +igt_plane_set_fb (plane,NULL ); +igt_plane_set_position (plane,0 ,0 ); +plane_commit (plane,COMMIT_ATOMIC ,ATOMIC_RELAX_NONE );/* Re-enable the plane through the legacy plane API, and verify through * atomic. */ -plane_commit_legacy (&plane,ATOMIC_RELAX_NONE ); +igt_plane_set_fb (plane, &fb); +igt_plane_set_position (plane, w/2 , h/2 ); +plane_commit (plane,COMMIT_LEGACY ,ATOMIC_RELAX_NONE );/* Restore the plane to its original settings through the legacy plane * API, and verify through atomic. */ -plane_commit_legacy (plane_old,ATOMIC_RELAX_NONE ); +igt_plane_set_fb (plane,NULL ); +igt_plane_set_position (plane,0 ,0 ); +plane_commit (plane,COMMIT_LEGACY ,ATOMIC_RELAX_NONE ); -drmModeAtomicFree (req); +igt_remove_fb (pipe->display->drm_fd, &fb); } -static void plane_primary (struct kms_atomic_crtc_state *crtc, -struct kms_atomic_plane_state *plane_old) +static void plane_primary (igt_pipe_t *pipe,igt_plane_t *plane,struct igt_fb *fb) { -struct drm_mode_modeinfo *mode = crtc->mode.data; -struct kms_atomic_plane_state plane = *plane_old; -uint32_t format =plane_get_igt_format (&plane); -drmModeAtomicReq *req =drmModeAtomicAlloc (); -struct igt_fb fb; -uint32_t flags =0 ; -int ret; - -igt_require (format !=0 ); +struct igt_fb fb2; - plane.src_x =0 ; - plane.src_y =0 ; - plane.src_w = mode->hdisplay <<16 ; - plane.src_h = mode->vdisplay <<16 ; - plane.crtc_x =0 ; - plane.crtc_y =0 ; - plane.crtc_w = mode->hdisplay; - plane.crtc_h = mode->vdisplay; - plane.crtc_id = crtc->obj; - plane.fb_id =igt_create_pattern_fb (plane.state->desc->fd, - plane.crtc_w, plane.crtc_h, - format,I915_TILING_NONE , &fb); - -drmModeAtomicSetCursor (req,0 ); -crtc_populate_req (crtc, req); -plane_populate_req (&plane, req); - ret =drmModeAtomicCommit (crtc->state->desc->fd, req, -DRM_MODE_ATOMIC_TEST_ONLY ,NULL ); -/* Try harder in case the failure is caused by disallowing modeset. */ -if (ret == -EINVAL ) - flags |=DRM_MODE_ATOMIC_ALLOW_MODESET ; +igt_create_color_pattern_fb (pipe->display->drm_fd, + fb->width, fb->height, + fb->drm_format,I915_TILING_NONE , +0.2 ,0.2 ,0.2 , &fb2);/* Flip the primary plane using the atomic API, and double-check * state is what we think it should be. */ -crtc_commit_atomic (crtc, &plane, req,ATOMIC_RELAX_NONE , flags); +igt_plane_set_fb (plane, &fb2); +crtc_commit (pipe, plane,COMMIT_ATOMIC ,ATOMIC_RELAX_NONE );/* Restore the primary plane and check the state matches the old. */ -crtc_commit_atomic (crtc, plane_old, req,ATOMIC_RELAX_NONE , flags); +igt_plane_set_fb (plane, fb); +crtc_commit (pipe, plane,COMMIT_ATOMIC ,ATOMIC_RELAX_NONE ); -/* Re-enable the plane through the legacy CRTC/primary-plane API, and +/* Set the plane through the legacy CRTC/primary-plane API, and * verify through atomic. */ -crtc_commit_legacy (crtc, &plane,CRTC_RELAX_MODE ); +igt_plane_set_fb (plane, &fb2); +crtc_commit (pipe, plane,COMMIT_LEGACY ,CRTC_RELAX_MODE );/* Restore the plane to its original settings through the legacy CRTC * API, and verify through atomic. */ -crtc_commit_legacy (crtc, plane_old,CRTC_RELAX_MODE ); +igt_plane_set_fb (plane, fb); +crtc_commit (pipe, plane,COMMIT_LEGACY ,CRTC_RELAX_MODE ); -/* Finally, restore to the original state. */ -crtc_commit_atomic (crtc, plane_old, req,ATOMIC_RELAX_NONE , flags); - -drmModeAtomicFree (req); +/* Set the plane through the universal setplane API, and +* verify through atomic. */ +igt_plane_set_fb (plane, &fb2); +plane_commit (plane,COMMIT_UNIVERSAL ,ATOMIC_RELAX_NONE ); }/* test to ensure that DRM_MODE_ATOMIC_TEST_ONLY really only touches the * free-standing state objects and nothing else. */ -static void test_only (struct kms_atomic_crtc_state *crtc, -struct kms_atomic_plane_state *plane_old) +static void test_only (igt_pipe_t *pipe_obj, +igt_plane_t *primary, +igt_output_t *output) { -struct drm_mode_modeinfo *mode = crtc->mode.data; -struct kms_atomic_plane_state plane = *plane_old; -uint32_t format =plane_get_igt_format (&plane); -drmModeAtomicReq *req =drmModeAtomicAlloc (); +drmModeModeInfo *mode =igt_output_get_mode (output); +uint32_t format =plane_get_igt_format (primary);struct igt_fb fb; -int ret; +uint64_t old_plane_values[IGT_NUM_PLANE_PROPS ], old_crtc_values[IGT_NUM_CRTC_PROPS ];igt_require (format !=0 ); - plane.src_x =0 ; - plane.src_y =0 ; - plane.src_w = mode->hdisplay <<16 ; - plane.src_h = mode->vdisplay <<16 ; - plane.crtc_x =0 ; - plane.crtc_y =0 ; - plane.crtc_w = mode->hdisplay; - plane.crtc_h = mode->vdisplay; - plane.crtc_id = crtc->obj; - plane.fb_id =igt_create_pattern_fb (plane.state->desc->fd, - plane.crtc_w, plane.crtc_h, - format,I915_TILING_NONE , &fb); - -drmModeAtomicSetCursor (req,0 ); -crtc_populate_req (crtc, req); -plane_populate_req (&plane, req); - ret =drmModeAtomicCommit (crtc->state->desc->fd, req, -DRM_MODE_ATOMIC_TEST_ONLY ,NULL ); - -igt_assert_eq (ret,0 ); - -/* go through dpms off/on cycle */ -set_dpms (crtc->state->desc->fd,DRM_MODE_DPMS_OFF ); -set_dpms (crtc->state->desc->fd,DRM_MODE_DPMS_ON ); - -/* check the state */ -crtc_check_current_state (crtc, plane_old,ATOMIC_RELAX_NONE ); -plane_check_current_state (plane_old,ATOMIC_RELAX_NONE ); - -/* Re-enable the plane through the legacy CRTC/primary-plane API, and -* verify through atomic. */ -crtc_commit_legacy (crtc, plane_old,CRTC_RELAX_MODE ); +plane_get_current_state (primary, old_plane_values); +crtc_get_current_state (pipe_obj, old_crtc_values); + +igt_assert (!old_crtc_values[IGT_CRTC_MODE_ID ]); + +igt_create_pattern_fb (pipe_obj->display->drm_fd, + mode->hdisplay, mode->vdisplay, + format,I915_TILING_NONE , &fb); +igt_plane_set_fb (primary, &fb); +igt_output_set_pipe (output, pipe_obj->pipe); + +igt_display_commit_atomic (pipe_obj->display,DRM_MODE_ATOMIC_TEST_ONLY |DRM_MODE_ATOMIC_ALLOW_MODESET ,NULL ); + +/* check the state, should still be old state */ +crtc_check_current_state (pipe_obj, old_crtc_values, old_plane_values,ATOMIC_RELAX_NONE ); +plane_check_current_state (primary, old_plane_values,ATOMIC_RELAX_NONE ); + +/* +* Enable the plane through the legacy CRTC/primary-plane API, and +* verify through atomic. +*/ +crtc_commit (pipe_obj, primary,COMMIT_LEGACY ,CRTC_RELAX_MODE ); + +/* Same for disable.. */ +plane_get_current_state (primary, old_plane_values); +crtc_get_current_state (pipe_obj, old_crtc_values); + +igt_plane_set_fb (primary,NULL ); +igt_output_set_pipe (output,PIPE_NONE ); -drmModeAtomicFree (req); +igt_display_commit_atomic (pipe_obj->display,DRM_MODE_ATOMIC_TEST_ONLY |DRM_MODE_ATOMIC_ALLOW_MODESET ,NULL ); + +/* for extra stress, go through dpms off/on cycle */ +set_dpms (output,DRM_MODE_DPMS_OFF ); +set_dpms (output,DRM_MODE_DPMS_ON ); + +/* check the state, should still be old state */ +crtc_check_current_state (pipe_obj, old_crtc_values, old_plane_values,ATOMIC_RELAX_NONE ); +plane_check_current_state (primary, old_plane_values,ATOMIC_RELAX_NONE ); + +/* And disable the pipe and remove fb, test complete */ +crtc_commit (pipe_obj, primary,COMMIT_ATOMIC ,ATOMIC_RELAX_NONE ); +igt_remove_fb (pipe_obj->display->drm_fd, &fb); } -static void plane_cursor (struct kms_atomic_crtc_state *crtc, -struct kms_atomic_plane_state *plane_old) +static void plane_cursor (igt_pipe_t *pipe_obj, +igt_output_t *output, +igt_plane_t *cursor) { -struct drm_mode_modeinfo *mode = crtc->mode.data; -struct kms_atomic_plane_state plane = *plane_old; -drmModeAtomicReq *req =drmModeAtomicAlloc (); +drmModeModeInfo *mode =igt_output_get_mode (output);struct igt_fb fb;uint64_t width, height; - -igt_assert (req); +int x = mode->hdisplay /2 ; +int y = mode->vdisplay /2 ;/* Any kernel new enough for atomic, also has the cursor size caps. */ -do_or_die (drmGetCap (plane.state->desc->fd, +do_or_die (drmGetCap (pipe_obj->display->drm_fd,DRM_CAP_CURSOR_WIDTH , &width)); -do_or_die (drmGetCap (plane.state->desc->fd, +do_or_die (drmGetCap (pipe_obj->display->drm_fd,DRM_CAP_CURSOR_HEIGHT , &height)); - plane.src_x =0 ; - plane.src_y =0 ; - plane.src_w = width <<16 ; - plane.src_h = height <<16 ; - plane.crtc_x = mode->hdisplay /2 ; - plane.crtc_y = mode->vdisplay /2 ; - plane.crtc_w = width; - plane.crtc_h = height; - plane.crtc_id = crtc->obj; - plane.fb_id =igt_create_color_fb (plane.state->desc->fd, - width, height, -DRM_FORMAT_ARGB8888 , -LOCAL_DRM_FORMAT_MOD_NONE , -0.0 ,0.0 ,0.0 , - &fb); -igt_assert_neq_u32 (plane.fb_id,0 ); +igt_create_color_fb (pipe_obj->display->drm_fd, + width, height,DRM_FORMAT_ARGB8888 , +LOCAL_DRM_FORMAT_MOD_NONE , +0.0 ,0.0 ,0.0 , &fb);/* Flip the cursor plane using the atomic API, and double-check * state is what we think it should be. */ -plane_commit_atomic (&plane, req,ATOMIC_RELAX_NONE ); +igt_plane_set_fb (cursor, &fb); +igt_plane_set_position (cursor, x, y); +plane_commit (cursor,COMMIT_ATOMIC ,ATOMIC_RELAX_NONE );/* Restore the cursor plane and check the state matches the old. */ -plane_commit_atomic (plane_old, req,ATOMIC_RELAX_NONE ); +igt_plane_set_fb (cursor,NULL ); +igt_plane_set_position (cursor,0 ,0 ); +plane_commit (cursor,COMMIT_ATOMIC ,ATOMIC_RELAX_NONE );/* Re-enable the plane through the legacy cursor API, and verify * through atomic. */ -do_or_die (drmModeMoveCursor (plane.state->desc->fd, plane.crtc_id, - plane.crtc_x, plane.crtc_y)); -do_or_die (drmModeSetCursor (plane.state->desc->fd, plane.crtc_id, - fb.gem_handle, width, height)); -plane_check_current_state (&plane,PLANE_RELAX_FB ); +igt_plane_set_fb (cursor, &fb); +igt_plane_set_position (cursor, x, y); +plane_commit (cursor,COMMIT_LEGACY ,PLANE_RELAX_FB );/* Wiggle. */ - plane.crtc_x -=16 ; - plane.crtc_y -=16 ; -do_or_die (drmModeMoveCursor (plane.state->desc->fd, plane.crtc_id, - plane.crtc_x, plane.crtc_y)); -plane_check_current_state (&plane,PLANE_RELAX_FB ); +igt_plane_set_position (cursor, x -16 , y -16 ); +plane_commit (cursor,COMMIT_LEGACY ,PLANE_RELAX_FB );/* Restore the plane to its original settings through the legacy cursor * API, and verify through atomic. */ -do_or_die (drmModeSetCursor2 (plane.state->desc->fd, plane.crtc_id, -0 ,0 ,0 ,0 ,0 )); -plane_check_current_state (plane_old,ATOMIC_RELAX_NONE ); - -/* Finally, restore to the original state. */ -plane_commit_atomic (plane_old, req,ATOMIC_RELAX_NONE ); - -drmModeAtomicFree (req); +igt_plane_set_fb (cursor,NULL ); +igt_plane_set_position (cursor,0 ,0 ); +plane_commit (cursor,COMMIT_LEGACY ,ATOMIC_RELAX_NONE ); } -static void plane_invalid_params (struct kms_atomic_crtc_state *crtc, -struct kms_atomic_plane_state *plane_old, -struct kms_atomic_connector_state *conn) +static void plane_invalid_params (igt_pipe_t *pipe, +igt_output_t *output, +igt_plane_t *plane, +struct igt_fb *fb) { -struct drm_mode_modeinfo *mode = crtc->mode.data; -struct kms_atomic_plane_state plane = *plane_old; -uint32_t format =plane_get_igt_format (&plane); -drmModeAtomicReq *req =drmModeAtomicAlloc (); -struct igt_fb fb; +struct igt_fb fb2;/* Pass a series of invalid object IDs for the FB ID. */ - plane.fb_id = plane.obj; -plane_commit_atomic_err (&plane, plane_old, req, -ATOMIC_RELAX_NONE ,EINVAL ); +igt_plane_set_prop_value (plane,IGT_PLANE_FB_ID , plane->drm_plane->plane_id); +plane_commit_atomic_err (plane,ATOMIC_RELAX_NONE ,EINVAL ); - plane.fb_id = crtc->obj; -plane_commit_atomic_err (&plane, plane_old, req, -ATOMIC_RELAX_NONE ,EINVAL ); +igt_plane_set_prop_value (plane,IGT_PLANE_FB_ID , pipe->crtc_id); +plane_commit_atomic_err (plane,ATOMIC_RELAX_NONE ,EINVAL ); - plane.fb_id = conn->obj; -plane_commit_atomic_err (&plane, plane_old, req, -ATOMIC_RELAX_NONE ,EINVAL ); +igt_plane_set_prop_value (plane,IGT_PLANE_FB_ID , output->id); +plane_commit_atomic_err (plane,ATOMIC_RELAX_NONE ,EINVAL ); - plane.fb_id = crtc->mode.id; -plane_commit_atomic_err (&plane, plane_old, req, -ATOMIC_RELAX_NONE ,EINVAL ); +igt_plane_set_prop_value (plane,IGT_PLANE_FB_ID , pipe->values[IGT_CRTC_MODE_ID ]); +plane_commit_atomic_err (plane,ATOMIC_RELAX_NONE ,EINVAL ); - plane.fb_id = plane_old->fb_id; -plane_commit_atomic (&plane, req,ATOMIC_RELAX_NONE ); +igt_plane_set_fb (plane, fb); +plane_commit (plane,COMMIT_ATOMIC ,ATOMIC_RELAX_NONE );/* Pass a series of invalid object IDs for the CRTC ID. */ - plane.crtc_id = plane.obj; -plane_commit_atomic_err (&plane, plane_old, req, -ATOMIC_RELAX_NONE ,EINVAL ); +igt_plane_set_prop_value (plane,IGT_PLANE_CRTC_ID , plane->drm_plane->plane_id); +plane_commit_atomic_err (plane,ATOMIC_RELAX_NONE ,EINVAL ); - plane.crtc_id = plane.fb_id; -plane_commit_atomic_err (&plane, plane_old, req, -ATOMIC_RELAX_NONE ,EINVAL ); +igt_plane_set_prop_value (plane,IGT_PLANE_CRTC_ID , fb->fb_id); +plane_commit_atomic_err (plane,ATOMIC_RELAX_NONE ,EINVAL ); - plane.crtc_id = conn->obj; -plane_commit_atomic_err (&plane, plane_old, req, -ATOMIC_RELAX_NONE ,EINVAL ); +igt_plane_set_prop_value (plane,IGT_PLANE_CRTC_ID , output->id); +plane_commit_atomic_err (plane,ATOMIC_RELAX_NONE ,EINVAL ); - plane.crtc_id = crtc->mode.id; -plane_commit_atomic_err (&plane, plane_old, req, -ATOMIC_RELAX_NONE ,EINVAL ); +igt_plane_set_prop_value (plane,IGT_PLANE_CRTC_ID , pipe->values[IGT_CRTC_MODE_ID ]); +plane_commit_atomic_err (plane,ATOMIC_RELAX_NONE ,EINVAL ); - plane.crtc_id = plane_old->crtc_id; -plane_commit_atomic (&plane, req,ATOMIC_RELAX_NONE ); +igt_plane_set_fb (plane, fb); +plane_commit (plane,COMMIT_ATOMIC ,ATOMIC_RELAX_NONE );/* Create a framebuffer too small for the plane configuration. */ -igt_require (format !=0 ); +igt_create_pattern_fb (pipe->display->drm_fd, + fb->width -1 , fb->height -1 , + fb->drm_format,I915_TILING_NONE , &fb2); - plane.src_x =0 ; - plane.src_y =0 ; - plane.src_w = mode->hdisplay <<16 ; - plane.src_h = mode->vdisplay <<16 ; - plane.crtc_x =0 ; - plane.crtc_y =0 ; - plane.crtc_w = mode->hdisplay; - plane.crtc_h = mode->vdisplay; - plane.crtc_id = crtc->obj; - plane.fb_id =igt_create_pattern_fb (plane.state->desc->fd, - plane.crtc_w -1 , plane.crtc_h -1 , - format,I915_TILING_NONE , &fb); - -plane_commit_atomic_err (&plane, plane_old, req, -ATOMIC_RELAX_NONE ,ENOSPC ); +igt_plane_set_prop_value (plane,IGT_PLANE_FB_ID , fb2.fb_id); +plane_commit_atomic_err (plane,ATOMIC_RELAX_NONE ,ENOSPC );/* Restore the primary plane and check the state matches the old. */ -plane_commit_atomic (plane_old, req,ATOMIC_RELAX_NONE ); - -drmModeAtomicFree (req); +igt_plane_set_fb (plane, fb); +plane_commit (plane,COMMIT_ATOMIC ,ATOMIC_RELAX_NONE ); } -static void plane_invalid_params_fence (struct kms_atomic_crtc_state *crtc, -struct kms_atomic_plane_state *plane_old, -struct kms_atomic_connector_state *conn) +static void plane_invalid_params_fence (igt_pipe_t *pipe, +igt_output_t *output, +igt_plane_t *plane) { -struct kms_atomic_plane_state plane = *plane_old; -drmModeAtomicReq *req =drmModeAtomicAlloc ();int timeline, fence_fd;igt_require_sw_sync (); + timeline =sw_sync_timeline_create (); +/* invalid fence fd */ - plane.fence_fd = plane.state->desc->fd; - plane.crtc_id = plane_old->crtc_id; -plane_commit_atomic_err (&plane, plane_old, req, -ATOMIC_RELAX_NONE ,EINVAL ); +igt_plane_set_fence_fd (plane, pipe->display->drm_fd); +plane_commit_atomic_err (plane,ATOMIC_RELAX_NONE ,EINVAL );/* Valid fence_fd but invalid CRTC */ - timeline =sw_sync_timeline_create (); - fence_fd =sw_sync_timeline_create_fence (timeline,1 ); - plane.fence_fd = fence_fd; - plane.crtc_id = ~0U ; -plane_commit_atomic_err (&plane, plane_old, req, -ATOMIC_RELAX_NONE ,EINVAL ); + fence_fd =sw_sync_timeline_create_fence (timeline,1 ); + +igt_plane_set_prop_value (plane,IGT_PLANE_CRTC_ID , ~0 ); +igt_plane_set_fence_fd (plane, fence_fd); +plane_commit_atomic_err (plane,ATOMIC_RELAX_NONE ,EINVAL ); + +sw_sync_timeline_inc (timeline,1 ); +igt_plane_set_prop_value (plane,IGT_PLANE_CRTC_ID , pipe->crtc_id); +plane_commit (plane,COMMIT_ATOMIC ,ATOMIC_RELAX_NONE ); - plane.fence_fd =-1 ;close (fence_fd);close (timeline); - -drmModeAtomicFree (req); } -static void crtc_invalid_params (struct kms_atomic_crtc_state *crtc_old, -struct kms_atomic_plane_state *plane, -struct kms_atomic_connector_state *conn) +static void crtc_invalid_params (igt_pipe_t *pipe, +igt_output_t *output, +igt_plane_t *plane, +struct igt_fb *fb) { -struct kms_atomic_crtc_state crtc = *crtc_old; -drmModeAtomicReq *req =drmModeAtomicAlloc (); - -igt_assert (req); +uint64_t old_mode_id = pipe->values[IGT_CRTC_MODE_ID ]; +drmModeModeInfo *mode =igt_output_get_mode (output);/* Pass a series of invalid object IDs for the mode ID. */ - crtc.mode.id = plane->obj; -crtc_commit_atomic_err (&crtc, plane, crtc_old, plane, req,0 , -ATOMIC_RELAX_NONE ,EINVAL ); +igt_pipe_obj_set_prop_value (pipe,IGT_CRTC_MODE_ID , plane->drm_plane->plane_id); +crtc_commit_atomic_err (pipe, plane,ATOMIC_RELAX_NONE ,EINVAL ); - crtc.mode.id = crtc.obj; -crtc_commit_atomic_err (&crtc, plane, crtc_old, plane, req,0 , -ATOMIC_RELAX_NONE ,EINVAL ); +igt_pipe_obj_set_prop_value (pipe,IGT_CRTC_MODE_ID , pipe->crtc_id); +crtc_commit_atomic_err (pipe, plane,ATOMIC_RELAX_NONE ,EINVAL ); - crtc.mode.id = conn->obj; -crtc_commit_atomic_err (&crtc, plane, crtc_old, plane, req,0 , -ATOMIC_RELAX_NONE ,EINVAL ); +igt_pipe_obj_set_prop_value (pipe,IGT_CRTC_MODE_ID , output->id); +crtc_commit_atomic_err (pipe, plane,ATOMIC_RELAX_NONE ,EINVAL ); - crtc.mode.id = plane->fb_id; -crtc_commit_atomic_err (&crtc, plane, crtc_old, plane, req,0 , -ATOMIC_RELAX_NONE ,EINVAL ); +igt_pipe_obj_set_prop_value (pipe,IGT_CRTC_MODE_ID , fb->fb_id); +crtc_commit_atomic_err (pipe, plane,ATOMIC_RELAX_NONE ,EINVAL ); -/* successful TEST_ONLY with fences set */ - crtc.mode.id = crtc_old->mode.id; -crtc_commit_atomic (&crtc, plane, req,ATOMIC_RELAX_NONE , -DRM_MODE_ATOMIC_TEST_ONLY ); +/* Can we restore mode? */ +igt_pipe_obj_set_prop_value (pipe,IGT_CRTC_MODE_ID , old_mode_id); +crtc_commit_atomic_flags_err (pipe, plane,DRM_MODE_ATOMIC_TEST_ONLY ,ATOMIC_RELAX_NONE ,0 );/* * TEST_ONLY cannot be combined with DRM_MODE_PAGE_FLIP_EVENT, * but DRM_MODE_PAGE_FLIP_EVENT will always generate EINVAL * without valid crtc, so test it here. */ -crtc_commit_atomic_err (&crtc, plane, crtc_old, plane, req, -DRM_MODE_ATOMIC_TEST_ONLY |DRM_MODE_PAGE_FLIP_EVENT , -ATOMIC_RELAX_NONE ,EINVAL ); +crtc_commit_atomic_flags_err (pipe, plane, +DRM_MODE_ATOMIC_TEST_ONLY |DRM_MODE_PAGE_FLIP_EVENT , +ATOMIC_RELAX_NONE ,EINVAL );/* Create a blob which is the wrong size to be a valid mode. */ -do_or_die (drmModeCreatePropertyBlob (crtc.state->desc->fd, - crtc.mode.data, -sizeof (struct drm_mode_modeinfo ) -1 , - &crtc.mode.id)); -crtc_commit_atomic_err (&crtc, plane, crtc_old, plane, req,0 , -ATOMIC_RELAX_NONE ,EINVAL ); - +igt_pipe_obj_replace_prop_blob (pipe,IGT_CRTC_MODE_ID , mode,sizeof (*mode) -1 ); +crtc_commit_atomic_err (pipe, plane,ATOMIC_RELAX_NONE ,EINVAL ); -do_or_die (drmModeCreatePropertyBlob (crtc.state->desc->fd, - crtc.mode.data, -sizeof (struct drm_mode_modeinfo ) +1 , - &crtc.mode.id)); -crtc_commit_atomic_err (&crtc, plane, crtc_old, plane, req,0 , -ATOMIC_RELAX_NONE ,EINVAL ); +igt_pipe_obj_replace_prop_blob (pipe,IGT_CRTC_MODE_ID , mode,sizeof (*mode) +1 ); +crtc_commit_atomic_err (pipe, plane,ATOMIC_RELAX_NONE ,EINVAL );/* Restore the CRTC and check the state matches the old. */ -crtc_commit_atomic (crtc_old, plane, req,ATOMIC_RELAX_NONE ,0 ); - -drmModeAtomicFree (req); +igt_pipe_obj_replace_prop_blob (pipe,IGT_CRTC_MODE_ID , mode,sizeof (*mode)); +crtc_commit (pipe, plane,COMMIT_ATOMIC ,ATOMIC_RELAX_NONE ); } -static void crtc_invalid_params_fence (struct kms_atomic_crtc_state *crtc_old, -struct kms_atomic_plane_state *plane, -struct kms_atomic_connector_state *conn) +static void crtc_invalid_params_fence (igt_pipe_t *pipe, +igt_output_t *output, +igt_plane_t *plane, +struct igt_fb *fb) { -struct kms_atomic_crtc_state crtc = *crtc_old; -drmModeAtomicReq *req =drmModeAtomicAlloc (); -int timeline, fence_fd, *out_fence; +int timeline, fence_fd; +void *map; +const ptrdiff_t PAGE_SIZE =sysconf (_SC_PAGE_SIZE); +uint64_t old_mode_id = pipe->values[IGT_CRTC_MODE_ID ];igt_require_sw_sync (); + timeline =sw_sync_timeline_create (); + +/* invalid out_fence_ptr */ + map =mmap (NULL ,PAGE_SIZE ,PROT_READ ,MAP_ANONYMOUS |MAP_PRIVATE ,-1 ,0 ); +igt_assert (map !=MAP_FAILED ); + +igt_pipe_obj_set_prop_value (pipe,IGT_CRTC_OUT_FENCE_PTR , (ptrdiff_t )map); +crtc_commit_atomic_err (pipe, plane,ATOMIC_RELAX_NONE ,EFAULT ); +munmap (map,PAGE_SIZE ); +/* invalid out_fence_ptr */ - crtc.mode.id = crtc_old->mode.id; - crtc.out_fence_ptr = (int32_t *) crtc_invalid_params; -crtc_commit_atomic_err (&crtc, plane, crtc_old, plane, req,0 , -ATOMIC_RELAX_NONE ,EFAULT ); + map =mmap (NULL ,PAGE_SIZE ,PROT_EXEC ,MAP_ANONYMOUS |MAP_PRIVATE ,-1 ,0 ); +igt_assert (map !=MAP_FAILED ); + +igt_pipe_obj_set_prop_value (pipe,IGT_CRTC_OUT_FENCE_PTR , (ptrdiff_t )map); +crtc_commit_atomic_err (pipe, plane,ATOMIC_RELAX_NONE ,EFAULT ); +munmap (map,PAGE_SIZE );/* invalid out_fence_ptr */ - crtc.mode.id = crtc_old->mode.id; - crtc.out_fence_ptr = (int32_t *)0x8 ; -crtc_commit_atomic_err (&crtc, plane, crtc_old, plane, req,0 , -ATOMIC_RELAX_NONE ,EFAULT ); - crtc.out_fence_ptr = (int32_t *)0 ; + map =mmap (NULL ,PAGE_SIZE ,PROT_NONE ,MAP_ANONYMOUS |MAP_PRIVATE ,-1 ,0 ); +igt_assert (map !=MAP_FAILED ); + +igt_pipe_obj_set_prop_value (pipe,IGT_CRTC_OUT_FENCE_PTR , (ptrdiff_t )map); +crtc_commit_atomic_err (pipe, plane,ATOMIC_RELAX_NONE ,EFAULT ); +munmap (map,PAGE_SIZE );/* valid in fence but not allowed prop on crtc */ - timeline =sw_sync_timeline_create (); - fence_fd =sw_sync_timeline_create_fence (timeline,1 ); - plane->fence_fd = fence_fd; - crtc.active = false; -crtc_commit_atomic_err (&crtc, plane, crtc_old, plane, req,0 , -ATOMIC_RELAX_NONE ,EINVAL ); + fence_fd =sw_sync_timeline_create_fence (timeline,1 ); +igt_plane_set_fence_fd (plane, fence_fd); - out_fence =malloc (sizeof (uint64_t )); -igt_assert (out_fence); +igt_pipe_obj_set_prop_value (pipe,IGT_CRTC_ACTIVE ,0 ); +igt_pipe_obj_clear_prop_changed (pipe,IGT_CRTC_OUT_FENCE_PTR ); +crtc_commit_atomic_flags_err (pipe, plane,0 ,ATOMIC_RELAX_NONE ,EINVAL );/* valid out fence ptr and flip event but not allowed prop on crtc */ - crtc.out_fence_ptr = (int32_t *) out_fence; -crtc_commit_atomic_err (&crtc, plane, crtc_old, plane, req,0 , -ATOMIC_RELAX_NONE ,EINVAL ); +igt_pipe_request_out_fence (pipe); +crtc_commit_atomic_flags_err (pipe, plane,DRM_MODE_PAGE_FLIP_EVENT , +ATOMIC_RELAX_NONE ,EINVAL ); -/* valid out fence ptr and flip event but not allowed prop on crtc */ -crtc_commit_atomic_err (&crtc, plane, crtc_old, plane, req, -DRM_MODE_PAGE_FLIP_EVENT , -ATOMIC_RELAX_NONE ,EINVAL ); - -/* valid page flip event but not allowed prop on crtc */ - crtc.out_fence_ptr = (int32_t *)0 ; -crtc_commit_atomic_err (&crtc, plane, crtc_old, plane, req, -DRM_MODE_PAGE_FLIP_EVENT , -ATOMIC_RELAX_NONE ,EINVAL ); - crtc.active = true; - -/* valid out fence ptr and flip event but invalid prop on crtc */ - crtc.out_fence_ptr = (int32_t *) out_fence; - crtc.mode.id = plane->fb_id; -crtc_commit_atomic_err (&crtc, plane, crtc_old, plane, req,0 , -ATOMIC_RELAX_NONE ,EINVAL ); +/* valid flip event but not allowed prop on crtc */ +igt_pipe_obj_clear_prop_changed (pipe,IGT_CRTC_OUT_FENCE_PTR ); +crtc_commit_atomic_flags_err (pipe, plane,DRM_MODE_PAGE_FLIP_EVENT , +ATOMIC_RELAX_NONE ,EINVAL ); + +igt_pipe_obj_set_prop_value (pipe,IGT_CRTC_ACTIVE ,1 ); + +/* Configuration should be valid again */ +crtc_commit_atomic_flags_err (pipe, plane,DRM_MODE_ATOMIC_TEST_ONLY , +ATOMIC_RELAX_NONE ,0 ); + +/* Set invalid prop */ +igt_pipe_obj_set_prop_value (pipe,IGT_CRTC_MODE_ID , fb->fb_id); + +/* valid out fence but invalid prop on crtc */ +igt_pipe_request_out_fence (pipe); +crtc_commit_atomic_flags_err (pipe, plane,0 , +ATOMIC_RELAX_NONE ,EINVAL );/* valid out fence ptr and flip event but invalid prop on crtc */ -crtc_commit_atomic_err (&crtc, plane, crtc_old, plane, req, -DRM_MODE_PAGE_FLIP_EVENT , -ATOMIC_RELAX_NONE ,EINVAL ); +crtc_commit_atomic_flags_err (pipe, plane,DRM_MODE_PAGE_FLIP_EVENT , +ATOMIC_RELAX_NONE ,EINVAL );/* valid page flip event but invalid prop on crtc */ - crtc.out_fence_ptr = (int32_t *)0 ; -crtc_commit_atomic_err (&crtc, plane, crtc_old, plane, req, -DRM_MODE_PAGE_FLIP_EVENT , -ATOMIC_RELAX_NONE ,EINVAL ); +crtc_commit_atomic_flags_err (pipe, plane,DRM_MODE_PAGE_FLIP_EVENT , +ATOMIC_RELAX_NONE ,EINVAL );/* successful TEST_ONLY with fences set */ - plane->fence_fd = fence_fd; - crtc.mode.id = crtc_old->mode.id; -crtc_commit_atomic (&crtc, plane, req,ATOMIC_RELAX_NONE , -DRM_MODE_ATOMIC_TEST_ONLY ); -igt_assert (*out_fence ==-1 ); +igt_pipe_obj_set_prop_value (pipe,IGT_CRTC_MODE_ID , old_mode_id); +crtc_commit_atomic_flags_err (pipe, plane,DRM_MODE_ATOMIC_TEST_ONLY , +ATOMIC_RELAX_NONE ,0 ); +igt_assert (pipe->out_fence_fd ==-1 );close (fence_fd);close (timeline);/* reset fences */ - plane->fence_fd =-1 ; - crtc.out_fence_ptr = (int32_t *)0 ; -crtc_commit_atomic (&crtc, plane, req,ATOMIC_RELAX_NONE ,0 ); +igt_plane_set_fence_fd (plane,-1 ); +igt_pipe_obj_set_prop_value (pipe,IGT_CRTC_OUT_FENCE_PTR ,0 ); +igt_pipe_obj_clear_prop_changed (pipe,IGT_CRTC_OUT_FENCE_PTR ); +crtc_commit (pipe, plane,COMMIT_ATOMIC ,ATOMIC_RELAX_NONE );/* out fence ptr but not page flip event */ - crtc.out_fence_ptr = (int32_t *) out_fence; -crtc_commit_atomic (crtc_old, plane, req,ATOMIC_RELAX_NONE ,0 ); +igt_pipe_request_out_fence (pipe); +crtc_commit (pipe, plane,COMMIT_ATOMIC ,ATOMIC_RELAX_NONE ); -close (*out_fence); -free (out_fence); -drmModeAtomicFree (req); +igt_assert (pipe->out_fence_fd !=-1 ); }/* Abuse the atomic ioctl directly in order to test various invalid conditions, * which the libdrm wrapper won't allow us to create. */ -static void atomic_invalid_params (struct kms_atomic_crtc_state *crtc, -struct kms_atomic_plane_state *plane, -struct kms_atomic_connector_state *connector) +static void atomic_invalid_params (igt_pipe_t *pipe, +igt_plane_t *plane, +igt_output_t *output, +struct igt_fb *fb) { -struct kms_atomic_desc *desc = crtc->state->desc; +igt_display_t *display = pipe->display;struct drm_mode_atomic ioc;uint32_t obj_raw[16 ];/* array of objects (sized by count_objs) */ uint32_t num_props_raw[16 ];/* array of num props per obj (ditto) */
@@ -1346,7 +718,7 @@ static void atomic_invalid_params(struct kms_atomic_crtc_state *crtc,memset (&ioc,0 ,sizeof (ioc));/* An empty request should do nothing. */ -do_ioctl (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc); +do_ioctl (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc);for (i =0 ; i <ARRAY_SIZE (obj_raw); i++) obj_raw[i] =0 ;
@@ -1363,248 +735,228 @@ static void atomic_invalid_params(struct kms_atomic_crtc_state *crtc, ioc.prop_values_ptr = (uintptr_t ) values_raw;/* Valid pointers, but still should copy nothing. */ -do_ioctl (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc); +do_ioctl (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc);/* Valid noop, but with event set should fail. */ ioc.flags =DRM_MODE_PAGE_FLIP_EVENT ; -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EINVAL ); +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EINVAL );/* Nonsense flags. */ ioc.flags =0xdeadbeef ; -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EINVAL ); +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EINVAL ); ioc.flags =0 ;/* Safety check that flags is reset properly. */ -do_ioctl (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc); +do_ioctl (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc);/* Reserved/MBZ. */ ioc.reserved =1 ; -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EINVAL ); +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EINVAL ); ioc.reserved =0 ; -do_ioctl (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc); +do_ioctl (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc);/* Zero is not a valid object ID. */ ioc.count_objs =ARRAY_SIZE (obj_raw); -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,ENOENT ); +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,ENOENT );/* Invalid object type (not a thing we can set properties on). */ ioc.count_objs =1 ; - obj_raw[0 ] = crtc->mode.id; -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,ENOENT ); - obj_raw[0 ] = plane->fb_id; -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,ENOENT ); + obj_raw[0 ] = pipe->values[IGT_CRTC_MODE_ID ]; +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,ENOENT ); + obj_raw[0 ] = fb->fb_id; +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,ENOENT );/* Filled object but with no properties; no-op. */ for (i =0 ; i <ARRAY_SIZE (obj_raw); i++) - obj_raw[i] = crtc->obj; -do_ioctl (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc); + obj_raw[i] = pipe->crtc_id; +do_ioctl (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc);/* Pass in all sorts of things other than the property ID. */ num_props_raw[0 ] =1 ; -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,ENOENT ); - props_raw[0 ] = crtc->obj; -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,ENOENT ); - props_raw[0 ] = plane->obj; -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,ENOENT ); - props_raw[0 ] = connector->obj; -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,ENOENT ); - props_raw[0 ] = crtc->mode.id; -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,ENOENT ); +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,ENOENT ); + props_raw[0 ] = pipe->crtc_id; +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,ENOENT ); + props_raw[0 ] = plane->drm_plane->plane_id; +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,ENOENT ); + props_raw[0 ] = output->id; +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,ENOENT ); + props_raw[0 ] = pipe->values[IGT_CRTC_MODE_ID ]; +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,ENOENT );/* Valid property, valid value. */ for (i =0 ; i <ARRAY_SIZE (props_raw); i++) { - props_raw[i] = desc->props_crtc[IGT_CRTC_MODE_ID ]; - values_raw[i] = crtc->mode.id; + props_raw[i] = pipe->props[IGT_CRTC_MODE_ID ]; + values_raw[i] = pipe->values[IGT_CRTC_MODE_ID ]; } -do_ioctl (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc); +do_ioctl (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc);/* Setting the same thing multiple times is OK. */ for (i =0 ; i <ARRAY_SIZE (obj_raw); i++) num_props_raw[i] =ARRAY_SIZE (props_raw) /ARRAY_SIZE (obj_raw); -do_ioctl (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc); +do_ioctl (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc); ioc.count_objs =ARRAY_SIZE (obj_raw); -do_ioctl (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc); +do_ioctl (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc);/* Pass a series of outlandish addresses. */ ioc.objs_ptr =0 ; -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT ); +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT ); ioc.objs_ptr = (uintptr_t ) obj_raw; ioc.count_props_ptr =0 ; -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT ); +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT ); ioc.count_props_ptr = (uintptr_t ) num_props_raw; ioc.props_ptr =0 ; -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT ); +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT ); ioc.props_ptr = (uintptr_t ) props_raw; ioc.prop_values_ptr =0 ; -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT ); +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT ); ioc.prop_values_ptr = (uintptr_t ) values_raw; -do_ioctl (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc); +do_ioctl (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc);/* Attempt to overflow and/or trip various boundary conditions. */ ioc.count_objs =UINT32_MAX /sizeof (uint32_t ); -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,ENOENT ); +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,ENOENT ); ioc.count_objs =ARRAY_SIZE (obj_raw); ioc.objs_ptr =UINT64_MAX -sizeof (uint32_t ); -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT ); +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT ); ioc.count_objs =1 ; ioc.objs_ptr =UINT64_MAX -sizeof (uint32_t ); -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT ); +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT ); num_props_raw[0 ] =UINT32_MAX /sizeof (uint32_t ); -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT ); +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT ); num_props_raw[0 ] =UINT32_MAX -1 ; -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT ); +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT );for (i =0 ; i <ARRAY_SIZE (obj_raw); i++) num_props_raw[i] = (UINT32_MAX /ARRAY_SIZE (obj_raw)) +1 ; -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT ); +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT );for (i =0 ; i <ARRAY_SIZE (obj_raw); i++) num_props_raw[i] =ARRAY_SIZE (props_raw) /ARRAY_SIZE (obj_raw); -do_ioctl_err (desc->fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT ); +do_ioctl_err (display->drm_fd,DRM_IOCTL_MODE_ATOMIC , &ioc,EFAULT ); +} + +static void atomic_setup (igt_display_t *display,enum pipe pipe,igt_output_t *output,igt_plane_t *primary,struct igt_fb *fb) +{ +igt_output_set_pipe (output, pipe); +igt_plane_set_fb (primary, fb); + +crtc_commit (primary->pipe, primary,COMMIT_ATOMIC ,ATOMIC_RELAX_NONE ); +} + +static void atomic_clear (igt_display_t *display,enum pipe pipe,igt_plane_t *primary,igt_output_t *output) +{ +igt_plane_t *plane; + +for_each_plane_on_pipe (display, pipe, plane) { +igt_plane_set_fb (plane,NULL ); +igt_plane_set_position (plane,0 ,0 ); + } + +igt_output_set_pipe (output,PIPE_NONE ); +crtc_commit (primary->pipe, primary,COMMIT_ATOMIC ,ATOMIC_RELAX_NONE ); } igt_main { -struct kms_atomic_desc desc; -struct kms_atomic_state *current; +igt_display_t display; +enum pipe pipe =PIPE_NONE ; +igt_pipe_t *pipe_obj; +igt_output_t *output =NULL ; +igt_plane_t *primary =NULL ; +drmModeModeInfo *mode; +struct igt_fb fb; + + igt_fixture { + display.drm_fd =drm_open_driver_master (DRIVER_ANY ); + +kmstest_set_vt_graphics_mode (); + +igt_display_init (&display, display.drm_fd); + +igt_require (display.is_atomic); +igt_display_require_output (&display); -memset (&desc,0 ,sizeof (desc)); +for_each_pipe_with_valid_output (&display, pipe, output) +break ; + + pipe_obj = &display.pipes[pipe]; + primary =igt_pipe_get_plane_type (pipe_obj,DRM_PLANE_TYPE_PRIMARY ); - current =calloc (1 ,sizeof (*current)); -igt_assert (current); - current->desc = &desc; + mode =igt_output_get_mode (output); -igt_fixture -atomic_setup (current ); +igt_create_pattern_fb (display.drm_fd, + mode->hdisplay, mode->vdisplay, +plane_get_igt_format (primary), +LOCAL_DRM_FORMAT_MOD_NONE , &fb); + } igt_subtest("plane_overlay_legacy") { -struct kms_atomic_state *scratch =atomic_state_dup (current); -struct kms_atomic_crtc_state *crtc =find_crtc (scratch, true); -struct kms_atomic_plane_state *plane = -find_plane (scratch,PLANE_TYPE_OVERLAY , crtc); - -igt_require (crtc); -igt_require (plane); -plane_overlay (crtc, plane); -atomic_state_free (scratch); +igt_plane_t *overlay = +igt_pipe_get_plane_type (pipe_obj,DRM_PLANE_TYPE_OVERLAY ); + +igt_require (overlay); + +atomic_setup (&display, pipe, output, primary, &fb); +plane_overlay (pipe_obj, output, overlay); } igt_subtest("plane_primary_legacy") { -struct kms_atomic_state *scratch =atomic_state_dup (current); -struct kms_atomic_crtc_state *crtc =find_crtc (scratch, true); -struct kms_atomic_plane_state *plane = -find_plane (scratch,PLANE_TYPE_PRIMARY , crtc); - -igt_require (crtc); -igt_require (plane); -plane_primary (crtc, plane); -atomic_state_free (scratch); +atomic_setup (&display, pipe, output, primary, &fb); + +plane_primary (pipe_obj, primary, &fb); } igt_subtest("test_only") { -struct kms_atomic_state *scratch =atomic_state_dup (current); -struct kms_atomic_crtc_state *crtc =find_crtc (scratch, true); -struct kms_atomic_plane_state *plane = -find_plane (scratch,PLANE_TYPE_PRIMARY , crtc); - -igt_require (crtc); -igt_require (plane); -test_only (crtc, plane); -atomic_state_free (scratch); - } +atomic_clear (&display, pipe, primary, output); +test_only (pipe_obj, primary, output); + } igt_subtest("plane_cursor_legacy") { -struct kms_atomic_state *scratch =atomic_state_dup (current); -struct kms_atomic_crtc_state *crtc =find_crtc (scratch, true); -struct kms_atomic_plane_state *plane = -find_plane (scratch,PLANE_TYPE_CURSOR , crtc); - -igt_require (crtc); -igt_require (plane); -plane_cursor (crtc, plane); -atomic_state_free (scratch); +igt_plane_t *cursor = +igt_pipe_get_plane_type (pipe_obj,DRM_PLANE_TYPE_CURSOR ); + +igt_require (cursor); + +atomic_setup (&display, pipe, output, primary, &fb); +plane_cursor (pipe_obj, output, cursor); } igt_subtest("plane_invalid_params") { -struct kms_atomic_state *scratch =atomic_state_dup (current); -struct kms_atomic_crtc_state *crtc =find_crtc (scratch, true); -struct kms_atomic_plane_state *plane = -find_plane (current,PLANE_TYPE_PRIMARY , crtc); -struct kms_atomic_connector_state *conn = -find_connector (scratch, crtc); - -igt_require (crtc); -igt_require (plane); -plane_invalid_params (crtc, plane, conn); -atomic_state_free (scratch); +atomic_setup (&display, pipe, output, primary, &fb); + +plane_invalid_params (pipe_obj, output, primary, &fb); } igt_subtest("plane_invalid_params_fence") { -struct kms_atomic_state *scratch =atomic_state_dup (current); -struct kms_atomic_crtc_state *crtc =find_crtc (scratch, true); -struct kms_atomic_plane_state *plane = -find_plane (current,PLANE_TYPE_PRIMARY , crtc); -struct kms_atomic_connector_state *conn = -find_connector (scratch, crtc); - -igt_require (crtc); -igt_require (plane); -plane_invalid_params_fence (crtc, plane, conn); -atomic_state_free (scratch); +atomic_setup (&display, pipe, output, primary, &fb); + +plane_invalid_params_fence (pipe_obj, output, primary); } igt_subtest("crtc_invalid_params") { -struct kms_atomic_state *scratch =atomic_state_dup (current); -struct kms_atomic_crtc_state *crtc =find_crtc (scratch, true); -struct kms_atomic_plane_state *plane = -find_plane (scratch,NUM_PLANE_TYPE_PROPS , crtc); -struct kms_atomic_connector_state *conn = -find_connector (scratch, crtc); - -igt_require (crtc); -igt_require (plane); -igt_require (conn); -crtc_invalid_params (crtc, plane, conn); -atomic_state_free (scratch); +atomic_setup (&display, pipe, output, primary, &fb); + +crtc_invalid_params (pipe_obj, output, primary, &fb); } igt_subtest("crtc_invalid_params_fence") { -struct kms_atomic_state *scratch =atomic_state_dup (current); -struct kms_atomic_crtc_state *crtc =find_crtc (scratch, true); -struct kms_atomic_plane_state *plane = -find_plane (scratch,NUM_PLANE_TYPE_PROPS , crtc); -struct kms_atomic_connector_state *conn = -find_connector (scratch, crtc); - -igt_require (crtc); -igt_require (plane); -igt_require (conn); -crtc_invalid_params_fence (crtc, plane, conn); -atomic_state_free (scratch); - } +atomic_setup (&display, pipe, output, primary, &fb); - igt_subtest("atomic_invalid_params") { -struct kms_atomic_state *scratch =atomic_state_dup (current); -struct kms_atomic_crtc_state *crtc =find_crtc (scratch, true); -struct kms_atomic_plane_state *plane = -find_plane (scratch,NUM_PLANE_TYPE_PROPS , crtc); -struct kms_atomic_connector_state *conn = -find_connector (scratch, crtc); - -igt_require (crtc); -igt_require (plane); -igt_require (conn); -atomic_invalid_params (crtc, plane, conn); -atomic_state_free (scratch); +crtc_invalid_params_fence (pipe_obj, output, primary, &fb); } -atomic_state_free (current); + igt_subtest("atomic_invalid_params") +atomic_invalid_params (pipe_obj, primary, output, &fb); -igt_fixture - close(desc.fd); + igt_fixture { +atomic_clear (&display, pipe, primary, output); +igt_remove_fb (display.drm_fd, &fb); + +igt_display_fini (&display); + } }
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: failure for lib/igt_kms: Rewrite property handling to better match atomic.
In reply to Maarten Lankhorst== Series Details ==
== Series Details ==
Series: lib/igt_kms: Rewrite property handling to better match atomic.
URL : https://patchwork.freedesktop.org/series/31733/
State : failure
== Summary ==
IGT patchset build failed on latest successful build 136100c2f00b590bc9485100cce012282c1217cf igt/syncobj_wait: Don't close the timeline early in wait_snapshot
make all-recursive
Making all in lib
make all-recursive
Making all in .
Making all in tests
make[4]: Nothing to be done for 'all'.
Making all in man
make[2]: Nothing to be done for 'all'.
Making all in tools
Making all in null_state_gen
make[3]: Nothing to be done for 'all'.
Making all in registers
make[3]: Nothing to be done for 'all'.
make[3]: Nothing to be done for 'all-am'.
Making all in scripts
make[2]: Nothing to be done for 'all'.
Making all in benchmarks
Making all in wsim
make[3]: Nothing to be done for 'all'.
Making all in ezbench.d
make[3]: Nothing to be done for 'all'.
make[3]: Nothing to be done for 'all-am'.
Making all in tests
Making all in intel-ci
make[3]: Nothing to be done for 'all'.
CCLD gem_ctx_create CCLD gem_ctx_exec CCLD gem_ctx_param CCLD gem_ctx_switch CCLD gem_ctx_thrash CCLD gem_double_irq_loop CCLD gem_eio CCLD gem_evict_alignment CCLD gem_evict_everything CCLD gem_exec_alignment CCLD gem_exec_async CCLD gem_exec_await CCLD gem_exec_bad_domains CCLD gem_exec_basic CCLD gem_exec_big CCLD gem_exec_blt CCLD gem_exec_capture CCLD gem_exec_create CCLD gem_exec_faulting_reloc CCLD gem_exec_fence CCLD gem_exec_flush CCLD gem_exec_gttfill CCLD gem_exec_latency CCLD gem_exec_lut_handle CCLD gem_exec_nop CCLD gem_exec_parallel CCLD gem_exec_params CCLD gem_exec_parse CCLD gem_exec_reloc CCLD gem_exec_reuse CCLD gem_exec_schedule CCLD gem_exec_store CCLD gem_exec_suspend CCLD gem_exec_whisper CCLD gem_fd_exhaustion CCLD gem_fence_thrash CCLD gem_fence_upload CCLD gem_fenced_exec_thrash CCLD gem_flink_basic CCLD gem_flink_race CCLD gem_gpgpu_fill CCLD gem_gtt_cpu_tlb CCLD gem_gtt_hog CCLD gem_gtt_speed CCLD gem_hangcheck_forcewake CCLD gem_largeobject CCLD gem_linear_blits CCLD gem_lut_handle CCLD gem_madvise CCLD gem_media_fill CCLD gem_mmap CCLD gem_mmap_gtt CCLD gem_mmap_offset_exhaustion CCLD gem_mmap_wc CCLD gem_mocs_settings CCLD gem_partial_pwrite_pread CCLD gem_persistent_relocs CCLD gem_pin CCLD gem_pipe_control_store_loop CCLD gem_ppgtt CCLD gem_pread CCLD gem_pread_after_blit CCLD gem_pwrite CCLD gem_pwrite_pread CCLD gem_pwrite_snooped CCLD gem_read_read_speed CCLD gem_readwrite CCLD gem_reg_read CCLD gem_reloc_overflow CCLD gem_reloc_vs_gpu CCLD gem_render_copy CCLD gem_render_copy_redux CCLD gem_render_linear_blits CCLD gem_render_tiled_blits CCLD gem_request_retire CCLD gem_reset_stats CCLD gem_ring_sync_copy CCLD gem_ring_sync_loop CCLD gem_ringfill CCLD gem_seqno_wrap CCLD gem_set_tiling_vs_blt CCLD gem_set_tiling_vs_gtt CCLD gem_set_tiling_vs_pwrite CCLD gem_shrink CCLD gem_softpin CCLD gem_spin_batch CCLD gem_stolen CCLD gem_storedw_batches_loop CCLD gem_storedw_loop CCLD gem_streaming_writes CCLD gem_sync CCLD gem_threaded_access_tiled CCLD gem_tiled_blits CCLD gem_tiled_fence_blits CCLD gem_tiled_partial_pwrite_pread CCLD gem_tiled_pread_basic CCLD gem_tiled_pread_pwrite CCLD gem_tiled_swapping CCLD gem_tiled_wb CCLD gem_tiled_wc CCLD gem_tiling_max_stride CCLD gem_unfence_active_buffers CCLD gem_unref_active_buffers CCLD gem_userptr_blits CCLD gem_wait CCLD gem_workarounds CCLD gem_write_read_ring_switch CCLD gen3_mixed_blits CCLD gen3_render_linear_blits CCLD gen3_render_mixed_blits CCLD gen3_render_tiledx_blits CCLD gen3_render_tiledy_blits CCLD gen7_forcewake_mt CCLD gvt_basic CCLD kms_3d CCLD kms_addfb_basic CCLD kms_atomic CCLD kms_atomic_interruptible CCLD kms_atomic_transition CCLD kms_busy CCLD kms_ccs CCLD kms_chv_cursor_fail CCLD kms_color CCLD kms_concurrent CCLD kms_crtc_background_color CCLD kms_cursor_crc CCLD kms_cursor_legacy CCLD kms_draw_crc CCLD kms_fbc_crc CCLD kms_fbcon_fbt CCLD kms_fence_pin_leak CCLD kms_flip CCLD kms_flip_event_leak CCLD kms_flip_tiling CCLD kms_force_connector_basic CCLD kms_frontbuffer_tracking CCLD kms_hdmi_inject CCLD kms_invalid_dotclock CCLD kms_legacy_colorkey CCLD kms_mmap_write_crc CCLD kms_mmio_vs_cs_flip CCLD kms_panel_fitting CCLD kms_pipe_b_c_ivb CCLD kms_pipe_crc_basic CCLD kms_plane CCLD kms_plane_lowres CCLD kms_plane_multiple CCLD kms_plane_scaling CCLD kms_properties CCLD kms_psr_sink_crc CCLD kms_pwrite_crc CCLD kms_render CCLD kms_rmfb CCLD kms_rotation_crc CCLD kms_setmode CCLD kms_sink_crc_basic CCLD kms_sysfs_edid_timing CCLD kms_tv_load_detect CCLD kms_universal_plane CCLD kms_vblank CCLD meta_test CCLD perf CCLD pm_backlight CCLD pm_lpsp CCLD pm_rc6_residency CCLD pm_rpm CCLD pm_rps CCLD pm_sseu CCLD prime_busy CCLD prime_mmap CCLD prime_mmap_coherency CCLD prime_mmap_kms CCLD prime_self_import CCLD prime_udl CCLD prime_vgem CCLD sw_sync CCLD syncobj_basic CCLD syncobj_wait CCLD template CCLD tools_test CCLD vgem_basic CCLD vgem_slow CC chamelium-chamelium.o
chamelium.c: In function ‘enable_output’:
chamelium.c:465:2: error: implicit declaration of function ‘igt_pipe_set_degamma_lut’ [-Werror=implicit-function-declaration]
igt_pipe_set_degamma_lut(primary->pipe, NULL, 0);
^~~~~~~~~~~~~~~~~~~~~~~~
chamelium.c:465:2: warning: nested extern declaration of ‘igt_pipe_set_degamma_lut’ [-Wnested-externs] chamelium.c:466:2: error: implicit declaration of function ‘igt_pipe_set_gamma_lut’ [-Werror=implicit-function-declaration]
igt_pipe_set_gamma_lut(primary->pipe, NULL, 0);
^~~~~~~~~~~~~~~~~~~~~~
chamelium.c:466:2: warning: nested extern declaration of ‘igt_pipe_set_gamma_lut’ [-Wnested-externs] chamelium.c:467:2: error: implicit declaration of function ‘igt_pipe_set_ctm_matrix’ [-Werror=implicit-function-declaration]
igt_pipe_set_ctm_matrix(primary->pipe, NULL, 0);
^~~~~~~~~~~~~~~~~~~~~~~
chamelium.c:467:2: warning: nested extern declaration of ‘igt_pipe_set_ctm_matrix’ [-Wnested-externs]
cc1: some warnings being treated as errors
Makefile:4050: recipe for target 'chamelium-chamelium.o' failed
make[3]: *** [chamelium-chamelium.o] Error 1
Makefile:4455: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
Makefile:533: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
Makefile:465: recipe for target 'all' failed
make: *** [all] Error 2
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for lib/igt_kms: Rewrite property handling to better match atomic. (rev3)
In reply to Maarten Lankhorst== Series Details ==
== Series Details ==
Series: lib/igt_kms: Rewrite property handling to better match atomic. (rev3)
URL : https://patchwork.freedesktop.org/series/31733/
State : success
== Summary ==
IGT patchset tested on top of latest successful build f0bfbad1cf1d01e65112310e95ba5ecba15133d1 benchmark/gem_busy: Compare polling with syncobj_wait
with latest DRM-Tip kernel build CI_DRM_3222a869721e93a5 drm-tip: 2017y-10m-12d-08h-30m-31s UTC integration manifest
No testlist changes.
Test chamelium:
Subgroup dp-crc-fast:
pass -> FAIL (fi-kbl-7500u) fdo#102514fdo#102514 https://bugs.freedesktop.org/show_bug.cgi?id=102514
fi-bdw-5557u total:289 pass:268 dwarn:0 dfail:0 fail:0 skip:21 time:463s fi-bdw-gvtdvm total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:475s fi-blb-e6850 total:289 pass:223 dwarn:1 dfail:0 fail:0 skip:65 time:395s fi-bsw-n3050 total:289 pass:243 dwarn:0 dfail:0 fail:0 skip:46 time:569s fi-bwr-2160 total:289 pass:183 dwarn:0 dfail:0 fail:0 skip:106 time:287s fi-bxt-dsi total:289 pass:259 dwarn:0 dfail:0 fail:0 skip:30 time:525s fi-bxt-j4205 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:525s fi-byt-j1900 total:289 pass:253 dwarn:1 dfail:0 fail:0 skip:35 time:540s fi-cfl-s total:289 pass:253 dwarn:4 dfail:0 fail:0 skip:32 time:564s fi-elk-e7500 total:289 pass:229 dwarn:0 dfail:0 fail:0 skip:60 time:440s fi-gdg-551 total:289 pass:178 dwarn:1 dfail:0 fail:1 skip:109 time:275s fi-glk-1 total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:602s fi-hsw-4770r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:440s fi-ilk-650 total:289 pass:228 dwarn:0 dfail:0 fail:0 skip:61 time:468s fi-ivb-3520m total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:509s fi-ivb-3770 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:476s fi-kbl-7500u total:289 pass:263 dwarn:1 dfail:0 fail:1 skip:24 time:501s fi-kbl-7567u total:289 pass:265 dwarn:4 dfail:0 fail:0 skip:20 time:489s fi-kbl-r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:596s fi-skl-6260u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:469s fi-skl-6700hq total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:657s fi-skl-6700k total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:536s fi-skl-6770hq total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:569s fi-skl-gvtdvm total:289 pass:266 dwarn:0 dfail:0 fail:0 skip:23 time:477s fi-snb-2520m total:289 pass:250 dwarn:0 dfail:0 fail:0 skip:39 time:581s fi-snb-2600 total:289 pass:249 dwarn:0 dfail:0 fail:0 skip:40 time:433s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_336/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for lib/igt_kms: Rewrite property handling to better match atomic. (rev3)
In reply to Maarten Lankhorst== Series Details ==
== Series Details ==
Series: lib/igt_kms: Rewrite property handling to better match atomic. (rev3)
URL : https://patchwork.freedesktop.org/series/31733/
State : success
== Summary ==
Test kms_frontbuffer_tracking:
Subgroup fbc-1p-offscren-pri-shrfb-draw-mmap-wc:
dmesg-warn -> PASS (shard-hsw) fdo#102614
Test kms_setmode:
Subgroup basic:
pass -> FAIL (shard-hsw) fdo#99912
Test prime_self_import:
Subgroup reimport-vs-gem_close-race:
fail -> PASS (shard-hsw) fdo#102655fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
fdo#102655 https://bugs.freedesktop.org/show_bug.cgi?id=102655
shard-hsw total:2551 pass:1439 dwarn:0 dfail:0 fail:9 skip:1103 time:9659s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_336/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx