diff options
-rw-r--r-- | firmware/export/usb_drv.h | 7 | ||||
-rw-r--r-- | firmware/usbstack/usb_core.c | 29 | ||||
-rw-r--r-- | utils/hwstub/stub/main.c | 26 | ||||
-rw-r--r-- | utils/hwstub/stub/usb_drv.h | 7 |
4 files changed, 22 insertions, 47 deletions
diff --git a/firmware/export/usb_drv.h b/firmware/export/usb_drv.h index b5b5a7f065..7ef7c8b7ee 100644 --- a/firmware/export/usb_drv.h +++ b/firmware/export/usb_drv.h | |||
@@ -80,4 +80,11 @@ bool usb_drv_connected(void); | |||
80 | int usb_drv_request_endpoint(int type, int dir); | 80 | int usb_drv_request_endpoint(int type, int dir); |
81 | void usb_drv_release_endpoint(int ep); | 81 | void usb_drv_release_endpoint(int ep); |
82 | 82 | ||
83 | /* USB_STRING_INITIALIZER(u"Example String") */ | ||
84 | #define USB_STRING_INITIALIZER(S) { \ | ||
85 | sizeof(struct usb_string_descriptor) + sizeof(S) - sizeof(*S), \ | ||
86 | USB_DT_STRING, \ | ||
87 | S \ | ||
88 | } | ||
89 | |||
83 | #endif /* _USB_DRV_H */ | 90 | #endif /* _USB_DRV_H */ |
diff --git a/firmware/usbstack/usb_core.c b/firmware/usbstack/usb_core.c index 038aef241f..3d187c8cab 100644 --- a/firmware/usbstack/usb_core.c +++ b/firmware/usbstack/usb_core.c | |||
@@ -120,43 +120,22 @@ static const struct usb_qualifier_descriptor __attribute__((aligned(2))) | |||
120 | 120 | ||
121 | static const struct usb_string_descriptor __attribute__((aligned(2))) | 121 | static const struct usb_string_descriptor __attribute__((aligned(2))) |
122 | usb_string_iManufacturer = | 122 | usb_string_iManufacturer = |
123 | { | 123 | USB_STRING_INITIALIZER(u"Rockbox.org"); |
124 | 24, | ||
125 | USB_DT_STRING, | ||
126 | {'R', 'o', 'c', 'k', 'b', 'o', 'x', '.', 'o', 'r', 'g'} | ||
127 | }; | ||
128 | 124 | ||
129 | static const struct usb_string_descriptor __attribute__((aligned(2))) | 125 | static const struct usb_string_descriptor __attribute__((aligned(2))) |
130 | usb_string_iProduct = | 126 | usb_string_iProduct = |
131 | { | 127 | USB_STRING_INITIALIZER(u"Rockbox media player"); |
132 | 42, | ||
133 | USB_DT_STRING, | ||
134 | {'R', 'o', 'c', 'k', 'b', 'o', 'x', ' ', | ||
135 | 'm', 'e', 'd', 'i', 'a', ' ', | ||
136 | 'p', 'l', 'a', 'y', 'e', 'r'} | ||
137 | }; | ||
138 | 128 | ||
139 | static struct usb_string_descriptor __attribute__((aligned(2))) | 129 | static struct usb_string_descriptor __attribute__((aligned(2))) |
140 | usb_string_iSerial = | 130 | usb_string_iSerial = |
141 | { | 131 | USB_STRING_INITIALIZER(u"00000000000000000000000000000000000000000"); |
142 | 84, | ||
143 | USB_DT_STRING, | ||
144 | {'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', | ||
145 | '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', | ||
146 | '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', | ||
147 | '0', '0', '0', '0', '0', '0', '0', '0'} | ||
148 | }; | ||
149 | 132 | ||
150 | /* Generic for all targets */ | 133 | /* Generic for all targets */ |
151 | 134 | ||
152 | /* this is stringid #0: languages supported */ | 135 | /* this is stringid #0: languages supported */ |
153 | static const struct usb_string_descriptor __attribute__((aligned(2))) | 136 | static const struct usb_string_descriptor __attribute__((aligned(2))) |
154 | lang_descriptor = | 137 | lang_descriptor = |
155 | { | 138 | USB_STRING_INITIALIZER(u"\x0409"); /* LANGID US English */ |
156 | 4, | ||
157 | USB_DT_STRING, | ||
158 | {0x0409} /* LANGID US English */ | ||
159 | }; | ||
160 | 139 | ||
161 | static const struct usb_string_descriptor* const usb_strings[] = | 140 | static const struct usb_string_descriptor* const usb_strings[] = |
162 | { | 141 | { |
diff --git a/utils/hwstub/stub/main.c b/utils/hwstub/stub/main.c index 7b6b02b83a..9e2e7116df 100644 --- a/utils/hwstub/stub/main.c +++ b/utils/hwstub/stub/main.c | |||
@@ -95,35 +95,17 @@ static struct usb_interface_descriptor interface_descriptor = | |||
95 | }; | 95 | }; |
96 | 96 | ||
97 | static const struct usb_string_descriptor usb_string_iManufacturer = | 97 | static const struct usb_string_descriptor usb_string_iManufacturer = |
98 | { | 98 | USB_STRING_INITIALIZER(u"Rockbox.org"); |
99 | 24, | ||
100 | USB_DT_STRING, | ||
101 | {'R', 'o', 'c', 'k', 'b', 'o', 'x', '.', 'o', 'r', 'g'} | ||
102 | }; | ||
103 | 99 | ||
104 | static const struct usb_string_descriptor usb_string_iProduct = | 100 | static const struct usb_string_descriptor usb_string_iProduct = |
105 | { | 101 | USB_STRING_INITIALIZER(u"Rockbox hardware stub"); |
106 | 44, | ||
107 | USB_DT_STRING, | ||
108 | {'R', 'o', 'c', 'k', 'b', 'o', 'x', ' ', | ||
109 | 'h', 'a', 'r', 'd', 'w', 'a', 'r', 'e', ' ', | ||
110 | 's', 't', 'u', 'b'} | ||
111 | }; | ||
112 | 102 | ||
113 | static const struct usb_string_descriptor usb_string_iInterface = | 103 | static const struct usb_string_descriptor usb_string_iInterface = |
114 | { | 104 | USB_STRING_INITIALIZER(u"HWStub"); |
115 | 14, | ||
116 | USB_DT_STRING, | ||
117 | {'H', 'W', 'S', 't', 'u', 'b'} | ||
118 | }; | ||
119 | 105 | ||
120 | /* this is stringid #0: languages supported */ | 106 | /* this is stringid #0: languages supported */ |
121 | static const struct usb_string_descriptor lang_descriptor = | 107 | static const struct usb_string_descriptor lang_descriptor = |
122 | { | 108 | USB_STRING_INITIALIZER(u"\x0409"); /* LANGID US English */ |
123 | 4, | ||
124 | USB_DT_STRING, | ||
125 | {0x0409} /* LANGID US English */ | ||
126 | }; | ||
127 | 109 | ||
128 | static struct hwstub_version_desc_t version_descriptor = | 110 | static struct hwstub_version_desc_t version_descriptor = |
129 | { | 111 | { |
diff --git a/utils/hwstub/stub/usb_drv.h b/utils/hwstub/stub/usb_drv.h index 00f22d8e1a..ef032f52a3 100644 --- a/utils/hwstub/stub/usb_drv.h +++ b/utils/hwstub/stub/usb_drv.h | |||
@@ -43,5 +43,12 @@ void usb_drv_set_address(int address); | |||
43 | int usb_drv_port_speed(void); | 43 | int usb_drv_port_speed(void); |
44 | void usb_drv_configure_endpoint(int ep_num, int type); | 44 | void usb_drv_configure_endpoint(int ep_num, int type); |
45 | 45 | ||
46 | /* USB_STRING_INITIALIZER(u"Example String") */ | ||
47 | #define USB_STRING_INITIALIZER(S) { \ | ||
48 | sizeof(struct usb_string_descriptor) + sizeof(S) - sizeof(*S), \ | ||
49 | USB_DT_STRING, \ | ||
50 | S \ | ||
51 | } | ||
52 | |||
46 | #endif /* _USB_DRV_H */ | 53 | #endif /* _USB_DRV_H */ |
47 | 54 | ||