soc-dpcm.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * linux/sound/soc-dpcm.h -- ALSA SoC Dynamic PCM Support
  3. *
  4. * Author: Liam Girdwood <lrg@ti.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef __LINUX_SND_SOC_DPCM_H
  11. #define __LINUX_SND_SOC_DPCM_H
  12. #include <linux/list.h>
  13. #include <sound/pcm.h>
  14. struct snd_soc_pcm_runtime;
  15. /*
  16. * Types of runtime_update to perform. e.g. originated from FE PCM ops
  17. * or audio route changes triggered by muxes/mixers.
  18. */
  19. enum snd_soc_dpcm_update {
  20. SND_SOC_DPCM_UPDATE_NO = 0,
  21. SND_SOC_DPCM_UPDATE_BE,
  22. SND_SOC_DPCM_UPDATE_FE,
  23. };
  24. /*
  25. * Dynamic PCM Frontend -> Backend link management states.
  26. */
  27. enum snd_soc_dpcm_link_state {
  28. SND_SOC_DPCM_LINK_STATE_NEW = 0, /* newly created link */
  29. SND_SOC_DPCM_LINK_STATE_FREE, /* link to be dismantled */
  30. };
  31. /*
  32. * Dynamic PCM Frontend -> Backend link PCM states.
  33. */
  34. enum snd_soc_dpcm_state {
  35. SND_SOC_DPCM_STATE_NEW = 0,
  36. SND_SOC_DPCM_STATE_OPEN,
  37. SND_SOC_DPCM_STATE_HW_PARAMS,
  38. SND_SOC_DPCM_STATE_PREPARE,
  39. SND_SOC_DPCM_STATE_START,
  40. SND_SOC_DPCM_STATE_STOP,
  41. SND_SOC_DPCM_STATE_PAUSED,
  42. SND_SOC_DPCM_STATE_SUSPEND,
  43. SND_SOC_DPCM_STATE_HW_FREE,
  44. SND_SOC_DPCM_STATE_CLOSE,
  45. };
  46. /*
  47. * Dynamic PCM trigger ordering. Triggering flexibility is required as some
  48. * DSPs require triggering before/after their CPU platform and DAIs.
  49. *
  50. * i.e. some clients may want to manually order this call in their PCM
  51. * trigger() whilst others will just use the regular core ordering.
  52. */
  53. enum snd_soc_dpcm_trigger {
  54. SND_SOC_DPCM_TRIGGER_PRE = 0,
  55. SND_SOC_DPCM_TRIGGER_POST,
  56. SND_SOC_DPCM_TRIGGER_BESPOKE,
  57. };
  58. /*
  59. * Dynamic PCM link
  60. * This links together a FE and BE DAI at runtime and stores the link
  61. * state information and the hw_params configuration.
  62. */
  63. struct snd_soc_dpcm {
  64. /* FE and BE DAIs*/
  65. struct snd_soc_pcm_runtime *be;
  66. struct snd_soc_pcm_runtime *fe;
  67. /* link state */
  68. enum snd_soc_dpcm_link_state state;
  69. /* list of BE and FE for this DPCM link */
  70. struct list_head list_be;
  71. struct list_head list_fe;
  72. /* hw params for this link - may be different for each link */
  73. struct snd_pcm_hw_params hw_params;
  74. #ifdef CONFIG_DEBUG_FS
  75. struct dentry *debugfs_state;
  76. #endif
  77. };
  78. /*
  79. * Dynamic PCM runtime data.
  80. */
  81. struct snd_soc_dpcm_runtime {
  82. struct list_head be_clients;
  83. struct list_head fe_clients;
  84. int users;
  85. struct snd_pcm_runtime *runtime;
  86. struct snd_pcm_hw_params hw_params;
  87. /* state and update */
  88. enum snd_soc_dpcm_update runtime_update;
  89. enum snd_soc_dpcm_state state;
  90. };
  91. /* can this BE stop and free */
  92. int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe,
  93. struct snd_soc_pcm_runtime *be, int stream);
  94. /* can this BE perform a hw_params() */
  95. int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe,
  96. struct snd_soc_pcm_runtime *be, int stream);
  97. /* is the current PCM operation for this FE ? */
  98. int snd_soc_dpcm_fe_can_update(struct snd_soc_pcm_runtime *fe, int stream);
  99. /* is the current PCM operation for this BE ? */
  100. int snd_soc_dpcm_be_can_update(struct snd_soc_pcm_runtime *fe,
  101. struct snd_soc_pcm_runtime *be, int stream);
  102. /* get the substream for this BE */
  103. struct snd_pcm_substream *
  104. snd_soc_dpcm_get_substream(struct snd_soc_pcm_runtime *be, int stream);
  105. /* get the BE runtime state */
  106. enum snd_soc_dpcm_state
  107. snd_soc_dpcm_be_get_state(struct snd_soc_pcm_runtime *be, int stream);
  108. /* set the BE runtime state */
  109. void snd_soc_dpcm_be_set_state(struct snd_soc_pcm_runtime *be, int stream,
  110. enum snd_soc_dpcm_state state);
  111. /* internal use only */
  112. int soc_dpcm_be_digital_mute(struct snd_soc_pcm_runtime *fe, int mute);
  113. int soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd);
  114. int soc_dpcm_runtime_update(struct snd_soc_dapm_widget *);
  115. #endif