[alsa-devel] [PATCH 1/7] ASoC: ad193X: Use table based DAPM and controls setup
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- sound/soc/codecs/ad193x.c | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c index 1901cd2..1dfda5c 100644 --- a/sound/soc/codecs/ad193x.c +++ b/sound/soc/codecs/ad193x.c @@ -345,7 +345,6 @@ static struct snd_soc_dai_driver ad193x_dai = { static int ad193x_probe(struct snd_soc_codec *codec) { struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = &codec->dapm; int ret;
codec->control_data = ad193x->regmap; @@ -371,17 +370,17 @@ static int ad193x_probe(struct snd_soc_codec *codec) snd_soc_write(codec, AD193X_PLL_CLK_CTRL0, 0x99); /* mclk=24.576Mhz: 0x9D; mclk=12.288Mhz: 0x99 */ snd_soc_write(codec, AD193X_PLL_CLK_CTRL1, 0x04);
- snd_soc_add_controls(codec, ad193x_snd_controls, - ARRAY_SIZE(ad193x_snd_controls)); - snd_soc_dapm_new_controls(dapm, ad193x_dapm_widgets, - ARRAY_SIZE(ad193x_dapm_widgets)); - snd_soc_dapm_add_routes(dapm, audio_paths, ARRAY_SIZE(audio_paths)); - return ret; }
static struct snd_soc_codec_driver soc_codec_dev_ad193x = { .probe = ad193x_probe, + .controls = ad193x_snd_controls, + .num_controls = ARRAY_SIZE(ad193x_snd_controls), + .dapm_widgets = ad193x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ad193x_dapm_widgets), + .dapm_routes = audio_paths, + .num_dapm_routes = ARRAY_SIZE(audio_paths), };
#if defined(CONFIG_SPI_MASTER)
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- sound/soc/codecs/ad193x.c | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c index 1dfda5c..7da7e29 100644 --- a/sound/soc/codecs/ad193x.c +++ b/sound/soc/codecs/ad193x.c @@ -35,16 +35,18 @@ static const char *ad193x_deemp[] = {"None", "48kHz", "44.1kHz", "32kHz"}; static const struct soc_enum ad193x_deemp_enum = SOC_ENUM_SINGLE(AD193X_DAC_CTRL2, 1, 4, ad193x_deemp);
+static const DECLARE_TLV_DB_MINMAX(adau193x_tlv, -9563, 0); + static const struct snd_kcontrol_new ad193x_snd_controls[] = { /* DAC volume control */ - SOC_DOUBLE_R("DAC1 Volume", AD193X_DAC_L1_VOL, - AD193X_DAC_R1_VOL, 0, 0xFF, 1), - SOC_DOUBLE_R("DAC2 Volume", AD193X_DAC_L2_VOL, - AD193X_DAC_R2_VOL, 0, 0xFF, 1), - SOC_DOUBLE_R("DAC3 Volume", AD193X_DAC_L3_VOL, - AD193X_DAC_R3_VOL, 0, 0xFF, 1), - SOC_DOUBLE_R("DAC4 Volume", AD193X_DAC_L4_VOL, - AD193X_DAC_R4_VOL, 0, 0xFF, 1), + SOC_DOUBLE_R_TLV("DAC1 Volume", AD193X_DAC_L1_VOL, + AD193X_DAC_R1_VOL, 0, 0xFF, 1, adau193x_tlv), + SOC_DOUBLE_R_TLV("DAC2 Volume", AD193X_DAC_L2_VOL, + AD193X_DAC_R2_VOL, 0, 0xFF, 1, adau193x_tlv), + SOC_DOUBLE_R_TLV("DAC3 Volume", AD193X_DAC_L3_VOL, + AD193X_DAC_R3_VOL, 0, 0xFF, 1, adau193x_tlv), + SOC_DOUBLE_R_TLV("DAC4 Volume", AD193X_DAC_L4_VOL, + AD193X_DAC_R4_VOL, 0, 0xFF, 1, adau193x_tlv),
/* ADC switch control */ SOC_DOUBLE("ADC1 Switch", AD193X_ADC_CTRL0, AD193X_ADCL1_MUTE,
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- sound/soc/codecs/ad193x.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c index 7da7e29..665af5c 100644 --- a/sound/soc/codecs/ad193x.c +++ b/sound/soc/codecs/ad193x.c @@ -30,7 +30,7 @@ struct ad193x_priv { /* * AD193X volume/mute/de-emphasis etc. controls */ -static const char *ad193x_deemp[] = {"None", "48kHz", "44.1kHz", "32kHz"}; +static const char * const ad193x_deemp[] = {"None", "48kHz", "44.1kHz", "32kHz"};
static const struct soc_enum ad193x_deemp_enum = SOC_ENUM_SINGLE(AD193X_DAC_CTRL2, 1, 4, ad193x_deemp);
On Mon, Nov 28, 2011 at 05:28:08PM +0100, Lars-Peter Clausen wrote:
-static const char *ad193x_deemp[] = {"None", "48kHz", "44.1kHz", "32kHz"}; +static const char * const ad193x_deemp[] = {"None", "48kHz", "44.1kHz", "32kHz"};
Ideally this would be converted to a switch and the driver would automatically select the rate based on the current sample rate.
On 11/28/2011 07:53 PM, Mark Brown wrote:
On Mon, Nov 28, 2011 at 05:28:08PM +0100, Lars-Peter Clausen wrote:
-static const char *ad193x_deemp[] = {"None", "48kHz", "44.1kHz", "32kHz"}; +static const char * const ad193x_deemp[] = {"None", "48kHz", "44.1kHz", "32kHz"};
Ideally this would be converted to a switch and the driver would automatically select the rate based on the current sample rate.
Ideally yes, but I'm not sure if this couldn't break some existing setup if it expects to find that control.
- Lars
On Mon, Nov 28, 2011 at 08:01:38PM +0100, Lars-Peter Clausen wrote:
On 11/28/2011 07:53 PM, Mark Brown wrote:
On Mon, Nov 28, 2011 at 05:28:08PM +0100, Lars-Peter Clausen wrote:
-static const char *ad193x_deemp[] = {"None", "48kHz", "44.1kHz", "32kHz"}; +static const char * const ad193x_deemp[] = {"None", "48kHz", "44.1kHz", "32kHz"};
Ideally this would be converted to a switch and the driver would automatically select the rate based on the current sample rate.
Ideally yes, but I'm not sure if this couldn't break some existing setup if it expects to find that control.
Well, it might but I'm not sure anyone actually uses deemphasis any more anyway.
DAPM route controls only take effect on paths where the sink is a mixer or a mux, furthermore the control must be a control assigned to the mixer or mux.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- sound/soc/codecs/ad193x.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c index 665af5c..c52ebd3 100644 --- a/sound/soc/codecs/ad193x.c +++ b/sound/soc/codecs/ad193x.c @@ -90,12 +90,12 @@ static const struct snd_soc_dapm_route audio_paths[] = { { "ADC", NULL, "PLL_PWR" }, { "DAC", NULL, "ADC_PWR" }, { "ADC", NULL, "ADC_PWR" }, - { "DAC1OUT", "DAC1 Switch", "DAC" }, - { "DAC2OUT", "DAC2 Switch", "DAC" }, - { "DAC3OUT", "DAC3 Switch", "DAC" }, - { "DAC4OUT", "DAC4 Switch", "DAC" }, - { "ADC", "ADC1 Switch", "ADC1IN" }, - { "ADC", "ADC2 Switch", "ADC2IN" }, + { "DAC1OUT", NULL, "DAC" }, + { "DAC2OUT", NULL, "DAC" }, + { "DAC3OUT", NULL, "DAC" }, + { "DAC4OUT", NULL, "DAC" }, + { "ADC", NULL, "ADC1IN" }, + { "ADC", NULL, "ADC2IN" }, };
/*
Add a DAPM supply widget for the internal sysclk, so it can be disabled automatically when not needed.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- sound/soc/codecs/ad193x.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c index c52ebd3..c19e223 100644 --- a/sound/soc/codecs/ad193x.c +++ b/sound/soc/codecs/ad193x.c @@ -77,6 +77,7 @@ static const struct snd_soc_dapm_widget ad193x_dapm_widgets[] = { SND_SOC_DAPM_ADC("ADC", "Capture", SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_SUPPLY("PLL_PWR", AD193X_PLL_CLK_CTRL0, 0, 1, NULL, 0), SND_SOC_DAPM_SUPPLY("ADC_PWR", AD193X_ADC_CTRL0, 0, 1, NULL, 0), + SND_SOC_DAPM_SUPPLY("SYSCLK", AD193X_PLL_CLK_CTRL0, 7, 0, NULL, 0), SND_SOC_DAPM_OUTPUT("DAC1OUT"), SND_SOC_DAPM_OUTPUT("DAC2OUT"), SND_SOC_DAPM_OUTPUT("DAC3OUT"), @@ -86,8 +87,8 @@ static const struct snd_soc_dapm_widget ad193x_dapm_widgets[] = { };
static const struct snd_soc_dapm_route audio_paths[] = { - { "DAC", NULL, "PLL_PWR" }, - { "ADC", NULL, "PLL_PWR" }, + { "DAC", NULL, "SYSCLK" }, + { "ADC", NULL, "SYSCLK" }, { "DAC", NULL, "ADC_PWR" }, { "ADC", NULL, "ADC_PWR" }, { "DAC1OUT", NULL, "DAC" }, @@ -96,6 +97,7 @@ static const struct snd_soc_dapm_route audio_paths[] = { { "DAC4OUT", NULL, "DAC" }, { "ADC", NULL, "ADC1IN" }, { "ADC", NULL, "ADC2IN" }, + { "SYSCLK", NULL, "PLL_PWR" }, };
/*
nitpick: you've got a variety of subjects: ASoC: AD193X: ... ASOC: AD193X: ... ASoC: ad193x: ...
be nice if it were consistent as it makes reading short logs easier ... -mike
On Tue, Nov 29, 2011 at 12:24:27AM -0500, Mike Frysinger wrote:
nitpick: you've got a variety of subjects:
Mike, *please* include some context in your replies.
ASoC: AD193X: ... ASOC: AD193X: ... ASoC: ad193x: ...
be nice if it were consistent as it makes reading short logs easier ...
I actually fixed this up when I was applying them but yes this is better.
On Tue, Nov 29, 2011 at 06:34, Mark Brown wrote:
On Tue, Nov 29, 2011 at 12:24:27AM -0500, Mike Frysinger wrote:
nitpick: you've got a variety of subjects:
Mike, *please* include some context in your replies.
the context was subject lines of diff patches, so i just picked a random one to reply to ... -mike
We can reduce the code size here a bit by using snd_soc_update_bits instead of open-coding the read-modify-write cycle. The conversion done in this patch is not completely straightforward and some minor code restructuring has been incorporated to further reduce the code size.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- sound/soc/codecs/ad193x.c | 96 +++++++++++++++++---------------------------- sound/soc/codecs/ad193x.h | 17 ++++---- 2 files changed, 45 insertions(+), 68 deletions(-)
diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c index c19e223..7d64f20 100644 --- a/sound/soc/codecs/ad193x.c +++ b/sound/soc/codecs/ad193x.c @@ -123,35 +123,29 @@ static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int width) { struct snd_soc_codec *codec = dai->codec; - int dac_reg = snd_soc_read(codec, AD193X_DAC_CTRL1); - int adc_reg = snd_soc_read(codec, AD193X_ADC_CTRL2); - - dac_reg &= ~AD193X_DAC_CHAN_MASK; - adc_reg &= ~AD193X_ADC_CHAN_MASK; + unsigned int channels;
switch (slots) { case 2: - dac_reg |= AD193X_DAC_2_CHANNELS << AD193X_DAC_CHAN_SHFT; - adc_reg |= AD193X_ADC_2_CHANNELS << AD193X_ADC_CHAN_SHFT; + channels = AD193X_2_CHANNELS; break; case 4: - dac_reg |= AD193X_DAC_4_CHANNELS << AD193X_DAC_CHAN_SHFT; - adc_reg |= AD193X_ADC_4_CHANNELS << AD193X_ADC_CHAN_SHFT; + channels = AD193X_4_CHANNELS; break; case 8: - dac_reg |= AD193X_DAC_8_CHANNELS << AD193X_DAC_CHAN_SHFT; - adc_reg |= AD193X_ADC_8_CHANNELS << AD193X_ADC_CHAN_SHFT; + channels = AD193X_8_CHANNELS; break; case 16: - dac_reg |= AD193X_DAC_16_CHANNELS << AD193X_DAC_CHAN_SHFT; - adc_reg |= AD193X_ADC_16_CHANNELS << AD193X_ADC_CHAN_SHFT; + channels = AD193X_16_CHANNELS; break; default: return -EINVAL; }
- snd_soc_write(codec, AD193X_DAC_CTRL1, dac_reg); - snd_soc_write(codec, AD193X_ADC_CTRL2, adc_reg); + snd_soc_update_bits(codec, AD193X_DAC_CTRL1, AD193X_DAC_CHAN_MASK, + channels << AD193X_DAC_CHAN_SHFT); + snd_soc_update_bits(codec, AD193X_ADC_CTRL2, AD193X_ADC_CHAN_MASK, + channels << AD193X_ADC_CHAN_SHFT);
return 0; } @@ -160,23 +154,19 @@ static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { struct snd_soc_codec *codec = codec_dai->codec; - int adc_reg1, adc_reg2, dac_reg; - - adc_reg1 = snd_soc_read(codec, AD193X_ADC_CTRL1); - adc_reg2 = snd_soc_read(codec, AD193X_ADC_CTRL2); - dac_reg = snd_soc_read(codec, AD193X_DAC_CTRL1); + unsigned int adc_serfmt = 0; + unsigned int adc_fmt = 0; + unsigned int dac_fmt = 0;
/* At present, the driver only support AUX ADC mode(SND_SOC_DAIFMT_I2S * with TDM) and ADC&DAC TDM mode(SND_SOC_DAIFMT_DSP_A) */ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: - adc_reg1 &= ~AD193X_ADC_SERFMT_MASK; - adc_reg1 |= AD193X_ADC_SERFMT_TDM; + adc_serfmt |= AD193X_ADC_SERFMT_TDM; break; case SND_SOC_DAIFMT_DSP_A: - adc_reg1 &= ~AD193X_ADC_SERFMT_MASK; - adc_reg1 |= AD193X_ADC_SERFMT_AUX; + adc_serfmt |= AD193X_ADC_SERFMT_AUX; break; default: return -EINVAL; @@ -184,29 +174,20 @@ static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai,
switch (fmt & SND_SOC_DAIFMT_INV_MASK) { case SND_SOC_DAIFMT_NB_NF: /* normal bit clock + frame */ - adc_reg2 &= ~AD193X_ADC_LEFT_HIGH; - adc_reg2 &= ~AD193X_ADC_BCLK_INV; - dac_reg &= ~AD193X_DAC_LEFT_HIGH; - dac_reg &= ~AD193X_DAC_BCLK_INV; break; case SND_SOC_DAIFMT_NB_IF: /* normal bclk + invert frm */ - adc_reg2 |= AD193X_ADC_LEFT_HIGH; - adc_reg2 &= ~AD193X_ADC_BCLK_INV; - dac_reg |= AD193X_DAC_LEFT_HIGH; - dac_reg &= ~AD193X_DAC_BCLK_INV; + adc_fmt |= AD193X_ADC_LEFT_HIGH; + dac_fmt |= AD193X_DAC_LEFT_HIGH; break; case SND_SOC_DAIFMT_IB_NF: /* invert bclk + normal frm */ - adc_reg2 &= ~AD193X_ADC_LEFT_HIGH; - adc_reg2 |= AD193X_ADC_BCLK_INV; - dac_reg &= ~AD193X_DAC_LEFT_HIGH; - dac_reg |= AD193X_DAC_BCLK_INV; + adc_fmt |= AD193X_ADC_BCLK_INV; + dac_fmt |= AD193X_DAC_BCLK_INV; break; - case SND_SOC_DAIFMT_IB_IF: /* invert bclk + frm */ - adc_reg2 |= AD193X_ADC_LEFT_HIGH; - adc_reg2 |= AD193X_ADC_BCLK_INV; - dac_reg |= AD193X_DAC_LEFT_HIGH; - dac_reg |= AD193X_DAC_BCLK_INV; + adc_fmt |= AD193X_ADC_LEFT_HIGH; + adc_fmt |= AD193X_ADC_BCLK_INV; + dac_fmt |= AD193X_DAC_LEFT_HIGH; + dac_fmt |= AD193X_DAC_BCLK_INV; break; default: return -EINVAL; @@ -214,36 +195,31 @@ static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai,
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: /* codec clk & frm master */ - adc_reg2 |= AD193X_ADC_LCR_MASTER; - adc_reg2 |= AD193X_ADC_BCLK_MASTER; - dac_reg |= AD193X_DAC_LCR_MASTER; - dac_reg |= AD193X_DAC_BCLK_MASTER; + adc_fmt |= AD193X_ADC_LCR_MASTER; + adc_fmt |= AD193X_ADC_BCLK_MASTER; + dac_fmt |= AD193X_DAC_LCR_MASTER; + dac_fmt |= AD193X_DAC_BCLK_MASTER; break; case SND_SOC_DAIFMT_CBS_CFM: /* codec clk slave & frm master */ - adc_reg2 |= AD193X_ADC_LCR_MASTER; - adc_reg2 &= ~AD193X_ADC_BCLK_MASTER; - dac_reg |= AD193X_DAC_LCR_MASTER; - dac_reg &= ~AD193X_DAC_BCLK_MASTER; + adc_fmt |= AD193X_ADC_LCR_MASTER; + dac_fmt |= AD193X_DAC_LCR_MASTER; break; case SND_SOC_DAIFMT_CBM_CFS: /* codec clk master & frame slave */ - adc_reg2 &= ~AD193X_ADC_LCR_MASTER; - adc_reg2 |= AD193X_ADC_BCLK_MASTER; - dac_reg &= ~AD193X_DAC_LCR_MASTER; - dac_reg |= AD193X_DAC_BCLK_MASTER; + adc_fmt |= AD193X_ADC_BCLK_MASTER; + dac_fmt |= AD193X_DAC_BCLK_MASTER; break; case SND_SOC_DAIFMT_CBS_CFS: /* codec clk & frm slave */ - adc_reg2 &= ~AD193X_ADC_LCR_MASTER; - adc_reg2 &= ~AD193X_ADC_BCLK_MASTER; - dac_reg &= ~AD193X_DAC_LCR_MASTER; - dac_reg &= ~AD193X_DAC_BCLK_MASTER; break; default: return -EINVAL; }
- snd_soc_write(codec, AD193X_ADC_CTRL1, adc_reg1); - snd_soc_write(codec, AD193X_ADC_CTRL2, adc_reg2); - snd_soc_write(codec, AD193X_DAC_CTRL1, dac_reg); + snd_soc_update_bits(codec, AD193X_ADC_CTRL1, AD193X_ADC_SERFMT_MASK, + adc_serfmt); + snd_soc_update_bits(codec, AD193X_ADC_CTRL2, AD193X_ADC_FMT_MASK, + adc_fmt); + snd_soc_update_bits(codec, AD193X_DAC_CTRL1, AD193X_DAC_FMT_MASK, + dac_fmt);
return 0; } diff --git a/sound/soc/codecs/ad193x.h b/sound/soc/codecs/ad193x.h index 1507eaa..4733880 100644 --- a/sound/soc/codecs/ad193x.h +++ b/sound/soc/codecs/ad193x.h @@ -23,16 +23,14 @@ #define AD193X_DAC_SERFMT_STEREO (0 << 6) #define AD193X_DAC_SERFMT_TDM (1 << 6) #define AD193X_DAC_CTRL1 0x03 -#define AD193X_DAC_2_CHANNELS 0 -#define AD193X_DAC_4_CHANNELS 1 -#define AD193X_DAC_8_CHANNELS 2 -#define AD193X_DAC_16_CHANNELS 3 #define AD193X_DAC_CHAN_SHFT 1 #define AD193X_DAC_CHAN_MASK (3 << AD193X_DAC_CHAN_SHFT) #define AD193X_DAC_LCR_MASTER (1 << 4) #define AD193X_DAC_BCLK_MASTER (1 << 5) #define AD193X_DAC_LEFT_HIGH (1 << 3) #define AD193X_DAC_BCLK_INV (1 << 7) +#define AD193X_DAC_FMT_MASK (AD193X_DAC_LCR_MASTER | \ + AD193X_DAC_BCLK_MASTER | AD193X_DAC_LEFT_HIGH | AD193X_DAC_BCLK_INV) #define AD193X_DAC_CTRL2 0x04 #define AD193X_DAC_WORD_LEN_SHFT 3 #define AD193X_DAC_WORD_LEN_MASK 0x18 @@ -68,16 +66,19 @@ #define AD193X_ADC_SERFMT_AUX (2 << 5) #define AD193X_ADC_WORD_LEN_MASK 0x3 #define AD193X_ADC_CTRL2 0x10 -#define AD193X_ADC_2_CHANNELS 0 -#define AD193X_ADC_4_CHANNELS 1 -#define AD193X_ADC_8_CHANNELS 2 -#define AD193X_ADC_16_CHANNELS 3 #define AD193X_ADC_CHAN_SHFT 4 #define AD193X_ADC_CHAN_MASK (3 << AD193X_ADC_CHAN_SHFT) #define AD193X_ADC_LCR_MASTER (1 << 3) #define AD193X_ADC_BCLK_MASTER (1 << 6) #define AD193X_ADC_LEFT_HIGH (1 << 2) #define AD193X_ADC_BCLK_INV (1 << 1) +#define AD193X_ADC_FMT_MASK (AD193X_ADC_LCR_MASTER | \ + AD193X_ADC_BCLK_MASTER | AD193X_ADC_LEFT_HIGH | AD193X_ADC_BCLK_INV) + +#define AD193X_2_CHANNELS 0 +#define AD193X_4_CHANNELS 1 +#define AD193X_8_CHANNELS 2 +#define AD193X_16_CHANNELS 3
#define AD193X_NUM_REGS 17
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- sound/soc/codecs/ad193x.c | 61 ++++++++++++++++++++++++++------------------ 1 files changed, 36 insertions(+), 25 deletions(-)
diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c index 7d64f20..c1b7d92 100644 --- a/sound/soc/codecs/ad193x.c +++ b/sound/soc/codecs/ad193x.c @@ -106,14 +106,14 @@ static const struct snd_soc_dapm_route audio_paths[] = {
static int ad193x_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(dai->codec);
if (mute) - snd_soc_update_bits(codec, AD193X_DAC_CTRL2, + regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL2, AD193X_DAC_MASTER_MUTE, AD193X_DAC_MASTER_MUTE); else - snd_soc_update_bits(codec, AD193X_DAC_CTRL2, + regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL2, AD193X_DAC_MASTER_MUTE, 0);
return 0; @@ -122,7 +122,7 @@ static int ad193x_mute(struct snd_soc_dai *dai, int mute) static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int width) { - struct snd_soc_codec *codec = dai->codec; + struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(dai->codec); unsigned int channels;
switch (slots) { @@ -142,10 +142,10 @@ static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, return -EINVAL; }
- snd_soc_update_bits(codec, AD193X_DAC_CTRL1, AD193X_DAC_CHAN_MASK, - channels << AD193X_DAC_CHAN_SHFT); - snd_soc_update_bits(codec, AD193X_ADC_CTRL2, AD193X_ADC_CHAN_MASK, - channels << AD193X_ADC_CHAN_SHFT); + regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL1, + AD193X_DAC_CHAN_MASK, channels << AD193X_DAC_CHAN_SHFT); + regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL2, + AD193X_ADC_CHAN_MASK, channels << AD193X_ADC_CHAN_SHFT);
return 0; } @@ -153,7 +153,7 @@ static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec_dai->codec); unsigned int adc_serfmt = 0; unsigned int adc_fmt = 0; unsigned int dac_fmt = 0; @@ -214,12 +214,12 @@ static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; }
- snd_soc_update_bits(codec, AD193X_ADC_CTRL1, AD193X_ADC_SERFMT_MASK, - adc_serfmt); - snd_soc_update_bits(codec, AD193X_ADC_CTRL2, AD193X_ADC_FMT_MASK, - adc_fmt); - snd_soc_update_bits(codec, AD193X_DAC_CTRL1, AD193X_DAC_FMT_MASK, - dac_fmt); + regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL1, + AD193X_ADC_SERFMT_MASK, adc_serfmt); + regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL2, + AD193X_ADC_FMT_MASK, adc_fmt); + regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL1, + AD193X_DAC_FMT_MASK, dac_fmt);
return 0; } @@ -279,14 +279,14 @@ static int ad193x_hw_params(struct snd_pcm_substream *substream, break; }
- snd_soc_update_bits(codec, AD193X_PLL_CLK_CTRL0, + regmap_update_bits(ad193x->regmap, AD193X_PLL_CLK_CTRL0, AD193X_PLL_INPUT_MASK, master_rate);
- snd_soc_update_bits(codec, AD193X_DAC_CTRL2, + regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL2, AD193X_DAC_WORD_LEN_MASK, word_len << AD193X_DAC_WORD_LEN_SHFT);
- snd_soc_update_bits(codec, AD193X_ADC_CTRL1, + regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL1, AD193X_ADC_WORD_LEN_MASK, word_len);
return 0; @@ -337,18 +337,18 @@ static int ad193x_probe(struct snd_soc_codec *codec) /* default setting for ad193x */
/* unmute dac channels */ - snd_soc_write(codec, AD193X_DAC_CHNL_MUTE, 0x0); + regmap_write(ad193x->regmap, AD193X_DAC_CHNL_MUTE, 0x0); /* de-emphasis: 48kHz, powedown dac */ - snd_soc_write(codec, AD193X_DAC_CTRL2, 0x1A); + regmap_write(ad193x->regmap, AD193X_DAC_CTRL2, 0x1A); /* powerdown dac, dac in tdm mode */ - snd_soc_write(codec, AD193X_DAC_CTRL0, 0x41); + regmap_write(ad193x->regmap, AD193X_DAC_CTRL0, 0x41); /* high-pass filter enable */ - snd_soc_write(codec, AD193X_ADC_CTRL0, 0x3); + regmap_write(ad193x->regmap, AD193X_ADC_CTRL0, 0x3); /* sata delay=1, adc aux mode */ - snd_soc_write(codec, AD193X_ADC_CTRL1, 0x43); + regmap_write(ad193x->regmap, AD193X_ADC_CTRL1, 0x43); /* pll input: mclki/xi */ - snd_soc_write(codec, AD193X_PLL_CLK_CTRL0, 0x99); /* mclk=24.576Mhz: 0x9D; mclk=12.288Mhz: 0x99 */ - snd_soc_write(codec, AD193X_PLL_CLK_CTRL1, 0x04); + regmap_write(ad193x->regmap, AD193X_PLL_CLK_CTRL0, 0x99); /* mclk=24.576Mhz: 0x9D; mclk=12.288Mhz: 0x99 */ + regmap_write(ad193x->regmap, AD193X_PLL_CLK_CTRL1, 0x04);
return ret; } @@ -363,6 +363,11 @@ static struct snd_soc_codec_driver soc_codec_dev_ad193x = { .num_dapm_routes = ARRAY_SIZE(audio_paths), };
+static bool adau193x_reg_volatile(struct device *dev, unsigned int reg) +{ + return false; +} + #if defined(CONFIG_SPI_MASTER)
static const struct regmap_config ad193x_spi_regmap_config = { @@ -370,6 +375,9 @@ static const struct regmap_config ad193x_spi_regmap_config = { .reg_bits = 16, .read_flag_mask = 0x09, .write_flag_mask = 0x08, + + .max_register = AD193X_NUM_REGS - 1, + .volatile_reg = adau193x_reg_volatile, };
static int __devinit ad193x_spi_probe(struct spi_device *spi) @@ -429,6 +437,9 @@ static struct spi_driver ad193x_spi_driver = { static const struct regmap_config ad193x_i2c_regmap_config = { .val_bits = 8, .reg_bits = 8, + + .max_register = AD193X_NUM_REGS - 1, + .volatile_reg = adau193x_reg_volatile, };
static const struct i2c_device_id ad193x_id[] = {
On Mon, Nov 28, 2011 at 05:28:06PM +0100, Lars-Peter Clausen wrote:
Signed-off-by: Lars-Peter Clausen lars@metafoo.de
Applied all, thanks.
participants (3)
-
Lars-Peter Clausen
-
Mark Brown
-
Mike Frysinger