Liam Girdwood | a00663b | 2011-01-31 21:23:17 +0000 | [diff] [blame] | 1 | /* |
| 2 | * linux/sound/soc-dsp.h -- ALSA SoC DSP |
| 3 | * |
| 4 | * Author: Liam Girdwood <lrg@slimlogic.co.uk> |
| 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_DSP_H |
| 12 | #define __LINUX_SND_SOC_DSP_H |
| 13 | |
| 14 | #include <sound/pcm.h> |
| 15 | |
| 16 | struct snd_soc_dapm_widget; |
| 17 | |
| 18 | /* |
| 19 | * DSP trigger ordering. Triggering flexibility is required as some DSPs |
| 20 | * require triggering before/after their clients/hosts. |
| 21 | * |
| 22 | * i.e. some clients may want to manually order this call in their PCM |
| 23 | * trigger() whilst others will just use the regular core ordering. |
| 24 | */ |
| 25 | enum snd_soc_dsp_trigger { |
| 26 | SND_SOC_DSP_TRIGGER_PRE = 0, |
| 27 | SND_SOC_DSP_TRIGGER_POST, |
| 28 | SND_SOC_DSP_TRIGGER_BESPOKE, |
| 29 | }; |
| 30 | |
| 31 | /* |
| 32 | * The DSP Backend state. |
| 33 | */ |
| 34 | enum snd_soc_dsp_link_state { |
| 35 | SND_SOC_DSP_LINK_STATE_NEW = 0, /* newly created path */ |
| 36 | SND_SOC_DSP_LINK_STATE_FREE, /* path to be dismantled */ |
| 37 | SND_SOC_DSP_LINK_STATE_HW_PARAMS, /* path hw_params configured */ |
| 38 | SND_SOC_DSP_LINK_STATE_PREPARE, /* path is prepared */ |
| 39 | SND_SOC_DSP_LINK_STATE_START, /* path is started */ |
| 40 | SND_SOC_DSP_LINK_STATE_PAUSED, /* path is paused */ |
| 41 | }; |
| 42 | |
| 43 | struct snd_soc_dsp_params { |
| 44 | struct snd_soc_pcm_runtime *be; |
| 45 | struct snd_soc_pcm_runtime *fe; |
| 46 | enum snd_soc_dsp_link_state state; |
| 47 | struct list_head list_be; |
| 48 | struct list_head list_fe; |
| 49 | struct snd_pcm_hw_params params; |
| 50 | #ifdef CONFIG_DEBUG_FS |
| 51 | struct dentry *debugfs_state; |
| 52 | #endif |
| 53 | }; |
| 54 | |
| 55 | struct snd_soc_dsp_link { |
Liam Girdwood | a42d64d | 2011-06-03 14:26:07 +0100 | [diff] [blame] | 56 | bool capture; |
| 57 | bool playback; |
Liam Girdwood | a00663b | 2011-01-31 21:23:17 +0000 | [diff] [blame] | 58 | enum snd_soc_dsp_trigger trigger[2]; |
| 59 | }; |
| 60 | |
| 61 | /* FE DSP PCM ops - called by soc-core */ |
| 62 | int soc_dsp_fe_dai_open(struct snd_pcm_substream *substream); |
| 63 | int soc_dsp_fe_dai_close(struct snd_pcm_substream *substream); |
| 64 | int soc_dsp_fe_dai_prepare(struct snd_pcm_substream *substream); |
| 65 | int soc_dsp_fe_dai_hw_free(struct snd_pcm_substream *substream); |
| 66 | int soc_dsp_fe_dai_trigger(struct snd_pcm_substream *substream, int cmd); |
| 67 | int soc_dsp_fe_dai_hw_params(struct snd_pcm_substream *substream, |
| 68 | struct snd_pcm_hw_params *params); |
| 69 | |
| 70 | /* Backend DSP trigger. |
| 71 | * Can be called by core or components depending on trigger config. |
| 72 | */ |
| 73 | int soc_dsp_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, int cmd); |
| 74 | |
| 75 | /* Is this trigger() call required for this BE and stream */ |
| 76 | static inline int snd_soc_dsp_is_trigger_for_be(struct snd_soc_pcm_runtime *fe, |
| 77 | struct snd_soc_pcm_runtime *be, int stream) |
| 78 | { |
| 79 | if (!fe->dsp[stream].runtime_update) |
| 80 | return 1; |
| 81 | else if (be->dsp[stream].runtime_update) |
| 82 | return 1; |
| 83 | else |
| 84 | return 0; |
| 85 | } |
| 86 | |
| 87 | /* Is this trigger() call required for this FE and stream */ |
| 88 | static inline int snd_soc_dsp_is_trigger_for_fe(struct snd_soc_pcm_runtime *fe, |
| 89 | int stream) |
| 90 | { |
| 91 | return !fe->dsp[stream].runtime_update; |
| 92 | } |
| 93 | |
| 94 | static inline int snd_soc_dsp_platform_trigger(struct snd_pcm_substream *substream, |
| 95 | int cmd, struct snd_soc_platform *platform) |
| 96 | { |
| 97 | if (platform->driver->ops->trigger) |
| 98 | return platform->driver->ops->trigger(substream, cmd); |
| 99 | return 0; |
| 100 | } |
| 101 | |
| 102 | /* Runtime update - open/close Backend DSP paths depending on mixer updates */ |
| 103 | int soc_dsp_runtime_update(struct snd_soc_dapm_widget *widget); |
| 104 | |
| 105 | /* Backend DSP suspend and resume */ |
| 106 | int soc_dsp_be_digital_mute(struct snd_soc_pcm_runtime *fe, int mute); |
| 107 | int soc_dsp_be_cpu_dai_suspend(struct snd_soc_pcm_runtime *fe); |
| 108 | int soc_dsp_be_ac97_cpu_dai_suspend(struct snd_soc_pcm_runtime *fe); |
| 109 | int soc_dsp_be_platform_suspend(struct snd_soc_pcm_runtime *fe); |
| 110 | int soc_dsp_be_cpu_dai_resume(struct snd_soc_pcm_runtime *fe); |
| 111 | int soc_dsp_be_ac97_cpu_dai_resume(struct snd_soc_pcm_runtime *fe); |
| 112 | int soc_dsp_be_platform_resume(struct snd_soc_pcm_runtime *fe); |
| 113 | |
| 114 | /* DAPM stream events for Backend DSP paths */ |
| 115 | int soc_dsp_dapm_stream_event(struct snd_soc_pcm_runtime *fe, |
| 116 | int dir, const char *stream, int event); |
| 117 | |
| 118 | static inline struct snd_pcm_substream *snd_soc_dsp_get_substream( |
| 119 | struct snd_soc_pcm_runtime *be, int stream) |
| 120 | { |
| 121 | return be->pcm->streams[stream].substream; |
| 122 | } |
| 123 | |
| 124 | #endif |