keyboard.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #ifndef __KEYBOARD_H
  2. #define __KEYBOARD_H
  3. #ifdef CONFIG_DM_KEYBOARD
  4. #include <input.h>
  5. #include <stdio_dev.h>
  6. /**
  7. * struct keyboard_priv - information about a keyboard, for the uclass
  8. *
  9. * @sdev: stdio device
  10. * @input: input configuration (the driver may use this if desired)
  11. */
  12. struct keyboard_priv {
  13. struct stdio_dev sdev;
  14. /*
  15. * This is set up by the uclass but will only be used if the driver
  16. * sets input.dev to its device pointer (it is initially NULL).
  17. */
  18. struct input_config input;
  19. };
  20. /**
  21. * struct keyboard_ops - keyboard device operations
  22. */
  23. struct keyboard_ops {
  24. /**
  25. * start() - enable the keyboard ready for use
  26. *
  27. * @dev: Device to enable
  28. * @return 0 if OK, -ve on error
  29. */
  30. int (*start)(struct udevice *dev);
  31. /**
  32. * stop() - disable the keyboard when no-longer needed
  33. *
  34. * @dev: Device to disable
  35. * @return 0 if OK, -ve on error
  36. */
  37. int (*stop)(struct udevice *dev);
  38. /**
  39. * tstc() - check if a key is available
  40. *
  41. * @dev: Device to check
  42. * @return 0 if no key is available, 1 if a key is available, -ve on
  43. * error
  44. */
  45. int (*tstc)(struct udevice *dev);
  46. /**
  47. * getc() - get a key
  48. *
  49. * TODO(sjg@chromium.org): At present this method may wait if it calls
  50. * input_getc().
  51. *
  52. * @dev: Device to read from
  53. * @return -EAGAIN if no key is available, otherwise key value read
  54. * (as ASCII).
  55. */
  56. int (*getc)(struct udevice *dev);
  57. /**
  58. * update_leds() - update keyboard LEDs
  59. *
  60. * This is called when the LEDs have changed and need to be updated.
  61. * For example, if 'caps lock' is pressed then this method will be
  62. * called with the new LED value.
  63. *
  64. * @dev: Device to update
  65. * @leds: New LED mask (see INPUT_LED_... in input.h)
  66. */
  67. int (*update_leds)(struct udevice *dev, int leds);
  68. };
  69. #define keyboard_get_ops(dev) ((struct keyboard_ops *)(dev)->driver->ops)
  70. #else
  71. #ifdef CONFIG_PS2MULT
  72. #include <ps2mult.h>
  73. #endif
  74. #if !defined(kbd_request_region) || \
  75. !defined(kbd_request_irq) || \
  76. !defined(kbd_read_input) || \
  77. !defined(kbd_read_status) || \
  78. !defined(kbd_write_output) || \
  79. !defined(kbd_write_command)
  80. #error PS/2 low level routines not defined
  81. #endif
  82. extern int kbd_init (void);
  83. extern void handle_scancode(unsigned char scancode);
  84. extern int kbd_init_hw(void);
  85. extern void pckbd_leds(unsigned char leds);
  86. #endif /* !CONFIG_DM_KEYBOARD */
  87. #if defined(CONFIG_MPC5xxx) || defined(CONFIG_ARCH_MPC8540) || \
  88. defined(CONFIG_ARCH_MPC8541) || defined(CONFIG_ARCH_MPC8555)
  89. int ps2ser_check(void);
  90. #endif
  91. #endif /* __KEYBOARD_H */