Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset c9113d2 in mainline for uspace/drv/usbhub/utils.c


Ignore:
Timestamp:
2010-12-12T14:52:39Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
138a7fd
Parents:
a822cd8 (diff), 3b9f1fd (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:

Merge development/ changes

File:
1 edited

Legend:

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

    ra822cd8 rc9113d2  
    3434 */
    3535#include <driver.h>
    36 #include <usb/devreq.h>
     36#include <bool.h>
     37#include <errno.h>
     38
    3739#include <usbhc_iface.h>
    3840#include <usb/usbdrv.h>
    3941#include <usb/descriptor.h>
    40 #include <driver.h>
    41 #include <bool.h>
    42 #include <errno.h>
     42#include <usb/devreq.h>
    4343#include <usb/classes/hub.h>
     44
    4445#include "usbhub.h"
    4546#include "usbhub_private.h"
    4647#include "port_status.h"
    47 #include <usb/devreq.h>
    48 
    49 static void check_hub_changes(void);
     48
    5049
    5150size_t USB_HUB_MAX_DESCRIPTOR_SIZE = 71;
     
    302301        //result->device = device;
    303302        result->port_count = -1;
     303        /// \TODO is this correct? is the device stored?
     304        result->device = device;
    304305
    305306
     
    316317        }*/
    317318
    318         result->device = usb_new(usb_hcd_attached_device_info_t);
    319         result->device->address = addr;
     319        result->usb_device = usb_new(usb_hcd_attached_device_info_t);
     320        result->usb_device->address = addr;
    320321
    321322        // get hub descriptor
     
    362363}
    363364
    364 /** Callback when new hub device is detected.
    365  *
    366  * @param dev New device.
    367  * @return Error code.
    368  */
    369365int usb_add_hub_device(device_t *dev) {
    370366        printf(NAME ": add_hub_device(handle=%d)\n", (int) dev->handle);
     
    387383        usb_device_request_setup_packet_t request;
    388384        usb_target_t target;
    389         target.address = hub_info->device->address;
     385        target.address = hub_info->usb_device->address;
    390386        target.endpoint = 0;
    391387        for (port = 0; port < hub_info->port_count; ++port) {
     
    404400        printf("[usb_hub] hub info added to list\n");
    405401        //(void)hub_info;
    406         check_hub_changes();
     402        usb_hub_check_hub_changes();
    407403
    408404        /// \TODO start the check loop, if not already started...
     
    412408
    413409        printf("[usb_hub] hub dev added\n");
     410        printf("\taddress %d, has %d ports \n",
     411                        hub_info->usb_device->address,
     412                        hub_info->port_count);
    414413
    415414        return EOK;
     
    429428 * @param target
    430429 */
    431 
    432430static void usb_hub_init_add_device(int hc, uint16_t port, usb_target_t target) {
    433431        usb_device_request_setup_packet_t request;
     
    459457 * @param target
    460458 */
    461 static void usb_hub_finalize_add_device(
     459static void usb_hub_finalize_add_device( usb_hub_info_t * hub,
    462460                int hc, uint16_t port, usb_target_t target) {
    463461
     
    479477                return;
    480478        }
     479
     480
    481481        usb_drv_release_default_address(hc);
    482482
    483 
    484         /// \TODO driver work
    485         //add_child_device.....
     483        devman_handle_t child_handle;
     484        opResult = usb_drv_register_child_in_devman(hc, hub->device,
     485        new_device_address, &child_handle);
     486        if (opResult != EOK) {
     487                printf("[usb_hub] could not start driver for new device \n");
     488                return;
     489        }
     490        usb_drv_bind_address(hc, new_device_address, child_handle);
     491       
    486492}
    487493
     
    519525 * @param target
    520526 */
    521 static void usb_hub_process_interrupt(int hc, uint16_t port, usb_target_t target) {
     527static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc, uint16_t port, usb_target_t target) {
    522528        printf("[usb_hub] interrupt at port %d\n", port);
    523529        //determine type of change
     
    554560                printf("[usb_hub] finalizing add device\n");
    555561                if (usb_port_enabled(&status)) {
    556                         usb_hub_finalize_add_device(hc, port, target);
     562                        usb_hub_finalize_add_device(hub, hc, port, target);
    557563                } else {
    558564                        printf("[usb_hub] ERROR: port reset, but port still not enabled\n");
     
    585591/** Check changes on all known hubs.
    586592 */
    587 static void check_hub_changes(void) {
     593void usb_hub_check_hub_changes(void) {
    588594        /*
    589595         * Iterate through all hubs.
     
    594600                        lst_item = lst_item->next) {
    595601                printf("[usb_hub] checking hub changes\n");
     602                usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data);
    596603                /*
    597604                 * Check status change pipe of this hub.
    598605                 */
    599606
    600                 usb_target_t target = {
    601                         .address = 5,
    602                         .endpoint = 1
    603                 };
    604                 /// \TODO uncomment once it works correctly
    605                 //target.address = usb_create_hub_info(lst_item)->device->address;
    606 
    607                 size_t port_count = 7;
     607                usb_target_t target;
     608                target.address = hub_info->usb_device->address;
     609                target.endpoint = 1;
     610
     611                size_t port_count = hub_info->port_count;
    608612
    609613                /*
    610614                 * Connect to respective HC.
    611615                 */
    612                 /// \FIXME this is incorrect code: here
    613                 /// must be used particular device instead of NULL
    614                 //which one?
    615                 int hc = usb_drv_hc_connect(NULL, 0);
     616                int hc = usb_drv_hc_connect(hub_info->device, 0);
    616617                if (hc < 0) {
    617618                        continue;
     
    642643                        bool interrupt = (((uint8_t*) change_bitmap)[port / 8] >> (port % 8)) % 2;
    643644                        if (interrupt) {
    644                                 usb_hub_process_interrupt(hc, port, target);
     645                                usb_hub_process_interrupt(hub_info, hc, port, target);
    645646                        }
    646647                }
Note: See TracChangeset for help on using the changeset viewer.