/* * Helper functions for jack-detection kcontrols * * Copyright (c) 2011 Takashi Iwai * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. */ #include #include #include #include #define jack_detect_kctl_info snd_ctl_boolean_mono_info static int jack_detect_kctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { ucontrol->value.integer.value[0] = kcontrol->private_value; return 0; } static struct snd_kcontrol_new jack_detect_kctl = { /* name is filled later */ .iface = SNDRV_CTL_ELEM_IFACE_CARD, .access = SNDRV_CTL_ELEM_ACCESS_READ, .info = jack_detect_kctl_info, .get = jack_detect_kctl_get, }; static int get_available_index(struct snd_card *card, const char *name) { struct snd_ctl_elem_id sid; memset(&sid, 0, sizeof(sid)); sid.index = 0; sid.iface = SNDRV_CTL_ELEM_IFACE_CARD; strlcpy(sid.name, name, sizeof(sid.name)); while (snd_ctl_find_id(card, &sid)) { sid.index++; /* reset numid; otherwise snd_ctl_find_id() hits this again */ sid.numid = 0; } return sid.index; } static void jack_kctl_name_gen(char *name, const char *src_name, int size) { size_t count = strlen(src_name); bool need_cat = true; /* remove redundant " Jack" from src_name */ if (count >= 5) need_cat = strncmp(&src_name[count - 5], " Jack", 5) ? true : false; snprintf(name, size, need_cat ? "%s Jack" : "%s", src_name); } struct snd_kcontrol * snd_kctl_jack_new(const char *name, struct snd_card *card) { struct snd_kcontrol *kctl; kctl = snd_ctl_new1(&jack_detect_kctl, NULL); if (!kctl) return NULL; jack_kctl_name_gen(kctl->id.name, name, sizeof(kctl->id.name)); kctl->id.index = get_available_index(card, kctl->id.name); kctl->private_value = 0; return kctl; } void snd_kctl_jack_report(struct snd_card *card, struct snd_kcontrol *kctl, bool status) { if (kctl->private_value == status) return; kctl->private_value = status; snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); } sung/Kconfig'>
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-01-30 11:26:38 +0100
committerJiri Kosina <jkosina@suse.cz>2017-01-31 12:59:32 +0100
commit7a7b5df84b6b4e5d599c7289526eed96541a0654 (patch)
treecf7514c7ddf4410fe37ca9099a2785e1cf08fa7d /sound/soc/samsung/Kconfig
parent877a021e08ccb6434718c0cc781fdf943c884cc0 (diff)
HID: cp2112: fix sleep-while-atomic
A recent commit fixing DMA-buffers on stack added a shared transfer buffer protected by a spinlock. This is broken as the USB HID request callbacks can sleep. Fix this up by replacing the spinlock with a mutex. Fixes: 1ffb3c40ffb5 ("HID: cp2112: make transfer buffers DMA capable") Cc: stable <stable@vger.kernel.org> # 4.9 Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'sound/soc/samsung/Kconfig')