Changeset b9e3aa3 in mainline for uspace/lib


Ignore:
Timestamp:
2011-05-30T14:13:53Z (15 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f3f9733
Parents:
2002595 (diff), 8357fc9 (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:

Development changes (a lot of stuff)

Location:
uspace/lib
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/driver.c

    r2002595 rb9e3aa3  
    405405                                /* The interface has not such method */
    406406                                printf("%s: driver_connection_gen error - "
    407                                     "invalid interface method (%d).\n",
     407                                    "invalid interface method "
     408                                    "(index %" PRIun ").\n",
    408409                                    driver->name, iface_method_idx);
    409410                                async_answer_0(callid, ENOTSUP);
  • uspace/lib/drv/include/remote_pci.h

    r2002595 rb9e3aa3  
    3636#define LIBDRV_REMOTE_PCI_H_
    3737
    38 remote_iface_t remote_pci_iface;
     38extern remote_iface_t remote_pci_iface;
    3939
    4040#endif
  • uspace/lib/drv/include/remote_usb.h

    r2002595 rb9e3aa3  
    3636#define LIBDRV_REMOTE_USB_H_
    3737
    38 remote_iface_t remote_usb_iface;
     38extern remote_iface_t remote_usb_iface;
    3939
    4040#endif
  • uspace/lib/drv/include/remote_usbhc.h

    r2002595 rb9e3aa3  
    3636#define LIBDRV_REMOTE_USBHC_H_
    3737
    38 remote_iface_t remote_usbhc_iface;
     38extern remote_iface_t remote_usbhc_iface;
    3939
    4040#endif
  • uspace/lib/drv/include/usbhc_iface.h

    r2002595 rb9e3aa3  
    212212/** USB host controller communication interface. */
    213213typedef struct {
    214         int (*reserve_default_address)(ddf_fun_t *, usb_speed_t);
    215         int (*release_default_address)(ddf_fun_t *);
    216214        int (*request_address)(ddf_fun_t *, usb_speed_t, usb_address_t *);
    217215        int (*bind_address)(ddf_fun_t *, usb_address_t, devman_handle_t);
  • uspace/lib/usbdev/include/usb/dev/driver.h

    r2002595 rb9e3aa3  
    168168int usb_device_destroy_pipes(ddf_dev_t *, usb_endpoint_mapping_t *, size_t);
    169169int usb_device_create(ddf_dev_t *, usb_endpoint_description_t **, usb_device_t **, const char **);
     170void usb_device_destroy(usb_device_t *);
    170171
    171172size_t usb_interface_count_alternates(uint8_t *, size_t, uint8_t);
  • uspace/lib/usbdev/src/devdrv.c

    r2002595 rb9e3aa3  
    533533}
    534534
     535/** Destroy instance of a USB device.
     536 *
     537 * @param dev Device to be destroyed.
     538 */
     539void usb_device_destroy(usb_device_t *dev)
     540{
     541        if (dev == NULL) {
     542                return;
     543        }
     544
     545        /* Ignore errors and hope for the best. */
     546        usb_device_destroy_pipes(dev->ddf_dev, dev->pipes, dev->pipes_count);
     547        if (dev->descriptors.configuration != NULL) {
     548                free(dev->descriptors.configuration);
     549        }
     550
     551        if (dev->alternate_interfaces != NULL) {
     552                if (dev->alternate_interfaces->alternatives != NULL) {
     553                        free(dev->alternate_interfaces->alternatives);
     554                }
     555                free(dev->alternate_interfaces);
     556        }
     557
     558        free(dev);
     559}
     560
    535561/**
    536562 * @}
  • uspace/lib/usbdev/src/hub.c

    r2002595 rb9e3aa3  
    331331                goto leave_release_free_address;
    332332        }
     333       
     334        usb_hc_connection_close(&hc_conn);
    333335
    334336        /*
  • uspace/lib/usbhid/src/hiddescriptor.c

    r2002595 rb9e3aa3  
    187187
    188188                field = malloc(sizeof(usb_hid_report_field_t));
     189                if(field == NULL) {
     190                        return ENOMEM;
     191                }
     192
    189193                memset(field, 0, sizeof(usb_hid_report_field_t));
    190194                list_initialize(&field->link);
     
    216220                        }
    217221                        else {
    218                                 usage = report_item->usages[
     222                                usage = report_item->usages[
    219223                                        report_item->usages_count- 1];
    220224                        }
     
    241245
    242246                field->size = report_item->size;
    243                
    244                 size_t offset_byte = (report_item->offset + (i *
    245                         report_item->size)) / 8;
    246 
    247                 size_t offset_bit = 8 - ((report_item->offset + (i *
    248                         report_item->size)) % 8) - report_item->size;
    249 
    250                 field->offset = 8 * offset_byte + offset_bit;
    251                 if(report_item->id != 0) {
     247
     248                if(report_item->type == USB_HID_REPORT_TYPE_INPUT) {
     249                        int offset = report_item->offset + report_item->size * i;
     250                        int field_offset = (offset/8)*8 + (offset/8 + 1) * 8 -
     251                                offset - report_item->size;
     252                        if(field_offset < 0) {
     253                                field->offset = 0;
     254                        }
     255                        else {
     256                                field->offset = field_offset;
     257                        }
     258                }
     259                else {
     260                        field->offset = report_item->offset + (i * report_item->size);
     261                }
     262
     263
     264                if(report->use_report_ids != 0) {
    252265                        field->offset += 8;
    253266                        report->use_report_ids = 1;
    254267                }
     268
    255269                field->item_flags = report_item->item_flags;
    256270
     
    322336                                usb_hid_report_description_t, link);
    323337
    324                 if((report_des->report_id == report_id) &&
     338                // if report id not set, return the first of the type
     339                if(((report_des->report_id == report_id) || (report_id == 0)) &&
    325340                   (report_des->type == type)) {
    326341                        return report_des;
  • uspace/lib/usbhid/src/hidparser.c

    r2002595 rb9e3aa3  
    153153
    154154
    155         report_des = usb_hid_report_find_description(report, *report_id, type);
     155        report_des = usb_hid_report_find_description(report, *report_id,
     156                type);
     157
    156158        if(report_des == NULL) {
    157159                return EINVAL;
     
    167169                if(USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) == 0) {
    168170                       
    169                         if(USB_HID_ITEM_FLAG_VARIABLE(item->item_flags) == 0) {
     171                        if(USB_HID_ITEM_FLAG_VARIABLE(item->item_flags) == 0){
    170172
    171173                                // array
     
    174176               
    175177                                item->usage = USB_HID_EXTENDED_USAGE(
    176                                     item->usages[item->value - item->physical_minimum]);
    177 
    178                                 item->usage_page = USB_HID_EXTENDED_USAGE_PAGE(
    179                                     item->usages[item->value - item->physical_minimum]);
    180 
    181                                 usb_hid_report_set_last_item (item->collection_path,
    182                                     USB_HID_TAG_CLASS_GLOBAL, item->usage_page);
    183 
    184                                 usb_hid_report_set_last_item (item->collection_path,
     178                                    item->usages[
     179                                    item->value - item->physical_minimum]);
     180
     181                                item->usage_page =
     182                                    USB_HID_EXTENDED_USAGE_PAGE(
     183                                    item->usages[
     184                                    item->value - item->physical_minimum]);
     185
     186                                usb_hid_report_set_last_item (
     187                                    item->collection_path,
     188                                    USB_HID_TAG_CLASS_GLOBAL,
     189                                    item->usage_page);
     190
     191                                usb_hid_report_set_last_item (
     192                                    item->collection_path,
    185193                                    USB_HID_TAG_CLASS_LOCAL, item->usage);
    186194                               
     
    188196                        else {
    189197                                // variable item
    190                                 item->value = usb_hid_translate_data(item, data);                               
    191                         }                               
     198                                item->value = usb_hid_translate_data(item,
     199                                    data);                             
     200                        }                       
    192201                }
    193202                list_item = list_item->next;
     
    213222       
    214223        int32_t value=0;
    215         int32_t mask;
    216         const uint8_t *foo;
     224        int32_t mask=0;
     225        const uint8_t *foo=0;
    217226
    218227        // now only shot tags are allowed
     
    240249        if((size_t)(offset/8) != (size_t)((offset+item->size-1)/8)) {
    241250               
    242                 part_size = ((offset+item->size)%8);
     251                part_size = 0;
    243252
    244253                size_t i=0;
     
    246255                        if(i == (size_t)(offset/8)) {
    247256                                // the higher one
     257                                part_size = 8 - (offset % 8);
    248258                                foo = data + i;
    249259                                mask =  ((1 << (item->size-part_size))-1);
    250                                 value = (*foo & mask) << part_size;
     260                                value = (*foo & mask);
    251261                        }
    252262                        else if(i == ((offset+item->size-1)/8)){
    253263                                // the lower one
    254264                                foo = data + i;
    255                                 mask =  ((1 << part_size)-1) << (8-part_size);
    256                                 value += ((*foo & mask) >> (8-part_size));
     265                                mask = ((1 << (item->size - part_size)) - 1)
     266                                        << (8 - (item->size - part_size));
     267
     268                                value = (((*foo & mask) >> (8 -
     269                                    (item->size - part_size))) << part_size )
     270                                    + value;
    257271                        }
    258272                        else {
    259                                 value = value << 8;
    260                                 value += *(data + 1);
     273                                value = (*(data + 1) << (part_size + 8)) + value;
     274                                part_size += 8;
    261275                        }
    262276                }
     
    375389                report_item = list_get_instance(item, usb_hid_report_field_t, link);
    376390
    377                 if(USB_HID_ITEM_FLAG_VARIABLE(report_item->item_flags) == 0) {
    378                                        
    379                         // array
    380                         value = usb_hid_translate_data_reverse(report_item,
    381                                 report_item->value);
    382 
    383                         offset = report_item->offset;
    384                         length = report_item->size;
    385                 }
    386                 else {
    387                         // variable item
    388                         value  = usb_hid_translate_data_reverse(report_item,
    389                                 report_item->value);
    390 
    391                         offset = report_item->offset;
    392                         length = report_item->size;
    393                 }
    394 
     391                value = usb_hid_translate_data_reverse(report_item,
     392                        report_item->value);
     393
     394                offset = report_des->bit_length - report_item->offset - 1;
     395                length = report_item->size;
     396               
    395397                usb_log_debug("\ttranslated value: %x\n", value);
    396398
     
    617619                        return report_des->report_id;
    618620                }
     621
     622                report_it = report_it->next;
    619623        }
    620624
  • uspace/lib/usbhid/src/hidpath.c

    r2002595 rb9e3aa3  
    211211
    212212        if(report_path->report_id != path->report_id) {
    213                 return 1;
     213                if(path->report_id != 0) {
     214                        return 1;
     215                }
    214216        }
    215217
Note: See TracChangeset for help on using the changeset viewer.