From patchwork Fri Nov 28 16:22:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 5404911 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 459C8BEEA8 for ; Fri, 28 Nov 2014 16:22:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4DFF02013A for ; Fri, 28 Nov 2014 16:22:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 3E1652011B for ; Fri, 28 Nov 2014 16:22:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D824C6EF08; Fri, 28 Nov 2014 08:22:28 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by gabe.freedesktop.org (Postfix) with ESMTP id 821AA6EF08 for ; Fri, 28 Nov 2014 08:22:27 -0800 (PST) Received: by mail-wg0-f43.google.com with SMTP id l18so9172742wgh.30 for ; Fri, 28 Nov 2014 08:22:26 -0800 (PST) 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; bh=hDI6vv8Rn8nV8aI5ieQGB0wmQuHnsvCmUZa3Z7HLBAc=; b=Dx2foCjojdHJ1ZGvpIGNFTQSHNd2B89qUehCulCs5t0YpEJGvGvTeECSNIfaaoqtyM JAcg3ASsHf/eJQI+DAY2s56BIQXtoIzK3BjVTuyQ3CHANOfggiRGXjOA4sWLo8//244L i/goGFvtwl0ajywbw+CeTUUaA1Dy7X5rZpGl6i3f6j0Nm5VH4BLav2PYpDxLONai/1As MA2BBH80NrnfPwBOxj3XjOYrCxrl9wkLZEcd7sDkwNQxYrjVOGBlwB9zld/G6Fqk3ugn IBhg1fiKaQfceW+Yp4y084mjH959ByYNCK3i31rRLs/xJgprmGtVcrXfNzXE8fbBF/Cz AlhA== X-Gm-Message-State: ALoCoQm/kjO2LXdBBhFEjFvqQuVlb7oUqm/i99eQrf6bVvMc0ggB/6c7E8xCAfZW/+tZPoIKo8S6 X-Received: by 10.194.61.168 with SMTP id q8mr63136715wjr.53.1417191746827; Fri, 28 Nov 2014 08:22:26 -0800 (PST) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id gy8sm30170135wib.3.2014.11.28.08.22.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Nov 2014 08:22:25 -0800 (PST) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Fri, 28 Nov 2014 16:22:21 +0000 Message-Id: <1417191744-5767-1-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 2.1.0 Subject: [Intel-gfx] [PATCH i-g-t 1/4] igt_kms: add a base edid 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 Add a basic edid block that includes several different display modes. Signed-off-by: Thomas Wood --- lib/igt_kms.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_kms.h | 3 ++ 2 files changed, 113 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index eb8e085..094f8c1 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -43,6 +44,7 @@ #include "igt_aux.h" #include "intel_chipset.h" #include "igt_debugfs.h" +#include "igt_edid.h" /* * There hasn't been a release of libdrm containing these #define's yet, so @@ -61,6 +63,114 @@ static char *forced_connectors[MAX_CONNECTORS + 1]; +#define VFREQ 60 +#define CLOCK 148500 +#define HACTIVE 1920 +#define HBLANK 280 +#define VACTIVE 1080 +#define VBLANK 45 +#define HOFFSET 88 +#define HPULSE 44 +#define VOFFSET 4 +#define VPULSE 5 + +#define HSIZE 52 +#define VSIZE 30 + +#define GAMMA(x) (x * 100) - 100 + +#define MANUFACTURER_ID(a, b, c) (a - '@') << 2 | (b - '@') >> 3, \ + (b - '@') << 5 | (c - '@') + + +#define ab(x, y) (x & 0xff), (y & 0xff), ((x & 0xf00) >> 4) | ((y & 0xf00) >> 8) +#define op(ho, hp, vo, vp) (ho & 0xff), (hp & 0xff), \ + ((vo & 0xf) << 4) | (vp & 0xf), \ + ((ho & 0x300) >> 2) | ((hp & 0x300) >> 4) \ + | ((vo & 0x30) >> 2) | (vp & 0x30 >> 4) + +static unsigned char base_edid[EDID_LENGTH] = { + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, /* header */ + MANUFACTURER_ID('I', 'G', 'T'), + /* product code, serial number, week and year of manufacture */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x03, /* edid version (1.3) */ + /* basic display parameters */ + /* digital display, maximum horizontal image size, maximum vertical + * image size, gamma, features: RGB 4:4:4, native pixel format and + * refresh rate in descriptor 1 */ + 0x80, HSIZE, VSIZE, GAMMA(2.20), 0x02, + /* chromaticity coordinates */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* established timings: 640x480 60Hz, 800x600 60Hz, 1024x768 60Hz */ + 0x21, 0x08, 0x00, + /* standard timings */ + 0xd1, 0xc0, /* 1920x1080 60Hz */ + 0x81, 0xc0, /* 1280x720 60Hz */ + 0x61, 0x40, /* 1024x768 60Hz */ + 0x45, 0x40, /* 800x600 60Hz */ + 0x31, 0x40, /* 640x480 60Hz */ + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + /* descriptor 1 (preferred timing) */ + (CLOCK / 10) & 0x00ff, ((CLOCK / 10) & 0xff00) >> 8, + ab(HACTIVE, HBLANK), ab(VACTIVE, VBLANK), + op(HOFFSET, HPULSE, VOFFSET, VPULSE), + ab(HSIZE * 10, VSIZE * 10), + 0x00, 0x00, 0x00, + /* descriptor 2 (monitor range limits) */ + 0x00, 0x00, 0x00, 0xfd, 0x00, + VFREQ - 1, VFREQ + 1, /* minimum, maximum vertical field rate */ + (CLOCK / (HACTIVE + HBLANK)) - 1, /* minimum horizontal line rate */ + (CLOCK / (HACTIVE + HBLANK)) + 1, /* maximum horizontal line rate */ + (CLOCK / 10000) + 1, /* maximum pixel clock rate */ + 0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + /* descriptor 3 (name descriptor) */ + 0x00, 0x00, 0x00, 0xfc, 0x00, 'I', 'G', 'T', 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + /* descriptor 4 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* extensions, checksum */ + 0x00, 0x00 +}; + +/** + * igt_kms_get_base_edid: + * + * Get the base edid block, which includes the following modes: + * + * - 1920x1080 60Hz + * - 1280x720 60Hz + * - 1024x768 60Hz + * - 800x600 60Hz + * - 640x480 60Hz + * + * This can be extended with further features using functions such as + * #kmstest_edid_add_3d. + * + * Returns: a basic edid block + */ +const unsigned char* igt_kms_get_base_edid(void) +{ + int i, sum = 0; + struct tm *tm; + time_t t; + + /* year of manufacture */ + t = time(NULL); + tm = localtime(&t); + base_edid[17] = tm->tm_year - 90; + + /* calculate checksum */ + for (i = 0; i < 127; i++) { + sum = sum + base_edid[i]; + } + base_edid[127] = 256 - sum; + + return base_edid; +} + + /** * SECTION:igt_kms * @short_description: Kernel modesetting support library diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 6d05b00..991b34a 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -292,5 +292,8 @@ void igt_wait_for_vblank(int drm_fd, enum pipe pipe); void igt_enable_connectors(void); void igt_reset_connectors(void); +const unsigned char* igt_kms_get_base_edid(void); + + #endif /* __IGT_KMS_H__ */