1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _AUDIO_CLIENT_H
#define _AUDIO_CLIENT_H
/*
* Structure implementation in audio_impl.h
*/
#include <sys/audio/audio_common.h>
typedef struct audio_client_ops {
const char *aco_minor_prefix;
void *(*aco_dev_init)(audio_dev_t *);
void (*aco_dev_fini)(void *);
int (*aco_open)(audio_client_t *, int);
void (*aco_close)(audio_client_t *);
int (*aco_read)(audio_client_t *, struct uio *, cred_t *);
int (*aco_write)(audio_client_t *, struct uio *, cred_t *);
int (*aco_ioctl)(audio_client_t *, int, intptr_t, int,
cred_t *, int *);
int (*aco_chpoll)(audio_client_t *, short, int, short *,
struct pollhead **);
int (*aco_mmap)(audio_client_t *, ...);
void (*aco_input)(audio_client_t *);
void (*aco_output)(audio_client_t *);
void (*aco_drain)(audio_client_t *);
void (*aco_wput)(audio_client_t *, mblk_t *);
void (*aco_wsrv)(audio_client_t *);
void (*aco_rsrv)(audio_client_t *);
} audio_client_ops_t;
void *auclnt_get_private(audio_client_t *);
void auclnt_set_private(audio_client_t *, void *);
int auclnt_drain(audio_client_t *);
int auclnt_start_drain(audio_client_t *);
int auclnt_set_rate(audio_stream_t *, int);
int auclnt_get_rate(audio_stream_t *);
int auclnt_set_format(audio_stream_t *, int);
int auclnt_get_format(audio_stream_t *);
int auclnt_set_channels(audio_stream_t *, int);
int auclnt_get_channels(audio_stream_t *);
void auclnt_set_gain(audio_stream_t *, uint8_t);
uint8_t auclnt_get_gain(audio_stream_t *);
void auclnt_set_muted(audio_stream_t *, boolean_t);
boolean_t auclnt_get_muted(audio_stream_t *);
uint64_t auclnt_get_samples(audio_stream_t *);
void auclnt_set_samples(audio_stream_t *, uint64_t);
uint64_t auclnt_get_errors(audio_stream_t *);
void auclnt_set_errors(audio_stream_t *, uint64_t);
uint64_t auclnt_get_eof(audio_stream_t *);
void auclnt_set_eof(audio_stream_t *, uint64_t);
boolean_t auclnt_is_running(audio_stream_t *);
void auclnt_start(audio_stream_t *);
void auclnt_stop(audio_stream_t *);
void auclnt_set_paused(audio_stream_t *);
void auclnt_clear_paused(audio_stream_t *);
boolean_t auclnt_is_paused(audio_stream_t *);
void auclnt_flush(audio_stream_t *);
void auclnt_get_output_qlen(audio_client_t *, uint_t *, uint_t *);
uint_t auclnt_get_fragsz(audio_stream_t *);
uint_t auclnt_get_framesz(audio_stream_t *);
uint_t auclnt_get_nfrags(audio_stream_t *);
uint_t auclnt_get_nframes(audio_stream_t *);
uint_t auclnt_get_count(audio_stream_t *);
uint64_t auclnt_get_head(audio_stream_t *);
uint64_t auclnt_get_tail(audio_stream_t *);
uint_t auclnt_get_hidx(audio_stream_t *);
uint_t auclnt_get_tidx(audio_stream_t *);
void auclnt_set_latency(audio_stream_t *, uint_t, uint_t);
audio_stream_t *auclnt_input_stream(audio_client_t *);
audio_stream_t *auclnt_output_stream(audio_client_t *);
int auclnt_get_oflag(audio_client_t *);
int auclnt_open(audio_client_t *, int);
void auclnt_close(audio_client_t *);
void auclnt_register_ops(minor_t, audio_client_ops_t *);
minor_t auclnt_get_minor(audio_client_t *);
minor_t auclnt_get_original_minor(audio_client_t *);
minor_t auclnt_get_minor_type(audio_client_t *);
queue_t *auclnt_get_rq(audio_client_t *);
queue_t *auclnt_get_wq(audio_client_t *);
uint_t auclnt_produce(audio_stream_t *, uint_t);
uint_t auclnt_produce_data(audio_stream_t *, caddr_t, uint_t);
uint_t auclnt_consume(audio_stream_t *, uint_t);
uint_t auclnt_consume_data(audio_stream_t *, caddr_t, uint_t);
int auclnt_read(audio_client_t *, struct uio *);
int auclnt_write(audio_client_t *, struct uio *);
int auclnt_chpoll(audio_client_t *, short, int, short *, struct pollhead **);
void auclnt_pollwakeup(audio_client_t *, short);
/*
* Return the process id that performed the original open() of the client.
*/
pid_t auclnt_get_pid(audio_client_t *);
/*
* Return the credentials of the process that opened the client.
*/
cred_t *auclnt_get_cred(audio_client_t *);
/*
* Get an opaque handle the underlying device for an audio client.
*/
audio_dev_t *auclnt_get_dev(audio_client_t *);
audio_dev_t *auclnt_hold_dev_by_index(int);
void auclnt_release_dev(audio_dev_t *);
int auclnt_get_dev_index(audio_dev_t *);
int auclnt_get_dev_number(audio_dev_t *);
void auclnt_set_dev_number(audio_dev_t *, int);
const char *auclnt_get_dev_name(audio_dev_t *);
const char *auclnt_get_dev_driver(audio_dev_t *);
dev_info_t *auclnt_get_dev_devinfo(audio_dev_t *);
int auclnt_get_dev_instance(audio_dev_t *);
const char *auclnt_get_dev_description(audio_dev_t *);
const char *auclnt_get_dev_version(audio_dev_t *);
const char *auclnt_get_dev_hw_info(audio_dev_t *, void **);
uint_t auclnt_get_dev_capab(audio_dev_t *);
#define AUDIO_CLIENT_CAP_PLAY (1U << 0)
#define AUDIO_CLIENT_CAP_RECORD (1U << 1)
#define AUDIO_CLIENT_CAP_DUPLEX (1U << 2)
#define AUDIO_CLIENT_CAP_SNDSTAT (1U << 3)
#define AUDIO_CLIENT_CAP_OPAQUE (1U << 4)
/*
* Walk all the open client structures for a named audio device.
* Clients can use this to find "peer" clients accessing the same
* audio device. (This is useful for implementing special linkages,
* e.g. between /dev/audio and /dev/audioctl.)
*/
void auclnt_dev_walk_clients(audio_dev_t *,
int (*)(audio_client_t *, void *), void *);
/*
* This is used to check for updates to volume and control status.
* Its a polling-based interface because that's what our clients (OSS)
* need, and its far lighter weight than forcing an asynchronous
* callback on everything.
*/
uint_t auclnt_dev_get_serial(audio_dev_t *);
/*
* Audio control functions for use by clients.
*/
/*
* This will walk all controls registered to my device and callback
* to walker for each one with its audio_ctrl_desc_t..
*
* Note that walk_func may return values to continue (AUDIO_WALK_CONTINUE)
* or stop walk (AUDIO_WALK_STOP).
*
*/
void auclnt_walk_controls(audio_dev_t *,
int (*)(audio_ctrl_t *, void *), void *);
/*
* This will search all controls attached to a clients
* audio device for a control with the desired name.
*
* On successful return a ctrl handle will be returned. On
* failure NULL is returned.
*/
audio_ctrl_t *auclnt_find_control(audio_dev_t *, const char *);
/*
* Given a known control, get its attributes.
*
* The caller must supply a audio_ctrl_desc_t structure. Also the
* values in the structure are ignored when making the call and filled
* in by this function.
*
* If an error occurs then a non-zero is returned.
*/
int auclnt_control_describe(audio_ctrl_t *, audio_ctrl_desc_t *);
/*
* This is used to read the current value of a control.
* Note, this will cause a callback into the driver to get the value.
*
* On return zero is returned on success else errno is returned.
*/
int auclnt_control_read(audio_ctrl_t *, uint64_t *);
/*
* This is used to write a value to a control.
* Note, this will cause a callback into the driver to write the value.
*
* On return zero is returned on success else errno is returned.
*
*/
int auclnt_control_write(audio_ctrl_t *, uint64_t);
/*
* Walk all the audio devices on the system. Useful for clients
* like sndstat, which may need to inquire about every audio device
* on the system.
*/
void auclnt_walk_devs(int (*walker)(audio_dev_t *, void *), void *);
void auclnt_walk_devs_by_number(int (*walker)(audio_dev_t *, void *), void *);
audio_client_t *auclnt_hold_by_devt(dev_t);
void auclnt_release(audio_client_t *);
void auclnt_hold(audio_client_t *);
int auclnt_serialize(audio_client_t *);
void auclnt_unserialize(audio_client_t *);
/*
* Engine rlated accesses. Note that normally clients don't need this level
* of information.
*/
void auclnt_dev_walk_engines(audio_dev_t *,
int (*)(audio_engine_t *, void *), void *);
int auclnt_engine_get_format(audio_engine_t *);
int auclnt_engine_get_rate(audio_engine_t *);
int auclnt_engine_get_channels(audio_engine_t *);
uint_t auclnt_engine_get_capab(audio_engine_t *);
/*
* Retrieve minor-specific data for the instance. This allows for
* personality modules to store persistent state data on a physical
* device (e.g. to store persistent settings.) Synchronization of
* stored settings between personality modules is up to the
* personality modules themselves.
*/
void *auclnt_get_minor_data(audio_client_t *, minor_t);
void *auclnt_get_dev_minor_data(audio_dev_t *, minor_t);
/*
* Simpler warning message, alternative to cmn_err.
*/
void auclnt_warn(audio_client_t *, const char *fmt, ...);
#endif /* _AUDIO_CLIENT_H */
|