https://blog.csdn.net/l1991819/article/details/84393703
之前做UAC项目时整理的关于request的内容,有一些是从其他牛人写的博客上摘取的,没有标明出处,请谅解。
Request: 请求,Audio-class-specific request用于set和get AUDIO相关的控制request。这些控制主要包括两部分:包括audio功能的控制(如音量)和影响数据传输的request(如采样频率)
Request属于控制传输,控制传输包括三个阶段:建立阶段、数据阶段、状态阶段。
控制传输三个阶段
建立阶段(Setup Stage)
建立阶段包括:SETUP令牌包,DATA0数据包,ACK握手包。SETUP包传输的是SETUP PID,设备地址,端点数。数据包中传输的是要控制的类型,传输方向,数据包长度等,见setup数据结构。ACK packet传输的是ACK PID。
数据阶段(控制读取)
读取数据阶段包括:IN令牌信息包,DATA数据包,ACK握手包。IN包传输的是IN PID,设备地址,端点数,表示要有数据读进来。数据包是从设备向主设备传输的数据,首先是DATA PID,然后是描述符,或是request中的控制属性。ACK包同上。
数据阶段(控制写入)
写入数据阶段包括:OUT令牌信息包,DATA数据包,ACK握手包。OUT包传输的是OUT PID,设备地址,端点数,表示要有数据向外写。数据包是由主设备向从设备传输的数据,首先是DATA PID,然后是是request中的控制属性。ACK包同上。
状态阶段(控制读取)
读取状态阶段包括:OUT令牌信息包,DATA1数据包,ACK握手包。
状态阶段(控制写入&无数据控制)
写入状态阶段包括:IN令牌信息包,DATA1数据包,ACK握手包。
注意:
数据阶段,DATA1,DATA0交替,根据PID确定是哪一个数据包。
控制读取以及无数据控制的状态阶段都是HOST发送IN packet。
PID数据格式,8位:0-3为PID, 4-8为PID反转。
Setup数据结构
bmRequestType
Direction(D7)
0b0-Set request
0b1-Get request
Type(D6..5)
0b01-Audio class-specific request
Recipient(D4..0)
0b00001-an interface (AudioControl or AudioStreaming) of the audio function
0b00010-isochronous endpoint of an AudioStreaming interface
bRequest
0x00-REQUEST_CODE_UNDEFINED
0x01-CUR
0x02-RANGE
0x03-MEM
wValue
Control Selector(hight byte)| Channel Number(low byte)
(Mixer: CS=MU_MIXER_CONTROL(higth byte)|Mixer Control Number(low byte))
wIndex
bmRequestType = 0b00100001 or 10100001(interface)
Entity ID(hight byte)|interface(low byte)
bmRequestType = 0b00100010 or 10100010(endpoint)
0(higt byte)|endpoint(low byte)
wLength
The length of the parameter block
上表中,bmRequestType D6..5:0b01代表Audio类请求,其余请求类型有0x02: CDC控制类,0x03: HID类等。
每一种控制都会有一个或者更多的属性,目前定义的属性有
1.Current setting attribute当前设置属性
0
bCUR
1
当前设置值
2.Range attribute范围属性
0
wNumSubRanges
2
子范围的数量
2
bMIN(1)
1
第一个子范围的最小值
3
bMAX(1)
1
第一个子范围的最大值
4
bRES(1)
1
第一个子范围的步进
…
…
1
…
2+3*(n-1)
bMIN(n)
1
第n个子范围的最小值
3+3*(n-1)
bMAX(n)
1
第n个子范围的最大值
4+3*(n-1)
bRES(n)
1
第n个子范围的步进
具体请求实例
Get request(FREQ-RANGE)-Play
bmRequestType
A1
Get request
Audio class request
interface
bRequest
02
RANGE
wValue
0100
CS_SAM_FREQ_CONTROL
wIndex
**00
Clock Source (Play)
wLength
0002
2
wNumSubRanges
The number of subranges of the addressed Control
1
bmRequestType
A1
Get request
Audio class request
interface
bRequest
02
RANGE
wValue
0100
CS_SAM_FREQ_CONTROL
wIndex
**00
Clock Source (Play)
wLength
000E
14
wNumSubRanges
0001
1
bMIN(1)
0000BB80
480000
bMAX(1)
0000BB80
480000
bRES(1)
00000000
0
Get request(FREQ-CUR) -Play
bmRequestType
A1
Get request
Audio class request
interface
bRequest
01
CUR
wValue
0100
CS_SAM_FREQ_CONTROL
wIndex
**00
Clock Source (play)
wLength
0004
4
bCUR
0000BB80
48000
Get request(FREQ-RANGE)-Record
bmRequestType
A1
Get request
Audio class request
interface
bRequest
02
RANGE
wValue
0100
CS_SAM_FREQ_CONTROL
wIndex
**00
Clock Source (Record)
wLength
0002
2
wNumSubRanges
The number of subranges of the addressed Control
1
bmRequestType
A1
Get request
Audio class request
interface
bRequest
02
RANGE
wValue
0100
CS_SAM_FREQ_CONTROL
wIndex
**00
Clock Source (Record)
wLength
000E
14
wNumSubRanges
0001
1
bMIN(1)
0000BB80
480000
bMAX(1)
0000BB80
480000
bRES(1)
00000000
0
Get request(FREQ-CUR)-Record
bmRequestType
A1
Get request
Audio class request
interface
bRequest
01
CUR
wValue
0100
CS_SAM_FREQ_CONTROL
wIndex
**00
Clock Source(Record)
wLength
0004
4
bCUR
0000BB80
48000
Get request(MUTE-CUR)-Play
bmRequestType
A1
Get request
Audio class request
interface
bRequest
01
CUR
wValue
0100
FU_MUTE_CONTROL
wIndex
**00
Feature Unit (Play)
wLength
0001
1
bCUR
00
Not mute
Get request(MUTE-CUR)-Record
bmRequestType
A1
Get request
Audio class request
interface
bRequest
01
CUR
wValue
0100
FU_MUTE_CONTROL
wIndex
**00
Feature Unit (Record)
wLength
0001
1
bCUR
00
Not mute
Set request(MUTE-CUR)-Play
bmRequestType
21
Set request
Audio class request
interface
bRequest
01
CUR
wValue
0100
FU_MUTE_CONTROL
wIndex
**00
Feature Unit (Play)
wLength
0001
1
Set request(MUTE-CUR)-Record
bmRequestType
21
Set request
Audio class request
interface
bRequest
01
CUR
wValue
0100
FU_MUTE_CONTROL
wIndex
**00
Feature Unit (Record)
wLength
0001
1
---------------------
作者:l1991819
来源:CSDN
原文:https://blog.csdn.net/l1991819/article/details/84393703
版权声明:本文为博主原创文章,转载请附上博文链接!