[igt-dev] [PATCH i-g-t 2/4] lib/igt_kms: drop EDID_LENGTH, replace with EDID_BLOCK_SIZE
Simon Ser
simon.ser at intel.com
Fri Jul 19 11:38:45 UTC 2019
EDID_LENGTH is misleading because EDIDs are a variable size (they contain one
or more 128-byte EDID blocks). This commit renames it to EDID_BLOCK_SIZE which
makes it clear users need to call edid_get_size to get the total size.
The declaration has also been moved to igt_edid.
("Size" has been chosen over "length" because it's clearer that it's a number
of bytes, not a number of elements)
Signed-off-by: Simon Ser <simon.ser at intel.com>
---
lib/igt_edid.h | 2 ++
lib/igt_kms.c | 8 ++++----
lib/igt_kms.h | 1 -
lib/tests/igt_edid.c | 13 ++++++++-----
tests/i915/i915_pm_rpm.c | 13 +++++++------
5 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/lib/igt_edid.h b/lib/igt_edid.h
index 606541ac63b4..319ccc3dc734 100644
--- a/lib/igt_edid.h
+++ b/lib/igt_edid.h
@@ -32,6 +32,8 @@
#include <xf86drmMode.h>
+#define EDID_BLOCK_SIZE 128
+
/**
* est_timings: set of established timings
*/
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index b7fb165e0678..e66f5af2083c 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -158,10 +158,10 @@ const struct edid *igt_kms_get_alt_edid(void)
return &edid;
}
-#define AUDIO_EDID_LENGTH (2 * EDID_LENGTH)
+#define AUDIO_EDID_SIZE (2 * EDID_BLOCK_SIZE)
static const struct edid *
-generate_audio_edid(unsigned char raw_edid[static AUDIO_EDID_LENGTH],
+generate_audio_edid(unsigned char raw_edid[static AUDIO_EDID_SIZE],
bool with_vsdb, struct cea_sad *sad,
struct cea_speaker_alloc *speaker_alloc)
{
@@ -214,7 +214,7 @@ const struct edid *igt_kms_get_hdmi_audio_edid(void)
{
int channels;
uint8_t sampling_rates, sample_sizes;
- static unsigned char raw_edid[AUDIO_EDID_LENGTH] = {0};
+ static unsigned char raw_edid[AUDIO_EDID_SIZE] = {0};
struct cea_sad sad = {0};
struct cea_speaker_alloc speaker_alloc = {0};
@@ -238,7 +238,7 @@ const struct edid *igt_kms_get_dp_audio_edid(void)
{
int channels;
uint8_t sampling_rates, sample_sizes;
- static unsigned char raw_edid[AUDIO_EDID_LENGTH] = {0};
+ static unsigned char raw_edid[AUDIO_EDID_SIZE] = {0};
struct cea_sad sad = {0};
struct cea_speaker_alloc speaker_alloc = {0};
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 0b9374a16b0e..a3b1bece95be 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -754,7 +754,6 @@ void igt_reset_connectors(void);
uint32_t kmstest_get_vbl_flag(uint32_t pipe_id);
-#define EDID_LENGTH 128
const struct edid *igt_kms_get_base_edid(void);
const struct edid *igt_kms_get_alt_edid(void);
const struct edid *igt_kms_get_hdmi_audio_edid(void);
diff --git a/lib/tests/igt_edid.c b/lib/tests/igt_edid.c
index bbbf15058982..8474d29e27bc 100644
--- a/lib/tests/igt_edid.c
+++ b/lib/tests/igt_edid.c
@@ -57,7 +57,7 @@ static bool edid_block_checksum(const unsigned char *raw_edid)
size_t i;
unsigned char csum = 0;
- for (i = 0; i < EDID_LENGTH; i++) {
+ for (i = 0; i < EDID_BLOCK_SIZE; i++) {
csum += raw_edid[i];
}
@@ -81,7 +81,7 @@ igt_simple_main
{0},
}, *f;
const struct edid *edid;
- const uint8_t *raw_edid;
+ const uint8_t *raw_edid, *raw_block;
size_t i;
for (f = funcs; f->f; f++) {
@@ -97,8 +97,11 @@ igt_simple_main
igt_assert_f(raw_edid[126] == f->exts,
"unexpected number of extensions on %s EDID",
f->desc);
- for (i = 0; i < f->exts; i++)
- igt_assert_f(edid_block_checksum(raw_edid + (i + 1) * EDID_LENGTH),
- "CEA block checksum failed on %s EDID", f->desc);
+ for (i = 0; i < f->exts; i++) {
+ raw_block = raw_edid + (i + 1) * EDID_BLOCK_SIZE;
+ igt_assert_f(edid_block_checksum(raw_block),
+ "CEA block checksum failed on %s EDID",
+ f->desc);
+ }
}
}
diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
index e2c7ba217081..2168ff72c97b 100644
--- a/tests/i915/i915_pm_rpm.c
+++ b/tests/i915/i915_pm_rpm.c
@@ -50,6 +50,7 @@
#include "igt_sysfs.h"
#include "igt_debugfs.h"
#include "igt_device.h"
+#include "igt_edid.h"
#define MSR_PKG_CST_CONFIG_CONTROL 0xE2
/* HSW/BDW: */
@@ -655,10 +656,10 @@ static bool i2c_read_edid(const char *connector_name, unsigned char *edid)
return rc >= 0;
}
-static void format_hex_string(const unsigned char edid[static EDID_LENGTH],
- char buf[static EDID_LENGTH * 5 + 1])
+static void format_hex_string(const unsigned char edid[static EDID_BLOCK_SIZE],
+ char buf[static EDID_BLOCK_SIZE * 5 + 1])
{
- for (int i = 0; i < EDID_LENGTH; ++i)
+ for (int i = 0; i < EDID_BLOCK_SIZE; ++i)
sprintf(buf+i*5, "0x%02x ", edid[i]);
}
@@ -670,7 +671,7 @@ static void test_i2c(struct mode_set_data *data)
for (int i = 0; i < data->res->count_connectors; i++) {
unsigned char *drm_edid = data->edids[i] ? data->edids[i]->data : NULL;
- unsigned char i2c_edid[EDID_LENGTH] = {};
+ unsigned char i2c_edid[EDID_BLOCK_SIZE] = {};
igt_output_t *output = igt_output_from_connector(&display,
data->connectors[i]);
@@ -694,13 +695,13 @@ static void test_i2c(struct mode_set_data *data)
continue;
if (got_i2c_edid && got_drm_edid)
- edids_equal = (0 == memcmp(drm_edid, i2c_edid, EDID_LENGTH));
+ edids_equal = (0 == memcmp(drm_edid, i2c_edid, EDID_BLOCK_SIZE));
else
edids_equal = false;
if (!edids_equal) {
- char buf[5 * EDID_LENGTH + 1];
+ char buf[5 * EDID_BLOCK_SIZE + 1];
igt_critical("Detected EDID mismatch on connector %s\n",
connector_name);
--
2.22.0
More information about the igt-dev
mailing list