Skip to content

Commit

Permalink
Merge tag 'asoc-fix-v5.17-rc4' of https://git.kernel.org/pub/scm/linu…
Browse files Browse the repository at this point in the history
…x/kernel/git/broonie/sound into for-linus

ASoC: Fixes for v5.18

More fixes that have arrived in the past few -rcs, plus a MAINTAINERS
update.  The biggest update here is the fix for control change
notifications in ASoC generic controls found by mixer-test.
  • Loading branch information
tiwai committed Feb 14, 2022
2 parents 2a84583 + a887f9c commit 5948342
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ title: Audio codec controlled by ChromeOS EC

maintainers:
- Cheng-Yi Chiang <[email protected]>
- Tzung-Bi Shih <[email protected]>

description: |
Google's ChromeOS EC codec is a digital mic codec provided by the
Expand Down
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -4543,6 +4543,7 @@ F: drivers/platform/chrome/

CHROMEOS EC CODEC DRIVER
M: Cheng-Yi Chiang <[email protected]>
M: Tzung-Bi Shih <[email protected]>
R: Guenter Roeck <[email protected]>
S: Maintained
F: Documentation/devicetree/bindings/sound/google,cros-ec-codec.yaml
Expand Down
15 changes: 4 additions & 11 deletions drivers/soc/mediatek/mtk-scpsys.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,17 +411,12 @@ static int scpsys_power_off(struct generic_pm_domain *genpd)
return ret;
}

static int init_clks(struct platform_device *pdev, struct clk **clk)
static void init_clks(struct platform_device *pdev, struct clk **clk)
{
int i;

for (i = CLK_NONE + 1; i < CLK_MAX; i++) {
for (i = CLK_NONE + 1; i < CLK_MAX; i++)
clk[i] = devm_clk_get(&pdev->dev, clk_names[i]);
if (IS_ERR(clk[i]))
return PTR_ERR(clk[i]);
}

return 0;
}

static struct scp *init_scp(struct platform_device *pdev,
Expand All @@ -431,7 +426,7 @@ static struct scp *init_scp(struct platform_device *pdev,
{
struct genpd_onecell_data *pd_data;
struct resource *res;
int i, j, ret;
int i, j;
struct scp *scp;
struct clk *clk[CLK_MAX];

Expand Down Expand Up @@ -486,9 +481,7 @@ static struct scp *init_scp(struct platform_device *pdev,

pd_data->num_domains = num;

ret = init_clks(pdev, clk);
if (ret)
return ERR_PTR(ret);
init_clks(pdev, clk);

for (i = 0; i < num; i++) {
struct scp_domain *scpd = &scp->domains[i];
Expand Down
1 change: 0 additions & 1 deletion sound/soc/amd/acp/acp-mach.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <linux/gpio/consumer.h>

#define EN_SPKR_GPIO_GB 0x11F
#define EN_SPKR_GPIO_NK 0x146
#define EN_SPKR_GPIO_NONE -EINVAL

enum be_id {
Expand Down
4 changes: 2 additions & 2 deletions sound/soc/amd/acp/acp-sof-mach.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static struct acp_card_drvdata sof_rt5682_max_data = {
.hs_codec_id = RT5682,
.amp_codec_id = MAX98360A,
.dmic_codec_id = DMIC,
.gpio_spkr_en = EN_SPKR_GPIO_NK,
.gpio_spkr_en = EN_SPKR_GPIO_NONE,
};

static struct acp_card_drvdata sof_rt5682s_max_data = {
Expand All @@ -47,7 +47,7 @@ static struct acp_card_drvdata sof_rt5682s_max_data = {
.hs_codec_id = RT5682S,
.amp_codec_id = MAX98360A,
.dmic_codec_id = DMIC,
.gpio_spkr_en = EN_SPKR_GPIO_NK,
.gpio_spkr_en = EN_SPKR_GPIO_NONE,
};

static const struct snd_kcontrol_new acp_controls[] = {
Expand Down
12 changes: 7 additions & 5 deletions sound/soc/codecs/rt5668.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,11 +1022,13 @@ static void rt5668_jack_detect_handler(struct work_struct *work)
container_of(work, struct rt5668_priv, jack_detect_work.work);
int val, btn_type;

while (!rt5668->component)
usleep_range(10000, 15000);

while (!rt5668->component->card->instantiated)
usleep_range(10000, 15000);
if (!rt5668->component || !rt5668->component->card ||
!rt5668->component->card->instantiated) {
/* card not yet ready, try later */
mod_delayed_work(system_power_efficient_wq,
&rt5668->jack_detect_work, msecs_to_jiffies(15));
return;
}

mutex_lock(&rt5668->calibrate_mutex);

Expand Down
12 changes: 7 additions & 5 deletions sound/soc/codecs/rt5682.c
Original file line number Diff line number Diff line change
Expand Up @@ -1092,11 +1092,13 @@ void rt5682_jack_detect_handler(struct work_struct *work)
struct snd_soc_dapm_context *dapm;
int val, btn_type;

while (!rt5682->component)
usleep_range(10000, 15000);

while (!rt5682->component->card->instantiated)
usleep_range(10000, 15000);
if (!rt5682->component || !rt5682->component->card ||
!rt5682->component->card->instantiated) {
/* card not yet ready, try later */
mod_delayed_work(system_power_efficient_wq,
&rt5682->jack_detect_work, msecs_to_jiffies(15));
return;
}

dapm = snd_soc_component_get_dapm(rt5682->component);

Expand Down
12 changes: 7 additions & 5 deletions sound/soc/codecs/rt5682s.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,11 +824,13 @@ static void rt5682s_jack_detect_handler(struct work_struct *work)
container_of(work, struct rt5682s_priv, jack_detect_work.work);
int val, btn_type;

while (!rt5682s->component)
usleep_range(10000, 15000);

while (!rt5682s->component->card->instantiated)
usleep_range(10000, 15000);
if (!rt5682s->component || !rt5682s->component->card ||
!rt5682s->component->card->instantiated) {
/* card not yet ready, try later */
mod_delayed_work(system_power_efficient_wq,
&rt5682s->jack_detect_work, msecs_to_jiffies(15));
return;
}

mutex_lock(&rt5682s->jdet_mutex);
mutex_lock(&rt5682s->calibrate_mutex);
Expand Down
7 changes: 6 additions & 1 deletion sound/soc/codecs/tas2770.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ static void tas2770_reset(struct tas2770_priv *tas2770)
gpiod_set_value_cansleep(tas2770->reset_gpio, 0);
msleep(20);
gpiod_set_value_cansleep(tas2770->reset_gpio, 1);
usleep_range(1000, 2000);
}

snd_soc_component_write(tas2770->component, TAS2770_SW_RST,
TAS2770_RST);
usleep_range(1000, 2000);
}

static int tas2770_set_bias_level(struct snd_soc_component *component,
Expand Down Expand Up @@ -110,6 +112,7 @@ static int tas2770_codec_resume(struct snd_soc_component *component)

if (tas2770->sdz_gpio) {
gpiod_set_value_cansleep(tas2770->sdz_gpio, 1);
usleep_range(1000, 2000);
} else {
ret = snd_soc_component_update_bits(component, TAS2770_PWR_CTRL,
TAS2770_PWR_CTRL_MASK,
Expand Down Expand Up @@ -510,8 +513,10 @@ static int tas2770_codec_probe(struct snd_soc_component *component)

tas2770->component = component;

if (tas2770->sdz_gpio)
if (tas2770->sdz_gpio) {
gpiod_set_value_cansleep(tas2770->sdz_gpio, 1);
usleep_range(1000, 2000);
}

tas2770_reset(tas2770);

Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/wm_adsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,8 @@ static int wm_adsp_buffer_parse_coeff(struct cs_dsp_coeff_ctl *cs_ctl)
int ret, i;

for (i = 0; i < 5; ++i) {
ret = cs_dsp_coeff_read_ctrl(cs_ctl, 0, &coeff_v1, sizeof(coeff_v1));
ret = cs_dsp_coeff_read_ctrl(cs_ctl, 0, &coeff_v1,
min(cs_ctl->len, sizeof(coeff_v1)));
if (ret < 0)
return ret;

Expand Down
8 changes: 4 additions & 4 deletions sound/soc/qcom/lpass-platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ static int lpass_platform_pcmops_trigger(struct snd_soc_component *component,
return -EINVAL;
}

ret = regmap_update_bits(map, reg_irqclr, val_irqclr, val_irqclr);
ret = regmap_write_bits(map, reg_irqclr, val_irqclr, val_irqclr);
if (ret) {
dev_err(soc_runtime->dev, "error writing to irqclear reg: %d\n", ret);
return ret;
Expand Down Expand Up @@ -665,7 +665,7 @@ static irqreturn_t lpass_dma_interrupt_handler(
return -EINVAL;
}
if (interrupts & LPAIF_IRQ_PER(chan)) {
rv = regmap_update_bits(map, reg, mask, (LPAIF_IRQ_PER(chan) | val));
rv = regmap_write_bits(map, reg, mask, (LPAIF_IRQ_PER(chan) | val));
if (rv) {
dev_err(soc_runtime->dev,
"error writing to irqclear reg: %d\n", rv);
Expand All @@ -676,7 +676,7 @@ static irqreturn_t lpass_dma_interrupt_handler(
}

if (interrupts & LPAIF_IRQ_XRUN(chan)) {
rv = regmap_update_bits(map, reg, mask, (LPAIF_IRQ_XRUN(chan) | val));
rv = regmap_write_bits(map, reg, mask, (LPAIF_IRQ_XRUN(chan) | val));
if (rv) {
dev_err(soc_runtime->dev,
"error writing to irqclear reg: %d\n", rv);
Expand All @@ -688,7 +688,7 @@ static irqreturn_t lpass_dma_interrupt_handler(
}

if (interrupts & LPAIF_IRQ_ERR(chan)) {
rv = regmap_update_bits(map, reg, mask, (LPAIF_IRQ_ERR(chan) | val));
rv = regmap_write_bits(map, reg, mask, (LPAIF_IRQ_ERR(chan) | val));
if (rv) {
dev_err(soc_runtime->dev,
"error writing to irqclear reg: %d\n", rv);
Expand Down
41 changes: 31 additions & 10 deletions sound/soc/soc-ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
unsigned int sign_bit = mc->sign_bit;
unsigned int mask = (1 << fls(max)) - 1;
unsigned int invert = mc->invert;
int err;
int err, ret;
bool type_2r = false;
unsigned int val2 = 0;
unsigned int val, val_mask;
Expand Down Expand Up @@ -350,12 +350,18 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
err = snd_soc_component_update_bits(component, reg, val_mask, val);
if (err < 0)
return err;
ret = err;

if (type_2r)
if (type_2r) {
err = snd_soc_component_update_bits(component, reg2, val_mask,
val2);
val2);
/* Don't discard any error code or drop change flag */
if (ret == 0 || err < 0) {
ret = err;
}
}

return err;
return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_put_volsw);

Expand Down Expand Up @@ -421,6 +427,7 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
int min = mc->min;
unsigned int mask = (1U << (fls(min + max) - 1)) - 1;
int err = 0;
int ret;
unsigned int val, val_mask;

if (ucontrol->value.integer.value[0] < 0)
Expand All @@ -437,6 +444,7 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
err = snd_soc_component_update_bits(component, reg, val_mask, val);
if (err < 0)
return err;
ret = err;

if (snd_soc_volsw_is_stereo(mc)) {
unsigned int val2;
Expand All @@ -447,6 +455,11 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,

err = snd_soc_component_update_bits(component, reg2, val_mask,
val2);

/* Don't discard any error code or drop change flag */
if (ret == 0 || err < 0) {
ret = err;
}
}
return err;
}
Expand Down Expand Up @@ -506,7 +519,7 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
unsigned int mask = (1 << fls(max)) - 1;
unsigned int invert = mc->invert;
unsigned int val, val_mask;
int ret;
int err, ret;

if (invert)
val = (max - ucontrol->value.integer.value[0]) & mask;
Expand All @@ -515,9 +528,10 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
val_mask = mask << shift;
val = val << shift;

ret = snd_soc_component_update_bits(component, reg, val_mask, val);
if (ret < 0)
return ret;
err = snd_soc_component_update_bits(component, reg, val_mask, val);
if (err < 0)
return err;
ret = err;

if (snd_soc_volsw_is_stereo(mc)) {
if (invert)
Expand All @@ -527,8 +541,12 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
val_mask = mask << shift;
val = val << shift;

ret = snd_soc_component_update_bits(component, rreg, val_mask,
err = snd_soc_component_update_bits(component, rreg, val_mask,
val);
/* Don't discard any error code or drop change flag */
if (ret == 0 || err < 0) {
ret = err;
}
}

return ret;
Expand Down Expand Up @@ -877,6 +895,7 @@ int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
unsigned long mask = (1UL<<mc->nbits)-1;
long max = mc->max;
long val = ucontrol->value.integer.value[0];
int ret = 0;
unsigned int i;

if (val < mc->min || val > mc->max)
Expand All @@ -891,9 +910,11 @@ int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
regmask, regval);
if (err < 0)
return err;
if (err > 0)
ret = err;
}

return 0;
return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_put_xr_sx);

Expand Down

0 comments on commit 5948342

Please sign in to comment.