1. 查找 USB 设备供应商和产品 ID

1. 查找 USB 设备供应商和产品 ID

我如何将信息列入黑名单或其他永久禁用扩展坞上的声卡,同时保留使用 USB 声音设备的能力以及使用扩展坞的其他功能的能力?

硬件:

  • 我有一套基于 USB 声卡的耳机。Bus 002 Device 014: ID 046d:0a44 Logitech, Inc. Headset H390
  • 我还有一个 Dell D3100 扩展坞,用作 USB 倍增器并运行附加屏幕。我认为这些 USB 设备与 USB 集线器相关:
Bus 003 Device 005: ID 17e9:436e DisplayLink 
Bus 003 Device 004: ID 2109:0813 VIA Labs, Inc. 
Bus 003 Device 003: ID 17e9:436e DisplayLink 
Bus 003 Device 002: ID 2109:0813 VIA Labs, Inc. 
Bus 002 Device 005: ID 2109:2813 VIA Labs, Inc. 
Bus 002 Device 003: ID 2109:2813 VIA Labs, Inc. 

以下是所有声音设备:

# cat /proc/asound/modules
 0 snd_hda_intel    # Built in HP Audio
 1 snd_usb_audio    # Dell Docking Station Sound
 2 snd_hda_intel    # Built in HP Audio (HDMI)
 3 snd_usb_audio    # Headset

以下是我希望继续使用的设备的详细信息:

T:  Bus=02 Lev=03 Prnt=16 Port=00 Cnt=01 Dev#= 19 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=16 #Cfgs=  1
P:  Vendor=046d ProdID=0a44 Rev=01.27
S:  Manufacturer=Logitech
S:  Product=Logitech USB Headset
C:  #Ifs= 4 Cfg#= 1 Atr=80 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 0 Cls=01(audio) Sub=01 Prot=00 Driver=snd-usb-audio
I:  If#= 1 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=00 Driver=snd-usb-audio
I:  If#= 2 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=00 Driver=snd-usb-audio
I:  If#= 3 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid


                         description: Audio device
                         product: Logitech USB Headset
                         vendor: Logitech
                         physical id: 1
                         bus info: usb@2:4.2.1
                         version: 1.27
                         capabilities: usb-1.10 audio-control
                         configuration: driver=usbhid maxpower=100mA speed=12Mbit/s

以下是我希望列入黑名单的设备的详细信息:

T:  Bus=03 Lev=02 Prnt=06 Port=02 Cnt=03 Dev#=  8 Spd=5000 MxCh= 0
D:  Ver= 3.10 Cls=ef(misc ) Sub=02 Prot=01 MxPS= 9 #Cfgs=  1
P:  Vendor=17e9 ProdID=436e Rev=31.24
S:  Manufacturer=DisplayLink
S:  Product=Dell D3100 USB3.0 Dock
S:  SerialNumber=1709142212
C:  #Ifs= 7 Cfg#= 1 Atr=e0 MxPwr=8mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=03 Driver=usbfs
I:  If#= 1 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none)
I:  If#= 2 Alt= 0 #EPs= 1 Cls=01(audio) Sub=01 Prot=20 Driver=snd-usb-audio
I:  If#= 3 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=20 Driver=snd-usb-audio
I:  If#= 4 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=20 Driver=snd-usb-audio
I:  If#= 5 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0d Prot=00 Driver=cdc_ncm
I:  If#= 6 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=01 Driver=cdc_ncm

声音设备具体如下:

*-usb:2
     description: Audio device
     product: Dell D3100 USB3.0 Dock
     vendor: DisplayLink
     physical id: 3
     bus info: usb@3:4.3
     version: 31.24
     serial: 1709142212
     capabilities: usb-3.10 audio-control
     configuration: driver=cdc_ncm maxpower=8mA speed=5000Mbit/s

答案1

我没有这个特定的底座,但我有一个类似的底座(戴尔 WD19),它也具有线路输出和耳机插孔。这很令人沮丧,因为每次我连接底座时,即使没有连接耳机,PulseAudio 也会自动将声音输出切换到底座耳机输出。如果我接听电话,我会连接 USB 耳机,因此底座上的耳机或线路输出端口对我毫无用处。不过,我非常喜欢让 PulseAudio 自动切换到 USB 耳机,所以我不想完全禁用自动切换。可以通过命令行更改活动输出,如所述在这个问题中,但是当我断开耳机时,自动切换仍然会返回到基座输出。

事实证明,通过 udev 规则让 PulseAudio 忽略设备并不难。(原文来源)


1. 查找 USB 设备供应商和产品 ID

运行pactl list sinks以查看 PulseAudio 已知的所有音频输出的详细信息。这将产生相当多的输出,但应该很容易找到我们想要列入黑名单的特定设备。

Sink #21
    State: RUNNING
    Name: alsa_output.usb-Generic_USB_Audio_200901010001-00.HiFi__hw_Dock__sink
    Description: USB Audio Headphones
    Driver: module-alsa-card.c
    Sample Specification: s24le 2ch 48000Hz
    Channel Map: front-left,front-right
    Owner Module: 37
    Mute: no
    Volume: front-left: 30419 /  46% / -20.00 dB,   front-right: 30419 /  46% / -20.00 dB
            balance 0.00
    Base Volume: 65536 / 100% / 0.00 dB
    Monitor Source: alsa_output.usb-Generic_USB_Audio_200901010001-00.HiFi__hw_Dock__sink.monitor
    Latency: 21709 usec, configured 18750 usec
    Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY 
    Properties:
        alsa.resolution_bits = "24"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = "USB Audio"
        alsa.id = "USB Audio"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "0"
        alsa.card = "1"
        alsa.card_name = "WD19 Dock"
        alsa.long_card_name = "Dell-WD15-Dock"
        alsa.driver_name = "snd_usb_audio"
        device.bus_path = "pci-0000:00:14.0-usb-0:1.3.4:1.0"
        sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.3/1-1.3.4/1-1.3.4:1.0/sound/card1"
        udev.id = "usb-Generic_USB_Audio_200901010001-00"
        device.bus = "usb"
        device.vendor.id = "0bda"
        device.vendor.name = "Realtek Semiconductor Corp."
        device.product.id = "402e"
        device.product.name = "USB Audio"
        device.serial = "Generic_USB_Audio_200901010001"
        device.string = "hw:Dock"
        device.buffering.buffer_size = "576000"
        device.buffering.fragment_size = "288000"
        device.access_mode = "mmap+timer"
        device.profile.name = "HiFi: hw:Dock: sink"
        device.profile.description = "Headphones"
        alsa.mixer_device = "hw:Dock"
        device.description = "USB Audio Headphones"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-usb"
    Ports:
        [Out] Headphones: Headphones (priority: 100)
    Active Port: [Out] Headphones
    Formats:
        pcm

我们正在寻找线条device.vendor.id = "0bda"device.product.id = "402e"

2. 创建自定义 udev 规则

创建一个文件/etc/udev/rules.d/89-pulseaudio-usb.rules(使用您喜欢的编辑器)并插入如下一行,使用之前找到的供应商和产品 ID:

ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="402e", ENV{PULSE_IGNORE}="1"

保存文件,然后断开基座。

3. 重新连接(无需重启)

udev 应该读取这条新规则,并告诉 PulseAudio 在下次连接时忽略该设备 - 不需要重启(至少我在 Ubuntu 20.04 上不需要)。该设备将不再显示为 PulseAudio 的输出设备,因此它不会被自动选为输出设备。

答案2

好吧,我无法评论,所以我只想说 seanlano 接受的答案在 22.04 对我有用。非常感谢。这个问题困扰了我好几个月。

相关内容