summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Ser <simon.ser@intel.com>2019-06-19 11:13:29 +0300
committerSimon Ser <simon.ser@intel.com>2019-07-19 10:58:36 +0300
commitc9dac1819c10cb28834f71f1dd2ed4879071876b (patch)
tree61f74a41399b7c25455000f309616f0244d54aee /lib
parent363f340b9b72423fe3686bcb69a70d816da5c0e5 (diff)
lib/igt_chamelium: set EDID serial
Set a different EDID serial string for each Chamelium port, so that we can easily tell which DRM connector maps to a Chamelium port. 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.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 4df3a456..7f37e0c6 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -83,7 +83,9 @@
*/
struct chamelium_edid {
- struct edid *raw;
+ struct chamelium *chamelium;
+ struct edid *base;
+ struct edid *raw[CHAMELIUM_MAX_PORTS];
int ids[CHAMELIUM_MAX_PORTS];
struct igt_list link;
};
@@ -567,14 +569,34 @@ struct chamelium_edid *chamelium_new_edid(struct chamelium *chamelium,
size_t edid_size = edid_get_size(edid);
chamelium_edid = calloc(1, sizeof(struct chamelium_edid));
- chamelium_edid->raw = malloc(edid_size);
- memcpy(chamelium_edid->raw, edid, edid_size);
+ chamelium_edid->chamelium = chamelium;
+ chamelium_edid->base = malloc(edid_size);
+ memcpy(chamelium_edid->base, edid, edid_size);
igt_list_add(&chamelium_edid->link, &chamelium->edids);
return chamelium_edid;
}
/**
+ * chamelium_port_tag_edid: tag the EDID with the provided Chamelium port.
+ */
+static void chamelium_port_tag_edid(struct chamelium_port *port,
+ struct edid *edid)
+{
+ uint32_t *serial;
+
+ /* Product code: Chamelium */
+ edid->prod_code[0] = 'C';
+ edid->prod_code[1] = 'H';
+
+ /* Serial: Chamelium port ID */
+ serial = (uint32_t *) &edid->serial;
+ *serial = port->id;
+
+ edid_update_checksum(edid);
+}
+
+/**
* chamelium_edid_get_raw: get the raw EDID
* @edid: the Chamelium EDID
* @port: the Chamelium port
@@ -588,7 +610,17 @@ struct chamelium_edid *chamelium_new_edid(struct chamelium *chamelium,
const struct edid *chamelium_edid_get_raw(struct chamelium_edid *edid,
struct chamelium_port *port)
{
- return edid->raw;
+ size_t port_index = port - edid->chamelium->ports;
+ size_t edid_size;
+
+ if (!edid->raw[port_index]) {
+ edid_size = edid_get_size(edid->base);
+ edid->raw[port_index] = malloc(edid_size);
+ memcpy(edid->raw[port_index], edid->base, edid_size);
+ chamelium_port_tag_edid(port, edid->raw[port_index]);
+ }
+
+ return edid->raw[port_index];
}
/**
@@ -2010,8 +2042,9 @@ void chamelium_deinit(struct chamelium *chamelium)
for (i = 0; i < CHAMELIUM_MAX_PORTS; i++) {
if (pos->ids[i])
chamelium_destroy_edid(chamelium, pos->ids[i]);
+ free(pos->raw[i]);
}
- free(pos->raw);
+ free(pos->base);
free(pos);
}