Re: [PATCH RFC v2 02/15] [media] Add a V4L2 OF parser

2013-01-02 Thread Guennadi Liakhovetski
Hi Sylwester

Just one question to this one:

On Mon, 31 Dec 2012, Sylwester Nawrocki wrote:

 diff --git a/drivers/media/v4l2-core/v4l2-of.c 
 b/drivers/media/v4l2-core/v4l2-of.c
 new file mode 100644
 index 000..cdac04b
 --- /dev/null
 +++ b/drivers/media/v4l2-core/v4l2-of.c
 @@ -0,0 +1,249 @@
 +/*
 + * V4L2 OF binding parsing library
 + *
 + * Copyright (C) 2012 Renesas Electronics Corp.
 + * Author: Guennadi Liakhovetski g.liakhovet...@gmx.de
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of version 2 of the GNU General Public License as
 + * published by the Free Software Foundation.
 + */
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/of.h
 +#include linux/slab.h

Is slab.h really needed? I didn't have it in my version. Maybe you meant 
to include string.h for memset()?

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH RFC v2 02/15] [media] Add a V4L2 OF parser

2013-01-02 Thread Sylwester Nawrocki

Hi Guennadi,

On 01/02/2013 12:58 PM, Guennadi Liakhovetski wrote:

--- /dev/null
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -0,0 +1,249 @@
+/*
+ * V4L2 OF binding parsing library
+ *
+ * Copyright (C) 2012 Renesas Electronics Corp.
+ * Author: Guennadi Liakhovetskig.liakhovet...@gmx.de
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ */
+#includelinux/kernel.h
+#includelinux/module.h
+#includelinux/of.h
+#includelinux/slab.h


Is slab.h really needed? I didn't have it in my version. Maybe you meant
to include string.h for memset()?


I don't think it is needed, it looks like my mistake. I'll check it again
and replace it with string.h.

I've also noticed there are EXPORT_SYMBOL() missing for the first two 
functions

in this file. I'll fix it in next version.

---

Thanks,
Sylwester
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RFC v2 02/15] [media] Add a V4L2 OF parser

2012-12-31 Thread Sylwester Nawrocki
From: Guennadi Liakhovetski g.liakhovet...@gmx.de

Add a V4L2 OF parser, implementing bindings, documented in
Documentation/devicetree/bindings/media/video-interfaces.txt.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
---

Changes since previous version:
- merged into this one all my fixup patches from this series [1]:
  v4l2-of: Support variable length of data-lanes property
  v4l2-of: Add v4l2_of_parse_data_lanes() function
  v4l2-of: Corrected v4l2_of_parse_link() function declaration
  v4l2_of_parse_link() return value type is int, not void.
  v4l2-of: Replace remote property with remote-endpoint

[1] https://lkml.org/lkml/2012/12/10/464
---
 drivers/media/v4l2-core/Makefile  |3 +
 drivers/media/v4l2-core/v4l2-of.c |  249 +
 include/media/v4l2-of.h   |   79 
 3 files changed, 331 insertions(+)
 create mode 100644 drivers/media/v4l2-core/v4l2-of.c
 create mode 100644 include/media/v4l2-of.h

diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile
index c2d61d4..00f64d6 100644
--- a/drivers/media/v4l2-core/Makefile
+++ b/drivers/media/v4l2-core/Makefile
@@ -9,6 +9,9 @@ videodev-objs   :=  v4l2-dev.o v4l2-ioctl.o v4l2-device.o 
v4l2-fh.o \
 ifeq ($(CONFIG_COMPAT),y)
   videodev-objs += v4l2-compat-ioctl32.o
 endif
+ifeq ($(CONFIG_OF),y)
+  videodev-objs += v4l2-of.o
+endif
 
 obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-int-device.o
 obj-$(CONFIG_VIDEO_V4L2) += v4l2-common.o
diff --git a/drivers/media/v4l2-core/v4l2-of.c 
b/drivers/media/v4l2-core/v4l2-of.c
new file mode 100644
index 000..cdac04b
--- /dev/null
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -0,0 +1,249 @@
+/*
+ * V4L2 OF binding parsing library
+ *
+ * Copyright (C) 2012 Renesas Electronics Corp.
+ * Author: Guennadi Liakhovetski g.liakhovet...@gmx.de
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ */
+#include linux/kernel.h
+#include linux/module.h
+#include linux/of.h
+#include linux/slab.h
+#include linux/types.h
+
+#include media/v4l2-of.h
+
+/**
+ * v4l2_of_parse_mipi_csi2() - parse MIPI CSI-2 bus properties
+ * @node: pointer to endpoint device_node
+ * @endpoint: pointer to v4l2_of_endpoint data structure
+ *
+ * Return: 0 on success or negative error value otherwise.
+ */
+int v4l2_of_parse_mipi_csi2(const struct device_node *node,
+   struct v4l2_of_endpoint *endpoint)
+{
+   struct v4l2_of_mipi_csi2 *mipi_csi2 = endpoint-mipi_csi_2;
+   u32 data_lanes[ARRAY_SIZE(mipi_csi2-data_lanes)];
+   struct property *prop;
+   const __be32 *lane = NULL;
+   u32 v;
+   int i = 0;
+
+   prop = of_find_property(node, data-lanes, NULL);
+   if (!prop)
+   return -EINVAL;
+   do {
+   lane = of_prop_next_u32(prop, lane, data_lanes[i]);
+   } while (lane  i++  ARRAY_SIZE(data_lanes));
+
+   mipi_csi2-num_data_lanes = i;
+   while (i--)
+   mipi_csi2-data_lanes[i] = data_lanes[i];
+
+   if (!of_property_read_u32(node, clock-lanes, v))
+   mipi_csi2-clock_lane = v;
+
+   if (of_get_property(node, clock-noncontinuous, v))
+   endpoint-mbus_flags |= V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK;
+
+   return 0;
+}
+
+/**
+ * v4l2_of_parse_parallel_bus() - parse parallel bus properties
+ * @node: pointer to endpoint device_node
+ * @endpoint: pointer to v4l2_of_endpoint data structure
+ */
+void v4l2_of_parse_parallel_bus(const struct device_node *node,
+   struct v4l2_of_endpoint *endpoint)
+{
+   unsigned int flags = 0;
+   u32 v;
+
+   if (WARN_ON(!endpoint))
+   return;
+
+   if (!of_property_read_u32(node, hsync-active, v))
+   flags |= v ? V4L2_MBUS_HSYNC_ACTIVE_HIGH :
+   V4L2_MBUS_HSYNC_ACTIVE_LOW;
+
+   if (!of_property_read_u32(node, vsync-active, v))
+   flags |= v ? V4L2_MBUS_VSYNC_ACTIVE_HIGH :
+   V4L2_MBUS_VSYNC_ACTIVE_LOW;
+
+   if (!of_property_read_u32(node, pclk-sample, v))
+   flags |= v ? V4L2_MBUS_PCLK_SAMPLE_RISING :
+   V4L2_MBUS_PCLK_SAMPLE_FALLING;
+
+   if (!of_property_read_u32(node, field-even-active, v))
+   flags |= v ? V4L2_MBUS_FIELD_EVEN_HIGH :
+   V4L2_MBUS_FIELD_EVEN_LOW;
+   if (flags)
+   endpoint-mbus_type = V4L2_MBUS_PARALLEL;
+   else
+   endpoint-mbus_type = V4L2_MBUS_BT656;
+
+   if (!of_property_read_u32(node, data-active, v))
+   flags |= v ? V4L2_MBUS_DATA_ACTIVE_HIGH :
+   V4L2_MBUS_DATA_ACTIVE_LOW;
+
+   if (of_get_property(node, slave-mode, v))
+   flags |= V4L2_MBUS_SLAVE;
+
+   if