From patchwork Wed Mar 15 11:41:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdiel Janulgue X-Patchwork-Id: 9625443 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 686786048C for ; Wed, 15 Mar 2017 11:43:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53E1728343 for ; Wed, 15 Mar 2017 11:43:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 479DB2860B; Wed, 15 Mar 2017 11:43:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B8FC828343 for ; Wed, 15 Mar 2017 11:43:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 196206E0A9; Wed, 15 Mar 2017 11:43:47 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 929AD6E0A9 for ; Wed, 15 Mar 2017 11:43:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489578225; x=1521114225; h=from:to:cc:subject:date:message-id; bh=bfZTrjmNbyeYDJTa6Dc752+OuhfnwpjB6THXAMoNSHo=; b=juobzeiHUFnIGaWoZoc6xRABD/UkFSn+sj+qTv8y/HNen9H0Dus8CYyy 3PbjmBlZfoAnULxGWCNs0T1KOpIWYQ==; Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Mar 2017 04:43:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,168,1486454400"; d="scan'208";a="60639461" Received: from skylake-nuc.fi.intel.com ([10.237.72.145]) by orsmga002.jf.intel.com with ESMTP; 15 Mar 2017 04:43:42 -0700 From: Abdiel Janulgue To: intel-gfx@lists.freedesktop.org Date: Wed, 15 Mar 2017 13:41:00 +0200 Message-Id: <1489578061-11427-1-git-send-email-abdiel.janulgue@linux.intel.com> X-Mailer: git-send-email 2.7.4 Cc: Marius Vlad Subject: [Intel-gfx] [i-g-t PATCH v3 1/2] lib/igt_kms: Add support for 4K and audio HDMI EDID injection. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Marius Vlad v3: Bring back audio injection Signed-off-by: Marius Vlad Signed-off-by: Abdiel Janulgue --- lib/igt_kms.c | 181 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_kms.h | 2 + 2 files changed, 183 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index e12ed72..d367f77 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1198,6 +1198,187 @@ void kmstest_edid_add_3d(const unsigned char *edid, size_t length, } /** + * 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) +{ + 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 = 12; + + 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++] = 0x10; + new_edid[pos++] = 0x00; + /* 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++] = 0x00; /* 3D present */ + + /* HDMI MODE LEN -- how many entries */ + new_edid[pos++] = 0x20; + /* 2160p, specified as short descriptor */ + new_edid[pos++] = 0x01; + + + /* checksum */ + sum = 0; + for (i = 0; i < 127; i++) { + sum = sum + new_edid[length + i]; + } + new_edid[length + 127] = 256 - sum; +} + +/** + * 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) +{ + 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 = 10; + char audio_block_len = 4, spkr_block_len = 4; + + 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 + audio_block_len + + video_block_len + vsdb_block_len + spkr_block_len; + new_edid[pos++] = (1 << 6); /* support basic audio */ + + /* audio block, short audio block descriptors */ + new_edid[pos++] = (1 << 5) | (audio_block_len - 1); + new_edid[pos++] = 0x09; /* Audio Format, PCM */ + new_edid[pos++] = 0x07; /* Frequency, 32, 44.1, 48kHz */ + new_edid[pos++] = 0x07; /* Bit Rate 16, 20, 24 bit */ + + /* 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 ) -- need vsdb as well + * otherwise the kernel will fallback to lower clock modes */ + 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++] = 0x10; + new_edid[pos++] = 0x00; + /* 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++] = 0x00; /* 3D present */ + + /* speaker data block */ + new_edid[pos++] = (4 << 5) | (spkr_block_len - 1); + new_edid[pos++] = (1 << 5); + new_edid[pos++] = 0x00; + 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 f29dfe0..cf2978a 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);