public inbox for linux-rockchip@lists.infradead.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann-l3A5Bk7waGM@public.gmane.org>
To: Andrzej Pietrasiewicz
	<andrzej.p-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: "Y.C. Chen" <yc_chen-SAlXDmAnmOAqDJ6do+/SaQ@public.gmane.org>,
	"Heiko Stübner" <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>,
	"Sam Ravnborg" <sam-uyr5N9Q2VtJg9hUCZPvPmw@public.gmane.org>,
	"Neil Armstrong"
	<narmstrong-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>,
	"Maxime Ripard"
	<maxime.ripard-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org>,
	"Douglas Anderson"
	<dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	"Andrzej Hajda" <a.hajda-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
	"Thierry Reding"
	<thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Laurent Pinchart"
	<Laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>,
	"Benjamin Gaignard"
	<benjamin.gaignard-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	kernel-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org,
	"Fabio Estevam"
	<festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Ville Syrjälä"
	<ville.syrjala-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	"David (ChunMing) Zhou"
	<David1.Zhou-5C7GfCeVMHo@public.gmane.org>,
	linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"Joonyoung Shim"
	<jy0922.shim-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	"Vincent Abriou" <vincent.abriou-qxv4g6HH51o@public.gmane.org>,
	"Rob Clark" <robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Krzysztof Kozlowski"
	<krzk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	"Jonathan Hunter"
	<jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH v3 01/22] drm: Include ddc adapter pointer in struct drm_connector
Date: Sun, 30 Jun 2019 10:12:54 +0200	[thread overview]
Message-ID: <9b03d145-ec50-927c-55a8-dff1cd51d655@suse.de> (raw)
In-Reply-To: <d6381c020ea1c848a7044d830bdb0ec9663d1619.1561735433.git.andrzej.p-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>

Hi

I like the idea, but would prefer a more structured approach.

Setting connector->ddc before calling drm_sysfs_connector_add() seems
error prone. The dependency is not really clear from the code or interfaces.

The other thing is that drivers I mostly work on, ast and mgag200, have
code like this:

  struct ast_i2c_chan {
	struct i2c_adapter adapter;
	struct drm_device *dev;
	struct i2c_algo_bit_data bit;
  };

  struct ast_connector {
	struct drm_connector base;
	struct ast_i2c_chan *i2c;
  };

It already encodes the connection between connector and ddc adapter.

I suggest to introduce struct drm_i2c_adapter

  struct drm_i2c_adapter {
	struct i2c_adapter base;
	struct drm_connector *connector;
  };

and convert drivers over to it. Ast would look like this:

  struct ast_i2c_chan {
	struct drm_i2c_adapter adapter;
	struct i2c_algo_bit_data bit;
  };

Two new sysfs functions would set up and remove the file.

  int drm_sysfs_i2c_adapter_add(struct drm_i2c_adapter *i2c);
  void drm_sysfs_i2c_adapter_remove(struct drm_i2c_adapter *i2c);

The i2c adapter, connector->ddc pointer and sysfs entry would be
initialized by

  drm_i2c_adapter_init(struct drm_i2c_adapter *i2c, struct connector
	*connector, void *algo_data);

and cleaned up by

  drm_i2c_adapter_remove(struct drm_i2c_adapter *i2c);


Thoughts?

Best regards
Thomas

Am 28.06.19 um 18:01 schrieb Andrzej Pietrasiewicz:
> 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 <andrzej.p@collabora.com>
> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  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 <linux/i2c.h>
>  #include <linux/list.h>
>  #include <linux/llist.h>
>  #include <linux/ctype.h>
> @@ -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
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)
_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno

  parent reply	other threads:[~2019-06-30  8:12 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3fb19371-db7d-f9dc-31a7-1ccd126f6784@collabora.com>
     [not found] ` <3fb19371-db7d-f9dc-31a7-1ccd126f6784-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2019-06-28 16:01   ` [PATCH v3 00/22] Associate ddc adapters with connectors Andrzej Pietrasiewicz
     [not found]     ` <cover.1561735433.git.andrzej.p-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2019-06-28 16:01       ` [PATCH v3 01/22] drm: Include ddc adapter pointer in struct drm_connector Andrzej Pietrasiewicz
     [not found]         ` <d6381c020ea1c848a7044d830bdb0ec9663d1619.1561735433.git.andrzej.p-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2019-06-30  8:12           ` Thomas Zimmermann [this message]
     [not found]             ` <9b03d145-ec50-927c-55a8-dff1cd51d655-l3A5Bk7waGM@public.gmane.org>
2019-07-01 13:27               ` Andrzej Pietrasiewicz
     [not found]                 ` <cf1984e4-50af-302d-ef67-9ad530118c29-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2019-07-01 14:41                   ` Thomas Zimmermann
     [not found]                     ` <9e65f3c0-941d-d04c-5745-6b3a2965b990-l3A5Bk7waGM@public.gmane.org>
2019-07-05  9:44                       ` Andrzej Hajda
2019-06-28 16:01       ` [PATCH v3 02/22] drm/exynos: Provide ddc symlink in connector's sysfs Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 03/22] drm: rockchip: Provide ddc symlink in rk3066_hdmi sysfs directory Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 04/22] drm: rockchip: Provide ddc symlink in inno_hdmi " Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 05/22] drm/msm/hdmi: Provide ddc symlink in hdmi connector " Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 06/22] drm/sun4i: hdmi: Provide ddc symlink in sun4i " Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 07/22] drm/mediatek: Provide ddc symlink in " Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 08/22] drm/tegra: Provide ddc symlink in output " Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 09/22] drm/imx: imx-ldb: Provide ddc symlink in connector's sysfs Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 10/22] drm/imx: imx-tve: " Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 11/22] drm/vc4: Provide ddc symlink in connector sysfs directory Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 12/22] drm: zte: Provide ddc symlink in hdmi " Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 13/22] drm: zte: Provide ddc symlink in vga " Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 14/22] drm/tilcdc: Provide ddc symlink in " Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 15/22] drm: sti: Provide ddc symlink in hdmi " Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 16/22] drm/mgag200: Provide ddc symlink in " Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 17/22] drm/ast: " Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 18/22] drm/bridge: dumb-vga-dac: " Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 19/22] drm/bridge: dw-hdmi: " Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 20/22] drm/bridge: ti-tfp410: " Andrzej Pietrasiewicz
2019-06-28 16:01       ` [PATCH v3 21/22] drm/amdgpu: " Andrzej Pietrasiewicz
     [not found]         ` <5e355b8bec8fb3907566a741db8cc3e356246a32.1561735433.git.andrzej.p-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2019-07-02 20:54           ` Alex Deucher
     [not found]             ` <CADnq5_MrVoScVFgj3TP2Z+Ky8_32k=Cou5jebuMT5gE1+GZ0cA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-07-04 13:17               ` Andrzej Pietrasiewicz
     [not found]                 ` <fc26ac17-dc18-f995-53cf-42b50754c916-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2019-07-05 20:17                   ` Alex Deucher
2019-06-28 16:01       ` [PATCH v3 22/22] drm/radeon: " Andrzej Pietrasiewicz
2019-07-02 20:56         ` Alex Deucher
2019-06-28 16:45       ` [PATCH v3 00/22] Associate ddc adapters with connectors Daniel Vetter
     [not found]         ` <20190628164514.GS12905-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2019-07-02 15:08           ` Emil Velikov
2019-06-28 16:11     ` Laurent Pinchart
     [not found]       ` <20190628161137.GH4779-N3hz7ZxfLydczECFQUw77jytWr6r+dGw0E9HWUfgJXw@public.gmane.org>
2019-07-05  8:38         ` Andrzej Pietrasiewicz
     [not found]           ` <44f98134-bc8a-133a-b702-589f007b175e-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2019-07-05  8:39             ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9b03d145-ec50-927c-55a8-dff1cd51d655@suse.de \
    --to=tzimmermann-l3a5bk7wagm@public.gmane.org \
    --cc=David1.Zhou-5C7GfCeVMHo@public.gmane.org \
    --cc=Laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org \
    --cc=a.hajda-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=andrzej.p-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org \
    --cc=benjamin.gaignard-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org \
    --cc=jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=jy0922.shim-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=kernel-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org \
    --cc=krzk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=maxime.ripard-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org \
    --cc=narmstrong-rdvid1DuHRBWk0Htik3J/w@public.gmane.org \
    --cc=robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=sam-uyr5N9Q2VtJg9hUCZPvPmw@public.gmane.org \
    --cc=thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=ville.syrjala-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=vincent.abriou-qxv4g6HH51o@public.gmane.org \
    --cc=yc_chen-SAlXDmAnmOAqDJ6do+/SaQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox