public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Martin Peres <martin.peres@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t 3/3] lib/igt_chamelium: replace EDID IDs with opaque structs
Date: Mon, 17 Jun 2019 10:21:32 +0300	[thread overview]
Message-ID: <55dacc73-164e-f899-0cda-e24d59e5a6ea@linux.intel.com> (raw)
In-Reply-To: <20190614142203.7753-4-simon.ser@intel.com>

On 14/06/2019 17:22, Simon Ser wrote:
> 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>

> ---
>  lib/igt_chamelium.c   | 25 ++++++++++++-------------
>  lib/igt_chamelium.h   |  8 ++++++--
>  tests/kms_chamelium.c |  2 +-
>  3 files changed, 19 insertions(+), 16 deletions(-)
> 
> diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
> index 0c44e56cad86..b83ff395d44b 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));
>  }
>  
>  /**
> diff --git a/lib/igt_chamelium.h b/lib/igt_chamelium.h
> index 28f726c91e83..ce9e9ced75d9 100644
> --- a/lib/igt_chamelium.h
> +++ b/lib/igt_chamelium.h
> @@ -59,6 +59,8 @@ struct chamelium_audio_file {
>  	int channels;
>  };
>  
> +struct chamelium_edid;
> +
>  /**
>   * CHAMELIUM_DEFAULT_EDID: provide this ID to #chamelium_port_set_edid to use
>   * the default EDID.
> @@ -98,9 +100,11 @@ void chamelium_fire_hpd_pulses(struct chamelium *chamelium,
>  void chamelium_schedule_hpd_toggle(struct chamelium *chamelium,
>  				   struct chamelium_port *port, int delay_ms,
>  				   bool rising_edge);
> -int chamelium_new_edid(struct chamelium *chamelium, const unsigned char *edid);
> +struct chamelium_edid *chamelium_new_edid(struct chamelium *chamelium,
> +					  const unsigned char *edid);
>  void chamelium_port_set_edid(struct chamelium *chamelium,
> -			     struct chamelium_port *port, int edid_id);
> +			     struct chamelium_port *port,
> +			     struct chamelium_edid *edid);
>  bool chamelium_port_get_ddc_state(struct chamelium *chamelium,
>  				  struct chamelium_port *port);
>  void chamelium_port_set_ddc_state(struct chamelium *chamelium,
> diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
> index 03ebbd9c4b20..18f504f3bcad 100644
> --- a/tests/kms_chamelium.c
> +++ b/tests/kms_chamelium.c
> @@ -51,7 +51,7 @@ typedef struct {
>  
>  	int drm_fd;
>  
> -	int edids[TEST_EDID_COUNT];
> +	struct chamelium_edid *edids[TEST_EDID_COUNT];
>  } data_t;
>  
>  #define HOTPLUG_TIMEOUT 20 /* seconds */
> 
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2019-06-17  7:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-14 14:22 [igt-dev] [PATCH i-g-t 0/3] Preliminary work for automagical Chamelium port mapping Simon Ser
2019-06-14 14:22 ` [igt-dev] [PATCH i-g-t 1/3] tests/kms_chamelium: drop TEST_EDID_CHAMELIUM_DEFAULT Simon Ser
2019-06-17  7:17   ` Martin Peres
2019-06-14 14:22 ` [igt-dev] [PATCH i-g-t 2/3] lib/igt_chamelium: fix EDID list Simon Ser
2019-06-17 10:57   ` Arkadiusz Hiler
2019-06-14 14:22 ` [igt-dev] [PATCH i-g-t 3/3] lib/igt_chamelium: replace EDID IDs with opaque structs Simon Ser
2019-06-17  7:21   ` Martin Peres [this message]
2019-06-15  2:56 ` [igt-dev] ✓ Fi.CI.BAT: success for Preliminary work for automagical Chamelium port mapping Patchwork
2019-06-15 20:39 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55dacc73-164e-f899-0cda-e24d59e5a6ea@linux.intel.com \
    --to=martin.peres@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox