summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2008-03-04 12:08:00 +0000
committerFrank Gevaerts <frank@gevaerts.be>2008-03-04 12:08:00 +0000
commit52df7addcf3d60b4955b0ce8bfc8955e4d33b933 (patch)
treeb604f43565b6bfc8dadc626ca082231a30f04602 /firmware
parent4fe9d7c2cdec63b5fd498af3574d16b6b852e470 (diff)
downloadrockbox-52df7addcf3d60b4955b0ce8bfc8955e4d33b933.tar.gz
rockbox-52df7addcf3d60b4955b0ce8bfc8955e4d33b933.zip
present a different USB serial number depending on which USB class drivers are enabled. This is needed for Windows to correctly detect the device if a different set of drivers is active than on the previous plugin
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16511 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/usbstack/usb_core.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/firmware/usbstack/usb_core.c b/firmware/usbstack/usb_core.c
index a46310b4cb..883d3d6dfb 100644
--- a/firmware/usbstack/usb_core.c
+++ b/firmware/usbstack/usb_core.c
@@ -201,11 +201,11 @@ static struct usb_string_descriptor __attribute__((aligned(2))) usb_string_iProd
201 201
202static struct usb_string_descriptor __attribute__((aligned(2))) usb_string_iSerial = 202static struct usb_string_descriptor __attribute__((aligned(2))) usb_string_iSerial =
203{ 203{
204 82, 204 84,
205 USB_DT_STRING, 205 USB_DT_STRING,
206 {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0', 206 {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0',
207 '0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0', 207 '0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0',
208 '0','0','0','0','0','0','0','0'} 208 '0','0','0','0','0','0','0','0','0'}
209}; 209};
210 210
211/* Generic for all targets */ 211/* Generic for all targets */
@@ -255,11 +255,11 @@ static unsigned char __response_data[CACHEALIGN_UP(256)] CACHEALIGN_ATTR;
255 255
256static struct usb_transfer_completion_event_data events[NUM_ENDPOINTS]; 256static struct usb_transfer_completion_event_data events[NUM_ENDPOINTS];
257 257
258static short hex[16] = {'0','1','2','3','4','5','6','7',
259 '8','9','A','B','C','D','E','F'};
258#ifdef IPOD_ARCH 260#ifdef IPOD_ARCH
259static void set_serial_descriptor(void) 261static void set_serial_descriptor(void)
260{ 262{
261 static short hex[16] = {'0','1','2','3','4','5','6','7',
262 '8','9','A','B','C','D','E','F'};
263#ifdef IPOD_VIDEO 263#ifdef IPOD_VIDEO
264 uint32_t* serial = (uint32_t*)(0x20004034); 264 uint32_t* serial = (uint32_t*)(0x20004034);
265#else 265#else
@@ -268,7 +268,7 @@ static void set_serial_descriptor(void)
268 268
269 /* We need to convert from a little-endian 64-bit int 269 /* We need to convert from a little-endian 64-bit int
270 into a utf-16 string of hex characters */ 270 into a utf-16 string of hex characters */
271 short* p = &usb_string_iSerial.wString[23]; 271 short* p = &usb_string_iSerial.wString[24];
272 uint32_t x; 272 uint32_t x;
273 int i,j; 273 int i,j;
274 274
@@ -281,17 +281,14 @@ static void set_serial_descriptor(void)
281 x >>= 4; 281 x >>= 4;
282 } 282 }
283 } 283 }
284 usb_string_iSerial.bLength=50; 284 usb_string_iSerial.bLength=52;
285} 285}
286#elif defined(HAVE_AS3514) 286#elif defined(HAVE_AS3514)
287static void set_serial_descriptor(void) 287static void set_serial_descriptor(void)
288{ 288{
289 static short hex[16] = {'0','1','2','3','4','5','6','7',
290 '8','9','A','B','C','D','E','F'};
291
292 unsigned char serial[16]; 289 unsigned char serial[16];
293 /* Align 32 digits right in the 40-digit serial number */ 290 /* Align 32 digits right in the 40-digit serial number */
294 short* p = usb_string_iSerial.wString; 291 short* p = &usb_string_iSerial.wString[1];
295 int i; 292 int i;
296 293
297 i2c_readbytes(AS3514_I2C_ADDR, 0x30, 0x10, serial); 294 i2c_readbytes(AS3514_I2C_ADDR, 0x30, 0x10, serial);
@@ -300,17 +297,14 @@ static void set_serial_descriptor(void)
300 *p++ = hex[(serial[i] >> 4) & 0xF]; 297 *p++ = hex[(serial[i] >> 4) & 0xF];
301 *p++ = hex[(serial[i] >> 0) & 0xF]; 298 *p++ = hex[(serial[i] >> 0) & 0xF];
302 } 299 }
303 usb_string_iSerial.bLength=66; 300 usb_string_iSerial.bLength=68;
304} 301}
305#else 302#else
306/* If we don't know the device serial number, use the one 303/* If we don't know the device serial number, use the one
307 * from the disk */ 304 * from the disk */
308static void set_serial_descriptor(void) 305static void set_serial_descriptor(void)
309{ 306{
310 static short hex[16] = {'0','1','2','3','4','5','6','7', 307 short* p = &usb_string_iSerial.wString[1];
311 '8','9','A','B','C','D','E','F'};
312
313 short* p = usb_string_iSerial.wString;
314 unsigned short* identify = ata_get_identify(); 308 unsigned short* identify = ata_get_identify();
315 unsigned short x; 309 unsigned short x;
316 int i; 310 int i;
@@ -323,7 +317,7 @@ static void set_serial_descriptor(void)
323 *p++ = hex[(x >> 4) & 0xF]; 317 *p++ = hex[(x >> 4) & 0xF];
324 *p++ = hex[(x >> 0) & 0xF]; 318 *p++ = hex[(x >> 0) & 0xF];
325 } 319 }
326 usb_string_iSerial.bLength=82; 320 usb_string_iSerial.bLength=84;
327} 321}
328#endif 322#endif
329 323
@@ -417,10 +411,19 @@ static void usb_core_control_request_handler(struct usb_ctrlrequest* req)
417{ 411{
418 if(usb_state == DEFAULT) { 412 if(usb_state == DEFAULT) {
419 set_serial_descriptor(); 413 set_serial_descriptor();
414
415 int serial_function_id = 0;
420#ifdef USB_STORAGE 416#ifdef USB_STORAGE
421 if(usb_core_storage_enabled) 417 if(usb_core_storage_enabled) {
422 usb_request_exclusive_ata(); 418 usb_request_exclusive_ata();
419 serial_function_id |= 1;
420 }
421#endif
422#ifdef USB_SERIAL
423 if(usb_core_serial_enabled)
424 serial_function_id |= 2;
423#endif 425#endif
426 usb_string_iSerial.wString[0] = hex[serial_function_id];
424 } 427 }
425 428
426 switch (req->bRequest) { 429 switch (req->bRequest) {