source: GPL/alsa-kernel/include/sound/control.h@ 1

Last change on this file since 1 was 1, checked in by vladest, 20 years ago

initial import

File size: 5.3 KB
Line 
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)
26struct snd_kcontrol;
27typedef int (snd_kcontrol_info_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_info * uinfo);
28typedef int (snd_kcontrol_get_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol);
29typedef int (snd_kcontrol_put_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol);
30
31struct 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
45struct snd_kcontrol_volatile {
46 struct snd_ctl_file *owner; /* locked */
47 pid_t owner_pid;
48 unsigned int access; /* access rights */
49};
50
51struct 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
70struct 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
78struct 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
93typedef int (*snd_kctl_ioctl_func_t) (struct snd_card * card,
94 struct snd_ctl_file * control,
95 unsigned int cmd, unsigned long arg);
96
97void snd_ctl_notify(struct snd_card * card, unsigned int mask, struct snd_ctl_elem_id * id);
98
99struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol * kcontrol, unsigned int access);
100struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new * kcontrolnew, void * private_data);
101void snd_ctl_free_one(struct snd_kcontrol * kcontrol);
102int snd_ctl_add(struct snd_card * card, struct snd_kcontrol * kcontrol);
103int snd_ctl_remove(struct snd_card * card, struct snd_kcontrol * kcontrol);
104int snd_ctl_remove_id(struct snd_card * card, struct snd_ctl_elem_id *id);
105int snd_ctl_rename_id(struct snd_card * card, struct snd_ctl_elem_id *src_id, struct snd_ctl_elem_id *dst_id);
106struct snd_kcontrol *snd_ctl_find_numid(struct snd_card * card, unsigned int numid);
107struct snd_kcontrol *snd_ctl_find_id(struct snd_card * card, struct snd_ctl_elem_id *id);
108
109int snd_ctl_create(struct snd_card *card);
110
111int snd_ctl_register(struct snd_card *card);
112int snd_ctl_disconnect(struct snd_card *card);
113int snd_ctl_can_unregister(struct snd_card *card);
114int snd_ctl_unregister(struct snd_card *card);
115int snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn);
116int snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn);
117
118int snd_ctl_elem_read(struct snd_card *card, struct snd_ctl_elem_value *control);
119int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file, struct snd_ctl_elem_value *control);
120
121static 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
126static 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
131static 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 */
Note: See TracBrowser for help on using the repository browser.