3 Copyright (c) 2004 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 UsbMouseAbsolutePointer.c
21 #include "UsbMouseAbsolutePointer.h"
23 #include <Library/DebugLib.h>
24 #include <IndustryStandard/Usb.h>
30 // Driver model protocol interface
34 USBMouseAbsolutePointerDriverBindingEntryPoint (
35 IN EFI_HANDLE ImageHandle
,
36 IN EFI_SYSTEM_TABLE
*SystemTable
41 USBMouseAbsolutePointerDriverBindingSupported (
42 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
43 IN EFI_HANDLE Controller
,
44 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
49 USBMouseAbsolutePointerDriverBindingStart (
50 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
51 IN EFI_HANDLE Controller
,
52 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
57 USBMouseAbsolutePointerDriverBindingStop (
58 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
59 IN EFI_HANDLE Controller
,
60 IN UINTN NumberOfChildren
,
61 IN EFI_HANDLE
*ChildHandleBuffer
64 EFI_GUID gEfiUsbMouseAbsolutePointerDriverGuid
= {
65 0xa579f729, 0xa71d, 0x4b45, { 0xbe, 0xd7, 0xd, 0xb0, 0xa8, 0x7c, 0x3e, 0x8d }
68 EFI_DRIVER_BINDING_PROTOCOL gUsbMouseAbsolutePointerDriverBinding
= {
69 USBMouseAbsolutePointerDriverBindingSupported
,
70 USBMouseAbsolutePointerDriverBindingStart
,
71 USBMouseAbsolutePointerDriverBindingStop
,
81 IsUsbMouseAbsolutePointer (
82 IN EFI_USB_IO_PROTOCOL
*UsbIo
86 InitializeUsbMouseAbsolutePointerDevice (
87 IN USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDev
92 UsbMouseAbsolutePointerWaitForInput (
98 // Mouse interrupt handler
102 OnMouseAbsolutePointerInterruptComplete (
110 // Mouse simulate TouchPad, Using AbsolutePointer Protocol
114 GetMouseAbsolutePointerState (
115 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
116 OUT EFI_ABSOLUTE_POINTER_STATE
*MouseAbsolutePointerState
121 UsbMouseAbsolutePointerReset (
122 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
123 IN BOOLEAN ExtendedVerification
131 USBMouseAbsolutePointerDriverBindingEntryPoint (
132 IN EFI_HANDLE ImageHandle
,
133 IN EFI_SYSTEM_TABLE
*SystemTable
138 Entry point for EFI drivers.
141 ImageHandle - EFI_HANDLE
142 SystemTable - EFI_SYSTEM_TABLE
149 return EfiLibInstallDriverBindingComponentName2 (
152 &gUsbMouseAbsolutePointerDriverBinding
,
154 &gUsbMouseAbsolutePointerComponentName
,
155 &gUsbMouseAbsolutePointerComponentName2
161 Test to see if this driver supports ControllerHandle. Any ControllerHandle
162 that has UsbHcProtocol installed will be supported.
164 @param This Protocol instance pointer.
165 @param Controller Handle of device to test
166 @param RemainingDevicePath Not used
168 @retval EFI_SUCCESS This driver supports this device.
169 @retval EFI_UNSUPPORTED This driver does not support this device.
174 USBMouseAbsolutePointerDriverBindingSupported (
175 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
176 IN EFI_HANDLE Controller
,
177 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
180 EFI_STATUS OpenStatus
;
181 EFI_USB_IO_PROTOCOL
*UsbIo
;
184 OpenStatus
= gBS
->OpenProtocol (
186 &gEfiUsbIoProtocolGuid
,
188 This
->DriverBindingHandle
,
190 EFI_OPEN_PROTOCOL_BY_DRIVER
192 if (EFI_ERROR (OpenStatus
) && (OpenStatus
!= EFI_ALREADY_STARTED
)) {
193 return EFI_UNSUPPORTED
;
196 if (OpenStatus
== EFI_ALREADY_STARTED
) {
197 return EFI_ALREADY_STARTED
;
201 // Use the USB I/O protocol interface to see the Controller is
202 // the Mouse controller that can be managed by this driver.
204 Status
= EFI_SUCCESS
;
205 if (!IsUsbMouseAbsolutePointer (UsbIo
)) {
206 Status
= EFI_UNSUPPORTED
;
211 &gEfiUsbIoProtocolGuid
,
212 This
->DriverBindingHandle
,
221 Starting the Usb Bus Driver
223 @param This Protocol instance pointer.
224 @param Controller Handle of device to test
225 @param RemainingDevicePath Not used
227 @retval EFI_SUCCESS This driver supports this device.
228 @retval EFI_UNSUPPORTED This driver does not support this device.
229 @retval EFI_DEVICE_ERROR This driver cannot be started due to device Error
230 EFI_OUT_OF_RESOURCES- Can't allocate memory
232 @retval EFI_ALREADY_STARTED Thios driver has been started
237 USBMouseAbsolutePointerDriverBindingStart (
238 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
239 IN EFI_HANDLE Controller
,
240 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
244 EFI_USB_IO_PROTOCOL
*UsbIo
;
245 EFI_USB_ENDPOINT_DESCRIPTOR
*EndpointDesc
;
246 USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDevice
;
247 UINT8 EndpointNumber
;
250 UINT8 PollingInterval
;
253 UsbMouseAbsolutePointerDevice
= NULL
;
254 Status
= EFI_SUCCESS
;
256 Status
= gBS
->OpenProtocol (
258 &gEfiUsbIoProtocolGuid
,
260 This
->DriverBindingHandle
,
262 EFI_OPEN_PROTOCOL_BY_DRIVER
264 if (EFI_ERROR (Status
)) {
268 UsbMouseAbsolutePointerDevice
= AllocateZeroPool (sizeof (USB_MOUSE_ABSOLUTE_POINTER_DEV
));
269 if (UsbMouseAbsolutePointerDevice
== NULL
) {
270 Status
= EFI_OUT_OF_RESOURCES
;
274 UsbMouseAbsolutePointerDevice
->UsbIo
= UsbIo
;
276 UsbMouseAbsolutePointerDevice
->Signature
= USB_MOUSE_ABSOLUTE_POINTER_DEV_SIGNATURE
;
278 UsbMouseAbsolutePointerDevice
->InterfaceDescriptor
= AllocatePool (sizeof (EFI_USB_INTERFACE_DESCRIPTOR
));
280 if (UsbMouseAbsolutePointerDevice
->InterfaceDescriptor
== NULL
) {
281 Status
= EFI_OUT_OF_RESOURCES
;
285 EndpointDesc
= AllocatePool (sizeof (EFI_USB_ENDPOINT_DESCRIPTOR
));
286 if (EndpointDesc
== NULL
) {
287 Status
= EFI_OUT_OF_RESOURCES
;
291 // Get the Device Path Protocol on Controller's handle
293 Status
= gBS
->OpenProtocol (
295 &gEfiDevicePathProtocolGuid
,
296 (VOID
**) &UsbMouseAbsolutePointerDevice
->DevicePath
,
297 This
->DriverBindingHandle
,
299 EFI_OPEN_PROTOCOL_GET_PROTOCOL
302 if (EFI_ERROR (Status
)) {
306 // Get interface & endpoint descriptor
308 UsbIo
->UsbGetInterfaceDescriptor (
310 UsbMouseAbsolutePointerDevice
->InterfaceDescriptor
313 EndpointNumber
= UsbMouseAbsolutePointerDevice
->InterfaceDescriptor
->NumEndpoints
;
315 for (Index
= 0; Index
< EndpointNumber
; Index
++) {
316 UsbIo
->UsbGetEndpointDescriptor (
322 if ((EndpointDesc
->Attributes
& 0x03) == 0x03) {
325 // We only care interrupt endpoint here
327 UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
= EndpointDesc
;
331 if (UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
== NULL
) {
333 // No interrupt endpoint, then error
335 Status
= EFI_UNSUPPORTED
;
339 Status
= InitializeUsbMouseAbsolutePointerDevice (UsbMouseAbsolutePointerDevice
);
340 if (EFI_ERROR (Status
)) {
341 MouseAbsolutePointerReportStatusCode (
342 UsbMouseAbsolutePointerDevice
->DevicePath
,
343 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
344 PcdGet32 (PcdStatusCodeValueMouseInterfaceError
)
350 UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
.GetState
= GetMouseAbsolutePointerState
;
351 UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
.Reset
= UsbMouseAbsolutePointerReset
;
352 UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
.Mode
= &UsbMouseAbsolutePointerDevice
->AbsolutePointerMode
;
354 Status
= gBS
->CreateEvent (
357 UsbMouseAbsolutePointerWaitForInput
,
358 UsbMouseAbsolutePointerDevice
,
359 &((UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
).WaitForInput
)
361 if (EFI_ERROR (Status
)) {
365 Status
= gBS
->InstallProtocolInterface (
367 &gEfiAbsolutePointerProtocolGuid
,
368 EFI_NATIVE_INTERFACE
,
369 &UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
372 if (EFI_ERROR (Status
)) {
373 Status
= EFI_DEVICE_ERROR
;
378 // After Enabling Async Interrupt Transfer on this mouse Device
379 // we will be able to get key data from it. Thus this is deemed as
380 // the enable action of the mouse
383 MouseAbsolutePointerReportStatusCode (
384 UsbMouseAbsolutePointerDevice
->DevicePath
,
386 PcdGet32 (PcdStatusCodeValueMouseEnable
)
390 // submit async interrupt transfer
392 EndpointAddr
= UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
->EndpointAddress
;
393 PollingInterval
= UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
->Interval
;
394 PacketSize
= (UINT8
) (UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
->MaxPacketSize
);
396 Status
= UsbIo
->UsbAsyncInterruptTransfer (
402 OnMouseAbsolutePointerInterruptComplete
,
403 UsbMouseAbsolutePointerDevice
406 if (!EFI_ERROR (Status
)) {
408 UsbMouseAbsolutePointerDevice
->ControllerNameTable
= NULL
;
411 gUsbMouseAbsolutePointerComponentName
.SupportedLanguages
,
412 &UsbMouseAbsolutePointerDevice
->ControllerNameTable
,
413 L
"Generic Usb Mouse Simulate TouchPad",
418 gUsbMouseAbsolutePointerComponentName2
.SupportedLanguages
,
419 &UsbMouseAbsolutePointerDevice
->ControllerNameTable
,
420 L
"Generic Usb Mouse Simulate TouchPad2",
428 // If submit error, uninstall that interface
430 Status
= EFI_DEVICE_ERROR
;
432 gBS
->UninstallProtocolInterface (
434 &gEfiAbsolutePointerProtocolGuid
,
435 &UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
439 if (EFI_ERROR (Status
)) {
442 &gEfiUsbIoProtocolGuid
,
443 This
->DriverBindingHandle
,
447 if (UsbMouseAbsolutePointerDevice
!= NULL
) {
448 if (UsbMouseAbsolutePointerDevice
->InterfaceDescriptor
!= NULL
) {
449 gBS
->FreePool (UsbMouseAbsolutePointerDevice
->InterfaceDescriptor
);
452 if (UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
!= NULL
) {
453 gBS
->FreePool (UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
);
456 if ((UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
).WaitForInput
!= NULL
) {
457 gBS
->CloseEvent ((UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
).WaitForInput
);
460 gBS
->FreePool (UsbMouseAbsolutePointerDevice
);
461 UsbMouseAbsolutePointerDevice
= NULL
;
470 Stop this driver on ControllerHandle. Support stoping any child handles
471 created by this driver.
473 @param This Protocol instance pointer.
474 @param Controller Handle of device to stop driver on
475 @param NumberOfChildren Number of Children in the ChildHandleBuffer
476 @param ChildHandleBuffer List of handles for the children we need to stop.
479 @return EFI_DEVICE_ERROR
485 USBMouseAbsolutePointerDriverBindingStop (
486 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
487 IN EFI_HANDLE Controller
,
488 IN UINTN NumberOfChildren
,
489 IN EFI_HANDLE
*ChildHandleBuffer
493 USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDevice
;
494 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointerProtocol
;
495 EFI_USB_IO_PROTOCOL
*UsbIo
;
498 // Get our context back.
500 Status
= gBS
->OpenProtocol (
502 &gEfiAbsolutePointerProtocolGuid
,
503 (VOID
**) &AbsolutePointerProtocol
,
504 This
->DriverBindingHandle
,
506 EFI_OPEN_PROTOCOL_GET_PROTOCOL
509 if (EFI_ERROR (Status
)) {
510 return EFI_UNSUPPORTED
;
512 UsbMouseAbsolutePointerDevice
= USB_MOUSE_ABSOLUTE_POINTER_DEV_FROM_MOUSE_PROTOCOL (AbsolutePointerProtocol
);
516 &gEfiAbsolutePointerProtocolGuid
,
517 This
->DriverBindingHandle
,
521 UsbIo
= UsbMouseAbsolutePointerDevice
->UsbIo
;
524 // Uninstall the Asyn Interrupt Transfer from this device
525 // will disable the mouse data input from this device
527 MouseAbsolutePointerReportStatusCode (
528 UsbMouseAbsolutePointerDevice
->DevicePath
,
530 PcdGet32 (PcdStatusCodeValueMouseDisable
)
534 // Delete Mouse Async Interrupt Transfer
536 UsbIo
->UsbAsyncInterruptTransfer (
538 UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
->EndpointAddress
,
540 UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
->Interval
,
546 gBS
->CloseEvent (UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
.WaitForInput
);
548 if (UsbMouseAbsolutePointerDevice
->DelayedRecoveryEvent
) {
549 gBS
->CloseEvent (UsbMouseAbsolutePointerDevice
->DelayedRecoveryEvent
);
550 UsbMouseAbsolutePointerDevice
->DelayedRecoveryEvent
= 0;
553 Status
= gBS
->UninstallProtocolInterface (
555 &gEfiAbsolutePointerProtocolGuid
,
556 &UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
558 if (EFI_ERROR (Status
)) {
564 &gEfiUsbIoProtocolGuid
,
565 This
->DriverBindingHandle
,
569 gBS
->FreePool (UsbMouseAbsolutePointerDevice
->InterfaceDescriptor
);
570 gBS
->FreePool (UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
);
572 if (UsbMouseAbsolutePointerDevice
->ControllerNameTable
) {
573 FreeUnicodeStringTable (UsbMouseAbsolutePointerDevice
->ControllerNameTable
);
576 gBS
->FreePool (UsbMouseAbsolutePointerDevice
);
584 Tell if a Usb Controller is a mouse
586 @param UsbIo Protocol instance pointer.
588 @retval TRUE It is a mouse
589 @retval FALSE It is not a mouse
593 IsUsbMouseAbsolutePointer (
594 IN EFI_USB_IO_PROTOCOL
*UsbIo
598 EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor
;
601 // Get the Default interface descriptor, now we only
602 // suppose it is interface 1
604 Status
= UsbIo
->UsbGetInterfaceDescriptor (
609 if (EFI_ERROR (Status
)) {
613 if ((InterfaceDescriptor
.InterfaceClass
== CLASS_HID
) &&
614 (InterfaceDescriptor
.InterfaceSubClass
== SUBCLASS_BOOT
) &&
615 (InterfaceDescriptor
.InterfaceProtocol
== PROTOCOL_MOUSE
)
626 Initialize the Usb Mouse Simulate TouchPad Device.
628 @param UsbMouseAbsolutePointerDev Device instance to be initialized
630 @retval EFI_SUCCESS Success
631 @retval EFI_DEVICE_ERROR Init error. EFI_OUT_OF_RESOURCES- Can't allocate
636 InitializeUsbMouseAbsolutePointerDevice (
637 IN USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDev
640 EFI_USB_IO_PROTOCOL
*UsbIo
;
643 EFI_USB_HID_DESCRIPTOR MouseHidDesc
;
646 UsbIo
= UsbMouseAbsolutePointerDev
->UsbIo
;
649 // Get HID descriptor
651 Status
= UsbGetHidDescriptor (
653 UsbMouseAbsolutePointerDev
->InterfaceDescriptor
->InterfaceNumber
,
657 if (EFI_ERROR (Status
)) {
662 // Get Report descriptor
664 if (MouseHidDesc
.HidClassDesc
[0].DescriptorType
!= 0x22) {
665 return EFI_UNSUPPORTED
;
668 ReportDesc
= AllocateZeroPool (MouseHidDesc
.HidClassDesc
[0].DescriptorLength
);
669 if (ReportDesc
== NULL
) {
670 return EFI_OUT_OF_RESOURCES
;
673 Status
= UsbGetReportDescriptor (
675 UsbMouseAbsolutePointerDev
->InterfaceDescriptor
->InterfaceNumber
,
676 MouseHidDesc
.HidClassDesc
[0].DescriptorLength
,
680 if (EFI_ERROR (Status
)) {
681 gBS
->FreePool (ReportDesc
);
686 // Parse report descriptor
688 Status
= ParseMouseReportDescriptor (
689 UsbMouseAbsolutePointerDev
,
691 MouseHidDesc
.HidClassDesc
[0].DescriptorLength
694 if (EFI_ERROR (Status
)) {
695 gBS
->FreePool (ReportDesc
);
699 UsbMouseAbsolutePointerDev
->AbsolutePointerMode
.AbsoluteMaxX
= 1024;
700 UsbMouseAbsolutePointerDev
->AbsolutePointerMode
.AbsoluteMaxY
= 1024;
701 UsbMouseAbsolutePointerDev
->AbsolutePointerMode
.AbsoluteMaxZ
= 0;
702 UsbMouseAbsolutePointerDev
->AbsolutePointerMode
.AbsoluteMinX
= 0;
703 UsbMouseAbsolutePointerDev
->AbsolutePointerMode
.AbsoluteMinY
= 0;
704 UsbMouseAbsolutePointerDev
->AbsolutePointerMode
.AbsoluteMinZ
= 0;
705 UsbMouseAbsolutePointerDev
->AbsolutePointerMode
.Attributes
= 0x3;
708 // Here we just assume interface 0 is the mouse interface
710 UsbGetProtocolRequest (
716 if (Protocol
!= BOOT_PROTOCOL
) {
717 Status
= UsbSetProtocolRequest (
723 if (EFI_ERROR (Status
)) {
724 gBS
->FreePool (ReportDesc
);
725 return EFI_DEVICE_ERROR
;
730 // Set indefinite Idle rate for USB Mouse
739 gBS
->FreePool (ReportDesc
);
741 if (UsbMouseAbsolutePointerDev
->DelayedRecoveryEvent
) {
742 gBS
->CloseEvent (UsbMouseAbsolutePointerDev
->DelayedRecoveryEvent
);
743 UsbMouseAbsolutePointerDev
->DelayedRecoveryEvent
= 0;
746 Status
= gBS
->CreateEvent (
747 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
749 USBMouseAbsolutePointerRecoveryHandler
,
750 UsbMouseAbsolutePointerDev
,
751 &UsbMouseAbsolutePointerDev
->DelayedRecoveryEvent
759 It is called whenever there is data received from async interrupt
762 @param Data Data received.
763 @param DataLength Length of Data
764 @param Context Passed in context
765 @param Result Async Interrupt Transfer result
768 @return EFI_DEVICE_ERROR
773 OnMouseAbsolutePointerInterruptComplete (
780 USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDevice
;
781 EFI_USB_IO_PROTOCOL
*UsbIo
;
785 UsbMouseAbsolutePointerDevice
= (USB_MOUSE_ABSOLUTE_POINTER_DEV
*) Context
;
786 UsbIo
= UsbMouseAbsolutePointerDevice
->UsbIo
;
788 if (Result
!= EFI_USB_NOERROR
) {
790 // Some errors happen during the process
792 MouseAbsolutePointerReportStatusCode (
793 UsbMouseAbsolutePointerDevice
->DevicePath
,
794 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
795 PcdGet32 (PcdStatusCodeValueMouseInputError
)
798 if ((Result
& EFI_USB_ERR_STALL
) == EFI_USB_ERR_STALL
) {
799 EndpointAddr
= UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
->EndpointAddress
;
801 UsbClearEndpointHalt (
808 UsbIo
->UsbAsyncInterruptTransfer (
810 UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
->EndpointAddress
,
819 UsbMouseAbsolutePointerDevice
->DelayedRecoveryEvent
,
821 EFI_USB_INTERRUPT_DELAY
823 return EFI_DEVICE_ERROR
;
826 if (DataLength
== 0 || Data
== NULL
) {
833 UsbMouseAbsolutePointerDevice
->AbsolutePointerStateChanged
= TRUE
;
834 UsbMouseAbsolutePointerDevice
->AbsolutePointerState
.CurrentX
+= *((INT8
*) Data
+ 1);
835 UsbMouseAbsolutePointerDevice
->AbsolutePointerState
.CurrentY
+= *((INT8
*) Data
+ 2);
836 if (DataLength
> 3) {
837 UsbMouseAbsolutePointerDevice
->AbsolutePointerState
.CurrentZ
+= *((INT8
*) Data
+ 3);
839 UsbMouseAbsolutePointerDevice
->AbsolutePointerState
.ActiveButtons
= *(UINT8
*)Data
& 0x3;
845 Get the mouse state, see ABSOLUTE POINTER PROTOCOL.
847 @param This Protocol instance pointer.
848 @param MouseState Current mouse state
851 @return EFI_DEVICE_ERROR
852 @return EFI_NOT_READY
857 GetMouseAbsolutePointerState (
858 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
859 OUT EFI_ABSOLUTE_POINTER_STATE
*MouseAbsolutePointerState
862 USB_MOUSE_ABSOLUTE_POINTER_DEV
*MouseAbsolutePointerDev
;
864 if (MouseAbsolutePointerState
== NULL
) {
865 return EFI_DEVICE_ERROR
;
868 MouseAbsolutePointerDev
= USB_MOUSE_ABSOLUTE_POINTER_DEV_FROM_MOUSE_PROTOCOL (This
);
870 if (!MouseAbsolutePointerDev
->AbsolutePointerStateChanged
) {
871 return EFI_NOT_READY
;
875 MouseAbsolutePointerState
,
876 &MouseAbsolutePointerDev
->AbsolutePointerState
,
877 sizeof (EFI_ABSOLUTE_POINTER_STATE
)
881 // Clear previous move state
883 MouseAbsolutePointerDev
->AbsolutePointerState
.CurrentX
= 0;
884 MouseAbsolutePointerDev
->AbsolutePointerState
.CurrentY
= 0;
885 MouseAbsolutePointerDev
->AbsolutePointerState
.CurrentZ
= 0;
886 MouseAbsolutePointerDev
->AbsolutePointerState
.ActiveButtons
= 0;
888 MouseAbsolutePointerDev
->AbsolutePointerStateChanged
= FALSE
;
895 Reset the mouse device, see ABSOLUTE POINTER PROTOCOL.
897 @param This Protocol instance pointer.
898 @param ExtendedVerification Ignored here/
905 UsbMouseAbsolutePointerReset (
906 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
907 IN BOOLEAN ExtendedVerification
910 USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDevice
;
912 UsbMouseAbsolutePointerDevice
= USB_MOUSE_ABSOLUTE_POINTER_DEV_FROM_MOUSE_PROTOCOL (This
);
914 MouseAbsolutePointerReportStatusCode (
915 UsbMouseAbsolutePointerDevice
->DevicePath
,
917 PcdGet32 (PcdStatusCodeValueMouseReset
)
921 &UsbMouseAbsolutePointerDevice
->AbsolutePointerState
,
922 sizeof (EFI_ABSOLUTE_POINTER_STATE
)
924 UsbMouseAbsolutePointerDevice
->AbsolutePointerStateChanged
= FALSE
;
930 Event notification function for ABSOLUTE_POINTER.WaitForInput event
931 Signal the event if there is input from mouse
933 @param Event Wait Event
934 @param Context Passed parameter to event handler
940 UsbMouseAbsolutePointerWaitForInput (
945 USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDev
;
947 UsbMouseAbsolutePointerDev
= (USB_MOUSE_ABSOLUTE_POINTER_DEV
*) Context
;
950 // Someone is waiting on the mouse event, if there's
951 // input from mouse, signal the event
953 if (UsbMouseAbsolutePointerDev
->AbsolutePointerStateChanged
) {
954 gBS
->SignalEvent (Event
);
959 Timer handler for Delayed Recovery timer.
961 @param Event The Delayed Recovery event.
962 @param Context Points to the USB_KB_DEV instance.
968 USBMouseAbsolutePointerRecoveryHandler (
973 USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDev
;
974 EFI_USB_IO_PROTOCOL
*UsbIo
;
976 UsbMouseAbsolutePointerDev
= (USB_MOUSE_ABSOLUTE_POINTER_DEV
*) Context
;
978 UsbIo
= UsbMouseAbsolutePointerDev
->UsbIo
;
980 UsbIo
->UsbAsyncInterruptTransfer (
982 UsbMouseAbsolutePointerDev
->IntEndpointDescriptor
->EndpointAddress
,
984 UsbMouseAbsolutePointerDev
->IntEndpointDescriptor
->Interval
,
985 UsbMouseAbsolutePointerDev
->IntEndpointDescriptor
->MaxPacketSize
,
986 OnMouseAbsolutePointerInterruptComplete
,
987 UsbMouseAbsolutePointerDev
993 Report Status Code in Usb Bot Driver
995 @param DevicePath Use this to get Device Path
996 @param CodeType Status Code Type
997 @param CodeValue Status Code Value
1003 MouseAbsolutePointerReportStatusCode (
1004 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
1005 IN EFI_STATUS_CODE_TYPE CodeType
,
1006 IN EFI_STATUS_CODE_VALUE Value
1009 REPORT_STATUS_CODE_WITH_DEVICE_PATH (