Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 150
ASoC: intel: sof_sdw: add rt711 rt1316 rt714 codecs support.#2340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| // SPDX-License-Identifier: GPL-2.0-only | ||
| // Copyright (c) 2020 Intel Corporation | ||
| /* | ||
| * sof_sdw_rt1316 - Helpers to handle RT1316 from generic machine driver | ||
| */ | ||
| #include <linux/device.h> | ||
| #include <linux/errno.h> | ||
| #include <sound/control.h> | ||
| #include <sound/soc.h> | ||
| #include <sound/soc-acpi.h> | ||
| #include <sound/soc-dapm.h> | ||
| #include "sof_sdw_common.h" | ||
| static const struct snd_soc_dapm_widget rt1316_widgets[] = { | ||
plbossart marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| SND_SOC_DAPM_SPK("Speaker", NULL), | ||
| }; | ||
| /* | ||
| * dapm routes for rt1316 will be registered dynamically according | ||
| * to the number of rt1316 used. The first two entries will be registered | ||
| * for one codec case, and the last two entries are also registered | ||
| * if two 1316s are used. | ||
| */ | ||
| static const struct snd_soc_dapm_route rt1316_map[] = { | ||
| { "Speaker", NULL, "rt1316-1 SPOL" }, | ||
| { "Speaker", NULL, "rt1316-1 SPOR" }, | ||
| { "Speaker", NULL, "rt1316-2 SPOL" }, | ||
| { "Speaker", NULL, "rt1316-2 SPOR" }, | ||
| }; | ||
| static const struct snd_kcontrol_new rt1316_controls[] = { | ||
Collaborator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
| ||
| SOC_DAPM_PIN_SWITCH("Speaker"), | ||
| }; | ||
| static int first_spk_init(struct snd_soc_pcm_runtime *rtd) | ||
| { | ||
| struct snd_soc_card *card = rtd->card; | ||
| int ret; | ||
| ret = snd_soc_add_card_controls(card, rt1316_controls, | ||
| ARRAY_SIZE(rt1316_controls)); | ||
| if (ret) { | ||
| dev_err(card->dev, "rt1316 controls addition failed: %d\n", ret); | ||
| return ret; | ||
| } | ||
| ret = snd_soc_dapm_new_controls(&card->dapm, rt1316_widgets, | ||
| ARRAY_SIZE(rt1316_widgets)); | ||
| if (ret) { | ||
| dev_err(card->dev, "rt1316 widgets addition failed: %d\n", ret); | ||
| return ret; | ||
| } | ||
| ret = snd_soc_dapm_add_routes(&card->dapm, rt1316_map, 2); | ||
| if (ret) | ||
| dev_err(rtd->dev, "failed to add first SPK map: %d\n", ret); | ||
| return ret; | ||
| } | ||
| static int second_spk_init(struct snd_soc_pcm_runtime *rtd) | ||
| { | ||
| struct snd_soc_card *card = rtd->card; | ||
| int ret; | ||
| ret = snd_soc_dapm_add_routes(&card->dapm, rt1316_map + 2, 2); | ||
| if (ret) | ||
| dev_err(rtd->dev, "failed to add second SPK map: %d\n", ret); | ||
| return ret; | ||
| } | ||
| static int all_spk_init(struct snd_soc_pcm_runtime *rtd) | ||
| { | ||
| int ret; | ||
| ret = first_spk_init(rtd); | ||
| if (ret) | ||
| return ret; | ||
| return second_spk_init(rtd); | ||
| } | ||
| int sof_sdw_rt1316_init(const struct snd_soc_acpi_link_adr *link, | ||
| struct snd_soc_dai_link *dai_links, | ||
| struct sof_sdw_codec_info *info, | ||
| bool playback) | ||
| { | ||
| /* Count amp number and do init on playback link only. */ | ||
| if (!playback) | ||
| return 0; | ||
| info->amp_num++; | ||
| if (info->amp_num == 1) | ||
| dai_links->init = first_spk_init; | ||
| if (info->amp_num == 2) { | ||
| /* | ||
| * if two 1316s are in one dai link, the init function | ||
| * in this dai link will be first set for the first speaker, | ||
| * and it should be reset to initialize all speakers when | ||
| * the second speaker is found. | ||
| */ | ||
| if (dai_links->init) | ||
| dai_links->init = all_spk_init; | ||
| else | ||
| dai_links->init = second_spk_init; | ||
| } | ||
| return 0; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.