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.

ASoC: amd: acp: Refactor acp machine select

Refactor and move acp machine select function from acp platform
driver to acp pci driver and assign platform specific acpi machines
to chip->machines.

Signed-off-by: Venkata Prasad Potturu <venkataprasad.potturu@amd.com>
Link: https://patch.msgid.link/20250310183201.11979-6-venkataprasad.potturu@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Venkata Prasad Potturu and committed by
Mark Brown
6e60db74 a8b9d2d7

+114 -124
+28
sound/soc/amd/acp/acp-legacy-common.c
··· 16 16 #include <linux/pci.h> 17 17 #include <linux/export.h> 18 18 19 + #include "../mach-config.h" 20 + 19 21 #define ACP_RENOIR_PDM_ADDR 0x02 20 22 #define ACP_REMBRANDT_PDM_ADDR 0x03 21 23 #define ACP63_PDM_ADDR 0x02 ··· 352 350 return 0; 353 351 } 354 352 EXPORT_SYMBOL_NS_GPL(acp_deinit, "SND_SOC_ACP_COMMON"); 353 + int acp_machine_select(struct acp_chip_info *chip) 354 + { 355 + struct snd_soc_acpi_mach *mach; 356 + int size, platform; 357 + 358 + if (chip->flag == FLAG_AMD_LEGACY_ONLY_DMIC) { 359 + platform = chip->acp_rev; 360 + chip->mach_dev = platform_device_register_data(chip->dev, "acp-pdm-mach", 361 + PLATFORM_DEVID_NONE, &platform, 362 + sizeof(platform)); 363 + } else { 364 + size = sizeof(*chip->machines); 365 + mach = snd_soc_acpi_find_machine(chip->machines); 366 + if (!mach) { 367 + dev_err(chip->dev, "warning: No matching ASoC machine driver found\n"); 368 + return -EINVAL; 369 + } 370 + mach->mach_params.subsystem_rev = chip->acp_rev; 371 + chip->mach_dev = platform_device_register_data(chip->dev, mach->drv_name, 372 + PLATFORM_DEVID_NONE, mach, size); 373 + } 374 + if (IS_ERR(chip->mach_dev)) 375 + dev_warn(chip->dev, "Unable to register Machine device\n"); 376 + return 0; 377 + } 378 + EXPORT_SYMBOL_NS_GPL(acp_machine_select, "SND_SOC_ACP_COMMON"); 355 379 356 380 static void check_acp3x_config(struct acp_chip_info *chip) 357 381 {
+7
sound/soc/amd/acp/acp-pci.c
··· 127 127 case 0x01: 128 128 chip->name = "acp_asoc_renoir"; 129 129 chip->acp_hw_ops_init = acp31_hw_ops_init; 130 + chip->machines = snd_soc_acpi_amd_acp_machines; 130 131 break; 131 132 case 0x6f: 132 133 chip->name = "acp_asoc_rembrandt"; 133 134 chip->acp_hw_ops_init = acp6x_hw_ops_init; 135 + chip->machines = snd_soc_acpi_amd_rmb_acp_machines; 134 136 break; 135 137 case 0x63: 136 138 chip->name = "acp_asoc_acp63"; 137 139 chip->acp_hw_ops_init = acp63_hw_ops_init; 140 + chip->machines = snd_soc_acpi_amd_acp63_acp_machines; 138 141 break; 139 142 case 0x70: 140 143 case 0x71: 141 144 chip->name = "acp_asoc_acp70"; 142 145 chip->acp_hw_ops_init = acp70_hw_ops_init; 146 + chip->machines = snd_soc_acpi_amd_acp70_acp_machines; 143 147 break; 144 148 default: 145 149 dev_err(dev, "Unsupported device revision:0x%x\n", pci->revision); ··· 179 175 chip->chip_pdev = chip->acp_plat_dev; 180 176 chip->dev = &chip->acp_plat_dev->dev; 181 177 178 + acp_machine_select(chip); 182 179 skip_pdev_creation: 183 180 dev_set_drvdata(&pci->dev, chip); 184 181 pm_runtime_set_autosuspend_delay(&pci->dev, 2000); ··· 247 242 platform_device_unregister(chip->dmic_codec_dev); 248 243 if (chip->acp_plat_dev) 249 244 platform_device_unregister(chip->acp_plat_dev); 245 + if (chip->mach_dev) 246 + platform_device_unregister(chip->mach_dev); 250 247 251 248 ret = acp_hw_deinit(chip); 252 249 if (ret)
-28
sound/soc/amd/acp/acp-platform.c
··· 21 21 #include <linux/dma-mapping.h> 22 22 23 23 #include "amd.h" 24 - #include "../mach-config.h" 25 24 #include "acp-mach.h" 26 25 27 26 #define DRV_NAME "acp_i2s_dma" ··· 106 107 .periods_min = CAPTURE_MIN_NUM_PERIODS, 107 108 .periods_max = CAPTURE_MAX_NUM_PERIODS, 108 109 }; 109 - 110 - int acp_machine_select(struct acp_dev_data *adata) 111 - { 112 - struct snd_soc_acpi_mach *mach; 113 - int size, platform; 114 - 115 - if (adata->flag == FLAG_AMD_LEGACY_ONLY_DMIC) { 116 - platform = adata->acp_rev; 117 - adata->mach_dev = platform_device_register_data(adata->dev, "acp-pdm-mach", 118 - PLATFORM_DEVID_NONE, &platform, 119 - sizeof(platform)); 120 - } else { 121 - size = sizeof(*adata->machines); 122 - mach = snd_soc_acpi_find_machine(adata->machines); 123 - if (!mach) { 124 - dev_err(adata->dev, "warning: No matching ASoC machine driver found\n"); 125 - return -EINVAL; 126 - } 127 - mach->mach_params.subsystem_rev = adata->acp_rev; 128 - adata->mach_dev = platform_device_register_data(adata->dev, mach->drv_name, 129 - PLATFORM_DEVID_NONE, mach, size); 130 - } 131 - if (IS_ERR(adata->mach_dev)) 132 - dev_warn(adata->dev, "Unable to register Machine device\n"); 133 - return 0; 134 - } 135 - EXPORT_SYMBOL_NS_GPL(acp_machine_select, "SND_SOC_ACP_COMMON"); 136 110 137 111 static irqreturn_t i2s_irq_handler(int irq, void *data) 138 112 {
-32
sound/soc/amd/acp/acp-rembrandt.c
··· 44 44 .sram_pte_offset = 0x03802800, 45 45 }; 46 46 47 - static struct snd_soc_acpi_codecs amp_rt1019 = { 48 - .num_codecs = 1, 49 - .codecs = {"10EC1019"} 50 - }; 51 - 52 - static struct snd_soc_acpi_codecs amp_max = { 53 - .num_codecs = 1, 54 - .codecs = {"MX98360A"} 55 - }; 56 - 57 - static struct snd_soc_acpi_mach snd_soc_acpi_amd_rmb_acp_machines[] = { 58 - { 59 - .id = "10508825", 60 - .drv_name = "rmb-nau8825-max", 61 - .machine_quirk = snd_soc_acpi_codec_list, 62 - .quirk_data = &amp_max, 63 - }, 64 - { 65 - .id = "AMDI0007", 66 - .drv_name = "rembrandt-acp", 67 - }, 68 - { 69 - .id = "RTL5682", 70 - .drv_name = "rmb-rt5682s-rt1019", 71 - .machine_quirk = snd_soc_acpi_codec_list, 72 - .quirk_data = &amp_rt1019, 73 - }, 74 - {}, 75 - }; 76 - 77 47 static struct snd_soc_dai_driver acp_rmb_dai[] = { 78 48 { 79 49 .name = "acp-i2s-sp", ··· 200 230 adata->acp_rev = chip->acp_rev; 201 231 adata->flag = chip->flag; 202 232 adata->is_i2s_config = chip->is_i2s_config; 203 - adata->machines = snd_soc_acpi_amd_rmb_acp_machines; 204 - acp_machine_select(adata); 205 233 206 234 dev_set_drvdata(dev, adata); 207 235
-42
sound/soc/amd/acp/acp-renoir.c
··· 36 36 .sram_pte_offset = 0x02052800, 37 37 }; 38 38 39 - static struct snd_soc_acpi_codecs amp_rt1019 = { 40 - .num_codecs = 1, 41 - .codecs = {"10EC1019"} 42 - }; 43 - 44 - static struct snd_soc_acpi_codecs amp_max = { 45 - .num_codecs = 1, 46 - .codecs = {"MX98360A"} 47 - }; 48 - 49 - static struct snd_soc_acpi_mach snd_soc_acpi_amd_acp_machines[] = { 50 - { 51 - .id = "10EC5682", 52 - .drv_name = "acp3xalc56821019", 53 - .machine_quirk = snd_soc_acpi_codec_list, 54 - .quirk_data = &amp_rt1019, 55 - }, 56 - { 57 - .id = "RTL5682", 58 - .drv_name = "acp3xalc5682sm98360", 59 - .machine_quirk = snd_soc_acpi_codec_list, 60 - .quirk_data = &amp_max, 61 - }, 62 - { 63 - .id = "RTL5682", 64 - .drv_name = "acp3xalc5682s1019", 65 - .machine_quirk = snd_soc_acpi_codec_list, 66 - .quirk_data = &amp_rt1019, 67 - }, 68 - { 69 - .id = "AMDI1019", 70 - .drv_name = "renoir-acp", 71 - }, 72 - { 73 - .id = "ESSX8336", 74 - .drv_name = "acp3x-es83xx", 75 - }, 76 - {}, 77 - }; 78 39 79 40 static struct snd_soc_dai_driver acp_renoir_dai[] = { 80 41 { ··· 148 187 adata->rsrc = &rsrc; 149 188 adata->acp_rev = chip->acp_rev; 150 189 adata->flag = chip->flag; 151 - 152 - adata->machines = snd_soc_acpi_amd_acp_machines; 153 - acp_machine_select(adata); 154 190 155 191 dev_set_drvdata(dev, adata); 156 192 acp_enable_interrupts(adata);
-10
sound/soc/amd/acp/acp63.c
··· 62 62 .sram_pte_offset = 0x03802800, 63 63 }; 64 64 65 - static struct snd_soc_acpi_mach snd_soc_acpi_amd_acp63_acp_machines[] = { 66 - { 67 - .id = "AMDI0052", 68 - .drv_name = "acp63-acp", 69 - }, 70 - {}, 71 - }; 72 - 73 65 static struct snd_soc_dai_driver acp63_dai[] = { 74 66 { 75 67 .name = "acp-i2s-sp", ··· 251 259 adata->acp_rev = chip->acp_rev; 252 260 adata->flag = chip->flag; 253 261 adata->is_i2s_config = chip->is_i2s_config; 254 - adata->machines = snd_soc_acpi_amd_acp63_acp_machines; 255 - acp_machine_select(adata); 256 262 dev_set_drvdata(dev, adata); 257 263 258 264 if (chip->is_i2s_config && rsrc.soc_mclk) {
-10
sound/soc/amd/acp/acp70.c
··· 40 40 .sram_pte_offset = 0x03800000, 41 41 }; 42 42 43 - static struct snd_soc_acpi_mach snd_soc_acpi_amd_acp70_acp_machines[] = { 44 - { 45 - .id = "AMDI0029", 46 - .drv_name = "acp70-acp", 47 - }, 48 - {}, 49 - }; 50 - 51 43 static struct snd_soc_dai_driver acp70_dai[] = { 52 44 { 53 45 .name = "acp-i2s-sp", ··· 179 187 adata->dai_driver = acp70_dai; 180 188 adata->num_dai = ARRAY_SIZE(acp70_dai); 181 189 adata->rsrc = &rsrc; 182 - adata->machines = snd_soc_acpi_amd_acp70_acp_machines; 183 190 adata->acp_rev = chip->acp_rev; 184 191 adata->flag = chip->flag; 185 - acp_machine_select(adata); 186 192 187 193 dev_set_drvdata(dev, adata); 188 194
+79 -2
sound/soc/amd/acp/amd.h
··· 149 149 struct platform_device *chip_pdev; 150 150 struct platform_device *dmic_codec_dev; 151 151 struct platform_device *acp_plat_dev; 152 + struct platform_device *mach_dev; 153 + struct snd_soc_acpi_mach *machines; 152 154 u32 addr; 153 155 unsigned int flag; /* Distinguish b/w Legacy or Only PDM */ 154 156 bool is_pdm_dev; /* flag set to true when ACP PDM controller exists */ ··· 197 195 struct list_head stream_list; 198 196 spinlock_t acp_lock; 199 197 200 - struct snd_soc_acpi_mach *machines; 201 198 struct platform_device *mach_dev; 202 199 203 200 u32 bclk_div; ··· 246 245 ACP_CONFIG_20, 247 246 }; 248 247 248 + struct snd_soc_acpi_codecs amp_rt1019 = { 249 + .num_codecs = 1, 250 + .codecs = {"10EC1019"} 251 + }; 252 + 253 + struct snd_soc_acpi_codecs amp_max = { 254 + .num_codecs = 1, 255 + .codecs = {"MX98360A"} 256 + }; 257 + 258 + struct snd_soc_acpi_mach snd_soc_acpi_amd_acp_machines[] = { 259 + { 260 + .id = "10EC5682", 261 + .drv_name = "acp3xalc56821019", 262 + .machine_quirk = snd_soc_acpi_codec_list, 263 + .quirk_data = &amp_rt1019, 264 + }, 265 + { 266 + .id = "RTL5682", 267 + .drv_name = "acp3xalc5682sm98360", 268 + .machine_quirk = snd_soc_acpi_codec_list, 269 + .quirk_data = &amp_max, 270 + }, 271 + { 272 + .id = "RTL5682", 273 + .drv_name = "acp3xalc5682s1019", 274 + .machine_quirk = snd_soc_acpi_codec_list, 275 + .quirk_data = &amp_rt1019, 276 + }, 277 + { 278 + .id = "AMDI1019", 279 + .drv_name = "renoir-acp", 280 + }, 281 + { 282 + .id = "ESSX8336", 283 + .drv_name = "acp3x-es83xx", 284 + }, 285 + {}, 286 + }; 287 + 288 + struct snd_soc_acpi_mach snd_soc_acpi_amd_rmb_acp_machines[] = { 289 + { 290 + .id = "10508825", 291 + .drv_name = "rmb-nau8825-max", 292 + .machine_quirk = snd_soc_acpi_codec_list, 293 + .quirk_data = &amp_max, 294 + }, 295 + { 296 + .id = "AMDI0007", 297 + .drv_name = "rembrandt-acp", 298 + }, 299 + { 300 + .id = "RTL5682", 301 + .drv_name = "rmb-rt5682s-rt1019", 302 + .machine_quirk = snd_soc_acpi_codec_list, 303 + .quirk_data = &amp_rt1019, 304 + }, 305 + {}, 306 + }; 307 + 308 + struct snd_soc_acpi_mach snd_soc_acpi_amd_acp63_acp_machines[] = { 309 + { 310 + .id = "AMDI0052", 311 + .drv_name = "acp63-acp", 312 + }, 313 + {}, 314 + }; 315 + 316 + struct snd_soc_acpi_mach snd_soc_acpi_amd_acp70_acp_machines[] = { 317 + { 318 + .id = "AMDI0029", 319 + .drv_name = "acp70-acp", 320 + }, 321 + {}, 322 + }; 323 + 249 324 extern const struct snd_soc_dai_ops asoc_acp_cpu_dai_ops; 250 325 extern const struct snd_soc_dai_ops acp_dmic_dai_ops; 251 326 252 327 int acp_platform_register(struct device *dev); 253 328 int acp_platform_unregister(struct device *dev); 254 329 255 - int acp_machine_select(struct acp_dev_data *adata); 330 + int acp_machine_select(struct acp_chip_info *chip); 256 331 257 332 int acp_init(struct acp_chip_info *chip); 258 333 int acp_deinit(struct acp_chip_info *chip);