[igt-dev] [PATCH i-g-t v2 1/6] lib/igt_kms: remove length parameter from kmstest_force_edid
Simon Ser
simon.ser at intel.com
Wed Jul 3 12:02:21 UTC 2019
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>
Reviewed-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
lib/igt_kms.c | 13 +++++++------
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, 20 insertions(+), 23 deletions(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index dc8992cb043b..a66a685009cd 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,
@@ -990,15 +992,13 @@ bool kmstest_force_connector(int drm_fd, drmModeConnector *connector,
* @drm_fd: drm file descriptor
* @connector: connector to set @edid on
* @edid: An EDID data block
- * @length: length of the EDID data. #EDID_LENGTH defines the standard EDID
- * length
*
* Set the EDID data on @connector to @edid. See also #igt_kms_get_base_edid.
*
- * If @length is zero, the forced EDID will be removed.
+ * If @edid is NULL, 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 +1011,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
More information about the igt-dev
mailing list