aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSimon Ser <simon.ser@intel.com>2019-06-19 10:49:58 +0300
committerSimon Ser <simon.ser@intel.com>2019-07-19 10:52:58 +0300
commitc002f3ef5a51b27df0f28e8a64a7a5381aa2e158 (patch)
treeeb004a681478851b719886e4fc022dca21231766 /lib
parent043dae641dd5b2d403eda0a94da9a4d81ebff244 (diff)
downloadplatform_external_igt-gpu-tools-c002f3ef5a51b27df0f28e8a64a7a5381aa2e158.tar.gz
platform_external_igt-gpu-tools-c002f3ef5a51b27df0f28e8a64a7a5381aa2e158.tar.bz2
platform_external_igt-gpu-tools-c002f3ef5a51b27df0f28e8a64a7a5381aa2e158.zip
lib/igt_chamelium: add CHAMELIUM_MAX_PORTS
We will always be able to find an upper bound for the number of connectors supported by a Chamelium board. Instead of using dynamic arrays, simplify the code by using static ones. More code will need to have arrays of ports in the future. Signed-off-by: Simon Ser <simon.ser@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_chamelium.c7
-rw-r--r--lib/igt_chamelium.h7
2 files changed, 9 insertions, 5 deletions
diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 7198df63..2a49bf56 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -121,7 +121,7 @@ struct chamelium {
int drm_fd;
struct igt_list edids;
- struct chamelium_port *ports;
+ struct chamelium_port ports[CHAMELIUM_MAX_PORTS];
int port_count;
};
@@ -1804,11 +1804,9 @@ static bool chamelium_read_port_mappings(struct chamelium *chamelium,
if (strstr(group_list[i], "Chamelium:"))
chamelium->port_count++;
}
+ igt_assert(chamelium->port_count <= CHAMELIUM_MAX_PORTS);
- chamelium->ports = calloc(sizeof(struct chamelium_port),
- chamelium->port_count);
port_i = 0;
-
for (i = 0; group_list[i] != NULL; i++) {
group = group_list[i];
@@ -2008,7 +2006,6 @@ void chamelium_deinit(struct chamelium *chamelium)
for (i = 0; i < chamelium->port_count; i++)
free(chamelium->ports[i].name);
- free(chamelium->ports);
free(chamelium);
}
diff --git a/lib/igt_chamelium.h b/lib/igt_chamelium.h
index 7f77745f..b6b7eb44 100644
--- a/lib/igt_chamelium.h
+++ b/lib/igt_chamelium.h
@@ -68,6 +68,13 @@ struct chamelium_audio_file {
struct chamelium_edid;
/**
+ * CHAMELIUM_MAX_PORTS: the maximum number of ports supported by igt_chamelium.
+ *
+ * For now, we have 1 VGA, 1 HDMI and 2 DisplayPort ports.
+ */
+#define CHAMELIUM_MAX_PORTS 4
+
+/**
* CHAMELIUM_DEFAULT_EDID: provide this ID to #chamelium_port_set_edid to use
* the default EDID.
*/