From: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
To: alsa-devel@alsa-project.org
Cc: liam.r.girdwood@linux.intel.com, mengdong.lin@linux.intel.com,
vinod.koul@intel.com,
Vaibhav Agarwal <vaibhav.agarwal@linaro.org>,
peter.ujfalusi@ti.com, broonie@kernel.org
Subject: [RFC 4/4] ASoC: Change soc-card codec_conf array to a list
Date: Mon, 15 Feb 2016 17:49:32 +0530 [thread overview]
Message-ID: <1455538772-24926-5-git-send-email-vaibhav.agarwal@linaro.org> (raw)
In-Reply-To: <1455538772-24926-1-git-send-email-vaibhav.agarwal@linaro.org>
Currently, number & type of codec(s) available on a platform is
fixed. Thus, machine driver knows in advance the corresponding
device name and can easily define codec_configuration
(name_prefix, compress_type) statically.
However, with the scope of adding codec devices dynamically there
is a need to add codec configuration dynamically as well.
Now we can add/remove codec configuration dynamically in response
to any codec device added/removed.
For backward compatibility, there is a provision to create list
for predefined codec configuration as well.
ToDo:
For snd_soc_remove_codec_config(), possible argument should be
of_node as well to identify codec_conf
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
---
include/sound/soc.h | 10 +++++++++-
sound/soc/soc-core.c | 48 ++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 53 insertions(+), 5 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 44d8568..4074ec3 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -396,6 +396,7 @@ struct snd_soc_dai_link;
struct snd_soc_platform_driver;
struct snd_soc_codec;
struct snd_soc_codec_driver;
+struct snd_soc_codec_conf;
struct snd_soc_component;
struct snd_soc_component_driver;
struct soc_enum;
@@ -1074,6 +1075,7 @@ struct snd_soc_codec_conf {
* associated per device
*/
const char *name_prefix;
+ struct list_head list; /* codec_conf list of the soc card */
};
struct snd_soc_aux_dev {
@@ -1140,8 +1142,9 @@ struct snd_soc_card {
int num_rtd;
/* optional codec specific configuration */
- struct snd_soc_codec_conf *codec_conf;
+ struct snd_soc_codec_conf *codec_conf; /* predefined configs only */
int num_configs;
+ struct list_head codec_conf_list; /* all configs */
/*
* optional auxiliary devices such as amplifiers or codecs with DAI
@@ -1688,6 +1691,11 @@ int snd_soc_add_dailink(struct snd_soc_card *card,
struct snd_soc_dai_link *dai_link);
void snd_soc_remove_dailink(struct snd_soc_card *card, const char *link_name);
+void snd_soc_add_codec_config(struct snd_soc_card *card,
+ struct snd_soc_codec_conf *codec_conf);
+void snd_soc_remove_codec_config(struct snd_soc_card *card,
+ const char *dev_name);
+
int snd_soc_register_dai(struct snd_soc_component *component,
struct snd_soc_dai_driver *dai_drv);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 7049f9b..57ce151 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1584,16 +1584,51 @@ void snd_soc_remove_dailink(struct snd_soc_card *card, const char *link_name)
}
EXPORT_SYMBOL_GPL(snd_soc_remove_dailink);
+/**
+ * snd_soc_add_codec_config - add codec configuration to a sound card.
+ *
+ * @card: Sound card identifier to add codec configuration to
+ * @codec_conf: codec configuration to add
+ */
+void snd_soc_add_codec_config(struct snd_soc_card *card,
+ struct snd_soc_codec_conf *codec_conf)
+{
+ mutex_lock(&client_mutex);
+ list_add_tail(&codec_conf->list, &card->codec_conf_list);
+ mutex_unlock(&client_mutex);
+}
+EXPORT_SYMBOL(snd_soc_add_codec_config);
+
+/**
+ * snd_soc_remove_codec_config - remove codec configuration from a sound card.
+ *
+ * @card: Sound card identifier to remove codec configuration from
+ * @dev_name: codec configuration identifier
+ */
+void snd_soc_remove_codec_config(struct snd_soc_card *card,
+ const char *dev_name)
+{
+ struct snd_soc_codec_conf *codec_conf;
+
+ mutex_lock(&client_mutex);
+ list_for_each_entry(codec_conf, &card->codec_conf_list, list)
+ if (!strcmp(codec_conf->dev_name, dev_name)) {
+ list_del(&codec_conf->list);
+ break;
+ }
+ mutex_unlock(&client_mutex);
+}
+EXPORT_SYMBOL(snd_soc_remove_codec_config);
+
static void soc_set_name_prefix(struct snd_soc_card *card,
struct snd_soc_component *component)
{
- int i;
+ struct snd_soc_codec_conf *map, *_map;
- if (card->codec_conf == NULL)
+ if (list_empty(&card->codec_conf_list))
return;
- for (i = 0; i < card->num_configs; i++) {
- struct snd_soc_codec_conf *map = &card->codec_conf[i];
+ list_for_each_entry_safe(map, _map, &card->codec_conf_list, list) {
if (map->of_node && component->dev->of_node != map->of_node)
continue;
if (map->dev_name && strcmp(component->name, map->dev_name))
@@ -2119,6 +2154,10 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
for (i = 0; i < card->num_links; i++)
snd_soc_add_dai_link(card, card->dai_link+i);
+ /* add predefined codec_configs to the list */
+ for (i = 0; i < card->num_configs; i++)
+ snd_soc_add_codec_config(card, card->codec_conf+i);
+
/* initialize the register cache for each available codec */
list_for_each_entry(codec, &codec_list, list) {
if (codec->cache_init)
@@ -2899,6 +2938,7 @@ int snd_soc_register_card(struct snd_soc_card *card)
INIT_LIST_HEAD(&card->rtd_list);
card->num_rtd = 0;
+ INIT_LIST_HEAD(&card->codec_conf_list);
INIT_LIST_HEAD(&card->dapm_dirty);
INIT_LIST_HEAD(&card->dobj_list);
card->instantiated = 0;
--
2.1.4
next prev parent reply other threads:[~2016-02-15 12:19 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-15 12:19 [RFC 0/4] Add support for DAI link addition dynamically Vaibhav Agarwal
2016-02-15 12:19 ` [RFC 1/4] ASoc: Use ref_count for soc DAI & component Vaibhav Agarwal
2016-02-15 13:59 ` Mark Brown
2016-02-16 13:27 ` Vaibhav Agarwal
2016-02-15 12:19 ` [RFC 2/4] alsa: add locked variant for snd_ctl_remove_id Vaibhav Agarwal
2016-02-15 14:02 ` Mark Brown
2016-02-16 13:54 ` Vaibhav Agarwal
2016-02-16 14:13 ` Takashi Iwai
2016-02-16 14:15 ` Vaibhav Agarwal
2016-02-15 12:19 ` [RFC 3/4] ASoC: Enable dynamic DAIlink insertion & removal Vaibhav Agarwal
2016-02-15 17:02 ` Mark Brown
2016-02-16 14:34 ` Vaibhav Agarwal
2016-02-16 19:03 ` Mark Brown
2016-02-15 12:19 ` Vaibhav Agarwal [this message]
2016-02-15 17:11 ` [RFC 4/4] ASoC: Change soc-card codec_conf array to a list Mark Brown
2016-02-15 14:22 ` [RFC 0/4] Add support for DAI link addition dynamically Lars-Peter Clausen
2016-02-17 5:52 ` Mengdong Lin
2016-02-17 8:25 ` Mengdong Lin
2016-02-17 9:31 ` Vaibhav Agarwal
2016-02-18 5:23 ` Mengdong Lin
2016-02-18 7:57 ` Vaibhav Agarwal
2016-02-18 13:39 ` Mark Brown
2016-02-22 8:51 ` Mengdong Lin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1455538772-24926-5-git-send-email-vaibhav.agarwal@linaro.org \
--to=vaibhav.agarwal@linaro.org \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=liam.r.girdwood@linux.intel.com \
--cc=mengdong.lin@linux.intel.com \
--cc=peter.ujfalusi@ti.com \
--cc=vinod.koul@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).