Commit 2bc46b3a authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] 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: default avatarHans Verkuil <hans.verkuil@cisco.com>
Cc: Federico Vaga <federico.vaga@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 0e2f5118
...@@ -691,17 +691,10 @@ static int cobalt_probe(struct pci_dev *pci_dev, ...@@ -691,17 +691,10 @@ static int cobalt_probe(struct pci_dev *pci_dev,
cobalt->pci_dev = pci_dev; cobalt->pci_dev = pci_dev;
cobalt->instance = i; 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); retval = v4l2_device_register(&pci_dev->dev, &cobalt->v4l2_dev);
if (retval) { if (retval) {
pr_err("cobalt: v4l2_device_register of card %d failed\n", pr_err("cobalt: v4l2_device_register of card %d failed\n",
cobalt->instance); cobalt->instance);
vb2_dma_sg_cleanup_ctx(cobalt->alloc_ctx);
kfree(cobalt); kfree(cobalt);
return retval; return retval;
} }
...@@ -782,7 +775,6 @@ static int cobalt_probe(struct pci_dev *pci_dev, ...@@ -782,7 +775,6 @@ static int cobalt_probe(struct pci_dev *pci_dev,
cobalt_err("error %d on initialization\n", retval); cobalt_err("error %d on initialization\n", retval);
v4l2_device_unregister(&cobalt->v4l2_dev); v4l2_device_unregister(&cobalt->v4l2_dev);
vb2_dma_sg_cleanup_ctx(cobalt->alloc_ctx);
kfree(cobalt); kfree(cobalt);
return retval; return retval;
} }
...@@ -818,7 +810,6 @@ static void cobalt_remove(struct pci_dev *pci_dev) ...@@ -818,7 +810,6 @@ static void cobalt_remove(struct pci_dev *pci_dev)
cobalt_info("removed cobalt card\n"); cobalt_info("removed cobalt card\n");
v4l2_device_unregister(v4l2_dev); v4l2_device_unregister(v4l2_dev);
vb2_dma_sg_cleanup_ctx(cobalt->alloc_ctx);
kfree(cobalt); kfree(cobalt);
} }
......
...@@ -262,7 +262,6 @@ struct cobalt { ...@@ -262,7 +262,6 @@ struct cobalt {
int instance; int instance;
struct pci_dev *pci_dev; struct pci_dev *pci_dev;
struct v4l2_device v4l2_dev; struct v4l2_device v4l2_dev;
void *alloc_ctx;
void __iomem *bar0, *bar1; void __iomem *bar0, *bar1;
......
...@@ -54,7 +54,6 @@ static int cobalt_queue_setup(struct vb2_queue *q, ...@@ -54,7 +54,6 @@ static int cobalt_queue_setup(struct vb2_queue *q,
*num_buffers = 3; *num_buffers = 3;
if (*num_buffers > NR_BUFS) if (*num_buffers > NR_BUFS)
*num_buffers = NR_BUFS; *num_buffers = NR_BUFS;
alloc_ctxs[0] = s->cobalt->alloc_ctx;
if (*num_planes) if (*num_planes)
return sizes[0] < size ? -EINVAL : 0; return sizes[0] < size ? -EINVAL : 0;
*num_planes = 1; *num_planes = 1;
...@@ -1224,6 +1223,7 @@ static int cobalt_node_register(struct cobalt *cobalt, int node) ...@@ -1224,6 +1223,7 @@ static int cobalt_node_register(struct cobalt *cobalt, int node)
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->min_buffers_needed = 2; q->min_buffers_needed = 2;
q->lock = &s->lock; q->lock = &s->lock;
q->dev = &cobalt->pci_dev->dev;
vdev->queue = q; vdev->queue = q;
video_set_drvdata(vdev, s); video_set_drvdata(vdev, s);
......
...@@ -1148,7 +1148,6 @@ static int queue_setup(struct vb2_queue *q, ...@@ -1148,7 +1148,6 @@ static int queue_setup(struct vb2_queue *q,
dev->ts1.ts_packet_count = mpeglines; dev->ts1.ts_packet_count = mpeglines;
*num_planes = 1; *num_planes = 1;
sizes[0] = mpeglinesize * mpeglines; sizes[0] = mpeglinesize * mpeglines;
alloc_ctxs[0] = dev->alloc_ctx;
*num_buffers = mpegbufs; *num_buffers = mpegbufs;
return 0; return 0;
} }
......
...@@ -2005,14 +2005,9 @@ static int cx23885_initdev(struct pci_dev *pci_dev, ...@@ -2005,14 +2005,9 @@ static int cx23885_initdev(struct pci_dev *pci_dev,
err = pci_set_dma_mask(pci_dev, 0xffffffff); err = pci_set_dma_mask(pci_dev, 0xffffffff);
if (err) { if (err) {
printk("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name); printk("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name);
goto fail_context; goto fail_ctrl;
} }
dev->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev);
if (IS_ERR(dev->alloc_ctx)) {
err = PTR_ERR(dev->alloc_ctx);
goto fail_context;
}
err = request_irq(pci_dev->irq, cx23885_irq, err = request_irq(pci_dev->irq, cx23885_irq,
IRQF_SHARED, dev->name, dev); IRQF_SHARED, dev->name, dev);
if (err < 0) { if (err < 0) {
...@@ -2041,8 +2036,6 @@ static int cx23885_initdev(struct pci_dev *pci_dev, ...@@ -2041,8 +2036,6 @@ static int cx23885_initdev(struct pci_dev *pci_dev,
return 0; return 0;
fail_irq: fail_irq:
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
fail_context:
cx23885_dev_unregister(dev); cx23885_dev_unregister(dev);
fail_ctrl: fail_ctrl:
v4l2_ctrl_handler_free(hdl); v4l2_ctrl_handler_free(hdl);
...@@ -2068,7 +2061,6 @@ static void cx23885_finidev(struct pci_dev *pci_dev) ...@@ -2068,7 +2061,6 @@ static void cx23885_finidev(struct pci_dev *pci_dev)
pci_disable_device(pci_dev); pci_disable_device(pci_dev);
cx23885_dev_unregister(dev); cx23885_dev_unregister(dev);
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
v4l2_ctrl_handler_free(&dev->ctrl_handler); v4l2_ctrl_handler_free(&dev->ctrl_handler);
v4l2_device_unregister(v4l2_dev); v4l2_device_unregister(v4l2_dev);
kfree(dev); kfree(dev);
......
...@@ -102,7 +102,6 @@ static int queue_setup(struct vb2_queue *q, ...@@ -102,7 +102,6 @@ static int queue_setup(struct vb2_queue *q,
port->ts_packet_count = 32; port->ts_packet_count = 32;
*num_planes = 1; *num_planes = 1;
sizes[0] = port->ts_packet_size * port->ts_packet_count; sizes[0] = port->ts_packet_size * port->ts_packet_count;
alloc_ctxs[0] = port->dev->alloc_ctx;
*num_buffers = 32; *num_buffers = 32;
return 0; return 0;
} }
...@@ -2397,6 +2396,7 @@ int cx23885_dvb_register(struct cx23885_tsport *port) ...@@ -2397,6 +2396,7 @@ int cx23885_dvb_register(struct cx23885_tsport *port)
q->mem_ops = &vb2_dma_sg_memops; q->mem_ops = &vb2_dma_sg_memops;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &dev->lock; q->lock = &dev->lock;
q->dev = &dev->pci->dev;
err = vb2_queue_init(q); err = vb2_queue_init(q);
if (err < 0) if (err < 0)
......
...@@ -131,7 +131,6 @@ static int queue_setup(struct vb2_queue *q, ...@@ -131,7 +131,6 @@ static int queue_setup(struct vb2_queue *q,
lines = VBI_NTSC_LINE_COUNT; lines = VBI_NTSC_LINE_COUNT;
*num_planes = 1; *num_planes = 1;
sizes[0] = lines * VBI_LINE_LENGTH * 2; sizes[0] = lines * VBI_LINE_LENGTH * 2;
alloc_ctxs[0] = dev->alloc_ctx;
return 0; return 0;
} }
......
...@@ -341,7 +341,6 @@ static int queue_setup(struct vb2_queue *q, ...@@ -341,7 +341,6 @@ static int queue_setup(struct vb2_queue *q,
*num_planes = 1; *num_planes = 1;
sizes[0] = (dev->fmt->depth * dev->width * dev->height) >> 3; sizes[0] = (dev->fmt->depth * dev->width * dev->height) >> 3;
alloc_ctxs[0] = dev->alloc_ctx;
return 0; return 0;
} }
...@@ -1268,6 +1267,7 @@ int cx23885_video_register(struct cx23885_dev *dev) ...@@ -1268,6 +1267,7 @@ int cx23885_video_register(struct cx23885_dev *dev)
q->mem_ops = &vb2_dma_sg_memops; q->mem_ops = &vb2_dma_sg_memops;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &dev->lock; q->lock = &dev->lock;
q->dev = &dev->pci->dev;
err = vb2_queue_init(q); err = vb2_queue_init(q);
if (err < 0) if (err < 0)
...@@ -1284,6 +1284,7 @@ int cx23885_video_register(struct cx23885_dev *dev) ...@@ -1284,6 +1284,7 @@ int cx23885_video_register(struct cx23885_dev *dev)
q->mem_ops = &vb2_dma_sg_memops; q->mem_ops = &vb2_dma_sg_memops;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &dev->lock; q->lock = &dev->lock;
q->dev = &dev->pci->dev;
err = vb2_queue_init(q); err = vb2_queue_init(q);
if (err < 0) if (err < 0)
......
...@@ -430,7 +430,6 @@ struct cx23885_dev { ...@@ -430,7 +430,6 @@ struct cx23885_dev {
struct vb2_queue vb2_vidq; struct vb2_queue vb2_vidq;
struct cx23885_dmaqueue vbiq; struct cx23885_dmaqueue vbiq;
struct vb2_queue vb2_vbiq; struct vb2_queue vb2_vbiq;
void *alloc_ctx;
spinlock_t slock; spinlock_t slock;
......
...@@ -1301,15 +1301,10 @@ static int cx25821_initdev(struct pci_dev *pci_dev, ...@@ -1301,15 +1301,10 @@ static int cx25821_initdev(struct pci_dev *pci_dev,
goto fail_unregister_device; goto fail_unregister_device;
} }
dev->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev);
if (IS_ERR(dev->alloc_ctx)) {
err = PTR_ERR(dev->alloc_ctx);
goto fail_unregister_pci;
}
err = cx25821_dev_setup(dev); err = cx25821_dev_setup(dev);
if (err) if (err)
goto fail_free_ctx; goto fail_unregister_pci;
/* print pci info */ /* print pci info */
pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &dev->pci_rev); pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &dev->pci_rev);
...@@ -1340,8 +1335,6 @@ static int cx25821_initdev(struct pci_dev *pci_dev, ...@@ -1340,8 +1335,6 @@ static int cx25821_initdev(struct pci_dev *pci_dev,
pr_info("cx25821_initdev() can't get IRQ !\n"); pr_info("cx25821_initdev() can't get IRQ !\n");
cx25821_dev_unregister(dev); cx25821_dev_unregister(dev);
fail_free_ctx:
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
fail_unregister_pci: fail_unregister_pci:
pci_disable_device(pci_dev); pci_disable_device(pci_dev);
fail_unregister_device: fail_unregister_device:
...@@ -1365,7 +1358,6 @@ static void cx25821_finidev(struct pci_dev *pci_dev) ...@@ -1365,7 +1358,6 @@ static void cx25821_finidev(struct pci_dev *pci_dev)
free_irq(pci_dev->irq, dev); free_irq(pci_dev->irq, dev);
cx25821_dev_unregister(dev); cx25821_dev_unregister(dev);
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
v4l2_device_unregister(v4l2_dev); v4l2_device_unregister(v4l2_dev);
kfree(dev); kfree(dev);
} }
......
...@@ -148,8 +148,6 @@ static int cx25821_queue_setup(struct vb2_queue *q, ...@@ -148,8 +148,6 @@ static int cx25821_queue_setup(struct vb2_queue *q,
struct cx25821_channel *chan = q->drv_priv; struct cx25821_channel *chan = q->drv_priv;
unsigned size = (chan->fmt->depth * chan->width * chan->height) >> 3; unsigned size = (chan->fmt->depth * chan->width * chan->height) >> 3;
alloc_ctxs[0] = chan->dev->alloc_ctx;
if (*num_planes) if (*num_planes)
return sizes[0] < size ? -EINVAL : 0; return sizes[0] < size ? -EINVAL : 0;
...@@ -759,6 +757,7 @@ int cx25821_video_register(struct cx25821_dev *dev) ...@@ -759,6 +757,7 @@ int cx25821_video_register(struct cx25821_dev *dev)
q->mem_ops = &vb2_dma_sg_memops; q->mem_ops = &vb2_dma_sg_memops;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &dev->lock; q->lock = &dev->lock;
q->dev = &dev->pci->dev;
if (!is_output) { if (!is_output) {
err = vb2_queue_init(q); err = vb2_queue_init(q);
......
...@@ -249,7 +249,6 @@ struct cx25821_dev { ...@@ -249,7 +249,6 @@ struct cx25821_dev {
int hwrevision; int hwrevision;
/* used by cx25821-alsa */ /* used by cx25821-alsa */
struct snd_card *card; struct snd_card *card;
void *alloc_ctx;
u32 clk_freq; u32 clk_freq;
......
...@@ -647,7 +647,6 @@ static int queue_setup(struct vb2_queue *q, ...@@ -647,7 +647,6 @@ static int queue_setup(struct vb2_queue *q,
dev->ts_packet_size = 188 * 4; dev->ts_packet_size = 188 * 4;
dev->ts_packet_count = 32; dev->ts_packet_count = 32;
sizes[0] = dev->ts_packet_size * dev->ts_packet_count; sizes[0] = dev->ts_packet_size * dev->ts_packet_count;
alloc_ctxs[0] = dev->alloc_ctx;
return 0; return 0;
} }
...@@ -1183,6 +1182,7 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv) ...@@ -1183,6 +1182,7 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv)
q->mem_ops = &vb2_dma_sg_memops; q->mem_ops = &vb2_dma_sg_memops;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &core->lock; q->lock = &core->lock;
q->dev = &dev->pci->dev;
err = vb2_queue_init(q); err = vb2_queue_init(q);
if (err < 0) if (err < 0)
......
...@@ -92,7 +92,6 @@ static int queue_setup(struct vb2_queue *q, ...@@ -92,7 +92,6 @@ static int queue_setup(struct vb2_queue *q,
dev->ts_packet_size = 188 * 4; dev->ts_packet_size = 188 * 4;
dev->ts_packet_count = dvb_buf_tscnt; dev->ts_packet_count = dvb_buf_tscnt;
sizes[0] = dev->ts_packet_size * dev->ts_packet_count; sizes[0] = dev->ts_packet_size * dev->ts_packet_count;
alloc_ctxs[0] = dev->alloc_ctx;
*num_buffers = dvb_buf_tscnt; *num_buffers = dvb_buf_tscnt;
return 0; return 0;
} }
...@@ -1793,6 +1792,7 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv) ...@@ -1793,6 +1792,7 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
q->mem_ops = &vb2_dma_sg_memops; q->mem_ops = &vb2_dma_sg_memops;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &core->lock; q->lock = &core->lock;
q->dev = &dev->pci->dev;
err = vb2_queue_init(q); err = vb2_queue_init(q);
if (err < 0) if (err < 0)
......
...@@ -726,11 +726,6 @@ static int cx8802_probe(struct pci_dev *pci_dev, ...@@ -726,11 +726,6 @@ static int cx8802_probe(struct pci_dev *pci_dev,
if (NULL == dev) if (NULL == dev)
goto fail_core; goto fail_core;
dev->pci = pci_dev; dev->pci = pci_dev;
dev->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev);
if (IS_ERR(dev->alloc_ctx)) {
err = PTR_ERR(dev->alloc_ctx);
goto fail_dev;
}
dev->core = core; dev->core = core;
/* Maintain a reference so cx88-video can query the 8802 device. */ /* Maintain a reference so cx88-video can query the 8802 device. */
...@@ -738,7 +733,7 @@ static int cx8802_probe(struct pci_dev *pci_dev, ...@@ -738,7 +733,7 @@ static int cx8802_probe(struct pci_dev *pci_dev,
err = cx8802_init_common(dev); err = cx8802_init_common(dev);
if (err != 0) if (err != 0)
goto fail_free; goto fail_dev;
INIT_LIST_HEAD(&dev->drvlist); INIT_LIST_HEAD(&dev->drvlist);
mutex_lock(&cx8802_mutex); mutex_lock(&cx8802_mutex);
...@@ -749,8 +744,6 @@ static int cx8802_probe(struct pci_dev *pci_dev, ...@@ -749,8 +744,6 @@ static int cx8802_probe(struct pci_dev *pci_dev,
request_modules(dev); request_modules(dev);
return 0; return 0;
fail_free:
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
fail_dev: fail_dev:
kfree(dev); kfree(dev);
fail_core: fail_core:
...@@ -798,7 +791,6 @@ static void cx8802_remove(struct pci_dev *pci_dev) ...@@ -798,7 +791,6 @@ static void cx8802_remove(struct pci_dev *pci_dev)
/* common */ /* common */
cx8802_fini_common(dev); cx8802_fini_common(dev);
cx88_core_put(dev->core,dev->pci); cx88_core_put(dev->core,dev->pci);
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
kfree(dev); kfree(dev);
} }
......
...@@ -118,7 +118,6 @@ static int queue_setup(struct vb2_queue *q, ...@@ -118,7 +118,6 @@ static int queue_setup(struct vb2_queue *q,
sizes[0] = VBI_LINE_NTSC_COUNT * VBI_LINE_LENGTH * 2; sizes[0] = VBI_LINE_NTSC_COUNT * VBI_LINE_LENGTH * 2;
else else
sizes[0] = VBI_LINE_PAL_COUNT * VBI_LINE_LENGTH * 2; sizes[0] = VBI_LINE_PAL_COUNT * VBI_LINE_LENGTH * 2;
alloc_ctxs[0] = dev->alloc_ctx;
return 0; return 0;
} }
......
...@@ -438,7 +438,6 @@ static int queue_setup(struct vb2_queue *q, ...@@ -438,7 +438,6 @@ static int queue_setup(struct vb2_queue *q,
*num_planes = 1; *num_planes = 1;
sizes[0] = (dev->fmt->depth * core->width * core->height) >> 3; sizes[0] = (dev->fmt->depth * core->width * core->height) >> 3;
alloc_ctxs[0] = dev->alloc_ctx;
return 0; return 0;
} }
...@@ -1319,12 +1318,6 @@ static int cx8800_initdev(struct pci_dev *pci_dev, ...@@ -1319,12 +1318,6 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
printk("%s/0: Oops: no 32bit PCI DMA ???\n",core->name); printk("%s/0: Oops: no 32bit PCI DMA ???\n",core->name);
goto fail_core; goto fail_core;
} }
dev->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev);
if (IS_ERR(dev->alloc_ctx)) {
err = PTR_ERR(dev->alloc_ctx);
goto fail_core;
}
/* initialize driver struct */ /* initialize driver struct */
spin_lock_init(&dev->slock); spin_lock_init(&dev->slock);
...@@ -1445,6 +1438,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev, ...@@ -1445,6 +1438,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
q->mem_ops = &vb2_dma_sg_memops; q->mem_ops = &vb2_dma_sg_memops;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &core->lock; q->lock = &core->lock;
q->dev = &dev->pci->dev;
err = vb2_queue_init(q); err = vb2_queue_init(q);
if (err < 0) if (err < 0)
...@@ -1461,6 +1455,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev, ...@@ -1461,6 +1455,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
q->mem_ops = &vb2_dma_sg_memops; q->mem_ops = &vb2_dma_sg_memops;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &core->lock; q->lock = &core->lock;
q->dev = &dev->pci->dev;
err = vb2_queue_init(q); err = vb2_queue_init(q);
if (err < 0) if (err < 0)
...@@ -1530,7 +1525,6 @@ static int cx8800_initdev(struct pci_dev *pci_dev, ...@@ -1530,7 +1525,6 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
free_irq(pci_dev->irq, dev); free_irq(pci_dev->irq, dev);
mutex_unlock(&core->lock); mutex_unlock(&core->lock);
fail_core: fail_core:
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
core->v4ldev = NULL; core->v4ldev = NULL;
cx88_core_put(core,dev->pci); cx88_core_put(core,dev->pci);
fail_free: fail_free:
...@@ -1564,7 +1558,6 @@ static void cx8800_finidev(struct pci_dev *pci_dev) ...@@ -1564,7 +1558,6 @@ static void cx8800_finidev(struct pci_dev *pci_dev)
/* free memory */ /* free memory */
cx88_core_put(core,dev->pci); cx88_core_put(core,dev->pci);
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
kfree(dev); kfree(dev);
} }
......
...@@ -485,7 +485,6 @@ struct cx8800_dev { ...@@ -485,7 +485,6 @@ struct cx8800_dev {
/* pci i/o */ /* pci i/o */
struct pci_dev *pci; struct pci_dev *pci;
unsigned char pci_rev,pci_lat; unsigned char pci_rev,pci_lat;
void *alloc_ctx;
const struct cx8800_fmt *fmt; const struct cx8800_fmt *fmt;
...@@ -549,7 +548,6 @@ struct cx8802_dev { ...@@ -549,7 +548,6 @@ struct cx8802_dev {
/* pci i/o */ /* pci i/o */
struct pci_dev *pci; struct pci_dev *pci;
unsigned char pci_rev,pci_lat; unsigned char pci_rev,pci_lat;
void *alloc_ctx;
/* dma queues */ /* dma queues */
struct cx88_dmaqueue mpegq; struct cx88_dmaqueue mpegq;
......
...@@ -141,7 +141,6 @@ dt3155_queue_setup(struct vb2_queue *vq, ...@@ -141,7 +141,6 @@ dt3155_queue_setup(struct vb2_queue *vq,
if (vq->num_buffers + *nbuffers < 2) if (vq->num_buffers + *nbuffers < 2)
*nbuffers = 2 - vq->num_buffers; *nbuffers = 2 - vq->num_buffers;
alloc_ctxs[0] = pd->alloc_ctx;
if (*num_planes) if (*num_planes)
return sizes[0] < size ? -EINVAL : 0; return sizes[0] < size ? -EINVAL : 0;
*num_planes = 1; *num_planes = 1;
...@@ -544,21 +543,16 @@ static int dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -544,21 +543,16 @@ static int dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)
pd->vidq.min_buffers_needed = 2; pd->vidq.min_buffers_needed = 2;
pd->vidq.gfp_flags = GFP_DMA32; pd->vidq.gfp_flags = GFP_DMA32;
pd->vidq.lock = &pd->mux; /* for locking v4l2_file_operations */ pd->vidq.lock = &pd->mux; /* for locking v4l2_file_operations */
pd->vidq.dev = &pdev->dev;
pd->vdev.queue = &pd->vidq; pd->vdev.queue = &pd->vidq;
err = vb2_queue_init(&pd->vidq); err = vb2_queue_init(&pd->vidq);
if (err < 0) if (err < 0)
goto err_v4l2_dev_unreg; goto err_v4l2_dev_unreg;
pd->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
if (IS_ERR(pd->alloc_ctx)) {
dev_err(&pdev->dev, "Can't allocate buffer context");
err = PTR_ERR(pd->alloc_ctx);
goto err_v4l2_dev_unreg;
}
spin_lock_init(&pd->lock); spin_lock_init(&pd->lock);
pd->config = ACQ_MODE_EVEN; pd->config = ACQ_MODE_EVEN;
err = pci_enable_device(pdev); err = pci_enable_device(pdev);
if (err) if (err)
goto err_free_ctx; goto err_v4l2_dev_unreg;
err = pci_request_region(pdev, 0, pci_name(pdev)); err = pci_request_region(pdev, 0, pci_name(pdev));
if (err) if (err)
goto err_pci_disable; goto err_pci_disable;
...@@ -588,8 +582,6 @@ static int dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -588,8 +582,6 @@ static int dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)
pci_release_region(pdev, 0); pci_release_region(pdev, 0);
err_pci_disable: err_pci_disable:
pci_disable_device(pdev); pci_disable_device(pdev);
err_free_ctx:
vb2_dma_contig_cleanup_ctx(pd->alloc_ctx);
err_v4l2_dev_unreg: err_v4l2_dev_unreg:
v4l2_device_unregister(&pd->v4l2_dev); v4l2_device_unregister(&pd->v4l2_dev);
return err; return err;
...@@ -608,7 +600,6 @@ static void dt3155_remove(struct pci_dev *pdev) ...@@ -608,7 +600,6 @@ static void dt3155_remove(struct pci_dev *pdev)
pci_iounmap(pdev, pd->regs); pci_iounmap(pdev, pd->regs);
pci_release_region(pdev, 0); pci_release_region(pdev, 0);
pci_disable_device(pdev); pci_disable_device(pdev);
vb2_dma_contig_cleanup_ctx(pd->alloc_ctx);
} }
static const struct pci_device_id pci_ids[] = { static const struct pci_device_id pci_ids[] = {
......
...@@ -161,7 +161,6 @@ ...@@ -161,7 +161,6 @@
* @vdev: video_device structure * @vdev: video_device structure
* @pdev: pointer to pci_dev structure * @pdev: pointer to pci_dev structure
* @vidq: vb2_queue structure * @vidq: vb2_queue structure
* @alloc_ctx: dma_contig allocation context
* @curr_buf: pointer to curren buffer * @curr_buf: pointer to curren buffer
* @mux: mutex to protect the instance * @mux: mutex to protect the instance
* @dmaq: queue for dma buffers * @dmaq: queue for dma buffers
...@@ -181,7 +180,6 @@ struct dt3155_priv { ...@@ -181,7 +180,6 @@ struct dt3155_priv {
struct video_device vdev; struct video_device vdev;
struct pci_dev *pdev; struct pci_dev *pdev;
struct vb2_queue vidq; struct vb2_queue vidq;
struct vb2_alloc_ctx *alloc_ctx;
struct vb2_v4l2_buffer *curr_buf; struct vb2_v4l2_buffer *curr_buf;
struct mutex mux; struct mutex mux;
struct list_head dmaq; struct list_head dmaq;
......
...@@ -1164,18 +1164,13 @@ static int saa7134_initdev(struct pci_dev *pci_dev, ...@@ -1164,18 +1164,13 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
saa7134_board_init1(dev); saa7134_board_init1(dev);
saa7134_hwinit1(dev); saa7134_hwinit1(dev);
dev->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev);
if (IS_ERR(dev->alloc_ctx)) {
err = PTR_ERR(dev->alloc_ctx);
goto fail3;
}
/* get irq */ /* get irq */
err = request_irq(pci_dev->irq, saa7134_irq, err = request_irq(pci_dev->irq, saa7134_irq,
IRQF_SHARED, dev->name, dev); IRQF_SHARED, dev->name, dev);
if (err < 0) { if (err < 0) {
pr_err("%s: can't get IRQ %d\n", pr_err("%s: can't get IRQ %d\n",
dev->name,pci_dev->irq); dev->name,pci_dev->irq);
goto fail4; goto fail3;
} }
/* wait a bit, register i2c bus */ /* wait a bit, register i2c bus */
...@@ -1233,7 +1228,7 @@ static int saa7134_initdev(struct pci_dev *pci_dev, ...@@ -1233,7 +1228,7 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
if (err < 0) { if (err < 0) {
pr_info("%s: can't register video device\n", pr_info("%s: can't register video device\n",
dev->name); dev->name);
goto fail5; goto fail4;
} }
pr_info("%s: registered device %s [v4l2]\n", pr_info("%s: registered device %s [v4l2]\n",
dev->name, video_device_node_name(dev->video_dev)); dev->name, video_device_node_name(dev->video_dev));
...@@ -1246,7 +1241,7 @@ static int saa7134_initdev(struct pci_dev *pci_dev, ...@@ -1246,7 +1241,7 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI, err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI,
vbi_nr[dev->nr]); vbi_nr[dev->nr]);
if (err < 0) if (err < 0)
goto fail5; goto fail4;
pr_info("%s: registered device %s\n", pr_info("%s: registered device %s\n",
dev->name, video_device_node_name(dev->vbi_dev)); dev->name, video_device_node_name(dev->vbi_dev));
...@@ -1257,7 +1252,7 @@ static int saa7134_initdev(struct pci_dev *pci_dev, ...@@ -1257,7 +1252,7 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO, err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO,
radio_nr[dev->nr]); radio_nr[dev->nr]);
if (err < 0) if (err < 0)
goto fail5; goto fail4;
pr_info("%s: registered device %s\n", pr_info("%s: registered device %s\n",
dev->name, video_device_node_name(dev->radio_dev)); dev->name, video_device_node_name(dev->radio_dev));
} }
...@@ -1268,7 +1263,7 @@ static int saa7134_initdev(struct pci_dev *pci_dev, ...@@ -1268,7 +1263,7 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
err = v4l2_mc_create_media_graph(dev->media_dev); err = v4l2_mc_create_media_graph(dev->media_dev);
if (err) { if (err) {
pr_err("failed to create media graph\n"); pr_err("failed to create media graph\n");
goto fail5; goto fail4;
} }
#endif #endif
/* everything worked */ /* everything worked */
...@@ -1287,17 +1282,15 @@ static int saa7134_initdev(struct pci_dev *pci_dev, ...@@ -1287,17 +1282,15 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
#ifdef CONFIG_MEDIA_CONTROLLER #ifdef CONFIG_MEDIA_CONTROLLER
err = media_device_register(dev->media_dev); err = media_device_register(dev->media_dev);
if (err) if (err)
goto fail5; goto fail4;
#endif #endif
return 0; return 0;
fail5: fail4:
saa7134_unregister_video(dev); saa7134_unregister_video(dev);
saa7134_i2c_unregister(dev); saa7134_i2c_unregister(dev);
free_irq(pci_dev->irq, dev); free_irq(pci_dev->irq, dev);
fail4:
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
fail3: fail3:
saa7134_hwfini(dev); saa7134_hwfini(dev);
iounmap(dev->lmmio); iounmap(dev->lmmio);
...@@ -1367,7 +1360,6 @@ static void saa7134_finidev(struct pci_dev *pci_dev) ...@@ -1367,7 +1360,6 @@ static void saa7134_finidev(struct pci_dev *pci_dev)
/* release resources */ /* release resources */
free_irq(pci_dev->irq, dev); free_irq(pci_dev->irq, dev);
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
iounmap(dev->lmmio); iounmap(dev->lmmio);
release_mem_region(pci_resource_start(pci_dev,0), release_mem_region(pci_resource_start(pci_dev,0),
pci_resource_len(pci_dev,0)); pci_resource_len(pci_dev,0));
......
...@@ -131,7 +131,6 @@ int saa7134_ts_queue_setup(struct vb2_queue *q, ...@@ -131,7 +131,6 @@ int saa7134_ts_queue_setup(struct vb2_queue *q,
*nbuffers = 3; *nbuffers = 3;
*nplanes = 1; *nplanes = 1;
sizes[0] = size; sizes[0] = size;
alloc_ctxs[0] = dev->alloc_ctx;
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(saa7134_ts_queue_setup); EXPORT_SYMBOL_GPL(saa7134_ts_queue_setup);
......
...@@ -155,7 +155,6 @@ static int queue_setup(struct vb2_queue *q, ...@@ -155,7 +155,6 @@ static int queue_setup(struct vb2_queue *q,
*nbuffers = saa7134_buffer_count(size, *nbuffers); *nbuffers = saa7134_buffer_count(size, *nbuffers);
*nplanes = 1; *nplanes = 1;
sizes[0] = size; sizes[0] = size;
alloc_ctxs[0] = dev->alloc_ctx;
return 0; return 0;
} }
......
...@@ -980,7 +980,6 @@ static int queue_setup(struct vb2_queue *q, ...@@ -980,7 +980,6 @@ static int queue_setup(struct vb2_queue *q,
*nbuffers = saa7134_buffer_count(size, *nbuffers); *nbuffers = saa7134_buffer_count(size, *nbuffers);
*nplanes = 1; *nplanes = 1;
sizes[0] = size; sizes[0] = size;
alloc_ctxs[0] = dev->alloc_ctx;
saa7134_enable_analog_tuner(dev); saa7134_enable_analog_tuner(dev);
...@@ -2173,6 +2172,7 @@ int saa7134_video_init1(struct saa7134_dev *dev) ...@@ -2173,6 +2172,7 @@ int saa7134_video_init1(struct saa7134_dev *dev)
q->buf_struct_size = sizeof(struct saa7134_buf); q->buf_struct_size = sizeof(struct saa7134_buf);
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &dev->lock; q->lock = &dev->lock;
q->dev = &dev->pci->dev;
ret = vb2_queue_init(q); ret = vb2_queue_init(q);
if (ret) if (ret)
return ret; return ret;
...@@ -2191,6 +2191,7 @@ int saa7134_video_init1(struct saa7134_dev *dev) ...@@ -2191,6 +2191,7 @@ int saa7134_video_init1(struct saa7134_dev *dev)
q->buf_struct_size = sizeof(struct saa7134_buf); q->buf_struct_size = sizeof(struct saa7134_buf);
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &dev->lock; q->lock = &dev->lock;
q->dev = &dev->pci->dev;
ret = vb2_queue_init(q); ret = vb2_queue_init(q);
if (ret) if (ret)
return ret; return ret;
......
...@@ -610,7 +610,6 @@ struct saa7134_dev { ...@@ -610,7 +610,6 @@ struct saa7134_dev {
/* video+ts+vbi capture */ /* video+ts+vbi capture */
void *alloc_ctx;
struct saa7134_dmaqueue video_q; struct saa7134_dmaqueue video_q;
struct vb2_queue video_vbq; struct vb2_queue video_vbq;
struct saa7134_dmaqueue vbi_q; struct saa7134_dmaqueue vbi_q;
......
...@@ -666,10 +666,7 @@ static int solo_enc_queue_setup(struct vb2_queue *q, ...@@ -666,10 +666,7 @@ static int solo_enc_queue_setup(struct vb2_queue *q,
unsigned int *num_planes, unsigned int sizes[], unsigned int *num_planes, unsigned int sizes[],
void *alloc_ctxs[]) void *alloc_ctxs[])
{ {
struct solo_enc_dev *solo_enc = vb2_get_drv_priv(q);
sizes[0] = FRAME_BUF_SIZE; sizes[0] = FRAME_BUF_SIZE;
alloc_ctxs[0] = solo_enc->alloc_ctx;
*num_planes = 1; *num_planes = 1;
if (*num_buffers < MIN_VID_BUFFERS) if (*num_buffers < MIN_VID_BUFFERS)
...@@ -1239,11 +1236,6 @@ static struct solo_enc_dev *solo_enc_alloc(struct solo_dev *solo_dev, ...@@ -1239,11 +1236,6 @@ static struct solo_enc_dev *solo_enc_alloc(struct solo_dev *solo_dev,
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
hdl = &solo_enc->hdl; hdl = &solo_enc->hdl;
solo_enc->alloc_ctx = vb2_dma_sg_init_ctx(&solo_dev->pdev->dev);
if (IS_ERR(solo_enc->alloc_ctx)) {
ret = PTR_ERR(solo_enc->alloc_ctx);
goto hdl_free;
}
v4l2_ctrl_handler_init(hdl, 10); v4l2_ctrl_handler_init(hdl, 10);
v4l2_ctrl_new_std(hdl, &solo_ctrl_ops, v4l2_ctrl_new_std(hdl, &solo_ctrl_ops,
V4L2_CID_BRIGHTNESS, 0, 255, 1, 128); V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
...@@ -1299,6 +1291,7 @@ static struct solo_enc_dev *solo_enc_alloc(struct solo_dev *solo_dev, ...@@ -1299,6 +1291,7 @@ static struct solo_enc_dev *solo_enc_alloc(struct solo_dev *solo_dev,
solo_enc->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; solo_enc->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
solo_enc->vidq.buf_struct_size = sizeof(struct solo_vb2_buf); solo_enc->vidq.buf_struct_size = sizeof(struct solo_vb2_buf);
solo_enc->vidq.lock = &solo_enc->lock; solo_enc->vidq.lock = &solo_enc->lock;
solo_enc->vidq.dev = &solo_dev->pdev->dev;
ret = vb2_queue_init(&solo_enc->vidq); ret = vb2_queue_init(&solo_enc->vidq);
if (ret) if (ret)
goto hdl_free; goto hdl_free;
...@@ -1347,7 +1340,6 @@ static struct solo_enc_dev *solo_enc_alloc(struct solo_dev *solo_dev, ...@@ -1347,7 +1340,6 @@ static struct solo_enc_dev *solo_enc_alloc(struct solo_dev *solo_dev,
solo_enc->desc_items, solo_enc->desc_dma); solo_enc->desc_items, solo_enc->desc_dma);
hdl_free: hdl_free:
v4l2_ctrl_handler_free(hdl); v4l2_ctrl_handler_free(hdl);
vb2_dma_sg_cleanup_ctx(solo_enc->alloc_ctx);
kfree(solo_enc); kfree(solo_enc);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
...@@ -1362,7 +1354,6 @@ static void solo_enc_free(struct solo_enc_dev *solo_enc) ...@@ -1362,7 +1354,6 @@ static void solo_enc_free(struct solo_enc_dev *solo_enc)
solo_enc->desc_items, solo_enc->desc_dma); solo_enc->desc_items, solo_enc->desc_dma);
video_unregister_device(solo_enc->vfd); video_unregister_device(solo_enc->vfd);
v4l2_ctrl_handler_free(&solo_enc->hdl); v4l2_ctrl_handler_free(&solo_enc->hdl);
vb2_dma_sg_cleanup_ctx(solo_enc->alloc_ctx);
kfree(solo_enc); kfree(solo_enc);
} }
......
...@@ -320,7 +320,6 @@ static int solo_queue_setup(struct vb2_queue *q, ...@@ -320,7 +320,6 @@ static int solo_queue_setup(struct vb2_queue *q,
struct solo_dev *solo_dev = vb2_get_drv_priv(q); struct solo_dev *solo_dev = vb2_get_drv_priv(q);
sizes[0] = solo_image_size(solo_dev); sizes[0] = solo_image_size(solo_dev);
alloc_ctxs[0] = solo_dev->alloc_ctx;
*num_planes = 1; *num_planes = 1;
if (*num_buffers < MIN_VID_BUFFERS) if (*num_buffers < MIN_VID_BUFFERS)
...@@ -679,16 +678,11 @@ int solo_v4l2_init(struct solo_dev *solo_dev, unsigned nr) ...@@ -679,16 +678,11 @@ int solo_v4l2_init(struct solo_dev *solo_dev, unsigned nr)
solo_dev->vidq.gfp_flags = __GFP_DMA32 | __GFP_KSWAPD_RECLAIM; solo_dev->vidq.gfp_flags = __GFP_DMA32 | __GFP_KSWAPD_RECLAIM;
solo_dev->vidq.buf_struct_size = sizeof(struct solo_vb2_buf); solo_dev->vidq.buf_struct_size = sizeof(struct solo_vb2_buf);
solo_dev->vidq.lock = &solo_dev->lock; solo_dev->vidq.lock = &solo_dev->lock;
solo_dev->vidq.dev = &solo_dev->pdev->dev;
ret = vb2_queue_init(&solo_dev->vidq); ret = vb2_queue_init(&solo_dev->vidq);
if (ret < 0) if (ret < 0)
goto fail; goto fail;
solo_dev->alloc_ctx = vb2_dma_contig_init_ctx(&solo_dev->pdev->dev);
if (IS_ERR(solo_dev->alloc_ctx)) {
dev_err(&solo_dev->pdev->dev, "Can't allocate buffer context");
return PTR_ERR(solo_dev->alloc_ctx);
}
/* Cycle all the channels and clear */ /* Cycle all the channels and clear */
for (i = 0; i < solo_dev->nr_chans; i++) { for (i = 0; i < solo_dev->nr_chans; i++) {
solo_v4l2_set_ch(solo_dev, i); solo_v4l2_set_ch(solo_dev, i);
...@@ -716,7 +710,6 @@ int solo_v4l2_init(struct solo_dev *solo_dev, unsigned nr) ...@@ -716,7 +710,6 @@ int solo_v4l2_init(struct solo_dev *solo_dev, unsigned nr)
fail: fail:
video_device_release(solo_dev->vfd); video_device_release(solo_dev->vfd);
vb2_dma_contig_cleanup_ctx(solo_dev->alloc_ctx);
v4l2_ctrl_handler_free(&solo_dev->disp_hdl); v4l2_ctrl_handler_free(&solo_dev->disp_hdl);
solo_dev->vfd = NULL; solo_dev->vfd = NULL;
return ret; return ret;
...@@ -728,7 +721,6 @@ void solo_v4l2_exit(struct solo_dev *solo_dev) ...@@ -728,7 +721,6 @@ void solo_v4l2_exit(struct solo_dev *solo_dev)
return; return;
video_unregister_device(solo_dev->vfd); video_unregister_device(solo_dev->vfd);
vb2_dma_contig_cleanup_ctx(solo_dev->alloc_ctx);
v4l2_ctrl_handler_free(&solo_dev->disp_hdl); v4l2_ctrl_handler_free(&solo_dev->disp_hdl);
solo_dev->vfd = NULL; solo_dev->vfd = NULL;
} }
...@@ -178,7 +178,6 @@ struct solo_enc_dev { ...@@ -178,7 +178,6 @@ struct solo_enc_dev {
u32 sequence; u32 sequence;
struct vb2_queue vidq; struct vb2_queue vidq;
struct list_head vidq_active; struct list_head vidq_active;
void *alloc_ctx;
int desc_count; int desc_count;
int desc_nelts; int desc_nelts;
struct solo_p2m_desc *desc_items; struct solo_p2m_desc *desc_items;
...@@ -269,7 +268,6 @@ struct solo_dev { ...@@ -269,7 +268,6 @@ struct solo_dev {
/* Buffer handling */ /* Buffer handling */
struct vb2_queue vidq; struct vb2_queue vidq;
struct vb2_alloc_ctx *alloc_ctx;
u32 sequence; u32 sequence;
struct task_struct *kthread; struct task_struct *kthread;
struct mutex lock; struct mutex lock;
......
...@@ -111,7 +111,6 @@ static inline struct vip_buffer *to_vip_buffer(struct vb2_v4l2_buffer *vb2) ...@@ -111,7 +111,6 @@ static inline struct vip_buffer *to_vip_buffer(struct vb2_v4l2_buffer *vb2)
* @input: input line for video signal ( 0 or 1 ) * @input: input line for video signal ( 0 or 1 )
* @disabled: Device is in power down state * @disabled: Device is in power down state
* @slock: for excluse acces of registers * @slock: for excluse acces of registers
* @alloc_ctx: context for videobuf2
* @vb_vidq: queue maintained by videobuf2 layer * @vb_vidq: queue maintained by videobuf2 layer
* @buffer_list: list of buffer in use * @buffer_list: list of buffer in use
* @sequence: sequence number of acquired buffer * @sequence: sequence number of acquired buffer
...@@ -141,7 +140,6 @@ struct sta2x11_vip { ...@@ -141,7 +140,6 @@ struct sta2x11_vip {
int disabled; int disabled;
spinlock_t slock; spinlock_t slock;
struct vb2_alloc_ctx *alloc_ctx;
struct vb2_queue vb_vidq; struct vb2_queue vb_vidq;
struct list_head buffer_list; struct list_head buffer_list;
unsigned int sequence; unsigned int sequence;
...@@ -276,7 +274,6 @@ static int queue_setup(struct vb2_queue *vq, ...@@ -276,7 +274,6 @@ static int queue_setup(struct vb2_queue *vq,
*nplanes = 1; *nplanes = 1;
sizes[0] = vip->format.sizeimage; sizes[0] = vip->format.sizeimage;
alloc_ctxs[0] = vip->alloc_ctx;
vip->sequence = 0; vip->sequence = 0;
vip->active = NULL; vip->active = NULL;
...@@ -861,25 +858,15 @@ static int sta2x11_vip_init_buffer(struct sta2x11_vip *vip) ...@@ -861,25 +858,15 @@ static int sta2x11_vip_init_buffer(struct sta2x11_vip *vip)
vip->vb_vidq.ops = &vip_video_qops; vip->vb_vidq.ops = &vip_video_qops;
vip->vb_vidq.mem_ops = &vb2_dma_contig_memops; vip->vb_vidq.mem_ops = &vb2_dma_contig_memops;
vip->vb_vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; vip->vb_vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
vip->vb_vidq.dev = &vip->pdev->dev;
err = vb2_queue_init(&vip->vb_vidq); err = vb2_queue_init(&vip->vb_vidq);
if (err) if (err)
return err; return err;
INIT_LIST_HEAD(&vip->buffer_list); INIT_LIST_HEAD(&vip->buffer_list);
spin_lock_init(&vip->lock); spin_lock_init(&vip->lock);
vip->alloc_ctx = vb2_dma_contig_init_ctx(&vip->pdev->dev);
if (IS_ERR(vip->alloc_ctx)) {
v4l2_err(&vip->v4l2_dev, "Can't allocate buffer context");
return PTR_ERR(vip->alloc_ctx);
}
return 0; return 0;
} }
static void sta2x11_vip_release_buffer(struct sta2x11_vip *vip)
{
vb2_dma_contig_cleanup_ctx(vip->alloc_ctx);
}
static int sta2x11_vip_init_controls(struct sta2x11_vip *vip) static int sta2x11_vip_init_controls(struct sta2x11_vip *vip)
{ {
/* /*
...@@ -1120,7 +1107,6 @@ static int sta2x11_vip_init_one(struct pci_dev *pdev, ...@@ -1120,7 +1107,6 @@ static int sta2x11_vip_init_one(struct pci_dev *pdev,
video_unregister_device(&vip->video_dev); video_unregister_device(&vip->video_dev);
free_irq(pdev->irq, vip); free_irq(pdev->irq, vip);
release_buf: release_buf:
sta2x11_vip_release_buffer(vip);
pci_disable_msi(pdev); pci_disable_msi(pdev);
unmap: unmap:
vb2_queue_release(&vip->vb_vidq); vb2_queue_release(&vip->vb_vidq);
......
...@@ -305,19 +305,13 @@ static int tw68_initdev(struct pci_dev *pci_dev, ...@@ -305,19 +305,13 @@ static int tw68_initdev(struct pci_dev *pci_dev,
/* Then do any initialisation wanted before interrupts are on */ /* Then do any initialisation wanted before interrupts are on */
tw68_hw_init1(dev); tw68_hw_init1(dev);
dev->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev);
if (IS_ERR(dev->alloc_ctx)) {
err = PTR_ERR(dev->alloc_ctx);
goto fail3;
}
/* get irq */ /* get irq */
err = devm_request_irq(&pci_dev->dev, pci_dev->irq, tw68_irq, err = devm_request_irq(&pci_dev->dev, pci_dev->irq, tw68_irq,
IRQF_SHARED, dev->name, dev); IRQF_SHARED, dev->name, dev);
if (err < 0) { if (err < 0) {
pr_err("%s: can't get IRQ %d\n", pr_err("%s: can't get IRQ %d\n",
dev->name, pci_dev->irq); dev->name, pci_dev->irq);
goto fail4; goto fail3;
} }
/* /*
...@@ -331,7 +325,7 @@ static int tw68_initdev(struct pci_dev *pci_dev, ...@@ -331,7 +325,7 @@ static int tw68_initdev(struct pci_dev *pci_dev,
if (err < 0) { if (err < 0) {
pr_err("%s: can't register video device\n", pr_err("%s: can't register video device\n",
dev->name); dev->name);
goto fail5; goto fail4;
} }
tw_setl(TW68_INTMASK, dev->pci_irqmask); tw_setl(TW68_INTMASK, dev->pci_irqmask);
...@@ -340,10 +334,8 @@ static int tw68_initdev(struct pci_dev *pci_dev, ...@@ -340,10 +334,8 @@ static int tw68_initdev(struct pci_dev *pci_dev,
return 0; return 0;
fail5:
video_unregister_device(&dev->vdev);
fail4: fail4:
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx); video_unregister_device(&dev->vdev);
fail3: fail3:
iounmap(dev->lmmio); iounmap(dev->lmmio);
fail2: fail2:
...@@ -367,7 +359,6 @@ static void tw68_finidev(struct pci_dev *pci_dev) ...@@ -367,7 +359,6 @@ static void tw68_finidev(struct pci_dev *pci_dev)
/* unregister */ /* unregister */
video_unregister_device(&dev->vdev); video_unregister_device(&dev->vdev);
v4l2_ctrl_handler_free(&dev->hdl); v4l2_ctrl_handler_free(&dev->hdl);
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
/* release resources */ /* release resources */
iounmap(dev->lmmio); iounmap(dev->lmmio);
......
...@@ -388,7 +388,6 @@ static int tw68_queue_setup(struct vb2_queue *q, ...@@ -388,7 +388,6 @@ static int tw68_queue_setup(struct vb2_queue *q,
tot_bufs = 2; tot_bufs = 2;
tot_bufs = tw68_buffer_count(size, tot_bufs); tot_bufs = tw68_buffer_count(size, tot_bufs);
*num_buffers = tot_bufs - q->num_buffers; *num_buffers = tot_bufs - q->num_buffers;
alloc_ctxs[0] = dev->alloc_ctx;
/* /*
* We allow create_bufs, but only if the sizeimage is >= as the * We allow create_bufs, but only if the sizeimage is >= as the
* current sizeimage. The tw68_buffer_count calculation becomes quite * current sizeimage. The tw68_buffer_count calculation becomes quite
...@@ -983,6 +982,7 @@ int tw68_video_init2(struct tw68_dev *dev, int video_nr) ...@@ -983,6 +982,7 @@ int tw68_video_init2(struct tw68_dev *dev, int video_nr)
dev->vidq.buf_struct_size = sizeof(struct tw68_buf); dev->vidq.buf_struct_size = sizeof(struct tw68_buf);
dev->vidq.lock = &dev->lock; dev->vidq.lock = &dev->lock;
dev->vidq.min_buffers_needed = 2; dev->vidq.min_buffers_needed = 2;
dev->vidq.dev = &dev->pci->dev;
ret = vb2_queue_init(&dev->vidq); ret = vb2_queue_init(&dev->vidq);
if (ret) if (ret)
return ret; return ret;
......
...@@ -165,7 +165,6 @@ struct tw68_dev { ...@@ -165,7 +165,6 @@ struct tw68_dev {
unsigned field; unsigned field;
struct vb2_queue vidq; struct vb2_queue vidq;
struct list_head active; struct list_head active;
void *alloc_ctx;
/* various v4l controls */ /* various v4l controls */
const struct tw68_tvnorm *tvnorm; /* video */ const struct tw68_tvnorm *tvnorm; /* video */
......
...@@ -135,7 +135,6 @@ static int tw686x_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, ...@@ -135,7 +135,6 @@ static int tw686x_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,
struct tw686x_video_channel *vc = vb2_get_drv_priv(vq); struct tw686x_video_channel *vc = vb2_get_drv_priv(vq);
unsigned int size = vc->width * vc->height * vc->format->depth / 8; unsigned int size = vc->width * vc->height * vc->format->depth / 8;
alloc_ctxs[0] = vc->alloc_ctx;
if (*nbuffers < 2) if (*nbuffers < 2)
*nbuffers = 2; *nbuffers = 2;
...@@ -645,7 +644,6 @@ void tw686x_kh_video_free(struct tw686x_dev *dev) ...@@ -645,7 +644,6 @@ void tw686x_kh_video_free(struct tw686x_dev *dev)
v4l2_ctrl_handler_free(&vc->ctrl_handler); v4l2_ctrl_handler_free(&vc->ctrl_handler);
if (vc->device) if (vc->device)
video_unregister_device(vc->device); video_unregister_device(vc->device);
vb2_dma_sg_cleanup_ctx(vc->alloc_ctx);
for (n = 0; n < 2; n++) { for (n = 0; n < 2; n++) {
struct dma_desc *descs = &vc->sg_tables[n]; struct dma_desc *descs = &vc->sg_tables[n];
...@@ -750,13 +748,6 @@ int tw686x_kh_video_init(struct tw686x_dev *dev) ...@@ -750,13 +748,6 @@ int tw686x_kh_video_init(struct tw686x_dev *dev)
goto error; goto error;
} }
vc->alloc_ctx = vb2_dma_sg_init_ctx(&dev->pci_dev->dev);
if (IS_ERR(vc->alloc_ctx)) {
pr_warn("Unable to initialize DMA scatter-gather context\n");
err = PTR_ERR(vc->alloc_ctx);
goto error;
}
vc->vidq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; vc->vidq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
vc->vidq.io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; vc->vidq.io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
vc->vidq.drv_priv = vc; vc->vidq.drv_priv = vc;
...@@ -766,6 +757,7 @@ int tw686x_kh_video_init(struct tw686x_dev *dev) ...@@ -766,6 +757,7 @@ int tw686x_kh_video_init(struct tw686x_dev *dev)
vc->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; vc->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
vc->vidq.min_buffers_needed = 2; vc->vidq.min_buffers_needed = 2;
vc->vidq.lock = &vc->vb_mutex; vc->vidq.lock = &vc->vb_mutex;
vc->vidq.dev = &dev->pci_dev->dev;
vc->vidq.gfp_flags = GFP_DMA32; vc->vidq.gfp_flags = GFP_DMA32;
err = vb2_queue_init(&vc->vidq); err = vb2_queue_init(&vc->vidq);
......
...@@ -56,7 +56,6 @@ struct tw686x_video_channel { ...@@ -56,7 +56,6 @@ struct tw686x_video_channel {
struct video_device *device; struct video_device *device;
struct dma_desc sg_tables[2]; struct dma_desc sg_tables[2];
struct tw686x_vb2_buf *curr_bufs[2]; struct tw686x_vb2_buf *curr_bufs[2];
void *alloc_ctx;
struct vdma_desc *sg_descs[2]; struct vdma_desc *sg_descs[2];
struct v4l2_ctrl_handler ctrl_handler; struct v4l2_ctrl_handler ctrl_handler;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment