diff mbox

[i-g-t,1/3] lib: add kmstest_edid_add_3d

Message ID 1408532049-9215-1-git-send-email-thomas.wood@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Thomas Wood Aug. 20, 2014, 10:54 a.m. UTC
kmstest_edid_add_3d adds an EDID extension block with 3D support to a
copy of the specified EDID.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
---
 lib/igt_kms.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h |  1 +
 2 files changed, 81 insertions(+)

Comments

Lespiau, Damien Aug. 26, 2014, 1:43 p.m. UTC | #1
On Wed, Aug 20, 2014 at 11:54:07AM +0100, Thomas Wood wrote:
> kmstest_edid_add_3d adds an EDID extension block with 3D support to a
> copy of the specified EDID.
> 
> Signed-off-by: Thomas Wood <thomas.wood@intel.com>

The series looks reasonable, ship it!
Clint Taylor Sept. 4, 2014, 7:57 p.m. UTC | #2
On 08/20/2014 03:54 AM, Thomas Wood wrote:
> kmstest_edid_add_3d adds an EDID extension block with 3D support to a
> copy of the specified EDID.
>
> Signed-off-by: Thomas Wood <thomas.wood@intel.com>
> ---
>   lib/igt_kms.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>   lib/igt_kms.h |  1 +
>   2 files changed, 81 insertions(+)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index a414d96..eb898f8 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -657,6 +657,86 @@ kmstest_get_property(int drm_fd, uint32_t object_id, uint32_t object_type,
>   }
>
>   /**
> + * kmstest_edid_add_3d:
> + * @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
> + * stereo 3D capabilities.
> + */
> +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);
> +
> +	*new_length = length + 128;
> +
> +	new_edid = calloc(*new_length, sizeof(char));
> +	memcpy(new_edid, edid, length);
> +	*new_edid_ptr = new_edid;
> +
> +	n_extensions = new_edid[126];
> +	n_extensions++;
> +	new_edid[126] = n_extensions;
> +
> +	/* recompute checksum */
> +	for (i = 0; i < 127; i++) {
> +		sum = sum + new_edid[i];
> +	}
> +	new_edid[127] = 256 - sum;
> +
> +	/* 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;
> +
> +	/* 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*/
> +
> +	/* vsdb block ( id | length ) */
> +	new_edid[pos++] = 3 << 5 | (vsdb_block_len - 1);
> +	/* registration id */
> +	new_edid[pos++] = 0x3;
> +	new_edid[pos++] = 0xc;
> +	new_edid[pos++] = 0x0;
> +	/* source physical address */
> +	new_edid[pos++] = 0x0;
> +	new_edid[pos++] = 0x0;

A CEC SPA of 0.0.0.0 is actually invalid and may cause issues with the 
EDID decoder. Suggest since this is dummy VSDB make the SPA 1.0.0.0.

Clint


> +	/* Supports_AI ... etc */
> +	new_edid[pos++] = 0x00;
> +	/* Max TMDS Clock */
> +	new_edid[pos++] = 0x00;
> +	/* Latency present, HDMI Video Present */
> +	new_edid[pos++] = 0x20;
> +	/* HDMI Video */
> +	new_edid[pos++] = 0x80;
> +	new_edid[pos++] = 0x00;
> +
> +	/* checksum */
> +	sum = 0;
> +	for (i = 0; i < 127; i++) {
> +		sum = sum + new_edid[length + i];
> +	}
> +	new_edid[length + 127] = 256 - sum;
> +}
> +
> +/**
>    * kmstest_unset_all_crtcs:
>    * @drm_fd: the DRM fd
>    * @resources: libdrm resources pointer
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 4263a01..921afef 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -149,6 +149,7 @@ enum kmstest_generic_edid {
>
>   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_force_edid(int drm_fd, drmModeConnector *connector,
>   			const unsigned char *edid, size_t length);
>
>
Thomas Wood Sept. 5, 2014, 9:52 a.m. UTC | #3
This updated and rebased series fixes various issues with the previous one and
also skips testing on gen 7 and 8 where it is not currently possible to force
the HDMI and DP connector states. There is also a small documentation fix for
igt_create_fb.

Thomas Wood (6):
  lib: add kmstest_edid_add_3d
  lib: move create_stereo_fb from testdisplay to igt_fb
  tests: add kms_3d test
  lib/igt_fb: ensure igt_create_fb parameters are consistent
  lib: don't force HDMI or DP connectors on gen 7 and 8
  tests/kms_3d: skip if connectors cannot be forced

 lib/Makefile.am        |   4 +-
 lib/igt_fb.c           | 102 ++++++++++++++++++++++++++++++++++++++++-
 lib/igt_fb.h           |   4 +-
 lib/igt_kms.c          |  92 +++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h          |   1 +
 tests/.gitignore       |   1 +
 tests/Android.mk       |   1 +
 tests/Makefile.sources |   1 +
 tests/kms_3d.c         | 121 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/testdisplay.c    | 118 ++---------------------------------------------
 10 files changed, 327 insertions(+), 118 deletions(-)
 create mode 100644 tests/kms_3d.c
diff mbox

Patch

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index a414d96..eb898f8 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -657,6 +657,86 @@  kmstest_get_property(int drm_fd, uint32_t object_id, uint32_t object_type,
 }
 
 /**
+ * kmstest_edid_add_3d:
+ * @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
+ * stereo 3D capabilities.
+ */
+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);
+
+	*new_length = length + 128;
+
+	new_edid = calloc(*new_length, sizeof(char));
+	memcpy(new_edid, edid, length);
+	*new_edid_ptr = new_edid;
+
+	n_extensions = new_edid[126];
+	n_extensions++;
+	new_edid[126] = n_extensions;
+
+	/* recompute checksum */
+	for (i = 0; i < 127; i++) {
+		sum = sum + new_edid[i];
+	}
+	new_edid[127] = 256 - sum;
+
+	/* 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;
+
+	/* 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*/
+
+	/* vsdb block ( id | length ) */
+	new_edid[pos++] = 3 << 5 | (vsdb_block_len - 1);
+	/* registration id */
+	new_edid[pos++] = 0x3;
+	new_edid[pos++] = 0xc;
+	new_edid[pos++] = 0x0;
+	/* source physical address */
+	new_edid[pos++] = 0x0;
+	new_edid[pos++] = 0x0;
+	/* Supports_AI ... etc */
+	new_edid[pos++] = 0x00;
+	/* Max TMDS Clock */
+	new_edid[pos++] = 0x00;
+	/* Latency present, HDMI Video Present */
+	new_edid[pos++] = 0x20;
+	/* HDMI Video */
+	new_edid[pos++] = 0x80;
+	new_edid[pos++] = 0x00;
+
+	/* checksum */
+	sum = 0;
+	for (i = 0; i < 127; i++) {
+		sum = sum + new_edid[length + i];
+	}
+	new_edid[length + 127] = 256 - sum;
+}
+
+/**
  * kmstest_unset_all_crtcs:
  * @drm_fd: the DRM fd
  * @resources: libdrm resources pointer
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 4263a01..921afef 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -149,6 +149,7 @@  enum kmstest_generic_edid {
 
 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_force_edid(int drm_fd, drmModeConnector *connector,
 			const unsigned char *edid, size_t length);