/* * 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); } cgit.cgi/linux/net-next.git/log/include/xen/interface'>
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2017-01-29 21:00:48 -0800
committerOlof Johansson <olof@lixom.net>2017-01-29 21:00:48 -0800
commit0a019a28e0ca0af7dc2691d1a9527960b07ad2bb (patch)
tree5ee1db9aacacd6af6701fb290e8a294ef3cc2bf2 /include/xen/interface
parentec026b5020688a8bde5fae9a69ae3c59b66ba3ae (diff)
parent8413299cb3933dade6186bbee8363f190032107e (diff)
Merge tag 'sti-dt-for-v4.10-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/pchotard/sti into fixes
STi DT fix: Since v4.10-rc1, xhci is complaining in loop with : [ 801.953836] usb usb6-port1: Cannot enable. Maybe the USB cable is bad? [ 801.960455] xhci-hcd xhci-hcd.0.auto: Cannot set link state. [ 801.966611] usb usb6-port1: cannot disable (err = -32) set property "snps,dis_u3_susphy_quirk" in DT fix it. * tag 'sti-dt-for-v4.10-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/pchotard/sti: ARM: dts: STiH407-family: set snps,dis_u3_susphy_quirk Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'include/xen/interface')