Lines Matching +full:pin +full:- +full:count
1 // SPDX-License-Identifier: GPL-2.0+
3 // soc-jack.c -- ALSA SoC jack handling
20 * snd_soc_jack_report - Report the current status for a jack
36 struct snd_soc_jack_pin *pin; in snd_soc_jack_report() local
39 if (!jack || !jack->jack) in snd_soc_jack_report()
43 dapm = &jack->card->dapm; in snd_soc_jack_report()
45 mutex_lock(&jack->mutex); in snd_soc_jack_report()
47 jack->status &= ~mask; in snd_soc_jack_report()
48 jack->status |= status & mask; in snd_soc_jack_report()
52 list_for_each_entry(pin, &jack->pins, list) { in snd_soc_jack_report()
53 int enable = pin->mask & jack->status; in snd_soc_jack_report()
55 if (pin->invert) in snd_soc_jack_report()
59 snd_soc_dapm_enable_pin(dapm, pin->pin); in snd_soc_jack_report()
61 snd_soc_dapm_disable_pin(dapm, pin->pin); in snd_soc_jack_report()
68 blocking_notifier_call_chain(&jack->notifier, jack->status, jack); in snd_soc_jack_report()
73 snd_jack_report(jack->jack, jack->status); in snd_soc_jack_report()
75 mutex_unlock(&jack->mutex); in snd_soc_jack_report()
80 * snd_soc_jack_add_zones - Associate voltage zones with jack
83 * @count: Number of zones
89 int snd_soc_jack_add_zones(struct snd_soc_jack *jack, int count, in snd_soc_jack_add_zones() argument
94 for (i = 0; i < count; i++) { in snd_soc_jack_add_zones()
96 list_add(&(zones[i].list), &jack->jack_zones); in snd_soc_jack_add_zones()
103 * snd_soc_jack_get_type - Based on the mic bias value, this function returns
116 list_for_each_entry(zone, &jack->jack_zones, list) { in snd_soc_jack_get_type()
117 if (micbias_voltage >= zone->min_mv && in snd_soc_jack_get_type()
118 micbias_voltage < zone->max_mv) in snd_soc_jack_get_type()
119 return zone->jack_type; in snd_soc_jack_get_type()
126 * snd_soc_jack_add_pins - Associate DAPM pins with an ASoC jack
129 * @count: Number of pins
136 int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, in snd_soc_jack_add_pins() argument
141 for (i = 0; i < count; i++) { in snd_soc_jack_add_pins()
142 if (!pins[i].pin) { in snd_soc_jack_add_pins()
143 dev_err(jack->card->dev, "ASoC: No name for pin %d\n", in snd_soc_jack_add_pins()
145 return -EINVAL; in snd_soc_jack_add_pins()
148 dev_err(jack->card->dev, "ASoC: No mask for pin %d" in snd_soc_jack_add_pins()
149 " (%s)\n", i, pins[i].pin); in snd_soc_jack_add_pins()
150 return -EINVAL; in snd_soc_jack_add_pins()
154 list_add(&(pins[i].list), &jack->pins); in snd_soc_jack_add_pins()
155 snd_jack_add_new_kctl(jack->jack, pins[i].pin, pins[i].mask); in snd_soc_jack_add_pins()
169 * snd_soc_jack_notifier_register - Register a notifier for jack status
183 blocking_notifier_chain_register(&jack->notifier, nb); in snd_soc_jack_notifier_register()
188 * snd_soc_jack_notifier_unregister - Unregister a notifier for jack status
198 blocking_notifier_chain_unregister(&jack->notifier, nb); in snd_soc_jack_notifier_unregister()
204 int count; member
212 struct snd_soc_jack *jack = gpio->jack; in snd_soc_jack_gpio_detect()
216 enable = gpiod_get_value_cansleep(gpio->desc); in snd_soc_jack_gpio_detect()
217 if (gpio->invert) in snd_soc_jack_gpio_detect()
221 report = gpio->report; in snd_soc_jack_gpio_detect()
225 if (gpio->jack_status_check) in snd_soc_jack_gpio_detect()
226 report = gpio->jack_status_check(gpio->data); in snd_soc_jack_gpio_detect()
228 snd_soc_jack_report(jack, report, gpio->report); in snd_soc_jack_gpio_detect()
231 /* irq handler for gpio pin */
235 struct device *dev = gpio->jack->card->dev; in gpio_handler()
237 trace_snd_soc_jack_irq(gpio->name); in gpio_handler()
240 pm_wakeup_event(dev, gpio->debounce_time + 50); in gpio_handler()
242 queue_delayed_work(system_power_efficient_wq, &gpio->work, in gpio_handler()
243 msecs_to_jiffies(gpio->debounce_time)); in gpio_handler()
271 queue_delayed_work(system_power_efficient_wq, &gpio->work, 0); in snd_soc_jack_pm_notifier()
278 static void jack_free_gpios(struct snd_soc_jack *jack, int count, in jack_free_gpios() argument
283 for (i = 0; i < count; i++) { in jack_free_gpios()
297 jack_free_gpios(tbl->jack, tbl->count, tbl->gpios); in jack_devres_free_gpios()
301 * snd_soc_jack_add_gpios - Associate GPIO pins with an ASoC jack
304 * @count: number of pins
310 int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, in snd_soc_jack_add_gpios() argument
318 return -ENOMEM; in snd_soc_jack_add_gpios()
319 tbl->jack = jack; in snd_soc_jack_add_gpios()
320 tbl->count = count; in snd_soc_jack_add_gpios()
321 tbl->gpios = gpios; in snd_soc_jack_add_gpios()
323 for (i = 0; i < count; i++) { in snd_soc_jack_add_gpios()
325 dev_err(jack->card->dev, in snd_soc_jack_add_gpios()
327 ret = -EINVAL; in snd_soc_jack_add_gpios()
347 dev_err(jack->card->dev, "ASoC: Invalid gpio at index %d\n", i); in snd_soc_jack_add_gpios()
348 ret = -EINVAL; in snd_soc_jack_add_gpios()
368 dev_err(jack->card->dev, in snd_soc_jack_add_gpios()
388 devres_add(jack->card->dev, tbl); in snd_soc_jack_add_gpios()
400 * snd_soc_jack_add_gpiods - Associate GPIO descriptor pins with an ASoC jack
404 * @count: number of pins
412 int count, struct snd_soc_jack_gpio *gpios) in snd_soc_jack_add_gpiods() argument
416 for (i = 0; i < count; i++) in snd_soc_jack_add_gpiods()
419 return snd_soc_jack_add_gpios(jack, count, gpios); in snd_soc_jack_add_gpiods()
424 * snd_soc_jack_free_gpios - Release GPIO pins' resources of an ASoC jack
427 * @count: number of pins
432 void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, in snd_soc_jack_free_gpios() argument
435 jack_free_gpios(jack, count, gpios); in snd_soc_jack_free_gpios()
436 devres_destroy(jack->card->dev, jack_devres_free_gpios, NULL, NULL); in snd_soc_jack_free_gpios()