[igt-dev] [PATCH i-g-t] lib/igt_kms: remove length parameter from kmstest_force_edid

Ser, Simon simon.ser at intel.com
Tue Jul 2 12:52:11 UTC 2019


Actually, I've posted this patch as part of the 4K EDID series, so
please ignore it.

On Tue, 2019-07-02 at 15:12 +0300, Simon Ser wrote:
> Given an EDID, computing the size is trivial. Instead of having one size
> constant per EDID and hope the callers use the right one (ie. *not* EDID_LENGTH
> when there's an extension), we can make functions that take EDIDs compute the
> size if they need it.
> 
> We have tests in lib/tests/igt_edid.c which assert the number of extensions
> present in the EDID anyway.
> 
> Signed-off-by: Simon Ser <simon.ser at intel.com>
> ---
>  lib/igt_kms.c                     |  9 ++++++---
>  lib/igt_kms.h                     |  3 +--
>  tests/kms_3d.c                    |  4 ++--
>  tests/kms_force_connector_basic.c | 12 ++++++------
>  tests/kms_hdmi_inject.c           | 11 ++++-------
>  5 files changed, 19 insertions(+), 20 deletions(-)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index dc8992cb043b..f8185edf6e8b 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -182,6 +182,8 @@ const unsigned char *igt_kms_get_alt_edid(void)
>  	return (unsigned char *) &edid;
>  }
> 
> +#define AUDIO_EDID_LENGTH (2 * EDID_LENGTH)
> +
>  static void
>  generate_audio_edid(unsigned char raw_edid[static AUDIO_EDID_LENGTH],
>  		    bool with_vsd, struct cea_sad *sad,
> @@ -998,7 +1000,7 @@ bool kmstest_force_connector(int drm_fd, drmModeConnector *connector,
>   * If @length is zero, the forced EDID will be removed.
>   */
>  void kmstest_force_edid(int drm_fd, drmModeConnector *connector,
> -			const unsigned char *edid, size_t length)
> +			const unsigned char *edid)
>  {
>  	char *path;
>  	int debugfs_fd, ret;
> @@ -1011,10 +1013,11 @@ void kmstest_force_edid(int drm_fd, drmModeConnector *connector,
> 
>  	igt_require(debugfs_fd != -1);
> 
> -	if (length == 0)
> +	if (edid == NULL)
>  		ret = write(debugfs_fd, "reset", 5);
>  	else
> -		ret = write(debugfs_fd, edid, length);
> +		ret = write(debugfs_fd, edid,
> +			    edid_get_size((struct edid *) edid));
>  	close(debugfs_fd);
> 
>  	/* To allow callers to always use GetConnectorCurrent we need to force a
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index a448a003ae56..f72508640712 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -197,7 +197,7 @@ bool kmstest_force_connector(int fd, drmModeConnector *connector,
>  void kmstest_edid_add_3d(const unsigned char *edid, size_t length, unsigned char *new_edid_ptr[], size_t *new_length);
>  void kmstest_edid_add_4k(const unsigned char *edid, size_t length, unsigned char *new_edid_ptr[], size_t *new_length);
>  void kmstest_force_edid(int drm_fd, drmModeConnector *connector,
> -			const unsigned char *edid, size_t length);
> +			const unsigned char *edid);
> 
>  bool kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
>  					drmModeModeInfo *mode);
> @@ -759,7 +759,6 @@ struct cea_sad;
>  struct cea_speaker_alloc;
> 
>  #define EDID_LENGTH 128
> -#define AUDIO_EDID_LENGTH (2 * EDID_LENGTH)
>  const unsigned char *igt_kms_get_base_edid(void);
>  const unsigned char *igt_kms_get_alt_edid(void);
>  const unsigned char *igt_kms_get_hdmi_audio_edid(void);
> diff --git a/tests/kms_3d.c b/tests/kms_3d.c
> index df8185abebc4..a170814f6356 100644
> --- a/tests/kms_3d.c
> +++ b/tests/kms_3d.c
> @@ -60,7 +60,7 @@ igt_simple_main
>  	kmstest_edid_add_3d(igt_kms_get_base_edid(), EDID_LENGTH, &edid,
>  			    &length);
> 
> -	kmstest_force_edid(drm_fd, connector, edid, length);
> +	kmstest_force_edid(drm_fd, connector, edid);
>  	if (!kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_ON))
>  		igt_skip("Could not force connector on\n");
> 
> @@ -113,7 +113,7 @@ igt_simple_main
>  	}
> 
>  	kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_UNSPECIFIED);
> -	kmstest_force_edid(drm_fd, connector, NULL, 0);
> +	kmstest_force_edid(drm_fd, connector, NULL);
> 
>  	drmModeFreeConnector(connector);
>  	free(edid);
> diff --git a/tests/kms_force_connector_basic.c b/tests/kms_force_connector_basic.c
> index 20812d5e3189..f1533e5415c0 100644
> --- a/tests/kms_force_connector_basic.c
> +++ b/tests/kms_force_connector_basic.c
> @@ -48,7 +48,7 @@ static void reset_connectors(void)
>  		kmstest_force_connector(drm_fd, connector,
>  					FORCE_CONNECTOR_UNSPECIFIED);
> 
> -		kmstest_force_edid(drm_fd, connector, NULL, 0);
> +		kmstest_force_edid(drm_fd, connector, NULL);
> 
>  		drmModeFreeConnector(connector);
>  	}
> @@ -247,7 +247,7 @@ igt_main_args("", long_opts, help_str, opt_handler, NULL)
> 
>  		/* test edid forcing */
>  		kmstest_force_edid(drm_fd, vga_connector,
> -				   igt_kms_get_base_edid(), EDID_LENGTH);
> +				   igt_kms_get_base_edid());
>  		temp = drmModeGetConnectorCurrent(drm_fd,
>  						  vga_connector->connector_id);
> 
> @@ -260,7 +260,7 @@ igt_main_args("", long_opts, help_str, opt_handler, NULL)
>  		drmModeFreeConnector(temp);
> 
>  		/* remove edid */
> -		kmstest_force_edid(drm_fd, vga_connector, NULL, 0);
> +		kmstest_force_edid(drm_fd, vga_connector, NULL);
>  		kmstest_force_connector(drm_fd, vga_connector,
>  					FORCE_CONNECTOR_UNSPECIFIED);
>  		temp = drmModeGetConnectorCurrent(drm_fd,
> @@ -280,7 +280,7 @@ igt_main_args("", long_opts, help_str, opt_handler, NULL)
> 
>  		/* test pruning of stale modes */
>  		kmstest_force_edid(drm_fd, vga_connector,
> -				   igt_kms_get_alt_edid(), EDID_LENGTH);
> +				   igt_kms_get_alt_edid());
>  		temp = drmModeGetConnectorCurrent(drm_fd,
>  						  vga_connector->connector_id);
> 
> @@ -294,7 +294,7 @@ igt_main_args("", long_opts, help_str, opt_handler, NULL)
>  		drmModeFreeConnector(temp);
> 
>  		kmstest_force_edid(drm_fd, vga_connector,
> -				   igt_kms_get_base_edid(), EDID_LENGTH);
> +				   igt_kms_get_base_edid());
>  		temp = drmModeGetConnectorCurrent(drm_fd,
>  						  vga_connector->connector_id);
> 
> @@ -307,7 +307,7 @@ igt_main_args("", long_opts, help_str, opt_handler, NULL)
> 
>  		drmModeFreeConnector(temp);
> 
> -		kmstest_force_edid(drm_fd, vga_connector, NULL, 0);
> +		kmstest_force_edid(drm_fd, vga_connector, NULL);
>  		kmstest_force_connector(drm_fd, vga_connector,
>  					FORCE_CONNECTOR_UNSPECIFIED);
>  	}
> diff --git a/tests/kms_hdmi_inject.c b/tests/kms_hdmi_inject.c
> index 8c0d1333db19..9a968fa9e50e 100644
> --- a/tests/kms_hdmi_inject.c
> +++ b/tests/kms_hdmi_inject.c
> @@ -93,7 +93,7 @@ hdmi_inject_4k(int drm_fd, drmModeConnector *connector)
>  	kmstest_edid_add_4k(igt_kms_get_base_edid(), EDID_LENGTH, &edid,
>  			    &length);
> 
> -	kmstest_force_edid(drm_fd, connector, edid, length);
> +	kmstest_force_edid(drm_fd, connector, edid);
> 
>  	if (!kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_ON))
>  		igt_skip("Could not force connector on\n");
> @@ -134,7 +134,7 @@ hdmi_inject_4k(int drm_fd, drmModeConnector *connector)
>  	igt_remove_fb(drm_fd, &fb);
> 
>  	kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_UNSPECIFIED);
> -	kmstest_force_edid(drm_fd, connector, NULL, 0);
> +	kmstest_force_edid(drm_fd, connector, NULL);
> 
>  	free(edid);
>  }
> @@ -143,15 +143,12 @@ static void
>  hdmi_inject_audio(int drm_fd, drmModeConnector *connector)
>  {
>  	const unsigned char *edid;
> -	size_t length;
>  	int fb_id, cid, ret, crtc_mask = -1;
>  	struct igt_fb fb;
>  	struct kmstest_connector_config config;
> 
>  	edid = igt_kms_get_hdmi_audio_edid();
> -	length = AUDIO_EDID_LENGTH;
> -
> -	kmstest_force_edid(drm_fd, connector, edid, length);
> +	kmstest_force_edid(drm_fd, connector, edid);
> 
>  	if (!kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_ON))
>  		igt_skip("Could not force connector on\n");
> @@ -191,7 +188,7 @@ hdmi_inject_audio(int drm_fd, drmModeConnector *connector)
>  	kmstest_dump_mode(&connector->modes[0]);
> 
>  	kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_UNSPECIFIED);
> -	kmstest_force_edid(drm_fd, connector, NULL, 0);
> +	kmstest_force_edid(drm_fd, connector, NULL);
>  }
> 
>  igt_main
> --
> 2.22.0
> 
> _______________________________________________
> igt-dev mailing list
> igt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev


More information about the igt-dev mailing list