Lines Matching full:jack

3  *  Jack abstraction layer
14 #include <sound/jack.h>
20 struct list_head list; /* list of controls belong to the same jack */
22 struct snd_jack *jack; /* pointer to struct snd_jack */ member
43 struct snd_jack *jack = device->device_data; in snd_jack_dev_disconnect() local
45 mutex_lock(&jack->input_dev_lock); in snd_jack_dev_disconnect()
46 if (!jack->input_dev) { in snd_jack_dev_disconnect()
47 mutex_unlock(&jack->input_dev_lock); in snd_jack_dev_disconnect()
53 if (jack->registered) in snd_jack_dev_disconnect()
54 input_unregister_device(jack->input_dev); in snd_jack_dev_disconnect()
56 input_free_device(jack->input_dev); in snd_jack_dev_disconnect()
57 jack->input_dev = NULL; in snd_jack_dev_disconnect()
58 mutex_unlock(&jack->input_dev_lock); in snd_jack_dev_disconnect()
65 struct snd_jack *jack = device->device_data; in snd_jack_dev_free() local
70 list_for_each_entry_safe(jack_kctl, tmp_jack_kctl, &jack->kctl_list, list) { in snd_jack_dev_free()
76 if (jack->private_free) in snd_jack_dev_free()
77 jack->private_free(jack); in snd_jack_dev_free()
81 kfree(jack->id); in snd_jack_dev_free()
82 kfree(jack); in snd_jack_dev_free()
90 struct snd_jack *jack = device->device_data; in snd_jack_dev_register() local
94 snprintf(jack->name, sizeof(jack->name), "%s %s", in snd_jack_dev_register()
95 card->shortname, jack->id); in snd_jack_dev_register()
97 mutex_lock(&jack->input_dev_lock); in snd_jack_dev_register()
98 if (!jack->input_dev) { in snd_jack_dev_register()
99 mutex_unlock(&jack->input_dev_lock); in snd_jack_dev_register()
103 jack->input_dev->name = jack->name; in snd_jack_dev_register()
106 if (!jack->input_dev->dev.parent) in snd_jack_dev_register()
107 jack->input_dev->dev.parent = snd_card_get_device_link(card); in snd_jack_dev_register()
110 for (i = 0; i < ARRAY_SIZE(jack->key); i++) { in snd_jack_dev_register()
113 if (!(jack->type & testbit)) in snd_jack_dev_register()
116 if (!jack->key[i]) in snd_jack_dev_register()
117 jack->key[i] = BTN_0 + i; in snd_jack_dev_register()
119 input_set_capability(jack->input_dev, EV_KEY, jack->key[i]); in snd_jack_dev_register()
122 err = input_register_device(jack->input_dev); in snd_jack_dev_register()
124 jack->registered = 1; in snd_jack_dev_register()
126 mutex_unlock(&jack->input_dev_lock); in snd_jack_dev_register()
134 struct snd_jack *jack; in snd_jack_inject_report() local
141 jack = jack_kctl->jack; in snd_jack_inject_report()
144 snd_kctl_jack_report(jack->card, jack_kctl->kctl, in snd_jack_inject_report()
148 if (!jack->input_dev) in snd_jack_inject_report()
151 for (i = 0; i < ARRAY_SIZE(jack->key); i++) { in snd_jack_inject_report()
154 if (jack->type & testbit) in snd_jack_inject_report()
155 input_report_key(jack->input_dev, jack->key[i], in snd_jack_inject_report()
162 if (jack->type & testbit) in snd_jack_inject_report()
163 input_report_switch(jack->input_dev, in snd_jack_inject_report()
168 input_sync(jack->input_dev); in snd_jack_inject_report()
179 len = scnprintf(buf, sizeof(buf), "%s: %s\t\t%s: %i\n", "Jack", jack_kctl->kctl->id.name, in sw_inject_enable_read()
205 snd_jack_report(jack_kctl->jack, jack_kctl->jack->hw_status_cache); in sw_inject_enable_write()
244 /* the bit definition is aligned with snd_jack_types in jack.h */
304 len = parse_mask_bits(jack_kctl->jack->type, buf, sizeof(buf)); in jack_type_read()
348 static int snd_jack_debugfs_add_inject_node(struct snd_jack *jack, in snd_jack_debugfs_add_inject_node() argument
367 jack_kctl->jack_debugfs_root = debugfs_create_dir(tname, jack->card->debugfs_root); in snd_jack_debugfs_add_inject_node()
398 static int snd_jack_debugfs_add_inject_node(struct snd_jack *jack, in snd_jack_debugfs_add_inject_node() argument
421 static void snd_jack_kctl_add(struct snd_jack *jack, struct snd_jack_kctl *jack_kctl) in snd_jack_kctl_add() argument
423 jack_kctl->jack = jack; in snd_jack_kctl_add()
424 list_add_tail(&jack_kctl->list, &jack->kctl_list); in snd_jack_kctl_add()
425 snd_jack_debugfs_add_inject_node(jack, jack_kctl); in snd_jack_kctl_add()
460 * snd_jack_add_new_kctl - Create a new snd_jack_kctl and add it to jack
461 * @jack: the jack instance which the kctl will attaching to
466 * Creates a new snd_kcontrol object and adds it to the jack kctl_list.
470 int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask) in snd_jack_add_new_kctl() argument
474 jack_kctl = snd_jack_kctl_new(jack->card, name, mask); in snd_jack_add_new_kctl()
478 snd_jack_kctl_add(jack, jack_kctl); in snd_jack_add_new_kctl()
484 * snd_jack_new - Create a new jack
486 * @id: an identifying string for this jack
488 * this jack
489 * @jjack: Used to provide the allocated jack object to the caller.
490 * @initial_kctl: if true, create a kcontrol and add it to the jack list.
493 * Creates a new jack object.
501 struct snd_jack *jack; in snd_jack_new() local
518 jack = kzalloc(sizeof(struct snd_jack), GFP_KERNEL); in snd_jack_new()
519 if (jack == NULL) in snd_jack_new()
522 jack->id = kstrdup(id, GFP_KERNEL); in snd_jack_new()
523 if (jack->id == NULL) { in snd_jack_new()
524 kfree(jack); in snd_jack_new()
529 mutex_init(&jack->input_dev_lock); in snd_jack_new()
531 /* don't create input device for phantom jack */ in snd_jack_new()
535 jack->input_dev = input_allocate_device(); in snd_jack_new()
536 if (jack->input_dev == NULL) { in snd_jack_new()
541 jack->input_dev->phys = "ALSA"; in snd_jack_new()
543 jack->type = type; in snd_jack_new()
547 input_set_capability(jack->input_dev, EV_SW, in snd_jack_new()
553 err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops); in snd_jack_new()
557 jack->card = card; in snd_jack_new()
558 INIT_LIST_HEAD(&jack->kctl_list); in snd_jack_new()
561 snd_jack_kctl_add(jack, jack_kctl); in snd_jack_new()
563 *jjack = jack; in snd_jack_new()
569 input_free_device(jack->input_dev); in snd_jack_new()
571 kfree(jack->id); in snd_jack_new()
572 kfree(jack); in snd_jack_new()
579 * snd_jack_set_parent - Set the parent device for a jack
581 * @jack: The jack to configure
582 * @parent: The device to set as parent for the jack.
584 * Set the parent for the jack devices in the device tree. This
585 * function is only valid prior to registration of the jack. If no
588 void snd_jack_set_parent(struct snd_jack *jack, struct device *parent) in snd_jack_set_parent() argument
590 WARN_ON(jack->registered); in snd_jack_set_parent()
591 mutex_lock(&jack->input_dev_lock); in snd_jack_set_parent()
592 if (!jack->input_dev) { in snd_jack_set_parent()
593 mutex_unlock(&jack->input_dev_lock); in snd_jack_set_parent()
597 jack->input_dev->dev.parent = parent; in snd_jack_set_parent()
598 mutex_unlock(&jack->input_dev_lock); in snd_jack_set_parent()
603 * snd_jack_set_key - Set a key mapping on a jack
605 * @jack: The jack to configure
606 * @type: Jack report type for this key
610 * reporting of keys on accessories via the jack abstraction. If no
611 * mapping is provided but keys are enabled in the jack type then
623 * This function may only be called prior to registration of the jack.
627 int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type, in snd_jack_set_key() argument
632 WARN_ON(jack->registered); in snd_jack_set_key()
634 if (!keytype || key >= ARRAY_SIZE(jack->key)) in snd_jack_set_key()
637 jack->type |= type; in snd_jack_set_key()
638 jack->key[key] = keytype; in snd_jack_set_key()
645 * snd_jack_report - Report the current status of a jack
649 * @jack: The jack to report status for
650 * @status: The current status of the jack
652 void snd_jack_report(struct snd_jack *jack, int status) in snd_jack_report() argument
660 if (!jack) in snd_jack_report()
663 jack->hw_status_cache = status; in snd_jack_report()
665 list_for_each_entry(jack_kctl, &jack->kctl_list, list) in snd_jack_report()
669 snd_kctl_jack_report(jack->card, jack_kctl->kctl, in snd_jack_report()
673 mutex_lock(&jack->input_dev_lock); in snd_jack_report()
674 if (!jack->input_dev) { in snd_jack_report()
675 mutex_unlock(&jack->input_dev_lock); in snd_jack_report()
679 for (i = 0; i < ARRAY_SIZE(jack->key); i++) { in snd_jack_report()
682 if (jack->type & testbit) in snd_jack_report()
683 input_report_key(jack->input_dev, jack->key[i], in snd_jack_report()
690 if (jack->type & testbit) in snd_jack_report()
691 input_report_switch(jack->input_dev, in snd_jack_report()
696 input_sync(jack->input_dev); in snd_jack_report()
697 mutex_unlock(&jack->input_dev_lock); in snd_jack_report()