summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2009-04-18 20:40:50 +0000
committerFrank Gevaerts <frank@gevaerts.be>2009-04-18 20:40:50 +0000
commit3314f389baf54e74e3c52c069f8e829a701b2b94 (patch)
tree7407217cc1f7456999c653f610c44a9fab1bb6e1
parent2c0da9d15205b425276d769b4d5f1275bd6ea954 (diff)
downloadrockbox-3314f389baf54e74e3c52c069f8e829a701b2b94.tar.gz
rockbox-3314f389baf54e74e3c52c069f8e829a701b2b94.zip
Allow class drivers to reuse the core data buffer for control transfers. This doesn't make much difference right now, but it should keep HID memory usage lower (once HID is ready) (FS#10146 by Tomer Shalev)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20735 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/usbstack/usb_class_driver.h2
-rw-r--r--firmware/usbstack/usb_core.c10
-rw-r--r--firmware/usbstack/usb_serial.c4
-rw-r--r--firmware/usbstack/usb_serial.h2
-rw-r--r--firmware/usbstack/usb_storage.c4
-rw-r--r--firmware/usbstack/usb_storage.h2
6 files changed, 14 insertions, 10 deletions
diff --git a/firmware/usbstack/usb_class_driver.h b/firmware/usbstack/usb_class_driver.h
index b51eb3e93f..36f2ea9e3d 100644
--- a/firmware/usbstack/usb_class_driver.h
+++ b/firmware/usbstack/usb_class_driver.h
@@ -75,7 +75,7 @@ struct usb_class_driver {
75 able to handle it, it should ack the request, and return true. Otherwise 75 able to handle it, it should ack the request, and return true. Otherwise
76 it should return false. 76 it should return false.
77 Optional function */ 77 Optional function */
78 bool (*control_request)(struct usb_ctrlrequest* req); 78 bool (*control_request)(struct usb_ctrlrequest* req, unsigned char *dest);
79 79
80#ifdef HAVE_HOTSWAP 80#ifdef HAVE_HOTSWAP
81 /* Tells the driver that a hotswappable disk/card was inserted or 81 /* Tells the driver that a hotswappable disk/card was inserted or
diff --git a/firmware/usbstack/usb_core.c b/firmware/usbstack/usb_core.c
index 737ac1ac0c..3f67407c72 100644
--- a/firmware/usbstack/usb_core.c
+++ b/firmware/usbstack/usb_core.c
@@ -168,7 +168,7 @@ static enum { DEFAULT, ADDRESS, CONFIGURED } usb_state;
168static int usb_core_num_interfaces; 168static int usb_core_num_interfaces;
169 169
170typedef void (*completion_handler_t)(int ep,int dir, int status, int length); 170typedef void (*completion_handler_t)(int ep,int dir, int status, int length);
171typedef bool (*control_handler_t)(struct usb_ctrlrequest* req); 171typedef bool (*control_handler_t)(struct usb_ctrlrequest* req, unsigned char *dest);
172 172
173static struct 173static struct
174{ 174{
@@ -695,7 +695,7 @@ static void usb_core_control_request_handler(struct usb_ctrlrequest* req)
695 drivers[i].first_interface <= (req->wIndex) && 695 drivers[i].first_interface <= (req->wIndex) &&
696 drivers[i].last_interface > (req->wIndex)) 696 drivers[i].last_interface > (req->wIndex))
697 { 697 {
698 handled = drivers[i].control_request(req); 698 handled = drivers[i].control_request(req, response_data);
699 } 699 }
700 } 700 }
701 if(!handled) { 701 if(!handled) {
@@ -735,8 +735,10 @@ static void usb_core_control_request_handler(struct usb_ctrlrequest* req)
735 break; 735 break;
736 default: { 736 default: {
737 bool handled=false; 737 bool handled=false;
738 if(ep_data[req->wIndex & 0xf].control_handler[0] != NULL) 738 if(ep_data[req->wIndex & 0xf].control_handler[0] != NULL) {
739 handled = ep_data[req->wIndex & 0xf].control_handler[0](req); 739 handled = ep_data[req->wIndex & 0xf].control_handler[0](req,
740 response_data);
741 }
740 if(!handled) { 742 if(!handled) {
741 /* nope. flag error */ 743 /* nope. flag error */
742 logf("usb bad req %d", req->bRequest); 744 logf("usb bad req %d", req->bRequest);
diff --git a/firmware/usbstack/usb_serial.c b/firmware/usbstack/usb_serial.c
index 514df0dc2b..520a4b3370 100644
--- a/firmware/usbstack/usb_serial.c
+++ b/firmware/usbstack/usb_serial.c
@@ -117,9 +117,11 @@ int usb_serial_get_config_descriptor(unsigned char *dest,int max_packet_size)
117} 117}
118 118
119/* called by usb_core_control_request() */ 119/* called by usb_core_control_request() */
120bool usb_serial_control_request(struct usb_ctrlrequest* req) 120bool usb_serial_control_request(struct usb_ctrlrequest* req, unsigned char* dest)
121{ 121{
122 bool handled = false; 122 bool handled = false;
123
124 (void)dest;
123 switch (req->bRequest) { 125 switch (req->bRequest) {
124 default: 126 default:
125 logf("serial: unhandeld req %d", req->bRequest); 127 logf("serial: unhandeld req %d", req->bRequest);
diff --git a/firmware/usbstack/usb_serial.h b/firmware/usbstack/usb_serial.h
index 94decdc42b..2701a96cd3 100644
--- a/firmware/usbstack/usb_serial.h
+++ b/firmware/usbstack/usb_serial.h
@@ -30,7 +30,7 @@ void usb_serial_init_connection(void);
30void usb_serial_init(void); 30void usb_serial_init(void);
31void usb_serial_disconnect(void); 31void usb_serial_disconnect(void);
32void usb_serial_transfer_complete(int ep,int dir, int status, int length); 32void usb_serial_transfer_complete(int ep,int dir, int status, int length);
33bool usb_serial_control_request(struct usb_ctrlrequest* req); 33bool usb_serial_control_request(struct usb_ctrlrequest* req, unsigned char *dest);
34 34
35void usb_serial_send(unsigned char *data,int length); 35void usb_serial_send(unsigned char *data,int length);
36 36
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c
index 2a3808dd92..be785da321 100644
--- a/firmware/usbstack/usb_storage.c
+++ b/firmware/usbstack/usb_storage.c
@@ -593,11 +593,11 @@ void usb_storage_transfer_complete(int ep,int dir,int status,int length)
593} 593}
594 594
595/* called by usb_core_control_request() */ 595/* called by usb_core_control_request() */
596bool usb_storage_control_request(struct usb_ctrlrequest* req) 596bool usb_storage_control_request(struct usb_ctrlrequest* req, unsigned char* dest)
597{ 597{
598 bool handled = false; 598 bool handled = false;
599 599
600 600 (void)dest;
601 switch (req->bRequest) { 601 switch (req->bRequest) {
602 case USB_BULK_GET_MAX_LUN: { 602 case USB_BULK_GET_MAX_LUN: {
603#ifdef ONLY_EXPOSE_CARD_SLOT 603#ifdef ONLY_EXPOSE_CARD_SLOT
diff --git a/firmware/usbstack/usb_storage.h b/firmware/usbstack/usb_storage.h
index c76cb898bb..3591d285d8 100644
--- a/firmware/usbstack/usb_storage.h
+++ b/firmware/usbstack/usb_storage.h
@@ -30,7 +30,7 @@ void usb_storage_init_connection(void);
30void usb_storage_disconnect(void); 30void usb_storage_disconnect(void);
31void usb_storage_init(void); 31void usb_storage_init(void);
32void usb_storage_transfer_complete(int ep,int dir,int state,int length); 32void usb_storage_transfer_complete(int ep,int dir,int state,int length);
33bool usb_storage_control_request(struct usb_ctrlrequest* req); 33bool usb_storage_control_request(struct usb_ctrlrequest* req, unsigned char* dest);
34#ifdef HAVE_HOTSWAP 34#ifdef HAVE_HOTSWAP
35void usb_storage_notify_hotswap(int volume,bool inserted); 35void usb_storage_notify_hotswap(int volume,bool inserted);
36#endif 36#endif