title: How to allocate DMA channel in user space?
body: <p>I am the maintainer of an <a href="https://github.com/sarfata/pi-blaster" rel="nofollow">open source project that relies on the DMA controller to do PWM on Raspberry Pi IO pins</a>. This technique requires the use of one DMA channel. We have historically hard-coded the DMA channel 0 but got multiple bug reports stating that the program does not work properly when X is running at the same time (bug reports: <a href="https://github.com/sarfata/pi-blaster/issues/16" rel="nofollow">here</a> and <a href="https://github.com/sarfata/pi-blaster/issues/27" rel="nofollow">here</a>, <a href="https://github.com/sarfata/pi-blaster/issues" rel="nofollow">etc</a>).</p>
  
  <p>We have found the <a href="https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface" rel="nofollow">Mailbox API</a> in the Raspberry PI firmware which includes an API to manage shared resources such as DMA channels and figure out which ones are available.</p>
  
  <p>Pattrick Hueper <a href="https://github.com/sarfata/pi-blaster/pull/38#discussion_r28041695" rel="nofollow">gave this a try</a> but it still reports channel 0 as available. Maybe X does not use this API to announce which channel it is using.</p>
  
  <p>I found <code>dma_request_channel()</code> for kernel space programs but that is not available in user space.</p>
  
  <p>What is the proper way to use a DMA channel from user space while being a good citizen on the computer and avoid conflict with other tools?</p>