Re: [Linux-kernel] [PATCH 03/13] media: adv7604: fix probe of ADV7611/7612

2015-07-24 Thread Ben Dooks
On 23/07/15 13:21, William Towle wrote:
 Prior to commit f862f57d ([media] media: i2c: ADV7604: Migrate to
 regmap), the local variable 'val' contained the combined register
 reads used in the chipset version ID test. Restore this expectation
 so that the comparison works as it used to.

Forgot the Signed-off-by: line here.

-- 
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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 v6 3/6] rcar_vin: add devicetree support

2014-07-25 Thread Ben Dooks
On 23/07/14 19:23, Guennadi Liakhovetski wrote:
 Add support for devicetree probe for the rcar-vin
 driver.
 
 Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
 [g.liakhovet...@gmx.de fix a typo, sort headers alphabetically]
 Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
 ---
 
 Ben, is this version ok?

From looking at it, it seems ok.

I have been off work ill for the last couple of days, so have only
just seen these. I will try and get these reviewed/tests as soon
as possible.

Is there a git branch I could merge with our devel tree?

-- 
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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: [Linux-kernel] [PATCH 0/4] rcar_vin: fix soc_camera WARN_ON() issues.

2014-07-07 Thread Ben Dooks
On 07/07/14 17:37, Ian Molton wrote:
 This patch series provides fixes that allow the rcar_vin driver to function
 without triggering dozens of warnings from the videobuf2 and soc_camera 
 layers.
 
 Patches 2/3 should probably be merged into a single, atomic change, although
 patch 2 does not make the existing situation /worse/ in and of itself.
 
 Patch 4 does not change the code logic, but is cleaner and less prone to
 breakage caused by furtutre modification. Also, more consistent with the use 
 of
 vb pointers elsewhere in the driver.
 
 Comments welcome!

You should have probably CC:d the original authors
as well as the linux-sh list and possibly Magnus and
Horms.

-- 
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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


rcar-vin soc-camera device tree updates

2014-07-05 Thread Ben Dooks
This is a new patch, with most of the issues from the previous
reviews now fixed. If there is anything that I have missed then
please let me know.

The only issues remaining is what to do about multiple subdevices
and/or multiple ports on drivers. I have yet to do either of erroring
out or supporting them. Feedback on this issue is welcome.

--
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 1/6] adv7180: Remove duplicate unregister call

2014-07-05 Thread Ben Dooks
From: Ian Molton ian.mol...@codethink.co.uk

This driver moved over to v4l2_async_unregister_subdev()
but still retained a call to v4l2_unregister_subdev(). Remove.

Signed-off-by: Ian Molton ian.mol...@codethink.co.uk
Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/media/i2c/adv7180.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index ac1cdbe..821178d 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -663,7 +663,6 @@ static int adv7180_remove(struct i2c_client *client)
if (state-irq  0)
free_irq(client-irq, state);
 
-   v4l2_device_unregister_subdev(sd);
adv7180_exit_controls(state);
mutex_destroy(state-mutex);
return 0;
-- 
2.0.0

--
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 2/6] rcar_vin: copy flags from pdata

2014-07-05 Thread Ben Dooks
The platform data is a single word, so simply copy
it into the device's private data structure than
keeping a copy of the pointer.

This will make changing to device-tree binding
easier as it is one allocation instead of two.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index e594230..7c4299d 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -126,13 +126,13 @@ struct rcar_vin_priv {
int sequence;
/* State of the VIN module in capturing mode */
enum rcar_vin_state state;
-   struct rcar_vin_platform_data   *pdata;
struct soc_camera_host  ici;
struct list_headcapture;
 #define MAX_BUFFER_NUM 3
struct vb2_buffer   *queue_buf[MAX_BUFFER_NUM];
struct vb2_alloc_ctx*alloc_ctx;
enum v4l2_field field;
+   unsigned intpdata_flags;
unsigned intvb_count;
unsigned intnr_hw_slots;
boolrequest_to_stop;
@@ -275,12 +275,12 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
break;
case V4L2_MBUS_FMT_YUYV8_2X8:
/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
-   vnmc |= priv-pdata-flags  RCAR_VIN_BT656 ?
+   vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
break;
case V4L2_MBUS_FMT_YUYV10_2X10:
/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
-   vnmc |= priv-pdata-flags  RCAR_VIN_BT656 ?
+   vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
break;
default:
@@ -797,7 +797,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device 
*icd)
/* Make choises, based on platform preferences */
if ((common_flags  V4L2_MBUS_HSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_HSYNC_ACTIVE_LOW)) {
-   if (priv-pdata-flags  RCAR_VIN_HSYNC_ACTIVE_LOW)
+   if (priv-pdata_flags  RCAR_VIN_HSYNC_ACTIVE_LOW)
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_LOW;
@@ -805,7 +805,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device 
*icd)
 
if ((common_flags  V4L2_MBUS_VSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_VSYNC_ACTIVE_LOW)) {
-   if (priv-pdata-flags  RCAR_VIN_VSYNC_ACTIVE_LOW)
+   if (priv-pdata_flags  RCAR_VIN_VSYNC_ACTIVE_LOW)
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_LOW;
@@ -1445,7 +1445,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
priv-ici.drv_name = dev_name(pdev-dev);
priv-ici.ops = rcar_vin_host_ops;
 
-   priv-pdata = pdata;
+   priv-pdata_flags = pdata-flags;
priv-chip = pdev-id_entry-driver_data;
spin_lock_init(priv-lock);
INIT_LIST_HEAD(priv-capture);
-- 
2.0.0

--
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 4/6] [V3] soc_camera: add support for dt binding soc_camera drivers

2014-07-05 Thread Ben Dooks
Add initial support for OF based soc-camera devices that may be used
by any of the soc-camera drivers. The driver itself will need converting
to use OF.

These changes allow the soc-camera driver to do the connecting of any
async capable v4l2 device to the soc-camera driver. This has currently
been tested on the Renesas Lager board.

It currently only supports one input device per driver as this seems
to be the standard connection for these devices.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---

Fixes since v1:
- Fix i2c mclk name compatible with other drivers
- Ensure of_node is put after use
Fixes since v2:
- Updated freeing of dyn-pdev as requested
- Coding style fixes
- Allocate initial resources in one go
---
 drivers/media/platform/soc_camera/soc_camera.c | 123 -
 1 file changed, 122 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index 7fec8cd..e25fc8e 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -36,6 +36,7 @@
 #include media/v4l2-common.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-dev.h
+#include media/v4l2-of.h
 #include media/videobuf-core.h
 #include media/videobuf2-core.h
 
@@ -1581,6 +1582,124 @@ static void scan_async_host(struct soc_camera_host *ici)
 #define scan_async_host(ici)   do {} while (0)
 #endif
 
+#ifdef CONFIG_OF
+
+struct soc_of_info {
+   struct soc_camera_async_subdev  sasd;
+   struct v4l2_async_subdev*subdevs[2];
+};
+
+static int soc_of_bind(struct soc_camera_host *ici,
+  struct device_node *ep,
+  struct device_node *remote)
+{
+   struct soc_camera_device *icd;
+   struct soc_camera_desc sdesc = {.host_desc.bus_id = ici-nr,};
+   struct soc_camera_async_client *sasc;
+   struct soc_of_info *info;
+   struct i2c_client *client;
+   char clk_name[V4L2_SUBDEV_NAME_SIZE];
+   int ret;
+
+   /* allocate a new subdev and add match info to it */
+   info = devm_kzalloc(ici-v4l2_dev.dev, sizeof(struct soc_of_info),
+   GFP_KERNEL);
+   if (!info)
+   return -ENOMEM;
+
+   info-sasd.asd.match.of.node = remote;
+   info-sasd.asd.match_type = V4L2_ASYNC_MATCH_OF;
+   info-subdevs[0] = info-sasd.asd;
+
+   /* Or shall this be managed by the soc-camera device? */
+   sasc = devm_kzalloc(ici-v4l2_dev.dev, sizeof(*sasc), GFP_KERNEL);
+   if (!sasc)
+   return -ENOMEM;
+
+   /* HACK: just need a != NULL */
+   sdesc.host_desc.board_info = ERR_PTR(-ENODATA);
+
+   ret = soc_camera_dyn_pdev(sdesc, sasc);
+   if (ret  0)
+   goto eallocpdev;
+
+   sasc-sensor = info-sasd.asd;
+
+   icd = soc_camera_add_pdev(sasc);
+   if (!icd) {
+   ret = -ENOMEM;
+   goto eaddpdev;
+   }
+
+   sasc-notifier.subdevs = info-subdevs;
+   sasc-notifier.num_subdevs = 1;
+   sasc-notifier.bound = soc_camera_async_bound;
+   sasc-notifier.unbind = soc_camera_async_unbind;
+   sasc-notifier.complete = soc_camera_async_complete;
+
+   icd-sasc = sasc;
+   icd-parent = ici-v4l2_dev.dev;
+
+   client = of_find_i2c_device_by_node(remote);
+
+   if (client)
+   snprintf(clk_name, sizeof(clk_name), %d-%04x,
+client-adapter-nr, client-addr);
+   else
+   snprintf(clk_name, sizeof(clk_name), of-%s,
+of_node_full_name(remote));
+
+   icd-clk = v4l2_clk_register(soc_camera_clk_ops, clk_name, mclk, 
icd);
+   if (IS_ERR(icd-clk)) {
+   ret = PTR_ERR(icd-clk);
+   goto eclkreg;
+   }
+
+   ret = v4l2_async_notifier_register(ici-v4l2_dev, sasc-notifier);
+   if (!ret)
+   return 0;
+eclkreg:
+   icd-clk = NULL;
+   platform_device_del(sasc-pdev);
+eaddpdev:
+   platform_device_put(sasc-pdev);
+eallocpdev:
+   devm_kfree(ici-v4l2_dev.dev, sasc);
+   dev_err(ici-v4l2_dev.dev, group probe failed: %d\n, ret);
+
+   return ret;
+}
+
+static void scan_of_host(struct soc_camera_host *ici)
+{
+   struct device_node *np = ici-v4l2_dev.dev-of_node;
+   struct device_node *epn = NULL;
+   struct device_node *ren;
+
+   while (true) {
+   epn = of_graph_get_next_endpoint(np, epn);
+   if (!epn)
+   break;
+
+   ren = of_graph_get_remote_port(epn);
+   if (!ren) {
+   pr_info(%s: no remote for %s\n,
+   __func__,  of_node_full_name(epn));
+   continue;
+   }
+
+   /* so we now have a remote node to connect */
+   soc_of_bind(ici, epn, ren-parent);
+
+   of_node_put(epn

[PATCH 6/6] [PATCH v2] ARM: lager: add vin1 node

2014-07-05 Thread Ben Dooks
Add device-tree for vin1 (composite video in) on the
lager board.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---

Fixes since v1:
- Whitespace fixes as suggested by Sergei
---
 arch/arm/boot/dts/r8a7790-lager.dts | 36 
 1 file changed, 36 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index 4805c9f..e00543b 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -214,6 +214,11 @@
renesas,groups = i2c2;
renesas,function = i2c2;
};
+
+   vin1_pins: vin {
+   renesas,groups = vin1_data8, vin1_clk;
+   renesas,function = vin1;
+   };
 };
 
 ether {
@@ -342,8 +347,39 @@
status = ok;
pinctrl-0 = i2c2_pins;
pinctrl-names = default;
+
+   composite-in@20 {
+   compatible = adi,adv7180;
+   reg = 0x20;
+   remote = vin1;
+
+   port {
+   adv7180: endpoint {
+   bus-width = 8;
+   remote-endpoint = vin1ep0;
+   };
+   };
+   };
 };
 
 i2c3  {
status = ok;
 };
+
+/* composite video input */
+vin1 {
+   pinctrl-0 = vin1_pins;
+   pinctrl-names = default;
+
+   status = ok;
+
+   port {
+   #address-cells = 1;
+   #size-cells = 0;
+
+   vin1ep0: endpoint {
+   remote-endpoint = adv7180;
+   bus-width = 8;
+   };
+   };
+};
-- 
2.0.0

--
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 5/6] r8a7790.dtsi: add vin[0-3] nodes

2014-07-05 Thread Ben Dooks
Add nodes for the four video input channels on the R8A7790.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790.dtsi | 36 
 1 file changed, 36 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
index 7ff2960..a6f083d 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -33,6 +33,10 @@
spi2 = msiof1;
spi3 = msiof2;
spi4 = msiof3;
+   vin0 = vin0;
+   vin1 = vin1;
+   vin2 = vin2;
+   vin3 = vin3;
};
 
cpus {
@@ -462,6 +466,38 @@
status = disabled;
};
 
+   vin0: vin@e6ef {
+   compatible = renesas,vin-r8a7790;
+   clocks = mstp8_clks R8A7790_CLK_VIN0;
+   reg = 0 0xe6ef 0 0x1000;
+   interrupts = 0 188 IRQ_TYPE_LEVEL_HIGH;
+   status = disabled;
+   };
+
+   vin1: vin@e6ef1000 {
+   compatible = renesas,vin-r8a7790;
+   clocks = mstp8_clks R8A7790_CLK_VIN1;
+   reg = 0 0xe6ef1000 0 0x1000;
+   interrupts = 0 189 IRQ_TYPE_LEVEL_HIGH;
+   status = disabled;
+   };
+
+   vin2: vin@e6ef2000 {
+   compatible = renesas,vin-r8a7790;
+   clocks = mstp8_clks R8A7790_CLK_VIN2;
+   reg = 0 0xe6ef2000 0 0x1000;
+   interrupts = 0 190 IRQ_TYPE_LEVEL_HIGH;
+   status = disabled;
+   };
+
+   vin3: vin@e6ef3000 {
+   compatible = renesas,vin-r8a7790;
+   clocks = mstp8_clks R8A7790_CLK_VIN3;
+   reg = 0 0xe6ef3000 0 0x1000;
+   interrupts = 0 191 IRQ_TYPE_LEVEL_HIGH;
+   status = disabled;
+   };
+
clocks {
#address-cells = 2;
#size-cells = 2;
-- 
2.0.0

--
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 3/6] rcar_vin: add devicetree support

2014-07-05 Thread Ben Dooks
Add support for devicetree probe for the rcar-vin
driver.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 .../devicetree/bindings/media/rcar_vin.txt | 86 ++
 drivers/media/platform/soc_camera/rcar_vin.c   | 72 --
 2 files changed, 151 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/rcar_vin.txt

diff --git a/Documentation/devicetree/bindings/media/rcar_vin.txt 
b/Documentation/devicetree/bindings/media/rcar_vin.txt
new file mode 100644
index 000..10fefa9
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/rcar_vin.txt
@@ -0,0 +1,86 @@
+Renesas RCar Video Input driver (rcar_vin)
+--
+
+The rcar_vin device provides video input capabilities for the Renesas R-Car
+family of devices. The current blocks are always slaves and suppot one input
+channel which can be either RGB, YUYV or BT656.
+
+ - compatible: Must be one of the following
+   - renesas,vin-r8a7791 for the R8A7791 device
+   - renesas,vin-r8a7790 for the R8A7790 device
+   - renesas,vin-r8a7779 for the R8A7779 device
+   - renesas,vin-r8a7778 for the R8A7778 device
+ - reg: the register base and size for the device registers
+ - interrupts: the interrupt for the device
+ - clocks: Reference to the parent clock
+
+Additionally, an alias named vinX will need to be created to specify
+which video input device this is.
+
+The per-board settings:
+ - port sub-node describing a single endpoint connected to the vin
+   as described in video-interfaces.txt[1]. Only the first one will
+   be considered as each vin interface has one input port.
+
+   These settings are used to work out video input format and widths
+   into the system.
+
+
+Device node example
+---
+
+   aliases {
+  vin0 = vin0;
+   };
+
+vin0: vin@0xe6ef {
+compatible = renesas,vin-r8a7790;
+clocks = mstp8_clks R8A7790_CLK_VIN0;
+reg = 0 0xe6ef 0 0x1000;
+interrupts = 0 188 IRQ_TYPE_LEVEL_HIGH;
+status = disabled;
+};
+
+Board setup example (vin1 composite video input)
+
+
+i2c2   {
+status = ok;
+pinctrl-0 = i2c2_pins;
+pinctrl-names = default;
+
+adv7180@020 {
+compatible = adi,adv7180;
+reg = 0x20;
+remote = vin1;
+
+port {
+adv7180: endpoint {
+bus-width = 8;
+remote-endpoint = vin1ep0;
+};
+};
+};
+};
+
+/* composite video input */
+vin1 {
+pinctrl-0 = vin1_pins;
+pinctrl-names = default;
+
+status = ok;
+
+port {
+#address-cells = 1;
+#size-cells = 0;
+
+vin1ep0: endpoint {
+remote-endpoint = adv7180;
+bus-width = 8;
+};
+};
+};
+
+
+
+[1] video-interfaces.txt common video media interface
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 7c4299d..eb196ef 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -24,6 +24,8 @@
 #include linux/pm_runtime.h
 #include linux/slab.h
 #include linux/videodev2.h
+#include linux/of.h
+#include linux/of_device.h
 
 #include media/soc_camera.h
 #include media/soc_mediabus.h
@@ -32,6 +34,7 @@
 #include media/v4l2-device.h
 #include media/v4l2-mediabus.h
 #include media/v4l2-subdev.h
+#include media/v4l2-of.h
 #include media/videobuf2-dma-contig.h
 
 #include soc_scale_crop.h
@@ -1390,6 +1393,17 @@ static struct soc_camera_host_ops rcar_vin_host_ops = {
.init_videobuf2 = rcar_vin_init_videobuf2,
 };
 
+#ifdef CONFIG_OF
+static struct of_device_id rcar_vin_of_table[] = {
+   { .compatible = renesas,vin-r8a7791, .data = (void *)RCAR_GEN2 },
+   { .compatible = renesas,vin-r8a7790, .data = (void *)RCAR_GEN2 },
+   { .compatible = renesas,vin-r8a7779, .data = (void *)RCAR_H1 },
+   { .compatible = renesas,vin-r8a7778, .data = (void *)RCAR_M1 },
+   { },
+};
+MODULE_DEVICE_TABLE(of, rcar_vin_of_table);
+#endif
+
 static struct platform_device_id rcar_vin_id_table[] = {
{ r8a7791-vin,  RCAR_GEN2 },
{ r8a7790-vin,  RCAR_GEN2 },
@@ -1402,15 +1416,52 @@ MODULE_DEVICE_TABLE(platform, rcar_vin_id_table);
 
 static int rcar_vin_probe(struct platform_device *pdev)
 {
+   const struct of_device_id *match = NULL;
struct rcar_vin_priv *priv;
struct resource *mem;
struct rcar_vin_platform_data *pdata;
+   unsigned int pdata_flags;
int irq, ret;
 
-   pdata = pdev-dev.platform_data;
-   if (!pdata || !pdata-flags) {
-   dev_err(pdev-dev

Re: [PATCH 7/9] soc_camera: add support for dt binding soc_camera drivers

2014-06-23 Thread Ben Dooks
On 19/06/14 08:28, Guennadi Liakhovetski wrote:
 Hi Ben,
 
 Thanks for an update.
 
 On Sun, 15 Jun 2014, Ben Dooks wrote:
 
 Add initial support for OF based soc-camera devices that may be used
 by any of the soc-camera drivers. The driver itself will need converting
 to use OF.

 These changes allow the soc-camera driver to do the connecting of any
 async capable v4l2 device to the soc-camera driver. This has currently
 been tested on the Renesas Lager board.

 It currently only supports one input device per driver as this seems
 to be the standard connection for these devices.
 
 You ignored most of my comments to the previous version of this your 
 patch. Please, revisit.

Sorry, will go and have a look over this tomorrow.


-- 
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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 1/2] r8a7790.dtsi: add vin[0-3] nodes

2014-06-23 Thread Ben Dooks
Add nodes for the four video input channels on the R8A7790.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790.dtsi | 36 
 1 file changed, 36 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
index 7ff2960..a6f083d 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -33,6 +33,10 @@
spi2 = msiof1;
spi3 = msiof2;
spi4 = msiof3;
+   vin0 = vin0;
+   vin1 = vin1;
+   vin2 = vin2;
+   vin3 = vin3;
};
 
cpus {
@@ -462,6 +466,38 @@
status = disabled;
};
 
+   vin0: vin@e6ef {
+   compatible = renesas,vin-r8a7790;
+   clocks = mstp8_clks R8A7790_CLK_VIN0;
+   reg = 0 0xe6ef 0 0x1000;
+   interrupts = 0 188 IRQ_TYPE_LEVEL_HIGH;
+   status = disabled;
+   };
+
+   vin1: vin@e6ef1000 {
+   compatible = renesas,vin-r8a7790;
+   clocks = mstp8_clks R8A7790_CLK_VIN1;
+   reg = 0 0xe6ef1000 0 0x1000;
+   interrupts = 0 189 IRQ_TYPE_LEVEL_HIGH;
+   status = disabled;
+   };
+
+   vin2: vin@e6ef2000 {
+   compatible = renesas,vin-r8a7790;
+   clocks = mstp8_clks R8A7790_CLK_VIN2;
+   reg = 0 0xe6ef2000 0 0x1000;
+   interrupts = 0 190 IRQ_TYPE_LEVEL_HIGH;
+   status = disabled;
+   };
+
+   vin3: vin@e6ef3000 {
+   compatible = renesas,vin-r8a7790;
+   clocks = mstp8_clks R8A7790_CLK_VIN3;
+   reg = 0 0xe6ef3000 0 0x1000;
+   interrupts = 0 191 IRQ_TYPE_LEVEL_HIGH;
+   status = disabled;
+   };
+
clocks {
#address-cells = 2;
#size-cells = 2;
-- 
2.0.0

--
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


resend: device tree updates for r8a7790 vin

2014-06-23 Thread Ben Dooks
I've gone through and hopefully cleaned up Sergei's issues.

Is there any chance Simon could queue these in his tree?

--
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 2/2] [PATCH v2] ARM: lager: add vin1 node

2014-06-23 Thread Ben Dooks
Add device-tree for vin1 (composite video in) on the
lager board.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---

Fixes since v1:
- Whitespace fixes as suggested by Sergei
---
 arch/arm/boot/dts/r8a7790-lager.dts | 36 
 1 file changed, 36 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index 4805c9f..e00543b 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -214,6 +214,11 @@
renesas,groups = i2c2;
renesas,function = i2c2;
};
+
+   vin1_pins: vin {
+   renesas,groups = vin1_data8, vin1_clk;
+   renesas,function = vin1;
+   };
 };
 
 ether {
@@ -342,8 +347,39 @@
status = ok;
pinctrl-0 = i2c2_pins;
pinctrl-names = default;
+
+   composite-in@20 {
+   compatible = adi,adv7180;
+   reg = 0x20;
+   remote = vin1;
+
+   port {
+   adv7180: endpoint {
+   bus-width = 8;
+   remote-endpoint = vin1ep0;
+   };
+   };
+   };
 };
 
 i2c3  {
status = ok;
 };
+
+/* composite video input */
+vin1 {
+   pinctrl-0 = vin1_pins;
+   pinctrl-names = default;
+
+   status = ok;
+
+   port {
+   #address-cells = 1;
+   #size-cells = 0;
+
+   vin1ep0: endpoint {
+   remote-endpoint = adv7180;
+   bus-width = 8;
+   };
+   };
+};
-- 
2.0.0

--
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 2/9] ARM: lager: add i2c1, i2c2 pins

2014-06-18 Thread Ben Dooks
On 16/06/14 13:33, Sergei Shtylyov wrote:
 Hello.
 
 On 06/15/2014 11:56 PM, Ben Dooks wrote:
 
 Add pinctrl definitions for i2c1 and i2c2 busses on the Lager board
 to ensure these are setup correctly at initialisation time. The i2c0
 and i2c3 busses are connected to single function pins.
 
 Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
 
Likewise, this as been already merged by Simon.

Ah, they had not been merged when I took the branch for this around
-rc8 time. I will look at changing the necessary bits for the vin
in the DT and re-sub them as a new series for Simon to look at merging.


-- 
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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: soc_camera and device-tree

2014-06-15 Thread Ben Dooks
On 14/06/14 21:30, Robert Jarzmik wrote:
 Hi Guennadi,
 
 I'm slowly converting all of my drivers to device-tree.
 In the process, I met ... soc_camera.
 
 I converted mt9m111.c and pxa_camera.c, but now I need the linking
 soc_camera. And I don't have a clear idea on how it should be done.
 
 I was thinking of having soc_camera_pdrv_probe() changed, to handle
 device-tree. What bothers me a bit is that amongst the needed data for me are
 the bus_id and a soc_camera_subdev_desc. I was thinking that this could be
 expressed in device-tree like :

I will put a new series out today for review.

-- 
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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 2/9] ARM: lager: add i2c1, i2c2 pins

2014-06-15 Thread Ben Dooks
Add pinctrl definitions for i2c1 and i2c2 busses on the Lager board
to ensure these are setup correctly at initialisation time. The i2c0
and i2c3 busses are connected to single function pins.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790-lager.dts | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index 8617755..4805c9f 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -204,6 +204,16 @@
 msiof1_tx;
renesas,function = msiof1;
};
+
+   i2c1_pins: i2c1 {
+   renesas,groups = i2c1;
+   renesas,function = i2c1;
+   };
+
+   i2c2_pins: i2c2 {
+   renesas,groups = i2c2;
+   renesas,function = i2c2;
+   };
 };
 
 ether {
@@ -324,10 +334,14 @@
 
 i2c1  {
status = ok;
+   pinctrl-0 = i2c1_pins;
+   pinctrl-names = default;
 };
 
 i2c2  {
status = ok;
+   pinctrl-0 = i2c2_pins;
+   pinctrl-names = default;
 };
 
 i2c3  {
-- 
2.0.0

--
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 1/9] ARM: lager: enable i2c devices

2014-06-15 Thread Ben Dooks
Add i2c0, i2c1, i2c2 and i2c3 nodes to the Lager reference device tree as
these busses all have devices on them that can be probed even if they
are no drivers yet.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790-lager.dts | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index dd2fe46..8617755 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -317,3 +317,19 @@
cd-gpios = gpio3 22 GPIO_ACTIVE_LOW;
status = okay;
 };
+
+i2c0  {
+   status = ok;
+};
+
+i2c1  {
+   status = ok;
+};
+
+i2c2  {
+   status = ok;
+};
+
+i2c3  {
+   status = ok;
+};
-- 
2.0.0

--
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 4/9] adv7180: add of match table

2014-06-15 Thread Ben Dooks
Add a proper of match id for use when the device is being bound via
device tree, to avoid having to use the i2c old-style binding of the
device.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---

Since original submission:
- Fixed of_match_table typo
---
 drivers/media/i2c/adv7180.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 821178d..46e47a0 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -25,6 +25,7 @@
 #include linux/interrupt.h
 #include linux/i2c.h
 #include linux/slab.h
+#include linux/of.h
 #include media/v4l2-ioctl.h
 #include linux/videodev2.h
 #include media/v4l2-device.h
@@ -710,11 +711,21 @@ static SIMPLE_DEV_PM_OPS(adv7180_pm_ops, adv7180_suspend, 
adv7180_resume);
 
 MODULE_DEVICE_TABLE(i2c, adv7180_id);
 
+#ifdef CONFIG_OF
+static const struct of_device_id adv7180_of_id[] = {
+   { .compatible = adi,adv7180, },
+   { },
+};
+
+MODULE_DEVICE_TABLE(of, adv7180_of_id)
+#endif
+
 static struct i2c_driver adv7180_driver = {
.driver = {
   .owner = THIS_MODULE,
   .name = KBUILD_MODNAME,
   .pm = ADV7180_PM_OPS,
+  .of_match_table = of_match_ptr(adv7180_of_id),
   },
.probe = adv7180_probe,
.remove = adv7180_remove,
-- 
2.0.0

--
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


RFC: new soc_camera/rcar_vin patch series

2014-06-15 Thread Ben Dooks
This is a new series for the rcar_vin and soc_camera layer
to support using OF.

It should incorporate most of the feedback from the previous
series, but please let me know if there's anything missed. As
a note, we have skipped over multiple eps for this release as
there are few scenarios for the driver.

Testing/feedback welcome.

--
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 6/9] rcar_vin: add devicetree support

2014-06-15 Thread Ben Dooks
Add support for devicetree probe for the rcar-vin
driver.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 .../devicetree/bindings/media/rcar_vin.txt | 86 ++
 drivers/media/platform/soc_camera/rcar_vin.c   | 72 --
 2 files changed, 151 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/rcar_vin.txt

diff --git a/Documentation/devicetree/bindings/media/rcar_vin.txt 
b/Documentation/devicetree/bindings/media/rcar_vin.txt
new file mode 100644
index 000..10fefa9
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/rcar_vin.txt
@@ -0,0 +1,86 @@
+Renesas RCar Video Input driver (rcar_vin)
+--
+
+The rcar_vin device provides video input capabilities for the Renesas R-Car
+family of devices. The current blocks are always slaves and suppot one input
+channel which can be either RGB, YUYV or BT656.
+
+ - compatible: Must be one of the following
+   - renesas,vin-r8a7791 for the R8A7791 device
+   - renesas,vin-r8a7790 for the R8A7790 device
+   - renesas,vin-r8a7779 for the R8A7779 device
+   - renesas,vin-r8a7778 for the R8A7778 device
+ - reg: the register base and size for the device registers
+ - interrupts: the interrupt for the device
+ - clocks: Reference to the parent clock
+
+Additionally, an alias named vinX will need to be created to specify
+which video input device this is.
+
+The per-board settings:
+ - port sub-node describing a single endpoint connected to the vin
+   as described in video-interfaces.txt[1]. Only the first one will
+   be considered as each vin interface has one input port.
+
+   These settings are used to work out video input format and widths
+   into the system.
+
+
+Device node example
+---
+
+   aliases {
+  vin0 = vin0;
+   };
+
+vin0: vin@0xe6ef {
+compatible = renesas,vin-r8a7790;
+clocks = mstp8_clks R8A7790_CLK_VIN0;
+reg = 0 0xe6ef 0 0x1000;
+interrupts = 0 188 IRQ_TYPE_LEVEL_HIGH;
+status = disabled;
+};
+
+Board setup example (vin1 composite video input)
+
+
+i2c2   {
+status = ok;
+pinctrl-0 = i2c2_pins;
+pinctrl-names = default;
+
+adv7180@020 {
+compatible = adi,adv7180;
+reg = 0x20;
+remote = vin1;
+
+port {
+adv7180: endpoint {
+bus-width = 8;
+remote-endpoint = vin1ep0;
+};
+};
+};
+};
+
+/* composite video input */
+vin1 {
+pinctrl-0 = vin1_pins;
+pinctrl-names = default;
+
+status = ok;
+
+port {
+#address-cells = 1;
+#size-cells = 0;
+
+vin1ep0: endpoint {
+remote-endpoint = adv7180;
+bus-width = 8;
+};
+};
+};
+
+
+
+[1] video-interfaces.txt common video media interface
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 7c4299d..eb196ef 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -24,6 +24,8 @@
 #include linux/pm_runtime.h
 #include linux/slab.h
 #include linux/videodev2.h
+#include linux/of.h
+#include linux/of_device.h
 
 #include media/soc_camera.h
 #include media/soc_mediabus.h
@@ -32,6 +34,7 @@
 #include media/v4l2-device.h
 #include media/v4l2-mediabus.h
 #include media/v4l2-subdev.h
+#include media/v4l2-of.h
 #include media/videobuf2-dma-contig.h
 
 #include soc_scale_crop.h
@@ -1390,6 +1393,17 @@ static struct soc_camera_host_ops rcar_vin_host_ops = {
.init_videobuf2 = rcar_vin_init_videobuf2,
 };
 
+#ifdef CONFIG_OF
+static struct of_device_id rcar_vin_of_table[] = {
+   { .compatible = renesas,vin-r8a7791, .data = (void *)RCAR_GEN2 },
+   { .compatible = renesas,vin-r8a7790, .data = (void *)RCAR_GEN2 },
+   { .compatible = renesas,vin-r8a7779, .data = (void *)RCAR_H1 },
+   { .compatible = renesas,vin-r8a7778, .data = (void *)RCAR_M1 },
+   { },
+};
+MODULE_DEVICE_TABLE(of, rcar_vin_of_table);
+#endif
+
 static struct platform_device_id rcar_vin_id_table[] = {
{ r8a7791-vin,  RCAR_GEN2 },
{ r8a7790-vin,  RCAR_GEN2 },
@@ -1402,15 +1416,52 @@ MODULE_DEVICE_TABLE(platform, rcar_vin_id_table);
 
 static int rcar_vin_probe(struct platform_device *pdev)
 {
+   const struct of_device_id *match = NULL;
struct rcar_vin_priv *priv;
struct resource *mem;
struct rcar_vin_platform_data *pdata;
+   unsigned int pdata_flags;
int irq, ret;
 
-   pdata = pdev-dev.platform_data;
-   if (!pdata || !pdata-flags) {
-   dev_err(pdev-dev

[PATCH 3/9] adv7180: Remove duplicate unregister call

2014-06-15 Thread Ben Dooks
From: Ian Molton ian.mol...@codethink.co.uk

This driver moved over to v4l2_async_unregister_subdev()
but still retained a call to v4l2_unregister_subdev(). Remove.

Signed-off-by: Ian Molton ian.mol...@codethink.co.uk
Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/media/i2c/adv7180.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index ac1cdbe..821178d 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -663,7 +663,6 @@ static int adv7180_remove(struct i2c_client *client)
if (state-irq  0)
free_irq(client-irq, state);
 
-   v4l2_device_unregister_subdev(sd);
adv7180_exit_controls(state);
mutex_destroy(state-mutex);
return 0;
-- 
2.0.0

--
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 5/9] rcar_vin: copy flags from pdata

2014-06-15 Thread Ben Dooks
The platform data is a single word, so simply copy
it into the device's private data structure than
keeping a copy of the pointer.

This will make changing to device-tree binding
easier as it is one allocation instead of two.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index e594230..7c4299d 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -126,13 +126,13 @@ struct rcar_vin_priv {
int sequence;
/* State of the VIN module in capturing mode */
enum rcar_vin_state state;
-   struct rcar_vin_platform_data   *pdata;
struct soc_camera_host  ici;
struct list_headcapture;
 #define MAX_BUFFER_NUM 3
struct vb2_buffer   *queue_buf[MAX_BUFFER_NUM];
struct vb2_alloc_ctx*alloc_ctx;
enum v4l2_field field;
+   unsigned intpdata_flags;
unsigned intvb_count;
unsigned intnr_hw_slots;
boolrequest_to_stop;
@@ -275,12 +275,12 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
break;
case V4L2_MBUS_FMT_YUYV8_2X8:
/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
-   vnmc |= priv-pdata-flags  RCAR_VIN_BT656 ?
+   vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
break;
case V4L2_MBUS_FMT_YUYV10_2X10:
/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
-   vnmc |= priv-pdata-flags  RCAR_VIN_BT656 ?
+   vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
break;
default:
@@ -797,7 +797,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device 
*icd)
/* Make choises, based on platform preferences */
if ((common_flags  V4L2_MBUS_HSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_HSYNC_ACTIVE_LOW)) {
-   if (priv-pdata-flags  RCAR_VIN_HSYNC_ACTIVE_LOW)
+   if (priv-pdata_flags  RCAR_VIN_HSYNC_ACTIVE_LOW)
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_LOW;
@@ -805,7 +805,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device 
*icd)
 
if ((common_flags  V4L2_MBUS_VSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_VSYNC_ACTIVE_LOW)) {
-   if (priv-pdata-flags  RCAR_VIN_VSYNC_ACTIVE_LOW)
+   if (priv-pdata_flags  RCAR_VIN_VSYNC_ACTIVE_LOW)
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_LOW;
@@ -1445,7 +1445,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
priv-ici.drv_name = dev_name(pdev-dev);
priv-ici.ops = rcar_vin_host_ops;
 
-   priv-pdata = pdata;
+   priv-pdata_flags = pdata-flags;
priv-chip = pdev-id_entry-driver_data;
spin_lock_init(priv-lock);
INIT_LIST_HEAD(priv-capture);
-- 
2.0.0

--
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 7/9] soc_camera: add support for dt binding soc_camera drivers

2014-06-15 Thread Ben Dooks
Add initial support for OF based soc-camera devices that may be used
by any of the soc-camera drivers. The driver itself will need converting
to use OF.

These changes allow the soc-camera driver to do the connecting of any
async capable v4l2 device to the soc-camera driver. This has currently
been tested on the Renesas Lager board.

It currently only supports one input device per driver as this seems
to be the standard connection for these devices.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---

Fixes since v1:
- Fix i2c mclk name compatible with other drivers
- Ensure of_node is put after use
---
 drivers/media/platform/soc_camera/soc_camera.c | 120 -
 1 file changed, 119 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index 7fec8cd..eda67d7 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -36,6 +36,7 @@
 #include media/v4l2-common.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-dev.h
+#include media/v4l2-of.h
 #include media/videobuf-core.h
 #include media/videobuf2-core.h
 
@@ -1581,6 +1582,121 @@ static void scan_async_host(struct soc_camera_host *ici)
 #define scan_async_host(ici)   do {} while (0)
 #endif
 
+#ifdef CONFIG_OF
+static int soc_of_bind(struct soc_camera_host *ici,
+  struct device_node *ep,
+  struct device_node *remote)
+{
+   struct soc_camera_device *icd;
+   struct soc_camera_desc sdesc = {.host_desc.bus_id = ici-nr,};
+   struct soc_camera_async_client *sasc;
+   struct soc_camera_async_subdev *sasd;
+   struct v4l2_async_subdev **asd_array;
+   struct i2c_client *client;
+   char clk_name[V4L2_SUBDEV_NAME_SIZE];
+   int ret;
+
+   /* allocate a new subdev and add match info to it */
+   sasd = devm_kzalloc(ici-v4l2_dev.dev, sizeof(*sasd), GFP_KERNEL);
+   if (!sasd)
+   return -ENOMEM;
+
+   asd_array = devm_kzalloc(ici-v4l2_dev.dev,
+sizeof(struct v4l2_async_subdev **),
+GFP_KERNEL);
+   if (!asd_array)
+   return -ENOMEM;
+
+   sasd-asd.match.of.node = remote;
+   sasd-asd.match_type = V4L2_ASYNC_MATCH_OF;
+   asd_array[0] = sasd-asd;
+
+   /* Or shall this be managed by the soc-camera device? */
+   sasc = devm_kzalloc(ici-v4l2_dev.dev, sizeof(*sasc), GFP_KERNEL);
+   if (!sasc)
+   return -ENOMEM;
+
+   /* HACK: just need a != NULL */
+   sdesc.host_desc.board_info = ERR_PTR(-ENODATA);
+
+   ret = soc_camera_dyn_pdev(sdesc, sasc);
+   if (ret  0)
+   return ret;
+
+   sasc-sensor = sasd-asd;
+
+   icd = soc_camera_add_pdev(sasc);
+   if (!icd) {
+   platform_device_put(sasc-pdev);
+   return -ENOMEM;
+   }
+
+   sasc-notifier.subdevs = asd_array;
+   sasc-notifier.num_subdevs = 1;
+   sasc-notifier.bound = soc_camera_async_bound;
+   sasc-notifier.unbind = soc_camera_async_unbind;
+   sasc-notifier.complete = soc_camera_async_complete;
+
+   icd-sasc = sasc;
+   icd-parent = ici-v4l2_dev.dev;
+
+   client = of_find_i2c_device_by_node(remote);
+
+   if (client)
+   snprintf(clk_name, sizeof(clk_name), %d-%04x,
+client-adapter-nr, client-addr);
+   else
+   snprintf(clk_name, sizeof(clk_name), of-%s,
+of_node_full_name(remote));
+
+   icd-clk = v4l2_clk_register(soc_camera_clk_ops, clk_name, mclk, 
icd);
+   if (IS_ERR(icd-clk)) {
+   ret = PTR_ERR(icd-clk);
+   goto eclkreg;
+   }
+
+   ret = v4l2_async_notifier_register(ici-v4l2_dev, sasc-notifier);
+   if (!ret)
+   return 0;
+
+eclkreg:
+   icd-clk = NULL;
+   platform_device_unregister(sasc-pdev);
+   dev_err(ici-v4l2_dev.dev, group probe failed: %d\n, ret);
+
+   return ret;
+}
+
+static inline void scan_of_host(struct soc_camera_host *ici)
+{
+   struct device_node *np = ici-v4l2_dev.dev-of_node;
+   struct device_node *epn = NULL;
+   struct device_node *ren;
+
+   while (true) {
+   epn = of_graph_get_next_endpoint(np, epn);
+   if (!epn)
+   break;
+
+   ren = of_graph_get_remote_port(epn);
+   if (!ren) {
+   pr_info(%s: no remote for %s\n,
+   __func__,  of_node_full_name(epn));
+   continue;
+   }
+
+   /* so we now have a remote node to connect */
+   soc_of_bind(ici, epn, ren-parent);
+
+   of_node_put(epn);
+   of_node_put(ren);
+   }
+}
+
+#else
+static inline void scan_of_host(struct soc_camera_host *ici) { }
+#endif

[PATCH 9/9] ARM: lager: add vin1 node

2014-06-15 Thread Ben Dooks
Add device-tree for vin1 (composite video in) on the
lager board.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790-lager.dts | 38 +
 1 file changed, 38 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index 4805c9f..8ecb294 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -214,6 +214,11 @@
renesas,groups = i2c2;
renesas,function = i2c2;
};
+
+   vin1_pins: vin {
+   renesas,groups = vin1_data8, vin1_clk;
+   renesas,function = vin1;
+   };
 };
 
 ether {
@@ -342,8 +347,41 @@
status = ok;
pinctrl-0 = i2c2_pins;
pinctrl-names = default;
+
+   composite-in@20 {
+   compatible = adi,adv7180;
+   reg = 0x20;
+   remote = vin1;
+
+   port {
+   adv7180: endpoint {
+   bus-width = 8;
+   remote-endpoint = vin1ep0;
+   };
+   };
+   };
+
 };
 
 i2c3  {
status = ok;
 };
+
+/* composite video input */
+vin1 {
+   pinctrl-0 = vin1_pins;
+   pinctrl-names = default;
+
+   status = ok;
+
+   port {
+   #address-cells = 1;
+   #size-cells = 0;
+
+   vin1ep0: endpoint {
+   remote-endpoint = adv7180;
+   bus-width = 8;
+   };
+   };
+};
+
-- 
2.0.0

--
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 8/9] r8a7790.dtsi: add vin[0-3] nodes

2014-06-15 Thread Ben Dooks
Add nodes for the four video input channels on the R8A7790.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790.dtsi | 36 
 1 file changed, 36 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
index 7ff2960..a6f083d 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -33,6 +33,10 @@
spi2 = msiof1;
spi3 = msiof2;
spi4 = msiof3;
+   vin0 = vin0;
+   vin1 = vin1;
+   vin2 = vin2;
+   vin3 = vin3;
};
 
cpus {
@@ -462,6 +466,38 @@
status = disabled;
};
 
+   vin0: vin@e6ef {
+   compatible = renesas,vin-r8a7790;
+   clocks = mstp8_clks R8A7790_CLK_VIN0;
+   reg = 0 0xe6ef 0 0x1000;
+   interrupts = 0 188 IRQ_TYPE_LEVEL_HIGH;
+   status = disabled;
+   };
+
+   vin1: vin@e6ef1000 {
+   compatible = renesas,vin-r8a7790;
+   clocks = mstp8_clks R8A7790_CLK_VIN1;
+   reg = 0 0xe6ef1000 0 0x1000;
+   interrupts = 0 189 IRQ_TYPE_LEVEL_HIGH;
+   status = disabled;
+   };
+
+   vin2: vin@e6ef2000 {
+   compatible = renesas,vin-r8a7790;
+   clocks = mstp8_clks R8A7790_CLK_VIN2;
+   reg = 0 0xe6ef2000 0 0x1000;
+   interrupts = 0 190 IRQ_TYPE_LEVEL_HIGH;
+   status = disabled;
+   };
+
+   vin3: vin@e6ef3000 {
+   compatible = renesas,vin-r8a7790;
+   clocks = mstp8_clks R8A7790_CLK_VIN3;
+   reg = 0 0xe6ef3000 0 0x1000;
+   interrupts = 0 191 IRQ_TYPE_LEVEL_HIGH;
+   status = disabled;
+   };
+
clocks {
#address-cells = 2;
#size-cells = 2;
-- 
2.0.0

--
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: soc_camera and device-tree

2014-06-15 Thread Ben Dooks
On 14/06/14 21:58, Guennadi Liakhovetski wrote:
 Hi Robert,
 
 On Sat, 14 Jun 2014, Robert Jarzmik wrote:
 
 Hi Guennadi,

 I'm slowly converting all of my drivers to device-tree.
 In the process, I met ... soc_camera.

 I converted mt9m111.c and pxa_camera.c, but now I need the linking
 soc_camera. And I don't have a clear idea on how it should be done.

New series is on the list. Let me know if there are any issues.

I am pushing the series up to git.codethink.co.uk.

http://git.codethink.co.uk/linux.git bjdooks/v315/vin-of

-- 
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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: [Linux-kernel] RFC: new soc_camera/rcar_vin patch series

2014-06-15 Thread Ben Dooks
On 15/06/14 20:56, Ben Dooks wrote:
 This is a new series for the rcar_vin and soc_camera layer
 to support using OF.
 
 It should incorporate most of the feedback from the previous
 series, but please let me know if there's anything missed. As
 a note, we have skipped over multiple eps for this release as
 there are few scenarios for the driver.
 
 Testing/feedback welcome.

Forgot, pushed to:

http://git.codethink.co.uk/linux.git bjdooks/v315/vin-of


-- 
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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: [GIT PULL for 3.16-rc1] updates and DT support for adv7604

2014-06-06 Thread Ben Dooks
On 05/06/14 13:55, Mauro Carvalho Chehab wrote:
 Linus,
 
 Please pull from:
   git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 
 topic/adv76xx
 
 For adv7604 driver updates, including DT support.

Can we use the adv7611 for the adv7612 with these?

-- 
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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: [GIT PULL for 3.16-rc1] updates and DT support for adv7604

2014-06-06 Thread Ben Dooks
On 06/06/14 16:51, Lars-Peter Clausen wrote:
 On 06/06/2014 05:49 PM, Ben Dooks wrote:
 On 05/06/14 13:55, Mauro Carvalho Chehab wrote:
 Linus,

 Please pull from:
git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
 topic/adv76xx

 For adv7604 driver updates, including DT support.

 Can we use the adv7611 for the adv7612 with these?

 
 You can, except that you won't be able to use the second HDMI in. But it
 should be fairly trivial to add that.

Thanks, we're going to try the rcar_vin driver and the HDMI in on the
Lager board next week.

-- 
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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 v2 48/48] adv7604: Add endpoint properties to DT bindings

2014-04-17 Thread Ben Dooks

On 17/04/14 13:45, Laurent Pinchart wrote:

Hi Sylwester,

On Thursday 17 April 2014 13:17:41 Sylwester Nawrocki wrote:

On 11/03/14 00:15, Laurent Pinchart wrote:

Add support for the hsync-active, vsync-active and pclk-sample
properties to the DT bindings and control BT.656 mode implicitly.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---

  .../devicetree/bindings/media/i2c/adv7604.txt  | 13 +
  drivers/media/i2c/adv7604.c| 31
  -- 2 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/i2c/adv7604.txt
b/Documentation/devicetree/bindings/media/i2c/adv7604.txt index
0845c50..2b62c06 100644
--- a/Documentation/devicetree/bindings/media/i2c/adv7604.txt
+++ b/Documentation/devicetree/bindings/media/i2c/adv7604.txt

@@ -30,6 +30,19 @@ Optional Properties:
- adi,disable-cable-reset: Boolean property. When set disables the HDMI

  receiver automatic reset when the HDMI cable is unplugged.

+Optional Endpoint Properties:
+
+  The following three properties are defined in video-interfaces.txt and
are +  valid for source endpoints only.
+
+  - hsync-active: Horizontal synchronization polarity. Defaults to active
low. +  - vsync-active: Vertical synchronization polarity. Defaults to
active low. +  - pclk-sample: Pixel clock polarity. Defaults to output on
the falling edge. +
+  If none of hsync-active, vsync-active and pclk-sample is specified the
+  endpoint will use embedded BT.656 synchronization.
+
+

  Example:
hdmi_receiver@4c {

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 95cc911..2a92099 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -41,6 +41,7 @@

  #include media/v4l2-ctrls.h
  #include media/v4l2-device.h
  #include media/v4l2-dv-timings.h

+#include media/v4l2-of.h

  static int debug;
  module_param(debug, int, 0644);

@@ -2643,11 +2644,39 @@ MODULE_DEVICE_TABLE(of, adv7604_of_id);

  static int adv7604_parse_dt(struct adv7604_state *state)
  {

+   struct v4l2_of_endpoint bus_cfg;
+   struct device_node *endpoint;

struct device_node *np;

+   unsigned int flags;

int ret;

np = state-i2c_clients[ADV7604_PAGE_IO]-dev.of_node;

+   /* Parse the endpoint. */
+   endpoint = v4l2_of_get_next_endpoint(np, NULL);
+   if (!endpoint)
+   return -EINVAL;


Perhaps we should document this binding requires at least one endpoint
node ? I guess there is no point in not having any endpoint node ?


I think that's pretty much implied, otherwise the device will not be connected
to anything and will be unusable. I will document ports node usage though,
that's currently missing in the DT bindings documentation.


Doesn't the v4l2 helper code have standard parsing for the
endpoint sync configurations?


--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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: [v2] media: soc-camera: OF cameras

2014-04-14 Thread Ben Dooks

On 14/04/14 18:14, Bryan Wu wrote:

On Thu, Apr 10, 2014 at 2:18 PM, Guennadi Liakhovetski
g.liakhovet...@gmx.de wrote:

Hi Bryan,

On Tue, 8 Apr 2014, Bryan Wu wrote:


Thanks Josh, I think I will take you point and rework my patch again.
But I need Guennadi's review firstly, Guennadi, could you please help
to review it?


Ok, let me double check the situation:

1. We've got this patch from you, aiming at adding OF probing support to
soc-camra

2. We've got an alternative patch from Ben to do the same, his last reply
to a comment to his patch was Thanks, I will look into this.

3. We've got Ben's patches for rcar-vin, that presumably work with his
patch from (2) above

4. We've got Josh's patches to add OF / async probing to atmel-isi and
ov2640, that are not known to work with either (1) or (2) above, so, they
don't work at all, right?

So, to summarise, there is a core patch from Ben, that he possibly wants
to adjust, and that works with his rcar-vin OF, there is a patch from you
that isn't known to work with any driver, and there are patches from Josh,
that don't work, because there isn't a suitable patch available for them.
I will have a look at your and Ben's soc-camera OF patches to compare them
and compare them with my early code (hopefully this coming weekend), but
so far it looks like only Ben's solution has a complete working stack. Am
I missing something?



My bad. I missed the conversation and patches from Ben Dooks and you guys.
I have no problem for merging Ben's patch and I will align my Tegra
Camera patch with that, probably posted later.


If possible, could you test the latest one? I've not had much time
to actually use this and would welcome some feedback.


--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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: [v2] media: soc-camera: OF cameras

2014-04-11 Thread Ben Dooks

On 10/04/14 22:18, Guennadi Liakhovetski wrote:

Hi Bryan,

On Tue, 8 Apr 2014, Bryan Wu wrote:


Thanks Josh, I think I will take you point and rework my patch again.
But I need Guennadi's review firstly, Guennadi, could you please help
to review it?


Ok, let me double check the situation:

1. We've got this patch from you, aiming at adding OF probing support to
soc-camra

2. We've got an alternative patch from Ben to do the same, his last reply
to a comment to his patch was Thanks, I will look into this.

3. We've got Ben's patches for rcar-vin, that presumably work with his
patch from (2) above

4. We've got Josh's patches to add OF / async probing to atmel-isi and
ov2640, that are not known to work with either (1) or (2) above, so, they
don't work at all, right?

So, to summarise, there is a core patch from Ben, that he possibly wants
to adjust, and that works with his rcar-vin OF, there is a patch from you
that isn't known to work with any driver, and there are patches from Josh,
that don't work, because there isn't a suitable patch available for them.
I will have a look at your and Ben's soc-camera OF patches to compare them
and compare them with my early code (hopefully this coming weekend), but
so far it looks like only Ben's solution has a complete working stack. Am
I missing something?


I am looking in to fix the comments from Josh to get the atmel to
work and hope to have them out this weekend.

--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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: [RFCv3,3/3] soc_camera: initial of code

2014-04-01 Thread Ben Dooks

On 01/04/14 07:39, Josh Wu wrote:

Hi, Ben

On 3/31/2014 6:10 PM, Ben Dooks wrote:

On 31/03/14 10:28, Josh Wu wrote:

Hi, Ben

Thanks for the patch, I just test atmel-isi with the your patch,
I find the mclk registered in soc-camera driver cannot be find
by the soc-camera sensors. See comment in below:


Ok, I guess that the driver I have does not need the
mclk clock.




... ...



+#ifdef CONFIG_OF
+static int soc_of_bind(struct soc_camera_host *ici,
+   struct device_node *ep,
+   struct device_node *remote)
+{
+struct soc_camera_device *icd;
+struct soc_camera_desc sdesc = {.host_desc.bus_id = ici-nr,};
+struct soc_camera_async_client *sasc;
+struct soc_camera_async_subdev *sasd;
+struct v4l2_async_subdev **asd_array;
+char clk_name[V4L2_SUBDEV_NAME_SIZE];
+int ret;
+
+/* alloacte a new subdev and add match info to it */
+sasd = devm_kzalloc(ici-v4l2_dev.dev, sizeof(*sasd), GFP_KERNEL);
+if (!sasd)
+return -ENOMEM;
+
+asd_array = devm_kzalloc(ici-v4l2_dev.dev,
+ sizeof(struct v4l2_async_subdev **),
+ GFP_KERNEL);
+if (!asd_array)
+return -ENOMEM;
+
+sasd-asd.match.of.node = remote;
+sasd-asd.match_type = V4L2_ASYNC_MATCH_OF;
+asd_array[0] = sasd-asd;
+
+/* Or shall this be managed by the soc-camera device? */
+sasc = devm_kzalloc(ici-v4l2_dev.dev, sizeof(*sasc), GFP_KERNEL);
+if (!sasc)
+return -ENOMEM;
+
+/* HACK: just need a != NULL */
+sdesc.host_desc.board_info = ERR_PTR(-ENODATA);
+
+ret = soc_camera_dyn_pdev(sdesc, sasc);
+if (ret  0)
+return ret;
+
+sasc-sensor = sasd-asd;
+
+icd = soc_camera_add_pdev(sasc);
+if (!icd) {
+platform_device_put(sasc-pdev);
+return -ENOMEM;
+}
+
+//sasc-notifier.subdevs = asd;
+sasc-notifier.subdevs = asd_array;
+sasc-notifier.num_subdevs = 1;
+sasc-notifier.bound = soc_camera_async_bound;
+sasc-notifier.unbind = soc_camera_async_unbind;
+sasc-notifier.complete = soc_camera_async_complete;
+
+icd-sasc = sasc;
+icd-parent = ici-v4l2_dev.dev;
+
+snprintf(clk_name, sizeof(clk_name), of-%s,
+ of_node_full_name(remote));


The clk_name you register here is a OF string, but for the i2c
sensors, which
call the v4l2_clk_get by using dev_name(client-dev). It is format
like:
1-0030, combined i2c adaptor ID and addr.
So the i2c sensor can not find this registered mclk as the name is
not match.


Hmm, this sounds like something that really should go
away and be handled by the clk system instead.


Since the v4l2 clk (mclk) is just a temperory solution and it will be
removed if all use common clk framework.
(See the commit message of ff5430de70).

So IMHO we can live with this, just simply add the code in soc_of_bind():

+   struct i2c_client *client;
... ...

  client = of_find_i2c_device_by_node(remote);
+   if (!client)
+   goto eclkreg;

-snprintf(clk_name, sizeof(clk_name), of-%s,
-   of_node_full_name(remote));
+   snprintf(clk_name, sizeof(clk_name), %d-%04x,
+client-adapter-nr, client-addr);

 icd-clk = v4l2_clk_register(soc_camera_clk_ops, clk_name,
mclk, icd);



[snip]


Thanks, I will look into this.

--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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: [RFCv3,3/3] soc_camera: initial of code

2014-03-31 Thread Ben Dooks

On 31/03/14 10:28, Josh Wu wrote:

Hi, Ben

Thanks for the patch, I just test atmel-isi with the your patch,
I find the mclk registered in soc-camera driver cannot be find
by the soc-camera sensors. See comment in below:


Ok, I guess that the driver I have does not need the
mclk clock.




... ...



+#ifdef CONFIG_OF
+static int soc_of_bind(struct soc_camera_host *ici,
+  struct device_node *ep,
+  struct device_node *remote)
+{
+   struct soc_camera_device *icd;
+   struct soc_camera_desc sdesc = {.host_desc.bus_id = ici-nr,};
+   struct soc_camera_async_client *sasc;
+   struct soc_camera_async_subdev *sasd;
+   struct v4l2_async_subdev **asd_array;
+   char clk_name[V4L2_SUBDEV_NAME_SIZE];
+   int ret;
+
+   /* alloacte a new subdev and add match info to it */
+   sasd = devm_kzalloc(ici-v4l2_dev.dev, sizeof(*sasd), GFP_KERNEL);
+   if (!sasd)
+   return -ENOMEM;
+
+   asd_array = devm_kzalloc(ici-v4l2_dev.dev,
+sizeof(struct v4l2_async_subdev **),
+GFP_KERNEL);
+   if (!asd_array)
+   return -ENOMEM;
+
+   sasd-asd.match.of.node = remote;
+   sasd-asd.match_type = V4L2_ASYNC_MATCH_OF;
+   asd_array[0] = sasd-asd;
+
+   /* Or shall this be managed by the soc-camera device? */
+   sasc = devm_kzalloc(ici-v4l2_dev.dev, sizeof(*sasc), GFP_KERNEL);
+   if (!sasc)
+   return -ENOMEM;
+
+   /* HACK: just need a != NULL */
+   sdesc.host_desc.board_info = ERR_PTR(-ENODATA);
+
+   ret = soc_camera_dyn_pdev(sdesc, sasc);
+   if (ret  0)
+   return ret;
+
+   sasc-sensor = sasd-asd;
+
+   icd = soc_camera_add_pdev(sasc);
+   if (!icd) {
+   platform_device_put(sasc-pdev);
+   return -ENOMEM;
+   }
+
+   //sasc-notifier.subdevs = asd;
+   sasc-notifier.subdevs = asd_array;
+   sasc-notifier.num_subdevs = 1;
+   sasc-notifier.bound = soc_camera_async_bound;
+   sasc-notifier.unbind = soc_camera_async_unbind;
+   sasc-notifier.complete = soc_camera_async_complete;
+
+   icd-sasc = sasc;
+   icd-parent = ici-v4l2_dev.dev;
+
+   snprintf(clk_name, sizeof(clk_name), of-%s,
+of_node_full_name(remote));


The clk_name you register here is a OF string, but for the i2c sensors, which
call the v4l2_clk_get by using dev_name(client-dev). It is format like:
1-0030, combined i2c adaptor ID and addr.
So the i2c sensor can not find this registered mclk as the name is not match.


Hmm, this sounds like something that really should go
away and be handled by the clk system instead.

[snip]


--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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 5/5] rcar_vin: add devicetree support

2014-03-30 Thread Ben Dooks

On 30/03/14 22:04, Guennadi Liakhovetski wrote:

Hi Ben,

Since I never received a reply to this my query, I consider this your
patch series suspended.

Thanks
Guennadi


I meant to send out a patch series for the of probe for soc_camera.
The actual rcar_vin does not need much to support async probe, it is
just the soc_camera that needs sorting.


--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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


[RFC 1/3] rcar_vin: copy flags from pdata

2014-03-30 Thread Ben Dooks
The platform data is a single word, so simply copy
it into the device's private data structure than
keeping a copy of the pointer.

This will make changing to device-tree binding
easier as it is one allocation instead of two.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 702dc47..47516df 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -126,13 +126,13 @@ struct rcar_vin_priv {
int sequence;
/* State of the VIN module in capturing mode */
enum rcar_vin_state state;
-   struct rcar_vin_platform_data   *pdata;
struct soc_camera_host  ici;
struct list_headcapture;
 #define MAX_BUFFER_NUM 3
struct vb2_buffer   *queue_buf[MAX_BUFFER_NUM];
struct vb2_alloc_ctx*alloc_ctx;
enum v4l2_field field;
+   unsigned intpdata_flags;
unsigned intvb_count;
unsigned intnr_hw_slots;
boolrequest_to_stop;
@@ -275,12 +275,12 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
break;
case V4L2_MBUS_FMT_YUYV8_2X8:
/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
-   vnmc |= priv-pdata-flags  RCAR_VIN_BT656 ?
+   vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
break;
case V4L2_MBUS_FMT_YUYV10_2X10:
/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
-   vnmc |= priv-pdata-flags  RCAR_VIN_BT656 ?
+   vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
break;
default:
@@ -799,7 +799,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device 
*icd)
/* Make choises, based on platform preferences */
if ((common_flags  V4L2_MBUS_HSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_HSYNC_ACTIVE_LOW)) {
-   if (priv-pdata-flags  RCAR_VIN_HSYNC_ACTIVE_LOW)
+   if (priv-pdata_flags  RCAR_VIN_HSYNC_ACTIVE_LOW)
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_LOW;
@@ -807,7 +807,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device 
*icd)
 
if ((common_flags  V4L2_MBUS_VSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_VSYNC_ACTIVE_LOW)) {
-   if (priv-pdata-flags  RCAR_VIN_VSYNC_ACTIVE_LOW)
+   if (priv-pdata_flags  RCAR_VIN_VSYNC_ACTIVE_LOW)
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_LOW;
@@ -1447,7 +1447,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
priv-ici.drv_name = dev_name(pdev-dev);
priv-ici.ops = rcar_vin_host_ops;
 
-   priv-pdata = pdata;
+   priv-pdata_flags = pdata-flags;
priv-chip = pdev-id_entry-driver_data;
spin_lock_init(priv-lock);
INIT_LIST_HEAD(priv-capture);
-- 
1.9.0

--
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


[RFC 3/3] soc_camera: initial of code

2014-03-30 Thread Ben Dooks
Add initial support for OF based soc-camera devices that may be used
by any of the soc-camera drivers. The driver itself will need converting
to use OF.

These changes allow the soc-camera driver to do the connecting of any
async capable v4l2 device to the soc-camera driver. This has currently
been tested on the Renesas Lager board.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_camera.c | 111 -
 1 file changed, 110 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index 4b8c024..afe22d4 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -36,6 +36,7 @@
 #include media/v4l2-common.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-dev.h
+#include media/v4l2-of.h
 #include media/videobuf-core.h
 #include media/videobuf2-core.h
 
@@ -1579,6 +1580,112 @@ static void scan_async_host(struct soc_camera_host *ici)
 #define scan_async_host(ici)   do {} while (0)
 #endif
 
+#ifdef CONFIG_OF
+static int soc_of_bind(struct soc_camera_host *ici,
+  struct device_node *ep,
+  struct device_node *remote)
+{
+   struct soc_camera_device *icd;
+   struct soc_camera_desc sdesc = {.host_desc.bus_id = ici-nr,};
+   struct soc_camera_async_client *sasc;
+   struct soc_camera_async_subdev *sasd;
+   struct v4l2_async_subdev **asd_array;
+   char clk_name[V4L2_SUBDEV_NAME_SIZE];
+   int ret;
+
+   /* alloacte a new subdev and add match info to it */
+   sasd = devm_kzalloc(ici-v4l2_dev.dev, sizeof(*sasd), GFP_KERNEL);
+   if (!sasd)
+   return -ENOMEM;
+
+   asd_array = devm_kzalloc(ici-v4l2_dev.dev,
+sizeof(struct v4l2_async_subdev **),
+GFP_KERNEL);
+   if (!asd_array)
+   return -ENOMEM;
+
+   sasd-asd.match.of.node = remote;
+   sasd-asd.match_type = V4L2_ASYNC_MATCH_OF;
+   asd_array[0] = sasd-asd;
+
+   /* Or shall this be managed by the soc-camera device? */
+   sasc = devm_kzalloc(ici-v4l2_dev.dev, sizeof(*sasc), GFP_KERNEL);
+   if (!sasc)
+   return -ENOMEM;
+
+   /* HACK: just need a != NULL */
+   sdesc.host_desc.board_info = ERR_PTR(-ENODATA);
+
+   ret = soc_camera_dyn_pdev(sdesc, sasc);
+   if (ret  0)
+   return ret;
+
+   sasc-sensor = sasd-asd;
+
+   icd = soc_camera_add_pdev(sasc);
+   if (!icd) {
+   platform_device_put(sasc-pdev);
+   return -ENOMEM;
+   }
+
+   //sasc-notifier.subdevs = asd;
+   sasc-notifier.subdevs = asd_array;
+   sasc-notifier.num_subdevs = 1;
+   sasc-notifier.bound = soc_camera_async_bound;
+   sasc-notifier.unbind = soc_camera_async_unbind;
+   sasc-notifier.complete = soc_camera_async_complete;
+
+   icd-sasc = sasc;
+   icd-parent = ici-v4l2_dev.dev;
+
+   snprintf(clk_name, sizeof(clk_name), of-%s,
+of_node_full_name(remote));
+
+   icd-clk = v4l2_clk_register(soc_camera_clk_ops, clk_name, mclk, 
icd);
+   if (IS_ERR(icd-clk)) {
+   ret = PTR_ERR(icd-clk);
+   goto eclkreg;
+   }
+
+   ret = v4l2_async_notifier_register(ici-v4l2_dev, sasc-notifier);
+   if (!ret)
+   return 0;
+
+eclkreg:
+   icd-clk = NULL;
+   platform_device_unregister(sasc-pdev);
+   dev_err(ici-v4l2_dev.dev, group probe failed: %d\n, ret);
+
+   return ret;
+}
+
+static inline void scan_of_host(struct soc_camera_host *ici)
+{
+   struct device_node *np = ici-v4l2_dev.dev-of_node;
+   struct device_node *epn = NULL;
+   struct device_node *ren;
+
+   while (true) {
+   epn = v4l2_of_get_next_endpoint(np, epn);
+   if (!epn)
+   break;
+
+   ren = v4l2_of_get_remote_port(epn);
+   if (!ren) {
+   pr_info(%s: no remote for %s\n,
+   __func__,  of_node_full_name(epn));
+   continue;
+   }
+
+   /* so we now have a remote node to connect */
+   soc_of_bind(ici, epn, ren-parent);
+   }
+}
+
+#else
+static inline void scan_of_host(struct soc_camera_host *ici) { }
+#endif
+
 /* Called during host-driver probe */
 static int soc_camera_probe(struct soc_camera_host *ici,
struct soc_camera_device *icd)
@@ -1830,7 +1937,9 @@ int soc_camera_host_register(struct soc_camera_host *ici)
mutex_init(ici-host_lock);
mutex_init(ici-clk_lock);
 
-   if (ici-asd_sizes)
+   if (ici-v4l2_dev.dev-of_node)
+   scan_of_host(ici);
+   else if (ici-asd_sizes)
/*
 * No OF, host with a list of subdevices. Don't try to mix

[RFC 2/3] rcar_vin: add devicetree support

2014-03-30 Thread Ben Dooks
Add support for devicetree probe for the rcar-vin
driver.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 .../devicetree/bindings/media/rcar_vin.txt | 79 ++
 drivers/media/platform/soc_camera/rcar_vin.c   | 67 --
 2 files changed, 140 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/rcar_vin.txt

diff --git a/Documentation/devicetree/bindings/media/rcar_vin.txt 
b/Documentation/devicetree/bindings/media/rcar_vin.txt
new file mode 100644
index 000..105b8de
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/rcar_vin.txt
@@ -0,0 +1,79 @@
+Renesas RCar Video Input driver (rcar_vin)
+--
+
+The rcar_vin device provides video input capabilities for the Renesas R-Car
+family of devices. The current blocks are always slaves and suppot one input
+channel which can be either RGB, YUYV or BT656.
+
+ - compatible: Must be one of the following
+   - renesas,vin-r8a7791 for the R8A7791 device
+   - renesas,vin-r8a7790 for the R8A7790 device
+   - renesas,vin-r8a7779 for the R8A7779 device
+   - renesas,vin-r8a7778 for the R8A7778 device
+ - reg: the register base and size for the device registers
+ - interrupts: the interrupt for the device
+ - clocks: Reference to the parent clock
+
+The per-board settings:
+ - port sub-node describing a single endpoint connected to the vin
+   as described in video-interfaces.txt[1]. Only the first one will
+   be considered as each vin interface has one input port.
+
+   These settings are used to work out video input format and widths
+   into the system.
+
+
+Device node example
+---
+
+vin0: vin@0xe6ef {
+compatible = renesas,vin-r8a7790;
+clocks = mstp8_clks R8A7790_CLK_VIN0;
+reg = 0 0xe6ef 0 0x1000;
+interrupts = 0 188 IRQ_TYPE_LEVEL_HIGH;
+status = disabled;
+};
+
+Board setup example (vin1 composite video input)
+
+
+i2c2   {
+status = ok;
+pinctrl-0 = i2c2_pins;
+pinctrl-names = default;
+
+adv7180: adv7180@0x20 {
+compatible = adi,adv7180;
+reg = 0x20;
+remote = vin1;
+
+port {
+adv7180_1: endpoint {
+bus-width = 8;
+remote-endpoint = vin1ep0;
+};
+};
+};
+};
+
+/* composite video input */
+vin1 {
+pinctrl-0 = vin1_pins;
+pinctrl-names = default;
+
+status = ok;
+
+port {
+#address-cells = 1;
+#size-cells = 0;
+
+vin1ep0: endpoint {
+remote-endpoint = adv7180_1;
+bus-width = 8;
+};
+};
+};
+
+
+
+[1] video-interfaces.txt common video media interface
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 47516df..73c56c7 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -24,6 +24,8 @@
 #include linux/pm_runtime.h
 #include linux/slab.h
 #include linux/videodev2.h
+#include linux/of.h
+#include linux/of_device.h
 
 #include media/soc_camera.h
 #include media/soc_mediabus.h
@@ -32,6 +34,7 @@
 #include media/v4l2-device.h
 #include media/v4l2-mediabus.h
 #include media/v4l2-subdev.h
+#include media/v4l2-of.h
 #include media/videobuf2-dma-contig.h
 
 #include soc_scale_crop.h
@@ -1392,6 +1395,17 @@ static struct soc_camera_host_ops rcar_vin_host_ops = {
.init_videobuf2 = rcar_vin_init_videobuf2,
 };
 
+#ifdef CONFIG_OF
+static struct of_device_id rcar_vin_of_table[] = {
+   { .compatible = renesas,vin-r8a7791, .data = (void *)RCAR_GEN2 },
+   { .compatible = renesas,vin-r8a7790, .data = (void *)RCAR_GEN2 },
+   { .compatible = renesas,vin-r8a7779, .data = (void *)RCAR_H1 },
+   { .compatible = renesas,vin-r8a7778, .data = (void *)RCAR_M1 },
+   { },
+};
+MODULE_DEVICE_TABLE(of, rcar_vin_of_table);
+#endif
+
 static struct platform_device_id rcar_vin_id_table[] = {
{ r8a7791-vin,  RCAR_GEN2 },
{ r8a7790-vin,  RCAR_GEN2 },
@@ -1404,15 +1418,50 @@ MODULE_DEVICE_TABLE(platform, rcar_vin_id_table);
 
 static int rcar_vin_probe(struct platform_device *pdev)
 {
+   const struct of_device_id *match = NULL;
struct rcar_vin_priv *priv;
struct resource *mem;
struct rcar_vin_platform_data *pdata;
+   unsigned int pdata_flags;
int irq, ret;
 
-   pdata = pdev-dev.platform_data;
-   if (!pdata || !pdata-flags) {
-   dev_err(pdev-dev, platform data not set\n);
-   return -EINVAL;
+   if (pdev-dev.of_node) {
+   struct v4l2_of_endpoint ep

Re: [PATCH 5/5] rcar_vin: add devicetree support

2014-03-30 Thread Ben Dooks

On 30/03/14 22:17, Guennadi Liakhovetski wrote:

On Sun, 30 Mar 2014, Ben Dooks wrote:


On 30/03/14 22:04, Guennadi Liakhovetski wrote:

Hi Ben,

Since I never received a reply to this my query, I consider this your
patch series suspended.

Thanks
Guennadi


I meant to send out a patch series for the of probe for soc_camera.
The actual rcar_vin does not need much to support async probe, it is
just the soc_camera that needs sorting.


But without that soc-camera DT support your patches are non-functional,
right?


They're not much use. I've sent the soc-camera patch out now for
review. I will sort out sending patches for the async device changes
for the device(s) on the lager board as soon as I can get some time
to re-test.

--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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: [RFC 2/3] rcar_vin: add devicetree support

2014-03-30 Thread Ben Dooks

On 30/03/14 22:26, Ben Dooks wrote:

Add support for devicetree probe for the rcar-vin
driver.


Sorry, this was an older branch and needed
a fix for the pdev-id field.


--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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


[RFCv2] rcar_vin: copy flags from pdata

2014-03-30 Thread Ben Dooks
The platform data is a single word, so simply copy
it into the device's private data structure than
keeping a copy of the pointer.

This will make changing to device-tree binding
easier as it is one allocation instead of two.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 702dc47..47516df 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -126,13 +126,13 @@ struct rcar_vin_priv {
int sequence;
/* State of the VIN module in capturing mode */
enum rcar_vin_state state;
-   struct rcar_vin_platform_data   *pdata;
struct soc_camera_host  ici;
struct list_headcapture;
 #define MAX_BUFFER_NUM 3
struct vb2_buffer   *queue_buf[MAX_BUFFER_NUM];
struct vb2_alloc_ctx*alloc_ctx;
enum v4l2_field field;
+   unsigned intpdata_flags;
unsigned intvb_count;
unsigned intnr_hw_slots;
boolrequest_to_stop;
@@ -275,12 +275,12 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
break;
case V4L2_MBUS_FMT_YUYV8_2X8:
/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
-   vnmc |= priv-pdata-flags  RCAR_VIN_BT656 ?
+   vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
break;
case V4L2_MBUS_FMT_YUYV10_2X10:
/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
-   vnmc |= priv-pdata-flags  RCAR_VIN_BT656 ?
+   vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
break;
default:
@@ -799,7 +799,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device 
*icd)
/* Make choises, based on platform preferences */
if ((common_flags  V4L2_MBUS_HSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_HSYNC_ACTIVE_LOW)) {
-   if (priv-pdata-flags  RCAR_VIN_HSYNC_ACTIVE_LOW)
+   if (priv-pdata_flags  RCAR_VIN_HSYNC_ACTIVE_LOW)
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_LOW;
@@ -807,7 +807,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device 
*icd)
 
if ((common_flags  V4L2_MBUS_VSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_VSYNC_ACTIVE_LOW)) {
-   if (priv-pdata-flags  RCAR_VIN_VSYNC_ACTIVE_LOW)
+   if (priv-pdata_flags  RCAR_VIN_VSYNC_ACTIVE_LOW)
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_LOW;
@@ -1447,7 +1447,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
priv-ici.drv_name = dev_name(pdev-dev);
priv-ici.ops = rcar_vin_host_ops;
 
-   priv-pdata = pdata;
+   priv-pdata_flags = pdata-flags;
priv-chip = pdev-id_entry-driver_data;
spin_lock_init(priv-lock);
INIT_LIST_HEAD(priv-capture);
-- 
1.9.0

--
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


[RFCv3 1/3] rcar_vin: copy flags from pdata

2014-03-30 Thread Ben Dooks
The platform data is a single word, so simply copy
it into the device's private data structure than
keeping a copy of the pointer.

This will make changing to device-tree binding
easier as it is one allocation instead of two.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 702dc47..47516df 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -126,13 +126,13 @@ struct rcar_vin_priv {
int sequence;
/* State of the VIN module in capturing mode */
enum rcar_vin_state state;
-   struct rcar_vin_platform_data   *pdata;
struct soc_camera_host  ici;
struct list_headcapture;
 #define MAX_BUFFER_NUM 3
struct vb2_buffer   *queue_buf[MAX_BUFFER_NUM];
struct vb2_alloc_ctx*alloc_ctx;
enum v4l2_field field;
+   unsigned intpdata_flags;
unsigned intvb_count;
unsigned intnr_hw_slots;
boolrequest_to_stop;
@@ -275,12 +275,12 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
break;
case V4L2_MBUS_FMT_YUYV8_2X8:
/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
-   vnmc |= priv-pdata-flags  RCAR_VIN_BT656 ?
+   vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
break;
case V4L2_MBUS_FMT_YUYV10_2X10:
/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
-   vnmc |= priv-pdata-flags  RCAR_VIN_BT656 ?
+   vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
break;
default:
@@ -799,7 +799,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device 
*icd)
/* Make choises, based on platform preferences */
if ((common_flags  V4L2_MBUS_HSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_HSYNC_ACTIVE_LOW)) {
-   if (priv-pdata-flags  RCAR_VIN_HSYNC_ACTIVE_LOW)
+   if (priv-pdata_flags  RCAR_VIN_HSYNC_ACTIVE_LOW)
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_LOW;
@@ -807,7 +807,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device 
*icd)
 
if ((common_flags  V4L2_MBUS_VSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_VSYNC_ACTIVE_LOW)) {
-   if (priv-pdata-flags  RCAR_VIN_VSYNC_ACTIVE_LOW)
+   if (priv-pdata_flags  RCAR_VIN_VSYNC_ACTIVE_LOW)
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_LOW;
@@ -1447,7 +1447,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
priv-ici.drv_name = dev_name(pdev-dev);
priv-ici.ops = rcar_vin_host_ops;
 
-   priv-pdata = pdata;
+   priv-pdata_flags = pdata-flags;
priv-chip = pdev-id_entry-driver_data;
spin_lock_init(priv-lock);
INIT_LIST_HEAD(priv-capture);
-- 
1.9.0

--
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


[RFCv3 3/3] soc_camera: initial of code

2014-03-30 Thread Ben Dooks
Add initial support for OF based soc-camera devices that may be used
by any of the soc-camera drivers. The driver itself will need converting
to use OF.

These changes allow the soc-camera driver to do the connecting of any
async capable v4l2 device to the soc-camera driver. This has currently
been tested on the Renesas Lager board.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_camera.c | 111 -
 1 file changed, 110 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index 4b8c024..afe22d4 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -36,6 +36,7 @@
 #include media/v4l2-common.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-dev.h
+#include media/v4l2-of.h
 #include media/videobuf-core.h
 #include media/videobuf2-core.h
 
@@ -1579,6 +1580,112 @@ static void scan_async_host(struct soc_camera_host *ici)
 #define scan_async_host(ici)   do {} while (0)
 #endif
 
+#ifdef CONFIG_OF
+static int soc_of_bind(struct soc_camera_host *ici,
+  struct device_node *ep,
+  struct device_node *remote)
+{
+   struct soc_camera_device *icd;
+   struct soc_camera_desc sdesc = {.host_desc.bus_id = ici-nr,};
+   struct soc_camera_async_client *sasc;
+   struct soc_camera_async_subdev *sasd;
+   struct v4l2_async_subdev **asd_array;
+   char clk_name[V4L2_SUBDEV_NAME_SIZE];
+   int ret;
+
+   /* alloacte a new subdev and add match info to it */
+   sasd = devm_kzalloc(ici-v4l2_dev.dev, sizeof(*sasd), GFP_KERNEL);
+   if (!sasd)
+   return -ENOMEM;
+
+   asd_array = devm_kzalloc(ici-v4l2_dev.dev,
+sizeof(struct v4l2_async_subdev **),
+GFP_KERNEL);
+   if (!asd_array)
+   return -ENOMEM;
+
+   sasd-asd.match.of.node = remote;
+   sasd-asd.match_type = V4L2_ASYNC_MATCH_OF;
+   asd_array[0] = sasd-asd;
+
+   /* Or shall this be managed by the soc-camera device? */
+   sasc = devm_kzalloc(ici-v4l2_dev.dev, sizeof(*sasc), GFP_KERNEL);
+   if (!sasc)
+   return -ENOMEM;
+
+   /* HACK: just need a != NULL */
+   sdesc.host_desc.board_info = ERR_PTR(-ENODATA);
+
+   ret = soc_camera_dyn_pdev(sdesc, sasc);
+   if (ret  0)
+   return ret;
+
+   sasc-sensor = sasd-asd;
+
+   icd = soc_camera_add_pdev(sasc);
+   if (!icd) {
+   platform_device_put(sasc-pdev);
+   return -ENOMEM;
+   }
+
+   //sasc-notifier.subdevs = asd;
+   sasc-notifier.subdevs = asd_array;
+   sasc-notifier.num_subdevs = 1;
+   sasc-notifier.bound = soc_camera_async_bound;
+   sasc-notifier.unbind = soc_camera_async_unbind;
+   sasc-notifier.complete = soc_camera_async_complete;
+
+   icd-sasc = sasc;
+   icd-parent = ici-v4l2_dev.dev;
+
+   snprintf(clk_name, sizeof(clk_name), of-%s,
+of_node_full_name(remote));
+
+   icd-clk = v4l2_clk_register(soc_camera_clk_ops, clk_name, mclk, 
icd);
+   if (IS_ERR(icd-clk)) {
+   ret = PTR_ERR(icd-clk);
+   goto eclkreg;
+   }
+
+   ret = v4l2_async_notifier_register(ici-v4l2_dev, sasc-notifier);
+   if (!ret)
+   return 0;
+
+eclkreg:
+   icd-clk = NULL;
+   platform_device_unregister(sasc-pdev);
+   dev_err(ici-v4l2_dev.dev, group probe failed: %d\n, ret);
+
+   return ret;
+}
+
+static inline void scan_of_host(struct soc_camera_host *ici)
+{
+   struct device_node *np = ici-v4l2_dev.dev-of_node;
+   struct device_node *epn = NULL;
+   struct device_node *ren;
+
+   while (true) {
+   epn = v4l2_of_get_next_endpoint(np, epn);
+   if (!epn)
+   break;
+
+   ren = v4l2_of_get_remote_port(epn);
+   if (!ren) {
+   pr_info(%s: no remote for %s\n,
+   __func__,  of_node_full_name(epn));
+   continue;
+   }
+
+   /* so we now have a remote node to connect */
+   soc_of_bind(ici, epn, ren-parent);
+   }
+}
+
+#else
+static inline void scan_of_host(struct soc_camera_host *ici) { }
+#endif
+
 /* Called during host-driver probe */
 static int soc_camera_probe(struct soc_camera_host *ici,
struct soc_camera_device *icd)
@@ -1830,7 +1937,9 @@ int soc_camera_host_register(struct soc_camera_host *ici)
mutex_init(ici-host_lock);
mutex_init(ici-clk_lock);
 
-   if (ici-asd_sizes)
+   if (ici-v4l2_dev.dev-of_node)
+   scan_of_host(ici);
+   else if (ici-asd_sizes)
/*
 * No OF, host with a list of subdevices. Don't try to mix

[RFCv3 2/3] rcar_vin: add devicetree support

2014-03-30 Thread Ben Dooks
Add support for devicetree probe for the rcar-vin
driver.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
Changes since v1:
- fix pdev-id handling via usage of alias property
Changes since v2:
- fix documentation for v1 updates
---
 .../devicetree/bindings/media/rcar_vin.txt | 86 ++
 drivers/media/platform/soc_camera/rcar_vin.c   | 70 --
 2 files changed, 149 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/rcar_vin.txt

diff --git a/Documentation/devicetree/bindings/media/rcar_vin.txt 
b/Documentation/devicetree/bindings/media/rcar_vin.txt
new file mode 100644
index 000..5463615
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/rcar_vin.txt
@@ -0,0 +1,86 @@
+Renesas RCar Video Input driver (rcar_vin)
+--
+
+The rcar_vin device provides video input capabilities for the Renesas R-Car
+family of devices. The current blocks are always slaves and suppot one input
+channel which can be either RGB, YUYV or BT656.
+
+ - compatible: Must be one of the following
+   - renesas,vin-r8a7791 for the R8A7791 device
+   - renesas,vin-r8a7790 for the R8A7790 device
+   - renesas,vin-r8a7779 for the R8A7779 device
+   - renesas,vin-r8a7778 for the R8A7778 device
+ - reg: the register base and size for the device registers
+ - interrupts: the interrupt for the device
+ - clocks: Reference to the parent clock
+
+Additionally, an alias named vinX will need to be created to specify
+which video input device this is.
+
+The per-board settings:
+ - port sub-node describing a single endpoint connected to the vin
+   as described in video-interfaces.txt[1]. Only the first one will
+   be considered as each vin interface has one input port.
+
+   These settings are used to work out video input format and widths
+   into the system.
+
+
+Device node example
+---
+
+   aliases {
+  vin0 = vin0;
+   };
+
+vin0: vin@0xe6ef {
+compatible = renesas,vin-r8a7790;
+clocks = mstp8_clks R8A7790_CLK_VIN0;
+reg = 0 0xe6ef 0 0x1000;
+interrupts = 0 188 IRQ_TYPE_LEVEL_HIGH;
+status = disabled;
+};
+
+Board setup example (vin1 composite video input)
+
+
+i2c2   {
+status = ok;
+pinctrl-0 = i2c2_pins;
+pinctrl-names = default;
+
+adv7180: adv7180@0x20 {
+compatible = adi,adv7180;
+reg = 0x20;
+remote = vin1;
+
+port {
+adv7180_1: endpoint {
+bus-width = 8;
+remote-endpoint = vin1ep0;
+};
+};
+};
+};
+
+/* composite video input */
+vin1 {
+pinctrl-0 = vin1_pins;
+pinctrl-names = default;
+
+status = ok;
+
+port {
+#address-cells = 1;
+#size-cells = 0;
+
+vin1ep0: endpoint {
+remote-endpoint = adv7180_1;
+bus-width = 8;
+};
+};
+};
+
+
+
+[1] video-interfaces.txt common video media interface
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 47516df..72d2504 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -24,6 +24,8 @@
 #include linux/pm_runtime.h
 #include linux/slab.h
 #include linux/videodev2.h
+#include linux/of.h
+#include linux/of_device.h
 
 #include media/soc_camera.h
 #include media/soc_mediabus.h
@@ -32,6 +34,7 @@
 #include media/v4l2-device.h
 #include media/v4l2-mediabus.h
 #include media/v4l2-subdev.h
+#include media/v4l2-of.h
 #include media/videobuf2-dma-contig.h
 
 #include soc_scale_crop.h
@@ -1392,6 +1395,17 @@ static struct soc_camera_host_ops rcar_vin_host_ops = {
.init_videobuf2 = rcar_vin_init_videobuf2,
 };
 
+#ifdef CONFIG_OF
+static struct of_device_id rcar_vin_of_table[] = {
+   { .compatible = renesas,vin-r8a7791, .data = (void *)RCAR_GEN2 },
+   { .compatible = renesas,vin-r8a7790, .data = (void *)RCAR_GEN2 },
+   { .compatible = renesas,vin-r8a7779, .data = (void *)RCAR_H1 },
+   { .compatible = renesas,vin-r8a7778, .data = (void *)RCAR_M1 },
+   { },
+};
+MODULE_DEVICE_TABLE(of, rcar_vin_of_table);
+#endif
+
 static struct platform_device_id rcar_vin_id_table[] = {
{ r8a7791-vin,  RCAR_GEN2 },
{ r8a7790-vin,  RCAR_GEN2 },
@@ -1404,15 +1418,50 @@ MODULE_DEVICE_TABLE(platform, rcar_vin_id_table);
 
 static int rcar_vin_probe(struct platform_device *pdev)
 {
+   const struct of_device_id *match = NULL;
struct rcar_vin_priv *priv;
struct resource *mem;
struct rcar_vin_platform_data *pdata

Re: [PATCH v2] media: soc-camera: OF cameras

2014-03-07 Thread Ben Dooks
 v4l2_of_endpoint *node = sdesc-host_desc.node;

 v4l2_ctrl_handler_free(icd-ctrl_handler);
 if (vdev) {
@@ -1719,6 +1908,17 @@ static int soc_camera_remove(struct soc_camera_device 
*icd)
 if (icd-sasc)
 platform_device_unregister(icd-sasc-pdev);

+   if (node) {
+   struct soc_camera_of_client *sofc = container_of(node,
+   struct soc_camera_of_client, node);
+   /* Don't dead-lock: remove the device here under the lock */
+   clear_bit(sofc-sasc.pdev-id, device_map);
+   list_del(icd-list);
+   if (sofc-link_node)
+   of_node_put(sofc-link_node);
+   platform_device_unregister(sofc-sasc.pdev);
+   }
+


Going back to the previous, in the use-case we have the device that
we link to the soc_camera is /not/ an soc-camera, it is a standard
v4l2 subdev device (adv7180).


--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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 5/5] rcar_vin: add devicetree support

2014-03-07 Thread Ben Dooks
Add support for devicetree probe for the rcar-vin
driver.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 .../devicetree/bindings/media/rcar_vin.txt | 79 ++
 drivers/media/platform/soc_camera/rcar_vin.c   | 67 --
 2 files changed, 140 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/rcar_vin.txt

diff --git a/Documentation/devicetree/bindings/media/rcar_vin.txt 
b/Documentation/devicetree/bindings/media/rcar_vin.txt
new file mode 100644
index 000..105b8de
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/rcar_vin.txt
@@ -0,0 +1,79 @@
+Renesas RCar Video Input driver (rcar_vin)
+--
+
+The rcar_vin device provides video input capabilities for the Renesas R-Car
+family of devices. The current blocks are always slaves and suppot one input
+channel which can be either RGB, YUYV or BT656.
+
+ - compatible: Must be one of the following
+   - renesas,vin-r8a7791 for the R8A7791 device
+   - renesas,vin-r8a7790 for the R8A7790 device
+   - renesas,vin-r8a7779 for the R8A7779 device
+   - renesas,vin-r8a7778 for the R8A7778 device
+ - reg: the register base and size for the device registers
+ - interrupts: the interrupt for the device
+ - clocks: Reference to the parent clock
+
+The per-board settings:
+ - port sub-node describing a single endpoint connected to the vin
+   as described in video-interfaces.txt[1]. Only the first one will
+   be considered as each vin interface has one input port.
+
+   These settings are used to work out video input format and widths
+   into the system.
+
+
+Device node example
+---
+
+vin0: vin@0xe6ef {
+compatible = renesas,vin-r8a7790;
+clocks = mstp8_clks R8A7790_CLK_VIN0;
+reg = 0 0xe6ef 0 0x1000;
+interrupts = 0 188 IRQ_TYPE_LEVEL_HIGH;
+status = disabled;
+};
+
+Board setup example (vin1 composite video input)
+
+
+i2c2   {
+status = ok;
+pinctrl-0 = i2c2_pins;
+pinctrl-names = default;
+
+adv7180: adv7180@0x20 {
+compatible = adi,adv7180;
+reg = 0x20;
+remote = vin1;
+
+port {
+adv7180_1: endpoint {
+bus-width = 8;
+remote-endpoint = vin1ep0;
+};
+};
+};
+};
+
+/* composite video input */
+vin1 {
+pinctrl-0 = vin1_pins;
+pinctrl-names = default;
+
+status = ok;
+
+port {
+#address-cells = 1;
+#size-cells = 0;
+
+vin1ep0: endpoint {
+remote-endpoint = adv7180_1;
+bus-width = 8;
+};
+};
+};
+
+
+
+[1] video-interfaces.txt common video media interface
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 47516df..73c56c7 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -24,6 +24,8 @@
 #include linux/pm_runtime.h
 #include linux/slab.h
 #include linux/videodev2.h
+#include linux/of.h
+#include linux/of_device.h
 
 #include media/soc_camera.h
 #include media/soc_mediabus.h
@@ -32,6 +34,7 @@
 #include media/v4l2-device.h
 #include media/v4l2-mediabus.h
 #include media/v4l2-subdev.h
+#include media/v4l2-of.h
 #include media/videobuf2-dma-contig.h
 
 #include soc_scale_crop.h
@@ -1392,6 +1395,17 @@ static struct soc_camera_host_ops rcar_vin_host_ops = {
.init_videobuf2 = rcar_vin_init_videobuf2,
 };
 
+#ifdef CONFIG_OF
+static struct of_device_id rcar_vin_of_table[] = {
+   { .compatible = renesas,vin-r8a7791, .data = (void *)RCAR_GEN2 },
+   { .compatible = renesas,vin-r8a7790, .data = (void *)RCAR_GEN2 },
+   { .compatible = renesas,vin-r8a7779, .data = (void *)RCAR_H1 },
+   { .compatible = renesas,vin-r8a7778, .data = (void *)RCAR_M1 },
+   { },
+};
+MODULE_DEVICE_TABLE(of, rcar_vin_of_table);
+#endif
+
 static struct platform_device_id rcar_vin_id_table[] = {
{ r8a7791-vin,  RCAR_GEN2 },
{ r8a7790-vin,  RCAR_GEN2 },
@@ -1404,15 +1418,50 @@ MODULE_DEVICE_TABLE(platform, rcar_vin_id_table);
 
 static int rcar_vin_probe(struct platform_device *pdev)
 {
+   const struct of_device_id *match = NULL;
struct rcar_vin_priv *priv;
struct resource *mem;
struct rcar_vin_platform_data *pdata;
+   unsigned int pdata_flags;
int irq, ret;
 
-   pdata = pdev-dev.platform_data;
-   if (!pdata || !pdata-flags) {
-   dev_err(pdev-dev, platform data not set\n);
-   return -EINVAL;
+   if (pdev-dev.of_node) {
+   struct v4l2_of_endpoint ep

[PATCH 1/5] r8a7790.dtsi: add vin[0-3] nodes

2014-03-07 Thread Ben Dooks
Add nodes for the four video input channels on the R8A7790.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 arch/arm/boot/dts/r8a7790.dtsi | 32 
 1 file changed, 32 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
index a1e7c39..4c3eafb 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -395,6 +395,38 @@
status = disabled;
};
 
+   vin0: vin@0xe6ef {
+   compatible = renesas,vin-r8a7790;
+   clocks = mstp8_clks R8A7790_CLK_VIN0;
+   reg = 0 0xe6ef 0 0x1000;
+   interrupts = 0 188 IRQ_TYPE_LEVEL_HIGH;
+   status = disabled;
+   };
+
+   vin1: vin@0xe6ef1000 {
+   compatible = renesas,vin-r8a7790;
+   clocks = mstp8_clks R8A7790_CLK_VIN1;
+   reg = 0 0xe6ef1000 0 0x1000;
+   interrupts = 0 189 IRQ_TYPE_LEVEL_HIGH;
+   status = disabled;
+   };
+
+   vin2: vin@0xe6ef2000 {
+   compatible = renesas,vin-r8a7790;
+   clocks = mstp8_clks R8A7790_CLK_VIN2;
+   reg = 0 0xe6ef2000 0 0x1000;
+   interrupts = 0 190 IRQ_TYPE_LEVEL_HIGH;
+   status = disabled;
+   };
+
+   vin3: vin@0xe6ef3000 {
+   compatible = renesas,vin-r8a7790;
+   clocks = mstp8_clks R8A7790_CLK_VIN3;
+   reg = 0 0xe6ef3000 0 0x1000;
+   interrupts = 0 191 IRQ_TYPE_LEVEL_HIGH;
+   status = disabled;
+   };
+
clocks {
#address-cells = 2;
#size-cells = 2;
-- 
1.9.0

--
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 4/5] rcar_vin: copy flags from pdata

2014-03-07 Thread Ben Dooks
The platform data is a single word, so simply copy
it into the device's private data structure than
keeping a copy of the pointer.

This will make changing to device-tree binding
easier as it is one allocation instead of two.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 702dc47..47516df 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -126,13 +126,13 @@ struct rcar_vin_priv {
int sequence;
/* State of the VIN module in capturing mode */
enum rcar_vin_state state;
-   struct rcar_vin_platform_data   *pdata;
struct soc_camera_host  ici;
struct list_headcapture;
 #define MAX_BUFFER_NUM 3
struct vb2_buffer   *queue_buf[MAX_BUFFER_NUM];
struct vb2_alloc_ctx*alloc_ctx;
enum v4l2_field field;
+   unsigned intpdata_flags;
unsigned intvb_count;
unsigned intnr_hw_slots;
boolrequest_to_stop;
@@ -275,12 +275,12 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
break;
case V4L2_MBUS_FMT_YUYV8_2X8:
/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
-   vnmc |= priv-pdata-flags  RCAR_VIN_BT656 ?
+   vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
break;
case V4L2_MBUS_FMT_YUYV10_2X10:
/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
-   vnmc |= priv-pdata-flags  RCAR_VIN_BT656 ?
+   vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
break;
default:
@@ -799,7 +799,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device 
*icd)
/* Make choises, based on platform preferences */
if ((common_flags  V4L2_MBUS_HSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_HSYNC_ACTIVE_LOW)) {
-   if (priv-pdata-flags  RCAR_VIN_HSYNC_ACTIVE_LOW)
+   if (priv-pdata_flags  RCAR_VIN_HSYNC_ACTIVE_LOW)
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_LOW;
@@ -807,7 +807,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device 
*icd)
 
if ((common_flags  V4L2_MBUS_VSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_VSYNC_ACTIVE_LOW)) {
-   if (priv-pdata-flags  RCAR_VIN_VSYNC_ACTIVE_LOW)
+   if (priv-pdata_flags  RCAR_VIN_VSYNC_ACTIVE_LOW)
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_LOW;
@@ -1447,7 +1447,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
priv-ici.drv_name = dev_name(pdev-dev);
priv-ici.ops = rcar_vin_host_ops;
 
-   priv-pdata = pdata;
+   priv-pdata_flags = pdata-flags;
priv-chip = pdev-id_entry-driver_data;
spin_lock_init(priv-lock);
INIT_LIST_HEAD(priv-capture);
-- 
1.9.0

--
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


soc_camera rcar_vin support for device-tree binding

2014-03-07 Thread Ben Dooks
This is a series of patches to get towards the point the renesas
rcar_vin driver can be bound via device-tree. Patches 1 and 2 add
the device tree nodes, patch 3 is one which has been in my tree
for a while and the last two modify the rcar_vin driver.

--
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 1/5] r8a7790.dtsi: add vin[0-3] nodes

2014-03-07 Thread Ben Dooks

On 07/03/14 16:45, Sergei Shtylyov wrote:

Hello.

On 03/07/2014 04:01 PM, Ben Dooks wrote:


Add nodes for the four video input channels on the R8A7790.



Signed-off-by: Ben Dooks ben.do...@codethink.co.uk


This patch should have been preceded by the VIN driver patch and
bindings description, don't you think?


Given this is a pretty standard device and video input binding
as already described in the relevant documentation, didn't really
think it was necessary.


diff --git a/arch/arm/boot/dts/r8a7790.dtsi
b/arch/arm/boot/dts/r8a7790.dtsi
index a1e7c39..4c3eafb 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -395,6 +395,38 @@
  status = disabled;
  };

+vin0: vin@0xe6ef {


ePAPR standard [1] tells us that:

The name of a node should be somewhat generic, reflecting the function
of the device and not its precise programming model.

So, I would suggest something like video. And remove 0x from the
address part of the node name please.


vin is a reasonable contraction of video-input.


--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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 2/5] ARM: lager: add vin1 node

2014-03-07 Thread Ben Dooks

On 07/03/14 16:50, Sergei Shtylyov wrote:

Hello.

On 03/07/2014 04:01 PM, Ben Dooks wrote:


Add device-tree for vin1 (composite video in) on the
lager board.



Signed-off-by: Ben Dooks ben.do...@codethink.co.uk


This patch should have been preceded by the VIN driver patch and
bindings description, don't you think?


diff --git a/arch/arm/boot/dts/r8a7790-lager.dts
b/arch/arm/boot/dts/r8a7790-lager.dts
index a087421..7528cfc 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts

[...]

@@ -239,8 +244,41 @@
  status = ok;
  pinctrl-0 = i2c2_pins;
  pinctrl-names = default;
+
+adv7180: adv7180@0x20 {


ePAPR standard [1] tells us that:

The name of a node should be somewhat generic, reflecting the function
of the device and not its precise programming model.

So, I would suggest something like video-decoder instead. And
remove 0x from the address part of the node name please.


Personally I'm not fussed about names in the tree.

I will look at changing it to something like vin1_decoder


--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
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: How to efficiently handle DMA and cache on ARMv7 ? (was Is get_user_pages() enough to prevent pages from being swapped out ?)

2009-08-06 Thread Ben Dooks
On Thu, Aug 06, 2009 at 12:08:21PM +0200, Laurent Pinchart wrote:
 [Resent with an updated subject, this time CC'ing linux-arm-kernel]
 
 I've spent the last few days playing with get_user_pages() and mlock() and 
 got some interesting results. It turned out that cache coherency comes into 
 play at some point, making the overall problem more complex.
 
 Here's my current setup:
 
 - OMAP processor, based on an ARMv7 core
 - MMU and IOMMU
 - VIPT non-aliasing data cache
 - video capture driver that transfers data to memory using DMA
 - video capture application that pass userspace pointers to video buffers to 
 the driver
 
 My goal is to make sure that, upon DMA completion, the correct data will be 
 available to the userspace application.
 
 The first problem was to pin pages to memory, to make sure they will not be 
 freed when the DMA is in progress. videobug-dma-sg uses get_user_pages() for 
 that, and Hugh Dickins nicely explained to me why this is enough.
 
 The second problem is to ensure cache coherency. As the userspace application 
 will read data from the video buffers, those buffers will end up being cached 
 in the processor's data cache. The driver does need to invalidate the cache 
 before starting the DMA operation (userspace could in theory write to the 
 buffers, but the data will be overwritten by DMA anyway, so there's no need 
 to 
 clean the cache).

You'll need to clean the write buffers, otherwise the CPU may have data
queued that it has yet to write back to memory.

 As the cache is of the VIPT (Virtual Index Physical Tag) type, cache 
 invalidation can either be done globally (in which case the cache is flushed 
 instead of being invalidated) or based on virtual addresses. In the last case 
 the processor will need to look physical addresses up, either in the TLB or 
 through hardware table walk.
 
 I can see three solutions to the DMA/cache problem.
 
 1. Flushing the whole data cache right before starting the DMA transfer. 
 There's no API for that in the ARM architecture, so a whole I+D cache is 
 required. This is quite costly, we're talking about around 30 flushes per 
 second, but it doesn't involve the MMU. That's the solution that I currently 
 use.
 
 2. Invalidating only the cache lines that store video buffer data. This 
 requires a TLB lookup or a hardware table walk, so the userspace application 
 MM context needs to be available (no problem there as where's flushing in 
 userspace context) and all pages need to be mapped properly. This can be a 
 problem as, as Hugh pointed out, pages can still be unmapped from the 
 userspace context after get_user_pages() returns. I have experienced one oops 
 due to a kernel paging request failure:

If you already know the virtual addresses of the buffers, why do you need
a TLB lookup (or am I being dense here?)

 Unable to handle kernel paging request at virtual address 44e12000
 pgd = c8698000
 [44e12000] *pgd=8a4fd031, *pte=8cfda1cd, *ppte=
 Internal error: Oops: 817 [#1] PREEMPT
 PC is at v7_dma_inv_range+0x2c/0x44
 
 Fixing this requires more investigation, and I'm not sure how to proceed to 
 find out if the page fault is really caused by pages being unmapped from the 
 userspace context. Help would be appreciated.
 
 3. Mark the pages as non-cacheable. Depending on how the buffers are then 
 used 
 by userspace, the additional cache misses might destroy any benefit I would 
 get from not flushing the cache before DMA. I'm not sure how to mark a bunch 
 of pages as non-cacheable though. What usually happens is that video drivers 
 allocate DMA-coherent memory themselves, but in this case I need to deal with 
 an arbitrary buffer allocated by userspace. If someone has any experience 
 with 
 this, it would be appreciated.
 
 Regards,
 
 Laurent Pinchart
 
 
 ---
 List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel
 FAQ:http://www.arm.linux.org.uk/mailinglists/faq.php
 Etiquette:  http://www.arm.linux.org.uk/mailinglists/etiquette.php

-- 
-- 
Ben

Q:  What's a light-year?
A:  One-third less calories than a regular year.

--
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