Changes in / [50ba203:0c00dac] in mainline


Ignore:
Location:
uspace/drv/usbhub
Files:
3 edited

Legend:

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

    r50ba203 r0c00dac  
    4343#include <usb/recognise.h>
    4444#include <usb/devreq.h>
    45 #include <usb/request.h>
    4645#include <usb/classes/hub.h>
    4746
     
    5049#include "port_status.h"
    5150#include "usb/usb.h"
    52 #include "usb/pipes.h"
    5351
    5452static usb_iface_t hub_usb_iface = {
     
    6664//*********************************************
    6765
    68 usb_hub_info_t * usb_create_hub_info(device_t * device) {
     66usb_hub_info_t * usb_create_hub_info(device_t * device, int hc) {
    6967        usb_hub_info_t* result = usb_new(usb_hub_info_t);
    70         usb_device_connection_initialize_from_device(&result->connection, device);
    71         usb_endpoint_pipe_initialize_default_control(&result->endpoints.control,
    72             &result->connection);
    73        
    74 
    7568        //result->device = device;
    7669        result->port_count = -1;
     
    7871        result->device = device;
    7972
    80 <<<<<<< TREE
    81         result->usb_device = usb_new(usb_hcd_attached_device_info_t);
    82        
    83 =======
    8473
    8574        dprintf(USB_LOG_LEVEL_DEBUG, "phone to hc = %d", hc);
     
    9786        result->address = addr;
    9887
    99 >>>>>>> MERGE-SOURCE
    10088        // get hub descriptor
    10189
     
    10694        int opResult;
    10795        dprintf(USB_LOG_LEVEL_DEBUG, "starting control transaction");
    108         usb_endpoint_pipe_start_session(&result->endpoints.control);
    109         opResult = usb_request_get_descriptor(&result->endpoints.control,
     96       
     97        opResult = usb_drv_req_get_descriptor(hc, addr,
    11098                        USB_REQUEST_TYPE_CLASS,
    11199                        USB_DESCTYPE_HUB, 0, 0, serialized_descriptor,
    112100                        USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size);
    113         usb_endpoint_pipe_end_session(&result->endpoints.control);
    114 
    115         /* Initialize the interrupt endpoint.
    116         usb_endpoint_pipe_initalize(
    117                 &hub_data->endpoints->status_change,
    118                 &endpiont_descriptor, &hub_data->connection);
    119 
    120          */ /// \TODO add this call
    121101
    122102        if (opResult != EOK) {
     
    163143        dev->ops = &hub_device_ops;
    164144
    165 
    166         usb_hub_info_t * hub_info = usb_create_hub_info(dev);
    167         usb_endpoint_pipe_start_session(&hub_info->endpoints.control);
     145        //create the hub structure
     146        //get hc connection
     147        int hc = usb_drv_hc_connect_auto(dev, 0);
     148        if (hc < 0) {
     149                return hc;
     150        }
     151
     152        usb_hub_info_t * hub_info = usb_create_hub_info(dev, hc);
    168153        int port;
    169154        int opResult;
    170 <<<<<<< TREE
    171         //usb_target_t target;
    172         //target.address = hub_info->usb_device->address;
    173         //target.endpoint = 0;
    174 =======
    175155        usb_target_t target;
    176156        target.address = hub_info->address;
    177157        target.endpoint = 0;
    178 >>>>>>> MERGE-SOURCE
    179158
    180159        //get configuration descriptor
     
    182161        // and all should be checked
    183162        usb_standard_device_descriptor_t std_descriptor;
    184         opResult = usb_request_get_device_descriptor(&hub_info->endpoints.control,
     163        opResult = usb_drv_req_get_device_descriptor(hc, target.address,
    185164            &std_descriptor);
    186165        if(opResult!=EOK){
     
    195174        /// \TODO check other configurations
    196175        usb_standard_configuration_descriptor_t config_descriptor;
    197         opResult = usb_request_get_bare_configuration_descriptor(
    198             &hub_info->endpoints.control, 0,
     176        opResult = usb_drv_req_get_bare_configuration_descriptor(hc,
     177        target.address, 0,
    199178        &config_descriptor);
    200179        if(opResult!=EOK){
     
    203182        }
    204183        //set configuration
    205         opResult = usb_request_set_configuration(&hub_info->endpoints.control,
     184        opResult = usb_drv_req_set_configuration(hc, target.address,
    206185    config_descriptor.configuration_number);
    207186
     
    213192        for (port = 1; port < hub_info->port_count+1; ++port) {
    214193                usb_hub_set_power_port_request(&request, port);
    215                 opResult = usb_endpoint_pipe_control_write(&hub_info->endpoints.control,
    216                                 &request,sizeof(usb_device_request_setup_packet_t), NULL, 0);
     194                opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0);
    217195                dprintf(USB_LOG_LEVEL_INFO, "powering port %d",port);
    218196                if (opResult != EOK) {
     
    222200        //ports powered, hub seems to be enabled
    223201
    224         usb_endpoint_pipe_end_session(&hub_info->endpoints.control);
    225         //async_hangup(hc);
     202        async_hangup(hc);
    226203
    227204        //add the hub to list
     
    275252 * @param target
    276253 */
    277 static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port) {
     254static void usb_hub_init_add_device(int hc, uint16_t port, usb_target_t target) {
    278255        usb_device_request_setup_packet_t request;
    279256        int opResult;
    280257        dprintf(USB_LOG_LEVEL_INFO, "some connection changed");
    281258        //get default address
    282         ///////////////here ended pipe api upgrading
    283         gfdl;gfdgldglglkfgklfjfkld;sjgk;fgklsjgld
    284259        opResult = usb_drv_reserve_default_address(hc);
    285260        if (opResult != EOK) {
     
    408383 * @param target
    409384 */
    410 static void usb_hub_process_interrupt(usb_hub_info_t * hub,
    411         uint16_t port) {
     385static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc,
     386        uint16_t port, usb_address_t address) {
    412387        dprintf(USB_LOG_LEVEL_DEBUG, "interrupt at port %d", port);
    413388        //determine type of change
    414         int opResult = usb_endpoint_pipe_start_session(&hub->endpoints.control);
    415         usb_endpoint_pipe_t *pipe = &hub->endpoints.control;
    416         if(opResult != EOK){
    417                 continue;
    418         }
    419 
    420         /*
    421389        usb_target_t target;
    422390        target.address=address;
    423391        target.endpoint=0;
    424         */
    425 
    426392        usb_port_status_t status;
    427393        size_t rcvd_size;
    428394        usb_device_request_setup_packet_t request;
    429         //int opResult;
     395        int opResult;
    430396        usb_hub_set_port_status_request(&request, port);
    431397        //endpoint 0
    432398
    433         opResult = usb_endpoint_pipe_control_read(
    434                         pipe,
    435                         &request, sizeof(usb_device_request_setup_packet_t),
     399        opResult = usb_drv_sync_control_read(
     400                        hc, target,
     401                        &request,
    436402                        &status, 4, &rcvd_size
    437403                        );
     
    446412        //something connected/disconnected
    447413        if (usb_port_connect_change(&status)) {
    448                 opResult = usb_hub_clear_port_feature(&hub->endpoints.control,
     414                opResult = usb_hub_clear_port_feature(hc, target.address,
    449415                    port, USB_HUB_FEATURE_C_PORT_CONNECTION);
    450416                // TODO: check opResult
    451417                if (usb_port_dev_connected(&status)) {
    452418                        dprintf(USB_LOG_LEVEL_INFO, "some connection changed");
    453                         usb_hub_init_add_device(hub, port);
     419                        usb_hub_init_add_device(hc, port, target);
    454420                } else {
    455                         usb_hub_removed_device(hub, port);
     421                        usb_hub_removed_device(hub, hc, port, target);
    456422                }
    457423        }
     
    460426                dprintf(USB_LOG_LEVEL_INFO, "port reset complete");
    461427                if (usb_port_enabled(&status)) {
    462                         usb_hub_finalize_add_device(hub, port);
     428                        usb_hub_finalize_add_device(hub, hc, port, target);
    463429                } else {
    464430                        dprintf(USB_LOG_LEVEL_WARNING, "ERROR: port reset, but port still not enabled");
     
    476442        /// \TODO handle other changes
    477443        /// \TODO debug log for various situations
    478         usb_endpoint_pipe_end_session(&hub->endpoints.control);
    479 
    480444
    481445}
     
    495459                fibril_mutex_unlock(&usb_hub_list_lock);
    496460                usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data);
    497                 int opResult;
    498 
    499                 opResult = usb_endpoint_pipe_start_session(&hub_info->endpoints.status_change);
    500                 if(opResult != EOK){
    501                         continue;
    502                 }
    503461                /*
    504462                 * Check status change pipe of this hub.
    505463                 */
    506                 /*
     464
    507465                usb_target_t target;
    508466                target.address = hub_info->address;
     
    510468                dprintf(USB_LOG_LEVEL_INFO, "checking changes for hub at addr %d",
    511469                    target.address);
    512                 */
     470
    513471                size_t port_count = hub_info->port_count;
    514472
    515473                /*
    516474                 * Connect to respective HC.
    517                  *
     475                 */
    518476                int hc = usb_drv_hc_connect_auto(hub_info->device, 0);
    519477                if (hc < 0) {
    520478                        continue;
    521                 }*/
     479                }
    522480
    523481                /// FIXME: count properly
     
    531489                 * Send the request.
    532490                 */
    533                 opResult = usb_endpoint_pipe_read(
    534                                 &hub_info->endpoints.status_change,
     491                int opResult = usb_drv_async_interrupt_in(hc, target,
    535492                                change_bitmap, byte_length, &actual_size,
    536                                 );
     493                                &handle);
    537494
    538495                usb_drv_async_wait_for(handle);
     
    549506                        if (interrupt) {
    550507                                usb_hub_process_interrupt(
    551 <<<<<<< TREE
    552                                         hub_info, port);
    553 =======
    554508                                        hub_info, hc, port, hub_info->address);
    555 >>>>>>> MERGE-SOURCE
    556509                        }
    557510                }
    558                 usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change);
    559511                free(change_bitmap);
    560                
    561 
    562                 //async_hangup(hc);
     512
     513                async_hangup(hc);
    563514                fibril_mutex_lock(&usb_hub_list_lock);
    564515        }
  • uspace/drv/usbhub/usbhub.h

    r50ba203 r0c00dac  
    4242#define NAME "usbhub"
    4343
    44 <<<<<<< TREE
    45 #include "usb/hcdhubd.h"
    46 
    47 #include <usb/pipes.h>
    48 
    49 =======
    50 >>>>>>> MERGE-SOURCE
    5144/** basic information about device attached to hub */
    5245typedef struct{
     
    5548}usb_hub_attached_device_t;
    5649
    57 /* Hub endpoints. */
    58 typedef struct {
    59         usb_endpoint_pipe_t control;
    60         usb_endpoint_pipe_t status_change;
    61 } usb_hub_endpoints_t;
    62 
    63 
    64 
    6550/** Information about attached hub. */
    6651typedef struct {
    6752        /** Number of ports. */
    6853        int port_count;
    69         /** attached device handles, for each port one */
     54        /** attached device handles */
    7055        usb_hub_attached_device_t * attached_devs;
    7156        /** USB address of the hub. */
     
    7358        /** General device info*/
    7459        device_t * device;
    75 <<<<<<< TREE
    76         /** connection to hcd */
    77         usb_device_connection_t connection;
    78         /** hub endpoints */
    79         usb_hub_endpoints_t endpoints;
    80 
    81 =======
    82 >>>>>>> MERGE-SOURCE
    8360} usb_hub_info_t;
    8461
  • uspace/drv/usbhub/usbhub_private.h

    r50ba203 r0c00dac  
    7777 * @return
    7878 */
    79 usb_hub_info_t * usb_create_hub_info(device_t * device);
     79usb_hub_info_t * usb_create_hub_info(device_t * device, int hc);
    8080
    8181/** List of hubs maanged by this driver */
     
    9898 * @return error code
    9999 */
    100 /*
    101100int usb_drv_sync_control_read(
    102     usb_endpoint_pipe_t *pipe,
     101    int phone, usb_target_t target,
    103102    usb_device_request_setup_packet_t * request,
    104103    void * rcvd_buffer, size_t rcvd_size, size_t * actual_size
    105 );*/
     104);
    106105
    107106/**
     
    116115 * @return error code
    117116 */
    118 /*int usb_drv_sync_control_write(
    119     usb_endpoint_pipe_t *pipe,
     117int usb_drv_sync_control_write(
     118    int phone, usb_target_t target,
    120119    usb_device_request_setup_packet_t * request,
    121120    void * sent_buffer, size_t sent_size
    122 );*/
     121);
    123122
    124123/**
     
    148147 * @return Operation result
    149148 */
    150 static inline int usb_hub_clear_port_feature(usb_endpoint_pipe_t *pipe,
     149static inline int usb_hub_clear_port_feature(int hc, usb_address_t address,
    151150    int port_index,
    152151    usb_hub_class_feature_t feature) {
    153        
     152        usb_target_t target = {
     153                .address = address,
     154                .endpoint = 0
     155        };
    154156        usb_device_request_setup_packet_t clear_request = {
    155157                .request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE,
     
    159161        };
    160162        clear_request.value = feature;
    161         return usb_endpoint_pipe_control_write(pipe, &clear_request,
     163        return usb_drv_psync_control_write(hc, target, &clear_request,
    162164            sizeof(clear_request), NULL, 0);
    163165}
Note: See TracChangeset for help on using the changeset viewer.