Lines Matching refs:mem

38 			       struct videobuf_dma_contig_memory *mem,  in __videobuf_dc_alloc()  argument
41 mem->size = size; in __videobuf_dc_alloc()
42 mem->vaddr = dma_alloc_coherent(dev, mem->size, &mem->dma_handle, in __videobuf_dc_alloc()
44 if (!mem->vaddr) { in __videobuf_dc_alloc()
45 dev_err(dev, "memory alloc size %ld failed\n", mem->size); in __videobuf_dc_alloc()
49 dev_dbg(dev, "dma mapped data is at %p (%ld)\n", mem->vaddr, mem->size); in __videobuf_dc_alloc()
55 struct videobuf_dma_contig_memory *mem) in __videobuf_dc_free() argument
57 dma_free_coherent(dev, mem->size, mem->vaddr, mem->dma_handle); in __videobuf_dc_free()
59 mem->vaddr = NULL; in __videobuf_dc_free()
83 struct videobuf_dma_contig_memory *mem; in videobuf_vm_close() local
99 mem = q->bufs[i]->priv; in videobuf_vm_close()
100 if (mem) { in videobuf_vm_close()
107 MAGIC_CHECK(mem->magic, MAGIC_DC_MEM); in videobuf_vm_close()
113 i, mem->vaddr); in videobuf_vm_close()
115 __videobuf_dc_free(q->dev, mem); in videobuf_vm_close()
116 mem->vaddr = NULL; in videobuf_vm_close()
140 static void videobuf_dma_contig_user_put(struct videobuf_dma_contig_memory *mem) in videobuf_dma_contig_user_put() argument
142 mem->dma_handle = 0; in videobuf_dma_contig_user_put()
143 mem->size = 0; in videobuf_dma_contig_user_put()
156 static int videobuf_dma_contig_user_get(struct videobuf_dma_contig_memory *mem, in videobuf_dma_contig_user_get() argument
168 mem->size = PAGE_ALIGN(vb->size + offset); in videobuf_dma_contig_user_get()
177 if ((untagged_baddr + mem->size) > vma->vm_end) in videobuf_dma_contig_user_get()
184 while (pages_done < (mem->size >> PAGE_SHIFT)) { in videobuf_dma_contig_user_get()
190 mem->dma_handle = (this_pfn << PAGE_SHIFT) + offset; in videobuf_dma_contig_user_get()
210 struct videobuf_dma_contig_memory *mem; in __videobuf_alloc() local
213 vb = kzalloc(size + sizeof(*mem), GFP_KERNEL); in __videobuf_alloc()
216 mem = vb->priv; in __videobuf_alloc()
217 mem->magic = MAGIC_DC_MEM; in __videobuf_alloc()
225 struct videobuf_dma_contig_memory *mem = buf->priv; in __videobuf_to_vaddr() local
227 BUG_ON(!mem); in __videobuf_to_vaddr()
228 MAGIC_CHECK(mem->magic, MAGIC_DC_MEM); in __videobuf_to_vaddr()
230 return mem->vaddr; in __videobuf_to_vaddr()
237 struct videobuf_dma_contig_memory *mem = vb->priv; in __videobuf_iolock() local
239 BUG_ON(!mem); in __videobuf_iolock()
240 MAGIC_CHECK(mem->magic, MAGIC_DC_MEM); in __videobuf_iolock()
247 if (!mem->vaddr) { in __videobuf_iolock()
257 return videobuf_dma_contig_user_get(mem, vb); in __videobuf_iolock()
260 if (__videobuf_dc_alloc(q->dev, mem, PAGE_ALIGN(vb->size))) in __videobuf_iolock()
276 struct videobuf_dma_contig_memory *mem; in __videobuf_mmap_mapper() local
292 mem = buf->priv; in __videobuf_mmap_mapper()
293 BUG_ON(!mem); in __videobuf_mmap_mapper()
294 MAGIC_CHECK(mem->magic, MAGIC_DC_MEM); in __videobuf_mmap_mapper()
296 if (__videobuf_dc_alloc(q->dev, mem, PAGE_ALIGN(buf->bsize))) in __videobuf_mmap_mapper()
306 retval = dma_mmap_coherent(q->dev, vma, mem->vaddr, mem->dma_handle, in __videobuf_mmap_mapper()
307 mem->size); in __videobuf_mmap_mapper()
311 dma_free_coherent(q->dev, mem->size, in __videobuf_mmap_mapper()
312 mem->vaddr, mem->dma_handle); in __videobuf_mmap_mapper()
358 struct videobuf_dma_contig_memory *mem = buf->priv; in videobuf_to_dma_contig() local
360 BUG_ON(!mem); in videobuf_to_dma_contig()
361 MAGIC_CHECK(mem->magic, MAGIC_DC_MEM); in videobuf_to_dma_contig()
363 return mem->dma_handle; in videobuf_to_dma_contig()
370 struct videobuf_dma_contig_memory *mem = buf->priv; in videobuf_dma_contig_free() local
381 if (!mem) in videobuf_dma_contig_free()
384 MAGIC_CHECK(mem->magic, MAGIC_DC_MEM); in videobuf_dma_contig_free()
388 videobuf_dma_contig_user_put(mem); in videobuf_dma_contig_free()
393 if (mem->vaddr) { in videobuf_dma_contig_free()
394 __videobuf_dc_free(q->dev, mem); in videobuf_dma_contig_free()
395 mem->vaddr = NULL; in videobuf_dma_contig_free()