diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2013-10-17 01:05:26 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-10-17 19:43:32 -0400 |
commit | 6833c452c2fb47353566aa705d68541c6045c796 (patch) | |
tree | e729fe7bf43a71b506b8545370682871f9ac06d4 | |
parent | 7cc302d231aae87a08909ae40cdf36dfe7bb5102 (diff) |
ASoC: add snd_soc_of_get_dai_name() default of_xlate
Current snd_soc_of_get_dai_name() needs .of_xlate_dai_name()
callback on each component drivers.
But required behavior on almost all these drivers is
just returns its indexed driver's name.
This patch adds this feature as default behavior.
.of_xlate_dai_name() can overwrite it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | include/sound/soc.h | 4 | ||||
-rw-r--r-- | sound/soc/soc-core.c | 28 |
2 files changed, 27 insertions, 5 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h index b13eecbaea78..6ed3dc0773cc 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
@@ -644,10 +644,12 @@ struct snd_soc_component_driver { | |||
644 | struct snd_soc_component { | 644 | struct snd_soc_component { |
645 | const char *name; | 645 | const char *name; |
646 | int id; | 646 | int id; |
647 | int num_dai; | ||
648 | struct device *dev; | 647 | struct device *dev; |
649 | struct list_head list; | 648 | struct list_head list; |
650 | 649 | ||
650 | struct snd_soc_dai_driver *dai_drv; | ||
651 | int num_dai; | ||
652 | |||
651 | const struct snd_soc_component_driver *driver; | 653 | const struct snd_soc_component_driver *driver; |
652 | }; | 654 | }; |
653 | 655 | ||
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 67cfb5f5ca96..0860a7f11299 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -4023,6 +4023,7 @@ __snd_soc_register_component(struct device *dev, | |||
4023 | 4023 | ||
4024 | cmpnt->dev = dev; | 4024 | cmpnt->dev = dev; |
4025 | cmpnt->driver = cmpnt_drv; | 4025 | cmpnt->driver = cmpnt_drv; |
4026 | cmpnt->dai_drv = dai_drv; | ||
4026 | cmpnt->num_dai = num_dai; | 4027 | cmpnt->num_dai = num_dai; |
4027 | 4028 | ||
4028 | /* | 4029 | /* |
@@ -4548,12 +4549,31 @@ int snd_soc_of_get_dai_name(struct device_node *of_node, | |||
4548 | if (pos->dev->of_node != args.np) | 4549 | if (pos->dev->of_node != args.np) |
4549 | continue; | 4550 | continue; |
4550 | 4551 | ||
4551 | if (!pos->driver->of_xlate_dai_name) { | 4552 | if (pos->driver->of_xlate_dai_name) { |
4552 | ret = -ENOSYS; | 4553 | ret = pos->driver->of_xlate_dai_name(pos, &args, dai_name); |
4553 | break; | 4554 | } else { |
4555 | int id = -1; | ||
4556 | |||
4557 | switch (args.args_count) { | ||
4558 | case 0: | ||
4559 | id = 0; /* same as dai_drv[0] */ | ||
4560 | break; | ||
4561 | case 1: | ||
4562 | id = args.args[0]; | ||
4563 | break; | ||
4564 | default: | ||
4565 | /* not supported */ | ||
4566 | break; | ||
4567 | } | ||
4568 | |||
4569 | if (id < 0 || id >= pos->num_dai) { | ||
4570 | ret = -EINVAL; | ||
4571 | } else { | ||
4572 | *dai_name = pos->dai_drv[id].name; | ||
4573 | ret = 0; | ||
4574 | } | ||
4554 | } | 4575 | } |
4555 | 4576 | ||
4556 | ret = pos->driver->of_xlate_dai_name(pos, &args, dai_name); | ||
4557 | break; | 4577 | break; |
4558 | } | 4578 | } |
4559 | mutex_unlock(&client_mutex); | 4579 | mutex_unlock(&client_mutex); |