From patchwork Thu May 29 15:57:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 4266071 Return-Path: X-Original-To: patchwork-dri-devel@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 CECB09F30B for ; Thu, 29 May 2014 15:57:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E17082035E for ; Thu, 29 May 2014 15:57:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 847AA2035D for ; Thu, 29 May 2014 15:57:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7E0436E9DF; Thu, 29 May 2014 08:57:52 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F6E56E9E1 for ; Thu, 29 May 2014 08:57:51 -0700 (PDT) Received: by mail-wi0-f176.google.com with SMTP id n15so5850303wiw.15 for ; Thu, 29 May 2014 08:57:50 -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:cc:subject:date:message-id:in-reply-to :references; bh=1+yeABcYlaOUsUkupXQeuvmt1vLZRBPbhVZHIyJ17Nw=; b=TXtKI9gSUOnrpnyP8LvHtD3CpYMHvyYsUUlwosmb3hVMebEiAiRy0prEsh4V9cKgkN 8qlB6KCRveTwNEb6LdkQhCuIMzrZGw1oJfHrXQ5qrbs+EtpLlwZpIkBUSOpS26KGbFi5 h/wek4NMghLyhlaztez8h6ooI1x9BLQsPUl4NGTNB4+20c6wHZc5C+q4s9WsgdA7UtIz fZxP9ld6amrsEEmYURBdlP/trODOP/IfNxSVLtn8TE4biKNveO3YpVQQC11VTM/zDQAP 7Y6Tls8QFVcki3MfAMycHBblJh+Z64k/F8/NFRoYGk+DS/RLwQFjG9etinD/3Vvi4jqP IYRQ== X-Gm-Message-State: ALoCoQlZmfVamqts+27B9VsV8BmK4tSMWe6vW3yvrt7irfcgv+qjB/r1m3INjOAmaQvHlHeqLdEk X-Received: by 10.180.94.163 with SMTP id dd3mr12878851wib.26.1401379069562; Thu, 29 May 2014 08:57:49 -0700 (PDT) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id ej2sm2702468wjd.21.2014.05.29.08.57.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 May 2014 08:57:48 -0700 (PDT) From: Thomas Wood To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/3] drm/debugfs: add an "edid_override" file per connector Date: Thu, 29 May 2014 16:57:43 +0100 Message-Id: <1401379063-15375-4-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1401379063-15375-1-git-send-email-thomas.wood@intel.com> References: <1401379063-15375-1-git-send-email-thomas.wood@intel.com> Cc: intel-gfx@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.8 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 Add a file to debugfs for each connector that allows the edid data to be overridden. Signed-off-by: Thomas Wood --- drivers/gpu/drm/drm_crtc.c | 4 +++ drivers/gpu/drm/drm_debugfs.c | 56 ++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_probe_helper.c | 9 +++++- include/drm/drm_crtc.h | 1 + 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 59a2784..8543eac 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -3701,6 +3701,10 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector, struct drm_device *dev = connector->dev; int ret, size; + /* ignore requests to set edid when overridden */ + if (connector->override_edid) + return 0; + if (connector->edid_blob_ptr) drm_property_destroy_blob(dev, connector->edid_blob_ptr); diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index b57b614..2c666ba 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -35,6 +35,7 @@ #include #include #include +#include #if defined(CONFIG_DEBUG_FS) @@ -295,6 +296,55 @@ static ssize_t connector_write(struct file *file, const char __user *ubuf, return len; } +static int edid_show(struct seq_file *m, void *data) +{ + struct drm_connector *connector = m->private; + struct drm_property_blob *edid = connector->edid_blob_ptr; + + if (connector->override_edid && edid) + seq_write(m, edid->data, edid->length); + + return 0; +} + +static int edid_open(struct inode *inode, struct file *file) +{ + struct drm_connector *dev = inode->i_private; + + return single_open(file, edid_show, dev); +} + +static ssize_t edid_write(struct file *file, const char __user *ubuf, + size_t len, loff_t *offp) +{ + struct seq_file *m = file->private_data; + struct drm_connector *connector = m->private; + + if (len >= EDID_LENGTH) { + drm_mode_connector_update_edid_property(connector, + (struct edid *) ubuf); + connector->override_edid = true; + } else { + if (connector->override_edid) { + connector->override_edid = false; + drm_mode_connector_update_edid_property(connector, + NULL); + } + } + + return len; +} + +static const struct file_operations drm_edid_fops = { + .owner = THIS_MODULE, + .open = edid_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .write = edid_write +}; + + static const struct file_operations drm_connector_fops = { .owner = THIS_MODULE, .open = connector_open, @@ -325,6 +375,12 @@ int drm_debugfs_connector_add(struct drm_connector *connector) if (!ent) return -ENOMEM; + /* edid */ + ent = debugfs_create_file("edid_override", S_IRUGO, root, connector, + &drm_edid_fops); + if (!ent) + return -ENOMEM; + return 0; } diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c index 79f07f2..1f0dc77 100644 --- a/drivers/gpu/drm/drm_probe_helper.c +++ b/drivers/gpu/drm/drm_probe_helper.c @@ -130,7 +130,14 @@ static int drm_helper_probe_single_connector_modes_merge_bits(struct drm_connect count = drm_load_edid_firmware(connector); if (count == 0) #endif - count = (*connector_funcs->get_modes)(connector); + { + if (connector->override_edid) { + struct edid *edid = (struct edid *) connector->edid_blob_ptr->data; + + count = drm_add_edid_modes(connector, edid); + } else + count = (*connector_funcs->get_modes)(connector); + } if (count == 0 && connector->status == connector_status_connected) count = drm_add_modes_noedid(connector, 1024, 768); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index f04f4b9..11fce43 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -513,6 +513,7 @@ struct drm_connector { /* forced on connector */ enum drm_connector_force force; + bool override_edid; uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; struct drm_encoder *encoder; /* currently active encoder */