1 | #ifndef __CONTROL_H
|
---|
2 | #define __CONTROL_H
|
---|
3 |
|
---|
4 | /*
|
---|
5 | * Header file for control interface
|
---|
6 | * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * This program is free software; you can redistribute it and/or modify
|
---|
10 | * it under the terms of the GNU General Public License as published by
|
---|
11 | * the Free Software Foundation; either version 2 of the License, or
|
---|
12 | * (at your option) any later version.
|
---|
13 | *
|
---|
14 | * This program is distributed in the hope that it will be useful,
|
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
17 | * GNU General Public License for more details.
|
---|
18 | *
|
---|
19 | * You should have received a copy of the GNU General Public License
|
---|
20 | * along with this program; if not, write to the Free Software
|
---|
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
22 | *
|
---|
23 | */
|
---|
24 |
|
---|
25 | #define snd_kcontrol_chip(kcontrol) ((kcontrol)->private_data)
|
---|
26 | struct snd_kcontrol;
|
---|
27 | typedef int (snd_kcontrol_info_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_info * uinfo);
|
---|
28 | typedef int (snd_kcontrol_get_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol);
|
---|
29 | typedef int (snd_kcontrol_put_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol);
|
---|
30 |
|
---|
31 | struct snd_kcontrol_new {
|
---|
32 | snd_ctl_elem_iface_t iface; /* interface identifier */
|
---|
33 | unsigned int device; /* device/client number */
|
---|
34 | unsigned int subdevice; /* subdevice (substream) number */
|
---|
35 | unsigned char *name; /* ASCII name of item */
|
---|
36 | unsigned int index; /* index of item */
|
---|
37 | unsigned int access; /* access rights */
|
---|
38 | unsigned int count; /* count of same elements */
|
---|
39 | snd_kcontrol_info_t *info;
|
---|
40 | snd_kcontrol_get_t *get;
|
---|
41 | snd_kcontrol_put_t *put;
|
---|
42 | unsigned long private_value;
|
---|
43 | };
|
---|
44 |
|
---|
45 | struct snd_kcontrol_volatile {
|
---|
46 | struct snd_ctl_file *owner; /* locked */
|
---|
47 | pid_t owner_pid;
|
---|
48 | unsigned int access; /* access rights */
|
---|
49 | };
|
---|
50 |
|
---|
51 | struct snd_kcontrol {
|
---|
52 | struct list_head list; /* list of controls */
|
---|
53 | struct snd_ctl_elem_id id;
|
---|
54 | unsigned int count; /* count of same elements */
|
---|
55 | snd_kcontrol_info_t *info;
|
---|
56 | snd_kcontrol_get_t *get;
|
---|
57 | snd_kcontrol_put_t *put;
|
---|
58 | unsigned long private_value;
|
---|
59 | #ifdef TARGET_OS2
|
---|
60 | void *private_ptr;
|
---|
61 | #endif
|
---|
62 | void *private_data;
|
---|
63 | void (*private_free)(struct snd_kcontrol *kcontrol);
|
---|
64 | struct snd_kcontrol_volatile vd[1]; /* volatile data */
|
---|
65 | //snd_kcontrol_volatile_t vd[1]; /* volatile data */
|
---|
66 | };
|
---|
67 |
|
---|
68 | #define snd_kcontrol(n) list_entry(n, struct snd_kcontrol, list)
|
---|
69 |
|
---|
70 | struct snd_kctl_event {
|
---|
71 | struct list_head list; /* list of events */
|
---|
72 | struct snd_ctl_elem_id id;
|
---|
73 | unsigned int mask;
|
---|
74 | };
|
---|
75 |
|
---|
76 | #define snd_kctl_event(n) list_entry(n, struct snd_kctl_event, list)
|
---|
77 |
|
---|
78 | struct snd_ctl_file {
|
---|
79 | struct list_head list; /* list of all control files */
|
---|
80 | struct snd_card *card;
|
---|
81 | pid_t pid;
|
---|
82 | int prefer_pcm_subdevice;
|
---|
83 | int prefer_rawmidi_subdevice;
|
---|
84 | wait_queue_head_t change_sleep;
|
---|
85 | spinlock_t read_lock;
|
---|
86 | struct fasync_struct *fasync;
|
---|
87 | int subscribed; /* read interface is activated */
|
---|
88 | struct list_head events; /* waiting events for read */
|
---|
89 | };
|
---|
90 |
|
---|
91 | #define snd_ctl_file(n) list_entry(n, struct snd_ctl_file, list)
|
---|
92 |
|
---|
93 | typedef int (*snd_kctl_ioctl_func_t) (struct snd_card * card,
|
---|
94 | struct snd_ctl_file * control,
|
---|
95 | unsigned int cmd, unsigned long arg);
|
---|
96 |
|
---|
97 | void snd_ctl_notify(struct snd_card * card, unsigned int mask, struct snd_ctl_elem_id * id);
|
---|
98 |
|
---|
99 | struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol * kcontrol, unsigned int access);
|
---|
100 | struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new * kcontrolnew, void * private_data);
|
---|
101 | void snd_ctl_free_one(struct snd_kcontrol * kcontrol);
|
---|
102 | int snd_ctl_add(struct snd_card * card, struct snd_kcontrol * kcontrol);
|
---|
103 | int snd_ctl_remove(struct snd_card * card, struct snd_kcontrol * kcontrol);
|
---|
104 | int snd_ctl_remove_id(struct snd_card * card, struct snd_ctl_elem_id *id);
|
---|
105 | int snd_ctl_rename_id(struct snd_card * card, struct snd_ctl_elem_id *src_id, struct snd_ctl_elem_id *dst_id);
|
---|
106 | struct snd_kcontrol *snd_ctl_find_numid(struct snd_card * card, unsigned int numid);
|
---|
107 | struct snd_kcontrol *snd_ctl_find_id(struct snd_card * card, struct snd_ctl_elem_id *id);
|
---|
108 |
|
---|
109 | int snd_ctl_create(struct snd_card *card);
|
---|
110 |
|
---|
111 | int snd_ctl_register(struct snd_card *card);
|
---|
112 | int snd_ctl_disconnect(struct snd_card *card);
|
---|
113 | int snd_ctl_can_unregister(struct snd_card *card);
|
---|
114 | int snd_ctl_unregister(struct snd_card *card);
|
---|
115 | int snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn);
|
---|
116 | int snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn);
|
---|
117 |
|
---|
118 | int snd_ctl_elem_read(struct snd_card *card, struct snd_ctl_elem_value *control);
|
---|
119 | int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file, struct snd_ctl_elem_value *control);
|
---|
120 |
|
---|
121 | static inline unsigned int snd_ctl_get_ioffnum(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id)
|
---|
122 | {
|
---|
123 | return id->numid - kctl->id.numid;
|
---|
124 | }
|
---|
125 |
|
---|
126 | static inline unsigned int snd_ctl_get_ioffidx(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id)
|
---|
127 | {
|
---|
128 | return id->index - kctl->id.index;
|
---|
129 | }
|
---|
130 |
|
---|
131 | static inline unsigned int snd_ctl_get_ioff(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id)
|
---|
132 | {
|
---|
133 | if (id->numid) {
|
---|
134 | return snd_ctl_get_ioffnum(kctl, id);
|
---|
135 | } else {
|
---|
136 | return snd_ctl_get_ioffidx(kctl, id);
|
---|
137 | }
|
---|
138 | }
|
---|
139 |
|
---|
140 | #endif /* __CONTROL_H */
|
---|