162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci *
362306a36Sopenharmony_ci * soc-component.h
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2019 Renesas Electronics Corp.
662306a36Sopenharmony_ci * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci#ifndef __SOC_COMPONENT_H
962306a36Sopenharmony_ci#define __SOC_COMPONENT_H
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include <sound/soc.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci/*
1462306a36Sopenharmony_ci * Component probe and remove ordering levels for components with runtime
1562306a36Sopenharmony_ci * dependencies.
1662306a36Sopenharmony_ci */
1762306a36Sopenharmony_ci#define SND_SOC_COMP_ORDER_FIRST	-2
1862306a36Sopenharmony_ci#define SND_SOC_COMP_ORDER_EARLY	-1
1962306a36Sopenharmony_ci#define SND_SOC_COMP_ORDER_NORMAL	 0
2062306a36Sopenharmony_ci#define SND_SOC_COMP_ORDER_LATE		 1
2162306a36Sopenharmony_ci#define SND_SOC_COMP_ORDER_LAST		 2
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci#define for_each_comp_order(order)		\
2462306a36Sopenharmony_ci	for (order  = SND_SOC_COMP_ORDER_FIRST;	\
2562306a36Sopenharmony_ci	     order <= SND_SOC_COMP_ORDER_LAST;	\
2662306a36Sopenharmony_ci	     order++)
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci/* component interface */
2962306a36Sopenharmony_cistruct snd_compress_ops {
3062306a36Sopenharmony_ci	int (*open)(struct snd_soc_component *component,
3162306a36Sopenharmony_ci		    struct snd_compr_stream *stream);
3262306a36Sopenharmony_ci	int (*free)(struct snd_soc_component *component,
3362306a36Sopenharmony_ci		    struct snd_compr_stream *stream);
3462306a36Sopenharmony_ci	int (*set_params)(struct snd_soc_component *component,
3562306a36Sopenharmony_ci			  struct snd_compr_stream *stream,
3662306a36Sopenharmony_ci			  struct snd_compr_params *params);
3762306a36Sopenharmony_ci	int (*get_params)(struct snd_soc_component *component,
3862306a36Sopenharmony_ci			  struct snd_compr_stream *stream,
3962306a36Sopenharmony_ci			  struct snd_codec *params);
4062306a36Sopenharmony_ci	int (*set_metadata)(struct snd_soc_component *component,
4162306a36Sopenharmony_ci			    struct snd_compr_stream *stream,
4262306a36Sopenharmony_ci			    struct snd_compr_metadata *metadata);
4362306a36Sopenharmony_ci	int (*get_metadata)(struct snd_soc_component *component,
4462306a36Sopenharmony_ci			    struct snd_compr_stream *stream,
4562306a36Sopenharmony_ci			    struct snd_compr_metadata *metadata);
4662306a36Sopenharmony_ci	int (*trigger)(struct snd_soc_component *component,
4762306a36Sopenharmony_ci		       struct snd_compr_stream *stream, int cmd);
4862306a36Sopenharmony_ci	int (*pointer)(struct snd_soc_component *component,
4962306a36Sopenharmony_ci		       struct snd_compr_stream *stream,
5062306a36Sopenharmony_ci		       struct snd_compr_tstamp *tstamp);
5162306a36Sopenharmony_ci	int (*copy)(struct snd_soc_component *component,
5262306a36Sopenharmony_ci		    struct snd_compr_stream *stream, char __user *buf,
5362306a36Sopenharmony_ci		    size_t count);
5462306a36Sopenharmony_ci	int (*mmap)(struct snd_soc_component *component,
5562306a36Sopenharmony_ci		    struct snd_compr_stream *stream,
5662306a36Sopenharmony_ci		    struct vm_area_struct *vma);
5762306a36Sopenharmony_ci	int (*ack)(struct snd_soc_component *component,
5862306a36Sopenharmony_ci		   struct snd_compr_stream *stream, size_t bytes);
5962306a36Sopenharmony_ci	int (*get_caps)(struct snd_soc_component *component,
6062306a36Sopenharmony_ci			struct snd_compr_stream *stream,
6162306a36Sopenharmony_ci			struct snd_compr_caps *caps);
6262306a36Sopenharmony_ci	int (*get_codec_caps)(struct snd_soc_component *component,
6362306a36Sopenharmony_ci			      struct snd_compr_stream *stream,
6462306a36Sopenharmony_ci			      struct snd_compr_codec_caps *codec);
6562306a36Sopenharmony_ci};
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_cistruct snd_soc_component_driver {
6862306a36Sopenharmony_ci	const char *name;
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci	/* Default control and setup, added after probe() is run */
7162306a36Sopenharmony_ci	const struct snd_kcontrol_new *controls;
7262306a36Sopenharmony_ci	unsigned int num_controls;
7362306a36Sopenharmony_ci	const struct snd_soc_dapm_widget *dapm_widgets;
7462306a36Sopenharmony_ci	unsigned int num_dapm_widgets;
7562306a36Sopenharmony_ci	const struct snd_soc_dapm_route *dapm_routes;
7662306a36Sopenharmony_ci	unsigned int num_dapm_routes;
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci	int (*probe)(struct snd_soc_component *component);
7962306a36Sopenharmony_ci	void (*remove)(struct snd_soc_component *component);
8062306a36Sopenharmony_ci	int (*suspend)(struct snd_soc_component *component);
8162306a36Sopenharmony_ci	int (*resume)(struct snd_soc_component *component);
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci	unsigned int (*read)(struct snd_soc_component *component,
8462306a36Sopenharmony_ci			     unsigned int reg);
8562306a36Sopenharmony_ci	int (*write)(struct snd_soc_component *component,
8662306a36Sopenharmony_ci		     unsigned int reg, unsigned int val);
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci	/* pcm creation and destruction */
8962306a36Sopenharmony_ci	int (*pcm_construct)(struct snd_soc_component *component,
9062306a36Sopenharmony_ci			     struct snd_soc_pcm_runtime *rtd);
9162306a36Sopenharmony_ci	void (*pcm_destruct)(struct snd_soc_component *component,
9262306a36Sopenharmony_ci			     struct snd_pcm *pcm);
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci	/* component wide operations */
9562306a36Sopenharmony_ci	int (*set_sysclk)(struct snd_soc_component *component,
9662306a36Sopenharmony_ci			  int clk_id, int source, unsigned int freq, int dir);
9762306a36Sopenharmony_ci	int (*set_pll)(struct snd_soc_component *component, int pll_id,
9862306a36Sopenharmony_ci		       int source, unsigned int freq_in, unsigned int freq_out);
9962306a36Sopenharmony_ci	int (*set_jack)(struct snd_soc_component *component,
10062306a36Sopenharmony_ci			struct snd_soc_jack *jack,  void *data);
10162306a36Sopenharmony_ci	int (*get_jack_type)(struct snd_soc_component *component);
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci	/* DT */
10462306a36Sopenharmony_ci	int (*of_xlate_dai_name)(struct snd_soc_component *component,
10562306a36Sopenharmony_ci				 const struct of_phandle_args *args,
10662306a36Sopenharmony_ci				 const char **dai_name);
10762306a36Sopenharmony_ci	int (*of_xlate_dai_id)(struct snd_soc_component *comment,
10862306a36Sopenharmony_ci			       struct device_node *endpoint);
10962306a36Sopenharmony_ci	void (*seq_notifier)(struct snd_soc_component *component,
11062306a36Sopenharmony_ci			     enum snd_soc_dapm_type type, int subseq);
11162306a36Sopenharmony_ci	int (*stream_event)(struct snd_soc_component *component, int event);
11262306a36Sopenharmony_ci	int (*set_bias_level)(struct snd_soc_component *component,
11362306a36Sopenharmony_ci			      enum snd_soc_bias_level level);
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ci	int (*open)(struct snd_soc_component *component,
11662306a36Sopenharmony_ci		    struct snd_pcm_substream *substream);
11762306a36Sopenharmony_ci	int (*close)(struct snd_soc_component *component,
11862306a36Sopenharmony_ci		     struct snd_pcm_substream *substream);
11962306a36Sopenharmony_ci	int (*ioctl)(struct snd_soc_component *component,
12062306a36Sopenharmony_ci		     struct snd_pcm_substream *substream,
12162306a36Sopenharmony_ci		     unsigned int cmd, void *arg);
12262306a36Sopenharmony_ci	int (*hw_params)(struct snd_soc_component *component,
12362306a36Sopenharmony_ci			 struct snd_pcm_substream *substream,
12462306a36Sopenharmony_ci			 struct snd_pcm_hw_params *params);
12562306a36Sopenharmony_ci	int (*hw_free)(struct snd_soc_component *component,
12662306a36Sopenharmony_ci		       struct snd_pcm_substream *substream);
12762306a36Sopenharmony_ci	int (*prepare)(struct snd_soc_component *component,
12862306a36Sopenharmony_ci		       struct snd_pcm_substream *substream);
12962306a36Sopenharmony_ci	int (*trigger)(struct snd_soc_component *component,
13062306a36Sopenharmony_ci		       struct snd_pcm_substream *substream, int cmd);
13162306a36Sopenharmony_ci	int (*sync_stop)(struct snd_soc_component *component,
13262306a36Sopenharmony_ci			 struct snd_pcm_substream *substream);
13362306a36Sopenharmony_ci	snd_pcm_uframes_t (*pointer)(struct snd_soc_component *component,
13462306a36Sopenharmony_ci				     struct snd_pcm_substream *substream);
13562306a36Sopenharmony_ci	int (*get_time_info)(struct snd_soc_component *component,
13662306a36Sopenharmony_ci		struct snd_pcm_substream *substream, struct timespec64 *system_ts,
13762306a36Sopenharmony_ci		struct timespec64 *audio_ts,
13862306a36Sopenharmony_ci		struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
13962306a36Sopenharmony_ci		struct snd_pcm_audio_tstamp_report *audio_tstamp_report);
14062306a36Sopenharmony_ci	int (*copy)(struct snd_soc_component *component,
14162306a36Sopenharmony_ci		    struct snd_pcm_substream *substream, int channel,
14262306a36Sopenharmony_ci		    unsigned long pos, struct iov_iter *iter,
14362306a36Sopenharmony_ci		    unsigned long bytes);
14462306a36Sopenharmony_ci	struct page *(*page)(struct snd_soc_component *component,
14562306a36Sopenharmony_ci			     struct snd_pcm_substream *substream,
14662306a36Sopenharmony_ci			     unsigned long offset);
14762306a36Sopenharmony_ci	int (*mmap)(struct snd_soc_component *component,
14862306a36Sopenharmony_ci		    struct snd_pcm_substream *substream,
14962306a36Sopenharmony_ci		    struct vm_area_struct *vma);
15062306a36Sopenharmony_ci	int (*ack)(struct snd_soc_component *component,
15162306a36Sopenharmony_ci		   struct snd_pcm_substream *substream);
15262306a36Sopenharmony_ci	snd_pcm_sframes_t (*delay)(struct snd_soc_component *component,
15362306a36Sopenharmony_ci				   struct snd_pcm_substream *substream);
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_ci	const struct snd_compress_ops *compress_ops;
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_ci	/* probe ordering - for components with runtime dependencies */
15862306a36Sopenharmony_ci	int probe_order;
15962306a36Sopenharmony_ci	int remove_order;
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_ci	/*
16262306a36Sopenharmony_ci	 * soc_pcm_trigger() start/stop sequence.
16362306a36Sopenharmony_ci	 * see also
16462306a36Sopenharmony_ci	 *	snd_soc_dai_link
16562306a36Sopenharmony_ci	 *	soc_pcm_trigger()
16662306a36Sopenharmony_ci	 */
16762306a36Sopenharmony_ci	enum snd_soc_trigger_order trigger_start;
16862306a36Sopenharmony_ci	enum snd_soc_trigger_order trigger_stop;
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_ci	/*
17162306a36Sopenharmony_ci	 * signal if the module handling the component should not be removed
17262306a36Sopenharmony_ci	 * if a pcm is open. Setting this would prevent the module
17362306a36Sopenharmony_ci	 * refcount being incremented in probe() but allow it be incremented
17462306a36Sopenharmony_ci	 * when a pcm is opened and decremented when it is closed.
17562306a36Sopenharmony_ci	 */
17662306a36Sopenharmony_ci	unsigned int module_get_upon_open:1;
17762306a36Sopenharmony_ci
17862306a36Sopenharmony_ci	/* bits */
17962306a36Sopenharmony_ci	unsigned int idle_bias_on:1;
18062306a36Sopenharmony_ci	unsigned int suspend_bias_off:1;
18162306a36Sopenharmony_ci	unsigned int use_pmdown_time:1; /* care pmdown_time at stop */
18262306a36Sopenharmony_ci	/*
18362306a36Sopenharmony_ci	 * Indicates that the component does not care about the endianness of
18462306a36Sopenharmony_ci	 * PCM audio data and the core will ensure that both LE and BE variants
18562306a36Sopenharmony_ci	 * of each used format are present. Typically this is because the
18662306a36Sopenharmony_ci	 * component sits behind a bus that abstracts away the endian of the
18762306a36Sopenharmony_ci	 * original data, ie. one for which the transmission endian is defined
18862306a36Sopenharmony_ci	 * (I2S/SLIMbus/SoundWire), or the concept of endian doesn't exist (PDM,
18962306a36Sopenharmony_ci	 * analogue).
19062306a36Sopenharmony_ci	 */
19162306a36Sopenharmony_ci	unsigned int endianness:1;
19262306a36Sopenharmony_ci	unsigned int legacy_dai_naming:1;
19362306a36Sopenharmony_ci
19462306a36Sopenharmony_ci	/* this component uses topology and ignore machine driver FEs */
19562306a36Sopenharmony_ci	const char *ignore_machine;
19662306a36Sopenharmony_ci	const char *topology_name_prefix;
19762306a36Sopenharmony_ci	int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
19862306a36Sopenharmony_ci				  struct snd_pcm_hw_params *params);
19962306a36Sopenharmony_ci	bool use_dai_pcm_id;	/* use DAI link PCM ID as PCM device number */
20062306a36Sopenharmony_ci	int be_pcm_base;	/* base device ID for all BE PCMs */
20162306a36Sopenharmony_ci
20262306a36Sopenharmony_ci#ifdef CONFIG_DEBUG_FS
20362306a36Sopenharmony_ci	const char *debugfs_prefix;
20462306a36Sopenharmony_ci#endif
20562306a36Sopenharmony_ci};
20662306a36Sopenharmony_ci
20762306a36Sopenharmony_cistruct snd_soc_component {
20862306a36Sopenharmony_ci	const char *name;
20962306a36Sopenharmony_ci	int id;
21062306a36Sopenharmony_ci	const char *name_prefix;
21162306a36Sopenharmony_ci	struct device *dev;
21262306a36Sopenharmony_ci	struct snd_soc_card *card;
21362306a36Sopenharmony_ci
21462306a36Sopenharmony_ci	unsigned int active;
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ci	unsigned int suspended:1; /* is in suspend PM state */
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_ci	struct list_head list;
21962306a36Sopenharmony_ci	struct list_head card_aux_list; /* for auxiliary bound components */
22062306a36Sopenharmony_ci	struct list_head card_list;
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_ci	const struct snd_soc_component_driver *driver;
22362306a36Sopenharmony_ci
22462306a36Sopenharmony_ci	struct list_head dai_list;
22562306a36Sopenharmony_ci	int num_dai;
22662306a36Sopenharmony_ci
22762306a36Sopenharmony_ci	struct regmap *regmap;
22862306a36Sopenharmony_ci	int val_bytes;
22962306a36Sopenharmony_ci
23062306a36Sopenharmony_ci	struct mutex io_mutex;
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_ci	/* attached dynamic objects */
23362306a36Sopenharmony_ci	struct list_head dobj_list;
23462306a36Sopenharmony_ci
23562306a36Sopenharmony_ci	/*
23662306a36Sopenharmony_ci	 * DO NOT use any of the fields below in drivers, they are temporary and
23762306a36Sopenharmony_ci	 * are going to be removed again soon. If you use them in driver code
23862306a36Sopenharmony_ci	 * the driver will be marked as BROKEN when these fields are removed.
23962306a36Sopenharmony_ci	 */
24062306a36Sopenharmony_ci
24162306a36Sopenharmony_ci	/* Don't use these, use snd_soc_component_get_dapm() */
24262306a36Sopenharmony_ci	struct snd_soc_dapm_context dapm;
24362306a36Sopenharmony_ci
24462306a36Sopenharmony_ci	/* machine specific init */
24562306a36Sopenharmony_ci	int (*init)(struct snd_soc_component *component);
24662306a36Sopenharmony_ci
24762306a36Sopenharmony_ci	/* function mark */
24862306a36Sopenharmony_ci	void *mark_module;
24962306a36Sopenharmony_ci	struct snd_pcm_substream *mark_open;
25062306a36Sopenharmony_ci	struct snd_pcm_substream *mark_hw_params;
25162306a36Sopenharmony_ci	struct snd_pcm_substream *mark_trigger;
25262306a36Sopenharmony_ci	struct snd_compr_stream  *mark_compr_open;
25362306a36Sopenharmony_ci	void *mark_pm;
25462306a36Sopenharmony_ci
25562306a36Sopenharmony_ci	struct dentry *debugfs_root;
25662306a36Sopenharmony_ci	const char *debugfs_prefix;
25762306a36Sopenharmony_ci};
25862306a36Sopenharmony_ci
25962306a36Sopenharmony_ci#define for_each_component_dais(component, dai)\
26062306a36Sopenharmony_ci	list_for_each_entry(dai, &(component)->dai_list, list)
26162306a36Sopenharmony_ci#define for_each_component_dais_safe(component, dai, _dai)\
26262306a36Sopenharmony_ci	list_for_each_entry_safe(dai, _dai, &(component)->dai_list, list)
26362306a36Sopenharmony_ci
26462306a36Sopenharmony_ci/**
26562306a36Sopenharmony_ci * snd_soc_dapm_to_component() - Casts a DAPM context to the component it is
26662306a36Sopenharmony_ci *  embedded in
26762306a36Sopenharmony_ci * @dapm: The DAPM context to cast to the component
26862306a36Sopenharmony_ci *
26962306a36Sopenharmony_ci * This function must only be used on DAPM contexts that are known to be part of
27062306a36Sopenharmony_ci * a component (e.g. in a component driver). Otherwise the behavior is
27162306a36Sopenharmony_ci * undefined.
27262306a36Sopenharmony_ci */
27362306a36Sopenharmony_cistatic inline struct snd_soc_component *snd_soc_dapm_to_component(
27462306a36Sopenharmony_ci	struct snd_soc_dapm_context *dapm)
27562306a36Sopenharmony_ci{
27662306a36Sopenharmony_ci	return container_of(dapm, struct snd_soc_component, dapm);
27762306a36Sopenharmony_ci}
27862306a36Sopenharmony_ci
27962306a36Sopenharmony_ci/**
28062306a36Sopenharmony_ci * snd_soc_component_get_dapm() - Returns the DAPM context associated with a
28162306a36Sopenharmony_ci *  component
28262306a36Sopenharmony_ci * @component: The component for which to get the DAPM context
28362306a36Sopenharmony_ci */
28462306a36Sopenharmony_cistatic inline struct snd_soc_dapm_context *snd_soc_component_get_dapm(
28562306a36Sopenharmony_ci	struct snd_soc_component *component)
28662306a36Sopenharmony_ci{
28762306a36Sopenharmony_ci	return &component->dapm;
28862306a36Sopenharmony_ci}
28962306a36Sopenharmony_ci
29062306a36Sopenharmony_ci/**
29162306a36Sopenharmony_ci * snd_soc_component_init_bias_level() - Initialize COMPONENT DAPM bias level
29262306a36Sopenharmony_ci * @component: The COMPONENT for which to initialize the DAPM bias level
29362306a36Sopenharmony_ci * @level: The DAPM level to initialize to
29462306a36Sopenharmony_ci *
29562306a36Sopenharmony_ci * Initializes the COMPONENT DAPM bias level. See snd_soc_dapm_init_bias_level()
29662306a36Sopenharmony_ci */
29762306a36Sopenharmony_cistatic inline void
29862306a36Sopenharmony_cisnd_soc_component_init_bias_level(struct snd_soc_component *component,
29962306a36Sopenharmony_ci				  enum snd_soc_bias_level level)
30062306a36Sopenharmony_ci{
30162306a36Sopenharmony_ci	snd_soc_dapm_init_bias_level(
30262306a36Sopenharmony_ci		snd_soc_component_get_dapm(component), level);
30362306a36Sopenharmony_ci}
30462306a36Sopenharmony_ci
30562306a36Sopenharmony_ci/**
30662306a36Sopenharmony_ci * snd_soc_component_get_bias_level() - Get current COMPONENT DAPM bias level
30762306a36Sopenharmony_ci * @component: The COMPONENT for which to get the DAPM bias level
30862306a36Sopenharmony_ci *
30962306a36Sopenharmony_ci * Returns: The current DAPM bias level of the COMPONENT.
31062306a36Sopenharmony_ci */
31162306a36Sopenharmony_cistatic inline enum snd_soc_bias_level
31262306a36Sopenharmony_cisnd_soc_component_get_bias_level(struct snd_soc_component *component)
31362306a36Sopenharmony_ci{
31462306a36Sopenharmony_ci	return snd_soc_dapm_get_bias_level(
31562306a36Sopenharmony_ci		snd_soc_component_get_dapm(component));
31662306a36Sopenharmony_ci}
31762306a36Sopenharmony_ci
31862306a36Sopenharmony_ci/**
31962306a36Sopenharmony_ci * snd_soc_component_force_bias_level() - Set the COMPONENT DAPM bias level
32062306a36Sopenharmony_ci * @component: The COMPONENT for which to set the level
32162306a36Sopenharmony_ci * @level: The level to set to
32262306a36Sopenharmony_ci *
32362306a36Sopenharmony_ci * Forces the COMPONENT bias level to a specific state. See
32462306a36Sopenharmony_ci * snd_soc_dapm_force_bias_level().
32562306a36Sopenharmony_ci */
32662306a36Sopenharmony_cistatic inline int
32762306a36Sopenharmony_cisnd_soc_component_force_bias_level(struct snd_soc_component *component,
32862306a36Sopenharmony_ci				   enum snd_soc_bias_level level)
32962306a36Sopenharmony_ci{
33062306a36Sopenharmony_ci	return snd_soc_dapm_force_bias_level(
33162306a36Sopenharmony_ci		snd_soc_component_get_dapm(component),
33262306a36Sopenharmony_ci		level);
33362306a36Sopenharmony_ci}
33462306a36Sopenharmony_ci
33562306a36Sopenharmony_ci/**
33662306a36Sopenharmony_ci * snd_soc_dapm_kcontrol_component() - Returns the component associated to a
33762306a36Sopenharmony_ci * kcontrol
33862306a36Sopenharmony_ci * @kcontrol: The kcontrol
33962306a36Sopenharmony_ci *
34062306a36Sopenharmony_ci * This function must only be used on DAPM contexts that are known to be part of
34162306a36Sopenharmony_ci * a COMPONENT (e.g. in a COMPONENT driver). Otherwise the behavior is undefined
34262306a36Sopenharmony_ci */
34362306a36Sopenharmony_cistatic inline struct snd_soc_component *snd_soc_dapm_kcontrol_component(
34462306a36Sopenharmony_ci	struct snd_kcontrol *kcontrol)
34562306a36Sopenharmony_ci{
34662306a36Sopenharmony_ci	return snd_soc_dapm_to_component(snd_soc_dapm_kcontrol_dapm(kcontrol));
34762306a36Sopenharmony_ci}
34862306a36Sopenharmony_ci
34962306a36Sopenharmony_ci/**
35062306a36Sopenharmony_ci * snd_soc_component_cache_sync() - Sync the register cache with the hardware
35162306a36Sopenharmony_ci * @component: COMPONENT to sync
35262306a36Sopenharmony_ci *
35362306a36Sopenharmony_ci * Note: This function will call regcache_sync()
35462306a36Sopenharmony_ci */
35562306a36Sopenharmony_cistatic inline int snd_soc_component_cache_sync(
35662306a36Sopenharmony_ci	struct snd_soc_component *component)
35762306a36Sopenharmony_ci{
35862306a36Sopenharmony_ci	return regcache_sync(component->regmap);
35962306a36Sopenharmony_ci}
36062306a36Sopenharmony_ci
36162306a36Sopenharmony_civoid snd_soc_component_set_aux(struct snd_soc_component *component,
36262306a36Sopenharmony_ci			       struct snd_soc_aux_dev *aux);
36362306a36Sopenharmony_ciint snd_soc_component_init(struct snd_soc_component *component);
36462306a36Sopenharmony_ciint snd_soc_component_is_dummy(struct snd_soc_component *component);
36562306a36Sopenharmony_ci
36662306a36Sopenharmony_ci/* component IO */
36762306a36Sopenharmony_ciunsigned int snd_soc_component_read(struct snd_soc_component *component,
36862306a36Sopenharmony_ci				      unsigned int reg);
36962306a36Sopenharmony_ciint snd_soc_component_write(struct snd_soc_component *component,
37062306a36Sopenharmony_ci			    unsigned int reg, unsigned int val);
37162306a36Sopenharmony_ciint snd_soc_component_update_bits(struct snd_soc_component *component,
37262306a36Sopenharmony_ci				  unsigned int reg, unsigned int mask,
37362306a36Sopenharmony_ci				  unsigned int val);
37462306a36Sopenharmony_ciint snd_soc_component_update_bits_async(struct snd_soc_component *component,
37562306a36Sopenharmony_ci					unsigned int reg, unsigned int mask,
37662306a36Sopenharmony_ci					unsigned int val);
37762306a36Sopenharmony_civoid snd_soc_component_async_complete(struct snd_soc_component *component);
37862306a36Sopenharmony_ciint snd_soc_component_test_bits(struct snd_soc_component *component,
37962306a36Sopenharmony_ci				unsigned int reg, unsigned int mask,
38062306a36Sopenharmony_ci				unsigned int value);
38162306a36Sopenharmony_ci
38262306a36Sopenharmony_ciunsigned int snd_soc_component_read_field(struct snd_soc_component *component,
38362306a36Sopenharmony_ci					  unsigned int reg, unsigned int mask);
38462306a36Sopenharmony_ciint snd_soc_component_write_field(struct snd_soc_component *component,
38562306a36Sopenharmony_ci				  unsigned int reg, unsigned int mask,
38662306a36Sopenharmony_ci				  unsigned int val);
38762306a36Sopenharmony_ci
38862306a36Sopenharmony_ci/* component wide operations */
38962306a36Sopenharmony_ciint snd_soc_component_set_sysclk(struct snd_soc_component *component,
39062306a36Sopenharmony_ci				 int clk_id, int source,
39162306a36Sopenharmony_ci				 unsigned int freq, int dir);
39262306a36Sopenharmony_ciint snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id,
39362306a36Sopenharmony_ci			      int source, unsigned int freq_in,
39462306a36Sopenharmony_ci			      unsigned int freq_out);
39562306a36Sopenharmony_ciint snd_soc_component_set_jack(struct snd_soc_component *component,
39662306a36Sopenharmony_ci			       struct snd_soc_jack *jack, void *data);
39762306a36Sopenharmony_ciint snd_soc_component_get_jack_type(struct snd_soc_component *component);
39862306a36Sopenharmony_ci
39962306a36Sopenharmony_civoid snd_soc_component_seq_notifier(struct snd_soc_component *component,
40062306a36Sopenharmony_ci				    enum snd_soc_dapm_type type, int subseq);
40162306a36Sopenharmony_ciint snd_soc_component_stream_event(struct snd_soc_component *component,
40262306a36Sopenharmony_ci				   int event);
40362306a36Sopenharmony_ciint snd_soc_component_set_bias_level(struct snd_soc_component *component,
40462306a36Sopenharmony_ci				     enum snd_soc_bias_level level);
40562306a36Sopenharmony_ci
40662306a36Sopenharmony_civoid snd_soc_component_setup_regmap(struct snd_soc_component *component);
40762306a36Sopenharmony_ci#ifdef CONFIG_REGMAP
40862306a36Sopenharmony_civoid snd_soc_component_init_regmap(struct snd_soc_component *component,
40962306a36Sopenharmony_ci				   struct regmap *regmap);
41062306a36Sopenharmony_civoid snd_soc_component_exit_regmap(struct snd_soc_component *component);
41162306a36Sopenharmony_ci#endif
41262306a36Sopenharmony_ci
41362306a36Sopenharmony_ci#define snd_soc_component_module_get_when_probe(component)\
41462306a36Sopenharmony_ci	snd_soc_component_module_get(component, NULL, 0)
41562306a36Sopenharmony_ci#define snd_soc_component_module_get_when_open(component, substream)	\
41662306a36Sopenharmony_ci	snd_soc_component_module_get(component, substream, 1)
41762306a36Sopenharmony_ciint snd_soc_component_module_get(struct snd_soc_component *component,
41862306a36Sopenharmony_ci				 void *mark, int upon_open);
41962306a36Sopenharmony_ci#define snd_soc_component_module_put_when_remove(component)	\
42062306a36Sopenharmony_ci	snd_soc_component_module_put(component, NULL, 0, 0)
42162306a36Sopenharmony_ci#define snd_soc_component_module_put_when_close(component, substream, rollback) \
42262306a36Sopenharmony_ci	snd_soc_component_module_put(component, substream, 1, rollback)
42362306a36Sopenharmony_civoid snd_soc_component_module_put(struct snd_soc_component *component,
42462306a36Sopenharmony_ci				  void *mark, int upon_open, int rollback);
42562306a36Sopenharmony_ci
42662306a36Sopenharmony_cistatic inline void snd_soc_component_set_drvdata(struct snd_soc_component *c,
42762306a36Sopenharmony_ci						 void *data)
42862306a36Sopenharmony_ci{
42962306a36Sopenharmony_ci	dev_set_drvdata(c->dev, data);
43062306a36Sopenharmony_ci}
43162306a36Sopenharmony_ci
43262306a36Sopenharmony_cistatic inline void *snd_soc_component_get_drvdata(struct snd_soc_component *c)
43362306a36Sopenharmony_ci{
43462306a36Sopenharmony_ci	return dev_get_drvdata(c->dev);
43562306a36Sopenharmony_ci}
43662306a36Sopenharmony_ci
43762306a36Sopenharmony_cistatic inline unsigned int
43862306a36Sopenharmony_cisnd_soc_component_active(struct snd_soc_component *component)
43962306a36Sopenharmony_ci{
44062306a36Sopenharmony_ci	return component->active;
44162306a36Sopenharmony_ci}
44262306a36Sopenharmony_ci
44362306a36Sopenharmony_ci/* component pin */
44462306a36Sopenharmony_ciint snd_soc_component_enable_pin(struct snd_soc_component *component,
44562306a36Sopenharmony_ci				 const char *pin);
44662306a36Sopenharmony_ciint snd_soc_component_enable_pin_unlocked(struct snd_soc_component *component,
44762306a36Sopenharmony_ci					  const char *pin);
44862306a36Sopenharmony_ciint snd_soc_component_disable_pin(struct snd_soc_component *component,
44962306a36Sopenharmony_ci				  const char *pin);
45062306a36Sopenharmony_ciint snd_soc_component_disable_pin_unlocked(struct snd_soc_component *component,
45162306a36Sopenharmony_ci					   const char *pin);
45262306a36Sopenharmony_ciint snd_soc_component_nc_pin(struct snd_soc_component *component,
45362306a36Sopenharmony_ci			     const char *pin);
45462306a36Sopenharmony_ciint snd_soc_component_nc_pin_unlocked(struct snd_soc_component *component,
45562306a36Sopenharmony_ci				      const char *pin);
45662306a36Sopenharmony_ciint snd_soc_component_get_pin_status(struct snd_soc_component *component,
45762306a36Sopenharmony_ci				     const char *pin);
45862306a36Sopenharmony_ciint snd_soc_component_force_enable_pin(struct snd_soc_component *component,
45962306a36Sopenharmony_ci				       const char *pin);
46062306a36Sopenharmony_ciint snd_soc_component_force_enable_pin_unlocked(
46162306a36Sopenharmony_ci	struct snd_soc_component *component,
46262306a36Sopenharmony_ci	const char *pin);
46362306a36Sopenharmony_ci
46462306a36Sopenharmony_ci/* component controls */
46562306a36Sopenharmony_ciint snd_soc_component_notify_control(struct snd_soc_component *component,
46662306a36Sopenharmony_ci				     const char * const ctl);
46762306a36Sopenharmony_ci
46862306a36Sopenharmony_ci/* component driver ops */
46962306a36Sopenharmony_ciint snd_soc_component_open(struct snd_soc_component *component,
47062306a36Sopenharmony_ci			   struct snd_pcm_substream *substream);
47162306a36Sopenharmony_ciint snd_soc_component_close(struct snd_soc_component *component,
47262306a36Sopenharmony_ci			    struct snd_pcm_substream *substream,
47362306a36Sopenharmony_ci			    int rollback);
47462306a36Sopenharmony_civoid snd_soc_component_suspend(struct snd_soc_component *component);
47562306a36Sopenharmony_civoid snd_soc_component_resume(struct snd_soc_component *component);
47662306a36Sopenharmony_ciint snd_soc_component_is_suspended(struct snd_soc_component *component);
47762306a36Sopenharmony_ciint snd_soc_component_probe(struct snd_soc_component *component);
47862306a36Sopenharmony_civoid snd_soc_component_remove(struct snd_soc_component *component);
47962306a36Sopenharmony_ciint snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component,
48062306a36Sopenharmony_ci				      struct device_node *ep);
48162306a36Sopenharmony_ciint snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component,
48262306a36Sopenharmony_ci					const struct of_phandle_args *args,
48362306a36Sopenharmony_ci					const char **dai_name);
48462306a36Sopenharmony_ciint snd_soc_component_compr_open(struct snd_soc_component *component,
48562306a36Sopenharmony_ci				 struct snd_compr_stream *cstream);
48662306a36Sopenharmony_civoid snd_soc_component_compr_free(struct snd_soc_component *component,
48762306a36Sopenharmony_ci				  struct snd_compr_stream *cstream,
48862306a36Sopenharmony_ci				  int rollback);
48962306a36Sopenharmony_ciint snd_soc_component_compr_trigger(struct snd_compr_stream *cstream, int cmd);
49062306a36Sopenharmony_ciint snd_soc_component_compr_set_params(struct snd_compr_stream *cstream,
49162306a36Sopenharmony_ci				       struct snd_compr_params *params);
49262306a36Sopenharmony_ciint snd_soc_component_compr_get_params(struct snd_compr_stream *cstream,
49362306a36Sopenharmony_ci				       struct snd_codec *params);
49462306a36Sopenharmony_ciint snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream,
49562306a36Sopenharmony_ci				     struct snd_compr_caps *caps);
49662306a36Sopenharmony_ciint snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream,
49762306a36Sopenharmony_ci					   struct snd_compr_codec_caps *codec);
49862306a36Sopenharmony_ciint snd_soc_component_compr_ack(struct snd_compr_stream *cstream, size_t bytes);
49962306a36Sopenharmony_ciint snd_soc_component_compr_pointer(struct snd_compr_stream *cstream,
50062306a36Sopenharmony_ci				    struct snd_compr_tstamp *tstamp);
50162306a36Sopenharmony_ciint snd_soc_component_compr_copy(struct snd_compr_stream *cstream,
50262306a36Sopenharmony_ci				 char __user *buf, size_t count);
50362306a36Sopenharmony_ciint snd_soc_component_compr_set_metadata(struct snd_compr_stream *cstream,
50462306a36Sopenharmony_ci					 struct snd_compr_metadata *metadata);
50562306a36Sopenharmony_ciint snd_soc_component_compr_get_metadata(struct snd_compr_stream *cstream,
50662306a36Sopenharmony_ci					 struct snd_compr_metadata *metadata);
50762306a36Sopenharmony_ci
50862306a36Sopenharmony_ciint snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
50962306a36Sopenharmony_ciint snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
51062306a36Sopenharmony_ci				unsigned int cmd, void *arg);
51162306a36Sopenharmony_ciint snd_soc_pcm_component_sync_stop(struct snd_pcm_substream *substream);
51262306a36Sopenharmony_ciint snd_soc_pcm_component_copy(struct snd_pcm_substream *substream,
51362306a36Sopenharmony_ci			       int channel, unsigned long pos,
51462306a36Sopenharmony_ci			       struct iov_iter *iter, unsigned long bytes);
51562306a36Sopenharmony_cistruct page *snd_soc_pcm_component_page(struct snd_pcm_substream *substream,
51662306a36Sopenharmony_ci					unsigned long offset);
51762306a36Sopenharmony_ciint snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream,
51862306a36Sopenharmony_ci			       struct vm_area_struct *vma);
51962306a36Sopenharmony_ciint snd_soc_pcm_component_new(struct snd_soc_pcm_runtime *rtd);
52062306a36Sopenharmony_civoid snd_soc_pcm_component_free(struct snd_soc_pcm_runtime *rtd);
52162306a36Sopenharmony_ciint snd_soc_pcm_component_prepare(struct snd_pcm_substream *substream);
52262306a36Sopenharmony_ciint snd_soc_pcm_component_hw_params(struct snd_pcm_substream *substream,
52362306a36Sopenharmony_ci				    struct snd_pcm_hw_params *params);
52462306a36Sopenharmony_civoid snd_soc_pcm_component_hw_free(struct snd_pcm_substream *substream,
52562306a36Sopenharmony_ci				   int rollback);
52662306a36Sopenharmony_ciint snd_soc_pcm_component_trigger(struct snd_pcm_substream *substream,
52762306a36Sopenharmony_ci				  int cmd, int rollback);
52862306a36Sopenharmony_ciint snd_soc_pcm_component_pm_runtime_get(struct snd_soc_pcm_runtime *rtd,
52962306a36Sopenharmony_ci					 void *stream);
53062306a36Sopenharmony_civoid snd_soc_pcm_component_pm_runtime_put(struct snd_soc_pcm_runtime *rtd,
53162306a36Sopenharmony_ci					  void *stream, int rollback);
53262306a36Sopenharmony_ciint snd_soc_pcm_component_ack(struct snd_pcm_substream *substream);
53362306a36Sopenharmony_civoid snd_soc_pcm_component_delay(struct snd_pcm_substream *substream,
53462306a36Sopenharmony_ci				 snd_pcm_sframes_t *cpu_delay, snd_pcm_sframes_t *codec_delay);
53562306a36Sopenharmony_ci
53662306a36Sopenharmony_ci#endif /* __SOC_COMPONENT_H */
537