[PATCH 1/3] dt-bindings: Update Renesas R-Car FCP DT binding

2016-06-09 Thread Kieran Bingham
The FCP driver, can also support the FCPF variant for FDP1 compatible
processing.

Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 Documentation/devicetree/bindings/media/renesas,fcp.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/media/renesas,fcp.txt 
b/Documentation/devicetree/bindings/media/renesas,fcp.txt
index 6a12960609d8..271dcfdb5a76 100644
--- a/Documentation/devicetree/bindings/media/renesas,fcp.txt
+++ b/Documentation/devicetree/bindings/media/renesas,fcp.txt
@@ -7,12 +7,14 @@ conversion of AXI transactions in order to reduce the memory 
bandwidth.
 
 There are three types of FCP: FCP for Codec (FCPC), FCP for VSP (FCPV) and FCP
 for FDP (FCPF). Their configuration and behaviour depend on the module they
-are paired with. These DT bindings currently support the FCPV only.
+are paired with. These DT bindings currently support the FCPV and FCPF.
 
  - compatible: Must be one or more of the following
 
- "renesas,r8a7795-fcpv" for R8A7795 (R-Car H3) compatible 'FCP for VSP'
+   - "renesas,r8a7795-fcpf" for R8A7795 (R-Car H3) compatible 'FCP for FDP'
- "renesas,fcpv" for generic compatible 'FCP for VSP'
+   - "renesas,fcpf" for generic compatible 'FCP for FDP'
 
When compatible with the generic version, nodes must list the
SoC-specific version corresponding to the platform first, followed by the
-- 
2.7.4



[PATCHv2] clk: renesas: r8a7795: Provide FDP1 clocks

2016-06-09 Thread Kieran Bingham
Now that the  clock parents have been confirmed, and the clock names adjusted
the FDP1 clocks can be added to the cpg-mssr

Kieran Bingham (1):
  clk: renesas: r8a7795: Provide FDP1 clocks

 drivers/clk/renesas/r8a7795-cpg-mssr.c | 3 +++
 1 file changed, 3 insertions(+)

-- 
2.7.4



[PATCH] clk: renesas: r8a7795: Provide FDP1 clocks

2016-06-09 Thread Kieran Bingham
Reviewed-by: Geert Uytterhoeven <geert+rene...@glider.be>
Reviewed-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 drivers/clk/renesas/r8a7795-cpg-mssr.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/clk/renesas/r8a7795-cpg-mssr.c 
b/drivers/clk/renesas/r8a7795-cpg-mssr.c
index ca5519c583d4..f2b887502066 100644
--- a/drivers/clk/renesas/r8a7795-cpg-mssr.c
+++ b/drivers/clk/renesas/r8a7795-cpg-mssr.c
@@ -129,6 +129,9 @@ static const struct cpg_core_clk r8a7795_core_clks[] 
__initconst = {
 };
 
 static const struct mssr_mod_clk r8a7795_mod_clks[] __initconst = {
+   DEF_MOD("fdp1-2",117,   R8A7795_CLK_S2D1),
+   DEF_MOD("fdp1-1",118,   R8A7795_CLK_S2D1),
+   DEF_MOD("fdp1-0",119,   R8A7795_CLK_S2D1),
DEF_MOD("scif5", 202,   R8A7795_CLK_S3D4),
DEF_MOD("scif4", 203,   R8A7795_CLK_S3D4),
DEF_MOD("scif3", 204,   R8A7795_CLK_S3D4),
-- 
2.7.4



Re: [PATCH RFC 1/2] v4l: platform: Add Renesas R-Car FDP1 Driver

2016-06-10 Thread Kieran Bingham
Today I learned about make C=1

So ... reviewing my own patch, consider the following sparse warnings
'fixed up'

I'll run make C=1 before any future submissions from now on.


On 09/06/16 18:37, Kieran Bingham wrote:
> The FDP1 driver performs advanced de-interlacing on a memory 2 memory
> based video stream, and supports conversion from YCbCr/YUV
> to RGB pixel formats
> 
> Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
> ---
>  drivers/media/platform/Kconfig |   13 +
>  drivers/media/platform/Makefile|1 +
>  drivers/media/platform/rcar_fdp1.c | 2038 
> 
>  3 files changed, 2052 insertions(+)
>  create mode 100644 drivers/media/platform/rcar_fdp1.c

...

> +/* FDP1 Lookup tables range from 0...255 only */
> +unsigned char fdp1_diff_adj[256] = {
sparse: warning: symbol '...' was not declared. Should it be static?
+ static unsigned...

> + 0x00, 0x24, 0x43, 0x5E, 0x76, 0x8C, 0x9E, 0xAF,
...
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
> +};
> +
> +unsigned char fdp1_sad_adj[256] = {
likewise

> + 0x00, 0x24, 0x43, 0x5E, 0x76, 0x8C, 0x9E, 0xAF,
...
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
> +};
> +
> +unsigned char fdp1_bld_gain[256] = {
and again ...
> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
...
> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80
> +};
> +
> +unsigned char fdp1_dif_gain[256] = {
> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
...
> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80
> +};
> +
> +unsigned char fdp1_mdet[256] = {
and finally for the lut...
> + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
...
> + 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
> +};
> +
...

> +static void fdp1_write(struct fdp1_dev *fdp1, u32 val, unsigned int reg)
> +{
> + if (debug >= 2)
> + dprintk(fdp1, "Write to %p\n", fdp1->regs + reg);
> +
> + iowrite32(val, fdp1->regs + reg);
> +}
> +
> +
> +void fdp1_print_regs32(struct fdp1_dev *fdp1)
Another +static

...

> +static struct fdp1_plane_addrs vb2_dc_to_pa(struct vb2_v4l2_buffer *buf,
> + unsigned int planes)
> +{
> + struct fdp1_plane_addrs pa = { 0 };

sparse: warning: missing braces around initializer
+ struct fdp1_plane_addrs pa = { { 0 } };

-- 
Regards

Kieran Bingham


[PATCH RFC 1/2] v4l: platform: Add Renesas R-Car FDP1 Driver

2016-06-09 Thread Kieran Bingham
The FDP1 driver performs advanced de-interlacing on a memory 2 memory
based video stream, and supports conversion from YCbCr/YUV
to RGB pixel formats

Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 drivers/media/platform/Kconfig |   13 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/rcar_fdp1.c | 2038 
 3 files changed, 2052 insertions(+)
 create mode 100644 drivers/media/platform/rcar_fdp1.c

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 84e041c0a70e..9c745e53909b 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -235,6 +235,19 @@ config VIDEO_SH_VEU
Support for the Video Engine Unit (VEU) on SuperH and
SH-Mobile SoCs.
 
+config VIDEO_RENESAS_FDP1
+   tristate "Renesas Fine Display Processor"
+   depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
+   #   depends on ARCH_SHMOBILE || COMPILE_TEST
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   ---help---
+ This is a V4L2 driver for the Renesas Fine Display Processor
+ providing colour space conversion, and de-interlacing features.
+
+ To compile this driver as a module, choose M here: the module
+ will be called rcar_fdp1.
+
 config VIDEO_RENESAS_JPU
tristate "Renesas JPEG Processing Unit"
depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index bbb7bd1eb268..907ed6473718 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -46,6 +46,7 @@ obj-$(CONFIG_VIDEO_SH_VOU)+= sh_vou.o
 
 obj-$(CONFIG_SOC_CAMERA)   += soc_camera/
 
+obj-$(CONFIG_VIDEO_RENESAS_FDP1)   += rcar_fdp1.o
 obj-$(CONFIG_VIDEO_RENESAS_JPU)+= rcar_jpu.o
 obj-$(CONFIG_VIDEO_RENESAS_VSP1)   += vsp1/
 
diff --git a/drivers/media/platform/rcar_fdp1.c 
b/drivers/media/platform/rcar_fdp1.c
new file mode 100644
index ..82078367fa14
--- /dev/null
+++ b/drivers/media/platform/rcar_fdp1.c
@@ -0,0 +1,2038 @@
+/*
+ * Renesas RCar Fine Display Processor
+ *
+ * Video format converter and frame deinterlacer device.
+ *
+ * Author: Kieran Bingham, <kie...@bingham.xyz>
+ * Copyright (c) 2016 Renesas Electronics Corporation.
+ *
+ * This code is developed and inspired from the vim2m, rcar_jpu,
+ * m2m-deinterlace, and vsp1 drivers.
+ *
+ * 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
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static unsigned int debug;
+module_param(debug, uint, 0644);
+MODULE_PARM_DESC(debug, "activate debug info");
+
+/* Min Width/Height/Height-Field */
+#define MIN_W 80U
+#define MIN_H 80U
+
+#define MAX_W 3840U
+#define MAX_H 2160U
+
+/* Flags that indicate a format can be used for capture/output */
+#define FDP1_CAPTURE   (1 << 0)
+#define FDP1_OUTPUT(1 << 1)
+
+#define DRIVER_NAME"rcar_fdp1"
+
+#define dprintk(dev, fmt, arg...) \
+   v4l2_dbg(1, debug, >v4l2_dev, "%s: " fmt, __func__, ## arg)
+
+/*
+ * FDP1 registers and bits
+ */
+
+/* FDP1 start register - Imm */
+#define CTL_CMD0x
+#define CTL_CMD_STRCMD BIT(0)
+
+/* Sync generator register - Imm */
+#define CTL_SGCMD  0x0004
+#define CTL_SGCMD_SGEN BIT(0)
+
+/* Register set end register - Imm */
+#define CTL_REGEND 0x0008
+#define CTL_REGEND_REGEND  BIT(0)
+
+/* Channel activation register - Vupdt */
+#define CTL_CHACT  0x000C
+#define CTL_CHACT_SMW  BIT(9)
+#define CTL_CHACT_WR   BIT(8)
+#define CTL_CHACT_SMR  BIT(3)
+#define CTL_CHACT_RD2  BIT(2)
+#define CTL_CHACT_RD1  BIT(1)
+#define CTL_CHACT_RD0  BIT(0)
+
+/* Operation Mode Register - Vupdt */
+#define CTL_OPMODE 0x0010
+#define CTL_OPMODE_PRG BIT(4)
+#define CTL_OPMODE_VIMDGENMASK(1, 0)
+#define CTL_OPMODE_INTERRUPT   0
+#define CTL_OPMODE_BEST_EFFORT 1
+#define CTL_OPMODE_NO_INTERRUPT2
+
+#define CTL_VPERIOD0x0014
+#define CTL_CLKCTRL0x0018
+#define CTL_CLKCTRL_CSTP_N BIT(0)
+
+/* Software reset register */
+#define CTL_SRESET 0x001C
+#define CTL_SRESET_SRSTBIT(0)
+
+/* Control status register (V-update-status) */
+#define CTL_STATUS 0x0024
+#define CTL_STATUS_VINT_CNT(x) ((x & 0xff) >> 16)
+#defin

[PATCH RFC 0/2] v4l: platform: Add Renesas R-Car FDP1 Driver

2016-06-09 Thread Kieran Bingham
This early version of the driver, is submitted for review, and functions only
as a pixel format converter.

The FDP1, (Fine Display Processor) is a de-interlacer device, with capability
to convert from various YCbCr/YUV formats to both YCbCr/YUV and RGB formats
at the same time as converting interlaced content to progressive.

It can also function with progressive frames on input, and still act as a
pixel converter which is the current state of the driver.

The next phase of work will be to implement the de-interlacing fucntionality
on top of this code base, however as it is now a functional driver this seemed
like an apt point to start the review process.

Kieran Bingham (2):
  v4l: platform: Add Renesas R-Car FDP1 Driver
  MAINTAINERS: Add support for FDP driver

 MAINTAINERS|9 +
 drivers/media/platform/Kconfig |   13 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/rcar_fdp1.c | 2038 
 4 files changed, 2061 insertions(+)
 create mode 100644 drivers/media/platform/rcar_fdp1.c

-- 
2.7.4



[PATCH 1/2] arm64: dts: r8a7795: add FCPF device nodes

2016-06-09 Thread Kieran Bingham
Provide nodes for the FCP devices dedicated to the FDP device channels.

Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 arch/arm64/boot/dts/renesas/r8a7795.dtsi | 21 +
 1 file changed, 21 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a7795.dtsi 
b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
index 3285a9286786..e63e5f29cceb 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
@@ -1223,5 +1223,26 @@
power-domains = < R8A7795_PD_ALWAYS_ON>;
status = "disabled";
};
+
+   fcpf0: fcp@fe95 {
+   compatible = "renesas,r8a7795-fcpf", "renesas,fcpf";
+   reg = <0 0xfe95 0 0x200>;
+   clocks = < CPG_MOD 615>;
+   power-domains = < R8A7795_PD_A3VP>;
+   };
+
+   fcpf1: fcp@fe951000 {
+   compatible = "renesas,r8a7795-fcpf", "renesas,fcpf";
+   reg = <0 0xfe951000 0 0x200>;
+   clocks = < CPG_MOD 614>;
+   power-domains = < R8A7795_PD_A3VP>;
+   };
+
+   fcpf2: fcp@fe952000 {
+   compatible = "renesas,r8a7795-fcpf", "renesas,fcpf";
+   reg = <0 0xfe952000 0 0x200>;
+   clocks = < CPG_MOD 613>;
+   power-domains = < R8A7795_PD_A3VP>;
+   };
};
 };
-- 
2.7.4



[PATCH 3/3] dt-bindings: Add Renesas R-Car FDP1 bindings

2016-06-09 Thread Kieran Bingham
The FDP1 is a de-interlacing module which converts interlaced video to
progressive video. It is also capable of performing pixel format conversion
between YCbCr/YUV formats and RGB formats.

Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 .../devicetree/bindings/media/renesas,fdp1.txt | 34 ++
 1 file changed, 34 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/renesas,fdp1.txt

diff --git a/Documentation/devicetree/bindings/media/renesas,fdp1.txt 
b/Documentation/devicetree/bindings/media/renesas,fdp1.txt
new file mode 100644
index ..e2da2aec5e9f
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/renesas,fdp1.txt
@@ -0,0 +1,34 @@
+Renesas R-Car Fine Display Processor (FDP1)
+---
+
+The FDP1 is a de-interlacing module which converts interlaced video to
+progressive video. It is capable of performing pixel format conversion between
+YCbCr/YUV formats and RGB formats. Only YCbCr/YUV formats are supported as
+an input to the module.
+
+ - compatible: Must be one or more of the following
+
+   - "renesas,r8a7795-fdp1" for R8A7795 (R-Car H3)
+   - "renesas,r8a7796-fdp1" for R8A7796 (R-Car M3-W)
+   - "renesas,fdp1" for generic compatible
+
+   When compatible with the generic version, nodes must list the
+   SoC-specific version corresponding to the platform first, followed by the
+   family-specific and/or generic versions.
+
+ - reg: the register base and size for the device registers
+ - clocks: Reference to the functional clock
+ - renesas,fcp: Reference to the FCPF connected to the FDP1
+
+
+Device node example
+---
+
+   fdp1ch1: fdp1@fe94 {
+   compatible = "renesas,r8a7795-fdp1", "renesas,fdp1";
+   reg = <0 0xfe94 0 0x2400>;
+   interrupts = ;
+   clocks = < CPG_MOD 119>;
+   power-domains = < R8A7795_PD_A3VP>;
+   renesas,fcp = <>;
+   };
\ No newline at end of file
-- 
2.7.4



[PATCH 2/2] arm64: dts: r8a7795: add FDP1 device nodes

2016-06-09 Thread Kieran Bingham
Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 arch/arm64/boot/dts/renesas/r8a7795.dtsi | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a7795.dtsi 
b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
index e63e5f29cceb..0c0aa14f7f4d 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
@@ -1244,5 +1244,32 @@
clocks = < CPG_MOD 613>;
power-domains = < R8A7795_PD_A3VP>;
};
+
+   fdp1ch1: fdp1@fe94 {
+   compatible = "renesas,r8a7795-fdp1", "renesas,fdp1";
+   reg = <0 0xfe94 0 0x2400>;
+   interrupts = ;
+   clocks = < CPG_MOD 119>;
+   power-domains = < R8A7795_PD_A3VP>;
+   renesas,fcp = <>;
+   };
+
+   fdp1ch2: fdp1@fe944000 {
+   compatible = "renesas,r8a7795-fdp1", "renesas,fdp1";
+   reg = <0 0xfe944000 0 0x2400>;
+   interrupts = ;
+   clocks = < CPG_MOD 118>;
+   power-domains = < R8A7795_PD_A3VP>;
+   renesas,fcp = <>;
+   };
+
+   fdp1ch3: fdp1@fe948000 {
+   compatible = "renesas,r8a7795-fdp1", "renesas,fdp1";
+   reg = <0 0xfe948000 0 0x2400>;
+   interrupts = ;
+   clocks = < CPG_MOD 117>;
+   power-domains = < R8A7795_PD_A3VP>;
+   renesas,fcp = <>;
+   };
};
 };
-- 
2.7.4



[PATCH 1/2] arm64: dts: r8a7795: add FCPF device nodes

2016-06-09 Thread Kieran Bingham
Provide nodes for the FCP devices dedicated to the FDP device channels.

Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 arch/arm64/boot/dts/renesas/r8a7795.dtsi | 21 +
 1 file changed, 21 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a7795.dtsi 
b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
index 3285a9286786..e63e5f29cceb 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
@@ -1223,5 +1223,26 @@
power-domains = < R8A7795_PD_ALWAYS_ON>;
status = "disabled";
};
+
+   fcpf0: fcp@fe95 {
+   compatible = "renesas,r8a7795-fcpf", "renesas,fcpf";
+   reg = <0 0xfe95 0 0x200>;
+   clocks = < CPG_MOD 615>;
+   power-domains = < R8A7795_PD_A3VP>;
+   };
+
+   fcpf1: fcp@fe951000 {
+   compatible = "renesas,r8a7795-fcpf", "renesas,fcpf";
+   reg = <0 0xfe951000 0 0x200>;
+   clocks = < CPG_MOD 614>;
+   power-domains = < R8A7795_PD_A3VP>;
+   };
+
+   fcpf2: fcp@fe952000 {
+   compatible = "renesas,r8a7795-fcpf", "renesas,fcpf";
+   reg = <0 0xfe952000 0 0x200>;
+   clocks = < CPG_MOD 613>;
+   power-domains = < R8A7795_PD_A3VP>;
+   };
};
 };
-- 
2.7.4



[PATCH] v4l: Extend FCP compatible list to support the FDP

2016-06-09 Thread Kieran Bingham
The FCP must be powered up for the FDP1 to function, even when the FDP1
does not make use of the FCNL features. Extend the compatible list
to allow us to use the power domain and runtime-pm support.

Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 drivers/media/platform/rcar-fcp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/rcar-fcp.c 
b/drivers/media/platform/rcar-fcp.c
index 6a7bcc3028b1..0ff6b1edf1db 100644
--- a/drivers/media/platform/rcar-fcp.c
+++ b/drivers/media/platform/rcar-fcp.c
@@ -160,6 +160,7 @@ static int rcar_fcp_remove(struct platform_device *pdev)
 
 static const struct of_device_id rcar_fcp_of_match[] = {
{ .compatible = "renesas,fcpv" },
+   { .compatible = "renesas,fcpf" },
{ },
 };
 
-- 
2.7.4



[PATCH] v4l: Extend FCP compatible list to support the FDP

2016-06-09 Thread Kieran Bingham
The following patch extends Laurents FCP driver to support the FCP for
FDP (FCPF) which is used by the FDP driver currently in development

This patch is of course dependant upon Laurents FCP driver series [0]
which has not yet hit mainline

[0] http://www.spinics.net/lists/linux-media/msg97302.html

Kieran Bingham (1):
  v4l: Extend FCP compatible list to support the FDP

 drivers/media/platform/rcar-fcp.c | 1 +
 1 file changed, 1 insertion(+)

-- 
2.7.4



Re: [PATCH 1/3] dt-bindings: Update Renesas R-Car FCP DT binding

2016-06-13 Thread Kieran Bingham
On 10/06/16 18:37, Rob Herring wrote:
> On Thu, Jun 09, 2016 at 02:41:32PM +0100, Kieran Bingham wrote:
>> The FCP driver, can also support the FCPF variant for FDP1 compatible
> 
> Drop the comma.

Ok

>> processing.
>>
>> Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
>> ---
>>  Documentation/devicetree/bindings/media/renesas,fcp.txt | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> With that,
> 
> Acked-by: Rob Herring <r...@kernel.org>

Thanks



Re: R8A7795 FDP1 clock parentage

2016-05-30 Thread Kieran Bingham
Hi Morimoto-san,

On 30/05/16 07:32, Kuninori Morimoto wrote:
>>> Just to add to this request, could you ask the HW engineers to confirm
>>> the clock parents for the FCPF (0,1,2) as well please?
>>>
>>> They too are currently listed as R8A7795_CLK_S2D1, however now that I am
>>> trying to enable the FCPF and read registers from it - the VCR is
>>> returning as 0x00 (I expect 0x0101) and then I'm getting
>>>  "Bad mode in Error handler detected, code 0xbf02 -- SError"
>>>
>>> My suspicion is that my clock has not been enabled correctly :)
>>
>> About FCP, I had same request from Laurent, and its answer was this thread.
>>
>> http://thread.gmane.org/gmane.linux.kernel.renesas-soc/662/focus=1304

Thank you for that reference. It was helpful!

>> # I think this "parent clock" settings itself is not super critical
>> # (= it works anyway with wrong settings)
>> # it seems other issues ?

You were right :) - It was the power-domain. It's resolved now and
working. Thank you for your help.

> I got information from HW team.
> About H3 ES1 FDP1 parent clock is "S2D1"

Perfect, thanks for confirming this. Now the patch is unblocked from
submission.

-- 
Regards

Kieran Bingham


Re: [PATCH 2/4] dt-bindings: Update Renesas R-Car FCP DT binding

2016-05-30 Thread Kieran Bingham
Hi Geert!

On 28/05/16 20:06, Geert Uytterhoeven wrote:
> Hi Kieran,
> 
> On Fri, May 27, 2016 at 7:19 PM, Kieran Bingham <kie...@ksquared.org.uk> 
> wrote:
>> The FCP driver, can also support the FCPF variant for FDP1 compatible
>> processing.
>>
>> Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
> 
> Thanks for your patch!
> 
>> ---
>>  Documentation/devicetree/bindings/media/renesas,fcp.txt | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> Cc: devicet...@vger.kernel.org
>>
>> diff --git a/Documentation/devicetree/bindings/media/renesas,fcp.txt 
>> b/Documentation/devicetree/bindings/media/renesas,fcp.txt
>> index 6a12960609d8..1c0718b501ef 100644
>> --- a/Documentation/devicetree/bindings/media/renesas,fcp.txt
>> +++ b/Documentation/devicetree/bindings/media/renesas,fcp.txt
>> @@ -7,11 +7,12 @@ conversion of AXI transactions in order to reduce the 
>> memory bandwidth.
>>
>>  There are three types of FCP: FCP for Codec (FCPC), FCP for VSP (FCPV) and 
>> FCP
>>  for FDP (FCPF). Their configuration and behaviour depend on the module they
>> -are paired with. These DT bindings currently support the FCPV only.
>> +are paired with. These DT bindings currently support the FCPV and FCPF.
>>
>>   - compatible: Must be one or more of the following
>>
>> - "renesas,r8a7795-fcpv" for R8A7795 (R-Car H3) compatible 'FCP for VSP'
>> +   - "renesas,r8a7795-fcpf" for R8A7795 (R-Car H3) compatible 'FCP for FDP'
>> - "renesas,fcpv" for generic compatible 'FCP for VSP'
> 
> I guess checkpatch complained about your dtsi additions because you forgot
> to add  "renesas,fcpf" here?

Yes. Looks quite obvious doesn't it :)
I thought CP.pl was complaining because the file was renesas,fcp.txt,
and I was adding in fcpf!.

I was clearly a bit too keen to get those patches out on a friday
evening. I must remember that I'm not smarter than checkpatch!

I'll add the missing line :)

> Gr{oetje,eeting}s,
> 
> Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds
> 

-- 
Regards

Kieran Bingham


Re: [PATCH 3/4] dt-bindings: Document Renesas R-Car FCP power-domains usage

2016-05-30 Thread Kieran Bingham
Hi Geert,

On 28/05/16 20:03, Geert Uytterhoeven wrote:
> Hi Kieran,
> 
> On Fri, May 27, 2016 at 7:19 PM, Kieran Bingham <kie...@ksquared.org.uk> 
> wrote:
>> The example misses the power-domains usage, and documentation that the
>> property is used by the node.
>>
>> Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
> 
> Thanks for your patch!
> 
>> ---
>>  Documentation/devicetree/bindings/media/renesas,fcp.txt | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/media/renesas,fcp.txt 
>> b/Documentation/devicetree/bindings/media/renesas,fcp.txt
>> index 1c0718b501ef..464bb7ae4b92 100644
>> --- a/Documentation/devicetree/bindings/media/renesas,fcp.txt
>> +++ b/Documentation/devicetree/bindings/media/renesas,fcp.txt
>> @@ -21,6 +21,8 @@ are paired with. These DT bindings currently support the 
>> FCPV and FCPF.
>>
>>   - reg: the register base and size for the device registers
>>   - clocks: Reference to the functional clock
>> + - power-domains : power-domain property defined with a phandle
>> +   to respective power domain.
> 
> I'd write "power domain specifier" instead of "phandle". While SYSC on R-Car
> Gen3 uses #power-domain-cells = 0, the FCP module may show up on another
> SoC that uses a different value, needing more than just a phandle.
> 
> In fact I'm inclined to leave out the power-domains property completely:
> it's not a feature of the FCP, but of the SoC the FCP is part of.
> power-domains properties may appear in any device node where needed.

I'm happy to just drop this part. It was mainly the addition to the
example I was after, as I had followed the example, and thus missed the
power-domain setting.

>>  Device node example
>> @@ -30,4 +32,5 @@ Device node example
>> compatible = "renesas,r8a7795-fcpv", "renesas,fcpv";
>> reg = <0 0xfea2f000 0 0x200>;
>> clocks = < CPG_MOD 602>;
>> +   power-domains = < R8A7795_PD_A3VP>;
> 
> Adding it to the example doesn't hurt, though.

Ok, I'll adjust and just keep the example in v2.

-- 
Regards

Kieran Bingham


[PATCH 0/4] RCar r8a7795 FCPF support

2016-05-27 Thread Kieran Bingham
An RCar FCP driver is available with support for the FCPV module for VSP.
This series updates that driver to support the FCPF and then provide the
relevant nodes in the r8a7795 device tree.

Checkpatch generates a warning on these DT references but they are
documented under Documentation/devicetree/bindings/media/renesas,fcp.txt

These patches are based on Geert's renesas-drivers tree, and are pushed
to a branch at g...@github.com:kbingham/linux.git renesas/fcpf for
convenience.

Kieran Bingham (4):
  v4l: Extend FCP compatible list to support the FDP
  dt-bindings: Update Renesas R-Car FCP DT binding
  dt-bindings: Document Renesas R-Car FCP power-domains usage
  arm64: dts: r8a7795: add FCPF device nodes

 .../devicetree/bindings/media/renesas,fcp.txt   |  6 +-
 arch/arm64/boot/dts/renesas/r8a7795.dtsi| 21 +
 drivers/media/platform/rcar-fcp.c   |  1 +
 3 files changed, 27 insertions(+), 1 deletion(-)

-- 
2.5.0



[PATCH 3/4] dt-bindings: Document Renesas R-Car FCP power-domains usage

2016-05-27 Thread Kieran Bingham
The example misses the power-domains usage, and documentation that the
property is used by the node.

Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 Documentation/devicetree/bindings/media/renesas,fcp.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/renesas,fcp.txt 
b/Documentation/devicetree/bindings/media/renesas,fcp.txt
index 1c0718b501ef..464bb7ae4b92 100644
--- a/Documentation/devicetree/bindings/media/renesas,fcp.txt
+++ b/Documentation/devicetree/bindings/media/renesas,fcp.txt
@@ -21,6 +21,8 @@ are paired with. These DT bindings currently support the FCPV 
and FCPF.
 
  - reg: the register base and size for the device registers
  - clocks: Reference to the functional clock
+ - power-domains : power-domain property defined with a phandle
+   to respective power domain.
 
 
 Device node example
@@ -30,4 +32,5 @@ Device node example
compatible = "renesas,r8a7795-fcpv", "renesas,fcpv";
reg = <0 0xfea2f000 0 0x200>;
clocks = < CPG_MOD 602>;
+   power-domains = < R8A7795_PD_A3VP>;
};
-- 
2.5.0



[PATCH 4/4] arm64: dts: r8a7795: add FCPF device nodes

2016-05-27 Thread Kieran Bingham
Provide nodes for the FCP devices dedicated to the FDP device channels.

Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 arch/arm64/boot/dts/renesas/r8a7795.dtsi | 21 +
 1 file changed, 21 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a7795.dtsi 
b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
index 26df3001617e..14f086b9036d 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
@@ -1610,5 +1610,26 @@
interrupts = <0 436 IRQ_TYPE_LEVEL_HIGH>;
clocks = < CPG_MOD 728>;
};
+
+   fcpf0: fcp@fe95 {
+   compatible = "renesas,r8a7795-fcpf", "renesas,fcpf";
+   reg = <0 0xfe95 0 0x200>;
+   clocks = < CPG_MOD 615>;
+   power-domains = < R8A7795_PD_A3VP>;
+   };
+
+   fcpf1: fcp@fe951000 {
+   compatible = "renesas,r8a7795-fcpf", "renesas,fcpf";
+   reg = <0 0xfe951000 0 0x200>;
+   clocks = < CPG_MOD 614>;
+   power-domains = < R8A7795_PD_A3VP>;
+   };
+
+   fcpf2: fcp@fe952000 {
+   compatible = "renesas,r8a7795-fcpf", "renesas,fcpf";
+   reg = <0 0xfe952000 0 0x200>;
+   clocks = < CPG_MOD 613>;
+   power-domains = < R8A7795_PD_A3VP>;
+   };
};
 };
-- 
2.5.0



[PATCH 2/4] dt-bindings: Update Renesas R-Car FCP DT binding

2016-05-27 Thread Kieran Bingham
The FCP driver, can also support the FCPF variant for FDP1 compatible
processing.

Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 Documentation/devicetree/bindings/media/renesas,fcp.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Cc: devicet...@vger.kernel.org

diff --git a/Documentation/devicetree/bindings/media/renesas,fcp.txt 
b/Documentation/devicetree/bindings/media/renesas,fcp.txt
index 6a12960609d8..1c0718b501ef 100644
--- a/Documentation/devicetree/bindings/media/renesas,fcp.txt
+++ b/Documentation/devicetree/bindings/media/renesas,fcp.txt
@@ -7,11 +7,12 @@ conversion of AXI transactions in order to reduce the memory 
bandwidth.
 
 There are three types of FCP: FCP for Codec (FCPC), FCP for VSP (FCPV) and FCP
 for FDP (FCPF). Their configuration and behaviour depend on the module they
-are paired with. These DT bindings currently support the FCPV only.
+are paired with. These DT bindings currently support the FCPV and FCPF.
 
  - compatible: Must be one or more of the following
 
- "renesas,r8a7795-fcpv" for R8A7795 (R-Car H3) compatible 'FCP for VSP'
+   - "renesas,r8a7795-fcpf" for R8A7795 (R-Car H3) compatible 'FCP for FDP'
- "renesas,fcpv" for generic compatible 'FCP for VSP'
 
When compatible with the generic version, nodes must list the
-- 
2.5.0



[PATCH 1/4] fcp: Extend FCP compatible list to support the FDP

2016-05-27 Thread Kieran Bingham
The FCP must be powered up for the FDP1 to function, even when the FDP1
does not make use of the FCNL features. Extend the compatible list
to allow us to use the power domain and runtime-pm support.

Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 drivers/media/platform/rcar-fcp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/rcar-fcp.c 
b/drivers/media/platform/rcar-fcp.c
index 6a7bcc3028b1..0ff6b1edf1db 100644
--- a/drivers/media/platform/rcar-fcp.c
+++ b/drivers/media/platform/rcar-fcp.c
@@ -160,6 +160,7 @@ static int rcar_fcp_remove(struct platform_device *pdev)
 
 static const struct of_device_id rcar_fcp_of_match[] = {
{ .compatible = "renesas,fcpv" },
+   { .compatible = "renesas,fcpf" },
{ },
 };
 
-- 
2.5.0



[PATCH 1/4] v4l: Extend FCP compatible list to support the FDP

2016-05-27 Thread Kieran Bingham
The FCP must be powered up for the FDP1 to function, even when the FDP1
does not make use of the FCNL features. Extend the compatible list
to allow us to use the power domain and runtime-pm support.

Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 drivers/media/platform/rcar-fcp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/rcar-fcp.c 
b/drivers/media/platform/rcar-fcp.c
index 6a7bcc3028b1..0ff6b1edf1db 100644
--- a/drivers/media/platform/rcar-fcp.c
+++ b/drivers/media/platform/rcar-fcp.c
@@ -160,6 +160,7 @@ static int rcar_fcp_remove(struct platform_device *pdev)
 
 static const struct of_device_id rcar_fcp_of_match[] = {
{ .compatible = "renesas,fcpv" },
+   { .compatible = "renesas,fcpf" },
{ },
 };
 
-- 
2.5.0



Re: [PATCH 1/4] fcp: Extend FCP compatible list to support the FDP

2016-05-27 Thread Kieran Bingham
My apologies - I had a stale file in my patches folder :(
This one had the wrong commit-shortlog, please ignore.

--
Kieran

On 27/05/16 18:19, Kieran Bingham wrote:
> The FCP must be powered up for the FDP1 to function, even when the FDP1
> does not make use of the FCNL features. Extend the compatible list
> to allow us to use the power domain and runtime-pm support.
> 
> Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
> ---
>  drivers/media/platform/rcar-fcp.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/media/platform/rcar-fcp.c 
> b/drivers/media/platform/rcar-fcp.c
> index 6a7bcc3028b1..0ff6b1edf1db 100644
> --- a/drivers/media/platform/rcar-fcp.c
> +++ b/drivers/media/platform/rcar-fcp.c
> @@ -160,6 +160,7 @@ static int rcar_fcp_remove(struct platform_device *pdev)
>  
>  static const struct of_device_id rcar_fcp_of_match[] = {
>   { .compatible = "renesas,fcpv" },
> + { .compatible = "renesas,fcpf" },
>   { },
>  };
>  
> 

-- 
Regards

Kieran Bingham


[PATCH] clk: renesas: Provide r8a7795 FDP1 clocks

2016-05-17 Thread Kieran Bingham
Add the clocks with a parent of S2D1 for now, until the correct
parentage is identified
---
 drivers/clk/renesas/r8a7795-cpg-mssr.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/clk/renesas/r8a7795-cpg-mssr.c 
b/drivers/clk/renesas/r8a7795-cpg-mssr.c
index 6af7f5b6e824..5fdc6bd840a4 100644
--- a/drivers/clk/renesas/r8a7795-cpg-mssr.c
+++ b/drivers/clk/renesas/r8a7795-cpg-mssr.c
@@ -128,6 +128,9 @@ static const struct cpg_core_clk r8a7795_core_clks[] 
__initconst = {
 };
 
 static const struct mssr_mod_clk r8a7795_mod_clks[] __initconst = {
+   DEF_MOD("fdp1-ch2",  117,   R8A7795_CLK_S2D1),
+   DEF_MOD("fdp1-ch1",  118,   R8A7795_CLK_S2D1),
+   DEF_MOD("fdp1-ch0",  119,   R8A7795_CLK_S2D1),
DEF_MOD("scif5", 202,   R8A7795_CLK_S3D4),
DEF_MOD("scif4", 203,   R8A7795_CLK_S3D4),
DEF_MOD("scif3", 204,   R8A7795_CLK_S3D4),
-- 
2.5.0



[PATCH] Provide r8a7795 FDP1 clocks

2016-05-17 Thread Kieran Bingham
Hi All,

I've now got the FDP1 powered up and reading registers, and the cpg-mssr
is updated to support this. However, we did not have a mapping to identify
the correct clock parent. For now I have used the R8A7795_CLK_S2D1, but
does anyone have a clock tree diagram to verify this, or identify the
correct parent please?

Kieran Bingham (1):
  clk: renesas: Provide r8a7795 FDP1 clocks

 drivers/clk/renesas/r8a7795-cpg-mssr.c | 3 +++
 1 file changed, 3 insertions(+)

-- 
2.5.0



Re: [PATCH] clk: renesas: Provide r8a7795 FDP1 clocks

2016-05-17 Thread Kieran Bingham
Thanks Geert,

On 17/05/16 11:25, Geert Uytterhoeven wrote:
> Hi Kieran,
> 
> On Tue, May 17, 2016 at 12:03 PM, Kieran Bingham <kie...@ksquared.org.uk> 
> wrote:
>> Add the clocks with a parent of S2D1 for now, until the correct
>> parentage is identified
> 
> Thanks for your patch!
> 
>> --- a/drivers/clk/renesas/r8a7795-cpg-mssr.c
>> +++ b/drivers/clk/renesas/r8a7795-cpg-mssr.c
>> @@ -128,6 +128,9 @@ static const struct cpg_core_clk r8a7795_core_clks[] 
>> __initconst = {
>>  };
>>
>>  static const struct mssr_mod_clk r8a7795_mod_clks[] __initconst = {
>> +   DEF_MOD("fdp1-ch2",  117,   R8A7795_CLK_S2D1),
>> +   DEF_MOD("fdp1-ch1",  118,   R8A7795_CLK_S2D1),
>> +   DEF_MOD("fdp1-ch0",  119,   R8A7795_CLK_S2D1),
> 
> I would call them "fdp1-2" etc., to match the documentation for the various
> Module Stop registers.

Ok. I've adjusted the names locally, and I'll await
confirmation/correction on the clock parents before a resubmit with
updated commit-log/sign-off.

I presume patches can be integrated as soon as they are wholly
independent? i.e. this update, and the DTS updates for the FDP1, then
the FDP1 driver itself? or would it be preferred to batch the whole lot
up into one set?

Possibly just as well to keep the DT, and driver close together...

> Apart from that:
> Reviewed-by: Geert Uytterhoeven <geert+rene...@glider.be>
> 
> Gr{oetje,eeting}s,
> 
> Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds
> 

-- 
Regards

Kieran Bingham


R8A7795 FDP1 clock parentage

2016-05-25 Thread Kieran Bingham
Hi Morimoto-san,

I have added an initial patch to support the FDP1 in the clock
framework, but I have not been able to correctly identify the actual
clock parent.

For now I have assumed that it is R8A7795_CLK_S2D1.

Could you please confirm this selection, or help identify the true
parent please?
--
Regards

Kieran


Re: R8A7795 FDP1 clock parentage

2016-05-25 Thread Kieran Bingham
On 25/05/16 09:49, Kuninori Morimoto wrote:
> 
> Hi Kieran
> 
>> I have added an initial patch to support the FDP1 in the clock
>> framework, but I have not been able to correctly identify the actual
>> clock parent.
>>
>> For now I have assumed that it is R8A7795_CLK_S2D1.
>>
>> Could you please confirm this selection, or help identify the true
>> parent please?
> 
> OK, please wait

Thanks,

Just to add to this request, could you ask the HW engineers to confirm
the clock parents for the FCPF (0,1,2) as well please?

They too are currently listed as R8A7795_CLK_S2D1, however now that I am
trying to enable the FCPF and read registers from it - the VCR is
returning as 0x00 (I expect 0x0101) and then I'm getting
 "Bad mode in Error handler detected, code 0xbf02 -- SError"

My suspicion is that my clock has not been enabled correctly :)

Thanks again for your help
-- 
Regards

Kieran Bingham


Re: [PATCH] [media] fdp1: vb2_queue dev conversion

2016-07-19 Thread Kieran Bingham
 allocator\n");
> - return PTR_ERR(fdp1->alloc_ctx);
> - }
> -
>   /* V4L2 device registration */
>   ret = v4l2_device_register(>dev, >v4l2_dev);
>   if (ret) {
>   v4l2_err(>v4l2_dev, "Failed to register video device\n");
> - goto vb2_allocator_rollback;
> + return ret;
>   }
>  
>   /* M2M registration */
> @@ -2327,9 +2317,6 @@ release_m2m:
>  unreg_dev:
>   v4l2_device_unregister(>v4l2_dev);
>  
> -vb2_allocator_rollback:
> - vb2_dma_contig_cleanup_ctx(fdp1->alloc_ctx);
> -
>   return ret;
>  }
>  
> @@ -2340,7 +2327,6 @@ static int fdp1_remove(struct platform_device *pdev)
>   v4l2_m2m_release(fdp1->m2m_dev);
>   video_unregister_device(>vfd);
>   v4l2_device_unregister(>v4l2_dev);
> - vb2_dma_contig_cleanup_ctx(fdp1->alloc_ctx);
>   pm_runtime_disable(>dev);
>  
>   return 0;
> 

-- 
Regards

Kieran Bingham


[PATCH] v4l: platform: Add Renesas R-Car FDP1 Driver

2016-06-30 Thread Kieran Bingham
The FDP1 driver performs advanced de-interlacing on a memory 2 memory
based video stream, and supports conversion from YCbCr/YUV
to RGB pixel formats

Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 MAINTAINERS|9 +
 drivers/media/platform/Kconfig |   13 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/rcar_fdp1.c | 2395 
 4 files changed, 2418 insertions(+)
 create mode 100644 drivers/media/platform/rcar_fdp1.c

diff --git a/MAINTAINERS b/MAINTAINERS
index eb5e3b673c1d..985d243ff066 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7331,6 +7331,15 @@ F:   
Documentation/devicetree/bindings/media/renesas,fcp.txt
 F: drivers/media/platform/rcar-fcp.c
 F: include/media/rcar-fcp.h
 
+MEDIA DRIVERS FOR RENESAS - FDP1
+M: Kieran Bingham <kie...@bingham.xyz>
+L: linux-me...@vger.kernel.org
+L: linux-renesas-soc@vger.kernel.org
+T: git git://linuxtv.org/media_tree.git
+S: Supported
+F: Documentation/devicetree/bindings/media/renesas,fdp1.txt
+F: drivers/media/platform/rcar_fdp1.c
+
 MEDIA DRIVERS FOR RENESAS - VSP1
 M: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
 L: linux-me...@vger.kernel.org
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 0141af8cfdbc..80cdc3b6efa3 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -235,6 +235,19 @@ config VIDEO_SH_VEU
Support for the Video Engine Unit (VEU) on SuperH and
SH-Mobile SoCs.
 
+config VIDEO_RENESAS_FDP1
+   tristate "Renesas Fine Display Processor"
+   depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
+   depends on ARCH_SHMOBILE || COMPILE_TEST
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   ---help---
+ This is a V4L2 driver for the Renesas Fine Display Processor
+ providing colour space conversion, and de-interlacing features.
+
+ To compile this driver as a module, choose M here: the module
+ will be called rcar_fdp1.
+
 config VIDEO_RENESAS_JPU
tristate "Renesas JPEG Processing Unit"
depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index befc4f97057c..0c8a3ae7b6cb 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -47,6 +47,7 @@ obj-$(CONFIG_VIDEO_SH_VOU)+= sh_vou.o
 obj-$(CONFIG_SOC_CAMERA)   += soc_camera/
 
 obj-$(CONFIG_VIDEO_RENESAS_FCP)+= rcar-fcp.o
+obj-$(CONFIG_VIDEO_RENESAS_FDP1)   += rcar_fdp1.o
 obj-$(CONFIG_VIDEO_RENESAS_JPU)+= rcar_jpu.o
 obj-$(CONFIG_VIDEO_RENESAS_VSP1)   += vsp1/
 
diff --git a/drivers/media/platform/rcar_fdp1.c 
b/drivers/media/platform/rcar_fdp1.c
new file mode 100644
index ..c7280183262a
--- /dev/null
+++ b/drivers/media/platform/rcar_fdp1.c
@@ -0,0 +1,2395 @@
+/*
+ * Renesas RCar Fine Display Processor
+ *
+ * Video format converter and frame deinterlacer device.
+ *
+ * Author: Kieran Bingham, <kie...@bingham.xyz>
+ * Copyright (c) 2016 Renesas Electronics Corporation.
+ *
+ * This code is developed and inspired from the vim2m, rcar_jpu,
+ * m2m-deinterlace, and vsp1 drivers.
+ *
+ * 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
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static unsigned int debug;
+module_param(debug, uint, 0644);
+MODULE_PARM_DESC(debug, "activate debug info");
+
+/* Min Width/Height/Height-Field */
+#define FDP1_MIN_W 80U
+#define FDP1_MIN_H 80U
+
+#define FDP1_MAX_W 3840U
+#define FDP1_MAX_H 2160U
+
+#define FDP1_MAX_PLANES3U
+
+/* Flags that indicate a format can be used for capture/output */
+#define FDP1_CAPTURE   BIT(0)
+#define FDP1_OUTPUTBIT(1)
+
+#define DRIVER_NAME"rcar_fdp1"
+
+/* Number of Job's to have available on the processing queue */
+#define FDP1_NUMBER_JOBS 8
+#define FDP1_NUMBER_BUFFERS ((FDP1_NUMBER_JOBS*2)+1)
+
+#define dprintk(fdp1, fmt, arg...) \
+   v4l2_dbg(1, debug, >v4l2_dev, "%s: " fmt, __func__, ## arg)
+
+/*
+ * FDP1 registers and bits
+ */
+
+/* FDP1 start register - Imm */
+#define FD1_CTL_CMD0x
+#define FD1_CTL_CMD_STRCMD BIT(0)
+
+/* Sync generator register - Imm */
+#define FD1_CTL_SGCMD  0x0004
+#define FD1_CTL_SGCMD_SGEN   

[PATCH v2] v4l: platform: Add Renesas R-Car FDP1 Driver

2016-06-30 Thread Kieran Bingham
Version 2 of the FDP1 driver introduces support for deinterlacing on top
of the previous patch which only supported pixel format conversion.

The FDP1, (Fine Display Processor) is a de-interlacer device, with capability
to convert from various YCbCr/YUV formats to both YCbCr/YUV and RGB formats
at the same time as converting interlaced content to progressive.

Kieran Bingham (1):
  v4l: platform: Add Renesas R-Car FDP1 Driver

 MAINTAINERS|9 +
 drivers/media/platform/Kconfig |   13 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/rcar_fdp1.c | 2395 
 4 files changed, 2418 insertions(+)
 create mode 100644 drivers/media/platform/rcar_fdp1.c

-- 
2.7.4



[PATCH v2 0/2] arm64: dts: r8a7795: FCPF and FDP1 device nodes

2016-06-30 Thread Kieran Bingham
Hi Simon,

Here is my updated series for the dts updates in relation to the RCar/FDP1.

The fcpf patch has collected a reviewed-by from Geert, whilst the fdp1
patch has collected a reviewed by from both Laurent and Geert, with a
small change to remove the labels, as they will not be referenced.

You responded to my previous set for these with the following comment:

> These patches look good to me. My assumption is that they
> can be applied without causing any breakage and that the
> relevant features will start working once driver support
> shows up in the kernel.
> 
> If the above assumption is correct then please let me know when the
> bindings have been accepted by the relevant subsystem maintainer(s).
> 
> If the patches need rebasing at that time then please repost them.
> Otherwise you can either repost them or ping me as a response to this thread.

Your assumption was correct, and they could be applied without breakage.

RobH has acked the binding for the RCar FCPF, but I have not seen an ack for
the FDP1 binding yet. I'll follow that up, and ping you on the fdp1 dts patch
when it resolved.

Regards

Kieran

--

Kieran Bingham (2):
  arm64: dts: r8a7795: add FCPF device nodes
  arm64: dts: r8a7795: add FDP1 device nodes

 arch/arm64/boot/dts/renesas/r8a7795.dtsi | 48 
 1 file changed, 48 insertions(+)

-- 
2.7.4



[PATCH 1/2] arm64: dts: r8a7795: add FCPF device nodes

2016-06-30 Thread Kieran Bingham
Provide nodes for the FCP devices dedicated to the FDP device channels.

Reviewed-by: Geert Uytterhoeven <geert+rene...@glider.be>
Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 arch/arm64/boot/dts/renesas/r8a7795.dtsi | 21 +
 1 file changed, 21 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a7795.dtsi 
b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
index fff92acc5d2e..a451bd217f05 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
@@ -1422,5 +1422,26 @@
};
};
};
+
+   fcpf0: fcp@fe95 {
+   compatible = "renesas,r8a7795-fcpf", "renesas,fcpf";
+   reg = <0 0xfe95 0 0x200>;
+   clocks = < CPG_MOD 615>;
+   power-domains = < R8A7795_PD_A3VP>;
+   };
+
+   fcpf1: fcp@fe951000 {
+   compatible = "renesas,r8a7795-fcpf", "renesas,fcpf";
+   reg = <0 0xfe951000 0 0x200>;
+   clocks = < CPG_MOD 614>;
+   power-domains = < R8A7795_PD_A3VP>;
+   };
+
+   fcpf2: fcp@fe952000 {
+   compatible = "renesas,r8a7795-fcpf", "renesas,fcpf";
+   reg = <0 0xfe952000 0 0x200>;
+   clocks = < CPG_MOD 613>;
+   power-domains = < R8A7795_PD_A3VP>;
+   };
};
 };
-- 
2.7.4



[PATCH 2/2] arm64: dts: r8a7795: add FDP1 device nodes

2016-06-30 Thread Kieran Bingham
Reviewed-by: Geert Uytterhoeven <geert+rene...@glider.be>
Reviewed-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
--
changes for v2
 - channel labels dropped

 arch/arm64/boot/dts/renesas/r8a7795.dtsi | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a7795.dtsi 
b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
index a451bd217f05..8bc87e09efd7 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
@@ -1443,5 +1443,32 @@
clocks = < CPG_MOD 613>;
power-domains = < R8A7795_PD_A3VP>;
};
+
+   fdp1@fe94 {
+   compatible = "renesas,fdp1";
+   reg = <0 0xfe94 0 0x2400>;
+   interrupts = ;
+   clocks = < CPG_MOD 119>;
+   power-domains = < R8A7795_PD_A3VP>;
+   renesas,fcp = <>;
+   };
+
+   fdp1@fe944000 {
+   compatible = "renesas,fdp1";
+   reg = <0 0xfe944000 0 0x2400>;
+   interrupts = ;
+   clocks = < CPG_MOD 118>;
+   power-domains = < R8A7795_PD_A3VP>;
+   renesas,fcp = <>;
+   };
+
+   fdp1@fe948000 {
+   compatible = "renesas,fdp1";
+   reg = <0 0xfe948000 0 0x2400>;
+   interrupts = ;
+   clocks = < CPG_MOD 117>;
+   power-domains = < R8A7795_PD_A3VP>;
+   renesas,fcp = <>;
+   };
};
 };
-- 
2.7.4



[GIT PULL FOR renesas-drivers] FDP1 Fine Display Processor support

2016-06-30 Thread Kieran Bingham
Hi Geert,

The following changes since commit f50e3d0720c0f27476153c2c7129b18639228d1b:

  Merge branch 'drm/next/dt' into for/renesas-drivers (2016-06-21 18:01:05 
+0300)

are available in the git repository at:

  https://github.com/kbingham/linux.git renesas/fdp1

for you to fetch changes up to 06f3e8e204a41e68ab649a26c557e7bc4c01c0f0:

  Merge branches 'renesas/fdp1-dt' and 'renesas/fdp1-driver' into renesas/fdp1 
(2016-06-30 10:13:43 +0100)


Kieran Bingham (9):
  dt-bindings: Update Renesas R-Car FCP DT binding
  dt-bindings: Document Renesas R-Car FCP power-domains usage
  dt-bindings: Add Renesas R-Car FDP1 bindings
  arm64: dts: r8a7795: add FCPF device nodes
  arm64: dts: r8a7795: add FDP1 device nodes
  clk: renesas: r8a7795: Provide FDP1 clocks
  v4l: Extend FCP compatible list to support the FDP
  v4l: platform: Add Renesas R-Car FDP1 Driver
  Merge branches 'renesas/fdp1-dt' and 'renesas/fdp1-driver' into 
renesas/fdp1

Laurent Pinchart (1):
  v4l: ioctl: Clear the v4l2_pix_format_mplane reserved field

 .../devicetree/bindings/media/renesas,fcp.txt  |5 +-
 .../devicetree/bindings/media/renesas,fdp1.txt |   30 +
 MAINTAINERS|9 +
 arch/arm64/boot/dts/renesas/r8a7795.dtsi   |   48 +
 drivers/clk/renesas/r8a7795-cpg-mssr.c |3 +
 drivers/media/platform/Kconfig |   13 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/rcar-fcp.c  |1 +
 drivers/media/platform/rcar_fdp1.c | 2395 
 drivers/media/v4l2-core/v4l2-ioctl.c   |8 +-
 10 files changed, 2508 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/renesas,fdp1.txt
 create mode 100644 drivers/media/platform/rcar_fdp1.c

Regards
--
Kieran Bingham


[PATCH v2 3/3] dt-bindings: Add Renesas R-Car FDP1 bindings

2016-06-30 Thread Kieran Bingham
The FDP1 is a de-interlacing module which converts interlaced video to
progressive video. It is also capable of performing pixel format conversion
between YCbCr/YUV formats and RGB formats.

Reviewed-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
Changes since v1:
 - title fixed
 - Interrupts property documented
 - version specific compatibles removed as we have a hw version register
 - label removed from device node example
   * (fdp1 is not referenced by other nodes)

 .../devicetree/bindings/media/renesas,fdp1.txt | 33 ++
 1 file changed, 33 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/renesas,fdp1.txt

diff --git a/Documentation/devicetree/bindings/media/renesas,fdp1.txt 
b/Documentation/devicetree/bindings/media/renesas,fdp1.txt
new file mode 100644
index ..e6abd2a17e66
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/renesas,fdp1.txt
@@ -0,0 +1,33 @@
+Renesas R-Car Fine Display Processor (FDP1)
+---
+
+The FDP1 is a de-interlacing module which converts interlaced video to
+progressive video. It is capable of performing pixel format conversion between
+YCbCr/YUV formats and RGB formats. Only YCbCr/YUV formats are supported as
+an input to the module.
+
+ - compatible: Must be the following
+
+   - "renesas,fdp1" for generic compatible
+
+ - reg: the register base and size for the device registers
+ - interrupts : interrupt specifier for the FDP1 instance
+ - clocks: reference to the functional clock
+ - renesas,fcp: reference to the FCPF connected to the FDP1
+
+Optional properties:
+ - power-domains : power-domain property defined with a power domain specifier
+to respective power domain.
+
+
+Device node example
+---
+
+   fdp1@fe94 {
+   compatible = "renesas,fdp1";
+   reg = <0 0xfe94 0 0x2400>;
+   interrupts = ;
+   clocks = < CPG_MOD 119>;
+   power-domains = < R8A7795_PD_A3VP>;
+   renesas,fcp = <>;
+   };
-- 
2.7.4



[PATCH v2 2/3] dt-bindings: Document Renesas R-Car FCP power-domains usage

2016-06-30 Thread Kieran Bingham
The power domain must be specified to bring the device out of module
standby. Document this in the bindings provided, so that new additions
are not missed.

Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 Documentation/devicetree/bindings/media/renesas,fcp.txt | 5 +
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/renesas,fcp.txt 
b/Documentation/devicetree/bindings/media/renesas,fcp.txt
index 271dcfdb5a76..5be21b6411ba 100644
--- a/Documentation/devicetree/bindings/media/renesas,fcp.txt
+++ b/Documentation/devicetree/bindings/media/renesas,fcp.txt
@@ -23,6 +23,10 @@ are paired with. These DT bindings currently support the 
FCPV and FCPF.
  - reg: the register base and size for the device registers
  - clocks: Reference to the functional clock
 
+Optional properties:
+ - power-domains : power-domain property defined with a power domain specifier
+to respective power domain.
+
 
 Device node example
 ---
@@ -31,4 +35,5 @@ Device node example
compatible = "renesas,r8a7795-fcpv", "renesas,fcpv";
reg = <0 0xfea2f000 0 0x200>;
clocks = < CPG_MOD 602>;
+   power-domains = < R8A7795_PD_A3VP>;
};
-- 
2.7.4



Re: [PATCH 2/2] arm64: dts: r8a7795: add FDP1 device nodes

2016-07-01 Thread Kieran Bingham
Hi Simon,

The bindings for this have now been acked by RobH.

--
Cheers

Kieran

On 30/06/16 14:32, Kieran Bingham wrote:
> Reviewed-by: Geert Uytterhoeven <geert+rene...@glider.be>
> Reviewed-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
> Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
> --
> changes for v2
>  - channel labels dropped
> 
>  arch/arm64/boot/dts/renesas/r8a7795.dtsi | 27 +++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/renesas/r8a7795.dtsi 
> b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
> index a451bd217f05..8bc87e09efd7 100644
> --- a/arch/arm64/boot/dts/renesas/r8a7795.dtsi
> +++ b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
> @@ -1443,5 +1443,32 @@
>   clocks = < CPG_MOD 613>;
>   power-domains = < R8A7795_PD_A3VP>;
>   };
> +
> + fdp1@fe94 {
> + compatible = "renesas,fdp1";
> + reg = <0 0xfe94 0 0x2400>;
> + interrupts = ;
> + clocks = < CPG_MOD 119>;
> + power-domains = < R8A7795_PD_A3VP>;
> + renesas,fcp = <>;
> + };
> +
> + fdp1@fe944000 {
> + compatible = "renesas,fdp1";
> + reg = <0 0xfe944000 0 0x2400>;
> + interrupts = ;
> + clocks = < CPG_MOD 118>;
> + power-domains = < R8A7795_PD_A3VP>;
> + renesas,fcp = <>;
> + };
> +
> + fdp1@fe948000 {
> + compatible = "renesas,fdp1";
> + reg = <0 0xfe948000 0 0x2400>;
> + interrupts = ;
> + clocks = < CPG_MOD 117>;
> + power-domains = < R8A7795_PD_A3VP>;
> + renesas,fcp = <>;
> + };
>   };
>  };
> 


[PATCH 2/5] vsp-lib: Filter non-filesystem regular characters

2017-02-08 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

Parameters can contain characters not suited to use in filenames.

Add '=','(', and ')' to the filtering, and replace with '_'

Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
---
 scripts/vsp-lib.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh
index 5aff30217a27..08bf8f36c582 100755
--- a/scripts/vsp-lib.sh
+++ b/scripts/vsp-lib.sh
@@ -263,6 +263,9 @@ compare_frames() {
local params=${args// /-}
params=${params:+-$params}
params=${params//\//_}
+   params=${params/=/_}
+   params=${params/(/_}
+   params=${params/)/_}
params=$in_fmt-$out_fmt-$size$params
 
if [ x$__vsp_pixel_perfect != xtrue ] ; then
-- 
git-series 0.9.1


[PATCH 3/5] gen-image: Implement option to parse an input crop

2017-02-08 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

Allow the user to specify an input crop in the form (X,Y)/WxH

Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
---
 src/gen-image.c | 106 +-
 1 file changed, 106 insertions(+)

diff --git a/src/gen-image.c b/src/gen-image.c
index 9aabefa8389c..2f370e7a8ebd 100644
--- a/src/gen-image.c
+++ b/src/gen-image.c
@@ -97,6 +97,13 @@ struct format_info {
struct format_yuv_info yuv;
 };
 
+struct image_rect {
+   int left;
+   int top;
+   unsigned int width;
+   unsigned int height;
+};
+
 struct image {
const struct format_info *format;
unsigned int width;
@@ -136,6 +143,8 @@ struct options {
struct params params;
enum histogram_type histo_type;
uint8_t histo_areas[12];
+   bool crop;
+   struct image_rect inputcrop;
 };
 
 /* 
-
@@ -1085,6 +1094,26 @@ static void image_flip(const struct image *input, struct 
image *output,
 }
 
 /* 
-
+ * Image Cropping
+ */
+
+static void image_crop(const struct image *input, const struct image *output,
+  const struct image_rect *crop)
+{
+   const uint8_t *idata = input->data;
+   uint8_t *odata = output->data;
+   unsigned int y;
+
+   for (y = 0; y < output->height; ++y) {
+   unsigned int offset = (crop->top * input->width + crop->left) * 
3;
+
+   memcpy(odata + y * output->width * 3,
+  idata + y * input->width * 3 + offset,
+  output->width * 3);
+   }
+}
+
+/* 
-
  * Look Up Table
  */
 
@@ -1539,6 +1568,22 @@ static int process(const struct options *options)
input = rgb;
}
 
+   if (options->crop) {
+   struct image *cropped;
+
+   cropped = image_new(input->format, options->inputcrop.width,
+   options->inputcrop.height);
+
+   if (!cropped) {
+   ret = -ENOMEM;
+   goto done;
+   }
+
+   image_crop(input, cropped, >inputcrop);
+   image_delete(input);
+   input = cropped;
+   }
+
/* Scale */
if (options->output_width && options->output_height) {
output_width = options->output_width;
@@ -1773,6 +1818,7 @@ static void usage(const char *argv0)
printf("or percentages ([0%% - 100%%]). 
Defaults to 1.0\n");
printf("-c, --compose n Compose n copies of the image 
offset by (50,50) over a black background\n");
printf("-C, --no-chroma-average Disable chroma averaging for 
odd pixels on output\n");
+   printf("--crop (X,Y)/WxHCrop the input image\n");
printf("-e, --encoding enc  Set the YCbCr encoding method. 
Valid values are\n");
printf("BT.601, REC.709, BT.2020 and 
SMPTE240M\n");
printf("-f, --format format Set the output image format\n");
@@ -1813,11 +1859,13 @@ static void list_formats(void)
 #define OPT_VFLIP  257
 #define OPT_HISTOGRAM_TYPE 258
 #define OPT_HISTOGRAM_AREAS259
+#define OPT_CROP   260
 
 static struct option opts[] = {
{"alpha", 1, 0, 'a'},
{"clu", 1, 0, 'L'},
{"compose", 1, 0, 'c'},
+   {"crop", 1, 0, OPT_CROP},
{"encoding", 1, 0, 'e'},
{"format", 1, 0, 'f'},
{"help", 0, 0, 'h'},
@@ -1836,6 +1884,58 @@ static struct option opts[] = {
{0, 0, 0, 0}
 };
 
+static int parse_crop(struct options *options, char *optarg)
+{
+   char * endptr;
+
+   /* (X,Y)/WxH */
+   endptr = optarg;
+   if (*endptr != '(') {
+   printf("Invalid crop argument '%s', expected '(', got '%c'\n", 
optarg, *endptr);
+   return 1;
+   }
+
+   options->inputcrop.left = strtol(endptr + 1, , 10);
+   if (*endptr != ',' || endptr == optarg) {
+   printf("Invalid crop position '%s', expected ',', got '%c'\n", 
optarg, *endptr);
+   return 1;
+   }
+
+   options->inputcrop.top = strtol(endptr + 1, , 10);
+   if (*endptr != ')' || endptr == optarg) {
+   printf("Invalid crop position '%s', expected ')', got '%c'\n", 
optarg, *endptr);
+   return 1;
+   }
+
+   if (*endptr != ')') {
+   printf("Invalid crop argument 

[PATCH 1/5] vsp-lib: sort output frames correctly

2017-02-08 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

In the event of failed frames, or VSP_KEEP_FRAMES being set, the output
file names do not sort such that the reference frame is next to the
failed frame.

This can make comparing reference frames and the relevant output frames
tedious and difficult.

Re-arrange the output filenames such that the sort order will match the
option parameters correctly, followed by either the reference frame
identifier, or the frame number at the end of the filename string

Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
---
 scripts/vsp-lib.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh
index 1a356ec02374..5aff30217a27 100755
--- a/scripts/vsp-lib.sh
+++ b/scripts/vsp-lib.sh
@@ -278,12 +278,12 @@ compare_frames() {
}
 
if [ $match = "false" -o x$VSP_KEEP_FRAMES = x1 ] ; then
-   mv $frame ${0/.sh/}-$(basename 
${frame/.bin/-$params.bin})
+   mv $frame ${0/.sh/}-$params-$(basename ${frame})
fi
done
 
if [ x$VSP_KEEP_FRAMES = x1 -o $result = "fail" ] ; then
-   mv ${frames_dir}ref-frame.bin ${0/.sh/}-ref-frame-$params.bin
+   mv ${frames_dir}ref-frame.bin ${0/.sh/}-$params-ref-frame.bin
else
rm -f ${frames_dir}ref-frame.bin
rm -f ${frames_dir}frame-*.bin
-- 
git-series 0.9.1


[PATCH 4/5] vsp-lib: Support RPF frame cropping

2017-02-08 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

Pass the optional '--crop (X,Y)/WxH' parameter through reference_frame
allowing the input to be cropped for comparison

Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
---
 scripts/vsp-lib.sh | 37 +
 1 file changed, 37 insertions(+)

diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh
index 08bf8f36c582..42a4bb20d1be 100755
--- a/scripts/vsp-lib.sh
+++ b/scripts/vsp-lib.sh
@@ -162,6 +162,9 @@ reference_frame() {
vflip)
[ x$value = x1 ] && options="$options --vflip"
;;
+   crop)
+   options="$options --crop $value"
+   ;;
esac
done
 
@@ -717,6 +720,40 @@ format_rpf_wpf() {
__vsp_wpf_format=$5
 }
 
+format_crop_rpf_wpf() {
+   local rpf=$1
+   local wpf=$2
+   local infmt=$(format_v4l2_to_mbus $3)
+   local size=$4
+   local outfmt=$(format_v4l2_to_mbus $5)
+   local rpfcrop=$6
+   local wpfcrop=$7
+   local rpfoutsize=
+   local outsize=
+
+   if [ x$rpfcrop != 'x' ] ; then
+   rpfcrop="crop:$rpfcrop"
+   rpfoutsize=$(echo $rpfcrop | sed 's/.*\///')
+   else
+   rpfoutsize=$size
+   fi
+
+   if [ x$wpfcrop != 'x' ] ; then
+   wpfcrop="crop:$wpfcrop"
+   outsize=$(echo $wpfcrop | sed 's/.*\///')
+   else
+   outsize=$rpfoutsize
+   fi
+
+   $mediactl -d $mdev -V "'$dev rpf.$rpf':0 [fmt:$infmt/$size $rpfcrop]"
+   $mediactl -d $mdev -V "'$dev rpf.$rpf':1 [fmt:$infmt/$rpfoutsize]"
+   $mediactl -d $mdev -V "'$dev wpf.$wpf':0 [fmt:$infmt/$rpfoutsize 
$wpfcrop]"
+   $mediactl -d $mdev -V "'$dev wpf.$wpf':1 [fmt:$outfmt/$outsize]"
+
+   __vsp_rpf_format=$3
+   __vsp_wpf_format=$5
+}
+
 format_wpf() {
local format=$(format_v4l2_to_mbus $1)
local size=$2
-- 
git-series 0.9.1


[PATCH 5/5] tests: Add RPF cropping test

2017-02-08 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

Test both the input cropping size and position

Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
---
 tests/vsp-unit-test-0021.sh | 39 ++-
 1 file changed, 39 insertions(+)
 create mode 100755 tests/vsp-unit-test-0021.sh

diff --git a/tests/vsp-unit-test-0021.sh b/tests/vsp-unit-test-0021.sh
new file mode 100755
index ..d00dd0dece97
--- /dev/null
+++ b/tests/vsp-unit-test-0021.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+#
+# Test RPF crop in RGB and YUV mode. Use a RPF -> WPF pipeline with a fixed 
ARGB32
+# format on the input and capture output frames in all RGB formats supported
+# by the WPF.
+#
+
+source vsp-lib.sh
+
+features="rpf.0 wpf.0"
+crops="(0,0)/512x384 (32,32)/512x384 (32,64)/512x384 (64,32)/512x384"
+
+
+test_rpf_cropping() {
+   test_start "RPF crop from $crop"
+
+   pipe_configure rpf-wpf 0 0
+   format_configure crop-rpf-wpf 0 0 RGB24 1024x768 ARGB32 $crop
+
+   vsp_runner rpf.0 &
+   vsp_runner wpf.0
+
+   local result=$(compare_frames crop=${crop})
+
+   test_complete $result
+}
+
+test_main() {
+   local format
+   local crop
+
+   for crop in $crops ; do
+   test_rpf_cropping $crop
+   done
+}
+
+test_init $0 "$features"
+test_run
-- 
git-series 0.9.1


[PATCH 0/5] vsp-tests: Implement RPF cropping tests

2017-02-08 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

Update the gen-image utility such that it can crop the image at input,
and provide tests to ensure that the output of the RPF is as we expect.

The first patch in the series, reformats the output filenames such that
frames, and the correct reference frame are in the correct sort order in
the filesystem. This helps with comparing the output in case of errors

Kieran Bingham (5):
  vsp-lib: sort output frames correctly
  vsp-lib: Filter non-filesystem regular characters
  gen-image: Implement option to parse an input crop
  vsp-lib: Support RPF frame cropping
  tests: Add RPF cropping test

 scripts/vsp-lib.sh  |  44 ++-
 src/gen-image.c | 106 +-
 tests/vsp-unit-test-0021.sh |  39 ++-
 3 files changed, 187 insertions(+), 2 deletions(-)
 create mode 100755 tests/vsp-unit-test-0021.sh

base-commit: 067d210716b282f7e5ecede5a33c7f7fdabd1358
-- 
git-series 0.9.1


Re: [PATCH] vsp-lib: Fix reference frame generation for HSV input formats

2017-02-20 Thread Kieran Bingham
Hi Laurent,

On 13/02/17 15:46, Laurent Pinchart wrote:
> gen-image doesn't support processing HSV input frames. Fortunately the
> HSV tests don't require it either, when they take an HSV input frame
> they just pass it straight to the WPF. We can thus set the input format
> to RGB for reference frame generation.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
> ---
>  scripts/vsp-lib.sh | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh
> index ae9683cffab6..695e081bf34d 100755
> --- a/scripts/vsp-lib.sh
> +++ b/scripts/vsp-lib.sh
> @@ -103,6 +103,16 @@ reference_frame() {
>   local alpha=
>   local options=
>  
> + # gen-image doesn't support processing HSV input images. The good news
> + # is that the HSV tests that take HSV images as inputs don't need to
> + # perform any processing. We can set the input format to RGB for HSB

s/HSB/HSV/

> + # reference frame generation.
> + case $in_format in
> + HSV24 | HSV32)
> + in_format=ARGB32
> + ;;
> + esac
> +
>   # Start with the input format to compute the alpha value being used by
>   # the RPF after unpacking. Keep in sync with generate_input_frame.
>   case $in_format in

With that,

Reviewed-by: Kieran Bingham <kieran.bing...@ideasonboard.com>



Re: [PATCHv2 2/5] scripts: Provide bin2png.sh helper

2017-02-21 Thread Kieran Bingham
Hi Geert,

On 20/02/17 20:45, Geert Uytterhoeven wrote:
> Hi Kieran,
> 
> On Mon, Feb 20, 2017 at 6:47 PM, Kieran Bingham
> <kieran.bing...@ideasonboard.com> wrote:
>> This change breaks POSIX SH compliance, as reported by shellcheck:
>>
>> In scripts/bin2png.sh line 7:
>> local pnm=${file/%bin/pnm}
>>   ^-- SC2039: In POSIX sh, string replacement is not 
>> supported.
>>
>>
>> In scripts/bin2png.sh line 8:
>> local png=${file/%bin/png}
>>   ^-- SC2039: In POSIX sh, string replacement is not 
>> supported.
>>
>> It also breaks on my system which uses a strict posix compliant shell :D
> 
> Does "local pnm=${file%bin}pnm" work?

Yes, it does indeed seem to work so far!

Thanks for the hint.

I'll test a bit more and hopefully send a patch tomorrow :D

--
Kieran

> Gr{oetje,eeting}s,
> 
> Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds
> 


[PATCH 1/1] scripts: bin2png.sh: Fix POSIX shell compliance

2017-02-22 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

The string manipulations of the form ${VAR/search/replace} are not posix
compliant. Use string deletion, and append instead.

Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
---
 scripts/bin2png.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/bin2png.sh b/scripts/bin2png.sh
index 090f31fa992d..6422ee51bc33 100755
--- a/scripts/bin2png.sh
+++ b/scripts/bin2png.sh
@@ -4,8 +4,8 @@ FILE=${1:-.}
 
 convert_image() {
local file=$1
-   local pnm=${file/%bin/pnm}
-   local png=${file/%bin/png}
+   local pnm=${file%bin}pnm
+   local png=${file%bin}png
 
local format=$(echo $file | sed -e 
's|.*-\([[:alnum:]]*\)-\([0-9]*x[0-9]*\).*.bin|\1|' | tr '[:lower:]' 
'[:upper:]')
local size=$(echo $file   | sed -e 
's|.*-\([[:alnum:]]*\)-\([0-9]*x[0-9]*\).*.bin|\2|')
-- 
2.7.4



[PATCH 5/8] v4l: vsp1: Operate on partition struct data directly

2017-02-10 Thread Kieran Bingham
When generating the partition windows, operate directly on the partition
struct rather than copying and duplicating the processed data

Signed-off-by: Kieran Bingham <kieran.bingham+rene...@ideasonboard.com>
---
 drivers/media/platform/vsp1/vsp1_video.c | 43 -
 1 file changed, 21 insertions(+), 22 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_video.c 
b/drivers/media/platform/vsp1/vsp1_video.c
index a978508a4993..5f1886bfad26 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -189,17 +189,17 @@ static int __vsp1_video_try_format(struct vsp1_video 
*video,
 /**
  * vsp1_video_partition - Calculate the active partition output window
  *
+ * @partition: The active partition data
  * @div_size: pre-determined maximum partition division size
  * @index: partition index
  *
- * Returns a v4l2_rect describing the partition window.
+ * Generates the output partitioning positions.
  */
-static struct v4l2_rect vsp1_video_partition(struct vsp1_pipeline *pipe,
-unsigned int div_size,
-unsigned int index)
+static void vsp1_video_partition(struct vsp1_pipeline *pipe,
+struct vsp1_partition *partition,
+unsigned int div_size, unsigned int index)
 {
const struct v4l2_mbus_framefmt *format;
-   struct v4l2_rect partition;
unsigned int modulus;
 
format = vsp1_entity_get_pad_format(>output->entity,
@@ -208,18 +208,19 @@ static struct v4l2_rect vsp1_video_partition(struct 
vsp1_pipeline *pipe,
 
/* A single partition simply processes the output size in full. */
if (pipe->partitions <= 1) {
-   partition.left = 0;
-   partition.top = 0;
-   partition.width = format->width;
-   partition.height = format->height;
-   return partition;
+   partition->dest.left = 0;
+   partition->dest.top = 0;
+   partition->dest.width = format->width;
+   partition->dest.height = format->height;
+
+   return;
}
 
/* Initialise the partition with sane starting conditions. */
-   partition.left = index * div_size;
-   partition.top = 0;
-   partition.width = div_size;
-   partition.height = format->height;
+   partition->dest.left = index * div_size;
+   partition->dest.top = 0;
+   partition->dest.width = div_size;
+   partition->dest.height = format->height;
 
modulus = format->width % div_size;
 
@@ -242,18 +243,16 @@ static struct v4l2_rect vsp1_video_partition(struct 
vsp1_pipeline *pipe,
if (modulus < div_size / 2) {
if (index == partitions - 1) {
/* Halve the penultimate partition. */
-   partition.width = div_size / 2;
+   partition->dest.width = div_size / 2;
} else if (index == partitions) {
/* Increase the final partition. */
-   partition.width = (div_size / 2) + modulus;
-   partition.left -= div_size / 2;
+   partition->dest.width = div_size / 2 + modulus;
+   partition->dest.left -= div_size / 2;
}
} else if (index == partitions) {
-   partition.width = modulus;
+   partition->dest.width = modulus;
}
}
-
-   return partition;
 }
 
 static void vsp1_video_pipeline_setup_partitions(struct vsp1_pipeline *pipe)
@@ -274,7 +273,7 @@ static void vsp1_video_pipeline_setup_partitions(struct 
vsp1_pipeline *pipe)
struct vsp1_partition *partition = >part_table[0];
 
pipe->partitions = 1;
-   partition->dest = vsp1_video_partition(pipe, div_size, 0);
+   vsp1_video_partition(pipe, partition, div_size, 0);
 
return;
}
@@ -294,7 +293,7 @@ static void vsp1_video_pipeline_setup_partitions(struct 
vsp1_pipeline *pipe)
for (i = 0; i < pipe->partitions; i++) {
struct vsp1_partition *partition = >part_table[i];
 
-   partition->dest = vsp1_video_partition(pipe, div_size, i);
+   vsp1_video_partition(pipe, partition, div_size, i);
}
 }
 
-- 
git-series 0.9.1


[PATCH 7/8] v4l: vsp1: Calculate UDS phase for partitions

2017-02-10 Thread Kieran Bingham
To improve image quality when scaling using the UDS we need to correctly
determine the start phase value for each partition window.

Provide helper functions for calculating the phase, and write this value
to the registers when used.

Signed-off-by: Kieran Bingham <kieran.bingham+rene...@ideasonboard.com>
---
 drivers/media/platform/vsp1/vsp1_pipe.h |  4 ++-
 drivers/media/platform/vsp1/vsp1_uds.c  | 64 +-
 2 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/vsp1/vsp1_pipe.h 
b/drivers/media/platform/vsp1/vsp1_pipe.h
index 718ca0a5eca7..0faa1c9f6184 100644
--- a/drivers/media/platform/vsp1/vsp1_pipe.h
+++ b/drivers/media/platform/vsp1/vsp1_pipe.h
@@ -79,6 +79,8 @@ struct vsp1_partition_rect {
  * @uds_source: The UDS output partition window configuration
  * @sru: The SRU partition window configuration
  * @wpf: The WPF partition window configuration
+ * @start_phase: The UDS start phase specific to this partition.
+ * @end_phase: The UDS end phase specific to this partition.
  */
 struct vsp1_partition {
struct vsp1_partition_rect rpf;
@@ -86,6 +88,8 @@ struct vsp1_partition {
struct vsp1_partition_rect uds_source;
struct vsp1_partition_rect sru;
struct vsp1_partition_rect wpf;
+   unsigned int start_phase;
+   unsigned int end_phase;
 };
 
 /*
diff --git a/drivers/media/platform/vsp1/vsp1_uds.c 
b/drivers/media/platform/vsp1/vsp1_uds.c
index b274cbc2428b..9c1fb7ef3c46 100644
--- a/drivers/media/platform/vsp1/vsp1_uds.c
+++ b/drivers/media/platform/vsp1/vsp1_uds.c
@@ -50,6 +50,46 @@ void vsp1_uds_set_alpha(struct vsp1_entity *entity, struct 
vsp1_dl_list *dl,
   alpha << VI6_UDS_ALPVAL_VAL0_SHIFT);
 }
 
+struct uds_phase {
+   unsigned int mp;
+   unsigned int prefilt_term;
+   unsigned int prefilt_outpos;
+   unsigned int residual;
+};
+
+/*
+ * TODO: Remove start_phase if possible:
+ * 'start_phase' as we use it should always be 0 I believe,
+ * Therefore this could be removed once confirmed
+ */
+static struct uds_phase uds_phase_calculation(int position, int start_phase,
+ int ratio)
+{
+   struct uds_phase phase;
+   int alpha = ratio * position;
+
+   /* These must be adjusted if we ever set BLADV */
+   phase.mp = ratio / 4096;
+   phase.mp = phase.mp < 4 ? 1 : (phase.mp < 8 ? 2 : 4);
+
+   phase.prefilt_term = phase.mp * 4096;
+   phase.prefilt_outpos = (alpha - start_phase * phase.mp)
+   / phase.prefilt_term;
+   phase.residual = (alpha - start_phase * phase.mp)
+   % phase.prefilt_term;
+
+   return phase;
+}
+
+static int uds_start_phase(int pos, int start_phase, int ratio)
+{
+   struct uds_phase phase;
+
+   phase = uds_phase_calculation(pos, start_phase, ratio);
+
+   return phase.residual ? (4096 - phase.residual / phase.mp) : 0;
+}
+
 /*
  * uds_output_size - Return the output size for an input size and scaling ratio
  * @input: input size in pixels
@@ -269,6 +309,7 @@ static void uds_configure(struct vsp1_entity *entity,
const struct v4l2_mbus_framefmt *input;
unsigned int hscale;
unsigned int vscale;
+   bool manual_phase = (pipe->partitions > 1);
bool multitap;
 
if (params == VSP1_ENTITY_PARAMS_PARTITION) {
@@ -287,6 +328,16 @@ static void uds_configure(struct vsp1_entity *entity,
<< VI6_UDS_CLIP_SIZE_HSIZE_SHIFT) |
   (partition->uds_source.height
<< VI6_UDS_CLIP_SIZE_VSIZE_SHIFT));
+
+   if (!manual_phase)
+   return;
+
+   vsp1_uds_write(uds, dl, VI6_UDS_HPHASE,
+  (partition->start_phase
+   << VI6_UDS_HPHASE_HSTP_SHIFT) |
+  (partition->end_phase
+   << VI6_UDS_HPHASE_HEDP_SHIFT));
+
return;
}
 
@@ -314,7 +365,8 @@ static void uds_configure(struct vsp1_entity *entity,
 
vsp1_uds_write(uds, dl, VI6_UDS_CTRL,
   (uds->scale_alpha ? VI6_UDS_CTRL_AON : 0) |
-  (multitap ? VI6_UDS_CTRL_BC : 0));
+  (multitap ? VI6_UDS_CTRL_BC : 0) |
+  (manual_phase ? VI6_UDS_CTRL_AMDSLH : 0));
 
vsp1_uds_write(uds, dl, VI6_UDS_PASS_BWIDTH,
   (uds_passband_width(hscale)
@@ -366,6 +418,8 @@ struct vsp1_partition_rect *uds_partition(struct 
vsp1_entity *entity,
struct vsp1_uds *uds = to_uds(>subdev);
const struct v4l2_mbus_framefmt *output;
const struct v4l2_mbus_framefmt *input;
+   unsigned int hscale;
+   unsigned int image_start_phase = 0;
 
/* Initialise the partition state */
  

[PATCH 8/8] v4l: vsp1: Implement left edge partition algorithm overlap

2017-02-10 Thread Kieran Bingham
Increase the overlap on the left edge to allow a margin to provide
better image scaling

Signed-off-by: Kieran Bingham <kieran.bingham+rene...@ideasonboard.com>
---
 drivers/media/platform/vsp1/vsp1_rpf.c |  7 +-
 drivers/media/platform/vsp1/vsp1_uds.c | 39 ---
 2 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_rpf.c 
b/drivers/media/platform/vsp1/vsp1_rpf.c
index 94541ab4ca36..d08cfd944b7b 100644
--- a/drivers/media/platform/vsp1/vsp1_rpf.c
+++ b/drivers/media/platform/vsp1/vsp1_rpf.c
@@ -247,6 +247,13 @@ struct vsp1_partition_rect *rpf_partition(struct 
vsp1_entity *entity,
/* Duplicate the target configuration to the RPF */
partition->rpf = *dest;
 
+   /*
+* A partition offset, is a request for more input pixels, and a
+* declaration that the consumer will clip excess.
+*/
+   partition->rpf.width += dest->offset;
+   partition->rpf.left -= dest->offset;
+
return >rpf;
 }
 
diff --git a/drivers/media/platform/vsp1/vsp1_uds.c 
b/drivers/media/platform/vsp1/vsp1_uds.c
index 9c1fb7ef3c46..9ee476c8db59 100644
--- a/drivers/media/platform/vsp1/vsp1_uds.c
+++ b/drivers/media/platform/vsp1/vsp1_uds.c
@@ -81,6 +81,20 @@ static struct uds_phase uds_phase_calculation(int position, 
int start_phase,
return phase;
 }
 
+static int uds_left_src_pixel(int pos, int start_phase, int ratio)
+{
+   struct uds_phase phase;
+
+   phase = uds_phase_calculation(pos, start_phase, ratio);
+
+   /* Renesas guard against odd values in these scale ratios here ? */
+   if ((phase.mp == 2 && (phase.residual & 0x01)) ||
+   (phase.mp == 4 && (phase.residual & 0x03)))
+   WARN_ON(1);
+
+   return phase.mp * (phase.prefilt_outpos + (phase.residual ? 1 : 0));
+}
+
 static int uds_start_phase(int pos, int start_phase, int ratio)
 {
struct uds_phase phase;
@@ -420,6 +434,8 @@ struct vsp1_partition_rect *uds_partition(struct 
vsp1_entity *entity,
const struct v4l2_mbus_framefmt *input;
unsigned int hscale;
unsigned int image_start_phase = 0;
+   unsigned int right_sink;
+   unsigned int margin;
 
/* Initialise the partition state */
partition->uds_sink = *dest;
@@ -432,10 +448,25 @@ struct vsp1_partition_rect *uds_partition(struct 
vsp1_entity *entity,
 
hscale = uds_compute_ratio(input->width, output->width);
 
-   partition->uds_sink.width = dest->width * input->width
- / output->width;
-   partition->uds_sink.left = dest->left * input->width
-/ output->width;
+   /* Handle 'left' edge of the partitions */
+   if (partition_idx == 0) {
+   margin = 0;
+   } else {
+   margin = hscale < 0x200 ? 32 : /* 8 <  scale */
+hscale < 0x400 ? 16 : /* 4 <  scale <= 8 */
+hscale < 0x800 ?  8 : /* 2 <  scale <= 4 */
+  4;  /* 1 <  scale <= 2, scale <= 1 */
+   }
+
+   partition->uds_sink.left = uds_left_src_pixel(dest->left,
+   image_start_phase, hscale);
+
+   partition->uds_sink.offset = margin;
+
+   right_sink = uds_left_src_pixel(dest->left + dest->width - 1,
+   image_start_phase, hscale);
+
+   partition->uds_sink.width = right_sink - partition->uds_sink.left + 1;
 
partition->start_phase = uds_start_phase(partition->uds_source.left,
 image_start_phase, hscale);
-- 
git-series 0.9.1


[PATCH 6/8] v4l: vsp1: Allow entities to participate in the partition algorithm

2017-02-10 Thread Kieran Bingham
The configuration of the pipeline, and entities directly affects the
inputs required to each entity for the partition algorithm. Thus it
makes sense to involve those entities in the decision making process.

Extend the entity ops API to provide an optional '.partition' call. This
allows entities which may effect the partition window, to process based
on their configuration.

Entities implementing this operation must return their required input
parameters, which will be passed down the chain. This creates a process
whereby each entity describes what is required to satisfy the required
output to it's predecessor in the pipeline.

Signed-off-by: Kieran Bingham <kieran.bingham+rene...@ideasonboard.com>
---
 drivers/media/platform/vsp1/vsp1_entity.h |  8 -
 drivers/media/platform/vsp1/vsp1_pipe.c   | 22 -
 drivers/media/platform/vsp1/vsp1_pipe.h   | 35 +--
 drivers/media/platform/vsp1/vsp1_rpf.c| 33 +-
 drivers/media/platform/vsp1/vsp1_sru.c| 29 +++-
 drivers/media/platform/vsp1/vsp1_uds.c| 45 ++--
 drivers/media/platform/vsp1/vsp1_video.c  | 32 ++---
 drivers/media/platform/vsp1/vsp1_wpf.c| 29 +++
 8 files changed, 195 insertions(+), 38 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_entity.h 
b/drivers/media/platform/vsp1/vsp1_entity.h
index 901146f807b9..08aa29dea13b 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.h
+++ b/drivers/media/platform/vsp1/vsp1_entity.h
@@ -21,6 +21,7 @@
 struct vsp1_device;
 struct vsp1_dl_list;
 struct vsp1_pipeline;
+struct vsp1_partition;
 
 enum vsp1_entity_type {
VSP1_ENTITY_BRU,
@@ -79,12 +80,19 @@ struct vsp1_route {
  * selection rectangles, ...)
  * @max_width: Return the max supported width of data that the entity can
  * process in a single operation.
+ * @partition: Process the partition construction based on this entity's
+ * configuration.
  */
 struct vsp1_entity_operations {
void (*destroy)(struct vsp1_entity *);
void (*configure)(struct vsp1_entity *, struct vsp1_pipeline *,
  struct vsp1_dl_list *, enum vsp1_entity_params);
unsigned int (*max_width)(struct vsp1_entity *, struct vsp1_pipeline *);
+   struct vsp1_partition_rect *(*partition)(struct vsp1_entity *,
+struct vsp1_pipeline *,
+struct vsp1_partition *,
+unsigned int,
+struct vsp1_partition_rect *);
 };
 
 struct vsp1_entity {
diff --git a/drivers/media/platform/vsp1/vsp1_pipe.c 
b/drivers/media/platform/vsp1/vsp1_pipe.c
index 280ba0804699..16f2eada54d5 100644
--- a/drivers/media/platform/vsp1/vsp1_pipe.c
+++ b/drivers/media/platform/vsp1/vsp1_pipe.c
@@ -331,6 +331,28 @@ void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline 
*pipe,
vsp1_uds_set_alpha(pipe->uds, dl, alpha);
 }
 
+/*
+ * Propagate the partition calculations through the pipeline
+ *
+ * Work backwards through the pipe, allowing each entity to update
+ * the partition parameters based on it's configuration, and the entity
+ * connected to it's source. Each entity must produce the partition
+ * required for the next entity in the routing.
+ */
+void vsp1_pipeline_propagate_partition(struct vsp1_pipeline *pipe,
+  struct vsp1_partition *partition,
+  unsigned int index,
+  struct vsp1_partition_rect *rect)
+{
+   struct vsp1_entity *entity;
+
+   list_for_each_entry_reverse(entity, >entities, list_pipe) {
+   if (entity->ops->partition)
+   rect = entity->ops->partition(entity, pipe, partition,
+ index, rect);
+   }
+}
+
 void vsp1_pipelines_suspend(struct vsp1_device *vsp1)
 {
unsigned long flags;
diff --git a/drivers/media/platform/vsp1/vsp1_pipe.h 
b/drivers/media/platform/vsp1/vsp1_pipe.h
index 6494c4c75023..718ca0a5eca7 100644
--- a/drivers/media/platform/vsp1/vsp1_pipe.h
+++ b/drivers/media/platform/vsp1/vsp1_pipe.h
@@ -60,11 +60,32 @@ enum vsp1_pipeline_state {
 };
 
 /*
+ * struct vsp1_partition_rect
+ *
+ * replicates struct v4l2_rect, but with an offset to apply
+ */
+struct vsp1_partition_rect {
+   __s32   left;
+   __s32   top;
+   __u32   width;
+   __u32   height;
+   __u32   offset;
+};
+
+/*
  * struct vsp1_partition - A description of each partition slice performed by 
HW
- * @dest: The position and dimension of this partition in the destination image
+ * @rpf: The RPF partition window configuration
+ * @uds_sink: The UDS input partition window configuration
+ * @uds_source: The UDS output partition window configuration
+ * @sru: The SRU partit

[GIT PULL] v4l: vsp1: Partition phase developments

2017-02-10 Thread Kieran Bingham
Hi Geert,

The following changes since commit 0c3b6ad6a559391f367879fd4be6d2d85625bd5a:

  v4l: vsp1: Remove redundant context variables (Tue,  1 Nov 2016 15:01:02 
+)

are available in the git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/kbingham/rcar.git 
refs/tags/vsp1/pa-phases-2017-02-10

for you to fetch changes up to 19c6a7d542809dc814b5dfb11ba8ab737eab56f9:

  v4l: vsp1: Implement left edge partition algorithm overlap (Thu,  9 Feb 2017 
22:08:34 +)

This work further continues my developments on the partition algorithm
for the VSP UDS and SRU components.


Kieran Bingham (8):
  v4l: vsp1: Provide UDS register updates
  v4l: vsp1: Track the SRU entity in the pipeline
  v4l: vsp1: Correct image partition parameters
  v4l: vsp1: Move partition rectangles to struct
  v4l: vsp1: Operate on partition struct data directly
  v4l: vsp1: Allow entities to participate in the partition algorithm
  v4l: vsp1: Calculate UDS phase for partitions
  v4l: vsp1: Implement left edge partition algorithm overlap

 drivers/media/platform/vsp1/vsp1_entity.h |   8 +-
 drivers/media/platform/vsp1/vsp1_pipe.c   |  22 -
 drivers/media/platform/vsp1/vsp1_pipe.h   |  49 +++-
 drivers/media/platform/vsp1/vsp1_regs.h   |  14 ++-
 drivers/media/platform/vsp1/vsp1_rpf.c|  40 +++---
 drivers/media/platform/vsp1/vsp1_sru.c|  29 +-
 drivers/media/platform/vsp1/vsp1_uds.c| 144 ++-
 drivers/media/platform/vsp1/vsp1_video.c  |  82 -
 drivers/media/platform/vsp1/vsp1_wpf.c|  34 +++--
 9 files changed, 364 insertions(+), 58 deletions(-)

-- 
git-series 0.9.1


Re: [PATCH 2/5] vsp-lib: Filter non-filesystem regular characters

2017-02-10 Thread Kieran Bingham
Hi Laurent,

Thanks for the review!

On 10/02/17 07:58, Laurent Pinchart wrote:
> Hi Kieran,
> 
> Thank you for the patch.
> 
> On Wednesday 08 Feb 2017 14:03:57 Kieran Bingham wrote:
>> From: Kieran Bingham <kieran.bing...@ideasonboard.com>
>>
>> Parameters can contain characters not suited to use in filenames.
>>
>> Add '=','(', and ')' to the filtering, and replace with '_'
> 
> What's the issue with those characters ? :-)

Actually, now I think about it; the real issue is they break my automated file
conversion scripts.

The '=' breaks Makefile wildcard matching, and the '(', just cause extra
escaping to be required on the command line, when I try to examine the output 
files.

It could easily be argued that those cases could be handled elsewhere, but it
seemed easy to 'clean' the filename.

>> Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
>> ---
>>  scripts/vsp-lib.sh | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh
>> index 5aff30217a27..08bf8f36c582 100755
>> --- a/scripts/vsp-lib.sh
>> +++ b/scripts/vsp-lib.sh
>> @@ -263,6 +263,9 @@ compare_frames() {
>>  local params=${args// /-}
>>  params=${params:+-$params}
>>  params=${params//\//_}
>> +params=${params/=/_}
>> +params=${params/(/_}
>> +params=${params/)/_}
> 
> According to the bash manpage,
> 
> "If pattern begins with /, all matches of pattern are replaced with string.  
> Normally only the first match is replaced."
> 
> Shouldn't you add a leading / as for the \/ substitution ?

I tried that when I copied the existing line, but it caused breakage. But of
course my shell is 'busybox sh' and not bash ...

Hrm ... I've just retested on a local script, and it worked fine.
# ./k.sh
abc=def(ghi)jkl
abc_def(ghi)jkl
abc_def_ghi)jkl
abc_def_ghi_jkl

... So I must have been trying to work around a 'non-error' :D

--
Kieran

>>  params=$in_fmt-$out_fmt-$size$params
>>
>>  if [ x$__vsp_pixel_perfect != xtrue ] ; then
> 


Re: [PATCH 3/5] gen-image: Implement option to parse an input crop

2017-02-10 Thread Kieran Bingham
Hi Laurent,

Thanks for the review,

On 10/02/17 08:19, Laurent Pinchart wrote:
> Hi Kieran,
> 
> Thank you for the patch.
> 
> On Wednesday 08 Feb 2017 14:03:58 Kieran Bingham wrote:
>> From: Kieran Bingham <kieran.bing...@ideasonboard.com>
>>
>> Allow the user to specify an input crop in the form (X,Y)/WxH
>>
>> Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
>> ---
>>  src/gen-image.c | 106 +-
>>  1 file changed, 106 insertions(+)
>>
>> diff --git a/src/gen-image.c b/src/gen-image.c
>> index 9aabefa8389c..2f370e7a8ebd 100644
>> --- a/src/gen-image.c
>> +++ b/src/gen-image.c
>> @@ -97,6 +97,13 @@ struct format_info {
>>  struct format_yuv_info yuv;
>>  };
>>
>> +struct image_rect {
>> +int left;
>> +int top;
>> +unsigned int width;
>> +unsigned int height;
>> +};
>> +
>>  struct image {
>>  const struct format_info *format;
>>  unsigned int width;
>> @@ -136,6 +143,8 @@ struct options {
>>  struct params params;
>>  enum histogram_type histo_type;
>>  uint8_t histo_areas[12];
> 
> I'd like to merge this series in the near future, could you rebase it on top 
> of the master branch instead of the histogram branch ?

Ack.

>> +bool crop;
>> +struct image_rect inputcrop;
>>  };
>>
>>  /* 
>> @@ -1085,6 +1094,26 @@ static void image_flip(const struct image *input,
>> struct image *output, }
>>
>>  /* 
>>   + * Image Cropping
>> + */
>> +
>> +static void image_crop(const struct image *input, const struct image
>> *output,
>> +   const struct image_rect *crop)
>> +{
>> +const uint8_t *idata = input->data;
>> +uint8_t *odata = output->data;
>> +unsigned int y;
>> +
>> +for (y = 0; y < output->height; ++y) {
>> +unsigned int offset = (crop->top * input->width + crop->left) 
> * 3;
> 
> This variable doesn't depend on the value of y, you can compute it outside of 
> the loop.

Ah yes, :D
Done.

>> +memcpy(odata + y * output->width * 3,
>> +   idata + y * input->width * 3 + offset,
>> +   output->width * 3);
> 
> Instead of having to multiply the stride by y in every iteration of the loop, 
> you could do
> 
>   const uint8_t *idata = input->data + offset;
> 
> ...
>   memcpy(odata, idata, output->width * 3);
>   odata += output->width * 3;
>   idata += input->width * 3;
> 

I was replicating from the compose function, - but I'm fine with this.
Done.

> But in addition to that, not all formats have 3 bytes per pixel :-)

Ah, but I thought they do at the point I call this function. This conversion
only occurs after the formats are converted

/* Convert colorspace */
if (options->input_format->type == FORMAT_YUV) {
... # Image converted to YUV24
} else if (options->input_format->rgb.bpp < 24) {
... # Image converted to RGB24
}

if (options->crop) {
... Actual crop performed, on 24bpp image.
}

Perhaps it would be useful to declare that this function only operates on 24bit
images somehow. It is accordingly located next to image_scale, image_compose,
image_rotate, and image_flip which also operate on 24bpp images.

We can always make it more generic later if we need to use the code in other
parts of gen-image

>> +}
>> +}
>> +
>> +/* 
>>   * Look Up Table
>>   */
>>
>> @@ -1539,6 +1568,22 @@ static int process(const struct options *options)
>>  input = rgb;
>>  }
>>
>> +if (options->crop) {
>> +struct image *cropped;
>> +
>> +cropped = image_new(input->format, options->inputcrop.width,
>> +options->inputcrop.height);
>> +
> 
> I'd remove this blank line to keep the test logically grouped with the 
> image_new() call.

Ack.
Done.

> 
>> +if (!cropped) {
>> +ret = -ENOMEM;
>> +goto done;
>> +}
>> +
>> +image_crop(input, cropped, >inputcrop);
>> +image_delete(input);
&

[PATCH v2 3/4] vsp-lib: Support RPF frame cropping

2017-02-10 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

Pass the optional '--crop (X,Y)/WxH' parameter through reference_frame
allowing the input to be cropped for comparison

Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
---
 scripts/vsp-lib.sh | 52 +--
 1 file changed, 42 insertions(+), 10 deletions(-)

diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh
index 9e5e57b8c4ba..d13e7b6cde31 100755
--- a/scripts/vsp-lib.sh
+++ b/scripts/vsp-lib.sh
@@ -147,6 +147,9 @@ reference_frame() {
clu)
options="$options --clu $value"
;;
+   crop)
+   options="$options --crop $value"
+   ;;
hflip)
[ x$value = x1 ] && options="$options --hflip"
;;
@@ -662,22 +665,51 @@ format_rpf_wpf() {
local infmt=$(format_v4l2_to_mbus $3)
local size=$4
local outfmt=$(format_v4l2_to_mbus $5)
-   local crop=$6
+   local rpfcrop=
+   local wpfcrop=
+   local rpfoutsize=
local outsize=
+   local option=
+
+   __vsp_rpf_format=$3
+   __vsp_wpf_format=$5
+
+   shift 5
+
+   for option in $* ; do
+   case $option in
+   --rpfcrop=*)
+   rpfcrop=${option/--rpfcrop=/}
+   ;;
+
+   --wpfcrop=*)
+   wpfcrop=${option/--wpfcrop=/}
+   ;;
+   *)
+   echo "format_rpf_wpf: Unrecognised arguments"
+   return 1
+   ;;
+   esac
+   done
 
-   if [ x$crop != 'x' ] ; then
-   crop="crop:$crop"
-   outsize=$(echo $crop | sed 's/.*\///')
+   if [ x$rpfcrop != 'x' ] ; then
+   rpfcrop="crop:$rpfcrop"
+   rpfoutsize=$(echo $rpfcrop | sed 's/.*\///')
else
-   outsize=$size
+   rpfoutsize=$size
fi
 
-   $mediactl -d $mdev -V "'$dev rpf.$rpf':0 [fmt:$infmt/$size]"
-   $mediactl -d $mdev -V "'$dev wpf.$wpf':0 [fmt:$infmt/$size $crop]"
-   $mediactl -d $mdev -V "'$dev wpf.$wpf':1 [fmt:$outfmt/$outsize]"
+   if [ x$wpfcrop != 'x' ] ; then
+   wpfcrop="crop:$wpfcrop"
+   outsize=$(echo $wpfcrop | sed 's/.*\///')
+   else
+   outsize=$rpfoutsize
+   fi
 
-   __vsp_rpf_format=$3
-   __vsp_wpf_format=$5
+   $mediactl -d $mdev -V "'$dev rpf.$rpf':0 [fmt:$infmt/$size $rpfcrop]"
+   $mediactl -d $mdev -V "'$dev rpf.$rpf':1 [fmt:$infmt/$rpfoutsize]"
+   $mediactl -d $mdev -V "'$dev wpf.$wpf':0 [fmt:$infmt/$rpfoutsize 
$wpfcrop]"
+   $mediactl -d $mdev -V "'$dev wpf.$wpf':1 [fmt:$outfmt/$outsize]"
 }
 
 format_wpf() {
-- 
git-series 0.9.1


[PATCH v2 4/4] tests: Add RPF cropping test

2017-02-10 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

Test both the input cropping size and position

Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
---
 tests/vsp-unit-test-0021.sh | 36 
 1 file changed, 36 insertions(+)
 create mode 100755 tests/vsp-unit-test-0021.sh

diff --git a/tests/vsp-unit-test-0021.sh b/tests/vsp-unit-test-0021.sh
new file mode 100755
index ..9d692cfc6194
--- /dev/null
+++ b/tests/vsp-unit-test-0021.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+#
+# Test RPF crop using RGB. Use a RPF -> WPF pipeline, passing a selection of
+# cropping windows.
+#
+
+source vsp-lib.sh
+
+features="rpf.0 wpf.0"
+crops="(0,0)/512x384 (32,32)/512x384 (32,64)/512x384 (64,32)/512x384"
+
+test_rpf_cropping() {
+   test_start "RPF crop from $crop"
+
+   pipe_configure rpf-wpf 0 0
+   format_configure rpf-wpf 0 0 RGB24 1024x768 ARGB32 --rpfcrop=$crop
+
+   vsp_runner rpf.0 &
+   vsp_runner wpf.0
+
+   local result=$(compare_frames crop=${crop})
+
+   test_complete $result
+}
+
+test_main() {
+   local crop
+
+   for crop in $crops ; do
+   test_rpf_cropping $crop
+   done
+}
+
+test_init $0 "$features"
+test_run
-- 
git-series 0.9.1


[PATCH v2 1/4] vsp-lib: Filter non-filesystem regular characters

2017-02-10 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

Parameters can contain characters not suited to use in filenames.

Add '=','(', and ')' to the filtering, and replace with '_'

This reduces extra escaping, and quoting when working with the output
filenames of failed tests and VSP_KEEP_FRAMES=1

Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
---
 scripts/vsp-lib.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh
index 8f2755b57519..9e5e57b8c4ba 100755
--- a/scripts/vsp-lib.sh
+++ b/scripts/vsp-lib.sh
@@ -258,6 +258,9 @@ compare_frames() {
local params=${args// /-}
params=${params:+-$params}
params=${params//\//_}
+   params=${params//=/_}
+   params=${params//(/_}
+   params=${params//)/_}
params=$in_fmt-$out_fmt-$size$params
 
if [ x$__vsp_pixel_perfect != xtrue ] ; then
-- 
git-series 0.9.1


[PATCH v2 0/4] vsp-tests: Implement RPF cropping tests

2017-02-10 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

Update the gen-image utility such that it can crop the image at input,
and provide tests to ensure that the output of the RPF is as we expect.

v2:
 - rebased on master branch
 - review comments fixed
 - vsp-unit-test-0021.sh description fixed

Kieran Bingham (4):
  vsp-lib: Filter non-filesystem regular characters
  gen-image: Implement option to parse an input crop
  vsp-lib: Support RPF frame cropping
  tests: Add RPF cropping test

 scripts/vsp-lib.sh  |  55 ---
 src/gen-image.c | 132 +-
 tests/vsp-unit-test-0021.sh |  36 ++-
 3 files changed, 213 insertions(+), 10 deletions(-)
 create mode 100755 tests/vsp-unit-test-0021.sh

base-commit: 8d7af82da291e16c770040c857f6d5cb43590df1
-- 
git-series 0.9.1


[PATCH v2 2/4] gen-image: Implement option to parse an input crop

2017-02-10 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

Allow the user to specify an input crop in the form (X,Y)/WxH

Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
---
 src/gen-image.c | 132 +-
 1 file changed, 132 insertions(+)

diff --git a/src/gen-image.c b/src/gen-image.c
index 31d42e0211db..088e8b26f648 100644
--- a/src/gen-image.c
+++ b/src/gen-image.c
@@ -95,6 +95,13 @@ struct format_info {
struct format_yuv_info yuv;
 };
 
+struct image_rect {
+   int left;
+   int top;
+   unsigned int width;
+   unsigned int height;
+};
+
 struct image {
const struct format_info *format;
unsigned int width;
@@ -127,6 +134,8 @@ struct options {
bool rotate;
unsigned int compose;
struct params params;
+   bool crop;
+   struct image_rect inputcrop;
 };
 
 /* 
-
@@ -1076,6 +1085,25 @@ static void image_flip(const struct image *input, struct 
image *output,
 }
 
 /* 
-
+ * Image Cropping
+ */
+
+static void image_crop(const struct image *input, const struct image *output,
+  const struct image_rect *crop)
+{
+   unsigned int offset = (crop->top * input->width + crop->left) * 3;
+   const uint8_t *idata = input->data + offset;
+   uint8_t *odata = output->data;
+   unsigned int y;
+
+   for (y = 0; y < output->height; ++y) {
+   memcpy(odata, idata, output->width * 3);
+   odata += output->width * 3;
+   idata += input->width * 3;
+   }
+}
+
+/* 
-
  * Look Up Table
  */
 
@@ -1363,6 +1391,21 @@ static int process(const struct options *options)
input = rgb;
}
 
+   if (options->crop) {
+   struct image *cropped;
+
+   cropped = image_new(input->format, options->inputcrop.width,
+   options->inputcrop.height);
+   if (!cropped) {
+   ret = -ENOMEM;
+   goto done;
+   }
+
+   image_crop(input, cropped, >inputcrop);
+   image_delete(input);
+   input = cropped;
+   }
+
/* Scale */
if (options->output_width && options->output_height) {
output_width = options->output_width;
@@ -1596,6 +1639,7 @@ static void usage(const char *argv0)
printf("or percentages ([0%% - 100%%]). 
Defaults to 1.0\n");
printf("-c, --compose n Compose n copies of the image offset by 
(50,50) over a black background\n");
printf("-C, --no-chroma-average Disable chroma averaging for odd pixels 
on output\n");
+   printf("--crop (X,Y)/WxHCrop the input image\n");
printf("-e, --encoding enc  Set the YCbCr encoding method. Valid 
values are\n");
printf("BT.601, REC.709, BT.2020 and 
SMPTE240M\n");
printf("-f, --format format Set the output image format\n");
@@ -1628,11 +1672,13 @@ static void list_formats(void)
 
 #define OPT_HFLIP  256
 #define OPT_VFLIP  257
+#define OPT_CROP   260
 
 static struct option opts[] = {
{"alpha", 1, 0, 'a'},
{"clu", 1, 0, 'L'},
{"compose", 1, 0, 'c'},
+   {"crop", 1, 0, OPT_CROP},
{"encoding", 1, 0, 'e'},
{"format", 1, 0, 'f'},
{"help", 0, 0, 'h'},
@@ -1649,6 +1695,84 @@ static struct option opts[] = {
{0, 0, 0, 0}
 };
 
+static int parse_crop(struct image_rect *crop, char *optarg, char **endp)
+{
+   /* (X,Y)/WxH */
+   char *endptr = optarg;
+
+   if (*endptr != '(') {
+   printf("Invalid crop argument\n");
+   *endp = endptr;
+   return 1;
+   }
+
+   crop->left = strtol(endptr + 1, , 10);
+   if (*endptr != ',') {
+   printf("Invalid crop position\n");
+   *endp = endptr;
+   return 1;
+   }
+
+   if (crop->left < 0) {
+   printf("Invalid negative crop\n");
+   *endp = endptr - 1;
+   return 1;
+   }
+
+   crop->top = strtol(endptr + 1, , 10);
+   if (*endptr != ')') {
+   printf("Invalid crop position\n");
+   *endp = endptr;
+   return 1;
+   }
+
+   if (crop->top < 0) {
+   printf("Invalid negative crop\n");
+   *endp = endptr - 1;
+   return 1;
+   }
+
+  

[PATCH 0/2] vsp-tests: Provide stress testing

2017-02-11 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

Add two extra tests utilising the 'stress' command utilty.

These tests wrap existing test functionality whilst holding the system under
arbitrary heavy load

Kieran Bingham (2):
  tests: Add basic stress testing
  tests: Add extended stress testing

 tests/vsp-unit-test-0022.sh | 55 
 tests/vsp-unit-test-0023.sh | 61 +
 2 files changed, 116 insertions(+)
 create mode 100755 tests/vsp-unit-test-0022.sh
 create mode 100755 tests/vsp-unit-test-0023.sh

-- 
2.7.4



[PATCH 1/2] tests: Add basic stress testing

2017-02-11 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

Duplicate the functionality of vsp-unit-test-0001, to provide a set of
work for the hardware to run, whilst we load the system using the
'stress' utility.

Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
---
 tests/vsp-unit-test-0022.sh | 55 +
 1 file changed, 55 insertions(+)
 create mode 100755 tests/vsp-unit-test-0022.sh

diff --git a/tests/vsp-unit-test-0022.sh b/tests/vsp-unit-test-0022.sh
new file mode 100755
index ..10230dffcc42
--- /dev/null
+++ b/tests/vsp-unit-test-0022.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+#
+# Test active pipeline, with high load on CPU/Memory/IO using 'stress'
+#
+# Test WPF packing in RGB mode. Use a RPF -> WPF pipeline with a fixed ARGB32
+# format on the input and capture output frames in all RGB formats supported
+# by the WPF.
+#
+
+source vsp-lib.sh
+
+features="rpf.0 wpf.0"
+formats="RGB332 ARGB555 XRGB555 RGB565 BGR24 RGB24 ABGR32 ARGB32 XBGR32 XRGB32"
+
+test_wpf_packing() {
+   test_start "WPF packing in $format during stress testing"
+
+   pipe_configure rpf-wpf 0 0
+   format_configure rpf-wpf 0 0 ARGB32 1024x768 $format
+
+   vsp_runner rpf.0 &
+   vsp_runner wpf.0
+
+   local result=$(compare_frames)
+
+   test_complete $result
+}
+
+exists() { type -t "$1" > /dev/null 2>&1; }
+
+test_main() {
+   local format
+
+   if exists stress ; then
+   STRESS=`which stress`
+   else
+   echo "$0: Stress test requires utility 'stress'"
+   test_complete skip
+   return
+   fi
+
+   # Start stressing the system, as a background task
+   $STRESS --cpu 8 --io 4 --vm 2 --vm-bytes 128M &
+
+   for format in $formats ; do
+   test_wpf_packing $format
+   done
+
+   # Recover the system. Stress launches multiple PIDs, so it's best to:
+   killall -9 stress
+}
+
+test_init $0 "$features"
+test_run
-- 
2.7.4



[PATCH 2/2] tests: Add extended stress testing

2017-02-11 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

Duplicate the functionality of vsp-unit-test-0020, to provide a longer
duration task for the hardware to run, whilst we load the system using the
'stress' utility.

Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
---
 tests/vsp-unit-test-0023.sh | 61 +
 1 file changed, 61 insertions(+)
 create mode 100755 tests/vsp-unit-test-0023.sh

diff --git a/tests/vsp-unit-test-0023.sh b/tests/vsp-unit-test-0023.sh
new file mode 100755
index ..e944b12c9d53
--- /dev/null
+++ b/tests/vsp-unit-test-0023.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+#
+# Test active pipeline, with high load on CPU/Memory/IO using 'stress'
+#
+# Utilise the same test as for suspend resume testing, to verify a longer
+# duration pipeline lifetime while we stress the system.
+#
+
+source vsp-lib.sh
+
+features="rpf.0 wpf.0"
+
+# This extended function performs the same
+# as it's non-extended name-sake - but runs the pipeline
+# for 300 frames.
+
+test_extended_wpf_packing() {
+   pipe_configure rpf-wpf 0 0
+   format_configure rpf-wpf 0 0 ARGB32 1024x768 RGB24
+
+   vsp_runner rpf.0 --count=300 &
+   vsp_runner wpf.0 --count=300 --skip=297
+
+   local result=$(compare_frames)
+
+   if [ x$result == x"pass" ] ; then
+   return 0;
+   else
+   return 1;
+   fi
+}
+
+exists() { type -t "$1" > /dev/null 2>&1; }
+
+test_main() {
+   test_start "long duration pipelines under stress"
+
+   if exists stress ; then
+   STRESS=`which stress`
+   else
+   echo "$0: Stress test requires utility 'stress'"
+   test_complete skip
+   return
+   fi
+
+   # Start stressing the system, as a background task
+   $STRESS --cpu 8 --io 4 --vm 2 --vm-bytes 128M &
+
+   if test_extended_wpf_packing ; then
+   test_complete pass
+   else
+   test_complete fail
+   fi
+
+   # Recover the system. Stress launches multiple PIDs, so it's best to:
+   killall -9 stress
+}
+
+test_init $0 "$features"
+test_run
\ No newline at end of file
-- 
2.7.4



Re: [PATCH 4/5] vsp-lib: Support RPF frame cropping

2017-02-10 Thread Kieran Bingham
Ooops, I left this on my screen, and have already sent the V2 anyway.

Hitting send for posterity.

--
Kieran

On 10/02/17 09:20, Laurent Pinchart wrote:
> Hi Kieran,
> 
> Thank you for the patch.
> 
> On Wednesday 08 Feb 2017 14:03:59 Kieran Bingham wrote:
>> From: Kieran Bingham <kieran.bing...@ideasonboard.com>
>>
>> Pass the optional '--crop (X,Y)/WxH' parameter through reference_frame
>> allowing the input to be cropped for comparison
>>
>> Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
>> ---
>>  scripts/vsp-lib.sh | 37 +
>>  1 file changed, 37 insertions(+)
>>
>> diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh
>> index 08bf8f36c582..42a4bb20d1be 100755
>> --- a/scripts/vsp-lib.sh
>> +++ b/scripts/vsp-lib.sh
>> @@ -162,6 +162,9 @@ reference_frame() {
>>  vflip)
>>  [ x$value = x1 ] && options="$options --vflip"
>>  ;;
>> +crop)
>> +options="$options --crop $value"
>> +;;
> 
> Could you please keep the options sorted alphabetically ?

Fixed,

> 
>>  esac
>>  done
>>
>> @@ -717,6 +720,40 @@ format_rpf_wpf() {
>>  __vsp_wpf_format=$5
>>  }
>>
>> +format_crop_rpf_wpf() {
>> +local rpf=$1
>> +local wpf=$2
>> +local infmt=$(format_v4l2_to_mbus $3)
>> +local size=$4
>> +local outfmt=$(format_v4l2_to_mbus $5)
>> +local rpfcrop=$6
>> +local wpfcrop=$7
>> +local rpfoutsize=
>> +local outsize=
>> +
>> +if [ x$rpfcrop != 'x' ] ; then
> 
> I don't think this will work properly. You want to test for the presence of 
> an 
> RPF crop argument. If it's absent, and the WPF crop argument is specified, 
> WPF 
> crop will be stored in $6, and will thus be assigned to $rpfcrop.

Yes, you're correct.

> 
> I see two possible solutions. One of them is to make the RPF crop argument 
> mandatory. After all, given the function name, one can expect RPF crop to be 
> specified, otherwise the caller should use rpf-wpf, not crop-rpf-wpf. Another 
> more versatile option would be to add RPF crop support to the existing 
> format_rpf_wpf() crop function, and make both RPF and WPF crop optional. You 
> could use named option for that (rcrop=... wcrop=...) or use a special value 
> to indicate that an option should be skipped (for instance "- (0,0)/640x480" 
> to set the WPF crop rectangle without setting the RPF crop rectangle).

I think prefer named arguments over positional arguments in non-type-checked
code such as this...

Although I think I went down the 'fast' route of duplicating rpf-crop over
adding named arguments. That's not a good enough reason not to do it though ...

As there are no current users of the 'wpf' crop parameter, I've changed this to
support --rpfcrop=... --wpfcrop=...


> 
>> +rpfcrop="crop:$rpfcrop"
>> +rpfoutsize=$(echo $rpfcrop | sed 's/.*\///')
>> +else
>> +rpfoutsize=$size
>> +fi
>> +
>> +if [ x$wpfcrop != 'x' ] ; then
>> +wpfcrop="crop:$wpfcrop"
>> +outsize=$(echo $wpfcrop | sed 's/.*\///')
>> +else
>> +outsize=$rpfoutsize
>> +fi
>> +
>> +$mediactl -d $mdev -V "'$dev rpf.$rpf':0 [fmt:$infmt/$size $rpfcrop]"
>> +$mediactl -d $mdev -V "'$dev rpf.$rpf':1 [fmt:$infmt/$rpfoutsize]"
>> +$mediactl -d $mdev -V "'$dev wpf.$wpf':0 [fmt:$infmt/$rpfoutsize
>> $wpfcrop]"
>> +$mediactl -d $mdev -V "'$dev wpf.$wpf':1 [fmt:$outfmt/$outsize]"
>> +
>> +__vsp_rpf_format=$3
>> +__vsp_wpf_format=$5
>> +}
>> +
>>  format_wpf() {
>>  local format=$(format_v4l2_to_mbus $1)
>>  local size=$2
> 
--
Kieran


[RFC PATCH 2/3] v4l: vsp1: extend VSP1 module API to allow DRM callback registration

2017-03-01 Thread Kieran Bingham
To be able to perform page flips in DRM without flicker we need to be
able to notify the rcar-du module when the VSP has completed its
processing.

To synchronise the page flip events for userspace, we move the required
event through the VSP to track the data flow. When the frame is
completed, the event can be returned back to the originator through the
registered callback.

We must not have bidirectional dependencies on the two components to
maintain support for loadable modules, thus we extend the API to allow
a callback to be registered within the VSP DRM interface.

Signed-off-by: Kieran Bingham <kieran.bingham+rene...@ideasonboard.com>
---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c  |  2 +-
 drivers/media/platform/vsp1/vsp1_drm.c | 42 +--
 drivers/media/platform/vsp1/vsp1_drm.h | 12 -
 include/media/vsp1.h   |  6 +++-
 4 files changed, 58 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c 
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
index b5bfbe50bd87..71e70e1e0881 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
@@ -81,7 +81,7 @@ void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc)
 
 void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc)
 {
-   vsp1_du_atomic_flush(crtc->vsp->vsp);
+   vsp1_du_atomic_flush(crtc->vsp->vsp, NULL);
 }
 
 /* Keep the two tables in sync. */
diff --git a/drivers/media/platform/vsp1/vsp1_drm.c 
b/drivers/media/platform/vsp1/vsp1_drm.c
index 8e2aa3f8e52f..743cbce48d0c 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -52,6 +52,40 @@ int vsp1_du_init(struct device *dev)
 EXPORT_SYMBOL_GPL(vsp1_du_init);
 
 /**
+ * vsp1_du_register_callback - Register VSP completion notifier callback
+ *
+ * Allow the DRM framework to register a callback with us to notify the end of
+ * processing each frame. This allows synchronisation for page flipping.
+ *
+ * @dev: the VSP device
+ * @callback: the callback function to notify the DU module
+ * @private: private structure data to pass with the callback
+ *
+ */
+void vsp1_du_register_callback(struct device *dev,
+  void (*callback)(void *, void *),
+  void *private)
+{
+   struct vsp1_device *vsp1 = dev_get_drvdata(dev);
+
+   vsp1->drm->du_complete = callback;
+   vsp1->drm->du_private = private;
+}
+EXPORT_SYMBOL_GPL(vsp1_du_register_callback);
+
+static void vsp1_du_pipeline_frame_end(struct vsp1_pipeline *pipe)
+{
+   struct vsp1_drm *drm = to_vsp1_drm(pipe);
+
+   if (drm->du_complete && drm->active_data)
+   drm->du_complete(drm->du_private, drm->active_data);
+
+   /* The pending frame is now active */
+   drm->active_data = drm->pending_data;
+   drm->pending_data = NULL;
+}
+
+/**
  * vsp1_du_setup_lif - Setup the output part of the VSP pipeline
  * @dev: the VSP device
  * @width: output frame width in pixels
@@ -99,7 +133,8 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int width,
}
 
pipe->num_inputs = 0;
-
+   pipe->frame_end = NULL;
+   vsp1->drm->du_complete = NULL;
vsp1_dlm_reset(pipe->output->dlm);
vsp1_device_put(vsp1);
 
@@ -196,6 +231,8 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int 
width,
if (ret < 0)
return ret;
 
+   pipe->frame_end = vsp1_du_pipeline_frame_end;
+
ret = media_entity_pipeline_start(>output->entity.subdev.entity,
  >pipe);
if (ret < 0) {
@@ -420,7 +457,7 @@ static unsigned int rpf_zpos(struct vsp1_device *vsp1, 
struct vsp1_rwpf *rpf)
  * vsp1_du_atomic_flush - Commit an atomic update
  * @dev: the VSP device
  */
-void vsp1_du_atomic_flush(struct device *dev)
+void vsp1_du_atomic_flush(struct device *dev, void *data)
 {
struct vsp1_device *vsp1 = dev_get_drvdata(dev);
struct vsp1_pipeline *pipe = >drm->pipe;
@@ -504,6 +541,7 @@ void vsp1_du_atomic_flush(struct device *dev)
 
vsp1_dl_list_commit(pipe->dl);
pipe->dl = NULL;
+   vsp1->drm->pending_data = data;
 
/* Start or stop the pipeline if needed. */
if (!vsp1->drm->num_inputs && pipe->num_inputs) {
diff --git a/drivers/media/platform/vsp1/vsp1_drm.h 
b/drivers/media/platform/vsp1/vsp1_drm.h
index 9e28ab9254ba..fde19e5948a0 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.h
+++ b/drivers/media/platform/vsp1/vsp1_drm.h
@@ -33,8 +33,20 @@ struct vsp1_drm {
struct v4l2_rect compose;
unsigned int zpos;
} inputs[VSP1_MAX_RPF];
+
+   /* Frame syncronisation */
+   void (*du_complete)(void *, void *);
+   void *du_private;
+   void *pending_data;
+   

[RFC PATCH 0/3] RCAR-DU, VSP1: Prevent pre-emptive frame flips on VSP1-DRM pipelines

2017-03-01 Thread Kieran Bingham
The RCAR-DU utilises a running VSPD pipeline to perform processing
for the display pipeline.

Changes to this pipeline are performed with an atomic flush operation which
updates the state in the VSPD. Due to the way the running pipeline is
operated, any flush operation has an implicit latency of one frame interval.

This comes about as the display list is committed, but not updated until the
next VSP1 interrupt. At this point the frame is being processed, but is not
complete until the following VSP1 frame end interrupt.

To prevent reporting page flips early, we must track this timing through the
VSP1, and only allow the rcar-du object to report the page-flip completion
event after the VSP1 has processed.

[PATCH 1/3] fixes the VSP DRM object to register it's pipeline correctly.
[PATCH 2/3] extends the VSP1 to allow a callback to be registered allowing the
VSP1 to notify completion events, and extend the existing atomic
flush API to allow private event data to be passed through.
[PATCH 3/3] Utilises this API extension to postpone page flips as required.

In current testing, with kmstest, and kmscube, it can be seen that our refresh
rate has halved. I believe this is due to the one frame latency imposed by the
VSPD and will need further investigation.

Kieran Bingham (3):
  v4l: vsp1: Register pipe with output WPF
  v4l: vsp1: extend VSP1 module API to allow DRM callback registration
  drm: rcar-du: Register a completion callback with VSP1

 drivers/gpu/drm/rcar-du/rcar_du_crtc.c |  8 -
 drivers/gpu/drm/rcar-du/rcar_du_crtc.h |  1 +-
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c  | 34 -
 drivers/media/platform/vsp1/vsp1_drm.c | 43 +--
 drivers/media/platform/vsp1/vsp1_drm.h | 12 -
 include/media/vsp1.h   |  6 +++-
 6 files changed, 99 insertions(+), 5 deletions(-)

base-commit: a194138cd82dff52d4c39895fd89dc6f26eafc97
-- 
git-series 0.9.1


[RFC PATCH 1/3] v4l: vsp1: Register pipe with output WPF

2017-03-01 Thread Kieran Bingham
The DRM object does not register the pipe with the WPF object. This is
used internally throughout the driver as a means of accessing the pipe.
As such this breaks operations which require access to the pipe from WPF
interrupts.

Register the pipe inside the WPF object after it has been declared as
the output.

Signed-off-by: Kieran Bingham <kieran.bingham+rene...@ideasonboard.com>
---
 drivers/media/platform/vsp1/vsp1_drm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/vsp1/vsp1_drm.c 
b/drivers/media/platform/vsp1/vsp1_drm.c
index cd209dccff1b..8e2aa3f8e52f 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -596,6 +596,7 @@ int vsp1_drm_init(struct vsp1_device *vsp1)
pipe->bru = >bru->entity;
pipe->lif = >lif->entity;
pipe->output = vsp1->wpf[0];
+   pipe->output->pipe = pipe;
 
return 0;
 }
-- 
git-series 0.9.1


Re: [PATCH] v4l: vsp1: Disable HSV formats on Gen3 hardware

2017-03-02 Thread Kieran Bingham
Hi Laurent,

LGTM! :-)

On 28/02/17 23:08, Laurent Pinchart wrote:
> While all VSP instances can process HSV internally, on Gen3 hardware
> reading or writing HSV24 or HSV32 from/to memory causes the device to
> hang. Disable those pixel formats on Gen3 hardware.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+rene...@ideasonboard.com>

Reviewed-by: Kieran Bingham <kieran.bingham+rene...@ideasonboard.com>

> ---
>  drivers/media/platform/vsp1/vsp1_pipe.c | 12 +---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/platform/vsp1/vsp1_pipe.c 
> b/drivers/media/platform/vsp1/vsp1_pipe.c
> index 3f1acf68dc6e..35364f594e19 100644
> --- a/drivers/media/platform/vsp1/vsp1_pipe.c
> +++ b/drivers/media/platform/vsp1/vsp1_pipe.c
> @@ -157,9 +157,15 @@ const struct vsp1_format_info 
> *vsp1_get_format_info(struct vsp1_device *vsp1,
>  {
>   unsigned int i;
>  
> - /* Special case, the VYUY format is supported on Gen2 only. */
> - if (vsp1->info->gen != 2 && fourcc == V4L2_PIX_FMT_VYUY)
> - return NULL;
> + /* Special case, the VYUY and HSV formats are supported on Gen2 only. */
> + if (vsp1->info->gen != 2) {
> + switch (fourcc) {
> + case V4L2_PIX_FMT_VYUY:
> + case V4L2_PIX_FMT_HSV24:
> + case V4L2_PIX_FMT_HSV32:
> + return NULL;
> + }
> + }
>  
>   for (i = 0; i < ARRAY_SIZE(vsp1_video_formats); ++i) {
>   const struct vsp1_format_info *info = _video_formats[i];
> 


Re: [PATCH v3 00/10] v4l: platform: Add Renesas R-Car FDP1 Driver

2016-09-08 Thread Kieran Bingham
On 07/09/16 23:25, Laurent Pinchart wrote:
> Hello,

Thanks for all of your efforts here!

> Here's the third version of the Renesas R-Car FDP1 driver.
> 
> The FDP1 (Fine Display Processor) is a hardware memory-to-memory de-interlacer
> device, with capability to convert from various YCbCr/YUV formats to both
> YCbCr/YUV and RGB formats at the same time as converting interlaced content to
> progressive.
> 
> Patch 01/10 fixes an issue in the V4L2 ioctl handling core code. It has been
> posted before and hasn't been changed.
> 
> Patch 02/10 adds a new standard V4L2 menu control for the deinterlacing mode.
> The menu items are driver specific.
> 
> Patch 03/10 extends the FCP driver to support the FDP1. It has been posted
> before and hasn't been changed.
> 
> Patch 04/10 adds the FDP1 driver unchanged compared to the v2 posted by
> Kieran. Patches 05/10 to 09/10 then fix issues in the driver and incorporate
> review comments. They will eventually be squashed into patch 04/10, but are
> currently separate to allow easier review of the changes.
> 
> Patch 10/10 reworks buffer handling in the FDP1 driver. This is experimental
> and doesn't fix any known bug. I've included the patch in the series to get
> feedback on whether this is a good idea.
> 
> Kieran, I noticed that your patches are authored by
> 
>   Kieran Bingham <kie...@ksquared.org.uk>
> 
> Is that correct or should it be changed to
> 
>   Kieran Bingham <kieran+rene...@bingham.xyz>

Yes, @bingham.xyz is preferred.

Google is rewriting my outgoing mail address.
I fear I may have to set up my own mail server :(

I've had a quick look through the extra patches. I will try to reply to
each of them when I get chance. (I've just done the first two easy ones
so far)
--
Regards

Kieran

> 
> ?
> 
> Here is the V4L2 compliance report.
> 
> v4l2-compliance SHA   : abc1453dfe89f244dccd3460d8e1a2e3091cbadb
> 
> Driver Info:
> Driver name   : rcar_fdp1
> Card type : rcar_fdp1
> Bus info  : platform:rcar_fdp1
> Driver version: 4.8.0
> Capabilities  : 0x84204000
> Video Memory-to-Memory Multiplanar
> Streaming
> Extended Pix Format
> Device Capabilities
> Device Caps   : 0x04204000
> Video Memory-to-Memory Multiplanar
> Streaming
> Extended Pix Format
> 
> Compliance test for device /dev/video0 (not using libv4l2):
> 
> Required ioctls:
> test VIDIOC_QUERYCAP: OK
> 
> Allow for multiple opens:
> test second video open: OK
> test VIDIOC_QUERYCAP: OK
> test VIDIOC_G/S_PRIORITY: OK
> test for unlimited opens: OK
> 
> Debug ioctls:
> test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
> test VIDIOC_LOG_STATUS: OK (Not Supported)
> 
> Input ioctls:
> test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
> test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
> test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
> test VIDIOC_ENUMAUDIO: OK (Not Supported)
> test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
> test VIDIOC_G/S_AUDIO: OK (Not Supported)
> Inputs: 0 Audio Inputs: 0 Tuners: 0
> 
> Output ioctls:
> test VIDIOC_G/S_MODULATOR: OK (Not Supported)
> test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
> test VIDIOC_ENUMAUDOUT: OK (Not Supported)
> test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
> test VIDIOC_G/S_AUDOUT: OK (Not Supported)
> Outputs: 0 Audio Outputs: 0 Modulators: 0
> 
> Input/Output configuration ioctls:
> test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
> test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
> test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
> test VIDIOC_G/S_EDID: OK (Not Supported)
> 
> Control ioctls:
> test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
> test VIDIOC_QUERYCTRL: OK
> test VIDIOC_G/S_CTRL: OK
> test VIDIOC_G/S/TRY_EXT_CTRLS: OK
> test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
> test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
> Standard Controls: 5 Private Controls: 0
> 
> Format ioctls:
> test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
> test VIDIOC_G/S_PARM: OK (Not Supported)
> test VIDIOC_G_FBUF: OK (Not Supported)
> test VIDIOC_G_FMT: OK
> test VIDIOC_TRY_FMT: OK
> test VIDIOC_S_FMT: OK
> te

Re: [PATCH v3 02/10] v4l: ctrls: Add deinterlacing mode control

2016-09-08 Thread Kieran Bingham
On 07/09/16 23:25, Laurent Pinchart wrote:
> The menu control selects the operation mode of a video deinterlacer. The
> menu entries are driver specific.

Excellent. This makes a lot more sense than adding a custom control in
the driver :D

> Signed-off-by: Laurent Pinchart <laurent.pinchart+rene...@ideasonboard.com>

Reviewed-by: Kieran Bingham <kie...@bingham.xyz>

> ---
>  Documentation/media/uapi/v4l/extended-controls.rst | 4 
>  drivers/media/v4l2-core/v4l2-ctrls.c   | 2 ++
>  include/uapi/linux/v4l2-controls.h | 1 +
>  3 files changed, 7 insertions(+)
> 
> diff --git a/Documentation/media/uapi/v4l/extended-controls.rst 
> b/Documentation/media/uapi/v4l/extended-controls.rst
> index 1f1518e4859d..8e6314e23cd3 100644
> --- a/Documentation/media/uapi/v4l/extended-controls.rst
> +++ b/Documentation/media/uapi/v4l/extended-controls.rst
> @@ -4250,6 +4250,10 @@ Image Process Control IDs
>  test pattern images. These hardware specific test patterns can be
>  used to test if a device is working properly.
>  
> +``V4L2_CID_DEINTERLACING_MODE (menu)``
> +The video deinterlacing mode (such as Bob, Weave, ...). The menu items 
> are
> +driver specific.
> +
>  
>  .. _dv-controls:
>  
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
> b/drivers/media/v4l2-core/v4l2-ctrls.c
> index adc2147fcff7..47001e25fd9e 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
> @@ -885,6 +885,7 @@ const char *v4l2_ctrl_get_name(u32 id)
>   case V4L2_CID_LINK_FREQ:return "Link Frequency";
>   case V4L2_CID_PIXEL_RATE:   return "Pixel Rate";
>   case V4L2_CID_TEST_PATTERN: return "Test Pattern";
> + case V4L2_CID_DEINTERLACING_MODE:   return "Deinterlacing Mode";
>  
>   /* DV controls */
>   /* Keep the order of the 'case's the same as in v4l2-controls.h! */
> @@ -1058,6 +1059,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
> v4l2_ctrl_type *type,
>   case V4L2_CID_DV_RX_RGB_RANGE:
>   case V4L2_CID_DV_RX_IT_CONTENT_TYPE:
>   case V4L2_CID_TEST_PATTERN:
> + case V4L2_CID_DEINTERLACING_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 b6a357a5f053..0d2e1e01fbd5 100644
> --- a/include/uapi/linux/v4l2-controls.h
> +++ b/include/uapi/linux/v4l2-controls.h
> @@ -892,6 +892,7 @@ enum v4l2_jpeg_chroma_subsampling {
>  #define V4L2_CID_LINK_FREQ   (V4L2_CID_IMAGE_PROC_CLASS_BASE 
> + 1)
>  #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)
>  
>  
>  /*  DV-class control IDs defined by V4L2 */
> 

-- 
Regards

Kieran Bingham


Re: [PATCH v3 05/10] v4l: fdp1: vb2_queue dev conversion

2016-09-08 Thread Kieran Bingham
On 07/09/16 23:25, Laurent Pinchart wrote:
> From: Geert Uytterhoeven <geert+rene...@glider.be>
> 
> drivers/media/platform/rcar_fdp1.c:1972:2: warning: initialization from 
> incompatible pointer type
>   .queue_setup  = fdp1_queue_setup,
>   ^
> drivers/media/platform/rcar_fdp1.c:1972:2: warning: (near initialization 
> for 'fdp1_qops.queue_setup')
> drivers/media/platform/rcar_fdp1.c: In function 'fdp1_probe':
> drivers/media/platform/rcar_fdp1.c:2264:2: error: implicit declaration of 
> function 'vb2_dma_contig_init_ctx' [-Werror=implicit-function-declaration]
>   fdp1->alloc_ctx = vb2_dma_contig_init_ctx(>dev);
>   ^
> drivers/media/platform/rcar_fdp1.c:2264:18: warning: assignment makes 
> pointer from integer without a cast
>   fdp1->alloc_ctx = vb2_dma_contig_init_ctx(>dev);
> ^
> drivers/media/platform/rcar_fdp1.c:2331:2: error: implicit declaration of 
> function 'vb2_dma_contig_cleanup_ctx' [-Werror=implicit-function-declaration]
>   vb2_dma_contig_cleanup_ctx(fdp1->alloc_ctx);
>   ^
> 
> Commit 36c0f8b32c4bd4f6 ("[media] vb2: replace void *alloc_ctxs by
> struct device *alloc_devs") removed the vb2_dma_contig_init_ctx() and
> vb2_dma_contig_cleanup_ctx() functions, and changed the prototype of
> vb2_ops.queue_setup().
> 
> To fix this:
>   - Update the signature of fdp1_queue_setup(),
>   - Convert the FDP1 driver to use the new vb2_queue dev field, cfr.
> commit 53ddcc683faef8c7 ("[media] media/platform: convert drivers to
> use the new vb2_queue dev field").
> 
> Signed-off-by: Geert Uytterhoeven <geert+rene...@glider.be>

This looks like a good fix to me. Tested, and verified as well.

Reviewed-by: Kieran Bingham <kie...@bingham.xyz>

> ---
>  drivers/media/platform/rcar_fdp1.c | 26 ++
>  1 file changed, 6 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar_fdp1.c 
> b/drivers/media/platform/rcar_fdp1.c
> index c7280183262a..a2587745ca68 100644
> --- a/drivers/media/platform/rcar_fdp1.c
> +++ b/drivers/media/platform/rcar_fdp1.c
> @@ -570,7 +570,6 @@ struct fdp1_dev {
>   void __iomem*regs;
>   unsigned intirq;
>   struct device   *dev;
> - void*alloc_ctx;
>  
>   /* Job Queues */
>   struct fdp1_job jobs[FDP1_NUMBER_JOBS];
> @@ -1788,7 +1787,8 @@ static const struct v4l2_ioctl_ops fdp1_ioctl_ops = {
>  
>  static int fdp1_queue_setup(struct vb2_queue *vq,
>   unsigned int *nbuffers, unsigned int *nplanes,
> - unsigned int sizes[], void *alloc_ctxs[])
> + unsigned int sizes[],
> + struct device *alloc_ctxs[])
>  {
>   struct fdp1_ctx *ctx = vb2_get_drv_priv(vq);
>   struct fdp1_q_data *q_data;
> @@ -1800,18 +1800,13 @@ static int fdp1_queue_setup(struct vb2_queue *vq,
>   if (*nplanes > FDP1_MAX_PLANES)
>   return -EINVAL;
>  
> - for (i = 0; i < *nplanes; i++)
> - alloc_ctxs[i] = ctx->fdp1->alloc_ctx;
> -
>   return 0;
>   }
>  
>   *nplanes = q_data->format.num_planes;
>  
> - for (i = 0; i < *nplanes; i++) {
> + for (i = 0; i < *nplanes; i++)
>   sizes[i] = q_data->format.plane_fmt[i].sizeimage;
> - alloc_ctxs[i] = ctx->fdp1->alloc_ctx;
> - }
>  
>   return 0;
>  }
> @@ -1992,6 +1987,7 @@ static int queue_init(void *priv, struct vb2_queue 
> *src_vq,
>   src_vq->mem_ops = _dma_contig_memops;
>   src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
>   src_vq->lock = >fdp1->dev_mutex;
> + src_vq->dev = ctx->fdp1->dev;
>  
>   ret = vb2_queue_init(src_vq);
>   if (ret)
> @@ -2005,6 +2001,7 @@ static int queue_init(void *priv, struct vb2_queue 
> *src_vq,
>   dst_vq->mem_ops = _dma_contig_memops;
>   dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
>   dst_vq->lock = >fdp1->dev_mutex;
> + dst_vq->dev = ctx->fdp1->dev;
>  
>   return vb2_queue_init(dst_vq);
>  }
> @@ -2260,18 +2257,11 @@ static int fdp1_probe(struct platform_device *pdev)
>   fdp1->clk_rate = clk_get_rate(clk);
>   clk_put(clk);
>  
> - /* Memory allocation contexts */
> - fdp1->alloc_ctx = vb2_dma_contig_init_ctx(>dev);
> - if (IS_ERR(fdp1->alloc_ctx)) {
> - v4l2_err(>v4l2_dev, "Failed to init memory 

Re: [PATCH v3 09/10] v4l: fdp1: Fix field validation when preparing buffer

2016-09-11 Thread Kieran Bingham
On 07/09/16 23:25, Laurent Pinchart wrote:
> Ensure that the buffer field matches the field configured for the
> format.

Looks OK and tests fine.

I think with the field 'serialiser' the driver didn't actually care what
the buffers put in were (as long as they were sequential) but it
certainly isn't a bad thing to verify they are what we were told they
would be :D

--
Reviewed-by: Kieran Bingham <kie...@bingham.xyz>

> Signed-off-by: Laurent Pinchart <laurent.pinchart+rene...@ideasonboard.com>
> ---
>  drivers/media/platform/rcar_fdp1.c | 40 
> +++---
>  1 file changed, 33 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar_fdp1.c 
> b/drivers/media/platform/rcar_fdp1.c
> index 480f89381f15..c25531a919db 100644
> --- a/drivers/media/platform/rcar_fdp1.c
> +++ b/drivers/media/platform/rcar_fdp1.c
> @@ -1884,17 +1884,43 @@ static int fdp1_buf_prepare(struct vb2_buffer *vb)
>  
>   q_data = get_q_data(ctx, vb->vb2_queue->type);
>  
> - /* Default to Progressive if ANY selected */
> - if (vbuf->field == V4L2_FIELD_ANY)
> - vbuf->field = V4L2_FIELD_NONE;
> + if (V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) {
> + bool field_valid = true;
> +
> + /* Validate the buffer field. */
> + switch (q_data->format.field) {
> + case V4L2_FIELD_NONE:
> + if (vbuf->field != V4L2_FIELD_NONE)
> + field_valid = false;
> + break;
> +
> + case V4L2_FIELD_ALTERNATE:
> + if (vbuf->field != V4L2_FIELD_TOP &&
> + vbuf->field != V4L2_FIELD_BOTTOM)
> + field_valid = false;
> + break;
>  
> - /* We only support progressive CAPTURE */
> - if (!V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type) &&
> -  vbuf->field != V4L2_FIELD_NONE) {
> - dprintk(ctx->fdp1, "field isn't supported on capture\n");
> + case V4L2_FIELD_INTERLACED:
> + case V4L2_FIELD_SEQ_TB:
> + case V4L2_FIELD_SEQ_BT:
> + case V4L2_FIELD_INTERLACED_TB:
> + case V4L2_FIELD_INTERLACED_BT:
> + if (vbuf->field != q_data->format.field)
> + field_valid = false;
> + break;
> + }
> +
> + if (!field_valid) {
> + dprintk(ctx->fdp1,
> + "buffer field %u invalid for format field %u\n",
> + vbuf->field, q_data->format.field);
>   return -EINVAL;
> + }
> +     } else {
> + vbuf->field = V4L2_FIELD_NONE;
>   }
>  
> + /* Validate the planes sizes. */
>   for (i = 0; i < q_data->format.num_planes; i++) {
>   unsigned long size = q_data->format.plane_fmt[i].sizeimage;
>  
> 

-- 
Regards

Kieran Bingham


Re: [PATCH v3 10/10] v4l: fdp1: Store buffer information in vb2 buffer

2016-09-11 Thread Kieran Bingham
Hi Laurent,

Ok - I've gone through this properly now, and I really like what I see :)

Definitely some good changes here - and my comments are only minor
fixups which are just things I've noticed which we can 'squash' in.

You'll find 'fixup commits' for the following three hunks:
 - FDP1_NUMBER_BUFFERS
 - old struct fdp1_job comment
 - fdp1_field_complete(), unused ctx removal
at
git://git.kernel.org/pub/scm/linux/kernel/git/kbingham/rcar.git fdp1/review
if you wish to use them.

The rework of buffer usage here really makes a big difference I think.
Removing the late allocations, and preparing the buffers early is
clearly more elegant and less prone to failure.

Thanks

Kieran

...
Obligatory over tagging

Acked-by: Kieran Bingham <kie...@bingham.xyz>
Reviewed-by: Kieran Bingham <kie...@bingham.xyz>


On 07/09/16 23:25, Laurent Pinchart wrote:
> The struct fdp1_buffer instances are allocated separately from the vb2
> buffers, with one instance per field. Simplify the allocation by
> splitting the fdp1_buffer structure in per-buffer and per-field data,
> and let vb2 allocate the the fdp1_buffer structure.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+rene...@ideasonboard.com>
> ---
>  drivers/media/platform/rcar_fdp1.c | 437 
> ++---
>  1 file changed, 210 insertions(+), 227 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar_fdp1.c 
> b/drivers/media/platform/rcar_fdp1.c
> index c25531a919db..d4101a4fd114 100644
> --- a/drivers/media/platform/rcar_fdp1.c
> +++ b/drivers/media/platform/rcar_fdp1.c

Now that it's not used, we can add in a
@@ ~ 61
- #define FDP1_NUMBER_BUFFERS ((FDP1_NUMBER_JOBS*2)+1)

(Removing that makes me happy)

> @@ -473,12 +473,12 @@ static const u8 fdp1_mdet[] = {
>  
>  /* Per-queue, driver-specific private data */
>  struct fdp1_q_data {
> - const struct fdp1_fmt   *fmt;
> - struct v4l2_pix_format_mplane format;
> + const struct fdp1_fmt   *fmt;
> + struct v4l2_pix_format_mplane   format;
>  
> - unsigned intvsize;
> - unsigned intstride_y;
> - unsigned intstride_c;
> + unsigned intvsize;
> + unsigned intstride_y;
> + unsigned intstride_c;
>  };
>  
>  static const struct fdp1_fmt *fdp1_find_format(u32 pixelformat)
> @@ -519,91 +519,102 @@ enum fdp1_deint_mode {
>   * from the VB buffers using this context structure.
>   * Will always be a field or a full frame, never two fields.
>   */
> -struct fdp1_buffer {
> - struct vb2_v4l2_buffer  *vb;
> - dma_addr_t  addrs[3];
> +struct fdp1_field_buffer {
> + struct vb2_v4l2_buffer  *vb;
> + dma_addr_t  addrs[3];
>  
>   /* Should be NONE:TOP:BOTTOM only */
> - enum v4l2_field field;
> + enum v4l2_field field;
>  
>   /* Flag to indicate this is the last field in the vb */
> - boollast_field;
> + boollast_field;
>  
>   /* Buffer queue lists */
> - struct list_headlist;
> + struct list_headlist;
> +};
> +
> +struct fdp1_buffer {
> + struct v4l2_m2m_buffer  m2m_buf;
> + struct fdp1_field_bufferfields[2];
> + unsigned intnum_fields;
>  };
>  
> +static inline struct fdp1_buffer *to_fdp1_buffer(struct vb2_v4l2_buffer *vb)
> +{
> + return container_of(vb, struct fdp1_buffer, m2m_buf.vb);
> +}
> +
>  struct fdp1_job {
>   /* These could be pointers to save 'memory' and copying */

This comment is now defunct.

> - struct fdp1_buffer  *previous;
> - struct fdp1_buffer  *active;
> - struct fdp1_buffer  *next;
> - struct fdp1_buffer  dst;
> + struct fdp1_field_buffer*previous;
> + struct fdp1_field_buffer*active;
> + struct fdp1_field_buffer*next;
> + struct fdp1_field_buffer*dst;
>  
>   /* A job can only be on one list at a time */
> - struct list_headlist;
> + struct list_headlist;
>  };
>  
>  struct fdp1_dev {
> - struct v4l2_device  v4l2_dev;
> - struct video_device vfd;
> + struct v4l2_device  v4l2_dev;
> + struct video_device vfd;
>  
> - struct mutexdev_mutex;
> - spinlock_t  irqlock;
> - spinlock_t  device_process_lock;
> + struct mutexdev_mutex;
> + spinlock_t  irqlock;
> + spinlock_t  device_process_lock;
>  
> 

Re: [PATCH v3 06/10] v4l: fdp1: Incorporate miscellaneous review comments

2016-09-11 Thread Kieran Bingham


On 07/09/16 23:25, Laurent Pinchart wrote:
> - Constify data tables
> - Add missing break in switch statement
> - Use struct video_device::device_caps
> - Don't set read-only flag manually for V4L2_CID_MIN_BUFFERS_FOR_CAPTURE
> - Use V4L2_YCBCR_ENC_709 instead of V4L2_COLORSPACE_REC709 for ycbcr_enc
> - Fix handling of V4L2_FIELD_INTERLACED
> - Use the standard V4L2_CID_DEINTERLACER_MODE control
> - Add missing white space
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+rene...@ideasonboard.com>
Reviewed-by: Kieran Bingham <kie...@bingham.xyz>

> ---
>  drivers/media/platform/rcar_fdp1.c | 111 
> +
>  1 file changed, 52 insertions(+), 59 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar_fdp1.c 
> b/drivers/media/platform/rcar_fdp1.c
> index a2587745ca68..bbeacf1527b5 100644
> --- a/drivers/media/platform/rcar_fdp1.c
> +++ b/drivers/media/platform/rcar_fdp1.c
> @@ -297,108 +297,108 @@ struct fdp1_fmt {
>  static const struct fdp1_fmt fdp1_formats[] = {
>   /* RGB formats are only supported by the Write Pixel Formatter */
>  
> - { V4L2_PIX_FMT_RGB332, { 8, 0, 0}, 1, 1, 1, 0x00, false, false,
> + { V4L2_PIX_FMT_RGB332, { 8, 0, 0 }, 1, 1, 1, 0x00, false, false,
> FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
> FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
> FDP1_CAPTURE },
> - { V4L2_PIX_FMT_XRGB444, { 16, 0, 0}, 1, 1, 1, 0x01, false, false,
> + { V4L2_PIX_FMT_XRGB444, { 16, 0, 0 }, 1, 1, 1, 0x01, false, false,
> FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
> FD1_RWPF_SWAP_WORD,
> FDP1_CAPTURE },
> - { V4L2_PIX_FMT_XRGB555, { 16, 0, 0}, 1, 1, 1, 0x04, false, false,
> + { V4L2_PIX_FMT_XRGB555, { 16, 0, 0 }, 1, 1, 1, 0x04, false, false,
> FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
> FD1_RWPF_SWAP_WORD,
> FDP1_CAPTURE },
> - { V4L2_PIX_FMT_RGB565, { 16, 0, 0}, 1, 1, 1, 0x06, false, false,
> + { V4L2_PIX_FMT_RGB565, { 16, 0, 0 }, 1, 1, 1, 0x06, false, false,
> FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
> FD1_RWPF_SWAP_WORD,
> FDP1_CAPTURE },
> - { V4L2_PIX_FMT_ABGR32, { 32, 0, 0}, 1, 1, 1, 0x13, false, false,
> + { V4L2_PIX_FMT_ABGR32, { 32, 0, 0 }, 1, 1, 1, 0x13, false, false,
> FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD,
> FDP1_CAPTURE },
> - { V4L2_PIX_FMT_XBGR32, { 32, 0, 0}, 1, 1, 1, 0x13, false, false,
> + { V4L2_PIX_FMT_XBGR32, { 32, 0, 0 }, 1, 1, 1, 0x13, false, false,
> FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD,
> FDP1_CAPTURE },
> - { V4L2_PIX_FMT_ARGB32, { 32, 0, 0}, 1, 1, 1, 0x13, false, false,
> + { V4L2_PIX_FMT_ARGB32, { 32, 0, 0 }, 1, 1, 1, 0x13, false, false,
> FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
> FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
> FDP1_CAPTURE },
> - { V4L2_PIX_FMT_XRGB32, { 32, 0, 0}, 1, 1, 1, 0x13, false, false,
> + { V4L2_PIX_FMT_XRGB32, { 32, 0, 0 }, 1, 1, 1, 0x13, false, false,
> FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
> FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
> FDP1_CAPTURE },
> - { V4L2_PIX_FMT_RGB24, { 24, 0, 0}, 1, 1, 1, 0x15, false, false,
> + { V4L2_PIX_FMT_RGB24, { 24, 0, 0 }, 1, 1, 1, 0x15, false, false,
> FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
> FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
> FDP1_CAPTURE },
> - { V4L2_PIX_FMT_BGR24, { 24, 0, 0}, 1, 1, 1, 0x18, false, false,
> + { V4L2_PIX_FMT_BGR24, { 24, 0, 0 }, 1, 1, 1, 0x18, false, false,
> FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
> FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
> FDP1_CAPTURE },
> - { V4L2_PIX_FMT_ARGB444, { 16, 0, 0}, 1, 1, 1, 0x19, false, false,
> + { V4L2_PIX_FMT_ARGB444, { 16, 0, 0 }, 1, 1, 1, 0x19, false, false,
> FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
> FD1_RWPF_SWAP_WORD,
> FDP1_CAPTURE },
> - { V4L2_PIX_FMT_ARGB555, { 16, 0, 0}, 1, 1, 1, 0x1b, false, false,
> + { V4L2_PIX_FMT_ARGB555, { 16, 0, 0 }, 1, 1, 1, 0x1b, false, false,
> FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
> FD1_RWPF_SWAP_WORD,
> FDP1_CAPTURE },
>  
>   /* YUV Formats are supported by Read and Write Pixel Formatters */
>  
> - { V4L2_PIX_FMT_NV16M, { 8, 16, 0}, 2, 2, 1, 0x41, false, false,
> + { V4L2_PIX_FMT_NV16M, { 8, 16, 0 }, 2, 2, 1, 0x41, false, false,
> FD1_RWPF_SWAP_LLWD | FD1_RWPF_SWAP_LWRD |
> FD1_RWPF_SWAP_WORD | FD1_RWPF_SWAP_BYTE,
> FDP1_CAPTURE | FDP1_OUTPUT },
> - { V4L2_PIX_FMT_NV61M, { 8, 16, 0}, 2, 2, 1, 0x41, false, true,
> + { V4L2_PIX_FMT_NV61M, { 8, 16, 0 }, 2, 2, 1, 0x41, fals

[PULL REQUEST] VSP1 Image Partitioning algorithm

2016-09-14 Thread Kieran Bingham
Hi Geert,

Please consider integrating the latest VSP1 next branch to provide the
image partitioning algorithm into renesas-drivers

Regards

Kieran


The following changes since commit c3b809834db8b1a8891c7ff873a216eac119628d:

  [media] pulse8-cec: fix compiler warning (2016-09-12 06:42:44 -0300)

are available in the git repository at:

  git://linuxtv.org/pinchartl/media.git vsp1/next

for you to fetch changes up to 9f39e31fbb3fb6ebd75d7012d3574def2f5da596:

  v4l: vsp1: Fix spinlock in mixed IRQ context function (2016-09-14 13:06:51 
+0300)


Kieran Bingham (6):
  v4l: vsp1: Ensure pipeline locking in resume path
  v4l: vsp1: Repair race between frame end and qbuf handler
  v4l: vsp1: Use DFE instead of FRE for frame end
  v4l: vsp1: Support chained display lists
  v4l: vsp1: Determine partition requirements for scaled images
  v4l: vsp1: Support multiple partitions per frame

Laurent Pinchart (8):
  v4l: vsp1: Prevent pipelines from running when not streaming
  v4l: vsp1: Protect against race conditions between get and set format
  v4l: vsp1: Disable cropping on WPF sink pad
  v4l: vsp1: Fix RPF cropping
  v4l: vsp1: Pass parameter type to entity configuration operation
  v4l: vsp1: Replace .set_memory() with VSP1_ENTITY_PARAMS_PARTITION
  v4l: vsp1: wpf: Implement rotation support
  v4l: vsp1: Fix spinlock in mixed IRQ context function

 drivers/media/platform/vsp1/vsp1_bru.c|  33 +++-
 drivers/media/platform/vsp1/vsp1_clu.c|  61 ---
 drivers/media/platform/vsp1/vsp1_dl.c | 119 +++--
 drivers/media/platform/vsp1/vsp1_dl.h |   1 +
 drivers/media/platform/vsp1/vsp1_drm.c|  15 +-
 drivers/media/platform/vsp1/vsp1_drv.c|   2 +-
 drivers/media/platform/vsp1/vsp1_entity.c |  22 ++-
 drivers/media/platform/vsp1/vsp1_entity.h |  25 ++-
 drivers/media/platform/vsp1/vsp1_hsit.c   |  20 ++-
 drivers/media/platform/vsp1/vsp1_lif.c|  20 ++-
 drivers/media/platform/vsp1/vsp1_lut.c|  42 +++--
 drivers/media/platform/vsp1/vsp1_pipe.c   |   3 +
 drivers/media/platform/vsp1/vsp1_pipe.h   |   8 +
 drivers/media/platform/vsp1/vsp1_rpf.c| 106 
 drivers/media/platform/vsp1/vsp1_rwpf.c   |  86 +
 drivers/media/platform/vsp1/vsp1_rwpf.h   |  16 +-
 drivers/media/platform/vsp1/vsp1_sru.c|  50 +-
 drivers/media/platform/vsp1/vsp1_uds.c|  71 ++--
 drivers/media/platform/vsp1/vsp1_video.c  | 188 ++--
 drivers/media/platform/vsp1/vsp1_wpf.c| 279 ++
 20 files changed, 883 insertions(+), 284 deletions(-)


Re: [PATCH v3 07/10] v4l: fdp1: Remove unused struct fdp1_v4l2_buffer

2016-09-09 Thread Kieran Bingham


On 07/09/16 23:25, Laurent Pinchart wrote:
> The structure is not used, remove it.

Ahh yes, looks like a left over from my first attempt at serialising
input fields.

Reviewed-by: Kieran Bingham <kie...@bingham.xyz>

> Signed-off-by: Laurent Pinchart <laurent.pinchart+rene...@ideasonboard.com>
> ---
>  drivers/media/platform/rcar_fdp1.c | 13 -
>  1 file changed, 13 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar_fdp1.c 
> b/drivers/media/platform/rcar_fdp1.c
> index bbeacf1527b5..fdab41165f5a 100644
> --- a/drivers/media/platform/rcar_fdp1.c
> +++ b/drivers/media/platform/rcar_fdp1.c
> @@ -514,19 +514,6 @@ enum fdp1_deint_mode {
>mode == FDP1_PREVFIELD)
>  
>  /*
> - * fdp1_v4l2_buffer: Track v4l2_buffers with a reference count
> - *
> - * As buffers come in, they may be used for more than one field.
> - * It then becomes necessary to track the usage of these buffers,
> - * and only release when the last job has completed using this
> - * vb buffer.
> - */
> -struct fdp1_v4l2_buffer {
> - struct vb2_v4l2_buffer  vb;
> - struct list_headlist;
> -};
> -
> -/*
>   * FDP1 operates on potentially 3 fields, which are tracked
>   * from the VB buffers using this context structure.
>   * Will always be a field or a full frame, never two fields.
> 

-- 
Regards

Kieran Bingham


Re: [PATCH 04/13] v4l: vsp1: Repair race between frame end and qbuf handler

2016-09-14 Thread Kieran Bingham
On 14/09/16 00:16, Laurent Pinchart wrote:
> From: Kieran Bingham <kieran+rene...@bingham.xyz>
> 
> The frame-end function releases and completes the buffers on the input
> and output entities of the pipe before marking the pipe->state as
> 'STOPPED'. This introduces a race whereby with the pipe->state still
> 'RUNNING', a QBUF handler can commence processing a frame before the
> frame_end function has completed.
> 
> In the event that this happens, a frame queued by QBUF hangs due to the
> incorrect pipe->state setting which prevents vsp1_pipeline_run from
> issuing a CMD_STRCMD.
> 
> By locking the entire function we prevent this from occurring, but we
> also change the locking state of the buffer release code. This has been
> analysed visually as acceptable, but it must be considered that this now
> causes the video->irqlock to be taken under the pipe->irqlock context.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+rene...@ideasonboard.com>


This patch is of course perfectly welcome to my SoB:
Signed-off-by: Kieran Bingham <kieran+rene...@bingham.xyz>

> ---
>  drivers/media/platform/vsp1/vsp1_video.c | 9 ++---
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/platform/vsp1/vsp1_video.c 
> b/drivers/media/platform/vsp1/vsp1_video.c
> index ed9759e8a6fc..cd7d215ed455 100644
> --- a/drivers/media/platform/vsp1/vsp1_video.c
> +++ b/drivers/media/platform/vsp1/vsp1_video.c
> @@ -234,18 +234,13 @@ static void vsp1_video_frame_end(struct vsp1_pipeline 
> *pipe,
>  {
>   struct vsp1_video *video = rwpf->video;
>   struct vsp1_vb2_buffer *buf;
> - unsigned long flags;
>  
>   buf = vsp1_video_complete_buffer(video);
>   if (buf == NULL)
>   return;
>  
> - spin_lock_irqsave(>irqlock, flags);
> -
>   video->rwpf->mem = buf->mem;
>   pipe->buffers_ready |= 1 << video->pipe_index;
> -
> - spin_unlock_irqrestore(>irqlock, flags);
>  }
>  
>  static void vsp1_video_pipeline_run(struct vsp1_pipeline *pipe)
> @@ -285,6 +280,8 @@ static void vsp1_video_pipeline_frame_end(struct 
> vsp1_pipeline *pipe)
>   unsigned long flags;
>   unsigned int i;
>  
> + spin_lock_irqsave(>irqlock, flags);
> +
>   /* Complete buffers on all video nodes. */
>   for (i = 0; i < vsp1->info->rpf_count; ++i) {
>   if (!pipe->inputs[i])
> @@ -295,8 +292,6 @@ static void vsp1_video_pipeline_frame_end(struct 
> vsp1_pipeline *pipe)
>  
>   vsp1_video_frame_end(pipe, pipe->output);
>  
> - spin_lock_irqsave(>irqlock, flags);
> -
>   state = pipe->state;
>   pipe->state = VSP1_PIPELINE_STOPPED;
>  
> 


Re: [PULL REQUEST] VSP1 Image Partitioning algorithm

2016-09-19 Thread Kieran Bingham
On 19/09/16 16:57, Geert Uytterhoeven wrote:
> Hi Kieran,
> 
> On Wed, Sep 14, 2016 at 6:45 PM, Kieran Bingham <kie...@ksquared.org.uk> 
> wrote:
>> Please consider integrating the latest VSP1 next branch to provide the
>> image partitioning algorithm into renesas-drivers
>>
>> Regards
>>
>> Kieran
>>
>>
>> The following changes since commit c3b809834db8b1a8891c7ff873a216eac119628d:
>>
>>   [media] pulse8-cec: fix compiler warning (2016-09-12 06:42:44 -0300)
>>
>> are available in the git repository at:
>>
>>   git://linuxtv.org/pinchartl/media.git vsp1/next
>>
>> for you to fetch changes up to 9f39e31fbb3fb6ebd75d7012d3574def2f5da596:
>>
>>   v4l: vsp1: Fix spinlock in mixed IRQ context function (2016-09-14 13:06:51 
>> +0300)
> 
> In the mean time, this has been rebased, and more commits have been added?
> I will only pull tomorrow anyway...

Ahh yes,

Looks like a couple of bug-fixes got merged in afterwards.

The vsp1/next branch should also be merged into linux-media/master soon
(potentially today, dependant upon Mauro) ... so it could get in that
way also ...

Cheers

Kieran

> Gr{oetje,eeting}s,
> 
> Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds
> 

-- 
Regards

Kieran Bingham


Re: Kernal version Issue

2016-10-03 Thread Kieran Bingham
Hi Jithin,

On 03/10/16 08:55, Jithin T Raj wrote:

> hi team, I have downloaded Source tree version 4.7.5 from
> kernel.org..I have build image for RCAR E2  by using that..but the
> board is not accepting the kernel..

We would need to know a bit more detail about 'not accepting the kernel'
here.

Has the kernel you built been configured correctly for your target board?

Were there any traces from the serial console at the point of failure?

How are you building for your target, are you using Yocto?, Buildroot?,
or are you cross compiling the kernel yourself?

Looking through some of your other mail postings, I see you are typing
'make -j4' but I can not see what environment you are building in.

> i want to know "Is there any
> special release of kernel for Renesas only?

>From a community support perspective, you should really be looking to
use the mainline. (An official release from kernel.org, or usage of
torvalds/linux.git)

If you are intending to make modifications to the sources, I would
recommend that you use 'git', rather than downloading a specific version
of source tree from kernel.org, as this will help you track the changes
that you make.

Are you familiar with git yet?

You mention that you can not access github, but I see that you have been
able to access kernel.org ...

Are you able to 'clone' a git kernel using http? :

git clone http://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

> if yes can you please
> provide me some links or kernel from www.kernel.org are suitable for
> all Renesas Board? Hopping your reply

To answer that question as carefully as I can:

The mainline kernel is suitable for all *currently supported* Renesas
boards.

For anything else you would need to contact the vendor specifically, or
a specialist consultant to support you.

> Best Regards Jithin T Raj

--
Regards

Kieran Bingham


[PATCH] v4l: vsp1: Prevent commencing pipelines before they are setup

2016-11-11 Thread Kieran Bingham
With multiple inputs through the BRU it is feasible for the streams to
race each other at stream-on. In the case of the video pipelines, this
can present two serious issues.

 1) A null-dereference if the pipe->dl is committed at the same time as
the vsp1_video_setup_pipeline() is processing

 2) A hardware hang, where a display list is committed without having
called vsp1_video_setup_pipeline() first.

To prevent these scenarios from occurring, we ensure that only the thread
that calls the vsp1_video_setup_pipeline() is capable of committing and
commencing the display list.

Signed-off-by: Kieran Bingham <kieran.bingham+rene...@ideasonboard.com>
---

I considered a few options to fix this issue. If anyone disagrees with my
reasoning, and believes one of the below approaches should be used, let me
know and I'll rework the patch.

 A) Moving the vsp1_video_pipeline_run() call into the upper if block.
  - This changes the locking, and brings in unneccessary nested locking

 B) Adapting vsp1_pipeline_ready() such that it checks for a configured
pipeline event as well.

  - This was tempting - but this particular issue is local to this
function only. Changing vsp1_pipeline_ready() to watch for a flag
set by vsp1_video_setup_pipeline() would require adding unneccessary
changes to the vsp1_drm objects to cater for this.

To test this race, I have used the vsp-unit-test-0007.sh from Laurent's
VSP-Tests [0] in iteration. Without this patch, failures can be seen be
seen anywhere up to the 150 iterations mark.

With this patch in place, tests have successfully iterated over 1500
loops.

The function affected by this change appears to have been around since
v4.6-rc2-105-g351bbf99f245 and thus may want inclusion in stable trees
from that point forward. The issue may have been prevalent before that
but the solution would need reworking for earlier version.

[0] http://git.ideasonboard.com/renesas/vsp-tests.git

 drivers/media/platform/vsp1/vsp1_video.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/vsp1/vsp1_video.c 
b/drivers/media/platform/vsp1/vsp1_video.c
index 94b428596c4f..cc44b27f3e47 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -813,6 +813,7 @@ static int vsp1_video_start_streaming(struct vb2_queue *vq, 
unsigned int count)
struct vsp1_video *video = vb2_get_drv_priv(vq);
struct vsp1_pipeline *pipe = video->rwpf->pipe;
unsigned long flags;
+   bool configured = false;
int ret;
 
mutex_lock(>lock);
@@ -822,13 +823,20 @@ static int vsp1_video_start_streaming(struct vb2_queue 
*vq, unsigned int count)
mutex_unlock(>lock);
return ret;
}
+
+   /*
+* Multiple streams will execute this function in parallel.
+* Only the thread which configures the pipeline is allowed to
+* execute the vsp1_video_pipeline_run() call below
+*/
+   configured = true;
}
 
pipe->stream_count++;
mutex_unlock(>lock);
 
spin_lock_irqsave(>irqlock, flags);
-   if (vsp1_pipeline_ready(pipe))
+   if (vsp1_pipeline_ready(pipe) && configured)
vsp1_video_pipeline_run(pipe);
spin_unlock_irqrestore(>irqlock, flags);
 
-- 
2.7.4



Re: [PATCH v4 3/4] v4l: Add Renesas R-Car FDP1 Driver

2016-10-24 Thread Kieran Bingham
Hi Laurent,

Thanks for your reworking and improvements here.

The documentation additions look good.

Only one grammar fixup found inline in the struct fdp1_ctx which isn't
critical (and could have been from my original submission), so don't
worry about it unless there ends up being another respin.
--
Regards

Kieran

On 24/10/16 10:03, Laurent Pinchart wrote:
> From: Kieran Bingham <kieran+rene...@bingham.xyz>
> 
> The FDP1 driver performs advanced de-interlacing on a memory 2 memory
> based video stream, and supports conversion from YCbCr/YUV
> to RGB pixel formats
> 
> Signed-off-by: Kieran Bingham <kieran+rene...@bingham.xyz>
> Reviewed-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+rene...@ideasonboard.com>
> ---
> Changes since v3:
> 
> - Squashed all driver changes together
> - Documented deinterlacing modes
> - Capitalized the 2D and 3D abbreviations
> ---
>  Documentation/media/v4l-drivers/index.rst |1 +
>  Documentation/media/v4l-drivers/rcar-fdp1.rst |   37 +
>  MAINTAINERS   |9 +
>  drivers/media/platform/Kconfig|   13 +
>  drivers/media/platform/Makefile   |1 +
>  drivers/media/platform/rcar_fdp1.c| 2446 
> +
>  6 files changed, 2507 insertions(+)
>  create mode 100644 Documentation/media/v4l-drivers/rcar-fdp1.rst
>  create mode 100644 drivers/media/platform/rcar_fdp1.c
> 
> diff --git a/Documentation/media/v4l-drivers/index.rst 
> b/Documentation/media/v4l-drivers/index.rst
> index acde3ed7860f..a606d1cdac13 100644
> --- a/Documentation/media/v4l-drivers/index.rst
> +++ b/Documentation/media/v4l-drivers/index.rst
> @@ -48,6 +48,7 @@ For more details see the file COPYING in the source 
> distribution of Linux.
>   pvrusb2
>   pxa_camera
>   radiotrack
> + rcar-fdp1
>   saa7134
>   sh_mobile_ceu_camera
>   si470x
> diff --git a/Documentation/media/v4l-drivers/rcar-fdp1.rst 
> b/Documentation/media/v4l-drivers/rcar-fdp1.rst
> new file mode 100644
> index ..a59b1e8e3e9c
> --- /dev/null
> +++ b/Documentation/media/v4l-drivers/rcar-fdp1.rst
> @@ -0,0 +1,37 @@
> +Renesas R-Car Fine Display Processor (FDP1) Driver
> +==
> +
> +The R-Car FDP1 driver implements driver-specific controls as follows.
> +
> +``V4L2_CID_DEINTERLACING_MODE (menu)``
> +The video deinterlacing mode (such as Bob, Weave, ...). The R-Car FDP1
> +driver implements the following modes.
> +
> +.. flat-table::
> +:header-rows:  0
> +:stub-columns: 0
> +:widths:   1 4
> +
> +* - ``"Progressive" (0)``
> +  - The input image video stream is progressive (not interlaced). No
> +deinterlacing is performed. Apart from (optional) format and encoding
> +conversion output frames are identical to the input frames.
> +* - ``"Adaptive 2D/3D" (1)``
> +  - Motion adaptive version of 2D and 3D deinterlacing. Use 3D 
> deinterlacing
> +in the presence of fast motion and 2D deinterlacing with diagonal
> +interpolation otherwise.
> +* - ``"Fixed 2D" (2)``
> +  - The current field is scaled vertically by averaging adjacent lines to
> +recover missing lines. This method is also known as blending or Line
> +Averaging (LAV).
> +* - ``"Fixed 3D" (3)``
> +  - The previous and next fields are averaged to recover lines missing 
> from
> +the current field. This method is also known as Field Averaging 
> (FAV).
> +* - ``"Previous field" (4)``
> +  - The current field is weaved with the previous field, i.e. the 
> previous
> +field is used to fill missing lines from the current field. This 
> method
> +is also known as weave deinterlacing.
> +* - ``"Next field" (5)``
> +  - The current field is weaved with the next field, i.e. the next field 
> is
> +used to fill missing lines from the current field. This method is 
> also
> +known as weave deinterlacing.

Doc's look good.

> diff --git a/MAINTAINERS b/MAINTAINERS
> index 1cd38a7e0064..a61bebacee45 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -7712,6 +7712,15 @@ F: 
> Documentation/devicetree/bindings/media/renesas,fcp.txt
>  F:   drivers/media/platform/rcar-fcp.c
>  F:   include/media/rcar-fcp.h
>  
> +MEDIA DRIVERS FOR RENESAS - FDP1
> +M:   Kieran Bingham <kie...@bingham.xyz>
> +L:   linux-me...@vger.kernel.org
> +L:   linux-renesas-soc@vger.kernel.org
> +T:   git git

[PATCH 4/5] tests: Test suspend/resume on idle pipelines

2016-11-25 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

Provide a test to verify the hardware is functional both before and
after entering a suspend / resume cycle. Make use of the
/sys/power/pm_test functionality provided by CONFIG_PM_DEBUG to perform
the testing

Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
---
 tests/vsp-unit-test-0019.sh | 77 +
 1 file changed, 77 insertions(+)
 create mode 100755 tests/vsp-unit-test-0019.sh

diff --git a/tests/vsp-unit-test-0019.sh b/tests/vsp-unit-test-0019.sh
new file mode 100755
index ..e7b94996c1aa
--- /dev/null
+++ b/tests/vsp-unit-test-0019.sh
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+#
+# Test power-management suspend/resume whilst pipelines are idle
+#
+# Utilise the basic RPF->WPF packing test case as a measure that the hardware
+# is operable while we perform test suspend and resume, and verify that it is
+# still operable after resume.
+#
+# Format iteration loops are maintained, even with only one format so that this
+# test can be easily extended to try further formats if needed in the future.
+#
+
+source vsp-lib.sh
+
+features="rpf.0 wpf.0"
+formats="RGB24"
+
+# These can be extracted from /sys/power/pm_test
+suspend_modes="freezer devices platform processors core"
+
+test_wpf_packing() {
+   test_start "Verify WPF packing in $format before/after suspend:$mode"
+
+   pipe_configure rpf-wpf 0 0
+   format_configure rpf-wpf 0 0 ARGB32 1024x768 $format
+
+   vsp_runner rpf.0 &
+   vsp_runner wpf.0
+
+   local result=$(compare_frames)
+
+   test_complete $result
+}
+
+test_hw_pipe() {
+   local format
+
+   for format in $formats ; do
+   test_wpf_packing $format
+   done
+}
+
+test_suspend_resume() {
+   local test_results=0
+
+   # Test the hardware each side of suspend resume
+   test_hw_pipe
+
+   # Set the test mode
+   echo $mode > /sys/power/pm_test
+
+   # Comence suspend
+   # The pm_test framework will automatically resume after 5 seconds
+   echo mem > /sys/power/state
+
+   # Verify the hardware is still operational
+   test_hw_pipe
+}
+
+test_main() {
+   local mode;
+
+   # Check for pm-suspend test option
+   if [ ! -e /sys/power/pm_test ] ; then
+   echo "$0: Suspend Resume testing requires CONFIG_PM_DEBUG"
+   test_complete skip
+   return
+   fi;
+
+   for mode in $suspend_modes ; do
+   test_suspend_resume $mode
+   done;
+}
+
+test_init $0 "$features"
+test_run
-- 
2.7.4



[PATCH 2/5] scripts: Provide bin2png.sh helper

2016-11-25 Thread Kieran Bingham
From: Kieran Bingham <kie...@bingham.xyz>

Identify the size and format from the test output filename, and pass
to raw2rgbpnm for conversion to a PNM file.

>From there we can convert easily to a PNG output file.

Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 scripts/Makefile   |  2 +-
 scripts/bin2png.sh | 34 ++
 2 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100755 scripts/bin2png.sh

diff --git a/scripts/Makefile b/scripts/Makefile
index 8c452f4c54ce..6586b2989aed 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -1,4 +1,4 @@
-SCRIPTS=logger.sh vsp-lib.sh
+SCRIPTS=$(wildcard *.sh)
 
 all:
 
diff --git a/scripts/bin2png.sh b/scripts/bin2png.sh
new file mode 100755
index ..527c5546514d
--- /dev/null
+++ b/scripts/bin2png.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+FILE="$1"
+
+fmt=$(echo $FILE | sed -e 's/.*-\([[:alnum:]]*\)-\([0-9]*x[0-9]*\).*.bin/\1/')
+size=$(echo $FILE | sed -e 's/.*-\([[:alnum:]]*\)-\([0-9]*x[0-9]*\).*.bin/\2/')
+
+case $fmt in
+   yuv410m|yvu410m|yuv411m|yuv420m|yvu420m|yuv422m|yvu422m|yuv444m|yvu444m)
+   fmt=`echo $fmt | tr '[:lower:]' '[:upper:]'`
+   fmt=`echo $fmt | tr 'M' 'P'`
+   ;;
+   nv12m|nv21m|nv16m|nv61m)
+   fmt=`echo $fmt | tr '[:lower:]' '[:upper:]'`
+   fmt=`echo $fmt | tr -d 'M'`
+   ;;
+   argb555|xrgb555)
+   fmt=RGB555X
+   ;;
+   argb32|xrgb32)
+   fmt=RGB32
+   ;;
+   abgr32|xbgr32)
+   fmt=BGR32
+   ;;
+   *)
+   fmt=`echo $fmt | tr '[:lower:]' '[:upper:]'`
+   ;;
+esac
+
+# Only run pnmtopng if the conversion to PNM succeeds
+raw2rgbpnm -s $size -f $fmt $FILE $FILE.pnm && \
+   pnmtopng $FILE.pnm > $FILE.png
+rm $FILE.pnm
-- 
2.7.4



Re: [PATCH 2/5] scripts: Provide bin2png.sh helper

2016-11-25 Thread Kieran Bingham
Hi Laurent,

Thanks for the review :D

On 25/11/16 17:55, Laurent Pinchart wrote:
> Hi Kieran,
> 
> Thank you for the patch.
> 
> On Friday 25 Nov 2016 13:59:13 Kieran Bingham wrote:
>> From: Kieran Bingham <kie...@bingham.xyz>
>>
>> Identify the size and format from the test output filename, and pass
>> to raw2rgbpnm for conversion to a PNM file.
>>
>> From there we can convert easily to a PNG output file.
>>
>> Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
>> ---
>>  scripts/Makefile   |  2 +-
>>  scripts/bin2png.sh | 34 ++
>>  2 files changed, 35 insertions(+), 1 deletion(-)
>>  create mode 100755 scripts/bin2png.sh
>>
>> diff --git a/scripts/Makefile b/scripts/Makefile
>> index 8c452f4c54ce..6586b2989aed 100644
>> --- a/scripts/Makefile
>> +++ b/scripts/Makefile
>> @@ -1,4 +1,4 @@
>> -SCRIPTS=logger.sh vsp-lib.sh
>> +SCRIPTS=$(wildcard *.sh)
>>
>>  all:
>>
>> diff --git a/scripts/bin2png.sh b/scripts/bin2png.sh
>> new file mode 100755
>> index ..527c5546514d
>> --- /dev/null
>> +++ b/scripts/bin2png.sh
>> @@ -0,0 +1,34 @@
>> +#!/bin/sh
>> +
>> +FILE="$1"
>> +
>> +fmt=$(echo $FILE | sed -e
>> 's/.*-\([[:alnum:]]*\)-\([0-9]*x[0-9]*\).*.bin/\1/')
>> +size=$(echo $FILE |
>> sed -e 's/.*-\([[:alnum:]]*\)-\([0-9]*x[0-9]*\).*.bin/\2/')
>> +
>> +case $fmt in
>> +yuv410m|yvu410m|yuv411m|yuv420m|yvu420m|yuv422m|yvu422m|yuv444m|
> yvu444m)
>> +fmt=`echo $fmt | tr '[:lower:]' '[:upper:]'`
>> +fmt=`echo $fmt | tr 'M' 'P'`
>> +;;
>> +nv12m|nv21m|nv16m|nv61m)
>> +fmt=`echo $fmt | tr '[:lower:]' '[:upper:]'`
>> +fmt=`echo $fmt | tr -d 'M'`
>> +;;
>> +argb555|xrgb555)
>> +fmt=RGB555X
>> +;;
>> +argb32|xrgb32)
>> +fmt=RGB32
>> +;;
>> +abgr32|xbgr32)
>> +fmt=BGR32
>> +;;
>> +*)
>> +fmt=`echo $fmt | tr '[:lower:]' '[:upper:]'`
>> +;;
>> +esac
>> +
>> +# Only run pnmtopng if the conversion to PNM succeeds
>> +raw2rgbpnm -s $size -f $fmt $FILE $FILE.pnm && \
> 
> How about stripping the .bin suffix to avoid calling the output file 
> *.bin.png 
> ?

Yeah, we can probably manage this :D

>> +pnmtopng $FILE.pnm > $FILE.png
> 
> We already have a dependency on ImageMagick (although on the target side, not 
> the host side). Shoould we use convert instead of pnmtopng ?

Ahh - excellent plan. Actually I'd been using this script on the host
only, using convert makes it easy to run this on the target as well.

That means in fact that I can convert 'bin' files from tmpfs storage and
output small png's without hammering the network on NFS usage.

Sounds like a win to me !

> 
>> +rm $FILE.pnm
> 


[PATCH 1/5] scripts: Test suite runner

2016-11-25 Thread Kieran Bingham
From: Kieran Bingham <kie...@bingham.xyz>

Provide a utility script to execute all vsp unit tests, as well
as the option to execute multiple iterations of the suite.

Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 scripts/vsp-tests.sh | 46 ++
 1 file changed, 46 insertions(+)
 create mode 100755 scripts/vsp-tests.sh

diff --git a/scripts/vsp-tests.sh b/scripts/vsp-tests.sh
new file mode 100755
index ..e5ffa0ec4236
--- /dev/null
+++ b/scripts/vsp-tests.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+##
+## VSP Tests runner
+##
+## Automatically execute all vsp-unit tests
+## Move test failure results to a specific folder for
+## the running kernel version
+##
+## An argument can be provided to specify the number of
+## iterations to perform
+##
+## usage:
+##  ./vsp-tests.sh 
+##
+##   n: Number of iterations to execute test suite
+##
+
+KERNEL_VERSION=`uname -r`
+
+run_test() {
+   echo $1
+   ./$1
+
+   if [ $(ls *.bin 2>/dev/null | wc -l) != 0 ];
+   then
+   RESULTS_DIR=$KERNEL_VERSION/test-$1/$2/
+
+   echo "Moving *.bin to test-$1/$2/";
+   mkdir -p $RESULTS_DIR;
+   echo "mv *.bin $RESULTS_DIR";
+   mv *.bin $RESULTS_DIR;
+   fi;
+}
+
+run_suite() {
+   echo "Test loop $1"
+
+   for test in vsp-unit-test*.sh; do
+   run_test $test $1;
+   done;
+}
+
+for loop in `seq 1 1 $1`; do
+   run_suite $loop
+done;
-- 
2.7.4



[PATCH 5/5] tests: Test suspend/resume on active pipelines

2016-11-25 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

Provide a test to verify the hardware completes a functional test whilst
performing a suspend resume cycle in parallel. Make use of the
/sys/power/pm_test functionality provided by CONFIG_PM_DEBUG to perform
the testing

Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
---
 tests/vsp-unit-test-0020.sh | 86 +
 1 file changed, 86 insertions(+)
 create mode 100755 tests/vsp-unit-test-0020.sh

diff --git a/tests/vsp-unit-test-0020.sh b/tests/vsp-unit-test-0020.sh
new file mode 100755
index ..5838295139b2
--- /dev/null
+++ b/tests/vsp-unit-test-0020.sh
@@ -0,0 +1,86 @@
+#!/bin/sh
+
+#
+# Test power-management suspend/resume whilst pipelines are active
+#
+# Utilise the basic RPF->WPF packing test case as a measure that the hardware
+# is operable while we perform test suspend and resume, and verify that it is
+# still successful even with a suspend resume cycle in the middle of the test.
+#
+# Format iteration loops are maintained, even with only one format so that this
+# test can be easily extended to try further formats if needed in the future.
+#
+
+source vsp-lib.sh
+
+features="rpf.0 wpf.0"
+formats="RGB24"
+
+# These can be extracted from /sys/power/pm_test
+suspend_modes="freezer devices platform processors core"
+
+# This extended function performs the same
+# as it's non-extended name-sake - but runs the pipeline
+# for 300 frames. The suspend action occurs between frame #150~#200
+test_extended_wpf_packing() {
+   test_start "Verify WPF packing in $format during suspend:$mode"
+
+   pipe_configure rpf-wpf 0 0
+   format_configure rpf-wpf 0 0 ARGB32 1024x768 $format
+
+   vsp_runner rpf.0 --count=300 &
+   vsp_runner wpf.0 --count=300 --skip=297
+
+   local result=$(compare_frames)
+
+   test_complete $result
+}
+
+test_hw_pipe() {
+   local format
+
+   for format in $formats ; do
+   test_extended_wpf_packing $format
+   done
+}
+
+test_suspend_resume() {
+   local test_results=0
+   local test_pid
+
+   # Test the hardware each side of suspend resume
+   test_hw_pipe &
+   test_pid=$!
+
+   # Make sure the pipeline has time to start
+   sleep 1
+
+   # Set the test mode
+   echo $mode > /sys/power/pm_test
+
+   # Comence suspend
+   # The pm_test framework will automatically resume after 5 seconds
+   echo mem > /sys/power/state
+
+   # Wait for the pipeline to complete
+   wait $test_pid
+}
+
+test_main() {
+   local mode;
+   local suspend_test_failures
+
+   # Check for pm-suspend test option
+   if [ ! -e /sys/power/pm_test ] ; then
+   echo "$0: Suspend Resume testing requires CONFIG_PM_DEBUG"
+   test_complete skip
+   return
+   fi;
+
+   for mode in $suspend_modes ; do
+   test_suspend_resume $mode
+   done;
+}
+
+test_init $0 "$features"
+test_run
-- 
2.7.4



[PATCH 3/5] logger: Log to the FTrace buffer if tracing is enabled

2016-11-25 Thread Kieran Bingham
From: Kieran Bingham <kie...@bingham.xyz>

Extend the logger such that it will detect the tracing system, and also
append print statement to this ring buffer.

This provides the relevant logging output interspersed in the ftrace
logs for an effective solution to identifying the actions that caused
the traces to occur

Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
---
 scripts/logger.sh | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/scripts/logger.sh b/scripts/logger.sh
index 8123f0c9f6e3..8412b0ba9a08 100755
--- a/scripts/logger.sh
+++ b/scripts/logger.sh
@@ -6,6 +6,17 @@ now() {
 
 label=${1:+ [$1]}
 
+TRACE_MARKER=/sys/kernel/debug/tracing/trace_marker
+if [ -e $TRACE_MARKER ]; then
+   extra_log_files=$TRACE_MARKER
+fi
+
 while read line ; do
-   echo "$(now)$label $line"
+   newline="$(now)$label $line"
+
+   echo "$newline"
+
+   for f in $extra_log_files; do
+   echo "$newline" >> $f;
+   done;
 done
-- 
2.7.4



Re: [PATCH 4/5] tests: Test suspend/resume on idle pipelines

2016-11-25 Thread Kieran Bingham


On 25/11/16 17:13, Laurent Pinchart wrote:
> Hi Kieran,
> 
> Thank you for the patch.
> 
> On Friday 25 Nov 2016 13:59:15 Kieran Bingham wrote:
>> From: Kieran Bingham <kieran.bing...@ideasonboard.com>
>>
>> Provide a test to verify the hardware is functional both before and
>> after entering a suspend / resume cycle. Make use of the
>> /sys/power/pm_test functionality provided by CONFIG_PM_DEBUG to perform
>> the testing
>>
>> Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
>> ---
>>  tests/vsp-unit-test-0019.sh | 77 ++
>>  1 file changed, 77 insertions(+)
>>  create mode 100755 tests/vsp-unit-test-0019.sh
>>
>> diff --git a/tests/vsp-unit-test-0019.sh b/tests/vsp-unit-test-0019.sh
>> new file mode 100755
>> index ..e7b94996c1aa
>> --- /dev/null
>> +++ b/tests/vsp-unit-test-0019.sh
>> @@ -0,0 +1,77 @@
>> +#!/bin/sh
>> +
>> +#
>> +# Test power-management suspend/resume whilst pipelines are idle
>> +#
>> +# Utilise the basic RPF->WPF packing test case as a measure that the
>> hardware
>> +# is operable while we perform test suspend and resume, and verify that it
>> is
>> +# still operable after resume.
>> +#
>> +# Format iteration loops are maintained, even with only one format so that
>> this
>> +# test can be easily extended to try further formats if needed in the
>> future.
>> +#
> 
> I don't think testing multiple formats is needed, but I would like the 
> test_wpf_packing() function to be called twice, to verify that stop -> start 
> works fine after resume. You could specify two formats to achieve that (with 
> a 
> comment explaining why at least two formats should be specified).
> 

That sounds like a good plan.

>> +source vsp-lib.sh
>> +
>> +features="rpf.0 wpf.0"
>> +formats="RGB24"
>> +
>> +# These can be extracted from /sys/power/pm_test
>> +suspend_modes="freezer devices platform processors core"
>> +
>> +test_wpf_packing() {
>> +test_start "Verify WPF packing in $format before/after suspend:$mode"
>> +
>> +pipe_configure rpf-wpf 0 0
>> +format_configure rpf-wpf 0 0 ARGB32 1024x768 $format
>> +
>> +vsp_runner rpf.0 &
>> +vsp_runner wpf.0
>> +
>> +local result=$(compare_frames)
>> +
>> +test_complete $result
>> +}
>> +
>> +test_hw_pipe() {
>> +local format
>> +
>> +for format in $formats ; do
>> +test_wpf_packing $format
>> +done
>> +}
>> +
>> +test_suspend_resume() {
>> +local test_results=0
> 
> This variable is unused.

Bah, I missed some. I thought I'd cleaned these out before posting. :D

>> +
>> +# Test the hardware each side of suspend resume
>> +test_hw_pipe
>> +
>> +# Set the test mode
>> +echo $mode > /sys/power/pm_test
>> +
>> +# Comence suspend
>> +# The pm_test framework will automatically resume after 5 seconds
>> +echo mem > /sys/power/state
>> +
>> +# Verify the hardware is still operational
>> +test_hw_pipe
> 
> Given that the goal is to test proper operation after resume, it would be 
> better to call test_start and test_complete in this function, based on 
> whether 
> all the tests passed or not.

Yes, I did go down this route - but stalled. Mainly in getting sensible
return values from the $(compare_frames) which can be tracked through
the functions.

I think it looked like I'd have to string match against, pass, skip,
fail etc ... without a nice easy return value I can add to an integer.

This can be re-examined.

>> +}
>> +
>> +test_main() {
>> +local mode;
> 
> No need for the trailing ;.

I think my hands are preprogrammed in 'c' coding style. Tough to get out
of sometimes :D

>> +
>> +# Check for pm-suspend test option
>> +if [ ! -e /sys/power/pm_test ] ; then
>> +echo "$0: Suspend Resume testing requires CONFIG_PM_DEBUG"
>> +test_complete skip
>> +return
>> +fi;
> 
> Ditto.

Ack.

> 
>> +
>> +for mode in $suspend_modes ; do
>> +test_suspend_resume $mode
>> +done;
> 
> Ditto.
> 

Ack.


>> +}
>> +
>> +test_init $0 "$features"
>> +test_run
> 


Re: [PATCH 3/5] logger: Log to the FTrace buffer if tracing is enabled

2016-11-25 Thread Kieran Bingham
Hi Laurent,

On 25/11/16 17:40, Laurent Pinchart wrote:
> Hi Kieran,
> 
> Thank you for the patch.
> 
> On Friday 25 Nov 2016 13:59:14 Kieran Bingham wrote:
>> From: Kieran Bingham <kie...@bingham.xyz>
>>
>> Extend the logger such that it will detect the tracing system, and also
>> append print statement to this ring buffer.
>>
>> This provides the relevant logging output interspersed in the ftrace
>> logs for an effective solution to identifying the actions that caused
>> the traces to occur
>>
>> Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
>> ---
>>  scripts/logger.sh | 13 -
>>  1 file changed, 12 insertions(+), 1 deletion(-)
>>
>> diff --git a/scripts/logger.sh b/scripts/logger.sh
>> index 8123f0c9f6e3..8412b0ba9a08 100755
>> --- a/scripts/logger.sh
>> +++ b/scripts/logger.sh
>> @@ -6,6 +6,17 @@ now() {
>>
>>  label=${1:+ [$1]}
>>
>> +TRACE_MARKER=/sys/kernel/debug/tracing/trace_marker
>> +if [ -e $TRACE_MARKER ]; then
>> +extra_log_files=$TRACE_MARKER
>> +fi
>> +
>>  while read line ; do
>> -echo "$(now)$label $line"
>> +newline="$(now)$label $line"
>> +
>> +echo "$newline"
>> +
>> +for f in $extra_log_files; do
>> +echo "$newline" >> $f;
> 
> As the tracer adds a timestamp, should you echo "$label $line" only here ?

Hrm, yes it is possibly a little bit redundant...

My only argument would be that it will be a 'different' timestamp to the
one logged by logger.sh.

Inspection of a recent log shows a difference of around 40-50 ms, which
will be the latency between capturing the time in $(now) and passing the
buffer to the kernel.

At this level though, the logger.sh is already susceptible to scheduler
jitter anyway, so I'm not too worried about 40 ms. But anyone reading
the logs will have to be aware of that extra latency.


> 
>> +done;
>>  done
> 


Re: [PATCH 5/5] tests: Test suspend/resume on active pipelines

2016-11-25 Thread Kieran Bingham
Hi Laurent,

On 25/11/16 17:10, Laurent Pinchart wrote:
> Hi Kieran,
> 
> Thank you for the patch.
> 
> On Friday 25 Nov 2016 13:59:16 Kieran Bingham wrote:
>> From: Kieran Bingham <kieran.bing...@ideasonboard.com>
>>
>> Provide a test to verify the hardware completes a functional test whilst
>> performing a suspend resume cycle in parallel. Make use of the
>> /sys/power/pm_test functionality provided by CONFIG_PM_DEBUG to perform
>> the testing
>>
>> Signed-off-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
>> ---
>>  tests/vsp-unit-test-0020.sh | 86 ++
>>  1 file changed, 86 insertions(+)
>>  create mode 100755 tests/vsp-unit-test-0020.sh
>>
>> diff --git a/tests/vsp-unit-test-0020.sh b/tests/vsp-unit-test-0020.sh
>> new file mode 100755
>> index ..5838295139b2
>> --- /dev/null
>> +++ b/tests/vsp-unit-test-0020.sh
>> @@ -0,0 +1,86 @@
>> +#!/bin/sh
>> +
>> +#
>> +# Test power-management suspend/resume whilst pipelines are active
>> +#
>> +# Utilise the basic RPF->WPF packing test case as a measure that the
>> hardware
>> +# is operable while we perform test suspend and resume, and verify that it
>> is
>> +# still successful even with a suspend resume cycle in the middle of the
>> test.
>> +#
>> +# Format iteration loops are maintained, even with only one format so that
>> this
>> +# test can be easily extended to try further formats if needed in the
>> future.
>> +#
> 
> Given that this test will suspend during the first iteration only I don't 
> think it's very useful to keep the loop.
> 

Agreed. Can you tell this test started it's life as
vsp-unit-test-0019.sh ? :D

>> +
>> +source vsp-lib.sh
>> +
>> +features="rpf.0 wpf.0"
>> +formats="RGB24"
>> +
>> +# These can be extracted from /sys/power/pm_test
>> +suspend_modes="freezer devices platform processors core"
> 
> How about extracting them from that file then ? :-) Or maybe just verifying 
> they are available before trying to use them ?

I thought about that - and looked at it.

Annoyingly - /sys/power/pm_test contains none which would need to be
filtered out, and also the active mode is surrounded by square brackets,
which would also need filtering.

# cat /sys/power/pm_test
none core processors platform [devices] freezer

They are also in the reverse order of that which I wanted the tests to run.

All solvable, but I hadn't bothered as I thought it was possibly
overkill. Of course extracting automatically does future proof us
against different modes and changing mode-names - so it does sound like
a valuable thing to do.

>> +# This extended function performs the same
>> +# as it's non-extended name-sake - but runs the pipeline
>> +# for 300 frames. The suspend action occurs between frame #150~#200
>> +test_extended_wpf_packing() {
>> +test_start "Verify WPF packing in $format during suspend:$mode"
>> +
>> +pipe_configure rpf-wpf 0 0
>> +format_configure rpf-wpf 0 0 ARGB32 1024x768 $format
>> +
>> +vsp_runner rpf.0 --count=300 &
>> +vsp_runner wpf.0 --count=300 --skip=297
>> +
>> +local result=$(compare_frames)
>> +
>> +test_complete $result
>> +}
>> +
>> +test_hw_pipe() {
>> +local format
>> +
>> +for format in $formats ; do
>> +test_extended_wpf_packing $format
>> +done
>> +}
>> +
>> +test_suspend_resume() {
>> +local test_results=0
> 
> This variable doesn't seem to be used.
> 

Another left over from when I was experimenting to get the return values
before I was blocked by $(compare_frames) returning a string.


>> +local test_pid
>> +
>> +# Test the hardware each side of suspend resume
>> +test_hw_pipe &
>> +test_pid=$!
>> +
>> +# Make sure the pipeline has time to start
>> +sleep 1
>> +
>> +# Set the test mode
>> +echo $mode > /sys/power/pm_test
>> +
>> +# Comence suspend
> 
> Commence ?

Yes
Where can I get a terminal emulator with spell-check highlighting :D

> 
>> +# The pm_test framework will automatically resume after 5 seconds
>> +echo mem > /sys/power/state
>> +
>> +# Wait for the pipeline to complete
>> +wait $test_pid
> 
> It would be nice to add a timeout here. Maybe something like the following 
> (untested) ?
> 
>   (sleep 30 ; kill $test_pid) &
>   kill_pid=$!
>   wait $test_pid
>  

Re: [PATCH 1/5] scripts: Test suite runner

2016-11-25 Thread Kieran Bingham
On 25/11/16 18:21, Laurent Pinchart wrote:
> Hi Kieran,
> 
> Thank you for the patch.
> 
> On Friday 25 Nov 2016 13:59:12 Kieran Bingham wrote:
>> From: Kieran Bingham <kie...@bingham.xyz>
>>
>> Provide a utility script to execute all vsp unit tests, as well
>> as the option to execute multiple iterations of the suite.
>>
>> Signed-off-by: Kieran Bingham <kie...@bingham.xyz>
>> ---
>>  scripts/vsp-tests.sh | 46 ++
>>  1 file changed, 46 insertions(+)
>>  create mode 100755 scripts/vsp-tests.sh
>>
>> diff --git a/scripts/vsp-tests.sh b/scripts/vsp-tests.sh
>> new file mode 100755
>> index ..e5ffa0ec4236
>> --- /dev/null
>> +++ b/scripts/vsp-tests.sh
>> @@ -0,0 +1,46 @@
>> +#!/bin/sh
>> +
>> +##
>> +## VSP Tests runner
>> +##
>> +## Automatically execute all vsp-unit tests
>> +## Move test failure results to a specific folder for
>> +## the running kernel version
>> +##
>> +## An argument can be provided to specify the number of
>> +## iterations to perform
>> +##
>> +## usage:
>> +##  ./vsp-tests.sh 
>> +##
>> +##   n: Number of iterations to execute test suite
>> +##
>> +
>> +KERNEL_VERSION=`uname -r`
>> +
>> +run_test() {
>> +echo $1
>> +./$1
>> +
>> +if [ $(ls *.bin 2>/dev/null | wc -l) != 0 ];
>> +then
>> +RESULTS_DIR=$KERNEL_VERSION/test-$1/$2/
>> +
>> +echo "Moving *.bin to test-$1/$2/";
> 
> You can remove the ; at the end of the lines.
> 
>> +mkdir -p $RESULTS_DIR;
>> +echo "mv *.bin $RESULTS_DIR";
> 
> Do we really need this message ?

We certainly don't need two :D.

I'll combine the best bits of them both :D
echo "Moving test failures to $RESULTS_DIR";

And in fact, now that bin2png.sh works on the target - this could also
generate the PNG files immediately which would be useful.

>> +mv *.bin $RESULTS_DIR;
>> +fi;
>> +}
>> +
>> +run_suite() {
>> +echo "Test loop $1"
>> +
>> +for test in vsp-unit-test*.sh; do
>> +run_test $test $1;
>> +done;
>> +}
>> +
>> +for loop in `seq 1 1 $1`; do
>> +run_suite $loop
>> +done;
> 

-- 
Regards

Kieran Bingham


Re: [PATCH] v4l: vsp1: Prevent commencing pipelines before they are setup

2016-11-23 Thread Kieran Bingham
Just FYI,

Whilst this patch is functional on its own, it is likely to be
superseded before it gets a chance to be integrated as I am currently
reworking vsp1_video_start_streaming(), in particular the use of
vsp1_video_setup_pipeline().

The re-work will of course also consider and tackle the issue repaired here.

--
Regards

Kieran

On 11/11/16 10:31, Kieran Bingham wrote:
> With multiple inputs through the BRU it is feasible for the streams to
> race each other at stream-on. In the case of the video pipelines, this
> can present two serious issues.
> 
>  1) A null-dereference if the pipe->dl is committed at the same time as
> the vsp1_video_setup_pipeline() is processing
> 
>  2) A hardware hang, where a display list is committed without having
> called vsp1_video_setup_pipeline() first.
> 
> To prevent these scenarios from occurring, we ensure that only the thread
> that calls the vsp1_video_setup_pipeline() is capable of committing and
> commencing the display list.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham+rene...@ideasonboard.com>
> ---
> 
> I considered a few options to fix this issue. If anyone disagrees with my
> reasoning, and believes one of the below approaches should be used, let me
> know and I'll rework the patch.
> 
>  A) Moving the vsp1_video_pipeline_run() call into the upper if block.
>   - This changes the locking, and brings in unneccessary nested locking
> 
>  B) Adapting vsp1_pipeline_ready() such that it checks for a configured
> pipeline event as well.
> 
>   - This was tempting - but this particular issue is local to this
> function only. Changing vsp1_pipeline_ready() to watch for a flag
> set by vsp1_video_setup_pipeline() would require adding unneccessary
> changes to the vsp1_drm objects to cater for this.
> 
> To test this race, I have used the vsp-unit-test-0007.sh from Laurent's
> VSP-Tests [0] in iteration. Without this patch, failures can be seen be
> seen anywhere up to the 150 iterations mark.
> 
> With this patch in place, tests have successfully iterated over 1500
> loops.
> 
> The function affected by this change appears to have been around since
> v4.6-rc2-105-g351bbf99f245 and thus may want inclusion in stable trees
> from that point forward. The issue may have been prevalent before that
> but the solution would need reworking for earlier version.
> 
> [0] http://git.ideasonboard.com/renesas/vsp-tests.git
> 
>  drivers/media/platform/vsp1/vsp1_video.c | 10 +-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/vsp1/vsp1_video.c 
> b/drivers/media/platform/vsp1/vsp1_video.c
> index 94b428596c4f..cc44b27f3e47 100644
> --- a/drivers/media/platform/vsp1/vsp1_video.c
> +++ b/drivers/media/platform/vsp1/vsp1_video.c
> @@ -813,6 +813,7 @@ static int vsp1_video_start_streaming(struct vb2_queue 
> *vq, unsigned int count)
>   struct vsp1_video *video = vb2_get_drv_priv(vq);
>   struct vsp1_pipeline *pipe = video->rwpf->pipe;
>   unsigned long flags;
> + bool configured = false;
>   int ret;
>  
>   mutex_lock(>lock);
> @@ -822,13 +823,20 @@ static int vsp1_video_start_streaming(struct vb2_queue 
> *vq, unsigned int count)
>   mutex_unlock(>lock);
>   return ret;
>   }
> +
> + /*
> +  * Multiple streams will execute this function in parallel.
> +  * Only the thread which configures the pipeline is allowed to
> +  * execute the vsp1_video_pipeline_run() call below
> +  */
> + configured = true;
>   }
>  
>   pipe->stream_count++;
>   mutex_unlock(>lock);
>  
>   spin_lock_irqsave(>irqlock, flags);
> - if (vsp1_pipeline_ready(pipe))
> + if (vsp1_pipeline_ready(pipe) && configured)
>   vsp1_video_pipeline_run(pipe);
>   spin_unlock_irqrestore(>irqlock, flags);
>  
> 


[PATCH 0/5] VSP-Tests: Add suspend resume tests and helpers

2016-11-25 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

Provide two tests for suspend/resume cycles. One will verify the VSP1 is
functional with a test before and after a suspend cycle. The other will
maintain an active pipeline which must succeed despite a suspend resume cycle
occuring in the middle of the test.

Along side these tests are a couple of helpers that I have locally and thought
they might be useful to others, so I'm posting for review. A test suite runner
simplifies executing all vsp-unit tests, and provides the ability to easily
repeat the test suite (for example to run an overnight longevity test).

'bin2png.sh' is a wrapper around the existing tools that helps convert the test
files generated by VSP-Tests into png files for easy viewing.

Finally, I have extended 'logger.sh' to also log to the FTrace buffer. As I have
been making greater use of ftrace for register write capture, and driver flow -
this addition helps separate multiple tests from the ftrace kernelshark view.

Kieran Bingham (5):
  scripts: Test suite runner
  scripts: Provide bin2png.sh helper
  logger: Log to the FTrace buffer if tracing is enabled
  tests: Test suspend/resume on idle pipelines
  tests: Test suspend/resume on active pipelines

 scripts/Makefile|  2 +-
 scripts/bin2png.sh  | 34 
 scripts/logger.sh   | 13 ++-
 scripts/vsp-tests.sh| 46 ++
 tests/vsp-unit-test-0019.sh | 84 
 tests/vsp-unit-test-0020.sh | 94 +
 6 files changed, 271 insertions(+), 2 deletions(-)
 create mode 100755 scripts/bin2png.sh
 create mode 100755 scripts/vsp-tests.sh
 create mode 100755 tests/vsp-unit-test-0019.sh
 create mode 100755 tests/vsp-unit-test-0020.sh

-- 
2.7.4



[GIT PULL FOR renesas-drivers] VSP Writeback prototype

2016-11-14 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

Hi Geert,

The following changes since commit 8bc55e5947b58dee3c8b126d7c303991ae0db130:

  tty: serial_core: Fix serial console crash on port shutdown (2016-10-25 
13:53:49 +0200)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kbingham/rcar.git 
tags/vsp1/writeback/v2

for you to fetch changes up to 7ce3d143d5c287e5786b3471c32112363bcbdca2:

  v4l: vsp1: Provide a writeback video device (2016-11-03 10:34:29 +)

This implementation of a writeback video node allows frames to be
captured from the display pipeline using standard V4L2 calls.

----
Kieran Bingham (2):
  Revert "[media] v4l: vsp1: Supply frames to the DU continuously"
  v4l: vsp1: Provide a writeback video device

 drivers/media/platform/vsp1/vsp1.h   |   1 +
 drivers/media/platform/vsp1/vsp1_drm.c   |  19 
 drivers/media/platform/vsp1/vsp1_drv.c   |   5 +-
 drivers/media/platform/vsp1/vsp1_rwpf.h  |   1 +
 drivers/media/platform/vsp1/vsp1_video.c | 161 ---
 drivers/media/platform/vsp1/vsp1_video.h |   5 +
 drivers/media/platform/vsp1/vsp1_wpf.c   |  19 +++-
 7 files changed, 193 insertions(+), 18 deletions(-)


[GIT PULL FOR renesas-drivers] VSP Partition algorithm improvements

2016-11-14 Thread Kieran Bingham
From: Kieran Bingham <kieran.bing...@ideasonboard.com>

Hi Geert,

The following changes since commit 8bc55e5947b58dee3c8b126d7c303991ae0db130:

  tty: serial_core: Fix serial console crash on port shutdown (2016-10-25 
13:53:49 +0200)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kbingham/rcar.git 
tags/vsp1/pa-improvements/v1

for you to fetch changes up to 97ec8cd22aae933399b84b1a84eedcc48ad35eb8:

  v4l: vsp1: Remove redundant context variables (2016-11-14 18:49:57 +)

This tag contains some improvements to the performance of the partition
algorithm by moving the calculations to the stream on calls, instead of
calculating each partition in every frame during interrupt context.

----
Kieran Bingham (4):
  v4l: vsp1: Implement partition algorithm restrictions
  v4l: vsp1: Move vsp1_video_pipeline_setup_partitions() function
  v4l: vsp1: Calculate partition sizes at stream start.
  v4l: vsp1: Remove redundant context variables

 drivers/media/platform/vsp1/vsp1_pipe.h  |  10 ++-
 drivers/media/platform/vsp1/vsp1_sru.c   |   7 +-
 drivers/media/platform/vsp1/vsp1_sru.h   |   1 +
 drivers/media/platform/vsp1/vsp1_video.c | 124 +++
 4 files changed, 89 insertions(+), 53 deletions(-)


Re: [RFC 3/3] v4l: vsp1: Provide a writeback video device

2016-11-01 Thread Kieran Bingham
Looks like I forgot to run checkpatch here, and it picked up a few things.

Please disregard them in your review, and they will be fixed for next
version.


On 27/10/16 15:01, Kieran Bingham wrote:
> When the VSP1 is used in an active display pipeline, the output of the
> WPF can supply the LIF entity directly and simultaneously write to
> memory.
> 
> Support this functionality in the VSP1 driver, by extending the WPF
> source pads, and establishing a V4L2 video device node connected to the
> new source.
> 
> The source will be able to perform pixel format conversion, but not
> rescaling, and as such the output from the memory node will always be
> of the same dimensions as the display output.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham+rene...@ideasonboard.com>
> ---
>  drivers/media/platform/vsp1/vsp1.h   |   1 +
>  drivers/media/platform/vsp1/vsp1_drm.c   |  20 
>  drivers/media/platform/vsp1/vsp1_drv.c   |   5 +-
>  drivers/media/platform/vsp1/vsp1_rwpf.c  |  15 ++-
>  drivers/media/platform/vsp1/vsp1_rwpf.h  |   2 +
>  drivers/media/platform/vsp1/vsp1_video.c | 161 
> ++-
>  drivers/media/platform/vsp1/vsp1_video.h |   5 +
>  drivers/media/platform/vsp1/vsp1_wpf.c   |  23 -
>  8 files changed, 219 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/media/platform/vsp1/vsp1.h 
> b/drivers/media/platform/vsp1/vsp1.h
> index 85387a64179a..a2d462264312 100644
> --- a/drivers/media/platform/vsp1/vsp1.h
> +++ b/drivers/media/platform/vsp1/vsp1.h
> @@ -54,6 +54,7 @@ struct vsp1_uds;
>  #define VSP1_HAS_WPF_HFLIP   (1 << 6)
>  #define VSP1_HAS_HGO (1 << 7)
>  #define VSP1_HAS_HGT (1 << 8)
> +#define VSP1_HAS_WPF_WRITEBACK   (1 << 9)
>  
>  struct vsp1_device_info {
>   u32 version;
> diff --git a/drivers/media/platform/vsp1/vsp1_drm.c 
> b/drivers/media/platform/vsp1/vsp1_drm.c
> index 0daf5f2c06e2..446188a06a92 100644
> --- a/drivers/media/platform/vsp1/vsp1_drm.c
> +++ b/drivers/media/platform/vsp1/vsp1_drm.c
> @@ -27,6 +27,7 @@
>  #include "vsp1_lif.h"
>  #include "vsp1_pipe.h"
>  #include "vsp1_rwpf.h"
> +#include "vsp1_video.h"
>  
>  
>  /* 
> -
> @@ -479,6 +480,13 @@ void vsp1_du_atomic_flush(struct device *dev)
>   __func__, rpf->entity.index);
>   }
>  
> + /*
> +  * If we have a writeback node attached, we use this opportunity to
> +  * update the video buffers.
> +  */
> + if (pipe->output->video && pipe->output->video->frame_end)
> + pipe->output->video->frame_end(pipe);
> +
>   /* Configure all entities in the pipeline. */
>   list_for_each_entry(entity, >entities, list_pipe) {
>   /* Disconnect unused RPFs from the pipeline. */
> @@ -590,6 +598,17 @@ int vsp1_drm_create_links(struct vsp1_device *vsp1)
>   if (ret < 0)
>   return ret;
>  
> + if (!(vsp1->info->features & VSP1_HAS_WPF_WRITEBACK))
> + return 0;
> +
> + /* Connect the video device to the WPF for Writeback support */
> + ret = media_create_pad_link(>wpf[0]->entity.subdev.entity,
> + RWPF_PAD_SOURCE_WB,
> + >wpf[0]->video->video.entity,
> + 0, flags);
> + if (ret < 0)
> + return ret;
> +
>   return 0;
>  }
>  
> @@ -620,6 +639,7 @@ int vsp1_drm_init(struct vsp1_device *vsp1)
>   pipe->bru = >bru->entity;
>   pipe->lif = >lif->entity;
>   pipe->output = vsp1->wpf[0];
> + pipe->output->pipe = pipe;
>  
>   return 0;
>  }
> diff --git a/drivers/media/platform/vsp1/vsp1_drv.c 
> b/drivers/media/platform/vsp1/vsp1_drv.c
> index 3b084976094b..42fa822b38d3 100644
> --- a/drivers/media/platform/vsp1/vsp1_drv.c
> +++ b/drivers/media/platform/vsp1/vsp1_drv.c
> @@ -408,7 +408,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
>   vsp1->wpf[i] = wpf;
>   list_add_tail(>entity.list_dev, >entities);
>  
> - if (vsp1->info->uapi) {
> + if (vsp1->info->uapi || wpf->has_writeback) {
>   struct vsp1_video *video = vsp1_video_create(vsp1, wpf);
>  
>   if (IS_ERR(video)) {
> @@ -705,7 +705,8 @@ static const struct vsp1_device_info vsp1_device_infos[] 
> = {
>   .version = VI6_IP_VERSION_MODEL_VSPD_GEN3,
>   .m

[PATCHv2] v4l: vsp1: Provide a writeback video device

2016-11-03 Thread Kieran Bingham
When the VSP1 is used in an active display pipeline, the output of the
WPF can supply the LIF entity directly and simultaneously write to
memory.

Support this functionality in the VSP1 driver, by extending the WPF
source pads, and establishing a V4L2 video device node connected to the
new source.

The source will be able to perform pixel format conversion, but not
rescaling, and as such the output from the memory node will always be
of the same dimensions as the display output.

Signed-off-by: Kieran Bingham <kieran.bingham+rene...@ideasonboard.com>
---

With the patch "[media] v4l: vsp1: Supply frames to the DU continuously"
reverted, and the other patch from the previous series dropped - this
submission is down to a single patch to implement the writeback device.

This current version limits the output of the video node to match the frames
presented by updates from the CRTC atomic flush events.

The output from the device node can be tested by generating frames on the DRM
pipeline and capturing with yavta:

Terminal 1:
 # kmstest --flip --sync

Terminal 2:
 # yavta -c60 -n8 -f RGB24 -s1024x768 \
--file=frame-rgb24-1024x768-#.bin /dev/$VIDEO

$VIDEO must be determined for your platform and represents the WPF Video node

Changes since RFC
 - Fix checkpatch.pl warnings
 - Adapt to use a single source pad for the Writeback and LIF
 - Use WPF properties to determine when to create links instead of VSP
 - Remove incorrect vsp1_video_verify_format() changes
 - Spelling and grammar fixes

 drivers/media/platform/vsp1/vsp1.h   |   1 +
 drivers/media/platform/vsp1/vsp1_drm.c   |  19 
 drivers/media/platform/vsp1/vsp1_drv.c   |   5 +-
 drivers/media/platform/vsp1/vsp1_rwpf.h  |   1 +
 drivers/media/platform/vsp1/vsp1_video.c | 150 ++-
 drivers/media/platform/vsp1/vsp1_video.h |   5 ++
 drivers/media/platform/vsp1/vsp1_wpf.c   |  19 +++-
 7 files changed, 193 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1.h 
b/drivers/media/platform/vsp1/vsp1.h
index 85387a64179a..a2d462264312 100644
--- a/drivers/media/platform/vsp1/vsp1.h
+++ b/drivers/media/platform/vsp1/vsp1.h
@@ -54,6 +54,7 @@ struct vsp1_uds;
 #define VSP1_HAS_WPF_HFLIP (1 << 6)
 #define VSP1_HAS_HGO   (1 << 7)
 #define VSP1_HAS_HGT   (1 << 8)
+#define VSP1_HAS_WPF_WRITEBACK (1 << 9)
 
 struct vsp1_device_info {
u32 version;
diff --git a/drivers/media/platform/vsp1/vsp1_drm.c 
b/drivers/media/platform/vsp1/vsp1_drm.c
index 0daf5f2c06e2..9bb7c1a04157 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -27,6 +27,7 @@
 #include "vsp1_lif.h"
 #include "vsp1_pipe.h"
 #include "vsp1_rwpf.h"
+#include "vsp1_video.h"
 
 
 /* 
-
@@ -479,6 +480,13 @@ void vsp1_du_atomic_flush(struct device *dev)
__func__, rpf->entity.index);
}
 
+   /*
+* If we have a writeback node attached, we use this opportunity to
+* update the video buffers.
+*/
+   if (pipe->output->video && pipe->output->video->frame_end)
+   pipe->output->video->frame_end(pipe);
+
/* Configure all entities in the pipeline. */
list_for_each_entry(entity, >entities, list_pipe) {
/* Disconnect unused RPFs from the pipeline. */
@@ -590,6 +598,16 @@ int vsp1_drm_create_links(struct vsp1_device *vsp1)
if (ret < 0)
return ret;
 
+   if (vsp1->wpf[0]->has_writeback) {
+   /* Connect the video device to the WPF for Writeback support */
+   ret = media_create_pad_link(>wpf[0]->entity.subdev.entity,
+   RWPF_PAD_SOURCE,
+   >wpf[0]->video->video.entity,
+   0, flags);
+   if (ret < 0)
+   return ret;
+   }
+
return 0;
 }
 
@@ -620,6 +638,7 @@ int vsp1_drm_init(struct vsp1_device *vsp1)
pipe->bru = >bru->entity;
pipe->lif = >lif->entity;
pipe->output = vsp1->wpf[0];
+   pipe->output->pipe = pipe;
 
return 0;
 }
diff --git a/drivers/media/platform/vsp1/vsp1_drv.c 
b/drivers/media/platform/vsp1/vsp1_drv.c
index 3b084976094b..42fa822b38d3 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -408,7 +408,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
vsp1->wpf[i] = wpf;
list_add_tail(>entity.list_dev, >entities);
 
-   if (vsp1->info->uapi) {
+   if (vsp1->info->uapi || wpf->has_writeback) {
struct vsp

[RFC 0/3] vsp1 writeback prototype

2016-10-27 Thread Kieran Bingham
This series presents an initial version of a write back video node for the VSP
DRM pipeline, utilising the existing vsp1_video base where possible.

The current version limits the output of the video node to match the frames
presented by updates from the CRTC atomic flush events. Matching the output rate
against the vsync/display rate has proven more difficult and I wanted to get
this out for review early.

This series is based on renesas-drivers-2016-10-25-v4.9-rc2, and has been
tested on a Salvator-H3. An updated/recent firmware is essential on this target
otherwise WPF underruns will occur.

This output can be tested with kmstest to generate frames and yavta to capture:

Terminal 1:
 # kmstest --flip --sync

Terminal 2:
 # yavta -c60 -n8 -f RGB24 -s1024x768 \
--file=frame-rgb24-1024x768-#.bin /dev/$VIDEO

$VIDEO must be determined for your platform and represents the WPF Video node
from the VSP-D. On Salvator-H3, on renesas-drivers-2016-10-25-v4.9-rc2 this is
active at /dev/video28

Kieran Bingham (3):
  Revert "[media] v4l: vsp1: Supply frames to the DU continuously"
  v4l: vsp1: allow entities to have multiple source pads
  v4l: vsp1: Provide a writeback video device

 drivers/media/platform/vsp1/vsp1.h|   1 +
 drivers/media/platform/vsp1/vsp1_bru.c|   2 +-
 drivers/media/platform/vsp1/vsp1_clu.c|   2 +-
 drivers/media/platform/vsp1/vsp1_drm.c|  20 
 drivers/media/platform/vsp1/vsp1_drv.c|   5 +-
 drivers/media/platform/vsp1/vsp1_entity.c |  15 +--
 drivers/media/platform/vsp1/vsp1_entity.h |   3 +-
 drivers/media/platform/vsp1/vsp1_histo.c  |   2 +-
 drivers/media/platform/vsp1/vsp1_hsit.c   |   2 +-
 drivers/media/platform/vsp1/vsp1_lif.c|   2 +-
 drivers/media/platform/vsp1/vsp1_lut.c|   2 +-
 drivers/media/platform/vsp1/vsp1_rpf.c|   2 +-
 drivers/media/platform/vsp1/vsp1_rwpf.c   |  15 ++-
 drivers/media/platform/vsp1/vsp1_rwpf.h   |   2 +
 drivers/media/platform/vsp1/vsp1_sru.c|   2 +-
 drivers/media/platform/vsp1/vsp1_uds.c|   2 +-
 drivers/media/platform/vsp1/vsp1_video.c  | 172 +++---
 drivers/media/platform/vsp1/vsp1_video.h  |   5 +
 drivers/media/platform/vsp1/vsp1_wpf.c|  23 +++-
 19 files changed, 238 insertions(+), 41 deletions(-)

-- 
2.7.4



[RFC 1/3] Revert "[media] v4l: vsp1: Supply frames to the DU continuously"

2016-10-27 Thread Kieran Bingham
This reverts commit 3299ba5c0b213be5d911752d40251c1abc1004f7.

The DU output mode does not rely on frames being supplied on the WPF as
its pipeline is supplied from DRM. For the upcoming WPF writeback
functionality, we will choose to enable writeback mode if there is an
output buffer, or disable it (leaving the existing display pipeline
unharmed) otherwise.

Signed-off-by: Kieran Bingham <kieran.bingham+rene...@ideasonboard.com>
---
 drivers/media/platform/vsp1/vsp1_video.c | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_video.c 
b/drivers/media/platform/vsp1/vsp1_video.c
index 94b428596c4f..f10401065cd3 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -296,11 +296,6 @@ static struct v4l2_rect vsp1_video_partition(struct 
vsp1_pipeline *pipe,
  * This function completes the current buffer by filling its sequence number,
  * time stamp and payload size, and hands it back to the videobuf core.
  *
- * When operating in DU output mode (deep pipeline to the DU through the LIF),
- * the VSP1 needs to constantly supply frames to the display. In that case, if
- * no other buffer is queued, reuse the one that has just been processed 
instead
- * of handing it back to the videobuf core.
- *
  * Return the next queued buffer or NULL if the queue is empty.
  */
 static struct vsp1_vb2_buffer *
@@ -322,12 +317,6 @@ vsp1_video_complete_buffer(struct vsp1_video *video)
done = list_first_entry(>irqqueue,
struct vsp1_vb2_buffer, queue);
 
-   /* In DU output mode reuse the buffer if the list is singular. */
-   if (pipe->lif && list_is_singular(>irqqueue)) {
-   spin_unlock_irqrestore(>irqlock, flags);
-   return done;
-   }
-
list_del(>queue);
 
if (!list_empty(>irqqueue))
-- 
2.7.4



[RFC 2/3] v4l: vsp1: allow entities to have multiple source pads

2016-10-27 Thread Kieran Bingham
The upcoming writeback feature of the VSP1 WPF, allows the active output
of the DU to be written back to memory. On Generation 3 hardware, the DU
is fed by the LIF, which is in turn fed by the WPF.

It is the WPF which will perform memory writeback functionality, and
this brings in a second output of the entity. Configured in this mode,
the WPF will output to both the LIF, and to a memory (V4L2 video)
device.

Support this feature by extending vsp1_entity_init() to specify the
number of source and sink pads.

Signed-off-by: Kieran Bingham <kieran.bingham+rene...@ideasonboard.com>
---
 drivers/media/platform/vsp1/vsp1_bru.c|  2 +-
 drivers/media/platform/vsp1/vsp1_clu.c|  2 +-
 drivers/media/platform/vsp1/vsp1_entity.c | 15 ---
 drivers/media/platform/vsp1/vsp1_entity.h |  3 ++-
 drivers/media/platform/vsp1/vsp1_histo.c  |  2 +-
 drivers/media/platform/vsp1/vsp1_hsit.c   |  2 +-
 drivers/media/platform/vsp1/vsp1_lif.c|  2 +-
 drivers/media/platform/vsp1/vsp1_lut.c|  2 +-
 drivers/media/platform/vsp1/vsp1_rpf.c|  2 +-
 drivers/media/platform/vsp1/vsp1_sru.c|  2 +-
 drivers/media/platform/vsp1/vsp1_uds.c|  2 +-
 drivers/media/platform/vsp1/vsp1_wpf.c|  2 +-
 12 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_bru.c 
b/drivers/media/platform/vsp1/vsp1_bru.c
index ee8355c28f94..796bcc77eb44 100644
--- a/drivers/media/platform/vsp1/vsp1_bru.c
+++ b/drivers/media/platform/vsp1/vsp1_bru.c
@@ -411,7 +411,7 @@ struct vsp1_bru *vsp1_bru_create(struct vsp1_device *vsp1)
bru->entity.type = VSP1_ENTITY_BRU;
 
ret = vsp1_entity_init(vsp1, >entity, "bru",
-  vsp1->info->num_bru_inputs + 1, _ops,
+  vsp1->info->num_bru_inputs, 1, _ops,
   MEDIA_ENT_F_PROC_VIDEO_COMPOSER);
if (ret < 0)
return ERR_PTR(ret);
diff --git a/drivers/media/platform/vsp1/vsp1_clu.c 
b/drivers/media/platform/vsp1/vsp1_clu.c
index f2fb26e5ab4e..b38692b1f0dd 100644
--- a/drivers/media/platform/vsp1/vsp1_clu.c
+++ b/drivers/media/platform/vsp1/vsp1_clu.c
@@ -283,7 +283,7 @@ struct vsp1_clu *vsp1_clu_create(struct vsp1_device *vsp1)
clu->entity.ops = _entity_ops;
clu->entity.type = VSP1_ENTITY_CLU;
 
-   ret = vsp1_entity_init(vsp1, >entity, "clu", 2, _ops,
+   ret = vsp1_entity_init(vsp1, >entity, "clu", 1, 1, _ops,
   MEDIA_ENT_F_PROC_VIDEO_LUT);
if (ret < 0)
return ERR_PTR(ret);
diff --git a/drivers/media/platform/vsp1/vsp1_entity.c 
b/drivers/media/platform/vsp1/vsp1_entity.c
index 5263387f7ec7..72c99de6e3a4 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.c
+++ b/drivers/media/platform/vsp1/vsp1_entity.c
@@ -472,11 +472,13 @@ static const struct vsp1_route vsp1_routes[] = {
 };
 
 int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
-const char *name, unsigned int num_pads,
+const char *name, unsigned int num_sink_pads,
+unsigned int num_source_pads,
 const struct v4l2_subdev_ops *ops, u32 function)
 {
struct v4l2_subdev *subdev;
unsigned int i;
+   unsigned int num_pads = num_sink_pads + num_source_pads;
int ret;
 
for (i = 0; i < ARRAY_SIZE(vsp1_routes); ++i) {
@@ -501,18 +503,17 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct 
vsp1_entity *entity,
if (entity->pads == NULL)
return -ENOMEM;
 
-   for (i = 0; i < num_pads - 1; ++i)
+   for (i = 0; i < num_sink_pads; ++i)
entity->pads[i].flags = MEDIA_PAD_FL_SINK;
 
-   entity->sources = devm_kcalloc(vsp1->dev, max(num_pads - 1, 1U),
+   for (; i < num_pads; ++i)
+   entity->pads[i].flags = MEDIA_PAD_FL_SOURCE;
+
+   entity->sources = devm_kcalloc(vsp1->dev, num_source_pads,
   sizeof(*entity->sources), GFP_KERNEL);
if (entity->sources == NULL)
return -ENOMEM;
 
-   /* Single-pad entities only have a sink. */
-   entity->pads[num_pads - 1].flags = num_pads > 1 ? MEDIA_PAD_FL_SOURCE
-: MEDIA_PAD_FL_SINK;
-
/* Initialize the media entity. */
ret = media_entity_pads_init(>subdev.entity, num_pads,
 entity->pads);
diff --git a/drivers/media/platform/vsp1/vsp1_entity.h 
b/drivers/media/platform/vsp1/vsp1_entity.h
index c169a060b6d2..c709c29eb994 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.h
+++ b/drivers/media/platform/vsp1/vsp1_entity.h
@@ -120,7 +120,8 @@ static inline struct vsp1_entity *to_vsp1_entity(struct 
v4l2_subdev *subdev)
 }
 
 int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity

[PATCHv2 2/2] v4l: vsp1: Provide a writeback video device

2016-11-04 Thread Kieran Bingham
When the VSP1 is used in an active display pipeline, the output of the
WPF can supply the LIF entity directly and simultaneously write to
memory.

Support this functionality in the VSP1 driver, by extending the WPF
source pads, and establishing a V4L2 video device node connected to the
new source.

The source will be able to perform pixel format conversion, but not
rescaling, and as such the output from the memory node will always be
of the same dimensions as the display output.

Signed-off-by: Kieran Bingham <kieran.bingham+rene...@ideasonboard.com>

---
Changes since RFC
 - Fix checkpatch.pl warnings
 - Adapt to use a single source pad for the Writeback and LIF
 - Use WPF properties to determine when to create links instead of VSP
 - Remove incorrect vsp1_video_verify_format() changes
 - Spelling and grammar fixes
---
 drivers/media/platform/vsp1/vsp1.h   |   1 +
 drivers/media/platform/vsp1/vsp1_drm.c   |  19 
 drivers/media/platform/vsp1/vsp1_drv.c   |   5 +-
 drivers/media/platform/vsp1/vsp1_rwpf.h  |   1 +
 drivers/media/platform/vsp1/vsp1_video.c | 150 ++-
 drivers/media/platform/vsp1/vsp1_video.h |   5 ++
 drivers/media/platform/vsp1/vsp1_wpf.c   |  19 +++-
 7 files changed, 193 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1.h 
b/drivers/media/platform/vsp1/vsp1.h
index 85387a64179a..a2d462264312 100644
--- a/drivers/media/platform/vsp1/vsp1.h
+++ b/drivers/media/platform/vsp1/vsp1.h
@@ -54,6 +54,7 @@ struct vsp1_uds;
 #define VSP1_HAS_WPF_HFLIP (1 << 6)
 #define VSP1_HAS_HGO   (1 << 7)
 #define VSP1_HAS_HGT   (1 << 8)
+#define VSP1_HAS_WPF_WRITEBACK (1 << 9)
 
 struct vsp1_device_info {
u32 version;
diff --git a/drivers/media/platform/vsp1/vsp1_drm.c 
b/drivers/media/platform/vsp1/vsp1_drm.c
index 0daf5f2c06e2..9bb7c1a04157 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -27,6 +27,7 @@
 #include "vsp1_lif.h"
 #include "vsp1_pipe.h"
 #include "vsp1_rwpf.h"
+#include "vsp1_video.h"
 
 
 /* 
-
@@ -479,6 +480,13 @@ void vsp1_du_atomic_flush(struct device *dev)
__func__, rpf->entity.index);
}
 
+   /*
+* If we have a writeback node attached, we use this opportunity to
+* update the video buffers.
+*/
+   if (pipe->output->video && pipe->output->video->frame_end)
+   pipe->output->video->frame_end(pipe);
+
/* Configure all entities in the pipeline. */
list_for_each_entry(entity, >entities, list_pipe) {
/* Disconnect unused RPFs from the pipeline. */
@@ -590,6 +598,16 @@ int vsp1_drm_create_links(struct vsp1_device *vsp1)
if (ret < 0)
return ret;
 
+   if (vsp1->wpf[0]->has_writeback) {
+   /* Connect the video device to the WPF for Writeback support */
+   ret = media_create_pad_link(>wpf[0]->entity.subdev.entity,
+   RWPF_PAD_SOURCE,
+   >wpf[0]->video->video.entity,
+   0, flags);
+   if (ret < 0)
+   return ret;
+   }
+
return 0;
 }
 
@@ -620,6 +638,7 @@ int vsp1_drm_init(struct vsp1_device *vsp1)
pipe->bru = >bru->entity;
pipe->lif = >lif->entity;
pipe->output = vsp1->wpf[0];
+   pipe->output->pipe = pipe;
 
return 0;
 }
diff --git a/drivers/media/platform/vsp1/vsp1_drv.c 
b/drivers/media/platform/vsp1/vsp1_drv.c
index 3b084976094b..42fa822b38d3 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -408,7 +408,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
vsp1->wpf[i] = wpf;
list_add_tail(>entity.list_dev, >entities);
 
-   if (vsp1->info->uapi) {
+   if (vsp1->info->uapi || wpf->has_writeback) {
struct vsp1_video *video = vsp1_video_create(vsp1, wpf);
 
if (IS_ERR(video)) {
@@ -705,7 +705,8 @@ static const struct vsp1_device_info vsp1_device_infos[] = {
.version = VI6_IP_VERSION_MODEL_VSPD_GEN3,
.model = "VSP2-D",
.gen = 3,
-   .features = VSP1_HAS_BRU | VSP1_HAS_LIF | VSP1_HAS_WPF_VFLIP,
+   .features = VSP1_HAS_BRU | VSP1_HAS_LIF | VSP1_HAS_WPF_VFLIP
+ | VSP1_HAS_WPF_WRITEBACK,
.rpf_count = 5,
.wpf_count = 2,
.num_bru_inputs = 5,
diff --git a/drivers/media/platform/vsp1/vsp1_rwpf.h 
b/drivers/media/platform/vsp1/vsp1_rwpf.h
index b4ffc38f

  1   2   3   4   5   6   7   8   9   >