Changeset cbdb6457 in mainline for uspace/drv/usbhub/usbhub.c


Ignore:
Timestamp:
2011-04-15T13:51:46Z (13 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
11d2e96a, ab6fdad3
Parents:
8fd4ba0 (diff), be11749 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

interrupts for ohci root hub
hub powering corrected a bit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhub/usbhub.c

    r8fd4ba0 rcbdb6457  
    105105        }
    106106
    107         usb_pipe_start_session(hub_info->control_pipe);
     107        //usb_pipe_start_session(hub_info->control_pipe);
    108108        //set hub configuration
    109109        opResult = usb_hub_set_configuration(hub_info);
     
    122122                return opResult;
    123123        }
    124         usb_pipe_end_session(hub_info->control_pipe);
    125 
    126         /// \TODO what is this?
    127         usb_log_debug("Creating `hub' function.\n");
     124        //usb_pipe_end_session(hub_info->control_pipe);
     125
     126
     127        usb_log_debug("Creating 'hub' function in DDF.\n");
    128128        ddf_fun_t *hub_fun = ddf_fun_create(hub_info->usb_device->ddf_dev,
    129129            fun_exposed, "hub");
     
    153153bool hub_port_changes_callback(usb_device_t *dev,
    154154    uint8_t *change_bitmap, size_t change_bitmap_size, void *arg) {
     155        usb_log_debug("hub_port_changes_callback\n");
    155156        usb_hub_info_t *hub = (usb_hub_info_t *) arg;
    156157
     
    217218        // get hub descriptor
    218219        usb_log_debug("creating serialized descriptor\n");
    219         void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE);
     220        //void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE);
     221        uint8_t serialized_descriptor[USB_HUB_MAX_DESCRIPTOR_SIZE];
    220222        usb_hub_descriptor_t * descriptor;
    221223        int opResult;
     
    235237        }
    236238        usb_log_debug2("deserializing descriptor\n");
    237         descriptor = usb_deserialize_hub_desriptor(serialized_descriptor);
     239        descriptor = usb_create_deserialized_hub_desriptor(
     240            serialized_descriptor);
    238241        if (descriptor == NULL) {
    239242                usb_log_warning("could not deserialize descriptor \n");
    240                 return opResult;
     243                return ENOMEM;
    241244        }
    242245        usb_log_debug("setting port count to %d\n", descriptor->ports_count);
    243246        hub_info->port_count = descriptor->ports_count;
    244247        /// \TODO this is not semantically correct
     248        bool is_power_switched =
     249            ((descriptor->hub_characteristics & 1) ==0);
     250        bool has_individual_port_powering =
     251            ((descriptor->hub_characteristics & 1) !=0);
    245252        hub_info->ports = malloc(
    246253            sizeof (usb_hub_port_t) * (hub_info->port_count + 1));
     
    249256                usb_hub_port_init(&hub_info->ports[port]);
    250257        }
    251         for (port = 0; port < hub_info->port_count; port++) {
    252                 opResult = usb_hub_set_port_feature(hub_info->control_pipe,
    253                     port+1, USB_HUB_FEATURE_PORT_POWER);
    254                 if (opResult != EOK) {
    255                         usb_log_error("cannot power on port %d;  %d\n",
    256                             port+1, opResult);
    257                 }
     258        if(is_power_switched){
     259                usb_log_debug("is_power_switched\n");
     260                if(has_individual_port_powering){
     261                        usb_log_debug("has_individual_port_powering\n");
     262                        for (port = 0; port < hub_info->port_count; port++) {
     263                                opResult = usb_hub_set_port_feature(hub_info->control_pipe,
     264                                    port+1, USB_HUB_FEATURE_PORT_POWER);
     265                                if (opResult != EOK) {
     266                                        usb_log_error("cannot power on port %d;  %d\n",
     267                                            port+1, opResult);
     268                                }
     269                        }
     270                }else{
     271                        usb_log_debug("!has_individual_port_powering\n");
     272                        opResult = usb_hub_set_feature(hub_info->control_pipe,
     273                            USB_HUB_FEATURE_C_HUB_LOCAL_POWER);
     274                        if (opResult != EOK) {
     275                                usb_log_error("cannot power hub;  %d\n",
     276                                  opResult);
     277                        }
     278                }
     279        }else{
     280                usb_log_debug("!is_power_switched\n");
    258281        }
    259282        usb_log_debug2("freeing data\n");
    260         free(serialized_descriptor);
    261         free(descriptor->devices_removable);
     283        //free(serialized_descriptor);
     284        //free(descriptor->devices_removable);
    262285        free(descriptor);
    263286        return EOK;
     
    321344         * auto destruction, this could work better.
    322345         */
    323         int rc = usb_pipe_start_session(hub_info->control_pipe);
     346        int rc = usb_hc_connection_open(&hub_info->connection);
    324347        if (rc != EOK) {
    325                 usb_log_error("Failed to start session on control pipe: %s.\n",
    326                     str_error(rc));
    327                 return rc;
    328         }
    329         rc = usb_hc_connection_open(&hub_info->connection);
    330         if (rc != EOK) {
    331                 usb_pipe_end_session(hub_info->control_pipe);
     348                //usb_pipe_end_session(hub_info->control_pipe);
    332349                usb_log_error("Failed to open connection to HC: %s.\n",
    333350                    str_error(rc));
Note: See TracChangeset for help on using the changeset viewer.