videobuf-dma-sg.c 16.3 KB
Newer Older
1
/*
2
 * helper functions for SG DMA video4linux capture buffers
3
 *
4
 * The functions expect the hardware being able to scatter gather
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 * (i.e. the buffers are not linear in physical memory, but fragmented
 * into PAGE_SIZE chunks).  They also assume the driver does not need
 * to touch the video data.
 *
 * (c) 2007 Mauro Carvalho Chehab, <mchehab@infradead.org>
 *
 * Highly based on video-buf written originally by:
 * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org>
 * (c) 2006 Mauro Carvalho Chehab, <mchehab@infradead.org>
 * (c) 2006 Ted Walther and John Sokol
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2
 */

#include <linux/init.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
24
#include <linux/sched.h>
25 26 27
#include <linux/slab.h>
#include <linux/interrupt.h>

28
#include <linux/dma-mapping.h>
29 30
#include <linux/vmalloc.h>
#include <linux/pagemap.h>
31
#include <linux/scatterlist.h>
32 33 34 35 36 37 38 39
#include <asm/page.h>
#include <asm/pgtable.h>

#include <media/videobuf-dma-sg.h>

#define MAGIC_DMABUF 0x19721112
#define MAGIC_SG_MEM 0x17890714

40 41 42 43 44 45
#define MAGIC_CHECK(is, should)						\
	if (unlikely((is) != (should))) {				\
		printk(KERN_ERR "magic mismatch: %x (expected %x)\n",	\
				is, should);				\
		BUG();							\
	}
46

47
static int debug;
48 49
module_param(debug, int, 0644);

50
MODULE_DESCRIPTION("helper module to manage video4linux dma sg buffers");
51 52 53
MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>");
MODULE_LICENSE("GPL");

54 55 56
#define dprintk(level, fmt, arg...)					\
	if (debug >= level)						\
		printk(KERN_DEBUG "vbuf-sg: " fmt , ## arg)
57 58 59

/* --------------------------------------------------------------------- */

60
struct scatterlist *videobuf_vmalloc_to_sg(unsigned char *virt, int nr_pages)
61 62 63 64 65
{
	struct scatterlist *sglist;
	struct page *pg;
	int i;

66
	sglist = vmalloc(nr_pages * sizeof(*sglist));
67 68
	if (NULL == sglist)
		return NULL;
69
	memset(sglist, 0, nr_pages * sizeof(*sglist));
J
Jens Axboe 已提交
70
	sg_init_table(sglist, nr_pages);
71 72 73 74 75
	for (i = 0; i < nr_pages; i++, virt += PAGE_SIZE) {
		pg = vmalloc_to_page(virt);
		if (NULL == pg)
			goto err;
		BUG_ON(PageHighMem(pg));
76
		sg_set_page(&sglist[i], pg, PAGE_SIZE, 0);
77 78 79
	}
	return sglist;

80
err:
81
	vfree(sglist);
82 83
	return NULL;
}
84
EXPORT_SYMBOL_GPL(videobuf_vmalloc_to_sg);
85

86 87
struct scatterlist *videobuf_pages_to_sg(struct page **pages, int nr_pages,
					 int offset)
88 89
{
	struct scatterlist *sglist;
90
	int i;
91 92 93

	if (NULL == pages[0])
		return NULL;
94
	sglist = vmalloc(nr_pages * sizeof(*sglist));
95 96
	if (NULL == sglist)
		return NULL;
J
Jens Axboe 已提交
97
	sg_init_table(sglist, nr_pages);
98 99 100 101

	if (PageHighMem(pages[0]))
		/* DMA to highmem pages might not work */
		goto highmem;
102
	sg_set_page(&sglist[0], pages[0], PAGE_SIZE - offset, offset);
103 104 105 106 107
	for (i = 1; i < nr_pages; i++) {
		if (NULL == pages[i])
			goto nopage;
		if (PageHighMem(pages[i]))
			goto highmem;
108
		sg_set_page(&sglist[i], pages[i], PAGE_SIZE, 0);
109 110 111
	}
	return sglist;

112 113
nopage:
	dprintk(2, "sgl: oops - no page\n");
114
	vfree(sglist);
115 116
	return NULL;

117 118
highmem:
	dprintk(2, "sgl: oops - highmem page\n");
119
	vfree(sglist);
120 121 122 123 124
	return NULL;
}

/* --------------------------------------------------------------------- */

125
struct videobuf_dmabuf *videobuf_to_dma(struct videobuf_buffer *buf)
126
{
127 128
	struct videobuf_dma_sg_memory *mem = buf->priv;
	BUG_ON(!mem);
129

130
	MAGIC_CHECK(mem->magic, MAGIC_SG_MEM);
131 132 133

	return &mem->dma;
}
134
EXPORT_SYMBOL_GPL(videobuf_to_dma);
135 136 137

void videobuf_dma_init(struct videobuf_dmabuf *dma)
{
138
	memset(dma, 0, sizeof(*dma));
139 140
	dma->magic = MAGIC_DMABUF;
}
141
EXPORT_SYMBOL_GPL(videobuf_dma_init);
142

143 144
static int videobuf_dma_init_user_locked(struct videobuf_dmabuf *dma,
			int direction, unsigned long data, unsigned long size)
145
{
146
	unsigned long first, last;
147 148 149 150
	int err, rw = 0;

	dma->direction = direction;
	switch (dma->direction) {
151 152 153 154 155 156 157 158
	case DMA_FROM_DEVICE:
		rw = READ;
		break;
	case DMA_TO_DEVICE:
		rw = WRITE;
		break;
	default:
		BUG();
159 160 161 162 163 164
	}

	first = (data          & PAGE_MASK) >> PAGE_SHIFT;
	last  = ((data+size-1) & PAGE_MASK) >> PAGE_SHIFT;
	dma->offset   = data & ~PAGE_MASK;
	dma->nr_pages = last-first+1;
165
	dma->pages = kmalloc(dma->nr_pages * sizeof(struct page *), GFP_KERNEL);
166 167 168
	if (NULL == dma->pages)
		return -ENOMEM;

169 170 171 172
	dprintk(1, "init user [0x%lx+0x%lx => %d pages]\n",
		data, size, dma->nr_pages);

	err = get_user_pages(current, current->mm,
173 174 175
			     data & PAGE_MASK, dma->nr_pages,
			     rw == READ, 1, /* force */
			     dma->pages, NULL);
176

177 178
	if (err != dma->nr_pages) {
		dma->nr_pages = (err >= 0) ? err : 0;
179
		dprintk(1, "get_user_pages: err=%d [%d]\n", err, dma->nr_pages);
180 181 182 183 184
		return err < 0 ? err : -EINVAL;
	}
	return 0;
}

185 186 187 188
int videobuf_dma_init_user(struct videobuf_dmabuf *dma, int direction,
			   unsigned long data, unsigned long size)
{
	int ret;
189

190 191 192 193 194 195
	down_read(&current->mm->mmap_sem);
	ret = videobuf_dma_init_user_locked(dma, direction, data, size);
	up_read(&current->mm->mmap_sem);

	return ret;
}
196
EXPORT_SYMBOL_GPL(videobuf_dma_init_user);
197

198 199 200
int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction,
			     int nr_pages)
{
201 202
	dprintk(1, "init kernel [%d pages]\n", nr_pages);

203 204 205
	dma->direction = direction;
	dma->vmalloc = vmalloc_32(nr_pages << PAGE_SHIFT);
	if (NULL == dma->vmalloc) {
206
		dprintk(1, "vmalloc_32(%d pages) failed\n", nr_pages);
207 208
		return -ENOMEM;
	}
209 210

	dprintk(1, "vmalloc is at addr 0x%08lx, size=%d\n",
211 212
				(unsigned long)dma->vmalloc,
				nr_pages << PAGE_SHIFT);
213 214

	memset(dma->vmalloc, 0, nr_pages << PAGE_SHIFT);
215
	dma->nr_pages = nr_pages;
216

217 218
	return 0;
}
219
EXPORT_SYMBOL_GPL(videobuf_dma_init_kernel);
220 221 222 223

int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction,
			      dma_addr_t addr, int nr_pages)
{
224 225
	dprintk(1, "init overlay [%d pages @ bus 0x%lx]\n",
		nr_pages, (unsigned long)addr);
226
	dma->direction = direction;
227

228 229 230 231 232
	if (0 == addr)
		return -EINVAL;

	dma->bus_addr = addr;
	dma->nr_pages = nr_pages;
233

234 235
	return 0;
}
236
EXPORT_SYMBOL_GPL(videobuf_dma_init_overlay);
237

238
int videobuf_dma_map(struct videobuf_queue *q, struct videobuf_dmabuf *dma)
239
{
240
	MAGIC_CHECK(dma->magic, MAGIC_DMABUF);
241 242 243 244 245 246 247
	BUG_ON(0 == dma->nr_pages);

	if (dma->pages) {
		dma->sglist = videobuf_pages_to_sg(dma->pages, dma->nr_pages,
						   dma->offset);
	}
	if (dma->vmalloc) {
248 249
		dma->sglist = videobuf_vmalloc_to_sg(dma->vmalloc,
						     dma->nr_pages);
250 251
	}
	if (dma->bus_addr) {
252
		dma->sglist = vmalloc(sizeof(*dma->sglist));
253
		if (NULL != dma->sglist) {
254 255 256 257 258
			dma->sglen = 1;
			sg_dma_address(&dma->sglist[0])	= dma->bus_addr
							& PAGE_MASK;
			dma->sglist[0].offset = dma->bus_addr & ~PAGE_MASK;
			sg_dma_len(&dma->sglist[0]) = dma->nr_pages * PAGE_SIZE;
259 260 261
		}
	}
	if (NULL == dma->sglist) {
262
		dprintk(1, "scatterlist is NULL\n");
263 264 265
		return -ENOMEM;
	}
	if (!dma->bus_addr) {
266
		dma->sglen = dma_map_sg(q->dev, dma->sglist,
267 268 269
					dma->nr_pages, dma->direction);
		if (0 == dma->sglen) {
			printk(KERN_WARNING
270
			       "%s: videobuf_map_sg failed\n", __func__);
271
			vfree(dma->sglist);
272 273
			dma->sglist = NULL;
			dma->sglen = 0;
274
			return -ENOMEM;
275 276
		}
	}
277

278 279
	return 0;
}
280
EXPORT_SYMBOL_GPL(videobuf_dma_map);
281

282
int videobuf_dma_unmap(struct videobuf_queue *q, struct videobuf_dmabuf *dma)
283
{
284
	MAGIC_CHECK(dma->magic, MAGIC_DMABUF);
285

286 287 288
	if (!dma->sglen)
		return 0;

289
	dma_unmap_sg(q->dev, dma->sglist, dma->sglen, dma->direction);
290

291
	vfree(dma->sglist);
292 293
	dma->sglist = NULL;
	dma->sglen = 0;
294

295 296
	return 0;
}
297
EXPORT_SYMBOL_GPL(videobuf_dma_unmap);
298 299 300

int videobuf_dma_free(struct videobuf_dmabuf *dma)
{
301 302
	int i;
	MAGIC_CHECK(dma->magic, MAGIC_DMABUF);
303 304 305
	BUG_ON(dma->sglen);

	if (dma->pages) {
306
		for (i = 0; i < dma->nr_pages; i++)
307 308 309 310 311 312 313 314
			page_cache_release(dma->pages[i]);
		kfree(dma->pages);
		dma->pages = NULL;
	}

	vfree(dma->vmalloc);
	dma->vmalloc = NULL;

315
	if (dma->bus_addr)
316
		dma->bus_addr = 0;
317
	dma->direction = DMA_NONE;
318

319 320
	return 0;
}
321
EXPORT_SYMBOL_GPL(videobuf_dma_free);
322 323 324

/* --------------------------------------------------------------------- */

325
int videobuf_sg_dma_map(struct device *dev, struct videobuf_dmabuf *dma)
326 327 328
{
	struct videobuf_queue q;

329
	q.dev = dev;
330

331
	return videobuf_dma_map(&q, dma);
332
}
333
EXPORT_SYMBOL_GPL(videobuf_sg_dma_map);
334

335
int videobuf_sg_dma_unmap(struct device *dev, struct videobuf_dmabuf *dma)
336 337 338
{
	struct videobuf_queue q;

339
	q.dev = dev;
340

341
	return videobuf_dma_unmap(&q, dma);
342
}
343
EXPORT_SYMBOL_GPL(videobuf_sg_dma_unmap);
344 345 346

/* --------------------------------------------------------------------- */

347
static void videobuf_vm_open(struct vm_area_struct *vma)
348 349 350
{
	struct videobuf_mapping *map = vma->vm_private_data;

351 352 353
	dprintk(2, "vm_open %p [count=%d,vma=%08lx-%08lx]\n", map,
		map->count, vma->vm_start, vma->vm_end);

354 355 356
	map->count++;
}

357
static void videobuf_vm_close(struct vm_area_struct *vma)
358 359 360
{
	struct videobuf_mapping *map = vma->vm_private_data;
	struct videobuf_queue *q = map->q;
361
	struct videobuf_dma_sg_memory *mem;
362 363
	int i;

364 365
	dprintk(2, "vm_close %p [count=%d,vma=%08lx-%08lx]\n", map,
		map->count, vma->vm_start, vma->vm_end);
366 367 368

	map->count--;
	if (0 == map->count) {
369
		dprintk(1, "munmap %p q=%p\n", map, q);
370
		mutex_lock(&q->vb_lock);
371 372 373
		for (i = 0; i < VIDEO_MAX_FRAME; i++) {
			if (NULL == q->bufs[i])
				continue;
374
			mem = q->bufs[i]->priv;
375 376 377
			if (!mem)
				continue;

378
			MAGIC_CHECK(mem->magic, MAGIC_SG_MEM);
379

380
			if (q->bufs[i]->map != map)
381
				continue;
382
			q->bufs[i]->map   = NULL;
383
			q->bufs[i]->baddr = 0;
384
			q->ops->buf_release(q, q->bufs[i]);
385
		}
386
		mutex_unlock(&q->vb_lock);
387 388 389 390 391 392 393 394 395 396 397
		kfree(map);
	}
	return;
}

/*
 * Get a anonymous page for the mapping.  Make sure we can DMA to that
 * memory location with 32bit PCI devices (i.e. don't use highmem for
 * now ...).  Bounce buffers don't work very well for the data rates
 * video capture has.
 */
398
static int videobuf_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
399 400 401
{
	struct page *page;

402 403 404 405
	dprintk(3, "fault: fault @ %08lx [vma %08lx-%08lx]\n",
		(unsigned long)vmf->virtual_address,
		vma->vm_start, vma->vm_end);

406 407
	page = alloc_page(GFP_USER | __GFP_DMA32);
	if (!page)
408
		return VM_FAULT_OOM;
409
	clear_user_highpage(page, (unsigned long)vmf->virtual_address);
410
	vmf->page = page;
411

412
	return 0;
413 414
}

415 416 417 418
static const struct vm_operations_struct videobuf_vm_ops = {
	.open	= videobuf_vm_open,
	.close	= videobuf_vm_close,
	.fault	= videobuf_vm_fault,
419 420 421
};

/* ---------------------------------------------------------------------
422
 * SG handlers for the generic methods
423 424 425 426 427
 */

/* Allocated area consists on 3 parts:
	struct video_buffer
	struct <driver>_buffer (cx88_buffer, saa7134_buf, ...)
428
	struct videobuf_dma_sg_memory
429 430
 */

431
static struct videobuf_buffer *__videobuf_alloc_vb(size_t size)
432
{
433
	struct videobuf_dma_sg_memory *mem;
434 435
	struct videobuf_buffer *vb;

436
	vb = kzalloc(size + sizeof(*mem), GFP_KERNEL);
437 438
	if (!vb)
		return vb;
439

440 441
	mem = vb->priv = ((char *)vb) + size;
	mem->magic = MAGIC_SG_MEM;
442 443 444

	videobuf_dma_init(&mem->dma);

445 446 447
	dprintk(1, "%s: allocated at %p(%ld+%ld) & %p(%ld)\n",
		__func__, vb, (long)sizeof(*vb), (long)size - sizeof(*vb),
		mem, (long)sizeof(*mem));
448 449 450 451

	return vb;
}

452
static void *__videobuf_to_vaddr(struct videobuf_buffer *buf)
453 454 455 456 457 458 459 460 461
{
	struct videobuf_dma_sg_memory *mem = buf->priv;
	BUG_ON(!mem);

	MAGIC_CHECK(mem->magic, MAGIC_SG_MEM);

	return mem->dma.vmalloc;
}

462 463 464
static int __videobuf_iolock(struct videobuf_queue *q,
			     struct videobuf_buffer *vb,
			     struct v4l2_framebuffer *fbuf)
465
{
466
	int err, pages;
467
	dma_addr_t bus;
468
	struct videobuf_dma_sg_memory *mem = vb->priv;
469 470
	BUG_ON(!mem);

471
	MAGIC_CHECK(mem->magic, MAGIC_SG_MEM);
472 473 474 475 476 477 478

	switch (vb->memory) {
	case V4L2_MEMORY_MMAP:
	case V4L2_MEMORY_USERPTR:
		if (0 == vb->baddr) {
			/* no userspace addr -- kernel bounce buffer */
			pages = PAGE_ALIGN(vb->size) >> PAGE_SHIFT;
479 480 481
			err = videobuf_dma_init_kernel(&mem->dma,
						       DMA_FROM_DEVICE,
						       pages);
482 483
			if (0 != err)
				return err;
484
		} else if (vb->memory == V4L2_MEMORY_USERPTR) {
485
			/* dma directly to userspace */
486 487 488
			err = videobuf_dma_init_user(&mem->dma,
						     DMA_FROM_DEVICE,
						     vb->baddr, vb->bsize);
489 490
			if (0 != err)
				return err;
491 492 493 494 495 496 497
		} else {
			/* NOTE: HACK: videobuf_iolock on V4L2_MEMORY_MMAP
			buffers can only be called from videobuf_qbuf
			we take current->mm->mmap_sem there, to prevent
			locking inversion, so don't take it here */

			err = videobuf_dma_init_user_locked(&mem->dma,
498
						      DMA_FROM_DEVICE,
499 500 501
						      vb->baddr, vb->bsize);
			if (0 != err)
				return err;
502 503 504 505 506 507 508 509 510 511 512 513 514
		}
		break;
	case V4L2_MEMORY_OVERLAY:
		if (NULL == fbuf)
			return -EINVAL;
		/* FIXME: need sanity checks for vb->boff */
		/*
		 * Using a double cast to avoid compiler warnings when
		 * building for PAE. Compiler doesn't like direct casting
		 * of a 32 bit ptr to 64 bit integer.
		 */
		bus   = (dma_addr_t)(unsigned long)fbuf->base + vb->boff;
		pages = PAGE_ALIGN(vb->size) >> PAGE_SHIFT;
515
		err = videobuf_dma_init_overlay(&mem->dma, DMA_FROM_DEVICE,
516 517 518 519 520 521 522
						bus, pages);
		if (0 != err)
			return err;
		break;
	default:
		BUG();
	}
523
	err = videobuf_dma_map(q, &mem->dma);
524 525 526 527 528 529 530 531 532
	if (0 != err)
		return err;

	return 0;
}

static int __videobuf_sync(struct videobuf_queue *q,
			   struct videobuf_buffer *buf)
{
533
	struct videobuf_dma_sg_memory *mem = buf->priv;
534 535
	BUG_ON(!mem || !mem->dma.sglen);

536
	MAGIC_CHECK(mem->magic, MAGIC_SG_MEM);
537
	MAGIC_CHECK(mem->dma.magic, MAGIC_DMABUF);
538

539
	dma_sync_sg_for_cpu(q->dev, mem->dma.sglist,
540
			    mem->dma.sglen, mem->dma.direction);
541 542

	return 0;
543 544 545
}

static int __videobuf_mmap_mapper(struct videobuf_queue *q,
546 547
				  struct videobuf_buffer *buf,
				  struct vm_area_struct *vma)
548
{
549
	struct videobuf_dma_sg_memory *mem = buf->priv;
550
	struct videobuf_mapping *map;
551
	unsigned int first, last, size = 0, i;
552 553 554 555
	int retval;

	retval = -EINVAL;

556 557 558 559 560 561 562 563
	/* This function maintains backwards compatibility with V4L1 and will
	 * map more than one buffer if the vma length is equal to the combined
	 * size of multiple buffers than it will map them together.  See
	 * VIDIOCGMBUF in the v4l spec
	 *
	 * TODO: Allow drivers to specify if they support this mode
	 */

564 565 566
	BUG_ON(!mem);
	MAGIC_CHECK(mem->magic, MAGIC_SG_MEM);

567 568
	/* look for first buffer to map */
	for (first = 0; first < VIDEO_MAX_FRAME; first++) {
569 570
		if (buf == q->bufs[first]) {
			size = PAGE_ALIGN(q->bufs[first]->bsize);
571
			break;
572
		}
573
	}
574 575

	/* paranoia, should never happen since buf is always valid. */
576
	if (!size) {
577
		dprintk(1, "mmap app bug: offset invalid [offset=0x%lx]\n",
578
				(vma->vm_pgoff << PAGE_SHIFT));
579 580 581
		goto done;
	}

582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601
	last = first;
#ifdef CONFIG_VIDEO_V4L1_COMPAT
	if (size != (vma->vm_end - vma->vm_start)) {
		/* look for last buffer to map */
		for (last = first + 1; last < VIDEO_MAX_FRAME; last++) {
			if (NULL == q->bufs[last])
				continue;
			if (V4L2_MEMORY_MMAP != q->bufs[last]->memory)
				continue;
			if (q->bufs[last]->map) {
				retval = -EBUSY;
				goto done;
			}
			size += PAGE_ALIGN(q->bufs[last]->bsize);
			if (size == (vma->vm_end - vma->vm_start))
				break;
		}
		if (VIDEO_MAX_FRAME == last) {
			dprintk(1, "mmap app bug: size invalid [size=0x%lx]\n",
					(vma->vm_end - vma->vm_start));
602 603 604
			goto done;
		}
	}
605
#endif
606 607 608

	/* create mapping + update buffer list */
	retval = -ENOMEM;
609
	map = kmalloc(sizeof(struct videobuf_mapping), GFP_KERNEL);
610 611
	if (NULL == map)
		goto done;
612 613 614 615 616

	size = 0;
	for (i = first; i <= last; i++) {
		if (NULL == q->bufs[i])
			continue;
617
		q->bufs[i]->map   = map;
618
		q->bufs[i]->baddr = vma->vm_start + size;
619
		size += PAGE_ALIGN(q->bufs[i]->bsize);
620
	}
621

622 623 624 625 626 627 628 629
	map->count    = 1;
	map->start    = vma->vm_start;
	map->end      = vma->vm_end;
	map->q        = q;
	vma->vm_ops   = &videobuf_vm_ops;
	vma->vm_flags |= VM_DONTEXPAND | VM_RESERVED;
	vma->vm_flags &= ~VM_IO; /* using shared anonymous pages */
	vma->vm_private_data = map;
630 631
	dprintk(1, "mmap %p: q=%p %08lx-%08lx pgoff %08lx bufs %d-%d\n",
		map, q, vma->vm_start, vma->vm_end, vma->vm_pgoff, first, last);
632 633
	retval = 0;

634
done:
635 636 637
	return retval;
}

638
static struct videobuf_qtype_ops sg_ops = {
639 640
	.magic        = MAGIC_QTYPE_OPS,

641
	.alloc_vb     = __videobuf_alloc_vb,
642 643 644
	.iolock       = __videobuf_iolock,
	.sync         = __videobuf_sync,
	.mmap_mapper  = __videobuf_mmap_mapper,
645
	.vaddr        = __videobuf_to_vaddr,
646 647
};

648
void *videobuf_sg_alloc(size_t size)
649 650 651 652
{
	struct videobuf_queue q;

	/* Required to make generic handler to call __videobuf_alloc */
653
	q.int_ops = &sg_ops;
654

655
	q.msize = size;
656

657
	return videobuf_alloc_vb(&q);
658
}
659
EXPORT_SYMBOL_GPL(videobuf_sg_alloc);
660

661
void videobuf_queue_sg_init(struct videobuf_queue *q,
662
			 const struct videobuf_queue_ops *ops,
663
			 struct device *dev,
664 665 666 667 668 669
			 spinlock_t *irqlock,
			 enum v4l2_buf_type type,
			 enum v4l2_field field,
			 unsigned int msize,
			 void *priv)
{
670
	videobuf_queue_core_init(q, ops, dev, irqlock, type, field, msize,
671
				 priv, &sg_ops);
672
}
673
EXPORT_SYMBOL_GPL(videobuf_queue_sg_init);
674