cron job: media_tree daily build: WARNINGS

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

Results of the daily build of media_tree:

date:   Wed Sep  6 05:00:14 CEST 2017
media-tree git hash:1efdf1776e2253b77413c997bed862410e4b6aaf
media_build git hash:   bbd9f669f0da6705fe44aff89281c0d6e7bfd73e
v4l-utils git hash: 3296adfa7fa169111bf37c041c0ca70ac8506054
gcc version:i686-linux-gcc (GCC) 7.1.0
sparse version: v0.5.0
smatch version: v0.5.0-3553-g78b2ea6
host hardware:  x86_64
host os:4.12.0-164

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

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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


Re: [PATCH 0/6] [media] Atmel: Adjustments for seven function implementations

2017-09-05 Thread Yang, Wenyou

Hi,


On 2017/9/5 4:04, SF Markus Elfring wrote:

From: Markus Elfring 
Date: Mon, 4 Sep 2017 21:44:55 +0200

A few update suggestions were taken into account
from static source code analysis.

Thank you for your patches.

You can add my Acked-by for the patch series.

Acked-by: Wenyou Yang 



Markus Elfring (6):
   Delete an error message for a failed memory allocation in isc_formats_init()
   Improve a size determination in isc_formats_init()
   Adjust three checks for null pointers
   Delete an error message for a failed memory allocation in two functions
   Improve three size determinations
   Adjust a null pointer check in three functions

  drivers/media/platform/atmel/atmel-isc.c | 12 +---
  drivers/media/platform/atmel/atmel-isi.c | 20 
  2 files changed, 13 insertions(+), 19 deletions(-)



Best Regards,
Wenyou Yang


[PATCH v1] media: ov13858: Calculate pixel-rate at runtime, use mode

2017-09-05 Thread Rajmohan Mani
From: Chiranjeevi Rapolu 

Instead of calculating pixle-rate at two different places, calculate at run
time at a single place.

Instead of using hardcoded pixels-per-line, extract it from current sensor
mode.

Signed-off-by: Chiranjeevi Rapolu 
---
 drivers/media/i2c/ov13858.c | 42 +-
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/drivers/media/i2c/ov13858.c b/drivers/media/i2c/ov13858.c
index af7af0d..2821824 100644
--- a/drivers/media/i2c/ov13858.c
+++ b/drivers/media/i2c/ov13858.c
@@ -955,11 +955,9 @@ struct ov13858_mode {
 };
 
 /* Link frequency configs */
-static const struct ov13858_link_freq_config
+static struct ov13858_link_freq_config
link_freq_configs[OV13858_NUM_OF_LINK_FREQS] = {
{
-   /* pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample */
-   .pixel_rate = (OV13858_LINK_FREQ_540MHZ * 2 * 4) / 10,
.pixels_per_line = OV13858_PPL_540MHZ,
.reg_list = {
.num_of_regs = ARRAY_SIZE(mipi_data_rate_1080mbps),
@@ -967,8 +965,6 @@ struct ov13858_mode {
}
},
{
-   /* pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample */
-   .pixel_rate = (OV13858_LINK_FREQ_270MHZ * 2 * 4) / 10,
.pixels_per_line = OV13858_PPL_270MHZ,
.reg_list = {
.num_of_regs = ARRAY_SIZE(mipi_data_rate_540mbps),
@@ -1617,6 +1613,10 @@ static int ov13858_init_controls(struct ov13858 *ov13858)
s64 exposure_max;
s64 vblank_def;
s64 vblank_min;
+   s64 hblank;
+   s64 pixel_rate_min;
+   s64 pixel_rate_max;
+   const struct ov13858_mode *mode;
int ret;
 
ctrl_hdlr = >ctrl_handler;
@@ -1634,29 +1634,30 @@ static int ov13858_init_controls(struct ov13858 
*ov13858)
link_freq_menu_items);
ov13858->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
 
+   pixel_rate_max = link_freq_configs[0].pixel_rate;
+   pixel_rate_min = link_freq_configs[1].pixel_rate;
/* By default, PIXEL_RATE is read only */
ov13858->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, _ctrl_ops,
-   V4L2_CID_PIXEL_RATE, 0,
-   link_freq_configs[0].pixel_rate, 1,
-   link_freq_configs[0].pixel_rate);
+   V4L2_CID_PIXEL_RATE,
+   pixel_rate_min, pixel_rate_max,
+   1, pixel_rate_max);
 
-   vblank_def = ov13858->cur_mode->vts_def - ov13858->cur_mode->height;
-   vblank_min = ov13858->cur_mode->vts_min - ov13858->cur_mode->height;
+   mode = ov13858->cur_mode;
+   vblank_def = mode->vts_def - mode->height;
+   vblank_min = mode->vts_min - mode->height;
ov13858->vblank = v4l2_ctrl_new_std(
ctrl_hdlr, _ctrl_ops, V4L2_CID_VBLANK,
-   vblank_min,
-   OV13858_VTS_MAX - ov13858->cur_mode->height, 1,
+   vblank_min, OV13858_VTS_MAX - mode->height, 1,
vblank_def);
 
+   hblank = link_freq_configs[mode->link_freq_index].pixels_per_line -
+mode->width;
ov13858->hblank = v4l2_ctrl_new_std(
ctrl_hdlr, _ctrl_ops, V4L2_CID_HBLANK,
-   OV13858_PPL_540MHZ - ov13858->cur_mode->width,
-   OV13858_PPL_540MHZ - ov13858->cur_mode->width,
-   1,
-   OV13858_PPL_540MHZ - ov13858->cur_mode->width);
+   hblank, hblank, 1, hblank);
ov13858->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
 
-   exposure_max = ov13858->cur_mode->vts_def - 8;
+   exposure_max = mode->vts_def - 8;
ov13858->exposure = v4l2_ctrl_new_std(
ctrl_hdlr, _ctrl_ops,
V4L2_CID_EXPOSURE, OV13858_EXPOSURE_MIN,
@@ -1704,6 +1705,7 @@ static int ov13858_probe(struct i2c_client *client,
 const struct i2c_device_id *devid)
 {
struct ov13858 *ov13858;
+   int i;
int ret;
u32 val = 0;
 
@@ -1725,6 +1727,12 @@ static int ov13858_probe(struct i2c_client *client,
return ret;
}
 
+   for (i = 0; i < OV13858_NUM_OF_LINK_FREQS; i++) {
+   /* pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample */
+   link_freq_configs[i].pixel_rate  =
+   (link_freq_menu_items[i] * 2 * 4) / 10;
+   }
+
/* Set default mode to max resolution */

Re: [PATCH] media: leds: as3645a: add V4L2_FLASH_LED_CLASS depdendency

2017-09-05 Thread Sakari Ailus

Hi Jacek and Arnd,

Thanks for fixing this plus the ack! I chatted with Mauro, and as the 
patches are still only in mediatree, we'll apply this there, possibly 
with a minor spelling fix to the subject (depdendency -> dependency).




Cc linux-media.

Jacek Anaszewski wrote:

Hi Arnd,

Thanks for the patch.

On 09/05/2017 09:13 AM, Arnd Bergmann wrote:

We get a link error when V4L2_FLASH_LED_CLASS=m and AS3645A is built-in:

drivers/leds/leds-as3645a.o: In function `as3645a_v4l2_setup':
leds-as3645a.c:(.text+0x258): undefined reference to `v4l2_flash_init'
leds-as3645a.c:(.text+0x284): undefined reference to `v4l2_flash_indicator_init'
leds-as3645a.c:(.text+0x2a4): undefined reference to `v4l2_flash_release'
drivers/leds/leds-as3645a.o: In function `as3645a_remove':
leds-as3645a.c:(.text+0x784): undefined reference to `v4l2_flash_release'

This adds the same Kconfig dependency that the other V4L2 flash
drivers in drivers/leds use, to avoid that broken configuration.

Fixes: a56ba8fbcb55 ("media: leds: as3645a: Add LED flash class driver")
Signed-off-by: Arnd Bergmann 
---
 drivers/leds/Kconfig | 1 +
 1 file changed, 1 insertion(+)

The patch that caused the problem is currently in the v4l git tree,
rather than the leds tree. Please merge this through an appropriate
path, either v4l or led, depending on the timing.

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 0bf022bcb6ac..52ea34e337cd 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -61,6 +61,7 @@ config LEDS_AAT1290
 config LEDS_AS3645A
tristate "AS3645A LED flash controller support"
depends on I2C && LEDS_CLASS_FLASH
+   depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS
help
  Enable LED flash class support for AS3645A LED flash
  controller. V4L2 flash API is provided as well if



Acked-by: Jacek Anaszewski 




--
Sakari Ailus
sakari.ai...@linux.intel.com


RE: [PATCH 04/12] intel-ipu3: Add user space ABI definitions

2017-09-05 Thread Zhi, Yong
Hi, Sakari and Hans,

Sorry for the late response to this header file.

> -Original Message-
> From: Sakari Ailus [mailto:sakari.ai...@linux.intel.com]
> Sent: Wednesday, June 7, 2017 3:23 PM
> To: Hans Verkuil 
> Cc: Zhi, Yong ; linux-media@vger.kernel.org; Zheng,
> Jian Xu ; tf...@chromium.org; Mani, Rajmohan
> ; Toivonen, Tuukka
> 
> Subject: Re: [PATCH 04/12] intel-ipu3: Add user space ABI definitions
> 
> Hi Hans,
> 
> On Tue, Jun 06, 2017 at 10:28:26AM +0200, Hans Verkuil wrote:
> > On 05/06/17 22:39, Yong Zhi wrote:
> >
> > Commit message missing.
> >
> > > Signed-off-by: Yong Zhi 
> > > ---
> > >  include/uapi/linux/intel-ipu3.h | 2182
> > > +++
> > >  1 file changed, 2182 insertions(+)
> > >  create mode 100644 include/uapi/linux/intel-ipu3.h
> > >
> > > diff --git a/include/uapi/linux/intel-ipu3.h
> > > b/include/uapi/linux/intel-ipu3.h new file mode 100644 index
> > > 000..9e90aec
> > > --- /dev/null
> > > +++ b/include/uapi/linux/intel-ipu3.h
> > > @@ -0,0 +1,2182 @@
> > > +/*
> > > + * Copyright (c) 2017 Intel Corporation.
> > > + *
> > > + * 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.
> > > + */
> > > +
> > > +#ifndef __IPU3_UAPI_H
> > > +#define __IPU3_UAPI_H
> > > +
> > > +#include 
> > > +
> > > +#define IPU3_UAPI_ISP_VEC_ELEMS  64
> > > +
> > > +#define IMGU_ABI_PAD __aligned(IPU3_UAPI_ISP_WORD_BYTES)
> > > +#define IPU3_ALIGN
>   __attribute__((aligned(IPU3_UAPI_ISP_WORD_BYTES)))
> > > +
> > > +#define IPU3_UAPI_ISP_WORD_BYTES 32
> > > +#define IPU3_UAPI_MAX_STRIPES2
> > > +
> > > +/*** ipu3_uapi_stats_3a ***/
> > > +
> > > +#define IPU3_UAPI_MAX_BUBBLE_SIZE10
> > > +
> > > +#define IPU3_UAPI_AE_COLORS  4
> > > +#define IPU3_UAPI_AE_BINS256
> > > +
> > > +#define IPU3_UAPI_AWB_MD_ITEM_SIZE   8
> > > +#define IPU3_UAPI_AWB_MAX_SETS   60
> > > +#define IPU3_UAPI_AWB_SET_SIZE   0x500
> > > +#define IPU3_UAPI_AWB_SPARE_FOR_BUBBLES \
> > > + (IPU3_UAPI_MAX_BUBBLE_SIZE * IPU3_UAPI_MAX_STRIPES *
> \
> > > +  IPU3_UAPI_AWB_MD_ITEM_SIZE)
> > > +#define IPU3_UAPI_AWB_MAX_BUFFER_SIZE \
> > > + (IPU3_UAPI_AWB_MAX_SETS * \
> > > +  (IPU3_UAPI_AWB_SET_SIZE +
> IPU3_UAPI_AWB_SPARE_FOR_BUBBLES))
> > > +
> > > +#define IPU3_UAPI_AF_MAX_SETS24
> > > +#define IPU3_UAPI_AF_MD_ITEM_SIZE4
> > > +#define IPU3_UAPI_AF_SPARE_FOR_BUBBLES \
> > > + (IPU3_UAPI_MAX_BUBBLE_SIZE * IPU3_UAPI_MAX_STRIPES *
> \
> > > +  IPU3_UAPI_AF_MD_ITEM_SIZE)
> > > +#define IPU3_UAPI_AF_Y_TABLE_SET_SIZE0x80
> > > +#define IPU3_UAPI_AF_Y_TABLE_MAX_SIZE \
> > > + (IPU3_UAPI_AF_MAX_SETS * \
> > > +  (IPU3_UAPI_AF_Y_TABLE_SET_SIZE +
> IPU3_UAPI_AF_SPARE_FOR_BUBBLES) * \
> > > +  IPU3_UAPI_MAX_STRIPES)
> > > +
> > > +#define IPU3_UAPI_AWB_FR_MAX_SETS24
> > > +#define IPU3_UAPI_AWB_FR_MD_ITEM_SIZE8
> > > +#define IPU3_UAPI_AWB_FR_BAYER_TBL_SIZE  0x100
> > > +#define IPU3_UAPI_AWB_FR_SPARE_FOR_BUBBLES \
> > > + (IPU3_UAPI_MAX_BUBBLE_SIZE * IPU3_UAPI_MAX_STRIPES *
> \
> > > + IPU3_UAPI_AWB_FR_MD_ITEM_SIZE)
> > > +#define IPU3_UAPI_AWB_FR_BAYER_TABLE_MAX_SIZE \
> > > + (IPU3_UAPI_AWB_FR_MAX_SETS * \
> > > + (IPU3_UAPI_AWB_FR_BAYER_TBL_SIZE + \
> > > +  IPU3_UAPI_AWB_FR_SPARE_FOR_BUBBLES) * \
> > > + IPU3_UAPI_MAX_STRIPES)
> > > +
> > > +struct ipu3_uapi_grid_config {
> > > + __u8 width; /* 6 or 7 (rgbs_grd_cfg) bits
> */
> > > + __u8 height;
> > > + __u16 block_width_log2:3;
> > > + __u16 block_height_log2:3;
> > > + __u16 height_per_slice:8;   /* default value 1 */
> > > + __u16 x_start;  /* 12 bits */
> > > + __u16 y_start;
> > > +#define IPU3_UAPI_GRID_START_MASK((1 << 12) - 1)
> > > +#define IPU3_UAPI_GRID_Y_START_EN(1 << 15)
> > > + __u16 x_end;/* 12 bits */
> > > + __u16 y_end;
> > > +};
> >
> > You can't use bitfields in a public API. It is up to the compiler to
> > decide how to place bitfields, so this is 

Re: [PATCH] uvcvideo: extend UVC_QUIRK_FIX_BANDWIDTH to MJPEG streams

2017-09-05 Thread Pavel Rojtberg
Hi Laurent,

2017-09-04 11:56 GMT+02:00 Laurent Pinchart :
> Hi Pavel,
>
> Thank you for the patch.
>
> On Monday, 4 September 2017 11:14:17 EEST Pavel Rojtberg wrote:
>> From: Pavel Rojtberg 
>>
>> attaching two Logitech C615 webcams currently results in
>> VIDIOC_STREAMON: No space left on device
>> as the required bandwidth is not estimated correctly by the device.
>> In fact it always requests 3060 bytes - no matter the format or resolution.
>>
>> setting UVC_QUIRK_FIX_BANDWIDTH does not help either as it is only
>> implemented for uncompressed streams.
>>
>> This patch extends UVC_QUIRK_FIX_BANDWIDTH to MJPEG streams by making a
>> (conservative) assumption of 4bpp for MJPEG streams.
>> As the actual compression ration is often closer to 1bpp this can be
>> overridden via the new mjpeg_bpp parameter.
>>
>> Based on:
>> https://www.mail-archive.com/linux-uvc-devel@lists.berlios.de/msg05724.html
>> ---
>>  drivers/media/usb/uvc/uvc_driver.c | 14 +-
>>  drivers/media/usb/uvc/uvc_video.c  |  3 ++-
>>  2 files changed, 15 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/media/usb/uvc/uvc_driver.c
>> b/drivers/media/usb/uvc/uvc_driver.c index 70842c5..f7b759e 100644
>> --- a/drivers/media/usb/uvc/uvc_driver.c
>> +++ b/drivers/media/usb/uvc/uvc_driver.c
>> @@ -37,6 +37,7 @@ unsigned int uvc_no_drop_param;
>>  static unsigned int uvc_quirks_param = -1;
>>  unsigned int uvc_trace_param;
>>  unsigned int uvc_timeout_param = UVC_CTRL_STREAMING_TIMEOUT;
>> +static unsigned int uvc_mjpeg_bpp_param;
>>
>>  /* 
>> * Video formats
>> @@ -463,7 +464,16 @@ static int uvc_parse_format(struct uvc_device *dev,
>>   strlcpy(format->name, "MJPEG", sizeof format->name);
>>   format->fcc = V4L2_PIX_FMT_MJPEG;
>>   format->flags = UVC_FMT_FLAG_COMPRESSED;
>> - format->bpp = 0;
>> + if ((uvc_mjpeg_bpp_param >= 1) && (uvc_mjpeg_bpp_param <= 16)) 
>> {
>> + format->bpp = uvc_mjpeg_bpp_param;
>> + } else {
>> + /* conservative estimate. Actual values are around 
>> 1bpp.
>> +  * see e.g.
>> +  * 
>> https://developers.google.com/speed/webp/docs/webp_study
>> +  */
>> + format->bpp = 4;
>> + }
>> +
>>   ftype = UVC_VS_FRAME_MJPEG;
>>   break;
>>
>> @@ -2274,6 +2284,8 @@ module_param_named(trace, uvc_trace_param, uint,
>> S_IRUGO|S_IWUSR); MODULE_PARM_DESC(trace, "Trace level bitmask");
>>  module_param_named(timeout, uvc_timeout_param, uint, S_IRUGO|S_IWUSR);
>>  MODULE_PARM_DESC(timeout, "Streaming control requests timeout");
>> +module_param_named(mjpeg_bpp, uvc_mjpeg_bpp_param, uint, S_IRUGO|S_IWUSR);
>> +MODULE_PARM_DESC(mjpeg_bpp, "MJPEG bits per pixel for bandwidth quirk");
>
> I'd rather avoid adding a new module parameter for this, it would be confusing
> for users. What is your use case to make the MJPEG average BPP configurable ?
> Can't we come up with a heuristic that would calculate it automatically ?
this is the minimal expected JPEG compression ratio. It depends on the
JPEG quality
chosen by the hardware (which we do not know) as well as the actual image (which
we can not control either).
We could hardcode it to the average bpp which 1 - but this will break
when somebody
films a high-frequency checkerborad. We could leave it at 4, but this
would again
artificially limit the number of possible cameras when not filming a
checkerboard.
4 would already be a noticable improvement over the current state though.

If you can come up with a working heuristic - I am open for that too.

>>  /* 
>> * Driver initialization and cleanup
>> diff --git a/drivers/media/usb/uvc/uvc_video.c
>> b/drivers/media/usb/uvc/uvc_video.c index fb86d6a..382a0be 100644
>> --- a/drivers/media/usb/uvc/uvc_video.c
>> +++ b/drivers/media/usb/uvc/uvc_video.c
>> @@ -127,7 +127,8 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming
>> *stream, if ((ctrl->dwMaxPayloadTransferSize & 0x) == 0x)
>> ctrl->dwMaxPayloadTransferSize &= ~0x;
>>
>> - if (!(format->flags & UVC_FMT_FLAG_COMPRESSED) &&
>> + if ((!(format->flags & UVC_FMT_FLAG_COMPRESSED) ||
>> + (format->fcc == V4L2_PIX_FMT_MJPEG)) &&
>>   stream->dev->quirks & UVC_QUIRK_FIX_BANDWIDTH &&
>>   stream->intf->num_altsetting > 1) {
>>   u32 interval;
>
>
> --
> Regards,
>
> Laurent Pinchart
>

2017-09-04 11:56 GMT+02:00 Laurent Pinchart :
> Hi Pavel,
>
> Thank you for the patch.
>
> On Monday, 4 September 2017 11:14:17 EEST Pavel Rojtberg wrote:
>> From: Pavel Rojtberg 
>>
>> attaching two Logitech C615 webcams currently 

[PATCH] [media] cobalt: remove redundant zero check on retval

2017-09-05 Thread Colin King
From: Colin Ian King 

The error handling paths all end up with retval being non-zero,
so the check for retval being zero is always false and hence
is redundant. Remove it.

Detected by CoverityScan CID#1309479 ("Logically dead code")

Signed-off-by: Colin Ian King 
---
 drivers/media/pci/cobalt/cobalt-driver.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/media/pci/cobalt/cobalt-driver.c 
b/drivers/media/pci/cobalt/cobalt-driver.c
index 98b6cb9505d1..8487ecaa4d30 100644
--- a/drivers/media/pci/cobalt/cobalt-driver.c
+++ b/drivers/media/pci/cobalt/cobalt-driver.c
@@ -767,8 +767,6 @@ static int cobalt_probe(struct pci_dev *pci_dev,
 err_wq:
destroy_workqueue(cobalt->irq_work_queues);
 err:
-   if (retval == 0)
-   retval = -ENODEV;
cobalt_err("error %d on initialization\n", retval);
 
v4l2_device_unregister(>v4l2_dev);
-- 
2.14.1



Re: [PATCH v7 01/18] v4l: fwnode: Move KernelDoc documentation to the header

2017-09-05 Thread Sakari Ailus
On Mon, Sep 04, 2017 at 05:49:40PM +0200, Pavel Machek wrote:
> On Sun 2017-09-03 20:49:41, Sakari Ailus wrote:
> > In V4L2 the practice is to have the KernelDoc documentation in the header
> > and not in .c source code files. This consequientally makes the V4L2
> 
> consequientally: spelling?
> 
> > fwnode function documentation part of the Media documentation build.
> > 
> > Also correct the link related function and argument naming in
> > documentation.
> > 
> > Signed-off-by: Sakari Ailus 
> > Reviewed-by: Niklas Söderlund 
> 
> Something funny going on with utf-8 here.
> 
> Acked-by: Pavel Machek 

Thanks! Will fix for v9.

I had bad commit message encoding in .gitconfig, that's now fixed.

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


Re: [PATCH v3 1/2] dt-bindings: media: Add Cadence MIPI-CSI2 RX Device Tree bindings

2017-09-05 Thread Sakari Ailus
Hi Maxime,

On Mon, Sep 04, 2017 at 03:03:34PM +0200, Maxime Ripard wrote:
> The Cadence MIPI-CSI2 RX controller is a CSI2RX bridge that supports up to
> 4 CSI-2 lanes, and can route the frames to up to 4 streams, depending on
> the hardware implementation.
> 
> It can operate with an external D-PHY, an internal one or no D-PHY at all
> in some configurations.
> 
> Acked-by: Rob Herring 
> Acked-by: Benoit Parrot 
> Signed-off-by: Maxime Ripard 
> ---
>  .../devicetree/bindings/media/cdns-csi2rx.txt  | 98 
> ++
>  1 file changed, 98 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/media/cdns-csi2rx.txt

Naming this according to the compatible string would make it easier to
find. The same pattern is used by a number of existing binding files.

Up to you.

> 
> diff --git a/Documentation/devicetree/bindings/media/cdns-csi2rx.txt 
> b/Documentation/devicetree/bindings/media/cdns-csi2rx.txt
> new file mode 100644
> index ..2395030d8c72
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/cdns-csi2rx.txt
> @@ -0,0 +1,98 @@
> +Cadence MIPI-CSI2 RX controller
> +===
> +
> +The Cadence MIPI-CSI2 RX controller is a CSI-2 bridge supporting up to 4 CSI
> +lanes in input, and 4 different pixel streams in output.
> +
> +Required properties:
> +  - compatible: must be set to "cdns,csi2rx" and an SoC-specific compatible
> +  - reg: base address and size of the memory mapped region
> +  - clocks: phandles to the clocks driving the controller
> +  - clock-names: must contain:
> +* sys_clk: main clock
> +* p_clk: register bank clock
> +* pixel_if[0-3]_clk: pixel stream output clock, one for each stream
> + implemented in hardware, between 0 and 3
> +
> +Optional properties:
> +  - phys: phandle to the external D-PHY, phy-names must be provided
> +  - phy-names: must contain dphy, if the implementation uses an
> +   external D-PHY
> +
> +Required subnodes:
> +  - ports: A ports node with endpoint definitions as defined in
> +   Documentation/devicetree/bindings/media/video-interfaces.txt. The
> +   first port subnode should be the input endpoint, the next ones the
> +   output, one for each stream supported by the CSI2-RX controller.

While I guess the DT compiler won't rearrange the nodes, it'd be better to
define the port numbers explicitly, i.e. that input is number 0.

> +   The ports ID must be the stream output number used in the
> +   implementation, plus 1.

And also that outputs are from 1 to 4.

With that,

Acked-by: Sakari Ailus 

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


[PATCH v8 09/21] omap3isp: Fix check for our own sub-devices

2017-09-05 Thread Sakari Ailus
We only want to link sub-devices that were bound to the async notifier the
isp driver registered but there may be other sub-devices in the
v4l2_device as well. Check for the correct async notifier.

Signed-off-by: Sakari Ailus 
---
 drivers/media/platform/omap3isp/isp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/omap3isp/isp.c 
b/drivers/media/platform/omap3isp/isp.c
index a546cf774d40..3b1a9cd0e591 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -2155,7 +2155,7 @@ static int isp_subdev_notifier_complete(struct 
v4l2_async_notifier *async)
return ret;
 
list_for_each_entry(sd, _dev->subdevs, list) {
-   if (!sd->asd)
+   if (sd->notifier != >notifier)
continue;
 
ret = isp_link_entity(isp, >entity,
-- 
2.11.0



[PATCH v8 02/21] v4l: async: Remove re-probing support

2017-09-05 Thread Sakari Ailus
Remove V4L2 async re-probing support. The re-probing support has been
there to support cases where the sub-devices require resources provided by
the main driver's hardware to function, such as clocks.

Reprobing has allowed unbinding and again binding the main driver without
explicilty unbinding the sub-device drivers. This is certainly not a
common need, and the responsibility will be the user's going forward.

An alternative could have been to introduce notifier specific locks.
Considering the complexity of the re-probing and that it isn't really a
solution to a problem but a workaround, remove re-probing instead.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-async.c | 54 
 1 file changed, 54 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index 851f128eba22..f50a82767863 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -203,78 +203,24 @@ EXPORT_SYMBOL(v4l2_async_notifier_register);
 void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
 {
struct v4l2_subdev *sd, *tmp;
-   unsigned int notif_n_subdev = notifier->num_subdevs;
-   unsigned int n_subdev = min(notif_n_subdev, V4L2_MAX_SUBDEVS);
-   struct device **dev;
-   int i = 0;
 
if (!notifier->v4l2_dev)
return;
 
-   dev = kvmalloc_array(n_subdev, sizeof(*dev), GFP_KERNEL);
-   if (!dev) {
-   dev_err(notifier->v4l2_dev->dev,
-   "Failed to allocate device cache!\n");
-   }
-
mutex_lock(_lock);
 
list_del(>list);
 
list_for_each_entry_safe(sd, tmp, >done, async_list) {
-   struct device *d;
-
-   d = get_device(sd->dev);
-
v4l2_async_cleanup(sd);
 
-   /* If we handled USB devices, we'd have to lock the parent too 
*/
-   device_release_driver(d);
-
if (notifier->unbind)
notifier->unbind(notifier, sd, sd->asd);
-
-   /*
-* Store device at the device cache, in order to call
-* put_device() on the final step
-*/
-   if (dev)
-   dev[i++] = d;
-   else
-   put_device(d);
}
 
mutex_unlock(_lock);
 
-   /*
-* Call device_attach() to reprobe devices
-*
-* NOTE: If dev allocation fails, i is 0, and the whole loop won't be
-* executed.
-*/
-   while (i--) {
-   struct device *d = dev[i];
-
-   if (d && device_attach(d) < 0) {
-   const char *name = "(none)";
-   int lock = device_trylock(d);
-
-   if (lock && d->driver)
-   name = d->driver->name;
-   dev_err(d, "Failed to re-probe to %s\n", name);
-   if (lock)
-   device_unlock(d);
-   }
-   put_device(d);
-   }
-   kvfree(dev);
-
notifier->v4l2_dev = NULL;
-
-   /*
-* Don't care about the waiting list, it is initialised and populated
-* upon notifier registration.
-*/
 }
 EXPORT_SYMBOL(v4l2_async_notifier_unregister);
 
-- 
2.11.0



[PATCH v8 11/21] v4l: async: Move async subdev notifier operations to a separate structure

2017-09-05 Thread Sakari Ailus
From: Laurent Pinchart 

The async subdev notifier .bound(), .unbind() and .complete() operations
are function pointers stored directly in the v4l2_async_subdev
structure. As the structure isn't immutable, this creates a potential
security risk as the function pointers are mutable.

To fix this, move the function pointers to a new
v4l2_async_subdev_operations structure that can be made const in
drivers.

Signed-off-by: Laurent Pinchart 
Acked-by: Hans Verkuil 
---
 drivers/media/platform/am437x/am437x-vpfe.c|  8 +--
 drivers/media/platform/atmel/atmel-isc.c   | 10 ++---
 drivers/media/platform/atmel/atmel-isi.c   | 10 ++---
 drivers/media/platform/davinci/vpif_capture.c  |  8 +--
 drivers/media/platform/davinci/vpif_display.c  |  8 +--
 drivers/media/platform/exynos4-is/media-dev.c  |  8 +--
 drivers/media/platform/omap3isp/isp.c  |  6 +-
 drivers/media/platform/pxa_camera.c|  8 +--
 drivers/media/platform/qcom/camss-8x16/camss.c |  8 +--
 drivers/media/platform/rcar-vin/rcar-core.c| 10 ++---
 drivers/media/platform/rcar_drif.c | 10 ++---
 drivers/media/platform/soc_camera/soc_camera.c | 14 +++--
 drivers/media/platform/stm32/stm32-dcmi.c  | 10 ++---
 drivers/media/platform/ti-vpe/cal.c|  8 +--
 drivers/media/platform/xilinx/xilinx-vipp.c|  8 +--
 drivers/media/v4l2-core/v4l2-async.c   | 20 +-
 drivers/staging/media/imx/imx-media-dev.c  |  8 +--
 include/media/v4l2-async.h | 29 +-
 18 files changed, 131 insertions(+), 60 deletions(-)

diff --git a/drivers/media/platform/am437x/am437x-vpfe.c 
b/drivers/media/platform/am437x/am437x-vpfe.c
index dfcc484cab89..0997c640191d 100644
--- a/drivers/media/platform/am437x/am437x-vpfe.c
+++ b/drivers/media/platform/am437x/am437x-vpfe.c
@@ -2417,6 +2417,11 @@ static int vpfe_async_complete(struct 
v4l2_async_notifier *notifier)
return vpfe_probe_complete(vpfe);
 }
 
+static const struct v4l2_async_notifier_operations vpfe_async_ops = {
+   .bound = vpfe_async_bound,
+   .complete = vpfe_async_complete,
+};
+
 static struct vpfe_config *
 vpfe_get_pdata(struct platform_device *pdev)
 {
@@ -2590,8 +2595,7 @@ static int vpfe_probe(struct platform_device *pdev)
 
vpfe->notifier.subdevs = vpfe->cfg->asd;
vpfe->notifier.num_subdevs = ARRAY_SIZE(vpfe->cfg->asd);
-   vpfe->notifier.bound = vpfe_async_bound;
-   vpfe->notifier.complete = vpfe_async_complete;
+   vpfe->notifier.ops = _async_ops;
ret = v4l2_async_notifier_register(>v4l2_dev,
>notifier);
if (ret) {
diff --git a/drivers/media/platform/atmel/atmel-isc.c 
b/drivers/media/platform/atmel/atmel-isc.c
index d7103c5f92c3..48544c4137cb 100644
--- a/drivers/media/platform/atmel/atmel-isc.c
+++ b/drivers/media/platform/atmel/atmel-isc.c
@@ -1639,6 +1639,12 @@ static int isc_async_complete(struct v4l2_async_notifier 
*notifier)
return 0;
 }
 
+static const struct v4l2_async_notifier_operations isc_async_ops = {
+   .bound = isc_async_bound,
+   .unbind = isc_async_unbind,
+   .complete = isc_async_complete,
+};
+
 static void isc_subdev_cleanup(struct isc_device *isc)
 {
struct isc_subdev_entity *subdev_entity;
@@ -1851,9 +1857,7 @@ static int atmel_isc_probe(struct platform_device *pdev)
list_for_each_entry(subdev_entity, >subdev_entities, list) {
subdev_entity->notifier.subdevs = _entity->asd;
subdev_entity->notifier.num_subdevs = 1;
-   subdev_entity->notifier.bound = isc_async_bound;
-   subdev_entity->notifier.unbind = isc_async_unbind;
-   subdev_entity->notifier.complete = isc_async_complete;
+   subdev_entity->notifier.ops = _async_ops;
 
ret = v4l2_async_notifier_register(>v4l2_dev,
   _entity->notifier);
diff --git a/drivers/media/platform/atmel/atmel-isi.c 
b/drivers/media/platform/atmel/atmel-isi.c
index 891fa2505efa..eadbf9def358 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -1105,6 +1105,12 @@ static int isi_graph_notify_bound(struct 
v4l2_async_notifier *notifier,
return 0;
 }
 
+static const struct v4l2_async_notifier_operations isi_graph_notify_ops = {
+   .bound = isi_graph_notify_bound,
+   .unbind = isi_graph_notify_unbind,
+   .complete = isi_graph_notify_complete,
+};
+
 static int isi_graph_parse(struct atmel_isi *isi, struct device_node *node)
 {
struct device_node *ep = NULL;
@@ -1152,9 +1158,7 @@ static int isi_graph_init(struct atmel_isi *isi)
 
isi->notifier.subdevs = subdevs;
isi->notifier.num_subdevs = 1;
-   

[PATCH v8 04/21] v4l: async: Add V4L2 async documentation to the documentation build

2017-09-05 Thread Sakari Ailus
The V4L2 async wasn't part of the documentation build. Fix this.

Signed-off-by: Sakari Ailus 
Reviewed-by: Niklas Söderlund 
Acked-by: Hans Verkuil 
---
 Documentation/media/kapi/v4l2-async.rst | 3 +++
 Documentation/media/kapi/v4l2-core.rst  | 1 +
 2 files changed, 4 insertions(+)
 create mode 100644 Documentation/media/kapi/v4l2-async.rst

diff --git a/Documentation/media/kapi/v4l2-async.rst 
b/Documentation/media/kapi/v4l2-async.rst
new file mode 100644
index ..523ff9eb09a0
--- /dev/null
+++ b/Documentation/media/kapi/v4l2-async.rst
@@ -0,0 +1,3 @@
+V4L2 async kAPI
+^^^
+.. kernel-doc:: include/media/v4l2-async.h
diff --git a/Documentation/media/kapi/v4l2-core.rst 
b/Documentation/media/kapi/v4l2-core.rst
index c7434f38fd9c..5cf292037a48 100644
--- a/Documentation/media/kapi/v4l2-core.rst
+++ b/Documentation/media/kapi/v4l2-core.rst
@@ -19,6 +19,7 @@ Video4Linux devices
 v4l2-mc
 v4l2-mediabus
 v4l2-mem2mem
+v4l2-async
 v4l2-fwnode
 v4l2-rect
 v4l2-tuner
-- 
2.11.0



[PATCH v8 00/21] Unified fwnode endpoint parser, async sub-device notifier support, N9 flash DTS

2017-09-05 Thread Sakari Ailus
Hi folks,

We have a large influx of new, unmerged, drivers that are now parsing
fwnode endpoints and each one of them is doing this a little bit
differently. The needs are still exactly the same for the graph data
structure is device independent. This is still a non-trivial task and the
majority of the driver implementations are buggy, just buggy in different
ways.

Facilitate parsing endpoints by adding a convenience function for parsing
the endpoints, and make the omap3isp and rcar-vin drivers use them as an
example.

To show where we're getting with this, I've added support for async
sub-device notifier support that is notifiers that can be registered by
sub-device drivers as well as V4L2 fwnode improvements to make use of them
and the DTS changes for the Nokia N9. Some of these patches I've posted
previously in this set here:



Since that, the complete callback of the master notifier registering the
V4L2 device is only called once all sub-notifiers have been completed as
well. This way the device node creation can be postponed until all devices
have been successfully initialised.

With this, the as3645a driver successfully registers a sub-device to the
media device created by the omap3isp driver. The kernel also has the
information it's related to the sensor driven by the smiapp driver but we
don't have a way to expose that information yet.

since v7:

- Added three more patches:

v4l: async: Remove re-probing support
v4l: async: Use more intuitive names for internal functions
dt: bindings: smiapp: Document lens-focus and flash properties

  The last one was already sent previously after the rest of the patchset.

- Removed re-probing support. This is hard to support and only useful in
  special cases. It can be reintroduced later on if there's really a need
  --- note that in e.g. omap3isp this was always broken and no-one ever
  complained.

- Remove smiapp driver's async complete callback (and ops). It is
  redundant: the sub-device nodes are created through the master notifier.

- Improve flash property documentation in video-interfaces.txt.

- Introduce helper functions to call notifier operations, one for each
  operation.

- Rename v4l2_async_test_notify as v4l2_async_match_notify and
  v4l2_async_belongs to v4l2_async_find_match.

- v4l2_async_notifier_test_all_subdevs() renamed as
  v4l2_async_notifier_try_all_subdevs().

- Made notifier_v4l2_dev a function (it was a macro).

- Registering subdev notifiers from sub-device drivers that control
  sub-devices created through sub-notifiers is now supported. In other
  words, subdev notifiers may be registered through other subdev
  notifiers. This is the source of the bulk of the changes between v7 and
  v8.

- Add explanatory comments to helper functions used by V4L2 async
  framework. This should help understanding the internal workings of the
  framework.

- Removed the "notifiers" list in struct v4l2_async_notifier. The
  information can be found from existing data structures.

- Explicitly check that registering a non-subdev notifier has v4l2_dev and
  a subdev notifier has a sub-device pointer.

- Unified several code paths between subdev notifiers and non-subdev
  notifiers.

- Fixed v4l2_async_notifier_release() --- calling it on a notifier for
  which the driver had allocated the subdevs array would lead calling
  kvfree() on that array. Now notifier->max_subdevs is checked before
  proceeding.

- Fixed a use-after-free issue in
  v4l2_async_notifier_fwnode_parse_endpoints().

- Small fixes to KernelDoc documentation for
  v4l2_async_notifier_parse_fwnode_endpoints().

since v6:

- Drop the last patch that added variant for parsing endpoints given
  specific port and endpoints numbers.

- Separate driver changes from the fwnode endpoint parser patch into two
  patches. rcar-vin driver is now using the name function.

- Use -ENOTCONN to tell the parser that and endpoint (or a reference) is
  to be ignored.

- parse_endpoint and parse_single callback functions are now optional and
  documented as such.

- Added Laurent's patch adding notifier operations struct which I rebase
  on the fwnode parser patchset. I wrote another patch to call the
  notifier operations through macros.

- Add DT bindings for flash and lens devices.

- V4L2 fwnode parser for references (such as flash and lens).

- Added smiapp driver support for async sub-devices (lens and flash).

- Added a few fixes for omap3isp.

since v5:

- Use v4l2_async_ prefix for static functions as well (4th patch)

- Use memcpy() to copy array rather than a loop

- Document that the v4l2_async_subdev pointer in driver specific struct
  must be the first member

- Improve documentation of the added functions (4th and 5th
  patches)

- Arguments

- More thorough explation of the purpose, usage and object
  lifetime

- Added acks

since v4:

- Prepend the set with three 

[PATCH v8 06/21] v4l: fwnode: Support generic parsing of graph endpoints in a device

2017-09-05 Thread Sakari Ailus
The current practice is that drivers iterate over their endpoints and
parse each endpoint separately. This is very similar in a number of
drivers, implement a generic function for the job. Driver specific matters
can be taken into account in the driver specific callback.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-async.c  |  19 +
 drivers/media/v4l2-core/v4l2-fwnode.c | 140 ++
 include/media/v4l2-async.h|  24 +-
 include/media/v4l2-fwnode.h   |  53 +
 4 files changed, 234 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index 3d81ff6a496f..7bd595c4094a 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -22,6 +22,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
@@ -224,6 +225,24 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
 }
 EXPORT_SYMBOL(v4l2_async_notifier_unregister);
 
+void v4l2_async_notifier_release(struct v4l2_async_notifier *notifier)
+{
+   unsigned int i;
+
+   if (!notifier->max_subdevs)
+   return;
+
+   for (i = 0; i < notifier->num_subdevs; i++)
+   kfree(notifier->subdevs[i]);
+
+   notifier->max_subdevs = 0;
+   notifier->num_subdevs = 0;
+
+   kvfree(notifier->subdevs);
+   notifier->subdevs = NULL;
+}
+EXPORT_SYMBOL_GPL(v4l2_async_notifier_release);
+
 int v4l2_async_register_subdev(struct v4l2_subdev *sd)
 {
struct v4l2_async_notifier *notifier;
diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 706f9e7b90f1..e6932d7d47b6 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -19,6 +19,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -26,6 +27,7 @@
 #include 
 #include 
 
+#include 
 #include 
 
 enum v4l2_fwnode_bus_type {
@@ -313,6 +315,144 @@ void v4l2_fwnode_put_link(struct v4l2_fwnode_link *link)
 }
 EXPORT_SYMBOL_GPL(v4l2_fwnode_put_link);
 
+static int v4l2_async_notifier_realloc(struct v4l2_async_notifier *notifier,
+  unsigned int max_subdevs)
+{
+   struct v4l2_async_subdev **subdevs;
+
+   if (max_subdevs <= notifier->max_subdevs)
+   return 0;
+
+   subdevs = kvmalloc_array(
+   max_subdevs, sizeof(*notifier->subdevs),
+   GFP_KERNEL | __GFP_ZERO);
+   if (!subdevs)
+   return -ENOMEM;
+
+   if (notifier->subdevs) {
+   memcpy(subdevs, notifier->subdevs,
+  sizeof(*subdevs) * notifier->num_subdevs);
+
+   kvfree(notifier->subdevs);
+   }
+
+   notifier->subdevs = subdevs;
+   notifier->max_subdevs = max_subdevs;
+
+   return 0;
+}
+
+static int v4l2_async_notifier_fwnode_parse_endpoint(
+   struct device *dev, struct v4l2_async_notifier *notifier,
+   struct fwnode_handle *endpoint, unsigned int asd_struct_size,
+   int (*parse_endpoint)(struct device *dev,
+   struct v4l2_fwnode_endpoint *vep,
+   struct v4l2_async_subdev *asd))
+{
+   struct v4l2_async_subdev *asd;
+   struct v4l2_fwnode_endpoint *vep;
+   struct fwnode_endpoint ep;
+   int ret = 0;
+
+   asd = kzalloc(asd_struct_size, GFP_KERNEL);
+   if (!asd)
+   return -ENOMEM;
+
+   asd->match.fwnode.fwnode =
+   fwnode_graph_get_remote_port_parent(endpoint);
+   if (!asd->match.fwnode.fwnode) {
+   dev_warn(dev, "bad remote port parent\n");
+   ret = -EINVAL;
+   goto out_err;
+   }
+
+   /* Ignore endpoints the parsing of which failed. */
+   vep = v4l2_fwnode_endpoint_alloc_parse(endpoint);
+   if (IS_ERR(vep)) {
+   ret = PTR_ERR(vep);
+   dev_warn(dev, "unable to parse V4L2 fwnode endpoint (%d)\n",
+ret);
+   goto out_err;
+   }
+
+   ep = vep->base;
+
+   ret = parse_endpoint ? parse_endpoint(dev, vep, asd) : 0;
+   v4l2_fwnode_endpoint_free(vep);
+   if (ret == -ENOTCONN) {
+   dev_dbg(dev, "ignoring endpoint %u,%u\n", ep.port, ep.id);
+   kfree(asd);
+   return 0;
+   } else if (ret < 0) {
+   dev_warn(dev, "driver could not parse endpoint %u,%u (%d)\n",
+ep.port, ep.id, ret);
+   goto out_err;
+   }
+
+   asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
+   notifier->subdevs[notifier->num_subdevs] = asd;
+   notifier->num_subdevs++;
+
+   return 0;
+
+out_err:
+   fwnode_handle_put(asd->match.fwnode.fwnode);
+   kfree(asd);
+
+   return ret;
+}
+
+int 

[PATCH v8 07/21] omap3isp: Use generic parser for parsing fwnode endpoints

2017-09-05 Thread Sakari Ailus
Instead of using driver implementation, use
v4l2_async_notifier_parse_fwnode_endpoints() to parse the fwnode endpoints
of the device.

Signed-off-by: Sakari Ailus 
---
 drivers/media/platform/omap3isp/isp.c | 115 +++---
 drivers/media/platform/omap3isp/isp.h |   5 +-
 2 files changed, 37 insertions(+), 83 deletions(-)

diff --git a/drivers/media/platform/omap3isp/isp.c 
b/drivers/media/platform/omap3isp/isp.c
index 1a428fe9f070..a546cf774d40 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -2001,6 +2001,7 @@ static int isp_remove(struct platform_device *pdev)
__omap3isp_put(isp, false);
 
media_entity_enum_cleanup(>crashed);
+   v4l2_async_notifier_release(>notifier);
 
return 0;
 }
@@ -2011,44 +2012,41 @@ enum isp_of_phy {
ISP_OF_PHY_CSIPHY2,
 };
 
-static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwnode,
-   struct isp_async_subdev *isd)
+static int isp_fwnode_parse(struct device *dev,
+   struct v4l2_fwnode_endpoint *vep,
+   struct v4l2_async_subdev *asd)
 {
+   struct isp_async_subdev *isd =
+   container_of(asd, struct isp_async_subdev, asd);
struct isp_bus_cfg *buscfg = >bus;
-   struct v4l2_fwnode_endpoint vep;
-   unsigned int i;
-   int ret;
bool csi1 = false;
-
-   ret = v4l2_fwnode_endpoint_parse(fwnode, );
-   if (ret)
-   return ret;
+   unsigned int i;
 
dev_dbg(dev, "parsing endpoint %pOF, interface %u\n",
-   to_of_node(fwnode), vep.base.port);
+   to_of_node(vep->base.local_fwnode), vep->base.port);
 
-   switch (vep.base.port) {
+   switch (vep->base.port) {
case ISP_OF_PHY_PARALLEL:
buscfg->interface = ISP_INTERFACE_PARALLEL;
buscfg->bus.parallel.data_lane_shift =
-   vep.bus.parallel.data_shift;
+   vep->bus.parallel.data_shift;
buscfg->bus.parallel.clk_pol =
-   !!(vep.bus.parallel.flags
+   !!(vep->bus.parallel.flags
   & V4L2_MBUS_PCLK_SAMPLE_FALLING);
buscfg->bus.parallel.hs_pol =
-   !!(vep.bus.parallel.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW);
+   !!(vep->bus.parallel.flags & 
V4L2_MBUS_VSYNC_ACTIVE_LOW);
buscfg->bus.parallel.vs_pol =
-   !!(vep.bus.parallel.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW);
+   !!(vep->bus.parallel.flags & 
V4L2_MBUS_HSYNC_ACTIVE_LOW);
buscfg->bus.parallel.fld_pol =
-   !!(vep.bus.parallel.flags & V4L2_MBUS_FIELD_EVEN_LOW);
+   !!(vep->bus.parallel.flags & V4L2_MBUS_FIELD_EVEN_LOW);
buscfg->bus.parallel.data_pol =
-   !!(vep.bus.parallel.flags & V4L2_MBUS_DATA_ACTIVE_LOW);
-   buscfg->bus.parallel.bt656 = vep.bus_type == V4L2_MBUS_BT656;
+   !!(vep->bus.parallel.flags & V4L2_MBUS_DATA_ACTIVE_LOW);
+   buscfg->bus.parallel.bt656 = vep->bus_type == V4L2_MBUS_BT656;
break;
 
case ISP_OF_PHY_CSIPHY1:
case ISP_OF_PHY_CSIPHY2:
-   switch (vep.bus_type) {
+   switch (vep->bus_type) {
case V4L2_MBUS_CCP2:
case V4L2_MBUS_CSI1:
dev_dbg(dev, "CSI-1/CCP-2 configuration\n");
@@ -2060,11 +2058,11 @@ static int isp_fwnode_parse(struct device *dev, struct 
fwnode_handle *fwnode,
break;
default:
dev_err(dev, "unsupported bus type %u\n",
-   vep.bus_type);
+   vep->bus_type);
return -EINVAL;
}
 
-   switch (vep.base.port) {
+   switch (vep->base.port) {
case ISP_OF_PHY_CSIPHY1:
if (csi1)
buscfg->interface = ISP_INTERFACE_CCP2B_PHY1;
@@ -2080,47 +2078,47 @@ static int isp_fwnode_parse(struct device *dev, struct 
fwnode_handle *fwnode,
}
if (csi1) {
buscfg->bus.ccp2.lanecfg.clk.pos =
-   vep.bus.mipi_csi1.clock_lane;
+   vep->bus.mipi_csi1.clock_lane;
buscfg->bus.ccp2.lanecfg.clk.pol =
-   vep.bus.mipi_csi1.lane_polarity[0];
+   vep->bus.mipi_csi1.lane_polarity[0];
dev_dbg(dev, "clock lane polarity %u, pos %u\n",
buscfg->bus.ccp2.lanecfg.clk.pol,
buscfg->bus.ccp2.lanecfg.clk.pos);
 

[PATCH v8 08/21] rcar-vin: Use generic parser for parsing fwnode endpoints

2017-09-05 Thread Sakari Ailus
Instead of using driver implementation, use
v4l2_async_notifier_parse_fwnode_endpoints() to parse the fwnode endpoints
of the device.

Signed-off-by: Sakari Ailus 
---
 drivers/media/platform/rcar-vin/rcar-core.c | 112 +---
 drivers/media/platform/rcar-vin/rcar-dma.c  |  10 +--
 drivers/media/platform/rcar-vin/rcar-v4l2.c |  14 ++--
 drivers/media/platform/rcar-vin/rcar-vin.h  |   4 +-
 4 files changed, 48 insertions(+), 92 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
b/drivers/media/platform/rcar-vin/rcar-core.c
index 142de447..bd551f0be213 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 
+#include 
 #include 
 
 #include "rcar-vin.h"
@@ -77,14 +78,14 @@ static int rvin_digital_notify_complete(struct 
v4l2_async_notifier *notifier)
int ret;
 
/* Verify subdevices mbus format */
-   if (!rvin_mbus_supported(>digital)) {
+   if (!rvin_mbus_supported(vin->digital)) {
vin_err(vin, "Unsupported media bus format for %s\n",
-   vin->digital.subdev->name);
+   vin->digital->subdev->name);
return -EINVAL;
}
 
vin_dbg(vin, "Found media bus format for %s: %d\n",
-   vin->digital.subdev->name, vin->digital.code);
+   vin->digital->subdev->name, vin->digital->code);
 
ret = v4l2_device_register_subdev_nodes(>v4l2_dev);
if (ret < 0) {
@@ -103,7 +104,7 @@ static void rvin_digital_notify_unbind(struct 
v4l2_async_notifier *notifier,
 
vin_dbg(vin, "unbind digital subdev %s\n", subdev->name);
rvin_v4l2_remove(vin);
-   vin->digital.subdev = NULL;
+   vin->digital->subdev = NULL;
 }
 
 static int rvin_digital_notify_bound(struct v4l2_async_notifier *notifier,
@@ -120,117 +121,70 @@ static int rvin_digital_notify_bound(struct 
v4l2_async_notifier *notifier,
ret = rvin_find_pad(subdev, MEDIA_PAD_FL_SOURCE);
if (ret < 0)
return ret;
-   vin->digital.source_pad = ret;
+   vin->digital->source_pad = ret;
 
ret = rvin_find_pad(subdev, MEDIA_PAD_FL_SINK);
-   vin->digital.sink_pad = ret < 0 ? 0 : ret;
+   vin->digital->sink_pad = ret < 0 ? 0 : ret;
 
-   vin->digital.subdev = subdev;
+   vin->digital->subdev = subdev;
 
vin_dbg(vin, "bound subdev %s source pad: %u sink pad: %u\n",
-   subdev->name, vin->digital.source_pad,
-   vin->digital.sink_pad);
+   subdev->name, vin->digital->source_pad,
+   vin->digital->sink_pad);
 
return 0;
 }
 
-static int rvin_digitial_parse_v4l2(struct rvin_dev *vin,
-   struct device_node *ep,
-   struct v4l2_mbus_config *mbus_cfg)
+static int rvin_digital_parse_v4l2(struct device *dev,
+  struct v4l2_fwnode_endpoint *vep,
+  struct v4l2_async_subdev *asd)
 {
-   struct v4l2_fwnode_endpoint v4l2_ep;
-   int ret;
+   struct rvin_dev *vin = dev_get_drvdata(dev);
+   struct rvin_graph_entity *rvge =
+   container_of(asd, struct rvin_graph_entity, asd);
 
-   ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep), _ep);
-   if (ret) {
-   vin_err(vin, "Could not parse v4l2 endpoint\n");
-   return -EINVAL;
-   }
+   if (vep->base.port || vep->base.id)
+   return -EPERM;
 
-   mbus_cfg->type = v4l2_ep.bus_type;
+   rvge->mbus_cfg.type = vep->bus_type;
 
-   switch (mbus_cfg->type) {
+   switch (rvge->mbus_cfg.type) {
case V4L2_MBUS_PARALLEL:
vin_dbg(vin, "Found PARALLEL media bus\n");
-   mbus_cfg->flags = v4l2_ep.bus.parallel.flags;
+   rvge->mbus_cfg.flags = vep->bus.parallel.flags;
break;
case V4L2_MBUS_BT656:
vin_dbg(vin, "Found BT656 media bus\n");
-   mbus_cfg->flags = 0;
+   rvge->mbus_cfg.flags = 0;
break;
default:
vin_err(vin, "Unknown media bus type\n");
return -EINVAL;
}
 
-   return 0;
-}
-
-static int rvin_digital_graph_parse(struct rvin_dev *vin)
-{
-   struct device_node *ep, *np;
-   int ret;
-
-   vin->digital.asd.match.fwnode.fwnode = NULL;
-   vin->digital.subdev = NULL;
-
-   /*
-* Port 0 id 0 is local digital input, try to get it.
-* Not all instances can or will have this, that is OK
-*/
-   ep = of_graph_get_endpoint_by_regs(vin->dev->of_node, 0, 0);
-   if (!ep)
-   return 0;
-
-   np = of_graph_get_remote_port_parent(ep);
-   if (!np) {
-   vin_err(vin, "No remote parent for digital input\n");
-   

[PATCH v8 19/21] smiapp: Add support for flash and lens devices

2017-09-05 Thread Sakari Ailus
Parse async sub-devices by using
v4l2_subdev_fwnode_reference_parse_sensor_common().

These types devices aren't directly related to the sensor, but are
nevertheless handled by the smiapp driver due to the relationship of these
component to the main part of the camera module --- the sensor.

This does not yet address providing the user space with information on how
to associate the sensor or lens devices but the kernel now has the
necessary information to do that.

Signed-off-by: Sakari Ailus 
---
 drivers/media/i2c/smiapp/smiapp-core.c | 18 --
 drivers/media/i2c/smiapp/smiapp.h  |  4 +++-
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index 700f433261d0..2a7cf430270c 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -31,7 +31,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
@@ -2887,6 +2887,11 @@ static int smiapp_probe(struct i2c_client *client,
v4l2_i2c_subdev_init(>src->sd, client, _ops);
sensor->src->sd.internal_ops = _internal_src_ops;
 
+   rval = v4l2_fwnode_reference_parse_sensor_common(
+   >dev, >notifier);
+   if (rval < 0 && rval != -ENOENT)
+   return rval;
+
sensor->vana = devm_regulator_get(>dev, "vana");
if (IS_ERR(sensor->vana)) {
dev_err(>dev, "could not get regulator for vana\n");
@@ -3092,9 +3097,14 @@ static int smiapp_probe(struct i2c_client *client,
if (rval < 0)
goto out_media_entity_cleanup;
 
+   rval = v4l2_async_subdev_notifier_register(>src->sd,
+  >notifier);
+   if (rval)
+   goto out_media_entity_cleanup;
+
rval = v4l2_async_register_subdev(>src->sd);
if (rval < 0)
-   goto out_media_entity_cleanup;
+   goto out_unregister_async_notifier;
 
pm_runtime_set_active(>dev);
pm_runtime_get_noresume(>dev);
@@ -3105,6 +3115,9 @@ static int smiapp_probe(struct i2c_client *client,
 
return 0;
 
+out_unregister_async_notifier:
+   v4l2_async_notifier_unregister(>notifier);
+
 out_media_entity_cleanup:
media_entity_cleanup(>src->sd.entity);
 
@@ -3124,6 +3137,7 @@ static int smiapp_remove(struct i2c_client *client)
unsigned int i;
 
v4l2_async_unregister_subdev(subdev);
+   v4l2_async_notifier_unregister(>notifier);
 
pm_runtime_disable(>dev);
if (!pm_runtime_status_suspended(>dev))
diff --git a/drivers/media/i2c/smiapp/smiapp.h 
b/drivers/media/i2c/smiapp/smiapp.h
index f74d695018b9..be92cb5713f4 100644
--- a/drivers/media/i2c/smiapp/smiapp.h
+++ b/drivers/media/i2c/smiapp/smiapp.h
@@ -20,9 +20,10 @@
 #define __SMIAPP_PRIV_H_
 
 #include 
+#include 
+#include 
 #include 
 #include 
-#include 
 
 #include "smiapp-pll.h"
 #include "smiapp-reg.h"
@@ -172,6 +173,7 @@ struct smiapp_subdev {
  * struct smiapp_sensor - Main device structure
  */
 struct smiapp_sensor {
+   struct v4l2_async_notifier notifier;
/*
 * "mutex" is used to serialise access to all fields here
 * except v4l2_ctrls at the end of the struct. "mutex" is also
-- 
2.11.0



[PATCH v8 21/21] arm: dts: omap3: N9/N950: Add flash references to the camera

2017-09-05 Thread Sakari Ailus
Add flash and indicator LED phandles to the sensor node.

Signed-off-by: Sakari Ailus 
---
 arch/arm/boot/dts/omap3-n9.dts   | 1 +
 arch/arm/boot/dts/omap3-n950-n9.dtsi | 4 ++--
 arch/arm/boot/dts/omap3-n950.dts | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/omap3-n9.dts b/arch/arm/boot/dts/omap3-n9.dts
index b9e58c536afd..a2944010f62f 100644
--- a/arch/arm/boot/dts/omap3-n9.dts
+++ b/arch/arm/boot/dts/omap3-n9.dts
@@ -26,6 +26,7 @@
clocks = < 0>;
clock-frequency = <960>;
nokia,nvm-size = <(16 * 64)>;
+   flash = <_flash _indicator>;
port {
smia_1_1: endpoint {
link-frequencies = /bits/ 64 <19920 
21000 49920>;
diff --git a/arch/arm/boot/dts/omap3-n950-n9.dtsi 
b/arch/arm/boot/dts/omap3-n950-n9.dtsi
index cb47ae79a5f9..92c1a1da28d3 100644
--- a/arch/arm/boot/dts/omap3-n950-n9.dtsi
+++ b/arch/arm/boot/dts/omap3-n950-n9.dtsi
@@ -269,13 +269,13 @@
as3645a@30 {
reg = <0x30>;
compatible = "ams,as3645a";
-   flash {
+   as3645a_flash: flash {
flash-timeout-us = <15>;
flash-max-microamp = <32>;
led-max-microamp = <6>;
peak-current-limit = <175>;
};
-   indicator {
+   as3645a_indicator: indicator {
led-max-microamp = <1>;
};
};
diff --git a/arch/arm/boot/dts/omap3-n950.dts b/arch/arm/boot/dts/omap3-n950.dts
index 646601a3ebd8..bba5c5a6950c 100644
--- a/arch/arm/boot/dts/omap3-n950.dts
+++ b/arch/arm/boot/dts/omap3-n950.dts
@@ -60,6 +60,7 @@
clocks = < 0>;
clock-frequency = <960>;
nokia,nvm-size = <(16 * 64)>;
+   flash = <_flash _indicator>;
port {
smia_1_1: endpoint {
link-frequencies = /bits/ 64 <21000 
33360 39840>;
-- 
2.11.0



[PATCH v8 12/21] v4l: async: Introduce helpers for calling async ops callbacks

2017-09-05 Thread Sakari Ailus
Add three helper functions to call async operations callbacks. Besides
simplifying callbacks, this allows async notifiers to have no ops set,
i.e. it can be left NULL.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-async.c | 49 ++--
 include/media/v4l2-async.h   |  1 +
 2 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index f7eb3713207a..baee95eacbba 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -25,6 +25,34 @@
 #include 
 #include 
 
+static int v4l2_async_notifier_call_bound(struct v4l2_async_notifier *n,
+ struct v4l2_subdev *subdev,
+ struct v4l2_async_subdev *asd)
+{
+   if (!n->ops || !n->ops->bound)
+   return 0;
+
+   return n->ops->bound(n, subdev, asd);
+}
+
+static void v4l2_async_notifier_call_unbind(struct v4l2_async_notifier *n,
+   struct v4l2_subdev *subdev,
+   struct v4l2_async_subdev *asd)
+{
+   if (!n->ops || !n->ops->unbind)
+   return;
+
+   n->ops->unbind(n, subdev, asd);
+}
+
+static int v4l2_async_notifier_call_complete(struct v4l2_async_notifier *n)
+{
+   if (!n->ops || !n->ops->complete)
+   return 0;
+
+   return n->ops->complete(n);
+}
+
 static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
 {
 #if IS_ENABLED(CONFIG_I2C)
@@ -107,16 +135,13 @@ static int v4l2_async_match_notify(struct 
v4l2_async_notifier *notifier,
 {
int ret;
 
-   if (notifier->ops->bound) {
-   ret = notifier->ops->bound(notifier, sd, asd);
-   if (ret < 0)
-   return ret;
-   }
+   ret = v4l2_async_notifier_call_bound(notifier, sd, asd);
+   if (ret < 0)
+   return ret;
 
ret = v4l2_device_register_subdev(notifier->v4l2_dev, sd);
if (ret < 0) {
-   if (notifier->ops->unbind)
-   notifier->ops->unbind(notifier, sd, asd);
+   v4l2_async_notifier_call_unbind(notifier, sd, asd);
return ret;
}
 
@@ -128,8 +153,8 @@ static int v4l2_async_match_notify(struct 
v4l2_async_notifier *notifier,
/* Move from the global subdevice list to notifier's done */
list_move(>async_list, >done);
 
-   if (list_empty(>waiting) && notifier->ops->complete)
-   return notifier->ops->complete(notifier);
+   if (list_empty(>waiting))
+   return v4l2_async_notifier_call_complete(notifier);
 
return 0;
 }
@@ -215,8 +240,7 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
list_for_each_entry_safe(sd, tmp, >done, async_list) {
v4l2_async_cleanup(sd);
 
-   if (notifier->ops->unbind)
-   notifier->ops->unbind(notifier, sd, sd->asd);
+   v4l2_async_notifier_call_unbind(notifier, sd, sd->asd);
}
 
mutex_unlock(_lock);
@@ -294,8 +318,7 @@ void v4l2_async_unregister_subdev(struct v4l2_subdev *sd)
 
v4l2_async_cleanup(sd);
 
-   if (notifier->ops->unbind)
-   notifier->ops->unbind(notifier, sd, sd->asd);
+   v4l2_async_notifier_call_unbind(notifier, sd, sd->asd);
 
mutex_unlock(_lock);
 }
diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h
index 3c48f8b66d12..3bc8a7c0d83f 100644
--- a/include/media/v4l2-async.h
+++ b/include/media/v4l2-async.h
@@ -164,4 +164,5 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd);
  * @sd: pointer to  v4l2_subdev
  */
 void v4l2_async_unregister_subdev(struct v4l2_subdev *sd);
+
 #endif
-- 
2.11.0



[PATCH v8 18/21] v4l: fwnode: Add convenience function for parsing common external refs

2017-09-05 Thread Sakari Ailus
Add v4l2_fwnode_parse_reference_sensor_common for parsing common
sensor properties that refer to adjacent devices such as flash or lens
driver chips.

As this is an association only, there's little a regular driver needs to
know about these devices as such.

Signed-off-by: Sakari Ailus 
Acked-by: Hans Verkuil 
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 27 +++
 include/media/v4l2-fwnode.h   |  3 +++
 2 files changed, 30 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 8c059a4217b4..3c86229629b2 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -538,6 +538,33 @@ int v4l2_fwnode_reference_parse(
 }
 EXPORT_SYMBOL_GPL(v4l2_fwnode_reference_parse);
 
+int v4l2_fwnode_reference_parse_sensor_common(
+   struct device *dev, struct v4l2_async_notifier *notifier)
+{
+   static const struct {
+   char *name;
+   char *cells;
+   unsigned int nr_cells;
+   } props[] = {
+   { "flash", NULL, 0 },
+   { "lens-focus", NULL, 0 },
+   };
+   unsigned int i;
+   int rval;
+
+   for (i = 0; i < ARRAY_SIZE(props); i++) {
+   rval = v4l2_fwnode_reference_parse(
+   dev, notifier, props[i].name, props[i].cells,
+   props[i].nr_cells, sizeof(struct v4l2_async_subdev),
+   NULL);
+   if (rval < 0 && rval != -ENOENT)
+   return rval;
+   }
+
+   return rval;
+}
+EXPORT_SYMBOL_GPL(v4l2_fwnode_reference_parse_sensor_common);
+
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Sakari Ailus ");
 MODULE_AUTHOR("Sylwester Nawrocki ");
diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h
index 3ad71241cb20..36b6514dd6ef 100644
--- a/include/media/v4l2-fwnode.h
+++ b/include/media/v4l2-fwnode.h
@@ -282,4 +282,7 @@ int v4l2_fwnode_reference_parse(
struct fwnode_reference_args *args,
struct v4l2_async_subdev *asd));
 
+int v4l2_fwnode_reference_parse_sensor_common(
+   struct device *dev, struct v4l2_async_notifier *notifier);
+
 #endif /* _V4L2_FWNODE_H */
-- 
2.11.0



[PATCH v8 17/21] v4l: fwnode: Add convenience function for parsing generic references

2017-09-05 Thread Sakari Ailus
Add function v4l2_fwnode_reference_count() for counting external
references and v4l2_fwnode_reference_parse() for parsing them as async
sub-devices.

This can be done on e.g. flash or lens async sub-devices that are not part
of but are associated with a sensor.

struct v4l2_async_notifier.max_subdevs field is added to contain the
maximum number of sub-devices in a notifier to reflect the memory
allocated for the subdevs array.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 85 +++
 include/media/v4l2-fwnode.h   | 28 
 2 files changed, 113 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index e6932d7d47b6..8c059a4217b4 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -453,6 +453,91 @@ int v4l2_async_notifier_parse_fwnode_endpoints(
 }
 EXPORT_SYMBOL_GPL(v4l2_async_notifier_parse_fwnode_endpoints);
 
+static void v4l2_fwnode_print_args(struct fwnode_reference_args *args)
+{
+   unsigned int i;
+
+   for (i = 0; i < args->nargs; i++) {
+   pr_cont(" %u", args->args[i]);
+   if (i + 1 < args->nargs)
+   pr_cont(",");
+   }
+}
+
+int v4l2_fwnode_reference_parse(
+   struct device *dev, struct v4l2_async_notifier *notifier,
+   const char *prop, const char *nargs_prop, unsigned int nargs,
+   size_t asd_struct_size,
+   int (*parse_single)(struct device *dev,
+   struct fwnode_reference_args *args,
+   struct v4l2_async_subdev *asd))
+{
+   struct fwnode_reference_args args;
+   unsigned int index = 0;
+   int ret = -ENOENT;
+
+   if (asd_struct_size < sizeof(struct v4l2_async_subdev))
+   return -EINVAL;
+
+   for (; !fwnode_property_get_reference_args(
+dev_fwnode(dev), prop, nargs_prop, nargs,
+index, ); index++)
+   fwnode_handle_put(args.fwnode);
+
+   ret = v4l2_async_notifier_realloc(notifier,
+ notifier->num_subdevs + index);
+   if (ret)
+   return -ENOMEM;
+
+   for (ret = -ENOENT, index = 0; !fwnode_property_get_reference_args(
+dev_fwnode(dev), prop, nargs_prop, nargs,
+index, ); index++) {
+   struct v4l2_async_subdev *asd;
+
+   if (WARN_ON(notifier->num_subdevs >= notifier->max_subdevs)) {
+   ret = -EINVAL;
+   goto error;
+   }
+
+   asd = kzalloc(asd_struct_size, GFP_KERNEL);
+   if (!asd) {
+   ret = -ENOMEM;
+   goto error;
+   }
+
+   ret = parse_single ? parse_single(dev, , asd) : 0;
+   if (ret < 0) {
+   kfree(asd);
+   if (ret == -ENOTCONN)
+   dev_dbg(dev,
+   "ignoring reference prop \"%s\", 
nargs_prop \"%s\", nargs %u, index %u",
+   prop, nargs_prop, nargs, index);
+   else
+   dev_warn(dev,
+"driver could not parse reference prop 
\"%s\", nargs_prop \"%s\", nargs %u, index %u",
+prop, nargs_prop, nargs, index);
+   v4l2_fwnode_print_args();
+   pr_cont("\n");
+   if (ret == -ENOTCONN)
+   continue;
+   else
+   goto error;
+   }
+
+   notifier->subdevs[notifier->num_subdevs] = asd;
+   asd->match.fwnode.fwnode = args.fwnode;
+   asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
+   notifier->num_subdevs++;
+   }
+
+   return 0;
+
+error:
+   fwnode_handle_put(args.fwnode);
+   return ret;
+}
+EXPORT_SYMBOL_GPL(v4l2_fwnode_reference_parse);
+
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Sakari Ailus ");
 MODULE_AUTHOR("Sylwester Nawrocki ");
diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h
index 6d125f26ec84..3ad71241cb20 100644
--- a/include/media/v4l2-fwnode.h
+++ b/include/media/v4l2-fwnode.h
@@ -254,4 +254,32 @@ int v4l2_async_notifier_parse_fwnode_endpoints(
  struct v4l2_fwnode_endpoint *vep,
  struct v4l2_async_subdev *asd));
 
+/**
+ * v4l2_fwnode_reference_parse - parse references for async sub-devices
+ * @dev: the device node the properties of which are parsed for references
+ * @notifier: the async notifier where the async subdevs will be added
+ * @prop: the name of the property
+ * 

[PATCH v8 14/21] v4l: async: Allow binding notifiers to sub-devices

2017-09-05 Thread Sakari Ailus
Registering a notifier has required the knowledge of struct v4l2_device
for the reason that sub-devices generally are registered to the
v4l2_device (as well as the media device, also available through
v4l2_device).

This information is not available for sub-device drivers at probe time.

What this patch does is that it allows registering notifiers without
having v4l2_device around. Instead the sub-device pointer is stored to the
notifier. Once the sub-device of the driver that registered the notifier
is registered, the notifier will gain the knowledge of the v4l2_device,
and the binding of async sub-devices from the sub-device driver's notifier
may proceed.

The master notifier's complete callback is only called when all sub-device
notifiers are completed.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-async.c | 209 ++-
 include/media/v4l2-async.h   |  16 ++-
 2 files changed, 194 insertions(+), 31 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index 79f216723a3f..620b2cd29fc3 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -53,6 +53,10 @@ static int v4l2_async_notifier_call_complete(struct 
v4l2_async_notifier *n)
return n->ops->complete(n);
 }
 
+static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier,
+  struct v4l2_subdev *sd,
+  struct v4l2_async_subdev *asd);
+
 static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
 {
 #if IS_ENABLED(CONFIG_I2C)
@@ -129,14 +133,119 @@ static struct v4l2_async_subdev *v4l2_async_find_match(
return NULL;
 }
 
+/* Get the sub-device notifier registered by a sub-device driver. */
+static struct v4l2_async_notifier *v4l2_async_get_subdev_notifier(
+   struct v4l2_subdev *sd)
+{
+   struct v4l2_async_notifier *n;
+
+   list_for_each_entry(n, _list, list)
+   if (n->sd == sd)
+   return n;
+
+   return NULL;
+}
+
+/* Return true if all sub-device notifiers are complete, false otherwise. */
+static bool v4l2_async_subdev_notifiers_complete(
+   struct v4l2_async_notifier *notifier)
+{
+   struct v4l2_subdev *sd;
+
+   if (!list_empty(>waiting))
+   return false;
+
+   list_for_each_entry(sd, >done, async_list) {
+   struct v4l2_async_notifier *subdev_notifier =
+   v4l2_async_get_subdev_notifier(sd);
+
+   if (!subdev_notifier)
+   continue;
+
+   if (!v4l2_async_subdev_notifiers_complete(subdev_notifier))
+   return false;
+   }
+
+   return true;
+}
+
+/* Get v4l2_device related to the notifier if one can be found. */
+static struct v4l2_device *v4l2_async_notifier_get_v4l2_dev(
+   struct v4l2_async_notifier *notifier)
+{
+   while (notifier->master)
+   notifier = notifier->master;
+
+   return notifier->v4l2_dev;
+}
+
+/* Test all async sub-devices in a notifier for a match. */
+static int v4l2_async_notifier_try_all_subdevs(
+   struct v4l2_async_notifier *notifier)
+{
+   struct v4l2_subdev *sd, *tmp;
+
+   if (!v4l2_async_notifier_get_v4l2_dev(notifier))
+   return 0;
+
+   list_for_each_entry_safe(sd, tmp, _list, async_list) {
+   struct v4l2_async_subdev *asd;
+   int ret;
+
+   asd = v4l2_async_find_match(notifier, sd);
+   if (!asd)
+   continue;
+
+   ret = v4l2_async_match_notify(notifier, sd, asd);
+   if (ret < 0)
+   return ret;
+   }
+
+   return 0;
+}
+
+/* Try completing a notifier. */
+static int v4l2_async_notifier_try_complete(
+   struct v4l2_async_notifier *notifier)
+{
+   do {
+   int ret;
+
+   /* Any local async sub-devices left? */
+   if (!list_empty(>waiting))
+   return 0;
+
+   /*
+* Any sub-device notifiers waiting for async subdevs
+* to be bound?
+*/
+   if (!v4l2_async_subdev_notifiers_complete(notifier))
+   return 0;
+
+   /* Proceed completing the notifier */
+   ret = v4l2_async_notifier_call_complete(notifier);
+   if (ret < 0)
+   return ret;
+
+   /*
+* Obtain notifier's master. If there is one, repeat
+* the process, otherwise we're done here.
+*/
+   } while ((notifier = notifier->master));
+
+   return 0;
+}
+
 static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier,
   struct v4l2_subdev *sd,
   struct v4l2_async_subdev 

[PATCH v8 15/21] dt: bindings: Add a binding for flash devices associated to a sensor

2017-09-05 Thread Sakari Ailus
Camera flash drivers (and LEDs) are separate from the sensor devices in
DT. In order to make an association between the two, provide the
association information to the software.

Signed-off-by: Sakari Ailus 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/media/video-interfaces.txt | 8 
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/video-interfaces.txt 
b/Documentation/devicetree/bindings/media/video-interfaces.txt
index 852041a7480c..efc67161e389 100644
--- a/Documentation/devicetree/bindings/media/video-interfaces.txt
+++ b/Documentation/devicetree/bindings/media/video-interfaces.txt
@@ -67,6 +67,14 @@ are required in a relevant parent node:
identifier, should be 1.
  - #size-cells: should be zero.
 
+
+Optional properties
+---
+
+- flash: An array of phandles, each referring to a flash LED, a sub-node
+  of the LED driver device node.
+
+
 Optional endpoint properties
 
 
-- 
2.11.0



[PATCH v8 20/21] dt: bindings: smiapp: Document lens-focus and flash properties

2017-09-05 Thread Sakari Ailus
Document optional lens-focus and flash properties for the smiapp driver.

Signed-off-by: Sakari Ailus 
---
 Documentation/devicetree/bindings/media/i2c/nokia,smia.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt 
b/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt
index 855e1faf73e2..f02178eef84d 100644
--- a/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt
+++ b/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt
@@ -27,6 +27,8 @@ Optional properties
 - nokia,nvm-size: The size of the NVM, in bytes. If the size is not given,
   the NVM contents will not be read.
 - reset-gpios: XSHUTDOWN GPIO
+- flash: One or more phandles to refer to flash LEDs
+- lens-focus: Phandle for lens focus
 
 
 Endpoint node mandatory properties
-- 
2.11.0



[PATCH v8 16/21] dt: bindings: Add lens-focus binding for image sensors

2017-09-05 Thread Sakari Ailus
The lens-focus property contains a phandle to the lens voice coil driver
that is associated to the sensor; typically both are contained in the same
camera module.

Signed-off-by: Sakari Ailus 
Acked-by: Pavel Machek 
Reviewed-by: Sebastian Reichel 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/media/video-interfaces.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/video-interfaces.txt 
b/Documentation/devicetree/bindings/media/video-interfaces.txt
index efc67161e389..39b19d9d8426 100644
--- a/Documentation/devicetree/bindings/media/video-interfaces.txt
+++ b/Documentation/devicetree/bindings/media/video-interfaces.txt
@@ -74,6 +74,8 @@ Optional properties
 - flash: An array of phandles, each referring to a flash LED, a sub-node
   of the LED driver device node.
 
+- lens-focus: A phandle to the node of the focus lens controller.
+
 
 Optional endpoint properties
 
-- 
2.11.0



[PATCH v8 05/21] docs-rst: v4l: Include Qualcomm CAMSS in documentation build

2017-09-05 Thread Sakari Ailus
Qualcomm CAMSS was left out from documentation build. Fix this.

Signed-off-by: Sakari Ailus 
Reviewed-by: Laurent Pinchart 
Acked-by: Hans Verkuil 
---
 Documentation/media/v4l-drivers/index.rst | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/media/v4l-drivers/index.rst 
b/Documentation/media/v4l-drivers/index.rst
index 10f2ce42ece2..5c202e23616b 100644
--- a/Documentation/media/v4l-drivers/index.rst
+++ b/Documentation/media/v4l-drivers/index.rst
@@ -50,6 +50,7 @@ For more details see the file COPYING in the source 
distribution of Linux.
philips
pvrusb2
pxa_camera
+   qcom_camss
radiotrack
rcar-fdp1
saa7134
-- 
2.11.0



[PATCH v8 13/21] v4l: async: Register sub-devices before calling bound callback

2017-09-05 Thread Sakari Ailus
Register the sub-device before calling the notifier's bound callback.
Doing this the other way around is problematic as the struct v4l2_device
has not assigned for the sub-device yet and may be required by the bound
callback.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-async.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index baee95eacbba..79f216723a3f 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -135,13 +135,13 @@ static int v4l2_async_match_notify(struct 
v4l2_async_notifier *notifier,
 {
int ret;
 
-   ret = v4l2_async_notifier_call_bound(notifier, sd, asd);
+   ret = v4l2_device_register_subdev(notifier->v4l2_dev, sd);
if (ret < 0)
return ret;
 
-   ret = v4l2_device_register_subdev(notifier->v4l2_dev, sd);
+   ret = v4l2_async_notifier_call_bound(notifier, sd, asd);
if (ret < 0) {
-   v4l2_async_notifier_call_unbind(notifier, sd, asd);
+   v4l2_device_unregister_subdev(sd);
return ret;
}
 
-- 
2.11.0



[PATCH v8 01/21] v4l: fwnode: Move KernelDoc documentation to the header

2017-09-05 Thread Sakari Ailus
In V4L2 the practice is to have the KernelDoc documentation in the header
and not in .c source code files. This consequientally makes the V4L2
fwnode function documentation part of the Media documentation build.

Also correct the link related function and argument naming in
documentation.

Signed-off-by: Sakari Ailus 
Reviewed-by: Niklas Söderlund 
Acked-by: Hans Verkuil 
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 75 
 include/media/v4l2-fwnode.h   | 81 ++-
 2 files changed, 80 insertions(+), 76 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 40b2fbfe8865..706f9e7b90f1 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -181,25 +181,6 @@ v4l2_fwnode_endpoint_parse_csi1_bus(struct fwnode_handle 
*fwnode,
vep->bus_type = V4L2_MBUS_CSI1;
 }
 
-/**
- * v4l2_fwnode_endpoint_parse() - parse all fwnode node properties
- * @fwnode: pointer to the endpoint's fwnode handle
- * @vep: pointer to the V4L2 fwnode data structure
- *
- * All properties are optional. If none are found, we don't set any flags. This
- * means the port has a static configuration and no properties have to be
- * specified explicitly. If any properties that identify the bus as parallel
- * are found and slave-mode isn't set, we set V4L2_MBUS_MASTER. Similarly, if
- * we recognise the bus as serial CSI-2 and clock-noncontinuous isn't set, we
- * set the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag. The caller should hold a
- * reference to @fwnode.
- *
- * NOTE: This function does not parse properties the size of which is variable
- * without a low fixed limit. Please use v4l2_fwnode_endpoint_alloc_parse() in
- * new drivers instead.
- *
- * Return: 0 on success or a negative error code on failure.
- */
 int v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
   struct v4l2_fwnode_endpoint *vep)
 {
@@ -239,14 +220,6 @@ int v4l2_fwnode_endpoint_parse(struct fwnode_handle 
*fwnode,
 }
 EXPORT_SYMBOL_GPL(v4l2_fwnode_endpoint_parse);
 
-/*
- * v4l2_fwnode_endpoint_free() - free the V4L2 fwnode acquired by
- * v4l2_fwnode_endpoint_alloc_parse()
- * @vep - the V4L2 fwnode the resources of which are to be released
- *
- * It is safe to call this function with NULL argument or on a V4L2 fwnode the
- * parsing of which failed.
- */
 void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep)
 {
if (IS_ERR_OR_NULL(vep))
@@ -257,29 +230,6 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint 
*vep)
 }
 EXPORT_SYMBOL_GPL(v4l2_fwnode_endpoint_free);
 
-/**
- * v4l2_fwnode_endpoint_alloc_parse() - parse all fwnode node properties
- * @fwnode: pointer to the endpoint's fwnode handle
- *
- * All properties are optional. If none are found, we don't set any flags. This
- * means the port has a static configuration and no properties have to be
- * specified explicitly. If any properties that identify the bus as parallel
- * are found and slave-mode isn't set, we set V4L2_MBUS_MASTER. Similarly, if
- * we recognise the bus as serial CSI-2 and clock-noncontinuous isn't set, we
- * set the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag. The caller should hold a
- * reference to @fwnode.
- *
- * v4l2_fwnode_endpoint_alloc_parse() has two important differences to
- * v4l2_fwnode_endpoint_parse():
- *
- * 1. It also parses variable size data.
- *
- * 2. The memory it has allocated to store the variable size data must be freed
- *using v4l2_fwnode_endpoint_free() when no longer needed.
- *
- * Return: Pointer to v4l2_fwnode_endpoint if successful, on an error pointer
- * on error.
- */
 struct v4l2_fwnode_endpoint *v4l2_fwnode_endpoint_alloc_parse(
struct fwnode_handle *fwnode)
 {
@@ -322,24 +272,6 @@ struct v4l2_fwnode_endpoint 
*v4l2_fwnode_endpoint_alloc_parse(
 }
 EXPORT_SYMBOL_GPL(v4l2_fwnode_endpoint_alloc_parse);
 
-/**
- * v4l2_fwnode_endpoint_parse_link() - parse a link between two endpoints
- * @__fwnode: pointer to the endpoint's fwnode at the local end of the link
- * @link: pointer to the V4L2 fwnode link data structure
- *
- * Fill the link structure with the local and remote nodes and port numbers.
- * The local_node and remote_node fields are set to point to the local and
- * remote port's parent nodes respectively (the port parent node being the
- * parent node of the port node if that node isn't a 'ports' node, or the
- * grand-parent node of the port node otherwise).
- *
- * A reference is taken to both the local and remote nodes, the caller must use
- * v4l2_fwnode_endpoint_put_link() to drop the references when done with the
- * link.
- *
- * Return: 0 on success, or -ENOLINK if the remote endpoint fwnode can't be
- * found.
- */
 int v4l2_fwnode_parse_link(struct fwnode_handle *__fwnode,
  

[PATCH v8 10/21] omap3isp: Print the name of the entity where no source pads could be found

2017-09-05 Thread Sakari Ailus
If no source pads are found in an entity, print the name of the entity.

Signed-off-by: Sakari Ailus 
---
 drivers/media/platform/omap3isp/isp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/omap3isp/isp.c 
b/drivers/media/platform/omap3isp/isp.c
index 3b1a9cd0e591..9a694924e46e 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -1669,8 +1669,8 @@ static int isp_link_entity(
break;
}
if (i == entity->num_pads) {
-   dev_err(isp->dev, "%s: no source pad in external entity\n",
-   __func__);
+   dev_err(isp->dev, "%s: no source pad in external entity %s\n",
+   __func__, entity->name);
return -EINVAL;
}
 
-- 
2.11.0



[PATCH v8 03/21] v4l: async: Use more intuitive names for internal functions

2017-09-05 Thread Sakari Ailus
Rename internal functions to make the names of the functions better
describe what they do.

Old nameNew name
v4l2_async_test_notify  v4l2_async_match_notify
v4l2_async_belongs  v4l2_async_find_match

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-async.c | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index f50a82767863..3d81ff6a496f 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -65,8 +65,8 @@ static LIST_HEAD(subdev_list);
 static LIST_HEAD(notifier_list);
 static DEFINE_MUTEX(list_lock);
 
-static struct v4l2_async_subdev *v4l2_async_belongs(struct v4l2_async_notifier 
*notifier,
-   struct v4l2_subdev *sd)
+static struct v4l2_async_subdev *v4l2_async_find_match(
+   struct v4l2_async_notifier *notifier, struct v4l2_subdev *sd)
 {
bool (*match)(struct v4l2_subdev *, struct v4l2_async_subdev *);
struct v4l2_async_subdev *asd;
@@ -100,9 +100,9 @@ static struct v4l2_async_subdev *v4l2_async_belongs(struct 
v4l2_async_notifier *
return NULL;
 }
 
-static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,
- struct v4l2_subdev *sd,
- struct v4l2_async_subdev *asd)
+static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier,
+  struct v4l2_subdev *sd,
+  struct v4l2_async_subdev *asd)
 {
int ret;
 
@@ -180,11 +180,11 @@ int v4l2_async_notifier_register(struct v4l2_device 
*v4l2_dev,
list_for_each_entry_safe(sd, tmp, _list, async_list) {
int ret;
 
-   asd = v4l2_async_belongs(notifier, sd);
+   asd = v4l2_async_find_match(notifier, sd);
if (!asd)
continue;
 
-   ret = v4l2_async_test_notify(notifier, sd, asd);
+   ret = v4l2_async_match_notify(notifier, sd, asd);
if (ret < 0) {
mutex_unlock(_lock);
return ret;
@@ -241,9 +241,10 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd)
INIT_LIST_HEAD(>async_list);
 
list_for_each_entry(notifier, _list, list) {
-   struct v4l2_async_subdev *asd = v4l2_async_belongs(notifier, 
sd);
+   struct v4l2_async_subdev *asd = v4l2_async_find_match(notifier,
+ sd);
if (asd) {
-   int ret = v4l2_async_test_notify(notifier, sd, asd);
+   int ret = v4l2_async_match_notify(notifier, sd, asd);
mutex_unlock(_lock);
return ret;
}
-- 
2.11.0



[PATCH] media: get rid of removed DMX_GET_CAPS and DMX_SET_SOURCE leftovers

2017-09-05 Thread Mauro Carvalho Chehab
Those two ioctls were never used within the Kernel. Still, there
used to have compat32 code there (and an if #0 block at the core).

Get rid of them.

Fixes: 286fe1ca3fa1 ("media: dmx.h: get rid of DMX_GET_CAPS")
Fixes: 13adefbe9e56 ("media: dmx.h: get rid of DMX_SET_SOURCE")
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb-core/dmxdev.c | 20 
 fs/compat_ioctl.c   |  2 --
 2 files changed, 22 deletions(-)

diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c
index 16b0b74c3114..18e4230865be 100644
--- a/drivers/media/dvb-core/dmxdev.c
+++ b/drivers/media/dvb-core/dmxdev.c
@@ -1025,26 +1025,6 @@ static int dvb_demux_do_ioctl(struct file *file,
dmxdev->demux->get_pes_pids(dmxdev->demux, parg);
break;
 
-#if 0
-   /* Not used upstream and never documented */
-
-   case DMX_GET_CAPS:
-   if (!dmxdev->demux->get_caps) {
-   ret = -EINVAL;
-   break;
-   }
-   ret = dmxdev->demux->get_caps(dmxdev->demux, parg);
-   break;
-
-   case DMX_SET_SOURCE:
-   if (!dmxdev->demux->set_source) {
-   ret = -EINVAL;
-   break;
-   }
-   ret = dmxdev->demux->set_source(dmxdev->demux, parg);
-   break;
-#endif
-
case DMX_GET_STC:
if (!dmxdev->demux->get_stc) {
ret = -EINVAL;
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 2dd4a7af7dd7..d27b326d96f4 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -1331,8 +1331,6 @@ COMPATIBLE_IOCTL(DMX_SET_FILTER)
 COMPATIBLE_IOCTL(DMX_SET_PES_FILTER)
 COMPATIBLE_IOCTL(DMX_SET_BUFFER_SIZE)
 COMPATIBLE_IOCTL(DMX_GET_PES_PIDS)
-COMPATIBLE_IOCTL(DMX_GET_CAPS)
-COMPATIBLE_IOCTL(DMX_SET_SOURCE)
 COMPATIBLE_IOCTL(DMX_GET_STC)
 COMPATIBLE_IOCTL(FE_GET_INFO)
 COMPATIBLE_IOCTL(FE_DISEQC_RESET_OVERLOAD)
-- 
2.13.3



[linuxtv-media:fixes 2543/2599] fs/compat_ioctl.c:1335:18: error: 'DMX_SET_SOURCE' undeclared here (not in a function)

2017-09-05 Thread kbuild test robot
tree:   git://linuxtv.org/media_tree.git fixes
head:   12f92866f13f9ca12e158c07978246ed83d52ed0
commit: 13adefbe9e566c6db91579e4ce17f1e5193d6f2c [2543/2599] media: dmx.h: get 
rid of DMX_SET_SOURCE
config: x86_64-randconfig-i0-201736 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
git checkout 13adefbe9e566c6db91579e4ce17f1e5193d6f2c
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   fs/compat_ioctl.c:1334:18: error: 'DMX_GET_CAPS' undeclared here (not in a 
function)
COMPATIBLE_IOCTL(DMX_GET_CAPS)
 ^
   fs/compat_ioctl.c:833:21: note: in definition of macro 'XFORM'
#define XFORM(i) (((i) ^ ((i) << 27) ^ ((i) << 17)) & 0x)
^
   fs/compat_ioctl.c:1334:1: note: in expansion of macro 'COMPATIBLE_IOCTL'
COMPATIBLE_IOCTL(DMX_GET_CAPS)
^
>> fs/compat_ioctl.c:1335:18: error: 'DMX_SET_SOURCE' undeclared here (not in a 
>> function)
COMPATIBLE_IOCTL(DMX_SET_SOURCE)
 ^
   fs/compat_ioctl.c:833:21: note: in definition of macro 'XFORM'
#define XFORM(i) (((i) ^ ((i) << 27) ^ ((i) << 17)) & 0x)
^
   fs/compat_ioctl.c:1335:1: note: in expansion of macro 'COMPATIBLE_IOCTL'
COMPATIBLE_IOCTL(DMX_SET_SOURCE)
^

vim +/DMX_SET_SOURCE +1335 fs/compat_ioctl.c

644fd4f5 Christoph Hellwig  2007-05-08   849  
644fd4f5 Christoph Hellwig  2007-05-08   850  /* Big T */
644fd4f5 Christoph Hellwig  2007-05-08   851  COMPATIBLE_IOCTL(TCGETA)
644fd4f5 Christoph Hellwig  2007-05-08   852  COMPATIBLE_IOCTL(TCSETA)
644fd4f5 Christoph Hellwig  2007-05-08   853  COMPATIBLE_IOCTL(TCSETAW)
644fd4f5 Christoph Hellwig  2007-05-08   854  COMPATIBLE_IOCTL(TCSETAF)
644fd4f5 Christoph Hellwig  2007-05-08   855  COMPATIBLE_IOCTL(TCSBRK)
644fd4f5 Christoph Hellwig  2007-05-08   856  COMPATIBLE_IOCTL(TCXONC)
644fd4f5 Christoph Hellwig  2007-05-08   857  COMPATIBLE_IOCTL(TCFLSH)
644fd4f5 Christoph Hellwig  2007-05-08   858  COMPATIBLE_IOCTL(TCGETS)
644fd4f5 Christoph Hellwig  2007-05-08   859  COMPATIBLE_IOCTL(TCSETS)
644fd4f5 Christoph Hellwig  2007-05-08   860  COMPATIBLE_IOCTL(TCSETSW)
644fd4f5 Christoph Hellwig  2007-05-08   861  COMPATIBLE_IOCTL(TCSETSF)
644fd4f5 Christoph Hellwig  2007-05-08   862  COMPATIBLE_IOCTL(TIOCLINUX)
644fd4f5 Christoph Hellwig  2007-05-08   863  COMPATIBLE_IOCTL(TIOCSBRK)
b7b8de08 Werner Fink2010-12-03   864  COMPATIBLE_IOCTL(TIOCGDEV)
644fd4f5 Christoph Hellwig  2007-05-08   865  COMPATIBLE_IOCTL(TIOCCBRK)
4cfbafd3 Andreas Schwab 2010-02-10   866  COMPATIBLE_IOCTL(TIOCGSID)
644fd4f5 Christoph Hellwig  2007-05-08   867  COMPATIBLE_IOCTL(TIOCGICOUNT)
c6298038 Cyrill Gorcunov2012-10-24   868  COMPATIBLE_IOCTL(TIOCGEXCL)
644fd4f5 Christoph Hellwig  2007-05-08   869  /* Little t */
644fd4f5 Christoph Hellwig  2007-05-08   870  COMPATIBLE_IOCTL(TIOCGETD)
644fd4f5 Christoph Hellwig  2007-05-08   871  COMPATIBLE_IOCTL(TIOCSETD)
644fd4f5 Christoph Hellwig  2007-05-08   872  COMPATIBLE_IOCTL(TIOCEXCL)
644fd4f5 Christoph Hellwig  2007-05-08   873  COMPATIBLE_IOCTL(TIOCNXCL)
644fd4f5 Christoph Hellwig  2007-05-08   874  COMPATIBLE_IOCTL(TIOCCONS)
644fd4f5 Christoph Hellwig  2007-05-08   875  COMPATIBLE_IOCTL(TIOCGSOFTCAR)
644fd4f5 Christoph Hellwig  2007-05-08   876  COMPATIBLE_IOCTL(TIOCSSOFTCAR)
644fd4f5 Christoph Hellwig  2007-05-08   877  COMPATIBLE_IOCTL(TIOCSWINSZ)
644fd4f5 Christoph Hellwig  2007-05-08   878  COMPATIBLE_IOCTL(TIOCGWINSZ)
644fd4f5 Christoph Hellwig  2007-05-08   879  COMPATIBLE_IOCTL(TIOCMGET)
644fd4f5 Christoph Hellwig  2007-05-08   880  COMPATIBLE_IOCTL(TIOCMBIC)
644fd4f5 Christoph Hellwig  2007-05-08   881  COMPATIBLE_IOCTL(TIOCMBIS)
644fd4f5 Christoph Hellwig  2007-05-08   882  COMPATIBLE_IOCTL(TIOCMSET)
644fd4f5 Christoph Hellwig  2007-05-08   883  COMPATIBLE_IOCTL(TIOCNOTTY)
644fd4f5 Christoph Hellwig  2007-05-08   884  COMPATIBLE_IOCTL(TIOCSTI)
644fd4f5 Christoph Hellwig  2007-05-08   885  COMPATIBLE_IOCTL(TIOCOUTQ)
644fd4f5 Christoph Hellwig  2007-05-08   886  COMPATIBLE_IOCTL(TIOCSPGRP)
644fd4f5 Christoph Hellwig  2007-05-08   887  COMPATIBLE_IOCTL(TIOCGPGRP)
644fd4f5 Christoph Hellwig  2007-05-08   888  
COMPATIBLE_IOCTL(TIOCSERGETLSR)
142e5460 Jaeden Amero   2012-09-24   889  #ifdef TIOCSRS485
84c3b848 Jaeden Amero   2012-09-19   890  COMPATIBLE_IOCTL(TIOCSRS485)
142e5460 Jaeden Amero   2012-09-24   891  #endif
142e5460 Jaeden Amero   2012-09-24   892  #ifdef TIOCGRS485
84c3b848 Jaeden Amero   2012-09-19   893  COMPATIBLE_IOCTL(TIOCGRS485)
142e5460 Jaeden Amero   2012-09-24   894  #endif
81257def Heiko Carstens 2007-11-28   895  #ifdef TCGETS2
81257def Heiko Carstens 2007-11-28   896  COMPATIBLE_IOCTL(TCGETS2)
81257def Heiko 

[PATCH] [media] imon: make two const arrays static, reduces object code size

2017-09-05 Thread Colin King
From: Colin Ian King 

Don't populate the const arrays vfd_packet6 and fp_packet on the
stack, instead make them static.  Makes the object code smaller
by over 600 bytes:

Before:
   textdata bss dec hex filename
  43794   179201024   62738f512 drivers/media/rc/imon.o

After:
   textdata bss dec hex filename
  42994   180801024   62098f292 drivers/media/rc/imon.o

Signed-off-by: Colin Ian King 
---
 drivers/media/rc/imon.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 7b3f31cc63d2..c50875a8c5b6 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -943,7 +943,7 @@ static ssize_t vfd_write(struct file *file, const char 
__user *buf,
int seq;
int retval = 0;
struct imon_context *ictx;
-   const unsigned char vfd_packet6[] = {
+   static const unsigned char vfd_packet6[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF };
 
ictx = file->private_data;
@@ -2047,8 +2047,8 @@ static struct rc_dev *imon_init_rdev(struct imon_context 
*ictx)
 {
struct rc_dev *rdev;
int ret;
-   const unsigned char fp_packet[] = { 0x40, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x88 };
+   static const unsigned char fp_packet[] = {
+   0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88 };
 
rdev = rc_allocate_device(ictx->dev_descr->flags & IMON_IR_RAW ?
  RC_DRIVER_IR_RAW : RC_DRIVER_SCANCODE);
-- 
2.14.1



[media-next:master 2542/2599] fs/compat_ioctl.c:1334:18: error: 'DMX_GET_CAPS' undeclared here (not in a function)

2017-09-05 Thread kbuild test robot
tree:   git://linuxtv.org/mchehab/media-next.git master
head:   12f92866f13f9ca12e158c07978246ed83d52ed0
commit: 286fe1ca3fa1b6fcc7ce8695b7c8d681e6e1c3b7 [2542/2599] media: dmx.h: get 
rid of DMX_GET_CAPS
config: x86_64-randconfig-i0-201736 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
git checkout 286fe1ca3fa1b6fcc7ce8695b7c8d681e6e1c3b7
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> fs/compat_ioctl.c:1334:18: error: 'DMX_GET_CAPS' undeclared here (not in a 
>> function)
COMPATIBLE_IOCTL(DMX_GET_CAPS)
 ^
   fs/compat_ioctl.c:833:21: note: in definition of macro 'XFORM'
#define XFORM(i) (((i) ^ ((i) << 27) ^ ((i) << 17)) & 0x)
^
   fs/compat_ioctl.c:1334:1: note: in expansion of macro 'COMPATIBLE_IOCTL'
COMPATIBLE_IOCTL(DMX_GET_CAPS)
^

vim +/DMX_GET_CAPS +1334 fs/compat_ioctl.c

644fd4f5 Christoph Hellwig  2007-05-08   849  
644fd4f5 Christoph Hellwig  2007-05-08   850  /* Big T */
644fd4f5 Christoph Hellwig  2007-05-08   851  COMPATIBLE_IOCTL(TCGETA)
644fd4f5 Christoph Hellwig  2007-05-08   852  COMPATIBLE_IOCTL(TCSETA)
644fd4f5 Christoph Hellwig  2007-05-08   853  COMPATIBLE_IOCTL(TCSETAW)
644fd4f5 Christoph Hellwig  2007-05-08   854  COMPATIBLE_IOCTL(TCSETAF)
644fd4f5 Christoph Hellwig  2007-05-08   855  COMPATIBLE_IOCTL(TCSBRK)
644fd4f5 Christoph Hellwig  2007-05-08   856  COMPATIBLE_IOCTL(TCXONC)
644fd4f5 Christoph Hellwig  2007-05-08   857  COMPATIBLE_IOCTL(TCFLSH)
644fd4f5 Christoph Hellwig  2007-05-08   858  COMPATIBLE_IOCTL(TCGETS)
644fd4f5 Christoph Hellwig  2007-05-08   859  COMPATIBLE_IOCTL(TCSETS)
644fd4f5 Christoph Hellwig  2007-05-08   860  COMPATIBLE_IOCTL(TCSETSW)
644fd4f5 Christoph Hellwig  2007-05-08   861  COMPATIBLE_IOCTL(TCSETSF)
644fd4f5 Christoph Hellwig  2007-05-08   862  COMPATIBLE_IOCTL(TIOCLINUX)
644fd4f5 Christoph Hellwig  2007-05-08   863  COMPATIBLE_IOCTL(TIOCSBRK)
b7b8de08 Werner Fink2010-12-03   864  COMPATIBLE_IOCTL(TIOCGDEV)
644fd4f5 Christoph Hellwig  2007-05-08   865  COMPATIBLE_IOCTL(TIOCCBRK)
4cfbafd3 Andreas Schwab 2010-02-10   866  COMPATIBLE_IOCTL(TIOCGSID)
644fd4f5 Christoph Hellwig  2007-05-08   867  COMPATIBLE_IOCTL(TIOCGICOUNT)
c6298038 Cyrill Gorcunov2012-10-24   868  COMPATIBLE_IOCTL(TIOCGEXCL)
644fd4f5 Christoph Hellwig  2007-05-08   869  /* Little t */
644fd4f5 Christoph Hellwig  2007-05-08   870  COMPATIBLE_IOCTL(TIOCGETD)
644fd4f5 Christoph Hellwig  2007-05-08   871  COMPATIBLE_IOCTL(TIOCSETD)
644fd4f5 Christoph Hellwig  2007-05-08   872  COMPATIBLE_IOCTL(TIOCEXCL)
644fd4f5 Christoph Hellwig  2007-05-08   873  COMPATIBLE_IOCTL(TIOCNXCL)
644fd4f5 Christoph Hellwig  2007-05-08   874  COMPATIBLE_IOCTL(TIOCCONS)
644fd4f5 Christoph Hellwig  2007-05-08   875  COMPATIBLE_IOCTL(TIOCGSOFTCAR)
644fd4f5 Christoph Hellwig  2007-05-08   876  COMPATIBLE_IOCTL(TIOCSSOFTCAR)
644fd4f5 Christoph Hellwig  2007-05-08   877  COMPATIBLE_IOCTL(TIOCSWINSZ)
644fd4f5 Christoph Hellwig  2007-05-08   878  COMPATIBLE_IOCTL(TIOCGWINSZ)
644fd4f5 Christoph Hellwig  2007-05-08   879  COMPATIBLE_IOCTL(TIOCMGET)
644fd4f5 Christoph Hellwig  2007-05-08   880  COMPATIBLE_IOCTL(TIOCMBIC)
644fd4f5 Christoph Hellwig  2007-05-08   881  COMPATIBLE_IOCTL(TIOCMBIS)
644fd4f5 Christoph Hellwig  2007-05-08   882  COMPATIBLE_IOCTL(TIOCMSET)
644fd4f5 Christoph Hellwig  2007-05-08   883  COMPATIBLE_IOCTL(TIOCNOTTY)
644fd4f5 Christoph Hellwig  2007-05-08   884  COMPATIBLE_IOCTL(TIOCSTI)
644fd4f5 Christoph Hellwig  2007-05-08   885  COMPATIBLE_IOCTL(TIOCOUTQ)
644fd4f5 Christoph Hellwig  2007-05-08   886  COMPATIBLE_IOCTL(TIOCSPGRP)
644fd4f5 Christoph Hellwig  2007-05-08   887  COMPATIBLE_IOCTL(TIOCGPGRP)
644fd4f5 Christoph Hellwig  2007-05-08   888  
COMPATIBLE_IOCTL(TIOCSERGETLSR)
142e5460 Jaeden Amero   2012-09-24   889  #ifdef TIOCSRS485
84c3b848 Jaeden Amero   2012-09-19   890  COMPATIBLE_IOCTL(TIOCSRS485)
142e5460 Jaeden Amero   2012-09-24   891  #endif
142e5460 Jaeden Amero   2012-09-24   892  #ifdef TIOCGRS485
84c3b848 Jaeden Amero   2012-09-19   893  COMPATIBLE_IOCTL(TIOCGRS485)
142e5460 Jaeden Amero   2012-09-24   894  #endif
81257def Heiko Carstens 2007-11-28   895  #ifdef TCGETS2
81257def Heiko Carstens 2007-11-28   896  COMPATIBLE_IOCTL(TCGETS2)
81257def Heiko Carstens 2007-11-28   897  COMPATIBLE_IOCTL(TCSETS2)
81257def Heiko Carstens 2007-11-28   898  COMPATIBLE_IOCTL(TCSETSW2)
81257def Heiko Carstens 2007-11-28   899  COMPATIBLE_IOCTL(TCSETSF2)
81257def Heiko Carstens 2007-11-28   900  #endif
644fd4f5 Christoph Hellwig  2007-05-08   901  /* Little f */
644fd4f5 Christoph Hellwig  2007-05-08   902  COMPATIBLE_IOCTL(FIOCLEX)
644fd4f5 

[PATCH] media: add qcom_camss.rst to v4l-drivers rst file

2017-09-05 Thread Mauro Carvalho Chehab
Avoid this warning:
/devel/v4l/docs/Documentation/media/v4l-drivers/qcom_camss.rst:: 
WARNING: document isn't included in any toctree

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/media/v4l-drivers/index.rst | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/media/v4l-drivers/index.rst 
b/Documentation/media/v4l-drivers/index.rst
index 3643e63c4e46..679238e786a7 100644
--- a/Documentation/media/v4l-drivers/index.rst
+++ b/Documentation/media/v4l-drivers/index.rst
@@ -52,6 +52,7 @@ For more details see the file COPYING in the source 
distribution of Linux.
philips
pvrusb2
pxa_camera
+   qcom_camss
radiotrack
rcar-fdp1
saa7134
-- 
2.13.5



[PATCH 1/2] media: dvb uapi: move frontend legacy API to another part of the book

2017-09-05 Thread Mauro Carvalho Chehab
There's a chapter for the legacy APIs. Move the frontend DVBv3
API to it, and update the chapter's introduction accordingly.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/media/uapi/dvb/frontend.rst|  1 -
 Documentation/media/uapi/dvb/legacy_dvb_apis.rst | 21 ++---
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/Documentation/media/uapi/dvb/frontend.rst 
b/Documentation/media/uapi/dvb/frontend.rst
index b9cfcad39823..4967c48d46ce 100644
--- a/Documentation/media/uapi/dvb/frontend.rst
+++ b/Documentation/media/uapi/dvb/frontend.rst
@@ -54,4 +54,3 @@ Data types and ioctl definitions can be accessed by including
 dvb-fe-read-status
 dvbproperty
 frontend_fcalls
-frontend_legacy_dvbv3_api
diff --git a/Documentation/media/uapi/dvb/legacy_dvb_apis.rst 
b/Documentation/media/uapi/dvb/legacy_dvb_apis.rst
index 7eb14d6f729f..e1b2c9c7b620 100644
--- a/Documentation/media/uapi/dvb/legacy_dvb_apis.rst
+++ b/Documentation/media/uapi/dvb/legacy_dvb_apis.rst
@@ -6,20 +6,27 @@
 Digital TV Deprecated APIs
 ***
 
-The APIs described here are kept only for historical reasons. There's
-just one driver for a very legacy hardware that uses this API. No modern
-drivers should use it. Instead, audio and video should be using the V4L2
-and ALSA APIs, and the pipelines should be set using the Media
-Controller API
+The APIs described here **should not** be used on new drivers or applications.
 
-.. note::
+The DVBv3 frontend API has issues with new delivery systems, including
+DVB-S2, DVB-T2, ISDB, etc.
+
+There's just one driver for a very legacy hardware using the Digital TV
+audio and video APIs. No modern drivers should use it. Instead, audio and
+video should be using the V4L2 and ALSA APIs, and the pipelines should
+be set via the Media Controller API.
+
+.. attention::
 
The APIs described here doesn't necessarily reflect the current
-   code implementation.
+   code implementation, as this section of the document was written
+   for DVB version 1, while the code reflects DVB version 3
+   implementation.
 
 
 .. toctree::
 :maxdepth: 1
 
+frontend_legacy_dvbv3_api
 video
 audio
-- 
2.13.5



[PATCH 2/2] media: dvb headers: make checkpatch happier

2017-09-05 Thread Mauro Carvalho Chehab
Adjust dvb ca.h, dmx.h and frontend.h in order to make
checkpatch happier. Now, it only complains about the typedefs,
and those are there just to provide backward userspace
compatibility.

Signed-off-by: Mauro Carvalho Chehab 
---
 include/uapi/linux/dvb/ca.h   | 2 +-
 include/uapi/linux/dvb/dmx.h  | 5 ++---
 include/uapi/linux/dvb/frontend.h | 6 +++---
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/include/uapi/linux/dvb/ca.h b/include/uapi/linux/dvb/ca.h
index 24fc38efbc2b..cb150029fdff 100644
--- a/include/uapi/linux/dvb/ca.h
+++ b/include/uapi/linux/dvb/ca.h
@@ -139,7 +139,7 @@ struct ca_descr {
 #define CA_SEND_MSG   _IOW('o', 133, struct ca_msg)
 #define CA_SET_DESCR  _IOW('o', 134, struct ca_descr)
 
-#if !defined (__KERNEL__)
+#if !defined(__KERNEL__)
 
 /* This is needed for legacy userspace support */
 typedef struct ca_slot_info ca_slot_info_t;
diff --git a/include/uapi/linux/dvb/dmx.h b/include/uapi/linux/dvb/dmx.h
index 4e3f3a2fe83f..4aa5f6a1815a 100644
--- a/include/uapi/linux/dvb/dmx.h
+++ b/include/uapi/linux/dvb/dmx.h
@@ -189,8 +189,7 @@ struct dmx_sct_filter_params {
  * @pes_type:  Type of the pes filter, as specified by  dmx_pes_type.
  * @flags: Demux PES flags.
  */
-struct dmx_pes_filter_params
-{
+struct dmx_pes_filter_params {
__u16   pid;
enum dmx_input  input;
enum dmx_output output;
@@ -221,7 +220,7 @@ struct dmx_stc {
 #define DMX_ADD_PID  _IOW('o', 51, __u16)
 #define DMX_REMOVE_PID   _IOW('o', 52, __u16)
 
-#if !defined (__KERNEL__)
+#if !defined(__KERNEL__)
 
 /* This is needed for legacy userspace support */
 typedef enum dmx_output dmx_output_t;
diff --git a/include/uapi/linux/dvb/frontend.h 
b/include/uapi/linux/dvb/frontend.h
index fc2edb6014fe..861cacd5711f 100644
--- a/include/uapi/linux/dvb/frontend.h
+++ b/include/uapi/linux/dvb/frontend.h
@@ -907,7 +907,7 @@ struct dtv_properties {
 #define FE_SET_PROPERTY   _IOW('o', 82, struct dtv_properties)
 #define FE_GET_PROPERTY   _IOR('o', 83, struct dtv_properties)
 
-#if defined(__DVB_CORE__) || !defined (__KERNEL__)
+#if defined(__DVB_CORE__) || !defined(__KERNEL__)
 
 /*
  * DEPRECATED: Everything below is deprecated in favor of DVBv5 API
@@ -982,8 +982,8 @@ struct dvb_ofdm_parameters {
 };
 
 struct dvb_frontend_parameters {
-   __u32 frequency; /* (absolute) frequency in Hz for DVB-C/DVB-T/ATSC 
*/
-/* intermediate frequency in kHz for DVB-S */
+   __u32 frequency;  /* (absolute) frequency in Hz for DVB-C/DVB-T/ATSC */
+ /* intermediate frequency in kHz for DVB-S */
fe_spectral_inversion_t inversion;
union {
struct dvb_qpsk_parameters qpsk;/* DVB-S */
-- 
2.13.5



[PATCH] [media] cx25840: make array stds static const, reduces object code size

2017-09-05 Thread Colin King
From: Colin Ian King 

Don't populate the array syds on the stack, instead make it static const.
Makes the object code smaller by over 280 bytes:

Before:
   textdata bss dec hex filename
  81451   12784 704   94939   172db cx25840-core.o

   textdata bss dec hex filename
  81070   12880 704   94654   171be cx25840-core.o

Signed-off-by: Colin Ian King 
---
 drivers/media/i2c/cx25840/cx25840-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/cx25840/cx25840-core.c 
b/drivers/media/i2c/cx25840/cx25840-core.c
index 39f51daa7558..f38bf819d805 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -1745,7 +1745,7 @@ static int cx25840_g_std(struct v4l2_subdev *sd, 
v4l2_std_id *std)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
 
-   v4l2_std_id stds[] = {
+   static const v4l2_std_id stds[] = {
/*  */ V4L2_STD_UNKNOWN,
 
/* 0001 */ V4L2_STD_NTSC_M,
-- 
2.14.1



Re: [PATCH v4] drm/bridge/sii8620: add remote control support

2017-09-05 Thread Maciej Purski

Hi Hans,

According to my tests, when pressing 'Press and Hold' key, the messages 
received are
always the same until the button is released. The second message is received 
after
~550 ms and each next message is received every ~100 ms.

Regards,

Maciej

On 27/08/2017 14:40, Hans Verkuil wrote:


Hi Maciej,

On 24/08/17 10:58, Maciej Purski wrote:

MHL specification defines Remote Control Protocol(RCP) to
send input events between MHL devices.
The driver now recognizes RCP messages and reacts to them
by reporting key events to input subsystem, allowing
a user to control a device using TV remote control.

Before I Ack this I would like to know how this behaves w.r.t. autorepeat.

If you keep pressing a remote key, what RCP messages do you receive and
at what time intervals? If that's similar to what CEC does, then it is
very likely that the same rules apply and I will have to review this patch
again with that in mind.

See the commit log for the patching fixing the CEC 'Press and Hold' behavior:

https://git.linuxtv.org/media_tree.git/commit/drivers/media/cec/cec-adap.c?id=a9a249a2c997506a64eaee22f1458fda893f62a8

If you have access to the HDMI 2.0 specification, then that spec describes the 
CEC
'Press and Hold' behavior in detail.

Regards,

Hans


Signed-off-by: Maciej Purski 
---

Changes in v2:
- use RC subsystem (including CEC keymap)
- RC device initialized in attach drm_bridge callback and
   removed in detach callback. This is necessary, because RC_CORE,
   which is needed during rc_dev init, is loaded after sii8620.
   DRM bridge is binded later which solves the problem.
- add RC_CORE dependency

Changes in v3:
- fix error handling in init_rcp and in attach callback

Changes in v4:
- usage of rc-core API compatible with upcoming changes
- fix error handling in init_rcp
- fix commit message
---
  drivers/gpu/drm/bridge/Kconfig   |  2 +-
  drivers/gpu/drm/bridge/sil-sii8620.c | 96 ++--
  include/drm/bridge/mhl.h |  4 ++
  3 files changed, 96 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index adf9ae0..6ef901c 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -71,7 +71,7 @@ config DRM_PARADE_PS8622
  
  config DRM_SIL_SII8620

tristate "Silicon Image SII8620 HDMI/MHL bridge"
-   depends on OF
+   depends on OF && RC_CORE
select DRM_KMS_HELPER
help
  Silicon Image SII8620 HDMI/MHL bridge chip driver.
diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c 
b/drivers/gpu/drm/bridge/sil-sii8620.c
index 2d51a22..ecb26c4 100644
--- a/drivers/gpu/drm/bridge/sil-sii8620.c
+++ b/drivers/gpu/drm/bridge/sil-sii8620.c
@@ -28,6 +28,8 @@
  #include 
  #include 
  
+#include 

+
  #include "sil-sii8620.h"
  
  #define SII8620_BURST_BUF_LEN 288

@@ -58,6 +60,7 @@ enum sii8620_mt_state {
  struct sii8620 {
struct drm_bridge bridge;
struct device *dev;
+   struct rc_dev *rc_dev;
struct clk *clk_xtal;
struct gpio_desc *gpio_reset;
struct gpio_desc *gpio_int;
@@ -431,6 +434,16 @@ static void sii8620_mt_rap(struct sii8620 *ctx, u8 code)
sii8620_mt_msc_msg(ctx, MHL_MSC_MSG_RAP, code);
  }
  
+static void sii8620_mt_rcpk(struct sii8620 *ctx, u8 code)

+{
+   sii8620_mt_msc_msg(ctx, MHL_MSC_MSG_RCPK, code);
+}
+
+static void sii8620_mt_rcpe(struct sii8620 *ctx, u8 code)
+{
+   sii8620_mt_msc_msg(ctx, MHL_MSC_MSG_RCPE, code);
+}
+
  static void sii8620_mt_read_devcap_send(struct sii8620 *ctx,
struct sii8620_mt_msg *msg)
  {
@@ -1753,6 +1766,25 @@ static void sii8620_send_features(struct sii8620 *ctx)
sii8620_write_buf(ctx, REG_MDT_XMIT_WRITE_PORT, buf, ARRAY_SIZE(buf));
  }
  
+static bool sii8620_rcp_consume(struct sii8620 *ctx, u8 scancode)

+{
+   bool pressed = !(scancode & MHL_RCP_KEY_RELEASED_MASK);
+
+   scancode &= MHL_RCP_KEY_ID_MASK;
+
+   if (!ctx->rc_dev) {
+   dev_dbg(ctx->dev, "RCP input device not initialized\n");
+   return false;
+   }
+
+   if (pressed)
+   rc_keydown(ctx->rc_dev, RC_PROTO_CEC, scancode, 0);
+   else
+   rc_keyup(ctx->rc_dev);
+
+   return true;
+}
+
  static void sii8620_msc_mr_set_int(struct sii8620 *ctx)
  {
u8 ints[MHL_INT_SIZE];
@@ -1804,19 +1836,25 @@ static void sii8620_msc_mt_done(struct sii8620 *ctx)
  
  static void sii8620_msc_mr_msc_msg(struct sii8620 *ctx)

  {
-   struct sii8620_mt_msg *msg = sii8620_msc_msg_first(ctx);
+   struct sii8620_mt_msg *msg;
u8 buf[2];
  
-	if (!msg)

-   return;
-
sii8620_read_buf(ctx, REG_MSC_MR_MSC_MSG_RCVD_1ST_DATA, buf, 2);
  
  	switch (buf[0]) {

case MHL_MSC_MSG_RAPK:
+   msg = sii8620_msc_msg_first(ctx);
+   if (!msg)
+   return;

Re: [ANN] Call for topics for the media mini-summit on Friday Oct 27 in Prague

2017-09-05 Thread Honza Petrouš
>
> Also, if you plan to attend, please let me know. It is open for all, but it is
> nice if we know beforehand who we can expect.
>
> So if you have a topic that you want to discuss there, then just reply to this
> post. If possible, please add a rough idea of how much time you think you will
> need.
>

Hi Hans,

I'm going to attend LCE, but I still don't know if I will be able to
stay till Friday.
When I know more I drop message.

/Honza


Re: [PATCH 1/2] docs-rst: media: Don't use \small for V4L2_PIX_FMT_SRGGB10 documentation

2017-09-05 Thread Sakari Ailus
Hi Mauro,

On Mon, Sep 04, 2017 at 05:41:27PM -0300, Mauro Carvalho Chehab wrote:
> From: Sakari Ailus 
> 
> There appears to be an issue in using \small in certain cases on Sphinx
> 1.4 and 1.5. Other format documents don't use \small either, remove it
> from here as well.
> 
> [mche...@s-opensource.com: kept tabularcolumns - readjusted - and
>  add a few blank lines for it to display better]
> Signed-off-by: Sakari Ailus 
> Signed-off-by: Mauro Carvalho Chehab 

Thanks!

For both:

Acked-by: Sakari Ailus 

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


Re: [ANN] Call for topics for the media mini-summit on Friday Oct 27 in Prague

2017-09-05 Thread Ricardo Ribalda Delgado
Hi Hans

On Fri, Sep 1, 2017 at 11:46 AM, Hans Verkuil  wrote:
>
>
> Also, if you plan to attend, please let me know. It is open for all, but it is
> nice if we know beforehand who we can expect.
>

I plan to attend. I do not have any specific topic right now, but as
the date gets closer I might add something.

See you in Prague.
Thanks


Re: UVC property auto update

2017-09-05 Thread Edgar Thier

> 
> Ok, looking more at the spec, the driver and your patch, here's what I 
> come up with:
> 
> 1. UVC defines which standard controls should have which flags. Among 
> those flags it specifies, which controls should specify the Autoupdate 
> flag. E.g. see the first of them as it appears in my copy of the spec 
> "4.2.2.4.8 Average Bit Rate Control"
> 2. The driver could read out flags from descriptors, but it hard-codes 
> them instead. So, (arguably), there's no need to actually read them at 
> probe time. XUs on the other hand aren't standard, therefore their flags 
> have to be read out.
> 3. In your patch you provide gain as an example. Do you mean the 
> PU_GAIN_CONTROL? The spec doesn't specify, that it should have Autoupdate 
> set. Now, whether that means, that using that flag with PU_GAIN_CONTROL is 
> a violation of the spec - I'm not sure about.
> 
> So, I think, the question really is - are hard-coded flags a proper and 
> sufficient approach or should flags be read from descriptors?
> 

That is the questioned I cannot answer. The current approach (with my patch) 
enables both.
The cameras I work with either assume no AUTO_UPDATE or try to define the FLAG 
themselves.
As to what the standard expects, I do not know as IMO it is not clearly enough 
defined if this flag
is optional or somehow expected. But I think that it makes more sense to ask 
the device
for its capabilities than the other way around. E.g. I have yet to encounter a 
camera that has hue
with AUTO_UPDATE yet the driver expects it.

> 
>> I will also ask the firmware developer if only value changes are available 
>> or flag changes are also
>> a possibility.
> 
> Well, flags aren't likely to change, perhaps. I think min and max values 
> are more likely to be updated.
> 

I just talked to him. There are no plans to use the auto update functionality 
for anything besides
GET_CUR. Flags could get messy since auto update itself could be toggled once 
other properties are
changed. These cross dependencies are not handled in the standard as far as I 
am aware.

> Well, flags aren't likely to change, perhaps. I think min and max values 
> are more likely to be updated.

That depends. When activating an auto feature, say auto-exposure. it could be 
interesting to set
exposure to read-only. For boundary changes I would say the question is how 
many users would
anticipate such a behavior.

>>>
>>> As you can see, it only handles the VALUE_CHANGE (GET_CUR) case. I would 
>>> suggest implementing a patch on top of it to add support for INFO_CHANGE 
>>> and you'd be the best person to test it then!
>>
>> I will try it out. I should be able to give you feedback tomorrow.
> 
> Thanks.
> 

Your patch works in combination with mine. I could not detect any problems.


Re: [PATCH v7 12/18] v4l: async: Allow binding notifiers to sub-devices

2017-09-05 Thread Sakari Ailus
Hi Hans,

Thanks for the review!

On 09/05/17 09:49, Hans Verkuil wrote:
> On 09/03/2017 07:49 PM, Sakari Ailus wrote:
>> Registering a notifier has required the knowledge of struct v4l2_device
>> for the reason that sub-devices generally are registered to the
>> v4l2_device (as well as the media device, also available through
>> v4l2_device).
>>
>> This information is not available for sub-device drivers at probe time.
>>
>> What this patch does is that it allows registering notifiers without
>> having v4l2_device around. Instead the sub-device pointer is stored to the
>> notifier. Once the sub-device of the driver that registered the notifier
>> is registered, the notifier will gain the knowledge of the v4l2_device,
>> and the binding of async sub-devices from the sub-device driver's notifier
>> may proceed.
>>
>> The master notifier's complete callback is only called when all sub-device
>> notifiers are completed.
>>
>> Signed-off-by: Sakari Ailus 
>> ---
>>  drivers/media/v4l2-core/v4l2-async.c | 153 
>> +--
>>  include/media/v4l2-async.h   |  19 -
>>  2 files changed, 146 insertions(+), 26 deletions(-)
>>
>> diff --git a/drivers/media/v4l2-core/v4l2-async.c 
>> b/drivers/media/v4l2-core/v4l2-async.c
>> index 70d02378b48f..55d7886103d2 100644
>> --- a/drivers/media/v4l2-core/v4l2-async.c
>> +++ b/drivers/media/v4l2-core/v4l2-async.c
>> @@ -25,6 +25,10 @@
>>  #include 
>>  #include 
>>  
>> +static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,
>> +  struct v4l2_subdev *sd,
>> +  struct v4l2_async_subdev *asd);
>> +
>>  static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
>>  {
>>  #if IS_ENABLED(CONFIG_I2C)
>> @@ -101,14 +105,69 @@ static struct v4l2_async_subdev 
>> *v4l2_async_belongs(struct v4l2_async_notifier *
>>  return NULL;
>>  }
>>  
>> +static bool v4l2_async_subdev_notifiers_complete(
>> +struct v4l2_async_notifier *notifier)
>> +{
>> +struct v4l2_async_notifier *n;
>> +
>> +list_for_each_entry(n, >notifiers, notifiers) {
>> +if (!n->master)
>> +return false;
>> +}
>> +
>> +return true;
>> +}
>> +
>> +#define notifier_v4l2_dev(n) \
>> +(!!(n)->v4l2_dev ? (n)->v4l2_dev : \
>> + !!(n)->master ? (n)->master->v4l2_dev : NULL)
>> +
>> +static struct v4l2_async_notifier *v4l2_async_get_subdev_notifier(
>> +struct v4l2_async_notifier *notifier, struct v4l2_subdev *sd)
> 
> Why pass the notifier argument when it is not actually used in the function?
> 
> Is this function needed at all? As far as I can see the sd always belongs to
> the given notifier, otherwise the v4l2_async_belongs() call would fail.
> And v4l2_async_belongs() is always called before v4l2_async_test_notify().

The function gets a notifier which the sub-device may have registered,
it's not the same notifier that was used in registering the sub-device
itself.

I'll remove the other argument as well.

> 
> This could all do with some more code comments. I'm having a difficult time
> understanding it all.

Yes, I'm adding comments to v8.

-- 
Sakari Ailus
sakari.ai...@linux.intel.com


Re: [PATCH v7 12/18] v4l: async: Allow binding notifiers to sub-devices

2017-09-05 Thread Hans Verkuil
On 09/03/2017 07:49 PM, Sakari Ailus wrote:
> Registering a notifier has required the knowledge of struct v4l2_device
> for the reason that sub-devices generally are registered to the
> v4l2_device (as well as the media device, also available through
> v4l2_device).
> 
> This information is not available for sub-device drivers at probe time.
> 
> What this patch does is that it allows registering notifiers without
> having v4l2_device around. Instead the sub-device pointer is stored to the
> notifier. Once the sub-device of the driver that registered the notifier
> is registered, the notifier will gain the knowledge of the v4l2_device,
> and the binding of async sub-devices from the sub-device driver's notifier
> may proceed.
> 
> The master notifier's complete callback is only called when all sub-device
> notifiers are completed.
> 
> Signed-off-by: Sakari Ailus 
> ---
>  drivers/media/v4l2-core/v4l2-async.c | 153 
> +--
>  include/media/v4l2-async.h   |  19 -
>  2 files changed, 146 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-async.c 
> b/drivers/media/v4l2-core/v4l2-async.c
> index 70d02378b48f..55d7886103d2 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -25,6 +25,10 @@
>  #include 
>  #include 
>  
> +static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,
> +   struct v4l2_subdev *sd,
> +   struct v4l2_async_subdev *asd);
> +
>  static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
>  {
>  #if IS_ENABLED(CONFIG_I2C)
> @@ -101,14 +105,69 @@ static struct v4l2_async_subdev 
> *v4l2_async_belongs(struct v4l2_async_notifier *
>   return NULL;
>  }
>  
> +static bool v4l2_async_subdev_notifiers_complete(
> + struct v4l2_async_notifier *notifier)
> +{
> + struct v4l2_async_notifier *n;
> +
> + list_for_each_entry(n, >notifiers, notifiers) {
> + if (!n->master)
> + return false;
> + }
> +
> + return true;
> +}
> +
> +#define notifier_v4l2_dev(n) \
> + (!!(n)->v4l2_dev ? (n)->v4l2_dev : \
> +  !!(n)->master ? (n)->master->v4l2_dev : NULL)
> +
> +static struct v4l2_async_notifier *v4l2_async_get_subdev_notifier(
> + struct v4l2_async_notifier *notifier, struct v4l2_subdev *sd)

Why pass the notifier argument when it is not actually used in the function?

Is this function needed at all? As far as I can see the sd always belongs to
the given notifier, otherwise the v4l2_async_belongs() call would fail.
And v4l2_async_belongs() is always called before v4l2_async_test_notify().

This could all do with some more code comments. I'm having a difficult time
understanding it all.

I'll wait for v8 before continuing this.

Regards,

Hans

> +{
> + struct v4l2_async_notifier *n;
> +
> + list_for_each_entry(n, _list, list) {
> + if (n->sd == sd)
> + return n;
> + }
> +
> + return NULL;
> +}