Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3589198ybd; Tue, 25 Jun 2019 05:20:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxReSKXbyy8uDV9QtrZZ0vnQfgQaV8xeQC14bEGEAnhsQYLiGvxo1lAX5Y6jJQz3ALezMvj X-Received: by 2002:a17:902:d916:: with SMTP id c22mr24412297plz.195.1561465202265; Tue, 25 Jun 2019 05:20:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561465202; cv=none; d=google.com; s=arc-20160816; b=dgPcboWJRczrXkNx043htzuJ4QggUEJPtTgCcOqsiLgMSTjQKmVR1s00+Cq5XFuaSG vBbAs8KwCVNIhdC8ZithQVGly2xRFZDJvnO08ZzYDZZ9La1c4Ea+Fd69wlSOej2hyIUf IwON3h+ZAdP0egMZ62rX6sSU8XBsGV1/07D6tZwE2AVHcPFvS2TFobq8tjst8r5vSQ6g QzKpjVxnnPl5r+bYGwondbzHlGG2rdRF18ZHJTeEYzFlaIaTwp2O9vuF5iw3sJCbosiI x0zfP2V2ElkYID8ndLqBwhV4zWySWlUGq3UgEFFAk8dKpahqsjRFzAsXqL/YyN5tpZUO IePA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from; bh=GzdcIRGFkqjDrKmURsUOAYWx8b4iiInCGtuEC1xC46o=; b=JOp0D1HJjx32i110xYjZDBbNoZWpL+gz2id1+8JVpo5F+blcwMvI9I2QBdzIgBvFps TO9Ln8GpqC2vkKKSGjykElPorYtnZmmPa//gWWC5UosJqFev4nm+M3s6a05pffAftOrp DFwNiILhGrGiXFbyWaOw0C7fBCGYvMvbKIpyQLxWuBNBpH0HoRJPY1bm74X82IYhe+7N JB9l7kGivmWm48A/3nJ2YLKks1fbAbALiZ9Latx9Go5B3oCc60Ip/86QDRzIMXKzltpz KaghprjXk0tUFfxc7QGhf/GTLOn0XKwv9pqkKTHW85TgH8WZ2zcj1kwmJ+20lGvsLQjP 3orw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay6si195668plb.203.2019.06.25.05.19.46; Tue, 25 Jun 2019 05:20:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731712AbfFYKYx (ORCPT + 99 others); Tue, 25 Jun 2019 06:24:53 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:56384 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727102AbfFYKYu (ORCPT ); Tue, 25 Jun 2019 06:24:50 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 69E98288E1F From: Andrzej Pietrasiewicz To: dri-devel@lists.freedesktop.org Cc: kernel@collabora.com, m.szyprowski@samsung.com, Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , Inki Dae , Joonyoung Shim , Seung-Woo Kim , Kyungmin Park , Kukjin Kim , Krzysztof Kozlowski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH v2 1/2] drm: Include ddc adapter pointer in struct drm_connector Date: Tue, 25 Jun 2019 12:24:40 +0200 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: <20190625101655.n246vbwtupb4eoyz@shell.armlinux.org.uk> In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add generic code which creates symbolic links in sysfs, pointing to ddc interface used by a particular video output. For example: ls -l /sys/class/drm/card0-HDMI-A-1/ddc lrwxrwxrwx 1 root root 0 Jun 24 10:42 /sys/class/drm/card0-HDMI-A-1/ddc \ -> ../../../../soc/13880000.i2c/i2c-2 This makes it easy for user to associate a display with its ddc adapter and use e.g. ddcutil to control the chosen monitor. This patch adds an i2c_adapter pointer to struct drm_connector. Particular drivers can then use it instead of using their own private instance. If a connector contains a ddc, then create a symbolic link in sysfs. Signed-off-by: Andrzej Pietrasiewicz --- drivers/gpu/drm/drm_sysfs.c | 7 +++++++ include/drm/drm_connector.h | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index ad10810bc972..26d359b39785 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c @@ -294,6 +294,9 @@ int drm_sysfs_connector_add(struct drm_connector *connector) /* Let userspace know we have a new connector */ drm_sysfs_hotplug_event(dev); + if (connector->ddc) + return sysfs_create_link(&connector->kdev->kobj, + &connector->ddc->dev.kobj, "ddc"); return 0; } @@ -301,6 +304,10 @@ void drm_sysfs_connector_remove(struct drm_connector *connector) { if (!connector->kdev) return; + + if (connector->ddc) + sysfs_remove_link(&connector->kdev->kobj, "ddc"); + DRM_DEBUG("removing \"%s\" from sysfs\n", connector->name); diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index ca745d9feaf5..1ad3d1d54ba7 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -23,6 +23,7 @@ #ifndef __DRM_CONNECTOR_H__ #define __DRM_CONNECTOR_H__ +#include #include #include #include @@ -1308,6 +1309,16 @@ struct drm_connector { * [0]: progressive, [1]: interlaced */ int audio_latency[2]; + + /** + * @ddc: associated ddc adapter. + * A connector usually has its associated ddc adapter. If a driver uses + * this field, then an appropriate symbolic link is created in connector + * sysfs directory to make it easy for the user to tell which i2c + * adapter is for a particular display. + */ + struct i2c_adapter *ddc; + /** * @null_edid_counter: track sinks that give us all zeros for the EDID. * Needed to workaround some HW bugs where we get all 0s -- 2.17.1