* [PATCH 1/2] ASoC: cs4271: switch to mute_stream
@ 2013-03-15 5:35 Daniel Mack
2013-03-15 5:35 ` [PATCH 2/2] ASoC: cs4271: preserve "Master Playback Switch" setting Daniel Mack
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Mack @ 2013-03-15 5:35 UTC (permalink / raw)
To: alsa-devel; +Cc: broonie, subaparts, lgirdwood, Daniel Mack
Use the newly introduced mute_stream DAI operation, and don't mute the
codec if it's called for the _CAPTURE stream.
Signed-off-by: Daniel Mack <zonque@gmail.com>
---
sound/soc/codecs/cs4271.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c
index ac0d3b4..03036b3 100644
--- a/sound/soc/codecs/cs4271.c
+++ b/sound/soc/codecs/cs4271.c
@@ -388,7 +388,7 @@ static int cs4271_hw_params(struct snd_pcm_substream *substream,
return cs4271_set_deemph(codec);
}
-static int cs4271_digital_mute(struct snd_soc_dai *dai, int mute)
+static int cs4271_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
{
struct snd_soc_codec *codec = dai->codec;
struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec);
@@ -396,6 +396,9 @@ static int cs4271_digital_mute(struct snd_soc_dai *dai, int mute)
int val_a = 0;
int val_b = 0;
+ if (stream != SNDRV_PCM_STREAM_PLAYBACK)
+ return 0;
+
if (mute) {
val_a = CS4271_VOLA_MUTE;
val_b = CS4271_VOLB_MUTE;
@@ -442,7 +445,7 @@ static const struct snd_soc_dai_ops cs4271_dai_ops = {
.hw_params = cs4271_hw_params,
.set_sysclk = cs4271_set_dai_sysclk,
.set_fmt = cs4271_set_dai_fmt,
- .digital_mute = cs4271_digital_mute,
+ .mute_stream = cs4271_mute_stream,
};
static struct snd_soc_dai_driver cs4271_dai = {
--
1.8.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] ASoC: cs4271: preserve "Master Playback Switch" setting
2013-03-15 5:35 [PATCH 1/2] ASoC: cs4271: switch to mute_stream Daniel Mack
@ 2013-03-15 5:35 ` Daniel Mack
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Mack @ 2013-03-15 5:35 UTC (permalink / raw)
To: alsa-devel; +Cc: broonie, subaparts, lgirdwood, Daniel Mack
Currently, both the ALSA control for "Digital Master Playback Switch"
and the ALSA core (by calling dai_ops->mute_stream()) control the same
bits in the CS4271_VOL[AB]_MUTE registers.
That's a problem for applications which intentionally want to keep the
flag switched off from userspace, even though the stream is already
playing.
Fix this by keeping track of the states on both sides - the ALSA
control and the ASoC core - and actually mute the Codec if either one
of the two flags is set.
Signed-off-by: Daniel Mack <zonque@gmail.com>
Reported-by: Michael Hirsch <m.hirsch@raumfeld.com>
---
sound/soc/codecs/cs4271.c | 74 +++++++++++++++++++++++++++++++++--------------
1 file changed, 53 insertions(+), 21 deletions(-)
diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c
index 03036b3..3a2ab48 100644
--- a/sound/soc/codecs/cs4271.c
+++ b/sound/soc/codecs/cs4271.c
@@ -171,6 +171,9 @@ struct cs4271_private {
int gpio_disable;
/* enable soft reset workaround */
bool enable_soft_reset;
+ /* keep track of playback mute flags */
+ bool mute_control;
+ bool digital_mute;
};
/*
@@ -281,6 +284,51 @@ static int cs4271_put_deemph(struct snd_kcontrol *kcontrol,
return cs4271_set_deemph(codec);
}
+static int cs4271_set_mute(struct snd_soc_codec *codec)
+{
+ struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec);
+ int val_a = 0;
+ int val_b = 0;
+ int ret;
+
+ if (cs4271->digital_mute || cs4271->mute_control) {
+ val_a = CS4271_VOLA_MUTE;
+ val_b = CS4271_VOLB_MUTE;
+ }
+
+ ret = regmap_update_bits(cs4271->regmap, CS4271_VOLA,
+ CS4271_VOLA_MUTE, val_a);
+ if (ret < 0)
+ return ret;
+
+ ret = regmap_update_bits(cs4271->regmap, CS4271_VOLB,
+ CS4271_VOLB_MUTE, val_b);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static int cs4271_get_playback_switch(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+ struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec);
+
+ ucontrol->value.enumerated.item[0] = !cs4271->mute_control;
+ return 0;
+}
+
+static int cs4271_put_playback_switch(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+ struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec);
+
+ cs4271->mute_control = !ucontrol->value.enumerated.item[0];
+ return cs4271_set_mute(codec);
+}
+
struct cs4271_clk_cfg {
bool master; /* codec mode */
u8 speed_mode; /* codec speed mode: 1x, 2x, 4x */
@@ -392,28 +440,12 @@ static int cs4271_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
{
struct snd_soc_codec *codec = dai->codec;
struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec);
- int ret;
- int val_a = 0;
- int val_b = 0;
- if (stream != SNDRV_PCM_STREAM_PLAYBACK)
- return 0;
-
- if (mute) {
- val_a = CS4271_VOLA_MUTE;
- val_b = CS4271_VOLB_MUTE;
+ if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ cs4271->digital_mute = mute;
+ return cs4271_set_mute(codec);
}
- ret = regmap_update_bits(cs4271->regmap, CS4271_VOLA,
- CS4271_VOLA_MUTE, val_a);
- if (ret < 0)
- return ret;
-
- ret = regmap_update_bits(cs4271->regmap, CS4271_VOLB,
- CS4271_VOLB_MUTE, val_b);
- if (ret < 0)
- return ret;
-
return 0;
}
@@ -437,8 +469,8 @@ static const struct snd_kcontrol_new cs4271_snd_controls[] = {
SOC_DOUBLE("Master Capture Switch", CS4271_ADCCTL, 3, 2, 1, 1),
SOC_SINGLE("Dither 16-Bit Data Switch", CS4271_ADCCTL, 5, 1, 0),
SOC_DOUBLE("High Pass Filter Switch", CS4271_ADCCTL, 1, 0, 1, 1),
- SOC_DOUBLE_R("Master Playback Switch", CS4271_VOLA, CS4271_VOLB,
- 7, 1, 1),
+ SOC_SINGLE_BOOL_EXT("Master Playback Switch", 0,
+ cs4271_get_playback_switch, cs4271_put_playback_switch),
};
static const struct snd_soc_dai_ops cs4271_dai_ops = {
--
1.8.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-03-15 5:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-15 5:35 [PATCH 1/2] ASoC: cs4271: switch to mute_stream Daniel Mack
2013-03-15 5:35 ` [PATCH 2/2] ASoC: cs4271: preserve "Master Playback Switch" setting Daniel Mack
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).