All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
To: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
	linux-media@vger.kernel.org
Cc: "Sebastien Guiriec" <s-guiriec@ti.com>,
	"Jesse Barnes" <jesse.barnes@intel.com>,
	"Benjamin Gaignard" <benjamin.gaignard@linaro.org>,
	"Tom Gall" <tom.gall@linaro.org>,
	"Kyungmin Park" <kyungmin.park@samsung.com>,
	"Tomi Valkeinen" <tomi.valkeinen@ti.com>,
	"Stephen Warren" <swarren@wwwdotorg.org>,
	"Mark Zhang" <markz@nvidia.com>,
	"Stéphane Marchesin" <stephane.marchesin@gmail.com>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Ragesh Radhakrishnan" <Ragesh.R@linaro.org>,
	"Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>,
	"Sunil Joshi" <joshi@samsung.com>,
	"Maxime Ripard" <maxime.ripard@free-electrons.com>,
	"Vikas Sajjan" <vikas.sajjan@linaro.org>,
	"Marcus Lorentzon" <marcus.lorentzon@huawei.com>
Subject: [PATCH/RFC v3 09/19] video: panel: Add DPI panel support
Date: Fri,  9 Aug 2013 19:15:00 +0200	[thread overview]
Message-ID: <1376068510-30363-10-git-send-email-laurent.pinchart+renesas@ideasonboard.com> (raw)
In-Reply-To: <1376068510-30363-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com>

The Display Pixel Interface is a configurable-width video-only
unidirectional parallel bus standard that defines video formats and
signaling for panel devices.

This driver implements support for simple DPI panels with no runtime
configuration capabilities (GPIOs- and/or regulators-based control can
be implemented later when needed) and exposes it as a display entity.
The panel native video mode is passed to the driver through platform
data or device tree properties.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/video/display/Kconfig     |  10 ++
 drivers/video/display/Makefile    |   1 +
 drivers/video/display/panel-dpi.c | 207 ++++++++++++++++++++++++++++++++++++++
 include/video/panel-dpi.h         |  24 +++++
 4 files changed, 242 insertions(+)
 create mode 100644 drivers/video/display/panel-dpi.c
 create mode 100644 include/video/panel-dpi.h

diff --git a/drivers/video/display/Kconfig b/drivers/video/display/Kconfig
index f7532c1..bce09d6 100644
--- a/drivers/video/display/Kconfig
+++ b/drivers/video/display/Kconfig
@@ -9,4 +9,14 @@ config DISPLAY_MIPI_DBI
 	tristate
 	default n
 
+config DISPLAY_PANEL_DPI
+	tristate "DPI (Parallel) Display Panels"
+	---help---
+	  Support for simple digital (parallel) pixel interface panels. Those
+	  panels receive pixel data through a parallel bus and have no control
+	  bus.
+
+	  If you are in doubt, say N. To compile this driver as a module, choose
+	  M here; the module will be called panel-dpi.
+
 endif # DISPLAY_CORE
diff --git a/drivers/video/display/Makefile b/drivers/video/display/Makefile
index 59022d2..31c017b 100644
--- a/drivers/video/display/Makefile
+++ b/drivers/video/display/Makefile
@@ -2,3 +2,4 @@ display-y					:= display-core.o \
 						   display-notifier.o
 obj-$(CONFIG_DISPLAY_CORE)			+= display.o
 obj-$(CONFIG_DISPLAY_MIPI_DBI)			+= mipi-dbi-bus.o
+obj-$(CONFIG_DISPLAY_PANEL_DPI)			+= panel-dpi.o
diff --git a/drivers/video/display/panel-dpi.c b/drivers/video/display/panel-dpi.c
new file mode 100644
index 0000000..b1ecf6d
--- /dev/null
+++ b/drivers/video/display/panel-dpi.c
@@ -0,0 +1,207 @@
+/*
+ * DPI Display Panel
+ *
+ * Copyright (C) 2012 Renesas Solutions Corp.
+ *
+ * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#include <video/display.h>
+#include <video/of_display_timing.h>
+#include <video/of_videomode.h>
+#include <video/panel-dpi.h>
+#include <video/videomode.h>
+
+struct panel_dpi {
+	struct display_entity entity;
+
+	unsigned int width;
+	unsigned int height;
+	struct videomode mode;
+};
+
+static inline struct panel_dpi *to_panel_dpi(struct display_entity *e)
+{
+	return container_of(e, struct panel_dpi, entity);
+}
+
+static const struct display_entity_interface_params panel_dpi_params = {
+	.type = DISPLAY_ENTITY_INTERFACE_DPI,
+};
+
+static int panel_dpi_set_state(struct display_entity *entity,
+			       enum display_entity_state state)
+{
+	struct media_pad *source;
+
+	source = media_entity_remote_pad(&entity->entity.pads[0]);
+	if (source == NULL)
+		return -EPIPE;
+
+	switch (state) {
+	case DISPLAY_ENTITY_STATE_OFF:
+	case DISPLAY_ENTITY_STATE_STANDBY:
+		display_entity_set_stream(to_display_entity(source->entity),
+					  source->index,
+					  DISPLAY_ENTITY_STREAM_STOPPED);
+		break;
+
+	case DISPLAY_ENTITY_STATE_ON:
+		display_entity_set_stream(to_display_entity(source->entity),
+					  source->index,
+					  DISPLAY_ENTITY_STREAM_CONTINUOUS);
+		break;
+	}
+
+	return 0;
+}
+
+static int panel_dpi_get_modes(struct display_entity *entity, unsigned int port,
+			       const struct videomode **modes)
+{
+	struct panel_dpi *panel = to_panel_dpi(entity);
+
+	*modes = &panel->mode;
+	return 1;
+}
+
+static int panel_dpi_get_size(struct display_entity *entity,
+			      unsigned int *width, unsigned int *height)
+{
+	struct panel_dpi *panel = to_panel_dpi(entity);
+
+	*width = panel->width;
+	*height = panel->height;
+	return 0;
+}
+
+static int panel_dpi_get_params(struct display_entity *entity,
+				unsigned int port,
+				struct display_entity_interface_params *params)
+{
+	*params = panel_dpi_params;
+	return 0;
+}
+
+static const struct display_entity_control_ops panel_dpi_control_ops = {
+	.set_state = panel_dpi_set_state,
+	.get_modes = panel_dpi_get_modes,
+	.get_size = panel_dpi_get_size,
+	.get_params = panel_dpi_get_params,
+};
+
+static const struct display_entity_ops panel_dpi_ops = {
+	.ctrl = &panel_dpi_control_ops,
+};
+
+static int panel_dpi_remove(struct platform_device *pdev)
+{
+	struct panel_dpi *panel = platform_get_drvdata(pdev);
+
+	display_entity_remove(&panel->entity);
+	display_entity_cleanup(&panel->entity);
+
+	return 0;
+}
+
+static int panel_dpi_parse_pdata(struct panel_dpi *panel,
+				 struct platform_device *pdev)
+{
+	const struct panel_dpi_platform_data *pdata = pdev->dev.platform_data;
+	struct device_node *np = pdev->dev.of_node;
+	int ret;
+
+	if (pdata) {
+		panel->width = pdata->width;
+		panel->height = pdata->height;
+		panel->mode = *pdata->mode;
+	} else if (IS_ENABLED(CONFIG_OF) && np) {
+		/* Width and height are optional. */
+		of_property_read_u32(np, "width-mm", &panel->width);
+		of_property_read_u32(np, "height-mm", &panel->height);
+
+		ret = of_get_videomode(np, &panel->mode, OF_USE_NATIVE_MODE);
+		if (ret < 0)
+			return ret;
+	} else {
+		dev_err(&pdev->dev, "no platform data\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int panel_dpi_probe(struct platform_device *pdev)
+{
+	struct panel_dpi *panel;
+	int ret;
+
+	panel = devm_kzalloc(&pdev->dev, sizeof(*panel), GFP_KERNEL);
+	if (panel == NULL)
+		return -ENOMEM;
+
+	ret = panel_dpi_parse_pdata(panel, pdev);
+	if (ret < 0)
+		return ret;
+
+	panel->entity.dev = &pdev->dev;
+	panel->entity.ops = &panel_dpi_ops;
+	strlcpy(panel->entity.name, "panel-dpi", sizeof(panel->entity.name));
+
+	ret = display_entity_init(&panel->entity, 1, 0);
+	if (ret < 0)
+		return ret;
+
+	ret = display_entity_add(&panel->entity);
+	if (ret < 0)
+		return ret;
+
+	platform_set_drvdata(pdev, panel);
+
+	return 0;
+}
+
+static const struct dev_pm_ops panel_dpi_dev_pm_ops = {
+};
+
+static struct platform_device_id panel_dpi_id_table[] = {
+	{ "panel-dpi", 0 },
+	{ },
+};
+MODULE_DEVICE_TABLE(platform, panel_dpi_id_table);
+
+#ifdef CONFIG_OF
+static struct of_device_id panel_dpi_of_id_table[] = {
+	{ .compatible = "panel-dpi", },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, panel_dpi_of_id_table);
+#endif
+
+static struct platform_driver panel_dpi_driver = {
+	.probe = panel_dpi_probe,
+	.remove = panel_dpi_remove,
+	.id_table = panel_dpi_id_table,
+	.driver = {
+		.name = "panel-dpi",
+		.owner = THIS_MODULE,
+		.pm = &panel_dpi_dev_pm_ops,
+		.of_match_table = of_match_ptr(panel_dpi_of_id_table),
+	},
+};
+
+module_platform_driver(panel_dpi_driver);
+
+MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@ideasonboard.com>");
+MODULE_DESCRIPTION("DPI Display Panel");
+MODULE_LICENSE("GPL");
diff --git a/include/video/panel-dpi.h b/include/video/panel-dpi.h
new file mode 100644
index 0000000..af85d5b
--- /dev/null
+++ b/include/video/panel-dpi.h
@@ -0,0 +1,24 @@
+/*
+ * DPI Display Panel
+ *
+ * Copyright (C) 2012 Renesas Solutions Corp.
+ *
+ * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __PANEL_DPI_H__
+#define __PANEL_DPI_H__
+
+struct videomode;
+
+struct panel_dpi_platform_data {
+	unsigned long width;		/* Panel width in mm */
+	unsigned long height;		/* Panel height in mm */
+	const struct videomode *mode;
+};
+
+#endif /* __PANEL_DPI_H__ */
-- 
1.8.1.5

  parent reply	other threads:[~2013-08-09 17:14 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-09 17:14 [PATCH/RFC v3 00/19] Common Display Framework Laurent Pinchart
2013-08-09 17:14 ` [PATCH/RFC v3 01/19] OMAPDSS: panels: Rename Kconfig options to OMAP2_DISPLAY_* Laurent Pinchart
2013-08-09 17:14 ` [PATCH/RFC v3 02/19] video: Add Common Display Framework core Laurent Pinchart
2013-09-02  8:42   ` Tomi Valkeinen
2013-09-03 11:29     ` Laurent Pinchart
2013-08-09 17:14 ` [PATCH/RFC v3 03/19] video: display: Add video and stream control operations Laurent Pinchart
2013-08-09 17:14 ` [PATCH/RFC v3 04/19] video: display: Add display entity notifier Laurent Pinchart
2013-08-09 17:14 ` [PATCH/RFC v3 05/19] video: display: Graph helpers Laurent Pinchart
2013-08-09 17:14 ` [PATCH/RFC v3 06/19] video: display: OF support Laurent Pinchart
2013-08-13 14:37   ` Philipp Zabel
2013-08-21  1:02     ` Laurent Pinchart
2013-08-21  9:10       ` Philipp Zabel
2013-08-22  0:51         ` Laurent Pinchart
2013-08-09 17:14 ` [PATCH/RFC v3 07/19] video: display: Add pixel coding definitions Laurent Pinchart
2013-08-09 17:14 ` [PATCH/RFC v3 08/19] video: display: Add MIPI DBI bus support Laurent Pinchart
2013-08-14  0:52   ` Rob Clark
2013-08-20 13:26     ` Laurent Pinchart
2013-08-26 11:10   ` Tomi Valkeinen
2013-09-06 14:09     ` Laurent Pinchart
2013-09-06 15:43       ` Tomi Valkeinen
2013-09-07  9:35         ` Tomi Valkeinen
2013-09-04 10:50   ` Vikas Sajjan
2013-09-06 14:37     ` Laurent Pinchart
2013-09-18 10:59       ` Vikas Sajjan
2013-09-04 12:52   ` Vikas Sajjan
2013-09-06 14:56     ` Laurent Pinchart
2013-08-09 17:15 ` Laurent Pinchart [this message]
2013-08-09 17:15 ` [PATCH/RFC v3 10/19] video: panel: Add R61505 panel support Laurent Pinchart
2013-08-09 17:15 ` [PATCH/RFC v3 11/19] video: panel: Add R61517 " Laurent Pinchart
2013-08-09 17:15 ` [PATCH/RFC v3 12/19] video: display: Add VGA Digital to Analog Converter support Laurent Pinchart
2013-08-09 17:15 ` [PATCH/RFC v3 13/19] video: display: Add VGA connector support Laurent Pinchart
2013-08-09 17:15 ` [PATCH/RFC v3 14/19] ARM: shmobile: r8a7790: Add DU clocks for DT Laurent Pinchart
2013-08-09 17:15 ` [PATCH/RFC v3 15/19] ARM: shmobile: r8a7790: Add DU device node to device tree Laurent Pinchart
2013-08-09 17:15 ` [PATCH/RFC v3 16/19] ARM: shmobile: marzen: Port DU platform data to CDF Laurent Pinchart
2013-08-09 17:15 ` [PATCH/RFC v3 17/19] ARM: shmobile: lager: " Laurent Pinchart
2013-08-09 17:15 ` [PATCH/RFC v3 18/19] ARM: shmobile: lager-reference: Add display device nodes to device tree Laurent Pinchart
2013-08-09 17:15 ` [PATCH/RFC v3 19/19] drm/rcar-du: Port to the Common Display Framework Laurent Pinchart
2013-08-14  0:43 ` [PATCH/RFC v3 00/19] " Rob Clark
2013-08-20 15:24   ` Laurent Pinchart
2013-08-20 18:40     ` Rob Clark
2013-08-21  7:09       ` Sascha Hauer
2013-08-21 12:22         ` Rob Clark
2013-09-06 16:16           ` Laurent Pinchart
2013-09-09 12:12           ` Tomi Valkeinen
2013-09-09 14:17             ` Rob Clark
2013-09-09 14:58               ` Tomi Valkeinen
2013-09-09 15:10                 ` Rob Clark
2013-09-02 11:06 ` Tomi Valkeinen
2013-09-30 13:48 ` Tomi Valkeinen
2013-10-02 12:23   ` Andrzej Hajda
2013-10-02 12:23     ` Andrzej Hajda
2013-10-02 13:24     ` Tomi Valkeinen
2013-10-02 13:24       ` Tomi Valkeinen
2013-10-02 13:24       ` Tomi Valkeinen
2013-10-09 14:08       ` Andrzej Hajda
2013-10-09 14:08         ` Andrzej Hajda
2013-10-11  6:37         ` Tomi Valkeinen
2013-10-11  6:37           ` Tomi Valkeinen
2013-10-11  6:37           ` Tomi Valkeinen
2013-10-11 11:19           ` Andrzej Hajda
2013-10-11 11:19             ` Andrzej Hajda
2013-10-11 12:30             ` Tomi Valkeinen
2013-10-11 12:30               ` Tomi Valkeinen
2013-10-11 12:30               ` Tomi Valkeinen
2013-10-11 14:16               ` Andrzej Hajda
2013-10-11 14:16                 ` Andrzej Hajda
2013-10-11 14:45                 ` Tomi Valkeinen
2013-10-11 14:45                   ` Tomi Valkeinen
2013-10-11 14:45                   ` Tomi Valkeinen
2013-10-17  7:48                   ` Andrzej Hajda
2013-10-17  7:48                     ` Andrzej Hajda
2013-10-17  8:18                     ` Tomi Valkeinen
2013-10-17  8:18                       ` Tomi Valkeinen
2013-10-17  8:18                       ` Tomi Valkeinen
2013-10-17 12:26                       ` Andrzej Hajda
2013-10-17 12:26                         ` Andrzej Hajda
2013-10-17 12:55                         ` Tomi Valkeinen
2013-10-17 12:55                           ` Tomi Valkeinen
2013-10-17 12:55                           ` Tomi Valkeinen
2013-10-18 11:55                           ` Andrzej Hajda
2013-10-18 11:55                             ` Andrzej Hajda
2013-08-09 23:02 Laurent Pinchart
2013-08-09 23:03 ` [PATCH/RFC v3 09/19] video: panel: Add DPI panel support Laurent Pinchart
2013-08-09 23:03   ` 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=1376068510-30363-10-git-send-email-laurent.pinchart+renesas@ideasonboard.com \
    --to=laurent.pinchart+renesas@ideasonboard.com \
    --cc=Ragesh.R@linaro.org \
    --cc=acourbot@nvidia.com \
    --cc=benjamin.gaignard@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jesse.barnes@intel.com \
    --cc=joshi@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=marcus.lorentzon@huawei.com \
    --cc=markz@nvidia.com \
    --cc=maxime.ripard@free-electrons.com \
    --cc=s-guiriec@ti.com \
    --cc=stephane.marchesin@gmail.com \
    --cc=swarren@wwwdotorg.org \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=tom.gall@linaro.org \
    --cc=tomi.valkeinen@ti.com \
    --cc=vikas.sajjan@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.