aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiam Girdwood <lg@opensource.wolfsonmicro.com>2008-07-07 11:07:17 -0400
committerJaroslav Kysela <perex@perex.cz>2008-07-10 03:32:32 -0400
commit3c4b266fe642bcaebe2b95edb56c3f8802924ff9 (patch)
tree837a5e7d8e77702bcca5a02fbcaed51c3fa52065
parenta5302181e5321664047f75715242aac4e0bbd17c (diff)
ALSA: asoc: core - merge structs snd_soc_codec_dai and snd_soc_cpu_dai.
This patch series merges struct snd_soc_codec_dai and struct snd_soc_cpu_dai into struct snd_soc_dai in preparation for further ASoC v2 patches. This merger removes duplication in both DAI structures and simplifies the API for other users. Signed-off-by: Liam Girdwood <lg@opensource.wolfsonmicro.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r--include/sound/soc.h71
-rw-r--r--sound/soc/soc-core.c50
2 files changed, 48 insertions, 73 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 340223a8f24c..778e57e74dc8 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -221,8 +221,7 @@ struct snd_soc_pcm_stream;
221struct snd_soc_ops; 221struct snd_soc_ops;
222struct snd_soc_dai_mode; 222struct snd_soc_dai_mode;
223struct snd_soc_pcm_runtime; 223struct snd_soc_pcm_runtime;
224struct snd_soc_codec_dai; 224struct snd_soc_dai;
225struct snd_soc_cpu_dai;
226struct snd_soc_codec; 225struct snd_soc_codec;
227struct snd_soc_machine_config; 226struct snd_soc_machine_config;
228struct soc_enum; 227struct soc_enum;
@@ -317,50 +316,24 @@ struct snd_soc_ops {
317/* ASoC DAI ops */ 316/* ASoC DAI ops */
318struct snd_soc_dai_ops { 317struct snd_soc_dai_ops {
319 /* DAI clocking configuration */ 318 /* DAI clocking configuration */
320 int (*set_sysclk)(struct snd_soc_codec_dai *codec_dai, 319 int (*set_sysclk)(struct snd_soc_dai *dai,
321 int clk_id, unsigned int freq, int dir); 320 int clk_id, unsigned int freq, int dir);
322 int (*set_pll)(struct snd_soc_codec_dai *codec_dai, 321 int (*set_pll)(struct snd_soc_dai *dai,
323 int pll_id, unsigned int freq_in, unsigned int freq_out); 322 int pll_id, unsigned int freq_in, unsigned int freq_out);
324 int (*set_clkdiv)(struct snd_soc_codec_dai *codec_dai, 323 int (*set_clkdiv)(struct snd_soc_dai *dai, int div_id, int div);
325 int div_id, int div);
326 324
327 /* DAI format configuration */ 325 /* DAI format configuration */
328 int (*set_fmt)(struct snd_soc_codec_dai *codec_dai, 326 int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt);
329 unsigned int fmt); 327 int (*set_tdm_slot)(struct snd_soc_dai *dai,
330 int (*set_tdm_slot)(struct snd_soc_codec_dai *codec_dai,
331 unsigned int mask, int slots); 328 unsigned int mask, int slots);
332 int (*set_tristate)(struct snd_soc_codec_dai *, int tristate); 329 int (*set_tristate)(struct snd_soc_dai *dai, int tristate);
333 330
334 /* digital mute */ 331 /* digital mute */
335 int (*digital_mute)(struct snd_soc_codec_dai *, int mute); 332 int (*digital_mute)(struct snd_soc_dai *dai, int mute);
336}; 333};
337 334
338/* SoC Codec DAI */ 335/* SoC DAI (Digital Audio Interface) */
339struct snd_soc_codec_dai { 336struct snd_soc_dai {
340 char *name;
341 int id;
342 unsigned char type;
343
344 /* DAI capabilities */
345 struct snd_soc_pcm_stream playback;
346 struct snd_soc_pcm_stream capture;
347
348 /* DAI runtime info */
349 struct snd_soc_codec *codec;
350 unsigned int active;
351 unsigned char pop_wait:1;
352
353 /* ops */
354 struct snd_soc_ops ops;
355 struct snd_soc_dai_ops dai_ops;
356
357 /* DAI private data */
358 void *private_data;
359};
360
361/* SoC CPU DAI */
362struct snd_soc_cpu_dai {
363
364 /* DAI description */ 337 /* DAI description */
365 char *name; 338 char *name;
366 unsigned int id; 339 unsigned int id;
@@ -368,13 +341,13 @@ struct snd_soc_cpu_dai {
368 341
369 /* DAI callbacks */ 342 /* DAI callbacks */
370 int (*probe)(struct platform_device *pdev, 343 int (*probe)(struct platform_device *pdev,
371 struct snd_soc_cpu_dai *dai); 344 struct snd_soc_dai *dai);
372 void (*remove)(struct platform_device *pdev, 345 void (*remove)(struct platform_device *pdev,
373 struct snd_soc_cpu_dai *dai); 346 struct snd_soc_dai *dai);
374 int (*suspend)(struct platform_device *pdev, 347 int (*suspend)(struct platform_device *pdev,
375 struct snd_soc_cpu_dai *cpu_dai); 348 struct snd_soc_dai *dai);
376 int (*resume)(struct platform_device *pdev, 349 int (*resume)(struct platform_device *pdev,
377 struct snd_soc_cpu_dai *cpu_dai); 350 struct snd_soc_dai *dai);
378 351
379 /* ops */ 352 /* ops */
380 struct snd_soc_ops ops; 353 struct snd_soc_ops ops;
@@ -386,7 +359,9 @@ struct snd_soc_cpu_dai {
386 359
387 /* DAI runtime info */ 360 /* DAI runtime info */
388 struct snd_pcm_runtime *runtime; 361 struct snd_pcm_runtime *runtime;
389 unsigned char active:1; 362 struct snd_soc_codec *codec;
363 unsigned int active;
364 unsigned char pop_wait:1;
390 void *dma_data; 365 void *dma_data;
391 366
392 /* DAI private data */ 367 /* DAI private data */
@@ -428,7 +403,7 @@ struct snd_soc_codec {
428 struct delayed_work delayed_work; 403 struct delayed_work delayed_work;
429 404
430 /* codec DAI's */ 405 /* codec DAI's */
431 struct snd_soc_codec_dai *dai; 406 struct snd_soc_dai *dai;
432 unsigned int num_dai; 407 unsigned int num_dai;
433}; 408};
434 409
@@ -447,12 +422,12 @@ struct snd_soc_platform {
447 int (*probe)(struct platform_device *pdev); 422 int (*probe)(struct platform_device *pdev);
448 int (*remove)(struct platform_device *pdev); 423 int (*remove)(struct platform_device *pdev);
449 int (*suspend)(struct platform_device *pdev, 424 int (*suspend)(struct platform_device *pdev,
450 struct snd_soc_cpu_dai *cpu_dai); 425 struct snd_soc_dai *dai);
451 int (*resume)(struct platform_device *pdev, 426 int (*resume)(struct platform_device *pdev,
452 struct snd_soc_cpu_dai *cpu_dai); 427 struct snd_soc_dai *dai);
453 428
454 /* pcm creation and destruction */ 429 /* pcm creation and destruction */
455 int (*pcm_new)(struct snd_card *, struct snd_soc_codec_dai *, 430 int (*pcm_new)(struct snd_card *, struct snd_soc_dai *,
456 struct snd_pcm *); 431 struct snd_pcm *);
457 void (*pcm_free)(struct snd_pcm *); 432 void (*pcm_free)(struct snd_pcm *);
458 433
@@ -466,8 +441,8 @@ struct snd_soc_dai_link {
466 char *stream_name; /* Stream name */ 441 char *stream_name; /* Stream name */
467 442
468 /* DAI */ 443 /* DAI */
469 struct snd_soc_codec_dai *codec_dai; 444 struct snd_soc_dai *codec_dai;
470 struct snd_soc_cpu_dai *cpu_dai; 445 struct snd_soc_dai *cpu_dai;
471 446
472 /* machine stream operations */ 447 /* machine stream operations */
473 struct snd_soc_ops *ops; 448 struct snd_soc_ops *ops;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index bdbbc6a980fa..4d626b47b2ff 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -134,8 +134,8 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
134 struct snd_pcm_runtime *runtime = substream->runtime; 134 struct snd_pcm_runtime *runtime = substream->runtime;
135 struct snd_soc_dai_link *machine = rtd->dai; 135 struct snd_soc_dai_link *machine = rtd->dai;
136 struct snd_soc_platform *platform = socdev->platform; 136 struct snd_soc_platform *platform = socdev->platform;
137 struct snd_soc_cpu_dai *cpu_dai = machine->cpu_dai; 137 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
138 struct snd_soc_codec_dai *codec_dai = machine->codec_dai; 138 struct snd_soc_dai *codec_dai = machine->codec_dai;
139 int ret = 0; 139 int ret = 0;
140 140
141 mutex_lock(&pcm_mutex); 141 mutex_lock(&pcm_mutex);
@@ -272,7 +272,7 @@ static void close_delayed_work(struct work_struct *work)
272 struct snd_soc_device *socdev = 272 struct snd_soc_device *socdev =
273 container_of(work, struct snd_soc_device, delayed_work.work); 273 container_of(work, struct snd_soc_device, delayed_work.work);
274 struct snd_soc_codec *codec = socdev->codec; 274 struct snd_soc_codec *codec = socdev->codec;
275 struct snd_soc_codec_dai *codec_dai; 275 struct snd_soc_dai *codec_dai;
276 int i; 276 int i;
277 277
278 mutex_lock(&pcm_mutex); 278 mutex_lock(&pcm_mutex);
@@ -323,8 +323,8 @@ static int soc_codec_close(struct snd_pcm_substream *substream)
323 struct snd_soc_device *socdev = rtd->socdev; 323 struct snd_soc_device *socdev = rtd->socdev;
324 struct snd_soc_dai_link *machine = rtd->dai; 324 struct snd_soc_dai_link *machine = rtd->dai;
325 struct snd_soc_platform *platform = socdev->platform; 325 struct snd_soc_platform *platform = socdev->platform;
326 struct snd_soc_cpu_dai *cpu_dai = machine->cpu_dai; 326 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
327 struct snd_soc_codec_dai *codec_dai = machine->codec_dai; 327 struct snd_soc_dai *codec_dai = machine->codec_dai;
328 struct snd_soc_codec *codec = socdev->codec; 328 struct snd_soc_codec *codec = socdev->codec;
329 329
330 mutex_lock(&pcm_mutex); 330 mutex_lock(&pcm_mutex);
@@ -384,8 +384,8 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
384 struct snd_soc_device *socdev = rtd->socdev; 384 struct snd_soc_device *socdev = rtd->socdev;
385 struct snd_soc_dai_link *machine = rtd->dai; 385 struct snd_soc_dai_link *machine = rtd->dai;
386 struct snd_soc_platform *platform = socdev->platform; 386 struct snd_soc_platform *platform = socdev->platform;
387 struct snd_soc_cpu_dai *cpu_dai = machine->cpu_dai; 387 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
388 struct snd_soc_codec_dai *codec_dai = machine->codec_dai; 388 struct snd_soc_dai *codec_dai = machine->codec_dai;
389 struct snd_soc_codec *codec = socdev->codec; 389 struct snd_soc_codec *codec = socdev->codec;
390 int ret = 0; 390 int ret = 0;
391 391
@@ -489,8 +489,8 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
489 struct snd_soc_device *socdev = rtd->socdev; 489 struct snd_soc_device *socdev = rtd->socdev;
490 struct snd_soc_dai_link *machine = rtd->dai; 490 struct snd_soc_dai_link *machine = rtd->dai;
491 struct snd_soc_platform *platform = socdev->platform; 491 struct snd_soc_platform *platform = socdev->platform;
492 struct snd_soc_cpu_dai *cpu_dai = machine->cpu_dai; 492 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
493 struct snd_soc_codec_dai *codec_dai = machine->codec_dai; 493 struct snd_soc_dai *codec_dai = machine->codec_dai;
494 int ret = 0; 494 int ret = 0;
495 495
496 mutex_lock(&pcm_mutex); 496 mutex_lock(&pcm_mutex);
@@ -559,8 +559,8 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
559 struct snd_soc_device *socdev = rtd->socdev; 559 struct snd_soc_device *socdev = rtd->socdev;
560 struct snd_soc_dai_link *machine = rtd->dai; 560 struct snd_soc_dai_link *machine = rtd->dai;
561 struct snd_soc_platform *platform = socdev->platform; 561 struct snd_soc_platform *platform = socdev->platform;
562 struct snd_soc_cpu_dai *cpu_dai = machine->cpu_dai; 562 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
563 struct snd_soc_codec_dai *codec_dai = machine->codec_dai; 563 struct snd_soc_dai *codec_dai = machine->codec_dai;
564 struct snd_soc_codec *codec = socdev->codec; 564 struct snd_soc_codec *codec = socdev->codec;
565 565
566 mutex_lock(&pcm_mutex); 566 mutex_lock(&pcm_mutex);
@@ -594,8 +594,8 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
594 struct snd_soc_device *socdev = rtd->socdev; 594 struct snd_soc_device *socdev = rtd->socdev;
595 struct snd_soc_dai_link *machine = rtd->dai; 595 struct snd_soc_dai_link *machine = rtd->dai;
596 struct snd_soc_platform *platform = socdev->platform; 596 struct snd_soc_platform *platform = socdev->platform;
597 struct snd_soc_cpu_dai *cpu_dai = machine->cpu_dai; 597 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
598 struct snd_soc_codec_dai *codec_dai = machine->codec_dai; 598 struct snd_soc_dai *codec_dai = machine->codec_dai;
599 int ret; 599 int ret;
600 600
601 if (codec_dai->ops.trigger) { 601 if (codec_dai->ops.trigger) {
@@ -651,7 +651,7 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state)
651 651
652 /* mute any active DAC's */ 652 /* mute any active DAC's */
653 for (i = 0; i < machine->num_links; i++) { 653 for (i = 0; i < machine->num_links; i++) {
654 struct snd_soc_codec_dai *dai = machine->dai_link[i].codec_dai; 654 struct snd_soc_dai *dai = machine->dai_link[i].codec_dai;
655 if (dai->dai_ops.digital_mute && dai->playback.active) 655 if (dai->dai_ops.digital_mute && dai->playback.active)
656 dai->dai_ops.digital_mute(dai, 1); 656 dai->dai_ops.digital_mute(dai, 1);
657 } 657 }
@@ -664,7 +664,7 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state)
664 machine->suspend_pre(pdev, state); 664 machine->suspend_pre(pdev, state);
665 665
666 for (i = 0; i < machine->num_links; i++) { 666 for (i = 0; i < machine->num_links; i++) {
667 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; 667 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
668 if (cpu_dai->suspend && cpu_dai->type != SND_SOC_DAI_AC97) 668 if (cpu_dai->suspend && cpu_dai->type != SND_SOC_DAI_AC97)
669 cpu_dai->suspend(pdev, cpu_dai); 669 cpu_dai->suspend(pdev, cpu_dai);
670 if (platform->suspend) 670 if (platform->suspend)
@@ -690,7 +690,7 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state)
690 codec_dev->suspend(pdev, state); 690 codec_dev->suspend(pdev, state);
691 691
692 for (i = 0; i < machine->num_links; i++) { 692 for (i = 0; i < machine->num_links; i++) {
693 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; 693 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
694 if (cpu_dai->suspend && cpu_dai->type == SND_SOC_DAI_AC97) 694 if (cpu_dai->suspend && cpu_dai->type == SND_SOC_DAI_AC97)
695 cpu_dai->suspend(pdev, cpu_dai); 695 cpu_dai->suspend(pdev, cpu_dai);
696 } 696 }
@@ -726,7 +726,7 @@ static void soc_resume_deferred(struct work_struct *work)
726 machine->resume_pre(pdev); 726 machine->resume_pre(pdev);
727 727
728 for (i = 0; i < machine->num_links; i++) { 728 for (i = 0; i < machine->num_links; i++) {
729 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; 729 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
730 if (cpu_dai->resume && cpu_dai->type == SND_SOC_DAI_AC97) 730 if (cpu_dai->resume && cpu_dai->type == SND_SOC_DAI_AC97)
731 cpu_dai->resume(pdev, cpu_dai); 731 cpu_dai->resume(pdev, cpu_dai);
732 } 732 }
@@ -747,13 +747,13 @@ static void soc_resume_deferred(struct work_struct *work)
747 747
748 /* unmute any active DACs */ 748 /* unmute any active DACs */
749 for (i = 0; i < machine->num_links; i++) { 749 for (i = 0; i < machine->num_links; i++) {
750 struct snd_soc_codec_dai *dai = machine->dai_link[i].codec_dai; 750 struct snd_soc_dai *dai = machine->dai_link[i].codec_dai;
751 if (dai->dai_ops.digital_mute && dai->playback.active) 751 if (dai->dai_ops.digital_mute && dai->playback.active)
752 dai->dai_ops.digital_mute(dai, 0); 752 dai->dai_ops.digital_mute(dai, 0);
753 } 753 }
754 754
755 for (i = 0; i < machine->num_links; i++) { 755 for (i = 0; i < machine->num_links; i++) {
756 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; 756 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
757 if (cpu_dai->resume && cpu_dai->type != SND_SOC_DAI_AC97) 757 if (cpu_dai->resume && cpu_dai->type != SND_SOC_DAI_AC97)
758 cpu_dai->resume(pdev, cpu_dai); 758 cpu_dai->resume(pdev, cpu_dai);
759 if (platform->resume) 759 if (platform->resume)
@@ -803,7 +803,7 @@ static int soc_probe(struct platform_device *pdev)
803 } 803 }
804 804
805 for (i = 0; i < machine->num_links; i++) { 805 for (i = 0; i < machine->num_links; i++) {
806 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; 806 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
807 if (cpu_dai->probe) { 807 if (cpu_dai->probe) {
808 ret = cpu_dai->probe(pdev, cpu_dai); 808 ret = cpu_dai->probe(pdev, cpu_dai);
809 if (ret < 0) 809 if (ret < 0)
@@ -838,7 +838,7 @@ platform_err:
838 838
839cpu_dai_err: 839cpu_dai_err:
840 for (i--; i >= 0; i--) { 840 for (i--; i >= 0; i--) {
841 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; 841 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
842 if (cpu_dai->remove) 842 if (cpu_dai->remove)
843 cpu_dai->remove(pdev, cpu_dai); 843 cpu_dai->remove(pdev, cpu_dai);
844 } 844 }
@@ -867,7 +867,7 @@ static int soc_remove(struct platform_device *pdev)
867 codec_dev->remove(pdev); 867 codec_dev->remove(pdev);
868 868
869 for (i = 0; i < machine->num_links; i++) { 869 for (i = 0; i < machine->num_links; i++) {
870 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; 870 struct snd_soc_dai *cpu_dai = machine->dai_link[i].cpu_dai;
871 if (cpu_dai->remove) 871 if (cpu_dai->remove)
872 cpu_dai->remove(pdev, cpu_dai); 872 cpu_dai->remove(pdev, cpu_dai);
873 } 873 }
@@ -895,8 +895,8 @@ static int soc_new_pcm(struct snd_soc_device *socdev,
895 struct snd_soc_dai_link *dai_link, int num) 895 struct snd_soc_dai_link *dai_link, int num)
896{ 896{
897 struct snd_soc_codec *codec = socdev->codec; 897 struct snd_soc_codec *codec = socdev->codec;
898 struct snd_soc_codec_dai *codec_dai = dai_link->codec_dai; 898 struct snd_soc_dai *codec_dai = dai_link->codec_dai;
899 struct snd_soc_cpu_dai *cpu_dai = dai_link->cpu_dai; 899 struct snd_soc_dai *cpu_dai = dai_link->cpu_dai;
900 struct snd_soc_pcm_runtime *rtd; 900 struct snd_soc_pcm_runtime *rtd;
901 struct snd_pcm *pcm; 901 struct snd_pcm *pcm;
902 char new_name[64]; 902 char new_name[64];
@@ -1211,7 +1211,7 @@ void snd_soc_free_pcms(struct snd_soc_device *socdev)
1211{ 1211{
1212 struct snd_soc_codec *codec = socdev->codec; 1212 struct snd_soc_codec *codec = socdev->codec;
1213#ifdef CONFIG_SND_SOC_AC97_BUS 1213#ifdef CONFIG_SND_SOC_AC97_BUS
1214 struct snd_soc_codec_dai *codec_dai; 1214 struct snd_soc_dai *codec_dai;
1215 int i; 1215 int i;
1216#endif 1216#endif
1217 1217