From: Ramesh Babu K V <[email protected]>

This patch support detection of american headeset.
Type of headset is detected based on mic bias voltage
level.

Signed-off-by: Dharageswari R <[email protected]>
Signed-off-by: Ramesh Babu K V <[email protected]>
---
 sound/pci/sst/intel_sst_common.h      |    4 +-
 sound/pci/sst/intelmid_msic_control.c |   39 ++++++++++++++++++++++----------
 2 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/sound/pci/sst/intel_sst_common.h b/sound/pci/sst/intel_sst_common.h
index 67a1350..51e15bb 100644
--- a/sound/pci/sst/intel_sst_common.h
+++ b/sound/pci/sst/intel_sst_common.h
@@ -28,8 +28,8 @@
  *  Common private declarations for SST
  */
 
-#define SST_DRIVER_VERSION "1.2.15"
-#define SST_VERSION_NUM 0x1215
+#define SST_DRIVER_VERSION "1.2.17"
+#define SST_VERSION_NUM 0x1217
 
 /* driver names */
 #define SST_DRV_NAME "intel_sst_driver"
diff --git a/sound/pci/sst/intelmid_msic_control.c 
b/sound/pci/sst/intelmid_msic_control.c
index 5747da5..146b53d 100644
--- a/sound/pci/sst/intelmid_msic_control.c
+++ b/sound/pci/sst/intelmid_msic_control.c
@@ -31,7 +31,6 @@
 #include <linux/input.h>
 #include "intelmid_snd_control.h"
 #include "intelmid.h"
-
 #define AUDIOMUX12  0x24c
 #define AUDIOMUX34  0x24d
 
@@ -341,11 +340,12 @@ static int msic_power_up_pb(unsigned int device)
        };
        struct sc_reg_access vhs[] = {
                /*  VHSP */
-               {0x0DC, 0xFF, 0},
+               {0x0DC, 0x3D, 0},
                /*  VHSN */
                {0x0DD, 0x3F, 0},
        };
        struct sc_reg_access hsdac[] = {
+               {0x382, 0x40, 0x40},
                /*  disable driver */
                {0x25D, 0x0, 0x43},
                /* DAC CONFIG ; both HP, LP on */
@@ -409,9 +409,9 @@ static int msic_power_up_pb(unsigned int device)
                {0x26A, 0x02, 0x82},
        };
        struct sc_reg_access pcm2_en[] = {
-               /* enable pcm 2 */
                {0x27C, 0x1, 0x1},
        };
+
        int retval = 0;
 
        if (snd_msic_ops.card_status == SND_CARD_UN_INIT) {
@@ -431,7 +431,7 @@ static int msic_power_up_pb(unsigned int device)
                snd_msic_ops.pbhs_on = 1;
                if (snd_msic_ops.output_dev_id == STEREO_HEADPHONE) {
                        sst_sc_reg_access(vhs, PMIC_WRITE, 2);
-                       sst_sc_reg_access(hsdac, PMIC_READ_MODIFY, 2);
+                       sst_sc_reg_access(hsdac, PMIC_READ_MODIFY, 3);
                        sst_sc_reg_access(hs_filter, PMIC_WRITE, 2);
                        sst_sc_reg_access(hs_enable, PMIC_READ_MODIFY, 4);
                } else {
@@ -585,6 +585,7 @@ static int msic_power_down_pb(unsigned int device)
        struct sc_reg_access hs_off[] = {
                {0x257, 0x00, 0x03},
                {0x250, 0x00, 0x30},
+               {0x382, 0x00, 0x40},
        };
        struct sc_reg_access ihf_mute[] = {
                {0x25B, 0x80, 0x80},
@@ -616,7 +617,7 @@ static int msic_power_down_pb(unsigned int device)
                sst_sc_reg_access(hs_mute, PMIC_READ_MODIFY, 3);
                drv_enable[0].mask = 0x43;
                sst_sc_reg_access(drv_enable, PMIC_READ_MODIFY, 1);
-               sst_sc_reg_access(hs_off, PMIC_READ_MODIFY, 2);
+               sst_sc_reg_access(hs_off, PMIC_READ_MODIFY, 3);
                if (snd_msic_ops.lineout_dev_id == HEADSET)
                        sst_sc_reg_access(lout_off, PMIC_WRITE, 1);
                break;
@@ -648,6 +649,7 @@ static int msic_power_down_pb(unsigned int device)
                        sst_sc_reg_access(lout_off, PMIC_WRITE, 1);
                break;
        }
+
        return 0;
 }
 
@@ -877,24 +879,36 @@ static int msic_enable_jack_btn(void)
        };
        return sst_sc_reg_access(btn_enable, PMIC_WRITE, 2);
 }
-static int msic_convert_adc_to_volt(unsigned int mic_bias)
+static int msic_convert_adc_to_mvolt(unsigned int mic_bias)
 {
        return (ADC_ONE_LSB_MULTIPLIER * mic_bias) / 1000;
 }
-
 int msic_get_headset_state(int mic_bias)
 {
-       if (mic_bias >= 0 && mic_bias < 400)
+       struct sc_reg_access msic_hs_toggle[] = {
+               {0x070, 0x00, 0x01},
+       };
+       if (mic_bias >= 0 && mic_bias < 400) {
+
                pr_debug("sst: Detected Headphone!!!\n");
-       else if (mic_bias > 400 && mic_bias < 700)
-               pr_debug("sst: Detected Other device\n");
-       else if (mic_bias > 700 && mic_bias < 2000) {
+               sst_sc_reg_access(msic_hs_toggle, PMIC_READ_MODIFY, 1);
+
+       } else if (mic_bias > 400 && mic_bias < 650) {
+
+               pr_debug("sst: Detected American headset\n");
+               msic_hs_toggle[0].value = 0x01;
+               sst_sc_reg_access(msic_hs_toggle, PMIC_READ_MODIFY, 1);
+
+       } else if (mic_bias >= 650 && mic_bias < 2000) {
+
                pr_debug("sst: Detected Headset!!!\n");
+               sst_sc_reg_access(msic_hs_toggle, PMIC_READ_MODIFY, 1);
                /*power on jack and btn*/
                snd_msic_ops.jack_interrupt_status = true;
                msic_enable_jack_btn();
                msic_enable_mic_bias();
                return SND_JACK_HEADSET;
+
        } else
                pr_debug("sst: Detected Open Cable!!!\n");
 
@@ -988,7 +1002,8 @@ static void msic_pmic_irq_cb(void *cb_data, u8 intsts)
                buttonpressflag = 0;
                mic_bias = msic_get_mic_bias(intelmaddata);
                pr_debug("sst: mic_bias = %d\n", mic_bias);
-               mic_bias = msic_convert_adc_to_volt(mic_bias);
+               mic_bias = msic_convert_adc_to_mvolt(mic_bias);
+               pr_debug("sst: mic_bias after conversion = %d mV\n", mic_bias);
                mjack->jack_dev_state = msic_get_headset_state(mic_bias);
                mjack->jack.type = present = mjack->jack_dev_state;
        }
-- 
1.6.2.5

Attachment: 0006-sst-american-headset-detection.patch
Description: 0006-sst-american-headset-detection.patch

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

Reply via email to