Blame view
sound/soc/soc-card.c
4.77 KB
1793936bc ASoC: add soc-card.c |
1 2 3 4 5 6 7 8 |
// SPDX-License-Identifier: GPL-2.0 // // soc-card.c // // Copyright (C) 2019 Renesas Electronics Corp. // Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> // #include <sound/soc.h> |
3359e9b6f ASoC: soc-card: m... |
9 |
#include <sound/jack.h> |
1793936bc ASoC: add soc-card.c |
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
#define soc_card_ret(dai, ret) _soc_card_ret(dai, __func__, ret) static inline int _soc_card_ret(struct snd_soc_card *card, const char *func, int ret) { switch (ret) { case -EPROBE_DEFER: case -ENOTSUPP: case 0: break; default: dev_err(card->dev, "ASoC: error at %s on %s: %d ", func, card->name, ret); } return ret; } |
209c6cdfd ASoC: soc-card: m... |
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card, const char *name) { struct snd_card *card = soc_card->snd_card; struct snd_kcontrol *kctl; if (unlikely(!name)) return NULL; list_for_each_entry(kctl, &card->controls, list) if (!strncmp(kctl->id.name, name, sizeof(kctl->id.name))) return kctl; return NULL; } EXPORT_SYMBOL_GPL(snd_soc_card_get_kcontrol); |
3359e9b6f ASoC: soc-card: m... |
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
/** * snd_soc_card_jack_new - Create a new jack * @card: ASoC card * @id: an identifying string for this jack * @type: a bitmask of enum snd_jack_type values that can be detected by * this jack * @jack: structure to use for the jack * @pins: Array of jack pins to be added to the jack or NULL * @num_pins: Number of elements in the @pins array * * Creates a new jack object. * * Returns zero if successful, or a negative error code on failure. * On success jack will be initialised. */ int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type, struct snd_soc_jack *jack, struct snd_soc_jack_pin *pins, unsigned int num_pins) { int ret; mutex_init(&jack->mutex); jack->card = card; INIT_LIST_HEAD(&jack->pins); INIT_LIST_HEAD(&jack->jack_zones); BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier); ret = snd_jack_new(card->snd_card, id, type, &jack->jack, false, false); if (ret) goto end; if (num_pins) ret = snd_soc_jack_add_pins(jack, num_pins, pins); end: return soc_card_ret(card, ret); } EXPORT_SYMBOL_GPL(snd_soc_card_jack_new); |
130dc08c8 ASoC: soc-card: a... |
83 84 85 86 87 88 89 90 91 92 |
int snd_soc_card_suspend_pre(struct snd_soc_card *card) { int ret = 0; if (card->suspend_pre) ret = card->suspend_pre(card); return soc_card_ret(card, ret); } |
d17b60b2c ASoC: soc-card: a... |
93 94 95 96 97 98 99 100 101 102 |
int snd_soc_card_suspend_post(struct snd_soc_card *card) { int ret = 0; if (card->suspend_post) ret = card->suspend_post(card); return soc_card_ret(card, ret); } |
934c752c3 ASoC: soc-card: a... |
103 104 105 106 107 108 109 110 111 112 |
int snd_soc_card_resume_pre(struct snd_soc_card *card) { int ret = 0; if (card->resume_pre) ret = card->resume_pre(card); return soc_card_ret(card, ret); } |
739443d1f ASoC: soc-card: a... |
113 114 115 116 117 118 119 120 121 122 |
int snd_soc_card_resume_post(struct snd_soc_card *card) { int ret = 0; if (card->resume_post) ret = card->resume_post(card); return soc_card_ret(card, ret); } |
73de4b026 ASoC: soc-card: a... |
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
int snd_soc_card_probe(struct snd_soc_card *card) { if (card->probe) { int ret = card->probe(card); if (ret < 0) return soc_card_ret(card, ret); /* * It has "card->probe" and "card->late_probe" callbacks. * So, set "probed" flag here, because it needs to care * about "late_probe". * * see * snd_soc_bind_card() * snd_soc_card_late_probe() */ card->probed = 1; } return 0; } |
5c0eac036 ASoC: soc-card: a... |
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
int snd_soc_card_late_probe(struct snd_soc_card *card) { if (card->late_probe) { int ret = card->late_probe(card); if (ret < 0) return soc_card_ret(card, ret); } /* * It has "card->probe" and "card->late_probe" callbacks, * and "late_probe" callback is called after "probe". * This means, we can set "card->probed" flag afer "late_probe" * for all cases. * * see * snd_soc_bind_card() * snd_soc_card_probe() */ card->probed = 1; return 0; } |
b0275d956 ASoC: soc-card: a... |
170 171 172 173 174 175 176 177 178 179 180 181 182 |
int snd_soc_card_remove(struct snd_soc_card *card) { int ret = 0; if (card->probed && card->remove) ret = card->remove(card); card->probed = 0; return soc_card_ret(card, ret); } |
39caefda0 ASoC: soc-card: a... |
183 184 185 186 187 188 189 190 191 192 193 194 |
int snd_soc_card_set_bias_level(struct snd_soc_card *card, struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level) { int ret = 0; if (card && card->set_bias_level) ret = card->set_bias_level(card, dapm, level); return soc_card_ret(card, ret); } |
d41278ea0 ASoC: soc-card: a... |
195 196 197 198 199 200 201 202 203 204 205 206 |
int snd_soc_card_set_bias_level_post(struct snd_soc_card *card, struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level) { int ret = 0; if (card && card->set_bias_level_post) ret = card->set_bias_level_post(card, dapm, level); return soc_card_ret(card, ret); } |
cbc7a6b5a ASoC: soc-card: a... |
207 208 209 210 211 212 213 214 215 216 217 218 |
int snd_soc_card_add_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) { int ret = 0; if (card->add_dai_link) ret = card->add_dai_link(card, dai_link); return soc_card_ret(card, ret); } EXPORT_SYMBOL_GPL(snd_soc_card_add_dai_link); |
fcbbcc325 ASoC: soc-card: a... |
219 220 221 222 223 224 225 226 |
void snd_soc_card_remove_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) { if (card->remove_dai_link) card->remove_dai_link(card, dai_link); } EXPORT_SYMBOL_GPL(snd_soc_card_remove_dai_link); |