Lines Matching refs:jack

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 */
43 struct snd_jack *jack = device->device_data;
45 guard(mutex)(&jack->input_dev_lock);
46 if (!jack->input_dev)
51 if (jack->registered)
52 input_unregister_device(jack->input_dev);
54 input_free_device(jack->input_dev);
55 jack->input_dev = NULL;
62 struct snd_jack *jack = device->device_data;
66 list_for_each_entry_safe(jack_kctl, tmp_jack_kctl, &jack->kctl_list, list) {
71 if (jack->private_free)
72 jack->private_free(jack);
76 kfree(jack->id);
77 kfree(jack);
85 struct snd_jack *jack = device->device_data;
89 snprintf(jack->name, sizeof(jack->name), "%s %s",
90 card->shortname, jack->id);
92 guard(mutex)(&jack->input_dev_lock);
93 if (!jack->input_dev)
96 jack->input_dev->name = jack->name;
99 if (!jack->input_dev->dev.parent)
100 jack->input_dev->dev.parent = snd_card_get_device_link(card);
103 for (i = 0; i < ARRAY_SIZE(jack->key); i++) {
106 if (!(jack->type & testbit))
109 if (!jack->key[i])
110 jack->key[i] = BTN_0 + i;
112 input_set_capability(jack->input_dev, EV_KEY, jack->key[i]);
115 err = input_register_device(jack->input_dev);
117 jack->registered = 1;
126 struct snd_jack *jack;
133 jack = jack_kctl->jack;
136 snd_kctl_jack_report(jack->card, jack_kctl->kctl,
140 if (!jack->input_dev)
143 for (i = 0; i < ARRAY_SIZE(jack->key); i++) {
146 if (jack->type & testbit)
147 input_report_key(jack->input_dev, jack->key[i],
154 if (jack->type & testbit)
155 input_report_switch(jack->input_dev,
160 input_sync(jack->input_dev);
197 snd_jack_report(jack_kctl->jack, jack_kctl->jack->hw_status_cache);
236 /* the bit definition is aligned with snd_jack_types in jack.h */
296 len = parse_mask_bits(jack_kctl->jack->type, buf, sizeof(buf));
340 static int snd_jack_debugfs_add_inject_node(struct snd_jack *jack,
359 jack_kctl->jack_debugfs_root = debugfs_create_dir(tname, jack->card->debugfs_root);
390 static int snd_jack_debugfs_add_inject_node(struct snd_jack *jack,
413 static void snd_jack_kctl_add(struct snd_jack *jack, struct snd_jack_kctl *jack_kctl)
415 jack_kctl->jack = jack;
416 list_add_tail(&jack_kctl->list, &jack->kctl_list);
417 snd_jack_debugfs_add_inject_node(jack, jack_kctl);
452 * snd_jack_add_new_kctl - Create a new snd_jack_kctl and add it to jack
453 * @jack: the jack instance which the kctl will attaching to
458 * Creates a new snd_kcontrol object and adds it to the jack kctl_list.
462 int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask)
466 jack_kctl = snd_jack_kctl_new(jack->card, name, mask);
470 snd_jack_kctl_add(jack, jack_kctl);
476 * snd_jack_new - Create a new jack
478 * @id: an identifying string for this jack
480 * this jack
481 * @jjack: Used to provide the allocated jack object to the caller.
482 * @initial_kctl: if true, create a kcontrol and add it to the jack list.
485 * Creates a new jack object.
493 struct snd_jack *jack;
510 jack = kzalloc(sizeof(struct snd_jack), GFP_KERNEL);
511 if (jack == NULL)
514 jack->id = kstrdup(id, GFP_KERNEL);
515 if (jack->id == NULL) {
516 kfree(jack);
521 mutex_init(&jack->input_dev_lock);
523 /* don't create input device for phantom jack */
527 jack->input_dev = input_allocate_device();
528 if (jack->input_dev == NULL) {
533 jack->input_dev->phys = "ALSA";
535 jack->type = type;
539 input_set_capability(jack->input_dev, EV_SW,
545 err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops);
549 jack->card = card;
550 INIT_LIST_HEAD(&jack->kctl_list);
553 snd_jack_kctl_add(jack, jack_kctl);
555 *jjack = jack;
561 input_free_device(jack->input_dev);
563 kfree(jack->id);
564 kfree(jack);
571 * snd_jack_set_parent - Set the parent device for a jack
573 * @jack: The jack to configure
574 * @parent: The device to set as parent for the jack.
576 * Set the parent for the jack devices in the device tree. This
577 * function is only valid prior to registration of the jack. If no
580 void snd_jack_set_parent(struct snd_jack *jack, struct device *parent)
582 WARN_ON(jack->registered);
583 guard(mutex)(&jack->input_dev_lock);
584 if (jack->input_dev)
585 jack->input_dev->dev.parent = parent;
590 * snd_jack_set_key - Set a key mapping on a jack
592 * @jack: The jack to configure
597 * reporting of keys on accessories via the jack abstraction. If no
598 * mapping is provided but keys are enabled in the jack type then
610 * This function may only be called prior to registration of the jack.
614 int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type,
619 WARN_ON(jack->registered);
621 if (!keytype || key >= ARRAY_SIZE(jack->key))
624 jack->type |= type;
625 jack->key[key] = keytype;
632 * snd_jack_report - Report the current status of a jack
636 * @jack: The jack to report status for
637 * @status: The current status of the jack
639 void snd_jack_report(struct snd_jack *jack, int status)
648 if (!jack)
651 jack->hw_status_cache = status;
653 list_for_each_entry(jack_kctl, &jack->kctl_list, list)
657 snd_kctl_jack_report(jack->card, jack_kctl->kctl,
661 idev = input_get_device(jack->input_dev);
665 for (i = 0; i < ARRAY_SIZE(jack->key); i++) {
668 if (jack->type & testbit)
669 input_report_key(idev, jack->key[i],
676 if (jack->type & testbit)