From 31ad0f31c3a45ba489203eef7e71d3215005afbc Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 27 Mar 2009 10:39:07 +0200 Subject: ASoC: TWL4030: 96KHz playback support TWL4030 supports 96KHz sample playback, but only playback. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/codecs/twl4030.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/soc/codecs/twl4030.c') diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 97738e2ece0..b07d8d68a93 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -1395,7 +1395,7 @@ struct snd_soc_dai twl4030_dai = { .stream_name = "Playback", .channels_min = 2, .channels_max = 2, - .rates = TWL4030_RATES, + .rates = TWL4030_RATES | SNDRV_PCM_RATE_96000, .formats = TWL4030_FORMATS,}, .capture = { .stream_name = "Capture", -- cgit v1.2.3 From 7220b9f4bd4fad41f6f7299fe74c2c38ec85d793 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 27 Mar 2009 10:39:08 +0200 Subject: ASoC: TWL4030: Add constrains for second stream In case of duplex mode (capture and playback at the same time), the second stream has to have the same parameters (rate, sample size) as the already running stream. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/codecs/twl4030.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'sound/soc/codecs/twl4030.c') diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index b07d8d68a93..4199498a891 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -122,6 +122,9 @@ struct twl4030_priv { unsigned int bypass_state; unsigned int codec_powered; unsigned int codec_muted; + + struct snd_pcm_substream *master_substream; + struct snd_pcm_substream *slave_substream; }; /* @@ -1217,6 +1220,50 @@ static int twl4030_set_bias_level(struct snd_soc_codec *codec, return 0; } +static int twl4030_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_device *socdev = rtd->socdev; + struct snd_soc_codec *codec = socdev->codec; + struct twl4030_priv *twl4030 = codec->private_data; + + /* If we already have a playback or capture going then constrain + * this substream to match it. + */ + if (twl4030->master_substream) { + struct snd_pcm_runtime *master_runtime; + master_runtime = twl4030->master_substream->runtime; + + snd_pcm_hw_constraint_minmax(substream->runtime, + SNDRV_PCM_HW_PARAM_RATE, + master_runtime->rate, + master_runtime->rate); + + snd_pcm_hw_constraint_minmax(substream->runtime, + SNDRV_PCM_HW_PARAM_SAMPLE_BITS, + master_runtime->sample_bits, + master_runtime->sample_bits); + + twl4030->slave_substream = substream; + } else + twl4030->master_substream = substream; + + return 0; +} + +static void twl4030_shutdown(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_device *socdev = rtd->socdev; + struct snd_soc_codec *codec = socdev->codec; + struct twl4030_priv *twl4030 = codec->private_data; + + if (twl4030->master_substream == substream) + twl4030->master_substream = twl4030->slave_substream; + + twl4030->slave_substream = NULL; +} + static int twl4030_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) @@ -1224,8 +1271,13 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_device *socdev = rtd->socdev; struct snd_soc_codec *codec = socdev->card->codec; + struct twl4030_priv *twl4030 = codec->private_data; u8 mode, old_mode, format, old_format; + if (substream == twl4030->slave_substream) + /* Ignoring hw_params for slave substream */ + return 0; + /* bit rate */ old_mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE) & ~TWL4030_CODECPDZ; @@ -1384,6 +1436,8 @@ static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai, #define TWL4030_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FORMAT_S24_LE) static struct snd_soc_dai_ops twl4030_dai_ops = { + .startup = twl4030_startup, + .shutdown = twl4030_shutdown, .hw_params = twl4030_hw_params, .set_sysclk = twl4030_set_dai_sysclk, .set_fmt = twl4030_set_dai_fmt, -- cgit v1.2.3 From 103f211d0be2bed75b5739de62a10415ef0bbc25 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 3 Apr 2009 14:39:05 +0300 Subject: ASoC: TWL4030: Add actual support for 96KHz playback support Adds the needed code to be able to use 96KHz playback. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/codecs/twl4030.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sound/soc/codecs/twl4030.c') diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 4199498a891..bfda7a88e82 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -1311,6 +1311,9 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream, case 48000: mode |= TWL4030_APLL_RATE_48000; break; + case 96000: + mode |= TWL4030_APLL_RATE_96000; + break; default: printk(KERN_ERR "TWL4030 hw params: unknown rate %d\n", params_rate(params)); -- cgit v1.2.3