| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ad1848.c,v 1.29 2008/04/28 20:23:48 martin Exp $ */ | | 1 | /* $NetBSD: ad1848.c,v 1.30 2011/04/27 07:47:33 plunky Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1999 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1999 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Ken Hornstein and John Kohl. | | 8 | * by Ken Hornstein and John Kohl. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -85,27 +85,27 @@ | | | @@ -85,27 +85,27 @@ |
85 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 85 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
86 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 86 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
87 | * SUCH DAMAGE. | | 87 | * SUCH DAMAGE. |
88 | * | | 88 | * |
89 | */ | | 89 | */ |
90 | /* | | 90 | /* |
91 | * Portions of this code are from the VOXware support for the ad1848 | | 91 | * Portions of this code are from the VOXware support for the ad1848 |
92 | * by Hannu Savolainen <hannu@voxware.pp.fi> | | 92 | * by Hannu Savolainen <hannu@voxware.pp.fi> |
93 | * | | 93 | * |
94 | * Portions also supplied from the SoundBlaster driver for NetBSD. | | 94 | * Portions also supplied from the SoundBlaster driver for NetBSD. |
95 | */ | | 95 | */ |
96 | | | 96 | |
97 | #include <sys/cdefs.h> | | 97 | #include <sys/cdefs.h> |
98 | __KERNEL_RCSID(0, "$NetBSD: ad1848.c,v 1.29 2008/04/28 20:23:48 martin Exp $"); | | 98 | __KERNEL_RCSID(0, "$NetBSD: ad1848.c,v 1.30 2011/04/27 07:47:33 plunky Exp $"); |
99 | | | 99 | |
100 | #include <sys/param.h> | | 100 | #include <sys/param.h> |
101 | #include <sys/systm.h> | | 101 | #include <sys/systm.h> |
102 | #include <sys/errno.h> | | 102 | #include <sys/errno.h> |
103 | #include <sys/ioctl.h> | | 103 | #include <sys/ioctl.h> |
104 | #include <sys/device.h> | | 104 | #include <sys/device.h> |
105 | #include <sys/fcntl.h> | | 105 | #include <sys/fcntl.h> |
106 | /*#include <sys/syslog.h>*/ | | 106 | /*#include <sys/syslog.h>*/ |
107 | /*#include <sys/proc.h>*/ | | 107 | /*#include <sys/proc.h>*/ |
108 | | | 108 | |
109 | #include <sys/cpu.h> | | 109 | #include <sys/cpu.h> |
110 | #include <sys/bus.h> | | 110 | #include <sys/bus.h> |
111 | | | 111 | |
| @@ -206,64 +206,64 @@ ad1848_from_vol(mixer_ctrl_t *cp, struct | | | @@ -206,64 +206,64 @@ ad1848_from_vol(mixer_ctrl_t *cp, struct |
206 | if (cp->un.value.num_channels == 1) { | | 206 | if (cp->un.value.num_channels == 1) { |
207 | cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = vol->left; | | 207 | cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = vol->left; |
208 | return 1; | | 208 | return 1; |
209 | } | | 209 | } |
210 | else if (cp->un.value.num_channels == 2) { | | 210 | else if (cp->un.value.num_channels == 2) { |
211 | cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = vol->left; | | 211 | cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = vol->left; |
212 | cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = vol->right; | | 212 | cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = vol->right; |
213 | return 1; | | 213 | return 1; |
214 | } | | 214 | } |
215 | return 0; | | 215 | return 0; |
216 | } | | 216 | } |
217 | | | 217 | |
218 | | | 218 | |
219 | inline int | | 219 | int |
220 | ad_read(struct ad1848_softc *sc, int reg) | | 220 | ad_read(struct ad1848_softc *sc, int reg) |
221 | { | | 221 | { |
222 | int x; | | 222 | int x; |
223 | | | 223 | |
224 | ADWRITE(sc, AD1848_IADDR, (reg & 0xff) | sc->MCE_bit); | | 224 | ADWRITE(sc, AD1848_IADDR, (reg & 0xff) | sc->MCE_bit); |
225 | x = ADREAD(sc, AD1848_IDATA); | | 225 | x = ADREAD(sc, AD1848_IDATA); |
226 | /* printf("(%02x<-%02x) ", reg|sc->MCE_bit, x); */ | | 226 | /* printf("(%02x<-%02x) ", reg|sc->MCE_bit, x); */ |
227 | return x; | | 227 | return x; |
228 | } | | 228 | } |
229 | | | 229 | |
230 | inline void | | 230 | void |
231 | ad_write(struct ad1848_softc *sc, int reg, int data) | | 231 | ad_write(struct ad1848_softc *sc, int reg, int data) |
232 | { | | 232 | { |
233 | | | 233 | |
234 | ADWRITE(sc, AD1848_IADDR, (reg & 0xff) | sc->MCE_bit); | | 234 | ADWRITE(sc, AD1848_IADDR, (reg & 0xff) | sc->MCE_bit); |
235 | ADWRITE(sc, AD1848_IDATA, data & 0xff); | | 235 | ADWRITE(sc, AD1848_IDATA, data & 0xff); |
236 | /* printf("(%02x->%02x) ", reg|sc->MCE_bit, data); */ | | 236 | /* printf("(%02x->%02x) ", reg|sc->MCE_bit, data); */ |
237 | } | | 237 | } |
238 | | | 238 | |
239 | /* | | 239 | /* |
240 | * extended registers (mode 3) require an additional level of | | 240 | * extended registers (mode 3) require an additional level of |
241 | * indirection through CS_XREG (I23). | | 241 | * indirection through CS_XREG (I23). |
242 | */ | | 242 | */ |
243 | | | 243 | |
244 | inline int | | 244 | int |
245 | ad_xread(struct ad1848_softc *sc, int reg) | | 245 | ad_xread(struct ad1848_softc *sc, int reg) |
246 | { | | 246 | { |
247 | int x; | | 247 | int x; |
248 | | | 248 | |
249 | ADWRITE(sc, AD1848_IADDR, CS_XREG | sc->MCE_bit); | | 249 | ADWRITE(sc, AD1848_IADDR, CS_XREG | sc->MCE_bit); |
250 | ADWRITE(sc, AD1848_IDATA, (reg | ALT_F3_XRAE) & 0xff); | | 250 | ADWRITE(sc, AD1848_IDATA, (reg | ALT_F3_XRAE) & 0xff); |
251 | x = ADREAD(sc, AD1848_IDATA); | | 251 | x = ADREAD(sc, AD1848_IDATA); |
252 | | | 252 | |
253 | return x; | | 253 | return x; |
254 | } | | 254 | } |
255 | | | 255 | |
256 | inline void | | 256 | void |
257 | ad_xwrite(struct ad1848_softc *sc, int reg, int val) | | 257 | ad_xwrite(struct ad1848_softc *sc, int reg, int val) |
258 | { | | 258 | { |
259 | | | 259 | |
260 | ADWRITE(sc, AD1848_IADDR, CS_XREG | sc->MCE_bit); | | 260 | ADWRITE(sc, AD1848_IADDR, CS_XREG | sc->MCE_bit); |
261 | ADWRITE(sc, AD1848_IDATA, (reg | ALT_F3_XRAE) & 0xff); | | 261 | ADWRITE(sc, AD1848_IDATA, (reg | ALT_F3_XRAE) & 0xff); |
262 | ADWRITE(sc, AD1848_IDATA, val & 0xff); | | 262 | ADWRITE(sc, AD1848_IDATA, val & 0xff); |
263 | } | | 263 | } |
264 | | | 264 | |
265 | static void | | 265 | static void |
266 | ad_set_MCE(struct ad1848_softc *sc, int state) | | 266 | ad_set_MCE(struct ad1848_softc *sc, int state) |
267 | { | | 267 | { |
268 | | | 268 | |
269 | if (state) | | 269 | if (state) |