summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/audio/audio_mixer.h
blob: 4f84acb44fa3216c2113c6412c7771a4d3510274 (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
/*
 * 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 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 *
 * This header file defines the public interfaces for the audio mixer
 * audio personality module.
 *
 * 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_MIXER_H
#define	_SYS_AUDIO_MIXER_H

#ifdef	__cplusplus
extern "C" {
#endif

#ifdef _KERNEL

/*
 * Miscellaneous defines
 */
struct am_ad_sample_rates {
	uint_t		*ad_srs;	/* NULL term. list of sample rates */
};
typedef struct am_ad_sample_rates am_ad_sample_rates_t;

/*
 * am_ad_ch_cap_t	- Audio Driver play/record capabilities
 */
struct am_ad_ch_cap {
	am_ad_sample_rates_t	ad_mixer_srs;	/* mixer mode sample rates */
	uint_t			*ad_chs;	/* list of channel types */
	int			ad_int_rate;	/* interrupt rate */
	int			ad_max_chs;	/* max channels */
	size_t			ad_bsize;	/* buffer size */
};
typedef struct am_ad_ch_cap am_ad_ch_cap_t;

/*
 * am_ad_cap_comb_t	- Audio Driver play/record capability combinations
 */
struct am_ad_cap_comb {
	int		ad_prec;	/* the data precision */
	int		ad_enc;		/* the data encoding method */
};
typedef struct am_ad_cap_comb am_ad_cap_comb_t;

/*
 * am_ad_entry_t	- Audio Driver ops vector definition
 */
struct am_ad_entry {
	int		(*ad_setup)(audiohdl_t handle, int flags);
	void		(*ad_teardown)(audiohdl_t handle, int dir);
	int		(*ad_set_config)(audiohdl_t handle,
				int command, int dir, int arg1, int arg2);
	int		(*ad_set_format)(audiohdl_t handle,
				int dir, int sample_rate, int channels,
				int precision, int encoding);
	int		(*ad_start_play)(audiohdl_t handle);
	void		(*ad_stop_play)(audiohdl_t handle);
	int		(*ad_start_record)(audiohdl_t handle);
	void		(*ad_stop_record)(audiohdl_t handle);
};
typedef struct am_ad_entry am_ad_entry_t;

/* ad_set_config() commands */
#define	AM_SET_GAIN		0x01	/* set input/ouput channel gain */
#define	AM_SET_PORT		0x03	/* set input/output port */
#define	AM_SET_MONITOR_GAIN	0x04	/* set monitor gain */
#define	AM_OUTPUT_MUTE		0x05	/* mute output */
#define	AM_MIC_BOOST		0x07	/* enable/disable mic preamp */

/*
 * am_ad_info_t	- Audio Driver configuration information structure
 */
struct am_ad_info {
	audio_info_t	*ad_defaults;	/* Audio Driver audio_info_t struct */
	am_ad_ch_cap_t	ad_play;	/* play capabilities */
	am_ad_ch_cap_t	ad_record;	/* record capabilities */
	am_ad_cap_comb_t *ad_play_comb;	/* list of play cap. combinations */
	am_ad_cap_comb_t *ad_rec_comb;	/* list of rec cap. combinations */
	am_ad_entry_t	*ad_entry;	/* Audio Driver entry points */
	audio_device_t	*ad_dev_info;	/* device information */
	int		ad_num_mics;	/* # of mic inputs */
};
typedef struct am_ad_info am_ad_info_t;

/* the taskq lock must be held in order for ad_mode to be valid */
_NOTE(SCHEME_PROTECTS_DATA("method", am_ad_info::ad_mode))

/*
 * Audio Mixer Driver Entry Point Routines
 */
int am_attach(audiohdl_t handle, ddi_attach_cmd_t cmd, am_ad_info_t *ad_infop);
int am_detach(audiohdl_t handle, ddi_detach_cmd_t cmd);

/*
 * Audio Mixer Driver Device Dependent Driver Play Routines
 */
int am_get_audio(audiohdl_t handle, void *buf, int samples);
void am_play_shutdown(audiohdl_t handle);

/*
 * Audio Mixer Driver Device Dependent Driver Record Routines
 */
void am_send_audio(audiohdl_t handle, void *buf, int samples);

/*
 * Audio Mixer Driver Device Dependent Driver Miscellaneous Routines
 */
int am_hw_state_change(audiohdl_t handle, int cmd, int dir, int value,
    int sleep);

/* am_hw_state_change() commands */
#define	AM_HWSC_SET_GAIN_DELTA	0x01
#define	AM_HWSC_SET_BAL_DELTA	0x02
#define	AM_HWSC_MUTE_TOGGLE	0x03
#define	AM_HWSC_ONLINE		0x04
#define	AM_HWSC_OFFLINE		0x05
#define	AM_HWSC_SET_GAIN_ABS	0x06
#define	AM_HWSC_SET_BAL_ABS	0x07

#endif	/* _KERNEL */

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_AUDIO_MIXER_H */