]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h
Clean up the private GUID definition in module Level.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbKbDxe / KeyBoard.h
... / ...
CommitLineData
1/** @file\r
2 Function prototype for USB Keyboard Driver.\r
3\r
4Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef _EFI_KEYBOARD_H_\r
16#define _EFI_KEYBOARD_H_\r
17\r
18\r
19#include "EfiKey.h"\r
20\r
21#define USB_KEYBOARD_KEY_COUNT 104\r
22\r
23#define USB_KEYBOARD_LANGUAGE_STR_LEN 5 // RFC4646 Language Code: "en-US"\r
24#define USB_KEYBOARD_DESCRIPTION_STR_LEN (16 + 1) // Description: "English Keyboard"\r
25\r
26#pragma pack (1)\r
27typedef struct {\r
28 //\r
29 // This 4-bytes total array length is required by PreparePackageList()\r
30 //\r
31 UINT32 Length;\r
32\r
33 //\r
34 // Keyboard Layout package definition\r
35 //\r
36 EFI_HII_PACKAGE_HEADER PackageHeader;\r
37 UINT16 LayoutCount;\r
38\r
39 //\r
40 // EFI_HII_KEYBOARD_LAYOUT\r
41 //\r
42 UINT16 LayoutLength;\r
43 EFI_GUID Guid;\r
44 UINT32 LayoutDescriptorStringOffset;\r
45 UINT8 DescriptorCount;\r
46 EFI_KEY_DESCRIPTOR KeyDescriptor[USB_KEYBOARD_KEY_COUNT];\r
47 UINT16 DescriptionCount;\r
48 CHAR16 Language[USB_KEYBOARD_LANGUAGE_STR_LEN];\r
49 CHAR16 Space;\r
50 CHAR16 DescriptionString[USB_KEYBOARD_DESCRIPTION_STR_LEN];\r
51} USB_KEYBOARD_LAYOUT_PACK_BIN;\r
52#pragma pack()\r
53/**\r
54 Uses USB I/O to check whether the device is a USB keyboard device.\r
55\r
56 @param UsbIo Pointer to a USB I/O protocol instance.\r
57\r
58 @retval TRUE Device is a USB keyboard device.\r
59 @retval FALSE Device is a not USB keyboard device.\r
60\r
61**/\r
62BOOLEAN\r
63IsUSBKeyboard (\r
64 IN EFI_USB_IO_PROTOCOL *UsbIo\r
65 );\r
66\r
67/**\r
68 Initialize USB keyboard device and all private data structures.\r
69\r
70 @param UsbKeyboardDevice The USB_KB_DEV instance.\r
71\r
72 @retval EFI_SUCCESS Initialization is successful.\r
73 @retval EFI_DEVICE_ERROR Keyboard initialization failed.\r
74\r
75**/\r
76EFI_STATUS\r
77InitUSBKeyboard (\r
78 IN OUT USB_KB_DEV *UsbKeyboardDevice\r
79 );\r
80\r
81/**\r
82 Initialize USB keyboard layout.\r
83\r
84 This function initializes Key Convertion Table for the USB keyboard device.\r
85 It first tries to retrieve layout from HII database. If failed and default\r
86 layout is enabled, then it just uses the default layout.\r
87\r
88 @param UsbKeyboardDevice The USB_KB_DEV instance.\r
89\r
90 @retval EFI_SUCCESS Initialization succeeded.\r
91 @retval EFI_NOT_READY Keyboard layout cannot be retrieve from HII\r
92 database, and default layout is disabled.\r
93 @retval Other Fail to register event to EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group.\r
94\r
95**/\r
96EFI_STATUS\r
97InitKeyboardLayout (\r
98 OUT USB_KB_DEV *UsbKeyboardDevice\r
99 );\r
100\r
101/**\r
102 Destroy resources for keyboard layout.\r
103\r
104 @param UsbKeyboardDevice The USB_KB_DEV instance.\r
105\r
106**/\r
107VOID\r
108ReleaseKeyboardLayoutResources (\r
109 IN OUT USB_KB_DEV *UsbKeyboardDevice\r
110 );\r
111\r
112/**\r
113 Handler function for USB keyboard's asynchronous interrupt transfer.\r
114\r
115 This function is the handler function for USB keyboard's asynchronous interrupt transfer\r
116 to manage the keyboard. It parses the USB keyboard input report, and inserts data to\r
117 keyboard buffer according to state of modifer keys and normal keys. Timer for repeat key\r
118 is also set accordingly.\r
119\r
120 @param Data A pointer to a buffer that is filled with key data which is\r
121 retrieved via asynchronous interrupt transfer.\r
122 @param DataLength Indicates the size of the data buffer.\r
123 @param Context Pointing to USB_KB_DEV instance.\r
124 @param Result Indicates the result of the asynchronous interrupt transfer.\r
125\r
126 @retval EFI_SUCCESS Asynchronous interrupt transfer is handled successfully.\r
127 @retval EFI_DEVICE_ERROR Hardware error occurs.\r
128\r
129**/\r
130EFI_STATUS\r
131EFIAPI\r
132KeyboardHandler (\r
133 IN VOID *Data,\r
134 IN UINTN DataLength,\r
135 IN VOID *Context,\r
136 IN UINT32 Result\r
137 );\r
138\r
139/**\r
140 Handler for Delayed Recovery event.\r
141\r
142 This function is the handler for Delayed Recovery event triggered\r
143 by timer.\r
144 After a device error occurs, the event would be triggered\r
145 with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY\r
146 is defined in USB standard for error handling.\r
147\r
148 @param Event The Delayed Recovery event.\r
149 @param Context Points to the USB_KB_DEV instance.\r
150\r
151**/\r
152VOID\r
153EFIAPI\r
154USBKeyboardRecoveryHandler (\r
155 IN EFI_EVENT Event,\r
156 IN VOID *Context\r
157 );\r
158\r
159/**\r
160 Retrieves a USB keycode after parsing the raw data in keyboard buffer.\r
161\r
162 This function parses keyboard buffer. It updates state of modifier key for\r
163 USB_KB_DEV instancem, and returns keycode for output.\r
164\r
165 @param UsbKeyboardDevice The USB_KB_DEV instance.\r
166 @param KeyCode Pointer to the USB keycode for output.\r
167\r
168 @retval EFI_SUCCESS Keycode successfully parsed.\r
169 @retval EFI_NOT_READY Keyboard buffer is not ready for a valid keycode\r
170\r
171**/\r
172EFI_STATUS\r
173USBParseKey (\r
174 IN OUT USB_KB_DEV *UsbKeyboardDevice,\r
175 OUT UINT8 *KeyCode\r
176 );\r
177\r
178/**\r
179 Converts USB Keycode ranging from 0x4 to 0x65 to EFI_INPUT_KEY.\r
180\r
181 @param UsbKeyboardDevice The USB_KB_DEV instance.\r
182 @param KeyCode Indicates the key code that will be interpreted.\r
183 @param KeyData A pointer to a buffer that is filled in with\r
184 the keystroke information for the key that\r
185 was pressed.\r
186\r
187 @retval EFI_SUCCESS Success.\r
188 @retval EFI_INVALID_PARAMETER KeyCode is not in the range of 0x4 to 0x65.\r
189 @retval EFI_INVALID_PARAMETER Translated EFI_INPUT_KEY has zero for both ScanCode and UnicodeChar.\r
190 @retval EFI_NOT_READY KeyCode represents a dead key with EFI_NS_KEY_MODIFIER\r
191 @retval EFI_DEVICE_ERROR Keyboard layout is invalid.\r
192\r
193**/\r
194EFI_STATUS\r
195UsbKeyCodeToEfiInputKey (\r
196 IN USB_KB_DEV *UsbKeyboardDevice,\r
197 IN UINT8 KeyCode,\r
198 OUT EFI_KEY_DATA *KeyData\r
199 );\r
200\r
201\r
202/**\r
203 Create the queue.\r
204\r
205 @param Queue Points to the queue.\r
206 @param ItemSize Size of the single item.\r
207\r
208**/\r
209VOID\r
210InitQueue (\r
211 IN OUT USB_SIMPLE_QUEUE *Queue,\r
212 IN UINTN ItemSize\r
213 );\r
214\r
215/**\r
216 Destroy the queue\r
217\r
218 @param Queue Points to the queue.\r
219**/\r
220VOID\r
221DestroyQueue (\r
222 IN OUT USB_SIMPLE_QUEUE *Queue\r
223 );\r
224\r
225\r
226/**\r
227 Check whether the queue is empty.\r
228\r
229 @param Queue Points to the queue.\r
230\r
231 @retval TRUE Queue is empty.\r
232 @retval FALSE Queue is not empty.\r
233\r
234**/\r
235BOOLEAN\r
236IsQueueEmpty (\r
237 IN USB_SIMPLE_QUEUE *Queue\r
238 );\r
239\r
240\r
241/**\r
242 Check whether the queue is full.\r
243\r
244 @param Queue Points to the queue.\r
245\r
246 @retval TRUE Queue is full.\r
247 @retval FALSE Queue is not full.\r
248\r
249**/\r
250BOOLEAN\r
251IsQueueFull (\r
252 IN USB_SIMPLE_QUEUE *Queue\r
253 );\r
254\r
255\r
256/**\r
257 Enqueue the item to the queue.\r
258\r
259 @param Queue Points to the queue.\r
260 @param Item Points to the item to be enqueued.\r
261 @param ItemSize Size of the item.\r
262**/\r
263VOID\r
264Enqueue (\r
265 IN OUT USB_SIMPLE_QUEUE *Queue,\r
266 IN VOID *Item,\r
267 IN UINTN ItemSize\r
268 );\r
269\r
270\r
271/**\r
272 Dequeue a item from the queue.\r
273\r
274 @param Queue Points to the queue.\r
275 @param Item Receives the item.\r
276 @param ItemSize Size of the item.\r
277\r
278 @retval EFI_SUCCESS Item was successfully dequeued.\r
279 @retval EFI_DEVICE_ERROR The queue is empty.\r
280\r
281**/\r
282EFI_STATUS\r
283Dequeue (\r
284 IN OUT USB_SIMPLE_QUEUE *Queue,\r
285 OUT VOID *Item,\r
286 IN UINTN ItemSize\r
287 );\r
288\r
289/**\r
290 Handler for Repeat Key event.\r
291\r
292 This function is the handler for Repeat Key event triggered\r
293 by timer.\r
294 After a repeatable key is pressed, the event would be triggered\r
295 with interval of USBKBD_REPEAT_DELAY. Once the event is triggered,\r
296 following trigger will come with interval of USBKBD_REPEAT_RATE.\r
297\r
298 @param Event The Repeat Key event.\r
299 @param Context Points to the USB_KB_DEV instance.\r
300\r
301**/\r
302VOID\r
303EFIAPI\r
304USBKeyboardRepeatHandler (\r
305 IN EFI_EVENT Event,\r
306 IN VOID *Context\r
307 );\r
308\r
309/**\r
310 Sets USB keyboard LED state.\r
311\r
312 @param UsbKeyboardDevice The USB_KB_DEV instance.\r
313\r
314**/\r
315VOID\r
316SetKeyLED (\r
317 IN USB_KB_DEV *UsbKeyboardDevice\r
318 );\r
319\r
320#endif\r