diff options
author | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-03-17 23:15:21 +0300 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-08-12 17:00:00 +0400 |
commit | f0fba2ad1b6b53d5360125c41953b7afcd6deff0 (patch) | |
tree | f6ad50905f8daa616593c978d7ae992e73241180 /sound/soc/codecs/ak4671.c | |
parent | bda7d2a862e6b788bca2d02d38a07966a9c92e48 (diff) | |
download | linux-f0fba2ad1b6b53d5360125c41953b7afcd6deff0.tar.xz |
ASoC: multi-component - ASoC Multi-Component Support
This patch extends the ASoC API to allow sound cards to have more than one
CODEC and more than one platform DMA controller. This is achieved by dividing
some current ASoC structures that contain both driver data and device data into
structures that only either contain device data or driver data. i.e.
struct snd_soc_codec ---> struct snd_soc_codec (device data)
+-> struct snd_soc_codec_driver (driver data)
struct snd_soc_platform ---> struct snd_soc_platform (device data)
+-> struct snd_soc_platform_driver (driver data)
struct snd_soc_dai ---> struct snd_soc_dai (device data)
+-> struct snd_soc_dai_driver (driver data)
struct snd_soc_device ---> deleted
This now allows ASoC to be more tightly aligned with the Linux driver model and
also means that every ASoC codec, platform and (platform) DAI is a kernel
device. ASoC component private data is now stored as device private data.
The ASoC sound card struct snd_soc_card has also been updated to store lists
of it's components rather than a pointer to a codec and platform. The PCM
runtime struct soc_pcm_runtime now has pointers to all its components.
This patch adds DAPM support for ASoC multi-component and removes struct
snd_soc_socdev from DAPM core. All DAPM calls are now made on a card, codec
or runtime PCM level basis rather than using snd_soc_socdev.
Other notable multi-component changes:-
* Stream operations now de-reference less structures.
* close_delayed work() now runs on a DAI basis rather than looping all DAIs
in a card.
* PM suspend()/resume() operations can now handle N CODECs and Platforms
per sound card.
* Added soc_bind_dai_link() to bind the component devices to the sound card.
* Added soc_dai_link_probe() and soc_dai_link_remove() to probe and remove
DAI link components.
* sysfs entries can now be registered per component per card.
* snd_soc_new_pcms() functionailty rolled into dai_link_probe().
* snd_soc_register_codec() now does all the codec list and mutex init.
This patch changes the probe() and remove() of the CODEC drivers as follows:-
o Make CODEC driver a platform driver
o Moved all struct snd_soc_codec list, mutex, etc initialiasation to core.
o Removed all static codec pointers (drivers now support > 1 codec dev)
o snd_soc_register_pcms() now done by core.
o snd_soc_register_dai() folded into snd_soc_register_codec().
CS4270 portions:
Acked-by: Timur Tabi <timur@freescale.com>
Some TLV320aic23 and Cirrus platform fixes.
Signed-off-by: Ryan Mallon <ryan@bluewatersys.com>
TI CODEC and OMAP fixes
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
Samsung platform and misc fixes :-
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Jassi Brar <jassi.brar@samsung.com>
Signed-off-by: Seungwhan Youn <sw.youn@samsung.com>
MPC8610 and PPC fixes.
Signed-off-by: Timur Tabi <timur@freescale.com>
i.MX fixes and some core fixes.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
J4740 platform fixes:-
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
CC: Tony Lindgren <tony@atomide.com>
CC: Nicolas Ferre <nicolas.ferre@atmel.com>
CC: Kevin Hilman <khilman@deeprootsystems.com>
CC: Sascha Hauer <s.hauer@pengutronix.de>
CC: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
CC: Kuninori Morimoto <morimoto.kuninori@renesas.com>
CC: Daniel Gloeckner <dg@emlix.com>
CC: Manuel Lauss <mano@roarinelk.homelinux.net>
CC: Mike Frysinger <vapier.adi@gmail.com>
CC: Arnaud Patard <apatard@mandriva.com>
CC: Wan ZongShun <mcuos.com@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound/soc/codecs/ak4671.c')
-rw-r--r-- | sound/soc/codecs/ak4671.c | 141 |
1 files changed, 30 insertions, 111 deletions
diff --git a/sound/soc/codecs/ak4671.c b/sound/soc/codecs/ak4671.c index 87566932a3b1..239f0562003c 100644 --- a/sound/soc/codecs/ak4671.c +++ b/sound/soc/codecs/ak4671.c @@ -23,11 +23,11 @@ #include "ak4671.h" -static struct snd_soc_codec *ak4671_codec; /* codec private data */ struct ak4671_priv { - struct snd_soc_codec codec; + enum snd_soc_control_type control_type; + void *control_data; u8 reg_cache[AK4671_CACHEREGNUM]; }; @@ -619,8 +619,8 @@ static struct snd_soc_dai_ops ak4671_dai_ops = { .set_fmt = ak4671_set_dai_fmt, }; -struct snd_soc_dai ak4671_dai = { - .name = "AK4671", +static struct snd_soc_dai_driver ak4671_dai = { + .name = "ak4671-hifi", .playback = { .stream_name = "Playback", .channels_min = 1, @@ -635,27 +635,19 @@ struct snd_soc_dai ak4671_dai = { .formats = AK4671_FORMATS,}, .ops = &ak4671_dai_ops, }; -EXPORT_SYMBOL_GPL(ak4671_dai); -static int ak4671_probe(struct platform_device *pdev) +static int ak4671_probe(struct snd_soc_codec *codec) { - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec; - int ret = 0; - - if (ak4671_codec == NULL) { - dev_err(&pdev->dev, "Codec device not registered\n"); - return -ENODEV; - } + struct ak4671_priv *ak4671 = snd_soc_codec_get_drvdata(codec); + int ret; - socdev->card->codec = ak4671_codec; - codec = ak4671_codec; + codec->hw_write = (hw_write_t)i2c_master_send; + codec->bias_level = SND_SOC_BIAS_OFF; - /* register pcms */ - ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); + ret = snd_soc_codec_set_cache_io(codec, 8, 8, ak4671->control_type); if (ret < 0) { - dev_err(codec->dev, "failed to create pcms: %d\n", ret); - goto pcm_err; + dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); + return ret; } snd_soc_add_controls(codec, ak4671_snd_controls, @@ -665,121 +657,48 @@ static int ak4671_probe(struct platform_device *pdev) ak4671_set_bias_level(codec, SND_SOC_BIAS_STANDBY); return ret; - -pcm_err: - return ret; } -static int ak4671_remove(struct platform_device *pdev) +static int ak4671_remove(struct snd_soc_codec *codec) { - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - - snd_soc_free_pcms(socdev); - snd_soc_dapm_free(socdev); - + ak4671_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; } -struct snd_soc_codec_device soc_codec_dev_ak4671 = { +static struct snd_soc_codec_driver soc_codec_dev_ak4671 = { .probe = ak4671_probe, .remove = ak4671_remove, + .set_bias_level = ak4671_set_bias_level, + .reg_cache_size = AK4671_CACHEREGNUM, + .reg_word_size = sizeof(u8), + .reg_cache_default = ak4671_reg, }; -EXPORT_SYMBOL_GPL(soc_codec_dev_ak4671); - -static int ak4671_register(struct ak4671_priv *ak4671, - enum snd_soc_control_type control) -{ - int ret; - struct snd_soc_codec *codec = &ak4671->codec; - - if (ak4671_codec) { - dev_err(codec->dev, "Another AK4671 is registered\n"); - ret = -EINVAL; - goto err; - } - - mutex_init(&codec->mutex); - INIT_LIST_HEAD(&codec->dapm_widgets); - INIT_LIST_HEAD(&codec->dapm_paths); - - snd_soc_codec_set_drvdata(codec, ak4671); - codec->name = "AK4671"; - codec->owner = THIS_MODULE; - codec->bias_level = SND_SOC_BIAS_OFF; - codec->set_bias_level = ak4671_set_bias_level; - codec->dai = &ak4671_dai; - codec->num_dai = 1; - codec->reg_cache_size = AK4671_CACHEREGNUM; - codec->reg_cache = &ak4671->reg_cache; - - memcpy(codec->reg_cache, ak4671_reg, sizeof(ak4671_reg)); - - ret = snd_soc_codec_set_cache_io(codec, 8, 8, control); - if (ret < 0) { - dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); - goto err; - } - - ak4671_dai.dev = codec->dev; - ak4671_codec = codec; - - ret = snd_soc_register_codec(codec); - if (ret != 0) { - dev_err(codec->dev, "Failed to register codec: %d\n", ret); - goto err; - } - - ret = snd_soc_register_dai(&ak4671_dai); - if (ret != 0) { - dev_err(codec->dev, "Failed to register DAI: %d\n", ret); - goto err_codec; - } - - return 0; - -err_codec: - snd_soc_unregister_codec(codec); -err: - kfree(ak4671); - return ret; -} - -static void ak4671_unregister(struct ak4671_priv *ak4671) -{ - ak4671_set_bias_level(&ak4671->codec, SND_SOC_BIAS_OFF); - snd_soc_unregister_dai(&ak4671_dai); - snd_soc_unregister_codec(&ak4671->codec); - kfree(ak4671); - ak4671_codec = NULL; -} static int __devinit ak4671_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct ak4671_priv *ak4671; - struct snd_soc_codec *codec; + int ret; ak4671 = kzalloc(sizeof(struct ak4671_priv), GFP_KERNEL); if (ak4671 == NULL) return -ENOMEM; - codec = &ak4671->codec; - codec->hw_write = (hw_write_t)i2c_master_send; - i2c_set_clientdata(client, ak4671); - codec->control_data = client; - - codec->dev = &client->dev; + ak4671->control_data = client; + ak4671->control_type = SND_SOC_I2C; - return ak4671_register(ak4671, SND_SOC_I2C); + ret = snd_soc_register_codec(&client->dev, + &soc_codec_dev_ak4671, &ak4671_dai, 1); + if (ret < 0) + kfree(ak4671); + return ret; } static __devexit int ak4671_i2c_remove(struct i2c_client *client) { - struct ak4671_priv *ak4671 = i2c_get_clientdata(client); - - ak4671_unregister(ak4671); - + snd_soc_unregister_codec(&client->dev); + kfree(i2c_get_clientdata(client)); return 0; } @@ -791,7 +710,7 @@ MODULE_DEVICE_TABLE(i2c, ak4671_i2c_id); static struct i2c_driver ak4671_i2c_driver = { .driver = { - .name = "ak4671", + .name = "ak4671-codec", .owner = THIS_MODULE, }, .probe = ak4671_i2c_probe, |