Lines Matching +full:zero +full:- +full:initialised
1 // SPDX-License-Identifier: GPL-2.0-or-later
35 struct snd_jack *jack = device->device_data; in snd_jack_dev_disconnect()
37 if (!jack->input_dev) in snd_jack_dev_disconnect()
42 if (jack->registered) in snd_jack_dev_disconnect()
43 input_unregister_device(jack->input_dev); in snd_jack_dev_disconnect()
45 input_free_device(jack->input_dev); in snd_jack_dev_disconnect()
46 jack->input_dev = NULL; in snd_jack_dev_disconnect()
53 struct snd_jack *jack = device->device_data; in snd_jack_dev_free()
54 struct snd_card *card = device->card; in snd_jack_dev_free()
57 list_for_each_entry_safe(jack_kctl, tmp_jack_kctl, &jack->kctl_list, list) { in snd_jack_dev_free()
58 list_del_init(&jack_kctl->list); in snd_jack_dev_free()
59 snd_ctl_remove(card, jack_kctl->kctl); in snd_jack_dev_free()
61 if (jack->private_free) in snd_jack_dev_free()
62 jack->private_free(jack); in snd_jack_dev_free()
66 kfree(jack->id); in snd_jack_dev_free()
75 struct snd_jack *jack = device->device_data; in snd_jack_dev_register()
76 struct snd_card *card = device->card; in snd_jack_dev_register()
79 snprintf(jack->name, sizeof(jack->name), "%s %s", in snd_jack_dev_register()
80 card->shortname, jack->id); in snd_jack_dev_register()
82 if (!jack->input_dev) in snd_jack_dev_register()
85 jack->input_dev->name = jack->name; in snd_jack_dev_register()
88 if (!jack->input_dev->dev.parent) in snd_jack_dev_register()
89 jack->input_dev->dev.parent = snd_card_get_device_link(card); in snd_jack_dev_register()
92 for (i = 0; i < ARRAY_SIZE(jack->key); i++) { in snd_jack_dev_register()
95 if (!(jack->type & testbit)) in snd_jack_dev_register()
98 if (!jack->key[i]) in snd_jack_dev_register()
99 jack->key[i] = BTN_0 + i; in snd_jack_dev_register()
101 input_set_capability(jack->input_dev, EV_KEY, jack->key[i]); in snd_jack_dev_register()
104 err = input_register_device(jack->input_dev); in snd_jack_dev_register()
106 jack->registered = 1; in snd_jack_dev_register()
116 jack_kctl = kctl->private_data; in snd_jack_kctl_private_free()
118 list_del(&jack_kctl->list); in snd_jack_kctl_private_free()
125 list_add_tail(&jack_kctl->list, &jack->kctl_list); in snd_jack_kctl_add()
147 jack_kctl->kctl = kctl; in snd_jack_kctl_new()
148 jack_kctl->mask_bits = mask; in snd_jack_kctl_new()
150 kctl->private_data = jack_kctl; in snd_jack_kctl_new()
151 kctl->private_free = snd_jack_kctl_private_free; in snd_jack_kctl_new()
160 * snd_jack_add_new_kctl - Create a new snd_jack_kctl and add it to jack
168 * Return: Zero if successful, or a negative error code on failure.
174 jack_kctl = snd_jack_kctl_new(jack->card, name, mask); in snd_jack_add_new_kctl()
176 return -ENOMEM; in snd_jack_add_new_kctl()
184 * snd_jack_new - Create a new jack
195 * Return: Zero if successful, or a negative error code on failure.
196 * On success @jjack will be initialised.
215 return -ENOMEM; in snd_jack_new()
220 return -ENOMEM; in snd_jack_new()
222 jack->id = kstrdup(id, GFP_KERNEL); in snd_jack_new()
229 jack->input_dev = input_allocate_device(); in snd_jack_new()
230 if (jack->input_dev == NULL) { in snd_jack_new()
231 err = -ENOMEM; in snd_jack_new()
235 jack->input_dev->phys = "ALSA"; in snd_jack_new()
237 jack->type = type; in snd_jack_new()
241 input_set_capability(jack->input_dev, EV_SW, in snd_jack_new()
251 jack->card = card; in snd_jack_new()
252 INIT_LIST_HEAD(&jack->kctl_list); in snd_jack_new()
263 input_free_device(jack->input_dev); in snd_jack_new()
265 kfree(jack->id); in snd_jack_new()
273 * snd_jack_set_parent - Set the parent device for a jack
284 WARN_ON(jack->registered); in snd_jack_set_parent()
285 if (!jack->input_dev) in snd_jack_set_parent()
288 jack->input_dev->dev.parent = parent; in snd_jack_set_parent()
293 * snd_jack_set_key - Set a key mapping on a jack
309 * access the input device directly - devices with complex input
315 * Return: Zero if successful, or a negative error code on failure.
320 int key = fls(SND_JACK_BTN_0) - fls(type); in snd_jack_set_key()
322 WARN_ON(jack->registered); in snd_jack_set_key()
324 if (!keytype || key >= ARRAY_SIZE(jack->key)) in snd_jack_set_key()
325 return -EINVAL; in snd_jack_set_key()
327 jack->type |= type; in snd_jack_set_key()
328 jack->key[key] = keytype; in snd_jack_set_key()
335 * snd_jack_report - Report the current status of a jack
350 list_for_each_entry(jack_kctl, &jack->kctl_list, list) in snd_jack_report()
351 snd_kctl_jack_report(jack->card, jack_kctl->kctl, in snd_jack_report()
352 status & jack_kctl->mask_bits); in snd_jack_report()
355 if (!jack->input_dev) in snd_jack_report()
358 for (i = 0; i < ARRAY_SIZE(jack->key); i++) { in snd_jack_report()
361 if (jack->type & testbit) in snd_jack_report()
362 input_report_key(jack->input_dev, jack->key[i], in snd_jack_report()
368 if (jack->type & testbit) in snd_jack_report()
369 input_report_switch(jack->input_dev, in snd_jack_report()
374 input_sync(jack->input_dev); in snd_jack_report()