Skip to content

Commit

Permalink
ASoC: Merge fixes
Browse files Browse the repository at this point in the history
So we can apply AMD patches that rely on them.
  • Loading branch information
Mark Brown committed Aug 8, 2024
2 parents 7d2fb38 + a44b7b5 commit 1a4f796
Show file tree
Hide file tree
Showing 28 changed files with 255 additions and 61 deletions.
5 changes: 5 additions & 0 deletions include/sound/cs35l56.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ static inline int cs35l56_force_sync_asp1_registers_from_cache(struct cs35l56_ba
return 0;
}

static inline bool cs35l56_is_otp_register(unsigned int reg)
{
return (reg >> 16) == 3;
}

extern struct regmap_config cs35l56_regmap_i2c;
extern struct regmap_config cs35l56_regmap_spi;
extern struct regmap_config cs35l56_regmap_sdw;
Expand Down
5 changes: 5 additions & 0 deletions include/sound/soc-component.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,11 @@ int snd_soc_component_force_enable_pin_unlocked(
const char *pin);

/* component controls */
struct snd_kcontrol *snd_soc_component_get_kcontrol(struct snd_soc_component *component,
const char * const ctl);
struct snd_kcontrol *
snd_soc_component_get_kcontrol_locked(struct snd_soc_component *component,
const char * const ctl);
int snd_soc_component_notify_control(struct snd_soc_component *component,
const char * const ctl);

Expand Down
7 changes: 7 additions & 0 deletions sound/soc/amd/yc/acp6x-mach.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,13 @@ static const struct dmi_system_id yc_acp_quirk_table[] = {
DMI_MATCH(DMI_BOARD_NAME, "8A3E"),
}
},
{
.driver_data = &acp6x_card,
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "HP"),
DMI_MATCH(DMI_BOARD_NAME, "8B27"),
}
},
{
.driver_data = &acp6x_card,
.matches = {
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/codecs/cs-amp-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static efi_status_t cs_amp_get_efi_variable(efi_char16_t *name,

KUNIT_STATIC_STUB_REDIRECT(cs_amp_get_efi_variable, name, guid, size, buf);

if (IS_ENABLED(CONFIG_EFI))
if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE))
return efi.get_variable(name, guid, &attr, size, buf);

return EFI_NOT_FOUND;
Expand Down
11 changes: 2 additions & 9 deletions sound/soc/codecs/cs35l45.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,10 @@ static int cs35l45_activate_ctl(struct snd_soc_component *component,
struct snd_kcontrol *kcontrol;
struct snd_kcontrol_volatile *vd;
unsigned int index_offset;
char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];

if (component->name_prefix)
snprintf(name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s %s",
component->name_prefix, ctl_name);
else
snprintf(name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s", ctl_name);

kcontrol = snd_soc_card_get_kcontrol_locked(component->card, name);
kcontrol = snd_soc_component_get_kcontrol_locked(component, ctl_name);
if (!kcontrol) {
dev_err(component->dev, "Can't find kcontrol %s\n", name);
dev_err(component->dev, "Can't find kcontrol %s\n", ctl_name);
return -EINVAL;
}

Expand Down
77 changes: 77 additions & 0 deletions sound/soc/codecs/cs35l56-sdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,79 @@
/* Register addresses are offset when sent over SoundWire */
#define CS35L56_SDW_ADDR_OFFSET 0x8000

/* Cirrus bus bridge registers */
#define CS35L56_SDW_MEM_ACCESS_STATUS 0xd0
#define CS35L56_SDW_MEM_READ_DATA 0xd8

#define CS35L56_SDW_LAST_LATE BIT(3)
#define CS35L56_SDW_CMD_IN_PROGRESS BIT(2)
#define CS35L56_SDW_RDATA_RDY BIT(0)

#define CS35L56_LATE_READ_POLL_US 10
#define CS35L56_LATE_READ_TIMEOUT_US 1000

static int cs35l56_sdw_poll_mem_status(struct sdw_slave *peripheral,
unsigned int mask,
unsigned int match)
{
int ret, val;

ret = read_poll_timeout(sdw_read_no_pm, val,
(val < 0) || ((val & mask) == match),
CS35L56_LATE_READ_POLL_US, CS35L56_LATE_READ_TIMEOUT_US,
false, peripheral, CS35L56_SDW_MEM_ACCESS_STATUS);
if (ret < 0)
return ret;

if (val < 0)
return val;

return 0;
}

static int cs35l56_sdw_slow_read(struct sdw_slave *peripheral, unsigned int reg,
u8 *buf, size_t val_size)
{
int ret, i;

reg += CS35L56_SDW_ADDR_OFFSET;

for (i = 0; i < val_size; i += sizeof(u32)) {
/* Poll for bus bridge idle */
ret = cs35l56_sdw_poll_mem_status(peripheral,
CS35L56_SDW_CMD_IN_PROGRESS,
0);
if (ret < 0) {
dev_err(&peripheral->dev, "!CMD_IN_PROGRESS fail: %d\n", ret);
return ret;
}

/* Reading LSByte triggers read of register to holding buffer */
sdw_read_no_pm(peripheral, reg + i);

/* Wait for data available */
ret = cs35l56_sdw_poll_mem_status(peripheral,
CS35L56_SDW_RDATA_RDY,
CS35L56_SDW_RDATA_RDY);
if (ret < 0) {
dev_err(&peripheral->dev, "RDATA_RDY fail: %d\n", ret);
return ret;
}

/* Read data from buffer */
ret = sdw_nread_no_pm(peripheral, CS35L56_SDW_MEM_READ_DATA,
sizeof(u32), &buf[i]);
if (ret) {
dev_err(&peripheral->dev, "Late read @%#x failed: %d\n", reg + i, ret);
return ret;
}

swab32s((u32 *)&buf[i]);
}

return 0;
}

static int cs35l56_sdw_read_one(struct sdw_slave *peripheral, unsigned int reg, void *buf)
{
int ret;
Expand All @@ -48,6 +121,10 @@ static int cs35l56_sdw_read(void *context, const void *reg_buf,
int ret;

reg = le32_to_cpu(*(const __le32 *)reg_buf);

if (cs35l56_is_otp_register(reg))
return cs35l56_sdw_slow_read(peripheral, reg, buf8, val_size);

reg += CS35L56_SDW_ADDR_OFFSET;

if (val_size == 4)
Expand Down
11 changes: 11 additions & 0 deletions sound/soc/codecs/cs35l56.c
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,11 @@ int cs35l56_system_resume(struct device *dev)
}
EXPORT_SYMBOL_GPL(cs35l56_system_resume);

static int cs35l56_control_add_nop(struct wm_adsp *dsp, struct cs_dsp_coeff_ctl *cs_ctl)
{
return 0;
}

static int cs35l56_dsp_init(struct cs35l56_private *cs35l56)
{
struct wm_adsp *dsp;
Expand All @@ -1117,6 +1122,12 @@ static int cs35l56_dsp_init(struct cs35l56_private *cs35l56)
dsp->fw = 12;
dsp->wmfw_optional = true;

/*
* None of the firmware controls need to be exported so add a no-op
* callback that suppresses creating an ALSA control.
*/
dsp->control_add = &cs35l56_control_add_nop;

dev_dbg(cs35l56->base.dev, "DSP system name: '%s'\n", dsp->system_name);

ret = wm_halo_init(dsp);
Expand Down
75 changes: 57 additions & 18 deletions sound/soc/codecs/cs42l43.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <linux/bitops.h>
#include <linux/bits.h>
#include <linux/build_bug.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/err.h>
Expand Down Expand Up @@ -252,24 +253,20 @@ CS42L43_IRQ_COMPLETE(load_detect)
static irqreturn_t cs42l43_mic_shutter(int irq, void *data)
{
struct cs42l43_codec *priv = data;
static const char * const controls[] = {
"Decimator 1 Switch",
"Decimator 2 Switch",
"Decimator 3 Switch",
"Decimator 4 Switch",
};
int i, ret;
struct snd_soc_component *component = priv->component;
int i;

dev_dbg(priv->dev, "Microphone shutter changed\n");

if (!priv->component)
if (!component)
return IRQ_NONE;

for (i = 0; i < ARRAY_SIZE(controls); i++) {
ret = snd_soc_component_notify_control(priv->component,
controls[i]);
if (ret)
for (i = 1; i < ARRAY_SIZE(priv->kctl); i++) {
if (!priv->kctl[i])
return IRQ_NONE;

snd_ctl_notify(component->card->snd_card,
SNDRV_CTL_EVENT_MASK_VALUE, &priv->kctl[i]->id);
}

return IRQ_HANDLED;
Expand All @@ -278,18 +275,19 @@ static irqreturn_t cs42l43_mic_shutter(int irq, void *data)
static irqreturn_t cs42l43_spk_shutter(int irq, void *data)
{
struct cs42l43_codec *priv = data;
int ret;
struct snd_soc_component *component = priv->component;

dev_dbg(priv->dev, "Speaker shutter changed\n");

if (!priv->component)
if (!component)
return IRQ_NONE;

ret = snd_soc_component_notify_control(priv->component,
"Speaker Digital Switch");
if (ret)
if (!priv->kctl[0])
return IRQ_NONE;

snd_ctl_notify(component->card->snd_card,
SNDRV_CTL_EVENT_MASK_VALUE, &priv->kctl[0]->id);

return IRQ_HANDLED;
}

Expand Down Expand Up @@ -590,7 +588,46 @@ static int cs42l43_asp_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mas
return 0;
}

static int cs42l43_dai_probe(struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
struct cs42l43_codec *priv = snd_soc_component_get_drvdata(component);
static const char * const controls[] = {
"Speaker Digital Switch",
"Decimator 1 Switch",
"Decimator 2 Switch",
"Decimator 3 Switch",
"Decimator 4 Switch",
};
int i;

static_assert(ARRAY_SIZE(controls) == ARRAY_SIZE(priv->kctl));

for (i = 0; i < ARRAY_SIZE(controls); i++) {
if (priv->kctl[i])
continue;

priv->kctl[i] = snd_soc_component_get_kcontrol(component, controls[i]);
}

return 0;
}

static int cs42l43_dai_remove(struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
struct cs42l43_codec *priv = snd_soc_component_get_drvdata(component);
int i;

for (i = 0; i < ARRAY_SIZE(priv->kctl); i++)
priv->kctl[i] = NULL;

return 0;
}

static const struct snd_soc_dai_ops cs42l43_asp_ops = {
.probe = cs42l43_dai_probe,
.remove = cs42l43_dai_remove,
.startup = cs42l43_startup,
.hw_params = cs42l43_asp_hw_params,
.set_fmt = cs42l43_asp_set_fmt,
Expand All @@ -608,9 +645,11 @@ static int cs42l43_sdw_hw_params(struct snd_pcm_substream *substream,
return ret;

return cs42l43_set_sample_rate(substream, params, dai);
};
}

static const struct snd_soc_dai_ops cs42l43_sdw_ops = {
.probe = cs42l43_dai_probe,
.remove = cs42l43_dai_remove,
.startup = cs42l43_startup,
.set_stream = cs42l43_sdw_set_stream,
.hw_params = cs42l43_sdw_hw_params,
Expand Down
2 changes: 2 additions & 0 deletions sound/soc/codecs/cs42l43.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ struct cs42l43_codec {
struct delayed_work hp_ilimit_clear_work;
bool hp_ilimited;
int hp_ilimit_count;

struct snd_kcontrol *kctl[5];
};

#if IS_REACHABLE(CONFIG_SND_SOC_CS42L43_SDW)
Expand Down
8 changes: 4 additions & 4 deletions sound/soc/codecs/cs530x.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,16 @@ static int cs530x_put_volsw_vu(struct snd_kcontrol *kcontrol,

static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -1270, 50, 0);

static const char * const cs530x_in_hpf_text[] = {
static const char * const cs530x_in_filter_text[] = {
"Min Phase Slow Roll-off",
"Min Phase Fast Roll-off",
"Linear Phase Slow Roll-off",
"Linear Phase Fast Roll-off",
};

static SOC_ENUM_SINGLE_DECL(cs530x_in_hpf_enum, CS530X_IN_FILTER,
static SOC_ENUM_SINGLE_DECL(cs530x_in_filter_enum, CS530X_IN_FILTER,
CS530X_IN_FILTER_SHIFT,
cs530x_in_hpf_text);
cs530x_in_filter_text);

static const char * const cs530x_in_4ch_sum_text[] = {
"None",
Expand Down Expand Up @@ -189,7 +189,7 @@ SOC_SINGLE_EXT_TLV("IN1 Volume", CS530X_IN_VOL_CTRL1_0, 0, 255, 1,
SOC_SINGLE_EXT_TLV("IN2 Volume", CS530X_IN_VOL_CTRL1_1, 0, 255, 1,
snd_soc_get_volsw, cs530x_put_volsw_vu, in_vol_tlv),

SOC_ENUM("IN HPF Select", cs530x_in_hpf_enum),
SOC_ENUM("IN DEC Filter Select", cs530x_in_filter_enum),
SOC_ENUM("Input Ramp Up", cs530x_ramp_inc_enum),
SOC_ENUM("Input Ramp Down", cs530x_ramp_dec_enum),

Expand Down
2 changes: 2 additions & 0 deletions sound/soc/codecs/lpass-va-macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,8 @@ static void va_macro_set_lpass_codec_version(struct va_macro *va)

if ((core_id_0 == 0x01) && (core_id_1 == 0x0F))
version = LPASS_CODEC_VERSION_2_0;
if ((core_id_0 == 0x02) && (core_id_1 == 0x0F) && core_id_2 == 0x01)
version = LPASS_CODEC_VERSION_2_0;
if ((core_id_0 == 0x02) && (core_id_1 == 0x0E))
version = LPASS_CODEC_VERSION_2_1;
if ((core_id_0 == 0x02) && (core_id_1 == 0x0F) && (core_id_2 == 0x50 || core_id_2 == 0x51))
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/codecs/nau8822.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ static int nau8822_set_pll(struct snd_soc_dai *dai, int pll_id, int source,
return ret;
}

dev_info(component->dev,
dev_dbg(component->dev,
"pll_int=%x pll_frac=%x mclk_scaler=%x pre_factor=%x\n",
pll_param->pll_int, pll_param->pll_frac,
pll_param->mclk_scaler, pll_param->pre_factor);
Expand Down
4 changes: 2 additions & 2 deletions sound/soc/codecs/wcd937x-sdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ static int wcd9370_probe(struct sdw_slave *pdev,
pdev->prop.lane_control_support = true;
pdev->prop.simple_clk_stop_capable = true;
if (wcd->is_tx) {
pdev->prop.source_ports = GENMASK(WCD937X_MAX_TX_SWR_PORTS, 0);
pdev->prop.source_ports = GENMASK(WCD937X_MAX_TX_SWR_PORTS - 1, 0);
pdev->prop.src_dpn_prop = wcd937x_dpn_prop;
wcd->ch_info = &wcd937x_sdw_tx_ch_info[0];
pdev->prop.wake_capable = true;
Expand All @@ -1062,7 +1062,7 @@ static int wcd9370_probe(struct sdw_slave *pdev,
/* Start in cache-only until device is enumerated */
regcache_cache_only(wcd->regmap, true);
} else {
pdev->prop.sink_ports = GENMASK(WCD937X_MAX_SWR_PORTS, 0);
pdev->prop.sink_ports = GENMASK(WCD937X_MAX_SWR_PORTS - 1, 0);
pdev->prop.sink_dpn_prop = wcd937x_dpn_prop;
wcd->ch_info = &wcd937x_sdw_rx_ch_info[0];
}
Expand Down
4 changes: 2 additions & 2 deletions sound/soc/codecs/wcd938x-sdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1252,12 +1252,12 @@ static int wcd9380_probe(struct sdw_slave *pdev,
pdev->prop.lane_control_support = true;
pdev->prop.simple_clk_stop_capable = true;
if (wcd->is_tx) {
pdev->prop.source_ports = GENMASK(WCD938X_MAX_SWR_PORTS, 0);
pdev->prop.source_ports = GENMASK(WCD938X_MAX_SWR_PORTS - 1, 0);
pdev->prop.src_dpn_prop = wcd938x_dpn_prop;
wcd->ch_info = &wcd938x_sdw_tx_ch_info[0];
pdev->prop.wake_capable = true;
} else {
pdev->prop.sink_ports = GENMASK(WCD938X_MAX_SWR_PORTS, 0);
pdev->prop.sink_ports = GENMASK(WCD938X_MAX_SWR_PORTS - 1, 0);
pdev->prop.sink_dpn_prop = wcd938x_dpn_prop;
wcd->ch_info = &wcd938x_sdw_rx_ch_info[0];
}
Expand Down
Loading

0 comments on commit 1a4f796

Please sign in to comment.