summaryrefslogtreecommitdiff
path: root/lib/igt_chamelium.c
diff options
context:
space:
mode:
authorSimon Ser <simon.ser@intel.com>2019-06-17 18:29:14 +0300
committerSimon Ser <simon.ser@intel.com>2019-07-19 10:50:24 +0300
commit26d8543681efc78e68dcce7273e7c39084d022ca (patch)
treea47c170eebb99cb0143b8e5e54934bb793399547 /lib/igt_chamelium.c
parent9b35bb9edf02ed4f024f48968767fcdcc49264a2 (diff)
lib/igt_chamelium: allow EDIDs to be mutated for each port
This adds the infrastructure necessary to change EDIDs provided to chamelium_new_edid, without actually doing it yet. This commit just updates the API to make it possible, documents expectations and updates callers accordingly. Mutating EDIDs is necessary to add an identifier to them (e.g. by adding a serial number) and to be able to map Chamelium ports to DRM connectors. A new function chamelium_edid_get_raw allows callers to retrieve the exact EDID used for a particular port. Signed-off-by: Simon Ser <simon.ser@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Diffstat (limited to 'lib/igt_chamelium.c')
-rw-r--r--lib/igt_chamelium.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 94c363ae..ae10bf4c 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -84,6 +84,7 @@
struct chamelium_edid {
int id;
+ struct edid *raw;
struct igt_list link;
};
@@ -531,6 +532,11 @@ void chamelium_schedule_hpd_toggle(struct chamelium *chamelium,
* Uploads and registers a new EDID with the chamelium. The EDID will be
* destroyed automatically when #chamelium_deinit is called.
*
+ * Callers shouldn't assume that the raw EDID they provide is uploaded as-is to
+ * the Chamelium. The EDID may be mutated (e.g. a serial number can be appended
+ * to be able to uniquely identify the EDID). To retrieve the exact EDID that
+ * will be applied to a particular port, use #chamelium_edid_get_raw.
+ *
* Returns: An opaque pointer to the Chamelium EDID
*/
struct chamelium_edid *chamelium_new_edid(struct chamelium *chamelium,
@@ -540,16 +546,18 @@ struct chamelium_edid *chamelium_new_edid(struct chamelium *chamelium,
struct chamelium_edid *chamelium_edid;
int edid_id;
const struct edid *edid = (struct edid *) raw_edid;
+ size_t edid_size = edid_get_size(edid);
res = chamelium_rpc(chamelium, NULL, "CreateEdid", "(6)",
- raw_edid, edid_get_size(edid));
+ raw_edid, edid_size);
xmlrpc_read_int(&chamelium->env, res, &edid_id);
xmlrpc_DECREF(res);
chamelium_edid = calloc(1, sizeof(struct chamelium_edid));
chamelium_edid->id = edid_id;
-
+ chamelium_edid->raw = malloc(edid_size);
+ memcpy(chamelium_edid->raw, raw_edid, edid_size);
igt_list_add(&chamelium_edid->link, &chamelium->edids);
return chamelium_edid;
@@ -562,6 +570,23 @@ static void chamelium_destroy_edid(struct chamelium *chamelium, int edid_id)
}
/**
+ * chamelium_edid_get_raw: get the raw EDID
+ * @edid: the Chamelium EDID
+ * @port: the Chamelium port
+ *
+ * The EDID provided to #chamelium_new_edid may be mutated for identification
+ * purposes. This function allows to retrieve the exact EDID that will be set
+ * for a given port.
+ *
+ * The returned raw EDID is only valid until the next call to this function.
+ */
+const struct edid *chamelium_edid_get_raw(struct chamelium_edid *edid,
+ struct chamelium_port *port)
+{
+ return edid->raw;
+}
+
+/**
* chamelium_port_set_edid:
* @chamelium: The Chamelium instance to use
* @port: The port on the Chamelium to set the EDID on
@@ -1964,6 +1989,7 @@ void chamelium_deinit(struct chamelium *chamelium)
/* Destroy any EDIDs we created to make sure we don't leak them */
igt_list_for_each_safe(pos, tmp, &chamelium->edids, link) {
chamelium_destroy_edid(chamelium, pos->id);
+ free(pos->raw);
free(pos);
}