Changeset 76fbd9a in mainline for uspace/drv/bus/usb/usbhid


Ignore:
Timestamp:
2012-02-24T19:07:44Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a76b01b4
Parents:
5837c7a
Message:

usb drivers: remove optical separators

Location:
uspace/drv/bus/usb/usbhid
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhid/generic/hiddev.c

    r5837c7a r76fbd9a  
    4646#include "usbhid.h"
    4747
    48 /*----------------------------------------------------------------------------*/
     48
    4949
    5050const usb_endpoint_description_t usb_hid_generic_poll_endpoint_description = {
     
    6060const char *HID_GENERIC_CLASS_NAME = "hid";
    6161
    62 /*----------------------------------------------------------------------------*/
     62
    6363static size_t usb_generic_hid_get_event_length(ddf_fun_t *fun);
    6464static int usb_generic_hid_get_event(ddf_fun_t *fun, uint8_t *buffer,
     
    6868static int usb_generic_get_report_descriptor(ddf_fun_t *fun, uint8_t *desc,
    6969    size_t size, size_t *actual_size);
    70 /*----------------------------------------------------------------------------*/
     70
    7171static usbhid_iface_t usb_generic_iface = {
    7272        .get_event = usb_generic_hid_get_event,
     
    7575        .get_report_descriptor = usb_generic_get_report_descriptor
    7676};
    77 /*----------------------------------------------------------------------------*/
     77
    7878static ddf_dev_ops_t usb_generic_hid_ops = {
    7979        .interfaces[USBHID_DEV_IFACE] = &usb_generic_iface,
    8080        .open = usb_generic_hid_client_connected
    8181};
    82 /*----------------------------------------------------------------------------*/
     82
    8383static size_t usb_generic_hid_get_event_length(ddf_fun_t *fun)
    8484{
     
    9797        return hid_dev->max_input_report_size;
    9898}
    99 /*----------------------------------------------------------------------------*/
     99
    100100static int usb_generic_hid_get_event(ddf_fun_t *fun, uint8_t *buffer,
    101101    size_t size, size_t *act_size, int *event_nr, unsigned int flags)
     
    127127        return EOK;
    128128}
    129 /*----------------------------------------------------------------------------*/
     129
    130130static size_t usb_generic_get_report_descriptor_length(ddf_fun_t *fun)
    131131{
     
    144144        return hid_dev->report_desc_size;
    145145}
    146 /*----------------------------------------------------------------------------*/
     146
    147147static int usb_generic_get_report_descriptor(ddf_fun_t *fun, uint8_t *desc,
    148148    size_t size, size_t *actual_size)
     
    166166        return EOK;
    167167}
    168 /*----------------------------------------------------------------------------*/
     168
    169169static int usb_generic_hid_client_connected(ddf_fun_t *fun)
    170170{
     
    172172        return EOK;
    173173}
    174 /*----------------------------------------------------------------------------*/
     174
    175175void usb_generic_hid_deinit(usb_hid_dev_t *hid_dev, void *data)
    176176{
     
    189189        ddf_fun_destroy(fun);
    190190}
    191 /*----------------------------------------------------------------------------*/
     191
    192192int usb_generic_hid_init(usb_hid_dev_t *hid_dev, void **data)
    193193{
     
    224224        return EOK;
    225225}
    226 /*----------------------------------------------------------------------------*/
     226
    227227bool usb_generic_hid_polling_callback(usb_hid_dev_t *hid_dev, void *data)
    228228{
  • uspace/drv/bus/usb/usbhid/generic/hiddev.h

    r5837c7a r76fbd9a  
    4747const char *HID_GENERIC_CLASS_NAME;
    4848
    49 /*----------------------------------------------------------------------------*/
     49
    5050
    5151int usb_generic_hid_init(struct usb_hid_dev *hid_dev, void **data);
  • uspace/drv/bus/usb/usbhid/kbd/kbddev.c

    r5837c7a r76fbd9a  
    7373static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
    7474static ddf_dev_ops_t kbdops = { .default_handler = default_connection_handler };
    75 /*----------------------------------------------------------------------------*/
     75
    7676
    7777static const unsigned DEFAULT_ACTIVE_MODS = KM_NUM_LOCK;
     
    8888static const unsigned int DEFAULT_REPEAT_DELAY = 50 * 1000;
    8989
    90 /*----------------------------------------------------------------------------*/
     90
    9191/** Keyboard polling endpoint description for boot protocol class. */
    9292const usb_endpoint_description_t usb_hid_kbd_poll_endpoint_description = {
     
    103103
    104104static void usb_kbd_set_led(usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev);
    105 /*----------------------------------------------------------------------------*/
     105
    106106static const uint8_t USB_KBD_BOOT_REPORT_DESCRIPTOR[] = {
    107107        0x05, 0x01,  /* Usage Page (Generic Desktop), */
     
    138138        0xC0         /* End Collection */
    139139};
    140 /*----------------------------------------------------------------------------*/
     140
    141141typedef enum usb_kbd_flags {
    142142        USB_KBD_STATUS_UNINITIALIZED = 0,
     
    144144        USB_KBD_STATUS_TO_DESTROY = -1
    145145} usb_kbd_flags;
    146 /*----------------------------------------------------------------------------*/
     146
    147147/* IPC method handler                                                         */
    148 /*----------------------------------------------------------------------------*/
     148
    149149/**
    150150 * Default handler for IPC methods not handled by DDF.
     
    208208
    209209}
    210 /*----------------------------------------------------------------------------*/
     210
    211211/* Key processing functions                                                   */
    212 /*----------------------------------------------------------------------------*/
     212
    213213/**
    214214 * Handles turning of LED lights on and off.
     
    283283        }
    284284}
    285 /*----------------------------------------------------------------------------*/
     285
    286286/** Send key event.
    287287 *
     
    308308        }
    309309}
    310 /*----------------------------------------------------------------------------*/
     310
    311311static inline int usb_kbd_is_lock(unsigned int key_code)
    312312{
     
    315315            || key_code == KC_CAPS_LOCK);
    316316}
    317 /*----------------------------------------------------------------------------*/
     317
    318318static size_t find_in_array_int32(int32_t val, int32_t *arr, size_t arr_size)
    319319{
     
    326326        return (size_t) -1;
    327327}
    328 /*----------------------------------------------------------------------------*/
     328
    329329/**
    330330 * Checks if some keys were pressed or released and generates key events.
     
    409409        usb_log_debug2("Stored keys %s.\n", key_buffer);
    410410}
    411 /*----------------------------------------------------------------------------*/
     411
    412412/* General kbd functions                                                      */
    413 /*----------------------------------------------------------------------------*/
     413
    414414/**
    415415 * Processes data received from the device in form of report.
     
    481481        usb_kbd_check_key_changes(hid_dev, kbd_dev);
    482482}
    483 /*----------------------------------------------------------------------------*/
     483
    484484/* HID/KBD structure manipulation                                             */
    485 /*----------------------------------------------------------------------------*/
     485
    486486static int usb_kbd_create_function(usb_kbd_t *kbd_dev)
    487487{
     
    537537        return EOK;
    538538}
    539 /*----------------------------------------------------------------------------*/
     539
    540540/* API functions                                                              */
    541 /*----------------------------------------------------------------------------*/
     541
    542542/**
    543543 * Initialization of the USB/HID keyboard structure.
     
    701701        return EOK;
    702702}
    703 /*----------------------------------------------------------------------------*/
     703
    704704bool usb_kbd_polling_callback(usb_hid_dev_t *hid_dev, void *data)
    705705{
     
    715715        return true;
    716716}
    717 /*----------------------------------------------------------------------------*/
     717
    718718int usb_kbd_is_initialized(const usb_kbd_t *kbd_dev)
    719719{
    720720        return (kbd_dev->initialized == USB_KBD_STATUS_INITIALIZED);
    721721}
    722 /*----------------------------------------------------------------------------*/
     722
    723723int usb_kbd_is_ready_to_destroy(const usb_kbd_t *kbd_dev)
    724724{
    725725        return (kbd_dev->initialized == USB_KBD_STATUS_TO_DESTROY);
    726726}
    727 /*----------------------------------------------------------------------------*/
     727
    728728/**
    729729 * Properly destroys the USB/HID keyboard structure.
     
    766766        free(kbd_dev);
    767767}
    768 /*----------------------------------------------------------------------------*/
     768
    769769void usb_kbd_deinit(usb_hid_dev_t *hid_dev, void *data)
    770770{
     
    779779        }
    780780}
    781 /*----------------------------------------------------------------------------*/
     781
    782782int usb_kbd_set_boot_protocol(usb_hid_dev_t *hid_dev)
    783783{
  • uspace/drv/bus/usb/usbhid/kbd/kbddev.h

    r5837c7a r76fbd9a  
    5050struct usb_hid_dev;
    5151
    52 /*----------------------------------------------------------------------------*/
     52
    5353/**
    5454 * USB/HID keyboard device type.
     
    113113} usb_kbd_t;
    114114
    115 /*----------------------------------------------------------------------------*/
     115
    116116
    117117extern const usb_endpoint_description_t usb_hid_kbd_poll_endpoint_description;
     
    120120const char *HID_KBD_CLASS_NAME;
    121121
    122 /*----------------------------------------------------------------------------*/
     122
    123123
    124124int usb_kbd_init(struct usb_hid_dev *hid_dev, void **data);
  • uspace/drv/bus/usb/usbhid/kbd/kbdrepeat.c

    r5837c7a r76fbd9a  
    105105        }
    106106}
    107 /*----------------------------------------------------------------------------*/
     107
    108108/**
    109109 * Main routine to be executed by a fibril for handling auto-repeat.
     
    132132        return EOK;
    133133}
    134 /*----------------------------------------------------------------------------*/
     134
    135135/**
    136136 * Start repeating particular key.
     
    149149        fibril_mutex_unlock(&kbd->repeat_mtx);
    150150}
    151 /*----------------------------------------------------------------------------*/
     151
    152152/**
    153153 * Stop repeating particular key.
  • uspace/drv/bus/usb/usbhid/kbd/kbdrepeat.h

    r5837c7a r76fbd9a  
    4242struct usb_kbd_t;
    4343
    44 /*----------------------------------------------------------------------------*/
     44
    4545/**
    4646 * Structure for keeping information needed for auto-repeat of keys.
     
    5757} usb_kbd_repeat_t;
    5858
    59 /*----------------------------------------------------------------------------*/
     59
    6060
    6161int usb_kbd_repeat_fibril(void *arg);
  • uspace/drv/bus/usb/usbhid/main.c

    r5837c7a r76fbd9a  
    113113        return EOK;
    114114}
    115 /*----------------------------------------------------------------------------*/
     115
    116116/**
    117117 * Callback for a device about to be removed from the driver.
     
    126126        return ENOTSUP;
    127127}
    128 /*----------------------------------------------------------------------------*/
     128
    129129/**
    130130 * Callback for removing a device from the driver.
     
    152152        return EOK;
    153153}
    154 /*----------------------------------------------------------------------------*/
     154
    155155/** USB generic driver callbacks */
    156156static const usb_driver_ops_t usb_hid_driver_ops = {
     
    159159        .device_gone = usb_hid_device_gone,
    160160};
    161 /*----------------------------------------------------------------------------*/
     161
    162162/** The driver itself. */
    163163static const usb_driver_t usb_hid_driver = {
     
    166166        .endpoints = usb_hid_endpoints
    167167};
    168 /*----------------------------------------------------------------------------*/
     168
    169169int main(int argc, char *argv[])
    170170{
  • uspace/drv/bus/usb/usbhid/mouse/mousedev.c

    r5837c7a r76fbd9a  
    5858static ddf_dev_ops_t ops = { .default_handler = default_connection_handler };
    5959
    60 /*----------------------------------------------------------------------------*/
     60
    6161const usb_endpoint_description_t usb_hid_mouse_poll_endpoint_description = {
    6262        .transfer_type = USB_TRANSFER_INTERRUPT,
     
    7474static const uint8_t IDLE_RATE = 0;
    7575
    76 /*----------------------------------------------------------------------------*/
     76
    7777static const uint8_t USB_MOUSE_BOOT_REPORT_DESCRIPTOR[] = {
    7878        0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
     
    104104};
    105105
    106 /*----------------------------------------------------------------------------*/
     106
    107107
    108108/** Default handler for IPC methods not handled by DDF.
     
    146146        }
    147147}
    148 /*----------------------------------------------------------------------------*/
     148
    149149static int get_mouse_axis_move_value(uint8_t rid, usb_hid_report_t *report,
    150150    int32_t usage)
     
    245245        return true;
    246246}
    247 /*----------------------------------------------------------------------------*/
     247
    248248#define FUN_UNBIND_DESTROY(fun) \
    249249if (fun) { \
     
    256256        } \
    257257} else (void)0
    258 /*----------------------------------------------------------------------------*/
     258
    259259static int usb_mouse_create_function(usb_hid_dev_t *hid_dev, usb_mouse_t *mouse)
    260260{
     
    337337        return highest_button;
    338338}
    339 /*----------------------------------------------------------------------------*/
     339
    340340int usb_mouse_init(usb_hid_dev_t *hid_dev, void **data)
    341341{
     
    387387        return EOK;
    388388}
    389 /*----------------------------------------------------------------------------*/
     389
    390390bool usb_mouse_polling_callback(usb_hid_dev_t *hid_dev, void *data)
    391391{
     
    400400        return usb_mouse_process_report(hid_dev, mouse_dev);
    401401}
    402 /*----------------------------------------------------------------------------*/
     402
    403403void usb_mouse_deinit(usb_hid_dev_t *hid_dev, void *data)
    404404{
     
    421421        free(mouse_dev);
    422422}
    423 /*----------------------------------------------------------------------------*/
     423
    424424int usb_mouse_set_boot_protocol(usb_hid_dev_t *hid_dev)
    425425{
  • uspace/drv/bus/usb/usbhid/mouse/mousedev.h

    r5837c7a r76fbd9a  
    4242struct usb_hid_dev;
    4343
    44 /*----------------------------------------------------------------------------*/
     44
    4545
    4646/** Container for USB mouse device. */
     
    5757} usb_mouse_t;
    5858
    59 /*----------------------------------------------------------------------------*/
     59
    6060
    6161extern const usb_endpoint_description_t usb_hid_mouse_poll_endpoint_description;
     
    6464const char *HID_MOUSE_CATEGORY;
    6565
    66 /*----------------------------------------------------------------------------*/
     66
    6767
    6868int usb_mouse_init(struct usb_hid_dev *hid_dev, void **data);
     
    7474int usb_mouse_set_boot_protocol(struct usb_hid_dev *hid_dev);
    7575
    76 /*----------------------------------------------------------------------------*/
     76
    7777
    7878#endif // USB_HID_MOUSEDEV_H_
  • uspace/drv/bus/usb/usbhid/multimedia/multimedia.c

    r5837c7a r76fbd9a  
    5454#define NAME  "multimedia-keys"
    5555
    56 /*----------------------------------------------------------------------------*/
     56
    5757/**
    5858 * Logitech UltraX device type.
     
    7070
    7171
    72 /*----------------------------------------------------------------------------*/
     72
    7373/**
    7474 * Default handler for IPC methods not handled by DDF.
     
    106106                async_answer_0(icallid, EINVAL);
    107107}
    108 /*----------------------------------------------------------------------------*/
     108
    109109static ddf_dev_ops_t multimedia_ops = {
    110110        .default_handler = default_connection_handler
    111111};
    112 /*----------------------------------------------------------------------------*/
     112
    113113/**
    114114 * Processes key events.
     
    155155        }
    156156}
    157 /*----------------------------------------------------------------------------*/
     157
    158158int usb_multimedia_init(struct usb_hid_dev *hid_dev, void **data)
    159159{
     
    216216        return EOK;
    217217}
    218 /*----------------------------------------------------------------------------*/
     218
    219219void usb_multimedia_deinit(struct usb_hid_dev *hid_dev, void *data)
    220220{
     
    239239        }
    240240}
    241 /*----------------------------------------------------------------------------*/
     241
    242242bool usb_multimedia_polling_callback(struct usb_hid_dev *hid_dev, void *data)
    243243{
  • uspace/drv/bus/usb/usbhid/multimedia/multimedia.h

    r5837c7a r76fbd9a  
    4141struct usb_hid_dev;
    4242
    43 /*----------------------------------------------------------------------------*/
     43
    4444
    4545int usb_multimedia_init(struct usb_hid_dev *hid_dev, void **data);
     
    4949bool usb_multimedia_polling_callback(struct usb_hid_dev *hid_dev, void *data);
    5050
    51 /*----------------------------------------------------------------------------*/
     51
    5252
    5353#endif // USB_HID_MULTIMEDIA_H_
  • uspace/drv/bus/usb/usbhid/subdrivers.h

    r5837c7a r76fbd9a  
    4040#include "kbd/kbddev.h"
    4141
    42 /*----------------------------------------------------------------------------*/
     42
    4343
    4444typedef struct usb_hid_subdriver_usage {
     
    4747} usb_hid_subdriver_usage_t;
    4848
    49 /*----------------------------------------------------------------------------*/
     49
    5050
    5151/** Structure representing the mapping between device requirements and the
     
    8181} usb_hid_subdriver_mapping_t;
    8282
    83 /*----------------------------------------------------------------------------*/
     83
    8484
    8585extern const usb_hid_subdriver_mapping_t usb_hid_subdrivers[];
    8686extern const size_t USB_HID_MAX_SUBDRIVERS;
    8787
    88 /*----------------------------------------------------------------------------*/
     88
    8989
    9090#endif /* USB_HID_SUBDRIVERS_H_ */
  • uspace/drv/bus/usb/usbhid/usbhid.c

    r5837c7a r76fbd9a  
    5858        NULL
    5959};
    60 /*----------------------------------------------------------------------------*/
     60
    6161static int usb_hid_set_boot_kbd_subdriver(usb_hid_dev_t *hid_dev)
    6262{
     
    7474        return EOK;
    7575}
    76 /*----------------------------------------------------------------------------*/
     76
    7777static int usb_hid_set_boot_mouse_subdriver(usb_hid_dev_t *hid_dev)
    7878{
     
    9090        return EOK;
    9191}
    92 /*----------------------------------------------------------------------------*/
     92
    9393static int usb_hid_set_generic_hid_subdriver(usb_hid_dev_t *hid_dev)
    9494{
     
    110110        return EOK;
    111111}
    112 /*----------------------------------------------------------------------------*/
     112
    113113static bool usb_hid_ids_match(const usb_hid_dev_t *hid_dev,
    114114    const usb_hid_subdriver_mapping_t *mapping)
     
    122122            == mapping->product_id);
    123123}
    124 /*----------------------------------------------------------------------------*/
     124
    125125static bool usb_hid_path_matches(usb_hid_dev_t *hid_dev,
    126126    const usb_hid_subdriver_mapping_t *mapping)
     
    178178        return matches;
    179179}
    180 /*----------------------------------------------------------------------------*/
     180
    181181static int usb_hid_save_subdrivers(usb_hid_dev_t *hid_dev,
    182182    const usb_hid_subdriver_t **subdrivers, unsigned count)
     
    211211        return EOK;
    212212}
    213 /*----------------------------------------------------------------------------*/
     213
    214214static int usb_hid_find_subdrivers(usb_hid_dev_t *hid_dev)
    215215{
     
    263263        return usb_hid_save_subdrivers(hid_dev, subdrivers, count);
    264264}
    265 /*----------------------------------------------------------------------------*/
     265
    266266static int usb_hid_check_pipes(usb_hid_dev_t *hid_dev, const usb_device_t *dev)
    267267{
     
    290290        return ENOTSUP;
    291291}
    292 /*----------------------------------------------------------------------------*/
     292
    293293static int usb_hid_init_report(usb_hid_dev_t *hid_dev)
    294294{
     
    322322        return EOK;
    323323}
    324 /*----------------------------------------------------------------------------*/
     324
    325325/*
    326326 * This functions initializes required structures from the device's descriptors
     
    458458        return rc;
    459459}
    460 /*----------------------------------------------------------------------------*/
     460
    461461bool usb_hid_polling_callback(usb_device_t *dev, uint8_t *buffer,
    462462    size_t buffer_size, void *arg)
     
    500500        return cont;
    501501}
    502 /*----------------------------------------------------------------------------*/
     502
    503503void usb_hid_polling_ended_callback(usb_device_t *dev, bool reason, void *arg)
    504504{
     
    517517        hid_dev->running = false;
    518518}
    519 /*----------------------------------------------------------------------------*/
     519
    520520void usb_hid_new_report(usb_hid_dev_t *hid_dev)
    521521{
    522522        ++hid_dev->report_nr;
    523523}
    524 /*----------------------------------------------------------------------------*/
     524
    525525int usb_hid_report_number(const usb_hid_dev_t *hid_dev)
    526526{
    527527        return hid_dev->report_nr;
    528528}
    529 /*----------------------------------------------------------------------------*/
     529
    530530void usb_hid_deinit(usb_hid_dev_t *hid_dev)
    531531{
  • uspace/drv/bus/usb/usbhid/usbhid.h

    r5837c7a r76fbd9a  
    9595};
    9696
    97 /*----------------------------------------------------------------------------*/
     97
    9898/**
    9999 * Structure for holding general HID device data.
     
    132132};
    133133
    134 /*----------------------------------------------------------------------------*/
     134
    135135
    136136enum {
     
    143143extern const usb_endpoint_description_t *usb_hid_endpoints[];
    144144
    145 /*----------------------------------------------------------------------------*/
     145
    146146
    147147int usb_hid_init(usb_hid_dev_t *hid_dev, usb_device_t *dev);
Note: See TracChangeset for help on using the changeset viewer.