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