Lines Matching +full:adc +full:- +full:use +full:- +full:res

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
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
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
107 * @micbias_voltage: mic bias voltage at adc channel when jack is plugged in
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
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()
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()
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()
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()
268 * Use workqueue so we do not have to care about running in snd_soc_jack_pm_notifier()
271 queue_delayed_work(system_power_efficient_wq, &gpio->work, 0); in snd_soc_jack_pm_notifier()
293 static void jack_devres_free_gpios(struct device *dev, void *res) in jack_devres_free_gpios() argument
295 struct jack_gpio_tbl *tbl = res; in jack_devres_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
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()
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
424 * snd_soc_jack_free_gpios - Release GPIO pins' resources of an ASoC jack
436 devres_destroy(jack->card->dev, jack_devres_free_gpios, NULL, NULL); in snd_soc_jack_free_gpios()