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
40 static void snd_jack_remove_debugfs(struct snd_jack *jack);
44 struct snd_jack *jack = device->device_data; in snd_jack_dev_disconnect() local
46 snd_jack_remove_debugfs(jack); in snd_jack_dev_disconnect()
49 guard(mutex)(&jack->input_dev_lock); in snd_jack_dev_disconnect()
50 if (!jack->input_dev) in snd_jack_dev_disconnect()
55 if (jack->registered) in snd_jack_dev_disconnect()
56 input_unregister_device(jack->input_dev); in snd_jack_dev_disconnect()
58 input_free_device(jack->input_dev); in snd_jack_dev_disconnect()
59 jack->input_dev = NULL; in snd_jack_dev_disconnect()
66 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()
75 if (jack->private_free) in snd_jack_dev_free()
76 jack->private_free(jack); in snd_jack_dev_free()
80 kfree(jack->id); in snd_jack_dev_free()
81 kfree(jack); in snd_jack_dev_free()
89 struct snd_jack *jack = device->device_data; in snd_jack_dev_register() local
93 snprintf(jack->name, sizeof(jack->name), "%s %s", in snd_jack_dev_register()
94 card->shortname, jack->id); in snd_jack_dev_register()
96 guard(mutex)(&jack->input_dev_lock); in snd_jack_dev_register()
97 if (!jack->input_dev) in snd_jack_dev_register()
100 jack->input_dev->name = jack->name; in snd_jack_dev_register()
103 if (!jack->input_dev->dev.parent) in snd_jack_dev_register()
104 jack->input_dev->dev.parent = snd_card_get_device_link(card); in snd_jack_dev_register()
107 for (i = 0; i < ARRAY_SIZE(jack->key); i++) { in snd_jack_dev_register()
110 if (!(jack->type & testbit)) in snd_jack_dev_register()
113 if (!jack->key[i]) in snd_jack_dev_register()
114 jack->key[i] = BTN_0 + i; in snd_jack_dev_register()
116 input_set_capability(jack->input_dev, EV_KEY, jack->key[i]); in snd_jack_dev_register()
119 err = input_register_device(jack->input_dev); in snd_jack_dev_register()
121 jack->registered = 1; in snd_jack_dev_register()
130 struct snd_jack *jack; in snd_jack_inject_report() local
137 jack = jack_kctl->jack; in snd_jack_inject_report()
140 snd_kctl_jack_report(jack->card, jack_kctl->kctl, in snd_jack_inject_report()
144 if (!jack->input_dev) in snd_jack_inject_report()
147 for (i = 0; i < ARRAY_SIZE(jack->key); i++) { in snd_jack_inject_report()
150 if (jack->type & testbit) in snd_jack_inject_report()
151 input_report_key(jack->input_dev, jack->key[i], in snd_jack_inject_report()
158 if (jack->type & testbit) in snd_jack_inject_report()
159 input_report_switch(jack->input_dev, in snd_jack_inject_report()
164 input_sync(jack->input_dev); in snd_jack_inject_report()
175 len = scnprintf(buf, sizeof(buf), "%s: %s\t\t%s: %i\n", "Jack", jack_kctl->kctl->id.name, in sw_inject_enable_read()
201 snd_jack_report(jack_kctl->jack, jack_kctl->jack->hw_status_cache); in sw_inject_enable_write()
240 /* the bit definition is aligned with snd_jack_types in jack.h */
300 len = parse_mask_bits(jack_kctl->jack->type, buf, sizeof(buf)); in jack_type_read()
344 static int snd_jack_debugfs_add_inject_node(struct snd_jack *jack, in snd_jack_debugfs_add_inject_node() argument
363 jack_kctl->jack_debugfs_root = debugfs_create_dir(tname, jack->card->debugfs_root); in snd_jack_debugfs_add_inject_node()
388 static void snd_jack_remove_debugfs(struct snd_jack *jack) in snd_jack_remove_debugfs() argument
392 list_for_each_entry(jack_kctl, &jack->kctl_list, list) { in snd_jack_remove_debugfs()
398 static int snd_jack_debugfs_add_inject_node(struct snd_jack *jack, in snd_jack_debugfs_add_inject_node() argument
404 static void snd_jack_remove_debugfs(struct snd_jack *jack) in snd_jack_remove_debugfs() argument
420 static void snd_jack_kctl_add(struct snd_jack *jack, struct snd_jack_kctl *jack_kctl) in snd_jack_kctl_add() argument
422 jack_kctl->jack = jack; in snd_jack_kctl_add()
423 list_add_tail(&jack_kctl->list, &jack->kctl_list); in snd_jack_kctl_add()
424 snd_jack_debugfs_add_inject_node(jack, jack_kctl); in snd_jack_kctl_add()
459 * snd_jack_add_new_kctl - Create a new snd_jack_kctl and add it to jack
460 * @jack: the jack instance which the kctl will attaching to
465 * Creates a new snd_kcontrol object and adds it to the jack kctl_list.
469 int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask) in snd_jack_add_new_kctl() argument
473 jack_kctl = snd_jack_kctl_new(jack->card, name, mask); in snd_jack_add_new_kctl()
477 snd_jack_kctl_add(jack, jack_kctl); in snd_jack_add_new_kctl()
483 * snd_jack_new - Create a new jack
485 * @id: an identifying string for this jack
487 * this jack
488 * @jjack: Used to provide the allocated jack object to the caller.
489 * @initial_kctl: if true, create a kcontrol and add it to the jack list.
492 * Creates a new jack object.
500 struct snd_jack *jack; in snd_jack_new() local
517 jack = kzalloc(sizeof(struct snd_jack), GFP_KERNEL); in snd_jack_new()
518 if (jack == NULL) in snd_jack_new()
521 jack->id = kstrdup(id, GFP_KERNEL); in snd_jack_new()
522 if (jack->id == NULL) { in snd_jack_new()
523 kfree(jack); in snd_jack_new()
528 mutex_init(&jack->input_dev_lock); in snd_jack_new()
530 /* don't create input device for phantom jack */ in snd_jack_new()
534 jack->input_dev = input_allocate_device(); in snd_jack_new()
535 if (jack->input_dev == NULL) { in snd_jack_new()
540 jack->input_dev->phys = "ALSA"; in snd_jack_new()
542 jack->type = type; in snd_jack_new()
546 input_set_capability(jack->input_dev, EV_SW, in snd_jack_new()
552 err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops); in snd_jack_new()
556 jack->card = card; in snd_jack_new()
557 INIT_LIST_HEAD(&jack->kctl_list); in snd_jack_new()
560 snd_jack_kctl_add(jack, jack_kctl); in snd_jack_new()
562 *jjack = jack; in snd_jack_new()
568 input_free_device(jack->input_dev); in snd_jack_new()
570 kfree(jack->id); in snd_jack_new()
571 kfree(jack); in snd_jack_new()
578 * snd_jack_set_parent - Set the parent device for a jack
580 * @jack: The jack to configure
581 * @parent: The device to set as parent for the jack.
583 * Set the parent for the jack devices in the device tree. This
584 * function is only valid prior to registration of the jack. If no
587 void snd_jack_set_parent(struct snd_jack *jack, struct device *parent) in snd_jack_set_parent() argument
589 WARN_ON(jack->registered); in snd_jack_set_parent()
590 guard(mutex)(&jack->input_dev_lock); in snd_jack_set_parent()
591 if (jack->input_dev) in snd_jack_set_parent()
592 jack->input_dev->dev.parent = parent; in snd_jack_set_parent()
597 * snd_jack_set_key - Set a key mapping on a jack
599 * @jack: The jack to configure
600 * @type: Jack report type for this key
604 * reporting of keys on accessories via the jack abstraction. If no
605 * mapping is provided but keys are enabled in the jack type then
617 * This function may only be called prior to registration of the jack.
621 int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type, in snd_jack_set_key() argument
626 WARN_ON(jack->registered); in snd_jack_set_key()
628 if (!keytype || key >= ARRAY_SIZE(jack->key)) in snd_jack_set_key()
631 jack->type |= type; in snd_jack_set_key()
632 jack->key[key] = keytype; in snd_jack_set_key()
639 * snd_jack_report - Report the current status of a jack
643 * @jack: The jack to report status for
644 * @status: The current status of the jack
646 void snd_jack_report(struct snd_jack *jack, int status) in snd_jack_report() argument
655 if (!jack) in snd_jack_report()
658 jack->hw_status_cache = status; in snd_jack_report()
660 list_for_each_entry(jack_kctl, &jack->kctl_list, list) in snd_jack_report()
664 snd_kctl_jack_report(jack->card, jack_kctl->kctl, in snd_jack_report()
668 idev = input_get_device(jack->input_dev); in snd_jack_report()
672 for (i = 0; i < ARRAY_SIZE(jack->key); i++) { in snd_jack_report()
675 if (jack->type & testbit) in snd_jack_report()
676 input_report_key(idev, jack->key[i], in snd_jack_report()
683 if (jack->type & testbit) in snd_jack_report()