Bug 14028 - snd_usb_audio and "Slave PCM not usable"
Summary: snd_usb_audio and "Slave PCM not usable"
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Sound(ALSA) (show other bugs)
Hardware: All Linux
: P1 high
Assignee: Clemens Ladisch
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-20 15:24 UTC by Andrzej
Modified: 2009-08-25 06:27 UTC (History)
2 users (show)

See Also:
Kernel Version: >=2.6.20
Subsystem:
Regression: No
Bisected commit-id:


Attachments
fix unsorted list constraint handling (1.58 KB, patch)
2009-08-24 07:25 UTC, Clemens Ladisch
Details | Diff

Description Andrzej 2009-08-20 15:24:12 UTC
I've got an old USB PixelView webcam, detected by system as:

Bus 002 Device 002: ID 0471:0304 Philips Askey VC010 WebCam [pwc]

Output from dmesg:
pwc: Philips webcam module version 10.0.13 loaded.
pwc: Supports Philips PCA645/646, PCVC675/680/690, PCVC720[40]/730/740/750 & PCVC830/840.
pwc: Also supports the Askey VC010, various Logitech Quickcams, Samsung MPC-C10 and MPC-C30,
pwc: the Creative WebCam 5 & Pro Ex, SOTEC Afina Eye and Visionite VCS-UC300 and VCS-UM100.
pwc: Askey VC010 type 2 USB webcam detected.
pwc: Registered as /dev/video0.
usbcore: registered new interface driver snd-usb-audio

To make everything work, I need two kernel modules: pwc (for image capture) and snd-usb-audio (integrated microphone). Everything worked fine, until kernel version 2.6.20. Now, integrated microphone is unusable. When connecting the camera, everything behaves just like on 2.6.18 - dmesg reports loading of snd-usb-audio. But when I try to use e.g. Skype, I've got an error "Problem with capture device". Skype in the console returns many times:

ALSA lib pcm_params.c:2152:(snd_pcm_hw_refine_slave) Slave PCM not usable

In the dmesg there's nothing related to audio device at the same time.
No matter, what ALSA version I compile - it seems to be a kernel problem (I also submitted this bug to ALSA bugtracker, but without any response).
Comment 1 Takashi Iwai 2009-08-20 15:38:55 UTC
What shows /proc/asound/card*/stream#* files?

It's more likely a problem of alsa-lib default configuration for usb-audio devices than the driver issue.  Possibly the format dmix/dsnoop alsa-lib plugins require isn't supported on your device.
Comment 2 Andrzej 2009-08-20 18:39:08 UTC
/proc/asound/card1/stream0:

USB Device 0x471:0x304 at usb-0000:00:03.1-2, full speed : USB Audio

Capture:
  Status: Stop
  Interface 2
    Altset 1
    Format: 0x0 (8 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 48000
  Interface 2
    Altset 2
    Format: 0x2 (16 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 48000
  Interface 2
    Altset 3
    Format: 0x20 (24 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 48000
  Interface 2
    Altset 4
    Format: 0x0 (8 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 44100
  Interface 2
    Altset 5
    Format: 0x2 (16 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 44100
  Interface 2
    Altset 6
    Format: 0x20 (24 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 44100
  Interface 2
    Altset 7
    Format: 0x0 (8 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 32000
  Interface 2
    Altset 8
    Format: 0x2 (16 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 32000
  Interface 2
    Altset 9
    Format: 0x20 (24 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 32000
  Interface 2
    Altset 10
    Format: 0x0 (8 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 24000
  Interface 2
    Altset 11
    Format: 0x2 (16 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 24000
  Interface 2
    Altset 12
    Format: 0x20 (24 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 24000
  Interface 2
    Altset 13
    Format: 0x0 (8 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 22050
  Interface 2
    Altset 14
    Format: 0x2 (16 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 22050
  Interface 2
    Altset 15
    Format: 0x20 (24 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 22050
  Interface 2
    Altset 16
    Format: 0x0 (8 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 16000
  Interface 2
    Altset 17
    Format: 0x2 (16 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 16000
  Interface 2
    Altset 18
    Format: 0x20 (24 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 16000
  Interface 2
    Altset 19
    Format: 0x0 (8 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 12000
  Interface 2
    Altset 20
    Format: 0x2 (16 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 12000
  Interface 2
    Altset 21
    Format: 0x20 (24 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 12000
  Interface 2
    Altset 22
    Format: 0x0 (8 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 11025
  Interface 2
    Altset 23
    Format: 0x2 (16 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 11025
  Interface 2
    Altset 24
    Format: 0x20 (24 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 11025
  Interface 2
    Altset 25
    Format: 0x0 (8 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 8000
  Interface 2
    Altset 26
    Format: 0x2 (16 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 8000
  Interface 2
    Altset 27
    Format: 0x20 (24 bits)
    Channels: 1
    Endpoint: 5 IN (ASYNC)
    Rates: 8000
------------------
I've got two kernels in my system now: 2.6.18 and 2.6.20. On the first my device works correctly with the same alsa-lib which makes problems on 2.6.20.
I tried to compile latest alsa-lib, but nothing changed.
Comment 4 Andrzej 2009-08-21 08:49:15 UTC
I checked 2.6.30-1-686 from Debian Squeeze and I can also confirm this bug.
Comment 5 Clemens Ladisch 2009-08-21 09:11:33 UTC
Do the following commands work?

arecord -D hw:1 -f dat -c 1 something.wav
arecord -D default:1 -f dat -c 1 something.wav
Comment 6 Andrzej 2009-08-21 10:21:01 UTC
adk@linux:~$ arecord -D hw:1 -f dat -c 1 something.wav
Recording WAVE 'something.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
arecord: set_params:882: Broken configuration for this PCM: no configurations available
adk@linux:~$ arecord -D default:1 -f dat -c 1 something.wav
ALSA lib pcm_direct.c:866:(snd1_pcm_direct_initialize_slave) snd_pcm_hw_params_any failed
ALSA lib pcm_dsnoop.c:604:(snd_pcm_dsnoop_open) unable to initialize slave
arecord: main:550: audio open error: Bad argument

I also executed these commands on 2.6.18 kernel and both record a file, which could be correctly played by mplayer.
Comment 7 Clemens Ladisch 2009-08-21 11:47:49 UTC
> $ arecord -D hw:1 ...
> arecord: Broken configuration for this PCM: no configurations available

OK, this is definitely a driver bug.

Please uncomment the "#define HW_CONST_DEBUG" in sound/usb/usbaudio.c, recompile the driver, and show the debug message in the system log when you try to run arecord on hw:1.

BTW: Your /proc/asound/card1/stream0 is from a 2.6.30 kernel.
Comment 8 Andrzej 2009-08-21 14:04:01 UTC
usbcore: registered new interface driver snd-usb-audio
hw_rule_rate: (8000,48000)
  --> (8000, 48000) (changed = 0)
hw_rule_channels: (1,1)
  --> (1, 1) (changed = 0)
hw_rule_format: 5:1
  --> 5:1 (changed = 0)

> BTW: Your /proc/asound/card1/stream0 is from a 2.6.30 kernel.
That sounds strange - I am completely sure it was from 2.6.20 (but with self-compiled alsa-driver 1.0.20).
Comment 9 Clemens Ladisch 2009-08-21 14:47:13 UTC
>  --> (8000, 48000) (changed = 0)
>  --> (1, 1) (changed = 0)
>  --> 5:1 (changed = 0)

This looks OK, but the arecord message indicates that these values did not end up in userspace.

Please change "#undef RULES_DEBUG" to "#define RULES_DEBUG" in sound/core/pcm_native.c and show that debug output.

> it was from 2.6.20 (but with self-compiled alsa-driver 1.0.20)

The drivers from the alsa-driver package replace the kernel drivers.
Did you ever test with the 2.6.20 drivers?
Comment 10 Andrzej 2009-08-21 18:02:04 UTC
 
> Did you ever test with the 2.6.20 drivers?
Yes, just after kernel compilation, but with the same result - so I decided to compile ALSA again, from latest source.

After changes debug output shows:
ACCESS = 00000000ffffffffffffffff -> 0000000000000009
FORMAT = 00000000ffffffffffffffff -> 0000000000010005
SUBFORMAT = 00000000ffffffffffffffff -> 0000000000000001
SAMPLE_BITS = [0 4294967295] -> [0 4294967295]
FRAME_BITS = [0 4294967295] -> [0 4294967295]
CHANNELS = [0 4294967295] -> [1 1]
RATE = [0 4294967295] -> [8000 48000]
PERIOD_TIME = [0 4294967295] -> [1000 4294967295]
PERIOD_SIZE = [0 4294967295] -> [0 4294967295]
PERIOD_BYTES = [0 4294967295] -> [64 524288]
PERIODS = [0 4294967295] -> [2 1024]
BUFFER_TIME = [0 4294967295] -> [0 4294967295]
BUFFER_SIZE = [0 4294967295] -> [0 4294967295]
BUFFER_BYTES = [0 4294967295] -> [64 1048576]
TICK_TIME = [0 4294967295] -> [0 4294967295]
Rule 0 [f89ca589]: FORMAT = 5 -> 5
Rule 1 [f89ca40f]: SAMPLE_BITS = [0 4294967295] -> [8 24]
Rule 2 [f89ca54e]: SAMPLE_BITS = [8 24] -> [8 24]
Rule 3 [f89ca513]: FRAME_BITS = [0 4294967295] -> [8 24]
Rule 4 [f89ca4d0]: FRAME_BITS = [8 24] -> [8 24]
Rule 5 [f89ca4d0]: FRAME_BITS = [8 24] -> [8 24]
Rule 6 [f89ca54e]: CHANNELS = [1 1] -> [1 1]
Rule 7 [f89ca4d0]: RATE = [8000 48000] -> [8000 48000]
Rule 8 [f89ca4d0]: RATE = [8000 48000] -> [8000 48000]
Rule 9 [f89ca54e]: PERIODS = [2 1024] -> [2 1024]
Rule 10 [f89ca54e]: PERIOD_SIZE = [0 4294967295] -> [0 2147483647]
Rule 11 [f89ca4d0]: PERIOD_SIZE = [0 2147483647] -> [22 524288]
Rule 12 [f89ca48d]: PERIOD_SIZE = [22 524288] -> [22 524288]
Rule 13 [f89ca513]: BUFFER_SIZE = [0 4294967295] -> [44 536870912]
Rule 14 [f89ca4d0]: BUFFER_SIZE = [44 536870912] -> [44 1048576]
Rule 15 [f89ca48d]: BUFFER_SIZE = [44 1048576] -> [44 1048576]
Rule 16 [f89ca48d]: PERIOD_BYTES = [64 524288] -> [64 524288]
Rule 17 [f89ca48d]: BUFFER_BYTES = [64 1048576] -> [64 1048576]
Rule 18 [f89ca4d0]: PERIOD_TIME = [1000 4294967295] -> [1000 65536000]
Rule 19 [f89ca4d0]: BUFFER_TIME = [0 4294967295] -> (916 131072000]
Rule 20 [f8c01ba9]: RATE = [8000 48000]<7>hw_rule_rate: (8000,48000)
  --> (8000, 48000) (changed = 0)
 -> [8000 48000]
Rule 21 [f8c01a73]: CHANNELS = [1 1]<7>hw_rule_channels: (1,1)
  --> (1, 1) (changed = 0)
 -> [1 1]
Rule 22 [f8c0196c]: FORMAT = 5<7>hw_rule_format: 5:1
  --> 5:1 (changed = 0)
 -> 5
Rule 23 [f89cd557]: RATE = [8000 48000] -> empty
Comment 11 Clemens Ladisch 2009-08-24 07:25:06 UTC
Created attachment 22826 [details]
fix unsorted list constraint handling

> Rule 23 [f89cd557]: RATE = [8000 48000] -> empty

So the rate list created by snd_usb_pcm_check_knot() does not work.

Please try the patch.
Comment 12 Andrzej 2009-08-24 14:36:04 UTC
Your patch seems to be working :)
Comment 13 Clemens Ladisch 2009-08-24 15:27:47 UTC
If you want to be credited, please provide your e-mail address for the Reported-and-tested-by tag.
Comment 14 Andrzej 2009-08-24 21:03:09 UTC
adkadk at gmail dot com

Thanks for your help.

Note You need to log in before you can comment on or make changes to this bug.