From: Heiko Stuebner <heiko@sntech.de>
To: airlied@linux.ie, mark.yao@rock-chips.com,
laurent.pinchart@ideasonboard.com
Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-rockchip@lists.infradead.org,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH RFC v2 01/12] drm/encoder: add functionality to register encoders to a global list
Date: Wed, 1 Apr 2015 12:09:35 +0200 [thread overview]
Message-ID: <1427882986-19110-2-git-send-email-heiko@sntech.de> (raw)
In-Reply-To: <1427882986-19110-1-git-send-email-heiko@sntech.de>
This allows standalone encoders to be registered and found again
through their devicetree node when going through their connection graph.
Setting the of_node property is of course still optional, as it is not
necessary in most cases to lookup encoders that are part of a bigger
component.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
drivers/gpu/drm/drm_crtc.c | 41 +++++++++++++++++++++++++++++++++++++++++
include/drm/drm_crtc.h | 8 ++++++++
2 files changed, 49 insertions(+)
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index f6d04c7..b63e69d 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -1066,6 +1066,47 @@ void drm_connector_unplug_all(struct drm_device *dev)
}
EXPORT_SYMBOL(drm_connector_unplug_all);
+static DEFINE_MUTEX(encoder_lock);
+static LIST_HEAD(encoder_list);
+
+int drm_encoder_add(struct drm_encoder *encoder)
+{
+ mutex_lock(&encoder_lock);
+ list_add_tail(&encoder->list, &encoder_list);
+ mutex_unlock(&encoder_lock);
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_encoder_add);
+
+void drm_encoder_remove(struct drm_encoder *encoder)
+{
+ mutex_lock(&encoder_lock);
+ list_del_init(&encoder->list);
+ mutex_unlock(&encoder_lock);
+}
+EXPORT_SYMBOL(drm_encoder_remove);
+
+#ifdef CONFIG_OF
+struct drm_encoder *of_drm_find_encoder(struct device_node *np)
+{
+ struct drm_encoder *encoder;
+
+ mutex_lock(&encoder_lock);
+
+ list_for_each_entry(encoder, &encoder_list, list) {
+ if (encoder->of_node == np) {
+ mutex_unlock(&encoder_lock);
+ return encoder;
+ }
+ }
+
+ mutex_unlock(&encoder_lock);
+ return NULL;
+}
+EXPORT_SYMBOL(of_drm_find_encoder);
+#endif
+
/**
* drm_encoder_init - Init a preallocated encoder
* @dev: drm device
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 920e21a..76994ba 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -569,6 +569,7 @@ struct drm_encoder_funcs {
/**
* struct drm_encoder - central DRM encoder structure
* @dev: parent DRM device
+ * @of_node: device node pointer to the bridge
* @head: list management
* @base: base KMS object
* @name: encoder name
@@ -585,6 +586,10 @@ struct drm_encoder_funcs {
*/
struct drm_encoder {
struct drm_device *dev;
+#ifdef CONFIG_OF
+ struct device_node *of_node;
+#endif
+ struct list_head list;
struct list_head head;
struct drm_mode_object base;
@@ -1225,6 +1230,9 @@ extern void drm_bridge_remove(struct drm_bridge *bridge);
extern struct drm_bridge *of_drm_find_bridge(struct device_node *np);
extern int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge);
+extern int drm_encoder_add(struct drm_encoder *encoder);
+extern void drm_encoder_remove(struct drm_encoder *encoder);
+extern struct drm_encoder *of_drm_find_encoder(struct device_node *np);
extern int drm_encoder_init(struct drm_device *dev,
struct drm_encoder *encoder,
const struct drm_encoder_funcs *funcs,
--
2.1.4
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2015-04-01 10:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-01 10:09 [PATCH RFC v2 00/12] drm/rockchip: add support for lvds controller and external encoders Heiko Stuebner
2015-04-01 10:09 ` Heiko Stuebner [this message]
2015-04-01 10:09 ` [PATCH RFC v2 04/12] drm/components: add generic vga encoder driver Heiko Stuebner
[not found] ` <1427882986-19110-5-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2015-04-01 10:27 ` Russell King - ARM Linux
2015-04-01 10:40 ` Heiko Stübner
2015-04-01 10:09 ` [PATCH RFC v2 06/12] dt-bindings: Add documentation for rockchip lvds Heiko Stuebner
[not found] ` <1427882986-19110-1-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2015-04-01 10:09 ` [PATCH RFC v2 02/12] drm/connector: add functionality to register connectors to a global list Heiko Stuebner
2015-04-01 10:09 ` [PATCH RFC v2 03/12] drm: add components subdirectory and infrastructure Heiko Stuebner
2015-04-01 10:09 ` [PATCH RFC v2 05/12] drm/components: add generic vga connector driver Heiko Stuebner
2015-04-01 10:09 ` [PATCH RFC v2 07/12] drm/rockchip: Add support for Rockchip Soc LVDS Heiko Stuebner
2015-04-01 10:09 ` [PATCH RFC v2 08/12] drm/rockchip: lvds: register a bridge when no panel is set Heiko Stuebner
2015-04-01 10:09 ` [PATCH RFC v2 09/12] drm/rockchip: enable rgb output of vops for all other connectors Heiko Stuebner
2015-04-01 10:09 ` [PATCH RFC v2 10/12] ARM: dts: rockchip: add rk3288 lcdc0 pinmux settings Heiko Stuebner
2015-04-01 10:09 ` [PATCH RFC v2 11/12] ARM: dts: rockchip: add rk3288 lvds node Heiko Stuebner
2015-04-01 10:09 ` [PATCH RFC v2 12/12] ARM: dts: rockchip: add vga encoder and enable lvds on rk3288-firefly Heiko Stuebner
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=1427882986-19110-2-git-send-email-heiko@sntech.de \
--to=heiko@sntech.de \
--cc=airlied@linux.ie \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mark.yao@rock-chips.com \
/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;
as well as URLs for NNTP newsgroup(s).