Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ALSA: hda/tas2781: Create an independent lib to save the shared parts for both SPI and I2C driver

Some common parts, such as struct tas2781_hda{...} and some audio
kcontrols are moved into an independent lib for code cleanup.

Signed-off-by: Shenghao Ding <shenghao-ding@ti.com>
Link: https://patch.msgid.link/20250507045813.151-1-shenghao-ding@ti.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Shenghao Ding and committed by
Takashi Iwai
28a09d9e 845b9977

+405 -457
+7
sound/pci/hda/Kconfig
··· 180 180 Say Y or M here to include CS35L56 amplifier support with 181 181 SPI control. 182 182 183 + config SND_HDA_SCODEC_TAS2781 184 + tristate 185 + select SND_HDA_GENERIC 186 + 183 187 config SND_HDA_SCODEC_TAS2781_I2C 184 188 tristate "Build TAS2781 HD-audio side codec support for I2C Bus" 185 189 depends on I2C 186 190 depends on ACPI 187 191 depends on EFI 188 192 depends on SND_SOC 193 + select SND_HDA_SCODEC_TAS2781 189 194 select SND_SOC_TAS2781_COMLIB_I2C 190 195 select SND_SOC_TAS2781_FMWLIB 191 196 select CRC32 ··· 207 202 depends on ACPI 208 203 depends on EFI 209 204 depends on SND_SOC 205 + select SND_HDA_SCODEC_TAS2781 206 + select SND_SOC_TAS2781_COMLIB 210 207 select SND_SOC_TAS2781_FMWLIB 211 208 select CRC8 212 209 select CRC32
+2
sound/pci/hda/Makefile
··· 38 38 snd-hda-scodec-cs35l56-i2c-y := cs35l56_hda_i2c.o 39 39 snd-hda-scodec-cs35l56-spi-y := cs35l56_hda_spi.o 40 40 snd-hda-scodec-component-y := hda_component.o 41 + snd-hda-scodec-tas2781-y := tas2781_hda.o 41 42 snd-hda-scodec-tas2781-i2c-y := tas2781_hda_i2c.o 42 43 snd-hda-scodec-tas2781-spi-y := tas2781_hda_spi.o 43 44 ··· 71 70 obj-$(CONFIG_SND_HDA_SCODEC_CS35L56_I2C) += snd-hda-scodec-cs35l56-i2c.o 72 71 obj-$(CONFIG_SND_HDA_SCODEC_CS35L56_SPI) += snd-hda-scodec-cs35l56-spi.o 73 72 obj-$(CONFIG_SND_HDA_SCODEC_COMPONENT) += snd-hda-scodec-component.o 73 + obj-$(CONFIG_SND_HDA_SCODEC_TAS2781) += snd-hda-scodec-tas2781.o 74 74 obj-$(CONFIG_SND_HDA_SCODEC_TAS2781_I2C) += snd-hda-scodec-tas2781-i2c.o 75 75 obj-$(CONFIG_SND_HDA_SCODEC_TAS2781_SPI) += snd-hda-scodec-tas2781-spi.o 76 76
+198
sound/pci/hda/tas2781_hda.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + // 3 + // TAS2781 HDA Shared Lib for I2C&SPI driver 4 + // 5 + // Copyright 2025 Texas Instruments, Inc. 6 + // 7 + // Author: Shenghao Ding <shenghao-ding@ti.com> 8 + 9 + #include <linux/component.h> 10 + #include <linux/crc8.h> 11 + #include <linux/crc32.h> 12 + #include <linux/efi.h> 13 + #include <linux/firmware.h> 14 + #include <linux/i2c.h> 15 + #include <linux/pm_runtime.h> 16 + #include <sound/soc.h> 17 + #include <sound/tas2781.h> 18 + 19 + #include "tas2781_hda.h" 20 + 21 + void tas2781_hda_remove(struct device *dev, 22 + const struct component_ops *ops) 23 + { 24 + struct tas2781_hda *tas_hda = dev_get_drvdata(dev); 25 + 26 + component_del(tas_hda->dev, ops); 27 + 28 + pm_runtime_get_sync(tas_hda->dev); 29 + pm_runtime_disable(tas_hda->dev); 30 + 31 + pm_runtime_put_noidle(tas_hda->dev); 32 + 33 + tasdevice_remove(tas_hda->priv); 34 + } 35 + EXPORT_SYMBOL_NS_GPL(tas2781_hda_remove, "SND_HDA_SCODEC_TAS2781"); 36 + 37 + int tasdevice_info_profile(struct snd_kcontrol *kcontrol, 38 + struct snd_ctl_elem_info *uinfo) 39 + { 40 + struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 41 + 42 + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 43 + uinfo->count = 1; 44 + uinfo->value.integer.min = 0; 45 + uinfo->value.integer.max = tas_priv->rcabin.ncfgs - 1; 46 + 47 + return 0; 48 + } 49 + EXPORT_SYMBOL_NS_GPL(tasdevice_info_profile, "SND_HDA_SCODEC_TAS2781"); 50 + 51 + int tasdevice_info_programs(struct snd_kcontrol *kcontrol, 52 + struct snd_ctl_elem_info *uinfo) 53 + { 54 + struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 55 + 56 + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 57 + uinfo->count = 1; 58 + uinfo->value.integer.min = 0; 59 + uinfo->value.integer.max = tas_priv->fmw->nr_programs - 1; 60 + 61 + return 0; 62 + } 63 + EXPORT_SYMBOL_NS_GPL(tasdevice_info_programs, "SND_HDA_SCODEC_TAS2781"); 64 + 65 + int tasdevice_info_config(struct snd_kcontrol *kcontrol, 66 + struct snd_ctl_elem_info *uinfo) 67 + { 68 + struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 69 + struct tasdevice_fw *tas_fw = tas_priv->fmw; 70 + 71 + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 72 + uinfo->count = 1; 73 + uinfo->value.integer.min = 0; 74 + uinfo->value.integer.max = tas_fw->nr_configurations - 1; 75 + 76 + return 0; 77 + } 78 + EXPORT_SYMBOL_NS_GPL(tasdevice_info_config, "SND_HDA_SCODEC_TAS2781"); 79 + 80 + int tasdevice_get_profile_id(struct snd_kcontrol *kcontrol, 81 + struct snd_ctl_elem_value *ucontrol) 82 + { 83 + struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 84 + 85 + ucontrol->value.integer.value[0] = tas_priv->rcabin.profile_cfg_id; 86 + 87 + dev_dbg(tas_priv->dev, "%s: kcontrol %s: %d\n", __func__, 88 + kcontrol->id.name, tas_priv->rcabin.profile_cfg_id); 89 + 90 + return 0; 91 + } 92 + EXPORT_SYMBOL_NS_GPL(tasdevice_get_profile_id, "SND_HDA_SCODEC_TAS2781"); 93 + 94 + int tasdevice_set_profile_id(struct snd_kcontrol *kcontrol, 95 + struct snd_ctl_elem_value *ucontrol) 96 + { 97 + struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 98 + int profile_id = ucontrol->value.integer.value[0]; 99 + int max = tas_priv->rcabin.ncfgs - 1; 100 + int val, ret = 0; 101 + 102 + val = clamp(profile_id, 0, max); 103 + 104 + guard(mutex)(&tas_priv->codec_lock); 105 + 106 + dev_dbg(tas_priv->dev, "%s: kcontrol %s: %d -> %d\n", __func__, 107 + kcontrol->id.name, tas_priv->rcabin.profile_cfg_id, val); 108 + 109 + if (tas_priv->rcabin.profile_cfg_id != val) { 110 + tas_priv->rcabin.profile_cfg_id = val; 111 + ret = 1; 112 + } 113 + 114 + return ret; 115 + } 116 + EXPORT_SYMBOL_NS_GPL(tasdevice_set_profile_id, "SND_HDA_SCODEC_TAS2781"); 117 + 118 + int tasdevice_program_get(struct snd_kcontrol *kcontrol, 119 + struct snd_ctl_elem_value *ucontrol) 120 + { 121 + struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 122 + 123 + ucontrol->value.integer.value[0] = tas_priv->cur_prog; 124 + 125 + dev_dbg(tas_priv->dev, "%s: kcontrol %s: %d\n", __func__, 126 + kcontrol->id.name, tas_priv->cur_prog); 127 + 128 + return 0; 129 + } 130 + EXPORT_SYMBOL_NS_GPL(tasdevice_program_get, "SND_HDA_SCODEC_TAS2781"); 131 + 132 + int tasdevice_program_put(struct snd_kcontrol *kcontrol, 133 + struct snd_ctl_elem_value *ucontrol) 134 + { 135 + struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 136 + struct tasdevice_fw *tas_fw = tas_priv->fmw; 137 + int nr_program = ucontrol->value.integer.value[0]; 138 + int max = tas_fw->nr_programs - 1; 139 + int val, ret = 0; 140 + 141 + val = clamp(nr_program, 0, max); 142 + 143 + guard(mutex)(&tas_priv->codec_lock); 144 + 145 + dev_dbg(tas_priv->dev, "%s: kcontrol %s: %d -> %d\n", __func__, 146 + kcontrol->id.name, tas_priv->cur_prog, val); 147 + 148 + if (tas_priv->cur_prog != val) { 149 + tas_priv->cur_prog = val; 150 + ret = 1; 151 + } 152 + 153 + return ret; 154 + } 155 + EXPORT_SYMBOL_NS_GPL(tasdevice_program_put, "SND_HDA_SCODEC_TAS2781"); 156 + 157 + int tasdevice_config_get(struct snd_kcontrol *kcontrol, 158 + struct snd_ctl_elem_value *ucontrol) 159 + { 160 + struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 161 + 162 + ucontrol->value.integer.value[0] = tas_priv->cur_conf; 163 + 164 + dev_dbg(tas_priv->dev, "%s: kcontrol %s: %d\n", __func__, 165 + kcontrol->id.name, tas_priv->cur_conf); 166 + 167 + return 0; 168 + } 169 + EXPORT_SYMBOL_NS_GPL(tasdevice_config_get, "SND_HDA_SCODEC_TAS2781"); 170 + 171 + int tasdevice_config_put(struct snd_kcontrol *kcontrol, 172 + struct snd_ctl_elem_value *ucontrol) 173 + { 174 + struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 175 + struct tasdevice_fw *tas_fw = tas_priv->fmw; 176 + int nr_config = ucontrol->value.integer.value[0]; 177 + int max = tas_fw->nr_configurations - 1; 178 + int val, ret = 0; 179 + 180 + val = clamp(nr_config, 0, max); 181 + 182 + guard(mutex)(&tas_priv->codec_lock); 183 + 184 + dev_dbg(tas_priv->dev, "%s: kcontrol %s: %d -> %d\n", __func__, 185 + kcontrol->id.name, tas_priv->cur_conf, val); 186 + 187 + if (tas_priv->cur_conf != val) { 188 + tas_priv->cur_conf = val; 189 + ret = 1; 190 + } 191 + 192 + return ret; 193 + } 194 + EXPORT_SYMBOL_NS_GPL(tasdevice_config_put, "SND_HDA_SCODEC_TAS2781"); 195 + 196 + MODULE_DESCRIPTION("TAS2781 HDA Driver"); 197 + MODULE_LICENSE("GPL"); 198 + MODULE_AUTHOR("Shenghao Ding, TI, <shenghao-ding@ti.com>");
+31
sound/pci/hda/tas2781_hda.h
··· 44 44 .private_value = xdata, \ 45 45 } 46 46 47 + struct tas2781_hda { 48 + struct device *dev; 49 + struct tasdevice_priv *priv; 50 + struct snd_kcontrol *dsp_prog_ctl; 51 + struct snd_kcontrol *dsp_conf_ctl; 52 + struct snd_kcontrol *prof_ctl; 53 + enum device_catlog_id catlog_id; 54 + void *hda_priv; 55 + }; 56 + 57 + void tas2781_hda_remove(struct device *dev, 58 + const struct component_ops *ops); 59 + int tasdevice_info_profile(struct snd_kcontrol *kctl, 60 + struct snd_ctl_elem_info *uctl); 61 + int tasdevice_info_programs(struct snd_kcontrol *kctl, 62 + struct snd_ctl_elem_info *uctl); 63 + int tasdevice_info_config(struct snd_kcontrol *kctl, 64 + struct snd_ctl_elem_info *uctl); 65 + int tasdevice_set_profile_id(struct snd_kcontrol *kctl, 66 + struct snd_ctl_elem_value *uctl); 67 + int tasdevice_get_profile_id(struct snd_kcontrol *kctl, 68 + struct snd_ctl_elem_value *uctl); 69 + int tasdevice_program_get(struct snd_kcontrol *kctl, 70 + struct snd_ctl_elem_value *uctl); 71 + int tasdevice_program_put(struct snd_kcontrol *kctl, 72 + struct snd_ctl_elem_value *uctl); 73 + int tasdevice_config_put(struct snd_kcontrol *kctl, 74 + struct snd_ctl_elem_value *uctl); 75 + int tasdevice_config_get(struct snd_kcontrol *kctl, 76 + struct snd_ctl_elem_value *uctl); 77 + 47 78 #endif
+17 -197
sound/pci/hda/tas2781_hda_i2c.c
··· 51 51 TAS2563_CAL_R0_LOW, TAS2563_CAL_TLIM, 52 52 }; 53 53 54 - struct tas2781_hda { 55 - struct device *dev; 56 - struct tasdevice_priv *priv; 57 - struct snd_kcontrol *dsp_prog_ctl; 58 - struct snd_kcontrol *dsp_conf_ctl; 59 - struct snd_kcontrol *prof_ctl; 54 + struct tas2781_hda_i2c_priv { 60 55 struct snd_kcontrol *snd_ctls[2]; 61 56 }; 62 57 ··· 168 173 default: 169 174 break; 170 175 } 171 - } 172 - 173 - static int tasdevice_info_profile(struct snd_kcontrol *kcontrol, 174 - struct snd_ctl_elem_info *uinfo) 175 - { 176 - struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 177 - 178 - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 179 - uinfo->count = 1; 180 - uinfo->value.integer.min = 0; 181 - uinfo->value.integer.max = tas_priv->rcabin.ncfgs - 1; 182 - 183 - return 0; 184 - } 185 - 186 - static int tasdevice_get_profile_id(struct snd_kcontrol *kcontrol, 187 - struct snd_ctl_elem_value *ucontrol) 188 - { 189 - struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 190 - 191 - mutex_lock(&tas_priv->codec_lock); 192 - 193 - ucontrol->value.integer.value[0] = tas_priv->rcabin.profile_cfg_id; 194 - 195 - dev_dbg(tas_priv->dev, "%s: kcontrol %s: %d\n", 196 - __func__, kcontrol->id.name, tas_priv->rcabin.profile_cfg_id); 197 - 198 - mutex_unlock(&tas_priv->codec_lock); 199 - 200 - return 0; 201 - } 202 - 203 - static int tasdevice_set_profile_id(struct snd_kcontrol *kcontrol, 204 - struct snd_ctl_elem_value *ucontrol) 205 - { 206 - struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 207 - int nr_profile = ucontrol->value.integer.value[0]; 208 - int max = tas_priv->rcabin.ncfgs - 1; 209 - int val, ret = 0; 210 - 211 - val = clamp(nr_profile, 0, max); 212 - 213 - mutex_lock(&tas_priv->codec_lock); 214 - 215 - dev_dbg(tas_priv->dev, "%s: kcontrol %s: %d -> %d\n", 216 - __func__, kcontrol->id.name, 217 - tas_priv->rcabin.profile_cfg_id, val); 218 - 219 - if (tas_priv->rcabin.profile_cfg_id != val) { 220 - tas_priv->rcabin.profile_cfg_id = val; 221 - ret = 1; 222 - } 223 - 224 - mutex_unlock(&tas_priv->codec_lock); 225 - 226 - return ret; 227 - } 228 - 229 - static int tasdevice_info_programs(struct snd_kcontrol *kcontrol, 230 - struct snd_ctl_elem_info *uinfo) 231 - { 232 - struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 233 - struct tasdevice_fw *tas_fw = tas_priv->fmw; 234 - 235 - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 236 - uinfo->count = 1; 237 - uinfo->value.integer.min = 0; 238 - uinfo->value.integer.max = tas_fw->nr_programs - 1; 239 - 240 - return 0; 241 - } 242 - 243 - static int tasdevice_info_config(struct snd_kcontrol *kcontrol, 244 - struct snd_ctl_elem_info *uinfo) 245 - { 246 - struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 247 - struct tasdevice_fw *tas_fw = tas_priv->fmw; 248 - 249 - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 250 - uinfo->count = 1; 251 - uinfo->value.integer.min = 0; 252 - uinfo->value.integer.max = tas_fw->nr_configurations - 1; 253 - 254 - return 0; 255 - } 256 - 257 - static int tasdevice_program_get(struct snd_kcontrol *kcontrol, 258 - struct snd_ctl_elem_value *ucontrol) 259 - { 260 - struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 261 - 262 - mutex_lock(&tas_priv->codec_lock); 263 - 264 - ucontrol->value.integer.value[0] = tas_priv->cur_prog; 265 - 266 - dev_dbg(tas_priv->dev, "%s: kcontrol %s: %d\n", 267 - __func__, kcontrol->id.name, tas_priv->cur_prog); 268 - 269 - mutex_unlock(&tas_priv->codec_lock); 270 - 271 - return 0; 272 - } 273 - 274 - static int tasdevice_program_put(struct snd_kcontrol *kcontrol, 275 - struct snd_ctl_elem_value *ucontrol) 276 - { 277 - struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 278 - struct tasdevice_fw *tas_fw = tas_priv->fmw; 279 - int nr_program = ucontrol->value.integer.value[0]; 280 - int max = tas_fw->nr_programs - 1; 281 - int val, ret = 0; 282 - 283 - val = clamp(nr_program, 0, max); 284 - 285 - mutex_lock(&tas_priv->codec_lock); 286 - 287 - dev_dbg(tas_priv->dev, "%s: kcontrol %s: %d -> %d\n", 288 - __func__, kcontrol->id.name, tas_priv->cur_prog, val); 289 - 290 - if (tas_priv->cur_prog != val) { 291 - tas_priv->cur_prog = val; 292 - ret = 1; 293 - } 294 - 295 - mutex_unlock(&tas_priv->codec_lock); 296 - 297 - return ret; 298 - } 299 - 300 - static int tasdevice_config_get(struct snd_kcontrol *kcontrol, 301 - struct snd_ctl_elem_value *ucontrol) 302 - { 303 - struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 304 - 305 - mutex_lock(&tas_priv->codec_lock); 306 - 307 - ucontrol->value.integer.value[0] = tas_priv->cur_conf; 308 - 309 - dev_dbg(tas_priv->dev, "%s: kcontrol %s: %d\n", 310 - __func__, kcontrol->id.name, tas_priv->cur_conf); 311 - 312 - mutex_unlock(&tas_priv->codec_lock); 313 - 314 - return 0; 315 - } 316 - 317 - static int tasdevice_config_put(struct snd_kcontrol *kcontrol, 318 - struct snd_ctl_elem_value *ucontrol) 319 - { 320 - struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 321 - struct tasdevice_fw *tas_fw = tas_priv->fmw; 322 - int nr_config = ucontrol->value.integer.value[0]; 323 - int max = tas_fw->nr_configurations - 1; 324 - int val, ret = 0; 325 - 326 - val = clamp(nr_config, 0, max); 327 - 328 - mutex_lock(&tas_priv->codec_lock); 329 - 330 - dev_dbg(tas_priv->dev, "%s: kcontrol %s: %d -> %d\n", 331 - __func__, kcontrol->id.name, tas_priv->cur_conf, val); 332 - 333 - if (tas_priv->cur_conf != val) { 334 - tas_priv->cur_conf = val; 335 - ret = 1; 336 - } 337 - 338 - mutex_unlock(&tas_priv->codec_lock); 339 - 340 - return ret; 341 176 } 342 177 343 178 static int tas2781_amp_getvol(struct snd_kcontrol *kcontrol, ··· 440 615 441 616 static void tas2781_hda_remove_controls(struct tas2781_hda *tas_hda) 442 617 { 618 + struct tas2781_hda_i2c_priv *hda_priv = tas_hda->hda_priv; 443 619 struct hda_codec *codec = tas_hda->priv->codec; 444 620 445 621 snd_ctl_remove(codec->card, tas_hda->dsp_prog_ctl); 446 622 snd_ctl_remove(codec->card, tas_hda->dsp_conf_ctl); 447 623 448 - for (int i = ARRAY_SIZE(tas_hda->snd_ctls) - 1; i >= 0; i--) 449 - snd_ctl_remove(codec->card, tas_hda->snd_ctls[i]); 624 + for (int i = ARRAY_SIZE(hda_priv->snd_ctls) - 1; i >= 0; i--) 625 + snd_ctl_remove(codec->card, hda_priv->snd_ctls[i]); 450 626 451 627 snd_ctl_remove(codec->card, tas_hda->prof_ctl); 452 628 } ··· 456 630 { 457 631 struct tasdevice_priv *tas_priv = context; 458 632 struct tas2781_hda *tas_hda = dev_get_drvdata(tas_priv->dev); 633 + struct tas2781_hda_i2c_priv *hda_priv = tas_hda->hda_priv; 459 634 struct hda_codec *codec = tas_priv->codec; 460 635 int i, ret, spk_id; 461 636 ··· 477 650 } 478 651 479 652 for (i = 0; i < ARRAY_SIZE(tas2781_snd_controls); i++) { 480 - tas_hda->snd_ctls[i] = snd_ctl_new1(&tas2781_snd_controls[i], 653 + hda_priv->snd_ctls[i] = snd_ctl_new1(&tas2781_snd_controls[i], 481 654 tas_priv); 482 - ret = snd_ctl_add(codec->card, tas_hda->snd_ctls[i]); 655 + ret = snd_ctl_add(codec->card, hda_priv->snd_ctls[i]); 483 656 if (ret) { 484 657 dev_err(tas_priv->dev, 485 658 "Failed to add KControl %s = %d\n", ··· 632 805 .unbind = tas2781_hda_unbind, 633 806 }; 634 807 635 - static void tas2781_hda_remove(struct device *dev) 636 - { 637 - struct tas2781_hda *tas_hda = dev_get_drvdata(dev); 638 - 639 - component_del(tas_hda->dev, &tas2781_hda_comp_ops); 640 - 641 - pm_runtime_get_sync(tas_hda->dev); 642 - pm_runtime_disable(tas_hda->dev); 643 - 644 - pm_runtime_put_noidle(tas_hda->dev); 645 - 646 - tasdevice_remove(tas_hda->priv); 647 - } 648 - 649 808 static int tas2781_hda_i2c_probe(struct i2c_client *clt) 650 809 { 810 + struct tas2781_hda_i2c_priv *hda_priv; 651 811 struct tas2781_hda *tas_hda; 652 812 const char *device_name; 653 813 int ret; 654 814 655 - 656 815 tas_hda = devm_kzalloc(&clt->dev, sizeof(*tas_hda), GFP_KERNEL); 657 816 if (!tas_hda) 658 817 return -ENOMEM; 818 + 819 + hda_priv = devm_kzalloc(&clt->dev, sizeof(*hda_priv), GFP_KERNEL); 820 + if (!hda_priv) 821 + return -ENOMEM; 822 + 823 + tas_hda->hda_priv = hda_priv; 659 824 660 825 dev_set_drvdata(&clt->dev, tas_hda); 661 826 tas_hda->dev = &clt->dev; ··· 695 876 696 877 err: 697 878 if (ret) 698 - tas2781_hda_remove(&clt->dev); 879 + tas2781_hda_remove(&clt->dev, &tas2781_hda_comp_ops); 699 880 return ret; 700 881 } 701 882 702 883 static void tas2781_hda_i2c_remove(struct i2c_client *clt) 703 884 { 704 - tas2781_hda_remove(&clt->dev); 885 + tas2781_hda_remove(&clt->dev, &tas2781_hda_comp_ops); 705 886 } 706 887 707 888 static int tas2781_runtime_suspend(struct device *dev) ··· 829 1010 MODULE_AUTHOR("Shenghao Ding, TI, <shenghao-ding@ti.com>"); 830 1011 MODULE_LICENSE("GPL"); 831 1012 MODULE_IMPORT_NS("SND_SOC_TAS2781_FMWLIB"); 1013 + MODULE_IMPORT_NS("SND_HDA_SCODEC_TAS2781");
+150 -260
sound/pci/hda/tas2781_hda_spi.c
··· 49 49 #define TAS2781_REG_CLK_CONFIG TASDEVICE_REG(0x0, 0x0, 0x5c) 50 50 #define TAS2781_REG_CLK_CONFIG_RESET 0x19 51 51 52 - struct tas2781_hda { 53 - struct tasdevice_priv *priv; 54 - struct acpi_device *dacpi; 55 - struct snd_kcontrol *dsp_prog_ctl; 56 - struct snd_kcontrol *dsp_conf_ctl; 52 + struct tas2781_hda_spi_priv { 57 53 struct snd_kcontrol *snd_ctls[3]; 58 - struct snd_kcontrol *prof_ctl; 59 54 }; 60 55 61 56 static const struct regmap_range_cfg tasdevice_ranges[] = { ··· 188 193 } else { 189 194 ret = tasdevice_dev_write(tas_dev, tas_dev->index, 190 195 TASDEVICE_REG_SWRESET, TASDEVICE_REG_SWRESET_RESET); 191 - if (ret < 0) 196 + if (ret < 0) { 192 197 dev_err(tas_dev->dev, "dev sw-reset fail, %d\n", ret); 198 + return; 199 + } 193 200 fsleep(1000); 194 201 } 195 202 } ··· 320 323 } 321 324 322 325 static int tas2781_read_acpi(struct tas2781_hda *tas_hda, 323 - const char *hid, 324 - int id) 326 + const char *hid, int id) 325 327 { 326 328 struct tasdevice_priv *p = tas_hda->priv; 327 329 struct acpi_device *adev; ··· 337 341 } 338 342 339 343 strscpy(p->dev_name, hid, sizeof(p->dev_name)); 340 - tas_hda->dacpi = adev; 341 344 physdev = get_device(acpi_get_first_physical_node(adev)); 342 345 acpi_dev_put(adev); 343 346 ··· 403 408 pm_runtime_mark_last_busy(dev); 404 409 pm_runtime_put_autosuspend(dev); 405 410 } 406 - } 407 - 408 - static int tasdevice_info_profile(struct snd_kcontrol *kcontrol, 409 - struct snd_ctl_elem_info *uinfo) 410 - { 411 - struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 412 - 413 - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 414 - uinfo->count = 1; 415 - uinfo->value.integer.min = 0; 416 - uinfo->value.integer.max = tas_priv->rcabin.ncfgs - 1; 417 - 418 - return 0; 419 - } 420 - 421 - static int tasdevice_get_profile_id(struct snd_kcontrol *kcontrol, 422 - struct snd_ctl_elem_value *ucontrol) 423 - { 424 - struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 425 - 426 - ucontrol->value.integer.value[0] = tas_priv->rcabin.profile_cfg_id; 427 - 428 - return 0; 429 - } 430 - 431 - static int tasdevice_set_profile_id(struct snd_kcontrol *kcontrol, 432 - struct snd_ctl_elem_value *ucontrol) 433 - { 434 - struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 435 - int max = tas_priv->rcabin.ncfgs - 1; 436 - int val; 437 - 438 - val = clamp(ucontrol->value.integer.value[0], 0, max); 439 - if (tas_priv->rcabin.profile_cfg_id != val) { 440 - tas_priv->rcabin.profile_cfg_id = val; 441 - return 1; 442 - } 443 - 444 - return 0; 445 - } 446 - 447 - static int tasdevice_info_programs(struct snd_kcontrol *kcontrol, 448 - struct snd_ctl_elem_info *uinfo) 449 - { 450 - struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 451 - 452 - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 453 - uinfo->count = 1; 454 - uinfo->value.integer.min = 0; 455 - uinfo->value.integer.max = tas_priv->fmw->nr_programs - 1; 456 - 457 - return 0; 458 - } 459 - 460 - static int tasdevice_info_config(struct snd_kcontrol *kcontrol, 461 - struct snd_ctl_elem_info *uinfo) 462 - { 463 - struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 464 - 465 - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 466 - uinfo->count = 1; 467 - uinfo->value.integer.min = 0; 468 - uinfo->value.integer.max = tas_priv->fmw->nr_configurations - 1; 469 - 470 - return 0; 471 - } 472 - 473 - static int tasdevice_program_get(struct snd_kcontrol *kcontrol, 474 - struct snd_ctl_elem_value *ucontrol) 475 - { 476 - struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 477 - 478 - ucontrol->value.integer.value[0] = tas_priv->cur_prog; 479 - 480 - return 0; 481 - } 482 - 483 - static int tasdevice_program_put(struct snd_kcontrol *kcontrol, 484 - struct snd_ctl_elem_value *ucontrol) 485 - { 486 - struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 487 - int nr_program = ucontrol->value.integer.value[0]; 488 - int max = tas_priv->fmw->nr_programs - 1; 489 - int val; 490 - 491 - val = clamp(nr_program, 0, max); 492 - 493 - if (tas_priv->cur_prog != val) { 494 - tas_priv->cur_prog = val; 495 - return 1; 496 - } 497 - 498 - return 0; 499 - } 500 - 501 - static int tasdevice_config_get(struct snd_kcontrol *kcontrol, 502 - struct snd_ctl_elem_value *ucontrol) 503 - { 504 - struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 505 - 506 - ucontrol->value.integer.value[0] = tas_priv->cur_conf; 507 - 508 - return 0; 509 - } 510 - 511 - static int tasdevice_config_put(struct snd_kcontrol *kcontrol, 512 - struct snd_ctl_elem_value *ucontrol) 513 - { 514 - struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); 515 - int max = tas_priv->fmw->nr_configurations - 1; 516 - int val; 517 - 518 - val = clamp(ucontrol->value.integer.value[0], 0, max); 519 - 520 - if (tas_priv->cur_conf != val) { 521 - tas_priv->cur_conf = val; 522 - return 1; 523 - } 524 - 525 - return 0; 526 411 } 527 412 528 413 /* ··· 493 618 return change; 494 619 } 495 620 496 - static const struct snd_kcontrol_new tas2781_snd_controls[] = { 497 - ACARD_SINGLE_RANGE_EXT_TLV("Speaker Analog Gain 0", TAS2781_AMP_LEVEL, 498 - 1, 0, 20, 0, tas2781_amp_getvol, 499 - tas2781_amp_putvol, amp_vol_tlv), 500 - ACARD_SINGLE_RANGE_EXT_TLV("Speaker Digital Gain 0", TAS2781_DVC_LVL, 501 - 0, 0, 200, 1, tas2781_digital_getvol, 502 - tas2781_digital_putvol, dvc_tlv), 503 - ACARD_SINGLE_BOOL_EXT("Speaker Force Firmware Load 0", 0, 504 - tas2781_force_fwload_get, tas2781_force_fwload_put), 505 - ACARD_SINGLE_RANGE_EXT_TLV("Speaker Analog Gain 1", TAS2781_AMP_LEVEL, 506 - 1, 0, 20, 0, tas2781_amp_getvol, 507 - tas2781_amp_putvol, amp_vol_tlv), 508 - ACARD_SINGLE_RANGE_EXT_TLV("Speaker Digital Gain 1", TAS2781_DVC_LVL, 509 - 0, 0, 200, 1, tas2781_digital_getvol, 510 - tas2781_digital_putvol, dvc_tlv), 511 - ACARD_SINGLE_BOOL_EXT("Speaker Force Firmware Load 1", 0, 512 - tas2781_force_fwload_get, tas2781_force_fwload_put), 621 + struct snd_kcontrol_new tas2781_snd_ctls[] = { 622 + ACARD_SINGLE_RANGE_EXT_TLV(NULL, TAS2781_AMP_LEVEL, 1, 0, 20, 0, 623 + tas2781_amp_getvol, tas2781_amp_putvol, amp_vol_tlv), 624 + ACARD_SINGLE_RANGE_EXT_TLV(NULL, TAS2781_DVC_LVL, 0, 0, 200, 1, 625 + tas2781_digital_getvol, tas2781_digital_putvol, dvc_tlv), 626 + ACARD_SINGLE_BOOL_EXT(NULL, 0, tas2781_force_fwload_get, 627 + tas2781_force_fwload_put), 513 628 }; 514 629 515 - static const struct snd_kcontrol_new tas2781_prof_ctrl[] = { 516 - { 517 - .name = "Speaker Profile Id - 0", 630 + struct snd_kcontrol_new tas2781_prof_ctl = { 518 631 .iface = SNDRV_CTL_ELEM_IFACE_CARD, 519 632 .info = tasdevice_info_profile, 520 633 .get = tasdevice_get_profile_id, 521 634 .put = tasdevice_set_profile_id, 522 - }, 523 - { 524 - .name = "Speaker Profile Id - 1", 525 - .iface = SNDRV_CTL_ELEM_IFACE_CARD, 526 - .info = tasdevice_info_profile, 527 - .get = tasdevice_get_profile_id, 528 - .put = tasdevice_set_profile_id, 529 - }, 530 - }; 531 - static const struct snd_kcontrol_new tas2781_dsp_prog_ctrl[] = { 532 - { 533 - .name = "Speaker Program Id 0", 534 - .iface = SNDRV_CTL_ELEM_IFACE_CARD, 535 - .info = tasdevice_info_programs, 536 - .get = tasdevice_program_get, 537 - .put = tasdevice_program_put, 538 - }, 539 - { 540 - .name = "Speaker Program Id 1", 541 - .iface = SNDRV_CTL_ELEM_IFACE_CARD, 542 - .info = tasdevice_info_programs, 543 - .get = tasdevice_program_get, 544 - .put = tasdevice_program_put, 545 - }, 546 635 }; 547 636 548 - static const struct snd_kcontrol_new tas2781_dsp_conf_ctrl[] = { 549 - { 550 - .name = "Speaker Config Id 0", 551 - .iface = SNDRV_CTL_ELEM_IFACE_CARD, 552 - .info = tasdevice_info_config, 553 - .get = tasdevice_config_get, 554 - .put = tasdevice_config_put, 555 - }, 556 - { 557 - .name = "Speaker Config Id 1", 558 - .iface = SNDRV_CTL_ELEM_IFACE_CARD, 559 - .info = tasdevice_info_config, 560 - .get = tasdevice_config_get, 561 - .put = tasdevice_config_put, 562 - }, 637 + struct snd_kcontrol_new tas2781_dsp_ctls[] = { 638 + /* Speaker Program */ 639 + { 640 + .iface = SNDRV_CTL_ELEM_IFACE_CARD, 641 + .info = tasdevice_info_programs, 642 + .get = tasdevice_program_get, 643 + .put = tasdevice_program_put, 644 + }, 645 + /* Speaker Config */ 646 + { 647 + .iface = SNDRV_CTL_ELEM_IFACE_CARD, 648 + .info = tasdevice_info_config, 649 + .get = tasdevice_config_get, 650 + .put = tasdevice_config_put, 651 + }, 563 652 }; 564 653 565 654 static void tas2781_apply_calib(struct tasdevice_priv *tas_priv) ··· 692 853 static void tas2781_hda_remove_controls(struct tas2781_hda *tas_hda) 693 854 { 694 855 struct hda_codec *codec = tas_hda->priv->codec; 856 + struct tas2781_hda_spi_priv *h_priv = tas_hda->hda_priv; 695 857 696 858 snd_ctl_remove(codec->card, tas_hda->dsp_prog_ctl); 697 859 698 860 snd_ctl_remove(codec->card, tas_hda->dsp_conf_ctl); 699 861 700 - for (int i = ARRAY_SIZE(tas_hda->snd_ctls) - 1; i >= 0; i--) 701 - snd_ctl_remove(codec->card, tas_hda->snd_ctls[i]); 862 + for (int i = ARRAY_SIZE(h_priv->snd_ctls) - 1; i >= 0; i--) 863 + snd_ctl_remove(codec->card, h_priv->snd_ctls[i]); 702 864 703 865 snd_ctl_remove(codec->card, tas_hda->prof_ctl); 866 + } 867 + 868 + static int tas2781_hda_spi_prf_ctl(struct tas2781_hda *h) 869 + { 870 + struct tasdevice_priv *p = h->priv; 871 + struct hda_codec *c = p->codec; 872 + char name[64]; 873 + int rc; 874 + 875 + snprintf(name, sizeof(name), "Speaker-%d Profile Id", p->index); 876 + tas2781_prof_ctl.name = name; 877 + h->prof_ctl = snd_ctl_new1(&tas2781_prof_ctl, p); 878 + rc = snd_ctl_add(c->card, h->prof_ctl); 879 + if (rc) 880 + dev_err(p->dev, "Failed to add KControl: %s, rc = %d\n", 881 + tas2781_prof_ctl.name, rc); 882 + return rc; 883 + } 884 + 885 + static int tas2781_hda_spi_snd_ctls(struct tas2781_hda *h) 886 + { 887 + struct tas2781_hda_spi_priv *h_priv = h->hda_priv; 888 + struct tasdevice_priv *p = h->priv; 889 + struct hda_codec *c = p->codec; 890 + char name[64]; 891 + int i = 0; 892 + int rc; 893 + 894 + snprintf(name, sizeof(name), "Speaker-%d Analog Volume", p->index); 895 + tas2781_snd_ctls[i].name = name; 896 + h_priv->snd_ctls[i] = snd_ctl_new1(&tas2781_snd_ctls[i], p); 897 + rc = snd_ctl_add(c->card, h_priv->snd_ctls[i]); 898 + if (rc) { 899 + dev_err(p->dev, "Failed to add KControl: %s, rc = %d\n", 900 + tas2781_snd_ctls[i].name, rc); 901 + return rc; 902 + } 903 + i++; 904 + snprintf(name, sizeof(name), "Speaker-%d Digital Volume", p->index); 905 + tas2781_snd_ctls[i].name = name; 906 + h_priv->snd_ctls[i] = snd_ctl_new1(&tas2781_snd_ctls[i], p); 907 + rc = snd_ctl_add(c->card, h_priv->snd_ctls[i]); 908 + if (rc) { 909 + dev_err(p->dev, "Failed to add KControl: %s, rc = %d\n", 910 + tas2781_snd_ctls[i].name, rc); 911 + return rc; 912 + } 913 + i++; 914 + snprintf(name, sizeof(name), "Froce Speaker-%d FW Load", p->index); 915 + tas2781_snd_ctls[i].name = name; 916 + h_priv->snd_ctls[i] = snd_ctl_new1(&tas2781_snd_ctls[i], p); 917 + rc = snd_ctl_add(c->card, h_priv->snd_ctls[i]); 918 + if (rc) { 919 + dev_err(p->dev, "Failed to add KControl: %s, rc = %d\n", 920 + tas2781_snd_ctls[i].name, rc); 921 + } 922 + return rc; 923 + } 924 + 925 + static int tas2781_hda_spi_dsp_ctls(struct tas2781_hda *h) 926 + { 927 + struct tasdevice_priv *p = h->priv; 928 + struct hda_codec *c = p->codec; 929 + char name[64]; 930 + int i = 0; 931 + int rc; 932 + 933 + snprintf(name, sizeof(name), "Speaker-%d Program Id", p->index); 934 + tas2781_dsp_ctls[i].name = name; 935 + h->dsp_prog_ctl = snd_ctl_new1(&tas2781_dsp_ctls[i], p); 936 + rc = snd_ctl_add(c->card, h->dsp_prog_ctl); 937 + if (rc) { 938 + dev_err(p->dev, "Failed to add KControl: %s, rc = %d\n", 939 + tas2781_dsp_ctls[i].name, rc); 940 + return rc; 941 + } 942 + i++; 943 + snprintf(name, sizeof(name), "Speaker-%d Config Id", p->index); 944 + tas2781_dsp_ctls[i].name = name; 945 + h->dsp_conf_ctl = snd_ctl_new1(&tas2781_dsp_ctls[i], p); 946 + rc = snd_ctl_add(c->card, h->dsp_conf_ctl); 947 + if (rc) { 948 + dev_err(p->dev, "Failed to add KControl: %s, rc = %d\n", 949 + tas2781_dsp_ctls[i].name, rc); 950 + } 951 + 952 + return rc; 704 953 } 705 954 706 955 static void tasdev_fw_ready(const struct firmware *fmw, void *context) ··· 796 869 struct tasdevice_priv *tas_priv = context; 797 870 struct tas2781_hda *tas_hda = dev_get_drvdata(tas_priv->dev); 798 871 struct hda_codec *codec = tas_priv->codec; 799 - int i, j, ret, val; 872 + int ret, val; 800 873 801 874 pm_runtime_get_sync(tas_priv->dev); 802 875 guard(mutex)(&tas_priv->codec_lock); ··· 806 879 goto out; 807 880 808 881 /* Add control one time only. */ 809 - tas_hda->prof_ctl = snd_ctl_new1(&tas2781_prof_ctrl[tas_priv->index], 810 - tas_priv); 811 - ret = snd_ctl_add(codec->card, tas_hda->prof_ctl); 812 - if (ret) { 813 - dev_err(tas_priv->dev, "Failed to add KControl %s = %d\n", 814 - tas2781_prof_ctrl[tas_priv->index].name, ret); 882 + ret = tas2781_hda_spi_prf_ctl(tas_hda); 883 + if (ret) 815 884 goto out; 816 - } 817 - j = tas_priv->index * ARRAY_SIZE(tas2781_snd_controls) / 2; 818 - for (i = 0; i < 3; i++) { 819 - tas_hda->snd_ctls[i] = snd_ctl_new1(&tas2781_snd_controls[i+j], 820 - tas_priv); 821 - ret = snd_ctl_add(codec->card, tas_hda->snd_ctls[i]); 822 - if (ret) { 823 - dev_err(tas_priv->dev, 824 - "Failed to add KControl %s = %d\n", 825 - tas2781_snd_controls[i+tas_priv->index*3].name, 826 - ret); 827 - goto out; 828 - } 829 - } 885 + 886 + ret = tas2781_hda_spi_snd_ctls(tas_hda); 887 + if (ret) 888 + goto out; 830 889 831 890 tasdevice_dsp_remove(tas_priv); 832 891 833 892 tas_priv->fw_state = TASDEVICE_DSP_FW_PENDING; 834 - scnprintf(tas_priv->coef_binaryname, 64, "TAS2XXX%08X-%01d.bin", 835 - codec->core.subsystem_id, tas_priv->index); 893 + scnprintf(tas_priv->coef_binaryname, 64, "TAS2XXX%04X-%01d.bin", 894 + lower_16_bits(codec->core.subsystem_id), tas_priv->index); 836 895 ret = tasdevice_dsp_parser(tas_priv); 837 896 if (ret) { 838 897 dev_err(tas_priv->dev, "dspfw load %s error\n", ··· 827 914 goto out; 828 915 } 829 916 830 - /* Add control one time only. */ 831 - tas_hda->dsp_prog_ctl = 832 - snd_ctl_new1(&tas2781_dsp_prog_ctrl[tas_priv->index], 833 - tas_priv); 834 - ret = snd_ctl_add(codec->card, tas_hda->dsp_prog_ctl); 835 - if (ret) { 836 - dev_err(tas_priv->dev, 837 - "Failed to add KControl %s = %d\n", 838 - tas2781_dsp_prog_ctrl[tas_priv->index].name, ret); 917 + ret = tas2781_hda_spi_dsp_ctls(tas_hda); 918 + if (ret) 839 919 goto out; 840 - } 841 - 842 - tas_hda->dsp_conf_ctl = 843 - snd_ctl_new1(&tas2781_dsp_conf_ctrl[tas_priv->index], 844 - tas_priv); 845 - ret = snd_ctl_add(codec->card, tas_hda->dsp_conf_ctl); 846 - if (ret) { 847 - dev_err(tas_priv->dev, "Failed to add KControl %s = %d\n", 848 - tas2781_dsp_conf_ctrl[tas_priv->index].name, ret); 849 - goto out; 850 - } 851 - 920 + /* Perform AMP reset before firmware download. */ 852 921 tas2781_spi_reset(tas_priv); 853 922 tas_priv->rcabin.profile_cfg_id = 0; 854 923 855 924 tas_priv->fw_state = TASDEVICE_DSP_FW_ALL_OK; 856 - ret = tas_priv->dev_read(tas_priv, tas_priv->index, 925 + ret = tasdevice_spi_dev_read(tas_priv, tas_priv->index, 857 926 TAS2781_REG_CLK_CONFIG, &val); 858 927 if (ret < 0) 859 928 goto out; ··· 847 952 ret); 848 953 goto out; 849 954 } 955 + tas_priv->fw_state = TASDEVICE_DSP_FW_ALL_OK; 850 956 } 851 957 if (tas_priv->fmw->nr_programs > 0) 852 958 tas_priv->tasdevice[tas_priv->index].cur_prog = 0; ··· 858 962 * If calibrated data occurs error, dsp will still works with default 859 963 * calibrated data inside algo. 860 964 */ 861 - 965 + tas2781_save_calibration(tas_priv); 862 966 out: 863 967 release_firmware(fmw); 864 968 pm_runtime_mark_last_busy(tas_hda->priv->dev); ··· 928 1032 .unbind = tas2781_hda_unbind, 929 1033 }; 930 1034 931 - static void tas2781_hda_remove(struct device *dev) 932 - { 933 - struct tas2781_hda *tas_hda = dev_get_drvdata(dev); 934 - 935 - component_del(tas_hda->priv->dev, &tas2781_hda_comp_ops); 936 - 937 - pm_runtime_get_sync(tas_hda->priv->dev); 938 - pm_runtime_disable(tas_hda->priv->dev); 939 - 940 - pm_runtime_put_noidle(tas_hda->priv->dev); 941 - 942 - mutex_destroy(&tas_hda->priv->codec_lock); 943 - } 944 - 945 1035 static int tas2781_hda_spi_probe(struct spi_device *spi) 946 1036 { 1037 + struct tas2781_hda_spi_priv *hda_priv; 947 1038 struct tasdevice_priv *tas_priv; 948 1039 struct tas2781_hda *tas_hda; 949 1040 const char *device_name; ··· 940 1057 if (!tas_hda) 941 1058 return -ENOMEM; 942 1059 1060 + hda_priv = devm_kzalloc(&spi->dev, sizeof(*hda_priv), GFP_KERNEL); 1061 + if (!hda_priv) 1062 + return -ENOMEM; 1063 + 1064 + tas_hda->hda_priv = hda_priv; 943 1065 spi->max_speed_hz = TAS2781_SPI_MAX_FREQ; 944 1066 945 1067 tas_priv = devm_kzalloc(&spi->dev, sizeof(*tas_priv), GFP_KERNEL); ··· 975 1087 spi_get_chipselect(spi, 0)); 976 1088 if (ret) 977 1089 return dev_err_probe(tas_priv->dev, ret, 978 - "Platform not supported\n"); 1090 + "Platform not supported\n"); 979 1091 980 1092 tasdevice_spi_init(tas_priv); 981 - 982 - ret = component_add(tas_priv->dev, &tas2781_hda_comp_ops); 983 - if (ret) { 984 - dev_err(tas_priv->dev, "Register component fail: %d\n", ret); 985 - return ret; 986 - } 987 1093 988 1094 pm_runtime_set_autosuspend_delay(tas_priv->dev, 3000); 989 1095 pm_runtime_use_autosuspend(tas_priv->dev); ··· 988 1106 989 1107 pm_runtime_put_autosuspend(tas_priv->dev); 990 1108 991 - return 0; 1109 + ret = component_add(tas_priv->dev, &tas2781_hda_comp_ops); 1110 + if (ret) { 1111 + dev_err(tas_priv->dev, "Register component fail: %d\n", ret); 1112 + pm_runtime_disable(tas_priv->dev); 1113 + tas2781_hda_remove(&spi->dev, &tas2781_hda_comp_ops); 1114 + } 1115 + 1116 + return ret; 992 1117 } 993 1118 994 1119 static void tas2781_hda_spi_remove(struct spi_device *spi) 995 1120 { 996 - tas2781_hda_remove(&spi->dev); 1121 + tas2781_hda_remove(&spi->dev, &tas2781_hda_comp_ops); 997 1122 } 998 1123 999 1124 static int tas2781_runtime_suspend(struct device *dev) ··· 1120 1231 MODULE_AUTHOR("Baojun, Xu, <baojun.xug@ti.com>"); 1121 1232 MODULE_LICENSE("GPL"); 1122 1233 MODULE_IMPORT_NS("SND_SOC_TAS2781_FMWLIB"); 1234 + MODULE_IMPORT_NS("SND_HDA_SCODEC_TAS2781");