devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ajay Kumar <ajaykumar.rs@samsung.com>
To: dri-devel@lists.freedesktop.org,
	linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org
Cc: inki.dae@samsung.com, seanpaul@google.com, ajaynumb@gmail.com,
	robdclark@gmail.com, daniel.vetter@ffwll.ch,
	thierry.reding@gmail.com, joshi@samsung.com,
	prashanth.g@samsung.com, marcheu@chromium.org,
	Ajay Kumar <ajaykumar.rs@samsung.com>
Subject: [PATCH V4 06/10] drm/bridge: Add a driver which binds drm_bridge with drm_panel
Date: Wed, 11 Jun 2014 23:57:04 +0530	[thread overview]
Message-ID: <1402511228-18945-7-git-send-email-ajaykumar.rs@samsung.com> (raw)
In-Reply-To: <1402511228-18945-1-git-send-email-ajaykumar.rs@samsung.com>

Add a dummy bridge which binds all of the drm_bridge callbacks
to corresponding drm_panel callbacks.

In theory, this is just a glue layer for the last bridge and
the panel attached to it.

This driver also implements the required drm_connector ops
for the encoder(on which the entire bridge chain is hanging off).

Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>
---
 drivers/gpu/drm/bridge/Kconfig        |    7 ++
 drivers/gpu/drm/bridge/Makefile       |    1 +
 drivers/gpu/drm/bridge/panel_binder.c |  193 +++++++++++++++++++++++++++++++++
 include/drm/bridge/panel_binder.h     |   44 ++++++++
 4 files changed, 245 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/panel_binder.c
 create mode 100644 include/drm/bridge/panel_binder.h

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index 884923f..e3fb487 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -3,3 +3,10 @@ config DRM_PTN3460
 	depends on DRM
 	select DRM_KMS_HELPER
 	---help---
+
+config DRM_PANEL_BINDER
+	tristate "bridge panel binder"
+	depends on DRM
+	select DRM_KMS_HELPER
+	select DRM_PANEL
+	---help---
diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index b4733e1..ba8b5b8 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -1,3 +1,4 @@
 ccflags-y := -Iinclude/drm
 
 obj-$(CONFIG_DRM_PTN3460) += ptn3460.o
+obj-$(CONFIG_DRM_PANEL_BINDER) += panel_binder.o
diff --git a/drivers/gpu/drm/bridge/panel_binder.c b/drivers/gpu/drm/bridge/panel_binder.c
new file mode 100644
index 0000000..93d976b
--- /dev/null
+++ b/drivers/gpu/drm/bridge/panel_binder.c
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/of.h>
+
+#include <drm/drm_panel.h>
+
+#include "drmP.h"
+#include "drm_crtc.h"
+#include "drm_crtc_helper.h"
+
+#include "bridge/panel_binder.h"
+
+struct panel_binder {
+	struct drm_connector	connector;
+	struct i2c_client	*client;
+	struct drm_encoder	*encoder;
+	struct drm_bridge	*bridge;
+	struct drm_panel	*panel;
+};
+
+static void panel_binder_pre_enable(struct drm_bridge *bridge)
+{
+	struct panel_binder *panel_binder = bridge->driver_private;
+
+	drm_panel_prepare(panel_binder->panel);
+}
+
+static void panel_binder_enable(struct drm_bridge *bridge)
+{
+	struct panel_binder *panel_binder = bridge->driver_private;
+
+	drm_panel_enable(panel_binder->panel);
+}
+
+static void panel_binder_disable(struct drm_bridge *bridge)
+{
+	struct panel_binder *panel_binder = bridge->driver_private;
+
+	drm_panel_disable(panel_binder->panel);
+}
+
+static void panel_binder_post_disable(struct drm_bridge *bridge)
+{
+	struct panel_binder *panel_binder = bridge->driver_private;
+
+	drm_panel_unprepare(panel_binder->panel);
+}
+
+void panel_binder_destroy(struct drm_bridge *bridge)
+{
+	struct panel_binder *panel_binder = bridge->driver_private;
+
+	drm_panel_detach(panel_binder->panel);
+	drm_bridge_cleanup(bridge);
+}
+
+struct drm_bridge_funcs panel_binder_funcs = {
+	.pre_enable = panel_binder_pre_enable,
+	.enable = panel_binder_enable,
+	.disable = panel_binder_disable,
+	.post_disable = panel_binder_post_disable,
+	.destroy = panel_binder_destroy,
+};
+
+static int panel_binder_mode_valid(struct drm_connector *connector,
+				 struct drm_display_mode *mode)
+{
+	return MODE_OK;
+}
+
+static int panel_binder_get_modes(struct drm_connector *connector)
+{
+	struct panel_binder *panel_binder;
+
+	panel_binder = container_of(connector, struct panel_binder, connector);
+
+	return panel_binder->panel->funcs->get_modes(panel_binder->panel);
+}
+
+static struct drm_encoder *panel_binder_best_encoder(struct drm_connector
+								*connector)
+{
+	struct panel_binder *panel_binder;
+
+	panel_binder = container_of(connector, struct panel_binder, connector);
+
+	return panel_binder->encoder;
+}
+
+static const struct drm_connector_helper_funcs
+					panel_binder_connector_helper_funcs = {
+	.get_modes = panel_binder_get_modes,
+	.mode_valid = panel_binder_mode_valid,
+	.best_encoder = panel_binder_best_encoder,
+};
+
+static enum drm_connector_status panel_binder_detect(struct drm_connector
+							*connector, bool force)
+{
+	return connector_status_connected;
+}
+
+static void panel_binder_connector_destroy(struct drm_connector *connector)
+{
+	drm_connector_cleanup(connector);
+}
+
+static const struct drm_connector_funcs panel_binder_connector_funcs = {
+	.dpms = drm_helper_connector_dpms,
+	.fill_modes = drm_helper_probe_single_connector_modes,
+	.detect = panel_binder_detect,
+	.destroy = panel_binder_connector_destroy,
+};
+
+struct drm_bridge *panel_binder_init(struct drm_device *dev,
+					struct drm_encoder *encoder,
+					struct i2c_client *client,
+					struct device_node *node,
+					struct drm_panel *panel,
+					int connector_type,
+					uint8_t polled)
+{
+	int ret;
+	struct drm_bridge *bridge;
+	struct panel_binder *panel_binder;
+
+	if (IS_ERR_OR_NULL(panel)) {
+		DRM_ERROR("invalid drm_panel pointer\n");
+		return NULL;
+	}
+
+	bridge = devm_kzalloc(dev->dev, sizeof(*bridge), GFP_KERNEL);
+	if (!bridge) {
+		DRM_ERROR("failed to allocate drm bridge\n");
+		return NULL;
+	}
+
+	panel_binder = devm_kzalloc(dev->dev, sizeof(*panel_binder),
+								GFP_KERNEL);
+	if (!panel_binder) {
+		DRM_ERROR("failed to allocate bridge panel_binder\n");
+		return NULL;
+	}
+
+	panel_binder->client = client;
+	panel_binder->encoder = encoder;
+	panel_binder->bridge = bridge;
+	panel_binder->panel = panel;
+
+	ret = drm_bridge_init(dev, bridge, &panel_binder_funcs);
+	if (ret) {
+		DRM_ERROR("failed to initialize bridge with drm\n");
+		goto err;
+	}
+
+	bridge->driver_private = panel_binder;
+
+	drm_panel_attach(panel_binder->panel, &panel_binder->connector);
+
+	if (!encoder->bridge)
+		/* First entry in the bridge chain */
+		encoder->bridge = bridge;
+
+	panel_binder->connector.polled = polled;
+	ret = drm_connector_init(dev, &panel_binder->connector,
+			&panel_binder_connector_funcs, connector_type);
+	if (ret) {
+		DRM_ERROR("failed to initialize connector with drm\n");
+		goto err;
+	}
+	drm_connector_helper_add(&panel_binder->connector,
+			&panel_binder_connector_helper_funcs);
+	drm_sysfs_connector_add(&panel_binder->connector);
+	drm_mode_connector_attach_encoder(&panel_binder->connector, encoder);
+
+	return bridge;
+
+err:
+	return NULL;
+}
+EXPORT_SYMBOL(panel_binder_init);
diff --git a/include/drm/bridge/panel_binder.h b/include/drm/bridge/panel_binder.h
new file mode 100644
index 0000000..b5ebbc2
--- /dev/null
+++ b/include/drm/bridge/panel_binder.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _DRM_BRIDGE_PANEL_H_
+#define _DRM_BRIDGE_PANEL_H_
+
+struct drm_device;
+struct drm_encoder;
+struct i2c_client;
+struct device_node;
+struct drm_panel;
+
+#if defined(CONFIG_DRM_PANEL_BINDER)
+struct drm_bridge *panel_binder_init(struct drm_device *dev,
+					struct drm_encoder *encoder,
+					struct i2c_client *client,
+					struct device_node *node,
+					struct drm_panel *panel,
+					int connector_type,
+					uint8_t polled);
+#else
+static inline struct drm_bridge *panel_binder_init(struct drm_device *dev,
+						struct drm_encoder *encoder,
+						struct i2c_client *client,
+						struct device_node *node,
+						struct drm_panel *panel,
+						int connector_type,
+						uint8_t polled)
+{
+	return 0;
+}
+#endif
+
+#endif
-- 
1.7.9.5

  parent reply	other threads:[~2014-06-11 18:27 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-11 18:26 [PATCH V4 00/10] drm: exynos: few patches to enhance bridge chip support Ajay Kumar
2014-06-11 18:26 ` [PATCH V4 01/10] drm/exynos: Move DP setup out of hotplug workqueue Ajay Kumar
2014-06-20  8:07   ` Ajay kumar
2014-06-11 18:27 ` [PATCH V4 02/10] drm/panel: add prepare and unprepare routines Ajay Kumar
2014-06-20  8:07   ` Ajay kumar
2014-06-11 18:27 ` [PATCH V4 03/10] drm/exynos: dp: modify driver to support drm_panel Ajay Kumar
2014-06-20  8:08   ` Ajay kumar
2014-06-11 18:27 ` [PATCH V4 04/10] drm/panel: Add driver for lvds/edp based panels Ajay Kumar
2014-06-20  8:07   ` Ajay kumar
     [not found]   ` <1402511228-18945-5-git-send-email-ajaykumar.rs-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-06-23 15:30     ` Javier Martinez Canillas
2014-06-24  8:18       ` Ajay kumar
2014-06-23 16:55   ` Christian Gmeiner
2014-06-24  8:22     ` Ajay kumar
2014-06-11 18:27 ` [PATCH V4 05/10] drm/bridge: add helper functions to support bridge chain Ajay Kumar
2014-06-20  8:07   ` Ajay kumar
2014-06-11 18:27 ` Ajay Kumar [this message]
     [not found]   ` <1402511228-18945-7-git-send-email-ajaykumar.rs-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-06-20  8:08     ` [PATCH V4 06/10] drm/bridge: Add a driver which binds drm_bridge with drm_panel Ajay kumar
2014-06-11 18:27 ` [PATCH V4 07/10] drm/bridge: ptn3460: Support bridge chaining Ajay Kumar
2014-06-20  8:09   ` Ajay kumar
2014-06-11 18:27 ` [PATCH V4 08/10] drm/exynos: dp: create bridge chain using ptn3460 and panel_binder Ajay Kumar
2014-06-20  8:09   ` Ajay kumar
2014-06-11 18:27 ` [PATCH V4 09/10] drm/bridge: Add ps8622/ps8625 bridge driver Ajay Kumar
2014-06-20  8:09   ` Ajay kumar
2014-06-23 16:05   ` Javier Martinez Canillas
2014-06-24  8:15     ` Ajay kumar
2014-06-11 18:27 ` [PATCH V4 10/10] drm/exynos: Add ps8622 lvds bridge discovery to DP driver Ajay Kumar
2014-06-20  8:09   ` Ajay kumar
2014-06-20  8:06 ` [PATCH V4 00/10] drm: exynos: few patches to enhance bridge chip support Ajay kumar
2014-06-20 15:51   ` Inki Dae
2014-06-23 13:58     ` Rahul Sharma
2014-06-23 14:38       ` Tomasz Figa
2014-06-24  3:25         ` Rahul Sharma
2014-06-23 16:15     ` Javier Martinez Canillas
2014-07-03  5:19 ` Andreas Färber
2014-07-03 14:55   ` Ajay kumar
2014-07-04 13:06     ` Andreas Färber
2014-07-07 20:27       ` Doug Anderson
2014-07-07 20:46   ` Doug Anderson
2014-07-09  6:11     ` Ajay kumar
2014-07-14 17:22       ` Olof Johansson
2014-07-15  5:37         ` Inki Dae

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=1402511228-18945-7-git-send-email-ajaykumar.rs@samsung.com \
    --to=ajaykumar.rs@samsung.com \
    --cc=ajaynumb@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=inki.dae@samsung.com \
    --cc=joshi@samsung.com \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=marcheu@chromium.org \
    --cc=prashanth.g@samsung.com \
    --cc=robdclark@gmail.com \
    --cc=seanpaul@google.com \
    --cc=thierry.reding@gmail.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).