mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [RFC 1/1] i.MX: IPUv3: Add parallel display support
@ 2016-02-25 16:01 Philippe Leduc
  2016-02-29  6:50 ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Philippe Leduc @ 2016-02-25 16:01 UTC (permalink / raw)
  To: barebox; +Cc: Philippe Leduc

Add a driver compatible with "fsl,imx-parallel-display" in order
to enable parallel display with the i.MX IPUv3.

Signed-off-by: Philippe Leduc<ledphilippe@gmail.com>
--
diff --git a/drivers/video/imx-ipu-v3/Kconfig b/drivers/video/imx-ipu-v3/Kconfig
index b5ee4ef..5ec8031 100644
--- a/drivers/video/imx-ipu-v3/Kconfig
+++ b/drivers/video/imx-ipu-v3/Kconfig
@@ -15,5 +15,9 @@ config DRIVER_VIDEO_IMX_IPUV3_HDMI
 	bool "IPUv3 HDMI support"
 	depends on DRIVER_VIDEO_EDID
 	select OFDEVICE
+
+config DRIVER_VIDEO_IMX_IPUV3_PARALLEL
+	bool "IPUv3 parallel display support"
+	select OFDEVICE
 
 endif
diff --git a/drivers/video/imx-ipu-v3/Makefile b/drivers/video/imx-ipu-v3/Makefile
index 2bc0aec..1f68120 100644
--- a/drivers/video/imx-ipu-v3/Makefile
+++ b/drivers/video/imx-ipu-v3/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_DRIVER_VIDEO_IMX_IPUV3) += ipu-dp.o ipuv3-plane.o ipufb.o
 obj-$(CONFIG_DRIVER_VIDEO_IMX_IPUV3) += ipu-dc.o
 obj-$(CONFIG_DRIVER_VIDEO_IMX_IPUV3_LVDS) += imx-ldb.o
 obj-$(CONFIG_DRIVER_VIDEO_IMX_IPUV3_HDMI) += imx-hdmi.o
+obj-$(CONFIG_DRIVER_VIDEO_IMX_IPUV3_PARALLEL) += imx-pd.o
diff --git a/drivers/video/imx-ipu-v3/imx-pd.c b/drivers/video/imx-ipu-v3/imx-pd.c
new file mode 100644
index 0000000..acfeed2
--- /dev/null
+++ b/drivers/video/imx-ipu-v3/imx-pd.c
@@ -0,0 +1,111 @@
+/*
+ * i.MX drm driver - parallel display implementation
+ *
+ * Copyright (C) 2016 Philippe Leduc
+ *
+ * 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.
+ */
+
+#include <common.h>
+#include <fb.h>
+#include <io.h>
+#include <of_graph.h>
+#include <driver.h>
+#include <malloc.h>
+#include <errno.h>
+#include <init.h>
+#include <video/vpl.h>
+#include <linux/err.h>
+
+#include "imx-ipu-v3.h"
+
+struct imx_pd {
+	struct device_d *dev;
+	struct display_timings *timings;
+	u32 interface_pix_fmt;
+	struct vpl vpl;
+};
+
+
+
+static int imx_pd_ioctl(struct vpl *vpl, unsigned int port,
+		unsigned int cmd, void *data)
+{
+	struct imx_pd *imx_pd = container_of(vpl, struct imx_pd, vpl);
+	struct ipu_di_mode *mode;
+	struct display_timings *timings;
+
+	switch (cmd) {
+	case IMX_IPU_VPL_DI_MODE:
+		mode = data;
+
+		mode->di_clkflags = IPU_DI_CLKMODE_SYNC;
+		mode->interface_pix_fmt = imx_pd->interface_pix_fmt;
+		return 0;
+
+	case VPL_GET_VIDEOMODES:
+		timings = data;
+
+		timings->num_modes   = imx_pd->timings->num_modes;
+		timings->native_mode = imx_pd->timings->native_mode;
+		timings->modes       = imx_pd->timings->modes;
+		timings->edid        = NULL;
+		return 0;
+	}
+
+	return 0;
+}
+
+static int imx_pd_probe(struct device_d *dev)
+{
+	struct device_node *node = dev->device_node;
+	struct imx_pd *imx_pd;
+	const char *fmt;
+	int ret;
+
+	imx_pd = xzalloc(sizeof(*imx_pd));
+	imx_pd->dev = dev;
+
+	ret = of_property_read_string(node, "interface-pix-fmt", &fmt);
+	if (!ret) {
+		if (!strcmp(fmt, "rgb24"))
+			imx_pd->interface_pix_fmt = V4L2_PIX_FMT_RGB24;
+		else if (!strcmp(fmt, "rgb565"))
+			imx_pd->interface_pix_fmt = V4L2_PIX_FMT_RGB565;
+		else if (!strcmp(fmt, "bgr666"))
+			imx_pd->interface_pix_fmt = V4L2_PIX_FMT_BGR666;
+	}
+
+	imx_pd->timings = of_get_display_timings(node);
+
+	imx_pd->vpl.node = node;
+	imx_pd->vpl.ioctl = &imx_pd_ioctl;
+	ret = vpl_register(&imx_pd->vpl);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+static struct of_device_id imx_pd_dt_ids[] = {
+	{ .compatible = "fsl,imx-parallel-display", },
+	{ /* sentinel */ }
+};
+
+static struct driver_d imx_pd_driver = {
+	.probe			  = imx_pd_probe,
+	.of_compatible	= imx_pd_dt_ids,
+	.name				= "imx-parallel-display",
+};
+device_platform_driver(imx_pd_driver);
+
+MODULE_DESCRIPTION("i.MX Parallel display driver");
+MODULE_AUTHOR("Philippe Leduc");
+MODULE_LICENSE("GPL");

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC 1/1] i.MX: IPUv3: Add parallel display support
  2016-02-25 16:01 [RFC 1/1] i.MX: IPUv3: Add parallel display support Philippe Leduc
@ 2016-02-29  6:50 ` Sascha Hauer
  2016-03-14  8:48   ` Philippe Leduc
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2016-02-29  6:50 UTC (permalink / raw)
  To: Philippe Leduc; +Cc: barebox

Hi Philippe,

Looks good overall, some small points.

On Thu, Feb 25, 2016 at 05:01:20PM +0100, Philippe Leduc wrote:
> Add a driver compatible with "fsl,imx-parallel-display" in order
> to enable parallel display with the i.MX IPUv3.
> 
> Signed-off-by: Philippe Leduc<ledphilippe@gmail.com>
> --
> +struct imx_pd {
> +	struct device_d *dev;
> +	struct display_timings *timings;
> +	u32 interface_pix_fmt;
> +	struct vpl vpl;
> +};
> +
> +
> +

Plese drop multiple blank lines here.

> +static int imx_pd_ioctl(struct vpl *vpl, unsigned int port,
> +		unsigned int cmd, void *data)
> +{
> +	struct imx_pd *imx_pd = container_of(vpl, struct imx_pd, vpl);
> +	struct ipu_di_mode *mode;
> +	struct display_timings *timings;
> +
> +	switch (cmd) {
> +	case IMX_IPU_VPL_DI_MODE:
> +		mode = data;
> +
> +		mode->di_clkflags = IPU_DI_CLKMODE_SYNC;
> +		mode->interface_pix_fmt = imx_pd->interface_pix_fmt;
> +		return 0;
> +
> +	case VPL_GET_VIDEOMODES:
> +		timings = data;
> +
> +		timings->num_modes   = imx_pd->timings->num_modes;
> +		timings->native_mode = imx_pd->timings->native_mode;
> +		timings->modes       = imx_pd->timings->modes;
> +		timings->edid        = NULL;
> +		return 0;
> +	}
> +
> +	return 0;
> +}
> +
> +static int imx_pd_probe(struct device_d *dev)
> +{
> +	struct device_node *node = dev->device_node;
> +	struct imx_pd *imx_pd;
> +	const char *fmt;
> +	int ret;
> +
> +	imx_pd = xzalloc(sizeof(*imx_pd));
> +	imx_pd->dev = dev;
> +
> +	ret = of_property_read_string(node, "interface-pix-fmt", &fmt);
> +	if (!ret) {
> +		if (!strcmp(fmt, "rgb24"))
> +			imx_pd->interface_pix_fmt = V4L2_PIX_FMT_RGB24;
> +		else if (!strcmp(fmt, "rgb565"))
> +			imx_pd->interface_pix_fmt = V4L2_PIX_FMT_RGB565;
> +		else if (!strcmp(fmt, "bgr666"))
> +			imx_pd->interface_pix_fmt = V4L2_PIX_FMT_BGR666;

else? You should probably bail out with an error here.

> +	}
> +
> +	imx_pd->timings = of_get_display_timings(node);

You should check the result. If no display timing is found then barebox
will crash in the ioctl function.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC 1/1] i.MX: IPUv3: Add parallel display support
  2016-02-29  6:50 ` Sascha Hauer
@ 2016-03-14  8:48   ` Philippe Leduc
  0 siblings, 0 replies; 3+ messages in thread
From: Philippe Leduc @ 2016-03-14  8:48 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hi,

Thanks for the feedback, I'll fix that ASAP.

Regards,

--
Philippe LEDUC
ledphilippe@gmail.com


2016-02-29 7:50 GMT+01:00 Sascha Hauer <s.hauer@pengutronix.de>:
> Hi Philippe,
>
> Looks good overall, some small points.
>
> On Thu, Feb 25, 2016 at 05:01:20PM +0100, Philippe Leduc wrote:
>> Add a driver compatible with "fsl,imx-parallel-display" in order
>> to enable parallel display with the i.MX IPUv3.
>>
>> Signed-off-by: Philippe Leduc<ledphilippe@gmail.com>
>> --
>> +struct imx_pd {
>> +     struct device_d *dev;
>> +     struct display_timings *timings;
>> +     u32 interface_pix_fmt;
>> +     struct vpl vpl;
>> +};
>> +
>> +
>> +
>
> Plese drop multiple blank lines here.
>
>> +static int imx_pd_ioctl(struct vpl *vpl, unsigned int port,
>> +             unsigned int cmd, void *data)
>> +{
>> +     struct imx_pd *imx_pd = container_of(vpl, struct imx_pd, vpl);
>> +     struct ipu_di_mode *mode;
>> +     struct display_timings *timings;
>> +
>> +     switch (cmd) {
>> +     case IMX_IPU_VPL_DI_MODE:
>> +             mode = data;
>> +
>> +             mode->di_clkflags = IPU_DI_CLKMODE_SYNC;
>> +             mode->interface_pix_fmt = imx_pd->interface_pix_fmt;
>> +             return 0;
>> +
>> +     case VPL_GET_VIDEOMODES:
>> +             timings = data;
>> +
>> +             timings->num_modes   = imx_pd->timings->num_modes;
>> +             timings->native_mode = imx_pd->timings->native_mode;
>> +             timings->modes       = imx_pd->timings->modes;
>> +             timings->edid        = NULL;
>> +             return 0;
>> +     }
>> +
>> +     return 0;
>> +}
>> +
>> +static int imx_pd_probe(struct device_d *dev)
>> +{
>> +     struct device_node *node = dev->device_node;
>> +     struct imx_pd *imx_pd;
>> +     const char *fmt;
>> +     int ret;
>> +
>> +     imx_pd = xzalloc(sizeof(*imx_pd));
>> +     imx_pd->dev = dev;
>> +
>> +     ret = of_property_read_string(node, "interface-pix-fmt", &fmt);
>> +     if (!ret) {
>> +             if (!strcmp(fmt, "rgb24"))
>> +                     imx_pd->interface_pix_fmt = V4L2_PIX_FMT_RGB24;
>> +             else if (!strcmp(fmt, "rgb565"))
>> +                     imx_pd->interface_pix_fmt = V4L2_PIX_FMT_RGB565;
>> +             else if (!strcmp(fmt, "bgr666"))
>> +                     imx_pd->interface_pix_fmt = V4L2_PIX_FMT_BGR666;
>
> else? You should probably bail out with an error here.
>
>> +     }
>> +
>> +     imx_pd->timings = of_get_display_timings(node);
>
> You should check the result. If no display timing is found then barebox
> will crash in the ioctl function.
>
> Sascha
>
> --
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-03-14  8:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-25 16:01 [RFC 1/1] i.MX: IPUv3: Add parallel display support Philippe Leduc
2016-02-29  6:50 ` Sascha Hauer
2016-03-14  8:48   ` Philippe Leduc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox