Usb

找出 USB 設備

  • November 20, 2017

我有使用 USB 與之互動的硬體。它是一個 USB 音效卡 配置文件需要這樣的東西:

devstr=1-1.3.1:1.0

lsusb看起來像這樣:

Bus 001 Device 004: ID 0d8c:0012 C-Media Electronics, Inc.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

我需要Bus 001 Device 004: ID 0d8c:0012 C-Media Electronics, Inc. to在配置文件中引用這個設備。

更新 這裡是**/var/log/messages**(重啟後)

Nov 17 12:33:52 44249 kernel: [    3.658983] usb 1-1.2: New USB device found, idVendor=0d8c, idProduct=0012
Nov 17 12:33:52 44249 kernel: [    3.671869] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Nov 17 12:33:52 44249 kernel: [    3.685433] usb 1-1.2: Product: USB Audio Device
Nov 17 12:33:52 44249 kernel: [    3.694574] usb 1-1.2: Manufacturer: C-Media Electronics Inc.
Nov 17 12:33:52 44249 kernel: [    3.710586] input: C-Media Electronics Inc. USB Audio Device as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.3/0003:0D8C:0012.0001/input/input0
Nov 17 12:33:52 44249 kernel: [    3.790955] hid-generic 0003:0D8C:0012.0001: input,hidraw0: USB HID v1.00 Device [C-Media Electronics Inc. USB Audio Device] on usb-3f980000.usb-1.2/input3

結束更新

lsusb -vd 0d8c:0012的****更新 2輸出

root@44249:~# lsusb -vd 0d8c:0012

Bus 001 Device 004: ID 0d8c:0012 C-Media Electronics, Inc. 
Device Descriptor:
bLength                18
bDescriptorType         1
bcdUSB               1.10
bDeviceClass            0 (Defined at Interface level)
bDeviceSubClass         0 
bDeviceProtocol         0 
bMaxPacketSize0         8
idVendor           0x0d8c C-Media Electronics, Inc.
idProduct          0x0012 
bcdDevice            1.00
iManufacturer           1 C-Media Electronics Inc.
iProduct                2 USB Audio Device
iSerial                 0 
bNumConfigurations      1
Configuration Descriptor:
bLength                 9
bDescriptorType         2
wTotalLength          253
bNumInterfaces          4
bConfigurationValue     1
iConfiguration          0 
bmAttributes         0x80
 (Bus Powered)
MaxPower              100mA
Interface Descriptor:
 bLength                 9
 bDescriptorType         4
 bInterfaceNumber        0
 bAlternateSetting       0
 bNumEndpoints           0
 bInterfaceClass         1 Audio
 bInterfaceSubClass      1 Control Device
 bInterfaceProtocol      0 
 iInterface              0 
 AudioControl Interface Descriptor:
   bLength                10
   bDescriptorType        36
   bDescriptorSubtype      1 (HEADER)
   bcdADC               1.00
   wTotalLength          100
   bInCollection           2
   baInterfaceNr( 0)       1
   baInterfaceNr( 1)       2
 AudioControl Interface Descriptor:
   bLength                12
   bDescriptorType        36
   bDescriptorSubtype      2 (INPUT_TERMINAL)
   bTerminalID             1
   wTerminalType      0x0101 USB Streaming
   bAssocTerminal          0
   bNrChannels             2
   wChannelConfig     0x0003
     Left Front (L)
     Right Front (R)
   iChannelNames           0 
   iTerminal               0 
 AudioControl Interface Descriptor:
   bLength                12
   bDescriptorType        36
   bDescriptorSubtype      2 (INPUT_TERMINAL)
   bTerminalID             2
   wTerminalType      0x0201 Microphone
   bAssocTerminal          0
   bNrChannels             1
   wChannelConfig     0x0001
     Left Front (L)
   iChannelNames           0 
   iTerminal               0 
 AudioControl Interface Descriptor:
   bLength                 9
   bDescriptorType        36
   bDescriptorSubtype      3 (OUTPUT_TERMINAL)
   bTerminalID             6
   wTerminalType      0x0301 Speaker
   bAssocTerminal          0
   bSourceID               9
   iTerminal               0 
 AudioControl Interface Descriptor:
   bLength                 9
   bDescriptorType        36
   bDescriptorSubtype      3 (OUTPUT_TERMINAL)
   bTerminalID             7
   wTerminalType      0x0101 USB Streaming
   bAssocTerminal          0
   bSourceID               8
   iTerminal               0 
 AudioControl Interface Descriptor:
   bLength                 7
   bDescriptorType        36
   bDescriptorSubtype      5 (SELECTOR_UNIT)
   bUnitID                 8
   bNrInPins               1
   baSource( 0)           10
   iSelector               0 
 AudioControl Interface Descriptor:
   bLength                10
   bDescriptorType        36
   bDescriptorSubtype      6 (FEATURE_UNIT)
   bUnitID                 9
   bSourceID              15
   bControlSize            1
   bmaControls( 0)      0x01
     Mute Control
   bmaControls( 1)      0x02
     Volume Control
   bmaControls( 2)      0x02
     Volume Control
   iFeature                0 
 AudioControl Interface Descriptor:
   bLength                 9
   bDescriptorType        36
   bDescriptorSubtype      6 (FEATURE_UNIT)
   bUnitID                10
   bSourceID               2
   bControlSize            1
   bmaControls( 0)      0x43
     Mute Control
     Volume Control
     Automatic Gain Control
   bmaControls( 1)      0x00
   iFeature                0 
 AudioControl Interface Descriptor:
   bLength                 9
   bDescriptorType        36
   bDescriptorSubtype      6 (FEATURE_UNIT)
   bUnitID                13
   bSourceID               2
   bControlSize            1
   bmaControls( 0)      0x03
     Mute Control
     Volume Control
   bmaControls( 1)      0x00
   iFeature                0 
 AudioControl Interface Descriptor:
   bLength                13
   bDescriptorType        36
   bDescriptorSubtype      4 (MIXER_UNIT)
   bUnitID                15
   bNrInPins               2
   baSourceID( 0)          1
   baSourceID( 1)         13
   bNrChannels             2
   wChannelConfig     0x0003
     Left Front (L)
     Right Front (R)
   iChannelNames           0 
   bmControls         0x00
   iMixer                  0 
Interface Descriptor:
 bLength                 9
 bDescriptorType         4
 bInterfaceNumber        1
 bAlternateSetting       0
 bNumEndpoints           0
 bInterfaceClass         1 Audio
 bInterfaceSubClass      2 Streaming
 bInterfaceProtocol      0 
 iInterface              0 
Interface Descriptor:
 bLength                 9
 bDescriptorType         4
 bInterfaceNumber        1
 bAlternateSetting       1
 bNumEndpoints           1
 bInterfaceClass         1 Audio
 bInterfaceSubClass      2 Streaming
 bInterfaceProtocol      0 
 iInterface              0 
 AudioStreaming Interface Descriptor:
   bLength                 7
   bDescriptorType        36
   bDescriptorSubtype      1 (AS_GENERAL)
   bTerminalLink           1
   bDelay                  1 frames
   wFormatTag              1 PCM
 AudioStreaming Interface Descriptor:
   bLength                14
   bDescriptorType        36
   bDescriptorSubtype      2 (FORMAT_TYPE)
   bFormatType             1 (FORMAT_TYPE_I)
   bNrChannels             2
   bSubframeSize           2
   bBitResolution         16
   bSamFreqType            2 Discrete
   tSamFreq[ 0]        48000
   tSamFreq[ 1]        44100
 Endpoint Descriptor:
   bLength                 9
   bDescriptorType         5
   bEndpointAddress     0x01  EP 1 OUT
   bmAttributes            9
     Transfer Type            Isochronous
     Synch Type               Adaptive
     Usage Type               Data
   wMaxPacketSize     0x00c8  1x 200 bytes
   bInterval               1
   bRefresh                0
   bSynchAddress           0
   AudioControl Endpoint Descriptor:
     bLength                 7
     bDescriptorType        37
     bDescriptorSubtype      1 (EP_GENERAL)
     bmAttributes         0x01
       Sampling Frequency
     bLockDelayUnits         1 Milliseconds
     wLockDelay              1 Milliseconds
Interface Descriptor:
 bLength                 9
 bDescriptorType         4
 bInterfaceNumber        2
 bAlternateSetting       0
 bNumEndpoints           0
 bInterfaceClass         1 Audio
 bInterfaceSubClass      2 Streaming
 bInterfaceProtocol      0 
 iInterface              0 
Interface Descriptor:
 bLength                 9
 bDescriptorType         4

Bus 001 Device 004: ID 0d8c:0012 C-Media Electronics, Inc.
Device Descriptor:
bLength                18
bDescriptorType         1
bcdUSB               1.10
bDeviceClass            0 (Defined at Interface level)
bDeviceSubClass         0
bDeviceProtocol         0
bMaxPacketSize0         8
idVendor           0x0d8c C-Media Electronics, Inc.
idProduct          0x0012
bcdDevice            1.00
iManufacturer           1 C-Media Electronics Inc.
iProduct                2 USB Audio Device
iSerial                 0
bNumConfigurations      1
Configuration Descriptor:
bLength                 9
bDescriptorType         2
wTotalLength          253
bNumInterfaces          4
bConfigurationValue     1
iConfiguration          0
bmAttributes         0x80
 (Bus Powered)
MaxPower              100mA
Interface Descriptor:
 bLength                 9
 bDescriptorType         4
 bInterfaceNumber        0
 bAlternateSetting       0
 bNumEndpoints           0
 bInterfaceClass         1 Audio
 bInterfaceSubClass      1 Control Device
 bInterfaceProtocol      0
 iInterface              0
 AudioControl Interface Descriptor:
   bLength                10
   bDescriptorType        36
   bDescriptorSubtype      1 (HEADER)
   bcdADC               1.00
   wTotalLength          100
   bInCollection           2
   baInterfaceNr( 0)       1
   baInterfaceNr( 1)       2
 AudioControl Interface Descriptor:
   bLength                12
   bDescriptorType        36
   bDescriptorSubtype      2 (INPUT_TERMINAL)
   bTerminalID             1
   wTerminalType      0x0101 USB Streaming
   bAssocTerminal          0
   bNrChannels             2
   wChannelConfig     0x0003
     Left Front (L)
     Right Front (R)
   iChannelNames           0
   iTerminal               0
 AudioControl Interface Descriptor:
   bLength                12
   bDescriptorType        36
   bDescriptorSubtype      2 (INPUT_TERMINAL)
   bTerminalID             2
   wTerminalType      0x0201 Microphone
   bAssocTerminal          0
   bNrChannels             1
   wChannelConfig     0x0001
     Left Front (L)
   iChannelNames           0
   iTerminal               0
 AudioControl Interface Descriptor:
   bLength                 9
   bDescriptorType        36
   bDescriptorSubtype      3 (OUTPUT_TERMINAL)
   bTerminalID             6
   wTerminalType      0x0301 Speaker
   bAssocTerminal          0
   bSourceID               9

結束更新

任何指針?

謝謝

丹尼

  1. USB 音頻設備由 ALSA 核心驅動程序處理,並且這些驅動程序自動對供應商做出反應:USB 設備的產品標識符(或通用介面)。您通常使用的驅動程序都不會使用devstr. 你沒有說你為什麼需要這個字元串,但你可能做錯了。

  2. 您的範例內容devstr是 USB 路徑,如圖所示/sys/bus/usb/deviceslsusb -t無法從您的資訊中獲取,但如果您無法直接找到設備,則可以從中獲取。

dmesg3) 請在插入設備後編輯帶有輸出的問題。

  1. 您很可能缺少正確的 ALSA 驅動程序。如果還沒有,請將核心更新到最新版本。

編輯

應該發生snd-usb-audio的是根據 USB 設備的類載入模組。相反,根據您dmesg的情況,該設備被辨識為Human Interface Device,這很奇怪,除非它除了聲音功能之外還具有以這種方式表示的按鈕或類似設備。

請編輯輸出為 的問題lsusb -vd 0d8c:0012,以便我們可以查看它是否具有帶有音頻類的描述符。另外,驗證您的核心是否包含模組snd-usb-audio,並modinfo snd-usb-audio包含這兩個

alias:          usb:v*p*d*dc*dsc*dp*ic01isc01ip*in*
alias:          usb:v*p*d*dc*dsc*dp*ic01isc03ip*in*

線。

編輯

假設輸出末尾的重複行是複制和粘貼錯誤:這看起來像標準 USB 音效卡,應該snd-usb-audio. 我剛剛仔細檢查了我的 USB 音效卡,看起來這個驅動程序在成功初始化時不會產生消息。請編輯帶有輸出的問題cat /proc/asound/cards/以查看它是否被拾取。

如果不是,我唯一的猜測是您以某種方式弄亂了模組依賴項,儘管我不知道您做了什麼,而且您沒有說(但是“(我有一個未命名的軟體在哪裡)配置時需要…”聽起來有些不祥)。如果是這種情況,您可以嘗試使用手冊modprobe snd-usb-audio;您可以嘗試使用 修復它depmod,或者您可以重新安裝(或升級,同時使用它)您的核心。

如果這沒有幫助,我沒有想法。

引用自:https://unix.stackexchange.com/questions/404684