cron job: media_tree daily build: WARNINGS

2017-10-15 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:   Mon Oct 16 05:00:18 CEST 2017
media-tree git hash:8382e556b1a2f30c4bf866f021b33577a64f9ebf
media_build git hash:   8a4a9a7064317bd4a687d35ce0537cb5984330e4
v4l-utils git hash: 01c04f7c8ad1a91af33e20621eba9200f447737e
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: WARNINGS
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: OK
spec-git: OK

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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


[PATCH v6 3/3] media: ov7670: Add the ov7670_s_power function

2017-10-15 Thread Wenyou Yang
Add the ov7670_s_power function which is responsible for
manipulating the power dowm mode through the PWDN pin and the reset
operation through the RESET pin, and keep it powered at all times.

Signed-off-by: Wenyou Yang 
---

Changes in v6:
 - Remove .s_power callback to keep the ov7670 powered at all times.
 - Update the commit log accordingly.

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
 - Add the patch to support the get_fmt ops.
 - Remove the redundant invoking ov7670_init_gpio().

 drivers/media/i2c/ov7670.c | 31 ++-
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index 73ceec63a8ca..35a30605d6e3 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -1544,6 +1544,22 @@ static int ov7670_s_register(struct v4l2_subdev *sd, 
const struct v4l2_dbg_regis
 }
 #endif
 
+static int ov7670_s_power(struct v4l2_subdev *sd, int on)
+{
+   struct ov7670_info *info = to_state(sd);
+
+   if (info->pwdn_gpio)
+   gpiod_direction_output(info->pwdn_gpio, !on);
+   if (on && info->resetb_gpio) {
+   gpiod_set_value(info->resetb_gpio, 1);
+   usleep_range(500, 1000);
+   gpiod_set_value(info->resetb_gpio, 0);
+   usleep_range(3000, 5000);
+   }
+
+   return 0;
+}
+
 static void ov7670_get_default_format(struct v4l2_subdev *sd,
  struct v4l2_mbus_framefmt *format)
 {
@@ -1694,23 +1710,25 @@ static int ov7670_probe(struct i2c_client *client,
if (ret)
return ret;
 
-   ret = ov7670_init_gpio(client, info);
-   if (ret)
-   goto clk_disable;
-
info->clock_speed = clk_get_rate(info->clk) / 100;
if (info->clock_speed < 10 || info->clock_speed > 48) {
ret = -EINVAL;
goto clk_disable;
}
 
+   ret = ov7670_init_gpio(client, info);
+   if (ret)
+   goto clk_disable;
+
+   ov7670_s_power(sd, 1);
+
/* Make sure it's an ov7670 */
ret = ov7670_detect(sd);
if (ret) {
v4l_dbg(1, debug, client,
"chip found @ 0x%x (%s) is not an ov7670 chip.\n",
client->addr << 1, client->adapter->name);
-   goto clk_disable;
+   goto power_off;
}
v4l_info(client, "chip found @ 0x%02x (%s)\n",
client->addr << 1, client->adapter->name);
@@ -1789,6 +1807,8 @@ static int ov7670_probe(struct i2c_client *client,
 #endif
 hdl_free:
v4l2_ctrl_handler_free(&info->hdl);
+power_off:
+   ov7670_s_power(sd, 0);
 clk_disable:
clk_disable_unprepare(info->clk);
return ret;
@@ -1806,6 +1826,7 @@ static int ov7670_remove(struct i2c_client *client)
 #if defined(CONFIG_MEDIA_CONTROLLER)
media_entity_cleanup(&info->sd.entity);
 #endif
+   ov7670_s_power(sd, 0);
return 0;
 }
 
-- 
2.13.0



[PATCH v6 2/3] media: ov7670: Add the get_fmt callback

2017-10-15 Thread Wenyou Yang
Add the get_fmt callback, also enable V4L2_SUBDEV_FL_HAS_DEVNODE flag
to make this subdev has device node.

Signed-off-by: Wenyou Yang 
---

Changes in v6: None
Changes in v5:
 - Fix the build warning on the declaration *mbus_fmt(ISO C90 forbids mixed).

Changes in v4:
 - Fix the build error when not enabling V4L2 sub-device userspace API option.

Changes in v3:
 - Keep tried format info in the try_fmt member of
   v4l2_subdev__pad_config struct.
 - Add the internal_ops callback to set default format.

Changes in v2: None

 drivers/media/i2c/ov7670.c | 77 +-
 1 file changed, 76 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index 553945d4ca28..73ceec63a8ca 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -232,6 +232,7 @@ struct ov7670_info {
struct v4l2_ctrl *saturation;
struct v4l2_ctrl *hue;
};
+   struct v4l2_mbus_framefmt format;
struct ov7670_format_struct *fmt;  /* Current format */
struct clk *clk;
struct gpio_desc *resetb_gpio;
@@ -975,6 +976,9 @@ static int ov7670_try_fmt_internal(struct v4l2_subdev *sd,
fmt->width = wsize->width;
fmt->height = wsize->height;
fmt->colorspace = ov7670_formats[index].colorspace;
+
+   info->format = *fmt;
+
return 0;
 }
 
@@ -988,6 +992,9 @@ static int ov7670_set_fmt(struct v4l2_subdev *sd,
struct ov7670_format_struct *ovfmt;
struct ov7670_win_size *wsize;
struct ov7670_info *info = to_state(sd);
+#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
+   struct v4l2_mbus_framefmt *mbus_fmt;
+#endif
unsigned char com7;
int ret;
 
@@ -998,8 +1005,13 @@ static int ov7670_set_fmt(struct v4l2_subdev *sd,
ret = ov7670_try_fmt_internal(sd, &format->format, NULL, NULL);
if (ret)
return ret;
-   cfg->try_fmt = format->format;
+#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
+   mbus_fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
+   *mbus_fmt = format->format;
return 0;
+#else
+   return -ENOTTY;
+#endif
}
 
ret = ov7670_try_fmt_internal(sd, &format->format, &ovfmt, &wsize);
@@ -1041,6 +1053,30 @@ static int ov7670_set_fmt(struct v4l2_subdev *sd,
return 0;
 }
 
+static int ov7670_get_fmt(struct v4l2_subdev *sd,
+ struct v4l2_subdev_pad_config *cfg,
+ struct v4l2_subdev_format *format)
+{
+   struct ov7670_info *info = to_state(sd);
+#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
+   struct v4l2_mbus_framefmt *mbus_fmt;
+#endif
+
+   if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
+#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
+   mbus_fmt = v4l2_subdev_get_try_format(sd, cfg, 0);
+   format->format = *mbus_fmt;
+   return 0;
+#else
+   return -ENOTTY;
+#endif
+   } else {
+   format->format = info->format;
+   }
+
+   return 0;
+}
+
 /*
  * Implement G/S_PARM.  There is a "high quality" mode we could try
  * to do someday; for now, we just do the frame rate tweak.
@@ -1508,6 +1544,30 @@ static int ov7670_s_register(struct v4l2_subdev *sd, 
const struct v4l2_dbg_regis
 }
 #endif
 
+static void ov7670_get_default_format(struct v4l2_subdev *sd,
+ struct v4l2_mbus_framefmt *format)
+{
+   struct ov7670_info *info = to_state(sd);
+
+   format->width = info->devtype->win_sizes[0].width;
+   format->height = info->devtype->win_sizes[0].height;
+   format->colorspace = info->fmt->colorspace;
+   format->code = info->fmt->mbus_code;
+   format->field = V4L2_FIELD_NONE;
+}
+
+#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
+static int ov7670_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
+{
+   struct v4l2_mbus_framefmt *format =
+   v4l2_subdev_get_try_format(sd, fh->pad, 0);
+
+   ov7670_get_default_format(sd, format);
+
+   return 0;
+}
+#endif
+
 /* --- */
 
 static const struct v4l2_subdev_core_ops ov7670_core_ops = {
@@ -1528,6 +1588,7 @@ static const struct v4l2_subdev_pad_ops ov7670_pad_ops = {
.enum_frame_interval = ov7670_enum_frame_interval,
.enum_frame_size = ov7670_enum_frame_size,
.enum_mbus_code = ov7670_enum_mbus_code,
+   .get_fmt = ov7670_get_fmt,
.set_fmt = ov7670_set_fmt,
 };
 
@@ -1537,6 +1598,12 @@ static const struct v4l2_subdev_ops ov7670_ops = {
.pad = &ov7670_pad_ops,
 };
 
+#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
+static const struct v4l2_subdev_internal_ops ov7670_subdev_internal_ops = {
+   .open = ov7670_open,
+};
+#endif
+
 /* --- */
 
 static const struct ov7670_devtype ov7670_devdata[] 

[PATCH v6 1/3] media: ov7670: Add entity pads initialization

2017-10-15 Thread Wenyou Yang
Add the media entity pads initialization.

Signed-off-by: Wenyou Yang 
---

Changes in v6: None
Changes in v5: None
Changes in v4:
 - Fix the build error when not enabling Media Controller API option.

Changes in v3: None
Changes in v2: None

 drivers/media/i2c/ov7670.c | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index e88549f0e704..553945d4ca28 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -213,6 +213,9 @@ struct ov7670_devtype {
 struct ov7670_format_struct;  /* coming later */
 struct ov7670_info {
struct v4l2_subdev sd;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   struct media_pad pad;
+#endif
struct v4l2_ctrl_handler hdl;
struct {
/* gain cluster */
@@ -1688,14 +1691,27 @@ static int ov7670_probe(struct i2c_client *client,
v4l2_ctrl_auto_cluster(2, &info->auto_exposure,
   V4L2_EXPOSURE_MANUAL, false);
v4l2_ctrl_cluster(2, &info->saturation);
+
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   info->pad.flags = MEDIA_PAD_FL_SOURCE;
+   info->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
+   ret = media_entity_pads_init(&info->sd.entity, 1, &info->pad);
+   if (ret < 0)
+   goto hdl_free;
+#endif
+
v4l2_ctrl_handler_setup(&info->hdl);
 
ret = v4l2_async_register_subdev(&info->sd);
if (ret < 0)
-   goto hdl_free;
+   goto entity_cleanup;
 
return 0;
 
+entity_cleanup:
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   media_entity_cleanup(&info->sd.entity);
+#endif
 hdl_free:
v4l2_ctrl_handler_free(&info->hdl);
 clk_disable:
@@ -1712,6 +1728,9 @@ static int ov7670_remove(struct i2c_client *client)
v4l2_device_unregister_subdev(sd);
v4l2_ctrl_handler_free(&info->hdl);
clk_disable_unprepare(info->clk);
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   media_entity_cleanup(&info->sd.entity);
+#endif
return 0;
 }
 
-- 
2.13.0



[PATCH v6 0/3] media: ov7670: Add entity init and power operation

2017-10-15 Thread Wenyou Yang
This patch set is to add the media entity pads initialization,
the ov7670_s_power function and get_fmt callback support.

Changes in v6:
 - Remove .s_power callback to keep the ov7670 powered at all times.
 - Update the commit log accordingly.

Changes in v5:
 - Fix the build warning on the declaration *mbus_fmt(ISO C90 forbids mixed).

Changes in v4:
 - Fix the build error when not enabling Media Controller API option.
 - Fix the build error when not enabling V4L2 sub-device userspace API option.

Changes in v3:
 - Keep tried format info in the try_fmt member of
   v4l2_subdev__pad_config struct.
 - Add the internal_ops callback to set default format.

Changes in v2:
 - Add the patch to support the get_fmt ops.
 - Remove the redundant invoking ov7670_init_gpio().

Wenyou Yang (3):
  media: ov7670: Add entity pads initialization
  media: ov7670: Add the get_fmt callback
  media: ov7670: Add the ov7670_s_power function

 drivers/media/i2c/ov7670.c | 129 ++---
 1 file changed, 122 insertions(+), 7 deletions(-)

-- 
2.13.0



Re: [PATCH 0/4] media: ov7670: add media controller support

2017-10-15 Thread Yang, Wenyou

Hi Sakari,


On 2017/10/14 4:48, Sakari Ailus wrote:

Hi Akinobu,

On Fri, Oct 13, 2017 at 01:21:13AM +0900, Akinobu Mita wrote:

This series adds media controller support and other related changes to the
OV7670 which is cheap and highly available CMOS image sensor for hobbyists.

This enables to control a video pipeline system with the OV7670.  I've
tested this with the xilinx video IP pipeline.

Akinobu Mita (4):
   media: ov7670: create subdevice device node
   media: ov7670: use v4l2_async_unregister_subdev()
   media: ov7670: add media controller support
   media: ov7670: add get_fmt() pad ops callback

  drivers/media/i2c/ov7670.c | 55 +-
  1 file changed, 54 insertions(+), 1 deletion(-)

I understand Wenyou has submitted a set with similar functionality +
runtime PM as well, but it has issues. There hasn't been updated for some
time on that. Wenyou, what's the status of your patchset?

Sorry for I missed your previous mail.

I will update the patchset soon.

The set was submitted on the list under subject "[PATCH v5 0/3] media:
ov7670: Add entity init and power operation"



Best Regards,
Wenyou Yang


Re: [PATCH v4 02/12] [media] cxd2880-spi: Add support for CXD2880 SPI interface

2017-10-15 Thread Takiguchi, Yasunari
Hi Honza,

> BTW, is there any device, preferable some devboard with this silicon
> on the market?
There is not devboard at this moment, but we are promoting this device.

Takiguchi


Re: [PATCH] media: vb2: unify calling of set_page_dirty_lock

2017-10-15 Thread Nicolas Dufresne
Le dimanche 15 octobre 2017 à 23:40 +0300, Sakari Ailus a écrit :
> Hi Nicolas,
> 
> On Tue, Oct 10, 2017 at 11:40:10AM -0400, Nicolas Dufresne wrote:
> > Le mardi 29 août 2017 à 14:26 +0300, Stanimir Varbanov a écrit :
> > > Currently videobuf2-dma-sg checks for dma direction for
> > > every single page and videobuf2-dc lacks any dma direction
> > > checks and calls set_page_dirty_lock unconditionally.
> > > 
> > > Thus unify and align the invocations of set_page_dirty_lock
> > > for videobuf2-dc, videobuf2-sg  memory allocators with
> > > videobuf2-vmalloc, i.e. the pattern used in vmalloc has been
> > > copied to dc and dma-sg.
> > 
> > Just before we go too far in "doing like vmalloc", I would like to
> > share this small video that display coherency issues when rendering
> > vmalloc backed DMABuf over various KMS/DRM driver. I can reproduce
> > this
> > easily with Intel and MSM display drivers using UVC or Vivid as
> > source.
> > 
> > The following is an HDMI capture of the following GStreamer
> > pipeline
> > running on Dragonboard 410c.
> > 
> > gst-launch-1.0 -v v4l2src device=/dev/video2 ! video/x-
> > raw,format=NV16,width=1280,height=720 ! kmssink
> > https://people.collabora.com/~nicolas/vmalloc-issue.mov
> > 
> > Feedback on this issue would be more then welcome. It's not clear
> > to me
> > who's bug is this (v4l2, drm or iommu). The software is unlikely to
> > be
> > blamed as this same pipeline works fine with non-vmalloc based
> > sources.
> 
> Could you elaborate this a little bit more? Which Intel CPU do you
> have
> there?

I have tested with Skylake and Ivy Bridge and on Dragonboard 410c
(Qualcomm APQ8016 SoC) (same visual artefact)

> 
> Where are the buffers allocated for this GStreamer pipeline, is it
> v4l2src
> or another element or somewhere else?

This is from V4L2 capture driver, exported as DMABuf, drivers are UVC
and VIVID, both are using the vmalloc allocator.

Nicolas


Re: [PATCH v2 08/14] [media] v4l: add support to BUF_QUEUED event

2017-10-15 Thread Sakari Ailus
Hi Gustavo,

On Thu, Aug 31, 2017 at 10:50:35PM -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan 
> 
> Implement the needed pieces to let userspace subscribe for
> V4L2_EVENT_BUF_QUEUED events. Videobuf2 will queue the event for the
> DQEVENT ioctl.
> 
> v3:   - Do not call v4l2 event API from vb2 (Mauro)
> 
> v2:   - Use VIDEO_MAX_FRAME to allocate room for events at
>   v4l2_event_subscribe() (Hans)
> 
> Signed-off-by: Gustavo Padovan 
> ---
>  drivers/media/v4l2-core/v4l2-ctrls.c |  6 +-
>  drivers/media/v4l2-core/videobuf2-core.c |  2 ++
>  drivers/media/v4l2-core/videobuf2-v4l2.c | 13 +
>  3 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
> b/drivers/media/v4l2-core/v4l2-ctrls.c
> index dd1db678718c..17d4b9e3eec6 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
> @@ -3438,8 +3438,12 @@ EXPORT_SYMBOL(v4l2_ctrl_log_status);
>  int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh,
>   const struct v4l2_event_subscription *sub)
>  {
> - if (sub->type == V4L2_EVENT_CTRL)
> + switch (sub->type) {
> + case V4L2_EVENT_CTRL:
>   return v4l2_event_subscribe(fh, sub, 0, &v4l2_ctrl_sub_ev_ops);
> + case V4L2_EVENT_BUF_QUEUED:
> + return v4l2_event_subscribe(fh, sub, VIDEO_MAX_FRAME, NULL);

While I think this is probably the correct place to add the event
subscription handling, the name of the function no longer corresponds what
it does, nor it belongs to v4l2-ctrls.c.

v4l2_ctrl_subscribe_event() is also used for subscribing control events on
sub-devices. BUF_QUEUED events will be available only on video nodes.

BUF_QUEUED events presumably should be availble on all video nodes that
support V4L2_CAP_STREAMING capability. Perhaps this could be handled by
moving v4l2_ctrl_subscribe_event() to v4l2-event.c and renaming it e.g.
v4l2_event_subscribe_v4l2(), for these events originate from specific
conditions the V4L2 framework is aware of.
v4l2_ctrl_subdev_subscribe_event() handling needs to be addressed as well.

A separate patch would be nice. 

> + }
>   return -EINVAL;
>  }
>  EXPORT_SYMBOL(v4l2_ctrl_subscribe_event);
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
> b/drivers/media/v4l2-core/videobuf2-core.c
> index b19c1bc4b083..bbbae0eed567 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -1231,6 +1231,8 @@ static void __enqueue_in_driver(struct vb2_buffer *vb)
>   trace_vb2_buf_queue(q, vb);
>  
>   call_void_vb_qop(vb, buf_queue, vb);
> +
> + call_void_bufop(q, buffer_queued, vb);
>  }
>  
>  static int __buf_prepare(struct vb2_buffer *vb, const void *pb)
> diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c 
> b/drivers/media/v4l2-core/videobuf2-v4l2.c
> index 8c322cd1b346..1c93bfedaffc 100644
> --- a/drivers/media/v4l2-core/videobuf2-v4l2.c
> +++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
> @@ -138,6 +138,18 @@ static void __copy_timestamp(struct vb2_buffer *vb, 
> const void *pb)
>   }
>  };
>  
> +static void __buffer_queued(struct vb2_buffer *vb)
> +{
> + struct video_device *vdev = to_video_device(vb->vb2_queue->dev);
> + struct v4l2_event event;
> +
> + memset(&event, 0, sizeof(event));
> + event.type = V4L2_EVENT_BUF_QUEUED;
> + event.u.buf_queued.index = vb->index;
> +
> + v4l2_event_queue(vdev, &event);
> +}
> +
>  static void vb2_warn_zero_bytesused(struct vb2_buffer *vb)
>  {
>   static bool check_once;
> @@ -455,6 +467,7 @@ static const struct vb2_buf_ops v4l2_buf_ops = {
>   .fill_user_buffer   = __fill_v4l2_buffer,
>   .fill_vb2_buffer= __fill_vb2_buffer,
>   .copy_timestamp = __copy_timestamp,
> + .buffer_queued  = __buffer_queued,
>  };
>  
>  /**

-- 
Kind regards,

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


[PATCH 6/8] [media] ddbridge/max: prefix lnb_init_fmode() and fe_attach_mxl5xx()

2017-10-15 Thread Daniel Scheller
From: Daniel Scheller 

Add a ddb_ prefix to the two functions to better avoid conflicts in the
global namespace, ie. when building everything into the kernel image.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 4 ++--
 drivers/media/pci/ddbridge/ddbridge-max.c  | 6 +++---
 drivers/media/pci/ddbridge/ddbridge-max.h  | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index e2e793b749f2..348cc8b3d1f9 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1442,7 +1442,7 @@ static int dvb_input_attach(struct ddb_input *input)
dvb->fe2 = NULL;
switch (port->type) {
case DDB_TUNER_MXL5XX:
-   if (fe_attach_mxl5xx(input) < 0)
+   if (ddb_fe_attach_mxl5xx(input) < 0)
return -ENODEV;
break;
case DDB_TUNER_DVBS_ST:
@@ -2955,7 +2955,7 @@ static ssize_t fmode_store(struct device *device, struct 
device_attribute *attr,
return -EINVAL;
if (val > 3)
return -EINVAL;
-   lnb_init_fmode(dev, &dev->link[num], val);
+   ddb_lnb_init_fmode(dev, &dev->link[num], val);
return count;
 }
 
diff --git a/drivers/media/pci/ddbridge/ddbridge-max.c 
b/drivers/media/pci/ddbridge/ddbridge-max.c
index 67ab4e300a36..dc6b81488746 100644
--- a/drivers/media/pci/ddbridge/ddbridge-max.c
+++ b/drivers/media/pci/ddbridge/ddbridge-max.c
@@ -360,7 +360,7 @@ static int mxl_fw_read(void *priv, u8 *buf, u32 len)
return ddbridge_flashread(dev, link->nr, buf, 0xc, len);
 }
 
-int lnb_init_fmode(struct ddb *dev, struct ddb_link *link, u32 fm)
+int ddb_lnb_init_fmode(struct ddb *dev, struct ddb_link *link, u32 fm)
 {
u32 l = link->nr;
 
@@ -404,7 +404,7 @@ static struct mxl5xx_cfg mxl5xx = {
.fw_read  = mxl_fw_read,
 };
 
-int fe_attach_mxl5xx(struct ddb_input *input)
+int ddb_fe_attach_mxl5xx(struct ddb_input *input)
 {
struct ddb *dev = input->port->dev;
struct i2c_adapter *i2c = &input->port->i2c->adap;
@@ -440,7 +440,7 @@ int fe_attach_mxl5xx(struct ddb_input *input)
lnb_command(dev, port->lnr, input->nr, LNB_CMD_INIT);
lnb_set_voltage(dev, port->lnr, input->nr, SEC_VOLTAGE_OFF);
}
-   lnb_init_fmode(dev, link, fmode);
+   ddb_lnb_init_fmode(dev, link, fmode);
 
dvb->fe->ops.set_voltage = max_set_voltage;
dvb->fe->ops.enable_high_lnb_voltage = max_enable_high_lnb_voltage;
diff --git a/drivers/media/pci/ddbridge/ddbridge-max.h 
b/drivers/media/pci/ddbridge/ddbridge-max.h
index b1bfbbea4337..bf8bf38739f6 100644
--- a/drivers/media/pci/ddbridge/ddbridge-max.h
+++ b/drivers/media/pci/ddbridge/ddbridge-max.h
@@ -23,7 +23,7 @@
 
 
/**/
 
-int lnb_init_fmode(struct ddb *dev, struct ddb_link *link, u32 fm);
-int fe_attach_mxl5xx(struct ddb_input *input);
+int ddb_lnb_init_fmode(struct ddb *dev, struct ddb_link *link, u32 fm);
+int ddb_fe_attach_mxl5xx(struct ddb_input *input);
 
 #endif /* _DDBRIDGE_MAX_H */
-- 
2.13.6



[PATCH 5/8] [media] ddbridge/max: rename ddbridge-maxs8.[c|h] to ddbridge-max.[c|h]

2017-10-15 Thread Daniel Scheller
From: Daniel Scheller 

Rename the MaxS4/8 support files following upstream. References to these
files and descriptions have been updated aswell.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/Makefile | 2 +-
 drivers/media/pci/ddbridge/ddbridge-core.c  | 2 +-
 drivers/media/pci/ddbridge/{ddbridge-maxs8.c => ddbridge-max.c} | 4 ++--
 drivers/media/pci/ddbridge/{ddbridge-maxs8.h => ddbridge-max.h} | 8 
 4 files changed, 8 insertions(+), 8 deletions(-)
 rename drivers/media/pci/ddbridge/{ddbridge-maxs8.c => ddbridge-max.c} (99%)
 rename drivers/media/pci/ddbridge/{ddbridge-maxs8.h => ddbridge-max.h} (85%)

diff --git a/drivers/media/pci/ddbridge/Makefile 
b/drivers/media/pci/ddbridge/Makefile
index 00e89b6a0328..222045703020 100644
--- a/drivers/media/pci/ddbridge/Makefile
+++ b/drivers/media/pci/ddbridge/Makefile
@@ -3,7 +3,7 @@
 #
 
 ddbridge-objs := ddbridge-main.o ddbridge-core.o ddbridge-ci.o \
-   ddbridge-hw.o ddbridge-i2c.o ddbridge-maxs8.o
+   ddbridge-hw.o ddbridge-i2c.o ddbridge-max.o
 
 obj-$(CONFIG_DVB_DDBRIDGE) += ddbridge.o
 
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 6354e00f4c9b..e2e793b749f2 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -37,7 +37,7 @@
 #include "ddbridge.h"
 #include "ddbridge-i2c.h"
 #include "ddbridge-regs.h"
-#include "ddbridge-maxs8.h"
+#include "ddbridge-max.h"
 #include "ddbridge-ci.h"
 #include "ddbridge-io.h"
 
diff --git a/drivers/media/pci/ddbridge/ddbridge-maxs8.c 
b/drivers/media/pci/ddbridge/ddbridge-max.c
similarity index 99%
rename from drivers/media/pci/ddbridge/ddbridge-maxs8.c
rename to drivers/media/pci/ddbridge/ddbridge-max.c
index 06d57a4772fa..67ab4e300a36 100644
--- a/drivers/media/pci/ddbridge/ddbridge-maxs8.c
+++ b/drivers/media/pci/ddbridge/ddbridge-max.c
@@ -1,5 +1,5 @@
 /*
- * ddbridge-maxs8.c: Digital Devices bridge MaxS4/8 support
+ * ddbridge-max.c: Digital Devices bridge MAX card support
  *
  * Copyright (C) 2010-2017 Digital Devices GmbH
  * Ralph Metzler 
@@ -34,7 +34,7 @@
 #include "ddbridge-regs.h"
 #include "ddbridge-io.h"
 
-#include "ddbridge-maxs8.h"
+#include "ddbridge-max.h"
 #include "mxl5xx.h"
 
 
/**/
diff --git a/drivers/media/pci/ddbridge/ddbridge-maxs8.h 
b/drivers/media/pci/ddbridge/ddbridge-max.h
similarity index 85%
rename from drivers/media/pci/ddbridge/ddbridge-maxs8.h
rename to drivers/media/pci/ddbridge/ddbridge-max.h
index bb8884811a46..b1bfbbea4337 100644
--- a/drivers/media/pci/ddbridge/ddbridge-maxs8.h
+++ b/drivers/media/pci/ddbridge/ddbridge-max.h
@@ -1,5 +1,5 @@
 /*
- * ddbridge-maxs8.h: Digital Devices bridge MaxS4/8 support
+ * ddbridge-max.h: Digital Devices bridge MAX card support
  *
  * Copyright (C) 2010-2017 Digital Devices GmbH
  * Ralph Metzler 
@@ -16,8 +16,8 @@
  *
  */
 
-#ifndef _DDBRIDGE_MAXS8_H_
-#define _DDBRIDGE_MAXS8_H_
+#ifndef _DDBRIDGE_MAX_H_
+#define _DDBRIDGE_MAX_H_
 
 #include "ddbridge.h"
 
@@ -26,4 +26,4 @@
 int lnb_init_fmode(struct ddb *dev, struct ddb_link *link, u32 fm);
 int fe_attach_mxl5xx(struct ddb_input *input);
 
-#endif /* _DDBRIDGE_MAXS8_H */
+#endif /* _DDBRIDGE_MAX_H */
-- 
2.13.6



[PATCH 1/8] [media] ddbridge: remove unneeded *fe vars from attach functions

2017-10-15 Thread Daniel Scheller
From: Daniel Scheller 

These are only used in C/T demod attach functions, don't add any real
benefit (ie. line length savings) and in case of cxd28xx_attach aren't
even used consequently. Remove them.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 29 +
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index f4bd4908acdd..653e7986923c 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -848,21 +848,20 @@ static int demod_attach_drxk(struct ddb_input *input)
struct i2c_adapter *i2c = &input->port->i2c->adap;
struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1];
struct device *dev = input->port->dev->dev;
-   struct dvb_frontend *fe;
struct drxk_config config;
 
memset(&config, 0, sizeof(config));
config.adr = 0x29 + (input->nr & 1);
config.microcode_name = "drxk_a3.mc";
 
-   fe = dvb->fe = dvb_attach(drxk_attach, &config, i2c);
-   if (!fe) {
+   dvb->fe = dvb_attach(drxk_attach, &config, i2c);
+   if (!dvb->fe) {
dev_err(dev, "No DRXK found!\n");
return -ENODEV;
}
-   fe->sec_priv = input;
-   dvb->i2c_gate_ctrl = fe->ops.i2c_gate_ctrl;
-   fe->ops.i2c_gate_ctrl = locked_gate_ctrl;
+   dvb->fe->sec_priv = input;
+   dvb->i2c_gate_ctrl = dvb->fe->ops.i2c_gate_ctrl;
+   dvb->fe->ops.i2c_gate_ctrl = locked_gate_ctrl;
return 0;
 }
 
@@ -912,19 +911,18 @@ static int demod_attach_stv0367(struct ddb_input *input)
struct i2c_adapter *i2c = &input->port->i2c->adap;
struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1];
struct device *dev = input->port->dev->dev;
-   struct dvb_frontend *fe;
 
/* attach frontend */
-   fe = dvb->fe = dvb_attach(stv0367ddb_attach,
+   dvb->fe = dvb_attach(stv0367ddb_attach,
&ddb_stv0367_config[(input->nr & 1)], i2c);
 
if (!dvb->fe) {
dev_err(dev, "No stv0367 found!\n");
return -ENODEV;
}
-   fe->sec_priv = input;
-   dvb->i2c_gate_ctrl = fe->ops.i2c_gate_ctrl;
-   fe->ops.i2c_gate_ctrl = locked_gate_ctrl;
+   dvb->fe->sec_priv = input;
+   dvb->i2c_gate_ctrl = dvb->fe->ops.i2c_gate_ctrl;
+   dvb->fe->ops.i2c_gate_ctrl = locked_gate_ctrl;
return 0;
 }
 
@@ -956,7 +954,6 @@ static int demod_attach_cxd28xx(struct ddb_input *input, 
int par, int osc24)
struct i2c_adapter *i2c = &input->port->i2c->adap;
struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1];
struct device *dev = input->port->dev->dev;
-   struct dvb_frontend *fe;
struct cxd2841er_config cfg;
 
/* the cxd2841er driver expects 8bit/shifted I2C addresses */
@@ -971,15 +968,15 @@ static int demod_attach_cxd28xx(struct ddb_input *input, 
int par, int osc24)
cfg.flags |= CXD2841ER_TS_SERIAL;
 
/* attach frontend */
-   fe = dvb->fe = dvb_attach(cxd2841er_attach_t_c, &cfg, i2c);
+   dvb->fe = dvb_attach(cxd2841er_attach_t_c, &cfg, i2c);
 
if (!dvb->fe) {
dev_err(dev, "No cxd2837/38/43/54 found!\n");
return -ENODEV;
}
-   fe->sec_priv = input;
-   dvb->i2c_gate_ctrl = fe->ops.i2c_gate_ctrl;
-   fe->ops.i2c_gate_ctrl = locked_gate_ctrl;
+   dvb->fe->sec_priv = input;
+   dvb->i2c_gate_ctrl = dvb->fe->ops.i2c_gate_ctrl;
+   dvb->fe->ops.i2c_gate_ctrl = locked_gate_ctrl;
return 0;
 }
 
-- 
2.13.6



[PATCH 3/8] [media] ddbridge: split off CI (common interface) from ddbridge-core

2017-10-15 Thread Daniel Scheller
From: Daniel Scheller 

Move all CI device support related code from ddbridge-core to ddbridge-ci,
following the previously split off MaxS4/8 support.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/Makefile|   4 +-
 drivers/media/pci/ddbridge/ddbridge-ci.c   | 349 +
 drivers/media/pci/ddbridge/ddbridge-ci.h   |  30 +++
 drivers/media/pci/ddbridge/ddbridge-core.c | 330 +--
 4 files changed, 383 insertions(+), 330 deletions(-)
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-ci.c
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-ci.h

diff --git a/drivers/media/pci/ddbridge/Makefile 
b/drivers/media/pci/ddbridge/Makefile
index 09703312a3f1..00e89b6a0328 100644
--- a/drivers/media/pci/ddbridge/Makefile
+++ b/drivers/media/pci/ddbridge/Makefile
@@ -2,8 +2,8 @@
 # Makefile for the ddbridge device driver
 #
 
-ddbridge-objs := ddbridge-main.o ddbridge-core.o ddbridge-hw.o \
-   ddbridge-i2c.o ddbridge-maxs8.o
+ddbridge-objs := ddbridge-main.o ddbridge-core.o ddbridge-ci.o \
+   ddbridge-hw.o ddbridge-i2c.o ddbridge-maxs8.o
 
 obj-$(CONFIG_DVB_DDBRIDGE) += ddbridge.o
 
diff --git a/drivers/media/pci/ddbridge/ddbridge-ci.c 
b/drivers/media/pci/ddbridge/ddbridge-ci.c
new file mode 100644
index ..c775b17c3228
--- /dev/null
+++ b/drivers/media/pci/ddbridge/ddbridge-ci.c
@@ -0,0 +1,349 @@
+/*
+ * ddbridge-ci.c: Digital Devices bridge CI (DuoFlex, CI Bridge) support
+ *
+ * Copyright (C) 2010-2017 Digital Devices GmbH
+ * Marcus Metzler 
+ * Ralph Metzler 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 only, 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.
+ *
+ * To obtain the license, point your browser to
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include "ddbridge.h"
+#include "ddbridge-regs.h"
+#include "ddbridge-io.h"
+#include "ddbridge-i2c.h"
+
+#include "cxd2099.h"
+
+/* Octopus CI internal CI interface */
+
+static int wait_ci_ready(struct ddb_ci *ci)
+{
+   u32 count = 10;
+
+   ndelay(500);
+   do {
+   if (ddbreadl(ci->port->dev,
+CI_CONTROL(ci->nr)) & CI_READY)
+   break;
+   usleep_range(1, 2);
+   if ((--count) == 0)
+   return -1;
+   } while (1);
+   return 0;
+}
+
+static int read_attribute_mem(struct dvb_ca_en50221 *ca,
+ int slot, int address)
+{
+   struct ddb_ci *ci = ca->data;
+   u32 val, off = (address >> 1) & (CI_BUFFER_SIZE - 1);
+
+   if (address > CI_BUFFER_SIZE)
+   return -1;
+   ddbwritel(ci->port->dev, CI_READ_CMD | (1 << 16) | address,
+ CI_DO_READ_ATTRIBUTES(ci->nr));
+   wait_ci_ready(ci);
+   val = 0xff & ddbreadl(ci->port->dev, CI_BUFFER(ci->nr) + off);
+   return val;
+}
+
+static int write_attribute_mem(struct dvb_ca_en50221 *ca, int slot,
+  int address, u8 value)
+{
+   struct ddb_ci *ci = ca->data;
+
+   ddbwritel(ci->port->dev, CI_WRITE_CMD | (value << 16) | address,
+ CI_DO_ATTRIBUTE_RW(ci->nr));
+   wait_ci_ready(ci);
+   return 0;
+}
+
+static int read_cam_control(struct dvb_ca_en50221 *ca,
+   int slot, u8 address)
+{
+   u32 count = 100;
+   struct ddb_ci *ci = ca->data;
+   u32 res;
+
+   ddbwritel(ci->port->dev, CI_READ_CMD | address,
+ CI_DO_IO_RW(ci->nr));
+   ndelay(500);
+   do {
+   res = ddbreadl(ci->port->dev, CI_READDATA(ci->nr));
+   if (res & CI_READY)
+   break;
+   usleep_range(1, 2);
+   if ((--count) == 0)
+   return -1;
+   } while (1);
+   return 0xff & res;
+}
+
+static int write_cam_control(struct dvb_ca_en50221 *ca, int slot,
+u8 address, u8 value)
+{
+   struct ddb_ci *ci = ca->data;
+
+   ddbwritel(ci->port->dev, CI_WRITE_CMD | (value << 16) | address,
+ CI_DO_IO_RW(ci->nr));
+   wait_ci_ready(ci);
+   return 0;
+}
+
+static int slot_reset(struct dvb_ca_en50221 *ca, int slot)
+{
+   struct ddb_ci *ci = ca->data;
+
+   ddbwritel(ci->port->dev, CI_POWER_ON,
+ CI_CONTROL(ci->nr));
+   msleep(100);
+   ddbwritel(ci->port->dev, CI_POWER_ON | CI_RESET_CAM,
+ CI_CONTROL(ci->nr));
+   ddbwritel(ci->port->dev, CI_ENABLE | CI_POWER_ON | CI_RESET_CAM,
+ CI_CONTROL(ci->nr));
+   usleep_

[PATCH 8/8] [media] ddbridge: update driver version number

2017-10-15 Thread Daniel Scheller
From: Daniel Scheller 

Update the driver version number/string to 0.9.32-integrated.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge.h 
b/drivers/media/pci/ddbridge/ddbridge.h
index e8432e49564c..70ac9e576c74 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -63,7 +63,7 @@
 #include "dvb_ca_en50221.h"
 #include "dvb_net.h"
 
-#define DDBRIDGE_VERSION "0.9.31intermediate-integrated"
+#define DDBRIDGE_VERSION "0.9.32-integrated"
 
 #define DDB_MAX_I2C32
 #define DDB_MAX_PORT   32
-- 
2.13.6



[PATCH 4/8] [media] ddbridge/ci: change debug printing to debug severity

2017-10-15 Thread Daniel Scheller
From: Daniel Scheller 

slot_ts_enable_xo2() logged debug output to info instead of debug, so
fix this up.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-ci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-ci.c 
b/drivers/media/pci/ddbridge/ddbridge-ci.c
index c775b17c3228..457c711aaced 100644
--- a/drivers/media/pci/ddbridge/ddbridge-ci.c
+++ b/drivers/media/pci/ddbridge/ddbridge-ci.c
@@ -260,7 +260,7 @@ static int slot_ts_enable_xo2(struct dvb_ca_en50221 *ca, 
int slot)
 {
struct ddb_ci *ci = ca->data;
 
-   dev_info(ci->port->dev->dev, "%s\n", __func__);
+   dev_dbg(ci->port->dev->dev, "%s\n", __func__);
write_creg(ci, 0x00, 0x10);
return 0;
 }
-- 
2.13.6



[PATCH 7/8] [media] stv0910: read and update mod_cod in read_status()

2017-10-15 Thread Daniel Scheller
From: Daniel Scheller 

Add missing state->modcod update from upstream driver which needs to be
done when manage_matype_info() sets is_vcm on certain S2 transponders.

Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/stv0910.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/media/dvb-frontends/stv0910.c 
b/drivers/media/dvb-frontends/stv0910.c
index 8bf855c301f5..73f6df0abbfe 100644
--- a/drivers/media/dvb-frontends/stv0910.c
+++ b/drivers/media/dvb-frontends/stv0910.c
@@ -1498,6 +1498,19 @@ static int read_status(struct dvb_frontend *fe, enum 
fe_status *status)
enable_puncture_rate(state,
 state->puncture_rate);
}
+
+   /* Use highest signaled ModCod for quality */
+   if (state->is_vcm) {
+   u8 tmp;
+   enum fe_stv0910_mod_cod mod_cod;
+
+   read_reg(state, RSTV0910_P2_DMDMODCOD + state->regoff,
+&tmp);
+   mod_cod = (enum fe_stv0910_mod_cod)((tmp & 0x7c) >> 2);
+
+   if (mod_cod > state->mod_cod)
+   state->mod_cod = mod_cod;
+   }
}
 
/* read signal statistics */
-- 
2.13.6



[PATCH 2/8] [media] ddbridge: fixup checkpatch-strict issues

2017-10-15 Thread Daniel Scheller
From: Daniel Scheller 

Fixes several alignment, braces, space-before-cast, camelcase et al issues
reported by checkpatch --strict, plus a few more checkpatch didn't report.

Three checks are left after this though:
- one CamelCase in ddbridge-core, related to defines/vars/enums referenced
  from the stv090x demod driver
- one macro argument reuse in ddbridge-core aswell
- one unbalanced braces around else in ddbridge-main, which is due to
  #ifdefs related to CONFIG_PCI_MSI, which preferrably should be kept
  as-is for readability.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-core.c  | 131 ++--
 drivers/media/pci/ddbridge/ddbridge-hw.c|   8 +-
 drivers/media/pci/ddbridge/ddbridge-i2c.c   |  16 ++--
 drivers/media/pci/ddbridge/ddbridge-main.c  |  23 ++---
 drivers/media/pci/ddbridge/ddbridge-maxs8.c |  44 ++
 drivers/media/pci/ddbridge/ddbridge-regs.h  |  32 +++
 drivers/media/pci/ddbridge/ddbridge.h   |  89 ++-
 7 files changed, 179 insertions(+), 164 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 653e7986923c..0eaa2efdcc54 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -112,7 +112,6 @@ static void ddb_set_dma_tables(struct ddb *dev)
}
 }
 
-
 //
 //
 //
@@ -210,8 +209,9 @@ static int ddb_redirect(u32 i, u32 p)
if (input->redi) {
input2->redi = input->redi;
input->redi = NULL;
-   } else
+   } else {
input2->redi = input;
+   }
}
input->redo = port->output;
port->output->redi = input;
@@ -357,9 +357,9 @@ static void calc_con(struct ddb_output *output, u32 *con, 
u32 *con2, u32 flags)
max_bitrate = 0;
gap = 0;
if (bitrate != 72000) {
-   if (bitrate >= 96000)
+   if (bitrate >= 96000) {
*con |= 0x800;
-   else {
+   } else {
*con |= 0x1000;
nco = (bitrate * 8192 + 71999)
/ 72000;
@@ -506,7 +506,6 @@ static void ddb_input_start(struct ddb_input *input)
}
 }
 
-
 static void ddb_input_start_all(struct ddb_input *input)
 {
struct ddb_input *i = input;
@@ -572,7 +571,7 @@ static ssize_t ddb_output_write(struct ddb_output *output,
while (left) {
len = output->dma->size - output->dma->coff;
if output->dma->cbuf + 1) % output->dma->num) == idx) &&
-   (off == 0)) {
+   off == 0) {
if (len <= 188)
break;
len -= 188;
@@ -593,7 +592,8 @@ static ssize_t ddb_output_write(struct ddb_output *output,
   buf, len))
return -EIO;
if (alt_dma)
-   dma_sync_single_for_device(dev->dev,
+   dma_sync_single_for_device(
+   dev->dev,
output->dma->pbuf[output->dma->cbuf],
output->dma->size, DMA_TO_DEVICE);
left -= len;
@@ -632,7 +632,7 @@ static u32 ddb_input_avail(struct ddb_input *input)
 }
 
 static ssize_t ddb_input_read(struct ddb_input *input,
-   __user u8 *buf, size_t count)
+ __user u8 *buf, size_t count)
 {
struct ddb *dev = input->port->dev;
u32 left = count;
@@ -648,7 +648,8 @@ static ssize_t ddb_input_read(struct ddb_input *input,
if (free > left)
free = left;
if (alt_dma)
-   dma_sync_single_for_cpu(dev->dev,
+   dma_sync_single_for_cpu(
+   dev->dev,
input->dma->pbuf[input->dma->cbuf],
input->dma->size, DMA_FROM_DEVICE);
ret = copy_to_user(buf, input->dma->vbuf[input->dma->cbuf] +
@@ -792,8 +793,10 @@ static int ts_open(struct inode *inode, struct file *file)
} else if ((file->f_flags & O_ACCMODE) == O_WRONLY) {
if (!output)
return -EINVAL;
-   } else
+   } else {
return -EINVA

[PATCH for 4.15] ddbridge update to 0.9.32

2017-10-15 Thread Daniel Scheller
From: Daniel Scheller 

For the 4.15 merge window. These patches update the mainline ddbridge
driver to version 0.9.32, which was released ~3 weeks ago by upstream.

Nothing really fancy in this series, in fact upstream applied many of
the changes that went into the mainline driver, which was released as
0.9.32. A few more changes were applied though, namely the CI DuoFlex/
PCIe Bridge support has been split from -core (like ie. the MaxS8 card
support), upstream named the files with the MaxS8 support code
"-max.[c|h]" (thus the rename), and everything was made checkpatch-
strict clean.

One condition in stv0910.c:read_status() was missing in mainline and is
being added in 7/8.

The series was tested for bisect safety and checked with smatch.

Please pull for 4.15.

Daniel Scheller (8):
  [media] ddbridge: remove unneeded *fe vars from attach functions
  [media] ddbridge: fixup checkpatch-strict issues
  [media] ddbridge: split off CI (common interface) from ddbridge-core
  [media] ddbridge/ci: change debug printing to debug severity
  [media] ddbridge/max: rename ddbridge-maxs8.[c|h] to
ddbridge-max.[c|h]
  [media] ddbridge/max: prefix lnb_init_fmode() and fe_attach_mxl5xx()
  [media] stv0910: read and update mod_cod in read_status()
  [media] ddbridge: update driver version number

 drivers/media/dvb-frontends/stv0910.c  |  13 +
 drivers/media/pci/ddbridge/Makefile|   4 +-
 drivers/media/pci/ddbridge/ddbridge-ci.c   | 349 +++
 drivers/media/pci/ddbridge/ddbridge-ci.h   |  30 ++
 drivers/media/pci/ddbridge/ddbridge-core.c | 494 -
 drivers/media/pci/ddbridge/ddbridge-hw.c   |   8 +-
 drivers/media/pci/ddbridge/ddbridge-i2c.c  |  16 +-
 drivers/media/pci/ddbridge/ddbridge-main.c |  23 +-
 .../ddbridge/{ddbridge-maxs8.c => ddbridge-max.c}  |  54 ++-
 .../ddbridge/{ddbridge-maxs8.h => ddbridge-max.h}  |  12 +-
 drivers/media/pci/ddbridge/ddbridge-regs.h |  32 +-
 drivers/media/pci/ddbridge/ddbridge.h  |  91 ++--
 12 files changed, 602 insertions(+), 524 deletions(-)
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-ci.c
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-ci.h
 rename drivers/media/pci/ddbridge/{ddbridge-maxs8.c => ddbridge-max.c} (92%)
 rename drivers/media/pci/ddbridge/{ddbridge-maxs8.h => ddbridge-max.h} (73%)

-- 
2.13.6



Re: [PATCH] media: vb2: unify calling of set_page_dirty_lock

2017-10-15 Thread Sakari Ailus
Hi Nicolas,

On Tue, Oct 10, 2017 at 11:40:10AM -0400, Nicolas Dufresne wrote:
> Le mardi 29 août 2017 à 14:26 +0300, Stanimir Varbanov a écrit :
> > Currently videobuf2-dma-sg checks for dma direction for
> > every single page and videobuf2-dc lacks any dma direction
> > checks and calls set_page_dirty_lock unconditionally.
> > 
> > Thus unify and align the invocations of set_page_dirty_lock
> > for videobuf2-dc, videobuf2-sg  memory allocators with
> > videobuf2-vmalloc, i.e. the pattern used in vmalloc has been
> > copied to dc and dma-sg.
> 
> Just before we go too far in "doing like vmalloc", I would like to
> share this small video that display coherency issues when rendering
> vmalloc backed DMABuf over various KMS/DRM driver. I can reproduce this
> easily with Intel and MSM display drivers using UVC or Vivid as source.
> 
> The following is an HDMI capture of the following GStreamer pipeline
> running on Dragonboard 410c.
> 
> gst-launch-1.0 -v v4l2src device=/dev/video2 ! 
> video/x-raw,format=NV16,width=1280,height=720 ! kmssink
> https://people.collabora.com/~nicolas/vmalloc-issue.mov
> 
> Feedback on this issue would be more then welcome. It's not clear to me
> who's bug is this (v4l2, drm or iommu). The software is unlikely to be
> blamed as this same pipeline works fine with non-vmalloc based sources.

Could you elaborate this a little bit more? Which Intel CPU do you have
there?

Where are the buffers allocated for this GStreamer pipeline, is it v4l2src
or another element or somewhere else?

-- 
Kind regards,

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


[PATCH RESEND] media: mxl5xx: fix tuning logic

2017-10-15 Thread Daniel Scheller
From: Mauro Carvalho Chehab 

The tuning logic is broken with regards to status report:
it relies on a previously-cached value that may not be valid
if retuned.

Change the logic to always read the status.

Signed-off-by: Mauro Carvalho Chehab 
Acked-by: Daniel Scheller 
---
Resend (ref. https://patchwork.linuxtv.org/patch/43541/) so this doesn't
get lost - this fix really should go in.

 drivers/media/dvb-frontends/mxl5xx.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/media/dvb-frontends/mxl5xx.c 
b/drivers/media/dvb-frontends/mxl5xx.c
index 676c96c216c3..4b449a6943c5 100644
--- a/drivers/media/dvb-frontends/mxl5xx.c
+++ b/drivers/media/dvb-frontends/mxl5xx.c
@@ -636,16 +636,9 @@ static int tune(struct dvb_frontend *fe, bool re_tune,
if (r)
return r;
state->tune_time = jiffies;
-   return 0;
}
-   if (*status & FE_HAS_LOCK)
-   return 0;
 
-   r = read_status(fe, status);
-   if (r)
-   return r;
-
-   return 0;
+   return read_status(fe, status);
 }
 
 static enum fe_code_rate conv_fec(enum MXL_HYDRA_FEC_E fec)
-- 
2.13.6



Re: [PATCH 0/2] Add timers to en50221 protocol driver

2017-10-15 Thread Jasmin J.
Ping!


Re: [PATCH] media: dvb_ca_en50221: sanity check slot number from userspace

2017-10-15 Thread Jasmin J.
Good catch!

> Seems that this bug has been in the driver forever.
Indeed ... and I overlooked it during my recent changes to that module.

Reviewed-by: Jasmin Jessich 

BR,
   Jasmin


Re: [PATCH] build: Fixed patches partly for Kernel 2.6.32

2017-10-15 Thread Jasmin J.
Hello Hans!

> Do you need build support for kernels < 2.6.36?
I don't, but I have the headers laying around on my disk and I simply tried to
fix the build ;)

> I gave up supporting such old kernels 2 or 3 years ago.
It seems so. I just learned, that RHEL 6.x does still use 2.6.32.
But there is RHEL 7 out since 3 years now and they use 3.10, so there is no
real need to support this Kernel version.
But I personally want to support back to 2.6.36, because this is also the last
Version which is supported by Digitial Devices with their drivers. And my
media-build DKMS should compile back to the same version.

> I'm holding off on merging this patch and the 2.6.35 patch until I
> have a better idea of why you want to support those kernels.
The patch for 2.6.35 could be applied without any problems and should also
work. It is not much effort to merge it, I guess.

> The other patches I just merged.
THX!

BR,
   Jasmin


Re: [PATCH 2/3] arm64: dts: rockchip: add the cec clk for dw-mipi-hdmi on rk3399

2017-10-15 Thread Heiko Stuebner
Am Samstag, 14. Oktober 2017, 00:53:36 CEST schrieb Pierre-Hugues Husson:
> Signed-off-by: Pierre-Hugues Husson 

applied for 4.15 after adding a basic commit message.
It is custom to always provide at least some sort of message there.


Thanks
Heiko


Re: [PATCH 3/3] arm64: dts: rockchip: enable cec pin for rk3399 firefly

2017-10-15 Thread Heiko Stuebner
Am Samstag, 14. Oktober 2017, 00:53:37 CEST schrieb Pierre-Hugues Husson:
> Signed-off-by: Pierre-Hugues Husson 

applied for 4.15 after adding a basic commit message.
It is custom to always provide at least some sort of message there.


Thanks
Heiko


Re: [PATCH] Simplify major/minor non-dynamic logic

2017-10-15 Thread Matthias Schwarzott
Am 11.10.2017 um 21:36 schrieb Mauro Carvalho Chehab:
> changeset 6bbf7a855d20 ("media: dvbdev: convert DVB device types into an 
> enum")
> added a new warning on gcc 6:
> 
>>> drivers/media/dvb-core/dvbdev.c:86:1: warning: control reaches end of 
>>> non-void function [-Wreturn-type]
> 
> That's because gcc is not smart enough to see that all types are
> present at the switch. Also, the current code is not too optimized.
> 
How should the compiler know that "int type" will only contain values
0..8? dvb_register_adapter is not inlined.

> So, replace it to a more optimized one, based on a static table.
> 
> Reported-by: kbuild test robot 
> Fixes: 6bbf7a855d20 ("media: dvbdev: convert DVB device types into an enum")
> Signed-off-by: Mauro Carvalho Chehab 
> ---
> I actually suggested this patch to be fold with changeset 6bbf7a855d20.
> Unfortunately, I actually forgot to do that (I guess I did, but on a different
> machine than the one I used today to pick it).
> 
> Anyway, that saves some code space with static minors and cleans up
> a warning. So, let's apply it.
> 
>  drivers/media/dvb-core/dvbdev.c | 28 +---
>  1 file changed, 13 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index a53eb53a4fd5..060c60ddfcc3 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -68,22 +68,20 @@ static const char * const dnames[] = {
>  #else
>  #define DVB_MAX_IDS  4
>  
> -static int nums2minor(int num, enum dvb_device_type type, int id)
> -{
> - int n = (num << 6) | (id << 4);
> +static const u8 minor_type[] = {
> +   [DVB_DEVICE_VIDEO]  = 0,
> +   [DVB_DEVICE_AUDIO]  = 1,
> +   [DVB_DEVICE_SEC]= 2,
> +   [DVB_DEVICE_FRONTEND]   = 3,
> +   [DVB_DEVICE_DEMUX]  = 4,
> +   [DVB_DEVICE_DVR]= 5,
> +   [DVB_DEVICE_CA] = 6,
> +   [DVB_DEVICE_NET]= 7,
> +   [DVB_DEVICE_OSD]= 8,
> +};
>  
> - switch (type) {
> - case DVB_DEVICE_VIDEO:  return n;
> - case DVB_DEVICE_AUDIO:  return n | 1;
> - case DVB_DEVICE_SEC:return n | 2;
> - case DVB_DEVICE_FRONTEND:   return n | 3;
> - case DVB_DEVICE_DEMUX:  return n | 4;
> - case DVB_DEVICE_DVR:return n | 5;
> - case DVB_DEVICE_CA: return n | 6;
> - case DVB_DEVICE_NET:return n | 7;
> - case DVB_DEVICE_OSD:return n | 8;
> - }
> -}
> +#define nums2minor(num, type, id) \
> +   (((num) << 6) | ((id) << 4) | minor_type[type])

In this code it is problematic that a bad value of type will trigger an
invalid memory access.

>  
>  #define MAX_DVB_MINORS   (DVB_MAX_ADAPTERS*64)
>  #endif
> 

Regards
Matthias


Re: [PATCH 0/3] Enable CEC on rk3399

2017-10-15 Thread Heiko Stuebner
Hi Hans,

Am Sonntag, 15. Oktober 2017, 12:31:29 CEST schrieb Hans Verkuil:
> On 10/14/2017 04:52 PM, Heiko Stuebner wrote:
> > Am Samstag, 14. Oktober 2017, 15:14:40 CEST schrieb Pierre-Hugues Husson:
> >>> Nice! I had a similar dw-hdmi.c patch pending but got around to posting 
> >>> it.
> >>>
> >>> I'll brush off my old rk3288 patches and see if I can get CEC enabled
> >>> for my firefly-reload. I was close to getting it work, but I guess
> >>> missed the "enable cec pin" change.
> >> Please note that on rk3288, there are two CEC pins, and you must write
> >> in RK3288_GRF_SOC_CON8 which pin you're using.
> >> On the firefly-reload, the pin used is GPIO7C0, while the default pin
> >> configuration is GPIO7C7.
> > 
> > And as an additional note, later socs have even more of these pin-routing
> > settings and we currently have infrastructure in the pinctrl driver to do
> > this automatically depending on the pinctrl settings.
> > 
> > So most likely this can also be added there for the rk3288.
> > 
> > 
> > Heiko
> > 
> 
> How does 'GPIO7C0' translate to a 'rockchip,pins' line?
> 
> I have this in rk3288-firefly-reload.dts:
> 
>hdmi {
> hdmi_cec: hdmi-cec {
> rockchip,pins = <7 16 RK_FUNC_2 &pcfg_pull_none>;
> };
> };
> 
> I think this is correct. You can find my patches for the firefly reload here:

Yep, looks correct (i.e. we have 8 pins per A,B,C,D bank, so C0 is pin 16)
but as a helping measure we now also have constants, RK_PC7 in your case.

> https://git.linuxtv.org/hverkuil/media_tree.git/log/?h=firefly2
> 
> I don't have access to my firefly reload until Friday, so I can't test this
> until then.
> 
> I'd be very grateful though if you can check the last three patches in that
> branch. It's just a test branch, so the subject/changelog of those patches
> are incomplete.

While basically ok, I'd suggest having the cec pin definitions in rk3288.dtsi,
like adding entries "hdmi-cec-c0" and "hdmi-cec-c7" or similar and selecting
the correct one per board, so that we don't need to duplicate them into each
and every board dts.

The cec pin function is after all a function of the soc itself.


> The very last patch adds CEC support for the firefly/firefly beta. I don't
> have that hardware, so I won't be able to test that.

at least in the schematics for the old firefly-rk3288 it specifies gpio7c0
as cec pin, similar to the reload but in your patch you selected gpio7c7?

Especially as gpio7c7 is part of the debug uart, this would be quite strange.


Heiko


Re: [PATCH] build: Fixed patches partly for Kernel 2.6.32

2017-10-15 Thread Hans Verkuil
Hi Jasmin,

On 10/14/2017 02:00 AM, Jasmin J. wrote:
> Hi!
> 
> I have fixed the patches for 2.6.32 partly.
> File rc-ir-raw.c is still missing, but I can't fix that.
> Moreover, when compiling for 2.6.32, I get errors from compat.h:
>implicit declaration of function 'ktime_to_ms'
> So it seems this needs a fix in compat.h also.
> 
> I am sending this patch anyway, so that someone may continue.
> On the other hand the daily build is done back to Kernel 2.6.36, so it
> seems media_build is tested only down to this Kernel Version.

Do you need build support for kernels < 2.6.36?

I gave up supporting such old kernels 2 or 3 years ago.

I'm holding off on merging this patch and the 2.6.35 patch until I
have a better idea of why you want to support those kernels.

The other patches I just merged.

Regards,

Hans


Re: [PATCH 0/3] Enable CEC on rk3399

2017-10-15 Thread Hans Verkuil
On 10/14/2017 04:52 PM, Heiko Stuebner wrote:
> Am Samstag, 14. Oktober 2017, 15:14:40 CEST schrieb Pierre-Hugues Husson:
>> Hi Hans,
>>
>>> Nice! I had a similar dw-hdmi.c patch pending but got around to posting it.
>>>
>>> I'll brush off my old rk3288 patches and see if I can get CEC enabled
>>> for my firefly-reload. I was close to getting it work, but I guess
>>> missed the "enable cec pin" change.
>> Please note that on rk3288, there are two CEC pins, and you must write
>> in RK3288_GRF_SOC_CON8 which pin you're using.
>> On the firefly-reload, the pin used is GPIO7C0, while the default pin
>> configuration is GPIO7C7.
> 
> And as an additional note, later socs have even more of these pin-routing
> settings and we currently have infrastructure in the pinctrl driver to do
> this automatically depending on the pinctrl settings.
> 
> So most likely this can also be added there for the rk3288.
> 
> 
> Heiko
> 

How does 'GPIO7C0' translate to a 'rockchip,pins' line?

I have this in rk3288-firefly-reload.dts:

   hdmi {
hdmi_cec: hdmi-cec {
rockchip,pins = <7 16 RK_FUNC_2 &pcfg_pull_none>;
};
};

I think this is correct. You can find my patches for the firefly reload here:

https://git.linuxtv.org/hverkuil/media_tree.git/log/?h=firefly2

I don't have access to my firefly reload until Friday, so I can't test this
until then.

I'd be very grateful though if you can check the last three patches in that
branch. It's just a test branch, so the subject/changelog of those patches
are incomplete.

The very last patch adds CEC support for the firefly/firefly beta. I don't
have that hardware, so I won't be able to test that.

Regards,

Hans