Skip to content

Commit

Permalink
ASoC: Merge fixes
Browse files Browse the repository at this point in the history
So we can send to Linus.
  • Loading branch information
Mark Brown committed Dec 31, 2021
2 parents cc5c978 + 30e693e commit 8b974c1
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 77 deletions.
4 changes: 4 additions & 0 deletions sound/soc/codecs/rt5682.c
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,8 @@ int rt5682_headset_detect(struct snd_soc_component *component, int jack_insert)
unsigned int val, count;

if (jack_insert) {
snd_soc_dapm_mutex_lock(dapm);

snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1,
RT5682_PWR_VREF2 | RT5682_PWR_MB,
RT5682_PWR_VREF2 | RT5682_PWR_MB);
Expand Down Expand Up @@ -979,6 +981,8 @@ int rt5682_headset_detect(struct snd_soc_component *component, int jack_insert)
snd_soc_component_update_bits(component, RT5682_MICBIAS_2,
RT5682_PWR_CLK25M_MASK | RT5682_PWR_CLK1M_MASK,
RT5682_PWR_CLK25M_PU | RT5682_PWR_CLK1M_PU);

snd_soc_dapm_mutex_unlock(dapm);
} else {
rt5682_enable_push_button_irq(component, false);
snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
Expand Down
4 changes: 2 additions & 2 deletions sound/soc/codecs/tas2770.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,11 @@ static int tas2770_set_samplerate(struct tas2770_priv *tas2770, int samplerate)
ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_44_1KHZ |
TAS2770_TDM_CFG_REG0_31_88_2_96KHZ;
break;
case 19200:
case 192000:
ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_48KHZ |
TAS2770_TDM_CFG_REG0_31_176_4_192KHZ;
break;
case 17640:
case 176400:
ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_44_1KHZ |
TAS2770_TDM_CFG_REG0_31_176_4_192KHZ;
break;
Expand Down
126 changes: 93 additions & 33 deletions sound/soc/codecs/wcd934x.c
Original file line number Diff line number Diff line change
Expand Up @@ -3256,6 +3256,9 @@ static int wcd934x_compander_set(struct snd_kcontrol *kc,
int value = ucontrol->value.integer.value[0];
int sel;

if (wcd->comp_enabled[comp] == value)
return 0;

wcd->comp_enabled[comp] = value;
sel = value ? WCD934X_HPH_GAIN_SRC_SEL_COMPANDER :
WCD934X_HPH_GAIN_SRC_SEL_REGISTER;
Expand All @@ -3279,10 +3282,10 @@ static int wcd934x_compander_set(struct snd_kcontrol *kc,
case COMPANDER_8:
break;
default:
break;
return 0;
}

return 0;
return 1;
}

static int wcd934x_rx_hph_mode_get(struct snd_kcontrol *kc,
Expand Down Expand Up @@ -3326,50 +3329,91 @@ static int slim_rx_mux_get(struct snd_kcontrol *kc,
return 0;
}

static int slim_rx_mux_to_dai_id(int mux)
{
int aif_id;

switch (mux) {
case 1:
aif_id = AIF1_PB;
break;
case 2:
aif_id = AIF2_PB;
break;
case 3:
aif_id = AIF3_PB;
break;
case 4:
aif_id = AIF4_PB;
break;
default:
aif_id = -1;
break;
}

return aif_id;
}

static int slim_rx_mux_put(struct snd_kcontrol *kc,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_widget(kc);
struct wcd934x_codec *wcd = dev_get_drvdata(w->dapm->dev);
struct soc_enum *e = (struct soc_enum *)kc->private_value;
struct snd_soc_dapm_update *update = NULL;
struct wcd934x_slim_ch *ch, *c;
u32 port_id = w->shift;
bool found = false;
int mux_idx;
int prev_mux_idx = wcd->rx_port_value[port_id];
int aif_id;

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

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

switch (wcd->rx_port_value[port_id]) {
switch(mux_idx) {
case 0:
list_del_init(&wcd->rx_chs[port_id].list);
break;
case 1:
list_add_tail(&wcd->rx_chs[port_id].list,
&wcd->dai[AIF1_PB].slim_ch_list);
break;
case 2:
list_add_tail(&wcd->rx_chs[port_id].list,
&wcd->dai[AIF2_PB].slim_ch_list);
break;
case 3:
list_add_tail(&wcd->rx_chs[port_id].list,
&wcd->dai[AIF3_PB].slim_ch_list);
aif_id = slim_rx_mux_to_dai_id(prev_mux_idx);
if (aif_id < 0)
return 0;

list_for_each_entry_safe(ch, c, &wcd->dai[aif_id].slim_ch_list, list) {
if (ch->port == port_id + WCD934X_RX_START) {
found = true;
list_del_init(&ch->list);
break;
}
}
if (!found)
return 0;

break;
case 4:
list_add_tail(&wcd->rx_chs[port_id].list,
&wcd->dai[AIF4_PB].slim_ch_list);
case 1 ... 4:
aif_id = slim_rx_mux_to_dai_id(mux_idx);
if (aif_id < 0)
return 0;

if (list_empty(&wcd->rx_chs[port_id].list)) {
list_add_tail(&wcd->rx_chs[port_id].list,
&wcd->dai[aif_id].slim_ch_list);
} else {
dev_err(wcd->dev ,"SLIM_RX%d PORT is busy\n", port_id);
return 0;
}
break;

default:
dev_err(wcd->dev, "Unknown AIF %d\n",
wcd->rx_port_value[port_id]);
dev_err(wcd->dev, "Unknown AIF %d\n", mux_idx);
goto err;
}

wcd->rx_port_value[port_id] = mux_idx;
snd_soc_dapm_mux_update_power(w->dapm, kc, wcd->rx_port_value[port_id],
e, update);

return 0;
return 1;
err:
return -EINVAL;
}
Expand Down Expand Up @@ -3813,24 +3857,40 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kc,
struct soc_mixer_control *mixer =
(struct soc_mixer_control *)kc->private_value;
int enable = ucontrol->value.integer.value[0];
struct wcd934x_slim_ch *ch, *c;
int dai_id = widget->shift;
int port_id = mixer->shift;

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

wcd->tx_port_value[port_id] = enable;

if (enable)
list_add_tail(&wcd->tx_chs[port_id].list,
&wcd->dai[dai_id].slim_ch_list);
else
list_del_init(&wcd->tx_chs[port_id].list);
if (enable) {
if (list_empty(&wcd->tx_chs[port_id].list)) {
list_add_tail(&wcd->tx_chs[port_id].list,
&wcd->dai[dai_id].slim_ch_list);
} else {
dev_err(wcd->dev ,"SLIM_TX%d PORT is busy\n", port_id);
return 0;
}
} else {
bool found = false;

list_for_each_entry_safe(ch, c, &wcd->dai[dai_id].slim_ch_list, list) {
if (ch->port == port_id) {
found = true;
list_del_init(&wcd->tx_chs[port_id].list);
break;
}
}
if (!found)
return 0;
}

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

return 0;
return 1;
}

static const struct snd_kcontrol_new aif1_slim_cap_mixer[] = {
Expand Down
16 changes: 12 additions & 4 deletions sound/soc/codecs/wsa881x.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,8 @@ static int wsa881x_put_pa_gain(struct snd_kcontrol *kc,

usleep_range(1000, 1010);
}
return 0;

return 1;
}

static int wsa881x_get_port(struct snd_kcontrol *kcontrol,
Expand Down Expand Up @@ -816,15 +817,22 @@ static int wsa881x_set_port(struct snd_kcontrol *kcontrol,
(struct soc_mixer_control *)kcontrol->private_value;
int portidx = mixer->reg;

if (ucontrol->value.integer.value[0])
if (ucontrol->value.integer.value[0]) {
if (data->port_enable[portidx])
return 0;

data->port_enable[portidx] = true;
else
} else {
if (!data->port_enable[portidx])
return 0;

data->port_enable[portidx] = false;
}

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

return 0;
return 1;
}

static const char * const smart_boost_lvl_text[] = {
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/mediatek/mt8195/mt8195-afe-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3029,7 +3029,7 @@ static const struct reg_sequence mt8195_afe_reg_defaults[] = {

static const struct reg_sequence mt8195_cg_patch[] = {
{ AUDIO_TOP_CON0, 0xfffffffb },
{ AUDIO_TOP_CON1, 0xfffffffa },
{ AUDIO_TOP_CON1, 0xfffffff8 },
};

static int mt8195_afe_init_registers(struct mtk_base_afe *afe)
Expand Down
33 changes: 0 additions & 33 deletions sound/soc/meson/aiu-encoder-i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#define AIU_RST_SOFT_I2S_FAST BIT(0)

#define AIU_I2S_DAC_CFG_MSB_FIRST BIT(2)
#define AIU_I2S_MISC_HOLD_EN BIT(2)
#define AIU_CLK_CTRL_I2S_DIV_EN BIT(0)
#define AIU_CLK_CTRL_I2S_DIV GENMASK(3, 2)
#define AIU_CLK_CTRL_AOCLK_INVERT BIT(6)
Expand All @@ -36,37 +35,6 @@ static void aiu_encoder_i2s_divider_enable(struct snd_soc_component *component,
enable ? AIU_CLK_CTRL_I2S_DIV_EN : 0);
}

static void aiu_encoder_i2s_hold(struct snd_soc_component *component,
bool enable)
{
snd_soc_component_update_bits(component, AIU_I2S_MISC,
AIU_I2S_MISC_HOLD_EN,
enable ? AIU_I2S_MISC_HOLD_EN : 0);
}

static int aiu_encoder_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;

switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
aiu_encoder_i2s_hold(component, false);
return 0;

case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
aiu_encoder_i2s_hold(component, true);
return 0;

default:
return -EINVAL;
}
}

static int aiu_encoder_i2s_setup_desc(struct snd_soc_component *component,
struct snd_pcm_hw_params *params)
{
Expand Down Expand Up @@ -353,7 +321,6 @@ static void aiu_encoder_i2s_shutdown(struct snd_pcm_substream *substream,
}

const struct snd_soc_dai_ops aiu_encoder_i2s_dai_ops = {
.trigger = aiu_encoder_i2s_trigger,
.hw_params = aiu_encoder_i2s_hw_params,
.hw_free = aiu_encoder_i2s_hw_free,
.set_fmt = aiu_encoder_i2s_set_fmt,
Expand Down
19 changes: 19 additions & 0 deletions sound/soc/meson/aiu-fifo-i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#define AIU_MEM_I2S_CONTROL_MODE_16BIT BIT(6)
#define AIU_MEM_I2S_BUF_CNTL_INIT BIT(0)
#define AIU_RST_SOFT_I2S_FAST BIT(0)
#define AIU_I2S_MISC_HOLD_EN BIT(2)
#define AIU_I2S_MISC_FORCE_LEFT_RIGHT BIT(4)

#define AIU_FIFO_I2S_BLOCK 256

Expand Down Expand Up @@ -90,6 +92,10 @@ static int aiu_fifo_i2s_hw_params(struct snd_pcm_substream *substream,
unsigned int val;
int ret;

snd_soc_component_update_bits(component, AIU_I2S_MISC,
AIU_I2S_MISC_HOLD_EN,
AIU_I2S_MISC_HOLD_EN);

ret = aiu_fifo_hw_params(substream, params, dai);
if (ret)
return ret;
Expand Down Expand Up @@ -117,6 +123,19 @@ static int aiu_fifo_i2s_hw_params(struct snd_pcm_substream *substream,
snd_soc_component_update_bits(component, AIU_MEM_I2S_MASKS,
AIU_MEM_I2S_MASKS_IRQ_BLOCK, val);

/*
* Most (all?) supported SoCs have this bit set by default. The vendor
* driver however sets it manually (depending on the version either
* while un-setting AIU_I2S_MISC_HOLD_EN or right before that). Follow
* the same approach for consistency with the vendor driver.
*/
snd_soc_component_update_bits(component, AIU_I2S_MISC,
AIU_I2S_MISC_FORCE_LEFT_RIGHT,
AIU_I2S_MISC_FORCE_LEFT_RIGHT);

snd_soc_component_update_bits(component, AIU_I2S_MISC,
AIU_I2S_MISC_HOLD_EN, 0);

return 0;
}

Expand Down
6 changes: 6 additions & 0 deletions sound/soc/meson/aiu-fifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <linux/bitfield.h>
#include <linux/clk.h>
#include <linux/dma-mapping.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-dai.h>
Expand Down Expand Up @@ -179,6 +180,11 @@ int aiu_fifo_pcm_new(struct snd_soc_pcm_runtime *rtd,
struct snd_card *card = rtd->card->snd_card;
struct aiu_fifo *fifo = dai->playback_dma_data;
size_t size = fifo->pcm->buffer_bytes_max;
int ret;

ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
if (ret)
return ret;

snd_pcm_set_managed_buffer_all(rtd->pcm, SNDRV_DMA_TYPE_DEV,
card->dev, size, size);
Expand Down
8 changes: 5 additions & 3 deletions sound/soc/qcom/qdsp6/q6routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,14 +498,16 @@ static int msm_routing_put_audio_mixer(struct snd_kcontrol *kcontrol,
struct session_data *session = &data->sessions[session_id];

if (ucontrol->value.integer.value[0]) {
if (session->port_id == be_id)
return 0;

session->port_id = be_id;
snd_soc_dapm_mixer_update_power(dapm, kcontrol, 1, update);
} else {
if (session->port_id == be_id) {
session->port_id = -1;
if (session->port_id == -1 || session->port_id != be_id)
return 0;
}

session->port_id = -1;
snd_soc_dapm_mixer_update_power(dapm, kcontrol, 0, update);
}

Expand Down
Loading

0 comments on commit 8b974c1

Please sign in to comment.