Changes in / [103a3626:78d1525] in mainline


Ignore:
Location:
uspace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhid/hid.h

    r103a3626 r78d1525  
    6969        device_t *device;
    7070        usb_hid_configuration_t *conf;
     71        usb_address_t address;
    7172        usb_hid_report_parser_t *parser;
    7273
    7374        usb_device_connection_t wire;
    74         usb_endpoint_pipe_t ctrl_pipe;
    7575        usb_endpoint_pipe_t poll_pipe;
    7676} usb_hid_dev_kbd_t;
  • uspace/drv/usbhid/main.c

    r103a3626 r78d1525  
    4747#include <usb/classes/hid.h>
    4848#include <usb/classes/hidparser.h>
    49 #include <usb/request.h>
     49#include <usb/devreq.h>
    5050#include <usb/descriptor.h>
    5151#include <io/console.h>
     
    280280               
    281281                // get the descriptor from the device
    282                 int rc = usb_request_get_descriptor(&kbd_dev->ctrl_pipe,
    283                     USB_REQUEST_TYPE_CLASS, USB_DESCTYPE_HID_REPORT,
    284                     i, 0,
    285                     kbd_dev->conf->interfaces[i].report_desc, length,
     282                int rc = usb_drv_req_get_descriptor(kbd_dev->device->parent_phone,
     283                    kbd_dev->address, USB_REQUEST_TYPE_CLASS, USB_DESCTYPE_HID_REPORT,
     284                    0, i, kbd_dev->conf->interfaces[i].report_desc, length,
    286285                    &actual_size);
    287286
     
    304303        usb_standard_configuration_descriptor_t config_desc;
    305304       
    306         int rc;
    307         rc = usb_request_get_bare_configuration_descriptor(&kbd_dev->ctrl_pipe,
    308             0, &config_desc);
     305        int rc = usb_drv_req_get_bare_configuration_descriptor(
     306            kbd_dev->device->parent_phone, kbd_dev->address, 0, &config_desc);
    309307       
    310308        if (rc != EOK) {
     
    320318        size_t transferred = 0;
    321319        // get full configuration descriptor
    322         rc = usb_request_get_full_configuration_descriptor(&kbd_dev->ctrl_pipe,
    323             0, descriptors,
     320        rc = usb_drv_req_get_full_configuration_descriptor(
     321            kbd_dev->device->parent_phone, kbd_dev->address, 0, descriptors,
    324322            config_desc.total_length, &transferred);
    325323       
     
    368366static usb_hid_dev_kbd_t *usbkbd_init_device(device_t *dev)
    369367{
    370         int rc;
    371 
    372368        usb_hid_dev_kbd_t *kbd_dev = (usb_hid_dev_kbd_t *)calloc(1,
    373369            sizeof(usb_hid_dev_kbd_t));
     
    380376        kbd_dev->device = dev;
    381377
     378        // get phone to my HC and save it as my parent's phone
     379        // TODO: maybe not a good idea if DDF will use parent_phone
     380        int rc = kbd_dev->device->parent_phone = usb_drv_hc_connect_auto(dev, 0);
     381        if (rc < 0) {
     382                printf("Problem setting phone to HC.\n");
     383                goto error_leave;
     384        }
     385
     386        rc = kbd_dev->address = usb_drv_get_my_address(dev->parent_phone, dev);
     387        if (rc < 0) {
     388                printf("Problem getting address of the device.\n");
     389                goto error_leave;
     390        }
     391
     392        // doesn't matter now that we have no address
     393//      if (kbd_dev->address < 0) {
     394//              fprintf(stderr, NAME ": No device address!\n");
     395//              free(kbd_dev);
     396//              return NULL;
     397//      }
     398
     399        /*
     400         * will need all descriptors:
     401         * 1) choose one configuration from configuration descriptors
     402         *    (set it to the device)
     403         * 2) set endpoints from endpoint descriptors
     404         */
     405
     406        // TODO: get descriptors, parse descriptors and save endpoints
     407        usbkbd_process_descriptors(kbd_dev);
     408
     409
     410
    382411        /*
    383412         * Initialize the backing connection to the host controller.
     
    393422         * Initialize device pipes.
    394423         */
    395         rc = usb_endpoint_pipe_initialize_default_control(&kbd_dev->ctrl_pipe,
    396             &kbd_dev->wire);
    397         if (rc != EOK) {
    398                 printf("Failed to initialize default control pipe: %s.\n",
    399                     str_error(rc));
    400                 goto error_leave;
    401         }
    402 
    403424        rc = usb_endpoint_pipe_initialize(&kbd_dev->poll_pipe, &kbd_dev->wire,
    404425            GUESSED_POLL_ENDPOINT, USB_TRANSFER_INTERRUPT, USB_DIRECTION_IN);
     
    409430        }
    410431
    411         /*
    412          * will need all descriptors:
    413          * 1) choose one configuration from configuration descriptors
    414          *    (set it to the device)
    415          * 2) set endpoints from endpoint descriptors
    416          */
    417 
    418         // TODO: get descriptors, parse descriptors and save endpoints
    419         usb_endpoint_pipe_start_session(&kbd_dev->ctrl_pipe);
    420         usbkbd_process_descriptors(kbd_dev);
    421         usb_endpoint_pipe_end_session(&kbd_dev->ctrl_pipe);
    422432
    423433        return kbd_dev;
  • uspace/lib/usb/src/addrkeep.c

    r103a3626 r78d1525  
    149149                        &addresses->default_condvar_guard);
    150150        }
     151        addresses->default_available = false;
    151152        fibril_mutex_unlock(&addresses->default_condvar_guard);
    152153}
  • uspace/lib/usb/src/debug.c

    r103a3626 r78d1525  
    6767/** Serialization mutex for logging functions. */
    6868static FIBRIL_MUTEX_INITIALIZE(log_serializer);
     69static FILE *log_stream = NULL;
    6970
    7071/** Find or create new tag with given name.
     
    171172        log_prefix = message_prefix;
    172173        log_level = level;
     174        if (log_stream == NULL) {
     175                char *fname;
     176                int rc = asprintf(&fname, "/log/%s", message_prefix);
     177                if (rc > 0) {
     178                        log_stream = fopen(fname, "w");
     179                        free(fname);
     180                }
     181        }
    173182}
    174183
     
    197206void usb_log_printf(usb_log_level_t level, const char *format, ...)
    198207{
    199         if (level > log_level) {
    200                 return;
    201         }
    202 
    203208        FILE *stream = NULL;
    204209        switch (level) {
     
    216221        va_start(args, format);
    217222
     223        /*
     224         * Serialize access to log files.
     225         * Always print to log file, to screen print only when the enabled
     226         * log level is high enough.
     227         */
    218228        fibril_mutex_lock(&log_serializer);
    219         fprintf(stream, "[%s]%s: ", log_prefix, log_level_name(level));
    220         vfprintf(stream, format, args);
     229
     230        const char *level_name = log_level_name(level);
     231
     232        if (log_stream != NULL) {
     233                fprintf(log_stream, "[%s]%s: ", log_prefix, level_name);
     234                vfprintf(log_stream, format, args);
     235        }
     236
     237        if (level <= log_level) {
     238                fprintf(stream, "[%s]%s: ", log_prefix, level_name);
     239                vfprintf(stream, format, args);
     240        }
     241
    221242        fibril_mutex_unlock(&log_serializer);
    222243
Note: See TracChangeset for help on using the changeset viewer.