Deleted Added
full compact
ac97.c (102302) ac97.c (107285)
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

--- 15 unchanged lines hidden (view full) ---

24 * SUCH DAMAGE.
25 */
26
27#include <dev/sound/pcm/sound.h>
28#include <dev/sound/pcm/ac97.h>
29
30#include "mixer_if.h"
31
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

--- 15 unchanged lines hidden (view full) ---

24 * SUCH DAMAGE.
25 */
26
27#include <dev/sound/pcm/sound.h>
28#include <dev/sound/pcm/ac97.h>
29
30#include "mixer_if.h"
31
32SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pcm/ac97.c 102302 2002-08-23 06:19:28Z orion $");
32SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pcm/ac97.c 107285 2002-11-26 18:16:27Z cg $");
33
34MALLOC_DEFINE(M_AC97, "ac97", "ac97 codec");
35
36struct ac97mixtable_entry {
37 int reg:8;
38 unsigned bits:4;
39 unsigned ofs:4;
40 unsigned stereo:1;

--- 9 unchanged lines hidden (view full) ---

50 device_t dev;
51 void *devinfo;
52 char *id;
53 char rev;
54 unsigned count, caps, se, extcaps, extid, extstat, noext:1;
55 u_int32_t flags;
56 struct ac97mixtable_entry mix[32];
57 char name[AC97_NAMELEN];
33
34MALLOC_DEFINE(M_AC97, "ac97", "ac97 codec");
35
36struct ac97mixtable_entry {
37 int reg:8;
38 unsigned bits:4;
39 unsigned ofs:4;
40 unsigned stereo:1;

--- 9 unchanged lines hidden (view full) ---

50 device_t dev;
51 void *devinfo;
52 char *id;
53 char rev;
54 unsigned count, caps, se, extcaps, extid, extstat, noext:1;
55 u_int32_t flags;
56 struct ac97mixtable_entry mix[32];
57 char name[AC97_NAMELEN];
58 void *lock;
58 struct mtx *lock;
59};
60
61struct ac97_codecid {
62 u_int32_t id, noext:1;
63 char *name;
64};
65
66static const struct ac97mixtable_entry ac97mixtable_default[32] = {

--- 135 unchanged lines hidden (view full) ---

202
203static void
204ac97_reset(struct ac97_info *codec)
205{
206 u_int32_t i, ps;
207 wrcd(codec, AC97_REG_RESET, 0);
208 for (i = 0; i < 500; i++) {
209 ps = rdcd(codec, AC97_REG_POWER) & AC97_POWER_STATUS;
59};
60
61struct ac97_codecid {
62 u_int32_t id, noext:1;
63 char *name;
64};
65
66static const struct ac97mixtable_entry ac97mixtable_default[32] = {

--- 135 unchanged lines hidden (view full) ---

202
203static void
204ac97_reset(struct ac97_info *codec)
205{
206 u_int32_t i, ps;
207 wrcd(codec, AC97_REG_RESET, 0);
208 for (i = 0; i < 500; i++) {
209 ps = rdcd(codec, AC97_REG_POWER) & AC97_POWER_STATUS;
210 if (ps == AC97_POWER_STATUS)
210 if (ps == AC97_POWER_STATUS)
211 return;
212 DELAY(1000);
213 }
214 device_printf(codec->dev, "AC97 reset timed out.");
215}
216
217int
218ac97_setrate(struct ac97_info *codec, int which, int rate)
219{
220 u_int16_t v;
221
222 switch(which) {
211 return;
212 DELAY(1000);
213 }
214 device_printf(codec->dev, "AC97 reset timed out.");
215}
216
217int
218ac97_setrate(struct ac97_info *codec, int which, int rate)
219{
220 u_int16_t v;
221
222 switch(which) {
223 case AC97_REGEXT_FDACRATE:
223 case AC97_REGEXT_FDACRATE:
224 case AC97_REGEXT_SDACRATE:
225 case AC97_REGEXT_LDACRATE:
224 case AC97_REGEXT_SDACRATE:
225 case AC97_REGEXT_LDACRATE:
226 case AC97_REGEXT_LADCRATE:
226 case AC97_REGEXT_LADCRATE:
227 case AC97_REGEXT_MADCRATE:
228 break;
229
230 default:
231 return -1;
232 }
233
234 snd_mtxlock(codec->lock);

--- 10 unchanged lines hidden (view full) ---

245 return v;
246}
247
248int
249ac97_setextmode(struct ac97_info *codec, u_int16_t mode)
250{
251 mode &= AC97_EXTCAPS;
252 if ((mode & ~codec->extcaps) != 0) {
227 case AC97_REGEXT_MADCRATE:
228 break;
229
230 default:
231 return -1;
232 }
233
234 snd_mtxlock(codec->lock);

--- 10 unchanged lines hidden (view full) ---

245 return v;
246}
247
248int
249ac97_setextmode(struct ac97_info *codec, u_int16_t mode)
250{
251 mode &= AC97_EXTCAPS;
252 if ((mode & ~codec->extcaps) != 0) {
253 device_printf(codec->dev, "ac97 invalid mode set 0x%04x\n",
253 device_printf(codec->dev, "ac97 invalid mode set 0x%04x\n",
254 mode);
255 return -1;
256 }
257 snd_mtxlock(codec->lock);
258 wrcd(codec, AC97_REGEXT_STAT, mode);
259 codec->extstat = rdcd(codec, AC97_REGEXT_STAT) & AC97_EXTCAPS;
260 snd_mtxunlock(codec->lock);
261 return (mode == codec->extstat)? 0 : -1;

--- 104 unchanged lines hidden (view full) ---

366 } else
367 return -1;
368}
369#endif
370
371static void
372ac97_fix_auxout(struct ac97_info *codec)
373{
254 mode);
255 return -1;
256 }
257 snd_mtxlock(codec->lock);
258 wrcd(codec, AC97_REGEXT_STAT, mode);
259 codec->extstat = rdcd(codec, AC97_REGEXT_STAT) & AC97_EXTCAPS;
260 snd_mtxunlock(codec->lock);
261 return (mode == codec->extstat)? 0 : -1;

--- 104 unchanged lines hidden (view full) ---

366 } else
367 return -1;
368}
369#endif
370
371static void
372ac97_fix_auxout(struct ac97_info *codec)
373{
374 /* Determine what AUXOUT really means, it can be:
374 /* Determine what AUXOUT really means, it can be:
375 *
376 * 1. Headphone out.
377 * 2. 4-Channel Out
378 * 3. True line level out (effectively master volume).
379 *
380 * See Sections 5.2.1 and 5.27 for AUX_OUT Options in AC97r2.{2,3}.
381 */
382 if (codec->caps & AC97_CAP_HEADPHONE) {
375 *
376 * 1. Headphone out.
377 * 2. 4-Channel Out
378 * 3. True line level out (effectively master volume).
379 *
380 * See Sections 5.2.1 and 5.27 for AUX_OUT Options in AC97r2.{2,3}.
381 */
382 if (codec->caps & AC97_CAP_HEADPHONE) {
383 /* XXX We should probably check the AUX_OUT initial value.
383 /* XXX We should probably check the AUX_OUT initial value.
384 * Leave AC97_MIX_AUXOUT - SOUND_MIXER_MONITOR relationship */
385 return;
386 } else if (codec->extcaps & AC97_EXTCAP_SDAC &&
387 rdcd(codec, AC97_MIXEXT_SURROUND) == 0x8080) {
388 /* 4-Channel Out, add an additional gain setting. */
389 codec->mix[SOUND_MIXER_OGAIN] = codec->mix[SOUND_MIXER_MONITOR];
390 } else {
384 * Leave AC97_MIX_AUXOUT - SOUND_MIXER_MONITOR relationship */
385 return;
386 } else if (codec->extcaps & AC97_EXTCAP_SDAC &&
387 rdcd(codec, AC97_MIXEXT_SURROUND) == 0x8080) {
388 /* 4-Channel Out, add an additional gain setting. */
389 codec->mix[SOUND_MIXER_OGAIN] = codec->mix[SOUND_MIXER_MONITOR];
390 } else {
391 /* Master volume is/maybe fixed in h/w, not sufficiently
391 /* Master volume is/maybe fixed in h/w, not sufficiently
392 * clear in spec to blat SOUND_MIXER_MASTER. */
393 codec->mix[SOUND_MIXER_OGAIN] = codec->mix[SOUND_MIXER_MONITOR];
394 }
395 /* Blat monitor, inappropriate label if we get here */
392 * clear in spec to blat SOUND_MIXER_MASTER. */
393 codec->mix[SOUND_MIXER_OGAIN] = codec->mix[SOUND_MIXER_MONITOR];
394 }
395 /* Blat monitor, inappropriate label if we get here */
396 bzero(&codec->mix[SOUND_MIXER_MONITOR],
396 bzero(&codec->mix[SOUND_MIXER_MONITOR],
397 sizeof(codec->mix[SOUND_MIXER_MONITOR]));
398}
399
400static unsigned
401ac97_initmixer(struct ac97_info *codec)
402{
403 unsigned i, j, k, old;
404 u_int32_t id;

--- 267 unchanged lines hidden ---
397 sizeof(codec->mix[SOUND_MIXER_MONITOR]));
398}
399
400static unsigned
401ac97_initmixer(struct ac97_info *codec)
402{
403 unsigned i, j, k, old;
404 u_int32_t id;

--- 267 unchanged lines hidden ---