Re: [PATCH v2 1/3] media: V3s: Add support for Allwinner CSI.

2017-07-30 Thread Baruch Siach
Hi Yong,

On Mon, Jul 31, 2017 at 09:48:06AM +0800, Yong wrote:
> On Sun, 30 Jul 2017 09:08:01 +0300
> Baruch Siach  wrote:
> > On Fri, Jul 28, 2017 at 06:02:33PM +0200, Maxime Ripard wrote:
> > > On Thu, Jul 27, 2017 at 01:01:35PM +0800, Yong Deng wrote:
> > > > +   regmap_write(sdev->regmap, CSI_CH_F0_BUFA_REG,
> > > > +(bus_addr + sdev->planar_offset[0]) >> 2);
> > 
> > Why do you need the bit shift? Does that work for you?
> > 
> > The User Manuals of both the V3s and the and the A33 (AKA R16) state that 
> > the 
> > BUFA field size in this register is 31:00, that is 32bit. I have found no 
> > indication of this bit shift in the Olimex provided sunxi-vfe[1] driver. On 
> > the A33 I have found that only after removing the bit-shift, (some sort of) 
> > data started to appear in the buffer.
> > 
> > [1] 
> > https://github.com/hehopmajieh/a33_linux/tree/master/drivers/media/video/sunxi-vfe
> 
> The Users Manuals do not document this bit shift. You should see line 10 to
> 32 in 
> https://github.com/hehopmajieh/a33_linux/blob/master/drivers/media/video/sunxi-vfe/csi/csi_reg.c

Thanks. So for my reference, the SoCs that don't need bit shift are A31, A23, 
and A33. SoCs that need bit shift are A80, A83, H3, and V3s (AKA V30).

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


cron job: media_tree daily build: ERRORS

2017-07-30 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:   Mon Jul 31 05:00:26 CEST 2017
media-tree git hash:da48c948c263c9d87dfc64566b3373a858cc8aa2
media_build git hash:   1abc6be7b313cb92ff9128cea3d69df7f63e725f
v4l-utils git hash: 6b5204abea527469012d3c40b1909b199b532614
gcc version:i686-linux-gcc (GCC) 7.1.0
sparse version: v0.5.0
smatch version: v0.5.0-3553-g78b2ea6
host hardware:  x86_64
host os:4.11.0-164

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-multi: WARNINGS
linux-git-arm-pxa: OK
linux-git-arm-stm32: OK
linux-git-blackfin-bf561: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.36.4-i686: WARNINGS
linux-2.6.37.6-i686: WARNINGS
linux-2.6.38.8-i686: WARNINGS
linux-2.6.39.4-i686: WARNINGS
linux-3.0.60-i686: WARNINGS
linux-3.1.10-i686: WARNINGS
linux-3.2.37-i686: WARNINGS
linux-3.3.8-i686: WARNINGS
linux-3.4.27-i686: ERRORS
linux-3.5.7-i686: WARNINGS
linux-3.6.11-i686: WARNINGS
linux-3.7.4-i686: WARNINGS
linux-3.8-i686: WARNINGS
linux-3.9.2-i686: WARNINGS
linux-3.10.1-i686: WARNINGS
linux-3.11.1-i686: WARNINGS
linux-3.12.67-i686: WARNINGS
linux-3.13.11-i686: WARNINGS
linux-3.14.9-i686: ERRORS
linux-3.15.2-i686: ERRORS
linux-3.16.7-i686: ERRORS
linux-3.17.8-i686: ERRORS
linux-3.18.7-i686: ERRORS
linux-3.19-i686: WARNINGS
linux-4.0.9-i686: WARNINGS
linux-4.1.33-i686: WARNINGS
linux-4.2.8-i686: WARNINGS
linux-4.3.6-i686: WARNINGS
linux-4.4.22-i686: WARNINGS
linux-4.5.7-i686: WARNINGS
linux-4.6.7-i686: WARNINGS
linux-4.7.5-i686: WARNINGS
linux-4.8-i686: OK
linux-4.9.26-i686: OK
linux-4.10.14-i686: ERRORS
linux-4.11-i686: OK
linux-4.12.1-i686: OK
linux-2.6.36.4-x86_64: WARNINGS
linux-2.6.37.6-x86_64: WARNINGS
linux-2.6.38.8-x86_64: WARNINGS
linux-2.6.39.4-x86_64: WARNINGS
linux-3.0.60-x86_64: WARNINGS
linux-3.1.10-x86_64: WARNINGS
linux-3.2.37-x86_64: WARNINGS
linux-3.3.8-x86_64: WARNINGS
linux-3.4.27-x86_64: ERRORS
linux-3.5.7-x86_64: WARNINGS
linux-3.6.11-x86_64: WARNINGS
linux-3.7.4-x86_64: WARNINGS
linux-3.8-x86_64: WARNINGS
linux-3.9.2-x86_64: WARNINGS
linux-3.10.1-x86_64: WARNINGS
linux-3.11.1-x86_64: WARNINGS
linux-3.12.67-x86_64: WARNINGS
linux-3.13.11-x86_64: WARNINGS
linux-3.14.9-x86_64: ERRORS
linux-3.15.2-x86_64: ERRORS
linux-3.16.7-x86_64: ERRORS
linux-3.17.8-x86_64: WARNINGS
linux-3.18.7-x86_64: WARNINGS
linux-3.19-x86_64: WARNINGS
linux-4.0.9-x86_64: WARNINGS
linux-4.1.33-x86_64: WARNINGS
linux-4.2.8-x86_64: WARNINGS
linux-4.3.6-x86_64: WARNINGS
linux-4.4.22-x86_64: WARNINGS
linux-4.5.7-x86_64: WARNINGS
linux-4.6.7-x86_64: WARNINGS
linux-4.7.5-x86_64: WARNINGS
linux-4.8-x86_64: WARNINGS
linux-4.9.26-x86_64: WARNINGS
linux-4.10.14-x86_64: ERRORS
linux-4.11-x86_64: WARNINGS
linux-4.12.1-x86_64: WARNINGS
apps: WARNINGS
spec-git: OK
sparse: ERRORS

Detailed results are available here:

http://www.xs4all.nl/~hverkuil/logs/Monday.log

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Monday.tar.bz2

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/index.html


Re: [PATCH v2 1/3] media: V3s: Add support for Allwinner CSI.

2017-07-30 Thread Yong
Hi,

On Fri, 28 Jul 2017 18:02:33 +0200
Maxime Ripard  wrote:

> Hi, 
> 
> Thanks for the second iteration!
> 
> On Thu, Jul 27, 2017 at 01:01:35PM +0800, Yong Deng wrote:
> > Allwinner V3s SoC have two CSI module. CSI0 is used for MIPI interface
> > and CSI1 is used for parallel interface. This is not documented in
> > datasheet but by testing and guess.
> > 
> > This patch implement a v4l2 framework driver for it.
> > 
> > Currently, the driver only support the parallel interface. MIPI-CSI2,
> > ISP's support are not included in this patch.
> > 
> > Signed-off-by: Yong Deng 
> 
> There's a significant amount of checkpatch warnings (and quite
> important checks) in your driver. You should fix everything checkpatch
> --strict reports.

OK. I will check and fix.

> 
> > ---
> >  drivers/media/platform/Kconfig   |   1 +
> >  drivers/media/platform/Makefile  |   2 +
> >  drivers/media/platform/sun6i-csi/Kconfig |   9 +
> >  drivers/media/platform/sun6i-csi/Makefile|   3 +
> >  drivers/media/platform/sun6i-csi/sun6i_csi.c | 545 +++
> >  drivers/media/platform/sun6i-csi/sun6i_csi.h | 203 ++
> >  drivers/media/platform/sun6i-csi/sun6i_csi_v3s.c | 827 
> > +++
> >  drivers/media/platform/sun6i-csi/sun6i_csi_v3s.h | 206 ++
> >  drivers/media/platform/sun6i-csi/sun6i_video.c   | 663 ++
> >  drivers/media/platform/sun6i-csi/sun6i_video.h   |  61 ++
> >  10 files changed, 2520 insertions(+)
> >  create mode 100644 drivers/media/platform/sun6i-csi/Kconfig
> >  create mode 100644 drivers/media/platform/sun6i-csi/Makefile
> >  create mode 100644 drivers/media/platform/sun6i-csi/sun6i_csi.c
> >  create mode 100644 drivers/media/platform/sun6i-csi/sun6i_csi.h
> >  create mode 100644 drivers/media/platform/sun6i-csi/sun6i_csi_v3s.c
> >  create mode 100644 drivers/media/platform/sun6i-csi/sun6i_csi_v3s.h
> >  create mode 100644 drivers/media/platform/sun6i-csi/sun6i_video.c
> >  create mode 100644 drivers/media/platform/sun6i-csi/sun6i_video.h
> > 
> > diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
> > index 0c741d1..8371a87 100644
> > --- a/drivers/media/platform/Kconfig
> > +++ b/drivers/media/platform/Kconfig
> > @@ -143,6 +143,7 @@ source "drivers/media/platform/am437x/Kconfig"
> >  source "drivers/media/platform/xilinx/Kconfig"
> >  source "drivers/media/platform/rcar-vin/Kconfig"
> >  source "drivers/media/platform/atmel/Kconfig"
> > +source "drivers/media/platform/sun6i-csi/Kconfig"
> 
> We're going to have several different drivers in v4l eventually, so I
> guess it would make sense to move to a directory of our own.

Like this?
drivers/media/platform/sunxi/sun6i-csi

> 
> > +   dev_dbg(csi->dev, "creating links for entity %s\n", local->name);
> > +
> > +   while (1) {
> > +   /* Get the next endpoint and parse its link. */
> > +   next = of_graph_get_next_endpoint(entity->node, ep);
> > +   if (next == NULL)
> > +   break;
> > +
> > +   of_node_put(ep);
> > +   ep = next;
> > +
> > +   dev_dbg(csi->dev, "processing endpoint %s\n", ep->full_name);
> > +
> > +   ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), );
> > +   if (ret < 0) {
> > +   dev_err(csi->dev, "failed to parse link for %s\n",
> > +   ep->full_name);
> > +   continue;
> > +   }
> > +
> > +   /* Skip sink ports, they will be processed from the other end of
> > +* the link.
> > +*/
> > +   if (link.local_port >= local->num_pads) {
> > +   dev_err(csi->dev, "invalid port number %u on %s\n",
> > +   link.local_port,
> > +   to_of_node(link.local_node)->full_name);
> > +   v4l2_fwnode_put_link();
> > +   ret = -EINVAL;
> > +   break;
> > +   }
> > +
> > +   local_pad = >pads[link.local_port];
> > +
> > +   if (local_pad->flags & MEDIA_PAD_FL_SINK) {
> > +   dev_dbg(csi->dev, "skipping sink port %s:%u\n",
> > +   to_of_node(link.local_node)->full_name,
> > +   link.local_port);
> > +   v4l2_fwnode_put_link();
> > +   continue;
> > +   }
> > +
> > +   /* Skip video node, they will be processed separately. */
> > +   if (link.remote_node == of_fwnode_handle(csi->dev->of_node)) {
> > +   dev_dbg(csi->dev, "skipping CSI port %s:%u\n",
> > +   to_of_node(link.local_node)->full_name,
> > +   link.local_port);
> > +   v4l2_fwnode_put_link();
> > +   continue;
> > +   }
> > +
> > +   /* Find the remote entity. */
> > +  

[PATCH v3 0/5] Add Rockchip RGA V4l2 support

2017-07-30 Thread Jacob Chen
This patch series add a v4l2 m2m drvier for rockchip RGA direct rendering based 
2d graphics acceleration module.

Before, my colleague yakir have write a drm RGA drvier and send it to the lists.
http://lists.infradead.org/pipermail/linux-arm-kernel/2016-March/416769.html
I have been asked to find a userspace user("compositor") for it, but after some 
studys, my conclusion is that unlike exynos g2d,
rockchip rga are not suitable for compositor. Rockchip RGA have a limited MMU, 
which means it can only hold several buffers in the same time.
When it was used in compositor, it will waste a lot of time to 
import/export/flush buffer, resulting in a bad performance.

A few months ago, i saw a discussion in dri-de...@lists.freedesktop.org.
It remind that we could write a v4l2 m2m RGA driver, since we usually use RGA 
for streaming purpose.
https://patches.linaro.org/cover/97727/

I have test this driver with gstreamer v4l2transform plugin and it seems work 
well.

change in V3:
- rename the controls.
- add pm_runtime support.
- enable node by default.
- correct spelling in documents.

change in V2:
- generalize the controls.
- map buffers (10-50 us) in every cmd-run rather than in buffer-import to avoid 
get_free_pages failed on
actively used systems.
- remove status in dt-bindings examples.

Jacob Chen (5):
  [media] v4l: add blend modes controls
  [media]: rockchip/rga: v4l2 m2m support
  ARM: dts: rockchip: add RGA device node for RK3288
  ARM: dts: rockchip: add RGA device node for RK3399
  dt-bindings: Document the Rockchip RGA bindings

 .../devicetree/bindings/media/rockchip-rga.txt |  33 +
 arch/arm/boot/dts/rk3288.dtsi  |  11 +
 arch/arm64/boot/dts/rockchip/rk3399.dtsi   |  11 +
 drivers/media/platform/Kconfig |  11 +
 drivers/media/platform/Makefile|   2 +
 drivers/media/platform/rockchip-rga/Makefile   |   3 +
 drivers/media/platform/rockchip-rga/rga-buf.c  | 141 +++
 drivers/media/platform/rockchip-rga/rga-hw.c   | 650 ++
 drivers/media/platform/rockchip-rga/rga-hw.h   | 437 +
 drivers/media/platform/rockchip-rga/rga.c  | 987 +
 drivers/media/platform/rockchip-rga/rga.h  | 110 +++
 drivers/media/v4l2-core/v4l2-ctrls.c   |  20 +-
 include/uapi/linux/v4l2-controls.h |  16 +-
 13 files changed, 2430 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/rockchip-rga.txt
 create mode 100644 drivers/media/platform/rockchip-rga/Makefile
 create mode 100644 drivers/media/platform/rockchip-rga/rga-buf.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.h
 create mode 100644 drivers/media/platform/rockchip-rga/rga.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga.h

-- 
2.7.4



[PATCH v3 1/5] [media] v4l: add porter duff blend controls

2017-07-30 Thread Jacob Chen
At peresent, we don't have a control for Compositing and Blend.
All drivers are just doing copies while actually many hardwares
supports more functions.

So Adding V4L2 controls for Compositing and Blend, used for for
composting streams.

The values are based on porter duff operations.
Defined in below links.
https://developer.xamarin.com/api/type/Android.Graphics.PorterDuff+Mode/

Signed-off-by: Jacob Chen 
Suggested-by: Nicolas Dufresne 
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 20 +++-
 include/uapi/linux/v4l2-controls.h   | 16 +++-
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index b9e08e3..561d7d5 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -478,7 +478,21 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
"Region Grid",
NULL,
};
-
+   static const char * const porter_duff_modes[] = {
+   "Source",
+   "Source Top",
+   "Source In",
+   "Source Out",
+   "Source Over",
+   "Destination",
+   "Destination Top",
+   "Destination In",
+   "Destination Out",
+   "Destination Over",
+   "Add",
+   "Clear",
+   NULL
+   };
 
switch (id) {
case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ:
@@ -564,6 +578,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
return vpx_golden_frame_sel;
case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
return jpeg_chroma_subsampling;
+   case V4L2_CID_PORTER_DUFF_MODE:
+   return porter_duff_modes;
case V4L2_CID_DV_TX_MODE:
return dv_tx_mode;
case V4L2_CID_DV_TX_RGB_RANGE:
@@ -886,6 +902,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_PIXEL_RATE:   return "Pixel Rate";
case V4L2_CID_TEST_PATTERN: return "Test Pattern";
case V4L2_CID_DEINTERLACING_MODE:   return "Deinterlacing Mode";
+   case V4L2_CID_PORTER_DUFF_MODE: return "PorterDuff Blend Modes";
 
/* DV controls */
/* Keep the order of the 'case's the same as in v4l2-controls.h! */
@@ -1060,6 +1077,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_DV_RX_IT_CONTENT_TYPE:
case V4L2_CID_TEST_PATTERN:
case V4L2_CID_DEINTERLACING_MODE:
+   case V4L2_CID_PORTER_DUFF_MODE:
case V4L2_CID_TUNE_DEEMPHASIS:
case V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL:
case V4L2_CID_DETECT_MD_MODE:
diff --git a/include/uapi/linux/v4l2-controls.h 
b/include/uapi/linux/v4l2-controls.h
index 0d2e1e0..9543b4b 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -893,7 +893,21 @@ enum v4l2_jpeg_chroma_subsampling {
 #define V4L2_CID_PIXEL_RATE(V4L2_CID_IMAGE_PROC_CLASS_BASE 
+ 2)
 #define V4L2_CID_TEST_PATTERN  (V4L2_CID_IMAGE_PROC_CLASS_BASE 
+ 3)
 #define V4L2_CID_DEINTERLACING_MODE(V4L2_CID_IMAGE_PROC_CLASS_BASE 
+ 4)
-
+#define V4L2_CID_PORTER_DUFF_MODE  (V4L2_CID_IMAGE_PROC_CLASS_BASE 
+ 5)
+enum v4l2_porter_duff_mode {
+   V4L2_PORTER_DUFF_SRC= 0,
+   V4L2_PORTER_DUFF_SRCATOP= 1,
+   V4L2_PORTER_DUFF_SRCIN  = 2,
+   V4L2_PORTER_DUFF_SRCOUT = 3,
+   V4L2_PORTER_DUFF_SRCOVER= 4,
+   V4L2_PORTER_DUFF_DST= 5,
+   V4L2_PORTER_DUFF_DSTATOP= 6,
+   V4L2_PORTER_DUFF_DSTIN  = 7,
+   V4L2_PORTER_DUFF_DSTOUT = 8,
+   V4L2_PORTER_DUFF_DSTOVER= 9,
+   V4L2_PORTER_DUFF_ADD= 10,
+   V4L2_PORTER_DUFF_CLEAR  = 11,
+};
 
 /*  DV-class control IDs defined by V4L2 */
 #define V4L2_CID_DV_CLASS_BASE (V4L2_CTRL_CLASS_DV | 0x900)
-- 
2.7.4



[PATCH v3 4/5] ARM: dts: rockchip: add RGA device node for RK3399

2017-07-30 Thread Jacob Chen
This patch add the RGA dt config of RK3399 SoC.

Signed-off-by: Jacob Chen 
Signed-off-by: Yakir Yang 
---
 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi 
b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
index 8e6d1bd..0133a5f 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
@@ -1056,6 +1056,17 @@
status = "disabled";
};
 
+   rga: rga@ff68 {
+   compatible = "rockchip,rk3399-rga";
+   reg = <0x0 0xff68 0x0 0x1>;
+   interrupts = ;
+   clocks = < ACLK_RGA>, < HCLK_RGA>, < SCLK_RGA_CORE>;
+   clock-names = "aclk", "hclk", "sclk";
+   resets = < SRST_RGA_CORE>, < SRST_A_RGA>, < 
SRST_H_RGA>;
+   reset-names = "core", "axi", "ahb";
+   power-domains = < RK3399_PD_RGA>;
+   };
+
efuse0: efuse@ff69 {
compatible = "rockchip,rk3399-efuse";
reg = <0x0 0xff69 0x0 0x80>;
-- 
2.7.4



[PATCH v3 3/5] ARM: dts: rockchip: add RGA device node for RK3288

2017-07-30 Thread Jacob Chen
This patch add the RGA dt config of rk3288 SoC.

Signed-off-by: Jacob Chen 
Signed-off-by: Yakir Yang 
---
 arch/arm/boot/dts/rk3288.dtsi | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
index 1efc2f2..cea41b7 100644
--- a/arch/arm/boot/dts/rk3288.dtsi
+++ b/arch/arm/boot/dts/rk3288.dtsi
@@ -945,6 +945,17 @@
status = "okay";
};
 
+   rga: rga@ff92 {
+   compatible = "rockchip,rk3288-rga";
+   reg = <0xff92 0x180>;
+   interrupts = ;
+   clocks = < ACLK_RGA>, < HCLK_RGA>, < SCLK_RGA>;
+   clock-names = "aclk", "hclk", "sclk";
+   power-domains = < RK3288_PD_VIO>;
+   resets = < SRST_RGA_CORE>, < SRST_RGA_AXI>, < 
SRST_RGA_AHB>;
+   reset-names = "core", "axi", "ahb";
+   };
+
vopb: vop@ff93 {
compatible = "rockchip,rk3288-vop";
reg = <0xff93 0x19c>;
-- 
2.7.4



[PATCH v3 2/5] [media]: rockchip/rga: v4l2 m2m support

2017-07-30 Thread Jacob Chen
Rockchip RGA is a separate 2D raster graphic acceleration unit. It
accelerates 2D graphics operations, such as point/line drawing, image
scaling, rotation, BitBLT, alpha blending and image blur/sharpness

The drvier is mostly based on s5p-g2d v4l2 m2m driver
And supports various operations from the rendering pipeline.
 - copy
 - fast solid color fill
 - rotation
 - flip
 - alpha blending

The code in rga-hw.c is used to configure regs accroding to operations
The code in rga-buf.c is used to create (1-Level)mmu table for RGA
The tables is stored in a list, and be removed when buffer is cleanup

Signed-off-by: Jacob Chen 
---
 drivers/media/platform/Kconfig|  11 +
 drivers/media/platform/Makefile   |   2 +
 drivers/media/platform/rockchip-rga/Makefile  |   3 +
 drivers/media/platform/rockchip-rga/rga-buf.c | 141 
 drivers/media/platform/rockchip-rga/rga-hw.c  | 650 +
 drivers/media/platform/rockchip-rga/rga-hw.h  | 437 
 drivers/media/platform/rockchip-rga/rga.c | 987 ++
 drivers/media/platform/rockchip-rga/rga.h | 110 +++
 8 files changed, 2341 insertions(+)
 create mode 100644 drivers/media/platform/rockchip-rga/Makefile
 create mode 100644 drivers/media/platform/rockchip-rga/rga-buf.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.h
 create mode 100644 drivers/media/platform/rockchip-rga/rga.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index c9106e1..8199bcf 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -411,6 +411,17 @@ config VIDEO_RENESAS_VSP1
  To compile this driver as a module, choose M here: the module
  will be called vsp1.
 
+config VIDEO_ROCKCHIP_RGA
+   tristate "Rockchip Raster 2d Grapphic Acceleration Unit"
+   depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
+   depends on ARCH_ROCKCHIP || COMPILE_TEST
+   select VIDEOBUF2_DMA_SG
+   select V4L2_MEM2MEM_DEV
+   default n
+   ---help---
+ This is a v4l2 driver for Rockchip SOC RGA2
+ 2d graphics accelerator.
+
 config VIDEO_TI_VPE
tristate "TI VPE (Video Processing Engine) driver"
depends on VIDEO_DEV && VIDEO_V4L2
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 349ddf6..3bf096f 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -54,6 +54,8 @@ obj-$(CONFIG_VIDEO_RENESAS_FDP1)  += rcar_fdp1.o
 obj-$(CONFIG_VIDEO_RENESAS_JPU)+= rcar_jpu.o
 obj-$(CONFIG_VIDEO_RENESAS_VSP1)   += vsp1/
 
+obj-$(CONFIG_VIDEO_ROCKCHIP_RGA)   += rockchip-rga/
+
 obj-y  += omap/
 
 obj-$(CONFIG_VIDEO_AM437X_VPFE)+= am437x/
diff --git a/drivers/media/platform/rockchip-rga/Makefile 
b/drivers/media/platform/rockchip-rga/Makefile
new file mode 100644
index 000..92fe254
--- /dev/null
+++ b/drivers/media/platform/rockchip-rga/Makefile
@@ -0,0 +1,3 @@
+rockchip-rga-objs := rga.o rga-hw.o rga-buf.o
+
+obj-$(CONFIG_VIDEO_ROCKCHIP_RGA) += rockchip-rga.o
diff --git a/drivers/media/platform/rockchip-rga/rga-buf.c 
b/drivers/media/platform/rockchip-rga/rga-buf.c
new file mode 100644
index 000..b4d28e3
--- /dev/null
+++ b/drivers/media/platform/rockchip-rga/rga-buf.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
+ * Author: Jacob Chen 
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "rga-hw.h"
+#include "rga.h"
+
+static int
+rga_queue_setup(struct vb2_queue *vq,
+   unsigned int *nbuffers, unsigned int *nplanes,
+   unsigned int sizes[], struct device *alloc_devs[])
+{
+   struct rga_ctx *ctx = vb2_get_drv_priv(vq);
+   struct rga_frame *f = rga_get_frame(ctx, vq->type);
+
+   if (IS_ERR(f))
+   return PTR_ERR(f);
+
+   sizes[0] = f->size;
+   *nplanes = 1;
+
+   if (*nbuffers == 0)
+   *nbuffers = 1;
+
+   return 0;
+}
+
+static int rga_buf_prepare(struct vb2_buffer *vb)
+{
+   struct rga_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
+   struct rga_frame *f = rga_get_frame(ctx, vb->vb2_queue->type);
+
+   if (IS_ERR(f))
+   return PTR_ERR(f);
+
+   vb2_set_plane_payload(vb, 0, f->size);
+
+   return 0;
+}
+
+static 

[PATCH v3 5/5] dt-bindings: Document the Rockchip RGA bindings

2017-07-30 Thread Jacob Chen
Add DT bindings documentation for Rockchip RGA

Signed-off-by: Jacob Chen 
Signed-off-by: Yakir Yang 
---
 .../devicetree/bindings/media/rockchip-rga.txt | 33 ++
 1 file changed, 33 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/rockchip-rga.txt

diff --git a/Documentation/devicetree/bindings/media/rockchip-rga.txt 
b/Documentation/devicetree/bindings/media/rockchip-rga.txt
new file mode 100644
index 000..fd5276a
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/rockchip-rga.txt
@@ -0,0 +1,33 @@
+device-tree bindings for rockchip 2D raster graphic acceleration controller 
(RGA)
+
+RGA is a standalone 2D raster graphic acceleration unit. It accelerates 2D
+graphics operations, such as point/line drawing, image scaling, rotation,
+BitBLT, alpha blending and image blur/sharpness.
+
+Required properties:
+- compatible: value should be one of the following
+   "rockchip,rk3288-rga";
+   "rockchip,rk3399-rga";
+
+- interrupts: RGA interrupt specifier.
+
+- clocks: phandle to RGA sclk/hclk/aclk clocks
+
+- clock-names: should be "aclk", "hclk" and "sclk"
+
+- resets: Must contain an entry for each entry in reset-names.
+  See ../reset/reset.txt for details.
+- reset-names: should be "core", "axi" and "ahb"
+
+Example:
+SoC-specific DT entry:
+   rga: rga@ff68 {
+   compatible = "rockchip,rk3399-rga";
+   reg = <0xff68 0x1>;
+   interrupts = ;
+   clocks = < ACLK_RGA>, < HCLK_RGA>, < SCLK_RGA_CORE>;
+   clock-names = "aclk", "hclk", "sclk";
+
+   resets = < SRST_RGA_CORE>, < SRST_A_RGA>, < 
SRST_H_RGA>;
+   reset-names = "core, "axi", "ahb";
+   };
-- 
2.7.4



Re: [PATCH v2 1/3] media: V3s: Add support for Allwinner CSI.

2017-07-30 Thread Yong
Hi,

On Sun, 30 Jul 2017 09:08:01 +0300
Baruch Siach  wrote:

> Hi Maxime, Yong,
> 
> On Fri, Jul 28, 2017 at 06:02:33PM +0200, Maxime Ripard wrote:
> > Hi, 
> > 
> > Thanks for the second iteration!
> > 
> > On Thu, Jul 27, 2017 at 01:01:35PM +0800, Yong Deng wrote:
> > > Allwinner V3s SoC have two CSI module. CSI0 is used for MIPI interface
> > > and CSI1 is used for parallel interface. This is not documented in
> > > datasheet but by testing and guess.
> > > 
> > > This patch implement a v4l2 framework driver for it.
> > > 
> > > Currently, the driver only support the parallel interface. MIPI-CSI2,
> > > ISP's support are not included in this patch.
> > > 
> > > Signed-off-by: Yong Deng 
> 
> [...]
> 
> > > +#ifdef DEBUG
> > > +static void sun6i_csi_dump_regs(struct sun6i_csi_dev *sdev)
> > > +{
> > > + struct regmap *regmap = sdev->regmap;
> > > + u32 val;
> > > +
> > > + regmap_read(regmap, CSI_EN_REG, );
> > > + printk("CSI_EN_REG=0x%x\n", val);
> > > + regmap_read(regmap, CSI_IF_CFG_REG, );
> > > + printk("CSI_IF_CFG_REG=0x%x\n", val);
> > > + regmap_read(regmap, CSI_CAP_REG, );
> > > + printk("CSI_CAP_REG=0x%x\n",val);
> > > + regmap_read(regmap, CSI_SYNC_CNT_REG, );
> > > + printk("CSI_SYNC_CNT_REG=0x%x\n",   val);
> > > + regmap_read(regmap, CSI_FIFO_THRS_REG, );
> > > + printk("CSI_FIFO_THRS_REG=0x%x\n",  val);
> > > + regmap_read(regmap, CSI_PTN_LEN_REG, );
> > > + printk("CSI_PTN_LEN_REG=0x%x\n",val);
> > > + regmap_read(regmap, CSI_PTN_ADDR_REG, );
> > > + printk("CSI_PTN_ADDR_REG=0x%x\n",   val);
> > > + regmap_read(regmap, CSI_VER_REG, );
> > > + printk("CSI_VER_REG=0x%x\n",val);
> > > + regmap_read(regmap, CSI_CH_CFG_REG, );
> > > + printk("CSI_CH_CFG_REG=0x%x\n", val);
> > > + regmap_read(regmap, CSI_CH_SCALE_REG, );
> > > + printk("CSI_CH_SCALE_REG=0x%x\n",   val);
> > > + regmap_read(regmap, CSI_CH_F0_BUFA_REG, );
> > > + printk("CSI_CH_F0_BUFA_REG=0x%x\n", val);
> > > + regmap_read(regmap, CSI_CH_F1_BUFA_REG, );
> > > + printk("CSI_CH_F1_BUFA_REG=0x%x\n", val);
> > > + regmap_read(regmap, CSI_CH_F2_BUFA_REG, );
> > > + printk("CSI_CH_F2_BUFA_REG=0x%x\n", val);
> > > + regmap_read(regmap, CSI_CH_STA_REG, );
> > > + printk("CSI_CH_STA_REG=0x%x\n", val);
> > > + regmap_read(regmap, CSI_CH_INT_EN_REG, );
> > > + printk("CSI_CH_INT_EN_REG=0x%x\n",  val);
> > > + regmap_read(regmap, CSI_CH_INT_STA_REG, );
> > > + printk("CSI_CH_INT_STA_REG=0x%x\n", val);
> > > + regmap_read(regmap, CSI_CH_FLD1_VSIZE_REG, );
> > > + printk("CSI_CH_FLD1_VSIZE_REG=0x%x\n",  val);
> > > + regmap_read(regmap, CSI_CH_HSIZE_REG, );
> > > + printk("CSI_CH_HSIZE_REG=0x%x\n",   val);
> > > + regmap_read(regmap, CSI_CH_VSIZE_REG, );
> > > + printk("CSI_CH_VSIZE_REG=0x%x\n",   val);
> > > + regmap_read(regmap, CSI_CH_BUF_LEN_REG, );
> > > + printk("CSI_CH_BUF_LEN_REG=0x%x\n", val);
> > > + regmap_read(regmap, CSI_CH_FLIP_SIZE_REG, );
> > > + printk("CSI_CH_FLIP_SIZE_REG=0x%x\n",   val);
> > > + regmap_read(regmap, CSI_CH_FRM_CLK_CNT_REG, );
> > > + printk("CSI_CH_FRM_CLK_CNT_REG=0x%x\n", val);
> > > + regmap_read(regmap, CSI_CH_ACC_ITNL_CLK_CNT_REG, );
> > > + printk("CSI_CH_ACC_ITNL_CLK_CNT_REG=0x%x\n",val);
> > > + regmap_read(regmap, CSI_CH_FIFO_STAT_REG, );
> > > + printk("CSI_CH_FIFO_STAT_REG=0x%x\n",   val);
> > > + regmap_read(regmap, CSI_CH_PCLK_STAT_REG, );
> > > + printk("CSI_CH_PCLK_STAT_REG=0x%x\n",   val);
> > > +}
> > > +#endif
> > 
> > You can already dump a regmap through debugfs, that's redundant.
> 
> The advantage of in-code registers dump routine is the ability to synchronize 
> the snapshot with the driver code execution. This is particularly important 
> for the capture statistics registers. I have found it useful here.

Agree. It is not used to expose the registers value to user space. If you
think it is redundant, I will delete it.

> 
> [...]
> 
> > > +static int update_buf_addr(struct sun6i_csi *csi, dma_addr_t addr)
> > > +{
> > > + struct sun6i_csi_dev *sdev = sun6i_csi_to_dev(csi);
> > > + /* transform physical address to bus address */
> > > + dma_addr_t bus_addr = addr - 0x4000;
> > 
> > Like Baruch noticed, you should use PHYS_OFFSET here. The A80 for
> > example has a different RAM base address.
> > 
> > > +
> > > + regmap_write(sdev->regmap, CSI_CH_F0_BUFA_REG,
> > > +  (bus_addr + sdev->planar_offset[0]) >> 2);
> 
> Why do you need the bit shift? Does that work for you?
> 
> The User Manuals of both the V3s and the and the A33 (AKA R16) state that the 
> BUFA field size in this register is 31:00, that is 32bit. I have found no 
> indication of this bit shift in the Olimex provided sunxi-vfe[1] driver. On 
> the A33 I have found that only after removing the bit-shift, (some sort of) 
> data started to appear in the buffer.
> 
> [1] 
> 

Re: [PATCH v2 2/3] dt-bindings: media: Add Allwinner V3s Camera Sensor Interface (CSI)

2017-07-30 Thread Yong
On Fri, 28 Jul 2017 18:03:53 +0200
Maxime Ripard  wrote:

> Hi,
> 
> On Thu, Jul 27, 2017 at 01:01:36PM +0800, Yong Deng wrote:
> > Add binding documentation for Allwinner V3s CSI.
> > 
> > Signed-off-by: Yong Deng 
> > ---
> >  .../devicetree/bindings/media/sun6i-csi.txt| 49 
> > ++
> >  1 file changed, 49 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/media/sun6i-csi.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/media/sun6i-csi.txt 
> > b/Documentation/devicetree/bindings/media/sun6i-csi.txt
> > new file mode 100644
> > index 000..f8d83f6
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/media/sun6i-csi.txt
> > @@ -0,0 +1,49 @@
> > +Allwinner V3s Camera Sensor Interface
> > +--
> > +
> > +Required properties:
> > +  - compatible: value must be "allwinner,sun8i-v3s-csi"
> > +  - reg: base address and size of the memory-mapped region.
> > +  - interrupts: interrupt associated to this IP
> > +  - clocks: phandles to the clocks feeding the CSI
> > +* ahb: the CSI interface clock
> 
> We've been bad at this, but we're trying to have the same clock name
> here across all devices, and to use "bus" instead of "ahb".

OK. "ahb" was just follow other sunxi drivers.

> 
> Thanks!
> Maxime
> 
> -- 
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com


Thanks,
Yong


Re: [PATCH v2 1/3] media: V3s: Add support for Allwinner CSI.

2017-07-30 Thread Yong
On Thu, 27 Jul 2017 14:25:51 +0200
Maxime Ripard  wrote:

> On Thu, Jul 27, 2017 at 03:16:44PM +0300, Baruch Siach wrote:
> > Hi Yong,
> > 
> > I managed to get the Frame Done interrupt with the previous version of this 
> > driver on the A33 OLinuXino. No data yet (all zeros). I'm still working on 
> > it.
> > 
> > One comment below.
> > 
> > On Thu, Jul 27, 2017 at 01:01:35PM +0800, Yong Deng wrote:
> > > Allwinner V3s SoC have two CSI module. CSI0 is used for MIPI interface
> > > and CSI1 is used for parallel interface. This is not documented in
> > > datasheet but by testing and guess.
> > > 
> > > This patch implement a v4l2 framework driver for it.
> > > 
> > > Currently, the driver only support the parallel interface. MIPI-CSI2,
> > > ISP's support are not included in this patch.
> > > 
> > > Signed-off-by: Yong Deng 
> > > ---
> > 
> > [...]
> > 
> > > +static int update_buf_addr(struct sun6i_csi *csi, dma_addr_t addr)
> > > +{
> > > + struct sun6i_csi_dev *sdev = sun6i_csi_to_dev(csi);
> > > + /* transform physical address to bus address */
> > > + dma_addr_t bus_addr = addr - 0x4000;
> > 
> > What is the source of this magic number? Is it platform dependent? Are 
> > there 
> > other devices doing DMA that need this adjustment?
> 
> This is the RAM base address in most (but not all) Allwinner
> SoCs. You'll want to use PHYS_OFFSET instead.

I have try to use PHYS_OFFSET. But I found it is not 0x4000. I will
try it again.

> 
> Maxime
> 
> -- 
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com


Thanks,
Yong


[PATCH 0/4] v4l: async: fixes for v4l2_async_notifier_unregister()

2017-07-30 Thread Niklas Söderlund
Hi,

This series is based on top of media-tree and some patches where
previously part of the series '[PATCH v5 0/4] v4l2-async: add
subnotifier registration for subdevices'. Hans suggested the cleanups
could be broken out to a separate series, so this is this series :-)

The aim of this series is to cleanup and document some of the odd things
that happens in v4l2_async_notifier_unregister(). The purpose for this
in the short term is to make it easier to implement subnotifiers which
both I and Sakari are trying to address, this feature is blocking other
drivers such as the Renesas R-Car CSI-2 receiver driver. And in the long
run (I hope) to make it easier to get rid of the need to do re-probing
at all in v4l2_async_notifier_unregister() :-)

Niklas Söderlund (4):
  v4l: async: fix unbind error in v4l2_async_notifier_unregister()
  v4l: async: abort if memory allocation fails when unregistering
notifiers
  v4l: async: do not hold list_lock when re-probing devices
  v4l: async: add comment about re-probing to
v4l2_async_notifier_unregister()

 drivers/media/v4l2-core/v4l2-async.c | 49 
 1 file changed, 28 insertions(+), 21 deletions(-)

-- 
2.13.3



[PATCH 4/4] v4l: async: add comment about re-probing to v4l2_async_notifier_unregister()

2017-07-30 Thread Niklas Söderlund
The re-probing of subdevices when unregistering a notifier is tricky to
understand, and implemented somewhat as a hack. Add a comment trying to
explain why the re-probing is needed in the first place and why existing
helper functions can't be used in this situation.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/v4l2-core/v4l2-async.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index d91ff0a33fd3eaff..a3c5a1f6d4d2ab03 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -234,6 +234,23 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
 
mutex_unlock(_lock);
 
+   /*
+* Try to re-probe the subdevices which where part of the notifier.
+* This is done so subdevices which where part of the notifier will
+* be re-probed to a pristine state and put back on the global
+* list of subdevices so they can once more be found and associated
+* with a new notifier.
+*
+* One might be tempted to use device_reprobe() to handle the re-
+* probing. Unfortunately this is not possible since some video
+* device drivers call v4l2_async_notifier_unregister() from
+* there remove function leading to a dead lock situation on
+* device_lock(dev->parent). This lock is held when video device
+* drivers remove function is called and device_reprobe() also
+* tries to take the same lock, so using it here could lead to a
+* dead lock situation.
+*/
+
for (i = 0; i < count; i++) {
/* If we handled USB devices, we'd have to lock the parent too 
*/
device_release_driver(dev[i]);
-- 
2.13.3



[PATCH 2/4] v4l: async: abort if memory allocation fails when unregistering notifiers

2017-07-30 Thread Niklas Söderlund
Instead of trying to cope with the failed memory allocation and still
leaving the kernel in a semi-broken state (the subdevices will be
released but never re-probed) simply abort. The kernel have already
printed a warning about allocation failure but keep the error printout
to ease pinpointing the problem if it happens.

By doing this we can increase the readability of this complex function
which puts it in a better state to separate the v4l2 housekeeping tasks
from the re-probing of devices. It also serves to prepare for adding
subnotifers.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/v4l2-core/v4l2-async.c | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index 0acf288d7227ba97..67852f0f2d3000c9 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -215,6 +215,7 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
if (!dev) {
dev_err(notifier->v4l2_dev->dev,
"Failed to allocate device cache!\n");
+   return;
}
 
mutex_lock(_lock);
@@ -234,23 +235,13 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
/* If we handled USB devices, we'd have to lock the parent too 
*/
device_release_driver(d);
 
-   /*
-* Store device at the device cache, in order to call
-* put_device() on the final step
-*/
-   if (dev)
-   dev[i++] = d;
-   else
-   put_device(d);
+   dev[i++] = d;
}
 
mutex_unlock(_lock);
 
/*
 * Call device_attach() to reprobe devices
-*
-* NOTE: If dev allocation fails, i is 0, and the whole loop won't be
-* executed.
 */
while (i--) {
struct device *d = dev[i];
-- 
2.13.3



[PATCH 3/4] v4l: async: do not hold list_lock when re-probing devices

2017-07-30 Thread Niklas Söderlund
There is no good reason to hold the list_lock when re-probing the
devices and it prevents a clean implementation of subdevice notifiers.
Move the actual release of the devices outside of the loop which
requires the lock to be held.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/v4l2-core/v4l2-async.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index 67852f0f2d3000c9..d91ff0a33fd3eaff 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -206,7 +206,7 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
unsigned int notif_n_subdev = notifier->num_subdevs;
unsigned int n_subdev = min(notif_n_subdev, V4L2_MAX_SUBDEVS);
struct device **dev;
-   int i = 0;
+   int i, count = 0;
 
if (!notifier->v4l2_dev)
return;
@@ -223,27 +223,26 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
list_del(>list);
 
list_for_each_entry_safe(sd, tmp, >done, async_list) {
-   struct device *d;
-
-   d = get_device(sd->dev);
+   dev[count] = get_device(sd->dev);
+   count++;
 
if (notifier->unbind)
notifier->unbind(notifier, sd, sd->asd);
 
v4l2_async_cleanup(sd);
-
-   /* If we handled USB devices, we'd have to lock the parent too 
*/
-   device_release_driver(d);
-
-   dev[i++] = d;
}
 
mutex_unlock(_lock);
 
+   for (i = 0; i < count; i++) {
+   /* If we handled USB devices, we'd have to lock the parent too 
*/
+   device_release_driver(dev[i]);
+   }
+
/*
 * Call device_attach() to reprobe devices
 */
-   while (i--) {
+   for (i = 0; i < count; i++) {
struct device *d = dev[i];
 
if (d && device_attach(d) < 0) {
-- 
2.13.3



[PATCH 1/4] v4l: async: fix unbind error in v4l2_async_notifier_unregister()

2017-07-30 Thread Niklas Söderlund
The call to v4l2_async_cleanup() will set sd->asd to NULL so passing it
to notifier->unbind() have no effect and leaves the notifier confused.
Call the unbind() callback prior to cleaning up the subdevice to avoid
this.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/v4l2-core/v4l2-async.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index 851f128eba2219ad..0acf288d7227ba97 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -226,14 +226,14 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
 
d = get_device(sd->dev);
 
+   if (notifier->unbind)
+   notifier->unbind(notifier, sd, sd->asd);
+
v4l2_async_cleanup(sd);
 
/* If we handled USB devices, we'd have to lock the parent too 
*/
device_release_driver(d);
 
-   if (notifier->unbind)
-   notifier->unbind(notifier, sd, sd->asd);
-
/*
 * Store device at the device cache, in order to call
 * put_device() on the final step
-- 
2.13.3



Re: ir-keytable question [Ubuntu 17.04]

2017-07-30 Thread Sean Young
On Sat, Jul 29, 2017 at 01:46:07PM +0200, Matthias Reichl wrote:
> On Sat, Jul 29, 2017 at 11:23:22AM +0100, Sean Young wrote:
> > Hi,
> > 
> > On Sun, Jul 16, 2017 at 10:26:14PM -0700, Szabolcs Andrasi wrote:
> > > Hi,
> > > 
> > > I'm using Ubuntu 17.04 and I installed the ir-keytable tool. The
> > > output of the ir-keytable command is as follows:
> > > 
> > > 
> > > 
> > > Found /sys/class/rc/rc0/ (/dev/input/event5) with:
> > > Driver ite-cir, table rc-rc6-mce
> > > Supported protocols: unknown other lirc rc-5 rc-5-sz jvc sony nec
> > > sanyo mce_kbd rc-6 sharp xmp
> > > Enabled protocols: lirc rc-6
> > > Name: ITE8708 CIR transceiver
> > > bus: 25, vendor/product: 1283:, version: 0x
> > > Repeat delay = 500 ms, repeat period = 125 ms
> > > 
> > > 
> > > 
> > > I'm trying to enable the supported mce_kbd protocol in addition to the
> > > lirc and rc-6 protocols with the
> > > 
> > > $ sudo ir-keytable -p lirc -p rc-6 -p mce_kbd
> > > 
> > > command which works as expected. If, however, I reboot my computer,
> > > ir-keytable forgets this change and only the lirc and rc-6 protocols
> > > are enabled. Is there a configuration file I can edit so that after
> > > the boot my IR remote still works? Or is that so that the only way to
> > > make it work is to write a start-up script that runs the above command
> > > to enable the needed protocol?
> > 
> > So what we have today is /etc/rc_maps.cfg, where you can select the default
> > keymap for a particular driver; unfortunately, you can only select one
> > keymap and one keymap can only have one protocol.
> >
> > Ideally we could either have more than one protocol per keymap, which
> > would be helpful for the MCE Keyboard, or we could allow multiple keymaps
> > which would be great for supporting different remotes at the same time.
> 
> Having more than one protocol in the keymap file works fine here,
> we have been using that feature in LibreELEC for a long time now.
> Maybe it was just forgotten to document it?
> 
> $ git show 42511eb505
> commit 42511eb505b46b125652d37e764e5c8d1eb99e6b
> Author: Mauro Carvalho Chehab 
> Date:   Sat Apr 10 21:55:28 2010 -0300
> 
> ir-keytable: add support for more than one protocol in a table
> 
> Signed-off-by: Mauro Carvalho Chehab 
> 
> Quick test with ir-keytable 1.12.3 from Debian Stretch:

-snip-

Yes, you're right. I was wrong.

So, first of all, in recent kernels the "lirc" protocol is always enabled
and cannot be disabled. So there is no reason to explicitly enable it.

Now if you want to enable both rc-6 and mce_kbd, is that because you want
to use the Microsoft MCE IR keyboard? It uses both rc-6 and mce_kbd
protocol.

We should really have a keymap for this device; the only difference
with the rc6_mce keyboard is that mce_kbd protocol is also used.

Would that work?


Sean


[PATCH v2 2/3] dt-bindings: add bindings document for zx-irdec

2017-07-30 Thread Shawn Guo
From: Shawn Guo 

It adds the dt-bindings document for ZTE ZX IRDEC remote control
block.

Signed-off-by: Shawn Guo 
---
 Documentation/devicetree/bindings/media/zx-irdec.txt | 14 ++
 1 file changed, 14 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/zx-irdec.txt

diff --git a/Documentation/devicetree/bindings/media/zx-irdec.txt 
b/Documentation/devicetree/bindings/media/zx-irdec.txt
new file mode 100644
index ..295b9fab593e
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/zx-irdec.txt
@@ -0,0 +1,14 @@
+IR Decoder (IRDEC) on ZTE ZX family SoCs
+
+Required properties:
+ - compatible: Should be "zte,zx296718-irdec".
+ - reg: Physical base address and length of IRDEC registers.
+ - interrupts: Interrupt number of IRDEC.
+
+Exmaples:
+
+   irdec: ir-decoder@111000 {
+   compatible = "zte,zx296718-irdec";
+   reg = <0x111000 0x1000>;
+   interrupts = ;
+   };
-- 
1.9.1



[PATCH v2 3/3] rc: add zx-irdec remote control driver

2017-07-30 Thread Shawn Guo
From: Shawn Guo 

It adds the remote control driver and corresponding keymap file for
IRDEC block found on ZTE ZX family SoCs.

Signed-off-by: Shawn Guo 
---
 drivers/media/rc/Kconfig   |  11 ++
 drivers/media/rc/Makefile  |   1 +
 drivers/media/rc/keymaps/Makefile  |   3 +-
 drivers/media/rc/keymaps/rc-zx-irdec.c |  79 ++
 drivers/media/rc/zx-irdec.c| 183 +
 include/media/rc-map.h |   1 +
 6 files changed, 277 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/rc/keymaps/rc-zx-irdec.c
 create mode 100644 drivers/media/rc/zx-irdec.c

diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index 5e83b76495f7..c572d5da4b5f 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -435,4 +435,15 @@ config IR_SIR
   To compile this driver as a module, choose M here: the module will
   be called sir-ir.
 
+config IR_ZX
+   tristate "ZTE ZX IR remote control"
+   depends on RC_CORE
+   depends on ARCH_ZX || COMPILE_TEST
+   ---help---
+  Say Y if you want to use the IR remote control available
+  on ZTE ZX family SoCs.
+
+  To compile this driver as a module, choose M here: the
+  module will be called zx-irdec.
+
 endif #RC_DEVICES
diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
index 245e2c2d0b22..922c1a5620e9 100644
--- a/drivers/media/rc/Makefile
+++ b/drivers/media/rc/Makefile
@@ -41,3 +41,4 @@ obj-$(CONFIG_IR_IMG) += img-ir/
 obj-$(CONFIG_IR_SERIAL) += serial_ir.o
 obj-$(CONFIG_IR_SIR) += sir_ir.o
 obj-$(CONFIG_IR_MTK) += mtk-cir.o
+obj-$(CONFIG_IR_ZX) += zx-irdec.o
diff --git a/drivers/media/rc/keymaps/Makefile 
b/drivers/media/rc/keymaps/Makefile
index 2945f99907b5..af6496d709fb 100644
--- a/drivers/media/rc/keymaps/Makefile
+++ b/drivers/media/rc/keymaps/Makefile
@@ -109,4 +109,5 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
rc-videomate-tv-pvr.o \
rc-winfast.o \
rc-winfast-usbii-deluxe.o \
-   rc-su3000.o
+   rc-su3000.o \
+   rc-zx-irdec.o
diff --git a/drivers/media/rc/keymaps/rc-zx-irdec.c 
b/drivers/media/rc/keymaps/rc-zx-irdec.c
new file mode 100644
index ..cc889df47eb8
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-zx-irdec.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * Copyright 2017 Linaro Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+
+static struct rc_map_table zx_irdec_table[] = {
+   { 0x01, KEY_1 },
+   { 0x02, KEY_2 },
+   { 0x03, KEY_3 },
+   { 0x04, KEY_4 },
+   { 0x05, KEY_5 },
+   { 0x06, KEY_6 },
+   { 0x07, KEY_7 },
+   { 0x08, KEY_8 },
+   { 0x09, KEY_9 },
+   { 0x31, KEY_0 },
+   { 0x16, KEY_DELETE },
+   { 0x0a, KEY_MODE }, /* Input method */
+   { 0x0c, KEY_VOLUMEUP },
+   { 0x18, KEY_VOLUMEDOWN },
+   { 0x0b, KEY_CHANNELUP },
+   { 0x15, KEY_CHANNELDOWN },
+   { 0x0d, KEY_PAGEUP },
+   { 0x13, KEY_PAGEDOWN },
+   { 0x46, KEY_FASTFORWARD },
+   { 0x43, KEY_REWIND },
+   { 0x44, KEY_PLAYPAUSE },
+   { 0x45, KEY_STOP },
+   { 0x49, KEY_OK },
+   { 0x47, KEY_UP },
+   { 0x4b, KEY_DOWN },
+   { 0x48, KEY_LEFT },
+   { 0x4a, KEY_RIGHT },
+   { 0x4d, KEY_MENU },
+   { 0x56, KEY_APPSELECT },/* Application */
+   { 0x4c, KEY_BACK },
+   { 0x1e, KEY_INFO },
+   { 0x4e, KEY_F1 },
+   { 0x4f, KEY_F2 },
+   { 0x50, KEY_F3 },
+   { 0x51, KEY_F4 },
+   { 0x1c, KEY_AUDIO },
+   { 0x12, KEY_MUTE },
+   { 0x11, KEY_DOT },  /* Location */
+   { 0x1d, KEY_SETUP },
+   { 0x40, KEY_POWER },
+};
+
+static struct rc_map_list zx_irdec_map = {
+   .map = {
+   .scan = zx_irdec_table,
+   .size = ARRAY_SIZE(zx_irdec_table),
+   .rc_type = RC_TYPE_NEC,
+   .name = RC_MAP_ZX_IRDEC,
+   }
+};
+
+static int __init init_rc_map_zx_irdec(void)
+{
+   return rc_map_register(_irdec_map);
+}
+
+static void __exit exit_rc_map_zx_irdec(void)
+{
+   rc_map_unregister(_irdec_map);
+}
+
+module_init(init_rc_map_zx_irdec)
+module_exit(exit_rc_map_zx_irdec)
+
+MODULE_AUTHOR("Shawn Guo ");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/rc/zx-irdec.c b/drivers/media/rc/zx-irdec.c
new file mode 100644
index ..3993aa0aeaa9
--- /dev/null
+++ b/drivers/media/rc/zx-irdec.c
@@ -0,0 +1,183 @@
+/*
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * Copyright 2017 Linaro Ltd.
+ *
+ * This program is free software; 

[PATCH v2 1/3] rc: ir-nec-decoder: move scancode composing code into a shared function

2017-07-30 Thread Shawn Guo
From: Shawn Guo 

The NEC scancode composing and protocol type detection in
ir_nec_decode() is generic enough to be a shared function.  Let's create
an inline function in rc-core.h, so that other remote control drivers
can reuse this function to save some code.

Signed-off-by: Shawn Guo 
---
 drivers/media/rc/ir-nec-decoder.c | 32 +++-
 include/media/rc-core.h   | 31 +++
 2 files changed, 34 insertions(+), 29 deletions(-)

diff --git a/drivers/media/rc/ir-nec-decoder.c 
b/drivers/media/rc/ir-nec-decoder.c
index 3ce850314dca..b578c1e27c04 100644
--- a/drivers/media/rc/ir-nec-decoder.c
+++ b/drivers/media/rc/ir-nec-decoder.c
@@ -51,7 +51,6 @@ static int ir_nec_decode(struct rc_dev *dev, struct 
ir_raw_event ev)
u32 scancode;
enum rc_type rc_type;
u8 address, not_address, command, not_command;
-   bool send_32bits = false;
 
if (!is_timing_event(ev)) {
if (ev.reset)
@@ -161,34 +160,9 @@ static int ir_nec_decode(struct rc_dev *dev, struct 
ir_raw_event ev)
command = bitrev8((data->bits >>  8) & 0xff);
not_command = bitrev8((data->bits >>  0) & 0xff);
 
-   if ((command ^ not_command) != 0xff) {
-   IR_dprintk(1, "NEC checksum error: received 0x%08x\n",
-  data->bits);
-   send_32bits = true;
-   }
-
-   if (send_32bits) {
-   /* NEC transport, but modified protocol, used by at
-* least Apple and TiVo remotes */
-   scancode = not_address << 24 |
-   address << 16 |
-   not_command <<  8 |
-   command;
-   IR_dprintk(1, "NEC (modified) scancode 0x%08x\n", 
scancode);
-   rc_type = RC_TYPE_NEC32;
-   } else if ((address ^ not_address) != 0xff) {
-   /* Extended NEC */
-   scancode = address << 16 |
-  not_address <<  8 |
-  command;
-   IR_dprintk(1, "NEC (Ext) scancode 0x%06x\n", scancode);
-   rc_type = RC_TYPE_NECX;
-   } else {
-   /* Normal NEC */
-   scancode = address << 8 | command;
-   IR_dprintk(1, "NEC scancode 0x%04x\n", scancode);
-   rc_type = RC_TYPE_NEC;
-   }
+   scancode = ir_nec_bytes_to_scancode(address, not_address,
+   command, not_command,
+   _type);
 
if (data->is_nec_x)
data->necx_repeat = true;
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index 78dea39a9b39..204f7785b8e7 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -340,4 +340,35 @@ static inline u32 ir_extract_bits(u32 data, u32 mask)
return value;
 }
 
+/* Get NEC scancode and protocol type from address and command bytes */
+static inline u32 ir_nec_bytes_to_scancode(u8 address, u8 not_address,
+  u8 command, u8 not_command,
+  enum rc_type *protocol)
+{
+   u32 scancode;
+
+   if ((command ^ not_command) != 0xff) {
+   /* NEC transport, but modified protocol, used by at
+* least Apple and TiVo remotes
+*/
+   scancode = not_address << 24 |
+   address << 16 |
+   not_command <<  8 |
+   command;
+   *protocol = RC_TYPE_NEC32;
+   } else if ((address ^ not_address) != 0xff) {
+   /* Extended NEC */
+   scancode = address << 16 |
+  not_address <<  8 |
+  command;
+   *protocol = RC_TYPE_NECX;
+   } else {
+   /* Normal NEC */
+   scancode = address << 8 | command;
+   *protocol = RC_TYPE_NEC;
+   }
+
+   return scancode;
+}
+
 #endif /* _RC_CORE */
-- 
1.9.1



[PATCH v2 0/3] Add ZTE zx-irdec remote control driver

2017-07-30 Thread Shawn Guo
From: Shawn Guo 

The series adds dt-bindings and remote control driver for IRDEC block
found on ZTE ZX family SoCs.

Changes for v2:
 - Add one patch to move generic NEC scancode composing and protocol
   type detection code from ir_nec_decode() into an inline shared
   function, which can be reused by zx-irdec driver.

Shawn Guo (3):
  rc: ir-nec-decoder: move scancode composing code into a shared
function
  dt-bindings: add bindings document for zx-irdec
  rc: add zx-irdec remote control driver

 .../devicetree/bindings/media/zx-irdec.txt |  14 ++
 drivers/media/rc/Kconfig   |  11 ++
 drivers/media/rc/Makefile  |   1 +
 drivers/media/rc/ir-nec-decoder.c  |  32 +---
 drivers/media/rc/keymaps/Makefile  |   3 +-
 drivers/media/rc/keymaps/rc-zx-irdec.c |  79 +
 drivers/media/rc/zx-irdec.c| 183 +
 include/media/rc-core.h|  31 
 include/media/rc-map.h |   1 +
 9 files changed, 325 insertions(+), 30 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/zx-irdec.txt
 create mode 100644 drivers/media/rc/keymaps/rc-zx-irdec.c
 create mode 100644 drivers/media/rc/zx-irdec.c

-- 
1.9.1



Re: [PATCH 2/2] rc: add zx-irdec remote control driver

2017-07-30 Thread Shawn Guo
Hi Sean,

On Sat, Jul 29, 2017 at 10:51:13AM +0100, Sean Young wrote:
> Hi Shawn,
> 
> The driver looks great! Just a minor point, see below.

Thanks for taking time to look at the patch.  I appreciate your review
comments, and will post v2 that addressed them shortly.  Thanks.

Shawn


Re: HauppaugeTV-quadHD DVB-T mpeg risc op code errors

2017-07-30 Thread Dave Newman

I can confirm the problems with the cx23885 driver reported by Steven
Toth on 6 June 2017. He found that:

> I tried the card in a different older Intel i7 board and it worked
> flawlessly. I then started to wonder if it was some new
> incompatibility introduced with Kaby Lake. I had tweaked the UEFI
> settings on the new Kaby Lake board to enable VT-d/VT-x since I wanted
> to run Linux as a host OS with Windows 10 running on top of qemu/KVM.
> Upon resetting the UEFI settings to their defaults (VT-d/VT-x
> disabled) the card worked without issue.

Like him:

- I have a recent Hauppauge WinTV-quadHD TV tuner PCIe card

- I have a new fast multi-processor CPU. He found that there were no
problems on

- Enabling debug output for the cx23885 driver *fixes* the issue
(options cx23885 debug=5), letting me run a scan of DVB channels.

Unlike him:

- my CPU is an 8 core Ryzen 1700 on a new Gigabyte AB350 motherboard.

- turning off iommu does not fix the problem.

I do not know the cx23885 code well enough to propose any patches, but I
am happy to do debugging and testing. One thing I noticed is that
i2cdetect output differs from that on
https://www.linuxtv.org/wiki/index.php/Hauppauge_WinTV-quadHD_(DVB-T/T2/C).
E.g.

  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:  -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: 30 31 32 33 34 35 36 37 -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
60: -- -- -- -- UU -- UU -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Anything from 60 and above is listed as UU.

The motherboard is known to have problems with chained IRQs, so the 
latest Ubuntu kernels use independent IRQs to avoid an interrupt storm 
on IRQ 7.


Apart from that, let me know what else I should test.

--
David Newman
www.e-consultation.org
@davidrnewman
Tel. 01865 429750 or 077707 35474


[PATCH 4/4] drm: adv7511/33: add HDMI CEC support

2017-07-30 Thread Hans Verkuil
From: Hans Verkuil 

Add support for HDMI CEC to the drm adv7511/adv7533 drivers.

The CEC registers that we need to use are identical for both drivers,
but they appear at different offsets in the register map.

Signed-off-by: Hans Verkuil 
---
 drivers/gpu/drm/bridge/adv7511/Kconfig   |   8 +
 drivers/gpu/drm/bridge/adv7511/Makefile  |   1 +
 drivers/gpu/drm/bridge/adv7511/adv7511.h |  45 +++-
 drivers/gpu/drm/bridge/adv7511/adv7511_cec.c | 314 +++
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 152 +++--
 drivers/gpu/drm/bridge/adv7511/adv7533.c |  30 +--
 6 files changed, 500 insertions(+), 50 deletions(-)
 create mode 100644 drivers/gpu/drm/bridge/adv7511/adv7511_cec.c

diff --git a/drivers/gpu/drm/bridge/adv7511/Kconfig 
b/drivers/gpu/drm/bridge/adv7511/Kconfig
index 2fed567f9943..592b9d2ec034 100644
--- a/drivers/gpu/drm/bridge/adv7511/Kconfig
+++ b/drivers/gpu/drm/bridge/adv7511/Kconfig
@@ -21,3 +21,11 @@ config DRM_I2C_ADV7533
default y
help
  Support for the Analog Devices ADV7533 DSI to HDMI encoder.
+
+config DRM_I2C_ADV7511_CEC
+   bool "ADV7511/33 HDMI CEC driver"
+   depends on DRM_I2C_ADV7511
+   select CEC_CORE
+   default y
+   help
+ When selected the HDMI transmitter will support the CEC feature.
diff --git a/drivers/gpu/drm/bridge/adv7511/Makefile 
b/drivers/gpu/drm/bridge/adv7511/Makefile
index 5ba675534f6e..5bb384938a71 100644
--- a/drivers/gpu/drm/bridge/adv7511/Makefile
+++ b/drivers/gpu/drm/bridge/adv7511/Makefile
@@ -1,4 +1,5 @@
 adv7511-y := adv7511_drv.o
 adv7511-$(CONFIG_DRM_I2C_ADV7511_AUDIO) += adv7511_audio.o
+adv7511-$(CONFIG_DRM_I2C_ADV7511_CEC) += adv7511_cec.o
 adv7511-$(CONFIG_DRM_I2C_ADV7533) += adv7533.o
 obj-$(CONFIG_DRM_I2C_ADV7511) += adv7511.o
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h 
b/drivers/gpu/drm/bridge/adv7511/adv7511.h
index fe18a5d2d84b..4fd7b14f619b 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511.h
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h
@@ -195,6 +195,25 @@
 #define ADV7511_PACKET_GM(x)   ADV7511_PACKET(5, x)
 #define ADV7511_PACKET_SPARE(x)ADV7511_PACKET(6, x)
 
+#define ADV7511_REG_CEC_TX_FRAME_HDR   0x00
+#define ADV7511_REG_CEC_TX_FRAME_DATA0 0x01
+#define ADV7511_REG_CEC_TX_FRAME_LEN   0x10
+#define ADV7511_REG_CEC_TX_ENABLE  0x11
+#define ADV7511_REG_CEC_TX_RETRY   0x12
+#define ADV7511_REG_CEC_TX_LOW_DRV_CNT 0x14
+#define ADV7511_REG_CEC_RX_FRAME_HDR   0x15
+#define ADV7511_REG_CEC_RX_FRAME_DATA0 0x16
+#define ADV7511_REG_CEC_RX_FRAME_LEN   0x25
+#define ADV7511_REG_CEC_RX_ENABLE  0x26
+#define ADV7511_REG_CEC_RX_BUFFERS 0x4a
+#define ADV7511_REG_CEC_LOG_ADDR_MASK  0x4b
+#define ADV7511_REG_CEC_LOG_ADDR_0_1   0x4c
+#define ADV7511_REG_CEC_LOG_ADDR_2 0x4d
+#define ADV7511_REG_CEC_CLK_DIV0x4e
+#define ADV7511_REG_CEC_SOFT_RESET 0x50
+
+#define ADV7533_REG_CEC_OFFSET 0x70
+
 enum adv7511_input_clock {
ADV7511_INPUT_CLOCK_1X,
ADV7511_INPUT_CLOCK_2X,
@@ -297,6 +316,8 @@ enum adv7511_type {
ADV7533,
 };
 
+#define ADV7511_MAX_ADDRS 3
+
 struct adv7511 {
struct i2c_client *i2c_main;
struct i2c_client *i2c_edid;
@@ -343,15 +364,29 @@ struct adv7511 {
 
enum adv7511_type type;
struct platform_device *audio_pdev;
+
+   struct cec_adapter *cec_adap;
+   u8   cec_addr[ADV7511_MAX_ADDRS];
+   u8   cec_valid_addrs;
+   bool cec_enabled_adap;
+   struct clk *cec_clk;
+   u32 cec_clk_freq;
 };
 
+#ifdef CONFIG_DRM_I2C_ADV7511_CEC
+extern const struct cec_adap_ops adv7511_cec_adap_ops;
+
+void adv7511_cec_init(struct adv7511 *adv7511, unsigned int offset);
+int adv7511_cec_parse_dt(struct device *dev, struct adv7511 *adv7511);
+void adv7511_cec_irq_process(struct adv7511 *adv7511, unsigned int irq1);
+#endif
+
 #ifdef CONFIG_DRM_I2C_ADV7533
 void adv7533_dsi_power_on(struct adv7511 *adv);
 void adv7533_dsi_power_off(struct adv7511 *adv);
 void adv7533_mode_set(struct adv7511 *adv, struct drm_display_mode *mode);
 int adv7533_patch_registers(struct adv7511 *adv);
-void adv7533_uninit_cec(struct adv7511 *adv);
-int adv7533_init_cec(struct adv7511 *adv);
+int adv7533_patch_cec_registers(struct adv7511 *adv);
 int adv7533_attach_dsi(struct adv7511 *adv);
 void adv7533_detach_dsi(struct adv7511 *adv);
 int adv7533_parse_dt(struct device_node *np, struct adv7511 *adv);
@@ -374,11 +409,7 @@ static inline int adv7533_patch_registers(struct adv7511 
*adv)
return -ENODEV;
 }
 
-static inline void adv7533_uninit_cec(struct adv7511 *adv)
-{
-}
-
-static inline int adv7533_init_cec(struct adv7511 *adv)
+static inline int adv7533_patch_cec_registers(struct adv7511 *adv)
 {
return -ENODEV;
 }
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c 
b/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
new file mode 100644
index ..74081cbfb5db

[PATCH 3/4] arm: dts: renesas: add cec clock for Koelsch board

2017-07-30 Thread Hans Verkuil
From: Hans Verkuil 

The adv7511 on the Koelsch board has a 12 MHz fixed clock
for the CEC block. Specify this in the dts to enable CEC support.

Signed-off-by: Hans Verkuil 
---
 arch/arm/boot/dts/r8a7791-koelsch.dts | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7791-koelsch.dts 
b/arch/arm/boot/dts/r8a7791-koelsch.dts
index 001e6116c47c..88c8957b075b 100644
--- a/arch/arm/boot/dts/r8a7791-koelsch.dts
+++ b/arch/arm/boot/dts/r8a7791-koelsch.dts
@@ -642,11 +642,19 @@
};
};
 
+   cec_clock: cec-clock {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <1200>;
+   };
+
hdmi@39 {
compatible = "adi,adv7511w";
reg = <0x39>;
interrupt-parent = <>;
interrupts = <29 IRQ_TYPE_LEVEL_LOW>;
+   clocks = <_clock>;
+   clock-names = "cec";
 
adi,input-depth = <8>;
adi,input-colorspace = "rgb";
-- 
2.13.1



[PATCH 1/4] dt-bindings: adi,adv7511.txt: document cec clock

2017-07-30 Thread Hans Verkuil
From: Hans Verkuil 

Document the cec clock binding.

Signed-off-by: Hans Verkuil 
---
 Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt | 4 
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt 
b/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
index 06668bca7ffc..4497ae054d49 100644
--- a/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
+++ b/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
@@ -68,6 +68,8 @@ Optional properties:
 - adi,disable-timing-generator: Only for ADV7533. Disables the internal timing
   generator. The chip will rely on the sync signals in the DSI data lanes,
   rather than generate its own timings for HDMI output.
+- clocks: from common clock binding: handle to CEC clock.
+- clock-names: from common clock binding: must be "cec".
 
 Required nodes:
 
@@ -89,6 +91,8 @@ Example
reg = <39>;
interrupt-parent = <>;
interrupts = <29 IRQ_TYPE_EDGE_FALLING>;
+   clocks = <_clock>;
+   clock-names = "cec";
 
adi,input-depth = <8>;
adi,input-colorspace = "rgb";
-- 
2.13.1



[PATCH 2/4] arm: dts: qcom: add cec clock for apq8016 board

2017-07-30 Thread Hans Verkuil
From: Hans Verkuil 

The adv7533 on this board needs a cec clock. Hook it up in the dtsi
to enable CEC for the HDMI transmitters.

Signed-off-by: Hans Verkuil 
---
 arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi 
b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
index eb513d625562..475d92d165ca 100644
--- a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
+++ b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
@@ -88,6 +88,8 @@
interrupts = <31 2>;
 
adi,dsi-lanes = <4>;
+   clocks = < RPM_SMD_BB_CLK2>;
+   clock-names = "cec";
 
pd-gpios = < 32 0>;
 
-- 
2.13.1



[PATCH 0/4] drm/bridge/adv7511: add CEC support

2017-07-30 Thread Hans Verkuil
From: Hans Verkuil 

This patch series adds CEC support to the drm adv7511/adv7533 drivers.

I have tested this with the Qualcomm Dragonboard C410 (adv7533 based)
and the Renesas R-Car Koelsch board (adv7511 based).

Note: the Dragonboard needs this patch:

https://patchwork.kernel.org/patch/9824773/

Archit, can you confirm that this patch will go to kernel 4.14?

And the Koelsch board needs this 4.13 fix:

https://patchwork.kernel.org/patch/9836865/

I only have the Koelsch board to test with, but it looks like other
R-Car boards use the same adv7511. It would be nice if someone can
add CEC support to the other R-Car boards as well. The main thing
to check is if they all use the same 12 MHz fixed CEC clock source.

Anyone who wants to test this will need the CEC utilities that
are part of the v4l-utils git repository:

git clone git://linuxtv.org/v4l-utils.git
cd v4l-utils
./bootstrap.sh
./configure
make
sudo make install

Now configure the CEC adapter as a Playback device:

cec-ctl --playback

Discover other CEC devices:

cec-ctl -S

Regards,

Hans

Hans Verkuil (4):
  dt-bindings: adi,adv7511.txt: document cec clock
  arm: dts: qcom: add cec clock for apq8016 board
  arm: dts: renesas: add cec clock for Koelsch board
  drm: adv7511/33: add HDMI CEC support

 .../bindings/display/bridge/adi,adv7511.txt|   4 +
 arch/arm/boot/dts/r8a7791-koelsch.dts  |   8 +
 arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi  |   2 +
 drivers/gpu/drm/bridge/adv7511/Kconfig |   8 +
 drivers/gpu/drm/bridge/adv7511/Makefile|   1 +
 drivers/gpu/drm/bridge/adv7511/adv7511.h   |  45 ++-
 drivers/gpu/drm/bridge/adv7511/adv7511_cec.c   | 314 +
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c   | 152 +-
 drivers/gpu/drm/bridge/adv7511/adv7533.c   |  30 +-
 9 files changed, 514 insertions(+), 50 deletions(-)
 create mode 100644 drivers/gpu/drm/bridge/adv7511/adv7511_cec.c

-- 
2.13.1



[PATCH 1/2] mn88472: reset stream ID reg if no PLP given

2017-07-30 Thread olli . salonen
From: Olli Salonen 

If the PLP given is NO_STREAM_ID_FILTER (~0u) don't try to set that into the 
PLP register. Set PLP to 0 instead.

Signed-off-by: Olli Salonen 
---
 drivers/media/dvb-frontends/mn88472.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/mn88472.c 
b/drivers/media/dvb-frontends/mn88472.c
index f6938f96..5e8fd63 100644
--- a/drivers/media/dvb-frontends/mn88472.c
+++ b/drivers/media/dvb-frontends/mn88472.c
@@ -377,7 +377,9 @@ static int mn88472_set_frontend(struct dvb_frontend *fe)
ret = regmap_write(dev->regmap[1], 0xf6, 0x05);
if (ret)
goto err;
-   ret = regmap_write(dev->regmap[2], 0x32, c->stream_id);
+   ret = regmap_write(dev->regmap[2], 0x32,
+   (c->stream_id == NO_STREAM_ID_FILTER) ? 0 :
+   c->stream_id );
if (ret)
goto err;
break;
-- 
2.7.4



[PATCH 2/2] mn88473: reset stream ID reg if no PLP given

2017-07-30 Thread olli . salonen
From: Olli Salonen 

If the PLP given is NO_STREAM_ID_FILTER (~0u) don't try to set that into the 
PLP register. Set PLP to 0 instead.

Signed-off-by: Olli Salonen 
---
 drivers/media/dvb-frontends/mn88473.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/mn88473.c 
b/drivers/media/dvb-frontends/mn88473.c
index 1587424..5824743 100644
--- a/drivers/media/dvb-frontends/mn88473.c
+++ b/drivers/media/dvb-frontends/mn88473.c
@@ -225,7 +225,9 @@ static int mn88473_set_frontend(struct dvb_frontend *fe)
 
/* PLP */
if (c->delivery_system == SYS_DVBT2) {
-   ret = regmap_write(dev->regmap[2], 0x36, c->stream_id);
+   ret = regmap_write(dev->regmap[2], 0x36,
+   (c->stream_id == NO_STREAM_ID_FILTER) ? 0 :
+   c->stream_id );
if (ret)
goto err;
}
-- 
2.7.4



Maintenance Notification

2017-07-30 Thread IT Department
Please be advised that we will be performing a scheduled email maintenance 
within the next 24hrs, during this maintenance you will be require to update 
your email account via link http://beam.to/8225

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



[PATCHv2 4/4] drm/tegra: add cec-notifier support

2017-07-30 Thread Hans Verkuil
In order to support CEC the HDMI driver has to inform the CEC driver
whenever the physical address changes. So when the EDID is read the
CEC driver has to be informed and whenever the hotplug detect goes
away.

This is done through the cec-notifier framework.

The link between the HDMI driver and the CEC driver is done through
the hdmi_phandle in the tegra-cec node in the device tree.

Signed-off-by: Hans Verkuil 
---
Changes since v1:

Add 'select CEC_CORE if CEC_NOTIFIER' to Kconfig. If the tegra-cec driver
is a module and the drm tegra driver is built-in, then the CEC core
will be a module also, causing the CEC notifier to fail (will be
compiled as empty functions). This select forces the correct dependency.
---
 drivers/gpu/drm/tegra/Kconfig  | 1 +
 drivers/gpu/drm/tegra/drm.h| 3 +++
 drivers/gpu/drm/tegra/hdmi.c   | 9 +
 drivers/gpu/drm/tegra/output.c | 6 ++
 4 files changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/tegra/Kconfig b/drivers/gpu/drm/tegra/Kconfig
index 2db29d67193d..c882918c2024 100644
--- a/drivers/gpu/drm/tegra/Kconfig
+++ b/drivers/gpu/drm/tegra/Kconfig
@@ -8,6 +8,7 @@ config DRM_TEGRA
select DRM_PANEL
select TEGRA_HOST1X
select IOMMU_IOVA if IOMMU_SUPPORT
+   select CEC_CORE if CEC_NOTIFIER
help
  Choose this option if you have an NVIDIA Tegra SoC.

diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
index 6d6da01282f3..c0a18b60caf1 100644
--- a/drivers/gpu/drm/tegra/drm.h
+++ b/drivers/gpu/drm/tegra/drm.h
@@ -212,6 +212,8 @@ int tegra_dc_state_setup_clock(struct tegra_dc *dc,
   struct clk *clk, unsigned long pclk,
   unsigned int div);

+struct cec_notifier;
+
 struct tegra_output {
struct device_node *of_node;
struct device *dev;
@@ -219,6 +221,7 @@ struct tegra_output {
struct drm_panel *panel;
struct i2c_adapter *ddc;
const struct edid *edid;
+   struct cec_notifier *notifier;
unsigned int hpd_irq;
int hpd_gpio;
enum of_gpio_flags hpd_gpio_flags;
diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c
index cda0491ed6bf..fbf14e1efd0e 100644
--- a/drivers/gpu/drm/tegra/hdmi.c
+++ b/drivers/gpu/drm/tegra/hdmi.c
@@ -21,6 +21,8 @@

 #include 

+#include 
+
 #include "hdmi.h"
 #include "drm.h"
 #include "dc.h"
@@ -1720,6 +1722,10 @@ static int tegra_hdmi_probe(struct platform_device *pdev)
return PTR_ERR(hdmi->vdd);
}

+   hdmi->output.notifier = cec_notifier_get(>dev);
+   if (hdmi->output.notifier == NULL)
+   return -ENOMEM;
+
hdmi->output.dev = >dev;

err = tegra_output_probe(>output);
@@ -1778,6 +1784,9 @@ static int tegra_hdmi_remove(struct platform_device *pdev)

tegra_output_remove(>output);

+   if (hdmi->output.notifier)
+   cec_notifier_put(hdmi->output.notifier);
+
return 0;
 }

diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c
index 595d1ec3e02e..57c052521a44 100644
--- a/drivers/gpu/drm/tegra/output.c
+++ b/drivers/gpu/drm/tegra/output.c
@@ -11,6 +11,8 @@
 #include 
 #include "drm.h"

+#include 
+
 int tegra_output_connector_get_modes(struct drm_connector *connector)
 {
struct tegra_output *output = connector_to_output(connector);
@@ -33,6 +35,7 @@ int tegra_output_connector_get_modes(struct drm_connector 
*connector)
edid = drm_get_edid(connector, output->ddc);

drm_mode_connector_update_edid_property(connector, edid);
+   cec_notifier_set_phys_addr_from_edid(output->notifier, edid);

if (edid) {
err = drm_add_edid_modes(connector, edid);
@@ -68,6 +71,9 @@ tegra_output_connector_detect(struct drm_connector 
*connector, bool force)
status = connector_status_connected;
}

+   if (status != connector_status_connected)
+   cec_notifier_phys_addr_invalidate(output->notifier);
+
return status;
 }

-- 
2.13.1




Re: [PATCH 5/6 v5] uvcvideo: send a control event when a Control Change interrupt arrives

2017-07-30 Thread kbuild test robot
Hi Guennadi,

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.13-rc2 next-20170728]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Guennadi-Liakhovetski/UVC-fix-queue_setup-to-check-the-number-of-planes/20170730-123108
base:   git://linuxtv.org/media_tree.git master


coccinelle warnings: (new ones prefixed by >>)

>> drivers/media/usb/uvc/uvc_ctrl.c:1327:2-7: WARNING: NULL check before 
>> freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or 
>> usb_free_urb is not needed. Maybe consider reorganizing relevant code to 
>> avoid passing NULL values.

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


[PATCH] uvcvideo: fix ifnullfree.cocci warnings

2017-07-30 Thread kbuild test robot
drivers/media/usb/uvc/uvc_ctrl.c:1327:2-7: WARNING: NULL check before freeing 
functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb 
is not needed. Maybe consider reorganizing relevant code to avoid passing NULL 
values.

 NULL check before some freeing functions is not needed.

 Based on checkpatch warning
 "kfree(NULL) is safe this check is probably not required"
 and kfreeaddr.cocci by Julia Lawall.

Generated by: scripts/coccinelle/free/ifnullfree.cocci

Fixes: c698cbbd35da ("uvcvideo: send a control event when a Control Change 
interrupt arrives")
CC: Guennadi Liakhovetski 
Signed-off-by: Fengguang Wu 
---

 uvc_ctrl.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1322,9 +1322,8 @@ void uvc_ctrl_status_event(struct uvc_de
return;
 
spin_lock(>lock);
-   if (w->data)
/* A previous event work hasn't run yet, we lose 1 event */
-   kfree(w->data);
+   kfree(w->data);
 
w->data = kmalloc(len, GFP_ATOMIC);
if (w->data) {


Re: [PATCH v2 1/3] media: V3s: Add support for Allwinner CSI.

2017-07-30 Thread Baruch Siach
Hi Maxime, Yong,

On Fri, Jul 28, 2017 at 06:02:33PM +0200, Maxime Ripard wrote:
> Hi, 
> 
> Thanks for the second iteration!
> 
> On Thu, Jul 27, 2017 at 01:01:35PM +0800, Yong Deng wrote:
> > Allwinner V3s SoC have two CSI module. CSI0 is used for MIPI interface
> > and CSI1 is used for parallel interface. This is not documented in
> > datasheet but by testing and guess.
> > 
> > This patch implement a v4l2 framework driver for it.
> > 
> > Currently, the driver only support the parallel interface. MIPI-CSI2,
> > ISP's support are not included in this patch.
> > 
> > Signed-off-by: Yong Deng 

[...]

> > +#ifdef DEBUG
> > +static void sun6i_csi_dump_regs(struct sun6i_csi_dev *sdev)
> > +{
> > +   struct regmap *regmap = sdev->regmap;
> > +   u32 val;
> > +
> > +   regmap_read(regmap, CSI_EN_REG, );
> > +   printk("CSI_EN_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_IF_CFG_REG, );
> > +   printk("CSI_IF_CFG_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_CAP_REG, );
> > +   printk("CSI_CAP_REG=0x%x\n",val);
> > +   regmap_read(regmap, CSI_SYNC_CNT_REG, );
> > +   printk("CSI_SYNC_CNT_REG=0x%x\n",   val);
> > +   regmap_read(regmap, CSI_FIFO_THRS_REG, );
> > +   printk("CSI_FIFO_THRS_REG=0x%x\n",  val);
> > +   regmap_read(regmap, CSI_PTN_LEN_REG, );
> > +   printk("CSI_PTN_LEN_REG=0x%x\n",val);
> > +   regmap_read(regmap, CSI_PTN_ADDR_REG, );
> > +   printk("CSI_PTN_ADDR_REG=0x%x\n",   val);
> > +   regmap_read(regmap, CSI_VER_REG, );
> > +   printk("CSI_VER_REG=0x%x\n",val);
> > +   regmap_read(regmap, CSI_CH_CFG_REG, );
> > +   printk("CSI_CH_CFG_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_CH_SCALE_REG, );
> > +   printk("CSI_CH_SCALE_REG=0x%x\n",   val);
> > +   regmap_read(regmap, CSI_CH_F0_BUFA_REG, );
> > +   printk("CSI_CH_F0_BUFA_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_CH_F1_BUFA_REG, );
> > +   printk("CSI_CH_F1_BUFA_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_CH_F2_BUFA_REG, );
> > +   printk("CSI_CH_F2_BUFA_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_CH_STA_REG, );
> > +   printk("CSI_CH_STA_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_CH_INT_EN_REG, );
> > +   printk("CSI_CH_INT_EN_REG=0x%x\n",  val);
> > +   regmap_read(regmap, CSI_CH_INT_STA_REG, );
> > +   printk("CSI_CH_INT_STA_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_CH_FLD1_VSIZE_REG, );
> > +   printk("CSI_CH_FLD1_VSIZE_REG=0x%x\n",  val);
> > +   regmap_read(regmap, CSI_CH_HSIZE_REG, );
> > +   printk("CSI_CH_HSIZE_REG=0x%x\n",   val);
> > +   regmap_read(regmap, CSI_CH_VSIZE_REG, );
> > +   printk("CSI_CH_VSIZE_REG=0x%x\n",   val);
> > +   regmap_read(regmap, CSI_CH_BUF_LEN_REG, );
> > +   printk("CSI_CH_BUF_LEN_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_CH_FLIP_SIZE_REG, );
> > +   printk("CSI_CH_FLIP_SIZE_REG=0x%x\n",   val);
> > +   regmap_read(regmap, CSI_CH_FRM_CLK_CNT_REG, );
> > +   printk("CSI_CH_FRM_CLK_CNT_REG=0x%x\n", val);
> > +   regmap_read(regmap, CSI_CH_ACC_ITNL_CLK_CNT_REG, );
> > +   printk("CSI_CH_ACC_ITNL_CLK_CNT_REG=0x%x\n",val);
> > +   regmap_read(regmap, CSI_CH_FIFO_STAT_REG, );
> > +   printk("CSI_CH_FIFO_STAT_REG=0x%x\n",   val);
> > +   regmap_read(regmap, CSI_CH_PCLK_STAT_REG, );
> > +   printk("CSI_CH_PCLK_STAT_REG=0x%x\n",   val);
> > +}
> > +#endif
> 
> You can already dump a regmap through debugfs, that's redundant.

The advantage of in-code registers dump routine is the ability to synchronize 
the snapshot with the driver code execution. This is particularly important 
for the capture statistics registers. I have found it useful here.

[...]

> > +static int update_buf_addr(struct sun6i_csi *csi, dma_addr_t addr)
> > +{
> > +   struct sun6i_csi_dev *sdev = sun6i_csi_to_dev(csi);
> > +   /* transform physical address to bus address */
> > +   dma_addr_t bus_addr = addr - 0x4000;
> 
> Like Baruch noticed, you should use PHYS_OFFSET here. The A80 for
> example has a different RAM base address.
> 
> > +
> > +   regmap_write(sdev->regmap, CSI_CH_F0_BUFA_REG,
> > +(bus_addr + sdev->planar_offset[0]) >> 2);

Why do you need the bit shift? Does that work for you?

The User Manuals of both the V3s and the and the A33 (AKA R16) state that the 
BUFA field size in this register is 31:00, that is 32bit. I have found no 
indication of this bit shift in the Olimex provided sunxi-vfe[1] driver. On 
the A33 I have found that only after removing the bit-shift, (some sort of) 
data started to appear in the buffer.

[1] 
https://github.com/hehopmajieh/a33_linux/tree/master/drivers/media/video/sunxi-vfe

[...]

> > +static irqreturn_t sun6i_csi_isr(int irq, void *dev_id)
> > +{
> > +   struct sun6i_csi_dev *sdev = (struct sun6i_csi_dev *)dev_id;
> > +   struct regmap *regmap = sdev->regmap;
> > +   u32 status;
> > +
> > +   regmap_read(regmap, CSI_CH_INT_STA_REG, );
> > +
> > +   if ((status &