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


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

Legend:

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

    r0c00dac r50ba203  
    4343#include <usb/recognise.h>
    4444#include <usb/devreq.h>
     45#include <usb/request.h>
    4546#include <usb/classes/hub.h>
    4647
     
    4950#include "port_status.h"
    5051#include "usb/usb.h"
     52#include "usb/pipes.h"
    5153
    5254static usb_iface_t hub_usb_iface = {
     
    6466//*********************************************
    6567
    66 usb_hub_info_t * usb_create_hub_info(device_t * device, int hc) {
     68usb_hub_info_t * usb_create_hub_info(device_t * device) {
    6769        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
    6875        //result->device = device;
    6976        result->port_count = -1;
     
    7178        result->device = device;
    7279
     80<<<<<<< TREE
     81        result->usb_device = usb_new(usb_hcd_attached_device_info_t);
     82       
     83=======
    7384
    7485        dprintf(USB_LOG_LEVEL_DEBUG, "phone to hc = %d", hc);
     
    8697        result->address = addr;
    8798
     99>>>>>>> MERGE-SOURCE
    88100        // get hub descriptor
    89101
     
    94106        int opResult;
    95107        dprintf(USB_LOG_LEVEL_DEBUG, "starting control transaction");
    96        
    97         opResult = usb_drv_req_get_descriptor(hc, addr,
     108        usb_endpoint_pipe_start_session(&result->endpoints.control);
     109        opResult = usb_request_get_descriptor(&result->endpoints.control,
    98110                        USB_REQUEST_TYPE_CLASS,
    99111                        USB_DESCTYPE_HUB, 0, 0, serialized_descriptor,
    100112                        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
    101121
    102122        if (opResult != EOK) {
     
    143163        dev->ops = &hub_device_ops;
    144164
    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);
     165
     166        usb_hub_info_t * hub_info = usb_create_hub_info(dev);
     167        usb_endpoint_pipe_start_session(&hub_info->endpoints.control);
    153168        int port;
    154169        int opResult;
     170<<<<<<< TREE
     171        //usb_target_t target;
     172        //target.address = hub_info->usb_device->address;
     173        //target.endpoint = 0;
     174=======
    155175        usb_target_t target;
    156176        target.address = hub_info->address;
    157177        target.endpoint = 0;
     178>>>>>>> MERGE-SOURCE
    158179
    159180        //get configuration descriptor
     
    161182        // and all should be checked
    162183        usb_standard_device_descriptor_t std_descriptor;
    163         opResult = usb_drv_req_get_device_descriptor(hc, target.address,
     184        opResult = usb_request_get_device_descriptor(&hub_info->endpoints.control,
    164185            &std_descriptor);
    165186        if(opResult!=EOK){
     
    174195        /// \TODO check other configurations
    175196        usb_standard_configuration_descriptor_t config_descriptor;
    176         opResult = usb_drv_req_get_bare_configuration_descriptor(hc,
    177         target.address, 0,
     197        opResult = usb_request_get_bare_configuration_descriptor(
     198            &hub_info->endpoints.control, 0,
    178199        &config_descriptor);
    179200        if(opResult!=EOK){
     
    182203        }
    183204        //set configuration
    184         opResult = usb_drv_req_set_configuration(hc, target.address,
     205        opResult = usb_request_set_configuration(&hub_info->endpoints.control,
    185206    config_descriptor.configuration_number);
    186207
     
    192213        for (port = 1; port < hub_info->port_count+1; ++port) {
    193214                usb_hub_set_power_port_request(&request, port);
    194                 opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0);
     215                opResult = usb_endpoint_pipe_control_write(&hub_info->endpoints.control,
     216                                &request,sizeof(usb_device_request_setup_packet_t), NULL, 0);
    195217                dprintf(USB_LOG_LEVEL_INFO, "powering port %d",port);
    196218                if (opResult != EOK) {
     
    200222        //ports powered, hub seems to be enabled
    201223
    202         async_hangup(hc);
     224        usb_endpoint_pipe_end_session(&hub_info->endpoints.control);
     225        //async_hangup(hc);
    203226
    204227        //add the hub to list
     
    252275 * @param target
    253276 */
    254 static void usb_hub_init_add_device(int hc, uint16_t port, usb_target_t target) {
     277static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port) {
    255278        usb_device_request_setup_packet_t request;
    256279        int opResult;
    257280        dprintf(USB_LOG_LEVEL_INFO, "some connection changed");
    258281        //get default address
     282        ///////////////here ended pipe api upgrading
     283        gfdl;gfdgldglglkfgklfjfkld;sjgk;fgklsjgld
    259284        opResult = usb_drv_reserve_default_address(hc);
    260285        if (opResult != EOK) {
     
    383408 * @param target
    384409 */
    385 static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc,
    386         uint16_t port, usb_address_t address) {
     410static void usb_hub_process_interrupt(usb_hub_info_t * hub,
     411        uint16_t port) {
    387412        dprintf(USB_LOG_LEVEL_DEBUG, "interrupt at port %d", port);
    388413        //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        /*
    389421        usb_target_t target;
    390422        target.address=address;
    391423        target.endpoint=0;
     424        */
     425
    392426        usb_port_status_t status;
    393427        size_t rcvd_size;
    394428        usb_device_request_setup_packet_t request;
    395         int opResult;
     429        //int opResult;
    396430        usb_hub_set_port_status_request(&request, port);
    397431        //endpoint 0
    398432
    399         opResult = usb_drv_sync_control_read(
    400                         hc, target,
    401                         &request,
     433        opResult = usb_endpoint_pipe_control_read(
     434                        pipe,
     435                        &request, sizeof(usb_device_request_setup_packet_t),
    402436                        &status, 4, &rcvd_size
    403437                        );
     
    412446        //something connected/disconnected
    413447        if (usb_port_connect_change(&status)) {
    414                 opResult = usb_hub_clear_port_feature(hc, target.address,
     448                opResult = usb_hub_clear_port_feature(&hub->endpoints.control,
    415449                    port, USB_HUB_FEATURE_C_PORT_CONNECTION);
    416450                // TODO: check opResult
    417451                if (usb_port_dev_connected(&status)) {
    418452                        dprintf(USB_LOG_LEVEL_INFO, "some connection changed");
    419                         usb_hub_init_add_device(hc, port, target);
     453                        usb_hub_init_add_device(hub, port);
    420454                } else {
    421                         usb_hub_removed_device(hub, hc, port, target);
     455                        usb_hub_removed_device(hub, port);
    422456                }
    423457        }
     
    426460                dprintf(USB_LOG_LEVEL_INFO, "port reset complete");
    427461                if (usb_port_enabled(&status)) {
    428                         usb_hub_finalize_add_device(hub, hc, port, target);
     462                        usb_hub_finalize_add_device(hub, port);
    429463                } else {
    430464                        dprintf(USB_LOG_LEVEL_WARNING, "ERROR: port reset, but port still not enabled");
     
    442476        /// \TODO handle other changes
    443477        /// \TODO debug log for various situations
     478        usb_endpoint_pipe_end_session(&hub->endpoints.control);
     479
    444480
    445481}
     
    459495                fibril_mutex_unlock(&usb_hub_list_lock);
    460496                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                }
    461503                /*
    462504                 * Check status change pipe of this hub.
    463505                 */
    464 
     506                /*
    465507                usb_target_t target;
    466508                target.address = hub_info->address;
     
    468510                dprintf(USB_LOG_LEVEL_INFO, "checking changes for hub at addr %d",
    469511                    target.address);
    470 
     512                */
    471513                size_t port_count = hub_info->port_count;
    472514
    473515                /*
    474516                 * Connect to respective HC.
    475                  */
     517                 *
    476518                int hc = usb_drv_hc_connect_auto(hub_info->device, 0);
    477519                if (hc < 0) {
    478520                        continue;
    479                 }
     521                }*/
    480522
    481523                /// FIXME: count properly
     
    489531                 * Send the request.
    490532                 */
    491                 int opResult = usb_drv_async_interrupt_in(hc, target,
     533                opResult = usb_endpoint_pipe_read(
     534                                &hub_info->endpoints.status_change,
    492535                                change_bitmap, byte_length, &actual_size,
    493                                 &handle);
     536                                );
    494537
    495538                usb_drv_async_wait_for(handle);
     
    506549                        if (interrupt) {
    507550                                usb_hub_process_interrupt(
     551<<<<<<< TREE
     552                                        hub_info, port);
     553=======
    508554                                        hub_info, hc, port, hub_info->address);
     555>>>>>>> MERGE-SOURCE
    509556                        }
    510557                }
     558                usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change);
    511559                free(change_bitmap);
    512 
    513                 async_hangup(hc);
     560               
     561
     562                //async_hangup(hc);
    514563                fibril_mutex_lock(&usb_hub_list_lock);
    515564        }
  • uspace/drv/usbhub/usbhub.h

    r0c00dac r50ba203  
    4242#define NAME "usbhub"
    4343
     44<<<<<<< TREE
     45#include "usb/hcdhubd.h"
     46
     47#include <usb/pipes.h>
     48
     49=======
     50>>>>>>> MERGE-SOURCE
    4451/** basic information about device attached to hub */
    4552typedef struct{
     
    4855}usb_hub_attached_device_t;
    4956
     57/* Hub endpoints. */
     58typedef struct {
     59        usb_endpoint_pipe_t control;
     60        usb_endpoint_pipe_t status_change;
     61} usb_hub_endpoints_t;
     62
     63
     64
    5065/** Information about attached hub. */
    5166typedef struct {
    5267        /** Number of ports. */
    5368        int port_count;
    54         /** attached device handles */
     69        /** attached device handles, for each port one */
    5570        usb_hub_attached_device_t * attached_devs;
    5671        /** USB address of the hub. */
     
    5873        /** General device info*/
    5974        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
    6083} usb_hub_info_t;
    6184
  • uspace/drv/usbhub/usbhub_private.h

    r0c00dac r50ba203  
    7777 * @return
    7878 */
    79 usb_hub_info_t * usb_create_hub_info(device_t * device, int hc);
     79usb_hub_info_t * usb_create_hub_info(device_t * device);
    8080
    8181/** List of hubs maanged by this driver */
     
    9898 * @return error code
    9999 */
     100/*
    100101int usb_drv_sync_control_read(
    101     int phone, usb_target_t target,
     102    usb_endpoint_pipe_t *pipe,
    102103    usb_device_request_setup_packet_t * request,
    103104    void * rcvd_buffer, size_t rcvd_size, size_t * actual_size
    104 );
     105);*/
    105106
    106107/**
     
    115116 * @return error code
    116117 */
    117 int usb_drv_sync_control_write(
    118     int phone, usb_target_t target,
     118/*int usb_drv_sync_control_write(
     119    usb_endpoint_pipe_t *pipe,
    119120    usb_device_request_setup_packet_t * request,
    120121    void * sent_buffer, size_t sent_size
    121 );
     122);*/
    122123
    123124/**
     
    147148 * @return Operation result
    148149 */
    149 static inline int usb_hub_clear_port_feature(int hc, usb_address_t address,
     150static inline int usb_hub_clear_port_feature(usb_endpoint_pipe_t *pipe,
    150151    int port_index,
    151152    usb_hub_class_feature_t feature) {
    152         usb_target_t target = {
    153                 .address = address,
    154                 .endpoint = 0
    155         };
     153       
    156154        usb_device_request_setup_packet_t clear_request = {
    157155                .request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE,
     
    161159        };
    162160        clear_request.value = feature;
    163         return usb_drv_psync_control_write(hc, target, &clear_request,
     161        return usb_endpoint_pipe_control_write(pipe, &clear_request,
    164162            sizeof(clear_request), NULL, 0);
    165163}
Note: See TracChangeset for help on using the changeset viewer.