static int usbhub_get_hub_descriptor(usbdev_t *dev,usb_hub_descr_t *dscr,int idx,int maxlen) { int res; uint8_t *respbuf; int len; /* * Get the hub descriptor. Get the first 8 bytes first, then get * the rest if there is more. */ respbuf = usb_dma_alloc(USB_HUB_DESCR_SIZE); res = usb_std_request(dev,0xA0, USB_HUBREQ_GET_DESCRIPTOR, 0, 0, respbuf, USB_HUB_DESCR_SIZE); len = ((usb_hub_descr_t *)respbuf)->bDescriptorLength; if (len > USB_HUB_DESCR_SIZE) { usb_dma_free(respbuf); respbuf = usb_dma_alloc(USB_HUB_DESCR_SIZE); res = usb_std_request(dev,0xA0, USB_HUBREQ_GET_DESCRIPTOR, 0, 0, respbuf, len); } memcpy(dscr, respbuf, (len <= maxlen ? len : maxlen)); usb_dma_free(respbuf); return res; }
static int rtek_set_reg( usbdev_t *dev, int16_t reg, int8_t val ) { uint8_t data[1]; data[0] = val; return usb_std_request( dev, (USBREQ_TYPE_VENDOR | USBREQ_DIR_OUT), RTEK_REG_ACCESS, reg, 0, data, 1 ); }
static int usbhub_get_hub_descriptor(usbdev_t *dev,usb_hub_descr_t *dscr,int idx,int maxlen) { return usb_std_request(dev,0xA0, USB_HUBREQ_GET_DESCRIPTOR, 0,0, (uint8_t *) dscr, maxlen); }
static int usbhub_get_port_status(usbdev_t *dev,int port,usb_port_status_t *status) { return usb_std_request(dev, 0xA3, 0, 0, port, (uint8_t *) status, sizeof(usb_port_status_t)); }
static int usbhub_get_hub_status(usbdev_t *dev,usb_hub_status_t *status) { return usb_std_request(dev, 0xA0, 0x00, 0, 0, (uint8_t *) status, sizeof(usbhub_status_t)); }
static int usbmass_get_max_lun(usbdev_t *dev,int *lunp) { uint8_t buf = 0; int res; res = usb_std_request(dev,0xA1,0xFE,0,0,&buf,1); if (res < 0) return res; if (lunp) *lunp = (int) buf; return 0; }
static int rtek_get_reg( usbdev_t *dev, int16_t reg, uint8_t *val, int16_t len ) { return usb_std_request( dev, (USBREQ_TYPE_VENDOR | USBREQ_DIR_IN), RTEK_REG_ACCESS, reg, 0, val, len ); }