Changeset 61257f4 in mainline for uspace/drv/usbhid/usbhid.h


Ignore:
Timestamp:
2011-04-07T20:19:24Z (14 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f8e8738
Parents:
fd9ba204
Message:

Initial implementation of general HID driver.

  • Should handle:
    • keyboard (most of functions from usbkbd driver), more-or-less works
    • mouse (not implemented yet)
    • generic HID device (just dummy polling callback now)
File:
1 edited

Legend:

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

    rfd9ba204 r61257f4  
    4242
    4343//#include <usb/classes/hid.h>
    44 //#include <usb/classes/hidparser.h>
     44#include <usb/classes/hidparser.h>
    4545#include <ddf/driver.h>
    4646#include <usb/pipes.h>
    4747#include <usb/devdrv.h>
     48#include <usb/classes/hid.h>
    4849
    4950/*----------------------------------------------------------------------------*/
    50 ///**
    51 // * USB/HID keyboard device type.
    52 // *
    53 // * Holds a reference to generic USB/HID device structure and keyboard-specific
    54 // * data, such as currently pressed keys, modifiers and lock keys.
    55 // *
    56 // * Also holds a IPC phone to the console (since there is now no other way to
    57 // * communicate with it).
    58 // *
    59 // * @note Storing active lock keys in this structure results in their setting
    60 // *       being device-specific.
    61 // */
    62 //typedef struct usb_kbd_t {
    63 //      /** Structure holding generic USB device information. */
    64 //      //usbhid_dev_t *hid_dev;
    65 //      usb_device_t *usb_dev;
     51/**
     52 * Structure for holding general HID device data.
     53 */
     54typedef struct usb_hid_dev_t {
     55        /** Structure holding generic USB device information. */
     56        usb_device_t *usb_dev;
    6657       
    67 //      /** Currently pressed keys (not translated to key codes). */
    68 //      uint8_t *keys;
    69 //      /** Count of stored keys (i.e. number of keys in the report). */
    70 //      size_t key_count;
    71 //      /** Currently pressed modifiers (bitmap). */
    72 //      uint8_t modifiers;
     58        /** @todo What is this actually? */
     59        ddf_dev_ops_t ops;
    7360       
    74 //      /** Currently active modifiers including locks. Sent to the console. */
    75 //      unsigned mods;
     61        /** Index of the polling pipe in usb_hid_endpoints array. */
     62        int poll_pipe_index;
    7663       
    77 //      /** Currently active lock keys. */
    78 //      unsigned lock_keys;
     64        /** Function to be called when data arrives from the device. */
     65        usb_polling_callback_t poll_callback;
    7966       
    80 //      /** IPC phone to the console device (for sending key events). */
    81 //      int console_phone;
     67        /** Report descriptor. */
     68        uint8_t *report_desc;
     69
     70        /** Report descriptor size. */
     71        size_t report_desc_size;
    8272       
    83 //      /** Information for auto-repeat of keys. */
    84 //      usb_kbd_repeat_t repeat;
     73        /** HID Report parser. */
     74        usb_hid_report_parser_t *parser;
    8575       
    86 //      /** Mutex for accessing the information about auto-repeat. */
    87 //      fibril_mutex_t *repeat_mtx;
     76        /** Arbitrary data (e.g. a special structure for handling keyboard). */
     77        void *data;
    8878       
    89 //      /** Report descriptor. */
    90 //      uint8_t *report_desc;
    91 
    92 //      /** Report descriptor size. */
    93 //      size_t report_desc_size;
    94        
    95 //      uint8_t *output_buffer;
    96        
    97 //      size_t output_size;
    98        
    99 //      size_t led_output_size;
    100        
    101 //      usb_hid_report_path_t *led_path;
    102        
    103 //      int32_t *led_data;
    104 
    105 //      /** HID Report parser. */
    106 //      usb_hid_report_parser_t *parser;
    107        
    108 //      /** State of the structure (for checking before use).
    109 //       *
    110 //       * 0 - not initialized
    111 //       * 1 - initialized
    112 //       * -1 - ready for destroying
    113 //       */
    114 //      int initialized;
    115 //} usb_kbd_t;
     79        /** Type of the device (keyboard, mouse, generic HID device). */
     80        usb_hid_iface_protocol_t device_type;
     81} usb_hid_dev_t;
    11682
    11783/*----------------------------------------------------------------------------*/
    11884
    11985enum {
    120         USB_HID_POLL_EP_NO = 0,
    121         USB_HID_POLL_EP_COUNT = 1
     86        USB_HID_KBD_POLL_EP_NO = 0,
     87        USB_HID_MOUSE_POLL_EP_NO = 1,
     88        USB_HID_GENERIC_POLL_EP_NO = 2,
     89        USB_HID_POLL_EP_COUNT = 3
    12290};
    12391
    12492usb_endpoint_description_t *usb_hid_endpoints[USB_HID_POLL_EP_COUNT + 1];
    12593
    126 ddf_dev_ops_t hid_ops;
    127 
    12894/*----------------------------------------------------------------------------*/
    12995
    130 bool usb_hid_polling_callback(usb_device_t *dev, uint8_t *buffer,
    131      size_t buffer_size, void *arg);
     96usb_hid_dev_t *usb_hid_new(void);
    13297
    133 void usb_hid_polling_ended_callback(usb_device_t *dev, bool reason,
     98int usb_hid_init(usb_hid_dev_t *hid_dev, usb_device_t *dev);
     99
     100void usb_hid_polling_ended_callback(usb_device_t *dev, bool reason,
    134101     void *arg);
    135102
    136 #endif /* USB_KBDDEV_H_ */
     103const char *usb_hid_get_function_name(usb_hid_iface_protocol_t device_type);
     104
     105const char *usb_hid_get_class_name(usb_hid_iface_protocol_t device_type);
     106
     107/** @todo Maybe not needed in the API. */
     108void usb_hid_free(usb_hid_dev_t **hid_dev);
     109
     110#endif /* USB_USBHID_H_ */
    137111
    138112/**
Note: See TracChangeset for help on using the changeset viewer.