-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Shawn Guo
authored and
Mark Brown
committed
Mar 6, 2012
1 parent
35d5d1d
commit 4a8a36f
Showing
8 changed files
with
151 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: af4872fb39301bbe196d0778f80d22ec51d8884b | ||
refs/heads/master: 4762fbab0b1cf1d4f3e02b78351dc6fa59ca564e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Copyright 2009 Sascha Hauer <s.hauer@pengutronix.de> | ||
* | ||
* This code is based on code copyrighted by Freescale, | ||
* Liam Girdwood, Javier Martin and probably others. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. | ||
*/ | ||
|
||
#include <linux/dma-mapping.h> | ||
#include <linux/module.h> | ||
#include <sound/pcm.h> | ||
#include <sound/soc.h> | ||
#include "imx-pcm.h" | ||
|
||
int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, | ||
struct vm_area_struct *vma) | ||
{ | ||
struct snd_pcm_runtime *runtime = substream->runtime; | ||
int ret; | ||
|
||
ret = dma_mmap_writecombine(substream->pcm->card->dev, vma, | ||
runtime->dma_area, runtime->dma_addr, runtime->dma_bytes); | ||
|
||
pr_debug("%s: ret: %d %p 0x%08x 0x%08x\n", __func__, ret, | ||
runtime->dma_area, | ||
runtime->dma_addr, | ||
runtime->dma_bytes); | ||
return ret; | ||
} | ||
EXPORT_SYMBOL_GPL(snd_imx_pcm_mmap); | ||
|
||
static int imx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) | ||
{ | ||
struct snd_pcm_substream *substream = pcm->streams[stream].substream; | ||
struct snd_dma_buffer *buf = &substream->dma_buffer; | ||
size_t size = IMX_SSI_DMABUF_SIZE; | ||
|
||
buf->dev.type = SNDRV_DMA_TYPE_DEV; | ||
buf->dev.dev = pcm->card->dev; | ||
buf->private_data = NULL; | ||
buf->area = dma_alloc_writecombine(pcm->card->dev, size, | ||
&buf->addr, GFP_KERNEL); | ||
if (!buf->area) | ||
return -ENOMEM; | ||
buf->bytes = size; | ||
|
||
return 0; | ||
} | ||
|
||
static u64 imx_pcm_dmamask = DMA_BIT_MASK(32); | ||
|
||
int imx_pcm_new(struct snd_soc_pcm_runtime *rtd) | ||
{ | ||
struct snd_card *card = rtd->card->snd_card; | ||
struct snd_pcm *pcm = rtd->pcm; | ||
int ret = 0; | ||
|
||
if (!card->dev->dma_mask) | ||
card->dev->dma_mask = &imx_pcm_dmamask; | ||
if (!card->dev->coherent_dma_mask) | ||
card->dev->coherent_dma_mask = DMA_BIT_MASK(32); | ||
if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { | ||
ret = imx_pcm_preallocate_dma_buffer(pcm, | ||
SNDRV_PCM_STREAM_PLAYBACK); | ||
if (ret) | ||
goto out; | ||
} | ||
|
||
if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { | ||
ret = imx_pcm_preallocate_dma_buffer(pcm, | ||
SNDRV_PCM_STREAM_CAPTURE); | ||
if (ret) | ||
goto out; | ||
} | ||
|
||
out: | ||
return ret; | ||
} | ||
EXPORT_SYMBOL_GPL(imx_pcm_new); | ||
|
||
void imx_pcm_free(struct snd_pcm *pcm) | ||
{ | ||
struct snd_pcm_substream *substream; | ||
struct snd_dma_buffer *buf; | ||
int stream; | ||
|
||
for (stream = 0; stream < 2; stream++) { | ||
substream = pcm->streams[stream].substream; | ||
if (!substream) | ||
continue; | ||
|
||
buf = &substream->dma_buffer; | ||
if (!buf->area) | ||
continue; | ||
|
||
dma_free_writecombine(pcm->card->dev, buf->bytes, | ||
buf->area, buf->addr); | ||
buf->area = NULL; | ||
} | ||
} | ||
EXPORT_SYMBOL_GPL(imx_pcm_free); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2009 Sascha Hauer <s.hauer@pengutronix.de> | ||
* | ||
* This code is based on code copyrighted by Freescale, | ||
* Liam Girdwood, Javier Martin and probably others. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. | ||
*/ | ||
|
||
#ifndef _IMX_PCM_H | ||
#define _IMX_PCM_H | ||
|
||
/* | ||
* Do not change this as the FIQ handler depends on this size | ||
*/ | ||
#define IMX_SSI_DMABUF_SIZE (64 * 1024) | ||
|
||
struct imx_pcm_dma_params { | ||
int dma; | ||
unsigned long dma_addr; | ||
int burstsize; | ||
}; | ||
|
||
int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, | ||
struct vm_area_struct *vma); | ||
int imx_pcm_new(struct snd_soc_pcm_runtime *rtd); | ||
void imx_pcm_free(struct snd_pcm *pcm); | ||
|
||
#endif /* _IMX_PCM_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters