Ignore:
File:
1 edited

Legend:

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

    rfa8d346 r65b458c4  
    6262static size_t usb_generic_hid_get_event_length(ddf_fun_t *fun);
    6363
    64 static int usb_generic_hid_get_event(ddf_fun_t *fun, uint8_t *buffer,
     64static int usb_generic_hid_get_event(ddf_fun_t *fun, int32_t *buffer,
    6565    size_t size, size_t *act_size, unsigned int flags);
    6666
    6767static int usb_generic_hid_client_connected(ddf_fun_t *fun);
    68 
    69 static size_t usb_generic_get_report_descriptor_length(ddf_fun_t *fun);
    70 
    71 static int usb_generic_get_report_descriptor(ddf_fun_t *fun, uint8_t *desc,
    72     size_t size, size_t *actual_size);
    7368
    7469/*----------------------------------------------------------------------------*/
     
    7671static usbhid_iface_t usb_generic_iface = {
    7772        .get_event = usb_generic_hid_get_event,
    78         .get_event_length = usb_generic_hid_get_event_length,
    79         .get_report_descriptor_length = usb_generic_get_report_descriptor_length,
    80         .get_report_descriptor = usb_generic_get_report_descriptor
     73        .get_event_length = usb_generic_hid_get_event_length
    8174};
    8275
     
    9083static size_t usb_generic_hid_get_event_length(ddf_fun_t *fun)
    9184{
    92         usb_log_debug("Generic HID: Get event length (fun: %p, "
    93             "fun->driver_data: %p.\n", fun, fun->driver_data);
    94        
    95         if (fun == NULL || fun->driver_data == NULL) {
     85        if (fun == NULL || fun->driver_data) {
    9686                return 0;
    9787        }
     
    9989        usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data;
    10090       
    101         usb_log_debug("hid_dev: %p, Max input report size (%d).\n",
    102             hid_dev, hid_dev->max_input_report_size);
    103        
    104         return hid_dev->max_input_report_size;
     91        return hid_dev->input_report_size;
    10592}
    10693
    10794/*----------------------------------------------------------------------------*/
    10895
    109 static int usb_generic_hid_get_event(ddf_fun_t *fun, uint8_t *buffer,
     96static int usb_generic_hid_get_event(ddf_fun_t *fun, int32_t *buffer,
    11097    size_t size, size_t *act_size, unsigned int flags)
    11198{
    112         usb_log_debug("Generic HID: Get event.\n");
    113        
    114         if (fun == NULL || fun->driver_data == NULL) {
    115                 usb_log_debug("No function");
     99        if (fun == NULL || fun->driver_data) {
    116100                return EINVAL;
    117101        }
     
    142126/*----------------------------------------------------------------------------*/
    143127
    144 static size_t usb_generic_get_report_descriptor_length(ddf_fun_t *fun)
    145 {
    146         usb_log_debug("Generic HID: Get report descriptor length.\n");
    147        
    148         if (fun == NULL || fun->driver_data == NULL) {
    149                 usb_log_debug("No function");
    150                 return EINVAL;
    151         }
    152        
    153         usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data;
    154        
    155         printf("hid_dev->report_desc_size = %zu\n", hid_dev->report_desc_size);
    156        
    157         return hid_dev->report_desc_size;
    158 }
    159 
    160 /*----------------------------------------------------------------------------*/
    161 
    162 static int usb_generic_get_report_descriptor(ddf_fun_t *fun, uint8_t *desc,
    163     size_t size, size_t *actual_size)
    164 {
    165         usb_log_debug("Generic HID: Get report descriptor.\n");
    166        
    167         if (fun == NULL || fun->driver_data == NULL) {
    168                 usb_log_debug("No function");
    169                 return EINVAL;
    170         }
    171        
    172         usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data;
    173        
    174         if (hid_dev->report_desc_size > size) {
    175                 return EINVAL;  // TODO: other error code
    176         }
    177        
    178         memcpy(desc, hid_dev->report_desc, hid_dev->report_desc_size);
    179         *actual_size = hid_dev->report_desc_size;
    180        
    181         return EOK;
    182 }
    183 
    184 /*----------------------------------------------------------------------------*/
    185 
    186128static int usb_generic_hid_client_connected(ddf_fun_t *fun)
    187129{
    188         usb_log_debug("Generic HID: Client connected.\n");
    189130        usb_hid_report_received();
    190131        return EOK;
     
    204145                return ENOMEM;
    205146        }
    206        
    207         fun->ops = &usb_generic_hid_ops;
    208         fun->driver_data = hid_dev;
    209147
    210148        int rc = ddf_fun_bind(fun);
     
    216154        }
    217155       
    218         usb_log_debug("HID function created. Handle: %d\n", fun->handle);
     156        fun->ops = &usb_generic_hid_ops;
     157        fun->driver_data = hid_dev;
    219158       
    220159        return EOK;
Note: See TracChangeset for help on using the changeset viewer.