aboutsummaryrefslogtreecommitdiffstats
path: root/tools/usb
diff options
context:
space:
mode:
authorRobert Baldyga <r.baldyga@samsung.com>2015-01-13 08:56:28 -0500
committerFelipe Balbi <balbi@ti.com>2015-01-15 10:41:49 -0500
commit969678c09877fd1116be6ae304e59a27658226c2 (patch)
treee3320cc560031774e2e17c86e8af3e2849b305e4 /tools/usb
parentfc12c68b4ff2904c3322b7a12089f0b9808e2383 (diff)
tools: ffs-aio-example: use endpoint addresses from descriptors
This makes examples more platform independent and more compatible with USB standard, as endpoint addresses in given interface may differ between hardware platforms or even between configurations in single USB device. Signed-off-by: Robert Baldyga <r.baldyga@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'tools/usb')
-rw-r--r--tools/usb/ffs-aio-example/multibuff/host_app/test.c14
-rw-r--r--tools/usb/ffs-aio-example/simple/host_app/test.c17
2 files changed, 18 insertions, 13 deletions
diff --git a/tools/usb/ffs-aio-example/multibuff/host_app/test.c b/tools/usb/ffs-aio-example/multibuff/host_app/test.c
index daa3abe6bebd..2cbcce6e8dd7 100644
--- a/tools/usb/ffs-aio-example/multibuff/host_app/test.c
+++ b/tools/usb/ffs-aio-example/multibuff/host_app/test.c
@@ -33,11 +33,6 @@
33#define VENDOR 0x1d6b 33#define VENDOR 0x1d6b
34#define PRODUCT 0x0105 34#define PRODUCT 0x0105
35 35
36/* endpoints indexes */
37
38#define EP_BULK_IN (1 | LIBUSB_ENDPOINT_IN)
39#define EP_BULK_OUT (2 | LIBUSB_ENDPOINT_OUT)
40
41#define BUF_LEN 8192 36#define BUF_LEN 8192
42 37
43/* 38/*
@@ -159,14 +154,21 @@ void test_exit(struct test_state *state)
159int main(void) 154int main(void)
160{ 155{
161 struct test_state state; 156 struct test_state state;
157 struct libusb_config_descriptor *conf;
158 struct libusb_interface_descriptor const *iface;
159 unsigned char addr;
162 160
163 if (test_init(&state)) 161 if (test_init(&state))
164 return 1; 162 return 1;
165 163
164 libusb_get_config_descriptor(state.found, 0, &conf);
165 iface = &conf->interface[0].altsetting[0];
166 addr = iface->endpoint[0].bEndpointAddress;
167
166 while (1) { 168 while (1) {
167 static unsigned char buffer[BUF_LEN]; 169 static unsigned char buffer[BUF_LEN];
168 int bytes; 170 int bytes;
169 libusb_bulk_transfer(state.handle, EP_BULK_IN, buffer, BUF_LEN, 171 libusb_bulk_transfer(state.handle, addr, buffer, BUF_LEN,
170 &bytes, 500); 172 &bytes, 500);
171 } 173 }
172 test_exit(&state); 174 test_exit(&state);
diff --git a/tools/usb/ffs-aio-example/simple/host_app/test.c b/tools/usb/ffs-aio-example/simple/host_app/test.c
index acd6332811f3..aed86ffff280 100644
--- a/tools/usb/ffs-aio-example/simple/host_app/test.c
+++ b/tools/usb/ffs-aio-example/simple/host_app/test.c
@@ -33,11 +33,6 @@
33#define VENDOR 0x1d6b 33#define VENDOR 0x1d6b
34#define PRODUCT 0x0105 34#define PRODUCT 0x0105
35 35
36/* endpoints indexes */
37
38#define EP_BULK_IN (1 | LIBUSB_ENDPOINT_IN)
39#define EP_BULK_OUT (2 | LIBUSB_ENDPOINT_OUT)
40
41#define BUF_LEN 8192 36#define BUF_LEN 8192
42 37
43/* 38/*
@@ -159,16 +154,24 @@ void test_exit(struct test_state *state)
159int main(void) 154int main(void)
160{ 155{
161 struct test_state state; 156 struct test_state state;
157 struct libusb_config_descriptor *conf;
158 struct libusb_interface_descriptor const *iface;
159 unsigned char in_addr, out_addr;
162 160
163 if (test_init(&state)) 161 if (test_init(&state))
164 return 1; 162 return 1;
165 163
164 libusb_get_config_descriptor(state.found, 0, &conf);
165 iface = &conf->interface[0].altsetting[0];
166 in_addr = iface->endpoint[0].bEndpointAddress;
167 out_addr = iface->endpoint[1].bEndpointAddress;
168
166 while (1) { 169 while (1) {
167 static unsigned char buffer[BUF_LEN]; 170 static unsigned char buffer[BUF_LEN];
168 int bytes; 171 int bytes;
169 libusb_bulk_transfer(state.handle, EP_BULK_IN, buffer, BUF_LEN, 172 libusb_bulk_transfer(state.handle, in_addr, buffer, BUF_LEN,
170 &bytes, 500); 173 &bytes, 500);
171 libusb_bulk_transfer(state.handle, EP_BULK_OUT, buffer, BUF_LEN, 174 libusb_bulk_transfer(state.handle, out_addr, buffer, BUF_LEN,
172 &bytes, 500); 175 &bytes, 500);
173 } 176 }
174 test_exit(&state); 177 test_exit(&state);