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: add rt1320/rt1321 dmic dai and fix the wrong name prefix

Bard Liao <yung-chuan.liao@linux.intel.com> says:

The new rt722 + rt1320 configuration uses the DMIC on the rt1320.
This series adds support for such configurations, where the DMIC is
provided by the rt1320 instead of the rt722.

+79 -105
+2
include/sound/soc_sdw_utils.h
··· 83 83 const int dai_num; 84 84 struct asoc_sdw_aux_info auxs[SOC_SDW_MAX_AUX_NUM]; 85 85 const int aux_num; 86 + /* Force AMP-style name_prefix handling (append AMP index) even if MIC/Jack DAIs exist */ 87 + const bool is_amp; 86 88 87 89 int (*codec_card_late_probe)(struct snd_soc_card *card); 88 90
-100
sound/soc/intel/common/soc-acpi-intel-ptl-match.c
··· 134 134 .group_id = 1, 135 135 }; 136 136 137 - /* 138 - * Multi-function codecs with three endpoints created for 139 - * headset, amp and dmic functions. 140 - */ 141 - static const struct snd_soc_acpi_endpoint rt_mf_endpoints[] = { 142 - { 143 - .num = 0, 144 - .aggregated = 0, 145 - .group_position = 0, 146 - .group_id = 0, 147 - }, 148 - { 149 - .num = 1, 150 - .aggregated = 0, 151 - .group_position = 0, 152 - .group_id = 0, 153 - }, 154 - { 155 - .num = 2, 156 - .aggregated = 0, 157 - .group_position = 0, 158 - .group_id = 0, 159 - }, 160 - }; 161 - 162 137 static const struct snd_soc_acpi_endpoint jack_dmic_endpoints[] = { 163 138 /* Jack Endpoint */ 164 139 { ··· 340 365 } 341 366 }; 342 367 343 - static const struct snd_soc_acpi_adr_device rt722_0_single_adr[] = { 344 - { 345 - .adr = 0x000030025d072201ull, 346 - .num_endpoints = ARRAY_SIZE(rt_mf_endpoints), 347 - .endpoints = rt_mf_endpoints, 348 - .name_prefix = "rt722" 349 - } 350 - }; 351 - 352 - static const struct snd_soc_acpi_adr_device rt722_1_single_adr[] = { 353 - { 354 - .adr = 0x000130025d072201ull, 355 - .num_endpoints = ARRAY_SIZE(rt_mf_endpoints), 356 - .endpoints = rt_mf_endpoints, 357 - .name_prefix = "rt722" 358 - } 359 - }; 360 - 361 - static const struct snd_soc_acpi_adr_device rt722_3_single_adr[] = { 362 - { 363 - .adr = 0x000330025d072201ull, 364 - .num_endpoints = ARRAY_SIZE(rt_mf_endpoints), 365 - .endpoints = rt_mf_endpoints, 366 - .name_prefix = "rt722" 367 - } 368 - }; 369 - 370 368 static const struct snd_soc_acpi_adr_device rt1320_1_group1_adr[] = { 371 369 { 372 370 .adr = 0x000130025D132001ull, ··· 423 475 .mask = BIT(3), 424 476 .num_adr = ARRAY_SIZE(cs35l56_3_3amp_adr), 425 477 .adr_d = cs35l56_3_3amp_adr, 426 - }, 427 - {} 428 - }; 429 - 430 - static const struct snd_soc_acpi_link_adr ptl_rt722_only[] = { 431 - { 432 - .mask = BIT(0), 433 - .num_adr = ARRAY_SIZE(rt722_0_single_adr), 434 - .adr_d = rt722_0_single_adr, 435 - }, 436 - {} 437 - }; 438 - 439 - static const struct snd_soc_acpi_link_adr ptl_rt722_l1[] = { 440 - { 441 - .mask = BIT(1), 442 - .num_adr = ARRAY_SIZE(rt722_1_single_adr), 443 - .adr_d = rt722_1_single_adr, 444 - }, 445 - {} 446 - }; 447 - 448 - static const struct snd_soc_acpi_link_adr ptl_rt722_l3[] = { 449 - { 450 - .mask = BIT(3), 451 - .num_adr = ARRAY_SIZE(rt722_3_single_adr), 452 - .adr_d = rt722_3_single_adr, 453 478 }, 454 479 {} 455 480 }; ··· 620 699 .sof_tplg_filename = "sof-ptl-rt711.tplg", 621 700 }, 622 701 { 623 - .link_mask = BIT(0), 624 - .links = ptl_rt722_only, 625 - .drv_name = "sof_sdw", 626 - .sof_tplg_filename = "sof-ptl-rt722.tplg", 627 - .get_function_tplg_files = sof_sdw_get_tplg_files, 628 - }, 629 - { 630 - .link_mask = BIT(1), 631 - .links = ptl_rt722_l1, 632 - .drv_name = "sof_sdw", 633 - .sof_tplg_filename = "sof-ptl-rt722.tplg", 634 - .get_function_tplg_files = sof_sdw_get_tplg_files, 635 - }, 636 - { 637 702 .link_mask = BIT(3), 638 703 .links = ptl_sdw_rt712_vb_l3_rt1320_l3, 639 704 .drv_name = "sof_sdw", 640 705 .machine_check = snd_soc_acpi_intel_sdca_is_device_rt712_vb, 641 706 .sof_tplg_filename = "sof-ptl-rt712-l3-rt1320-l3.tplg", 642 - .get_function_tplg_files = sof_sdw_get_tplg_files, 643 - }, 644 - { 645 - .link_mask = BIT(3), 646 - .links = ptl_rt722_l3, 647 - .drv_name = "sof_sdw", 648 - .sof_tplg_filename = "sof-ptl-rt722.tplg", 649 707 .get_function_tplg_files = sof_sdw_get_tplg_files, 650 708 }, 651 709 {},
+43 -3
sound/soc/sdw_utils/soc_sdw_rt_dmic.c
··· 9 9 10 10 #include <linux/device.h> 11 11 #include <linux/errno.h> 12 + #include <linux/soundwire/sdw.h> 13 + #include <linux/soundwire/sdw_type.h> 12 14 #include <sound/soc.h> 13 15 #include <sound/soc-acpi.h> 14 16 #include <sound/soc_sdw_utils.h> 17 + #include <sound/sdca_function.h> 15 18 16 19 int asoc_sdw_rt_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai) 17 20 { 18 21 struct snd_soc_card *card = rtd->card; 19 22 struct snd_soc_component *component; 23 + struct sdw_slave *sdw_peripheral = NULL; 20 24 char *mic_name; 25 + int rt1320_dmic_num = 0, part_id, i; 21 26 22 27 component = dai->component; 23 28 ··· 37 32 if (!mic_name) 38 33 return -ENOMEM; 39 34 40 - card->components = devm_kasprintf(card->dev, GFP_KERNEL, 41 - "%s mic:%s", card->components, 42 - mic_name); 35 + /* 36 + * If there is any rt1320/rt1321 DMIC belonging to this card, try to count the `cfg-mics` 37 + * to be used in card->components. 38 + * Note: The rt1320 drivers register the peripheral dev to component->dev, so get the 39 + * sdw_peripheral from component->dev. 40 + */ 41 + if (is_sdw_slave(component->dev)) 42 + sdw_peripheral = dev_to_sdw_dev(component->dev); 43 + if (sdw_peripheral && 44 + (sdw_peripheral->id.part_id == 0x1320 || sdw_peripheral->id.part_id == 0x1321)) { 45 + part_id = sdw_peripheral->id.part_id; 46 + /* 47 + * This rtd init callback is called once, so count the rt1320/rt1321 with SDCA 48 + * function SmartMic type in this card. 49 + */ 50 + for_each_card_components(card, component) { 51 + if (!is_sdw_slave(component->dev)) 52 + continue; 53 + sdw_peripheral = dev_to_sdw_dev(component->dev); 54 + if (sdw_peripheral->id.part_id != part_id) 55 + continue; 56 + for (i = 0; i < sdw_peripheral->sdca_data.num_functions; i++) { 57 + if (sdw_peripheral->sdca_data.function[i].type == 58 + SDCA_FUNCTION_TYPE_SMART_MIC) { 59 + rt1320_dmic_num++; 60 + break; 61 + } 62 + } 63 + } 64 + card->components = devm_kasprintf(card->dev, GFP_KERNEL, 65 + "%s mic:%s cfg-mics:%d", card->components, 66 + mic_name, rt1320_dmic_num); 67 + } else { 68 + card->components = devm_kasprintf(card->dev, GFP_KERNEL, 69 + "%s mic:%s", card->components, 70 + mic_name); 71 + } 72 + 43 73 if (!card->components) 44 74 return -ENOMEM; 45 75
+24 -2
sound/soc/sdw_utils/soc_sdw_utils.c
··· 331 331 .vendor_id = 0x025d, 332 332 .part_id = 0x1320, 333 333 .name_prefix = "rt1320", 334 + .is_amp = true, 334 335 .dais = { 335 336 { 336 337 .direction = {true, false}, ··· 347 346 .widgets = generic_spk_widgets, 348 347 .num_widgets = ARRAY_SIZE(generic_spk_widgets), 349 348 }, 349 + { 350 + .direction = {false, true}, 351 + .dai_name = "rt1320-aif2", 352 + .component_name = "rt1320", 353 + .dai_type = SOC_SDW_DAI_TYPE_MIC, 354 + .dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_DMIC_DAI_ID}, 355 + .rtd_init = asoc_sdw_rt_dmic_rtd_init, 356 + .widgets = generic_dmic_widgets, 357 + .num_widgets = ARRAY_SIZE(generic_dmic_widgets), 358 + }, 350 359 }, 351 - .dai_num = 1, 360 + .dai_num = 2, 352 361 }, 353 362 { 354 363 .vendor_id = 0x025d, 355 364 .part_id = 0x1321, 356 365 .name_prefix = "rt1320", 366 + .is_amp = true, 357 367 .dais = { 358 368 { 359 369 .direction = {true, false}, ··· 380 368 .widgets = generic_spk_widgets, 381 369 .num_widgets = ARRAY_SIZE(generic_spk_widgets), 382 370 }, 371 + { 372 + .direction = {false, true}, 373 + .dai_name = "rt1320-aif2", 374 + .component_name = "rt1320", 375 + .dai_type = SOC_SDW_DAI_TYPE_MIC, 376 + .dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_DMIC_DAI_ID}, 377 + .rtd_init = asoc_sdw_rt_dmic_rtd_init, 378 + .widgets = generic_dmic_widgets, 379 + .num_widgets = ARRAY_SIZE(generic_dmic_widgets), 380 + }, 383 381 }, 384 - .dai_num = 1, 382 + .dai_num = 2, 385 383 }, 386 384 { 387 385 .vendor_id = 0x025d,
+10
sound/soc/sof/intel/hda.c
··· 1232 1232 return NULL; 1233 1233 } 1234 1234 1235 + /* 1236 + * codec_info_list[].is_amp is a codec-level override: for multi-function 1237 + * codecs we must treat the whole codec as an AMP when it is described as 1238 + * such in the codec info table, even if some endpoints were detected as 1239 + * non-AMP above. Callers/UCM rely on this to keep name_prefix and AMP 1240 + * indexing stable and backwards compatible. 1241 + */ 1242 + if (codec_info_list[i].is_amp) 1243 + is_amp = true; 1244 + 1235 1245 adr_dev[index].adr = ((u64)sdw_device->id.class_id & 0xFF) | 1236 1246 ((u64)sdw_device->id.part_id & 0xFFFF) << 8 | 1237 1247 ((u64)sdw_device->id.mfg_id & 0xFFFF) << 24 |