ad1848var.h revision 1.6.2.1 1 1.6.2.1 bouyer /* $NetBSD: ad1848var.h,v 1.6.2.1 2000/11/20 11:40:04 bouyer 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.1 pk struct ad1848_volume {
75 1.1 pk u_char left;
76 1.1 pk u_char right;
77 1.1 pk };
78 1.1 pk
79 1.1 pk struct ad1848_softc {
80 1.1 pk struct device sc_dev; /* base device */
81 1.1 pk bus_space_tag_t sc_iot; /* tag */
82 1.1 pk bus_space_handle_t sc_ioh; /* handle */
83 1.1 pk
84 1.1 pk int (*sc_readreg)__P((struct ad1848_softc *, int));
85 1.1 pk void (*sc_writereg)__P((struct ad1848_softc *, int, int));
86 1.1 pk #define ADREAD(sc, index) (*(sc)->sc_readreg)(sc, index)
87 1.1 pk #define ADWRITE(sc, index, data) (*(sc)->sc_writereg)(sc, index, data)
88 1.1 pk
89 1.1 pk void *parent;
90 1.2 pk
91 1.1 pk /* We keep track of these */
92 1.2 pk struct ad1848_volume gains[6];
93 1.1 pk struct ad1848_volume rec_gain;
94 1.1 pk
95 1.1 pk int rec_port; /* recording port */
96 1.1 pk
97 1.1 pk /* ad1848 */
98 1.1 pk u_char MCE_bit;
99 1.1 pk char mic_gain_on; /* CS4231 only */
100 1.1 pk char mute[6];
101 1.1 pk
102 1.1 pk char *chip_name;
103 1.1 pk int mode;
104 1.2 pk
105 1.1 pk u_int precision; /* 8/16 bits */
106 1.1 pk int channels;
107 1.2 pk
108 1.1 pk u_char speed_bits;
109 1.1 pk u_char format_bits;
110 1.1 pk u_char need_commit;
111 1.6 itohy
112 1.6 itohy u_char wave_mute_status;
113 1.6 itohy int open_mode;
114 1.1 pk };
115 1.1 pk
116 1.1 pk #define MUTE_LEFT 1
117 1.1 pk #define MUTE_RIGHT 2
118 1.1 pk #define MUTE_ALL (MUTE_LEFT | MUTE_RIGHT)
119 1.1 pk #define MUTE_MONO MUTE_ALL
120 1.1 pk
121 1.6 itohy #define WAVE_MUTE0 1 /* force mute (overrides UNMUTE1) */
122 1.6 itohy #define WAVE_UNMUTE1 2 /* unmute (overrides MUTE2) */
123 1.6 itohy #define WAVE_MUTE2 4 /* weak mute */
124 1.6 itohy #define WAVE_MUTE2_INIT 0 /* init and MUTE2 */
125 1.6 itohy
126 1.2 pk /*
127 1.2 pk * Don't change this ordering without seriously looking around.
128 1.2 pk * These are indexes into mute[] array and into a register
129 1.2 pk * information array.
130 1.2 pk */
131 1.2 pk #define AD1848_AUX2_CHANNEL 0
132 1.2 pk #define AD1848_AUX1_CHANNEL 1
133 1.2 pk #define AD1848_DAC_CHANNEL 2
134 1.2 pk #define AD1848_LINE_CHANNEL 3
135 1.2 pk #define AD1848_MONO_CHANNEL 4
136 1.2 pk #define AD1848_MONITOR_CHANNEL 5 /* Doesn't seem to be on all later chips */
137 1.1 pk
138 1.1 pk /*
139 1.2 pk * Ad1848 registers.
140 1.1 pk */
141 1.1 pk #define MIC_IN_PORT 0
142 1.1 pk #define LINE_IN_PORT 1
143 1.1 pk #define AUX1_IN_PORT 2
144 1.1 pk #define DAC_IN_PORT 3
145 1.1 pk
146 1.1 pk #define AD1848_KIND_LVL 0
147 1.1 pk #define AD1848_KIND_MUTE 1
148 1.1 pk #define AD1848_KIND_RECORDGAIN 2
149 1.1 pk #define AD1848_KIND_MICGAIN 3
150 1.1 pk #define AD1848_KIND_RECORDSOURCE 4
151 1.1 pk
152 1.1 pk typedef struct ad1848_devmap {
153 1.1 pk int id;
154 1.1 pk int kind;
155 1.1 pk int dev;
156 1.1 pk } ad1848_devmap_t;
157 1.1 pk
158 1.6 itohy #ifdef _KERNEL
159 1.6 itohy
160 1.1 pk int ad_read __P((struct ad1848_softc *, int));
161 1.5 rh int ad_xread __P((struct ad1848_softc *, int));
162 1.1 pk void ad_write __P((struct ad1848_softc *, int, int));
163 1.5 rh void ad_xwrite __P((struct ad1848_softc *, int, int));
164 1.1 pk
165 1.1 pk void ad1848_attach __P((struct ad1848_softc *));
166 1.2 pk void ad1848_reset __P((struct ad1848_softc *));
167 1.1 pk int ad1848_open __P((void *, int));
168 1.1 pk void ad1848_close __P((void *));
169 1.2 pk
170 1.2 pk int ad1848_mixer_get_port __P((struct ad1848_softc *, ad1848_devmap_t *,
171 1.2 pk int, mixer_ctrl_t *));
172 1.2 pk int ad1848_mixer_set_port __P((struct ad1848_softc *, ad1848_devmap_t *,
173 1.2 pk int, mixer_ctrl_t *));
174 1.2 pk int ad1848_set_speed __P((struct ad1848_softc *, u_long *));
175 1.6 itohy void ad1848_mute_wave_output __P((struct ad1848_softc *, int, int));
176 1.1 pk int ad1848_query_encoding __P((void *, struct audio_encoding *));
177 1.2 pk int ad1848_set_params __P((void *, int, int, struct audio_params *,
178 1.2 pk struct audio_params *));
179 1.1 pk int ad1848_round_blocksize __P((void *, int));
180 1.1 pk int ad1848_commit_settings __P((void *));
181 1.1 pk int ad1848_set_rec_port __P((struct ad1848_softc *, int));
182 1.1 pk int ad1848_get_rec_port __P((struct ad1848_softc *));
183 1.2 pk int ad1848_set_channel_gain __P((struct ad1848_softc *, int,
184 1.2 pk struct ad1848_volume *));
185 1.2 pk int ad1848_get_device_gain __P((struct ad1848_softc *, int,
186 1.2 pk struct ad1848_volume *));
187 1.2 pk int ad1848_set_rec_gain __P((struct ad1848_softc *,
188 1.2 pk struct ad1848_volume *));
189 1.2 pk int ad1848_get_rec_gain __P((struct ad1848_softc *,
190 1.2 pk struct ad1848_volume *));
191 1.1 pk /* Note: The mic pre-MUX gain is not a variable gain, it's 20dB or 0dB */
192 1.2 pk int ad1848_set_mic_gain __P((struct ad1848_softc *,
193 1.2 pk struct ad1848_volume *));
194 1.2 pk int ad1848_get_mic_gain __P((struct ad1848_softc *,
195 1.2 pk struct ad1848_volume *));
196 1.2 pk void ad1848_mute_channel __P((struct ad1848_softc *, int device, int mute));
197 1.1 pk int ad1848_to_vol __P((mixer_ctrl_t *, struct ad1848_volume *));
198 1.1 pk int ad1848_from_vol __P((mixer_ctrl_t *, struct ad1848_volume *));
199 1.1 pk
200 1.4 mycroft int ad1848_halt_output __P((void *));
201 1.4 mycroft int ad1848_halt_input __P((void *));
202 1.6.2.1 bouyer paddr_t ad1848_mappage __P((void *, void *, off_t, int));
203 1.1 pk
204 1.1 pk #ifdef AUDIO_DEBUG
205 1.2 pk void ad1848_dump_regs __P((struct ad1848_softc *));
206 1.1 pk #endif
207 1.1 pk
208 1.1 pk #endif
209