cron job: media_tree daily build: ERRORS

2017-08-01 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:   Wed Aug  2 05:00:16 CEST 2017
media-tree git hash:da48c948c263c9d87dfc64566b3373a858cc8aa2
media_build git hash:   f01a9176bb03f22e3cd3b70282bd7fd272e504ae
v4l-utils git hash: 98c162029eb1a21b39028180ac5d36b544a9493c
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: WARNINGS
linux-3.15.2-i686: WARNINGS
linux-3.16.7-i686: WARNINGS
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: OK
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: WARNINGS
linux-3.15.2-x86_64: WARNINGS
linux-3.16.7-x86_64: WARNINGS
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: WARNINGS
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/Wednesday.log

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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


[PATCH v5 0/6] Add Rockchip RGA V4l2 support

2017-08-01 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 work well.

change in V5:
- v4l2-compliance: handle invalid pxielformat 
- v4l2-compliance: add subscribe_event
- add colorspace support

change in V4:
- document the controls.
- change according to Hans's comments

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 (6):
  v4l: add portduff blend modes
  extended-controls.rst: add PorterDuff mode control
  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 +
 Documentation/media/uapi/v4l/extended-controls.rst |5 +
 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  |  155 +++
 drivers/media/platform/rockchip-rga/rga-hw.c   |  671 +
 drivers/media/platform/rockchip-rga/rga-hw.h   |  437 +
 drivers/media/platform/rockchip-rga/rga.c  | 1024 
 drivers/media/platform/rockchip-rga/rga.h  |  110 +++
 drivers/media/v4l2-core/v4l2-ctrls.c   |   20 +-
 include/uapi/linux/v4l2-controls.h |   20 +-
 14 files changed, 2511 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 v5 2/6] extended-controls.rst: add PorterDuff mode control

2017-08-01 Thread Jacob Chen
PorterDuff mode control are used to determine
how two images are combined.

Signed-off-by: Jacob Chen 
---
 Documentation/media/uapi/v4l/extended-controls.rst | 5 +
 1 file changed, 5 insertions(+)

diff --git a/Documentation/media/uapi/v4l/extended-controls.rst 
b/Documentation/media/uapi/v4l/extended-controls.rst
index abb1057..b713581 100644
--- a/Documentation/media/uapi/v4l/extended-controls.rst
+++ b/Documentation/media/uapi/v4l/extended-controls.rst
@@ -3021,6 +3021,11 @@ Image Process Control IDs
 The video deinterlacing mode (such as Bob, Weave, ...). The menu items are
 driver specific and are documented in :ref:`v4l-drivers`.
 
+``V4L2_CID_PORTER_DUFF_MODE (menu)``
+The PorterDuff blend modes. PorterDuff is a method to overlay, combine and
+trim images as if they were pieces of cardboard. The device uses this to
+determine how two images are combined. For more information see
+`PorterDuff.Mode 
`__.
 
 .. _dv-controls:
 
-- 
2.7.4



[PATCH v5 1/6] v4l: add portduff blend modes

2017-08-01 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   | 20 +++-
 2 files changed, 38 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..986a02b6 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -893,7 +893,25 @@ 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)
+/*
+ * For details: see
+ * 
https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html
+ */
+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 v5 4/6] ARM: dts: rockchip: add RGA device node for RK3288

2017-08-01 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 v5 3/6] rockchip/rga: v4l2 m2m support

2017-08-01 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 according to operations
The code in rga-buf.c is used to create private mmu table for RGA.

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 |  155 
 drivers/media/platform/rockchip-rga/rga-hw.c  |  671 
 drivers/media/platform/rockchip-rga/rga-hw.h  |  437 +++
 drivers/media/platform/rockchip-rga/rga.c | 1024 +
 drivers/media/platform/rockchip-rga/rga.h |  110 +++
 8 files changed, 2413 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..6a9fd2c
--- /dev/null
+++ b/drivers/media/platform/rockchip-rga/rga-buf.c
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2017 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);
+
+   if (*nplanes)
+   return sizes[0] < f->size ? -EINVAL : 0;
+
+   sizes[0] = f->size;
+   *nplanes = 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 void rga_buf_queue(struct vb2_buffer *vb)

[PATCH v5 6/6] dt-bindings: Document the Rockchip RGA bindings

2017-08-01 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



[PATCH v5 5/6] ARM: dts: rockchip: add RGA device node for RK3399

2017-08-01 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



Re: [PATCH v4 3/6] [media] rockchip/rga: v4l2 m2m support

2017-08-01 Thread Jacob Chen
Hi Hans,

2017-08-01 0:18 GMT+08:00 Hans Verkuil :
> On 07/31/2017 05:32 PM, Jacob Chen wrote:
>> 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 according to operations
>> The code in rga-buf.c is used to create private mmu table for RGA.
>>
>> 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 | 155 
>>  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 | 980 
>> ++
>>  drivers/media/platform/rockchip-rga/rga.h | 109 +++
>>  8 files changed, 2347 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/rockchip-rga/rga.c 
>> b/drivers/media/platform/rockchip-rga/rga.c
>> new file mode 100644
>> index 000..0c0bc4b
>> --- /dev/null
>> +++ b/drivers/media/platform/rockchip-rga/rga.c
>> @@ -0,0 +1,980 @@
>> +/*
>> + * 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 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include "rga-hw.h"
>> +#include "rga.h"
>> +
>> +static void job_abort(void *prv)
>> +{
>> + struct rga_ctx *ctx = prv;
>> + struct rockchip_rga *rga = ctx->rga;
>> +
>> + if (rga->curr == NULL)  /* No job currently running */
>> + return;
>> +
>> + wait_event_timeout(rga->irq_queue,
>> +rga->curr == NULL, msecs_to_jiffies(RGA_TIMEOUT));
>> +}
>> +
>> +static void device_run(void *prv)
>> +{
>> + struct rga_ctx *ctx = prv;
>> + struct rockchip_rga *rga = ctx->rga;
>> + struct vb2_buffer *src, *dst;
>> + unsigned long flags;
>> +
>> + spin_lock_irqsave(>ctrl_lock, flags);
>> +
>> + rga->curr = ctx;
>> +
>> + src = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
>> + dst = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
>> +
>> + rga_buf_map(src);
>> + rga_buf_map(dst);
>> +
>> + rga_cmd_set(ctx);
>> +
>> + rga_start(rga);
>> +
>> + spin_unlock_irqrestore(>ctrl_lock, flags);
>> +}
>> +
>> +static irqreturn_t rga_isr(int irq, void *prv)
>> +{
>> + struct rockchip_rga *rga = prv;
>> + int intr;
>> +
>> + intr = rga_read(rga, RGA_INT) & 0xf;
>> +
>> + rga_mod(rga, RGA_INT, intr << 4, 0xf << 4);
>> +
>> + if (intr & 0x04) {
>> + struct vb2_v4l2_buffer *src, *dst;
>> + struct rga_ctx *ctx = rga->curr;
>> +
>> + BUG_ON(ctx == NULL);
>> +
>> + rga->curr = NULL;
>> +
>> + src = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
>> + dst = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
>> +
>> + BUG_ON(src == NULL);
>> + BUG_ON(dst == NULL);
>> +
>> + dst->timecode = src->timecode;
>> + dst->vb2_buf.timestamp = src->vb2_buf.timestamp;
>> + dst->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
>> + dst->flags |= src->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
>> +
>> + v4l2_m2m_buf_done(src, VB2_BUF_STATE_DONE);
>> + v4l2_m2m_buf_done(dst, VB2_BUF_STATE_DONE);
>> + v4l2_m2m_job_finish(rga->m2m_dev, ctx->fh.m2m_ctx);
>> +
>> + wake_up(>irq_queue);

Re: [PATCH v1 0/4] media: rc: add support for IR receiver on MT7622 SoC

2017-08-01 Thread Sean Wang

Hi, Mauro and Sean

Just a gentle ping on the whole patchset porting MediaTek CIR to another
platform.

Sean


On Tue, 2017-07-04 at 19:10 +0900, Andi Shyti wrote:
> Hi Sean,
> 
> > This patchset introduces Consumer IR (CIR) support for MT7622 SoC
> > implements raw mode for more compatibility with different protocols
> > as previously SoC did. Before adding support to MT7622 SoC, extra
> > code refactor is done since there're major differences in register and
> > field definition from the previous SoC.
> > 
> > Sean Wang (4):
> >   dt-bindings: media: mtk-cir: Add support for MT7622 SoC
> >   media: rc: mtk-cir: add platform data to adapt into various hardware
> >   media: rc: mtk-cir: add support for MediaTek MT7622 SoC
> >   MAINTAINERS: add entry for MediaTek CIR driver
> 
> for the whole patchset:
> 
> Reviewed-by: Andi Shyti 
> 
> Andi




Re: [PATCH 19/19] lirc_dev: consistent device registration printk

2017-08-01 Thread Sean Young
On Sun, Jun 25, 2017 at 02:32:51PM +0200, David Härdeman wrote:
> This patch changes the message that is printed on lirc device registration to
> make it more consistent with the input and rc subsystems.
> 
> Before:
>   rc rc0: rc-core loopback device as /devices/virtual/rc/rc0
>   input: rc-core loopback device as /devices/virtual/rc/rc0/input43
>   lirc lirc0: lirc_dev: driver ir-lirc-codec (rc-loopback) registered at 
> minor = 0
> 
> After:
>   rc rc0: rc-core loopback device as /devices/virtual/rc/rc0
>   input: rc-core loopback device as /devices/virtual/rc/rc0/input23
>   lirc lirc0: rc-core loopback device as /devices/virtual/rc/rc0/lirc0

There is a couple of problems with this.

1. lirc_dev name is 40 bytes, but rc_dev input_name has no limit, so it ends
up truncating which you don't want. For example:

[  106.303589] rc rc2: IguanaWorks USB IR Transceiver version 0x0308 as 
/devices/pci:00/:00:1a.1/usb4/4-2/4-2.3/4-2.3:1.0/rc/rc2
[  106.303664] input: IguanaWorks USB IR Transceiver version 0x0308 as 
/devices/pci:00/:00:1a.1/usb4/4-2/4-2.3/4-2.3:1.0/rc/rc2/input24
[  106.307272] lirc lirc2: IguanaWorks USB IR Transceiver version  as 
/devices/pci:00/:00:1a.1/usb4/4-2/4-2.3/4-2.3:1.0/rc/rc2/lirc2
[  233.005834] rc rc2: Media Center Ed. eHome Infrared Remote Transceiver 
(0609:031d) as /devices/pci:00/:00:1a.1/usb4/4-2/4-2.3/4-2.3:1.0/rc/rc2
[  233.005907] input: Media Center Ed. eHome Infrared Remote Transceiver 
(0609:031d) as 
/devices/pci:00/:00:1a.1/usb4/4-2/4-2.3/4-2.3:1.0/rc/rc2/input25
[  233.006307] lirc lirc2: Media Center Ed. eHome Infrared Remote  as 
/devices/pci:00/:00:1a.1/usb4/4-2/4-2.3/4-2.3:1.0/rc/rc2/lirc2

2. Documentation/media/uapi/rc/lirc-dev-intro.rst explicitly mentions this 
message, so that will need updating too. On a related note, should we be
changing messages, esp. documented ones? I agree the original message is
a bit ugly.

3. I like have the driver name in the message. As you can see above, you
have no idea you're plugging in an mceusb device (iguanair is a bit
more obvious). Then again none of the other messages mention this, maybe
it be added there.

As it is the patch can't be applied.

Maybe lirc_dev name can be changed to const char* so we avoid the strcpy
and truncation.


Sean

> 
> Signed-off-by: David Härdeman 
> ---
>  drivers/media/rc/ir-lirc-codec.c |3 +--
>  drivers/media/rc/lirc_dev.c  |6 --
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/rc/ir-lirc-codec.c 
> b/drivers/media/rc/ir-lirc-codec.c
> index 05f88401f694..4f33516a95a3 100644
> --- a/drivers/media/rc/ir-lirc-codec.c
> +++ b/drivers/media/rc/ir-lirc-codec.c
> @@ -595,8 +595,7 @@ static int ir_lirc_register(struct rc_dev *dev)
>   if (dev->max_timeout)
>   features |= LIRC_CAN_SET_REC_TIMEOUT;
>  
> - snprintf(ldev->name, sizeof(ldev->name), "ir-lirc-codec (%s)",
> -  dev->driver_name);
> + snprintf(ldev->name, sizeof(ldev->name), "%s", dev->input_name);
>   ldev->features = features;
>   ldev->data = >raw->lirc;
>   ldev->buf = NULL;
> diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
> index c1c917932f7e..03430a1fb192 100644
> --- a/drivers/media/rc/lirc_dev.c
> +++ b/drivers/media/rc/lirc_dev.c
> @@ -105,6 +105,7 @@ int lirc_register_device(struct lirc_dev *d)
>  {
>   int minor;
>   int err;
> + const char *path;
>  
>   if (!d) {
>   pr_err("driver pointer must be not NULL!\n");
> @@ -171,8 +172,9 @@ int lirc_register_device(struct lirc_dev *d)
>   return err;
>   }
>  
> - dev_info(>dev, "lirc_dev: driver %s registered at minor = %d\n",
> -  d->name, d->minor);
> + path = kobject_get_path(>dev.kobj, GFP_KERNEL);
> + dev_info(>dev, "%s as %s\n", d->name, path ?: "N/A");
> + kfree(path);
>  
>   return 0;
>  }


Re: [PATCH v2 12/14] drm: rcar-du: Support multiple sources from the same VSP

2017-08-01 Thread Laurent Pinchart
Hi Kieran,

On Tuesday 01 Aug 2017 19:10:20 Kieran Bingham wrote:
> On 26/06/17 19:12, Laurent Pinchart wrote:
> > On R-Car H3 ES2.0, DU channels 0 and 3 are served by two separate
> > pipelines from the same VSP. Support this in the DU driver.
> > 
> > Signed-off-by: Laurent Pinchart
> > 
> 
> This looks good to me.
> 
> Minor nit / comment can be safely ignored. Mostly just me thinking outload.
> 
> Reviewed-by: Kieran Bingham 
> 
> > ---
> > 
> >  drivers/gpu/drm/rcar-du/rcar_du_crtc.c |  2 +-
> >  drivers/gpu/drm/rcar-du/rcar_du_crtc.h |  3 ++
> >  drivers/gpu/drm/rcar-du/rcar_du_kms.c  | 91 +
> >  drivers/gpu/drm/rcar-du/rcar_du_vsp.c  | 37 +++---
> >  drivers/gpu/drm/rcar-du/rcar_du_vsp.h  | 10 +++-
> >  5 files changed, 110 insertions(+), 33 deletions(-)

[snip]

> > diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> > b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index f4125c8ca902..82b978a5dae6
> > 100644
> > --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> > +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> > @@ -432,6 +432,83 @@ static int rcar_du_properties_init(struct
> > rcar_du_device *rcdu)
> > return 0;
> >  }
> > 
> > +static int rcar_du_vsps_init(struct rcar_du_device *rcdu)
> > +{
> > +   const struct device_node *np = rcdu->dev->of_node;
> > +   struct of_phandle_args args;
> > +   struct {
> > +   struct device_node *np;
> > +   unsigned int crtcs_mask;
> > +   } vsps[RCAR_DU_MAX_VSPS] = { { 0, }, };
> > +   unsigned int vsps_count = 0;
> > +   unsigned int cells;
> > +   unsigned int i;
> > +   int ret;
> > +
> > +   /*
> > +* First parse the DT vsps property to populate the list of VSPs. Each
> > +* entry contains a pointer to the VSP DT node and a bitmask of the
> > +* connected DU CRTCs.
> > +*/
> > +   cells = of_property_count_u32_elems(np, "vsps") / rcdu->num_crtcs - 1;
> > +   if (cells > 1)
> > +   return -EINVAL;
> > +
> > +   for (i = 0; i < rcdu->num_crtcs; ++i) {
> > +   unsigned int j;
> > +
> > +   ret = of_parse_phandle_with_fixed_args(np, "vsps", cells, i,
> > +  );
> > +   if (ret < 0)
> > +   goto error;
> > +
> > +   /*
> > +* Add the VSP to the list or update the corresponding
> > existing
> > +* entry if the VSP has already been added.
> > +*/
> > +   for (j = 0; j < vsps_count; ++j) {
> > +   if (vsps[j].np == args.np)
> > +   break;
> > +   }
> > +
> > +   if (j < vsps_count)
> > +   of_node_put(args.np);
> > +   else
> > +   vsps[vsps_count++].np = args.np;
> > +
> > +   vsps[j].crtcs_mask |= 1 << i;
> 
> I do love the BIT(x) macro personally - but it's not important :)

I wonder why I don't like the BIT macro. There's probably no good reason.

> > +
> > +   /* Store the VSP pointer and pipe index in the CRTC. */
> > +   rcdu->crtcs[i].vsp = >vsps[j];
> > +   rcdu->crtcs[i].vsp_pipe = cells >= 1 ? args.args[0] : 0;
> > +   }
> > +
> > +   /*
> > +* Then initialize all the VSPs from the node pointers and CRTCs
> > bitmask
> > +* computed previously.
> > +*/
> > +   for (i = 0; i < vsps_count; ++i) {
> > +   struct rcar_du_vsp *vsp = >vsps[i];
> > +
> > +   vsp->index = i;
> > +   vsp->dev = rcdu;
> > +
> > +   ret = rcar_du_vsp_init(vsp, vsps[i].np, vsps[i].crtcs_mask);
> > +   if (ret < 0)
> > +   goto error;
> > +   }
> > +
> > +   return 0;
> > +
> > +error:
> > +   for (i = 0; i < ARRAY_SIZE(vsps); ++i) {
> > +   if (vsps[i].np)
> 
> Minor nit: of_node_put already has NULL protection so we don't need this
> 'if' but it probably does make it clearer that we are only putting back
> nodes that we collected.

It's a good point, I'll remove the check.

> > +   of_node_put(vsps[i].np);
> > +   }
> > +
> > +   return ret;
> > +}

[snip]

-- 
Regards,

Laurent Pinchart



Re: [PATCH v2 11/14] v4l: vsp1: Add support for header display lists in continuous mode

2017-08-01 Thread Laurent Pinchart
Hi Kieran,

On Tuesday 01 Aug 2017 18:35:48 Kieran Bingham wrote:
> On 26/06/17 19:12, Laurent Pinchart wrote:
> > The VSP supports both header and headerless display lists. The latter is
> > easier to use when the VSP feeds data directly to the DU in continuous
> > mode, and the driver thus uses headerless display lists for DU operation
> > and header display lists otherwise.
> > 
> > Headerless display lists are only available on WPF.0. This has never
> > been an issue so far, as only WPF.0 is connected to the DU. However, on
> > H3 ES2.0, the VSP-DL instance has both WPF.0 and WPF.1 connected to the
> > DU. We thus can't use headerless display lists unconditionally for DU
> > operation.
> 
> Would it be crazy to suggest we drop headerless display lists?
> 
> If we must support header display lists in continuous mode - Rather than
> having 2 cases for continuous modes to support (having to support
> headerless, on WPF.0, and header on WPF.1) if we just use your header loop
> trick - would that simplify our code maintenance?
> 
> (We can always remove headerless support later if you agree, this is more of
> an idea at the moment)

I had the exact same thought, but I believe we should wait a few kernel 
releases to see if the next code is stable before removing the old one. I have 
a debug patch that forces usage of header display lists unconditionally, and 
I'll try to develop a few additional stress-tests for that.

> > Implement support for continuous mode with header display lists, and use
> > it for DU operation on WPF outputs that don't support headerless mode.
> > 
> > Signed-off-by: Laurent Pinchart
> > 
> 
> Except for future discussion points, I can't see anything wrong here so:
> 
> Reviewed-by: Kieran Bingham 
> 
> > ---
> > 
> >  drivers/media/platform/vsp1/vsp1_dl.c   | 195 +-
> >  drivers/media/platform/vsp1/vsp1_regs.h |   1 +
> >  2 files changed, 127 insertions(+), 69 deletions(-)

-- 
Regards,

Laurent Pinchart



Re: [PATCH v2 10/14] v4l: vsp1: Add support for multiple DRM pipelines

2017-08-01 Thread Kieran Bingham
Hi Laurent,

Last one - (and I thought I'd already done this one in the last batch .. but
perhaps I lost it before hitting send)

On 26/06/17 19:12, Laurent Pinchart wrote:
> The R-Car H3 ES2.0 VSP-DL instance has two LIF entities and can drive
> two display pipelines at the same time. Refactor the VSP DRM code to
> support that by introducing a vsp_drm_pipeline object that models one
> display pipeline.
> 
> Signed-off-by: Laurent Pinchart 

I can't see anything wrong here, so maybe my eyes are going fuzzy from all the
blue text in my mail client :-)

Reviewed-by: Kieran Bingham 

> ---
>  drivers/media/platform/vsp1/vsp1_drm.c | 200 
> -
>  drivers/media/platform/vsp1/vsp1_drm.h |  35 +++---
>  2 files changed, 141 insertions(+), 94 deletions(-)
> 
> diff --git a/drivers/media/platform/vsp1/vsp1_drm.c 
> b/drivers/media/platform/vsp1/vsp1_drm.c
> index 4e1b893e8f51..7791d7b5a743 100644
> --- a/drivers/media/platform/vsp1/vsp1_drm.c
> +++ b/drivers/media/platform/vsp1/vsp1_drm.c
> @@ -34,10 +34,10 @@
>  
>  static void vsp1_du_pipeline_frame_end(struct vsp1_pipeline *pipe)
>  {
> - struct vsp1_drm *drm = to_vsp1_drm(pipe);
> + struct vsp1_drm_pipeline *drm_pipe = to_vsp1_drm_pipeline(pipe);
>  
> - if (drm->du_complete)
> - drm->du_complete(drm->du_private);
> + if (drm_pipe->du_complete)
> + drm_pipe->du_complete(drm_pipe->du_private);
>  }
>  
>  /* 
> -
> @@ -80,15 +80,22 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int 
> pipe_index,
> const struct vsp1_du_lif_config *cfg)
>  {
>   struct vsp1_device *vsp1 = dev_get_drvdata(dev);
> - struct vsp1_pipeline *pipe = >drm->pipe;
> - struct vsp1_bru *bru = vsp1->bru;
> + struct vsp1_drm_pipeline *drm_pipe;
> + struct vsp1_pipeline *pipe;
> + struct vsp1_bru *bru;
>   struct v4l2_subdev_format format;
> + const char *bru_name;
>   unsigned int i;
>   int ret;
>  
> - if (pipe_index > 0)
> + if (pipe_index >= vsp1->info->lif_count)
>   return -EINVAL;
>  
> + drm_pipe = >drm->pipe[pipe_index];
> + pipe = _pipe->pipe;
> + bru = to_bru(>bru->subdev);
> + bru_name = pipe->bru->type == VSP1_ENTITY_BRU ? "BRU" : "BRS";
> +
>   if (!cfg) {
>   /*
>* NULL configuration means the CRTC is being disabled, stop
> @@ -100,14 +107,25 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int 
> pipe_index,
>  
>   media_pipeline_stop(>output->entity.subdev.entity);
>  
> - for (i = 0; i < bru->entity.source_pad; ++i) {
> - vsp1->drm->inputs[i].enabled = false;
> - bru->inputs[i].rpf = NULL;
> + for (i = 0; i < ARRAY_SIZE(pipe->inputs); ++i) {
> + struct vsp1_rwpf *rpf = pipe->inputs[i];
> +
> + if (!rpf)
> + continue;
> +
> + /*
> +  * Remove the RPF from the pipe and the list of BRU
> +  * inputs.
> +  */
> + WARN_ON(list_empty(>entity.list_pipe));
> + list_del_init(>entity.list_pipe);
>   pipe->inputs[i] = NULL;
> +
> + bru->inputs[rpf->bru_input].rpf = NULL;
>   }
>  
> + drm_pipe->du_complete = NULL;
>   pipe->num_inputs = 0;
> - vsp1->drm->du_complete = NULL;
>  
>   vsp1_dlm_reset(pipe->output->dlm);
>   vsp1_device_put(vsp1);
> @@ -117,8 +135,8 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int 
> pipe_index,
>   return 0;
>   }
>  
> - dev_dbg(vsp1->dev, "%s: configuring LIF with format %ux%u\n",
> - __func__, cfg->width, cfg->height);
> + dev_dbg(vsp1->dev, "%s: configuring LIF%u with format %ux%u\n",
> + __func__, pipe_index, cfg->width, cfg->height);
>  
>   /*
>* Configure the format at the BRU sinks and propagate it through the
> @@ -127,7 +145,7 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int 
> pipe_index,
>   memset(, 0, sizeof(format));
>   format.which = V4L2_SUBDEV_FORMAT_ACTIVE;
>  
> - for (i = 0; i < bru->entity.source_pad; ++i) {
> + for (i = 0; i < pipe->bru->source_pad; ++i) {
>   format.pad = i;
>  
>   format.format.width = cfg->width;
> @@ -135,60 +153,60 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int 
> pipe_index,
>   format.format.code = MEDIA_BUS_FMT_ARGB_1X32;
>   format.format.field = V4L2_FIELD_NONE;
>  
> - ret = v4l2_subdev_call(>entity.subdev, pad,
> + ret = v4l2_subdev_call(>bru->subdev, pad,
>  

Re: [PATCH v2 13/14] drm: rcar-du: Restrict DPLL duty cycle workaround to H3 ES1.x

2017-08-01 Thread Laurent Pinchart
Hi Kieran,

On Tuesday 01 Aug 2017 15:06:20 Kieran Bingham wrote:
> On 26/06/17 19:12, Laurent Pinchart wrote:
> > The H3 ES1.x exhibits dot clock duty cycle stability issues. We can work
> > around them by configuring the DPLL to twice the desired frequency,
> > coupled with a /2 post-divider. This isn't needed on other SoCs and
> > breaks HDMI output on M3-W for a currently unknown reason, so restrict
> > the workaround to H3 ES1.x.
> > 
> > From an implementation point of view, move work around handling outside
> > of the rcar_du_dpll_divider() function by requesting a x2 DPLL output
> > frequency explicitly. The existing post-divider calculation mechanism
> > will then take care of dividing the clock by two automatically.
> > 
> > While at it, print a more useful debugging message to ease debugging
> > clock rate issues.
> > 
> > Signed-off-by: Laurent Pinchart
> > 
> > ---
> > 
> >  drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 37 +---
> >  1 file changed, 27 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> > b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c index 8f942ebdd0c6..6c29981377c0
> > 100644
> > --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> > +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> > @@ -13,6 +13,7 @@
> > 
> >  #include 
> >  #include 
> > +#include 
> > 
> >  #include 
> >  #include 
> > @@ -129,10 +130,8 @@ static void rcar_du_dpll_divider(struct rcar_du_crtc
> > *rcrtc,> 
> > for (fdpll = 1; fdpll < 32; fdpll++) {
> > unsigned long output;
> > 
> > -   /* 1/2 (FRQSEL=1) for duty rate 50% */
> > output = input * (n + 1) / (m + 1)
> > -  / (fdpll + 1) / 2;
> > -
> > +  / (fdpll + 1);
> 
> I'm finding this hard to interpret vs the commit-message.
> 
> Here we remove the /2 (which affects all targets... is this a problem?)

The purpose of this function is to compute DPLL parameters for given input and 
output frequencies. However, the current implementation computes parameters 
that result in twice the requested frequency, assuming that the caller will 
configure a /2 post-divider.

I found this confusing, so the patch modifies the function to use the 
requested output frequency, and updates the caller accordingly. The function 
now performs the operation described by its name.

This indeed affects all targets, but there's no DPLL on Gen2, so in practice 
only H3 and M3-W are affected.

> > if (output >= 4)
> > continue;

[snip]

> > @@ -185,7 +189,20 @@ static void rcar_du_crtc_set_display_timing(struct
> > rcar_du_crtc *rcrtc)> 
> > extclk = clk_get_rate(rcrtc->extclock);
> > if (rcdu->info->dpll_ch & (1 << rcrtc->index)) {
> > 
> > -   rcar_du_dpll_divider(rcrtc, , extclk,
> > mode_clock);
> > +   unsigned long target = mode_clock;
> > +
> > +   /*
> > +* The H3 ES1.x exhibits dot clock duty cycle
> > stability
> > +* issues. We can work around them by configuring the
> > +* DPLL to twice the desired frequency, coupled with a
> > +* /2 post-divider. This isn't needed on other SoCs
> > and
> 
> But here we discuss 'coupling' it with a /2 post - divider.
> 
> My inference here then is that by setting a target that is 'twice' the value
> - code later will provide the /2 post-divide?

Correct. The /2 post-divider is required on H3 ES1.x to obtain a stable output 
clock, so the output of the DPLL has to be twice the pixel clock frequency. 
Based on my understanding it shouldn't hurt to do the same on H3 ES2.0 and M3-
W, but in practice that doesn't work. I've thus restricted the post-divider to 
H3 ES1.x.

> > +* breaks HDMI output on M3-W for a currently unknown
> > +* reason, so restrict the workaround to H3 ES1.x.
> > +*/
> > +   if (soc_device_match(rcar_du_r8a7795_es1))
> > +   target *= 2;
> > +
> > +   rcar_du_dpll_divider(rcrtc, , extclk, target);
> > extclk = dpll.output;
> > }
> > 
> > @@ -197,8 +214,6 @@ static void rcar_du_crtc_set_display_timing(struct
> > rcar_du_crtc *rcrtc)
> > if (abs((long)extrate - (long)mode_clock) <
> > abs((long)rate - (long)mode_clock)) {
> > -   dev_dbg(rcrtc->group->dev->dev,
> > -   "crtc%u: using external clock\n", rcrtc-
>index);
> > 
> > if (rcdu->info->dpll_ch & (1 << rcrtc->index)) {
> > u32 dpllcr = DPLLCR_CODE | DPLLCR_CLKE
> > 
> > @@ -215,12 +230,14 @@ static void 

Re: [PATCH v2 12/14] drm: rcar-du: Support multiple sources from the same VSP

2017-08-01 Thread Kieran Bingham
Hi Laurent,

On 26/06/17 19:12, Laurent Pinchart wrote:
> On R-Car H3 ES2.0, DU channels 0 and 3 are served by two separate
> pipelines from the same VSP. Support this in the DU driver.
> 
> Signed-off-by: Laurent Pinchart 

This looks good to me.

Minor nit / comment can be safely ignored. Mostly just me thinking outload.

Reviewed-by: Kieran Bingham 

> ---
>  drivers/gpu/drm/rcar-du/rcar_du_crtc.c |  2 +-
>  drivers/gpu/drm/rcar-du/rcar_du_crtc.h |  3 ++
>  drivers/gpu/drm/rcar-du/rcar_du_kms.c  | 91 
> ++
>  drivers/gpu/drm/rcar-du/rcar_du_vsp.c  | 37 +++---
>  drivers/gpu/drm/rcar-du/rcar_du_vsp.h  | 10 +++-
>  5 files changed, 110 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
> b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> index 345eff72f581..8f942ebdd0c6 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> @@ -721,7 +721,7 @@ int rcar_du_crtc_create(struct rcar_du_group *rgrp, 
> unsigned int index)
>   rcrtc->index = index;
>  
>   if (rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE))
> - primary = >vsp->planes[0].plane;
> + primary = >vsp->planes[rcrtc->vsp_pipe].plane;
>   else
>   primary = >planes[index % 2].plane;
>  
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h 
> b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
> index b199ed5adf36..0b6d26ecfc38 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
> @@ -35,6 +35,8 @@ struct rcar_du_vsp;
>   * @flip_wait: wait queue used to signal page flip completion
>   * @outputs: bitmask of the outputs (enum rcar_du_output) driven by this CRTC
>   * @group: CRTC group this CRTC belongs to
> + * @vsp: VSP feeding video to this CRTC
> + * @vsp_pipe: index of the VSP pipeline feeding video to this CRTC
>   */
>  struct rcar_du_crtc {
>   struct drm_crtc crtc;
> @@ -52,6 +54,7 @@ struct rcar_du_crtc {
>  
>   struct rcar_du_group *group;
>   struct rcar_du_vsp *vsp;
> + unsigned int vsp_pipe;
>  };
>  
>  #define to_rcar_crtc(c)  container_of(c, struct rcar_du_crtc, crtc)
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c 
> b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> index f4125c8ca902..82b978a5dae6 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> @@ -432,6 +432,83 @@ static int rcar_du_properties_init(struct rcar_du_device 
> *rcdu)
>   return 0;
>  }
>  
> +static int rcar_du_vsps_init(struct rcar_du_device *rcdu)
> +{
> + const struct device_node *np = rcdu->dev->of_node;
> + struct of_phandle_args args;
> + struct {
> + struct device_node *np;
> + unsigned int crtcs_mask;
> + } vsps[RCAR_DU_MAX_VSPS] = { { 0, }, };
> + unsigned int vsps_count = 0;
> + unsigned int cells;
> + unsigned int i;
> + int ret;
> +
> + /*
> +  * First parse the DT vsps property to populate the list of VSPs. Each
> +  * entry contains a pointer to the VSP DT node and a bitmask of the
> +  * connected DU CRTCs.
> +  */
> + cells = of_property_count_u32_elems(np, "vsps") / rcdu->num_crtcs - 1;
> + if (cells > 1)
> + return -EINVAL;
> +
> + for (i = 0; i < rcdu->num_crtcs; ++i) {
> + unsigned int j;
> +
> + ret = of_parse_phandle_with_fixed_args(np, "vsps", cells, i,
> +);
> + if (ret < 0)
> + goto error;
> +
> + /*
> +  * Add the VSP to the list or update the corresponding existing
> +  * entry if the VSP has already been added.
> +  */
> + for (j = 0; j < vsps_count; ++j) {
> + if (vsps[j].np == args.np)
> + break;
> + }
> +
> + if (j < vsps_count)
> + of_node_put(args.np);
> + else
> + vsps[vsps_count++].np = args.np;
> +
> + vsps[j].crtcs_mask |= 1 << i;

I do love the BIT(x) macro personally - but it's not important :)

> +
> + /* Store the VSP pointer and pipe index in the CRTC. */
> + rcdu->crtcs[i].vsp = >vsps[j];
> + rcdu->crtcs[i].vsp_pipe = cells >= 1 ? args.args[0] : 0;
> + }
> +
> + /*
> +  * Then initialize all the VSPs from the node pointers and CRTCs bitmask
> +  * computed previously.
> +  */
> + for (i = 0; i < vsps_count; ++i) {
> + struct rcar_du_vsp *vsp = >vsps[i];
> +
> + vsp->index = i;
> + vsp->dev = rcdu;
> +
> + ret = rcar_du_vsp_init(vsp, vsps[i].np, vsps[i].crtcs_mask);
> + if (ret < 0)
> + goto error;
> + }
> +
> + return 0;
> +
> 

[PATCH 09/18] [media] bt8xx: bttv: constify pci_device_id.

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/pci/bt8xx/bttv-driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c 
b/drivers/media/pci/bt8xx/bttv-driver.c
index ed319f1..40110be 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -4388,7 +4388,7 @@ static int bttv_resume(struct pci_dev *pci_dev)
 }
 #endif
 
-static struct pci_device_id bttv_pci_tbl[] = {
+static const struct pci_device_id bttv_pci_tbl[] = {
{PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT848), 0},
{PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT849), 0},
{PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT878), 0},
-- 
2.7.4



[PATCH 00/18] constify media pci_device_id

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Arvind Yadav (18):
  [PATCH 01/18] [media] marvell-ccic: constify pci_device_id.
  [PATCH 02/18] [media] netup_unidvb: constify pci_device_id.
  [PATCH 03/18] [media] cx23885: constify pci_device_id.
  [PATCH 04/18] [media] meye: constify pci_device_id.
  [PATCH 05/18] [media] pluto2: constify pci_device_id.
  [PATCH 06/18] [media] dm1105: constify pci_device_id.
  [PATCH 07/18] [media] zoran: constify pci_device_id.
  [PATCH 08/18] [media] bt8xx: constify pci_device_id.
  [PATCH 09/18] [media] bt8xx: bttv: constify pci_device_id.
  [PATCH 10/18] [media] ivtv: constify pci_device_id.
  [PATCH 11/18] [media] cobalt: constify pci_device_id.
  [PATCH 12/18] [media] b2c2: constify pci_device_id.
  [PATCH 13/18] [media] saa7164: constify pci_device_id.
  [PATCH 14/18] [media] pt1: constify pci_device_id.
  [PATCH 15/18] [media] mantis: constify pci_device_id.
  [PATCH 16/18] [media] mantis: hopper_cards: constify pci_device_id.
  [PATCH 17/18] [media] cx18: constify pci_device_id.
  [PATCH 18/18] [media] radio: constify pci_device_id.

 drivers/media/pci/b2c2/flexcop-pci.c   | 2 +-
 drivers/media/pci/bt8xx/bt878.c| 2 +-
 drivers/media/pci/bt8xx/bttv-driver.c  | 2 +-
 drivers/media/pci/cobalt/cobalt-driver.c   | 2 +-
 drivers/media/pci/cx18/cx18-driver.c   | 2 +-
 drivers/media/pci/cx23885/cx23885-core.c   | 2 +-
 drivers/media/pci/dm1105/dm1105.c  | 2 +-
 drivers/media/pci/ivtv/ivtv-driver.c   | 2 +-
 drivers/media/pci/mantis/hopper_cards.c| 2 +-
 drivers/media/pci/mantis/mantis_cards.c| 2 +-
 drivers/media/pci/meye/meye.c  | 2 +-
 drivers/media/pci/netup_unidvb/netup_unidvb_core.c | 2 +-
 drivers/media/pci/pluto2/pluto2.c  | 2 +-
 drivers/media/pci/pt1/pt1.c| 2 +-
 drivers/media/pci/saa7164/saa7164-core.c   | 2 +-
 drivers/media/pci/zoran/zoran_card.c   | 2 +-
 drivers/media/platform/marvell-ccic/cafe-driver.c  | 2 +-
 drivers/media/radio/radio-maxiradio.c  | 2 +-
 18 files changed, 18 insertions(+), 18 deletions(-)

-- 
2.7.4



[PATCH 02/18] [media] netup_unidvb: constify pci_device_id.

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/pci/netup_unidvb/netup_unidvb_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c 
b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
index 5c0a4e6..60e6cd5 100644
--- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
+++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
@@ -1014,7 +1014,7 @@ static void netup_unidvb_finidev(struct pci_dev *pci_dev)
 }
 
 
-static struct pci_device_id netup_unidvb_pci_tbl[] = {
+static const struct pci_device_id netup_unidvb_pci_tbl[] = {
{ PCI_DEVICE(0x1b55, 0x18f6) }, /* hw rev. 1.3 */
{ PCI_DEVICE(0x1b55, 0x18f7) }, /* hw rev. 1.4 */
{ 0, }
-- 
2.7.4



[PATCH 01/18] [media] marvell-ccic: constify pci_device_id.

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/platform/marvell-ccic/cafe-driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/marvell-ccic/cafe-driver.c 
b/drivers/media/platform/marvell-ccic/cafe-driver.c
index 77890bd..b1ad054 100644
--- a/drivers/media/platform/marvell-ccic/cafe-driver.c
+++ b/drivers/media/platform/marvell-ccic/cafe-driver.c
@@ -612,7 +612,7 @@ static int cafe_pci_resume(struct pci_dev *pdev)
 
 #endif  /* CONFIG_PM */
 
-static struct pci_device_id cafe_ids[] = {
+static const struct pci_device_id cafe_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL,
 PCI_DEVICE_ID_MARVELL_88ALP01_CCIC) },
{ 0, }
-- 
2.7.4



[PATCH 03/18] [media] cx23885: constify pci_device_id.

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/pci/cx23885/cx23885-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/cx23885/cx23885-core.c 
b/drivers/media/pci/cx23885/cx23885-core.c
index 02b5ec5..8f63df1 100644
--- a/drivers/media/pci/cx23885/cx23885-core.c
+++ b/drivers/media/pci/cx23885/cx23885-core.c
@@ -2056,7 +2056,7 @@ static void cx23885_finidev(struct pci_dev *pci_dev)
kfree(dev);
 }
 
-static struct pci_device_id cx23885_pci_tbl[] = {
+static const struct pci_device_id cx23885_pci_tbl[] = {
{
/* CX23885 */
.vendor   = 0x14f1,
-- 
2.7.4



[PATCH 04/18] [media] meye: constify pci_device_id.

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/pci/meye/meye.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/meye/meye.c b/drivers/media/pci/meye/meye.c
index 9c4a024..0fe76be 100644
--- a/drivers/media/pci/meye/meye.c
+++ b/drivers/media/pci/meye/meye.c
@@ -1801,7 +1801,7 @@ static void meye_remove(struct pci_dev *pcidev)
printk(KERN_INFO "meye: removed\n");
 }
 
-static struct pci_device_id meye_pci_tbl[] = {
+static const struct pci_device_id meye_pci_tbl[] = {
{ PCI_VDEVICE(KAWASAKI, PCI_DEVICE_ID_MCHIP_KL5A72002), 0 },
{ }
 };
-- 
2.7.4



[PATCH 05/18] [media] pluto2: constify pci_device_id.

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/pci/pluto2/pluto2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/pluto2/pluto2.c 
b/drivers/media/pci/pluto2/pluto2.c
index 7483810..39dcba2 100644
--- a/drivers/media/pci/pluto2/pluto2.c
+++ b/drivers/media/pci/pluto2/pluto2.c
@@ -770,7 +770,7 @@ static void pluto2_remove(struct pci_dev *pdev)
 #define PCI_DEVICE_ID_PLUTO2   0x0001
 #endif
 
-static struct pci_device_id pluto2_id_table[] = {
+static const struct pci_device_id pluto2_id_table[] = {
{
.vendor = PCI_VENDOR_ID_SCM,
.device = PCI_DEVICE_ID_PLUTO2,
-- 
2.7.4



[PATCH 07/18] [media] zoran: constify pci_device_id.

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/pci/zoran/zoran_card.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/zoran/zoran_card.c 
b/drivers/media/pci/zoran/zoran_card.c
index 4680f00..a6b9ebd 100644
--- a/drivers/media/pci/zoran/zoran_card.c
+++ b/drivers/media/pci/zoran/zoran_card.c
@@ -130,7 +130,7 @@ MODULE_VERSION(ZORAN_VERSION);
.vendor = PCI_VENDOR_ID_ZORAN, .device = PCI_DEVICE_ID_ZORAN_36057, \
.subvendor = (subven), .subdevice = (subdev), .driver_data = (data) }
 
-static struct pci_device_id zr36067_pci_tbl[] = {
+static const struct pci_device_id zr36067_pci_tbl[] = {
ZR_DEVICE(PCI_VENDOR_ID_MIRO, PCI_DEVICE_ID_MIRO_DC10PLUS, DC10plus),
ZR_DEVICE(PCI_VENDOR_ID_MIRO, PCI_DEVICE_ID_MIRO_DC30PLUS, DC30plus),
ZR_DEVICE(PCI_VENDOR_ID_ELECTRONICDESIGNGMBH, PCI_DEVICE_ID_LML_33R10, 
LML33R10),
-- 
2.7.4



[PATCH 06/18] [media] dm1105: constify pci_device_id.

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/pci/dm1105/dm1105.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/dm1105/dm1105.c 
b/drivers/media/pci/dm1105/dm1105.c
index 1d41934..0cd854f 100644
--- a/drivers/media/pci/dm1105/dm1105.c
+++ b/drivers/media/pci/dm1105/dm1105.c
@@ -1208,7 +1208,7 @@ static void dm1105_remove(struct pci_dev *pdev)
kfree(dev);
 }
 
-static struct pci_device_id dm1105_id_table[] = {
+static const struct pci_device_id dm1105_id_table[] = {
{
.vendor = PCI_VENDOR_ID_TRIGEM,
.device = PCI_DEVICE_ID_DM1105,
-- 
2.7.4



[PATCH 12/18] [media] b2c2: constify pci_device_id.

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/pci/b2c2/flexcop-pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/b2c2/flexcop-pci.c 
b/drivers/media/pci/b2c2/flexcop-pci.c
index 6e60dec..cc6527e 100644
--- a/drivers/media/pci/b2c2/flexcop-pci.c
+++ b/drivers/media/pci/b2c2/flexcop-pci.c
@@ -415,7 +415,7 @@ static void flexcop_pci_remove(struct pci_dev *pdev)
flexcop_device_kfree(fc_pci->fc_dev);
 }
 
-static struct pci_device_id flexcop_pci_tbl[] = {
+static const struct pci_device_id flexcop_pci_tbl[] = {
{ PCI_DEVICE(0x13d0, 0x2103) },
{ },
 };
-- 
2.7.4



[PATCH 10/18] [media] ivtv: constify pci_device_id.

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/pci/ivtv/ivtv-driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/ivtv/ivtv-driver.c 
b/drivers/media/pci/ivtv/ivtv-driver.c
index e8fa99b..54dcac4 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.c
+++ b/drivers/media/pci/ivtv/ivtv-driver.c
@@ -73,7 +73,7 @@ int (*ivtv_ext_init)(struct ivtv *);
 EXPORT_SYMBOL(ivtv_ext_init);
 
 /* add your revision and whatnot here */
-static struct pci_device_id ivtv_pci_tbl[] = {
+static const struct pci_device_id ivtv_pci_tbl[] = {
{PCI_VENDOR_ID_ICOMP, PCI_DEVICE_ID_IVTV15,
 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{PCI_VENDOR_ID_ICOMP, PCI_DEVICE_ID_IVTV16,
-- 
2.7.4



[PATCH 11/18] [media] cobalt: constify pci_device_id.

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/pci/cobalt/cobalt-driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/cobalt/cobalt-driver.c 
b/drivers/media/pci/cobalt/cobalt-driver.c
index f8e173f..98b6cb9 100644
--- a/drivers/media/pci/cobalt/cobalt-driver.c
+++ b/drivers/media/pci/cobalt/cobalt-driver.c
@@ -36,7 +36,7 @@
 #include "cobalt-omnitek.h"
 
 /* add your revision and whatnot here */
-static struct pci_device_id cobalt_pci_tbl[] = {
+static const struct pci_device_id cobalt_pci_tbl[] = {
{PCI_VENDOR_ID_CISCO, PCI_DEVICE_ID_COBALT,
 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0,}
-- 
2.7.4



[PATCH 14/18] [media] pt1: constify pci_device_id.

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/pci/pt1/pt1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/pt1/pt1.c b/drivers/media/pci/pt1/pt1.c
index 3219d2f..b6b1a8d 100644
--- a/drivers/media/pci/pt1/pt1.c
+++ b/drivers/media/pci/pt1/pt1.c
@@ -1202,7 +1202,7 @@ static int pt1_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 
 }
 
-static struct pci_device_id pt1_id_table[] = {
+static const struct pci_device_id pt1_id_table[] = {
{ PCI_DEVICE(0x10ee, 0x211a) },
{ PCI_DEVICE(0x10ee, 0x222a) },
{ },
-- 
2.7.4



[PATCH 13/18] [media] saa7164: constify pci_device_id.

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/pci/saa7164/saa7164-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/saa7164/saa7164-core.c 
b/drivers/media/pci/saa7164/saa7164-core.c
index 75eed4c..fca36a4 100644
--- a/drivers/media/pci/saa7164/saa7164-core.c
+++ b/drivers/media/pci/saa7164/saa7164-core.c
@@ -1490,7 +1490,7 @@ static void saa7164_finidev(struct pci_dev *pci_dev)
kfree(dev);
 }
 
-static struct pci_device_id saa7164_pci_tbl[] = {
+static const struct pci_device_id saa7164_pci_tbl[] = {
{
/* SAA7164 */
.vendor   = 0x1131,
-- 
2.7.4



[PATCH 15/18] [media] mantis: constify pci_device_id.

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/pci/mantis/mantis_cards.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/mantis/mantis_cards.c 
b/drivers/media/pci/mantis/mantis_cards.c
index cdefffc..adc980d 100644
--- a/drivers/media/pci/mantis/mantis_cards.c
+++ b/drivers/media/pci/mantis/mantis_cards.c
@@ -281,7 +281,7 @@ static void mantis_pci_remove(struct pci_dev *pdev)
return;
 }
 
-static struct pci_device_id mantis_pci_table[] = {
+static const struct pci_device_id mantis_pci_table[] = {
MAKE_ENTRY(TECHNISAT, CABLESTAR_HD2, _config,
   RC_MAP_TECHNISAT_TS35),
MAKE_ENTRY(TECHNISAT, SKYSTAR_HD2_10, _config,
-- 
2.7.4



[PATCH 16/18] [media] mantis: hopper_cards: constify pci_device_id.

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/pci/mantis/hopper_cards.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/mantis/hopper_cards.c 
b/drivers/media/pci/mantis/hopper_cards.c
index 68b5800..11e9878 100644
--- a/drivers/media/pci/mantis/hopper_cards.c
+++ b/drivers/media/pci/mantis/hopper_cards.c
@@ -255,7 +255,7 @@ static void hopper_pci_remove(struct pci_dev *pdev)
 
 }
 
-static struct pci_device_id hopper_pci_table[] = {
+static const struct pci_device_id hopper_pci_table[] = {
MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_3028_DVB_T, _config,
   NULL),
{ }
-- 
2.7.4



[PATCH 17/18] [media] cx18: constify pci_device_id.

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/pci/cx18/cx18-driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/cx18/cx18-driver.c 
b/drivers/media/pci/cx18/cx18-driver.c
index 8bce49c..8654710 100644
--- a/drivers/media/pci/cx18/cx18-driver.c
+++ b/drivers/media/pci/cx18/cx18-driver.c
@@ -48,7 +48,7 @@ int (*cx18_ext_init)(struct cx18 *);
 EXPORT_SYMBOL(cx18_ext_init);
 
 /* add your revision and whatnot here */
-static struct pci_device_id cx18_pci_tbl[] = {
+static const struct pci_device_id cx18_pci_tbl[] = {
{PCI_VENDOR_ID_CX, PCI_DEVICE_ID_CX23418,
 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0,}
-- 
2.7.4



[PATCH 08/18] [media] bt8xx: constify pci_device_id.

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/pci/bt8xx/bt878.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/bt8xx/bt878.c b/drivers/media/pci/bt8xx/bt878.c
index 8aa7266..a5f5213 100644
--- a/drivers/media/pci/bt8xx/bt878.c
+++ b/drivers/media/pci/bt8xx/bt878.c
@@ -383,7 +383,7 @@ EXPORT_SYMBOL(bt878_device_control);
.driver_data = (unsigned long) name \
}
 
-static struct pci_device_id bt878_pci_tbl[] = {
+static const struct pci_device_id bt878_pci_tbl[] = {
BROOKTREE_878_DEVICE(0x0071, 0x0101, "Nebula Electronics DigiTV"),
BROOKTREE_878_DEVICE(0x1461, 0x0761, "AverMedia AverTV DVB-T 761"),
BROOKTREE_878_DEVICE(0x11bd, 0x001c, "Pinnacle PCTV Sat"),
-- 
2.7.4



[PATCH 18/18] [media] radio: constify pci_device_id.

2017-08-01 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/radio/radio-maxiradio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/radio/radio-maxiradio.c 
b/drivers/media/radio/radio-maxiradio.c
index 8253f79..3aa5ad3 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -186,7 +186,7 @@ static void maxiradio_remove(struct pci_dev *pdev)
kfree(dev);
 }
 
-static struct pci_device_id maxiradio_pci_tbl[] = {
+static const struct pci_device_id maxiradio_pci_tbl[] = {
{ PCI_VENDOR_ID_GUILLEMOT, PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO,
PCI_ANY_ID, PCI_ANY_ID, },
{ 0 }
-- 
2.7.4



[PATCHv2 2/2] dib0700: add support for Xbox One Digital TV Tuner

2017-08-01 Thread olli . salonen
From: Olli Salonen 

Xbox One Digital TV Tuner is a low-cost USB 2.0 multistandard TV tuner. It
supports DVB-T, DVB-T2 and DVB-C broadcast standards.

USB bridge: DibCom 0700C
Demodulator: Panasonic MN88472
Tuner: TDA18250BHN

The demodulator requires firmware. Download one from here:
http://palosaari.fi/linux/v4l-dvb/firmware/MN88472/02/latest/

Signed-off-by: Olli Salonen 
---
 drivers/media/dvb-core/dvb-usb-ids.h|   2 +
 drivers/media/usb/dvb-usb/Kconfig   |   2 +
 drivers/media/usb/dvb-usb/dib0700.h |   2 +
 drivers/media/usb/dvb-usb/dib0700_core.c|  26 ++-
 drivers/media/usb/dvb-usb/dib0700_devices.c | 109 +++-
 5 files changed, 139 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-core/dvb-usb-ids.h 
b/drivers/media/dvb-core/dvb-usb-ids.h
index 5b6041d..daf49ec 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -80,6 +80,7 @@
 #define USB_VID_AZUREWAVE  0x13d3
 #define USB_VID_TECHNISAT  0x14f7
 #define USB_VID_HAMA   0x147f
+#define USB_VID_MICROSOFT  0x045e
 
 /* Product IDs */
 #define USB_PID_ADSTECH_USB2_COLD  0xa333
@@ -417,4 +418,5 @@
 #define USB_PID_WINTV_SOLOHD0x0264
 #define USB_PID_EVOLVEO_XTRATV_STICK   0xa115
 #define USB_PID_HAMA_DVBT_HYBRID   0x2758
+#define USB_PID_XBOX_ONE_TUNER  0x02d5
 #endif
diff --git a/drivers/media/usb/dvb-usb/Kconfig 
b/drivers/media/usb/dvb-usb/Kconfig
index 959fa09..2651ae2 100644
--- a/drivers/media/usb/dvb-usb/Kconfig
+++ b/drivers/media/usb/dvb-usb/Kconfig
@@ -86,6 +86,7 @@ config DVB_USB_DIB0700
select DVB_USB_DIB3000MC if MEDIA_SUBDRV_AUTOSELECT
select DVB_S5H1411 if MEDIA_SUBDRV_AUTOSELECT
select DVB_LGDT3305 if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_MN88472 if MEDIA_SUBDRV_AUTOSELECT
select DVB_TUNER_DIB0070 if MEDIA_SUBDRV_AUTOSELECT
select DVB_TUNER_DIB0090 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_MT2060 if MEDIA_SUBDRV_AUTOSELECT
@@ -94,6 +95,7 @@ config DVB_USB_DIB0700
select MEDIA_TUNER_XC5000 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_XC4000 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_MXL5007T if MEDIA_SUBDRV_AUTOSELECT
+   select MEDIA_TUNER_TDA18250 if MEDIA_SUBDRV_AUTOSELECT
help
  Support for USB2.0/1.1 DVB receivers based on the DiB0700 USB bridge. 
The
  USB bridge is also present in devices having the DiB7700 DVB-T-USB
diff --git a/drivers/media/usb/dvb-usb/dib0700.h 
b/drivers/media/usb/dvb-usb/dib0700.h
index 8fd8f5b..5f29128 100644
--- a/drivers/media/usb/dvb-usb/dib0700.h
+++ b/drivers/media/usb/dvb-usb/dib0700.h
@@ -51,6 +51,8 @@ struct dib0700_state {
int (*read_status)(struct dvb_frontend *, enum fe_status *);
int (*sleep)(struct dvb_frontend* fe);
u8 buf[255];
+   struct i2c_client *i2c_client_demod;
+   struct i2c_client *i2c_client_tuner;
 };
 
 extern int dib0700_get_version(struct dvb_usb_device *d, u32 *hwversion,
diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c 
b/drivers/media/usb/dvb-usb/dib0700_core.c
index bea1b47..dbd031c 100644
--- a/drivers/media/usb/dvb-usb/dib0700_core.c
+++ b/drivers/media/usb/dvb-usb/dib0700_core.c
@@ -911,10 +911,34 @@ static int dib0700_probe(struct usb_interface *intf,
return -ENODEV;
 }
 
+static void dib0700_disconnect(struct usb_interface *intf)
+{
+   struct dvb_usb_device *d = usb_get_intfdata(intf);
+   struct dib0700_state *st = d->priv;
+   struct i2c_client *client;
+
+   /* remove I2C client for tuner */
+   client = st->i2c_client_tuner;
+   if (client) {
+   module_put(client->dev.driver->owner);
+   i2c_unregister_device(client);
+   }
+
+   /* remove I2C client for demodulator */
+   client = st->i2c_client_demod;
+   if (client) {
+   module_put(client->dev.driver->owner);
+   i2c_unregister_device(client);
+   }
+
+   dvb_usb_device_exit(intf);
+}
+
+
 static struct usb_driver dib0700_driver = {
.name   = "dvb_usb_dib0700",
.probe  = dib0700_probe,
-   .disconnect = dvb_usb_device_exit,
+   .disconnect = dib0700_disconnect,
.id_table   = dib0700_usb_id_table,
 };
 
diff --git a/drivers/media/usb/dvb-usb/dib0700_devices.c 
b/drivers/media/usb/dvb-usb/dib0700_devices.c
index 6a57fc6..7c0fb18 100644
--- a/drivers/media/usb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/usb/dvb-usb/dib0700_devices.c
@@ -23,6 +23,9 @@
 #include "dib0090.h"
 #include "lgdt3305.h"
 #include "mxl5007t.h"
+#include "mn88472.h"
+#include "tda18250.h"
+
 
 static int force_lna_activation;
 module_param(force_lna_activation, int, 0644);
@@ -3725,6 +3728,90 @@ static int 

[PATCHv2 1/2] tda18250: support for new silicon tuner

2017-08-01 Thread olli . salonen
From: Olli Salonen 

NXP TDA18250 silicon tuner driver.

Version 2 adds media controller support and does regmap_exit at exit.

Signed-off-by: Olli Salonen 
---
 drivers/media/tuners/Kconfig |   7 +
 drivers/media/tuners/Makefile|   1 +
 drivers/media/tuners/tda18250.c  | 924 +++
 drivers/media/tuners/tda18250.h  |  51 ++
 drivers/media/tuners/tda18250_priv.h | 153 ++
 5 files changed, 1136 insertions(+)
 create mode 100644 drivers/media/tuners/tda18250.c
 create mode 100644 drivers/media/tuners/tda18250.h
 create mode 100644 drivers/media/tuners/tda18250_priv.h

diff --git a/drivers/media/tuners/Kconfig b/drivers/media/tuners/Kconfig
index 05998f0..6687514 100644
--- a/drivers/media/tuners/Kconfig
+++ b/drivers/media/tuners/Kconfig
@@ -26,6 +26,13 @@ config MEDIA_TUNER_SIMPLE
help
  Say Y here to include support for various simple tuners.
 
+config MEDIA_TUNER_TDA18250
+   tristate "NXP TDA18250 silicon tuner"
+   depends on MEDIA_SUPPORT && I2C
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ Say Y here to include support for TDA18250 tuner.
+
 config MEDIA_TUNER_TDA8290
tristate "TDA 8290/8295 + 8275(a)/18271 tuner combo"
depends on MEDIA_SUPPORT && I2C
diff --git a/drivers/media/tuners/Makefile b/drivers/media/tuners/Makefile
index 06a9ab6..4b9444b 100644
--- a/drivers/media/tuners/Makefile
+++ b/drivers/media/tuners/Makefile
@@ -41,6 +41,7 @@ obj-$(CONFIG_MEDIA_TUNER_R820T) += r820t.o
 obj-$(CONFIG_MEDIA_TUNER_MXL301RF) += mxl301rf.o
 obj-$(CONFIG_MEDIA_TUNER_QM1D1C0042) += qm1d1c0042.o
 obj-$(CONFIG_MEDIA_TUNER_M88RS6000T) += m88rs6000t.o
+obj-$(CONFIG_MEDIA_TUNER_TDA18250) += tda18250.o
 
 ccflags-y += -I$(srctree)/drivers/media/dvb-core
 ccflags-y += -I$(srctree)/drivers/media/dvb-frontends
diff --git a/drivers/media/tuners/tda18250.c b/drivers/media/tuners/tda18250.c
new file mode 100644
index 000..201e1c1
--- /dev/null
+++ b/drivers/media/tuners/tda18250.c
@@ -0,0 +1,924 @@
+/*
+ * NXP TDA18250 silicon tuner driver
+ *
+ * Copyright (C) 2017 Olli Salonen 
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ */
+
+#include "tda18250_priv.h"
+#include 
+
+static const struct dvb_tuner_ops tda18250_ops;
+
+static int tda18250_power_control(struct dvb_frontend *fe,
+   unsigned int power_state)
+{
+   struct i2c_client *client = fe->tuner_priv;
+   struct tda18250_dev *dev = i2c_get_clientdata(client);
+   int ret;
+   unsigned int utmp;
+
+   dev_dbg(>dev, "power state: %d", power_state);
+
+   switch (power_state) {
+   case TDA18250_POWER_NORMAL:
+   ret = regmap_write_bits(dev->regmap, R06_POWER2, 0x07, 0x00);
+   if (ret)
+   goto err;
+   ret = regmap_write_bits(dev->regmap, R25_REF, 0xc0, 0xc0);
+   if (ret)
+   goto err;
+   break;
+   case TDA18250_POWER_STANDBY:
+   if (dev->loopthrough) {
+   ret = regmap_write_bits(dev->regmap, R25_REF, 0xc0, 
0x80);
+   if (ret)
+   goto err;
+   ret = regmap_write_bits(dev->regmap, R06_POWER2, 0x07, 
0x02);
+   if (ret)
+   goto err;
+   ret = regmap_write_bits(dev->regmap, R10_LT1, 0x80, 
0x00);
+   if (ret)
+   goto err;
+   } else {
+   ret = regmap_write_bits(dev->regmap, R25_REF, 0xc0, 
0x80);
+   if (ret)
+   goto err;
+   ret = regmap_write_bits(dev->regmap, R06_POWER2, 0x07, 
0x01);
+   if (ret)
+   goto err;
+   ret = regmap_read(dev->regmap, R0D_AGC12, );
+   if (ret)
+   goto err;
+   ret = regmap_write_bits(dev->regmap, R0D_AGC12, 0x03, 
0x03);
+   if (ret)
+   goto err;
+   ret = regmap_write_bits(dev->regmap, R10_LT1, 0x80, 
0x80);
+   if (ret)
+   goto err;
+   ret = regmap_write_bits(dev->regmap, R0D_AGC12, 0x03, 
utmp & 0x03);
+   if 

Re: [PATCH v2 11/14] v4l: vsp1: Add support for header display lists in continuous mode

2017-08-01 Thread Kieran Bingham
Hi Laurent,

On 26/06/17 19:12, Laurent Pinchart wrote:
> The VSP supports both header and headerless display lists. The latter is
> easier to use when the VSP feeds data directly to the DU in continuous
> mode, and the driver thus uses headerless display lists for DU operation
> and header display lists otherwise.
> 
> Headerless display lists are only available on WPF.0. This has never
> been an issue so far, as only WPF.0 is connected to the DU. However, on
> H3 ES2.0, the VSP-DL instance has both WPF.0 and WPF.1 connected to the
> DU. We thus can't use headerless display lists unconditionally for DU
> operation.

Would it be crazy to suggest we drop headerless display lists?

If we must support header display lists in continuous mode - Rather than having
2 cases for continuous modes to support (having to support headerless, on WPF.0,
and header on WPF.1) if we just use your header loop trick - would that simplify
our code maintenance?

(We can always remove headerless support later if you agree, this is more of an
idea at the moment)


> Implement support for continuous mode with header display lists, and use
> it for DU operation on WPF outputs that don't support headerless mode.
> 
> Signed-off-by: Laurent Pinchart 

Except for future discussion points, I can't see anything wrong here so:

Reviewed-by: Kieran Bingham 

> ---
>  drivers/media/platform/vsp1/vsp1_dl.c   | 195 
> +---
>  drivers/media/platform/vsp1/vsp1_regs.h |   1 +
>  2 files changed, 127 insertions(+), 69 deletions(-)
> 
> diff --git a/drivers/media/platform/vsp1/vsp1_dl.c 
> b/drivers/media/platform/vsp1/vsp1_dl.c
> index bb92be4fe0f0..8b5cbb6b7a70 100644
> --- a/drivers/media/platform/vsp1/vsp1_dl.c
> +++ b/drivers/media/platform/vsp1/vsp1_dl.c
> @@ -95,6 +95,7 @@ enum vsp1_dl_mode {
>   * struct vsp1_dl_manager - Display List manager
>   * @index: index of the related WPF
>   * @mode: display list operation mode (header or headerless)
> + * @singleshot: execute the display list in single-shot mode
>   * @vsp1: the VSP1 device
>   * @lock: protects the free, active, queued, pending and gc_fragments lists
>   * @free: array of all free display lists
> @@ -107,6 +108,7 @@ enum vsp1_dl_mode {
>  struct vsp1_dl_manager {
>   unsigned int index;
>   enum vsp1_dl_mode mode;
> + bool singleshot;
>   struct vsp1_device *vsp1;
>  
>   spinlock_t lock;
> @@ -437,6 +439,7 @@ int vsp1_dl_list_add_chain(struct vsp1_dl_list *head,
>  
>  static void vsp1_dl_list_fill_header(struct vsp1_dl_list *dl, bool is_last)
>  {
> + struct vsp1_dl_manager *dlm = dl->dlm;
>   struct vsp1_dl_header_list *hdr = dl->header->lists;
>   struct vsp1_dl_body *dlb;
>   unsigned int num_lists = 0;
> @@ -461,85 +464,145 @@ static void vsp1_dl_list_fill_header(struct 
> vsp1_dl_list *dl, bool is_last)
>  
>   dl->header->num_lists = num_lists;
>  
> - /*
> -  * If this display list's chain is not empty, we are on a list, where
> -  * the next item in the list is the display list entity which should be
> -  * automatically queued by the hardware.
> -  */
>   if (!list_empty(>chain) && !is_last) {
> + /*
> +  * If this display list's chain is not empty, we are on a list,
> +  * and the next item is the display list that we must queue for
> +  * automatic processing by the hardware.
> +  */
>   struct vsp1_dl_list *next = list_next_entry(dl, chain);
>  
>   dl->header->next_header = next->dma;
>   dl->header->flags = VSP1_DLH_AUTO_START;
> + } else if (!dlm->singleshot) {
> + /*
> +  * if the display list manager works in continuous mode, the VSP
> +  * should loop over the display list continuously until
> +  * instructed to do otherwise.
> +  */
> + dl->header->next_header = dl->dma;
> + dl->header->flags = VSP1_DLH_INT_ENABLE | VSP1_DLH_AUTO_START;

This is a neat trick - and I wonder if actually - it gives us even more
flexibility in our control.

Presently on continuous mode - I believe we have to reset the WPF to 'stop' ...
In this mode - I suspect we could update the display list - (albeit that might
be a bit racy) to disable the AUTO_START. Maybe that's better .. Maybe it's 
worse :)

>   } else {
> + /*
> +  * Otherwise, in mem-to-mem mode, we work in single-shot mode
> +  * and the next display list must not be started automatically.
> +  */
>   dl->header->flags = VSP1_DLH_INT_ENABLE;
>   }
>  }
>  
> -void vsp1_dl_list_commit(struct vsp1_dl_list *dl)
> +static bool vsp1_dl_list_hw_update_pending(struct vsp1_dl_manager *dlm)
>  {
> - struct vsp1_dl_manager *dlm = dl->dlm;
>   struct vsp1_device *vsp1 = dlm->vsp1;
> - unsigned 

Re: [PATCH v2 13/14] drm: rcar-du: Restrict DPLL duty cycle workaround to H3 ES1.x

2017-08-01 Thread Kieran Bingham
Hi Laurent,

On 26/06/17 19:12, Laurent Pinchart wrote:
> The H3 ES1.x exhibits dot clock duty cycle stability issues. We can work
> around them by configuring the DPLL to twice the desired frequency,
> coupled with a /2 post-divider. This isn't needed on other SoCs and
> breaks HDMI output on M3-W for a currently unknown reason, so restrict
> the workaround to H3 ES1.x.
> 
> From an implementation point of view, move work around handling outside
> of the rcar_du_dpll_divider() function by requesting a x2 DPLL output
> frequency explicitly. The existing post-divider calculation mechanism
> will then take care of dividing the clock by two automatically.
> 
> While at it, print a more useful debugging message to ease debugging
> clock rate issues.
> 
> Signed-off-by: Laurent Pinchart 
> ---
>  drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 37 
> +-
>  1 file changed, 27 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
> b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> index 8f942ebdd0c6..6c29981377c0 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> @@ -13,6 +13,7 @@
>  
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  #include 
> @@ -129,10 +130,8 @@ static void rcar_du_dpll_divider(struct rcar_du_crtc 
> *rcrtc,
>   for (fdpll = 1; fdpll < 32; fdpll++) {
>   unsigned long output;
>  
> - /* 1/2 (FRQSEL=1) for duty rate 50% */
>   output = input * (n + 1) / (m + 1)
> -/ (fdpll + 1) / 2;
> -
> +/ (fdpll + 1);

I'm finding this hard to interpret vs the commit-message.

Here we remove the /2 (which affects all targets... is this a problem?)

>   if (output >= 4)
>   continue;
>  
> @@ -158,6 +157,11 @@ static void rcar_du_dpll_divider(struct rcar_du_crtc 
> *rcrtc,
>best_diff);
>  }
>  
> +static const struct soc_device_attribute rcar_du_r8a7795_es1[] = {
> + { .soc_id = "r8a7795", .revision = "ES1.*" },
> + { /* sentinel */ }
> +};
> +
>  static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc)
>  {
>   const struct drm_display_mode *mode = >crtc.state->adjusted_mode;
> @@ -185,7 +189,20 @@ static void rcar_du_crtc_set_display_timing(struct 
> rcar_du_crtc *rcrtc)
>  
>   extclk = clk_get_rate(rcrtc->extclock);
>   if (rcdu->info->dpll_ch & (1 << rcrtc->index)) {
> - rcar_du_dpll_divider(rcrtc, , extclk, mode_clock);
> + unsigned long target = mode_clock;
> +
> + /*
> +  * The H3 ES1.x exhibits dot clock duty cycle stability
> +  * issues. We can work around them by configuring the
> +  * DPLL to twice the desired frequency, coupled with a
> +  * /2 post-divider. This isn't needed on other SoCs and

But here we discuss 'coupling' it with a /2 post - divider.

My inference here then is that by setting a target that is 'twice' the value -
code later will provide the /2 post-divide?

> +  * breaks HDMI output on M3-W for a currently unknown
> +  * reason, so restrict the workaround to H3 ES1.x.
> +  */
> + if (soc_device_match(rcar_du_r8a7795_es1))
> + target *= 2;
> +
> + rcar_du_dpll_divider(rcrtc, , extclk, target);
>   extclk = dpll.output;
>   }
>  
> @@ -197,8 +214,6 @@ static void rcar_du_crtc_set_display_timing(struct 
> rcar_du_crtc *rcrtc)
>  
>   if (abs((long)extrate - (long)mode_clock) <
>   abs((long)rate - (long)mode_clock)) {
> - dev_dbg(rcrtc->group->dev->dev,
> - "crtc%u: using external clock\n", rcrtc->index);
>  
>   if (rcdu->info->dpll_ch & (1 << rcrtc->index)) {
>   u32 dpllcr = DPLLCR_CODE | DPLLCR_CLKE
> @@ -215,12 +230,14 @@ static void rcar_du_crtc_set_display_timing(struct 
> rcar_du_crtc *rcrtc)
>  
>   rcar_du_group_write(rcrtc->group, DPLLCR,
>   dpllcr);
> -
> - escr = ESCR_DCLKSEL_DCLKIN | 1;
> - } else {
> - escr = ESCR_DCLKSEL_DCLKIN | extdiv;
>   }
> +
> + escr = ESCR_DCLKSEL_DCLKIN | extdiv;

Therefore - is this the post-divider?

If my inferences are correct - then OK:

Reviewed-by: Kieran Bingham 

--
KB

>   }
> +
> + 

Re: [PATCH v2 14/14] drm: rcar-du: Configure DPAD0 routing through last group on Gen3

2017-08-01 Thread Laurent Pinchart
Hi Kieran,

On Tuesday 01 Aug 2017 14:46:13 Kieran Bingham wrote:
> On 26/06/17 19:12, Laurent Pinchart wrote:
> > On Gen3 SoCs DPAD0 routing is configured through the last CRTC group,
> > unlike on Gen2 where it is configured through the first CRTC group. Fix
> > the driver accordingly.
> > 
> > Fixes: 2427b3037710 ("drm: rcar-du: Add R8A7795 device support")
> > Signed-off-by: Laurent Pinchart
> > 
> > ---
> > 
> >  drivers/gpu/drm/rcar-du/rcar_du_group.c | 21 ++---
> >  1 file changed, 14 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.c
> > b/drivers/gpu/drm/rcar-du/rcar_du_group.c index
> > 64738fca96d0..2abb2fdd143e 100644
> > --- a/drivers/gpu/drm/rcar-du/rcar_du_group.c
> > +++ b/drivers/gpu/drm/rcar-du/rcar_du_group.c
> > @@ -208,23 +208,30 @@ void rcar_du_group_restart(struct rcar_du_group
> > *rgrp)
> >  int rcar_du_set_dpad0_vsp1_routing(struct rcar_du_device *rcdu)
> >  {
> > +   struct rcar_du_group *rgrp;
> > +   struct rcar_du_crtc *crtc;
> > int ret;
> > 
> > if (!rcar_du_has(rcdu, RCAR_DU_FEATURE_EXT_CTRL_REGS))
> > return 0;
> > 
> > -   /* RGB output routing to DPAD0 and VSP1D routing to DU0/1/2 are
> > -* configured in the DEFR8 register of the first group. As this
> > function
> > -* can be called with the DU0 and DU1 CRTCs disabled, we need to
> > enable
> > -* the first group clock before accessing the register.
> > +   /*
> > +* RGB output routing to DPAD0 and VSP1D routing to DU0/1/2 are
> > +* configured in the DEFR8 register of the first group on Gen2 and the
> > +* last group on Gen3. As this function can be called with the DU
> > +* channels of the corresponding CRTCs disabled, we need to enable the
> > +* group clock before accessing the register.
> >  */
> > 
> > -   ret = clk_prepare_enable(rcdu->crtcs[0].clock);
> > +   rgrp = >groups[DIV_ROUND_UP(rcdu->num_crtcs, 2) - 1];
> > +   crtc = >crtcs[rgrp->index * 2];
> 
> I'm not certain I understand how this makes a distinct difference between
> G2, and G3.

That's because, well, it doesn't :-)

> Is rcdu->num_crtcs the distinguishing factor between the SoC's?

I'm not sure what I was thinking when I wrote this. I'll send a v3.

> > +
> > +   ret = clk_prepare_enable(crtc->clock);
> > if (ret < 0)
> > return ret;
> > 
> > -   rcar_du_group_setup_defr8(>groups[0]);
> > +   rcar_du_group_setup_defr8(rgrp);
> > 
> > -   clk_disable_unprepare(rcdu->crtcs[0].clock);
> > +   clk_disable_unprepare(crtc->clock);
> > 
> > return 0;
> >  }

-- 
Regards,

Laurent Pinchart



Re: [PATCH v2 14/14] drm: rcar-du: Configure DPAD0 routing through last group on Gen3

2017-08-01 Thread Kieran Bingham
Hi Laurent,

Thankyou for the patch,

On 26/06/17 19:12, Laurent Pinchart wrote:
> On Gen3 SoCs DPAD0 routing is configured through the last CRTC group,
> unlike on Gen2 where it is configured through the first CRTC group. Fix
> the driver accordingly.
> 
> Fixes: 2427b3037710 ("drm: rcar-du: Add R8A7795 device support")
> Signed-off-by: Laurent Pinchart 
> ---
>  drivers/gpu/drm/rcar-du/rcar_du_group.c | 21 ++---
>  1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.c 
> b/drivers/gpu/drm/rcar-du/rcar_du_group.c
> index 64738fca96d0..2abb2fdd143e 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_group.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_group.c
> @@ -208,23 +208,30 @@ void rcar_du_group_restart(struct rcar_du_group *rgrp)
>  
>  int rcar_du_set_dpad0_vsp1_routing(struct rcar_du_device *rcdu)
>  {
> + struct rcar_du_group *rgrp;
> + struct rcar_du_crtc *crtc;
>   int ret;
>  
>   if (!rcar_du_has(rcdu, RCAR_DU_FEATURE_EXT_CTRL_REGS))
>   return 0;
>  
> - /* RGB output routing to DPAD0 and VSP1D routing to DU0/1/2 are
> -  * configured in the DEFR8 register of the first group. As this function
> -  * can be called with the DU0 and DU1 CRTCs disabled, we need to enable
> -  * the first group clock before accessing the register.
> + /*
> +  * RGB output routing to DPAD0 and VSP1D routing to DU0/1/2 are
> +  * configured in the DEFR8 register of the first group on Gen2 and the
> +  * last group on Gen3. As this function can be called with the DU
> +  * channels of the corresponding CRTCs disabled, we need to enable the
> +  * group clock before accessing the register.
>*/
> - ret = clk_prepare_enable(rcdu->crtcs[0].clock);
> + rgrp = >groups[DIV_ROUND_UP(rcdu->num_crtcs, 2) - 1];
> + crtc = >crtcs[rgrp->index * 2];

I'm not certain I understand how this makes a distinct difference between G2,
and G3.

Is rcdu->num_crtcs the distinguishing factor between the SoC's?

> +
> + ret = clk_prepare_enable(crtc->clock);
>   if (ret < 0)
>   return ret;
>  
> - rcar_du_group_setup_defr8(>groups[0]);
> + rcar_du_group_setup_defr8(rgrp);
>  
> - clk_disable_unprepare(rcdu->crtcs[0].clock);
> + clk_disable_unprepare(crtc->clock);
>  
>   return 0;
>  }
> 


[PATCH] cec-funcs.h: cec_ops_report_features: set *dev_features to NULL

2017-08-01 Thread Hans Verkuil
gcc can get confused by this code and it thinks dev_features can be
returned uninitialized. So initialize to NULL at the beginning to shut up
the warning.

Signed-off-by: Hans Verkuil 
---
diff --git a/include/uapi/linux/cec-funcs.h b/include/uapi/linux/cec-funcs.h
index c451eec42a83..270b251a3d9b 100644
--- a/include/uapi/linux/cec-funcs.h
+++ b/include/uapi/linux/cec-funcs.h
@@ -895,6 +895,7 @@ static inline void cec_ops_report_features(const struct 
cec_msg *msg,
*cec_version = msg->msg[2];
*all_device_types = msg->msg[3];
*rc_profile = p;
+   *dev_features = NULL;
while (p < >msg[14] && (*p & CEC_OP_FEAT_EXT))
p++;
if (!(*p & CEC_OP_FEAT_EXT)) {