From patchwork Thu Aug 9 06:11:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Packard X-Patchwork-Id: 10560941 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3288F13B4 for ; Thu, 9 Aug 2018 06:11:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B61C2AA5D for ; Thu, 9 Aug 2018 06:11:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C7B22AA59; Thu, 9 Aug 2018 06:11:44 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 B42CF2AA59 for ; Thu, 9 Aug 2018 06:11:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 288E36E69D; Thu, 9 Aug 2018 06:11:41 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from elaine.keithp.com (home.keithp.com [63.227.221.253]) by gabe.freedesktop.org (Postfix) with ESMTP id 873126E69D for ; Thu, 9 Aug 2018 06:11:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id 519043F2205A; Wed, 8 Aug 2018 23:11:39 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at keithp.com Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id GATwGP8XC0q0; Wed, 8 Aug 2018 23:11:39 -0700 (PDT) Received: from vr.keithp.com (vr.keithp.com [10.0.0.39]) by elaine.keithp.com (Postfix) with ESMTP id 0879C3F201A3; Wed, 8 Aug 2018 23:11:39 -0700 (PDT) Received: by vr.keithp.com (Postfix, from userid 1000) id AAF1E74088C; Wed, 8 Aug 2018 23:11:35 -0700 (PDT) From: Keith Packard To: linux-kernel@vger.kernel.org, Dave Airlie , Daniel Vetter Subject: [PATCH] drm: Add drm.edid_quirk_param module parameter Date: Wed, 8 Aug 2018 23:11:23 -0700 Message-Id: <20180809061123.1734-1-keithp@keithp.com> X-Mailer: git-send-email 2.18.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Packard , dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This parameter allows the set of EDID quirks to be changed at runtime. The syntax is vendor/product/quirks,vendor/product/quirks,... where vendor is the three-letter EDID vendor value, product is the EDID product id which may be prefixed with 0x to for hex instead of decimal values and quirks is the replacement quirks value from the list in drm_edid.c. Signed-off-by: Keith Packard --- drivers/gpu/drm/drm_edid.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 5dc742b27ca0..63b4587faddd 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -98,6 +98,12 @@ struct detailed_mode_closure { #define LEVEL_GTF2 2 #define LEVEL_CVT 3 +#define EDID_QUIRK_PARAM_LEN 256 +static char edid_quirk_param[EDID_QUIRK_PARAM_LEN]; +module_param_string(edid_quirk_param, edid_quirk_param, sizeof(edid_quirk_param), 0644); +MODULE_PARM_DESC(edid_quirk_param, "Extra EDID quirks, " + "format is 'vendor/product/quirks;...' "); + static const struct edid_quirk { char vendor[4]; int product_id; @@ -1774,8 +1780,24 @@ static bool edid_vendor(const struct edid *edid, const char *vendor) static u32 edid_get_quirks(const struct edid *edid) { const struct edid_quirk *quirk; + const char *q; int i; + for (q = edid_quirk_param; q && *q; q = strchr(q, ',')) { + char vendor[4]; + int product_id; + int quirks; + + while (*q == ',') + q++; + + if (sscanf(q, "%3s/%i/%i", vendor, &product_id, &quirks) == 3) { + if (edid_vendor(edid, vendor) && + (EDID_PRODUCT_ID(edid) == product_id)) + return quirks; + } + } + for (i = 0; i < ARRAY_SIZE(edid_quirk_list); i++) { quirk = &edid_quirk_list[i];