ASoC: blackfin: Convert to the new PCM ops
Replace the copy and the silence ops with the new PCM ops. In AC97 and I2S-TDM mode, we need to convert back to frames, but otherwise the conversion is pretty straightforward. Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Acked-by: Mark Brown <broonie@kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
1cc2f8ba0b
commit
aa708c613b
2 changed files with 43 additions and 20 deletions
|
@ -279,23 +279,33 @@ static int bf5xx_pcm_mmap(struct snd_pcm_substream *substream,
|
||||||
return 0 ;
|
return 0 ;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static int bf5xx_pcm_copy(struct snd_pcm_substream *substream, int channel,
|
static int bf5xx_pcm_copy(struct snd_pcm_substream *substream,
|
||||||
snd_pcm_uframes_t pos,
|
int channel, unsigned long pos,
|
||||||
void __user *buf, snd_pcm_uframes_t count)
|
void *buf, unsigned long count)
|
||||||
{
|
{
|
||||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||||
unsigned int chan_mask = ac97_chan_mask[runtime->channels - 1];
|
unsigned int chan_mask = ac97_chan_mask[runtime->channels - 1];
|
||||||
|
struct ac97_frame *dst;
|
||||||
|
|
||||||
pr_debug("%s copy pos:0x%lx count:0x%lx\n",
|
pr_debug("%s copy pos:0x%lx count:0x%lx\n",
|
||||||
substream->stream ? "Capture" : "Playback", pos, count);
|
substream->stream ? "Capture" : "Playback", pos, count);
|
||||||
|
dst = (struct ac97_frame *)runtime->dma_area +
|
||||||
|
bytes_to_frames(runtime, pos);
|
||||||
|
count = bytes_to_frames(runtime, count);
|
||||||
|
|
||||||
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
||||||
bf5xx_pcm_to_ac97((struct ac97_frame *)runtime->dma_area + pos,
|
bf5xx_pcm_to_ac97(dst, buf, count, chan_mask);
|
||||||
(__u16 *)buf, count, chan_mask);
|
|
||||||
else
|
else
|
||||||
bf5xx_ac97_to_pcm((struct ac97_frame *)runtime->dma_area + pos,
|
bf5xx_ac97_to_pcm(dst, buf, count);
|
||||||
(__u16 *)buf, count);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int bf5xx_pcm_copy_user(struct snd_pcm_substream *substream,
|
||||||
|
int channel, unsigned long pos,
|
||||||
|
void __user *buf, unsigned long count)
|
||||||
|
{
|
||||||
|
return bf5xx_pcm_copy(substream, channel, pos, (void *)buf, count);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct snd_pcm_ops bf5xx_pcm_ac97_ops = {
|
static struct snd_pcm_ops bf5xx_pcm_ac97_ops = {
|
||||||
|
@ -309,7 +319,8 @@ static struct snd_pcm_ops bf5xx_pcm_ac97_ops = {
|
||||||
#if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT)
|
#if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT)
|
||||||
.mmap = bf5xx_pcm_mmap,
|
.mmap = bf5xx_pcm_mmap,
|
||||||
#else
|
#else
|
||||||
.copy = bf5xx_pcm_copy,
|
.copy_user = bf5xx_pcm_copy_user,
|
||||||
|
.copy_kernel = bf5xx_pcm_copy,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -225,8 +225,9 @@ static int bf5xx_pcm_mmap(struct snd_pcm_substream *substream,
|
||||||
return 0 ;
|
return 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bf5xx_pcm_copy(struct snd_pcm_substream *substream, int channel,
|
static int bf5xx_pcm_copy(struct snd_pcm_substream *substream,
|
||||||
snd_pcm_uframes_t pos, void *buf, snd_pcm_uframes_t count)
|
int channel, unsigned long pos,
|
||||||
|
void *buf, unsigned long count)
|
||||||
{
|
{
|
||||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||||
|
@ -238,6 +239,8 @@ static int bf5xx_pcm_copy(struct snd_pcm_substream *substream, int channel,
|
||||||
dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
|
dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
|
||||||
|
|
||||||
if (dma_data->tdm_mode) {
|
if (dma_data->tdm_mode) {
|
||||||
|
pos = bytes_to_frames(runtime, pos);
|
||||||
|
count = bytes_to_frames(runtime, count);
|
||||||
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
||||||
src = buf;
|
src = buf;
|
||||||
dst = runtime->dma_area;
|
dst = runtime->dma_area;
|
||||||
|
@ -269,21 +272,29 @@ static int bf5xx_pcm_copy(struct snd_pcm_substream *substream, int channel,
|
||||||
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
||||||
src = buf;
|
src = buf;
|
||||||
dst = runtime->dma_area;
|
dst = runtime->dma_area;
|
||||||
dst += frames_to_bytes(runtime, pos);
|
dst += pos;
|
||||||
} else {
|
} else {
|
||||||
src = runtime->dma_area;
|
src = runtime->dma_area;
|
||||||
src += frames_to_bytes(runtime, pos);
|
src += pos;
|
||||||
dst = buf;
|
dst = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(dst, src, frames_to_bytes(runtime, count));
|
memcpy(dst, src, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int bf5xx_pcm_copy_user(struct snd_pcm_substream *substream,
|
||||||
|
int channel, unsigned long pos,
|
||||||
|
void __user *buf, unsigned long count)
|
||||||
|
{
|
||||||
|
return bf5xx_pcm_copy(substream, channel, pos, (void *)buf, count);
|
||||||
|
}
|
||||||
|
|
||||||
static int bf5xx_pcm_silence(struct snd_pcm_substream *substream,
|
static int bf5xx_pcm_silence(struct snd_pcm_substream *substream,
|
||||||
int channel, snd_pcm_uframes_t pos, snd_pcm_uframes_t count)
|
int channel, unsigned long pos,
|
||||||
|
unsigned long count)
|
||||||
{
|
{
|
||||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||||
|
@ -295,11 +306,11 @@ static int bf5xx_pcm_silence(struct snd_pcm_substream *substream,
|
||||||
dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
|
dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
|
||||||
|
|
||||||
if (dma_data->tdm_mode) {
|
if (dma_data->tdm_mode) {
|
||||||
offset = pos * 8 * sample_size;
|
offset = bytes_to_frames(runtime, pos) * 8 * sample_size;
|
||||||
samples = count * 8;
|
samples = bytes_to_frames(runtime, count) * 8;
|
||||||
} else {
|
} else {
|
||||||
offset = frames_to_bytes(runtime, pos);
|
offset = pos;
|
||||||
samples = count * runtime->channels;
|
samples = bytes_to_samples(runtime, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
snd_pcm_format_set_silence(runtime->format, buf + offset, samples);
|
snd_pcm_format_set_silence(runtime->format, buf + offset, samples);
|
||||||
|
@ -316,8 +327,9 @@ static struct snd_pcm_ops bf5xx_pcm_i2s_ops = {
|
||||||
.trigger = bf5xx_pcm_trigger,
|
.trigger = bf5xx_pcm_trigger,
|
||||||
.pointer = bf5xx_pcm_pointer,
|
.pointer = bf5xx_pcm_pointer,
|
||||||
.mmap = bf5xx_pcm_mmap,
|
.mmap = bf5xx_pcm_mmap,
|
||||||
.copy = bf5xx_pcm_copy,
|
.copy_user = bf5xx_pcm_copy_user,
|
||||||
.silence = bf5xx_pcm_silence,
|
.copy_kernel = bf5xx_pcm_copy,
|
||||||
|
.fill_silence = bf5xx_pcm_silence,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int bf5xx_pcm_i2s_new(struct snd_soc_pcm_runtime *rtd)
|
static int bf5xx_pcm_i2s_new(struct snd_soc_pcm_runtime *rtd)
|
||||||
|
|
Loading…
Reference in a new issue