videobuf2-dma-sg.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. /*
  2. * videobuf2-dma-sg.c - dma scatter/gather memory allocator for videobuf2
  3. *
  4. * Copyright (C) 2010 Samsung Electronics
  5. *
  6. * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation.
  11. */
  12. #include <linux/module.h>
  13. #include <linux/mm.h>
  14. #include <linux/scatterlist.h>
  15. #include <linux/sched.h>
  16. #include <linux/slab.h>
  17. #include <linux/vmalloc.h>
  18. #include <media/videobuf2-v4l2.h>
  19. #include <media/videobuf2-memops.h>
  20. #include <media/videobuf2-dma-sg.h>
  21. static int debug;
  22. module_param(debug, int, 0644);
  23. #define dprintk(level, fmt, arg...) \
  24. do { \
  25. if (debug >= level) \
  26. printk(KERN_DEBUG "vb2-dma-sg: " fmt, ## arg); \
  27. } while (0)
  28. struct vb2_dma_sg_buf {
  29. struct device *dev;
  30. void *vaddr;
  31. struct page **pages;
  32. struct frame_vector *vec;
  33. int offset;
  34. enum dma_data_direction dma_dir;
  35. struct sg_table sg_table;
  36. /*
  37. * This will point to sg_table when used with the MMAP or USERPTR
  38. * memory model, and to the dma_buf sglist when used with the
  39. * DMABUF memory model.
  40. */
  41. struct sg_table *dma_sgt;
  42. size_t size;
  43. unsigned int num_pages;
  44. atomic_t refcount;
  45. struct vb2_vmarea_handler handler;
  46. struct dma_buf_attachment *db_attach;
  47. };
  48. static void vb2_dma_sg_put(void *buf_priv);
  49. static int vb2_dma_sg_alloc_compacted(struct vb2_dma_sg_buf *buf,
  50. gfp_t gfp_flags)
  51. {
  52. unsigned int last_page = 0;
  53. int size = buf->size;
  54. while (size > 0) {
  55. struct page *pages;
  56. int order;
  57. int i;
  58. order = get_order(size);
  59. /* Dont over allocate*/
  60. if ((PAGE_SIZE << order) > size)
  61. order--;
  62. pages = NULL;
  63. while (!pages) {
  64. pages = alloc_pages(GFP_KERNEL | __GFP_ZERO |
  65. __GFP_NOWARN | gfp_flags, order);
  66. if (pages)
  67. break;
  68. if (order == 0) {
  69. while (last_page--)
  70. __free_page(buf->pages[last_page]);
  71. return -ENOMEM;
  72. }
  73. order--;
  74. }
  75. split_page(pages, order);
  76. for (i = 0; i < (1 << order); i++)
  77. buf->pages[last_page++] = &pages[i];
  78. size -= PAGE_SIZE << order;
  79. }
  80. return 0;
  81. }
  82. static void *vb2_dma_sg_alloc(struct device *dev, unsigned long dma_attrs,
  83. unsigned long size, enum dma_data_direction dma_dir,
  84. gfp_t gfp_flags)
  85. {
  86. struct vb2_dma_sg_buf *buf;
  87. struct sg_table *sgt;
  88. int ret;
  89. int num_pages;
  90. if (WARN_ON(dev == NULL))
  91. return NULL;
  92. buf = kzalloc(sizeof *buf, GFP_KERNEL);
  93. if (!buf)
  94. return NULL;
  95. buf->vaddr = NULL;
  96. buf->dma_dir = dma_dir;
  97. buf->offset = 0;
  98. buf->size = size;
  99. /* size is already page aligned */
  100. buf->num_pages = size >> PAGE_SHIFT;
  101. buf->dma_sgt = &buf->sg_table;
  102. buf->pages = kzalloc(buf->num_pages * sizeof(struct page *),
  103. GFP_KERNEL);
  104. if (!buf->pages)
  105. goto fail_pages_array_alloc;
  106. ret = vb2_dma_sg_alloc_compacted(buf, gfp_flags);
  107. if (ret)
  108. goto fail_pages_alloc;
  109. ret = sg_alloc_table_from_pages(buf->dma_sgt, buf->pages,
  110. buf->num_pages, 0, size, GFP_KERNEL);
  111. if (ret)
  112. goto fail_table_alloc;
  113. /* Prevent the device from being released while the buffer is used */
  114. buf->dev = get_device(dev);
  115. sgt = &buf->sg_table;
  116. /*
  117. * No need to sync to the device, this will happen later when the
  118. * prepare() memop is called.
  119. */
  120. sgt->nents = dma_map_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents,
  121. buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
  122. if (!sgt->nents)
  123. goto fail_map;
  124. buf->handler.refcount = &buf->refcount;
  125. buf->handler.put = vb2_dma_sg_put;
  126. buf->handler.arg = buf;
  127. atomic_inc(&buf->refcount);
  128. dprintk(1, "%s: Allocated buffer of %d pages\n",
  129. __func__, buf->num_pages);
  130. return buf;
  131. fail_map:
  132. put_device(buf->dev);
  133. sg_free_table(buf->dma_sgt);
  134. fail_table_alloc:
  135. num_pages = buf->num_pages;
  136. while (num_pages--)
  137. __free_page(buf->pages[num_pages]);
  138. fail_pages_alloc:
  139. kfree(buf->pages);
  140. fail_pages_array_alloc:
  141. kfree(buf);
  142. return NULL;
  143. }
  144. static void vb2_dma_sg_put(void *buf_priv)
  145. {
  146. struct vb2_dma_sg_buf *buf = buf_priv;
  147. struct sg_table *sgt = &buf->sg_table;
  148. int i = buf->num_pages;
  149. if (atomic_dec_and_test(&buf->refcount)) {
  150. dprintk(1, "%s: Freeing buffer of %d pages\n", __func__,
  151. buf->num_pages);
  152. dma_unmap_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents,
  153. buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
  154. if (buf->vaddr)
  155. vm_unmap_ram(buf->vaddr, buf->num_pages);
  156. sg_free_table(buf->dma_sgt);
  157. while (--i >= 0)
  158. __free_page(buf->pages[i]);
  159. kfree(buf->pages);
  160. put_device(buf->dev);
  161. kfree(buf);
  162. }
  163. }
  164. static void vb2_dma_sg_prepare(void *buf_priv)
  165. {
  166. struct vb2_dma_sg_buf *buf = buf_priv;
  167. struct sg_table *sgt = buf->dma_sgt;
  168. /* DMABUF exporter will flush the cache for us */
  169. if (buf->db_attach)
  170. return;
  171. dma_sync_sg_for_device(buf->dev, sgt->sgl, sgt->orig_nents,
  172. buf->dma_dir);
  173. }
  174. static void vb2_dma_sg_finish(void *buf_priv)
  175. {
  176. struct vb2_dma_sg_buf *buf = buf_priv;
  177. struct sg_table *sgt = buf->dma_sgt;
  178. /* DMABUF exporter will flush the cache for us */
  179. if (buf->db_attach)
  180. return;
  181. dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->orig_nents, buf->dma_dir);
  182. }
  183. static void *vb2_dma_sg_get_userptr(struct device *dev, unsigned long vaddr,
  184. unsigned long size,
  185. enum dma_data_direction dma_dir)
  186. {
  187. struct vb2_dma_sg_buf *buf;
  188. struct sg_table *sgt;
  189. struct frame_vector *vec;
  190. buf = kzalloc(sizeof *buf, GFP_KERNEL);
  191. if (!buf)
  192. return NULL;
  193. buf->vaddr = NULL;
  194. buf->dev = dev;
  195. buf->dma_dir = dma_dir;
  196. buf->offset = vaddr & ~PAGE_MASK;
  197. buf->size = size;
  198. buf->dma_sgt = &buf->sg_table;
  199. vec = vb2_create_framevec(vaddr, size, buf->dma_dir == DMA_FROM_DEVICE);
  200. if (IS_ERR(vec))
  201. goto userptr_fail_pfnvec;
  202. buf->vec = vec;
  203. buf->pages = frame_vector_pages(vec);
  204. if (IS_ERR(buf->pages))
  205. goto userptr_fail_sgtable;
  206. buf->num_pages = frame_vector_count(vec);
  207. if (sg_alloc_table_from_pages(buf->dma_sgt, buf->pages,
  208. buf->num_pages, buf->offset, size, 0))
  209. goto userptr_fail_sgtable;
  210. sgt = &buf->sg_table;
  211. /*
  212. * No need to sync to the device, this will happen later when the
  213. * prepare() memop is called.
  214. */
  215. sgt->nents = dma_map_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents,
  216. buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
  217. if (!sgt->nents)
  218. goto userptr_fail_map;
  219. return buf;
  220. userptr_fail_map:
  221. sg_free_table(&buf->sg_table);
  222. userptr_fail_sgtable:
  223. vb2_destroy_framevec(vec);
  224. userptr_fail_pfnvec:
  225. kfree(buf);
  226. return NULL;
  227. }
  228. /*
  229. * @put_userptr: inform the allocator that a USERPTR buffer will no longer
  230. * be used
  231. */
  232. static void vb2_dma_sg_put_userptr(void *buf_priv)
  233. {
  234. struct vb2_dma_sg_buf *buf = buf_priv;
  235. struct sg_table *sgt = &buf->sg_table;
  236. int i = buf->num_pages;
  237. dprintk(1, "%s: Releasing userspace buffer of %d pages\n",
  238. __func__, buf->num_pages);
  239. dma_unmap_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents, buf->dma_dir,
  240. DMA_ATTR_SKIP_CPU_SYNC);
  241. if (buf->vaddr)
  242. vm_unmap_ram(buf->vaddr, buf->num_pages);
  243. sg_free_table(buf->dma_sgt);
  244. while (--i >= 0) {
  245. if (buf->dma_dir == DMA_FROM_DEVICE)
  246. set_page_dirty_lock(buf->pages[i]);
  247. }
  248. vb2_destroy_framevec(buf->vec);
  249. kfree(buf);
  250. }
  251. static void *vb2_dma_sg_vaddr(void *buf_priv)
  252. {
  253. struct vb2_dma_sg_buf *buf = buf_priv;
  254. BUG_ON(!buf);
  255. if (!buf->vaddr) {
  256. if (buf->db_attach)
  257. buf->vaddr = dma_buf_vmap(buf->db_attach->dmabuf);
  258. else
  259. buf->vaddr = vm_map_ram(buf->pages,
  260. buf->num_pages, -1, PAGE_KERNEL);
  261. }
  262. /* add offset in case userptr is not page-aligned */
  263. return buf->vaddr ? buf->vaddr + buf->offset : NULL;
  264. }
  265. static unsigned int vb2_dma_sg_num_users(void *buf_priv)
  266. {
  267. struct vb2_dma_sg_buf *buf = buf_priv;
  268. return atomic_read(&buf->refcount);
  269. }
  270. static int vb2_dma_sg_mmap(void *buf_priv, struct vm_area_struct *vma)
  271. {
  272. struct vb2_dma_sg_buf *buf = buf_priv;
  273. unsigned long uaddr = vma->vm_start;
  274. unsigned long usize = vma->vm_end - vma->vm_start;
  275. int i = 0;
  276. if (!buf) {
  277. printk(KERN_ERR "No memory to map\n");
  278. return -EINVAL;
  279. }
  280. do {
  281. int ret;
  282. ret = vm_insert_page(vma, uaddr, buf->pages[i++]);
  283. if (ret) {
  284. printk(KERN_ERR "Remapping memory, error: %d\n", ret);
  285. return ret;
  286. }
  287. uaddr += PAGE_SIZE;
  288. usize -= PAGE_SIZE;
  289. } while (usize > 0);
  290. /*
  291. * Use common vm_area operations to track buffer refcount.
  292. */
  293. vma->vm_private_data = &buf->handler;
  294. vma->vm_ops = &vb2_common_vm_ops;
  295. vma->vm_ops->open(vma);
  296. return 0;
  297. }
  298. /*********************************************/
  299. /* DMABUF ops for exporters */
  300. /*********************************************/
  301. struct vb2_dma_sg_attachment {
  302. struct sg_table sgt;
  303. enum dma_data_direction dma_dir;
  304. };
  305. static int vb2_dma_sg_dmabuf_ops_attach(struct dma_buf *dbuf, struct device *dev,
  306. struct dma_buf_attachment *dbuf_attach)
  307. {
  308. struct vb2_dma_sg_attachment *attach;
  309. unsigned int i;
  310. struct scatterlist *rd, *wr;
  311. struct sg_table *sgt;
  312. struct vb2_dma_sg_buf *buf = dbuf->priv;
  313. int ret;
  314. attach = kzalloc(sizeof(*attach), GFP_KERNEL);
  315. if (!attach)
  316. return -ENOMEM;
  317. sgt = &attach->sgt;
  318. /* Copy the buf->base_sgt scatter list to the attachment, as we can't
  319. * map the same scatter list to multiple attachments at the same time.
  320. */
  321. ret = sg_alloc_table(sgt, buf->dma_sgt->orig_nents, GFP_KERNEL);
  322. if (ret) {
  323. kfree(attach);
  324. return -ENOMEM;
  325. }
  326. rd = buf->dma_sgt->sgl;
  327. wr = sgt->sgl;
  328. for (i = 0; i < sgt->orig_nents; ++i) {
  329. sg_set_page(wr, sg_page(rd), rd->length, rd->offset);
  330. rd = sg_next(rd);
  331. wr = sg_next(wr);
  332. }
  333. attach->dma_dir = DMA_NONE;
  334. dbuf_attach->priv = attach;
  335. return 0;
  336. }
  337. static void vb2_dma_sg_dmabuf_ops_detach(struct dma_buf *dbuf,
  338. struct dma_buf_attachment *db_attach)
  339. {
  340. struct vb2_dma_sg_attachment *attach = db_attach->priv;
  341. struct sg_table *sgt;
  342. if (!attach)
  343. return;
  344. sgt = &attach->sgt;
  345. /* release the scatterlist cache */
  346. if (attach->dma_dir != DMA_NONE)
  347. dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents,
  348. attach->dma_dir);
  349. sg_free_table(sgt);
  350. kfree(attach);
  351. db_attach->priv = NULL;
  352. }
  353. static struct sg_table *vb2_dma_sg_dmabuf_ops_map(
  354. struct dma_buf_attachment *db_attach, enum dma_data_direction dma_dir)
  355. {
  356. struct vb2_dma_sg_attachment *attach = db_attach->priv;
  357. /* stealing dmabuf mutex to serialize map/unmap operations */
  358. struct mutex *lock = &db_attach->dmabuf->lock;
  359. struct sg_table *sgt;
  360. mutex_lock(lock);
  361. sgt = &attach->sgt;
  362. /* return previously mapped sg table */
  363. if (attach->dma_dir == dma_dir) {
  364. mutex_unlock(lock);
  365. return sgt;
  366. }
  367. /* release any previous cache */
  368. if (attach->dma_dir != DMA_NONE) {
  369. dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents,
  370. attach->dma_dir);
  371. attach->dma_dir = DMA_NONE;
  372. }
  373. /* mapping to the client with new direction */
  374. sgt->nents = dma_map_sg(db_attach->dev, sgt->sgl, sgt->orig_nents,
  375. dma_dir);
  376. if (!sgt->nents) {
  377. pr_err("failed to map scatterlist\n");
  378. mutex_unlock(lock);
  379. return ERR_PTR(-EIO);
  380. }
  381. attach->dma_dir = dma_dir;
  382. mutex_unlock(lock);
  383. return sgt;
  384. }
  385. static void vb2_dma_sg_dmabuf_ops_unmap(struct dma_buf_attachment *db_attach,
  386. struct sg_table *sgt, enum dma_data_direction dma_dir)
  387. {
  388. /* nothing to be done here */
  389. }
  390. static void vb2_dma_sg_dmabuf_ops_release(struct dma_buf *dbuf)
  391. {
  392. /* drop reference obtained in vb2_dma_sg_get_dmabuf */
  393. vb2_dma_sg_put(dbuf->priv);
  394. }
  395. static void *vb2_dma_sg_dmabuf_ops_kmap(struct dma_buf *dbuf, unsigned long pgnum)
  396. {
  397. struct vb2_dma_sg_buf *buf = dbuf->priv;
  398. return buf->vaddr ? buf->vaddr + pgnum * PAGE_SIZE : NULL;
  399. }
  400. static void *vb2_dma_sg_dmabuf_ops_vmap(struct dma_buf *dbuf)
  401. {
  402. struct vb2_dma_sg_buf *buf = dbuf->priv;
  403. return vb2_dma_sg_vaddr(buf);
  404. }
  405. static int vb2_dma_sg_dmabuf_ops_mmap(struct dma_buf *dbuf,
  406. struct vm_area_struct *vma)
  407. {
  408. return vb2_dma_sg_mmap(dbuf->priv, vma);
  409. }
  410. static struct dma_buf_ops vb2_dma_sg_dmabuf_ops = {
  411. .attach = vb2_dma_sg_dmabuf_ops_attach,
  412. .detach = vb2_dma_sg_dmabuf_ops_detach,
  413. .map_dma_buf = vb2_dma_sg_dmabuf_ops_map,
  414. .unmap_dma_buf = vb2_dma_sg_dmabuf_ops_unmap,
  415. .kmap = vb2_dma_sg_dmabuf_ops_kmap,
  416. .kmap_atomic = vb2_dma_sg_dmabuf_ops_kmap,
  417. .vmap = vb2_dma_sg_dmabuf_ops_vmap,
  418. .mmap = vb2_dma_sg_dmabuf_ops_mmap,
  419. .release = vb2_dma_sg_dmabuf_ops_release,
  420. };
  421. static struct dma_buf *vb2_dma_sg_get_dmabuf(void *buf_priv, unsigned long flags)
  422. {
  423. struct vb2_dma_sg_buf *buf = buf_priv;
  424. struct dma_buf *dbuf;
  425. DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
  426. exp_info.ops = &vb2_dma_sg_dmabuf_ops;
  427. exp_info.size = buf->size;
  428. exp_info.flags = flags;
  429. exp_info.priv = buf;
  430. if (WARN_ON(!buf->dma_sgt))
  431. return NULL;
  432. dbuf = dma_buf_export(&exp_info);
  433. if (IS_ERR(dbuf))
  434. return NULL;
  435. /* dmabuf keeps reference to vb2 buffer */
  436. atomic_inc(&buf->refcount);
  437. return dbuf;
  438. }
  439. /*********************************************/
  440. /* callbacks for DMABUF buffers */
  441. /*********************************************/
  442. static int vb2_dma_sg_map_dmabuf(void *mem_priv)
  443. {
  444. struct vb2_dma_sg_buf *buf = mem_priv;
  445. struct sg_table *sgt;
  446. if (WARN_ON(!buf->db_attach)) {
  447. pr_err("trying to pin a non attached buffer\n");
  448. return -EINVAL;
  449. }
  450. if (WARN_ON(buf->dma_sgt)) {
  451. pr_err("dmabuf buffer is already pinned\n");
  452. return 0;
  453. }
  454. /* get the associated scatterlist for this buffer */
  455. sgt = dma_buf_map_attachment(buf->db_attach, buf->dma_dir);
  456. if (IS_ERR(sgt)) {
  457. pr_err("Error getting dmabuf scatterlist\n");
  458. return -EINVAL;
  459. }
  460. buf->dma_sgt = sgt;
  461. buf->vaddr = NULL;
  462. return 0;
  463. }
  464. static void vb2_dma_sg_unmap_dmabuf(void *mem_priv)
  465. {
  466. struct vb2_dma_sg_buf *buf = mem_priv;
  467. struct sg_table *sgt = buf->dma_sgt;
  468. if (WARN_ON(!buf->db_attach)) {
  469. pr_err("trying to unpin a not attached buffer\n");
  470. return;
  471. }
  472. if (WARN_ON(!sgt)) {
  473. pr_err("dmabuf buffer is already unpinned\n");
  474. return;
  475. }
  476. if (buf->vaddr) {
  477. dma_buf_vunmap(buf->db_attach->dmabuf, buf->vaddr);
  478. buf->vaddr = NULL;
  479. }
  480. dma_buf_unmap_attachment(buf->db_attach, sgt, buf->dma_dir);
  481. buf->dma_sgt = NULL;
  482. }
  483. static void vb2_dma_sg_detach_dmabuf(void *mem_priv)
  484. {
  485. struct vb2_dma_sg_buf *buf = mem_priv;
  486. /* if vb2 works correctly you should never detach mapped buffer */
  487. if (WARN_ON(buf->dma_sgt))
  488. vb2_dma_sg_unmap_dmabuf(buf);
  489. /* detach this attachment */
  490. dma_buf_detach(buf->db_attach->dmabuf, buf->db_attach);
  491. kfree(buf);
  492. }
  493. static void *vb2_dma_sg_attach_dmabuf(struct device *dev, struct dma_buf *dbuf,
  494. unsigned long size, enum dma_data_direction dma_dir)
  495. {
  496. struct vb2_dma_sg_buf *buf;
  497. struct dma_buf_attachment *dba;
  498. if (dbuf->size < size)
  499. return ERR_PTR(-EFAULT);
  500. buf = kzalloc(sizeof(*buf), GFP_KERNEL);
  501. if (!buf)
  502. return ERR_PTR(-ENOMEM);
  503. buf->dev = dev;
  504. /* create attachment for the dmabuf with the user device */
  505. dba = dma_buf_attach(dbuf, buf->dev);
  506. if (IS_ERR(dba)) {
  507. pr_err("failed to attach dmabuf\n");
  508. kfree(buf);
  509. return dba;
  510. }
  511. buf->dma_dir = dma_dir;
  512. buf->size = size;
  513. buf->db_attach = dba;
  514. return buf;
  515. }
  516. static void *vb2_dma_sg_cookie(void *buf_priv)
  517. {
  518. struct vb2_dma_sg_buf *buf = buf_priv;
  519. return buf->dma_sgt;
  520. }
  521. const struct vb2_mem_ops vb2_dma_sg_memops = {
  522. .alloc = vb2_dma_sg_alloc,
  523. .put = vb2_dma_sg_put,
  524. .get_userptr = vb2_dma_sg_get_userptr,
  525. .put_userptr = vb2_dma_sg_put_userptr,
  526. .prepare = vb2_dma_sg_prepare,
  527. .finish = vb2_dma_sg_finish,
  528. .vaddr = vb2_dma_sg_vaddr,
  529. .mmap = vb2_dma_sg_mmap,
  530. .num_users = vb2_dma_sg_num_users,
  531. .get_dmabuf = vb2_dma_sg_get_dmabuf,
  532. .map_dmabuf = vb2_dma_sg_map_dmabuf,
  533. .unmap_dmabuf = vb2_dma_sg_unmap_dmabuf,
  534. .attach_dmabuf = vb2_dma_sg_attach_dmabuf,
  535. .detach_dmabuf = vb2_dma_sg_detach_dmabuf,
  536. .cookie = vb2_dma_sg_cookie,
  537. };
  538. EXPORT_SYMBOL_GPL(vb2_dma_sg_memops);
  539. MODULE_DESCRIPTION("dma scatter/gather memory handling routines for videobuf2");
  540. MODULE_AUTHOR("Andrzej Pietrasiewicz");
  541. MODULE_LICENSE("GPL");