Ignore:
Timestamp:
2011-04-01T14:41:35Z (13 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
03eea27, 8e7d724
Parents:
98169ab (diff), e4153ea (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:

Using HID parser Output report API in KBD driver.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/classes/hidparser.h

    r98169ab r1b9c0e2  
    3131 */
    3232/** @file
    33  * @brief USB HID parser.
     33 * USB HID report descriptor and report data parser
    3434 */
    3535#ifndef LIBUSB_HIDPARSER_H_
     
    7474#define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY    4
    7575
     76/** */
    7677typedef struct {
     78        /** */
    7779        int32_t usage_page;
     80        /** */ 
    7881        int32_t usage;
    79 
     82        /** */
    8083        link_t link;
    8184} usb_hid_report_usage_path_t;
    8285
     86/** */
    8387typedef struct {
     88        /** */ 
    8489        int depth;     
     90       
     91        /** */ 
    8592        link_t link;
    8693} usb_hid_report_path_t;
     
    9097 */
    9198typedef struct {
     99        /** */ 
    92100        int32_t id;
     101        /** */ 
    93102        int32_t usage_minimum;
     103        /** */ 
    94104        int32_t usage_maximum;
     105        /** */ 
    95106        int32_t logical_minimum;
     107        /** */ 
    96108        int32_t logical_maximum;
     109        /** */ 
    97110        int32_t size;
     111        /** */ 
    98112        int32_t count;
     113        /** */ 
    99114        size_t offset;
     115        /** */ 
    100116        int32_t delimiter;
    101 
     117        /** */ 
    102118        int32_t unit_exponent;
     119        /** */ 
    103120        int32_t unit;
    104121
    105         /*
    106          * some not yet used fields
    107          */
     122        /** */
    108123        int32_t string_index;
     124        /** */ 
    109125        int32_t string_minimum;
     126        /** */ 
    110127        int32_t string_maximum;
     128        /** */ 
    111129        int32_t designator_index;
     130        /** */ 
    112131        int32_t designator_minimum;
     132        /** */ 
    113133        int32_t designator_maximum;
     134        /** */ 
    114135        int32_t physical_minimum;
     136        /** */ 
    115137        int32_t physical_maximum;
    116138
     139        /** */ 
    117140        uint8_t item_flags;
    118141
     142        /** */ 
    119143        usb_hid_report_path_t *usage_path;
     144        /** */ 
    120145        link_t link;
    121146} usb_hid_report_item_t;
     
    124149/** HID report parser structure. */
    125150typedef struct {       
     151        /** */ 
    126152        link_t input;
     153        /** */ 
    127154        link_t output;
     155        /** */ 
    128156        link_t feature;
    129157} usb_hid_report_parser_t;     
     
    154182} usb_hid_modifiers_t;
    155183
    156 typedef enum {
    157         USB_HID_LED_NUM_LOCK = 0x1,
    158         USB_HID_LED_CAPS_LOCK = 0x2,
    159         USB_HID_LED_SCROLL_LOCK = 0x4,
    160         USB_HID_LED_COMPOSE = 0x8,
    161         USB_HID_LED_KANA = 0x10,
    162         USB_HID_LED_COUNT = 5
    163 } usb_hid_led_t;
     184//typedef enum {
     185//      USB_HID_LED_NUM_LOCK = 0x1,
     186//      USB_HID_LED_CAPS_LOCK = 0x2,
     187//      USB_HID_LED_SCROLL_LOCK = 0x4,
     188//      USB_HID_LED_COMPOSE = 0x8,
     189//      USB_HID_LED_KANA = 0x10,
     190//      USB_HID_LED_COUNT = 5
     191//} usb_hid_led_t;
    164192
    165193static const usb_hid_modifiers_t
     
    190218
    191219/*
    192  * modifiers definitions
    193  */
    194 
     220 * Descriptor parser functions
     221 */
     222/** */
     223int usb_hid_parser_init(usb_hid_report_parser_t *parser);
     224
     225/** */
     226int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser,
     227    const uint8_t *data, size_t size);
     228
     229/** */
     230void usb_hid_free_report_parser(usb_hid_report_parser_t *parser);
     231
     232/** */
     233void usb_hid_descriptor_print(usb_hid_report_parser_t *parser);
     234
     235/*
     236 * Boot protocol functions
     237 */
     238/** */
    195239int usb_hid_boot_keyboard_input_report(const uint8_t *data, size_t size,
    196240        const usb_hid_report_in_callbacks_t *callbacks, void *arg);
    197241
     242/** */
    198243int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size);
    199244
    200 int usb_hid_parser_init(usb_hid_report_parser_t *parser);
    201 int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser,
    202     const uint8_t *data, size_t size);
    203 
     245
     246/*
     247 * Input report parser functions
     248 */
     249/** */
    204250int usb_hid_parse_report(const usb_hid_report_parser_t *parser, 
    205251    const uint8_t *data, size_t size,
     
    207253    const usb_hid_report_in_callbacks_t *callbacks, void *arg);
    208254
    209 int usb_hid_report_input_length(const usb_hid_report_parser_t *parser,
     255/** */
     256size_t usb_hid_report_input_length(const usb_hid_report_parser_t *parser,
    210257        usb_hid_report_path_t *path, int flags);
    211258
    212259
    213 void usb_hid_free_report_parser(usb_hid_report_parser_t *parser);
    214 
    215 void usb_hid_descriptor_print(usb_hid_report_parser_t *parser);
    216 
    217 /* usage path functions */
     260
     261/*
     262 * usage path functions
     263 */
     264/** */
    218265usb_hid_report_path_t *usb_hid_report_path(void);
     266
     267/** */
    219268void usb_hid_report_path_free(usb_hid_report_path_t *path);
     269
     270/** */
    220271int usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, int32_t usage_page, int32_t usage);
     272
     273/** */
    221274void usb_hid_report_remove_last_item(usb_hid_report_path_t *usage_path);
     275
     276/** */
    222277void usb_hid_report_null_last_item(usb_hid_report_path_t *usage_path);
     278
     279/** */
    223280void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path, int32_t tag, int32_t data);
     281
     282/** */
    224283int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path, usb_hid_report_path_t *path, int flags);
    225 int     usb_hid_report_path_clone(usb_hid_report_path_t *new_usage_path, usb_hid_report_path_t *usage_path);
    226 
    227 
    228 // output
    229 //      - funkce co vrati cesty poli v output reportu
    230 //      - funkce co pro danou cestu nastavi data
    231 //      - finalize
    232 
     284
     285/** */
     286usb_hid_report_path_t *usb_hid_report_path_clone(usb_hid_report_path_t *usage_path);
     287
     288
     289/*
     290 * Output report parser functions
     291 */
     292/** Allocates output report buffer*/
     293uint8_t *usb_hid_report_output(usb_hid_report_parser_t *parser, size_t *size);
     294
     295/** Frees output report buffer*/
     296void usb_hid_report_output_free(uint8_t *output);
     297
     298/** Returns size of output for given usage path */
     299size_t usb_hid_report_output_size(usb_hid_report_parser_t *parser,
     300                                  usb_hid_report_path_t *path, int flags);
     301
     302/** Updates the output report buffer by translated given data */
     303int usb_hid_report_output_translate(usb_hid_report_parser_t *parser,
     304                                    usb_hid_report_path_t *path, int flags,
     305                                    uint8_t *buffer, size_t size,
     306                                    int32_t *data, size_t data_size);
    233307#endif
    234308/**
Note: See TracChangeset for help on using the changeset viewer.