Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
f003397c
Q
qemu
项目概览
openeuler
/
qemu
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f003397c
编写于
8月 31, 2011
作者:
G
Gerd Hoffmann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
usb: add max_packet_size to USBEndpoint
Signed-off-by:
N
Gerd Hoffmann
<
kraxel@redhat.com
>
上级
5b6780d0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
44 addition
and
30 deletion
+44
-30
hw/usb-desc.c
hw/usb-desc.c
+2
-0
hw/usb.c
hw/usb.c
+33
-4
hw/usb.h
hw/usb.h
+4
-0
usb-linux.c
usb-linux.c
+5
-26
未找到文件。
hw/usb-desc.c
浏览文件 @
f003397c
...
...
@@ -248,6 +248,8 @@ static void usb_desc_ep_init(USBDevice *dev)
ep
=
iface
->
eps
[
e
].
bEndpointAddress
&
0x0f
;
usb_ep_set_type
(
dev
,
pid
,
ep
,
iface
->
eps
[
e
].
bmAttributes
&
0x03
);
usb_ep_set_ifnum
(
dev
,
pid
,
ep
,
iface
->
bInterfaceNumber
);
usb_ep_set_max_packet_size
(
dev
,
pid
,
ep
,
iface
->
eps
[
e
].
wMaxPacketSize
);
}
}
}
...
...
hw/usb.c
浏览文件 @
f003397c
...
...
@@ -449,8 +449,9 @@ void usb_ep_dump(USBDevice *dev)
fprintf
(
stderr
,
" Interface %d, alternative %d
\n
"
,
ifnum
,
dev
->
altsetting
[
ifnum
]);
}
fprintf
(
stderr
,
" Endpoint %d, IN, %s
\n
"
,
ep
,
tname
[
dev
->
ep_in
[
ep
].
type
]);
fprintf
(
stderr
,
" Endpoint %d, IN, %s, %d max
\n
"
,
ep
,
tname
[
dev
->
ep_in
[
ep
].
type
],
dev
->
ep_in
[
ep
].
max_packet_size
);
}
if
(
dev
->
ep_out
[
ep
].
type
!=
USB_ENDPOINT_XFER_INVALID
&&
dev
->
ep_out
[
ep
].
ifnum
==
ifnum
)
{
...
...
@@ -459,8 +460,9 @@ void usb_ep_dump(USBDevice *dev)
fprintf
(
stderr
,
" Interface %d, alternative %d
\n
"
,
ifnum
,
dev
->
altsetting
[
ifnum
]);
}
fprintf
(
stderr
,
" Endpoint %d, OUT, %s
\n
"
,
ep
,
tname
[
dev
->
ep_out
[
ep
].
type
]);
fprintf
(
stderr
,
" Endpoint %d, OUT, %s, %d max
\n
"
,
ep
,
tname
[
dev
->
ep_out
[
ep
].
type
],
dev
->
ep_out
[
ep
].
max_packet_size
);
}
}
}
...
...
@@ -498,3 +500,30 @@ void usb_ep_set_ifnum(USBDevice *dev, int pid, int ep, uint8_t ifnum)
struct
USBEndpoint
*
uep
=
usb_ep_get
(
dev
,
pid
,
ep
);
uep
->
ifnum
=
ifnum
;
}
void
usb_ep_set_max_packet_size
(
USBDevice
*
dev
,
int
pid
,
int
ep
,
uint16_t
raw
)
{
struct
USBEndpoint
*
uep
=
usb_ep_get
(
dev
,
pid
,
ep
);
int
size
,
microframes
;
size
=
raw
&
0x7ff
;
switch
((
raw
>>
11
)
&
3
)
{
case
1
:
microframes
=
2
;
break
;
case
2
:
microframes
=
3
;
break
;
default:
microframes
=
1
;
break
;
}
uep
->
max_packet_size
=
size
*
microframes
;
}
int
usb_ep_get_max_packet_size
(
USBDevice
*
dev
,
int
pid
,
int
ep
)
{
struct
USBEndpoint
*
uep
=
usb_ep_get
(
dev
,
pid
,
ep
);
return
uep
->
max_packet_size
;
}
hw/usb.h
浏览文件 @
f003397c
...
...
@@ -176,6 +176,7 @@ struct USBDescString {
struct
USBEndpoint
{
uint8_t
type
;
uint8_t
ifnum
;
int
max_packet_size
;
};
/* definition of a USB device */
...
...
@@ -339,6 +340,9 @@ uint8_t usb_ep_get_type(USBDevice *dev, int pid, int ep);
uint8_t
usb_ep_get_ifnum
(
USBDevice
*
dev
,
int
pid
,
int
ep
);
void
usb_ep_set_type
(
USBDevice
*
dev
,
int
pid
,
int
ep
,
uint8_t
type
);
void
usb_ep_set_ifnum
(
USBDevice
*
dev
,
int
pid
,
int
ep
,
uint8_t
ifnum
);
void
usb_ep_set_max_packet_size
(
USBDevice
*
dev
,
int
pid
,
int
ep
,
uint16_t
raw
);
int
usb_ep_get_max_packet_size
(
USBDevice
*
dev
,
int
pid
,
int
ep
);
void
usb_attach
(
USBPort
*
port
);
void
usb_detach
(
USBPort
*
port
);
...
...
usb-linux.c
浏览文件 @
f003397c
...
...
@@ -83,7 +83,6 @@ struct endp_data {
AsyncURB
*
iso_urb
;
int
iso_urb_idx
;
int
iso_buffer_used
;
int
max_packet_size
;
int
inflight
;
};
...
...
@@ -259,26 +258,6 @@ static int get_iso_buffer_used(USBHostDevice *s, int pid, int ep)
return
get_endp
(
s
,
pid
,
ep
)
->
iso_buffer_used
;
}
static
void
set_max_packet_size
(
USBHostDevice
*
s
,
int
pid
,
int
ep
,
uint8_t
*
descriptor
)
{
int
raw
=
descriptor
[
4
]
+
(
descriptor
[
5
]
<<
8
);
int
size
,
microframes
;
size
=
raw
&
0x7ff
;
switch
((
raw
>>
11
)
&
3
)
{
case
1
:
microframes
=
2
;
break
;
case
2
:
microframes
=
3
;
break
;
default:
microframes
=
1
;
break
;
}
get_endp
(
s
,
pid
,
ep
)
->
max_packet_size
=
size
*
microframes
;
}
static
int
get_max_packet_size
(
USBHostDevice
*
s
,
int
pid
,
int
ep
)
{
return
get_endp
(
s
,
pid
,
ep
)
->
max_packet_size
;
}
/*
* Async URB state.
* We always allocate iso packet descriptors even for bulk transfers
...
...
@@ -674,7 +653,7 @@ static void usb_host_handle_destroy(USBDevice *dev)
static
AsyncURB
*
usb_host_alloc_iso
(
USBHostDevice
*
s
,
int
pid
,
uint8_t
ep
)
{
AsyncURB
*
aurb
;
int
i
,
j
,
len
=
get_max_packet_size
(
s
,
pid
,
ep
);
int
i
,
j
,
len
=
usb_ep_get_max_packet_size
(
&
s
->
dev
,
pid
,
ep
);
aurb
=
g_malloc0
(
s
->
iso_urb_count
*
sizeof
(
*
aurb
));
for
(
i
=
0
;
i
<
s
->
iso_urb_count
;
i
++
)
{
...
...
@@ -754,7 +733,7 @@ static int usb_host_handle_iso_data(USBHostDevice *s, USBPacket *p, int in)
int
i
,
j
,
ret
,
max_packet_size
,
offset
,
len
=
0
;
uint8_t
*
buf
;
max_packet_size
=
get_max_packet_size
(
s
,
p
->
pid
,
p
->
devep
);
max_packet_size
=
usb_ep_get_max_packet_size
(
&
s
->
dev
,
p
->
pid
,
p
->
devep
);
if
(
max_packet_size
==
0
)
return
USB_RET_NAK
;
...
...
@@ -1133,6 +1112,7 @@ static int usb_linux_update_endp_table(USBHostDevice *s)
{
uint8_t
*
descriptors
;
uint8_t
devep
,
type
,
alt_interface
;
uint16_t
raw
;
int
interface
,
length
,
i
,
ep
,
pid
;
struct
endp_data
*
epd
;
...
...
@@ -1200,9 +1180,8 @@ static int usb_linux_update_endp_table(USBHostDevice *s)
}
type
=
descriptors
[
i
+
3
]
&
0x3
;
if
(
type
==
USB_ENDPOINT_XFER_ISOC
)
{
set_max_packet_size
(
s
,
pid
,
ep
,
descriptors
+
i
);
};
raw
=
descriptors
[
i
+
4
]
+
(
descriptors
[
i
+
5
]
<<
8
);
usb_ep_set_max_packet_size
(
&
s
->
dev
,
pid
,
ep
,
raw
);
assert
(
usb_ep_get_type
(
&
s
->
dev
,
pid
,
ep
)
==
USB_ENDPOINT_XFER_INVALID
);
usb_ep_set_type
(
&
s
->
dev
,
pid
,
ep
,
type
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录