Skip to content

Commit

Permalink
Fix: ac101 stereo widgets get/put interface
Browse files Browse the repository at this point in the history
  • Loading branch information
turmary committed Feb 27, 2018
1 parent 00d1238 commit 2f31ac4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
53 changes: 33 additions & 20 deletions ac101.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,15 @@ static int snd_ac101_get_volsw(struct snd_kcontrol *kcontrol,
ucontrol->value.integer.value[0] =
mc->max - ucontrol->value.integer.value[0];
}

if (snd_soc_volsw_is_stereo(mc)) {
val = (ret >> mc->rshift) & mask;
ucontrol->value.integer.value[1] = val - mc->min;
if (invert) {
ucontrol->value.integer.value[1] =
mc->max - ucontrol->value.integer.value[1];
}
}
return 0;
}

Expand Down Expand Up @@ -379,10 +388,17 @@ static int snd_ac101_put_volsw(struct snd_kcontrol *kcontrol,
val = mc->max - val;
}

mask = mask << mc->shift;
val = val << mc->shift;
ret = ac101_update_bits(static_ac10x->codec, mc->reg, mask << mc->shift, val << mc->shift);

if (! snd_soc_volsw_is_stereo(mc)) {
return ret;
}
val = ((ucontrol->value.integer.value[1] + mc->min) & mask);
if (invert) {
val = mc->max - val;
}

ret = ac101_update_bits(static_ac10x->codec, mc->reg, mask, val);
ret = ac101_update_bits(static_ac10x->codec, mc->reg, mask << mc->rshift, val << mc->rshift);
return ret;
}

Expand Down Expand Up @@ -695,22 +711,6 @@ int ac101_hw_params(struct snd_pcm_substream *substream,
return 0;
}

#if 0
static int ac101_set_dai_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir)
{
struct snd_soc_codec *codec = codec_dai->codec;
struct ac10x_priv *ac10x = snd_soc_codec_get_drvdata(codec);

AC101_DBG("%s,line:%d, id=%d freq=%d, dir=%d\n", __func__, __LINE__,
clk_id, freq, dir);

ac10x->sysclk = freq;

return 0;
}
#endif

int ac101_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
{
int reg_val;
Expand Down Expand Up @@ -820,6 +820,20 @@ static int ac101_set_clock(int y_start_n_stop) {
#endif

#if 0
static int ac101_set_dai_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir)
{
struct snd_soc_codec *codec = codec_dai->codec;
struct ac10x_priv *ac10x = snd_soc_codec_get_drvdata(codec);

AC101_DBG("%s,line:%d, id=%d freq=%d, dir=%d\n", __func__, __LINE__,
clk_id, freq, dir);

ac10x->sysclk = freq;

return 0;
}

static int ac101_trigger(struct snd_pcm_substream *substream, int cmd,
struct snd_soc_dai *dai)
{
Expand Down Expand Up @@ -936,7 +950,6 @@ int ac101_codec_probe(struct snd_soc_codec *codec)
ac10x->aif1_clken = 0;
ac10x->aif2_clken = 0;
mutex_init(&ac10x->dac_mutex);
mutex_init(&ac10x->adc_mutex);
mutex_init(&ac10x->aifclk_mutex);

#if _MASTER_MULTI_CODEC == _MASTER_AC101
Expand Down
1 change: 0 additions & 1 deletion ac10x.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ struct ac10x_priv {
struct regmap* regmap101;

struct mutex dac_mutex;
struct mutex adc_mutex;
u8 dac_enable;
struct mutex aifclk_mutex;
u8 aif1_clken;
Expand Down
1 change: 0 additions & 1 deletion seeed-8mic-voicecard-overlay.dts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@

simple-audio-card,dai-link@0 {
format = "dsp_a";
/* below is dummy master, real clock master is ac101 */
bitclock-master = <&codec0_dai>;
frame-master = <&codec0_dai>;
/* bitclock-inversion; */
Expand Down

0 comments on commit 2f31ac4

Please sign in to comment.