14ff1fef1SKuninori Morimoto /* SPDX-License-Identifier: GPL-2.0
24ff1fef1SKuninori Morimoto *
34ff1fef1SKuninori Morimoto * soc-component.h
44ff1fef1SKuninori Morimoto *
545108214SKuninori Morimoto * Copyright (C) 2019 Renesas Electronics Corp.
645108214SKuninori Morimoto * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
74ff1fef1SKuninori Morimoto */
84ff1fef1SKuninori Morimoto #ifndef __SOC_COMPONENT_H
94ff1fef1SKuninori Morimoto #define __SOC_COMPONENT_H
104ff1fef1SKuninori Morimoto
114ff1fef1SKuninori Morimoto #include <sound/soc.h>
124ff1fef1SKuninori Morimoto
134ff1fef1SKuninori Morimoto /*
144ff1fef1SKuninori Morimoto * Component probe and remove ordering levels for components with runtime
154ff1fef1SKuninori Morimoto * dependencies.
164ff1fef1SKuninori Morimoto */
174ff1fef1SKuninori Morimoto #define SND_SOC_COMP_ORDER_FIRST -2
184ff1fef1SKuninori Morimoto #define SND_SOC_COMP_ORDER_EARLY -1
194ff1fef1SKuninori Morimoto #define SND_SOC_COMP_ORDER_NORMAL 0
204ff1fef1SKuninori Morimoto #define SND_SOC_COMP_ORDER_LATE 1
214ff1fef1SKuninori Morimoto #define SND_SOC_COMP_ORDER_LAST 2
224ff1fef1SKuninori Morimoto
234ff1fef1SKuninori Morimoto #define for_each_comp_order(order) \
244ff1fef1SKuninori Morimoto for (order = SND_SOC_COMP_ORDER_FIRST; \
254ff1fef1SKuninori Morimoto order <= SND_SOC_COMP_ORDER_LAST; \
264ff1fef1SKuninori Morimoto order++)
274ff1fef1SKuninori Morimoto
284ff1fef1SKuninori Morimoto /* component interface */
29c6cb522cSKuninori Morimoto struct snd_compress_ops {
30c6cb522cSKuninori Morimoto int (*open)(struct snd_soc_component *component,
31c6cb522cSKuninori Morimoto struct snd_compr_stream *stream);
32c6cb522cSKuninori Morimoto int (*free)(struct snd_soc_component *component,
33c6cb522cSKuninori Morimoto struct snd_compr_stream *stream);
34c6cb522cSKuninori Morimoto int (*set_params)(struct snd_soc_component *component,
35c6cb522cSKuninori Morimoto struct snd_compr_stream *stream,
36c6cb522cSKuninori Morimoto struct snd_compr_params *params);
37c6cb522cSKuninori Morimoto int (*get_params)(struct snd_soc_component *component,
38c6cb522cSKuninori Morimoto struct snd_compr_stream *stream,
39c6cb522cSKuninori Morimoto struct snd_codec *params);
40c6cb522cSKuninori Morimoto int (*set_metadata)(struct snd_soc_component *component,
41c6cb522cSKuninori Morimoto struct snd_compr_stream *stream,
42c6cb522cSKuninori Morimoto struct snd_compr_metadata *metadata);
43c6cb522cSKuninori Morimoto int (*get_metadata)(struct snd_soc_component *component,
44c6cb522cSKuninori Morimoto struct snd_compr_stream *stream,
45c6cb522cSKuninori Morimoto struct snd_compr_metadata *metadata);
46c6cb522cSKuninori Morimoto int (*trigger)(struct snd_soc_component *component,
47c6cb522cSKuninori Morimoto struct snd_compr_stream *stream, int cmd);
48c6cb522cSKuninori Morimoto int (*pointer)(struct snd_soc_component *component,
49c6cb522cSKuninori Morimoto struct snd_compr_stream *stream,
50c6cb522cSKuninori Morimoto struct snd_compr_tstamp *tstamp);
51c6cb522cSKuninori Morimoto int (*copy)(struct snd_soc_component *component,
52c6cb522cSKuninori Morimoto struct snd_compr_stream *stream, char __user *buf,
53c6cb522cSKuninori Morimoto size_t count);
54c6cb522cSKuninori Morimoto int (*mmap)(struct snd_soc_component *component,
55c6cb522cSKuninori Morimoto struct snd_compr_stream *stream,
56c6cb522cSKuninori Morimoto struct vm_area_struct *vma);
57c6cb522cSKuninori Morimoto int (*ack)(struct snd_soc_component *component,
58c6cb522cSKuninori Morimoto struct snd_compr_stream *stream, size_t bytes);
59c6cb522cSKuninori Morimoto int (*get_caps)(struct snd_soc_component *component,
60c6cb522cSKuninori Morimoto struct snd_compr_stream *stream,
61c6cb522cSKuninori Morimoto struct snd_compr_caps *caps);
62c6cb522cSKuninori Morimoto int (*get_codec_caps)(struct snd_soc_component *component,
63c6cb522cSKuninori Morimoto struct snd_compr_stream *stream,
64c6cb522cSKuninori Morimoto struct snd_compr_codec_caps *codec);
65c6cb522cSKuninori Morimoto };
66c6cb522cSKuninori Morimoto
674ff1fef1SKuninori Morimoto struct snd_soc_component_driver {
684ff1fef1SKuninori Morimoto const char *name;
694ff1fef1SKuninori Morimoto
704ff1fef1SKuninori Morimoto /* Default control and setup, added after probe() is run */
714ff1fef1SKuninori Morimoto const struct snd_kcontrol_new *controls;
724ff1fef1SKuninori Morimoto unsigned int num_controls;
734ff1fef1SKuninori Morimoto const struct snd_soc_dapm_widget *dapm_widgets;
744ff1fef1SKuninori Morimoto unsigned int num_dapm_widgets;
754ff1fef1SKuninori Morimoto const struct snd_soc_dapm_route *dapm_routes;
764ff1fef1SKuninori Morimoto unsigned int num_dapm_routes;
774ff1fef1SKuninori Morimoto
784ff1fef1SKuninori Morimoto int (*probe)(struct snd_soc_component *component);
794ff1fef1SKuninori Morimoto void (*remove)(struct snd_soc_component *component);
804ff1fef1SKuninori Morimoto int (*suspend)(struct snd_soc_component *component);
814ff1fef1SKuninori Morimoto int (*resume)(struct snd_soc_component *component);
824ff1fef1SKuninori Morimoto
834ff1fef1SKuninori Morimoto unsigned int (*read)(struct snd_soc_component *component,
844ff1fef1SKuninori Morimoto unsigned int reg);
854ff1fef1SKuninori Morimoto int (*write)(struct snd_soc_component *component,
864ff1fef1SKuninori Morimoto unsigned int reg, unsigned int val);
874ff1fef1SKuninori Morimoto
884ff1fef1SKuninori Morimoto /* pcm creation and destruction */
89c64bfc90SKuninori Morimoto int (*pcm_construct)(struct snd_soc_component *component,
90c64bfc90SKuninori Morimoto struct snd_soc_pcm_runtime *rtd);
91c64bfc90SKuninori Morimoto void (*pcm_destruct)(struct snd_soc_component *component,
92c64bfc90SKuninori Morimoto struct snd_pcm *pcm);
93c64bfc90SKuninori Morimoto
944ff1fef1SKuninori Morimoto /* component wide operations */
954ff1fef1SKuninori Morimoto int (*set_sysclk)(struct snd_soc_component *component,
964ff1fef1SKuninori Morimoto int clk_id, int source, unsigned int freq, int dir);
974ff1fef1SKuninori Morimoto int (*set_pll)(struct snd_soc_component *component, int pll_id,
984ff1fef1SKuninori Morimoto int source, unsigned int freq_in, unsigned int freq_out);
994ff1fef1SKuninori Morimoto int (*set_jack)(struct snd_soc_component *component,
1004ff1fef1SKuninori Morimoto struct snd_soc_jack *jack, void *data);
101df55122bSAstrid Rost int (*get_jack_type)(struct snd_soc_component *component);
1024ff1fef1SKuninori Morimoto
1034ff1fef1SKuninori Morimoto /* DT */
1044ff1fef1SKuninori Morimoto int (*of_xlate_dai_name)(struct snd_soc_component *component,
105933f98beSKrzysztof Kozlowski const struct of_phandle_args *args,
1064ff1fef1SKuninori Morimoto const char **dai_name);
1074ff1fef1SKuninori Morimoto int (*of_xlate_dai_id)(struct snd_soc_component *comment,
1084ff1fef1SKuninori Morimoto struct device_node *endpoint);
1094ff1fef1SKuninori Morimoto void (*seq_notifier)(struct snd_soc_component *component,
1104ff1fef1SKuninori Morimoto enum snd_soc_dapm_type type, int subseq);
1114ff1fef1SKuninori Morimoto int (*stream_event)(struct snd_soc_component *component, int event);
1124ff1fef1SKuninori Morimoto int (*set_bias_level)(struct snd_soc_component *component,
1134ff1fef1SKuninori Morimoto enum snd_soc_bias_level level);
1144ff1fef1SKuninori Morimoto
115e2cb4a14SKuninori Morimoto int (*open)(struct snd_soc_component *component,
116e2cb4a14SKuninori Morimoto struct snd_pcm_substream *substream);
117e2cb4a14SKuninori Morimoto int (*close)(struct snd_soc_component *component,
118e2cb4a14SKuninori Morimoto struct snd_pcm_substream *substream);
119e2cb4a14SKuninori Morimoto int (*ioctl)(struct snd_soc_component *component,
120e2cb4a14SKuninori Morimoto struct snd_pcm_substream *substream,
121e2cb4a14SKuninori Morimoto unsigned int cmd, void *arg);
122e2cb4a14SKuninori Morimoto int (*hw_params)(struct snd_soc_component *component,
123e2cb4a14SKuninori Morimoto struct snd_pcm_substream *substream,
124e2cb4a14SKuninori Morimoto struct snd_pcm_hw_params *params);
125e2cb4a14SKuninori Morimoto int (*hw_free)(struct snd_soc_component *component,
126e2cb4a14SKuninori Morimoto struct snd_pcm_substream *substream);
127e2cb4a14SKuninori Morimoto int (*prepare)(struct snd_soc_component *component,
128e2cb4a14SKuninori Morimoto struct snd_pcm_substream *substream);
129e2cb4a14SKuninori Morimoto int (*trigger)(struct snd_soc_component *component,
130e2cb4a14SKuninori Morimoto struct snd_pcm_substream *substream, int cmd);
1311e5ddb6bSTakashi Iwai int (*sync_stop)(struct snd_soc_component *component,
1321e5ddb6bSTakashi Iwai struct snd_pcm_substream *substream);
133e2cb4a14SKuninori Morimoto snd_pcm_uframes_t (*pointer)(struct snd_soc_component *component,
134e2cb4a14SKuninori Morimoto struct snd_pcm_substream *substream);
135e2cb4a14SKuninori Morimoto int (*get_time_info)(struct snd_soc_component *component,
136fcae40c9SBaolin Wang struct snd_pcm_substream *substream, struct timespec64 *system_ts,
137fcae40c9SBaolin Wang struct timespec64 *audio_ts,
138e2cb4a14SKuninori Morimoto struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
139e2cb4a14SKuninori Morimoto struct snd_pcm_audio_tstamp_report *audio_tstamp_report);
14066201cacSTakashi Iwai int (*copy)(struct snd_soc_component *component,
14166201cacSTakashi Iwai struct snd_pcm_substream *substream, int channel,
142*ef98a488STakashi Iwai unsigned long pos, struct iov_iter *iter,
14366201cacSTakashi Iwai unsigned long bytes);
144e2cb4a14SKuninori Morimoto struct page *(*page)(struct snd_soc_component *component,
145e2cb4a14SKuninori Morimoto struct snd_pcm_substream *substream,
146e2cb4a14SKuninori Morimoto unsigned long offset);
147e2cb4a14SKuninori Morimoto int (*mmap)(struct snd_soc_component *component,
148e2cb4a14SKuninori Morimoto struct snd_pcm_substream *substream,
149e2cb4a14SKuninori Morimoto struct vm_area_struct *vma);
1508bdfc045SShengjiu Wang int (*ack)(struct snd_soc_component *component,
1518bdfc045SShengjiu Wang struct snd_pcm_substream *substream);
152403f830eSKuninori Morimoto snd_pcm_sframes_t (*delay)(struct snd_soc_component *component,
153403f830eSKuninori Morimoto struct snd_pcm_substream *substream);
154e2cb4a14SKuninori Morimoto
155c6cb522cSKuninori Morimoto const struct snd_compress_ops *compress_ops;
1564ff1fef1SKuninori Morimoto
1574ff1fef1SKuninori Morimoto /* probe ordering - for components with runtime dependencies */
1584ff1fef1SKuninori Morimoto int probe_order;
1594ff1fef1SKuninori Morimoto int remove_order;
1604ff1fef1SKuninori Morimoto
1614ff1fef1SKuninori Morimoto /*
162356caf66SKuninori Morimoto * soc_pcm_trigger() start/stop sequence.
163356caf66SKuninori Morimoto * see also
164356caf66SKuninori Morimoto * snd_soc_dai_link
165356caf66SKuninori Morimoto * soc_pcm_trigger()
166356caf66SKuninori Morimoto */
167356caf66SKuninori Morimoto enum snd_soc_trigger_order trigger_start;
168356caf66SKuninori Morimoto enum snd_soc_trigger_order trigger_stop;
169356caf66SKuninori Morimoto
170356caf66SKuninori Morimoto /*
1714ff1fef1SKuninori Morimoto * signal if the module handling the component should not be removed
1724ff1fef1SKuninori Morimoto * if a pcm is open. Setting this would prevent the module
1734ff1fef1SKuninori Morimoto * refcount being incremented in probe() but allow it be incremented
1744ff1fef1SKuninori Morimoto * when a pcm is opened and decremented when it is closed.
1754ff1fef1SKuninori Morimoto */
1764ff1fef1SKuninori Morimoto unsigned int module_get_upon_open:1;
1774ff1fef1SKuninori Morimoto
1784ff1fef1SKuninori Morimoto /* bits */
1794ff1fef1SKuninori Morimoto unsigned int idle_bias_on:1;
1804ff1fef1SKuninori Morimoto unsigned int suspend_bias_off:1;
1814ff1fef1SKuninori Morimoto unsigned int use_pmdown_time:1; /* care pmdown_time at stop */
1825c832efdSCharles Keepax /*
1835c832efdSCharles Keepax * Indicates that the component does not care about the endianness of
1845c832efdSCharles Keepax * PCM audio data and the core will ensure that both LE and BE variants
1855c832efdSCharles Keepax * of each used format are present. Typically this is because the
1865c832efdSCharles Keepax * component sits behind a bus that abstracts away the endian of the
1875c832efdSCharles Keepax * original data, ie. one for which the transmission endian is defined
1885c832efdSCharles Keepax * (I2S/SLIMbus/SoundWire), or the concept of endian doesn't exist (PDM,
1895c832efdSCharles Keepax * analogue).
1905c832efdSCharles Keepax */
1914ff1fef1SKuninori Morimoto unsigned int endianness:1;
1921c348f74SCharles Keepax unsigned int legacy_dai_naming:1;
1934ff1fef1SKuninori Morimoto
1944ff1fef1SKuninori Morimoto /* this component uses topology and ignore machine driver FEs */
1954ff1fef1SKuninori Morimoto const char *ignore_machine;
1964ff1fef1SKuninori Morimoto const char *topology_name_prefix;
1974ff1fef1SKuninori Morimoto int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
1984ff1fef1SKuninori Morimoto struct snd_pcm_hw_params *params);
1994ff1fef1SKuninori Morimoto bool use_dai_pcm_id; /* use DAI link PCM ID as PCM device number */
2004ff1fef1SKuninori Morimoto int be_pcm_base; /* base device ID for all BE PCMs */
201d462f6edSHeiner Kallweit
202d462f6edSHeiner Kallweit #ifdef CONFIG_DEBUG_FS
203d462f6edSHeiner Kallweit const char *debugfs_prefix;
204d462f6edSHeiner Kallweit #endif
2054ff1fef1SKuninori Morimoto };
2064ff1fef1SKuninori Morimoto
2074ff1fef1SKuninori Morimoto struct snd_soc_component {
2084ff1fef1SKuninori Morimoto const char *name;
2094ff1fef1SKuninori Morimoto int id;
2104ff1fef1SKuninori Morimoto const char *name_prefix;
2114ff1fef1SKuninori Morimoto struct device *dev;
2124ff1fef1SKuninori Morimoto struct snd_soc_card *card;
2134ff1fef1SKuninori Morimoto
2144ff1fef1SKuninori Morimoto unsigned int active;
2154ff1fef1SKuninori Morimoto
2164ff1fef1SKuninori Morimoto unsigned int suspended:1; /* is in suspend PM state */
2174ff1fef1SKuninori Morimoto
2184ff1fef1SKuninori Morimoto struct list_head list;
2194ff1fef1SKuninori Morimoto struct list_head card_aux_list; /* for auxiliary bound components */
2204ff1fef1SKuninori Morimoto struct list_head card_list;
2214ff1fef1SKuninori Morimoto
2224ff1fef1SKuninori Morimoto const struct snd_soc_component_driver *driver;
2234ff1fef1SKuninori Morimoto
2244ff1fef1SKuninori Morimoto struct list_head dai_list;
2254ff1fef1SKuninori Morimoto int num_dai;
2264ff1fef1SKuninori Morimoto
2274ff1fef1SKuninori Morimoto struct regmap *regmap;
2284ff1fef1SKuninori Morimoto int val_bytes;
2294ff1fef1SKuninori Morimoto
2304ff1fef1SKuninori Morimoto struct mutex io_mutex;
2314ff1fef1SKuninori Morimoto
2324ff1fef1SKuninori Morimoto /* attached dynamic objects */
2334ff1fef1SKuninori Morimoto struct list_head dobj_list;
2344ff1fef1SKuninori Morimoto
2354ff1fef1SKuninori Morimoto /*
2364ff1fef1SKuninori Morimoto * DO NOT use any of the fields below in drivers, they are temporary and
2374ff1fef1SKuninori Morimoto * are going to be removed again soon. If you use them in driver code
2384ff1fef1SKuninori Morimoto * the driver will be marked as BROKEN when these fields are removed.
2394ff1fef1SKuninori Morimoto */
2404ff1fef1SKuninori Morimoto
2414ff1fef1SKuninori Morimoto /* Don't use these, use snd_soc_component_get_dapm() */
2424ff1fef1SKuninori Morimoto struct snd_soc_dapm_context dapm;
2434ff1fef1SKuninori Morimoto
2444ff1fef1SKuninori Morimoto /* machine specific init */
2454ff1fef1SKuninori Morimoto int (*init)(struct snd_soc_component *component);
2464ff1fef1SKuninori Morimoto
24751aff91aSKuninori Morimoto /* function mark */
248a739fdc2SPeter Ujfalusi void *mark_module;
24951aff91aSKuninori Morimoto struct snd_pcm_substream *mark_open;
2503a36a64aSKuninori Morimoto struct snd_pcm_substream *mark_hw_params;
2516374f493SKuninori Morimoto struct snd_pcm_substream *mark_trigger;
252f94ba9acSKuninori Morimoto struct snd_compr_stream *mark_compr_open;
253939a5cfbSKuninori Morimoto void *mark_pm;
25451aff91aSKuninori Morimoto
2554ff1fef1SKuninori Morimoto struct dentry *debugfs_root;
2564ff1fef1SKuninori Morimoto const char *debugfs_prefix;
2574ff1fef1SKuninori Morimoto };
2584ff1fef1SKuninori Morimoto
2594ff1fef1SKuninori Morimoto #define for_each_component_dais(component, dai)\
2604ff1fef1SKuninori Morimoto list_for_each_entry(dai, &(component)->dai_list, list)
2614ff1fef1SKuninori Morimoto #define for_each_component_dais_safe(component, dai, _dai)\
2624ff1fef1SKuninori Morimoto list_for_each_entry_safe(dai, _dai, &(component)->dai_list, list)
2634ff1fef1SKuninori Morimoto
2644ff1fef1SKuninori Morimoto /**
2654ff1fef1SKuninori Morimoto * snd_soc_dapm_to_component() - Casts a DAPM context to the component it is
2664ff1fef1SKuninori Morimoto * embedded in
2674ff1fef1SKuninori Morimoto * @dapm: The DAPM context to cast to the component
2684ff1fef1SKuninori Morimoto *
2694ff1fef1SKuninori Morimoto * This function must only be used on DAPM contexts that are known to be part of
2704ff1fef1SKuninori Morimoto * a component (e.g. in a component driver). Otherwise the behavior is
2714ff1fef1SKuninori Morimoto * undefined.
2724ff1fef1SKuninori Morimoto */
snd_soc_dapm_to_component(struct snd_soc_dapm_context * dapm)2734ff1fef1SKuninori Morimoto static inline struct snd_soc_component *snd_soc_dapm_to_component(
2744ff1fef1SKuninori Morimoto struct snd_soc_dapm_context *dapm)
2754ff1fef1SKuninori Morimoto {
2764ff1fef1SKuninori Morimoto return container_of(dapm, struct snd_soc_component, dapm);
2774ff1fef1SKuninori Morimoto }
2784ff1fef1SKuninori Morimoto
2794ff1fef1SKuninori Morimoto /**
2804ff1fef1SKuninori Morimoto * snd_soc_component_get_dapm() - Returns the DAPM context associated with a
2814ff1fef1SKuninori Morimoto * component
2824ff1fef1SKuninori Morimoto * @component: The component for which to get the DAPM context
2834ff1fef1SKuninori Morimoto */
snd_soc_component_get_dapm(struct snd_soc_component * component)2844ff1fef1SKuninori Morimoto static inline struct snd_soc_dapm_context *snd_soc_component_get_dapm(
2854ff1fef1SKuninori Morimoto struct snd_soc_component *component)
2864ff1fef1SKuninori Morimoto {
2874ff1fef1SKuninori Morimoto return &component->dapm;
2884ff1fef1SKuninori Morimoto }
2894ff1fef1SKuninori Morimoto
2904ff1fef1SKuninori Morimoto /**
2914ff1fef1SKuninori Morimoto * snd_soc_component_init_bias_level() - Initialize COMPONENT DAPM bias level
2924ff1fef1SKuninori Morimoto * @component: The COMPONENT for which to initialize the DAPM bias level
2934ff1fef1SKuninori Morimoto * @level: The DAPM level to initialize to
2944ff1fef1SKuninori Morimoto *
2954ff1fef1SKuninori Morimoto * Initializes the COMPONENT DAPM bias level. See snd_soc_dapm_init_bias_level()
2964ff1fef1SKuninori Morimoto */
2974ff1fef1SKuninori Morimoto static inline void
snd_soc_component_init_bias_level(struct snd_soc_component * component,enum snd_soc_bias_level level)2984ff1fef1SKuninori Morimoto snd_soc_component_init_bias_level(struct snd_soc_component *component,
2994ff1fef1SKuninori Morimoto enum snd_soc_bias_level level)
3004ff1fef1SKuninori Morimoto {
3014ff1fef1SKuninori Morimoto snd_soc_dapm_init_bias_level(
3024ff1fef1SKuninori Morimoto snd_soc_component_get_dapm(component), level);
3034ff1fef1SKuninori Morimoto }
3044ff1fef1SKuninori Morimoto
3054ff1fef1SKuninori Morimoto /**
3064ff1fef1SKuninori Morimoto * snd_soc_component_get_bias_level() - Get current COMPONENT DAPM bias level
3074ff1fef1SKuninori Morimoto * @component: The COMPONENT for which to get the DAPM bias level
3084ff1fef1SKuninori Morimoto *
3094ff1fef1SKuninori Morimoto * Returns: The current DAPM bias level of the COMPONENT.
3104ff1fef1SKuninori Morimoto */
3114ff1fef1SKuninori Morimoto static inline enum snd_soc_bias_level
snd_soc_component_get_bias_level(struct snd_soc_component * component)3124ff1fef1SKuninori Morimoto snd_soc_component_get_bias_level(struct snd_soc_component *component)
3134ff1fef1SKuninori Morimoto {
3144ff1fef1SKuninori Morimoto return snd_soc_dapm_get_bias_level(
3154ff1fef1SKuninori Morimoto snd_soc_component_get_dapm(component));
3164ff1fef1SKuninori Morimoto }
3174ff1fef1SKuninori Morimoto
3184ff1fef1SKuninori Morimoto /**
3194ff1fef1SKuninori Morimoto * snd_soc_component_force_bias_level() - Set the COMPONENT DAPM bias level
3204ff1fef1SKuninori Morimoto * @component: The COMPONENT for which to set the level
3214ff1fef1SKuninori Morimoto * @level: The level to set to
3224ff1fef1SKuninori Morimoto *
3234ff1fef1SKuninori Morimoto * Forces the COMPONENT bias level to a specific state. See
3244ff1fef1SKuninori Morimoto * snd_soc_dapm_force_bias_level().
3254ff1fef1SKuninori Morimoto */
3264ff1fef1SKuninori Morimoto static inline int
snd_soc_component_force_bias_level(struct snd_soc_component * component,enum snd_soc_bias_level level)3274ff1fef1SKuninori Morimoto snd_soc_component_force_bias_level(struct snd_soc_component *component,
3284ff1fef1SKuninori Morimoto enum snd_soc_bias_level level)
3294ff1fef1SKuninori Morimoto {
3304ff1fef1SKuninori Morimoto return snd_soc_dapm_force_bias_level(
3314ff1fef1SKuninori Morimoto snd_soc_component_get_dapm(component),
3324ff1fef1SKuninori Morimoto level);
3334ff1fef1SKuninori Morimoto }
3344ff1fef1SKuninori Morimoto
3354ff1fef1SKuninori Morimoto /**
3364ff1fef1SKuninori Morimoto * snd_soc_dapm_kcontrol_component() - Returns the component associated to a
3374ff1fef1SKuninori Morimoto * kcontrol
3384ff1fef1SKuninori Morimoto * @kcontrol: The kcontrol
3394ff1fef1SKuninori Morimoto *
3404ff1fef1SKuninori Morimoto * This function must only be used on DAPM contexts that are known to be part of
3414ff1fef1SKuninori Morimoto * a COMPONENT (e.g. in a COMPONENT driver). Otherwise the behavior is undefined
3424ff1fef1SKuninori Morimoto */
snd_soc_dapm_kcontrol_component(struct snd_kcontrol * kcontrol)3434ff1fef1SKuninori Morimoto static inline struct snd_soc_component *snd_soc_dapm_kcontrol_component(
3444ff1fef1SKuninori Morimoto struct snd_kcontrol *kcontrol)
3454ff1fef1SKuninori Morimoto {
3464ff1fef1SKuninori Morimoto return snd_soc_dapm_to_component(snd_soc_dapm_kcontrol_dapm(kcontrol));
3474ff1fef1SKuninori Morimoto }
3484ff1fef1SKuninori Morimoto
3494ff1fef1SKuninori Morimoto /**
3504ff1fef1SKuninori Morimoto * snd_soc_component_cache_sync() - Sync the register cache with the hardware
3514ff1fef1SKuninori Morimoto * @component: COMPONENT to sync
3524ff1fef1SKuninori Morimoto *
3534ff1fef1SKuninori Morimoto * Note: This function will call regcache_sync()
3544ff1fef1SKuninori Morimoto */
snd_soc_component_cache_sync(struct snd_soc_component * component)3554ff1fef1SKuninori Morimoto static inline int snd_soc_component_cache_sync(
3564ff1fef1SKuninori Morimoto struct snd_soc_component *component)
3574ff1fef1SKuninori Morimoto {
3584ff1fef1SKuninori Morimoto return regcache_sync(component->regmap);
3594ff1fef1SKuninori Morimoto }
3604ff1fef1SKuninori Morimoto
361257c4dacSKuninori Morimoto void snd_soc_component_set_aux(struct snd_soc_component *component,
362257c4dacSKuninori Morimoto struct snd_soc_aux_dev *aux);
363257c4dacSKuninori Morimoto int snd_soc_component_init(struct snd_soc_component *component);
3648f1a1681SKuninori Morimoto int snd_soc_component_is_dummy(struct snd_soc_component *component);
365536aba1dSKuninori Morimoto
3664ff1fef1SKuninori Morimoto /* component IO */
367cf6e26c7SKuninori Morimoto unsigned int snd_soc_component_read(struct snd_soc_component *component,
3684ff1fef1SKuninori Morimoto unsigned int reg);
3694ff1fef1SKuninori Morimoto int snd_soc_component_write(struct snd_soc_component *component,
3704ff1fef1SKuninori Morimoto unsigned int reg, unsigned int val);
3714ff1fef1SKuninori Morimoto int snd_soc_component_update_bits(struct snd_soc_component *component,
3724ff1fef1SKuninori Morimoto unsigned int reg, unsigned int mask,
3734ff1fef1SKuninori Morimoto unsigned int val);
3744ff1fef1SKuninori Morimoto int snd_soc_component_update_bits_async(struct snd_soc_component *component,
3754ff1fef1SKuninori Morimoto unsigned int reg, unsigned int mask,
3764ff1fef1SKuninori Morimoto unsigned int val);
3774ff1fef1SKuninori Morimoto void snd_soc_component_async_complete(struct snd_soc_component *component);
3784ff1fef1SKuninori Morimoto int snd_soc_component_test_bits(struct snd_soc_component *component,
3794ff1fef1SKuninori Morimoto unsigned int reg, unsigned int mask,
3804ff1fef1SKuninori Morimoto unsigned int value);
3814ff1fef1SKuninori Morimoto
3821da0b989SSrinivas Kandagatla unsigned int snd_soc_component_read_field(struct snd_soc_component *component,
3831da0b989SSrinivas Kandagatla unsigned int reg, unsigned int mask);
3841da0b989SSrinivas Kandagatla int snd_soc_component_write_field(struct snd_soc_component *component,
3851da0b989SSrinivas Kandagatla unsigned int reg, unsigned int mask,
3861da0b989SSrinivas Kandagatla unsigned int val);
3871da0b989SSrinivas Kandagatla
3884ff1fef1SKuninori Morimoto /* component wide operations */
3894ff1fef1SKuninori Morimoto int snd_soc_component_set_sysclk(struct snd_soc_component *component,
3904ff1fef1SKuninori Morimoto int clk_id, int source,
3914ff1fef1SKuninori Morimoto unsigned int freq, int dir);
3924ff1fef1SKuninori Morimoto int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id,
3934ff1fef1SKuninori Morimoto int source, unsigned int freq_in,
3944ff1fef1SKuninori Morimoto unsigned int freq_out);
3954ff1fef1SKuninori Morimoto int snd_soc_component_set_jack(struct snd_soc_component *component,
3964ff1fef1SKuninori Morimoto struct snd_soc_jack *jack, void *data);
397df55122bSAstrid Rost int snd_soc_component_get_jack_type(struct snd_soc_component *component);
3984ff1fef1SKuninori Morimoto
3999d415fbfSKuninori Morimoto void snd_soc_component_seq_notifier(struct snd_soc_component *component,
4009d415fbfSKuninori Morimoto enum snd_soc_dapm_type type, int subseq);
4018e2a990dSKuninori Morimoto int snd_soc_component_stream_event(struct snd_soc_component *component,
4028e2a990dSKuninori Morimoto int event);
4037951b146SKuninori Morimoto int snd_soc_component_set_bias_level(struct snd_soc_component *component,
4047951b146SKuninori Morimoto enum snd_soc_bias_level level);
4059d415fbfSKuninori Morimoto
406c7d75b59SKuninori Morimoto void snd_soc_component_setup_regmap(struct snd_soc_component *component);
4074ff1fef1SKuninori Morimoto #ifdef CONFIG_REGMAP
4084ff1fef1SKuninori Morimoto void snd_soc_component_init_regmap(struct snd_soc_component *component,
4094ff1fef1SKuninori Morimoto struct regmap *regmap);
4104ff1fef1SKuninori Morimoto void snd_soc_component_exit_regmap(struct snd_soc_component *component);
4114ff1fef1SKuninori Morimoto #endif
4124ff1fef1SKuninori Morimoto
4134a81e8f3SKuninori Morimoto #define snd_soc_component_module_get_when_probe(component)\
41451aff91aSKuninori Morimoto snd_soc_component_module_get(component, NULL, 0)
41551aff91aSKuninori Morimoto #define snd_soc_component_module_get_when_open(component, substream) \
41651aff91aSKuninori Morimoto snd_soc_component_module_get(component, substream, 1)
4174a81e8f3SKuninori Morimoto int snd_soc_component_module_get(struct snd_soc_component *component,
418a739fdc2SPeter Ujfalusi void *mark, int upon_open);
4194a81e8f3SKuninori Morimoto #define snd_soc_component_module_put_when_remove(component) \
42051aff91aSKuninori Morimoto snd_soc_component_module_put(component, NULL, 0, 0)
42151aff91aSKuninori Morimoto #define snd_soc_component_module_put_when_close(component, substream, rollback) \
42251aff91aSKuninori Morimoto snd_soc_component_module_put(component, substream, 1, rollback)
4234a81e8f3SKuninori Morimoto void snd_soc_component_module_put(struct snd_soc_component *component,
424a739fdc2SPeter Ujfalusi void *mark, int upon_open, int rollback);
4254a81e8f3SKuninori Morimoto
snd_soc_component_set_drvdata(struct snd_soc_component * c,void * data)4264ff1fef1SKuninori Morimoto static inline void snd_soc_component_set_drvdata(struct snd_soc_component *c,
4274ff1fef1SKuninori Morimoto void *data)
4284ff1fef1SKuninori Morimoto {
4294ff1fef1SKuninori Morimoto dev_set_drvdata(c->dev, data);
4304ff1fef1SKuninori Morimoto }
4314ff1fef1SKuninori Morimoto
snd_soc_component_get_drvdata(struct snd_soc_component * c)4324ff1fef1SKuninori Morimoto static inline void *snd_soc_component_get_drvdata(struct snd_soc_component *c)
4334ff1fef1SKuninori Morimoto {
4344ff1fef1SKuninori Morimoto return dev_get_drvdata(c->dev);
4354ff1fef1SKuninori Morimoto }
4364ff1fef1SKuninori Morimoto
437488b2ca5SKuninori Morimoto static inline unsigned int
snd_soc_component_active(struct snd_soc_component * component)438488b2ca5SKuninori Morimoto snd_soc_component_active(struct snd_soc_component *component)
439488b2ca5SKuninori Morimoto {
440488b2ca5SKuninori Morimoto return component->active;
441488b2ca5SKuninori Morimoto }
442488b2ca5SKuninori Morimoto
4434ff1fef1SKuninori Morimoto /* component pin */
4444ff1fef1SKuninori Morimoto int snd_soc_component_enable_pin(struct snd_soc_component *component,
4454ff1fef1SKuninori Morimoto const char *pin);
4464ff1fef1SKuninori Morimoto int snd_soc_component_enable_pin_unlocked(struct snd_soc_component *component,
4474ff1fef1SKuninori Morimoto const char *pin);
4484ff1fef1SKuninori Morimoto int snd_soc_component_disable_pin(struct snd_soc_component *component,
4494ff1fef1SKuninori Morimoto const char *pin);
4504ff1fef1SKuninori Morimoto int snd_soc_component_disable_pin_unlocked(struct snd_soc_component *component,
4514ff1fef1SKuninori Morimoto const char *pin);
4524ff1fef1SKuninori Morimoto int snd_soc_component_nc_pin(struct snd_soc_component *component,
4534ff1fef1SKuninori Morimoto const char *pin);
4544ff1fef1SKuninori Morimoto int snd_soc_component_nc_pin_unlocked(struct snd_soc_component *component,
4554ff1fef1SKuninori Morimoto const char *pin);
4564ff1fef1SKuninori Morimoto int snd_soc_component_get_pin_status(struct snd_soc_component *component,
4574ff1fef1SKuninori Morimoto const char *pin);
4584ff1fef1SKuninori Morimoto int snd_soc_component_force_enable_pin(struct snd_soc_component *component,
4594ff1fef1SKuninori Morimoto const char *pin);
4604ff1fef1SKuninori Morimoto int snd_soc_component_force_enable_pin_unlocked(
4614ff1fef1SKuninori Morimoto struct snd_soc_component *component,
4624ff1fef1SKuninori Morimoto const char *pin);
4634ff1fef1SKuninori Morimoto
464ace9ed54SCharles Keepax /* component controls */
465ace9ed54SCharles Keepax int snd_soc_component_notify_control(struct snd_soc_component *component,
466ace9ed54SCharles Keepax const char * const ctl);
467ace9ed54SCharles Keepax
468ae2f4849SKuninori Morimoto /* component driver ops */
469ae2f4849SKuninori Morimoto int snd_soc_component_open(struct snd_soc_component *component,
470ae2f4849SKuninori Morimoto struct snd_pcm_substream *substream);
4713672beb8SKuninori Morimoto int snd_soc_component_close(struct snd_soc_component *component,
47251aff91aSKuninori Morimoto struct snd_pcm_substream *substream,
47351aff91aSKuninori Morimoto int rollback);
47466c51573SKuninori Morimoto void snd_soc_component_suspend(struct snd_soc_component *component);
4759a840cbaSKuninori Morimoto void snd_soc_component_resume(struct snd_soc_component *component);
476e40fadbcSKuninori Morimoto int snd_soc_component_is_suspended(struct snd_soc_component *component);
47708e837ddSKuninori Morimoto int snd_soc_component_probe(struct snd_soc_component *component);
47803b34dd7SKuninori Morimoto void snd_soc_component_remove(struct snd_soc_component *component);
4792c7b1704SKuninori Morimoto int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component,
4802c7b1704SKuninori Morimoto struct device_node *ep);
481a2a34175SKuninori Morimoto int snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component,
482933f98beSKrzysztof Kozlowski const struct of_phandle_args *args,
483a2a34175SKuninori Morimoto const char **dai_name);
484cd46f382SPeter Ujfalusi int snd_soc_component_compr_open(struct snd_soc_component *component,
485cd46f382SPeter Ujfalusi struct snd_compr_stream *cstream);
486cd46f382SPeter Ujfalusi void snd_soc_component_compr_free(struct snd_soc_component *component,
487cd46f382SPeter Ujfalusi struct snd_compr_stream *cstream,
488f94ba9acSKuninori Morimoto int rollback);
48908aee251SKuninori Morimoto int snd_soc_component_compr_trigger(struct snd_compr_stream *cstream, int cmd);
490ff08cf80SKuninori Morimoto int snd_soc_component_compr_set_params(struct snd_compr_stream *cstream,
491ff08cf80SKuninori Morimoto struct snd_compr_params *params);
49277c221ecSKuninori Morimoto int snd_soc_component_compr_get_params(struct snd_compr_stream *cstream,
49377c221ecSKuninori Morimoto struct snd_codec *params);
494d67fcb2dSKuninori Morimoto int snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream,
495d67fcb2dSKuninori Morimoto struct snd_compr_caps *caps);
4960f6fe097SKuninori Morimoto int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream,
4970f6fe097SKuninori Morimoto struct snd_compr_codec_caps *codec);
4980506b885SKuninori Morimoto int snd_soc_component_compr_ack(struct snd_compr_stream *cstream, size_t bytes);
49903ecea64SKuninori Morimoto int snd_soc_component_compr_pointer(struct snd_compr_stream *cstream,
50003ecea64SKuninori Morimoto struct snd_compr_tstamp *tstamp);
501b5852e66SKuninori Morimoto int snd_soc_component_compr_copy(struct snd_compr_stream *cstream,
502b5852e66SKuninori Morimoto char __user *buf, size_t count);
5031b308fb1SKuninori Morimoto int snd_soc_component_compr_set_metadata(struct snd_compr_stream *cstream,
5041b308fb1SKuninori Morimoto struct snd_compr_metadata *metadata);
505bab78c23SKuninori Morimoto int snd_soc_component_compr_get_metadata(struct snd_compr_stream *cstream,
506bab78c23SKuninori Morimoto struct snd_compr_metadata *metadata);
507ae2f4849SKuninori Morimoto
5080035e256SKuninori Morimoto int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
50996a47908SKuninori Morimoto int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
51096a47908SKuninori Morimoto unsigned int cmd, void *arg);
5111e5ddb6bSTakashi Iwai int snd_soc_pcm_component_sync_stop(struct snd_pcm_substream *substream);
51266201cacSTakashi Iwai int snd_soc_pcm_component_copy(struct snd_pcm_substream *substream,
51366201cacSTakashi Iwai int channel, unsigned long pos,
514*ef98a488STakashi Iwai struct iov_iter *iter, unsigned long bytes);
5159c712e4fSKuninori Morimoto struct page *snd_soc_pcm_component_page(struct snd_pcm_substream *substream,
5169c712e4fSKuninori Morimoto unsigned long offset);
517205875e1SKuninori Morimoto int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream,
518205875e1SKuninori Morimoto struct vm_area_struct *vma);
519b2b2afbbSKuninori Morimoto int snd_soc_pcm_component_new(struct snd_soc_pcm_runtime *rtd);
520b2b2afbbSKuninori Morimoto void snd_soc_pcm_component_free(struct snd_soc_pcm_runtime *rtd);
5214f39514fSKuninori Morimoto int snd_soc_pcm_component_prepare(struct snd_pcm_substream *substream);
522e1bafa82SKuninori Morimoto int snd_soc_pcm_component_hw_params(struct snd_pcm_substream *substream,
5233a36a64aSKuninori Morimoto struct snd_pcm_hw_params *params);
52404751119SKuninori Morimoto void snd_soc_pcm_component_hw_free(struct snd_pcm_substream *substream,
5253a36a64aSKuninori Morimoto int rollback);
52632fd1204SKuninori Morimoto int snd_soc_pcm_component_trigger(struct snd_pcm_substream *substream,
5276374f493SKuninori Morimoto int cmd, int rollback);
528939a5cfbSKuninori Morimoto int snd_soc_pcm_component_pm_runtime_get(struct snd_soc_pcm_runtime *rtd,
529939a5cfbSKuninori Morimoto void *stream);
530939a5cfbSKuninori Morimoto void snd_soc_pcm_component_pm_runtime_put(struct snd_soc_pcm_runtime *rtd,
531939a5cfbSKuninori Morimoto void *stream, int rollback);
5328bdfc045SShengjiu Wang int snd_soc_pcm_component_ack(struct snd_pcm_substream *substream);
533403f830eSKuninori Morimoto void snd_soc_pcm_component_delay(struct snd_pcm_substream *substream,
534403f830eSKuninori Morimoto snd_pcm_sframes_t *cpu_delay, snd_pcm_sframes_t *codec_delay);
5350035e256SKuninori Morimoto
5364ff1fef1SKuninori Morimoto #endif /* __SOC_COMPONENT_H */
537