Re: [PATCHv5 05/13] media/pci: convert drivers to use the new vb2_queue dev field

2016-07-04 Thread Federico Vaga
Acked-by: Federico Vaga 

On Monday 27 June 2016 15:31:56 Hans Verkuil wrote:
> 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 
> ---
>  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
> -
>  drivers/staging/media/tw686x-kh/tw686x-kh-video.c | 10 +-
>  drivers/staging/media/tw686x-kh/tw686x-kh.h   |  1 -
>  34 files changed, 32 insertions(+), 153 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(_dev->dev);
> - if (IS_ERR(cobalt->alloc_ctx)) {
> - kfree(cobalt);
> - return -ENOMEM;
> - }
> -
>   retval = v4l2_device_register(_dev->dev, >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(>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..6c19cdfc
> 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 

Re: [PATCHv5 05/13] media/pci: convert drivers to use the new vb2_queue dev field

2016-07-01 Thread Ezequiel Garcia
On 01 Jul 11:55 AM, Hans Verkuil wrote:
> From 62ddd1aabe5672541055bc6de3c80ca1e3635729 Mon Sep 17 00:00:00 2001
> From: Hans Verkuil 
> Date: Mon, 15 Feb 2016 15:37:15 +0100
> Subject: [PATCH 05/13] media/pci: convert drivers to use the new vb2_queue dev
>  field
> 
> Stop using alloc_ctx and just fill in the device pointer.
> 
> Signed-off-by: Hans Verkuil 
> Cc: Federico Vaga 
> Cc: Mauro Carvalho Chehab 
> ---
> After rebasing the vb2: replace allocation context by device pointer patch 
> series I discovered
> that newly committed changes to tw686x required that driver to be updated as 
> well.
> This is the patch for that.

Reviewed-by: Ezequiel Garcia 

Thanks for the cleanup,
-- 
Ezequiel Garcia, VanguardiaSur
www.vanguardiasur.com.ar
--
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


[PATCHv5 05/13] media/pci: convert drivers to use the new vb2_queue dev field

2016-07-01 Thread Hans Verkuil
>From 62ddd1aabe5672541055bc6de3c80ca1e3635729 Mon Sep 17 00:00:00 2001
From: Hans Verkuil 
Date: Mon, 15 Feb 2016 15:37:15 +0100
Subject: [PATCH 05/13] media/pci: convert drivers to use the new vb2_queue dev
 field

Stop using alloc_ctx and just fill in the device pointer.

Signed-off-by: Hans Verkuil 
Cc: Federico Vaga 
Cc: Mauro Carvalho Chehab 
---
After rebasing the vb2: replace allocation context by device pointer patch 
series I discovered
that newly committed changes to tw686x required that driver to be updated as 
well.
This is the patch for that.
---
diff --git a/drivers/media/pci/tw686x/tw686x-video.c 
b/drivers/media/pci/tw686x/tw686x-video.c
index 0e839f6..d380a8d 100644
--- a/drivers/media/pci/tw686x/tw686x-video.c
+++ b/drivers/media/pci/tw686x/tw686x-video.c
@@ -177,24 +177,7 @@ static void tw686x_contig_buf_refill(struct 
tw686x_video_channel *vc,
vc->curr_bufs[pb] = NULL;
 }

-static void tw686x_contig_cleanup(struct tw686x_dev *dev)
-{
-   vb2_dma_contig_cleanup_ctx(dev->alloc_ctx);
-}
-
-static int tw686x_contig_setup(struct tw686x_dev *dev)
-{
-   dev->alloc_ctx = vb2_dma_contig_init_ctx(>pci_dev->dev);
-   if (IS_ERR(dev->alloc_ctx)) {
-   dev_err(>pci_dev->dev, "unable to init DMA context\n");
-   return PTR_ERR(dev->alloc_ctx);
-   }
-   return 0;
-}
-
 const struct tw686x_dma_ops contig_dma_ops = {
-   .setup  = tw686x_contig_setup,
-   .cleanup= tw686x_contig_cleanup,
.buf_refill = tw686x_contig_buf_refill,
.mem_ops= _dma_contig_memops,
.hw_dma_mode= TW686X_FRAME_MODE,
@@ -316,21 +299,10 @@ static int tw686x_sg_dma_alloc(struct 
tw686x_video_channel *vc,
return 0;
 }

-static void tw686x_sg_cleanup(struct tw686x_dev *dev)
-{
-   vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
-}
-
 static int tw686x_sg_setup(struct tw686x_dev *dev)
 {
unsigned int sg_table_size, pb, ch, channels;

-   dev->alloc_ctx = vb2_dma_sg_init_ctx(>pci_dev->dev);
-   if (IS_ERR(dev->alloc_ctx)) {
-   dev_err(>pci_dev->dev, "unable to init DMA context\n");
-   return PTR_ERR(dev->alloc_ctx);
-   }
-
if (is_second_gen(dev)) {
/*
 * TW6865/TW6869: each channel needs a pair of
@@ -360,7 +332,6 @@ static int tw686x_sg_setup(struct tw686x_dev *dev)

 const struct tw686x_dma_ops sg_dma_ops = {
.setup  = tw686x_sg_setup,
-   .cleanup= tw686x_sg_cleanup,
.alloc  = tw686x_sg_dma_alloc,
.free   = tw686x_sg_dma_free,
.buf_refill = tw686x_sg_buf_refill,
@@ -449,7 +420,6 @@ static int tw686x_queue_setup(struct vb2_queue *vq,
return 0;
}

-   alloc_ctxs[0] = vc->dev->alloc_ctx;
sizes[0] = szimage;
*nplanes = 1;
return 0;
@@ -1063,9 +1033,6 @@ void tw686x_video_free(struct tw686x_dev *dev)
for (pb = 0; pb < 2; pb++)
dev->dma_ops->free(vc, pb);
}
-
-   if (dev->dma_ops->cleanup)
-   dev->dma_ops->cleanup(dev);
 }

 int tw686x_video_init(struct tw686x_dev *dev)
@@ -1135,6 +1102,7 @@ int tw686x_video_init(struct tw686x_dev *dev)
vc->vidq.min_buffers_needed = 2;
vc->vidq.lock = >vb_mutex;
vc->vidq.gfp_flags = GFP_DMA32;
+   vc->vidq.dev = >pci_dev->dev;

err = vb2_queue_init(>vidq);
if (err) {
diff --git a/drivers/media/pci/tw686x/tw686x.h 
b/drivers/media/pci/tw686x/tw686x.h
index 35d7bc9..f24a2a9 100644
--- a/drivers/media/pci/tw686x/tw686x.h
+++ b/drivers/media/pci/tw686x/tw686x.h
@@ -106,7 +106,6 @@ struct tw686x_video_channel {

 struct tw686x_dma_ops {
int (*setup)(struct tw686x_dev *dev);
-   void (*cleanup)(struct tw686x_dev *dev);
int (*alloc)(struct tw686x_video_channel *vc, unsigned int pb);
void (*free)(struct tw686x_video_channel *vc, unsigned int pb);
void (*buf_refill)(struct tw686x_video_channel *vc, unsigned int pb);
@@ -132,8 +131,6 @@ struct tw686x_dev {
struct pci_dev *pci_dev;
__u32 __iomem *mmio;

-   void *alloc_ctx;
-
const struct tw686x_dma_ops *dma_ops;
struct tw686x_video_channel *video_channels;
struct tw686x_audio_channel *audio_channels;
--
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


[PATCHv5 05/13] media/pci: convert drivers to use the new vb2_queue dev field

2016-06-27 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 
---
 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 -
 drivers/staging/media/tw686x-kh/tw686x-kh-video.c | 10 +-
 drivers/staging/media/tw686x-kh/tw686x-kh.h   |  1 -
 34 files changed, 32 insertions(+), 153 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(_dev->dev);
-   if (IS_ERR(cobalt->alloc_ctx)) {
-   kfree(cobalt);
-   return -ENOMEM;
-   }
-
retval = v4l2_device_register(_dev->dev, >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(>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..6c19cdfc 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 = >lock;
+   q->dev = >pci_dev->dev;