[PATCH i-g-t v2 13/15] igt_kms: Add more apis for panel fitting test.

Maarten Lankhorst
2016-07-06T09:56:04Z

igt_output_set_scaling_mode is a simple way to update scaling mode,
igt_display_(try_)commit_atomic will allow you to call drmAtomicCommit
with custom flags, like TEST_ONLY, EVENT, NONBLOCKING or without
ALLOW_MODESET.

This is useful when you only want to do any of those things, for events
it can be useful to set the user_data pointer too, so export that to
users.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
lib/igt_kms.c | 113 +++++++++++++++++++++++++++++++++++++++++++---------------
lib/igt_kms.h | 3 ++
2 files changed, 87 insertions(+), 29 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 17865c263f35..681f2bb41b07 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -867,7 +867,9 @@ static bool _kmstest_connector_config(int drm_fd, uint32_t connector_id,
goto err3;

if (!connector->count_modes) {
- igt_warn("connector %d has no modes\n", connector_id);
+ igt_warn("connector %d/%s-%d has no modes\n", connector_id,
+ kmstest_connector_type_str(connector->connector_type),
+ connector->connector_type_id);
goto err3;
}

@@ -2125,7 +2127,7 @@ static void igt_atomic_prepare_connector_commit(igt_output_t *output, drmModeAto
* Commit all the changes of all the planes,crtcs, connectors
* atomically using drmModeAtomicCommit()
*/
-static int igt_atomic_commit(igt_display_t *display)
+static int igt_atomic_commit(igt_display_t *display, uint32_t flags, void *user_data)
{

int ret = 0, i;
@@ -2166,11 +2168,51 @@ static int igt_atomic_commit(igt_display_t *display)
igt_atomic_prepare_connector_commit(output, req);
}

- ret = drmModeAtomicCommit(display->drm_fd, req, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+ ret = drmModeAtomicCommit(display->drm_fd, req, flags, user_data);
drmModeAtomicFree(req);
return ret;

}
+
+static void
+display_commit_changed(igt_display_t *display, enum igt_commit_style s)
+{
+ int i;
+ enum pipe pipe;
+
+ for_each_pipe(display, pipe) {
+ igt_pipe_t *pipe_obj = &display->pipes[pipe];
+ igt_plane_t *plane;
+
+ if (s == COMMIT_ATOMIC) {
+ pipe_obj->color_mgmt_changed = false;
+ pipe_obj->background_changed = false;
+ }
+
+ if (s != COMMIT_UNIVERSAL)
+ pipe_obj->mode_changed = false;
+
+ for_each_plane_on_pipe(display, pipe, plane) {
+ plane->fb_changed = false;
+ plane->position_changed = false;
+ plane->size_changed = false;
+
+ if (s != COMMIT_LEGACY || !(plane->is_primary || plane->is_cursor))
+ plane->rotation_changed = false;
+ }
+ }
+
+ 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;
+ }
+}
+
/*
* Commit all plane changes across all outputs of the display.
*
@@ -2184,14 +2226,14 @@ static int do_display_commit(igt_display_t *display,
enum igt_commit_style s,
bool fail_on_error)
{
- int i, ret;
+ int ret;
enum pipe pipe;
LOG_INDENT(display, "commit");

igt_display_refresh(display);

if (s == COMMIT_ATOMIC) {
- ret = igt_atomic_commit(display);
+ ret = igt_atomic_commit(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);

CHECK_RETURN(ret, fail_on_error);
} else {
@@ -2222,43 +2264,42 @@ static int do_display_commit(igt_display_t *display,
if (ret)
return ret;

- for_each_pipe(display, pipe) {
- igt_pipe_t *pipe_obj = &display->pipes[pipe];
- igt_plane_t *plane;
+ display_commit_changed(display, s);

- if (s == COMMIT_ATOMIC) {
- pipe_obj->color_mgmt_changed = false;
- pipe_obj->background_changed = false;
- }
+ igt_debug_wait_for_keypress("modeset");

- if (s != COMMIT_UNIVERSAL)
- pipe_obj->mode_changed = false;
+ return 0;
+}

- for_each_plane_on_pipe(display, pipe, plane) {
- plane->fb_changed = false;
- plane->position_changed = false;
- plane->size_changed = false;
+int igt_display_try_commit_atomic(igt_display_t *display, uint32_t flags, void *user_data)
+{
+ int ret;

- if (s != COMMIT_LEGACY || !(plane->is_primary || plane->is_cursor))
- plane->rotation_changed = false;
- }
- }
+ LOG_INDENT(display, "commit");

- for (i = 0; i < display->n_outputs; i++) {
- igt_output_t *output = &display->outputs[i];
+ igt_display_refresh(display);

- if (s != COMMIT_UNIVERSAL)
- output->config.pipe_changed = false;
+ ret = igt_atomic_commit(display, flags, user_data);

- if (s == COMMIT_ATOMIC)
- output->config.connector_scaling_mode_changed = false;
- }
+ LOG_UNINDENT(display);
+
+ if (ret || (flags & DRM_MODE_ATOMIC_TEST_ONLY))
+ return ret;
+
+ display_commit_changed(display, COMMIT_ATOMIC);

igt_debug_wait_for_keypress("modeset");

return 0;
}

+void igt_display_commit_atomic(igt_display_t *display, uint32_t flags, void *user_data)
+{
+ int ret = igt_display_try_commit_atomic(display, flags, user_data);
+
+ igt_assert_eq(ret, 0);
+}
+
/**
* igt_display_commit2:
* @display: DRM device handle
@@ -2380,6 +2421,15 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe)
output->config.pipe_changed = true;
}

+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_require(output->config.atomic_props_connector[IGT_CONNECTOR_SCALING_MODE]);
+}
+
igt_plane_t *igt_output_get_plane(igt_output_t *output, enum igt_plane plane)
{
igt_pipe_t *pipe;
@@ -2411,6 +2461,11 @@ void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb *fb)
plane->src_w = fb->width;
plane->src_h = fb->height;
} else {
+ plane->src_x = 0;
+ plane->src_y = 0;
+ plane->src_w = 0;
+ plane->src_h = 0;
+
plane->crtc_w = 0;
plane->crtc_h = 0;
}
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 39e3b9fa1972..bc7825a3f06d 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -303,6 +303,8 @@ void igt_display_init(igt_display_t *display, int drm_fd);
void igt_display_fini(igt_display_t *display);
int igt_display_commit2(igt_display_t *display, enum igt_commit_style s);
int igt_display_commit(igt_display_t *display);
+int igt_display_try_commit_atomic(igt_display_t *display, uint32_t flags, void *user_data);
+void igt_display_commit_atomic(igt_display_t *display, uint32_t flags, void *user_data);
int igt_display_try_commit2(igt_display_t *display, enum igt_commit_style s);
int igt_display_get_n_pipes(igt_display_t *display);

@@ -310,6 +312,7 @@ 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, enum igt_plane plane);
bool igt_pipe_get_property(igt_pipe_t *pipe, const char *name,
uint32_t *prop_id, uint64_t *value,