Changeset 31cfee16 in mainline for uspace/drv/usbhid/kbd/kbddev.c


Ignore:
Timestamp:
2011-05-03T09:16:39Z (13 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3facf63a
Parents:
30710035
Message:

Creating DDF functions in subdrivers + saving input report.

  • Keyboard function.
  • Mouse function.
  • Lgtch UltraX function - added to class keyboard.
  • Saving input report in hid dev structure.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhid/kbd/kbddev.c

    r30710035 r31cfee16  
    766766
    767767/*----------------------------------------------------------------------------*/
     768
     769static int usb_kbd_create_function(usb_hid_dev_t *hid_dev)
     770{
     771        assert(hid_dev != NULL);
     772        assert(hid_dev->usb_dev != NULL);
     773       
     774        /* Create the function exposed under /dev/devices. */
     775        usb_log_debug("Creating DDF function %s...\n", HID_KBD_FUN_NAME);
     776        ddf_fun_t *fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed,
     777            HID_KBD_FUN_NAME);
     778        if (fun == NULL) {
     779                usb_log_error("Could not create DDF function node.\n");
     780                return ENOMEM;
     781        }
     782       
     783        /*
     784         * Store the initialized HID device and HID ops
     785         * to the DDF function.
     786         */
     787        fun->ops = &hid_dev->ops;
     788        fun->driver_data = hid_dev;   // TODO: maybe change to hid_dev->data
     789
     790        int rc = ddf_fun_bind(fun);
     791        if (rc != EOK) {
     792                usb_log_error("Could not bind DDF function: %s.\n",
     793                    str_error(rc));
     794                ddf_fun_destroy(fun);
     795                return rc;
     796        }
     797       
     798        usb_log_debug("Adding DDF function to class %s...\n",
     799            HID_KBD_CLASS_NAME);
     800        rc = ddf_fun_add_to_class(fun, HID_KBD_CLASS_NAME);
     801        if (rc != EOK) {
     802                usb_log_error(
     803                    "Could not add DDF function to class %s: %s.\n",
     804                    HID_KBD_CLASS_NAME, str_error(rc));
     805                ddf_fun_destroy(fun);
     806                return rc;
     807        }
     808       
     809        return EOK;
     810}
     811
     812/*----------------------------------------------------------------------------*/
    768813/* API functions                                                              */
    769814/*----------------------------------------------------------------------------*/
     
    930975        usb_log_debug("HID/KBD device structure initialized.\n");
    931976       
     977        usb_log_debug("Creating KBD function...\n");
     978        int rc = usb_kbd_create_function(hid_dev);
     979        if (rc != EOK) {
     980                usb_kbd_free(&kbd_dev);
     981                return rc;
     982        }
     983       
    932984        return EOK;
    933985}
Note: See TracChangeset for help on using the changeset viewer.