[PATCH i-g-t v2 07/15] igt_kms: Handle atomic pipe properties better.

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

Move properties to the pipe, they don't belong in the output
and make atomic commit use the pipes for crtc properties.

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

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 88cae7d51787..8c7598a88a69 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -213,8 +213,7 @@ igt_atomic_fill_plane_props(igt_display_t *display, igt_plane_t *plane,
* config->atomic_props_crtc and config->atomic_props_connector.
*/
static void
-igt_atomic_fill_props(igt_display_t *display, igt_output_t *output,
- int num_crtc_props, const char **crtc_prop_names,
+igt_atomic_fill_connector_props(igt_display_t *display, igt_output_t *output,
int num_connector_props, const char **conn_prop_names)
{
drmModeObjectPropertiesPtr props;
@@ -222,18 +221,18 @@ igt_atomic_fill_props(igt_display_t *display, igt_output_t *output,

fd = display->drm_fd;

- props = drmModeObjectGetProperties(fd, output->config.crtc->crtc_id, DRM_MODE_OBJECT_CRTC);
+ props = drmModeObjectGetProperties(fd, output->config.connector->connector_id, DRM_MODE_OBJECT_CONNECTOR);
igt_assert(props);

for (i = 0; i < props->count_props; i++) {
drmModePropertyPtr prop =
drmModeGetProperty(fd, props->props[i]);

- for (j = 0; j < num_crtc_props; j++) {
- if (strcmp(prop->name, crtc_prop_names[j]) != 0)
+ for (j = 0; j < num_connector_props; j++) {
+ if (strcmp(prop->name, conn_prop_names[j]) != 0)
continue;

- output->config.atomic_props_crtc[j] = props->props[i];
+ output->config.atomic_props_connector[j] = props->props[i];
break;
}

@@ -241,19 +240,29 @@ igt_atomic_fill_props(igt_display_t *display, igt_output_t *output,
}

drmModeFreeObjectProperties(props);
- props = NULL;
- props = drmModeObjectGetProperties(fd, output->config.connector->connector_id, DRM_MODE_OBJECT_CONNECTOR);
+}
+
+static void
+igt_atomic_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;
+
+ fd = display->drm_fd;
+
+ props = drmModeObjectGetProperties(fd, pipe->crtc_id, DRM_MODE_OBJECT_CRTC);
igt_assert(props);

for (i = 0; i < props->count_props; i++) {
drmModePropertyPtr prop =
drmModeGetProperty(fd, props->props[i]);

- for (j = 0; j < num_connector_props; j++) {
- if (strcmp(prop->name, conn_prop_names[j]) != 0)
+ for (j = 0; j < num_crtc_props; j++) {
+ if (strcmp(prop->name, crtc_prop_names[j]) != 0)
continue;

- output->config.atomic_props_connector[j] = props->props[i];
+ pipe->atomic_props_crtc[j] = props->props[i];
break;
}

@@ -261,7 +270,6 @@ igt_atomic_fill_props(igt_display_t *display, igt_output_t *output,
}

drmModeFreeObjectProperties(props);
-
}

const unsigned char* igt_kms_get_alt_edid(void)
@@ -1222,6 +1230,9 @@ static void igt_output_refresh(igt_output_t *output)
-1);
}

+ igt_atomic_fill_connector_props(display, output,
+ IGT_NUM_CONNECTOR_PROPS, igt_connector_prop_names);
+
if (!output->valid)
return;

@@ -1232,8 +1243,6 @@ static void igt_output_refresh(igt_output_t *output)
kmstest_pipe_name(output->config.pipe));

display->pipes_in_use |= 1 << output->config.pipe;
- igt_atomic_fill_props(display, output, IGT_NUM_CRTC_PROPS, igt_crtc_prop_names,
- IGT_NUM_CONNECTOR_PROPS, igt_connector_prop_names);
}

static bool
@@ -1359,6 +1368,8 @@ void igt_display_init(igt_display_t *display, int drm_fd)
NULL,
NULL);

+ igt_atomic_fill_pipe_props(display, pipe, IGT_NUM_CRTC_PROPS, igt_crtc_prop_names);
+
/* add the planes that can be used with that pipe */
for (j = 0; j < plane_resources->count_planes; j++) {
drmModePlane *drm_plane;
@@ -1660,11 +1671,10 @@ static uint32_t igt_plane_get_fb_gem_handle(igt_plane_t *plane)
* Add position and fb changes of a plane to the atomic property set
*/
static void
-igt_atomic_prepare_plane_commit(igt_plane_t *plane, igt_output_t *output,
+igt_atomic_prepare_plane_commit(igt_plane_t *plane, igt_pipe_t *pipe,
drmModeAtomicReq *req)
{
-
- igt_display_t *display = output->display;
+ igt_display_t *display = pipe->display;
uint32_t fb_id, crtc_id;

igt_assert(plane->drm_plane);
@@ -1674,12 +1684,11 @@ igt_atomic_prepare_plane_commit(igt_plane_t *plane, igt_output_t *output,
!plane->rotation_changed);

fb_id = igt_plane_get_fb_id(plane);
- crtc_id = output->config.crtc->crtc_id;
+ crtc_id = pipe->crtc_id;

LOG(display,
- "%s: populating plane data: %s.%d, fb %u\n",
- igt_output_name(output),
- kmstest_pipe_name(output->config.pipe),
+ "populating plane data: %s.%d, fb %u\n",
+ kmstest_pipe_name(pipe->pipe),
plane->index,
fb_id);

@@ -2040,21 +2049,15 @@ static int igt_pipe_commit(igt_pipe_t *pipe,
/*
* Add crtc property changes to the atomic property set
*/
-static void igt_atomic_prepare_crtc_commit(igt_output_t *output, drmModeAtomicReq *req)
+static void igt_atomic_prepare_crtc_commit(igt_pipe_t *pipe_obj, drmModeAtomicReq *req)
{
-
- igt_pipe_t *pipe_obj = igt_output_get_driving_pipe(output);
-
- if (!pipe_obj)
- return;
-
if (pipe_obj->background_changed)
- igt_atomic_populate_crtc_req(req, output, IGT_CRTC_BACKGROUND, pipe_obj->background);
+ 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, output, IGT_CRTC_DEGAMMA_LUT, pipe_obj->degamma_blob);
- igt_atomic_populate_crtc_req(req, output, IGT_CRTC_CTM, pipe_obj->ctm_blob);
- igt_atomic_populate_crtc_req(req, output, IGT_CRTC_GAMMA_LUT, pipe_obj->gamma_blob);
+ 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);
}

/*
@@ -2088,42 +2091,37 @@ static void igt_atomic_prepare_connector_commit(igt_output_t *output, drmModeAto
static int igt_atomic_commit(igt_display_t *display)
{

- int ret = 0;
+ int ret = 0, i;
+ enum pipe pipe;
drmModeAtomicReq *req;
igt_output_t *output;
+
if (display->is_atomic != 1)
return -1;
req = drmModeAtomicAlloc();
drmModeAtomicSetCursor(req, 0);

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

/*
* Add CRTC Properties to the property set
*/
- igt_atomic_prepare_crtc_commit(output, req);
-
- /*
- * Add Connector Properties to the property set
- */
- igt_atomic_prepare_connector_commit(output, req);
-
-
- pipe_obj = igt_output_get_driving_pipe(output);
- if (!pipe_obj)
- continue;
-
- pipe = pipe_obj->pipe;
+ igt_atomic_prepare_crtc_commit(pipe_obj, req);

for_each_plane_on_pipe(display, pipe, plane) {
- igt_atomic_prepare_plane_commit(plane, output, req);
+ igt_atomic_prepare_plane_commit(plane, pipe_obj, req);
}

}

+ for (i = 0; i < display->n_outputs; i++) {
+ output = &display->outputs[i];
+
+ igt_atomic_prepare_connector_commit(output, req);
+ }
+
ret = drmModeAtomicCommit(display->drm_fd, req, 0, NULL);
drmModeAtomicFree(req);
return ret;
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 3531dc20b6e0..b9e8d344ed8c 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -117,7 +117,6 @@ struct kmstest_connector_config {
bool connector_scaling_mode_changed;
uint64_t connector_dpms;
bool connector_dpms_changed;
- uint32_t atomic_props_crtc[IGT_NUM_CRTC_PROPS];
uint32_t atomic_props_connector[IGT_NUM_CONNECTOR_PROPS];
int pipe;
unsigned valid_crtc_idx_mask;
@@ -257,6 +256,9 @@ struct igt_pipe {
bool enabled;
int n_planes;
igt_plane_t planes[IGT_MAX_PLANES];
+
+ uint32_t atomic_props_crtc[IGT_NUM_CRTC_PROPS];
+
uint64_t background; /* Background color MSB BGR 16bpc LSB */
uint32_t background_changed : 1;
uint32_t background_property;
@@ -395,13 +397,13 @@ static inline bool igt_pipe_connector_valid(enum pipe pipe,
/**
* igt_atomic_populate_crtc_req:
* @req: A pointer to drmModeAtomicReq
- * @output: A pointer igt_output_t
+ * @pipe: A pointer igt_pipe_t
* @prop: one of igt_atomic_crtc_properties
* @value: the value to add
*/
-#define igt_atomic_populate_crtc_req(req, output, prop, value) \
- igt_assert_lt(0, drmModeAtomicAddProperty(req, output->config.crtc->crtc_id,\
- output->config.atomic_props_crtc[prop], value))
+#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