2 USB Mouse Driver that manages USB mouse and produces Absolute Pointer Protocol.
4 Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "UsbMouseAbsolutePointer.h"
17 EFI_DRIVER_BINDING_PROTOCOL gUsbMouseAbsolutePointerDriverBinding
= {
18 USBMouseAbsolutePointerDriverBindingSupported
,
19 USBMouseAbsolutePointerDriverBindingStart
,
20 USBMouseAbsolutePointerDriverBindingStop
,
27 Entrypoint of USB Mouse Absolute Pointer Driver.
29 This function is the entrypoint of USB Mouse Driver. It installs Driver Binding
30 Protocols together with Component Name Protocols.
32 @param ImageHandle The firmware allocated handle for the EFI image.
33 @param SystemTable A pointer to the EFI System Table.
35 @retval EFI_SUCCESS The entry point is executed successfully.
40 USBMouseAbsolutePointerDriverBindingEntryPoint (
41 IN EFI_HANDLE ImageHandle
,
42 IN EFI_SYSTEM_TABLE
*SystemTable
47 Status
= EfiLibInstallDriverBindingComponentName2 (
50 &gUsbMouseAbsolutePointerDriverBinding
,
52 &gUsbMouseAbsolutePointerComponentName
,
53 &gUsbMouseAbsolutePointerComponentName2
55 ASSERT_EFI_ERROR (Status
);
62 Check whether USB Mouse Absolute Pointer Driver supports this device.
64 @param This The driver binding protocol.
65 @param Controller The controller handle to check.
66 @param RemainingDevicePath The remaining device path.
68 @retval EFI_SUCCESS The driver supports this controller.
69 @retval other This device isn't supported.
74 USBMouseAbsolutePointerDriverBindingSupported (
75 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
76 IN EFI_HANDLE Controller
,
77 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
81 EFI_USB_IO_PROTOCOL
*UsbIo
;
83 Status
= gBS
->OpenProtocol (
85 &gEfiUsbIoProtocolGuid
,
87 This
->DriverBindingHandle
,
89 EFI_OPEN_PROTOCOL_BY_DRIVER
91 if (EFI_ERROR (Status
)) {
96 // Use the USB I/O Protocol interface to check whether Controller is
97 // a mouse device that can be managed by this driver.
100 if (!IsUsbMouse (UsbIo
)) {
101 Status
= EFI_UNSUPPORTED
;
106 &gEfiUsbIoProtocolGuid
,
107 This
->DriverBindingHandle
,
116 Starts the mouse device with this driver.
118 This function consumes USB I/O Portocol, intializes USB mouse device,
119 installs Absolute Pointer Protocol, and submits Asynchronous Interrupt
120 Transfer to manage the USB mouse device.
122 @param This The driver binding instance.
123 @param Controller Handle of device to bind driver to.
124 @param RemainingDevicePath Optional parameter use to pick a specific child
127 @retval EFI_SUCCESS This driver supports this device.
128 @retval EFI_UNSUPPORTED This driver does not support this device.
129 @retval EFI_DEVICE_ERROR This driver cannot be started due to device Error.
130 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
131 @retval EFI_ALREADY_STARTED This driver has been started.
136 USBMouseAbsolutePointerDriverBindingStart (
137 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
138 IN EFI_HANDLE Controller
,
139 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
143 EFI_USB_IO_PROTOCOL
*UsbIo
;
144 USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDevice
;
145 UINT8 EndpointNumber
;
146 EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor
;
149 UINT8 PollingInterval
;
154 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
156 // Open USB I/O Protocol
158 Status
= gBS
->OpenProtocol (
160 &gEfiUsbIoProtocolGuid
,
162 This
->DriverBindingHandle
,
164 EFI_OPEN_PROTOCOL_BY_DRIVER
166 if (EFI_ERROR (Status
)) {
170 UsbMouseAbsolutePointerDevice
= AllocateZeroPool (sizeof (USB_MOUSE_ABSOLUTE_POINTER_DEV
));
171 ASSERT (UsbMouseAbsolutePointerDevice
!= NULL
);
173 UsbMouseAbsolutePointerDevice
->UsbIo
= UsbIo
;
174 UsbMouseAbsolutePointerDevice
->Signature
= USB_MOUSE_ABSOLUTE_POINTER_DEV_SIGNATURE
;
177 // Get the Device Path Protocol on Controller's handle
179 Status
= gBS
->OpenProtocol (
181 &gEfiDevicePathProtocolGuid
,
182 (VOID
**) &UsbMouseAbsolutePointerDevice
->DevicePath
,
183 This
->DriverBindingHandle
,
185 EFI_OPEN_PROTOCOL_GET_PROTOCOL
188 if (EFI_ERROR (Status
)) {
192 // Get interface & endpoint descriptor
194 UsbIo
->UsbGetInterfaceDescriptor (
196 &UsbMouseAbsolutePointerDevice
->InterfaceDescriptor
199 EndpointNumber
= UsbMouseAbsolutePointerDevice
->InterfaceDescriptor
.NumEndpoints
;
202 // Traverse endpoints to find interrupt endpoint
205 for (Index
= 0; Index
< EndpointNumber
; Index
++) {
206 UsbIo
->UsbGetEndpointDescriptor (
212 if ((EndpointDescriptor
.Attributes
& (BIT0
| BIT1
)) == USB_ENDPOINT_INTERRUPT
) {
214 // We only care interrupt endpoint here
216 CopyMem (&UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
, &EndpointDescriptor
, sizeof(EndpointDescriptor
));
224 // No interrupt endpoint found, then return unsupported.
226 Status
= EFI_UNSUPPORTED
;
230 Status
= InitializeUsbMouseDevice (UsbMouseAbsolutePointerDevice
);
231 if (EFI_ERROR (Status
)) {
233 // Fail to initialize USB mouse device.
235 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
236 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
237 (EFI_PERIPHERAL_MOUSE
| EFI_P_EC_INTERFACE_ERROR
),
238 UsbMouseAbsolutePointerDevice
->DevicePath
245 // Initialize and install EFI Absolute Pointer Protocol.
247 UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
.GetState
= GetMouseAbsolutePointerState
;
248 UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
.Reset
= UsbMouseAbsolutePointerReset
;
249 UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
.Mode
= &UsbMouseAbsolutePointerDevice
->Mode
;
251 Status
= gBS
->CreateEvent (
254 UsbMouseAbsolutePointerWaitForInput
,
255 UsbMouseAbsolutePointerDevice
,
256 &((UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
).WaitForInput
)
258 if (EFI_ERROR (Status
)) {
262 Status
= gBS
->InstallProtocolInterface (
264 &gEfiAbsolutePointerProtocolGuid
,
265 EFI_NATIVE_INTERFACE
,
266 &UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
269 if (EFI_ERROR (Status
)) {
274 // The next step would be submitting Asynchronous Interrupt Transfer on this mouse device.
275 // After that we will be able to get key data from it. Thus this is deemed as
276 // the enable action of the mouse, so report status code accordingly.
278 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
280 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_ENABLE
),
281 UsbMouseAbsolutePointerDevice
->DevicePath
285 // Submit Asynchronous Interrupt Transfer to manage this device.
287 EndpointAddr
= UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
.EndpointAddress
;
288 PollingInterval
= UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
.Interval
;
289 PacketSize
= (UINT8
) (UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
.MaxPacketSize
);
291 Status
= UsbIo
->UsbAsyncInterruptTransfer (
297 OnMouseInterruptComplete
,
298 UsbMouseAbsolutePointerDevice
301 if (EFI_ERROR (Status
)) {
303 // If submit error, uninstall that interface
305 gBS
->UninstallProtocolInterface (
307 &gEfiAbsolutePointerProtocolGuid
,
308 &UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
313 UsbMouseAbsolutePointerDevice
->ControllerNameTable
= NULL
;
316 gUsbMouseAbsolutePointerComponentName
.SupportedLanguages
,
317 &UsbMouseAbsolutePointerDevice
->ControllerNameTable
,
318 L
"Generic Usb Mouse Absolute Pointer",
323 gUsbMouseAbsolutePointerComponentName2
.SupportedLanguages
,
324 &UsbMouseAbsolutePointerDevice
->ControllerNameTable
,
325 L
"Generic Usb Mouse Absolute Pointer",
329 gBS
->RestoreTPL (OldTpl
);
336 if (EFI_ERROR (Status
)) {
339 &gEfiUsbIoProtocolGuid
,
340 This
->DriverBindingHandle
,
344 if (UsbMouseAbsolutePointerDevice
!= NULL
) {
345 if ((UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
).WaitForInput
!= NULL
) {
346 gBS
->CloseEvent ((UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
).WaitForInput
);
349 FreePool (UsbMouseAbsolutePointerDevice
);
350 UsbMouseAbsolutePointerDevice
= NULL
;
355 gBS
->RestoreTPL (OldTpl
);
362 Stop the USB mouse device handled by this driver.
364 @param This The driver binding protocol.
365 @param Controller The controller to release.
366 @param NumberOfChildren The number of handles in ChildHandleBuffer.
367 @param ChildHandleBuffer The array of child handle.
369 @retval EFI_SUCCESS The device was stopped.
370 @retval EFI_UNSUPPORTED Absolute Pointer Protocol is not installed on Controller.
371 @retval Others Fail to uninstall protocols attached on the device.
376 USBMouseAbsolutePointerDriverBindingStop (
377 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
378 IN EFI_HANDLE Controller
,
379 IN UINTN NumberOfChildren
,
380 IN EFI_HANDLE
*ChildHandleBuffer
384 USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDevice
;
385 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointerProtocol
;
386 EFI_USB_IO_PROTOCOL
*UsbIo
;
388 Status
= gBS
->OpenProtocol (
390 &gEfiAbsolutePointerProtocolGuid
,
391 (VOID
**) &AbsolutePointerProtocol
,
392 This
->DriverBindingHandle
,
394 EFI_OPEN_PROTOCOL_GET_PROTOCOL
397 if (EFI_ERROR (Status
)) {
398 return EFI_UNSUPPORTED
;
401 UsbMouseAbsolutePointerDevice
= USB_MOUSE_ABSOLUTE_POINTER_DEV_FROM_MOUSE_PROTOCOL (AbsolutePointerProtocol
);
403 UsbIo
= UsbMouseAbsolutePointerDevice
->UsbIo
;
406 // The key data input from this device will be disabled.
408 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
410 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_DISABLE
),
411 UsbMouseAbsolutePointerDevice
->DevicePath
415 // Delete the Asynchronous Interrupt Transfer from this device
417 UsbIo
->UsbAsyncInterruptTransfer (
419 UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
.EndpointAddress
,
421 UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
.Interval
,
427 Status
= gBS
->UninstallProtocolInterface (
429 &gEfiAbsolutePointerProtocolGuid
,
430 &UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
432 if (EFI_ERROR (Status
)) {
438 &gEfiUsbIoProtocolGuid
,
439 This
->DriverBindingHandle
,
444 // Free all resources.
446 gBS
->CloseEvent (UsbMouseAbsolutePointerDevice
->AbsolutePointerProtocol
.WaitForInput
);
448 if (UsbMouseAbsolutePointerDevice
->DelayedRecoveryEvent
!= NULL
) {
449 gBS
->CloseEvent (UsbMouseAbsolutePointerDevice
->DelayedRecoveryEvent
);
450 UsbMouseAbsolutePointerDevice
->DelayedRecoveryEvent
= NULL
;
453 if (UsbMouseAbsolutePointerDevice
->ControllerNameTable
!= NULL
) {
454 FreeUnicodeStringTable (UsbMouseAbsolutePointerDevice
->ControllerNameTable
);
457 FreePool (UsbMouseAbsolutePointerDevice
);
465 Uses USB I/O to check whether the device is a USB mouse device.
467 @param UsbIo Pointer to a USB I/O protocol instance.
469 @retval TRUE Device is a USB mouse device.
470 @retval FALSE Device is a not USB mouse device.
475 IN EFI_USB_IO_PROTOCOL
*UsbIo
479 EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor
;
482 // Get the default interface descriptor
484 Status
= UsbIo
->UsbGetInterfaceDescriptor (
489 if (EFI_ERROR (Status
)) {
493 if ((InterfaceDescriptor
.InterfaceClass
== CLASS_HID
) &&
494 (InterfaceDescriptor
.InterfaceSubClass
== SUBCLASS_BOOT
) &&
495 (InterfaceDescriptor
.InterfaceProtocol
== PROTOCOL_MOUSE
)
505 Initialize the USB mouse device.
507 This function retrieves and parses HID report descriptor, and
508 initializes state of USB_MOUSE_ABSOLUTE_POINTER_DEV. Then it sets indefinite idle
509 rate for the device. Finally it creates event for delayed recovery,
510 which deals with device error.
512 @param UsbMouseAbsolutePointerDev Device instance to be initialized.
514 @retval EFI_SUCCESS USB mouse device successfully initialized.
515 @retval EFI_UNSUPPORTED HID descriptor type is not report descriptor.
516 @retval Other USB mouse device was not initialized successfully.
520 InitializeUsbMouseDevice (
521 IN USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDev
524 EFI_USB_IO_PROTOCOL
*UsbIo
;
527 EFI_USB_HID_DESCRIPTOR MouseHidDesc
;
532 UsbIo
= UsbMouseAbsolutePointerDev
->UsbIo
;
535 // Get HID descriptor
537 Status
= UsbGetHidDescriptor (
539 UsbMouseAbsolutePointerDev
->InterfaceDescriptor
.InterfaceNumber
,
542 if (EFI_ERROR (Status
)) {
547 // Get report descriptor
549 if (MouseHidDesc
.HidClassDesc
[0].DescriptorType
!= USB_DESC_TYPE_REPORT
) {
550 return EFI_UNSUPPORTED
;
553 ReportDesc
= AllocateZeroPool (MouseHidDesc
.HidClassDesc
[0].DescriptorLength
);
554 ASSERT (ReportDesc
!= NULL
);
556 Status
= UsbGetReportDescriptor (
558 UsbMouseAbsolutePointerDev
->InterfaceDescriptor
.InterfaceNumber
,
559 MouseHidDesc
.HidClassDesc
[0].DescriptorLength
,
563 if (EFI_ERROR (Status
)) {
564 FreePool (ReportDesc
);
569 // Parse report descriptor
571 Status
= ParseMouseReportDescriptor (
572 UsbMouseAbsolutePointerDev
,
574 MouseHidDesc
.HidClassDesc
[0].DescriptorLength
577 if (EFI_ERROR (Status
)) {
578 FreePool (ReportDesc
);
582 UsbMouseAbsolutePointerDev
->Mode
.AbsoluteMaxX
= 1024;
583 UsbMouseAbsolutePointerDev
->Mode
.AbsoluteMaxY
= 1024;
584 UsbMouseAbsolutePointerDev
->Mode
.AbsoluteMaxZ
= 0;
585 UsbMouseAbsolutePointerDev
->Mode
.AbsoluteMinX
= 0;
586 UsbMouseAbsolutePointerDev
->Mode
.AbsoluteMinY
= 0;
587 UsbMouseAbsolutePointerDev
->Mode
.AbsoluteMinZ
= 0;
588 UsbMouseAbsolutePointerDev
->Mode
.Attributes
= 0x3;
591 // Set boot protocol for the USB mouse.
592 // This driver only supports boot protocol.
594 UsbGetProtocolRequest (
596 UsbMouseAbsolutePointerDev
->InterfaceDescriptor
.InterfaceNumber
,
599 if (Protocol
!= BOOT_PROTOCOL
) {
600 Status
= UsbSetProtocolRequest (
606 if (EFI_ERROR (Status
)) {
607 FreePool (ReportDesc
);
613 // ReportId is zero, which means the idle rate applies to all input reports.
617 // Duration is zero, which means the duration is infinite.
618 // so the endpoint will inhibit reporting forever,
619 // and only reporting when a change is detected in the report data.
624 UsbMouseAbsolutePointerDev
->InterfaceDescriptor
.InterfaceNumber
,
629 FreePool (ReportDesc
);
632 // Create event for delayed recovery, which deals with device error.
634 if (UsbMouseAbsolutePointerDev
->DelayedRecoveryEvent
!= NULL
) {
635 gBS
->CloseEvent (UsbMouseAbsolutePointerDev
->DelayedRecoveryEvent
);
636 UsbMouseAbsolutePointerDev
->DelayedRecoveryEvent
= 0;
640 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
642 USBMouseRecoveryHandler
,
643 UsbMouseAbsolutePointerDev
,
644 &UsbMouseAbsolutePointerDev
->DelayedRecoveryEvent
652 Handler function for USB mouse's asynchronous interrupt transfer.
654 This function is the handler function for USB mouse's asynchronous interrupt transfer
655 to manage the mouse. It parses data returned from asynchronous interrupt transfer, and
656 get button and movement state.
658 @param Data A pointer to a buffer that is filled with key data which is
659 retrieved via asynchronous interrupt transfer.
660 @param DataLength Indicates the size of the data buffer.
661 @param Context Pointing to USB_KB_DEV instance.
662 @param Result Indicates the result of the asynchronous interrupt transfer.
664 @retval EFI_SUCCESS Asynchronous interrupt transfer is handled successfully.
665 @retval EFI_DEVICE_ERROR Hardware error occurs.
670 OnMouseInterruptComplete (
677 USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDevice
;
678 EFI_USB_IO_PROTOCOL
*UsbIo
;
682 UsbMouseAbsolutePointerDevice
= (USB_MOUSE_ABSOLUTE_POINTER_DEV
*) Context
;
683 UsbIo
= UsbMouseAbsolutePointerDevice
->UsbIo
;
685 if (Result
!= EFI_USB_NOERROR
) {
687 // Some errors happen during the process
689 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
690 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
691 (EFI_PERIPHERAL_MOUSE
| EFI_P_EC_INPUT_ERROR
),
692 UsbMouseAbsolutePointerDevice
->DevicePath
695 if ((Result
& EFI_USB_ERR_STALL
) == EFI_USB_ERR_STALL
) {
696 EndpointAddr
= UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
.EndpointAddress
;
698 UsbClearEndpointHalt (
706 // Delete & Submit this interrupt again
707 // Handler of DelayedRecoveryEvent triggered by timer will re-submit the interrupt.
709 UsbIo
->UsbAsyncInterruptTransfer (
711 UsbMouseAbsolutePointerDevice
->IntEndpointDescriptor
.EndpointAddress
,
719 // EFI_USB_INTERRUPT_DELAY is defined in USB standard for error handling.
722 UsbMouseAbsolutePointerDevice
->DelayedRecoveryEvent
,
724 EFI_USB_INTERRUPT_DELAY
726 return EFI_DEVICE_ERROR
;
730 // If no error and no data, just return EFI_SUCCESS.
732 if (DataLength
== 0 || Data
== NULL
) {
736 UsbMouseAbsolutePointerDevice
->StateChanged
= TRUE
;
740 // USB HID Specification specifies following data format:
741 // Byte Bits Description
745 // 4 to 7 Device-specific
746 // 1 0 to 7 X displacement
747 // 2 0 to 7 Y displacement
748 // 3 to n 0 to 7 Device specific (optional)
750 UsbMouseAbsolutePointerDevice
->State
.CurrentX
+= *((INT8
*) Data
+ 1);
751 UsbMouseAbsolutePointerDevice
->State
.CurrentY
+= *((INT8
*) Data
+ 2);
753 if (DataLength
> 3) {
754 UsbMouseAbsolutePointerDevice
->State
.CurrentZ
+= *((INT8
*) Data
+ 3);
756 UsbMouseAbsolutePointerDevice
->State
.ActiveButtons
= *(UINT8
*) Data
& (BIT0
| BIT1
);
762 Retrieves the current state of a pointer device.
764 @param This A pointer to the EFI_ABSOLUTE_POINTER_PROTOCOL instance.
765 @param MouseState A pointer to the state information on the pointer device.
767 @retval EFI_SUCCESS The state of the pointer device was returned in State.
768 @retval EFI_NOT_READY The state of the pointer device has not changed since the last call to
770 @retval EFI_DEVICE_ERROR A device error occurred while attempting to retrieve the pointer device's
772 @retval EFI_INVALID_PARAMETER State is NULL.
777 GetMouseAbsolutePointerState (
778 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
779 OUT EFI_ABSOLUTE_POINTER_STATE
*State
782 USB_MOUSE_ABSOLUTE_POINTER_DEV
*MouseAbsolutePointerDev
;
785 return EFI_INVALID_PARAMETER
;
788 MouseAbsolutePointerDev
= USB_MOUSE_ABSOLUTE_POINTER_DEV_FROM_MOUSE_PROTOCOL (This
);
790 if (!MouseAbsolutePointerDev
->StateChanged
) {
791 return EFI_NOT_READY
;
795 // Retrieve mouse state from USB_MOUSE_ABSOLUTE_POINTER_DEV,
796 // which was filled by OnMouseInterruptComplete()
800 &MouseAbsolutePointerDev
->State
,
801 sizeof (EFI_ABSOLUTE_POINTER_STATE
)
805 // Clear previous move state
807 MouseAbsolutePointerDev
->State
.CurrentX
= 0;
808 MouseAbsolutePointerDev
->State
.CurrentY
= 0;
809 MouseAbsolutePointerDev
->State
.CurrentZ
= 0;
810 MouseAbsolutePointerDev
->State
.ActiveButtons
= 0;
812 MouseAbsolutePointerDev
->StateChanged
= FALSE
;
819 Resets the pointer device hardware.
821 @param This A pointer to the EFI_ABSOLUTE_POINTER_PROTOCOL instance.
822 @param ExtendedVerification Indicates that the driver may perform a more exhaustive
823 verification operation of the device during reset.
825 @retval EFI_SUCCESS The device was reset.
826 @retval EFI_DEVICE_ERROR The device is not functioning correctly and could not be reset.
831 UsbMouseAbsolutePointerReset (
832 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
833 IN BOOLEAN ExtendedVerification
836 USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDevice
;
838 UsbMouseAbsolutePointerDevice
= USB_MOUSE_ABSOLUTE_POINTER_DEV_FROM_MOUSE_PROTOCOL (This
);
840 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
842 (EFI_PERIPHERAL_MOUSE
| EFI_P_PC_RESET
),
843 UsbMouseAbsolutePointerDevice
->DevicePath
847 // Clear mouse state.
850 &UsbMouseAbsolutePointerDevice
->State
,
851 sizeof (EFI_ABSOLUTE_POINTER_STATE
)
853 UsbMouseAbsolutePointerDevice
->StateChanged
= FALSE
;
859 Event notification function for EFI_ABSOLUTE_POINTER_PROTOCOL.WaitForInput event.
861 @param Event Event to be signaled when there's input from mouse.
862 @param Context Points to USB_MOUSE_ABSOLUTE_POINTER_DEV instance.
867 UsbMouseAbsolutePointerWaitForInput (
872 USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDev
;
874 UsbMouseAbsolutePointerDev
= (USB_MOUSE_ABSOLUTE_POINTER_DEV
*) Context
;
877 // If there's input from mouse, signal the event.
879 if (UsbMouseAbsolutePointerDev
->StateChanged
) {
880 gBS
->SignalEvent (Event
);
885 Handler for Delayed Recovery event.
887 This function is the handler for Delayed Recovery event triggered
889 After a device error occurs, the event would be triggered
890 with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY
891 is defined in USB standard for error handling.
893 @param Event The Delayed Recovery event.
894 @param Context Points to the USB_MOUSE_ABSOLUTE_POINTER_DEV instance.
899 USBMouseRecoveryHandler (
904 USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDev
;
905 EFI_USB_IO_PROTOCOL
*UsbIo
;
907 UsbMouseAbsolutePointerDev
= (USB_MOUSE_ABSOLUTE_POINTER_DEV
*) Context
;
909 UsbIo
= UsbMouseAbsolutePointerDev
->UsbIo
;
912 // Re-submit Asynchronous Interrupt Transfer for recovery.
914 UsbIo
->UsbAsyncInterruptTransfer (
916 UsbMouseAbsolutePointerDev
->IntEndpointDescriptor
.EndpointAddress
,
918 UsbMouseAbsolutePointerDev
->IntEndpointDescriptor
.Interval
,
919 UsbMouseAbsolutePointerDev
->IntEndpointDescriptor
.MaxPacketSize
,
920 OnMouseInterruptComplete
,
921 UsbMouseAbsolutePointerDev