From: Bernhard Urban Date: Tue, 22 Sep 2009 08:08:47 +0000 (+0200) Subject: m00h @ previous commit: using wTotalLenght of CONFIGURATION you get X-Git-Tag: demo0~16 X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=ppcskel.git;a=commitdiff_plain;h=331464e8015d87543fc89b3417ad75cb2710411f m00h @ previous commit: using wTotalLenght of CONFIGURATION you get CONFIGURATION, INTERFACE(s) and ENDPOINT(s) in one big request. WIP --- diff --git a/usb/core/core.c b/usb/core/core.c index 5583c75..b575315 100644 --- a/usb/core/core.c +++ b/usb/core/core.c @@ -110,7 +110,7 @@ struct usb_device *usb_add_device() memset(buf, 0, sizeof(buf)); ret = usb_get_desc_dev_simple(dev, buf, sizeof(buf)); #ifdef _DU_CORE_ADD - printf("=============\nbuf: 0x%08X\nafter usb_get_dev_desc_simple(ret: %d):\n", buf, ret); + printf("=============\nafter usb_get_dev_desc_simple(ret: %d):\n", ret); hexdump(buf, sizeof(buf)); #endif if(ret < 0) { @@ -129,7 +129,7 @@ struct usb_device *usb_add_device() memset(buf, 0, sizeof(buf)); ret = usb_get_desc_dev(dev, buf, sizeof(buf)); #ifdef _DU_CORE_ADD - printf("=============\nbuf: 0x%08X\nafter usb_get_dev_desc(ret: %d):\n", buf, ret); + printf("=============\nafter usb_get_dev_desc(ret: %d):\n", ret); hexdump(buf, sizeof(buf)); #endif @@ -183,17 +183,30 @@ struct usb_device *usb_add_device() memset(buf, 0, sizeof(buf)); /* in the most cases usb devices have just one configuration descriptor */ ret = usb_get_desc_configuration(dev, 0, buf, sizeof(buf)); - printf("=============\nbuf: 0x%08X\nafter usb_get_desc_configuration(ret: %d):\n", buf, ret); + printf("=============\nafter usb_get_desc_configuration(ret: %d):\n", ret); hexdump(buf, sizeof(buf)); - printf("interfaces: %d\n", dev->conf->bNumInterfaces); + memset(buf, 0, sizeof(buf)); + ret = usb_get_descriptor(dev, CONFIGURATION, 0, buf, dev->conf->wTotalLength); + printf("=============\nafter usb_get_HACK(ret: %d):\n", ret); + hexdump(buf, sizeof(buf)); + + /* select configuration */ + ret = usb_set_configuration(dev, dev->conf->bConfigurationValue); + printf("=============\nusb_set_configuration(ret: %d) %d\n", ret, dev->conf->bConfigurationValue); + + /* + udelay(600000); + + printf("=============\ninterfaces: %d\n", dev->conf->bNumInterfaces); u8 i; for(i = 1; i <= dev->conf->bNumInterfaces; i++) { memset(buf, 0, sizeof(buf)); - ret = usb_get_desc_interface(dev, i, buf, sizeof(buf)); - printf("=============\nbuf: 0x%08X\nafter usb_get_desc_interface_%d(ret: %d):\n", buf, i, ret); + ret = usb_get_desc_interface(dev, 1, buf, sizeof(buf)); + printf("=============\nafter usb_get_desc_interface_%d(ret: %d):\n", i, ret); hexdump(buf, sizeof(buf)); } + */ diff --git a/usb/core/usb.c b/usb/core/usb.c index 94676d3..9511067 100644 --- a/usb/core/usb.c +++ b/usb/core/usb.c @@ -234,8 +234,7 @@ s8 usb_get_desc_interface(struct usb_device *dev, u8 index, u8 *buf, u8 size) if(size < 9) { return -1; } - usb_get_descriptor(dev, INTERFACE, index, buf, 8); - usb_get_descriptor(dev, INTERFACE, index, buf, size >= buf[0] ? buf[0] : size); + usb_get_descriptor(dev, INTERFACE, index, buf, 9); return 0; } @@ -249,7 +248,8 @@ s8 usb_set_address(struct usb_device *dev, u8 address) s8 usb_set_configuration(struct usb_device *dev, u8 configuration) { - + u8 buf[64]; + usb_control_msg(dev, 0x00, SET_CONFIGURATION, configuration, 0, 0, buf, 0); return 0; }