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