ad1848var.h revision 1.15 1 1.15 martin /* $NetBSD: ad1848var.h,v 1.15 2007/12/11 00:21:51 martin Exp $ */
2 1.1 pk
3 1.4 mycroft /*-
4 1.4 mycroft * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 1.4 mycroft * All rights reserved.
6 1.4 mycroft *
7 1.4 mycroft * This code is derived from software contributed to The NetBSD Foundation
8 1.4 mycroft * by Ken Hornstein and John Kohl.
9 1.4 mycroft *
10 1.4 mycroft * Redistribution and use in source and binary forms, with or without
11 1.4 mycroft * modification, are permitted provided that the following conditions
12 1.4 mycroft * are met:
13 1.4 mycroft * 1. Redistributions of source code must retain the above copyright
14 1.4 mycroft * notice, this list of conditions and the following disclaimer.
15 1.4 mycroft * 2. Redistributions in binary form must reproduce the above copyright
16 1.4 mycroft * notice, this list of conditions and the following disclaimer in the
17 1.4 mycroft * documentation and/or other materials provided with the distribution.
18 1.4 mycroft * 3. All advertising materials mentioning features or use of this software
19 1.4 mycroft * must display the following acknowledgement:
20 1.6 itohy * This product includes software developed by the NetBSD
21 1.6 itohy * Foundation, Inc. and its contributors.
22 1.6 itohy * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.6 itohy * contributors may be used to endorse or promote products derived
24 1.4 mycroft * from this software without specific prior written permission.
25 1.4 mycroft *
26 1.4 mycroft * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.4 mycroft * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.4 mycroft * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.4 mycroft * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.4 mycroft * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.4 mycroft * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.4 mycroft * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.4 mycroft * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.4 mycroft * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.4 mycroft * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.4 mycroft * POSSIBILITY OF SUCH DAMAGE.
37 1.4 mycroft */
38 1.1 pk /*
39 1.1 pk * Copyright (c) 1994 John Brezak
40 1.1 pk * Copyright (c) 1991-1993 Regents of the University of California.
41 1.1 pk * All rights reserved.
42 1.1 pk *
43 1.1 pk * Redistribution and use in source and binary forms, with or without
44 1.1 pk * modification, are permitted provided that the following conditions
45 1.1 pk * are met:
46 1.1 pk * 1. Redistributions of source code must retain the above copyright
47 1.1 pk * notice, this list of conditions and the following disclaimer.
48 1.1 pk * 2. Redistributions in binary form must reproduce the above copyright
49 1.1 pk * notice, this list of conditions and the following disclaimer in the
50 1.1 pk * documentation and/or other materials provided with the distribution.
51 1.1 pk * 3. All advertising materials mentioning features or use of this software
52 1.1 pk * must display the following acknowledgement:
53 1.1 pk * This product includes software developed by the Computer Systems
54 1.1 pk * Engineering Group at Lawrence Berkeley Laboratory.
55 1.1 pk * 4. Neither the name of the University nor of the Laboratory may be used
56 1.1 pk * to endorse or promote products derived from this software without
57 1.1 pk * specific prior written permission.
58 1.1 pk *
59 1.1 pk * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
60 1.1 pk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61 1.1 pk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
62 1.1 pk * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
63 1.1 pk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
64 1.1 pk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
65 1.1 pk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66 1.1 pk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67 1.1 pk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68 1.1 pk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69 1.1 pk * SUCH DAMAGE.
70 1.1 pk *
71 1.1 pk */
72 1.1 pk
73 1.1 pk
74 1.10 martin #define MUTE_LEFT 1
75 1.10 martin #define MUTE_RIGHT 2
76 1.12 kent #define MUTE_ALL (MUTE_LEFT | MUTE_RIGHT)
77 1.10 martin #define MUTE_MONO MUTE_ALL
78 1.10 martin
79 1.10 martin #define WAVE_MUTE0 1 /* force mute (overrides UNMUTE1) */
80 1.10 martin #define WAVE_UNMUTE1 2 /* unmute (overrides MUTE2) */
81 1.10 martin #define WAVE_MUTE2 4 /* weak mute */
82 1.10 martin #define WAVE_MUTE2_INIT 0 /* init and MUTE2 */
83 1.10 martin
84 1.10 martin /*
85 1.10 martin * Don't change this ordering without seriously looking around.
86 1.10 martin * These are indexes into mute[] array and into a register
87 1.10 martin * information array.
88 1.10 martin */
89 1.10 martin #define AD1848_AUX2_CHANNEL 0
90 1.10 martin #define AD1848_AUX1_CHANNEL 1
91 1.10 martin #define AD1848_DAC_CHANNEL 2
92 1.10 martin #define AD1848_LINE_CHANNEL 3
93 1.10 martin #define AD1848_MONO_CHANNEL 4
94 1.10 martin #define AD1848_OUT_CHANNEL 5
95 1.10 martin #define AD1848_MONITOR_CHANNEL 6 /* Doesn't seem to be on all later chips */
96 1.10 martin
97 1.10 martin #define AD1848_NUM_CHANNELS 7
98 1.10 martin
99 1.1 pk struct ad1848_volume {
100 1.1 pk u_char left;
101 1.1 pk u_char right;
102 1.1 pk };
103 1.1 pk
104 1.1 pk struct ad1848_softc {
105 1.1 pk struct device sc_dev; /* base device */
106 1.1 pk bus_space_tag_t sc_iot; /* tag */
107 1.1 pk bus_space_handle_t sc_ioh; /* handle */
108 1.1 pk
109 1.12 kent int (*sc_readreg)(struct ad1848_softc *, int);
110 1.12 kent void (*sc_writereg)(struct ad1848_softc *, int, int);
111 1.1 pk #define ADREAD(sc, index) (*(sc)->sc_readreg)(sc, index)
112 1.1 pk #define ADWRITE(sc, index, data) (*(sc)->sc_writereg)(sc, index, data)
113 1.1 pk
114 1.1 pk void *parent;
115 1.2 pk
116 1.1 pk /* We keep track of these */
117 1.10 martin struct ad1848_volume gains[AD1848_NUM_CHANNELS];
118 1.1 pk struct ad1848_volume rec_gain;
119 1.1 pk
120 1.1 pk int rec_port; /* recording port */
121 1.1 pk
122 1.1 pk /* ad1848 */
123 1.1 pk u_char MCE_bit;
124 1.1 pk char mic_gain_on; /* CS4231 only */
125 1.12 kent char mute[AD1848_NUM_CHANNELS];
126 1.1 pk
127 1.13 christos const char *chip_name;
128 1.1 pk int mode;
129 1.8 itohy int is_ad1845;
130 1.2 pk
131 1.1 pk u_int precision; /* 8/16 bits */
132 1.1 pk int channels;
133 1.2 pk
134 1.1 pk u_char speed_bits;
135 1.1 pk u_char format_bits;
136 1.1 pk u_char need_commit;
137 1.6 itohy
138 1.6 itohy u_char wave_mute_status;
139 1.6 itohy int open_mode;
140 1.1 pk };
141 1.1 pk
142 1.1 pk /*
143 1.2 pk * Ad1848 registers.
144 1.1 pk */
145 1.1 pk #define MIC_IN_PORT 0
146 1.1 pk #define LINE_IN_PORT 1
147 1.1 pk #define AUX1_IN_PORT 2
148 1.1 pk #define DAC_IN_PORT 3
149 1.1 pk
150 1.12 kent #define AD1848_KIND_LVL 0
151 1.12 kent #define AD1848_KIND_MUTE 1
152 1.12 kent #define AD1848_KIND_RECORDGAIN 2
153 1.12 kent #define AD1848_KIND_MICGAIN 3
154 1.1 pk #define AD1848_KIND_RECORDSOURCE 4
155 1.1 pk
156 1.1 pk typedef struct ad1848_devmap {
157 1.1 pk int id;
158 1.1 pk int kind;
159 1.1 pk int dev;
160 1.1 pk } ad1848_devmap_t;
161 1.1 pk
162 1.6 itohy #ifdef _KERNEL
163 1.6 itohy
164 1.12 kent int ad_read(struct ad1848_softc *, int);
165 1.12 kent int ad_xread(struct ad1848_softc *, int);
166 1.12 kent void ad_write(struct ad1848_softc *, int, int);
167 1.12 kent void ad_xwrite(struct ad1848_softc *, int, int);
168 1.12 kent
169 1.12 kent void ad1848_attach(struct ad1848_softc *);
170 1.12 kent void ad1848_reset(struct ad1848_softc *);
171 1.12 kent int ad1848_open(void *, int);
172 1.12 kent void ad1848_close(void *);
173 1.12 kent
174 1.15 martin int ad1848_mixer_get_port(struct ad1848_softc *, const ad1848_devmap_t *,
175 1.12 kent int, mixer_ctrl_t *);
176 1.15 martin int ad1848_mixer_set_port(struct ad1848_softc *, const ad1848_devmap_t *,
177 1.12 kent int, mixer_ctrl_t *);
178 1.12 kent int ad1848_set_speed(struct ad1848_softc *, u_int *);
179 1.12 kent void ad1848_mute_wave_output(struct ad1848_softc *, int, int);
180 1.12 kent int ad1848_query_encoding(void *, struct audio_encoding *);
181 1.12 kent int ad1848_set_params(void *, int, int, audio_params_t *,
182 1.12 kent audio_params_t *, stream_filter_list_t *,
183 1.12 kent stream_filter_list_t *);
184 1.12 kent int ad1848_round_blocksize(void *, int, int, const audio_params_t *);
185 1.12 kent int ad1848_commit_settings(void *);
186 1.12 kent int ad1848_set_rec_port(struct ad1848_softc *, int);
187 1.12 kent int ad1848_get_rec_port(struct ad1848_softc *);
188 1.12 kent int ad1848_set_channel_gain(struct ad1848_softc *, int,
189 1.12 kent struct ad1848_volume *);
190 1.12 kent int ad1848_get_device_gain(struct ad1848_softc *, int,
191 1.12 kent struct ad1848_volume *);
192 1.12 kent int ad1848_set_rec_gain(struct ad1848_softc *, struct ad1848_volume *);
193 1.12 kent int ad1848_get_rec_gain(struct ad1848_softc *, struct ad1848_volume *);
194 1.1 pk /* Note: The mic pre-MUX gain is not a variable gain, it's 20dB or 0dB */
195 1.12 kent int ad1848_set_mic_gain(struct ad1848_softc *, struct ad1848_volume *);
196 1.12 kent int ad1848_get_mic_gain(struct ad1848_softc *, struct ad1848_volume *);
197 1.12 kent void ad1848_mute_channel(struct ad1848_softc *, int, int);
198 1.12 kent int ad1848_to_vol(mixer_ctrl_t *, struct ad1848_volume *);
199 1.12 kent int ad1848_from_vol(mixer_ctrl_t *, struct ad1848_volume *);
200 1.12 kent
201 1.12 kent int ad1848_halt_output(void *);
202 1.12 kent int ad1848_halt_input(void *);
203 1.12 kent paddr_t ad1848_mappage(void *, void *, off_t, int);
204 1.1 pk
205 1.1 pk #ifdef AUDIO_DEBUG
206 1.12 kent void ad1848_dump_regs(struct ad1848_softc *);
207 1.1 pk #endif
208 1.1 pk
209 1.1 pk #endif
210