diff options
author | Simon Ser <simon.ser@intel.com> | 2019-06-14 17:04:05 +0300 |
---|---|---|
committer | Simon Ser <simon.ser@intel.com> | 2019-06-17 15:04:42 +0300 |
commit | 1f67ee0d09d6513f487f2be74aae9700e755258a (patch) | |
tree | 74bb3f3c36b969d425d17444b81422c741e7ae1a /lib/igt_chamelium.c | |
parent | 9651105df6e7261fe3df8e05d934aac0847ec93e (diff) |
lib/igt_chamelium: replace EDID IDs with opaque structs
There are two reasons for this:
* An opaque struct is more type-safe than an int
* In the future we'll want to tag EDIDs with the Chamelium port ID, to be able
to automagically infer the DRM connector <-> Chamelium port mapping. This is
necessary for DP MST (connector names are not stable).
Signed-off-by: Simon Ser <simon.ser@intel.com>
Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
Diffstat (limited to 'lib/igt_chamelium.c')
-rw-r--r-- | lib/igt_chamelium.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c index 0c44e56c..b83ff395 100644 --- a/lib/igt_chamelium.c +++ b/lib/igt_chamelium.c @@ -530,13 +530,13 @@ 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. * - * Returns: The ID of the EDID uploaded to the chamelium. + * Returns: An opaque pointer to the Chamelium EDID */ -int chamelium_new_edid(struct chamelium *chamelium, - const unsigned char *raw_edid) +struct chamelium_edid *chamelium_new_edid(struct chamelium *chamelium, + const unsigned char *raw_edid) { xmlrpc_value *res; - struct chamelium_edid *allocated_edid; + struct chamelium_edid *chamelium_edid; int edid_id; struct edid *edid = (struct edid *) raw_edid; size_t edid_size = sizeof(struct edid) + @@ -548,14 +548,12 @@ int chamelium_new_edid(struct chamelium *chamelium, xmlrpc_read_int(&chamelium->env, res, &edid_id); xmlrpc_DECREF(res); - allocated_edid = malloc(sizeof(struct chamelium_edid)); - memset(allocated_edid, 0, sizeof(*allocated_edid)); + chamelium_edid = calloc(1, sizeof(struct chamelium_edid)); + chamelium_edid->id = edid_id; - allocated_edid->id = edid_id; + igt_list_add(&chamelium_edid->link, &chamelium->edids); - igt_list_add(&allocated_edid->link, &chamelium->edids); - - return edid_id; + return chamelium_edid; } static void chamelium_destroy_edid(struct chamelium *chamelium, int edid_id) @@ -568,7 +566,7 @@ static void chamelium_destroy_edid(struct chamelium *chamelium, int edid_id) * chamelium_port_set_edid: * @chamelium: The Chamelium instance to use * @port: The port on the Chamelium to set the EDID on - * @edid_id: The ID of an EDID on the chamelium created with + * @edid: The Chamelium EDID to set * #chamelium_new_edid, or 0 to disable the EDID on the port * * Sets a port on the chamelium to use the specified EDID. This does not fire a @@ -578,10 +576,11 @@ static void chamelium_destroy_edid(struct chamelium *chamelium, int edid_id) * change. */ void chamelium_port_set_edid(struct chamelium *chamelium, - struct chamelium_port *port, int edid_id) + struct chamelium_port *port, + struct chamelium_edid *edid) { xmlrpc_DECREF(chamelium_rpc(chamelium, NULL, "ApplyEdid", "(ii)", - port->id, edid_id)); + port->id, edid->id)); } /** |