Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3574145ybd; Tue, 25 Jun 2019 05:05:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyV+okHwKu12KEDT6EKeEu0VITj/Ntt7NFegUi2IAtooUeCbTsnHKF23pJe+c/RIwsOqjHi X-Received: by 2002:a65:62ca:: with SMTP id m10mr2312216pgv.57.1561464328981; Tue, 25 Jun 2019 05:05:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561464328; cv=none; d=google.com; s=arc-20160816; b=lrQ+NC1fYDrlFn9KaOCkEHhcU+rnXZBsjf4rHk9y7TcVFc7YqjEu/sBb1GAMHOqN4Y PSXnmCpV6Dtf73GAemgaIdm7gzR7KyBvvxDlTVvU70QAEOzo6wj3KfIbl2Y2XEK/E9/M fvHyTJ1B2qGf3QYZ8A6dkGjoaPX0/iRLUCSGGrHDz2NlOvbJkoX5lAdDdS2Q2wNx6HCz n3IPnB62VKzdRiD0aKKgb0V8Zmfr4SSW+Sqk4SSOL4pjHDs3nUR/Z43U7mAKbfybXF+C BZl+DHtmdH0OLqYhRJOqR+ho5Numfe2lzSf4y3wE7CXA2UGgCEqpDSlNe5UYyv+0hXU4 oIGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:from; bh=kjILQ2gQ0A+ILikClqUTepr0jgNtsC7P1l81+cVEo9w=; b=AlnFgmyEB8GCoEsxkozzOL3lKH7IyXRxWpAlUp+8vfesjlR7Bp4Fs0x0t095VY21nu xJZ1INoqva/HComSmNM3sRY6fRT5LfHECcMIEfy7o1Z8/QbbNzs2AqHgaf1Po6EhiTY/ TsYx02y07fU4/P09TDoSgdAuusLgP95kEUP5h9einA//SHgLtBw2pVR/0kFIkkP28ek1 HO7nmf95XfPZvaW6J+PNDfMIHbuitmzKfTJxmJYNCPQXOAHI0QS9+1GRJYMgkQBEhqsE kDPxm4lCM/XLcdhR7+EljYCr3wrYlyT5WMZHRQQixB1yEoZEO8XCs9yKGKj2eBhGMdhg Oo9A== 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.04.48; Tue, 25 Jun 2019 05:05:28 -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 S1729983AbfFYJqu (ORCPT + 99 others); Tue, 25 Jun 2019 05:46:50 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:55848 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727932AbfFYJqs (ORCPT ); Tue, 25 Jun 2019 05:46:48 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 90928260A37 From: Andrzej Pietrasiewicz 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 , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 1/2] drm: Include ddc adapter pointer in struct drm_connector Date: Tue, 25 Jun 2019 11:46:35 +0200 Message-Id: <04382593e44ac3f69cd63adfe0dd0660dc32a722.1561452052.git.andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: To: unlisted-recipients:; (no To-header on input) 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/i2c-2 lrwxrwxrwx 1 root root 0 Jun 24 10:42 /sys/class/drm/card0-HDMI-A-1/i2c-2 \ -> ../../../../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 | 9 +++++++++ include/drm/drm_connector.h | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index ad10810bc972..627f8ebfc87a 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c @@ -294,6 +294,10 @@ 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, + connector->ddc->dev.kobj.name); return 0; } @@ -301,6 +305,11 @@ void drm_sysfs_connector_remove(struct drm_connector *connector) { if (!connector->kdev) return; + + if (connector->ddc) + sysfs_remove_link(&connector->kdev->kobj, + connector->ddc->dev.kobj.name); + 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