1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun *
3*4882a593Smuzhiyun * soc-component.h
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Copyright (C) 2019 Renesas Electronics Corp.
6*4882a593Smuzhiyun * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
7*4882a593Smuzhiyun */
8*4882a593Smuzhiyun #ifndef __SOC_COMPONENT_H
9*4882a593Smuzhiyun #define __SOC_COMPONENT_H
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun #include <sound/soc.h>
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun /*
14*4882a593Smuzhiyun * Component probe and remove ordering levels for components with runtime
15*4882a593Smuzhiyun * dependencies.
16*4882a593Smuzhiyun */
17*4882a593Smuzhiyun #define SND_SOC_COMP_ORDER_FIRST -2
18*4882a593Smuzhiyun #define SND_SOC_COMP_ORDER_EARLY -1
19*4882a593Smuzhiyun #define SND_SOC_COMP_ORDER_NORMAL 0
20*4882a593Smuzhiyun #define SND_SOC_COMP_ORDER_LATE 1
21*4882a593Smuzhiyun #define SND_SOC_COMP_ORDER_LAST 2
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun #define for_each_comp_order(order) \
24*4882a593Smuzhiyun for (order = SND_SOC_COMP_ORDER_FIRST; \
25*4882a593Smuzhiyun order <= SND_SOC_COMP_ORDER_LAST; \
26*4882a593Smuzhiyun order++)
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun /* component interface */
29*4882a593Smuzhiyun struct snd_compress_ops {
30*4882a593Smuzhiyun int (*open)(struct snd_soc_component *component,
31*4882a593Smuzhiyun struct snd_compr_stream *stream);
32*4882a593Smuzhiyun int (*free)(struct snd_soc_component *component,
33*4882a593Smuzhiyun struct snd_compr_stream *stream);
34*4882a593Smuzhiyun int (*set_params)(struct snd_soc_component *component,
35*4882a593Smuzhiyun struct snd_compr_stream *stream,
36*4882a593Smuzhiyun struct snd_compr_params *params);
37*4882a593Smuzhiyun int (*get_params)(struct snd_soc_component *component,
38*4882a593Smuzhiyun struct snd_compr_stream *stream,
39*4882a593Smuzhiyun struct snd_codec *params);
40*4882a593Smuzhiyun int (*set_metadata)(struct snd_soc_component *component,
41*4882a593Smuzhiyun struct snd_compr_stream *stream,
42*4882a593Smuzhiyun struct snd_compr_metadata *metadata);
43*4882a593Smuzhiyun int (*get_metadata)(struct snd_soc_component *component,
44*4882a593Smuzhiyun struct snd_compr_stream *stream,
45*4882a593Smuzhiyun struct snd_compr_metadata *metadata);
46*4882a593Smuzhiyun int (*trigger)(struct snd_soc_component *component,
47*4882a593Smuzhiyun struct snd_compr_stream *stream, int cmd);
48*4882a593Smuzhiyun int (*pointer)(struct snd_soc_component *component,
49*4882a593Smuzhiyun struct snd_compr_stream *stream,
50*4882a593Smuzhiyun struct snd_compr_tstamp *tstamp);
51*4882a593Smuzhiyun int (*copy)(struct snd_soc_component *component,
52*4882a593Smuzhiyun struct snd_compr_stream *stream, char __user *buf,
53*4882a593Smuzhiyun size_t count);
54*4882a593Smuzhiyun int (*mmap)(struct snd_soc_component *component,
55*4882a593Smuzhiyun struct snd_compr_stream *stream,
56*4882a593Smuzhiyun struct vm_area_struct *vma);
57*4882a593Smuzhiyun int (*ack)(struct snd_soc_component *component,
58*4882a593Smuzhiyun struct snd_compr_stream *stream, size_t bytes);
59*4882a593Smuzhiyun int (*get_caps)(struct snd_soc_component *component,
60*4882a593Smuzhiyun struct snd_compr_stream *stream,
61*4882a593Smuzhiyun struct snd_compr_caps *caps);
62*4882a593Smuzhiyun int (*get_codec_caps)(struct snd_soc_component *component,
63*4882a593Smuzhiyun struct snd_compr_stream *stream,
64*4882a593Smuzhiyun struct snd_compr_codec_caps *codec);
65*4882a593Smuzhiyun };
66*4882a593Smuzhiyun
67*4882a593Smuzhiyun struct snd_soc_component_driver {
68*4882a593Smuzhiyun const char *name;
69*4882a593Smuzhiyun
70*4882a593Smuzhiyun /* Default control and setup, added after probe() is run */
71*4882a593Smuzhiyun const struct snd_kcontrol_new *controls;
72*4882a593Smuzhiyun unsigned int num_controls;
73*4882a593Smuzhiyun const struct snd_soc_dapm_widget *dapm_widgets;
74*4882a593Smuzhiyun unsigned int num_dapm_widgets;
75*4882a593Smuzhiyun const struct snd_soc_dapm_route *dapm_routes;
76*4882a593Smuzhiyun unsigned int num_dapm_routes;
77*4882a593Smuzhiyun
78*4882a593Smuzhiyun int (*probe)(struct snd_soc_component *component);
79*4882a593Smuzhiyun void (*remove)(struct snd_soc_component *component);
80*4882a593Smuzhiyun int (*suspend)(struct snd_soc_component *component);
81*4882a593Smuzhiyun int (*resume)(struct snd_soc_component *component);
82*4882a593Smuzhiyun
83*4882a593Smuzhiyun unsigned int (*read)(struct snd_soc_component *component,
84*4882a593Smuzhiyun unsigned int reg);
85*4882a593Smuzhiyun int (*write)(struct snd_soc_component *component,
86*4882a593Smuzhiyun unsigned int reg, unsigned int val);
87*4882a593Smuzhiyun
88*4882a593Smuzhiyun /* pcm creation and destruction */
89*4882a593Smuzhiyun int (*pcm_construct)(struct snd_soc_component *component,
90*4882a593Smuzhiyun struct snd_soc_pcm_runtime *rtd);
91*4882a593Smuzhiyun void (*pcm_destruct)(struct snd_soc_component *component,
92*4882a593Smuzhiyun struct snd_pcm *pcm);
93*4882a593Smuzhiyun
94*4882a593Smuzhiyun /* component wide operations */
95*4882a593Smuzhiyun int (*set_sysclk)(struct snd_soc_component *component,
96*4882a593Smuzhiyun int clk_id, int source, unsigned int freq, int dir);
97*4882a593Smuzhiyun int (*set_pll)(struct snd_soc_component *component, int pll_id,
98*4882a593Smuzhiyun int source, unsigned int freq_in, unsigned int freq_out);
99*4882a593Smuzhiyun int (*set_jack)(struct snd_soc_component *component,
100*4882a593Smuzhiyun struct snd_soc_jack *jack, void *data);
101*4882a593Smuzhiyun
102*4882a593Smuzhiyun /* DT */
103*4882a593Smuzhiyun int (*of_xlate_dai_name)(struct snd_soc_component *component,
104*4882a593Smuzhiyun struct of_phandle_args *args,
105*4882a593Smuzhiyun const char **dai_name);
106*4882a593Smuzhiyun int (*of_xlate_dai_id)(struct snd_soc_component *comment,
107*4882a593Smuzhiyun struct device_node *endpoint);
108*4882a593Smuzhiyun void (*seq_notifier)(struct snd_soc_component *component,
109*4882a593Smuzhiyun enum snd_soc_dapm_type type, int subseq);
110*4882a593Smuzhiyun int (*stream_event)(struct snd_soc_component *component, int event);
111*4882a593Smuzhiyun int (*set_bias_level)(struct snd_soc_component *component,
112*4882a593Smuzhiyun enum snd_soc_bias_level level);
113*4882a593Smuzhiyun
114*4882a593Smuzhiyun int (*open)(struct snd_soc_component *component,
115*4882a593Smuzhiyun struct snd_pcm_substream *substream);
116*4882a593Smuzhiyun int (*close)(struct snd_soc_component *component,
117*4882a593Smuzhiyun struct snd_pcm_substream *substream);
118*4882a593Smuzhiyun int (*ioctl)(struct snd_soc_component *component,
119*4882a593Smuzhiyun struct snd_pcm_substream *substream,
120*4882a593Smuzhiyun unsigned int cmd, void *arg);
121*4882a593Smuzhiyun int (*hw_params)(struct snd_soc_component *component,
122*4882a593Smuzhiyun struct snd_pcm_substream *substream,
123*4882a593Smuzhiyun struct snd_pcm_hw_params *params);
124*4882a593Smuzhiyun int (*hw_free)(struct snd_soc_component *component,
125*4882a593Smuzhiyun struct snd_pcm_substream *substream);
126*4882a593Smuzhiyun int (*prepare)(struct snd_soc_component *component,
127*4882a593Smuzhiyun struct snd_pcm_substream *substream);
128*4882a593Smuzhiyun int (*trigger)(struct snd_soc_component *component,
129*4882a593Smuzhiyun struct snd_pcm_substream *substream, int cmd);
130*4882a593Smuzhiyun int (*sync_stop)(struct snd_soc_component *component,
131*4882a593Smuzhiyun struct snd_pcm_substream *substream);
132*4882a593Smuzhiyun snd_pcm_uframes_t (*pointer)(struct snd_soc_component *component,
133*4882a593Smuzhiyun struct snd_pcm_substream *substream);
134*4882a593Smuzhiyun int (*get_time_info)(struct snd_soc_component *component,
135*4882a593Smuzhiyun struct snd_pcm_substream *substream, struct timespec64 *system_ts,
136*4882a593Smuzhiyun struct timespec64 *audio_ts,
137*4882a593Smuzhiyun struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
138*4882a593Smuzhiyun struct snd_pcm_audio_tstamp_report *audio_tstamp_report);
139*4882a593Smuzhiyun int (*copy_user)(struct snd_soc_component *component,
140*4882a593Smuzhiyun struct snd_pcm_substream *substream, int channel,
141*4882a593Smuzhiyun unsigned long pos, void __user *buf,
142*4882a593Smuzhiyun unsigned long bytes);
143*4882a593Smuzhiyun struct page *(*page)(struct snd_soc_component *component,
144*4882a593Smuzhiyun struct snd_pcm_substream *substream,
145*4882a593Smuzhiyun unsigned long offset);
146*4882a593Smuzhiyun int (*mmap)(struct snd_soc_component *component,
147*4882a593Smuzhiyun struct snd_pcm_substream *substream,
148*4882a593Smuzhiyun struct vm_area_struct *vma);
149*4882a593Smuzhiyun int (*ack)(struct snd_soc_component *component,
150*4882a593Smuzhiyun struct snd_pcm_substream *substream);
151*4882a593Smuzhiyun
152*4882a593Smuzhiyun const struct snd_compress_ops *compress_ops;
153*4882a593Smuzhiyun
154*4882a593Smuzhiyun /* probe ordering - for components with runtime dependencies */
155*4882a593Smuzhiyun int probe_order;
156*4882a593Smuzhiyun int remove_order;
157*4882a593Smuzhiyun
158*4882a593Smuzhiyun /*
159*4882a593Smuzhiyun * signal if the module handling the component should not be removed
160*4882a593Smuzhiyun * if a pcm is open. Setting this would prevent the module
161*4882a593Smuzhiyun * refcount being incremented in probe() but allow it be incremented
162*4882a593Smuzhiyun * when a pcm is opened and decremented when it is closed.
163*4882a593Smuzhiyun */
164*4882a593Smuzhiyun unsigned int module_get_upon_open:1;
165*4882a593Smuzhiyun
166*4882a593Smuzhiyun /* bits */
167*4882a593Smuzhiyun unsigned int idle_bias_on:1;
168*4882a593Smuzhiyun unsigned int suspend_bias_off:1;
169*4882a593Smuzhiyun unsigned int use_pmdown_time:1; /* care pmdown_time at stop */
170*4882a593Smuzhiyun unsigned int endianness:1;
171*4882a593Smuzhiyun unsigned int non_legacy_dai_naming:1;
172*4882a593Smuzhiyun
173*4882a593Smuzhiyun /* this component uses topology and ignore machine driver FEs */
174*4882a593Smuzhiyun const char *ignore_machine;
175*4882a593Smuzhiyun const char *topology_name_prefix;
176*4882a593Smuzhiyun int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
177*4882a593Smuzhiyun struct snd_pcm_hw_params *params);
178*4882a593Smuzhiyun bool use_dai_pcm_id; /* use DAI link PCM ID as PCM device number */
179*4882a593Smuzhiyun int be_pcm_base; /* base device ID for all BE PCMs */
180*4882a593Smuzhiyun };
181*4882a593Smuzhiyun
182*4882a593Smuzhiyun struct snd_soc_component {
183*4882a593Smuzhiyun const char *name;
184*4882a593Smuzhiyun int id;
185*4882a593Smuzhiyun const char *name_prefix;
186*4882a593Smuzhiyun struct device *dev;
187*4882a593Smuzhiyun struct snd_soc_card *card;
188*4882a593Smuzhiyun
189*4882a593Smuzhiyun unsigned int active;
190*4882a593Smuzhiyun
191*4882a593Smuzhiyun unsigned int suspended:1; /* is in suspend PM state */
192*4882a593Smuzhiyun
193*4882a593Smuzhiyun struct list_head list;
194*4882a593Smuzhiyun struct list_head card_aux_list; /* for auxiliary bound components */
195*4882a593Smuzhiyun struct list_head card_list;
196*4882a593Smuzhiyun
197*4882a593Smuzhiyun const struct snd_soc_component_driver *driver;
198*4882a593Smuzhiyun
199*4882a593Smuzhiyun struct list_head dai_list;
200*4882a593Smuzhiyun int num_dai;
201*4882a593Smuzhiyun
202*4882a593Smuzhiyun struct regmap *regmap;
203*4882a593Smuzhiyun int val_bytes;
204*4882a593Smuzhiyun
205*4882a593Smuzhiyun struct mutex io_mutex;
206*4882a593Smuzhiyun
207*4882a593Smuzhiyun /* attached dynamic objects */
208*4882a593Smuzhiyun struct list_head dobj_list;
209*4882a593Smuzhiyun
210*4882a593Smuzhiyun /*
211*4882a593Smuzhiyun * DO NOT use any of the fields below in drivers, they are temporary and
212*4882a593Smuzhiyun * are going to be removed again soon. If you use them in driver code
213*4882a593Smuzhiyun * the driver will be marked as BROKEN when these fields are removed.
214*4882a593Smuzhiyun */
215*4882a593Smuzhiyun
216*4882a593Smuzhiyun /* Don't use these, use snd_soc_component_get_dapm() */
217*4882a593Smuzhiyun struct snd_soc_dapm_context dapm;
218*4882a593Smuzhiyun
219*4882a593Smuzhiyun /* machine specific init */
220*4882a593Smuzhiyun int (*init)(struct snd_soc_component *component);
221*4882a593Smuzhiyun
222*4882a593Smuzhiyun /* function mark */
223*4882a593Smuzhiyun struct snd_pcm_substream *mark_module;
224*4882a593Smuzhiyun struct snd_pcm_substream *mark_open;
225*4882a593Smuzhiyun void *mark_pm;
226*4882a593Smuzhiyun
227*4882a593Smuzhiyun #ifdef CONFIG_DEBUG_FS
228*4882a593Smuzhiyun struct dentry *debugfs_root;
229*4882a593Smuzhiyun const char *debugfs_prefix;
230*4882a593Smuzhiyun #endif
231*4882a593Smuzhiyun };
232*4882a593Smuzhiyun
233*4882a593Smuzhiyun #define for_each_component_dais(component, dai)\
234*4882a593Smuzhiyun list_for_each_entry(dai, &(component)->dai_list, list)
235*4882a593Smuzhiyun #define for_each_component_dais_safe(component, dai, _dai)\
236*4882a593Smuzhiyun list_for_each_entry_safe(dai, _dai, &(component)->dai_list, list)
237*4882a593Smuzhiyun
238*4882a593Smuzhiyun /**
239*4882a593Smuzhiyun * snd_soc_dapm_to_component() - Casts a DAPM context to the component it is
240*4882a593Smuzhiyun * embedded in
241*4882a593Smuzhiyun * @dapm: The DAPM context to cast to the component
242*4882a593Smuzhiyun *
243*4882a593Smuzhiyun * This function must only be used on DAPM contexts that are known to be part of
244*4882a593Smuzhiyun * a component (e.g. in a component driver). Otherwise the behavior is
245*4882a593Smuzhiyun * undefined.
246*4882a593Smuzhiyun */
snd_soc_dapm_to_component(struct snd_soc_dapm_context * dapm)247*4882a593Smuzhiyun static inline struct snd_soc_component *snd_soc_dapm_to_component(
248*4882a593Smuzhiyun struct snd_soc_dapm_context *dapm)
249*4882a593Smuzhiyun {
250*4882a593Smuzhiyun return container_of(dapm, struct snd_soc_component, dapm);
251*4882a593Smuzhiyun }
252*4882a593Smuzhiyun
253*4882a593Smuzhiyun /**
254*4882a593Smuzhiyun * snd_soc_component_get_dapm() - Returns the DAPM context associated with a
255*4882a593Smuzhiyun * component
256*4882a593Smuzhiyun * @component: The component for which to get the DAPM context
257*4882a593Smuzhiyun */
snd_soc_component_get_dapm(struct snd_soc_component * component)258*4882a593Smuzhiyun static inline struct snd_soc_dapm_context *snd_soc_component_get_dapm(
259*4882a593Smuzhiyun struct snd_soc_component *component)
260*4882a593Smuzhiyun {
261*4882a593Smuzhiyun return &component->dapm;
262*4882a593Smuzhiyun }
263*4882a593Smuzhiyun
264*4882a593Smuzhiyun /**
265*4882a593Smuzhiyun * snd_soc_component_init_bias_level() - Initialize COMPONENT DAPM bias level
266*4882a593Smuzhiyun * @component: The COMPONENT for which to initialize the DAPM bias level
267*4882a593Smuzhiyun * @level: The DAPM level to initialize to
268*4882a593Smuzhiyun *
269*4882a593Smuzhiyun * Initializes the COMPONENT DAPM bias level. See snd_soc_dapm_init_bias_level()
270*4882a593Smuzhiyun */
271*4882a593Smuzhiyun static inline void
snd_soc_component_init_bias_level(struct snd_soc_component * component,enum snd_soc_bias_level level)272*4882a593Smuzhiyun snd_soc_component_init_bias_level(struct snd_soc_component *component,
273*4882a593Smuzhiyun enum snd_soc_bias_level level)
274*4882a593Smuzhiyun {
275*4882a593Smuzhiyun snd_soc_dapm_init_bias_level(
276*4882a593Smuzhiyun snd_soc_component_get_dapm(component), level);
277*4882a593Smuzhiyun }
278*4882a593Smuzhiyun
279*4882a593Smuzhiyun /**
280*4882a593Smuzhiyun * snd_soc_component_get_bias_level() - Get current COMPONENT DAPM bias level
281*4882a593Smuzhiyun * @component: The COMPONENT for which to get the DAPM bias level
282*4882a593Smuzhiyun *
283*4882a593Smuzhiyun * Returns: The current DAPM bias level of the COMPONENT.
284*4882a593Smuzhiyun */
285*4882a593Smuzhiyun static inline enum snd_soc_bias_level
snd_soc_component_get_bias_level(struct snd_soc_component * component)286*4882a593Smuzhiyun snd_soc_component_get_bias_level(struct snd_soc_component *component)
287*4882a593Smuzhiyun {
288*4882a593Smuzhiyun return snd_soc_dapm_get_bias_level(
289*4882a593Smuzhiyun snd_soc_component_get_dapm(component));
290*4882a593Smuzhiyun }
291*4882a593Smuzhiyun
292*4882a593Smuzhiyun /**
293*4882a593Smuzhiyun * snd_soc_component_force_bias_level() - Set the COMPONENT DAPM bias level
294*4882a593Smuzhiyun * @component: The COMPONENT for which to set the level
295*4882a593Smuzhiyun * @level: The level to set to
296*4882a593Smuzhiyun *
297*4882a593Smuzhiyun * Forces the COMPONENT bias level to a specific state. See
298*4882a593Smuzhiyun * snd_soc_dapm_force_bias_level().
299*4882a593Smuzhiyun */
300*4882a593Smuzhiyun static inline int
snd_soc_component_force_bias_level(struct snd_soc_component * component,enum snd_soc_bias_level level)301*4882a593Smuzhiyun snd_soc_component_force_bias_level(struct snd_soc_component *component,
302*4882a593Smuzhiyun enum snd_soc_bias_level level)
303*4882a593Smuzhiyun {
304*4882a593Smuzhiyun return snd_soc_dapm_force_bias_level(
305*4882a593Smuzhiyun snd_soc_component_get_dapm(component),
306*4882a593Smuzhiyun level);
307*4882a593Smuzhiyun }
308*4882a593Smuzhiyun
309*4882a593Smuzhiyun /**
310*4882a593Smuzhiyun * snd_soc_dapm_kcontrol_component() - Returns the component associated to a
311*4882a593Smuzhiyun * kcontrol
312*4882a593Smuzhiyun * @kcontrol: The kcontrol
313*4882a593Smuzhiyun *
314*4882a593Smuzhiyun * This function must only be used on DAPM contexts that are known to be part of
315*4882a593Smuzhiyun * a COMPONENT (e.g. in a COMPONENT driver). Otherwise the behavior is undefined
316*4882a593Smuzhiyun */
snd_soc_dapm_kcontrol_component(struct snd_kcontrol * kcontrol)317*4882a593Smuzhiyun static inline struct snd_soc_component *snd_soc_dapm_kcontrol_component(
318*4882a593Smuzhiyun struct snd_kcontrol *kcontrol)
319*4882a593Smuzhiyun {
320*4882a593Smuzhiyun return snd_soc_dapm_to_component(snd_soc_dapm_kcontrol_dapm(kcontrol));
321*4882a593Smuzhiyun }
322*4882a593Smuzhiyun
323*4882a593Smuzhiyun /**
324*4882a593Smuzhiyun * snd_soc_component_cache_sync() - Sync the register cache with the hardware
325*4882a593Smuzhiyun * @component: COMPONENT to sync
326*4882a593Smuzhiyun *
327*4882a593Smuzhiyun * Note: This function will call regcache_sync()
328*4882a593Smuzhiyun */
snd_soc_component_cache_sync(struct snd_soc_component * component)329*4882a593Smuzhiyun static inline int snd_soc_component_cache_sync(
330*4882a593Smuzhiyun struct snd_soc_component *component)
331*4882a593Smuzhiyun {
332*4882a593Smuzhiyun return regcache_sync(component->regmap);
333*4882a593Smuzhiyun }
334*4882a593Smuzhiyun
335*4882a593Smuzhiyun void snd_soc_component_set_aux(struct snd_soc_component *component,
336*4882a593Smuzhiyun struct snd_soc_aux_dev *aux);
337*4882a593Smuzhiyun int snd_soc_component_init(struct snd_soc_component *component);
338*4882a593Smuzhiyun
339*4882a593Smuzhiyun /* component IO */
340*4882a593Smuzhiyun unsigned int snd_soc_component_read(struct snd_soc_component *component,
341*4882a593Smuzhiyun unsigned int reg);
342*4882a593Smuzhiyun int snd_soc_component_write(struct snd_soc_component *component,
343*4882a593Smuzhiyun unsigned int reg, unsigned int val);
344*4882a593Smuzhiyun int snd_soc_component_update_bits(struct snd_soc_component *component,
345*4882a593Smuzhiyun unsigned int reg, unsigned int mask,
346*4882a593Smuzhiyun unsigned int val);
347*4882a593Smuzhiyun int snd_soc_component_update_bits_async(struct snd_soc_component *component,
348*4882a593Smuzhiyun unsigned int reg, unsigned int mask,
349*4882a593Smuzhiyun unsigned int val);
350*4882a593Smuzhiyun void snd_soc_component_async_complete(struct snd_soc_component *component);
351*4882a593Smuzhiyun int snd_soc_component_test_bits(struct snd_soc_component *component,
352*4882a593Smuzhiyun unsigned int reg, unsigned int mask,
353*4882a593Smuzhiyun unsigned int value);
354*4882a593Smuzhiyun
355*4882a593Smuzhiyun /* component wide operations */
356*4882a593Smuzhiyun int snd_soc_component_set_sysclk(struct snd_soc_component *component,
357*4882a593Smuzhiyun int clk_id, int source,
358*4882a593Smuzhiyun unsigned int freq, int dir);
359*4882a593Smuzhiyun int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id,
360*4882a593Smuzhiyun int source, unsigned int freq_in,
361*4882a593Smuzhiyun unsigned int freq_out);
362*4882a593Smuzhiyun int snd_soc_component_set_jack(struct snd_soc_component *component,
363*4882a593Smuzhiyun struct snd_soc_jack *jack, void *data);
364*4882a593Smuzhiyun
365*4882a593Smuzhiyun void snd_soc_component_seq_notifier(struct snd_soc_component *component,
366*4882a593Smuzhiyun enum snd_soc_dapm_type type, int subseq);
367*4882a593Smuzhiyun int snd_soc_component_stream_event(struct snd_soc_component *component,
368*4882a593Smuzhiyun int event);
369*4882a593Smuzhiyun int snd_soc_component_set_bias_level(struct snd_soc_component *component,
370*4882a593Smuzhiyun enum snd_soc_bias_level level);
371*4882a593Smuzhiyun
372*4882a593Smuzhiyun void snd_soc_component_setup_regmap(struct snd_soc_component *component);
373*4882a593Smuzhiyun #ifdef CONFIG_REGMAP
374*4882a593Smuzhiyun void snd_soc_component_init_regmap(struct snd_soc_component *component,
375*4882a593Smuzhiyun struct regmap *regmap);
376*4882a593Smuzhiyun void snd_soc_component_exit_regmap(struct snd_soc_component *component);
377*4882a593Smuzhiyun #endif
378*4882a593Smuzhiyun
379*4882a593Smuzhiyun #define snd_soc_component_module_get_when_probe(component)\
380*4882a593Smuzhiyun snd_soc_component_module_get(component, NULL, 0)
381*4882a593Smuzhiyun #define snd_soc_component_module_get_when_open(component, substream) \
382*4882a593Smuzhiyun snd_soc_component_module_get(component, substream, 1)
383*4882a593Smuzhiyun int snd_soc_component_module_get(struct snd_soc_component *component,
384*4882a593Smuzhiyun struct snd_pcm_substream *substream,
385*4882a593Smuzhiyun int upon_open);
386*4882a593Smuzhiyun #define snd_soc_component_module_put_when_remove(component) \
387*4882a593Smuzhiyun snd_soc_component_module_put(component, NULL, 0, 0)
388*4882a593Smuzhiyun #define snd_soc_component_module_put_when_close(component, substream, rollback) \
389*4882a593Smuzhiyun snd_soc_component_module_put(component, substream, 1, rollback)
390*4882a593Smuzhiyun void snd_soc_component_module_put(struct snd_soc_component *component,
391*4882a593Smuzhiyun struct snd_pcm_substream *substream,
392*4882a593Smuzhiyun int upon_open, int rollback);
393*4882a593Smuzhiyun
snd_soc_component_set_drvdata(struct snd_soc_component * c,void * data)394*4882a593Smuzhiyun static inline void snd_soc_component_set_drvdata(struct snd_soc_component *c,
395*4882a593Smuzhiyun void *data)
396*4882a593Smuzhiyun {
397*4882a593Smuzhiyun dev_set_drvdata(c->dev, data);
398*4882a593Smuzhiyun }
399*4882a593Smuzhiyun
snd_soc_component_get_drvdata(struct snd_soc_component * c)400*4882a593Smuzhiyun static inline void *snd_soc_component_get_drvdata(struct snd_soc_component *c)
401*4882a593Smuzhiyun {
402*4882a593Smuzhiyun return dev_get_drvdata(c->dev);
403*4882a593Smuzhiyun }
404*4882a593Smuzhiyun
405*4882a593Smuzhiyun static inline unsigned int
snd_soc_component_active(struct snd_soc_component * component)406*4882a593Smuzhiyun snd_soc_component_active(struct snd_soc_component *component)
407*4882a593Smuzhiyun {
408*4882a593Smuzhiyun return component->active;
409*4882a593Smuzhiyun }
410*4882a593Smuzhiyun
411*4882a593Smuzhiyun /* component pin */
412*4882a593Smuzhiyun int snd_soc_component_enable_pin(struct snd_soc_component *component,
413*4882a593Smuzhiyun const char *pin);
414*4882a593Smuzhiyun int snd_soc_component_enable_pin_unlocked(struct snd_soc_component *component,
415*4882a593Smuzhiyun const char *pin);
416*4882a593Smuzhiyun int snd_soc_component_disable_pin(struct snd_soc_component *component,
417*4882a593Smuzhiyun const char *pin);
418*4882a593Smuzhiyun int snd_soc_component_disable_pin_unlocked(struct snd_soc_component *component,
419*4882a593Smuzhiyun const char *pin);
420*4882a593Smuzhiyun int snd_soc_component_nc_pin(struct snd_soc_component *component,
421*4882a593Smuzhiyun const char *pin);
422*4882a593Smuzhiyun int snd_soc_component_nc_pin_unlocked(struct snd_soc_component *component,
423*4882a593Smuzhiyun const char *pin);
424*4882a593Smuzhiyun int snd_soc_component_get_pin_status(struct snd_soc_component *component,
425*4882a593Smuzhiyun const char *pin);
426*4882a593Smuzhiyun int snd_soc_component_force_enable_pin(struct snd_soc_component *component,
427*4882a593Smuzhiyun const char *pin);
428*4882a593Smuzhiyun int snd_soc_component_force_enable_pin_unlocked(
429*4882a593Smuzhiyun struct snd_soc_component *component,
430*4882a593Smuzhiyun const char *pin);
431*4882a593Smuzhiyun
432*4882a593Smuzhiyun /* component driver ops */
433*4882a593Smuzhiyun int snd_soc_component_open(struct snd_soc_component *component,
434*4882a593Smuzhiyun struct snd_pcm_substream *substream);
435*4882a593Smuzhiyun int snd_soc_component_close(struct snd_soc_component *component,
436*4882a593Smuzhiyun struct snd_pcm_substream *substream,
437*4882a593Smuzhiyun int rollback);
438*4882a593Smuzhiyun void snd_soc_component_suspend(struct snd_soc_component *component);
439*4882a593Smuzhiyun void snd_soc_component_resume(struct snd_soc_component *component);
440*4882a593Smuzhiyun int snd_soc_component_is_suspended(struct snd_soc_component *component);
441*4882a593Smuzhiyun int snd_soc_component_probe(struct snd_soc_component *component);
442*4882a593Smuzhiyun void snd_soc_component_remove(struct snd_soc_component *component);
443*4882a593Smuzhiyun int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component,
444*4882a593Smuzhiyun struct device_node *ep);
445*4882a593Smuzhiyun int snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component,
446*4882a593Smuzhiyun struct of_phandle_args *args,
447*4882a593Smuzhiyun const char **dai_name);
448*4882a593Smuzhiyun
449*4882a593Smuzhiyun int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
450*4882a593Smuzhiyun int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
451*4882a593Smuzhiyun unsigned int cmd, void *arg);
452*4882a593Smuzhiyun int snd_soc_pcm_component_sync_stop(struct snd_pcm_substream *substream);
453*4882a593Smuzhiyun int snd_soc_pcm_component_copy_user(struct snd_pcm_substream *substream,
454*4882a593Smuzhiyun int channel, unsigned long pos,
455*4882a593Smuzhiyun void __user *buf, unsigned long bytes);
456*4882a593Smuzhiyun struct page *snd_soc_pcm_component_page(struct snd_pcm_substream *substream,
457*4882a593Smuzhiyun unsigned long offset);
458*4882a593Smuzhiyun int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream,
459*4882a593Smuzhiyun struct vm_area_struct *vma);
460*4882a593Smuzhiyun int snd_soc_pcm_component_new(struct snd_soc_pcm_runtime *rtd);
461*4882a593Smuzhiyun void snd_soc_pcm_component_free(struct snd_soc_pcm_runtime *rtd);
462*4882a593Smuzhiyun int snd_soc_pcm_component_prepare(struct snd_pcm_substream *substream);
463*4882a593Smuzhiyun int snd_soc_pcm_component_hw_params(struct snd_pcm_substream *substream,
464*4882a593Smuzhiyun struct snd_pcm_hw_params *params,
465*4882a593Smuzhiyun struct snd_soc_component **last);
466*4882a593Smuzhiyun void snd_soc_pcm_component_hw_free(struct snd_pcm_substream *substream,
467*4882a593Smuzhiyun struct snd_soc_component *last);
468*4882a593Smuzhiyun int snd_soc_pcm_component_trigger(struct snd_pcm_substream *substream,
469*4882a593Smuzhiyun int cmd);
470*4882a593Smuzhiyun int snd_soc_pcm_component_pm_runtime_get(struct snd_soc_pcm_runtime *rtd,
471*4882a593Smuzhiyun void *stream);
472*4882a593Smuzhiyun void snd_soc_pcm_component_pm_runtime_put(struct snd_soc_pcm_runtime *rtd,
473*4882a593Smuzhiyun void *stream, int rollback);
474*4882a593Smuzhiyun int snd_soc_pcm_component_ack(struct snd_pcm_substream *substream);
475*4882a593Smuzhiyun
476*4882a593Smuzhiyun #endif /* __SOC_COMPONENT_H */
477