Re: [PATCH] v4l2-compat-ioctl32: replace pr_warn by pr_debug

2015-09-09 Thread Sakari Ailus
On Wed, Sep 09, 2015 at 08:40:39AM +0200, Hans Verkuil wrote:
> Every time compat32 encounters an unknown ioctl it will call pr_warn.
> However, that's very irritating since it is perfectly normal that this
> happens. For example, applications often try to call an ioctl to see if
> it exists, and if that's used with an older kernel where compat32 doesn't
> support that ioctl yet, then it starts spamming the kernel log.
> 
> So replace pr_warn by pr_debug.
> 
> Signed-off-by: Hans Verkuil 
> ---
>  drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c 
> b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
> index af63543..ba26a19 100644
> --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
> +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
> @@ -1033,8 +1033,8 @@ long v4l2_compat_ioctl32(struct file *file, unsigned 
> int cmd, unsigned long arg)
>   ret = vdev->fops->compat_ioctl32(file, cmd, arg);
>  
>   if (ret == -ENOIOCTLCMD)
> - pr_warn("compat_ioctl32: unknown ioctl '%c', dir=%d, #%d 
> (0x%08x)\n",
> - _IOC_TYPE(cmd), _IOC_DIR(cmd), _IOC_NR(cmd), cmd);
> + pr_debug("compat_ioctl32: unknown ioctl '%c', dir=%d, #%d 
> (0x%08x)\n",
> +  _IOC_TYPE(cmd), _IOC_DIR(cmd), _IOC_NR(cmd), cmd);
>   return ret;
>  }
>  EXPORT_SYMBOL_GPL(v4l2_compat_ioctl32);

Acked-by: Sakari Ailus 

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8 06/55] [media] media: use media_gobj inside pads

2015-09-09 Thread Sakari Ailus
Hi Mauro,

On Sun, Aug 30, 2015 at 12:06:17AM -0300, Mauro Carvalho Chehab wrote:
> PADs also need unique object IDs that won't conflict with
> the entity object IDs.
> 
> The pad objects are currently created via media_entity_init()
> and, once created, never change.
> 
> While this will likely change in the future in order to
> support dynamic changes, for now we'll keep PADs as arrays
> and initialize the media_gobj embedded structs when
> registering the entity.
> 
> Signed-off-by: Mauro Carvalho Chehab 
> Acked-by: Hans Verkuil 
> 
> diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> index 81d6a130efef..3bdda16584fe 100644
> --- a/drivers/media/media-device.c
> +++ b/drivers/media/media-device.c
> @@ -427,6 +427,8 @@ EXPORT_SYMBOL_GPL(media_device_unregister);
>  int __must_check media_device_register_entity(struct media_device *mdev,
> struct media_entity *entity)
>  {
> + int i;

unsigned int?

> +
>   /* Warn if we apparently re-register an entity */
>   WARN_ON(entity->parent != NULL);
>   entity->parent = mdev;
> @@ -435,6 +437,12 @@ int __must_check media_device_register_entity(struct 
> media_device *mdev,
>   /* Initialize media_gobj embedded at the entity */
>   media_gobj_init(mdev, MEDIA_GRAPH_ENTITY, >graph_obj);
>   list_add_tail(>list, >entities);
> +
> + /* Initialize objects at the pads */
> + for (i = 0; i < entity->num_pads; i++)
> + media_gobj_init(mdev, MEDIA_GRAPH_PAD,
> +>pads[i].graph_obj);
> +
>   spin_unlock(>lock);
>  
>   return 0;
> @@ -450,12 +458,15 @@ EXPORT_SYMBOL_GPL(media_device_register_entity);
>   */
>  void media_device_unregister_entity(struct media_entity *entity)
>  {
> + int i;

Ditto. It'd be nice to declare short temporary and counter variables as
last (i.e. after mdev).

>   struct media_device *mdev = entity->parent;
>  
>   if (mdev == NULL)
>   return;
>  
>   spin_lock(>lock);
> + for (i = 0; i < entity->num_pads; i++)
> + media_gobj_remove(>pads[i].graph_obj);
>   media_gobj_remove(>graph_obj);
>   list_del(>list);
>   spin_unlock(>lock);
> diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
> index 888cb88e19bf..377c6655c5d0 100644
> --- a/drivers/media/media-entity.c
> +++ b/drivers/media/media-entity.c
> @@ -48,6 +48,9 @@ void media_gobj_init(struct media_device *mdev,
>   case MEDIA_GRAPH_ENTITY:
>   gobj->id = media_gobj_gen_id(type, ++mdev->entity_id);
>   break;
> + case MEDIA_GRAPH_PAD:
> + gobj->id = media_gobj_gen_id(type, ++mdev->pad_id);
> + break;
>   }
>  }
>  
> diff --git a/include/media/media-device.h b/include/media/media-device.h
> index f6deef6e5820..9493721f630e 100644
> --- a/include/media/media-device.h
> +++ b/include/media/media-device.h
> @@ -42,6 +42,7 @@ struct device;
>   * @hw_revision: Hardware device revision
>   * @driver_version: Device driver version
>   * @entity_id:   Unique ID used on the last entity registered
> + * @pad_id:  Unique ID used on the last pad registered
>   * @entities:List of registered entities
>   * @lock:Entities list lock
>   * @graph_mutex: Entities graph operation lock
> @@ -69,6 +70,7 @@ struct media_device {
>   u32 driver_version;
>  
>   u32 entity_id;
> + u32 pad_id;
>  
>   struct list_head entities;
>  
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index bb74b5883cbb..ce4c654486d6 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -34,9 +34,11 @@
>   * enum media_gobj_type - type of a graph object
>   *
>   * @MEDIA_GRAPH_ENTITY:  Identify a media entity
> + * @MEDIA_GRAPH_PAD: Identify a media pad
>   */
>  enum media_gobj_type {
>   MEDIA_GRAPH_ENTITY,
> + MEDIA_GRAPH_PAD,
>  };
>  
>  #define MEDIA_BITS_PER_TYPE  8
> @@ -72,6 +74,7 @@ struct media_link {
>  };
>  
>  struct media_pad {
> + struct media_gobj graph_obj;
>   struct media_entity *entity;/* Entity this pad belongs to */
>   u16 index;  /* Pad index in the entity pads array */
>   unsigned long flags;/* Pad flags (MEDIA_PAD_FL_*) */

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8 18/55] [media] omap3isp: create links after all subdevs have been bound

2015-09-09 Thread Sakari Ailus
Hi Javier and Mauro,

On Sun, Aug 30, 2015 at 12:06:29AM -0300, Mauro Carvalho Chehab wrote:
> From: Javier Martinez Canillas 
> 
> The omap3isp driver parses the graph endpoints to know how many subdevices
> needs to be registered async and register notifiers callbacks for to know
> when these are bound and when the async registrations are completed.
> 
> Currently the entities pad are linked with the correct ISP input interface
> when the subdevs are bound but it happens before entitities are registered
> with the media device so that won't work now that the entity links list is
> initialized on device registration.
> 
> So instead creating the pad links when the subdevice is bound, create them
> on the complete callback once all the subdevices have been bound but only
> try to create for the ones that have a bus configuration set during bound.
> 
> Signed-off-by: Javier Martinez Canillas 
> Signed-off-by: Mauro Carvalho Chehab 
> 
> diff --git a/drivers/media/platform/omap3isp/isp.c 
> b/drivers/media/platform/omap3isp/isp.c
> index b8f6f81d2db2..69e7733d36cd 100644
> --- a/drivers/media/platform/omap3isp/isp.c
> +++ b/drivers/media/platform/omap3isp/isp.c
> @@ -2321,26 +2321,33 @@ static int isp_subdev_notifier_bound(struct 
> v4l2_async_notifier *async,
>struct v4l2_subdev *subdev,
>struct v4l2_async_subdev *asd)
>  {
> - struct isp_device *isp = container_of(async, struct isp_device,
> -   notifier);
>   struct isp_async_subdev *isd =
>   container_of(asd, struct isp_async_subdev, asd);
> - int ret;
> -
> - ret = isp_link_entity(isp, >entity, isd->bus.interface);
> - if (ret < 0)
> - return ret;
>  
>   isd->sd = subdev;
>   isd->sd->host_priv = >bus;
>  
> - return ret;
> + return 0;
>  }
>  
>  static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async)
>  {
>   struct isp_device *isp = container_of(async, struct isp_device,
> notifier);
> + struct v4l2_device *v4l2_dev = >v4l2_dev;
> + struct v4l2_subdev *sd;
> + struct isp_bus_cfg *bus;
> + int ret;
> +
> + list_for_each_entry(sd, _dev->subdevs, list) {
> + /* Only try to link entities whose interface was set on bound */
> + if (sd->host_priv) {
> + bus = (struct isp_bus_cfg *)sd->host_priv;
> + ret = isp_link_entity(isp, >entity, bus->interface);
> + if (ret < 0)
> + return ret;
> + }
> + }
>  
>   return v4l2_device_register_subdev_nodes(>v4l2_dev);
>  }

I think you're working around a problem here, not really fixing it.

This change will create the links only after the media device is registered,
which means the user may obtain a partial enumeration of links if the
enumeration is performed too early.

Before this set, the problem also was that the media device was registered
before the async entities were bound, again making it possible to obtain a
partial enumeration of entities.

What I'd suggest instead is that we split media device initialisation and
registration to the system; that way the media device can be prepared
(entities registered and links created) before it becomes visible to the
user space. I can write a patch for that if you like.

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] v4l2-compat-ioctl32: replace pr_warn by pr_debug

2015-09-09 Thread Hans Verkuil
Every time compat32 encounters an unknown ioctl it will call pr_warn.
However, that's very irritating since it is perfectly normal that this
happens. For example, applications often try to call an ioctl to see if
it exists, and if that's used with an older kernel where compat32 doesn't
support that ioctl yet, then it starts spamming the kernel log.

So replace pr_warn by pr_debug.

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c 
b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index af63543..ba26a19 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -1033,8 +1033,8 @@ long v4l2_compat_ioctl32(struct file *file, unsigned int 
cmd, unsigned long arg)
ret = vdev->fops->compat_ioctl32(file, cmd, arg);
 
if (ret == -ENOIOCTLCMD)
-   pr_warn("compat_ioctl32: unknown ioctl '%c', dir=%d, #%d 
(0x%08x)\n",
-   _IOC_TYPE(cmd), _IOC_DIR(cmd), _IOC_NR(cmd), cmd);
+   pr_debug("compat_ioctl32: unknown ioctl '%c', dir=%d, #%d 
(0x%08x)\n",
+_IOC_TYPE(cmd), _IOC_DIR(cmd), _IOC_NR(cmd), cmd);
return ret;
 }
 EXPORT_SYMBOL_GPL(v4l2_compat_ioctl32);
-- 
2.1.4

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


Re: [PATCH v1] media: uvcvideo: handle urb completion in a work queue

2015-09-09 Thread Laurent Pinchart
On Wednesday 09 September 2015 10:30:12 Hans de Goede wrote:
> On 08-09-15 16:36, Alan Stern wrote:
> > On Tue, 8 Sep 2015, Hans de Goede wrote:
> >> On 09/07/2015 06:23 PM, Mian Yousaf Kaukab wrote:
> >>> urb completion callback is executed in host controllers interrupt
> >>> context. To keep preempt disable time short, add urbs to a list on
> >>> completion and schedule work to process the list.
> >>> 
> >>> Moreover, save timestamp and sof number in the urb completion callback
> >>> to avoid any delays.
> >> 
> >> Erm, I thought that we had already moved to using threaded interrupt
> >> handling for the urb completion a while (1-2 years ?) back. Is this then
> >> still needed ?
> > 
> > We moved to handling URB completions in a tasklet, not a threaded
> > handler.
> 
> Right.
> 
> > (Similar idea, though.)  And the change was made in only one
> > or two HCDs, not in all of them.
> 
> Ah, I was under the impression this was a core change, not a per
> hcd change.

Instead of fixing the issue in the uvcvideo driver, would it then make more 
sense to fix it in the remaining hcd drivers ?

-- 
Regards,

Laurent Pinchart

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


Cher utilisateur de messagerie Web.

2015-09-09 Thread Lillie Phillips
Cher utilisateur de messagerie Web.



Nous avons un problème technique, nous notre base de date pour le moment. vous 
êtes au CLIQUEZ ICI pour vous reconfirmer 
web compte de messagerie une fois de plus.



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


Videobuf2's vb2_dqbuf return (-EINVAL) error on streamoff

2015-09-09 Thread Chetan Nanda
[Sorry if duplicate, as my last mail rejected because of HTML content]

Hi,

I am working on a V4L2 based video decoder driver,

At user side there are two contexts.
One is queuing/dequeuing buffers from driver (in a separate thread)
and other is the main context, from where I am calling streamon,
streamoff.

When I call a streamoff from main context and thread is blocking on
dqbuf, This cause the blocking thread to unblock from dqbuf with an
error (EINVAL).

Seems this error coming from videobuf2-core, as streamoff will unblock
the waiting thread, and this thread will go and check (in function
__vb2_wait_for_done_vb) for q->streaming and will return error as
q->streaming will be set to false on streamoff.

Is it the right behavior of vb2_dqbuf to return error when streamoff is called?

Or is it a right way to have this kind of mechanism i.e.on userside
one thread is queue/dequeue buffers while another is doing streamoff.

Thanks for your help and idea.

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


Re: [PATCH v8 04/55] [media] media: add a common struct to be embed on media graph objects

2015-09-09 Thread Sakari Ailus
Hi Mauro,

On Sun, Aug 30, 2015 at 12:06:15AM -0300, Mauro Carvalho Chehab wrote:
> Due to the MC API proposed changes, we'll need to have an unique
> object ID for all graph objects, and have some shared fields
> that will be common on all media graph objects.
> 
> Right now, the only common object is the object ID, but other
> fields will be added later on.
> 
> Signed-off-by: Mauro Carvalho Chehab 
> Acked-by: Hans Verkuil 
> 
> diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
> index cb0ac4e0dfa5..4834172bf6f8 100644
> --- a/drivers/media/media-entity.c
> +++ b/drivers/media/media-entity.c
> @@ -27,6 +27,38 @@
>  #include 
>  
>  /**
> + *  media_gobj_init - Initialize a graph object
> + *
> + * @mdev:Pointer to the media_device that contains the object
> + * @type:Type of the object
> + * @gobj:Pointer to the object
> + *
> + * This routine initializes the embedded struct media_gobj inside a
> + * media graph object. It is called automatically if media_*_create()
> + * calls are used. However, if the object (entity, link, pad, interface)
> + * is embedded on some other object, this function should be called before
> + * registering the object at the media controller.
> + */
> +void media_gobj_init(struct media_device *mdev,
> +enum media_gobj_type type,
> +struct media_gobj *gobj)
> +{
> + /* For now, nothing to do */
> +}
> +
> +/**
> + *  media_gobj_remove - Stop using a graph object on a media device
> + *
> + * @graph_obj:   Pointer to the object
> + *
> + * This should be called at media_device_unregister_*() routines
> + */
> +void media_gobj_remove(struct media_gobj *gobj)
> +{
> + /* For now, nothing to do */
> +}
> +
> +/**
>   * media_entity_init - Initialize a media entity
>   *
>   * @num_pads: Total number of sink and source pads.
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index 0a66fc225559..b1854239a476 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -28,6 +28,39 @@
>  #include 
>  #include 
>  
> +/* Enums used internally at the media controller to represent graphs */
> +
> +/**
> + * enum media_gobj_type - type of a graph object
> + *
> + */
> +enum media_gobj_type {
> +  /* FIXME: add the types here, as we embed media_gobj */
> + MEDIA_GRAPH_NONE
> +};
> +
> +#define MEDIA_BITS_PER_TYPE  8
> +#define MEDIA_BITS_PER_LOCAL_ID  (32 - MEDIA_BITS_PER_TYPE)
> +#define MEDIA_LOCAL_ID_MASK   GENMASK(MEDIA_BITS_PER_LOCAL_ID - 1, 0)
> +
> +/* Structs to represent the objects that belong to a media graph */
> +
> +/**
> + * struct media_gobj - Define a graph object.
> + *
> + * @id:  Non-zero object ID identifier. The ID should be unique
> + *   inside a media_device, as it is composed by
> + *   MEDIA_BITS_PER_TYPE to store the type plus
> + *   MEDIA_BITS_PER_LOCAL_ID to store a per-type ID
> + *   (called as "local ID").
> + *
> + * All objects on the media graph should have this struct embedded
> + */
> +struct media_gobj {
> + u32 id;
> +};
> +
> +

Two newlines. Looks like one would be enough. A minor matter though.

>  struct media_pipeline {
>  };
>  
> @@ -118,6 +151,26 @@ static inline u32 media_entity_id(struct media_entity 
> *entity)
>   return entity->id;
>  }
>  
> +static inline enum media_gobj_type media_type(struct media_gobj *gobj)
> +{
> + return gobj->id >> MEDIA_BITS_PER_LOCAL_ID;
> +}
> +
> +static inline u32 media_localid(struct media_gobj *gobj)
> +{
> + return gobj->id & MEDIA_LOCAL_ID_MASK;
> +}
> +
> +static inline u32 media_gobj_gen_id(enum media_gobj_type type, u32 local_id)
> +{
> + u32 id;
> +
> + id = type << MEDIA_BITS_PER_LOCAL_ID;
> + id |= local_id & MEDIA_LOCAL_ID_MASK;
> +
> + return id;
> +}
> +
>  #define MEDIA_ENTITY_ENUM_MAX_DEPTH  16
>  #define MEDIA_ENTITY_ENUM_MAX_ID 64
>  
> @@ -131,6 +184,14 @@ struct media_entity_graph {
>   int top;
>  };
>  
> +#define gobj_to_entity(gobj) \
> + container_of(gobj, struct media_entity, graph_obj)

Just on naming: I'd call this media_gobj_to_entity, as the type is called
media_gobj and secondly the common media prefix is used throughout the MC
API.

Same for the rest of similar macros in further patches.

> +
> +void media_gobj_init(struct media_device *mdev,
> + enum media_gobj_type type,
> + struct media_gobj *gobj);
> +void media_gobj_remove(struct media_gobj *gobj);
> +
>  int media_entity_init(struct media_entity *entity, u16 num_pads,
>   struct media_pad *pads);
>  void media_entity_cleanup(struct media_entity *entity);

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a 

Re: [PATCH v8 14/55] [media] media: add functions to allow creating interfaces

2015-09-09 Thread Sakari Ailus
Hi Mauro,

On Sun, Sep 06, 2015 at 09:02:45AM -0300, Mauro Carvalho Chehab wrote:
> Interfaces are different than entities: they represent a
> Kernel<->userspace interaction, while entities represent a
> piece of hardware/firmware/software that executes a function.
> 
> Let's distinguish them by creating a separate structure to
> store the interfaces.
> 
> Later patches should change the existing drivers and logic
> to split the current interface embedded inside the entity
> structure (device nodes) into a separate object of the graph.
> 
> Signed-off-by: Mauro Carvalho Chehab 
> 
> diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
> index a23c93369a04..dc679dfe8ade 100644
> --- a/drivers/media/media-entity.c
> +++ b/drivers/media/media-entity.c
> @@ -44,11 +44,41 @@ static inline const char *gobj_type(enum media_gobj_type 
> type)
>   return "pad";
>   case MEDIA_GRAPH_LINK:
>   return "link";
> + case MEDIA_GRAPH_INTF_DEVNODE:
> + return "intf-devnode";
>   default:
>   return "unknown";
>   }
>  }
>  
> +static inline const char *intf_type(struct media_interface *intf)
> +{
> + switch (intf->type) {
> + case MEDIA_INTF_T_DVB_FE:
> + return "frontend";
> + case MEDIA_INTF_T_DVB_DEMUX:
> + return "demux";
> + case MEDIA_INTF_T_DVB_DVR:
> + return "DVR";
> + case MEDIA_INTF_T_DVB_CA:
> + return  "CA";
> + case MEDIA_INTF_T_DVB_NET:
> + return "dvbnet";
> + case MEDIA_INTF_T_V4L_VIDEO:
> + return "video";
> + case MEDIA_INTF_T_V4L_VBI:
> + return "vbi";
> + case MEDIA_INTF_T_V4L_RADIO:
> + return "radio";
> + case MEDIA_INTF_T_V4L_SUBDEV:
> + return "v4l2-subdev";
> + case MEDIA_INTF_T_V4L_SWRADIO:
> + return "swradio";
> + default:
> + return "unknown-intf";
> + }
> +};
> +
>  static void dev_dbg_obj(const char *event_name,  struct media_gobj *gobj)
>  {
>  #if defined(DEBUG) || defined (CONFIG_DYNAMIC_DEBUG)
> @@ -84,6 +114,19 @@ static void dev_dbg_obj(const char *event_name,  struct 
> media_gobj *gobj)
>   "%s: id 0x%08x pad#%d: '%s':%d\n",
>   event_name, gobj->id, media_localid(gobj),
>   pad->entity->name, pad->index);
> + break;
> + }
> + case MEDIA_GRAPH_INTF_DEVNODE:
> + {
> + struct media_interface *intf = gobj_to_intf(gobj);
> + struct media_intf_devnode *devnode = intf_to_devnode(intf);
> +
> + dev_dbg(gobj->mdev->dev,
> + "%s: id 0x%08x intf_devnode#%d: %s - major: %d, minor: 
> %d\n",
> + event_name, gobj->id, media_localid(gobj),
> + intf_type(intf),
> + devnode->major, devnode->minor);
> + break;
>   }
>   }
>  #endif
> @@ -119,6 +162,9 @@ void media_gobj_init(struct media_device *mdev,
>   case MEDIA_GRAPH_LINK:
>   gobj->id = media_gobj_gen_id(type, ++mdev->link_id);
>   break;
> + case MEDIA_GRAPH_INTF_DEVNODE:
> + gobj->id = media_gobj_gen_id(type, ++mdev->intf_devnode_id);
> + break;
>   }
>   dev_dbg_obj(__func__, gobj);
>  }
> @@ -793,3 +839,40 @@ struct media_pad *media_entity_remote_pad(struct 
> media_pad *pad)
>  
>  }
>  EXPORT_SYMBOL_GPL(media_entity_remote_pad);
> +
> +
> +/* Functions related to the media interface via device nodes */
> +
> +struct media_intf_devnode *media_devnode_create(struct media_device *mdev,
> + u32 type, u32 flags,
> + u32 major, u32 minor,
> + gfp_t gfp_flags)
> +{
> + struct media_intf_devnode *devnode;
> + struct media_interface *intf;
> +
> + devnode = kzalloc(sizeof(*devnode), gfp_flags);

Do you think the user might want to specify something else then GFP_KERNEL
as gfp_flags? If not, I'd keep this internal to the function. It can also be
added later if needed.

> + if (!devnode)
> + return NULL;
> +
> + intf = >intf;
> +
> + intf->type = type;
> + intf->flags = flags;
> +
> + devnode->major = major;
> + devnode->minor = minor;
> +
> + media_gobj_init(mdev, MEDIA_GRAPH_INTF_DEVNODE,
> +>intf.graph_obj);
> +
> + return devnode;
> +}
> +EXPORT_SYMBOL_GPL(media_devnode_create);
> +
> +void media_devnode_remove(struct media_intf_devnode *devnode)
> +{
> + media_gobj_remove(>intf.graph_obj);
> + kfree(devnode);
> +}
> +EXPORT_SYMBOL_GPL(media_devnode_remove);
> diff --git a/include/media/media-device.h b/include/media/media-device.h
> index 05414e351f8e..3b14394d5701 100644
> --- a/include/media/media-device.h
> +++ b/include/media/media-device.h
> @@ -44,6 +44,7 @@ 

Re: [PATCH v8 18/55] [media] omap3isp: create links after all subdevs have been bound

2015-09-09 Thread Javier Martinez Canillas
Hello Sakari,

On 09/09/2015 10:03 AM, Sakari Ailus wrote:
> Hi Javier and Mauro,
> 
> On Sun, Aug 30, 2015 at 12:06:29AM -0300, Mauro Carvalho Chehab wrote:
>> From: Javier Martinez Canillas 
>>
>> The omap3isp driver parses the graph endpoints to know how many subdevices
>> needs to be registered async and register notifiers callbacks for to know
>> when these are bound and when the async registrations are completed.
>>
>> Currently the entities pad are linked with the correct ISP input interface
>> when the subdevs are bound but it happens before entitities are registered
>> with the media device so that won't work now that the entity links list is
>> initialized on device registration.
>>
>> So instead creating the pad links when the subdevice is bound, create them
>> on the complete callback once all the subdevices have been bound but only
>> try to create for the ones that have a bus configuration set during bound.
>>
>> Signed-off-by: Javier Martinez Canillas 
>> Signed-off-by: Mauro Carvalho Chehab 
>>
>> diff --git a/drivers/media/platform/omap3isp/isp.c 
>> b/drivers/media/platform/omap3isp/isp.c
>> index b8f6f81d2db2..69e7733d36cd 100644
>> --- a/drivers/media/platform/omap3isp/isp.c
>> +++ b/drivers/media/platform/omap3isp/isp.c
>> @@ -2321,26 +2321,33 @@ static int isp_subdev_notifier_bound(struct 
>> v4l2_async_notifier *async,
>>   struct v4l2_subdev *subdev,
>>   struct v4l2_async_subdev *asd)
>>  {
>> -struct isp_device *isp = container_of(async, struct isp_device,
>> -  notifier);
>>  struct isp_async_subdev *isd =
>>  container_of(asd, struct isp_async_subdev, asd);
>> -int ret;
>> -
>> -ret = isp_link_entity(isp, >entity, isd->bus.interface);
>> -if (ret < 0)
>> -return ret;
>>  
>>  isd->sd = subdev;
>>  isd->sd->host_priv = >bus;
>>  
>> -return ret;
>> +return 0;
>>  }
>>  
>>  static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async)
>>  {
>>  struct isp_device *isp = container_of(async, struct isp_device,
>>notifier);
>> +struct v4l2_device *v4l2_dev = >v4l2_dev;
>> +struct v4l2_subdev *sd;
>> +struct isp_bus_cfg *bus;
>> +int ret;
>> +
>> +list_for_each_entry(sd, _dev->subdevs, list) {
>> +/* Only try to link entities whose interface was set on bound */
>> +if (sd->host_priv) {
>> +bus = (struct isp_bus_cfg *)sd->host_priv;
>> +ret = isp_link_entity(isp, >entity, bus->interface);
>> +if (ret < 0)
>> +return ret;
>> +}
>> +}
>>  
>>  return v4l2_device_register_subdev_nodes(>v4l2_dev);
>>  }
> 
> I think you're working around a problem here, not really fixing it.
> 
> This change will create the links only after the media device is registered,
> which means the user may obtain a partial enumeration of links if the
> enumeration is performed too early.
> 
> Before this set, the problem also was that the media device was registered
> before the async entities were bound, again making it possible to obtain a
> partial enumeration of entities.
>

You are absolutely correct but I think these are separate issues. The problem
here is that v4l2_async_test_notify() [0] first invokes the bound notifier
callback and then calls v4l2_device_register_subdev() that register the media
entity with the media device.

Since now is a requirement that the entities must be registered prior creating
pads links (because to init a MEDIA_GRAPH_LINK object a mdev has to be set),
$SUBJECT is needed regardless of the race between subdev registration and the
media dev node being available to user-space before everything is registered.
 
> What I'd suggest instead is that we split media device initialisation and
> registration to the system; that way the media device can be prepared
> (entities registered and links created) before it becomes visible to the
> user space. I can write a patch for that if you like.
>

Agreed, looking at the implementation it seems that __media_device_register()
has to be split (possibly being renamed to __media_device_init) so it only
contains the initialization logic and all the media device node registration
logic moved to another function (that would become media_device_register).

I think the media dev node registration has to be made in the complete callback
to make sure that happens when all the subdevs have been already registered.

Is that what you had in mind? I can also write such a patch if you want.

[0]: 
http://lxr.free-electrons.com/source/drivers/media/v4l2-core/v4l2-async.c#L96
[1]: http://lxr.free-electrons.com/source/drivers/media/media-device.c#L372

Best regards,
-- 
Javier Martinez Canillas
Open Source Group

Re: [PATCH v1] media: uvcvideo: handle urb completion in a work queue

2015-09-09 Thread Hans de Goede

Hi,

On 08-09-15 16:36, Alan Stern wrote:

On Tue, 8 Sep 2015, Hans de Goede wrote:


Hi,

On 09/07/2015 06:23 PM, Mian Yousaf Kaukab wrote:

urb completion callback is executed in host controllers interrupt
context. To keep preempt disable time short, add urbs to a list on
completion and schedule work to process the list.

Moreover, save timestamp and sof number in the urb completion callback
to avoid any delays.


Erm, I thought that we had already moved to using threaded interrupt
handling for the urb completion a while (1-2 years ?) back. Is this then
still needed ?


We moved to handling URB completions in a tasklet, not a threaded
handler.


Right.


(Similar idea, though.)  And the change was made in only one
or two HCDs, not in all of them.


Ah, I was under the impression this was a core change, not a per
hcd change.

Regards,

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


Re: [PATCH v8 14/55] [media] media: add functions to allow creating interfaces

2015-09-09 Thread Mauro Carvalho Chehab
Em Wed, 09 Sep 2015 10:34:05 +0300
Sakari Ailus  escreveu:

> Hi Mauro,
> 
> On Sun, Sep 06, 2015 at 09:02:45AM -0300, Mauro Carvalho Chehab wrote:
> > Interfaces are different than entities: they represent a
> > Kernel<->userspace interaction, while entities represent a
> > piece of hardware/firmware/software that executes a function.
> > 
> > Let's distinguish them by creating a separate structure to
> > store the interfaces.
> > 
> > Later patches should change the existing drivers and logic
> > to split the current interface embedded inside the entity
> > structure (device nodes) into a separate object of the graph.
> > 
> > Signed-off-by: Mauro Carvalho Chehab 
> > 
> > diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
> > index a23c93369a04..dc679dfe8ade 100644
> > --- a/drivers/media/media-entity.c
> > +++ b/drivers/media/media-entity.c
> > @@ -44,11 +44,41 @@ static inline const char *gobj_type(enum 
> > media_gobj_type type)
> > return "pad";
> > case MEDIA_GRAPH_LINK:
> > return "link";
> > +   case MEDIA_GRAPH_INTF_DEVNODE:
> > +   return "intf-devnode";
> > default:
> > return "unknown";
> > }
> >  }
> >  
> > +static inline const char *intf_type(struct media_interface *intf)
> > +{
> > +   switch (intf->type) {
> > +   case MEDIA_INTF_T_DVB_FE:
> > +   return "frontend";
> > +   case MEDIA_INTF_T_DVB_DEMUX:
> > +   return "demux";
> > +   case MEDIA_INTF_T_DVB_DVR:
> > +   return "DVR";
> > +   case MEDIA_INTF_T_DVB_CA:
> > +   return  "CA";
> > +   case MEDIA_INTF_T_DVB_NET:
> > +   return "dvbnet";
> > +   case MEDIA_INTF_T_V4L_VIDEO:
> > +   return "video";
> > +   case MEDIA_INTF_T_V4L_VBI:
> > +   return "vbi";
> > +   case MEDIA_INTF_T_V4L_RADIO:
> > +   return "radio";
> > +   case MEDIA_INTF_T_V4L_SUBDEV:
> > +   return "v4l2-subdev";
> > +   case MEDIA_INTF_T_V4L_SWRADIO:
> > +   return "swradio";
> > +   default:
> > +   return "unknown-intf";
> > +   }
> > +};
> > +
> >  static void dev_dbg_obj(const char *event_name,  struct media_gobj *gobj)
> >  {
> >  #if defined(DEBUG) || defined (CONFIG_DYNAMIC_DEBUG)
> > @@ -84,6 +114,19 @@ static void dev_dbg_obj(const char *event_name,  struct 
> > media_gobj *gobj)
> > "%s: id 0x%08x pad#%d: '%s':%d\n",
> > event_name, gobj->id, media_localid(gobj),
> > pad->entity->name, pad->index);
> > +   break;
> > +   }
> > +   case MEDIA_GRAPH_INTF_DEVNODE:
> > +   {
> > +   struct media_interface *intf = gobj_to_intf(gobj);
> > +   struct media_intf_devnode *devnode = intf_to_devnode(intf);
> > +
> > +   dev_dbg(gobj->mdev->dev,
> > +   "%s: id 0x%08x intf_devnode#%d: %s - major: %d, minor: 
> > %d\n",
> > +   event_name, gobj->id, media_localid(gobj),
> > +   intf_type(intf),
> > +   devnode->major, devnode->minor);
> > +   break;
> > }
> > }
> >  #endif
> > @@ -119,6 +162,9 @@ void media_gobj_init(struct media_device *mdev,
> > case MEDIA_GRAPH_LINK:
> > gobj->id = media_gobj_gen_id(type, ++mdev->link_id);
> > break;
> > +   case MEDIA_GRAPH_INTF_DEVNODE:
> > +   gobj->id = media_gobj_gen_id(type, ++mdev->intf_devnode_id);
> > +   break;
> > }
> > dev_dbg_obj(__func__, gobj);
> >  }
> > @@ -793,3 +839,40 @@ struct media_pad *media_entity_remote_pad(struct 
> > media_pad *pad)
> >  
> >  }
> >  EXPORT_SYMBOL_GPL(media_entity_remote_pad);
> > +
> > +
> > +/* Functions related to the media interface via device nodes */
> > +
> > +struct media_intf_devnode *media_devnode_create(struct media_device *mdev,
> > +   u32 type, u32 flags,
> > +   u32 major, u32 minor,
> > +   gfp_t gfp_flags)
> > +{
> > +   struct media_intf_devnode *devnode;
> > +   struct media_interface *intf;
> > +
> > +   devnode = kzalloc(sizeof(*devnode), gfp_flags);
> 
> Do you think the user might want to specify something else then GFP_KERNEL
> as gfp_flags? If not, I'd keep this internal to the function. It can also be
> added later if needed.

Yeah, hardly interfaces would need something different than GFP_KERNEL.

I'll change it.

> 
> > +   if (!devnode)
> > +   return NULL;
> > +
> > +   intf = >intf;
> > +
> > +   intf->type = type;
> > +   intf->flags = flags;
> > +
> > +   devnode->major = major;
> > +   devnode->minor = minor;
> > +
> > +   media_gobj_init(mdev, MEDIA_GRAPH_INTF_DEVNODE,
> > +  >intf.graph_obj);
> > +
> > +   return devnode;
> > +}
> > +EXPORT_SYMBOL_GPL(media_devnode_create);
> > +
> > +void media_devnode_remove(struct media_intf_devnode *devnode)
> > +{
> > +   

Re: [PATCH 2/2] [media] media-device: use unsigned ints on some places

2015-09-09 Thread Hans Verkuil
On 09/09/15 13:32, Mauro Carvalho Chehab wrote:
> The entity->num_pads are defined as u16. So, better to use an
> unsigned int, as this prevents additional warnings when W=2
> (or W=1 on some architectures).
> 
> The "i" counter at __media_device_get_topology() is also a
> monotonic counter that should never be below zero. So,
> make it unsigned too.
> 
> Suggested-by: Sakari Ailus 
> Signed-off-by: Mauro Carvalho Chehab 

Acked-by: Hans Verkuil 

> 
> diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> index 13987710e5bc..1312e93ebd6e 100644
> --- a/drivers/media/media-device.c
> +++ b/drivers/media/media-device.c
> @@ -243,7 +243,8 @@ static long __media_device_get_topology(struct 
> media_device *mdev,
>   struct media_v2_interface uintf;
>   struct media_v2_pad upad;
>   struct media_v2_link ulink;
> - int ret = 0, i;
> + int ret = 0;
> + unsigned int i;
>  
>   topo->topology_version = mdev->topology_version;
>  
> @@ -613,7 +614,7 @@ EXPORT_SYMBOL_GPL(media_device_unregister);
>  int __must_check media_device_register_entity(struct media_device *mdev,
> struct media_entity *entity)
>  {
> - int i;
> + unsigned int i;
>  
>   if (entity->function == MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN ||
>   entity->function == MEDIA_ENT_F_UNKNOWN)
> @@ -650,9 +651,9 @@ EXPORT_SYMBOL_GPL(media_device_register_entity);
>   */
>  void media_device_unregister_entity(struct media_entity *entity)
>  {
> - int i;
>   struct media_device *mdev = entity->graph_obj.mdev;
>   struct media_link *link, *tmp;
> + unsigned int i;
>  
>   if (mdev == NULL)
>   return;
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Videobuf2's vb2_dqbuf return (-EINVAL) error on streamoff

2015-09-09 Thread Hans Verkuil
On 09/09/15 11:19, Chetan Nanda wrote:
> [Sorry if duplicate, as my last mail rejected because of HTML content]
> 
> Hi,
> 
> I am working on a V4L2 based video decoder driver,
> 
> At user side there are two contexts.
> One is queuing/dequeuing buffers from driver (in a separate thread)
> and other is the main context, from where I am calling streamon,
> streamoff.
> 
> When I call a streamoff from main context and thread is blocking on
> dqbuf, This cause the blocking thread to unblock from dqbuf with an
> error (EINVAL).
> 
> Seems this error coming from videobuf2-core, as streamoff will unblock
> the waiting thread, and this thread will go and check (in function
> __vb2_wait_for_done_vb) for q->streaming and will return error as
> q->streaming will be set to false on streamoff.
> 
> Is it the right behavior of vb2_dqbuf to return error when streamoff is 
> called?

Yes. No more buffers will arrive, so you want blocking waits to wake up.

Typically you would want to exit the dequeuing thread or do other clean up
actions.

> Or is it a right way to have this kind of mechanism i.e.on userside
> one thread is queue/dequeue buffers while another is doing streamoff.

This approach is fine.

Regards,

Hans

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


Re: [PATCH v8 04/55] [media] media: add a common struct to be embed on media graph objects

2015-09-09 Thread Mauro Carvalho Chehab
Hi Sakari,

Em Wed, 09 Sep 2015 10:01:49 +0300
Sakari Ailus  escreveu:

> Hi Mauro,
> 
> On Sun, Aug 30, 2015 at 12:06:15AM -0300, Mauro Carvalho Chehab wrote:
> > Due to the MC API proposed changes, we'll need to have an unique
> > object ID for all graph objects, and have some shared fields
> > that will be common on all media graph objects.
> > 
> > Right now, the only common object is the object ID, but other
> > fields will be added later on.

Thanks for the review!

There are already too much patches on the top of this one. So, I'll
be addressing anything we've agreed on at a separate patch series.

I guess this makes easier for reviewers, and avoid spending hours with rebases
and re-tests. On my experience, rebasing a long series like this is not
a good idea, as errors can be introduced on every rebase. So, doing a 
separate patch is usually better.

> > 
> > Signed-off-by: Mauro Carvalho Chehab 
> > Acked-by: Hans Verkuil 
> > 
> > diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
> > index cb0ac4e0dfa5..4834172bf6f8 100644
> > --- a/drivers/media/media-entity.c
> > +++ b/drivers/media/media-entity.c
> > @@ -27,6 +27,38 @@
> >  #include 
> >  
> >  /**
> > + *  media_gobj_init - Initialize a graph object
> > + *
> > + * @mdev:  Pointer to the media_device that contains the object
> > + * @type:  Type of the object
> > + * @gobj:  Pointer to the object
> > + *
> > + * This routine initializes the embedded struct media_gobj inside a
> > + * media graph object. It is called automatically if media_*_create()
> > + * calls are used. However, if the object (entity, link, pad, interface)
> > + * is embedded on some other object, this function should be called before
> > + * registering the object at the media controller.
> > + */
> > +void media_gobj_init(struct media_device *mdev,
> > +  enum media_gobj_type type,
> > +  struct media_gobj *gobj)
> > +{
> > +   /* For now, nothing to do */
> > +}
> > +
> > +/**
> > + *  media_gobj_remove - Stop using a graph object on a media device
> > + *
> > + * @graph_obj: Pointer to the object
> > + *
> > + * This should be called at media_device_unregister_*() routines
> > + */
> > +void media_gobj_remove(struct media_gobj *gobj)
> > +{
> > +   /* For now, nothing to do */
> > +}
> > +
> > +/**
> >   * media_entity_init - Initialize a media entity
> >   *
> >   * @num_pads: Total number of sink and source pads.
> > diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> > index 0a66fc225559..b1854239a476 100644
> > --- a/include/media/media-entity.h
> > +++ b/include/media/media-entity.h
> > @@ -28,6 +28,39 @@
> >  #include 
> >  #include 
> >  
> > +/* Enums used internally at the media controller to represent graphs */
> > +
> > +/**
> > + * enum media_gobj_type - type of a graph object
> > + *
> > + */
> > +enum media_gobj_type {
> > +/* FIXME: add the types here, as we embed media_gobj */
> > +   MEDIA_GRAPH_NONE
> > +};
> > +
> > +#define MEDIA_BITS_PER_TYPE8
> > +#define MEDIA_BITS_PER_LOCAL_ID(32 - MEDIA_BITS_PER_TYPE)
> > +#define MEDIA_LOCAL_ID_MASK 
> > GENMASK(MEDIA_BITS_PER_LOCAL_ID - 1, 0)
> > +
> > +/* Structs to represent the objects that belong to a media graph */
> > +
> > +/**
> > + * struct media_gobj - Define a graph object.
> > + *
> > + * @id:Non-zero object ID identifier. The ID should be unique
> > + * inside a media_device, as it is composed by
> > + * MEDIA_BITS_PER_TYPE to store the type plus
> > + * MEDIA_BITS_PER_LOCAL_ID to store a per-type ID
> > + * (called as "local ID").
> > + *
> > + * All objects on the media graph should have this struct embedded
> > + */
> > +struct media_gobj {
> > +   u32 id;
> > +};
> > +
> > +
> 
> Two newlines. Looks like one would be enough. A minor matter though.

Ok, I'll be dropping the extra line.

> >  struct media_pipeline {
> >  };
> >  
> > @@ -118,6 +151,26 @@ static inline u32 media_entity_id(struct media_entity 
> > *entity)
> > return entity->id;
> >  }
> >  
> > +static inline enum media_gobj_type media_type(struct media_gobj *gobj)
> > +{
> > +   return gobj->id >> MEDIA_BITS_PER_LOCAL_ID;
> > +}
> > +
> > +static inline u32 media_localid(struct media_gobj *gobj)
> > +{
> > +   return gobj->id & MEDIA_LOCAL_ID_MASK;
> > +}
> > +
> > +static inline u32 media_gobj_gen_id(enum media_gobj_type type, u32 
> > local_id)
> > +{
> > +   u32 id;
> > +
> > +   id = type << MEDIA_BITS_PER_LOCAL_ID;
> > +   id |= local_id & MEDIA_LOCAL_ID_MASK;
> > +
> > +   return id;
> > +}
> > +
> >  #define MEDIA_ENTITY_ENUM_MAX_DEPTH16
> >  #define MEDIA_ENTITY_ENUM_MAX_ID   64
> >  
> > @@ -131,6 +184,14 @@ struct media_entity_graph {
> > int top;
> >  };
> >  
> > +#define gobj_to_entity(gobj) \
> > +   container_of(gobj, 

[PATCH 0/2] MC minor cleanups

2015-09-09 Thread Mauro Carvalho Chehab
This two patch series do some minor cleanups as suggested by Sakari.

Mauro Carvalho Chehab (2):
  [media] media_entity: remove gfp_flags argument
  [media] media-device: use unsigned ints on some places

 drivers/media/dvb-core/dvbdev.c| 3 +--
 drivers/media/media-device.c   | 7 ---
 drivers/media/media-entity.c   | 5 ++---
 drivers/media/v4l2-core/v4l2-dev.c | 3 +--
 include/media/media-entity.h   | 4 +---
 5 files changed, 9 insertions(+), 13 deletions(-)

-- 
2.4.3


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


[PATCH 2/2] [media] media-device: use unsigned ints on some places

2015-09-09 Thread Mauro Carvalho Chehab
The entity->num_pads are defined as u16. So, better to use an
unsigned int, as this prevents additional warnings when W=2
(or W=1 on some architectures).

The "i" counter at __media_device_get_topology() is also a
monotonic counter that should never be below zero. So,
make it unsigned too.

Suggested-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 13987710e5bc..1312e93ebd6e 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -243,7 +243,8 @@ static long __media_device_get_topology(struct media_device 
*mdev,
struct media_v2_interface uintf;
struct media_v2_pad upad;
struct media_v2_link ulink;
-   int ret = 0, i;
+   int ret = 0;
+   unsigned int i;
 
topo->topology_version = mdev->topology_version;
 
@@ -613,7 +614,7 @@ EXPORT_SYMBOL_GPL(media_device_unregister);
 int __must_check media_device_register_entity(struct media_device *mdev,
  struct media_entity *entity)
 {
-   int i;
+   unsigned int i;
 
if (entity->function == MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN ||
entity->function == MEDIA_ENT_F_UNKNOWN)
@@ -650,9 +651,9 @@ EXPORT_SYMBOL_GPL(media_device_register_entity);
  */
 void media_device_unregister_entity(struct media_entity *entity)
 {
-   int i;
struct media_device *mdev = entity->graph_obj.mdev;
struct media_link *link, *tmp;
+   unsigned int i;
 
if (mdev == NULL)
return;
-- 
2.4.3


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


[PATCH 1/2] [media] media_entity: remove gfp_flags argument

2015-09-09 Thread Mauro Carvalho Chehab
We should not be creating device nodes at IRQ contexts. So,
the only flags we'll be using will be GFP_KERNEL. Let's
remove the gfp_flags, in order to make the interface simpler.

If we ever need it, it would be easy to revert those changes.

While here, remove an extra blank line.

Suggested-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index e9f24c1479dd..60828a9537a0 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -379,8 +379,7 @@ static int dvb_register_media_device(struct dvb_device 
*dvbdev,
 
dvbdev->intf_devnode = media_devnode_create(dvbdev->adapter->mdev,
intf_type, 0,
-   DVB_MAJOR, minor,
-   GFP_KERNEL);
+   DVB_MAJOR, minor);
 
if (!dvbdev->intf_devnode)
return -ENOMEM;
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 4868b8269204..f28265864b76 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -887,12 +887,11 @@ static void media_interface_init(struct media_device 
*mdev,
 
 struct media_intf_devnode *media_devnode_create(struct media_device *mdev,
u32 type, u32 flags,
-   u32 major, u32 minor,
-   gfp_t gfp_flags)
+   u32 major, u32 minor)
 {
struct media_intf_devnode *devnode;
 
-   devnode = kzalloc(sizeof(*devnode), gfp_flags);
+   devnode = kzalloc(sizeof(*devnode), GFP_KERNEL);
if (!devnode)
return NULL;
 
diff --git a/drivers/media/v4l2-core/v4l2-dev.c 
b/drivers/media/v4l2-core/v4l2-dev.c
index 430aa2330d07..982255d2063f 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -777,8 +777,7 @@ static int video_register_media_controller(struct 
video_device *vdev, int type)
vdev->intf_devnode = media_devnode_create(vdev->v4l2_dev->mdev,
  intf_type,
  0, VIDEO_MAJOR,
- vdev->minor,
- GFP_KERNEL);
+ vdev->minor);
if (!vdev->intf_devnode) {
media_device_unregister_entity(>entity);
return -ENOMEM;
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 9cbb10079024..44ab153c37fc 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -71,7 +71,6 @@ struct media_gobj {
struct list_headlist;
 };
 
-
 struct media_pipeline {
 };
 
@@ -373,8 +372,7 @@ void media_entity_pipeline_stop(struct media_entity 
*entity);
 struct media_intf_devnode *
 __must_check media_devnode_create(struct media_device *mdev,
  u32 type, u32 flags,
- u32 major, u32 minor,
- gfp_t gfp_flags);
+ u32 major, u32 minor);
 void media_devnode_remove(struct media_intf_devnode *devnode);
 struct media_link *
 __must_check media_create_intf_link(struct media_entity *entity,
-- 
2.4.3


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


Re: [PATCH 1/2] [media] media_entity: remove gfp_flags argument

2015-09-09 Thread Hans Verkuil
On 09/09/15 13:32, Mauro Carvalho Chehab wrote:
> We should not be creating device nodes at IRQ contexts. So,
> the only flags we'll be using will be GFP_KERNEL. Let's
> remove the gfp_flags, in order to make the interface simpler.
> 
> If we ever need it, it would be easy to revert those changes.
> 
> While here, remove an extra blank line.
> 
> Suggested-by: Sakari Ailus 
> Signed-off-by: Mauro Carvalho Chehab 

Acked-by: Hans Verkuil 

> 
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index e9f24c1479dd..60828a9537a0 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -379,8 +379,7 @@ static int dvb_register_media_device(struct dvb_device 
> *dvbdev,
>  
>   dvbdev->intf_devnode = media_devnode_create(dvbdev->adapter->mdev,
>   intf_type, 0,
> - DVB_MAJOR, minor,
> - GFP_KERNEL);
> + DVB_MAJOR, minor);
>  
>   if (!dvbdev->intf_devnode)
>   return -ENOMEM;
> diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
> index 4868b8269204..f28265864b76 100644
> --- a/drivers/media/media-entity.c
> +++ b/drivers/media/media-entity.c
> @@ -887,12 +887,11 @@ static void media_interface_init(struct media_device 
> *mdev,
>  
>  struct media_intf_devnode *media_devnode_create(struct media_device *mdev,
>   u32 type, u32 flags,
> - u32 major, u32 minor,
> - gfp_t gfp_flags)
> + u32 major, u32 minor)
>  {
>   struct media_intf_devnode *devnode;
>  
> - devnode = kzalloc(sizeof(*devnode), gfp_flags);
> + devnode = kzalloc(sizeof(*devnode), GFP_KERNEL);
>   if (!devnode)
>   return NULL;
>  
> diff --git a/drivers/media/v4l2-core/v4l2-dev.c 
> b/drivers/media/v4l2-core/v4l2-dev.c
> index 430aa2330d07..982255d2063f 100644
> --- a/drivers/media/v4l2-core/v4l2-dev.c
> +++ b/drivers/media/v4l2-core/v4l2-dev.c
> @@ -777,8 +777,7 @@ static int video_register_media_controller(struct 
> video_device *vdev, int type)
>   vdev->intf_devnode = media_devnode_create(vdev->v4l2_dev->mdev,
> intf_type,
> 0, VIDEO_MAJOR,
> -   vdev->minor,
> -   GFP_KERNEL);
> +   vdev->minor);
>   if (!vdev->intf_devnode) {
>   media_device_unregister_entity(>entity);
>   return -ENOMEM;
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index 9cbb10079024..44ab153c37fc 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -71,7 +71,6 @@ struct media_gobj {
>   struct list_headlist;
>  };
>  
> -
>  struct media_pipeline {
>  };
>  
> @@ -373,8 +372,7 @@ void media_entity_pipeline_stop(struct media_entity 
> *entity);
>  struct media_intf_devnode *
>  __must_check media_devnode_create(struct media_device *mdev,
> u32 type, u32 flags,
> -   u32 major, u32 minor,
> -   gfp_t gfp_flags);
> +   u32 major, u32 minor);
>  void media_devnode_remove(struct media_intf_devnode *devnode);
>  struct media_link *
>  __must_check media_create_intf_link(struct media_entity *entity,
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8 18/55] [media] omap3isp: create links after all subdevs have been bound

2015-09-09 Thread Mauro Carvalho Chehab
Hi Sakari,

Em Wed, 09 Sep 2015 11:03:33 +0300
Sakari Ailus  escreveu:

> Hi Javier and Mauro,
> 
> On Sun, Aug 30, 2015 at 12:06:29AM -0300, Mauro Carvalho Chehab wrote:
> > From: Javier Martinez Canillas 
> > 
> > The omap3isp driver parses the graph endpoints to know how many subdevices
> > needs to be registered async and register notifiers callbacks for to know
> > when these are bound and when the async registrations are completed.
> > 
> > Currently the entities pad are linked with the correct ISP input interface
> > when the subdevs are bound but it happens before entitities are registered
> > with the media device so that won't work now that the entity links list is
> > initialized on device registration.
> > 
> > So instead creating the pad links when the subdevice is bound, create them
> > on the complete callback once all the subdevices have been bound but only
> > try to create for the ones that have a bus configuration set during bound.
> > 
> > Signed-off-by: Javier Martinez Canillas 
> > Signed-off-by: Mauro Carvalho Chehab 
> > 
> > diff --git a/drivers/media/platform/omap3isp/isp.c 
> > b/drivers/media/platform/omap3isp/isp.c
> > index b8f6f81d2db2..69e7733d36cd 100644
> > --- a/drivers/media/platform/omap3isp/isp.c
> > +++ b/drivers/media/platform/omap3isp/isp.c
> > @@ -2321,26 +2321,33 @@ static int isp_subdev_notifier_bound(struct 
> > v4l2_async_notifier *async,
> >  struct v4l2_subdev *subdev,
> >  struct v4l2_async_subdev *asd)
> >  {
> > -   struct isp_device *isp = container_of(async, struct isp_device,
> > - notifier);
> > struct isp_async_subdev *isd =
> > container_of(asd, struct isp_async_subdev, asd);
> > -   int ret;
> > -
> > -   ret = isp_link_entity(isp, >entity, isd->bus.interface);
> > -   if (ret < 0)
> > -   return ret;
> >  
> > isd->sd = subdev;
> > isd->sd->host_priv = >bus;
> >  
> > -   return ret;
> > +   return 0;
> >  }
> >  
> >  static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async)
> >  {
> > struct isp_device *isp = container_of(async, struct isp_device,
> >   notifier);
> > +   struct v4l2_device *v4l2_dev = >v4l2_dev;
> > +   struct v4l2_subdev *sd;
> > +   struct isp_bus_cfg *bus;
> > +   int ret;
> > +
> > +   list_for_each_entry(sd, _dev->subdevs, list) {
> > +   /* Only try to link entities whose interface was set on bound */
> > +   if (sd->host_priv) {
> > +   bus = (struct isp_bus_cfg *)sd->host_priv;
> > +   ret = isp_link_entity(isp, >entity, bus->interface);
> > +   if (ret < 0)
> > +   return ret;
> > +   }
> > +   }
> >  
> > return v4l2_device_register_subdev_nodes(>v4l2_dev);
> >  }
> 
> I think you're working around a problem here, not really fixing it.
> 
> This change will create the links only after the media device is registered,
> which means the user may obtain a partial enumeration of links if the
> enumeration is performed too early.
> 
> Before this set, the problem also was that the media device was registered
> before the async entities were bound, again making it possible to obtain a
> partial enumeration of entities.

Before of after this series, if userspace tries to read the topology too
early, it will get a partial topology. Before this series, it may lose
entities and links; after this series, it may lose any object.

In any case, userspace won't do the right thing, whatever order we
initialize.

The patches on this series is not meant to solve this issue.

The rationale for this patch is due to a different reason. You should 
notice that, due to the G_TOPOLOGY ioctl requirements, all objects
should have their ID assigned and should be added at the mdev linked
lists, as those are used by G_TOPOLOGY loops that copy the object
data to userspace.

So, before registering/creating any object, the media_device struct
need to exist internally at Kernelspace.

> 
> What I'd suggest instead is that we split media device initialisation and
> registration to the system; that way the media device can be prepared
> (entities registered and links created) before it becomes visible to the
> user space. I can write a patch for that if you like.

Yes, we can split the internal media register stuff from the
creation of the /dev/media0 device node, doing that only after
having everything set in Kernel, as the patch that Javier proposed
on IRC.

Another alternative would be to add a "busy" flag at media_device,
making all ioctl's at /dev/mdeia0 to return -EBUSY during massive
graph changes.

Such flag would be rised at media_device registration and dropped
at the end of the device probe routine.

The advantage of using such flags is that this could be 

[GIT PULL FOR v4.4] uvcvideo fixes

2015-09-09 Thread Laurent Pinchart
Hi Mauro,

The following changes since commit 50ef28a6ac216fd8b796257a3768fef8f57b917d:

  [media] c8sectpfe: Remove select on undefined LIBELF_32 (2015-09-03 14:10:06 
-0300)

are available in the git repository at:

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

for you to fetch changes up to 9f9720591c14a177764d169073264243e2bd50b3:

  uvcvideo: Disable hardware timestamps by default (2015-09-09 13:36:57 +0300)


Laurent Pinchart (1):
  uvcvideo: Disable hardware timestamps by default

 drivers/media/usb/uvc/uvc_driver.c | 3 +++
 drivers/media/usb/uvc/uvc_video.c  | 3 +++
 drivers/media/usb/uvc/uvcvideo.h   | 1 +
 3 files changed, 7 insertions(+)

-- 
Regards,

Laurent Pinchart

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


[RFC PATCH v4 6/8] [media] videobuf2: Replace v4l2-specific data with vb2 data.

2015-09-09 Thread Junghak Sung
enum v4l2_memory -> enum vb2_memory
VIDEO_MAX_FRAME -> VB2_MAX_FRAME
VIDEO_MAX_PLANES -> VB2_MAX_PLANES

Signed-off-by: Junghak Sung 
Signed-off-by: Geunyoung Kim 
Acked-by: Seung-Woo Kim 
Acked-by: Inki Dae 
---
 drivers/media/v4l2-core/videobuf2-core.c |   80 +++---
 include/media/videobuf2-core.h   |   29 +++
 include/trace/events/v4l2.h  |5 +-
 3 files changed, 64 insertions(+), 50 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index ebdb318..34e27d2 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -347,7 +347,7 @@ static void __setup_offsets(struct vb2_queue *q, unsigned 
int n)
  *
  * Returns the number of buffers successfully allocated.
  */
-static int __vb2_queue_alloc(struct vb2_queue *q, enum v4l2_memory memory,
+static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
 unsigned int num_buffers, unsigned int num_planes)
 {
unsigned int buffer;
@@ -370,7 +370,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum 
v4l2_memory memory,
vb->memory = memory;
 
/* Allocate video buffer memory for the MMAP type */
-   if (memory == V4L2_MEMORY_MMAP) {
+   if (memory == VB2_MEMORY_MMAP) {
ret = __vb2_buf_mem_alloc(vb);
if (ret) {
dprintk(1, "failed allocating memory for "
@@ -397,7 +397,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum 
v4l2_memory memory,
}
 
__setup_lengths(q, buffer);
-   if (memory == V4L2_MEMORY_MMAP)
+   if (memory == VB2_MEMORY_MMAP)
__setup_offsets(q, buffer);
 
dprintk(1, "allocated %d buffers, %d plane(s) each\n",
@@ -421,9 +421,9 @@ static void __vb2_free_mem(struct vb2_queue *q, unsigned 
int buffers)
continue;
 
/* Free MMAP buffers or release USERPTR buffers */
-   if (q->memory == V4L2_MEMORY_MMAP)
+   if (q->memory == VB2_MEMORY_MMAP)
__vb2_buf_mem_free(vb);
-   else if (q->memory == V4L2_MEMORY_DMABUF)
+   else if (q->memory == VB2_MEMORY_DMABUF)
__vb2_buf_dmabuf_put(vb);
else
__vb2_buf_userptr_put(vb);
@@ -562,7 +562,7 @@ static int __verify_planes_array(struct vb2_buffer *vb, 
const struct v4l2_buffer
return -EINVAL;
}
 
-   if (b->length < vb->num_planes || b->length > VIDEO_MAX_PLANES) {
+   if (b->length < vb->num_planes || b->length > VB2_MAX_PLANES) {
dprintk(1, "incorrect planes array length, "
   "expected %d, got %d\n", vb->num_planes, b->length);
return -EINVAL;
@@ -586,8 +586,8 @@ static int __verify_length(struct vb2_buffer *vb, const 
struct v4l2_buffer *b)
 
if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) {
for (plane = 0; plane < vb->num_planes; ++plane) {
-   length = (b->memory == V4L2_MEMORY_USERPTR ||
- b->memory == V4L2_MEMORY_DMABUF)
+   length = (b->memory == VB2_MEMORY_USERPTR ||
+ b->memory == VB2_MEMORY_DMABUF)
   ? b->m.planes[plane].length
: vb->planes[plane].length;
bytesused = b->m.planes[plane].bytesused
@@ -601,7 +601,7 @@ static int __verify_length(struct vb2_buffer *vb, const 
struct v4l2_buffer *b)
return -EINVAL;
}
} else {
-   length = (b->memory == V4L2_MEMORY_USERPTR)
+   length = (b->memory == VB2_MEMORY_USERPTR)
? b->length : vb->planes[0].length;
 
if (b->bytesused > length)
@@ -682,11 +682,11 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, 
struct v4l2_buffer *b)
 
pdst->bytesused = psrc->bytesused;
pdst->length = psrc->length;
-   if (q->memory == V4L2_MEMORY_MMAP)
+   if (q->memory == VB2_MEMORY_MMAP)
pdst->m.mem_offset = psrc->m.offset;
-   else if (q->memory == V4L2_MEMORY_USERPTR)
+   else if (q->memory == VB2_MEMORY_USERPTR)
pdst->m.userptr = psrc->m.userptr;
-   else if (q->memory == V4L2_MEMORY_DMABUF)
+   else if (q->memory == VB2_MEMORY_DMABUF)
pdst->m.fd = psrc->m.fd;
pdst->data_offset = psrc->data_offset;

[RFC PATCH v4 3/8] [media] videobuf2: Restructure vb2_buffer (2/3)

2015-09-09 Thread Junghak Sung
Modify all device drivers related with previous change that restructures
vb2_buffer for common use.

Signed-off-by: Junghak Sung 
Signed-off-by: Geunyoung Kim 
Acked-by: Seung-Woo Kim 
Acked-by: Inki Dae 
---
 drivers/input/touchscreen/sur40.c  |   17 
 drivers/media/dvb-frontends/rtl2832_sdr.c  |   21 +
 drivers/media/pci/cobalt/cobalt-driver.h   |6 ++-
 drivers/media/pci/cobalt/cobalt-irq.c  |7 +--
 drivers/media/pci/cobalt/cobalt-v4l2.c |   20 +
 drivers/media/pci/cx23885/cx23885-417.c|   11 +++--
 drivers/media/pci/cx23885/cx23885-core.c   |   24 +-
 drivers/media/pci/cx23885/cx23885-dvb.c|9 ++--
 drivers/media/pci/cx23885/cx23885-vbi.c|   16 ---
 drivers/media/pci/cx23885/cx23885-video.c  |   27 +++-
 drivers/media/pci/cx23885/cx23885.h|2 +-
 drivers/media/pci/cx25821/cx25821-video.c  |   21 +
 drivers/media/pci/cx25821/cx25821.h|3 +-
 drivers/media/pci/cx88/cx88-blackbird.c|   13 +++---
 drivers/media/pci/cx88/cx88-core.c |8 ++--
 drivers/media/pci/cx88/cx88-dvb.c  |   11 +++--
 drivers/media/pci/cx88/cx88-mpeg.c |   14 +++---
 drivers/media/pci/cx88/cx88-vbi.c  |   17 +---
 drivers/media/pci/cx88/cx88-video.c|   19 
 drivers/media/pci/cx88/cx88.h  |2 +-
 drivers/media/pci/dt3155/dt3155.c  |   17 
 drivers/media/pci/dt3155/dt3155.h  |3 +-
 drivers/media/pci/netup_unidvb/netup_unidvb_core.c |   19 
 drivers/media/pci/saa7134/saa7134-core.c   |   14 +++---
 drivers/media/pci/saa7134/saa7134-ts.c |   14 +++---
 drivers/media/pci/saa7134/saa7134-vbi.c|   10 +++--
 drivers/media/pci/saa7134/saa7134-video.c  |   21 +
 drivers/media/pci/saa7134/saa7134.h|2 +-
 drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c |   46 +++-
 drivers/media/pci/solo6x10/solo6x10-v4l2.c |   19 
 drivers/media/pci/solo6x10/solo6x10.h  |2 +-
 drivers/media/pci/sta2x11/sta2x11_vip.c|   12 ++---
 drivers/media/pci/tw68/tw68-video.c|   19 
 drivers/media/pci/tw68/tw68.h  |3 +-
 drivers/media/usb/airspy/airspy.c  |   24 +-
 drivers/media/usb/au0828/au0828-vbi.c  |7 +--
 drivers/media/usb/au0828/au0828-video.c|   45 ++-
 drivers/media/usb/au0828/au0828.h  |3 +-
 drivers/media/usb/em28xx/em28xx-vbi.c  |7 +--
 drivers/media/usb/em28xx/em28xx-video.c|   34 +--
 drivers/media/usb/em28xx/em28xx.h  |3 +-
 drivers/media/usb/go7007/go7007-driver.c   |   29 ++--
 drivers/media/usb/go7007/go7007-priv.h |2 +-
 drivers/media/usb/go7007/go7007-v4l2.c |   20 +
 drivers/media/usb/hackrf/hackrf.c  |   22 ++
 drivers/media/usb/msi2500/msi2500.c|   17 +---
 drivers/media/usb/pwc/pwc-if.c |   33 +-
 drivers/media/usb/pwc/pwc-uncompress.c |6 +--
 drivers/media/usb/pwc/pwc.h|4 +-
 drivers/media/usb/s2255/s2255drv.c |   27 +++-
 drivers/media/usb/stk1160/stk1160-v4l.c|   15 ---
 drivers/media/usb/stk1160/stk1160-video.c  |   12 ++---
 drivers/media/usb/stk1160/stk1160.h|2 +-
 drivers/media/usb/usbtv/usbtv-video.c  |   19 
 drivers/media/usb/usbtv/usbtv.h|3 +-
 drivers/media/usb/uvc/uvc_queue.c  |   26 ++-
 drivers/media/usb/uvc/uvc_video.c  |   20 -
 drivers/media/usb/uvc/uvcvideo.h   |4 +-
 drivers/media/v4l2-core/v4l2-mem2mem.c |8 ++--
 drivers/staging/media/davinci_vpfe/vpfe_video.c|   43 ++
 drivers/staging/media/davinci_vpfe/vpfe_video.h|3 +-
 drivers/staging/media/omap4iss/iss_video.c |   23 +-
 drivers/staging/media/omap4iss/iss_video.h |6 +--
 drivers/usb/gadget/function/uvc_queue.c|   26 ++-
 drivers/usb/gadget/function/uvc_queue.h|2 +-
 include/media/davinci/vpbe_display.h   |3 +-
 include/media/v4l2-mem2mem.h   |9 ++--
 include/trace/events/v4l2.h|   35 +++
 68 files changed, 576 insertions(+), 435 deletions(-)

diff --git a/drivers/input/touchscreen/sur40.c 
b/drivers/input/touchscreen/sur40.c
index 

[RFC PATCH v4 5/8] [media] videobuf2: Change queue_setup argument

2015-09-09 Thread Junghak Sung
Replace struct v4l2_format * with void * to make queue_setup()
for common use.
And then, modify all device drivers related with this change.

Signed-off-by: Junghak Sung 
Signed-off-by: Geunyoung Kim 
Acked-by: Seung-Woo Kim 
Acked-by: Inki Dae 
---
 Documentation/video4linux/v4l2-pci-skeleton.c  |4 +++-
 drivers/input/touchscreen/sur40.c  |3 ++-
 drivers/media/dvb-frontends/rtl2832_sdr.c  |2 +-
 drivers/media/pci/cobalt/cobalt-v4l2.c |4 ++--
 drivers/media/pci/cx23885/cx23885-417.c|2 +-
 drivers/media/pci/cx23885/cx23885-dvb.c|2 +-
 drivers/media/pci/cx23885/cx23885-vbi.c|2 +-
 drivers/media/pci/cx23885/cx23885-video.c  |2 +-
 drivers/media/pci/cx25821/cx25821-video.c  |3 ++-
 drivers/media/pci/cx88/cx88-blackbird.c|2 +-
 drivers/media/pci/cx88/cx88-dvb.c  |2 +-
 drivers/media/pci/cx88/cx88-vbi.c  |2 +-
 drivers/media/pci/cx88/cx88-video.c|2 +-
 drivers/media/pci/dt3155/dt3155.c  |3 ++-
 drivers/media/pci/netup_unidvb/netup_unidvb_core.c |2 +-
 drivers/media/pci/saa7134/saa7134-ts.c |2 +-
 drivers/media/pci/saa7134/saa7134-vbi.c|2 +-
 drivers/media/pci/saa7134/saa7134-video.c  |2 +-
 drivers/media/pci/saa7134/saa7134.h|2 +-
 drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c |2 +-
 drivers/media/pci/solo6x10/solo6x10-v4l2.c |2 +-
 drivers/media/pci/sta2x11/sta2x11_vip.c|2 +-
 drivers/media/pci/tw68/tw68-video.c|3 ++-
 drivers/media/platform/am437x/am437x-vpfe.c|3 ++-
 drivers/media/platform/blackfin/bfin_capture.c |3 ++-
 drivers/media/platform/coda/coda-common.c  |3 +--
 drivers/media/platform/davinci/vpbe_display.c  |3 ++-
 drivers/media/platform/davinci/vpif_capture.c  |3 ++-
 drivers/media/platform/davinci/vpif_display.c  |3 ++-
 drivers/media/platform/exynos-gsc/gsc-m2m.c|2 +-
 drivers/media/platform/exynos4-is/fimc-capture.c   |3 ++-
 drivers/media/platform/exynos4-is/fimc-isp-video.c |3 ++-
 drivers/media/platform/exynos4-is/fimc-lite.c  |3 ++-
 drivers/media/platform/exynos4-is/fimc-m2m.c   |2 +-
 drivers/media/platform/m2m-deinterlace.c   |2 +-
 drivers/media/platform/marvell-ccic/mcam-core.c|3 ++-
 drivers/media/platform/mx2_emmaprp.c   |2 +-
 drivers/media/platform/omap3isp/ispvideo.c |2 +-
 drivers/media/platform/rcar_jpu.c  |3 ++-
 drivers/media/platform/s3c-camif/camif-capture.c   |3 ++-
 drivers/media/platform/s5p-g2d/g2d.c   |2 +-
 drivers/media/platform/s5p-jpeg/jpeg-core.c|2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c   |2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c   |2 +-
 drivers/media/platform/s5p-tv/mixer_video.c|2 +-
 drivers/media/platform/sh_veu.c|3 ++-
 drivers/media/platform/sh_vou.c|3 ++-
 drivers/media/platform/soc_camera/atmel-isi.c  |2 +-
 drivers/media/platform/soc_camera/mx2_camera.c |3 ++-
 drivers/media/platform/soc_camera/mx3_camera.c |3 ++-
 drivers/media/platform/soc_camera/rcar_vin.c   |3 ++-
 .../platform/soc_camera/sh_mobile_ceu_camera.c |6 --
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c  |3 ++-
 drivers/media/platform/ti-vpe/vpe.c|2 +-
 drivers/media/platform/vim2m.c |3 ++-
 drivers/media/platform/vivid/vivid-sdr-cap.c   |2 +-
 drivers/media/platform/vivid/vivid-vbi-cap.c   |7 +++
 drivers/media/platform/vivid/vivid-vbi-out.c   |2 +-
 drivers/media/platform/vivid/vivid-vid-cap.c   |3 ++-
 drivers/media/platform/vivid/vivid-vid-out.c   |3 ++-
 drivers/media/platform/vsp1/vsp1_video.c   |3 ++-
 drivers/media/platform/xilinx/xilinx-dma.c |3 ++-
 drivers/media/usb/airspy/airspy.c  |2 +-
 drivers/media/usb/au0828/au0828-vbi.c  |3 ++-
 drivers/media/usb/au0828/au0828-video.c|3 ++-
 drivers/media/usb/em28xx/em28xx-vbi.c  |3 ++-
 drivers/media/usb/em28xx/em28xx-video.c|3 ++-
 drivers/media/usb/go7007/go7007-v4l2.c |2 +-
 drivers/media/usb/hackrf/hackrf.c  |2 +-
 drivers/media/usb/msi2500/msi2500.c|2 +-
 drivers/media/usb/pwc/pwc-if.c |2 +-
 drivers/media/usb/s2255/s2255drv.c |2 +-
 drivers/media/usb/stk1160/stk1160-v4l.c|2 +-
 drivers/media/usb/usbtv/usbtv-video.c  |3 ++-
 

[RFC PATCH v4 7/8] [media] videobuf2: Move v4l2-specific stuff to videobuf2-v4l2

2015-09-09 Thread Junghak Sung
Move v4l2-specific stuff from videobu2-core to videobuf2-v4l2
without doing any functional changes.

Signed-off-by: Junghak Sung 
Signed-off-by: Geunyoung Kim 
Acked-by: Seung-Woo Kim 
Acked-by: Inki Dae 
---
 drivers/media/v4l2-core/videobuf2-core.c | 1661 +-
 drivers/media/v4l2-core/videobuf2-internal.h |  173 +++
 drivers/media/v4l2-core/videobuf2-v4l2.c | 1489 +++
 include/media/videobuf2-core.h   |  113 +-
 include/media/videobuf2-v4l2.h   |  112 ++
 5 files changed, 1795 insertions(+), 1753 deletions(-)
 create mode 100644 drivers/media/v4l2-core/videobuf2-internal.h

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 34e27d2..3e6ee0e 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -32,158 +32,12 @@
 
 #include 
 
-static int debug;
-module_param(debug, int, 0644);
+#include "videobuf2-internal.h"
 
-#define dprintk(level, fmt, arg...)  \
-   do {  \
-   if (debug >= level)   \
-   pr_info("vb2: %s: " fmt, __func__, ## arg); \
-   } while (0)
+int vb2_debug;
+EXPORT_SYMBOL_GPL(vb2_debug);
+module_param_named(debug, vb2_debug, int, 0644);
 
-#ifdef CONFIG_VIDEO_ADV_DEBUG
-
-/*
- * If advanced debugging is on, then count how often each op is called
- * successfully, which can either be per-buffer or per-queue.
- *
- * This makes it easy to check that the 'init' and 'cleanup'
- * (and variations thereof) stay balanced.
- */
-
-#define log_memop(vb, op)  \
-   dprintk(2, "call_memop(%p, %d, %s)%s\n",\
-   (vb)->vb2_queue, (vb)->index, #op,  \
-   (vb)->vb2_queue->mem_ops->op ? "" : " (nop)")
-
-#define call_memop(vb, op, args...)\
-({ \
-   struct vb2_queue *_q = (vb)->vb2_queue; \
-   int err;\
-   \
-   log_memop(vb, op);  \
-   err = _q->mem_ops->op ? _q->mem_ops->op(args) : 0;  \
-   if (!err)   \
-   (vb)->cnt_mem_ ## op++; \
-   err;\
-})
-
-#define call_ptr_memop(vb, op, args...)
\
-({ \
-   struct vb2_queue *_q = (vb)->vb2_queue; \
-   void *ptr;  \
-   \
-   log_memop(vb, op);  \
-   ptr = _q->mem_ops->op ? _q->mem_ops->op(args) : NULL;   \
-   if (!IS_ERR_OR_NULL(ptr))   \
-   (vb)->cnt_mem_ ## op++; \
-   ptr;\
-})
-
-#define call_void_memop(vb, op, args...)   \
-({ \
-   struct vb2_queue *_q = (vb)->vb2_queue; \
-   \
-   log_memop(vb, op);  \
-   if (_q->mem_ops->op)\
-   _q->mem_ops->op(args);  \
-   (vb)->cnt_mem_ ## op++; \
-})
-
-#define log_qop(q, op) \
-   dprintk(2, "call_qop(%p, %s)%s\n", q, #op,  \
-   (q)->ops->op ? "" : " (nop)")
-
-#define call_qop(q, op, args...)   \
-({ \
-   int err;\
-   \
-   log_qop(q, op); \
-   err = (q)->ops->op ? (q)->ops->op(args) : 0;\
-   if (!err)   \
-   (q)->cnt_ ## op++;  \
-   

[RFC PATCH v4 8/8] [media] videobuf2: Remove v4l2-dependencies from videobuf2-core

2015-09-09 Thread Junghak Sung
Move v4l2-stuffs from videobuf2-core to videobuf2-v4l2. And make
wrappers that use the vb2_core_* functions.

Signed-off-by: Junghak Sung 
Signed-off-by: Geunyoung Kim 
Acked-by: Seung-Woo Kim 
Acked-by: Inki Dae 
---
 drivers/media/v4l2-core/videobuf2-core.c |  517 --
 drivers/media/v4l2-core/videobuf2-internal.h |   51 +--
 drivers/media/v4l2-core/videobuf2-v4l2.c |  312 
 include/media/videobuf2-core.h   |   20 +-
 include/media/videobuf2-v4l2.h   |3 +-
 5 files changed, 601 insertions(+), 302 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 3e6ee0e..56d34f2 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -24,20 +24,16 @@
 #include 
 #include 
 
-#include 
-#include 
-#include 
-#include 
-#include 
-
 #include 
 
+#include 
 #include "videobuf2-internal.h"
 
 int vb2_debug;
 EXPORT_SYMBOL_GPL(vb2_debug);
 module_param_named(debug, vb2_debug, int, 0644);
 
+static void __vb2_queue_cancel(struct vb2_queue *q);
 static void __enqueue_in_driver(struct vb2_buffer *vb);
 
 /**
@@ -47,7 +43,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
 {
struct vb2_queue *q = vb->vb2_queue;
enum dma_data_direction dma_dir =
-   V4L2_TYPE_IS_OUTPUT(q->type) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
+   q->is_output ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
void *mem_priv;
int plane;
 
@@ -289,7 +285,7 @@ static void __vb2_free_mem(struct vb2_queue *q, unsigned 
int buffers)
  * related information, if no buffers are left return the queue to an
  * uninitialized state. Might be called even if the queue has already been 
freed.
  */
-int __vb2_queue_free(struct vb2_queue *q, unsigned int buffers)
+static int __vb2_queue_free(struct vb2_queue *q, unsigned int buffers)
 {
unsigned int buffer;
 
@@ -401,35 +397,10 @@ int __vb2_queue_free(struct vb2_queue *q, unsigned int 
buffers)
 }
 
 /**
- * __verify_planes_array() - verify that the planes array passed in struct
- * v4l2_buffer from userspace can be safely used
- */
-int __verify_planes_array(struct vb2_buffer *vb, const struct v4l2_buffer *b)
-{
-   if (!V4L2_TYPE_IS_MULTIPLANAR(b->type))
-   return 0;
-
-   /* Is memory for copying plane information present? */
-   if (NULL == b->m.planes) {
-   dprintk(1, "multi-planar buffer passed but "
-  "planes array not provided\n");
-   return -EINVAL;
-   }
-
-   if (b->length < vb->num_planes || b->length > VB2_MAX_PLANES) {
-   dprintk(1, "incorrect planes array length, "
-  "expected %d, got %d\n", vb->num_planes, b->length);
-   return -EINVAL;
-   }
-
-   return 0;
-}
-
-/**
- * __buffer_in_use() - return true if the buffer is in use and
+ * vb2_buffer_in_use() - return true if the buffer is in use and
  * the queue cannot be freed (by the means of REQBUFS(0)) call
  */
-bool __buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb)
+bool vb2_buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb)
 {
unsigned int plane;
for (plane = 0; plane < vb->num_planes; ++plane) {
@@ -445,6 +416,7 @@ bool __buffer_in_use(struct vb2_queue *q, struct vb2_buffer 
*vb)
}
return false;
 }
+EXPORT_SYMBOL_GPL(vb2_buffer_in_use);
 
 /**
  * __buffers_in_use() - return true if any buffers on the queue are in use and
@@ -454,13 +426,34 @@ static bool __buffers_in_use(struct vb2_queue *q)
 {
unsigned int buffer;
for (buffer = 0; buffer < q->num_buffers; ++buffer) {
-   if (__buffer_in_use(q, q->bufs[buffer]))
+   if (vb2_buffer_in_use(q, q->bufs[buffer]))
return true;
}
return false;
 }
 
 /**
+ * vb2_core_querybuf() - query video buffer information
+ * @q: videobuf queue
+ * @index: id number of the buffer
+ * @pb:buffer struct passed from userspace
+ *
+ * Should be called from vidioc_querybuf ioctl handler in driver.
+ * The passed buffer should have been verified.
+ * This function fills the relevant information for the userspace.
+ *
+ * The return values from this function are intended to be directly returned
+ * from vidioc_querybuf handler in driver.
+ */
+int vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb)
+{
+   call_bufop(q, fill_user_buffer, q->bufs[index], pb);
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(vb2_core_querybuf);
+
+/**
  * __verify_userptr_ops() - verify that all memory operations required for
  * USERPTR queue type have been provided
  */
@@ -501,10 +494,10 @@ static int __verify_dmabuf_ops(struct vb2_queue *q)
 }
 
 /**
- * __verify_memory_type() - Check whether 

[RFC PATCH v4 0/8] Refactoring Videobuf2 for common use

2015-09-09 Thread Junghak Sung
Hello everybody,

This is the 4th round for refactoring Videobuf2(a.k.a VB2).
The purpose of this patch series is to separate existing VB2 framework
into core part and V4L2 specific part. So that not only V4L2 but also other
frameworks can use them to manage buffer and utilize queue.

Why do we try to make the VB2 framework to be common?

As you may know, current DVB framework uses ringbuffer mechanism to demux
MPEG-2 TS data and pass it to userspace. However, this mechanism requires
extra memory copy because DVB framework provides only read() system call for
application - read() system call copies the kernel data to user-space buffer.
So if we can use VB2 framework which supports streaming I/O and buffer
sharing mechanism, then we could enhance existing DVB framework by removing
the extra memory copy - with VB2 framework, application can access the kernel
data directly through mmap system call.

We have a plan for this work as follows:
1. Separate existing VB2 framework into three parts - VB2 common, VB2-v4l2.
   Of course, this change will not affect other v4l2-based
   device drivers. This patch series corresponds to this step.

2. Add and implement new APIs for DVB streaming I/O.
   We can remove unnecessary memory copy between kernel-space and user-space
   by using these new APIs. However, we leaves legacy interfaces as-is
   for backward compatibility.

This patch series is the first step for it.
The previous version of this patch series can be found at belows.

[1] RFC PATCH v1 - http://www.spinics.net/lists/linux-media/msg90688.html
[2] RFC PATCH v2 - http://www.spinics.net/lists/linux-media/msg92130.html
[3] RFC PATCH v3 - http://www.spinics.net/lists/linux-media/msg92953.html


Changes since v3

1. Resolve build errors
In previous patch set, the build errors prevented reviewers from applying
the patch. So, in this patch, I tryed to fix the build errors but I hadn't
the build test on all architectures except for x86 and ARM.

2. Modify descriptions for DocBook
Descriptions not complying with the DocBook rule are modified,
which was pointed out by Mauro.

3. Initialize reserved fields explicitly
The reserved fields of v4l2_buffer are initialized by 0 explicitly
when the vb2_buffer information is returned to userspace,
which was pointed out by Hans.

4. Remove unnecessary type-cast
According to Mauro's advice, the unnecessary type-cast are removed
because it's better for the compiler - rather than human - to check those
things.

5. Sperate the patch - not easy to review - into two patches
In previous patch set, patch 5 was too difficult to review. So accoring to
Hans' opinion, it separated the patch without any functional changes.


Changes since v2

1. Remove v4l2 stuffs completely from vb2_buffer
The v4l2 stuffs - v4l2_buf and v4l2_planes - are removed completely from
struct vb2_buffer. New member variables - index, type, memory - are added
to struct vb2_buffer, all of which can be used commonly. And bytesused,
length, offset, userptr, fd, data_offset are added to struct vb2_plane
for the same reason. So, we can manage video buffer by only using
struct vb2_buffer.
And, v4l2 stuffs - flags, field, timestamp, timecode, sequence - are defined
as member variables of struct vb2_v4l2_buffer.

2. Create new header file for VB2 internal use
videobuf2-internal.h is created, which is referred by videobuf2-core
and videobuf2-v4l2. The header file contains dprintk() for debug,
macro functions to invoke various callbacks, and vb2_core_* function prototypes
referred by inside of videobuf2.

3. Remove buffer-specific callbacks as much as possible
There were many callback functions to handle video buffer information
in previous patch series. In this patch series, I try to remove these callbacks
as much as possible without breaking the existing function flow.
As a result, only four callbacks are remained - fill_user_buffer(),
fill_vb2_buffer(), fill_vb2_timestamp() and is_last().

All ideas above are from Hans and it seems to be better and right way.


Changes since v1

1. Divide patch set into more pieces
v1 was not reviewed normally because the 2/3 patch is failed to send to mailing
list with size problem - over 300kb. So I have divided the patch set into five
pieces and refined them neatly, which was pointed by Hans.

2. Add shell scripts for renaming patch
In case of renaming patch, shell scripts are included inside the body of the
patches by Mauro's advice. 1/5 and 5/5 patches include these scripts, which can
be used by reviewers or maintainers to regenerate big patch file if something
goes wrong during patch apply.

3. Remove dependency on v4l2 from videobuf2
In previous patch set, videobuf2-core uses v4l2-specific stuff as it is.
e.g. enum v4l2_buf_type and enum v4l2_memory. That prevented other frameworks
from using videobuf2 independently and made them forced to include
v4l2-specific stuff.
In this version, these dependent stuffs are replaced with VB2 own stuffs.
e.g. enum vb2_buf_type and enum 

[RFC PATCH v4 1/8] [media] videobuf2: Replace videobuf2-core with videobuf2-v4l2

2015-09-09 Thread Junghak Sung
Make videobuf2-v4l2 as a wrapper of videobuf2-core for v4l2-use.
And replace videobuf2-core.h with videobuf2-v4l2.h.
This renaming change should be accompanied by the modifications
of all device drivers that include videobuf2-core.h.
It can be done with just running this shell script.

replace()
{
str1=$1
str2=$2
dir=$3
for file in $(find $dir -name *.h -o -name *.c -o -name Makefile)
do
echo $file
sed "s/$str1/$str2/g" $file > $file.out
mv $file.out $file
done
}

replace "videobuf2-core" "videobuf2-v4l2" "include/media/"
replace "videobuf2-core" "videobuf2-v4l2" "drivers/media/"
replace "videobuf2-core" "videobuf2-v4l2" "drivers/usb/gadget/"

Signed-off-by: Junghak Sung 
Signed-off-by: Geunyoung Kim 
Acked-by: Seung-Woo Kim 
Acked-by: Inki Dae 
---
 drivers/media/pci/solo6x10/solo6x10.h  |2 +-
 drivers/media/platform/coda/coda-bit.c |2 +-
 drivers/media/platform/coda/coda-common.c  |2 +-
 drivers/media/platform/coda/coda.h |2 +-
 drivers/media/platform/coda/trace.h|2 +-
 drivers/media/platform/exynos-gsc/gsc-core.h   |2 +-
 drivers/media/platform/exynos4-is/fimc-capture.c   |2 +-
 drivers/media/platform/exynos4-is/fimc-core.c  |2 +-
 drivers/media/platform/exynos4-is/fimc-core.h  |2 +-
 drivers/media/platform/exynos4-is/fimc-is.h|2 +-
 drivers/media/platform/exynos4-is/fimc-isp-video.c |2 +-
 drivers/media/platform/exynos4-is/fimc-isp-video.h |2 +-
 drivers/media/platform/exynos4-is/fimc-isp.h   |2 +-
 drivers/media/platform/exynos4-is/fimc-lite.c  |2 +-
 drivers/media/platform/exynos4-is/fimc-lite.h  |2 +-
 drivers/media/platform/exynos4-is/fimc-m2m.c   |2 +-
 drivers/media/platform/marvell-ccic/mcam-core.h|2 +-
 drivers/media/platform/omap3isp/ispvideo.h |2 +-
 drivers/media/platform/rcar_jpu.c  |2 +-
 drivers/media/platform/s3c-camif/camif-capture.c   |2 +-
 drivers/media/platform/s3c-camif/camif-core.c  |2 +-
 drivers/media/platform/s3c-camif/camif-core.h  |2 +-
 drivers/media/platform/s5p-g2d/g2d.c   |2 +-
 drivers/media/platform/s5p-jpeg/jpeg-core.c|2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc.c   |2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h|2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c   |2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c   |2 +-
 drivers/media/platform/s5p-tv/mixer.h  |2 +-
 drivers/media/platform/soc_camera/mx2_camera.c |2 +-
 drivers/media/platform/soc_camera/soc_camera.c |2 +-
 drivers/media/platform/ti-vpe/vpe.c|2 +-
 drivers/media/platform/vivid/vivid-core.h  |2 +-
 drivers/media/platform/vsp1/vsp1_video.c   |2 +-
 drivers/media/platform/vsp1/vsp1_video.h   |2 +-
 drivers/media/platform/xilinx/xilinx-dma.c |2 +-
 drivers/media/platform/xilinx/xilinx-dma.h |2 +-
 drivers/media/usb/go7007/go7007-priv.h |2 +-
 drivers/media/usb/stk1160/stk1160.h|2 +-
 drivers/media/usb/usbtv/usbtv-video.c  |2 +-
 drivers/media/usb/uvc/uvcvideo.h   |2 +-
 drivers/media/v4l2-core/Makefile   |2 +-
 drivers/media/v4l2-core/v4l2-ioctl.c   |2 +-
 drivers/media/v4l2-core/v4l2-mem2mem.c |2 +-
 drivers/media/v4l2-core/v4l2-trace.c   |2 +-
 drivers/media/v4l2-core/videobuf2-core.c   |   10 +++
 drivers/media/v4l2-core/videobuf2-v4l2.c   |   31 
 drivers/usb/gadget/function/uvc_queue.h|2 +-
 include/media/soc_camera.h |2 +-
 include/media/v4l2-mem2mem.h   |2 +-
 include/media/videobuf2-core.h |3 +-
 include/media/videobuf2-dvb.h  |2 +-
 include/media/videobuf2-v4l2.h |   17 +++
 53 files changed, 103 insertions(+), 56 deletions(-)
 create mode 100644 drivers/media/v4l2-core/videobuf2-v4l2.c
 create mode 100644 include/media/videobuf2-v4l2.h

diff --git a/drivers/media/pci/solo6x10/solo6x10.h 
b/drivers/media/pci/solo6x10/solo6x10.h
index 27423d7..5cc9e9d 100644
--- a/drivers/media/pci/solo6x10/solo6x10.h
+++ b/drivers/media/pci/solo6x10/solo6x10.h
@@ -35,7 +35,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include "solo6x10-regs.h"
 
diff --git a/drivers/media/platform/coda/coda-bit.c 
b/drivers/media/platform/coda/coda-bit.c
index fd7819d..cd41d49 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -25,7 +25,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
diff --git 

[RFC PATCH v4 2/8] [media] videobuf2: Restructure vb2_buffer (1/3)

2015-09-09 Thread Junghak Sung
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.

Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {

unsigned intbytesused;
unsigned intlength;
union {
unsigned intoffset;
unsigned long   userptr;
int fd;
} m;
unsigned intdata_offset;
}

Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {

unsigned intindex;
unsigned inttype;
unsigned intmemory;
unsigned intnum_planes;
struct vb2_planeplanes[VIDEO_MAX_PLANES];

};

v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer   vb2_buf;

__u32   flags;
__u32   field;
struct timeval  timestamp;
struct v4l2_timecodetimecode;
__u32   sequence;
};

This patch includes only changes inside of the videobuf2.
So, in practice, we need to fold this patch and following two patches
when merging upstream, to avoid breaking git bisectability.

Signed-off-by: Junghak Sung 
Signed-off-by: Geunyoung Kim 
Acked-by: Seung-Woo Kim 
Acked-by: Inki Dae 
---
 drivers/media/v4l2-core/videobuf2-core.c |  217 ++
 include/media/videobuf2-core.h   |   63 +
 include/media/videobuf2-v4l2.h   |   28 
 3 files changed, 198 insertions(+), 110 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index ab00ea0..ebdb318 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -53,7 +53,7 @@ module_param(debug, int, 0644);
 
 #define log_memop(vb, op)  \
dprintk(2, "call_memop(%p, %d, %s)%s\n",\
-   (vb)->vb2_queue, (vb)->v4l2_buf.index, #op, \
+   (vb)->vb2_queue, (vb)->index, #op,  \
(vb)->vb2_queue->mem_ops->op ? "" : " (nop)")
 
 #define call_memop(vb, op, args...)\
@@ -115,7 +115,7 @@ module_param(debug, int, 0644);
 
 #define log_vb_qop(vb, op, args...)\
dprintk(2, "call_vb_qop(%p, %d, %s)%s\n",   \
-   (vb)->vb2_queue, (vb)->v4l2_buf.index, #op, \
+   (vb)->vb2_queue, (vb)->index, #op,  \
(vb)->vb2_queue->ops->op ? "" : " (nop)")
 
 #define call_vb_qop(vb, op, args...)   \
@@ -211,7 +211,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
 
/* Associate allocator private data with this plane */
vb->planes[plane].mem_priv = mem_priv;
-   vb->v4l2_planes[plane].length = q->plane_sizes[plane];
+   vb->planes[plane].length = q->plane_sizes[plane];
}
 
return 0;
@@ -235,8 +235,7 @@ static void __vb2_buf_mem_free(struct vb2_buffer *vb)
for (plane = 0; plane < vb->num_planes; ++plane) {
call_void_memop(vb, put, vb->planes[plane].mem_priv);
vb->planes[plane].mem_priv = NULL;
-   dprintk(3, "freed plane %d of buffer %d\n", plane,
-   vb->v4l2_buf.index);
+   dprintk(3, "freed plane %d of buffer %d\n", plane, vb->index);
}
 }
 
@@ -269,7 +268,9 @@ static void __vb2_plane_dmabuf_put(struct vb2_buffer *vb, 
struct vb2_plane *p)
 
call_void_memop(vb, detach_dmabuf, p->mem_priv);
dma_buf_put(p->dbuf);
-   memset(p, 0, sizeof(*p));
+   p->mem_priv = NULL;
+   p->dbuf = NULL;
+   p->dbuf_mapped = 0;
 }
 
 /**
@@ -299,7 +300,7 @@ static void __setup_lengths(struct vb2_queue *q, unsigned 
int n)
continue;
 
for (plane = 0; plane < vb->num_planes; ++plane)
-   vb->v4l2_planes[plane].length = q->plane_sizes[plane];
+   vb->planes[plane].length = q->plane_sizes[plane];
}
 }
 
@@ -314,10 +315,10 @@ static void __setup_offsets(struct vb2_queue *q, unsigned 
int n)
unsigned long off;
 
if (q->num_buffers) {
-   struct v4l2_plane *p;
+   struct vb2_plane *p;
vb = q->bufs[q->num_buffers - 1];
-   p = >v4l2_planes[vb->num_planes - 1];
-   off = PAGE_ALIGN(p->m.mem_offset + 

Re: [RFC 00/11] vb2: Handle user cache hints, allow drivers to choose cache coherency

2015-09-09 Thread Laurent Pinchart
+ Sumit, Rob, Laura and Daniel who have discussed cache optimization with me 
at LPC in the context of dmabuf.

The full patch set can be found at 
https://www.mail-archive.com/linux-media@vger.kernel.org/msg92120.html

On Tuesday 08 September 2015 13:33:44 Sakari Ailus wrote:
> Hi folks,
> 
> This RFC patchset achieves two main objectives:
> 
> 1. Respects cache flags passed from the user space. As no driver nor
> videobuf2 has (ever?) implemented them, the two flags are replaced by a
> single one (V4L2_BUF_FLAG_NO_CACHE_SYNC) and the two old flags are
> deprecated. This is done since a single flag provides the driver with
> enough information on what to do. (See more info in patch 4.)
> 
> 2. Allows a driver using videobuf2 dma-contig memory type to choose
> whether it prefers coherent or non-coherent CPU access to buffer memory
> for MMAP and USERPTR buffers. This could be later extended to be specified
> by the user, and per buffer if needed.
> 
> Only dma-contig memory type is changed but the same could be done to
> dma-sg as well. I can add it to the set if people are happy with the
> changes to dma-contig.

-- 
Regards,

Laurent Pinchart

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


Re: [PATCH v1] media: uvcvideo: handle urb completion in a work queue

2015-09-09 Thread Alan Stern
On Wed, 9 Sep 2015, Laurent Pinchart wrote:

> On Wednesday 09 September 2015 10:30:12 Hans de Goede wrote:
> > On 08-09-15 16:36, Alan Stern wrote:
> > > On Tue, 8 Sep 2015, Hans de Goede wrote:
> > >> On 09/07/2015 06:23 PM, Mian Yousaf Kaukab wrote:
> > >>> urb completion callback is executed in host controllers interrupt
> > >>> context. To keep preempt disable time short, add urbs to a list on
> > >>> completion and schedule work to process the list.
> > >>> 
> > >>> Moreover, save timestamp and sof number in the urb completion callback
> > >>> to avoid any delays.
> > >> 
> > >> Erm, I thought that we had already moved to using threaded interrupt
> > >> handling for the urb completion a while (1-2 years ?) back. Is this then
> > >> still needed ?
> > > 
> > > We moved to handling URB completions in a tasklet, not a threaded
> > > handler.
> > 
> > Right.
> > 
> > > (Similar idea, though.)  And the change was made in only one
> > > or two HCDs, not in all of them.
> > 
> > Ah, I was under the impression this was a core change, not a per
> > hcd change.
> 
> Instead of fixing the issue in the uvcvideo driver, would it then make more 
> sense to fix it in the remaining hcd drivers ?

Unfortunately that's not so easy.  It involves some subtle changes 
related to the way isochronous endpoints are handled.  I wouldn't know 
what to change in any of the HCDs, except the ones that I maintain.

Alan Stern

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


Re: [PATCH v1] media: uvcvideo: handle urb completion in a work queue

2015-09-09 Thread Laurent Pinchart
Hi Alan,

On Wednesday 09 September 2015 11:14:38 Alan Stern wrote:
> On Wed, 9 Sep 2015, Laurent Pinchart wrote:
> > On Wednesday 09 September 2015 10:30:12 Hans de Goede wrote:
> >> On 08-09-15 16:36, Alan Stern wrote:
> >>> On Tue, 8 Sep 2015, Hans de Goede wrote:
>  On 09/07/2015 06:23 PM, Mian Yousaf Kaukab wrote:
> > urb completion callback is executed in host controllers interrupt
> > context. To keep preempt disable time short, add urbs to a list on
> > completion and schedule work to process the list.
> > 
> > Moreover, save timestamp and sof number in the urb completion
> > callback to avoid any delays.
>  
>  Erm, I thought that we had already moved to using threaded interrupt
>  handling for the urb completion a while (1-2 years ?) back. Is this
>  then still needed ?
> >>> 
> >>> We moved to handling URB completions in a tasklet, not a threaded
> >>> handler.
> >> 
> >> Right.
> >> 
> >>> (Similar idea, though.)  And the change was made in only one
> >>> or two HCDs, not in all of them.
> >> 
> >> Ah, I was under the impression this was a core change, not a per
> >> hcd change.
> > 
> > Instead of fixing the issue in the uvcvideo driver, would it then make
> > more sense to fix it in the remaining hcd drivers ?
> 
> Unfortunately that's not so easy.  It involves some subtle changes
> related to the way isochronous endpoints are handled.  I wouldn't know
> what to change in any of the HCDs, except the ones that I maintain.

I'm not saying it would be easy, but I'm wondering whether it makes change to 
move individual USB device drivers to work queues when the long term goal is 
to use tasklets for URB completion anyway.

-- 
Regards,

Laurent Pinchart

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


Re: [PATCH v1] media: uvcvideo: handle urb completion in a work queue

2015-09-09 Thread Alan Stern
On Wed, 9 Sep 2015, Laurent Pinchart wrote:

> > > Instead of fixing the issue in the uvcvideo driver, would it then make
> > > more sense to fix it in the remaining hcd drivers ?
> > 
> > Unfortunately that's not so easy.  It involves some subtle changes
> > related to the way isochronous endpoints are handled.  I wouldn't know
> > what to change in any of the HCDs, except the ones that I maintain.
> 
> I'm not saying it would be easy, but I'm wondering whether it makes change to 
> move individual USB device drivers to work queues when the long term goal is 
> to use tasklets for URB completion anyway.

I'm not sure that this is a long-term goal for every HCD.  For
instance, there probably isn't much incentive to convert a driver if
its host controllers can only run at low speed or full speed.

Alan Stern

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


Re: [PATCH v1] media: uvcvideo: handle urb completion in a work queue

2015-09-09 Thread Alan Stern
On Wed, 9 Sep 2015, Hans de Goede wrote:

> Hi,
> 
> On 08-09-15 16:36, Alan Stern wrote:
> > On Tue, 8 Sep 2015, Hans de Goede wrote:
> >
> >> Hi,
> >>
> >> On 09/07/2015 06:23 PM, Mian Yousaf Kaukab wrote:
> >>> urb completion callback is executed in host controllers interrupt
> >>> context. To keep preempt disable time short, add urbs to a list on
> >>> completion and schedule work to process the list.
> >>>
> >>> Moreover, save timestamp and sof number in the urb completion callback
> >>> to avoid any delays.
> >>
> >> Erm, I thought that we had already moved to using threaded interrupt
> >> handling for the urb completion a while (1-2 years ?) back. Is this then
> >> still needed ?
> >
> > We moved to handling URB completions in a tasklet, not a threaded
> > handler.
> 
> Right.
> 
> > (Similar idea, though.)  And the change was made in only one
> > or two HCDs, not in all of them.
> 
> Ah, I was under the impression this was a core change, not a per
> hcd change.

In fact, both the core and the HCD needed to be changed.  For example,
see commits 94dfd7edfd5c (core) and 9118f9eb4f1e (ehci-hcd).  (There
was more to it than just those two commits, of course.)

In one respect the change still isn't complete: Since the completion
callback occurs in a tasklet, we should allow interrupts to remain
enabled while the callback runs.  But some class drivers still expect
interrupts to be disabled at that time, so the core has to disable
interrupts before invoking the callback and then re-enable them
afterward.

There was a proposal to fix up a number of drivers so that we could 
leave interrupts enabled the whole time.  But I don't think it ever got 
merged.

Alan Stern

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


Contact Us For Unsecured Guaranteed Loans Today!!!?

2015-09-09 Thread Guaranteed
Do you need a genuine Loan to settle your bills and start up a good
business? Kindly contact us now with your details to get a good
Loan at a low rate of 3% per Annu, Quick send your details via:
guarloa...@gmail.com
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


cron job: media_tree daily build: OK

2015-09-09 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 Sep 10 04:00:23 CEST 2015
git branch: test
git hash:   50ef28a6ac216fd8b796257a3768fef8f57b917d
gcc version:i686-linux-gcc (GCC) 5.1.0
sparse version: v0.5.0-51-ga53cea2
smatch version: 0.4.1-3153-g7d56ab3
host hardware:  x86_64
host os:4.0.0-3.slh.1-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: OK
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin-bf561: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.32.27-i686: OK
linux-2.6.33.7-i686: OK
linux-2.6.34.7-i686: OK
linux-2.6.35.9-i686: OK
linux-2.6.36.4-i686: OK
linux-2.6.37.6-i686: OK
linux-2.6.38.8-i686: OK
linux-2.6.39.4-i686: OK
linux-3.0.60-i686: OK
linux-3.1.10-i686: OK
linux-3.2.37-i686: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: OK
linux-3.5.7-i686: OK
linux-3.6.11-i686: OK
linux-3.7.4-i686: OK
linux-3.8-i686: OK
linux-3.9.2-i686: OK
linux-3.10.1-i686: OK
linux-3.11.1-i686: OK
linux-3.12.23-i686: OK
linux-3.13.11-i686: OK
linux-3.14.9-i686: OK
linux-3.15.2-i686: OK
linux-3.16.7-i686: OK
linux-3.17.8-i686: OK
linux-3.18.7-i686: OK
linux-3.19-i686: OK
linux-4.0-i686: OK
linux-4.1.1-i686: OK
linux-4.2-i686: OK
linux-2.6.32.27-x86_64: OK
linux-2.6.33.7-x86_64: OK
linux-2.6.34.7-x86_64: OK
linux-2.6.35.9-x86_64: OK
linux-2.6.36.4-x86_64: OK
linux-2.6.37.6-x86_64: OK
linux-2.6.38.8-x86_64: OK
linux-2.6.39.4-x86_64: OK
linux-3.0.60-x86_64: OK
linux-3.1.10-x86_64: OK
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-x86_64: OK
linux-3.7.4-x86_64: OK
linux-3.8-x86_64: OK
linux-3.9.2-x86_64: OK
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: OK
linux-3.12.23-x86_64: OK
linux-3.13.11-x86_64: OK
linux-3.14.9-x86_64: OK
linux-3.15.2-x86_64: OK
linux-3.16.7-x86_64: OK
linux-3.17.8-x86_64: OK
linux-3.18.7-x86_64: OK
linux-3.19-x86_64: OK
linux-4.0-x86_64: OK
linux-4.1.1-x86_64: OK
linux-4.2-x86_64: OK
apps: OK
spec-git: OK
sparse: WARNINGS
smatch: ERRORS

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


Purchasing/Infrared lamp therapy products/Aukewel Co., ltd

2015-09-09 Thread Woody Wu
Dear Client,

Have a good day!
Glad to learn you're on the market of Infrared Lamp products

We are the manufacture at family use electronic health devices since 2000.
We keep good quality and reliable cooperation for global valued customers. 

Main products include infrared lamp.

If any product meet your demand, please contact us. 
Any of your question will be replied prompt.


Best regards.

Woody 
WooN�Р骒r��yb�X�肚�v�^�)藓{.n�+�伐�{���bj)��骅w*jg�报�茛j/�赇z罐���2���ㄨ��&�)摺�a囤���G���h��j:+v���w��佶

[PATCH] rc: gpio-ir-recv: allow flush space on idle

2015-09-09 Thread Eric Nelson
Many decoders require a trailing space (period without IR illumination)
to be delivered before completing a decode.

Since the gpio-ir-recv driver only delivers events on gpio transitions,
a single IR symbol (caused by a quick touch on an IR remote) will not
be properly decoded without the use of a timer to flush the tail end
state of the IR receiver.

This patch adds an optional device tree node "flush-ms" which, if
present, will use a jiffie-based timer to complete the last pulse
stream and allow decode.

The "flush-ms" value should be chosen with a value that will convert
well to jiffies (multiples of 10 are good).

Signed-off-by: Eric Nelson 
---
 .../devicetree/bindings/media/gpio-ir-receiver.txt |  1 +
 drivers/media/rc/gpio-ir-recv.c| 39 ++
 include/media/gpio-ir-recv.h   |  1 +
 3 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/gpio-ir-receiver.txt 
b/Documentation/devicetree/bindings/media/gpio-ir-receiver.txt
index 56e726e..13ff92d 100644
--- a/Documentation/devicetree/bindings/media/gpio-ir-receiver.txt
+++ b/Documentation/devicetree/bindings/media/gpio-ir-receiver.txt
@@ -6,6 +6,7 @@ Required properties:
 
 Optional properties:
- linux,rc-map-name: Linux specific remote control map name.
+   - flush-ms: time for final flush of 'space' pulse (period with no IR)
 
 Example node:
 
diff --git a/drivers/media/rc/gpio-ir-recv.c b/drivers/media/rc/gpio-ir-recv.c
index 7dbc9ca..e3c353e 100644
--- a/drivers/media/rc/gpio-ir-recv.c
+++ b/drivers/media/rc/gpio-ir-recv.c
@@ -29,7 +29,9 @@
 struct gpio_rc_dev {
struct rc_dev *rcdev;
int gpio_nr;
+   int flush_jiffies;
bool active_low;
+   struct timer_list flush_timer;
 };
 
 #ifdef CONFIG_OF
@@ -42,6 +44,7 @@ static int gpio_ir_recv_get_devtree_pdata(struct device *dev,
struct device_node *np = dev->of_node;
enum of_gpio_flags flags;
int gpio;
+   u32 flush_ms = 0;
 
gpio = of_get_gpio_flags(np, 0, );
if (gpio < 0) {
@@ -50,6 +53,9 @@ static int gpio_ir_recv_get_devtree_pdata(struct device *dev,
return gpio;
}
 
+   of_property_read_u32(np, "flush-ms", _ms);
+   pdata->flush_jiffies = msecs_to_jiffies(flush_ms);
+
pdata->gpio_nr = gpio;
pdata->active_low = (flags & OF_GPIO_ACTIVE_LOW);
/* probe() takes care of map_name == NULL or allowed_protos == 0 */
@@ -71,9 +77,8 @@ MODULE_DEVICE_TABLE(of, gpio_ir_recv_of_match);
 
 #endif
 
-static irqreturn_t gpio_ir_recv_irq(int irq, void *dev_id)
+static void flush_gp(struct gpio_rc_dev *gpio_dev)
 {
-   struct gpio_rc_dev *gpio_dev = dev_id;
int gval;
int rc = 0;
enum raw_event_type type = IR_SPACE;
@@ -81,7 +86,7 @@ static irqreturn_t gpio_ir_recv_irq(int irq, void *dev_id)
gval = gpio_get_value(gpio_dev->gpio_nr);
 
if (gval < 0)
-   goto err_get_value;
+   return;
 
if (gpio_dev->active_low)
gval = !gval;
@@ -90,15 +95,30 @@ static irqreturn_t gpio_ir_recv_irq(int irq, void *dev_id)
type = IR_PULSE;
 
rc = ir_raw_event_store_edge(gpio_dev->rcdev, type);
-   if (rc < 0)
-   goto err_get_value;
+   if (rc >= 0)
+   ir_raw_event_handle(gpio_dev->rcdev);
+}
 
-   ir_raw_event_handle(gpio_dev->rcdev);
+static irqreturn_t gpio_ir_recv_irq(int irq, void *dev_id)
+{
+   struct gpio_rc_dev *gpio_dev = dev_id;
+
+   flush_gp(gpio_dev);
+
+   if (gpio_dev->flush_jiffies)
+   mod_timer(_dev->flush_timer,
+ jiffies + gpio_dev->flush_jiffies);
 
-err_get_value:
return IRQ_HANDLED;
 }
 
+static void flush_timer(unsigned long arg)
+{
+   struct gpio_rc_dev *gpio_dev = (struct gpio_rc_dev *)arg;
+
+   flush_gp(gpio_dev);
+}
+
 static int gpio_ir_recv_probe(struct platform_device *pdev)
 {
struct gpio_rc_dev *gpio_dev;
@@ -152,8 +172,13 @@ static int gpio_ir_recv_probe(struct platform_device *pdev)
 
gpio_dev->rcdev = rcdev;
gpio_dev->gpio_nr = pdata->gpio_nr;
+   gpio_dev->flush_jiffies = pdata->flush_jiffies;
gpio_dev->active_low = pdata->active_low;
 
+   init_timer(_dev->flush_timer);
+   gpio_dev->flush_timer.function = flush_timer;
+   gpio_dev->flush_timer.data = (unsigned long)gpio_dev;
+
rc = gpio_request(pdata->gpio_nr, "gpio-ir-recv");
if (rc < 0)
goto err_gpio_request;
diff --git a/include/media/gpio-ir-recv.h b/include/media/gpio-ir-recv.h
index 0142736..88fae78 100644
--- a/include/media/gpio-ir-recv.h
+++ b/include/media/gpio-ir-recv.h
@@ -17,6 +17,7 @@ struct gpio_ir_recv_platform_data {
int gpio_nr;
boolactive_low;
u64 allowed_protos;
+   int flush_jiffies;
const char