ASoC: ssm2602: Fix priv substreams refs
Clean up our record of the active streams in shutdown(), fixing subsequent failures of snd_pcm_hw_constraints_complete after closure of a stream. NOTE: - The ssm2602 allows pairs of non-matching PB/REC rates. - This is a fix for less evil: The logic is flawed (e.g. the slave might startup before the master's rate and sample_bits are set). Signed-off-by: Karl Beldan <karl.beldan@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
bd903bde7e
commit
faab5a32f4
@ -292,9 +292,15 @@ static int ssm2602_hw_params(struct snd_pcm_substream *substream,
|
|||||||
struct snd_soc_device *socdev = rtd->socdev;
|
struct snd_soc_device *socdev = rtd->socdev;
|
||||||
struct snd_soc_codec *codec = socdev->codec;
|
struct snd_soc_codec *codec = socdev->codec;
|
||||||
struct ssm2602_priv *ssm2602 = codec->private_data;
|
struct ssm2602_priv *ssm2602 = codec->private_data;
|
||||||
|
struct i2c_client *i2c = codec->control_data;
|
||||||
u16 iface = ssm2602_read_reg_cache(codec, SSM2602_IFACE) & 0xfff3;
|
u16 iface = ssm2602_read_reg_cache(codec, SSM2602_IFACE) & 0xfff3;
|
||||||
int i = get_coeff(ssm2602->sysclk, params_rate(params));
|
int i = get_coeff(ssm2602->sysclk, params_rate(params));
|
||||||
|
|
||||||
|
if (substream == ssm2602->slave_substream) {
|
||||||
|
dev_dbg(&i2c->dev, "Ignoring hw_params for slave substream\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*no match is found*/
|
/*no match is found*/
|
||||||
if (i == ARRAY_SIZE(coeff_div))
|
if (i == ARRAY_SIZE(coeff_div))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -330,13 +336,19 @@ static int ssm2602_startup(struct snd_pcm_substream *substream)
|
|||||||
struct snd_soc_device *socdev = rtd->socdev;
|
struct snd_soc_device *socdev = rtd->socdev;
|
||||||
struct snd_soc_codec *codec = socdev->codec;
|
struct snd_soc_codec *codec = socdev->codec;
|
||||||
struct ssm2602_priv *ssm2602 = codec->private_data;
|
struct ssm2602_priv *ssm2602 = codec->private_data;
|
||||||
|
struct i2c_client *i2c = codec->control_data;
|
||||||
struct snd_pcm_runtime *master_runtime;
|
struct snd_pcm_runtime *master_runtime;
|
||||||
|
|
||||||
/* The DAI has shared clocks so if we already have a playback or
|
/* The DAI has shared clocks so if we already have a playback or
|
||||||
* capture going then constrain this substream to match it.
|
* capture going then constrain this substream to match it.
|
||||||
|
* TODO: the ssm2602 allows pairs of non-matching PB/REC rates
|
||||||
*/
|
*/
|
||||||
if (ssm2602->master_substream) {
|
if (ssm2602->master_substream) {
|
||||||
master_runtime = ssm2602->master_substream->runtime;
|
master_runtime = ssm2602->master_substream->runtime;
|
||||||
|
dev_dbg(&i2c->dev, "Constraining to %d bits at %dHz\n",
|
||||||
|
master_runtime->sample_bits,
|
||||||
|
master_runtime->rate);
|
||||||
|
|
||||||
snd_pcm_hw_constraint_minmax(substream->runtime,
|
snd_pcm_hw_constraint_minmax(substream->runtime,
|
||||||
SNDRV_PCM_HW_PARAM_RATE,
|
SNDRV_PCM_HW_PARAM_RATE,
|
||||||
master_runtime->rate,
|
master_runtime->rate,
|
||||||
@ -370,9 +382,15 @@ static void ssm2602_shutdown(struct snd_pcm_substream *substream)
|
|||||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||||
struct snd_soc_device *socdev = rtd->socdev;
|
struct snd_soc_device *socdev = rtd->socdev;
|
||||||
struct snd_soc_codec *codec = socdev->codec;
|
struct snd_soc_codec *codec = socdev->codec;
|
||||||
|
struct ssm2602_priv *ssm2602 = codec->private_data;
|
||||||
/* deactivate */
|
/* deactivate */
|
||||||
if (!codec->active)
|
if (!codec->active)
|
||||||
ssm2602_write(codec, SSM2602_ACTIVE, 0);
|
ssm2602_write(codec, SSM2602_ACTIVE, 0);
|
||||||
|
|
||||||
|
if (ssm2602->master_substream == substream)
|
||||||
|
ssm2602->master_substream = ssm2602->slave_substream;
|
||||||
|
|
||||||
|
ssm2602->slave_substream = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ssm2602_mute(struct snd_soc_dai *dai, int mute)
|
static int ssm2602_mute(struct snd_soc_dai *dai, int mute)
|
||||||
|
Loading…
Reference in New Issue
Block a user