Changeset 621ba8c in mainline
- Timestamp:
- 2011-09-23T14:44:31Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4559d89
- Parents:
- 3b617579
- Location:
- uspace
- Files:
-
- 2 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhub/Makefile
r3b617579 r621ba8c 44 44 SOURCES = \ 45 45 main.c \ 46 utils.c \47 46 usbhub.c \ 48 47 port.c -
uspace/drv/bus/usb/usbhub/port.c
r3b617579 r621ba8c 45 45 #include "port.h" 46 46 #include "usbhub.h" 47 #include "utils.h"48 47 #include "port_status.h" 49 48 -
uspace/drv/bus/usb/usbhub/usbhub.c
r3b617579 r621ba8c 54 54 55 55 #include "usbhub.h" 56 #include "utils.h"57 56 #include "port_status.h" 58 57 … … 242 241 usb_log_debug("Retrieving descriptor\n"); 243 242 usb_pipe_t *control_pipe = &hub_info->usb_device->ctrl_pipe; 244 uint8_t serialized_descriptor[USB_HUB_MAX_DESCRIPTOR_SIZE]; 245 int opResult; 246 243 244 usb_hub_descriptor_header_t descriptor; 247 245 size_t received_size; 248 opResult = usb_request_get_descriptor(control_pipe,246 int opResult = usb_request_get_descriptor(control_pipe, 249 247 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_DEVICE, 250 USB_DESCTYPE_HUB, 0, 0, serialized_descriptor, 251 USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size); 252 248 USB_DESCTYPE_HUB, 0, 0, &descriptor, 249 sizeof(usb_hub_descriptor_t), &received_size); 253 250 if (opResult != EOK) { 254 251 usb_log_error("Failed to receive hub descriptor: %s.\n", … … 256 253 return opResult; 257 254 } 258 usb_log_debug2("Parsing descriptor\n"); 259 usb_hub_descriptor_t descriptor; 260 opResult = usb_deserialize_hub_desriptor( 261 serialized_descriptor, received_size, &descriptor); 262 if (opResult != EOK) { 263 usb_log_error("Could not parse descriptor: %s\n", 264 str_error(opResult)); 265 return opResult; 266 } 267 usb_log_debug("Setting port count to %d.\n", descriptor.ports_count); 268 hub_info->port_count = descriptor.ports_count; 255 256 usb_log_debug("Setting port count to %d.\n", descriptor.port_count); 257 hub_info->port_count = descriptor.port_count; 269 258 270 259 // TODO Why +1 ? … … 281 270 282 271 const bool is_power_switched = 283 !(descriptor. hub_characteristics & HUB_CHAR_NO_POWER_SWITCH_FLAG);272 !(descriptor.characteristics & HUB_CHAR_NO_POWER_SWITCH_FLAG); 284 273 if (is_power_switched) { 285 274 usb_log_debug("Hub power switched\n"); 286 const bool per_port_power = descriptor. hub_characteristics275 const bool per_port_power = descriptor.characteristics 287 276 & HUB_CHAR_POWER_PER_PORT_FLAG; 288 277 … … 303 292 } 304 293 } 305 306 294 } else { 307 295 usb_log_debug("Power not switched, ports always powered\n"); -
uspace/lib/usb/include/usb/classes/hub.h
r3b617579 r621ba8c 72 72 uint8_t port_count; 73 73 /** Characteristics bitmask. */ 74 uint16_t characteristics; 74 uint8_t characteristics; 75 #define HUB_CHAR_POWER_PER_PORT_FLAG (1 << 0) 76 #define HUB_CHAR_NO_POWER_SWITCH_FLAG (1 << 1) 77 /* Unused part of characteristics field */ 78 uint8_t characteristics_reservered; 75 79 /** Time from power-on to stabilization of current on the port. */ 76 80 uint8_t power_good_time; … … 92 96 93 97 /** Number of downstream ports that this hub supports */ 94 uint8_t port s_count;98 uint8_t port_count; 95 99 96 100 /** … … 119 123 */ 120 124 uint16_t hub_characteristics; 121 #define HUB_CHAR_POWER_PER_PORT_FLAG (1 << 0)122 #define HUB_CHAR_NO_POWER_SWITCH_FLAG (1 << 1)123 125 124 126 /** … … 214 216 * Maximum size of usb hub descriptor in bytes 215 217 */ 216 extern size_t USB_HUB_MAX_DESCRIPTOR_SIZE; 217 218 219 220 221 222 218 /* 7 (basic size) + 2*32 (port bitmasks) */ 219 #define USB_HUB_MAX_DESCRIPTOR_SIZE 71 223 220 224 221 #endif
Note:
See TracChangeset
for help on using the changeset viewer.