1 From bdf67add80855689e7580feaa8ae1c82d2f9d209 Mon Sep 17 00:00:00 2001
2 From: Jan Grulich <jan@grulich.eu>
3 Date: Mon, 24 Aug 2015 16:02:34 +0100
4 Subject: [PATCH 085/304] tpa6130a2: Add headphone switch control
6 Signed-off-by: Jan Grulich <jan@grulich.eu>
8 sound/soc/codecs/tpa6130a2.c | 29 ++++++++++++++++++++++++++---
9 1 file changed, 26 insertions(+), 3 deletions(-)
11 --- a/sound/soc/codecs/tpa6130a2.c
12 +++ b/sound/soc/codecs/tpa6130a2.c
14 * Copyright (C) Nokia Corporation
16 * Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
17 + * Modified: Jan Grulich <jan@grulich.eu>
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 @@ -52,6 +53,8 @@ struct tpa6130a2_data {
25 +static void tpa6130a2_channel_enable(u8 channel, int enable);
27 static int tpa6130a2_i2c_read(int reg)
29 struct tpa6130a2_data *data;
30 @@ -189,7 +192,7 @@ exit:
33 static int tpa6130a2_get_volsw(struct snd_kcontrol *kcontrol,
34 - struct snd_ctl_elem_value *ucontrol)
35 + struct snd_ctl_elem_value *ucontrol)
37 struct soc_mixer_control *mc =
38 (struct soc_mixer_control *)kcontrol->private_value;
39 @@ -218,7 +221,7 @@ static int tpa6130a2_get_volsw(struct sn
42 static int tpa6130a2_put_volsw(struct snd_kcontrol *kcontrol,
43 - struct snd_ctl_elem_value *ucontrol)
44 + struct snd_ctl_elem_value *ucontrol)
46 struct soc_mixer_control *mc =
47 (struct soc_mixer_control *)kcontrol->private_value;
48 @@ -255,8 +258,22 @@ static int tpa6130a2_put_volsw(struct sn
52 +static int tpa6130a2_put_hp_sw(struct snd_kcontrol *kcontrol,
53 + struct snd_ctl_elem_value *ucontrol)
55 + int enable = ucontrol->value.integer.value[0];
58 + state = (tpa6130a2_read(TPA6130A2_REG_VOL_MUTE) & 0x80) == 0;
59 + if (state == enable)
60 + return 0; /* No change */
62 + tpa6130a2_channel_enable(TPA6130A2_HP_EN_R | TPA6130A2_HP_EN_L, enable);
63 + return 1; /* Changed */
67 - * TPA6130 volume. From -59.5 to 4 dB with increasing step size when going
68 + * TPA6130 volume. From -59.5 to +4.0 dB with increasing step size when going
71 static const DECLARE_TLV_DB_RANGE(tpa6130_tlv,
72 @@ -277,6 +294,9 @@ static const struct snd_kcontrol_new tpa
73 TPA6130A2_REG_VOL_MUTE, 0, 0x3f, 0,
74 tpa6130a2_get_volsw, tpa6130a2_put_volsw,
76 + SOC_SINGLE_EXT("TPA6130A2 Headphone Playback Switch",
77 + TPA6130A2_REG_VOL_MUTE, 7, 1, 1,
78 + tpa6130a2_get_volsw, tpa6130a2_put_hp_sw),
81 static const DECLARE_TLV_DB_RANGE(tpa6140_tlv,
82 @@ -290,6 +310,9 @@ static const struct snd_kcontrol_new tpa
83 TPA6130A2_REG_VOL_MUTE, 1, 0x1f, 0,
84 tpa6130a2_get_volsw, tpa6130a2_put_volsw,
86 + SOC_SINGLE_EXT("TPA6140A2 Headphone Playback Switch",
87 + TPA6130A2_REG_VOL_MUTE, 7, 1, 1,
88 + tpa6130a2_get_volsw, tpa6130a2_put_hp_sw),