ac97.c (53512) | ac97.c (56249) |
---|---|
1/* 2 * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/* 2 * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/dev/sound/pcm/ac97.c 53512 1999-11-21 17:15:12Z cg $ | 26 * $FreeBSD: head/sys/dev/sound/pcm/ac97.c 56249 2000-01-18 17:13:43Z cg $ |
27 */ 28 29#include <dev/sound/pcm/sound.h> 30#include <dev/sound/pcm/ac97.h> 31 32#define AC97_MUTE 0x8000 33 34#define AC97_REG_RESET 0x00 --- 24 unchanged lines hidden (view full) --- 59 unsigned ofs:4; 60 unsigned stereo:1; 61 unsigned mute:1; 62 unsigned recidx:4; 63 unsigned mask:1; 64}; 65 66struct ac97_info { | 27 */ 28 29#include <dev/sound/pcm/sound.h> 30#include <dev/sound/pcm/ac97.h> 31 32#define AC97_MUTE 0x8000 33 34#define AC97_REG_RESET 0x00 --- 24 unchanged lines hidden (view full) --- 59 unsigned ofs:4; 60 unsigned stereo:1; 61 unsigned mute:1; 62 unsigned recidx:4; 63 unsigned mask:1; 64}; 65 66struct ac97_info { |
67 device_t dev; |
|
67 ac97_read *read; 68 ac97_write *write; 69 void *devinfo; 70 char id[4]; 71 char rev; 72 unsigned caps, se; 73 struct ac97mixtable_entry mix[32]; 74}; --- 182 unchanged lines hidden (view full) --- 257 codec->rev = id & 0x000000ff; 258 259 codec->write(codec->devinfo, AC97_MIX_MASTER, 0x20); 260 if ((codec->read(codec->devinfo, AC97_MIX_MASTER) & 0x20) == 0x20) 261 codec->mix[SOUND_MIXER_VOLUME].bits++; 262 codec->write(codec->devinfo, AC97_MIX_MASTER, 0x00); 263 264 if (bootverbose) { | 68 ac97_read *read; 69 ac97_write *write; 70 void *devinfo; 71 char id[4]; 72 char rev; 73 unsigned caps, se; 74 struct ac97mixtable_entry mix[32]; 75}; --- 182 unchanged lines hidden (view full) --- 258 codec->rev = id & 0x000000ff; 259 260 codec->write(codec->devinfo, AC97_MIX_MASTER, 0x20); 261 if ((codec->read(codec->devinfo, AC97_MIX_MASTER) & 0x20) == 0x20) 262 codec->mix[SOUND_MIXER_VOLUME].bits++; 263 codec->write(codec->devinfo, AC97_MIX_MASTER, 0x00); 264 265 if (bootverbose) { |
265 printf("ac97: codec id 0x%8x", id); | 266 device_printf(codec->dev, "ac97 codec id 0x%8x", id); |
266 for (i = 0; ac97codecid[i].id; i++) { 267 if (ac97codecid[i].id == id) printf(" (%s)", ac97codecid[i].name); 268 } | 267 for (i = 0; ac97codecid[i].id; i++) { 268 if (ac97codecid[i].id == id) printf(" (%s)", ac97codecid[i].name); 269 } |
269 printf("\nac97: codec features "); | 270 printf("\n"); 271 device_printf(codec->dev, "ac97 codec features "); |
270 for (i = j = 0; i < 10; i++) { 271 if (codec->caps & (1 << i)) { 272 printf("%s%s", j? ", " : "", ac97feature[i]); 273 j++; 274 } 275 } 276 printf("%s%d bit master volume", j? ", " : "", codec->mix[SOUND_MIXER_VOLUME].bits); 277 printf("%s%s\n", j? ", " : "", ac97enhancement[codec->se]); 278 } 279 280 if ((codec->read(codec->devinfo, AC97_REG_POWER) & 2) == 0) | 272 for (i = j = 0; i < 10; i++) { 273 if (codec->caps & (1 << i)) { 274 printf("%s%s", j? ", " : "", ac97feature[i]); 275 j++; 276 } 277 } 278 printf("%s%d bit master volume", j? ", " : "", codec->mix[SOUND_MIXER_VOLUME].bits); 279 printf("%s%s\n", j? ", " : "", ac97enhancement[codec->se]); 280 } 281 282 if ((codec->read(codec->devinfo, AC97_REG_POWER) & 2) == 0) |
281 printf("ac97: dac not ready\n"); | 283 device_printf(codec->dev, "ac97 codec reports dac not ready\n"); |
282 return 0; 283} 284 285struct ac97_info * | 284 return 0; 285} 286 287struct ac97_info * |
286ac97_create(void *devinfo, ac97_read *rd, ac97_write *wr) | 288ac97_create(device_t dev, void *devinfo, ac97_read *rd, ac97_write *wr) |
287{ 288 struct ac97_info *codec; 289 290 codec = (struct ac97_info *)malloc(sizeof *codec, M_DEVBUF, M_NOWAIT); 291 if (codec != NULL) { | 289{ 290 struct ac97_info *codec; 291 292 codec = (struct ac97_info *)malloc(sizeof *codec, M_DEVBUF, M_NOWAIT); 293 if (codec != NULL) { |
294 codec->dev = dev; |
|
292 codec->read = rd; 293 codec->write = wr; 294 codec->devinfo = devinfo; 295 } 296 return codec; 297} 298 299static int --- 36 unchanged lines hidden --- | 295 codec->read = rd; 296 codec->write = wr; 297 codec->devinfo = devinfo; 298 } 299 return codec; 300} 301 302static int --- 36 unchanged lines hidden --- |