summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2020-07-24 15:22:35 +0100
committerMark Brown <broonie@kernel.org>2020-07-24 15:22:35 +0100
commitaa2d1ee76660edd4072c9cf8f83ffde4b58a1dd0 (patch)
treee9dcdf2a7295089803981e93a47e587c43f2d400 /sound
parent62f2c7797de376e39bca5630a0f80209ffb4c70f (diff)
parenta63419beafd4edf20761c37dbefd639a0b1b481e (diff)
downloadlinux-stable-aa2d1ee76660edd4072c9cf8f83ffde4b58a1dd0.tar.gz
linux-stable-aa2d1ee76660edd4072c9cf8f83ffde4b58a1dd0.tar.bz2
linux-stable-aa2d1ee76660edd4072c9cf8f83ffde4b58a1dd0.zip
Merge series "ASoC: qcom: Use qcom_snd_parse_of() for apq8016_sbc" from Stephan Gerhold <stephan@gerhold.net>:
At the moment we have two separate functions to parse the sound card properties from the device tree: qcom_snd_parse_of() for DPCM and apq8016_sbc_parse_of() without DPCM. These functions are almost identical except for a few minor differences. This patch set extends qcom_snd_parse_of() to handle links without DPCM, so that we can use one common function for all (qcom) machine drivers. Stephan Gerhold (7): ASoC: qcom: Use devm for resource management ASoC: qcom: common: Use snd_soc_dai_link_set_capabilities() ASoC: q6afe: Remove unused q6afe_is_rx_port() function ASoC: qcom: common: Support parsing links without DPCM ASoC: qcom: common: Parse properties with "qcom," prefix ASoC: qcom: apq8016_sbc: Use qcom_snd_parse_of() ASoC: qcom: common: Avoid printing errors for -EPROBE_DEFER sound/soc/qcom/Kconfig | 1 + sound/soc/qcom/apq8016_sbc.c | 120 ++++------------------------------- sound/soc/qcom/apq8096.c | 28 +------- sound/soc/qcom/common.c | 58 ++++++++++------- sound/soc/qcom/qdsp6/q6afe.c | 8 --- sound/soc/qcom/qdsp6/q6afe.h | 1 - sound/soc/qcom/sdm845.c | 40 ++---------- 7 files changed, 59 insertions(+), 197 deletions(-) -- 2.27.0
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/qcom/Kconfig1
-rw-r--r--sound/soc/qcom/apq8016_sbc.c120
-rw-r--r--sound/soc/qcom/apq8096.c28
-rw-r--r--sound/soc/qcom/common.c58
-rw-r--r--sound/soc/qcom/qdsp6/q6afe.c8
-rw-r--r--sound/soc/qcom/qdsp6/q6afe.h1
-rw-r--r--sound/soc/qcom/sdm845.c40
7 files changed, 59 insertions, 197 deletions
diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig
index cfca0f730c61..5d6b2466a2f2 100644
--- a/sound/soc/qcom/Kconfig
+++ b/sound/soc/qcom/Kconfig
@@ -37,6 +37,7 @@ config SND_SOC_APQ8016_SBC
tristate "SoC Audio support for APQ8016 SBC platforms"
depends on SND_SOC_QCOM
select SND_SOC_LPASS_APQ8016
+ select SND_SOC_QCOM_COMMON
help
Support for Qualcomm Technologies LPASS audio block in
APQ8016 SOC-based systems.
diff --git a/sound/soc/qcom/apq8016_sbc.c b/sound/soc/qcom/apq8016_sbc.c
index 2ef090f4af9e..083413abc2f6 100644
--- a/sound/soc/qcom/apq8016_sbc.c
+++ b/sound/soc/qcom/apq8016_sbc.c
@@ -16,13 +16,14 @@
#include <sound/soc.h>
#include <uapi/linux/input-event-codes.h>
#include <dt-bindings/sound/apq8016-lpass.h>
+#include "common.h"
struct apq8016_sbc_data {
+ struct snd_soc_card card;
void __iomem *mic_iomux;
void __iomem *spkr_iomux;
struct snd_soc_jack jack;
bool jack_setup;
- struct snd_soc_dai_link dai_link[]; /* dynamically allocated */
};
#define MIC_CTRL_TER_WS_SLAVE_SEL BIT(21)
@@ -110,107 +111,13 @@ static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd)
return 0;
}
-static struct apq8016_sbc_data *apq8016_sbc_parse_of(struct snd_soc_card *card)
+static void apq8016_sbc_add_ops(struct snd_soc_card *card)
{
- struct device *dev = card->dev;
struct snd_soc_dai_link *link;
- struct device_node *np, *codec, *cpu, *node = dev->of_node;
- struct apq8016_sbc_data *data;
- struct snd_soc_dai_link_component *dlc;
- int ret, num_links;
-
- ret = snd_soc_of_parse_card_name(card, "qcom,model");
- if (ret) {
- dev_err(dev, "Error parsing card name: %d\n", ret);
- return ERR_PTR(ret);
- }
-
- /* DAPM routes */
- if (of_property_read_bool(node, "qcom,audio-routing")) {
- ret = snd_soc_of_parse_audio_routing(card,
- "qcom,audio-routing");
- if (ret)
- return ERR_PTR(ret);
- }
-
-
- /* Populate links */
- num_links = of_get_child_count(node);
-
- /* Allocate the private data and the DAI link array */
- data = devm_kzalloc(dev,
- struct_size(data, dai_link, num_links),
- GFP_KERNEL);
- if (!data)
- return ERR_PTR(-ENOMEM);
-
- card->dai_link = &data->dai_link[0];
- card->num_links = num_links;
-
- link = data->dai_link;
-
- for_each_child_of_node(node, np) {
- dlc = devm_kzalloc(dev, 2 * sizeof(*dlc), GFP_KERNEL);
- if (!dlc)
- return ERR_PTR(-ENOMEM);
-
- link->cpus = &dlc[0];
- link->platforms = &dlc[1];
-
- link->num_cpus = 1;
- link->num_platforms = 1;
-
- cpu = of_get_child_by_name(np, "cpu");
- codec = of_get_child_by_name(np, "codec");
-
- if (!cpu || !codec) {
- dev_err(dev, "Can't find cpu/codec DT node\n");
- ret = -EINVAL;
- goto error;
- }
+ int i;
- link->cpus->of_node = of_parse_phandle(cpu, "sound-dai", 0);
- if (!link->cpus->of_node) {
- dev_err(card->dev, "error getting cpu phandle\n");
- ret = -EINVAL;
- goto error;
- }
-
- ret = snd_soc_of_get_dai_name(cpu, &link->cpus->dai_name);
- if (ret) {
- dev_err(card->dev, "error getting cpu dai name\n");
- goto error;
- }
-
- ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
-
- if (ret < 0) {
- dev_err(card->dev, "error getting codec dai name\n");
- goto error;
- }
-
- link->platforms->of_node = link->cpus->of_node;
- ret = of_property_read_string(np, "link-name", &link->name);
- if (ret) {
- dev_err(card->dev, "error getting codec dai_link name\n");
- goto error;
- }
-
- link->stream_name = link->name;
+ for_each_card_prelinks(card, i, link)
link->init = apq8016_sbc_dai_init;
- link++;
-
- of_node_put(cpu);
- of_node_put(codec);
- }
-
- return data;
-
- error:
- of_node_put(np);
- of_node_put(cpu);
- of_node_put(codec);
- return ERR_PTR(ret);
}
static const struct snd_soc_dapm_widget apq8016_sbc_dapm_widgets[] = {
@@ -228,20 +135,20 @@ static int apq8016_sbc_platform_probe(struct platform_device *pdev)
struct snd_soc_card *card;
struct apq8016_sbc_data *data;
struct resource *res;
+ int ret;
- card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
- if (!card)
+ data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+ if (!data)
return -ENOMEM;
+ card = &data->card;
card->dev = dev;
card->dapm_widgets = apq8016_sbc_dapm_widgets;
card->num_dapm_widgets = ARRAY_SIZE(apq8016_sbc_dapm_widgets);
- data = apq8016_sbc_parse_of(card);
- if (IS_ERR(data)) {
- dev_err(&pdev->dev, "Error resolving dai links: %ld\n",
- PTR_ERR(data));
- return PTR_ERR(data);
- }
+
+ ret = qcom_snd_parse_of(card);
+ if (ret)
+ return ret;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mic-iomux");
data->mic_iomux = devm_ioremap_resource(dev, res);
@@ -255,6 +162,7 @@ static int apq8016_sbc_platform_probe(struct platform_device *pdev)
snd_soc_card_set_drvdata(card, data);
+ apq8016_sbc_add_ops(card);
return devm_snd_soc_register_card(&pdev->dev, card);
}
diff --git a/sound/soc/qcom/apq8096.c b/sound/soc/qcom/apq8096.c
index 6b5a381cf9b6..253549600c5a 100644
--- a/sound/soc/qcom/apq8096.c
+++ b/sound/soc/qcom/apq8096.c
@@ -109,7 +109,7 @@ static int apq8096_platform_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
int ret;
- card = kzalloc(sizeof(*card), GFP_KERNEL);
+ card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
if (!card)
return -ENOMEM;
@@ -117,31 +117,10 @@ static int apq8096_platform_probe(struct platform_device *pdev)
dev_set_drvdata(dev, card);
ret = qcom_snd_parse_of(card);
if (ret)
- goto err;
+ return ret;
apq8096_add_be_ops(card);
- ret = snd_soc_register_card(card);
- if (ret)
- goto err_card_register;
-
- return 0;
-
-err_card_register:
- kfree(card->dai_link);
-err:
- kfree(card);
- return ret;
-}
-
-static int apq8096_platform_remove(struct platform_device *pdev)
-{
- struct snd_soc_card *card = dev_get_drvdata(&pdev->dev);
-
- snd_soc_unregister_card(card);
- kfree(card->dai_link);
- kfree(card);
-
- return 0;
+ return devm_snd_soc_register_card(dev, card);
}
static const struct of_device_id msm_snd_apq8096_dt_match[] = {
@@ -153,7 +132,6 @@ MODULE_DEVICE_TABLE(of, msm_snd_apq8096_dt_match);
static struct platform_driver msm_snd_apq8096_driver = {
.probe = apq8096_platform_probe,
- .remove = apq8096_platform_remove,
.driver = {
.name = "msm-snd-apq8096",
.of_match_table = msm_snd_apq8096_dt_match,
diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c
index 8ada4ecba847..5194d90ddb96 100644
--- a/sound/soc/qcom/common.c
+++ b/sound/soc/qcom/common.c
@@ -4,7 +4,6 @@
#include <linux/module.h>
#include "common.h"
-#include "qdsp6/q6afe.h"
int qcom_snd_parse_of(struct snd_soc_card *card)
{
@@ -19,6 +18,9 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
int ret, num_links;
ret = snd_soc_of_parse_card_name(card, "model");
+ if (ret == 0 && !card->name)
+ /* Deprecated, only for compatibility with old device trees */
+ ret = snd_soc_of_parse_card_name(card, "qcom,model");
if (ret) {
dev_err(dev, "Error parsing card name: %d\n", ret);
return ret;
@@ -26,8 +28,13 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
/* DAPM routes */
if (of_property_read_bool(dev->of_node, "audio-routing")) {
- ret = snd_soc_of_parse_audio_routing(card,
- "audio-routing");
+ ret = snd_soc_of_parse_audio_routing(card, "audio-routing");
+ if (ret)
+ return ret;
+ }
+ /* Deprecated, only for compatibility with old device trees */
+ if (of_property_read_bool(dev->of_node, "qcom,audio-routing")) {
+ ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
if (ret)
return ret;
}
@@ -36,7 +43,7 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
num_links = of_get_child_count(dev->of_node);
/* Allocate the DAI link array */
- card->dai_link = kcalloc(num_links, sizeof(*link), GFP_KERNEL);
+ card->dai_link = devm_kcalloc(dev, num_links, sizeof(*link), GFP_KERNEL);
if (!card->dai_link)
return -ENOMEM;
@@ -81,11 +88,13 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
ret = snd_soc_of_get_dai_name(cpu, &link->cpus->dai_name);
if (ret) {
- dev_err(card->dev, "%s: error getting cpu dai name\n", link->name);
+ if (ret != -EPROBE_DEFER)
+ dev_err(card->dev, "%s: error getting cpu dai name: %d\n",
+ link->name, ret);
goto err;
}
- if (codec && platform) {
+ if (platform) {
link->platforms->of_node = of_parse_phandle(platform,
"sound-dai",
0);
@@ -94,24 +103,26 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
ret = -EINVAL;
goto err;
}
+ } else {
+ link->platforms->of_node = link->cpus->of_node;
+ }
+ if (codec) {
ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
if (ret < 0) {
- dev_err(card->dev, "%s: codec dai not found\n", link->name);
+ if (ret != -EPROBE_DEFER)
+ dev_err(card->dev, "%s: codec dai not found: %d\n",
+ link->name, ret);
goto err;
}
- link->no_pcm = 1;
- link->ignore_pmdown_time = 1;
-
- if (q6afe_is_rx_port(link->id)) {
- link->dpcm_playback = 1;
- link->dpcm_capture = 0;
- } else {
- link->dpcm_playback = 0;
- link->dpcm_capture = 1;
- }
+ if (platform) {
+ /* DPCM backend */
+ link->no_pcm = 1;
+ link->ignore_pmdown_time = 1;
+ }
} else {
+ /* DPCM frontend */
dlc = devm_kzalloc(dev, sizeof(*dlc), GFP_KERNEL);
if (!dlc)
return -ENOMEM;
@@ -119,16 +130,18 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
link->codecs = dlc;
link->num_codecs = 1;
- link->platforms->of_node = link->cpus->of_node;
link->codecs->dai_name = "snd-soc-dummy-dai";
link->codecs->name = "snd-soc-dummy";
link->dynamic = 1;
- link->dpcm_playback = 1;
- link->dpcm_capture = 1;
}
- link->ignore_suspend = 1;
- link->nonatomic = 1;
+ if (platform || !codec) {
+ /* DPCM */
+ snd_soc_dai_link_set_capabilities(link);
+ link->ignore_suspend = 1;
+ link->nonatomic = 1;
+ }
+
link->stream_name = link->name;
link++;
@@ -143,7 +156,6 @@ err:
of_node_put(cpu);
of_node_put(codec);
of_node_put(platform);
- kfree(card->dai_link);
return ret;
}
EXPORT_SYMBOL(qcom_snd_parse_of);
diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c
index 0ce4eb60f984..e0945f7a58c8 100644
--- a/sound/soc/qcom/qdsp6/q6afe.c
+++ b/sound/soc/qcom/qdsp6/q6afe.c
@@ -800,14 +800,6 @@ int q6afe_get_port_id(int index)
}
EXPORT_SYMBOL_GPL(q6afe_get_port_id);
-int q6afe_is_rx_port(int index)
-{
- if (index < 0 || index >= AFE_PORT_MAX)
- return -EINVAL;
-
- return port_maps[index].is_rx;
-}
-EXPORT_SYMBOL_GPL(q6afe_is_rx_port);
static int afe_apr_send_pkt(struct q6afe *afe, struct apr_pkt *pkt,
struct q6afe_port *port)
{
diff --git a/sound/soc/qcom/qdsp6/q6afe.h b/sound/soc/qcom/qdsp6/q6afe.h
index 1a0f80a14afe..c7ed5422baff 100644
--- a/sound/soc/qcom/qdsp6/q6afe.h
+++ b/sound/soc/qcom/qdsp6/q6afe.h
@@ -198,7 +198,6 @@ int q6afe_port_start(struct q6afe_port *port);
int q6afe_port_stop(struct q6afe_port *port);
void q6afe_port_put(struct q6afe_port *port);
int q6afe_get_port_id(int index);
-int q6afe_is_rx_port(int index);
void q6afe_hdmi_port_prepare(struct q6afe_port *port,
struct q6afe_hdmi_cfg *cfg);
void q6afe_slim_port_prepare(struct q6afe_port *port,
diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c
index e77a88784e61..0d10fba53945 100644
--- a/sound/soc/qcom/sdm845.c
+++ b/sound/soc/qcom/sdm845.c
@@ -543,16 +543,14 @@ static int sdm845_snd_platform_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
int ret;
- card = kzalloc(sizeof(*card), GFP_KERNEL);
+ card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
if (!card)
return -ENOMEM;
/* Allocate the private data */
- data = kzalloc(sizeof(*data), GFP_KERNEL);
- if (!data) {
- ret = -ENOMEM;
- goto data_alloc_fail;
- }
+ data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
card->dapm_widgets = sdm845_snd_widgets;
card->num_dapm_widgets = ARRAY_SIZE(sdm845_snd_widgets);
@@ -560,38 +558,13 @@ static int sdm845_snd_platform_probe(struct platform_device *pdev)
dev_set_drvdata(dev, card);
ret = qcom_snd_parse_of(card);
if (ret)
- goto parse_dt_fail;
+ return ret;
data->card = card;
snd_soc_card_set_drvdata(card, data);
sdm845_add_ops(card);
- ret = snd_soc_register_card(card);
- if (ret) {
- dev_err(dev, "Sound card registration failed\n");
- goto register_card_fail;
- }
- return ret;
-
-register_card_fail:
- kfree(card->dai_link);
-parse_dt_fail:
- kfree(data);
-data_alloc_fail:
- kfree(card);
- return ret;
-}
-
-static int sdm845_snd_platform_remove(struct platform_device *pdev)
-{
- struct snd_soc_card *card = dev_get_drvdata(&pdev->dev);
- struct sdm845_snd_data *data = snd_soc_card_get_drvdata(card);
-
- snd_soc_unregister_card(card);
- kfree(card->dai_link);
- kfree(data);
- kfree(card);
- return 0;
+ return devm_snd_soc_register_card(dev, card);
}
static const struct of_device_id sdm845_snd_device_id[] = {
@@ -604,7 +577,6 @@ MODULE_DEVICE_TABLE(of, sdm845_snd_device_id);
static struct platform_driver sdm845_snd_driver = {
.probe = sdm845_snd_platform_probe,
- .remove = sdm845_snd_platform_remove,
.driver = {
.name = "msm-snd-sdm845",
.of_match_table = sdm845_snd_device_id,