Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oneplus/qc8996 o 8.0.0 #42

Open
wants to merge 2 commits into
base: oneplus/QC8996_O_8.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions drivers/slimbus/slim-msm-ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ enum mgr_intr {

enum frm_cfg {
FRM_ACTIVE = 1,
CLK_GEAR = 7,
ROOT_FREQ = 11,
CLK_GEAR = 9,
ROOT_FREQ = 19,
REF_CLK_GEAR = 15,
INTR_WAKE = 19,
};
Expand Down
166 changes: 128 additions & 38 deletions sound/soc/codecs/wcd9335.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
*Copyright (C) 2018, Laster K. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -50,7 +51,8 @@

#define WCD9335_RATES_MASK (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000 |\
SNDRV_PCM_RATE_384000)
/* Fractional Rates */
#define WCD9335_FRAC_RATES_MASK (SNDRV_PCM_RATE_44100)

Expand Down Expand Up @@ -164,7 +166,17 @@ enum tasha_sido_voltage {

static enum codec_variant codec_ver;

static int dig_core_collapse_enable = 1;
static int huwifi_mode = 1;
module_param(huwifi_mode, int,
S_IRUGO | S_IWUSR | S_IWGRP);
MODULE_PARM_DESC(huwifi_mode, "enable/disable l UHQA Mode");

static int low_distort_amp = 1;
module_param(low_distort_amp, int,
S_IRUGO | S_IWUSR | S_IWGRP);
MODULE_PARM_DESC(low_distort_amp, "enable/disable l Class AB Mode");

static int dig_core_collapse_enable = 0;
module_param(dig_core_collapse_enable, int,
S_IRUGO | S_IWUSR | S_IWGRP);
MODULE_PARM_DESC(dig_core_collapse_enable, "enable/disable power gating");
Expand Down Expand Up @@ -442,6 +454,7 @@ static struct interp_sample_rate int_mix_sample_rate_val[] = {
{48000, 0x4}, /* 48K */
{96000, 0x5}, /* 96K */
{192000, 0x6}, /* 192K */
{384000, 0x7}, /* 384K */
};

static const struct wcd9xxx_ch tasha_rx_chs[TASHA_RX_MAX] = {
Expand Down Expand Up @@ -3840,9 +3853,13 @@ static void tasha_codec_hph_post_pa_config(struct tasha_priv *tasha,
case CLS_H_HIFI:
scale_val = 0x3;
break;

case CLS_H_LOHIFI:
scale_val = 0x1;
break;
if (!huwifi_mode)
scale_val = 0x1;
else
scale_val = 031;
break;
}
if (tasha->anc_func) {
/* Clear Tx FE HOLD if both PAs are enabled */
Expand Down Expand Up @@ -4456,10 +4473,16 @@ static void tasha_codec_hph_mode_config(struct snd_soc_codec *codec,

switch (mode) {
case CLS_H_LP:
tasha_codec_hph_lp_config(codec, event);
if (!huwifi_mode)
tasha_codec_hph_lp_config(codec, event);
else
tasha_codec_hph_hifi_config(codec, event);
break;
case CLS_H_LOHIFI:
tasha_codec_hph_lohifi_config(codec, event);
if (!huwifi_mode)
tasha_codec_hph_lohifi_config(codec, event);
else
tasha_codec_hph_hifi_config(codec, event);
break;
case CLS_H_HIFI:
tasha_codec_hph_hifi_config(codec, event);
Expand Down Expand Up @@ -4498,12 +4521,19 @@ static int tasha_codec_hphr_dac_event(struct snd_soc_dapm_widget *w,
__func__, hph_mode);
return -EINVAL;
}
wcd_clsh_fsm(codec, &tasha->clsh_d,
WCD_CLSH_EVENT_PRE_DAC,
WCD_CLSH_STATE_HPHR,
((hph_mode == CLS_H_LOHIFI) ?
CLS_H_HIFI : hph_mode));

if (!low_distort_amp) {
wcd_clsh_fsm(codec, &tasha->clsh_d,
WCD_CLSH_EVENT_PRE_DAC,
WCD_CLSH_STATE_HPHR,
((hph_mode == CLS_H_LOHIFI) ?
CLS_H_HIFI : hph_mode));
}
else {
wcd_clsh_fsm(codec, &tasha->clsh_d,
WCD_CLSH_EVENT_PRE_DAC,
WCD_CLSH_STATE_HPHR,
CLS_AB);
}
tasha_codec_hph_mode_config(codec, event, hph_mode);

if (tasha->anc_func)
Expand Down Expand Up @@ -4534,12 +4564,19 @@ static int tasha_codec_hphr_dac_event(struct snd_soc_dapm_widget *w,
if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) &
WCD_CLSH_STATE_HPHL))
tasha_codec_hph_mode_config(codec, event, hph_mode);

wcd_clsh_fsm(codec, &tasha->clsh_d,
WCD_CLSH_EVENT_POST_PA,
WCD_CLSH_STATE_HPHR,
((hph_mode == CLS_H_LOHIFI) ?
CLS_H_HIFI : hph_mode));
if (!low_distort_amp) {
wcd_clsh_fsm(codec, &tasha->clsh_d,
WCD_CLSH_EVENT_POST_PA,
WCD_CLSH_STATE_HPHL,
((hph_mode == CLS_H_LOHIFI) ?
CLS_H_HIFI : hph_mode));
}
else {
wcd_clsh_fsm(codec, &tasha->clsh_d,
WCD_CLSH_EVENT_POST_PA,
WCD_CLSH_STATE_HPHL,
CLS_AB);
}
break;
};

Expand Down Expand Up @@ -4578,11 +4615,20 @@ static int tasha_codec_hphl_dac_event(struct snd_soc_dapm_widget *w,
__func__, hph_mode);
return -EINVAL;
}
wcd_clsh_fsm(codec, &tasha->clsh_d,
WCD_CLSH_EVENT_PRE_DAC,
WCD_CLSH_STATE_HPHL,
((hph_mode == CLS_H_LOHIFI) ?
CLS_H_HIFI : hph_mode));

if (!low_distort_amp) {
wcd_clsh_fsm(codec, &tasha->clsh_d,
WCD_CLSH_EVENT_PRE_DAC,
WCD_CLSH_STATE_HPHL,
((hph_mode == CLS_H_LOHIFI) ?
CLS_H_HIFI : hph_mode));
}
else {
wcd_clsh_fsm(codec, &tasha->clsh_d,
WCD_CLSH_EVENT_PRE_DAC,
WCD_CLSH_STATE_HPHL,
CLS_AB);
}

tasha_codec_hph_mode_config(codec, event, hph_mode);

Expand Down Expand Up @@ -4626,20 +4672,26 @@ static int tasha_codec_hphl_dac_event(struct snd_soc_dapm_widget *w,
if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) &
WCD_CLSH_STATE_HPHR))
tasha_codec_hph_mode_config(codec, event, hph_mode);
wcd_clsh_fsm(codec, &tasha->clsh_d,
WCD_CLSH_EVENT_POST_PA,
WCD_CLSH_STATE_HPHL,
((hph_mode == CLS_H_LOHIFI) ?
CLS_H_HIFI : hph_mode));
if (!low_distort_amp) {
wcd_clsh_fsm(codec, &tasha->clsh_d,
WCD_CLSH_EVENT_POST_PA,
WCD_CLSH_STATE_HPHR,
((hph_mode == CLS_H_LOHIFI) ?
CLS_H_HIFI : hph_mode));
}
else {
wcd_clsh_fsm(codec, &tasha->clsh_d,
WCD_CLSH_EVENT_POST_PA,
WCD_CLSH_STATE_HPHR,
CLS_AB);
}

if (test_bit(CLASSH_CONFIG, &tasha->status_mask)) {
wcd_clsh_imped_config(codec, impedl, true);
clear_bit(CLASSH_CONFIG, &tasha->status_mask);
} else
dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n",
__func__, ret);


break;
};

Expand Down Expand Up @@ -4791,18 +4843,52 @@ static int tasha_codec_ear_dac_event(struct snd_soc_dapm_widget *w,
struct snd_soc_codec *codec = w->codec;
struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
int ret = 0;
int hph_mode = tasha->hph_mode;

dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);

switch (event) {
case SND_SOC_DAPM_PRE_PMU:
if (tasha->anc_func)
ret = tasha_codec_enable_anc(w, kcontrol, event);

wcd_clsh_fsm(codec, &tasha->clsh_d,
WCD_CLSH_EVENT_PRE_DAC,
WCD_CLSH_STATE_EAR,
CLS_H_NORMAL);
if (!low_distort_amp) {
if (!huwifi_mode) {
wcd_clsh_fsm(codec, &tasha->clsh_d,
WCD_CLSH_EVENT_PRE_DAC,
WCD_CLSH_STATE_EAR,
CLS_H_NORMAL);
}
else {
wcd_clsh_fsm(codec, &tasha->clsh_d,
WCD_CLSH_EVENT_PRE_DAC,
WCD_CLSH_STATE_EAR,
((hph_mode == CLS_H_LOHIFI) ?
CLS_H_HIFI : hph_mode));
}
}
else {
if (!low_distort_amp) {
if (!huwifi_mode) {
wcd_clsh_fsm(codec, &tasha->clsh_d,
WCD_CLSH_EVENT_POST_PA,
WCD_CLSH_STATE_EAR,
CLS_H_NORMAL);
}
else {
wcd_clsh_fsm(codec, &tasha->clsh_d,
WCD_CLSH_EVENT_POST_PA,
WCD_CLSH_STATE_EAR,
((hph_mode == CLS_H_LOHIFI) ?
CLS_H_HIFI : hph_mode));
}
}
else {
wcd_clsh_fsm(codec, &tasha->clsh_d,
WCD_CLSH_EVENT_POST_PA,
WCD_CLSH_STATE_EAR,
CLS_AB);
}
}
if (tasha->anc_func)
snd_soc_update_bits(codec,
WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x10);
Expand Down Expand Up @@ -11786,6 +11872,10 @@ static int tasha_hw_params(struct snd_pcm_substream *substream,
tasha->dai[dai->id].bit_width = 24;
i2s_bit_mode = 0x00;
break;
case 32:
tasha->dai[dai->id].bit_width = 32;
i2s_bit_mode = 0x00;
break;
default:
return -EINVAL;
}
Expand Down Expand Up @@ -11813,6 +11903,9 @@ static int tasha_hw_params(struct snd_pcm_substream *substream,
case 192000:
rx_fs_rate = 5;
break;
case 384000:
rx_fs_rate = 6;
break;
default:
dev_err(tasha->dev,
"%s: Invalid RX sample rate: %d\n",
Expand Down Expand Up @@ -11847,9 +11940,6 @@ static int tasha_hw_params(struct snd_pcm_substream *substream,
case 192000:
tx_fs_rate = 6;
break;
case 384000:
tx_fs_rate = 7;
break;
default:
dev_err(tasha->dev, "%s: Invalid TX sample rate: %d\n",
__func__, params_rate(params));
Expand Down