diff options
Diffstat (limited to 'firmware/usbstack/drivers/device/usb_storage.c')
-rw-r--r-- | firmware/usbstack/drivers/device/usb_storage.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/firmware/usbstack/drivers/device/usb_storage.c b/firmware/usbstack/drivers/device/usb_storage.c index 49644e5805..45fd5c14b7 100644 --- a/firmware/usbstack/drivers/device/usb_storage.c +++ b/firmware/usbstack/drivers/device/usb_storage.c | |||
@@ -46,6 +46,21 @@ struct usb_device_driver usb_storage_driver = { | |||
46 | /*-------------------------------------------------------------------------*/ | 46 | /*-------------------------------------------------------------------------*/ |
47 | /* usb descriptors */ | 47 | /* usb descriptors */ |
48 | 48 | ||
49 | #define MANUFACTURER_STR_ID 1 | ||
50 | #define PRODUCT_STR_ID 2 | ||
51 | #define SERIAL_STR_ID 3 | ||
52 | #define CONFIG_STR_ID 4 | ||
53 | #define DATA_STR_ID 5 | ||
54 | |||
55 | /* static strings, in UTF-8 */ | ||
56 | static struct usb_string strings[] = { | ||
57 | { MANUFACTURER_STR_ID, "RockBox" }, | ||
58 | { PRODUCT_STR_ID, "RockBox Storage Driver" }, | ||
59 | { SERIAL_STR_ID, "0" }, | ||
60 | { CONFIG_STR_ID, "Storage Bulk" }, | ||
61 | { DATA_STR_ID, "Storage Data" }, | ||
62 | }; | ||
63 | |||
49 | static struct usb_device_descriptor storage_device_desc = { | 64 | static struct usb_device_descriptor storage_device_desc = { |
50 | .bLength = USB_DT_DEVICE_SIZE, | 65 | .bLength = USB_DT_DEVICE_SIZE, |
51 | .bDescriptorType = USB_DT_DEVICE, | 66 | .bDescriptorType = USB_DT_DEVICE, |
@@ -55,9 +70,9 @@ static struct usb_device_descriptor storage_device_desc = { | |||
55 | .bDeviceProtocol = 0, | 70 | .bDeviceProtocol = 0, |
56 | .idVendor = 0xffff, | 71 | .idVendor = 0xffff, |
57 | .idProduct = 0x0001, | 72 | .idProduct = 0x0001, |
58 | .iManufacturer = 0, | 73 | .iManufacturer = MANUFACTURER_STR_ID, |
59 | .iProduct = 0, | 74 | .iProduct = PRODUCT_STR_ID, |
60 | .iSerialNumber = 0, | 75 | .iSerialNumber = SERIAL_STR_ID, |
61 | .bNumConfigurations = 1, | 76 | .bNumConfigurations = 1, |
62 | }; | 77 | }; |
63 | 78 | ||
@@ -67,7 +82,7 @@ static struct usb_config_descriptor storage_config_desc = { | |||
67 | 82 | ||
68 | .bNumInterfaces = 1, | 83 | .bNumInterfaces = 1, |
69 | .bConfigurationValue = 1, | 84 | .bConfigurationValue = 1, |
70 | .iConfiguration = 0, | 85 | .iConfiguration = CONFIG_STR_ID, |
71 | .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, | 86 | .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, |
72 | .bMaxPower = 1, | 87 | .bMaxPower = 1, |
73 | }; | 88 | }; |
@@ -80,7 +95,7 @@ static struct usb_interface_descriptor storage_interface_desc = { | |||
80 | .bInterfaceClass = USB_CLASS_MASS_STORAGE, | 95 | .bInterfaceClass = USB_CLASS_MASS_STORAGE, |
81 | .bInterfaceSubClass = SUBCL_SCSI, | 96 | .bInterfaceSubClass = SUBCL_SCSI, |
82 | .bInterfaceProtocol = PROTO_BULK, | 97 | .bInterfaceProtocol = PROTO_BULK, |
83 | .iInterface = 0, | 98 | .iInterface = DATA_STR_ID, |
84 | }; | 99 | }; |
85 | 100 | ||
86 | static struct usb_endpoint_descriptor storage_fs_bulk_in_desc = { | 101 | static struct usb_endpoint_descriptor storage_fs_bulk_in_desc = { |
@@ -246,6 +261,13 @@ int usb_storage_driver_request(struct usb_ctrlrequest* request) | |||
246 | } | 261 | } |
247 | res.buf = buf; | 262 | res.buf = buf; |
248 | break; | 263 | break; |
264 | |||
265 | case USB_DT_STRING: | ||
266 | logf("usb storage: sending string desc"); | ||
267 | ret = usb_stack_get_string(strings, request->wValue & 0xff, buf); | ||
268 | ret = MIN(ret, request->wLength); | ||
269 | res.buf = buf; | ||
270 | break; | ||
249 | } | 271 | } |
250 | break; | 272 | break; |
251 | 273 | ||