aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-core.c
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-11-08 05:43:25 -0500
committerMark Brown <broonie@linaro.org>2013-11-08 05:43:25 -0500
commitc6016bdeab11e2deb01058b93133633def62fa27 (patch)
tree5f5c098e07a282d51f83ea711991a60322ea118c /sound/soc/soc-core.c
parentd20b09f0c5aaaa49a8a0189837a87adbc40095f0 (diff)
parent988e8cc41efecbab53f13184940aa6317047765b (diff)
Merge remote-tracking branch 'asoc/topic/core' into asoc-next
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r--sound/soc/soc-core.c131
1 files changed, 62 insertions, 69 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index b1c472fde84b..4e53d87e881d 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -662,6 +662,8 @@ int snd_soc_suspend(struct device *dev)
662 codec->cache_sync = 1; 662 codec->cache_sync = 1;
663 if (codec->using_regmap) 663 if (codec->using_regmap)
664 regcache_mark_dirty(codec->control_data); 664 regcache_mark_dirty(codec->control_data);
665 /* deactivate pins to sleep state */
666 pinctrl_pm_select_sleep_state(codec->dev);
665 break; 667 break;
666 default: 668 default:
667 dev_dbg(codec->dev, 669 dev_dbg(codec->dev,
@@ -679,6 +681,9 @@ int snd_soc_suspend(struct device *dev)
679 681
680 if (cpu_dai->driver->suspend && cpu_dai->driver->ac97_control) 682 if (cpu_dai->driver->suspend && cpu_dai->driver->ac97_control)
681 cpu_dai->driver->suspend(cpu_dai); 683 cpu_dai->driver->suspend(cpu_dai);
684
685 /* deactivate pins to sleep state */
686 pinctrl_pm_select_sleep_state(cpu_dai->dev);
682 } 687 }
683 688
684 if (card->suspend_post) 689 if (card->suspend_post)
@@ -807,6 +812,16 @@ int snd_soc_resume(struct device *dev)
807 if (list_empty(&card->codec_dev_list)) 812 if (list_empty(&card->codec_dev_list))
808 return 0; 813 return 0;
809 814
815 /* activate pins from sleep state */
816 for (i = 0; i < card->num_rtd; i++) {
817 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;
818 struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai;
819 if (cpu_dai->active)
820 pinctrl_pm_select_default_state(cpu_dai->dev);
821 if (codec_dai->active)
822 pinctrl_pm_select_default_state(codec_dai->dev);
823 }
824
810 /* AC97 devices might have other drivers hanging off them so 825 /* AC97 devices might have other drivers hanging off them so
811 * need to resume immediately. Other drivers don't have that 826 * need to resume immediately. Other drivers don't have that
812 * problem and may take a substantial amount of time to resume 827 * problem and may take a substantial amount of time to resume
@@ -1589,17 +1604,13 @@ static void soc_remove_aux_dev(struct snd_soc_card *card, int num)
1589 soc_remove_codec(codec); 1604 soc_remove_codec(codec);
1590} 1605}
1591 1606
1592static int snd_soc_init_codec_cache(struct snd_soc_codec *codec, 1607static int snd_soc_init_codec_cache(struct snd_soc_codec *codec)
1593 enum snd_soc_compress_type compress_type)
1594{ 1608{
1595 int ret; 1609 int ret;
1596 1610
1597 if (codec->cache_init) 1611 if (codec->cache_init)
1598 return 0; 1612 return 0;
1599 1613
1600 /* override the compress_type if necessary */
1601 if (compress_type && codec->compress_type != compress_type)
1602 codec->compress_type = compress_type;
1603 ret = snd_soc_cache_init(codec); 1614 ret = snd_soc_cache_init(codec);
1604 if (ret < 0) { 1615 if (ret < 0) {
1605 dev_err(codec->dev, 1616 dev_err(codec->dev,
@@ -1614,8 +1625,6 @@ static int snd_soc_init_codec_cache(struct snd_soc_codec *codec,
1614static int snd_soc_instantiate_card(struct snd_soc_card *card) 1625static int snd_soc_instantiate_card(struct snd_soc_card *card)
1615{ 1626{
1616 struct snd_soc_codec *codec; 1627 struct snd_soc_codec *codec;
1617 struct snd_soc_codec_conf *codec_conf;
1618 enum snd_soc_compress_type compress_type;
1619 struct snd_soc_dai_link *dai_link; 1628 struct snd_soc_dai_link *dai_link;
1620 int ret, i, order, dai_fmt; 1629 int ret, i, order, dai_fmt;
1621 1630
@@ -1639,19 +1648,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1639 list_for_each_entry(codec, &codec_list, list) { 1648 list_for_each_entry(codec, &codec_list, list) {
1640 if (codec->cache_init) 1649 if (codec->cache_init)
1641 continue; 1650 continue;
1642 /* by default we don't override the compress_type */ 1651 ret = snd_soc_init_codec_cache(codec);
1643 compress_type = 0;
1644 /* check to see if we need to override the compress_type */
1645 for (i = 0; i < card->num_configs; ++i) {
1646 codec_conf = &card->codec_conf[i];
1647 if (!strcmp(codec->name, codec_conf->dev_name)) {
1648 compress_type = codec_conf->compress_type;
1649 if (compress_type && compress_type
1650 != codec->compress_type)
1651 break;
1652 }
1653 }
1654 ret = snd_soc_init_codec_cache(codec, compress_type);
1655 if (ret < 0) 1652 if (ret < 0)
1656 goto base_error; 1653 goto base_error;
1657 } 1654 }
@@ -1947,6 +1944,14 @@ int snd_soc_poweroff(struct device *dev)
1947 1944
1948 snd_soc_dapm_shutdown(card); 1945 snd_soc_dapm_shutdown(card);
1949 1946
1947 /* deactivate pins to sleep state */
1948 for (i = 0; i < card->num_rtd; i++) {
1949 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;
1950 struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai;
1951 pinctrl_pm_select_sleep_state(codec_dai->dev);
1952 pinctrl_pm_select_sleep_state(cpu_dai->dev);
1953 }
1954
1950 return 0; 1955 return 0;
1951} 1956}
1952EXPORT_SYMBOL_GPL(snd_soc_poweroff); 1957EXPORT_SYMBOL_GPL(snd_soc_poweroff);
@@ -2297,13 +2302,6 @@ unsigned int snd_soc_write(struct snd_soc_codec *codec,
2297} 2302}
2298EXPORT_SYMBOL_GPL(snd_soc_write); 2303EXPORT_SYMBOL_GPL(snd_soc_write);
2299 2304
2300unsigned int snd_soc_bulk_write_raw(struct snd_soc_codec *codec,
2301 unsigned int reg, const void *data, size_t len)
2302{
2303 return codec->bulk_write_raw(codec, reg, data, len);
2304}
2305EXPORT_SYMBOL_GPL(snd_soc_bulk_write_raw);
2306
2307/** 2305/**
2308 * snd_soc_update_bits - update codec register bits 2306 * snd_soc_update_bits - update codec register bits
2309 * @codec: audio codec 2307 * @codec: audio codec
@@ -2576,8 +2574,9 @@ int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
2576 2574
2577 if (uinfo->value.enumerated.item > e->max - 1) 2575 if (uinfo->value.enumerated.item > e->max - 1)
2578 uinfo->value.enumerated.item = e->max - 1; 2576 uinfo->value.enumerated.item = e->max - 1;
2579 strcpy(uinfo->value.enumerated.name, 2577 strlcpy(uinfo->value.enumerated.name,
2580 e->texts[uinfo->value.enumerated.item]); 2578 e->texts[uinfo->value.enumerated.item],
2579 sizeof(uinfo->value.enumerated.name));
2581 return 0; 2580 return 0;
2582} 2581}
2583EXPORT_SYMBOL_GPL(snd_soc_info_enum_double); 2582EXPORT_SYMBOL_GPL(snd_soc_info_enum_double);
@@ -3791,6 +3790,16 @@ int snd_soc_register_card(struct snd_soc_card *card)
3791 if (ret != 0) 3790 if (ret != 0)
3792 soc_cleanup_card_debugfs(card); 3791 soc_cleanup_card_debugfs(card);
3793 3792
3793 /* deactivate pins to sleep state */
3794 for (i = 0; i < card->num_rtd; i++) {
3795 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;
3796 struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai;
3797 if (!codec_dai->active)
3798 pinctrl_pm_select_sleep_state(codec_dai->dev);
3799 if (!cpu_dai->active)
3800 pinctrl_pm_select_sleep_state(cpu_dai->dev);
3801 }
3802
3794 return ret; 3803 return ret;
3795} 3804}
3796EXPORT_SYMBOL_GPL(snd_soc_register_card); 3805EXPORT_SYMBOL_GPL(snd_soc_register_card);
@@ -4063,6 +4072,7 @@ __snd_soc_register_component(struct device *dev,
4063 4072
4064 cmpnt->dev = dev; 4073 cmpnt->dev = dev;
4065 cmpnt->driver = cmpnt_drv; 4074 cmpnt->driver = cmpnt_drv;
4075 cmpnt->dai_drv = dai_drv;
4066 cmpnt->num_dai = num_dai; 4076 cmpnt->num_dai = num_dai;
4067 4077
4068 /* 4078 /*
@@ -4287,7 +4297,6 @@ int snd_soc_register_codec(struct device *dev,
4287 struct snd_soc_dai_driver *dai_drv, 4297 struct snd_soc_dai_driver *dai_drv,
4288 int num_dai) 4298 int num_dai)
4289{ 4299{
4290 size_t reg_size;
4291 struct snd_soc_codec *codec; 4300 struct snd_soc_codec *codec;
4292 int ret, i; 4301 int ret, i;
4293 4302
@@ -4304,11 +4313,6 @@ int snd_soc_register_codec(struct device *dev,
4304 goto fail_codec; 4313 goto fail_codec;
4305 } 4314 }
4306 4315
4307 if (codec_drv->compress_type)
4308 codec->compress_type = codec_drv->compress_type;
4309 else
4310 codec->compress_type = SND_SOC_FLAT_COMPRESSION;
4311
4312 codec->write = codec_drv->write; 4316 codec->write = codec_drv->write;
4313 codec->read = codec_drv->read; 4317 codec->read = codec_drv->read;
4314 codec->volatile_register = codec_drv->volatile_register; 4318 codec->volatile_register = codec_drv->volatile_register;
@@ -4325,35 +4329,6 @@ int snd_soc_register_codec(struct device *dev,
4325 codec->num_dai = num_dai; 4329 codec->num_dai = num_dai;
4326 mutex_init(&codec->mutex); 4330 mutex_init(&codec->mutex);
4327 4331
4328 /* allocate CODEC register cache */
4329 if (codec_drv->reg_cache_size && codec_drv->reg_word_size) {
4330 reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size;
4331 codec->reg_size = reg_size;
4332 /* it is necessary to make a copy of the default register cache
4333 * because in the case of using a compression type that requires
4334 * the default register cache to be marked as the
4335 * kernel might have freed the array by the time we initialize
4336 * the cache.
4337 */
4338 if (codec_drv->reg_cache_default) {
4339 codec->reg_def_copy = kmemdup(codec_drv->reg_cache_default,
4340 reg_size, GFP_KERNEL);
4341 if (!codec->reg_def_copy) {
4342 ret = -ENOMEM;
4343 goto fail_codec_name;
4344 }
4345 }
4346 }
4347
4348 if (codec_drv->reg_access_size && codec_drv->reg_access_default) {
4349 if (!codec->volatile_register)
4350 codec->volatile_register = snd_soc_default_volatile_register;
4351 if (!codec->readable_register)
4352 codec->readable_register = snd_soc_default_readable_register;
4353 if (!codec->writable_register)
4354 codec->writable_register = snd_soc_default_writable_register;
4355 }
4356
4357 for (i = 0; i < num_dai; i++) { 4332 for (i = 0; i < num_dai; i++) {
4358 fixup_codec_formats(&dai_drv[i].playback); 4333 fixup_codec_formats(&dai_drv[i].playback);
4359 fixup_codec_formats(&dai_drv[i].capture); 4334 fixup_codec_formats(&dai_drv[i].capture);
@@ -4412,7 +4387,6 @@ found:
4412 dev_dbg(codec->dev, "ASoC: Unregistered codec '%s'\n", codec->name); 4387 dev_dbg(codec->dev, "ASoC: Unregistered codec '%s'\n", codec->name);
4413 4388
4414 snd_soc_cache_exit(codec); 4389 snd_soc_cache_exit(codec);
4415 kfree(codec->reg_def_copy);
4416 kfree(codec->name); 4390 kfree(codec->name);
4417 kfree(codec); 4391 kfree(codec);
4418} 4392}
@@ -4624,12 +4598,31 @@ int snd_soc_of_get_dai_name(struct device_node *of_node,
4624 if (pos->dev->of_node != args.np) 4598 if (pos->dev->of_node != args.np)
4625 continue; 4599 continue;
4626 4600
4627 if (!pos->driver->of_xlate_dai_name) { 4601 if (pos->driver->of_xlate_dai_name) {
4628 ret = -ENOSYS; 4602 ret = pos->driver->of_xlate_dai_name(pos, &args, dai_name);
4629 break; 4603 } else {
4604 int id = -1;
4605
4606 switch (args.args_count) {
4607 case 0:
4608 id = 0; /* same as dai_drv[0] */
4609 break;
4610 case 1:
4611 id = args.args[0];
4612 break;
4613 default:
4614 /* not supported */
4615 break;
4616 }
4617
4618 if (id < 0 || id >= pos->num_dai) {
4619 ret = -EINVAL;
4620 } else {
4621 *dai_name = pos->dai_drv[id].name;
4622 ret = 0;
4623 }
4630 } 4624 }
4631 4625
4632 ret = pos->driver->of_xlate_dai_name(pos, &args, dai_name);
4633 break; 4626 break;
4634 } 4627 }
4635 mutex_unlock(&client_mutex); 4628 mutex_unlock(&client_mutex);