alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [v2] ASoC: support all possible sample rates in the WM8776 driver
@ 2011-09-16 14:16 Timur Tabi
  2011-09-16 15:37 ` Takashi Iwai
  2011-09-16 16:44 ` Mark Brown
  0 siblings, 2 replies; 20+ messages in thread
From: Timur Tabi @ 2011-09-16 14:16 UTC (permalink / raw)
  To: broonie, lrg, alsa-devel

The .set_sysclk() function in ASoC codec drivers can be used to tell the
driver what the frequency of master clock (mclk) is.  Some codecs use a
divider on this clock to determine the sample rate.  The WM8776 is one such
codec.

So instead of hard-coding a list of specific sample rates supported, these
codec drivers can specify SNDRV_PCM_RATE_CONTINUOUS instead, clamping the
range to the absolute limits of the hardware.  Then the .hw_params() function
can use the mclk rate to determine whether any requested rate is actually
supported.

Although the WM8776 driver includes a .set_sysclk function, it was also
hard-coding the list of supported sample rates.  We change the hard-coded
list to a range within the capabilities of the WM8776 itself.

Signed-off-by: Timur Tabi <timur@freescale.com>
---
 sound/soc/codecs/wm8776.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c
index ad6f0fa..ca8a593 100644
--- a/sound/soc/codecs/wm8776.c
+++ b/sound/soc/codecs/wm8776.c
@@ -321,11 +321,6 @@ static int wm8776_set_bias_level(struct snd_soc_codec *codec,
 	return 0;
 }
 
-#define WM8776_RATES (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
-		      SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |\
-		      SNDRV_PCM_RATE_96000)
-
-
 #define WM8776_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
 			SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
 
@@ -350,7 +345,9 @@ static struct snd_soc_dai_driver wm8776_dai[] = {
 			.stream_name = "Playback",
 			.channels_min = 2,
 			.channels_max = 2,
-			.rates = WM8776_RATES,
+			.rates = SNDRV_PCM_RATE_CONTINUOUS,
+			.rate_min = 32000,
+			.rate_max = 192000,
 			.formats = WM8776_FORMATS,
 		},
 		.ops = &wm8776_dac_ops,
@@ -362,7 +359,9 @@ static struct snd_soc_dai_driver wm8776_dai[] = {
 			.stream_name = "Capture",
 			.channels_min = 2,
 			.channels_max = 2,
-			.rates = WM8776_RATES,
+			.rates = SNDRV_PCM_RATE_CONTINUOUS,
+			.rate_min = 32000,
+			.rate_max = 96000,
 			.formats = WM8776_FORMATS,
 		},
 		.ops = &wm8776_adc_ops,
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2011-09-17 13:27 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-16 14:16 [PATCH] [v2] ASoC: support all possible sample rates in the WM8776 driver Timur Tabi
2011-09-16 15:37 ` Takashi Iwai
2011-09-16 15:47   ` Timur Tabi
2011-09-16 16:26     ` Mark Brown
2011-09-16 16:33       ` Timur Tabi
2011-09-16 16:47         ` Mark Brown
2011-09-16 16:54           ` Timur Tabi
2011-09-16 16:27     ` Lars-Peter Clausen
2011-09-16 16:28       ` Mark Brown
2011-09-16 16:34       ` Timur Tabi
2011-09-16 17:46         ` Lars-Peter Clausen
2011-09-16 18:19           ` Timur Tabi
2011-09-17 13:27           ` Mark Brown
2011-09-16 16:44 ` Mark Brown
2011-09-16 16:47   ` Timur Tabi
2011-09-16 16:48     ` Mark Brown
2011-09-16 16:56       ` Timur Tabi
2011-09-16 17:13         ` Mark Brown
2011-09-16 18:25           ` Timur Tabi
2011-09-17 12:58             ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).