Skip to content

Commit cabf0b0

Browse files
Shenghao-Dingbroonie
authored andcommitted
ASoc: tas2781: Set "Speaker Force Firmware Load" as the common kcontrol for both tas27871 and tas2563
Set "Speaker Force Firmware Load" as the common kcontrol for both tas27871 and tas2563 and move it into newly-created tasdevice_snd_controls, and keep the digital gain and analog gain in tas2781_snd_controls. Signed-off-by: Shenghao Ding <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 5080808 commit cabf0b0

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

sound/soc/codecs/tas2781-i2c.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static int tas2781_amp_putvol(struct snd_kcontrol *kcontrol,
104104
return tasdevice_amp_putvol(tas_priv, ucontrol, mc);
105105
}
106106

107-
static int tas2781_force_fwload_get(struct snd_kcontrol *kcontrol,
107+
static int tasdev_force_fwload_get(struct snd_kcontrol *kcontrol,
108108
struct snd_ctl_elem_value *ucontrol)
109109
{
110110
struct snd_soc_component *component =
@@ -119,7 +119,7 @@ static int tas2781_force_fwload_get(struct snd_kcontrol *kcontrol,
119119
return 0;
120120
}
121121

122-
static int tas2781_force_fwload_put(struct snd_kcontrol *kcontrol,
122+
static int tasdev_force_fwload_put(struct snd_kcontrol *kcontrol,
123123
struct snd_ctl_elem_value *ucontrol)
124124
{
125125
struct snd_soc_component *component =
@@ -140,15 +140,18 @@ static int tas2781_force_fwload_put(struct snd_kcontrol *kcontrol,
140140
return change;
141141
}
142142

143+
static const struct snd_kcontrol_new tasdevice_snd_controls[] = {
144+
SOC_SINGLE_BOOL_EXT("Speaker Force Firmware Load", 0,
145+
tasdev_force_fwload_get, tasdev_force_fwload_put),
146+
};
147+
143148
static const struct snd_kcontrol_new tas2781_snd_controls[] = {
144149
SOC_SINGLE_RANGE_EXT_TLV("Speaker Analog Gain", TAS2781_AMP_LEVEL,
145150
1, 0, 20, 0, tas2781_amp_getvol,
146151
tas2781_amp_putvol, amp_vol_tlv),
147152
SOC_SINGLE_RANGE_EXT_TLV("Speaker Digital Gain", TAS2781_DVC_LVL,
148153
0, 0, 200, 1, tas2781_digital_getvol,
149154
tas2781_digital_putvol, dvc_tlv),
150-
SOC_SINGLE_BOOL_EXT("Speaker Force Firmware Load", 0,
151-
tas2781_force_fwload_get, tas2781_force_fwload_put),
152155
};
153156

154157
static int tasdevice_set_profile_id(struct snd_kcontrol *kcontrol,
@@ -590,6 +593,18 @@ static struct snd_soc_dai_driver tasdevice_dai_driver[] = {
590593
static int tasdevice_codec_probe(struct snd_soc_component *codec)
591594
{
592595
struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec);
596+
int rc;
597+
598+
if (tas_priv->chip_id == TAS2781) {
599+
rc = snd_soc_add_component_controls(codec,
600+
tas2781_snd_controls,
601+
ARRAY_SIZE(tas2781_snd_controls));
602+
if (rc < 0) {
603+
dev_err(tas_priv->dev, "%s: Add control err rc = %d",
604+
__func__, rc);
605+
return rc;
606+
}
607+
}
593608

594609
tas_priv->name_prefix = codec->name_prefix;
595610
return tascodec_init(tas_priv, codec, THIS_MODULE, tasdevice_fw_ready);
@@ -617,8 +632,8 @@ static const struct snd_soc_component_driver
617632
soc_codec_driver_tasdevice = {
618633
.probe = tasdevice_codec_probe,
619634
.remove = tasdevice_codec_remove,
620-
.controls = tas2781_snd_controls,
621-
.num_controls = ARRAY_SIZE(tas2781_snd_controls),
635+
.controls = tasdevice_snd_controls,
636+
.num_controls = ARRAY_SIZE(tasdevice_snd_controls),
622637
.dapm_widgets = tasdevice_dapm_widgets,
623638
.num_dapm_widgets = ARRAY_SIZE(tasdevice_dapm_widgets),
624639
.dapm_routes = tasdevice_audio_map,
@@ -759,7 +774,7 @@ MODULE_DEVICE_TABLE(acpi, tasdevice_acpi_match);
759774

760775
static struct i2c_driver tasdevice_i2c_driver = {
761776
.driver = {
762-
.name = "tas2781-codec",
777+
.name = "tasdev-codec",
763778
.of_match_table = of_match_ptr(tasdevice_of_match),
764779
#ifdef CONFIG_ACPI
765780
.acpi_match_table = ACPI_PTR(tasdevice_acpi_match),

0 commit comments

Comments
 (0)