Release 4.7 sound/soc/omap/omap-pcm.c
/*
* omap-pcm.c -- ALSA PCM interface for the OMAP SoC
*
* Copyright (C) 2008 Nokia Corporation
*
* Contact: Jarkko Nikula <jarkko.nikula@bitmer.com>
* Peter Ujfalusi <peter.ujfalusi@ti.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#include <linux/dma-mapping.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/omap-dma.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/dmaengine_pcm.h>
#include <sound/soc.h>
#include <sound/omap-pcm.h>
#ifdef CONFIG_ARCH_OMAP1
#define pcm_omap1510() cpu_is_omap1510()
#else
#define pcm_omap1510() 0
#endif
static struct snd_pcm_hardware omap_pcm_hardware = {
.info = SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_MMAP_VALID |
SNDRV_PCM_INFO_INTERLEAVED |
SNDRV_PCM_INFO_PAUSE |
SNDRV_PCM_INFO_RESUME |
SNDRV_PCM_INFO_NO_PERIOD_WAKEUP,
.period_bytes_min = 32,
.period_bytes_max = 64 * 1024,
.periods_min = 2,
.periods_max = 255,
.buffer_bytes_max = 128 * 1024,
};
/* sDMA supports only 1, 2, and 4 byte transfer elements. */
static void omap_pcm_limit_supported_formats(void)
{
int i;
for (i = 0; i < SNDRV_PCM_FORMAT_LAST; i++) {
switch (snd_pcm_format_physical_width(i)) {
case 8:
case 16:
case 32:
omap_pcm_hardware.formats |= (1LL << i);
break;
default:
break;
}
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jyri sarha | jyri sarha | 57 | 100.00% | 1 | 100.00% |
| Total | 57 | 100.00% | 1 | 100.00% |
/* this may get called several times by oss emulation */
static int omap_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct omap_pcm_dma_data *dma_data;
struct dma_slave_config config;
struct dma_chan *chan;
int err = 0;
memset(&config, 0x00, sizeof(config));
dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
/* return if this is a bufferless transfer e.g.
* codec <--> BT codec or GSM modem -- lg FIXME */
if (!dma_data)
return 0;
snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
runtime->dma_bytes = params_buffer_bytes(params);
chan = snd_dmaengine_pcm_get_chan(substream);
if (!chan)
return -EINVAL;
/* fills in addr_width and direction */
err = snd_hwparams_to_dma_slave_config(substream, params, &config);
if (err)
return err;
snd_dmaengine_pcm_set_config_from_dai_data(substream,
snd_soc_dai_get_dma_data(rtd->cpu_dai, substream),
&config);
return dmaengine_slave_config(chan, &config);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jarkko nikula | jarkko nikula | 96 | 57.49% | 1 | 12.50% |
peter ujfalusi | peter ujfalusi | 32 | 19.16% | 2 | 25.00% |
jim lodes | jim lodes | 13 | 7.78% | 1 | 12.50% |
lars-peter clausen | lars-peter clausen | 12 | 7.19% | 1 | 12.50% |
daniel mack | daniel mack | 11 | 6.59% | 1 | 12.50% |
joonyoung shim | joonyoung shim | 2 | 1.20% | 1 | 12.50% |
arun ks | arun ks | 1 | 0.60% | 1 | 12.50% |
| Total | 167 | 100.00% | 8 | 100.00% |
static int omap_pcm_hw_free(struct snd_pcm_substream *substream)
{
snd_pcm_set_runtime_buffer(substream, NULL);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
peter ujfalusi | peter ujfalusi | 12 | 57.14% | 1 | 25.00% |
eduardo valentin | eduardo valentin | 4 | 19.05% | 1 | 25.00% |
jarkko nikula | jarkko nikula | 4 | 19.05% | 1 | 25.00% |
janusz krzysztofik | janusz krzysztofik | 1 | 4.76% | 1 | 25.00% |
| Total | 21 | 100.00% | 4 | 100.00% |
static snd_pcm_uframes_t omap_pcm_pointer(struct snd_pcm_substream *substream)
{
snd_pcm_uframes_t offset;
if (pcm_omap1510())
offset = snd_dmaengine_pcm_pointer_no_residue(substream);
else
offset = snd_dmaengine_pcm_pointer(substream);
return offset;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jarkko nikula | jarkko nikula | 24 | 64.86% | 1 | 20.00% |
janusz krzysztofik | janusz krzysztofik | 8 | 21.62% | 2 | 40.00% |
peter ujfalusi | peter ujfalusi | 4 | 10.81% | 1 | 20.00% |
tony lindgren | tony lindgren | 1 | 2.70% | 1 | 20.00% |
| Total | 37 | 100.00% | 5 | 100.00% |
static int omap_pcm_open(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_dmaengine_dai_dma_data *dma_data;
int ret;
snd_soc_set_runtime_hwparams(substream, &omap_pcm_hardware);
dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
/* DT boot: filter_data is the DMA name */
if (rtd->cpu_dai->dev->of_node) {
struct dma_chan *chan;
chan = dma_request_slave_channel(rtd->cpu_dai->dev,
dma_data->filter_data);
ret = snd_dmaengine_pcm_open(substream, chan);
} else {
ret = snd_dmaengine_pcm_open_request_chan(substream,
omap_dma_filter_fn,
dma_data->filter_data);
}
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
peter ujfalusi | peter ujfalusi | 74 | 68.52% | 2 | 40.00% |
jarkko nikula | jarkko nikula | 31 | 28.70% | 1 | 20.00% |
lars-peter clausen | lars-peter clausen | 3 | 2.78% | 2 | 40.00% |
| Total | 108 | 100.00% | 5 | 100.00% |
static int omap_pcm_mmap(struct snd_pcm_substream *substream,
struct vm_area_struct *vma)
{
struct snd_pcm_runtime *runtime = substream->runtime;
return dma_mmap_wc(substream->pcm->card->dev, vma, runtime->dma_area,
runtime->dma_addr, runtime->dma_bytes);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jarkko nikula | jarkko nikula | 50 | 98.04% | 1 | 50.00% |
luis r. rodriguez | luis r. rodriguez | 1 | 1.96% | 1 | 50.00% |
| Total | 51 | 100.00% | 2 | 100.00% |
static struct snd_pcm_ops omap_pcm_ops = {
.open = omap_pcm_open,
.close = snd_dmaengine_pcm_close_release_chan,
.ioctl = snd_pcm_lib_ioctl,
.hw_params = omap_pcm_hw_params,
.hw_free = omap_pcm_hw_free,
.trigger = snd_dmaengine_pcm_trigger,
.pointer = omap_pcm_pointer,
.mmap = omap_pcm_mmap,
};
static int omap_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 = omap_pcm_hardware.buffer_bytes_max;
buf->dev.type = SNDRV_DMA_TYPE_DEV;
buf->dev.dev = pcm->card->dev;
buf->private_data = NULL;
buf->area = dma_alloc_wc(pcm->card->dev, size, &buf->addr, GFP_KERNEL);
if (!buf->area)
return -ENOMEM;
buf->bytes = size;
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jarkko nikula | jarkko nikula | 112 | 99.12% | 1 | 50.00% |
luis r. rodriguez | luis r. rodriguez | 1 | 0.88% | 1 | 50.00% |
| Total | 113 | 100.00% | 2 | 100.00% |
static void omap_pcm_free_dma_buffers(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_wc(pcm->card->dev, buf->bytes, buf->area, buf->addr);
buf->area = NULL;
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jarkko nikula | jarkko nikula | 97 | 98.98% | 1 | 50.00% |
luis r. rodriguez | luis r. rodriguez | 1 | 1.02% | 1 | 50.00% |
| Total | 98 | 100.00% | 2 | 100.00% |
static int omap_pcm_new(struct snd_soc_pcm_runtime *rtd)
{
struct snd_card *card = rtd->card->snd_card;
struct snd_pcm *pcm = rtd->pcm;
int ret;
ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
if (ret)
return ret;
if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
ret = omap_pcm_preallocate_dma_buffer(pcm,
SNDRV_PCM_STREAM_PLAYBACK);
if (ret)
goto out;
}
if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
ret = omap_pcm_preallocate_dma_buffer(pcm,
SNDRV_PCM_STREAM_CAPTURE);
if (ret)
goto out;
}
out:
/* free preallocated buffers in case of error */
if (ret)
omap_pcm_free_dma_buffers(pcm);
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jarkko nikula | jarkko nikula | 69 | 53.91% | 1 | 11.11% |
liam girdwood | liam girdwood | 20 | 15.62% | 2 | 22.22% |
joachim eastwood | joachim eastwood | 12 | 9.38% | 1 | 11.11% |
russell king | russell king | 12 | 9.38% | 1 | 11.11% |
oleg matcovschi | oleg matcovschi | 10 | 7.81% | 1 | 11.11% |
yang hongyang | yang hongyang | 3 | 2.34% | 1 | 11.11% |
misael lopez cruz | misael lopez cruz | 1 | 0.78% | 1 | 11.11% |
peter ujfalusi | peter ujfalusi | 1 | 0.78% | 1 | 11.11% |
| Total | 128 | 100.00% | 9 | 100.00% |
static struct snd_soc_platform_driver omap_soc_platform = {
.ops = &omap_pcm_ops,
.pcm_new = omap_pcm_new,
.pcm_free = omap_pcm_free_dma_buffers,
};
int omap_pcm_platform_register(struct device *dev)
{
omap_pcm_limit_supported_formats();
return devm_snd_soc_register_platform(dev, &omap_soc_platform);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
peter ujfalusi | peter ujfalusi | 19 | 86.36% | 1 | 50.00% |
jyri sarha | jyri sarha | 3 | 13.64% | 1 | 50.00% |
| Total | 22 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL_GPL(omap_pcm_platform_register);
MODULE_AUTHOR("Jarkko Nikula <jarkko.nikula@bitmer.com>");
MODULE_DESCRIPTION("OMAP PCM DMA module");
MODULE_LICENSE("GPL");
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jarkko nikula | jarkko nikula | 629 | 63.34% | 2 | 6.06% |
peter ujfalusi | peter ujfalusi | 154 | 15.51% | 6 | 18.18% |
jyri sarha | jyri sarha | 61 | 6.14% | 1 | 3.03% |
liam girdwood | liam girdwood | 23 | 2.32% | 2 | 6.06% |
lars-peter clausen | lars-peter clausen | 20 | 2.01% | 4 | 12.12% |
tony lindgren | tony lindgren | 18 | 1.81% | 1 | 3.03% |
jim lodes | jim lodes | 13 | 1.31% | 1 | 3.03% |
russell king | russell king | 12 | 1.21% | 1 | 3.03% |
joachim eastwood | joachim eastwood | 12 | 1.21% | 1 | 3.03% |
daniel mack | daniel mack | 11 | 1.11% | 1 | 3.03% |
oleg matcovschi | oleg matcovschi | 10 | 1.01% | 1 | 3.03% |
janusz krzysztofik | janusz krzysztofik | 9 | 0.91% | 3 | 9.09% |
eduardo valentin | eduardo valentin | 4 | 0.40% | 1 | 3.03% |
luis r. rodriguez | luis r. rodriguez | 3 | 0.30% | 1 | 3.03% |
paul gortmaker | paul gortmaker | 3 | 0.30% | 1 | 3.03% |
tejun heo | tejun heo | 3 | 0.30% | 1 | 3.03% |
yang hongyang | yang hongyang | 3 | 0.30% | 1 | 3.03% |
joonyoung shim | joonyoung shim | 2 | 0.20% | 1 | 3.03% |
misael lopez cruz | misael lopez cruz | 1 | 0.10% | 1 | 3.03% |
mark brown | mark brown | 1 | 0.10% | 1 | 3.03% |
arun ks | arun ks | 1 | 0.10% | 1 | 3.03% |
| Total | 993 | 100.00% | 33 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.