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: Intel: add rt722/rt721 support for PTL platform

Merge series from Bard Liao <yung-chuan.liao@linux.intel.com>:

Rt722, rt721 and rt712 codecs are quite similar. Refactor the existing
spk_rtd_init() to support Realtek common multifunction SDCA codecs.

+206 -102
+1 -2
include/sound/soc_sdw_utils.h
··· 234 234 int asoc_sdw_rt_amp_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai); 235 235 int asoc_sdw_rt700_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai); 236 236 int asoc_sdw_rt711_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai); 237 - int asoc_sdw_rt712_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai); 238 - int asoc_sdw_rt722_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai); 237 + int asoc_sdw_rt_mf_sdca_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai); 239 238 int asoc_sdw_rt5682_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai); 240 239 int asoc_sdw_cs42l42_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai); 241 240 int asoc_sdw_cs42l43_hs_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
+8
sound/soc/intel/boards/sof_sdw.c
··· 598 598 }, 599 599 .driver_data = (void *)(SOC_SDW_CODEC_SPKR), 600 600 }, 601 + /* Pantherlake devices*/ 602 + { 603 + .callback = sof_sdw_quirk_cb, 604 + .matches = { 605 + DMI_MATCH(DMI_PRODUCT_FAMILY, "Intel_ptlrvp"), 606 + }, 607 + .driver_data = (void *)(SOC_SDW_PCH_DMIC), 608 + }, 601 609 {} 602 610 }; 603 611
+55 -7
sound/soc/intel/common/soc-acpi-intel-ptl-match.c
··· 36 36 }; 37 37 38 38 /* 39 - * RT722 is a multi-function codec, three endpoints are created for 40 - * its headset, amp and dmic functions. 39 + * Multi-function codecs with three endpoints created for 40 + * headset, amp and dmic functions. 41 41 */ 42 - static const struct snd_soc_acpi_endpoint rt722_endpoints[] = { 42 + static const struct snd_soc_acpi_endpoint rt_mf_endpoints[] = { 43 43 { 44 44 .num = 0, 45 45 .aggregated = 0, ··· 69 69 } 70 70 }; 71 71 72 + static const struct snd_soc_acpi_adr_device rt721_3_single_adr[] = { 73 + { 74 + .adr = 0x000330025d072101ull, 75 + .num_endpoints = ARRAY_SIZE(rt_mf_endpoints), 76 + .endpoints = rt_mf_endpoints, 77 + .name_prefix = "rt721" 78 + } 79 + }; 80 + 81 + static const struct snd_soc_acpi_link_adr ptl_rt721_l3[] = { 82 + { 83 + .mask = BIT(3), 84 + .num_adr = ARRAY_SIZE(rt721_3_single_adr), 85 + .adr_d = rt721_3_single_adr, 86 + }, 87 + {}, 88 + }; 89 + 72 90 static const struct snd_soc_acpi_adr_device rt722_0_single_adr[] = { 73 91 { 74 92 .adr = 0x000030025d072201ull, 75 - .num_endpoints = ARRAY_SIZE(rt722_endpoints), 76 - .endpoints = rt722_endpoints, 93 + .num_endpoints = ARRAY_SIZE(rt_mf_endpoints), 94 + .endpoints = rt_mf_endpoints, 95 + .name_prefix = "rt722" 96 + } 97 + }; 98 + 99 + static const struct snd_soc_acpi_adr_device rt722_1_single_adr[] = { 100 + { 101 + .adr = 0x000130025d072201ull, 102 + .num_endpoints = ARRAY_SIZE(rt_mf_endpoints), 103 + .endpoints = rt_mf_endpoints, 77 104 .name_prefix = "rt722" 78 105 } 79 106 }; ··· 108 81 static const struct snd_soc_acpi_adr_device rt722_3_single_adr[] = { 109 82 { 110 83 .adr = 0x000330025d072201ull, 111 - .num_endpoints = ARRAY_SIZE(rt722_endpoints), 112 - .endpoints = rt722_endpoints, 84 + .num_endpoints = ARRAY_SIZE(rt_mf_endpoints), 85 + .endpoints = rt_mf_endpoints, 113 86 .name_prefix = "rt722" 114 87 } 115 88 }; ··· 119 92 .mask = BIT(0), 120 93 .num_adr = ARRAY_SIZE(rt722_0_single_adr), 121 94 .adr_d = rt722_0_single_adr, 95 + }, 96 + {} 97 + }; 98 + 99 + static const struct snd_soc_acpi_link_adr ptl_rt722_l1[] = { 100 + { 101 + .mask = BIT(1), 102 + .num_adr = ARRAY_SIZE(rt722_1_single_adr), 103 + .adr_d = rt722_1_single_adr, 122 104 }, 123 105 {} 124 106 }; ··· 178 142 .sof_tplg_filename = "sof-ptl-rt711.tplg", 179 143 }, 180 144 { 145 + .link_mask = BIT(3), 146 + .links = ptl_rt721_l3, 147 + .drv_name = "sof_sdw", 148 + .sof_tplg_filename = "sof-ptl-rt721.tplg", 149 + }, 150 + { 181 151 .link_mask = BIT(0), 182 152 .links = ptl_rt722_only, 153 + .drv_name = "sof_sdw", 154 + .sof_tplg_filename = "sof-ptl-rt722.tplg", 155 + }, 156 + { 157 + .link_mask = BIT(1), 158 + .links = ptl_rt722_l1, 183 159 .drv_name = "sof_sdw", 184 160 .sof_tplg_filename = "sof-ptl-rt722.tplg", 185 161 },
+1 -2
sound/soc/sdw_utils/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 snd-soc-sdw-utils-y := soc_sdw_utils.o soc_sdw_dmic.o soc_sdw_rt_dmic.o \ 3 3 soc_sdw_rt700.o soc_sdw_rt711.o \ 4 - soc_sdw_rt712_sdca.o soc_sdw_rt722_sdca.o \ 5 4 soc_sdw_rt5682.o soc_sdw_rt_sdca_jack_common.o \ 6 - soc_sdw_rt_amp.o \ 5 + soc_sdw_rt_amp.o soc_sdw_rt_mf_sdca.o \ 7 6 soc_sdw_bridge_cs35l56.o \ 8 7 soc_sdw_cs42l42.o soc_sdw_cs42l43.o \ 9 8 soc_sdw_cs_amp.o \
-48
sound/soc/sdw_utils/soc_sdw_rt712_sdca.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - // This file incorporates work covered by the following copyright notice: 3 - // Copyright (c) 2023 Intel Corporation 4 - // Copyright (c) 2024 Advanced Micro Devices, Inc. 5 - 6 - /* 7 - * soc_sdw_rt712_sdca - Helpers to handle RT712-SDCA from generic machine driver 8 - */ 9 - 10 - #include <linux/device.h> 11 - #include <linux/errno.h> 12 - #include <linux/soundwire/sdw.h> 13 - #include <linux/soundwire/sdw_type.h> 14 - #include <sound/control.h> 15 - #include <sound/soc.h> 16 - #include <sound/soc-acpi.h> 17 - #include <sound/soc-dapm.h> 18 - #include <sound/soc_sdw_utils.h> 19 - 20 - /* 21 - * dapm routes for rt712 spk will be registered dynamically according 22 - * to the number of rt712 spk used. The first two entries will be registered 23 - * for one codec case, and the last two entries are also registered 24 - * if two rt712s are used. 25 - */ 26 - static const struct snd_soc_dapm_route rt712_spk_map[] = { 27 - { "Speaker", NULL, "rt712 SPOL" }, 28 - { "Speaker", NULL, "rt712 SPOR" }, 29 - }; 30 - 31 - int asoc_sdw_rt712_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai) 32 - { 33 - struct snd_soc_card *card = rtd->card; 34 - int ret; 35 - 36 - card->components = devm_kasprintf(card->dev, GFP_KERNEL, 37 - "%s spk:rt712", 38 - card->components); 39 - if (!card->components) 40 - return -ENOMEM; 41 - 42 - ret = snd_soc_dapm_add_routes(&card->dapm, rt712_spk_map, ARRAY_SIZE(rt712_spk_map)); 43 - if (ret) 44 - dev_err(rtd->dev, "failed to add SPK map: %d\n", ret); 45 - 46 - return ret; 47 - } 48 - EXPORT_SYMBOL_NS(asoc_sdw_rt712_spk_rtd_init, SND_SOC_SDW_UTILS);
-41
sound/soc/sdw_utils/soc_sdw_rt722_sdca.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - // This file incorporates work covered by the following copyright notice: 3 - // Copyright (c) 2023 Intel Corporation 4 - // Copyright (c) 2024 Advanced Micro Devices, Inc. 5 - 6 - /* 7 - * soc_sdw_rt722_sdca - Helpers to handle RT722-SDCA from generic machine driver 8 - */ 9 - 10 - #include <linux/device.h> 11 - #include <linux/errno.h> 12 - #include <linux/soundwire/sdw.h> 13 - #include <linux/soundwire/sdw_type.h> 14 - #include <sound/control.h> 15 - #include <sound/soc.h> 16 - #include <sound/soc-acpi.h> 17 - #include <sound/soc-dapm.h> 18 - #include <sound/soc_sdw_utils.h> 19 - 20 - static const struct snd_soc_dapm_route rt722_spk_map[] = { 21 - { "Speaker", NULL, "rt722 SPK" }, 22 - }; 23 - 24 - int asoc_sdw_rt722_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai) 25 - { 26 - struct snd_soc_card *card = rtd->card; 27 - int ret; 28 - 29 - card->components = devm_kasprintf(card->dev, GFP_KERNEL, 30 - "%s spk:rt722", 31 - card->components); 32 - if (!card->components) 33 - return -ENOMEM; 34 - 35 - ret = snd_soc_dapm_add_routes(&card->dapm, rt722_spk_map, ARRAY_SIZE(rt722_spk_map)); 36 - if (ret) 37 - dev_err(rtd->dev, "failed to add rt722 spk map: %d\n", ret); 38 - 39 - return ret; 40 - } 41 - EXPORT_SYMBOL_NS(asoc_sdw_rt722_spk_rtd_init, SND_SOC_SDW_UTILS);
+90
sound/soc/sdw_utils/soc_sdw_rt_mf_sdca.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + // This file incorporates work covered by the following copyright notice: 3 + // Copyright (c) 2024 Intel Corporation. 4 + 5 + /* 6 + * soc_sdw_rt_mf_sdca 7 + * - Helpers to handle RT Multifunction Codec from generic machine driver 8 + */ 9 + 10 + #include <linux/device.h> 11 + #include <linux/errno.h> 12 + #include <linux/soundwire/sdw.h> 13 + #include <linux/soundwire/sdw_type.h> 14 + #include <sound/control.h> 15 + #include <sound/soc.h> 16 + #include <sound/soc-acpi.h> 17 + #include <sound/soc-dapm.h> 18 + #include <sound/soc_sdw_utils.h> 19 + 20 + #define CODEC_NAME_SIZE 6 21 + 22 + /* dapm routes for RT-SPK will be registered dynamically */ 23 + static const struct snd_soc_dapm_route rt712_spk_map[] = { 24 + { "Speaker", NULL, "rt712 SPOL" }, 25 + { "Speaker", NULL, "rt712 SPOR" }, 26 + }; 27 + 28 + static const struct snd_soc_dapm_route rt721_spk_map[] = { 29 + { "Speaker", NULL, "rt721 SPK" }, 30 + }; 31 + 32 + static const struct snd_soc_dapm_route rt722_spk_map[] = { 33 + { "Speaker", NULL, "rt722 SPK" }, 34 + }; 35 + 36 + /* Structure to map codec names to respective route arrays and sizes */ 37 + struct codec_route_map { 38 + const char *codec_name; 39 + const struct snd_soc_dapm_route *route_map; 40 + size_t route_size; 41 + }; 42 + 43 + /* Codec route maps array */ 44 + static const struct codec_route_map codec_routes[] = { 45 + { "rt712", rt712_spk_map, ARRAY_SIZE(rt712_spk_map) }, 46 + { "rt721", rt721_spk_map, ARRAY_SIZE(rt721_spk_map) }, 47 + { "rt722", rt722_spk_map, ARRAY_SIZE(rt722_spk_map) }, 48 + }; 49 + 50 + static const struct codec_route_map *get_codec_route_map(const char *codec_name) 51 + { 52 + for (size_t i = 0; i < ARRAY_SIZE(codec_routes); i++) { 53 + if (strcmp(codec_routes[i].codec_name, codec_name) == 0) 54 + return &codec_routes[i]; 55 + } 56 + return NULL; 57 + } 58 + 59 + int asoc_sdw_rt_mf_sdca_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai) 60 + { 61 + struct snd_soc_card *card = rtd->card; 62 + char codec_name[CODEC_NAME_SIZE]; 63 + int ret; 64 + 65 + /* acquire codec name */ 66 + snprintf(codec_name, CODEC_NAME_SIZE, "%s", dai->name); 67 + 68 + /* acquire corresponding route map and size */ 69 + const struct codec_route_map *route_map = get_codec_route_map(codec_name); 70 + 71 + if (!route_map) { 72 + dev_err(rtd->dev, "failed to get codec name and route map\n"); 73 + return -EINVAL; 74 + } 75 + 76 + /* Update card components */ 77 + card->components = devm_kasprintf(card->dev, GFP_KERNEL, 78 + "%s spk:%s", 79 + card->components, codec_name); 80 + if (!card->components) 81 + return -ENOMEM; 82 + 83 + /* Add routes */ 84 + ret = snd_soc_dapm_add_routes(&card->dapm, route_map->route_map, route_map->route_size); 85 + if (ret) 86 + dev_err(rtd->dev, "failed to add rt sdca spk map: %d\n", ret); 87 + 88 + return ret; 89 + } 90 + EXPORT_SYMBOL_NS(asoc_sdw_rt_mf_sdca_spk_rtd_init, SND_SOC_SDW_UTILS);
+8
sound/soc/sdw_utils/soc_sdw_rt_sdca_jack_common.c
··· 60 60 { "rt713 MIC2", NULL, "Headset Mic" }, 61 61 }; 62 62 63 + static const struct snd_soc_dapm_route rt721_sdca_map[] = { 64 + { "Headphone", NULL, "rt721 HP" }, 65 + { "rt721 MIC2", NULL, "Headset Mic" }, 66 + }; 67 + 63 68 static const struct snd_soc_dapm_route rt722_sdca_map[] = { 64 69 { "Headphone", NULL, "rt722 HP" }, 65 70 { "rt722 MIC2", NULL, "Headset Mic" }, ··· 126 121 } else if (strstr(component->name_prefix, "rt713")) { 127 122 ret = snd_soc_dapm_add_routes(&card->dapm, rt713_sdca_map, 128 123 ARRAY_SIZE(rt713_sdca_map)); 124 + } else if (strstr(component->name_prefix, "rt721")) { 125 + ret = snd_soc_dapm_add_routes(&card->dapm, rt721_sdca_map, 126 + ARRAY_SIZE(rt721_sdca_map)); 129 127 } else if (strstr(component->name_prefix, "rt722")) { 130 128 ret = snd_soc_dapm_add_routes(&card->dapm, rt722_sdca_map, 131 129 ARRAY_SIZE(rt722_sdca_map));
+43 -2
sound/soc/sdw_utils/soc_sdw_utils.c
··· 138 138 .dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID}, 139 139 .init = asoc_sdw_rt_amp_init, 140 140 .exit = asoc_sdw_rt_amp_exit, 141 - .rtd_init = asoc_sdw_rt712_spk_rtd_init, 141 + .rtd_init = asoc_sdw_rt_mf_sdca_spk_rtd_init, 142 142 .controls = generic_spk_controls, 143 143 .num_controls = ARRAY_SIZE(generic_spk_controls), 144 144 .widgets = generic_spk_widgets, ··· 334 334 .dai_num = 1, 335 335 }, 336 336 { 337 + .part_id = 0x721, 338 + .version_id = 3, 339 + .dais = { 340 + { 341 + .direction = {true, true}, 342 + .dai_name = "rt721-sdca-aif1", 343 + .dai_type = SOC_SDW_DAI_TYPE_JACK, 344 + .dailink = {SOC_SDW_JACK_OUT_DAI_ID, SOC_SDW_JACK_IN_DAI_ID}, 345 + .init = asoc_sdw_rt_sdca_jack_init, 346 + .exit = asoc_sdw_rt_sdca_jack_exit, 347 + .rtd_init = asoc_sdw_rt_sdca_jack_rtd_init, 348 + .controls = generic_jack_controls, 349 + .num_controls = ARRAY_SIZE(generic_jack_controls), 350 + .widgets = generic_jack_widgets, 351 + .num_widgets = ARRAY_SIZE(generic_jack_widgets), 352 + }, 353 + { 354 + .direction = {true, false}, 355 + .dai_name = "rt721-sdca-aif2", 356 + .dai_type = SOC_SDW_DAI_TYPE_AMP, 357 + /* No feedback capability is provided by rt721-sdca codec driver*/ 358 + .dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID}, 359 + .init = asoc_sdw_rt_amp_init, 360 + .exit = asoc_sdw_rt_amp_exit, 361 + .rtd_init = asoc_sdw_rt_mf_sdca_spk_rtd_init, 362 + .controls = generic_spk_controls, 363 + .num_controls = ARRAY_SIZE(generic_spk_controls), 364 + .widgets = generic_spk_widgets, 365 + .num_widgets = ARRAY_SIZE(generic_spk_widgets), 366 + }, 367 + { 368 + .direction = {false, true}, 369 + .dai_name = "rt721-sdca-aif3", 370 + .dai_type = SOC_SDW_DAI_TYPE_MIC, 371 + .dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_DMIC_DAI_ID}, 372 + .rtd_init = asoc_sdw_rt_dmic_rtd_init, 373 + }, 374 + }, 375 + .dai_num = 3, 376 + }, 377 + { 337 378 .part_id = 0x722, 338 379 .version_id = 3, 339 380 .dais = { ··· 399 358 .dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID}, 400 359 .init = asoc_sdw_rt_amp_init, 401 360 .exit = asoc_sdw_rt_amp_exit, 402 - .rtd_init = asoc_sdw_rt722_spk_rtd_init, 361 + .rtd_init = asoc_sdw_rt_mf_sdca_spk_rtd_init, 403 362 .controls = generic_spk_controls, 404 363 .num_controls = ARRAY_SIZE(generic_spk_controls), 405 364 .widgets = generic_spk_widgets,