* [i-g-t PATCH v4 1/2] lib/igt_kms: Add support for 4K and audio HDMI EDID injection.
@ 2017-03-27 10:28 Abdiel Janulgue
2017-03-27 10:28 ` [i-g-t PATCH v3 2/2] tests/kms_hdmi_inject: Add test for HDMI injection capabilities Abdiel Janulgue
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Abdiel Janulgue @ 2017-03-27 10:28 UTC (permalink / raw)
To: intel-gfx
Based on the initial work by Marius Vlad.
v3: Bring back audio injection
v4: Make a helper for 3d/4k/audio HDMI injection (Petri)
Cc: Petri Latvala <petri.latvala@intel.com>
Signed-off-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
---
lib/igt_kms.c | 230 +++++++++++++++++++++++++++++++++++++++++++---------------
lib/igt_kms.h | 2 +
2 files changed, 175 insertions(+), 57 deletions(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 5811414..9bfa0e1 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -83,7 +83,7 @@
static char *forced_connectors[MAX_CONNECTORS + 1];
static int forced_connectors_device[MAX_CONNECTORS + 1];
-static void update_edid_csum(unsigned char *edid)
+static void update_edid_csum(unsigned char *edid, int cea_pos)
{
int i, sum = 0;
struct tm *tm;
@@ -96,9 +96,9 @@ static void update_edid_csum(unsigned char *edid)
/* calculate checksum */
for (i = 0; i < 127; i++) {
- sum = sum + edid[i];
+ sum = sum + edid[cea_pos + i];
}
- edid[127] = 256 - sum;
+ edid[cea_pos + 127] = 256 - sum;
}
#define VFREQ 60
@@ -136,7 +136,7 @@ static void update_edid_csum(unsigned char *edid)
*/
const unsigned char* igt_kms_get_base_edid(void)
{
- update_edid_csum(base_edid);
+ update_edid_csum(base_edid, 0);
return base_edid;
}
@@ -306,7 +306,7 @@ igt_atomic_fill_pipe_props(igt_display_t *display, igt_pipe_t *pipe,
*/
const unsigned char* igt_kms_get_alt_edid(void)
{
- update_edid_csum(alt_edid);
+ update_edid_csum(alt_edid, 0);
return alt_edid;
}
@@ -1116,6 +1116,59 @@ kmstest_get_property(int drm_fd, uint32_t object_id, uint32_t object_type,
return found;
}
+struct edid_block {
+ int pos;
+ unsigned char *data;
+};
+
+#define DTD_SUPPORTS_AUDIO 1<<6
+
+static struct edid_block
+init_cea_block(const unsigned char *edid, size_t length,
+ unsigned char *new_edid_ptr[], size_t *new_length,
+ char extra_extensions_length,
+ uint32_t dtd_support)
+{
+ struct edid_block new_edid;
+ int n_extensions;
+ int pos;
+ static const char cea_header_len = 4, video_block_len = 6;
+
+ igt_assert(new_edid_ptr != NULL && new_length != NULL);
+
+ *new_length = length + 128;
+
+ new_edid.data = calloc(*new_length, sizeof(char));
+ igt_assert_f(new_edid.data, "Failed to allocate %zu bytes for edid\n", sizeof(new_length));
+ memcpy(new_edid.data, edid, length);
+ *new_edid_ptr = new_edid.data;
+
+ n_extensions = new_edid.data[126];
+ n_extensions++;
+ new_edid.data[126] = n_extensions;
+
+ update_edid_csum(new_edid.data, 0);
+
+ /* add a cea-861 extension block */
+ pos = length;
+ new_edid.data[pos++] = 0x2;
+ new_edid.data[pos++] = 0x3;
+ new_edid.data[pos++] = cea_header_len + video_block_len +
+ extra_extensions_length;
+ new_edid.data[pos++] = dtd_support;
+
+ /* video block (id | length) */
+ new_edid.data[pos++] = 2 << 5 | (video_block_len - 1);
+ new_edid.data[pos++] = 32 | 0x80; /* 1080p @ 24Hz | (native)*/
+ new_edid.data[pos++] = 5; /* 1080i @ 60Hz */
+ new_edid.data[pos++] = 20; /* 1080i @ 50Hz */
+ new_edid.data[pos++] = 4; /* 720p @ 60Hz*/
+ new_edid.data[pos++] = 19; /* 720p @ 50Hz*/
+ new_edid.pos = pos;
+
+ return new_edid;
+}
+
/**
* kmstest_edid_add_3d:
* @edid: an existing valid edid block
@@ -1129,72 +1182,135 @@ kmstest_get_property(int drm_fd, uint32_t object_id, uint32_t object_type,
void kmstest_edid_add_3d(const unsigned char *edid, size_t length,
unsigned char *new_edid_ptr[], size_t *new_length)
{
- unsigned char *new_edid;
- int n_extensions;
- char sum = 0;
- int pos;
- int i;
- char cea_header_len = 4, video_block_len = 6, vsdb_block_len = 11;
-
- igt_assert(new_edid_ptr != NULL && new_length != NULL);
+ char vsdb_block_len = 11;
+ struct edid_block new_edid = init_cea_block(edid, length, new_edid_ptr,
+ new_length, vsdb_block_len,
+ 0);
+ int pos = new_edid.pos;
- *new_length = length + 128;
+ /* vsdb block ( id | length ) */
+ new_edid.data[pos++] = 3 << 5 | (vsdb_block_len - 1);
+ /* registration id */
+ new_edid.data[pos++] = 0x3;
+ new_edid.data[pos++] = 0xc;
+ new_edid.data[pos++] = 0x0;
+ /* source physical address */
+ new_edid.data[pos++] = 0x10;
+ new_edid.data[pos++] = 0x00;
+ /* Supports_AI ... etc */
+ new_edid.data[pos++] = 0x00;
+ /* Max TMDS Clock */
+ new_edid.data[pos++] = 0x00;
+ /* Latency present, HDMI Video Present */
+ new_edid.data[pos++] = 0x20;
+ /* HDMI Video */
+ new_edid.data[pos++] = 0x80;
+ new_edid.data[pos++] = 0x00;
- new_edid = calloc(*new_length, sizeof(char));
- igt_assert_f(new_edid, "Failed to allocate %zu bytes for edid\n", sizeof(new_length));
- memcpy(new_edid, edid, length);
- *new_edid_ptr = new_edid;
+ update_edid_csum(new_edid.data, length);
+}
- n_extensions = new_edid[126];
- n_extensions++;
- new_edid[126] = n_extensions;
+/**
+ * kmstest_edid_add_4k:
+ * @edid: an existing valid edid block
+ * @length: length of @edid
+ * @new_edid_ptr: pointer to where the new edid will be placed
+ * @new_length: pointer to the size of the new edid
+ *
+ * Makes a copy of an existing edid block and adds an extension indicating
+ * a HDMI 4K mode in vsdb.
+ */
+void kmstest_edid_add_4k(const unsigned char *edid, size_t length,
+ unsigned char *new_edid_ptr[], size_t *new_length)
+{
+ char vsdb_block_len = 12;
+ struct edid_block new_edid = init_cea_block(edid, length, new_edid_ptr,
+ new_length, vsdb_block_len,
+ 0);
+ int pos = new_edid.pos;
- /* recompute checksum */
- for (i = 0; i < 127; i++) {
- sum = sum + new_edid[i];
- }
- new_edid[127] = 256 - sum;
+ /* vsdb block ( id | length ) */
+ new_edid.data[pos++] = 3 << 5 | (vsdb_block_len - 1);
+ /* registration id */
+ new_edid.data[pos++] = 0x3;
+ new_edid.data[pos++] = 0xc;
+ new_edid.data[pos++] = 0x0;
+ /* source physical address */
+ new_edid.data[pos++] = 0x10;
+ new_edid.data[pos++] = 0x00;
+ /* Supports_AI ... etc */
+ new_edid.data[pos++] = 0x00;
+ /* Max TMDS Clock */
+ new_edid.data[pos++] = 0x00;
+ /* Latency present, HDMI Video Present */
+ new_edid.data[pos++] = 0x20;
+ /* HDMI Video */
+ new_edid.data[pos++] = 0x00; /* 3D present */
- /* add a cea-861 extension block */
- pos = length;
- new_edid[pos++] = 0x2;
- new_edid[pos++] = 0x3;
- new_edid[pos++] = cea_header_len + video_block_len + vsdb_block_len;
- new_edid[pos++] = 0x0;
+ /* HDMI MODE LEN -- how many entries */
+ new_edid.data[pos++] = 0x20;
+ /* 2160p, specified as short descriptor */
+ new_edid.data[pos++] = 0x01;
- /* video block (id | length) */
- new_edid[pos++] = 2 << 5 | (video_block_len - 1);
- new_edid[pos++] = 32 | 0x80; /* 1080p @ 24Hz | (native)*/
- new_edid[pos++] = 5; /* 1080i @ 60Hz */
- new_edid[pos++] = 20; /* 1080i @ 50Hz */
- new_edid[pos++] = 4; /* 720p @ 60Hz*/
- new_edid[pos++] = 19; /* 720p @ 50Hz*/
+ update_edid_csum(new_edid.data, length);
+}
- /* vsdb block ( id | length ) */
- new_edid[pos++] = 3 << 5 | (vsdb_block_len - 1);
+/**
+ * kmstest_edid_add_audio:
+ * @edid: an existing valid edid block
+ * @length: length of @edid
+ * @new_edid_ptr: pointer to where the new edid will be placed
+ * @new_length: pointer to the size of the new edid
+ *
+ * Makes a copy of an existing edid block and adds an extension indicating
+ * basic audio support and speaker data block.
+ *
+ */
+void kmstest_edid_add_audio(const unsigned char *edid, size_t length,
+ unsigned char *new_edid_ptr[], size_t *new_length)
+{
+ char vsdb_block_len = 10, audio_block_len = 4, spkr_block_len = 4;
+ struct edid_block new_edid = init_cea_block(edid, length, new_edid_ptr,
+ new_length,
+ vsdb_block_len +
+ audio_block_len +
+ spkr_block_len,
+ DTD_SUPPORTS_AUDIO);
+ int pos = new_edid.pos;
+
+ /* audio block, short audio block descriptors */
+ new_edid.data[pos++] = (1 << 5) | (audio_block_len - 1);
+ new_edid.data[pos++] = 0x09; /* Audio Format, PCM */
+ new_edid.data[pos++] = 0x07; /* Frequency, 32, 44.1, 48kHz */
+ new_edid.data[pos++] = 0x07; /* Bit Rate 16, 20, 24 bit */
+
+
+ /* vsdb block ( id | length ) -- need vsdb as well
+ * otherwise the kernel will fallback to lower clock modes */
+ new_edid.data[pos++] = 3 << 5 | (vsdb_block_len - 1);
/* registration id */
- new_edid[pos++] = 0x3;
- new_edid[pos++] = 0xc;
- new_edid[pos++] = 0x0;
+ new_edid.data[pos++] = 0x3;
+ new_edid.data[pos++] = 0xc;
+ new_edid.data[pos++] = 0x0;
/* source physical address */
- new_edid[pos++] = 0x10;
- new_edid[pos++] = 0x00;
+ new_edid.data[pos++] = 0x10;
+ new_edid.data[pos++] = 0x00;
/* Supports_AI ... etc */
- new_edid[pos++] = 0x00;
+ new_edid.data[pos++] = 0x00;
/* Max TMDS Clock */
- new_edid[pos++] = 0x00;
+ new_edid.data[pos++] = 0x00;
/* Latency present, HDMI Video Present */
- new_edid[pos++] = 0x20;
+ new_edid.data[pos++] = 0x20;
/* HDMI Video */
- new_edid[pos++] = 0x80;
- new_edid[pos++] = 0x00;
+ new_edid.data[pos++] = 0x00; /* 3D present */
- /* checksum */
- sum = 0;
- for (i = 0; i < 127; i++) {
- sum = sum + new_edid[length + i];
- }
- new_edid[length + 127] = 256 - sum;
+ /* speaker data block */
+ new_edid.data[pos++] = (4 << 5) | (spkr_block_len - 1);
+ new_edid.data[pos++] = (1 << 5);
+ new_edid.data[pos++] = 0x00;
+ new_edid.data[pos++] = 0x00;
+
+ update_edid_csum(new_edid.data, length);
}
/**
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 595832d..9567a26 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -184,6 +184,8 @@ enum kmstest_broadcast_rgb_mode {
bool kmstest_force_connector(int fd, drmModeConnector *connector,
enum kmstest_force_connector_state state);
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_edid_add_audio(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);
--
2.7.4
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [i-g-t PATCH v3 2/2] tests/kms_hdmi_inject: Add test for HDMI injection capabilities.
2017-03-27 10:28 [i-g-t PATCH v4 1/2] lib/igt_kms: Add support for 4K and audio HDMI EDID injection Abdiel Janulgue
@ 2017-03-27 10:28 ` Abdiel Janulgue
2017-03-29 9:52 ` [i-g-t PATCH v4] " Abdiel Janulgue
2017-03-30 8:09 ` [i-g-t PATCH v5 1/2] " Abdiel Janulgue
2017-04-19 8:13 ` [i-g-t PATCH v4 1/2] lib/igt_kms: Add support for 4K and audio HDMI EDID injection Petri Latvala
2 siblings, 1 reply; 10+ messages in thread
From: Abdiel Janulgue @ 2017-03-27 10:28 UTC (permalink / raw)
To: intel-gfx
From Marius Vlad. Fixed to include proper detection of asound ELD entry.
v3: Make audio injection work
Cc: Petri Latvala <petri.latvala@intel.com>
Signed-off-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
---
tests/Makefile.sources | 1 +
tests/kms_hdmi_inject.c | 272 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 273 insertions(+)
create mode 100644 tests/kms_hdmi_inject.c
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 45c21a0..58cd30f 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -223,6 +223,7 @@ TESTS_progs = \
gen3_render_tiledx_blits \
gen3_render_tiledy_blits \
gen7_forcewake_mt \
+ kms_hdmi_inject \
kms_3d \
kms_fence_pin_leak \
kms_force_connector_basic \
diff --git a/tests/kms_hdmi_inject.c b/tests/kms_hdmi_inject.c
new file mode 100644
index 0000000..cb916ac
--- /dev/null
+++ b/tests/kms_hdmi_inject.c
@@ -0,0 +1,272 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#include <dirent.h>
+#include "igt.h"
+
+#define HDISPLAY_4K 3840
+#define VDISPLAY_4K 2160
+
+IGT_TEST_DESCRIPTION("Tests 4K and audio HDMI injection.");
+
+static drmModeConnector *
+get_connector(int drm_fd, drmModeRes *res)
+{
+ int i;
+ drmModeConnector *connector;
+
+ for (i = 0; i < res->count_connectors; i++) {
+
+ connector =
+ drmModeGetConnectorCurrent(drm_fd, res->connectors[i]);
+
+ if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA &&
+ connector->connection == DRM_MODE_DISCONNECTED)
+ break;
+
+ drmModeFreeConnector(connector);
+ connector = NULL;
+ }
+
+ return connector;
+}
+
+static void
+hdmi_inject_4k(int drm_fd, drmModeConnector *connector)
+{
+ unsigned char *edid;
+ size_t length;
+ struct kmstest_connector_config config;
+ int ret, cid, i, crtc_mask = -1;
+ int fb_id;
+ struct igt_fb fb;
+ uint8_t found_4k_mode = 0;
+ uint32_t devid;
+
+ devid = intel_get_drm_devid(drm_fd);
+
+ /* 4K requires at least HSW */
+ igt_require(IS_HASWELL(devid) || intel_gen(devid) >= 8);
+
+ kmstest_edid_add_4k(igt_kms_get_base_edid(), EDID_LENGTH, &edid,
+ &length);
+
+ kmstest_force_edid(drm_fd, connector, edid, length);
+
+ if (!kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_ON))
+ igt_skip("Could not force connector on\n");
+
+ cid = connector->connector_id;
+
+ connector = drmModeGetConnectorCurrent(drm_fd, cid);
+
+ for (i = 0; i < connector->count_modes; i++) {
+ if (connector->modes[i].hdisplay == HDISPLAY_4K &&
+ connector->modes[i].vdisplay == VDISPLAY_4K) {
+ found_4k_mode++;
+ break;
+ }
+ }
+
+ igt_assert(found_4k_mode);
+
+ /* create a configuration */
+ ret = kmstest_get_connector_config(drm_fd, cid, crtc_mask, &config);
+ igt_assert(ret);
+
+ igt_info(" ");
+ kmstest_dump_mode(&connector->modes[i]);
+
+ /* create framebuffer */
+ fb_id = igt_create_fb(drm_fd, connector->modes[i].hdisplay,
+ connector->modes[i].vdisplay,
+ DRM_FORMAT_XRGB8888,
+ LOCAL_DRM_FORMAT_MOD_NONE, &fb);
+
+ ret = drmModeSetCrtc(drm_fd, config.crtc->crtc_id, fb_id, 0, 0,
+ &connector->connector_id, 1,
+ &connector->modes[i]);
+
+ igt_assert(ret == 0);
+
+ igt_remove_fb(drm_fd, &fb);
+
+ kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_UNSPECIFIED);
+ kmstest_force_edid(drm_fd, connector, NULL, 0);
+
+ free(edid);
+}
+
+static bool
+eld_entry_is_igt(const char* path)
+{
+ FILE *in;
+ char buf[1024];
+ uint8_t eld_valid = 0;
+ uint8_t mon_valid = 0;
+
+ in = fopen(path, "r");
+ if (!in)
+ return false;
+
+ memset(buf, 0, 1024);
+
+ while ((fgets(buf, 1024, in)) != NULL) {
+
+ char *line = buf;
+
+ if (!strncasecmp(line, "eld_valid", 9) &&
+ strstr(line, "1")) {
+ eld_valid++;
+ }
+
+ if (!strncasecmp(line, "monitor_name", 12) &&
+ strstr(line, "IGT")) {
+ mon_valid++;
+ }
+ }
+
+ fclose(in);
+ if (mon_valid && eld_valid)
+ return true;
+
+ return false;
+}
+
+static bool
+eld_is_valid(void)
+{
+ DIR *dir;
+ struct dirent *snd_hda;
+ int i;
+
+ for (i = 0; i < 8; i++) {
+ char cards[128];
+
+ snprintf(cards, sizeof(cards), "/proc/asound/card%d", i);
+ dir = opendir(cards);
+ if (!dir)
+ continue;
+
+ while ((snd_hda = readdir(dir))) {
+ char fpath[128];
+
+ if (*snd_hda->d_name == '.' ||
+ strstr(snd_hda->d_name, "eld") == 0)
+ continue;
+
+ snprintf(fpath, sizeof(fpath), "%s/%s", cards,
+ snd_hda->d_name);
+ if (eld_entry_is_igt(fpath)) {
+ closedir(dir);
+ return true;
+ }
+ }
+ closedir(dir);
+ }
+
+ return false;
+}
+
+static void
+hdmi_inject_audio(int drm_fd, drmModeConnector *connector)
+{
+ unsigned char *edid;
+ size_t length;
+ int fb_id, cid, ret, crtc_mask = -1;
+ struct igt_fb fb;
+ struct kmstest_connector_config config;
+
+ kmstest_edid_add_audio(igt_kms_get_base_edid(), EDID_LENGTH, &edid,
+ &length);
+
+ kmstest_force_edid(drm_fd, connector, edid, length);
+
+ if (!kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_ON))
+ igt_skip("Could not force connector on\n");
+
+ cid = connector->connector_id;
+ connector = drmModeGetConnectorCurrent(drm_fd, cid);
+
+ /* create a configuration */
+ ret = kmstest_get_connector_config(drm_fd, cid, crtc_mask, &config);
+ igt_assert(ret);
+
+ /*
+ * Create a framebuffer as to allow the kernel to enable the pipe and
+ * enable the audio encoder.
+ */
+ fb_id = igt_create_fb(drm_fd, connector->modes[0].hdisplay,
+ connector->modes[0].vdisplay,
+ DRM_FORMAT_XRGB8888,
+ LOCAL_DRM_FORMAT_MOD_NONE, &fb);
+
+ ret = drmModeSetCrtc(drm_fd, config.crtc->crtc_id, fb_id, 0, 0,
+ &connector->connector_id, 1,
+ &connector->modes[0]);
+
+
+ igt_assert(ret == 0);
+
+ /*
+ * Test if we have /proc/asound/HDMI/eld#0.0 and is its contents are
+ * valid.
+ */
+ igt_assert(eld_is_valid());
+
+ igt_remove_fb(drm_fd, &fb);
+
+ igt_info(" ");
+ kmstest_dump_mode(&connector->modes[0]);
+
+ kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_UNSPECIFIED);
+ kmstest_force_edid(drm_fd, connector, NULL, 0);
+
+ free(edid);
+}
+
+igt_main
+{
+ int drm_fd;
+ drmModeRes *res;
+ drmModeConnector *connector;
+
+ igt_fixture {
+ drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ res = drmModeGetResources(drm_fd);
+
+ connector = get_connector(drm_fd, res);
+ igt_require(connector);
+ }
+
+ igt_subtest("inject-4k")
+ hdmi_inject_4k(drm_fd, connector);
+
+ igt_subtest("inject-audio")
+ hdmi_inject_audio(drm_fd, connector);
+
+ igt_fixture {
+ drmModeFreeConnector(connector);
+ }
+}
--
2.7.4
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [i-g-t PATCH v4] tests/kms_hdmi_inject: Add test for HDMI injection capabilities.
2017-03-27 10:28 ` [i-g-t PATCH v3 2/2] tests/kms_hdmi_inject: Add test for HDMI injection capabilities Abdiel Janulgue
@ 2017-03-29 9:52 ` Abdiel Janulgue
2017-03-30 6:43 ` Petri Latvala
0 siblings, 1 reply; 10+ messages in thread
From: Abdiel Janulgue @ 2017-03-29 9:52 UTC (permalink / raw)
To: intel-gfx
Original author: Marius Vlad. Includes fixes below.
v4: Add a unit test to make sure synthetic EDID blocks generated by
IGT is valid (suggested by Petri).
v3: Make audio injection work.
Cc: Petri Latvala <petri.latvala@intel.com>
Signed-off-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
---
tests/Makefile.sources | 1 +
tests/kms_hdmi_inject.c | 345 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 346 insertions(+)
create mode 100644 tests/kms_hdmi_inject.c
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 45c21a0..58cd30f 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -223,6 +223,7 @@ TESTS_progs = \
gen3_render_tiledx_blits \
gen3_render_tiledy_blits \
gen7_forcewake_mt \
+ kms_hdmi_inject \
kms_3d \
kms_fence_pin_leak \
kms_force_connector_basic \
diff --git a/tests/kms_hdmi_inject.c b/tests/kms_hdmi_inject.c
new file mode 100644
index 0000000..b7d1433
--- /dev/null
+++ b/tests/kms_hdmi_inject.c
@@ -0,0 +1,345 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#include <dirent.h>
+#include "igt.h"
+
+#define HDISPLAY_4K 3840
+#define VDISPLAY_4K 2160
+
+IGT_TEST_DESCRIPTION("Tests 4K and audio HDMI injection.");
+
+static const unsigned char edid_header[] = {
+ 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00
+};
+
+/**
+ * Sanity check the header of the base EDID block.
+ *
+ * Return: 8 if the header is perfect, down to 0 if it's totally wrong.
+ */
+static int edid_header_is_valid(const unsigned char *raw_edid)
+{
+ int i, score = 0;
+
+ for (i = 0; i < sizeof(edid_header); i++)
+ if (raw_edid[i] == edid_header[i])
+ score++;
+
+ return score;
+}
+/**
+ * Sanity check the checksum of the EDID block.
+ *
+ * Return: 0 if the block is perfect.
+ * See byte 127 of spec
+ * https://en.wikipedia.org/wiki/Extended_Display_Identification_Data#EDID_1.3_data_format
+ */
+static int edid_block_checksum(const unsigned char *raw_edid)
+{
+ int i;
+ unsigned char csum = 0;
+ for (i = 0; i < EDID_LENGTH; i++) {
+ csum += raw_edid[i];
+ }
+
+ return csum;
+}
+
+typedef void (*hdmi_inject_func)(const unsigned char *edid, size_t length,
+ unsigned char *new_edid_ptr[], size_t *new_length);
+static void
+validate_edid_generation(void)
+{
+ const struct {
+ const char *desc;
+ hdmi_inject_func inject;
+ } funcs[] = {
+ { "3D", kmstest_edid_add_3d },
+ { "4k", kmstest_edid_add_4k },
+ { "audio", kmstest_edid_add_audio },
+ { NULL, NULL },
+ }, *f;
+
+ for (f = funcs; f->inject; f++) {
+ unsigned char *edid;
+ size_t length;
+
+ f->inject(igt_kms_get_base_edid(), EDID_LENGTH, &edid,
+ &length);
+
+ igt_assert_f(edid_header_is_valid(edid) == 8,
+ "invalid header on HDMI %s", f->desc);
+ /* check base edid block */
+ igt_assert_f(edid_block_checksum(edid) == 0,
+ "checksum failed on HDMI %s", f->desc);
+ /* check extension block */
+ igt_assert_f(edid_block_checksum(edid + EDID_LENGTH) == 0,
+ "CEA block checksum failed on HDMI %s", f->desc);
+ }
+}
+
+static drmModeConnector *
+get_connector(int drm_fd, drmModeRes *res)
+{
+ int i;
+ drmModeConnector *connector;
+
+ for (i = 0; i < res->count_connectors; i++) {
+
+ connector =
+ drmModeGetConnectorCurrent(drm_fd, res->connectors[i]);
+
+ if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA &&
+ connector->connection == DRM_MODE_DISCONNECTED)
+ break;
+
+ drmModeFreeConnector(connector);
+ connector = NULL;
+ }
+
+ return connector;
+}
+
+static void
+hdmi_inject_4k(int drm_fd, drmModeConnector *connector)
+{
+ unsigned char *edid;
+ size_t length;
+ struct kmstest_connector_config config;
+ int ret, cid, i, crtc_mask = -1;
+ int fb_id;
+ struct igt_fb fb;
+ uint8_t found_4k_mode = 0;
+ uint32_t devid;
+
+ devid = intel_get_drm_devid(drm_fd);
+
+ /* 4K requires at least HSW */
+ igt_require(IS_HASWELL(devid) || intel_gen(devid) >= 8);
+
+ kmstest_edid_add_4k(igt_kms_get_base_edid(), EDID_LENGTH, &edid,
+ &length);
+
+ kmstest_force_edid(drm_fd, connector, edid, length);
+
+ if (!kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_ON))
+ igt_skip("Could not force connector on\n");
+
+ cid = connector->connector_id;
+
+ connector = drmModeGetConnectorCurrent(drm_fd, cid);
+
+ for (i = 0; i < connector->count_modes; i++) {
+ if (connector->modes[i].hdisplay == HDISPLAY_4K &&
+ connector->modes[i].vdisplay == VDISPLAY_4K) {
+ found_4k_mode++;
+ break;
+ }
+ }
+
+ igt_assert(found_4k_mode);
+
+ /* create a configuration */
+ ret = kmstest_get_connector_config(drm_fd, cid, crtc_mask, &config);
+ igt_assert(ret);
+
+ igt_info(" ");
+ kmstest_dump_mode(&connector->modes[i]);
+
+ /* create framebuffer */
+ fb_id = igt_create_fb(drm_fd, connector->modes[i].hdisplay,
+ connector->modes[i].vdisplay,
+ DRM_FORMAT_XRGB8888,
+ LOCAL_DRM_FORMAT_MOD_NONE, &fb);
+
+ ret = drmModeSetCrtc(drm_fd, config.crtc->crtc_id, fb_id, 0, 0,
+ &connector->connector_id, 1,
+ &connector->modes[i]);
+
+ igt_assert(ret == 0);
+
+ igt_remove_fb(drm_fd, &fb);
+
+ kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_UNSPECIFIED);
+ kmstest_force_edid(drm_fd, connector, NULL, 0);
+
+ free(edid);
+}
+
+static bool
+eld_entry_is_igt(const char* path)
+{
+ FILE *in;
+ char buf[1024];
+ uint8_t eld_valid = 0;
+ uint8_t mon_valid = 0;
+
+ in = fopen(path, "r");
+ if (!in)
+ return false;
+
+ memset(buf, 0, 1024);
+
+ while ((fgets(buf, 1024, in)) != NULL) {
+
+ char *line = buf;
+
+ if (!strncasecmp(line, "eld_valid", 9) &&
+ strstr(line, "1")) {
+ eld_valid++;
+ }
+
+ if (!strncasecmp(line, "monitor_name", 12) &&
+ strstr(line, "IGT")) {
+ mon_valid++;
+ }
+ }
+
+ fclose(in);
+ if (mon_valid && eld_valid)
+ return true;
+
+ return false;
+}
+
+static bool
+eld_is_valid(void)
+{
+ DIR *dir;
+ struct dirent *snd_hda;
+ int i;
+
+ for (i = 0; i < 8; i++) {
+ char cards[128];
+
+ snprintf(cards, sizeof(cards), "/proc/asound/card%d", i);
+ dir = opendir(cards);
+ if (!dir)
+ continue;
+
+ while ((snd_hda = readdir(dir))) {
+ char fpath[128];
+
+ if (*snd_hda->d_name == '.' ||
+ strstr(snd_hda->d_name, "eld") == 0)
+ continue;
+
+ snprintf(fpath, sizeof(fpath), "%s/%s", cards,
+ snd_hda->d_name);
+ if (eld_entry_is_igt(fpath)) {
+ closedir(dir);
+ return true;
+ }
+ }
+ closedir(dir);
+ }
+
+ return false;
+}
+
+static void
+hdmi_inject_audio(int drm_fd, drmModeConnector *connector)
+{
+ unsigned char *edid;
+ size_t length;
+ int fb_id, cid, ret, crtc_mask = -1;
+ struct igt_fb fb;
+ struct kmstest_connector_config config;
+
+ kmstest_edid_add_audio(igt_kms_get_base_edid(), EDID_LENGTH, &edid,
+ &length);
+
+ kmstest_force_edid(drm_fd, connector, edid, length);
+
+ if (!kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_ON))
+ igt_skip("Could not force connector on\n");
+
+ cid = connector->connector_id;
+ connector = drmModeGetConnectorCurrent(drm_fd, cid);
+
+ /* create a configuration */
+ ret = kmstest_get_connector_config(drm_fd, cid, crtc_mask, &config);
+ igt_assert(ret);
+
+ /*
+ * Create a framebuffer as to allow the kernel to enable the pipe and
+ * enable the audio encoder.
+ */
+ fb_id = igt_create_fb(drm_fd, connector->modes[0].hdisplay,
+ connector->modes[0].vdisplay,
+ DRM_FORMAT_XRGB8888,
+ LOCAL_DRM_FORMAT_MOD_NONE, &fb);
+
+ ret = drmModeSetCrtc(drm_fd, config.crtc->crtc_id, fb_id, 0, 0,
+ &connector->connector_id, 1,
+ &connector->modes[0]);
+
+
+ igt_assert(ret == 0);
+
+ /*
+ * Test if we have /proc/asound/HDMI/eld#0.0 and is its contents are
+ * valid.
+ */
+ igt_assert(eld_is_valid());
+
+ igt_remove_fb(drm_fd, &fb);
+
+ igt_info(" ");
+ kmstest_dump_mode(&connector->modes[0]);
+
+ kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_UNSPECIFIED);
+ kmstest_force_edid(drm_fd, connector, NULL, 0);
+
+ free(edid);
+}
+
+igt_main
+{
+ int drm_fd;
+ drmModeRes *res;
+ drmModeConnector *connector;
+
+ igt_fixture {
+ drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ res = drmModeGetResources(drm_fd);
+
+ connector = get_connector(drm_fd, res);
+ igt_require(connector);
+ }
+
+ igt_subtest("valid-cea-block")
+ validate_edid_generation();
+
+ igt_subtest("inject-4k")
+ hdmi_inject_4k(drm_fd, connector);
+
+ igt_subtest("inject-audio")
+ hdmi_inject_audio(drm_fd, connector);
+
+ igt_fixture {
+ drmModeFreeConnector(connector);
+ }
+}
--
2.7.4
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [i-g-t PATCH v4] tests/kms_hdmi_inject: Add test for HDMI injection capabilities.
2017-03-29 9:52 ` [i-g-t PATCH v4] " Abdiel Janulgue
@ 2017-03-30 6:43 ` Petri Latvala
2017-03-30 6:46 ` Abdiel Janulgue
0 siblings, 1 reply; 10+ messages in thread
From: Petri Latvala @ 2017-03-30 6:43 UTC (permalink / raw)
To: Abdiel Janulgue; +Cc: intel-gfx
On Wed, Mar 29, 2017 at 12:52:29PM +0300, Abdiel Janulgue wrote:
> Original author: Marius Vlad. Includes fixes below.
>
> v4: Add a unit test to make sure synthetic EDID blocks generated by
> IGT is valid (suggested by Petri).
>
No no, I meant a build-time test, in lib/tests, run by 'make [dist]check'.
--
Petri Latvala
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [i-g-t PATCH v4] tests/kms_hdmi_inject: Add test for HDMI injection capabilities.
2017-03-30 6:43 ` Petri Latvala
@ 2017-03-30 6:46 ` Abdiel Janulgue
0 siblings, 0 replies; 10+ messages in thread
From: Abdiel Janulgue @ 2017-03-30 6:46 UTC (permalink / raw)
To: Petri Latvala; +Cc: intel-gfx
On 30.03.2017 09:43, Petri Latvala wrote:
> On Wed, Mar 29, 2017 at 12:52:29PM +0300, Abdiel Janulgue wrote:
>> Original author: Marius Vlad. Includes fixes below.
>>
>> v4: Add a unit test to make sure synthetic EDID blocks generated by
>> IGT is valid (suggested by Petri).
>>
>
>
> No no, I meant a build-time test, in lib/tests, run by 'make [dist]check'.
>
>
Ok, I'll add that as well. btw, I think the unit test in itself seem to
be good addition to sanity-check the generated blocks.
Thanks
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 10+ messages in thread
* [i-g-t PATCH v5 1/2] tests/kms_hdmi_inject: Add test for HDMI injection capabilities.
2017-03-27 10:28 [i-g-t PATCH v4 1/2] lib/igt_kms: Add support for 4K and audio HDMI EDID injection Abdiel Janulgue
2017-03-27 10:28 ` [i-g-t PATCH v3 2/2] tests/kms_hdmi_inject: Add test for HDMI injection capabilities Abdiel Janulgue
@ 2017-03-30 8:09 ` Abdiel Janulgue
2017-03-30 8:09 ` [i-g-t PATCH 2/2] lib/tests: Add kmstest_edid_add_* selftests Abdiel Janulgue
2017-04-19 8:13 ` [i-g-t PATCH v4 1/2] lib/igt_kms: Add support for 4K and audio HDMI EDID injection Petri Latvala
2 siblings, 1 reply; 10+ messages in thread
From: Abdiel Janulgue @ 2017-03-30 8:09 UTC (permalink / raw)
To: intel-gfx
Original author: Marius Vlad. Includes fixes below.
v5: Convert unit tests to lib selftest.
v4: Add a unit test to make sure synthetic EDID blocks generated by
IGT is valid (suggested by Petri).
v3: Make audio injection work.
Cc: Petri Latvala <petri.latvala@intel.com>
Signed-off-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
---
tests/Makefile.sources | 1 +
tests/kms_hdmi_inject.c | 272 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 273 insertions(+)
create mode 100644 tests/kms_hdmi_inject.c
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 45c21a0..58cd30f 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -223,6 +223,7 @@ TESTS_progs = \
gen3_render_tiledx_blits \
gen3_render_tiledy_blits \
gen7_forcewake_mt \
+ kms_hdmi_inject \
kms_3d \
kms_fence_pin_leak \
kms_force_connector_basic \
diff --git a/tests/kms_hdmi_inject.c b/tests/kms_hdmi_inject.c
new file mode 100644
index 0000000..cb916ac
--- /dev/null
+++ b/tests/kms_hdmi_inject.c
@@ -0,0 +1,272 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#include <dirent.h>
+#include "igt.h"
+
+#define HDISPLAY_4K 3840
+#define VDISPLAY_4K 2160
+
+IGT_TEST_DESCRIPTION("Tests 4K and audio HDMI injection.");
+
+static drmModeConnector *
+get_connector(int drm_fd, drmModeRes *res)
+{
+ int i;
+ drmModeConnector *connector;
+
+ for (i = 0; i < res->count_connectors; i++) {
+
+ connector =
+ drmModeGetConnectorCurrent(drm_fd, res->connectors[i]);
+
+ if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA &&
+ connector->connection == DRM_MODE_DISCONNECTED)
+ break;
+
+ drmModeFreeConnector(connector);
+ connector = NULL;
+ }
+
+ return connector;
+}
+
+static void
+hdmi_inject_4k(int drm_fd, drmModeConnector *connector)
+{
+ unsigned char *edid;
+ size_t length;
+ struct kmstest_connector_config config;
+ int ret, cid, i, crtc_mask = -1;
+ int fb_id;
+ struct igt_fb fb;
+ uint8_t found_4k_mode = 0;
+ uint32_t devid;
+
+ devid = intel_get_drm_devid(drm_fd);
+
+ /* 4K requires at least HSW */
+ igt_require(IS_HASWELL(devid) || intel_gen(devid) >= 8);
+
+ kmstest_edid_add_4k(igt_kms_get_base_edid(), EDID_LENGTH, &edid,
+ &length);
+
+ kmstest_force_edid(drm_fd, connector, edid, length);
+
+ if (!kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_ON))
+ igt_skip("Could not force connector on\n");
+
+ cid = connector->connector_id;
+
+ connector = drmModeGetConnectorCurrent(drm_fd, cid);
+
+ for (i = 0; i < connector->count_modes; i++) {
+ if (connector->modes[i].hdisplay == HDISPLAY_4K &&
+ connector->modes[i].vdisplay == VDISPLAY_4K) {
+ found_4k_mode++;
+ break;
+ }
+ }
+
+ igt_assert(found_4k_mode);
+
+ /* create a configuration */
+ ret = kmstest_get_connector_config(drm_fd, cid, crtc_mask, &config);
+ igt_assert(ret);
+
+ igt_info(" ");
+ kmstest_dump_mode(&connector->modes[i]);
+
+ /* create framebuffer */
+ fb_id = igt_create_fb(drm_fd, connector->modes[i].hdisplay,
+ connector->modes[i].vdisplay,
+ DRM_FORMAT_XRGB8888,
+ LOCAL_DRM_FORMAT_MOD_NONE, &fb);
+
+ ret = drmModeSetCrtc(drm_fd, config.crtc->crtc_id, fb_id, 0, 0,
+ &connector->connector_id, 1,
+ &connector->modes[i]);
+
+ igt_assert(ret == 0);
+
+ igt_remove_fb(drm_fd, &fb);
+
+ kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_UNSPECIFIED);
+ kmstest_force_edid(drm_fd, connector, NULL, 0);
+
+ free(edid);
+}
+
+static bool
+eld_entry_is_igt(const char* path)
+{
+ FILE *in;
+ char buf[1024];
+ uint8_t eld_valid = 0;
+ uint8_t mon_valid = 0;
+
+ in = fopen(path, "r");
+ if (!in)
+ return false;
+
+ memset(buf, 0, 1024);
+
+ while ((fgets(buf, 1024, in)) != NULL) {
+
+ char *line = buf;
+
+ if (!strncasecmp(line, "eld_valid", 9) &&
+ strstr(line, "1")) {
+ eld_valid++;
+ }
+
+ if (!strncasecmp(line, "monitor_name", 12) &&
+ strstr(line, "IGT")) {
+ mon_valid++;
+ }
+ }
+
+ fclose(in);
+ if (mon_valid && eld_valid)
+ return true;
+
+ return false;
+}
+
+static bool
+eld_is_valid(void)
+{
+ DIR *dir;
+ struct dirent *snd_hda;
+ int i;
+
+ for (i = 0; i < 8; i++) {
+ char cards[128];
+
+ snprintf(cards, sizeof(cards), "/proc/asound/card%d", i);
+ dir = opendir(cards);
+ if (!dir)
+ continue;
+
+ while ((snd_hda = readdir(dir))) {
+ char fpath[128];
+
+ if (*snd_hda->d_name == '.' ||
+ strstr(snd_hda->d_name, "eld") == 0)
+ continue;
+
+ snprintf(fpath, sizeof(fpath), "%s/%s", cards,
+ snd_hda->d_name);
+ if (eld_entry_is_igt(fpath)) {
+ closedir(dir);
+ return true;
+ }
+ }
+ closedir(dir);
+ }
+
+ return false;
+}
+
+static void
+hdmi_inject_audio(int drm_fd, drmModeConnector *connector)
+{
+ unsigned char *edid;
+ size_t length;
+ int fb_id, cid, ret, crtc_mask = -1;
+ struct igt_fb fb;
+ struct kmstest_connector_config config;
+
+ kmstest_edid_add_audio(igt_kms_get_base_edid(), EDID_LENGTH, &edid,
+ &length);
+
+ kmstest_force_edid(drm_fd, connector, edid, length);
+
+ if (!kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_ON))
+ igt_skip("Could not force connector on\n");
+
+ cid = connector->connector_id;
+ connector = drmModeGetConnectorCurrent(drm_fd, cid);
+
+ /* create a configuration */
+ ret = kmstest_get_connector_config(drm_fd, cid, crtc_mask, &config);
+ igt_assert(ret);
+
+ /*
+ * Create a framebuffer as to allow the kernel to enable the pipe and
+ * enable the audio encoder.
+ */
+ fb_id = igt_create_fb(drm_fd, connector->modes[0].hdisplay,
+ connector->modes[0].vdisplay,
+ DRM_FORMAT_XRGB8888,
+ LOCAL_DRM_FORMAT_MOD_NONE, &fb);
+
+ ret = drmModeSetCrtc(drm_fd, config.crtc->crtc_id, fb_id, 0, 0,
+ &connector->connector_id, 1,
+ &connector->modes[0]);
+
+
+ igt_assert(ret == 0);
+
+ /*
+ * Test if we have /proc/asound/HDMI/eld#0.0 and is its contents are
+ * valid.
+ */
+ igt_assert(eld_is_valid());
+
+ igt_remove_fb(drm_fd, &fb);
+
+ igt_info(" ");
+ kmstest_dump_mode(&connector->modes[0]);
+
+ kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_UNSPECIFIED);
+ kmstest_force_edid(drm_fd, connector, NULL, 0);
+
+ free(edid);
+}
+
+igt_main
+{
+ int drm_fd;
+ drmModeRes *res;
+ drmModeConnector *connector;
+
+ igt_fixture {
+ drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ res = drmModeGetResources(drm_fd);
+
+ connector = get_connector(drm_fd, res);
+ igt_require(connector);
+ }
+
+ igt_subtest("inject-4k")
+ hdmi_inject_4k(drm_fd, connector);
+
+ igt_subtest("inject-audio")
+ hdmi_inject_audio(drm_fd, connector);
+
+ igt_fixture {
+ drmModeFreeConnector(connector);
+ }
+}
--
2.7.4
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [i-g-t PATCH 2/2] lib/tests: Add kmstest_edid_add_* selftests
2017-03-30 8:09 ` [i-g-t PATCH v5 1/2] " Abdiel Janulgue
@ 2017-03-30 8:09 ` Abdiel Janulgue
2017-04-13 8:12 ` Abdiel Janulgue
0 siblings, 1 reply; 10+ messages in thread
From: Abdiel Janulgue @ 2017-03-30 8:09 UTC (permalink / raw)
To: intel-gfx
Sanity check the edid block generation capabilities.
Cc: Petri Latvala <petri.latvala@intel.com>
Signed-off-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
---
lib/tests/Makefile.sources | 1 +
lib/tests/igt_hdmi_inject.c | 96 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 97 insertions(+)
create mode 100644 lib/tests/igt_hdmi_inject.c
diff --git a/lib/tests/Makefile.sources b/lib/tests/Makefile.sources
index 3fcfe14..4cfc0a5 100644
--- a/lib/tests/Makefile.sources
+++ b/lib/tests/Makefile.sources
@@ -13,6 +13,7 @@ check_prog_list = \
igt_subtest_group \
igt_assert \
igt_exit_handler \
+ igt_hdmi_inject \
$(NULL)
TESTS = \
diff --git a/lib/tests/igt_hdmi_inject.c b/lib/tests/igt_hdmi_inject.c
new file mode 100644
index 0000000..9b6780a
--- /dev/null
+++ b/lib/tests/igt_hdmi_inject.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#include "igt.h"
+
+static const unsigned char edid_header[] = {
+ 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00
+};
+
+/**
+ * Sanity check the header of the base EDID block.
+ *
+ * Return: 8 if the header is perfect, down to 0 if it's totally wrong.
+ */
+static int edid_header_is_valid(const unsigned char *raw_edid)
+{
+ int i, score = 0;
+
+ for (i = 0; i < sizeof(edid_header); i++)
+ if (raw_edid[i] == edid_header[i])
+ score++;
+
+ return score;
+}
+
+/**
+ * Sanity check the checksum of the EDID block.
+ *
+ * Return: 0 if the block is perfect.
+ * See byte 127 of spec
+ * https://en.wikipedia.org/wiki/Extended_Display_Identification_Data#EDID_1.3_data_format
+ */
+static int edid_block_checksum(const unsigned char *raw_edid)
+{
+ int i;
+ unsigned char csum = 0;
+ for (i = 0; i < EDID_LENGTH; i++) {
+ csum += raw_edid[i];
+ }
+
+ return csum;
+}
+
+typedef void (*hdmi_inject_func)(const unsigned char *edid, size_t length,
+ unsigned char *new_edid_ptr[], size_t *new_length);
+
+igt_simple_main
+{
+ const struct {
+ const char *desc;
+ hdmi_inject_func inject;
+ } funcs[] = {
+ { "3D", kmstest_edid_add_3d },
+ { "4k", kmstest_edid_add_4k },
+ { "audio", kmstest_edid_add_audio },
+ { NULL, NULL },
+ }, *f;
+
+ for (f = funcs; f->inject; f++) {
+ unsigned char *edid;
+ size_t length;
+
+ f->inject(igt_kms_get_base_edid(), EDID_LENGTH, &edid,
+ &length);
+
+ igt_assert_f(edid_header_is_valid(edid) == 8,
+ "invalid header on HDMI %s", f->desc);
+ /* check base edid block */
+ igt_assert_f(edid_block_checksum(edid) == 0,
+ "checksum failed on HDMI %s", f->desc);
+ /* check extension block */
+ igt_assert_f(edid_block_checksum(edid + EDID_LENGTH) == 0,
+ "CEA block checksum failed on HDMI %s", f->desc);
+ }
+}
--
2.7.4
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [i-g-t PATCH 2/2] lib/tests: Add kmstest_edid_add_* selftests
2017-03-30 8:09 ` [i-g-t PATCH 2/2] lib/tests: Add kmstest_edid_add_* selftests Abdiel Janulgue
@ 2017-04-13 8:12 ` Abdiel Janulgue
0 siblings, 0 replies; 10+ messages in thread
From: Abdiel Janulgue @ 2017-04-13 8:12 UTC (permalink / raw)
To: petri.latvala; +Cc: Intel Graphics Development
On 30.03.2017 11:09, Abdiel Janulgue wrote:
> Sanity check the edid block generation capabilities.
>
> Cc: Petri Latvala <petri.latvala@intel.com>
Ping!
> Signed-off-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
> ---
> lib/tests/Makefile.sources | 1 +
> lib/tests/igt_hdmi_inject.c | 96 +++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 97 insertions(+)
> create mode 100644 lib/tests/igt_hdmi_inject.c
>
> diff --git a/lib/tests/Makefile.sources b/lib/tests/Makefile.sources
> index 3fcfe14..4cfc0a5 100644
> --- a/lib/tests/Makefile.sources
> +++ b/lib/tests/Makefile.sources
> @@ -13,6 +13,7 @@ check_prog_list = \
> igt_subtest_group \
> igt_assert \
> igt_exit_handler \
> + igt_hdmi_inject \
> $(NULL)
>
> TESTS = \
> diff --git a/lib/tests/igt_hdmi_inject.c b/lib/tests/igt_hdmi_inject.c
> new file mode 100644
> index 0000000..9b6780a
> --- /dev/null
> +++ b/lib/tests/igt_hdmi_inject.c
> @@ -0,0 +1,96 @@
> +/*
> + * Copyright © 2017 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + *
> + */
> +
> +#include "igt.h"
> +
> +static const unsigned char edid_header[] = {
> + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00
> +};
> +
> +/**
> + * Sanity check the header of the base EDID block.
> + *
> + * Return: 8 if the header is perfect, down to 0 if it's totally wrong.
> + */
> +static int edid_header_is_valid(const unsigned char *raw_edid)
> +{
> + int i, score = 0;
> +
> + for (i = 0; i < sizeof(edid_header); i++)
> + if (raw_edid[i] == edid_header[i])
> + score++;
> +
> + return score;
> +}
> +
> +/**
> + * Sanity check the checksum of the EDID block.
> + *
> + * Return: 0 if the block is perfect.
> + * See byte 127 of spec
> + * https://en.wikipedia.org/wiki/Extended_Display_Identification_Data#EDID_1.3_data_format
> + */
> +static int edid_block_checksum(const unsigned char *raw_edid)
> +{
> + int i;
> + unsigned char csum = 0;
> + for (i = 0; i < EDID_LENGTH; i++) {
> + csum += raw_edid[i];
> + }
> +
> + return csum;
> +}
> +
> +typedef void (*hdmi_inject_func)(const unsigned char *edid, size_t length,
> + unsigned char *new_edid_ptr[], size_t *new_length);
> +
> +igt_simple_main
> +{
> + const struct {
> + const char *desc;
> + hdmi_inject_func inject;
> + } funcs[] = {
> + { "3D", kmstest_edid_add_3d },
> + { "4k", kmstest_edid_add_4k },
> + { "audio", kmstest_edid_add_audio },
> + { NULL, NULL },
> + }, *f;
> +
> + for (f = funcs; f->inject; f++) {
> + unsigned char *edid;
> + size_t length;
> +
> + f->inject(igt_kms_get_base_edid(), EDID_LENGTH, &edid,
> + &length);
> +
> + igt_assert_f(edid_header_is_valid(edid) == 8,
> + "invalid header on HDMI %s", f->desc);
> + /* check base edid block */
> + igt_assert_f(edid_block_checksum(edid) == 0,
> + "checksum failed on HDMI %s", f->desc);
> + /* check extension block */
> + igt_assert_f(edid_block_checksum(edid + EDID_LENGTH) == 0,
> + "CEA block checksum failed on HDMI %s", f->desc);
> + }
> +}
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [i-g-t PATCH v4 1/2] lib/igt_kms: Add support for 4K and audio HDMI EDID injection.
2017-03-27 10:28 [i-g-t PATCH v4 1/2] lib/igt_kms: Add support for 4K and audio HDMI EDID injection Abdiel Janulgue
2017-03-27 10:28 ` [i-g-t PATCH v3 2/2] tests/kms_hdmi_inject: Add test for HDMI injection capabilities Abdiel Janulgue
2017-03-30 8:09 ` [i-g-t PATCH v5 1/2] " Abdiel Janulgue
@ 2017-04-19 8:13 ` Petri Latvala
2017-04-20 9:39 ` Abdiel Janulgue
2 siblings, 1 reply; 10+ messages in thread
From: Petri Latvala @ 2017-04-19 8:13 UTC (permalink / raw)
To: Abdiel Janulgue; +Cc: intel-gfx
Some minor nitpicks on the series:
lib/tests/.gitignore:
You need to add igt_hdmi_inject here. Only
tests/ has automatic .gitignore generation.
tests/Makefile.sources:
You added kms_hdmi_inject to TESTS_progs, it should go to
TESTS_progs_M as it contains subtests. The difference is absolutely
zero though, both sets get handled in the exact same way, and the
different listings will go away as soon as I can clean up the build
system some more, but meanwhile... *shrug*
The only Intel-specific part I can spot is that one chunk where you
check for at-least-hsw. Is that so you can properly report skip
instead of fail? It would be good to make this all suitable for
non-Intel hw.
Anyway, series is
Reviewed-by: Petri Latvala <petri.latvala@intel.com>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [i-g-t PATCH v4 1/2] lib/igt_kms: Add support for 4K and audio HDMI EDID injection.
2017-04-19 8:13 ` [i-g-t PATCH v4 1/2] lib/igt_kms: Add support for 4K and audio HDMI EDID injection Petri Latvala
@ 2017-04-20 9:39 ` Abdiel Janulgue
0 siblings, 0 replies; 10+ messages in thread
From: Abdiel Janulgue @ 2017-04-20 9:39 UTC (permalink / raw)
To: Petri Latvala; +Cc: intel-gfx
On 19.04.2017 11:13, Petri Latvala wrote:
>
> The only Intel-specific part I can spot is that one chunk where you
> check for at-least-hsw. Is that so you can properly report skip
> instead of fail? It would be good to make this all suitable for
> non-Intel hw.
>
That is meant to report skip on hardware before HSW - those can't
properly handle 4K anyway. I'm not sure how other older non-intel HW
handles 4K though.
>
> Anyway, series is
>
> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
>
>
Thanks, pushed!
>
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-04-20 9:39 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-27 10:28 [i-g-t PATCH v4 1/2] lib/igt_kms: Add support for 4K and audio HDMI EDID injection Abdiel Janulgue
2017-03-27 10:28 ` [i-g-t PATCH v3 2/2] tests/kms_hdmi_inject: Add test for HDMI injection capabilities Abdiel Janulgue
2017-03-29 9:52 ` [i-g-t PATCH v4] " Abdiel Janulgue
2017-03-30 6:43 ` Petri Latvala
2017-03-30 6:46 ` Abdiel Janulgue
2017-03-30 8:09 ` [i-g-t PATCH v5 1/2] " Abdiel Janulgue
2017-03-30 8:09 ` [i-g-t PATCH 2/2] lib/tests: Add kmstest_edid_add_* selftests Abdiel Janulgue
2017-04-13 8:12 ` Abdiel Janulgue
2017-04-19 8:13 ` [i-g-t PATCH v4 1/2] lib/igt_kms: Add support for 4K and audio HDMI EDID injection Petri Latvala
2017-04-20 9:39 ` Abdiel Janulgue
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.