Commit e1a29c6c authored by Andrzej Pietrasiewicz's avatar Andrzej Pietrasiewicz Committed by Neil Armstrong

drm: Add ddc link in sysfs created by drm_connector

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: default avatarAndrzej Pietrasiewicz <andrzej.p@collabora.com>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: default avatarAndrzej Hajda <a.hajda@samsung.com>
Reviewed-by: default avatarEmil Velikov <emil.velikov@collabora.com>
Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
Signed-off-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
Link: https://patchwork.freedesktop.org/patch/msgid/d470def6cd661b777faeee67b5838a4623c4010e.1564161140.git.andrzej.p@collabora.com
parent 77b8cabf
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/gfp.h> #include <linux/gfp.h>
#include <linux/i2c.h>
#include <linux/kdev_t.h> #include <linux/kdev_t.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -294,6 +295,9 @@ int drm_sysfs_connector_add(struct drm_connector *connector) ...@@ -294,6 +295,9 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
/* Let userspace know we have a new connector */ /* Let userspace know we have a new connector */
drm_sysfs_hotplug_event(dev); drm_sysfs_hotplug_event(dev);
if (connector->ddc)
return sysfs_create_link(&connector->kdev->kobj,
&connector->ddc->dev.kobj, "ddc");
return 0; return 0;
} }
...@@ -301,6 +305,10 @@ void drm_sysfs_connector_remove(struct drm_connector *connector) ...@@ -301,6 +305,10 @@ void drm_sysfs_connector_remove(struct drm_connector *connector)
{ {
if (!connector->kdev) if (!connector->kdev)
return; return;
if (connector->ddc)
sysfs_remove_link(&connector->kdev->kobj, "ddc");
DRM_DEBUG("removing \"%s\" from sysfs\n", DRM_DEBUG("removing \"%s\" from sysfs\n",
connector->name); connector->name);
......
...@@ -41,6 +41,7 @@ struct drm_property; ...@@ -41,6 +41,7 @@ struct drm_property;
struct drm_property_blob; struct drm_property_blob;
struct drm_printer; struct drm_printer;
struct edid; struct edid;
struct i2c_adapter;
enum drm_connector_force { enum drm_connector_force {
DRM_FORCE_UNSPECIFIED, DRM_FORCE_UNSPECIFIED,
...@@ -1311,6 +1312,16 @@ struct drm_connector { ...@@ -1311,6 +1312,16 @@ struct drm_connector {
* [0]: progressive, [1]: interlaced * [0]: progressive, [1]: interlaced
*/ */
int audio_latency[2]; 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. * @null_edid_counter: track sinks that give us all zeros for the EDID.
* Needed to workaround some HW bugs where we get all 0s * Needed to workaround some HW bugs where we get all 0s
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment