aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/pci/cx88/cx88-blackbird.c4
-rw-r--r--drivers/media/pci/cx88/cx88-dvb.c4
-rw-r--r--drivers/media/pci/cx88/cx88-mpeg.c11
-rw-r--r--drivers/media/pci/cx88/cx88-vbi.c9
-rw-r--r--drivers/media/pci/cx88/cx88-video.c17
-rw-r--r--drivers/media/pci/cx88/cx88.h2
6 files changed, 21 insertions, 26 deletions
diff --git a/drivers/media/pci/cx88/cx88-blackbird.c b/drivers/media/pci/cx88/cx88-blackbird.c
index 4160ca4e5413..d3c79d964f2c 100644
--- a/drivers/media/pci/cx88/cx88-blackbird.c
+++ b/drivers/media/pci/cx88/cx88-blackbird.c
@@ -647,6 +647,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt,
647 dev->ts_packet_size = 188 * 4; 647 dev->ts_packet_size = 188 * 4;
648 dev->ts_packet_count = 32; 648 dev->ts_packet_count = 32;
649 sizes[0] = dev->ts_packet_size * dev->ts_packet_count; 649 sizes[0] = dev->ts_packet_size * dev->ts_packet_count;
650 alloc_ctxs[0] = dev->alloc_ctx;
650 return 0; 651 return 0;
651} 652}
652 653
@@ -662,14 +663,11 @@ static void buffer_finish(struct vb2_buffer *vb)
662{ 663{
663 struct cx8802_dev *dev = vb->vb2_queue->drv_priv; 664 struct cx8802_dev *dev = vb->vb2_queue->drv_priv;
664 struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb); 665 struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb);
665 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
666 struct cx88_riscmem *risc = &buf->risc; 666 struct cx88_riscmem *risc = &buf->risc;
667 667
668 if (risc->cpu) 668 if (risc->cpu)
669 pci_free_consistent(dev->pci, risc->size, risc->cpu, risc->dma); 669 pci_free_consistent(dev->pci, risc->size, risc->cpu, risc->dma);
670 memset(risc, 0, sizeof(*risc)); 670 memset(risc, 0, sizeof(*risc));
671
672 dma_unmap_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE);
673} 671}
674 672
675static void buffer_queue(struct vb2_buffer *vb) 673static void buffer_queue(struct vb2_buffer *vb)
diff --git a/drivers/media/pci/cx88/cx88-dvb.c b/drivers/media/pci/cx88/cx88-dvb.c
index c344bfd0b896..5780e2f013b4 100644
--- a/drivers/media/pci/cx88/cx88-dvb.c
+++ b/drivers/media/pci/cx88/cx88-dvb.c
@@ -92,6 +92,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt,
92 dev->ts_packet_size = 188 * 4; 92 dev->ts_packet_size = 188 * 4;
93 dev->ts_packet_count = dvb_buf_tscnt; 93 dev->ts_packet_count = dvb_buf_tscnt;
94 sizes[0] = dev->ts_packet_size * dev->ts_packet_count; 94 sizes[0] = dev->ts_packet_size * dev->ts_packet_count;
95 alloc_ctxs[0] = dev->alloc_ctx;
95 *num_buffers = dvb_buf_tscnt; 96 *num_buffers = dvb_buf_tscnt;
96 return 0; 97 return 0;
97} 98}
@@ -108,14 +109,11 @@ static void buffer_finish(struct vb2_buffer *vb)
108{ 109{
109 struct cx8802_dev *dev = vb->vb2_queue->drv_priv; 110 struct cx8802_dev *dev = vb->vb2_queue->drv_priv;
110 struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb); 111 struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb);
111 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
112 struct cx88_riscmem *risc = &buf->risc; 112 struct cx88_riscmem *risc = &buf->risc;
113 113
114 if (risc->cpu) 114 if (risc->cpu)
115 pci_free_consistent(dev->pci, risc->size, risc->cpu, risc->dma); 115 pci_free_consistent(dev->pci, risc->size, risc->cpu, risc->dma);
116 memset(risc, 0, sizeof(*risc)); 116 memset(risc, 0, sizeof(*risc));
117
118 dma_unmap_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE);
119} 117}
120 118
121static void buffer_queue(struct vb2_buffer *vb) 119static void buffer_queue(struct vb2_buffer *vb)
diff --git a/drivers/media/pci/cx88/cx88-mpeg.c b/drivers/media/pci/cx88/cx88-mpeg.c
index f181a3a10389..1c1f69e6b0b9 100644
--- a/drivers/media/pci/cx88/cx88-mpeg.c
+++ b/drivers/media/pci/cx88/cx88-mpeg.c
@@ -235,10 +235,6 @@ int cx8802_buf_prepare(struct vb2_queue *q, struct cx8802_dev *dev,
235 return -EINVAL; 235 return -EINVAL;
236 vb2_set_plane_payload(&buf->vb, 0, size); 236 vb2_set_plane_payload(&buf->vb, 0, size);
237 237
238 rc = dma_map_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE);
239 if (!rc)
240 return -EIO;
241
242 rc = cx88_risc_databuffer(dev->pci, risc, sgt->sgl, 238 rc = cx88_risc_databuffer(dev->pci, risc, sgt->sgl,
243 dev->ts_packet_size, dev->ts_packet_count, 0); 239 dev->ts_packet_size, dev->ts_packet_count, 0);
244 if (rc) { 240 if (rc) {
@@ -733,6 +729,11 @@ static int cx8802_probe(struct pci_dev *pci_dev,
733 if (NULL == dev) 729 if (NULL == dev)
734 goto fail_core; 730 goto fail_core;
735 dev->pci = pci_dev; 731 dev->pci = pci_dev;
732 dev->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev);
733 if (IS_ERR(dev->alloc_ctx)) {
734 err = PTR_ERR(dev->alloc_ctx);
735 goto fail_core;
736 }
736 dev->core = core; 737 dev->core = core;
737 738
738 /* Maintain a reference so cx88-video can query the 8802 device. */ 739 /* Maintain a reference so cx88-video can query the 8802 device. */
@@ -752,6 +753,7 @@ static int cx8802_probe(struct pci_dev *pci_dev,
752 return 0; 753 return 0;
753 754
754 fail_free: 755 fail_free:
756 vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
755 kfree(dev); 757 kfree(dev);
756 fail_core: 758 fail_core:
757 core->dvbdev = NULL; 759 core->dvbdev = NULL;
@@ -798,6 +800,7 @@ static void cx8802_remove(struct pci_dev *pci_dev)
798 /* common */ 800 /* common */
799 cx8802_fini_common(dev); 801 cx8802_fini_common(dev);
800 cx88_core_put(dev->core,dev->pci); 802 cx88_core_put(dev->core,dev->pci);
803 vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
801 kfree(dev); 804 kfree(dev);
802} 805}
803 806
diff --git a/drivers/media/pci/cx88/cx88-vbi.c b/drivers/media/pci/cx88/cx88-vbi.c
index 6ab6e27648f6..32eb7fdb875e 100644
--- a/drivers/media/pci/cx88/cx88-vbi.c
+++ b/drivers/media/pci/cx88/cx88-vbi.c
@@ -120,6 +120,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt,
120 sizes[0] = VBI_LINE_NTSC_COUNT * VBI_LINE_LENGTH * 2; 120 sizes[0] = VBI_LINE_NTSC_COUNT * VBI_LINE_LENGTH * 2;
121 else 121 else
122 sizes[0] = VBI_LINE_PAL_COUNT * VBI_LINE_LENGTH * 2; 122 sizes[0] = VBI_LINE_PAL_COUNT * VBI_LINE_LENGTH * 2;
123 alloc_ctxs[0] = dev->alloc_ctx;
123 return 0; 124 return 0;
124} 125}
125 126
@@ -131,7 +132,6 @@ static int buffer_prepare(struct vb2_buffer *vb)
131 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); 132 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
132 unsigned int lines; 133 unsigned int lines;
133 unsigned int size; 134 unsigned int size;
134 int rc;
135 135
136 if (dev->core->tvnorm & V4L2_STD_525_60) 136 if (dev->core->tvnorm & V4L2_STD_525_60)
137 lines = VBI_LINE_NTSC_COUNT; 137 lines = VBI_LINE_NTSC_COUNT;
@@ -142,10 +142,6 @@ static int buffer_prepare(struct vb2_buffer *vb)
142 return -EINVAL; 142 return -EINVAL;
143 vb2_set_plane_payload(vb, 0, size); 143 vb2_set_plane_payload(vb, 0, size);
144 144
145 rc = dma_map_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE);
146 if (!rc)
147 return -EIO;
148
149 cx88_risc_buffer(dev->pci, &buf->risc, sgt->sgl, 145 cx88_risc_buffer(dev->pci, &buf->risc, sgt->sgl,
150 0, VBI_LINE_LENGTH * lines, 146 0, VBI_LINE_LENGTH * lines,
151 VBI_LINE_LENGTH, 0, 147 VBI_LINE_LENGTH, 0,
@@ -157,14 +153,11 @@ static void buffer_finish(struct vb2_buffer *vb)
157{ 153{
158 struct cx8800_dev *dev = vb->vb2_queue->drv_priv; 154 struct cx8800_dev *dev = vb->vb2_queue->drv_priv;
159 struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb); 155 struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb);
160 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
161 struct cx88_riscmem *risc = &buf->risc; 156 struct cx88_riscmem *risc = &buf->risc;
162 157
163 if (risc->cpu) 158 if (risc->cpu)
164 pci_free_consistent(dev->pci, risc->size, risc->cpu, risc->dma); 159 pci_free_consistent(dev->pci, risc->size, risc->cpu, risc->dma);
165 memset(risc, 0, sizeof(*risc)); 160 memset(risc, 0, sizeof(*risc));
166
167 dma_unmap_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE);
168} 161}
169 162
170static void buffer_queue(struct vb2_buffer *vb) 163static void buffer_queue(struct vb2_buffer *vb)
diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
index a64ae31ae142..25a4b7f3188a 100644
--- a/drivers/media/pci/cx88/cx88-video.c
+++ b/drivers/media/pci/cx88/cx88-video.c
@@ -440,6 +440,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt,
440 440
441 *num_planes = 1; 441 *num_planes = 1;
442 sizes[0] = (dev->fmt->depth * core->width * core->height) >> 3; 442 sizes[0] = (dev->fmt->depth * core->width * core->height) >> 3;
443 alloc_ctxs[0] = dev->alloc_ctx;
443 return 0; 444 return 0;
444} 445}
445 446
@@ -449,7 +450,6 @@ static int buffer_prepare(struct vb2_buffer *vb)
449 struct cx88_core *core = dev->core; 450 struct cx88_core *core = dev->core;
450 struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb); 451 struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb);
451 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); 452 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
452 int rc;
453 453
454 buf->bpl = core->width * dev->fmt->depth >> 3; 454 buf->bpl = core->width * dev->fmt->depth >> 3;
455 455
@@ -457,10 +457,6 @@ static int buffer_prepare(struct vb2_buffer *vb)
457 return -EINVAL; 457 return -EINVAL;
458 vb2_set_plane_payload(vb, 0, core->height * buf->bpl); 458 vb2_set_plane_payload(vb, 0, core->height * buf->bpl);
459 459
460 rc = dma_map_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE);
461 if (!rc)
462 return -EIO;
463
464 switch (core->field) { 460 switch (core->field) {
465 case V4L2_FIELD_TOP: 461 case V4L2_FIELD_TOP:
466 cx88_risc_buffer(dev->pci, &buf->risc, 462 cx88_risc_buffer(dev->pci, &buf->risc,
@@ -505,14 +501,11 @@ static void buffer_finish(struct vb2_buffer *vb)
505{ 501{
506 struct cx8800_dev *dev = vb->vb2_queue->drv_priv; 502 struct cx8800_dev *dev = vb->vb2_queue->drv_priv;
507 struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb); 503 struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb);
508 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
509 struct cx88_riscmem *risc = &buf->risc; 504 struct cx88_riscmem *risc = &buf->risc;
510 505
511 if (risc->cpu) 506 if (risc->cpu)
512 pci_free_consistent(dev->pci, risc->size, risc->cpu, risc->dma); 507 pci_free_consistent(dev->pci, risc->size, risc->cpu, risc->dma);
513 memset(risc, 0, sizeof(*risc)); 508 memset(risc, 0, sizeof(*risc));
514
515 dma_unmap_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE);
516} 509}
517 510
518static void buffer_queue(struct vb2_buffer *vb) 511static void buffer_queue(struct vb2_buffer *vb)
@@ -1345,6 +1338,12 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1345 err = -EIO; 1338 err = -EIO;
1346 goto fail_core; 1339 goto fail_core;
1347 } 1340 }
1341 dev->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev);
1342 if (IS_ERR(dev->alloc_ctx)) {
1343 err = PTR_ERR(dev->alloc_ctx);
1344 goto fail_core;
1345 }
1346
1348 1347
1349 /* initialize driver struct */ 1348 /* initialize driver struct */
1350 spin_lock_init(&dev->slock); 1349 spin_lock_init(&dev->slock);
@@ -1549,6 +1548,7 @@ fail_unreg:
1549 free_irq(pci_dev->irq, dev); 1548 free_irq(pci_dev->irq, dev);
1550 mutex_unlock(&core->lock); 1549 mutex_unlock(&core->lock);
1551fail_core: 1550fail_core:
1551 vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
1552 core->v4ldev = NULL; 1552 core->v4ldev = NULL;
1553 cx88_core_put(core,dev->pci); 1553 cx88_core_put(core,dev->pci);
1554fail_free: 1554fail_free:
@@ -1582,6 +1582,7 @@ static void cx8800_finidev(struct pci_dev *pci_dev)
1582 1582
1583 /* free memory */ 1583 /* free memory */
1584 cx88_core_put(core,dev->pci); 1584 cx88_core_put(core,dev->pci);
1585 vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
1585 kfree(dev); 1586 kfree(dev);
1586} 1587}
1587 1588
diff --git a/drivers/media/pci/cx88/cx88.h b/drivers/media/pci/cx88/cx88.h
index 3b0ae754f165..7748ca9abb09 100644
--- a/drivers/media/pci/cx88/cx88.h
+++ b/drivers/media/pci/cx88/cx88.h
@@ -485,6 +485,7 @@ struct cx8800_dev {
485 /* pci i/o */ 485 /* pci i/o */
486 struct pci_dev *pci; 486 struct pci_dev *pci;
487 unsigned char pci_rev,pci_lat; 487 unsigned char pci_rev,pci_lat;
488 void *alloc_ctx;
488 489
489 const struct cx8800_fmt *fmt; 490 const struct cx8800_fmt *fmt;
490 491
@@ -548,6 +549,7 @@ struct cx8802_dev {
548 /* pci i/o */ 549 /* pci i/o */
549 struct pci_dev *pci; 550 struct pci_dev *pci;
550 unsigned char pci_rev,pci_lat; 551 unsigned char pci_rev,pci_lat;
552 void *alloc_ctx;
551 553
552 /* dma queues */ 554 /* dma queues */
553 struct cx88_dmaqueue mpegq; 555 struct cx88_dmaqueue mpegq;