Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 243cb86 in mainline for uspace/drv/usbkbd/main.c


Ignore:
Timestamp:
2010-12-12T10:50:19Z (11 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master
Children:
8365533
Parents:
101ef25c (diff), ebb98c5 (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:

Merge from development + several changes to hid driver.

Changes to hid driver:

  • copied some code to usbkbd_get_descriptors() function
  • base structure for hid descriptor and report parser (files uspace/lib/usb/include/usb/classes/hidparser.h

and uspace/lib/usb/src/hidparser.c)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbkbd/main.c

    r101ef25c r243cb86  
    3232#include <fibril.h>
    3333#include <usb/classes/hid.h>
     34#include <usb/classes/hidparser.h>
     35#include <usb/devreq.h>
    3436
    3537#define BUFFER_SIZE 32
     
    3739
    3840static const usb_endpoint_t CONTROL_EP = 0;
     41
     42/*
     43 * Callbacks for parser
     44 */
     45static void usbkbd_process_keycodes(const uint16_t *key_codes, size_t count,
     46                                    void *arg)
     47{
     48
     49}
     50
     51/*
     52 * Kbd functions
     53 */
     54static int usbkbd_get_descriptors()
     55{
     56        // copy-pasted:
     57       
     58        /* Prepare the setup packet. */
     59        usb_device_request_setup_packet_t setup_packet = {
     60                .request_type = 128,
     61                .request = USB_DEVREQ_GET_DESCRIPTOR,
     62                .index = 0,
     63                .length = sizeof(usb_standard_device_descriptor_t)
     64        };
     65       
     66        setup_packet.value_high = USB_DESCTYPE_DEVICE;
     67        setup_packet.value_low = 0;
     68
     69        /* Prepare local descriptor. */
     70        size_t actually_transferred = 0;
     71        usb_standard_device_descriptor_t descriptor_tmp;
     72
     73        /* Perform the control read transaction. */
     74        int rc = usb_drv_psync_control_read(phone, target,
     75            &setup_packet, sizeof(setup_packet),
     76            &descriptor_tmp, sizeof(descriptor_tmp), &actually_transferred);
     77
     78        if (rc != EOK) {
     79                return rc;
     80        }
     81       
     82        // end of copy-paste
     83}
    3984
    4085static usb_hid_dev_kbd_t *usbkbd_init_device(device_t *dev)
     
    68113
    69114        // TODO: get descriptors
    70 
     115        usbkbd_get_descriptors();
    71116        // TODO: parse descriptors and save endpoints
    72117
     
    75120
    76121static void usbkbd_process_interrupt_in(usb_hid_dev_kbd_t *kbd_dev,
    77                                         char *buffer, size_t actual_size)
     122                                        uint8_t *buffer, size_t actual_size)
    78123{
    79124        /*
     
    81126         * now only take last 6 bytes and process, i.e. send to kbd
    82127         */
     128
     129        usb_hid_report_in_callbacks_t *callbacks =
     130            (usb_hid_report_in_callbacks_t *)malloc(
     131                sizeof(usb_hid_report_in_callbacks_t));
     132        callbacks->keyboard = usbkbd_process_keycodes;
     133
     134        usb_hid_parse_report(kbd_dev->parser, buffer, callbacks, NULL);
    83135}
    84136
     
    87139        int rc;
    88140        usb_handle_t handle;
    89         char buffer[BUFFER_SIZE];
     141        uint8_t buffer[BUFFER_SIZE];
    90142        size_t actual_size;
    91143        //usb_endpoint_t poll_endpoint = 1;
Note: See TracChangeset for help on using the changeset viewer.