Duy Truong | 790f06d | 2013-02-13 16:38:12 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 2 | * |
| 3 | * Based on videobuf-dma-contig.c, |
| 4 | * (c) 2008 Magnus Damm |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 and |
| 8 | * only version 2 as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * helper functions for physically contiguous pmem capture buffers |
| 16 | * The functions support contiguous memory allocations using pmem |
| 17 | * kernel API. |
| 18 | */ |
| 19 | |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/module.h> |
| 22 | #include <linux/mm.h> |
| 23 | #include <linux/slab.h> |
| 24 | #include <linux/pagemap.h> |
| 25 | #include <linux/sched.h> |
| 26 | #include <linux/io.h> |
Laura Abbott | 17b7dbe | 2013-03-09 15:59:25 -0800 | [diff] [blame] | 27 | |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 28 | #include <linux/memory_alloc.h> |
| 29 | #include <media/videobuf2-msm-mem.h> |
| 30 | #include <media/msm_camera.h> |
| 31 | #include <mach/memory.h> |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 32 | #include <media/videobuf2-core.h> |
Laura Abbott | 5b1e6f1 | 2012-05-28 08:13:55 -0700 | [diff] [blame] | 33 | #include <mach/iommu_domains.h> |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 34 | |
| 35 | #define MAGIC_PMEM 0x0733ac64 |
| 36 | #define MAGIC_CHECK(is, should) \ |
| 37 | if (unlikely((is) != (should))) { \ |
| 38 | pr_err("magic mismatch: %x expected %x\n", (is), (should)); \ |
| 39 | BUG(); \ |
| 40 | } |
| 41 | |
| 42 | #ifdef CONFIG_MSM_CAMERA_DEBUG |
| 43 | #define D(fmt, args...) pr_debug("videobuf-msm-mem: " fmt, ##args) |
| 44 | #else |
| 45 | #define D(fmt, args...) do {} while (0) |
| 46 | #endif |
| 47 | |
Ankit Premrajka | 4594296 | 2012-02-15 19:21:25 -0800 | [diff] [blame] | 48 | static unsigned long msm_mem_allocate(struct videobuf2_contig_pmem *mem) |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 49 | { |
Ankit Premrajka | 4594296 | 2012-02-15 19:21:25 -0800 | [diff] [blame] | 50 | unsigned long phyaddr; |
Ankit Premrajka | d814743 | 2012-01-06 09:45:11 -0800 | [diff] [blame] | 51 | #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION |
| 52 | int rc, len; |
| 53 | mem->client = msm_ion_client_create(-1, "camera"); |
| 54 | if (IS_ERR((void *)mem->client)) { |
| 55 | pr_err("%s Could not create client\n", __func__); |
| 56 | goto client_failed; |
| 57 | } |
| 58 | mem->ion_handle = ion_alloc(mem->client, mem->size, SZ_4K, |
Hanumant Singh | 7d72bad | 2012-08-29 18:39:44 -0700 | [diff] [blame] | 59 | (0x1 << ION_CP_MM_HEAP_ID | 0x1 << ION_IOMMU_HEAP_ID), 0); |
Ankit Premrajka | d814743 | 2012-01-06 09:45:11 -0800 | [diff] [blame] | 60 | if (IS_ERR((void *)mem->ion_handle)) { |
| 61 | pr_err("%s Could not allocate\n", __func__); |
| 62 | goto alloc_failed; |
| 63 | } |
Ankit Premrajka | 4594296 | 2012-02-15 19:21:25 -0800 | [diff] [blame] | 64 | rc = ion_map_iommu(mem->client, mem->ion_handle, |
Ankit Premrajka | 79b9f22 | 2012-07-02 12:38:34 -0700 | [diff] [blame] | 65 | -1, 0, SZ_4K, 0, |
Ankit Premrajka | 4594296 | 2012-02-15 19:21:25 -0800 | [diff] [blame] | 66 | (unsigned long *)&phyaddr, |
Mitchel Humpherys | 76b9b4d | 2012-09-17 14:33:22 -0700 | [diff] [blame] | 67 | (unsigned long *)&len, 0, 0); |
Ankit Premrajka | d814743 | 2012-01-06 09:45:11 -0800 | [diff] [blame] | 68 | if (rc < 0) { |
| 69 | pr_err("%s Could not get physical address\n", __func__); |
| 70 | goto phys_failed; |
| 71 | } |
| 72 | #else |
| 73 | phyaddr = allocate_contiguous_ebi_nomap(mem->size, SZ_4K); |
| 74 | #endif |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 75 | return phyaddr; |
Ankit Premrajka | d814743 | 2012-01-06 09:45:11 -0800 | [diff] [blame] | 76 | #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION |
| 77 | phys_failed: |
| 78 | ion_free(mem->client, mem->ion_handle); |
| 79 | alloc_failed: |
| 80 | ion_client_destroy(mem->client); |
| 81 | client_failed: |
| 82 | return 0; |
| 83 | #endif |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 84 | } |
| 85 | |
Ankit Premrajka | d814743 | 2012-01-06 09:45:11 -0800 | [diff] [blame] | 86 | static int32_t msm_mem_free(struct videobuf2_contig_pmem *mem) |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 87 | { |
| 88 | int32_t rc = 0; |
Ankit Premrajka | d814743 | 2012-01-06 09:45:11 -0800 | [diff] [blame] | 89 | #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION |
Ankit Premrajka | 79b9f22 | 2012-07-02 12:38:34 -0700 | [diff] [blame] | 90 | ion_unmap_iommu(mem->client, mem->ion_handle, -1, 0); |
Ankit Premrajka | d814743 | 2012-01-06 09:45:11 -0800 | [diff] [blame] | 91 | ion_free(mem->client, mem->ion_handle); |
| 92 | ion_client_destroy(mem->client); |
| 93 | #else |
| 94 | free_contiguous_memory_by_paddr(mem->phyaddr); |
| 95 | #endif |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 96 | return rc; |
| 97 | } |
| 98 | |
| 99 | static void videobuf2_vm_close(struct vm_area_struct *vma) |
| 100 | { |
| 101 | struct videobuf2_contig_pmem *mem = vma->vm_private_data; |
| 102 | D("vm_close %p [count=%u,vma=%08lx-%08lx]\n", |
| 103 | mem, mem->count, vma->vm_start, vma->vm_end); |
| 104 | mem->count--; |
| 105 | } |
| 106 | static void videobuf2_vm_open(struct vm_area_struct *vma) |
| 107 | { |
| 108 | struct videobuf2_contig_pmem *mem = vma->vm_private_data; |
| 109 | D("vm_open %p [count=%u,vma=%08lx-%08lx]\n", |
| 110 | mem, mem->count, vma->vm_start, vma->vm_end); |
| 111 | mem->count++; |
| 112 | } |
| 113 | |
| 114 | static const struct vm_operations_struct videobuf2_vm_ops = { |
| 115 | .open = videobuf2_vm_open, |
| 116 | .close = videobuf2_vm_close, |
| 117 | }; |
| 118 | |
| 119 | static void *msm_vb2_mem_ops_alloc(void *alloc_ctx, unsigned long size) |
| 120 | { |
| 121 | struct videobuf2_contig_pmem *mem; |
| 122 | mem = kzalloc(sizeof(*mem), GFP_KERNEL); |
| 123 | if (!mem) |
| 124 | return ERR_PTR(-ENOMEM); |
| 125 | |
| 126 | mem->magic = MAGIC_PMEM; |
| 127 | mem->size = PAGE_ALIGN(size); |
| 128 | mem->alloc_ctx = alloc_ctx; |
| 129 | mem->is_userptr = 0; |
Ankit Premrajka | d814743 | 2012-01-06 09:45:11 -0800 | [diff] [blame] | 130 | mem->phyaddr = msm_mem_allocate(mem); |
Ankit Premrajka | a5ea3a9 | 2011-08-04 17:54:17 -0700 | [diff] [blame] | 131 | if (!mem->phyaddr) { |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 132 | pr_err("%s : pmem memory allocation failed\n", __func__); |
| 133 | kfree(mem); |
| 134 | return ERR_PTR(-ENOMEM); |
| 135 | } |
Ankit Premrajka | 4594296 | 2012-02-15 19:21:25 -0800 | [diff] [blame] | 136 | mem->mapped_phyaddr = mem->phyaddr; |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 137 | return mem; |
| 138 | } |
| 139 | static void msm_vb2_mem_ops_put(void *buf_priv) |
| 140 | { |
| 141 | struct videobuf2_contig_pmem *mem = buf_priv; |
Ankit Premrajka | c6864b8 | 2011-07-15 11:43:41 -0700 | [diff] [blame] | 142 | if (!mem->is_userptr) { |
| 143 | D("%s Freeing memory ", __func__); |
Ankit Premrajka | d814743 | 2012-01-06 09:45:11 -0800 | [diff] [blame] | 144 | msm_mem_free(mem); |
Ankit Premrajka | c6864b8 | 2011-07-15 11:43:41 -0700 | [diff] [blame] | 145 | } |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 146 | kfree(mem); |
| 147 | } |
| 148 | int videobuf2_pmem_contig_mmap_get(struct videobuf2_contig_pmem *mem, |
Kiran Kumar H N | 5e08d77 | 2011-10-03 10:19:15 -0700 | [diff] [blame] | 149 | struct videobuf2_msm_offset *offset, |
| 150 | enum videobuf2_buffer_type buffer_type, |
| 151 | int path) |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 152 | { |
Kiran Kumar H N | 5e08d77 | 2011-10-03 10:19:15 -0700 | [diff] [blame] | 153 | if (offset) |
| 154 | mem->offset = *offset; |
| 155 | else |
| 156 | memset(&mem->offset, 0, sizeof(struct videobuf2_msm_offset)); |
| 157 | mem->buffer_type = buffer_type; |
| 158 | mem->path = path; |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 159 | return 0; |
| 160 | } |
| 161 | EXPORT_SYMBOL_GPL(videobuf2_pmem_contig_mmap_get); |
| 162 | |
| 163 | /** |
| 164 | * videobuf_pmem_contig_user_get() - setup user space memory pointer |
| 165 | * @mem: per-buffer private videobuf-contig-pmem data |
| 166 | * @vb: video buffer to map |
| 167 | * |
| 168 | * This function validates and sets up a pointer to user space memory. |
| 169 | * Only physically contiguous pfn-mapped memory is accepted. |
| 170 | * |
| 171 | * Returns 0 if successful. |
| 172 | */ |
| 173 | int videobuf2_pmem_contig_user_get(struct videobuf2_contig_pmem *mem, |
Kiran Kumar H N | 5e08d77 | 2011-10-03 10:19:15 -0700 | [diff] [blame] | 174 | struct videobuf2_msm_offset *offset, |
| 175 | enum videobuf2_buffer_type buffer_type, |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 176 | uint32_t addr_offset, int path, |
Ankit Premrajka | 79b9f22 | 2012-07-02 12:38:34 -0700 | [diff] [blame] | 177 | struct ion_client *client, |
| 178 | int domain_num) |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 179 | { |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 180 | int rc = 0; |
Laura Abbott | 17b7dbe | 2013-03-09 15:59:25 -0800 | [diff] [blame] | 181 | #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION |
| 182 | unsigned long len; |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 183 | #endif |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 184 | unsigned long paddr = 0; |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 185 | if (mem->phyaddr != 0) |
| 186 | return 0; |
Laura Abbott | 17b7dbe | 2013-03-09 15:59:25 -0800 | [diff] [blame] | 187 | #if defined(CONFIG_MSM_MULTIMEDIA_USE_ION) |
Laura Abbott | b14ed96 | 2012-01-30 14:18:08 -0800 | [diff] [blame] | 188 | mem->ion_handle = ion_import_dma_buf(client, (int)mem->vaddr); |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 189 | if (IS_ERR_OR_NULL(mem->ion_handle)) { |
| 190 | pr_err("%s ION import failed\n", __func__); |
| 191 | return PTR_ERR(mem->ion_handle); |
| 192 | } |
Ankit Premrajka | 79b9f22 | 2012-07-02 12:38:34 -0700 | [diff] [blame] | 193 | rc = ion_map_iommu(client, mem->ion_handle, domain_num, 0, |
Mitchel Humpherys | 76b9b4d | 2012-09-17 14:33:22 -0700 | [diff] [blame] | 194 | SZ_4K, 0, (unsigned long *)&mem->phyaddr, &len, 0, 0); |
Ankit Premrajka | 4594296 | 2012-02-15 19:21:25 -0800 | [diff] [blame] | 195 | if (rc < 0) |
| 196 | ion_free(client, mem->ion_handle); |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 197 | #else |
| 198 | paddr = 0; |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 199 | #endif |
Kiran Kumar H N | 5e08d77 | 2011-10-03 10:19:15 -0700 | [diff] [blame] | 200 | if (offset) |
| 201 | mem->offset = *offset; |
| 202 | else |
| 203 | memset(&mem->offset, 0, sizeof(struct videobuf2_msm_offset)); |
| 204 | mem->path = path; |
| 205 | mem->buffer_type = buffer_type; |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 206 | paddr = mem->phyaddr; |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 207 | mem->mapped_phyaddr = paddr + addr_offset; |
Kevin Chan | 318d7cb | 2011-11-29 14:24:26 -0800 | [diff] [blame] | 208 | mem->addr_offset = addr_offset; |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 209 | return rc; |
| 210 | } |
| 211 | EXPORT_SYMBOL_GPL(videobuf2_pmem_contig_user_get); |
| 212 | |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 213 | void videobuf2_pmem_contig_user_put(struct videobuf2_contig_pmem *mem, |
Ankit Premrajka | 79b9f22 | 2012-07-02 12:38:34 -0700 | [diff] [blame] | 214 | struct ion_client *client, int domain_num) |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 215 | { |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 216 | if (mem->is_userptr) { |
Laura Abbott | 17b7dbe | 2013-03-09 15:59:25 -0800 | [diff] [blame] | 217 | #if defined(CONFIG_MSM_MULTIMEDIA_USE_ION) |
Ankit Premrajka | 4594296 | 2012-02-15 19:21:25 -0800 | [diff] [blame] | 218 | ion_unmap_iommu(client, mem->ion_handle, |
Ankit Premrajka | 79b9f22 | 2012-07-02 12:38:34 -0700 | [diff] [blame] | 219 | domain_num, 0); |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 220 | ion_free(client, mem->ion_handle); |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 221 | #endif |
| 222 | } |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 223 | mem->is_userptr = 0; |
| 224 | mem->phyaddr = 0; |
| 225 | mem->size = 0; |
Kiran Kumar H N | ceea762 | 2011-08-23 14:01:03 -0700 | [diff] [blame] | 226 | mem->mapped_phyaddr = 0; |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 227 | } |
| 228 | EXPORT_SYMBOL_GPL(videobuf2_pmem_contig_user_put); |
| 229 | |
| 230 | static void *msm_vb2_mem_ops_get_userptr(void *alloc_ctx, unsigned long vaddr, |
| 231 | unsigned long size, int write) |
| 232 | { |
| 233 | struct videobuf2_contig_pmem *mem; |
| 234 | mem = kzalloc(sizeof(*mem), GFP_KERNEL); |
| 235 | if (!mem) |
| 236 | return ERR_PTR(-ENOMEM); |
| 237 | mem->magic = MAGIC_PMEM; |
| 238 | mem->is_userptr = 1; |
| 239 | mem->vaddr = (void *)vaddr; |
| 240 | mem->size = size; |
| 241 | mem->alloc_ctx = alloc_ctx; |
| 242 | return mem; |
| 243 | } |
| 244 | static void msm_vb2_mem_ops_put_userptr(void *buf_priv) |
| 245 | { |
| 246 | kfree(buf_priv); |
| 247 | } |
| 248 | |
| 249 | static void *msm_vb2_mem_ops_vaddr(void *buf_priv) |
| 250 | { |
| 251 | struct videobuf2_contig_pmem *mem = buf_priv; |
| 252 | return mem->vaddr; |
| 253 | } |
| 254 | static void *msm_vb2_mem_ops_cookie(void *buf_priv) |
| 255 | { |
| 256 | return buf_priv; |
| 257 | } |
| 258 | static unsigned int msm_vb2_mem_ops_num_users(void *buf_priv) |
| 259 | { |
| 260 | struct videobuf2_contig_pmem *mem = buf_priv; |
| 261 | MAGIC_CHECK(mem->magic, MAGIC_PMEM); |
| 262 | return mem->count; |
| 263 | } |
| 264 | static int msm_vb2_mem_ops_mmap(void *buf_priv, struct vm_area_struct *vma) |
| 265 | { |
| 266 | struct videobuf2_contig_pmem *mem; |
| 267 | int retval; |
| 268 | unsigned long size; |
| 269 | D("%s\n", __func__); |
| 270 | mem = buf_priv; |
| 271 | D("mem = 0x%x\n", (u32)mem); |
| 272 | BUG_ON(!mem); |
| 273 | MAGIC_CHECK(mem->magic, MAGIC_PMEM); |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 274 | /* Try to remap memory */ |
| 275 | size = vma->vm_end - vma->vm_start; |
| 276 | size = (size < mem->size) ? size : mem->size; |
| 277 | vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); |
| 278 | retval = remap_pfn_range(vma, vma->vm_start, |
| 279 | mem->phyaddr >> PAGE_SHIFT, |
| 280 | size, vma->vm_page_prot); |
| 281 | if (retval) { |
| 282 | pr_err("mmap: remap failed with error %d. ", retval); |
| 283 | goto error; |
| 284 | } |
| 285 | mem->vaddr = (void *)vma->vm_start; |
| 286 | vma->vm_ops = &videobuf2_vm_ops; |
| 287 | vma->vm_flags |= VM_DONTEXPAND; |
| 288 | vma->vm_private_data = mem; |
| 289 | |
| 290 | D("mmap %p: %08lx-%08lx (%lx) pgoff %08lx\n", |
| 291 | map, vma->vm_start, vma->vm_end, |
| 292 | (long int)mem->bsize, vma->vm_pgoff); |
| 293 | videobuf2_vm_open(vma); |
| 294 | return 0; |
| 295 | error: |
| 296 | return -ENOMEM; |
| 297 | } |
| 298 | |
| 299 | static struct vb2_mem_ops msm_vb2_mem_ops = { |
| 300 | .alloc = msm_vb2_mem_ops_alloc, |
| 301 | .put = msm_vb2_mem_ops_put, |
| 302 | .get_userptr = msm_vb2_mem_ops_get_userptr, |
| 303 | .put_userptr = msm_vb2_mem_ops_put_userptr, |
| 304 | .vaddr = msm_vb2_mem_ops_vaddr, |
| 305 | .cookie = msm_vb2_mem_ops_cookie, |
| 306 | .num_users = msm_vb2_mem_ops_num_users, |
| 307 | .mmap = msm_vb2_mem_ops_mmap |
| 308 | }; |
| 309 | |
| 310 | void videobuf2_queue_pmem_contig_init(struct vb2_queue *q, |
| 311 | enum v4l2_buf_type type, |
| 312 | const struct vb2_ops *ops, |
| 313 | unsigned int size, |
| 314 | void *priv) |
| 315 | { |
| 316 | memset(q, 0, sizeof(struct vb2_queue)); |
| 317 | q->mem_ops = &msm_vb2_mem_ops; |
| 318 | q->ops = ops; |
| 319 | q->drv_priv = priv; |
| 320 | q->type = type; |
| 321 | q->io_modes = VB2_MMAP | VB2_USERPTR; |
| 322 | q->io_flags = 0; |
| 323 | q->buf_struct_size = size; |
| 324 | vb2_queue_init(q); |
| 325 | } |
| 326 | EXPORT_SYMBOL_GPL(videobuf2_queue_pmem_contig_init); |
| 327 | |
Ankit Premrajka | c6864b8 | 2011-07-15 11:43:41 -0700 | [diff] [blame] | 328 | unsigned long videobuf2_to_pmem_contig(struct vb2_buffer *vb, |
| 329 | unsigned int plane_no) |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 330 | { |
| 331 | struct videobuf2_contig_pmem *mem; |
| 332 | mem = vb2_plane_cookie(vb, plane_no); |
| 333 | BUG_ON(!mem); |
| 334 | MAGIC_CHECK(mem->magic, MAGIC_PMEM); |
Kiran Kumar H N | ceea762 | 2011-08-23 14:01:03 -0700 | [diff] [blame] | 335 | return mem->mapped_phyaddr; |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 336 | } |
| 337 | EXPORT_SYMBOL_GPL(videobuf2_to_pmem_contig); |
| 338 | |
| 339 | MODULE_DESCRIPTION("helper module to manage video4linux PMEM contig buffers"); |
| 340 | MODULE_LICENSE("GPL v2"); |