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 mutex_lock(&jack->input_dev_lock);
46 if (!jack->input_dev) {
47 mutex_unlock(&jack->input_dev_lock);
53 if (jack->registered)
54 input_unregister_device(jack->input_dev);
56 input_free_device(jack->input_dev);
57 jack->input_dev = NULL;
58 mutex_unlock(&jack->input_dev_lock);
65 struct snd_jack *jack = device->device_data;
69 list_for_each_entry_safe(jack_kctl, tmp_jack_kctl, &jack->kctl_list, list) {
74 if (jack->private_free)
75 jack->private_free(jack);
79 kfree(jack->id);
80 kfree(jack);
88 struct snd_jack *jack = device->device_data;
92 snprintf(jack->name, sizeof(jack->name), "%s %s",
93 card->shortname, jack->id);
95 mutex_lock(&jack->input_dev_lock);
96 if (!jack->input_dev) {
97 mutex_unlock(&jack->input_dev_lock);
101 jack->input_dev->name = jack->name;
104 if (!jack->input_dev->dev.parent)
105 jack->input_dev->dev.parent = snd_card_get_device_link(card);
108 for (i = 0; i < ARRAY_SIZE(jack->key); i++) {
111 if (!(jack->type & testbit))
114 if (!jack->key[i])
115 jack->key[i] = BTN_0 + i;
117 input_set_capability(jack->input_dev, EV_KEY, jack->key[i]);
120 err = input_register_device(jack->input_dev);
122 jack->registered = 1;
124 mutex_unlock(&jack->input_dev_lock);
132 struct snd_jack *jack;
139 jack = jack_kctl->jack;
142 snd_kctl_jack_report(jack->card, jack_kctl->kctl,
146 if (!jack->input_dev)
149 for (i = 0; i < ARRAY_SIZE(jack->key); i++) {
152 if (jack->type & testbit)
153 input_report_key(jack->input_dev, jack->key[i],
160 if (jack->type & testbit)
161 input_report_switch(jack->input_dev,
166 input_sync(jack->input_dev);
203 snd_jack_report(jack_kctl->jack, jack_kctl->jack->hw_status_cache);
242 /* the bit definition is aligned with snd_jack_types in jack.h */
302 len = parse_mask_bits(jack_kctl->jack->type, buf, sizeof(buf));
346 static int snd_jack_debugfs_add_inject_node(struct snd_jack *jack,
365 jack_kctl->jack_debugfs_root = debugfs_create_dir(tname, jack->card->debugfs_root);
396 static int snd_jack_debugfs_add_inject_node(struct snd_jack *jack,
419 static void snd_jack_kctl_add(struct snd_jack *jack, struct snd_jack_kctl *jack_kctl)
421 jack_kctl->jack = jack;
422 list_add_tail(&jack_kctl->list, &jack->kctl_list);
423 snd_jack_debugfs_add_inject_node(jack, jack_kctl);
458 * snd_jack_add_new_kctl - Create a new snd_jack_kctl and add it to jack
459 * @jack: the jack instance which the kctl will attaching to
464 * Creates a new snd_kcontrol object and adds it to the jack kctl_list.
468 int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask)
472 jack_kctl = snd_jack_kctl_new(jack->card, name, mask);
476 snd_jack_kctl_add(jack, jack_kctl);
482 * snd_jack_new - Create a new jack
484 * @id: an identifying string for this jack
486 * this jack
487 * @jjack: Used to provide the allocated jack object to the caller.
488 * @initial_kctl: if true, create a kcontrol and add it to the jack list.
491 * Creates a new jack object.
499 struct snd_jack *jack;
516 jack = kzalloc(sizeof(struct snd_jack), GFP_KERNEL);
517 if (jack == NULL)
520 jack->id = kstrdup(id, GFP_KERNEL);
521 if (jack->id == NULL) {
522 kfree(jack);
527 mutex_init(&jack->input_dev_lock);
529 /* don't create input device for phantom jack */
533 jack->input_dev = input_allocate_device();
534 if (jack->input_dev == NULL) {
539 jack->input_dev->phys = "ALSA";
541 jack->type = type;
545 input_set_capability(jack->input_dev, EV_SW,
551 err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops);
555 jack->card = card;
556 INIT_LIST_HEAD(&jack->kctl_list);
559 snd_jack_kctl_add(jack, jack_kctl);
561 *jjack = jack;
567 input_free_device(jack->input_dev);
569 kfree(jack->id);
570 kfree(jack);
577 * snd_jack_set_parent - Set the parent device for a jack
579 * @jack: The jack to configure
580 * @parent: The device to set as parent for the jack.
582 * Set the parent for the jack devices in the device tree. This
583 * function is only valid prior to registration of the jack. If no
586 void snd_jack_set_parent(struct snd_jack *jack, struct device *parent)
588 WARN_ON(jack->registered);
589 mutex_lock(&jack->input_dev_lock);
590 if (!jack->input_dev) {
591 mutex_unlock(&jack->input_dev_lock);
595 jack->input_dev->dev.parent = parent;
596 mutex_unlock(&jack->input_dev_lock);
601 * snd_jack_set_key - Set a key mapping on a jack
603 * @jack: The jack to configure
608 * reporting of keys on accessories via the jack abstraction. If no
609 * mapping is provided but keys are enabled in the jack type then
621 * This function may only be called prior to registration of the jack.
625 int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type,
630 WARN_ON(jack->registered);
632 if (!keytype || key >= ARRAY_SIZE(jack->key))
635 jack->type |= type;
636 jack->key[key] = keytype;
643 * snd_jack_report - Report the current status of a jack
647 * @jack: The jack to report status for
648 * @status: The current status of the jack
650 void snd_jack_report(struct snd_jack *jack, int status)
659 if (!jack)
662 jack->hw_status_cache = status;
664 list_for_each_entry(jack_kctl, &jack->kctl_list, list)
668 snd_kctl_jack_report(jack->card, jack_kctl->kctl,
672 idev = input_get_device(jack->input_dev);
676 for (i = 0; i < ARRAY_SIZE(jack->key); i++) {
679 if (jack->type & testbit)
680 input_report_key(idev, jack->key[i],
687 if (jack->type & testbit)