Re: [PATCH 1/2] [media] media-device: get rid of the spinlock

2016-04-15 Thread Hans Verkuil
On 04/06/2016 03:55 PM, Mauro Carvalho Chehab wrote:
> Right now, the lock schema for media_device struct is messy,
> since sometimes, it is protected via a spin lock, while, for
> media graph traversal, it is protected by a mutex.
> 
> Solve this conflict by always using a mutex.
> 
> As a side effect, this prevents a bug when the media notifiers
> is called at atomic context, while running the notifier callback:
> 
>  BUG: sleeping function called from invalid context at mm/slub.c:1289
>  in_atomic(): 1, irqs_disabled(): 0, pid: 3479, name: modprobe
>  4 locks held by modprobe/3479:
>  #0:  (&dev->mutex){..}, at: [] 
> __driver_attach+0xa3/0x160
>  #1:  (&dev->mutex){..}, at: [] 
> __driver_attach+0xb1/0x160
>  #2:  (register_mutex#5){+.+.+.}, at: [] 
> usb_audio_probe+0x257/0x1c90 [snd_usb_audio]
>  #3:  (&(&mdev->lock)->rlock){+.+.+.}, at: [] 
> media_device_register_entity+0x1cb/0x700 [media]
>  CPU: 2 PID: 3479 Comm: modprobe Not tainted 4.5.0-rc3+ #49
>  Hardware name:  /NUC5i7RYB, BIOS 
> RYBDWi35.86A.0350.2015.0812.1722 08/12/2015
>   8803b3f6f288 81933901 8803c4bae000
>  8803c4bae5c8 8803b3f6f2b0 811c6af5 8803c4bae000
>  8285d7f6 0509 8803b3f6f2f0 811c6ce5
>  Call Trace:
>  [] dump_stack+0x85/0xc4
>  [] ___might_sleep+0x245/0x3a0
>  [] __might_sleep+0x95/0x1a0
>  [] kmem_cache_alloc_trace+0x20e/0x300
>  [] ? media_add_link+0x4d/0x140 [media]
>  [] media_add_link+0x4d/0x140 [media]
>  [] media_create_pad_link+0xa1/0x600 [media]
>  [] au0828_media_graph_notify+0x173/0x360 [au0828]
>  [] ? media_gobj_create+0x1ba/0x480 [media]
>  [] media_device_register_entity+0x3ab/0x700 [media]
> 
> Reviewed-by: Javier Martinez Canillas 
> Acked-by: Sakari Ailus 
> Signed-off-by: Mauro Carvalho Chehab 

Acked-by: Hans Verkuil 

Regards,

Hans

> ---
>  drivers/media/media-device.c | 39 +--
>  drivers/media/media-entity.c | 16 
>  include/media/media-device.h |  6 +-
>  3 files changed, 22 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> index 6e43c95629ea..898a3cf814ba 100644
> --- a/drivers/media/media-device.c
> +++ b/drivers/media/media-device.c
> @@ -90,18 +90,13 @@ static struct media_entity *find_entity(struct 
> media_device *mdev, u32 id)
>  
>   id &= ~MEDIA_ENT_ID_FLAG_NEXT;
>  
> - spin_lock(&mdev->lock);
> -
>   media_device_for_each_entity(entity, mdev) {
>   if (((media_entity_id(entity) == id) && !next) ||
>   ((media_entity_id(entity) > id) && next)) {
> - spin_unlock(&mdev->lock);
>   return entity;
>   }
>   }
>  
> - spin_unlock(&mdev->lock);
> -
>   return NULL;
>  }
>  
> @@ -431,6 +426,7 @@ static long media_device_ioctl(struct file *filp, 
> unsigned int cmd,
>   struct media_device *dev = to_media_device(devnode);
>   long ret;
>  
> + mutex_lock(&dev->graph_mutex);
>   switch (cmd) {
>   case MEDIA_IOC_DEVICE_INFO:
>   ret = media_device_get_info(dev,
> @@ -443,29 +439,24 @@ static long media_device_ioctl(struct file *filp, 
> unsigned int cmd,
>   break;
>  
>   case MEDIA_IOC_ENUM_LINKS:
> - mutex_lock(&dev->graph_mutex);
>   ret = media_device_enum_links(dev,
>   (struct media_links_enum __user *)arg);
> - mutex_unlock(&dev->graph_mutex);
>   break;
>  
>   case MEDIA_IOC_SETUP_LINK:
> - mutex_lock(&dev->graph_mutex);
>   ret = media_device_setup_link(dev,
>   (struct media_link_desc __user *)arg);
> - mutex_unlock(&dev->graph_mutex);
>   break;
>  
>   case MEDIA_IOC_G_TOPOLOGY:
> - mutex_lock(&dev->graph_mutex);
>   ret = media_device_get_topology(dev,
>   (struct media_v2_topology __user *)arg);
> - mutex_unlock(&dev->graph_mutex);
>   break;
>  
>   default:
>   ret = -ENOIOCTLCMD;
>   }
> + mutex_unlock(&dev->graph_mutex);
>  
>   return ret;
>  }
> @@ -590,12 +581,12 @@ int __must_check media_device_register_entity(struct 
> media_device *mdev,
>   if (!ida_pre_get(&mdev->entity_internal_idx, GFP_KERNEL))
>   return -ENOMEM;
>  
> - spin_lock(&mdev->lock);
> + mutex_lock(&mdev->graph_mutex);
>  
>   ret = ida_get_new_above(&mdev->entity_internal_idx, 1,
>   &entity->internal_idx);
>   if (ret < 0) {
> - spin_unlock(&mdev->lock);
> + mutex_unlock(&mdev->graph_mutex);
>   return ret;
>   }
>  
> @@ -615,9 +606,6 @@ int __must_check media_device_register_entity(struct 
> media_device *mdev,
>   (notify)->notify(entity, notify->notify_d

Re: [PATCH 2/2] [media] media: Improve documentation for link_setup/link_modify

2016-04-15 Thread Hans Verkuil
On 04/06/2016 03:55 PM, Mauro Carvalho Chehab wrote:
> Those callbacks are called with the media_device.graph_mutex hold.
> 
> Add a note about that, as the code called by those notifiers should
> not be touching in the mutex.
> 
> Signed-off-by: Mauro Carvalho Chehab 
> Acked-by: Sakari Ailus 

Acked-by: Hans Verkuil 

Regards,

Hans

> ---
>  include/media/media-device.h | 3 ++-
>  include/media/media-entity.h | 3 +++
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/include/media/media-device.h b/include/media/media-device.h
> index b21ef244ad3e..44563ec17d45 100644
> --- a/include/media/media-device.h
> +++ b/include/media/media-device.h
> @@ -311,7 +311,8 @@ struct media_entity_notify {
>   * @enable_source: Enable Source Handler function pointer
>   * @disable_source: Disable Source Handler function pointer
>   *
> - * @link_notify: Link state change notification callback
> + * @link_notify: Link state change notification callback. This callback is
> + * Called with the graph_mutex hold.
>   *
>   * This structure represents an abstract high-level media device. It allows 
> easy
>   * access to entities and provides basic media device-level support. The
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index 6dc9e4e8cbd4..0b16ebe36db7 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -179,6 +179,9 @@ struct media_pad {
>   * @link_validate:   Return whether a link is valid from the entity point of
>   *   view. The media_entity_pipeline_start() function
>   *   validates all links by calling this operation. Optional.
> + *
> + * Note: Those ioctls should not touch the struct media_device.@graph_mutex
> + * field, as they're called with it already hold.
>   */
>  struct media_entity_operations {
>   int (*link_setup)(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: Backport a Security Fix for CVE-2015-7833 to v4.1

2016-04-15 Thread Yuki Machida

Hi Vladis,

> I apologize for intercepting, but I believe commit 588afcc1 should
> not be accepted and reverted in the trees where it was.
>
> Reasons:
>
> https://patchwork.linuxtv.org/patch/32798/
> or
> https://www.spinics.net/lists/linux-media/msg96936.html
Thank you for your reply.

If it revert commit 588afcc1 from the kernel,
It exists a Security Issue of CVE-2015-7833.
What do you think about it?

Best regards,
Yuki Machida

On 2016年04月11日 21:03, Vladis Dronov wrote:

Hello,

I apologize for intercepting, but I believe commit 588afcc1 should
not be accepted and reverted in the trees where it was.

Reasons:

https://patchwork.linuxtv.org/patch/32798/
or
https://www.spinics.net/lists/linux-media/msg96936.html


Best regards,
Vladis Dronov | Red Hat, Inc. | Product Security Engineer

- Original Message -
From: "Yuki Machida" 
To: "sasha levin" 
Cc: linux-media@vger.kernel.org, sta...@vger.kernel.org, hverk...@xs4all.nl, 
oneu...@suse.com, vdro...@redhat.com, mche...@osg.samsung.com, 
r...@spenneberg.net
Sent: Monday, April 11, 2016 7:19:34 AM
Subject: Backport a Security Fix for CVE-2015-7833 to v4.1

Hi Sasha,

I conformed that these patches for CVE-2015-7833 not applied at v4.1.21.
588afcc1c0e45358159090d95bf7b246fb67565
fa52bd506f274b7619955917abfde355e3d19ff
Could you please apply this CVE-2015-7833 fix for 4.1-stable ?

References:
https://security-tracker.debian.org/tracker/CVE-2015-7833
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=588afcc1c0e45358159090d95bf7b246fb67565f
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=fa52bd506f274b7619955917abfde355e3d19ffe

Regards,
Yuki Machida


--
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] Add GS1662 driver (a SPI video serializer)

2016-04-15 Thread Hans Verkuil
On 04/04/2016 02:35 PM, Jean-Michel Hautbois wrote:
>>> Next, you should add a complete description to your commit. Just
>>> having an object and a signed-off-by line is not enough.
>> Oh, I'm sorry, I don't have any idea to explicit more details. I will
>> find something for that.
> 
> Just get the description from the datasheet as a start ;-).
> 
>>> You also have to use the scripts/checkpatch.pl script to verify that
>>> everything is ok with it.
>> I have executed this script before to send it. And it noticed nothing about 
>> that.
>>
>>> Last thing, I can't see anything related to V4L2 in your patch. It is
>>> just used to initialize the chip and the spi bus, that's all.
>>> Adding a subdev is a start, and some operations if it can do something
>>> else than just serializing.
>>
>> Maybe I'm in the wrong list for that in fact. I didn't know this list was 
>> about V4L2 and related topics.
>> This driver is only to configure the component to manage the video stream in 
>> electronic card, it is not to capture video stream via V4L.
>>
>> I should improve my driver to be configurable by userspace. But maybe I 
>> should submit my future patch in another ML.
> 
> Well, I am not really sure about that. I added Hans in cc as he may
> have a better view.
> From my point of view, it can be a V4L2 subdev, even a simple one, as
> you can configure outputs, etc.

I think the media subsystem is definitely the right place for this.

I would use the cs3308.c driver as a starting point. This is also a minimal 
driver
(and you can remove the code under CONFIG_VIDEO_ADV_DEBUG for your driver), but 
it
uses v4l2_subdev and that makes it ready to be extended in the future, which you
will likely need to do eventually.

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: Backport a Security Fix for CVE-2015-7833 to v4.1

2016-04-15 Thread Hans Verkuil
Hi Vladis,

On 04/11/2016 02:03 PM, Vladis Dronov wrote:
> Hello,
> 
> I apologize for intercepting, but I believe commit 588afcc1 should
> not be accepted and reverted in the trees where it was.

Your patch requesting that commit to be reverted fell through the cracks.

Having looked at it I agree that it should be reverted and I will apply it.

The main reason is really the incorrect error return which should have been
a goto. But as you say reverting it is easiest since your code does the
right thing.

Regards,

Hans

> 
> Reasons:
> 
> https://patchwork.linuxtv.org/patch/32798/
> or
> https://www.spinics.net/lists/linux-media/msg96936.html
> 
> 
> Best regards,
> Vladis Dronov | Red Hat, Inc. | Product Security Engineer
> 
> - Original Message -
> From: "Yuki Machida" 
> To: "sasha levin" 
> Cc: linux-media@vger.kernel.org, sta...@vger.kernel.org, hverk...@xs4all.nl, 
> oneu...@suse.com, vdro...@redhat.com, mche...@osg.samsung.com, 
> r...@spenneberg.net
> Sent: Monday, April 11, 2016 7:19:34 AM
> Subject: Backport a Security Fix for CVE-2015-7833 to v4.1
> 
> Hi Sasha,
> 
> I conformed that these patches for CVE-2015-7833 not applied at v4.1.21.
> 588afcc1c0e45358159090d95bf7b246fb67565
> fa52bd506f274b7619955917abfde355e3d19ff
> Could you please apply this CVE-2015-7833 fix for 4.1-stable ?
> 
> References:
> https://security-tracker.debian.org/tracker/CVE-2015-7833
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=588afcc1c0e45358159090d95bf7b246fb67565f
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=fa52bd506f274b7619955917abfde355e3d19ffe
> 
> Regards,
> Yuki Machida
> --
> 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 2/2] [media] atmel-isc: DT binding for Image Sensor Controller driver

2016-04-15 Thread Ludovic Desroches
+ linux-media@vger.kernel.org

On Wed, Apr 13, 2016 at 03:44:20PM +0800, Songjun Wu wrote:
> DT binding documentation for ISC driver.
> 
> Signed-off-by: Songjun Wu 
> ---
> 
>  .../devicetree/bindings/media/atmel-isc.txt| 84 
> ++
>  1 file changed, 84 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/media/atmel-isc.txt
> 
> diff --git a/Documentation/devicetree/bindings/media/atmel-isc.txt 
> b/Documentation/devicetree/bindings/media/atmel-isc.txt
> new file mode 100644
> index 000..449f05f
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/atmel-isc.txt
> @@ -0,0 +1,84 @@
> +Atmel Image Sensor Controller (ISC)
> +--
> +
> +Required properties:
> +- compatible
> + Must be "atmel,sama5d2-isc"
> +- reg
> + Physical base address and length of the registers set for the device;
> +- interrupts
> +  Should contain IRQ line for the ISI;
> +- clocks
> + List of clock specifiers, corresponding to entries in
> + the clock-names property;
> + Please refer to clock-bindings.txt.
> +- clock-names
> + Required elements: "hclock", "ispck".
> +- pinctrl-names, pinctrl-0
> + Please refer to pinctrl-bindings.txt.
> +- clk_in_isc
> + ISC internal clock node, it includes the isc_ispck and isc_mck.
> + Please refer to clock-bindings.txt.
> +- atmel,sensor-preferred
> + Sensor is preferred to process image (1-preferred, 0-not).
> + The default value is 1.
> +
> +ISC supports a single port node with parallel bus. It should contain one
> +'port' child node with child 'endpoint' node. Please refer to the bindings
> +defined in Documentation/devicetree/bindings/media/video-interfaces.txt.
> +
> +Example:
> +isc: isc@f0008000 {
> + compatible = "atmel,sama5d2-isc";
> + reg = <0xf0008000 0x4000>;
> + interrupts = <46 IRQ_TYPE_LEVEL_HIGH 5>;
> + clocks = <&isc_clk>, <&isc_ispck>;
> + clock-names = "hclock", "ispck";
> + atmel,sensor-preferred = <1>;
> +
> + port {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + isc_0: endpoint@0 {
> + remote-endpoint = <&ov7740_0>;
> + hsync-active = <1>;
> + vsync-active = <0>;
> + pclk-sample = <1>;
> + };
> + };
> +
> + clk_in_isc {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + isc_ispck: isc_ispck {
> + #clock-cells = <0>;
> + reg = <0>;
> + clocks = <&isc_clk>, <&iscck>;
> + };
> +
> + isc_mck: isc_mck {
> + #clock-cells = <0>;
> + reg = <1>;
> + clocks = <&isc_clk>, <&iscck>, <&isc_gclk>;
> + };
> + };
> +};
> +
> +i2c1: i2c@fc028000 {
> + ov7740: camera@0x21 {
> + compatible = "ovti,ov7740";
> + reg = <0x21>;
> +
> + clocks = <&isc_mck>;
> + clock-names = "xvclk";
> + assigned-clocks = <&isc_mck>;
> + assigned-clock-rates = <2400>;
> +
> + port {
> + ov7740_0: endpoint {
> + remote-endpoint = <&isc_0>;
> + };
> + };
> +};
> -- 
> 2.7.4
> 
> 
> ___
> linux-arm-kernel mailing list
> linux-arm-ker...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
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


[PATCHv2] v4l2-ioctl.c: improve cropcap compatibility code

2016-04-15 Thread Hans Verkuil
- Add a check for the case that both the cropcap and g_selection ops
  are NULL. This shouldn't happen, but I feel happier if the code
  guards against this.

- If g_selection exists, then ignore ENOTTY and ENOIOCTLCMD error
  codes from cropcap. Just assume square pixelaspect ratio in that
  case. This situation can happen if the bridge driver's cropcap op
  calls the corresponding subdev's op. So the cropcap ioctl is set,
  but it might return ENOIOCTLCMD anyway. In the past this would
  just return an error which is wrong.

- Call cropcap first and let g_selection overwrite the bounds and
  defrect. This safeguards against subdev cropcap implementations
  that set those rectangles as well. What g_selection returns has
  priority over what such cropcap implementations return.

Signed-off-by: Hans Verkuil 
---

This replaces a pair of older cleanup patches.

---
 drivers/media/v4l2-core/v4l2-ioctl.c | 70 ++--
 1 file changed, 43 insertions(+), 27 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 6bf5a3e..28e5be2 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -2160,40 +2160,56 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops,
struct file *file, void *fh, void *arg)
 {
struct v4l2_cropcap *p = arg;
+   struct v4l2_selection s = { .type = p->type };
+   int ret = 0;

-   if (ops->vidioc_g_selection) {
-   struct v4l2_selection s = { .type = p->type };
-   int ret;
+   /* setting trivial pixelaspect */
+   p->pixelaspect.numerator = 1;
+   p->pixelaspect.denominator = 1;

-   /* obtaining bounds */
-   if (V4L2_TYPE_IS_OUTPUT(p->type))
-   s.target = V4L2_SEL_TGT_COMPOSE_BOUNDS;
-   else
-   s.target = V4L2_SEL_TGT_CROP_BOUNDS;
+   /*
+* The determine_valid_ioctls() call already should ensure
+* that this can never happen, but just in case...
+*/
+   if (WARN_ON(!ops->vidioc_cropcap && !ops->vidioc_cropcap))
+   return -ENOTTY;

-   ret = ops->vidioc_g_selection(file, fh, &s);
-   if (ret)
-   return ret;
-   p->bounds = s.r;
+   if (ops->vidioc_cropcap)
+   ret = ops->vidioc_cropcap(file, fh, p);

-   /* obtaining defrect */
-   if (V4L2_TYPE_IS_OUTPUT(p->type))
-   s.target = V4L2_SEL_TGT_COMPOSE_DEFAULT;
-   else
-   s.target = V4L2_SEL_TGT_CROP_DEFAULT;
+   if (!ops->vidioc_g_selection)
+   return ret;

-   ret = ops->vidioc_g_selection(file, fh, &s);
-   if (ret)
-   return ret;
-   p->defrect = s.r;
-   }
+   /*
+* Ignore ENOTTY or ENOIOCTLCMD error returns, just use the
+* square pixel aspect ratio in that case.
+*/
+   if (ret && ret != -ENOTTY && ret != -ENOIOCTLCMD)
+   return ret;

-   /* setting trivial pixelaspect */
-   p->pixelaspect.numerator = 1;
-   p->pixelaspect.denominator = 1;
+   /* Use g_selection() to fill in the bounds and defrect rectangles */

-   if (ops->vidioc_cropcap)
-   return ops->vidioc_cropcap(file, fh, p);
+   /* obtaining bounds */
+   if (V4L2_TYPE_IS_OUTPUT(p->type))
+   s.target = V4L2_SEL_TGT_COMPOSE_BOUNDS;
+   else
+   s.target = V4L2_SEL_TGT_CROP_BOUNDS;
+
+   ret = ops->vidioc_g_selection(file, fh, &s);
+   if (ret)
+   return ret;
+   p->bounds = s.r;
+
+   /* obtaining defrect */
+   if (V4L2_TYPE_IS_OUTPUT(p->type))
+   s.target = V4L2_SEL_TGT_COMPOSE_DEFAULT;
+   else
+   s.target = V4L2_SEL_TGT_CROP_DEFAULT;
+
+   ret = ops->vidioc_g_selection(file, fh, &s);
+   if (ret)
+   return ret;
+   p->defrect = s.r;

return 0;
 }
-- 
2.8.0.rc3


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


[GIT PULL FOR v4.7] Add tw686x drivers

2016-04-15 Thread Hans Verkuil
Hi Mauro,

This pull request adds two tw686x drivers, one in mainline, one in staging.

We've ended up with two drivers: one only supports V4L2_FIELD_SEQ_BT,
FIELD_TOP and FIELD_BOTTOM interlaced modes and no audio, the other only
supports FIELD_INTERLACED by way of a memcpy and has audio support.

Part of the reason is weird hardware design that has different DMA modes
depending on the field settings. Krzysztof didn't need FIELD_INTERLACED,
so he never implemented that, and unfortunately when Ezequiel took his
code as starting point he only implemented the FIELD_INTERLACED format.
The memcpy was needed due to unstable DMA when using the DMA mode that
can do FIELD_INTERLACED. It is not known at this time if that unstable
behavior is specific to the hardware Ezequiel is using or if it is
inherent to the tw686x.

In the ideal world both feature sets should be merged into one driver.

But for now I decided to add Ezequiel's driver to the mainline and
Krzysztof's driver to staging. The reason for moving Ezequiel's driver
to mainline is that application support for FIELD_INTERLACED is standard,
whereas FIELD_TOP/BOTTOM/SEQ_BT is pretty rare. In addition, Ezequiel's
driver has audio support.

My hope is that someone will merge the feature sets and we can get rid
of one of the two drivers.

I have tested both drivers with this card:

http://www.nanzoom.com/product/nz-2108E.shtml

(available on ebay)

Update: Ezequiel has started work to add the missing features to his
driver, so hopefully we'll be able to drop the staging driver in the near
future.li

Regards,

Hans


The following changes since commit ecb7b0183a89613c154d1bea48b494907efbf8f9:

  [media] m88ds3103: fix undefined division (2016-04-13 19:17:39 -0300)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git tw686x

for you to fetch changes up to 21f8b7cd5a825ed04ca9ffafbbf0c474f156cca2:

  tw686x: Specify that the DMA is 32 bits (2016-04-15 11:35:21 +0200)


Ezequiel Garcia (2):
  media: Support Intersil/Techwell TW686x-based video capture cards
  tw686x: Specify that the DMA is 32 bits

Hans Verkuil (4):
  tw686x-kh: specify that the DMA is 32 bits
  tw686x-kh: add audio support to the TODO list
  tw686x: add missing statics
  tw686x-kh: rename three functions to prevent clash with tw686x driver

Krzysztof Hałasa (1):
  TW686x frame grabber driver

 MAINTAINERS   |   8 +
 drivers/media/pci/Kconfig |   1 +
 drivers/media/pci/Makefile|   1 +
 drivers/media/pci/tw686x/Kconfig  |  18 +
 drivers/media/pci/tw686x/Makefile |   3 +
 drivers/media/pci/tw686x/tw686x-audio.c   | 386 +
 drivers/media/pci/tw686x/tw686x-core.c| 415 ++
 drivers/media/pci/tw686x/tw686x-regs.h| 122 +++
 drivers/media/pci/tw686x/tw686x-video.c   | 928 
++
 drivers/media/pci/tw686x/tw686x.h | 158 +
 drivers/staging/media/Kconfig |   2 +
 drivers/staging/media/Makefile|   1 +
 drivers/staging/media/tw686x-kh/Kconfig   |  17 +
 drivers/staging/media/tw686x-kh/Makefile  |   3 +
 drivers/staging/media/tw686x-kh/TODO  |   6 +
 drivers/staging/media/tw686x-kh/tw686x-kh-core.c  | 140 
 drivers/staging/media/tw686x-kh/tw686x-kh-regs.h  | 103 ++
 drivers/staging/media/tw686x-kh/tw686x-kh-video.c | 821 

 drivers/staging/media/tw686x-kh/tw686x-kh.h   | 118 +++
 19 files changed, 3251 insertions(+)
 create mode 100644 drivers/media/pci/tw686x/Kconfig
 create mode 100644 drivers/media/pci/tw686x/Makefile
 create mode 100644 drivers/media/pci/tw686x/tw686x-audio.c
 create mode 100644 drivers/media/pci/tw686x/tw686x-core.c
 create mode 100644 drivers/media/pci/tw686x/tw686x-regs.h
 create mode 100644 drivers/media/pci/tw686x/tw686x-video.c
 create mode 100644 drivers/media/pci/tw686x/tw686x.h
 create mode 100644 drivers/staging/media/tw686x-kh/Kconfig
 create mode 100644 drivers/staging/media/tw686x-kh/Makefile
 create mode 100644 drivers/staging/media/tw686x-kh/TODO
 create mode 100644 drivers/staging/media/tw686x-kh/tw686x-kh-core.c
 create mode 100644 drivers/staging/media/tw686x-kh/tw686x-kh-regs.h
 create mode 100644 drivers/staging/media/tw686x-kh/tw686x-kh-video.c
 create mode 100644 drivers/staging/media/tw686x-kh/tw686x-kh.h

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


Re: [PATCH] media: saa7134 fix media_dev alloc error path to not free when alloc fails

2016-04-15 Thread Mauro Carvalho Chehab
Em Thu, 14 Apr 2016 16:18:17 -0600
Shuah Khan  escreveu:

> On 04/14/2016 03:08 PM, Mauro Carvalho Chehab wrote:
> > Em Thu, 14 Apr 2016 10:31:20 -0600
> > Shuah Khan  escreveu:
> >   
> >> media_dev alloc error path does kfree when alloc fails. Fix it to not call
> >> kfree when media_dev alloc fails.  
> > 
> > No need. kfree(NULL) is OK.  
> 
> Agreed.
> 
> > 
> > Adding a label inside a conditional block is ugly.  
> 
> In this case, if label is in normal path, we will see defined, but not
> used warnings when condition isn't defined. 

True, but we don't need a label here, as kfree() can be called with a null
pointer.

> We seem to have many such
> cases for CONFIG_MEDIA_CONTROLLER :(

We may try to address those media-controller dependent code latter on.

I have some ideas of adding some macros and helper functions to allow
getting rid of those ifdefs and not add extra code if !MEDIA_CONTROLLER,
but the better seems to first add MC support to ALSA and make the
enable/disable functions generic, and then cleanup the code to remove
those ifdefs.

> 
> thanks,
> -- Shuah
> 
> 


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


Re: Backport a Security Fix for CVE-2015-7833 to v4.1

2016-04-15 Thread Vladis Dronov
Hello, Yuki, all,

My commit fa52bd506f resolves CVE-2015-7833, as mentioned in
https://www.spinics.net/lists/linux-media/msg96936.html

Please, note a message from Hans down this thread, who agrees
with my point.

Best regards,
Vladis Dronov | Red Hat, Inc. | Product Security Engineer

- Original Message -
From: "Yuki Machida" 
To: "Vladis Dronov" 
Cc: "sasha levin" , linux-media@vger.kernel.org, 
sta...@vger.kernel.org, hverk...@xs4all.nl, oneu...@suse.com, 
mche...@osg.samsung.com, r...@spenneberg.net
Sent: Friday, April 15, 2016 10:31:17 AM
Subject: Re: Backport a Security Fix for CVE-2015-7833 to v4.1

Hi Vladis,

 > I apologize for intercepting, but I believe commit 588afcc1 should
 > not be accepted and reverted in the trees where it was.
 >
 > Reasons:
 >
 > https://patchwork.linuxtv.org/patch/32798/
 > or
 > https://www.spinics.net/lists/linux-media/msg96936.html
Thank you for your reply.

If it revert commit 588afcc1 from the kernel,
It exists a Security Issue of CVE-2015-7833.
What do you think about it?

Best regards,
Yuki Machida

On 2016年04月11日 21:03, Vladis Dronov wrote:
> Hello,
>
> I apologize for intercepting, but I believe commit 588afcc1 should
> not be accepted and reverted in the trees where it was.
>
> Reasons:
>
> https://patchwork.linuxtv.org/patch/32798/
> or
> https://www.spinics.net/lists/linux-media/msg96936.html
>
>
> Best regards,
> Vladis Dronov | Red Hat, Inc. | Product Security Engineer
>
> - Original Message -
> From: "Yuki Machida" 
> To: "sasha levin" 
> Cc: linux-media@vger.kernel.org, sta...@vger.kernel.org, hverk...@xs4all.nl, 
> oneu...@suse.com, vdro...@redhat.com, mche...@osg.samsung.com, 
> r...@spenneberg.net
> Sent: Monday, April 11, 2016 7:19:34 AM
> Subject: Backport a Security Fix for CVE-2015-7833 to v4.1
>
> Hi Sasha,
>
> I conformed that these patches for CVE-2015-7833 not applied at v4.1.21.
> 588afcc1c0e45358159090d95bf7b246fb67565
> fa52bd506f274b7619955917abfde355e3d19ff
> Could you please apply this CVE-2015-7833 fix for 4.1-stable ?
>
> References:
> https://security-tracker.debian.org/tracker/CVE-2015-7833
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=588afcc1c0e45358159090d95bf7b246fb67565f
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=fa52bd506f274b7619955917abfde355e3d19ffe
>
> Regards,
> Yuki Machida
>
--
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: Backport a Security Fix for CVE-2015-7833 to v4.1

2016-04-15 Thread Vladis Dronov
Hello, Hans!

>> Having looked at it I agree that it should be reverted and I will apply it.
Thank you! I'm happy this is now somehow resolved.

Best regards,
Vladis Dronov | Red Hat, Inc. | Product Security Engineer
--
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 v6 01/24] i2c-mux: add common data for every i2c-mux instance

2016-04-15 Thread Wolfram Sang

> > I'd suggest to rename 'adapters' into 'num_adapters' throughout this
> > patch. I think it makes the code a lot easier to understand.
> 
> Hmm, you mean just the variable names, right? And not function names
> such as i2c_mux_reserve_(num_)adapters?

Yes, only variable names.

> > Despite that I wonder why not using some of the realloc functions, I
> 
> When I wrote it, I found no devm_ version of realloc. I'm not finding
> anything now either...

Right, there is no devm_ version of it :(

> > wonder even more if we couldn't supply num_adapters to i2c_mux_alloc()
> > and reserve the memory statically. i2c busses are not
> > dynamic/hot-pluggable so that should be good enough?
> 
> Yes, that would work, but it would take some restructuring in some of
> the drivers that currently don't know how many child adapters they
> are going to need when they call i2c_mux_alloc.

Which ones?

> Because you thought about removing i2c_mux_reserve_adapters completely,
> and not provide any means of adding more adapters than specified in
> the i2c_mux_alloc call, right?

Yes. I assumed I2C to be static enough that such information is known in
advance.

> > Ignoring the 80 char limit here makes the code more readable.
> 
> That is only true if you actually have more than 80 characters, so I don't
> agree. Are you adamant about it? (I'm not)

No. Keep it if you prefer it.

> >> +EXPORT_SYMBOL_GPL(i2c_mux_one_adapter);
> > 
> > Are you sure the above function pays off? Its argument list is very
> > complex and it doesn't save a lot of code. Having seperate calls is
> > probably more understandable in drivers? Then again, I assume it makes
> > the conversion of existing drivers easier.
> 
> I added it in v4, you can check earlier versions if you like. Without
> it most gate-muxes (i.e. typically the muxes in drivers/media) grew
> since the i2c_add_mux_adapter call got replaced by two calls, i.e.
> i2c_mux_alloc followed by i2c_max_add_adapter, and coupled with
> error checks made it look more complex than before. So, this wasn't
> much of a cleanup from the point of those drivers.

Hmm, v3 didn't have the driver patches posted with it. Can you push it
to your branch? I am also not too strong with this one, but having a
look how it looks without would be nice.



signature.asc
Description: PGP signature


[PATCH for 4.6] davinci_vpfe: Revert "staging: media: davinci_vpfe: remove,unnecessary ret variable"

2016-04-15 Thread Hans Verkuil
This reverts commit afa5d19a2b5fbf0bbcce34f3613bce2bc9479bb7.

This patch is completely bogus and messed up the code big time.

I'm not sure what was intended, but this isn't it.

Cc: Thaissa Falbo 
Cc: Greg Kroah-Hartman 
---

Greg, this patch was never seen by us. Can you redirect patches for 
staging/media
to the linux-media mailinglist? We'd like to stay on top of what is happening 
there.

Thanks!

Hans

---
 drivers/staging/media/davinci_vpfe/vpfe_video.c | 54 -
 1 file changed, 34 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c 
b/drivers/staging/media/davinci_vpfe/vpfe_video.c
index df4f298..ea3ddec 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -172,9 +172,11 @@ static int vpfe_prepare_pipeline(struct vpfe_video_device 
*video)
 static int vpfe_update_pipe_state(struct vpfe_video_device *video)
 {
struct vpfe_pipeline *pipe = &video->pipe;
+   int ret;

-   if (vpfe_prepare_pipeline(video))
-   return vpfe_prepare_pipeline(video);
+   ret = vpfe_prepare_pipeline(video);
+   if (ret)
+   return ret;

/*
 * Find out if there is any input video
@@ -182,9 +184,10 @@ static int vpfe_update_pipe_state(struct vpfe_video_device 
*video)
 */
if (pipe->input_num == 0) {
pipe->state = VPFE_PIPELINE_STREAM_CONTINUOUS;
-   if (vpfe_update_current_ext_subdev(video)) {
+   ret = vpfe_update_current_ext_subdev(video);
+   if (ret) {
pr_err("Invalid external subdev\n");
-   return vpfe_update_current_ext_subdev(video);
+   return ret;
}
} else {
pipe->state = VPFE_PIPELINE_STREAM_SINGLESHOT;
@@ -667,6 +670,7 @@ static int vpfe_enum_fmt(struct file *file, void  *priv,
struct v4l2_subdev *subdev;
struct v4l2_format format;
struct media_pad *remote;
+   int ret;

v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_enum_fmt\n");

@@ -695,10 +699,11 @@ static int vpfe_enum_fmt(struct file *file, void  *priv,
sd_fmt.pad = remote->index;
sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
/* get output format of remote subdev */
-   if (v4l2_subdev_call(subdev, pad, get_fmt, NULL, &sd_fmt)) {
+   ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &sd_fmt);
+   if (ret) {
v4l2_err(&vpfe_dev->v4l2_dev,
 "invalid remote subdev for video node\n");
-   return v4l2_subdev_call(subdev, pad, get_fmt, NULL, &sd_fmt);
+   return ret;
}
/* convert to pix format */
mbus.code = sd_fmt.format.code;
@@ -725,6 +730,7 @@ static int vpfe_s_fmt(struct file *file, void *priv,
struct vpfe_video_device *video = video_drvdata(file);
struct vpfe_device *vpfe_dev = video->vpfe_dev;
struct v4l2_format format;
+   int ret;

v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_fmt\n");
/* If streaming is started, return error */
@@ -733,8 +739,9 @@ static int vpfe_s_fmt(struct file *file, void *priv,
return -EBUSY;
}
/* get adjacent subdev's output pad format */
-   if (__vpfe_video_get_format(video, &format))
-   return __vpfe_video_get_format(video, &format);
+   ret = __vpfe_video_get_format(video, &format);
+   if (ret)
+   return ret;
*fmt = format;
video->fmt = *fmt;
return 0;
@@ -757,11 +764,13 @@ static int vpfe_try_fmt(struct file *file, void *priv,
struct vpfe_video_device *video = video_drvdata(file);
struct vpfe_device *vpfe_dev = video->vpfe_dev;
struct v4l2_format format;
+   int ret;

v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_try_fmt\n");
/* get adjacent subdev's output pad format */
-   if (__vpfe_video_get_format(video, &format))
-   return __vpfe_video_get_format(video, &format);
+   ret = __vpfe_video_get_format(video, &format);
+   if (ret)
+   return ret;

*fmt = format;
return 0;
@@ -838,8 +847,9 @@ static int vpfe_s_input(struct file *file, void *priv, 
unsigned int index)

v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_input\n");

-   if (mutex_lock_interruptible(&video->lock))
-   return mutex_lock_interruptible(&video->lock);
+   ret = mutex_lock_interruptible(&video->lock);
+   if (ret)
+   return ret;
/*
 * If streaming is started return device busy
 * error
@@ -940,8 +950,9 @@ static int vpfe_s_std(struct file *file, void *priv, 
v4l2_std_id std_id)
v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_std\n");

/* Call decoder driver function to set the standard */
-   if (mutex_lock_interrupt

Re: [PATCH] Add GS1662 driver (a SPI video serializer)

2016-04-15 Thread Charles-Antoine Couret
Le 15/04/2016 10:38, Hans Verkuil a écrit :
> I think the media subsystem is definitely the right place for this.
> 
> I would use the cs3308.c driver as a starting point. This is also a minimal 
> driver
> (and you can remove the code under CONFIG_VIDEO_ADV_DEBUG for your driver), 
> but it
> uses v4l2_subdev and that makes it ready to be extended in the future, which 
> you
> will likely need to do eventually.

Yes, I agree with that now. :)
I'm writing a new version of patch to integrate it into media subdev. It's 
"ready" but I need some tests to validate all behaviours.

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


[GIT PULL FOR v4.7] Various fixes

2016-04-15 Thread Hans Verkuil

The following changes since commit ecb7b0183a89613c154d1bea48b494907efbf8f9:

  [media] m88ds3103: fix undefined division (2016-04-13 19:17:39 -0300)

are available in the git repository at:

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

for you to fetch changes up to 7a707cf621e9c299f3b07a059cabaed164d807b4:

  tpg: Export the tpg code from vivid as a module (2016-04-15 13:33:00 +0200)


Claudiu Beznea (1):
  Staging: media: bcm2048: defined region_configs[] array as const array

Hans Verkuil (8):
  tc358743: zero the reserved array
  vidioc-g-edid.xml: be explicit about zeroing the reserved array
  vidioc-enum-dv-timings.xml: explicitly state that pad and reserved should 
be zeroed
  vidioc-dv-timings-cap.xml: explicitly state that pad and reserved should 
be zeroed
  v4l2-device.h: add v4l2_device_mask_ variants
  ivtv/cx18: use the new mask variants of the v4l2_device_call_* defines
  v4l2-rect.h: new header with struct v4l2_rect helper functions.
  vivid: use new v4l2-rect.h header

Helen Mae Koike Fornazier (1):
  tpg: Export the tpg code from vivid as a module

Niklas Söderlund (3):
  adv7180: Add g_std operation
  adv7180: Add cropcap operation
  adv7180: Add g_tvnorms operation

Vladis Dronov (1):
  usbvision: revert commit 588afcc1

 Documentation/DocBook/device-drivers.tmpl|   1 +
 Documentation/DocBook/media/v4l/vidioc-dv-timings-cap.xml|  12 ++-
 Documentation/DocBook/media/v4l/vidioc-enum-dv-timings.xml   |   5 +-
 Documentation/DocBook/media/v4l/vidioc-g-edid.xml|  10 +-
 drivers/media/common/Kconfig |   1 +
 drivers/media/common/Makefile|   2 +-
 drivers/media/common/v4l2-tpg/Kconfig|   2 +
 drivers/media/common/v4l2-tpg/Makefile   |   3 +
 .../vivid/vivid-tpg-colors.c => common/v4l2-tpg/v4l2-tpg-colors.c}   |   7 +-
 .../{platform/vivid/vivid-tpg.c => common/v4l2-tpg/v4l2-tpg-core.c}  |  25 
-
 drivers/media/i2c/adv7180.c  |  34 
+-
 drivers/media/i2c/tc358743.c |   4 +
 drivers/media/pci/cx18/cx18-driver.h |  13 +--
 drivers/media/pci/ivtv/ivtv-driver.h |  13 +--
 drivers/media/platform/vivid/Kconfig |   1 +
 drivers/media/platform/vivid/Makefile|   2 +-
 drivers/media/platform/vivid/vivid-core.h|   2 +-
 drivers/media/platform/vivid/vivid-kthread-cap.c |  13 +--
 drivers/media/platform/vivid/vivid-vid-cap.c | 101 
+-
 drivers/media/platform/vivid/vivid-vid-common.c  |  97 
-
 drivers/media/platform/vivid/vivid-vid-common.h  |   9 --
 drivers/media/platform/vivid/vivid-vid-out.c | 103 
+-
 drivers/media/usb/go7007/go7007-v4l2.c   |   2 +-
 drivers/media/usb/usbvision/usbvision-video.c|   7 --
 drivers/staging/media/bcm2048/radio-bcm2048.c|   2 +-
 include/media/v4l2-device.h  |  55 
+-
 include/media/v4l2-rect.h| 173 
+++
 .../vivid/vivid-tpg-colors.h => include/media/v4l2-tpg-colors.h  |   6 +-
 drivers/media/platform/vivid/vivid-tpg.h => include/media/v4l2-tpg.h |   9 +-
 29 files changed, 440 insertions(+), 274 deletions(-)
 create mode 100644 drivers/media/common/v4l2-tpg/Kconfig
 create mode 100644 drivers/media/common/v4l2-tpg/Makefile
 rename drivers/media/{platform/vivid/vivid-tpg-colors.c => 
common/v4l2-tpg/v4l2-tpg-colors.c} (99%)
 rename drivers/media/{platform/vivid/vivid-tpg.c => 
common/v4l2-tpg/v4l2-tpg-core.c} (98%)
 create mode 100644 include/media/v4l2-rect.h
 rename drivers/media/platform/vivid/vivid-tpg-colors.h => 
include/media/v4l2-tpg-colors.h (93%)
 rename drivers/media/platform/vivid/vivid-tpg.h => include/media/v4l2-tpg.h 
(99%)
--
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


[PATCHv2 00/12] vb2: replace allocation context by device pointer

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

The opaque allocation context that allocators use and drivers have to fill
in is really nothing more than a device pointer wrapped in an kmalloc()ed
struct.

This patch series adds a new 'struct device *dev' field that contains the
default device pointer to use if the driver doesn't set alloc_ctxs. This
simplifies many drivers since there are only two Samsung drivers that need
different devices for different planes. All others use the same device for
everything.

So instead of having to allocate a context (and free it, which not all
drivers did) you just set a dev pointer once.

The last patch removes the allocation context code altogether and replaces
it with proper struct device pointers instead of the untyped void pointer.

Note: one idea I toyed with was to have an array of devs instead of a
single dev field in vb2_queue, but that was actually awkward to use.

A single dev turned out to be much easier to use.

Regards,

Hans

Changes since v1:
- rebased against latest linuxtv master
- add dma_attrs field to vb2_queue to specify non-standard DMA attributes
  for both dma-contig. This feature was added to v4.6.

Hans Verkuil (12):
  vb2: add a dev field to use for the default allocation context
  v4l2-pci-skeleton: set q->dev instead of allocating a context
  sur40: set q->dev instead of allocating a context
  media/pci: convert drivers to use the new vb2_queue dev field
  staging/media: convert drivers to use the new vb2_queue dev field
  media/platform: convert drivers to use the new vb2_queue dev field
  media/platform: convert drivers to use the new vb2_queue dev field
  media/platform: convert drivers to use the new vb2_queue dev field
  media/.../soc-camera: convert drivers to use the new vb2_queue dev
field
  media/platform: convert drivers to use the new vb2_queue dev field
  media/platform: convert drivers to use the new vb2_queue dev field
  vb2: replace void *alloc_ctxs by struct device *alloc_devs

 Documentation/video4linux/v4l2-pci-skeleton.c  | 17 ++--
 drivers/input/touchscreen/sur40.c  | 15 +--
 drivers/media/dvb-frontends/rtl2832_sdr.c  |  2 +-
 drivers/media/pci/cobalt/cobalt-driver.c   |  9 
 drivers/media/pci/cobalt/cobalt-driver.h   |  1 -
 drivers/media/pci/cobalt/cobalt-v4l2.c |  4 +-
 drivers/media/pci/cx23885/cx23885-417.c|  3 +-
 drivers/media/pci/cx23885/cx23885-core.c   | 10 +
 drivers/media/pci/cx23885/cx23885-dvb.c|  4 +-
 drivers/media/pci/cx23885/cx23885-vbi.c|  3 +-
 drivers/media/pci/cx23885/cx23885-video.c  |  5 ++-
 drivers/media/pci/cx23885/cx23885.h|  1 -
 drivers/media/pci/cx25821/cx25821-core.c   | 10 +
 drivers/media/pci/cx25821/cx25821-video.c  |  5 +--
 drivers/media/pci/cx25821/cx25821.h|  1 -
 drivers/media/pci/cx88/cx88-blackbird.c|  4 +-
 drivers/media/pci/cx88/cx88-dvb.c  |  4 +-
 drivers/media/pci/cx88/cx88-mpeg.c | 10 +
 drivers/media/pci/cx88/cx88-vbi.c  |  3 +-
 drivers/media/pci/cx88/cx88-video.c| 13 ++
 drivers/media/pci/cx88/cx88.h  |  2 -
 drivers/media/pci/dt3155/dt3155.c  | 15 ++-
 drivers/media/pci/dt3155/dt3155.h  |  2 -
 drivers/media/pci/netup_unidvb/netup_unidvb_core.c |  2 +-
 drivers/media/pci/saa7134/saa7134-core.c   | 22 --
 drivers/media/pci/saa7134/saa7134-ts.c |  3 +-
 drivers/media/pci/saa7134/saa7134-vbi.c|  3 +-
 drivers/media/pci/saa7134/saa7134-video.c  |  5 ++-
 drivers/media/pci/saa7134/saa7134.h|  3 +-
 drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | 13 +-
 drivers/media/pci/solo6x10/solo6x10-v4l2.c | 12 +-
 drivers/media/pci/solo6x10/solo6x10.h  |  2 -
 drivers/media/pci/sta2x11/sta2x11_vip.c| 20 ++---
 drivers/media/pci/tw68/tw68-core.c | 15 ++-
 drivers/media/pci/tw68/tw68-video.c|  4 +-
 drivers/media/pci/tw68/tw68.h  |  1 -
 drivers/media/platform/am437x/am437x-vpfe.c| 14 ++-
 drivers/media/platform/am437x/am437x-vpfe.h|  2 -
 drivers/media/platform/blackfin/bfin_capture.c | 17 ++--
 drivers/media/platform/coda/coda-common.c  | 18 ++--
 drivers/media/platform/coda/coda.h |  1 -
 drivers/media/platform/davinci/vpbe_display.c  | 14 +--
 drivers/media/platform/davinci/vpif_capture.c  | 15 ++-
 drivers/media/platform/davinci/vpif_capture.h  |  2 -
 drivers/media/platform/davinci/vpif_display.c  | 15 ++-
 drivers/media/platform/davinci/vpif_display.h  |  2 -
 drivers/media/platform/exynos-gsc/gsc-core.c   | 11 +
 drivers/media/platform/exynos-gsc/gsc-core.h   |  2 -
 drivers/media/platform/exynos-gsc/gsc-m2m.c|  

[PATCHv2 06/12] media/platform: convert drivers to use the new vb2_queue dev field

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

Stop using alloc_ctx and just fill in the device pointer.

Signed-off-by: Hans Verkuil 
Cc: "Lad, Prabhakar" 
Cc: Scott Jiang 
Cc: Philipp Zabel 
---
 drivers/media/platform/am437x/am437x-vpfe.c| 10 +-
 drivers/media/platform/am437x/am437x-vpfe.h|  2 --
 drivers/media/platform/blackfin/bfin_capture.c | 15 ++-
 drivers/media/platform/coda/coda-common.c  | 16 ++--
 drivers/media/platform/coda/coda.h |  1 -
 drivers/media/platform/davinci/vpbe_display.c  | 12 +---
 drivers/media/platform/davinci/vpif_capture.c  | 11 +--
 drivers/media/platform/davinci/vpif_capture.h  |  2 --
 drivers/media/platform/davinci/vpif_display.c  | 11 +--
 drivers/media/platform/davinci/vpif_display.h  |  2 --
 include/media/davinci/vpbe_display.h   |  2 --
 11 files changed, 8 insertions(+), 76 deletions(-)

diff --git a/drivers/media/platform/am437x/am437x-vpfe.c 
b/drivers/media/platform/am437x/am437x-vpfe.c
index e749eb7..d22b09d 100644
--- a/drivers/media/platform/am437x/am437x-vpfe.c
+++ b/drivers/media/platform/am437x/am437x-vpfe.c
@@ -1915,7 +1915,6 @@ static int vpfe_queue_setup(struct vb2_queue *vq,
 
if (vq->num_buffers + *nbuffers < 3)
*nbuffers = 3 - vq->num_buffers;
-   alloc_ctxs[0] = vpfe->alloc_ctx;
 
if (*nplanes) {
if (sizes[0] < size)
@@ -2364,13 +2363,6 @@ static int vpfe_probe_complete(struct vpfe_device *vpfe)
goto probe_out;
 
/* Initialize videobuf2 queue as per the buffer type */
-   vpfe->alloc_ctx = vb2_dma_contig_init_ctx(vpfe->pdev);
-   if (IS_ERR(vpfe->alloc_ctx)) {
-   vpfe_err(vpfe, "Failed to get the context\n");
-   err = PTR_ERR(vpfe->alloc_ctx);
-   goto probe_out;
-   }
-
q = &vpfe->buffer_queue;
q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
q->io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;
@@ -2381,11 +2373,11 @@ static int vpfe_probe_complete(struct vpfe_device *vpfe)
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &vpfe->lock;
q->min_buffers_needed = 1;
+   q->dev = vpfe->pdev;
 
err = vb2_queue_init(q);
if (err) {
vpfe_err(vpfe, "vb2_queue_init() failed\n");
-   vb2_dma_contig_cleanup_ctx(vpfe->alloc_ctx);
goto probe_out;
}
 
diff --git a/drivers/media/platform/am437x/am437x-vpfe.h 
b/drivers/media/platform/am437x/am437x-vpfe.h
index 777bf97..17d7aa4 100644
--- a/drivers/media/platform/am437x/am437x-vpfe.h
+++ b/drivers/media/platform/am437x/am437x-vpfe.h
@@ -264,8 +264,6 @@ struct vpfe_device {
struct v4l2_rect crop;
/* Buffer queue used in video-buf */
struct vb2_queue buffer_queue;
-   /* Allocator-specific contexts for each plane */
-   struct vb2_alloc_ctx *alloc_ctx;
/* Queue of filled frames */
struct list_head dma_queue;
/* IRQ lock for DMA queue */
diff --git a/drivers/media/platform/blackfin/bfin_capture.c 
b/drivers/media/platform/blackfin/bfin_capture.c
index d0092da..1e244287 100644
--- a/drivers/media/platform/blackfin/bfin_capture.c
+++ b/drivers/media/platform/blackfin/bfin_capture.c
@@ -91,8 +91,6 @@ struct bcap_device {
struct bcap_buffer *cur_frm;
/* buffer queue used in videobuf2 */
struct vb2_queue buffer_queue;
-   /* allocator-specific contexts for each plane */
-   struct vb2_alloc_ctx *alloc_ctx;
/* queue of filled frames */
struct list_head dma_queue;
/* used in videobuf2 callback */
@@ -209,7 +207,6 @@ static int bcap_queue_setup(struct vb2_queue *vq,
 
if (vq->num_buffers + *nbuffers < 2)
*nbuffers = 2;
-   alloc_ctxs[0] = bcap_dev->alloc_ctx;
 
if (*nplanes)
return sizes[0] < bcap_dev->fmt.sizeimage ? -EINVAL : 0;
@@ -820,12 +817,6 @@ static int bcap_probe(struct platform_device *pdev)
}
bcap_dev->ppi->priv = bcap_dev;
 
-   bcap_dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
-   if (IS_ERR(bcap_dev->alloc_ctx)) {
-   ret = PTR_ERR(bcap_dev->alloc_ctx);
-   goto err_free_ppi;
-   }
-
vfd = &bcap_dev->video_dev;
/* initialize field of video device */
vfd->release= video_device_release_empty;
@@ -839,7 +830,7 @@ static int bcap_probe(struct platform_device *pdev)
if (ret) {
v4l2_err(pdev->dev.driver,
"Unable to register v4l2 device\n");
-   goto err_cleanup_ctx;
+   goto err_free_ppi;
}
v4l2_info(&bcap_dev->v4l2_dev, "v4l2 device registered\n");
 
@@ -863,6 +854,7 @@ static int bcap_probe(struct platform_device *pdev)
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &bcap_dev->mutex;
q->min_buffers_needed = 1;
+   q->

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

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

The allocation context is nothing more than a per-plane device pointer
to use when allocating buffers. So just provide a dev pointer in vb2_queue
for that purpose and drivers can skip allocating/releasing/filling in
the allocation context unless they require different per-plane device
pointers as used by some Samsung SoCs.

Signed-off-by: Hans Verkuil 
Cc: Laurent Pinchart 
Cc: Sakari Ailus 
Cc: Mauro Carvalho Chehab 
Cc: Florian Echtler 
Cc: Federico Vaga 
Cc: "Lad, Prabhakar" 
Cc: Scott Jiang 
Cc: Philipp Zabel 
Cc: Fabien Dessenne 
Cc: Benoit Parrot 
Cc: Mikhail Ulyanov 
Cc: Guennadi Liakhovetski 
Cc: Javier Martin 
Cc: Jonathan Corbet 
Cc: Ludovic Desroches 
Cc: Sergei Shtylyov 
Cc: Kyungmin Park 
Cc: Sylwester Nawrocki 
---
 drivers/media/v4l2-core/videobuf2-core.c | 16 +---
 include/media/videobuf2-core.h   |  3 +++
 2 files changed, 12 insertions(+), 7 deletions(-)

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

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


[PATCHv2 03/12] sur40: set q->dev instead of allocating a context

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

Stop using alloc_ctx and just fill in the device pointer.

Signed-off-by: Hans Verkuil 
Cc: Florian Echtler 
#
#total: 0 errors, 0 warnings, 304 lines checked
#
#Your patch has no obvious style problems and is ready for submission.
#
#total: 0 errors, 0 warnings, 8 lines checked
#
#Your patch has no obvious style problems and is ready for submission.
---
 drivers/input/touchscreen/sur40.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/input/touchscreen/sur40.c 
b/drivers/input/touchscreen/sur40.c
index 880c40b..cc4bd3e 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -151,7 +151,6 @@ struct sur40_state {
struct mutex lock;
 
struct vb2_queue queue;
-   struct vb2_alloc_ctx *alloc_ctx;
struct list_head buf_list;
spinlock_t qlock;
int sequence;
@@ -580,19 +579,13 @@ static int sur40_probe(struct usb_interface *interface,
sur40->queue = sur40_queue;
sur40->queue.drv_priv = sur40;
sur40->queue.lock = &sur40->lock;
+   sur40->queue.dev = sur40->dev;
 
/* initialize the queue */
error = vb2_queue_init(&sur40->queue);
if (error)
goto err_unreg_v4l2;
 
-   sur40->alloc_ctx = vb2_dma_sg_init_ctx(sur40->dev);
-   if (IS_ERR(sur40->alloc_ctx)) {
-   dev_err(sur40->dev, "Can't allocate buffer context");
-   error = PTR_ERR(sur40->alloc_ctx);
-   goto err_unreg_v4l2;
-   }
-
sur40->vdev = sur40_video_device;
sur40->vdev.v4l2_dev = &sur40->v4l2;
sur40->vdev.lock = &sur40->lock;
@@ -633,7 +626,6 @@ static void sur40_disconnect(struct usb_interface 
*interface)
 
video_unregister_device(&sur40->vdev);
v4l2_device_unregister(&sur40->v4l2);
-   vb2_dma_sg_cleanup_ctx(sur40->alloc_ctx);
 
input_unregister_polled_device(sur40->input);
input_free_polled_device(sur40->input);
@@ -655,11 +647,8 @@ static int sur40_queue_setup(struct vb2_queue *q,
   unsigned int *nbuffers, unsigned int *nplanes,
   unsigned int sizes[], void *alloc_ctxs[])
 {
-   struct sur40_state *sur40 = vb2_get_drv_priv(q);
-
if (q->num_buffers + *nbuffers < 3)
*nbuffers = 3 - q->num_buffers;
-   alloc_ctxs[0] = sur40->alloc_ctx;
 
if (*nplanes)
return sizes[0] < sur40_video_format.sizeimage ? -EINVAL : 0;
-- 
2.8.0.rc3

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


[PATCHv2 02/12] v4l2-pci-skeleton: set q->dev instead of allocating a context

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

Stop using alloc_ctx as that is now no longer needed.

Signed-off-by: Hans Verkuil 
---
 Documentation/video4linux/v4l2-pci-skeleton.c | 15 ++-
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/Documentation/video4linux/v4l2-pci-skeleton.c 
b/Documentation/video4linux/v4l2-pci-skeleton.c
index a55cf94..5f91d76 100644
--- a/Documentation/video4linux/v4l2-pci-skeleton.c
+++ b/Documentation/video4linux/v4l2-pci-skeleton.c
@@ -56,7 +56,6 @@ MODULE_LICENSE("GPL v2");
  * @format: current pix format
  * @input: current video input (0 = SDTV, 1 = HDTV)
  * @queue: vb2 video capture queue
- * @alloc_ctx: vb2 contiguous DMA context
  * @qlock: spinlock controlling access to buf_list and sequence
  * @buf_list: list of buffers queued for DMA
  * @sequence: frame sequence counter
@@ -73,7 +72,6 @@ struct skeleton {
unsigned input;
 
struct vb2_queue queue;
-   struct vb2_alloc_ctx *alloc_ctx;
 
spinlock_t qlock;
struct list_head buf_list;
@@ -182,7 +180,6 @@ static int queue_setup(struct vb2_queue *vq,
 
if (vq->num_buffers + *nbuffers < 3)
*nbuffers = 3 - vq->num_buffers;
-   alloc_ctxs[0] = skel->alloc_ctx;
 
if (*nplanes)
return sizes[0] < skel->format.sizeimage ? -EINVAL : 0;
@@ -820,6 +817,7 @@ static int skeleton_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
q = &skel->queue;
q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
q->io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;
+   q->dev = &pdev->dev;
q->drv_priv = skel;
q->buf_struct_size = sizeof(struct skel_buffer);
q->ops = &skel_qops;
@@ -850,12 +848,6 @@ static int skeleton_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
if (ret)
goto free_hdl;
 
-   skel->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
-   if (IS_ERR(skel->alloc_ctx)) {
-   dev_err(&pdev->dev, "Can't allocate buffer context");
-   ret = PTR_ERR(skel->alloc_ctx);
-   goto free_hdl;
-   }
INIT_LIST_HEAD(&skel->buf_list);
spin_lock_init(&skel->qlock);
 
@@ -885,13 +877,11 @@ static int skeleton_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
 
ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
if (ret)
-   goto free_ctx;
+   goto free_hdl;
 
dev_info(&pdev->dev, "V4L2 PCI Skeleton Driver loaded\n");
return 0;
 
-free_ctx:
-   vb2_dma_contig_cleanup_ctx(skel->alloc_ctx);
 free_hdl:
v4l2_ctrl_handler_free(&skel->ctrl_handler);
v4l2_device_unregister(&skel->v4l2_dev);
@@ -907,7 +897,6 @@ static void skeleton_remove(struct pci_dev *pdev)
 
video_unregister_device(&skel->vdev);
v4l2_ctrl_handler_free(&skel->ctrl_handler);
-   vb2_dma_contig_cleanup_ctx(skel->alloc_ctx);
v4l2_device_unregister(&skel->v4l2_dev);
pci_disable_device(skel->pdev);
 }
-- 
2.8.0.rc3

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


[PATCHv2 05/12] staging/media: convert drivers to use the new vb2_queue dev field

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

Stop using alloc_ctx and just fill in the device pointer.

Signed-off-by: Hans Verkuil 
Cc: "Lad, Prabhakar" 
Cc: Laurent Pinchart 
---
 drivers/staging/media/davinci_vpfe/vpfe_video.c | 10 +-
 drivers/staging/media/davinci_vpfe/vpfe_video.h |  2 --
 drivers/staging/media/omap4iss/iss_video.c  | 10 +-
 drivers/staging/media/omap4iss/iss_video.h  |  1 -
 4 files changed, 2 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c 
b/drivers/staging/media/davinci_vpfe/vpfe_video.c
index ea3ddec..77e66e7 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -542,7 +542,6 @@ static int vpfe_release(struct file *file)
video->io_usrs = 0;
/* Free buffers allocated */
vb2_queue_release(&video->buffer_queue);
-   vb2_dma_contig_cleanup_ctx(video->alloc_ctx);
}
/* Decrement device users counter */
video->usrs--;
@@ -1115,7 +1114,6 @@ vpfe_buffer_queue_setup(struct vb2_queue *vq,
 
*nplanes = 1;
sizes[0] = size;
-   alloc_ctxs[0] = video->alloc_ctx;
v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
 "nbuffers=%d, size=%lu\n", *nbuffers, size);
return 0;
@@ -1350,12 +1348,6 @@ static int vpfe_reqbufs(struct file *file, void *priv,
video->memory = req_buf->memory;
 
/* Initialize videobuf2 queue as per the buffer type */
-   video->alloc_ctx = vb2_dma_contig_init_ctx(vpfe_dev->pdev);
-   if (IS_ERR(video->alloc_ctx)) {
-   v4l2_err(&vpfe_dev->v4l2_dev, "Failed to get the context\n");
-   return PTR_ERR(video->alloc_ctx);
-   }
-
q = &video->buffer_queue;
q->type = req_buf->type;
q->io_modes = VB2_MMAP | VB2_USERPTR;
@@ -1365,11 +1357,11 @@ static int vpfe_reqbufs(struct file *file, void *priv,
q->mem_ops = &vb2_dma_contig_memops;
q->buf_struct_size = sizeof(struct vpfe_cap_buffer);
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+   q->dev = vpfe_dev->pdev;
 
ret = vb2_queue_init(q);
if (ret) {
v4l2_err(&vpfe_dev->v4l2_dev, "vb2_queue_init() failed\n");
-   vb2_dma_contig_cleanup_ctx(vpfe_dev->pdev);
return ret;
}
 
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.h 
b/drivers/staging/media/davinci_vpfe/vpfe_video.h
index 653334d..aaec440 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.h
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.h
@@ -123,8 +123,6 @@ struct vpfe_video_device {
/* Used to store pixel format */
struct v4l2_format  fmt;
struct vb2_queuebuffer_queue;
-   /* allocator-specific contexts for each plane */
-   struct vb2_alloc_ctx *alloc_ctx;
/* Queue of filled frames */
struct list_headdma_queue;
spinlock_t  irqlock;
diff --git a/drivers/staging/media/omap4iss/iss_video.c 
b/drivers/staging/media/omap4iss/iss_video.c
index cf8da23..3c077e3 100644
--- a/drivers/staging/media/omap4iss/iss_video.c
+++ b/drivers/staging/media/omap4iss/iss_video.c
@@ -310,8 +310,6 @@ static int iss_video_queue_setup(struct vb2_queue *vq,
if (sizes[0] == 0)
return -EINVAL;
 
-   alloc_ctxs[0] = video->alloc_ctx;
-
*count = min(*count, video->capture_mem / PAGE_ALIGN(sizes[0]));
 
return 0;
@@ -1017,13 +1015,6 @@ static int iss_video_open(struct file *file)
goto done;
}
 
-   video->alloc_ctx = vb2_dma_contig_init_ctx(video->iss->dev);
-   if (IS_ERR(video->alloc_ctx)) {
-   ret = PTR_ERR(video->alloc_ctx);
-   omap4iss_put(video->iss);
-   goto done;
-   }
-
q = &handle->queue;
 
q->type = video->type;
@@ -1033,6 +1024,7 @@ static int iss_video_open(struct file *file)
q->mem_ops = &vb2_dma_contig_memops;
q->buf_struct_size = sizeof(struct iss_buffer);
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+   q->dev = video->iss->dev;
 
ret = vb2_queue_init(q);
if (ret) {
diff --git a/drivers/staging/media/omap4iss/iss_video.h 
b/drivers/staging/media/omap4iss/iss_video.h
index c8bd295..d7e05d0 100644
--- a/drivers/staging/media/omap4iss/iss_video.h
+++ b/drivers/staging/media/omap4iss/iss_video.h
@@ -170,7 +170,6 @@ struct iss_video {
spinlock_t qlock;   /* protects dmaqueue and error */
struct list_head dmaqueue;
enum iss_video_dmaqueue_flags dmaqueue_flags;
-   struct vb2_alloc_ctx *alloc_ctx;
 
const struct iss_video_operations *ops;
 };
-- 
2.8.0.rc3

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

[PATCHv2 08/12] media/platform: convert drivers to use the new vb2_queue dev field

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

Stop using alloc_ctx and just fill in the device pointer.

Signed-off-by: Hans Verkuil 
Cc: Laurent Pinchart 
Cc: Mikhail Ulyanov 
Cc: Guennadi Liakhovetski 
Cc: Javier Martin 
Cc: Jonathan Corbet 
---
 drivers/media/platform/m2m-deinterlace.c| 15 ++-
 drivers/media/platform/marvell-ccic/mcam-core.c | 24 +---
 drivers/media/platform/marvell-ccic/mcam-core.h |  2 --
 drivers/media/platform/mx2_emmaprp.c| 17 +++--
 drivers/media/platform/omap3isp/ispvideo.c  | 12 ++--
 drivers/media/platform/omap3isp/ispvideo.h  |  1 -
 drivers/media/platform/rcar_jpu.c   | 22 --
 drivers/media/platform/sh_veu.c | 17 +++--
 drivers/media/platform/sh_vou.c | 14 ++
 9 files changed, 17 insertions(+), 107 deletions(-)

diff --git a/drivers/media/platform/m2m-deinterlace.c 
b/drivers/media/platform/m2m-deinterlace.c
index 7383818..15110ea 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -136,7 +136,6 @@ struct deinterlace_dev {
struct dma_chan *dma_chan;
 
struct v4l2_m2m_dev *m2m_dev;
-   struct vb2_alloc_ctx*alloc_ctx;
 };
 
 struct deinterlace_ctx {
@@ -820,8 +819,6 @@ static int deinterlace_queue_setup(struct vb2_queue *vq,
*nbuffers = count;
sizes[0] = size;
 
-   alloc_ctxs[0] = ctx->dev->alloc_ctx;
-
dprintk(ctx->dev, "get %d buffer(s) of size %d each.\n", count, size);
 
return 0;
@@ -874,6 +871,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
src_vq->ops = &deinterlace_qops;
src_vq->mem_ops = &vb2_dma_contig_memops;
src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+   src_vq->dev = ctx->dev->v4l2_dev.dev;
q_data[V4L2_M2M_SRC].fmt = &formats[0];
q_data[V4L2_M2M_SRC].width = 640;
q_data[V4L2_M2M_SRC].height = 480;
@@ -891,6 +889,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
dst_vq->ops = &deinterlace_qops;
dst_vq->mem_ops = &vb2_dma_contig_memops;
dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+   dst_vq->dev = ctx->dev->v4l2_dev.dev;
q_data[V4L2_M2M_DST].fmt = &formats[0];
q_data[V4L2_M2M_DST].width = 640;
q_data[V4L2_M2M_DST].height = 480;
@@ -1046,13 +1045,6 @@ static int deinterlace_probe(struct platform_device 
*pdev)
 
platform_set_drvdata(pdev, pcdev);
 
-   pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
-   if (IS_ERR(pcdev->alloc_ctx)) {
-   v4l2_err(&pcdev->v4l2_dev, "Failed to alloc vb2 context\n");
-   ret = PTR_ERR(pcdev->alloc_ctx);
-   goto err_ctx;
-   }
-
pcdev->m2m_dev = v4l2_m2m_init(&m2m_ops);
if (IS_ERR(pcdev->m2m_dev)) {
v4l2_err(&pcdev->v4l2_dev, "Failed to init mem2mem device\n");
@@ -1064,8 +1056,6 @@ static int deinterlace_probe(struct platform_device *pdev)
 
 err_m2m:
video_unregister_device(&pcdev->vfd);
-err_ctx:
-   vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx);
 unreg_dev:
v4l2_device_unregister(&pcdev->v4l2_dev);
 rel_dma:
@@ -1082,7 +1072,6 @@ static int deinterlace_remove(struct platform_device 
*pdev)
v4l2_m2m_release(pcdev->m2m_dev);
video_unregister_device(&pcdev->vfd);
v4l2_device_unregister(&pcdev->v4l2_dev);
-   vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx);
dma_release_channel(pcdev->dma_chan);
 
return 0;
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 9b878de..8a1f12d 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1059,10 +1059,6 @@ static int mcam_vb_queue_setup(struct vb2_queue *vq,
 
if (*nbufs < minbufs)
*nbufs = minbufs;
-   if (cam->buffer_mode == B_DMA_contig)
-   alloc_ctxs[0] = cam->vb_alloc_ctx;
-   else if (cam->buffer_mode == B_DMA_sg)
-   alloc_ctxs[0] = cam->vb_alloc_ctx_sg;
 
if (*num_planes)
return sizes[0] < size ? -EINVAL : 0;
@@ -1271,6 +1267,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ;
vq->buf_struct_size = sizeof(struct mcam_vb_buffer);
+   vq->dev = cam->dev;
INIT_LIST_HEAD(&cam->buffers);
switch (cam->buffer_mode) {
case B_DMA_contig:
@@ -1279,9 +1276,6 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
vq->mem_ops = &vb2_dma_contig_memops;
cam->dma_setup = mcam_ctlr_dma_contig;
cam->frame_complete = mcam_dma_contig_done;
-   cam->vb_alloc_ctx = vb2_dma_contig_init_ctx(cam->dev);

[PATCHv2 10/12] media/platform: convert drivers to use the new vb2_queue dev field

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

Stop using alloc_ctx and just fill in the device pointer.

Signed-off-by: Hans Verkuil 
Cc: Kyungmin Park 
Cc: Sylwester Nawrocki 
---
 drivers/media/platform/exynos-gsc/gsc-core.c | 11 +--
 drivers/media/platform/exynos-gsc/gsc-core.h |  1 -
 drivers/media/platform/exynos-gsc/gsc-m2m.c  |  6 +++---
 drivers/media/platform/s3c-camif/camif-capture.c |  3 +--
 drivers/media/platform/s3c-camif/camif-core.c| 11 +--
 drivers/media/platform/s3c-camif/camif-core.h|  2 --
 drivers/media/platform/s5p-g2d/g2d.c | 14 +++---
 drivers/media/platform/s5p-g2d/g2d.h |  1 -
 drivers/media/platform/s5p-jpeg/jpeg-core.c  | 18 --
 drivers/media/platform/s5p-jpeg/jpeg-core.h  |  2 --
 drivers/media/platform/s5p-tv/mixer.h|  2 --
 drivers/media/platform/s5p-tv/mixer_video.c  | 16 ++--
 12 files changed, 15 insertions(+), 72 deletions(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c 
b/drivers/media/platform/exynos-gsc/gsc-core.c
index c595723..58a92a1 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.c
+++ b/drivers/media/platform/exynos-gsc/gsc-core.c
@@ -1119,19 +1119,11 @@ static int gsc_probe(struct platform_device *pdev)
if (ret < 0)
goto err_m2m;
 
-   /* Initialize continious memory allocator */
-   gsc->alloc_ctx = vb2_dma_contig_init_ctx(dev);
-   if (IS_ERR(gsc->alloc_ctx)) {
-   ret = PTR_ERR(gsc->alloc_ctx);
-   goto err_pm;
-   }
-
dev_dbg(dev, "gsc-%d registered successfully\n", gsc->id);
 
pm_runtime_put(dev);
return 0;
-err_pm:
-   pm_runtime_put(dev);
+
 err_m2m:
gsc_unregister_m2m_device(gsc);
 err_v4l2:
@@ -1148,7 +1140,6 @@ static int gsc_remove(struct platform_device *pdev)
gsc_unregister_m2m_device(gsc);
v4l2_device_unregister(&gsc->v4l2_dev);
 
-   vb2_dma_contig_cleanup_ctx(gsc->alloc_ctx);
pm_runtime_disable(&pdev->dev);
gsc_clk_put(gsc);
 
diff --git a/drivers/media/platform/exynos-gsc/gsc-core.h 
b/drivers/media/platform/exynos-gsc/gsc-core.h
index ec4000c..5c48329 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.h
+++ b/drivers/media/platform/exynos-gsc/gsc-core.h
@@ -341,7 +341,6 @@ struct gsc_dev {
wait_queue_head_t   irq_queue;
struct gsc_m2m_device   m2m;
unsigned long   state;
-   struct vb2_alloc_ctx*alloc_ctx;
struct video_device vdev;
struct v4l2_device  v4l2_dev;
 };
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c 
b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index a600e32..622709c 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -227,10 +227,8 @@ static int gsc_m2m_queue_setup(struct vb2_queue *vq,
return -EINVAL;
 
*num_planes = frame->fmt->num_planes;
-   for (i = 0; i < frame->fmt->num_planes; i++) {
+   for (i = 0; i < frame->fmt->num_planes; i++)
sizes[i] = frame->payload[i];
-   allocators[i] = ctx->gsc_dev->alloc_ctx;
-   }
return 0;
 }
 
@@ -591,6 +589,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
src_vq->lock = &ctx->gsc_dev->lock;
+   src_vq->dev = &ctx->gsc_dev->pdev->dev;
 
ret = vb2_queue_init(src_vq);
if (ret)
@@ -605,6 +604,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
dst_vq->lock = &ctx->gsc_dev->lock;
+   dst_vq->dev = &ctx->gsc_dev->pdev->dev;
 
return vb2_queue_init(dst_vq);
 }
diff --git a/drivers/media/platform/s3c-camif/camif-capture.c 
b/drivers/media/platform/s3c-camif/camif-capture.c
index bd060ef..5eb5df1 100644
--- a/drivers/media/platform/s3c-camif/camif-capture.c
+++ b/drivers/media/platform/s3c-camif/camif-capture.c
@@ -440,7 +440,6 @@ static int queue_setup(struct vb2_queue *vq,
   unsigned int sizes[], void *allocators[])
 {
struct camif_vp *vp = vb2_get_drv_priv(vq);
-   struct camif_dev *camif = vp->camif;
struct camif_frame *frame = &vp->out_frame;
const struct camif_fmt *fmt = vp->out_fmt;
unsigned int size;
@@ -449,7 +448,6 @@ static int queue_setup(struct vb2_queue *vq,
return -EINVAL;
 
size = (frame->f_width * frame->f_height * fmt->depth) / 8;
-   allocators[0] = camif->alloc_ctx;
 
if (*num_planes)
return sizes[0] < size ? -EINVAL : 0;
@@ -1138,6 +1136,7 @@ int s3c_camif_register_video_node(struct camif_dev 
*camif, int idx)
q->drv_priv = vp;
 

[PATCHv2 07/12] media/platform: convert drivers to use the new vb2_queue dev field

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

Stop using alloc_ctx and just fill in the device pointer.

Signed-off-by: Hans Verkuil 
Cc: Fabien Dessenne 
Cc: Benoit Parrot 
Cc: Laurent Pinchart 
#
#total: 0 errors, 0 warnings, 10 lines checked
#
#Your patch has no obvious style problems and is ready for submission.
---
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c | 18 --
 drivers/media/platform/sti/bdisp/bdisp.h  |  2 --
 drivers/media/platform/ti-vpe/cal.c   | 15 +--
 drivers/media/platform/ti-vpe/vpe.c   | 20 
 drivers/media/platform/vsp1/vsp1_video.c  | 18 +++---
 drivers/media/platform/vsp1/vsp1_video.h  |  1 -
 drivers/media/platform/xilinx/xilinx-dma.c| 11 +--
 drivers/media/platform/xilinx/xilinx-dma.h|  2 --
 8 files changed, 13 insertions(+), 74 deletions(-)

diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c 
b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
index d12a419..b3e8b5a 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
@@ -439,7 +439,7 @@ static void bdisp_ctrls_delete(struct bdisp_ctx *ctx)
 
 static int bdisp_queue_setup(struct vb2_queue *vq,
 unsigned int *nb_buf, unsigned int *nb_planes,
-unsigned int sizes[], void *allocators[])
+unsigned int sizes[], void *alloc_ctxs[])
 {
struct bdisp_ctx *ctx = vb2_get_drv_priv(vq);
struct bdisp_frame *frame = ctx_get_frame(ctx, vq->type);
@@ -453,7 +453,6 @@ static int bdisp_queue_setup(struct vb2_queue *vq,
dev_err(ctx->bdisp_dev->dev, "Invalid format\n");
return -EINVAL;
}
-   allocators[0] = ctx->bdisp_dev->alloc_ctx;
 
if (*nb_planes)
return sizes[0] < frame->sizeimage ? -EINVAL : 0;
@@ -553,6 +552,7 @@ static int queue_init(void *priv,
src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
src_vq->lock = &ctx->bdisp_dev->lock;
+   src_vq->dev = ctx->bdisp_dev->v4l2_dev.dev;
 
ret = vb2_queue_init(src_vq);
if (ret)
@@ -567,6 +567,7 @@ static int queue_init(void *priv,
dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
dst_vq->lock = &ctx->bdisp_dev->lock;
+   dst_vq->dev = ctx->bdisp_dev->v4l2_dev.dev;
 
return vb2_queue_init(dst_vq);
 }
@@ -1269,8 +1270,6 @@ static int bdisp_remove(struct platform_device *pdev)
 
bdisp_hw_free_filters(bdisp->dev);
 
-   vb2_dma_contig_cleanup_ctx(bdisp->alloc_ctx);
-
pm_runtime_disable(&pdev->dev);
 
bdisp_debugfs_remove(bdisp);
@@ -1371,18 +1370,11 @@ static int bdisp_probe(struct platform_device *pdev)
goto err_dbg;
}
 
-   /* Continuous memory allocator */
-   bdisp->alloc_ctx = vb2_dma_contig_init_ctx(dev);
-   if (IS_ERR(bdisp->alloc_ctx)) {
-   ret = PTR_ERR(bdisp->alloc_ctx);
-   goto err_pm;
-   }
-
/* Filters */
if (bdisp_hw_alloc_filters(bdisp->dev)) {
dev_err(bdisp->dev, "no memory for filters\n");
ret = -ENOMEM;
-   goto err_vb2_dma;
+   goto err_pm;
}
 
/* Register */
@@ -1401,8 +1393,6 @@ static int bdisp_probe(struct platform_device *pdev)
 
 err_filter:
bdisp_hw_free_filters(bdisp->dev);
-err_vb2_dma:
-   vb2_dma_contig_cleanup_ctx(bdisp->alloc_ctx);
 err_pm:
pm_runtime_put(dev);
 err_dbg:
diff --git a/drivers/media/platform/sti/bdisp/bdisp.h 
b/drivers/media/platform/sti/bdisp/bdisp.h
index 0cf9857..b3fbf99 100644
--- a/drivers/media/platform/sti/bdisp/bdisp.h
+++ b/drivers/media/platform/sti/bdisp/bdisp.h
@@ -175,7 +175,6 @@ struct bdisp_dbg {
  * @id: device index
  * @m2m:memory-to-memory V4L2 device information
  * @state:  flags used to synchronize m2m and capture mode operation
- * @alloc_ctx:  videobuf2 memory allocator context
  * @clock:  IP clock
  * @regs:   registers
  * @irq_queue:  interrupt handler waitqueue
@@ -193,7 +192,6 @@ struct bdisp_dev {
u16 id;
struct bdisp_m2m_device m2m;
unsigned long   state;
-   struct vb2_alloc_ctx*alloc_ctx;
struct clk  *clock;
void __iomem*regs;
wait_queue_head_t   irq_queue;
diff --git a/drivers/media/platform/ti-vpe/cal.c 
b/drivers/media/platform/ti-vpe/cal.c
index 82001e6..51ebf32 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -287,7 +287,6 @@ struct cal_ctx {
/* Several counters */
unsigned long   jiffies;
 
-   struct vb2_alloc_ctx*alloc_ctx;
struct cal_dmaqueue vidq;
 
/* Input Number */
@@ -12

[PATCHv2 09/12] media/.../soc-camera: convert drivers to use the new vb2_queue dev field

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

Stop using alloc_ctx and just fill in the device pointer.

Signed-off-by: Hans Verkuil 
Cc: Guennadi Liakhovetski 
Cc: Ludovic Desroches 
Cc: Sergei Shtylyov 
---
 drivers/media/platform/soc_camera/atmel-isi.c   | 13 +
 drivers/media/platform/soc_camera/rcar_vin.c| 12 +---
 .../media/platform/soc_camera/sh_mobile_ceu_camera.c| 15 ++-
 drivers/staging/media/mx2/mx2_camera.c  | 17 +++--
 drivers/staging/media/mx3/mx3_camera.c  | 16 ++--
 5 files changed, 9 insertions(+), 64 deletions(-)

diff --git a/drivers/media/platform/soc_camera/atmel-isi.c 
b/drivers/media/platform/soc_camera/atmel-isi.c
index ab2d9b9..899b93a 100644
--- a/drivers/media/platform/soc_camera/atmel-isi.c
+++ b/drivers/media/platform/soc_camera/atmel-isi.c
@@ -72,8 +72,6 @@ struct atmel_isi {
 
int sequence;
 
-   struct vb2_alloc_ctx*alloc_ctx;
-
/* Allocate descriptors for dma buffer use */
struct fbd  *p_fb_descriptors;
dma_addr_t  fb_descriptors_phys;
@@ -322,7 +320,6 @@ static int queue_setup(struct vb2_queue *vq,
 
*nplanes = 1;
sizes[0] = size;
-   alloc_ctxs[0] = isi->alloc_ctx;
 
isi->sequence = 0;
isi->active = NULL;
@@ -567,6 +564,7 @@ static int isi_camera_init_videobuf(struct vb2_queue *q,
q->mem_ops = &vb2_dma_contig_memops;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &ici->host_lock;
+   q->dev = ici->v4l2_dev.dev;
 
return vb2_queue_init(q);
 }
@@ -963,7 +961,6 @@ static int atmel_isi_remove(struct platform_device *pdev)
struct atmel_isi, soc_host);
 
soc_camera_host_unregister(soc_host);
-   vb2_dma_contig_cleanup_ctx(isi->alloc_ctx);
dma_free_coherent(&pdev->dev,
sizeof(struct fbd) * MAX_BUFFER_NUM,
isi->p_fb_descriptors,
@@ -1067,12 +1064,6 @@ static int atmel_isi_probe(struct platform_device *pdev)
list_add(&isi->dma_desc[i].list, &isi->dma_desc_head);
}
 
-   isi->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
-   if (IS_ERR(isi->alloc_ctx)) {
-   ret = PTR_ERR(isi->alloc_ctx);
-   goto err_alloc_ctx;
-   }
-
regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
isi->regs = devm_ioremap_resource(&pdev->dev, regs);
if (IS_ERR(isi->regs)) {
@@ -1119,8 +1110,6 @@ err_register_soc_camera_host:
pm_runtime_disable(&pdev->dev);
 err_req_irq:
 err_ioremap:
-   vb2_dma_contig_cleanup_ctx(isi->alloc_ctx);
-err_alloc_ctx:
dma_free_coherent(&pdev->dev,
sizeof(struct fbd) * MAX_BUFFER_NUM,
isi->p_fb_descriptors,
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 3f9c1b8..dadc5b3 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -484,7 +484,6 @@ struct rcar_vin_priv {
struct list_headcapture;
 #define MAX_BUFFER_NUM 3
struct vb2_v4l2_buffer  *queue_buf[MAX_BUFFER_NUM];
-   struct vb2_alloc_ctx*alloc_ctx;
enum v4l2_field field;
unsigned intpdata_flags;
unsigned intvb_count;
@@ -540,8 +539,6 @@ static int rcar_vin_videobuf_setup(struct vb2_queue *vq,
struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
struct rcar_vin_priv *priv = ici->priv;
 
-   alloc_ctxs[0] = priv->alloc_ctx;
-
if (!vq->num_buffers)
priv->sequence = 0;
 
@@ -1816,6 +1813,7 @@ static int rcar_vin_init_videobuf2(struct vb2_queue *vq,
vq->buf_struct_size = sizeof(struct rcar_vin_buffer);
vq->timestamp_flags  = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
vq->lock = &ici->host_lock;
+   vq->dev = ici->v4l2_dev.dev;
 
return vb2_queue_init(vq);
 }
@@ -1912,10 +1910,6 @@ static int rcar_vin_probe(struct platform_device *pdev)
if (ret)
return ret;
 
-   priv->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
-   if (IS_ERR(priv->alloc_ctx))
-   return PTR_ERR(priv->alloc_ctx);
-
priv->ici.priv = priv;
priv->ici.v4l2_dev.dev = &pdev->dev;
priv->ici.drv_name = dev_name(&pdev->dev);
@@ -1946,7 +1940,6 @@ static int rcar_vin_probe(struct platform_device *pdev)
 
 cleanup:
pm_runtime_disable(&pdev->dev);
-   vb2_dma_contig_cleanup_ctx(priv->alloc_ctx);
 
return ret;
 }
@@ -1954,12 +1947,9 @@ cleanup:
 static int rcar_vin_remove(struct platform_device *pdev)
 {
struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev);
-   struct

[PATCHv2 04/12] media/pci: convert drivers to use the new vb2_queue dev field

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

Stop using alloc_ctx and just fill in the device pointer.

Signed-off-by: Hans Verkuil 
Cc: Federico Vaga 
Cc: Mauro Carvalho Chehab 
#
#total: 0 errors, 0 warnings, 16 lines checked
#
#Your patch has no obvious style problems and is ready for submission.
---
 drivers/media/pci/cobalt/cobalt-driver.c   |  9 -
 drivers/media/pci/cobalt/cobalt-driver.h   |  1 -
 drivers/media/pci/cobalt/cobalt-v4l2.c |  2 +-
 drivers/media/pci/cx23885/cx23885-417.c|  1 -
 drivers/media/pci/cx23885/cx23885-core.c   | 10 +-
 drivers/media/pci/cx23885/cx23885-dvb.c|  2 +-
 drivers/media/pci/cx23885/cx23885-vbi.c|  1 -
 drivers/media/pci/cx23885/cx23885-video.c  |  3 ++-
 drivers/media/pci/cx23885/cx23885.h|  1 -
 drivers/media/pci/cx25821/cx25821-core.c   | 10 +-
 drivers/media/pci/cx25821/cx25821-video.c  |  3 +--
 drivers/media/pci/cx25821/cx25821.h|  1 -
 drivers/media/pci/cx88/cx88-blackbird.c|  2 +-
 drivers/media/pci/cx88/cx88-dvb.c  |  2 +-
 drivers/media/pci/cx88/cx88-mpeg.c | 10 +-
 drivers/media/pci/cx88/cx88-vbi.c  |  1 -
 drivers/media/pci/cx88/cx88-video.c| 11 ++-
 drivers/media/pci/cx88/cx88.h  |  2 --
 drivers/media/pci/dt3155/dt3155.c  | 13 ++---
 drivers/media/pci/dt3155/dt3155.h  |  2 --
 drivers/media/pci/saa7134/saa7134-core.c   | 22 +++---
 drivers/media/pci/saa7134/saa7134-ts.c |  1 -
 drivers/media/pci/saa7134/saa7134-vbi.c|  1 -
 drivers/media/pci/saa7134/saa7134-video.c  |  3 ++-
 drivers/media/pci/saa7134/saa7134.h|  1 -
 drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | 11 +--
 drivers/media/pci/solo6x10/solo6x10-v4l2.c | 10 +-
 drivers/media/pci/solo6x10/solo6x10.h  |  2 --
 drivers/media/pci/sta2x11/sta2x11_vip.c| 18 ++
 drivers/media/pci/tw68/tw68-core.c | 15 +++
 drivers/media/pci/tw68/tw68-video.c|  2 +-
 drivers/media/pci/tw68/tw68.h  |  1 -
 32 files changed, 31 insertions(+), 143 deletions(-)

diff --git a/drivers/media/pci/cobalt/cobalt-driver.c 
b/drivers/media/pci/cobalt/cobalt-driver.c
index 8d6f04f..1aaa2b0 100644
--- a/drivers/media/pci/cobalt/cobalt-driver.c
+++ b/drivers/media/pci/cobalt/cobalt-driver.c
@@ -691,17 +691,10 @@ static int cobalt_probe(struct pci_dev *pci_dev,
cobalt->pci_dev = pci_dev;
cobalt->instance = i;
 
-   cobalt->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev);
-   if (IS_ERR(cobalt->alloc_ctx)) {
-   kfree(cobalt);
-   return -ENOMEM;
-   }
-
retval = v4l2_device_register(&pci_dev->dev, &cobalt->v4l2_dev);
if (retval) {
pr_err("cobalt: v4l2_device_register of card %d failed\n",
cobalt->instance);
-   vb2_dma_sg_cleanup_ctx(cobalt->alloc_ctx);
kfree(cobalt);
return retval;
}
@@ -782,7 +775,6 @@ err:
cobalt_err("error %d on initialization\n", retval);
 
v4l2_device_unregister(&cobalt->v4l2_dev);
-   vb2_dma_sg_cleanup_ctx(cobalt->alloc_ctx);
kfree(cobalt);
return retval;
 }
@@ -818,7 +810,6 @@ static void cobalt_remove(struct pci_dev *pci_dev)
cobalt_info("removed cobalt card\n");
 
v4l2_device_unregister(v4l2_dev);
-   vb2_dma_sg_cleanup_ctx(cobalt->alloc_ctx);
kfree(cobalt);
 }
 
diff --git a/drivers/media/pci/cobalt/cobalt-driver.h 
b/drivers/media/pci/cobalt/cobalt-driver.h
index b2f08e4..ed00dc9 100644
--- a/drivers/media/pci/cobalt/cobalt-driver.h
+++ b/drivers/media/pci/cobalt/cobalt-driver.h
@@ -262,7 +262,6 @@ struct cobalt {
int instance;
struct pci_dev *pci_dev;
struct v4l2_device v4l2_dev;
-   void *alloc_ctx;
 
void __iomem *bar0, *bar1;
 
diff --git a/drivers/media/pci/cobalt/cobalt-v4l2.c 
b/drivers/media/pci/cobalt/cobalt-v4l2.c
index c0ba458..6c19cdf 100644
--- a/drivers/media/pci/cobalt/cobalt-v4l2.c
+++ b/drivers/media/pci/cobalt/cobalt-v4l2.c
@@ -54,7 +54,6 @@ static int cobalt_queue_setup(struct vb2_queue *q,
*num_buffers = 3;
if (*num_buffers > NR_BUFS)
*num_buffers = NR_BUFS;
-   alloc_ctxs[0] = s->cobalt->alloc_ctx;
if (*num_planes)
return sizes[0] < size ? -EINVAL : 0;
*num_planes = 1;
@@ -1224,6 +1223,7 @@ static int cobalt_node_register(struct cobalt *cobalt, 
int node)
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->min_buffers_needed = 2;
q->lock = &s->lock;
+   q->dev = &cobalt->pci_dev->dev;
vdev->queue = q;
 
video_set_drvdata(vdev, s);
diff --git a/drivers/media/pci/cx23885/cx23885-417.c 
b/drivers/media/pci/cx23885/cx23885-417.c
index bd33387..0174d

[PATCHv2 12/12] vb2: replace void *alloc_ctxs by struct device *alloc_devs

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

Make this a proper typed array. Drop the old allocate context code since
that is no longer used.

Note that the memops functions now get a struct device pointer instead of
the struct device ** that was there initially (actually a void pointer to
a struct containing only a struct device pointer).

This code is now a lot cleaner.

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

[PATCHv2 11/12] media/platform: convert drivers to use the new vb2_queue dev field

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

Stop using alloc_ctx and just fill in the device pointer.

Signed-off-by: Hans Verkuil 
Cc: Kyungmin Park 
Cc: Sylwester Nawrocki 
---
 drivers/media/platform/exynos4-is/fimc-capture.c   |  7 ++-
 drivers/media/platform/exynos4-is/fimc-core.c  | 11 ---
 drivers/media/platform/exynos4-is/fimc-core.h  |  3 ---
 drivers/media/platform/exynos4-is/fimc-is.c| 13 +
 drivers/media/platform/exynos4-is/fimc-is.h|  2 --
 drivers/media/platform/exynos4-is/fimc-isp-video.c |  9 +++--
 drivers/media/platform/exynos4-is/fimc-isp.h   |  2 --
 drivers/media/platform/exynos4-is/fimc-lite.c  | 19 +++
 drivers/media/platform/exynos4-is/fimc-lite.h  |  2 --
 drivers/media/platform/exynos4-is/fimc-m2m.c   |  6 +++---
 drivers/media/platform/s5p-mfc/s5p_mfc.c   | 19 +--
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h|  2 --
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c   | 10 --
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c   | 14 +-
 14 files changed, 22 insertions(+), 97 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c 
b/drivers/media/platform/exynos4-is/fimc-capture.c
index bf47d3b..512b254 100644
--- a/drivers/media/platform/exynos4-is/fimc-capture.c
+++ b/drivers/media/platform/exynos4-is/fimc-capture.c
@@ -354,11 +354,9 @@ static int queue_setup(struct vb2_queue *vq,
if (*num_planes) {
if (*num_planes != fmt->memplanes)
return -EINVAL;
-   for (i = 0; i < *num_planes; i++) {
+   for (i = 0; i < *num_planes; i++)
if (sizes[i] < (wh * fmt->depth[i]) / 8)
return -EINVAL;
-   allocators[i] = ctx->fimc_dev->alloc_ctx;
-   }
return 0;
}
 
@@ -371,8 +369,6 @@ static int queue_setup(struct vb2_queue *vq,
sizes[i] = frame->payload[i];
else
sizes[i] = max_t(u32, size, frame->payload[i]);
-
-   allocators[i] = ctx->fimc_dev->alloc_ctx;
}
 
return 0;
@@ -1779,6 +1775,7 @@ static int fimc_register_capture_device(struct fimc_dev 
*fimc,
q->buf_struct_size = sizeof(struct fimc_vid_buffer);
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &fimc->lock;
+   q->dev = &fimc->pdev->dev;
 
ret = vb2_queue_init(q);
if (ret)
diff --git a/drivers/media/platform/exynos4-is/fimc-core.c 
b/drivers/media/platform/exynos4-is/fimc-core.c
index b1c1cea..a767c76 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.c
+++ b/drivers/media/platform/exynos4-is/fimc-core.c
@@ -1018,19 +1018,9 @@ static int fimc_probe(struct platform_device *pdev)
goto err_sd;
}
 
-   /* Initialize contiguous memory allocator */
-   fimc->alloc_ctx = vb2_dma_contig_init_ctx(dev);
-   if (IS_ERR(fimc->alloc_ctx)) {
-   ret = PTR_ERR(fimc->alloc_ctx);
-   goto err_gclk;
-   }
-
dev_dbg(dev, "FIMC.%d registered successfully\n", fimc->id);
return 0;
 
-err_gclk:
-   if (!pm_runtime_enabled(dev))
-   clk_disable(fimc->clock[CLK_GATE]);
 err_sd:
fimc_unregister_capture_subdev(fimc);
 err_sclk:
@@ -1123,7 +1113,6 @@ static int fimc_remove(struct platform_device *pdev)
pm_runtime_set_suspended(&pdev->dev);
 
fimc_unregister_capture_subdev(fimc);
-   vb2_dma_contig_cleanup_ctx(fimc->alloc_ctx);
 
clk_disable(fimc->clock[CLK_BUS]);
fimc_clk_put(fimc);
diff --git a/drivers/media/platform/exynos4-is/fimc-core.h 
b/drivers/media/platform/exynos4-is/fimc-core.h
index 6b74354..5615fef 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.h
+++ b/drivers/media/platform/exynos4-is/fimc-core.h
@@ -307,7 +307,6 @@ struct fimc_m2m_device {
  */
 struct fimc_vid_cap {
struct fimc_ctx *ctx;
-   struct vb2_alloc_ctx*alloc_ctx;
struct v4l2_subdev  subdev;
struct exynos_video_entity  ve;
struct media_padvd_pad;
@@ -417,7 +416,6 @@ struct fimc_ctx;
  * @m2m:   memory-to-memory V4L2 device information
  * @vid_cap:   camera capture device information
  * @state: flags used to synchronize m2m and capture mode operation
- * @alloc_ctx: videobuf2 memory allocator context
  * @pipeline:  fimc video capture pipeline data structure
  */
 struct fimc_dev {
@@ -436,7 +434,6 @@ struct fimc_dev {
struct fimc_m2m_device  m2m;
struct fimc_vid_cap vid_cap;
unsigned long   state;
-   struct vb2_alloc_ctx*alloc_ctx;
 };
 
 /**
diff --git a/drivers/media/platform/exynos4-is/fimc-is.c 
b/drivers/media/platform/exynos4-is/fimc-is.c
index 979c388..4456c84 100644
--- a/drivers/me

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

2016-04-15 Thread Hans Verkuil
Hi Tiffany,

Some more comments, most are trivial but I realized that you were basing this
patch on an older kernel and not the latest media_tree master branch.

That's a bit of a killer because otherwise I am very close to merging this.

> +static int vidioc_venc_s_ctrl(struct v4l2_ctrl *ctrl)
> +{
> + struct mtk_vcodec_ctx *ctx = ctrl_to_ctx(ctrl);
> + struct mtk_enc_params *p = &ctx->enc_params;
> + int ret = 0;
> +
> + switch (ctrl->id) {
> + case V4L2_CID_MPEG_VIDEO_BITRATE:
> + mtk_v4l2_debug(2, "V4L2_CID_MPEG_VIDEO_BITRATE val = %d",
> + ctrl->val);
> + p->bitrate = ctrl->val;
> + ctx->param_change |= MTK_ENCODE_PARAM_BITRATE;
> + break;
> + case V4L2_CID_MPEG_VIDEO_B_FRAMES:
> + mtk_v4l2_debug(2, "V4L2_CID_MPEG_VIDEO_B_FRAMES val = %d",
> + ctrl->val);
> + p->num_b_frame = ctrl->val;
> + break;
> + case V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE:
> + mtk_v4l2_debug(2, "V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE val = 
> %d",
> + ctrl->val);
> + p->rc_frame = ctrl->val;
> + break;
> + case V4L2_CID_MPEG_VIDEO_H264_MAX_QP:
> + mtk_v4l2_debug(2, "V4L2_CID_MPEG_VIDEO_H264_MAX_QP val = %d",
> + ctrl->val);
> + p->h264_max_qp = ctrl->val;
> + break;
> + case V4L2_CID_MPEG_VIDEO_HEADER_MODE:
> + mtk_v4l2_debug(2, "V4L2_CID_MPEG_VIDEO_HEADER_MODE val = %d",
> + ctrl->val);
> + p->seq_hdr_mode = ctrl->val;
> + break;
> + case V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE:
> + mtk_v4l2_debug(2, "V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE val = %d",
> + ctrl->val);
> + p->rc_mb = ctrl->val;
> + break;
> + case V4L2_CID_MPEG_VIDEO_H264_PROFILE:
> + mtk_v4l2_debug(2, "V4L2_CID_MPEG_VIDEO_H264_PROFILE val = %d",
> + ctrl->val);
> + p->h264_profile = ctrl->val;
> + break;
> + case V4L2_CID_MPEG_VIDEO_H264_LEVEL:
> + mtk_v4l2_debug(2, "V4L2_CID_MPEG_VIDEO_H264_LEVEL val = %d",
> + ctrl->val);
> + p->h264_level = ctrl->val;
> + break;
> + case V4L2_CID_MPEG_VIDEO_H264_I_PERIOD:
> + mtk_v4l2_debug(2, "V4L2_CID_MPEG_VIDEO_H264_I_PERIOD val = %d",
> +ctrl->val);
> + p->intra_period = ctrl->val;
> + ctx->param_change |= MTK_ENCODE_PARAM_INTRA_PERIOD;
> + break;
> + case V4L2_CID_MPEG_VIDEO_GOP_SIZE:
> + mtk_v4l2_debug(2, "V4L2_CID_MPEG_VIDEO_GOP_SIZE val = %d",
> +ctrl->val);
> + p->gop_size = ctrl->val;
> + ctx->param_change |= MTK_ENCODE_PARAM_GOP_SIZE;
> + break;
> + case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME:
> + mtk_v4l2_debug(2, "V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME");
> + p->force_intra = 1;
> + ctx->param_change |= MTK_ENCODE_PARAM_FORCE_INTRA;
> + break;
> + default:
> + mtk_v4l2_err("Unspport CID %d", ctrl->id);

Unspport -> Unsupported

But either remove this or make it a debug message.

I would just remove it.

> + ret = -EINVAL;
> + break;
> + }
> +
> + return ret;
> +}
> +
> +static const struct v4l2_ctrl_ops mtk_vcodec_enc_ctrl_ops = {
> + .s_ctrl = vidioc_venc_s_ctrl,
> +};
> +
> +static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, bool output_queue)
> +{
> + struct mtk_video_fmt *fmt;
> + int i, j = 0;
> +
> + for (i = 0; i < NUM_FORMATS; ++i) {
> + if (output_queue && mtk_video_formats[i].type != MTK_FMT_FRAME)
> + continue;
> + if (!output_queue && mtk_video_formats[i].type != MTK_FMT_ENC)
> + continue;
> +
> + if (j == f->index) {
> + fmt = &mtk_video_formats[i];
> + f->pixelformat = fmt->fourcc;
> + memset(f->reserved, 0, sizeof(f->reserved));
> + return 0;
> + }
> + ++j;
> + }
> +
> + return -EINVAL;
> +}
> +
> +static int vidioc_enum_framesizes(struct file *file, void *fh,
> +   struct v4l2_frmsizeenum *fsize)
> +{
> + int i = 0;
> +
> + if (fsize->index != 0)
> + return -EINVAL;
> +
> + for (i = 0; i < NUM_SUPPORTED_FRAMESIZE; ++i) {
> + if (fsize->pixel_format != mtk_venc_framesizes[i].fourcc)
> + continue;
> +
> + fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
> + fsize->stepwise = mtk_venc_framesizes[i].stepwise;
> + return 0;
> + }
> +
> + return -EINVAL;
> +}
> +
> +static int vidioc_enum_fmt_vid_cap_mplane(struct file *file, void *pirv,
> +

Re: [PATCH 3/7] [Media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-04-15 Thread Hans Verkuil
On 04/13/2016 02:01 PM, Tiffany Lin wrote:
> Add v4l2 layer decoder driver for MT8173
> 
> Signed-off-by: Tiffany Lin 
> ---
>  drivers/media/platform/mtk-vcodec/Makefile |   10 +-
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 1429 
> 
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |   81 ++
>  .../media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c |  469 +++
>  .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c  |  153 +++
>  .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h  |   28 +
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |   98 +-
>  drivers/media/platform/mtk-vcodec/vdec_drv_base.h  |   56 +
>  drivers/media/platform/mtk-vcodec/vdec_drv_if.c|  113 ++
>  drivers/media/platform/mtk-vcodec/vdec_drv_if.h|   93 ++
>  drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h   |   86 ++
>  11 files changed, 2596 insertions(+), 20 deletions(-)
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
>  create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_base.h
>  create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.c
>  create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.h
>  create mode 100644 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
> 
> diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
> b/drivers/media/platform/mtk-vcodec/Makefile
> index dc5cb00..4c8ed2f 100644
> --- a/drivers/media/platform/mtk-vcodec/Makefile
> +++ b/drivers/media/platform/mtk-vcodec/Makefile
> @@ -1,7 +1,13 @@
>  
>  
> -obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-enc.o mtk-vcodec-common.o
> -
> +obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dec.o \
> +mtk-vcodec-enc.o \
> +mtk-vcodec-common.o
> +
> +mtk-vcodec-dec-y := mtk_vcodec_dec_drv.o \
> + vdec_drv_if.o \
> + mtk_vcodec_dec.o \
> + mtk_vcodec_dec_pm.o \
>  
>  
>  mtk-vcodec-enc-y := venc/venc_vp8_if.o \
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> new file mode 100644
> index 000..0499413
> --- /dev/null
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> @@ -0,0 +1,1429 @@
> +/*
> +* Copyright (c) 2016 MediaTek Inc.
> +* Author: PC Chen 
> +* Tiffany Lin 
> +*
> +* This program is free software; you can redistribute it and/or modify
> +* it under the terms of the GNU General Public License version 2 as
> +* published by the Free Software Foundation.
> +*
> +* This program is distributed in the hope that it will be useful,
> +* but WITHOUT ANY WARRANTY; without even the implied warranty of
> +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +* GNU General Public License for more details.
> +*/
> +
> +#include 
> +#include 
> +#include 
> +
> +#include "mtk_vcodec_drv.h"
> +#include "mtk_vcodec_dec.h"
> +#include "mtk_vcodec_intr.h"
> +#include "mtk_vcodec_util.h"
> +#include "vdec_drv_if.h"
> +#include "mtk_vcodec_dec_pm.h"
> +
> +static struct mtk_video_fmt mtk_video_formats[] = {
> + {
> + .fourcc = V4L2_PIX_FMT_H264,
> + .type = MTK_FMT_DEC,
> + .num_planes = 1,
> + },
> + {
> + .fourcc = V4L2_PIX_FMT_VP8,
> + .type = MTK_FMT_DEC,
> + .num_planes = 1,
> + },
> + {
> + .fourcc = V4L2_PIX_FMT_VP9,
> + .type = MTK_FMT_DEC,
> + .num_planes = 1,
> + },
> + {
> + .fourcc = V4L2_PIX_FMT_MT21,
> + .type = MTK_FMT_FRAME,
> + .num_planes = 2,
> + },
> +};
> +#define OUT_FMT_IDX  0
> +#define CAP_FMT_IDX  3
> +
> +#define VCODEC_CAPABILITY_4K_DISABLED0x10
> +#define VCODEC_DEC_4K_CODED_WIDTH4096U
> +#define VCODEC_DEC_4K_CODED_HEIGHT   2304U
> +
> +#define MTK_VDEC_MIN_W   64U
> +#define MTK_VDEC_MIN_H   64U
> +#define MTK_VDEC_MAX_W   2048U
> +#define MTK_VDEC_MAX_H   1088U
> +#define DFT_CFG_WIDTHMTK_VDEC_MIN_W
> +#define DFT_CFG_HEIGHT   MTK_VDEC_MIN_H
> +
> +static const struct mtk_codec_framesizes mtk_vdec_framesizes[] = {
> + {
> + .fourcc = V4L2_PIX_FMT_H264,
> + .stepwise = {  MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
> + MTK_VDEC_MIN_H, MTK_VDEC_MAX_H, 16 },
> + },
> + {
> + .fourcc = V4L2_PIX_FMT_VP8,
> + .stepwise = {  MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
> + MTK_VDEC_MIN_H, MTK_VDEC_MAX_H, 16 },
> + },
> + {
> + .fourcc = V4L2_PIX_FMT_VP9,
> + .st

Re: tvp5150 regression after commit 9f924169c035

2016-04-15 Thread Tony Lindgren
* Javier Martinez Canillas  [160414 17:00]:
> On 04/14/2016 11:12 AM, Tony Lindgren wrote:
> > Is this with omap3 and does tvp5150 have a reset GPIO pin?
> 
> Yes, it's a DM3730 (OMAP3) and yes the tvp5150 (actually it's a tvp5151) has
> a reset pin that has to be toggled, along with a power-down pin for the chip
> to be in an operative state before accessing the I2C registers. That is the
> power/reset sequence I mentioned before.
>  
> > If so, you could be hitting the GPIO errata where a glitch can happen
> > when restoring the GPIO state coming back from off mode in idle. This
> > happes for GPIO pins that are not in GPIO bank1 and have an external
> > pull down resistor on the line.
> >
> 
> The GPIO lines connected to these pins are:
> 
> GPIO126 (bank4 pin 30) -> tvp5150 power-down pin
> GPIO167 (bank6 pin 7)  -> tvp5150 reset pin
> 
> Neither are in GPIO bank1 so they could be affected by the errata you
> mention but there isn't external pull down (or up) resistors on these
> lines AFAICT by looking at the board schematics. I've added to the cc
> list to other people that are familiar with the board in case I missed
> something.
> 
> > The short term workaround is to mux the reset pin to use the internal
> > pulls by using PIN_INPUT_PULLUP | MUX_MODE7, or depending on the direction,
> > PIN_INPUT_PULLDOWN | MUX_MODE7.
> 
> I guess you meant MUX_MODE4 here since the pin has to be in GPIO mode?

No, the glitch affects the GPIO mode, so that's why direction + pull +
safe mode is needed.

> Also, I wonder how the issue could be related to the GPIO controller
> since is when enabling runtime PM for the I2C controller that things
> fail. IOW, disabling runtime PM for the I2C adapter shouldn't make
> things to work if the problem was caused by the mentioned GPIO errata.

If you block PM runtime for I2C, then it blocks deeper idle states
for the whole device. Note that you can disable off mode during idle
and suspend with:

# echo 0 > /sys/kernel/debug/pm_debug/enable_off_mode

> In any case, I've tried to use the internal pulls as you suggested but
> that didn't solve the issue.

OK. Just to be sure.. Did you use the safe mode mux option instead
of the GPIO mux option?

Note that in some cases the internal pull is not strong enough to
keep the reset line up if there's an external pull down resistor.

Regards,

Tony
--
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/3] pvrusb2: fix smatch errors

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

These are false positives, but still easy to fix.

pvrusb2-hdw.c:3676 pvr2_send_request_ex() error: we previously assumed 
'write_data' could be null (see line 3648)
pvrusb2-hdw.c:3829 pvr2_send_request_ex() error: we previously assumed 
'read_data' could be null (see line 3649)

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c 
b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index 1a093e5..83e9a3e 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -3672,11 +3672,10 @@ static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
 
 
hdw->cmd_debug_state = 1;
-   if (write_len) {
+   if (write_len && write_data)
hdw->cmd_debug_code = ((unsigned char *)write_data)[0];
-   } else {
+   else
hdw->cmd_debug_code = 0;
-   }
hdw->cmd_debug_write_len = write_len;
hdw->cmd_debug_read_len = read_len;
 
@@ -3688,7 +3687,7 @@ static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
setup_timer(&timer, pvr2_ctl_timeout, (unsigned long)hdw);
timer.expires = jiffies + timeout;
 
-   if (write_len) {
+   if (write_len && write_data) {
hdw->cmd_debug_state = 2;
/* Transfer write data to internal buffer */
for (idx = 0; idx < write_len; idx++) {
@@ -3795,7 +3794,7 @@ static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
goto done;
}
}
-   if (read_len) {
+   if (read_len && read_data) {
/* Validate results of read request */
if ((hdw->ctl_read_urb->status != 0) &&
(hdw->ctl_read_urb->status != -ENOENT) &&
-- 
2.8.0.rc3

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


[PATCH 3/3] dib0090: fix smatch error

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

Fix this smatch error:

dib0090.c:1124 dib0090_pwm_gain_reset() error: we previously assumed 
'state->rf_ramp' could be null (see line 1086)

Signed-off-by: Hans Verkuil 
---
 drivers/media/dvb-frontends/dib0090.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/dib0090.c 
b/drivers/media/dvb-frontends/dib0090.c
index dc2d41e..d879dc0 100644
--- a/drivers/media/dvb-frontends/dib0090.c
+++ b/drivers/media/dvb-frontends/dib0090.c
@@ -1121,7 +1121,7 @@ void dib0090_pwm_gain_reset(struct dvb_frontend *fe)
(state->current_band == BAND_CBAND) ? "CBAND" : 
"NOT CBAND",
state->identity.version & 0x1f);
 
-   if (rf_ramp && ((state->rf_ramp[0] == 0) ||
+   if (rf_ramp && ((state->rf_ramp && state->rf_ramp[0] == 0) ||
(state->current_band == BAND_CBAND &&
(state->identity.version & 0x1f) <= P1D_E_F))) {
dprintk("DE-Engage mux for direct gain reg control");
-- 
2.8.0.rc3

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


[PATCH 1/3] vivid: fix smatch errors

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

The smatch utility got really confused about the grp % 22 code. Rewrote
it so it now understands that there really isn't a buffer overwrite.

vivid-rds-gen.c:82 vivid_rds_generate() error: buffer overflow 'rds->psname' 9 
<= 43
vivid-rds-gen.c:83 vivid_rds_generate() error: buffer overflow 'rds->psname' 9 
<= 42
vivid-rds-gen.c:89 vivid_rds_generate() error: buffer overflow 'rds->radiotext' 
65 <= 84
vivid-rds-gen.c:90 vivid_rds_generate() error: buffer overflow 'rds->radiotext' 
65 <= 85
vivid-rds-gen.c:92 vivid_rds_generate() error: buffer overflow 'rds->radiotext' 
65 <= 86
vivid-rds-gen.c:93 vivid_rds_generate() error: buffer overflow 'rds->radiotext' 
65 <= 87

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-rds-gen.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-rds-gen.c 
b/drivers/media/platform/vivid/vivid-rds-gen.c
index c382343..53c 100644
--- a/drivers/media/platform/vivid/vivid-rds-gen.c
+++ b/drivers/media/platform/vivid/vivid-rds-gen.c
@@ -55,6 +55,7 @@ void vivid_rds_generate(struct vivid_rds_gen *rds)
 {
struct v4l2_rds_data *data = rds->data;
unsigned grp;
+   unsigned idx;
struct tm tm;
unsigned date;
unsigned time;
@@ -73,24 +74,26 @@ void vivid_rds_generate(struct vivid_rds_gen *rds)
case 0 ... 3:
case 22 ... 25:
case 44 ... 47: /* Group 0B */
+   idx = (grp % 22) % 4;
data[1].lsb |= (rds->ta << 4) | (rds->ms << 3);
-   data[1].lsb |= vivid_get_di(rds, grp % 22);
+   data[1].lsb |= vivid_get_di(rds, idx);
data[1].msb |= 1 << 3;
data[2].lsb = rds->picode & 0xff;
data[2].msb = rds->picode >> 8;
data[2].block = V4L2_RDS_BLOCK_C_ALT | 
(V4L2_RDS_BLOCK_C_ALT << 3);
-   data[3].lsb = rds->psname[2 * (grp % 22) + 1];
-   data[3].msb = rds->psname[2 * (grp % 22)];
+   data[3].lsb = rds->psname[2 * idx + 1];
+   data[3].msb = rds->psname[2 * idx];
break;
case 4 ... 19:
case 26 ... 41: /* Group 2A */
-   data[1].lsb |= (grp - 4) % 22;
+   idx = ((grp - 4) % 22) % 16;
+   data[1].lsb |= idx;
data[1].msb |= 4 << 3;
-   data[2].msb = rds->radiotext[4 * ((grp - 4) % 22)];
-   data[2].lsb = rds->radiotext[4 * ((grp - 4) % 22) + 1];
+   data[2].msb = rds->radiotext[4 * idx];
+   data[2].lsb = rds->radiotext[4 * idx + 1];
data[2].block = V4L2_RDS_BLOCK_C | (V4L2_RDS_BLOCK_C << 
3);
-   data[3].msb = rds->radiotext[4 * ((grp - 4) % 22) + 2];
-   data[3].lsb = rds->radiotext[4 * ((grp - 4) % 22) + 3];
+   data[3].msb = rds->radiotext[4 * idx + 2];
+   data[3].lsb = rds->radiotext[4 * idx + 3];
break;
case 56:
/*
-- 
2.8.0.rc3

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


[PATCH] [media] af9035: fix for MXL5007T devices with I2C read issues

2016-04-15 Thread Alessandro Radicati
The MXL5007T tuner will lock-up on some devices after an I2C read
transaction.  This patch adds a kernel module parameter "no_read" to work
around this issue by inhibiting such operations and emulating a 0x00
response.  The workaround is applied automatically to USB product IDs known
to exhibit this flaw, unless the kernel module parameter is specified.

Signed-off-by: Alessandro Radicati 
---
 drivers/media/usb/dvb-usb-v2/af9035.c | 27 +++
 drivers/media/usb/dvb-usb-v2/af9035.h |  1 +
 2 files changed, 28 insertions(+)

diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c 
b/drivers/media/usb/dvb-usb-v2/af9035.c
index 2638e32..8225403 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -24,6 +24,10 @@
 /* Max transfer size done by I2C transfer functions */
 #define MAX_XFER_SIZE  64
 
+static int dvb_usb_af9035_no_read = -1;
+module_param_named(no_read, dvb_usb_af9035_no_read, int, 0644);
+MODULE_PARM_DESC(no_read, "Emulate I2C reads for devices that do not support 
them.");
+
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 static u16 af9035_checksum(const u8 *buf, size_t len)
@@ -348,6 +352,9 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
 
ret = af9035_rd_regs(d, reg, &msg[1].buf[0],
msg[1].len);
+   } else if (state->no_read) {
+   memset(msg[1].buf, 0, msg[1].len);
+   ret = 0;
} else {
/* I2C write + read */
u8 buf[MAX_XFER_SIZE];
@@ -421,6 +428,9 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
if (msg[0].len > 40) {
/* TODO: correct limits > 40 */
ret = -EOPNOTSUPP;
+   } else if (state->no_read) {
+   memset(msg[0].buf, 0, msg[0].len);
+   ret = 0;
} else {
/* I2C read */
u8 buf[5];
@@ -962,6 +972,23 @@ skip_eeprom:
state->af9033_config[i].clock = clock_lut_af9035[tmp];
}
 
+   /* Some MXL5007T devices cannot properly handle tuner I2C read ops. */
+   if (dvb_usb_af9035_no_read != -1) { /* Override with module param */
+   state->no_read = dvb_usb_af9035_no_read == 0 ? false : true;
+   } else {
+   switch (le16_to_cpu(d->udev->descriptor.idProduct)) {
+   case USB_PID_AVERMEDIA_A867:
+   case USB_PID_AVERMEDIA_TWINSTAR:
+   dev_info(&d->udev->dev,
+   "%s: Device may have issues with I2C read 
operations. Enabling fix.\n",
+   KBUILD_MODNAME);
+   state->no_read = true;
+   break;
+   default:
+   state->no_read = false;
+   }
+   }
+
return 0;
 
 err:
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.h 
b/drivers/media/usb/dvb-usb-v2/af9035.h
index df22001..a76dafa 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.h
+++ b/drivers/media/usb/dvb-usb-v2/af9035.h
@@ -62,6 +62,7 @@ struct state {
u8 chip_version;
u16 chip_type;
u8 dual_mode:1;
+   u8 no_read:1;
u16 eeprom_addr;
u8 af9033_i2c_addr[2];
struct af9033_config af9033_config[2];
-- 
2.5.0

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


Re: gstreamer: v4l2videodec plugin

2016-04-15 Thread Rob Clark
On Tue, Apr 12, 2016 at 4:57 AM, Stanimir Varbanov
 wrote:
> Hi Nicolas,
>
> On 04/11/2016 07:25 PM, Nicolas Dufresne wrote:
>> Le lundi 11 avril 2016 à 15:11 +0300, Stanimir Varbanov a écrit :
>>> adding gstreamer-devel
>>>
>>> On 04/11/2016 03:03 PM, Stanimir Varbanov wrote:

 Hi,

 I'm working on QCOM v4l2 video decoder/encoder driver and in order
 to
 test its functionalities I'm using gstreamer v4l2videodec plugin. I
 am
 able to use the v4l2videodec plugin with MMAP, now I want to try
 the
 dmabuf export from v4l2 and import dmabuf buffers to glimagesink. I
 upgraded gst to 1.7.91 so that I have the dmabuf support in
 glimagesink.
 Mesa version is 11.1.2.
>>
>> I'm very happy to see this report. So far, we only had report that this
>> element works on Freescale IMX.6 (CODA) and Exynos 4/5.
>
> In this context, I would be very happy to see v4l2videoenc merged soon :)
>
>>

 I'm using the following pipeline:

 GST_GL_PLATFORM=egl GST_GL_API=gles2 gst-launch-1.0 $GSTDEBUG
 $GSTFILESRC ! qtdemux name=m m.video_0 ! h264parse ! v4l2video32dec
 capture-io-mode=dmabuf ! glimagesink

 I stalled on this error:

 eglimagememory
 gsteglimagememory.c:473:gst_egl_image_memory_from_dmabuf:>>> llocator0>
 eglCreateImage failed: EGL_BAD_MATCH

 which in Mesa is:

 libEGL debug: EGL user error 0x3009 (EGL_BAD_MATCH) in
 dri2_create_image_khr_texture

 Do someone know how the dmabuf import is tested when the support
 has
 been added to glimagesink? Or some pointers how to continue with
 debugging?
>>
>> So far the DMABuf support in glimagesink has been tested on Intel/Mesa
>> and libMALI. There is work in progress in Gallium/Mesa, but until
>> recently there was no support for offset in imported buffer, which
>> would result in BAD_MATCH error. I cannot guaranty this is the exact
>> reason here, BAD_MATCH is used for a very wide variety of reason in
>> those extensions. The right place to dig into this issue would be
>> through the Mesa list and/or Mesa code. Find out what is missing for
>> you driver in Mesa and then I may help you further.
>
> I came down to these conditions
>
> https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/state_trackers/dri/dri2.c?h=11.2#n1063
>
> but I don't know how this is related. The gstreamer
> (gst_egl_image_memory_from_dmabuf) doesn't set this "level" so it will
> be zero.
>
>>
>> For the reference, the importation strategy we use in GStreamer has
>> been inspired of Kodi (xmbc). It consist of importing each YUV plane
>> seperatly using R8 and RG88 textures and doing the color conversion
>> using shaders. Though, if the frame is allocated as a single DMABuf,
>> this requires using offset to access the frame data, and that support
>
> Yep that is my case, the driver capture buffers has one plain, hence one
> dmabuf will be exported per buffer.
>
>> had only been recently added in Gallium base code and in Radeon driver
>> recently. I don't know if Freedreno, VC4 have that, and I know nouveau
>> don't.
>
> Rob, do we need to add something in Freedreno Gallium driver to handle
> dmabuf import?

The issue is probably the YUV format, which we cannot really deal with
properly in gallium..  it's a similar issue to multi-planer even if it
is in a single buffer.

The best way to handle this would be to import the same dmabuf fd
twice, with appropriate offsets, to create one GL_RED eglimage for Y
and one GL_RG eglimage for UV, and then combine them in shader in a
similar way to how you'd handle separate Y and UV planes..

BR,
-R

> --
> regards,
> Stan
--
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: gstreamer: v4l2videodec plugin

2016-04-15 Thread Nicolas Dufresne
Le vendredi 15 avril 2016 à 11:58 -0400, Rob Clark a écrit :
> The issue is probably the YUV format, which we cannot really deal
> with
> properly in gallium..  it's a similar issue to multi-planer even if
> it
> is in a single buffer.
> 
> The best way to handle this would be to import the same dmabuf fd
> twice, with appropriate offsets, to create one GL_RED eglimage for Y
> and one GL_RG eglimage for UV, and then combine them in shader in a
> similar way to how you'd handle separate Y and UV planes..

That's the strategy we use in GStreamer, as very few GL stack support
implicit color conversions. For that to work you need to implement the
"offset" field in winsys_handle, that was added recently, and make sure
you have R8 and RG88 support (usually this is just mapping).

cheers,
Nicolas

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


Re: tvp5150 regression after commit 9f924169c035

2016-04-15 Thread Javier Martinez Canillas
Hello Tony,

On 04/15/2016 10:58 AM, Tony Lindgren wrote:
>>
>>> The short term workaround is to mux the reset pin to use the internal
>>> pulls by using PIN_INPUT_PULLUP | MUX_MODE7, or depending on the direction,
>>> PIN_INPUT_PULLDOWN | MUX_MODE7.
>>
>> I guess you meant MUX_MODE4 here since the pin has to be in GPIO mode?
> 
> No, the glitch affects the GPIO mode, so that's why direction + pull +
> safe mode is needed.
>

Ah ok, thanks for the explanation and sorry for the confusion.
 
>> Also, I wonder how the issue could be related to the GPIO controller
>> since is when enabling runtime PM for the I2C controller that things
>> fail. IOW, disabling runtime PM for the I2C adapter shouldn't make
>> things to work if the problem was caused by the mentioned GPIO errata.
> 
> If you block PM runtime for I2C, then it blocks deeper idle states
> for the whole device. Note that you can disable off mode during idle

Thanks again for this clarification.

> and suspend with:
> 
> # echo 0 > /sys/kernel/debug/pm_debug/enable_off_mode
>

I see thought that enable_off_mode is 0 by default when booting the board:

# cat /sys/kernel/debug/pm_debug/enable_off_mode 
0

So if I understood your explanation correctly, that means that the glitch
should not happen for the GPIO pins since the machine doesn't enter into
deeper idle states that could cause the glitch from erratum 1.158?
 
>> In any case, I've tried to use the internal pulls as you suggested but
>> that didn't solve the issue.
> 
> OK. Just to be sure.. Did you use the safe mode mux option instead
> of the GPIO mux option?
>

No sorry, I tested with the GPIO mux mode before since I misunderstood
your previous email. But now I've tested with safe mode mux and didn't
make a difference (which was expected since off mode is disabled AFAIU). 
 
> Note that in some cases the internal pull is not strong enough to
> keep the reset line up if there's an external pull down resistor.
>

Yes, I got that from your previous email but as I mentioned, the lines
in the board don't have external pull resistors.
 
> Regards,
> 
> Tony
> 

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America
--
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: tvp5150 regression after commit 9f924169c035

2016-04-15 Thread Tony Lindgren
* Javier Martinez Canillas  [160415 09:50]:
> On 04/15/2016 10:58 AM, Tony Lindgren wrote:
> > If you block PM runtime for I2C, then it blocks deeper idle states
> > for the whole device. Note that you can disable off mode during idle
> 
> Thanks again for this clarification.
> 
> > and suspend with:
> > 
> > # echo 0 > /sys/kernel/debug/pm_debug/enable_off_mode
> >
> 
> I see thought that enable_off_mode is 0 by default when booting the board:
> 
> # cat /sys/kernel/debug/pm_debug/enable_off_mode 
> 0

OK so you're not hitting off mode then.

> So if I understood your explanation correctly, that means that the glitch
> should not happen for the GPIO pins since the machine doesn't enter into
> deeper idle states that could cause the glitch from erratum 1.158?

Correct. But you could still have a dependency to some other
device driver that stays active if I2C keeps the whole system
from hitting retention mode during idle.

Regards,

Tony

--
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 v6 01/24] i2c-mux: add common data for every i2c-mux instance

2016-04-15 Thread Peter Rosin
Wolfram Sang wrote:
> > > wonder even more if we couldn't supply num_adapters to i2c_mux_alloc()
> > > and reserve the memory statically. i2c busses are not
> > > dynamic/hot-pluggable so that should be good enough?
> > 
> > Yes, that would work, but it would take some restructuring in some of
> > the drivers that currently don't know how many child adapters they
> > are going to need when they call i2c_mux_alloc.
> 
> Which ones?

If you look at i2c-mux-reg.c, it currently allocates its private
struct regmux, then fills it with various platform things and then
when it knows how many children it needs it allocates them. After
v6 it first allocates a mux core and private struct regmux in one go
using i2c_mux_alloc, then continues in much the same way as before.

If the number of children is needed for the i2c_mux_alloc call, then
this is certainly doable, and it would probably not be all that bad,
but the simplest approach would probably be to allocate the private
struct regmux first, then dig through the platform data, then allocate
the mux core when the number of children is known. Which would still
be two allocations separated by the platform data dig.

So, your suggestion would basically move the mux core allocation
from generally being done early together with other private data to
later when the driver has figured out how many children it's going
to create.

The restructuring I thought about is needed if the intention of this
was to reduce number of allocations, but maybe you just wanted
what I described above? Because what I did in v6 and what you are
suggesting is quite similar in complexity, but your version has the
advantage of not having the need for realloc.

So, I have made this change locally (and the adapters->num_adapters
change) and I like it. I haven't even compile-tested it yet though,
but I'll get back when I have done some testing.

> > Because you thought about removing i2c_mux_reserve_adapters completely,
> > and not provide any means of adding more adapters than specified in
> > the i2c_mux_alloc call, right?
> 
> Yes. I assumed I2C to be static enough that such information is known in
> advance.
> 
> > > Ignoring the 80 char limit here makes the code more readable.
> > 
> > That is only true if you actually have more than 80 characters, so I don't
> > agree. Are you adamant about it? (I'm not)
> 
> No. Keep it if you prefer it.
> 
> > >> +EXPORT_SYMBOL_GPL(i2c_mux_one_adapter);
> > > 
> > > Are you sure the above function pays off? Its argument list is very
> > > complex and it doesn't save a lot of code. Having seperate calls is
> > > probably more understandable in drivers? Then again, I assume it makes
> > > the conversion of existing drivers easier.
> > 
> > I added it in v4, you can check earlier versions if you like. Without
> > it most gate-muxes (i.e. typically the muxes in drivers/media) grew
> > since the i2c_add_mux_adapter call got replaced by two calls, i.e.
> > i2c_mux_alloc followed by i2c_max_add_adapter, and coupled with
> > error checks made it look more complex than before. So, this wasn't
> > much of a cleanup from the point of those drivers.
> 
> Hmm, v3 didn't have the driver patches posted with it. Can you push it
> to your branch? I am also not too strong with this one, but having a
> look how it looks without would be nice.

Although I'm not sure what you meant by "driver patches", I have pushed
mux-core-and-locking-2 and mux-core-and-locking-3 to
https://github.com/peda-r/i2c-mux/ (note that these are the branches as
they where when I posted v2 and v3 to the list, i.e. w/o fixups)

Those early versions updated all drivers with each change, making each
patch big, so if that was what you meant by missing "driver patches" then
there simply were no driver patches.

If you meant the follow-up patches to relax locking in the media drivers
etc, I only compile-tested them using throwaway branches back then (if I
even had branches). So, I don't have anything ready to push, sorry.

Cheers,
Peter
--
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 for 4.6] davinci_vpfe: Revert "staging: media: davinci_vpfe: remove,unnecessary ret variable"

2016-04-15 Thread Greg Kroah-Hartman
On Fri, Apr 15, 2016 at 01:58:10PM +0200, Hans Verkuil wrote:
> This reverts commit afa5d19a2b5fbf0bbcce34f3613bce2bc9479bb7.
> 
> This patch is completely bogus and messed up the code big time.
> 
> I'm not sure what was intended, but this isn't it.
> 
> Cc: Thaissa Falbo 
> Cc: Greg Kroah-Hartman 
> ---
> 
> Greg, this patch was never seen by us. Can you redirect patches for 
> staging/media
> to the linux-media mailinglist? We'd like to stay on top of what is happening 
> there.

Ugh, you are right, sorry about this.  I'll try to forward this stuff
onward, my fault.

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


cron job: media_tree daily build: OK

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

Results of the daily build of media_tree:

date:   Sat Apr 16 04:00:25 CEST 2016
git branch: test
git hash:   ecb7b0183a89613c154d1bea48b494907efbf8f9
gcc version:i686-linux-gcc (GCC) 5.3.0
sparse version: v0.5.0-56-g7647c77
smatch version: v0.5.0-3413-g618cd5c
host hardware:  x86_64
host os:4.4.0-164

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

Detailed results are available here:

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

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Saturday.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