Commit 597d364c authored by Mark Brown's avatar Mark Brown

ASoC: Intel: avs: remove redundant dapm routes

Merge series from Brent Lu <brent.lu@intel.com>:

This patch series remove redundant dapm routes declared in multiple machine
drivers. These routes will be created by snd_soc_dapm_connect_dai_link_widgets()
during soundcard initialization. Following is the kernel log from a KBL
chromebook nocturne.

dmic:
[   13.773455] avs_dmic avs_dmic: connected DAI link dmic-codec:Capture -> dmic-platform:DMIC Rx
[   13.773460] avs_dmic avs_dmic: connected DAI link dmic-codec:Capture -> dmic-platform:DMIC WoV Rx

max98373:
[   14.079536] avs_max98373 avs_max98373.1: connected DAI link avs_max98373.1-platform:ssp0 Tx -> i2c-MX98373:00:Right HiFi Playback
[   14.079545] avs_max98373 avs_max98373.1: connected DAI link i2c-MX98373:00:Right HiFi Capture -> avs_max98373.1-platform:ssp0 Rx
[   14.079550] avs_max98373 avs_max98373.1: connected DAI link avs_max98373.1-platform:ssp0 Tx -> i2c-MX98373:01:Left HiFi Playback
[   14.079554] avs_max98373 avs_max98373.1: connected DAI link i2c-MX98373:01:Left HiFi Capture -> avs_max98373.1-platform:ssp0 Rx

hdaudio:
[   14.094818] avs_hdaudio avs_hdaudio.2: connected DAI link hdaudioB0D2-platform:hdaudioB0D2-cpu0 Tx -> hdaudioB0D2:HDMI 0 Playback
[   14.094824] avs_hdaudio avs_hdaudio.2: connected DAI link hdaudioB0D2-platform:hdaudioB0D2-cpu1 Tx -> hdaudioB0D2:HDMI 1 Playback
[   14.094828] avs_hdaudio avs_hdaudio.2: connected DAI link hdaudioB0D2-platform:hdaudioB0D2-cpu2 Tx -> hdaudioB0D2:HDMI 2 Playback
parents 487db53b 51bdf6eb
......@@ -181,38 +181,6 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
return 0;
}
static int avs_create_dapm_routes(struct device *dev, int ssp_port,
struct snd_soc_dapm_route **routes, int *num_routes)
{
struct snd_soc_dapm_route *dr;
const int num_base = ARRAY_SIZE(card_base_routes);
const int num_dr = num_base + 2;
int idx;
dr = devm_kcalloc(dev, num_dr, sizeof(*dr), GFP_KERNEL);
if (!dr)
return -ENOMEM;
memcpy(dr, card_base_routes, num_base * sizeof(*dr));
idx = num_base;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "Playback");
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Tx", ssp_port);
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
idx++;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Rx", ssp_port);
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "Capture");
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
*routes = dr;
*num_routes = num_dr;
return 0;
}
static int avs_card_suspend_pre(struct snd_soc_card *card)
{
struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, DA7219_DAI_NAME);
......@@ -230,14 +198,13 @@ static int avs_card_resume_post(struct snd_soc_card *card)
static int avs_da7219_probe(struct platform_device *pdev)
{
struct snd_soc_dapm_route *routes;
struct snd_soc_dai_link *dai_link;
struct snd_soc_acpi_mach *mach;
struct snd_soc_card *card;
struct snd_soc_jack *jack;
struct device *dev = &pdev->dev;
const char *pname;
int num_routes, ssp_port, ret;
int ssp_port, ret;
mach = dev_get_platdata(dev);
pname = mach->mach_params.platform;
......@@ -249,12 +216,6 @@ static int avs_da7219_probe(struct platform_device *pdev)
return ret;
}
ret = avs_create_dapm_routes(dev, ssp_port, &routes, &num_routes);
if (ret) {
dev_err(dev, "Failed to create dapm routes: %d", ret);
return ret;
}
jack = devm_kzalloc(dev, sizeof(*jack), GFP_KERNEL);
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
if (!jack || !card)
......@@ -271,8 +232,8 @@ static int avs_da7219_probe(struct platform_device *pdev)
card->num_controls = ARRAY_SIZE(card_controls);
card->dapm_widgets = card_widgets;
card->num_dapm_widgets = ARRAY_SIZE(card_widgets);
card->dapm_routes = routes;
card->num_dapm_routes = num_routes;
card->dapm_routes = card_base_routes;
card->num_dapm_routes = ARRAY_SIZE(card_base_routes);
card->fully_routed = true;
snd_soc_card_set_drvdata(card, jack);
......
......@@ -44,8 +44,6 @@ static const struct snd_soc_dapm_widget card_widgets[] = {
static const struct snd_soc_dapm_route card_routes[] = {
{"DMic", NULL, "SoC DMIC"},
{"DMIC Rx", NULL, "Capture"},
{"DMIC WoV Rx", NULL, "Capture"},
};
static int avs_dmic_probe(struct platform_device *pdev)
......
......@@ -64,56 +64,6 @@ static int avs_create_dai_links(struct device *dev, struct hda_codec *codec, int
return 0;
}
static int avs_create_dapm_routes(struct device *dev, struct hda_codec *codec, int pcm_count,
struct snd_soc_dapm_route **routes, int *num_routes)
{
struct snd_soc_dapm_route *dr;
struct hda_pcm *pcm;
const char *cname = dev_name(&codec->core.dev);
int i, n = 0;
/* at max twice the number of pcms */
dr = devm_kcalloc(dev, pcm_count * 2, sizeof(*dr), GFP_KERNEL);
if (!dr)
return -ENOMEM;
pcm = list_first_entry(&codec->pcm_list_head, struct hda_pcm, list);
for (i = 0; i < pcm_count; i++, pcm = list_next_entry(pcm, list)) {
struct hda_pcm_stream *stream;
int dir;
dir = SNDRV_PCM_STREAM_PLAYBACK;
stream = &pcm->stream[dir];
if (!stream->substreams)
goto capture_routes;
dr[n].sink = devm_kasprintf(dev, GFP_KERNEL, "%s %s", pcm->name,
snd_pcm_direction_name(dir));
dr[n].source = devm_kasprintf(dev, GFP_KERNEL, "%s-cpu%d Tx", cname, i);
if (!dr[n].sink || !dr[n].source)
return -ENOMEM;
n++;
capture_routes:
dir = SNDRV_PCM_STREAM_CAPTURE;
stream = &pcm->stream[dir];
if (!stream->substreams)
continue;
dr[n].sink = devm_kasprintf(dev, GFP_KERNEL, "%s-cpu%d Rx", cname, i);
dr[n].source = devm_kasprintf(dev, GFP_KERNEL, "%s %s", pcm->name,
snd_pcm_direction_name(dir));
if (!dr[n].sink || !dr[n].source)
return -ENOMEM;
n++;
}
*routes = dr;
*num_routes = n;
return 0;
}
/* Should be aligned with SectionPCM's name from topology */
#define FEDAI_NAME_PREFIX "HDMI"
......@@ -172,13 +122,12 @@ static int avs_card_late_probe(struct snd_soc_card *card)
static int avs_probing_link_init(struct snd_soc_pcm_runtime *rtm)
{
struct snd_soc_dapm_route *routes;
struct snd_soc_acpi_mach *mach;
struct snd_soc_dai_link *links = NULL;
struct snd_soc_card *card = rtm->card;
struct hda_codec *codec;
struct hda_pcm *pcm;
int ret, n, pcm_count = 0;
int ret, pcm_count = 0;
mach = dev_get_platdata(card->dev);
codec = mach->pdata;
......@@ -200,18 +149,6 @@ static int avs_probing_link_init(struct snd_soc_pcm_runtime *rtm)
return ret;
}
ret = avs_create_dapm_routes(card->dev, codec, pcm_count, &routes, &n);
if (ret < 0) {
dev_err(card->dev, "create routes failed: %d\n", ret);
return ret;
}
ret = snd_soc_dapm_add_routes(&card->dapm, routes, n);
if (ret < 0) {
dev_err(card->dev, "add routes failed: %d\n", ret);
return ret;
}
return 0;
}
......
......@@ -86,41 +86,14 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
return 0;
}
static int avs_create_dapm_routes(struct device *dev, int ssp_port,
struct snd_soc_dapm_route **routes, int *num_routes)
{
struct snd_soc_dapm_route *dr;
const int num_base = ARRAY_SIZE(card_base_routes);
const int num_dr = num_base + 1;
int idx;
dr = devm_kcalloc(dev, num_dr, sizeof(*dr), GFP_KERNEL);
if (!dr)
return -ENOMEM;
memcpy(dr, card_base_routes, num_base * sizeof(*dr));
idx = num_base;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "HiFi Playback");
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Tx", ssp_port);
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
*routes = dr;
*num_routes = num_dr;
return 0;
}
static int avs_max98357a_probe(struct platform_device *pdev)
{
struct snd_soc_dapm_route *routes;
struct snd_soc_dai_link *dai_link;
struct snd_soc_acpi_mach *mach;
struct snd_soc_card *card;
struct device *dev = &pdev->dev;
const char *pname;
int num_routes, ssp_port, ret;
int ssp_port, ret;
mach = dev_get_platdata(dev);
pname = mach->mach_params.platform;
......@@ -132,12 +105,6 @@ static int avs_max98357a_probe(struct platform_device *pdev)
return ret;
}
ret = avs_create_dapm_routes(dev, ssp_port, &routes, &num_routes);
if (ret) {
dev_err(dev, "Failed to create dapm routes: %d", ret);
return ret;
}
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
if (!card)
return -ENOMEM;
......@@ -151,8 +118,8 @@ static int avs_max98357a_probe(struct platform_device *pdev)
card->num_controls = ARRAY_SIZE(card_controls);
card->dapm_widgets = card_widgets;
card->num_dapm_widgets = ARRAY_SIZE(card_widgets);
card->dapm_routes = routes;
card->num_dapm_routes = num_routes;
card->dapm_routes = card_base_routes;
card->num_dapm_routes = ARRAY_SIZE(card_base_routes);
card->fully_routed = true;
ret = snd_soc_fixup_dai_links_platform_name(card, pname);
......
......@@ -141,47 +141,14 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
return 0;
}
static int avs_create_dapm_routes(struct device *dev, int ssp_port,
struct snd_soc_dapm_route **routes, int *num_routes)
{
struct snd_soc_dapm_route *dr;
const int num_base = ARRAY_SIZE(card_base_routes);
const int num_dr = num_base + 2;
int idx;
dr = devm_kcalloc(dev, num_dr, sizeof(*dr), GFP_KERNEL);
if (!dr)
return -ENOMEM;
memcpy(dr, card_base_routes, num_base * sizeof(*dr));
idx = num_base;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "Left HiFi Playback");
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Tx", ssp_port);
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
idx++;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "Right HiFi Playback");
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Tx", ssp_port);
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
*routes = dr;
*num_routes = num_dr;
return 0;
}
static int avs_max98373_probe(struct platform_device *pdev)
{
struct snd_soc_dapm_route *routes;
struct snd_soc_dai_link *dai_link;
struct snd_soc_acpi_mach *mach;
struct snd_soc_card *card;
struct device *dev = &pdev->dev;
const char *pname;
int num_routes, ssp_port, ret;
int ssp_port, ret;
mach = dev_get_platdata(dev);
pname = mach->mach_params.platform;
......@@ -193,12 +160,6 @@ static int avs_max98373_probe(struct platform_device *pdev)
return ret;
}
ret = avs_create_dapm_routes(dev, ssp_port, &routes, &num_routes);
if (ret) {
dev_err(dev, "Failed to create dapm routes: %d", ret);
return ret;
}
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
if (!card)
return -ENOMEM;
......@@ -214,8 +175,8 @@ static int avs_max98373_probe(struct platform_device *pdev)
card->num_controls = ARRAY_SIZE(card_controls);
card->dapm_widgets = card_widgets;
card->num_dapm_widgets = ARRAY_SIZE(card_widgets);
card->dapm_routes = routes;
card->num_dapm_routes = num_routes;
card->dapm_routes = card_base_routes;
card->num_dapm_routes = ARRAY_SIZE(card_base_routes);
card->fully_routed = true;
ret = snd_soc_fixup_dai_links_platform_name(card, pname);
......
......@@ -138,47 +138,14 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
return 0;
}
static int avs_create_dapm_routes(struct device *dev, int ssp_port,
struct snd_soc_dapm_route **routes, int *num_routes)
{
struct snd_soc_dapm_route *dr;
const int num_base = ARRAY_SIZE(card_base_routes);
const int num_dr = num_base + 2;
int idx;
dr = devm_kcalloc(dev, num_dr, sizeof(*dr), GFP_KERNEL);
if (!dr)
return -ENOMEM;
memcpy(dr, card_base_routes, num_base * sizeof(*dr));
idx = num_base;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "Left HiFi Playback");
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Tx", ssp_port);
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
idx++;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "Right HiFi Playback");
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Tx", ssp_port);
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
*routes = dr;
*num_routes = num_dr;
return 0;
}
static int avs_max98927_probe(struct platform_device *pdev)
{
struct snd_soc_dapm_route *routes;
struct snd_soc_dai_link *dai_link;
struct snd_soc_acpi_mach *mach;
struct snd_soc_card *card;
struct device *dev = &pdev->dev;
const char *pname;
int num_routes, ssp_port, ret;
int ssp_port, ret;
mach = dev_get_platdata(dev);
pname = mach->mach_params.platform;
......@@ -190,12 +157,6 @@ static int avs_max98927_probe(struct platform_device *pdev)
return ret;
}
ret = avs_create_dapm_routes(dev, ssp_port, &routes, &num_routes);
if (ret) {
dev_err(dev, "Failed to create dapm routes: %d", ret);
return ret;
}
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
if (!card)
return -ENOMEM;
......@@ -211,8 +172,8 @@ static int avs_max98927_probe(struct platform_device *pdev)
card->num_controls = ARRAY_SIZE(card_controls);
card->dapm_widgets = card_widgets;
card->num_dapm_widgets = ARRAY_SIZE(card_widgets);
card->dapm_routes = routes;
card->num_dapm_routes = num_routes;
card->dapm_routes = card_base_routes;
card->num_dapm_routes = ARRAY_SIZE(card_base_routes);
card->fully_routed = true;
ret = snd_soc_fixup_dai_links_platform_name(card, pname);
......
......@@ -215,38 +215,6 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
return 0;
}
static int avs_create_dapm_routes(struct device *dev, int ssp_port,
struct snd_soc_dapm_route **routes, int *num_routes)
{
struct snd_soc_dapm_route *dr;
const int num_base = ARRAY_SIZE(card_base_routes);
const int num_dr = num_base + 2;
int idx;
dr = devm_kcalloc(dev, num_dr, sizeof(*dr), GFP_KERNEL);
if (!dr)
return -ENOMEM;
memcpy(dr, card_base_routes, num_base * sizeof(*dr));
idx = num_base;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "Playback");
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Tx", ssp_port);
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
idx++;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Rx", ssp_port);
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "Capture");
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
*routes = dr;
*num_routes = num_dr;
return 0;
}
static int avs_card_suspend_pre(struct snd_soc_card *card)
{
struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, SKL_NUVOTON_CODEC_DAI);
......@@ -274,14 +242,13 @@ static int avs_card_resume_post(struct snd_soc_card *card)
static int avs_nau8825_probe(struct platform_device *pdev)
{
struct snd_soc_dapm_route *routes;
struct snd_soc_dai_link *dai_link;
struct snd_soc_acpi_mach *mach;
struct snd_soc_card *card;
struct snd_soc_jack *jack;
struct device *dev = &pdev->dev;
const char *pname;
int num_routes, ssp_port, ret;
int ssp_port, ret;
mach = dev_get_platdata(dev);
pname = mach->mach_params.platform;
......@@ -293,12 +260,6 @@ static int avs_nau8825_probe(struct platform_device *pdev)
return ret;
}
ret = avs_create_dapm_routes(dev, ssp_port, &routes, &num_routes);
if (ret) {
dev_err(dev, "Failed to create dapm routes: %d", ret);
return ret;
}
jack = devm_kzalloc(dev, sizeof(*jack), GFP_KERNEL);
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
if (!jack || !card)
......@@ -315,8 +276,8 @@ static int avs_nau8825_probe(struct platform_device *pdev)
card->num_controls = ARRAY_SIZE(card_controls);
card->dapm_widgets = card_widgets;
card->num_dapm_widgets = ARRAY_SIZE(card_widgets);
card->dapm_routes = routes;
card->num_dapm_routes = num_routes;
card->dapm_routes = card_base_routes;
card->num_dapm_routes = ARRAY_SIZE(card_base_routes);
card->fully_routed = true;
snd_soc_card_set_drvdata(card, jack);
......
......@@ -188,38 +188,6 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
return 0;
}
static int avs_create_dapm_routes(struct device *dev, int ssp_port,
struct snd_soc_dapm_route **routes, int *num_routes)
{
struct snd_soc_dapm_route *dr;
const int num_base = ARRAY_SIZE(card_base_routes);
const int num_dr = num_base + 2;
int idx;
dr = devm_kcalloc(dev, num_dr, sizeof(*dr), GFP_KERNEL);
if (!dr)
return -ENOMEM;
memcpy(dr, card_base_routes, num_base * sizeof(*dr));
idx = num_base;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "AIF1 Playback");
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Tx", ssp_port);
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
idx++;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Rx", ssp_port);
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "AIF1 Capture");
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
*routes = dr;
*num_routes = num_dr;
return 0;
}
static int avs_card_suspend_pre(struct snd_soc_card *card)
{
struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, RT274_CODEC_DAI);
......@@ -237,14 +205,13 @@ static int avs_card_resume_post(struct snd_soc_card *card)
static int avs_rt274_probe(struct platform_device *pdev)
{
struct snd_soc_dapm_route *routes;
struct snd_soc_dai_link *dai_link;
struct snd_soc_acpi_mach *mach;
struct snd_soc_card *card;
struct snd_soc_jack *jack;
struct device *dev = &pdev->dev;
const char *pname;
int num_routes, ssp_port, ret;
int ssp_port, ret;
mach = dev_get_platdata(dev);
pname = mach->mach_params.platform;
......@@ -256,12 +223,6 @@ static int avs_rt274_probe(struct platform_device *pdev)
return ret;
}
ret = avs_create_dapm_routes(dev, ssp_port, &routes, &num_routes);
if (ret) {
dev_err(dev, "Failed to create dapm routes: %d", ret);
return ret;
}
jack = devm_kzalloc(dev, sizeof(*jack), GFP_KERNEL);
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
if (!jack || !card)
......@@ -278,8 +239,8 @@ static int avs_rt274_probe(struct platform_device *pdev)
card->num_controls = ARRAY_SIZE(card_controls);
card->dapm_widgets = card_widgets;
card->num_dapm_widgets = ARRAY_SIZE(card_widgets);
card->dapm_routes = routes;
card->num_dapm_routes = num_routes;
card->dapm_routes = card_base_routes;
card->num_dapm_routes = ARRAY_SIZE(card_base_routes);
card->fully_routed = true;
snd_soc_card_set_drvdata(card, jack);
......
......@@ -158,38 +158,6 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
return 0;
}
static int avs_create_dapm_routes(struct device *dev, int ssp_port,
struct snd_soc_dapm_route **routes, int *num_routes)
{
struct snd_soc_dapm_route *dr;
const int num_base = ARRAY_SIZE(card_base_routes);
const int num_dr = num_base + 2;
int idx;
dr = devm_kcalloc(dev, num_dr, sizeof(*dr), GFP_KERNEL);
if (!dr)
return -ENOMEM;
memcpy(dr, card_base_routes, num_base * sizeof(*dr));
idx = num_base;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "AIF1 Playback");
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Tx", ssp_port);
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
idx++;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Rx", ssp_port);
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "AIF1 Capture");
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
*routes = dr;
*num_routes = num_dr;
return 0;
}
static int avs_card_suspend_pre(struct snd_soc_card *card)
{
struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, RT286_CODEC_DAI);
......@@ -207,14 +175,13 @@ static int avs_card_resume_post(struct snd_soc_card *card)
static int avs_rt286_probe(struct platform_device *pdev)
{
struct snd_soc_dapm_route *routes;
struct snd_soc_dai_link *dai_link;
struct snd_soc_acpi_mach *mach;
struct snd_soc_card *card;
struct snd_soc_jack *jack;
struct device *dev = &pdev->dev;
const char *pname;
int num_routes, ssp_port, ret;
int ssp_port, ret;
mach = dev_get_platdata(dev);
pname = mach->mach_params.platform;
......@@ -226,12 +193,6 @@ static int avs_rt286_probe(struct platform_device *pdev)
return ret;
}
ret = avs_create_dapm_routes(dev, ssp_port, &routes, &num_routes);
if (ret) {
dev_err(dev, "Failed to create dapm routes: %d", ret);
return ret;
}
jack = devm_kzalloc(dev, sizeof(*jack), GFP_KERNEL);
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
if (!jack || !card)
......@@ -248,8 +209,8 @@ static int avs_rt286_probe(struct platform_device *pdev)
card->num_controls = ARRAY_SIZE(card_controls);
card->dapm_widgets = card_widgets;
card->num_dapm_widgets = ARRAY_SIZE(card_widgets);
card->dapm_routes = routes;
card->num_dapm_routes = num_routes;
card->dapm_routes = card_base_routes;
card->num_dapm_routes = ARRAY_SIZE(card_base_routes);
card->fully_routed = true;
snd_soc_card_set_drvdata(card, jack);
......
......@@ -178,38 +178,6 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
return 0;
}
static int avs_create_dapm_routes(struct device *dev, int ssp_port,
struct snd_soc_dapm_route **routes, int *num_routes)
{
struct snd_soc_dapm_route *dr;
const int num_base = ARRAY_SIZE(card_base_routes);
const int num_dr = num_base + 2;
int idx;
dr = devm_kcalloc(dev, num_dr, sizeof(*dr), GFP_KERNEL);
if (!dr)
return -ENOMEM;
memcpy(dr, card_base_routes, num_base * sizeof(*dr));
idx = num_base;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "AIF1 Playback");
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Tx", ssp_port);
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
idx++;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Rx", ssp_port);
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "AIF1 Capture");
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
*routes = dr;
*num_routes = num_dr;
return 0;
}
static int avs_card_suspend_pre(struct snd_soc_card *card)
{
struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, RT298_CODEC_DAI);
......@@ -227,14 +195,13 @@ static int avs_card_resume_post(struct snd_soc_card *card)
static int avs_rt298_probe(struct platform_device *pdev)
{
struct snd_soc_dapm_route *routes;
struct snd_soc_dai_link *dai_link;
struct snd_soc_acpi_mach *mach;
struct snd_soc_card *card;
struct snd_soc_jack *jack;
struct device *dev = &pdev->dev;
const char *pname;
int num_routes, ssp_port, ret;
int ssp_port, ret;
mach = dev_get_platdata(dev);
pname = mach->mach_params.platform;
......@@ -246,12 +213,6 @@ static int avs_rt298_probe(struct platform_device *pdev)
return ret;
}
ret = avs_create_dapm_routes(dev, ssp_port, &routes, &num_routes);
if (ret) {
dev_err(dev, "Failed to create dapm routes: %d", ret);
return ret;
}
jack = devm_kzalloc(dev, sizeof(*jack), GFP_KERNEL);
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
if (!jack || !card)
......@@ -268,8 +229,8 @@ static int avs_rt298_probe(struct platform_device *pdev)
card->num_controls = ARRAY_SIZE(card_controls);
card->dapm_widgets = card_widgets;
card->num_dapm_widgets = ARRAY_SIZE(card_widgets);
card->dapm_routes = routes;
card->num_dapm_routes = num_routes;
card->dapm_routes = card_base_routes;
card->num_dapm_routes = ARRAY_SIZE(card_base_routes);
card->fully_routed = true;
snd_soc_card_set_drvdata(card, jack);
......
......@@ -234,38 +234,6 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
return 0;
}
static int avs_create_dapm_routes(struct device *dev, int ssp_port,
struct snd_soc_dapm_route **routes, int *num_routes)
{
struct snd_soc_dapm_route *dr;
const int num_base = ARRAY_SIZE(card_base_routes);
const int num_dr = num_base + 2;
int idx;
dr = devm_kcalloc(dev, num_dr, sizeof(*dr), GFP_KERNEL);
if (!dr)
return -ENOMEM;
memcpy(dr, card_base_routes, num_base * sizeof(*dr));
idx = num_base;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "AIF1 Playback");
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Tx", ssp_port);
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
idx++;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Rx", ssp_port);
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "AIF1 Capture");
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
*routes = dr;
*num_routes = num_dr;
return 0;
}
static int avs_card_suspend_pre(struct snd_soc_card *card)
{
struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, AVS_RT5682_CODEC_DAI_NAME);
......@@ -283,14 +251,13 @@ static int avs_card_resume_post(struct snd_soc_card *card)
static int avs_rt5682_probe(struct platform_device *pdev)
{
struct snd_soc_dapm_route *routes;
struct snd_soc_dai_link *dai_link;
struct snd_soc_acpi_mach *mach;
struct snd_soc_card *card;
struct snd_soc_jack *jack;
struct device *dev = &pdev->dev;
const char *pname;
int num_routes, ssp_port, ret;
int ssp_port, ret;
if (pdev->id_entry && pdev->id_entry->driver_data)
avs_rt5682_quirk = (unsigned long)pdev->id_entry->driver_data;
......@@ -308,12 +275,6 @@ static int avs_rt5682_probe(struct platform_device *pdev)
return ret;
}
ret = avs_create_dapm_routes(dev, ssp_port, &routes, &num_routes);
if (ret) {
dev_err(dev, "Failed to create dapm routes: %d", ret);
return ret;
}
jack = devm_kzalloc(dev, sizeof(*jack), GFP_KERNEL);
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
if (!jack || !card)
......@@ -330,8 +291,8 @@ static int avs_rt5682_probe(struct platform_device *pdev)
card->num_controls = ARRAY_SIZE(card_controls);
card->dapm_widgets = card_widgets;
card->num_dapm_widgets = ARRAY_SIZE(card_widgets);
card->dapm_routes = routes;
card->num_dapm_routes = num_routes;
card->dapm_routes = card_base_routes;
card->num_dapm_routes = ARRAY_SIZE(card_base_routes);
card->fully_routed = true;
snd_soc_card_set_drvdata(card, jack);
......
......@@ -129,59 +129,14 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
return 0;
}
static int avs_create_dapm_routes(struct device *dev, int ssp_port,
struct snd_soc_dapm_route **routes, int *num_routes)
{
struct snd_soc_dapm_route *dr;
const int num_base = ARRAY_SIZE(card_base_routes);
const int num_dr = num_base + 4;
int idx;
dr = devm_kcalloc(dev, num_dr, sizeof(*dr), GFP_KERNEL);
if (!dr)
return -ENOMEM;
memcpy(dr, card_base_routes, num_base * sizeof(*dr));
idx = num_base;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "Left Playback");
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Tx", ssp_port);
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
idx++;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "Right Playback");
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Tx", ssp_port);
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
idx++;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Rx", ssp_port);
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "Left Capture Sense");
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
idx++;
dr[idx].sink = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Rx", ssp_port);
dr[idx].source = devm_kasprintf(dev, GFP_KERNEL, "Right Capture Sense");
if (!dr[idx].sink || !dr[idx].source)
return -ENOMEM;
*routes = dr;
*num_routes = num_dr;
return 0;
}
static int avs_ssm4567_probe(struct platform_device *pdev)
{
struct snd_soc_dapm_route *routes;
struct snd_soc_dai_link *dai_link;
struct snd_soc_acpi_mach *mach;
struct snd_soc_card *card;
struct device *dev = &pdev->dev;
const char *pname;
int num_routes, ssp_port, ret;
int ssp_port, ret;
mach = dev_get_platdata(dev);
pname = mach->mach_params.platform;
......@@ -193,12 +148,6 @@ static int avs_ssm4567_probe(struct platform_device *pdev)
return ret;
}
ret = avs_create_dapm_routes(dev, ssp_port, &routes, &num_routes);
if (ret) {
dev_err(dev, "Failed to create dapm routes: %d", ret);
return ret;
}
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
if (!card)
return -ENOMEM;
......@@ -214,8 +163,8 @@ static int avs_ssm4567_probe(struct platform_device *pdev)
card->num_controls = ARRAY_SIZE(card_controls);
card->dapm_widgets = card_widgets;
card->num_dapm_widgets = ARRAY_SIZE(card_widgets);
card->dapm_routes = routes;
card->num_dapm_routes = num_routes;
card->dapm_routes = card_base_routes;
card->num_dapm_routes = ARRAY_SIZE(card_base_routes);
card->fully_routed = true;
card->disable_route_checks = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment