1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * soc-acpi-intel-ptl-match.c - tables and support for PTL ACPI enumeration. 4 * 5 * Copyright (c) 2024, Intel Corporation. 6 * 7 * Order of entries in snd_soc_acpi_intel_ptl_sdw_machines[] matters. 8 * Check subset of link mask when matching the machine driver, rule is 9 * superset match should be ordered before subset matches. 10 */ 11 12 #include <sound/soc-acpi.h> 13 #include <sound/soc-acpi-intel-match.h> 14 #include "sof-function-topology-lib.h" 15 #include "soc-acpi-intel-sdca-quirks.h" 16 #include "soc-acpi-intel-sdw-mockup-match.h" 17 #include <sound/soc-acpi-intel-ssp-common.h> 18 19 static const struct snd_soc_acpi_codecs ptl_rt5682_rt5682s_hp = { 20 .num_codecs = 2, 21 .codecs = {RT5682_ACPI_HID, RT5682S_ACPI_HID}, 22 }; 23 24 struct snd_soc_acpi_mach snd_soc_acpi_intel_ptl_machines[] = { 25 { 26 .comp_ids = &ptl_rt5682_rt5682s_hp, 27 .drv_name = "ptl_rt5682_def", 28 .sof_tplg_filename = "sof-ptl", /* the tplg suffix is added at run time */ 29 .tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_AMP_NAME | 30 SND_SOC_ACPI_TPLG_INTEL_CODEC_NAME, 31 }, 32 {}, 33 }; 34 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_ptl_machines); 35 36 static const struct snd_soc_acpi_endpoint single_endpoint = { 37 .num = 0, 38 .aggregated = 0, 39 .group_position = 0, 40 .group_id = 0, 41 }; 42 43 static const struct snd_soc_acpi_endpoint spk_l_endpoint = { 44 .num = 0, 45 .aggregated = 1, 46 .group_position = 0, 47 .group_id = 1, 48 }; 49 50 static const struct snd_soc_acpi_endpoint spk_r_endpoint = { 51 .num = 0, 52 .aggregated = 1, 53 .group_position = 1, 54 .group_id = 1, 55 }; 56 57 static const struct snd_soc_acpi_endpoint spk_1_endpoint = { 58 .num = 0, 59 .aggregated = 1, 60 .group_position = 1, 61 .group_id = 1, 62 }; 63 64 static const struct snd_soc_acpi_endpoint spk_2_endpoint = { 65 .num = 0, 66 .aggregated = 1, 67 .group_position = 2, 68 .group_id = 1, 69 }; 70 71 static const struct snd_soc_acpi_endpoint spk_3_endpoint = { 72 .num = 0, 73 .aggregated = 1, 74 .group_position = 3, 75 .group_id = 1, 76 }; 77 78 static const struct snd_soc_acpi_endpoint spk_4_endpoint = { 79 .num = 0, 80 .aggregated = 1, 81 .group_position = 4, 82 .group_id = 1, 83 }; 84 85 static const struct snd_soc_acpi_endpoint spk_5_endpoint = { 86 .num = 0, 87 .aggregated = 1, 88 .group_position = 5, 89 .group_id = 1, 90 }; 91 92 static const struct snd_soc_acpi_endpoint spk_6_endpoint = { 93 .num = 0, 94 .aggregated = 1, 95 .group_position = 6, 96 .group_id = 1, 97 }; 98 99 /* 100 * Multi-function codecs with three endpoints created for 101 * headset, amp and dmic functions. 102 */ 103 static const struct snd_soc_acpi_endpoint rt_mf_endpoints[] = { 104 { 105 .num = 0, 106 .aggregated = 0, 107 .group_position = 0, 108 .group_id = 0, 109 }, 110 { 111 .num = 1, 112 .aggregated = 0, 113 .group_position = 0, 114 .group_id = 0, 115 }, 116 { 117 .num = 2, 118 .aggregated = 0, 119 .group_position = 0, 120 .group_id = 0, 121 }, 122 }; 123 124 static const struct snd_soc_acpi_endpoint jack_dmic_endpoints[] = { 125 /* Jack Endpoint */ 126 { 127 .num = 0, 128 .aggregated = 0, 129 .group_position = 0, 130 .group_id = 0, 131 }, 132 /* DMIC Endpoint */ 133 { 134 .num = 1, 135 .aggregated = 0, 136 .group_position = 0, 137 .group_id = 0, 138 }, 139 }; 140 141 static const struct snd_soc_acpi_endpoint jack_amp_g1_dmic_endpoints[] = { 142 /* Jack Endpoint */ 143 { 144 .num = 0, 145 .aggregated = 0, 146 .group_position = 0, 147 .group_id = 0, 148 }, 149 /* Amp Endpoint, work as spk_l_endpoint */ 150 { 151 .num = 1, 152 .aggregated = 1, 153 .group_position = 0, 154 .group_id = 1, 155 }, 156 /* DMIC Endpoint */ 157 { 158 .num = 2, 159 .aggregated = 0, 160 .group_position = 0, 161 .group_id = 0, 162 }, 163 }; 164 165 static const struct snd_soc_acpi_endpoint cs42l43_amp_spkagg_endpoints[] = { 166 { /* Jack Playback Endpoint */ 167 .num = 0, 168 .aggregated = 0, 169 .group_position = 0, 170 .group_id = 0, 171 }, 172 { /* DMIC Capture Endpoint */ 173 .num = 1, 174 .aggregated = 0, 175 .group_position = 0, 176 .group_id = 0, 177 }, 178 { /* Jack Capture Endpoint */ 179 .num = 2, 180 .aggregated = 0, 181 .group_position = 0, 182 .group_id = 0, 183 }, 184 { /* Speaker Playback Endpoint */ 185 .num = 3, 186 .aggregated = 1, 187 .group_position = 0, 188 .group_id = 1, 189 }, 190 }; 191 192 static const struct snd_soc_acpi_endpoint cs42l43_endpoints[] = { 193 { /* Jack Playback Endpoint */ 194 .num = 0, 195 .aggregated = 0, 196 .group_position = 0, 197 .group_id = 0, 198 }, 199 { /* DMIC Capture Endpoint */ 200 .num = 1, 201 .aggregated = 0, 202 .group_position = 0, 203 .group_id = 0, 204 }, 205 { /* Jack Capture Endpoint */ 206 .num = 2, 207 .aggregated = 0, 208 .group_position = 0, 209 .group_id = 0, 210 }, 211 { /* Speaker Playback Endpoint */ 212 .num = 3, 213 .aggregated = 0, 214 .group_position = 0, 215 .group_id = 0, 216 }, 217 }; 218 219 static const struct snd_soc_acpi_adr_device cs42l43_2_adr[] = { 220 { 221 .adr = 0x00023001fa424301ull, 222 .num_endpoints = ARRAY_SIZE(cs42l43_amp_spkagg_endpoints), 223 .endpoints = cs42l43_amp_spkagg_endpoints, 224 .name_prefix = "cs42l43" 225 } 226 }; 227 228 static const struct snd_soc_acpi_adr_device cs35l56_1_3amp_adr[] = { 229 { 230 .adr = 0x00013001fa355601ull, 231 .num_endpoints = 1, 232 .endpoints = &spk_1_endpoint, 233 .name_prefix = "AMP1" 234 }, 235 { 236 .adr = 0x00013101fa355601ull, 237 .num_endpoints = 1, 238 .endpoints = &spk_2_endpoint, 239 .name_prefix = "AMP2" 240 }, 241 { 242 .adr = 0x00013201fa355601ull, 243 .num_endpoints = 1, 244 .endpoints = &spk_3_endpoint, 245 .name_prefix = "AMP3" 246 } 247 }; 248 249 static const struct snd_soc_acpi_adr_device cs35l56_3_3amp_adr[] = { 250 { 251 .adr = 0x00033301fa355601ull, 252 .num_endpoints = 1, 253 .endpoints = &spk_4_endpoint, 254 .name_prefix = "AMP4" 255 }, 256 { 257 .adr = 0x00033401fa355601ull, 258 .num_endpoints = 1, 259 .endpoints = &spk_5_endpoint, 260 .name_prefix = "AMP5" 261 }, 262 { 263 .adr = 0x00033501fa355601ull, 264 .num_endpoints = 1, 265 .endpoints = &spk_6_endpoint, 266 .name_prefix = "AMP6" 267 } 268 }; 269 270 static const struct snd_soc_acpi_adr_device cs42l43_3_adr[] = { 271 { 272 .adr = 0x00033001FA424301ull, 273 .num_endpoints = ARRAY_SIZE(cs42l43_endpoints), 274 .endpoints = cs42l43_endpoints, 275 .name_prefix = "cs42l43" 276 } 277 }; 278 279 static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = { 280 { 281 .adr = 0x000030025D071101ull, 282 .num_endpoints = 1, 283 .endpoints = &single_endpoint, 284 .name_prefix = "rt711" 285 } 286 }; 287 288 static const struct snd_soc_acpi_adr_device rt712_vb_2_group1_adr[] = { 289 { 290 .adr = 0x000230025D071201ull, 291 .num_endpoints = ARRAY_SIZE(jack_amp_g1_dmic_endpoints), 292 .endpoints = jack_amp_g1_dmic_endpoints, 293 .name_prefix = "rt712" 294 } 295 }; 296 297 static const struct snd_soc_acpi_adr_device rt712_vb_3_group1_adr[] = { 298 { 299 .adr = 0x000330025D071201ull, 300 .num_endpoints = ARRAY_SIZE(jack_amp_g1_dmic_endpoints), 301 .endpoints = jack_amp_g1_dmic_endpoints, 302 .name_prefix = "rt712" 303 } 304 }; 305 306 static const struct snd_soc_acpi_adr_device rt713_vb_2_adr[] = { 307 { 308 .adr = 0x000230025d071301ull, 309 .num_endpoints = ARRAY_SIZE(jack_dmic_endpoints), 310 .endpoints = jack_dmic_endpoints, 311 .name_prefix = "rt713" 312 } 313 }; 314 315 static const struct snd_soc_acpi_adr_device rt713_vb_3_adr[] = { 316 { 317 .adr = 0x000330025D071301ull, 318 .num_endpoints = ARRAY_SIZE(jack_dmic_endpoints), 319 .endpoints = jack_dmic_endpoints, 320 .name_prefix = "rt713" 321 } 322 }; 323 324 static const struct snd_soc_acpi_adr_device rt1320_3_group1_adr[] = { 325 { 326 .adr = 0x000330025D132001ull, 327 .num_endpoints = 1, 328 .endpoints = &spk_r_endpoint, 329 .name_prefix = "rt1320-1" 330 } 331 }; 332 333 static const struct snd_soc_acpi_adr_device rt721_3_single_adr[] = { 334 { 335 .adr = 0x000330025d072101ull, 336 .num_endpoints = ARRAY_SIZE(rt_mf_endpoints), 337 .endpoints = rt_mf_endpoints, 338 .name_prefix = "rt721" 339 } 340 }; 341 342 static const struct snd_soc_acpi_link_adr ptl_rt721_l3[] = { 343 { 344 .mask = BIT(3), 345 .num_adr = ARRAY_SIZE(rt721_3_single_adr), 346 .adr_d = rt721_3_single_adr, 347 }, 348 {}, 349 }; 350 351 static const struct snd_soc_acpi_adr_device rt722_0_single_adr[] = { 352 { 353 .adr = 0x000030025d072201ull, 354 .num_endpoints = ARRAY_SIZE(rt_mf_endpoints), 355 .endpoints = rt_mf_endpoints, 356 .name_prefix = "rt722" 357 } 358 }; 359 360 static const struct snd_soc_acpi_adr_device rt722_1_single_adr[] = { 361 { 362 .adr = 0x000130025d072201ull, 363 .num_endpoints = ARRAY_SIZE(rt_mf_endpoints), 364 .endpoints = rt_mf_endpoints, 365 .name_prefix = "rt722" 366 } 367 }; 368 369 static const struct snd_soc_acpi_adr_device rt722_3_single_adr[] = { 370 { 371 .adr = 0x000330025d072201ull, 372 .num_endpoints = ARRAY_SIZE(rt_mf_endpoints), 373 .endpoints = rt_mf_endpoints, 374 .name_prefix = "rt722" 375 } 376 }; 377 378 static const struct snd_soc_acpi_adr_device rt1320_1_group1_adr[] = { 379 { 380 .adr = 0x000130025D132001ull, 381 .num_endpoints = 1, 382 .endpoints = &spk_r_endpoint, 383 .name_prefix = "rt1320-1" 384 } 385 }; 386 387 static const struct snd_soc_acpi_adr_device rt1320_1_group2_adr[] = { 388 { 389 .adr = 0x000130025D132001ull, 390 .num_endpoints = 1, 391 .endpoints = &spk_l_endpoint, 392 .name_prefix = "rt1320-1" 393 } 394 }; 395 396 static const struct snd_soc_acpi_adr_device rt1320_2_group1_adr[] = { 397 { 398 .adr = 0x000230025D132001ull, 399 .num_endpoints = 1, 400 .endpoints = &spk_r_endpoint, 401 .name_prefix = "rt1320-1" 402 } 403 }; 404 405 static const struct snd_soc_acpi_adr_device rt1320_2_group2_adr[] = { 406 { 407 .adr = 0x000230025D132001ull, 408 .num_endpoints = 1, 409 .endpoints = &spk_r_endpoint, 410 .name_prefix = "rt1320-1" 411 } 412 }; 413 414 static const struct snd_soc_acpi_adr_device rt1320_3_group2_adr[] = { 415 { 416 .adr = 0x000330025D132001ull, 417 .num_endpoints = 1, 418 .endpoints = &spk_r_endpoint, 419 .name_prefix = "rt1320-2" 420 } 421 }; 422 423 static const struct snd_soc_acpi_link_adr ptl_cs42l43_l2_cs35l56x6_l13[] = { 424 { 425 .mask = BIT(2), 426 .num_adr = ARRAY_SIZE(cs42l43_2_adr), 427 .adr_d = cs42l43_2_adr, 428 }, 429 { 430 .mask = BIT(1), 431 .num_adr = ARRAY_SIZE(cs35l56_1_3amp_adr), 432 .adr_d = cs35l56_1_3amp_adr, 433 }, 434 { 435 .mask = BIT(3), 436 .num_adr = ARRAY_SIZE(cs35l56_3_3amp_adr), 437 .adr_d = cs35l56_3_3amp_adr, 438 }, 439 {} 440 }; 441 442 static const struct snd_soc_acpi_link_adr ptl_cs42l43_l3[] = { 443 { 444 .mask = BIT(3), 445 .num_adr = ARRAY_SIZE(cs42l43_3_adr), 446 .adr_d = cs42l43_3_adr, 447 }, 448 {} 449 }; 450 451 static const struct snd_soc_acpi_link_adr ptl_rt722_only[] = { 452 { 453 .mask = BIT(0), 454 .num_adr = ARRAY_SIZE(rt722_0_single_adr), 455 .adr_d = rt722_0_single_adr, 456 }, 457 {} 458 }; 459 460 static const struct snd_soc_acpi_link_adr ptl_rt722_l1[] = { 461 { 462 .mask = BIT(1), 463 .num_adr = ARRAY_SIZE(rt722_1_single_adr), 464 .adr_d = rt722_1_single_adr, 465 }, 466 {} 467 }; 468 469 static const struct snd_soc_acpi_link_adr ptl_rt722_l3[] = { 470 { 471 .mask = BIT(3), 472 .num_adr = ARRAY_SIZE(rt722_3_single_adr), 473 .adr_d = rt722_3_single_adr, 474 }, 475 {} 476 }; 477 478 static const struct snd_soc_acpi_link_adr ptl_rvp[] = { 479 { 480 .mask = BIT(0), 481 .num_adr = ARRAY_SIZE(rt711_sdca_0_adr), 482 .adr_d = rt711_sdca_0_adr, 483 }, 484 {} 485 }; 486 487 static const struct snd_soc_acpi_link_adr ptl_sdw_rt713_vb_l2_rt1320_l13[] = { 488 { 489 .mask = BIT(2), 490 .num_adr = ARRAY_SIZE(rt713_vb_2_adr), 491 .adr_d = rt713_vb_2_adr, 492 }, 493 { 494 .mask = BIT(1), 495 .num_adr = ARRAY_SIZE(rt1320_1_group2_adr), 496 .adr_d = rt1320_1_group2_adr, 497 }, 498 { 499 .mask = BIT(3), 500 .num_adr = ARRAY_SIZE(rt1320_3_group2_adr), 501 .adr_d = rt1320_3_group2_adr, 502 }, 503 {} 504 }; 505 506 static const struct snd_soc_acpi_link_adr ptl_sdw_rt713_vb_l3_rt1320_l12[] = { 507 { 508 .mask = BIT(3), 509 .num_adr = ARRAY_SIZE(rt713_vb_3_adr), 510 .adr_d = rt713_vb_3_adr, 511 }, 512 { 513 .mask = BIT(1), 514 .num_adr = ARRAY_SIZE(rt1320_1_group2_adr), 515 .adr_d = rt1320_1_group2_adr, 516 }, 517 { 518 .mask = BIT(2), 519 .num_adr = ARRAY_SIZE(rt1320_2_group2_adr), 520 .adr_d = rt1320_2_group2_adr, 521 }, 522 {} 523 }; 524 525 static const struct snd_soc_acpi_link_adr ptl_sdw_rt712_vb_l2_rt1320_l1[] = { 526 { 527 .mask = BIT(2), 528 .num_adr = ARRAY_SIZE(rt712_vb_2_group1_adr), 529 .adr_d = rt712_vb_2_group1_adr, 530 }, 531 { 532 .mask = BIT(1), 533 .num_adr = ARRAY_SIZE(rt1320_1_group1_adr), 534 .adr_d = rt1320_1_group1_adr, 535 }, 536 {} 537 }; 538 539 static const struct snd_soc_acpi_link_adr ptl_sdw_rt712_vb_l3_rt1320_l2[] = { 540 { 541 .mask = BIT(3), 542 .num_adr = ARRAY_SIZE(rt712_vb_3_group1_adr), 543 .adr_d = rt712_vb_3_group1_adr, 544 }, 545 { 546 .mask = BIT(2), 547 .num_adr = ARRAY_SIZE(rt1320_2_group1_adr), 548 .adr_d = rt1320_2_group1_adr, 549 }, 550 {} 551 }; 552 553 static const struct snd_soc_acpi_link_adr ptl_sdw_rt712_vb_l3_rt1320_l3[] = { 554 { 555 .mask = BIT(3), 556 .num_adr = ARRAY_SIZE(rt712_vb_3_group1_adr), 557 .adr_d = rt712_vb_3_group1_adr, 558 }, 559 { 560 .mask = BIT(3), 561 .num_adr = ARRAY_SIZE(rt1320_3_group1_adr), 562 .adr_d = rt1320_3_group1_adr, 563 }, 564 {} 565 }; 566 567 /* this table is used when there is no I2S codec present */ 568 struct snd_soc_acpi_mach snd_soc_acpi_intel_ptl_sdw_machines[] = { 569 /* Order Priority: mockup > most links > most bit link-mask > alphabetical */ 570 { 571 .link_mask = GENMASK(3, 0), 572 .links = sdw_mockup_headset_2amps_mic, 573 .drv_name = "sof_sdw", 574 .sof_tplg_filename = "sof-ptl-rt711-rt1308-rt715.tplg", 575 }, 576 { 577 .link_mask = BIT(0) | BIT(1) | BIT(3), 578 .links = sdw_mockup_headset_1amp_mic, 579 .drv_name = "sof_sdw", 580 .sof_tplg_filename = "sof-ptl-rt711-rt1308-mono-rt715.tplg", 581 }, 582 { 583 .link_mask = GENMASK(2, 0), 584 .links = sdw_mockup_mic_headset_1amp, 585 .drv_name = "sof_sdw", 586 .sof_tplg_filename = "sof-ptl-rt715-rt711-rt1308-mono.tplg", 587 }, 588 { 589 .link_mask = BIT(0), 590 .links = sdw_mockup_multi_func, 591 .drv_name = "sof_sdw", 592 .sof_tplg_filename = "sof-ptl-rt722.tplg", /* Reuse the existing tplg file */ 593 }, 594 { 595 .link_mask = BIT(1) | BIT(2) | BIT(3), 596 .links = ptl_sdw_rt713_vb_l2_rt1320_l13, 597 .drv_name = "sof_sdw", 598 .machine_check = snd_soc_acpi_intel_sdca_is_device_rt712_vb, 599 .sof_tplg_filename = "sof-ptl-rt713-l2-rt1320-l13.tplg", 600 .get_function_tplg_files = sof_sdw_get_tplg_files, 601 }, 602 { 603 .link_mask = BIT(1) | BIT(2) | BIT(3), 604 .links = ptl_sdw_rt713_vb_l3_rt1320_l12, 605 .drv_name = "sof_sdw", 606 .machine_check = snd_soc_acpi_intel_sdca_is_device_rt712_vb, 607 .sof_tplg_filename = "sof-ptl-rt713-l3-rt1320-l12.tplg", 608 .get_function_tplg_files = sof_sdw_get_tplg_files, 609 }, 610 { 611 .link_mask = BIT(1) | BIT(2) | BIT(3), 612 .links = ptl_cs42l43_l2_cs35l56x6_l13, 613 .drv_name = "sof_sdw", 614 .sof_tplg_filename = "sof-ptl-cs42l43-l2-cs35l56x6-l13.tplg", 615 }, 616 { 617 .link_mask = BIT(1) | BIT(2), 618 .links = ptl_sdw_rt712_vb_l2_rt1320_l1, 619 .drv_name = "sof_sdw", 620 .machine_check = snd_soc_acpi_intel_sdca_is_device_rt712_vb, 621 .sof_tplg_filename = "sof-ptl-rt712-l2-rt1320-l1.tplg", 622 .get_function_tplg_files = sof_sdw_get_tplg_files, 623 }, 624 { 625 .link_mask = BIT(2) | BIT(3), 626 .links = ptl_sdw_rt712_vb_l3_rt1320_l2, 627 .drv_name = "sof_sdw", 628 .machine_check = snd_soc_acpi_intel_sdca_is_device_rt712_vb, 629 .sof_tplg_filename = "sof-ptl-rt712-l3-rt1320-l2.tplg", 630 .get_function_tplg_files = sof_sdw_get_tplg_files, 631 }, 632 { 633 .link_mask = BIT(0), 634 .links = ptl_rvp, 635 .drv_name = "sof_sdw", 636 .sof_tplg_filename = "sof-ptl-rt711.tplg", 637 }, 638 { 639 .link_mask = BIT(0), 640 .links = ptl_rt722_only, 641 .drv_name = "sof_sdw", 642 .sof_tplg_filename = "sof-ptl-rt722.tplg", 643 .get_function_tplg_files = sof_sdw_get_tplg_files, 644 }, 645 { 646 .link_mask = BIT(1), 647 .links = ptl_rt722_l1, 648 .drv_name = "sof_sdw", 649 .sof_tplg_filename = "sof-ptl-rt722.tplg", 650 .get_function_tplg_files = sof_sdw_get_tplg_files, 651 }, 652 { 653 .link_mask = BIT(3), 654 .links = ptl_cs42l43_l3, 655 .drv_name = "sof_sdw", 656 .sof_tplg_filename = "sof-ptl-cs42l43-l3.tplg", 657 .get_function_tplg_files = sof_sdw_get_tplg_files, 658 }, 659 { 660 .link_mask = BIT(3), 661 .links = ptl_sdw_rt712_vb_l3_rt1320_l3, 662 .drv_name = "sof_sdw", 663 .machine_check = snd_soc_acpi_intel_sdca_is_device_rt712_vb, 664 .sof_tplg_filename = "sof-ptl-rt712-l3-rt1320-l3.tplg", 665 .get_function_tplg_files = sof_sdw_get_tplg_files, 666 }, 667 { 668 .link_mask = BIT(3), 669 .links = ptl_rt721_l3, 670 .drv_name = "sof_sdw", 671 .sof_tplg_filename = "sof-ptl-rt721.tplg", 672 .get_function_tplg_files = sof_sdw_get_tplg_files, 673 }, 674 { 675 .link_mask = BIT(3), 676 .links = ptl_rt722_l3, 677 .drv_name = "sof_sdw", 678 .sof_tplg_filename = "sof-ptl-rt722.tplg", 679 .get_function_tplg_files = sof_sdw_get_tplg_files, 680 }, 681 {}, 682 }; 683 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_ptl_sdw_machines); 684