From: Stefan Binding <sbinding@opensource.cirrus.com>
To: Mark Brown <broonie@kernel.org>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@opensource.cirrus.com,
Stefan Binding <sbinding@opensource.cirrus.com>
Subject: [PATCH RESEND v1 3/5] ASoC: cs35l56: Add Mute, Volume and Posture registers to firmware register list
Date: Tue, 6 May 2025 10:58:48 +0100 [thread overview]
Message-ID: <20250506095903.10827-4-sbinding@opensource.cirrus.com> (raw)
In-Reply-To: <20250506095903.10827-1-sbinding@opensource.cirrus.com>
Registers to set Mute, Volume and Posture are inside firmware,
which means they should be added to the list of registers set inside
firmware, in case they vary across Device or Revision.
These three registers are also used for controls, so additional
handling is required to be able to obtain and set the register inside
ALSA controls.
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
---
include/sound/cs35l56.h | 3 +++
sound/pci/hda/cs35l56_hda.c | 17 +++++++----------
sound/soc/codecs/cs35l56-shared.c | 25 ++++++++++++++++++++++++-
sound/soc/codecs/cs35l56.c | 19 +++++++++++++++++--
4 files changed, 51 insertions(+), 13 deletions(-)
diff --git a/include/sound/cs35l56.h b/include/sound/cs35l56.h
index d712cb79652b..3abe4fbd2085 100644
--- a/include/sound/cs35l56.h
+++ b/include/sound/cs35l56.h
@@ -273,6 +273,9 @@ struct cs35l56_fw_reg {
unsigned int pm_cur_stat;
unsigned int prot_sts;
unsigned int transducer_actual_ps;
+ unsigned int user_mute;
+ unsigned int user_volume;
+ unsigned int posture_number;
};
struct cs35l56_base {
diff --git a/sound/pci/hda/cs35l56_hda.c b/sound/pci/hda/cs35l56_hda.c
index 5660cf7087fe..b6fecf119261 100644
--- a/sound/pci/hda/cs35l56_hda.c
+++ b/sound/pci/hda/cs35l56_hda.c
@@ -237,7 +237,8 @@ static int cs35l56_hda_posture_get(struct snd_kcontrol *kcontrol,
cs35l56_hda_wait_dsp_ready(cs35l56);
- ret = regmap_read(cs35l56->base.regmap, CS35L56_MAIN_POSTURE_NUMBER, &pos);
+ ret = regmap_read(cs35l56->base.regmap,
+ cs35l56->base.fw_reg->posture_number, &pos);
if (ret)
return ret;
@@ -260,10 +261,8 @@ static int cs35l56_hda_posture_put(struct snd_kcontrol *kcontrol,
cs35l56_hda_wait_dsp_ready(cs35l56);
- ret = regmap_update_bits_check(cs35l56->base.regmap,
- CS35L56_MAIN_POSTURE_NUMBER,
- CS35L56_MAIN_POSTURE_MASK,
- pos, &changed);
+ ret = regmap_update_bits_check(cs35l56->base.regmap, cs35l56->base.fw_reg->posture_number,
+ CS35L56_MAIN_POSTURE_MASK, pos, &changed);
if (ret)
return ret;
@@ -305,7 +304,7 @@ static int cs35l56_hda_vol_get(struct snd_kcontrol *kcontrol,
cs35l56_hda_wait_dsp_ready(cs35l56);
- ret = regmap_read(cs35l56->base.regmap, CS35L56_MAIN_RENDER_USER_VOLUME, &raw_vol);
+ ret = regmap_read(cs35l56->base.regmap, cs35l56->base.fw_reg->user_volume, &raw_vol);
if (ret)
return ret;
@@ -339,10 +338,8 @@ static int cs35l56_hda_vol_put(struct snd_kcontrol *kcontrol,
cs35l56_hda_wait_dsp_ready(cs35l56);
- ret = regmap_update_bits_check(cs35l56->base.regmap,
- CS35L56_MAIN_RENDER_USER_VOLUME,
- CS35L56_MAIN_RENDER_USER_VOLUME_MASK,
- raw_vol, &changed);
+ ret = regmap_update_bits_check(cs35l56->base.regmap, cs35l56->base.fw_reg->user_volume,
+ CS35L56_MAIN_RENDER_USER_VOLUME_MASK, raw_vol, &changed);
if (ret)
return ret;
diff --git a/sound/soc/codecs/cs35l56-shared.c b/sound/soc/codecs/cs35l56-shared.c
index bc8f9379bc74..da982774bb4d 100644
--- a/sound/soc/codecs/cs35l56-shared.c
+++ b/sound/soc/codecs/cs35l56-shared.c
@@ -38,7 +38,9 @@ static const struct reg_sequence cs35l56_patch[] = {
{ CS35L56_SWIRE_DP3_CH3_INPUT, 0x00000029 },
{ CS35L56_SWIRE_DP3_CH4_INPUT, 0x00000028 },
{ CS35L56_IRQ1_MASK_18, 0x1f7df0ff },
+};
+static const struct reg_sequence cs35l56_patch_fw[] = {
/* These are not reset by a soft-reset, so patch to defaults. */
{ CS35L56_MAIN_RENDER_USER_MUTE, 0x00000000 },
{ CS35L56_MAIN_RENDER_USER_VOLUME, 0x00000000 },
@@ -47,8 +49,26 @@ static const struct reg_sequence cs35l56_patch[] = {
int cs35l56_set_patch(struct cs35l56_base *cs35l56_base)
{
- return regmap_register_patch(cs35l56_base->regmap, cs35l56_patch,
+ int ret;
+
+ ret = regmap_register_patch(cs35l56_base->regmap, cs35l56_patch,
ARRAY_SIZE(cs35l56_patch));
+ if (ret)
+ return ret;
+
+
+ switch (cs35l56_base->type) {
+ case 0x54:
+ case 0x56:
+ case 0x57:
+ ret = regmap_register_patch(cs35l56_base->regmap, cs35l56_patch_fw,
+ ARRAY_SIZE(cs35l56_patch_fw));
+ break;
+ default:
+ break;
+ }
+
+ return ret;
}
EXPORT_SYMBOL_NS_GPL(cs35l56_set_patch, "SND_SOC_CS35L56_SHARED");
@@ -1066,6 +1086,9 @@ const struct cs35l56_fw_reg cs35l56_fw_reg = {
.pm_cur_stat = CS35L56_DSP1_PM_CUR_STATE,
.prot_sts = CS35L56_PROTECTION_STATUS,
.transducer_actual_ps = CS35L56_TRANSDUCER_ACTUAL_PS,
+ .user_mute = CS35L56_MAIN_RENDER_USER_MUTE,
+ .user_volume = CS35L56_MAIN_RENDER_USER_VOLUME,
+ .posture_number = CS35L56_MAIN_POSTURE_NUMBER,
};
EXPORT_SYMBOL_NS_GPL(cs35l56_fw_reg, "SND_SOC_CS35L56_SHARED");
diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c
index c1d8bfb803b9..a4a1d09097fc 100644
--- a/sound/soc/codecs/cs35l56.c
+++ b/sound/soc/codecs/cs35l56.c
@@ -838,6 +838,7 @@ static int cs35l56_component_probe(struct snd_soc_component *component)
struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component);
struct dentry *debugfs_root = component->debugfs_root;
unsigned short vendor, device;
+ int ret;
BUILD_BUG_ON(ARRAY_SIZE(cs35l56_tx_input_texts) != ARRAY_SIZE(cs35l56_tx_input_values));
@@ -877,6 +878,22 @@ static int cs35l56_component_probe(struct snd_soc_component *component)
debugfs_create_bool("can_hibernate", 0444, debugfs_root, &cs35l56->base.can_hibernate);
debugfs_create_bool("fw_patched", 0444, debugfs_root, &cs35l56->base.fw_patched);
+
+ switch (cs35l56->base.type) {
+ case 0x54:
+ case 0x56:
+ case 0x57:
+ ret = snd_soc_add_component_controls(component, cs35l56_controls,
+ ARRAY_SIZE(cs35l56_controls));
+ break;
+ default:
+ ret = -ENODEV;
+ break;
+ }
+
+ if (ret)
+ return dev_err_probe(cs35l56->base.dev, ret, "unable to add controls\n");
+
queue_work(cs35l56->dsp_wq, &cs35l56->dsp_work);
return 0;
@@ -932,8 +949,6 @@ static const struct snd_soc_component_driver soc_component_dev_cs35l56 = {
.num_dapm_widgets = ARRAY_SIZE(cs35l56_dapm_widgets),
.dapm_routes = cs35l56_audio_map,
.num_dapm_routes = ARRAY_SIZE(cs35l56_audio_map),
- .controls = cs35l56_controls,
- .num_controls = ARRAY_SIZE(cs35l56_controls),
.set_bias_level = cs35l56_set_bias_level,
--
2.43.0
next prev parent reply other threads:[~2025-05-06 9:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 9:58 [PATCH RESEND v1 0/5] Add support for CS35L63 Smart Amplifier Stefan Binding
2025-05-06 9:58 ` [PATCH RESEND v1 1/5] ASoC: cs35l56: Add Index based on ACPI HID or SDW ID to select regmap config Stefan Binding
2025-05-06 9:58 ` [PATCH RESEND v1 2/5] ASoC: cs35l56: Add struct to index firmware registers Stefan Binding
2025-05-06 9:58 ` Stefan Binding [this message]
2025-05-06 9:58 ` [PATCH RESEND v1 4/5] ASoC: cs35l56: Add initial support for CS35L63 for I2C and SoundWire Stefan Binding
2025-05-06 9:58 ` [PATCH RESEND v1 5/5] ASoC: cs35l56: Read Silicon ID from DIE_STS registers for CS35L63 Stefan Binding
2025-05-06 13:36 ` [PATCH RESEND v1 0/5] Add support for CS35L63 Smart Amplifier Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250506095903.10827-4-sbinding@opensource.cirrus.com \
--to=sbinding@opensource.cirrus.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox