soc-dpcm.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * linux/sound/soc-dpcm.h -- ALSA SoC Dynamic PCM Support
  3. *
  4. * Author: Liam Girdwood <[email protected]>
  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/slab.h>
  13. #include <linux/list.h>
  14. #include <sound/pcm.h>
  15. struct snd_soc_pcm_runtime;
  16. #define DPCM_MAX_BE_USERS 8
  17. /*
  18. * Types of runtime_update to perform. e.g. originated from FE PCM ops
  19. * or audio route changes triggered by muxes/mixers.
  20. */
  21. enum snd_soc_dpcm_update {
  22. SND_SOC_DPCM_UPDATE_NO = 0,
  23. SND_SOC_DPCM_UPDATE_BE,
  24. SND_SOC_DPCM_UPDATE_FE,
  25. };
  26. /*
  27. * Dynamic PCM Frontend -> Backend link management states.
  28. */
  29. enum snd_soc_dpcm_link_state {
  30. SND_SOC_DPCM_LINK_STATE_NEW = 0, /* newly created link */
  31. SND_SOC_DPCM_LINK_STATE_FREE, /* link to be dismantled */
  32. };
  33. /*
  34. * Dynamic PCM Frontend -> Backend link PCM states.
  35. */
  36. enum snd_soc_dpcm_state {
  37. SND_SOC_DPCM_STATE_NEW = 0,
  38. SND_SOC_DPCM_STATE_OPEN,
  39. SND_SOC_DPCM_STATE_HW_PARAMS,
  40. SND_SOC_DPCM_STATE_PREPARE,
  41. SND_SOC_DPCM_STATE_START,
  42. SND_SOC_DPCM_STATE_STOP,
  43. SND_SOC_DPCM_STATE_PAUSED,
  44. SND_SOC_DPCM_STATE_SUSPEND,
  45. SND_SOC_DPCM_STATE_HW_FREE,
  46. SND_SOC_DPCM_STATE_CLOSE,
  47. };
  48. /*
  49. * Dynamic PCM trigger ordering. Triggering flexibility is required as some
  50. * DSPs require triggering before/after their CPU platform and DAIs.
  51. *
  52. * i.e. some clients may want to manually order this call in their PCM
  53. * trigger() whilst others will just use the regular core ordering.
  54. */
  55. enum snd_soc_dpcm_trigger {
  56. SND_SOC_DPCM_TRIGGER_PRE = 0,
  57. SND_SOC_DPCM_TRIGGER_POST,
  58. SND_SOC_DPCM_TRIGGER_BESPOKE,
  59. };
  60. /*
  61. * Dynamic PCM link
  62. * This links together a FE and BE DAI at runtime and stores the link
  63. * state information and the hw_params configuration.
  64. */
  65. struct snd_soc_dpcm {
  66. /* FE and BE DAIs*/
  67. struct snd_soc_pcm_runtime *be;
  68. struct snd_soc_pcm_runtime *fe;
  69. /* link state */
  70. enum snd_soc_dpcm_link_state state;
  71. /* list of BE and FE for this DPCM link */
  72. struct list_head list_be;
  73. struct list_head list_fe;
  74. /* hw params for this link - may be different for each link */
  75. struct snd_pcm_hw_params hw_params;
  76. #ifdef CONFIG_DEBUG_FS
  77. struct dentry *debugfs_state;
  78. #endif
  79. int stream;
  80. };
  81. /*
  82. * Dynamic PCM runtime data.
  83. */
  84. struct snd_soc_dpcm_runtime {
  85. struct list_head be_clients;
  86. struct list_head fe_clients;
  87. int users;
  88. struct snd_pcm_runtime *runtime;
  89. struct snd_pcm_hw_params hw_params;
  90. /* state and update */
  91. enum snd_soc_dpcm_update runtime_update;
  92. enum snd_soc_dpcm_state state;
  93. int trigger_pending; /* trigger cmd + 1 if pending, 0 if not */
  94. };
  95. /* can this BE stop and free */
  96. int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe,
  97. struct snd_soc_pcm_runtime *be, int stream);
  98. /* can this BE perform a hw_params() */
  99. int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe,
  100. struct snd_soc_pcm_runtime *be, int stream);
  101. /* is the current PCM operation for this FE ? */
  102. int snd_soc_dpcm_fe_can_update(struct snd_soc_pcm_runtime *fe, int stream);
  103. /* is the current PCM operation for this BE ? */
  104. int snd_soc_dpcm_be_can_update(struct snd_soc_pcm_runtime *fe,
  105. struct snd_soc_pcm_runtime *be, int stream);
  106. /* get the substream for this BE */
  107. struct snd_pcm_substream *
  108. snd_soc_dpcm_get_substream(struct snd_soc_pcm_runtime *be, int stream);
  109. /* get the BE runtime state */
  110. enum snd_soc_dpcm_state
  111. snd_soc_dpcm_be_get_state(struct snd_soc_pcm_runtime *be, int stream);
  112. /* set the BE runtime state */
  113. void snd_soc_dpcm_be_set_state(struct snd_soc_pcm_runtime *be, int stream,
  114. enum snd_soc_dpcm_state state);
  115. /* internal use only */
  116. int soc_dpcm_be_digital_mute(struct snd_soc_pcm_runtime *fe, int mute);
  117. void soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd);
  118. int soc_dpcm_runtime_update(struct snd_soc_card *);
  119. int dpcm_path_get(struct snd_soc_pcm_runtime *fe,
  120. int stream, struct snd_soc_dapm_widget_list **list_);
  121. int dpcm_process_paths(struct snd_soc_pcm_runtime *fe,
  122. int stream, struct snd_soc_dapm_widget_list **list, int new);
  123. int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream);
  124. int dpcm_be_dai_shutdown(struct snd_soc_pcm_runtime *fe, int stream);
  125. void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream);
  126. void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream);
  127. int dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream);
  128. int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int tream);
  129. int dpcm_fe_dai_hw_params_be(struct snd_soc_pcm_runtime *fe,
  130. struct snd_soc_pcm_runtime *be, struct snd_pcm_hw_params *hw_params,
  131. int stream);
  132. int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, int cmd);
  133. int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream);
  134. int dpcm_fe_dai_prepare_be(struct snd_soc_pcm_runtime *fe,
  135. struct snd_soc_pcm_runtime *be, int stream);
  136. int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir,
  137. int event);
  138. static inline void dpcm_path_put(struct snd_soc_dapm_widget_list **list)
  139. {
  140. kfree(*list);
  141. }
  142. #endif