1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Vmalloc'ed Buffers</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Writing an ALSA Driver"><link rel="up" href="buffer-and-memory.html" title="Chapter 11. Buffer and Memory Management"><link rel="prev" href="buffer-and-memory-non-contiguous.html" title="Non-Contiguous Buffers"><link rel="next" href="proc-interface.html" title="Chapter 12. Proc Interface"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Vmalloc'ed Buffers</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="buffer-and-memory-non-contiguous.html">Prev</a> </td><th width="60%" align="center">Chapter 11. Buffer and Memory Management</th><td width="20%" align="right"> <a accesskey="n" href="proc-interface.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="buffer-and-memory-vmalloced"></a>Vmalloc'ed Buffers</h2></div></div></div><p> 2 It's possible to use a buffer allocated via 3 <code class="function">vmalloc</code>, for example, for an intermediate 4 buffer. Since the allocated pages are not contiguous, you need 5 to set the <em class="structfield"><code>page</code></em> callback to obtain 6 the physical address at every offset. 7 </p><p> 8 The implementation of <em class="structfield"><code>page</code></em> callback 9 would be like this: 10 11 </p><div class="informalexample"><pre class="programlisting"> 12 13 #include <linux/vmalloc.h> 14 15 /* get the physical page pointer on the given offset */ 16 static struct page *mychip_page(struct snd_pcm_substream *substream, 17 unsigned long offset) 18 { 19 void *pageptr = substream->runtime->dma_area + offset; 20 return vmalloc_to_page(pageptr); 21 } 22 23 </pre></div><p> 24 </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="buffer-and-memory-non-contiguous.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="buffer-and-memory.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="proc-interface.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Non-Contiguous Buffers </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 12. Proc Interface</td></tr></table></div></body></html> 25