Hi Arjan,

To make Bluetooth HSP profile work, we need some workarounds in
intel_sst, e.g. bypass the enabling of audio port, yield the I2S bus so
that bluetooth chip can take it over. Because we use the same I2S port
for audio codec and bluetooth chip under the hood.

Could you please take some review and put these into your MRST patchset?

I've tested these two patches and it works as expected.

-- 
guanqun
>From b0064cf74706faca7acbd8dacfdd1037a83d7b7a Mon Sep 17 00:00:00 2001
From: Lu Guanqun <guanqun...@intel.com>
Date: Wed, 22 Jun 2011 07:01:18 +0800
Subject: [PATCH 1/2] sst: add another meaning for device_route to bypass the 
preparation and activation

When we call SNDRV_SST_SET_TARGET_DEVICE ioctl, sometimes we only need to
change the sample rate and leave other stuff untouched, we don't need PMIC to
do the preparation and activation.  For these cases, we can pass number 3
instead of number 0. I admit that's kind of hack.

Signed-off-by: Lu Guanqun <guanqun...@intel.com>
---
 .../staging/intel_sst/intel_sst_stream_encoded.c   |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/intel_sst/intel_sst_stream_encoded.c 
b/drivers/staging/intel_sst/intel_sst_stream_encoded.c
index 7db72cc..fab4973 100644
--- a/drivers/staging/intel_sst/intel_sst_stream_encoded.c
+++ b/drivers/staging/intel_sst/intel_sst_stream_encoded.c
@@ -457,9 +457,13 @@ err:
 int sst_target_device_select(struct snd_sst_target_device *target)
 {
        int retval, i, prepare_count = 0;
+       unsigned int orig_device_route = target->device_route;
 
        pr_debug("sst: Target Device Select\n");
 
+       if (target->device_route == 3)
+               target->device_route = 0;
+
        if (target->device_route < 0 || target->device_route > 2) {
                pr_err("sst: device route is invalid\n");
                return -EINVAL;
@@ -476,6 +480,10 @@ int sst_target_device_select(struct snd_sst_target_device 
*target)
        retval = sst_send_target(target);
        if (retval)
                return retval;
+
+       if (orig_device_route == 3)
+               return retval;
+
        for (i = 0; i < SST_MAX_TARGET_DEVICES; i++) {
                if (target->devices[i].action == SND_SST_PORT_ACTIVATE) {
                        pr_debug("sst: activate called in %d\n", i);
-- 
1.7.2.3

>From 22ea27f036a3409843614fa3a9817ea4dda69d8f Mon Sep 17 00:00:00 2001
From: Lu Guanqun <guanqun...@intel.com>
Date: Wed, 22 Jun 2011 07:18:40 +0800
Subject: [PATCH 2/2] sst: add a new ioctl on intel_sst to tristate PMIC 
dynamically

This allows users to tristate PMIC dynamically so that the I2S bus connected
with PMIC will be tristated.  This allows other devices (e.g.  Bluetooth chip)
to drive the I2S bus.

The PMIC register (AUDIOPORT1 - 0x102) is the register to control PCM2 port on
PMIC, setting it to 0x0 will make it slave, tristate on I2S bus. Setting it
to 0x98 will make it back to life.

Signed-off-by: Lu Guanqun <guanqun...@intel.com>
---
 drivers/staging/intel_sst/intel_sst.h              |    1 +
 .../staging/intel_sst/intel_sst_app_interface.c    |    5 +++++
 drivers/staging/intel_sst/intel_sst_ioctl.h        |    1 +
 drivers/staging/intel_sst/intelmid_v2_control.c    |   15 +++++++++++++++
 4 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/intel_sst/intel_sst.h 
b/drivers/staging/intel_sst/intel_sst.h
index d5886c7..58dcf9a 100644
--- a/drivers/staging/intel_sst/intel_sst.h
+++ b/drivers/staging/intel_sst/intel_sst.h
@@ -116,6 +116,7 @@ struct snd_pmic_ops {
        int (*pmic_jack_enable) (void);
        int (*pmic_get_mic_bias)(void *intelmaddata);
        int (*pmic_set_headset_state)(int state);
+       int (*tristate_pmic)(int tristate);
 
        unsigned int hw_dmic_map[MFLD_MAX_HW_CH];
        unsigned int available_dmics;
diff --git a/drivers/staging/intel_sst/intel_sst_app_interface.c 
b/drivers/staging/intel_sst/intel_sst_app_interface.c
index 3357c7d..21eb626 100644
--- a/drivers/staging/intel_sst/intel_sst_app_interface.c
+++ b/drivers/staging/intel_sst/intel_sst_app_interface.c
@@ -1447,6 +1447,11 @@ free_iobufs:
                retval = sst_ioctl_tuning_params(arg);
                break;
 
+       case _IOC_NR(SNDRV_SST_TRISTATE_PMIC):
+               if (sst_drv_ctx->scard_ops->tristate_pmic)
+                       sst_drv_ctx->scard_ops->tristate_pmic(arg);
+               break;
+
        default:
                retval = -EINVAL;
        }
diff --git a/drivers/staging/intel_sst/intel_sst_ioctl.h 
b/drivers/staging/intel_sst/intel_sst_ioctl.h
index 5da5ee0..dec99df 100644
--- a/drivers/staging/intel_sst/intel_sst_ioctl.h
+++ b/drivers/staging/intel_sst/intel_sst_ioctl.h
@@ -436,5 +436,6 @@ struct snd_sst_tuning_params {
 #define SNDRV_SST_SET_ALGO     _IOW('L', 0x30,  struct snd_ppp_params *)
 #define SNDRV_SST_GET_ALGO     _IOWR('L', 0x31,  struct snd_ppp_params *)
 #define SNDRV_SST_TUNING_PARAMS        _IOW('L', 0x32,  struct 
snd_sst_tuning_params *)
+#define SNDRV_SST_TRISTATE_PMIC _IOW('L', 0x33, int)
 
 #endif /* __INTEL_SST_IOCTL_H__ */
diff --git a/drivers/staging/intel_sst/intelmid_v2_control.c 
b/drivers/staging/intel_sst/intelmid_v2_control.c
index b47c887..ad9d494 100644
--- a/drivers/staging/intel_sst/intelmid_v2_control.c
+++ b/drivers/staging/intel_sst/intelmid_v2_control.c
@@ -1146,6 +1146,20 @@ static int nc_jack_enable(void)
        return 0;
 }
 
+static int nc_tristate_pmic(int tristate)
+{
+       struct sc_reg_access sc_access;
+
+       sc_access.reg_addr = AUDIOPORT1;
+       if (tristate)
+               sc_access.value = 0x0;
+       else
+               sc_access.value = 0x98;
+       sc_access.mask = 0x0;
+
+       return sst_sc_reg_access(&sc_access, PMIC_WRITE, 1);
+}
+
 struct snd_pmic_ops snd_pmic_ops_nc = {
        .input_dev_id   =       DMIC,
        .output_dev_id  =       INTERNAL_SPKR,
@@ -1167,4 +1181,5 @@ struct snd_pmic_ops snd_pmic_ops_nc = {
        .power_down_pmic        =       nc_power_down,
        .pmic_irq_cb    =       nc_pmic_irq_cb,
        .pmic_jack_enable =     nc_jack_enable,
+       .tristate_pmic =        nc_tristate_pmic,
 };
-- 
1.7.2.3

_______________________________________________
MeeGo-kernel mailing list
MeeGo-kernel@lists.meego.com
http://lists.meego.com/listinfo/meego-kernel

Reply via email to