Skip to content

Commit

Permalink
ASoC: nuc900: patch for SUBSTREAM_TYPE', 'PCM_TX' and 'PCM_RX' removal
Browse files Browse the repository at this point in the history
This patch is to remove the 'SUBSTREAM_TYPE','PCM_TX' and 'PCM_RX' definition.

There is no need to redefine SNDRV_PCM_STREAM_PLAYBACK as PCM_TX,
the SUBSTREAM_TYPE(substream) can be deleted too, the playback or record can be
judged by 'if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)' directly rather
than 'if (PCM_TX == stype)', which makes the codes easy to read.

Signed-off-by: Wan ZongShun <mcuos.com@gmail.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Wan ZongShun authored and Mark Brown committed Jun 2, 2010
1 parent 1fab79b commit 018334c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
6 changes: 3 additions & 3 deletions sound/soc/nuc900/nuc900-ac97.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ static int nuc900_ac97_trigger(struct snd_pcm_substream *substream,
int cmd, struct snd_soc_dai *dai)
{
struct nuc900_audio *nuc900_audio = nuc900_ac97_data;
int ret, stype = SUBSTREAM_TYPE(substream);
int ret;
unsigned long val, tmp;

ret = 0;
Expand All @@ -231,7 +231,7 @@ static int nuc900_ac97_trigger(struct snd_pcm_substream *substream,
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
val = AUDIO_READ(nuc900_audio->mmio + ACTL_RESET);
if (PCM_TX == stype) {
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
tmp = AUDIO_READ(nuc900_audio->mmio + ACTL_ACOS0);
tmp |= (SLOT3_VALID | SLOT4_VALID | VALID_FRAME);
AUDIO_WRITE(nuc900_audio->mmio + ACTL_ACOS0, tmp);
Expand All @@ -254,7 +254,7 @@ static int nuc900_ac97_trigger(struct snd_pcm_substream *substream,
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
val = AUDIO_READ(nuc900_audio->mmio + ACTL_RESET);
if (PCM_TX == stype) {
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
tmp = AUDIO_READ(nuc900_audio->mmio + ACTL_ACOS0);
tmp &= ~(SLOT3_VALID | SLOT4_VALID);
AUDIO_WRITE(nuc900_audio->mmio + ACTL_ACOS0, tmp);
Expand Down
4 changes: 0 additions & 4 deletions sound/soc/nuc900/nuc900-auido.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@
#define RESET_PRSR 0x00
#define AUDIO_WRITE(addr, val) __raw_writel(val, addr)
#define AUDIO_READ(addr) __raw_readl(addr)
#define PCM_TX 0
#define PCM_RX 1
#define SUBSTREAM_TYPE(substream) \
((substream)->stream == SNDRV_PCM_STREAM_PLAYBACK ? PCM_TX : PCM_RX)

struct nuc900_audio {
void __iomem *mmio;
Expand Down
18 changes: 10 additions & 8 deletions sound/soc/nuc900/nuc900-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static int nuc900_dma_hw_params(struct snd_pcm_substream *substream,
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct nuc900_audio *nuc900_audio = runtime->private_data;
unsigned long flags, stype = SUBSTREAM_TYPE(substream);
unsigned long flags;
int ret = 0;

spin_lock_irqsave(&nuc900_audio->lock, flags);
Expand All @@ -57,8 +57,9 @@ static int nuc900_dma_hw_params(struct snd_pcm_substream *substream,
return ret;

nuc900_audio->substream = substream;
nuc900_audio->dma_addr[stype] = runtime->dma_addr;
nuc900_audio->buffersize[stype] = params_buffer_bytes(params);
nuc900_audio->dma_addr[substream->stream] = runtime->dma_addr;
nuc900_audio->buffersize[substream->stream] =
params_buffer_bytes(params);

spin_unlock_irqrestore(&nuc900_audio->lock, flags);

Expand All @@ -72,7 +73,7 @@ static void nuc900_update_dma_register(struct snd_pcm_substream *substream,
struct nuc900_audio *nuc900_audio = runtime->private_data;
void __iomem *mmio_addr, *mmio_len;

if (SUBSTREAM_TYPE(substream) == PCM_TX) {
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
mmio_addr = nuc900_audio->mmio + ACTL_PDSTB;
mmio_len = nuc900_audio->mmio + ACTL_PDST_LENGTH;
} else {
Expand Down Expand Up @@ -167,18 +168,19 @@ static int nuc900_dma_prepare(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct nuc900_audio *nuc900_audio = runtime->private_data;
unsigned long flags, val, stype = SUBSTREAM_TYPE(substream);;
unsigned long flags, val;

spin_lock_irqsave(&nuc900_audio->lock, flags);

nuc900_update_dma_register(substream,
nuc900_audio->dma_addr[stype], nuc900_audio->buffersize[stype]);
nuc900_audio->dma_addr[substream->stream],
nuc900_audio->buffersize[substream->stream]);

val = AUDIO_READ(nuc900_audio->mmio + ACTL_RESET);

switch (runtime->channels) {
case 1:
if (PCM_TX == stype) {
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
val &= ~(PLAY_LEFT_CHNNEL | PLAY_RIGHT_CHNNEL);
val |= PLAY_RIGHT_CHNNEL;
} else {
Expand All @@ -188,7 +190,7 @@ static int nuc900_dma_prepare(struct snd_pcm_substream *substream)
AUDIO_WRITE(nuc900_audio->mmio + ACTL_RESET, val);
break;
case 2:
if (PCM_TX == stype)
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
val |= (PLAY_LEFT_CHNNEL | PLAY_RIGHT_CHNNEL);
else
val |= (RECORD_LEFT_CHNNEL | RECORD_RIGHT_CHNNEL);
Expand Down

0 comments on commit 018334c

Please sign in to comment.