Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/src/recognise.c

    r345ea18 r687efaa  
    3636#include <usb_iface.h>
    3737#include <usb/usbdrv.h>
    38 #include <usb/pipes.h>
    39 #include <usb/recognise.h>
    40 #include <usb/request.h>
    4138#include <usb/classes/classes.h>
    4239#include <stdio.h>
    4340#include <errno.h>
    44 
    45 static size_t device_name_index = 0;
    46 static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex);
    4741
    4842/** Callback for getting host controller handle.
     
    161155                /* First, with release number. */
    162156                rc = usb_add_match_id(matches, 100,
    163                     "usb&vendor=0x%04x&product=0x%04x&release=" BCD_FMT,
     157                    "usb&vendor=%d&product=%d&release=" BCD_FMT,
    164158                    (int) device_descriptor->vendor_id,
    165159                    (int) device_descriptor->product_id,
     
    170164               
    171165                /* Next, without release number. */
    172                 rc = usb_add_match_id(matches, 90,
    173                     "usb&vendor=0x%04x&product=0x%04x",
     166                rc = usb_add_match_id(matches, 90, "usb&vendor=%d&product=%d",
    174167                    (int) device_descriptor->vendor_id,
    175168                    (int) device_descriptor->product_id);
     
    248241/** Add match ids based on configuration descriptor.
    249242 *
    250  * @param pipe Control pipe to the device.
     243 * @param hc Open phone to host controller.
    251244 * @param matches Match ids list to add matches to.
     245 * @param address USB address of the attached device.
    252246 * @param config_count Number of configurations the device has.
    253247 * @return Error code.
    254248 */
    255 static int usb_add_config_descriptor_match_ids(usb_endpoint_pipe_t *pipe,
    256     match_id_list_t *matches, int config_count)
     249static int usb_add_config_descriptor_match_ids(int hc,
     250    match_id_list_t *matches, usb_address_t address,
     251    int config_count)
    257252{
    258253        int final_rc = EOK;
     
    262257                int rc;
    263258                usb_standard_configuration_descriptor_t config_descriptor;
    264                 rc = usb_request_get_bare_configuration_descriptor(pipe,
    265                     config_index, &config_descriptor);
     259                rc = usb_drv_req_get_bare_configuration_descriptor(hc,
     260                    address,  config_index, &config_descriptor);
    266261                if (rc != EOK) {
    267262                        final_rc = rc;
     
    272267                void *full_config_descriptor
    273268                    = malloc(config_descriptor.total_length);
    274                 rc = usb_request_get_full_configuration_descriptor(pipe,
    275                     config_index,
     269                rc = usb_drv_req_get_full_configuration_descriptor(hc,
     270                    address, config_index,
    276271                    full_config_descriptor, config_descriptor.total_length,
    277272                    &full_config_descriptor_size);
     
    304299 * function exits with error.
    305300 *
    306  * @param ctrl_pipe Control pipe to given device (session must be already
    307  *      started).
     301 * @param hc Open phone to host controller.
    308302 * @param matches Initialized list of match ids.
    309  * @return Error code.
    310  */
    311 int usb_device_create_match_ids(usb_endpoint_pipe_t *ctrl_pipe,
    312     match_id_list_t *matches)
     303 * @param address USB address of the attached device.
     304 * @return Error code.
     305 */
     306int usb_drv_create_device_match_ids(int hc, match_id_list_t *matches,
     307    usb_address_t address)
    313308{
    314309        int rc;
     310       
    315311        /*
    316312         * Retrieve device descriptor and add matches from it.
     
    318314        usb_standard_device_descriptor_t device_descriptor;
    319315
    320         rc = usb_request_get_device_descriptor(ctrl_pipe, &device_descriptor);
     316        rc = usb_drv_req_get_device_descriptor(hc, address,
     317            &device_descriptor);
    321318        if (rc != EOK) {
    322319                return rc;
    323320        }
    324 
     321       
    325322        rc = usb_drv_create_match_ids_from_device_descriptor(matches,
    326323            &device_descriptor);
     
    328325                return rc;
    329326        }
    330 
     327       
    331328        /*
    332329         * Go through all configurations and add matches
    333330         * based on interface class.
    334331         */
    335         rc = usb_add_config_descriptor_match_ids(ctrl_pipe, matches,
    336             device_descriptor.configuration_count);
     332        rc = usb_add_config_descriptor_match_ids(hc, matches,
     333            address, device_descriptor.configuration_count);
    337334        if (rc != EOK) {
    338335                return rc;
     
    350347}
    351348
     349
    352350/** Probe for device kind and register it in devman.
    353351 *
     352 * @param[in] hc Open phone to the host controller.
     353 * @param[in] parent Parent device.
    354354 * @param[in] address Address of the (unknown) attached device.
    355  * @param[in] hc_handle Handle of the host controller.
    356  * @param[in] parent Parent device.
    357355 * @param[out] child_handle Handle of the child device.
    358356 * @return Error code.
    359357 */
    360 int usb_device_register_child_in_devman(usb_address_t address,
    361     devman_handle_t hc_handle,
    362     device_t *parent, devman_handle_t *child_handle)
    363 {
     358int usb_drv_register_child_in_devman(int hc, device_t *parent,
     359    usb_address_t address, devman_handle_t *child_handle)
     360{
     361        static size_t device_name_index = 0;
     362        static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex);
     363
    364364        size_t this_device_name_index;
    365365
     
    369369        fibril_mutex_unlock(&device_name_index_mutex);
    370370
     371
    371372        device_t *child = NULL;
    372373        char *child_name = NULL;
    373374        int rc;
    374         usb_device_connection_t dev_connection;
    375         usb_endpoint_pipe_t ctrl_pipe;
    376 
    377         rc = usb_device_connection_initialize(&dev_connection, hc_handle, address);
    378         if (rc != EOK) {
    379                 goto failure;
    380         }
    381 
    382         rc = usb_endpoint_pipe_initialize_default_control(&ctrl_pipe,
    383             &dev_connection);
    384         if (rc != EOK) {
    385                 goto failure;
    386         }
    387375
    388376        child = create_device();
     
    403391        child->name = child_name;
    404392        child->ops = &child_ops;
    405 
    406         rc = usb_endpoint_pipe_start_session(&ctrl_pipe);
    407         if (rc != EOK) {
    408                 goto failure;
    409         }
    410 
    411         rc = usb_device_create_match_ids(&ctrl_pipe, &child->match_ids);
    412         if (rc != EOK) {
    413                 goto failure;
    414         }
    415 
    416         rc = usb_endpoint_pipe_end_session(&ctrl_pipe);
     393       
     394        rc = usb_drv_create_device_match_ids(hc, &child->match_ids, address);
    417395        if (rc != EOK) {
    418396                goto failure;
     
    427405                *child_handle = child->handle;
    428406        }
    429 
     407       
    430408        return EOK;
    431409
     
    441419
    442420        return rc;
     421
    443422}
    444423
Note: See TracChangeset for help on using the changeset viewer.