ad1848var.h revision 1.5 1 1.5 rh /* $NetBSD: ad1848var.h,v 1.5 1999/09/06 17:07:05 rh 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.4 mycroft * This product includes software developed by the NetBSD
21 1.4 mycroft * Foundation, Inc. and its contributors.
22 1.4 mycroft * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.4 mycroft * 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.1 pk };
112 1.1 pk
113 1.1 pk #define MUTE_LEFT 1
114 1.1 pk #define MUTE_RIGHT 2
115 1.1 pk #define MUTE_ALL (MUTE_LEFT | MUTE_RIGHT)
116 1.1 pk #define MUTE_MONO MUTE_ALL
117 1.1 pk
118 1.2 pk /*
119 1.2 pk * Don't change this ordering without seriously looking around.
120 1.2 pk * These are indexes into mute[] array and into a register
121 1.2 pk * information array.
122 1.2 pk */
123 1.2 pk #define AD1848_AUX2_CHANNEL 0
124 1.2 pk #define AD1848_AUX1_CHANNEL 1
125 1.2 pk #define AD1848_DAC_CHANNEL 2
126 1.2 pk #define AD1848_LINE_CHANNEL 3
127 1.2 pk #define AD1848_MONO_CHANNEL 4
128 1.2 pk #define AD1848_MONITOR_CHANNEL 5 /* Doesn't seem to be on all later chips */
129 1.1 pk
130 1.1 pk /*
131 1.2 pk * Ad1848 registers.
132 1.1 pk */
133 1.1 pk #define MIC_IN_PORT 0
134 1.1 pk #define LINE_IN_PORT 1
135 1.1 pk #define AUX1_IN_PORT 2
136 1.1 pk #define DAC_IN_PORT 3
137 1.1 pk
138 1.1 pk #ifdef _KERNEL
139 1.1 pk
140 1.1 pk #define AD1848_KIND_LVL 0
141 1.1 pk #define AD1848_KIND_MUTE 1
142 1.1 pk #define AD1848_KIND_RECORDGAIN 2
143 1.1 pk #define AD1848_KIND_MICGAIN 3
144 1.1 pk #define AD1848_KIND_RECORDSOURCE 4
145 1.1 pk
146 1.1 pk typedef struct ad1848_devmap {
147 1.1 pk int id;
148 1.1 pk int kind;
149 1.1 pk int dev;
150 1.1 pk } ad1848_devmap_t;
151 1.1 pk
152 1.1 pk int ad_read __P((struct ad1848_softc *, int));
153 1.5 rh int ad_xread __P((struct ad1848_softc *, int));
154 1.1 pk void ad_write __P((struct ad1848_softc *, int, int));
155 1.5 rh void ad_xwrite __P((struct ad1848_softc *, int, int));
156 1.1 pk
157 1.1 pk void ad1848_attach __P((struct ad1848_softc *));
158 1.2 pk void ad1848_reset __P((struct ad1848_softc *));
159 1.1 pk int ad1848_open __P((void *, int));
160 1.1 pk void ad1848_close __P((void *));
161 1.2 pk
162 1.2 pk int ad1848_mixer_get_port __P((struct ad1848_softc *, ad1848_devmap_t *,
163 1.2 pk int, mixer_ctrl_t *));
164 1.2 pk int ad1848_mixer_set_port __P((struct ad1848_softc *, ad1848_devmap_t *,
165 1.2 pk int, mixer_ctrl_t *));
166 1.2 pk int ad1848_set_speed __P((struct ad1848_softc *, u_long *));
167 1.2 pk void ad1848_mute_monitor __P((void *, int));
168 1.1 pk int ad1848_query_encoding __P((void *, struct audio_encoding *));
169 1.2 pk int ad1848_set_params __P((void *, int, int, struct audio_params *,
170 1.2 pk struct audio_params *));
171 1.1 pk int ad1848_round_blocksize __P((void *, int));
172 1.1 pk int ad1848_commit_settings __P((void *));
173 1.1 pk int ad1848_set_rec_port __P((struct ad1848_softc *, int));
174 1.1 pk int ad1848_get_rec_port __P((struct ad1848_softc *));
175 1.2 pk int ad1848_set_channel_gain __P((struct ad1848_softc *, int,
176 1.2 pk struct ad1848_volume *));
177 1.2 pk int ad1848_get_device_gain __P((struct ad1848_softc *, int,
178 1.2 pk struct ad1848_volume *));
179 1.2 pk int ad1848_set_rec_gain __P((struct ad1848_softc *,
180 1.2 pk struct ad1848_volume *));
181 1.2 pk int ad1848_get_rec_gain __P((struct ad1848_softc *,
182 1.2 pk struct ad1848_volume *));
183 1.1 pk /* Note: The mic pre-MUX gain is not a variable gain, it's 20dB or 0dB */
184 1.2 pk int ad1848_set_mic_gain __P((struct ad1848_softc *,
185 1.2 pk struct ad1848_volume *));
186 1.2 pk int ad1848_get_mic_gain __P((struct ad1848_softc *,
187 1.2 pk struct ad1848_volume *));
188 1.2 pk void ad1848_mute_channel __P((struct ad1848_softc *, int device, int mute));
189 1.1 pk int ad1848_to_vol __P((mixer_ctrl_t *, struct ad1848_volume *));
190 1.1 pk int ad1848_from_vol __P((mixer_ctrl_t *, struct ad1848_volume *));
191 1.1 pk
192 1.4 mycroft int ad1848_halt_output __P((void *));
193 1.4 mycroft int ad1848_halt_input __P((void *));
194 1.1 pk int ad1848_mappage __P((void *, void *, int, int));
195 1.1 pk
196 1.1 pk #ifdef AUDIO_DEBUG
197 1.2 pk void ad1848_dump_regs __P((struct ad1848_softc *));
198 1.1 pk #endif
199 1.1 pk
200 1.1 pk #endif
201