From patchwork Fri Sep 5 09:52:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 4851031 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B643C9F314 for ; Fri, 5 Sep 2014 09:52:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D594720266 for ; Fri, 5 Sep 2014 09:52:18 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 9BC2C202BE for ; Fri, 5 Sep 2014 09:52:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D463F6E82E; Fri, 5 Sep 2014 02:52:16 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by gabe.freedesktop.org (Postfix) with ESMTP id 1C56C6E82A for ; Fri, 5 Sep 2014 02:52:14 -0700 (PDT) Received: by mail-wi0-f179.google.com with SMTP id q5so2654922wiv.12 for ; Fri, 05 Sep 2014 02:52:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=izfcsmdcBC9uINUa1lyOvqWCA7ng4W/qr67/fV4J+Ag=; b=TBP7YKpAIIwpaCgz8Jo2wM0AbQ3BkKjohbKw5+cbFiJz4R6R1kAD8K5oyv8T+ey+aV +hPgw3f6lJWFx7LjK2i55GRNBMuBD13krKvEs3EW799mzJZlH+MOB+HfEPE1WlnY8FTg +gQXK0UDMsPc1AAvvifww7P+P5/Nik7Y7TKfVPzELRmSsaYGVyjWFuI37Cs0elMUIsX1 55brAhwRPqVXCCD9A9B/OJ5JbJ5rC9LLiBwGPlf0l4RCwhsZxBk9QczZQieKPNC/HKva HfU7aT1kl86TkNuHHIsD3viXUEaroZ1Q+6M4Jm0ntMcRBBdAb6mmdTPyvuOVVV1GbfdT yLNQ== X-Gm-Message-State: ALoCoQnSoZQzFdAwe5dm/8iTamXEhYbdSoQO6KN6+aU377NG66zaO4EkwqFTT0l3PKsYbId3aOeM X-Received: by 10.180.210.231 with SMTP id mx7mr2317405wic.42.1409910733178; Fri, 05 Sep 2014 02:52:13 -0700 (PDT) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id h6sm875050wjb.33.2014.09.05.02.52.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Sep 2014 02:52:12 -0700 (PDT) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Fri, 5 Sep 2014 10:52:04 +0100 Message-Id: <1409910729-13485-2-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1409910729-13485-1-git-send-email-thomas.wood@intel.com> References: <5408C410.8080500@intel.com> <1409910729-13485-1-git-send-email-thomas.wood@intel.com> Subject: [Intel-gfx] [PATCH i-g-t v2 1/6] lib: add kmstest_edid_add_3d X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 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-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP kmstest_edid_add_3d adds an EDID extension block with 3D support to a copy of the specified EDID. v2: Avoid using an invalid CEC SPA (Clint Taylor) Signed-off-by: Thomas Wood --- 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 d763013..0dc46f9 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -649,6 +649,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++] = 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++] = 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);