cron job: media_tree daily build: ERRORS

2016-08-25 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:   Fri Aug 26 04:00:15 CEST 2016
git branch: test
git hash:   fb6609280db902bd5d34445fba1c926e95e63914
gcc version:i686-linux-gcc (GCC) 5.4.0
sparse version: v0.5.0-56-g7647c77
smatch version: v0.5.0-3428-gdfe27cf
host hardware:  x86_64
host os:4.6.0-164

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-multi: OK
linux-git-blackfin-bf561: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: WARNINGS
linux-2.6.36.4-i686: OK
linux-2.6.37.6-i686: OK
linux-2.6.38.8-i686: OK
linux-2.6.39.4-i686: OK
linux-3.0.60-i686: OK
linux-3.1.10-i686: OK
linux-3.2.37-i686: ERRORS
linux-3.3.8-i686: ERRORS
linux-3.4.27-i686: ERRORS
linux-3.5.7-i686: ERRORS
linux-3.6.11-i686: ERRORS
linux-3.7.4-i686: ERRORS
linux-3.8-i686: ERRORS
linux-3.9.2-i686: ERRORS
linux-3.10.1-i686: ERRORS
linux-3.11.1-i686: ERRORS
linux-3.12.23-i686: ERRORS
linux-3.13.11-i686: ERRORS
linux-3.14.9-i686: ERRORS
linux-3.15.2-i686: ERRORS
linux-3.16.7-i686: ERRORS
linux-3.17.8-i686: ERRORS
linux-3.18.7-i686: ERRORS
linux-3.19-i686: OK
linux-4.0-i686: OK
linux-4.1.1-i686: OK
linux-4.2-i686: OK
linux-4.3-i686: OK
linux-4.4-i686: OK
linux-4.5-i686: OK
linux-4.6-i686: OK
linux-4.7-i686: OK
linux-4.8-rc1-i686: OK
linux-2.6.36.4-x86_64: OK
linux-2.6.37.6-x86_64: OK
linux-2.6.38.8-x86_64: OK
linux-2.6.39.4-x86_64: OK
linux-3.0.60-x86_64: OK
linux-3.1.10-x86_64: OK
linux-3.2.37-x86_64: ERRORS
linux-3.3.8-x86_64: ERRORS
linux-3.4.27-x86_64: ERRORS
linux-3.5.7-x86_64: ERRORS
linux-3.6.11-x86_64: ERRORS
linux-3.7.4-x86_64: ERRORS
linux-3.8-x86_64: ERRORS
linux-3.9.2-x86_64: ERRORS
linux-3.10.1-x86_64: ERRORS
linux-3.11.1-x86_64: ERRORS
linux-3.12.23-x86_64: ERRORS
linux-3.13.11-x86_64: ERRORS
linux-3.14.9-x86_64: ERRORS
linux-3.15.2-x86_64: ERRORS
linux-3.16.7-x86_64: ERRORS
linux-3.17.8-x86_64: ERRORS
linux-3.18.7-x86_64: ERRORS
linux-3.19-x86_64: OK
linux-4.0-x86_64: OK
linux-4.1.1-x86_64: OK
linux-4.2-x86_64: OK
linux-4.3-x86_64: OK
linux-4.4-x86_64: OK
linux-4.5-x86_64: OK
linux-4.6-x86_64: OK
linux-4.7-x86_64: OK
linux-4.8-rc1-x86_64: OK
apps: OK
spec-git: OK
sparse: WARNINGS
smatch: WARNINGS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/index.html
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Plan to support Rockchip VPU in DRM, is it a good idea

2016-08-25 Thread Randy Li

Hello,
  We always use some kind of hack work to make our Video Process 
Unit(Multi-format Video Encoder/Decoder) work in kernel. From a 
customize driver(vpu service) to the customize V4L2 driver. The V4L2 
subsystem is really not suitable for the stateless Video process or it 
could make driver too fat.
  After talking to some kindness Intel guys and moving our userspace 
library to VA-API driver, I find the DRM may the good choice for us.
But I don't know whether it is welcome to to submit a video driver in 
DRM subsystem?
  Also our VPU(Video process unit) is not just like the Intel's, we 
don't have VCS, we based on registers to set the encoder/decoder. I 
think we may need a lots of IOCTL then. Also we do have a IOMMU in VPU 
but also not a isolated memory for VPU, I don't know I should use TT 
memory or GEM memory.
  I am actually not a member of the department in charge of VPU, and I 
am just beginning to learning DRM(thank the help from Intel again), I am 
not so good at memory part as well(I am more familiar with CMA not the 
IOMMU way), I may need know guide about the implementations when I am 
going to submit driver, I hope I could get help from someone.


--
Randy Li
The third produce department

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


DVB: Unable to find symbol dib7000p_attach()

2016-08-25 Thread Toralf Förster
Whilst kernel 4.6.5 is fine, kernel 4.7.x gives at a hardened Gentoo Linux:

...

Aug 25 20:28:24 t44 kernel: usb 1-3.1: USB disconnect, device number 4
Aug 25 20:28:24 t44 acpid[1084]: input device has been disconnected, fd 10
Aug 25 20:28:24 t44 kernel: dvb-usb: Terratec Cinergy T USB XXS (HD)/ T3 
successfully deinitialized and disconnected.
Aug 25 20:28:26 t44 kernel: usb 1-3.1: new high-speed USB device number 10 
using xhci_hcd
Aug 25 20:28:27 t44 kernel: usb 1-3.1: New USB device found, idVendor=0ccd, 
idProduct=00ab
Aug 25 20:28:27 t44 kernel: usb 1-3.1: New USB device strings: Mfr=1, 
Product=2, SerialNumber=3
Aug 25 20:28:27 t44 kernel: usb 1-3.1: Product: Cinergy T XXS
Aug 25 20:28:27 t44 kernel: usb 1-3.1: Manufacturer: TerraTec GmbH
Aug 25 20:28:27 t44 kernel: usb 1-3.1: SerialNumber: 01
Aug 25 20:28:27 t44 kernel: dvb-usb: found a 'Terratec Cinergy T USB XXS (HD)/ 
T3' in cold state, will try to load a firmware
Aug 25 20:28:27 t44 kernel: dvb-usb: downloading firmware from file 
'dvb-usb-dib0700-1.20.fw'
Aug 25 20:28:27 t44 kernel: dib0700: firmware started successfully.
Aug 25 20:28:27 t44 kernel: dvb-usb: found a 'Terratec Cinergy T USB XXS (HD)/ 
T3' in warm state.
Aug 25 20:28:27 t44 kernel: dvb-usb: will pass the complete MPEG2 transport 
stream to the software demuxer.
Aug 25 20:28:27 t44 kernel: DVB: registering new adapter (Terratec Cinergy T 
USB XXS (HD)/ T3)
Aug 25 20:28:27 t44 kernel: DVB: Unable to find symbol dib7000p_attach()
Aug 25 20:28:27 t44 kernel: dvb-usb: no frontend was attached by 'Terratec 
Cinergy T USB XXS (HD)/ T3'
Aug 25 20:28:27 t44 kernel: Registered IR keymap rc-dib0700-rc5
Aug 25 20:28:27 t44 kernel: input: IR-receiver inside an USB DVB receiver as 
/devices/pci:00/:00:14.0/usb1/1-3/1-3.1/rc/rc0/input18
Aug 25 20:28:27 t44 kernel: rc rc0: IR-receiver inside an USB DVB receiver as 
/devices/pci:00/:00:14.0/usb1/1-3/1-3.1/rc/rc0
Aug 25 20:28:27 t44 kernel: dvb-usb: schedule remote query interval to 50 msecs.
Aug 25 20:28:27 t44 kernel: dvb-usb: Terratec Cinergy T USB XXS (HD)/ T3 
successfully initialized and connected.

and Kaffeine / smplayer / name it as you want tells me , that no device is 
available.

-- 
Toralf
PGP: C4EACDDE 0076E94E, OTR: 420E74C8 30246EE7
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/8] media: vidc: adding core part and helper functions

2016-08-25 Thread Bjorn Andersson
On Thu 25 Aug 05:59 PDT 2016, Stanimir Varbanov wrote:

> Hi Bjorn,
> 
> Thanks for the review and comments!
> 
> On 08/23/2016 05:50 AM, Bjorn Andersson wrote:
> > On Mon 22 Aug 06:13 PDT 2016, Stanimir Varbanov wrote:
> > 
> > Hi Stan,
> > 
> >> This adds core part of the vidc driver common helper functions
> >> used by encoder and decoder specific files.
> > 
> > I believe "vidc" is short for "video core" and this is not the only
> > "video core" from Qualcomm. This driver is the v4l2 <-> hfi interface and
> 
> What other "video core"s do you know?
> 

The blackbird, or "vidc" as we know it in 8064. That one should likely
be named "mfc" though.

> > uses either two ram based fifos _or_ apr tal for communication with the
> > implementation.
> > 
> > In the case of apr, the other side is not the venus core but rather the
> > "VIDC" apr service on the Hexagon DSP. In this case the hfi packets are
> > encapsulated in apr packets. Although this is not used in 8916 it would
> > be nice to be able to add this later...
> 
> OK, you are talking about q6_hfi.c which file is found in msm-3.10 and
> maybe older kernel versions.
> 

That's the one.

> There is a function vidc_hfi_create() which currently creates venus hfi
> interface but it aways could be extended to call q6 DSP specific function.
> 

As the ADSP comes up with a VIDC service (on the applicable platform(s))
we get an APR channel, the concept is similar from then on but rather
than putting the messages directly into the venus hfi tx/rx fifos a
header is prepended to each hfi message and it's passed to the APR.

In the Qualcomm code the hfi ops are picked as vidc_hfi_create() is
called, but I think flipping that upside down to have the venus_hfi or
q6_hfi be the probe point and then calling the common probe part with an
ops struct associated would be more natural.

I do however not see a problem with doing such refactoring in the
future, I just wanted to bring it up.

> > 
> > 
> > But I think we should call this driver "hfi" - or at least venus, as
> > it's not compatible with e.g the "blackbird" found in 8064, which is
> > also called "vidc".
> 
> Do you think that vidc driver for 8064 will ever reach the mainline kernel?
> 

There are strong wishes for it to be supported, so we should take
reasonable measures to make sure its possible.

> I personally don't like hfi nor venus other suggestions? Does "vidcore"
> or "vcore" makes sense?
> 

These names would imply that we intend to have a single driver for all Qualcomm
video encoder/decoders.

As it's really hard to envision the future, or to argue about 8064 vidc,
I would rather see a driver for the hfi based video encoder/decoders.

If we in 8996+1 see a non-hfi chip benefit greatly from reusing
something from this implementation then those better go into the v4l
core or some other common entity.

[..]
> >> diff --git a/drivers/media/platform/qcom/vidc/core.c 
> >> b/drivers/media/platform/qcom/vidc/core.c
[..]
> >> +static void vidc_sys_error_handler(struct work_struct *work)
> >> +{
> >> +  struct vidc_sys_error *handler =
> >> +  container_of(work, struct vidc_sys_error, work.work);
> >> +  struct vidc_core *core = handler->core;
> >> +  struct hfi_core *hfi = >hfi;
> >> +  struct device *dev = core->dev;
> >> +  int ret;
> >> +
> >> +  mutex_lock(>lock);
> >> +  if (hfi->state != CORE_INVALID)
> >> +  goto exit;
> >> +
> >> +  mutex_unlock(>lock);
> >> +
> >> +  ret = vidc_hfi_core_deinit(hfi);
> >> +  if (ret)
> >> +  dev_err(dev, "core: deinit failed (%d)\n", ret);
> >> +
> >> +  mutex_lock(>lock);
> >> +
> >> +  rproc_report_crash(core->rproc, RPROC_FATAL_ERROR);
> > 
> > This operation is async, as such I believe this to be fragile. To get
> > the expected result you should be able to simply call
> > rproc_shutdown()/rproc_boot() to restart the core...
> 
> OK will remove crash report for now.
> 
> > 
> > However, if we at any point would like to be able to get memory dumps
> > from this core (likely a requirement on the Qualcomm side) we need to
> > call rproc_report_crash() and let it collect the resources and then
> > power cycle the core.
> > 
> > 
> > As the life cycle of the venus driver goes 1:1 with the rproc driver I
> > think it would be more suitable to make the v4l driver a child of the
> > rproc driver and have it probe/remove this driver as the rproc comes and
> > goes. This would allow us to call rproc_report_crash() here, we will be
> > removed and when the crash is handled (sometime in the future) we will
> > be probed again.
> 
> What's the problem with Kconfig "depends on QCOM_VENUS_PIL", isn't that
> enough?
> 

I mean in runtime, not compile time.

Devices instantiated from this driver does not serve a purpose without
either the venus rproc running or the adsp running. Further more as we
detect an issue with the remote core these resources (the venus or adsp)
will be stopped and restarted - potentially with a long delay inbetween
for ramdumping.


Re: [PATCH 1/2] [media] tw5864-core: remove double irq lock code

2016-08-25 Thread Andrey Utkin
For some reason (maybe "unlisted recipients"?), my reply didn't get
through to maillists. Resending my reply.

On Wed, Aug 24, 2016, at 19:30, Mauro Carvalho Chehab wrote:
> As warned by smatch:
>   drivers/media/pci/tw5864/tw5864-core.c:160 tw5864_h264_isr() error: 
> double lock 'irqsave:flags'
>   drivers/media/pci/tw5864/tw5864-core.c:174 tw5864_h264_isr() error: 
> double unlock 'irqsave:flags'
> 
> Remove the IRQ duplicated lock.
> 
> Signed-off-by: Mauro Carvalho Chehab 
> ---
>  drivers/media/pci/tw5864/tw5864-core.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/media/pci/tw5864/tw5864-core.c
> b/drivers/media/pci/tw5864/tw5864-core.c
> index 440cd7bb8d04..e3d884e963c0 100644
> --- a/drivers/media/pci/tw5864/tw5864-core.c
> +++ b/drivers/media/pci/tw5864/tw5864-core.c
> @@ -157,12 +157,10 @@ static void tw5864_h264_isr(struct tw5864_dev *dev)
>  
>   cur_frame = next_frame;
>  
> -   spin_lock_irqsave(>slock, flags);
>   input->frame_seqno++;
>   input->frame_gop_seqno++;
>   if (input->frame_gop_seqno >= input->gop)
>   input->frame_gop_seqno = 0;
> -   spin_unlock_irqrestore(>slock, flags);
>   } else {
>   dev_err(>pci->dev,
>   "Skipped frame on input %d because all buffers busy\n",


Thank you very much for catching this issue, but NACK on the patch.

These two lock operations are on different spinlocks. One for device,
another
one for input (a subordinate entity of device). What is superfluous here
is
second _irqsave. Also "flags" variable reuse is wrong. So what would be
right,
in my opinion, is the following (going to submit this patch):

diff --git a/drivers/media/pci/tw5864/tw5864-core.c
b/drivers/media/pci/tw5864/tw5864-core.c
index 440cd7b..1d43b96 100644
--- a/drivers/media/pci/tw5864/tw5864-core.c
+++ b/drivers/media/pci/tw5864/tw5864-core.c
@@ -157,12 +157,12 @@ static void tw5864_h264_isr(struct tw5864_dev
*dev)
 
cur_frame = next_frame;
 
-   spin_lock_irqsave(>slock, flags);
+   spin_lock(>slock);
input->frame_seqno++;
input->frame_gop_seqno++;
if (input->frame_gop_seqno >= input->gop)
input->frame_gop_seqno = 0;
-   spin_unlock_irqrestore(>slock, flags);
+   spin_unlock(>slock);
} else {
dev_err(>pci->dev,
"Skipped frame on input %d because all buffers
busy\n",
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 2/2] media: Add a driver for the ov5645 camera sensor.

2016-08-25 Thread Sakari Ailus
Hi Todor,

On Thu, Aug 25, 2016 at 04:30:33PM +0300, Todor Tomov wrote:
> Hi Sakari, Rob,
> 
> On 08/25/2016 10:18 AM, Sakari Ailus wrote:
> > Hi Todor,
> > 
> > On Wed, Aug 24, 2016 at 06:24:31PM +0300, Todor Tomov wrote:
> >> Hi Sakari,
> >>
> >> Thanks a lot for the time spent to review the driver!
> > 
> > You're welcome! :-)
> > 
> >> I have a few responses bellow.
> >>
> >>
> >> On 08/24/2016 01:17 PM, Sakari Ailus wrote:
> >>> Hi Todor,
> >>>
> >>> Thank you for the patch. Please see my comments below.
> >>>
> >>> On Fri, Jul 08, 2016 at 05:54:39PM +0300, Todor Tomov wrote:
>  The ov5645 sensor from Omnivision supports up to 2592x1944
>  and CSI2 interface.
> 
>  The driver adds support for the following modes:
>  - 1280x960
>  - 1920x1080
>  - 2592x1944
> 
>  Output format is packed 8bit UYVY.
> 
>  Signed-off-by: Todor Tomov 
>  ---
>   drivers/media/i2c/Kconfig  |   12 +
>   drivers/media/i2c/Makefile |1 +
>   drivers/media/i2c/ov5645.c | 1371 
>  
>   3 files changed, 1384 insertions(+)
>   create mode 100644 drivers/media/i2c/ov5645.c
> 
>  diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
>  index 993dc50..0cee05b 100644
>  --- a/drivers/media/i2c/Kconfig
>  +++ b/drivers/media/i2c/Kconfig
>  @@ -500,6 +500,18 @@ config VIDEO_OV2659
> To compile this driver as a module, choose M here: the
> module will be called ov2659.
>   
>  +config VIDEO_OV5645
>  +tristate "OmniVision OV5645 sensor support"
>  +depends on OF
>  +depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
>  +depends on MEDIA_CAMERA_SUPPORT
>  +---help---
>  +  This is a Video4Linux2 sensor-level driver for the OmniVision
>  +  OV5645 camera.
>  +
>  +  To compile this driver as a module, choose M here: the
>  +  module will be called ov5645.
>  +
>   config VIDEO_OV7640
>   tristate "OmniVision OV7640 sensor support"
>   depends on I2C && VIDEO_V4L2
>  diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
>  index 94f2c99..2485aed 100644
>  --- a/drivers/media/i2c/Makefile
>  +++ b/drivers/media/i2c/Makefile
>  @@ -55,6 +55,7 @@ obj-$(CONFIG_VIDEO_VP27SMPX) += vp27smpx.o
>   obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o
>   obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o
>   obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o
>  +obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
>   obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
>   obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
>   obj-$(CONFIG_VIDEO_OV9650) += ov9650.o
>  diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
>  new file mode 100644
>  index 000..ec96d10
>  --- /dev/null
>  +++ b/drivers/media/i2c/ov5645.c
>  @@ -0,0 +1,1371 @@
>  +/*
>  + * Driver for the OV5645 camera sensor.
>  + *
>  + * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
>  + * Copyright (C) 2015 By Tech Design S.L. All Rights Reserved.
>  + * Copyright (C) 2012-2013 Freescale Semiconductor, Inc. All Rights 
>  Reserved.
>  + *
>  + * Based on:
>  + * - the OV5645 driver from QC msm-3.10 kernel on codeaurora.org:
>  + *   
>  https://us.codeaurora.org/cgit/quic/la/kernel/msm-3.10/tree/drivers/
>  + *   
>  media/platform/msm/camera_v2/sensor/ov5645.c?h=LA.BR.1.2.4_rb1.41
>  + * - the OV5640 driver posted on linux-media:
>  + *   
>  https://www.mail-archive.com/linux-media%40vger.kernel.org/msg92671.html
>  + */
>  +
>  +/*
>  + * This program is free software; you can redistribute it and/or modify
>  + * it under the terms of the GNU General Public License as published by
>  + * the Free Software Foundation; either version 2 of the License, or
>  + * (at your option) any later version.
>  +
>  + * This program is distributed in the hope that it will be useful,
>  + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>  + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>  + * GNU General Public License for more details.
>  + */
>  +
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +
>  +#define OV5645_VOLTAGE_ANALOG   280
>  +#define OV5645_VOLTAGE_DIGITAL_CORE 150
>  +#define OV5645_VOLTAGE_DIGITAL_IO   180
>  +
>  +#define OV5645_XCLK 2388
> >>>
> >>> Is this really a 

Re: [PATCH v5 2/2] media: Add a driver for the ov5645 camera sensor.

2016-08-25 Thread Todor Tomov
Hi Sakari, Rob,

On 08/25/2016 10:18 AM, Sakari Ailus wrote:
> Hi Todor,
> 
> On Wed, Aug 24, 2016 at 06:24:31PM +0300, Todor Tomov wrote:
>> Hi Sakari,
>>
>> Thanks a lot for the time spent to review the driver!
> 
> You're welcome! :-)
> 
>> I have a few responses bellow.
>>
>>
>> On 08/24/2016 01:17 PM, Sakari Ailus wrote:
>>> Hi Todor,
>>>
>>> Thank you for the patch. Please see my comments below.
>>>
>>> On Fri, Jul 08, 2016 at 05:54:39PM +0300, Todor Tomov wrote:
 The ov5645 sensor from Omnivision supports up to 2592x1944
 and CSI2 interface.

 The driver adds support for the following modes:
 - 1280x960
 - 1920x1080
 - 2592x1944

 Output format is packed 8bit UYVY.

 Signed-off-by: Todor Tomov 
 ---
  drivers/media/i2c/Kconfig  |   12 +
  drivers/media/i2c/Makefile |1 +
  drivers/media/i2c/ov5645.c | 1371 
 
  3 files changed, 1384 insertions(+)
  create mode 100644 drivers/media/i2c/ov5645.c

 diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
 index 993dc50..0cee05b 100644
 --- a/drivers/media/i2c/Kconfig
 +++ b/drivers/media/i2c/Kconfig
 @@ -500,6 +500,18 @@ config VIDEO_OV2659
  To compile this driver as a module, choose M here: the
  module will be called ov2659.
  
 +config VIDEO_OV5645
 +  tristate "OmniVision OV5645 sensor support"
 +  depends on OF
 +  depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
 +  depends on MEDIA_CAMERA_SUPPORT
 +  ---help---
 +This is a Video4Linux2 sensor-level driver for the OmniVision
 +OV5645 camera.
 +
 +To compile this driver as a module, choose M here: the
 +module will be called ov5645.
 +
  config VIDEO_OV7640
tristate "OmniVision OV7640 sensor support"
depends on I2C && VIDEO_V4L2
 diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
 index 94f2c99..2485aed 100644
 --- a/drivers/media/i2c/Makefile
 +++ b/drivers/media/i2c/Makefile
 @@ -55,6 +55,7 @@ obj-$(CONFIG_VIDEO_VP27SMPX) += vp27smpx.o
  obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o
  obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o
  obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o
 +obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
  obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
  obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
  obj-$(CONFIG_VIDEO_OV9650) += ov9650.o
 diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
 new file mode 100644
 index 000..ec96d10
 --- /dev/null
 +++ b/drivers/media/i2c/ov5645.c
 @@ -0,0 +1,1371 @@
 +/*
 + * Driver for the OV5645 camera sensor.
 + *
 + * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
 + * Copyright (C) 2015 By Tech Design S.L. All Rights Reserved.
 + * Copyright (C) 2012-2013 Freescale Semiconductor, Inc. All Rights 
 Reserved.
 + *
 + * Based on:
 + * - the OV5645 driver from QC msm-3.10 kernel on codeaurora.org:
 + *   https://us.codeaurora.org/cgit/quic/la/kernel/msm-3.10/tree/drivers/
 + *   media/platform/msm/camera_v2/sensor/ov5645.c?h=LA.BR.1.2.4_rb1.41
 + * - the OV5640 driver posted on linux-media:
 + *   
 https://www.mail-archive.com/linux-media%40vger.kernel.org/msg92671.html
 + */
 +
 +/*
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; either version 2 of the License, or
 + * (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + */
 +
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +
 +#define OV5645_VOLTAGE_ANALOG   280
 +#define OV5645_VOLTAGE_DIGITAL_CORE 150
 +#define OV5645_VOLTAGE_DIGITAL_IO   180
 +
 +#define OV5645_XCLK   2388
>>>
>>> Is this really a property of the sensor itself? Shouldn't this go to the DT
>>> instead? And 23,88 MHz seems pretty unusual for an external clock frequency.
>>>
>>> Even if your driver only could use this frequency for now, the DT still
>>> should contain the real board specific frequency.
>>
>> Yes, 23.88MHz is the value of the external clock frequency.
>> The sensor mode settings (the big sensor register settings arrays below)
>> are calculated over 

Re: [PATCH 2/8] media: vidc: adding core part and helper functions

2016-08-25 Thread Stanimir Varbanov
Hi Bjorn,

Thanks for the review and comments!

On 08/23/2016 05:50 AM, Bjorn Andersson wrote:
> On Mon 22 Aug 06:13 PDT 2016, Stanimir Varbanov wrote:
> 
> Hi Stan,
> 
>> This adds core part of the vidc driver common helper functions
>> used by encoder and decoder specific files.
> 
> I believe "vidc" is short for "video core" and this is not the only
> "video core" from Qualcomm. This driver is the v4l2 <-> hfi interface and

What other "video core"s do you know?

> uses either two ram based fifos _or_ apr tal for communication with the
> implementation.
> 
> In the case of apr, the other side is not the venus core but rather the
> "VIDC" apr service on the Hexagon DSP. In this case the hfi packets are
> encapsulated in apr packets. Although this is not used in 8916 it would
> be nice to be able to add this later...

OK, you are talking about q6_hfi.c which file is found in msm-3.10 and
maybe older kernel versions.

There is a function vidc_hfi_create() which currently creates venus hfi
interface but it aways could be extended to call q6 DSP specific function.

> 
> 
> But I think we should call this driver "hfi" - or at least venus, as
> it's not compatible with e.g the "blackbird" found in 8064, which is
> also called "vidc".

Do you think that vidc driver for 8064 will ever reach the mainline kernel?

I personally don't like hfi nor venus other suggestions? Does "vidcore"
or "vcore" makes sense?

> 
>>
>>  - core.c has implemented the platform dirver methods, file
>> operations and v4l2 registration.
>>
>>  - helpers.c has implemented common helper functions for
>> buffer management, vb2_ops and functions for format propagation.
>>
>>  - int_bufs.c implements functions for allocating and freeing
>> buffers for internal usage. The buffer parameters describing
>> internal buffers depends on current format, resolution and
>> codec.
>>
>>  - load.c consists functions for calculation of current load
>> of the hardware. Depending on the count of instances and
>> resolutions it selects the best clock rate for the video
>> core.
>>
>>  - mem.c has two functions for memory allocation, currently
>> those functions are used for internal buffers and to allocate
>> the shared memory for communication with firmware via HFI
>> (Host Firmware Interface) interface commands.
> 
> Please drop this; see comments on mem_alloc()

OK.

> 
>>
>>  - resources.c exports a structure describing the details
>> specific to platform and SoC.
>>
>> Signed-off-by: Stanimir Varbanov 
>> ---
> 
> This doesn't compile, as it depends on later patches. Also there are
> plenty of functions that are related to later patches and would with be
> better to include there, to keep the size of this patch down.
> 
>>  drivers/media/platform/qcom/vidc/core.c  | 548 
>> +++
>>  drivers/media/platform/qcom/vidc/core.h  | 196 ++
>>  drivers/media/platform/qcom/vidc/helpers.c   | 394 +++
>>  drivers/media/platform/qcom/vidc/helpers.h   |  43 +++
>>  drivers/media/platform/qcom/vidc/int_bufs.c  | 325 
>>  drivers/media/platform/qcom/vidc/int_bufs.h  |  23 ++
>>  drivers/media/platform/qcom/vidc/load.c  | 104 +
>>  drivers/media/platform/qcom/vidc/load.h  |  22 ++
>>  drivers/media/platform/qcom/vidc/mem.c   |  64 
>>  drivers/media/platform/qcom/vidc/mem.h   |  32 ++
>>  drivers/media/platform/qcom/vidc/resources.c |  46 +++
>>  drivers/media/platform/qcom/vidc/resources.h |  46 +++
>>  12 files changed, 1843 insertions(+)
>>  create mode 100644 drivers/media/platform/qcom/vidc/core.c
>>  create mode 100644 drivers/media/platform/qcom/vidc/core.h
>>  create mode 100644 drivers/media/platform/qcom/vidc/helpers.c
>>  create mode 100644 drivers/media/platform/qcom/vidc/helpers.h
>>  create mode 100644 drivers/media/platform/qcom/vidc/int_bufs.c
>>  create mode 100644 drivers/media/platform/qcom/vidc/int_bufs.h
>>  create mode 100644 drivers/media/platform/qcom/vidc/load.c
>>  create mode 100644 drivers/media/platform/qcom/vidc/load.h
>>  create mode 100644 drivers/media/platform/qcom/vidc/mem.c
>>  create mode 100644 drivers/media/platform/qcom/vidc/mem.h
>>  create mode 100644 drivers/media/platform/qcom/vidc/resources.c
>>  create mode 100644 drivers/media/platform/qcom/vidc/resources.h
>>
>> diff --git a/drivers/media/platform/qcom/vidc/core.c 
>> b/drivers/media/platform/qcom/vidc/core.c
>> new file mode 100644
>> index ..e005be178fc0
>> --- /dev/null
>> +++ b/drivers/media/platform/qcom/vidc/core.c
>> @@ -0,0 +1,548 @@
>> +/*
>> + * Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
>> + * Copyright (C) 2016 Linaro Ltd.
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 and
>> + * only version 2 as published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope that 

Re: [PATCH v4 4/6] media: rc: meson-ir: Add support for newer versions of the IR decoder

2016-08-25 Thread Mauro Carvalho Chehab
Em Fri, 19 Aug 2016 15:28:22 -0700
Kevin Hilman  escreveu:

> Martin Blumenstingl  writes:
> 
> > From: Neil Armstrong 
> >
> > Newer SoCs (Meson 8b and GXBB) are using REG2 (offset 0x20) instead of
> > REG1 to configure the decoder mode. This makes it necessary to
> > introduce new bindings so the driver knows which register has to be
> > used.
> >
> > Signed-off-by: Neil Armstrong 
> > Signed-off-by: Martin Blumenstingl   
> 
> Acked-by: Kevin Hilman 
> 
> Mauro, are you the one to pick up new media/rc drivers?  Or if you
> prefer, with your ack, I'll take this along with the DT and submit via
> arm-soc.

I generally pick new media rc drivers, but in the specific case of this
patchset, it is just adding a few extra lines to existing drivers, and
most of the work are actually at the ARM tree.

So, feel free to merge via arm-soc with my ack:

Acked-by: Mauro Carvalho Chehab 

> 
> Thanks,
> 
> Kevin
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



Thanks,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [STLinux Kernel] [PATCH v4 0/3] support of v4l2 encoder for STMicroelectronics SOC

2016-08-25 Thread Peter Griffin
Hi Jean-Christophe,

On Mon, 25 Jul 2016, Jean-Christophe Trotin wrote:

> version 4:
> - Module renamed "st-hva" as suggested by Hans
> - resource_size() inline function used to calculate the esram size
> - V4L2 compliance successfully passed with this version (see report below)

For the series: -

Acked-by: Peter Griffin 

regards,

Peter.
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC 02/10] v4l: Add private compound control type.

2016-08-25 Thread Florent Revest
From: Pawel Osciak 

V4L2_CTRL_TYPE_PRIVATE is to be used for private driver compound
controls that use the "ptr" member of struct v4l2_ext_control.

Signed-off-by: Pawel Osciak 
Signed-off-by: Jung Zhao 
Signed-off-by: Florent Revest 
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 4 
 include/uapi/linux/videodev2.h   | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index f7333fe..60056b0 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1543,6 +1543,10 @@ static int std_validate(const struct v4l2_ctrl *ctrl, 
u32 idx,
return -ERANGE;
return 0;
 
+   /* FIXME:just return 0 for now */
+   case V4L2_CTRL_TYPE_PRIVATE:
+   return 0;
+
default:
return -EINVAL;
}
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 3eafd3f..904c44c 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -1521,6 +1521,8 @@ enum v4l2_ctrl_type {
V4L2_CTRL_TYPE_U8= 0x0100,
V4L2_CTRL_TYPE_U16   = 0x0101,
V4L2_CTRL_TYPE_U32   = 0x0102,
+
+   V4L2_CTRL_TYPE_PRIVATE   = 0x,
 };
 
 /*  Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC 00/10] Add Sunxi Cedrus Video Decoder Driver

2016-08-25 Thread Florent Revest
Hi,

This series adds a v4l2 memory2memory decoder driver for Allwinner's
VPU found in the A13 SoC. It follows the reverse engineering effort
of the Cedrus [1] project.

The VPU is able to decode a bunch of formats but currently only MPEG2
and a subset of MPEG4 are supported by the driver, more will come
eventually.

This VPU needs a frame-by-frame registers programming and implements
the idea of "Frame API" [2] proposed by Pawel Osciak. (i.e: binding
standard frame headers with frames via the "Request API") The patchset
includes both a new control for MPEG2 and MPEG4 frame headers. The
MPEG2 control should be generic enough for every other drivers but the
MPEG4 control sticks to the bare minimum needed by sunxi-cedrus.

The "Frame API" relies on the controls features of the "Request API".
[3] Since the latest Request API RFCs don't support controls and
given the time I had to work on this driver, I chose to use an older
RFC from Hans. [4] Of course, this is definitely not meant to be kept
and as soon as a newer Request API will support controls I'll stick
to the newest code base.

If you are interested in testing this driver, you can find a recently
(v4.8rc3) rebased version of this request API along my patchset in
this repository. [5] I also developed a libVA backend interfacing
with my proposal of MPEG2 and MPEG4 Frame API. [6] It's called 
"sunxi-cedrus-drv-video" but the only sunxi-cedrus specific part is
the format conversion code. Overall it should be generic enough for
any other v4l driver using the Frame API and as soon as the support
of DRM planes for this pixel format will be added it could be
renamed to something more generic.

[1] http://linux-sunxi.org/Cedrus
[2] 
https://docs.google.com/presentation/d/1RLkH3QxdmrcW_t41KllEvUmVsrHMbMOgd6CqAgzR7U4/pub?slide=id.p
[3] https://lwn.net/Articles/688585/
[4] https://lwn.net/Articles/641204/
[5] https://github.com/FlorentRevest/linux-sunxi-cedrus
[6] https://github.com/FlorentRevest/sunxi-cedrus-drv-video

Florent Revest (9):
  clk: sunxi-ng: Add a couple of A13 clocks
  v4l: Add sunxi Video Engine pixel format
  v4l: Add MPEG2 low-level decoder API control
  v4l: Add MPEG4 low-level decoder API control
  media: platform: Add Sunxi Cedrus decoder driver
  sunxi-cedrus: Add a MPEG 2 codec
  sunxi-cedrus: Add a MPEG 4 codec
  ARM: dts: sun5i: Use video-engine node
  sunxi-cedrus: Add device tree binding document

Pawel Osciak (1):
  v4l: Add private compound control type.

 .../devicetree/bindings/clock/sunxi-ccu.txt|   1 +
 .../devicetree/bindings/media/sunxi-cedrus.txt |  44 ++
 arch/arm/boot/dts/sun5i-a13.dtsi   |  42 ++
 drivers/clk/sunxi-ng/Kconfig   |  11 +
 drivers/clk/sunxi-ng/Makefile  |   1 +
 drivers/clk/sunxi-ng/ccu-sun5i-a13.c   |  80 +++
 drivers/clk/sunxi-ng/ccu-sun5i-a13.h   |  25 +
 drivers/media/platform/Kconfig |  13 +
 drivers/media/platform/Makefile|   1 +
 drivers/media/platform/sunxi-cedrus/Makefile   |   3 +
 drivers/media/platform/sunxi-cedrus/sunxi_cedrus.c | 285 ++
 .../platform/sunxi-cedrus/sunxi_cedrus_common.h| 101 
 .../media/platform/sunxi-cedrus/sunxi_cedrus_dec.c | 588 +
 .../media/platform/sunxi-cedrus/sunxi_cedrus_dec.h |  33 ++
 .../media/platform/sunxi-cedrus/sunxi_cedrus_hw.c  | 166 ++
 .../media/platform/sunxi-cedrus/sunxi_cedrus_hw.h  |  39 ++
 .../platform/sunxi-cedrus/sunxi_cedrus_mpeg2.c | 152 ++
 .../platform/sunxi-cedrus/sunxi_cedrus_mpeg4.c | 140 +
 .../platform/sunxi-cedrus/sunxi_cedrus_regs.h  | 170 ++
 drivers/media/v4l2-core/v4l2-ctrls.c   |  23 +
 drivers/media/v4l2-core/v4l2-ioctl.c   |   2 +
 include/dt-bindings/clock/sun5i-a13-ccu.h  |  49 ++
 include/dt-bindings/reset/sun5i-a13-ccu.h  |  48 ++
 include/uapi/linux/v4l2-controls.h |  68 +++
 include/uapi/linux/videodev2.h |   9 +
 25 files changed, 2094 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/sunxi-cedrus.txt
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun5i-a13.c
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun5i-a13.h
 create mode 100644 drivers/media/platform/sunxi-cedrus/Makefile
 create mode 100644 drivers/media/platform/sunxi-cedrus/sunxi_cedrus.c
 create mode 100644 drivers/media/platform/sunxi-cedrus/sunxi_cedrus_common.h
 create mode 100644 drivers/media/platform/sunxi-cedrus/sunxi_cedrus_dec.c
 create mode 100644 drivers/media/platform/sunxi-cedrus/sunxi_cedrus_dec.h
 create mode 100644 drivers/media/platform/sunxi-cedrus/sunxi_cedrus_hw.c
 create mode 100644 drivers/media/platform/sunxi-cedrus/sunxi_cedrus_hw.h
 create mode 100644 drivers/media/platform/sunxi-cedrus/sunxi_cedrus_mpeg2.c
 create mode 100644 drivers/media/platform/sunxi-cedrus/sunxi_cedrus_mpeg4.c
 create mode 100644 

[RFC 03/10] v4l: Add sunxi Video Engine pixel format

2016-08-25 Thread Florent Revest
Add support for the allwinner's proprietary pixel format described in
details here: http://linux-sunxi.org/File:Ve_tile_format_v1.pdf

This format is similar to V4L2_PIX_FMT_NV12M but the planes are divided
in tiles of 32x32px.

Signed-off-by: Florent Revest 
---
 include/uapi/linux/videodev2.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 904c44c..96e034d 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -627,6 +627,7 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_Y8I  v4l2_fourcc('Y', '8', 'I', ' ') /* Greyscale 
8-bit L/R interleaved */
 #define V4L2_PIX_FMT_Y12I v4l2_fourcc('Y', '1', '2', 'I') /* Greyscale 
12-bit L/R interleaved */
 #define V4L2_PIX_FMT_Z16  v4l2_fourcc('Z', '1', '6', ' ') /* Depth data 
16-bit */
+#define V4L2_PIX_FMT_SUNXIv4l2_fourcc('S', 'X', 'I', 'Y') /* Sunxi VE's 
32x32 tiled NV12 */
 
 /* SDR formats - used only for Software Defined Radio devices */
 #define V4L2_SDR_FMT_CU8  v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC 01/10] clk: sunxi-ng: Add a couple of A13 clocks

2016-08-25 Thread Florent Revest
Add a new style driver for the clock control unit in Allwinner A13.

Only AVS and VE are supported since they weren't provided until now and are
needed for "sunxi-cedrus".

Signed-off-by: Florent Revest 
---
 .../devicetree/bindings/clock/sunxi-ccu.txt|  1 +
 arch/arm/boot/dts/sun5i-a13.dtsi   | 11 +++
 drivers/clk/sunxi-ng/Kconfig   | 11 +++
 drivers/clk/sunxi-ng/Makefile  |  1 +
 drivers/clk/sunxi-ng/ccu-sun5i-a13.c   | 80 ++
 drivers/clk/sunxi-ng/ccu-sun5i-a13.h   | 25 +++
 include/dt-bindings/clock/sun5i-a13-ccu.h  | 49 +
 include/dt-bindings/reset/sun5i-a13-ccu.h  | 48 +
 8 files changed, 226 insertions(+)
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun5i-a13.c
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun5i-a13.h
 create mode 100644 include/dt-bindings/clock/sun5i-a13-ccu.h
 create mode 100644 include/dt-bindings/reset/sun5i-a13-ccu.h

diff --git a/Documentation/devicetree/bindings/clock/sunxi-ccu.txt 
b/Documentation/devicetree/bindings/clock/sunxi-ccu.txt
index cb91507..7bb7a6a 100644
--- a/Documentation/devicetree/bindings/clock/sunxi-ccu.txt
+++ b/Documentation/devicetree/bindings/clock/sunxi-ccu.txt
@@ -4,6 +4,7 @@ Allwinner Clock Control Unit Binding
 Required properties :
 - compatible: must contain one of the following compatible:
- "allwinner,sun8i-h3-ccu"
+   - "allwinner,sun5i-a13-ccu"
 
 - reg: Must contain the registers base address and length
 - clocks: phandle to the oscillators feeding the CCU. Two are needed:
diff --git a/arch/arm/boot/dts/sun5i-a13.dtsi b/arch/arm/boot/dts/sun5i-a13.dtsi
index e012890..2afe05fb 100644
--- a/arch/arm/boot/dts/sun5i-a13.dtsi
+++ b/arch/arm/boot/dts/sun5i-a13.dtsi
@@ -46,8 +46,10 @@
 
 #include "sun5i.dtsi"
 
+#include 
 #include 
 #include 
+#include 
 
 / {
interrupt-parent = <>;
@@ -327,6 +329,15 @@
};
};
};
+
+   ccu: clock@01c2 {
+   compatible = "allwinner,sun5i-a13-ccu";
+   reg = <0x01c2 0x400>;
+   clocks = <>, <>;
+   clock-names = "hosc", "losc";
+   #clock-cells = <1>;
+   #reset-cells = <1>;
+   };
};
 };
 
diff --git a/drivers/clk/sunxi-ng/Kconfig b/drivers/clk/sunxi-ng/Kconfig
index 2afcbd3..8faba4e 100644
--- a/drivers/clk/sunxi-ng/Kconfig
+++ b/drivers/clk/sunxi-ng/Kconfig
@@ -51,6 +51,17 @@ config SUNXI_CCU_MP
 
 # SoC Drivers
 
+config SUN5I_A13_CCU
+   bool "Support for the Allwinner A13 CCU"
+   select SUNXI_CCU_DIV
+   select SUNXI_CCU_NK
+   select SUNXI_CCU_NKM
+   select SUNXI_CCU_NKMP
+   select SUNXI_CCU_NM
+   select SUNXI_CCU_MP
+   select SUNXI_CCU_PHASE
+   default ARCH_SUN5I
+
 config SUN8I_H3_CCU
bool "Support for the Allwinner H3 CCU"
select SUNXI_CCU_DIV
diff --git a/drivers/clk/sunxi-ng/Makefile b/drivers/clk/sunxi-ng/Makefile
index 633ce64..1710745 100644
--- a/drivers/clk/sunxi-ng/Makefile
+++ b/drivers/clk/sunxi-ng/Makefile
@@ -17,4 +17,5 @@ obj-$(CONFIG_SUNXI_CCU_NM)+= ccu_nm.o
 obj-$(CONFIG_SUNXI_CCU_MP) += ccu_mp.o
 
 # SoC support
+obj-$(CONFIG_SUN5I_A13_CCU)+= ccu-sun5i-a13.o
 obj-$(CONFIG_SUN8I_H3_CCU) += ccu-sun8i-h3.o
diff --git a/drivers/clk/sunxi-ng/ccu-sun5i-a13.c 
b/drivers/clk/sunxi-ng/ccu-sun5i-a13.c
new file mode 100644
index 000..7f1da20
--- /dev/null
+++ b/drivers/clk/sunxi-ng/ccu-sun5i-a13.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2016 Maxime Ripard. All rights reserved.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+
+#include "ccu_common.h"
+#include "ccu_reset.h"
+
+#include "ccu_div.h"
+#include "ccu_gate.h"
+#include "ccu_mp.h"
+#include "ccu_mult.h"
+#include "ccu_nk.h"
+#include "ccu_nkm.h"
+#include "ccu_nkmp.h"
+#include "ccu_nm.h"
+#include "ccu_phase.h"
+
+#include "ccu-sun5i-a13.h"
+
+static SUNXI_CCU_GATE(ve_clk, "ve", "pll4",
+ 0x13c, BIT(31), CLK_SET_RATE_PARENT);
+
+static SUNXI_CCU_GATE(avs_clk, "avs",  "osc24M",
+ 0x144, BIT(31), 0);
+
+static struct ccu_common *sun5i_a13_ccu_clks[] = {
+   _clk.common,
+   _clk.common,
+};
+
+static struct clk_hw_onecell_data sun5i_a13_hw_clks = {
+   .hws= {
+   [CLK_VE]= _clk.common.hw,
+   

[RFC 04/10] v4l: Add MPEG2 low-level decoder API control

2016-08-25 Thread Florent Revest
This control is to be used with the new low-level decoder API for
MPEG2 to provide additional parameters for the hardware that cannot parse
the input stream.

Signed-off-by: Florent Revest 
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 11 +++
 drivers/media/v4l2-core/v4l2-ioctl.c |  1 +
 include/uapi/linux/v4l2-controls.h   | 26 ++
 include/uapi/linux/videodev2.h   |  3 +++
 4 files changed, 41 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 60056b0..331d009 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -760,6 +760,8 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER: return "Repeat 
Sequence Header";
case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME:   return "Force 
Key Frame";
 
+   case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR:   return "MPEG2 
Frame Header";
+
/* VPX controls */
case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS:return "VPX 
Number of Partitions";
case V4L2_CID_MPEG_VIDEO_VPX_IMD_DISABLE_4X4:   return "VPX 
Intra Mode Decision Disable";
@@ -1143,6 +1145,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_RDS_TX_ALT_FREQS:
*type = V4L2_CTRL_TYPE_U32;
break;
+   case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR:
+   *type = V4L2_CTRL_TYPE_MPEG2_FRAME_HDR;
+   break;
default:
*type = V4L2_CTRL_TYPE_INTEGER;
break;
@@ -1543,6 +1548,9 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 
idx,
return -ERANGE;
return 0;
 
+   case V4L2_CTRL_TYPE_MPEG2_FRAME_HDR:
+   return 0;
+
/* FIXME:just return 0 for now */
case V4L2_CTRL_TYPE_PRIVATE:
return 0;
@@ -2096,6 +2104,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct 
v4l2_ctrl_handler *hdl,
case V4L2_CTRL_TYPE_U32:
elem_size = sizeof(u32);
break;
+   case V4L2_CTRL_TYPE_MPEG2_FRAME_HDR:
+   elem_size = sizeof(struct v4l2_ctrl_mpeg2_frame_hdr);
+   break;
default:
if (type < V4L2_CTRL_COMPOUND_TYPES)
elem_size = sizeof(s32);
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index f19b666..de382a1 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1273,6 +1273,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_VC1_ANNEX_G:  descr = "VC-1 (SMPTE 412M Annex 
G)"; break;
case V4L2_PIX_FMT_VC1_ANNEX_L:  descr = "VC-1 (SMPTE 412M Annex 
L)"; break;
case V4L2_PIX_FMT_VP8:  descr = "VP8"; break;
+   case V4L2_PIX_FMT_MPEG2_FRAME:  descr = "MPEG2 FRAME"; break;
case V4L2_PIX_FMT_CPIA1:descr = "GSPCA CPiA YUV"; break;
case V4L2_PIX_FMT_WNVA: descr = "WNVA"; break;
case V4L2_PIX_FMT_SN9C10X:  descr = "GSPCA SN9C10X"; break;
diff --git a/include/uapi/linux/v4l2-controls.h 
b/include/uapi/linux/v4l2-controls.h
index b6a357a..cdf9497 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -547,6 +547,8 @@ enum v4l2_mpeg_video_mpeg4_profile {
 };
 #define V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (V4L2_CID_MPEG_BASE+407)
 
+#define V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR (V4L2_CID_MPEG_BASE+450)
+
 /*  Control IDs for VP8 streams
  *  Although VP8 is not part of MPEG we add these controls to the MPEG class
  *  as that class is already handling other video compression standards
@@ -974,4 +976,28 @@ enum v4l2_detect_md_mode {
 #define V4L2_CID_DETECT_MD_THRESHOLD_GRID  (V4L2_CID_DETECT_CLASS_BASE + 3)
 #define V4L2_CID_DETECT_MD_REGION_GRID (V4L2_CID_DETECT_CLASS_BASE + 4)
 
+struct v4l2_ctrl_mpeg2_frame_hdr {
+   __u32 slice_len;
+   __u32 slice_pos;
+   enum { MPEG1, MPEG2 } type;
+
+   __u16 width;
+   __u16 height;
+
+   enum { PCT_I = 1, PCT_P, PCT_B, PCT_D } picture_coding_type;
+   __u8 f_code[2][2];
+
+   __u8 intra_dc_precision;
+   __u8 picture_structure;
+   __u8 top_field_first;
+   __u8 frame_pred_frame_dct;
+   __u8 concealment_motion_vectors;
+   __u8 q_scale_type;
+   __u8 intra_vlc_format;
+   __u8 alternate_scan;
+
+   __u8 backward_index;
+   __u8 forward_index;
+};
+
 #endif
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 96e034d..feff200 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -596,6 +596,7 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_VC1_ANNEX_G v4l2_fourcc('V', 

[RFC 06/10] media: platform: Add Sunxi Cedrus decoder driver

2016-08-25 Thread Florent Revest
This patch adds a "sunxi-cedrus" v4l2 m2m decoder driver for
Allwinner's Video Processing Unit. This VPU has a low-level interface
which requires manual registers writing for frame headers. Hence, it
depends on the Request API to synchronize buffers with controls.

Most of the reverse engineering on which I based my work comes from the
"Cedrus" project: http://linux-sunxi.org/Cedrus

The driver currently only runs on the A13 and this patch doesn't
include any codec.

Signed-off-by: Florent Revest 
---
 drivers/media/platform/Kconfig |  13 +
 drivers/media/platform/Makefile|   1 +
 drivers/media/platform/sunxi-cedrus/Makefile   |   2 +
 drivers/media/platform/sunxi-cedrus/sunxi_cedrus.c | 248 ++
 .../platform/sunxi-cedrus/sunxi_cedrus_common.h|  86 
 .../media/platform/sunxi-cedrus/sunxi_cedrus_dec.c | 544 +
 .../media/platform/sunxi-cedrus/sunxi_cedrus_dec.h |  33 ++
 .../media/platform/sunxi-cedrus/sunxi_cedrus_hw.c  | 153 ++
 .../media/platform/sunxi-cedrus/sunxi_cedrus_hw.h  |  32 ++
 .../platform/sunxi-cedrus/sunxi_cedrus_regs.h  | 170 +++
 10 files changed, 1282 insertions(+)
 create mode 100644 drivers/media/platform/sunxi-cedrus/Makefile
 create mode 100644 drivers/media/platform/sunxi-cedrus/sunxi_cedrus.c
 create mode 100644 drivers/media/platform/sunxi-cedrus/sunxi_cedrus_common.h
 create mode 100644 drivers/media/platform/sunxi-cedrus/sunxi_cedrus_dec.c
 create mode 100644 drivers/media/platform/sunxi-cedrus/sunxi_cedrus_dec.h
 create mode 100644 drivers/media/platform/sunxi-cedrus/sunxi_cedrus_hw.c
 create mode 100644 drivers/media/platform/sunxi-cedrus/sunxi_cedrus_hw.h
 create mode 100644 drivers/media/platform/sunxi-cedrus/sunxi_cedrus_regs.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index f25344b..92c92d3 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -315,6 +315,19 @@ config VIDEO_TI_VPE
  Support for the TI VPE(Video Processing Engine) block
  found on DRA7XX SoC.
 
+config VIDEO_SUNXI_CEDRUS
+   tristate "Sunxi CEDRUS VPU driver"
+   depends on VIDEO_DEV && VIDEO_V4L2
+   depends on ARCH_SUNXI
+   depends on HAS_DMA
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   ---help---
+ Support for the VPU video codec found on Sunxi SoC.
+
+ To compile this driver as a module, choose M here: the module
+ will be called sunxi-cedrus.
+
 config VIDEO_TI_VPE_DEBUG
bool "VPE debug messages"
depends on VIDEO_TI_VPE
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 21771c1..1419749 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -53,6 +53,7 @@ obj-$(CONFIG_VIDEO_RENESAS_VSP1)  += vsp1/
 obj-y  += omap/
 
 obj-$(CONFIG_VIDEO_AM437X_VPFE)+= am437x/
+obj-$(CONFIG_VIDEO_SUNXI_CEDRUS)   += sunxi-cedrus/
 
 obj-$(CONFIG_VIDEO_XILINX) += xilinx/
 
diff --git a/drivers/media/platform/sunxi-cedrus/Makefile 
b/drivers/media/platform/sunxi-cedrus/Makefile
new file mode 100644
index 000..14c2f7a
--- /dev/null
+++ b/drivers/media/platform/sunxi-cedrus/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_VIDEO_SUNXI_CEDRUS) += sunxi_cedrus.o sunxi_cedrus_hw.o \
+   sunxi_cedrus_dec.o
diff --git a/drivers/media/platform/sunxi-cedrus/sunxi_cedrus.c 
b/drivers/media/platform/sunxi-cedrus/sunxi_cedrus.c
new file mode 100644
index 000..17af34c
--- /dev/null
+++ b/drivers/media/platform/sunxi-cedrus/sunxi_cedrus.c
@@ -0,0 +1,248 @@
+/*
+ * Sunxi Cedrus codec driver
+ *
+ * Copyright (C) 2016 Florent Revest
+ * Florent Revest 
+ *
+ * Based on vim2m
+ *
+ * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
+ * Pawel Osciak, 
+ * Marek Szyprowski, 
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include "sunxi_cedrus_common.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "sunxi_cedrus_dec.h"
+#include "sunxi_cedrus_hw.h"
+
+static int sunxi_cedrus_s_ctrl(struct v4l2_ctrl *ctrl)
+{
+   struct sunxi_cedrus_ctx *ctx =
+   container_of(ctrl->handler, struct sunxi_cedrus_ctx, hdl);
+
+   v4l2_err(>dev->v4l2_dev, "Invalid control\n");
+   return -EINVAL;
+}

[RFC 08/10] sunxi-cedrus: Add a MPEG 4 codec

2016-08-25 Thread Florent Revest
This patch introduces the support of MPEG4 video decoding to the
sunxi-cedrus video decoder driver.

Signed-off-by: Florent Revest 
---
 drivers/media/platform/sunxi-cedrus/Makefile   |   3 +-
 drivers/media/platform/sunxi-cedrus/sunxi_cedrus.c |  15 +++
 .../platform/sunxi-cedrus/sunxi_cedrus_common.h|  13 ++
 .../media/platform/sunxi-cedrus/sunxi_cedrus_dec.c |  33 +
 .../media/platform/sunxi-cedrus/sunxi_cedrus_hw.h  |   3 +
 .../platform/sunxi-cedrus/sunxi_cedrus_mpeg4.c | 140 +
 6 files changed, 206 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/platform/sunxi-cedrus/sunxi_cedrus_mpeg4.c

diff --git a/drivers/media/platform/sunxi-cedrus/Makefile 
b/drivers/media/platform/sunxi-cedrus/Makefile
index 2d495a2..823d611 100644
--- a/drivers/media/platform/sunxi-cedrus/Makefile
+++ b/drivers/media/platform/sunxi-cedrus/Makefile
@@ -1,2 +1,3 @@
 obj-$(CONFIG_VIDEO_SUNXI_CEDRUS) += sunxi_cedrus.o sunxi_cedrus_hw.o \
-   sunxi_cedrus_dec.o sunxi_cedrus_mpeg2.o
+   sunxi_cedrus_dec.o sunxi_cedrus_mpeg2.o \
+   sunxi_cedrus_mpeg4.o
diff --git a/drivers/media/platform/sunxi-cedrus/sunxi_cedrus.c 
b/drivers/media/platform/sunxi-cedrus/sunxi_cedrus.c
index d1c957a..3001440 100644
--- a/drivers/media/platform/sunxi-cedrus/sunxi_cedrus.c
+++ b/drivers/media/platform/sunxi-cedrus/sunxi_cedrus.c
@@ -47,6 +47,7 @@ static int sunxi_cedrus_s_ctrl(struct v4l2_ctrl *ctrl)
container_of(ctrl->handler, struct sunxi_cedrus_ctx, hdl);
 
switch (ctrl->id) {
+   case V4L2_CID_MPEG_VIDEO_MPEG4_FRAME_HDR:
case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR:
/* This is kept in memory and used directly. */
break;
@@ -71,6 +72,15 @@ static const struct v4l2_ctrl_config 
sunxi_cedrus_ctrl_mpeg2_frame_hdr = {
.elem_size = sizeof(struct v4l2_ctrl_mpeg2_frame_hdr),
 };
 
+static const struct v4l2_ctrl_config sunxi_cedrus_ctrl_mpeg4_frame_hdr = {
+   .ops = _cedrus_ctrl_ops,
+   .id = V4L2_CID_MPEG_VIDEO_MPEG4_FRAME_HDR,
+   .type = V4L2_CTRL_TYPE_PRIVATE,
+   .name = "MPEG4 Frame Header Parameters",
+   .max_reqs = VIDEO_MAX_FRAME,
+   .elem_size = sizeof(struct v4l2_ctrl_mpeg4_frame_hdr),
+};
+
 /*
  * File operations
  */
@@ -99,6 +109,10 @@ static int sunxi_cedrus_open(struct file *file)
_cedrus_ctrl_mpeg2_frame_hdr, NULL);
ctx->mpeg2_frame_hdr_ctrl->flags |= V4L2_CTRL_FLAG_REQ_KEEP;
 
+   ctx->mpeg4_frame_hdr_ctrl = v4l2_ctrl_new_custom(hdl,
+   _cedrus_ctrl_mpeg4_frame_hdr, NULL);
+   ctx->mpeg4_frame_hdr_ctrl->flags |= V4L2_CTRL_FLAG_REQ_KEEP;
+
if (hdl->error) {
rc = hdl->error;
v4l2_ctrl_handler_free(hdl);
@@ -139,6 +153,7 @@ static int sunxi_cedrus_release(struct file *file)
v4l2_fh_exit(>fh);
v4l2_ctrl_handler_free(>hdl);
ctx->mpeg2_frame_hdr_ctrl = NULL;
+   ctx->mpeg4_frame_hdr_ctrl = NULL;
mutex_lock(>dev_mutex);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
mutex_unlock(>dev_mutex);
diff --git a/drivers/media/platform/sunxi-cedrus/sunxi_cedrus_common.h 
b/drivers/media/platform/sunxi-cedrus/sunxi_cedrus_common.h
index e715184..33fa891 100644
--- a/drivers/media/platform/sunxi-cedrus/sunxi_cedrus_common.h
+++ b/drivers/media/platform/sunxi-cedrus/sunxi_cedrus_common.h
@@ -49,6 +49,18 @@ struct sunxi_cedrus_dev {
struct reset_control *rstc;
 
char *base;
+
+   unsigned int mbh_buf;
+   unsigned int dcac_buf;
+   unsigned int ncf_buf;
+
+   void *mbh_buf_virt;
+   void *dcac_buf_virt;
+   void *ncf_buf_virt;
+
+   unsigned int mbh_buf_size;
+   unsigned int dcac_buf_size;
+   unsigned int ncf_buf_size;
 };
 
 struct sunxi_cedrus_fmt {
@@ -72,6 +84,7 @@ struct sunxi_cedrus_ctx {
struct vb2_buffer *dst_bufs[VIDEO_MAX_FRAME];
 
struct v4l2_ctrl *mpeg2_frame_hdr_ctrl;
+   struct v4l2_ctrl *mpeg4_frame_hdr_ctrl;
 };
 
 static inline void sunxi_cedrus_write(struct sunxi_cedrus_dev *vpu,
diff --git a/drivers/media/platform/sunxi-cedrus/sunxi_cedrus_dec.c 
b/drivers/media/platform/sunxi-cedrus/sunxi_cedrus_dec.c
index 38e8a3a..8ce635d 100644
--- a/drivers/media/platform/sunxi-cedrus/sunxi_cedrus_dec.c
+++ b/drivers/media/platform/sunxi-cedrus/sunxi_cedrus_dec.c
@@ -53,6 +53,11 @@ static struct sunxi_cedrus_fmt formats[] = {
.types  = SUNXI_CEDRUS_OUTPUT,
.num_planes = 1,
},
+   {
+   .fourcc = V4L2_PIX_FMT_MPEG4_FRAME,
+   .types  = SUNXI_CEDRUS_OUTPUT,
+   .num_planes = 1,
+   },
 };
 
 #define NUM_FORMATS ARRAY_SIZE(formats)
@@ -129,6 +134,10 @@ void device_run(void *priv)
struct v4l2_ctrl_mpeg2_frame_hdr *frame_hdr =

[RFC 05/10] v4l: Add MPEG4 low-level decoder API control

2016-08-25 Thread Florent Revest
This control is to be used with the new low-level decoder API for MPEG4
to provide additional parameters for the hardware that cannot parse the
input stream.

Some fields are still missing for this structure to be complete.

Signed-off-by: Florent Revest 
---
 drivers/media/v4l2-core/v4l2-ctrls.c |  8 +++
 drivers/media/v4l2-core/v4l2-ioctl.c |  1 +
 include/uapi/linux/v4l2-controls.h   | 42 
 include/uapi/linux/videodev2.h   |  3 +++
 4 files changed, 54 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 331d009..302c744 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -761,6 +761,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME:   return "Force 
Key Frame";
 
case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR:   return "MPEG2 
Frame Header";
+   case V4L2_CID_MPEG_VIDEO_MPEG4_FRAME_HDR:   return "MPEG4 
Frame Header";
 
/* VPX controls */
case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS:return "VPX 
Number of Partitions";
@@ -1148,6 +1149,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR:
*type = V4L2_CTRL_TYPE_MPEG2_FRAME_HDR;
break;
+   case V4L2_CID_MPEG_VIDEO_MPEG4_FRAME_HDR:
+   *type = V4L2_CTRL_TYPE_MPEG4_FRAME_HDR;
+   break;
default:
*type = V4L2_CTRL_TYPE_INTEGER;
break;
@@ -1549,6 +1553,7 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 
idx,
return 0;
 
case V4L2_CTRL_TYPE_MPEG2_FRAME_HDR:
+   case V4L2_CTRL_TYPE_MPEG4_FRAME_HDR:
return 0;
 
/* FIXME:just return 0 for now */
@@ -2107,6 +2112,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct 
v4l2_ctrl_handler *hdl,
case V4L2_CTRL_TYPE_MPEG2_FRAME_HDR:
elem_size = sizeof(struct v4l2_ctrl_mpeg2_frame_hdr);
break;
+   case V4L2_CTRL_TYPE_MPEG4_FRAME_HDR:
+   elem_size = sizeof(struct v4l2_ctrl_mpeg4_frame_hdr);
+   break;
default:
if (type < V4L2_CTRL_COMPOUND_TYPES)
elem_size = sizeof(s32);
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index de382a1..be7973e 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1274,6 +1274,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_VC1_ANNEX_L:  descr = "VC-1 (SMPTE 412M Annex 
L)"; break;
case V4L2_PIX_FMT_VP8:  descr = "VP8"; break;
case V4L2_PIX_FMT_MPEG2_FRAME:  descr = "MPEG2 FRAME"; break;
+   case V4L2_PIX_FMT_MPEG4_FRAME:  descr = "MPEG4 FRAME"; break;
case V4L2_PIX_FMT_CPIA1:descr = "GSPCA CPiA YUV"; break;
case V4L2_PIX_FMT_WNVA: descr = "WNVA"; break;
case V4L2_PIX_FMT_SN9C10X:  descr = "GSPCA SN9C10X"; break;
diff --git a/include/uapi/linux/v4l2-controls.h 
b/include/uapi/linux/v4l2-controls.h
index cdf9497..af466ca 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -548,6 +548,7 @@ enum v4l2_mpeg_video_mpeg4_profile {
 #define V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (V4L2_CID_MPEG_BASE+407)
 
 #define V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR (V4L2_CID_MPEG_BASE+450)
+#define V4L2_CID_MPEG_VIDEO_MPEG4_FRAME_HDR (V4L2_CID_MPEG_BASE+451)
 
 /*  Control IDs for VP8 streams
  *  Although VP8 is not part of MPEG we add these controls to the MPEG class
@@ -1000,4 +1001,45 @@ struct v4l2_ctrl_mpeg2_frame_hdr {
__u8 forward_index;
 };
 
+struct v4l2_ctrl_mpeg4_frame_hdr {
+   __u32 slice_len;
+   __u32 slice_pos;
+   unsigned char quant_scale;
+
+   __u16 width;
+   __u16 height;
+
+   struct {
+   unsigned int short_video_header : 1;
+   unsigned int chroma_format  : 2;
+   unsigned int interlaced : 1;
+   unsigned int obmc_disable   : 1;
+   unsigned int sprite_enable  : 2;
+   unsigned int sprite_warping_accuracy: 2;
+   unsigned int quant_type : 1;
+   unsigned int quarter_sample : 1;
+   unsigned int data_partitioned   : 1;
+   unsigned int reversible_vlc : 1;
+   unsigned int resync_marker_disable  : 1;
+   } vol_fields;
+
+   struct {
+   unsigned int vop_coding_type: 2;
+   unsigned int 

[RFC 09/10] ARM: dts: sun5i: Use video-engine node

2016-08-25 Thread Florent Revest
Now that we have a driver matching "allwinner,sun5i-a13-video-engine" we
can load it.

The "video-engine" node depends on the new sunxi-ng's CCU clock and
reset bindings. This patch also includes a ve_reserved DMA pool for
videobuf2 buffer allocations in sunxi-cedrus.

Signed-off-by: Florent Revest 
---
 arch/arm/boot/dts/sun5i-a13.dtsi | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/arch/arm/boot/dts/sun5i-a13.dtsi b/arch/arm/boot/dts/sun5i-a13.dtsi
index 2afe05fb..384b645 100644
--- a/arch/arm/boot/dts/sun5i-a13.dtsi
+++ b/arch/arm/boot/dts/sun5i-a13.dtsi
@@ -69,6 +69,19 @@
};
};
 
+   reserved-memory {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+
+   ve_reserved: cma {
+   compatible = "shared-dma-pool";
+   reg = <0x43d0 0x900>;
+   no-map;
+   linux,cma-default;
+   };
+   };
+
thermal-zones {
cpu_thermal {
/* milliseconds */
@@ -330,6 +343,24 @@
};
};
 
+   video-engine {
+   compatible = "allwinner,sun5i-a13-video-engine";
+   memory-region = <_reserved>;
+
+   clocks = <_gates 32>, < CLK_VE>,
+<_gates 0>;
+   clock-names = "ahb", "mod", "ram";
+
+   assigned-clocks = < CLK_VE>;
+   assigned-clock-rates = <32000>;
+
+   resets = < RST_VE>;
+
+   interrupts = <53>;
+
+   reg = <0x01c0e000 4096>;
+   };
+
ccu: clock@01c2 {
compatible = "allwinner,sun5i-a13-ccu";
reg = <0x01c2 0x400>;
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC 07/10] sunxi-cedrus: Add a MPEG 2 codec

2016-08-25 Thread Florent Revest
This patch introduces the support of MPEG2 video decoding to the
sunxi-cedrus video decoder driver.

Signed-off-by: Florent Revest 
---
 drivers/media/platform/sunxi-cedrus/Makefile   |   2 +-
 drivers/media/platform/sunxi-cedrus/sunxi_cedrus.c |  26 +++-
 .../platform/sunxi-cedrus/sunxi_cedrus_common.h|   2 +
 .../media/platform/sunxi-cedrus/sunxi_cedrus_dec.c |  15 +-
 .../media/platform/sunxi-cedrus/sunxi_cedrus_hw.c  |  17 ++-
 .../media/platform/sunxi-cedrus/sunxi_cedrus_hw.h  |   4 +
 .../platform/sunxi-cedrus/sunxi_cedrus_mpeg2.c | 152 +
 7 files changed, 211 insertions(+), 7 deletions(-)
 create mode 100644 drivers/media/platform/sunxi-cedrus/sunxi_cedrus_mpeg2.c

diff --git a/drivers/media/platform/sunxi-cedrus/Makefile 
b/drivers/media/platform/sunxi-cedrus/Makefile
index 14c2f7a..2d495a2 100644
--- a/drivers/media/platform/sunxi-cedrus/Makefile
+++ b/drivers/media/platform/sunxi-cedrus/Makefile
@@ -1,2 +1,2 @@
 obj-$(CONFIG_VIDEO_SUNXI_CEDRUS) += sunxi_cedrus.o sunxi_cedrus_hw.o \
-   sunxi_cedrus_dec.o
+   sunxi_cedrus_dec.o sunxi_cedrus_mpeg2.o
diff --git a/drivers/media/platform/sunxi-cedrus/sunxi_cedrus.c 
b/drivers/media/platform/sunxi-cedrus/sunxi_cedrus.c
index 17af34c..d1c957a 100644
--- a/drivers/media/platform/sunxi-cedrus/sunxi_cedrus.c
+++ b/drivers/media/platform/sunxi-cedrus/sunxi_cedrus.c
@@ -46,14 +46,31 @@ static int sunxi_cedrus_s_ctrl(struct v4l2_ctrl *ctrl)
struct sunxi_cedrus_ctx *ctx =
container_of(ctrl->handler, struct sunxi_cedrus_ctx, hdl);
 
-   v4l2_err(>dev->v4l2_dev, "Invalid control\n");
-   return -EINVAL;
+   switch (ctrl->id) {
+   case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR:
+   /* This is kept in memory and used directly. */
+   break;
+   default:
+   v4l2_err(>dev->v4l2_dev, "Invalid control\n");
+   return -EINVAL;
+   }
+
+   return 0;
 }
 
 static const struct v4l2_ctrl_ops sunxi_cedrus_ctrl_ops = {
.s_ctrl = sunxi_cedrus_s_ctrl,
 };
 
+static const struct v4l2_ctrl_config sunxi_cedrus_ctrl_mpeg2_frame_hdr = {
+   .ops = _cedrus_ctrl_ops,
+   .id = V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR,
+   .type = V4L2_CTRL_TYPE_PRIVATE,
+   .name = "MPEG2 Frame Header Parameters",
+   .max_reqs = VIDEO_MAX_FRAME,
+   .elem_size = sizeof(struct v4l2_ctrl_mpeg2_frame_hdr),
+};
+
 /*
  * File operations
  */
@@ -78,6 +95,10 @@ static int sunxi_cedrus_open(struct file *file)
hdl = >hdl;
v4l2_ctrl_handler_init(hdl, 1);
 
+   ctx->mpeg2_frame_hdr_ctrl = v4l2_ctrl_new_custom(hdl,
+   _cedrus_ctrl_mpeg2_frame_hdr, NULL);
+   ctx->mpeg2_frame_hdr_ctrl->flags |= V4L2_CTRL_FLAG_REQ_KEEP;
+
if (hdl->error) {
rc = hdl->error;
v4l2_ctrl_handler_free(hdl);
@@ -117,6 +138,7 @@ static int sunxi_cedrus_release(struct file *file)
v4l2_fh_del(>fh);
v4l2_fh_exit(>fh);
v4l2_ctrl_handler_free(>hdl);
+   ctx->mpeg2_frame_hdr_ctrl = NULL;
mutex_lock(>dev_mutex);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
mutex_unlock(>dev_mutex);
diff --git a/drivers/media/platform/sunxi-cedrus/sunxi_cedrus_common.h 
b/drivers/media/platform/sunxi-cedrus/sunxi_cedrus_common.h
index 6b8d87a..e715184 100644
--- a/drivers/media/platform/sunxi-cedrus/sunxi_cedrus_common.h
+++ b/drivers/media/platform/sunxi-cedrus/sunxi_cedrus_common.h
@@ -70,6 +70,8 @@ struct sunxi_cedrus_ctx {
struct v4l2_ctrl_handler hdl;
 
struct vb2_buffer *dst_bufs[VIDEO_MAX_FRAME];
+
+   struct v4l2_ctrl *mpeg2_frame_hdr_ctrl;
 };
 
 static inline void sunxi_cedrus_write(struct sunxi_cedrus_dev *vpu,
diff --git a/drivers/media/platform/sunxi-cedrus/sunxi_cedrus_dec.c 
b/drivers/media/platform/sunxi-cedrus/sunxi_cedrus_dec.c
index 71ef34b..38e8a3a 100644
--- a/drivers/media/platform/sunxi-cedrus/sunxi_cedrus_dec.c
+++ b/drivers/media/platform/sunxi-cedrus/sunxi_cedrus_dec.c
@@ -48,6 +48,11 @@ static struct sunxi_cedrus_fmt formats[] = {
.depth = 8,
.num_planes = 2,
},
+   {
+   .fourcc = V4L2_PIX_FMT_MPEG2_FRAME,
+   .types  = SUNXI_CEDRUS_OUTPUT,
+   .num_planes = 1,
+   },
 };
 
 #define NUM_FORMATS ARRAY_SIZE(formats)
@@ -120,8 +125,14 @@ void device_run(void *priv)
 V4L2_BUF_FLAG_KEYFRAME | V4L2_BUF_FLAG_PFRAME |
 V4L2_BUF_FLAG_BFRAME   | V4L2_BUF_FLAG_TSTAMP_SRC_MASK);
 
-   v4l2_m2m_buf_done(in_vb, VB2_BUF_STATE_ERROR);
-   v4l2_m2m_buf_done(out_vb, VB2_BUF_STATE_ERROR);
+   if (ctx->vpu_src_fmt->fourcc == V4L2_PIX_FMT_MPEG2_FRAME) {
+   struct v4l2_ctrl_mpeg2_frame_hdr *frame_hdr =
+   ctx->mpeg2_frame_hdr_ctrl->p_new.p;
+   process_mpeg2(ctx, in_buf, 

[RFC 10/10] sunxi-cedrus: Add device tree binding document

2016-08-25 Thread Florent Revest
Device Tree bindings for the Allwinner's video engine

Signed-off-by: Florent Revest 
---
 .../devicetree/bindings/media/sunxi-cedrus.txt | 44 ++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/sunxi-cedrus.txt

diff --git a/Documentation/devicetree/bindings/media/sunxi-cedrus.txt 
b/Documentation/devicetree/bindings/media/sunxi-cedrus.txt
new file mode 100644
index 000..26f2e09
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/sunxi-cedrus.txt
@@ -0,0 +1,44 @@
+Device-Tree bindings for SUNXI video engine found in sunXi SoC family
+
+Required properties:
+- compatible   : "allwinner,sun5i-a13-video-engine";
+- memory-region : DMA pool for buffers allocation;
+- clocks   : list of clock specifiers, corresponding to
+ entries in clock-names property;
+- clock-names  : should contain "ahb", "mod" and "ram" entries;
+- resets   : phandle for reset;
+- interrupts   : should contain VE interrupt number;
+- reg  : should contain register base and length of VE.
+
+Example:
+
+reserved-memory {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+
+   ve_reserved: cma {
+   compatible = "shared-dma-pool";
+   reg = <0x43d0 0x900>;
+   no-map;
+   linux,cma-default;
+   };
+};
+
+video-engine {
+   compatible = "allwinner,sun5i-a13-video-engine";
+   memory-region = <_reserved>;
+
+   clocks = <_gates 32>, < CLK_VE>,
+<_gates 0>;
+   clock-names = "ahb", "mod", "ram";
+
+   assigned-clocks = < CLK_VE>;
+   assigned-clock-rates = <32000>;
+
+   resets = < RST_VE>;
+
+   interrupts = <53>;
+
+   reg = <0x01c0e000 4096>;
+};
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 2/2] media: Add a driver for the ov5645 camera sensor.

2016-08-25 Thread Sakari Ailus
Hi Todor,

On Wed, Aug 24, 2016 at 06:24:31PM +0300, Todor Tomov wrote:
> Hi Sakari,
> 
> Thanks a lot for the time spent to review the driver!

You're welcome! :-)

> I have a few responses bellow.
> 
> 
> On 08/24/2016 01:17 PM, Sakari Ailus wrote:
> > Hi Todor,
> > 
> > Thank you for the patch. Please see my comments below.
> > 
> > On Fri, Jul 08, 2016 at 05:54:39PM +0300, Todor Tomov wrote:
> >> The ov5645 sensor from Omnivision supports up to 2592x1944
> >> and CSI2 interface.
> >>
> >> The driver adds support for the following modes:
> >> - 1280x960
> >> - 1920x1080
> >> - 2592x1944
> >>
> >> Output format is packed 8bit UYVY.
> >>
> >> Signed-off-by: Todor Tomov 
> >> ---
> >>  drivers/media/i2c/Kconfig  |   12 +
> >>  drivers/media/i2c/Makefile |1 +
> >>  drivers/media/i2c/ov5645.c | 1371 
> >> 
> >>  3 files changed, 1384 insertions(+)
> >>  create mode 100644 drivers/media/i2c/ov5645.c
> >>
> >> diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
> >> index 993dc50..0cee05b 100644
> >> --- a/drivers/media/i2c/Kconfig
> >> +++ b/drivers/media/i2c/Kconfig
> >> @@ -500,6 +500,18 @@ config VIDEO_OV2659
> >>  To compile this driver as a module, choose M here: the
> >>  module will be called ov2659.
> >>  
> >> +config VIDEO_OV5645
> >> +  tristate "OmniVision OV5645 sensor support"
> >> +  depends on OF
> >> +  depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
> >> +  depends on MEDIA_CAMERA_SUPPORT
> >> +  ---help---
> >> +This is a Video4Linux2 sensor-level driver for the OmniVision
> >> +OV5645 camera.
> >> +
> >> +To compile this driver as a module, choose M here: the
> >> +module will be called ov5645.
> >> +
> >>  config VIDEO_OV7640
> >>tristate "OmniVision OV7640 sensor support"
> >>depends on I2C && VIDEO_V4L2
> >> diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
> >> index 94f2c99..2485aed 100644
> >> --- a/drivers/media/i2c/Makefile
> >> +++ b/drivers/media/i2c/Makefile
> >> @@ -55,6 +55,7 @@ obj-$(CONFIG_VIDEO_VP27SMPX) += vp27smpx.o
> >>  obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o
> >>  obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o
> >>  obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o
> >> +obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
> >>  obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
> >>  obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
> >>  obj-$(CONFIG_VIDEO_OV9650) += ov9650.o
> >> diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
> >> new file mode 100644
> >> index 000..ec96d10
> >> --- /dev/null
> >> +++ b/drivers/media/i2c/ov5645.c
> >> @@ -0,0 +1,1371 @@
> >> +/*
> >> + * Driver for the OV5645 camera sensor.
> >> + *
> >> + * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
> >> + * Copyright (C) 2015 By Tech Design S.L. All Rights Reserved.
> >> + * Copyright (C) 2012-2013 Freescale Semiconductor, Inc. All Rights 
> >> Reserved.
> >> + *
> >> + * Based on:
> >> + * - the OV5645 driver from QC msm-3.10 kernel on codeaurora.org:
> >> + *   https://us.codeaurora.org/cgit/quic/la/kernel/msm-3.10/tree/drivers/
> >> + *   media/platform/msm/camera_v2/sensor/ov5645.c?h=LA.BR.1.2.4_rb1.41
> >> + * - the OV5640 driver posted on linux-media:
> >> + *   
> >> https://www.mail-archive.com/linux-media%40vger.kernel.org/msg92671.html
> >> + */
> >> +
> >> +/*
> >> + * This program is free software; you can redistribute it and/or modify
> >> + * it under the terms of the GNU General Public License as published by
> >> + * the Free Software Foundation; either version 2 of the License, or
> >> + * (at your option) any later version.
> >> +
> >> + * This program is distributed in the hope that it will be useful,
> >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> >> + * GNU General Public License for more details.
> >> + */
> >> +
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +
> >> +#define OV5645_VOLTAGE_ANALOG   280
> >> +#define OV5645_VOLTAGE_DIGITAL_CORE 150
> >> +#define OV5645_VOLTAGE_DIGITAL_IO   180
> >> +
> >> +#define OV5645_XCLK   2388
> > 
> > Is this really a property of the sensor itself? Shouldn't this go to the DT
> > instead? And 23,88 MHz seems pretty unusual for an external clock frequency.
> > 
> > Even if your driver only could use this frequency for now, the DT still
> > should contain the real board specific frequency.
> 
> Yes, 23.88MHz is the value of the external clock frequency.
> The sensor mode settings (the big sensor register settings arrays below)
> are calculated over this value. Changing the external clock frequency
> implies different sensor 

[PATCH] [media] tw5864-core: remove excessive irqsave

2016-08-25 Thread Andrey Utkin
As warned by smatch:
drivers/media/pci/tw5864/tw5864-core.c:160 tw5864_h264_isr() error: 
double lock 'irqsave:flags'
drivers/media/pci/tw5864/tw5864-core.c:174 tw5864_h264_isr() error: 
double unlock 'irqsave:flags'

Two different spinlocks are obtained, so having two calls is correct,
but second irqsave is superfluous, and using same "flags" variable is
just wrong.

Reported-by: Mauro Carvalho Chehab 
Signed-off-by: Andrey Utkin 
---
 drivers/media/pci/tw5864/tw5864-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/tw5864/tw5864-core.c 
b/drivers/media/pci/tw5864/tw5864-core.c
index 440cd7b..1d43b96 100644
--- a/drivers/media/pci/tw5864/tw5864-core.c
+++ b/drivers/media/pci/tw5864/tw5864-core.c
@@ -157,12 +157,12 @@ static void tw5864_h264_isr(struct tw5864_dev *dev)
 
cur_frame = next_frame;
 
-   spin_lock_irqsave(>slock, flags);
+   spin_lock(>slock);
input->frame_seqno++;
input->frame_gop_seqno++;
if (input->frame_gop_seqno >= input->gop)
input->frame_gop_seqno = 0;
-   spin_unlock_irqrestore(>slock, flags);
+   spin_unlock(>slock);
} else {
dev_err(>pci->dev,
"Skipped frame on input %d because all buffers busy\n",
-- 
2.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html