9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [patch] nusb/audio /dev entries fix v2
@ 2023-12-29 16:00 Arne Meyer
  2023-12-29 17:10 ` cinap_lenrek
  0 siblings, 1 reply; 10+ messages in thread
From: Arne Meyer @ 2023-12-29 16:00 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 847 bytes --]

Hello,

the nusb/audio driver changes the namespace at 2 positions. It adds entries 
for audio and audioin in #u and an entry for volume in #σ/usb. So depending on
where #A, #u and #σ are bound in the namespace parts of nusb/audio will shadow or be shadowed
by #A.

Consensus on the mailing was to not mess with the bind order and let the user decide
what to do with nusb/audio. To make this easier and avoid any ambiguities I propose
to add a suffix U<N> to all of nusb/audio's device entries.

This is how the device entries look for me with the attached patch:

/dev/audioU83862
/dev/volumeU83862

I can now bind them on /dev/audio and /dev/volume in termrc or use the attached script to automatically 
bind any usb audio devices when they are plugged in. We also get as many usb audio devices as we want.

Greetings,
Arne

[-- Attachment #2: nusbaudio.patch --]
[-- Type: application/octet-stream, Size: 1250 bytes --]

diff 34e7b54c139826b55713702910a1280e6651df60 uncommitted
--- a/sys/man/4/nusb
+++ b/sys/man/4/nusb
@@ -274,6 +274,7 @@
 .BR /dev ),
 compatible with
 .IR audio (3).
+The files have a suffix UN, with N being the USB device identifier.
 .SS Camera devices
 .I Cam
 configures and exposes a USB camera device's capabilities,
--- a/sys/src/cmd/nusb/audio/audio.c
+++ b/sys/src/cmd/nusb/audio/audio.c
@@ -365,6 +365,7 @@
 	int dir = e->dir;
 	Aconf *c;
 	Range *f;
+	char buf[32];
 
 	for(;e != nil; e = e->next){
 		c = e->iface->aux;
@@ -395,9 +396,12 @@
 	devctl(d, "sampledelay %d", audiodelay);
 	devctl(d, "hz %d", speed);
 	if(e->dir==Ein)
-		devctl(d, "name audioin");
+		snprint(buf, sizeof buf, "name audioinU%s", audiodev->hname); 
 	else
-		devctl(d, "name audio");
+		snprint(buf, sizeof buf, "name audioU%s", audiodev->hname);
+	
+	devctl(d, buf);
+
 	return d;
 }
 
@@ -549,7 +553,8 @@
 		sysfatal("no output stream found");
 
 	fs.tree = alloctree(user, "usb", DMDIR|0555, nil);
-	createfile(fs.tree->root, "volume", user, 0666, nil);
+	snprint(buf, sizeof buf, "volumeU%s", audiodev->hname);
+	createfile(fs.tree->root, buf, user, 0666, nil);
 
 	snprint(buf, sizeof buf, "%d.audio", audiodev->id);
 	postsharesrv(&fs, nil, "usb", buf);

[-- Attachment #3: audiobind.rc --]
[-- Type: application/octet-stream, Size: 363 bytes --]

#!/bin/rc

if(! test -e /dev/audio)
	aux/stub /dev/audio
if(! test -e /dev/volume)
	aux/stub /dev/volume

@{
	rfork e
	fn attach {
		switch($4){
		case *01
			sleep 2
			bind /dev/audioU$5 /dev/audio
			bind /dev/volumeU$5 /dev/volume
		}
	}

	fn detach {
		switch($4){
		case *01
			unmount /dev/audio
			unmount /dev/volume
		}
	}

	rc < '#σ/usb/usbevent' &
}

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-01-06 20:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-29 16:00 [9front] [patch] nusb/audio /dev entries fix v2 Arne Meyer
2023-12-29 17:10 ` cinap_lenrek
2023-12-29 17:34   ` Arne Meyer
2023-12-29 21:54     ` cinap_lenrek
2023-12-30  1:53       ` hiro
2023-12-30 13:25       ` Arne Meyer
2024-01-06 16:04         ` Arne Meyer
2024-01-06 19:43           ` cinap_lenrek
2024-01-06 20:41             ` Arne Meyer
2024-01-06 19:58           ` cinap_lenrek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).