Skip to content

Commit a3ec669

Browse files
Stefan Bindingbroonie
authored andcommitted
ASoC: cs35l56: Add Mute, Volume and Posture registers to firmware register list
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 <[email protected]> Reviewed-by: Richard Fitzgerald <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 8c0821c commit a3ec669

File tree

4 files changed

+51
-13
lines changed

4 files changed

+51
-13
lines changed

include/sound/cs35l56.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ struct cs35l56_fw_reg {
273273
unsigned int pm_cur_stat;
274274
unsigned int prot_sts;
275275
unsigned int transducer_actual_ps;
276+
unsigned int user_mute;
277+
unsigned int user_volume;
278+
unsigned int posture_number;
276279
};
277280

278281
struct cs35l56_base {

sound/pci/hda/cs35l56_hda.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ static int cs35l56_hda_posture_get(struct snd_kcontrol *kcontrol,
237237

238238
cs35l56_hda_wait_dsp_ready(cs35l56);
239239

240-
ret = regmap_read(cs35l56->base.regmap, CS35L56_MAIN_POSTURE_NUMBER, &pos);
240+
ret = regmap_read(cs35l56->base.regmap,
241+
cs35l56->base.fw_reg->posture_number, &pos);
241242
if (ret)
242243
return ret;
243244

@@ -260,10 +261,8 @@ static int cs35l56_hda_posture_put(struct snd_kcontrol *kcontrol,
260261

261262
cs35l56_hda_wait_dsp_ready(cs35l56);
262263

263-
ret = regmap_update_bits_check(cs35l56->base.regmap,
264-
CS35L56_MAIN_POSTURE_NUMBER,
265-
CS35L56_MAIN_POSTURE_MASK,
266-
pos, &changed);
264+
ret = regmap_update_bits_check(cs35l56->base.regmap, cs35l56->base.fw_reg->posture_number,
265+
CS35L56_MAIN_POSTURE_MASK, pos, &changed);
267266
if (ret)
268267
return ret;
269268

@@ -305,7 +304,7 @@ static int cs35l56_hda_vol_get(struct snd_kcontrol *kcontrol,
305304

306305
cs35l56_hda_wait_dsp_ready(cs35l56);
307306

308-
ret = regmap_read(cs35l56->base.regmap, CS35L56_MAIN_RENDER_USER_VOLUME, &raw_vol);
307+
ret = regmap_read(cs35l56->base.regmap, cs35l56->base.fw_reg->user_volume, &raw_vol);
309308

310309
if (ret)
311310
return ret;
@@ -339,10 +338,8 @@ static int cs35l56_hda_vol_put(struct snd_kcontrol *kcontrol,
339338

340339
cs35l56_hda_wait_dsp_ready(cs35l56);
341340

342-
ret = regmap_update_bits_check(cs35l56->base.regmap,
343-
CS35L56_MAIN_RENDER_USER_VOLUME,
344-
CS35L56_MAIN_RENDER_USER_VOLUME_MASK,
345-
raw_vol, &changed);
341+
ret = regmap_update_bits_check(cs35l56->base.regmap, cs35l56->base.fw_reg->user_volume,
342+
CS35L56_MAIN_RENDER_USER_VOLUME_MASK, raw_vol, &changed);
346343
if (ret)
347344
return ret;
348345

sound/soc/codecs/cs35l56-shared.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ static const struct reg_sequence cs35l56_patch[] = {
3838
{ CS35L56_SWIRE_DP3_CH3_INPUT, 0x00000029 },
3939
{ CS35L56_SWIRE_DP3_CH4_INPUT, 0x00000028 },
4040
{ CS35L56_IRQ1_MASK_18, 0x1f7df0ff },
41+
};
4142

43+
static const struct reg_sequence cs35l56_patch_fw[] = {
4244
/* These are not reset by a soft-reset, so patch to defaults. */
4345
{ CS35L56_MAIN_RENDER_USER_MUTE, 0x00000000 },
4446
{ CS35L56_MAIN_RENDER_USER_VOLUME, 0x00000000 },
@@ -47,8 +49,26 @@ static const struct reg_sequence cs35l56_patch[] = {
4749

4850
int cs35l56_set_patch(struct cs35l56_base *cs35l56_base)
4951
{
50-
return regmap_register_patch(cs35l56_base->regmap, cs35l56_patch,
52+
int ret;
53+
54+
ret = regmap_register_patch(cs35l56_base->regmap, cs35l56_patch,
5155
ARRAY_SIZE(cs35l56_patch));
56+
if (ret)
57+
return ret;
58+
59+
60+
switch (cs35l56_base->type) {
61+
case 0x54:
62+
case 0x56:
63+
case 0x57:
64+
ret = regmap_register_patch(cs35l56_base->regmap, cs35l56_patch_fw,
65+
ARRAY_SIZE(cs35l56_patch_fw));
66+
break;
67+
default:
68+
break;
69+
}
70+
71+
return ret;
5272
}
5373
EXPORT_SYMBOL_NS_GPL(cs35l56_set_patch, "SND_SOC_CS35L56_SHARED");
5474

@@ -1066,6 +1086,9 @@ const struct cs35l56_fw_reg cs35l56_fw_reg = {
10661086
.pm_cur_stat = CS35L56_DSP1_PM_CUR_STATE,
10671087
.prot_sts = CS35L56_PROTECTION_STATUS,
10681088
.transducer_actual_ps = CS35L56_TRANSDUCER_ACTUAL_PS,
1089+
.user_mute = CS35L56_MAIN_RENDER_USER_MUTE,
1090+
.user_volume = CS35L56_MAIN_RENDER_USER_VOLUME,
1091+
.posture_number = CS35L56_MAIN_POSTURE_NUMBER,
10691092
};
10701093
EXPORT_SYMBOL_NS_GPL(cs35l56_fw_reg, "SND_SOC_CS35L56_SHARED");
10711094

sound/soc/codecs/cs35l56.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,7 @@ static int cs35l56_component_probe(struct snd_soc_component *component)
838838
struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component);
839839
struct dentry *debugfs_root = component->debugfs_root;
840840
unsigned short vendor, device;
841+
int ret;
841842

842843
BUILD_BUG_ON(ARRAY_SIZE(cs35l56_tx_input_texts) != ARRAY_SIZE(cs35l56_tx_input_values));
843844

@@ -877,6 +878,22 @@ static int cs35l56_component_probe(struct snd_soc_component *component)
877878
debugfs_create_bool("can_hibernate", 0444, debugfs_root, &cs35l56->base.can_hibernate);
878879
debugfs_create_bool("fw_patched", 0444, debugfs_root, &cs35l56->base.fw_patched);
879880

881+
882+
switch (cs35l56->base.type) {
883+
case 0x54:
884+
case 0x56:
885+
case 0x57:
886+
ret = snd_soc_add_component_controls(component, cs35l56_controls,
887+
ARRAY_SIZE(cs35l56_controls));
888+
break;
889+
default:
890+
ret = -ENODEV;
891+
break;
892+
}
893+
894+
if (ret)
895+
return dev_err_probe(cs35l56->base.dev, ret, "unable to add controls\n");
896+
880897
queue_work(cs35l56->dsp_wq, &cs35l56->dsp_work);
881898

882899
return 0;
@@ -932,8 +949,6 @@ static const struct snd_soc_component_driver soc_component_dev_cs35l56 = {
932949
.num_dapm_widgets = ARRAY_SIZE(cs35l56_dapm_widgets),
933950
.dapm_routes = cs35l56_audio_map,
934951
.num_dapm_routes = ARRAY_SIZE(cs35l56_audio_map),
935-
.controls = cs35l56_controls,
936-
.num_controls = ARRAY_SIZE(cs35l56_controls),
937952

938953
.set_bias_level = cs35l56_set_bias_level,
939954

0 commit comments

Comments
 (0)