keyboard.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef __KEYBOARD_H
  2. #define __KEYBOARD_H
  3. #include <input.h>
  4. #include <stdio_dev.h>
  5. /**
  6. * struct keyboard_priv - information about a keyboard, for the uclass
  7. *
  8. * @sdev: stdio device
  9. * @input: input configuration (the driver may use this if desired)
  10. */
  11. struct keyboard_priv {
  12. struct stdio_dev sdev;
  13. /*
  14. * This is set up by the uclass but will only be used if the driver
  15. * sets input.dev to its device pointer (it is initially NULL).
  16. */
  17. struct input_config input;
  18. };
  19. /**
  20. * struct keyboard_ops - keyboard device operations
  21. */
  22. struct keyboard_ops {
  23. /**
  24. * start() - enable the keyboard ready for use
  25. *
  26. * @dev: Device to enable
  27. * @return 0 if OK, -ve on error
  28. */
  29. int (*start)(struct udevice *dev);
  30. /**
  31. * stop() - disable the keyboard when no-longer needed
  32. *
  33. * @dev: Device to disable
  34. * @return 0 if OK, -ve on error
  35. */
  36. int (*stop)(struct udevice *dev);
  37. /**
  38. * tstc() - check if a key is available
  39. *
  40. * @dev: Device to check
  41. * @return 0 if no key is available, 1 if a key is available, -ve on
  42. * error
  43. */
  44. int (*tstc)(struct udevice *dev);
  45. /**
  46. * getc() - get a key
  47. *
  48. * TODO(sjg@chromium.org): At present this method may wait if it calls
  49. * input_getc().
  50. *
  51. * @dev: Device to read from
  52. * @return -EAGAIN if no key is available, otherwise key value read
  53. * (as ASCII).
  54. */
  55. int (*getc)(struct udevice *dev);
  56. /**
  57. * update_leds() - update keyboard LEDs
  58. *
  59. * This is called when the LEDs have changed and need to be updated.
  60. * For example, if 'caps lock' is pressed then this method will be
  61. * called with the new LED value.
  62. *
  63. * @dev: Device to update
  64. * @leds: New LED mask (see INPUT_LED_... in input.h)
  65. */
  66. int (*update_leds)(struct udevice *dev, int leds);
  67. };
  68. #define keyboard_get_ops(dev) ((struct keyboard_ops *)(dev)->driver->ops)
  69. #endif /* __KEYBOARD_H */