mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 07/13] video: Add Video Pipeline (VPL) support
Date: Thu,  9 Jul 2015 09:24:11 +0200	[thread overview]
Message-ID: <1436426657-5266-8-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1436426657-5266-1-git-send-email-s.hauer@pengutronix.de>

Complex video pipelines are modelled with the of_graph bindings in
the devicetree. This patch adds a ioctl infrastructure to issue
commands to the remote endpoint of a of_graph. Currently defined
ioctls are prepare/unprepare, enable/disable and get_modes. This
is enough to control LVDS or HDMI encoder or simple panels.

A device node which contains of_graph endpoints can be registered
as a VPL entity. An entity can receive ioctls via the .ioctl callback
and also issue ioctls by calling vpl_ioctl. The core itself will never
iterate over the entire pipeline. Instead, the different VPL entities
should forward an ioctl to the next instance in the pipeline whenever
necessary.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/video/Kconfig  |   3 ++
 drivers/video/Makefile |   1 +
 drivers/video/vpl.c    | 115 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/fb.h           |   1 +
 include/video/vpl.h    |  46 ++++++++++++++++++++
 5 files changed, 166 insertions(+)
 create mode 100644 drivers/video/vpl.c
 create mode 100644 include/video/vpl.h

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 8e6ae99..6d540a5 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -5,6 +5,9 @@ menuconfig VIDEO
 
 if VIDEO
 
+config VIDEO_VPL
+	bool
+
 config DRIVER_VIDEO_ATMEL
 	bool "Atmel LCDC framebuffer driver"
 	depends on ARCH_AT91
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 76fad5c..3aa544a 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_DRIVER_VIDEO_EDID) += edid.o
 obj-$(CONFIG_OFDEVICE) += of_display_timing.o
 obj-$(CONFIG_DRIVER_VIDEO_BACKLIGHT) += backlight.o
 obj-$(CONFIG_DRIVER_VIDEO_BACKLIGHT_PWM) += backlight-pwm.o
+obj-$(CONFIG_VIDEO_VPL) += vpl.o
 
 obj-$(CONFIG_DRIVER_VIDEO_ATMEL) += atmel_lcdfb.o atmel_lcdfb_core.o
 obj-$(CONFIG_DRIVER_VIDEO_ATMEL_HLCD) += atmel_hlcdfb.o atmel_lcdfb_core.o
diff --git a/drivers/video/vpl.c b/drivers/video/vpl.c
new file mode 100644
index 0000000..99ad180
--- /dev/null
+++ b/drivers/video/vpl.c
@@ -0,0 +1,115 @@
+/*
+ * Video pipeline (VPL) support for barebox
+ *
+ * (C) Copyright 2014 Sascha Hauer, Pengutronix
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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.
+ *
+ */
+#define pr_fmt(fmt) "VPL: " fmt
+
+#include <common.h>
+#include <driver.h>
+#include <of_graph.h>
+#include <linux/list.h>
+#include <video/vpl.h>
+
+static LIST_HEAD(vpls);
+
+int vpl_register(struct vpl *vpl)
+{
+	list_add_tail(&vpl->list, &vpls);
+
+	pr_debug("%s: %s\n", __func__, vpl->node->full_name);
+
+	return 0;
+}
+
+struct vpl *of_find_vpl(struct device_node *node)
+{
+	struct vpl *vpl;
+
+	list_for_each_entry(vpl, &vpls, list)
+		if (vpl->node == node)
+			return vpl;
+
+	return NULL;
+}
+
+struct vpl *of_vpl_get(struct device_node *node, int port)
+{
+	node = of_graph_get_port_by_id(node, port);
+	if (!node)
+		return NULL;
+
+	pr_debug("%s: port: %s\n", __func__, node->full_name);
+
+	node = of_graph_get_remote_port_parent(node);
+	if (!node)
+		return NULL;
+
+	pr_debug("%s: remote port parent: %s\n", __func__, node->full_name);
+
+	return of_find_vpl(node);
+}
+
+int vpl_ioctl(struct vpl *vpl, unsigned int port,
+		unsigned int cmd, void *ptr)
+{
+	struct device_node *node, *endpoint;
+	int ret;
+
+	pr_debug("%s: %s port %d\n", __func__, vpl->node->full_name, port);
+
+	node = of_graph_get_port_by_id(vpl->node, port);
+	if (!node) {
+		pr_err("%s: no port %d on %s\n", __func__, port, vpl->node->full_name);
+		return -ENODEV;
+	}
+
+	for_each_child_of_node(node, endpoint) {
+		struct device_node *remote, *remote_parent;
+		struct vpl *remote_vpl;
+		u32 remote_port_id;
+
+		remote = of_graph_get_remote_port(endpoint);
+		if (!remote) {
+			pr_debug("%s: no remote for endpoint %s\n", __func__, endpoint->full_name);
+			continue;
+		}
+
+		of_property_read_u32(remote, "reg", &remote_port_id);
+
+		remote_parent = of_graph_get_remote_port_parent(endpoint);
+		if (!remote_parent) {
+			pr_debug("%s: no remote_parent\n", __func__);
+			return -ENODEV;
+		}
+
+		if (!of_device_is_available(remote_parent))
+			continue;
+
+		remote_vpl = of_find_vpl(remote_parent);
+		if (!remote_vpl) {
+			pr_debug("%s: cannot find remote vpl %s\n", __func__, remote->full_name);
+			continue;
+		}
+
+		ret = remote_vpl->ioctl(remote_vpl, remote_port_id, cmd, ptr);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
diff --git a/include/fb.h b/include/fb.h
index 2db6ad6..9e59b2a 100644
--- a/include/fb.h
+++ b/include/fb.h
@@ -99,6 +99,7 @@ struct display_timings {
 
 	unsigned int num_modes;
 	struct fb_videomode *modes;
+	void *edid;
 };
 
 struct i2c_adapter;
diff --git a/include/video/vpl.h b/include/video/vpl.h
new file mode 100644
index 0000000..846007f
--- /dev/null
+++ b/include/video/vpl.h
@@ -0,0 +1,46 @@
+#ifndef __VIDEO_VPL_H
+#define __VIDEO_VPL_H
+
+#include <fb.h>
+
+#define VPL_PREPARE		0x67660001
+#define VPL_UNPREPARE		0x67660002
+#define VPL_ENABLE		0x67660003
+#define VPL_DISABLE		0x67660004
+#define VPL_GET_VIDEOMODES	0x67660005
+
+struct vpl {
+	int (*ioctl)(struct vpl *, unsigned int port,
+			unsigned int cmd, void *ptr);
+	struct device_node *node;
+	struct list_head list;
+};
+
+int vpl_register(struct vpl *);
+int vpl_ioctl(struct vpl *, unsigned int port,
+		unsigned int cmd, void *ptr);
+
+struct vpl *of_vpl_get(struct device_node *node, int port);
+
+static inline int vpl_ioctl_prepare(struct vpl *vpl, unsigned int port,
+		struct fb_videomode *mode)
+{
+	return vpl_ioctl(vpl, port, VPL_PREPARE, mode);
+}
+
+static inline int vpl_ioctl_unprepare(struct vpl *vpl, unsigned int port)
+{
+	return vpl_ioctl(vpl, port, VPL_UNPREPARE, NULL);
+}
+
+static inline int vpl_ioctl_enable(struct vpl *vpl, unsigned int port)
+{
+	return vpl_ioctl(vpl, port, VPL_ENABLE, NULL);
+}
+
+static inline int vpl_ioctl_disable(struct vpl *vpl, unsigned int port)
+{
+	return vpl_ioctl(vpl, port, VPL_DISABLE, NULL);
+}
+
+#endif /* __VIDEO_VPL_H */
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2015-07-09  7:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-09  7:24 Video support for EfikaSB Sascha Hauer
2015-07-09  7:24 ` [PATCH 01/13] of: base: implement of_get_next_child Sascha Hauer
2015-07-09  7:24 ` [PATCH 02/13] of: import of_graph functions Sascha Hauer
2015-07-09  7:24 ` [PATCH 03/13] of_graph: add of_graph_port_is_available Sascha Hauer
2015-07-09  7:24 ` [PATCH 04/13] ARM: i.MX51 Efikasb: Disable backlight earlier Sascha Hauer
2015-07-09  7:24 ` [PATCH 05/13] ARM: i.MX51 Efikasb: make more space for barebox Sascha Hauer
2015-07-09  7:24 ` [PATCH 06/13] ARM: i.MX51 Efikasb: update device tree Sascha Hauer
2015-07-09  7:24 ` Sascha Hauer [this message]
2015-07-09  7:24 ` [PATCH 08/13] video: Add MTL017 LVDS encoder support Sascha Hauer
2015-07-09  7:24 ` [PATCH 09/13] video: Add missing prototype for display_timings_release Sascha Hauer
2015-07-09  7:24 ` [PATCH 10/13] video: ipuv3: remove unused variable Sascha Hauer
2015-07-09  7:24 ` [PATCH 11/13] video: ipuv3: Replace ipu_output with VPL Sascha Hauer
2015-07-09  7:24 ` [PATCH 12/13] video: ipuv3: match ipu_di_signal_cfg's clk_pol with its description Sascha Hauer
2015-07-09  7:24 ` [PATCH 13/13] video: Add simple-panel support Sascha Hauer

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=1436426657-5266-8-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.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