nusb/audio: setup audioin
This commit is contained in:
parent
656762ae98
commit
5377a19447
1 changed files with 40 additions and 15 deletions
|
@ -22,7 +22,9 @@ int audiores = 16;
|
||||||
char user[] = "audio";
|
char user[] = "audio";
|
||||||
|
|
||||||
Dev *audiodev = nil;
|
Dev *audiodev = nil;
|
||||||
Ep *audioep = nil;
|
|
||||||
|
Ep *audioepin = nil;
|
||||||
|
Ep *audioepout = nil;
|
||||||
|
|
||||||
void
|
void
|
||||||
parsedescr(Desc *dd)
|
parsedescr(Desc *dd)
|
||||||
|
@ -96,7 +98,10 @@ Foundaltc:
|
||||||
devctl(d, "samplesz %d", audiochan*audiores/8);
|
devctl(d, "samplesz %d", audiochan*audiores/8);
|
||||||
devctl(d, "sampledelay %d", audiodelay);
|
devctl(d, "sampledelay %d", audiodelay);
|
||||||
devctl(d, "hz %d", speed);
|
devctl(d, "hz %d", speed);
|
||||||
devctl(d, "name audio");
|
if(e->dir == Ein)
|
||||||
|
devctl(d, "name audioin");
|
||||||
|
else
|
||||||
|
devctl(d, "name audio");
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,12 +133,15 @@ fswrite(Req *r)
|
||||||
|
|
||||||
speed = atoi(f[1]);
|
speed = atoi(f[1]);
|
||||||
Setup:
|
Setup:
|
||||||
if((d = setupep(audiodev, audioep, speed)) == nil){
|
if((d = setupep(audiodev, audioepout, speed)) == nil){
|
||||||
responderror(r);
|
responderror(r);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
closedev(d);
|
closedev(d);
|
||||||
|
if(audioepin != nil && audioepin != audioepout){
|
||||||
|
if(d = setupep(audiodev, audioepin, speed))
|
||||||
|
closedev(d);
|
||||||
|
}
|
||||||
audiofreq = speed;
|
audiofreq = speed;
|
||||||
} else if(strcmp(f[0], "delay") == 0){
|
} else if(strcmp(f[0], "delay") == 0){
|
||||||
audiodelay = atoi(f[1]);
|
audiodelay = atoi(f[1]);
|
||||||
|
@ -160,7 +168,7 @@ void
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char buf[32];
|
char buf[32];
|
||||||
Dev *d;
|
Dev *d, *ed;
|
||||||
Ep *e;
|
Ep *e;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -187,17 +195,34 @@ main(int argc, char *argv[])
|
||||||
parsedescr(d->usb->ddesc[i]);
|
parsedescr(d->usb->ddesc[i]);
|
||||||
for(i = 0; i < nelem(d->usb->ep); i++){
|
for(i = 0; i < nelem(d->usb->ep); i++){
|
||||||
e = d->usb->ep[i];
|
e = d->usb->ep[i];
|
||||||
if(e && e->iface && e->iface->csp == CSP(Claudio, 2, 0) && e->dir == Eout)
|
if(e && e->iface && e->iface->csp == CSP(Claudio, 2, 0)){
|
||||||
goto Foundendp;
|
switch(e->dir){
|
||||||
|
case Ein:
|
||||||
|
if(audioepin != nil)
|
||||||
|
continue;
|
||||||
|
audioepin = e;
|
||||||
|
break;
|
||||||
|
case Eout:
|
||||||
|
if(audioepout != nil)
|
||||||
|
continue;
|
||||||
|
audioepout = e;
|
||||||
|
break;
|
||||||
|
case Eboth:
|
||||||
|
if(audioepin != nil && audioepout != nil)
|
||||||
|
continue;
|
||||||
|
if(audioepin == nil)
|
||||||
|
audioepin = e;
|
||||||
|
if(audioepout == nil)
|
||||||
|
audioepout = e;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if((ed = setupep(audiodev, e, audiofreq)) == nil)
|
||||||
|
sysfatal("setupep: %r");
|
||||||
|
closedev(ed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sysfatal("no endpoints found");
|
if(audioepout == nil)
|
||||||
return;
|
sysfatal("no endpoints found");
|
||||||
|
|
||||||
Foundendp:
|
|
||||||
audioep = e;
|
|
||||||
if((d = setupep(audiodev, audioep, audiofreq)) == nil)
|
|
||||||
sysfatal("setupep: %r");
|
|
||||||
closedev(d);
|
|
||||||
|
|
||||||
fs.tree = alloctree(user, "usb", DMDIR|0555, nil);
|
fs.tree = alloctree(user, "usb", DMDIR|0555, nil);
|
||||||
createfile(fs.tree->root, "volume", user, 0666, nil);
|
createfile(fs.tree->root, "volume", user, 0666, nil);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue