Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Mar 2001 14:23:03 +0300 (MSK)
From:      Alex Kapranoff <alex@kapran.bitmcnit.bryansk.su>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/25799: pcm doesn't always autocreate device aliases w/ DEVFS
Message-ID:  <200103141123.f2EBN3n00805@kapran.bitmcnit.bryansk.su>

next in thread | raw e-mail | index | archive | help

>Number:         25799
>Category:       kern
>Synopsis:       pcm doesn't always autocreate device aliases w/ DEVFS
>Confidential:   no
>Severity:       non-critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 14 03:50:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Alex Kapranoff
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
Internal Mongolia
>Environment:

System: FreeBSD kapran.bitmcnit.bryansk.su 5.0-CURRENT FreeBSD 5.0-CURRENT #2: Wed Mar 14 11:06:41 MSK 2001 root@kapran.bitmcnit.bryansk.su:/usr/src/sys/compile/KAPRAN i386

I have an old ISA non-PNP Sound Blaster 16 Vibra. It probes as
follows:

sbc0: <SoundBlaster 16> at port 0x220-0x22f irq 5 drq 1 flags 0x15 on isa0
pcm1: <SB16 DSP 4.13> on sbc0

using the following /boot/device.hints:

hint.pcm.0.at="isa"
hint.pcm.0.irq="5"
hint.pcm.0.drq="1"
hint.pcm.0.flags="0x15"
hint.sbc.0.at="isa"
hint.sbc.0.port="0x220"
hint.sbc.0.irq="5"
hint.sbc.0.drq="1"
hint.sbc.0.flags="0x15"

I use DEVFS.

>Description:

I have the following sound-related devices in /dev after boot:

crw-rw-rw-  1 root  wheel      30,  20 14 อมา 13:39 /dev/audio1.0
crw-rw-rw-  1 root  wheel      30, 0x00010014 14 อมา 13:39 /dev/audio1.1
crw-rw-rw-  1 root  wheel      30,  19 14 อมา 13:39 /dev/dsp1.0
crw-rw-rw-  1 root  wheel      30, 0x00010013 14 อมา 13:39 /dev/dsp1.1
crw-rw-rw-  1 root  wheel      30,  21 14 อมา 13:39 /dev/dspW1.0
crw-rw-rw-  1 root  wheel      30, 0x00010015 14 อมา 13:39 /dev/dspW1.1
crw-rw-rw-  1 root  wheel      30,  16 14 อมา 13:39 /dev/mixer1
cr--r--r--  1 root  wheel      30,   6 14 อมา 13:39 /dev/sndstat

And sysctl hw.snd.unit is (default value):
hw.snd.unit: 0

pcm driver does not create /dev/{audio,dsp,dspW,mixer} aliases because
it tries to use unit 0 (according to hw.snd.unit), whereas my box only
have unit 1. See /sys/dev/sound/pcm/sound.c:pcm_makelinks()

>How-To-Repeat:
	
>Fix:

First, you can set hw.snd.unit to 1 or whatever in your kernel
hints file or in /boot/device.hints.

Next, you can set hw.snd.unit to 1 by appending
'hw.snd.unit=1' to your /etc/rc.sysctl file.

And last. With proposed patch, hw.snd.unit defaults to '-1'
which now means 'autoselect the first existing unit for
making aliases in /dev'. This variant is prefered :)

This PR supercedes my old and rather lame kern/21308 so whoever cares
please close kern/21308 as soon as this one.

--- /sys/dev/sound/pcm/sound.c.orig	Wed Mar 14 10:57:40 2001
+++ sound.c	Wed Mar 14 13:46:23 2001
@@ -90,7 +90,7 @@
 
 #ifdef USING_DEVFS
 int snd_unit;
-TUNABLE_INT_DECL("hw.snd.unit", 0, snd_unit);
+TUNABLE_INT_DECL("hw.snd.unit", -1, snd_unit);
 #endif
 
 SYSCTL_NODE(_hw, OID_AUTO, snd, CTLFLAG_RD, 0, "Sound driver");
@@ -193,8 +193,16 @@
 	}
 
 	unit = snd_unit;
-	if (unit < 0 || unit > devclass_get_maxunit(pcm_devclass))
-		return;
+	if (unit == -1) {
+		/* find the first unit */
+		for(unit = 0;
+		    unit <= devclass_get_maxunit(pcm_devclass); ++unit)
+			if (devclass_get_softc(pcm_devclass, unit) != NULL)
+				break;
+	} else {
+		if (unit < 0 || unit > devclass_get_maxunit(pcm_devclass))
+			return;
+	}
 	if (devclass_get_softc(pcm_devclass, unit) == NULL)
 		return;
 
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200103141123.f2EBN3n00805>