cron job: media_tree daily build: ERRORS

2018-06-27 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:   Thu Jun 28 05:00:19 CEST 2018
media-tree git hash:f6f630327de95c251741c1f682a94243c48f2b13
media_build git hash:   26d102795c91f8593a4f74f96b955f9a8b81dbc3
v4l-utils git hash: 5c197a3bbe7358670765d09f67ae2f05e89a61d1
gcc version:i686-linux-gcc (GCC) 8.1.0
sparse version: 0.5.2
smatch version: 0.5.1
host hardware:  x86_64
host os:4.16.0-1-amd64

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-arm64: OK
linux-git-i686: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
Check COMPILE_TEST: OK
linux-2.6.36.4-i686: ERRORS
linux-2.6.36.4-x86_64: ERRORS
linux-2.6.37.6-i686: ERRORS
linux-2.6.37.6-x86_64: ERRORS
linux-2.6.38.8-i686: ERRORS
linux-2.6.38.8-x86_64: ERRORS
linux-2.6.39.4-i686: ERRORS
linux-2.6.39.4-x86_64: ERRORS
linux-3.0.101-i686: ERRORS
linux-3.0.101-x86_64: ERRORS
linux-3.1.10-i686: ERRORS
linux-3.1.10-x86_64: ERRORS
linux-3.2.101-i686: ERRORS
linux-3.2.101-x86_64: ERRORS
linux-3.3.8-i686: ERRORS
linux-3.3.8-x86_64: ERRORS
linux-3.4.113-i686: ERRORS
linux-3.4.113-x86_64: ERRORS
linux-3.5.7-i686: ERRORS
linux-3.5.7-x86_64: ERRORS
linux-3.6.11-i686: ERRORS
linux-3.6.11-x86_64: ERRORS
linux-3.7.10-i686: ERRORS
linux-3.7.10-x86_64: ERRORS
linux-3.8.13-i686: ERRORS
linux-3.8.13-x86_64: ERRORS
linux-3.9.11-i686: ERRORS
linux-3.9.11-x86_64: ERRORS
linux-3.10.108-i686: ERRORS
linux-3.10.108-x86_64: ERRORS
linux-3.11.10-i686: ERRORS
linux-3.11.10-x86_64: ERRORS
linux-3.12.74-i686: ERRORS
linux-3.12.74-x86_64: ERRORS
linux-3.13.11-i686: ERRORS
linux-3.13.11-x86_64: ERRORS
linux-3.14.79-i686: ERRORS
linux-3.14.79-x86_64: ERRORS
linux-3.15.10-i686: ERRORS
linux-3.15.10-x86_64: ERRORS
linux-3.16.56-i686: ERRORS
linux-3.16.56-x86_64: ERRORS
linux-3.17.8-i686: ERRORS
linux-3.17.8-x86_64: ERRORS
linux-3.18.102-i686: ERRORS
linux-3.18.102-x86_64: ERRORS
linux-3.19.8-i686: ERRORS
linux-3.19.8-x86_64: ERRORS
linux-4.0.9-i686: ERRORS
linux-4.0.9-x86_64: ERRORS
linux-4.1.51-i686: ERRORS
linux-4.1.51-x86_64: ERRORS
linux-4.2.8-i686: ERRORS
linux-4.2.8-x86_64: ERRORS
linux-4.3.6-i686: ERRORS
linux-4.3.6-x86_64: ERRORS
linux-4.4.109-i686: ERRORS
linux-4.4.109-x86_64: ERRORS
linux-4.5.7-i686: ERRORS
linux-4.5.7-x86_64: ERRORS
linux-4.6.7-i686: ERRORS
linux-4.6.7-x86_64: ERRORS
linux-4.7.10-i686: ERRORS
linux-4.7.10-x86_64: ERRORS
linux-4.8.17-i686: ERRORS
linux-4.8.17-x86_64: ERRORS
linux-4.9.91-i686: ERRORS
linux-4.9.91-x86_64: ERRORS
linux-4.10.17-i686: ERRORS
linux-4.10.17-x86_64: ERRORS
linux-4.11.12-i686: ERRORS
linux-4.11.12-x86_64: ERRORS
linux-4.12.14-i686: ERRORS
linux-4.12.14-x86_64: ERRORS
linux-4.13.16-i686: ERRORS
linux-4.13.16-x86_64: ERRORS
linux-4.14.42-i686: ERRORS
linux-4.14.42-x86_64: ERRORS
linux-4.15.14-i686: ERRORS
linux-4.15.14-x86_64: ERRORS
linux-4.16.8-i686: ERRORS
linux-4.16.8-x86_64: ERRORS
linux-4.17.2-i686: ERRORS
linux-4.17.2-x86_64: ERRORS
linux-4.18-rc1-i686: OK
linux-4.18-rc1-x86_64: OK
apps: OK
spec-git: OK

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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


[PATCH v3 1/2] media: add helpers for memory-to-memory media controller

2018-06-27 Thread Ezequiel Garcia
A memory-to-memory pipeline device consists in three
entities: two DMA engine and one video processing entities.
The DMA engine entities are linked to a V4L interface.

This commit add a new v4l2_m2m_{un}register_media_controller
API to register this topology.

For instance, a typical mem2mem device topology would
look like this:

Device topology
- entity 1: source (1 pad, 1 link)
type Node subtype V4L flags 0
pad0: Source
-> "proc":1 [ENABLED,IMMUTABLE]

- entity 3: proc (2 pads, 2 links)
type Node subtype Unknown flags 0
pad0: Source
-> "sink":0 [ENABLED,IMMUTABLE]
pad1: Sink
<- "source":0 [ENABLED,IMMUTABLE]

- entity 6: sink (1 pad, 1 link)
type Node subtype V4L flags 0
pad0: Sink
<- "proc":0 [ENABLED,IMMUTABLE]

Suggested-by: Laurent Pinchart 
Suggested-by: Hans Verkuil 
Signed-off-by: Ezequiel Garcia 
---
 drivers/media/v4l2-core/v4l2-dev.c |  13 +-
 drivers/media/v4l2-core/v4l2-mem2mem.c | 172 +
 include/media/v4l2-mem2mem.h   |  19 +++
 3 files changed, 199 insertions(+), 5 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c 
b/drivers/media/v4l2-core/v4l2-dev.c
index 4ffd7d60a901..c1996d73ca74 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -202,7 +202,7 @@ static void v4l2_device_release(struct device *cd)
mutex_unlock(_lock);
 
 #if defined(CONFIG_MEDIA_CONTROLLER)
-   if (v4l2_dev->mdev) {
+   if (v4l2_dev->mdev && vdev->vfl_dir != VFL_DIR_M2M) {
/* Remove interfaces and interface links */
media_devnode_remove(vdev->intf_devnode);
if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN)
@@ -733,19 +733,22 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
BASE_VIDIOC_PRIVATE);
 }
 
-static int video_register_media_controller(struct video_device *vdev, int type)
+static int video_register_media_controller(struct video_device *vdev)
 {
 #if defined(CONFIG_MEDIA_CONTROLLER)
u32 intf_type;
int ret;
 
-   if (!vdev->v4l2_dev->mdev)
+   /* Memory-to-memory devices are more complex and use
+* their own function to register its mc entities.
+*/
+   if (!vdev->v4l2_dev->mdev || vdev->vfl_dir == VFL_DIR_M2M)
return 0;
 
vdev->entity.obj_type = MEDIA_ENTITY_TYPE_VIDEO_DEVICE;
vdev->entity.function = MEDIA_ENT_F_UNKNOWN;
 
-   switch (type) {
+   switch (vdev->vfl_type) {
case VFL_TYPE_GRABBER:
intf_type = MEDIA_INTF_T_V4L_VIDEO;
vdev->entity.function = MEDIA_ENT_F_IO_V4L;
@@ -993,7 +996,7 @@ int __video_register_device(struct video_device *vdev,
v4l2_device_get(vdev->v4l2_dev);
 
/* Part 5: Register the entity. */
-   ret = video_register_media_controller(vdev, type);
+   ret = video_register_media_controller(vdev);
 
/* Part 6: Activate this minor. The char device can now be used. */
set_bit(V4L2_FL_REGISTERED, >flags);
diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c 
b/drivers/media/v4l2-core/v4l2-mem2mem.c
index c4f963d96a79..8107ebabaebe 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -17,9 +17,11 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -50,6 +52,18 @@ module_param(debug, bool, 0644);
  * offsets but for different queues */
 #define DST_QUEUE_OFF_BASE (1 << 30)
 
+enum v4l2_m2m_entity_type {
+   MEM2MEM_ENT_TYPE_SOURCE,
+   MEM2MEM_ENT_TYPE_SINK,
+   MEM2MEM_ENT_TYPE_PROC,
+   MEM2MEM_ENT_TYPE_MAX
+};
+
+static const char * const m2m_entity_name[] = {
+   "source",
+   "sink",
+   "proc"
+};
 
 /**
  * struct v4l2_m2m_dev - per-device context
@@ -60,6 +74,15 @@ module_param(debug, bool, 0644);
  */
 struct v4l2_m2m_dev {
struct v4l2_m2m_ctx *curr_ctx;
+#ifdef CONFIG_MEDIA_CONTROLLER
+   struct media_entity *source;
+   struct media_padsource_pad;
+   struct media_entity sink;
+   struct media_padsink_pad;
+   struct media_entity proc;
+   struct media_padproc_pads[2];
+   struct media_intf_devnode *intf_devnode;
+#endif
 
struct list_headjob_queue;
spinlock_t  job_spinlock;
@@ -595,6 +618,155 @@ int v4l2_m2m_mmap(struct file *file, struct v4l2_m2m_ctx 
*m2m_ctx,
 }
 EXPORT_SYMBOL(v4l2_m2m_mmap);
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
+void v4l2_m2m_unregister_media_controller(struct v4l2_m2m_dev *m2m_dev)
+{
+   media_remove_intf_links(_dev->intf_devnode->intf);
+   media_devnode_remove(m2m_dev->intf_devnode);
+
+   media_entity_remove_links(m2m_dev->source);
+   media_entity_remove_links(_dev->sink);
+   media_entity_remove_links(_dev->proc);

[PATCH v3 2/2] vim2m: add media device

2018-06-27 Thread Ezequiel Garcia
From: Hans Verkuil 

Request API requires a media node. Add one to the vim2m driver so we can
use requests with it.

Signed-off-by: Hans Verkuil 
Signed-off-by: Ezequiel Garcia 
---
 drivers/media/platform/vim2m.c | 41 ++
 1 file changed, 37 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c
index 065483e62db4..da13a8927f3f 100644
--- a/drivers/media/platform/vim2m.c
+++ b/drivers/media/platform/vim2m.c
@@ -140,6 +140,9 @@ static struct vim2m_fmt *find_format(struct v4l2_format *f)
 struct vim2m_dev {
struct v4l2_device  v4l2_dev;
struct video_device vfd;
+#ifdef CONFIG_MEDIA_CONTROLLER
+   struct media_device mdev;
+#endif
 
atomic_tnum_inst;
struct mutexdev_mutex;
@@ -1016,7 +1019,7 @@ static int vim2m_probe(struct platform_device *pdev)
ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
if (ret) {
v4l2_err(>v4l2_dev, "Failed to register video device\n");
-   goto unreg_dev;
+   goto unreg_v4l2;
}
 
video_set_drvdata(vfd, dev);
@@ -1031,15 +1034,39 @@ static int vim2m_probe(struct platform_device *pdev)
if (IS_ERR(dev->m2m_dev)) {
v4l2_err(>v4l2_dev, "Failed to init mem2mem device\n");
ret = PTR_ERR(dev->m2m_dev);
-   goto err_m2m;
+   goto unreg_dev;
+   }
+
+#ifdef CONFIG_MEDIA_CONTROLLER
+   dev->mdev.dev = >dev;
+   strlcpy(dev->mdev.model, "vim2m", sizeof(dev->mdev.model));
+   media_device_init(>mdev);
+   dev->v4l2_dev.mdev = >mdev;
+
+   ret = v4l2_m2m_register_media_controller(dev->m2m_dev,
+   vfd, MEDIA_ENT_F_PROC_VIDEO_SCALER);
+   if (ret) {
+   v4l2_err(>v4l2_dev, "Failed to init mem2mem media 
controller\n");
+   goto unreg_m2m;
}
 
+   ret = media_device_register(>mdev);
+   if (ret) {
+   v4l2_err(>v4l2_dev, "Failed to register mem2mem media 
device\n");
+   goto unreg_m2m_mc;
+   }
+#endif
return 0;
 
-err_m2m:
+#ifdef CONFIG_MEDIA_CONTROLLER
+unreg_m2m_mc:
+   v4l2_m2m_unregister_media_controller(dev->m2m_dev);
+unreg_m2m:
v4l2_m2m_release(dev->m2m_dev);
-   video_unregister_device(>vfd);
+#endif
 unreg_dev:
+   video_unregister_device(>vfd);
+unreg_v4l2:
v4l2_device_unregister(>v4l2_dev);
 
return ret;
@@ -1050,6 +1077,12 @@ static int vim2m_remove(struct platform_device *pdev)
struct vim2m_dev *dev = platform_get_drvdata(pdev);
 
v4l2_info(>v4l2_dev, "Removing " MEM2MEM_NAME);
+
+#ifdef CONFIG_MEDIA_CONTROLLER
+   media_device_unregister(>mdev);
+   v4l2_m2m_unregister_media_controller(dev->m2m_dev);
+   media_device_cleanup(>mdev);
+#endif
v4l2_m2m_release(dev->m2m_dev);
del_timer_sync(>timer);
video_unregister_device(>vfd);
-- 
2.18.0.rc2



[PATCH v3 0/2] Memory-to-memory media controller topology

2018-06-27 Thread Ezequiel Garcia
As discussed on IRC, memory-to-memory need to be modeled
properly in order to be supported by the media controller
framework, and thus to support the Request API.

First commit introduces a register/unregister API,
that creates/destroys all the entities and pads needed,
and links them.

The second commit uses this API to support the vim2m driver.

The series applies cleanly on v4.18-rc1.

Topology (media-ctl -p output)
==

media-ctl -p
Media controller API version 4.17.0

Media device information

driver  vim2m
model   vim2m
serial  
bus info
hw revision 0x0
driver version  4.17.0

Device topology
- entity 1: source (1 pad, 1 link)
type Node subtype V4L flags 0
pad0: Source
-> "proc":1 [ENABLED,IMMUTABLE]

- entity 3: proc (2 pads, 2 links)
type Node subtype Unknown flags 0
pad0: Sink
-> "sink":0 [ENABLED,IMMUTABLE]
pad1: Source
<- "source":0 [ENABLED,IMMUTABLE]

- entity 6: sink (1 pad, 1 link)
type Node subtype V4L flags 0
pad0: Sink
<- "proc":0 [ENABLED,IMMUTABLE]

Compliance output
=

v4l2-compliance -m /dev/media0 -v 
v4l2-compliance SHA: e2038ec6451293787b929338c2a671c732b8693d, 64 bits

Compliance test for device /dev/media0:

Media Driver Info:
Driver name  : vim2m
Model: vim2m
Serial   : 
Bus info : 
Media version: 4.17.0
Hardware revision: 0x (0)
Driver version   : 4.17.0

Required ioctls:
test MEDIA_IOC_DEVICE_INFO: OK

Allow for multiple opens:
test second /dev/media0 open: OK
test MEDIA_IOC_DEVICE_INFO: OK
test for unlimited opens: OK

Media Controller ioctls:
Entity: 0x0001 (Name: 'source', Function: 0x00010001)
Entity: 0x0003 (Name: 'proc', Function: 0x4005)
Entity: 0x0006 (Name: 'sink', Function: 0x00010001)
Interface: 0x030c (Type: 0x0200)
Pad: 0x0102
Pad: 0x0104
Pad: 0x0105
Pad: 0x0107
Link: 0x0208
Link: 0x020a
Link: 0x020d
Link: 0x020e
test MEDIA_IOC_G_TOPOLOGY: OK
Entities: 3 Interfaces: 1 Pads: 4 Links: 4
Entity: 0x0001 (Name: 'source', Type: 0x00010001)
Entity: 0x0003 (Name: 'proc', Type: 0x0001)
Entity: 0x0006 (Name: 'sink', Type: 0x00010001)
Entity Links: 0x0001 (Name: 'source')
Entity Links: 0x0003 (Name: 'proc')
Entity Links: 0x0006 (Name: 'sink')
test MEDIA_IOC_ENUM_ENTITIES/LINKS: OK
test MEDIA_IOC_SETUP_LINK: OK


Compliance test for device /dev/video2:

Driver Info:
Driver name  : vim2m
Card type: vim2m
Bus info : platform:vim2m
Driver version   : 4.17.0
Capabilities : 0x84208000
Video Memory-to-Memory
Streaming
Extended Pix Format
Device Capabilities
Device Caps  : 0x04208000
Video Memory-to-Memory
Streaming
Extended Pix Format
Media Driver Info:
Driver name  : vim2m
Model: vim2m
Serial   : 
Bus info : 
Media version: 4.17.0
Hardware revision: 0x (0)
Driver version   : 4.17.0
Interface Info:
ID   : 0x030c
Type : V4L Video
Major: 81
Minor: 7
Entity Info:
ID   : 0x0001 (1)
Name : source
Function : V4L2 I/O
Pad 0x0102   : Source
  Link 0x0208: to remote pad 0x105 of entity 'proc': Data, 
Enabled, Immutable

Required ioctls:
test MC information (see 'Media Driver Info' above): OK
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second /dev/video2 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

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

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

Output ioctls:

Re: [PATCH] em28xx: Fix dual transport stream operation

2018-06-27 Thread Brad Love
Apologies, forgot to note this patch requires:

https://patchwork.kernel.org/patch/10492053/



On 2018-06-27 14:41, Brad Love wrote:
> Addresses the following, which introduced a regression itself:
>
> Commit 509f89652f83 ("media: em28xx: fix a regression with HVR-950")
>
> The regression fix breaks dual transport stream support. When a
> tuner starts streaming it sets alt mode on the USB interface.
> The problem is both tuners share the same USB interface, so when
> the second tuner becomes active and sets alt mode on the interface
> it kills streaming on the other port.
>
> It was suggested to add a refcounter and only set alt mode if no
> tuners are currently active on the interface. This requires
> sharing some state amongst both tuner devices, with appropriate
> locking.
>
> What I've done here is the following:
> - Add a usage_count pointer to struct em28xx
> - Share usage_count between both em28xx devices
> - Only set alt mode if usage_count is zero
> - Increment usage_count when each tuner becomes active
> - Decrement usage_count when a tuner becomes idle
>
> With usage_count in the main em28xx struct, locking is handled as
> follows:
> - if a secondary tuner exists, lock dev->dev_next->lock
> - if no secondary tuner exists, lock dev->lock
>
> By using the above scheme a single tuner device, will lock itself,
> the first tuner in a dual tuner device will lock the second tuner,
> and the second tuner in a dual tuner device will lock itself aka
> the second tuner instance.
>
> Signed-off-by: Brad Love 
> ---
>  drivers/media/usb/em28xx/em28xx-cards.c |  6 -
>  drivers/media/usb/em28xx/em28xx-dvb.c   | 47 
> +++--
>  drivers/media/usb/em28xx/em28xx.h   |  1 +
>  3 files changed, 51 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/usb/em28xx/em28xx-cards.c 
> b/drivers/media/usb/em28xx/em28xx-cards.c
> index 48bc505..91f9787 100644
> --- a/drivers/media/usb/em28xx/em28xx-cards.c
> +++ b/drivers/media/usb/em28xx/em28xx-cards.c
> @@ -3374,8 +3374,10 @@ void em28xx_free_device(struct kref *ref)
>   if (!dev->disconnected)
>   em28xx_release_resources(dev);
>  
> - if (dev->ts == PRIMARY_TS)
> + if (dev->ts == PRIMARY_TS) {
>   kfree(dev->alt_max_pkt_size_isoc);
> + kfree(dev->usage_count);
> + }
>  
>   kfree(dev);
>  }
> @@ -3793,6 +3795,8 @@ static int em28xx_usb_probe(struct usb_interface *intf,
>   dev->is_audio_only = has_vendor_audio && !(has_video || has_dvb);
>   dev->has_video = has_video;
>   dev->ifnum = ifnum;
> + dev->usage_count = kcalloc(1, sizeof(unsigned int), GFP_KERNEL);
> + *dev->usage_count = 0;
>  
>   dev->ts = PRIMARY_TS;
>   snprintf(dev->name, 28, "em28xx");
> diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c 
> b/drivers/media/usb/em28xx/em28xx-dvb.c
> index b778d8a..3a67831 100644
> --- a/drivers/media/usb/em28xx/em28xx-dvb.c
> +++ b/drivers/media/usb/em28xx/em28xx-dvb.c
> @@ -218,7 +218,19 @@ static int em28xx_start_streaming(struct em28xx_dvb *dvb)
>   dvb_alt = dev->dvb_alt_isoc;
>   }
>  
> - usb_set_interface(udev, dev->ifnum, dvb_alt);
> + if (dev->dev_next)
> + mutex_lock(>dev_next->lock);
> + else
> + mutex_lock(>lock);
> +
> + if (*dev->usage_count == 0)
> + usb_set_interface(udev, dev->ifnum, dvb_alt);
> +
> + if (dev->dev_next)
> + mutex_unlock(>dev_next->lock);
> + else
> + mutex_unlock(>lock);
> +
>   rc = em28xx_set_mode(dev, EM28XX_DIGITAL_MODE);
>   if (rc < 0)
>   return rc;
> @@ -250,6 +262,8 @@ static int em28xx_start_feed(struct dvb_demux_feed *feed)
>  {
>   struct dvb_demux *demux  = feed->demux;
>   struct em28xx_dvb *dvb = demux->priv;
> + struct em28xx_i2c_bus *i2c_bus = dvb->adapter.priv;
> + struct em28xx *dev = i2c_bus->dev;
>   int rc, ret;
>  
>   if (!demux->dmx.frontend)
> @@ -263,6 +277,19 @@ static int em28xx_start_feed(struct dvb_demux_feed *feed)
>   ret = em28xx_start_streaming(dvb);
>   if (ret < 0)
>   rc = ret;
> + else {
> + if (dev->dev_next)
> + mutex_lock(>dev_next->lock);
> + else
> + mutex_lock(>lock);
> +
> + *dev->usage_count = *dev->usage_count + 1;
> +
> + if (dev->dev_next)
> + mutex_unlock(>dev_next->lock);
> + else
> + mutex_unlock(>lock);
> + }
>   }
>  
>   mutex_unlock(>lock);
> @@ -273,14 +300,30 @@ static int em28xx_stop_feed(struct dvb_demux_feed *feed)
>  {
>   struct dvb_demux *demux  = feed->demux;
>   struct em28xx_dvb *dvb = demux->priv;
> + struct em28xx_i2c_bus *i2c_bus = dvb->adapter.priv;
> + struct em28xx *dev = i2c_bus->dev;
>   int 

[PATCH] em28xx: Fix dual transport stream operation

2018-06-27 Thread Brad Love
Addresses the following, which introduced a regression itself:

Commit 509f89652f83 ("media: em28xx: fix a regression with HVR-950")

The regression fix breaks dual transport stream support. When a
tuner starts streaming it sets alt mode on the USB interface.
The problem is both tuners share the same USB interface, so when
the second tuner becomes active and sets alt mode on the interface
it kills streaming on the other port.

It was suggested to add a refcounter and only set alt mode if no
tuners are currently active on the interface. This requires
sharing some state amongst both tuner devices, with appropriate
locking.

What I've done here is the following:
- Add a usage_count pointer to struct em28xx
- Share usage_count between both em28xx devices
- Only set alt mode if usage_count is zero
- Increment usage_count when each tuner becomes active
- Decrement usage_count when a tuner becomes idle

With usage_count in the main em28xx struct, locking is handled as
follows:
- if a secondary tuner exists, lock dev->dev_next->lock
- if no secondary tuner exists, lock dev->lock

By using the above scheme a single tuner device, will lock itself,
the first tuner in a dual tuner device will lock the second tuner,
and the second tuner in a dual tuner device will lock itself aka
the second tuner instance.

Signed-off-by: Brad Love 
---
 drivers/media/usb/em28xx/em28xx-cards.c |  6 -
 drivers/media/usb/em28xx/em28xx-dvb.c   | 47 +++--
 drivers/media/usb/em28xx/em28xx.h   |  1 +
 3 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/drivers/media/usb/em28xx/em28xx-cards.c 
b/drivers/media/usb/em28xx/em28xx-cards.c
index 48bc505..91f9787 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -3374,8 +3374,10 @@ void em28xx_free_device(struct kref *ref)
if (!dev->disconnected)
em28xx_release_resources(dev);
 
-   if (dev->ts == PRIMARY_TS)
+   if (dev->ts == PRIMARY_TS) {
kfree(dev->alt_max_pkt_size_isoc);
+   kfree(dev->usage_count);
+   }
 
kfree(dev);
 }
@@ -3793,6 +3795,8 @@ static int em28xx_usb_probe(struct usb_interface *intf,
dev->is_audio_only = has_vendor_audio && !(has_video || has_dvb);
dev->has_video = has_video;
dev->ifnum = ifnum;
+   dev->usage_count = kcalloc(1, sizeof(unsigned int), GFP_KERNEL);
+   *dev->usage_count = 0;
 
dev->ts = PRIMARY_TS;
snprintf(dev->name, 28, "em28xx");
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c 
b/drivers/media/usb/em28xx/em28xx-dvb.c
index b778d8a..3a67831 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -218,7 +218,19 @@ static int em28xx_start_streaming(struct em28xx_dvb *dvb)
dvb_alt = dev->dvb_alt_isoc;
}
 
-   usb_set_interface(udev, dev->ifnum, dvb_alt);
+   if (dev->dev_next)
+   mutex_lock(>dev_next->lock);
+   else
+   mutex_lock(>lock);
+
+   if (*dev->usage_count == 0)
+   usb_set_interface(udev, dev->ifnum, dvb_alt);
+
+   if (dev->dev_next)
+   mutex_unlock(>dev_next->lock);
+   else
+   mutex_unlock(>lock);
+
rc = em28xx_set_mode(dev, EM28XX_DIGITAL_MODE);
if (rc < 0)
return rc;
@@ -250,6 +262,8 @@ static int em28xx_start_feed(struct dvb_demux_feed *feed)
 {
struct dvb_demux *demux  = feed->demux;
struct em28xx_dvb *dvb = demux->priv;
+   struct em28xx_i2c_bus *i2c_bus = dvb->adapter.priv;
+   struct em28xx *dev = i2c_bus->dev;
int rc, ret;
 
if (!demux->dmx.frontend)
@@ -263,6 +277,19 @@ static int em28xx_start_feed(struct dvb_demux_feed *feed)
ret = em28xx_start_streaming(dvb);
if (ret < 0)
rc = ret;
+   else {
+   if (dev->dev_next)
+   mutex_lock(>dev_next->lock);
+   else
+   mutex_lock(>lock);
+
+   *dev->usage_count = *dev->usage_count + 1;
+
+   if (dev->dev_next)
+   mutex_unlock(>dev_next->lock);
+   else
+   mutex_unlock(>lock);
+   }
}
 
mutex_unlock(>lock);
@@ -273,14 +300,30 @@ static int em28xx_stop_feed(struct dvb_demux_feed *feed)
 {
struct dvb_demux *demux  = feed->demux;
struct em28xx_dvb *dvb = demux->priv;
+   struct em28xx_i2c_bus *i2c_bus = dvb->adapter.priv;
+   struct em28xx *dev = i2c_bus->dev;
int err = 0;
 
mutex_lock(>lock);
dvb->nfeeds--;
 
-   if (!dvb->nfeeds)
+   if (!dvb->nfeeds) {
err = em28xx_stop_streaming(dvb);
 
+   if (dev->dev_next)
+   mutex_lock(>dev_next->lock);
+  

[PATCH] [RFC] em28xx: Fix dual transport stream use

2018-06-27 Thread Brad Love
When dual transport stream support was added the call to set
alt mode on the USB interface was moved to em28xx_dvb_init.
This was reported to break streaming for a device, so the
call was re-added to em28xx_start_streaming.

Commit 509f89652f83 ("media: em28xx: fix a regression with HVR-950")

This regression fix however broke dual transport stream support.
When a tuner starts streaming it sets alt mode on the USB interface.
The problem is both tuners share the same USB interface, so when
the second tuner becomes active and sets alt mode on the interface
it kills streaming on the other port.

It was suggested add a refcount somewhere and only set alt mode if
no tuners are currently active on the interface. This requires
sharing some state amongst both tuner devices, with appropriate
locking.

What I've done here is the following:
- Add a usage_count pointer to struct em28xx
- Share usage_count between both em28xx devices
- Only set alt mode if usage_count is zero
- Increment usage_count when each tuner becomes active
- Decrement usage_count when a tuner becomes idle

With usage_count in the main em28xx struct, locking is handled as
follows:
- if a secondary tuner exists, lock dev->dev_next->lock
- if no secondary tuner exists, lock dev->lock

By using the above scheme a single tuner device, will lock itself,
the first tuner in a dual tuner device will lock the second tuner,
and the second tuner in a dual tuner device will lock itself aka
the second tuner instance.

This is a perhaps a little hacky, which is why I've added the RFC.
A quick solution was required though, so I don't fix a couple
newer Hauppauge devices, just to break a lot of older ones.


Brad Love (1):
  em28xx: Fix dual transport stream operation

 drivers/media/usb/em28xx/em28xx-cards.c |  6 -
 drivers/media/usb/em28xx/em28xx-dvb.c   | 47 +++--
 drivers/media/usb/em28xx/em28xx.h   |  1 +
 3 files changed, 51 insertions(+), 3 deletions(-)

-- 
2.7.4



[PATCH] media: v4l2-ctrls: Fix CID base conflict between MAX217X and IMX

2018-06-27 Thread Steve Longerbeam
When the imx-media driver was initially merged, there was a conflict
with 8d67ae25 ("media: v4l2-ctrls: Reserve controls for MAX217X") which
was not fixed up correctly, resulting in V4L2_CID_USER_MAX217X_BASE and
V4L2_CID_USER_IMX_BASE taking on the same value. Fix by assigning imx
CID base the next available range at 0x10b0.

Signed-off-by: Steve Longerbeam 
---
 include/uapi/linux/v4l2-controls.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/v4l2-controls.h 
b/include/uapi/linux/v4l2-controls.h
index 8d473c9..8a75ad7 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -188,7 +188,7 @@ enum v4l2_colorfx {
 
 /* The base for the imx driver controls.
  * We reserve 16 controls for this driver. */
-#define V4L2_CID_USER_IMX_BASE (V4L2_CID_USER_BASE + 0x1090)
+#define V4L2_CID_USER_IMX_BASE (V4L2_CID_USER_BASE + 0x10b0)
 
 /* MPEG-class control IDs */
 /* The MPEG controls are applicable to all codec controls
-- 
2.7.4



[PATCH 2/2] em28xx: Fix DualHD disconnect oops

2018-06-27 Thread Brad Love
During the duplication of em28xx state for the second tuner pair
a pointer to alt_max_pkt_size_isoc is copied. During tear down
the second tuner is destroyed first and kfrees alt_max_pkt_size_isoc,
then the first tuner is destroyed and kfrees it again. The property
should only be kfree'd if the tuner is PRIMARY_TS.

[  354.888560] [ cut here ]
[  354.888562] kernel BUG at mm/slub.c:296!
[  354.888574] invalid opcode:  [#1] SMP NOPTI
[  354.69] CPU: 1 PID: 19 Comm: kworker/1:0 Not tainted 4.18.0-rc1+ #20
[  354.889140] Hardware name: MSI MS-7A39/B350M GAMING PRO (MS-7A39), BIOS 2.G0 
04/27/2018
[  354.889408] Workqueue: usb_hub_wq hub_event
[  354.889679] RIP: 0010:__slab_free+0x217/0x370
[  354.889942] Code: bb c0 e8 07 41 38 c7 72 39 48 83 c4 70 5b 41 5a 41 5c 41 
5d 41 5e 41 5f 5d 49 8d 62 f8 c3 f3 90 49 8b 04 24 a8 01 75 f6 eb 82 <0f> 0b 44 
89 45 80 48 89 4d 88 e8 aa fa ff ff 85 c0 74 cc e9 b7 fe 
[  354.890598] RSP: 0018:b84c41a4fad0 EFLAGS: 00010246
[  354.890934] RAX: 948646e85150 RBX: 948646e85150 RCX: 948646e85150
[  354.891280] RDX: 820001d9 RSI: fa8fd01ba140 RDI: 94865e807c00
[  354.891649] RBP: b84c41a4fb70 R08: 0001 R09: c059ce21
[  354.892025] R10: 948646e85150 R11: 0001 R12: fa8fd01ba140
[  354.892403] R13: 948646e85150 R14: 94865e807c00 R15: 94864c92e0a0
[  354.892780] FS:  () GS:94865ec4() 
knlGS:
[  354.893150] CS:  0010 DS:  ES:  CR0: 80050033
[  354.893530] CR2: 7f4e476da950 CR3: 00040112c000 CR4: 003406e0
[  354.893917] Call Trace:
[  354.894315]  ? __dev_printk+0x3c/0x80
[  354.894695]  ? _dev_info+0x64/0x80
[  354.895082]  ? em28xx_free_device+0x41/0x50 [em28xx]
[  354.895464]  kfree+0x17a/0x190
[  354.895852]  ? kfree+0x17a/0x190
[  354.896310]  em28xx_free_device+0x41/0x50 [em28xx]
[  354.896698]  em28xx_usb_disconnect+0xfa/0x110 [em28xx]
[  354.897083]  usb_unbind_interface+0x7a/0x270
[  354.897475]  device_release_driver_internal+0x17c/0x250
[  354.897864]  device_release_driver+0x12/0x20
[  354.898252]  bus_remove_device+0xec/0x160
[  354.898639]  device_del+0x13d/0x320
[  354.899018]  ? usb_remove_ep_devs+0x1f/0x30
[  354.899392]  usb_disable_device+0x9e/0x270
[  354.899772]  usb_disconnect+0x92/0x2a0
[  354.900149]  hub_event+0x98e/0x1650
[  354.900519]  ? sched_clock_cpu+0x11/0xa0
[  354.900890]  process_one_work+0x167/0x3f0
[  354.901251]  worker_thread+0x4d/0x460
[  354.901610]  kthread+0x105/0x140
[  354.901964]  ? rescuer_thread+0x360/0x360
[  354.902318]  ? kthread_associate_blkcg+0xa0/0xa0
[  354.902672]  ret_from_fork+0x22/0x40
[  354.903024] Modules linked in: rc_hauppauge em28xx_rc rc_core si2157 
lgdt3306a i2c_mux em28xx_dvb dvb_core videobuf2_vmalloc videobuf2_memops 
videobuf2_common snd_hda_codec_hdmi nls_iso8859_1 edac_mce_amd kvm 
crct10dif_pclmul crc32_pclmul ghash_clmulni_intel pcbc snd_hda_intel 
snd_hda_codec snd_hda_core snd_hwdep snd_pcm snd_seq_midi aesni_intel 
snd_seq_midi_event aes_x86_64 snd_rawmidi crypto_simd em28xx cryptd glue_helper 
asix tveeprom usbnet snd_seq v4l2_common mii videodev snd_seq_device media 
input_leds snd_timer joydev ccp k10temp wmi_bmof snd soundcore mac_hid 
sch_fq_codel parport_pc ppdev lp parport ip_tables x_tables vfio_pci 
vfio_virqfd irqbypass vfio_iommu_type1 vfio nouveau mxm_wmi video i2c_algo_bit 
ttm drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops i2c_piix4 drm 
ahci libahci
[  354.905129]  wmi gpio_amdpt gpio_generic hid_generic usbhid hid
[  354.908140] ---[ end trace c230d02716298c34 ]---
[  354.908145] RIP: 0010:__slab_free+0x217/0x370
[  354.908147] Code: bb c0 e8 07 41 38 c7 72 39 48 83 c4 70 5b 41 5a 41 5c 41 
5d 41 5e 41 5f 5d 49 8d 62 f8 c3 f3 90 49 8b 04 24 a8 01 75 f6 eb 82 <0f> 0b 44 
89 45 80 48 89 4d 88 e8 aa fa ff ff 85 c0 74 cc e9 b7 fe 
[  354.908183] RSP: 0018:b84c41a4fad0 EFLAGS: 00010246
[  354.908186] RAX: 948646e85150 RBX: 948646e85150 RCX: 948646e85150
[  354.908189] RDX: 820001d9 RSI: fa8fd01ba140 RDI: 94865e807c00
[  354.908191] RBP: b84c41a4fb70 R08: 0001 R09: c059ce21
[  354.908193] R10: 948646e85150 R11: 0001 R12: fa8fd01ba140
[  354.908195] R13: 948646e85150 R14: 94865e807c00 R15: 94864c92e0a0
[  354.908198] FS:  () GS:94865ec4() 
knlGS:
[  354.908201] CS:  0010 DS:  ES:  CR0: 80050033
[  354.908203] CR2: 7f4e476da950 CR3: 00016b20a000 CR4: 003406e0



Signed-off-by: Brad Love 
---
 drivers/media/usb/em28xx/em28xx-cards.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/em28xx/em28xx-cards.c 
b/drivers/media/usb/em28xx/em28xx-cards.c
index c8d60e4..48bc505 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -3374,7 +3374,9 @@ 

[PATCH 1/2] em28xx: Remove duplicate PID

2018-06-27 Thread Brad Love
Half-revert: commit 5b1a270d224b ("media: dvb: add alternative USB PID for 
Hauppauge WinTV-soloHD")'

The PID already exists on the line above.

Signed-off-by: Brad Love 
---
 drivers/media/usb/em28xx/em28xx-cards.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/media/usb/em28xx/em28xx-cards.c 
b/drivers/media/usb/em28xx/em28xx-cards.c
index 6c84383..c8d60e4 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -2688,8 +2688,6 @@ struct usb_device_id em28xx_id_table[] = {
.driver_info = EM28178_BOARD_PCTV_292E },
{ USB_DEVICE(0x2040, 0x8268), /* Hauppauge Retail WinTV-soloHD Bulk */
.driver_info = EM28178_BOARD_PCTV_292E },
-   { USB_DEVICE(0x2040, 0x8268), /* Hauppauge WinTV-soloHD alt. PID */
-   .driver_info = EM28178_BOARD_PCTV_292E },
{ USB_DEVICE(0x0413, 0x6f07),
.driver_info = EM2861_BOARD_LEADTEK_VC100 },
{ USB_DEVICE(0xeb1a, 0x8179),
-- 
2.7.4



[PATCH 0/2] em28xx: Disconnect oops fix and cleanup

2018-06-27 Thread Brad Love
This series cleans up an oops that is encountered during
USB disconnect on all Hauppauge dual-tuner DualHD devices.

A duplicate PID that was added is also removed, since it
already existed on the line above.

Brad Love (2):
  em28xx: Remove duplicate PID
  em28xx: Fix DualHD disconnect oops

 drivers/media/usb/em28xx/em28xx-cards.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.7.4



With Due Respect!

2018-06-27 Thread Mr Ghazi Ahmed
Hi friend I am a banker in ADB BANK. I want to transfer an abandoned
$10.2Million to your Bank account. 40/percent will be your share.
For more details contanct me urgently. Yours Mr Ghazi Ahmed


[GIT FIXES FOR v4.18] meson-ir produces too many warnings

2018-06-27 Thread Sean Young
Hi Mauro,

The meson-ir drivers produces a lot of errors since v4.18. Simply make
this dev_warn_once().

Thanks,
Sean

The following changes since commit e88f5e9ebd54bdf75c9833e3d9add7c2c0d39b0b:

  media: uvcvideo: Prevent setting unavailable flags (2018-06-05 08:53:17 -0400)

are available in the Git repository at:

  git://linuxtv.org/syoung/media_tree.git for-v4.18e

for you to fetch changes up to 97983eed9c07ffd94429527a5e41facde4811fbc:

  media: rc: be less noisy when driver misbehaves (2018-06-27 10:51:42 +0100)


Sean Young (1):
  media: rc: be less noisy when driver misbehaves

 drivers/media/rc/rc-ir-raw.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)


Re: kernel patch 2018-05-28 media: gspca_zc3xx: Implement proper autogain and exposure control for OV7648

2018-06-27 Thread Ondrej Zary
On 22/06/18 01:49, safocl wrote:
> This patch makes it impossible to configure the exposure on webcams, 
> specifically a4tech, with others was not checked. Seen from several users.
> link to the Russian forum archlinux: 
> https://archlinux.org.ru/forum/topic/18581/?page=1
> 
> was checked on webcam a4tech pk-910h idVendor = 0ac8, idProduct = 3500, 
> bcdDevice = 10.07
> 
> with the kernel before this commit, exposure adjustment is possible.
> 
> commit link: 
> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=6f92c3a22ccd66604b8b528221a9d8e1b3fb4e39
> 

0ac8:3500 is an UVC camera. This patch does not affect UVC cameras in any way.

-- 
Ondrej Zary


Re: V4L2_CID_USER_MAX217X_BASE == V4L2_CID_USER_IMX_BASE

2018-06-27 Thread Hans Verkuil
On 06/26/2018 11:21 PM, Steve Longerbeam wrote:
> Hello Helmut,
> 
> 
> On 06/22/2018 12:51 AM, Helmut Grohne wrote:
>> Hi,
>>
>> I found it strange that the macros V4L2_CID_USER_MAX217X_BASE and
>> V4L2_CID_USER_IMX_BASE have equal value even though each of them state
>> that they reserved a range. Those reservations look conflicting to me.
> 
> Yes, they conflict.
> 
>> The macro V4L2_CID_USER_MAX217X_BASE came first,
> 
> No, imx came first. e1302912 ("media: Add i.MX media core driver")
> is dated June 10, 2017. 8d67ae25 ("media: v4l2-ctrls: Reserve controls for
> MAX217X") is dated two days later.
> 
>>   and
>> V4L2_CID_USER_IMX_BASE was introduced in e130291212df ("media: Add i.MX
>> media core driver") with the conflicting assignment (not a merge error).
>> The authors of that patch mostly make up the recipient list.
> 
> There were 8 revisions of the imx-media driver posted. In all of
> those postings, V4L2_CID_USER_MAX217X_BASE did not exist yet.
> So it looks like 8d67ae25 was merged at the same time as e1302912
> but the conflict went unnoticed.
> 
> Steve
> 

Since imx is staging I propose that the IMX base is modified. Steve, can
you make a patch for this changing 0x1090 to 0x10b0?

Regards,

Hans