Title: [6489] branches/2009R1/sound/soc/codecs/ssm2602.c: bug[#2424]use a more common way to set constraints to runtime parameters
Revision
6489
Author
cliff
Date
2009-05-27 04:22:20 -0500 (Wed, 27 May 2009)

Log Message

bug[#2424]use a more common way to set constraints to runtime parameters

Modified Paths

Diff

Modified: branches/2009R1/sound/soc/codecs/ssm2602.c (6488 => 6489)


--- branches/2009R1/sound/soc/codecs/ssm2602.c	2009-05-27 09:19:14 UTC (rev 6488)
+++ branches/2009R1/sound/soc/codecs/ssm2602.c	2009-05-27 09:22:20 UTC (rev 6489)
@@ -49,8 +49,8 @@
 /* codec private data */
 struct ssm2602_priv {
 	unsigned int sysclk;
-	unsigned int master_rate;
-	unsigned int master_sample_bits;
+	struct snd_pcm_substream *master_substream;
+	struct snd_pcm_substream *slave_substream;
 };
 
 /*
@@ -330,25 +330,27 @@
 	struct snd_soc_device *socdev = rtd->socdev;
 	struct snd_soc_codec *codec = socdev->codec;
 	struct ssm2602_priv *ssm2602 = codec->private_data;
+	struct snd_pcm_runtime *master_runtime;
 
 	/* The DAI has shared clocks so if we already have a playback or
 	 * capture going then constrain this substream to match it.
 	 */
-	if (ssm2602->master_rate) {
-		snd_pcm_hw_constraint_minmax(substream->runtime,
-					     SNDRV_PCM_HW_PARAM_RATE,
-					     ssm2602->master_rate,
-					     ssm2602->master_rate);
-	} else
-		ssm2602->master_rate = substream->runtime->rate;
+	if (ssm2602->master_substream) {
+		master_runtime = ssm2602->master_substream->runtime;
+		if (master_runtime->rate != 0)
+			snd_pcm_hw_constraint_minmax(substream->runtime,
+						     SNDRV_PCM_HW_PARAM_RATE,
+						     master_runtime->rate,
+						     master_runtime->rate);
+		if (master_runtime->sample_bits != 0)
+			snd_pcm_hw_constraint_minmax(substream->runtime,
+						     SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
+						     master_runtime->sample_bits,
+						     master_runtime->sample_bits);
 
-	if (ssm2602->master_sample_bits) {
-		snd_pcm_hw_constraint_minmax(substream->runtime,
-					     SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
-					     ssm2602->master_sample_bits,
-					     ssm2602->master_sample_bits);
+		ssm2602->slave_substream = substream;
 	} else
-		ssm2602->master_sample_bits = substream->runtime->sample_bits;
+		ssm2602->master_substream = substream;
 
 	return 0;
 }
@@ -369,6 +371,12 @@
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_device *socdev = rtd->socdev;
 	struct snd_soc_codec *codec = socdev->codec;
+	struct ssm2602_priv *ssm2602 = codec->private_data;
+
+	if (ssm2602->master_substream == substream)
+		ssm2602->master_substream = ssm2602->slave_substream;
+
+	ssm2602->slave_substream = NULL;
 	/* deactivate */
 	if (!codec->active)
 		ssm2602_write(codec, SSM2602_ACTIVE, 0);
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to