blob: 1f99cbad44c9dc2ef4f436645f691598f57f8556 [file] [log] [blame]
Steve Mucklef132c6c2012-06-06 18:30:57 -07001/*
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 <sound/pcm.h>
15
16/*
17 * Types of runtime_update to perform (e.g. originated from FE PCM ops
18 * or audio route changes triggered by muxes/mixers.
19 */
20#define SND_SOC_DPCM_UPDATE_NO 0
21#define SND_SOC_DPCM_UPDATE_BE 1
22#define SND_SOC_DPCM_UPDATE_FE 2
23
24/*
25 * Dynamic PCM Frontend -> Backend link state.
26 */
27enum snd_soc_dpcm_link_state {
28 SND_SOC_DPCM_LINK_STATE_NEW = 0, /* newly created path */
29 SND_SOC_DPCM_LINK_STATE_FREE, /* path to be dismantled */
30};
31
32/*
33 * Dynamic PCM params link
34 * This links together a FE and BE DAI at runtime and stores the link
35 * state information and the hw_params configuration.
36 */
37struct snd_soc_dpcm_params {
38 /* FE and BE DAIs*/
39 struct snd_soc_pcm_runtime *be;
40 struct snd_soc_pcm_runtime *fe;
41
42 /* link state */
43 enum snd_soc_dpcm_link_state state;
44
45 struct list_head list_be;
46 struct list_head list_fe;
47
48 /* hw params for this link - may be different for each link */
49 struct snd_pcm_hw_params hw_params;
50
51#ifdef CONFIG_DEBUG_FS
52 struct dentry *debugfs_state;
53#endif
54};
55
56/*
57 * Bespoke Trigger() Helper API
58 */
59
60/* is the PCM operation for this FE ? */
61static inline int snd_soc_dpcm_fe_can_update(struct snd_soc_pcm_runtime *fe,
62 int stream)
63{
64 return (fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE);
65}
66
67/* is the PCM operation for this BE ? */
68static inline int snd_soc_dpcm_be_can_update(struct snd_soc_pcm_runtime *fe,
69 struct snd_soc_pcm_runtime *be, int stream)
70{
71 if ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) ||
72 ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_BE) &&
73 be->dpcm[stream].runtime_update))
74 return 1;
75 else
76 return 0;
77}
78
79/* trigger platform driver only */
80static inline int
81 snd_soc_dpcm_platform_trigger(struct snd_pcm_substream *substream,
82 int cmd, struct snd_soc_platform *platform)
83{
84 if (platform->driver->ops->trigger)
85 return platform->driver->ops->trigger(substream, cmd);
86 return 0;
87}
88
89int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe,
90 struct snd_soc_pcm_runtime *be, int stream);
91
92static inline struct snd_pcm_substream *
93 snd_soc_dpcm_get_substream(struct snd_soc_pcm_runtime *be, int stream)
94{
95 return be->pcm->streams[stream].substream;
96}
97
98static inline enum snd_soc_dpcm_state
99 snd_soc_dpcm_be_get_state(struct snd_soc_pcm_runtime *be, int stream)
100{
101 return be->dpcm[stream].state;
102}
103
104static inline void snd_soc_dpcm_be_set_state(struct snd_soc_pcm_runtime *be,
105 int stream, enum snd_soc_dpcm_state state)
106{
107 be->dpcm[stream].state = state;
108}
109#endif