Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 148176
b: refs/heads/master
c: 06f409d
h: refs/heads/master
v: v3
  • Loading branch information
Mark Brown committed Apr 7, 2009
1 parent a91553f commit 2c9ebfa
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6553e192d48af88184029066c30c9464516ea0b7
refs/heads/master: 06f409d76f1d382167eb1cadde2e23a73272865d
1 change: 1 addition & 0 deletions trunk/include/sound/soc-dai.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ struct snd_soc_dai {
/* DAI capabilities */
struct snd_soc_pcm_stream capture;
struct snd_soc_pcm_stream playback;
unsigned int symmetric_rates:1;

/* DAI runtime info */
struct snd_pcm_runtime *runtime;
Expand Down
6 changes: 6 additions & 0 deletions trunk/include/sound/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,12 @@ struct snd_soc_dai_link {
/* codec/machine specific init - e.g. add machine controls */
int (*init)(struct snd_soc_codec *codec);

/* Symmetry requirements */
unsigned int symmetric_rates:1;

/* Symmetry data - only valid if symmetry is being enforced */
unsigned int rate;

/* DAI pcm */
struct snd_pcm *pcm;
};
Expand Down
38 changes: 38 additions & 0 deletions trunk/sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,35 @@ static int soc_ac97_dev_register(struct snd_soc_codec *codec)
}
#endif

static int soc_pcm_apply_symmetry(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_device *socdev = rtd->socdev;
struct snd_soc_card *card = socdev->card;
struct snd_soc_dai_link *machine = rtd->dai;
struct snd_soc_dai *cpu_dai = machine->cpu_dai;
struct snd_soc_dai *codec_dai = machine->codec_dai;
int ret;

if (codec_dai->symmetric_rates || cpu_dai->symmetric_rates ||
machine->symmetric_rates) {
dev_dbg(card->dev, "Symmetry forces %dHz rate\n",
machine->rate);

ret = snd_pcm_hw_constraint_minmax(substream->runtime,
SNDRV_PCM_HW_PARAM_RATE,
machine->rate,
machine->rate);
if (ret < 0) {
dev_err(card->dev,
"Unable to apply rate symmetry constraint: %d\n", ret);
return ret;
}
}

return 0;
}

/*
* Called by ALSA when a PCM substream is opened, the runtime->hw record is
* then initialized and any private data can be allocated. This also calls
Expand Down Expand Up @@ -221,6 +250,13 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
goto machine_err;
}

/* Symmetry only applies if we've already got an active stream. */
if (cpu_dai->active || codec_dai->active) {
ret = soc_pcm_apply_symmetry(substream);
if (ret != 0)
goto machine_err;
}

pr_debug("asoc: %s <-> %s info:\n", codec_dai->name, cpu_dai->name);
pr_debug("asoc: rate mask 0x%x\n", runtime->hw.rates);
pr_debug("asoc: min ch %d max ch %d\n", runtime->hw.channels_min,
Expand Down Expand Up @@ -521,6 +557,8 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
}
}

machine->rate = params_rate(params);

out:
mutex_unlock(&pcm_mutex);
return ret;
Expand Down

0 comments on commit 2c9ebfa

Please sign in to comment.