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

Changeset 91db50ac in mainline for uspace/drv/usbkbd/main.c


Ignore:
Timestamp:
2010-11-19T21:50:46Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial
Children:
7034be15
Parents:
63b4f90
Message:

USB driver to HC communication uses DDF interfaces

Started work on using interfaces on the background of communication
between HC and USB driver. However, for driver developers, this will
be hidden completely.

File:
1 edited

Legend:

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

    r63b4f90 r91db50ac  
    3030#include <errno.h>
    3131
     32#define BUFFER_SIZE 32
     33
     34/* Call this periodically to check keyboard status changes. */
     35static void poll_keyboard(device_t *dev)
     36{
     37        int rc;
     38        usb_handle_t handle;
     39        char buffer[BUFFER_SIZE];
     40        size_t actual_size;
     41        usb_endpoint_t poll_endpoint = 1;
     42
     43        rc = usb_drv_async_interrupt_in(dev->parent_phone, poll_endpoint,
     44            buffer, BUFFER_SIZE, &actual_size, &handle);
     45        if (rc != EOK) {
     46                return;
     47        }
     48
     49        rc = usb_drv_async_wait_for(handle);
     50        if (rc != EOK) {
     51                return;
     52        }
     53
     54        /*
     55         * If the keyboard answered with NAK, it returned no data.
     56         * This implies that no change happened since last query.
     57         */
     58        if (actual_size == 0) {
     59                return;
     60        }
     61
     62        /*
     63         * Process pressed keys.
     64         */
     65}
     66
    3267static int add_kbd_device(device_t *dev)
    3368{
     
    3873         * When everything is okay, connect to "our" HC.
    3974         */
    40         int rc = usb_drv_hc_connect(dev, 0);
    41         if (rc != EOK) {
     75        int phone = usb_drv_hc_connect(dev, 0);
     76        if (phone < 0) {
    4277                /*
    4378                 * Connecting to HC failed, roll-back and announce
    4479                 * failure.
    4580                 */
    46                 return rc;
     81                return phone;
    4782        }
     83
     84        dev->parent_phone = phone;
     85
     86        /*
     87         * Just for fun ;-).
     88         */
     89        poll_keyboard(dev);
    4890
    4991        /*
Note: See TracChangeset for help on using the changeset viewer.