Commit 09354ebe authored by Takashi Iwai's avatar Takashi Iwai

Merge tag 'asoc-fix-v5.17-rc7' of...

Merge tag 'asoc-fix-v5.17-rc7' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus

ASoC: Potential fixes for v5.17

Rather more fixes here than I'm comfortable with, we've had several
vendors noticing issues late in the release cycle all of which are valid
and reasonable fixes but it adds up to a much larger change set than I'd
like.  Several of the AMD fixes look like cleanups from the subject
lines but are actually fixing user visible problems as well.

If you were to merge this for 5.18 rather than 5.17 it wouldn't be the
end of the world, stable will probably backport everything anyway.
parents 9cb72750 5e02fb59
...@@ -88,10 +88,9 @@ static int acp5x_i2s_hwparams(struct snd_pcm_substream *substream, ...@@ -88,10 +88,9 @@ static int acp5x_i2s_hwparams(struct snd_pcm_substream *substream,
struct snd_soc_card *card; struct snd_soc_card *card;
struct acp5x_platform_info *pinfo; struct acp5x_platform_info *pinfo;
struct i2s_dev_data *adata; struct i2s_dev_data *adata;
union acp_i2stdm_mstrclkgen mclkgen;
u32 val; u32 val;
u32 reg_val, frmt_reg, master_reg; u32 reg_val, frmt_reg;
u32 lrclk_div_val, bclk_div_val; u32 lrclk_div_val, bclk_div_val;
lrclk_div_val = 0; lrclk_div_val = 0;
...@@ -160,20 +159,6 @@ static int acp5x_i2s_hwparams(struct snd_pcm_substream *substream, ...@@ -160,20 +159,6 @@ static int acp5x_i2s_hwparams(struct snd_pcm_substream *substream,
acp_writel(val, rtd->acp5x_base + reg_val); acp_writel(val, rtd->acp5x_base + reg_val);
if (adata->master_mode) { if (adata->master_mode) {
switch (rtd->i2s_instance) {
case I2S_HS_INSTANCE:
master_reg = ACP_I2STDM2_MSTRCLKGEN;
break;
case I2S_SP_INSTANCE:
default:
master_reg = ACP_I2STDM0_MSTRCLKGEN;
break;
}
mclkgen.bits.i2stdm_master_mode = 0x1;
if (adata->tdm_mode)
mclkgen.bits.i2stdm_format_mode = 0x01;
else
mclkgen.bits.i2stdm_format_mode = 0x0;
switch (params_format(params)) { switch (params_format(params)) {
case SNDRV_PCM_FORMAT_S16_LE: case SNDRV_PCM_FORMAT_S16_LE:
switch (params_rate(params)) { switch (params_rate(params)) {
...@@ -238,9 +223,8 @@ static int acp5x_i2s_hwparams(struct snd_pcm_substream *substream, ...@@ -238,9 +223,8 @@ static int acp5x_i2s_hwparams(struct snd_pcm_substream *substream,
default: default:
return -EINVAL; return -EINVAL;
} }
mclkgen.bits.i2stdm_bclk_div_val = bclk_div_val; rtd->lrclk_div = lrclk_div_val;
mclkgen.bits.i2stdm_lrclk_div_val = lrclk_div_val; rtd->bclk_div = bclk_div_val;
acp_writel(mclkgen.u32_all, rtd->acp5x_base + master_reg);
} }
return 0; return 0;
} }
...@@ -249,9 +233,11 @@ static int acp5x_i2s_trigger(struct snd_pcm_substream *substream, ...@@ -249,9 +233,11 @@ static int acp5x_i2s_trigger(struct snd_pcm_substream *substream,
int cmd, struct snd_soc_dai *dai) int cmd, struct snd_soc_dai *dai)
{ {
struct i2s_stream_instance *rtd; struct i2s_stream_instance *rtd;
struct i2s_dev_data *adata;
u32 ret, val, period_bytes, reg_val, ier_val, water_val; u32 ret, val, period_bytes, reg_val, ier_val, water_val;
u32 buf_size, buf_reg; u32 buf_size, buf_reg;
adata = snd_soc_dai_get_drvdata(dai);
rtd = substream->runtime->private_data; rtd = substream->runtime->private_data;
period_bytes = frames_to_bytes(substream->runtime, period_bytes = frames_to_bytes(substream->runtime,
substream->runtime->period_size); substream->runtime->period_size);
...@@ -300,6 +286,8 @@ static int acp5x_i2s_trigger(struct snd_pcm_substream *substream, ...@@ -300,6 +286,8 @@ static int acp5x_i2s_trigger(struct snd_pcm_substream *substream,
} }
acp_writel(period_bytes, rtd->acp5x_base + water_val); acp_writel(period_bytes, rtd->acp5x_base + water_val);
acp_writel(buf_size, rtd->acp5x_base + buf_reg); acp_writel(buf_size, rtd->acp5x_base + buf_reg);
if (adata->master_mode)
acp5x_set_i2s_clk(adata, rtd);
val = acp_readl(rtd->acp5x_base + reg_val); val = acp_readl(rtd->acp5x_base + reg_val);
val = val | BIT(0); val = val | BIT(0);
acp_writel(val, rtd->acp5x_base + reg_val); acp_writel(val, rtd->acp5x_base + reg_val);
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#define DUAL_CHANNEL 2 #define DUAL_CHANNEL 2
#define ACP5X_NUVOTON_CODEC_DAI "nau8821-hifi" #define ACP5X_NUVOTON_CODEC_DAI "nau8821-hifi"
#define VG_JUPITER 1 #define VG_JUPITER 1
#define ACP5X_NUVOTON_BCLK 3072000
#define ACP5X_NAU8821_FREQ_OUT 12288000
static unsigned long acp5x_machine_id; static unsigned long acp5x_machine_id;
static struct snd_soc_jack vg_headset; static struct snd_soc_jack vg_headset;
...@@ -98,6 +100,13 @@ static const struct snd_pcm_hw_constraint_list constraints_channels = { ...@@ -98,6 +100,13 @@ static const struct snd_pcm_hw_constraint_list constraints_channels = {
.mask = 0, .mask = 0,
}; };
static const unsigned int acp5x_nau8821_format[] = {32};
static struct snd_pcm_hw_constraint_list constraints_sample_bits = {
.list = acp5x_nau8821_format,
.count = ARRAY_SIZE(acp5x_nau8821_format),
};
static int acp5x_8821_startup(struct snd_pcm_substream *substream) static int acp5x_8821_startup(struct snd_pcm_substream *substream)
{ {
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
...@@ -113,6 +122,9 @@ static int acp5x_8821_startup(struct snd_pcm_substream *substream) ...@@ -113,6 +122,9 @@ static int acp5x_8821_startup(struct snd_pcm_substream *substream)
&constraints_channels); &constraints_channels);
snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
&constraints_rates); &constraints_rates);
snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
&constraints_sample_bits);
return 0; return 0;
} }
...@@ -274,6 +286,15 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, ...@@ -274,6 +286,15 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
dev_err(card->dev, "set sysclk err = %d\n", ret); dev_err(card->dev, "set sysclk err = %d\n", ret);
return -EIO; return -EIO;
} }
} else {
ret = snd_soc_dai_set_sysclk(codec_dai, NAU8821_CLK_FLL_BLK, 0,
SND_SOC_CLOCK_IN);
if (ret < 0)
dev_err(codec_dai->dev, "can't set BLK clock %d\n", ret);
ret = snd_soc_dai_set_pll(codec_dai, 0, 0, ACP5X_NUVOTON_BCLK,
ACP5X_NAU8821_FREQ_OUT);
if (ret < 0)
dev_err(codec_dai->dev, "can't set FLL: %d\n", ret);
} }
return ret; return ret;
} }
...@@ -289,7 +310,7 @@ static const struct snd_soc_dapm_widget acp5x_8821_widgets[] = { ...@@ -289,7 +310,7 @@ static const struct snd_soc_dapm_widget acp5x_8821_widgets[] = {
SND_SOC_DAPM_MIC("Headset Mic", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL),
SND_SOC_DAPM_MIC("Int Mic", NULL), SND_SOC_DAPM_MIC("Int Mic", NULL),
SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
platform_clock_control, SND_SOC_DAPM_POST_PMD), platform_clock_control, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
}; };
static const struct snd_soc_dapm_route acp5x_8821_audio_route[] = { static const struct snd_soc_dapm_route acp5x_8821_audio_route[] = {
......
...@@ -105,6 +105,8 @@ struct i2s_stream_instance { ...@@ -105,6 +105,8 @@ struct i2s_stream_instance {
dma_addr_t dma_addr; dma_addr_t dma_addr;
u64 bytescount; u64 bytescount;
void __iomem *acp5x_base; void __iomem *acp5x_base;
u32 lrclk_div;
u32 bclk_div;
}; };
union acp_dma_count { union acp_dma_count {
...@@ -191,3 +193,30 @@ static inline u64 acp_get_byte_count(struct i2s_stream_instance *rtd, ...@@ -191,3 +193,30 @@ static inline u64 acp_get_byte_count(struct i2s_stream_instance *rtd,
} }
return byte_count.bytescount; return byte_count.bytescount;
} }
static inline void acp5x_set_i2s_clk(struct i2s_dev_data *adata,
struct i2s_stream_instance *rtd)
{
union acp_i2stdm_mstrclkgen mclkgen;
u32 master_reg;
switch (rtd->i2s_instance) {
case I2S_HS_INSTANCE:
master_reg = ACP_I2STDM2_MSTRCLKGEN;
break;
case I2S_SP_INSTANCE:
default:
master_reg = ACP_I2STDM0_MSTRCLKGEN;
break;
}
mclkgen.bits.i2stdm_master_mode = 0x1;
if (adata->tdm_mode)
mclkgen.bits.i2stdm_format_mode = 0x01;
else
mclkgen.bits.i2stdm_format_mode = 0x00;
mclkgen.bits.i2stdm_bclk_div_val = rtd->bclk_div;
mclkgen.bits.i2stdm_lrclk_div_val = rtd->lrclk_div;
acp_writel(mclkgen.u32_all, rtd->acp5x_base + master_reg);
}
...@@ -92,12 +92,14 @@ static int acp5x_init(void __iomem *acp5x_base) ...@@ -92,12 +92,14 @@ static int acp5x_init(void __iomem *acp5x_base)
pr_err("ACP5x power on failed\n"); pr_err("ACP5x power on failed\n");
return ret; return ret;
} }
acp_writel(0x01, acp5x_base + ACP_CONTROL);
/* Reset */ /* Reset */
ret = acp5x_reset(acp5x_base); ret = acp5x_reset(acp5x_base);
if (ret) { if (ret) {
pr_err("ACP5x reset failed\n"); pr_err("ACP5x reset failed\n");
return ret; return ret;
} }
acp_writel(0x03, acp5x_base + ACP_CLKMUX_SEL);
acp5x_enable_interrupts(acp5x_base); acp5x_enable_interrupts(acp5x_base);
return 0; return 0;
} }
...@@ -113,6 +115,8 @@ static int acp5x_deinit(void __iomem *acp5x_base) ...@@ -113,6 +115,8 @@ static int acp5x_deinit(void __iomem *acp5x_base)
pr_err("ACP5x reset failed\n"); pr_err("ACP5x reset failed\n");
return ret; return ret;
} }
acp_writel(0x00, acp5x_base + ACP_CLKMUX_SEL);
acp_writel(0x00, acp5x_base + ACP_CONTROL);
return 0; return 0;
} }
......
...@@ -573,7 +573,7 @@ static int cs35l41_main_amp_event(struct snd_soc_dapm_widget *w, ...@@ -573,7 +573,7 @@ static int cs35l41_main_amp_event(struct snd_soc_dapm_widget *w,
int ret = 0; int ret = 0;
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_PRE_PMU:
regmap_multi_reg_write_bypassed(cs35l41->regmap, regmap_multi_reg_write_bypassed(cs35l41->regmap,
cs35l41_pup_patch, cs35l41_pup_patch,
ARRAY_SIZE(cs35l41_pup_patch)); ARRAY_SIZE(cs35l41_pup_patch));
...@@ -649,7 +649,7 @@ static const struct snd_soc_dapm_widget cs35l41_dapm_widgets[] = { ...@@ -649,7 +649,7 @@ static const struct snd_soc_dapm_widget cs35l41_dapm_widgets[] = {
SND_SOC_DAPM_OUT_DRV_E("Main AMP", CS35L41_PWR_CTRL2, 0, 0, NULL, 0, SND_SOC_DAPM_OUT_DRV_E("Main AMP", CS35L41_PWR_CTRL2, 0, 0, NULL, 0,
cs35l41_main_amp_event, cs35l41_main_amp_event,
SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_PRE_PMU),
SND_SOC_DAPM_MUX("ASP TX1 Source", SND_SOC_NOPM, 0, 0, &asp_tx1_mux), SND_SOC_DAPM_MUX("ASP TX1 Source", SND_SOC_NOPM, 0, 0, &asp_tx1_mux),
SND_SOC_DAPM_MUX("ASP TX2 Source", SND_SOC_NOPM, 0, 0, &asp_tx2_mux), SND_SOC_DAPM_MUX("ASP TX2 Source", SND_SOC_NOPM, 0, 0, &asp_tx2_mux),
...@@ -1035,8 +1035,8 @@ static int cs35l41_irq_gpio_config(struct cs35l41_private *cs35l41) ...@@ -1035,8 +1035,8 @@ static int cs35l41_irq_gpio_config(struct cs35l41_private *cs35l41)
regmap_update_bits(cs35l41->regmap, CS35L41_GPIO2_CTRL1, regmap_update_bits(cs35l41->regmap, CS35L41_GPIO2_CTRL1,
CS35L41_GPIO_POL_MASK | CS35L41_GPIO_DIR_MASK, CS35L41_GPIO_POL_MASK | CS35L41_GPIO_DIR_MASK,
irq_gpio_cfg1->irq_pol_inv << CS35L41_GPIO_POL_SHIFT | irq_gpio_cfg2->irq_pol_inv << CS35L41_GPIO_POL_SHIFT |
!irq_gpio_cfg1->irq_out_en << CS35L41_GPIO_DIR_SHIFT); !irq_gpio_cfg2->irq_out_en << CS35L41_GPIO_DIR_SHIFT);
regmap_update_bits(cs35l41->regmap, CS35L41_GPIO_PAD_CONTROL, regmap_update_bits(cs35l41->regmap, CS35L41_GPIO_PAD_CONTROL,
CS35L41_GPIO1_CTRL_MASK | CS35L41_GPIO2_CTRL_MASK, CS35L41_GPIO1_CTRL_MASK | CS35L41_GPIO2_CTRL_MASK,
...@@ -1091,7 +1091,7 @@ static struct snd_soc_dai_driver cs35l41_dai[] = { ...@@ -1091,7 +1091,7 @@ static struct snd_soc_dai_driver cs35l41_dai[] = {
.capture = { .capture = {
.stream_name = "AMP Capture", .stream_name = "AMP Capture",
.channels_min = 1, .channels_min = 1,
.channels_max = 8, .channels_max = 4,
.rates = SNDRV_PCM_RATE_KNOT, .rates = SNDRV_PCM_RATE_KNOT,
.formats = CS35L41_TX_FORMATS, .formats = CS35L41_TX_FORMATS,
}, },
......
...@@ -2039,6 +2039,10 @@ static int rx_macro_load_compander_coeff(struct snd_soc_component *component, ...@@ -2039,6 +2039,10 @@ static int rx_macro_load_compander_coeff(struct snd_soc_component *component,
int i; int i;
int hph_pwr_mode; int hph_pwr_mode;
/* AUX does not have compander */
if (comp == INTERP_AUX)
return 0;
if (!rx->comp_enabled[comp]) if (!rx->comp_enabled[comp])
return 0; return 0;
...@@ -2268,7 +2272,7 @@ static int rx_macro_mux_get(struct snd_kcontrol *kcontrol, ...@@ -2268,7 +2272,7 @@ static int rx_macro_mux_get(struct snd_kcontrol *kcontrol,
struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm);
struct rx_macro *rx = snd_soc_component_get_drvdata(component); struct rx_macro *rx = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = ucontrol->value.enumerated.item[0] =
rx->rx_port_value[widget->shift]; rx->rx_port_value[widget->shift];
return 0; return 0;
} }
...@@ -2280,7 +2284,7 @@ static int rx_macro_mux_put(struct snd_kcontrol *kcontrol, ...@@ -2280,7 +2284,7 @@ static int rx_macro_mux_put(struct snd_kcontrol *kcontrol,
struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm);
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
struct snd_soc_dapm_update *update = NULL; struct snd_soc_dapm_update *update = NULL;
u32 rx_port_value = ucontrol->value.integer.value[0]; u32 rx_port_value = ucontrol->value.enumerated.item[0];
u32 aif_rst; u32 aif_rst;
struct rx_macro *rx = snd_soc_component_get_drvdata(component); struct rx_macro *rx = snd_soc_component_get_drvdata(component);
...@@ -2392,7 +2396,7 @@ static int rx_macro_get_hph_pwr_mode(struct snd_kcontrol *kcontrol, ...@@ -2392,7 +2396,7 @@ static int rx_macro_get_hph_pwr_mode(struct snd_kcontrol *kcontrol,
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct rx_macro *rx = snd_soc_component_get_drvdata(component); struct rx_macro *rx = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = rx->hph_pwr_mode; ucontrol->value.enumerated.item[0] = rx->hph_pwr_mode;
return 0; return 0;
} }
...@@ -2402,7 +2406,7 @@ static int rx_macro_put_hph_pwr_mode(struct snd_kcontrol *kcontrol, ...@@ -2402,7 +2406,7 @@ static int rx_macro_put_hph_pwr_mode(struct snd_kcontrol *kcontrol,
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct rx_macro *rx = snd_soc_component_get_drvdata(component); struct rx_macro *rx = snd_soc_component_get_drvdata(component);
rx->hph_pwr_mode = ucontrol->value.integer.value[0]; rx->hph_pwr_mode = ucontrol->value.enumerated.item[0];
return 0; return 0;
} }
......
...@@ -780,7 +780,7 @@ static int va_macro_dec_mode_get(struct snd_kcontrol *kcontrol, ...@@ -780,7 +780,7 @@ static int va_macro_dec_mode_get(struct snd_kcontrol *kcontrol,
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
int path = e->shift_l; int path = e->shift_l;
ucontrol->value.integer.value[0] = va->dec_mode[path]; ucontrol->value.enumerated.item[0] = va->dec_mode[path];
return 0; return 0;
} }
...@@ -789,7 +789,7 @@ static int va_macro_dec_mode_put(struct snd_kcontrol *kcontrol, ...@@ -789,7 +789,7 @@ static int va_macro_dec_mode_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
int value = ucontrol->value.integer.value[0]; int value = ucontrol->value.enumerated.item[0];
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
int path = e->shift_l; int path = e->shift_l;
struct va_macro *va = snd_soc_component_get_drvdata(comp); struct va_macro *va = snd_soc_component_get_drvdata(comp);
......
...@@ -814,6 +814,7 @@ static const struct snd_soc_dai_ops nau8821_dai_ops = { ...@@ -814,6 +814,7 @@ static const struct snd_soc_dai_ops nau8821_dai_ops = {
.hw_params = nau8821_hw_params, .hw_params = nau8821_hw_params,
.set_fmt = nau8821_set_dai_fmt, .set_fmt = nau8821_set_dai_fmt,
.mute_stream = nau8821_digital_mute, .mute_stream = nau8821_digital_mute,
.no_capture_mute = 1,
}; };
#define NAU8821_RATES SNDRV_PCM_RATE_8000_192000 #define NAU8821_RATES SNDRV_PCM_RATE_8000_192000
......
...@@ -822,6 +822,7 @@ static void rt5682s_jack_detect_handler(struct work_struct *work) ...@@ -822,6 +822,7 @@ static void rt5682s_jack_detect_handler(struct work_struct *work)
{ {
struct rt5682s_priv *rt5682s = struct rt5682s_priv *rt5682s =
container_of(work, struct rt5682s_priv, jack_detect_work.work); container_of(work, struct rt5682s_priv, jack_detect_work.work);
struct snd_soc_dapm_context *dapm;
int val, btn_type; int val, btn_type;
if (!rt5682s->component || !rt5682s->component->card || if (!rt5682s->component || !rt5682s->component->card ||
...@@ -832,7 +833,9 @@ static void rt5682s_jack_detect_handler(struct work_struct *work) ...@@ -832,7 +833,9 @@ static void rt5682s_jack_detect_handler(struct work_struct *work)
return; return;
} }
mutex_lock(&rt5682s->jdet_mutex); dapm = snd_soc_component_get_dapm(rt5682s->component);
snd_soc_dapm_mutex_lock(dapm);
mutex_lock(&rt5682s->calibrate_mutex); mutex_lock(&rt5682s->calibrate_mutex);
val = snd_soc_component_read(rt5682s->component, RT5682S_AJD1_CTRL) val = snd_soc_component_read(rt5682s->component, RT5682S_AJD1_CTRL)
...@@ -889,6 +892,9 @@ static void rt5682s_jack_detect_handler(struct work_struct *work) ...@@ -889,6 +892,9 @@ static void rt5682s_jack_detect_handler(struct work_struct *work)
rt5682s->irq_work_delay_time = 50; rt5682s->irq_work_delay_time = 50;
} }
mutex_unlock(&rt5682s->calibrate_mutex);
snd_soc_dapm_mutex_unlock(dapm);
snd_soc_jack_report(rt5682s->hs_jack, rt5682s->jack_type, snd_soc_jack_report(rt5682s->hs_jack, rt5682s->jack_type,
SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
SND_JACK_BTN_2 | SND_JACK_BTN_3); SND_JACK_BTN_2 | SND_JACK_BTN_3);
...@@ -898,9 +904,6 @@ static void rt5682s_jack_detect_handler(struct work_struct *work) ...@@ -898,9 +904,6 @@ static void rt5682s_jack_detect_handler(struct work_struct *work)
schedule_delayed_work(&rt5682s->jd_check_work, 0); schedule_delayed_work(&rt5682s->jd_check_work, 0);
else else
cancel_delayed_work_sync(&rt5682s->jd_check_work); cancel_delayed_work_sync(&rt5682s->jd_check_work);
mutex_unlock(&rt5682s->calibrate_mutex);
mutex_unlock(&rt5682s->jdet_mutex);
} }
static void rt5682s_jd_check_handler(struct work_struct *work) static void rt5682s_jd_check_handler(struct work_struct *work)
...@@ -908,14 +911,9 @@ static void rt5682s_jd_check_handler(struct work_struct *work) ...@@ -908,14 +911,9 @@ static void rt5682s_jd_check_handler(struct work_struct *work)
struct rt5682s_priv *rt5682s = struct rt5682s_priv *rt5682s =
container_of(work, struct rt5682s_priv, jd_check_work.work); container_of(work, struct rt5682s_priv, jd_check_work.work);
if (snd_soc_component_read(rt5682s->component, RT5682S_AJD1_CTRL) if (snd_soc_component_read(rt5682s->component, RT5682S_AJD1_CTRL) & RT5682S_JDH_RS_MASK) {
& RT5682S_JDH_RS_MASK) {
/* jack out */ /* jack out */
rt5682s->jack_type = rt5682s_headset_detect(rt5682s->component, 0); schedule_delayed_work(&rt5682s->jack_detect_work, 0);
snd_soc_jack_report(rt5682s->hs_jack, rt5682s->jack_type,
SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
SND_JACK_BTN_2 | SND_JACK_BTN_3);
} else { } else {
schedule_delayed_work(&rt5682s->jd_check_work, 500); schedule_delayed_work(&rt5682s->jd_check_work, 500);
} }
...@@ -1323,7 +1321,6 @@ static int rt5682s_hp_amp_event(struct snd_soc_dapm_widget *w, ...@@ -1323,7 +1321,6 @@ static int rt5682s_hp_amp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event) struct snd_kcontrol *kcontrol, int event)
{ {
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
...@@ -1339,8 +1336,6 @@ static int rt5682s_hp_amp_event(struct snd_soc_dapm_widget *w, ...@@ -1339,8 +1336,6 @@ static int rt5682s_hp_amp_event(struct snd_soc_dapm_widget *w,
snd_soc_component_write(component, RT5682S_BIAS_CUR_CTRL_11, 0x6666); snd_soc_component_write(component, RT5682S_BIAS_CUR_CTRL_11, 0x6666);
snd_soc_component_write(component, RT5682S_BIAS_CUR_CTRL_12, 0xa82a); snd_soc_component_write(component, RT5682S_BIAS_CUR_CTRL_12, 0xa82a);
mutex_lock(&rt5682s->jdet_mutex);
snd_soc_component_update_bits(component, RT5682S_HP_CTRL_2, snd_soc_component_update_bits(component, RT5682S_HP_CTRL_2,
RT5682S_HPO_L_PATH_MASK | RT5682S_HPO_R_PATH_MASK | RT5682S_HPO_L_PATH_MASK | RT5682S_HPO_R_PATH_MASK |
RT5682S_HPO_SEL_IP_EN_SW, RT5682S_HPO_L_PATH_EN | RT5682S_HPO_SEL_IP_EN_SW, RT5682S_HPO_L_PATH_EN |
...@@ -1348,8 +1343,6 @@ static int rt5682s_hp_amp_event(struct snd_soc_dapm_widget *w, ...@@ -1348,8 +1343,6 @@ static int rt5682s_hp_amp_event(struct snd_soc_dapm_widget *w,
usleep_range(5000, 10000); usleep_range(5000, 10000);
snd_soc_component_update_bits(component, RT5682S_HP_AMP_DET_CTL_1, snd_soc_component_update_bits(component, RT5682S_HP_AMP_DET_CTL_1,
RT5682S_CP_SW_SIZE_MASK, RT5682S_CP_SW_SIZE_L | RT5682S_CP_SW_SIZE_S); RT5682S_CP_SW_SIZE_MASK, RT5682S_CP_SW_SIZE_L | RT5682S_CP_SW_SIZE_S);
mutex_unlock(&rt5682s->jdet_mutex);
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
...@@ -3103,7 +3096,6 @@ static int rt5682s_i2c_probe(struct i2c_client *i2c, ...@@ -3103,7 +3096,6 @@ static int rt5682s_i2c_probe(struct i2c_client *i2c,
mutex_init(&rt5682s->calibrate_mutex); mutex_init(&rt5682s->calibrate_mutex);
mutex_init(&rt5682s->sar_mutex); mutex_init(&rt5682s->sar_mutex);
mutex_init(&rt5682s->jdet_mutex);
rt5682s_calibrate(rt5682s); rt5682s_calibrate(rt5682s);
regmap_update_bits(rt5682s->regmap, RT5682S_MICBIAS_2, regmap_update_bits(rt5682s->regmap, RT5682S_MICBIAS_2,
......
...@@ -1446,7 +1446,6 @@ struct rt5682s_priv { ...@@ -1446,7 +1446,6 @@ struct rt5682s_priv {
struct delayed_work jd_check_work; struct delayed_work jd_check_work;
struct mutex calibrate_mutex; struct mutex calibrate_mutex;
struct mutex sar_mutex; struct mutex sar_mutex;
struct mutex jdet_mutex;
#ifdef CONFIG_COMMON_CLK #ifdef CONFIG_COMMON_CLK
struct clk_hw dai_clks_hw[RT5682S_DAI_NUM_CLKS]; struct clk_hw dai_clks_hw[RT5682S_DAI_NUM_CLKS];
......
...@@ -1111,6 +1111,7 @@ static int adc3xxx_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) ...@@ -1111,6 +1111,7 @@ static int adc3xxx_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
struct adc3xxx *adc3xxx = snd_soc_component_get_drvdata(component); struct adc3xxx *adc3xxx = snd_soc_component_get_drvdata(component);
u8 clkdir = 0, format = 0; u8 clkdir = 0, format = 0;
int master = 0; int master = 0;
int ret;
/* set master/slave audio interface */ /* set master/slave audio interface */
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
...@@ -1161,10 +1162,13 @@ static int adc3xxx_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) ...@@ -1161,10 +1162,13 @@ static int adc3xxx_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
adc3xxx->master = master; adc3xxx->master = master;
/* set clock direction and format */ /* set clock direction and format */
return snd_soc_component_update_bits(component, ret = snd_soc_component_update_bits(component,
ADC3XXX_INTERFACE_CTRL_1, ADC3XXX_INTERFACE_CTRL_1,
ADC3XXX_CLKDIR_MASK | ADC3XXX_FORMAT_MASK, ADC3XXX_CLKDIR_MASK | ADC3XXX_FORMAT_MASK,
clkdir | format); clkdir | format);
if (ret < 0)
return ret;
return 0;
} }
static const struct snd_soc_dai_ops adc3xxx_dai_ops = { static const struct snd_soc_dai_ops adc3xxx_dai_ops = {
......
...@@ -3023,14 +3023,14 @@ static int wcd934x_hph_impedance_get(struct snd_kcontrol *kcontrol, ...@@ -3023,14 +3023,14 @@ static int wcd934x_hph_impedance_get(struct snd_kcontrol *kcontrol,
return 0; return 0;
} }
static const struct snd_kcontrol_new hph_type_detect_controls[] = { static const struct snd_kcontrol_new hph_type_detect_controls[] = {
SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0, SOC_SINGLE_EXT("HPH Type", 0, 0, WCD_MBHC_HPH_STEREO, 0,
wcd934x_get_hph_type, NULL), wcd934x_get_hph_type, NULL),
}; };
static const struct snd_kcontrol_new impedance_detect_controls[] = { static const struct snd_kcontrol_new impedance_detect_controls[] = {
SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0, SOC_SINGLE_EXT("HPHL Impedance", 0, 0, INT_MAX, 0,
wcd934x_hph_impedance_get, NULL), wcd934x_hph_impedance_get, NULL),
SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0, SOC_SINGLE_EXT("HPHR Impedance", 0, 1, INT_MAX, 0,
wcd934x_hph_impedance_get, NULL), wcd934x_hph_impedance_get, NULL),
}; };
...@@ -3308,13 +3308,16 @@ static int wcd934x_rx_hph_mode_put(struct snd_kcontrol *kc, ...@@ -3308,13 +3308,16 @@ static int wcd934x_rx_hph_mode_put(struct snd_kcontrol *kc,
mode_val = ucontrol->value.enumerated.item[0]; mode_val = ucontrol->value.enumerated.item[0];
if (mode_val == wcd->hph_mode)
return 0;
if (mode_val == 0) { if (mode_val == 0) {
dev_err(wcd->dev, "Invalid HPH Mode, default to ClSH HiFi\n"); dev_err(wcd->dev, "Invalid HPH Mode, default to ClSH HiFi\n");
mode_val = CLS_H_LOHIFI; mode_val = CLS_H_LOHIFI;
} }
wcd->hph_mode = mode_val; wcd->hph_mode = mode_val;
return 0; return 1;
} }
static int slim_rx_mux_get(struct snd_kcontrol *kc, static int slim_rx_mux_get(struct snd_kcontrol *kc,
......
...@@ -2504,7 +2504,7 @@ static int wcd938x_tx_mode_get(struct snd_kcontrol *kcontrol, ...@@ -2504,7 +2504,7 @@ static int wcd938x_tx_mode_get(struct snd_kcontrol *kcontrol,
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
int path = e->shift_l; int path = e->shift_l;
ucontrol->value.integer.value[0] = wcd938x->tx_mode[path]; ucontrol->value.enumerated.item[0] = wcd938x->tx_mode[path];
return 0; return 0;
} }
...@@ -2528,7 +2528,7 @@ static int wcd938x_rx_hph_mode_get(struct snd_kcontrol *kcontrol, ...@@ -2528,7 +2528,7 @@ static int wcd938x_rx_hph_mode_get(struct snd_kcontrol *kcontrol,
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = wcd938x->hph_mode; ucontrol->value.enumerated.item[0] = wcd938x->hph_mode;
return 0; return 0;
} }
...@@ -3575,14 +3575,14 @@ static int wcd938x_hph_impedance_get(struct snd_kcontrol *kcontrol, ...@@ -3575,14 +3575,14 @@ static int wcd938x_hph_impedance_get(struct snd_kcontrol *kcontrol,
} }
static const struct snd_kcontrol_new hph_type_detect_controls[] = { static const struct snd_kcontrol_new hph_type_detect_controls[] = {
SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0, SOC_SINGLE_EXT("HPH Type", 0, 0, WCD_MBHC_HPH_STEREO, 0,
wcd938x_get_hph_type, NULL), wcd938x_get_hph_type, NULL),
}; };
static const struct snd_kcontrol_new impedance_detect_controls[] = { static const struct snd_kcontrol_new impedance_detect_controls[] = {
SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0, SOC_SINGLE_EXT("HPHL Impedance", 0, 0, INT_MAX, 0,
wcd938x_hph_impedance_get, NULL), wcd938x_hph_impedance_get, NULL),
SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0, SOC_SINGLE_EXT("HPHR Impedance", 0, 1, INT_MAX, 0,
wcd938x_hph_impedance_get, NULL), wcd938x_hph_impedance_get, NULL),
}; };
......
...@@ -127,7 +127,7 @@ static const struct snd_soc_acpi_codecs rt5640_comp_ids = { ...@@ -127,7 +127,7 @@ static const struct snd_soc_acpi_codecs rt5640_comp_ids = {
static const struct snd_soc_acpi_codecs wm5102_comp_ids = { static const struct snd_soc_acpi_codecs wm5102_comp_ids = {
.num_codecs = 2, .num_codecs = 2,
.codecs = { "WM510204", "WM510205"}, .codecs = { "10WM5102", "WM510204", "WM510205"},
}; };
static const struct snd_soc_acpi_codecs da7213_comp_ids = { static const struct snd_soc_acpi_codecs da7213_comp_ids = {
......
...@@ -47,7 +47,7 @@ static struct hdac_ext_stream *cl_stream_prepare(struct snd_sof_dev *sdev, unsig ...@@ -47,7 +47,7 @@ static struct hdac_ext_stream *cl_stream_prepare(struct snd_sof_dev *sdev, unsig
ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV_SG, &pci->dev, size, dmab); ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV_SG, &pci->dev, size, dmab);
if (ret < 0) { if (ret < 0) {
dev_err(sdev->dev, "error: memory alloc failed: %d\n", ret); dev_err(sdev->dev, "error: memory alloc failed: %d\n", ret);
goto error; goto out_put;
} }
hstream->period_bytes = 0;/* initialize period_bytes */ hstream->period_bytes = 0;/* initialize period_bytes */
...@@ -58,22 +58,23 @@ static struct hdac_ext_stream *cl_stream_prepare(struct snd_sof_dev *sdev, unsig ...@@ -58,22 +58,23 @@ static struct hdac_ext_stream *cl_stream_prepare(struct snd_sof_dev *sdev, unsig
ret = hda_dsp_iccmax_stream_hw_params(sdev, dsp_stream, dmab, NULL); ret = hda_dsp_iccmax_stream_hw_params(sdev, dsp_stream, dmab, NULL);
if (ret < 0) { if (ret < 0) {
dev_err(sdev->dev, "error: iccmax stream prepare failed: %d\n", ret); dev_err(sdev->dev, "error: iccmax stream prepare failed: %d\n", ret);
goto error; goto out_free;
} }
} else { } else {
ret = hda_dsp_stream_hw_params(sdev, dsp_stream, dmab, NULL); ret = hda_dsp_stream_hw_params(sdev, dsp_stream, dmab, NULL);
if (ret < 0) { if (ret < 0) {
dev_err(sdev->dev, "error: hdac prepare failed: %d\n", ret); dev_err(sdev->dev, "error: hdac prepare failed: %d\n", ret);
goto error; goto out_free;
} }
hda_dsp_stream_spib_config(sdev, dsp_stream, HDA_DSP_SPIB_ENABLE, size); hda_dsp_stream_spib_config(sdev, dsp_stream, HDA_DSP_SPIB_ENABLE, size);
} }
return dsp_stream; return dsp_stream;
error: out_free:
hda_dsp_stream_put(sdev, direction, hstream->stream_tag);
snd_dma_free_pages(dmab); snd_dma_free_pages(dmab);
out_put:
hda_dsp_stream_put(sdev, direction, hstream->stream_tag);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment