Skip to content
This repository has been archived by the owner on Nov 7, 2021. It is now read-only.

Commit

Permalink
techpack/audio: Import minimal Xiaomi changes
Browse files Browse the repository at this point in the history
@imjyotiraditya: moar cleanup

Signed-off-by: Rama Bondan Prakoso <[email protected]>
  • Loading branch information
ramabondanp authored and johnmart19 committed Feb 11, 2021
1 parent bde3902 commit 704dd63
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 66 deletions.
4 changes: 4 additions & 0 deletions techpack/audio/asoc/codecs/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,8 @@ mbhc_dlkm-y := $(MBHC_OBJS)
ifeq ($(CONFIG_MSM_EXT_DISPLAY),y)
obj-$(CONFIG_SND_SOC_MSM_HDMI_CODEC_RX) += hdmi_dlkm.o
hdmi_dlkm-y := $(HDMICODEC_OBJS)

obj-$(CONFIG_SND_SOC_AW87329) += aw87329_audio_dlkm.o
aw87329_audio_dlkm-y := $(AW87329_AUDIO_OBJS)

endif
17 changes: 7 additions & 10 deletions techpack/audio/asoc/codecs/wcd-mbhc-legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ static int wcd_check_cross_conn(struct wcd_mbhc *mbhc)
enum wcd_mbhc_plug_type plug_type = MBHC_PLUG_TYPE_NONE;
s16 reg1 = 0;
bool hphl_sch_res = 0, hphr_sch_res = 0;
//add-begin by zad for headset noise when inserting

return false;
//add-end

if (wcd_swch_level_remove(mbhc)) {
pr_debug("%s: Switch level is low\n", __func__);
return -EINVAL;
Expand Down Expand Up @@ -319,13 +319,11 @@ static void wcd_enable_mbhc_supply(struct wcd_mbhc *mbhc,
wcd_enable_curr_micbias(mbhc,
WCD_MBHC_EN_PULLUP);
} else {
//Add-begin by zad 20181102 for selfie stick
#if 1
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
#else
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_CS);
#endif
//Add-end
}
} else if (plug_type == MBHC_PLUG_TYPE_HEADPHONE) {
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_CS);
Expand Down Expand Up @@ -474,16 +472,15 @@ static void wcd_correct_swch_plug(struct work_struct *work)
* no need to enabale micbias/pullup here
*/

//add start by zad for playing music is interrupted when headset was inserting sometimes
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
//add end
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);

wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);

/* Enable HW FSM */
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
//add start by zad for playing music is interrupted when headset was inserting sometimes

msleep(20);
//add end

/*
* Check for any button press interrupts before starting 3-sec
* loop.
Expand Down
74 changes: 18 additions & 56 deletions techpack/audio/asoc/codecs/wcd-mbhc-v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
#include "wcd-mbhc-legacy.h"
#include "wcd-mbhc-adc.h"
#include "wcd-mbhc-v2-api.h"
static int det_Selfiestick_ins = 0;
//add-begin by zad for headset state check

static int det_Selfiestick_ins = 0;
static int headset_state = 0;
//add-end

void wcd_mbhc_jack_report(struct wcd_mbhc *mbhc,
struct snd_soc_jack *jack, int status, int mask)
{
Expand Down Expand Up @@ -325,14 +325,10 @@ static int wcd_event_notify(struct notifier_block *self, unsigned long val,
hphlocp_off_report(mbhc, SND_JACK_OC_HPHL);
clear_bit(WCD_MBHC_EVENT_PA_HPHL, &mbhc->event_state);
/* check if micbias is enabled */
//Add-begin by zad 2018112 for selfie stick
if (micbias2 || (det_Selfiestick_ins == 1))
/* Disable cs, pullup & enable micbias */
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
//modify start by zad for playing music is interrupted when headset was inserting sometimes
//else
else if(!wcd_swch_level_remove(mbhc))
//modify end
/* Disable micbias, pullup & enable cs */
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_CS);
//Add-end
Expand All @@ -351,10 +347,7 @@ static int wcd_event_notify(struct notifier_block *self, unsigned long val,
if (micbias2)
/* Disable cs, pullup & enable micbias */
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
//modify start by zad for playing music is interrupted when headset was inserting sometimes
//else
else if(!wcd_swch_level_remove(mbhc))
//modify end
/* Disable micbias, pullup & enable cs */
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_CS);
mutex_unlock(&mbhc->hphr_pa_lock);
Expand All @@ -365,12 +358,9 @@ static int wcd_event_notify(struct notifier_block *self, unsigned long val,
/* check if micbias is enabled */
if (micbias2)
/* Disable cs, pullup & enable micbias */
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
//modify start by zad for playing music is interrupted when headset was inserting sometimes
//else
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
else if(!wcd_swch_level_remove(mbhc))
//modify end
/* Disable micbias, enable pullup & cs */
/* Disable micbias, enable pullup & cs */
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_PULLUP);
break;
case WCD_EVENT_PRE_HPHR_PA_ON:
Expand All @@ -379,10 +369,7 @@ static int wcd_event_notify(struct notifier_block *self, unsigned long val,
if (micbias2)
/* Disable cs, pullup & enable micbias */
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
//modify start by zad for playing music is interrupted when headset was inserting sometimes
//else
else if(!wcd_swch_level_remove(mbhc))
//modify end
/* Disable micbias, enable pullup & cs */
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_PULLUP);
break;
Expand Down Expand Up @@ -575,9 +562,9 @@ void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion,
u8 fsm_en = 0;

WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
//add-begin by zad for headset state check

headset_state = insertion;
//add-end

pr_debug("%s: enter insertion %d hph_status %x\n",
__func__, insertion, mbhc->hph_status);
if (!insertion) {
Expand All @@ -597,7 +584,9 @@ void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion,
mbhc->buttons_pressed &=
~WCD_MBHC_JACK_BUTTON_MASK;
}

det_Selfiestick_ins = 0;

if (mbhc->micbias_enable) {
if (mbhc->mbhc_cb->mbhc_micbias_control)
mbhc->mbhc_cb->mbhc_micbias_control(
Expand Down Expand Up @@ -815,8 +804,6 @@ void wcd_mbhc_find_plug_and_report(struct wcd_mbhc *mbhc,
wcd_mbhc_report_plug(mbhc, 0, SND_JACK_HEADPHONE);
if (mbhc->current_plug == MBHC_PLUG_TYPE_HEADSET)
wcd_mbhc_report_plug(mbhc, 0, SND_JACK_HEADSET);
// wcd_mbhc_report_plug(mbhc, 1, SND_JACK_UNSUPPORTED);
//Add-begin by zad 2018112 for selfie stick
/*
* calculate impedance detection
* If Zl and Zr > 20k then it is special accessory
Expand All @@ -834,26 +821,13 @@ void wcd_mbhc_find_plug_and_report(struct wcd_mbhc *mbhc,
, __func__);
}
/* enable CS/MICBIAS for headset button detection to work */
//wcd_enable_mbhc_supply(mbhc, MBHC_PLUG_TYPE_HEADSET);
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
wcd_mbhc_report_plug(mbhc, 1, SND_JACK_HEADSET);
det_Selfiestick_ins = 1;
/* add code start
if (mbhc->is_hs_recording)
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
else if ((test_bit(WCD_MBHC_EVENT_PA_HPHL, &mbhc->event_state)) ||
(test_bit(WCD_MBHC_EVENT_PA_HPHR, &mbhc->event_state)))
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_PULLUP);
else
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_CS);
add code end */

}
else {
} else {
wcd_mbhc_report_plug(mbhc, 1, SND_JACK_UNSUPPORTED);
}
}
//Add-end
} else if (plug_type == MBHC_PLUG_TYPE_HEADSET) {
if (mbhc->mbhc_cfg->enable_anc_mic_detect &&
mbhc->mbhc_fn->wcd_mbhc_detect_anc_plug_type)
Expand All @@ -872,7 +846,6 @@ void wcd_mbhc_find_plug_and_report(struct wcd_mbhc *mbhc,

} else if (plug_type == MBHC_PLUG_TYPE_HIGH_HPH) {
if (mbhc->mbhc_cfg->detect_extn_cable) {
//Add-begin by zad 2018112 for selfie stick
/*
* calculate impedance detection
* If Zl and Zr > 20k then it is special accessory
Expand All @@ -890,18 +863,13 @@ void wcd_mbhc_find_plug_and_report(struct wcd_mbhc *mbhc,
, __func__);
}
/* enable CS/MICBIAS for headset button detection to work */
//wcd_enable_mbhc_supply(mbhc, MBHC_PLUG_TYPE_HEADSET);
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
det_Selfiestick_ins = 1;
wcd_mbhc_report_plug(mbhc, 1, SND_JACK_HEADSET);
}
else {
} else {
wcd_mbhc_report_plug(mbhc, 1, SND_JACK_LINEOUT);
}
}
//Add-end
else
{
} else {
/* High impedance device found. Report as LINEOUT */
wcd_mbhc_report_plug(mbhc, 1, SND_JACK_LINEOUT);
pr_debug("%s: setup mic trigger for further detection\n",
Expand Down Expand Up @@ -1357,19 +1325,18 @@ static irqreturn_t wcd_mbhc_hphr_ocp_irq(int irq, void *data)
return IRQ_HANDLED;
}

//add-begin by zad for headset state check
static ssize_t state_show(struct device *dev,struct device_attribute *attr, char *buf)
{
return sprintf(buf,"%d\n",headset_state);
}

static DEVICE_ATTR(state,0440,state_show,NULL);
//add-end

static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc)
{
int ret = 0;
struct snd_soc_codec *codec = mbhc->codec;
//add-begin by zad for headset state check
struct snd_soc_codec *codec = mbhc->codec;

struct device *dev;
struct class *dev_class;
dev_class = class_create(THIS_MODULE,"h2w");
Expand All @@ -1379,18 +1346,17 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc)
goto CREATE_FAIL;
}
dev = device_create(dev_class,NULL,0,NULL,"device");
if (IS_ERR(dev))
if (IS_ERR(dev))
{
pr_err("%s: device_create fail\n", __func__);
goto CREATE_FAIL;
}
}
if(device_create_file(dev,&dev_attr_state))
{
{
pr_err("%s: device_create_file fail\n", __func__);
goto CREATE_FAIL;
}
CREATE_FAIL:
//add-end
pr_debug("%s: enter\n", __func__);
WCD_MBHC_RSC_LOCK(mbhc);

Expand Down Expand Up @@ -1432,11 +1398,7 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc)
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_INSREM_DBNC, 4);
} else {
/* Insertion debounce set to 96ms */
//modify start by zad for playing music is interrupted when headset was inserting sometimes
//WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_INSREM_DBNC, 6);
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_INSREM_DBNC, 8);
//modify end

}

/* Button Debounce set to 16ms */
Expand Down
1 change: 1 addition & 0 deletions techpack/audio/config/sdm450auto.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CONFIG_SND_SOC_WSA881X=y
CONFIG_SND_SOC_WSA881X_ANALOG=y
CONFIG_SND_SOC_AW87329=y
CONFIG_SND_SOC_WCD_CPE=y
CONFIG_SND_SOC_AW87329=y
CONFIG_SND_SOC_CPE=y
CONFIG_SND_SOC_WCD9335=y
CONFIG_MSM_QDSP6V2_CODECS=y
Expand Down

0 comments on commit 704dd63

Please sign in to comment.