···272728281 - Codec DAI and PCM configuration2929-----------------------------------3030-Each codec driver must have a struct snd_soc_codec_dai to define its DAI and3030+Each codec driver must have a struct snd_soc_dai_driver to define its DAI and3131PCM capabilities and operations. This struct is exported so that it can be3232registered with the core by your machine driver.33333434e.g.35353636-struct snd_soc_codec_dai wm8731_dai = {3737- .name = "WM8731",3838- /* playback capabilities */3636+static struct snd_soc_dai_ops wm8731_dai_ops = {3737+ .prepare = wm8731_pcm_prepare,3838+ .hw_params = wm8731_hw_params,3939+ .shutdown = wm8731_shutdown,4040+ .digital_mute = wm8731_mute,4141+ .set_sysclk = wm8731_set_dai_sysclk,4242+ .set_fmt = wm8731_set_dai_fmt,4343+};4444+4545+struct snd_soc_dai_driver wm8731_dai = {4646+ .name = "wm8731-hifi",3947 .playback = {4048 .stream_name = "Playback",4149 .channels_min = 1,4250 .channels_max = 2,4351 .rates = WM8731_RATES,4452 .formats = WM8731_FORMATS,},4545- /* capture capabilities */4653 .capture = {4754 .stream_name = "Capture",4855 .channels_min = 1,4956 .channels_max = 2,5057 .rates = WM8731_RATES,5158 .formats = WM8731_FORMATS,},5252- /* pcm operations - see section 4 below */5353- .ops = {5454- .prepare = wm8731_pcm_prepare,5555- .hw_params = wm8731_hw_params,5656- .shutdown = wm8731_shutdown,5757- },5858- /* DAI operations - see DAI.txt */5959- .dai_ops = {6060- .digital_mute = wm8731_mute,6161- .set_sysclk = wm8731_set_dai_sysclk,6262- .set_fmt = wm8731_set_dai_fmt,6363- }5959+ .ops = &wm8731_dai_ops,6060+ .symmetric_rates = 1,6461};6565-EXPORT_SYMBOL_GPL(wm8731_dai);6662676368642 - Codec control IO···182186183187i.e.184188185185-static int wm8974_mute(struct snd_soc_codec *codec,186186- struct snd_soc_codec_dai *dai, int mute)189189+static int wm8974_mute(struct snd_soc_dai *dai, int mute)187190{188188- u16 mute_reg = wm8974_read_reg_cache(codec, WM8974_DAC) & 0xffbf;189189- if(mute)190190- wm8974_write(codec, WM8974_DAC, mute_reg | 0x40);191191+ struct snd_soc_codec *codec = dai->codec;192192+ u16 mute_reg = snd_soc_read(codec, WM8974_DAC) & 0xffbf;193193+194194+ if (mute)195195+ snd_soc_write(codec, WM8974_DAC, mute_reg | 0x40);191196 else192192- wm8974_write(codec, WM8974_DAC, mute_reg);197197+ snd_soc_write(codec, WM8974_DAC, mute_reg);193198 return 0;194199}
+9-29
Documentation/sound/alsa/soc/machine.txt
···1212struct snd_soc_card {1313 char *name;14141515+ ...1616+1517 int (*probe)(struct platform_device *pdev);1618 int (*remove)(struct platform_device *pdev);1719···2422 int (*resume_pre)(struct platform_device *pdev);2523 int (*resume_post)(struct platform_device *pdev);26242727- /* machine stream operations */2828- struct snd_soc_ops *ops;2525+ ...29263027 /* CPU <--> Codec DAI links */3128 struct snd_soc_dai_link *dai_link;3229 int num_links;3030+3131+ ...3332};34333534probe()/remove()···4340The machine driver has pre and post versions of suspend and resume to take care4441of any machine audio tasks that have to be done before or after the codec, DAIs4542and DMA is suspended and resumed. Optional.4646-4747-4848-Machine operations4949-------------------5050-The machine specific audio operations can be set here. Again this is optional.514352445345Machine DAI Configuration···5961static struct snd_soc_dai_link corgi_dai = {6062 .name = "WM8731",6163 .stream_name = "WM8731",6262- .cpu_dai = &pxa_i2s_dai,6363- .codec_dai = &wm8731_dai,6464+ .cpu_dai_name = "pxa-is2-dai",6565+ .codec_dai_name = "wm8731-hifi",6666+ .platform_name = "pxa-pcm-audio",6767+ .codec_name = "wm8713-codec.0-001a",6468 .init = corgi_wm8731_init,6569 .ops = &corgi_ops,6670};···7474 .name = "Corgi",7575 .dai_link = &corgi_dai,7676 .num_links = 1,7777-};7878-7979-8080-Machine Audio Subsystem8181------------------------8282-8383-The machine soc device glues the platform, machine and codec driver together.8484-Private data can also be set here. e.g.8585-8686-/* corgi audio private data */8787-static struct wm8731_setup_data corgi_wm8731_setup = {8888- .i2c_address = 0x1b,8989-};9090-9191-/* corgi audio subsystem */9292-static struct snd_soc_device corgi_snd_devdata = {9393- .machine = &snd_soc_corgi,9494- .platform = &pxa2xx_soc_platform,9595- .codec_dev = &soc_codec_dev_wm8731,9696- .codec_data = &corgi_wm8731_setup,9777};98789979
+10-2
Documentation/sound/alsa/soc/platform.txt
···2020 int (*trigger)(struct snd_pcm_substream *, int);2121};22222323-The platform driver exports its DMA functionality via struct snd_soc_platform:-2323+The platform driver exports its DMA functionality via struct2424+snd_soc_platform_driver:-24252525-struct snd_soc_platform {2626+struct snd_soc_platform_driver {2627 char *name;27282829 int (*probe)(struct platform_device *pdev);···3433 /* pcm creation and destruction */3534 int (*pcm_new)(struct snd_card *, struct snd_soc_codec_dai *, struct snd_pcm *);3635 void (*pcm_free)(struct snd_pcm *);3636+3737+ /*3838+ * For platform caused delay reporting.3939+ * Optional.4040+ */4141+ snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *,4242+ struct snd_soc_dai *);37433844 /* platform stream ops */3945 struct snd_pcm_ops *pcm_ops;
+6-5
sound/soc/blackfin/Kconfig
···11config SND_BF5XX_I2S22 tristate "SoC I2S Audio for the ADI BF5xx chip"33 depends on BLACKFIN44+ select SND_BF5XX_SOC_SPORT45 help56 Say Y or M if you want to add support for codecs attached to67 the Blackfin SPORT (synchronous serial ports) interface in I2S···3635config SND_BF5XX_TDM3736 tristate "SoC I2S(TDM mode) Audio for the ADI BF5xx chip"3837 depends on (BLACKFIN && SND_SOC)3838+ select SND_BF5XX_SOC_SPORT3939 help4040 Say Y or M if you want to add support for codecs attached to4141 the Blackfin SPORT (synchronous serial ports) interface in TDM···6361config SND_BF5XX_AC976462 tristate "SoC AC97 Audio for the ADI BF5xx chip"6563 depends on BLACKFIN6464+ select AC97_BUS6565+ select SND_SOC_AC97_BUS6666+ select SND_BF5XX_SOC_SPORT6767+ select SND_BF5XX_SOC_AC976668 help6769 Say Y or M if you want to add support for codecs attached to6870 the Blackfin SPORT (synchronous serial ports) interface in slot 16···128122129123config SND_BF5XX_SOC_I2S130124 tristate131131- select SND_BF5XX_SOC_SPORT132125133126config SND_BF5XX_SOC_TDM134127 tristate135135- select SND_BF5XX_SOC_SPORT136128137129config SND_BF5XX_SOC_AC97138130 tristate139139- select AC97_BUS140140- select SND_SOC_AC97_BUS141141- select SND_BF5XX_SOC_SPORT142131143132config SND_BF5XX_SPORT_NUM144133 int "Set a SPORT for Sound chip"
+2-2
sound/soc/blackfin/bf5xx-ac97.c
···260260 pr_debug("%s : sport %d\n", __func__, dai->id);261261 if (!dai->active)262262 return 0;263263- if (dai->capture.active)263263+ if (dai->capture_active)264264 sport_rx_stop(sport);265265- if (dai->playback.active)265265+ if (dai->playback_active)266266 sport_tx_stop(sport);267267 return 0;268268}
+5-5
sound/soc/blackfin/bf5xx-tdm.c
···210210#ifdef CONFIG_PM211211static int bf5xx_tdm_suspend(struct snd_soc_dai *dai)212212{213213- struct sport_device *sport = dai->private_data;213213+ struct sport_device *sport = snd_soc_dai_get_drvdata(dai);214214215215 if (!dai->active)216216 return 0;···235235 ret = -EBUSY;236236 }237237238238- ret = sport_config_rx(sport, IRFS, 0x1F, 0, 0);238238+ ret = sport_config_rx(sport, 0, 0x1F, 0, 0);239239 if (ret) {240240 pr_err("SPORT is busy!\n");241241 ret = -EBUSY;242242 }243243244244- ret = sport_config_tx(sport, ITFS, 0x1F, 0, 0);244244+ ret = sport_config_tx(sport, 0, 0x1F, 0, 0);245245 if (ret) {246246 pr_err("SPORT is busy!\n");247247 ret = -EBUSY;···303303 goto sport_config_err;304304 }305305306306- ret = sport_config_rx(sport_handle, IRFS, 0x1F, 0, 0);306306+ ret = sport_config_rx(sport_handle, 0, 0x1F, 0, 0);307307 if (ret) {308308 pr_err("SPORT is busy!\n");309309 ret = -EBUSY;310310 goto sport_config_err;311311 }312312313313- ret = sport_config_tx(sport_handle, ITFS, 0x1F, 0, 0);313313+ ret = sport_config_tx(sport_handle, 0, 0x1F, 0, 0);314314 if (ret) {315315 pr_err("SPORT is busy!\n");316316 ret = -EBUSY;