ASoC: davinci: replace private sram api with genalloc
Removes the DaVinci private SRAM API and replaces it with the genalloc API. The SRAM gen_pool is passed in pdata since DaVinci is in the early stages of DT conversion. [zonque@gmail.com: stub out gen_pool functions for !CONFIG_GENERIC_ALLOCATOR] Signed-off-by: Matt Porter <mporter@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
Родитель
6b7fa01157
Коммит
b8ec56d8ea
|
@ -16,6 +16,8 @@
|
||||||
#ifndef __DAVINCI_ASP_H
|
#ifndef __DAVINCI_ASP_H
|
||||||
#define __DAVINCI_ASP_H
|
#define __DAVINCI_ASP_H
|
||||||
|
|
||||||
|
#include <linux/genalloc.h>
|
||||||
|
|
||||||
struct snd_platform_data {
|
struct snd_platform_data {
|
||||||
u32 tx_dma_offset;
|
u32 tx_dma_offset;
|
||||||
u32 rx_dma_offset;
|
u32 rx_dma_offset;
|
||||||
|
@ -30,6 +32,7 @@ struct snd_platform_data {
|
||||||
unsigned enable_channel_combine:1;
|
unsigned enable_channel_combine:1;
|
||||||
unsigned sram_size_playback;
|
unsigned sram_size_playback;
|
||||||
unsigned sram_size_capture;
|
unsigned sram_size_capture;
|
||||||
|
struct gen_pool *sram_pool;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If McBSP peripheral gets the clock from an external pin,
|
* If McBSP peripheral gets the clock from an external pin,
|
||||||
|
|
|
@ -1167,6 +1167,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
|
||||||
dma_data = &dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK];
|
dma_data = &dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK];
|
||||||
dma_data->asp_chan_q = pdata->asp_chan_q;
|
dma_data->asp_chan_q = pdata->asp_chan_q;
|
||||||
dma_data->ram_chan_q = pdata->ram_chan_q;
|
dma_data->ram_chan_q = pdata->ram_chan_q;
|
||||||
|
dma_data->sram_pool = pdata->sram_pool;
|
||||||
dma_data->sram_size = pdata->sram_size_playback;
|
dma_data->sram_size = pdata->sram_size_playback;
|
||||||
dma_data->dma_addr = (dma_addr_t) (pdata->tx_dma_offset +
|
dma_data->dma_addr = (dma_addr_t) (pdata->tx_dma_offset +
|
||||||
mem->start);
|
mem->start);
|
||||||
|
@ -1184,6 +1185,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
|
||||||
dma_data = &dev->dma_params[SNDRV_PCM_STREAM_CAPTURE];
|
dma_data = &dev->dma_params[SNDRV_PCM_STREAM_CAPTURE];
|
||||||
dma_data->asp_chan_q = pdata->asp_chan_q;
|
dma_data->asp_chan_q = pdata->asp_chan_q;
|
||||||
dma_data->ram_chan_q = pdata->ram_chan_q;
|
dma_data->ram_chan_q = pdata->ram_chan_q;
|
||||||
|
dma_data->sram_pool = pdata->sram_pool;
|
||||||
dma_data->sram_size = pdata->sram_size_capture;
|
dma_data->sram_size = pdata->sram_size_capture;
|
||||||
dma_data->dma_addr = (dma_addr_t)(pdata->rx_dma_offset +
|
dma_data->dma_addr = (dma_addr_t)(pdata->rx_dma_offset +
|
||||||
mem->start);
|
mem->start);
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/dma-mapping.h>
|
#include <linux/dma-mapping.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/genalloc.h>
|
||||||
|
|
||||||
#include <sound/core.h>
|
#include <sound/core.h>
|
||||||
#include <sound/pcm.h>
|
#include <sound/pcm.h>
|
||||||
|
@ -23,7 +24,6 @@
|
||||||
#include <sound/soc.h>
|
#include <sound/soc.h>
|
||||||
|
|
||||||
#include <asm/dma.h>
|
#include <asm/dma.h>
|
||||||
#include <mach/sram.h>
|
|
||||||
|
|
||||||
#include "davinci-pcm.h"
|
#include "davinci-pcm.h"
|
||||||
|
|
||||||
|
@ -251,7 +251,9 @@ static void davinci_pcm_dma_irq(unsigned link, u16 ch_status, void *data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int allocate_sram(struct snd_pcm_substream *substream, unsigned size,
|
#ifdef CONFIG_GENERIC_ALLOCATOR
|
||||||
|
static int allocate_sram(struct snd_pcm_substream *substream,
|
||||||
|
struct gen_pool *sram_pool, unsigned size,
|
||||||
struct snd_pcm_hardware *ppcm)
|
struct snd_pcm_hardware *ppcm)
|
||||||
{
|
{
|
||||||
struct snd_dma_buffer *buf = &substream->dma_buffer;
|
struct snd_dma_buffer *buf = &substream->dma_buffer;
|
||||||
|
@ -263,9 +265,10 @@ static int allocate_sram(struct snd_pcm_substream *substream, unsigned size,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ppcm->period_bytes_max = size;
|
ppcm->period_bytes_max = size;
|
||||||
iram_virt = sram_alloc(size, &iram_phys);
|
iram_virt = (void *)gen_pool_alloc(sram_pool, size);
|
||||||
if (!iram_virt)
|
if (!iram_virt)
|
||||||
goto exit1;
|
goto exit1;
|
||||||
|
iram_phys = gen_pool_virt_to_phys(sram_pool, (unsigned)iram_virt);
|
||||||
iram_dma = kzalloc(sizeof(*iram_dma), GFP_KERNEL);
|
iram_dma = kzalloc(sizeof(*iram_dma), GFP_KERNEL);
|
||||||
if (!iram_dma)
|
if (!iram_dma)
|
||||||
goto exit2;
|
goto exit2;
|
||||||
|
@ -277,11 +280,33 @@ static int allocate_sram(struct snd_pcm_substream *substream, unsigned size,
|
||||||
return 0;
|
return 0;
|
||||||
exit2:
|
exit2:
|
||||||
if (iram_virt)
|
if (iram_virt)
|
||||||
sram_free(iram_virt, size);
|
gen_pool_free(sram_pool, (unsigned)iram_virt, size);
|
||||||
exit1:
|
exit1:
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void davinci_free_sram(struct snd_pcm_substream *substream,
|
||||||
|
struct snd_dma_buffer *iram_dma)
|
||||||
|
{
|
||||||
|
struct davinci_runtime_data *prtd = substream->runtime->private_data;
|
||||||
|
struct gen_pool *sram_pool = prtd->params->sram_pool;
|
||||||
|
|
||||||
|
gen_pool_free(sram_pool, (unsigned) iram_dma->area, iram_dma->bytes);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static int allocate_sram(struct snd_pcm_substream *substream,
|
||||||
|
struct gen_pool *sram_pool, unsigned size,
|
||||||
|
struct snd_pcm_hardware *ppcm)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void davinci_free_sram(struct snd_pcm_substream *substream,
|
||||||
|
struct snd_dma_buffer *iram_dma)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Only used with ping/pong.
|
* Only used with ping/pong.
|
||||||
* This is called after runtime->dma_addr, period_bytes and data_type are valid
|
* This is called after runtime->dma_addr, period_bytes and data_type are valid
|
||||||
|
@ -668,7 +693,7 @@ static int davinci_pcm_open(struct snd_pcm_substream *substream)
|
||||||
|
|
||||||
ppcm = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
|
ppcm = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
|
||||||
&pcm_hardware_playback : &pcm_hardware_capture;
|
&pcm_hardware_playback : &pcm_hardware_capture;
|
||||||
allocate_sram(substream, params->sram_size, ppcm);
|
allocate_sram(substream, params->sram_pool, params->sram_size, ppcm);
|
||||||
snd_soc_set_runtime_hwparams(substream, ppcm);
|
snd_soc_set_runtime_hwparams(substream, ppcm);
|
||||||
/* ensure that buffer size is a multiple of period size */
|
/* ensure that buffer size is a multiple of period size */
|
||||||
ret = snd_pcm_hw_constraint_integer(runtime,
|
ret = snd_pcm_hw_constraint_integer(runtime,
|
||||||
|
@ -811,7 +836,7 @@ static void davinci_pcm_free(struct snd_pcm *pcm)
|
||||||
buf->area = NULL;
|
buf->area = NULL;
|
||||||
iram_dma = buf->private_data;
|
iram_dma = buf->private_data;
|
||||||
if (iram_dma) {
|
if (iram_dma) {
|
||||||
sram_free(iram_dma->area, iram_dma->bytes);
|
davinci_free_sram(substream, iram_dma);
|
||||||
kfree(iram_dma);
|
kfree(iram_dma);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#ifndef _DAVINCI_PCM_H
|
#ifndef _DAVINCI_PCM_H
|
||||||
#define _DAVINCI_PCM_H
|
#define _DAVINCI_PCM_H
|
||||||
|
|
||||||
|
#include <linux/genalloc.h>
|
||||||
#include <linux/platform_data/davinci_asp.h>
|
#include <linux/platform_data/davinci_asp.h>
|
||||||
#include <mach/edma.h>
|
#include <mach/edma.h>
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ struct davinci_pcm_dma_params {
|
||||||
unsigned short acnt;
|
unsigned short acnt;
|
||||||
dma_addr_t dma_addr; /* device physical address for DMA */
|
dma_addr_t dma_addr; /* device physical address for DMA */
|
||||||
unsigned sram_size;
|
unsigned sram_size;
|
||||||
|
struct gen_pool *sram_pool; /* SRAM gen_pool for ping pong */
|
||||||
enum dma_event_q asp_chan_q; /* event queue number for ASP channel */
|
enum dma_event_q asp_chan_q; /* event queue number for ASP channel */
|
||||||
enum dma_event_q ram_chan_q; /* event queue number for RAM channel */
|
enum dma_event_q ram_chan_q; /* event queue number for RAM channel */
|
||||||
unsigned char data_type; /* xfer data type */
|
unsigned char data_type; /* xfer data type */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче