Changes in uspace/drv/usbhub/utils.c [9ca0013:4317827] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/utils.c
r9ca0013 r4317827 109 109 //********************************************* 110 110 111 static void set_hub_address(device_t *dev, usb_address_t address); 112 111 113 usb_hcd_hub_info_t * usb_create_hub_info(device_t * device) { 112 114 usb_hcd_hub_info_t* result = (usb_hcd_hub_info_t*) malloc(sizeof (usb_hcd_hub_info_t)); … … 122 124 int usb_add_hub_device(device_t *dev) { 123 125 printf(NAME ": add_hub_device(handle=%d)\n", (int) dev->handle); 126 set_hub_address(dev, 5); 124 127 125 128 check_hub_changes(); … … 139 142 } 140 143 144 /** Sample usage of usb_hc_async functions. 145 * This function sets hub address using standard SET_ADDRESS request. 146 * 147 * @warning This function shall be removed once you are familiar with 148 * the usb_hc_ API. 149 * 150 * @param hc Host controller the hub belongs to. 151 * @param address New hub address. 152 */ 153 static void set_hub_address(device_t *dev, usb_address_t address) { 154 printf(NAME ": setting hub address to %d\n", address); 155 usb_target_t target = {0, 0}; 156 usb_handle_t handle; 157 int rc; 158 159 usb_device_request_setup_packet_t setup_packet = { 160 .request_type = 0, 161 .request = USB_DEVREQ_SET_ADDRESS, 162 .index = 0, 163 .length = 0, 164 }; 165 setup_packet.value = address; 166 167 int hc = usb_drv_hc_connect(dev, 0); 168 169 rc = usb_drv_async_control_write_setup(hc, target, 170 &setup_packet, sizeof (setup_packet), &handle); 171 if (rc != EOK) { 172 return; 173 } 174 175 rc = usb_drv_async_wait_for(handle); 176 if (rc != EOK) { 177 return; 178 } 179 180 rc = usb_drv_async_control_write_status(hc, target, &handle); 181 if (rc != EOK) { 182 return; 183 } 184 185 rc = usb_drv_async_wait_for(handle); 186 if (rc != EOK) { 187 return; 188 } 189 190 printf(NAME ": hub address changed\n"); 191 } 141 192 142 193 /** Check changes on all known hubs. … … 186 237 */ 187 238 188 /*189 * WARNING: sample code, will not work out of the box.190 * And does not contain code for checking for errors.191 */192 #if 0193 /*194 * Before opening the port, we must acquire the default195 * address.196 */197 usb_drv_reserve_default_address(hc);198 199 usb_address_t new_device_address = usb_drv_request_address(hc);200 201 // TODO: open the port202 203 // TODO: send request for setting address to new_device_address204 205 /*206 * Once new address is set, we can release the default207 * address.208 */209 usb_drv_release_default_address(hc);210 211 /*212 * Obtain descriptors and create match ids for devman.213 */214 215 // TODO: get device descriptors216 217 // TODO: create match ids218 219 // TODO: add child device220 221 // child_device_register sets the device handle222 // TODO: store it here223 devman_handle_t new_device_handle = 0;224 225 /*226 * Inform the HC that the new device has devman handle227 * assigned.228 */229 usb_drv_bind_address(hc, new_device_address, new_device_handle);230 231 /*232 * That's all.233 */234 #endif235 236 239 237 240 /*
Note:
See TracChangeset
for help on using the changeset viewer.