Bug 89921 - OSS module doesn't detect some devices
Summary: OSS module doesn't detect some devices
Status: RESOLVED FIXED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: modules (show other bugs)
Version: unspecified
Hardware: All FreeBSD
: medium normal
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-06 17:53 UTC by Andrey Zholos
Modified: 2015-04-13 19:35 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Fix (299 bytes, patch)
2015-04-10 16:02 UTC, Andrey Zholos
Details | Splinter Review

Description Andrey Zholos 2015-04-06 17:53:17 UTC
Here is my OSS configuration on FreeBSD:

$ cat /dev/sndstat
Installed devices:
pcm0: <NVIDIA (0x0044) (HDMI/DP 8ch)> (play)
pcm1: <NVIDIA (0x0044) (HDMI/DP 8ch)> (play)
pcm2: <NVIDIA (0x0044) (HDMI/DP 8ch)> (play)
pcm3: <NVIDIA (0x0044) (HDMI/DP 8ch)> (play)
pcm4: <Realtek ALC892 (Rear Analog 7.1/2.0)> (play/rec) default
pcm5: <Realtek ALC892 (Front Analog)> (play/rec)
pcm6: <Realtek ALC892 (Rear Digital)> (play)
pcm7: <Realtek ALC892 (Onboard Digital)> (play)
pcm8: <USB audio> (rec)

PulseAudio doesn't detect any devices after the pcm4 line.

This is because that line is exactly one character too long for the
line[64] buffer in detect_oss(). The newline character from that line
is read in during the next iteration, which detect_oss() interprets as
an empty line that ends the "Installed devices" section.

Note that lines in /dev/sndstat can be significantly longer. On FreeBSD
setting sysctl hw.snd.verbose adds debugging information with lines up
to 109 characters on my system. I suggest increasing the buffer size to
at least 256.
Comment 1 Arun Raghavan 2015-04-10 13:01:27 UTC
Since you've got the cause pinned down, do you want to submit a patch after making sure that bumping that up to 256 gets things working for you?
Comment 2 Andrey Zholos 2015-04-10 16:02:23 UTC
Created attachment 115004 [details] [review]
Fix

Patch attached. It works for me with PulseAudio 5.0 which is the
current FreeBSD port version.

There's another interface available to query the same info: ioctl
SNDCTL_SYSINFO/SNDCTL_CARDINFO/SNDCTL_AUDIOINFO, but that would be a
much more complex patch.
Comment 3 Raymond 2015-04-11 02:14:20 UTC
pcm4: <Realtek ALC892 (Rear Analog 7.1/2.0)> (play/rec) default
pcm5: <Realtek ALC892 (Front Analog)> (play/rec)

do this mean NO headphone in default pcm4 and Front panel Headphone only used by pcm5 ?
Comment 4 Andrey Zholos 2015-04-11 09:56:20 UTC
Yes. This is the default configuration on my machine. pcm4 goes to
rear, pcm5 goes to front. This is governed by the pin configuration
below (man snd_hda). All the pins in as=1 (association) become pcm4,
as=2 becomes pcm5.

# sysctl dev.hdac.1.pindump=1
# dmesg
hdaa1: Dumping AFG pins:
hdaa1: nid   0x    as seq device       conn  jack    loc        color   misc
hdaa1: 17 99430140 4  0  SPDIF-out     Fixed ATAPI   Onboard    Unknown 1
hdaa1:     Caps:    OUT             
hdaa1: 18 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
hdaa1:     Caps: IN                 
hdaa1: 20 01014010 1  0  Line-out      Jack  1/8     Rear       Green   0
hdaa1:     Caps: IN OUT HP EAPD      Sense: 0x80000000 (connected)
hdaa1: 21 01011012 1  2  Line-out      Jack  1/8     Rear       Black   0
hdaa1:     Caps: IN OUT              Sense: 0x00000000 (disconnected)
hdaa1: 22 01016011 1  1  Line-out      Jack  1/8     Rear       Orange  0
hdaa1:     Caps: IN OUT              Sense: 0x00000000 (disconnected)
hdaa1: 23 01012014 1  4  Line-out      Jack  1/8     Rear       Grey    0
hdaa1:     Caps: IN OUT              Sense: 0x00000000 (disconnected)
hdaa1: 24 01a19850 5  0  Mic           Jack  1/8     Rear       Pink    8
hdaa1:     Caps: IN OUT         VREF Sense: 0x00000000 (disconnected)
hdaa1: 25 02a19c60 6  0  Mic           Jack  1/8     Front      Pink    12
hdaa1:     Caps: IN OUT HP      VREF Sense: 0x00000000 (disconnected)
hdaa1: 26 0181305f 5  15 Line-in       Jack  1/8     Rear       Blue    0
hdaa1:     Caps: IN OUT         VREF Sense: 0x00000000 (disconnected)
hdaa1: 27 02214c20 2  0  Headphones    Jack  1/8     Front      Green   12
hdaa1:     Caps: IN OUT HP EAPD VREF Sense: 0x00000000 (disconnected)
hdaa1: 28 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
hdaa1:     Caps: IN                  Sense: 0x00000000 (disconnected)
hdaa1: 30 014b6130 3  0  SPDIF-out     Jack  Combo   Rear       Orange  1
hdaa1:     Caps:    OUT             
hdaa1: 31 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
hdaa1:     Caps: IN                 
hdaa1: NumGPIO=2 NumGPO=0 NumGPI=0 GPIWake=0 GPIUnsol=1
hdaa1:  GPIO0: disabled
hdaa1:  GPIO1: disabled

I can override this configuration to combine speakers and headphones
into one pcm device and get automatic speaker muting when headphones
are plugged in:

# sysctl dev.hdaa.1.nid27_config="as=1 seq=15"
# sysctl dev.hdaa.1.reconfig=1

or

# echo 'hint.hdaa.1.nid27.config="as=1 seq=15"' >>/boot/device.hints

After this the two lines in /dev/sndstat become:

pcm4: <Realtek ALC892 (Analog 7.1+HP/2.0)> (play/rec) default
Comment 5 Raymond 2015-04-11 14:41:20 UTC
how do bsd oss support multichannel for those desktop with three jacks at rear panel ?

http://www.intel.com/support/motherboards/desktop/sb/CS-034198.htm

can you r six jacks  emulated three jacks by changing fixed conn from jack to none of your black, orange and grey jacks ?


what is the benefit of using pulseaudio if bsd oss support virtual channels ?
Comment 6 Andrey Zholos 2015-04-12 14:16:12 UTC
ioctl SNDCTL_DSP_CHANNELS sets the number of channels in the
current stream. E.g. mplayer -ao oss -channels 6 does this.

For this to work either virtual channels have to be disabled
(sysctl dev.pcm.4.play.vchans=0) or their format set correctly
(sysctl dev.pcm.4.play.vchanformat=s16le:7.1).

Some applications support PulseAudio but not OSS - that's one important
benefit :)
Comment 7 Raymond 2015-04-12 16:39:24 UTC
(In reply to Andrey Zholos from comment #2)
> Created attachment 115004 [details] [review] [review]
> Fix
> 
> Patch attached. It works for me with PulseAudio 5.0 which is the
> current FreeBSD port version.
> 
> There's another interface available to query the same info: ioctl
> SNDCTL_SYSINFO/SNDCTL_CARDINFO/SNDCTL_AUDIOINFO, but that would be a
> much more complex patch.

http://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/modules/oss/oss-util.c

seem hw description terminated by (DUPLEX) when using oss3

pa_oss_get_hw_description
Comment 8 Raymond 2015-04-12 16:47:24 UTC
how do oss peform jack retasking when there are only three jacks  at rear panel ?

do you mean that user have to change the pink jack to black jack, blue jack to orange jack ?

Audio jack retasking is a feature that allows a jack to support more than one function. For example, the pink audio jack can support microphone input when the system configuration is set to stereo mode, 2-channel, and as Center/LFE or Rear Surround, when set to 6-channel mode.
Comment 9 Andrey Zholos 2015-04-12 18:08:04 UTC
http://man.freebsd.org/snd_hda mentions retasking.

You can override device type (Line-out/Mic) for any pin and that
implies direction. The color doesn't matter, it's just for reference.
The above pindump represents 6 jacks on the back panel and 2 jacks on
the front panel, but I guess any of them can be retasked because each
says Caps: IN OUT.

pa_oss_get_hw_description doesn't work on FreeBSD anyway. It is parsing
for "%i:" rather than "pcm%i:", so no description is shown:

$ pacmd list-sinks
...
  * index: 4
        name: <oss_output.dsp4>
        driver: <module-oss.c>
        flags: HARDWARE HW_VOLUME_CTRL LATENCY 
        state: SUSPENDED
        suspend cause: IDLE 
        priority: 0
        volume: front-left: 65536 / 100%,   front-right: 65536 / 100%
                balance 0.00
        base volume: 65536 / 100%
        volume steps: 101
        muted: no
        current latency: 0.00 ms
        max request: 4 KiB
        max rewind: 0 KiB
        monitor source: 5
        sample spec: s16le 2ch 48000Hz
        channel map: front-left,front-right
                     Stereo
        used by: 0
        linked by: 0
        fixed latency: 21.33 ms
        module: 10
        properties:
                device.string = "/dev/dsp4"
                device.api = "oss"
                device.description = "/dev/dsp4"
                device.access_mode = "mmap"
                device.buffering.buffer_size = "4096"
                device.buffering.fragment_size = "1024"
                device.icon_name = "audio-card"
...

Also, PulseAudio doesn't seem to detect that it's multichannel, but
that's a topic for another bug report.
Comment 10 Raymond 2015-04-13 02:54:14 UTC
Example 3
     Setting the device.hints(5) options

     hint.hdac.0.cad0.nid20.config="as=1 seq=0"
     hint.hdac.0.cad0.nid26.config="as=2 seq=0"
     hint.hdac.0.cad0.nid27.config="as=3 seq=0"
     hint.hdac.0.cad0.nid25.config="as=4 seq=0"
     hint.hdac.0.cad0.nid24.config="as=5 seq=0 device=Line-out"
     hint.hdac.0.cad0.nid21.config="as=6 seq=0"

     will give 4 independent devices: pcm0 (line-out and line-in), pcm1
     (headphones and mic), pcm2	(additional line-out via retasked rear mic
     jack), and	pcm3 (internal speaker).


this example is interesting 

how do user know whether the codec has one, two or three ADC ?

the hda controllers usually have only four SDO which are shared by analog output and digital output, this means only four devices can be playing but you may have four analog outputs and two digital outputs


do this mean it is hard code to use front mic ?

pcm5: <Realtek ALC892 (Front Analog)> (play/rec)
Comment 11 Arun Raghavan 2015-04-13 03:06:48 UTC
I've pushed your patch now, thanks for the investigation and report!
Comment 12 Raymond 2015-04-13 03:18:09 UTC
hdaa1: 24 01a19850 5  0  Mic           Jack  1/8     Rear       Pink    8
hdaa1:     Caps: IN OUT         VREF Sense: 0x00000000 (disconnected)
hdaa1: 25 02a19c60 6  0  Mic           Jack  1/8     Front      Pink    12
hdaa1:     Caps: IN OUT HP      VREF Sense: 0x00000000 (disconnected)
hdaa1: 26 0181305f 5  15 Line-in       Jack  1/8     Rear       Blue    0
hdaa1:     Caps: IN OUT         VREF Sense: 0x00000000 (disconnected)


The	sequence numbers 14 and	15 has a special meaning for
		    input associations.	 Their presence	in association defines
		    it as multiplexed or mixed respectively.  If none of them
		    are	present	and there are more than	one pin	in associa-
		    tion, the association will provide multichannel input.


pcm4: <Realtek ALC892 (Rear Analog 7.1/2.0)> (play/rec) default


do it mean multi channel capture  when both rear input jacks are present ?
Comment 13 Raymond 2015-04-13 03:39:43 UTC
(In reply to Andrey Zholos from comment #9)
> http://man.freebsd.org/snd_hda mentions retasking.
> 
> You can override device type (Line-out/Mic) for any pin and that
> implies direction. The color doesn't matter, it's just for reference.
> The above pindump represents 6 jacks on the back panel and 2 jacks on
> the front panel, but I guess any of them can be retasked because each
> says Caps: IN OUT.
> 
> pa_oss_get_hw_description doesn't work on FreeBSD anyway. It is parsing
> for "%i:" rather than "pcm%i:", so no description is shown:
> 
> $ pacmd list-sinks
> ...
>   * index: 4
>         name: <oss_output.dsp4>
>         driver: <module-oss.c>
>         flags: HARDWARE HW_VOLUME_CTRL LATENCY 
>         state: SUSPENDED
>         suspend cause: IDLE 
>         priority: 0
>         volume: front-left: 65536 / 100%,   front-right: 65536 / 100%
>                 balance 0.00
>         base volume: 65536 / 100%
>         volume steps: 101
>         muted: no


do it mean that oss alway use 0 to 100 steps ?

 Device: name="ALC892 Analog", type="Audio", device=0
  Amp-Out caps: ofs=0x40, nsteps=0x40, stepsize=0x03, mute=0
Comment 14 Andrey Zholos 2015-04-13 19:35:12 UTC
> do this mean it is hard code to use front mic ?
> pcm5: <Realtek ALC892 (Front Analog)> (play/rec)

I haven't tried it, but I think so. One could also multiplex front and
back mic so either is recorded to the same channels.

> pcm4: <Realtek ALC892 (Rear Analog 7.1/2.0)> (play/rec) default
> do it mean multi channel capture  when both rear input jacks are present ?

It's possible, but I'm not sure what this particular device would
record since there are no input devices in the association.

> the hda controllers usually have only four SDO which are shared by analog
output and digital output, this means only four devices can be playing but you
may have four analog outputs and two digital outputs

I see. That would explain why there are always only four pcm devices
despite there being more associations configured.

I'm afraid I don't know any more about sound on FreeBSD.

If you're still curious, you could try it for yourself. The FreeBSD
install media (CD iso/USB img) has a Live CD option. If you email me
directly I can help you get it working. You could also ask on the
freebsd-hackers mailing list.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.