Re: [RFC PATCH 00/24] Make Nokia N900 cameras working

2016-04-25 Thread Ivaylo Dimitrov

Hi,

On 26.04.2016 01:07, Pavel Machek wrote:

Hi!


Hi!


All my testing so far was performed using modules, though it shouldn't make
difference.


https://lkml.org/lkml/2016/4/16/14
https://lkml.org/lkml/2016/4/16/33



More stuff is needed, all those twl4030 regulator patches (already in
linux-next) + DTS initial-mode patch
(https://lkml.org/lkml/2016/4/17/78).


Aha, that explains a lot. Dealing with -next would be tricky, I guess;
can I just pull from your camera branch?

https://github.com/freemangordon/linux-n900/tree/camera


I guess yes, though I am not sure all the patches there are compatible with
userland different from maemo, so be careful. Also, the correct branch is
v4.6-rc4-n900-camera.


I tried v4.6-rc4-n900-camera, but got the same results: green mplayer
window, if I try to use front or back camera. Assuming
v4.6-rc4-n900-camera works for you, could I get your .config and list
of modules loaded during the test?



.config is 'make rx51_defconfig' from v4.6-rc4-n900-camera branch, with 
added:


CONFIG_VIDEO_BUS_SWITCH=m
CONFIG_VIDEO_SMIAREGS=m
CONFIG_VIDEO_ET8EK8=m

For some reason I have to do 'modprobe smiapp' after every reboot, 
before using cameras.


After taking a nap, a question came to my mind - what is that device 
you're using? As some early board versions use VAUX3 for cameras as well.


awk '{ printf "%s ",$1 }' /proc/modules results in:

smiapp smiapp_pll sha256_generic hmac drbg ansi_cprng ctr ccm vfat fat 
rfcomm sd_mod scsi_mod bnep bluetooth omaplfb pvrsrvkm ipv6 
bq2415x_charger uinput radio_platform_si4713 joydev cmt_speech hsi_char 
video_bus_switch arc4 wl1251_spi isp1704_charger wl1251 gpio_keys 
mac80211 smc91x mii cfg80211 omap3_isp videobuf2_v4l2 omap_wdt 
videobuf2_dma_contig omap_sham crc7 videobuf2_memops videobuf2_core 
tsc2005 tsc200x_core leds_lp5523 bq27xxx_battery_i2c si4713 adp1653 
tsl2563 bq27xxx_battery leds_lp55xx_common twl4030_wdt rtc_twl et8ek8 
v4l2_common smiaregs videodev twl4030_vibra ff_memless lis3lv02d_i2c 
lis3lv02d media input_polldev omap_ssi_port ti_soc_thermal nokia_modem 
ssi_protocol omap_ssi hsi rx51_battery


Regards,
Ivo
--
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: mceusb xhci issue?

2016-04-25 Thread Wade Berrier
On Apr 25 18:15, Sean Young wrote:
> On Sun, Apr 24, 2016 at 10:06:33PM -0600, Wade Berrier wrote:
> > Hello,
> > 
> > I have a mceusb compatible transceiver that only seems to work with
> > certain computers.  I'm testing this on centos7 (3.10.0) and fedora23
> > (4.4.7).
> > 
> > The only difference I can see is that the working computer shows
> > "using uhci_hcd" and the non working shows "using xhci_hcd".
> > 
> > Here's the dmesg output of the non-working version:
> > 
> > -
> > 
> > [  217.951079] usb 1-5: new full-speed USB device number 10 using xhci_hcd
> > [  218.104087] usb 1-5: device descriptor read/64, error -71
> > [  218.371010] usb 1-5: config 1 interface 0 altsetting 0 endpoint 0x1 has 
> > an invalid bInterval 0, changing to 32
> > [  218.371019] usb 1-5: config 1 interface 0 altsetting 0 endpoint 0x81 has 
> > an invalid bInterval 0, changing to 32
> 
> That's odd. Can you post a "lsusb -vvv" of the device please?
> 

Sure.

---

Bus 002 Device 009: ID 1784:0006 TopSeed Technology Corp. eHome Infrared 
Transceiver
Device Descriptor:
  bLength18
  bDescriptorType 1
  bcdUSB   2.00
  bDeviceClass0 
  bDeviceSubClass 0 
  bDeviceProtocol 0 
  bMaxPacketSize0 8
  idVendor   0x1784 TopSeed Technology Corp.
  idProduct  0x0006 eHome Infrared Transceiver
  bcdDevice1.02
  iManufacturer   1 TopSeed Technology Corp.
  iProduct2 eHome Infrared Transceiver
  iSerial 3 TS004RrP
  bNumConfigurations  1
  Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength   32
bNumInterfaces  1
bConfigurationValue 1
iConfiguration  0 
bmAttributes 0xa0
  (Bus Powered)
  Remote Wakeup
MaxPower  100mA
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber0
  bAlternateSetting   0
  bNumEndpoints   2
  bInterfaceClass   255 Vendor Specific Class
  bInterfaceSubClass255 Vendor Specific Subclass
  bInterfaceProtocol255 Vendor Specific Protocol
  iInterface  0 
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01  EP 1 OUT
bmAttributes3
  Transfer TypeInterrupt
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0020  1x 32 bytes
bInterval   0
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81  EP 1 IN
bmAttributes3
  Transfer TypeInterrupt
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0020  1x 32 bytes
bInterval   0
Device Status: 0x0001
  Self Powered

---

Also, here's a link to a response on the lirc list:

https://sourceforge.net/p/lirc/mailman/message/35039126/

Wade
--
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


cron job: media_tree daily build: OK

2016-04-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:   Tue Apr 26 04:00:21 CEST 2016
git branch: test
git hash:   363d79f1d5bd09158cc28db543ca18549a5d7e52
gcc version:i686-linux-gcc (GCC) 5.3.0
sparse version: v0.5.0-56-g7647c77
smatch version: v0.5.0-3413-g618cd5c
host hardware:  x86_64
host os:4.5.0-164

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: OK
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin-bf561: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.36.4-i686: 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: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: OK
linux-3.5.7-i686: OK
linux-3.6.11-i686: OK
linux-3.7.4-i686: OK
linux-3.8-i686: OK
linux-3.9.2-i686: OK
linux-3.10.1-i686: OK
linux-3.11.1-i686: OK
linux-3.12.23-i686: OK
linux-3.13.11-i686: OK
linux-3.14.9-i686: OK
linux-3.15.2-i686: OK
linux-3.16.7-i686: OK
linux-3.17.8-i686: OK
linux-3.18.7-i686: OK
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-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: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-x86_64: OK
linux-3.7.4-x86_64: OK
linux-3.8-x86_64: OK
linux-3.9.2-x86_64: OK
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: OK
linux-3.12.23-x86_64: OK
linux-3.13.11-x86_64: OK
linux-3.14.9-x86_64: OK
linux-3.15.2-x86_64: OK
linux-3.16.7-x86_64: OK
linux-3.17.8-x86_64: OK
linux-3.18.7-x86_64: OK
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-rc1-x86_64: OK
apps: OK
spec-git: OK
sparse: WARNINGS
smatch: ERRORS

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/media.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


Re: [PATCH v8 5/8] [media] vcodec: mediatek: Add Mediatek V4L2 Video Encoder Driver

2016-04-25 Thread tiffany lin
Hi Hans,

On Mon, 2016-04-25 at 15:13 +0200, Hans Verkuil wrote:
> On 04/25/2016 02:30 PM, Tiffany Lin wrote:
> > Add v4l2 layer encoder driver for MT8173
> > 
> > Signed-off-by: Tiffany Lin 
> > 
> > ---
> >  drivers/media/platform/Kconfig |   16 +
> >  drivers/media/platform/Makefile|2 +
> >  drivers/media/platform/mtk-vcodec/Makefile |   14 +
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |  339 +
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 1303 
> > 
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.h |   58 +
> >  .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c |  456 +++
> >  .../media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c  |  137 ++
> >  .../media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h  |   26 +
> >  .../media/platform/mtk-vcodec/mtk_vcodec_intr.c|   56 +
> >  .../media/platform/mtk-vcodec/mtk_vcodec_intr.h|   27 +
> >  .../media/platform/mtk-vcodec/mtk_vcodec_util.c|   96 ++
> >  .../media/platform/mtk-vcodec/mtk_vcodec_util.h|   87 ++
> >  drivers/media/platform/mtk-vcodec/venc_drv_base.h  |   62 +
> >  drivers/media/platform/mtk-vcodec/venc_drv_if.c|  107 ++
> >  drivers/media/platform/mtk-vcodec/venc_drv_if.h|  165 +++
> >  drivers/media/platform/mtk-vcodec/venc_ipi_msg.h   |  210 
> >  17 files changed, 3161 insertions(+)
> >  create mode 100644 drivers/media/platform/mtk-vcodec/Makefile
> >  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> >  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> >  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.h
> >  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> >  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
> >  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h
> >  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.c
> >  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.h
> >  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c
> >  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> >  create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_base.h
> >  create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_if.c
> >  create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_if.h
> >  create mode 100644 drivers/media/platform/mtk-vcodec/venc_ipi_msg.h
> > 
> 
> ...
> 
> > +static int fops_vcodec_open(struct file *file)
> > +{
> > +   struct mtk_vcodec_dev *dev = video_drvdata(file);
> > +   struct mtk_vcodec_ctx *ctx = NULL;
> > +   int ret = 0;
> > +
> > +   mutex_lock(>dev_mutex);
> 
> I would move this to after the kzalloc, since that doesn't need to be
> called with the mutex held.
> 
Will fix this in next version.

> > +
> > +   ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
> > +   if (!ctx) {
> 
> And then you can just do return -ENOMEM here.
> 
Got it.
> > +   ret = -ENOMEM;
> > +   goto err_alloc;
> > +   }
> > +
> > +   ctx->idx = dev->curr_max_idx;
> 
> I'd do:
> 
>   /*
>* Use simple counter to uniquely identify this context. Only
>* used for logging.
>*/
>   ctx->idx = dev->curr_max_idx++;
> 
> I would also prefer that it is call 'id' instead of idx, since that's really
> what it is, just an ID.
> 
> And the counter is then id_counter instead of curr_max_idx.
> 
Got it, will fix this in next version.

> > +   v4l2_fh_init(>fh, video_devdata(file));
> > +   file->private_data = >fh;
> > +   v4l2_fh_add(>fh);
> > +   INIT_LIST_HEAD(>list);
> > +   ctx->dev = dev;
> > +   init_waitqueue_head(>queue);
> > +
> > +   ctx->type = MTK_INST_ENCODER;
> > +   ret = mtk_vcodec_enc_ctrls_setup(ctx);
> > +   if (ret) {
> > +   mtk_v4l2_err("Failed to setup controls() (%d)",
> > +   ret);
> > +   goto err_ctrls_setup;
> > +   }
> > +   ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev_enc, ctx,
> > +   _vcodec_enc_queue_init);
> > +   if (IS_ERR(ctx->m2m_ctx)) {
> > +   ret = PTR_ERR(ctx->m2m_ctx);
> > +   mtk_v4l2_err("Failed to v4l2_m2m_ctx_init() (%d)",
> > +   ret);
> > +   goto err_m2m_ctx_init;
> > +   }
> > +   mtk_vcodec_enc_set_default_params(ctx);
> > +
> > +   if (v4l2_fh_is_singular(>fh)) {
> > +   /*
> > +* vpu_load_firmware checks if it was loaded already and
> > +* does nothing in that case
> > +*/
> > +   ret = vpu_load_firmware(dev->vpu_plat_dev);
> > +   if (ret < 0) {
> > +   /*
> > +* Return 0 if downloading firmware successfully,
> > +* otherwise it is failed
> > +*/
> > +   mtk_v4l2_err("vpu_load_firmware failed!");
> > +   

[PATCH/RFC] dmxdev: Add support for the FIONREAD ioctl

2016-04-25 Thread Dominic Chen
This is a standard ioctl supported by file descriptors, sockets (as
SIOCINQ), and ttys (as TIOCOUTQ) to get the size of the available
read buffer. It provides userspace with a feedback mechanism to
avoid overflow of the kernel ringbuffer, and is used by e.g.
libevent.

Signed-off-by: Dominic Chen 
---
 drivers/media/dvb-core/dmxdev.c | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c
index a168cbe..668c8d2 100644
--- a/drivers/media/dvb-core/dmxdev.c
+++ b/drivers/media/dvb-core/dmxdev.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "dmxdev.h"
 
@@ -57,6 +58,22 @@ static int dvb_dmxdev_buffer_write(struct dvb_ringbuffer 
*buf,
return dvb_ringbuffer_write(buf, src, len);
 }
 
+static int dvb_dmxdev_get_buffer_avail(struct dvb_ringbuffer *src,
+  u32 *len)
+{
+   if (!src->data) {
+   *len = 0;
+   return 0;
+   }
+
+   if (src->error)
+   return src->error;
+
+   *len = dvb_ringbuffer_avail(src);
+
+   return 0;
+}
+
 static ssize_t dvb_dmxdev_buffer_read(struct dvb_ringbuffer *src,
  int non_blocking, char __user *buf,
  size_t count, loff_t *ppos)
@@ -965,6 +982,16 @@ static int dvb_demux_do_ioctl(struct file *file,
return -ERESTARTSYS;
 
switch (cmd) {
+   case FIONREAD:
+   if (mutex_lock_interruptible(>mutex)) {
+   mutex_unlock(>mutex);
+   return -ERESTARTSYS;
+   }
+   ret = dvb_dmxdev_get_buffer_avail(>buffer, parg);
+   mutex_unlock(>mutex);
+
+   break;
+
case DMX_START:
if (mutex_lock_interruptible(>mutex)) {
mutex_unlock(>mutex);
@@ -1160,6 +1187,10 @@ static int dvb_dvr_do_ioctl(struct file *file,
return -ERESTARTSYS;
 
switch (cmd) {
+   case FIONREAD:
+   ret = dvb_dmxdev_get_buffer_avail(>dvr_buffer, parg);
+   break;
+
case DMX_SET_BUFFER_SIZE:
ret = dvb_dvr_set_buffer_size(dmxdev, arg);
break;
-- 
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: [RFC PATCH 00/24] Make Nokia N900 cameras working

2016-04-25 Thread Pavel Machek
Hi!

> >Hi!
> >
> >>All my testing so far was performed using modules, though it shouldn't make
> >>difference.
> >>
> >>>https://lkml.org/lkml/2016/4/16/14
> >>>https://lkml.org/lkml/2016/4/16/33
> >>>
> >>
> >>More stuff is needed, all those twl4030 regulator patches (already in
> >>linux-next) + DTS initial-mode patch
> >>(https://lkml.org/lkml/2016/4/17/78).
> >
> >Aha, that explains a lot. Dealing with -next would be tricky, I guess;
> >can I just pull from your camera branch?
> >
> >https://github.com/freemangordon/linux-n900/tree/camera
> 
> I guess yes, though I am not sure all the patches there are compatible with
> userland different from maemo, so be careful. Also, the correct branch is
> v4.6-rc4-n900-camera.

I tried v4.6-rc4-n900-camera, but got the same results: green mplayer
window, if I try to use front or back camera. Assuming
v4.6-rc4-n900-camera works for you, could I get your .config and list
of modules loaded during the test?

Thanks a lot,
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.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


[PATCH v2 11/13] drm: rcar-du: Add alpha support for VSP planes

2016-04-25 Thread Laurent Pinchart
Make the global alpha multiplier of VSP planes configurable through the
alpha property, exactly as for the native DU planes.

Signed-off-by: Laurent Pinchart 
Acked-by: Dave Airlie 
---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 38 +--
 1 file changed, 19 insertions(+), 19 deletions(-)

Cc: dri-de...@lists.freedesktop.org

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c 
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
index de7ef041182b..8c89a6401542 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
@@ -148,40 +148,41 @@ static void rcar_du_vsp_plane_setup(struct 
rcar_du_vsp_plane *plane)
struct rcar_du_vsp_plane_state *state =
to_rcar_vsp_plane_state(plane->plane.state);
struct drm_framebuffer *fb = plane->plane.state->fb;
-   struct v4l2_rect src;
-   struct v4l2_rect dst;
-   dma_addr_t paddr[2] = { 0, };
-   u32 pixelformat = 0;
+   struct vsp1_du_atomic_config cfg = {
+   .pixelformat = 0,
+   .pitch = fb->pitches[0],
+   .alpha = state->alpha,
+   .zpos = 0,
+   };
unsigned int i;
 
-   src.left = state->state.src_x >> 16;
-   src.top = state->state.src_y >> 16;
-   src.width = state->state.src_w >> 16;
-   src.height = state->state.src_h >> 16;
+   cfg.src.left = state->state.src_x >> 16;
+   cfg.src.top = state->state.src_y >> 16;
+   cfg.src.width = state->state.src_w >> 16;
+   cfg.src.height = state->state.src_h >> 16;
 
-   dst.left = state->state.crtc_x;
-   dst.top = state->state.crtc_y;
-   dst.width = state->state.crtc_w;
-   dst.height = state->state.crtc_h;
+   cfg.dst.left = state->state.crtc_x;
+   cfg.dst.top = state->state.crtc_y;
+   cfg.dst.width = state->state.crtc_w;
+   cfg.dst.height = state->state.crtc_h;
 
for (i = 0; i < state->format->planes; ++i) {
struct drm_gem_cma_object *gem;
 
gem = drm_fb_cma_get_gem_obj(fb, i);
-   paddr[i] = gem->paddr + fb->offsets[i];
+   cfg.mem[i] = gem->paddr + fb->offsets[i];
}
 
for (i = 0; i < ARRAY_SIZE(formats_kms); ++i) {
if (formats_kms[i] == state->format->fourcc) {
-   pixelformat = formats_v4l2[i];
+   cfg.pixelformat = formats_v4l2[i];
break;
}
}
 
-   WARN_ON(!pixelformat);
+   WARN_ON(!cfg.pixelformat);
 
-   vsp1_du_atomic_update(plane->vsp->vsp, plane->index, pixelformat,
- fb->pitches[0], paddr, , );
+   vsp1_du_atomic_update(plane->vsp->vsp, plane->index, );
 }
 
 static int rcar_du_vsp_plane_atomic_check(struct drm_plane *plane,
@@ -220,8 +221,7 @@ static void rcar_du_vsp_plane_atomic_update(struct 
drm_plane *plane,
if (plane->state->crtc)
rcar_du_vsp_plane_setup(rplane);
else
-   vsp1_du_atomic_update(rplane->vsp->vsp, rplane->index, 0, 0, 0,
- NULL, NULL);
+   vsp1_du_atomic_update(rplane->vsp->vsp, rplane->index, NULL);
 }
 
 static const struct drm_plane_helper_funcs rcar_du_vsp_plane_helper_funcs = {
-- 
2.7.3

--
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


[PATCH v2 12/13] drm: rcar-du: Add Z-order support for VSP planes

2016-04-25 Thread Laurent Pinchart
Make the Z-order of VSP planes configurable through the zpos property,
exactly as for the native DU planes.

Signed-off-by: Laurent Pinchart 
Acked-by: Dave Airlie 
---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 11 ---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.h |  2 ++
 2 files changed, 10 insertions(+), 3 deletions(-)

Cc: dri-de...@lists.freedesktop.org

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c 
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
index 8c89a6401542..4927fb3b8554 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
@@ -152,7 +152,7 @@ static void rcar_du_vsp_plane_setup(struct 
rcar_du_vsp_plane *plane)
.pixelformat = 0,
.pitch = fb->pitches[0],
.alpha = state->alpha,
-   .zpos = 0,
+   .zpos = state->zpos,
};
unsigned int i;
 
@@ -180,8 +180,6 @@ static void rcar_du_vsp_plane_setup(struct 
rcar_du_vsp_plane *plane)
}
}
 
-   WARN_ON(!cfg.pixelformat);
-
vsp1_du_atomic_update(plane->vsp->vsp, plane->index, );
 }
 
@@ -269,6 +267,7 @@ static void rcar_du_vsp_plane_reset(struct drm_plane *plane)
return;
 
state->alpha = 255;
+   state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
 
plane->state = >state;
plane->state->plane = plane;
@@ -283,6 +282,8 @@ static int rcar_du_vsp_plane_atomic_set_property(struct 
drm_plane *plane,
 
if (property == rcdu->props.alpha)
rstate->alpha = val;
+   else if (property == rcdu->props.zpos)
+   rstate->zpos = val;
else
return -EINVAL;
 
@@ -299,6 +300,8 @@ static int rcar_du_vsp_plane_atomic_get_property(struct 
drm_plane *plane,
 
if (property == rcdu->props.alpha)
*val = rstate->alpha;
+   else if (property == rcdu->props.zpos)
+   *val = rstate->zpos;
else
return -EINVAL;
 
@@ -378,6 +381,8 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp)
 
drm_object_attach_property(>plane.base,
   rcdu->props.alpha, 255);
+   drm_object_attach_property(>plane.base,
+  rcdu->props.zpos, 1);
}
 
return 0;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.h 
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.h
index df3bf3805c69..510dcc9c6816 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.h
@@ -44,6 +44,7 @@ static inline struct rcar_du_vsp_plane 
*to_rcar_vsp_plane(struct drm_plane *p)
  * @state: base DRM plane state
  * @format: information about the pixel format used by the plane
  * @alpha: value of the plane alpha property
+ * @zpos: value of the plane zpos property
  */
 struct rcar_du_vsp_plane_state {
struct drm_plane_state state;
@@ -51,6 +52,7 @@ struct rcar_du_vsp_plane_state {
const struct rcar_du_format_info *format;
 
unsigned int alpha;
+   unsigned int zpos;
 };
 
 static inline struct rcar_du_vsp_plane_state *
-- 
2.7.3

--
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


[PATCH v2 04/13] v4l: vsp1: Don't handle clocks manually

2016-04-25 Thread Laurent Pinchart
The power domain performs functional clock handling when using runtime
PM, there's no need to enable and disable the clock manually.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/vsp1.h |  1 -
 drivers/media/platform/vsp1/vsp1_drv.c | 20 ++--
 2 files changed, 2 insertions(+), 19 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1.h 
b/drivers/media/platform/vsp1/vsp1.h
index 9e09bce43cf3..37cc05e34de0 100644
--- a/drivers/media/platform/vsp1/vsp1.h
+++ b/drivers/media/platform/vsp1/vsp1.h
@@ -62,7 +62,6 @@ struct vsp1_device {
const struct vsp1_device_info *info;
 
void __iomem *mmio;
-   struct clk *clock;
 
struct vsp1_bru *bru;
struct vsp1_hsit *hsi;
diff --git a/drivers/media/platform/vsp1/vsp1_drv.c 
b/drivers/media/platform/vsp1/vsp1_drv.c
index d6abc7f1216a..13907d4f08af 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -514,10 +514,6 @@ static int vsp1_pm_resume(struct device *dev)
 
 static int vsp1_pm_runtime_suspend(struct device *dev)
 {
-   struct vsp1_device *vsp1 = dev_get_drvdata(dev);
-
-   clk_disable_unprepare(vsp1->clock);
-
return 0;
 }
 
@@ -526,16 +522,10 @@ static int vsp1_pm_runtime_resume(struct device *dev)
struct vsp1_device *vsp1 = dev_get_drvdata(dev);
int ret;
 
-   ret = clk_prepare_enable(vsp1->clock);
-   if (ret < 0)
-   return ret;
-
if (vsp1->info) {
ret = vsp1_device_init(vsp1);
-   if (ret < 0) {
-   clk_disable_unprepare(vsp1->clock);
+   if (ret < 0)
return ret;
-   }
}
 
return 0;
@@ -640,18 +630,12 @@ static int vsp1_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, vsp1);
 
-   /* I/O, IRQ and clock resources */
+   /* I/O and IRQ resources (clock managed by the clock PM domain) */
io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
vsp1->mmio = devm_ioremap_resource(>dev, io);
if (IS_ERR(vsp1->mmio))
return PTR_ERR(vsp1->mmio);
 
-   vsp1->clock = devm_clk_get(>dev, NULL);
-   if (IS_ERR(vsp1->clock)) {
-   dev_err(>dev, "failed to get clock\n");
-   return PTR_ERR(vsp1->clock);
-   }
-
irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!irq) {
dev_err(>dev, "missing IRQ\n");
-- 
2.7.3

--
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


[PATCH v2 09/13] v4l: vsp1: Move frame sequence number from video node to pipeline

2016-04-25 Thread Laurent Pinchart
The frame sequence number is global to the pipeline, there's no need to
store copies in each video node.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/vsp1_pipe.c  | 2 ++
 drivers/media/platform/vsp1/vsp1_pipe.h  | 2 ++
 drivers/media/platform/vsp1/vsp1_video.c | 4 +---
 drivers/media/platform/vsp1/vsp1_video.h | 1 -
 4 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_pipe.c 
b/drivers/media/platform/vsp1/vsp1_pipe.c
index 0c1dc80eb304..be47c8a1a812 100644
--- a/drivers/media/platform/vsp1/vsp1_pipe.c
+++ b/drivers/media/platform/vsp1/vsp1_pipe.c
@@ -286,6 +286,8 @@ void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe)
 
if (pipe->frame_end)
pipe->frame_end(pipe);
+
+   pipe->sequence++;
 }
 
 /*
diff --git a/drivers/media/platform/vsp1/vsp1_pipe.h 
b/drivers/media/platform/vsp1/vsp1_pipe.h
index 7b56113511dd..febc62f99d6d 100644
--- a/drivers/media/platform/vsp1/vsp1_pipe.h
+++ b/drivers/media/platform/vsp1/vsp1_pipe.h
@@ -67,6 +67,7 @@ enum vsp1_pipeline_state {
  * @kref: pipeline reference count
  * @stream_count: number of streaming video nodes
  * @buffers_ready: bitmask of RPFs and WPFs with at least one buffer available
+ * @sequence: frame sequence number
  * @num_inputs: number of RPFs
  * @inputs: array of RPFs in the pipeline (indexed by RPF index)
  * @output: WPF at the output of the pipeline
@@ -90,6 +91,7 @@ struct vsp1_pipeline {
struct kref kref;
unsigned int stream_count;
unsigned int buffers_ready;
+   unsigned int sequence;
 
unsigned int num_inputs;
struct vsp1_rwpf *inputs[VSP1_MAX_RPF];
diff --git a/drivers/media/platform/vsp1/vsp1_video.c 
b/drivers/media/platform/vsp1/vsp1_video.c
index a9aec5c0bec6..34aa6427662d 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -219,7 +219,7 @@ vsp1_video_complete_buffer(struct vsp1_video *video)
 
spin_unlock_irqrestore(>irqlock, flags);
 
-   done->buf.sequence = video->sequence++;
+   done->buf.sequence = pipe->sequence;
done->buf.vb2_buf.timestamp = ktime_get_ns();
for (i = 0; i < done->buf.vb2_buf.num_planes; ++i)
vb2_set_plane_payload(>buf.vb2_buf, i,
@@ -805,8 +805,6 @@ vsp1_video_streamon(struct file *file, void *fh, enum 
v4l2_buf_type type)
if (video->queue.owner && video->queue.owner != file->private_data)
return -EBUSY;
 
-   video->sequence = 0;
-
/* Get a pipeline for the video node and start streaming on it. No link
 * touching an entity in the pipeline can be activated or deactivated
 * once streaming is started.
diff --git a/drivers/media/platform/vsp1/vsp1_video.h 
b/drivers/media/platform/vsp1/vsp1_video.h
index 867b00807c46..1595fd587fbc 100644
--- a/drivers/media/platform/vsp1/vsp1_video.h
+++ b/drivers/media/platform/vsp1/vsp1_video.h
@@ -49,7 +49,6 @@ struct vsp1_video {
void *alloc_ctx;
spinlock_t irqlock;
struct list_head irqqueue;
-   unsigned int sequence;
 };
 
 static inline struct vsp1_video *to_vsp1_video(struct video_device *vdev)
-- 
2.7.3

--
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


[PATCH v2 08/13] v4l: vsp1: Make vsp1_entity_get_pad_compose() more generic

2016-04-25 Thread Laurent Pinchart
Turn the helper into a function that can retrieve crop and compose
selection rectangles.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/vsp1_entity.c | 24 
 drivers/media/platform/vsp1/vsp1_entity.h |  6 +++---
 drivers/media/platform/vsp1/vsp1_rpf.c|  7 ---
 3 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_entity.c 
b/drivers/media/platform/vsp1/vsp1_entity.c
index f60d7926d53f..8c49a74381a1 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.c
+++ b/drivers/media/platform/vsp1/vsp1_entity.c
@@ -87,12 +87,28 @@ vsp1_entity_get_pad_format(struct vsp1_entity *entity,
return v4l2_subdev_get_try_format(>subdev, cfg, pad);
 }
 
+/**
+ * vsp1_entity_get_pad_selection - Get a pad selection from storage for entity
+ * @entity: the entity
+ * @cfg: the configuration storage
+ * @pad: the pad number
+ * @target: the selection target
+ *
+ * Return the selection rectangle stored in the given configuration for an
+ * entity's pad. The configuration can be an ACTIVE or TRY configuration. The
+ * selection target can be COMPOSE or CROP.
+ */
 struct v4l2_rect *
-vsp1_entity_get_pad_compose(struct vsp1_entity *entity,
-   struct v4l2_subdev_pad_config *cfg,
-   unsigned int pad)
+vsp1_entity_get_pad_selection(struct vsp1_entity *entity,
+ struct v4l2_subdev_pad_config *cfg,
+ unsigned int pad, unsigned int target)
 {
-   return v4l2_subdev_get_try_compose(>subdev, cfg, pad);
+   if (target == V4L2_SEL_TGT_COMPOSE)
+   return v4l2_subdev_get_try_compose(>subdev, cfg, pad);
+   else if (target == V4L2_SEL_TGT_CROP)
+   return v4l2_subdev_get_try_crop(>subdev, cfg, pad);
+   else
+   return NULL;
 }
 
 /*
diff --git a/drivers/media/platform/vsp1/vsp1_entity.h 
b/drivers/media/platform/vsp1/vsp1_entity.h
index aaab05f4952c..a240fc1c59a6 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.h
+++ b/drivers/media/platform/vsp1/vsp1_entity.h
@@ -122,9 +122,9 @@ vsp1_entity_get_pad_format(struct vsp1_entity *entity,
   struct v4l2_subdev_pad_config *cfg,
   unsigned int pad);
 struct v4l2_rect *
-vsp1_entity_get_pad_compose(struct vsp1_entity *entity,
-   struct v4l2_subdev_pad_config *cfg,
-   unsigned int pad);
+vsp1_entity_get_pad_selection(struct vsp1_entity *entity,
+ struct v4l2_subdev_pad_config *cfg,
+ unsigned int pad, unsigned int target);
 int vsp1_entity_init_cfg(struct v4l2_subdev *subdev,
 struct v4l2_subdev_pad_config *cfg);
 
diff --git a/drivers/media/platform/vsp1/vsp1_rpf.c 
b/drivers/media/platform/vsp1/vsp1_rpf.c
index 49168db3f529..64dfbddf2aba 100644
--- a/drivers/media/platform/vsp1/vsp1_rpf.c
+++ b/drivers/media/platform/vsp1/vsp1_rpf.c
@@ -130,9 +130,10 @@ static void rpf_configure(struct vsp1_entity *entity,
if (pipe->bru) {
const struct v4l2_rect *compose;
 
-   compose = vsp1_entity_get_pad_compose(pipe->bru,
- pipe->bru->config,
- rpf->bru_input);
+   compose = vsp1_entity_get_pad_selection(pipe->bru,
+   pipe->bru->config,
+   rpf->bru_input,
+   V4L2_SEL_TGT_COMPOSE);
left = compose->left;
top = compose->top;
}
-- 
2.7.3

--
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


[PATCH v2 07/13] v4l: vsp1: Replace container_of() with dedicated macro

2016-04-25 Thread Laurent Pinchart
Add a macro to cast from a struct media_entity to a struct vsp1_entity
to replace the manual implementations.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/vsp1_entity.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_entity.c 
b/drivers/media/platform/vsp1/vsp1_entity.c
index 6a96ea77de69..f60d7926d53f 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.c
+++ b/drivers/media/platform/vsp1/vsp1_entity.c
@@ -22,6 +22,12 @@
 #include "vsp1_dl.h"
 #include "vsp1_entity.h"
 
+static inline struct vsp1_entity *
+media_entity_to_vsp1_entity(struct media_entity *entity)
+{
+   return container_of(entity, struct vsp1_entity, subdev.entity);
+}
+
 void vsp1_entity_route_setup(struct vsp1_entity *source,
 struct vsp1_dl_list *dl)
 {
@@ -30,7 +36,7 @@ void vsp1_entity_route_setup(struct vsp1_entity *source,
if (source->route->reg == 0)
return;
 
-   sink = container_of(source->sink, struct vsp1_entity, subdev.entity);
+   sink = media_entity_to_vsp1_entity(source->sink);
vsp1_dl_list_write(dl, source->route->reg,
   sink->route->inputs[source->sink_pad]);
 }
@@ -252,7 +258,7 @@ int vsp1_entity_link_setup(struct media_entity *entity,
if (!(local->flags & MEDIA_PAD_FL_SOURCE))
return 0;
 
-   source = container_of(local->entity, struct vsp1_entity, subdev.entity);
+   source = media_entity_to_vsp1_entity(local->entity);
 
if (!source->route)
return 0;
-- 
2.7.3

--
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


[PATCH v2 00/13] R-Car VSP improvements for v4.7 - Round 2

2016-04-25 Thread Laurent Pinchart
Hello,

This patch series is the second version of the second (and most probably last)
round of vsp1 driver improvements for v4.7. In particular, it enables runtime
PM support (03/13 and 04/13), adds support for the FCP (01/13, 02/13 and
05/13), prepare for HGO (histogram) support (06/13 to 09/13) and update the
API towards the DRM driver (10/13 to 13/13).

The FCP is a companion module of video processing modules in the Renesas R-Car
Gen3 SoCs. It provides data compression and decompression, data caching, and
conversion of AXI transaction in order to reduce the memory bandwidth. The FCP
driver is not meant to be used standalone but provides an API to the video
processing modules to control the FCP.

The API towards the DRM driver is updated to store all configuration
parameters in a structure in order to improve readability and make future
updates easier. This series contain two R-Car DU DRM patches that update the
DU DRM driver to the new API. They would normally be merged through Dave
Airlie's tree, but due to dependencies on VSP1 patches queued up for v4.7 Dave
agreed to get them merged through the linux-media tree (hence his Acked-by for
the two patches). They should not conflict with any patch queued up for v4.7
through Dave's tree.

Note that patch 10/13 adds some macro magic to make the API transition easier.
Depending on your taste you will find the implementation beautiful or ugly,
but in any case patch 13/13 removes the macros and inline wrapper.

The code is based on top of the latest linux-media master branch. For
convenience I've pushed the patches to the following git tree branch.
patches on top of the latest Linux media master branch to

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

Changes since v1:

- Fixed typos
- Made rcar_fcp_enable() return a status
- Dropped the unneeded dependency on PM for the VSP driver

Cc: devicet...@vger.kernel.org
Cc: dri-de...@lists.freedesktop.org
Cc: Dave Airlie 

Laurent Pinchart (13):
  dt-bindings: Add Renesas R-Car FCP DT bindings
  v4l: Add Renesas R-Car FCP driver
  v4l: vsp1: Implement runtime PM support
  v4l: vsp1: Don't handle clocks manually
  v4l: vsp1: Add FCP support
  v4l: vsp1: Add output node value to routing table
  v4l: vsp1: Replace container_of() with dedicated macro
  v4l: vsp1: Make vsp1_entity_get_pad_compose() more generic
  v4l: vsp1: Move frame sequence number from video node to pipeline
  v4l: vsp1: Group DRM RPF parameters in a structure
  drm: rcar-du: Add alpha support for VSP planes
  drm: rcar-du: Add Z-order support for VSP planes
  v4l: vsp1: Remove deprecated DRM API

 .../devicetree/bindings/media/renesas,fcp.txt  |  31 
 .../devicetree/bindings/media/renesas,vsp1.txt |   5 +
 MAINTAINERS|  10 ++
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c  |  45 ++---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.h  |   2 +
 drivers/media/platform/Kconfig |  14 ++
 drivers/media/platform/Makefile|   1 +
 drivers/media/platform/rcar-fcp.c  | 181 +
 drivers/media/platform/vsp1/vsp1.h |   6 +-
 drivers/media/platform/vsp1/vsp1_drm.c |  68 
 drivers/media/platform/vsp1/vsp1_drv.c | 120 +++---
 drivers/media/platform/vsp1/vsp1_entity.c  |  86 +++---
 drivers/media/platform/vsp1/vsp1_entity.h  |  12 +-
 drivers/media/platform/vsp1/vsp1_pipe.c|   4 +-
 drivers/media/platform/vsp1/vsp1_pipe.h|   2 +
 drivers/media/platform/vsp1/vsp1_rpf.c |   7 +-
 drivers/media/platform/vsp1/vsp1_video.c   |   4 +-
 drivers/media/platform/vsp1/vsp1_video.h   |   1 -
 include/media/rcar-fcp.h   |  37 +
 include/media/vsp1.h   |  29 ++--
 20 files changed, 494 insertions(+), 171 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/renesas,fcp.txt
 create mode 100644 drivers/media/platform/rcar-fcp.c
 create mode 100644 include/media/rcar-fcp.h

-- 
Regards,

Laurent Pinchart

--
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


[PATCH v2 13/13] v4l: vsp1: Remove deprecated DRM API

2016-04-25 Thread Laurent Pinchart
The DRM driver has switched to the new API, remove the deprecated macros
and inline wrapper.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/vsp1_drm.c |  6 +++---
 include/media/vsp1.h   | 28 ++--
 2 files changed, 5 insertions(+), 29 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_drm.c 
b/drivers/media/platform/vsp1/vsp1_drm.c
index fef53ecefe25..14730119687f 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -255,8 +255,8 @@ EXPORT_SYMBOL_GPL(vsp1_du_atomic_begin);
  *
  * Return 0 on success or a negative error code on failure.
  */
-int __vsp1_du_atomic_update(struct device *dev, unsigned int rpf_index,
-   const struct vsp1_du_atomic_config *cfg)
+int vsp1_du_atomic_update(struct device *dev, unsigned int rpf_index,
+ const struct vsp1_du_atomic_config *cfg)
 {
struct vsp1_device *vsp1 = dev_get_drvdata(dev);
const struct vsp1_format_info *fmtinfo;
@@ -310,7 +310,7 @@ int __vsp1_du_atomic_update(struct device *dev, unsigned 
int rpf_index,
 
return 0;
 }
-EXPORT_SYMBOL_GPL(__vsp1_du_atomic_update);
+EXPORT_SYMBOL_GPL(vsp1_du_atomic_update);
 
 static int vsp1_du_setup_rpf_pipe(struct vsp1_device *vsp1,
  struct vsp1_rwpf *rpf, unsigned int bru_input)
diff --git a/include/media/vsp1.h b/include/media/vsp1.h
index ea8ad7537057..9322d9775fb7 100644
--- a/include/media/vsp1.h
+++ b/include/media/vsp1.h
@@ -34,32 +34,8 @@ struct vsp1_du_atomic_config {
 };
 
 void vsp1_du_atomic_begin(struct device *dev);
-int __vsp1_du_atomic_update(struct device *dev, unsigned int rpf,
-   const struct vsp1_du_atomic_config *cfg);
+int vsp1_du_atomic_update(struct device *dev, unsigned int rpf,
+ const struct vsp1_du_atomic_config *cfg);
 void vsp1_du_atomic_flush(struct device *dev);
 
-static inline int vsp1_du_atomic_update_old(struct device *dev,
-   unsigned int rpf, u32 pixelformat, unsigned int pitch,
-   dma_addr_t mem[2], const struct v4l2_rect *src,
-   const struct v4l2_rect *dst)
-{
-   struct vsp1_du_atomic_config cfg = {
-   .pixelformat = pixelformat,
-   .pitch = pitch,
-   .mem[0] = mem[0],
-   .mem[1] = mem[1],
-   .src = *src,
-   .dst = *dst,
-   .alpha = 255,
-   .zpos = 0,
-   };
-
-   return __vsp1_du_atomic_update(dev, rpf, );
-}
-
-#define _vsp1_du_atomic_update(_1, _2, _3, _4, _5, _6, _7, f, ...) f
-#define vsp1_du_atomic_update(...) \
-   _vsp1_du_atomic_update(__VA_ARGS__, vsp1_du_atomic_update_old, 0, 0, \
-  0, __vsp1_du_atomic_update)(__VA_ARGS__)
-
 #endif /* __MEDIA_VSP1_H__ */
-- 
2.7.3

--
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


[PATCH v2 10/13] v4l: vsp1: Group DRM RPF parameters in a structure

2016-04-25 Thread Laurent Pinchart
The vsp1_du_atomic_update_ext() function takes 7 RPF configuration
parameters, and more will likely be added later. This makes the code
difficult to read and error-prone as multiple parameters have the same
type.

Make the API safer and easier to extend in the future by grouping all
parameters in a structure. Use macro magic to ease the transition to the
new function by allowing the old and new functions to be called using
the same name. The macros and static inline wrapper will be removed as
soon as the caller is updated.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/vsp1_drm.c | 68 +++---
 include/media/vsp1.h   | 47 ---
 2 files changed, 64 insertions(+), 51 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_drm.c 
b/drivers/media/platform/vsp1/vsp1_drm.c
index fc4bbc401e67..fef53ecefe25 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -230,42 +230,33 @@ EXPORT_SYMBOL_GPL(vsp1_du_atomic_begin);
  * vsp1_du_atomic_update - Setup one RPF input of the VSP pipeline
  * @dev: the VSP device
  * @rpf_index: index of the RPF to setup (0-based)
- * @pixelformat: V4L2 pixel format for the RPF memory input
- * @pitch: number of bytes per line in the image stored in memory
- * @mem: DMA addresses of the memory buffers (one per plane)
- * @src: the source crop rectangle for the RPF
- * @dst: the destination compose rectangle for the BRU input
- * @alpha: global alpha value for the input
- * @zpos: the Z-order position of the input
+ * @cfg: the RPF configuration
  *
- * Configure the VSP to perform composition of the image referenced by @mem
- * through RPF @rpf_index, using the @src crop rectangle and the @dst
+ * Configure the VSP to perform image composition through RPF @rpf_index as
+ * described by the @cfg configuration. The image to compose is referenced by
+ * @cfg.mem and composed using the @cfg.src crop rectangle and the @cfg.dst
  * composition rectangle. The Z-order is configurable with higher @zpos values
  * displayed on top.
  *
- * Image format as stored in memory is expressed as a V4L2 @pixelformat value.
- * As a special case, setting the pixel format to 0 will disable the RPF. The
- * @pitch, @mem, @src and @dst parameters are ignored in that case. Calling the
+ * If the @cfg configuration is NULL, the RPF will be disabled. Calling the
  * function on a disabled RPF is allowed.
  *
- * The memory pitch is configurable to allow for padding at end of lines, or
- * simple for images that extend beyond the crop rectangle boundaries. The
- * @pitch value is expressed in bytes and applies to all planes for multiplanar
- * formats.
+ * Image format as stored in memory is expressed as a V4L2 @cfg.pixelformat
+ * value. The memory pitch is configurable to allow for padding at end of 
lines,
+ * or simply for images that extend beyond the crop rectangle boundaries. The
+ * @cfg.pitch value is expressed in bytes and applies to all planes for
+ * multiplanar formats.
  *
  * The source memory buffer is referenced by the DMA address of its planes in
- * the @mem array. Up to two planes are supported. The second plane DMA address
- * is ignored for formats using a single plane.
+ * the @cfg.mem array. Up to two planes are supported. The second plane DMA
+ * address is ignored for formats using a single plane.
  *
  * This function isn't reentrant, the caller needs to serialize calls.
  *
  * Return 0 on success or a negative error code on failure.
  */
-int vsp1_du_atomic_update_ext(struct device *dev, unsigned int rpf_index,
- u32 pixelformat, unsigned int pitch,
- dma_addr_t mem[2], const struct v4l2_rect *src,
- const struct v4l2_rect *dst, unsigned int alpha,
- unsigned int zpos)
+int __vsp1_du_atomic_update(struct device *dev, unsigned int rpf_index,
+   const struct vsp1_du_atomic_config *cfg)
 {
struct vsp1_device *vsp1 = dev_get_drvdata(dev);
const struct vsp1_format_info *fmtinfo;
@@ -276,7 +267,7 @@ int vsp1_du_atomic_update_ext(struct device *dev, unsigned 
int rpf_index,
 
rpf = vsp1->rpf[rpf_index];
 
-   if (pixelformat == 0) {
+   if (!cfg) {
dev_dbg(vsp1->dev, "%s: RPF%u: disable requested\n", __func__,
rpf_index);
 
@@ -287,38 +278,39 @@ int vsp1_du_atomic_update_ext(struct device *dev, 
unsigned int rpf_index,
dev_dbg(vsp1->dev,
"%s: RPF%u: (%u,%u)/%ux%u -> (%u,%u)/%ux%u (%08x), pitch %u dma 
{ %pad, %pad } zpos %u\n",
__func__, rpf_index,
-   src->left, src->top, src->width, src->height,
-   dst->left, dst->top, dst->width, dst->height,
-   pixelformat, pitch, [0], [1], zpos);
+   cfg->src.left, cfg->src.top, 

[PATCH v2 06/13] v4l: vsp1: Add output node value to routing table

2016-04-25 Thread Laurent Pinchart
The output node value indicates the value to be used in a sampling point
register to use the node as the source of histogram data.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/vsp1_entity.c | 52 ---
 drivers/media/platform/vsp1/vsp1_entity.h |  6 +++-
 2 files changed, 39 insertions(+), 19 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_entity.c 
b/drivers/media/platform/vsp1/vsp1_entity.c
index 3d070bcc6053..6a96ea77de69 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.c
+++ b/drivers/media/platform/vsp1/vsp1_entity.c
@@ -274,28 +274,44 @@ int vsp1_entity_link_setup(struct media_entity *entity,
  * Initialization
  */
 
+#define VSP1_ENTITY_ROUTE(ent) \
+   { VSP1_ENTITY_##ent, 0, VI6_DPR_##ent##_ROUTE,  \
+ { VI6_DPR_NODE_##ent }, VI6_DPR_NODE_##ent }
+
+#define VSP1_ENTITY_ROUTE_RPF(idx) \
+   { VSP1_ENTITY_RPF, idx, VI6_DPR_RPF_ROUTE(idx), \
+ { 0, }, VI6_DPR_NODE_RPF(idx) }
+
+#define VSP1_ENTITY_ROUTE_UDS(idx) \
+   { VSP1_ENTITY_UDS, idx, VI6_DPR_UDS_ROUTE(idx), \
+ { VI6_DPR_NODE_UDS(idx) }, VI6_DPR_NODE_UDS(idx) }
+
+#define VSP1_ENTITY_ROUTE_WPF(idx) \
+   { VSP1_ENTITY_WPF, idx, 0,  \
+ { VI6_DPR_NODE_WPF(idx) }, VI6_DPR_NODE_WPF(idx) }
+
 static const struct vsp1_route vsp1_routes[] = {
{ VSP1_ENTITY_BRU, 0, VI6_DPR_BRU_ROUTE,
  { VI6_DPR_NODE_BRU_IN(0), VI6_DPR_NODE_BRU_IN(1),
VI6_DPR_NODE_BRU_IN(2), VI6_DPR_NODE_BRU_IN(3),
-   VI6_DPR_NODE_BRU_IN(4) } },
-   { VSP1_ENTITY_HSI, 0, VI6_DPR_HSI_ROUTE, { VI6_DPR_NODE_HSI, } },
-   { VSP1_ENTITY_HST, 0, VI6_DPR_HST_ROUTE, { VI6_DPR_NODE_HST, } },
-   { VSP1_ENTITY_LIF, 0, 0, { VI6_DPR_NODE_LIF, } },
-   { VSP1_ENTITY_LUT, 0, VI6_DPR_LUT_ROUTE, { VI6_DPR_NODE_LUT, } },
-   { VSP1_ENTITY_RPF, 0, VI6_DPR_RPF_ROUTE(0), { 0, } },
-   { VSP1_ENTITY_RPF, 1, VI6_DPR_RPF_ROUTE(1), { 0, } },
-   { VSP1_ENTITY_RPF, 2, VI6_DPR_RPF_ROUTE(2), { 0, } },
-   { VSP1_ENTITY_RPF, 3, VI6_DPR_RPF_ROUTE(3), { 0, } },
-   { VSP1_ENTITY_RPF, 4, VI6_DPR_RPF_ROUTE(4), { 0, } },
-   { VSP1_ENTITY_SRU, 0, VI6_DPR_SRU_ROUTE, { VI6_DPR_NODE_SRU, } },
-   { VSP1_ENTITY_UDS, 0, VI6_DPR_UDS_ROUTE(0), { VI6_DPR_NODE_UDS(0), } },
-   { VSP1_ENTITY_UDS, 1, VI6_DPR_UDS_ROUTE(1), { VI6_DPR_NODE_UDS(1), } },
-   { VSP1_ENTITY_UDS, 2, VI6_DPR_UDS_ROUTE(2), { VI6_DPR_NODE_UDS(2), } },
-   { VSP1_ENTITY_WPF, 0, 0, { VI6_DPR_NODE_WPF(0), } },
-   { VSP1_ENTITY_WPF, 1, 0, { VI6_DPR_NODE_WPF(1), } },
-   { VSP1_ENTITY_WPF, 2, 0, { VI6_DPR_NODE_WPF(2), } },
-   { VSP1_ENTITY_WPF, 3, 0, { VI6_DPR_NODE_WPF(3), } },
+   VI6_DPR_NODE_BRU_IN(4) }, VI6_DPR_NODE_BRU_OUT },
+   VSP1_ENTITY_ROUTE(HSI),
+   VSP1_ENTITY_ROUTE(HST),
+   { VSP1_ENTITY_LIF, 0, 0, { VI6_DPR_NODE_LIF, }, VI6_DPR_NODE_LIF },
+   VSP1_ENTITY_ROUTE(LUT),
+   VSP1_ENTITY_ROUTE_RPF(0),
+   VSP1_ENTITY_ROUTE_RPF(1),
+   VSP1_ENTITY_ROUTE_RPF(2),
+   VSP1_ENTITY_ROUTE_RPF(3),
+   VSP1_ENTITY_ROUTE_RPF(4),
+   VSP1_ENTITY_ROUTE(SRU),
+   VSP1_ENTITY_ROUTE_UDS(0),
+   VSP1_ENTITY_ROUTE_UDS(1),
+   VSP1_ENTITY_ROUTE_UDS(2),
+   VSP1_ENTITY_ROUTE_WPF(0),
+   VSP1_ENTITY_ROUTE_WPF(1),
+   VSP1_ENTITY_ROUTE_WPF(2),
+   VSP1_ENTITY_ROUTE_WPF(3),
 };
 
 int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
diff --git a/drivers/media/platform/vsp1/vsp1_entity.h 
b/drivers/media/platform/vsp1/vsp1_entity.h
index 69eff4e17350..aaab05f4952c 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.h
+++ b/drivers/media/platform/vsp1/vsp1_entity.h
@@ -42,17 +42,21 @@ enum vsp1_entity_type {
  * @index: Entity index this routing entry is associated with
  * @reg: Output routing configuration register
  * @inputs: Target node value for each input
+ * @output: Target node value for entity output
  *
  * Each $vsp1_route entry describes routing configuration for the entity
  * specified by the entry's @type and @index. @reg indicates the register that
  * holds output routing configuration for the entity, and the @inputs array
- * store the target node value for each input of the entity.
+ * store the target node value for each input of the entity. The @output field
+ * stores the target node value of the entity output when used as a source for
+ * histogram generation.
  */
 struct vsp1_route {
enum vsp1_entity_type type;
unsigned int index;
unsigned int reg;
unsigned int inputs[VSP1_ENTITY_MAX_INPUTS];
+   unsigned int output;
 };
 
 /**
-- 
2.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of 

[PATCH v2 03/13] v4l: vsp1: Implement runtime PM support

2016-04-25 Thread Laurent Pinchart
Replace the manual refcount and clock management code by runtime PM.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/vsp1.h  |   3 -
 drivers/media/platform/vsp1/vsp1_drv.c  | 101 
 drivers/media/platform/vsp1/vsp1_pipe.c |   2 +-
 3 files changed, 53 insertions(+), 53 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1.h 
b/drivers/media/platform/vsp1/vsp1.h
index 46738b6c5f72..9e09bce43cf3 100644
--- a/drivers/media/platform/vsp1/vsp1.h
+++ b/drivers/media/platform/vsp1/vsp1.h
@@ -64,9 +64,6 @@ struct vsp1_device {
void __iomem *mmio;
struct clk *clock;
 
-   struct mutex lock;
-   int ref_count;
-
struct vsp1_bru *bru;
struct vsp1_hsit *hsi;
struct vsp1_hsit *hst;
diff --git a/drivers/media/platform/vsp1/vsp1_drv.c 
b/drivers/media/platform/vsp1/vsp1_drv.c
index e2d779fac0eb..d6abc7f1216a 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -462,35 +463,16 @@ static int vsp1_device_init(struct vsp1_device *vsp1)
 /*
  * vsp1_device_get - Acquire the VSP1 device
  *
- * Increment the VSP1 reference count and initialize the device if the first
- * reference is taken.
+ * Make sure the device is not suspended and initialize it if needed.
  *
  * Return 0 on success or a negative error code otherwise.
  */
 int vsp1_device_get(struct vsp1_device *vsp1)
 {
-   int ret = 0;
-
-   mutex_lock(>lock);
-   if (vsp1->ref_count > 0)
-   goto done;
-
-   ret = clk_prepare_enable(vsp1->clock);
-   if (ret < 0)
-   goto done;
-
-   ret = vsp1_device_init(vsp1);
-   if (ret < 0) {
-   clk_disable_unprepare(vsp1->clock);
-   goto done;
-   }
-
-done:
-   if (!ret)
-   vsp1->ref_count++;
+   int ret;
 
-   mutex_unlock(>lock);
-   return ret;
+   ret = pm_runtime_get_sync(vsp1->dev);
+   return ret < 0 ? ret : 0;
 }
 
 /*
@@ -501,12 +483,7 @@ done:
  */
 void vsp1_device_put(struct vsp1_device *vsp1)
 {
-   mutex_lock(>lock);
-
-   if (--vsp1->ref_count == 0)
-   clk_disable_unprepare(vsp1->clock);
-
-   mutex_unlock(>lock);
+   pm_runtime_put_sync(vsp1->dev);
 }
 
 /* 
-
@@ -518,37 +495,55 @@ static int vsp1_pm_suspend(struct device *dev)
 {
struct vsp1_device *vsp1 = dev_get_drvdata(dev);
 
-   WARN_ON(mutex_is_locked(>lock));
+   vsp1_pipelines_suspend(vsp1);
+   pm_runtime_force_suspend(vsp1->dev);
 
-   if (vsp1->ref_count == 0)
-   return 0;
+   return 0;
+}
 
-   vsp1_pipelines_suspend(vsp1);
+static int vsp1_pm_resume(struct device *dev)
+{
+   struct vsp1_device *vsp1 = dev_get_drvdata(dev);
 
-   clk_disable_unprepare(vsp1->clock);
+   pm_runtime_force_resume(vsp1->dev);
+   vsp1_pipelines_resume(vsp1);
 
return 0;
 }
+#endif
 
-static int vsp1_pm_resume(struct device *dev)
+static int vsp1_pm_runtime_suspend(struct device *dev)
 {
struct vsp1_device *vsp1 = dev_get_drvdata(dev);
 
-   WARN_ON(mutex_is_locked(>lock));
+   clk_disable_unprepare(vsp1->clock);
 
-   if (vsp1->ref_count == 0)
-   return 0;
+   return 0;
+}
 
-   clk_prepare_enable(vsp1->clock);
+static int vsp1_pm_runtime_resume(struct device *dev)
+{
+   struct vsp1_device *vsp1 = dev_get_drvdata(dev);
+   int ret;
 
-   vsp1_pipelines_resume(vsp1);
+   ret = clk_prepare_enable(vsp1->clock);
+   if (ret < 0)
+   return ret;
+
+   if (vsp1->info) {
+   ret = vsp1_device_init(vsp1);
+   if (ret < 0) {
+   clk_disable_unprepare(vsp1->clock);
+   return ret;
+   }
+   }
 
return 0;
 }
-#endif
 
 static const struct dev_pm_ops vsp1_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(vsp1_pm_suspend, vsp1_pm_resume)
+   SET_RUNTIME_PM_OPS(vsp1_pm_runtime_suspend, vsp1_pm_runtime_resume, 
NULL)
 };
 
 /* 
-
@@ -640,10 +635,11 @@ static int vsp1_probe(struct platform_device *pdev)
return -ENOMEM;
 
vsp1->dev = >dev;
-   mutex_init(>lock);
INIT_LIST_HEAD(>entities);
INIT_LIST_HEAD(>videos);
 
+   platform_set_drvdata(pdev, vsp1);
+
/* I/O, IRQ and clock resources */
io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
vsp1->mmio = devm_ioremap_resource(>dev, io);
@@ -670,12 +666,14 @@ static int vsp1_probe(struct platform_device *pdev)
}
 
/* Configure device parameters based on the version register. */
-   ret = clk_prepare_enable(vsp1->clock);
+   

[PATCH v2 02/13] v4l: Add Renesas R-Car FCP driver

2016-04-25 Thread Laurent Pinchart
The FCP is a companion module of video processing modules in the
Renesas R-Car Gen3 SoCs. It provides data compression and decompression,
data caching, and conversion of AXI transactions in order to reduce the
memory bandwidth.

The driver is not meant to be used standalone but provides an API to the
video processing modules to control the FCP.

Signed-off-by: Laurent Pinchart 
---
 MAINTAINERS   |  10 +++
 drivers/media/platform/Kconfig|  13 +++
 drivers/media/platform/Makefile   |   1 +
 drivers/media/platform/rcar-fcp.c | 181 ++
 include/media/rcar-fcp.h  |  37 
 5 files changed, 242 insertions(+)
 create mode 100644 drivers/media/platform/rcar-fcp.c
 create mode 100644 include/media/rcar-fcp.h

diff --git a/MAINTAINERS b/MAINTAINERS
index bfcb7ea42e20..88513e3eb35b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7049,6 +7049,16 @@ L:   linux-...@vger.kernel.org
 S: Maintained
 F: drivers/iio/potentiometer/mcp4531.c
 
+MEDIA DRIVERS FOR RENESAS - FCP
+M: Laurent Pinchart 
+L: linux-media@vger.kernel.org
+L: linux-renesas-...@vger.kernel.org
+T: git git://linuxtv.org/media_tree.git
+S: Supported
+F: Documentation/devicetree/bindings/media/renesas,fcp.txt
+F: drivers/media/platform/rcar-fcp.c
+F: include/media/rcar-fcp.h
+
 MEDIA DRIVERS FOR RENESAS - VSP1
 M: Laurent Pinchart 
 L: linux-media@vger.kernel.org
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 84e041c0a70e..f453910050be 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -247,6 +247,19 @@ config VIDEO_RENESAS_JPU
  To compile this driver as a module, choose M here: the module
  will be called rcar_jpu.
 
+config VIDEO_RENESAS_FCP
+   tristate "Renesas Frame Compression Processor"
+   depends on ARCH_RENESAS || COMPILE_TEST
+   depends on OF
+   ---help---
+ This is a driver for the Renesas Frame Compression Processor (FCP).
+ The FCP is a companion module of video processing modules in the
+ Renesas R-Car Gen3 SoCs. It handles memory access for the codec,
+ VSP and FDP modules.
+
+ To compile this driver as a module, choose M here: the module
+ will be called rcar-fcp.
+
 config VIDEO_RENESAS_VSP1
tristate "Renesas VSP1 Video Processing Engine"
depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && HAS_DMA
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index bbb7bd1eb268..befc4f97057c 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -46,6 +46,7 @@ obj-$(CONFIG_VIDEO_SH_VOU)+= sh_vou.o
 
 obj-$(CONFIG_SOC_CAMERA)   += soc_camera/
 
+obj-$(CONFIG_VIDEO_RENESAS_FCP)+= rcar-fcp.o
 obj-$(CONFIG_VIDEO_RENESAS_JPU)+= rcar_jpu.o
 obj-$(CONFIG_VIDEO_RENESAS_VSP1)   += vsp1/
 
diff --git a/drivers/media/platform/rcar-fcp.c 
b/drivers/media/platform/rcar-fcp.c
new file mode 100644
index ..6a7bcc3028b1
--- /dev/null
+++ b/drivers/media/platform/rcar-fcp.c
@@ -0,0 +1,181 @@
+/*
+ * rcar-fcp.c  --  R-Car Frame Compression Processor Driver
+ *
+ * Copyright (C) 2016 Renesas Electronics Corporation
+ *
+ * Contact: Laurent Pinchart (laurent.pinch...@ideasonboard.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+struct rcar_fcp_device {
+   struct list_head list;
+   struct device *dev;
+};
+
+static LIST_HEAD(fcp_devices);
+static DEFINE_MUTEX(fcp_lock);
+
+/* 
-
+ * Public API
+ */
+
+/**
+ * rcar_fcp_get - Find and acquire a reference to an FCP instance
+ * @np: Device node of the FCP instance
+ *
+ * Search the list of registered FCP instances for the instance corresponding 
to
+ * the given device node.
+ *
+ * Return a pointer to the FCP instance, or an ERR_PTR if the instance can't be
+ * found.
+ */
+struct rcar_fcp_device *rcar_fcp_get(const struct device_node *np)
+{
+   struct rcar_fcp_device *fcp;
+
+   mutex_lock(_lock);
+
+   list_for_each_entry(fcp, _devices, list) {
+   if (fcp->dev->of_node != np)
+   continue;
+
+   /*
+* Make sure the module won't be unloaded behind our back. This
+* is a poor man's safety net, the module should really not be
+* unloaded while FCP users can be active.
+*/
+   if 

[PATCH v2 05/13] v4l: vsp1: Add FCP support

2016-04-25 Thread Laurent Pinchart
On some platforms the VSP performs memory accesses through an FCP. When
that's the case get a reference to the FCP from the VSP DT node and
enable/disable it at runtime as needed.

Signed-off-by: Laurent Pinchart 
---
 .../devicetree/bindings/media/renesas,vsp1.txt  |  5 +
 drivers/media/platform/Kconfig  |  1 +
 drivers/media/platform/vsp1/vsp1.h  |  2 ++
 drivers/media/platform/vsp1/vsp1_drv.c  | 21 -
 4 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/media/renesas,vsp1.txt 
b/Documentation/devicetree/bindings/media/renesas,vsp1.txt
index 627405abd144..9b695bcbf219 100644
--- a/Documentation/devicetree/bindings/media/renesas,vsp1.txt
+++ b/Documentation/devicetree/bindings/media/renesas,vsp1.txt
@@ -14,6 +14,11 @@ Required properties:
   - interrupts: VSP interrupt specifier.
   - clocks: A phandle + clock-specifier pair for the VSP functional clock.
 
+Optional properties:
+
+  - renesas,fcp: A phandle referencing the FCP that handles memory accesses
+ for the VSP. Not needed on Gen2, mandatory on Gen3.
+
 
 Example: R8A7790 (R-Car H2) VSP1-S node
 
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index f453910050be..a3304466e628 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -264,6 +264,7 @@ config VIDEO_RENESAS_VSP1
tristate "Renesas VSP1 Video Processing Engine"
depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && HAS_DMA
depends on (ARCH_RENESAS && OF) || COMPILE_TEST
+   depends on !ARM64 || VIDEO_RENESAS_FCP
select VIDEOBUF2_DMA_CONTIG
---help---
  This is a V4L2 driver for the Renesas VSP1 video processing engine.
diff --git a/drivers/media/platform/vsp1/vsp1.h 
b/drivers/media/platform/vsp1/vsp1.h
index 37cc05e34de0..7cb0f5e428df 100644
--- a/drivers/media/platform/vsp1/vsp1.h
+++ b/drivers/media/platform/vsp1/vsp1.h
@@ -25,6 +25,7 @@
 
 struct clk;
 struct device;
+struct rcar_fcp_device;
 
 struct vsp1_drm;
 struct vsp1_entity;
@@ -62,6 +63,7 @@ struct vsp1_device {
const struct vsp1_device_info *info;
 
void __iomem *mmio;
+   struct rcar_fcp_device *fcp;
 
struct vsp1_bru *bru;
struct vsp1_hsit *hsi;
diff --git a/drivers/media/platform/vsp1/vsp1_drv.c 
b/drivers/media/platform/vsp1/vsp1_drv.c
index 13907d4f08af..e655639af7e2 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include 
 #include 
 
 #include "vsp1.h"
@@ -514,6 +515,10 @@ static int vsp1_pm_resume(struct device *dev)
 
 static int vsp1_pm_runtime_suspend(struct device *dev)
 {
+   struct vsp1_device *vsp1 = dev_get_drvdata(dev);
+
+   rcar_fcp_disable(vsp1->fcp);
+
return 0;
 }
 
@@ -528,7 +533,7 @@ static int vsp1_pm_runtime_resume(struct device *dev)
return ret;
}
 
-   return 0;
+   return rcar_fcp_enable(vsp1->fcp);
 }
 
 static const struct dev_pm_ops vsp1_pm_ops = {
@@ -614,6 +619,7 @@ static const struct vsp1_device_info vsp1_device_infos[] = {
 static int vsp1_probe(struct platform_device *pdev)
 {
struct vsp1_device *vsp1;
+   struct device_node *fcp_node;
struct resource *irq;
struct resource *io;
unsigned int i;
@@ -649,6 +655,18 @@ static int vsp1_probe(struct platform_device *pdev)
return ret;
}
 
+   /* FCP (optional) */
+   fcp_node = of_parse_phandle(pdev->dev.of_node, "renesas,fcp", 0);
+   if (fcp_node) {
+   vsp1->fcp = rcar_fcp_get(fcp_node);
+   of_node_put(fcp_node);
+   if (IS_ERR(vsp1->fcp)) {
+   dev_dbg(>dev, "FCP not found (%ld)\n",
+   PTR_ERR(vsp1->fcp));
+   return PTR_ERR(vsp1->fcp);
+   }
+   }
+
/* Configure device parameters based on the version register. */
pm_runtime_enable(>dev);
 
@@ -694,6 +712,7 @@ static int vsp1_remove(struct platform_device *pdev)
struct vsp1_device *vsp1 = platform_get_drvdata(pdev);
 
vsp1_destroy_entities(vsp1);
+   rcar_fcp_put(vsp1->fcp);
 
pm_runtime_disable(>dev);
 
-- 
2.7.3

--
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


[PATCH v2 01/13] dt-bindings: Add Renesas R-Car FCP DT bindings

2016-04-25 Thread Laurent Pinchart
The FCP is a companion module of video processing modules in the Renesas
R-Car Gen3 SoCs. It provides data compression and decompression, data
caching, and conversion of AXI transactions in order to reduce the
memory bandwidth.

Signed-off-by: Laurent Pinchart 
---
 .../devicetree/bindings/media/renesas,fcp.txt  | 31 ++
 1 file changed, 31 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/renesas,fcp.txt

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

diff --git a/Documentation/devicetree/bindings/media/renesas,fcp.txt 
b/Documentation/devicetree/bindings/media/renesas,fcp.txt
new file mode 100644
index ..0c72ca24379f
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/renesas,fcp.txt
@@ -0,0 +1,31 @@
+Renesas R-Car Frame Compression Processor (FCP)
+---
+
+The FCP is a companion module of video processing modules in the Renesas R-Car
+Gen3 SoCs. It provides data compression and decompression, data caching, and
+conversion of AXI transactions in order to reduce the memory bandwidth.
+
+There are three types of FCP whose configuration and behaviour highly depend
+on the module they are paired with.
+
+ - compatible: Must be one or more of the following
+
+   - "renesas,r8a7795-fcpv" for R8A7795 (R-Car H3) compatible 'FCP for VSP'
+   - "renesas,fcpv" for generic compatible 'FCP for VSP'
+
+   When compatible with the generic version, nodes must list the
+   SoC-specific version corresponding to the platform first, followed by the
+   family-specific and/or generic versions.
+
+ - reg: the register base and size for the device registers
+ - clocks: Reference to the functional clock
+
+
+Device node example
+---
+
+   fcpvd1: fcp@fea2f000 {
+   compatible = "renesas,r8a7795-fcpv", "renesas,fcpv";
+   reg = <0 0xfea2f000 0 0x200>;
+   clocks = < CPG_MOD 602>;
+   };
-- 
2.7.3

--
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: [RFC PATCH 00/24] Make Nokia N900 cameras working

2016-04-25 Thread Ivaylo Dimitrov

Hi,

On 25.04.2016 23:41, Pavel Machek wrote:

Hi!


All my testing so far was performed using modules, though it shouldn't make
difference.


https://lkml.org/lkml/2016/4/16/14
https://lkml.org/lkml/2016/4/16/33



More stuff is needed, all those twl4030 regulator patches (already in
linux-next) + DTS initial-mode patch
(https://lkml.org/lkml/2016/4/17/78).


Aha, that explains a lot. Dealing with -next would be tricky, I guess;
can I just pull from your camera branch?

https://github.com/freemangordon/linux-n900/tree/camera


I guess yes, though I am not sure all the patches there are compatible 
with userland different from maemo, so be careful. Also, the correct 
branch is v4.6-rc4-n900-camera.


Ivo
--
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: [RFC PATCH 00/24] Make Nokia N900 cameras working

2016-04-25 Thread Pavel Machek
Hi!

> All my testing so far was performed using modules, though it shouldn't make
> difference.
> 
> >https://lkml.org/lkml/2016/4/16/14
> >https://lkml.org/lkml/2016/4/16/33
> >
> 
> More stuff is needed, all those twl4030 regulator patches (already in
> linux-next) + DTS initial-mode patch
> (https://lkml.org/lkml/2016/4/17/78).

Aha, that explains a lot. Dealing with -next would be tricky, I guess;
can I just pull from your camera branch?

https://github.com/freemangordon/linux-n900/tree/camera

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.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


Re: [RFC PATCH 00/24] Make Nokia N900 cameras working

2016-04-25 Thread Ivaylo Dimitrov

Hi,

On 25.04.2016 21:40, Pavel Machek wrote:

Hi!


I can't do -vo xv ... fails for me, probably due to X
configuration. Does it work with -vo x11 for you?


yes, -vo x11 works under maemo.


Ok, good.


In linux-n900 branch we have a patch that reserves memory for omapfb - see 
https://github.com/freemangordon/linux-n900/commit/60f85dcb6a663efe687f58208861545d65210b55

also, because of a change in 4.6, 
https://github.com/freemangordon/linux-n900/commit/60f85dcb6a663efe687f58208861545d65210b55#diff-072444ea67d2aca6b402458f50d20edeR125
needs a change to DMA_MEMORY_IO and the if bellow needs the relevant change
as well.



This is needed for -vo xv (and any omapfb video playback) to reliably work
under maemo.


I don't have that kind of acceleration working.


For me it shows window with green interior. And complains about v4l2:
select timeouts. (I enabled these in .config):

+CONFIG_VIDEO_BUS_SWITCH=y
+CONFIG_VIDEO_SMIAREGS=y
+CONFIG_VIDEO_ET8EK8=y
+CONFIG_VIDEOBUF2_CORE=y
+CONFIG_VIDEOBUF2_MEMOPS=y
+CONFIG_VIDEOBUF2_DMA_CONTIG=y
+CONFIG_VIDEO_OMAP3=y
+CONFIG_VIDEO_SMIAPP_PLL=y
+CONFIG_VIDEO_SMIAPP=y

Any ideas?
Pavel



Try to build those as modules. Also, do you have all the needed patches
besides those in the patchset?

See https://github.com/freemangordon/linux-n900/commits/v4.6-rc4-n900-camera

Also, is there anything related in dmesg log?


Modules are tricky. I hate modules. I did patch with



All my testing so far was performed using modules, though it shouldn't 
make difference.



https://lkml.org/lkml/2016/4/16/14
https://lkml.org/lkml/2016/4/16/33



More stuff is needed, all those twl4030 regulator patches (already in 
linux-next) + DTS initial-mode patch (https://lkml.org/lkml/2016/4/17/78).



+ the series. And yes, there seems to be explanation in the dmesg:

[ 6134.261993] DISPC: channel 0 xres 800 yres 480
[ 6134.262023] DISPC: pck 2400
[ 6134.262023] DISPC: hsw 4 hfp 28 hbp 24 vsw 3 vfp 3 vbp 4
[ 6134.262023] DISPC: vsync_level 0 hsync_level 0 data_pclk_edge 1
de_level 1 sync_pclk_edge 1
[ 6134.262023] DISPC: hsync 28037Hz, vsync 57Hz
[ 6134.262054] DISPC: lck = 7200 (1)
[ 6134.262054] DISPC: pck = 2400 (3)
[ 6190.075103] omap3isp 480bc000.isp: Unable to stop OMAP3 ISP resizer
[ 6192.075347] omap3isp 480bc000.isp: CCDC stop timeout!
[ 6192.075408] omap3isp 480bc000.isp: Unable to stop OMAP3 ISP CCDC
[ 6292.293670] DISPC: dispc_runtime_put
[ 6292.293701] DISPC: dispc_save_context
[ 6292.293762] DISPC: context saved
[ 6292.294342] DSS: dss_save_context
[ 6292.294372] DSS: context saved
[ 6297.056976] DISPC: dispc_runtime_get
[ 6297.057067] DSS: dss_restore_context
[ 6297.057067] DSS: context restored
[ 6297.057159] DSS: set fck to 7200
[ 6297.057159] DISPC: lck = 7200 (1)
[ 6297.057159] DISPC: pck = 2400 (3)



That usually happens when strobe is incorrect or there is no signal from 
the camera.



Let me check the github...


I really hope I didn't miss something when I sent the series. May I have 
your boot log?


Ivo
--
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: [RFC PATCH 00/24] Make Nokia N900 cameras working

2016-04-25 Thread Pavel Machek
Hi!

> >I can't do -vo xv ... fails for me, probably due to X
> >configuration. Does it work with -vo x11 for you?
> >
> yes, -vo x11 works under maemo.

Ok, good.

> In linux-n900 branch we have a patch that reserves memory for omapfb - see 
> https://github.com/freemangordon/linux-n900/commit/60f85dcb6a663efe687f58208861545d65210b55
> 
> also, because of a change in 4.6, 
> https://github.com/freemangordon/linux-n900/commit/60f85dcb6a663efe687f58208861545d65210b55#diff-072444ea67d2aca6b402458f50d20edeR125
> needs a change to DMA_MEMORY_IO and the if bellow needs the relevant change
> as well.

> This is needed for -vo xv (and any omapfb video playback) to reliably work
> under maemo.

I don't have that kind of acceleration working.

> >For me it shows window with green interior. And complains about v4l2:
> >select timeouts. (I enabled these in .config):
> >
> >+CONFIG_VIDEO_BUS_SWITCH=y
> >+CONFIG_VIDEO_SMIAREGS=y
> >+CONFIG_VIDEO_ET8EK8=y
> >+CONFIG_VIDEOBUF2_CORE=y
> >+CONFIG_VIDEOBUF2_MEMOPS=y
> >+CONFIG_VIDEOBUF2_DMA_CONTIG=y
> >+CONFIG_VIDEO_OMAP3=y
> >+CONFIG_VIDEO_SMIAPP_PLL=y
> >+CONFIG_VIDEO_SMIAPP=y
> >
> >Any ideas?
> > Pavel
> >
> 
> Try to build those as modules. Also, do you have all the needed patches
> besides those in the patchset?
> 
> See https://github.com/freemangordon/linux-n900/commits/v4.6-rc4-n900-camera
> 
> Also, is there anything related in dmesg log?

Modules are tricky. I hate modules. I did patch with

https://lkml.org/lkml/2016/4/16/14
https://lkml.org/lkml/2016/4/16/33

+ the series. And yes, there seems to be explanation in the dmesg:

[ 6134.261993] DISPC: channel 0 xres 800 yres 480
[ 6134.262023] DISPC: pck 2400
[ 6134.262023] DISPC: hsw 4 hfp 28 hbp 24 vsw 3 vfp 3 vbp 4
[ 6134.262023] DISPC: vsync_level 0 hsync_level 0 data_pclk_edge 1
de_level 1 sync_pclk_edge 1
[ 6134.262023] DISPC: hsync 28037Hz, vsync 57Hz
[ 6134.262054] DISPC: lck = 7200 (1)
[ 6134.262054] DISPC: pck = 2400 (3)
[ 6190.075103] omap3isp 480bc000.isp: Unable to stop OMAP3 ISP resizer
[ 6192.075347] omap3isp 480bc000.isp: CCDC stop timeout!
[ 6192.075408] omap3isp 480bc000.isp: Unable to stop OMAP3 ISP CCDC
[ 6292.293670] DISPC: dispc_runtime_put
[ 6292.293701] DISPC: dispc_save_context
[ 6292.293762] DISPC: context saved
[ 6292.294342] DSS: dss_save_context
[ 6292.294372] DSS: context saved
[ 6297.056976] DISPC: dispc_runtime_get
[ 6297.057067] DSS: dss_restore_context
[ 6297.057067] DSS: context restored
[ 6297.057159] DSS: set fck to 7200
[ 6297.057159] DISPC: lck = 7200 (1)
[ 6297.057159] DISPC: pck = 2400 (3)

Let me check the github...
Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.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


Re: [PATCHv4 13/13] vb2: replace void *alloc_ctxs by struct device *alloc_devs

2016-04-25 Thread Laurent Pinchart
Hi Hans,

Thank you for the patch.

On Saturday 23 Apr 2016 13:03:49 Hans Verkuil wrote:
> From: Hans Verkuil 
> 
> Make this a proper typed array. Drop the old allocate context code since
> that is no longer used.
> 
> Note that the memops functions now get a struct device pointer instead of
> the struct device ** that was there initially (actually a void pointer to
> a struct containing only a struct device pointer).
> 
> This code is now a lot cleaner.
> 
> Signed-off-by: Hans Verkuil 
> Cc: Laurent Pinchart 
> Cc: Sakari Ailus 
> Cc: Mauro Carvalho Chehab 

For OMAP3 ISP, R-Car JPU, R-Car VSP1, Xilinx, UVC, OMAP4 ISS and videobuf2,

Reviewed-by: Laurent Pinchart 

> ---
>  Documentation/video4linux/v4l2-pci-skeleton.c  |  2 +-
>  drivers/input/touchscreen/sur40.c  |  2 +-
>  drivers/media/dvb-frontends/rtl2832_sdr.c  |  2 +-
>  drivers/media/pci/cobalt/cobalt-v4l2.c |  2 +-
>  drivers/media/pci/cx23885/cx23885-417.c|  2 +-
>  drivers/media/pci/cx23885/cx23885-dvb.c|  2 +-
>  drivers/media/pci/cx23885/cx23885-vbi.c|  2 +-
>  drivers/media/pci/cx23885/cx23885-video.c  |  2 +-
>  drivers/media/pci/cx25821/cx25821-video.c  |  2 +-
>  drivers/media/pci/cx88/cx88-blackbird.c|  2 +-
>  drivers/media/pci/cx88/cx88-dvb.c  |  2 +-
>  drivers/media/pci/cx88/cx88-vbi.c  |  2 +-
>  drivers/media/pci/cx88/cx88-video.c|  2 +-
>  drivers/media/pci/dt3155/dt3155.c  |  2 +-
>  drivers/media/pci/netup_unidvb/netup_unidvb_core.c |  2 +-
>  drivers/media/pci/saa7134/saa7134-ts.c |  2 +-
>  drivers/media/pci/saa7134/saa7134-vbi.c|  2 +-
>  drivers/media/pci/saa7134/saa7134-video.c  |  2 +-
>  drivers/media/pci/saa7134/saa7134.h|  2 +-
>  drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c |  2 +-
>  drivers/media/pci/solo6x10/solo6x10-v4l2.c |  2 +-
>  drivers/media/pci/sta2x11/sta2x11_vip.c|  2 +-
>  drivers/media/pci/tw68/tw68-video.c|  2 +-
>  drivers/media/pci/tw686x/tw686x-video.c|  2 +-
>  drivers/media/platform/am437x/am437x-vpfe.c|  4 +--
>  drivers/media/platform/blackfin/bfin_capture.c |  2 +-
>  drivers/media/platform/coda/coda-common.c  |  2 +-
>  drivers/media/platform/davinci/vpbe_display.c  |  2 +-
>  drivers/media/platform/davinci/vpif_capture.c  |  4 +--
>  drivers/media/platform/davinci/vpif_display.c  |  4 +--
>  drivers/media/platform/exynos-gsc/gsc-core.h   |  1 -
>  drivers/media/platform/exynos-gsc/gsc-m2m.c|  2 +-
>  drivers/media/platform/exynos4-is/fimc-capture.c   |  2 +-
>  drivers/media/platform/exynos4-is/fimc-isp-video.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/marvell-ccic/mcam-core.c|  2 +-
>  drivers/media/platform/mx2_emmaprp.c   |  2 +-
>  drivers/media/platform/omap3isp/ispvideo.c |  2 +-
>  drivers/media/platform/rcar_jpu.c  |  2 +-
>  drivers/media/platform/s3c-camif/camif-capture.c   |  2 +-
>  drivers/media/platform/s5p-g2d/g2d.c   |  2 +-
>  drivers/media/platform/s5p-jpeg/jpeg-core.c|  2 +-
>  drivers/media/platform/s5p-mfc/s5p_mfc_dec.c   | 10 +++---
>  drivers/media/platform/s5p-mfc/s5p_mfc_enc.c   | 12 +++
>  drivers/media/platform/s5p-tv/mixer_video.c|  2 +-
>  drivers/media/platform/sh_veu.c|  2 +-
>  drivers/media/platform/sh_vou.c|  2 +-
>  drivers/media/platform/soc_camera/atmel-isi.c  |  2 +-
>  drivers/media/platform/soc_camera/rcar_vin.c   |  2 +-
>  .../platform/soc_camera/sh_mobile_ceu_camera.c |  2 +-
>  drivers/media/platform/sti/bdisp/bdisp-v4l2.c  |  2 +-
>  drivers/media/platform/ti-vpe/cal.c|  2 +-
>  drivers/media/platform/ti-vpe/vpe.c|  2 +-
>  drivers/media/platform/vim2m.c |  7 +---
>  drivers/media/platform/vivid/vivid-sdr-cap.c   |  2 +-
>  drivers/media/platform/vivid/vivid-vbi-cap.c   |  2 +-
>  drivers/media/platform/vivid/vivid-vbi-out.c   |  2 +-
>  drivers/media/platform/vivid/vivid-vid-cap.c   |  7 +---
>  drivers/media/platform/vivid/vivid-vid-out.c   |  7 +---
>  drivers/media/platform/vsp1/vsp1_video.c   |  8 ++---
>  drivers/media/platform/xilinx/xilinx-dma.c |  2 +-
>  drivers/media/usb/airspy/airspy.c  |  2 +-
>  drivers/media/usb/au0828/au0828-vbi.c  |  2 +-
>  drivers/media/usb/au0828/au0828-video.c|  2 +-
>  

Re: [PATCHv4 02/13] vb2: add a dev field to use for the default allocation context

2016-04-25 Thread Laurent Pinchart
Hi Hans,

Thank you for the patch.

On Saturday 23 Apr 2016 13:03:38 Hans Verkuil wrote:
> From: Hans Verkuil 
> 
> The allocation context is nothing more than a per-plane device pointer
> to use when allocating buffers. So just provide a dev pointer in vb2_queue
> for that purpose and drivers can skip allocating/releasing/filling in
> the allocation context unless they require different per-plane device
> pointers as used by some Samsung SoCs.
> 
> Signed-off-by: Hans Verkuil 
> Cc: Laurent Pinchart 
> Cc: Sakari Ailus 
> Cc: Mauro Carvalho Chehab 
> Cc: Florian Echtler 
> Cc: Federico Vaga 
> Cc: "Lad, Prabhakar" 
> Cc: Scott Jiang 
> Acked-by: Philipp Zabel 
> Cc: Fabien Dessenne 
> Cc: Benoit Parrot 
> Cc: Mikhail Ulyanov 
> Cc: Guennadi Liakhovetski 
> Cc: Jonathan Corbet 
> Cc: Ludovic Desroches 
> Cc: Sergei Shtylyov 
> Cc: Kyungmin Park 
> Cc: Sylwester Nawrocki 

Reviewed-by: Laurent Pinchart 

> ---
>  drivers/media/v4l2-core/videobuf2-core.c | 14 --
>  include/media/videobuf2-core.h   |  3 +++
>  2 files changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c
> b/drivers/media/v4l2-core/videobuf2-core.c index 234e71b..2f50a91 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -206,7 +206,8 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
>   for (plane = 0; plane < vb->num_planes; ++plane) {
>   unsigned long size = PAGE_ALIGN(vb->planes[plane].length);
> 
> - mem_priv = call_ptr_memop(vb, alloc, q->alloc_ctx[plane],
> + mem_priv = call_ptr_memop(vb, alloc,
> + q->alloc_ctx[plane] ? : >dev,
>   q->dma_attrs, size, dma_dir, q->gfp_flags);
>   if (IS_ERR_OR_NULL(mem_priv))
>   goto free;
> @@ -1131,9 +1132,10 @@ static int __qbuf_userptr(struct vb2_buffer *vb,
> const void *pb) vb->planes[plane].data_offset = 0;
> 
>   /* Acquire each plane's memory */
> - mem_priv = call_ptr_memop(vb, get_userptr, q->alloc_ctx[plane],
> -   planes[plane].m.userptr,
> -   planes[plane].length, dma_dir);
> + mem_priv = call_ptr_memop(vb, get_userptr,
> + q->alloc_ctx[plane] ? : >dev,
> + planes[plane].m.userptr,
> + planes[plane].length, dma_dir);
>   if (IS_ERR_OR_NULL(mem_priv)) {
>   dprintk(1, "failed acquiring userspace "
>   "memory for plane %d\n", plane);
> @@ -1256,8 +1258,8 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const
> void *pb)
> 
>   /* Acquire each plane's memory */
>   mem_priv = call_ptr_memop(vb, attach_dmabuf,
> - q->alloc_ctx[plane], dbuf, planes[plane].length,
> - dma_dir);
> + q->alloc_ctx[plane] ? : >dev,
> + dbuf, planes[plane].length, dma_dir);
>   if (IS_ERR(mem_priv)) {
>   dprintk(1, "failed to attach dmabuf\n");
>   ret = PTR_ERR(mem_priv);
> diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
> index 48c489d..bf24c7f 100644
> --- a/include/media/videobuf2-core.h
> +++ b/include/media/videobuf2-core.h
> @@ -396,6 +396,8 @@ struct vb2_buf_ops {
>   *   caller. For example, for V4L2, it should match
>   *   the V4L2_BUF_TYPE_* in include/uapi/linux/videodev2.h
>   * @io_modes:supported io methods (see vb2_io_modes enum)
> + * @dev: device to use for the default allocation context if the driver
> + *   doesn't fill in the @alloc_ctx array.
>   * @dma_attrs:   DMA attributes to use for the DMA. May be NULL.
>   * @fileio_read_once:report EOF after reading the first 
> buffer
>   * @fileio_write_immediately:queue buffer after each write() call
> @@ -460,6 +462,7 @@ struct vb2_buf_ops {
>  struct vb2_queue {
>   unsigned inttype;
>   unsigned intio_modes;
> + struct device   *dev;
>   const struct dma_attrs  *dma_attrs;
>   unsignedfileio_read_once:1;
>   unsigned

Re: [PATCHv4 01/13] vb2: move dma_attrs to vb2_queue

2016-04-25 Thread Laurent Pinchart
Hi Hans,

Thank you for the patch.

On Saturday 23 Apr 2016 13:03:37 Hans Verkuil wrote:
> From: Hans Verkuil 
> 
> Make the dma attributes struct part of vb2_queue. This greatly simplifies
> the remainder of the patch series since the dma_contig alloc context is
> now (as before) just a struct device pointer.
> 
> Signed-off-by: Hans Verkuil 
> Cc: Laurent Pinchart 
> Cc: Sakari Ailus 
> Cc: Mauro Carvalho Chehab 

Reviewed-by: Laurent Pinchart 

> ---
>  drivers/media/v4l2-core/videobuf2-core.c   |  2 +-
>  drivers/media/v4l2-core/videobuf2-dma-contig.c | 16 +++-
>  drivers/media/v4l2-core/videobuf2-dma-sg.c |  5 +++--
>  drivers/media/v4l2-core/videobuf2-vmalloc.c|  5 +++--
>  include/media/videobuf2-core.h |  7 ---
>  include/media/videobuf2-dma-contig.h   |  9 +
>  6 files changed, 19 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c
> b/drivers/media/v4l2-core/videobuf2-core.c index 5d016f4..234e71b 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -207,7 +207,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
>   unsigned long size = PAGE_ALIGN(vb->planes[plane].length);
> 
>   mem_priv = call_ptr_memop(vb, alloc, q->alloc_ctx[plane],
> -   size, dma_dir, q->gfp_flags);
> + q->dma_attrs, size, dma_dir, q->gfp_flags);
>   if (IS_ERR_OR_NULL(mem_priv))
>   goto free;
> 
> diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c
> b/drivers/media/v4l2-core/videobuf2-dma-contig.c index 5361197..0a0befe
> 100644
> --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
> +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
> @@ -23,7 +23,6 @@
> 
>  struct vb2_dc_conf {
>   struct device   *dev;
> - struct dma_attrsattrs;
>  };
> 
>  struct vb2_dc_buf {
> @@ -140,8 +139,9 @@ static void vb2_dc_put(void *buf_priv)
>   kfree(buf);
>  }
> 
> -static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size,
> -   enum dma_data_direction dma_dir, gfp_t gfp_flags)
> +static void *vb2_dc_alloc(void *alloc_ctx, const struct dma_attrs *attrs,
> +   unsigned long size, enum dma_data_direction dma_dir,
> +   gfp_t gfp_flags)
>  {
>   struct vb2_dc_conf *conf = alloc_ctx;
>   struct device *dev = conf->dev;
> @@ -151,7 +151,8 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long
> size, if (!buf)
>   return ERR_PTR(-ENOMEM);
> 
> - buf->attrs = conf->attrs;
> + if (attrs)
> + buf->attrs = *attrs;
>   buf->cookie = dma_alloc_attrs(dev, size, >dma_addr,
>   GFP_KERNEL | gfp_flags, >attrs);
>   if (!buf->cookie) {
> @@ -729,8 +730,7 @@ const struct vb2_mem_ops vb2_dma_contig_memops = {
>  };
>  EXPORT_SYMBOL_GPL(vb2_dma_contig_memops);
> 
> -void *vb2_dma_contig_init_ctx_attrs(struct device *dev,
> - struct dma_attrs *attrs)
> +void *vb2_dma_contig_init_ctx(struct device *dev)
>  {
>   struct vb2_dc_conf *conf;
> 
> @@ -739,12 +739,10 @@ void *vb2_dma_contig_init_ctx_attrs(struct device
> *dev, return ERR_PTR(-ENOMEM);
> 
>   conf->dev = dev;
> - if (attrs)
> - conf->attrs = *attrs;
> 
>   return conf;
>  }
> -EXPORT_SYMBOL_GPL(vb2_dma_contig_init_ctx_attrs);
> +EXPORT_SYMBOL_GPL(vb2_dma_contig_init_ctx);
> 
>  void vb2_dma_contig_cleanup_ctx(void *alloc_ctx)
>  {
> diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c
> b/drivers/media/v4l2-core/videobuf2-dma-sg.c index 9985c89..e7153f7 100644
> --- a/drivers/media/v4l2-core/videobuf2-dma-sg.c
> +++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c
> @@ -99,8 +99,9 @@ static int vb2_dma_sg_alloc_compacted(struct
> vb2_dma_sg_buf *buf, return 0;
>  }
> 
> -static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size,
> -   enum dma_data_direction dma_dir, gfp_t gfp_flags)
> +static void *vb2_dma_sg_alloc(void *alloc_ctx, const struct dma_attrs
> *dma_attrs, +   unsigned long size, enum 
> dma_data_direction 
dma_dir,
> +   gfp_t gfp_flags)
>  {
>   struct vb2_dma_sg_conf *conf = alloc_ctx;
>   struct vb2_dma_sg_buf *buf;
> diff --git a/drivers/media/v4l2-core/videobuf2-vmalloc.c
> b/drivers/media/v4l2-core/videobuf2-vmalloc.c index 1c30274..fb94c80 100644
> --- a/drivers/media/v4l2-core/videobuf2-vmalloc.c
> +++ b/drivers/media/v4l2-core/videobuf2-vmalloc.c
> @@ -33,8 +33,9 @@ struct vb2_vmalloc_buf {
> 
>  static void vb2_vmalloc_put(void *buf_priv);
> 
> -static void *vb2_vmalloc_alloc(void *alloc_ctx, unsigned long 

Re: [PATCH] i2c: saa7115: Support CJC7113 detection

2016-04-25 Thread Ezequiel Garcia
On 23 March 2016 at 01:23, Ezequiel Garcia
 wrote:
> From: Kevin Fitch 
>
> It's been reported that CJC7113 devices are returning
> all 1s when reading register 0:
>
>   "" found @ 0x4a (stk1160)
>
> This new device is apparently compatible with SA7113, so let's
> add a quirk to allow its autodetection. Given there isn't
> any known differences with SAA7113, this commit does not
> introduces a new saa711x_model value.
>
> Reported-by: Philippe Desrochers 
> Signed-off-by: Kevin Fitch 
> Signed-off-by: Ezequiel Garcia 
> ---
>  drivers/media/i2c/saa7115.c | 15 +++
>  1 file changed, 15 insertions(+)
>
> diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
> index 24d2b76dbe97..04f266d0a1ef 100644
> --- a/drivers/media/i2c/saa7115.c
> +++ b/drivers/media/i2c/saa7115.c
> @@ -1794,6 +1794,21 @@ static int saa711x_detect_chip(struct i2c_client 
> *client,
> return GM7113C;
> }
>
> +   /* Check if it is a CJC7113 */
> +   if (!memcmp(name, "", CHIP_VER_SIZE)) {
> +   strlcpy(name, "cjc7113", CHIP_VER_SIZE);
> +
> +   if (!autodetect && strcmp(name, id->name))
> +   return -EINVAL;
> +
> +   v4l_dbg(1, debug, client,
> +   "It seems to be a %s chip (%*ph) @ 0x%x.\n",
> +   name, 16, chip_ver, client->addr << 1);
> +
> +   /* CJC7113 seems to be SAA7113-compatible */
> +   return SAA7113;
> +   }
> +
> /* Chip was not discovered. Return its ID and don't bind */
> v4l_dbg(1, debug, client, "chip %*ph @ 0x%x is unknown.\n",
> 16, chip_ver, client->addr << 1);
> --
> 2.7.0
>

Any feedback on this one?
-- 
Ezequiel García, VanguardiaSur
www.vanguardiasur.com.ar
--
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: [RFC PATCH 00/24] Make Nokia N900 cameras working

2016-04-25 Thread Ivaylo Dimitrov



On 25.04.2016 20:09, Pavel Machek wrote:

Hi!


The needed pipeline could be made with:


Would you have similar pipeline for the back camera? Autofocus and
5MPx makes it more interesting. I understand that different dts will
be needed.



Try with:

media-ctl -r
media-ctl -l '"et8ek8 3-003e":0 -> "video-bus-switch":1 [1]'
media-ctl -l '"video-bus-switch":0 -> "OMAP3 ISP CCP2":0 [1]'
media-ctl -l '"OMAP3 ISP CCP2":1 -> "OMAP3 ISP CCDC":0 [1]'
media-ctl -l '"OMAP3 ISP CCDC":2 -> "OMAP3 ISP preview":0 [1]'
media-ctl -l '"OMAP3 ISP preview":1 -> "OMAP3 ISP resizer":0 [1]'
media-ctl -l '"OMAP3 ISP resizer":1 -> "OMAP3 ISP resizer output":0 [1]'

media-ctl -V '"et8ek8 3-003e":0 [SGRBG10 864x656]'
media-ctl -V '"OMAP3 ISP CCP2":0 [SGRBG10 864x656]'
media-ctl -V '"OMAP3 ISP CCP2":1 [SGRBG10 864x656]'
media-ctl -V '"OMAP3 ISP CCDC":2 [SGRBG10 864x656]'
media-ctl -V '"OMAP3 ISP preview":1 [UYVY 864x656]'
media-ctl -V '"OMAP3 ISP resizer":1 [UYVY 800x600]'


mplayer -tv driver=v4l2:width=800:height=600:outfmt=uyvy:device=/dev/video6
-vo xv -vf screenshot tv://


It fails with:

pavel@n900:/my/tui/ofone/camera$ sudo ./back.sh
Unable to parse link: Device or resource busy (16)


That shouldn't happen, there is something else wrong.


MPlayer svn r34540 (Debian), built with gcc-4.6 (C) 2000-2012 MPlayer
Team

...but as I'm using the original dts, it is expected...?

Would you have dts suitable for the 5MPx camera?



Just change from strobe = <0>; to strobe = <1>; in isp node.

Ivo
--
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: [RFC PATCH 00/24] Make Nokia N900 cameras working

2016-04-25 Thread Ivaylo Dimitrov

Hi,

On 25.04.2016 19:58, Pavel Machek wrote:

Hi!

Ok, let me try:


The needed pipeline could be made with:

media-ctl -r
media-ctl -l '"vs6555 binner 2-0010":1 -> "video-bus-switch":2 [1]'
media-ctl -l '"video-bus-switch":0 -> "OMAP3 ISP CCP2":0 [1]'
media-ctl -l '"OMAP3 ISP CCP2":1 -> "OMAP3 ISP CCDC":0 [1]'
media-ctl -l '"OMAP3 ISP CCDC":2 -> "OMAP3 ISP preview":0 [1]'
media-ctl -l '"OMAP3 ISP preview":1 -> "OMAP3 ISP resizer":0 [1]'
media-ctl -l '"OMAP3 ISP resizer":1 -> "OMAP3 ISP resizer output":0 [1]'
media-ctl -V '"vs6555 pixel array 2-0010":0 [SGRBG10/648x488 (0,0)/648x488 
(0,0)/648x488]'
media-ctl -V '"vs6555 binner 2-0010":1 [SGRBG10/648x488 (0,0)/648x488 
(0,0)/648x488]'
media-ctl -V '"OMAP3 ISP CCP2":0 [SGRBG10 648x488]'
media-ctl -V '"OMAP3 ISP CCP2":1 [SGRBG10 648x488]'
media-ctl -V '"OMAP3 ISP CCDC":2 [SGRBG10 648x488]'
media-ctl -V '"OMAP3 ISP preview":1 [UYVY 648x488]'
media-ctl -V '"OMAP3 ISP resizer":1 [UYVY 656x488]'


pavel@n900:/my/tui/ofone/camera$ sudo ./front.sh
MPlayer svn r34540 (Debian), built with gcc-4.6 (C) 2000-2012 MPlayer
Team

Linux n900 4.6.0-rc5-176733-g8b658a3-dirty
media-ctl from today's git.


and tested with:

mplayer -tv driver=v4l2:width=656:height=488:outfmt=uyvy:device=/dev/video6 -vo 
xv -vf screenshot tv://



I can't do -vo xv ... fails for me, probably due to X
configuration. Does it work with -vo x11 for you?


yes, -vo x11 works under maemo.

In linux-n900 branch we have a patch that reserves memory for omapfb - 
see 
https://github.com/freemangordon/linux-n900/commit/60f85dcb6a663efe687f58208861545d65210b55


also, because of a change in 4.6, 
https://github.com/freemangordon/linux-n900/commit/60f85dcb6a663efe687f58208861545d65210b55#diff-072444ea67d2aca6b402458f50d20edeR125 
needs a change to DMA_MEMORY_IO and the if bellow needs the relevant 
change as well.


This is needed for -vo xv (and any omapfb video playback) to reliably 
work under maemo.



For me it shows window with green interior. And complains about v4l2:
select timeouts. (I enabled these in .config):

+CONFIG_VIDEO_BUS_SWITCH=y
+CONFIG_VIDEO_SMIAREGS=y
+CONFIG_VIDEO_ET8EK8=y
+CONFIG_VIDEOBUF2_CORE=y
+CONFIG_VIDEOBUF2_MEMOPS=y
+CONFIG_VIDEOBUF2_DMA_CONTIG=y
+CONFIG_VIDEO_OMAP3=y
+CONFIG_VIDEO_SMIAPP_PLL=y
+CONFIG_VIDEO_SMIAPP=y

Any ideas?
Pavel



Try to build those as modules. Also, do you have all the needed patches 
besides those in the patchset?


See https://github.com/freemangordon/linux-n900/commits/v4.6-rc4-n900-camera

Also, is there anything related in dmesg log?

Ivo
--
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: [RFC PATCH 00/24] Make Nokia N900 cameras working

2016-04-25 Thread Pali Rohár
On Monday 25 April 2016 16:14:41 Pali Rohár wrote:
> > Anyway, does anyone know where to get the media-ctl tool?
> 
> Looks like it is part of v4l-utils package. At least in git:
> https://git.linuxtv.org/v4l-utils.git/tree/utils/media-ctl
> 
> > It does not seem to be in debian 7 or debian 8...
> 
> I do not see it in debian too, but there is some version in ubuntu:
> http://packages.ubuntu.com/trusty/media-ctl
> 
> So you can compile ubuntu dsc package, should work on debian.

Finally, it is also in debian, see:

https://packages.debian.org/search?suite=sid=any=path=contents=media-ctl
https://packages.debian.org/sid/amd64/v4l-utils/filelist

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: This is a digitally signed message part.


Re: mceusb xhci issue?

2016-04-25 Thread Sean Young
On Sun, Apr 24, 2016 at 10:06:33PM -0600, Wade Berrier wrote:
> Hello,
> 
> I have a mceusb compatible transceiver that only seems to work with
> certain computers.  I'm testing this on centos7 (3.10.0) and fedora23
> (4.4.7).
> 
> The only difference I can see is that the working computer shows
> "using uhci_hcd" and the non working shows "using xhci_hcd".
> 
> Here's the dmesg output of the non-working version:
> 
> -
> 
> [  217.951079] usb 1-5: new full-speed USB device number 10 using xhci_hcd
> [  218.104087] usb 1-5: device descriptor read/64, error -71
> [  218.371010] usb 1-5: config 1 interface 0 altsetting 0 endpoint 0x1 has an 
> invalid bInterval 0, changing to 32
> [  218.371019] usb 1-5: config 1 interface 0 altsetting 0 endpoint 0x81 has 
> an invalid bInterval 0, changing to 32

That's odd. Can you post a "lsusb -vvv" of the device please?

Thanks,

Sean
--
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: [RFC PATCH 00/24] Make Nokia N900 cameras working

2016-04-25 Thread Pavel Machek
Hi!

> >>The needed pipeline could be made with:
> >
> >Would you have similar pipeline for the back camera? Autofocus and
> >5MPx makes it more interesting. I understand that different dts will
> >be needed.
> >
> 
> Try with:
> 
> media-ctl -r
> media-ctl -l '"et8ek8 3-003e":0 -> "video-bus-switch":1 [1]'
> media-ctl -l '"video-bus-switch":0 -> "OMAP3 ISP CCP2":0 [1]'
> media-ctl -l '"OMAP3 ISP CCP2":1 -> "OMAP3 ISP CCDC":0 [1]'
> media-ctl -l '"OMAP3 ISP CCDC":2 -> "OMAP3 ISP preview":0 [1]'
> media-ctl -l '"OMAP3 ISP preview":1 -> "OMAP3 ISP resizer":0 [1]'
> media-ctl -l '"OMAP3 ISP resizer":1 -> "OMAP3 ISP resizer output":0 [1]'
> 
> media-ctl -V '"et8ek8 3-003e":0 [SGRBG10 864x656]'
> media-ctl -V '"OMAP3 ISP CCP2":0 [SGRBG10 864x656]'
> media-ctl -V '"OMAP3 ISP CCP2":1 [SGRBG10 864x656]'
> media-ctl -V '"OMAP3 ISP CCDC":2 [SGRBG10 864x656]'
> media-ctl -V '"OMAP3 ISP preview":1 [UYVY 864x656]'
> media-ctl -V '"OMAP3 ISP resizer":1 [UYVY 800x600]'
> 
> 
> mplayer -tv driver=v4l2:width=800:height=600:outfmt=uyvy:device=/dev/video6
> -vo xv -vf screenshot tv://

It fails with:

pavel@n900:/my/tui/ofone/camera$ sudo ./back.sh
Unable to parse link: Device or resource busy (16)
MPlayer svn r34540 (Debian), built with gcc-4.6 (C) 2000-2012 MPlayer
Team

...but as I'm using the original dts, it is expected...?

Would you have dts suitable for the 5MPx camera?

Thanks,
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.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


Re: [RFC PATCH 00/24] Make Nokia N900 cameras working

2016-04-25 Thread Pavel Machek
Hi!

Ok, let me try:

> The needed pipeline could be made with:
> 
> media-ctl -r
> media-ctl -l '"vs6555 binner 2-0010":1 -> "video-bus-switch":2 [1]'
> media-ctl -l '"video-bus-switch":0 -> "OMAP3 ISP CCP2":0 [1]'
> media-ctl -l '"OMAP3 ISP CCP2":1 -> "OMAP3 ISP CCDC":0 [1]'
> media-ctl -l '"OMAP3 ISP CCDC":2 -> "OMAP3 ISP preview":0 [1]'
> media-ctl -l '"OMAP3 ISP preview":1 -> "OMAP3 ISP resizer":0 [1]'
> media-ctl -l '"OMAP3 ISP resizer":1 -> "OMAP3 ISP resizer output":0 [1]'
> media-ctl -V '"vs6555 pixel array 2-0010":0 [SGRBG10/648x488 (0,0)/648x488 
> (0,0)/648x488]'
> media-ctl -V '"vs6555 binner 2-0010":1 [SGRBG10/648x488 (0,0)/648x488 
> (0,0)/648x488]'
> media-ctl -V '"OMAP3 ISP CCP2":0 [SGRBG10 648x488]'
> media-ctl -V '"OMAP3 ISP CCP2":1 [SGRBG10 648x488]'
> media-ctl -V '"OMAP3 ISP CCDC":2 [SGRBG10 648x488]'
> media-ctl -V '"OMAP3 ISP preview":1 [UYVY 648x488]'
> media-ctl -V '"OMAP3 ISP resizer":1 [UYVY 656x488]'

pavel@n900:/my/tui/ofone/camera$ sudo ./front.sh
MPlayer svn r34540 (Debian), built with gcc-4.6 (C) 2000-2012 MPlayer
Team

Linux n900 4.6.0-rc5-176733-g8b658a3-dirty
media-ctl from today's git.

> and tested with:
> 
> mplayer -tv driver=v4l2:width=656:height=488:outfmt=uyvy:device=/dev/video6 
> -vo xv -vf screenshot tv://
>

I can't do -vo xv ... fails for me, probably due to X
configuration. Does it work with -vo x11 for you?

For me it shows window with green interior. And complains about v4l2:
select timeouts. (I enabled these in .config):

+CONFIG_VIDEO_BUS_SWITCH=y
+CONFIG_VIDEO_SMIAREGS=y
+CONFIG_VIDEO_ET8EK8=y
+CONFIG_VIDEOBUF2_CORE=y
+CONFIG_VIDEOBUF2_MEMOPS=y
+CONFIG_VIDEOBUF2_DMA_CONTIG=y
+CONFIG_VIDEO_OMAP3=y
+CONFIG_VIDEO_SMIAPP_PLL=y
+CONFIG_VIDEO_SMIAPP=y

Any ideas?
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.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


Re: [RFC PATCH 01/24] V4L fixes

2016-04-25 Thread Ivaylo Dimitrov

Hi,

On 25.04.2016 16:25, Sakari Ailus wrote:

Hi Ivaylo,

Thanks for the set!

On Mon, Apr 25, 2016 at 12:08:01AM +0300, Ivaylo Dimitrov wrote:

From: "Tuukka.O Toivonen" 

Squashed from the following upstream commits:

V4L: Create control class for sensor mode
V4L: add ad5820 focus specific custom controls
V4L: add V4L2_CID_TEST_PATTERN
V4L: Add V4L2_CID_MODE_OPSYSCLOCK for reading output system clock

Signed-off-by: Tuukka Toivonen 
Signed-off-by: Pali Rohár 
---
  include/uapi/linux/v4l2-controls.h | 17 +
  1 file changed, 17 insertions(+)

diff --git a/include/uapi/linux/v4l2-controls.h 
b/include/uapi/linux/v4l2-controls.h
index b6a357a..23011cc 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -62,6 +62,7 @@
  #define V4L2_CTRL_CLASS_FM_RX 0x00a1  /* FM Receiver controls 
*/
  #define V4L2_CTRL_CLASS_RF_TUNER  0x00a2  /* RF tuner controls */
  #define V4L2_CTRL_CLASS_DETECT0x00a3  /* Detection 
controls */
+#define V4L2_CTRL_CLASS_MODE   0x00a4  /* Sensor mode 
information */

  /* User-class control IDs */

@@ -974,4 +975,20 @@ 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)

+/* SMIA-type sensor information */
+#define V4L2_CID_MODE_CLASS_BASE   (V4L2_CTRL_CLASS_MODE | 0x900)
+#define V4L2_CID_MODE_CLASS(V4L2_CTRL_CLASS_MODE | 1)
+#define V4L2_CID_MODE_FRAME_WIDTH  (V4L2_CID_MODE_CLASS_BASE+1)
+#define V4L2_CID_MODE_FRAME_HEIGHT (V4L2_CID_MODE_CLASS_BASE+2)
+#define V4L2_CID_MODE_VISIBLE_WIDTH(V4L2_CID_MODE_CLASS_BASE+3)
+#define V4L2_CID_MODE_VISIBLE_HEIGHT   (V4L2_CID_MODE_CLASS_BASE+4)


The interface here pre-dates the selection API. The frame width and height
is today conveyed to the bridge driver by the smiapp driver in the scaler
(or binner in case of the lack of the scaler) sub-device's source pad
format.

(While that's the current interface, I'm not entirely happy with it; it
requires more sub-devices to be created for the same I2C device). I think in
this case you'd need one more to properly control the sensor.



By looking at the code, it seems those are read-only, so I don't think 
it make sense to add a binner sub-device with read-only controls.



+#define V4L2_CID_MODE_PIXELCLOCK   (V4L2_CID_MODE_CLASS_BASE+5)
+#define V4L2_CID_MODE_SENSITIVITY  (V4L2_CID_MODE_CLASS_BASE+6)
+#define V4L2_CID_MODE_OPSYSCLOCK   (V4L2_CID_MODE_CLASS_BASE+7)


While I don't remember quite what the sensitivity value was about (it could
be e.g. binning summing / averaging), the other two values are passed to
(and also controlled by) the user space using controls. There are
V4L2_CID_PIXEL_RATE and V4L2_CID_LINK_FREQ or such.



I've already made a change so V4L2_CID_PIXEL_RATE is used in et8ek8 
driver 
(https://github.com/freemangordon/linux-n900/commit/54433e50451b4ed6cc6e3b25d149c5cacd97e438), 
but V4L2_CID_MODE_PIXELCLOCK is used in smiapp driver, which seems to 
expose its own controls. Not sure those are needed though. And if, what 
for. I hope you know better than me.


I guess V4L2_CID_MODE_OPSYSCLOCK can be easily transformed to 
V4L2_CID_LINK_FREQ in the same way as V4L2_CID_MODE_PIXELCLOCK.



+
+/* Control IDs specific to the AD5820 driver as defined by V4L2 */
+#define V4L2_CID_FOCUS_AD5820_BASE (V4L2_CTRL_CLASS_CAMERA | 
0x10af)
+#define V4L2_CID_FOCUS_AD5820_RAMP_TIME
(V4L2_CID_FOCUS_AD5820_BASE+0)
+#define V4L2_CID_FOCUS_AD5820_RAMP_MODE
(V4L2_CID_FOCUS_AD5820_BASE+1)


The ad5820 driver isn't in upstream at the moment. It should be investigated
whether there is a possibility to have standard V4L2 controls for lens
devices, or whether device specific controls should be implemented instead.
Device specific controls are a safe choice in this case, but they should be
in a separate patch, possibly one that would also include the lens driver
itself.



Yeah, I sent the whole patch for the sake of not losing the history too 
much.


Thanks,
Ivo
--
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: dvb-s2 card "TeVii S472" (cx23885)

2016-04-25 Thread Hendrik Oenings
Hi Olli,

I've tested the driver, it compiles well and I've installed it on my
system.
But there's a problem: Everytime I try to load the driver (exact: the
module cx23885), modprobe (or insmod) is giving me the following:
# modprobe cx23885
modprobe: ERROR: could not insert 'cx23885': Exec format error

I've also tried to compile it with the current 4.6er kernel, but it
stays the same.
$ uname -r
4.6.0-rc5

I've also tried to recompile the driver, but it didn't help.

Maybe it is important to mention that some patches fail at the
beginning of the build process (pr_fmt, debug).

The installed module seems to be correct file format (my arch is
x86_64):
$ file \
 /lib/modules/4.6.0-rc5/kernel/drivers/media/pci/cx23885/cx23885.ko

/lib/modules/4.6.0-rc5/kernel/drivers/media/pci/cx23885/cx23885.ko: ELF
64-bit LSB relocatable, x86-64, version 1 (SYSV),
BuildID[sha1]=07a3f2f2fe383ab691b0022568dcd4d8315dc4b8, not stripped

Regards,
Hendrik

On Mo, 25 Apr 2016 11:56:37 +0300, Olli Salonen 
wrote:

> Hello Hendrik,
> 
> I've created an initial version of the driver.
> https://github.com/trsqr/media_tree/commit/b59f25b18bbe84e009618eefeaf646f5939bdd53
> 
> To build, do the following:
> 
> git clone git://linuxtv.org/media_build.git
> git clone --depth=1 https://github.com/trsqr/media_tree.git -b
> s472 ./media cd media_build
> make dir DIR=../media
> make distclean
> make
> 
> To install after a successful build:
> 
> sudo make install
> 
> Download also the following firmware and place it in /lib/firmware:
> http://palosaari.fi/linux/v4l-dvb/firmware/M88DS3103/3.B/
> 
> The thing is, I had to guess the following parameters in
> drivers/media/pci/cx23885/cx23885-dvb.c file:
> 
> +static const struct m88ds3103_config tevii_s472_m88ds3103_config = {
> +   .i2c_addr = 0x68,
> +   .clock = 2700,
> +   .i2c_wr_max = 33,
> +   .clock_out = 0,
> +   .ts_mode = M88DS3103_TS_PARALLEL,
> +   .ts_clk = 16000,
> +   .ts_clk_pol = 0,
> +   .lnb_en_pol = 0,
> +   .lnb_hv_pol = 1,
> +   .agc = 0x99,
> +};
> 
> If the driver does not work (it loads and appears to tune, but does
> not find channels), try altering ts_clk_pol, lnb_en_pol and
> lnb_hv_pol. The possible values are 1 and 0 so there should not be
> that many iterations needed.. Current values are based on best guess.
> 
> Cheers,
> -olli
> 
> 
> 
> On 24 April 2016 at 19:00, Hendrik Oenings  wrote:
> > Hi Olli,
> >
> > I'm glad that there is someone trying to help me and of course I'm
> > able to test a driver.
> >
> > Because of the attached photos, I think it is better not to send
> > this mail to the mailing list.
> >
> > cx23885, m88ds3103 and m88ts2022 are the values I also think they're
> > correct. cx23885 is also mentioned by lspci, the other values I've
> > also seen often while searching for a solution.
> >
> > Here is also the full output of lspci concerning the tv card which
> > is probably helpful.
> > # lspci -vv
> > [...]
> > 03:00.0 Multimedia video controller: Conexant Systems, Inc. CX23885
> > PCI Video and Audio Decoder (rev 04) Subsystem: Device d472:9022
> > Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop-
> > ParErr- Stepping- SERR- FastB2B- DisINTx- Status: Cap+ 66MHz- UDF-
> > FastB2B- ParErr- DEVSEL=fast >TAbort- SERR-
> >  > routed to IRQ 19 Region 0: Memory at f7c0 (64-bit,
> > non-prefetchable) [size=2M] Capabilities: [40] Express (v1)
> > Endpoint, MSI 00 DevCap: MaxPayload 128 bytes, PhantFunc 0,
> > Latency L0s <64ns, L1 <1us ExtTag- AttnBtn- AttnInd- PwrInd- RBE-
> > FLReset- DevCtl:Report errors: Correctable- Non-Fatal-
> > Fatal- Unsupported- RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop+
> > MaxPayload 128 bytes, MaxReadReq 512 bytes
> > DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq-
> > AuxPwr- TransPend- LnkCap:  Port #0, Speed 2.5GT/s, Width x1,
> > ASPM L0s L1, Exit Latency L0s <2us, L1 <4us ClockPM- Surprise-
> > LLActRep- BwNot- ASPMOptComp- LnkCtl:   ASPM Disabled; RCB 64
> > bytes Disabled- CommClk+ ExtSynch- ClockPM- AutWidDis- BWInt-
> > AutBWInt- LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train-
> > SlotClk+ DLActive- BWMgmt- ABWMgmt- Capabilities: [80] Power
> > Management version 2 Flags: PMEClk- DSI+ D1+ D2+ AuxCurrent=0mA
> > PME(D0+,D1+,D2+,D3hot+,D3cold-) Status: D0 NoSoftRst- PME-Enable-
> > DSel=0 DScale=0 PME- Capabilities: [90] Vital Product Data
> > Product Name: "
> > End
> > Capabilities: [a0] MSI: Enable- Count=1/1 Maskable- 64bit+
> > Address:   Data: 
> > Capabilities: [100 v1] Advanced Error Reporting
> > UESta:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt-
> > UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol- UEMsk:DLP-
> > SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC-
> > UnsupReq- ACSViol- UESvrt:  DLP+ SDES- TLP- FCP+ 

Re: [PATCH] [media] tvp686x: Don't go past array

2016-04-25 Thread Mauro Carvalho Chehab
Em Mon, 25 Apr 2016 12:26:40 -0300
Ezequiel Garcia  escreveu:

> Hi Mauro, Hans:
> 
> Thanks for the fixes to this driver :-)
> 
> On 25 Apr 09:40 AM, Mauro Carvalho Chehab wrote:
> > Ezequiel,
> > 
> > Btw, I'm not seeing support for fps != 25 (or 30 fps) on this driver.
> > As the device seems to support setting the fps, you should be adding
> > support on it for VIDIOC_S_PARM and VIDIOC_G_PARM.
> > 
> > On both ioctls, the driver should return the actual framerate used.
> > So, you'll need to add a code that would convert from the 15 possible
> > framerate converter register settings to v4l2_fract.
> >   
> 
> OK, thanks for the information.
> 
> In fact, framerate support is implemented in the driver that is in
> production.
> 
> Support for s_parm, g_parm was in the original submission [1]
> but we removed it later [2] because we thought it was unused.

hmm... from [1], the support were provided by:

+static void tw686x_set_framerate(struct tw686x_video_channel *vc,
+unsigned int fps)
+{
+   unsigned int map;
+
+   if (vc->fps == fps)
+   return;
+
+   map = tw686x_fields_map(vc->video_standard, fps) << 1;
+   map |= map << 1;
+   if (map > 0)
+   map |= BIT(31);
+   reg_write(vc->dev, VIDEO_FIELD_CTRL[vc->ch], map);
+   vc->fps = fps;
+}

+static int tw686x_g_parm(struct file *file, void *priv,
+struct v4l2_streamparm *sp)
+{
+   struct tw686x_video_channel *vc = video_drvdata(file);
+   struct v4l2_captureparm *cp = >parm.capture;
+
+   if (sp->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+   return -EINVAL;
+   sp->parm.capture.readbuffers = 3;
+
+   cp->capability = V4L2_CAP_TIMEPERFRAME;
+   cp->timeperframe.numerator = 1;
+   cp->timeperframe.denominator = vc->fps;
+   return 0;
+}

+static int tw686x_s_parm(struct file *file, void *priv,
+struct v4l2_streamparm *sp)
+{
+   struct tw686x_video_channel *vc = video_drvdata(file);
+   struct v4l2_captureparm *cp = >parm.capture;
+   unsigned int denominator = cp->timeperframe.denominator;
+   unsigned int numerator = cp->timeperframe.numerator;
+   unsigned int fps;
+
+   if (vb2_is_busy(>vidq))
+   return -EBUSY;
+
+   fps = (!numerator || !denominator) ? 0 : denominator / numerator;
+   if (vc->video_standard & V4L2_STD_625_50)
+   fps = (!fps || fps > 25) ? 25 : fps;
+   else
+   fps = (!fps || fps > 30) ? 30 : fps;
+   tw686x_set_framerate(vc, fps);
+
+   return tw686x_g_parm(file, priv, sp);
+}

Basically, s_parm just stores the fps received from the user and
g_parm just returns 1/fps. The only validation it does is to avoid
fps == 0 or fps > max_fps. This is not what the API docbook states.
It should, instead, return the actual framerate that it was
programmed on the hardware.

Looking at the code, it is not returning the actual framerate, as
the framerate seems to have only 15 possible values,
from 0 (meaning no temporal decimation - e. g. just use the
standard default) to 14:

static unsigned int tw686x_fields_map(v4l2_std_id std, unsigned int fps)
{
static const unsigned int map[15] = {
0x, 0x0001, 0x4001, 0x00104001, 0x00404041,
0x01041041, 0x01104411, 0x0111, 0x0445, 0x04511445,
0x05145145, 0x05151515, 0x05515455, 0x05551555, 0x0555
};

static const unsigned int std_625_50[26] = {
0, 1, 1, 2,  3,  3,  4,  4,  5,  5,  6,  7,  7,
   8, 8, 9, 10, 10, 11, 11, 12, 13, 13, 14, 14, 0
};

static const unsigned int std_525_60[31] = {
0, 1, 1, 1, 2,  2,  3,  3,  4,  4,  5,  5,  6,  6, 7, 7,
   8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 0, 0
};

unsigned int i;

if (std & V4L2_STD_525_60) {
if (fps > ARRAY_SIZE(std_525_60))
fps = 30;
i = std_525_60[fps];
} else {
if (fps > ARRAY_SIZE(std_625_50))
fps = 25;
i = std_625_50[fps];
}

return map[i];
}

>From the above, clearly it uses the same frame rate if "fps" var is
set to 1 to 2 (on 60Hz) and 1 to 3 (on 50 Hz).

What *I* suspect from the above is that the code setting a
temporal decimation register to zero (i = 0 -> map = 0x)
in order to disable the temporal decimation;

And when "i" var is between 1 to 14, the temporal decimation block is
enabled and the real frame rate is given by:

vc->real_fps = (fps * i) / 15

So, the driver should actually store the value of "i" and use it
when setting the framerate.

Btw, in the 60 Hz case, usually the fps is not 30 Hz, but,
instead, 3/1001.

So, I guess the code at s_parm should be doing something like:

if (std & 

Re: [PATCH] [media] tvp686x: Don't go past array

2016-04-25 Thread Ezequiel Garcia
Hi Mauro, Hans:

Thanks for the fixes to this driver :-)

On 25 Apr 09:40 AM, Mauro Carvalho Chehab wrote:
> Ezequiel,
> 
> Btw, I'm not seeing support for fps != 25 (or 30 fps) on this driver.
> As the device seems to support setting the fps, you should be adding
> support on it for VIDIOC_S_PARM and VIDIOC_G_PARM.
> 
> On both ioctls, the driver should return the actual framerate used.
> So, you'll need to add a code that would convert from the 15 possible
> framerate converter register settings to v4l2_fract.
> 

OK, thanks for the information.

In fact, framerate support is implemented in the driver that is in
production.

Support for s_parm, g_parm was in the original submission [1]
but we removed it later [2] because we thought it was unused.
I can't see how we came to that conclusion, since it is actually
used to set the framerate!

Anyway, since we are discussing this, I would like to know if
having s_parm/g_parm is enough for framerate setting support.

When I implemented this a year ago, the v4l2src gstreamer plugin
seemed to require enum_frame_size and enum_frame_interval as well.
It didn't make much sense, but I ended up implementing them
to get it to work. Should that be required?

(To be honest, v4lsrc is quite picky regarding parameters,
so it wouldn't be that surprising if it needs some love).

Thanks!

[1] http://www.spinics.net/lists/linux-media/msg95953.html
[2] http://www.spinics.net/lists/linux-media/msg96503.html
-- 
Ezequiel Garcia, VanguardiaSur
www.vanguardiasur.com.ar
--
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: [PATCHv4 08/13] media/platform: convert drivers to use the new vb2_queue dev field

2016-04-25 Thread Benoit Parrot
Hans,

Thanks for the patch.

Acked-by: Benoit Parrot 

Hans Verkuil  wrote on Sat [2016-Apr-23 13:03:44 +0200]:
> From: Hans Verkuil 
> 
> Stop using alloc_ctx and just fill in the device pointer.
> 
> Signed-off-by: Hans Verkuil 
> Cc: Fabien Dessenne 
> Cc: Benoit Parrot 
> Reviewed-by: Laurent Pinchart 
> ---
>  drivers/media/platform/sti/bdisp/bdisp-v4l2.c | 18 --
>  drivers/media/platform/sti/bdisp/bdisp.h  |  2 --
>  drivers/media/platform/ti-vpe/cal.c   | 15 +--
>  drivers/media/platform/ti-vpe/vpe.c   | 20 
>  drivers/media/platform/vsp1/vsp1_video.c  | 14 ++
>  drivers/media/platform/vsp1/vsp1_video.h  |  1 -
>  drivers/media/platform/xilinx/xilinx-dma.c| 11 +--
>  drivers/media/platform/xilinx/xilinx-dma.h|  2 --
>  8 files changed, 12 insertions(+), 71 deletions(-)
> 
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c 
> b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> index d12a419..b3e8b5a 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> @@ -439,7 +439,7 @@ static void bdisp_ctrls_delete(struct bdisp_ctx *ctx)
>  
>  static int bdisp_queue_setup(struct vb2_queue *vq,
>unsigned int *nb_buf, unsigned int *nb_planes,
> -  unsigned int sizes[], void *allocators[])
> +  unsigned int sizes[], void *alloc_ctxs[])
>  {
>   struct bdisp_ctx *ctx = vb2_get_drv_priv(vq);
>   struct bdisp_frame *frame = ctx_get_frame(ctx, vq->type);
> @@ -453,7 +453,6 @@ static int bdisp_queue_setup(struct vb2_queue *vq,
>   dev_err(ctx->bdisp_dev->dev, "Invalid format\n");
>   return -EINVAL;
>   }
> - allocators[0] = ctx->bdisp_dev->alloc_ctx;
>  
>   if (*nb_planes)
>   return sizes[0] < frame->sizeimage ? -EINVAL : 0;
> @@ -553,6 +552,7 @@ static int queue_init(void *priv,
>   src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
>   src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
>   src_vq->lock = >bdisp_dev->lock;
> + src_vq->dev = ctx->bdisp_dev->v4l2_dev.dev;
>  
>   ret = vb2_queue_init(src_vq);
>   if (ret)
> @@ -567,6 +567,7 @@ static int queue_init(void *priv,
>   dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
>   dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
>   dst_vq->lock = >bdisp_dev->lock;
> + dst_vq->dev = ctx->bdisp_dev->v4l2_dev.dev;
>  
>   return vb2_queue_init(dst_vq);
>  }
> @@ -1269,8 +1270,6 @@ static int bdisp_remove(struct platform_device *pdev)
>  
>   bdisp_hw_free_filters(bdisp->dev);
>  
> - vb2_dma_contig_cleanup_ctx(bdisp->alloc_ctx);
> -
>   pm_runtime_disable(>dev);
>  
>   bdisp_debugfs_remove(bdisp);
> @@ -1371,18 +1370,11 @@ static int bdisp_probe(struct platform_device *pdev)
>   goto err_dbg;
>   }
>  
> - /* Continuous memory allocator */
> - bdisp->alloc_ctx = vb2_dma_contig_init_ctx(dev);
> - if (IS_ERR(bdisp->alloc_ctx)) {
> - ret = PTR_ERR(bdisp->alloc_ctx);
> - goto err_pm;
> - }
> -
>   /* Filters */
>   if (bdisp_hw_alloc_filters(bdisp->dev)) {
>   dev_err(bdisp->dev, "no memory for filters\n");
>   ret = -ENOMEM;
> - goto err_vb2_dma;
> + goto err_pm;
>   }
>  
>   /* Register */
> @@ -1401,8 +1393,6 @@ static int bdisp_probe(struct platform_device *pdev)
>  
>  err_filter:
>   bdisp_hw_free_filters(bdisp->dev);
> -err_vb2_dma:
> - vb2_dma_contig_cleanup_ctx(bdisp->alloc_ctx);
>  err_pm:
>   pm_runtime_put(dev);
>  err_dbg:
> diff --git a/drivers/media/platform/sti/bdisp/bdisp.h 
> b/drivers/media/platform/sti/bdisp/bdisp.h
> index 0cf9857..b3fbf99 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp.h
> +++ b/drivers/media/platform/sti/bdisp/bdisp.h
> @@ -175,7 +175,6 @@ struct bdisp_dbg {
>   * @id: device index
>   * @m2m:memory-to-memory V4L2 device information
>   * @state:  flags used to synchronize m2m and capture mode operation
> - * @alloc_ctx:  videobuf2 memory allocator context
>   * @clock:  IP clock
>   * @regs:   registers
>   * @irq_queue:  interrupt handler waitqueue
> @@ -193,7 +192,6 @@ struct bdisp_dev {
>   u16 id;
>   struct bdisp_m2m_device m2m;
>   unsigned long   state;
> - struct vb2_alloc_ctx*alloc_ctx;
>   struct clk  *clock;
>   void __iomem*regs;
>   wait_queue_head_t   irq_queue;
> diff --git a/drivers/media/platform/ti-vpe/cal.c 
> b/drivers/media/platform/ti-vpe/cal.c
> index 82001e6..51ebf32 100644
> --- 

Re: [PATCHv4 02/13] vb2: add a dev field to use for the default allocation context

2016-04-25 Thread Benoit Parrot
Hans,

Thanks for the patch.

Acked-by: Benoit Parrot 

Hans Verkuil  wrote on Sat [2016-Apr-23 13:03:38 +0200]:
> From: Hans Verkuil 
> 
> The allocation context is nothing more than a per-plane device pointer
> to use when allocating buffers. So just provide a dev pointer in vb2_queue
> for that purpose and drivers can skip allocating/releasing/filling in
> the allocation context unless they require different per-plane device
> pointers as used by some Samsung SoCs.
> 
> Signed-off-by: Hans Verkuil 
> Cc: Laurent Pinchart 
> Cc: Sakari Ailus 
> Cc: Mauro Carvalho Chehab 
> Cc: Florian Echtler 
> Cc: Federico Vaga 
> Cc: "Lad, Prabhakar" 
> Cc: Scott Jiang 
> Acked-by: Philipp Zabel 
> Cc: Fabien Dessenne 
> Cc: Benoit Parrot 
> Cc: Mikhail Ulyanov 
> Cc: Guennadi Liakhovetski 
> Cc: Jonathan Corbet 
> Cc: Ludovic Desroches 
> Cc: Sergei Shtylyov 
> Cc: Kyungmin Park 
> Cc: Sylwester Nawrocki 
> ---
>  drivers/media/v4l2-core/videobuf2-core.c | 14 --
>  include/media/videobuf2-core.h   |  3 +++
>  2 files changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
> b/drivers/media/v4l2-core/videobuf2-core.c
> index 234e71b..2f50a91 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -206,7 +206,8 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
>   for (plane = 0; plane < vb->num_planes; ++plane) {
>   unsigned long size = PAGE_ALIGN(vb->planes[plane].length);
>  
> - mem_priv = call_ptr_memop(vb, alloc, q->alloc_ctx[plane],
> + mem_priv = call_ptr_memop(vb, alloc,
> + q->alloc_ctx[plane] ? : >dev,
>   q->dma_attrs, size, dma_dir, q->gfp_flags);
>   if (IS_ERR_OR_NULL(mem_priv))
>   goto free;
> @@ -1131,9 +1132,10 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const 
> void *pb)
>   vb->planes[plane].data_offset = 0;
>  
>   /* Acquire each plane's memory */
> - mem_priv = call_ptr_memop(vb, get_userptr, q->alloc_ctx[plane],
> -   planes[plane].m.userptr,
> -   planes[plane].length, dma_dir);
> + mem_priv = call_ptr_memop(vb, get_userptr,
> + q->alloc_ctx[plane] ? : >dev,
> + planes[plane].m.userptr,
> + planes[plane].length, dma_dir);
>   if (IS_ERR_OR_NULL(mem_priv)) {
>   dprintk(1, "failed acquiring userspace "
>   "memory for plane %d\n", plane);
> @@ -1256,8 +1258,8 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const 
> void *pb)
>  
>   /* Acquire each plane's memory */
>   mem_priv = call_ptr_memop(vb, attach_dmabuf,
> - q->alloc_ctx[plane], dbuf, planes[plane].length,
> - dma_dir);
> + q->alloc_ctx[plane] ? : >dev,
> + dbuf, planes[plane].length, dma_dir);
>   if (IS_ERR(mem_priv)) {
>   dprintk(1, "failed to attach dmabuf\n");
>   ret = PTR_ERR(mem_priv);
> diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
> index 48c489d..bf24c7f 100644
> --- a/include/media/videobuf2-core.h
> +++ b/include/media/videobuf2-core.h
> @@ -396,6 +396,8 @@ struct vb2_buf_ops {
>   *   caller. For example, for V4L2, it should match
>   *   the V4L2_BUF_TYPE_* in include/uapi/linux/videodev2.h
>   * @io_modes:supported io methods (see vb2_io_modes enum)
> + * @dev: device to use for the default allocation context if the driver
> + *   doesn't fill in the @alloc_ctx array.
>   * @dma_attrs:   DMA attributes to use for the DMA. May be NULL.
>   * @fileio_read_once:report EOF after reading the first 
> buffer
>   * @fileio_write_immediately:queue buffer after each write() call
> @@ -460,6 +462,7 @@ struct vb2_buf_ops {
>  struct vb2_queue {
>   unsigned inttype;
>   unsigned intio_modes;
> + struct device   *dev;
>   const struct dma_attrs  *dma_attrs;
>   unsignedfileio_read_once:1;
>   unsigned   

Re: [PATCH] [media] au0828: fix double free in au0828_usb_probe()

2016-04-25 Thread Shuah Khan
On 04/22/2016 04:05 PM, Alexey Khoroshilov wrote:
> In case of failure au0828_v4l2_device_register() deallocates dev
> and returns error code to au0828_usb_probe(), which also
> calls kfree(dev) on a failure path.
> 
> The patch removes duplicated code from au0828_v4l2_device_register().
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov 

I sent a fix in for this a few weeks ago:

https://lkml.org/lkml/2016/3/28/453

thanks,
-- Shuah

> ---
>  drivers/media/usb/au0828/au0828-video.c | 4 
>  1 file changed, 4 deletions(-)
> 
> diff --git a/drivers/media/usb/au0828/au0828-video.c 
> b/drivers/media/usb/au0828/au0828-video.c
> index 32d7db96479c..7d0ec4cb248c 100644
> --- a/drivers/media/usb/au0828/au0828-video.c
> +++ b/drivers/media/usb/au0828/au0828-video.c
> @@ -679,8 +679,6 @@ int au0828_v4l2_device_register(struct usb_interface 
> *interface,
>   if (retval) {
>   pr_err("%s() v4l2_device_register failed\n",
>  __func__);
> - mutex_unlock(>lock);
> - kfree(dev);
>   return retval;
>   }
>  
> @@ -691,8 +689,6 @@ int au0828_v4l2_device_register(struct usb_interface 
> *interface,
>   if (retval) {
>   pr_err("%s() v4l2_ctrl_handler_init failed\n",
>  __func__);
> - mutex_unlock(>lock);
> - kfree(dev);
>   return retval;
>   }
>   dev->v4l2_dev.ctrl_handler = >v4l2_ctrl_hdl;
> 

--
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: [RFC PATCH 00/24] Make Nokia N900 cameras working

2016-04-25 Thread Pali Rohár
On Monday 25 April 2016 16:06:12 Pavel Machek wrote:
> Hi!
> 
> > On Monday 25 April 2016 00:08:00 Ivaylo Dimitrov wrote:
> > > The needed pipeline could be made with:
> > > 
> > > media-ctl -r
> > > media-ctl -l '"vs6555 binner 2-0010":1 -> "video-bus-switch":2
> ...
> > On Monday 25 April 2016 09:33:18 Ivaylo Dimitrov wrote:
> > > Try with:
> > > 
> > > media-ctl -r
> > > media-ctl -l '"et8ek8 3-003e":0 -> "video-bus-switch":1 [1]'
> ...
> > > mplayer -tv 
> > > driver=v4l2:width=800:height=600:outfmt=uyvy:device=/dev/video6 -vo xv 
> > > -vf screenshot tv://
> > 
> > Hey!!! That is crazy! Who created such retard API?? In both cases you
> > are going to show video from /dev/video6 device. But in real I have two
> > independent camera devices: front and back.
> 
> Because Nokia, and because the hardware is complex, I'm afraid.

In Nokia kernel, there are just /dev/video0 and /dev/video1. When I open
first I see back camera, second front camera. No media-ctl nor any other
reconfiguration is needed. So not Nokia nor hw complexity is reason...

> First we need to get it to work, than we can improve v4l... 

Ok, I agree. But I really would like to see just two video devices and
all those route configuration in kernel...

> Anyway, does anyone know where to get the media-ctl tool?

Looks like it is part of v4l-utils package. At least in git:
https://git.linuxtv.org/v4l-utils.git/tree/utils/media-ctl

> It does not seem to be in debian 7 or debian 8...

I do not see it in debian too, but there is some version in ubuntu:
http://packages.ubuntu.com/trusty/media-ctl

So you can compile ubuntu dsc package, should work on debian.

-- 
Pali Rohár
pali.ro...@gmail.com
--
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: [RFC PATCH 00/24] Make Nokia N900 cameras working

2016-04-25 Thread Hans Verkuil
On 04/25/2016 04:06 PM, Pavel Machek wrote:
> Hi!
> 
>> On Monday 25 April 2016 00:08:00 Ivaylo Dimitrov wrote:
>>> The needed pipeline could be made with:
>>>
>>> media-ctl -r
>>> media-ctl -l '"vs6555 binner 2-0010":1 -> "video-bus-switch":2
> ...
>> On Monday 25 April 2016 09:33:18 Ivaylo Dimitrov wrote:
>>> Try with:
>>>
>>> media-ctl -r
>>> media-ctl -l '"et8ek8 3-003e":0 -> "video-bus-switch":1 [1]'
> ...
>>> mplayer -tv driver=v4l2:width=800:height=600:outfmt=uyvy:device=/dev/video6 
>>> -vo xv -vf screenshot tv://
>>
>> Hey!!! That is crazy! Who created such retard API?? In both cases you
>> are going to show video from /dev/video6 device. But in real I have two
>> independent camera devices: front and back.
> 
> Because Nokia, and because the hardware is complex, I'm afraid. First
> we need to get it to work, than we can improve v4l... 
> 
> Anyway, does anyone know where to get the media-ctl tool? It does not
> seem to be in debian 7 or debian 8...

It's part of the v4l-utils git repo:

https://git.linuxtv.org/v4l-utils.git/

Regards,

Hans
--
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: [RFC PATCH 00/24] Make Nokia N900 cameras working

2016-04-25 Thread Pavel Machek
Hi!

> On Monday 25 April 2016 00:08:00 Ivaylo Dimitrov wrote:
> > The needed pipeline could be made with:
> > 
> > media-ctl -r
> > media-ctl -l '"vs6555 binner 2-0010":1 -> "video-bus-switch":2
...
> On Monday 25 April 2016 09:33:18 Ivaylo Dimitrov wrote:
> > Try with:
> > 
> > media-ctl -r
> > media-ctl -l '"et8ek8 3-003e":0 -> "video-bus-switch":1 [1]'
...
> > mplayer -tv driver=v4l2:width=800:height=600:outfmt=uyvy:device=/dev/video6 
> > -vo xv -vf screenshot tv://
> 
> Hey!!! That is crazy! Who created such retard API?? In both cases you
> are going to show video from /dev/video6 device. But in real I have two
> independent camera devices: front and back.

Because Nokia, and because the hardware is complex, I'm afraid. First
we need to get it to work, than we can improve v4l... 

Anyway, does anyone know where to get the media-ctl tool? It does not
seem to be in debian 7 or debian 8...
pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.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


Re: [PATCHv3 01/12] vb2: add a dev field to use for the default allocation context

2016-04-25 Thread Laurent Pinchart
Hi Hans,

On Monday 25 Apr 2016 09:25:57 Hans Verkuil wrote:
> On 04/24/2016 11:51 PM, Laurent Pinchart wrote:
> > On Saturday 23 Apr 2016 12:37:10 Hans Verkuil wrote:
> >> On 04/23/2016 02:14 AM, Laurent Pinchart wrote:
> >>> On Friday 22 Apr 2016 10:38:08 Hans Verkuil wrote:
>  From: Hans Verkuil 
>  
>  The allocation context is nothing more than a per-plane device pointer
>  to use when allocating buffers. So just provide a dev pointer in
>  vb2_queue for that purpose and drivers can skip
>  allocating/releasing/filling in the allocation context unless they
>  require different per-plane device pointers as used by some Samsung
>  SoCs.
>  
>  Signed-off-by: Hans Verkuil 
>  Cc: Laurent Pinchart 
>  Cc: Sakari Ailus 
>  Cc: Mauro Carvalho Chehab 
>  Cc: Florian Echtler 
>  Cc: Federico Vaga 
>  Cc: "Lad, Prabhakar" 
>  Cc: Scott Jiang 
>  Cc: Philipp Zabel 
>  Cc: Fabien Dessenne 
>  Cc: Benoit Parrot 
>  Cc: Mikhail Ulyanov 
>  Cc: Guennadi Liakhovetski 
>  Cc: Javier Martin 
>  Cc: Jonathan Corbet 
>  Cc: Ludovic Desroches 
>  Cc: Sergei Shtylyov 
>  Cc: Kyungmin Park 
>  Cc: Sylwester Nawrocki 
>  ---
>  
>   drivers/media/v4l2-core/videobuf2-core.c | 16 +---
>   include/media/videobuf2-core.h   |  3 +++
>   2 files changed, 12 insertions(+), 7 deletions(-)
>  
>  diff --git a/drivers/media/v4l2-core/videobuf2-core.c
>  b/drivers/media/v4l2-core/videobuf2-core.c index 5d016f4..88b5e48
>  100644
>  --- a/drivers/media/v4l2-core/videobuf2-core.c
>  +++ b/drivers/media/v4l2-core/videobuf2-core.c
>  @@ -206,8 +206,9 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer
>  *vb)
>  
>   for (plane = 0; plane < vb->num_planes; ++plane) {
>   
>   unsigned long size = 
>  PAGE_ALIGN(vb->planes[plane].length);
>  
>  -mem_priv = call_ptr_memop(vb, alloc, 
>  q->alloc_ctx[plane],
>  -  size, dma_dir, q->gfp_flags);
>  +mem_priv = call_ptr_memop(vb, alloc,
>  +q->alloc_ctx[plane] ? : >dev,
>  +size, dma_dir, q->gfp_flags);
> >>> 
> >>> While the videobuf2-dma-sg allocation context indeed only contains a
> >>> pointer to the device, the videobuf2-dma-contig context also contains a
> >>> dma_attrs. This patch will break the videobuf2-dma-contig alloc
> >>> implementation.
> >> 
> >> Good point. I fixed this in the last patch, but that would mean
> >> dma-contig would be broken for the patches in between.
> >> 
> >> I'm moving dma_attrs to struct vb2_queue as the first patch, then the
> >> rest will work fine.
> > 
> > Couldn't a driver require different dma attributes per plane ? Would it
> > make sense to keep the allocation context structure, and use the struct
> > device and dma attributes stored in the queue when no allocation context
> > is provided ?
>
> I kept the dma_attrs part simple for two reasons:
> 
> 1) No driver in the kernel uses it.
> 2) I really can't think of any scenario where you get different DMA attrs
> per plane. Perhaps if we make it possible to have a variable number of
> planes, but all that is in the future and I rather take care of it when we
> actually know what we need.
> 
> The 'allocation context' idea was simply a bad one: you're stuck with void
> pointers (I hate those) and always having to check for ENOMEM when
> allocating them. When all you need in almost all cases is just a device
> pointer.

Fair enough, we can add support for different DMA attributes later if we end 
up needed that.

-- 
Regards,

Laurent Pinchart

--
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 02/13] v4l: Add Renesas R-Car FCP driver

2016-04-25 Thread Laurent Pinchart
Hi Geert,

Thank you for the review.

On Monday 25 Apr 2016 09:37:07 Geert Uytterhoeven wrote:
> On Sun, Apr 24, 2016 at 1:49 AM, Laurent Pinchart
> 
>  wrote:
> > The FCP is a companion module of video processing modules in the
> > Renesas R-Car Gen3 SoCs. It provides data compression and decompression,
> > data caching, and conversion of AXI transaction in order to reduce the
> 
> transactions

I'll fix that.

> > memory bandwidth.
> > 
> > --- /dev/null
> > +++ b/drivers/media/platform/rcar-fcp.c
> > @@ -0,0 +1,176 @@
> > 
> > +/**
> > + * rcar_fcp_enable - Enable an FCP
> > + * @fcp: The FCP instance
> > + *
> > + * Before any memory access through an FCP is performed by a module, the
> > FCP + * must be enabled by a call to this function. The enable calls are
> > reference + * counted, each of them must be followed by one
> > rcar_fcp_disable() call when + * no more memory transfer can occur
> > through the FCP.
> > + */
> > +void rcar_fcp_enable(struct rcar_fcp_device *fcp)
> > +{
> > +   if (fcp)
> > +   pm_runtime_get_sync(fcp->dev);
> 
> Given pm_runtime_get_sync() returns an error code (which is usually just
> ignored), perhaps you want to forward that?

I'll fix this too.

> > +}
> > +EXPORT_SYMBOL_GPL(rcar_fcp_enable);
> 
> Regardless
> Reviewed-by: Geert Uytterhoeven 

-- 
Regards,

Laurent Pinchart

--
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 14/41] Documentation: dt: media: fix spelling mistake

2016-04-25 Thread Rob Herring
On Mon, Apr 25, 2016 at 01:24:11AM +0100, Eric Engestrom wrote:
> Signed-off-by: Eric Engestrom 

Applied, thanks.

Rob

> ---
>  Documentation/devicetree/bindings/media/xilinx/video.txt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/media/xilinx/video.txt 
> b/Documentation/devicetree/bindings/media/xilinx/video.txt
> index cbd46fa..68ac210 100644
> --- a/Documentation/devicetree/bindings/media/xilinx/video.txt
> +++ b/Documentation/devicetree/bindings/media/xilinx/video.txt
> @@ -20,7 +20,7 @@ The following properties are common to all Xilinx video IP 
> cores.
>  - xlnx,video-format: This property represents a video format transmitted on 
> an
>AXI bus between video IP cores, using its VF code as defined in 
> "AXI4-Stream
>Video IP and System Design Guide" [UG934]. How the format relates to the IP
> -  core is decribed in the IP core bindings documentation.
> +  core is described in the IP core bindings documentation.
>  
>  - xlnx,video-width: This property qualifies the video format with the sample
>width expressed as a number of bits per pixel component. All components 
> must
> -- 
> 2.8.0
> 
--
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 03/13] v4l: vsp1: Implement runtime PM support

2016-04-25 Thread Laurent Pinchart
Hi Geert,

Thank you for the review.

On Monday 25 Apr 2016 10:24:22 Geert Uytterhoeven wrote:
> On Sun, Apr 24, 2016 at 1:49 AM, Laurent Pinchart
> 
>  wrote:
> > Replace the manual refcount and clock management code by runtime PM.
> > 
> > Signed-off-by: Laurent Pinchart
> > 
> > ---
> > 
> >  drivers/media/platform/Kconfig  |   1 +
> >  drivers/media/platform/vsp1/vsp1.h  |   3 -
> >  drivers/media/platform/vsp1/vsp1_drv.c  | 101 ---
> >  drivers/media/platform/vsp1/vsp1_pipe.c |   2 +-
> >  4 files changed, 54 insertions(+), 53 deletions(-)
> > 
> > diff --git a/drivers/media/platform/Kconfig
> > b/drivers/media/platform/Kconfig index f453910050be..28d0db102c0b 100644
> > --- a/drivers/media/platform/Kconfig
> > +++ b/drivers/media/platform/Kconfig
> > @@ -264,6 +264,7 @@ config VIDEO_RENESAS_VSP1
> > tristate "Renesas VSP1 Video Processing Engine"
> > depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && HAS_DMA
> > depends on (ARCH_RENESAS && OF) || COMPILE_TEST
> > +   depends on PM
> 
> PM is always enabled since commits 2ee98234b88174f2 ("arm64: renesas: Enable
> PM and PM_GENERIC_DOMAINS for SoCs with PM Domains") and 71d076ceb245f0d9
> ("ARM: shmobile: Enable PM and PM_GENERIC_DOMAINS for SoCs with PM
> Domains").
> 
> Even before that, drivers/sh/pm_runtime.c would have taken care of
> enabling the clocks for you.

OK, I'll fix that. COMPILE_TEST should be handled by the pm_runtime.h stub 
functions.

-- 
Regards,

Laurent Pinchart

--
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 01/13] dt-bindings: Add Renesas R-Car FCP DT bindings

2016-04-25 Thread Laurent Pinchart
Hi Geert,

Thank you for the review.

On Monday 25 Apr 2016 09:32:04 Geert Uytterhoeven wrote:
> On Sun, Apr 24, 2016 at 1:49 AM, Laurent Pinchart wrote:
> > The FCP is a companion module of video processing modules in the Renesas
> > R-Car Gen3 SoCs. It provides data compression and decompression, data
> > caching, and conversion of AXI transaction in order to reduce the memory
> 
> transactions
> 
> > bandwidth.
> > 
> > Signed-off-by: Laurent Pinchart
> > 
> > ---
> > 
> >  .../devicetree/bindings/media/renesas,fcp.txt  | 31 +
> >  1 file changed, 31 insertions(+)
> >  create mode 100644
> >  Documentation/devicetree/bindings/media/renesas,fcp.txt
> > 
> > Cc: devicet...@vger.kernel.org
> > 
> > diff --git a/Documentation/devicetree/bindings/media/renesas,fcp.txt
> > b/Documentation/devicetree/bindings/media/renesas,fcp.txt new file mode
> > 100644
> > index ..46beec97d625
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/media/renesas,fcp.txt
> > @@ -0,0 +1,31 @@
> > +Renesas R-Car Frame Compression Processor (FCP)
> > +---
> > +
> > +The FCP is a companion module of video processing modules in the Renesas
> > R-Car +Gen3 SoCs. It provides data compression and decompression, data
> > caching, and +conversion of AXI transaction in order to reduce the memory
> > bandwidth.
>
> transactions

I'll fix the typos.
 
> > +There are three types of FCP whose configuration and behaviour highly
> > depend +on the module they are paired with.
> 
> + - compatible: Must be one or more of the following
> +
> +   - "renesas,r8a7795-fcpv" for R8A7795 (R-Car H3) compatible 'FCP for VSP'
> +   - "renesas,fcpv" for generic compatible 'FCP for VSP'
> 
> As you list only one compatible value, I guess the type is determined
> automatically at run-time?

No, it's just that the bindings only support the FCPV at the moment, the other 
two variants are not supported yet.

-- 
Regards,

Laurent Pinchart

--
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: [RFC PATCH 01/24] V4L fixes

2016-04-25 Thread Sakari Ailus
Hi Ivaylo,

Thanks for the set!

On Mon, Apr 25, 2016 at 12:08:01AM +0300, Ivaylo Dimitrov wrote:
> From: "Tuukka.O Toivonen" 
> 
> Squashed from the following upstream commits:
> 
> V4L: Create control class for sensor mode
> V4L: add ad5820 focus specific custom controls
> V4L: add V4L2_CID_TEST_PATTERN
> V4L: Add V4L2_CID_MODE_OPSYSCLOCK for reading output system clock
> 
> Signed-off-by: Tuukka Toivonen 
> Signed-off-by: Pali Rohár 
> ---
>  include/uapi/linux/v4l2-controls.h | 17 +
>  1 file changed, 17 insertions(+)
> 
> diff --git a/include/uapi/linux/v4l2-controls.h 
> b/include/uapi/linux/v4l2-controls.h
> index b6a357a..23011cc 100644
> --- a/include/uapi/linux/v4l2-controls.h
> +++ b/include/uapi/linux/v4l2-controls.h
> @@ -62,6 +62,7 @@
>  #define V4L2_CTRL_CLASS_FM_RX0x00a1  /* FM Receiver 
> controls */
>  #define V4L2_CTRL_CLASS_RF_TUNER 0x00a2  /* RF tuner controls */
>  #define V4L2_CTRL_CLASS_DETECT   0x00a3  /* Detection 
> controls */
> +#define V4L2_CTRL_CLASS_MODE 0x00a4  /* Sensor mode 
> information */
>  
>  /* User-class control IDs */
>  
> @@ -974,4 +975,20 @@ 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)
>  
> +/* SMIA-type sensor information */
> +#define V4L2_CID_MODE_CLASS_BASE (V4L2_CTRL_CLASS_MODE | 0x900)
> +#define V4L2_CID_MODE_CLASS  (V4L2_CTRL_CLASS_MODE | 1)
> +#define V4L2_CID_MODE_FRAME_WIDTH(V4L2_CID_MODE_CLASS_BASE+1)
> +#define V4L2_CID_MODE_FRAME_HEIGHT   (V4L2_CID_MODE_CLASS_BASE+2)
> +#define V4L2_CID_MODE_VISIBLE_WIDTH  (V4L2_CID_MODE_CLASS_BASE+3)
> +#define V4L2_CID_MODE_VISIBLE_HEIGHT (V4L2_CID_MODE_CLASS_BASE+4)

The interface here pre-dates the selection API. The frame width and height
is today conveyed to the bridge driver by the smiapp driver in the scaler
(or binner in case of the lack of the scaler) sub-device's source pad
format.

(While that's the current interface, I'm not entirely happy with it; it
requires more sub-devices to be created for the same I2C device). I think in
this case you'd need one more to properly control the sensor.

> +#define V4L2_CID_MODE_PIXELCLOCK (V4L2_CID_MODE_CLASS_BASE+5)
> +#define V4L2_CID_MODE_SENSITIVITY(V4L2_CID_MODE_CLASS_BASE+6)
> +#define V4L2_CID_MODE_OPSYSCLOCK (V4L2_CID_MODE_CLASS_BASE+7)

While I don't remember quite what the sensitivity value was about (it could
be e.g. binning summing / averaging), the other two values are passed to
(and also controlled by) the user space using controls. There are
V4L2_CID_PIXEL_RATE and V4L2_CID_LINK_FREQ or such.

> +
> +/* Control IDs specific to the AD5820 driver as defined by V4L2 */
> +#define V4L2_CID_FOCUS_AD5820_BASE   (V4L2_CTRL_CLASS_CAMERA | 
> 0x10af)
> +#define V4L2_CID_FOCUS_AD5820_RAMP_TIME  
> (V4L2_CID_FOCUS_AD5820_BASE+0)
> +#define V4L2_CID_FOCUS_AD5820_RAMP_MODE  
> (V4L2_CID_FOCUS_AD5820_BASE+1)

The ad5820 driver isn't in upstream at the moment. It should be investigated
whether there is a possibility to have standard V4L2 controls for lens
devices, or whether device specific controls should be implemented instead.
Device specific controls are a safe choice in this case, but they should be
in a separate patch, possibly one that would also include the lens driver
itself.

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
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


[PATCH 3/3] samples: v4l: from Documentation to samples directory

2016-04-25 Thread Arnd Bergmann
With the new autoksyms support, we can run into a situation where
the v4l pci skeleton module is the only one using some exported
symbols that get dropped because they are never referenced by
the kernel otherwise, causing a build problem:

ERROR: "vb2_dma_contig_memops" [Documentation/video4linux/v4l2-pci-skeleton.ko] 
undefined!
ERROR: "vb2_dma_contig_init_ctx_attrs" 
[Documentation/video4linux/v4l2-pci-skeleton.ko] undefined!
ERROR: "v4l2_match_dv_timings" [Documentation/video4linux/v4l2-pci-skeleton.ko] 
undefined!
ERROR: "v4l2_find_dv_timings_cap" 
[Documentation/video4linux/v4l2-pci-skeleton.ko] undefined!
ERROR: "v4l2_valid_dv_timings" [Documentation/video4linux/v4l2-pci-skeleton.ko] 
undefined!
ERROR: "v4l2_enum_dv_timings_cap" 
[Documentation/video4linux/v4l2-pci-skeleton.ko] undefined!
ERROR: "vb2_dma_contig_cleanup_ctx" 
[Documentation/video4linux/v4l2-pci-skeleton.ko] undefined!

Specifically, we do look in the samples directory for users of
symbols, but not the Documentation directory.

This solves the build problem by moving the connector sample into
the same directory as the other samples.

Signed-off-by: Arnd Bergmann 
Fixes: 23121ca2b56b ("kbuild: create/adjust generated/autoksyms.h")
---
 Documentation/Makefile | 3 +--
 Documentation/video4linux/v4l2-framework.txt   | 2 +-
 samples/Makefile   | 2 +-
 {Documentation/video4linux => samples/v4l}/Makefile| 0
 {Documentation/video4linux => samples/v4l}/v4l2-pci-skeleton.c | 0
 5 files changed, 3 insertions(+), 4 deletions(-)
 rename {Documentation/video4linux => samples/v4l}/Makefile (100%)
 rename {Documentation/video4linux => samples/v4l}/v4l2-pci-skeleton.c (100%)

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 13b5ae1b87aa..de955e151af8 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -1,4 +1,3 @@
 subdir-y := accounting auxdisplay blackfin \
filesystems filesystems ia64 laptops mic misc-devices \
-   networking pcmcia prctl ptp timers vDSO video4linux \
-   watchdog
+   networking pcmcia prctl ptp timers vDSO watchdog
diff --git a/Documentation/video4linux/v4l2-framework.txt 
b/Documentation/video4linux/v4l2-framework.txt
index fa41608ab2b4..cbefc7902f5f 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -35,7 +35,7 @@ need and this same framework should make it much easier to 
refactor
 common code into utility functions shared by all drivers.
 
 A good example to look at as a reference is the v4l2-pci-skeleton.c
-source that is available in this directory. It is a skeleton driver for
+source that is available in samples/v4l/. It is a skeleton driver for
 a PCI capture card, and demonstrates how to use the V4L2 driver
 framework. It can be used as a template for real PCI video capture driver.
 
diff --git a/samples/Makefile b/samples/Makefile
index 594ef7d9fa2a..2e3b523d7097 100644
--- a/samples/Makefile
+++ b/samples/Makefile
@@ -2,4 +2,4 @@
 
 obj-$(CONFIG_SAMPLES)  += kobject/ kprobes/ trace_events/ livepatch/ \
   hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/ \
-  configfs/ connector/
+  configfs/ connector/ v4l/
diff --git a/Documentation/video4linux/Makefile b/samples/v4l/Makefile
similarity index 100%
rename from Documentation/video4linux/Makefile
rename to samples/v4l/Makefile
diff --git a/Documentation/video4linux/v4l2-pci-skeleton.c 
b/samples/v4l/v4l2-pci-skeleton.c
similarity index 100%
rename from Documentation/video4linux/v4l2-pci-skeleton.c
rename to samples/v4l/v4l2-pci-skeleton.c
-- 
2.7.0

--
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 v8 5/8] [media] vcodec: mediatek: Add Mediatek V4L2 Video Encoder Driver

2016-04-25 Thread Hans Verkuil
On 04/25/2016 02:30 PM, Tiffany Lin wrote:
> Add v4l2 layer encoder driver for MT8173
> 
> Signed-off-by: Tiffany Lin 
> 
> ---
>  drivers/media/platform/Kconfig |   16 +
>  drivers/media/platform/Makefile|2 +
>  drivers/media/platform/mtk-vcodec/Makefile |   14 +
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |  339 +
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 1303 
> 
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.h |   58 +
>  .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c |  456 +++
>  .../media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c  |  137 ++
>  .../media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h  |   26 +
>  .../media/platform/mtk-vcodec/mtk_vcodec_intr.c|   56 +
>  .../media/platform/mtk-vcodec/mtk_vcodec_intr.h|   27 +
>  .../media/platform/mtk-vcodec/mtk_vcodec_util.c|   96 ++
>  .../media/platform/mtk-vcodec/mtk_vcodec_util.h|   87 ++
>  drivers/media/platform/mtk-vcodec/venc_drv_base.h  |   62 +
>  drivers/media/platform/mtk-vcodec/venc_drv_if.c|  107 ++
>  drivers/media/platform/mtk-vcodec/venc_drv_if.h|  165 +++
>  drivers/media/platform/mtk-vcodec/venc_ipi_msg.h   |  210 
>  17 files changed, 3161 insertions(+)
>  create mode 100644 drivers/media/platform/mtk-vcodec/Makefile
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.h
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.c
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.h
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
>  create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_base.h
>  create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_if.c
>  create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_if.h
>  create mode 100644 drivers/media/platform/mtk-vcodec/venc_ipi_msg.h
> 

...

> +static int fops_vcodec_open(struct file *file)
> +{
> + struct mtk_vcodec_dev *dev = video_drvdata(file);
> + struct mtk_vcodec_ctx *ctx = NULL;
> + int ret = 0;
> +
> + mutex_lock(>dev_mutex);

I would move this to after the kzalloc, since that doesn't need to be
called with the mutex held.

> +
> + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
> + if (!ctx) {

And then you can just do return -ENOMEM here.

> + ret = -ENOMEM;
> + goto err_alloc;
> + }
> +
> + ctx->idx = dev->curr_max_idx;

I'd do:

/*
 * Use simple counter to uniquely identify this context. Only
 * used for logging.
 */
ctx->idx = dev->curr_max_idx++;

I would also prefer that it is call 'id' instead of idx, since that's really
what it is, just an ID.

And the counter is then id_counter instead of curr_max_idx.

> + v4l2_fh_init(>fh, video_devdata(file));
> + file->private_data = >fh;
> + v4l2_fh_add(>fh);
> + INIT_LIST_HEAD(>list);
> + ctx->dev = dev;
> + init_waitqueue_head(>queue);
> +
> + ctx->type = MTK_INST_ENCODER;
> + ret = mtk_vcodec_enc_ctrls_setup(ctx);
> + if (ret) {
> + mtk_v4l2_err("Failed to setup controls() (%d)",
> + ret);
> + goto err_ctrls_setup;
> + }
> + ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev_enc, ctx,
> + _vcodec_enc_queue_init);
> + if (IS_ERR(ctx->m2m_ctx)) {
> + ret = PTR_ERR(ctx->m2m_ctx);
> + mtk_v4l2_err("Failed to v4l2_m2m_ctx_init() (%d)",
> + ret);
> + goto err_m2m_ctx_init;
> + }
> + mtk_vcodec_enc_set_default_params(ctx);
> +
> + if (v4l2_fh_is_singular(>fh)) {
> + /*
> +  * vpu_load_firmware checks if it was loaded already and
> +  * does nothing in that case
> +  */
> + ret = vpu_load_firmware(dev->vpu_plat_dev);
> + if (ret < 0) {
> + /*
> +  * Return 0 if downloading firmware successfully,
> +  * otherwise it is failed
> +  */
> + mtk_v4l2_err("vpu_load_firmware failed!");
> + goto err_load_fw;
> + }
> +
> + dev->enc_capability =
> + vpu_get_venc_hw_capa(dev->vpu_plat_dev);
> + mtk_v4l2_debug(0, "encoder capability %x", dev->enc_capability);
> + }
> +
> + mtk_v4l2_debug(2, "Create instance 

Re: [PATCH] [media] tvp686x: Don't go past array

2016-04-25 Thread Mauro Carvalho Chehab
Em Mon, 25 Apr 2016 14:42:31 +0200
Hans Verkuil  escreveu:


> > So, I would go to the following enclosed patch.  
> 
> Looks good to me. Acked below. Amazing how many bugs one can make in one
> simple patch...

Applied, thanks!

Yeah, simple patches are harder than complex ones ;)

> 
> > 
> > Ezequiel,
> > 
> > Btw, I'm not seeing support for fps != 25 (or 30 fps) on this driver.
> > As the device seems to support setting the fps, you should be adding
> > support on it for VIDIOC_S_PARM and VIDIOC_G_PARM.
> > 
> > On both ioctls, the driver should return the actual framerate used.
> > So, you'll need to add a code that would convert from the 15 possible
> > framerate converter register settings to v4l2_fract.
> >   
> >>  
> >>> + i = 14; /* 25 fps */
> >>> + else
> >>> + i = std_625_50[fps];
> >>> + } else {
> >>> + if (unlikely(i > ARRAY_SIZE(std_525_60)))
> >>> + i = 0;  /* 30 fps */
> >>> + else
> >>> + i = std_525_60[fps];
> >>> + }
> >>>  
> >>>   return map[i];
> >>>  }
> >>> 
> >>
> >> Regards,
> >>
> >>Hans  
> > 
> > Thanks,
> > Mauro
> > 
> > -
> > 
> > [media] tw686x: Don't go past array
> > 
> > Depending on the compiler version, currently it produces the
> > following warnings:
> > tw686x-video.c: In function 'tw686x_video_init':
> > tw686x-video.c:65:543: warning: array subscript is above array bounds 
> > [-Warray-bounds]
> > 
> > This is actually bogus with the current code, as it currently
> > hardcodes the framerate to 30 frames/sec, however a potential
> > use after the array size could happen when the driver adds support
> > for setting the framerate. So, fix it.
> > 
> > Signed-off-by: Mauro Carvalho Chehab   
> 
> Acked-by: Hans Verkuil 
> 
> > 
> > diff --git a/drivers/media/pci/tw686x/tw686x-video.c 
> > b/drivers/media/pci/tw686x/tw686x-video.c
> > index 118e9fac9f28..9468fda69f3d 100644
> > --- a/drivers/media/pci/tw686x/tw686x-video.c
> > +++ b/drivers/media/pci/tw686x/tw686x-video.c
> > @@ -61,8 +61,17 @@ static unsigned int tw686x_fields_map(v4l2_std_id std, 
> > unsigned int fps)
> >8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 0, 0
> > };
> >  
> > -   unsigned int i =
> > -   (std & V4L2_STD_625_50) ? std_625_50[fps] : std_525_60[fps];
> > +   unsigned int i;
> > +
> > +   if (std & V4L2_STD_525_60) {
> > +   if (fps > ARRAY_SIZE(std_525_60))
> > +   fps = 30;
> > +   i = std_525_60[fps];
> > +   } else {
> > +   if (fps > ARRAY_SIZE(std_625_50))
> > +   fps = 25;
> > +   i = std_625_50[fps];
> > +   }
> >  
> > return map[i];
> >  }
> > 
> > 
> > --
> > 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: [PATCH] [media] tvp686x: Don't go past array

2016-04-25 Thread Hans Verkuil
On 04/25/2016 02:40 PM, Mauro Carvalho Chehab wrote:
> Em Mon, 25 Apr 2016 13:36:57 +0200
> Hans Verkuil  escreveu:
> 
>> Since my patch exchanges the sparse warning with a smatch warning, it's
>> OK to take this one, with a few corrections:
>>
>> Please update the subject line (it says tvp686x instead of tw686x).
> 
> Gah...
> 
>>
>> On 04/23/2016 11:23 AM, Mauro Carvalho Chehab wrote:
>>> Depending on the compiler version, currently it produces the
>>> following warnings:
>>> tw686x-video.c: In function 'tw686x_video_init':
>>> tw686x-video.c:65:543: warning: array subscript is above array bounds 
>>> [-Warray-bounds]
>>>
>>> This is actually bogus with the current code, as it currently
>>> hardcodes the framerate to 30 frames/sec, however a potential
>>> use after the array size could happen when the driver adds support
>>> for setting the framerate. So, fix it.
>>>
>>> Signed-off-by: Mauro Carvalho Chehab 
>>> ---
>>>  drivers/media/pci/tw686x/tw686x-video.c | 15 +--
>>>  1 file changed, 13 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/media/pci/tw686x/tw686x-video.c 
>>> b/drivers/media/pci/tw686x/tw686x-video.c
>>> index 118e9fac9f28..1ff59084ce08 100644
>>> --- a/drivers/media/pci/tw686x/tw686x-video.c
>>> +++ b/drivers/media/pci/tw686x/tw686x-video.c
>>> @@ -61,8 +61,19 @@ static unsigned int tw686x_fields_map(v4l2_std_id std, 
>>> unsigned int fps)
>>>8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 0, 0
>>> };
>>>  
>>> -   unsigned int i =
>>> -   (std & V4L2_STD_625_50) ? std_625_50[fps] : std_525_60[fps];
>>> +   unsigned int i;
>>> +
>>> +   if (std & V4L2_STD_625_50) {  
>>
>> Please test against 525_60 since that is the recommended test.
> 
> Both ways should work, but I'm OK with such change.
> 
>>
>>> +   if (unlikely(i > ARRAY_SIZE(std_625_50)))  
>>
>> Please don't use 'unlikely'. It's pointless for code that is rarely used.
> 
> OK.
> 
>>
>> Actually, the code is wrong: i is uninitialized here.
>>
>> It should be fps >= ARRAY_SIZE(std_625_50).
>>
>> In fact, I'd write it like this:
>>
>>  i = std_625_50[(fps >= ARRAY_SIZE(std_625_50) ? 24 : fps];
> 
> I really don't like the above, as it has an unexplained magic
> number on it. Also, "24" is wrong there.
> 
> So, I would go to the following enclosed patch.

Looks good to me. Acked below. Amazing how many bugs one can make in one
simple patch...

> 
> Ezequiel,
> 
> Btw, I'm not seeing support for fps != 25 (or 30 fps) on this driver.
> As the device seems to support setting the fps, you should be adding
> support on it for VIDIOC_S_PARM and VIDIOC_G_PARM.
> 
> On both ioctls, the driver should return the actual framerate used.
> So, you'll need to add a code that would convert from the 15 possible
> framerate converter register settings to v4l2_fract.
> 
>>
>>> +   i = 14; /* 25 fps */
>>> +   else
>>> +   i = std_625_50[fps];
>>> +   } else {
>>> +   if (unlikely(i > ARRAY_SIZE(std_525_60)))
>>> +   i = 0;  /* 30 fps */
>>> +   else
>>> +   i = std_525_60[fps];
>>> +   }
>>>  
>>> return map[i];
>>>  }
>>>   
>>
>> Regards,
>>
>>  Hans
> 
> Thanks,
> Mauro
> 
> -
> 
> [media] tw686x: Don't go past array
> 
> Depending on the compiler version, currently it produces the
> following warnings:
>   tw686x-video.c: In function 'tw686x_video_init':
>   tw686x-video.c:65:543: warning: array subscript is above array bounds 
> [-Warray-bounds]
> 
> This is actually bogus with the current code, as it currently
> hardcodes the framerate to 30 frames/sec, however a potential
> use after the array size could happen when the driver adds support
> for setting the framerate. So, fix it.
> 
> Signed-off-by: Mauro Carvalho Chehab 

Acked-by: Hans Verkuil 

> 
> diff --git a/drivers/media/pci/tw686x/tw686x-video.c 
> b/drivers/media/pci/tw686x/tw686x-video.c
> index 118e9fac9f28..9468fda69f3d 100644
> --- a/drivers/media/pci/tw686x/tw686x-video.c
> +++ b/drivers/media/pci/tw686x/tw686x-video.c
> @@ -61,8 +61,17 @@ static unsigned int tw686x_fields_map(v4l2_std_id std, 
> unsigned int fps)
>  8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 0, 0
>   };
>  
> - unsigned int i =
> - (std & V4L2_STD_625_50) ? std_625_50[fps] : std_525_60[fps];
> + unsigned int i;
> +
> + if (std & V4L2_STD_525_60) {
> + if (fps > ARRAY_SIZE(std_525_60))
> + fps = 30;
> + i = std_525_60[fps];
> + } else {
> + if (fps > ARRAY_SIZE(std_625_50))
> + fps = 25;
> + i = std_625_50[fps];
> + }
>  
>   return map[i];
>  }
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to 

Re: [PATCH] VPU: mediatek: fix platform_no_drv_owner.cocci warnings

2016-04-25 Thread andrew-ct chen
On Fri, 2016-04-22 at 15:08 +0200, Julia Lawall wrote:
> Remove .owner field if calls are used which set it automatically
> 
> Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci
> 
> CC: Andrew-CT Chen 
> Signed-off-by: Fengguang Wu 
> Signed-off-by: Julia Lawall 
> ---

Acked-by: Andrew-CT Chen 

> 
> base:   git://linuxtv.org/media_tree.git master
> 
>  mtk_vpu.c |1 -
>  1 file changed, 1 deletion(-)
> 
> --- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
> +++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
> @@ -939,7 +939,6 @@ static struct platform_driver mtk_vpu_dr
>   .remove = mtk_vpu_remove,
>   .driver = {
>   .name   = "mtk_vpu",
> - .owner  = THIS_MODULE,
>   .of_match_table = mtk_vpu_match,
>   },
>  };


--
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] VPU: mediatek: fix simple_open.cocci warnings

2016-04-25 Thread andrew-ct chen
On Fri, 2016-04-22 at 15:12 +0200, Julia Lawall wrote:
> Remove an open coded simple_open() function
> and replace file operations references to the function
> with simple_open() instead.
> 
> Generated by: scripts/coccinelle/api/simple_open.cocci
> 
> CC: Andrew-CT Chen 
> Signed-off-by: Fengguang Wu 
> Signed-off-by: Julia Lawall 
> ---

Acked-by: Andrew-CT Chen 

> 
> I'm just passing this along.  Simple_open additionally has a check that
> inode->i_private is not NULL, before doing the assignment.  I don't know
> if that difference is important in this case.
> 
> base:   git://linuxtv.org/media_tree.git master
> 
>  mtk_vpu.c |7 +--
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> --- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
> +++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
> @@ -599,11 +599,6 @@ static void vpu_init_ipi_handler(void *d
>  }
> 
>  #ifdef CONFIG_DEBUG_FS
> -static int vpu_debug_open(struct inode *inode, struct file *file)
> -{
> - file->private_data = inode->i_private;
> - return 0;
> -}
> 
>  static ssize_t vpu_debug_read(struct file *file, char __user *user_buf,
> size_t count, loff_t *ppos)
> @@ -646,7 +641,7 @@ static ssize_t vpu_debug_read(struct fil
>  }
> 
>  static const struct file_operations vpu_debug_fops = {
> - .open = vpu_debug_open,
> + .open = simple_open,
>   .read = vpu_debug_read,
>  };
>  #endif /* CONFIG_DEBUG_FS */


--
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] [media] tvp686x: Don't go past array

2016-04-25 Thread Mauro Carvalho Chehab
Em Mon, 25 Apr 2016 13:36:57 +0200
Hans Verkuil  escreveu:

> Since my patch exchanges the sparse warning with a smatch warning, it's
> OK to take this one, with a few corrections:
> 
> Please update the subject line (it says tvp686x instead of tw686x).

Gah...

> 
> On 04/23/2016 11:23 AM, Mauro Carvalho Chehab wrote:
> > Depending on the compiler version, currently it produces the
> > following warnings:
> > tw686x-video.c: In function 'tw686x_video_init':
> > tw686x-video.c:65:543: warning: array subscript is above array bounds 
> > [-Warray-bounds]
> > 
> > This is actually bogus with the current code, as it currently
> > hardcodes the framerate to 30 frames/sec, however a potential
> > use after the array size could happen when the driver adds support
> > for setting the framerate. So, fix it.
> > 
> > Signed-off-by: Mauro Carvalho Chehab 
> > ---
> >  drivers/media/pci/tw686x/tw686x-video.c | 15 +--
> >  1 file changed, 13 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/media/pci/tw686x/tw686x-video.c 
> > b/drivers/media/pci/tw686x/tw686x-video.c
> > index 118e9fac9f28..1ff59084ce08 100644
> > --- a/drivers/media/pci/tw686x/tw686x-video.c
> > +++ b/drivers/media/pci/tw686x/tw686x-video.c
> > @@ -61,8 +61,19 @@ static unsigned int tw686x_fields_map(v4l2_std_id std, 
> > unsigned int fps)
> >8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 0, 0
> > };
> >  
> > -   unsigned int i =
> > -   (std & V4L2_STD_625_50) ? std_625_50[fps] : std_525_60[fps];
> > +   unsigned int i;
> > +
> > +   if (std & V4L2_STD_625_50) {  
> 
> Please test against 525_60 since that is the recommended test.

Both ways should work, but I'm OK with such change.

> 
> > +   if (unlikely(i > ARRAY_SIZE(std_625_50)))  
> 
> Please don't use 'unlikely'. It's pointless for code that is rarely used.

OK.

> 
> Actually, the code is wrong: i is uninitialized here.
> 
> It should be fps >= ARRAY_SIZE(std_625_50).
> 
> In fact, I'd write it like this:
> 
>   i = std_625_50[(fps >= ARRAY_SIZE(std_625_50) ? 24 : fps];

I really don't like the above, as it has an unexplained magic
number on it. Also, "24" is wrong there.

So, I would go to the following enclosed patch.

Ezequiel,

Btw, I'm not seeing support for fps != 25 (or 30 fps) on this driver.
As the device seems to support setting the fps, you should be adding
support on it for VIDIOC_S_PARM and VIDIOC_G_PARM.

On both ioctls, the driver should return the actual framerate used.
So, you'll need to add a code that would convert from the 15 possible
framerate converter register settings to v4l2_fract.

> 
> > +   i = 14; /* 25 fps */
> > +   else
> > +   i = std_625_50[fps];
> > +   } else {
> > +   if (unlikely(i > ARRAY_SIZE(std_525_60)))
> > +   i = 0;  /* 30 fps */
> > +   else
> > +   i = std_525_60[fps];
> > +   }
> >  
> > return map[i];
> >  }
> >   
> 
> Regards,
> 
>   Hans

Thanks,
Mauro

-

[media] tw686x: Don't go past array

Depending on the compiler version, currently it produces the
following warnings:
tw686x-video.c: In function 'tw686x_video_init':
tw686x-video.c:65:543: warning: array subscript is above array bounds 
[-Warray-bounds]

This is actually bogus with the current code, as it currently
hardcodes the framerate to 30 frames/sec, however a potential
use after the array size could happen when the driver adds support
for setting the framerate. So, fix it.

Signed-off-by: Mauro Carvalho Chehab 

diff --git a/drivers/media/pci/tw686x/tw686x-video.c 
b/drivers/media/pci/tw686x/tw686x-video.c
index 118e9fac9f28..9468fda69f3d 100644
--- a/drivers/media/pci/tw686x/tw686x-video.c
+++ b/drivers/media/pci/tw686x/tw686x-video.c
@@ -61,8 +61,17 @@ static unsigned int tw686x_fields_map(v4l2_std_id std, 
unsigned int fps)
   8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 0, 0
};
 
-   unsigned int i =
-   (std & V4L2_STD_625_50) ? std_625_50[fps] : std_525_60[fps];
+   unsigned int i;
+
+   if (std & V4L2_STD_525_60) {
+   if (fps > ARRAY_SIZE(std_525_60))
+   fps = 30;
+   i = std_525_60[fps];
+   } else {
+   if (fps > ARRAY_SIZE(std_625_50))
+   fps = 25;
+   i = std_625_50[fps];
+   }
 
return map[i];
 }


--
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


[PATCH v8 1/8] dt-bindings: Add a binding for Mediatek Video Processor

2016-04-25 Thread Tiffany Lin
From: Andrew-CT Chen 

Add a DT binding documentation of Video Processor Unit for the
MT8173 SoC from Mediatek.

Signed-off-by: Andrew-CT Chen 
Signed-off-by: Tiffany Lin 
Acked-by: Rob Herring 

---
 .../devicetree/bindings/media/mediatek-vpu.txt |   31 
 1 file changed, 31 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/mediatek-vpu.txt

diff --git a/Documentation/devicetree/bindings/media/mediatek-vpu.txt 
b/Documentation/devicetree/bindings/media/mediatek-vpu.txt
new file mode 100644
index 000..2a5bac3
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/mediatek-vpu.txt
@@ -0,0 +1,31 @@
+* Mediatek Video Processor Unit
+
+Video Processor Unit is a HW video controller. It controls HW Codec including
+H.264/VP8/VP9 Decode, H.264/VP8 Encode and Image Processor (scale/rotate/color 
convert).
+
+Required properties:
+  - compatible: "mediatek,mt8173-vpu"
+  - reg: Must contain an entry for each entry in reg-names.
+  - reg-names: Must include the following entries:
+"tcm": tcm base
+"cfg_reg": Main configuration registers base
+  - interrupts: interrupt number to the cpu.
+  - clocks : clock name from clock manager
+  - clock-names: must be main. It is the main clock of VPU
+
+Optional properties:
+  - memory-region: phandle to a node describing memory (see
+Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt)
+to be used for VPU extended memory; if not present, VPU may be located
+anywhere in the memory
+
+Example:
+   vpu: vpu@1002 {
+   compatible = "mediatek,mt8173-vpu";
+   reg = <0 0x1002 0 0x3>,
+ <0 0x1005 0 0x100>;
+   reg-names = "tcm", "cfg_reg";
+   interrupts = ;
+   clocks = < TOP_SCP_SEL>;
+   clock-names = "main";
+   };
-- 
1.7.9.5

--
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


[PATCH v8 7/8] [media] vcodec: mediatek: Add Mediatek H264 Video Encoder Driver

2016-04-25 Thread Tiffany Lin
Add h264 encoder driver for MT8173

Signed-off-by: PoChun Lin 
Signed-off-by: Tiffany Lin 

---
 drivers/media/platform/mtk-vcodec/Makefile |1 +
 .../media/platform/mtk-vcodec/venc/venc_h264_if.c  |  677 
 drivers/media/platform/mtk-vcodec/venc_drv_if.c|4 +-
 3 files changed, 681 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index bf73a45..dc5cb00 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -12,6 +12,7 @@ mtk-vcodec-enc-y := venc/venc_vp8_if.o \
venc_drv_if.o \
venc_vpu_if.o \
 
+
 mtk-vcodec-common-y := mtk_vcodec_intr.o \
mtk_vcodec_util.o\
 
diff --git a/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c 
b/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
new file mode 100644
index 000..36ebc8f
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
@@ -0,0 +1,677 @@
+/*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Jungchang Tsao 
+ * Daniel Hsiao 
+ * PoChun Lin 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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 "../mtk_vcodec_drv.h"
+#include "../mtk_vcodec_util.h"
+#include "../mtk_vcodec_intr.h"
+#include "../mtk_vcodec_enc.h"
+#include "../mtk_vcodec_enc_pm.h"
+#include "../venc_drv_base.h"
+#include "../venc_ipi_msg.h"
+#include "../venc_vpu_if.h"
+#include "mtk_vpu.h"
+
+static const char h264_filler_marker[] = {0x0, 0x0, 0x0, 0x1, 0xc};
+
+#define H264_FILLER_MARKER_SIZE ARRAY_SIZE(h264_filler_marker)
+#define VENC_PIC_BITSTREAM_BYTE_CNT 0x0098
+
+/**
+ * enum venc_h264_vpu_work_buf - h264 encoder buffer index
+ */
+enum venc_h264_vpu_work_buf {
+   VENC_H264_VPU_WORK_BUF_RC_INFO,
+   VENC_H264_VPU_WORK_BUF_RC_CODE,
+   VENC_H264_VPU_WORK_BUF_REC_LUMA,
+   VENC_H264_VPU_WORK_BUF_REC_CHROMA,
+   VENC_H264_VPU_WORK_BUF_REF_LUMA,
+   VENC_H264_VPU_WORK_BUF_REF_CHROMA,
+   VENC_H264_VPU_WORK_BUF_MV_INFO_1,
+   VENC_H264_VPU_WORK_BUF_MV_INFO_2,
+   VENC_H264_VPU_WORK_BUF_SKIP_FRAME,
+   VENC_H264_VPU_WORK_BUF_MAX,
+};
+
+/**
+ * enum venc_h264_bs_mode - for bs_mode argument in h264_enc_vpu_encode
+ */
+enum venc_h264_bs_mode {
+   H264_BS_MODE_SPS,
+   H264_BS_MODE_PPS,
+   H264_BS_MODE_FRAME,
+};
+
+/*
+ * struct venc_h264_vpu_config - Structure for h264 encoder configuration
+ * @input_fourcc: input fourcc
+ * @bitrate: target bitrate (in bps)
+ * @pic_w: picture width. Picture size is visible stream resolution, in pixels,
+ * to be used for display purposes; must be smaller or equal to buffer
+ * size.
+ * @pic_h: picture height
+ * @buf_w: buffer width. Buffer size is stream resolution in pixels aligned to
+ * hardware requirements.
+ * @buf_h: buffer height
+ * @gop_size: group of picture size (idr frame)
+ * @intra_period: intra frame period
+ * @framerate: frame rate in fps
+ * @profile: as specified in standard
+ * @level: as specified in standard
+ * @wfd: WFD mode 1:on, 0:off
+ */
+struct venc_h264_vpu_config {
+   u32 input_fourcc;
+   u32 bitrate;
+   u32 pic_w;
+   u32 pic_h;
+   u32 buf_w;
+   u32 buf_h;
+   u32 gop_size;
+   u32 intra_period;
+   u32 framerate;
+   u32 profile;
+   u32 level;
+   u32 wfd;
+};
+
+/*
+ * struct venc_h264_vpu_buf - Structure for buffer information
+ * @align: buffer alignment (in bytes)
+ * @iova: IO virtual address
+ * @vpua: VPU side memory addr which is used by RC_CODE
+ * @size: buffer size (in bytes)
+ */
+struct venc_h264_vpu_buf {
+   u32 align;
+   u32 iova;
+   u32 vpua;
+   u32 size;
+};
+
+/*
+ * struct venc_h264_vsi - Structure for VPU driver control and info share
+ * This structure is allocated in VPU side and shared to AP side.
+ * @config: h264 encoder configuration
+ * @work_bufs: working buffer information in VPU side
+ * The work_bufs here is for storing the 'size' info shared to AP side.
+ * The similar item in struct venc_h264_inst is for memory allocation
+ * in AP side. The AP driver will copy the 'size' from here to the one in
+ * struct mtk_vcodec_mem, then invoke mtk_vcodec_mem_alloc to allocate
+ * the buffer. After that, bypass the 'dma_addr' to the 'iova' 

[PATCH v8 5/8] [media] vcodec: mediatek: Add Mediatek V4L2 Video Encoder Driver

2016-04-25 Thread Tiffany Lin
Add v4l2 layer encoder driver for MT8173

Signed-off-by: Tiffany Lin 

---
 drivers/media/platform/Kconfig |   16 +
 drivers/media/platform/Makefile|2 +
 drivers/media/platform/mtk-vcodec/Makefile |   14 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |  339 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 1303 
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.h |   58 +
 .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c |  456 +++
 .../media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c  |  137 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h  |   26 +
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.c|   56 +
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.h|   27 +
 .../media/platform/mtk-vcodec/mtk_vcodec_util.c|   96 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_util.h|   87 ++
 drivers/media/platform/mtk-vcodec/venc_drv_base.h  |   62 +
 drivers/media/platform/mtk-vcodec/venc_drv_if.c|  107 ++
 drivers/media/platform/mtk-vcodec/venc_drv_if.h|  165 +++
 drivers/media/platform/mtk-vcodec/venc_ipi_msg.h   |  210 
 17 files changed, 3161 insertions(+)
 create mode 100644 drivers/media/platform/mtk-vcodec/Makefile
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.h
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.h
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
 create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_base.h
 create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_if.h
 create mode 100644 drivers/media/platform/mtk-vcodec/venc_ipi_msg.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 74c3575..13b765a 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -165,6 +165,22 @@ config VIDEO_MEDIATEK_VPU
To compile this driver as a module, choose M here: the
module will be called mtk-vpu.
 
+config VIDEO_MEDIATEK_VCODEC
+   tristate "Mediatek Video Codec driver"
+   depends on VIDEO_DEV && VIDEO_V4L2
+   depends on ARCH_MEDIATEK || COMPILE_TEST
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   select VIDEO_MEDIATEK_VPU
+   default n
+   ---help---
+   Mediatek video codec driver provides HW capability to
+   encode and decode in a range of video formats
+   This driver rely on VPU driver to communicate with VPU.
+
+   To compile this driver as a module, choose M here: the
+   module will be called mtk-vcodec
+
 config VIDEO_MEM2MEM_DEINTERLACE
tristate "Deinterlace support"
depends on VIDEO_DEV && VIDEO_V4L2 && DMA_ENGINE
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 2efb7b1..6e735fe 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -58,3 +58,5 @@ obj-$(CONFIG_VIDEO_XILINX)+= xilinx/
 ccflags-y += -I$(srctree)/drivers/media/i2c
 
 obj-$(CONFIG_VIDEO_MEDIATEK_VPU)   += mtk-vpu/
+
+obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC)+= mtk-vcodec/
diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
new file mode 100644
index 000..d04433be
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -0,0 +1,14 @@
+
+obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-enc.o mtk-vcodec-common.o
+
+
+
+mtk-vcodec-enc-y := mtk_vcodec_enc.o \
+   mtk_vcodec_enc_drv.o \
+   mtk_vcodec_enc_pm.o \
+   venc_drv_if.o \
+
+mtk-vcodec-common-y := mtk_vcodec_intr.o \
+   mtk_vcodec_util.o\
+
+ccflags-y += -I$(srctree)/drivers/media/platform/mtk-vpu
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
new file mode 100644
index 000..1e09eb75
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -0,0 +1,339 @@
+/*
+* Copyright (c) 2016 MediaTek Inc.
+* Author: PC Chen 
+* Tiffany Lin 
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*
+* This program is distributed in the hope that 

[PATCH v8 0/8] Add MT8173 Video Encoder Driver and VPU Driver

2016-04-25 Thread Tiffany Lin
==
 Introduction
==

The purpose of this series is to add the driver for video codec hw embedded in 
the Mediatek's MT8173 SoCs.
Mediatek Video Codec is able to handle video encoding of in a range of formats.

This patch series also include VPU driver. Mediatek Video Codec driver rely on 
VPU driver to load,
communicate with VPU.

Internally the driver uses videobuf2 framework and MTK IOMMU and MTK SMI both 
have been merged in v4.6-rc1.

==
 Device interface
==

In principle the driver bases on v4l2 memory-to-memory framework:
it provides a single video node and each opened file handle gets its own 
private context with separate
buffer queues. Each context consist of 2 buffer queues: OUTPUT (for source 
buffers, i.e. raw video
frames) and CAPTURE (for destination buffers, i.e. encoded video frames).

==
 VPU (Video Processor Unit)
==
The VPU driver for hw video codec embedded in Mediatek's MT8173 SOCs.
It is able to handle video decoding/encoding in a range of formats.
The driver provides with VPU firmware download, memory management and the 
communication interface between CPU and VPU.
For VPU initialization, it will create virtual memory for CPU access and 
physical address for VPU hw device access. 
When a decode/encode instance opens a device node, vpu driver will download vpu 
firmware to the device.
A decode/encode instant will decode/encode a frame using VPU interface to 
interrupt vpu to handle decoding/encoding jobs.

Please have a look at the code and comments will be very much appreciated.

Change in v8:
1. Refine indentation
2. Refine colorspace information processing in vidioc_try_fmt_vid_out_mplane
3. Remove instance_mask field in mtk_vcodec_dev, use curr_max_idx for instance 
index
4. Use kzalloc to allocate ctx
5. Refine fops_vcodec_open

VPU Part
1. Refine vpu_load_firmware

Change in v7:
1. Rebase against the master branch of git://linuxtv.org/media_tree.git
2. Add ycbcr_enc, quantization and xfer_func in try_fmt, g_fmt, s_fmt
3. Merge h264_enc and vp8_enc to venc directory

Change in v6:
1. Add synchronization access protect between irq handler and work thread
2. Add DMA_ATTR_ALLOC_SINGLE_PAGES support
3. S_FMT will return coded_width, coded_height, so user space could allocate 
correct size memory that HW required
4. merge h264/vp8 enc ap and md32 ipi msg
5. separate h264/vp8 enc gop_size and intra_period handle
6. remove sizeimage relative code in work buffer function
7. Refine makefile to build as an module
8. Code clean up

VPU Part
1. export symbols for building VPU as an module
2. change function from "wait_event_interruptible_timeout" to 
"wait_event_timeout" since
   CPU needs to wait for ACK from VPU even if it was interrupted by a signal

v4l2-compliance test output:
localhost Encode # ./v4l2-compliance -d /dev/video1
Driver Info:
Driver name   : mtk-vcodec-enc
Card type : platform:mt8173
Bus info  : platform:mt8173
Driver version: 4.4.0
Capabilities  : 0x84204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps   : 0x04204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format

Compliance test for device /dev/video1 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls:
test VIDIOC_QUERYCTRL/MENU: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test 

[PATCH v8 2/8] [media] VPU: mediatek: support Mediatek VPU

2016-04-25 Thread Tiffany Lin
From: Andrew-CT Chen 

The VPU driver for hw video codec embedded in Mediatek's MT8173 SOCs.
It is able to handle video decoding/encoding of in a range of formats.
The driver provides with VPU firmware download, memory management and
the communication interface between CPU and VPU.
For VPU initialization, it will create virtual memory for CPU access and
IOMMU address for vcodec hw device access. When a decode/encode instance
opens a device node, vpu driver will download vpu firmware to the device.
A decode/encode instant will decode/encode a frame using VPU
interface to interrupt vpu to handle decoding/encoding jobs.

Signed-off-by: Andrew-CT Chen 
Signed-off-by: Tiffany Lin 

---
 drivers/media/platform/Kconfig   |   13 +
 drivers/media/platform/Makefile  |2 +
 drivers/media/platform/mtk-vpu/Makefile  |3 +
 drivers/media/platform/mtk-vpu/mtk_vpu.c |  949 ++
 drivers/media/platform/mtk-vpu/mtk_vpu.h |  162 +
 5 files changed, 1129 insertions(+)
 create mode 100644 drivers/media/platform/mtk-vpu/Makefile
 create mode 100755 drivers/media/platform/mtk-vpu/mtk_vpu.c
 create mode 100644 drivers/media/platform/mtk-vpu/mtk_vpu.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 84e041c..74c3575 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -152,6 +152,19 @@ config VIDEO_CODA
   Coda is a range of video codec IPs that supports
   H.264, MPEG-4, and other video formats.
 
+config VIDEO_MEDIATEK_VPU
+   tristate "Mediatek Video Processor Unit"
+   depends on VIDEO_DEV && VIDEO_V4L2
+   depends on ARCH_MEDIATEK || COMPILE_TEST
+   ---help---
+   This driver provides downloading VPU firmware and
+   communicating with VPU. This driver for hw video
+   codec embedded in Mediatek's MT8173 SOCs. It is able
+   to handle video decoding/encoding in a range of formats.
+
+   To compile this driver as a module, choose M here: the
+   module will be called mtk-vpu.
+
 config VIDEO_MEM2MEM_DEINTERLACE
tristate "Deinterlace support"
depends on VIDEO_DEV && VIDEO_V4L2 && DMA_ENGINE
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index bbb7bd1..2efb7b1 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -56,3 +56,5 @@ obj-$(CONFIG_VIDEO_AM437X_VPFE)   += am437x/
 obj-$(CONFIG_VIDEO_XILINX) += xilinx/
 
 ccflags-y += -I$(srctree)/drivers/media/i2c
+
+obj-$(CONFIG_VIDEO_MEDIATEK_VPU)   += mtk-vpu/
diff --git a/drivers/media/platform/mtk-vpu/Makefile 
b/drivers/media/platform/mtk-vpu/Makefile
new file mode 100644
index 000..58cc1b4
--- /dev/null
+++ b/drivers/media/platform/mtk-vpu/Makefile
@@ -0,0 +1,3 @@
+mtk-vpu-y += mtk_vpu.o
+
+obj-$(CONFIG_VIDEO_MEDIATEK_VPU) += mtk-vpu.o
diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.c 
b/drivers/media/platform/mtk-vpu/mtk_vpu.c
new file mode 100755
index 000..61bb818
--- /dev/null
+++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
@@ -0,0 +1,949 @@
+/*
+* Copyright (c) 2016 MediaTek Inc.
+* Author: Andrew-CT Chen 
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*
+* 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 "mtk_vpu.h"
+
+/**
+ * VPU (video processor unit) is a tiny processor controlling video hardware
+ * related to video codec, scaling and color format converting.
+ * VPU interfaces with other blocks by share memory and interrupt.
+ **/
+
+#define INIT_TIMEOUT_MS2000U
+#define IPI_TIMEOUT_MS 2000U
+#define VPU_FW_VER_LEN 16
+
+/* maximum program/data TCM (Tightly-Coupled Memory) size */
+#define VPU_PTCM_SIZE  (96 * SZ_1K)
+#define VPU_DTCM_SIZE  (32 * SZ_1K)
+/* the offset to get data tcm address */
+#define VPU_DTCM_OFFSET0x18000UL
+/* daynamic allocated maximum extended memory size */
+#define VPU_EXT_P_SIZE SZ_1M
+#define VPU_EXT_D_SIZE SZ_4M
+/* maximum binary firmware size */
+#define VPU_P_FW_SIZE  (VPU_PTCM_SIZE + VPU_EXT_P_SIZE)
+#define VPU_D_FW_SIZE  (VPU_DTCM_SIZE + VPU_EXT_D_SIZE)
+/* the size of share buffer between Host and  VPU */
+#define SHARE_BUF_SIZE 48
+
+/* binary firmware name */
+#define VPU_P_FW   "vpu_p.bin"
+#define 

[PATCH v8 4/8] dt-bindings: Add a binding for Mediatek Video Encoder

2016-04-25 Thread Tiffany Lin
Add a DT binding documentation of Video Encoder for the
MT8173 SoC from Mediatek.

Signed-off-by: Tiffany Lin 
Acked-by: Rob Herring 

---
 .../devicetree/bindings/media/mediatek-vcodec.txt  |   59 
 1 file changed, 59 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/mediatek-vcodec.txt

diff --git a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt 
b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
new file mode 100644
index 000..59a47a5
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
@@ -0,0 +1,59 @@
+Mediatek Video Codec
+
+Mediatek Video Codec is the video codec hw present in Mediatek SoCs which
+supports high resolution encoding functionalities.
+
+Required properties:
+- compatible : "mediatek,mt8173-vcodec-enc" for encoder
+- reg : Physical base address of the video codec registers and length of
+  memory mapped region.
+- interrupts : interrupt number to the cpu.
+- mediatek,larb : must contain the local arbiters in the current Socs.
+- clocks : list of clock specifiers, corresponding to entries in
+  the clock-names property.
+- clock-names: encoder must contain "venc_sel_src", "venc_sel",
+- "venc_lt_sel_src", "venc_lt_sel".
+- iommus : should point to the respective IOMMU block with master port as
+  argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
+  for details.
+- mediatek,vpu : the node of video processor unit
+
+Example:
+vcodec_enc: vcodec@0x18002000 {
+compatible = "mediatek,mt8173-vcodec-enc";
+reg = <0 0x18002000 0 0x1000>,/*VENC_SYS*/
+  <0 0x19002000 0 0x1000>;/*VENC_LT_SYS*/
+interrupts = ,
+;
+mediatek,larb = <>,
+   <>;
+iommus = < M4U_PORT_VENC_RCPU>,
+ < M4U_PORT_VENC_REC>,
+ < M4U_PORT_VENC_BSDMA>,
+ < M4U_PORT_VENC_SV_COMV>,
+ < M4U_PORT_VENC_RD_COMV>,
+ < M4U_PORT_VENC_CUR_LUMA>,
+ < M4U_PORT_VENC_CUR_CHROMA>,
+ < M4U_PORT_VENC_REF_LUMA>,
+ < M4U_PORT_VENC_REF_CHROMA>,
+ < M4U_PORT_VENC_NBM_RDMA>,
+ < M4U_PORT_VENC_NBM_WDMA>,
+ < M4U_PORT_VENC_RCPU_SET2>,
+ < M4U_PORT_VENC_REC_FRM_SET2>,
+ < M4U_PORT_VENC_BSDMA_SET2>,
+ < M4U_PORT_VENC_SV_COMA_SET2>,
+ < M4U_PORT_VENC_RD_COMA_SET2>,
+ < M4U_PORT_VENC_CUR_LUMA_SET2>,
+ < M4U_PORT_VENC_CUR_CHROMA_SET2>,
+ < M4U_PORT_VENC_REF_LUMA_SET2>,
+ < M4U_PORT_VENC_REC_CHROMA_SET2>;
+mediatek,vpu = <>;
+clocks = < CLK_TOP_VENCPLL_D2>,
+ < CLK_TOP_VENC_SEL>,
+ < CLK_TOP_UNIVPLL1_D2>,
+ < CLK_TOP_VENC_LT_SEL>;
+clock-names = "venc_sel_src",
+  "venc_sel",
+  "venc_lt_sel_src",
+  "venc_lt_sel";
+  };
-- 
1.7.9.5

--
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


[PATCH v8 3/8] arm64: dts: mediatek: Add node for Mediatek Video Processor Unit

2016-04-25 Thread Tiffany Lin
From: Andrew-CT Chen 

Add VPU drivers for MT8173

Signed-off-by: Andrew-CT Chen 
Signed-off-by: Tiffany Lin 

---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   23 +++
 1 file changed, 23 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index eab7efc..ae147bb 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -125,6 +125,18 @@
clock-output-names = "cpum_ck";
};
 
+   reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   vpu_dma_reserved: vpu_dma_mem_region {
+   compatible = "shared-dma-pool";
+   reg = <0 0xb700 0 0x50>;
+   alignment = <0x1000>;
+   no-map;
+   };
+   };
+
timer {
compatible = "arm,armv8-timer";
interrupt-parent = <>;
@@ -269,6 +281,17 @@
clock-names = "spi", "wrap";
};
 
+   vpu: vpu@1002 {
+   compatible = "mediatek,mt8173-vpu";
+   reg = <0 0x1002 0 0x3>,
+ <0 0x1005 0 0x100>;
+   reg-names = "tcm", "cfg_reg";
+   interrupts = ;
+   clocks = < CLK_TOP_SCP_SEL>;
+   clock-names = "main";
+   memory-region = <_dma_reserved>;
+   };
+
sysirq: intpol-controller@10200620 {
compatible = "mediatek,mt8173-sysirq",
 "mediatek,mt6577-sysirq";
-- 
1.7.9.5

--
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


[PATCH v8 6/8] [media] vcodec: mediatek: Add Mediatek VP8 Video Encoder Driver

2016-04-25 Thread Tiffany Lin
Add vp8 encoder driver for MT8173

Signed-off-by: PoChun Lin 
Signed-off-by: Tiffany Lin 

---
 drivers/media/platform/mtk-vcodec/Makefile |6 +-
 .../media/platform/mtk-vcodec/venc/venc_vp8_if.c   |  479 
 drivers/media/platform/mtk-vcodec/venc_drv_if.c|7 +-
 drivers/media/platform/mtk-vcodec/venc_vpu_if.c|  237 ++
 drivers/media/platform/mtk-vcodec/venc_vpu_if.h|   61 +++
 5 files changed, 788 insertions(+), 2 deletions(-)
 create mode 100644 drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/venc_vpu_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/venc_vpu_if.h

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index d04433be..bf73a45 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -1,12 +1,16 @@
 
+
 obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-enc.o mtk-vcodec-common.o
 
 
 
-mtk-vcodec-enc-y := mtk_vcodec_enc.o \
+mtk-vcodec-enc-y := venc/venc_vp8_if.o \
+   venc/venc_h264_if.o \
+   mtk_vcodec_enc.o \
mtk_vcodec_enc_drv.o \
mtk_vcodec_enc_pm.o \
venc_drv_if.o \
+   venc_vpu_if.o \
 
 mtk-vcodec-common-y := mtk_vcodec_intr.o \
mtk_vcodec_util.o\
diff --git a/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c 
b/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
new file mode 100644
index 000..ac6d4ac
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
@@ -0,0 +1,479 @@
+/*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Daniel Hsiao 
+ * PoChun Lin 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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 "../mtk_vcodec_drv.h"
+#include "../mtk_vcodec_util.h"
+#include "../mtk_vcodec_intr.h"
+#include "../mtk_vcodec_enc.h"
+#include "../mtk_vcodec_enc_pm.h"
+#include "../venc_drv_base.h"
+#include "../venc_ipi_msg.h"
+#include "../venc_vpu_if.h"
+#include "mtk_vpu.h"
+
+#define VENC_BITSTREAM_FRAME_SIZE 0x0098
+#define VENC_BITSTREAM_HEADER_LEN 0x00e8
+
+/* This ac_tag is vp8 frame tag. */
+#define MAX_AC_TAG_SIZE 10
+
+/**
+ * enum venc_vp8_vpu_work_buf - vp8 encoder buffer index
+ */
+enum venc_vp8_vpu_work_buf {
+   VENC_VP8_VPU_WORK_BUF_LUMA,
+   VENC_VP8_VPU_WORK_BUF_LUMA2,
+   VENC_VP8_VPU_WORK_BUF_LUMA3,
+   VENC_VP8_VPU_WORK_BUF_CHROMA,
+   VENC_VP8_VPU_WORK_BUF_CHROMA2,
+   VENC_VP8_VPU_WORK_BUF_CHROMA3,
+   VENC_VP8_VPU_WORK_BUF_MV_INFO,
+   VENC_VP8_VPU_WORK_BUF_BS_HEADER,
+   VENC_VP8_VPU_WORK_BUF_PROB_BUF,
+   VENC_VP8_VPU_WORK_BUF_RC_INFO,
+   VENC_VP8_VPU_WORK_BUF_RC_CODE,
+   VENC_VP8_VPU_WORK_BUF_RC_CODE2,
+   VENC_VP8_VPU_WORK_BUF_RC_CODE3,
+   VENC_VP8_VPU_WORK_BUF_MAX,
+};
+
+/*
+ * struct venc_vp8_vpu_config - Structure for vp8 encoder configuration
+ * @input_fourcc: input fourcc
+ * @bitrate: target bitrate (in bps)
+ * @pic_w: picture width. Picture size is visible stream resolution, in pixels,
+ * to be used for display purposes; must be smaller or equal to buffer
+ * size.
+ * @pic_h: picture height
+ * @buf_w: buffer width (with 16 alignment). Buffer size is stream resolution
+ * in pixels aligned to hardware requirements.
+ * @buf_h: buffer height (with 16 alignment)
+ * @gop_size: group of picture size (key frame)
+ * @framerate: frame rate in fps
+ * @ts_mode: temporal scalability mode (0: disable, 1: enable)
+ *  support three temporal layers - 0: 7.5fps 1: 7.5fps 2: 15fps.
+ */
+struct venc_vp8_vpu_config {
+   u32 input_fourcc;
+   u32 bitrate;
+   u32 pic_w;
+   u32 pic_h;
+   u32 buf_w;
+   u32 buf_h;
+   u32 gop_size;
+   u32 framerate;
+   u32 ts_mode;
+};
+
+/*
+ * struct venc_vp8_vpu_buf -Structure for buffer information
+ * @align: buffer alignment (in bytes)
+ * @iova: IO virtual address
+ * @vpua: VPU side memory addr which is used by RC_CODE
+ * @size: buffer size (in bytes)
+ */
+struct venc_vp8_vpu_buf {
+   u32 align;
+   u32 iova;
+   u32 vpua;
+   u32 size;
+};
+
+/*
+ * struct venc_vp8_vsi - Structure for VPU driver control and info share
+ * This structure is allocated in VPU side and shared to AP side.
+ * @config: vp8 encoder configuration
+ * @work_bufs: working buffer information in VPU side
+ * The 

[PATCH v8 8/8] arm64: dts: mediatek: Add Video Encoder for MT8173

2016-04-25 Thread Tiffany Lin
Add video encoder node for MT8173

Signed-off-by: Tiffany Lin 

---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   39 ++
 1 file changed, 39 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index ae147bb..348ce0e 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -717,6 +717,45 @@
clock-names = "apb", "smi";
};
 
+   vcodec_enc: vcodec@18002000 {
+   compatible = "mediatek,mt8173-vcodec-enc";
+   reg = <0 0x18002000 0 0x1000>,  /* VENC_SYS */
+ <0 0x19002000 0 0x1000>;  /* VENC_LT_SYS */
+   interrupts = ,
+;
+   mediatek,larb = <>,
+   <>;
+   iommus = < M4U_PORT_VENC_RCPU>,
+< M4U_PORT_VENC_REC>,
+< M4U_PORT_VENC_BSDMA>,
+< M4U_PORT_VENC_SV_COMV>,
+< M4U_PORT_VENC_RD_COMV>,
+< M4U_PORT_VENC_CUR_LUMA>,
+< M4U_PORT_VENC_CUR_CHROMA>,
+< M4U_PORT_VENC_REF_LUMA>,
+< M4U_PORT_VENC_REF_CHROMA>,
+< M4U_PORT_VENC_NBM_RDMA>,
+< M4U_PORT_VENC_NBM_WDMA>,
+< M4U_PORT_VENC_RCPU_SET2>,
+< M4U_PORT_VENC_REC_FRM_SET2>,
+< M4U_PORT_VENC_BSDMA_SET2>,
+< M4U_PORT_VENC_SV_COMA_SET2>,
+< M4U_PORT_VENC_RD_COMA_SET2>,
+< M4U_PORT_VENC_CUR_LUMA_SET2>,
+< M4U_PORT_VENC_CUR_CHROMA_SET2>,
+< M4U_PORT_VENC_REF_LUMA_SET2>,
+< M4U_PORT_VENC_REC_CHROMA_SET2>;
+   mediatek,vpu = <>;
+   clocks = < CLK_TOP_VENCPLL_D2>,
+< CLK_TOP_VENC_SEL>,
+< CLK_TOP_UNIVPLL1_D2>,
+< CLK_TOP_VENC_LT_SEL>;
+   clock-names = "venc_sel_src",
+ "venc_sel",
+ "venc_lt_sel_src",
+ "venc_lt_sel";
+   };
+
vencltsys: clock-controller@1900 {
compatible = "mediatek,mt8173-vencltsys", "syscon";
reg = <0 0x1900 0 0x1000>;
-- 
1.7.9.5

--
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


[PATCHv15 13/15] vivid: add CEC emulation

2016-04-25 Thread Hans Verkuil
From: Hans Verkuil 

The vivid driver has been extended to provide CEC adapters for the HDMI
input and HDMI outputs in order to test CEC applications.

This CEC emulation is faithful to the CEC timings (i.e., it all at a
snail's pace).

Signed-off-by: Hans Verkuil 
---
 Documentation/video4linux/vivid.txt  |  36 +++-
 drivers/media/platform/vivid/Kconfig |   9 +
 drivers/media/platform/vivid/Makefile|   4 +
 drivers/media/platform/vivid/vivid-cec.c | 254 +++
 drivers/media/platform/vivid/vivid-cec.h |  33 +++
 drivers/media/platform/vivid/vivid-core.c| 119 ++-
 drivers/media/platform/vivid/vivid-core.h|  27 +++
 drivers/media/platform/vivid/vivid-kthread-cap.c |  11 +
 drivers/media/platform/vivid/vivid-vid-cap.c |  23 +-
 drivers/media/platform/vivid/vivid-vid-common.c  |   7 +
 10 files changed, 508 insertions(+), 15 deletions(-)
 create mode 100644 drivers/media/platform/vivid/vivid-cec.c
 create mode 100644 drivers/media/platform/vivid/vivid-cec.h

diff --git a/Documentation/video4linux/vivid.txt 
b/Documentation/video4linux/vivid.txt
index e35d376..0d89715 100644
--- a/Documentation/video4linux/vivid.txt
+++ b/Documentation/video4linux/vivid.txt
@@ -74,7 +74,8 @@ Section 11: Cropping, Composing, Scaling
 Section 12: Formats
 Section 13: Capture Overlay
 Section 14: Output Overlay
-Section 15: Some Future Improvements
+Section 15: CEC (Consumer Electronics Control)
+Section 16: Some Future Improvements
 
 
 Section 1: Configuring the driver
@@ -364,7 +365,11 @@ For HDMI inputs it is possible to set the EDID. By default 
a simple EDID
 is provided. You can only set the EDID for HDMI inputs. Internally, however,
 the EDID is shared between all HDMI inputs.
 
-No interpretation is done of the EDID data.
+No interpretation is done of the EDID data with the exception of the
+physical address. See the CEC section for more details.
+
+There is a maximum of 15 HDMI inputs (if there are more, then they will be
+reduced to 15) since that's the limitation of the EDID physical address.
 
 
 Section 3: Video Output
@@ -409,6 +414,9 @@ standard, and for all others a 1:1 pixel aspect ratio is 
returned.
 
 An HDMI output has a valid EDID which can be obtained through VIDIOC_G_EDID.
 
+There is a maximum of 15 HDMI outputs (if there are more, then they will be
+reduced to 15) since that's the limitation of the EDID physical address. See
+also the CEC section for more details.
 
 Section 4: VBI Capture
 --
@@ -1108,7 +1116,26 @@ capabilities will slow down the video loop considerably 
as a lot of checks have
 to be done per pixel.
 
 
-Section 15: Some Future Improvements
+Section 15: CEC (Consumer Electronics Control)
+--
+
+If there are HDMI inputs then a CEC adapter will be created that has
+the same number of input ports. This is the equivalent of e.g. a TV that
+has that number of inputs. Each HDMI output will also create a
+CEC adapter that is hooked up to the corresponding input port, or (if there
+are more outputs than inputs) is not hooked up at all. In other words,
+this is the equivalent of hooking up each output device to an input port of
+the TV. Any remaining output devices remain unconnected.
+
+The EDID that each output reads reports a unique CEC physical address that is
+based on the physical address of the EDID of the input. So if the EDID of the
+receiver has physical address A.B.0.0, then each output will see an EDID
+containing physical address A.B.C.0 where C is 1 to the number of inputs. If
+there are more outputs than inputs then the remaining outputs have a CEC 
adapter
+that is disabled and reports an invalid physical address.
+
+
+Section 16: Some Future Improvements
 
 
 Just as a reminder and in no particular order:
@@ -1121,8 +1148,6 @@ Just as a reminder and in no particular order:
 - Fix sequence/field numbering when looping of video with alternate fields
 - Add support for V4L2_CID_BG_COLOR for video outputs
 - Add ARGB888 overlay support: better testing of the alpha channel
-- Add custom DV timings support
-- Add support for V4L2_DV_FL_REDUCED_FPS
 - Improve pixel aspect support in the tpg code by passing a real v4l2_fract
 - Use per-queue locks and/or per-device locks to improve throughput
 - Add support to loop from a specific output to a specific input across
@@ -1133,3 +1158,4 @@ Just as a reminder and in no particular order:
 - Make a thread for the RDS generation, that would help in particular for the
   "Controls" RDS Rx I/O Mode as the read-only RDS controls could be updated
   in real-time.
+- Changing the EDID should cause hotplug detect emulation to happen.
diff --git a/drivers/media/platform/vivid/Kconfig 
b/drivers/media/platform/vivid/Kconfig
index f535f57..20c5eea 100644
--- a/drivers/media/platform/vivid/Kconfig
+++ 

[PATCHv15 14/15] pulse8-cec: add new driver

2016-04-25 Thread Hans Verkuil
From: Hans Verkuil 

Alpha quality only at the moment.

Signed-off-by: Hans Verkuil 
---
 MAINTAINERS   |   7 +
 drivers/media/usb/Kconfig |   5 +
 drivers/media/usb/Makefile|   1 +
 drivers/media/usb/pulse8/Kconfig  |  10 +
 drivers/media/usb/pulse8/Makefile |   1 +
 drivers/media/usb/pulse8/pulse8-cec.c | 412 ++
 include/uapi/linux/serio.h|   1 +
 7 files changed, 437 insertions(+)
 create mode 100644 drivers/media/usb/pulse8/Kconfig
 create mode 100644 drivers/media/usb/pulse8/Makefile
 create mode 100644 drivers/media/usb/pulse8/pulse8-cec.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 0e43b30..734d177 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8962,6 +8962,13 @@ F:   include/linux/tracehook.h
 F: include/uapi/linux/ptrace.h
 F: kernel/ptrace.c
 
+PULSE8-CEC DRIVER
+M: Hans Verkuil 
+L: linux-media@vger.kernel.org
+T: git git://linuxtv.org/media_tree.git
+S: Maintained
+F: drivers/media/usb/pulse8
+
 PVRUSB2 VIDEO4LINUX DRIVER
 M: Mike Isely 
 L: pvru...@isely.net   (subscribers-only)
diff --git a/drivers/media/usb/Kconfig b/drivers/media/usb/Kconfig
index 7496f33..9301961 100644
--- a/drivers/media/usb/Kconfig
+++ b/drivers/media/usb/Kconfig
@@ -60,5 +60,10 @@ source "drivers/media/usb/hackrf/Kconfig"
 source "drivers/media/usb/msi2500/Kconfig"
 endif
 
+if MEDIA_CEC
+   comment "HDMI CEC USB devices"
+source "drivers/media/usb/pulse8/Kconfig"
+endif
+
 endif #MEDIA_USB_SUPPORT
 endif #USB
diff --git a/drivers/media/usb/Makefile b/drivers/media/usb/Makefile
index 8874ba7..468e541 100644
--- a/drivers/media/usb/Makefile
+++ b/drivers/media/usb/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_USB_PWC)   += pwc/
 obj-$(CONFIG_USB_AIRSPY)+= airspy/
 obj-$(CONFIG_USB_HACKRF)+= hackrf/
 obj-$(CONFIG_USB_MSI2500)   += msi2500/
+obj-$(CONFIG_USB_PULSE8_CEC)+= pulse8/
 obj-$(CONFIG_VIDEO_CPIA2) += cpia2/
 obj-$(CONFIG_VIDEO_AU0828) += au0828/
 obj-$(CONFIG_VIDEO_HDPVR)  += hdpvr/
diff --git a/drivers/media/usb/pulse8/Kconfig b/drivers/media/usb/pulse8/Kconfig
new file mode 100644
index 000..c6aa2d1
--- /dev/null
+++ b/drivers/media/usb/pulse8/Kconfig
@@ -0,0 +1,10 @@
+config USB_PULSE8_CEC
+   tristate "Pulse Eight HDMI CEC"
+   depends on USB_ACM && MEDIA_CEC
+   select SERIO
+   select SERIO_SERPORT
+   ---help---
+ This is a cec driver for the Pulse Eight HDMI CEC device.
+
+ To compile this driver as a module, choose M here: the
+ module will be called pulse8-cec.
diff --git a/drivers/media/usb/pulse8/Makefile 
b/drivers/media/usb/pulse8/Makefile
new file mode 100644
index 000..dd52d42
--- /dev/null
+++ b/drivers/media/usb/pulse8/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_USB_PULSE8_CEC)  += pulse8-cec.o
diff --git a/drivers/media/usb/pulse8/pulse8-cec.c 
b/drivers/media/usb/pulse8/pulse8-cec.c
new file mode 100644
index 000..d02e5df
--- /dev/null
+++ b/drivers/media/usb/pulse8/pulse8-cec.c
@@ -0,0 +1,412 @@
+/*
+ * Pulse Eight HDMI CEC driver
+ *
+ * Copyright 2016 Hans Verkuil ");
+MODULE_DESCRIPTION("Pulse Eight HDMI CEC driver");
+MODULE_LICENSE("GPL");
+
+enum pulse8_msgcodes
+{
+   MSGCODE_NOTHING = 0,
+   MSGCODE_PING,
+   MSGCODE_TIMEOUT_ERROR,
+   MSGCODE_HIGH_ERROR,
+   MSGCODE_LOW_ERROR,
+   MSGCODE_FRAME_START,
+   MSGCODE_FRAME_DATA,
+   MSGCODE_RECEIVE_FAILED,
+   MSGCODE_COMMAND_ACCEPTED,   /* 0x08 */
+   MSGCODE_COMMAND_REJECTED,
+   MSGCODE_SET_ACK_MASK,
+   MSGCODE_TRANSMIT,
+   MSGCODE_TRANSMIT_EOM,
+   MSGCODE_TRANSMIT_IDLETIME,
+   MSGCODE_TRANSMIT_ACK_POLARITY,
+   MSGCODE_TRANSMIT_LINE_TIMEOUT,
+   MSGCODE_TRANSMIT_SUCCEEDED, /* 0x10 */
+   MSGCODE_TRANSMIT_FAILED_LINE,
+   MSGCODE_TRANSMIT_FAILED_ACK,
+   MSGCODE_TRANSMIT_FAILED_TIMEOUT_DATA,
+   MSGCODE_TRANSMIT_FAILED_TIMEOUT_LINE,
+   MSGCODE_FIRMWARE_VERSION,
+   MSGCODE_START_BOOTLOADER,
+   MSGCODE_GET_BUILDDATE,
+   MSGCODE_SET_CONTROLLED, /* 0x18 */
+   MSGCODE_GET_AUTO_ENABLED,
+   MSGCODE_SET_AUTO_ENABLED,
+   MSGCODE_GET_DEFAULT_LOGICAL_ADDRESS,
+   MSGCODE_SET_DEFAULT_LOGICAL_ADDRESS,
+   MSGCODE_GET_LOGICAL_ADDRESS_MASK,
+   

[PATCHv15 15/15] cec: add ARC and CDC support

2016-04-25 Thread Hans Verkuil
From: Hans Verkuil 

Preliminary ARC and CDC support. Untested and experimental!

Signed-off-by: Hans Verkuil 
---
 .../DocBook/media/v4l/cec-ioc-adap-g-caps.xml  |  10 ++
 Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml |  36 
 Documentation/cec.txt  |  75 
 drivers/staging/media/cec/cec.c| 198 -
 include/linux/cec.h|   5 +
 include/media/cec.h|  12 ++
 6 files changed, 334 insertions(+), 2 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/cec-ioc-adap-g-caps.xml 
b/Documentation/DocBook/media/v4l/cec-ioc-adap-g-caps.xml
index b99ed22..65250b7 100644
--- a/Documentation/DocBook/media/v4l/cec-ioc-adap-g-caps.xml
+++ b/Documentation/DocBook/media/v4l/cec-ioc-adap-g-caps.xml
@@ -129,6 +129,16 @@
The CEC hardware can monitor all messages, not just directed 
and
broadcast messages.
  
+ 
+   CEC_CAP_ARC
+   0x0040
+   This adapter supports the Audio Return Channel 
protocol.
+ 
+ 
+   CEC_CAP_CDC_HPD
+   0x0080
+   This adapter supports the hotplug detect protocol over 
CDC.
+ 

   
 
diff --git a/Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml 
b/Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml
index 0cb1941..485e8b2 100644
--- a/Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml
+++ b/Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml
@@ -187,6 +187,42 @@ The follower can of course always call 
.


  
+   CEC_MSG_INITIATE_ARC
+   
+ 
+ 
+   CEC_MSG_TERMINATE_ARC
+   
+ 
+ 
+   CEC_MSG_REQUEST_ARC_INITIATION
+   
+ 
+ 
+   CEC_MSG_REQUEST_ARC_TERMINATION
+   
+ 
+ 
+   CEC_MSG_REPORT_ARC_INITIATED
+   
+ 
+ 
+   CEC_MSG_REPORT_ARC_TERMINATED
+   If CEC_CAP_ARC is not set, then just 
pass
+   it on to userspace for processing. However, if 
CEC_CAP_ARC is
+   set, then the core framework processes this message and userspace 
will
+   not see it, not even in passthrough mode.
+ 
+ 
+   CEC_MSG_CDC_MESSAGE
+   If CEC_CAP_CDC_HPD is not set, then 
just pass
+   it on to userspace for processing. Do the same if the CDC command 
is not
+   one of CEC_MSG_CDC_HPD_REPORT_STATE or
+   CEC_MSG_CDC_HPD_SET_STATE. Else the core 
framework
+   processes this message and userspace will not see it, not even in 
passthrough
+   mode.
+ 
+ 
CEC_MSG_GET_CEC_VERSION
When in passthrough mode this message has to be handled by 
userspace,
otherwise the core will return the CEC version that was set with 
.
diff --git a/Documentation/cec.txt b/Documentation/cec.txt
index 75155fe..8a61819 100644
--- a/Documentation/cec.txt
+++ b/Documentation/cec.txt
@@ -216,6 +216,16 @@ struct cec_adap_ops {
 
/* High-level CEC message callback */
int (*received)(struct cec_adapter *adap, struct cec_msg *msg);
+
+   /* High-level CDC Hotplug Detect callbacks */
+   u8 (*source_cdc_hpd)(struct cec_adapter *adap, u8 cdc_hpd_state);
+   void (*sink_cdc_hpd)(struct cec_adapter *adap, u8 cdc_hpd_state, u8 
cdc_hpd_error);
+
+   /* High-level Audio Return Channel callbacks */
+   int (*sink_initiate_arc)(struct cec_adapter *adap);
+   int (*sink_terminate_arc)(struct cec_adapter *adap);
+   int (*source_arc_initiated)(struct cec_adapter *adap);
+   int (*source_arc_terminated)(struct cec_adapter *adap);
 };
 
 The received() callback allows the driver to optionally handle a newly
@@ -228,6 +238,62 @@ callback. If it doesn't want to handle this message, then 
it should return
 -ENOMSG, otherwise the CEC framework assumes it processed this message and
 it will not no anything with it.
 
+The other callbacks deal with two CEC features: CDC Hotplug Detect and
+Audio Return Channel. Here the framework takes care of handling these
+messages and it calls the callbacks to notify the driver when it needs
+to take action.
+
+CDC Hotplug Support
+---
+
+A source received a hotplug state change message:
+
+   u8 (*source_cdc_hpd)(struct cec_adapter *adap, u8 cdc_hpd_state);
+
+A source received a CEC_MSG_CDC_HPD_SET_STATE message. The framework will
+reply with a CEC_MSG_CDC_HPD_REPORT_STATE message and this callback is used
+to fill in the HPD Error Code Operand of the REPORT_STATE message. In addition,
+the driver can act in this callback on the hotplug state change.
+
+Only implement if CEC_CAP_CDC_HPD is set.
+
+A sink received a hotplug report state message:
+
+   void (*sink_cdc_hpd)(struct cec_adapter 

[PATCHv15 06/15] cec: add compat32 ioctl support

2016-04-25 Thread Hans Verkuil
From: Hans Verkuil 

The CEC ioctls didn't have compat32 support, so they returned -ENOTTY
when used in a 32 bit application on a 64 bit kernel.

Since all the CEC ioctls are 32-bit compatible adding support for this
API is trivial.

Signed-off-by: Hans Verkuil 
---
 fs/compat_ioctl.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index bd01b92..c1e9f29 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -57,6 +57,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "internal.h"
 
@@ -1377,6 +1378,17 @@ COMPATIBLE_IOCTL(VIDEO_GET_NAVI)
 COMPATIBLE_IOCTL(VIDEO_SET_ATTRIBUTES)
 COMPATIBLE_IOCTL(VIDEO_GET_SIZE)
 COMPATIBLE_IOCTL(VIDEO_GET_FRAME_RATE)
+/* cec */
+COMPATIBLE_IOCTL(CEC_ADAP_G_CAPS)
+COMPATIBLE_IOCTL(CEC_ADAP_G_LOG_ADDRS)
+COMPATIBLE_IOCTL(CEC_ADAP_S_LOG_ADDRS)
+COMPATIBLE_IOCTL(CEC_ADAP_G_PHYS_ADDR)
+COMPATIBLE_IOCTL(CEC_ADAP_S_PHYS_ADDR)
+COMPATIBLE_IOCTL(CEC_G_MODE)
+COMPATIBLE_IOCTL(CEC_S_MODE)
+COMPATIBLE_IOCTL(CEC_TRANSMIT)
+COMPATIBLE_IOCTL(CEC_RECEIVE)
+COMPATIBLE_IOCTL(CEC_DQEVENT)
 
 /* joystick */
 COMPATIBLE_IOCTL(JSIOCGVERSION)
-- 
2.8.1

--
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


[PATCHv15 07/15] cec.txt: add CEC framework documentation

2016-04-25 Thread Hans Verkuil
From: Hans Verkuil 

Document the new HDMI CEC framework.

Signed-off-by: Hans Verkuil 
[k.deb...@samsung.com: add DocBook documentation by Hans Verkuil, with
Signed-off-by: Kamil Debski 
Signed-off-by: Hans Verkuil 
---
 Documentation/cec.txt | 267 ++
 1 file changed, 267 insertions(+)
 create mode 100644 Documentation/cec.txt

diff --git a/Documentation/cec.txt b/Documentation/cec.txt
new file mode 100644
index 000..75155fe
--- /dev/null
+++ b/Documentation/cec.txt
@@ -0,0 +1,267 @@
+CEC Kernel Support
+==
+
+The CEC framework provides a unified kernel interface for use with HDMI CEC
+hardware. It is designed to handle a multiple types of hardware (receivers,
+transmitters, USB dongles). The framework also gives the option to decide
+what to do in the kernel driver and what should be handled by userspace
+applications. In addition it integrates the remote control passthrough
+feature into the kernel's remote control framework.
+
+
+The CEC Protocol
+
+
+The CEC protocol enables consumer electronic devices to communicate with each
+other through the HDMI connection. The protocol uses logical addresses in the
+communication. The logical address is strictly connected with the functionality
+provided by the device. The TV acting as the communication hub is always
+assigned address 0. The physical address is determined by the physical
+connection between devices.
+
+The CEC framework described here is up to date with the CEC 2.0 specification.
+It is documented in the HDMI 1.4 specification with the new 2.0 bits documented
+in the HDMI 2.0 specification. But for most of the features the freely 
available
+HDMI 1.3a specification is sufficient:
+
+http://www.microprocessor.org/HDMISpecification13a.pdf
+
+
+The Kernel Interface
+
+
+CEC Adapter
+---
+
+The struct cec_adapter represents the CEC adapter hardware. It is created by
+calling cec_allocate_adapter() and deleted by calling cec_delete_adapter():
+
+struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
+  void *priv, const char *name, u32 caps, u8 available_las,
+  struct device *parent);
+void cec_delete_adapter(struct cec_adapter *adap);
+
+To create an adapter you need to pass the following information:
+
+ops: adapter operations which are called by the CEC framework and that you
+have to implement.
+
+priv: will be stored in adap->priv and can be used by the adapter ops.
+
+name: the name of the CEC adapter. Note: this name will be copied.
+
+caps: capabilities of the CEC adapter. These capabilities determine the
+   capabilities of the hardware and which parts are to be handled
+   by userspace and which parts are handled by kernelspace. The
+   capabilities are returned by CEC_ADAP_G_CAPS.
+
+available_las: the number of simultaneous logical addresses that this
+   adapter can handle. Must be 1 <= available_las <= CEC_MAX_LOG_ADDRS.
+
+parent: the parent device.
+
+
+To register the /dev/cecX device node and the remote control device (if
+CEC_CAP_RC is set) you call:
+
+int cec_register_adapter(struct cec_adapter *adap);
+
+To unregister the devices call:
+
+void cec_unregister_adapter(struct cec_adapter *adap);
+
+Note: if cec_register_adapter() fails, then call cec_delete_adapter() to
+clean up. But if cec_register_adapter() succeeded, then only call
+cec_unregister_adapter() to clean up, never cec_delete_adapter(). The
+unregister function will delete the adapter automatically once the last user
+of that /dev/cecX device has closed its file handle.
+
+
+Implementing the Low-Level CEC Adapter
+--
+
+The following low-level adapter operations have to be implemented in
+your driver:
+
+struct cec_adap_ops {
+   /* Low-level callbacks */
+   int (*adap_enable)(struct cec_adapter *adap, bool enable);
+   int (*adap_monitor_all_enable)(struct cec_adapter *adap, bool enable);
+   int (*adap_log_addr)(struct cec_adapter *adap, u8 logical_addr);
+   int (*adap_transmit)(struct cec_adapter *adap, u8 attempts,
+u32 signal_free_time, struct cec_msg *msg);
+   void (*adap_log_status)(struct cec_adapter *adap);
+
+   /* High-level callbacks */
+   ...
+};
+
+The three low-level ops deal with various aspects of controlling the CEC 
adapter
+hardware:
+
+
+To enable/disable the hardware:
+
+   int (*adap_enable)(struct cec_adapter *adap, bool enable);
+
+This callback enables or disables the CEC hardware. Enabling the CEC hardware
+means powering it up in a state where no logical addresses are claimed. This
+op assumes that the physical address (adap->phys_addr) is valid when enable is
+true and will not change while the CEC adapter remains enabled. The initial
+state of the CEC adapter after calling 

[PATCHv15 09/15] cec: adv7604: add cec support.

2016-04-25 Thread Hans Verkuil
From: Hans Verkuil 

Add CEC support to the adv7604 driver.

Signed-off-by: Hans Verkuil 
[k.deb...@samsung.com: Merged changes from CEC Updates commit by Hans Verkuil]
[k.deb...@samsung.com: add missing methods cec/io_write_and_or]
[k.deb...@samsung.com: change adv7604 to adv76xx in added functions]
[hansv...@cisco.com: use _clr_set instead of _and_or]
---
 drivers/media/i2c/Kconfig   |   9 ++
 drivers/media/i2c/adv7604.c | 332 +++-
 2 files changed, 305 insertions(+), 36 deletions(-)

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 993dc50..cba1fc7 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -209,6 +209,7 @@ config VIDEO_ADV7604
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
depends on GPIOLIB || COMPILE_TEST
select HDMI
+   select MEDIA_CEC_EDID
---help---
  Support for the Analog Devices ADV7604 video decoder.
 
@@ -218,6 +219,14 @@ config VIDEO_ADV7604
  To compile this driver as a module, choose M here: the
  module will be called adv7604.
 
+config VIDEO_ADV7604_CEC
+   bool "Enable Analog Devices ADV7604 CEC support"
+   depends on VIDEO_ADV7604 && MEDIA_CEC
+   default y
+   ---help---
+ When selected the adv7604 will support the optional
+ HDMI CEC feature.
+
 config VIDEO_ADV7842
tristate "Analog Devices ADV7842 decoder"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 41a1bfc..d99f30a 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -40,6 +40,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -80,6 +81,8 @@ MODULE_LICENSE("GPL");
 
 #define ADV76XX_OP_SWAP_CB_CR  (1 << 0)
 
+#define ADV76XX_MAX_ADDRS (3)
+
 enum adv76xx_type {
ADV7604,
ADV7611,
@@ -184,6 +187,12 @@ struct adv76xx_state {
u16 spa_port_a[2];
struct v4l2_fract aspect_ratio;
u32 rgb_quantization_range;
+
+   struct cec_adapter *cec_adap;
+   u8   cec_addr[ADV76XX_MAX_ADDRS];
+   u8   cec_valid_addrs;
+   bool cec_enabled_adap;
+
struct workqueue_struct *work_queues;
struct delayed_work delayed_work_enable_hotplug;
bool restart_stdi_once;
@@ -381,7 +390,8 @@ static inline int io_write(struct v4l2_subdev *sd, u8 reg, 
u8 val)
return regmap_write(state->regmap[ADV76XX_PAGE_IO], reg, val);
 }
 
-static inline int io_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 
val)
+static inline int io_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask,
+  u8 val)
 {
return io_write(sd, reg, (io_read(sd, reg) & ~mask) | val);
 }
@@ -414,6 +424,12 @@ static inline int cec_write(struct v4l2_subdev *sd, u8 
reg, u8 val)
return regmap_write(state->regmap[ADV76XX_PAGE_CEC], reg, val);
 }
 
+static inline int cec_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask,
+  u8 val)
+{
+   return cec_write(sd, reg, (cec_read(sd, reg) & ~mask) | val);
+}
+
 static inline int infoframe_read(struct v4l2_subdev *sd, u8 reg)
 {
struct adv76xx_state *state = to_state(sd);
@@ -872,9 +888,9 @@ static int adv76xx_s_detect_tx_5v_ctrl(struct v4l2_subdev 
*sd)
 {
struct adv76xx_state *state = to_state(sd);
const struct adv76xx_chip_info *info = state->info;
+   u16 cable_det = info->read_cable_det(sd);
 
-   return v4l2_ctrl_s_ctrl(state->detect_tx_5v_ctrl,
-   info->read_cable_det(sd));
+   return v4l2_ctrl_s_ctrl(state->detect_tx_5v_ctrl, cable_det);
 }
 
 static int find_and_set_predefined_video_timings(struct v4l2_subdev *sd,
@@ -1900,6 +1916,210 @@ static int adv76xx_set_format(struct v4l2_subdev *sd,
return 0;
 }
 
+#if IS_ENABLED(CONFIG_VIDEO_ADV7604_CEC)
+static void adv76xx_cec_tx_raw_status(struct v4l2_subdev *sd, u8 tx_raw_status)
+{
+   struct adv76xx_state *state = to_state(sd);
+
+   if ((cec_read(sd, 0x11) & 0x01) == 0) {
+   v4l2_dbg(1, debug, sd, "%s: tx raw: tx disabled\n", __func__);
+   return;
+   }
+
+   if (tx_raw_status & 0x02) {
+   v4l2_dbg(1, debug, sd, "%s: tx raw: arbitration lost\n",
+__func__);
+   cec_transmit_done(state->cec_adap, CEC_TX_STATUS_ARB_LOST,
+ 1, 0, 0, 0);
+   }
+   if (tx_raw_status & 0x04) {
+   u8 status;
+   u8 nack_cnt;
+   u8 low_drive_cnt;
+
+   v4l2_dbg(1, debug, sd, "%s: tx raw: retry failed\n", __func__);
+   /*
+* We set this status bit since this hardware performs
+* retransmissions.
+*/
+   status = 

[PATCHv15 08/15] DocBook/media: add CEC documentation

2016-04-25 Thread Hans Verkuil
From: Hans Verkuil 

Add DocBook documentation for the CEC API.

Signed-off-by: Hans Verkuil 
[k.deb...@samsung.com: add documentation for passthrough mode]
[k.deb...@samsung.com: minor fixes and change of reserved field sizes]
Signed-off-by: Kamil Debski 
Signed-off-by: Hans Verkuil 
---
 Documentation/DocBook/device-drivers.tmpl  |   3 +
 Documentation/DocBook/media/Makefile   |   2 +
 Documentation/DocBook/media/v4l/biblio.xml |  10 +
 Documentation/DocBook/media/v4l/cec-api.xml|  72 +
 Documentation/DocBook/media/v4l/cec-func-close.xml |  59 
 Documentation/DocBook/media/v4l/cec-func-ioctl.xml |  73 +
 Documentation/DocBook/media/v4l/cec-func-open.xml  |  94 ++
 Documentation/DocBook/media/v4l/cec-func-poll.xml  |  89 ++
 .../DocBook/media/v4l/cec-ioc-adap-g-caps.xml  | 140 +
 .../DocBook/media/v4l/cec-ioc-adap-g-log-addrs.xml | 324 +
 .../DocBook/media/v4l/cec-ioc-adap-g-phys-addr.xml |  82 ++
 .../DocBook/media/v4l/cec-ioc-dqevent.xml  | 190 
 Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml | 245 
 .../DocBook/media/v4l/cec-ioc-receive.xml  | 260 +
 Documentation/DocBook/media_api.tmpl   |   6 +-
 15 files changed, 1648 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/DocBook/media/v4l/cec-api.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-func-close.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-func-ioctl.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-func-open.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-func-poll.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-caps.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-log-addrs.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-adap-g-phys-addr.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-dqevent.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml
 create mode 100644 Documentation/DocBook/media/v4l/cec-ioc-receive.xml

diff --git a/Documentation/DocBook/device-drivers.tmpl 
b/Documentation/DocBook/device-drivers.tmpl
index 893b2ca..6525246 100644
--- a/Documentation/DocBook/device-drivers.tmpl
+++ b/Documentation/DocBook/device-drivers.tmpl
@@ -270,6 +270,9 @@ X!Isound/sound_firmware.c
 !Iinclude/media/media-devnode.h
 !Iinclude/media/media-entity.h
 
+ Consumer Electronics Control devices
+!Iinclude/media/cec.h
+ 
 
   
 
diff --git a/Documentation/DocBook/media/Makefile 
b/Documentation/DocBook/media/Makefile
index 2840ff4..497b57e 100644
--- a/Documentation/DocBook/media/Makefile
+++ b/Documentation/DocBook/media/Makefile
@@ -64,6 +64,7 @@ IOCTLS = \
$(shell perl -ne 'print "$$1 " if /\#define\s+([A-Z][^\s]+)\s+_IO/' 
$(srctree)/include/uapi/linux/dvb/net.h) \
$(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' 
$(srctree)/include/uapi/linux/dvb/video.h) \
$(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' 
$(srctree)/include/uapi/linux/media.h) \
+   $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' 
$(srctree)/include/uapi/linux/cec.h) \
$(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' 
$(srctree)/include/uapi/linux/v4l2-subdev.h) \
 
 DEFINES = \
@@ -100,6 +101,7 @@ STRUCTS = \
$(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/ && !/_old/)' 
$(srctree)/include/uapi/linux/dvb/net.h) \
$(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' 
$(srctree)/include/uapi/linux/dvb/video.h) \
$(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/media.h) \
+   $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/cec.h) \
$(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/v4l2-subdev.h) \
$(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/v4l2-mediabus.h)
 
diff --git a/Documentation/DocBook/media/v4l/biblio.xml 
b/Documentation/DocBook/media/v4l/biblio.xml
index 9beb30f..87f1d24 100644
--- a/Documentation/DocBook/media/v4l/biblio.xml
+++ b/Documentation/DocBook/media/v4l/biblio.xml
@@ -342,6 +342,16 @@ in the frequency range from 87,5 to 108,0 MHz
   Specification Version 1.4a
 
 
+
+  HDMI2
+  
+   HDMI Licensing LLC
+(http://www.hdmi.org;>http://www.hdmi.org)
+  
+  High-Definition Multimedia Interface
+  Specification Version 2.0
+
+
 
   DP
   
diff --git a/Documentation/DocBook/media/v4l/cec-api.xml 
b/Documentation/DocBook/media/v4l/cec-api.xml
new file mode 100644
index 000..caa04c0
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/cec-api.xml
@@ -0,0 +1,72 @@
+
+  
+
+ 

[PATCHv15 10/15] cec: adv7842: add cec support

2016-04-25 Thread Hans Verkuil
From: Hans Verkuil 

Add CEC support to the adv7842 driver.

Signed-off-by: Hans Verkuil 
---
 drivers/media/i2c/Kconfig   |   9 ++
 drivers/media/i2c/adv7604.c |  10 +-
 drivers/media/i2c/adv7842.c | 368 
 3 files changed, 319 insertions(+), 68 deletions(-)

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index cba1fc7..5168454 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -231,6 +231,7 @@ config VIDEO_ADV7842
tristate "Analog Devices ADV7842 decoder"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
select HDMI
+   select MEDIA_CEC_EDID
---help---
  Support for the Analog Devices ADV7842 video decoder.
 
@@ -240,6 +241,14 @@ config VIDEO_ADV7842
  To compile this driver as a module, choose M here: the
  module will be called adv7842.
 
+config VIDEO_ADV7842_CEC
+   bool "Enable Analog Devices ADV7842 CEC support"
+   depends on VIDEO_ADV7842 && MEDIA_CEC
+   default y
+   ---help---
+ When selected the adv7842 will support the optional
+ HDMI CEC feature.
+
 config VIDEO_BT819
tristate "BT819A VideoStream decoder"
depends on VIDEO_V4L2 && I2C
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index d99f30a..cf9db86 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -2641,6 +2641,11 @@ static const struct v4l2_subdev_ops adv76xx_ops = {
.pad = _pad_ops,
 };
 
+static const struct v4l2_subdev_internal_ops adv76xx_int_ops = {
+   .registered = adv76xx_registered,
+   .unregistered = adv76xx_unregistered,
+};
+
 /* -- custom ctrls -- 
*/
 
 static const struct v4l2_ctrl_config adv7604_ctrl_analog_sampling_phase = {
@@ -2676,11 +2681,6 @@ static const struct v4l2_ctrl_config 
adv76xx_ctrl_free_run_color = {
.def = 0x0,
 };
 
-static const struct v4l2_subdev_internal_ops adv76xx_int_ops = {
-   .registered = adv76xx_registered,
-   .unregistered = adv76xx_unregistered,
-};
-
 /* --- */
 
 static int adv76xx_core_init(struct v4l2_subdev *sd)
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 7ccb85d..424bf87 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -79,6 +80,8 @@ MODULE_LICENSE("GPL");
 
 #define ADV7842_OP_SWAP_CB_CR  (1 << 0)
 
+#define ADV7842_MAX_ADDRS (3)
+
 /*
 **
 *
@@ -142,6 +145,11 @@ struct adv7842_state {
struct v4l2_ctrl *free_run_color_ctrl_manual;
struct v4l2_ctrl *free_run_color_ctrl;
struct v4l2_ctrl *rgb_quantization_range_ctrl;
+
+   struct cec_adapter *cec_adap;
+   u8   cec_addr[ADV7842_MAX_ADDRS];
+   u8   cec_valid_addrs;
+   bool cec_enabled_adap;
 };
 
 /* Unsupported timings. This device cannot support 720p30. */
@@ -418,9 +426,9 @@ static inline int cec_write(struct v4l2_subdev *sd, u8 reg, 
u8 val)
return adv_smbus_write_byte_data(state->i2c_cec, reg, val);
 }
 
-static inline int cec_write_and_or(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 
val)
+static inline int cec_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, 
u8 val)
 {
-   return cec_write(sd, reg, (cec_read(sd, reg) & mask) | val);
+   return cec_write(sd, reg, (cec_read(sd, reg) & ~mask) | val);
 }
 
 static inline int infoframe_read(struct v4l2_subdev *sd, u8 reg)
@@ -696,6 +704,18 @@ adv7842_get_dv_timings_cap(struct v4l2_subdev *sd)
 
 /* --- */
 
+static u16 adv7842_read_cable_det(struct v4l2_subdev *sd)
+{
+   u8 reg = io_read(sd, 0x6f);
+   u16 val = 0;
+
+   if (reg & 0x02)
+   val |= 1; /* port A */
+   if (reg & 0x01)
+   val |= 2; /* port B */
+   return val;
+}
+
 static void adv7842_delayed_work_enable_hotplug(struct work_struct *work)
 {
struct delayed_work *dwork = to_delayed_work(work);
@@ -762,50 +782,18 @@ static int edid_write_vga_segment(struct v4l2_subdev *sd)
return 0;
 }
 
-static int edid_spa_location(const u8 *edid)
-{
-   u8 d;
-
-   /*
-* TODO, improve and update for other CEA extensions
-* currently only for 1 segment (256 bytes),
-* i.e. 1 extension block and CEA revision 3.
-*/
-   if ((edid[0x7e] != 1) ||
-   (edid[0x80] != 0x02) ||
-   (edid[0x81] != 0x03)) {
-   return -EINVAL;
-   }
-   /*
-* search Vendor Specific Data Block (tag 3)
-*/
-   d = edid[0x82] & 0x7f;
-   if (d > 4) {
-   int i = 0x84;

[PATCHv15 01/15] input.h: add BUS_CEC type

2016-04-25 Thread Hans Verkuil
From: Hans Verkuil 

Inputs can come in over the HDMI CEC bus, so add a new type for this.

Signed-off-by: Hans Verkuil 
Acked-by: Dmitry Torokhov 
---
 include/uapi/linux/input.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
index 0111384..c514941 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -247,6 +247,7 @@ struct input_mask {
 #define BUS_ATARI  0x1B
 #define BUS_SPI0x1C
 #define BUS_RMI0x1D
+#define BUS_CEC0x1E
 
 /*
  * MT_TOOL types
-- 
2.8.1

--
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


[PATCHv15 12/15] cec: s5p-cec: Add s5p-cec driver

2016-04-25 Thread Hans Verkuil
From: Kamil Debski 

Add CEC interface driver present in the Samsung Exynos range of
SoCs.

The following files were based on work by SangPil Moon:
- exynos_hdmi_cec.h
- exynos_hdmi_cecctl.c

Signed-off-by: Kamil Debski 
Signed-off-by: Hans Verkuil 
---
 .../devicetree/bindings/media/s5p-cec.txt  |  31 +++
 MAINTAINERS|   7 +
 drivers/media/platform/Kconfig |  11 +
 drivers/media/platform/Makefile|   1 +
 drivers/media/platform/s5p-cec/Makefile|   2 +
 drivers/media/platform/s5p-cec/exynos_hdmi_cec.h   |  38 +++
 .../media/platform/s5p-cec/exynos_hdmi_cecctrl.c   | 210 +++
 drivers/media/platform/s5p-cec/regs-cec.h  |  96 +++
 drivers/media/platform/s5p-cec/s5p_cec.c   | 295 +
 drivers/media/platform/s5p-cec/s5p_cec.h   |  76 ++
 10 files changed, 767 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/s5p-cec.txt
 create mode 100644 drivers/media/platform/s5p-cec/Makefile
 create mode 100644 drivers/media/platform/s5p-cec/exynos_hdmi_cec.h
 create mode 100644 drivers/media/platform/s5p-cec/exynos_hdmi_cecctrl.c
 create mode 100644 drivers/media/platform/s5p-cec/regs-cec.h
 create mode 100644 drivers/media/platform/s5p-cec/s5p_cec.c
 create mode 100644 drivers/media/platform/s5p-cec/s5p_cec.h

diff --git a/Documentation/devicetree/bindings/media/s5p-cec.txt 
b/Documentation/devicetree/bindings/media/s5p-cec.txt
new file mode 100644
index 000..925ab4d
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/s5p-cec.txt
@@ -0,0 +1,31 @@
+* Samsung HDMI CEC driver
+
+The HDMI CEC module is present is Samsung SoCs and its purpose is to
+handle communication between HDMI connected devices over the CEC bus.
+
+Required properties:
+  - compatible : value should be following
+   "samsung,s5p-cec"
+
+  - reg : Physical base address of the IP registers and length of memory
+ mapped region.
+
+  - interrupts : HDMI CEC interrupt number to the CPU.
+  - clocks : from common clock binding: handle to HDMI CEC clock.
+  - clock-names : from common clock binding: must contain "hdmicec",
+ corresponding to entry in the clocks property.
+  - samsung,syscon-phandle - phandle to the PMU system controller
+
+Example:
+
+hdmicec: cec@100B {
+   compatible = "samsung,s5p-cec";
+   reg = <0x100B 0x200>;
+   interrupts = <0 114 0>;
+   clocks = < CLK_HDMI_CEC>;
+   clock-names = "hdmicec";
+   samsung,syscon-phandle = <_system_controller>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_cec>;
+   status = "okay";
+};
diff --git a/MAINTAINERS b/MAINTAINERS
index 83bd865..0e43b30 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1581,6 +1581,13 @@ L:   linux-media@vger.kernel.org
 S: Maintained
 F: drivers/media/platform/s5p-tv/
 
+ARM/SAMSUNG S5P SERIES HDMI CEC SUBSYSTEM SUPPORT
+M: Kyungmin Park 
+L: linux-arm-ker...@lists.infradead.org
+L: linux-media@vger.kernel.org
+S: Maintained
+F: drivers/media/platform/s5p-cec/
+
 ARM/SAMSUNG S5P SERIES JPEG CODEC SUPPORT
 M: Andrzej Pietrasiewicz 
 M: Jacek Anaszewski 
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 84e041c..c3945c3 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -108,6 +108,17 @@ config VIDEO_S3C_CAMIF
 source "drivers/media/platform/soc_camera/Kconfig"
 source "drivers/media/platform/exynos4-is/Kconfig"
 source "drivers/media/platform/s5p-tv/Kconfig"
+
+config VIDEO_SAMSUNG_S5P_CEC
+   tristate "Samsung S5P CEC driver"
+   depends on VIDEO_DEV && MEDIA_CEC && (PLAT_S5P || ARCH_EXYNOS || 
COMPILE_TEST)
+   default n
+   ---help---
+ This is a driver for Samsung S5P HDMI CEC interface. It uses the
+ generic CEC framework interface.
+ CEC bus is present in the HDMI connector and enables communication
+ between compatible devices.
+
 source "drivers/media/platform/am437x/Kconfig"
 source "drivers/media/platform/xilinx/Kconfig"
 
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index bbb7bd1..f598c80 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_VIDEO_MEM2MEM_DEINTERLACE)   += 
m2m-deinterlace.o
 
 obj-$(CONFIG_VIDEO_S3C_CAMIF)  += s3c-camif/
 obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS4_IS) += exynos4-is/
+obj-$(CONFIG_VIDEO_SAMSUNG_S5P_CEC)+= s5p-cec/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG)   += s5p-jpeg/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC)+= s5p-mfc/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_TV) += s5p-tv/
diff --git a/drivers/media/platform/s5p-cec/Makefile 
b/drivers/media/platform/s5p-cec/Makefile
new file mode 

[PATCHv15 11/15] cec: adv7511: add cec support.

2016-04-25 Thread Hans Verkuil
From: Hans Verkuil 

Add CEC support to the adv7511 driver.

Signed-off-by: Hans Verkuil 
[k.deb...@samsung.com: Merged changes from CEC Updates commit by Hans Verkuil]
Signed-off-by: Kamil Debski 
Signed-off-by: Hans Verkuil 
---
 drivers/media/i2c/Kconfig   |   9 +
 drivers/media/i2c/adv7511.c | 401 +++-
 include/media/i2c/adv7511.h |   6 +-
 3 files changed, 403 insertions(+), 13 deletions(-)

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 5168454..6c2acb6 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -465,6 +465,7 @@ config VIDEO_ADV7511
tristate "Analog Devices ADV7511 encoder"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
select HDMI
+   select MEDIA_CEC_EDID
---help---
  Support for the Analog Devices ADV7511 video encoder.
 
@@ -473,6 +474,14 @@ config VIDEO_ADV7511
  To compile this driver as a module, choose M here: the
  module will be called adv7511.
 
+config VIDEO_ADV7511_CEC
+   bool "Enable Analog Devices ADV7511 CEC support"
+   depends on VIDEO_ADV7511 && MEDIA_CEC
+   default y
+   ---help---
+ When selected the adv7511 will support the optional
+ HDMI CEC feature.
+
 config VIDEO_AD9389B
tristate "Analog Devices AD9389B encoder"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index bd822f0..38a1002 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static int debug;
 module_param(debug, int, 0644);
@@ -59,6 +60,8 @@ MODULE_LICENSE("GPL v2");
 #define ADV7511_MIN_PIXELCLOCK 2000
 #define ADV7511_MAX_PIXELCLOCK 22500
 
+#define ADV7511_MAX_ADDRS (3)
+
 /*
 **
 *
@@ -90,12 +93,20 @@ struct adv7511_state {
struct v4l2_ctrl_handler hdl;
int chip_revision;
u8 i2c_edid_addr;
-   u8 i2c_cec_addr;
u8 i2c_pktmem_addr;
+   u8 i2c_cec_addr;
+
+   struct i2c_client *i2c_cec;
+   struct cec_adapter *cec_adap;
+   u8   cec_addr[ADV7511_MAX_ADDRS];
+   u8   cec_valid_addrs;
+   bool cec_enabled_adap;
+
/* Is the adv7511 powered on? */
bool power_on;
/* Did we receive hotplug and rx-sense signals? */
bool have_monitor;
+   bool enabled_irq;
/* timings from s_dv_timings */
struct v4l2_dv_timings dv_timings;
u32 fmt_code;
@@ -227,7 +238,7 @@ static int adv_smbus_read_i2c_block_data(struct i2c_client 
*client,
return ret;
 }
 
-static inline void adv7511_edid_rd(struct v4l2_subdev *sd, u16 len, u8 *buf)
+static void adv7511_edid_rd(struct v4l2_subdev *sd, uint16_t len, uint8_t *buf)
 {
struct adv7511_state *state = get_adv7511_state(sd);
int i;
@@ -242,6 +253,34 @@ static inline void adv7511_edid_rd(struct v4l2_subdev *sd, 
u16 len, u8 *buf)
v4l2_err(sd, "%s: i2c read error\n", __func__);
 }
 
+static inline int adv7511_cec_read(struct v4l2_subdev *sd, u8 reg)
+{
+   struct adv7511_state *state = get_adv7511_state(sd);
+
+   return i2c_smbus_read_byte_data(state->i2c_cec, reg);
+}
+
+static int adv7511_cec_write(struct v4l2_subdev *sd, u8 reg, u8 val)
+{
+   struct adv7511_state *state = get_adv7511_state(sd);
+   int ret;
+   int i;
+
+   for (i = 0; i < 3; i++) {
+   ret = i2c_smbus_write_byte_data(state->i2c_cec, reg, val);
+   if (ret == 0)
+   return 0;
+   }
+   v4l2_err(sd, "%s: I2C Write Problem\n", __func__);
+   return ret;
+}
+
+static inline int adv7511_cec_write_and_or(struct v4l2_subdev *sd, u8 reg, u8 
mask,
+  u8 val)
+{
+   return adv7511_cec_write(sd, reg, (adv7511_cec_read(sd, reg) & mask) | 
val);
+}
+
 static int adv7511_pktmem_rd(struct v4l2_subdev *sd, u8 reg)
 {
struct adv7511_state *state = get_adv7511_state(sd);
@@ -425,16 +464,28 @@ static const struct v4l2_ctrl_ops adv7511_ctrl_ops = {
 #ifdef CONFIG_VIDEO_ADV_DEBUG
 static void adv7511_inv_register(struct v4l2_subdev *sd)
 {
+   struct adv7511_state *state = get_adv7511_state(sd);
+
v4l2_info(sd, "0x000-0x0ff: Main Map\n");
+   if (state->i2c_cec)
+   v4l2_info(sd, "0x100-0x1ff: CEC Map\n");
 }
 
 static int adv7511_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register 
*reg)
 {
+   struct adv7511_state *state = get_adv7511_state(sd);
+
reg->size = 1;
switch (reg->reg >> 8) {
case 0:
reg->val = adv7511_rd(sd, reg->reg & 0xff);
break;
+   case 1:
+   if (state->i2c_cec) {
+   reg->val = 

[PATCHv15 03/15] rc: Add HDMI CEC protocol handling

2016-04-25 Thread Hans Verkuil
From: Kamil Debski 

Add handling of remote control events coming from the HDMI CEC bus.
This patch includes a new keymap that maps values found in the CEC
messages to the keys pressed and released. Also, a new protocol has
been added to the core.

Signed-off-by: Kamil Debski 
Signed-off-by: Hans Verkuil 
---
 drivers/media/rc/keymaps/Makefile |   1 +
 drivers/media/rc/keymaps/rc-cec.c | 174 ++
 drivers/media/rc/rc-main.c|   1 +
 include/media/rc-map.h|   5 +-
 4 files changed, 180 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/rc/keymaps/rc-cec.c

diff --git a/drivers/media/rc/keymaps/Makefile 
b/drivers/media/rc/keymaps/Makefile
index fbbd3bb..9cffcc6 100644
--- a/drivers/media/rc/keymaps/Makefile
+++ b/drivers/media/rc/keymaps/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
rc-behold.o \
rc-behold-columbus.o \
rc-budget-ci-old.o \
+   rc-cec.o \
rc-cinergy-1400.o \
rc-cinergy.o \
rc-delock-61959.o \
diff --git a/drivers/media/rc/keymaps/rc-cec.c 
b/drivers/media/rc/keymaps/rc-cec.c
new file mode 100644
index 000..193cdca
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-cec.c
@@ -0,0 +1,174 @@
+/* Keytable for the CEC remote control
+ *
+ * Copyright (c) 2015 by Kamil Debski
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+
+/* CEC Spec "High-Definition Multimedia Interface Specification" can be 
obtained
+ * here: http://xtreamerdev.googlecode.com/files/CEC_Specs.pdf
+ * The list of control codes is listed in Table 27: User Control Codes p. 95 */
+
+static struct rc_map_table cec[] = {
+   { 0x00, KEY_OK },
+   { 0x01, KEY_UP },
+   { 0x02, KEY_DOWN },
+   { 0x03, KEY_LEFT },
+   { 0x04, KEY_RIGHT },
+   { 0x05, KEY_RIGHT_UP },
+   { 0x06, KEY_RIGHT_DOWN },
+   { 0x07, KEY_LEFT_UP },
+   { 0x08, KEY_LEFT_DOWN },
+   { 0x09, KEY_ROOT_MENU }, /* CEC Spec: Device Root Menu - see Note 2 */
+   /* Note 2: This is the initial display that a device shows. It is
+* device-dependent and can be, for example, a contents menu, setup
+* menu, favorite menu or other menu. The actual menu displayed
+* may also depend on the device's current state. */
+   { 0x0a, KEY_SETUP },
+   { 0x0b, KEY_MENU }, /* CEC Spec: Contents Menu */
+   { 0x0c, KEY_FAVORITES }, /* CEC Spec: Favorite Menu */
+   { 0x0d, KEY_EXIT },
+   /* 0x0e-0x0f: Reserved */
+   { 0x10, KEY_MEDIA_TOP_MENU },
+   { 0x11, KEY_CONTEXT_MENU },
+   /* 0x12-0x1c: Reserved */
+   { 0x1d, KEY_DIGITS }, /* CEC Spec: select/toggle a Number Entry Mode */
+   { 0x1e, KEY_NUMERIC_11 },
+   { 0x1f, KEY_NUMERIC_12 },
+   /* 0x20-0x29: Keys 0 to 9 */
+   { 0x20, KEY_NUMERIC_0 },
+   { 0x21, KEY_NUMERIC_1 },
+   { 0x22, KEY_NUMERIC_2 },
+   { 0x23, KEY_NUMERIC_3 },
+   { 0x24, KEY_NUMERIC_4 },
+   { 0x25, KEY_NUMERIC_5 },
+   { 0x26, KEY_NUMERIC_6 },
+   { 0x27, KEY_NUMERIC_7 },
+   { 0x28, KEY_NUMERIC_8 },
+   { 0x29, KEY_NUMERIC_9 },
+   { 0x2a, KEY_DOT },
+   { 0x2b, KEY_ENTER },
+   { 0x2c, KEY_CLEAR },
+   /* 0x2d-0x2e: Reserved */
+   { 0x2f, KEY_NEXT_FAVORITE }, /* CEC Spec: Next Favorite */
+   { 0x30, KEY_CHANNELUP },
+   { 0x31, KEY_CHANNELDOWN },
+   { 0x32, KEY_PREVIOUS }, /* CEC Spec: Previous Channel */
+   { 0x33, KEY_SOUND }, /* CEC Spec: Sound Select */
+   { 0x34, KEY_VIDEO }, /* 0x34: CEC Spec: Input Select */
+   { 0x35, KEY_INFO }, /* CEC Spec: Display Information */
+   { 0x36, KEY_HELP },
+   { 0x37, KEY_PAGEUP },
+   { 0x38, KEY_PAGEDOWN },
+   /* 0x39-0x3f: Reserved */
+   { 0x40, KEY_POWER },
+   { 0x41, KEY_VOLUMEUP },
+   { 0x42, KEY_VOLUMEDOWN },
+   { 0x43, KEY_MUTE },
+   { 0x44, KEY_PLAYCD },
+   { 0x45, KEY_STOPCD },
+   { 0x46, KEY_PAUSECD },
+   { 0x47, KEY_RECORD },
+   { 0x48, KEY_REWIND },
+   { 0x49, KEY_FASTFORWARD },
+   { 0x4a, KEY_EJECTCD }, /* CEC Spec: Eject */
+   { 0x4b, KEY_FORWARD },
+   { 0x4c, KEY_BACK },
+   { 0x4d, KEY_STOP_RECORD }, /* CEC Spec: Stop-Record */
+   { 0x4e, KEY_PAUSE_RECORD }, /* CEC Spec: Pause-Record */
+   /* 0x4f: Reserved */
+   { 0x50, KEY_ANGLE },
+   { 0x51, KEY_TV2 },
+   { 0x52, KEY_VOD }, /* CEC Spec: Video on Demand */
+   { 0x53, KEY_EPG },
+   { 0x54, KEY_TIME }, /* CEC Spec: Timer */
+   { 0x55, KEY_CONFIG },
+   /* The following 

[PATCHv15 02/15] HID: add HDMI CEC specific keycodes

2016-04-25 Thread Hans Verkuil
From: Kamil Debski 

Add HDMI CEC specific keycodes to the keycodes definition.

Signed-off-by: Kamil Debski 
Signed-off-by: Hans Verkuil 
Acked-by: Dmitry Torokhov 
---
 include/uapi/linux/input-event-codes.h | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/include/uapi/linux/input-event-codes.h 
b/include/uapi/linux/input-event-codes.h
index 87cf351..02b7b3a 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -611,6 +611,36 @@
 #define KEY_KBDINPUTASSIST_ACCEPT  0x264
 #define KEY_KBDINPUTASSIST_CANCEL  0x265
 
+/* Diagonal movement keys */
+#define KEY_RIGHT_UP   0x266
+#define KEY_RIGHT_DOWN 0x267
+#define KEY_LEFT_UP0x268
+#define KEY_LEFT_DOWN  0x269
+
+#define KEY_ROOT_MENU  0x26a /* Show Device's Root Menu */
+#define KEY_MEDIA_TOP_MENU 0x26b /* Show Top Menu of the Media 
(e.g. DVD) */
+#define KEY_NUMERIC_11 0x26c
+#define KEY_NUMERIC_12 0x26d
+/*
+ * Toggle Audio Description: refers to an audio service that helps blind and
+ * visually impaired consumers understand the action in a program. Note: in
+ * some countries this is referred to as "Video Description".
+ */
+#define KEY_AUDIO_DESC 0x26e
+#define KEY_3D_MODE0x26f
+#define KEY_NEXT_FAVORITE  0x270
+#define KEY_STOP_RECORD0x271
+#define KEY_PAUSE_RECORD   0x272
+#define KEY_VOD0x273 /* Video on Demand */
+#define KEY_UNMUTE 0x274
+#define KEY_FASTREVERSE0x275
+#define KEY_SLOWREVERSE0x276
+/*
+ * Control a data application associated with the currently viewed channel,
+ * e.g. teletext or data broadcast application (MHEG, MHP, HbbTV, etc.)
+ */
+#define KEY_DATA   0x275
+
 #define BTN_TRIGGER_HAPPY  0x2c0
 #define BTN_TRIGGER_HAPPY1 0x2c0
 #define BTN_TRIGGER_HAPPY2 0x2c1
-- 
2.8.1

--
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


[PATCHv15 00/15] HDMI CEC framework

2016-04-25 Thread Hans Verkuil
From: Hans Verkuil 

Hi all,

The fifteenth version of this patchset takes care of the TODO items from
the previous patch series. I don't have anything else pending and if there
are no other comments then I intend to post a pull request.

The highlight of this v15 release are:

- The framework itself is now added to staging and the public headers
  aren't exported yet. While the kABI is fine, the uABI might need some
  tweaks. Having this in the kernel makes it easier for more people to
  test and I plan to move it out of staging by the end of the year.

- The LOG_STATUS ioctl has been replaced by a debugfs implementation.

- The reserved fields have been removed in the ioctl structs since
  versioning was prefered over using reserved fields.
 
- The EDID CEC helpers that deal with the physical address are moved to
  a separate module. You need those even without MEDIA_CEC.

- Three Samsung dts patches are dropped and will go in via the samsung
  tree.

- Simplified how the adv drivers create the CEC device.
 
See the changelog below for more details.

The last two patches of this series will not be part of a pull request:
the ARC/CDC code needs to be tested with actual hardware first and the new
pulse8 driver is still work-in-progress. The pulse eight adapter has a mind
of its own and will handle some messages autonomously and I haven't quite
figured out how to turn that off. But transmitting and receiving CEC messages
does work fine. You'll need a patch for the inputattach utility, mail me
if you are interested.

I had hoped to have an omap pandaboard implementation as well, but I
suspect there is something wrong with either the dts or the actual hardware
since it seems the CEC data never reaches the omap. Either pins aren't
hooked up correctly or they are not configured correctly, I can't figure
it out. If anyone has more detailed knowledge about the omap4430 relating
and pandaboard, then please contact me.

The cec-ctl and cec-compliance utilities used to test the CEC framework
can be found here:
  
http://git.linuxtv.org/cgit.cgi/hverkuil/v4l-utils.git/log/?h=cec

Best regards,

Hans

Changes since v14
=
- Dropped the Samsung dts patches, these will go in via the samsung tree.
- CEC_LOG_STATUS is replaced by a debugfs status file.
- Dropped the reserved fields in the API, use versioning instead. Two
  flags field were added instead.
- Extended cec_caps with a version field.
- Dropped CEC_CAP_IS_SOURCE as it is not needed in practice.
- The adv drivers now create the CEC adapter themselves instead of leaving
  that to the bridge. It greatly simplifies the code and it was really a
  left-over from the early days of the framework.
- The CEC implementation of the adv drivers is now configured through
  a separate config option. CEC is an optional HDMI feature and you may not
  want to compile this in if your hardware hasn't hooked up the CEC pin.
- The EDID CEC helper functions have been split off into their own cec-edid
  module. You likely need them even if MEDIA_CEC is not set.
- Added missing copyright statements.
- Added RFC code for the pulse-eight USB CEC adapter.

Changes since v13
=
- Removed CEC_CAP_STATE and _VENDOR_ID
- Removed CEC_ADAP_G/S_STATE and CEC_ADAP_G/S_VENDOR_ID
- Add vendor_id to struct cec_log_addrs
- CEC_EVENT_STATE_CHANGE now reports the physical address, the logical
  address mask and the logical address type mask.
- Add the logical address mask and the logical address type mask to
  struct cec_log_addrs.
- Dropped cec_enable, instead enable/disable the adapter based on the
  physical address.
- Once a valid physical address is available and userspace or driver
  specified the requested logical address configuration the framework
  will automatically claim the needed logical addresses. It will retry
  the last used addresses first, as per the recommendation in the CEC
  specification.
- Dropped CEC power status handling: it's not clear if the kernel should
  handle that, and if it has to, whether this is the correct way.
- Dropped CEC_EVENT_PHYS_ADDR_CHANGE, this is now handled by
  CEC_EVENT_STATE_CHANGE.
- Add helper functions for manipulating physical addresses.
- Updated documentation.
- Dropped ninputs field in struct cec_caps.
- Dropped CEC_EVENT_INPUTS_CHANGE, was never used and it is unclear if it
  is needed.

Changes since v12
=
- Added driver and name fields to the cec_caps struct. Without this it was
  very difficult to tell CEC adapters apart in a human readable manner.
- Renamed CEC_CAP_IO to CEC_CAP_TRANSMIT, which better describes this
  capability. 
- Added the CEC_ADAP_LOG_STATUS to log the current status of the CEC adapter.
  Very useful when debugging.
- Added comments to the cec.c source.
- Added a timeout when waiting for a transmit to finish. Without the timeout
  the state machine could lock up when dealing with broken CEC adapter drivers
  or just unlucky situations.
- 

[PATCHv15 05/15] cec/TODO: add TODO file so we know why this is still in staging

2016-04-25 Thread Hans Verkuil
From: Hans Verkuil 

Explain why cec.c is still in staging.

Signed-off-by: Hans Verkuil 
---
 drivers/staging/media/cec/TODO | 13 +
 1 file changed, 13 insertions(+)
 create mode 100644 drivers/staging/media/cec/TODO

diff --git a/drivers/staging/media/cec/TODO b/drivers/staging/media/cec/TODO
new file mode 100644
index 000..c0751ef
--- /dev/null
+++ b/drivers/staging/media/cec/TODO
@@ -0,0 +1,13 @@
+The reason why cec.c is still in staging is that I would like
+to have a bit more confidence in the uABI. The kABI is fine,
+no problem there, but I would like to let the public API mature
+a bit.
+
+Once I'm confident that I didn't miss anything then the cec.c source
+can move to drivers/media and the linux/cec.h and linux/cec-funcs.h
+headers can move to uapi/linux and added to uapi/linux/Kbuild to make
+them public.
+
+Hopefully this will happen later in 2016.
+
+Hans Verkuil 
-- 
2.8.1

--
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] [media] tvp686x: Don't go past array

2016-04-25 Thread Hans Verkuil
Since my patch exchanges the sparse warning with a smatch warning, it's
OK to take this one, with a few corrections:

Please update the subject line (it says tvp686x instead of tw686x).

On 04/23/2016 11:23 AM, Mauro Carvalho Chehab wrote:
> Depending on the compiler version, currently it produces the
> following warnings:
>   tw686x-video.c: In function 'tw686x_video_init':
>   tw686x-video.c:65:543: warning: array subscript is above array bounds 
> [-Warray-bounds]
> 
> This is actually bogus with the current code, as it currently
> hardcodes the framerate to 30 frames/sec, however a potential
> use after the array size could happen when the driver adds support
> for setting the framerate. So, fix it.
> 
> Signed-off-by: Mauro Carvalho Chehab 
> ---
>  drivers/media/pci/tw686x/tw686x-video.c | 15 +--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/pci/tw686x/tw686x-video.c 
> b/drivers/media/pci/tw686x/tw686x-video.c
> index 118e9fac9f28..1ff59084ce08 100644
> --- a/drivers/media/pci/tw686x/tw686x-video.c
> +++ b/drivers/media/pci/tw686x/tw686x-video.c
> @@ -61,8 +61,19 @@ static unsigned int tw686x_fields_map(v4l2_std_id std, 
> unsigned int fps)
>  8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 0, 0
>   };
>  
> - unsigned int i =
> - (std & V4L2_STD_625_50) ? std_625_50[fps] : std_525_60[fps];
> + unsigned int i;
> +
> + if (std & V4L2_STD_625_50) {

Please test against 525_60 since that is the recommended test.

> + if (unlikely(i > ARRAY_SIZE(std_625_50)))

Please don't use 'unlikely'. It's pointless for code that is rarely used.

Actually, the code is wrong: i is uninitialized here.

It should be fps >= ARRAY_SIZE(std_625_50).

In fact, I'd write it like this:

i = std_625_50[(fps >= ARRAY_SIZE(std_625_50) ? 24 : fps];

> + i = 14; /* 25 fps */
> + else
> + i = std_625_50[fps];
> + } else {
> + if (unlikely(i > ARRAY_SIZE(std_525_60)))
> + i = 0;  /* 30 fps */
> + else
> + i = std_525_60[fps];
> + }
>  
>   return map[i];
>  }
> 

Regards,

Hans
--
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


[PATCH] [media] sta2x11: remove unused vars

2016-04-25 Thread Mauro Carvalho Chehab
Changeset 7b9f31f3b3ca ("[media] sta2x11_vip: fix s_std") removed
autodetect code, but it kept two vars unused:

drivers/media/pci/sta2x11/sta2x11_vip.c: In function 'vidioc_s_std':
drivers/media/pci/sta2x11/sta2x11_vip.c:448:6: warning: unused variable 
'status' [-Wunused-variable]
  int status;
  ^
drivers/media/pci/sta2x11/sta2x11_vip.c:447:14: warning: unused variable 
'oldstd' [-Wunused-variable]
  v4l2_std_id oldstd = vip->std;
  ^
Remove them.

Fixes: 7b9f31f3b3ca ("[media] sta2x11_vip: fix s_std")
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/pci/sta2x11/sta2x11_vip.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c 
b/drivers/media/pci/sta2x11/sta2x11_vip.c
index c79623ca5fc3..1fc195f89686 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.c
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
@@ -444,8 +444,6 @@ static int vidioc_querycap(struct file *file, void *priv,
 static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id std)
 {
struct sta2x11_vip *vip = video_drvdata(file);
-   v4l2_std_id oldstd = vip->std;
-   int status;
 
/*
 * This is here for backwards compatibility only.
-- 
2.5.5

--
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: [GIT PULL FOR v4.7] Various fixes, remove most 'experimental' annotations

2016-04-25 Thread Mauro Carvalho Chehab
Em Mon, 25 Apr 2016 11:14:27 +0200
Hans Verkuil  escreveu:

> Hi Mauro,
> 
> Here are various fixes for 4.7.
> 
> Note that I chose to go with my tw686x patches instead of yours
> (https://patchwork.linuxtv.org/patch/33991/).

Your patch caused this new smatch warning:
drivers/media/pci/tw686x/tw686x-video.c:67 tw686x_fields_map() error: 
buffer overflow 'std_625_50' 26 <= 30

It sounds better to stay with the one I wrote ;)

For now, I'll just drop it from the patch series.

Regards,
Mauro
-- 
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: [RFC PATCH 00/24] Make Nokia N900 cameras working

2016-04-25 Thread Pali Rohár
front camera:

On Monday 25 April 2016 00:08:00 Ivaylo Dimitrov wrote:
> The needed pipeline could be made with:
> 
> media-ctl -r
> media-ctl -l '"vs6555 binner 2-0010":1 -> "video-bus-switch":2 [1]'
> media-ctl -l '"video-bus-switch":0 -> "OMAP3 ISP CCP2":0 [1]'
> media-ctl -l '"OMAP3 ISP CCP2":1 -> "OMAP3 ISP CCDC":0 [1]'
> media-ctl -l '"OMAP3 ISP CCDC":2 -> "OMAP3 ISP preview":0 [1]'
> media-ctl -l '"OMAP3 ISP preview":1 -> "OMAP3 ISP resizer":0 [1]'
> media-ctl -l '"OMAP3 ISP resizer":1 -> "OMAP3 ISP resizer output":0 [1]'
> media-ctl -V '"vs6555 pixel array 2-0010":0 [SGRBG10/648x488 (0,0)/648x488 
> (0,0)/648x488]'
> media-ctl -V '"vs6555 binner 2-0010":1 [SGRBG10/648x488 (0,0)/648x488 
> (0,0)/648x488]'
> media-ctl -V '"OMAP3 ISP CCP2":0 [SGRBG10 648x488]'
> media-ctl -V '"OMAP3 ISP CCP2":1 [SGRBG10 648x488]'
> media-ctl -V '"OMAP3 ISP CCDC":2 [SGRBG10 648x488]'
> media-ctl -V '"OMAP3 ISP preview":1 [UYVY 648x488]'
> media-ctl -V '"OMAP3 ISP resizer":1 [UYVY 656x488]'
> 
> and tested with:
> 
> mplayer -tv driver=v4l2:width=656:height=488:outfmt=uyvy:device=/dev/video6 
> -vo xv -vf screenshot tv://

back camera:

On Monday 25 April 2016 09:33:18 Ivaylo Dimitrov wrote:
> Try with:
> 
> media-ctl -r
> media-ctl -l '"et8ek8 3-003e":0 -> "video-bus-switch":1 [1]'
> media-ctl -l '"video-bus-switch":0 -> "OMAP3 ISP CCP2":0 [1]'
> media-ctl -l '"OMAP3 ISP CCP2":1 -> "OMAP3 ISP CCDC":0 [1]'
> media-ctl -l '"OMAP3 ISP CCDC":2 -> "OMAP3 ISP preview":0 [1]'
> media-ctl -l '"OMAP3 ISP preview":1 -> "OMAP3 ISP resizer":0 [1]'
> media-ctl -l '"OMAP3 ISP resizer":1 -> "OMAP3 ISP resizer output":0 [1]'
> 
> media-ctl -V '"et8ek8 3-003e":0 [SGRBG10 864x656]'
> media-ctl -V '"OMAP3 ISP CCP2":0 [SGRBG10 864x656]'
> media-ctl -V '"OMAP3 ISP CCP2":1 [SGRBG10 864x656]'
> media-ctl -V '"OMAP3 ISP CCDC":2 [SGRBG10 864x656]'
> media-ctl -V '"OMAP3 ISP preview":1 [UYVY 864x656]'
> media-ctl -V '"OMAP3 ISP resizer":1 [UYVY 800x600]'
> 
> 
> mplayer -tv driver=v4l2:width=800:height=600:outfmt=uyvy:device=/dev/video6 
> -vo xv -vf screenshot tv://

Hey!!! That is crazy! Who created such retard API?? In both cases you
are going to show video from /dev/video6 device. But in real I have two
independent camera devices: front and back.

Why on the earth I cannot have /dev/video0 for back camera and
/dev/video1 for front camera? And need to call such huge commands which
re-route pictures from correct camera to /dev/video6 device? I'm really
not interested in some hw details how are cameras connected, I just want
to show pictures in userspace...

And what are those others /dev/video[0-5] devices?

-- 
Pali Rohár
pali.ro...@gmail.com
--
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


[GIT PULL FOR v4.6] One bug fix, two regression fixes

2016-04-25 Thread Hans Verkuil
Three fixes for 4.6: two vb2 regressions and one bug fix for 4k timings that
was wrong since the beginning.

Regards,

Hans

The following changes since commit e07d46e7e0da86c146f199dae76f879096bc436a:

  [media] tpg: Export the tpg code from vivid as a module (2016-04-20 16:14:39 
-0300)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git for-v4.6b

for you to fetch changes up to 5630e38582d970604daff4bb261734fe204e2791:

  vb2-memops: Fix over allocation of frame vectors (2016-04-25 12:19:30 +0200)


Hans Verkuil (1):
  v4l2-dv-timings.h: fix polarity for 4k formats

Ricardo Ribalda Delgado (2):
  media: vb2: Fix regression on poll() for RW mode
  vb2-memops: Fix over allocation of frame vectors

 drivers/media/v4l2-core/videobuf2-core.c   | 10 ++
 drivers/media/v4l2-core/videobuf2-memops.c |  2 +-
 drivers/media/v4l2-core/videobuf2-v4l2.c   | 14 ++
 include/media/videobuf2-core.h |  4 
 include/uapi/linux/v4l2-dv-timings.h   | 30 --
 5 files changed, 41 insertions(+), 19 deletions(-)
--
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


[GIT PULL FOR v4.6] One bug fix, one regression

2016-04-25 Thread Hans Verkuil
Two fixes for 4.6: one vb2 regression and one bug fix for 4k timings that
was wrong since the beginning.

Regards,

Hans

The following changes since commit e07d46e7e0da86c146f199dae76f879096bc436a:

  [media] tpg: Export the tpg code from vivid as a module (2016-04-20 16:14:39 
-0300)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git for-v4.6b

for you to fetch changes up to 94f40244bb886a9f4245a7123f1af9572c7cf82f:

  media: vb2: Fix regression on poll() for RW mode (2016-04-25 11:21:22 +0200)


Hans Verkuil (1):
  v4l2-dv-timings.h: fix polarity for 4k formats

Ricardo Ribalda Delgado (1):
  media: vb2: Fix regression on poll() for RW mode

 drivers/media/v4l2-core/videobuf2-core.c | 10 ++
 drivers/media/v4l2-core/videobuf2-v4l2.c | 14 ++
 include/media/videobuf2-core.h   |  4 
 include/uapi/linux/v4l2-dv-timings.h | 30 --
 4 files changed, 40 insertions(+), 18 deletions(-)
--
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 v7 2/8] [media] VPU: mediatek: support Mediatek VPU

2016-04-25 Thread andrew-ct chen
On Mon, 2016-04-25 at 09:40 +0200, Hans Verkuil wrote:
> On 04/22/2016 06:25 AM, Tiffany Lin wrote:
> > From: Andrew-CT Chen 
> > 
> > The VPU driver for hw video codec embedded in Mediatek's MT8173 SOCs.
> > It is able to handle video decoding/encoding of in a range of formats.
> > The driver provides with VPU firmware download, memory management and
> > the communication interface between CPU and VPU.
> > For VPU initialization, it will create virtual memory for CPU access and
> > IOMMU address for vcodec hw device access. When a decode/encode instance
> > opens a device node, vpu driver will download vpu firmware to the device.
> > A decode/encode instant will decode/encode a frame using VPU
> > interface to interrupt vpu to handle decoding/encoding jobs.
> > 
> > Signed-off-by: Andrew-CT Chen 
> > Signed-off-by: Tiffany Lin 
> > 
> > ---
> >  drivers/media/platform/Kconfig   |   13 +
> >  drivers/media/platform/Makefile  |2 +
> >  drivers/media/platform/mtk-vpu/Makefile  |3 +
> >  drivers/media/platform/mtk-vpu/mtk_vpu.c |  950 
> > ++
> >  drivers/media/platform/mtk-vpu/mtk_vpu.h |  162 +
> >  5 files changed, 1130 insertions(+)
> >  create mode 100644 drivers/media/platform/mtk-vpu/Makefile
> >  create mode 100755 drivers/media/platform/mtk-vpu/mtk_vpu.c
> >  create mode 100644 drivers/media/platform/mtk-vpu/mtk_vpu.h
> > 
> 
> 
> > +int vpu_load_firmware(struct platform_device *pdev)
> > +{
> > +   struct mtk_vpu *vpu = platform_get_drvdata(pdev);
> > +   struct device *dev = >dev;
> > +   struct vpu_run *run = >run;
> > +   const struct firmware *vpu_fw;
> > +   int ret;
> > +
> > +   if (!pdev) {
> > +   dev_err(dev, "VPU platform device is invalid\n");
> > +   return -EINVAL;
> > +   }
> > +
> > +   ret = vpu_clock_enable(vpu);
> > +   if (ret) {
> > +   dev_err(dev, "enable clock failed %d\n", ret);
> > +   return ret;
> > +   }
> > +
> > +   mutex_lock(>vpu_mutex);
> > +
> > +   if (vpu_running(vpu)) {
> > +   mutex_unlock(>vpu_mutex);
> > +   vpu_clock_disable(vpu);
> > +   dev_warn(dev, "vpu is running already\n");
> 
> This warning should be dropped. Currently vpu_load_firmware is called
> every time the video device is opened and no one else has the video device
> open. So calling this multiple times is perfectly normal and the log shouldn't
> be spammed with warnings.
> 
> I would recommend adding a fw_loaded bool to struct mtk_vpu and just
> check that at the beginning of this function and just return 0 if it is true.
> 
> Then you don't need to enable the vpu clock either.
> 
> I hope I understand the hw correctly, though.
> 
> Assuming you can do this, then this code from the v4l driver needs an
> additional comment:

We will change this in next version.

> 
> >>> + if (v4l2_fh_is_singular(>fh)) {
> 
> Add a comment here that says that vpu_load_firmware checks if it was
> loaded already and does nothing in that case.

We will change this in next version. Thanks

> 
> >>> + ret = vpu_load_firmware(dev->vpu_plat_dev);
> >>> + if (ret < 0) {
> >>> + /*
> >>> +   * Return 0 if downloading firmware successfully,
> >>> +   * otherwise it is failed
> >>> +   */
> >>> + mtk_v4l2_err("vpu_load_firmware failed!");
> >>> + goto err_load_fw;
> >>> + }
> 
> That makes it clear to the reader (i.e. me :-) ) that you can safely call
> vpu_load_firmware multiple times.
> 
> Regards,
> 
>   Hans
> 
> > +   return 0;
> > +   }
> > +
> > +   run->signaled = false;
> > +   dev_dbg(vpu->dev, "firmware request\n");
> > +   /* Downloading program firmware to device*/
> > +   ret = load_requested_vpu(vpu, vpu_fw, P_FW);
> > +   if (ret < 0) {
> > +   dev_err(dev, "Failed to request %s, %d\n", VPU_P_FW, ret);
> > +   goto OUT_LOAD_FW;
> > +   }
> > +
> > +   /* Downloading data firmware to device */
> > +   ret = load_requested_vpu(vpu, vpu_fw, D_FW);
> > +   if (ret < 0) {
> > +   dev_err(dev, "Failed to request %s, %d\n", VPU_D_FW, ret);
> > +   goto OUT_LOAD_FW;
> > +   }
> > +
> > +   /* boot up vpu */
> > +   vpu_cfg_writel(vpu, 0x1, VPU_RESET);
> > +
> > +   ret = wait_event_interruptible_timeout(run->wq,
> > +  run->signaled,
> > +  msecs_to_jiffies(INIT_TIMEOUT_MS)
> > +  );
> > +   if (ret == 0) {
> > +   ret = -ETIME;
> > +   dev_err(dev, "wait vpu initialization timout!\n");
> > +   goto OUT_LOAD_FW;
> > +   } else if (-ERESTARTSYS == ret) {
> > +   dev_err(dev, "wait vpu interrupted by a signal!\n");
> > +   goto OUT_LOAD_FW;
> > +   }
> > +
> > +   ret = 0;
> > +   dev_info(dev, "vpu is 

[GIT PULL FOR v4.7] Various fixes, remove most 'experimental' annotations

2016-04-25 Thread Hans Verkuil
Hi Mauro,

Here are various fixes for 4.7.

Note that I chose to go with my tw686x patches instead of yours
(https://patchwork.linuxtv.org/patch/33991/).

Probably more interesting is the removal of old 'experimental' annotations in
videodev2.h and DocBook. APIs that have been around for several years now were
still marked as experimental, which makes no sense after so long a time.

Regards,

Hans

The following changes since commit e07d46e7e0da86c146f199dae76f879096bc436a:

  [media] tpg: Export the tpg code from vivid as a module (2016-04-20 16:14:39 
-0300)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git for-v4.7c

for you to fetch changes up to 802d91c1804e3577984b6523e6428524b429035d:

  Documentation: video4linux: fix spelling mistakes (2016-04-25 11:04:39 +0200)


Dan Carpenter (1):
  cx231xx: silence uninitialized variable warning

Eric Engestrom (3):
  Documentation: dt: media: fix spelling mistake
  Documentation: DocBook: fix spelling mistake
  Documentation: video4linux: fix spelling mistakes

Hans Verkuil (8):
  tw686x: fix sparse warning
  tw686x-video: test for 60Hz instead of 50Hz
  videodev2.h: remove 'experimental' annotations.
  DocBook media: drop 'experimental' annotations
  adv7180: fix broken standards handling
  sta2x11_vip: fix s_std
  tc358743: drop bogus comment
  media/i2c/adv*: make controls inheritable instead of private

 Documentation/DocBook/media/dvb/net.xml  |   2 +-
 Documentation/DocBook/media/v4l/compat.xml   |  38 
--
 Documentation/DocBook/media/v4l/controls.xml |  31 

 Documentation/DocBook/media/v4l/dev-sdr.xml  |   6 --
 Documentation/DocBook/media/v4l/dev-subdev.xml   |   6 --
 Documentation/DocBook/media/v4l/io.xml   |   6 --
 Documentation/DocBook/media/v4l/selection-api.xml|   9 +--
 Documentation/DocBook/media/v4l/subdev-formats.xml   |   6 --
 Documentation/DocBook/media/v4l/vidioc-create-bufs.xml   |   6 --
 Documentation/DocBook/media/v4l/vidioc-dv-timings-cap.xml|   6 --
 Documentation/DocBook/media/v4l/vidioc-enum-dv-timings.xml   |   6 --
 Documentation/DocBook/media/v4l/vidioc-enum-freq-bands.xml   |   6 --
 Documentation/DocBook/media/v4l/vidioc-expbuf.xml|   6 --
 Documentation/DocBook/media/v4l/vidioc-g-selection.xml   |   6 --
 Documentation/DocBook/media/v4l/vidioc-prepare-buf.xml   |   6 --
 Documentation/DocBook/media/v4l/vidioc-query-dv-timings.xml  |   6 --
 .../DocBook/media/v4l/vidioc-subdev-enum-frame-interval.xml  |   6 --
 Documentation/DocBook/media/v4l/vidioc-subdev-enum-frame-size.xml|   6 --
 Documentation/DocBook/media/v4l/vidioc-subdev-enum-mbus-code.xml |   6 --
 Documentation/DocBook/media/v4l/vidioc-subdev-g-fmt.xml  |   6 --
 Documentation/DocBook/media/v4l/vidioc-subdev-g-frame-interval.xml   |   6 --
 Documentation/DocBook/media/v4l/vidioc-subdev-g-selection.xml|   6 --
 Documentation/devicetree/bindings/media/xilinx/video.txt |   2 +-
 Documentation/video4linux/vivid.txt  |   6 +-
 drivers/media/i2c/ad9389b.c  |   8 ---
 drivers/media/i2c/adv7180.c  | 118 
+--
 drivers/media/i2c/adv7511.c  |   6 --
 drivers/media/i2c/adv7604.c  |   8 ---
 drivers/media/i2c/adv7842.c  |   6 --
 drivers/media/i2c/tc358743.c |   1 -
 drivers/media/pci/sta2x11/sta2x11_vip.c  |  26 
+++
 drivers/media/pci/tw686x/tw686x-video.c  |  15 ++--
 drivers/media/usb/cx231xx/cx231xx-core.c |   3 +-
 include/uapi/linux/videodev2.h   |  38 
+++---
 34 files changed, 116 insertions(+), 309 deletions(-)
--
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] [media] v4l2-dv-timings.h: CEA-861-F 4K timings have positive sync polarities

2016-04-25 Thread Hans Verkuil
On 04/25/2016 10:51 AM, Martin Bugge wrote:
> Corrected sync polarities for CEA-861-F timings
> 3840x2160p24/25/30/50/60 and 4096x2160p24/25/30/50/60.

I posted this fix on Friday:

https://patchwork.linuxtv.org/patch/33963/

If you don't mind I'll go with that one.

Regards,

Hans

> 
> Cc: Hans Verkuil 
> Signed-off-by: Martin Bugge 
> ---
>  include/uapi/linux/v4l2-dv-timings.h | 30 --
>  1 file changed, 20 insertions(+), 10 deletions(-)
> 
> diff --git a/include/uapi/linux/v4l2-dv-timings.h 
> b/include/uapi/linux/v4l2-dv-timings.h
> index c039f1d..086168e 100644
> --- a/include/uapi/linux/v4l2-dv-timings.h
> +++ b/include/uapi/linux/v4l2-dv-timings.h
> @@ -183,7 +183,8 @@
>  
>  #define V4L2_DV_BT_CEA_3840X2160P24 { \
>   .type = V4L2_DV_BT_656_1120, \
> - V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
> + V4L2_INIT_BT_TIMINGS(3840, 2160, 0, \
> + V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
>   29700, 1276, 88, 296, 8, 10, 72, 0, 0, 0, \
>   V4L2_DV_BT_STD_CEA861, \
>   V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
> @@ -191,14 +192,16 @@
>  
>  #define V4L2_DV_BT_CEA_3840X2160P25 { \
>   .type = V4L2_DV_BT_656_1120, \
> - V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
> + V4L2_INIT_BT_TIMINGS(3840, 2160, 0, \
> + V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
>   29700, 1056, 88, 296, 8, 10, 72, 0, 0, 0, \
>   V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \
>  }
>  
>  #define V4L2_DV_BT_CEA_3840X2160P30 { \
>   .type = V4L2_DV_BT_656_1120, \
> - V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
> + V4L2_INIT_BT_TIMINGS(3840, 2160, 0, \
> + V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
>   29700, 176, 88, 296, 8, 10, 72, 0, 0, 0, \
>   V4L2_DV_BT_STD_CEA861, \
>   V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
> @@ -206,14 +209,16 @@
>  
>  #define V4L2_DV_BT_CEA_3840X2160P50 { \
>   .type = V4L2_DV_BT_656_1120, \
> - V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
> + V4L2_INIT_BT_TIMINGS(3840, 2160, 0, \
> + V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
>   59400, 1056, 88, 296, 8, 10, 72, 0, 0, 0, \
>   V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \
>  }
>  
>  #define V4L2_DV_BT_CEA_3840X2160P60 { \
>   .type = V4L2_DV_BT_656_1120, \
> - V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
> + V4L2_INIT_BT_TIMINGS(3840, 2160, 0, \
> + V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
>   59400, 176, 88, 296, 8, 10, 72, 0, 0, 0, \
>   V4L2_DV_BT_STD_CEA861, \
>   V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
> @@ -221,7 +226,8 @@
>  
>  #define V4L2_DV_BT_CEA_4096X2160P24 { \
>   .type = V4L2_DV_BT_656_1120, \
> - V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
> + V4L2_INIT_BT_TIMINGS(4096, 2160, 0, \
> + V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
>   29700, 1020, 88, 296, 8, 10, 72, 0, 0, 0, \
>   V4L2_DV_BT_STD_CEA861, \
>   V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
> @@ -229,14 +235,16 @@
>  
>  #define V4L2_DV_BT_CEA_4096X2160P25 { \
>   .type = V4L2_DV_BT_656_1120, \
> - V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
> + V4L2_INIT_BT_TIMINGS(4096, 2160, 0, \
> + V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
>   29700, 968, 88, 128, 8, 10, 72, 0, 0, 0, \
>   V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \
>  }
>  
>  #define V4L2_DV_BT_CEA_4096X2160P30 { \
>   .type = V4L2_DV_BT_656_1120, \
> - V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
> + V4L2_INIT_BT_TIMINGS(4096, 2160, 0, \
> + V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
>   29700, 88, 88, 128, 8, 10, 72, 0, 0, 0, \
>   V4L2_DV_BT_STD_CEA861, \
>   V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
> @@ -244,14 +252,16 @@
>  
>  #define V4L2_DV_BT_CEA_4096X2160P50 { \
>   .type = V4L2_DV_BT_656_1120, \
> - V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
> + V4L2_INIT_BT_TIMINGS(4096, 2160, 0, \
> + V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
>   59400, 968, 88, 128, 8, 10, 72, 0, 0, 0, \
>   V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \
>  }
>  
>  #define V4L2_DV_BT_CEA_4096X2160P60 { \
>   .type = V4L2_DV_BT_656_1120, \
> - V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
> + V4L2_INIT_BT_TIMINGS(4096, 2160, 0, \
> + V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
>   59400, 88, 88, 128, 8, 10, 

[PATCH v4] media: vb2: Fix regression on poll() for RW mode

2016-04-25 Thread Ricardo Ribalda Delgado
When using a device is read/write mode, vb2 does not handle properly the
first select/poll operation.

The reason for this, is that when this code has been refactored, some of
the operations have changed their order, and now fileio emulator is not
started.

The reintroduced check to the core is enabled by a quirk flag, that
avoids this check by other subsystems like DVB.

Reported-by: Dimitrios Katsaros 
Cc: Junghak Sung 
Fixes: 49d8ab9feaf2 ("media] media: videobuf2: Separate vb2_poll()")
Cc: sta...@vger.kernel.org
Signed-off-by: Ricardo Ribalda Delgado 
---

v4: Reported by Hans
   Rewrite comments
Thanks!


 drivers/media/v4l2-core/videobuf2-core.c | 10 ++
 drivers/media/v4l2-core/videobuf2-v4l2.c | 14 ++
 include/media/videobuf2-core.h   |  4 
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 5d016f496e0e..6b3a81504a7a 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -2298,6 +2298,16 @@ unsigned int vb2_core_poll(struct vb2_queue *q, struct 
file *file,
return POLLERR;
 
/*
+* If this quirk is set and QBUF hasn't been called yet then
+* return POLLERR as well. This only affects capture queues, output
+* queues will always initialize waiting_for_buffers to false.
+* This quirk is set by V4L2 for backwards compatibility reasons.
+*/
+   if (q->quirk_poll_must_check_waiting_for_buffers &&
+   q->waiting_for_buffers && (req_events & (POLLIN | POLLRDNORM)))
+   return POLLERR;
+
+   /*
 * For output streams you can call write() as long as there are fewer
 * buffers queued than there are buffers available.
 */
diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c 
b/drivers/media/v4l2-core/videobuf2-v4l2.c
index 91f552124050..0b1b8c7b6ce5 100644
--- a/drivers/media/v4l2-core/videobuf2-v4l2.c
+++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
@@ -765,6 +765,12 @@ int vb2_queue_init(struct vb2_queue *q)
q->is_output = V4L2_TYPE_IS_OUTPUT(q->type);
q->copy_timestamp = (q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK)
== V4L2_BUF_FLAG_TIMESTAMP_COPY;
+   /*
+* For compatibility with vb1: if QBUF hasn't been called yet, then
+* return POLLERR as well. This only affects capture queues, output
+* queues will always initialize waiting_for_buffers to false.
+*/
+   q->quirk_poll_must_check_waiting_for_buffers = true;
 
return vb2_core_queue_init(q);
 }
@@ -818,14 +824,6 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file 
*file, poll_table *wait)
poll_wait(file, >wait, wait);
}
 
-   /*
-* For compatibility with vb1: if QBUF hasn't been called yet, then
-* return POLLERR as well. This only affects capture queues, output
-* queues will always initialize waiting_for_buffers to false.
-*/
-   if (q->waiting_for_buffers && (req_events & (POLLIN | POLLRDNORM)))
-   return POLLERR;
-
return res | vb2_core_poll(q, file, wait);
 }
 EXPORT_SYMBOL_GPL(vb2_poll);
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index 8a0f55b6c2ba..3a1620946068 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -400,6 +400,9 @@ struct vb2_buf_ops {
  * @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
+ * @quirk_poll_must_check_waiting_for_buffers: Return POLLERR at poll when QBUF
+ *  has not been called. This is a vb1 idiom that has been adopted
+ *  also by vb2.
  * @lock:  pointer to a mutex that protects the vb2_queue struct. The
  * driver can set this to a mutex to let the v4l2 core serialize
  * the queuing ioctls. If the driver wants to handle locking
@@ -463,6 +466,7 @@ struct vb2_queue {
unsignedfileio_read_once:1;
unsignedfileio_write_immediately:1;
unsignedallow_zero_bytesused:1;
+   unsigned   quirk_poll_must_check_waiting_for_buffers:1;
 
struct mutex*lock;
void*owner;
-- 
2.8.0.rc3

--
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


[PATCH] [media] v4l2-dv-timings.h: CEA-861-F 4K timings have positive sync polarities

2016-04-25 Thread Martin Bugge
Corrected sync polarities for CEA-861-F timings
3840x2160p24/25/30/50/60 and 4096x2160p24/25/30/50/60.

Cc: Hans Verkuil 
Signed-off-by: Martin Bugge 
---
 include/uapi/linux/v4l2-dv-timings.h | 30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/include/uapi/linux/v4l2-dv-timings.h 
b/include/uapi/linux/v4l2-dv-timings.h
index c039f1d..086168e 100644
--- a/include/uapi/linux/v4l2-dv-timings.h
+++ b/include/uapi/linux/v4l2-dv-timings.h
@@ -183,7 +183,8 @@
 
 #define V4L2_DV_BT_CEA_3840X2160P24 { \
.type = V4L2_DV_BT_656_1120, \
-   V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
+   V4L2_INIT_BT_TIMINGS(3840, 2160, 0, \
+   V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
29700, 1276, 88, 296, 8, 10, 72, 0, 0, 0, \
V4L2_DV_BT_STD_CEA861, \
V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
@@ -191,14 +192,16 @@
 
 #define V4L2_DV_BT_CEA_3840X2160P25 { \
.type = V4L2_DV_BT_656_1120, \
-   V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
+   V4L2_INIT_BT_TIMINGS(3840, 2160, 0, \
+   V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
29700, 1056, 88, 296, 8, 10, 72, 0, 0, 0, \
V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \
 }
 
 #define V4L2_DV_BT_CEA_3840X2160P30 { \
.type = V4L2_DV_BT_656_1120, \
-   V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
+   V4L2_INIT_BT_TIMINGS(3840, 2160, 0, \
+   V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
29700, 176, 88, 296, 8, 10, 72, 0, 0, 0, \
V4L2_DV_BT_STD_CEA861, \
V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
@@ -206,14 +209,16 @@
 
 #define V4L2_DV_BT_CEA_3840X2160P50 { \
.type = V4L2_DV_BT_656_1120, \
-   V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
+   V4L2_INIT_BT_TIMINGS(3840, 2160, 0, \
+   V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
59400, 1056, 88, 296, 8, 10, 72, 0, 0, 0, \
V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \
 }
 
 #define V4L2_DV_BT_CEA_3840X2160P60 { \
.type = V4L2_DV_BT_656_1120, \
-   V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
+   V4L2_INIT_BT_TIMINGS(3840, 2160, 0, \
+   V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
59400, 176, 88, 296, 8, 10, 72, 0, 0, 0, \
V4L2_DV_BT_STD_CEA861, \
V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
@@ -221,7 +226,8 @@
 
 #define V4L2_DV_BT_CEA_4096X2160P24 { \
.type = V4L2_DV_BT_656_1120, \
-   V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
+   V4L2_INIT_BT_TIMINGS(4096, 2160, 0, \
+   V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
29700, 1020, 88, 296, 8, 10, 72, 0, 0, 0, \
V4L2_DV_BT_STD_CEA861, \
V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
@@ -229,14 +235,16 @@
 
 #define V4L2_DV_BT_CEA_4096X2160P25 { \
.type = V4L2_DV_BT_656_1120, \
-   V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
+   V4L2_INIT_BT_TIMINGS(4096, 2160, 0, \
+   V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
29700, 968, 88, 128, 8, 10, 72, 0, 0, 0, \
V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \
 }
 
 #define V4L2_DV_BT_CEA_4096X2160P30 { \
.type = V4L2_DV_BT_656_1120, \
-   V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
+   V4L2_INIT_BT_TIMINGS(4096, 2160, 0, \
+   V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
29700, 88, 88, 128, 8, 10, 72, 0, 0, 0, \
V4L2_DV_BT_STD_CEA861, \
V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
@@ -244,14 +252,16 @@
 
 #define V4L2_DV_BT_CEA_4096X2160P50 { \
.type = V4L2_DV_BT_656_1120, \
-   V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
+   V4L2_INIT_BT_TIMINGS(4096, 2160, 0, \
+   V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
59400, 968, 88, 128, 8, 10, 72, 0, 0, 0, \
V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \
 }
 
 #define V4L2_DV_BT_CEA_4096X2160P60 { \
.type = V4L2_DV_BT_656_1120, \
-   V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
+   V4L2_INIT_BT_TIMINGS(4096, 2160, 0, \
+   V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, \
59400, 88, 88, 128, 8, 10, 72, 0, 0, 0, \
V4L2_DV_BT_STD_CEA861, \
V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
-- 
2.4.11

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

Re: [PATCH v2] media: vb2: Fix regression on poll() for RW mode

2016-04-25 Thread Hans Verkuil
On 04/25/2016 10:39 AM, Hans Verkuil wrote:
> On 04/25/2016 09:59 AM, Ricardo Ribalda Delgado wrote:
>> When using a device is read/write mode, vb2 does not handle properly the
>> first select/poll operation.
>>
>> The reason for this, is that when this code has been refactored, some of
>> the operations have changed their order, and now fileio emulator is not
>> started.
>>
>> The reintroduced check to the core is enabled by a quirk flag, that
>> avoids this check by other subsystems like DVB.
>>
>> Reported-by: Dimitrios Katsaros 
>> Cc: Junghak Sung 
>> Fixes: 49d8ab9feaf2 ("media] media: videobuf2: Separate vb2_poll()")
>> Cc: sta...@vger.kernel.org
>> Signed-off-by: Ricardo Ribalda Delgado 
>> ---
>>
>> v2: By  Hans Verkuil  and
>>  Mauro Carvalho Chehab :
>>
>>  Add a quirk bit to enable this behaviour on the core.
>>  drivers/media/v4l2-core/videobuf2-core.c | 9 +
>>  drivers/media/v4l2-core/videobuf2-v4l2.c | 9 +
>>  include/media/videobuf2-core.h   | 4 
>>  3 files changed, 14 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
>> b/drivers/media/v4l2-core/videobuf2-core.c
>> index 5d016f496e0e..58eb9be13510 100644
>> --- a/drivers/media/v4l2-core/videobuf2-core.c
>> +++ b/drivers/media/v4l2-core/videobuf2-core.c
>> @@ -2298,6 +2298,15 @@ unsigned int vb2_core_poll(struct vb2_queue *q, 
>> struct file *file,
>>  return POLLERR;
>>  
>>  /*
>> + * For compatibility with vb1: if QBUF hasn't been called yet, then
>> + * return POLLERR as well. This only affects capture queues, output
>> + * queues will always initialize waiting_for_buffers to false.
>> + */
> 
> This comment should be moved to where the quirk is set in v4l2. This comment 
> shouldn't
> refer to vb2 at all. How about:

I'm sorry, I realize I was quite confusing here. I should have said:

"This comment should be copied to where the quirk is set in v4l2. This comment 
here
in core.c shouldn't refer to vb1 at all. How about:"

So in both places (here and in v4l2.c) there should be a comment.

Can you make a v4? Ask on irc if something is still unclear.

Hans

> 
> "If this quirk is set and if QBUF hasn't been called..."
> 
> and perhaps at the end of the comment:
> 
> "This quirk is set by V4L2 for backwards compatibility reasons."
> 
> although I am not completely certain we need that at all here.
> 
>> +if (q->quirk_poll_must_check_waiting_for_buffers &&
>> +q->waiting_for_buffers && (req_events & (POLLIN | POLLRDNORM)))
>> +return POLLERR;
>> +
>> +/*
>>   * For output streams you can call write() as long as there are fewer
>>   * buffers queued than there are buffers available.
>>   */
>> diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c 
>> b/drivers/media/v4l2-core/videobuf2-v4l2.c
>> index 91f552124050..3e649adf85ef 100644
>> --- a/drivers/media/v4l2-core/videobuf2-v4l2.c
>> +++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
>> @@ -765,6 +765,7 @@ int vb2_queue_init(struct vb2_queue *q)
>>  q->is_output = V4L2_TYPE_IS_OUTPUT(q->type);
>>  q->copy_timestamp = (q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK)
>>  == V4L2_BUF_FLAG_TIMESTAMP_COPY;
>> +q->quirk_poll_must_check_waiting_for_buffers = true;
>>  
>>  return vb2_core_queue_init(q);
>>  }
>> @@ -818,14 +819,6 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file 
>> *file, poll_table *wait)
>>  poll_wait(file, >wait, wait);
>>  }
>>  
>> -/*
>> - * For compatibility with vb1: if QBUF hasn't been called yet, then
>> - * return POLLERR as well. This only affects capture queues, output
>> - * queues will always initialize waiting_for_buffers to false.
>> - */
>> -if (q->waiting_for_buffers && (req_events & (POLLIN | POLLRDNORM)))
>> -return POLLERR;
>> -
>>  return res | vb2_core_poll(q, file, wait);
>>  }
>>  EXPORT_SYMBOL_GPL(vb2_poll);
>> diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
>> index 8a0f55b6c2ba..3a1620946068 100644
>> --- a/include/media/videobuf2-core.h
>> +++ b/include/media/videobuf2-core.h
>> @@ -400,6 +400,9 @@ struct vb2_buf_ops {
>>   * @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
>> + * @quirk_poll_must_check_waiting_for_buffers: Return POLLERR at poll when 
>> QBUF
>> + *  has not been called. This is a vb1 idiom that has been 
>> adopted
>> + *  also by vb2.
>>   * @lock:   pointer to a mutex that protects the vb2_queue struct. The
>>   *  driver can set this to a mutex to let the v4l2 core serialize
>>   *  the queuing 

[PATCH v3] media: vb2: Fix regression on poll() for RW mode

2016-04-25 Thread Ricardo Ribalda Delgado
When using a device is read/write mode, vb2 does not handle properly the
first select/poll operation.

The reason for this, is that when this code has been refactored, some of
the operations have changed their order, and now fileio emulator is not
started.

The reintroduced check to the core is enabled by a quirk flag, that
avoids this check by other subsystems like DVB.

Reported-by: Dimitrios Katsaros 
Cc: Junghak Sung 
Fixes: 49d8ab9feaf2 ("media] media: videobuf2: Separate vb2_poll()")
Cc: sta...@vger.kernel.org
Signed-off-by: Ricardo Ribalda Delgado 
---

v3: By  Hans Verkuil 

Reorder comment.

 drivers/media/v4l2-core/videobuf2-core.c |  4 
 drivers/media/v4l2-core/videobuf2-v4l2.c | 15 +++
 include/media/videobuf2-core.h   |  4 
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 5d016f496e0e..05ad744504ce 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -2297,6 +2297,10 @@ unsigned int vb2_core_poll(struct vb2_queue *q, struct 
file *file,
if (!vb2_is_streaming(q) || q->error)
return POLLERR;
 
+   if (q->quirk_poll_must_check_waiting_for_buffers &&
+   q->waiting_for_buffers && (req_events & (POLLIN | POLLRDNORM)))
+   return POLLERR;
+
/*
 * For output streams you can call write() as long as there are fewer
 * buffers queued than there are buffers available.
diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c 
b/drivers/media/v4l2-core/videobuf2-v4l2.c
index 91f552124050..e46754b5610e 100644
--- a/drivers/media/v4l2-core/videobuf2-v4l2.c
+++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
@@ -765,6 +765,13 @@ int vb2_queue_init(struct vb2_queue *q)
q->is_output = V4L2_TYPE_IS_OUTPUT(q->type);
q->copy_timestamp = (q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK)
== V4L2_BUF_FLAG_TIMESTAMP_COPY;
+   /*
+* If this quirk is set and QBUF hasn't been called yet then
+* return POLLERR as well. This only affects capture queues, output
+* queues will always initialize waiting_for_buffers to false.
+* This quirk is set by V4L2 for backwards compatibility reasons.
+*/
+   q->quirk_poll_must_check_waiting_for_buffers = true;
 
return vb2_core_queue_init(q);
 }
@@ -818,14 +825,6 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file 
*file, poll_table *wait)
poll_wait(file, >wait, wait);
}
 
-   /*
-* For compatibility with vb1: if QBUF hasn't been called yet, then
-* return POLLERR as well. This only affects capture queues, output
-* queues will always initialize waiting_for_buffers to false.
-*/
-   if (q->waiting_for_buffers && (req_events & (POLLIN | POLLRDNORM)))
-   return POLLERR;
-
return res | vb2_core_poll(q, file, wait);
 }
 EXPORT_SYMBOL_GPL(vb2_poll);
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index 8a0f55b6c2ba..3a1620946068 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -400,6 +400,9 @@ struct vb2_buf_ops {
  * @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
+ * @quirk_poll_must_check_waiting_for_buffers: Return POLLERR at poll when QBUF
+ *  has not been called. This is a vb1 idiom that has been adopted
+ *  also by vb2.
  * @lock:  pointer to a mutex that protects the vb2_queue struct. The
  * driver can set this to a mutex to let the v4l2 core serialize
  * the queuing ioctls. If the driver wants to handle locking
@@ -463,6 +466,7 @@ struct vb2_queue {
unsignedfileio_read_once:1;
unsignedfileio_write_immediately:1;
unsignedallow_zero_bytesused:1;
+   unsigned   quirk_poll_must_check_waiting_for_buffers:1;
 
struct mutex*lock;
void*owner;
-- 
2.8.0.rc3

--
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 v2] media: vb2: Fix regression on poll() for RW mode

2016-04-25 Thread Hans Verkuil
On 04/25/2016 09:59 AM, Ricardo Ribalda Delgado wrote:
> When using a device is read/write mode, vb2 does not handle properly the
> first select/poll operation.
> 
> The reason for this, is that when this code has been refactored, some of
> the operations have changed their order, and now fileio emulator is not
> started.
> 
> The reintroduced check to the core is enabled by a quirk flag, that
> avoids this check by other subsystems like DVB.
> 
> Reported-by: Dimitrios Katsaros 
> Cc: Junghak Sung 
> Fixes: 49d8ab9feaf2 ("media] media: videobuf2: Separate vb2_poll()")
> Cc: sta...@vger.kernel.org
> Signed-off-by: Ricardo Ribalda Delgado 
> ---
> 
> v2: By  Hans Verkuil  and
>   Mauro Carvalho Chehab :
> 
>   Add a quirk bit to enable this behaviour on the core.
>  drivers/media/v4l2-core/videobuf2-core.c | 9 +
>  drivers/media/v4l2-core/videobuf2-v4l2.c | 9 +
>  include/media/videobuf2-core.h   | 4 
>  3 files changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
> b/drivers/media/v4l2-core/videobuf2-core.c
> index 5d016f496e0e..58eb9be13510 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -2298,6 +2298,15 @@ unsigned int vb2_core_poll(struct vb2_queue *q, struct 
> file *file,
>   return POLLERR;
>  
>   /*
> +  * For compatibility with vb1: if QBUF hasn't been called yet, then
> +  * return POLLERR as well. This only affects capture queues, output
> +  * queues will always initialize waiting_for_buffers to false.
> +  */

This comment should be moved to where the quirk is set in v4l2. This comment 
shouldn't
refer to vb2 at all. How about:

"If this quirk is set and if QBUF hasn't been called..."

and perhaps at the end of the comment:

"This quirk is set by V4L2 for backwards compatibility reasons."

although I am not completely certain we need that at all here.

> + if (q->quirk_poll_must_check_waiting_for_buffers &&
> + q->waiting_for_buffers && (req_events & (POLLIN | POLLRDNORM)))
> + return POLLERR;
> +
> + /*
>* For output streams you can call write() as long as there are fewer
>* buffers queued than there are buffers available.
>*/
> diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c 
> b/drivers/media/v4l2-core/videobuf2-v4l2.c
> index 91f552124050..3e649adf85ef 100644
> --- a/drivers/media/v4l2-core/videobuf2-v4l2.c
> +++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
> @@ -765,6 +765,7 @@ int vb2_queue_init(struct vb2_queue *q)
>   q->is_output = V4L2_TYPE_IS_OUTPUT(q->type);
>   q->copy_timestamp = (q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK)
>   == V4L2_BUF_FLAG_TIMESTAMP_COPY;
> + q->quirk_poll_must_check_waiting_for_buffers = true;
>  
>   return vb2_core_queue_init(q);
>  }
> @@ -818,14 +819,6 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file 
> *file, poll_table *wait)
>   poll_wait(file, >wait, wait);
>   }
>  
> - /*
> -  * For compatibility with vb1: if QBUF hasn't been called yet, then
> -  * return POLLERR as well. This only affects capture queues, output
> -  * queues will always initialize waiting_for_buffers to false.
> -  */
> - if (q->waiting_for_buffers && (req_events & (POLLIN | POLLRDNORM)))
> - return POLLERR;
> -
>   return res | vb2_core_poll(q, file, wait);
>  }
>  EXPORT_SYMBOL_GPL(vb2_poll);
> diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
> index 8a0f55b6c2ba..3a1620946068 100644
> --- a/include/media/videobuf2-core.h
> +++ b/include/media/videobuf2-core.h
> @@ -400,6 +400,9 @@ struct vb2_buf_ops {
>   * @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
> + * @quirk_poll_must_check_waiting_for_buffers: Return POLLERR at poll when 
> QBUF
> + *  has not been called. This is a vb1 idiom that has been 
> adopted
> + *  also by vb2.
>   * @lock:pointer to a mutex that protects the vb2_queue struct. The
>   *   driver can set this to a mutex to let the v4l2 core serialize
>   *   the queuing ioctls. If the driver wants to handle locking
> @@ -463,6 +466,7 @@ struct vb2_queue {
>   unsignedfileio_read_once:1;
>   unsignedfileio_write_immediately:1;
>   unsignedallow_zero_bytesused:1;
> + unsigned   quirk_poll_must_check_waiting_for_buffers:1;
>  
>   struct mutex*lock;
>   void*owner;
> 

Regards,


Re: [PATCH 03/13] v4l: vsp1: Implement runtime PM support

2016-04-25 Thread Geert Uytterhoeven
On Sun, Apr 24, 2016 at 1:49 AM, Laurent Pinchart
 wrote:
> Replace the manual refcount and clock management code by runtime PM.
>
> Signed-off-by: Laurent Pinchart 
> ---
>  drivers/media/platform/Kconfig  |   1 +
>  drivers/media/platform/vsp1/vsp1.h  |   3 -
>  drivers/media/platform/vsp1/vsp1_drv.c  | 101 
> 
>  drivers/media/platform/vsp1/vsp1_pipe.c |   2 +-
>  4 files changed, 54 insertions(+), 53 deletions(-)
>
> diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
> index f453910050be..28d0db102c0b 100644
> --- a/drivers/media/platform/Kconfig
> +++ b/drivers/media/platform/Kconfig
> @@ -264,6 +264,7 @@ config VIDEO_RENESAS_VSP1
> tristate "Renesas VSP1 Video Processing Engine"
> depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && HAS_DMA
> depends on (ARCH_RENESAS && OF) || COMPILE_TEST
> +   depends on PM

PM is always enabled since commits 2ee98234b88174f2 ("arm64: renesas: Enable PM
and PM_GENERIC_DOMAINS for SoCs with PM Domains") and 71d076ceb245f0d9 ("ARM:
shmobile: Enable PM and PM_GENERIC_DOMAINS for SoCs with PM Domains").

Even before that, drivers/sh/pm_runtime.c would have taken care of
enabling the clocks for you.

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
--
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


[PATCH v2] media: vb2: Fix regression on poll() for RW mode

2016-04-25 Thread Ricardo Ribalda Delgado
When using a device is read/write mode, vb2 does not handle properly the
first select/poll operation.

The reason for this, is that when this code has been refactored, some of
the operations have changed their order, and now fileio emulator is not
started.

The reintroduced check to the core is enabled by a quirk flag, that
avoids this check by other subsystems like DVB.

Reported-by: Dimitrios Katsaros 
Cc: Junghak Sung 
Fixes: 49d8ab9feaf2 ("media] media: videobuf2: Separate vb2_poll()")
Cc: sta...@vger.kernel.org
Signed-off-by: Ricardo Ribalda Delgado 
---

v2: By  Hans Verkuil  and
Mauro Carvalho Chehab :

Add a quirk bit to enable this behaviour on the core.
 drivers/media/v4l2-core/videobuf2-core.c | 9 +
 drivers/media/v4l2-core/videobuf2-v4l2.c | 9 +
 include/media/videobuf2-core.h   | 4 
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 5d016f496e0e..58eb9be13510 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -2298,6 +2298,15 @@ unsigned int vb2_core_poll(struct vb2_queue *q, struct 
file *file,
return POLLERR;
 
/*
+* For compatibility with vb1: if QBUF hasn't been called yet, then
+* return POLLERR as well. This only affects capture queues, output
+* queues will always initialize waiting_for_buffers to false.
+*/
+   if (q->quirk_poll_must_check_waiting_for_buffers &&
+   q->waiting_for_buffers && (req_events & (POLLIN | POLLRDNORM)))
+   return POLLERR;
+
+   /*
 * For output streams you can call write() as long as there are fewer
 * buffers queued than there are buffers available.
 */
diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c 
b/drivers/media/v4l2-core/videobuf2-v4l2.c
index 91f552124050..3e649adf85ef 100644
--- a/drivers/media/v4l2-core/videobuf2-v4l2.c
+++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
@@ -765,6 +765,7 @@ int vb2_queue_init(struct vb2_queue *q)
q->is_output = V4L2_TYPE_IS_OUTPUT(q->type);
q->copy_timestamp = (q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK)
== V4L2_BUF_FLAG_TIMESTAMP_COPY;
+   q->quirk_poll_must_check_waiting_for_buffers = true;
 
return vb2_core_queue_init(q);
 }
@@ -818,14 +819,6 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file 
*file, poll_table *wait)
poll_wait(file, >wait, wait);
}
 
-   /*
-* For compatibility with vb1: if QBUF hasn't been called yet, then
-* return POLLERR as well. This only affects capture queues, output
-* queues will always initialize waiting_for_buffers to false.
-*/
-   if (q->waiting_for_buffers && (req_events & (POLLIN | POLLRDNORM)))
-   return POLLERR;
-
return res | vb2_core_poll(q, file, wait);
 }
 EXPORT_SYMBOL_GPL(vb2_poll);
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index 8a0f55b6c2ba..3a1620946068 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -400,6 +400,9 @@ struct vb2_buf_ops {
  * @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
+ * @quirk_poll_must_check_waiting_for_buffers: Return POLLERR at poll when QBUF
+ *  has not been called. This is a vb1 idiom that has been adopted
+ *  also by vb2.
  * @lock:  pointer to a mutex that protects the vb2_queue struct. The
  * driver can set this to a mutex to let the v4l2 core serialize
  * the queuing ioctls. If the driver wants to handle locking
@@ -463,6 +466,7 @@ struct vb2_queue {
unsignedfileio_read_once:1;
unsignedfileio_write_immediately:1;
unsignedallow_zero_bytesused:1;
+   unsigned   quirk_poll_must_check_waiting_for_buffers:1;
 
struct mutex*lock;
void*owner;
-- 
2.8.0.rc3

--
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 v7 2/8] [media] VPU: mediatek: support Mediatek VPU

2016-04-25 Thread Hans Verkuil
On 04/22/2016 06:25 AM, Tiffany Lin wrote:
> From: Andrew-CT Chen 
> 
> The VPU driver for hw video codec embedded in Mediatek's MT8173 SOCs.
> It is able to handle video decoding/encoding of in a range of formats.
> The driver provides with VPU firmware download, memory management and
> the communication interface between CPU and VPU.
> For VPU initialization, it will create virtual memory for CPU access and
> IOMMU address for vcodec hw device access. When a decode/encode instance
> opens a device node, vpu driver will download vpu firmware to the device.
> A decode/encode instant will decode/encode a frame using VPU
> interface to interrupt vpu to handle decoding/encoding jobs.
> 
> Signed-off-by: Andrew-CT Chen 
> Signed-off-by: Tiffany Lin 
> 
> ---
>  drivers/media/platform/Kconfig   |   13 +
>  drivers/media/platform/Makefile  |2 +
>  drivers/media/platform/mtk-vpu/Makefile  |3 +
>  drivers/media/platform/mtk-vpu/mtk_vpu.c |  950 
> ++
>  drivers/media/platform/mtk-vpu/mtk_vpu.h |  162 +
>  5 files changed, 1130 insertions(+)
>  create mode 100644 drivers/media/platform/mtk-vpu/Makefile
>  create mode 100755 drivers/media/platform/mtk-vpu/mtk_vpu.c
>  create mode 100644 drivers/media/platform/mtk-vpu/mtk_vpu.h
> 


> +int vpu_load_firmware(struct platform_device *pdev)
> +{
> + struct mtk_vpu *vpu = platform_get_drvdata(pdev);
> + struct device *dev = >dev;
> + struct vpu_run *run = >run;
> + const struct firmware *vpu_fw;
> + int ret;
> +
> + if (!pdev) {
> + dev_err(dev, "VPU platform device is invalid\n");
> + return -EINVAL;
> + }
> +
> + ret = vpu_clock_enable(vpu);
> + if (ret) {
> + dev_err(dev, "enable clock failed %d\n", ret);
> + return ret;
> + }
> +
> + mutex_lock(>vpu_mutex);
> +
> + if (vpu_running(vpu)) {
> + mutex_unlock(>vpu_mutex);
> + vpu_clock_disable(vpu);
> + dev_warn(dev, "vpu is running already\n");

This warning should be dropped. Currently vpu_load_firmware is called
every time the video device is opened and no one else has the video device
open. So calling this multiple times is perfectly normal and the log shouldn't
be spammed with warnings.

I would recommend adding a fw_loaded bool to struct mtk_vpu and just
check that at the beginning of this function and just return 0 if it is true.

Then you don't need to enable the vpu clock either.

I hope I understand the hw correctly, though.

Assuming you can do this, then this code from the v4l driver needs an
additional comment:

>>> +   if (v4l2_fh_is_singular(>fh)) {

Add a comment here that says that vpu_load_firmware checks if it was
loaded already and does nothing in that case.

>>> +   ret = vpu_load_firmware(dev->vpu_plat_dev);
>>> +   if (ret < 0) {
>>> +   /*
>>> + * Return 0 if downloading firmware successfully,
>>> + * otherwise it is failed
>>> + */
>>> +   mtk_v4l2_err("vpu_load_firmware failed!");
>>> +   goto err_load_fw;
>>> +   }

That makes it clear to the reader (i.e. me :-) ) that you can safely call
vpu_load_firmware multiple times.

Regards,

Hans

> + return 0;
> + }
> +
> + run->signaled = false;
> + dev_dbg(vpu->dev, "firmware request\n");
> + /* Downloading program firmware to device*/
> + ret = load_requested_vpu(vpu, vpu_fw, P_FW);
> + if (ret < 0) {
> + dev_err(dev, "Failed to request %s, %d\n", VPU_P_FW, ret);
> + goto OUT_LOAD_FW;
> + }
> +
> + /* Downloading data firmware to device */
> + ret = load_requested_vpu(vpu, vpu_fw, D_FW);
> + if (ret < 0) {
> + dev_err(dev, "Failed to request %s, %d\n", VPU_D_FW, ret);
> + goto OUT_LOAD_FW;
> + }
> +
> + /* boot up vpu */
> + vpu_cfg_writel(vpu, 0x1, VPU_RESET);
> +
> + ret = wait_event_interruptible_timeout(run->wq,
> +run->signaled,
> +msecs_to_jiffies(INIT_TIMEOUT_MS)
> +);
> + if (ret == 0) {
> + ret = -ETIME;
> + dev_err(dev, "wait vpu initialization timout!\n");
> + goto OUT_LOAD_FW;
> + } else if (-ERESTARTSYS == ret) {
> + dev_err(dev, "wait vpu interrupted by a signal!\n");
> + goto OUT_LOAD_FW;
> + }
> +
> + ret = 0;
> + dev_info(dev, "vpu is ready. Fw version %s\n", run->fw_ver);
> +
> +OUT_LOAD_FW:
> + mutex_unlock(>vpu_mutex);
> + vpu_clock_disable(vpu);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(vpu_load_firmware);

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the 

Re: [PATCH 02/13] v4l: Add Renesas R-Car FCP driver

2016-04-25 Thread Geert Uytterhoeven
Hi Laurent,

On Sun, Apr 24, 2016 at 1:49 AM, Laurent Pinchart
 wrote:
> The FCP is a companion module of video processing modules in the
> Renesas R-Car Gen3 SoCs. It provides data compression and decompression,
> data caching, and conversion of AXI transaction in order to reduce the

transactions

> memory bandwidth.

> --- /dev/null
> +++ b/drivers/media/platform/rcar-fcp.c
> @@ -0,0 +1,176 @@

> +/**
> + * rcar_fcp_enable - Enable an FCP
> + * @fcp: The FCP instance
> + *
> + * Before any memory access through an FCP is performed by a module, the FCP
> + * must be enabled by a call to this function. The enable calls are reference
> + * counted, each of them must be followed by one rcar_fcp_disable() call when
> + * no more memory transfer can occur through the FCP.
> + */
> +void rcar_fcp_enable(struct rcar_fcp_device *fcp)
> +{
> +   if (fcp)
> +   pm_runtime_get_sync(fcp->dev);

Given pm_runtime_get_sync() returns an error code (which is usually just
ignored), perhaps you want to forward that?

> +}
> +EXPORT_SYMBOL_GPL(rcar_fcp_enable);

Regardless
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
--
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 01/13] dt-bindings: Add Renesas R-Car FCP DT bindings

2016-04-25 Thread Geert Uytterhoeven
Hi Laurent,

On Sun, Apr 24, 2016 at 1:49 AM, Laurent Pinchart
 wrote:
> The FCP is a companion module of video processing modules in the Renesas
> R-Car Gen3 SoCs. It provides data compression and decompression, data
> caching, and conversion of AXI transaction in order to reduce the memory

transactions

> bandwidth.
>
> Signed-off-by: Laurent Pinchart 
> ---
>  .../devicetree/bindings/media/renesas,fcp.txt  | 31 
> ++
>  1 file changed, 31 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/media/renesas,fcp.txt
>
> Cc: devicet...@vger.kernel.org
>
> diff --git a/Documentation/devicetree/bindings/media/renesas,fcp.txt 
> b/Documentation/devicetree/bindings/media/renesas,fcp.txt
> new file mode 100644
> index ..46beec97d625
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/renesas,fcp.txt
> @@ -0,0 +1,31 @@
> +Renesas R-Car Frame Compression Processor (FCP)
> +---
> +
> +The FCP is a companion module of video processing modules in the Renesas 
> R-Car
> +Gen3 SoCs. It provides data compression and decompression, data caching, and
> +conversion of AXI transaction in order to reduce the memory bandwidth.

transactions

> +There are three types of FCP whose configuration and behaviour highly depend
> +on the module they are paired with.
>
+ - compatible: Must be one or more of the following
+
+   - "renesas,r8a7795-fcpv" for R8A7795 (R-Car H3) compatible 'FCP for VSP'
+   - "renesas,fcpv" for generic compatible 'FCP for VSP'

As you list only one compatible value, I guess the type is determined
automatically at run-time?

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
--
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


  1   2   >