soc-dapm.c (50ae8384cde9a67714ff03010493c5052690624e) soc-dapm.c (9949788b793826f2d19e929ac0219ad0e0891e2d)
1/*
2 * soc-dapm.c -- ALSA SoC Dynamic Audio Power Management
3 *
4 * Copyright 2005 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the

--- 416 unchanged lines hidden (view full) ---

425static inline void dapm_clear_walk(struct snd_soc_codec *codec)
426{
427 struct snd_soc_dapm_path *p;
428
429 list_for_each_entry(p, &codec->dapm_paths, list)
430 p->walked = 0;
431}
432
1/*
2 * soc-dapm.c -- ALSA SoC Dynamic Audio Power Management
3 *
4 * Copyright 2005 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the

--- 416 unchanged lines hidden (view full) ---

425static inline void dapm_clear_walk(struct snd_soc_codec *codec)
426{
427 struct snd_soc_dapm_path *p;
428
429 list_for_each_entry(p, &codec->dapm_paths, list)
430 p->walked = 0;
431}
432
433/* We implement power down on suspend by checking the power state of
434 * the ALSA card - when we are suspending the ALSA state for the card
435 * is set to D3.
436 */
437static int snd_soc_dapm_suspend_check(struct snd_soc_dapm_widget *widget)
438{
439 struct snd_soc_codec *codec = widget->codec;
440
441 switch (snd_power_get_state(codec->card)) {
442 case SNDRV_CTL_POWER_D3hot:
443 case SNDRV_CTL_POWER_D3cold:
444 return 0;
445 default:
446 return 1;
447 }
448}
449
433/*
434 * Recursively check for a completed path to an active or physically connected
435 * output widget. Returns number of complete paths.
436 */
437static int is_connected_output_ep(struct snd_soc_dapm_widget *widget)
438{
439 struct snd_soc_dapm_path *path;
440 int con = 0;
441
442 if (widget->id == snd_soc_dapm_supply)
443 return 0;
444
445 switch (widget->id) {
446 case snd_soc_dapm_adc:
447 case snd_soc_dapm_aif_out:
448 if (widget->active)
450/*
451 * Recursively check for a completed path to an active or physically connected
452 * output widget. Returns number of complete paths.
453 */
454static int is_connected_output_ep(struct snd_soc_dapm_widget *widget)
455{
456 struct snd_soc_dapm_path *path;
457 int con = 0;
458
459 if (widget->id == snd_soc_dapm_supply)
460 return 0;
461
462 switch (widget->id) {
463 case snd_soc_dapm_adc:
464 case snd_soc_dapm_aif_out:
465 if (widget->active)
449 return 1;
466 return snd_soc_dapm_suspend_check(widget);
450 default:
451 break;
452 }
453
454 if (widget->connected) {
455 /* connected pin ? */
456 if (widget->id == snd_soc_dapm_output && !widget->ext)
467 default:
468 break;
469 }
470
471 if (widget->connected) {
472 /* connected pin ? */
473 if (widget->id == snd_soc_dapm_output && !widget->ext)
457 return 1;
474 return snd_soc_dapm_suspend_check(widget);
458
459 /* connected jack or spk ? */
460 if (widget->id == snd_soc_dapm_hp || widget->id == snd_soc_dapm_spk ||
461 (widget->id == snd_soc_dapm_line && !list_empty(&widget->sources)))
475
476 /* connected jack or spk ? */
477 if (widget->id == snd_soc_dapm_hp || widget->id == snd_soc_dapm_spk ||
478 (widget->id == snd_soc_dapm_line && !list_empty(&widget->sources)))
462 return 1;
479 return snd_soc_dapm_suspend_check(widget);
463 }
464
465 list_for_each_entry(path, &widget->sinks, list_source) {
466 if (path->walked)
467 continue;
468
469 if (path->sink && path->connect) {
470 path->walked = 1;

--- 16 unchanged lines hidden (view full) ---

487 if (widget->id == snd_soc_dapm_supply)
488 return 0;
489
490 /* active stream ? */
491 switch (widget->id) {
492 case snd_soc_dapm_dac:
493 case snd_soc_dapm_aif_in:
494 if (widget->active)
480 }
481
482 list_for_each_entry(path, &widget->sinks, list_source) {
483 if (path->walked)
484 continue;
485
486 if (path->sink && path->connect) {
487 path->walked = 1;

--- 16 unchanged lines hidden (view full) ---

504 if (widget->id == snd_soc_dapm_supply)
505 return 0;
506
507 /* active stream ? */
508 switch (widget->id) {
509 case snd_soc_dapm_dac:
510 case snd_soc_dapm_aif_in:
511 if (widget->active)
495 return 1;
512 return snd_soc_dapm_suspend_check(widget);
496 default:
497 break;
498 }
499
500 if (widget->connected) {
501 /* connected pin ? */
502 if (widget->id == snd_soc_dapm_input && !widget->ext)
513 default:
514 break;
515 }
516
517 if (widget->connected) {
518 /* connected pin ? */
519 if (widget->id == snd_soc_dapm_input && !widget->ext)
503 return 1;
520 return snd_soc_dapm_suspend_check(widget);
504
505 /* connected VMID/Bias for lower pops */
506 if (widget->id == snd_soc_dapm_vmid)
521
522 /* connected VMID/Bias for lower pops */
523 if (widget->id == snd_soc_dapm_vmid)
507 return 1;
524 return snd_soc_dapm_suspend_check(widget);
508
509 /* connected jack ? */
510 if (widget->id == snd_soc_dapm_mic ||
511 (widget->id == snd_soc_dapm_line && !list_empty(&widget->sinks)))
525
526 /* connected jack ? */
527 if (widget->id == snd_soc_dapm_mic ||
528 (widget->id == snd_soc_dapm_line && !list_empty(&widget->sinks)))
512 return 1;
529 return snd_soc_dapm_suspend_check(widget);
513 }
514
515 list_for_each_entry(path, &widget->sources, list_sink) {
516 if (path->walked)
517 continue;
518
519 if (path->source && path->connect) {
520 path->walked = 1;

--- 371 unchanged lines hidden (view full) ---

892 case snd_soc_dapm_post:
893 dapm_seq_insert(w, &up_list, dapm_up_seq);
894 break;
895
896 default:
897 if (!w->power_check)
898 continue;
899
530 }
531
532 list_for_each_entry(path, &widget->sources, list_sink) {
533 if (path->walked)
534 continue;
535
536 if (path->source && path->connect) {
537 path->walked = 1;

--- 371 unchanged lines hidden (view full) ---

909 case snd_soc_dapm_post:
910 dapm_seq_insert(w, &up_list, dapm_up_seq);
911 break;
912
913 default:
914 if (!w->power_check)
915 continue;
916
900 /* If we're suspending then pull down all the
901 * power. */
902 switch (event) {
903 case SND_SOC_DAPM_STREAM_SUSPEND:
904 power = 0;
905 break;
917 if (!w->force)
918 power = w->power_check(w);
919 else
920 power = 1;
921 if (power)
922 sys_power = 1;
906
923
907 default:
908 if (!w->force)
909 power = w->power_check(w);
910 else
911 power = 1;
912 if (power)
913 sys_power = 1;
914 break;
915 }
916
917 if (w->power == power)
918 continue;
919
920 if (power)
921 dapm_seq_insert(w, &up_list, dapm_up_seq);
922 else
923 dapm_seq_insert(w, &down_list, dapm_down_seq);
924

--- 1256 unchanged lines hidden ---
924 if (w->power == power)
925 continue;
926
927 if (power)
928 dapm_seq_insert(w, &up_list, dapm_up_seq);
929 else
930 dapm_seq_insert(w, &down_list, dapm_down_seq);
931

--- 1256 unchanged lines hidden ---