diff options
Diffstat (limited to 'sound/soc/soc-core.c')
| -rw-r--r-- | sound/soc/soc-core.c | 148 | 
1 files changed, 123 insertions, 25 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 1d70829464e..7ff04ad2a97 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -28,6 +28,7 @@  #include <linux/bitops.h>  #include <linux/debugfs.h>  #include <linux/platform_device.h> +#include <sound/ac97_codec.h>  #include <sound/core.h>  #include <sound/pcm.h>  #include <sound/pcm_params.h> @@ -619,8 +620,9 @@ static struct snd_pcm_ops soc_pcm_ops = {  #ifdef CONFIG_PM  /* powers down audio subsystem for suspend */ -static int soc_suspend(struct platform_device *pdev, pm_message_t state) +static int soc_suspend(struct device *dev)  { +	struct platform_device *pdev = to_platform_device(dev);  	struct snd_soc_device *socdev = platform_get_drvdata(pdev);  	struct snd_soc_card *card = socdev->card;  	struct snd_soc_platform *platform = card->platform; @@ -656,7 +658,7 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state)  		snd_pcm_suspend_all(card->dai_link[i].pcm);  	if (card->suspend_pre) -		card->suspend_pre(pdev, state); +		card->suspend_pre(pdev, PMSG_SUSPEND);  	for (i = 0; i < card->num_links; i++) {  		struct snd_soc_dai  *cpu_dai = card->dai_link[i].cpu_dai; @@ -682,7 +684,7 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state)  	}  	if (codec_dev->suspend) -		codec_dev->suspend(pdev, state); +		codec_dev->suspend(pdev, PMSG_SUSPEND);  	for (i = 0; i < card->num_links; i++) {  		struct snd_soc_dai *cpu_dai = card->dai_link[i].cpu_dai; @@ -691,7 +693,7 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state)  	}  	if (card->suspend_post) -		card->suspend_post(pdev, state); +		card->suspend_post(pdev, PMSG_SUSPEND);  	return 0;  } @@ -765,8 +767,9 @@ static void soc_resume_deferred(struct work_struct *work)  }  /* powers up audio subsystem after a suspend */ -static int soc_resume(struct platform_device *pdev) +static int soc_resume(struct device *dev)  { +	struct platform_device *pdev = to_platform_device(dev);  	struct snd_soc_device *socdev = platform_get_drvdata(pdev);  	struct snd_soc_card *card = socdev->card;  	struct snd_soc_dai *cpu_dai = card->dai_link[0].cpu_dai; @@ -788,6 +791,44 @@ static int soc_resume(struct platform_device *pdev)  	return 0;  } +/** + * snd_soc_suspend_device: Notify core of device suspend + * + * @dev: Device being suspended. + * + * In order to ensure that the entire audio subsystem is suspended in a + * coordinated fashion ASoC devices should suspend themselves when + * called by ASoC.  When the standard kernel suspend process asks the + * device to suspend it should call this function to initiate a suspend + * of the entire ASoC card. + * + * \note Currently this function is stubbed out. + */ +int snd_soc_suspend_device(struct device *dev) +{ +	return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_suspend_device); + +/** + * snd_soc_resume_device: Notify core of device resume + * + * @dev: Device being resumed. + * + * In order to ensure that the entire audio subsystem is resumed in a + * coordinated fashion ASoC devices should resume themselves when called + * by ASoC.  When the standard kernel resume process asks the device + * to resume it should call this function.  Once all the components of + * the card have notified that they are ready to be resumed the card + * will be resumed. + * + * \note Currently this function is stubbed out. + */ +int snd_soc_resume_device(struct device *dev) +{ +	return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_resume_device);  #else  #define soc_suspend	NULL  #define soc_resume	NULL @@ -981,16 +1022,39 @@ static int soc_remove(struct platform_device *pdev)  	return 0;  } +static int soc_poweroff(struct device *dev) +{ +	struct platform_device *pdev = to_platform_device(dev); +	struct snd_soc_device *socdev = platform_get_drvdata(pdev); +	struct snd_soc_card *card = socdev->card; + +	if (!card->instantiated) +		return 0; + +	/* Flush out pmdown_time work - we actually do want to run it +	 * now, we're shutting down so no imminent restart. */ +	run_delayed_work(&card->delayed_work); + +	snd_soc_dapm_shutdown(socdev); + +	return 0; +} + +static struct dev_pm_ops soc_pm_ops = { +	.suspend = soc_suspend, +	.resume = soc_resume, +	.poweroff = soc_poweroff, +}; +  /* ASoC platform driver */  static struct platform_driver soc_driver = {  	.driver		= {  		.name		= "soc-audio",  		.owner		= THIS_MODULE, +		.pm		= &soc_pm_ops,  	},  	.probe		= soc_probe,  	.remove		= soc_remove, -	.suspend	= soc_suspend, -	.resume		= soc_resume,  };  /* create a new pcm */ @@ -1062,6 +1126,23 @@ static int soc_new_pcm(struct snd_soc_device *socdev,  	return ret;  } +/** + * snd_soc_codec_volatile_register: Report if a register is volatile. + * + * @codec: CODEC to query. + * @reg: Register to query. + * + * Boolean function indiciating if a CODEC register is volatile. + */ +int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int reg) +{ +	if (codec->volatile_register) +		return codec->volatile_register(reg); +	else +		return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_codec_volatile_register); +  /* codec register dump */  static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf)  { @@ -1075,6 +1156,9 @@ static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf)  	count += sprintf(buf, "%s registers\n", codec->name);  	for (i = 0; i < codec->reg_cache_size; i += step) { +		if (codec->readable_register && !codec->readable_register(i)) +			continue; +  		count += sprintf(buf + count, "%2x: ", i);  		if (count >= PAGE_SIZE - 1)  			break; @@ -1183,10 +1267,18 @@ static void soc_init_codec_debugfs(struct snd_soc_codec *codec)  	if (!codec->debugfs_pop_time)  		printk(KERN_WARNING  		       "Failed to create pop time debugfs file\n"); + +	codec->debugfs_dapm = debugfs_create_dir("dapm", debugfs_root); +	if (!codec->debugfs_dapm) +		printk(KERN_WARNING +		       "Failed to create DAPM debugfs directory\n"); + +	snd_soc_dapm_debugfs_init(codec);  }  static void soc_cleanup_codec_debugfs(struct snd_soc_codec *codec)  { +	debugfs_remove_recursive(codec->debugfs_dapm);  	debugfs_remove(codec->debugfs_pop_time);  	debugfs_remove(codec->debugfs_reg);  } @@ -1264,10 +1356,10 @@ EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec);   * Returns 1 for change else 0.   */  int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, -				unsigned short mask, unsigned short value) +				unsigned int mask, unsigned int value)  {  	int change; -	unsigned short old, new; +	unsigned int old, new;  	mutex_lock(&io_mutex);  	old = snd_soc_read(codec, reg); @@ -1294,10 +1386,10 @@ EXPORT_SYMBOL_GPL(snd_soc_update_bits);   * Returns 1 for change else 0.   */  int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg, -				unsigned short mask, unsigned short value) +				unsigned int mask, unsigned int value)  {  	int change; -	unsigned short old, new; +	unsigned int old, new;  	mutex_lock(&io_mutex);  	old = snd_soc_read(codec, reg); @@ -1381,8 +1473,11 @@ int snd_soc_init_card(struct snd_soc_device *socdev)  				continue;  			}  		} -		if (card->dai_link[i].codec_dai->ac97_control) +		if (card->dai_link[i].codec_dai->ac97_control) {  			ac97 = 1; +			snd_ac97_dev_add_pdata(codec->ac97, +				card->dai_link[i].cpu_dai->ac97_pdata); +		}  	}  	snprintf(codec->card->shortname, sizeof(codec->card->shortname),  		 "%s",  card->name); @@ -1586,7 +1681,7 @@ int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,  {  	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);  	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; -	unsigned short val, bitmask; +	unsigned int val, bitmask;  	for (bitmask = 1; bitmask < e->max; bitmask <<= 1)  		; @@ -1615,8 +1710,8 @@ int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,  {  	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);  	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; -	unsigned short val; -	unsigned short mask, bitmask; +	unsigned int val; +	unsigned int mask, bitmask;  	for (bitmask = 1; bitmask < e->max; bitmask <<= 1)  		; @@ -1652,7 +1747,7 @@ int snd_soc_get_value_enum_double(struct snd_kcontrol *kcontrol,  {  	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);  	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; -	unsigned short reg_val, val, mux; +	unsigned int reg_val, val, mux;  	reg_val = snd_soc_read(codec, e->reg);  	val = (reg_val >> e->shift_l) & e->mask; @@ -1691,8 +1786,8 @@ int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol,  {  	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);  	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; -	unsigned short val; -	unsigned short mask; +	unsigned int val; +	unsigned int mask;  	if (ucontrol->value.enumerated.item[0] > e->max - 1)  		return -EINVAL; @@ -1852,7 +1947,7 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,  	int max = mc->max;  	unsigned int mask = (1 << fls(max)) - 1;  	unsigned int invert = mc->invert; -	unsigned short val, val2, val_mask; +	unsigned int val, val2, val_mask;  	val = (ucontrol->value.integer.value[0] & mask);  	if (invert) @@ -1918,7 +2013,7 @@ int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,  	unsigned int reg2 = mc->rreg;  	unsigned int shift = mc->shift;  	int max = mc->max; -	unsigned int mask = (1<<fls(max))-1; +	unsigned int mask = (1 << fls(max)) - 1;  	unsigned int invert = mc->invert;  	ucontrol->value.integer.value[0] = @@ -1958,7 +2053,7 @@ int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,  	unsigned int mask = (1 << fls(max)) - 1;  	unsigned int invert = mc->invert;  	int err; -	unsigned short val, val2, val_mask; +	unsigned int val, val2, val_mask;  	val_mask = mask << shift;  	val = (ucontrol->value.integer.value[0] & mask); @@ -2050,7 +2145,7 @@ int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,  	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);  	unsigned int reg = mc->reg;  	int min = mc->min; -	unsigned short val; +	unsigned int val;  	val = (ucontrol->value.integer.value[0]+min) & 0xff;  	val |= ((ucontrol->value.integer.value[1]+min) & 0xff) << 8; @@ -2136,17 +2231,20 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt);  /**   * snd_soc_dai_set_tdm_slot - configure DAI TDM.   * @dai: DAI - * @mask: DAI specific mask representing used slots. + * @tx_mask: bitmask representing active TX slots. + * @rx_mask: bitmask representing active RX slots.   * @slots: Number of slots in use. + * @slot_width: Width in bits for each slot.   *   * Configures a DAI for TDM operation. Both mask and slots are codec and DAI   * specific.   */  int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, -	unsigned int mask, int slots) +	unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)  {  	if (dai->ops && dai->ops->set_tdm_slot) -		return dai->ops->set_tdm_slot(dai, mask, slots); +		return dai->ops->set_tdm_slot(dai, tx_mask, rx_mask, +				slots, slot_width);  	else  		return -EINVAL;  }  |