audio/hda: added archfile command interface
This commit is contained in:
parent
0918ce10dc
commit
7b6675ff1a
1 changed files with 46 additions and 1 deletions
|
@ -277,9 +277,9 @@ struct Ctlr {
|
||||||
uchar *mem;
|
uchar *mem;
|
||||||
ulong size;
|
ulong size;
|
||||||
|
|
||||||
|
Queue *q;
|
||||||
ulong *corb;
|
ulong *corb;
|
||||||
ulong corbsize;
|
ulong corbsize;
|
||||||
|
|
||||||
ulong *rirb;
|
ulong *rirb;
|
||||||
ulong rirbsize;
|
ulong rirbsize;
|
||||||
|
|
||||||
|
@ -370,6 +370,8 @@ static char *pinloc2[] = {
|
||||||
"other",
|
"other",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Ctlr *lastcard;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
waitup8(Ctlr *ctlr, int reg, uchar mask, uchar set)
|
waitup8(Ctlr *ctlr, int reg, uchar mask, uchar set)
|
||||||
{
|
{
|
||||||
|
@ -1264,6 +1266,45 @@ hdamatch(Pcidev *p)
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static long
|
||||||
|
hdacmdread(Chan *, void *a, long n, vlong)
|
||||||
|
{
|
||||||
|
Ctlr *ctlr;
|
||||||
|
|
||||||
|
ctlr = lastcard;
|
||||||
|
if(ctlr == nil)
|
||||||
|
error(Enodev);
|
||||||
|
if(n & 7)
|
||||||
|
error(Ebadarg);
|
||||||
|
return qread(ctlr->q, a, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static long
|
||||||
|
hdacmdwrite(Chan *, void *a, long n, vlong)
|
||||||
|
{
|
||||||
|
Ctlr *ctlr;
|
||||||
|
ulong *lp;
|
||||||
|
int i;
|
||||||
|
uint w[2];
|
||||||
|
|
||||||
|
ctlr = lastcard;
|
||||||
|
if(ctlr == nil)
|
||||||
|
error(Enodev);
|
||||||
|
if(n & 3)
|
||||||
|
error(Ebadarg);
|
||||||
|
lp = a;
|
||||||
|
qlock(ctlr);
|
||||||
|
for(i=0; i<n/4; i++){
|
||||||
|
if(hdacmd(ctlr, lp[i], w) < 0){
|
||||||
|
w[0] = 0;
|
||||||
|
w[1] = ~0;
|
||||||
|
}
|
||||||
|
qproduce(ctlr->q, w, sizeof(w));
|
||||||
|
}
|
||||||
|
qunlock(ctlr);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
hdareset(Audio *adev)
|
hdareset(Audio *adev)
|
||||||
{
|
{
|
||||||
|
@ -1304,6 +1345,7 @@ Found:
|
||||||
|
|
||||||
ctlr->no = adev->ctlrno;
|
ctlr->no = adev->ctlrno;
|
||||||
ctlr->size = p->mem[0].size;
|
ctlr->size = p->mem[0].size;
|
||||||
|
ctlr->q = qopen(256, 0, 0, 0);
|
||||||
ctlr->mem = vmap(p->mem[0].bar & ~0x0F, ctlr->size);
|
ctlr->mem = vmap(p->mem[0].bar & ~0x0F, ctlr->size);
|
||||||
if(ctlr->mem == nil){
|
if(ctlr->mem == nil){
|
||||||
print("#A%d: can't map %.8lux\n", ctlr->no, p->mem[0].bar);
|
print("#A%d: can't map %.8lux\n", ctlr->no, p->mem[0].bar);
|
||||||
|
@ -1345,6 +1387,8 @@ Found:
|
||||||
adev->ctl = hdactl;
|
adev->ctl = hdactl;
|
||||||
|
|
||||||
intrenable(irq, hdainterrupt, adev, tbdf, "hda");
|
intrenable(irq, hdainterrupt, adev, tbdf, "hda");
|
||||||
|
lastcard = ctlr;
|
||||||
|
addarchfile("hdacmd", 0664, hdacmdread, hdacmdwrite);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1354,3 +1398,4 @@ audiohdalink(void)
|
||||||
{
|
{
|
||||||
addaudiocard("hda", hdareset);
|
addaudiocard("hda", hdareset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue