Lines Matching refs:jack

11 #include <sound/jack.h>
17 struct list_head list; /* list of controls belong to the same jack */
35 struct snd_jack *jack = device->device_data;
37 mutex_lock(&jack->input_dev_lock);
38 if (!jack->input_dev) {
39 mutex_unlock(&jack->input_dev_lock);
45 if (jack->registered)
46 input_unregister_device(jack->input_dev);
48 input_free_device(jack->input_dev);
49 jack->input_dev = NULL;
50 mutex_unlock(&jack->input_dev_lock);
57 struct snd_jack *jack = device->device_data;
62 list_for_each_entry_safe(jack_kctl, tmp_jack_kctl, &jack->kctl_list, list) {
68 if (jack->private_free)
69 jack->private_free(jack);
73 kfree(jack->id);
74 kfree(jack);
82 struct snd_jack *jack = device->device_data;
86 snprintf(jack->name, sizeof(jack->name), "%s %s",
87 card->shortname, jack->id);
89 mutex_lock(&jack->input_dev_lock);
90 if (!jack->input_dev) {
91 mutex_unlock(&jack->input_dev_lock);
95 jack->input_dev->name = jack->name;
98 if (!jack->input_dev->dev.parent)
99 jack->input_dev->dev.parent = snd_card_get_device_link(card);
102 for (i = 0; i < ARRAY_SIZE(jack->key); i++) {
105 if (!(jack->type & testbit))
108 if (!jack->key[i])
109 jack->key[i] = BTN_0 + i;
111 input_set_capability(jack->input_dev, EV_KEY, jack->key[i]);
114 err = input_register_device(jack->input_dev);
116 jack->registered = 1;
118 mutex_unlock(&jack->input_dev_lock);
134 static void snd_jack_kctl_add(struct snd_jack *jack, struct snd_jack_kctl *jack_kctl)
136 list_add_tail(&jack_kctl->list, &jack->kctl_list);
171 * snd_jack_add_new_kctl - Create a new snd_jack_kctl and add it to jack
172 * @jack: the jack instance which the kctl will attaching to
177 * Creates a new snd_kcontrol object and adds it to the jack kctl_list.
181 int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask)
185 jack_kctl = snd_jack_kctl_new(jack->card, name, mask);
189 snd_jack_kctl_add(jack, jack_kctl);
195 * snd_jack_new - Create a new jack
197 * @id: an identifying string for this jack
199 * this jack
200 * @jjack: Used to provide the allocated jack object to the caller.
201 * @initial_kctl: if true, create a kcontrol and add it to the jack list.
204 * Creates a new jack object.
212 struct snd_jack *jack;
229 jack = kzalloc(sizeof(struct snd_jack), GFP_KERNEL);
230 if (jack == NULL)
233 jack->id = kstrdup(id, GFP_KERNEL);
234 if (jack->id == NULL) {
235 kfree(jack);
240 mutex_init(&jack->input_dev_lock);
242 /* don't create input device for phantom jack */
246 jack->input_dev = input_allocate_device();
247 if (jack->input_dev == NULL) {
252 jack->input_dev->phys = "ALSA";
254 jack->type = type;
258 input_set_capability(jack->input_dev, EV_SW,
264 err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops);
268 jack->card = card;
269 INIT_LIST_HEAD(&jack->kctl_list);
272 snd_jack_kctl_add(jack, jack_kctl);
274 *jjack = jack;
280 input_free_device(jack->input_dev);
282 kfree(jack->id);
283 kfree(jack);
290 * snd_jack_set_parent - Set the parent device for a jack
292 * @jack: The jack to configure
293 * @parent: The device to set as parent for the jack.
295 * Set the parent for the jack devices in the device tree. This
296 * function is only valid prior to registration of the jack. If no
299 void snd_jack_set_parent(struct snd_jack *jack, struct device *parent)
301 WARN_ON(jack->registered);
302 mutex_lock(&jack->input_dev_lock);
303 if (!jack->input_dev) {
304 mutex_unlock(&jack->input_dev_lock);
308 jack->input_dev->dev.parent = parent;
309 mutex_unlock(&jack->input_dev_lock);
314 * snd_jack_set_key - Set a key mapping on a jack
316 * @jack: The jack to configure
321 * reporting of keys on accessories via the jack abstraction. If no
322 * mapping is provided but keys are enabled in the jack type then
334 * This function may only be called prior to registration of the jack.
338 int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type,
343 WARN_ON(jack->registered);
345 if (!keytype || key >= ARRAY_SIZE(jack->key))
348 jack->type |= type;
349 jack->key[key] = keytype;
356 * snd_jack_report - Report the current status of a jack
360 * @jack: The jack to report status for
361 * @status: The current status of the jack
363 void snd_jack_report(struct snd_jack *jack, int status)
371 if (!jack)
374 list_for_each_entry(jack_kctl, &jack->kctl_list, list)
375 snd_kctl_jack_report(jack->card, jack_kctl->kctl,
379 idev = input_get_device(jack->input_dev);
383 for (i = 0; i < ARRAY_SIZE(jack->key); i++) {
386 if (jack->type & testbit)
387 input_report_key(idev, jack->key[i],
393 if (jack->type & testbit)