Ankit Premrajka | d814743 | 2012-01-06 09:45:11 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011-2012, Code Aurora Forum. 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> |
| 27 | #include <linux/android_pmem.h> |
| 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, |
| 67 | (unsigned long *)&len, UNCACHED, 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 | { |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 180 | unsigned long len; |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 181 | int rc = 0; |
| 182 | #ifndef CONFIG_MSM_MULTIMEDIA_USE_ION |
| 183 | unsigned long kvstart; |
| 184 | #endif |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 185 | unsigned long paddr = 0; |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 186 | if (mem->phyaddr != 0) |
| 187 | return 0; |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 188 | #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION |
Laura Abbott | b14ed96 | 2012-01-30 14:18:08 -0800 | [diff] [blame] | 189 | mem->ion_handle = ion_import_dma_buf(client, (int)mem->vaddr); |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 190 | if (IS_ERR_OR_NULL(mem->ion_handle)) { |
| 191 | pr_err("%s ION import failed\n", __func__); |
| 192 | return PTR_ERR(mem->ion_handle); |
| 193 | } |
Ankit Premrajka | 79b9f22 | 2012-07-02 12:38:34 -0700 | [diff] [blame] | 194 | rc = ion_map_iommu(client, mem->ion_handle, domain_num, 0, |
Ankit Premrajka | 4594296 | 2012-02-15 19:21:25 -0800 | [diff] [blame] | 195 | SZ_4K, 0, (unsigned long *)&mem->phyaddr, &len, UNCACHED, 0); |
| 196 | if (rc < 0) |
| 197 | ion_free(client, mem->ion_handle); |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 198 | #elif CONFIG_ANDROID_PMEM |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 199 | rc = get_pmem_file((int)mem->vaddr, (unsigned long *)&mem->phyaddr, |
| 200 | &kvstart, &len, &mem->file); |
| 201 | if (rc < 0) { |
| 202 | pr_err("%s: get_pmem_file fd %d error %d\n", |
| 203 | __func__, (int)mem->vaddr, rc); |
| 204 | return rc; |
| 205 | } |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 206 | #else |
| 207 | paddr = 0; |
| 208 | kvstart = 0; |
| 209 | #endif |
Kiran Kumar H N | 5e08d77 | 2011-10-03 10:19:15 -0700 | [diff] [blame] | 210 | if (offset) |
| 211 | mem->offset = *offset; |
| 212 | else |
| 213 | memset(&mem->offset, 0, sizeof(struct videobuf2_msm_offset)); |
| 214 | mem->path = path; |
| 215 | mem->buffer_type = buffer_type; |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 216 | paddr = mem->phyaddr; |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 217 | mem->mapped_phyaddr = paddr + addr_offset; |
Kevin Chan | 318d7cb | 2011-11-29 14:24:26 -0800 | [diff] [blame] | 218 | mem->addr_offset = addr_offset; |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 219 | return rc; |
| 220 | } |
| 221 | EXPORT_SYMBOL_GPL(videobuf2_pmem_contig_user_get); |
| 222 | |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 223 | void videobuf2_pmem_contig_user_put(struct videobuf2_contig_pmem *mem, |
Ankit Premrajka | 79b9f22 | 2012-07-02 12:38:34 -0700 | [diff] [blame] | 224 | struct ion_client *client, int domain_num) |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 225 | { |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 226 | if (mem->is_userptr) { |
| 227 | #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION |
Ankit Premrajka | 4594296 | 2012-02-15 19:21:25 -0800 | [diff] [blame] | 228 | ion_unmap_iommu(client, mem->ion_handle, |
Ankit Premrajka | 79b9f22 | 2012-07-02 12:38:34 -0700 | [diff] [blame] | 229 | domain_num, 0); |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 230 | ion_free(client, mem->ion_handle); |
| 231 | #elif CONFIG_ANDROID_PMEM |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 232 | put_pmem_file(mem->file); |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 233 | #endif |
| 234 | } |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 235 | mem->is_userptr = 0; |
| 236 | mem->phyaddr = 0; |
| 237 | mem->size = 0; |
Kiran Kumar H N | ceea762 | 2011-08-23 14:01:03 -0700 | [diff] [blame] | 238 | mem->mapped_phyaddr = 0; |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 239 | } |
| 240 | EXPORT_SYMBOL_GPL(videobuf2_pmem_contig_user_put); |
| 241 | |
| 242 | static void *msm_vb2_mem_ops_get_userptr(void *alloc_ctx, unsigned long vaddr, |
| 243 | unsigned long size, int write) |
| 244 | { |
| 245 | struct videobuf2_contig_pmem *mem; |
| 246 | mem = kzalloc(sizeof(*mem), GFP_KERNEL); |
| 247 | if (!mem) |
| 248 | return ERR_PTR(-ENOMEM); |
| 249 | mem->magic = MAGIC_PMEM; |
| 250 | mem->is_userptr = 1; |
| 251 | mem->vaddr = (void *)vaddr; |
| 252 | mem->size = size; |
| 253 | mem->alloc_ctx = alloc_ctx; |
| 254 | return mem; |
| 255 | } |
| 256 | static void msm_vb2_mem_ops_put_userptr(void *buf_priv) |
| 257 | { |
| 258 | kfree(buf_priv); |
| 259 | } |
| 260 | |
| 261 | static void *msm_vb2_mem_ops_vaddr(void *buf_priv) |
| 262 | { |
| 263 | struct videobuf2_contig_pmem *mem = buf_priv; |
| 264 | return mem->vaddr; |
| 265 | } |
| 266 | static void *msm_vb2_mem_ops_cookie(void *buf_priv) |
| 267 | { |
| 268 | return buf_priv; |
| 269 | } |
| 270 | static unsigned int msm_vb2_mem_ops_num_users(void *buf_priv) |
| 271 | { |
| 272 | struct videobuf2_contig_pmem *mem = buf_priv; |
| 273 | MAGIC_CHECK(mem->magic, MAGIC_PMEM); |
| 274 | return mem->count; |
| 275 | } |
| 276 | static int msm_vb2_mem_ops_mmap(void *buf_priv, struct vm_area_struct *vma) |
| 277 | { |
| 278 | struct videobuf2_contig_pmem *mem; |
| 279 | int retval; |
| 280 | unsigned long size; |
| 281 | D("%s\n", __func__); |
| 282 | mem = buf_priv; |
| 283 | D("mem = 0x%x\n", (u32)mem); |
| 284 | BUG_ON(!mem); |
| 285 | MAGIC_CHECK(mem->magic, MAGIC_PMEM); |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 286 | /* Try to remap memory */ |
| 287 | size = vma->vm_end - vma->vm_start; |
| 288 | size = (size < mem->size) ? size : mem->size; |
| 289 | vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); |
| 290 | retval = remap_pfn_range(vma, vma->vm_start, |
| 291 | mem->phyaddr >> PAGE_SHIFT, |
| 292 | size, vma->vm_page_prot); |
| 293 | if (retval) { |
| 294 | pr_err("mmap: remap failed with error %d. ", retval); |
| 295 | goto error; |
| 296 | } |
| 297 | mem->vaddr = (void *)vma->vm_start; |
| 298 | vma->vm_ops = &videobuf2_vm_ops; |
| 299 | vma->vm_flags |= VM_DONTEXPAND; |
| 300 | vma->vm_private_data = mem; |
| 301 | |
| 302 | D("mmap %p: %08lx-%08lx (%lx) pgoff %08lx\n", |
| 303 | map, vma->vm_start, vma->vm_end, |
| 304 | (long int)mem->bsize, vma->vm_pgoff); |
| 305 | videobuf2_vm_open(vma); |
| 306 | return 0; |
| 307 | error: |
| 308 | return -ENOMEM; |
| 309 | } |
| 310 | |
| 311 | static struct vb2_mem_ops msm_vb2_mem_ops = { |
| 312 | .alloc = msm_vb2_mem_ops_alloc, |
| 313 | .put = msm_vb2_mem_ops_put, |
| 314 | .get_userptr = msm_vb2_mem_ops_get_userptr, |
| 315 | .put_userptr = msm_vb2_mem_ops_put_userptr, |
| 316 | .vaddr = msm_vb2_mem_ops_vaddr, |
| 317 | .cookie = msm_vb2_mem_ops_cookie, |
| 318 | .num_users = msm_vb2_mem_ops_num_users, |
| 319 | .mmap = msm_vb2_mem_ops_mmap |
| 320 | }; |
| 321 | |
| 322 | void videobuf2_queue_pmem_contig_init(struct vb2_queue *q, |
| 323 | enum v4l2_buf_type type, |
| 324 | const struct vb2_ops *ops, |
| 325 | unsigned int size, |
| 326 | void *priv) |
| 327 | { |
| 328 | memset(q, 0, sizeof(struct vb2_queue)); |
| 329 | q->mem_ops = &msm_vb2_mem_ops; |
| 330 | q->ops = ops; |
| 331 | q->drv_priv = priv; |
| 332 | q->type = type; |
| 333 | q->io_modes = VB2_MMAP | VB2_USERPTR; |
| 334 | q->io_flags = 0; |
| 335 | q->buf_struct_size = size; |
| 336 | vb2_queue_init(q); |
| 337 | } |
| 338 | EXPORT_SYMBOL_GPL(videobuf2_queue_pmem_contig_init); |
| 339 | |
Ankit Premrajka | c6864b8 | 2011-07-15 11:43:41 -0700 | [diff] [blame] | 340 | unsigned long videobuf2_to_pmem_contig(struct vb2_buffer *vb, |
| 341 | unsigned int plane_no) |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 342 | { |
| 343 | struct videobuf2_contig_pmem *mem; |
| 344 | mem = vb2_plane_cookie(vb, plane_no); |
| 345 | BUG_ON(!mem); |
| 346 | MAGIC_CHECK(mem->magic, MAGIC_PMEM); |
Kiran Kumar H N | ceea762 | 2011-08-23 14:01:03 -0700 | [diff] [blame] | 347 | return mem->mapped_phyaddr; |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 348 | } |
| 349 | EXPORT_SYMBOL_GPL(videobuf2_to_pmem_contig); |
| 350 | |
| 351 | MODULE_DESCRIPTION("helper module to manage video4linux PMEM contig buffers"); |
| 352 | MODULE_LICENSE("GPL v2"); |