#include "../port/error.h"
#include "../port/audioif.h"
-enum { Maxbusywait = 500000 };
-
enum {
Reset = 0x0,
Capmic = 0x1,
};
static Volume voltab[] = {
- [Vmaster] "master", 0x02, 63, Stereo, 0,
- [Vaudio] "audio", 0x18, 31, Stereo, 0,
- [Vhead] "head", 0x04, 31, Stereo, Capheadphones,
+ [Vmaster] "master", 0x02, -63, Stereo, 0,
+ [Vaudio] "audio", 0x18, -31, Stereo, 0,
+ [Vhead] "head", 0x04, -31, Stereo, Capheadphones,
[Vbass] "bass", 0x08, 15, Left, Captonectl,
[Vtreb] "treb", 0x08, 15, Right, Captonectl,
- [Vbeep] "beep", 0x0a, 31, Right, 0,
- [Vphone] "phone", 0x0c, 31, Right, 0,
- [Vmic] "mic", 0x0e, 31, Right, Capmic,
- [Vline] "line", 0x10, 31, Stereo, 0,
- [Vcd] "cd", 0x12, 31, Stereo, 0,
- [Vvideo] "video", 0x14, 31, Stereo, 0,
- [Vaux] "aux", 0x16, 63, Stereo, 0,
+ [Vbeep] "beep", 0x0a, -31, Right, 0,
+ [Vphone] "phone", 0x0c, -31, Right, 0,
+ [Vmic] "mic", 0x0e, -31, Right, Capmic,
+ [Vline] "line", 0x10, -31, Stereo, 0,
+ [Vcd] "cd", 0x12, -31, Stereo, 0,
+ [Vvideo] "video", 0x14, -31, Stereo, 0,
+ [Vaux] "aux", 0x16, -63, Stereo, 0,
[Vrecgain] "recgain", 0x1c, 15, Stereo, 0,
[Vmicgain] "micgain", 0x1e, 15, Right, Capmic,
[Vspeed] "speed", 0x2c, 0, Absolute, 0,
default:
v = m->rr(adev, vol->reg);
if(v & 0x8000){
- a[0] = 0;
- a[1] = 0;
+ a[0] = a[1] = vol->range < 0 ? 0x7f : 0;
} else {
- a[0] = vol->range - ((v>>8) & 0x7f);
- a[1] = vol->range - (v & 0x7f);
+ a[0] = ((v>>8) & 0x7f);
+ a[1] = (v & 0x7f);
}
}
return 0;
return 0;
}
m->wr(adev, vol->reg, a[0]);
- if(x == Vspeed)
+ if(x == Vspeed){
+ m->wr(adev, 0x32, a[0]); /* adc rate */
adev->speed = m->rr(adev, vol->reg);
+ }
break;
case Left:
- v = (vol->range - a[0]) & 0x7f;
+ v = a[0] & 0x7f;
w = m->rr(adev, vol->reg) & 0x7f;
m->wr(adev, vol->reg, (v<<8)|w);
break;
case Right:
v = m->rr(adev, vol->reg) & 0x7f00;
- w = (vol->range - a[1]) & 0x7f;
+ w = a[1] & 0x7f;
m->wr(adev, vol->reg, v|w);
break;
case Stereo:
- v = (vol->range - a[0]) & 0x7f;
- w = (vol->range - a[1]) & 0x7f;
+ v = a[0] & 0x7f;
+ w = a[1] & 0x7f;
m->wr(adev, vol->reg, (v<<8)|w);
break;
}
{
Mixer *m;
ushort t;
- int i;
m = malloc(sizeof(Mixer));
if(m == nil){
m->rr = rr;
m->wr(adev, Reset, 0);
m->wr(adev, Powerdowncsr, 0);
-
+ delay(1000);
t = (Adcpower | Dacpower | Anlpower | Refpower);
- for(i = 0; i < Maxbusywait; i++){
- if((m->rr(adev, Powerdowncsr) & t) == t)
- break;
- microdelay(1);
- }
- if(i == Maxbusywait)
+ if((m->rr(adev, Powerdowncsr) & t) != t)
print("#A%d: ac97 exhausted waiting powerup\n", adev->ctlrno);
t = m->rr(adev, Extid);