Changeset 175ad13e in mainline for uspace/lib/usb/include


Ignore:
Timestamp:
2011-04-15T15:19:34Z (14 years ago)
Author:
Matej Klonfar <maklf@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
681f24b3
Parents:
9698695
Message:

new report structure

Location:
uspace/lib/usb/include/usb/classes
Files:
3 edited

Legend:

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

    r9698695 r175ad13e  
    5050        USB_HIDREQ_SET_PROTOCOL = 11
    5151} usb_hid_request_t;
    52 
    53 typedef enum {
    54         USB_HID_REPORT_TYPE_INPUT = 1,
    55         USB_HID_REPORT_TYPE_OUTPUT = 2,
    56         USB_HID_REPORT_TYPE_FEATURE = 3
    57 } usb_hid_report_type_t;
    5852
    5953typedef enum {
  • uspace/lib/usb/include/usb/classes/hidparser.h

    r9698695 r175ad13e  
    7474#define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY    4
    7575
    76 /** */
    77 typedef struct {
    78         /** */
    79         int32_t usage_page;
    80         /** */ 
    81         int32_t usage;
     76
     77#define USB_HID_MAX_USAGES      20
     78
     79typedef enum {
     80        USB_HID_REPORT_TYPE_INPUT = 1,
     81        USB_HID_REPORT_TYPE_OUTPUT = 2,
     82        USB_HID_REPORT_TYPE_FEATURE = 3
     83} usb_hid_report_type_t;
     84
     85/** Collection usage path structure */
     86typedef struct {
     87        /** */
     88        uint32_t usage_page;
     89        /** */ 
     90        uint32_t usage;
     91
     92        uint8_t flags;
    8293        /** */
    8394        link_t link;
     
    95106} usb_hid_report_path_t;
    96107
    97 /**
    98  * Description of report items
    99  */
    100 typedef struct {
    101         /** */ 
     108
     109typedef struct {
     110        /** */
     111        int report_count;
     112        link_t reports;         /** list of usb_hid_report_description_t */
     113
     114        link_t collection_paths;
     115        int collection_paths_count;
     116
     117        int use_report_ids;
     118       
     119} usb_hid_report_t;
     120
     121typedef struct {
     122        uint8_t report_id;
     123        usb_hid_report_type_t type;
     124
     125        size_t bit_length;
     126        size_t item_length;
     127       
     128        link_t report_items;    /** list of report items (fields) */
     129
     130        link_t link;
     131} usb_hid_report_description_t;
     132
     133typedef struct {
     134
     135        int offset;
     136        size_t size;
     137
     138        uint16_t usage_page;
     139        uint16_t usage;
     140
     141        uint8_t item_flags;
     142        usb_hid_report_path_t *collection_path;
     143
     144        int32_t logical_minimum;
     145        int32_t logical_maximum;
     146        int32_t physical_minimum;
     147        int32_t physical_maximum;
     148        uint32_t usage_minimum;
     149        uint32_t usage_maximum;
     150        uint32_t unit;
     151        uint32_t unit_exponent;
     152       
     153
     154        int32_t value;
     155
     156        link_t link;
     157} usb_hid_report_field_t;
     158
     159
     160
     161/**
     162 * state table
     163 */
     164typedef struct {
     165        /** report id */       
    102166        int32_t id;
    103         /** */ 
    104         int32_t usage_minimum;
    105         /** */ 
    106         int32_t usage_maximum;
     167       
     168        /** */
     169        uint16_t extended_usage_page;
     170        uint32_t usages[USB_HID_MAX_USAGES];
     171        int usages_count;
     172
     173        /** */
     174        uint32_t usage_page;
     175
     176        /** */ 
     177        uint32_t usage_minimum;
     178        /** */ 
     179        uint32_t usage_maximum;
    107180        /** */ 
    108181        int32_t logical_minimum;
     
    116189        size_t offset;
    117190        /** */ 
    118         int32_t delimiter;
    119         /** */ 
    120191        int32_t unit_exponent;
    121192        /** */ 
     
    123194
    124195        /** */
    125         int32_t string_index;
    126         /** */ 
    127         int32_t string_minimum;
    128         /** */ 
    129         int32_t string_maximum;
    130         /** */ 
    131         int32_t designator_index;
    132         /** */ 
    133         int32_t designator_minimum;
    134         /** */ 
    135         int32_t designator_maximum;
     196        uint32_t string_index;
     197        /** */ 
     198        uint32_t string_minimum;
     199        /** */ 
     200        uint32_t string_maximum;
     201        /** */ 
     202        uint32_t designator_index;
     203        /** */ 
     204        uint32_t designator_minimum;
     205        /** */ 
     206        uint32_t designator_maximum;
    136207        /** */ 
    137208        int32_t physical_minimum;
     
    142213        uint8_t item_flags;
    143214
    144         /** */ 
     215        usb_hid_report_type_t type;
     216
     217        /** current collection path*/   
    145218        usb_hid_report_path_t *usage_path;
    146219        /** */ 
    147220        link_t link;
    148221} usb_hid_report_item_t;
    149 
    150 
    151 /** HID report parser structure. */
    152 typedef struct {       
    153         /** */ 
    154         link_t input;
    155         /** */ 
    156         link_t output;
    157         /** */ 
    158         link_t feature;
    159        
    160         int use_report_id;
    161 
    162         /** */
    163         link_t stack;
    164 } usb_hid_report_parser_t;     
    165 
    166222
    167223/** HID parser callbacks for IN items. */
     
    189245} usb_hid_modifiers_t;
    190246
    191 //typedef enum {
    192 //      USB_HID_LED_NUM_LOCK = 0x1,
    193 //      USB_HID_LED_CAPS_LOCK = 0x2,
    194 //      USB_HID_LED_SCROLL_LOCK = 0x4,
    195 //      USB_HID_LED_COMPOSE = 0x8,
    196 //      USB_HID_LED_KANA = 0x10,
    197 //      USB_HID_LED_COUNT = 5
    198 //} usb_hid_led_t;
    199 
    200247static const usb_hid_modifiers_t
    201248    usb_hid_modifiers_consts[USB_HID_MOD_COUNT] = {
     
    210257};
    211258
    212 //static const usb_hid_led_t usb_hid_led_consts[USB_HID_LED_COUNT] = {
    213 //      USB_HID_LED_NUM_LOCK,
    214 //      USB_HID_LED_CAPS_LOCK,
    215 //      USB_HID_LED_SCROLL_LOCK,
    216 //      USB_HID_LED_COMPOSE,
    217 //      USB_HID_LED_KANA
    218 //};
    219 
    220 //#define USB_HID_BOOT_KEYBOARD_NUM_LOCK                0x01
    221 //#define USB_HID_BOOT_KEYBOARD_CAPS_LOCK               0x02
    222 //#define USB_HID_BOOT_KEYBOARD_SCROLL_LOCK     0x04
    223 //#define USB_HID_BOOT_KEYBOARD_COMPOSE         0x08
    224 //#define USB_HID_BOOT_KEYBOARD_KANA                    0x10
    225 
    226259/*
    227260 * Descriptor parser functions
    228261 */
    229 /** */
    230 int usb_hid_parser_init(usb_hid_report_parser_t *parser);
    231 
    232 /** */
    233 int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser,
     262
     263/** */
     264int usb_hid_parse_report_descriptor(usb_hid_report_t *report,
    234265    const uint8_t *data, size_t size);
    235266
    236267/** */
    237 void usb_hid_free_report_parser(usb_hid_report_parser_t *parser);
    238 
    239 /** */
    240 void usb_hid_descriptor_print(usb_hid_report_parser_t *parser);
     268void usb_hid_free_report(usb_hid_report_t *report);
     269
     270/** */
     271void usb_hid_descriptor_print(usb_hid_report_t *report);
    241272
    242273
     
    245276 */
    246277/** */
    247 int usb_hid_parse_report(const usb_hid_report_parser_t *parser, 
    248     const uint8_t *data, size_t size,
    249     usb_hid_report_path_t *path, int flags,
    250     const usb_hid_report_in_callbacks_t *callbacks, void *arg);
    251 
    252 /** */
    253 size_t usb_hid_report_input_length(const usb_hid_report_parser_t *parser,
     278int usb_hid_parse_report(const usb_hid_report_t *report, const uint8_t *data, size_t size);
     279
     280/** */
     281size_t usb_hid_report_input_length(const usb_hid_report_t *report,
    254282        usb_hid_report_path_t *path, int flags);
    255283
     
    291319 */
    292320/** Allocates output report buffer*/
    293 uint8_t *usb_hid_report_output(usb_hid_report_parser_t *parser, size_t *size, uint8_t report_id);
     321uint8_t *usb_hid_report_output(usb_hid_report_t *report, size_t *size, uint8_t report_id);
    294322
    295323/** Frees output report buffer*/
     
    297325
    298326/** Returns size of output for given usage path */
    299 size_t usb_hid_report_output_size(usb_hid_report_parser_t *parser,
     327size_t usb_hid_report_output_size(usb_hid_report_t *report,
    300328                                  usb_hid_report_path_t *path, int flags);
    301329
    302 /** Updates the output report buffer by translated given data */
    303 int 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);
     330/** Sets data in report structure */
     331int usb_hid_report_output_set_data(usb_hid_report_t *report,
     332                                   usb_hid_report_path_t *path, int flags,
     333                                  int *data, size_t data_size);
     334
     335/** Makes the output report buffer by translated given data */
     336int usb_hid_report_output_translate(usb_hid_report_t *report, uint8_t report_id, uint8_t *buffer, size_t size);
    307337#endif
    308338/**
  • uspace/lib/usb/include/usb/classes/hidreport.h

    r9698695 r175ad13e  
    5757 */
    5858int usb_hid_process_report_descriptor(usb_device_t *dev,
    59     usb_hid_report_parser_t *parser);
     59    usb_hid_report_t *report);
    6060
    6161#endif /* LIBUSB_HIDREPORT_H_ */
Note: See TracChangeset for help on using the changeset viewer.