diff options
Diffstat (limited to 'sound/soc/soc-jack.c')
-rw-r--r-- | sound/soc/soc-jack.c | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index 4380dcc064a5..9f60c25c4568 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c | |||
@@ -22,30 +22,42 @@ | |||
22 | #include <trace/events/asoc.h> | 22 | #include <trace/events/asoc.h> |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * snd_soc_jack_new - Create a new jack | 25 | * snd_soc_card_jack_new - Create a new jack |
26 | * @codec: ASoC codec | 26 | * @card: ASoC card |
27 | * @id: an identifying string for this jack | 27 | * @id: an identifying string for this jack |
28 | * @type: a bitmask of enum snd_jack_type values that can be detected by | 28 | * @type: a bitmask of enum snd_jack_type values that can be detected by |
29 | * this jack | 29 | * this jack |
30 | * @jack: structure to use for the jack | 30 | * @jack: structure to use for the jack |
31 | * @pins: Array of jack pins to be added to the jack or NULL | ||
32 | * @num_pins: Number of elements in the @pins array | ||
31 | * | 33 | * |
32 | * Creates a new jack object. | 34 | * Creates a new jack object. |
33 | * | 35 | * |
34 | * Returns zero if successful, or a negative error code on failure. | 36 | * Returns zero if successful, or a negative error code on failure. |
35 | * On success jack will be initialised. | 37 | * On success jack will be initialised. |
36 | */ | 38 | */ |
37 | int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type, | 39 | int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type, |
38 | struct snd_soc_jack *jack) | 40 | struct snd_soc_jack *jack, struct snd_soc_jack_pin *pins, |
41 | unsigned int num_pins) | ||
39 | { | 42 | { |
43 | int ret; | ||
44 | |||
40 | mutex_init(&jack->mutex); | 45 | mutex_init(&jack->mutex); |
41 | jack->codec = codec; | 46 | jack->card = card; |
42 | INIT_LIST_HEAD(&jack->pins); | 47 | INIT_LIST_HEAD(&jack->pins); |
43 | INIT_LIST_HEAD(&jack->jack_zones); | 48 | INIT_LIST_HEAD(&jack->jack_zones); |
44 | BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier); | 49 | BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier); |
45 | 50 | ||
46 | return snd_jack_new(codec->component.card->snd_card, id, type, &jack->jack); | 51 | ret = snd_jack_new(card->snd_card, id, type, &jack->jack); |
52 | if (ret) | ||
53 | return ret; | ||
54 | |||
55 | if (num_pins) | ||
56 | return snd_soc_jack_add_pins(jack, num_pins, pins); | ||
57 | |||
58 | return 0; | ||
47 | } | 59 | } |
48 | EXPORT_SYMBOL_GPL(snd_soc_jack_new); | 60 | EXPORT_SYMBOL_GPL(snd_soc_card_jack_new); |
49 | 61 | ||
50 | /** | 62 | /** |
51 | * snd_soc_jack_report - Report the current status for a jack | 63 | * snd_soc_jack_report - Report the current status for a jack |
@@ -63,7 +75,6 @@ EXPORT_SYMBOL_GPL(snd_soc_jack_new); | |||
63 | */ | 75 | */ |
64 | void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) | 76 | void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) |
65 | { | 77 | { |
66 | struct snd_soc_codec *codec; | ||
67 | struct snd_soc_dapm_context *dapm; | 78 | struct snd_soc_dapm_context *dapm; |
68 | struct snd_soc_jack_pin *pin; | 79 | struct snd_soc_jack_pin *pin; |
69 | unsigned int sync = 0; | 80 | unsigned int sync = 0; |
@@ -74,8 +85,7 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) | |||
74 | if (!jack) | 85 | if (!jack) |
75 | return; | 86 | return; |
76 | 87 | ||
77 | codec = jack->codec; | 88 | dapm = &jack->card->dapm; |
78 | dapm = &codec->dapm; | ||
79 | 89 | ||
80 | mutex_lock(&jack->mutex); | 90 | mutex_lock(&jack->mutex); |
81 | 91 | ||
@@ -175,12 +185,12 @@ int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, | |||
175 | 185 | ||
176 | for (i = 0; i < count; i++) { | 186 | for (i = 0; i < count; i++) { |
177 | if (!pins[i].pin) { | 187 | if (!pins[i].pin) { |
178 | dev_err(jack->codec->dev, "ASoC: No name for pin %d\n", | 188 | dev_err(jack->card->dev, "ASoC: No name for pin %d\n", |
179 | i); | 189 | i); |
180 | return -EINVAL; | 190 | return -EINVAL; |
181 | } | 191 | } |
182 | if (!pins[i].mask) { | 192 | if (!pins[i].mask) { |
183 | dev_err(jack->codec->dev, "ASoC: No mask for pin %d" | 193 | dev_err(jack->card->dev, "ASoC: No mask for pin %d" |
184 | " (%s)\n", i, pins[i].pin); | 194 | " (%s)\n", i, pins[i].pin); |
185 | return -EINVAL; | 195 | return -EINVAL; |
186 | } | 196 | } |
@@ -260,7 +270,7 @@ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio) | |||
260 | static irqreturn_t gpio_handler(int irq, void *data) | 270 | static irqreturn_t gpio_handler(int irq, void *data) |
261 | { | 271 | { |
262 | struct snd_soc_jack_gpio *gpio = data; | 272 | struct snd_soc_jack_gpio *gpio = data; |
263 | struct device *dev = gpio->jack->codec->component.card->dev; | 273 | struct device *dev = gpio->jack->card->dev; |
264 | 274 | ||
265 | trace_snd_soc_jack_irq(gpio->name); | 275 | trace_snd_soc_jack_irq(gpio->name); |
266 | 276 | ||
@@ -299,7 +309,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | |||
299 | 309 | ||
300 | for (i = 0; i < count; i++) { | 310 | for (i = 0; i < count; i++) { |
301 | if (!gpios[i].name) { | 311 | if (!gpios[i].name) { |
302 | dev_err(jack->codec->dev, | 312 | dev_err(jack->card->dev, |
303 | "ASoC: No name for gpio at index %d\n", i); | 313 | "ASoC: No name for gpio at index %d\n", i); |
304 | ret = -EINVAL; | 314 | ret = -EINVAL; |
305 | goto undo; | 315 | goto undo; |
@@ -320,7 +330,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | |||
320 | } else { | 330 | } else { |
321 | /* legacy GPIO number */ | 331 | /* legacy GPIO number */ |
322 | if (!gpio_is_valid(gpios[i].gpio)) { | 332 | if (!gpio_is_valid(gpios[i].gpio)) { |
323 | dev_err(jack->codec->dev, | 333 | dev_err(jack->card->dev, |
324 | "ASoC: Invalid gpio %d\n", | 334 | "ASoC: Invalid gpio %d\n", |
325 | gpios[i].gpio); | 335 | gpios[i].gpio); |
326 | ret = -EINVAL; | 336 | ret = -EINVAL; |
@@ -350,7 +360,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | |||
350 | if (gpios[i].wake) { | 360 | if (gpios[i].wake) { |
351 | ret = irq_set_irq_wake(gpiod_to_irq(gpios[i].desc), 1); | 361 | ret = irq_set_irq_wake(gpiod_to_irq(gpios[i].desc), 1); |
352 | if (ret != 0) | 362 | if (ret != 0) |
353 | dev_err(jack->codec->dev, | 363 | dev_err(jack->card->dev, |
354 | "ASoC: Failed to mark GPIO at index %d as wake source: %d\n", | 364 | "ASoC: Failed to mark GPIO at index %d as wake source: %d\n", |
355 | i, ret); | 365 | i, ret); |
356 | } | 366 | } |