GNU Linux-libre 5.19-rc6-gnu
[releases.git] / include / sound / soc-card.h
1 /* SPDX-License-Identifier: GPL-2.0
2  *
3  * soc-card.h
4  *
5  * Copyright (C) 2019 Renesas Electronics Corp.
6  * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
7  */
8 #ifndef __SOC_CARD_H
9 #define __SOC_CARD_H
10
11 enum snd_soc_card_subclass {
12         SND_SOC_CARD_CLASS_INIT         = 0,
13         SND_SOC_CARD_CLASS_RUNTIME      = 1,
14 };
15
16 struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
17                                                const char *name);
18 int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
19                           struct snd_soc_jack *jack);
20 int snd_soc_card_jack_new_pins(struct snd_soc_card *card, const char *id,
21                                int type, struct snd_soc_jack *jack,
22                                struct snd_soc_jack_pin *pins,
23                                unsigned int num_pins);
24
25 int snd_soc_card_suspend_pre(struct snd_soc_card *card);
26 int snd_soc_card_suspend_post(struct snd_soc_card *card);
27 int snd_soc_card_resume_pre(struct snd_soc_card *card);
28 int snd_soc_card_resume_post(struct snd_soc_card *card);
29
30 int snd_soc_card_probe(struct snd_soc_card *card);
31 int snd_soc_card_late_probe(struct snd_soc_card *card);
32 int snd_soc_card_remove(struct snd_soc_card *card);
33
34 int snd_soc_card_set_bias_level(struct snd_soc_card *card,
35                                 struct snd_soc_dapm_context *dapm,
36                                 enum snd_soc_bias_level level);
37 int snd_soc_card_set_bias_level_post(struct snd_soc_card *card,
38                                      struct snd_soc_dapm_context *dapm,
39                                      enum snd_soc_bias_level level);
40
41 int snd_soc_card_add_dai_link(struct snd_soc_card *card,
42                               struct snd_soc_dai_link *dai_link);
43 void snd_soc_card_remove_dai_link(struct snd_soc_card *card,
44                                   struct snd_soc_dai_link *dai_link);
45
46 /* device driver data */
47 static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card,
48                                             void *data)
49 {
50         card->drvdata = data;
51 }
52
53 static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card)
54 {
55         return card->drvdata;
56 }
57
58 static inline
59 struct snd_soc_dai *snd_soc_card_get_codec_dai(struct snd_soc_card *card,
60                                                const char *dai_name)
61 {
62         struct snd_soc_pcm_runtime *rtd;
63
64         for_each_card_rtds(card, rtd) {
65                 if (!strcmp(asoc_rtd_to_codec(rtd, 0)->name, dai_name))
66                         return asoc_rtd_to_codec(rtd, 0);
67         }
68
69         return NULL;
70 }
71
72 #endif /* __SOC_CARD_H */