Skip to content

Commit 8b974c1

Browse files
committed
ASoC: Merge fixes
So we can send to Linus.
2 parents cc5c978 + 30e693e commit 8b974c1

File tree

12 files changed

+157
-77
lines changed

12 files changed

+157
-77
lines changed

sound/soc/codecs/rt5682.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,8 @@ int rt5682_headset_detect(struct snd_soc_component *component, int jack_insert)
929929
unsigned int val, count;
930930

931931
if (jack_insert) {
932+
snd_soc_dapm_mutex_lock(dapm);
933+
932934
snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1,
933935
RT5682_PWR_VREF2 | RT5682_PWR_MB,
934936
RT5682_PWR_VREF2 | RT5682_PWR_MB);
@@ -979,6 +981,8 @@ int rt5682_headset_detect(struct snd_soc_component *component, int jack_insert)
979981
snd_soc_component_update_bits(component, RT5682_MICBIAS_2,
980982
RT5682_PWR_CLK25M_MASK | RT5682_PWR_CLK1M_MASK,
981983
RT5682_PWR_CLK25M_PU | RT5682_PWR_CLK1M_PU);
984+
985+
snd_soc_dapm_mutex_unlock(dapm);
982986
} else {
983987
rt5682_enable_push_button_irq(component, false);
984988
snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,

sound/soc/codecs/tas2770.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,11 @@ static int tas2770_set_samplerate(struct tas2770_priv *tas2770, int samplerate)
291291
ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_44_1KHZ |
292292
TAS2770_TDM_CFG_REG0_31_88_2_96KHZ;
293293
break;
294-
case 19200:
294+
case 192000:
295295
ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_48KHZ |
296296
TAS2770_TDM_CFG_REG0_31_176_4_192KHZ;
297297
break;
298-
case 17640:
298+
case 176400:
299299
ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_44_1KHZ |
300300
TAS2770_TDM_CFG_REG0_31_176_4_192KHZ;
301301
break;

sound/soc/codecs/wcd934x.c

Lines changed: 93 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3256,6 +3256,9 @@ static int wcd934x_compander_set(struct snd_kcontrol *kc,
32563256
int value = ucontrol->value.integer.value[0];
32573257
int sel;
32583258

3259+
if (wcd->comp_enabled[comp] == value)
3260+
return 0;
3261+
32593262
wcd->comp_enabled[comp] = value;
32603263
sel = value ? WCD934X_HPH_GAIN_SRC_SEL_COMPANDER :
32613264
WCD934X_HPH_GAIN_SRC_SEL_REGISTER;
@@ -3279,10 +3282,10 @@ static int wcd934x_compander_set(struct snd_kcontrol *kc,
32793282
case COMPANDER_8:
32803283
break;
32813284
default:
3282-
break;
3285+
return 0;
32833286
}
32843287

3285-
return 0;
3288+
return 1;
32863289
}
32873290

32883291
static int wcd934x_rx_hph_mode_get(struct snd_kcontrol *kc,
@@ -3326,50 +3329,91 @@ static int slim_rx_mux_get(struct snd_kcontrol *kc,
33263329
return 0;
33273330
}
33283331

3332+
static int slim_rx_mux_to_dai_id(int mux)
3333+
{
3334+
int aif_id;
3335+
3336+
switch (mux) {
3337+
case 1:
3338+
aif_id = AIF1_PB;
3339+
break;
3340+
case 2:
3341+
aif_id = AIF2_PB;
3342+
break;
3343+
case 3:
3344+
aif_id = AIF3_PB;
3345+
break;
3346+
case 4:
3347+
aif_id = AIF4_PB;
3348+
break;
3349+
default:
3350+
aif_id = -1;
3351+
break;
3352+
}
3353+
3354+
return aif_id;
3355+
}
3356+
33293357
static int slim_rx_mux_put(struct snd_kcontrol *kc,
33303358
struct snd_ctl_elem_value *ucontrol)
33313359
{
33323360
struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_widget(kc);
33333361
struct wcd934x_codec *wcd = dev_get_drvdata(w->dapm->dev);
33343362
struct soc_enum *e = (struct soc_enum *)kc->private_value;
33353363
struct snd_soc_dapm_update *update = NULL;
3364+
struct wcd934x_slim_ch *ch, *c;
33363365
u32 port_id = w->shift;
3366+
bool found = false;
3367+
int mux_idx;
3368+
int prev_mux_idx = wcd->rx_port_value[port_id];
3369+
int aif_id;
33373370

3338-
if (wcd->rx_port_value[port_id] == ucontrol->value.enumerated.item[0])
3339-
return 0;
3371+
mux_idx = ucontrol->value.enumerated.item[0];
33403372

3341-
wcd->rx_port_value[port_id] = ucontrol->value.enumerated.item[0];
3373+
if (mux_idx == prev_mux_idx)
3374+
return 0;
33423375

3343-
switch (wcd->rx_port_value[port_id]) {
3376+
switch(mux_idx) {
33443377
case 0:
3345-
list_del_init(&wcd->rx_chs[port_id].list);
3346-
break;
3347-
case 1:
3348-
list_add_tail(&wcd->rx_chs[port_id].list,
3349-
&wcd->dai[AIF1_PB].slim_ch_list);
3350-
break;
3351-
case 2:
3352-
list_add_tail(&wcd->rx_chs[port_id].list,
3353-
&wcd->dai[AIF2_PB].slim_ch_list);
3354-
break;
3355-
case 3:
3356-
list_add_tail(&wcd->rx_chs[port_id].list,
3357-
&wcd->dai[AIF3_PB].slim_ch_list);
3378+
aif_id = slim_rx_mux_to_dai_id(prev_mux_idx);
3379+
if (aif_id < 0)
3380+
return 0;
3381+
3382+
list_for_each_entry_safe(ch, c, &wcd->dai[aif_id].slim_ch_list, list) {
3383+
if (ch->port == port_id + WCD934X_RX_START) {
3384+
found = true;
3385+
list_del_init(&ch->list);
3386+
break;
3387+
}
3388+
}
3389+
if (!found)
3390+
return 0;
3391+
33583392
break;
3359-
case 4:
3360-
list_add_tail(&wcd->rx_chs[port_id].list,
3361-
&wcd->dai[AIF4_PB].slim_ch_list);
3393+
case 1 ... 4:
3394+
aif_id = slim_rx_mux_to_dai_id(mux_idx);
3395+
if (aif_id < 0)
3396+
return 0;
3397+
3398+
if (list_empty(&wcd->rx_chs[port_id].list)) {
3399+
list_add_tail(&wcd->rx_chs[port_id].list,
3400+
&wcd->dai[aif_id].slim_ch_list);
3401+
} else {
3402+
dev_err(wcd->dev ,"SLIM_RX%d PORT is busy\n", port_id);
3403+
return 0;
3404+
}
33623405
break;
3406+
33633407
default:
3364-
dev_err(wcd->dev, "Unknown AIF %d\n",
3365-
wcd->rx_port_value[port_id]);
3408+
dev_err(wcd->dev, "Unknown AIF %d\n", mux_idx);
33663409
goto err;
33673410
}
33683411

3412+
wcd->rx_port_value[port_id] = mux_idx;
33693413
snd_soc_dapm_mux_update_power(w->dapm, kc, wcd->rx_port_value[port_id],
33703414
e, update);
33713415

3372-
return 0;
3416+
return 1;
33733417
err:
33743418
return -EINVAL;
33753419
}
@@ -3813,24 +3857,40 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kc,
38133857
struct soc_mixer_control *mixer =
38143858
(struct soc_mixer_control *)kc->private_value;
38153859
int enable = ucontrol->value.integer.value[0];
3860+
struct wcd934x_slim_ch *ch, *c;
38163861
int dai_id = widget->shift;
38173862
int port_id = mixer->shift;
38183863

38193864
/* only add to the list if value not set */
38203865
if (enable == wcd->tx_port_value[port_id])
38213866
return 0;
38223867

3823-
wcd->tx_port_value[port_id] = enable;
3824-
3825-
if (enable)
3826-
list_add_tail(&wcd->tx_chs[port_id].list,
3827-
&wcd->dai[dai_id].slim_ch_list);
3828-
else
3829-
list_del_init(&wcd->tx_chs[port_id].list);
3868+
if (enable) {
3869+
if (list_empty(&wcd->tx_chs[port_id].list)) {
3870+
list_add_tail(&wcd->tx_chs[port_id].list,
3871+
&wcd->dai[dai_id].slim_ch_list);
3872+
} else {
3873+
dev_err(wcd->dev ,"SLIM_TX%d PORT is busy\n", port_id);
3874+
return 0;
3875+
}
3876+
} else {
3877+
bool found = false;
3878+
3879+
list_for_each_entry_safe(ch, c, &wcd->dai[dai_id].slim_ch_list, list) {
3880+
if (ch->port == port_id) {
3881+
found = true;
3882+
list_del_init(&wcd->tx_chs[port_id].list);
3883+
break;
3884+
}
3885+
}
3886+
if (!found)
3887+
return 0;
3888+
}
38303889

3890+
wcd->tx_port_value[port_id] = enable;
38313891
snd_soc_dapm_mixer_update_power(widget->dapm, kc, enable, update);
38323892

3833-
return 0;
3893+
return 1;
38343894
}
38353895

38363896
static const struct snd_kcontrol_new aif1_slim_cap_mixer[] = {

sound/soc/codecs/wsa881x.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,8 @@ static int wsa881x_put_pa_gain(struct snd_kcontrol *kc,
772772

773773
usleep_range(1000, 1010);
774774
}
775-
return 0;
775+
776+
return 1;
776777
}
777778

778779
static int wsa881x_get_port(struct snd_kcontrol *kcontrol,
@@ -816,15 +817,22 @@ static int wsa881x_set_port(struct snd_kcontrol *kcontrol,
816817
(struct soc_mixer_control *)kcontrol->private_value;
817818
int portidx = mixer->reg;
818819

819-
if (ucontrol->value.integer.value[0])
820+
if (ucontrol->value.integer.value[0]) {
821+
if (data->port_enable[portidx])
822+
return 0;
823+
820824
data->port_enable[portidx] = true;
821-
else
825+
} else {
826+
if (!data->port_enable[portidx])
827+
return 0;
828+
822829
data->port_enable[portidx] = false;
830+
}
823831

824832
if (portidx == WSA881X_PORT_BOOST) /* Boost Switch */
825833
wsa881x_boost_ctrl(comp, data->port_enable[portidx]);
826834

827-
return 0;
835+
return 1;
828836
}
829837

830838
static const char * const smart_boost_lvl_text[] = {

sound/soc/mediatek/mt8195/mt8195-afe-pcm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3029,7 +3029,7 @@ static const struct reg_sequence mt8195_afe_reg_defaults[] = {
30293029

30303030
static const struct reg_sequence mt8195_cg_patch[] = {
30313031
{ AUDIO_TOP_CON0, 0xfffffffb },
3032-
{ AUDIO_TOP_CON1, 0xfffffffa },
3032+
{ AUDIO_TOP_CON1, 0xfffffff8 },
30333033
};
30343034

30353035
static int mt8195_afe_init_registers(struct mtk_base_afe *afe)

sound/soc/meson/aiu-encoder-i2s.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#define AIU_RST_SOFT_I2S_FAST BIT(0)
1919

2020
#define AIU_I2S_DAC_CFG_MSB_FIRST BIT(2)
21-
#define AIU_I2S_MISC_HOLD_EN BIT(2)
2221
#define AIU_CLK_CTRL_I2S_DIV_EN BIT(0)
2322
#define AIU_CLK_CTRL_I2S_DIV GENMASK(3, 2)
2423
#define AIU_CLK_CTRL_AOCLK_INVERT BIT(6)
@@ -36,37 +35,6 @@ static void aiu_encoder_i2s_divider_enable(struct snd_soc_component *component,
3635
enable ? AIU_CLK_CTRL_I2S_DIV_EN : 0);
3736
}
3837

39-
static void aiu_encoder_i2s_hold(struct snd_soc_component *component,
40-
bool enable)
41-
{
42-
snd_soc_component_update_bits(component, AIU_I2S_MISC,
43-
AIU_I2S_MISC_HOLD_EN,
44-
enable ? AIU_I2S_MISC_HOLD_EN : 0);
45-
}
46-
47-
static int aiu_encoder_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
48-
struct snd_soc_dai *dai)
49-
{
50-
struct snd_soc_component *component = dai->component;
51-
52-
switch (cmd) {
53-
case SNDRV_PCM_TRIGGER_START:
54-
case SNDRV_PCM_TRIGGER_RESUME:
55-
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
56-
aiu_encoder_i2s_hold(component, false);
57-
return 0;
58-
59-
case SNDRV_PCM_TRIGGER_STOP:
60-
case SNDRV_PCM_TRIGGER_SUSPEND:
61-
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
62-
aiu_encoder_i2s_hold(component, true);
63-
return 0;
64-
65-
default:
66-
return -EINVAL;
67-
}
68-
}
69-
7038
static int aiu_encoder_i2s_setup_desc(struct snd_soc_component *component,
7139
struct snd_pcm_hw_params *params)
7240
{
@@ -353,7 +321,6 @@ static void aiu_encoder_i2s_shutdown(struct snd_pcm_substream *substream,
353321
}
354322

355323
const struct snd_soc_dai_ops aiu_encoder_i2s_dai_ops = {
356-
.trigger = aiu_encoder_i2s_trigger,
357324
.hw_params = aiu_encoder_i2s_hw_params,
358325
.hw_free = aiu_encoder_i2s_hw_free,
359326
.set_fmt = aiu_encoder_i2s_set_fmt,

sound/soc/meson/aiu-fifo-i2s.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#define AIU_MEM_I2S_CONTROL_MODE_16BIT BIT(6)
2121
#define AIU_MEM_I2S_BUF_CNTL_INIT BIT(0)
2222
#define AIU_RST_SOFT_I2S_FAST BIT(0)
23+
#define AIU_I2S_MISC_HOLD_EN BIT(2)
24+
#define AIU_I2S_MISC_FORCE_LEFT_RIGHT BIT(4)
2325

2426
#define AIU_FIFO_I2S_BLOCK 256
2527

@@ -90,6 +92,10 @@ static int aiu_fifo_i2s_hw_params(struct snd_pcm_substream *substream,
9092
unsigned int val;
9193
int ret;
9294

95+
snd_soc_component_update_bits(component, AIU_I2S_MISC,
96+
AIU_I2S_MISC_HOLD_EN,
97+
AIU_I2S_MISC_HOLD_EN);
98+
9399
ret = aiu_fifo_hw_params(substream, params, dai);
94100
if (ret)
95101
return ret;
@@ -117,6 +123,19 @@ static int aiu_fifo_i2s_hw_params(struct snd_pcm_substream *substream,
117123
snd_soc_component_update_bits(component, AIU_MEM_I2S_MASKS,
118124
AIU_MEM_I2S_MASKS_IRQ_BLOCK, val);
119125

126+
/*
127+
* Most (all?) supported SoCs have this bit set by default. The vendor
128+
* driver however sets it manually (depending on the version either
129+
* while un-setting AIU_I2S_MISC_HOLD_EN or right before that). Follow
130+
* the same approach for consistency with the vendor driver.
131+
*/
132+
snd_soc_component_update_bits(component, AIU_I2S_MISC,
133+
AIU_I2S_MISC_FORCE_LEFT_RIGHT,
134+
AIU_I2S_MISC_FORCE_LEFT_RIGHT);
135+
136+
snd_soc_component_update_bits(component, AIU_I2S_MISC,
137+
AIU_I2S_MISC_HOLD_EN, 0);
138+
120139
return 0;
121140
}
122141

sound/soc/meson/aiu-fifo.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <linux/bitfield.h>
77
#include <linux/clk.h>
8+
#include <linux/dma-mapping.h>
89
#include <sound/pcm_params.h>
910
#include <sound/soc.h>
1011
#include <sound/soc-dai.h>
@@ -179,6 +180,11 @@ int aiu_fifo_pcm_new(struct snd_soc_pcm_runtime *rtd,
179180
struct snd_card *card = rtd->card->snd_card;
180181
struct aiu_fifo *fifo = dai->playback_dma_data;
181182
size_t size = fifo->pcm->buffer_bytes_max;
183+
int ret;
184+
185+
ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
186+
if (ret)
187+
return ret;
182188

183189
snd_pcm_set_managed_buffer_all(rtd->pcm, SNDRV_DMA_TYPE_DEV,
184190
card->dev, size, size);

sound/soc/qcom/qdsp6/q6routing.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,14 +498,16 @@ static int msm_routing_put_audio_mixer(struct snd_kcontrol *kcontrol,
498498
struct session_data *session = &data->sessions[session_id];
499499

500500
if (ucontrol->value.integer.value[0]) {
501+
if (session->port_id == be_id)
502+
return 0;
503+
501504
session->port_id = be_id;
502505
snd_soc_dapm_mixer_update_power(dapm, kcontrol, 1, update);
503506
} else {
504-
if (session->port_id == be_id) {
505-
session->port_id = -1;
507+
if (session->port_id == -1 || session->port_id != be_id)
506508
return 0;
507-
}
508509

510+
session->port_id = -1;
509511
snd_soc_dapm_mixer_update_power(dapm, kcontrol, 0, update);
510512
}
511513

0 commit comments

Comments
 (0)