From patchwork Mon May 19 13:37:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 4202501 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 0246EBEEAB for ; Mon, 19 May 2014 13:37:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 439552026F for ; Mon, 19 May 2014 13:37:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 715BB20221 for ; Mon, 19 May 2014 13:37:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DFCAE6E4B8; Mon, 19 May 2014 06:37:04 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-we0-f179.google.com (mail-we0-f179.google.com [74.125.82.179]) by gabe.freedesktop.org (Postfix) with ESMTP id 1F1466E4B4 for ; Mon, 19 May 2014 06:37:02 -0700 (PDT) Received: by mail-we0-f179.google.com with SMTP id q59so5431852wes.24 for ; Mon, 19 May 2014 06:37:02 -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; bh=jcjVetDW2pzuaEWkYFdo7FPCd9nCog1TSSka3fFBSPE=; b=b6GYLZCEMRBufzsagrdVerfHjgXLqHE6UuxWkShtIM9VSAJn11f3m47gk+q8AHHvbA RoO3HMU9P8LzPjbPHXjC38KxTfLq9G/heH6SOY5vsnjCkunHG8Ka+aiSgcc8+4Zlrwjs cGElsbzaLzqKOluE1UIB0EIccRmdspZpXu0XgvCYW4vL0Y7oap3ncy6YFd0DHapR0eBW Aq+OcKpHay1cGbkJV4C7EgQ28VyyhARX1JUW7Z/9FcsDq5ORGeqVRyIONURgw1OrXciU zcfpvYCrJTe352bGX7rQ/4VxuJX17KCQz+zy6ynkxxTZv/9DS4gmpAzQEo7JoisPmjMg iXYQ== X-Gm-Message-State: ALoCoQm+8H3q2NC450GxWNEZQLAChiIhMS8sWivKW/o1SOzULc7yImu4YyK7krdPTj/GxU/3a0dC X-Received: by 10.180.109.69 with SMTP id hq5mr13118840wib.30.1400506621969; Mon, 19 May 2014 06:37:01 -0700 (PDT) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id l9sm15109607wic.21.2014.05.19.06.37.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 May 2014 06:37:01 -0700 (PDT) From: Thomas Wood To: dri-devel@lists.freedesktop.org Date: Mon, 19 May 2014 14:37:00 +0100 Message-Id: <1400506620-12509-1-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 1.9.0 Cc: intel-gfx@lists.freedesktop.org Subject: [Intel-gfx] [PATCH] drm/sysfs: expose the "force" connector attribute 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=-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 Signed-off-by: Thomas Wood --- drivers/gpu/drm/drm_sysfs.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index c22c309..257816e 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c @@ -338,11 +338,60 @@ static ssize_t select_subconnector_show(struct device *device, drm_get_dvi_i_select_name((int)subconnector)); } +static ssize_t force_show(struct device *device, + struct device_attribute *attr, + char *buf) +{ + struct drm_connector *connector = to_drm_connector(device); + char *status; + + switch (connector->force) { + case DRM_FORCE_ON: + status = "on"; + break; + + case DRM_FORCE_ON_DIGITAL: + status = "digital"; + break; + + case DRM_FORCE_OFF: + status = "off"; + break; + + case DRM_FORCE_UNSPECIFIED: + status = "unspecified"; + break; + + default: + return 0; + } + + return snprintf(buf, PAGE_SIZE, "%s\n", status); +} + +ssize_t force_store(struct device *device, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct drm_connector *connector = to_drm_connector(device); + + if (strcmp(buf, "on") == 0) + connector->force = DRM_FORCE_ON; + else if (strcmp(buf, "digital") == 0) + connector->force = DRM_FORCE_ON_DIGITAL; + else if (strcmp(buf, "off") == 0) + connector->force = DRM_FORCE_OFF; + else if (strcmp(buf, "unspecified") == 0) + connector->force = DRM_FORCE_UNSPECIFIED; + + return count; +} + static struct device_attribute connector_attrs[] = { __ATTR_RO(status), __ATTR_RO(enabled), __ATTR_RO(dpms), __ATTR_RO(modes), + __ATTR_RW(force), }; /* These attributes are for both DVI-I connectors and all types of tv-out. */