diff options
Diffstat (limited to 'drivers/media/video/videobuf-dma-sg.c')
-rw-r--r-- | drivers/media/video/videobuf-dma-sg.c | 156 |
1 files changed, 88 insertions, 68 deletions
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c index 53fed4b74ce9..03a7b946bd54 100644 --- a/drivers/media/video/videobuf-dma-sg.c +++ b/drivers/media/video/videobuf-dma-sg.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * helper functions for PCI DMA video4linux capture buffers | 2 | * helper functions for SG DMA video4linux capture buffers |
3 | * | 3 | * |
4 | * The functions expect the hardware being able to scatter gatter | 4 | * The functions expect the hardware being able to scatter gatter |
5 | * (i.e. the buffers are not linear in physical memory, but fragmented | 5 | * (i.e. the buffers are not linear in physical memory, but fragmented |
@@ -24,7 +24,7 @@ | |||
24 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
26 | 26 | ||
27 | #include <linux/pci.h> | 27 | #include <linux/dma-mapping.h> |
28 | #include <linux/vmalloc.h> | 28 | #include <linux/vmalloc.h> |
29 | #include <linux/pagemap.h> | 29 | #include <linux/pagemap.h> |
30 | #include <linux/scatterlist.h> | 30 | #include <linux/scatterlist.h> |
@@ -39,10 +39,10 @@ | |||
39 | #define MAGIC_CHECK(is,should) if (unlikely((is) != (should))) \ | 39 | #define MAGIC_CHECK(is,should) if (unlikely((is) != (should))) \ |
40 | { printk(KERN_ERR "magic mismatch: %x (expected %x)\n",is,should); BUG(); } | 40 | { printk(KERN_ERR "magic mismatch: %x (expected %x)\n",is,should); BUG(); } |
41 | 41 | ||
42 | static int debug = 0; | 42 | static int debug; |
43 | module_param(debug, int, 0644); | 43 | module_param(debug, int, 0644); |
44 | 44 | ||
45 | MODULE_DESCRIPTION("helper module to manage video4linux pci dma sg buffers"); | 45 | MODULE_DESCRIPTION("helper module to manage video4linux dma sg buffers"); |
46 | MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); | 46 | MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); |
47 | MODULE_LICENSE("GPL"); | 47 | MODULE_LICENSE("GPL"); |
48 | 48 | ||
@@ -119,10 +119,10 @@ videobuf_pages_to_sg(struct page **pages, int nr_pages, int offset) | |||
119 | 119 | ||
120 | struct videobuf_dmabuf *videobuf_to_dma (struct videobuf_buffer *buf) | 120 | struct videobuf_dmabuf *videobuf_to_dma (struct videobuf_buffer *buf) |
121 | { | 121 | { |
122 | struct videbuf_pci_sg_memory *mem=buf->priv; | 122 | struct videobuf_dma_sg_memory *mem = buf->priv; |
123 | BUG_ON (!mem); | 123 | BUG_ON(!mem); |
124 | 124 | ||
125 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); | 125 | MAGIC_CHECK(mem->magic, MAGIC_SG_MEM); |
126 | 126 | ||
127 | return &mem->dma; | 127 | return &mem->dma; |
128 | } | 128 | } |
@@ -141,9 +141,14 @@ static int videobuf_dma_init_user_locked(struct videobuf_dmabuf *dma, | |||
141 | 141 | ||
142 | dma->direction = direction; | 142 | dma->direction = direction; |
143 | switch (dma->direction) { | 143 | switch (dma->direction) { |
144 | case PCI_DMA_FROMDEVICE: rw = READ; break; | 144 | case DMA_FROM_DEVICE: |
145 | case PCI_DMA_TODEVICE: rw = WRITE; break; | 145 | rw = READ; |
146 | default: BUG(); | 146 | break; |
147 | case DMA_TO_DEVICE: | ||
148 | rw = WRITE; | ||
149 | break; | ||
150 | default: | ||
151 | BUG(); | ||
147 | } | 152 | } |
148 | 153 | ||
149 | first = (data & PAGE_MASK) >> PAGE_SHIFT; | 154 | first = (data & PAGE_MASK) >> PAGE_SHIFT; |
@@ -157,9 +162,6 @@ static int videobuf_dma_init_user_locked(struct videobuf_dmabuf *dma, | |||
157 | dprintk(1,"init user [0x%lx+0x%lx => %d pages]\n", | 162 | dprintk(1,"init user [0x%lx+0x%lx => %d pages]\n", |
158 | data,size,dma->nr_pages); | 163 | data,size,dma->nr_pages); |
159 | 164 | ||
160 | dma->varea = (void *) data; | ||
161 | |||
162 | |||
163 | err = get_user_pages(current,current->mm, | 165 | err = get_user_pages(current,current->mm, |
164 | data & PAGE_MASK, dma->nr_pages, | 166 | data & PAGE_MASK, dma->nr_pages, |
165 | rw == READ, 1, /* force */ | 167 | rw == READ, 1, /* force */ |
@@ -216,10 +218,8 @@ int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction, | |||
216 | return 0; | 218 | return 0; |
217 | } | 219 | } |
218 | 220 | ||
219 | int videobuf_dma_map(struct videobuf_queue* q,struct videobuf_dmabuf *dma) | 221 | int videobuf_dma_map(struct videobuf_queue* q, struct videobuf_dmabuf *dma) |
220 | { | 222 | { |
221 | void *dev=q->dev; | ||
222 | |||
223 | MAGIC_CHECK(dma->magic,MAGIC_DMABUF); | 223 | MAGIC_CHECK(dma->magic,MAGIC_DMABUF); |
224 | BUG_ON(0 == dma->nr_pages); | 224 | BUG_ON(0 == dma->nr_pages); |
225 | 225 | ||
@@ -245,11 +245,11 @@ int videobuf_dma_map(struct videobuf_queue* q,struct videobuf_dmabuf *dma) | |||
245 | return -ENOMEM; | 245 | return -ENOMEM; |
246 | } | 246 | } |
247 | if (!dma->bus_addr) { | 247 | if (!dma->bus_addr) { |
248 | dma->sglen = pci_map_sg(dev,dma->sglist, | 248 | dma->sglen = dma_map_sg(q->dev, dma->sglist, |
249 | dma->nr_pages, dma->direction); | 249 | dma->nr_pages, dma->direction); |
250 | if (0 == dma->sglen) { | 250 | if (0 == dma->sglen) { |
251 | printk(KERN_WARNING | 251 | printk(KERN_WARNING |
252 | "%s: videobuf_map_sg failed\n",__FUNCTION__); | 252 | "%s: videobuf_map_sg failed\n",__func__); |
253 | kfree(dma->sglist); | 253 | kfree(dma->sglist); |
254 | dma->sglist = NULL; | 254 | dma->sglist = NULL; |
255 | dma->sglen = 0; | 255 | dma->sglen = 0; |
@@ -259,26 +259,22 @@ int videobuf_dma_map(struct videobuf_queue* q,struct videobuf_dmabuf *dma) | |||
259 | return 0; | 259 | return 0; |
260 | } | 260 | } |
261 | 261 | ||
262 | int videobuf_dma_sync(struct videobuf_queue *q,struct videobuf_dmabuf *dma) | 262 | int videobuf_dma_sync(struct videobuf_queue *q, struct videobuf_dmabuf *dma) |
263 | { | 263 | { |
264 | void *dev=q->dev; | 264 | MAGIC_CHECK(dma->magic, MAGIC_DMABUF); |
265 | |||
266 | MAGIC_CHECK(dma->magic,MAGIC_DMABUF); | ||
267 | BUG_ON(!dma->sglen); | 265 | BUG_ON(!dma->sglen); |
268 | 266 | ||
269 | pci_dma_sync_sg_for_cpu (dev,dma->sglist,dma->nr_pages,dma->direction); | 267 | dma_sync_sg_for_cpu(q->dev, dma->sglist, dma->nr_pages, dma->direction); |
270 | return 0; | 268 | return 0; |
271 | } | 269 | } |
272 | 270 | ||
273 | int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma) | 271 | int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma) |
274 | { | 272 | { |
275 | void *dev=q->dev; | 273 | MAGIC_CHECK(dma->magic, MAGIC_DMABUF); |
276 | |||
277 | MAGIC_CHECK(dma->magic,MAGIC_DMABUF); | ||
278 | if (!dma->sglen) | 274 | if (!dma->sglen) |
279 | return 0; | 275 | return 0; |
280 | 276 | ||
281 | pci_unmap_sg (dev,dma->sglist,dma->nr_pages,dma->direction); | 277 | dma_unmap_sg(q->dev, dma->sglist, dma->nr_pages, dma->direction); |
282 | 278 | ||
283 | kfree(dma->sglist); | 279 | kfree(dma->sglist); |
284 | dma->sglist = NULL; | 280 | dma->sglist = NULL; |
@@ -301,33 +297,32 @@ int videobuf_dma_free(struct videobuf_dmabuf *dma) | |||
301 | 297 | ||
302 | vfree(dma->vmalloc); | 298 | vfree(dma->vmalloc); |
303 | dma->vmalloc = NULL; | 299 | dma->vmalloc = NULL; |
304 | dma->varea = NULL; | ||
305 | 300 | ||
306 | if (dma->bus_addr) { | 301 | if (dma->bus_addr) { |
307 | dma->bus_addr = 0; | 302 | dma->bus_addr = 0; |
308 | } | 303 | } |
309 | dma->direction = PCI_DMA_NONE; | 304 | dma->direction = DMA_NONE; |
310 | return 0; | 305 | return 0; |
311 | } | 306 | } |
312 | 307 | ||
313 | /* --------------------------------------------------------------------- */ | 308 | /* --------------------------------------------------------------------- */ |
314 | 309 | ||
315 | int videobuf_pci_dma_map(struct pci_dev *pci,struct videobuf_dmabuf *dma) | 310 | int videobuf_sg_dma_map(struct device *dev, struct videobuf_dmabuf *dma) |
316 | { | 311 | { |
317 | struct videobuf_queue q; | 312 | struct videobuf_queue q; |
318 | 313 | ||
319 | q.dev=pci; | 314 | q.dev = dev; |
320 | 315 | ||
321 | return (videobuf_dma_map(&q,dma)); | 316 | return videobuf_dma_map(&q, dma); |
322 | } | 317 | } |
323 | 318 | ||
324 | int videobuf_pci_dma_unmap(struct pci_dev *pci,struct videobuf_dmabuf *dma) | 319 | int videobuf_sg_dma_unmap(struct device *dev, struct videobuf_dmabuf *dma) |
325 | { | 320 | { |
326 | struct videobuf_queue q; | 321 | struct videobuf_queue q; |
327 | 322 | ||
328 | q.dev=pci; | 323 | q.dev = dev; |
329 | 324 | ||
330 | return (videobuf_dma_unmap(&q,dma)); | 325 | return videobuf_dma_unmap(&q, dma); |
331 | } | 326 | } |
332 | 327 | ||
333 | /* --------------------------------------------------------------------- */ | 328 | /* --------------------------------------------------------------------- */ |
@@ -347,7 +342,7 @@ videobuf_vm_close(struct vm_area_struct *vma) | |||
347 | { | 342 | { |
348 | struct videobuf_mapping *map = vma->vm_private_data; | 343 | struct videobuf_mapping *map = vma->vm_private_data; |
349 | struct videobuf_queue *q = map->q; | 344 | struct videobuf_queue *q = map->q; |
350 | struct videbuf_pci_sg_memory *mem; | 345 | struct videobuf_dma_sg_memory *mem; |
351 | int i; | 346 | int i; |
352 | 347 | ||
353 | dprintk(2,"vm_close %p [count=%d,vma=%08lx-%08lx]\n",map, | 348 | dprintk(2,"vm_close %p [count=%d,vma=%08lx-%08lx]\n",map, |
@@ -409,18 +404,18 @@ static struct vm_operations_struct videobuf_vm_ops = | |||
409 | }; | 404 | }; |
410 | 405 | ||
411 | /* --------------------------------------------------------------------- | 406 | /* --------------------------------------------------------------------- |
412 | * PCI handlers for the generic methods | 407 | * SG handlers for the generic methods |
413 | */ | 408 | */ |
414 | 409 | ||
415 | /* Allocated area consists on 3 parts: | 410 | /* Allocated area consists on 3 parts: |
416 | struct video_buffer | 411 | struct video_buffer |
417 | struct <driver>_buffer (cx88_buffer, saa7134_buf, ...) | 412 | struct <driver>_buffer (cx88_buffer, saa7134_buf, ...) |
418 | struct videobuf_pci_sg_memory | 413 | struct videobuf_dma_sg_memory |
419 | */ | 414 | */ |
420 | 415 | ||
421 | static void *__videobuf_alloc(size_t size) | 416 | static void *__videobuf_alloc(size_t size) |
422 | { | 417 | { |
423 | struct videbuf_pci_sg_memory *mem; | 418 | struct videobuf_dma_sg_memory *mem; |
424 | struct videobuf_buffer *vb; | 419 | struct videobuf_buffer *vb; |
425 | 420 | ||
426 | vb = kzalloc(size+sizeof(*mem),GFP_KERNEL); | 421 | vb = kzalloc(size+sizeof(*mem),GFP_KERNEL); |
@@ -431,22 +426,32 @@ static void *__videobuf_alloc(size_t size) | |||
431 | videobuf_dma_init(&mem->dma); | 426 | videobuf_dma_init(&mem->dma); |
432 | 427 | ||
433 | dprintk(1,"%s: allocated at %p(%ld+%ld) & %p(%ld)\n", | 428 | dprintk(1,"%s: allocated at %p(%ld+%ld) & %p(%ld)\n", |
434 | __FUNCTION__,vb,(long)sizeof(*vb),(long)size-sizeof(*vb), | 429 | __func__,vb,(long)sizeof(*vb),(long)size-sizeof(*vb), |
435 | mem,(long)sizeof(*mem)); | 430 | mem,(long)sizeof(*mem)); |
436 | 431 | ||
437 | return vb; | 432 | return vb; |
438 | } | 433 | } |
439 | 434 | ||
435 | static void *__videobuf_to_vmalloc (struct videobuf_buffer *buf) | ||
436 | { | ||
437 | struct videobuf_dma_sg_memory *mem = buf->priv; | ||
438 | BUG_ON(!mem); | ||
439 | |||
440 | MAGIC_CHECK(mem->magic, MAGIC_SG_MEM); | ||
441 | |||
442 | return mem->dma.vmalloc; | ||
443 | } | ||
444 | |||
440 | static int __videobuf_iolock (struct videobuf_queue* q, | 445 | static int __videobuf_iolock (struct videobuf_queue* q, |
441 | struct videobuf_buffer *vb, | 446 | struct videobuf_buffer *vb, |
442 | struct v4l2_framebuffer *fbuf) | 447 | struct v4l2_framebuffer *fbuf) |
443 | { | 448 | { |
444 | int err,pages; | 449 | int err,pages; |
445 | dma_addr_t bus; | 450 | dma_addr_t bus; |
446 | struct videbuf_pci_sg_memory *mem=vb->priv; | 451 | struct videobuf_dma_sg_memory *mem = vb->priv; |
447 | BUG_ON(!mem); | 452 | BUG_ON(!mem); |
448 | 453 | ||
449 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); | 454 | MAGIC_CHECK(mem->magic, MAGIC_SG_MEM); |
450 | 455 | ||
451 | switch (vb->memory) { | 456 | switch (vb->memory) { |
452 | case V4L2_MEMORY_MMAP: | 457 | case V4L2_MEMORY_MMAP: |
@@ -455,14 +460,14 @@ static int __videobuf_iolock (struct videobuf_queue* q, | |||
455 | /* no userspace addr -- kernel bounce buffer */ | 460 | /* no userspace addr -- kernel bounce buffer */ |
456 | pages = PAGE_ALIGN(vb->size) >> PAGE_SHIFT; | 461 | pages = PAGE_ALIGN(vb->size) >> PAGE_SHIFT; |
457 | err = videobuf_dma_init_kernel( &mem->dma, | 462 | err = videobuf_dma_init_kernel( &mem->dma, |
458 | PCI_DMA_FROMDEVICE, | 463 | DMA_FROM_DEVICE, |
459 | pages ); | 464 | pages ); |
460 | if (0 != err) | 465 | if (0 != err) |
461 | return err; | 466 | return err; |
462 | } else if (vb->memory == V4L2_MEMORY_USERPTR) { | 467 | } else if (vb->memory == V4L2_MEMORY_USERPTR) { |
463 | /* dma directly to userspace */ | 468 | /* dma directly to userspace */ |
464 | err = videobuf_dma_init_user( &mem->dma, | 469 | err = videobuf_dma_init_user( &mem->dma, |
465 | PCI_DMA_FROMDEVICE, | 470 | DMA_FROM_DEVICE, |
466 | vb->baddr,vb->bsize ); | 471 | vb->baddr,vb->bsize ); |
467 | if (0 != err) | 472 | if (0 != err) |
468 | return err; | 473 | return err; |
@@ -473,7 +478,7 @@ static int __videobuf_iolock (struct videobuf_queue* q, | |||
473 | locking inversion, so don't take it here */ | 478 | locking inversion, so don't take it here */ |
474 | 479 | ||
475 | err = videobuf_dma_init_user_locked(&mem->dma, | 480 | err = videobuf_dma_init_user_locked(&mem->dma, |
476 | PCI_DMA_FROMDEVICE, | 481 | DMA_FROM_DEVICE, |
477 | vb->baddr, vb->bsize); | 482 | vb->baddr, vb->bsize); |
478 | if (0 != err) | 483 | if (0 != err) |
479 | return err; | 484 | return err; |
@@ -490,7 +495,7 @@ static int __videobuf_iolock (struct videobuf_queue* q, | |||
490 | */ | 495 | */ |
491 | bus = (dma_addr_t)(unsigned long)fbuf->base + vb->boff; | 496 | bus = (dma_addr_t)(unsigned long)fbuf->base + vb->boff; |
492 | pages = PAGE_ALIGN(vb->size) >> PAGE_SHIFT; | 497 | pages = PAGE_ALIGN(vb->size) >> PAGE_SHIFT; |
493 | err = videobuf_dma_init_overlay(&mem->dma,PCI_DMA_FROMDEVICE, | 498 | err = videobuf_dma_init_overlay(&mem->dma, DMA_FROM_DEVICE, |
494 | bus, pages); | 499 | bus, pages); |
495 | if (0 != err) | 500 | if (0 != err) |
496 | return err; | 501 | return err; |
@@ -498,7 +503,7 @@ static int __videobuf_iolock (struct videobuf_queue* q, | |||
498 | default: | 503 | default: |
499 | BUG(); | 504 | BUG(); |
500 | } | 505 | } |
501 | err = videobuf_dma_map(q,&mem->dma); | 506 | err = videobuf_dma_map(q, &mem->dma); |
502 | if (0 != err) | 507 | if (0 != err) |
503 | return err; | 508 | return err; |
504 | 509 | ||
@@ -508,8 +513,8 @@ static int __videobuf_iolock (struct videobuf_queue* q, | |||
508 | static int __videobuf_sync(struct videobuf_queue *q, | 513 | static int __videobuf_sync(struct videobuf_queue *q, |
509 | struct videobuf_buffer *buf) | 514 | struct videobuf_buffer *buf) |
510 | { | 515 | { |
511 | struct videbuf_pci_sg_memory *mem=buf->priv; | 516 | struct videobuf_dma_sg_memory *mem = buf->priv; |
512 | BUG_ON (!mem); | 517 | BUG_ON(!mem); |
513 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); | 518 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); |
514 | 519 | ||
515 | return videobuf_dma_sync(q,&mem->dma); | 520 | return videobuf_dma_sync(q,&mem->dma); |
@@ -532,7 +537,7 @@ static int __videobuf_mmap_free(struct videobuf_queue *q) | |||
532 | static int __videobuf_mmap_mapper(struct videobuf_queue *q, | 537 | static int __videobuf_mmap_mapper(struct videobuf_queue *q, |
533 | struct vm_area_struct *vma) | 538 | struct vm_area_struct *vma) |
534 | { | 539 | { |
535 | struct videbuf_pci_sg_memory *mem; | 540 | struct videobuf_dma_sg_memory *mem; |
536 | struct videobuf_mapping *map; | 541 | struct videobuf_mapping *map; |
537 | unsigned int first,last,size,i; | 542 | unsigned int first,last,size,i; |
538 | int retval; | 543 | int retval; |
@@ -547,12 +552,20 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, | |||
547 | goto done; | 552 | goto done; |
548 | } | 553 | } |
549 | 554 | ||
555 | /* This function maintains backwards compatibility with V4L1 and will | ||
556 | * map more than one buffer if the vma length is equal to the combined | ||
557 | * size of multiple buffers than it will map them together. See | ||
558 | * VIDIOCGMBUF in the v4l spec | ||
559 | * | ||
560 | * TODO: Allow drivers to specify if they support this mode | ||
561 | */ | ||
562 | |||
550 | /* look for first buffer to map */ | 563 | /* look for first buffer to map */ |
551 | for (first = 0; first < VIDEO_MAX_FRAME; first++) { | 564 | for (first = 0; first < VIDEO_MAX_FRAME; first++) { |
552 | if (NULL == q->bufs[first]) | 565 | if (NULL == q->bufs[first]) |
553 | continue; | 566 | continue; |
554 | mem=q->bufs[first]->priv; | 567 | mem=q->bufs[first]->priv; |
555 | BUG_ON (!mem); | 568 | BUG_ON(!mem); |
556 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); | 569 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); |
557 | 570 | ||
558 | if (V4L2_MEMORY_MMAP != q->bufs[first]->memory) | 571 | if (V4L2_MEMORY_MMAP != q->bufs[first]->memory) |
@@ -591,10 +604,16 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, | |||
591 | map = kmalloc(sizeof(struct videobuf_mapping),GFP_KERNEL); | 604 | map = kmalloc(sizeof(struct videobuf_mapping),GFP_KERNEL); |
592 | if (NULL == map) | 605 | if (NULL == map) |
593 | goto done; | 606 | goto done; |
594 | for (size = 0, i = first; i <= last; size += q->bufs[i++]->bsize) { | 607 | |
608 | size = 0; | ||
609 | for (i = first; i <= last; i++) { | ||
610 | if (NULL == q->bufs[i]) | ||
611 | continue; | ||
595 | q->bufs[i]->map = map; | 612 | q->bufs[i]->map = map; |
596 | q->bufs[i]->baddr = vma->vm_start + size; | 613 | q->bufs[i]->baddr = vma->vm_start + size; |
614 | size += q->bufs[i]->bsize; | ||
597 | } | 615 | } |
616 | |||
598 | map->count = 1; | 617 | map->count = 1; |
599 | map->start = vma->vm_start; | 618 | map->start = vma->vm_start; |
600 | map->end = vma->vm_end; | 619 | map->end = vma->vm_end; |
@@ -615,8 +634,8 @@ static int __videobuf_copy_to_user ( struct videobuf_queue *q, | |||
615 | char __user *data, size_t count, | 634 | char __user *data, size_t count, |
616 | int nonblocking ) | 635 | int nonblocking ) |
617 | { | 636 | { |
618 | struct videbuf_pci_sg_memory *mem=q->read_buf->priv; | 637 | struct videobuf_dma_sg_memory *mem = q->read_buf->priv; |
619 | BUG_ON (!mem); | 638 | BUG_ON(!mem); |
620 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); | 639 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); |
621 | 640 | ||
622 | /* copy to userspace */ | 641 | /* copy to userspace */ |
@@ -634,8 +653,8 @@ static int __videobuf_copy_stream ( struct videobuf_queue *q, | |||
634 | int vbihack, int nonblocking ) | 653 | int vbihack, int nonblocking ) |
635 | { | 654 | { |
636 | unsigned int *fc; | 655 | unsigned int *fc; |
637 | struct videbuf_pci_sg_memory *mem=q->read_buf->priv; | 656 | struct videobuf_dma_sg_memory *mem = q->read_buf->priv; |
638 | BUG_ON (!mem); | 657 | BUG_ON(!mem); |
639 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); | 658 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); |
640 | 659 | ||
641 | if (vbihack) { | 660 | if (vbihack) { |
@@ -658,7 +677,7 @@ static int __videobuf_copy_stream ( struct videobuf_queue *q, | |||
658 | return count; | 677 | return count; |
659 | } | 678 | } |
660 | 679 | ||
661 | static struct videobuf_qtype_ops pci_ops = { | 680 | static struct videobuf_qtype_ops sg_ops = { |
662 | .magic = MAGIC_QTYPE_OPS, | 681 | .magic = MAGIC_QTYPE_OPS, |
663 | 682 | ||
664 | .alloc = __videobuf_alloc, | 683 | .alloc = __videobuf_alloc, |
@@ -668,23 +687,24 @@ static struct videobuf_qtype_ops pci_ops = { | |||
668 | .mmap_mapper = __videobuf_mmap_mapper, | 687 | .mmap_mapper = __videobuf_mmap_mapper, |
669 | .video_copy_to_user = __videobuf_copy_to_user, | 688 | .video_copy_to_user = __videobuf_copy_to_user, |
670 | .copy_stream = __videobuf_copy_stream, | 689 | .copy_stream = __videobuf_copy_stream, |
690 | .vmalloc = __videobuf_to_vmalloc, | ||
671 | }; | 691 | }; |
672 | 692 | ||
673 | void *videobuf_pci_alloc (size_t size) | 693 | void *videobuf_sg_alloc(size_t size) |
674 | { | 694 | { |
675 | struct videobuf_queue q; | 695 | struct videobuf_queue q; |
676 | 696 | ||
677 | /* Required to make generic handler to call __videobuf_alloc */ | 697 | /* Required to make generic handler to call __videobuf_alloc */ |
678 | q.int_ops=&pci_ops; | 698 | q.int_ops = &sg_ops; |
679 | 699 | ||
680 | q.msize=size; | 700 | q.msize = size; |
681 | 701 | ||
682 | return videobuf_alloc (&q); | 702 | return videobuf_alloc(&q); |
683 | } | 703 | } |
684 | 704 | ||
685 | void videobuf_queue_pci_init(struct videobuf_queue* q, | 705 | void videobuf_queue_sg_init(struct videobuf_queue* q, |
686 | struct videobuf_queue_ops *ops, | 706 | struct videobuf_queue_ops *ops, |
687 | void *dev, | 707 | struct device *dev, |
688 | spinlock_t *irqlock, | 708 | spinlock_t *irqlock, |
689 | enum v4l2_buf_type type, | 709 | enum v4l2_buf_type type, |
690 | enum v4l2_field field, | 710 | enum v4l2_field field, |
@@ -692,7 +712,7 @@ void videobuf_queue_pci_init(struct videobuf_queue* q, | |||
692 | void *priv) | 712 | void *priv) |
693 | { | 713 | { |
694 | videobuf_queue_core_init(q, ops, dev, irqlock, type, field, msize, | 714 | videobuf_queue_core_init(q, ops, dev, irqlock, type, field, msize, |
695 | priv, &pci_ops); | 715 | priv, &sg_ops); |
696 | } | 716 | } |
697 | 717 | ||
698 | /* --------------------------------------------------------------------- */ | 718 | /* --------------------------------------------------------------------- */ |
@@ -709,11 +729,11 @@ EXPORT_SYMBOL_GPL(videobuf_dma_sync); | |||
709 | EXPORT_SYMBOL_GPL(videobuf_dma_unmap); | 729 | EXPORT_SYMBOL_GPL(videobuf_dma_unmap); |
710 | EXPORT_SYMBOL_GPL(videobuf_dma_free); | 730 | EXPORT_SYMBOL_GPL(videobuf_dma_free); |
711 | 731 | ||
712 | EXPORT_SYMBOL_GPL(videobuf_pci_dma_map); | 732 | EXPORT_SYMBOL_GPL(videobuf_sg_dma_map); |
713 | EXPORT_SYMBOL_GPL(videobuf_pci_dma_unmap); | 733 | EXPORT_SYMBOL_GPL(videobuf_sg_dma_unmap); |
714 | EXPORT_SYMBOL_GPL(videobuf_pci_alloc); | 734 | EXPORT_SYMBOL_GPL(videobuf_sg_alloc); |
715 | 735 | ||
716 | EXPORT_SYMBOL_GPL(videobuf_queue_pci_init); | 736 | EXPORT_SYMBOL_GPL(videobuf_queue_sg_init); |
717 | 737 | ||
718 | /* | 738 | /* |
719 | * Local variables: | 739 | * Local variables: |