9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Arne Meyer <meyer.arne83@netcologne.de>
To: "9front@9front.org" <9front@9front.org>
Subject: [9front] [patch] nusb/audio /dev entries fix v2
Date: Fri, 29 Dec 2023 17:00:48 +0100 (CET)	[thread overview]
Message-ID: <1787115101.3760397.1703865648791@comcenter.netcologne.de> (raw)

[-- 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' &
}

             reply	other threads:[~2023-12-29 16:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-29 16:00 Arne Meyer [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1787115101.3760397.1703865648791@comcenter.netcologne.de \
    --to=meyer.arne83@netcologne.de \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).