1 #ifndef __SOUND_CONTROL_H
2 #define __SOUND_CONTROL_H
5 * Header file for control interface
6 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include <sound/asound.h>
27 typedef struct sndrv_aes_iec958 snd_aes_iec958_t
;
28 typedef struct sndrv_ctl_card_info snd_ctl_card_info_t
;
29 typedef enum sndrv_ctl_elem_type snd_ctl_elem_type_t
;
30 typedef enum sndrv_ctl_elem_iface snd_ctl_elem_iface_t
;
31 typedef struct sndrv_ctl_elem_id snd_ctl_elem_id_t
;
32 typedef struct sndrv_ctl_elem_list snd_ctl_elem_list_t
;
33 typedef struct sndrv_ctl_elem_info snd_ctl_elem_info_t
;
34 typedef struct sndrv_ctl_elem_value snd_ctl_elem_value_t
;
35 typedef enum sndrv_ctl_event_type snd_ctl_event_type_t
;
36 typedef struct sndrv_ctl_event snd_ctl_event_t
;
38 #define snd_kcontrol_chip(kcontrol) ((kcontrol)->private_data)
40 typedef int (snd_kcontrol_info_t
) (snd_kcontrol_t
* kcontrol
, snd_ctl_elem_info_t
* uinfo
);
41 typedef int (snd_kcontrol_get_t
) (snd_kcontrol_t
* kcontrol
, snd_ctl_elem_value_t
* ucontrol
);
42 typedef int (snd_kcontrol_put_t
) (snd_kcontrol_t
* kcontrol
, snd_ctl_elem_value_t
* ucontrol
);
44 typedef struct _snd_kcontrol_new
{
45 snd_ctl_elem_iface_t iface
; /* interface identifier */
46 unsigned int device
; /* device/client number */
47 unsigned int subdevice
; /* subdevice (substream) number */
48 unsigned char *name
; /* ASCII name of item */
49 unsigned int index
; /* index of item */
50 unsigned int access
; /* access rights */
51 unsigned int count
; /* count of same elements */
52 snd_kcontrol_info_t
*info
;
53 snd_kcontrol_get_t
*get
;
54 snd_kcontrol_put_t
*put
;
55 unsigned long private_value
;
58 typedef struct _snd_kcontrol_volatile
{
59 snd_ctl_file_t
*owner
; /* locked */
61 unsigned int access
; /* access rights */
62 } snd_kcontrol_volatile_t
;
64 struct _snd_kcontrol
{
65 struct list_head list
; /* list of controls */
67 unsigned int count
; /* count of same elements */
68 snd_kcontrol_info_t
*info
;
69 snd_kcontrol_get_t
*get
;
70 snd_kcontrol_put_t
*put
;
71 unsigned long private_value
;
73 void (*private_free
)(snd_kcontrol_t
*kcontrol
);
74 snd_kcontrol_volatile_t vd
[0]; /* volatile data */
77 #define snd_kcontrol(n) list_entry(n, snd_kcontrol_t, list)
79 typedef struct _snd_kctl_event
{
80 struct list_head list
; /* list of events */
85 #define snd_kctl_event(n) list_entry(n, snd_kctl_event_t, list)
87 struct _snd_ctl_file
{
88 struct list_head list
; /* list of all control files */
91 int prefer_pcm_subdevice
;
92 int prefer_rawmidi_subdevice
;
93 wait_queue_head_t change_sleep
;
95 struct fasync_struct
*fasync
;
96 int subscribed
; /* read interface is activated */
97 struct list_head events
; /* waiting events for read */
100 #define snd_ctl_file(n) list_entry(n, snd_ctl_file_t, list)
102 typedef int (*snd_kctl_ioctl_func_t
) (snd_card_t
* card
,
103 snd_ctl_file_t
* control
,
104 unsigned int cmd
, unsigned long arg
);
106 void snd_ctl_notify(snd_card_t
* card
, unsigned int mask
, snd_ctl_elem_id_t
* id
);
108 snd_kcontrol_t
*snd_ctl_new(snd_kcontrol_t
* kcontrol
, unsigned int access
);
109 snd_kcontrol_t
*snd_ctl_new1(snd_kcontrol_new_t
* kcontrolnew
, void * private_data
);
110 void snd_ctl_free_one(snd_kcontrol_t
* kcontrol
);
111 int snd_ctl_add(snd_card_t
* card
, snd_kcontrol_t
* kcontrol
);
112 int snd_ctl_remove(snd_card_t
* card
, snd_kcontrol_t
* kcontrol
);
113 int snd_ctl_remove_id(snd_card_t
* card
, snd_ctl_elem_id_t
*id
);
114 int snd_ctl_rename_id(snd_card_t
* card
, snd_ctl_elem_id_t
*src_id
, snd_ctl_elem_id_t
*dst_id
);
115 snd_kcontrol_t
*snd_ctl_find_numid(snd_card_t
* card
, unsigned int numid
);
116 snd_kcontrol_t
*snd_ctl_find_id(snd_card_t
* card
, snd_ctl_elem_id_t
*id
);
118 int snd_ctl_create(snd_card_t
*card
);
120 int snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn
);
121 int snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn
);
123 int snd_ctl_register_ioctl_compat(snd_kctl_ioctl_func_t fcn
);
124 int snd_ctl_unregister_ioctl_compat(snd_kctl_ioctl_func_t fcn
);
126 #define snd_ctl_register_ioctl_compat(fcn)
127 #define snd_ctl_unregister_ioctl_compat(fcn)
130 int snd_ctl_elem_read(snd_card_t
*card
, snd_ctl_elem_value_t
*control
);
131 int snd_ctl_elem_write(snd_card_t
*card
, snd_ctl_file_t
*file
, snd_ctl_elem_value_t
*control
);
133 static inline unsigned int snd_ctl_get_ioffnum(snd_kcontrol_t
*kctl
, snd_ctl_elem_id_t
*id
)
135 return id
->numid
- kctl
->id
.numid
;
138 static inline unsigned int snd_ctl_get_ioffidx(snd_kcontrol_t
*kctl
, snd_ctl_elem_id_t
*id
)
140 return id
->index
- kctl
->id
.index
;
143 static inline unsigned int snd_ctl_get_ioff(snd_kcontrol_t
*kctl
, snd_ctl_elem_id_t
*id
)
146 return snd_ctl_get_ioffnum(kctl
, id
);
148 return snd_ctl_get_ioffidx(kctl
, id
);
152 static inline snd_ctl_elem_id_t
*snd_ctl_build_ioff(snd_ctl_elem_id_t
*dst_id
,
153 snd_kcontrol_t
*src_kctl
,
156 *dst_id
= src_kctl
->id
;
157 dst_id
->index
+= offset
;
158 dst_id
->numid
+= offset
;
162 #endif /* __SOUND_CONTROL_H */