Source
x
static inline struct soundscape *get_card_soundscape(struct snd_card *c)
{
return (struct soundscape *) (c->private_data);
}
/*
* Allocates some kernel memory that we can use for DMA.
* I think this means that the memory has to map to
* contiguous pages of physical memory.
*/
static struct snd_dma_buffer *get_dmabuf(struct snd_dma_buffer *buf,
static struct snd_dma_buffer *get_dmabuf(struct soundscape *s,
struct snd_dma_buffer *buf,
unsigned long size)
{
if (buf) {
if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV,
snd_dma_isa_data(),
s->chip->card->dev,
size, buf) < 0) {
snd_printk(KERN_ERR "sscape: Failed to allocate "
"%lu bytes for DMA\n",
size);
return NULL;
}
}
return buf;
}
* Upload a byte-stream into the SoundScape using DMA channel A.
*/
static int upload_dma_data(struct soundscape *s, const unsigned char *data,
size_t size)
{
unsigned long flags;
struct snd_dma_buffer dma;
int ret;
unsigned char val;
if (!get_dmabuf(&dma, PAGE_ALIGN(32 * 1024)))
if (!get_dmabuf(s, &dma, PAGE_ALIGN(32 * 1024)))
return -ENOMEM;
spin_lock_irqsave(&s->lock, flags);
/*
* Reset the board ...
*/
val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG);
sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val & 0x3f);