summaryrefslogtreecommitdiff
path: root/tests/kms_setmode.c
diff options
context:
space:
mode:
authorHarry Wentland <harry.wentland@amd.com>2017-06-05 14:43:19 -0400
committerPetri Latvala <petri.latvala@intel.com>2017-06-06 10:37:16 +0300
commit750319044f0fdce1c251e040ce0741d672b31226 (patch)
tree69a69b0538572cc0da772ca3a9106f58e056d578 /tests/kms_setmode.c
parenta0433ca1dddb83968a0f91753509526bb0240b5a (diff)
tests/kms_setmode: Dynamic crtc/connector combinations
Create crtc/connector combinations based on actual adapter information obtained from drmModeRes. Also set MAX_CRTCs to 6 for AMD GPUs. Signed-off-by: Harry Wentland <harry.wentland@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'tests/kms_setmode.c')
-rw-r--r--tests/kms_setmode.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c
index 430568a1..a7a48de4 100644
--- a/tests/kms_setmode.c
+++ b/tests/kms_setmode.c
@@ -31,15 +31,13 @@
#include <unistd.h>
#include <string.h>
#include <sys/time.h>
-
+#include <math.h>
#include "intel_bufmgr.h"
#define MAX_CONNECTORS 10
-#define MAX_CRTCS 3
+#define MAX_CRTCS 6
/* max combinations with repetitions */
-#define MAX_COMBINATION_COUNT \
- (MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS)
#define MAX_COMBINATION_ELEMS MAX_CRTCS
static int drm_fd;
@@ -702,7 +700,8 @@ struct combination {
struct combination_set {
int count;
- struct combination items[MAX_COMBINATION_COUNT];
+ int capacity;
+ struct combination *items;
};
/*
@@ -716,7 +715,7 @@ static void iterate_combinations(int n, int k, bool allow_repetitions,
int v;
if (!k) {
- igt_assert(set->count < ARRAY_SIZE(set->items));
+ igt_assert(set->count < set->capacity);
set->items[set->count++] = *comb;
return;
}
@@ -751,6 +750,16 @@ static void test_combinations(const struct test_config *tconf,
if (connector_count > 2 && (tconf->flags & TEST_STEALING))
return;
+ igt_assert(tconf->resources);
+
+ connector_combs.capacity = pow(tconf->resources->count_connectors,
+ tconf->resources->count_crtcs + 1);
+ crtc_combs.capacity = pow(tconf->resources->count_crtcs,
+ tconf->resources->count_crtcs + 1);
+
+ connector_combs.items = malloc(connector_combs.capacity * sizeof(struct combination));
+ crtc_combs.items = malloc(crtc_combs.capacity * sizeof(struct combination));
+
get_combinations(tconf->resources->count_connectors, connector_count,
false, &connector_combs);
get_combinations(tconf->resources->count_crtcs, connector_count,
@@ -787,6 +796,9 @@ static void test_combinations(const struct test_config *tconf,
free_cconfs:
free(cconfs);
}
+
+ free(connector_combs.items);
+ free(crtc_combs.items);
}
static void run_test(const struct test_config *tconf)