From f8f11795b96a3632edb25a8924c61bfb74581cb0 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 6 Aug 2013 13:39:29 +0200 Subject: ASoC: tlv320aic26: Fix keyclick feature The tlv320aic26 contains a embedded snd_soc_codec struct which is referenced in the keyclick code. That struct is never initialized though, replace the embedded struct with a pointer and use that in the keyclick code. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic26.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c index b1f6982c7c9c..b192cd4705a0 100644 --- a/sound/soc/codecs/tlv320aic26.c +++ b/sound/soc/codecs/tlv320aic26.c @@ -29,7 +29,7 @@ MODULE_LICENSE("GPL"); /* AIC26 driver private data */ struct aic26 { struct spi_device *spi; - struct snd_soc_codec codec; + struct snd_soc_codec *codec; int master; int datfm; int mclk; @@ -330,7 +330,7 @@ static ssize_t aic26_keyclick_show(struct device *dev, struct aic26 *aic26 = dev_get_drvdata(dev); int val, amp, freq, len; - val = aic26_reg_read_cache(&aic26->codec, AIC26_REG_AUDIO_CTRL2); + val = aic26_reg_read_cache(aic26->codec, AIC26_REG_AUDIO_CTRL2); amp = (val >> 12) & 0x7; freq = (125 << ((val >> 8) & 0x7)) >> 1; len = 2 * (1 + ((val >> 4) & 0xf)); @@ -346,9 +346,9 @@ static ssize_t aic26_keyclick_set(struct device *dev, struct aic26 *aic26 = dev_get_drvdata(dev); int val; - val = aic26_reg_read_cache(&aic26->codec, AIC26_REG_AUDIO_CTRL2); + val = aic26_reg_read_cache(aic26->codec, AIC26_REG_AUDIO_CTRL2); val |= 0x8000; - aic26_reg_write(&aic26->codec, AIC26_REG_AUDIO_CTRL2, val); + aic26_reg_write(aic26->codec, AIC26_REG_AUDIO_CTRL2, val); return count; } @@ -360,8 +360,11 @@ static DEVICE_ATTR(keyclick, 0644, aic26_keyclick_show, aic26_keyclick_set); */ static int aic26_probe(struct snd_soc_codec *codec) { + struct aic26 *aic26 = dev_get_drvdata(codec->dev); int ret, err, i, reg; + aic26->codec = codec; + dev_info(codec->dev, "Probing AIC26 SoC CODEC driver\n"); /* Reset the codec to power on defaults */ -- cgit v1.2.3 From 12201398fc9ad25f5c6568527e70c9a4bcf5fcee Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 16 Aug 2013 12:13:50 +0100 Subject: ASoC: tlv320aic26: Remove direct use of internal I/O functions Use the core to do I/O rather than directly calling the driver operations in order to support further refactoring. Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic26.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c index b192cd4705a0..a4f93608287e 100644 --- a/sound/soc/codecs/tlv320aic26.c +++ b/sound/soc/codecs/tlv320aic26.c @@ -174,9 +174,9 @@ static int aic26_hw_params(struct snd_pcm_substream *substream, dev_dbg(&aic26->spi->dev, "Setting PLLM to %d.%04d\n", jval, dval); qval = 0; reg = 0x8000 | qval << 11 | pval << 8 | jval << 2; - aic26_reg_write(codec, AIC26_REG_PLL_PROG1, reg); + snd_soc_write(codec, AIC26_REG_PLL_PROG1, reg); reg = dval << 2; - aic26_reg_write(codec, AIC26_REG_PLL_PROG2, reg); + snd_soc_write(codec, AIC26_REG_PLL_PROG2, reg); /* Audio Control 3 (master mode, fsref rate) */ reg = aic26_reg_read_cache(codec, AIC26_REG_AUDIO_CTRL3); @@ -185,13 +185,13 @@ static int aic26_hw_params(struct snd_pcm_substream *substream, reg |= 0x0800; if (fsref == 48000) reg |= 0x2000; - aic26_reg_write(codec, AIC26_REG_AUDIO_CTRL3, reg); + snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg); /* Audio Control 1 (FSref divisor) */ reg = aic26_reg_read_cache(codec, AIC26_REG_AUDIO_CTRL1); reg &= ~0x0fff; reg |= wlen | aic26->datfm | (divisor << 3) | divisor; - aic26_reg_write(codec, AIC26_REG_AUDIO_CTRL1, reg); + snd_soc_write(codec, AIC26_REG_AUDIO_CTRL1, reg); return 0; } @@ -212,7 +212,7 @@ static int aic26_mute(struct snd_soc_dai *dai, int mute) reg |= 0x8080; else reg &= ~0x8080; - aic26_reg_write(codec, AIC26_REG_DAC_GAIN, reg); + snd_soc_write(codec, AIC26_REG_DAC_GAIN, reg); return 0; } @@ -348,7 +348,7 @@ static ssize_t aic26_keyclick_set(struct device *dev, val = aic26_reg_read_cache(aic26->codec, AIC26_REG_AUDIO_CTRL2); val |= 0x8000; - aic26_reg_write(aic26->codec, AIC26_REG_AUDIO_CTRL2, val); + snd_soc_write(aic26->codec, AIC26_REG_AUDIO_CTRL2, val); return count; } @@ -368,20 +368,20 @@ static int aic26_probe(struct snd_soc_codec *codec) dev_info(codec->dev, "Probing AIC26 SoC CODEC driver\n"); /* Reset the codec to power on defaults */ - aic26_reg_write(codec, AIC26_REG_RESET, 0xBB00); + snd_soc_write(codec, AIC26_REG_RESET, 0xBB00); /* Power up CODEC */ - aic26_reg_write(codec, AIC26_REG_POWER_CTRL, 0); + snd_soc_write(codec, AIC26_REG_POWER_CTRL, 0); /* Audio Control 3 (master mode, fsref rate) */ - reg = aic26_reg_read(codec, AIC26_REG_AUDIO_CTRL3); + reg = snd_soc_read(codec, AIC26_REG_AUDIO_CTRL3); reg &= ~0xf800; reg |= 0x0800; /* set master mode */ - aic26_reg_write(codec, AIC26_REG_AUDIO_CTRL3, reg); + snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg); /* Fill register cache */ for (i = 0; i < codec->driver->reg_cache_size; i++) - aic26_reg_read(codec, i); + snd_soc_read(codec, i); /* Register the sysfs files for debugging */ /* Create SysFS files */ -- cgit v1.2.3 From c21bb9b1b7de87ee33c8ebf94a155be2aa551849 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 16 Aug 2013 12:14:42 +0100 Subject: ASoC: tlv320aic26: Remove noisy print Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic26.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c index a4f93608287e..93cf692a8db7 100644 --- a/sound/soc/codecs/tlv320aic26.c +++ b/sound/soc/codecs/tlv320aic26.c @@ -365,8 +365,6 @@ static int aic26_probe(struct snd_soc_codec *codec) aic26->codec = codec; - dev_info(codec->dev, "Probing AIC26 SoC CODEC driver\n"); - /* Reset the codec to power on defaults */ snd_soc_write(codec, AIC26_REG_RESET, 0xBB00); -- cgit v1.2.3 From 4a11bc2fdd7f526c70e013366171d66f27656203 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 16 Aug 2013 12:24:47 +0100 Subject: ASoC: tlv320aic26: Add basic DAPM support Provide external widgets for the CODEC to ensure the device continues to function with DAPM mandatory and to make it easier to hook the device up to other components. Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic26.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c index 93cf692a8db7..7b8f3d965f43 100644 --- a/sound/soc/codecs/tlv320aic26.c +++ b/sound/soc/codecs/tlv320aic26.c @@ -119,6 +119,22 @@ static int aic26_reg_write(struct snd_soc_codec *codec, unsigned int reg, return 0; } +static const struct snd_soc_dapm_widget tlv320aic26_dapm_widgets[] = { +SND_SOC_DAPM_INPUT("MICIN"), +SND_SOC_DAPM_INPUT("AUX"), + +SND_SOC_DAPM_OUTPUT("HPL"), +SND_SOC_DAPM_OUTPUT("HPR"), +}; + +static const struct snd_soc_dapm_route tlv320aic26_dapm_routes[] = { + { "Capture", NULL, "MICIN" }, + { "Capture", NULL, "AUX" }, + + { "HPL", NULL, "Playback" }, + { "HPR", NULL, "Playback" }, +}; + /* --------------------------------------------------------------------- * Digital Audio Interface Operations */ @@ -402,6 +418,10 @@ static struct snd_soc_codec_driver aic26_soc_codec_dev = { .write = aic26_reg_write, .reg_cache_size = AIC26_NUM_REGS, .reg_word_size = sizeof(u16), + .dapm_widgets = tlv320aic26_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(tlv320aic26_dapm_widgets), + .dapm_routes = tlv320aic26_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(tlv320aic26_dapm_routes), }; /* --------------------------------------------------------------------- -- cgit v1.2.3