From 5b586a0fd2ddf9aab90298b9d01c908da04afbb4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=AE=8B=E7=A7=80=E6=9D=B0?= Date: Thu, 23 Aug 2012 21:37:14 +0800 Subject: [PATCH] phonepad: add modem input control function. --- sound/soc/codecs/rt3261.c | 40 ++++++++++++++++++++++++++++++++++++++- sound/soc/codecs/rt3261.h | 2 ++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt3261.c b/sound/soc/codecs/rt3261.c index 59cd3e484c0b..0f38bf18a5a6 100644 --- a/sound/soc/codecs/rt3261.c +++ b/sound/soc/codecs/rt3261.c @@ -62,6 +62,9 @@ static struct snd_soc_codec *rt3261_codec; #define VERSION "RT3261_V1.0.0" +extern void rt5623_on(void); +extern void rt5623_off(void); + struct rt3261_init_reg { u8 reg; u16 val; @@ -709,7 +712,6 @@ static int rt3261_hp_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - unsigned int i,j,k; if(ucontrol->value.integer.value[0]) { /* headphone unmute sequence */ @@ -763,6 +765,33 @@ static int rt3261_hp_mute_put(struct snd_kcontrol *kcontrol, return 0; } +static int rt3261_modem_input_switch_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct rt3261_priv *rt3261 = snd_soc_codec_get_drvdata(codec); + + ucontrol->value.integer.value[0] = rt3261->modem_is_open; + return 0; +} + +static int rt3261_modem_input_switch_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct rt3261_priv *rt3261 = snd_soc_codec_get_drvdata(codec); + + if(ucontrol->value.integer.value[0]) { + rt5623_on( ); + rt3261->modem_is_open = 1; + }else { + rt5623_off( ); + rt3261->modem_is_open = 0; + } + + return 0; +} + /* IN1/IN2 Input Type */ static const char *rt3261_input_mode[] = { "Single ended", "Differential"}; @@ -822,6 +851,10 @@ static const char *rt3261_hp_mute_mode[] = {"off", "on",}; static const SOC_ENUM_SINGLE_DECL(rt3261_hp_mute_enum, 0, 0, rt3261_hp_mute_mode); +static const char *rt3261_modem_input_switch_mode[] = {"off", "on",}; + +static const SOC_ENUM_SINGLE_DECL(rt3261_modem_input_switch_enum, 0, 0, rt3261_modem_input_switch_mode); + #ifdef RT3261_REG_RW #define REGVAL_MAX 0xffff static unsigned int regctl_addr; @@ -976,6 +1009,9 @@ static const struct snd_kcontrol_new rt3261_snd_controls[] = { SOC_ENUM_EXT("HP mute Switch", rt3261_hp_mute_enum, rt3261_hp_mute_get, rt3261_hp_mute_put), + + SOC_ENUM_EXT("Modem Input Switch", rt3261_modem_input_switch_enum, + rt3261_modem_input_switch_get, rt3261_modem_input_switch_put), }; /** @@ -3079,6 +3115,8 @@ static int __devinit rt3261_i2c_probe(struct i2c_client *i2c, if(rt3261->io_init) rt3261->io_init(pdata->codec_en_gpio, pdata->codec_en_gpio_info.iomux_name, pdata->codec_en_gpio_info.iomux_mode); + rt3261->modem_is_open = 0; + i2c_set_clientdata(i2c, rt3261); DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt3261, diff --git a/sound/soc/codecs/rt3261.h b/sound/soc/codecs/rt3261.h index 8f9741869838..b72589f2f747 100644 --- a/sound/soc/codecs/rt3261.h +++ b/sound/soc/codecs/rt3261.h @@ -2143,6 +2143,8 @@ struct rt3261_priv { unsigned int codec_en_gpio; int (*io_init)(int gpio, char *iomux_name, int iomux_mode); + + unsigned int modem_is_open; }; int rt3261_conn_mux_path(struct snd_soc_codec *codec, -- 2.34.1