summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/audio/audio_support.h
blob: 46e7ecdf78e8c2b4790e4709989e65ae0e258a36 (plain)
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
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (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 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 *
 * This header file defines the public interfaces for the audio support
 * module. These definitions are available for use by all audio modules
 * and drivers.
 *
 * CAUTION: This header file has not gone through a formal review process.
 *	Thus its commitment level is very low and may change or be removed
 *	at any time.
 */

#ifndef	_SYS_AUDIO_SUPPORT_H
#define	_SYS_AUDIO_SUPPORT_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#ifdef	__cplusplus
extern "C" {
#endif

#ifdef _KERNEL

/*
 * Internal audio interface return codes.
 */
#define	AUDIO_SUCCESS			(0)
#define	AUDIO_FAILURE			(-1)

/*
 * Miscellaneous defines.
 */
#define	AUDIO_PRECISION_SHIFT		3
#define	AUDIO_NO_CHANNEL		(-1)
#define	AUDIO_TOGGLE(X)			(X) ^= 1

/*
 * Opaque handle used by all audio drivers to reference the audio
 * support module and all audio personality modules.
 */
typedef struct audio_handle *audiohdl_t;

/*
 * Opaque handle used by all audio personality modules to reference the
 * audio task queue.
 */
typedef struct audio_taskq *audio_taskq_t;

/*
 * audio_i_state	- This structure is used to hold state information
 *			  between M_IOCTL and M_IOCDATA messages from the
 *			  STREAMS head.
 */
struct audio_i_state {
	long	ais_command;	/* the M_IOCDATA command to execute next */
	caddr_t	ais_address;	/* address to M_COPYOUT/M_COPYIN data from/to */
	caddr_t	ais_address2;	/* address to M_COPYOUT/M_COPYIN data from/to */
};
typedef struct audio_i_state audio_i_state_t;

/*
 * audio_sup_reg_data	- This structure is used to provide registration
 *			  data from the audio driver to the audiosup module.
 */
struct audio_sup_reg_data {
	int		asrd_version;	/* version of this data structure */
	char		*asrd_key;	/* unique string used to ID drvr inst */
};
typedef struct audio_sup_reg_data audio_sup_reg_data_t;

_NOTE(SCHEME_PROTECTS_DATA("private data", audio_sup_reg_data::asrd_key))

#define	AUDIOSUP_VERSION	AUDIOSUP_VERSION1
#define	AUDIOSUP_VERSION1	1

/*
 * Audio Support Module Entry Point Routines
 */
audiohdl_t audio_sup_register(dev_info_t *dip, audio_sup_reg_data_t *data);
int audio_sup_unregister(audiohdl_t handle);
int audio_sup_open(queue_t *q, dev_t *devp, int flag, int sflags,
    cred_t *credp);
int audio_sup_close(queue_t *q, int flag, cred_t *credp);
int audio_sup_getinfo(dev_info_t *dip, ddi_info_cmd_t infocmd,
    void *arg, void **result);
int audio_sup_restore_state(audiohdl_t handle, audio_device_type_e device,
    int dir);
int audio_sup_save_state(audiohdl_t handle, audio_device_type_e device,
    int dir);

#define	AUDIO_ALL_DEVICES	UNDEFINED

int audio_sup_rput(queue_t *q, mblk_t *mp);
int audio_sup_rsvc(queue_t *q);
int audio_sup_wput(queue_t *q, mblk_t *mp);
int audio_sup_wsvc(queue_t *q);

/*
 * Audio Support Module Entry Point Routines
 *	CAUTION: These routines will be removed from the next
 *		release of Solaris. Migrate to audio_sup_register()
 *		and audio_sup_unregister().
 */
audiohdl_t audio_sup_attach(dev_info_t *dip, ddi_attach_cmd_t cmd);
int audio_sup_detach(audiohdl_t handle, ddi_detach_cmd_t cmd);

/*
 * Audio Support Module STREAMS Private Data Routines
 */
void audio_sup_set_qptr(queue_t *q, dev_t dev, void *data);
void audio_sup_free_qptr(queue_t *q);
dev_t audio_sup_get_qptr_dev(queue_t *q);
void *audio_sup_get_qptr_data(queue_t *q);
int audio_sup_get_qptr_instance(queue_t *q);

/*
 * Audio Support Module Minor Routines
 */
int audio_sup_get_max_chs(audiohdl_t handle);
int audio_sup_get_minors_per_inst(audiohdl_t handle);
int audio_sup_construct_minor(audiohdl_t handle, audio_device_type_e type);
int audio_sup_devt_to_instance(dev_t devt);

/*
 * Audio Support Module Miscellaneous Routines
 */
dev_info_t *audio_sup_get_dip(audiohdl_t handle);
void *audio_sup_get_private(audiohdl_t handle);
void audio_sup_set_private(audiohdl_t handle, void *private);
/*PRINTFLIKE3*/
extern void audio_sup_log(audiohdl_t handle, uint_t level, char *fmt, ...)
    __KPRINTFLIKE(3);
int audio_sup_update_persist_key(dev_info_t *dip, char *new_key, int sleep);


#ifdef _SYSCALL32
/* ILP32 view of the audio_channel structure */
struct audio_channel32 {
	pid32_t			pid;		/* process ID */
	uint32_t		ch_number;	/* channel number */
	int32_t			dev_type;	/* device type */
	size32_t		info_size;	/* size of info structure */
	caddr32_t		info;		/* pointer to info structure */
};
#endif

#endif	/* _KERNEL */

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_AUDIO_SUPPORT_H */