summaryrefslogtreecommitdiff
path: root/sound/soc/soc-compress.c
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2020-01-10 05:35:21 +0300
committerMark Brown <broonie@kernel.org>2020-01-10 16:31:22 +0300
commit613fb50059cf19aa6acbc503a00265d9151c0b09 (patch)
tree65c16095cdfbbef874c085d6ad552983fea255c6 /sound/soc/soc-compress.c
parenta84188eced6109983af54f9435a26d21eac3f8cc (diff)
downloadlinux-613fb50059cf19aa6acbc503a00265d9151c0b09.tar.xz
ASoC: soc-core: remove snd_soc_rtdcom_list
Current ALSA SoC is using struct snd_soc_rtdcom_list to connecting component to rtd by using list_head. struct snd_soc_rtdcom_list { struct snd_soc_component *component; struct list_head list; /* rtd::component_list */ }; struct snd_soc_pcm_runtime { ... struct list_head component_list; /* list of connected components */ ... }; The CPU/Codec/Platform component which will be connected to rtd (a) is indicated via dai_link at snd_soc_add_pcm_runtime() int snd_soc_add_pcm_runtime(...) { ... /* Find CPU from registered CPUs */ rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus); ... (a) snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component); ... /* Find CODEC from registered CODECs */ (b) for_each_link_codecs(dai_link, i, codec) { rtd->codec_dais[i] = snd_soc_find_dai(codec); ... (a) snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component); } ... /* Find PLATFORM from registered PLATFORMs */ (b) for_each_link_platforms(dai_link, i, platform) { for_each_component(component) { ... (a) snd_soc_rtdcom_add(rtd, component); } } } It shows, it is possible to know how many components will be connected to rtd by using dai_link->num_cpus dai_link->num_codecs dai_link->num_platforms If so, we can use component pointer array instead of list_head, in such case, code can be more simple. This patch removes struct snd_soc_rtdcom_list that is only of temporary value, and convert to pointer array. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/87a76wt4wm.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/soc-compress.c')
-rw-r--r--sound/soc/soc-compress.c75
1 files changed, 31 insertions, 44 deletions
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index b2a5351b1a11..16fe08690cf5 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -26,10 +26,9 @@ static int soc_compr_components_open(struct snd_compr_stream *cstream,
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
- struct snd_soc_rtdcom_list *rtdcom;
- int ret;
+ int i, ret;
- for_each_rtd_components(rtd, rtdcom, component) {
+ for_each_rtd_components(rtd, i, component) {
if (!component->driver->compr_ops ||
!component->driver->compr_ops->open)
continue;
@@ -54,9 +53,9 @@ static int soc_compr_components_free(struct snd_compr_stream *cstream,
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
- struct snd_soc_rtdcom_list *rtdcom;
+ int i;
- for_each_rtd_components(rtd, rtdcom, component) {
+ for_each_rtd_components(rtd, i, component) {
if (component == last)
break;
@@ -74,11 +73,10 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component, *save = NULL;
- struct snd_soc_rtdcom_list *rtdcom;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
- int ret;
+ int ret, i;
- for_each_rtd_components(rtd, rtdcom, component) {
+ for_each_rtd_components(rtd, i, component) {
ret = pm_runtime_get_sync(component->dev);
if (ret < 0 && ret != -EACCES) {
pm_runtime_put_noidle(component->dev);
@@ -127,7 +125,7 @@ machine_err:
out:
mutex_unlock(&rtd->card->pcm_mutex);
pm_err:
- for_each_rtd_components(rtd, rtdcom, component) {
+ for_each_rtd_components(rtd, i, component) {
if (component == save)
break;
pm_runtime_mark_last_busy(component->dev);
@@ -259,10 +257,9 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
- struct snd_soc_rtdcom_list *rtdcom;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
struct snd_soc_dai *codec_dai = rtd->codec_dai;
- int stream;
+ int stream, i;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
@@ -309,7 +306,7 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
mutex_unlock(&rtd->card->pcm_mutex);
- for_each_rtd_components(rtd, rtdcom, component) {
+ for_each_rtd_components(rtd, i, component) {
pm_runtime_mark_last_busy(component->dev);
pm_runtime_put_autosuspend(component->dev);
}
@@ -371,10 +368,9 @@ static int soc_compr_components_trigger(struct snd_compr_stream *cstream,
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
- struct snd_soc_rtdcom_list *rtdcom;
- int ret;
+ int i, ret;
- for_each_rtd_components(rtd, rtdcom, component) {
+ for_each_rtd_components(rtd, i, component) {
if (!component->driver->compr_ops ||
!component->driver->compr_ops->trigger)
continue;
@@ -474,10 +470,9 @@ static int soc_compr_components_set_params(struct snd_compr_stream *cstream,
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
- struct snd_soc_rtdcom_list *rtdcom;
- int ret;
+ int i, ret;
- for_each_rtd_components(rtd, rtdcom, component) {
+ for_each_rtd_components(rtd, i, component) {
if (!component->driver->compr_ops ||
!component->driver->compr_ops->set_params)
continue;
@@ -606,9 +601,8 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
- struct snd_soc_rtdcom_list *rtdcom;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
- int ret = 0;
+ int i, ret = 0;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
@@ -618,7 +612,7 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
goto err;
}
- for_each_rtd_components(rtd, rtdcom, component) {
+ for_each_rtd_components(rtd, i, component) {
if (!component->driver->compr_ops ||
!component->driver->compr_ops->get_params)
continue;
@@ -637,12 +631,11 @@ static int soc_compr_get_caps(struct snd_compr_stream *cstream,
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
- struct snd_soc_rtdcom_list *rtdcom;
- int ret = 0;
+ int i, ret = 0;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
- for_each_rtd_components(rtd, rtdcom, component) {
+ for_each_rtd_components(rtd, i, component) {
if (!component->driver->compr_ops ||
!component->driver->compr_ops->get_caps)
continue;
@@ -660,12 +653,11 @@ static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream,
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
- struct snd_soc_rtdcom_list *rtdcom;
- int ret = 0;
+ int i, ret = 0;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
- for_each_rtd_components(rtd, rtdcom, component) {
+ for_each_rtd_components(rtd, i, component) {
if (!component->driver->compr_ops ||
!component->driver->compr_ops->get_codec_caps)
continue;
@@ -683,9 +675,8 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
- struct snd_soc_rtdcom_list *rtdcom;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
- int ret = 0;
+ int i, ret = 0;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
@@ -695,7 +686,7 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
goto err;
}
- for_each_rtd_components(rtd, rtdcom, component) {
+ for_each_rtd_components(rtd, i, component) {
if (!component->driver->compr_ops ||
!component->driver->compr_ops->ack)
continue;
@@ -715,8 +706,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
- struct snd_soc_rtdcom_list *rtdcom;
- int ret = 0;
+ int i, ret = 0;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
@@ -724,7 +714,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
if (cpu_dai->driver->cops && cpu_dai->driver->cops->pointer)
cpu_dai->driver->cops->pointer(cstream, tstamp, cpu_dai);
- for_each_rtd_components(rtd, rtdcom, component) {
+ for_each_rtd_components(rtd, i, component) {
if (!component->driver->compr_ops ||
!component->driver->compr_ops->pointer)
continue;
@@ -742,12 +732,11 @@ static int soc_compr_copy(struct snd_compr_stream *cstream,
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
- struct snd_soc_rtdcom_list *rtdcom;
- int ret = 0;
+ int i, ret = 0;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
- for_each_rtd_components(rtd, rtdcom, component) {
+ for_each_rtd_components(rtd, i, component) {
if (!component->driver->compr_ops ||
!component->driver->compr_ops->copy)
continue;
@@ -765,9 +754,8 @@ static int soc_compr_set_metadata(struct snd_compr_stream *cstream,
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
- struct snd_soc_rtdcom_list *rtdcom;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
- int ret;
+ int i, ret;
if (cpu_dai->driver->cops && cpu_dai->driver->cops->set_metadata) {
ret = cpu_dai->driver->cops->set_metadata(cstream, metadata, cpu_dai);
@@ -775,7 +763,7 @@ static int soc_compr_set_metadata(struct snd_compr_stream *cstream,
return ret;
}
- for_each_rtd_components(rtd, rtdcom, component) {
+ for_each_rtd_components(rtd, i, component) {
if (!component->driver->compr_ops ||
!component->driver->compr_ops->set_metadata)
continue;
@@ -794,9 +782,8 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream,
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_component *component;
- struct snd_soc_rtdcom_list *rtdcom;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
- int ret;
+ int i, ret;
if (cpu_dai->driver->cops && cpu_dai->driver->cops->get_metadata) {
ret = cpu_dai->driver->cops->get_metadata(cstream, metadata, cpu_dai);
@@ -804,7 +791,7 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream,
return ret;
}
- for_each_rtd_components(rtd, rtdcom, component) {
+ for_each_rtd_components(rtd, i, component) {
if (!component->driver->compr_ops ||
!component->driver->compr_ops->get_metadata)
continue;
@@ -857,7 +844,6 @@ static struct snd_compr_ops soc_compr_dyn_ops = {
int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
{
struct snd_soc_component *component;
- struct snd_soc_rtdcom_list *rtdcom;
struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
struct snd_compr *compr;
@@ -865,6 +851,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
char new_name[64];
int ret = 0, direction = 0;
int playback = 0, capture = 0;
+ int i;
if (rtd->num_codecs > 1) {
dev_err(rtd->card->dev,
@@ -933,7 +920,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops));
}
- for_each_rtd_components(rtd, rtdcom, component) {
+ for_each_rtd_components(rtd, i, component) {
if (!component->driver->compr_ops ||
!component->driver->compr_ops->copy)
continue;