aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaster K <officiallazerl0rd@gmail.com>2018-06-26 21:48:18 +0200
committerShubh@m <shubhindia123@gmail.com>2019-02-28 22:27:37 +0530
commitcbabd2850108cb40ddc6edce9a237caab2dcca72 (patch)
tree1604bcdbe1091a51bb1e66a473eadc6719336d76
parent84cd6c744915551800950f4d244c3e3aab78286f (diff)
Initial AudioWizard bringup
Ported from Asus ZS551KL kernel source. Change-Id: I1d040d01788b18521d75ecccacf7d38b65cf065a Signed-off-by: Laster K. (lazerl0rd) <officiallazerl0rd@gmail.com>
-rw-r--r--drivers/base/regmap/internal.h4
-rw-r--r--include/sound/audio_calibration.h7
-rw-r--r--include/uapi/linux/msm_audio_calibration.h21
-rw-r--r--sound/soc/codecs/wcd-mbhc-v2.c79
-rw-r--r--sound/soc/codecs/wcd-mbhc-v2.h1
-rw-r--r--sound/soc/codecs/wcd9330.c20
-rw-r--r--sound/soc/msm/qdsp6v2/audio_calibration.c122
7 files changed, 254 insertions, 0 deletions
diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h
index c130536e0ab..bbdc315b75d 100644
--- a/drivers/base/regmap/internal.h
+++ b/drivers/base/regmap/internal.h
@@ -79,6 +79,10 @@ struct regmap {
struct list_head debugfs_off_cache;
struct mutex cache_lock;
#endif
+ //Austin +++
+ struct list_head proc_off_cache;
+ struct mutex proc_cache_lock;
+ //Austin ---
unsigned int max_register;
bool (*writeable_reg)(struct device *dev, unsigned int reg);
diff --git a/include/sound/audio_calibration.h b/include/sound/audio_calibration.h
index 5f6b5e37aa5..1f02f249418 100644
--- a/include/sound/audio_calibration.h
+++ b/include/sound/audio_calibration.h
@@ -34,6 +34,13 @@ struct audio_cal_reg {
struct audio_cal_callbacks callbacks;
};
+/* ASUS_BSP Eric +++ */
+struct headset_imp_val {
+ uint32_t ZL;
+ uint32_t ZR;
+};
+/* ASUS_BSP Eric --- */
+
int audio_cal_register(int num_cal_types, struct audio_cal_reg *reg_data);
int audio_cal_deregister(int num_cal_types, struct audio_cal_reg *reg_data);
diff --git a/include/uapi/linux/msm_audio_calibration.h b/include/uapi/linux/msm_audio_calibration.h
index dfa66636945..199dba2a242 100644
--- a/include/uapi/linux/msm_audio_calibration.h
+++ b/include/uapi/linux/msm_audio_calibration.h
@@ -44,6 +44,20 @@
217, void *)
#define AUDIO_SET_RTAC_AFE_CAL _IOWR(CAL_IOCTL_MAGIC, \
218, void *)
+
+/* ASUS_BSP Paul +++ */
+#define AUDIO_SET_AUDIOWIZARD_FORCE_PRESET _IOWR(CAL_IOCTL_MAGIC, \
+ 221, void *)
+/* ASUS_BSP Paul --- */
+
+/* ASUS_BSP */
+#define AUDIO_GET_HS_IMP _IOWR(CAL_IOCTL_MAGIC, \
+ 230, void *)
+#define AUDIO_SET_MODE _IOWR(CAL_IOCTL_MAGIC, 225, void *)
+extern int get_audiomode(void);
+#define AUDIO_SET_FORMAT _IOWR(CAL_IOCTL_MAGIC, 231, void *)
+extern int get_audioformat(void);
+
enum {
CVP_VOC_RX_TOPOLOGY_CAL_TYPE = 0,
CVP_VOC_TX_TOPOLOGY_CAL_TYPE,
@@ -88,6 +102,13 @@ enum {
AUDIO_CORE_METAINFO_CAL_TYPE,
SRS_TRUMEDIA_CAL_TYPE,
+ /* ASUS_BSP */
+ AUDIOWIZARD_FORCE_PRESET_TYPE,
+ SKYPE_STATE_TYPE,
+ SET_MODE_TYPE,
+ SET_FORMAT_TYPE,
+ GET_IMP_TYPE,
+
MAX_CAL_TYPES,
};
diff --git a/sound/soc/codecs/wcd-mbhc-v2.c b/sound/soc/codecs/wcd-mbhc-v2.c
index 5a36a8df94b..07c1320fd31 100644
--- a/sound/soc/codecs/wcd-mbhc-v2.c
+++ b/sound/soc/codecs/wcd-mbhc-v2.c
@@ -47,6 +47,16 @@
#define FW_READ_TIMEOUT 4000000
#define FAKE_REM_RETRY_ATTEMPTS 3
+/* ASUS_BSP Paul +++ */
+int g_jack_det_invert = 0;
+extern int g_DebugMode;
+/* ASUS_BSP Paul --- */
+
+/* ASUS_BSP Eric +++*/
+uint32_t g_ZL = 0;
+uint32_t g_ZR = 0;
+/* ASUS_BSP Eric ---*/
+
static int det_extn_cable_en;
module_param(det_extn_cable_en, int,
S_IRUGO | S_IWUSR | S_IWGRP);
@@ -514,6 +524,24 @@ static void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion,
if (mbhc->impedance_detect && mbhc->mbhc_cb->compute_impedance){
mbhc->mbhc_cb->compute_impedance(mbhc,
&mbhc->zl, &mbhc->zr);
+
+ /* ASUS_BSP Eric +++*/
+ g_ZL = mbhc->zl;
+ g_ZR = mbhc->zr;
+ printk("wcd_mbhc_v2 : print hs_imp_val : LL = %d , RR = %d\n",g_ZL, g_ZR);
+ /* ASUS_BSP Eric ---*/
+
+ /*if ((mbhc->zl > mbhc->mbhc_cfg->linein_th) &&
+ (mbhc->zr > mbhc->mbhc_cfg->linein_th)) {
+ jack_type = SND_JACK_LINEOUT;
+ mbhc->current_plug = MBHC_PLUG_TYPE_HIGH_HPH;
+ pr_debug("%s: Marking jack type as SND_JACK_LINEOUT\n",
+ __func__);
+ }*/
+ }
+
+ mbhc->hph_status |= jack_type;
+
pr_debug("%s: Reporting insertion %d(%x)\n", __func__,
jack_type, mbhc->hph_status);
wcd_mbhc_jack_report(mbhc, &mbhc->headset_jack,
@@ -1028,6 +1056,11 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc)
mbhc->current_plug, detection_type);
wcd_cancel_hs_detect_plug(mbhc, &mbhc->correct_plug_swch);
+ /* ASUS_BSP Paul +++ */
+ if (g_DebugMode)
+ goto exit;
+ /* ASUS_BSP Paul --- */
+
if (mbhc->mbhc_cb->micbias_enable_status)
micbias1 = mbhc->mbhc_cb->micbias_enable_status(mbhc,
MIC_BIAS_1);
@@ -1114,6 +1147,7 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc)
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL, 0);
}
+exit: /* ASUS_BSP Paul +++ */
mbhc->in_swch_irq_handler = false;
WCD_MBHC_RSC_UNLOCK(mbhc);
pr_debug("%s: leave\n", __func__);
@@ -1137,6 +1171,51 @@ static irqreturn_t wcd_mbhc_mech_plug_detect_irq(int irq, void *data)
return r;
}
+/* ASUS_BSP Paul +++ */
+void wcd_mbhc_plug_detect_for_debug_mode(struct wcd_mbhc *mbhc, int debug_mode)
+{
+ if (debug_mode) {
+ if (mbhc->current_plug != MBHC_PLUG_TYPE_NONE) {
+ printk("%s: current_plug != MBHC_PLUG_TYPE_NONE, force removal\n", __func__);
+ mbhc->mbhc_cb->lock_sleep(mbhc, true);
+ wcd_mbhc_swch_irq_handler(mbhc);
+ mbhc->mbhc_cb->lock_sleep(mbhc, false);
+ g_jack_det_invert = 1;
+ }
+ mbhc->mbhc_cb->irq_control(mbhc->codec, mbhc->intr_ids->mbhc_btn_press_intr, false);
+ mbhc->mbhc_cb->irq_control(mbhc->codec, mbhc->intr_ids->mbhc_btn_release_intr, false);
+ mbhc->mbhc_cb->irq_control(mbhc->codec, mbhc->intr_ids->hph_left_ocp, false);
+ mbhc->mbhc_cb->irq_control(mbhc->codec, mbhc->intr_ids->hph_right_ocp, false);
+ } else {
+ bool detection_type;
+ mbhc->mbhc_cb->irq_control(mbhc->codec, mbhc->intr_ids->mbhc_btn_press_intr, true);
+ mbhc->mbhc_cb->irq_control(mbhc->codec, mbhc->intr_ids->mbhc_btn_release_intr, true);
+ mbhc->mbhc_cb->irq_control(mbhc->codec, mbhc->intr_ids->hph_left_ocp, true);
+ mbhc->mbhc_cb->irq_control(mbhc->codec, mbhc->intr_ids->hph_right_ocp, true);
+ WCD_MBHC_REG_READ(WCD_MBHC_MECH_DETECTION_TYPE, detection_type);
+ if (!g_jack_det_invert && !detection_type) {
+ printk("%s: g_jack_det_invert == 0, detect plug type\n", __func__);
+ WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MECH_DETECTION_TYPE,
+ !detection_type);
+ mbhc->mbhc_cb->lock_sleep(mbhc, true);
+ wcd_mbhc_swch_irq_handler(mbhc);
+ mbhc->mbhc_cb->lock_sleep(mbhc, false);
+ } else if (g_jack_det_invert && !detection_type) {
+ printk("%s: current_plug == MBHC_PLUG_TYPE_NONE\n", __func__);
+ WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MECH_DETECTION_TYPE,
+ !detection_type);
+ } else if (g_jack_det_invert && detection_type) {
+ printk("%s: g_jack_det_invert == 1, detect plug type\n", __func__);
+ mbhc->mbhc_cb->lock_sleep(mbhc, true);
+ wcd_mbhc_swch_irq_handler(mbhc);
+ mbhc->mbhc_cb->lock_sleep(mbhc, false);
+ }
+ g_jack_det_invert = 0;
+ }
+}
+EXPORT_SYMBOL(wcd_mbhc_plug_detect_for_debug_mode);
+/* ASUS_BSP Paul --- */
+
static int wcd_mbhc_get_button_mask(struct wcd_mbhc *mbhc)
{
int mask = 0;
diff --git a/sound/soc/codecs/wcd-mbhc-v2.h b/sound/soc/codecs/wcd-mbhc-v2.h
index 9a36f5e88a3..e35db76c222 100644
--- a/sound/soc/codecs/wcd-mbhc-v2.h
+++ b/sound/soc/codecs/wcd-mbhc-v2.h
@@ -385,6 +385,7 @@ struct wcd_mbhc {
(sizeof(cfg_ptr->_rload[0]) + sizeof(cfg_ptr->_alpha[0]))))
int wcd_mbhc_set_keycode(struct wcd_mbhc *mbhc);
+void wcd_mbhc_plug_detect_for_debug_mode(struct wcd_mbhc *mbhc, int debug_mode); /* ASUS_BSP Paul +++ */
#ifdef CONFIG_SND_SOC_WCD_MBHC
int wcd_mbhc_start(struct wcd_mbhc *mbhc,
diff --git a/sound/soc/codecs/wcd9330.c b/sound/soc/codecs/wcd9330.c
index 5dff270bb92..e038d226f4e 100644
--- a/sound/soc/codecs/wcd9330.c
+++ b/sound/soc/codecs/wcd9330.c
@@ -39,6 +39,9 @@
#include "wcd9xxx-resmgr.h"
#include "wcd9xxx-common.h"
#include "wcdcal-hwdep.h"
+#include <linux/proc_fs.h>
+#include <../drivers/base/regmap/internal.h>
+#include <linux/switch.h>
#include "wcd_cpe_core.h"
enum {
@@ -83,6 +86,8 @@ enum {
#define SLIM_BW_CLK_GEAR_9 6200000
#define SLIM_BW_UNVOTE 0
+int g_DebugMode = 1;
+struct switch_dev *g_audiowizard_force_preset_sdev = NULL;
static int cpe_debug_mode;
module_param(cpe_debug_mode, int,
S_IRUGO | S_IWUSR | S_IWGRP);
@@ -9119,6 +9124,21 @@ static int tomtom_codec_probe(struct snd_soc_codec *codec)
/*wangdongdong@MultiMedia.AudioDrv, 2015-03-24, Modify for headset uevent*/
priv_headset_type = tomtom;
#endif
+
+ /* ASUS_BSP Paul +++ */
+ if (!g_audiowizard_force_preset_sdev) {
+ g_audiowizard_force_preset_sdev = kzalloc(sizeof(struct switch_dev), GFP_KERNEL);
+ if (!g_audiowizard_force_preset_sdev) {
+ pr_err("%s: failed to allocate switch_dev\n", __func__);
+ ret = -ENOMEM;
+ }
+ g_audiowizard_force_preset_sdev->name = "audiowizard_force_preset";
+ g_audiowizard_force_preset_sdev->state = 0;
+ ret = switch_dev_register(g_audiowizard_force_preset_sdev);
+ if (ret < 0)
+ pr_err("%s: failed to register switch audiowizard_force_preset\n", __func__);
+ }
+ /* ASUS_BSP Paul --- */
return ret;
err_pdata:
diff --git a/sound/soc/msm/qdsp6v2/audio_calibration.c b/sound/soc/msm/qdsp6v2/audio_calibration.c
index 2a1b34776b6..554eff32edb 100644
--- a/sound/soc/msm/qdsp6v2/audio_calibration.c
+++ b/sound/soc/msm/qdsp6v2/audio_calibration.c
@@ -21,6 +21,11 @@
#include <sound/audio_calibration.h>
#include <sound/audio_cal_utils.h>
+#include <linux/switch.h>
+#include <sound/soc.h>
+#include "../../codecs/wcd9330.h"
+#include "../../codecs/wcd-mbhc-v2.h"
+
struct audio_cal_client_info {
struct list_head list;
struct audio_cal_callbacks *callbacks;
@@ -35,6 +40,15 @@ struct audio_cal_info {
static struct audio_cal_info audio_cal;
+/* ASUS_BSP */
+int g_audiowizard_force_preset_state = 0;
+int g_skype_state = 0;
+extern struct switch_dev *g_audiowizard_force_preset_sdev;
+extern uint32_t g_ZL;
+extern uint32_t g_ZR;
+int audio_mode = -1;
+int mode = -1;
+int audio_24bit = 0;
static bool callbacks_are_equal(struct audio_cal_callbacks *callback1,
struct audio_cal_callbacks *callback2)
@@ -392,6 +406,9 @@ static long audio_cal_shared_ioctl(struct file *file, unsigned int cmd,
int ret = 0;
int32_t size;
struct audio_cal_basic *data = NULL;
+ /* ASUS_BSP */
+ struct audio_codec_reg *codec_reg = NULL;
+ struct headset_imp_val *imp_val = NULL;
pr_debug("%s\n", __func__);
switch (cmd) {
@@ -402,6 +419,79 @@ static long audio_cal_shared_ioctl(struct file *file, unsigned int cmd,
case AUDIO_GET_CALIBRATION:
case AUDIO_POST_CALIBRATION:
break;
+ /* ASUS_BSP */
+ case AUDIO_SET_AUDIOWIZARD_FORCE_PRESET:
+ mutex_lock(&audio_cal.cal_mutex[AUDIOWIZARD_FORCE_PRESET_TYPE]);
+ if (copy_from_user(&g_audiowizard_force_preset_state, (void *)arg,
+ sizeof(g_audiowizard_force_preset_state))) {
+ pr_err("%s: Could not copy g_audiowizard_force_preset_state from user\n", __func__);
+ ret = -EFAULT;
+ }
+ switch_set_state(g_audiowizard_force_preset_sdev, g_audiowizard_force_preset_state);
+ mutex_unlock(&audio_cal.cal_mutex[AUDIOWIZARD_FORCE_PRESET_TYPE]);
+ goto done;
+ case AUDIO_GET_HS_IMP:
+ printk("AUDIO_GET_HS_IMP : start\n");
+ mutex_lock(&audio_cal.cal_mutex[GET_IMP_TYPE]);
+ imp_val = kmalloc(sizeof(struct headset_imp_val), GFP_KERNEL);
+ if (imp_val == NULL) {
+ //pr_err("%s: could not allocated codec_reg!\n", __func__);
+ printk("%s: could not allocated codec_reg!\n", __func__);
+ ret = -ENOMEM;
+ mutex_unlock(&audio_cal.cal_mutex[GET_IMP_TYPE]);
+ goto done;
+ }
+ if (copy_from_user(imp_val, (void *)arg,
+ sizeof(struct headset_imp_val))) {
+ //pr_err("%s: Could not copy codec_reg from user\n", __func__);
+ printk("%s: Could not copy codec_reg from user\n", __func__);
+ ret = -EFAULT;
+ mutex_unlock(&audio_cal.cal_mutex[GET_IMP_TYPE]);
+ goto done;
+ }
+/*
+ if ( g_tasha->mbhc.current_plug == MBHC_PLUG_TYPE_NONE ||
+ g_tasha->mbhc.current_plug == MBHC_PLUG_TYPE_INVALID ) {
+ //pr_err("%s: headset not plugin or invalid plug\n", __func__);
+ printk("%s: headset not plugin or invalid plug\n", __func__);
+ ret = -EINVAL;
+ mutex_unlock(&audio_cal.cal_mutex[GET_IMP_TYPE]);
+ goto done;
+ }
+*/
+ imp_val->ZL = g_ZL;
+ imp_val->ZR = g_ZR;
+ printk("%s: RR = %d , LL = %d\n", __func__ , imp_val->ZR , imp_val->ZL);
+ if (copy_to_user((void *)arg, imp_val,
+ sizeof(struct headset_imp_val))) {
+ //pr_err("%s: Could not copy imp_val to user\n", __func__);
+ printk("%s: Could not copy imp_val to user\n", __func__);
+ ret = -EFAULT;
+ }
+ mutex_unlock(&audio_cal.cal_mutex[GET_IMP_TYPE]);
+ printk("AUDIO_GET_HS_IMP : done\n");
+ goto done;
+ case AUDIO_SET_MODE:
+ mutex_lock(&audio_cal.cal_mutex[SET_MODE_TYPE]);
+ if(copy_from_user(&mode, (void *)arg,sizeof(mode))) {
+ pr_err("%s: Could not copy lmode to user\n", __func__);
+ ret = -EFAULT;
+ }
+
+ audio_mode = mode;
+ printk("%s: Audio mode status:audio_mode=%d\n",__func__,audio_mode);
+ mutex_unlock(&audio_cal.cal_mutex[SET_MODE_TYPE]);
+ goto done;
+ case AUDIO_SET_FORMAT:
+ mutex_lock(&audio_cal.cal_mutex[SET_FORMAT_TYPE]);
+ if(copy_from_user(&audio_24bit, (void *)arg,sizeof(audio_24bit))) {
+ pr_err("%s: Could not copy lmode to user\n", __func__);
+ ret = -EFAULT;
+ }
+ printk("%s: audio_24bit=%d\n",__func__,audio_24bit);
+ mutex_unlock(&audio_cal.cal_mutex[SET_FORMAT_TYPE]);
+ goto done;
+
default:
pr_err("%s: ioctl not found!\n", __func__);
ret = -EFAULT;
@@ -509,9 +599,21 @@ unlock:
mutex_unlock(&audio_cal.cal_mutex[data->hdr.cal_type]);
done:
kfree(data);
+
+ /* ASUS_BSP */
+ kfree(codec_reg);
+ kfree(imp_val);
return ret;
}
+/* ASUS_BSP */
+int get_audiomode(void)
+{
+ printk("%s: Audio mode=%d\n",__func__, audio_mode);
+ return audio_mode;
+}
+EXPORT_SYMBOL(get_audiomode);
+
static long audio_cal_ioctl(struct file *f,
unsigned int cmd, unsigned long arg)
{
@@ -532,6 +634,13 @@ static long audio_cal_ioctl(struct file *f,
204, compat_uptr_t)
#define AUDIO_POST_CALIBRATION32 _IOWR(CAL_IOCTL_MAGIC, \
205, compat_uptr_t)
+/* ASUS_BSP */
+#define AUDIO_SET_AUDIOWIZARD_FORCE_PRESET32 _IOWR(CAL_IOCTL_MAGIC, \
+ 221, compat_uptr_t)
+#define AUDIO_GET_HS_IMP32 _IOWR(CAL_IOCTL_MAGIC, \
+ 230, compat_uptr_t)
+#define AUDIO_SET_MODE32 _IOWR(CAL_IOCTL_MAGIC,225,compat_uptr_t)
+#define AUDIO_SET_FORMAT32 _IOWR(CAL_IOCTL_MAGIC,231,compat_uptr_t) //Rice
static long audio_cal_compat_ioctl(struct file *f,
unsigned int cmd, unsigned long arg)
@@ -558,6 +667,19 @@ static long audio_cal_compat_ioctl(struct file *f,
case AUDIO_POST_CALIBRATION32:
cmd64 = AUDIO_POST_CALIBRATION;
break;
+ /* ASUS_BSP */
+ case AUDIO_SET_AUDIOWIZARD_FORCE_PRESET32:
+ cmd64 = AUDIO_SET_AUDIOWIZARD_FORCE_PRESET;
+ break;
+ case AUDIO_GET_HS_IMP32:
+ cmd64 = AUDIO_GET_HS_IMP;
+ break;
+ case AUDIO_SET_MODE32:
+ cmd64 = AUDIO_SET_MODE;
+ break;
+ case AUDIO_SET_FORMAT32:
+ cmd64 = AUDIO_SET_FORMAT;
+ break;
default:
pr_err("%s: ioctl not found!\n", __func__);
ret = -EFAULT;