cron job: media_tree daily build: ERRORS

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

Results of the daily build of media_tree:

date:   Tue Aug 15 05:00:15 CEST 2017
media-tree git hash:ec0c3ec497cabbf3bfa03a9eb5edcc252190a4e0
media_build git hash:   a03e89634b47f570039c7d6931cd751777d4bba1
v4l-utils git hash: 5a67da05fded64b5f678033c16196799e134c62c
gcc version:i686-linux-gcc (GCC) 7.1.0
sparse version: v0.5.0
smatch version: v0.5.0-3553-g78b2ea6
host hardware:  x86_64
host os:4.11.0-164

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

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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


Re: [PATCH] [media] staging/imx: always select VIDEOBUF2_DMA_CONTIG

2017-08-14 Thread Steve Longerbeam

Thanks,

Reviewed-by: Steve Longerbeam 

Steve

On 08/07/2017 03:49 AM, Arnd Bergmann wrote:

I ran into a rare build error during randconfig testing:

drivers/staging/media/imx/imx-media-capture.o: In function 
`capture_stop_streaming':
imx-media-capture.c:(.text+0x224): undefined reference to `vb2_buffer_done'
drivers/staging/media/imx/imx-media-capture.o: In function 
`imx_media_capture_device_register':
imx-media-capture.c:(.text+0xe60): undefined reference to `vb2_queue_init'
imx-media-capture.c:(.text+0xfa0): undefined reference to 
`vb2_dma_contig_memops'

While VIDEOBUF2_DMA_CONTIG was already selected by the camera driver,
it wasn't necessarily there with just the base driver enabled.
This moves the 'select' statement to the top-level option to make
sure it's always available.

Fixes: 64b5a49df486 ("[media] media: imx: Add Capture Device Interface")
Signed-off-by: Arnd Bergmann 
---
  drivers/staging/media/imx/Kconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/imx/Kconfig 
b/drivers/staging/media/imx/Kconfig
index 719508fcb0e9..2be921cd0d55 100644
--- a/drivers/staging/media/imx/Kconfig
+++ b/drivers/staging/media/imx/Kconfig
@@ -2,6 +2,7 @@ config VIDEO_IMX_MEDIA
tristate "i.MX5/6 V4L2 media core driver"
depends on MEDIA_CONTROLLER && VIDEO_V4L2 && ARCH_MXC && IMX_IPUV3_CORE
depends on VIDEO_V4L2_SUBDEV_API
+   select VIDEOBUF2_DMA_CONTIG
select V4L2_FWNODE
---help---
  Say yes here to enable support for video4linux media controller
@@ -13,7 +14,6 @@ menu "i.MX5/6 Media Sub devices"
  config VIDEO_IMX_CSI
tristate "i.MX5/6 Camera Sensor Interface driver"
depends on VIDEO_IMX_MEDIA && VIDEO_DEV && I2C
-   select VIDEOBUF2_DMA_CONTIG
default y
---help---
  A video4linux camera sensor interface driver for i.MX5/6.




Re: [PATCH 6/6] [media] media: imx: capture: constify vb2_ops structures

2017-08-14 Thread Steve Longerbeam

Thanks,

Reviewed-by: Steve Longerbeam 

Steve

On 08/05/2017 03:47 AM, Julia Lawall wrote:

These vb2_ops structures are only stored in the ops field of a
vb2_queue structure, which is declared as const.  Thus the vb2_ops
structures themselves can be const.

Done with the help of Coccinelle.

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct vb2_ops i@p = { ... };

@ok@
identifier r.i;
struct vb2_queue e;
position p;
@@
e.ops = @p;

@bad@
position p != {r.p,ok.p};
identifier r.i;
struct vb2_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
  struct vb2_ops i = { ... };
// 

Signed-off-by: Julia Lawall 

---
  drivers/staging/media/imx/imx-media-capture.c |4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-capture.c 
b/drivers/staging/media/imx/imx-media-capture.c
index ddab4c2..ea145ba 100644
--- a/drivers/staging/media/imx/imx-media-capture.c
+++ b/drivers/staging/media/imx/imx-media-capture.c
@@ -62,7 +62,7 @@ struct capture_priv {
  /* In bytes, per queue */
  #define VID_MEM_LIMIT SZ_64M
  
-static struct vb2_ops capture_qops;

+static const struct vb2_ops capture_qops;
  
  /*

   * Video ioctls follow
@@ -503,7 +503,7 @@ static void capture_stop_streaming(struct vb2_queue *vq)
spin_unlock_irqrestore(>q_lock, flags);
  }
  
-static struct vb2_ops capture_qops = {

+static const struct vb2_ops capture_qops = {
.queue_setup = capture_queue_setup,
.buf_init= capture_buf_init,
.buf_prepare = capture_buf_prepare,





Re: [PATCH] [media] media: imx: use setup_timer

2017-08-14 Thread Steve Longerbeam

Thanks,

Reviewed-by: Steve Longerbeam 
Tested-by: Steve Longerbeam 

Steve


On 08/13/2017 11:39 AM, Cihangir Akturk wrote:

Use setup_timer function instead of initializing timer with the
function and data fields.

Generated by: scripts/coccinelle/api/setup_timer.cocci.

Signed-off-by: Cihangir Akturk 
---
  drivers/staging/media/imx/imx-ic-prpencvf.c | 5 ++---
  drivers/staging/media/imx/imx-media-csi.c   | 5 ++---
  2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c
index ed363fe..65f5729 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -1278,9 +1278,8 @@ static int prp_init(struct imx_ic_priv *ic_priv)
priv->ic_priv = ic_priv;
  
  	spin_lock_init(>irqlock);

-   init_timer(>eof_timeout_timer);
-   priv->eof_timeout_timer.data = (unsigned long)priv;
-   priv->eof_timeout_timer.function = prp_eof_timeout;
+   setup_timer(>eof_timeout_timer, prp_eof_timeout,
+   (unsigned long)priv);
  
  	priv->vdev = imx_media_capture_device_init(_priv->sd,

   PRPENCVF_SRC_PAD);
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index a2d2669..8fef5f1 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1731,9 +1731,8 @@ static int imx_csi_probe(struct platform_device *pdev)
priv->csi_id = pdata->csi;
priv->smfc_id = (priv->csi_id == 0) ? 0 : 2;
  
-	init_timer(>eof_timeout_timer);

-   priv->eof_timeout_timer.data = (unsigned long)priv;
-   priv->eof_timeout_timer.function = csi_idmac_eof_timeout;
+   setup_timer(>eof_timeout_timer, csi_idmac_eof_timeout,
+   (unsigned long)priv);
spin_lock_init(>irqlock);
  
  	v4l2_subdev_init(>sd, _subdev_ops);




Unknown symbol errors with latest RH7 kernel using meda_build

2017-08-14 Thread Werner, Zachary
I'm new to mailing lists, so I'm sorry if this message is poorly formatted.

I have been compiling v4l on RH7 using very minor changes (made it
into an rpm, have to remove 'v3.16_wait_on_bit.patch' from the
backports) for a while now. I had been using an older set of firmware
and git hash from the media_build repo for several kernels, but the
latest kernel release had an issue loading the modules. The latest
kernel release, 3.10.0-693.el7.x86_64, builds with a few warnings
(below), but still builds successfully. After installing the new
kernel, updated rpm, and rebooting, I get the following in dmesg:

videobuf2_v4l2: Unknown symbol vb2_buffer_in_use (err 0)
videobuf2_v4l2: Unknown symbol vb2_core_queue_init (err 0)
videobuf2_v4l2: Unknown symbol vb2_verify_memory_type (err 0)
videobuf2_v4l2: Unknown symbol vb2_core_reqbufs (err 0)
videobuf2_v4l2: Unknown symbol vb2_core_expbuf (err 0)
videobuf2_v4l2: Unknown symbol vb2_core_create_bufs (err 0)
videobuf2_v4l2: disagrees about version of symbol vb2_write
videobuf2_v4l2: Unknown symbol vb2_write (err -22)
videobuf2_v4l2: Unknown symbol vb2_core_queue_release (err 0)
videobuf2_v4l2: Unknown symbol vb2_core_prepare_buf (err 0)
videobuf2_v4l2: disagrees about version of symbol vb2_read
videobuf2_v4l2: Unknown symbol vb2_read (err -22)
videobuf2_v4l2: Unknown symbol vb2_core_poll (err 0)
videobuf2_v4l2: Unknown symbol vb2_core_streamon (err 0)
videobuf2_v4l2: Unknown symbol vb2_core_querybuf (err 0)
videobuf2_v4l2: Unknown symbol vb2_core_qbuf (err 0)
videobuf2_v4l2: disagrees about version of symbol vb2_mmap
videobuf2_v4l2: Unknown symbol vb2_mmap (err -22)
videobuf2_v4l2: Unknown symbol vb2_core_dqbuf (err 0)
videobuf2_v4l2: Unknown symbol vb2_core_streamoff (err 0)

Since the videobuf2-core module loaded, I'm not sure why the symbols
are missing. If I compile and install using the latest git versions
using the rpm and locally on the box (using './build' and 'make
install'), I get the same results. I've tried looking into issues with
the symbols not being exported, but the code seems to have them there,
and considering this used to work, I'm a at a loss.

Some of the warnings on build include various files that report:

WARNING: /root/rpmbuild/BUILD/v4l/media_build/v4l/dvb-core.o
(.discard.unreachable): unexpected non-allocatable section.
Did you forget to use "ax"/"aw" in a .S file?
Note that for example  contains
section definitions for use in .S files.

After which this block comes up:

WARNING: "frame_vector_to_pages"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/videobuf2-vmalloc.ko]
undefined!
WARNING: "frame_vector_to_pfns"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/videobuf2-vmalloc.ko]
undefined!
WARNING: "dma_buf_export_named"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/videobuf2-vmalloc.ko]
undefined!
WARNING: "frame_vector_create"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/videobuf2-memops.ko]
undefined!
WARNING: "frame_vector_destroy"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/videobuf2-memops.ko]
undefined!
WARNING: "get_vaddr_frames"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/videobuf2-memops.ko]
undefined!
WARNING: "put_vaddr_frames"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/videobuf2-memops.ko]
undefined!
WARNING: "frame_vector_to_pages"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/videobuf2-dma-sg.ko]
undefined!
WARNING: "dma_buf_export_named"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/videobuf2-dma-sg.ko]
undefined!
WARNING: "frame_vector_to_pages"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/videobuf2-dma-contig.ko]
undefined!
WARNING: "frame_vector_to_pfns"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/videobuf2-dma-contig.ko]
undefined!
WARNING: "dma_buf_export_named"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/videobuf2-dma-contig.ko]
undefined!
WARNING: "v4l_vb2q_enable_media_source"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/videobuf2-core.ko]
undefined!
WARNING: "v4l2_mc_create_media_graph"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/saa7134.ko] undefined!
WARNING: "syscon_regmap_lookup_by_phandle"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/ir-hix5hd2.ko] undefined!
WARNING: "v4l2_mc_create_media_graph"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/em28xx-v4l.ko] undefined!
WARNING: "__v4l2_ctrl_s_ctrl"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/cx8800.ko] undefined!
WARNING: "__v4l2_ctrl_s_ctrl"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/cx88-alsa.ko] undefined!
WARNING: "__v4l2_ctrl_s_ctrl"
[/root/rpmbuild/BUILD/v4l/media_build/v4l/cx23885.ko] undefined!

I don't recall these errors in earlier builds, and I'm not sure if
they are perhaps related to the issues I'm getting on module load.

Any help is appreciated.

Zach


Re: [PATCH 0/2] More s5p-jpeg fixes

2017-08-14 Thread Jacek Anaszewski
Hi Andrzej,

Thanks for the patches.

On 08/11/2017 01:49 PM, Andrzej Pietrasiewicz wrote:
> Hi All,
> 
> The first patch in the series fixes decoding path,
> the second patch fixes encoding path. Please see
> appropriate commit messages.
> 
> Andrzej Pietrasiewicz (2):
>   media: s5p-jpeg: don't overwrite result's "size" member
>   media: s5p-jpeg: set w/h when encoding
> 
>  drivers/media/platform/s5p-jpeg/jpeg-core.c | 10 +++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 

Reviewed-by: Jacek Anaszewski 

-- 
Best regards,
Jacek Anaszewski


Re: [PATCH] [media] media: imx: depends on V4L2 sub-device userspace API

2017-08-14 Thread Cihangir Akturk
On Mon, Aug 14, 2017 at 10:57:46AM -0700, Steve Longerbeam wrote:
> Hi Akturk, this has already been fixed, see

Sorry. Apparently, I missed to update my tree, somehow.

> 
> 4560cb4a0c ("media: imx: add VIDEO_V4L2_SUBDEV_API dependency").
> 
> Steve
> 
> On 08/14/2017 04:00 AM, Cihangir Akturk wrote:
> > This driver uses various v4l2_subdev_get_try_*() functions provided by
> > V4L2 sub-device userspace API. Current configuration of Kconfig file
> > allows us to enable VIDEO_IMX_MEDIA without enabling this API. This
> > breaks the build of driver.
> > 
> > Depend on VIDEO_V4L2_SUBDEV_API to fix this issue.
> > 
> > Signed-off-by: Cihangir Akturk 
> > ---
> >   drivers/staging/media/imx/Kconfig | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/media/imx/Kconfig 
> > b/drivers/staging/media/imx/Kconfig
> > index 7eff50b..d8c3890 100644
> > --- a/drivers/staging/media/imx/Kconfig
> > +++ b/drivers/staging/media/imx/Kconfig
> > @@ -1,6 +1,7 @@
> >   config VIDEO_IMX_MEDIA
> > tristate "i.MX5/6 V4L2 media core driver"
> > -   depends on MEDIA_CONTROLLER && VIDEO_V4L2 && ARCH_MXC && IMX_IPUV3_CORE
> > +   depends on MEDIA_CONTROLLER && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && \
> > +   ARCH_MXC && IMX_IPUV3_CORE
> > select V4L2_FWNODE
> > ---help---
> >   Say yes here to enable support for video4linux media controller
> 


Re: [PATCH 0/5] s5p-jpeg fixes

2017-08-14 Thread Jacek Anaszewski
Hi Andrzej,

Thanks for the patch set.

On 08/08/2017 01:22 PM, Andrzej Pietrasiewicz wrote:
> Hi All,
> 
> This series contains a number of fixes to the s5p-jpeg driver.
> 
> There are two patches from Tony K Nadackal, which got lost long time ago.
> 
> @Thierry:
> The patch changing the software reset routine you sent recently was
> actually a resend of Tony's patch. I investigated the question why
> this patch is needed. The encoder/decoder should be disabled as soon
> as possible, in the interrupt service routine; please see the commit message.
> I am resending Tony's patch again, with updated commit message.
> Thank you for reminding about the patch in question!
> 
> There are also three patches from me, please see appropriate commit
> messages.
> 
> Rebased onto Mauro's master.
> 
> Andrzej Pietrasiewicz (3):
>   media: platform: s5p-jpeg: disable encoder/decoder in exynos4-like
> hardware after use
>   media: platform: s5p-jpeg: fix number of components macro
>   media: platform: s5p-jpeg: directly use parsed subsampling on 5433
> 
> Tony K Nadackal (2):
>   media: platform: s5p-jpeg: Fix crash in jpeg isr due to multiple
> interrupts.
>   media: platform: s5p-jpeg: Clear JPEG_CODEC_ON bits in sw reset
> function
> 
>  drivers/media/platform/s5p-jpeg/jpeg-core.c   | 8 +++-
>  drivers/media/platform/s5p-jpeg/jpeg-core.h   | 1 +
>  drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c | 9 -
>  drivers/media/platform/s5p-jpeg/jpeg-regs.h   | 2 +-
>  4 files changed, 17 insertions(+), 3 deletions(-)
> 

For the whole series:

Reviewed-by: Jacek Anaszewski 

-- 
Best regards,
Jacek Anaszewski


Re: [PATCH] v4l2-compat-ioctl32.c: make ctrl_is_pointer generic

2017-08-14 Thread Sakari Ailus
Hi Hans,

On Fri, Aug 11, 2017 at 03:26:03PM +0200, Hans Verkuil wrote:
> The ctrl_is_pointer used a hard-coded list of control IDs that besides being
> outdated also wouldn't work for custom driver controls.
> 
> Replaced by calling queryctrl and checking if the V4L2_CTRL_FLAG_HAS_PAYLOAD
> flag was set.

I think the approach is good, this scales much better.

Considering that running a 32-bit user space on a 64-bit kernel is an
entirely possible production setup, I'm worried of the overhead that this
brings to accessing controls.

How about just looking up the control and then checking ctrl->is_ptr?
Wouldn't it yield the same result?

> 
> Note that get_v4l2_ext_controls32() will set the v4l2_ext_control 'size' field
> to 0 if the control has no payload before passing it to the kernel. This
> helps in put_v4l2_ext_controls32() since that function can just look at the
> 'size' field instead of having to call queryctrl again. The reason we set
> 'size' explicitly for non-pointer controls is that 'size' is ignored by the
> kernel in that case. That makes 'size' useless as an indicator of a pointer
> type in the put function since it can be any value. But setting it to 0 here
> turns it into a useful indicator.
> 
> Also added proper checks for the compat_alloc_user_space return value which
> can be NULL, this was never done for some reason.
> 
> Tested with a 32-bit build of v4l2-ctl and the vivid driver.
> 
> Signed-off-by: Hans Verkuil 
> ---
> diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c 
> b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
> index af8b4c5b0efa..a16338cc216e 100644
> --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
> +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
> @@ -17,7 +17,9 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
> +#include 
>  #include 
> 
>  static long native_ioctl(struct file *file, unsigned int cmd, unsigned long 
> arg)
> @@ -67,6 +69,8 @@ static int get_v4l2_window32(struct v4l2_window *kp, struct 
> v4l2_window32 __user
>   return -EFAULT;
>   uclips = compat_ptr(p);
>   kclips = compat_alloc_user_space(n * sizeof(struct v4l2_clip));
> + if (kclips == NULL)
> + return -EFAULT;
>   kp->clips = kclips;
>   while (--n >= 0) {
>   if (copy_in_user(>c, >c, 
> sizeof(uclips->c)))
> @@ -473,6 +477,8 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, 
> struct v4l2_buffer32 __user
>* by passing a very big num_planes value */
>   uplane = compat_alloc_user_space(kp->length *
>sizeof(struct v4l2_plane));
> + if (uplane == NULL)
> + return -EFAULT;
>   kp->m.planes = (__force struct v4l2_plane *)uplane;
> 
>   for (num_planes = 0; num_planes < kp->length; num_planes++) {
> @@ -668,24 +674,38 @@ struct v4l2_ext_control32 {
>   };
>  } __attribute__ ((packed));
> 
> -/* The following function really belong in v4l2-common, but that causes
> -   a circular dependency between modules. We need to think about this, but
> -   for now this will do. */
> 
> -/* Return non-zero if this control is a pointer type. Currently only
> -   type STRING is a pointer type. */
> -static inline int ctrl_is_pointer(u32 id)
> +/* Return non-zero if this control is a pointer type. */
> +static inline int ctrl_is_pointer(struct file *file, u32 id)
>  {
> - switch (id) {
> - case V4L2_CID_RDS_TX_PS_NAME:
> - case V4L2_CID_RDS_TX_RADIO_TEXT:
> - return 1;
> - default:
> + struct video_device *vfd = video_devdata(file);
> + const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
> + void *fh = file->private_data;
> + struct v4l2_fh *vfh =
> + test_bit(V4L2_FL_USES_V4L2_FH, >flags) ? fh : NULL;
> + struct v4l2_queryctrl qctrl = { id };
> + int err;
> +
> + if (!test_bit(_IOC_NR(VIDIOC_QUERYCTRL), vfd->valid_ioctls))
> + err = -ENOTTY;
> + else if (vfh && vfh->ctrl_handler)
> + err = v4l2_queryctrl(vfh->ctrl_handler, );
> + else if (vfd->ctrl_handler)
> + err = v4l2_queryctrl(vfd->ctrl_handler, );
> + else if (ops->vidioc_queryctrl)
> + err = ops->vidioc_queryctrl(file, fh, );
> + else
> + err = -ENOTTY;
> +
> + if (err)
>   return 0;
> - }
> +
> + return qctrl.flags & V4L2_CTRL_FLAG_HAS_PAYLOAD;
>  }
> 
> -static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct 
> v4l2_ext_controls32 __user *up)
> +static int get_v4l2_ext_controls32(struct file *file,
> +struct v4l2_ext_controls *kp,
> +struct v4l2_ext_controls32 __user *up)
>  {
>   struct v4l2_ext_control32 __user *ucontrols;
>   struct v4l2_ext_control __user *kcontrols;
> @@ -713,15 

[PATCH v1.3 1/1] omap3isp: Skip CSI-2 receiver initialisation in CCP2 configuration

2017-08-14 Thread Sakari Ailus
If the CSI-2 receiver isn't part of the pipeline (or isn't there to begin
with), skip its initialisation.

Signed-off-by: Sakari Ailus 
Tested-by: Laurent Pinchart  # on 
Beagleboard-xM + MPT9P031
Acked-by: Pavel Machek 
---
 drivers/media/platform/omap3isp/ispccp2.c   |  2 +-
 drivers/media/platform/omap3isp/ispcsi2.c   |  4 +--
 drivers/media/platform/omap3isp/ispcsiphy.c | 45 +
 drivers/media/platform/omap3isp/ispcsiphy.h |  6 ++--
 4 files changed, 27 insertions(+), 30 deletions(-)

diff --git a/drivers/media/platform/omap3isp/ispccp2.c 
b/drivers/media/platform/omap3isp/ispccp2.c
index 47210b102bcb..3db8df09cd9a 100644
--- a/drivers/media/platform/omap3isp/ispccp2.c
+++ b/drivers/media/platform/omap3isp/ispccp2.c
@@ -841,7 +841,7 @@ static int ccp2_s_stream(struct v4l2_subdev *sd, int enable)
switch (enable) {
case ISP_PIPELINE_STREAM_CONTINUOUS:
if (ccp2->phy) {
-   ret = omap3isp_csiphy_acquire(ccp2->phy);
+   ret = omap3isp_csiphy_acquire(ccp2->phy, >entity);
if (ret < 0)
return ret;
}
diff --git a/drivers/media/platform/omap3isp/ispcsi2.c 
b/drivers/media/platform/omap3isp/ispcsi2.c
index 7dae2fe0d42d..3ec37fed710b 100644
--- a/drivers/media/platform/omap3isp/ispcsi2.c
+++ b/drivers/media/platform/omap3isp/ispcsi2.c
@@ -490,7 +490,7 @@ int omap3isp_csi2_reset(struct isp_csi2_device *csi2)
if (!csi2->available)
return -ENODEV;
 
-   if (csi2->phy->phy_in_use)
+   if (csi2->phy->entity)
return -EBUSY;
 
isp_reg_set(isp, csi2->regs1, ISPCSI2_SYSCONFIG,
@@ -1053,7 +1053,7 @@ static int csi2_set_stream(struct v4l2_subdev *sd, int 
enable)
 
switch (enable) {
case ISP_PIPELINE_STREAM_CONTINUOUS:
-   if (omap3isp_csiphy_acquire(csi2->phy) < 0)
+   if (omap3isp_csiphy_acquire(csi2->phy, >entity) < 0)
return -ENODEV;
if (csi2->output & CSI2_OUTPUT_MEMORY)
omap3isp_sbl_enable(isp, OMAP3_ISP_SBL_CSI2A_WRITE);
diff --git a/drivers/media/platform/omap3isp/ispcsiphy.c 
b/drivers/media/platform/omap3isp/ispcsiphy.c
index 2028bb519108..7e2846c52bb2 100644
--- a/drivers/media/platform/omap3isp/ispcsiphy.c
+++ b/drivers/media/platform/omap3isp/ispcsiphy.c
@@ -164,22 +164,17 @@ static int csiphy_set_power(struct isp_csiphy *phy, u32 
power)
 
 static int omap3isp_csiphy_config(struct isp_csiphy *phy)
 {
-   struct isp_csi2_device *csi2 = phy->csi2;
-   struct isp_pipeline *pipe = to_isp_pipeline(>subdev.entity);
-   struct isp_bus_cfg *buscfg = pipe->external->host_priv;
+   struct isp_pipeline *pipe = to_isp_pipeline(phy->entity);
+   struct isp_async_subdev *isd =
+   container_of(pipe->external->asd, struct isp_async_subdev, asd);
+   struct isp_bus_cfg *buscfg = pipe->external->host_priv ?
+   pipe->external->host_priv : >bus;
struct isp_csiphy_lanes_cfg *lanes;
int csi2_ddrclk_khz;
unsigned int num_data_lanes, used_lanes = 0;
unsigned int i;
u32 reg;
 
-   if (!buscfg) {
-   struct isp_async_subdev *isd =
-   container_of(pipe->external->asd,
-struct isp_async_subdev, asd);
-   buscfg = >bus;
-   }
-
if (buscfg->interface == ISP_INTERFACE_CCP2B_PHY1
|| buscfg->interface == ISP_INTERFACE_CCP2B_PHY2) {
lanes = >bus.ccp2.lanecfg;
@@ -222,7 +217,7 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy)
csi2_ddrclk_khz = pipe->external_rate / 1000
/ (2 * hweight32(used_lanes)) * pipe->external_width;
 
-   reg = isp_reg_readl(csi2->isp, phy->phy_regs, ISPCSIPHY_REG0);
+   reg = isp_reg_readl(phy->isp, phy->phy_regs, ISPCSIPHY_REG0);
 
reg &= ~(ISPCSIPHY_REG0_THS_TERM_MASK |
 ISPCSIPHY_REG0_THS_SETTLE_MASK);
@@ -233,9 +228,9 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy)
reg |= (DIV_ROUND_UP(90 * csi2_ddrclk_khz, 100) + 3)
<< ISPCSIPHY_REG0_THS_SETTLE_SHIFT;
 
-   isp_reg_writel(csi2->isp, reg, phy->phy_regs, ISPCSIPHY_REG0);
+   isp_reg_writel(phy->isp, reg, phy->phy_regs, ISPCSIPHY_REG0);
 
-   reg = isp_reg_readl(csi2->isp, phy->phy_regs, ISPCSIPHY_REG1);
+   reg = isp_reg_readl(phy->isp, phy->phy_regs, ISPCSIPHY_REG1);
 
reg &= ~(ISPCSIPHY_REG1_TCLK_TERM_MASK |
 ISPCSIPHY_REG1_TCLK_MISS_MASK |
@@ -244,10 +239,10 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy)
reg |= TCLK_MISS << ISPCSIPHY_REG1_TCLK_MISS_SHIFT;
reg |= TCLK_SETTLE << ISPCSIPHY_REG1_TCLK_SETTLE_SHIFT;
 
-   isp_reg_writel(csi2->isp, reg, phy->phy_regs, 

Re: [PATCH v1.2 1/1] omap3isp: Skip CSI-2 receiver initialisation in CCP2 configuration

2017-08-14 Thread Sakari Ailus
On Mon, Aug 14, 2017 at 04:33:39PM +0300, Laurent Pinchart wrote:
> Hi Sakari,
> 
> On Monday 14 Aug 2017 13:53:27 Sakari Ailus wrote:
> > On Fri, Aug 11, 2017 at 02:32:00PM +0300, Laurent Pinchart wrote:
> > > On Friday 11 Aug 2017 12:57:09 Sakari Ailus wrote:
> > >> If the CSI-2 receiver isn't part of the pipeline (or isn't there to
> > >> begin with), skip its initialisation.
> > > 
> > > I don't think the commit message really describes the patch.
> > > 
> > >> Signed-off-by: Sakari Ailus 
> > >> Tested-by: Laurent Pinchart  # on
> > >> Beagleboard-xM + MPT9P031 Acked-by: Pavel Machek 
> > >> ---
> > >> since v1.1:
> > >> 
> > >> - Assign phy->entity before calling omap3isp_csiphy_config(), for
> > >> 
> > >>   phy->entity is used by omap3isp_csiphy_config(). (Thanks to Pavel for
> > >>   spotting this.)
> > >>  
> > >>  drivers/media/platform/omap3isp/ispccp2.c   |  2 +-
> > >>  drivers/media/platform/omap3isp/ispcsi2.c   |  4 +--
> > >>  drivers/media/platform/omap3isp/ispcsiphy.c | 38 ++
> > >>  drivers/media/platform/omap3isp/ispcsiphy.h |  6 +++--
> > >>  4 files changed, 27 insertions(+), 23 deletions(-)
> > >> 
> 
> [snip]
> 
> > >> diff --git a/drivers/media/platform/omap3isp/ispcsiphy.c
> > >> b/drivers/media/platform/omap3isp/ispcsiphy.c index
> > >> 2028bb519108..aedd88fa8246 100644
> > >> --- a/drivers/media/platform/omap3isp/ispcsiphy.c
> > >> +++ b/drivers/media/platform/omap3isp/ispcsiphy.c
> > >> @@ -164,15 +164,18 @@ static int csiphy_set_power(struct isp_csiphy
> > >> *phy, u32 power)
> > >> 
> > >>  static int omap3isp_csiphy_config(struct isp_csiphy *phy)
> > >>  {
> > >> -struct isp_csi2_device *csi2 = phy->csi2;
> > >> -struct isp_pipeline *pipe = 
> > >> to_isp_pipeline(>subdev.entity);
> > >> -struct isp_bus_cfg *buscfg = pipe->external->host_priv;
> > >> +struct isp_pipeline *pipe = to_isp_pipeline(phy->entity);
> > >> +struct isp_bus_cfg *buscfg;
> > >>  struct isp_csiphy_lanes_cfg *lanes;
> > >>  int csi2_ddrclk_khz;
> > >>  unsigned int num_data_lanes, used_lanes = 0;
> > >>  unsigned int i;
> > >>  u32 reg;
> > >> 
> > >> +if (!pipe)
> > >> +return -EBUSY;
> > > 
> > > When can this happen ?
> > 
> > It shouldn't. Just in case, it'd be a driver bug if it did. What would you
> > think of adding WARN_ON() here?
> 
> I throw WARN_ON()s in when I believe that driver could get it wrong. In this 
> particular case, given that this function is called from .s_stream() handlers 
> only, I wonder if the check makes sense at all.

Yeah, makes sense; I'll drop it.

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi


Re: [PATCH] [media] media: imx: depends on V4L2 sub-device userspace API

2017-08-14 Thread Steve Longerbeam

Hi Akturk, this has already been fixed, see

4560cb4a0c ("media: imx: add VIDEO_V4L2_SUBDEV_API dependency").

Steve

On 08/14/2017 04:00 AM, Cihangir Akturk wrote:

This driver uses various v4l2_subdev_get_try_*() functions provided by
V4L2 sub-device userspace API. Current configuration of Kconfig file
allows us to enable VIDEO_IMX_MEDIA without enabling this API. This
breaks the build of driver.

Depend on VIDEO_V4L2_SUBDEV_API to fix this issue.

Signed-off-by: Cihangir Akturk 
---
  drivers/staging/media/imx/Kconfig | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/imx/Kconfig 
b/drivers/staging/media/imx/Kconfig
index 7eff50b..d8c3890 100644
--- a/drivers/staging/media/imx/Kconfig
+++ b/drivers/staging/media/imx/Kconfig
@@ -1,6 +1,7 @@
  config VIDEO_IMX_MEDIA
tristate "i.MX5/6 V4L2 media core driver"
-   depends on MEDIA_CONTROLLER && VIDEO_V4L2 && ARCH_MXC && IMX_IPUV3_CORE
+   depends on MEDIA_CONTROLLER && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && \
+   ARCH_MXC && IMX_IPUV3_CORE
select V4L2_FWNODE
---help---
  Say yes here to enable support for video4linux media controller




[PATCH v2] media: ddbridge: constify stv0910_p and lnbh25_cfg

2017-08-14 Thread Julia Lawall
These structures are only copied into other structures, so
they can be const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall 

---

v2: fix typo in the commit message

 drivers/media/pci/ddbridge/ddbridge-core.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 7e164a37..7ff570b 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -800,14 +800,14 @@ static int tuner_attach_stv6110(struct ddb_input *input, 
int type)
return 0;
 }
 
-static struct stv0910_cfg stv0910_p = {
+static const struct stv0910_cfg stv0910_p = {
.adr  = 0x68,
.parallel = 1,
.rptlvl   = 4,
.clk  = 3000,
 };
 
-static struct lnbh25_config lnbh25_cfg = {
+static const struct lnbh25_config lnbh25_cfg = {
.i2c_address = 0x0c << 1,
.data2_config = LNBH25_TEN
 };



[PATCH] [media] dvb-frontends/stv0367: remove QAM_AUTO from ddb_fe_ops

2017-08-14 Thread Daniel Scheller
From: Daniel Scheller 

Since the cab_* codepath doesn't recognize QAM_AUTO, don't announce that
it is supported when it really isn't. Fixes ie. w_scan from
unconditionally using QAM_AUTO on DVB-C scans.

Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/stv0367.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/stv0367.c 
b/drivers/media/dvb-frontends/stv0367.c
index bc6eb0ab733e..f3529df8211d 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -3283,7 +3283,7 @@ static const struct dvb_frontend_ops stv0367ddb_ops = {
0x400 |/* FE_CAN_QAM_4 */
FE_CAN_QAM_16 | FE_CAN_QAM_32  |
FE_CAN_QAM_64 | FE_CAN_QAM_128 |
-   FE_CAN_QAM_256 | FE_CAN_QAM_AUTO |
+   FE_CAN_QAM_256 |
/* DVB-T */
FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
-- 
2.13.0



[PATCH] media: ddbridge: constify stv0910_p and lnbh25_cfg

2017-08-14 Thread Julia Lawall
These structures are only copied into other stuructures, so
they can be const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall 

---
 drivers/media/pci/ddbridge/ddbridge-core.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 7e164a37..7ff570b 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -800,14 +800,14 @@ static int tuner_attach_stv6110(struct ddb_input *input, 
int type)
return 0;
 }
 
-static struct stv0910_cfg stv0910_p = {
+static const struct stv0910_cfg stv0910_p = {
.adr  = 0x68,
.parallel = 1,
.rptlvl   = 4,
.clk  = 3000,
 };
 
-static struct lnbh25_config lnbh25_cfg = {
+static const struct lnbh25_config lnbh25_cfg = {
.i2c_address = 0x0c << 1,
.data2_config = LNBH25_TEN
 };



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

2017-08-14 Thread Geert Uytterhoeven
On Sun, Jul 30, 2017 at 3:07 PM, Hans Verkuil  wrote:
> From: Hans Verkuil 

Probably the one-line summary should be

ARM: dts: koelsch: Add CEC clock  for HDMI transmitter

> The adv7511 on the Koelsch board has a 12 MHz fixed clock
> for the CEC block. Specify this in the dts to enable CEC support.
>
> Signed-off-by: Hans Verkuil 

Reviewed-by: Geert Uytterhoeven 

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 v2 2/8] v4l: vsp1: Provide a fragment pool

2017-08-14 Thread Kieran Bingham
Each display list allocates a body to store register values in a dma
accessible buffer from a dma_alloc_wc() allocation. Each of these
results in an entry in the TLB, and a large number of display list
allocations adds pressure to this resource.

Reduce TLB pressure on the IPMMUs by allocating multiple display list
bodies in a single allocation, and providing these to the display list
through a 'fragment pool'. A pool can be allocated by the display list
manager or entities which require their own body allocations.

Signed-off-by: Kieran Bingham 

---
v2:
 - assign dlb->dma correctly
---
 drivers/media/platform/vsp1/vsp1_dl.c | 129 +++-
 drivers/media/platform/vsp1/vsp1_dl.h |   8 ++-
 2 files changed, 137 insertions(+)

diff --git a/drivers/media/platform/vsp1/vsp1_dl.c 
b/drivers/media/platform/vsp1/vsp1_dl.c
index cb4625ae13c2..aab9dd6ec0eb 100644
--- a/drivers/media/platform/vsp1/vsp1_dl.c
+++ b/drivers/media/platform/vsp1/vsp1_dl.c
@@ -45,6 +45,8 @@ struct vsp1_dl_entry {
 /**
  * struct vsp1_dl_body - Display list body
  * @list: entry in the display list list of bodies
+ * @free: entry in the pool free body list
+ * @pool: pool to which this body belongs
  * @vsp1: the VSP1 device
  * @entries: array of entries
  * @dma: DMA address of the entries
@@ -54,6 +56,9 @@ struct vsp1_dl_entry {
  */
 struct vsp1_dl_body {
struct list_head list;
+   struct list_head free;
+
+   struct vsp1_dl_fragment_pool *pool;
struct vsp1_device *vsp1;
 
struct vsp1_dl_entry *entries;
@@ -65,6 +70,30 @@ struct vsp1_dl_body {
 };
 
 /**
+ * struct vsp1_dl_fragment_pool - display list body/fragment pool
+ * @dma: DMA address of the entries
+ * @size: size of the full DMA memory pool in bytes
+ * @mem: CPU memory pointer for the pool
+ * @bodies: Array of DLB structures for the pool
+ * @free: List of free DLB entries
+ * @lock: Protects the pool and free list
+ * @vsp1: the VSP1 device
+ */
+struct vsp1_dl_fragment_pool {
+   /* DMA allocation */
+   dma_addr_t dma;
+   size_t size;
+   void *mem;
+
+   /* Body management */
+   struct vsp1_dl_body *bodies;
+   struct list_head free;
+   spinlock_t lock;
+
+   struct vsp1_device *vsp1;
+};
+
+/**
  * struct vsp1_dl_list - Display list
  * @list: entry in the display list manager lists
  * @dlm: the display list manager
@@ -104,6 +133,7 @@ enum vsp1_dl_mode {
  * @active: list currently being processed (loaded) by hardware
  * @queued: list queued to the hardware (written to the DL registers)
  * @pending: list waiting to be queued to the hardware
+ * @pool: fragment pool for the display list bodies
  * @gc_work: fragments garbage collector work struct
  * @gc_fragments: array of display list fragments waiting to be freed
  */
@@ -119,6 +149,8 @@ struct vsp1_dl_manager {
struct vsp1_dl_list *queued;
struct vsp1_dl_list *pending;
 
+   struct vsp1_dl_fragment_pool *pool;
+
struct work_struct gc_work;
struct list_head gc_fragments;
 };
@@ -128,6 +160,103 @@ struct vsp1_dl_manager {
  */
 
 /*
+ * Fragment pool's reduce the pressure on the iommu TLB by allocating a single
+ * large area of DMA memory and allocating it as a pool of fragment bodies
+ */
+struct vsp1_dl_fragment_pool *
+vsp1_dl_fragment_pool_alloc(struct vsp1_device *vsp1, unsigned int qty,
+   unsigned int num_entries, size_t extra_size)
+{
+   struct vsp1_dl_fragment_pool *pool;
+   size_t dlb_size;
+   unsigned int i;
+
+   pool = kzalloc(sizeof(*pool), GFP_KERNEL);
+   if (!pool)
+   return NULL;
+
+   pool->vsp1 = vsp1;
+
+   dlb_size = num_entries * sizeof(struct vsp1_dl_entry) + extra_size;
+   pool->size = dlb_size * qty;
+
+   pool->bodies = kcalloc(qty, sizeof(*pool->bodies), GFP_KERNEL);
+   if (!pool->bodies) {
+   kfree(pool);
+   return NULL;
+   }
+
+   pool->mem = dma_alloc_wc(vsp1->bus_master, pool->size, >dma,
+   GFP_KERNEL);
+   if (!pool->mem) {
+   kfree(pool->bodies);
+   kfree(pool);
+   return NULL;
+   }
+
+   spin_lock_init(>lock);
+   INIT_LIST_HEAD(>free);
+
+   for (i = 0; i < qty; ++i) {
+   struct vsp1_dl_body *dlb = >bodies[i];
+
+   dlb->pool = pool;
+   dlb->max_entries = num_entries;
+
+   dlb->dma = pool->dma + i * dlb_size;
+   dlb->entries = pool->mem + i * dlb_size;
+
+   list_add_tail(>free, >free);
+   }
+
+   return pool;
+}
+
+void vsp1_dl_fragment_pool_free(struct vsp1_dl_fragment_pool *pool)
+{
+   if (!pool)
+   return;
+
+   if (pool->mem)
+   dma_free_wc(pool->vsp1->bus_master, pool->size, pool->mem,
+   pool->dma);
+
+   kfree(pool->bodies);
+   

[PATCH v2 8/8] v4l: vsp1: Reduce display list body size

2017-08-14 Thread Kieran Bingham
The display list originally allocated a body of 256 entries to store all
of the register lists required for each frame.

This has now been separated into fragments for constant stream setup, and
runtime updates.

Empirical testing shows that the body0 now uses a maximum of 41
registers for each frame, for both DRM and Video API pipelines thus a
rounded 64 entries provides a suitable allocation.

Signed-off-by: Kieran Bingham 
---
 drivers/media/platform/vsp1/vsp1_dl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/vsp1/vsp1_dl.c 
b/drivers/media/platform/vsp1/vsp1_dl.c
index 176a258146ac..b3f5eb2f9a4f 100644
--- a/drivers/media/platform/vsp1/vsp1_dl.c
+++ b/drivers/media/platform/vsp1/vsp1_dl.c
@@ -21,7 +21,7 @@
 #include "vsp1.h"
 #include "vsp1_dl.h"
 
-#define VSP1_DL_NUM_ENTRIES256
+#define VSP1_DL_NUM_ENTRIES64
 
 #define VSP1_DLH_INT_ENABLE(1 << 1)
 #define VSP1_DLH_AUTO_START(1 << 0)
-- 
git-series 0.9.1


[PATCH v2 5/8] v4l: vsp1: Refactor display list configure operations

2017-08-14 Thread Kieran Bingham
The entities provide a single .configure operation which configures the
object into the target display list, based on the vsp1_entity_params
selection.

This restricts us to a single function prototype for both static
configuration (the pre-stream INIT stage) and the dynamic runtime stages
for both each frame - and each partition therein.

Split the configure function into two parts, '.prepare()' and
'.configure()', merging both the VSP1_ENTITY_PARAMS_RUNTIME and
VSP1_ENTITY_PARAMS_PARTITION stages into a single call through the
.configure(). The configuration for individual partitions is handled by
passing the partition number to the configure call, and processing any
runtime stage actions on the first partition only.

Signed-off-by: Kieran Bingham 
---
 drivers/media/platform/vsp1/vsp1_bru.c|  12 +-
 drivers/media/platform/vsp1/vsp1_clu.c|  43 +--
 drivers/media/platform/vsp1/vsp1_drm.c|  11 +-
 drivers/media/platform/vsp1/vsp1_entity.c |  15 +-
 drivers/media/platform/vsp1/vsp1_entity.h |  27 +--
 drivers/media/platform/vsp1/vsp1_hgo.c|  12 +-
 drivers/media/platform/vsp1/vsp1_hgt.c|  12 +-
 drivers/media/platform/vsp1/vsp1_hsit.c   |  12 +-
 drivers/media/platform/vsp1/vsp1_lif.c|  12 +-
 drivers/media/platform/vsp1/vsp1_lut.c|  24 +-
 drivers/media/platform/vsp1/vsp1_rpf.c| 162 ++---
 drivers/media/platform/vsp1/vsp1_sru.c|  12 +-
 drivers/media/platform/vsp1/vsp1_uds.c|  55 ++--
 drivers/media/platform/vsp1/vsp1_video.c  |  24 +--
 drivers/media/platform/vsp1/vsp1_wpf.c| 297 ---
 15 files changed, 359 insertions(+), 371 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_bru.c 
b/drivers/media/platform/vsp1/vsp1_bru.c
index e8fd2ae3b3eb..b9ff96f76b3e 100644
--- a/drivers/media/platform/vsp1/vsp1_bru.c
+++ b/drivers/media/platform/vsp1/vsp1_bru.c
@@ -285,19 +285,15 @@ static const struct v4l2_subdev_ops bru_ops = {
  * VSP1 Entity Operations
  */
 
-static void bru_configure(struct vsp1_entity *entity,
- struct vsp1_pipeline *pipe,
- struct vsp1_dl_list *dl,
- enum vsp1_entity_params params)
+static void bru_prepare(struct vsp1_entity *entity,
+   struct vsp1_pipeline *pipe,
+   struct vsp1_dl_list *dl)
 {
struct vsp1_bru *bru = to_bru(>subdev);
struct v4l2_mbus_framefmt *format;
unsigned int flags;
unsigned int i;
 
-   if (params != VSP1_ENTITY_PARAMS_INIT)
-   return;
-
format = vsp1_entity_get_pad_format(>entity, bru->entity.config,
bru->entity.source_pad);
 
@@ -404,7 +400,7 @@ static void bru_configure(struct vsp1_entity *entity,
 }
 
 static const struct vsp1_entity_operations bru_entity_ops = {
-   .configure = bru_configure,
+   .prepare = bru_prepare,
 };
 
 /* 
-
diff --git a/drivers/media/platform/vsp1/vsp1_clu.c 
b/drivers/media/platform/vsp1/vsp1_clu.c
index 175717018e11..5f65ce3ad97f 100644
--- a/drivers/media/platform/vsp1/vsp1_clu.c
+++ b/drivers/media/platform/vsp1/vsp1_clu.c
@@ -213,37 +213,37 @@ static const struct v4l2_subdev_ops clu_ops = {
 /* 
-
  * VSP1 Entity Operations
  */
+static void clu_prepare(struct vsp1_entity *entity,
+   struct vsp1_pipeline *pipe,
+   struct vsp1_dl_list *dl)
+{
+   struct vsp1_clu *clu = to_clu(>subdev);
+
+   /*
+* The format can't be changed during streaming, only verify it
+* at setup time and store the information internally for future
+* runtime configuration calls.
+*/
+   struct v4l2_mbus_framefmt *format;
+
+   format = vsp1_entity_get_pad_format(>entity,
+   clu->entity.config,
+   CLU_PAD_SINK);
+   clu->yuv_mode = format->code == MEDIA_BUS_FMT_AYUV8_1X32;
+}
 
 static void clu_configure(struct vsp1_entity *entity,
  struct vsp1_pipeline *pipe,
  struct vsp1_dl_list *dl,
- enum vsp1_entity_params params)
+ unsigned int partition)
 {
struct vsp1_clu *clu = to_clu(>subdev);
struct vsp1_dl_body *dlb;
unsigned long flags;
u32 ctrl = VI6_CLU_CTRL_AAI | VI6_CLU_CTRL_MVS | VI6_CLU_CTRL_EN;
 
-   switch (params) {
-   case VSP1_ENTITY_PARAMS_INIT: {
-   /*
-* The format can't be changed during streaming, only verify it
-* at setup time and store the information internally for future
-* runtime configuration calls.
-*/
-   struct v4l2_mbus_framefmt *format;
-
-  

[PATCH v2 4/8] v4l: vsp1: Use reference counting for fragments

2017-08-14 Thread Kieran Bingham
Extend the display list body with a reference count, allowing bodies to
be kept as long as a reference is maintained. This provides the ability
to keep a cached copy of bodies which will not change, so that they can
be re-applied to multiple display lists.

Signed-off-by: Kieran Bingham 

---
This could be squashed into the fragment update code, but it's not a
straightforward squash as the refcounts will affect both:
  v4l: vsp1: Provide a fragment pool
and
  v4l: vsp1: Convert display lists to use new fragment pool
therefore, I have kept this separate to prevent breaking bisectability
of the vsp-tests.
---
 drivers/media/platform/vsp1/vsp1_clu.c |  7 ++-
 drivers/media/platform/vsp1/vsp1_dl.c  | 15 ++-
 drivers/media/platform/vsp1/vsp1_lut.c |  7 ++-
 3 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_clu.c 
b/drivers/media/platform/vsp1/vsp1_clu.c
index 52c523625e2f..175717018e11 100644
--- a/drivers/media/platform/vsp1/vsp1_clu.c
+++ b/drivers/media/platform/vsp1/vsp1_clu.c
@@ -257,8 +257,13 @@ static void clu_configure(struct vsp1_entity *entity,
clu->clu = NULL;
spin_unlock_irqrestore(>lock, flags);
 
-   if (dlb)
+   if (dlb) {
vsp1_dl_list_add_fragment(dl, dlb);
+
+   /* release our local reference */
+   vsp1_dl_fragment_put(dlb);
+   }
+
break;
}
 }
diff --git a/drivers/media/platform/vsp1/vsp1_dl.c 
b/drivers/media/platform/vsp1/vsp1_dl.c
index 6ffdc3549283..37feda248946 100644
--- a/drivers/media/platform/vsp1/vsp1_dl.c
+++ b/drivers/media/platform/vsp1/vsp1_dl.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -58,6 +59,8 @@ struct vsp1_dl_body {
struct list_head list;
struct list_head free;
 
+   refcount_t refcnt;
+
struct vsp1_dl_fragment_pool *pool;
struct vsp1_device *vsp1;
 
@@ -230,6 +233,7 @@ struct vsp1_dl_body *vsp1_dl_fragment_get(struct 
vsp1_dl_fragment_pool *pool)
if (!list_empty(>free)) {
dlb = list_first_entry(>free, struct vsp1_dl_body, free);
list_del(>free);
+   refcount_set(>refcnt, 1);
}
 
spin_unlock_irqrestore(>lock, flags);
@@ -244,6 +248,9 @@ void vsp1_dl_fragment_put(struct vsp1_dl_body *dlb)
if (!dlb)
return;
 
+   if (!refcount_dec_and_test(>refcnt))
+   return;
+
dlb->num_entries = 0;
 
spin_lock_irqsave(>pool->lock, flags);
@@ -428,7 +435,11 @@ void vsp1_dl_list_write(struct vsp1_dl_list *dl, u32 reg, 
u32 data)
  * list, in the order in which fragments are added.
  *
  * Adding a fragment to a display list passes ownership of the fragment to the
- * list. The caller must not touch the fragment after this call.
+ * list. The caller must not modify the fragment after this call, but can 
retain
+ * a reference to it for future use if necessary, to add to subsequent lists.
+ *
+ * The reference count of the body is incremented by this attachment, and thus
+ * the caller should release it's reference if does not want to cache the body.
  *
  * Fragments are only usable for display lists in header mode. Attempt to
  * add a fragment to a header-less display list will return an error.
@@ -440,6 +451,8 @@ int vsp1_dl_list_add_fragment(struct vsp1_dl_list *dl,
if (dl->dlm->mode != VSP1_DL_MODE_HEADER)
return -EINVAL;
 
+   refcount_inc(>refcnt);
+
list_add_tail(>list, >fragments);
return 0;
 }
diff --git a/drivers/media/platform/vsp1/vsp1_lut.c 
b/drivers/media/platform/vsp1/vsp1_lut.c
index 57482e057e54..388bd89ade0b 100644
--- a/drivers/media/platform/vsp1/vsp1_lut.c
+++ b/drivers/media/platform/vsp1/vsp1_lut.c
@@ -213,8 +213,13 @@ static void lut_configure(struct vsp1_entity *entity,
lut->lut = NULL;
spin_unlock_irqrestore(>lock, flags);
 
-   if (dlb)
+   if (dlb) {
vsp1_dl_list_add_fragment(dl, dlb);
+
+   /* release our local reference */
+   vsp1_dl_fragment_put(dlb);
+   }
+
break;
}
 }
-- 
git-series 0.9.1


[PATCH v2 7/8] v4l: vsp1: Move video configuration to a cached dlb

2017-08-14 Thread Kieran Bingham
We are now able to configure a pipeline directly into a local display
list body. Take advantage of this fact, and create a cacheable body to
store the configuration of the pipeline in the video object.

vsp1_video_pipeline_run() is now the last user of the pipe->dl object.
Convert this function to use the cached video->config body and obtain a
local display list reference.

Attach the video->config body to the display list when needed before
committing to hardware.

The pipe object is marked as un-configured when entering a suspend. This
ensures that upon resume, where the hardware is reset - our cached
configuration will be re-attached to the next committed DL.

Signed-off-by: Kieran Bingham 
---

Our video DL usage now looks like the below output:

dl->body0 contains our disposable runtime configuration. Max 41.
dl_child->body0 is our partition specific configuration. Max 12.
dl->fragments shows our constant configuration and LUTs.

  These two are LUT/CLU:
 * dl->fragments[x]->num_entries 256 / max 256
 * dl->fragments[x]->num_entries 4914 / max 4914

Which shows that our 'constant' configuration cache is currently
utilised to a maximum of 64 entries.

trace-cmd report | \
grep max | sed 's/.*vsp1_dl_list_commit://g' | sort | uniq;

  dl->body0->num_entries 13 / max 128
  dl->body0->num_entries 14 / max 128
  dl->body0->num_entries 16 / max 128
  dl->body0->num_entries 20 / max 128
  dl->body0->num_entries 27 / max 128
  dl->body0->num_entries 34 / max 128
  dl->body0->num_entries 41 / max 128
  dl_child->body0->num_entries 10 / max 128
  dl_child->body0->num_entries 12 / max 128
  dl->fragments[x]->num_entries 15 / max 128
  dl->fragments[x]->num_entries 16 / max 128
  dl->fragments[x]->num_entries 17 / max 128
  dl->fragments[x]->num_entries 18 / max 128
  dl->fragments[x]->num_entries 20 / max 128
  dl->fragments[x]->num_entries 21 / max 128
  dl->fragments[x]->num_entries 256 / max 256
  dl->fragments[x]->num_entries 31 / max 128
  dl->fragments[x]->num_entries 32 / max 128
  dl->fragments[x]->num_entries 39 / max 128
  dl->fragments[x]->num_entries 40 / max 128
  dl->fragments[x]->num_entries 47 / max 128
  dl->fragments[x]->num_entries 48 / max 128
  dl->fragments[x]->num_entries 4914 / max 4914
  dl->fragments[x]->num_entries 55 / max 128
  dl->fragments[x]->num_entries 56 / max 128
  dl->fragments[x]->num_entries 63 / max 128
  dl->fragments[x]->num_entries 64 / max 128
---
 drivers/media/platform/vsp1/vsp1_pipe.c  |  4 +-
 drivers/media/platform/vsp1/vsp1_pipe.h  |  4 +-
 drivers/media/platform/vsp1/vsp1_video.c | 67 -
 drivers/media/platform/vsp1/vsp1_video.h |  2 +-
 4 files changed, 51 insertions(+), 26 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_pipe.c 
b/drivers/media/platform/vsp1/vsp1_pipe.c
index 5012643583b6..7d1f7ba43060 100644
--- a/drivers/media/platform/vsp1/vsp1_pipe.c
+++ b/drivers/media/platform/vsp1/vsp1_pipe.c
@@ -249,6 +249,7 @@ void vsp1_pipeline_run(struct vsp1_pipeline *pipe)
vsp1_write(vsp1, VI6_CMD(pipe->output->entity.index),
   VI6_CMD_STRCMD);
pipe->state = VSP1_PIPELINE_RUNNING;
+   pipe->configured = true;
}
 
pipe->buffers_ready = 0;
@@ -430,6 +431,9 @@ void vsp1_pipelines_suspend(struct vsp1_device *vsp1)
spin_lock_irqsave(>irqlock, flags);
if (pipe->state == VSP1_PIPELINE_RUNNING)
pipe->state = VSP1_PIPELINE_STOPPING;
+
+   /* After a suspend, the hardware will be reset */
+   pipe->configured = false;
spin_unlock_irqrestore(>irqlock, flags);
}
 
diff --git a/drivers/media/platform/vsp1/vsp1_pipe.h 
b/drivers/media/platform/vsp1/vsp1_pipe.h
index 90d29492b9b9..e7ad6211b4d0 100644
--- a/drivers/media/platform/vsp1/vsp1_pipe.h
+++ b/drivers/media/platform/vsp1/vsp1_pipe.h
@@ -90,6 +90,7 @@ struct vsp1_partition {
  * @irqlock: protects the pipeline state
  * @state: current state
  * @wq: wait queue to wait for state change completion
+ * @configured: flag determining if the hardware has run since reset
  * @frame_end: frame end interrupt handler
  * @lock: protects the pipeline use count and stream count
  * @kref: pipeline reference count
@@ -117,6 +118,7 @@ struct vsp1_pipeline {
spinlock_t irqlock;
enum vsp1_pipeline_state state;
wait_queue_head_t wq;
+   bool configured;
 
void (*frame_end)(struct vsp1_pipeline *pipe, bool completed);
 
@@ -143,8 +145,6 @@ struct vsp1_pipeline {
 */
struct list_head entities;
 
-   struct vsp1_dl_list *dl;
-
unsigned int partitions;
struct vsp1_partition *partition;
struct vsp1_partition *part_table;
diff --git a/drivers/media/platform/vsp1/vsp1_video.c 
b/drivers/media/platform/vsp1/vsp1_video.c
index 7e825f3360bf..42b70b8465ba 100644
--- 

[PATCH v2 1/8] v4l: vsp1: Protect fragments against overflow

2017-08-14 Thread Kieran Bingham
The fragment write function relies on the code never asking it to
write more than the entries available in the list.

Currently with each list body containing 256 entries, this is fine,
but we can reduce this number greatly saving memory.

In preparation of this - add a level of protection to catch any
buffer overflows.

Signed-off-by: Kieran Bingham 
---
 drivers/media/platform/vsp1/vsp1_dl.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/media/platform/vsp1/vsp1_dl.c 
b/drivers/media/platform/vsp1/vsp1_dl.c
index 8b5cbb6b7a70..cb4625ae13c2 100644
--- a/drivers/media/platform/vsp1/vsp1_dl.c
+++ b/drivers/media/platform/vsp1/vsp1_dl.c
@@ -50,6 +50,7 @@ struct vsp1_dl_entry {
  * @dma: DMA address of the entries
  * @size: size of the DMA memory in bytes
  * @num_entries: number of stored entries
+ * @max_entries: number of entries available
  */
 struct vsp1_dl_body {
struct list_head list;
@@ -60,6 +61,7 @@ struct vsp1_dl_body {
size_t size;
 
unsigned int num_entries;
+   unsigned int max_entries;
 };
 
 /**
@@ -138,6 +140,7 @@ static int vsp1_dl_body_init(struct vsp1_device *vsp1,
 
dlb->vsp1 = vsp1;
dlb->size = size;
+   dlb->max_entries = num_entries;
 
dlb->entries = dma_alloc_wc(vsp1->bus_master, dlb->size, >dma,
GFP_KERNEL);
@@ -220,6 +223,11 @@ void vsp1_dl_fragment_free(struct vsp1_dl_body *dlb)
  */
 void vsp1_dl_fragment_write(struct vsp1_dl_body *dlb, u32 reg, u32 data)
 {
+   if (unlikely(dlb->num_entries >= dlb->max_entries)) {
+   WARN_ONCE(true, "DLB size exceeded (max %u)", dlb->max_entries);
+   return;
+   }
+
dlb->entries[dlb->num_entries].addr = reg;
dlb->entries[dlb->num_entries].data = data;
dlb->num_entries++;
-- 
git-series 0.9.1


[PATCH v2 6/8] v4l: vsp1: Adapt entities to configure into a body

2017-08-14 Thread Kieran Bingham
Currently the entities store their configurations into a display list.
Adapt this such that the code can be configured into a body fragment
directly, allowing greater flexibility and control of the content.

All users of vsp1_dl_list_write() are removed in this process, thus it
too is removed.

A helper, vsp1_dl_list_body() is provided to access the internal body0
from the display list.

Signed-off-by: Kieran Bingham 
---
 drivers/media/platform/vsp1/vsp1_bru.c| 22 ++--
 drivers/media/platform/vsp1/vsp1_clu.c| 22 ++--
 drivers/media/platform/vsp1/vsp1_dl.c | 12 ++-
 drivers/media/platform/vsp1/vsp1_dl.h |  2 +-
 drivers/media/platform/vsp1/vsp1_drm.c| 14 +---
 drivers/media/platform/vsp1/vsp1_entity.c | 16 -
 drivers/media/platform/vsp1/vsp1_entity.h | 12 ---
 drivers/media/platform/vsp1/vsp1_hgo.c| 16 -
 drivers/media/platform/vsp1/vsp1_hgt.c| 18 +-
 drivers/media/platform/vsp1/vsp1_hsit.c   | 10 +++---
 drivers/media/platform/vsp1/vsp1_lif.c| 13 +++
 drivers/media/platform/vsp1/vsp1_lut.c| 21 ++--
 drivers/media/platform/vsp1/vsp1_pipe.c   |  4 +-
 drivers/media/platform/vsp1/vsp1_pipe.h   |  3 +-
 drivers/media/platform/vsp1/vsp1_rpf.c| 43 +++-
 drivers/media/platform/vsp1/vsp1_sru.c| 14 
 drivers/media/platform/vsp1/vsp1_uds.c| 24 +++--
 drivers/media/platform/vsp1/vsp1_uds.h|  2 +-
 drivers/media/platform/vsp1/vsp1_video.c  | 11 --
 drivers/media/platform/vsp1/vsp1_wpf.c| 42 ---
 20 files changed, 168 insertions(+), 153 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_bru.c 
b/drivers/media/platform/vsp1/vsp1_bru.c
index b9ff96f76b3e..652b42e3ec2d 100644
--- a/drivers/media/platform/vsp1/vsp1_bru.c
+++ b/drivers/media/platform/vsp1/vsp1_bru.c
@@ -30,10 +30,10 @@
  * Device Access
  */
 
-static inline void vsp1_bru_write(struct vsp1_bru *bru, struct vsp1_dl_list 
*dl,
- u32 reg, u32 data)
+static inline void vsp1_bru_write(struct vsp1_bru *bru,
+ struct vsp1_dl_body *dlb, u32 reg, u32 data)
 {
-   vsp1_dl_list_write(dl, bru->base + reg, data);
+   vsp1_dl_fragment_write(dlb, bru->base + reg, data);
 }
 
 /* 
-
@@ -287,7 +287,7 @@ static const struct v4l2_subdev_ops bru_ops = {
 
 static void bru_prepare(struct vsp1_entity *entity,
struct vsp1_pipeline *pipe,
-   struct vsp1_dl_list *dl)
+   struct vsp1_dl_body *dlb)
 {
struct vsp1_bru *bru = to_bru(>subdev);
struct v4l2_mbus_framefmt *format;
@@ -309,7 +309,7 @@ static void bru_prepare(struct vsp1_entity *entity,
 * format at the pipeline output is premultiplied.
 */
flags = pipe->output ? pipe->output->format.flags : 0;
-   vsp1_bru_write(bru, dl, VI6_BRU_INCTRL,
+   vsp1_bru_write(bru, dlb, VI6_BRU_INCTRL,
   flags & V4L2_PIX_FMT_FLAG_PREMUL_ALPHA ?
   0 : VI6_BRU_INCTRL_NRM);
 
@@ -317,12 +317,12 @@ static void bru_prepare(struct vsp1_entity *entity,
 * Set the background position to cover the whole output image and
 * configure its color.
 */
-   vsp1_bru_write(bru, dl, VI6_BRU_VIRRPF_SIZE,
+   vsp1_bru_write(bru, dlb, VI6_BRU_VIRRPF_SIZE,
   (format->width << VI6_BRU_VIRRPF_SIZE_HSIZE_SHIFT) |
   (format->height << VI6_BRU_VIRRPF_SIZE_VSIZE_SHIFT));
-   vsp1_bru_write(bru, dl, VI6_BRU_VIRRPF_LOC, 0);
+   vsp1_bru_write(bru, dlb, VI6_BRU_VIRRPF_LOC, 0);
 
-   vsp1_bru_write(bru, dl, VI6_BRU_VIRRPF_COL, bru->bgcolor |
+   vsp1_bru_write(bru, dlb, VI6_BRU_VIRRPF_COL, bru->bgcolor |
   (0xff << VI6_BRU_VIRRPF_COL_A_SHIFT));
 
/*
@@ -332,7 +332,7 @@ static void bru_prepare(struct vsp1_entity *entity,
 * unit.
 */
if (entity->type == VSP1_ENTITY_BRU)
-   vsp1_bru_write(bru, dl, VI6_BRU_ROP,
+   vsp1_bru_write(bru, dlb, VI6_BRU_ROP,
   VI6_BRU_ROP_DSTSEL_BRUIN(1) |
   VI6_BRU_ROP_CROP(VI6_ROP_NOP) |
   VI6_BRU_ROP_AROP(VI6_ROP_NOP));
@@ -374,7 +374,7 @@ static void bru_prepare(struct vsp1_entity *entity,
if (!(entity->type == VSP1_ENTITY_BRU && i == 1))
ctrl |= VI6_BRU_CTRL_SRCSEL_BRUIN(i);
 
-   vsp1_bru_write(bru, dl, VI6_BRU_CTRL(i), ctrl);
+   vsp1_bru_write(bru, dlb, VI6_BRU_CTRL(i), ctrl);
 
/*
 * Harcode the blending formula to
@@ -389,7 +389,7 @@ static void bru_prepare(struct vsp1_entity *entity,
 *
 * otherwise.
 */
-   

[PATCH v2 0/8] vsp1: TLB optimisation and DL caching

2017-08-14 Thread Kieran Bingham
Each display list currently allocates an area of DMA memory to store register
settings for the VSP1 to process. Each of these allocations adds pressure to
the IPMMU TLB entries.

We can reduce the pressure by pre-allocating larger areas and dividing the area
across multiple bodies represented as a pool.

With this reconfiguration of bodies, we can adapt the configuration code to
separate out constant hardware configuration and cache it for re-use.

Patch 1 adds protection to ensure that the display list body does not overflow
and will allow us to reduce the size of the body allocations in the future (it
has already helped me catch an overflow during the development of this series,
so I thought it was a worth while addition)

Patch 2 implements the fragment pool object and provides function helpers to
interact with the pool

Patch 3 converts the existing allocations to use the new fragment pool.

>From patch 4 to 7, we then refactor the display list handling code to separate
out the two stages of stream setup and frame configuration and then configure
directly into display list bodies. This allows us to cache the constant stream
configuration in a reusable display list body which also repairs suspend/resume
cycles for the video pipelines.

Finally in patch 8, the size of the internal display list body is reduced down
to 64 entries, as the maximum used is now 41 slots. The cached video pipeline
stream configuration appears to use a maximum of 64 entries, but to allow for
expansion this is set to 128 for now to prevent unexpected overflows.

Kieran Bingham (8):
  v4l: vsp1: Protect fragments against overflow
  v4l: vsp1: Provide a fragment pool
  v4l: vsp1: Convert display lists to use new fragment pool
  v4l: vsp1: Use reference counting for fragments
  v4l: vsp1: Refactor display list configure operations
  v4l: vsp1: Adapt entities to configure into a body
  v4l: vsp1: Move video configuration to a cached dlb
  v4l: vsp1: Reduce display list body size

 drivers/media/platform/vsp1/vsp1_bru.c|  32 +--
 drivers/media/platform/vsp1/vsp1_clu.c|  86 +++---
 drivers/media/platform/vsp1/vsp1_clu.h|   1 +-
 drivers/media/platform/vsp1/vsp1_dl.c | 331 ---
 drivers/media/platform/vsp1/vsp1_dl.h |  13 +-
 drivers/media/platform/vsp1/vsp1_drm.c|  21 +-
 drivers/media/platform/vsp1/vsp1_entity.c |  23 +-
 drivers/media/platform/vsp1/vsp1_entity.h |  31 +--
 drivers/media/platform/vsp1/vsp1_hgo.c|  26 +--
 drivers/media/platform/vsp1/vsp1_hgt.c|  28 +--
 drivers/media/platform/vsp1/vsp1_hsit.c   |  20 +-
 drivers/media/platform/vsp1/vsp1_lif.c|  23 +--
 drivers/media/platform/vsp1/vsp1_lut.c|  65 +++--
 drivers/media/platform/vsp1/vsp1_lut.h|   1 +-
 drivers/media/platform/vsp1/vsp1_pipe.c   |   8 +-
 drivers/media/platform/vsp1/vsp1_pipe.h   |   7 +-
 drivers/media/platform/vsp1/vsp1_rpf.c| 179 ++--
 drivers/media/platform/vsp1/vsp1_sru.c|  24 +--
 drivers/media/platform/vsp1/vsp1_uds.c|  73 ++---
 drivers/media/platform/vsp1/vsp1_uds.h|   2 +-
 drivers/media/platform/vsp1/vsp1_video.c  |  82 +++---
 drivers/media/platform/vsp1/vsp1_video.h  |   2 +-
 drivers/media/platform/vsp1/vsp1_wpf.c| 325 ---
 23 files changed, 753 insertions(+), 650 deletions(-)

base-commit: f44bd631453bf7dcbe57f79b924db3a6dd038bff
-- 
git-series 0.9.1


[PATCH v2 3/8] v4l: vsp1: Convert display lists to use new fragment pool

2017-08-14 Thread Kieran Bingham
Adapt the dl->body0 object to use an object from the fragment pool.
This greatly reduces the pressure on the TLB for IPMMU use cases, as
all of the lists use a single allocation for the main body.

The CLU and LUT objects pre-allocate a pool containing two bodies,
allowing a userspace update before the hardware has committed a previous
set of tables.

Fragments are no longer 'freed' in interrupt context, but instead
released back to their respective pools.  This allows us to remove the
garbage collector in the DLM.

Signed-off-by: Kieran Bingham 

---
v2:
 - Use dl->body0->max_entries to determine header offset, instead of the
   global constant VSP1_DL_NUM_ENTRIES which is incorrect.
 - squash updates for LUT, CLU, and fragment cleanup into single patch.
   (Not fully bisectable when separated)
---
 drivers/media/platform/vsp1/vsp1_clu.c |  22 ++-
 drivers/media/platform/vsp1/vsp1_clu.h |   1 +-
 drivers/media/platform/vsp1/vsp1_dl.c  | 223 +-
 drivers/media/platform/vsp1/vsp1_dl.h  |   3 +-
 drivers/media/platform/vsp1/vsp1_lut.c |  23 ++-
 drivers/media/platform/vsp1/vsp1_lut.h |   1 +-
 6 files changed, 90 insertions(+), 183 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_clu.c 
b/drivers/media/platform/vsp1/vsp1_clu.c
index f2fb26e5ab4e..52c523625e2f 100644
--- a/drivers/media/platform/vsp1/vsp1_clu.c
+++ b/drivers/media/platform/vsp1/vsp1_clu.c
@@ -23,6 +23,8 @@
 #define CLU_MIN_SIZE   4U
 #define CLU_MAX_SIZE   8190U
 
+#define CLU_SIZE   (17 * 17 * 17)
+
 /* 
-
  * Device Access
  */
@@ -47,19 +49,19 @@ static int clu_set_table(struct vsp1_clu *clu, struct 
v4l2_ctrl *ctrl)
struct vsp1_dl_body *dlb;
unsigned int i;
 
-   dlb = vsp1_dl_fragment_alloc(clu->entity.vsp1, 1 + 17 * 17 * 17);
+   dlb = vsp1_dl_fragment_get(clu->pool);
if (!dlb)
return -ENOMEM;
 
vsp1_dl_fragment_write(dlb, VI6_CLU_ADDR, 0);
-   for (i = 0; i < 17 * 17 * 17; ++i)
+   for (i = 0; i < CLU_SIZE; ++i)
vsp1_dl_fragment_write(dlb, VI6_CLU_DATA, ctrl->p_new.p_u32[i]);
 
spin_lock_irq(>lock);
swap(clu->clu, dlb);
spin_unlock_irq(>lock);
 
-   vsp1_dl_fragment_free(dlb);
+   vsp1_dl_fragment_put(dlb);
return 0;
 }
 
@@ -261,8 +263,16 @@ static void clu_configure(struct vsp1_entity *entity,
}
 }
 
+static void clu_destroy(struct vsp1_entity *entity)
+{
+   struct vsp1_clu *clu = to_clu(>subdev);
+
+   vsp1_dl_fragment_pool_free(clu->pool);
+}
+
 static const struct vsp1_entity_operations clu_entity_ops = {
.configure = clu_configure,
+   .destroy = clu_destroy,
 };
 
 /* 
-
@@ -288,6 +298,12 @@ struct vsp1_clu *vsp1_clu_create(struct vsp1_device *vsp1)
if (ret < 0)
return ERR_PTR(ret);
 
+   /* Allocate a fragment pool */
+   clu->pool = vsp1_dl_fragment_pool_alloc(clu->entity.vsp1, 2,
+   CLU_SIZE + 1, 0);
+   if (!clu->pool)
+   return ERR_PTR(-ENOMEM);
+
/* Initialize the control handler. */
v4l2_ctrl_handler_init(>ctrls, 2);
v4l2_ctrl_new_custom(>ctrls, _table_control, NULL);
diff --git a/drivers/media/platform/vsp1/vsp1_clu.h 
b/drivers/media/platform/vsp1/vsp1_clu.h
index 036e0a2f1a42..601ffb558e30 100644
--- a/drivers/media/platform/vsp1/vsp1_clu.h
+++ b/drivers/media/platform/vsp1/vsp1_clu.h
@@ -36,6 +36,7 @@ struct vsp1_clu {
spinlock_t lock;
unsigned int mode;
struct vsp1_dl_body *clu;
+   struct vsp1_dl_fragment_pool *pool;
 };
 
 static inline struct vsp1_clu *to_clu(struct v4l2_subdev *subdev)
diff --git a/drivers/media/platform/vsp1/vsp1_dl.c 
b/drivers/media/platform/vsp1/vsp1_dl.c
index aab9dd6ec0eb..6ffdc3549283 100644
--- a/drivers/media/platform/vsp1/vsp1_dl.c
+++ b/drivers/media/platform/vsp1/vsp1_dl.c
@@ -110,7 +110,7 @@ struct vsp1_dl_list {
struct vsp1_dl_header *header;
dma_addr_t dma;
 
-   struct vsp1_dl_body body0;
+   struct vsp1_dl_body *body0;
struct list_head fragments;
 
bool has_chain;
@@ -134,8 +134,6 @@ enum vsp1_dl_mode {
  * @queued: list queued to the hardware (written to the DL registers)
  * @pending: list waiting to be queued to the hardware
  * @pool: fragment pool for the display list bodies
- * @gc_work: fragments garbage collector work struct
- * @gc_fragments: array of display list fragments waiting to be freed
  */
 struct vsp1_dl_manager {
unsigned int index;
@@ -150,9 +148,6 @@ struct vsp1_dl_manager {
struct vsp1_dl_list *pending;
 
struct vsp1_dl_fragment_pool *pool;
-
-   struct work_struct gc_work;
-   struct list_head 

[GIT PULL FOR v4.14] More constify, uvc and some random patches

2017-08-14 Thread Hans Verkuil
The following changes since commit ec0c3ec497cabbf3bfa03a9eb5edcc252190a4e0:

  media: ddbridge: split code into multiple files (2017-08-09 12:17:01 -0400)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git for-v4.14h

for you to fetch changes up to 23d405327ef551c42cb21c73405710e01a19a9dd:

  v4l2-compat-ioctl32.c: add capabilities field to, v4l2_input32 (2017-08-14 
15:39:33 +0200)


Guennadi Liakhovetski (2):
  uvcvideo: Fix .queue_setup() to check the number of planes
  uvcvideo: Convert from using an atomic variable to a reference count

Guenter Roeck (1):
  uvcvideo: Prevent heap overflow when accessing mapped controls

Hans Verkuil (1):
  v4l2-compat-ioctl32.c: add capabilities field to, v4l2_input32

Jim Lin (1):
  uvcvideo: Fix incorrect timeout for Get Request

Julia Lawall (5):
  cx18: constify videobuf_queue_ops structures
  cx231xx: constify videobuf_queue_ops structures
  tm6000: constify videobuf_queue_ops structures
  zr364xx: constify videobuf_queue_ops structures
  uvcvideo: Constify video_subdev structures

Mauro Carvalho Chehab (1):
  media: v4l2-ctrls.h: better document the arguments for v4l2_ctrl_fill

 drivers/media/pci/cx18/cx18-streams.c |  2 +-
 drivers/media/usb/cx231xx/cx231xx-417.c   |  2 +-
 drivers/media/usb/cx231xx/cx231xx-video.c |  2 +-
 drivers/media/usb/tm6000/tm6000-video.c   |  2 +-
 drivers/media/usb/uvc/uvc_ctrl.c  |  7 +++
 drivers/media/usb/uvc/uvc_driver.c| 25 +
 drivers/media/usb/uvc/uvc_entity.c|  2 +-
 drivers/media/usb/uvc/uvc_queue.c |  9 +++--
 drivers/media/usb/uvc/uvcvideo.h  |  4 ++--
 drivers/media/usb/zr364xx/zr364xx.c   |  2 +-
 drivers/media/v4l2-core/v4l2-compat-ioctl32.c |  3 ++-
 include/media/v4l2-ctrls.h| 16 
 12 files changed, 41 insertions(+), 35 deletions(-)


Re: [PATCH v1.2 1/1] omap3isp: Skip CSI-2 receiver initialisation in CCP2 configuration

2017-08-14 Thread Laurent Pinchart
Hi Sakari,

On Monday 14 Aug 2017 13:53:27 Sakari Ailus wrote:
> On Fri, Aug 11, 2017 at 02:32:00PM +0300, Laurent Pinchart wrote:
> > On Friday 11 Aug 2017 12:57:09 Sakari Ailus wrote:
> >> If the CSI-2 receiver isn't part of the pipeline (or isn't there to
> >> begin with), skip its initialisation.
> > 
> > I don't think the commit message really describes the patch.
> > 
> >> Signed-off-by: Sakari Ailus 
> >> Tested-by: Laurent Pinchart  # on
> >> Beagleboard-xM + MPT9P031 Acked-by: Pavel Machek 
> >> ---
> >> since v1.1:
> >> 
> >> - Assign phy->entity before calling omap3isp_csiphy_config(), for
> >> 
> >>   phy->entity is used by omap3isp_csiphy_config(). (Thanks to Pavel for
> >>   spotting this.)
> >>  
> >>  drivers/media/platform/omap3isp/ispccp2.c   |  2 +-
> >>  drivers/media/platform/omap3isp/ispcsi2.c   |  4 +--
> >>  drivers/media/platform/omap3isp/ispcsiphy.c | 38 ++
> >>  drivers/media/platform/omap3isp/ispcsiphy.h |  6 +++--
> >>  4 files changed, 27 insertions(+), 23 deletions(-)
> >> 

[snip]

> >> diff --git a/drivers/media/platform/omap3isp/ispcsiphy.c
> >> b/drivers/media/platform/omap3isp/ispcsiphy.c index
> >> 2028bb519108..aedd88fa8246 100644
> >> --- a/drivers/media/platform/omap3isp/ispcsiphy.c
> >> +++ b/drivers/media/platform/omap3isp/ispcsiphy.c
> >> @@ -164,15 +164,18 @@ static int csiphy_set_power(struct isp_csiphy
> >> *phy, u32 power)
> >> 
> >>  static int omap3isp_csiphy_config(struct isp_csiphy *phy)
> >>  {
> >> -  struct isp_csi2_device *csi2 = phy->csi2;
> >> -  struct isp_pipeline *pipe = to_isp_pipeline(>subdev.entity);
> >> -  struct isp_bus_cfg *buscfg = pipe->external->host_priv;
> >> +  struct isp_pipeline *pipe = to_isp_pipeline(phy->entity);
> >> +  struct isp_bus_cfg *buscfg;
> >>struct isp_csiphy_lanes_cfg *lanes;
> >>int csi2_ddrclk_khz;
> >>unsigned int num_data_lanes, used_lanes = 0;
> >>unsigned int i;
> >>u32 reg;
> >> 
> >> +  if (!pipe)
> >> +  return -EBUSY;
> > 
> > When can this happen ?
> 
> It shouldn't. Just in case, it'd be a driver bug if it did. What would you
> think of adding WARN_ON() here?

I throw WARN_ON()s in when I believe that driver could get it wrong. In this 
particular case, given that this function is called from .s_stream() handlers 
only, I wonder if the check makes sense at all.

> >> +  buscfg = pipe->external->host_priv;
> >>if (!buscfg) {
> >>struct isp_async_subdev *isd =
> >>container_of(pipe->external->asd,

[snip]

-- 
Regards,

Laurent Pinchart



[GIT PULL FOR v4.14] constify patches

2017-08-14 Thread Hans Verkuil
The following changes since commit ec0c3ec497cabbf3bfa03a9eb5edcc252190a4e0:

  media: ddbridge: split code into multiple files (2017-08-09 12:17:01 -0400)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git for-v4.14g

for you to fetch changes up to 4dc5ba647aa4ee895fc4b905cace9e9a15fa037b:

  pxa_camera: constify v4l2_clk_ops structure (2017-08-14 14:58:42 +0200)


Arvind Yadav (2):
  usb: constify usb_device_id
  radio: constify usb_device_id

Bhumika Goyal (3):
  usb: make snd_pcm_hardware const
  pci: make snd_pcm_hardware const
  tuners: make snd_pcm_hardware const

Julia Lawall (21):
  v4l2-pci-skeleton: constify vb2_ops structures
  media: davinci: vpbe: constify vb2_ops structures
  staging: media: davinci_vpfe: constify vb2_ops structures
  media: blackfin: bfin_capture: constify vb2_ops structures
  media: imx: capture: constify vb2_ops structures
  st-delta: constify v4l2_m2m_ops structures
  media: ti-vpe: vpe: constify v4l2_m2m_ops structures
  s5p-g2d: constify v4l2_m2m_ops structures
  V4L2: platform: rcar_jpu: constify v4l2_m2m_ops structures
  vcodec: mediatek: constify v4l2_m2m_ops structures
  exynos-gsc: constify v4l2_m2m_ops structures
  bdisp: constify v4l2_m2m_ops structures
  m2m-deinterlace: constify v4l2_m2m_ops structures
  media: mx2-emmaprp: constify v4l2_m2m_ops structures
  vim2m: constify v4l2_m2m_ops structures
  exynos4-is: constify v4l2_m2m_ops structures
  mtk-mdp: constify v4l2_m2m_ops structures
  vimc: constify video_subdev structures
  exynos4-is: constify video_subdev structures
  v4l2: av7110_v4l: constify v4l2_audio structure
  pxa_camera: constify v4l2_clk_ops structure

 drivers/media/pci/cobalt/cobalt-alsa-pcm.c| 4 ++--
 drivers/media/pci/cx18/cx18-alsa-pcm.c| 2 +-
 drivers/media/pci/cx23885/cx23885-alsa.c  | 2 +-
 drivers/media/pci/cx25821/cx25821-alsa.c  | 2 +-
 drivers/media/pci/ivtv/ivtv-alsa-pcm.c| 2 +-
 drivers/media/pci/saa7134/saa7134-alsa.c  | 2 +-
 drivers/media/pci/ttpci/av7110_v4l.c  | 2 +-
 drivers/media/platform/blackfin/bfin_capture.c| 2 +-
 drivers/media/platform/davinci/vpbe_display.c | 2 +-
 drivers/media/platform/exynos-gsc/gsc-m2m.c   | 2 +-
 drivers/media/platform/exynos4-is/fimc-isp.c  | 2 +-
 drivers/media/platform/exynos4-is/fimc-lite.c | 2 +-
 drivers/media/platform/exynos4-is/fimc-m2m.c  | 2 +-
 drivers/media/platform/m2m-deinterlace.c  | 2 +-
 drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c   | 2 +-
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c  | 2 +-
 drivers/media/platform/mx2_emmaprp.c  | 2 +-
 drivers/media/platform/pxa_camera.c   | 2 +-
 drivers/media/platform/rcar_jpu.c | 2 +-
 drivers/media/platform/s5p-g2d/g2d.c  | 2 +-
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c | 2 +-
 drivers/media/platform/sti/delta/delta-v4l2.c | 2 +-
 drivers/media/platform/ti-vpe/vpe.c   | 2 +-
 drivers/media/platform/vim2m.c| 2 +-
 drivers/media/platform/vimc/vimc-debayer.c| 2 +-
 drivers/media/platform/vimc/vimc-scaler.c | 2 +-
 drivers/media/platform/vimc/vimc-sensor.c | 2 +-
 drivers/media/radio/dsbr100.c | 2 +-
 drivers/media/radio/radio-keene.c | 2 +-
 drivers/media/radio/radio-ma901.c | 2 +-
 drivers/media/radio/radio-mr800.c | 2 +-
 drivers/media/radio/radio-raremono.c  | 2 +-
 drivers/media/radio/radio-shark.c | 2 +-
 drivers/media/radio/radio-shark2.c| 2 +-
 drivers/media/radio/si470x/radio-si470x-usb.c | 2 +-
 drivers/media/radio/si4713/radio-usb-si4713.c | 2 +-
 drivers/media/tuners/tda18271-maps.c  | 4 ++--
 drivers/media/usb/airspy/airspy.c | 2 +-
 drivers/media/usb/as102/as102_usb_drv.c   | 2 +-
 drivers/media/usb/b2c2/flexcop-usb.c  | 2 +-
 drivers/media/usb/cpia2/cpia2_usb.c   | 2 +-
 drivers/media/usb/cx231xx/cx231xx-audio.c | 2 +-
 drivers/media/usb/dvb-usb-v2/az6007.c | 2 +-
 drivers/media/usb/em28xx/em28xx-audio.c   | 2 +-
 drivers/media/usb/go7007/snd-go7007.c | 2 +-
 drivers/media/usb/hackrf/hackrf.c | 2 +-
 drivers/media/usb/hdpvr/hdpvr-core.c  | 2 +-
 drivers/media/usb/msi2500/msi2500.c   | 2 +-
 drivers/media/usb/s2255/s2255drv.c| 2 +-
 drivers/media/usb/stk1160/stk1160-core.c  | 2 +-
 drivers/media/usb/stkwebcam/stk-webcam.c  | 2 +-
 drivers/media/usb/tm6000/tm6000-alsa.c| 2 +-
 drivers/media/usb/tm6000/tm6000-cards.c   | 2 +-
 drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c | 2 +-
 

si2168 b40 and lack of auto plp

2017-08-14 Thread Torbjorn Jansson

Hello

a few questions
is there any card out there with a si2168 b40 in a country that uses plp!=0 
that dvb-t2 actually works for?

i suspect the answer to this is no and that it is broken on all cards.

auto plp appears broken anyway on my ct2-4650 with si2168 b40 and has been 
broken for a long time.




i have done a number of things to try to figure out whats going on.
first i have extracted the firmware for si2168 b40 used by the windows driver 
and this matches exactly with:

http://palosaari.fi/linux/v4l-dvb/firmware/Si2168/Si2168-B40/4.0.25/dvb-demod-si2168-b40-01.fw
which is the one i use on my linux box, so firmware should theoretically be ok.

then i used debugfs to turn on the extra debugging in si2168, i was mainly 
interested in verifying what plp the scanning software actually sent to the 
driver (si2168_set_frontend)


i then found out that both dvbv5-scan and w_scan both appear to use 
stream_id=0, i then made a quick and dirty hack to w_scan so it always sets plp 
id to 1 instead of 0 and this resulted for the first time in a lock on a dvb-t2 mux


so problem i have with this card appears to be the lack of auto plp and also 
the fact that all scanning programs i have tried so far doesn't really know how 
to handle plp by themselves and expect driver to do the right thing.



i assume this is a problem that is best fixed in the driver? right?
or is the software using the dvb card expected to somehow figure out plp and 
sett it correctly?


is there a way to dump what commands the windows driver is sending? if so 
perhaps something could be figured out how it sets plp.



(please keep me on CC when replying to list so i don't miss it)


[PATCH] [media] media: imx: depends on V4L2 sub-device userspace API

2017-08-14 Thread Cihangir Akturk
This driver uses various v4l2_subdev_get_try_*() functions provided by
V4L2 sub-device userspace API. Current configuration of Kconfig file
allows us to enable VIDEO_IMX_MEDIA without enabling this API. This
breaks the build of driver.

Depend on VIDEO_V4L2_SUBDEV_API to fix this issue.

Signed-off-by: Cihangir Akturk 
---
 drivers/staging/media/imx/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/imx/Kconfig 
b/drivers/staging/media/imx/Kconfig
index 7eff50b..d8c3890 100644
--- a/drivers/staging/media/imx/Kconfig
+++ b/drivers/staging/media/imx/Kconfig
@@ -1,6 +1,7 @@
 config VIDEO_IMX_MEDIA
tristate "i.MX5/6 V4L2 media core driver"
-   depends on MEDIA_CONTROLLER && VIDEO_V4L2 && ARCH_MXC && IMX_IPUV3_CORE
+   depends on MEDIA_CONTROLLER && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && \
+   ARCH_MXC && IMX_IPUV3_CORE
select V4L2_FWNODE
---help---
  Say yes here to enable support for video4linux media controller
-- 
2.7.4



Re: [PATCH v1.2 1/1] omap3isp: Skip CSI-2 receiver initialisation in CCP2 configuration

2017-08-14 Thread Sakari Ailus
On Fri, Aug 11, 2017 at 02:32:00PM +0300, Laurent Pinchart wrote:
> > +   if (!pipe)
> > +   return -EBUSY;
> 
> When can this happen ?

And this test should be for phy->entity instead.

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi


Re: [PATCH v1.2 1/1] omap3isp: Skip CSI-2 receiver initialisation in CCP2 configuration

2017-08-14 Thread Sakari Ailus
Hi Laurent,

On Fri, Aug 11, 2017 at 02:32:00PM +0300, Laurent Pinchart wrote:
> Hi Sakari,
> 
> Thank you for the patch.
> 
> On Friday 11 Aug 2017 12:57:09 Sakari Ailus wrote:
> > If the CSI-2 receiver isn't part of the pipeline (or isn't there to begin
> > with), skip its initialisation.
> 
> I don't think the commit message really describes the patch.
> 
> > Signed-off-by: Sakari Ailus 
> > Tested-by: Laurent Pinchart  # on
> > Beagleboard-xM + MPT9P031 Acked-by: Pavel Machek 
> > ---
> > since v1.1:
> > 
> > - Assign phy->entity before calling omap3isp_csiphy_config(), for
> >   phy->entity is used by omap3isp_csiphy_config(). (Thanks to Pavel for
> >   spotting this.)
> > 
> >  drivers/media/platform/omap3isp/ispccp2.c   |  2 +-
> >  drivers/media/platform/omap3isp/ispcsi2.c   |  4 +--
> >  drivers/media/platform/omap3isp/ispcsiphy.c | 38 --
> >  drivers/media/platform/omap3isp/ispcsiphy.h |  6 +++--
> >  4 files changed, 27 insertions(+), 23 deletions(-)
> > 
> > diff --git a/drivers/media/platform/omap3isp/ispccp2.c
> > b/drivers/media/platform/omap3isp/ispccp2.c index
> > 47210b102bcb..3db8df09cd9a 100644
> > --- a/drivers/media/platform/omap3isp/ispccp2.c
> > +++ b/drivers/media/platform/omap3isp/ispccp2.c
> > @@ -841,7 +841,7 @@ static int ccp2_s_stream(struct v4l2_subdev *sd, int
> > enable) switch (enable) {
> > case ISP_PIPELINE_STREAM_CONTINUOUS:
> > if (ccp2->phy) {
> > -   ret = omap3isp_csiphy_acquire(ccp2->phy);
> > +   ret = omap3isp_csiphy_acquire(ccp2->phy, >entity);
> > if (ret < 0)
> > return ret;
> > }
> > diff --git a/drivers/media/platform/omap3isp/ispcsi2.c
> > b/drivers/media/platform/omap3isp/ispcsi2.c index
> > 7dae2fe0d42d..3ec37fed710b 100644
> > --- a/drivers/media/platform/omap3isp/ispcsi2.c
> > +++ b/drivers/media/platform/omap3isp/ispcsi2.c
> > @@ -490,7 +490,7 @@ int omap3isp_csi2_reset(struct isp_csi2_device *csi2)
> > if (!csi2->available)
> > return -ENODEV;
> > 
> > -   if (csi2->phy->phy_in_use)
> > +   if (csi2->phy->entity)
> > return -EBUSY;
> > 
> > isp_reg_set(isp, csi2->regs1, ISPCSI2_SYSCONFIG,
> > @@ -1053,7 +1053,7 @@ static int csi2_set_stream(struct v4l2_subdev *sd, int
> > enable)
> > 
> > switch (enable) {
> > case ISP_PIPELINE_STREAM_CONTINUOUS:
> > -   if (omap3isp_csiphy_acquire(csi2->phy) < 0)
> > +   if (omap3isp_csiphy_acquire(csi2->phy, >entity) < 0)
> > return -ENODEV;
> > if (csi2->output & CSI2_OUTPUT_MEMORY)
> > omap3isp_sbl_enable(isp, OMAP3_ISP_SBL_CSI2A_WRITE);
> > diff --git a/drivers/media/platform/omap3isp/ispcsiphy.c
> > b/drivers/media/platform/omap3isp/ispcsiphy.c index
> > 2028bb519108..aedd88fa8246 100644
> > --- a/drivers/media/platform/omap3isp/ispcsiphy.c
> > +++ b/drivers/media/platform/omap3isp/ispcsiphy.c
> > @@ -164,15 +164,18 @@ static int csiphy_set_power(struct isp_csiphy *phy,
> > u32 power)
> > 
> >  static int omap3isp_csiphy_config(struct isp_csiphy *phy)
> >  {
> > -   struct isp_csi2_device *csi2 = phy->csi2;
> > -   struct isp_pipeline *pipe = to_isp_pipeline(>subdev.entity);
> > -   struct isp_bus_cfg *buscfg = pipe->external->host_priv;
> > +   struct isp_pipeline *pipe = to_isp_pipeline(phy->entity);
> > +   struct isp_bus_cfg *buscfg;
> > struct isp_csiphy_lanes_cfg *lanes;
> > int csi2_ddrclk_khz;
> > unsigned int num_data_lanes, used_lanes = 0;
> > unsigned int i;
> > u32 reg;
> > 
> > +   if (!pipe)
> > +   return -EBUSY;
> 
> When can this happen ?

It shouldn't. Just in case, it'd be a driver bug if it did. What would you
think of adding WARN_ON() here?

> 
> > +   buscfg = pipe->external->host_priv;
> > if (!buscfg) {
> > struct isp_async_subdev *isd =
> > container_of(pipe->external->asd,
> > @@ -222,7 +225,7 @@ static int omap3isp_csiphy_config(struct isp_csiphy
> > *phy) csi2_ddrclk_khz = pipe->external_rate / 1000
> > / (2 * hweight32(used_lanes)) * pipe->external_width;
> > 
> > -   reg = isp_reg_readl(csi2->isp, phy->phy_regs, ISPCSIPHY_REG0);
> > +   reg = isp_reg_readl(phy->isp, phy->phy_regs, ISPCSIPHY_REG0);
> > 
> > reg &= ~(ISPCSIPHY_REG0_THS_TERM_MASK |
> >  ISPCSIPHY_REG0_THS_SETTLE_MASK);
> > @@ -233,9 +236,9 @@ static int omap3isp_csiphy_config(struct isp_csiphy
> > *phy) reg |= (DIV_ROUND_UP(90 * csi2_ddrclk_khz, 100) + 3)
> > << ISPCSIPHY_REG0_THS_SETTLE_SHIFT;
> > 
> > -   isp_reg_writel(csi2->isp, reg, phy->phy_regs, ISPCSIPHY_REG0);
> > +   isp_reg_writel(phy->isp, reg, phy->phy_regs, ISPCSIPHY_REG0);
> > 
> > -   reg = isp_reg_readl(csi2->isp, phy->phy_regs, ISPCSIPHY_REG1);
> > +   reg = isp_reg_readl(phy->isp, phy->phy_regs, ISPCSIPHY_REG1);
> > 
> > reg 

[PATCH 3/3] v4l: fwnode: Use a less clash-prone name for MAX_DATA_LANES macro

2017-08-14 Thread Sakari Ailus
Avoid using a generic name such as MAX_DATA_LANES in a header file widely
included in drivers. Instead, call it V4L2_FWNODE_CSI2_MAX_DATA_LANES.

Fixes: 4ee236219f6d ("media: v4l2-fwnode: suppress a warning at OF parsing 
logic")
Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 5 +++--
 include/media/v4l2-fwnode.h   | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index df7169b5ed8c..40b2fbfe8865 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -48,9 +48,10 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
 
rval = fwnode_property_read_u32_array(fwnode, "data-lanes", NULL, 0);
if (rval > 0) {
-   u32 array[1 + MAX_DATA_LANES];
+   u32 array[1 + V4L2_FWNODE_CSI2_MAX_DATA_LANES];
 
-   bus->num_data_lanes = min_t(int, MAX_DATA_LANES, rval);
+   bus->num_data_lanes =
+   min_t(int, V4L2_FWNODE_CSI2_MAX_DATA_LANES, rval);
 
fwnode_property_read_u32_array(fwnode, "data-lanes", array,
   bus->num_data_lanes);
diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h
index 08e743fb7944..7adec9851d9e 100644
--- a/include/media/v4l2-fwnode.h
+++ b/include/media/v4l2-fwnode.h
@@ -26,7 +26,7 @@
 
 struct fwnode_handle;
 
-#define MAX_DATA_LANES 4
+#define V4L2_FWNODE_CSI2_MAX_DATA_LANES4
 
 /**
  * struct v4l2_fwnode_bus_mipi_csi2 - MIPI CSI-2 bus data structure
@@ -39,10 +39,10 @@ struct fwnode_handle;
  */
 struct v4l2_fwnode_bus_mipi_csi2 {
unsigned int flags;
-   unsigned char data_lanes[MAX_DATA_LANES];
+   unsigned char data_lanes[V4L2_FWNODE_CSI2_MAX_DATA_LANES];
unsigned char clock_lane;
unsigned short num_data_lanes;
-   bool lane_polarities[1 + MAX_DATA_LANES];
+   bool lane_polarities[1 + V4L2_FWNODE_CSI2_MAX_DATA_LANES];
 };
 
 /**
-- 
2.11.0



[PATCH 2/2] v4l: fwnode: The clock lane is the first lane in lane_polarities

2017-08-14 Thread Sakari Ailus
The clock lane is the first lane in the lane_polarities array. Reflect this
consistently by putting the number of data lanes after the number of clock
lanes.

Fixes: 4ee236219f6d ("media: v4l2-fwnode: suppress a warning at OF parsing 
logic")
Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 2 +-
 include/media/v4l2-fwnode.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 29e41312f04a..c9147ec398b3 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -48,7 +48,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
 
rval = fwnode_property_read_u32_array(fwnode, "data-lanes", NULL, 0);
if (rval > 0) {
-   u32 array[MAX_DATA_LANES + 1];
+   u32 array[1 + MAX_DATA_LANES];
 
bus->num_data_lanes = min_t(int, MAX_DATA_LANES, rval);
 
diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h
index b373c43f65e8..8da716a6a1b8 100644
--- a/include/media/v4l2-fwnode.h
+++ b/include/media/v4l2-fwnode.h
@@ -42,7 +42,7 @@ struct v4l2_fwnode_bus_mipi_csi2 {
unsigned char data_lanes[MAX_DATA_LANES];
unsigned char clock_lane;
unsigned short num_data_lanes;
-   bool lane_polarities[MAX_DATA_LANES + 1];
+   bool lane_polarities[1 + MAX_DATA_LANES];
 };
 
 /**
-- 
2.11.0



[PATCH 0/2] [PATCH 0/2] Bugfix for the fwnode smatch warning fix

2017-08-14 Thread Sakari Ailus
Hi folks,

Here's a few patches to address a subtle but serious bug introduced in the
fwnode smatch warning fix. The first patch fixes a bug whereas the second
one returns the way the lane polarity array size is calculatated consistent
across V4L2 fwnode.

Sakari Ailus (2):
  v4l: fwnode: Fix lane-polarities property parsing
  v4l: fwnode: The clock lane is the first lane in lane_polarities

 drivers/media/v4l2-core/v4l2-fwnode.c | 12 
 include/media/v4l2-fwnode.h   |  2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)

-- 
2.11.0



[PATCH 1/2] v4l: fwnode: Fix lane-polarities property parsing

2017-08-14 Thread Sakari Ailus
fwnode_property_read_u32_array() only returns the number of array elements
if the array argument is NULL. The assumption that it always did so lead to
lane-polarities properties never being read.

Fixes: 4ee236219f6d ("media: v4l2-fwnode: suppress a warning at OF parsing 
logic")
Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index d07c54efaa99..29e41312f04a 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -65,19 +65,23 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
}
 
rval = fwnode_property_read_u32_array(fwnode,
- "lane-polarities", array,
- 1 + bus->num_data_lanes);
+ "lane-polarities", NULL,
+ 0);
if (rval > 0) {
-   if (rval != 1 + bus->num_data_lanes /* clock + data */) 
{
+   if (rval != 1 + bus->num_data_lanes /* clock+data */) {
pr_warn("invalid number of lane-polarities 
entries (need %u, got %u)\n",
1 + bus->num_data_lanes, rval);
return -EINVAL;
}
 
+   fwnode_property_read_u32_array(fwnode,
+  "lane-polarities", array,
+  1 + bus->num_data_lanes);
 
for (i = 0; i < 1 + bus->num_data_lanes; i++)
bus->lane_polarities[i] = array[i];
}
+
}
 
if (!fwnode_property_read_u32(fwnode, "clock-lanes", )) {
-- 
2.11.0



[RFC PATCH] media: vb2: add bidirectional flag in vb2_queue

2017-08-14 Thread Stanimir Varbanov
Hi,

This RFC patch is intended to give to the drivers a choice to change
the default behavior of the v4l2-core DMA mapping direction from
DMA_TO/FROM_DEVICE (depending on the buffer type CAPTURE or OUTPUT)
to DMA_BIDIRECTIONAL during queue_init time.

Initially the issue with DMA mapping direction has been found in
Venus encoder driver where the firmware side of the driver adds few
lines padding on bottom of the image buffer, and the consequence was
triggering of IOMMU protection faults. 

Probably other drivers could also has a benefit of this feature (hint)
in the future.

Signed-off-by: Stanimir Varbanov 
---
 drivers/media/v4l2-core/videobuf2-core.c |  3 +++
 include/media/videobuf2-core.h   | 11 +++
 2 files changed, 14 insertions(+)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 14f83cecfa92..17d07fda4cdc 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -200,6 +200,9 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
int plane;
int ret = -ENOMEM;
 
+   if (q->bidirectional)
+   dma_dir = DMA_BIDIRECTIONAL;
+
/*
 * Allocate memory for all planes in this buffer
 * NOTE: mmapped areas should be page aligned
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index cb97c224be73..0b6e88e1aa79 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -427,6 +427,16 @@ struct vb2_buf_ops {
  * @dev:   device to use for the default allocation context if the driver
  * doesn't fill in the @alloc_devs array.
  * @dma_attrs: DMA attributes to use for the DMA.
+ * @bidirectional: when this flag is set the DMA direction for the buffers of
+ * this queue will be overridden with DMA_BIDIRECTIONAL direction.
+ * This is useful in cases where the hardware (firmware) writes to
+ * a buffer which is mapped as read (DMA_TO_DEVICE), or reads from
+ * buffer which is mapped for write (DMA_FROM_DEVICE) in order
+ * to satisfy some internal hardware restrictions or adds a padding
+ * needed by the processing algorithm. In case the DMA mapping is
+ * not bidirectional but the hardware (firmware) trying to access
+ * the buffer (in the opposite direction) this could lead to an
+ * IOMMU protection faults.
  * @fileio_read_once:  report EOF after reading the first buffer
  * @fileio_write_immediately:  queue buffer after each write() call
  * @allow_zero_bytesused:  allow bytesused == 0 to be passed to the driver
@@ -495,6 +505,7 @@ struct vb2_queue {
unsigned intio_modes;
struct device   *dev;
unsigned long   dma_attrs;
+   unsignedbidirectional:1;
unsignedfileio_read_once:1;
unsignedfileio_write_immediately:1;
unsignedallow_zero_bytesused:1;
-- 
2.11.0



Re: [PATCH] [media] media: imx: use setup_timer

2017-08-14 Thread Philipp Zabel
On Sun, 2017-08-13 at 21:39 +0300, Cihangir Akturk wrote:
> Use setup_timer function instead of initializing timer with the
> function and data fields.
> 
> Generated by: scripts/coccinelle/api/setup_timer.cocci.
> 
> Signed-off-by: Cihangir Akturk 
> ---
>  drivers/staging/media/imx/imx-ic-prpencvf.c | 5 ++---
>  drivers/staging/media/imx/imx-media-csi.c   | 5 ++---
>  2 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c
> b/drivers/staging/media/imx/imx-ic-prpencvf.c
> index ed363fe..65f5729 100644
> --- a/drivers/staging/media/imx/imx-ic-prpencvf.c
> +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
> @@ -1278,9 +1278,8 @@ static int prp_init(struct imx_ic_priv
> *ic_priv)
>   priv->ic_priv = ic_priv;
>  
>   spin_lock_init(>irqlock);
> - init_timer(>eof_timeout_timer);
> - priv->eof_timeout_timer.data = (unsigned long)priv;
> - priv->eof_timeout_timer.function = prp_eof_timeout;
> + setup_timer(>eof_timeout_timer, prp_eof_timeout,
> + (unsigned long)priv);
>  
>   priv->vdev = imx_media_capture_device_init(_priv->sd,
>      PRPENCVF_SRC_PAD)
> ;
> diff --git a/drivers/staging/media/imx/imx-media-csi.c
> b/drivers/staging/media/imx/imx-media-csi.c
> index a2d2669..8fef5f1 100644
> --- a/drivers/staging/media/imx/imx-media-csi.c
> +++ b/drivers/staging/media/imx/imx-media-csi.c
> @@ -1731,9 +1731,8 @@ static int imx_csi_probe(struct platform_device
> *pdev)
>   priv->csi_id = pdata->csi;
>   priv->smfc_id = (priv->csi_id == 0) ? 0 : 2;
>  
> - init_timer(>eof_timeout_timer);
> - priv->eof_timeout_timer.data = (unsigned long)priv;
> - priv->eof_timeout_timer.function = csi_idmac_eof_timeout;
> + setup_timer(>eof_timeout_timer, csi_idmac_eof_timeout,
> + (unsigned long)priv);
>   spin_lock_init(>irqlock);
>  
>   v4l2_subdev_init(>sd, _subdev_ops);

Reviewed-by: Philipp Zabel 

regards
Philipp


[PATCH] [media] pxa_camera: constify v4l2_clk_ops structure

2017-08-14 Thread Julia Lawall
This v4l2_clk_ops structure is only passed as the first argument of
v4l2_clk_register, which is const, so the v4l2_clk_ops structure can
also be const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall 

---
 drivers/media/platform/pxa_camera.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/pxa_camera.c 
b/drivers/media/platform/pxa_camera.c
index 0d4af6d..4a800a4 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -2100,7 +2100,7 @@ static int pxac_fops_camera_release(struct file *filp)
.vidioc_unsubscribe_event   = v4l2_event_unsubscribe,
 };
 
-static struct v4l2_clk_ops pxa_camera_mclk_ops = {
+static const struct v4l2_clk_ops pxa_camera_mclk_ops = {
 };
 
 static const struct video_device pxa_camera_videodev_template = {



[PATCH] [media] v4l2: av7110_v4l: constify v4l2_audio structure

2017-08-14 Thread Julia Lawall
This v4l2_audio structure is only copied into other structures,
so it can be const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall 

---
 drivers/media/pci/ttpci/av7110_v4l.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/ttpci/av7110_v4l.c 
b/drivers/media/pci/ttpci/av7110_v4l.c
index 397fe14..e4cf42c 100644
--- a/drivers/media/pci/ttpci/av7110_v4l.c
+++ b/drivers/media/pci/ttpci/av7110_v4l.c
@@ -218,7 +218,7 @@ static int stv0297_set_tv_freq(struct saa7146_dev *dev, u32 
freq)
 static struct saa7146_standard dvb_standard[];
 static struct saa7146_standard standard[];
 
-static struct v4l2_audio msp3400_v4l2_audio = {
+static const struct v4l2_audio msp3400_v4l2_audio = {
.index = 0,
.name = "Television",
.capability = V4L2_AUDCAP_STEREO