m00h @ previous commit: using wTotalLenght of CONFIGURATION you get
authorBernhard Urban <lewurm@gmx.net>
Tue, 22 Sep 2009 08:08:47 +0000 (10:08 +0200)
committerBernhard Urban <lewurm@gmx.net>
Tue, 22 Sep 2009 08:08:47 +0000 (10:08 +0200)
CONFIGURATION, INTERFACE(s) and ENDPOINT(s) in one big request. WIP

usb/core/core.c
usb/core/usb.c

index 5583c751629ab5b3b49f88a1064c219b33c88b24..b57531564eeef768bc7be37643bf5bdf399a356c 100644 (file)
@@ -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
        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) {
        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
        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
 
        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));
        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));
 
        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));
        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));
        }
                hexdump(buf, sizeof(buf));
        }
+       */
 
 
 
 
 
 
index 94676d3cddef0d808cf75f14aa5d9468885b3d84..95110672b1142f434950153ec4f9cec8c7b7dd97 100644 (file)
@@ -234,8 +234,7 @@ s8 usb_get_desc_interface(struct usb_device *dev, u8 index, u8 *buf, u8 size)
        if(size < 9) {
                return -1;
        }
        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;
 }
 
        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)
 {
 
 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;
 }
 
        return 0;
 }