ASoC: au1x: platform driver restructuring
RFC PATCH 1/1 ASoC: au1x: platform driver restructuring
Hi Mark!
Please have a look at the patch below and verify it does what you suggested earlier, and if you have no objections, add it to your patchqueue.
Both the AC97 and I2S modules are converted to full platform drivers; the PCM (DMA) interface is initialized during platform probe. Run-tested on DB1200 board.
Thank you!
Manuel Lauss
---
From: Manuel Lauss <[email protected]>
Subject: [PATCH] ASoC: au1x: platform driver restructuring
Make the AC97/I2S modules full platform drivers and update the sample machine code.
--- sound/soc/au1x/dbdma2.c | 24 +++++----- sound/soc/au1x/psc-ac97.c | 103 +++++++++++++++++++++++++----------------- sound/soc/au1x/psc-i2s.c | 103 ++++++++++++++++++++++++------------------ sound/soc/au1x/psc.h | 7 ++- sound/soc/au1x/sample-ac97.c | 48 +++++++++++-------- 5 files changed, 165 insertions(+), 120 deletions(-)
sound/soc/au1x/dbdma2.c +11 -13
@@ -1,8 +1,8 @@/* * Au12x0/Au1550 PSC ALSA ASoC audio support. * -* (c) 2007-2008 MSC Vertriebsges.m.b.H., -* Manuel Lauss <[email protected]> +* (c) 2007-2009 MSC Vertriebsges.m.b.H., +* Manuel Lauss <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -331,7 +331,7 @@ static int au1xpsc_pcm_new(struct snd_card *card,return 0 ; } -static int au1xpsc_pcm_probe (struct platform_device *pdev) +int au1xpsc_asoc_dbdma_init (struct platform_device *pdev) {struct resource *r;int ret;
@@ -375,8 +375,9 @@ out1: au1xpsc_audio_pcmdma[PCM_TX ] =NULL ;return ret; } +EXPORT_SYMBOL_GPL (au1xpsc_asoc_dbdma_init); -static int au1xpsc_pcm_remove (struct platform_device *pdev) +void au1xpsc_asoc_dbdma_exit (void ) {int i;
@@ -387,36 +388,33 @@ static int au1xpsc_pcm_remove(struct platform_device *pdev) au1xpsc_audio_pcmdma[i] =NULL ; } } - -return 0 ; } +EXPORT_SYMBOL_GPL (au1xpsc_asoc_dbdma_exit);/* au1xpsc audio platform */ struct snd_soc_platform au1xpsc_soc_platform = { .name ="au1xpsc-pcm-dbdma" , - .probe = au1xpsc_pcm_probe, - .remove = au1xpsc_pcm_remove, .pcm_ops = &au1xpsc_pcm_ops, .pcm_new = au1xpsc_pcm_new, .pcm_free = au1xpsc_pcm_free_dma_buffers, };EXPORT_SYMBOL_GPL (au1xpsc_soc_platform); -static int __init au1xpsc_audio_dbdma_init (void ) +static int __init au1xpsc_audio_dbdma_load (void ) { au1xpsc_audio_pcmdma[PCM_TX ] =NULL ; au1xpsc_audio_pcmdma[PCM_RX ] =NULL ;return snd_soc_register_platform (&au1xpsc_soc_platform); } -static void __exit au1xpsc_audio_dbdma_exit(void) +static void __exit au1xpsc_audio_dbdma_unload(void) {snd_soc_unregister_platform (&au1xpsc_soc_platform); } -module_init (au1xpsc_audio_dbdma_init); -module_exit (au1xpsc_audio_dbdma_exit); +module_init (au1xpsc_audio_dbdma_load); +module_exit (au1xpsc_audio_dbdma_unload);MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("Au12x0/Au1550 PSC Audio DMA driver" ); -MODULE_AUTHOR ("Manuel Lauss <[email protected]>" ); +MODULE_AUTHOR ("Manuel Lauss" );
sound/soc/au1x/psc-ac97.c +62 -41
159 lines not on this page · raw message
sound/soc/au1x/psc-i2s.c +59 -44
166 lines not on this page · raw message
sound/soc/au1x/psc.h +5 -2
@@ -1,8 +1,8 @@/* * Au12x0/Au1550 PSC ALSA ASoC audio support. * -* (c) 2007-2008 MSC Vertriebsges.m.b.H., -* Manuel Lauss <[email protected]> +* (c) 2007-2009 MSC Vertriebsges.m.b.H., +* Manuel Lauss <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -21,6 +21,9 @@ extern struct snd_soc_dai au1xpsc_i2s_dai;extern struct snd_soc_platform au1xpsc_soc_platform;extern struct snd_ac97_bus_ops soc_ac97_ops; +extern int au1xpsc_asoc_dbdma_init (struct platform_device *pdev); +extern void au1xpsc_asoc_dbdma_exit (void ); +struct au1xpsc_audio_data {void __iomem *mmio;
sound/soc/au1x/sample-ac97.c +28 -20
100 lines not on this page · raw message
Signature · 1 line
1.6.3.1
sound/soc/au1x/psc-ac97.c static int au1xpsc_ac97_suspend(struct snd_soc_dai *dai) · line 367
Quoted 8 lines · Manuel Lauss
sound/soc/au1x/psc-ac97.c +1
-1-static int au1xpsc_ac97_suspend (struct snd_soc_dai *dai) +static int au1xpsc_ac97_suspend (struct platform_device *pdev,pm_message_t m) {/* save interesting registers and disable PSC */ au1xpsc_ac97_workdata->pm[0] =@@ -328,7 +366,7 @@ static int au1xpsc_ac97_suspend(struct snd_soc_dai *dai)return 0 ; }
I'm don't think this is a good idea - it will remove any sequencing between the suspend of the various ASoC device components, meaning that the AC97 controller could suspend before the rest of ASoC. This would break if ASoC then comes along and tries to suspend the CODEC over an AC97 link which has been disabled. With I2S it's probably less serious but there's a risk of audio issues if the hardware does something dodgy when suspending or if the SoC is the clock master and the CODEC gets upset about having clocks stopping when it's using them.
In order to do this properly I have a plan to add a calls into the ASoC core that the individual drivers can call when they get suspend and resume calls. The core will suspend the entire ASoC device when it gets the first suspend call and will wait for all the suspended devices to resume before it resumes the ASoC device. I've not actually added those calls yet, though. I can add stubs quickly enough, though - I should probably do that just now so that we don't need a separate driver conversion step.
One other thing I'd say is that before registering the DAIs you should assign the dev field in the DAI structure to be the struct device that was used to probe the DAI.
Quoted 14 lines · Mark Brown
Review static int au1xpsc_ac97_suspend(struct snd_soc_dai *dai) · line 367
Quoted 8 lines · Manuel Lauss
sound/soc/au1x/psc-ac97.c +1
-1-static int au1xpsc_ac97_suspend (struct snd_soc_dai *dai) +static int au1xpsc_ac97_suspend (struct platform_device *pdev,pm_message_t m){
/* save interesting registers and disable PSC */ au1xpsc_ac97_workdata->pm[0] =(quoted diff) +0
-0@@ -328,7 +366,7 @@ static int au1xpsc_ac97_suspend(struct snd_soc_dai *dai) return 0; }I'm don't think this is a good idea - it will remove any sequencing between the suspend of the various ASoC device components, meaning that the AC97 controller could suspend before the rest of ASoC. This would
Reverted back,
Quoted 3 lines
One other thing I'd say is that before registering the DAIs you should assign the dev field in the DAI structure to be the struct device that was used to probe the DAI.
Done.
This patch unfortunately breaks PM (no sound after suspend-to-ram), so may take a while until I resend.
Thank you!
Manuel Lauss
Quoted 7 lines · Manuel Lauss
On Sat, Jun 13, 2009 at 7:44 PM, Mark
Quoted 3 lines
I'm don't think this is a good idea - it will remove any sequencing between the suspend of the various ASoC device components, meaning that the AC97 controller could suspend before the rest of ASoC. This would
Reverted back,
OK, when you do resubmit you might want to check for the patch below should make it in shortly:
Quoted 1 line
From
831dc0f10f7b2a4856094ff160c018bf19f77527Mon Sep 17 00:00:00 2001
From: Mark Brown <[email protected]>
Date: Sat, 13 Jun 2009 19:55:02 +0100
Subject: [PATCH] ASoC: Add stub suspend and resume calls for ASoC subdevices
Now that ASoC subdevices can be regular devices they can have normal suspend and resume calls from their buses. However, suspending them individually is not desirable since this can lead to problems such as pops and clicks from devices being suspended with their signals being amplified or clocks being stopped suddenly.
This will be resolved by having the normal device model suspend and resume calls call into ASoC which will suspend the entire card while any of its components are suspended. At present this is not yet implemented but in order to aid the transition of drivers to the standard device model this patch adds API calls for the notifications.
--- include/sound/soc.h | 5 +++++ sound/soc/soc-core.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 0 deletions(-)
include/sound/soc.h +5 -0
@@ -192,6 +192,11 @@ void snd_soc_unregister_platform(struct snd_soc_platform *platform);int snd_soc_register_codec (struct snd_soc_codec *codec);void snd_soc_unregister_codec (struct snd_soc_codec *codec); +#ifdef CONFIG_PM +int snd_soc_suspend_device (struct device *dev); +int snd_soc_resume_device (struct device *dev); +#endif +/* pcm <-> DAI connect */ void snd_soc_free_pcms (struct snd_soc_device *socdev);int snd_soc_new_pcms (struct snd_soc_device *socdev,int idx,const char *xid);
sound/soc/soc-core.c +39 -0
@@ -788,6 +788,45 @@ 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
Signature · 1 line
1.6.3.1