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: 4202491 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 6F6769F32A for ; Mon, 19 May 2014 13:37:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AC3B020251 for ; Mon, 19 May 2014 13:37:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B0F932012E 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 DB4C56E4B4; Mon, 19 May 2014 06:37:04 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-we0-f170.google.com (mail-we0-f170.google.com [74.125.82.170]) by gabe.freedesktop.org (Postfix) with ESMTP id 208036E4B8 for ; Mon, 19 May 2014 06:37:02 -0700 (PDT) Received: by mail-we0-f170.google.com with SMTP id u57so5594388wes.15 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=iMQEzA/3qdYEA3f72afa3cYDX16MC0L53rPe0PGSs7ni2IEhoCOzJbJVmrnCqW8t32 +nRTGpx2c7bq4fdCgoBQ4QW2imfsCP57qdO75ghKBKFQIRb2BA9mhX8tts2vOWULavqQ 4cBg7UdKd4fM1eQEcs7rNGsTvttqnF6GRgRwnl/dU/OSfle1r0y9m0Pn1W81LW1PMdo9 HRp6DjwaGD3cobK8rYD6UADfYJAAlyKlGrhva0zwQi+ieIDlyIc8EMJIZHen1r7dqVRi sNNi5eRt1yKlYzg1+GuXZ1bKGGfueg/et4cMzzIahPmQKAEIRvmmGMMkqnVBxscq0Sis 25lQ== X-Gm-Message-State: ALoCoQm597TAOdvHdGUDyVDZevJaz7NT9kUzy56buOmO1hPdHyo1a6BB/A6zjnRuQXEA3vDCZ3QC 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 Subject: [PATCH] drm/sysfs: expose the "force" connector attribute 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 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 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. */