Skip to content

Commit a010ff6

Browse files
larsclausenbroonie
authored andcommitted
ASoC: ssm2602: Use core for applying symmetry constraints
Let the core take care of applying sample rate and sample bits constraints instead of open-coding this in the driver. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
1 parent 647dc46 commit a010ff6

1 file changed

Lines changed: 2 additions & 48 deletions

File tree

‎sound/soc/codecs/ssm2602.c‎

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ enum ssm2602_type {
5353
struct ssm2602_priv {
5454
unsigned int sysclk;
5555
struct snd_pcm_hw_constraint_list *sysclk_constraints;
56-
struct snd_pcm_substream *master_substream;
57-
struct snd_pcm_substream *slave_substream;
5856

5957
struct regmap *regmap;
6058

@@ -277,11 +275,6 @@ static int ssm2602_hw_params(struct snd_pcm_substream *substream,
277275
int srate = ssm2602_get_coeff(ssm2602->sysclk, params_rate(params));
278276
unsigned int iface;
279277

280-
if (substream == ssm2602->slave_substream) {
281-
dev_dbg(codec->dev, "Ignoring hw_params for slave substream\n");
282-
return 0;
283-
}
284-
285278
if (srate < 0)
286279
return srate;
287280

@@ -314,33 +307,6 @@ static int ssm2602_startup(struct snd_pcm_substream *substream,
314307
{
315308
struct snd_soc_codec *codec = dai->codec;
316309
struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec);
317-
struct snd_pcm_runtime *master_runtime;
318-
319-
/* The DAI has shared clocks so if we already have a playback or
320-
* capture going then constrain this substream to match it.
321-
* TODO: the ssm2602 allows pairs of non-matching PB/REC rates
322-
*/
323-
if (ssm2602->master_substream) {
324-
master_runtime = ssm2602->master_substream->runtime;
325-
dev_dbg(codec->dev, "Constraining to %d bits at %dHz\n",
326-
master_runtime->sample_bits,
327-
master_runtime->rate);
328-
329-
if (master_runtime->rate != 0)
330-
snd_pcm_hw_constraint_minmax(substream->runtime,
331-
SNDRV_PCM_HW_PARAM_RATE,
332-
master_runtime->rate,
333-
master_runtime->rate);
334-
335-
if (master_runtime->sample_bits != 0)
336-
snd_pcm_hw_constraint_minmax(substream->runtime,
337-
SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
338-
master_runtime->sample_bits,
339-
master_runtime->sample_bits);
340-
341-
ssm2602->slave_substream = substream;
342-
} else
343-
ssm2602->master_substream = substream;
344310

345311
if (ssm2602->sysclk_constraints) {
346312
snd_pcm_hw_constraint_list(substream->runtime, 0,
@@ -351,19 +317,6 @@ static int ssm2602_startup(struct snd_pcm_substream *substream,
351317
return 0;
352318
}
353319

354-
static void ssm2602_shutdown(struct snd_pcm_substream *substream,
355-
struct snd_soc_dai *dai)
356-
{
357-
struct snd_soc_codec *codec = dai->codec;
358-
struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec);
359-
360-
if (ssm2602->master_substream == substream)
361-
ssm2602->master_substream = ssm2602->slave_substream;
362-
363-
ssm2602->slave_substream = NULL;
364-
}
365-
366-
367320
static int ssm2602_mute(struct snd_soc_dai *dai, int mute)
368321
{
369322
struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(dai->codec);
@@ -530,7 +483,6 @@ static int ssm2602_set_bias_level(struct snd_soc_codec *codec,
530483
static const struct snd_soc_dai_ops ssm2602_dai_ops = {
531484
.startup = ssm2602_startup,
532485
.hw_params = ssm2602_hw_params,
533-
.shutdown = ssm2602_shutdown,
534486
.digital_mute = ssm2602_mute,
535487
.set_sysclk = ssm2602_set_dai_sysclk,
536488
.set_fmt = ssm2602_set_dai_fmt,
@@ -551,6 +503,8 @@ static struct snd_soc_dai_driver ssm2602_dai = {
551503
.rates = SSM2602_RATES,
552504
.formats = SSM2602_FORMATS,},
553505
.ops = &ssm2602_dai_ops,
506+
.symmetric_rates = 1,
507+
.symmetric_samplebits = 1,
554508
};
555509

556510
static int ssm2602_suspend(struct snd_soc_codec *codec)

0 commit comments

Comments
 (0)