phonepad: add modem input control function.
author宋秀杰 <sxj@rock-chips.com>
Thu, 23 Aug 2012 13:37:14 +0000 (21:37 +0800)
committer宋秀杰 <sxj@rock-chips.com>
Thu, 23 Aug 2012 13:37:14 +0000 (21:37 +0800)
sound/soc/codecs/rt3261.c
sound/soc/codecs/rt3261.h

index 59cd3e484c0ba436dc9ea11c1c7800abee574369..0f38bf18a5a672614ecea81c6a7499033ecc1b6d 100644 (file)
@@ -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,
index 8f9741869838d1e3b5084a57993baaa1a795c7bd..b72589f2f7479bf27815eb2c555c6f2bd26ed8df 100644 (file)
@@ -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,