ASoC: Untangle AC'97 support form the core
Subsystems (9)
Lars-Peter Clausen
maintainercover ASoC: Untangle AC'97 support form the core
The AC'97 support has had a special role within the ASoC framework with it being (in contrast to other audio buses) tightly integrated into the core. This patch series creates a clean separation between the core and the AC'97 support making AC'97 from the point of view of the core just another bus. Some of the changes in this series are required for the upcoming conversion of the AC'97 drivers to regmap, the other changes just fit nicely with the idea of componentization and having a generic ASoC core.
The series starts with moving AC'97 support to its own file and doing a few general cleanups. After that it drops support of two features which were mainly responsible for the tight integration but are seemingly unused. This is
a) Delaying the initialization and registration of the AC'97 device until after the card has been registered. There doesn't seem to be a good reason to delay to registration, all the information we need to register the device is available at the time when the device is created. Furthermore this will be needed for regmap.
b) Setting platform data for the AC'97 via the CPU DAI. This hasn't been used in the last 5 years and doesn't seem to be that useful in general.
If we should ever have a need for those features again they can still be implemented on top of the current code while keeping the clean separation. But for the time being it is simpler to just drop unused code rather than restructuring it.
Finally the series pushes the pointer to the AC'97 device from the snd_soc_codec struct out to the driver private structs.
Depends on asoc/topic/ad1980, asoc/topic/wm9705 and asoc/topic/wm971x
- Lars
Lars-Peter Clausen (11):
ASoC: mpc5200_psc_ac97: Remove unused on-stack snd_ac97 device
ASoC: mpc5200_dma: Don't overwrite ac97 device private_data
ASoC: Properly handle AC'97 device lifetime management
ASoC: Move AC'97 support to its own file
ASoC: ac97: Use static ac97_bus
ASoC: ac97: Merge
soc_ac97_dev_{un,}register()/soc_{un,}register_ac97_codec() ASoC: ac97: Drop support for setting platform data via the CPU DAI
ASoC: ac97: Drop delayed device registration
ASoC: Drop ac97_control initialization from CODEC driver DAIs
ASoC: Rename snd_soc_dai_driver struct ac97_control field to
bus_control
ASoC: ac97: Push snd_ac97 pointer to the driver level
include/sound/soc-dai.h | 4 +- include/sound/soc.h | 25 ++- sound/soc/Makefile | 4 + sound/soc/au1x/ac97c.c | 2 +- sound/soc/au1x/psc-ac97.c | 2 +- sound/soc/blackfin/bf5xx-ac97.c | 2 +- sound/soc/cirrus/ep93xx-ac97.c | 2 +- sound/soc/codecs/ac97.c | 18 +- sound/soc/codecs/ad1980.c | 28 +-- sound/soc/codecs/stac9766.c | 40 +++-- sound/soc/codecs/wm9705.c | 32 ++-- sound/soc/codecs/wm9712.c | 33 ++-- sound/soc/codecs/wm9713.c | 32 ++-- sound/soc/fsl/fsl_ssi.c | 2 +- sound/soc/fsl/imx-ssi.c | 2 +- sound/soc/fsl/mpc5200_dma.c | 3 - sound/soc/fsl/mpc5200_psc_ac97.c | 6 +- sound/soc/nuc900/nuc900-ac97.c | 2 +- sound/soc/pxa/pxa2xx-ac97.c | 6 +- sound/soc/samsung/ac97.c | 4 +- sound/soc/sh/hac.c | 2 +- sound/soc/soc-ac97.c | 256 +++++++++++++++++++++++++++ sound/soc/soc-core.c | 372 ++------------------------------------- sound/soc/tegra/tegra20_ac97.c | 2 +- sound/soc/txx9/txx9aclc-ac97.c | 2 +- 25 files changed, 428 insertions(+), 455 deletions(-) create mode 100644 sound/soc/soc-ac97.c
Signature · 1 line
1.8.0
Lars-Peter Clausen
maintainerPATCH 1/11 ASoC: mpc5200_psc_ac97: Remove unused on-stack snd_ac97 device
The mpc5200_psc_ac97 driver puts a snd_ac97 device on the stack in the driver probe function, initializes the private data member of the device and the never uses the device again. It should be safe to remove it.
--- sound/soc/fsl/mpc5200_psc_ac97.c | 2 -- 1 file changed, 2 deletions(-)
sound/soc/fsl/mpc5200_psc_ac97.c +0 -2
@@ -282,7 +282,6 @@ static const struct snd_soc_component_driver psc_ac97_component = {static int psc_ac97_of_probe (struct platform_device *op) {int rc; -struct snd_ac97 ac97;struct mpc52xx_psc __iomem *regs; rc =mpc5200_audio_dma_create (op);
@@ -304,7 +303,6 @@ static int psc_ac97_of_probe(struct platform_device *op) psc_dma =dev_get_drvdata (&op->dev); regs = psc_dma->psc_regs; - ac97.private_data = psc_dma; psc_dma->imr =0 ;out_be16 (&psc_dma->psc_regs->isr_imr.imr, psc_dma->imr);
Signature · 1 line
1.8.0
Lars-Peter Clausen
maintainerPATCH 2/11 ASoC: mpc5200_dma: Don't overwrite ac97 device private_data
In reply to Lars-Peter ClausenThe mpc5200_dma overwrites the private_data field of the CODEC's AC'97 device with the DMA drivers private data, but never actually reads it again. Given that the private_data field is supposed to be owned by the AC'97 driver, overwriting it may cause undefined behavior. This patch removes the code that overwrites the field from the driver.
--- sound/soc/fsl/mpc5200_dma.c | 3 --- 1 file changed, 3 deletions(-)
sound/soc/fsl/mpc5200_dma.c +0 -3
@@ -327,9 +327,6 @@ static int psc_dma_new(struct snd_soc_pcm_runtime *rtd) goto capture_alloc_err; } -if (rtd->codec->ac97) - rtd->codec->ac97->private_data = psc_dma; -return 0 ; capture_alloc_err:
Signature · 1 line
1.8.0
Lars-Peter Clausen
maintainerPATCH 3/11 ASoC: Properly handle AC'97 device lifetime management
In reply to Lars-Peter ClausenThe memory that a struct device is contained in must not be freed except from within the device's release callback. The ASoC code currently does not adhere to this rule for the AC'97 device. This patch fixes it by moving the freeing of the AC'97 to the release callback and splitting up the registration and unregistration of the device into separate steps for getting/putting the reference to the device and adding/removing it to the device hierarchy.
--- sound/soc/soc-core.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
sound/soc/soc-core.c +11 -7
@@ -501,13 +501,10 @@ EXPORT_SYMBOL_GPL(snd_soc_get_pcm_runtime);static int soc_ac97_dev_unregister (struct snd_soc_codec *codec) {if (codec->ac97->dev.bus) -device_unregister (&codec->ac97->dev); +device_del (&codec->ac97->dev);return 0 ; } -/* stop no dev release warning */ -static void soc_ac97_device_release (struct device *dev){} -/* register ac97 codec to bus */ static int soc_ac97_dev_register (struct snd_soc_codec *codec) {
@@ -515,12 +512,11 @@ static int soc_ac97_dev_register(struct snd_soc_codec *codec) codec->ac97->dev.bus = &ac97_bus_type; codec->ac97->dev.parent = codec->component.card->dev; - codec->ac97->dev.release = soc_ac97_device_release;dev_set_name (&codec->ac97->dev,"%d-%d:%s" , codec->component.card->snd_card->number,0 , codec->component.name); - err =device_register (&codec->ac97->dev); + err =device_add (&codec->ac97->dev);if (err <0 ) {dev_err (codec->dev,"ASoC: Can't register ac97 bus\n" ); codec->ac97->dev.bus =NULL ;
@@ -1913,6 +1909,11 @@ static struct platform_driver soc_driver = { .remove = soc_remove, }; +static void soc_ac97_device_release (struct device *dev) +{ +kfree (to_ac97_t (dev)); +} +/** * snd_soc_new_ac97_codec - initailise AC97 device * @codec: audio codec
@@ -1937,12 +1938,14 @@ int snd_soc_new_ac97_codec(struct snd_soc_codec *codec, codec->ac97->bus->ops = ops; codec->ac97->num = num; + codec->ac97->dev.release = soc_ac97_device_release;/* * Mark the AC97 device to be created by us. This way we ensure that the * device will be registered with the device subsystem later on. */ codec->ac97_created =1 ; +device_initialize (&codec->ac97->dev);return 0 ; }
@@ -2117,7 +2120,8 @@ void snd_soc_free_ac97_codec(struct snd_soc_codec *codec)soc_unregister_ac97_codec (codec);#endif kfree (codec->ac97->bus); -kfree (codec->ac97); + codec->ac97->bus =NULL ; +put_device (&codec->ac97->dev); codec->ac97 =NULL ; codec->ac97_created =0 ; }
Signature · 1 line
1.8.0
Lars-Peter Clausen
maintainerPATCH 4/11 ASoC: Move AC'97 support to its own file
In reply to Lars-Peter ClausenCurrently the AC'97 support is splattered all throughout soc-core.c. Some parts are #ifdef'd some parts are not. This patch moves the AC'97 support to its own file, this should make the code a bit more clearer and also makes it possible to easily not compile it into the kernel when not needed.
--- include/sound/soc.h | 28 +++- sound/soc/Makefile | 4 + sound/soc/soc-ac97.c | 382 +++++++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/soc-core.c | 352 +---------------------------------------------- 4 files changed, 416 insertions(+), 350 deletions(-) create mode 100644 sound/soc/soc-ac97.c
include/sound/soc.h +26 -2
@@ -369,8 +369,6 @@ struct snd_soc_jack_gpio;typedef int (*hw_write_t )(void *,const char * ,int ); -extern struct snd_ac97_bus_ops *soc_ac97_ops; -enum snd_soc_pcm_subclass {SND_SOC_PCM_CLASS_PCM =0 ,SND_SOC_PCM_CLASS_BE =1 ,
@@ -499,6 +497,7 @@ int snd_soc_update_bits_locked(struct snd_soc_codec *codec,int snd_soc_test_bits (struct snd_soc_codec *codec,unsigned int reg,unsigned int mask,unsigned int value); +#ifdef CONFIG_SND_SOC_AC97_BUS int snd_soc_new_ac97_codec (struct snd_soc_codec *codec,struct snd_ac97_bus_ops *ops,int num);void snd_soc_free_ac97_codec (struct snd_soc_codec *codec);
@@ -507,6 +506,31 @@ int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops);int snd_soc_set_ac97_ops_of_reset (struct snd_ac97_bus_ops *ops,struct platform_device *pdev); +extern struct snd_ac97_bus_ops *soc_ac97_ops; + +int snd_soc_ac97_register_dai_links (struct snd_soc_card *card); +void snd_soc_ac97_add_pdata (struct snd_soc_pcm_runtime *rtd); +#else + +static inline int snd_soc_ac97_register_dai_links (struct snd_soc_card *card) +{ +return 0 ; +} + +static inline void snd_soc_ac97_add_pdata (struct snd_soc_pcm_runtime *rtd) {} + +static inline int snd_soc_set_ac97_ops_of_reset (struct snd_ac97_bus_ops *ops, +struct platform_device *pdev) +{ +return 0 ; +} + +static inline int snd_soc_set_ac97_ops (struct snd_ac97_bus_ops *ops) +{ +return 0 ; +} +#endif +/* *Controls */
sound/soc/Makefile +4 -0
@@ -5,6 +5,10 @@ ifneq ($(CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM),) snd-soc-core-objs += soc-generic-dmaengine-pcm.o endif +ifneq ($(CONFIG_SND_SOC_AC97_BUS),) +snd-soc-core-objs += soc-ac97.o +endif + obj-$(CONFIG_SND_SOC) += snd-soc-core.o obj-$(CONFIG_SND_SOC) += codecs/ obj-$(CONFIG_SND_SOC) += generic/
sound/soc/soc-ac97.c new file +382 -0
382 lines not on this page · raw message
sound/soc/soc-core.c +4 -348
392 lines not on this page · raw message
Signature · 1 line
1.8.0
Lars-Peter Clausen
maintainerPATCH 5/11 ASoC: ac97: Use static ac97_bus
In reply to Lars-Peter ClausenWe always pass soc_ac97_ops to snd_soc_new_ac97_codec(). So instead of allocating a snd_ac97_bus in snd_soc_new_ac97_codec() just use a static one that gets initialized when snd_soc_set_ac97_ops() is called.
Also drop the device number parameter from snd_soc_new_ac97_codec(). We currently only support one device per bus and all drivers pass 0 for the device number. And if we should ever support multiple devices per bus it wouldn't be up to individual AC'97 device drivers to pick their number, but rather either the AC'97 adapter driver or the core code will assign them.
--- include/sound/soc.h | 3 +-- sound/soc/codecs/ad1980.c | 2 +- sound/soc/codecs/stac9766.c | 2 +- sound/soc/codecs/wm9705.c | 2 +- sound/soc/codecs/wm9712.c | 2 +- sound/soc/codecs/wm9713.c | 2 +- sound/soc/soc-ac97.c | 22 ++++++++-------------- 7 files changed, 14 insertions(+), 21 deletions(-)
include/sound/soc.h +1 -2
@@ -498,8 +498,7 @@ int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg, unsigned int mask, unsigned int value);#ifdef CONFIG_SND_SOC_AC97_BUS -int snd_soc_new_ac97_codec (struct snd_soc_codec *codec, -struct snd_ac97_bus_ops *ops,int num); +int snd_soc_new_ac97_codec (struct snd_soc_codec *codec);void snd_soc_free_ac97_codec (struct snd_soc_codec *codec);int snd_soc_set_ac97_ops (struct snd_ac97_bus_ops *ops);
sound/soc/codecs/ad1980.c +1 -1
@@ -220,7 +220,7 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec)u16 vendor_id2;u16 ext_status; - ret =snd_soc_new_ac97_codec (codec, soc_ac97_ops,0 ); + ret =snd_soc_new_ac97_codec (codec);if (ret <0 ) {dev_err (codec->dev,"Failed to register AC97 codec\n" );return ret;
sound/soc/codecs/stac9766.c +1 -1
@@ -329,7 +329,7 @@ static int stac9766_codec_probe(struct snd_soc_codec *codec) {int ret =0 ; - ret =snd_soc_new_ac97_codec (codec, soc_ac97_ops,0 ); + ret =snd_soc_new_ac97_codec (codec);if (ret <0 ) goto codec_err;
sound/soc/codecs/wm9705.c +1 -1
@@ -337,7 +337,7 @@ static int wm9705_soc_probe(struct snd_soc_codec *codec) {int ret =0 ; - ret =snd_soc_new_ac97_codec (codec, soc_ac97_ops,0 ); + ret =snd_soc_new_ac97_codec (codec);if (ret <0 ) {dev_err (codec->dev,"Failed to register AC97 codec\n" );return ret;
sound/soc/codecs/wm9712.c +1 -1
@@ -666,7 +666,7 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec) {int ret =0 ; - ret =snd_soc_new_ac97_codec (codec, soc_ac97_ops,0 ); + ret =snd_soc_new_ac97_codec (codec);if (ret <0 ) {dev_err (codec->dev,"Failed to register AC97 codec\n" );return ret;
sound/soc/codecs/wm9713.c +1 -1
@@ -1219,7 +1219,7 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec) {int ret =0 , reg; - ret =snd_soc_new_ac97_codec (codec, soc_ac97_ops,0 ); + ret =snd_soc_new_ac97_codec (codec);if (ret <0 )return ret;
sound/soc/soc-ac97.c +8 -14
@@ -38,6 +38,10 @@ struct snd_ac97_reset_cfg {int gpio_reset; }; +static struct snd_ac97_bus soc_ac97_bus = { + .ops =NULL ,/* Gets initialized in snd_soc_set_ac97_ops() */ +}; +/* unregister ac97 codec */ static int soc_ac97_dev_unregister (struct snd_soc_codec *codec) {
@@ -140,27 +144,17 @@ static void soc_ac97_device_release(struct device *dev)/** * snd_soc_new_ac97_codec - initailise AC97 device * @codec: audio codec -* @ops: AC97 bus operations -* @num: AC97 codec number * * Initialises AC97 codec resources for use by ad-hoc devices only. */ -int snd_soc_new_ac97_codec (struct snd_soc_codec *codec, -struct snd_ac97_bus_ops *ops,int num) +int snd_soc_new_ac97_codec (struct snd_soc_codec *codec) { codec->ac97 =kzalloc (sizeof (struct snd_ac97 ),GFP_KERNEL );if (codec->ac97 ==NULL )return -ENOMEM ; - codec->ac97->bus =kzalloc (sizeof (struct snd_ac97_bus ),GFP_KERNEL ); -if (codec->ac97->bus ==NULL ) { -kfree (codec->ac97); - codec->ac97 =NULL ; -return -ENOMEM ; - } - - codec->ac97->bus->ops = ops; - codec->ac97->num = num; + codec->ac97->bus = &soc_ac97_bus; + codec->ac97->num =0 ; codec->ac97->dev.release = soc_ac97_device_release;/*
@@ -183,7 +177,6 @@ EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec);void snd_soc_free_ac97_codec (struct snd_soc_codec *codec) {soc_unregister_ac97_codec (codec); -kfree (codec->ac97->bus); codec->ac97->bus =NULL ;put_device (&codec->ac97->dev); codec->ac97 =NULL ;
@@ -314,6 +307,7 @@ int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops)return -EBUSY ; soc_ac97_ops = ops; + soc_ac97_bus.ops = ops;return 0 ; }
Signature · 1 line
1.8.0
Lars-Peter Clausen
maintainerPATCH 6/11 ASoC: ac97: Merge soc_ac97_dev_{un, }register()/soc_{un, }register_ac97_codec()
In reply to Lars-Peter Clausensoc_{un,}register_ac97_codec() is just a simple wrapper around soc_ac97_dev_{un,}register(). There is no need to split these up into two different sets of functions.
--- sound/soc/soc-ac97.c | 80 ++++++++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 50 deletions(-)
sound/soc/soc-ac97.c +30 -50
@@ -42,18 +42,28 @@ static struct snd_ac97_bus soc_ac97_bus = { .ops = NULL, /* Gets initialized in snd_soc_set_ac97_ops() */ }; -/* unregister ac97 codec */ -static int soc_ac97_dev_unregister (struct snd_soc_codec *codec) -{ -if (codec->ac97->dev.bus) -device_del (&codec->ac97->dev); -return 0 ; -} -/* register ac97 codec to bus */ -static int soc_ac97_dev_register (struct snd_soc_codec *codec) +static int soc_register_ac97_codec (struct snd_soc_codec *codec, +struct snd_soc_dai *codec_dai) { -int err; +int ret; + +/* Only instantiate AC97 if not already done by the adaptor +* for the generic AC97 subsystem. +*/ +if (!codec_dai->driver->ac97_control || codec->ac97_registered) +return 0 ; + +/* +* It is possible that the AC97 device is already registered to +* the device subsystem. This happens when the device is created +* via snd_ac97_mixer(). Currently only SoC codec that does so +* is the generic AC97 glue but others migh emerge. +* +* In those cases we don't try to register the device again. +*/ +if (!codec->ac97_created) +return 0 ; codec->ac97->dev.bus = &ac97_bus_type; codec->ac97->dev.parent = codec->component.card->dev;
@@ -61,53 +71,23 @@ static int soc_ac97_dev_register(struct snd_soc_codec *codec)dev_set_name (&codec->ac97->dev,"%d-%d:%s" , codec->component.card->snd_card->number,0 , codec->component.name); - err =device_add (&codec->ac97->dev); -if (err <0 ) { -dev_err (codec->dev,"ASoC: Can't register ac97 bus\n" ); - codec->ac97->dev.bus =NULL ; -return err; + ret =device_add (&codec->ac97->dev); +if (ret <0 ) { +dev_err (codec->dev,"ASoC: AC97 device register failed: %d\n" , + ret); +return ret; } -return 0 ; -} - -static int soc_register_ac97_codec (struct snd_soc_codec *codec, -struct snd_soc_dai *codec_dai) -{ -int ret; + codec->ac97_registered =1 ; -/* Only instantiate AC97 if not already done by the adaptor -* for the generic AC97 subsystem. -*/ -if (codec_dai->driver->ac97_control && !codec->ac97_registered) { -/* -* It is possible that the AC97 device is already registered to -* the device subsystem. This happens when the device is created -* via snd_ac97_mixer(). Currently only SoC codec that does so -* is the generic AC97 glue but others migh emerge. -* -* In those cases we don't try to register the device again. -*/ -if (!codec->ac97_created) -return 0 ; - - ret =soc_ac97_dev_register (codec); -if (ret <0 ) { -dev_err (codec->dev, -"ASoC: AC97 device register failed: %d\n" , ret); -return ret; - } - - codec->ac97_registered =1 ; - }return 0 ; }static void soc_unregister_ac97_codec (struct snd_soc_codec *codec) { -if (codec->ac97_registered) { -soc_ac97_dev_unregister (codec); - codec->ac97_registered =0 ; - } +if (!codec->ac97_registered) +return ; +device_del (&codec->ac97->dev); + codec->ac97_registered =0 ; }static int soc_register_ac97_dai_link (struct snd_soc_pcm_runtime *rtd)
Signature · 1 line
1.8.0
Lars-Peter Clausen
maintainerPATCH 7/11 ASoC: ac97: Drop support for setting platform data via the CPU DAI
In reply to Lars-Peter ClausenThis has no users since commit f0fba2ad1b6b ("ASoC: multi-component - ASoC Multi-Component Support") which was almost 5 years ago. Given that this runs after CODEC probe functions have been run it also doesn't seem to be that useful.
So drop it altogether to make the code simpler.
--- include/sound/soc-dai.h | 1 - include/sound/soc.h | 3 --- sound/soc/soc-ac97.c | 12 ------------ sound/soc/soc-core.c | 2 -- 4 files changed, 18 deletions(-)
include/sound/soc-dai.h +0 -1
@@ -241,7 +241,6 @@ struct snd_soc_dai {const char *name;int id;struct device *dev; -void *ac97_pdata;/* platform_data for the ac97 codec */ /* driver ops */ struct snd_soc_dai_driver *driver;
include/sound/soc.h +0 -3
@@ -508,7 +508,6 @@ int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,extern struct snd_ac97_bus_ops *soc_ac97_ops;int snd_soc_ac97_register_dai_links (struct snd_soc_card *card); -void snd_soc_ac97_add_pdata (struct snd_soc_pcm_runtime *rtd);#else static inline int snd_soc_ac97_register_dai_links (struct snd_soc_card *card)
@@ -516,8 +515,6 @@ static inline int snd_soc_ac97_register_dai_links(struct snd_soc_card *card)return 0 ; } -static inline void snd_soc_ac97_add_pdata (struct snd_soc_pcm_runtime *rtd) {} -static inline int snd_soc_set_ac97_ops_of_reset (struct snd_ac97_bus_ops *ops,struct platform_device *pdev) {
sound/soc/soc-ac97.c +0 -12
@@ -342,15 +342,3 @@ err:soc_unregister_ac97_dai_link (&card->rtd[i]);return ret; } - -void snd_soc_ac97_add_pdata (struct snd_soc_pcm_runtime *rtd) -{ -unsigned int i; - -/* add platform data for AC97 devices */ -for (i =0 ; i < rtd->num_codecs; i++) { -if (rtd->codec_dais[i]->driver->ac97_control) -snd_ac97_dev_add_pdata (rtd->codec_dais[i]->codec->ac97, - rtd->cpu_dai->ac97_pdata); - } -}
sound/soc/soc-core.c +0 -2
@@ -1340,8 +1340,6 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) } } -snd_soc_ac97_add_pdata (rtd); -return 0 ; }
Signature · 1 line
1.8.0
Lars-Peter Clausen
maintainerPATCH 8/11 ASoC: ac97: Drop delayed device registration
In reply to Lars-Peter ClausenWe have all the information and dependencies we need to initialize and register the device available in snd_soc_new_ac97_codec(). So there is no need to delay the device registration until after the card itself as been registered.
This makes the code significantly simpler and also makes it possible to use the AC'97 device in the CODECs probe function. The later will be required to be able to convert the AC'97 CODEC drivers to regmap.
--- include/sound/soc.h | 10 ----- sound/soc/soc-ac97.c | 118 ++++++--------------------------------------------- sound/soc/soc-core.c | 4 -- 3 files changed, 14 insertions(+), 118 deletions(-)
include/sound/soc.h +0 -10
@@ -506,15 +506,7 @@ int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops, struct platform_device *pdev);extern struct snd_ac97_bus_ops *soc_ac97_ops; - -int snd_soc_ac97_register_dai_links (struct snd_soc_card *card);#else - -static inline int snd_soc_ac97_register_dai_links (struct snd_soc_card *card) -{ -return 0 ; -} -static inline int snd_soc_set_ac97_ops_of_reset (struct snd_ac97_bus_ops *ops,struct platform_device *pdev) {
@@ -801,8 +793,6 @@ struct snd_soc_codec {struct snd_ac97 *ac97;/* for ad-hoc ac97 devices */ unsigned int cache_bypass:1; /* Suppress access to the cache */ unsigned int suspended:1; /* Codec is in suspend PM state */ - unsigned int ac97_registered:1; /* Codec has been AC97 registered */ - unsigned int ac97_created:1; /* Codec has been created by SoC */ unsigned int cache_init:1; /* codec cache has been initialized *//* codec IO */
sound/soc/soc-ac97.c +14 -104
151 lines not on this page · raw message
sound/soc/soc-core.c +0 -4
@@ -1636,10 +1636,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) goto probe_aux_dev_err; } - ret =snd_soc_ac97_register_dai_links (card); -if (ret <0 ) - goto probe_aux_dev_err; - card->instantiated =1 ;snd_soc_dapm_sync (&card->dapm);mutex_unlock (&card->mutex);
Signature · 1 line
1.8.0
Lars-Peter Clausen
maintainerPATCH 9/11 ASoC: Drop ac97_control initialization from CODEC driver DAIs
In reply to Lars-Peter ClausenThis is no longer necessary as there is no code anymore that uses this for CODEC DAIs.
--- sound/soc/codecs/ac97.c | 1 - sound/soc/codecs/ad1980.c | 1 - sound/soc/codecs/stac9766.c | 2 -- sound/soc/codecs/wm9705.c | 1 - sound/soc/codecs/wm9712.c | 1 - sound/soc/codecs/wm9713.c | 1 - 6 files changed, 7 deletions(-)
sound/soc/codecs/ac97.c +0 -1
@@ -53,7 +53,6 @@ static const struct snd_soc_dai_ops ac97_dai_ops = {static struct snd_soc_dai_driver ac97_dai = { .name ="ac97-hifi" , - .ac97_control =1 , .playback = { .stream_name ="AC97 Playback" , .channels_min =1 ,
sound/soc/codecs/ad1980.c +0 -1
@@ -170,7 +170,6 @@ static int ac97_write(struct snd_soc_codec *codec, unsigned int reg,static struct snd_soc_dai_driver ad1980_dai = { .name ="ad1980-hifi" , - .ac97_control =1 , .playback = { .stream_name ="Playback" , .channels_min =2 ,
sound/soc/codecs/stac9766.c +0 -2
@@ -287,7 +287,6 @@ static const struct snd_soc_dai_ops stac9766_dai_ops_digital = {static struct snd_soc_dai_driver stac9766_dai[] = { { .name ="stac9766-hifi-analog" , - .ac97_control =1 ,/* stream cababilities */ .playback = {
@@ -309,7 +308,6 @@ static struct snd_soc_dai_driver stac9766_dai[] = { }, { .name = "stac9766-hifi-IEC958", - .ac97_control = 1, /* stream cababilities */ .playback = {
sound/soc/codecs/wm9705.c +0 -1
@@ -263,7 +263,6 @@ static const struct snd_soc_dai_ops wm9705_dai_ops = {static struct snd_soc_dai_driver wm9705_dai[] = { { .name ="wm9705-hifi" , - .ac97_control =1 , .playback = { .stream_name ="HiFi Playback" , .channels_min =1 ,
sound/soc/codecs/wm9712.c +0 -1
@@ -565,7 +565,6 @@ static const struct snd_soc_dai_ops wm9712_dai_ops_aux = {static struct snd_soc_dai_driver wm9712_dai[] = { { .name ="wm9712-hifi" , - .ac97_control =1 , .playback = { .stream_name ="HiFi Playback" , .channels_min =1 ,
sound/soc/codecs/wm9713.c +0 -1
@@ -1076,7 +1076,6 @@ static const struct snd_soc_dai_ops wm9713_dai_ops_voice = {static struct snd_soc_dai_driver wm9713_dai[] = { { .name ="wm9713-hifi" , - .ac97_control =1 , .playback = { .stream_name ="HiFi Playback" , .channels_min =1 ,
Signature · 1 line
1.8.0
Lars-Peter Clausen
maintainerPATCH 10/11 ASoC: Rename snd_soc_dai_driver struct ac97_control field to bus_control
In reply to Lars-Peter ClausenSetting the ac97_control field on a CPU DAI tells the ASoC core that this DAI in addition to audio data also transports control data to the CODEC. This causes the core to suspend the DAI after the CODEC and resume it before the CODEC so communication to the CODEC is still possible. This is not necessarily something that is specific to AC'97 and can be used by other buses with the same requirement. This patch renames the flag from ac97_control to bus_control to make this explicit.
While we are at it also change the type from int to bool.
The following semantich patch was used for automatic conversion of the drivers:
// <smpl>
@@
identifier drv;
@@
struct snd_soc_dai_driver drv = {
- .ac97_control
+ .bus_control
=
- 1
+ true
};
// </smpl>
--- include/sound/soc-dai.h | 3 ++- sound/soc/au1x/ac97c.c | 2 +- sound/soc/au1x/psc-ac97.c | 2 +- sound/soc/blackfin/bf5xx-ac97.c | 2 +- sound/soc/cirrus/ep93xx-ac97.c | 2 +- sound/soc/fsl/fsl_ssi.c | 2 +- sound/soc/fsl/imx-ssi.c | 2 +- sound/soc/fsl/mpc5200_psc_ac97.c | 4 ++-- sound/soc/nuc900/nuc900-ac97.c | 2 +- sound/soc/pxa/pxa2xx-ac97.c | 6 +++--- sound/soc/samsung/ac97.c | 4 ++-- sound/soc/sh/hac.c | 2 +- sound/soc/soc-core.c | 26 ++++++++++++++------------ sound/soc/tegra/tegra20_ac97.c | 2 +- sound/soc/txx9/txx9aclc-ac97.c | 2 +- 15 files changed, 33 insertions(+), 30 deletions(-)
include/sound/soc-dai.h +2 -1
@@ -206,7 +206,6 @@ struct snd_soc_dai_driver {/* DAI description */ const char *name;unsigned int id; -int ac97_control;unsigned int base;/* DAI driver callbacks */
@@ -216,6 +215,8 @@ struct snd_soc_dai_driver {int (*resume)(struct snd_soc_dai *dai);/* compress dai */ bool compress_dai; +/* DAI is also used for the control bus */ +bool bus_control;/* ops */ const struct snd_soc_dai_ops *ops;
sound/soc/au1x/ac97c.c +1 -1
@@ -205,7 +205,7 @@ static int au1xac97c_dai_probe(struct snd_soc_dai *dai)static struct snd_soc_dai_driver au1xac97c_dai_driver = { .name ="alchemy-ac97c" , - .ac97_control =1 , + .bus_control = true, .probe = au1xac97c_dai_probe, .playback = { .rates =AC97_RATES ,
sound/soc/au1x/psc-ac97.c +1 -1
@@ -343,7 +343,7 @@ static const struct snd_soc_dai_ops au1xpsc_ac97_dai_ops = { };static const struct snd_soc_dai_driver au1xpsc_ac97_dai_template = { - .ac97_control =1 , + .bus_control = true, .probe = au1xpsc_ac97_probe, .playback = { .rates =AC97_RATES ,
sound/soc/blackfin/bf5xx-ac97.c +1 -1
@@ -260,7 +260,7 @@ static int bf5xx_ac97_resume(struct snd_soc_dai *dai)#endif static struct snd_soc_dai_driver bfin_ac97_dai = { - .ac97_control =1 , + .bus_control = true, .suspend = bf5xx_ac97_suspend, .resume = bf5xx_ac97_resume, .playback = {
sound/soc/cirrus/ep93xx-ac97.c +1 -1
@@ -338,7 +338,7 @@ static const struct snd_soc_dai_ops ep93xx_ac97_dai_ops = {static struct snd_soc_dai_driver ep93xx_ac97_dai = { .name ="ep93xx-ac97" , .id =0 , - .ac97_control =1 , + .bus_control = true, .probe = ep93xx_ac97_dai_probe, .playback = { .stream_name ="AC97 Playback" ,
sound/soc/fsl/fsl_ssi.c +1 -1
@@ -1099,7 +1099,7 @@ static const struct snd_soc_component_driver fsl_ssi_component = { };static struct snd_soc_dai_driver fsl_ssi_ac97_dai = { - .ac97_control =1 , + .bus_control = true, .playback = { .stream_name ="AC97 Playback" , .channels_min =2 ,
sound/soc/fsl/imx-ssi.c +1 -1
@@ -382,7 +382,7 @@ static struct snd_soc_dai_driver imx_ssi_dai = {static struct snd_soc_dai_driver imx_ac97_dai = { .probe = imx_ssi_dai_probe, - .ac97_control =1 , + .bus_control = true, .playback = { .stream_name ="AC97 Playback" , .channels_min =2 ,
sound/soc/fsl/mpc5200_psc_ac97.c +2 -2
@@ -237,7 +237,7 @@ static const struct snd_soc_dai_ops psc_ac97_digital_ops = {static struct snd_soc_dai_driver psc_ac97_dai[] = { { .name ="mpc5200-psc-ac97.0" , - .ac97_control =1 , + .bus_control = true, .probe = psc_ac97_probe, .playback = { .stream_name ="AC97 Playback" ,
@@ -257,7 +257,7 @@ static struct snd_soc_dai_driver psc_ac97_dai[] = { }, { .name = "mpc5200-psc-ac97.1", - .ac97_control = 1, + .bus_control = true, .playback = { .stream_name = "AC97 SPDIF", .channels_min = 1,
sound/soc/nuc900/nuc900-ac97.c +1 -1
@@ -298,7 +298,7 @@ static const struct snd_soc_dai_ops nuc900_ac97_dai_ops = {static struct snd_soc_dai_driver nuc900_ac97_dai = { .probe = nuc900_ac97_probe, .remove = nuc900_ac97_remove, - .ac97_control =1 , + .bus_control = true, .playback = { .rates =SNDRV_PCM_RATE_8000_48000 , .formats =SNDRV_PCM_FMTBIT_S16_LE ,
sound/soc/pxa/pxa2xx-ac97.c +3 -3
@@ -157,7 +157,7 @@ static const struct snd_soc_dai_ops pxa_ac97_mic_dai_ops = {static struct snd_soc_dai_driver pxa_ac97_dai_driver[] = { { .name ="pxa2xx-ac97" , - .ac97_control =1 , + .bus_control = true, .playback = { .stream_name ="AC97 Playback" , .channels_min =2 ,
@@ -174,7 +174,7 @@ static struct snd_soc_dai_driver pxa_ac97_dai_driver[] = { }, { .name = "pxa2xx-ac97-aux", - .ac97_control = 1, + .bus_control = true, .playback = { .stream_name = "AC97 Aux Playback", .channels_min = 1,
@@ -191,7 +191,7 @@ static struct snd_soc_dai_driver pxa_ac97_dai_driver[] = { }, { .name = "pxa2xx-ac97-mic", - .ac97_control = 1, + .bus_control = true, .capture = { .stream_name = "AC97 Mic Capture", .channels_min = 1,
sound/soc/samsung/ac97.c +2 -2
@@ -288,7 +288,7 @@ static int s3c_ac97_mic_dai_probe(struct snd_soc_dai *dai)static struct snd_soc_dai_driver s3c_ac97_dai[] = { [S3C_AC97_DAI_PCM ] = { .name ="samsung-ac97" , - .ac97_control =1 , + .bus_control = true, .playback = { .stream_name ="AC97 Playback" , .channels_min =2 ,
@@ -306,7 +306,7 @@ static struct snd_soc_dai_driver s3c_ac97_dai[] = { }, [S3C_AC97_DAI_MIC] = { .name = "samsung-ac97-mic", - .ac97_control = 1, + .bus_control = true, .capture = { .stream_name = "AC97 Mic Capture", .channels_min = 1,
sound/soc/sh/hac.c +1 -1
@@ -272,7 +272,7 @@ static const struct snd_soc_dai_ops hac_dai_ops = {static struct snd_soc_dai_driver sh4_hac_dai[] = { { .name ="hac-dai.0" , - .ac97_control =1 , + .bus_control = true, .playback = { .rates =AC97_RATES , .formats =AC97_FMTS ,
sound/soc/soc-core.c +14 -12
@@ -546,7 +546,7 @@ int snd_soc_suspend(struct device *dev)if (card->rtd[i].dai_link->ignore_suspend)continue ; -if (cpu_dai->driver->suspend && !cpu_dai->driver->ac97_control) +if (cpu_dai->driver->suspend && !cpu_dai->driver->bus_control) cpu_dai->driver->suspend (cpu_dai); }
@@ -620,7 +620,7 @@ int snd_soc_suspend(struct device *dev)if (card->rtd[i].dai_link->ignore_suspend)continue ; -if (cpu_dai->driver->suspend && cpu_dai->driver->ac97_control) +if (cpu_dai->driver->suspend && cpu_dai->driver->bus_control) cpu_dai->driver->suspend (cpu_dai);/* deactivate pins to sleep state */
@@ -656,14 +656,14 @@ static void soc_resume_deferred(struct work_struct *work)if (card->resume_pre) card->resume_pre (card); -/* resume AC97 DAIs */ +/* resume control bus DAIs */ for (i =0 ; i < card->num_rtd; i++) {struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;if (card->rtd[i].dai_link->ignore_suspend)continue ; -if (cpu_dai->driver->resume && cpu_dai->driver->ac97_control) +if (cpu_dai->driver->resume && cpu_dai->driver->bus_control) cpu_dai->driver->resume (cpu_dai); }
@@ -723,7 +723,7 @@ static void soc_resume_deferred(struct work_struct *work)if (card->rtd[i].dai_link->ignore_suspend)continue ; -if (cpu_dai->driver->resume && !cpu_dai->driver->ac97_control) +if (cpu_dai->driver->resume && !cpu_dai->driver->bus_control) cpu_dai->driver->resume (cpu_dai); }
@@ -744,7 +744,8 @@ static void soc_resume_deferred(struct work_struct *work)int snd_soc_resume (struct device *dev) {struct snd_soc_card *card =dev_get_drvdata (dev); -int i, ac97_control =0 ; +bool bus_control = false; +int i;/* If the card is not initialized yet there is nothing to do */ if (!card->instantiated)
@@ -767,17 +768,18 @@ int snd_soc_resume(struct device *dev) } } -/* AC97 devices might have other drivers hanging off them so -* need to resume immediately. Other drivers don't have that -* problem and may take a substantial amount of time to resume +/* +* DAIs that also act as the control bus master might have other drivers +* hanging off them so need to resume immediately. Other drivers don't +* have that problem and may take a substantial amount of time to resume * due to I/O costs and anti-pop so handle them out of line. */ for (i =0 ; i < card->num_rtd; i++) {struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; - ac97_control |= cpu_dai->driver->ac97_control; + bus_control |= cpu_dai->driver->bus_control; } -if (ac97_control) { -dev_dbg (dev,"ASoC: Resuming AC97 immediately\n" ); +if (bus_control) { +dev_dbg (dev,"ASoC: Resuming control bus master immediately\n" );soc_resume_deferred (&card->deferred_resume_work); }else {dev_dbg (dev,"ASoC: Scheduling resume work\n" );
sound/soc/tegra/tegra20_ac97.c +1 -1
@@ -228,7 +228,7 @@ static int tegra20_ac97_probe(struct snd_soc_dai *dai)static struct snd_soc_dai_driver tegra20_ac97_dai = { .name ="tegra-ac97-pcm" , - .ac97_control =1 , + .bus_control = true, .probe = tegra20_ac97_probe, .playback = { .stream_name ="PCM Playback" ,
sound/soc/txx9/txx9aclc-ac97.c +1 -1
@@ -152,7 +152,7 @@ static int txx9aclc_ac97_remove(struct snd_soc_dai *dai) }static struct snd_soc_dai_driver txx9aclc_ac97_dai = { - .ac97_control =1 , + .bus_control = true, .probe = txx9aclc_ac97_probe, .remove = txx9aclc_ac97_remove, .playback = {
Signature · 1 line
1.8.0
Lars-Peter Clausen
maintainerPATCH 11/11 ASoC: ac97: Push snd_ac97 pointer to the driver level
In reply to Lars-Peter ClausenNow that the ASoC core no longer needs a handle to the AC'97 device that is associated with a CODEC we can remove it from the snd_soc_codec struct and push it into the individual driver state structs like we do for other communication buses. Doing so creates a clean separation between the AC'97 bus support and the ASoC core.
--- include/sound/soc.h | 5 ++--- sound/soc/codecs/ac97.c | 17 +++++++++++++---- sound/soc/codecs/ad1980.c | 27 ++++++++++++++++++--------- sound/soc/codecs/stac9766.c | 38 ++++++++++++++++++++++++-------------- sound/soc/codecs/wm9705.c | 31 ++++++++++++++++++++++--------- sound/soc/codecs/wm9712.c | 32 +++++++++++++++++++++----------- sound/soc/codecs/wm9713.c | 31 ++++++++++++++++++++----------- sound/soc/soc-ac97.c | 40 +++++++++++++++++++++------------------- 8 files changed, 141 insertions(+), 80 deletions(-)
include/sound/soc.h +2 -3
@@ -498,8 +498,8 @@ int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg, unsigned int mask, unsigned int value);#ifdef CONFIG_SND_SOC_AC97_BUS -int snd_soc_new_ac97_codec (struct snd_soc_codec *codec); -void snd_soc_free_ac97_codec (struct snd_soc_codec *codec); +struct snd_ac97 *snd_soc_new_ac97_codec (struct snd_soc_codec *codec); +void snd_soc_free_ac97_codec (struct snd_ac97 *ac97);int snd_soc_set_ac97_ops (struct snd_ac97_bus_ops *ops); int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
@@ -790,7 +790,6 @@ struct snd_soc_codec {struct list_head card_list;/* runtime */ -struct snd_ac97 *ac97;/* for ad-hoc ac97 devices */ unsigned int cache_bypass:1; /* Suppress access to the cache */ unsigned int suspended:1; /* Codec is in suspend PM state */ unsigned int cache_init:1; /* codec cache has been initialized */
sound/soc/codecs/ac97.c +13 -4
@@ -37,10 +37,11 @@ static int ac97_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) {struct snd_soc_codec *codec = dai->codec; +struct snd_ac97 *ac97 =snd_soc_codec_get_drvdata (codec);int reg = (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) ?AC97_PCM_FRONT_DAC_RATE :AC97_PCM_LR_ADC_RATE ; -return snd_ac97_set_rate (codec->ac97, reg, substream->runtime->rate); +return snd_ac97_set_rate (ac97, reg, substream->runtime->rate); }#define STD_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
@@ -70,6 +71,7 @@ static struct snd_soc_dai_driver ac97_dai = {static int ac97_soc_probe (struct snd_soc_codec *codec) { +struct snd_ac97 *ac97;struct snd_ac97_bus *ac97_bus;struct snd_ac97_template ac97_template;int ret;
@@ -81,24 +83,31 @@ static int ac97_soc_probe(struct snd_soc_codec *codec)return ret;memset (&ac97_template,0 ,sizeof (struct snd_ac97_template )); - ret =snd_ac97_mixer (ac97_bus, &ac97_template, &codec->ac97); + ret =snd_ac97_mixer (ac97_bus, &ac97_template, &ac97);if (ret <0 )return ret; +snd_soc_codec_set_drvdata (codec, ac97); +return 0 ; }#ifdef CONFIG_PM static int ac97_soc_suspend (struct snd_soc_codec *codec) { -snd_ac97_suspend (codec->ac97); +struct snd_ac97 *ac97 =snd_soc_codec_get_drvdata (codec); + +snd_ac97_suspend (ac97);return 0 ; }static int ac97_soc_resume (struct snd_soc_codec *codec) { -snd_ac97_resume (codec->ac97); + +struct snd_ac97 *ac97 =snd_soc_codec_get_drvdata (codec); + +snd_ac97_resume (ac97);return 0 ; }
sound/soc/codecs/ad1980.c +18 -9
@@ -135,6 +135,7 @@ static const struct snd_soc_dapm_route ad1980_dapm_routes[] = {static unsigned int ac97_read (struct snd_soc_codec *codec,unsigned int reg) { +struct snd_ac97 *ac97 =snd_soc_codec_get_drvdata (codec);u16 *cache = codec->reg_cache;switch (reg) {
@@ -144,7 +145,7 @@ static unsigned int ac97_read(struct snd_soc_codec *codec,case AC97_EXTENDED_STATUS :case AC97_VENDOR_ID1 :case AC97_VENDOR_ID2 : -return soc_ac97_ops->read (codec->ac97, reg); +return soc_ac97_ops->read (ac97, reg);default : reg = reg >>1 ;
@@ -158,9 +159,10 @@ static unsigned int ac97_read(struct snd_soc_codec *codec,static int ac97_write (struct snd_soc_codec *codec,unsigned int reg,unsigned int val) { +struct snd_ac97 *ac97 =snd_soc_codec_get_drvdata (codec);u16 *cache = codec->reg_cache; - soc_ac97_ops->write (codec->ac97, reg, val); + soc_ac97_ops->write (ac97, reg, val); reg = reg >>1 ;if (reg <ARRAY_SIZE (ad1980_reg)) cache[reg] = val;
@@ -186,16 +188,17 @@ static struct snd_soc_dai_driver ad1980_dai = {static int ad1980_reset (struct snd_soc_codec *codec,int try_warm) { +struct snd_ac97 *ac97 =snd_soc_codec_get_drvdata (codec);unsigned int retry_cnt =0 ; do { if (try_warm && soc_ac97_ops->warm_reset) { - soc_ac97_ops->warm_reset(codec->ac97); + soc_ac97_ops->warm_reset(ac97); if (ac97_read(codec, AC97_RESET) == 0x0090) return 1; } - soc_ac97_ops->reset(codec->ac97); + soc_ac97_ops->reset(ac97); /* * Set bit 16slot in register 74h, then every slot will has only * 16 bits. This command is sent out in 20bit mode, in which
@@ -215,16 +218,20 @@ static int ad1980_reset(struct snd_soc_codec *codec, int try_warm)static int ad1980_soc_probe (struct snd_soc_codec *codec) { +struct snd_ac97 *ac97;int ret;u16 vendor_id2;u16 ext_status; - ret =snd_soc_new_ac97_codec (codec); -if (ret <0 ) { -dev_err (codec->dev,"Failed to register AC97 codec\n" ); + ac97 =snd_soc_new_ac97_codec (codec); +if (IS_ERR (ac97)) { + ret =PTR_ERR (ac97); +dev_err (codec->dev,"Failed to register AC97 codec: %d\n" , ret);return ret; } +snd_soc_codec_set_drvdata (codec, ac97); + ret =ad1980_reset (codec,0 );if (ret <0 ) goto reset_err;
@@ -261,13 +268,15 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec)return 0 ; reset_err: -snd_soc_free_ac97_codec (codec); +snd_soc_free_ac97_codec (ac97);return ret; }static int ad1980_soc_remove (struct snd_soc_codec *codec) { -snd_soc_free_ac97_codec (codec); +struct snd_ac97 *ac97 =snd_soc_codec_get_drvdata (codec); + +snd_soc_free_ac97_codec (ac97);return 0 ; }
sound/soc/codecs/stac9766.c +24 -14
@@ -139,18 +139,19 @@ static const struct snd_kcontrol_new stac9766_snd_ac97_controls[] = {static int stac9766_ac97_write (struct snd_soc_codec *codec,unsigned int reg,unsigned int val) { +struct snd_ac97 *ac97 =snd_soc_codec_get_drvdata (codec);u16 *cache = codec->reg_cache;if (reg >AC97_STAC_PAGE0 ) {stac9766_ac97_write (codec,AC97_INT_PAGING ,0 ); - soc_ac97_ops->write (codec->ac97, reg, val); + soc_ac97_ops->write (ac97, reg, val);stac9766_ac97_write (codec,AC97_INT_PAGING ,1 );return 0 ; }if (reg /2 >=ARRAY_SIZE (stac9766_reg))return -EIO ; - soc_ac97_ops->write (codec->ac97, reg, val); + soc_ac97_ops->write (ac97, reg, val); cache[reg /2 ] = val;return 0 ; }
@@ -158,11 +159,12 @@ static int stac9766_ac97_write(struct snd_soc_codec *codec, unsigned int reg,static unsigned int stac9766_ac97_read (struct snd_soc_codec *codec,unsigned int reg) { +struct snd_ac97 *ac97 =snd_soc_codec_get_drvdata (codec);u16 val =0 , *cache = codec->reg_cache;if (reg >AC97_STAC_PAGE0 ) {stac9766_ac97_write (codec,AC97_INT_PAGING ,0 ); - val = soc_ac97_ops->read (codec->ac97, reg -AC97_STAC_PAGE0 ); + val = soc_ac97_ops->read (ac97, reg -AC97_STAC_PAGE0 );stac9766_ac97_write (codec,AC97_INT_PAGING ,1 );return val; }
@@ -173,7 +175,7 @@ static unsigned int stac9766_ac97_read(struct snd_soc_codec *codec, reg == AC97_INT_PAGING || reg == AC97_VENDOR_ID1 || reg == AC97_VENDOR_ID2) { - val = soc_ac97_ops->read (codec->ac97, reg); + val = soc_ac97_ops->read (ac97, reg);return val; }return cache[reg /2 ];
@@ -240,15 +242,17 @@ static int stac9766_set_bias_level(struct snd_soc_codec *codec,static int stac9766_reset (struct snd_soc_codec *codec,int try_warm) { +struct snd_ac97 *ac97 =snd_soc_codec_get_drvdata (codec); +if (try_warm && soc_ac97_ops->warm_reset) { - soc_ac97_ops->warm_reset (codec->ac97); + soc_ac97_ops->warm_reset (ac97);if (stac9766_ac97_read (codec,0 ) == stac9766_reg[0 ])return 1 ; } - soc_ac97_ops->reset (codec->ac97); + soc_ac97_ops->reset (ac97);if (soc_ac97_ops->warm_reset) - soc_ac97_ops->warm_reset (codec->ac97); + soc_ac97_ops->warm_reset (ac97);if (stac9766_ac97_read (codec,0 ) != stac9766_reg[0 ])return -EIO ;return 0 ;
@@ -256,6 +260,7 @@ static int stac9766_reset(struct snd_soc_codec *codec, int try_warm)static int stac9766_codec_resume (struct snd_soc_codec *codec) { +struct snd_ac97 *ac97 =snd_soc_codec_get_drvdata (codec);u16 id, reset; reset =0 ;
@@ -265,8 +270,8 @@ reset:dev_err (codec->dev,"Failed to resume\n" );return -EIO ; } - codec->ac97->bus->ops->warm_reset (codec->ac97); - id = soc_ac97_ops->read (codec->ac97,AC97_VENDOR_ID2 ); + ac97->bus->ops->warm_reset (ac97); + id = soc_ac97_ops->read (ac97,AC97_VENDOR_ID2 );if (id !=0x4c13 ) {stac9766_reset (codec,0 ); reset++;
@@ -325,11 +330,14 @@ static struct snd_soc_dai_driver stac9766_dai[] = {static int stac9766_codec_probe (struct snd_soc_codec *codec) { +struct snd_ac97 *ac97;int ret =0 ; - ret =snd_soc_new_ac97_codec (codec); -if (ret <0 ) - goto codec_err; + ac97 =snd_soc_new_ac97_codec (codec); +if (IS_ERR (ac97)) +return PTR_ERR (ac97); + +snd_soc_codec_set_drvdata (codec, ac97);/* do a cold reset for the controller and then try * a warm reset followed by an optional cold reset for codec */
@@ -343,13 +351,15 @@ static int stac9766_codec_probe(struct snd_soc_codec *codec)return 0 ; codec_err: -snd_soc_free_ac97_codec (codec); +snd_soc_free_ac97_codec (ac97);return ret; }static int stac9766_codec_remove (struct snd_soc_codec *codec) { -snd_soc_free_ac97_codec (codec); +struct snd_ac97 *ac97 =snd_soc_codec_get_drvdata (codec); + +snd_soc_free_ac97_codec (ac97);return 0 ; }
sound/soc/codecs/wm9705.c +22 -9
@@ -203,13 +203,14 @@ static const struct snd_soc_dapm_route wm9705_audio_map[] = {/* We use a register cache to enhance read performance. */ static unsigned int ac97_read (struct snd_soc_codec *codec,unsigned int reg) { +struct snd_ac97 *ac97 =snd_soc_codec_get_drvdata (codec);u16 *cache = codec->reg_cache;switch (reg) {case AC97_RESET :case AC97_VENDOR_ID1 :case AC97_VENDOR_ID2 : -return soc_ac97_ops->read (codec->ac97, reg); +return soc_ac97_ops->read (ac97, reg);default : reg = reg >>1 ;
@@ -223,9 +224,10 @@ static unsigned int ac97_read(struct snd_soc_codec *codec, unsigned int reg)static int ac97_write (struct snd_soc_codec *codec,unsigned int reg,unsigned int val) { +struct snd_ac97 *ac97 =snd_soc_codec_get_drvdata (codec);u16 *cache = codec->reg_cache; - soc_ac97_ops->write (codec->ac97, reg, val); + soc_ac97_ops->write (ac97, reg, val); reg = reg >>1 ;if (reg < (ARRAY_SIZE (wm9705_reg))) cache[reg] = val;
@@ -293,8 +295,10 @@ static struct snd_soc_dai_driver wm9705_dai[] = {static int wm9705_reset (struct snd_soc_codec *codec) { +struct snd_ac97 *ac97 =snd_soc_codec_get_drvdata (codec); +if (soc_ac97_ops->reset) { - soc_ac97_ops->reset (codec->ac97); + soc_ac97_ops->reset (ac97);if (ac97_read (codec,0 ) == wm9705_reg[0 ])return 0 ;/* Success */ }
@@ -307,13 +311,16 @@ static int wm9705_reset(struct snd_soc_codec *codec)#ifdef CONFIG_PM static int wm9705_soc_suspend (struct snd_soc_codec *codec) { - soc_ac97_ops->write (codec->ac97,AC97_POWERDOWN ,0xffff ); +struct snd_ac97 *ac97 =snd_soc_codec_get_drvdata (codec); + + soc_ac97_ops->write (ac97,AC97_POWERDOWN ,0xffff );return 0 ; }static int wm9705_soc_resume (struct snd_soc_codec *codec) { +struct snd_ac97 *ac97 =snd_soc_codec_get_drvdata (codec);int i, ret;u16 *cache = codec->reg_cache;
@@ -322,7 +329,7 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec)return ret;for (i =2 ; i <ARRAY_SIZE (wm9705_reg) <<1 ; i +=2 ) { - soc_ac97_ops->write (codec->ac97, i, cache[i>>1 ]); + soc_ac97_ops->write (ac97, i, cache[i>>1 ]); }return 0 ;
@@ -334,14 +341,18 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec)static int wm9705_soc_probe (struct snd_soc_codec *codec) { +struct snd_ac97 *ac97;int ret =0 ; - ret =snd_soc_new_ac97_codec (codec); -if (ret <0 ) { + ac97 =snd_soc_new_ac97_codec (codec); +if (IS_ERR (ac97)) { + ret =PTR_ERR (ac97);dev_err (codec->dev,"Failed to register AC97 codec\n" );return ret; } +snd_soc_codec_set_drvdata (codec, ac97); + ret =wm9705_reset (codec);if (ret) goto reset_err;
@@ -349,13 +360,15 @@ static int wm9705_soc_probe(struct snd_soc_codec *codec)return 0 ; reset_err: -snd_soc_free_ac97_codec (codec); +snd_soc_free_ac97_codec (ac97);return ret; }static int wm9705_soc_remove (struct snd_soc_codec *codec) { -snd_soc_free_ac97_codec (codec); +struct snd_ac97 *ac97 =snd_soc_codec_get_drvdata (codec); + +snd_soc_free_ac97_codec (ac97);return 0 ; }
sound/soc/codecs/wm9712.c +21 -11
@@ -24,6 +24,7 @@#include "wm9712.h" struct wm9712_priv { +struct snd_ac97 *ac97;unsigned int hp_mixer[2 ];struct mutex lock; };
@@ -484,12 +485,13 @@ static const struct snd_soc_dapm_route wm9712_audio_map[] = {static unsigned int ac97_read (struct snd_soc_codec *codec,unsigned int reg) { +struct wm9712_priv *wm9712 =snd_soc_codec_get_drvdata (codec);u16 *cache = codec->reg_cache;if (reg ==AC97_RESET || reg ==AC97_GPIO_STATUS || reg ==AC97_VENDOR_ID1 || reg ==AC97_VENDOR_ID2 || reg ==AC97_REC_GAIN ) -return soc_ac97_ops->read (codec->ac97, reg); +return soc_ac97_ops->read (wm9712->ac97, reg);else { reg = reg >>1 ;
@@ -503,9 +505,10 @@ static unsigned int ac97_read(struct snd_soc_codec *codec,static int ac97_write (struct snd_soc_codec *codec,unsigned int reg,unsigned int val) { +struct wm9712_priv *wm9712 =snd_soc_codec_get_drvdata (codec);u16 *cache = codec->reg_cache; - soc_ac97_ops->write (codec->ac97, reg, val); + soc_ac97_ops->write (wm9712->ac97, reg, val); reg = reg >>1 ;if (reg < (ARRAY_SIZE (wm9712_reg))) cache[reg] = val;
@@ -613,15 +616,17 @@ static int wm9712_set_bias_level(struct snd_soc_codec *codec,static int wm9712_reset (struct snd_soc_codec *codec,int try_warm) { +struct wm9712_priv *wm9712 =snd_soc_codec_get_drvdata (codec); +if (try_warm && soc_ac97_ops->warm_reset) { - soc_ac97_ops->warm_reset (codec->ac97); + soc_ac97_ops->warm_reset (wm9712->ac97);if (ac97_read (codec,0 ) == wm9712_reg[0 ])return 1 ; } - soc_ac97_ops->reset (codec->ac97); + soc_ac97_ops->reset (wm9712->ac97);if (soc_ac97_ops->warm_reset) - soc_ac97_ops->warm_reset (codec->ac97); + soc_ac97_ops->warm_reset (wm9712->ac97);if (ac97_read (codec,0 ) != wm9712_reg[0 ]) goto err;return 0 ;
@@ -639,6 +644,7 @@ static int wm9712_soc_suspend(struct snd_soc_codec *codec)static int wm9712_soc_resume (struct snd_soc_codec *codec) { +struct wm9712_priv *wm9712 =snd_soc_codec_get_drvdata (codec);int i, ret;u16 *cache = codec->reg_cache;
@@ -654,7 +660,7 @@ static int wm9712_soc_resume(struct snd_soc_codec *codec)if (i ==AC97_INT_PAGING || i ==AC97_POWERDOWN || (i >0x58 && i !=0x5c ))continue ; - soc_ac97_ops->write (codec->ac97, i, cache[i>>1 ]); + soc_ac97_ops->write (wm9712->ac97, i, cache[i>>1 ]); } }
@@ -663,11 +669,13 @@ static int wm9712_soc_resume(struct snd_soc_codec *codec)static int wm9712_soc_probe (struct snd_soc_codec *codec) { +struct wm9712_priv *wm9712 =snd_soc_codec_get_drvdata (codec);int ret =0 ; - ret =snd_soc_new_ac97_codec (codec); -if (ret <0 ) { -dev_err (codec->dev,"Failed to register AC97 codec\n" ); + wm9712->ac97 =snd_soc_new_ac97_codec (codec); +if (IS_ERR (wm9712->ac97)) { + ret =PTR_ERR (wm9712->ac97); +dev_err (codec->dev,"Failed to register AC97 codec: %d\n" , ret);return ret; }
@@ -683,13 +691,15 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec)return 0 ; reset_err: -snd_soc_free_ac97_codec (codec); +snd_soc_free_ac97_codec (wm9712->ac97);return ret; }static int wm9712_soc_remove (struct snd_soc_codec *codec) { -snd_soc_free_ac97_codec (codec); +struct wm9712_priv *wm9712 =snd_soc_codec_get_drvdata (codec); + +snd_soc_free_ac97_codec (wm9712->ac97);return 0 ; }
sound/soc/codecs/wm9713.c +20 -11
@@ -30,6 +30,7 @@#include "wm9713.h" struct wm9713_priv { +struct snd_ac97 *ac97;u32 pll_in;/* PLL input frequency */ unsigned int hp_mixer[2 ];struct mutex lock;
@@ -674,12 +675,13 @@ static const struct snd_soc_dapm_route wm9713_audio_map[] = {static unsigned int ac97_read (struct snd_soc_codec *codec,unsigned int reg) { +struct wm9713_priv *wm9713 =snd_soc_codec_get_drvdata (codec);u16 *cache = codec->reg_cache;if (reg ==AC97_RESET || reg ==AC97_GPIO_STATUS || reg ==AC97_VENDOR_ID1 || reg ==AC97_VENDOR_ID2 || reg ==AC97_CD ) -return soc_ac97_ops->read (codec->ac97, reg); +return soc_ac97_ops->read (wm9713->ac97, reg);else { reg = reg >>1 ;
@@ -693,8 +695,10 @@ static unsigned int ac97_read(struct snd_soc_codec *codec,static int ac97_write (struct snd_soc_codec *codec,unsigned int reg,unsigned int val) { +struct wm9713_priv *wm9713 =snd_soc_codec_get_drvdata (codec); +u16 *cache = codec->reg_cache; - soc_ac97_ops->write (codec->ac97, reg, val); + soc_ac97_ops->write (wm9713->ac97, reg, val); reg = reg >>1 ;if (reg < (ARRAY_SIZE (wm9713_reg))) cache[reg] = val;
@@ -1121,15 +1125,17 @@ static struct snd_soc_dai_driver wm9713_dai[] = {int wm9713_reset (struct snd_soc_codec *codec,int try_warm) { +struct wm9713_priv *wm9713 =snd_soc_codec_get_drvdata (codec); +if (try_warm && soc_ac97_ops->warm_reset) { - soc_ac97_ops->warm_reset (codec->ac97); + soc_ac97_ops->warm_reset (wm9713->ac97);if (ac97_read (codec,0 ) == wm9713_reg[0 ])return 1 ; } - soc_ac97_ops->reset (codec->ac97); + soc_ac97_ops->reset (wm9713->ac97);if (soc_ac97_ops->warm_reset) - soc_ac97_ops->warm_reset (codec->ac97); + soc_ac97_ops->warm_reset (wm9713->ac97);if (ac97_read (codec,0 ) != wm9713_reg[0 ]) {dev_err (codec->dev,"Failed to reset: AC97 link error\n" );return -EIO ;
@@ -1207,7 +1213,7 @@ static int wm9713_soc_resume(struct snd_soc_codec *codec)if (i ==AC97_POWERDOWN || i ==AC97_EXTENDED_MID || i ==AC97_EXTENDED_MSTATUS || i >0x66 )continue ; - soc_ac97_ops->write (codec->ac97, i, cache[i>>1 ]); + soc_ac97_ops->write (wm9713->ac97, i, cache[i>>1 ]); } }
@@ -1216,11 +1222,12 @@ static int wm9713_soc_resume(struct snd_soc_codec *codec)static int wm9713_soc_probe (struct snd_soc_codec *codec) { +struct wm9713_priv *wm9713 =snd_soc_codec_get_drvdata (codec);int ret =0 , reg; - ret =snd_soc_new_ac97_codec (codec); -if (ret <0 ) -return ret; + wm9713->ac97 =snd_soc_new_ac97_codec (codec); +if (IS_ERR (wm9713->ac97)) +return PTR_ERR (wm9713->ac97);/* do a cold reset for the controller and then try * a warm reset followed by an optional cold reset for codec */
@@ -1238,13 +1245,15 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec)return 0 ; reset_err: -snd_soc_free_ac97_codec (codec); +snd_soc_free_ac97_codec (wm9713->ac97);return ret; }static int wm9713_soc_remove (struct snd_soc_codec *codec) { -snd_soc_free_ac97_codec (codec); +struct wm9713_priv *wm9713 =snd_soc_codec_get_drvdata (codec); + +snd_soc_free_ac97_codec (wm9713->ac97);return 0 ; }
sound/soc/soc-ac97.c +21 -19
@@ -53,30 +53,33 @@ static void soc_ac97_device_release(struct device *dev)* * Initialises AC97 codec resources for use by ad-hoc devices only. */ -int snd_soc_new_ac97_codec (struct snd_soc_codec *codec) +struct snd_ac97 *snd_soc_new_ac97_codec (struct snd_soc_codec *codec) { +struct snd_ac97 *ac97;int ret; - codec->ac97 =kzalloc (sizeof (struct snd_ac97 ),GFP_KERNEL ); -if (codec->ac97 ==NULL ) -return -ENOMEM ; + ac97 =kzalloc (sizeof (struct snd_ac97 ),GFP_KERNEL ); +if (ac97 ==NULL ) +return ERR_PTR (-ENOMEM ); - codec->ac97->bus = &soc_ac97_bus; - codec->ac97->num =0 ; + ac97->bus = &soc_ac97_bus; + ac97->num =0 ; - codec->ac97->dev.bus = &ac97_bus_type; - codec->ac97->dev.parent = codec->component.card->dev; - codec->ac97->dev.release = soc_ac97_device_release; + ac97->dev.bus = &ac97_bus_type; + ac97->dev.parent = codec->component.card->dev; + ac97->dev.release = soc_ac97_device_release; -dev_set_name (&codec->ac97->dev,"%d-%d:%s" , +dev_set_name (&ac97->dev,"%d-%d:%s" , codec->component.card->snd_card->number,0 , codec->component.name); - ret =device_register (&codec->ac97->dev); -if (ret) -put_device (&codec->ac97->dev); + ret =device_register (&ac97->dev); +if (ret) { +put_device (&ac97->dev); +return ERR_PTR (ret); + } -return ret; +return ac97; }EXPORT_SYMBOL_GPL (snd_soc_new_ac97_codec);
@@ -86,12 +89,11 @@ EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec);* * Frees AC97 codec device resources. */ -void snd_soc_free_ac97_codec (struct snd_soc_codec *codec) +void snd_soc_free_ac97_codec (struct snd_ac97 *ac97) { -device_del (&codec->ac97->dev); - codec->ac97->bus =NULL ; -put_device (&codec->ac97->dev); - codec->ac97 =NULL ; +device_del (&ac97->dev); + ac97->bus =NULL ; +put_device (&ac97->dev); }EXPORT_SYMBOL_GPL (snd_soc_free_ac97_codec);
Signature · 1 line
1.8.0
Re: [PATCH 11/11] ASoC: ac97: Push snd_ac97 pointer to the driver level
Quoted 8 lines · Lars-Peter Clausen
Now that the ASoC core no longer needs a handle to the AC'97 device that is associated with a CODEC we can remove it from the
snd_soc_codecstruct and push it into the individual driver state structs like we do for other communication buses. Doing so creates a clean separation between the AC'97 bus support and the ASoC core.Signed-off-by Lars-Peter Clausen <[email protected]>---
The Wolfson bits look ok to me:
Thanks,
Charles
Mark Brown
maintainerQuoted 1 line · Lars-Peter Clausen
Depends on asoc/topic/ad1980, asoc/topic/wm9705 and asoc/topic/wm971x
You've generated this against something other than the merge down of those things since git isn't able to find the SHAs it was generated against and apply it automatically with --threeway (so possibly also not -next?). I had to manually resolve a lot of patch applications.
Anyway, that all seemed to work easily so I applied it but you might want to check it all worked out.