On Moorestown platform, internal speaker's power line is connected to a GPIO
line, so we need to enable or disable it properly.

CC: "Koul, Vinod" <[email protected]>
CC: "Kp, Jeeja" <[email protected]>
Reviewed-by: Wu Fengguang <[email protected]>
Signed-off-by: Jeff Cheng <[email protected]>
Signed-off-by: Lu Guanqun <[email protected]>
Signed-off-by: Wang Xingchao <[email protected]>
---
 drivers/staging/intel_sst/intel_sst.h           |    2 +
 drivers/staging/intel_sst/intelmid.c            |   10 +++++++++
 drivers/staging/intel_sst/intelmid_v2_control.c |   25 ++++++++++++++++++++++-
 3 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/intel_sst/intel_sst.h 
b/drivers/staging/intel_sst/intel_sst.h
index 986a3df..635cf58 100644
--- a/drivers/staging/intel_sst/intel_sst.h
+++ b/drivers/staging/intel_sst/intel_sst.h
@@ -120,6 +120,8 @@ struct snd_pmic_ops {
        unsigned int hw_dmic_map[MFLD_MAX_HW_CH];
        unsigned int available_dmics;
        int (*set_hw_dmic_route) (u8 index);
+
+       int gpio_amp;
 };
 
 extern void sst_mad_send_jack_report(struct snd_jack *jack,
diff --git a/drivers/staging/intel_sst/intelmid.c 
b/drivers/staging/intel_sst/intelmid.c
index 3071904..17f912d 100644
--- a/drivers/staging/intel_sst/intelmid.c
+++ b/drivers/staging/intel_sst/intelmid.c
@@ -36,6 +36,7 @@
 #include <sound/jack.h>
 #include <sound/pcm_params.h>
 #include <sound/initval.h>
+#include <linux/gpio.h>
 #include "intel_sst.h"
 #include "intel_sst_ioctl.h"
 #include "intelmid_snd_control.h"
@@ -918,6 +919,13 @@ int __devinit snd_intelmad_probe(struct platform_device 
*pdev)
                goto set_pvt_data;;
        }
 
+       if (pdev->dev.platform_data) {
+               int gpio_amp = *(int *)pdev->dev.platform_data;
+               if (gpio_request_one(gpio_amp, GPIOF_OUT_INIT_LOW, "amp power"))
+                       gpio_amp = 0;
+               intelmaddata->sstdrv_ops->scard_ops->gpio_amp = gpio_amp;
+       }
+
        pr_debug("sst:snd_intelmad_probe complete\n");
        return ret_val;
 
@@ -945,6 +953,8 @@ static int snd_intelmad_remove(struct platform_device *pdev)
        struct snd_intelmad *intelmaddata = platform_get_drvdata(pdev);
 
        if (intelmaddata) {
+               if (intelmaddata->sstdrv_ops->scard_ops->gpio_amp)
+                       
gpio_free(intelmaddata->sstdrv_ops->scard_ops->gpio_amp);
                free_irq(intelmaddata->irq, intelmaddata);
                snd_card_free(intelmaddata->card);
        }
diff --git a/drivers/staging/intel_sst/intelmid_v2_control.c 
b/drivers/staging/intel_sst/intelmid_v2_control.c
index a7ab432..5048684 100644
--- a/drivers/staging/intel_sst/intelmid_v2_control.c
+++ b/drivers/staging/intel_sst/intelmid_v2_control.c
@@ -26,6 +26,7 @@
  *  This file contains the control operations of vendor 3
  */
 
+#include <linux/gpio.h>
 #include <linux/pci.h>
 #include <linux/file.h>
 #include <sound/control.h>
@@ -84,6 +85,12 @@ enum reg_v3 {
        AUXDBNC = 0x12f,
 };
 
+static void nc_set_amp_power(int power)
+{
+       if (snd_pmic_ops_nc.gpio_amp)
+               gpio_set_value(snd_pmic_ops_nc.gpio_amp, power);
+}
+
 /****
  * nc_init_card - initilize the sound card
  *
@@ -210,6 +217,16 @@ static int nc_power_up_pb(unsigned int port)
 
        msleep(30);
 
+       /*
+        * There is a mismatch between Playback Sources and the enumerated
+        * values of output sources.  This mismatch causes ALSA upper to send
+        * Item 1 for Internal Speaker, but the expected enumeration is 2!  For
+        * now, treat MONO_EARPIECE and INTERNAL_SPKR identically and power up
+        * the needed resources
+        */
+       if (snd_pmic_ops_nc.output_dev_id == MONO_EARPIECE ||
+           snd_pmic_ops_nc.output_dev_id == INTERNAL_SPKR)
+               nc_set_amp_power(1);
        return nc_enable_audiodac(UNMUTE);
 
 }
@@ -271,7 +288,6 @@ static int nc_power_down(void)
        int retval = 0;
        struct sc_reg_access sc_access[5];
 
-
        if (snd_pmic_ops_nc.card_status == SND_CARD_UN_INIT)
                retval = nc_init_card();
        if (retval)
@@ -281,6 +297,10 @@ static int nc_power_down(void)
 
        pr_debug("sst: powering dn nc_power_down ....\n");
 
+       if (snd_pmic_ops_nc.output_dev_id == MONO_EARPIECE ||
+           snd_pmic_ops_nc.output_dev_id == INTERNAL_SPKR)
+               nc_set_amp_power(0);
+
        msleep(30);
 
        sc_access[0].reg_addr = DRVPOWERCTRL;
@@ -516,9 +536,12 @@ static int nc_set_selected_output_dev(u8 value)
        switch (value) {
        case STEREO_HEADPHONE:
                retval = sst_sc_reg_access(sc_access_HP, PMIC_WRITE, 2);
+               nc_set_amp_power(0);
                break;
+       case MONO_EARPIECE:
        case INTERNAL_SPKR:
                retval = sst_sc_reg_access(sc_access_IS, PMIC_WRITE, 2);
+               nc_set_amp_power(1);
                break;
        default:
                pr_err("sst: rcvd illegal request: %d\n", value);
-- 
1.7.2.3

_______________________________________________
MeeGo-kernel mailing list
[email protected]
http://lists.meego.com/listinfo/meego-kernel

Reply via email to