kfree(dev);
}
----static int soc_aux_dev_init(struct snd_soc_card *card,
---- struct snd_soc_codec *codec,
---- int num)
---{
--- struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
--- struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num];
--- int ret;
---
--- rtd->card = card;
---
--- /* do machine specific initialization */
--- if (aux_dev->init) {
--- ret = aux_dev->init(&codec->dapm);
--- if (ret < 0)
--- return ret;
--- }
---
--- rtd->codec = codec;
---
--- return 0;
---}
---
---static int soc_dai_link_init(struct snd_soc_card *card,
--- struct snd_soc_codec *codec,
--- int num)
++++static int soc_post_component_init(struct snd_soc_pcm_runtime *rtd,
++++ const char *name)
{
- struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
- struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num];
- int ret;
-
- rtd->card = card;
-
- /* do machine specific initialization */
- if (aux_dev->init) {
- ret = aux_dev->init(&codec->dapm);
- if (ret < 0)
- return ret;
- }
-
- rtd->codec = codec;
-
- return 0;
- }
-
- static int soc_dai_link_init(struct snd_soc_card *card,
- struct snd_soc_codec *codec,
- int num)
- {
---- struct snd_soc_dai_link *dai_link = &card->dai_link[num];
---- struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
---- int ret;
----
---- rtd->card = card;
----
---- /* do machine specific initialization */
---- if (dai_link->init) {
---- ret = dai_link->init(rtd);
---- if (ret < 0)
---- return ret;
---- }
----
---- rtd->codec = codec;
----
---- return 0;
----}
----
----static int soc_post_component_init(struct snd_soc_card *card,
---- struct snd_soc_codec *codec,
---- int num, int dailess)
----{
---- struct snd_soc_dai_link *dai_link = NULL;
---- struct snd_soc_aux_dev *aux_dev = NULL;
---- struct snd_soc_pcm_runtime *rtd;
---- const char *name;
int ret = 0;
---- if (!dailess) {
---- dai_link = &card->dai_link[num];
---- rtd = &card->rtd[num];
---- name = dai_link->name;
---- ret = soc_dai_link_init(card, codec, num);
---- } else {
---- aux_dev = &card->aux_dev[num];
---- rtd = &card->rtd_aux[num];
---- name = aux_dev->name;
---- ret = soc_aux_dev_init(card, codec, num);
---- }
----
---- if (ret < 0) {
---- dev_err(card->dev, "ASoC: failed to init %s: %d\n", name, ret);
---- return ret;
---- }
----
/* register the rtd device */
rtd->dev = kzalloc(sizeof(struct device), GFP_KERNEL);
if (!rtd->dev)
return ret;
}
----/**
---- * snd_soc_register_component - Register a component with the ASoC core
---- *
---- */
----static int
----__snd_soc_register_component(struct device *dev,
---- struct snd_soc_component *cmpnt,
---- const struct snd_soc_component_driver *cmpnt_drv,
---- struct snd_soc_codec *codec,
---- struct snd_soc_dai_driver *dai_drv,
---- int num_dai, bool allow_single_dai)
++++static void snd_soc_component_seq_notifier(struct snd_soc_dapm_context *dapm,
++++ enum snd_soc_dapm_type type, int subseq)
{
---- int ret;
++++ struct snd_soc_component *component = dapm->component;
---- dev_dbg(dev, "component register %s\n", dev_name(dev));
++++ component->driver->seq_notifier(component, type, subseq);
++++}
---- if (!cmpnt) {
---- dev_err(dev, "ASoC: Failed to connecting component\n");
---- return -ENOMEM;
---- }
++++static int snd_soc_component_stream_event(struct snd_soc_dapm_context *dapm,
++++ int event)
++++{
++++ struct snd_soc_component *component = dapm->component;
---- mutex_init(&cmpnt->io_mutex);
++++ return component->driver->stream_event(component, event);
++++}
+++
- cmpnt->name = fmt_single_name(dev, &cmpnt->id);
- if (!cmpnt->name) {
- dev_err(dev, "ASoC: Failed to simplifying name\n");
++++static int snd_soc_component_initialize(struct snd_soc_component *component,
++++ const struct snd_soc_component_driver *driver, struct device *dev)
++++{
++++ struct snd_soc_dapm_context *dapm;
+
--- cmpnt->name = fmt_single_name(dev, &cmpnt->id);
--- if (!cmpnt->name) {
--- dev_err(dev, "ASoC: Failed to simplifying name\n");
++++ component->name = fmt_single_name(dev, &component->id);
++++ if (!component->name) {
++++ dev_err(dev, "ASoC: Failed to allocate name\n");
return -ENOMEM;
}
---- cmpnt->dev = dev;
---- cmpnt->driver = cmpnt_drv;
---- cmpnt->dai_drv = dai_drv;
---- cmpnt->num_dai = num_dai;
---- INIT_LIST_HEAD(&cmpnt->dai_list);
++++ component->dev = dev;
++++ component->driver = driver;
---- ret = snd_soc_register_dais(cmpnt, codec, dai_drv, num_dai,
---- allow_single_dai);
---- if (ret < 0) {
---- dev_err(dev, "ASoC: Failed to regster DAIs: %d\n", ret);
---- goto error_component_name;
---- }
++++ if (!component->dapm_ptr)
++++ component->dapm_ptr = &component->dapm;
++++
++++ dapm = component->dapm_ptr;
++++ dapm->dev = dev;
++++ dapm->component = component;
++++ dapm->bias_level = SND_SOC_BIAS_OFF;
++++ if (driver->seq_notifier)
++++ dapm->seq_notifier = snd_soc_component_seq_notifier;
++++ if (driver->stream_event)
++++ dapm->stream_event = snd_soc_component_stream_event;
++++
++++ INIT_LIST_HEAD(&component->dai_list);
++++ mutex_init(&component->io_mutex);
+
++++ return 0;
++++}
++++
++++static void snd_soc_component_add_unlocked(struct snd_soc_component *component)
++++{
++++ list_add(&component->list, &component_list);
++++}
+++
++++static void snd_soc_component_add(struct snd_soc_component *component)
++++{
mutex_lock(&client_mutex);
---- list_add(&cmpnt->list, &component_list);
++++ snd_soc_component_add_unlocked(component);
mutex_unlock(&client_mutex);
++++}
---- dev_dbg(cmpnt->dev, "ASoC: Registered component '%s'\n", cmpnt->name);
----
---- return ret;
++++static void snd_soc_component_cleanup(struct snd_soc_component *component)
++++{
++++ snd_soc_unregister_dais(component);
++++ kfree(component->name);
++++}
----error_component_name:
---- kfree(cmpnt->name);
++++static void snd_soc_component_del_unlocked(struct snd_soc_component *component)
++++{
++++ list_del(&component->list);
++++}
---- return ret;
++++static void snd_soc_component_del(struct snd_soc_component *component)
++++{
++++ mutex_lock(&client_mutex);
++++ snd_soc_component_del_unlocked(component);
++++ mutex_unlock(&client_mutex);
}
int snd_soc_register_component(struct device *dev,