summaryrefslogtreecommitdiff
path: root/sound/soc/codecs/vt1603.c
diff options
context:
space:
mode:
authorManish Patel2015-01-11 18:44:07 +0530
committerSrikant Patnaik2015-01-11 20:08:35 +0530
commitddd6804ba90290b66ebff05b99752fcdd75fec45 (patch)
treec9baf51431d256461575621ed851f4e4752b3d78 /sound/soc/codecs/vt1603.c
parentabc18728f7736823a28540346129bbeafb3b5866 (diff)
downloadFOSSEE-netbook-kernel-source-ddd6804ba90290b66ebff05b99752fcdd75fec45.tar.gz
FOSSEE-netbook-kernel-source-ddd6804ba90290b66ebff05b99752fcdd75fec45.tar.bz2
FOSSEE-netbook-kernel-source-ddd6804ba90290b66ebff05b99752fcdd75fec45.zip
Fix audio routing issue between speaker and headphone
Signed-off-by: Manish Patel <manish.patel@xzadium.com>
Diffstat (limited to 'sound/soc/codecs/vt1603.c')
-rwxr-xr-xsound/soc/codecs/vt1603.c103
1 files changed, 91 insertions, 12 deletions
diff --git a/sound/soc/codecs/vt1603.c b/sound/soc/codecs/vt1603.c
index eaa3d28e..3df20e54 100755
--- a/sound/soc/codecs/vt1603.c
+++ b/sound/soc/codecs/vt1603.c
@@ -160,43 +160,122 @@ static unsigned int vt1603_hw_read(struct snd_soc_codec *codec,
/*----------------------IRQ handle Functions----------------------------*/
+static int vt1603_hp_power_up(struct snd_soc_codec *codec)
+{
+ u16 reg;
+
+ /* disable mono mixing */
+ reg = snd_soc_read(codec, VT1603_R0d);
+ reg &= ~BIT4;
+ snd_soc_write(codec, VT1603_R0d, reg);
+
+ /* make sure DAC R channel is enable */
+ reg = snd_soc_read(codec, VT1603_R62);
+ reg |= BIT4;
+ snd_soc_write(codec, VT1603_R62, reg);
+
+ // set HP power up
+ reg = snd_soc_read(codec, VT1603_R68);
+ reg &= ~BIT4;
+ snd_soc_write(codec, VT1603_R68, reg);
+
+ return 0;
+}
+
+static int vt1603_classd_power_up(struct snd_soc_codec *codec)
+{
+ u16 reg;
+
+ // set class-d power up
+ reg = snd_soc_read(codec, VT1603_R25);
+ reg |= BIT1;
+ snd_soc_write(codec, VT1603_R25, reg);
+
+ return 0;
+}
+
+static int vt1603_hp_power_off(struct snd_soc_codec *codec)
+{
+ u16 reg;
+
+ // set HP power off
+ reg = snd_soc_read(codec, VT1603_R68);
+ reg |= BIT4;
+ snd_soc_write(codec, VT1603_R68, reg);
+
+ return 0;
+}
+
+static int vt1603_classd_power_off(struct snd_soc_codec *codec)
+{
+ u16 reg;
+
+ // set class-d power off
+ reg = snd_soc_read(codec, VT1603_R25);
+ reg &= ~BIT1;
+ snd_soc_write(codec, VT1603_R25, reg);
+
+ return 0;
+}
+static void vt1603_switch_to_hp(struct snd_soc_codec *codec)
+{
+ u16 reg;
+
+ vt1603_classd_power_off(codec);
+
+ if (codec->card->rtd->codec_dai->playback_active == 1)
+ vt1603_hp_power_up(codec);
+}
+
+static void vt1603_switch_to_classd(struct snd_soc_codec *codec)
+{
+ u16 reg;
+
+ vt1603_hp_power_off(codec);
+
+ if (codec->card->rtd->codec_dai->playback_active == 1)
+ vt1603_classd_power_up(codec);
+}
+
static void vt1603_set_switch_state(struct snd_soc_codec *codec)
{
- /* Just report hp state, don't switch hw device, app will handle it. */
-
struct vt1603_priv *vt1603 = snd_soc_codec_get_drvdata(codec);
unsigned int val = vt1603_hw_read(codec, VT1603_R21);
if (vt1603_boardinfo.hp_level) {
if (val & BIT1) {
- val &= ~BIT1;
- snd_soc_write(codec, VT1603_R21, val);
if (!vt1603_boardinfo.ignore_hp_event)
switch_set_state(&vt1603->hp_switch, 0);
- pr_info("<<<vt1603: hp out!\n");
+ val &= ~BIT1;
+ snd_soc_write(codec, VT1603_R21, val);
+ pr_info("<<<vt1603: hp out!\n");
+ vt1603_switch_to_classd(codec);
}
else {
- val |= BIT1;
- snd_soc_write(codec, VT1603_R21, val);
if (!vt1603_boardinfo.ignore_hp_event)
switch_set_state(&vt1603->hp_switch, 1);
+ val |= BIT1;
+ snd_soc_write(codec, VT1603_R21, val);
pr_info("<<<vt1603: hp in!\n");
+ vt1603_switch_to_hp(codec);
}
}
else {
if (val & BIT1) {
- val &= ~BIT1;
- snd_soc_write(codec, VT1603_R21, val);
if (!vt1603_boardinfo.ignore_hp_event)
switch_set_state(&vt1603->hp_switch, 1);
+ val &= ~BIT1;
+ snd_soc_write(codec, VT1603_R21, val);
pr_info("<<<vt1603: hp in!\n");
+ vt1603_switch_to_hp(codec);
}
else {
- val |= BIT1;
- snd_soc_write(codec, VT1603_R21, val);
if (!vt1603_boardinfo.ignore_hp_event)
switch_set_state(&vt1603->hp_switch, 0);
- pr_info("<<<vt1603: hp out!\n");
+ val |= BIT1;
+ snd_soc_write(codec, VT1603_R21, val);
+ pr_info("<<<vt1603: hp out!\n");
+ vt1603_switch_to_classd(codec);
}
}
}