*
* @APPLE_LICENSE_HEADER_START@
*
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
* 12 Nov 1998 suurballe Created.
*/
+#include <IOKit/pwr_mgt/IOPM.h>
#include <IOKit/IOSyncer.h>
#include "IOPMUADBController.h"
waitingForData = NULL;
// Registers for the two interrupts that needs to handle:
- if (PMUdriver->callPlatformFunction("registerForPMUInterrupts", true, (void*)kPMUADBint, (void*)handleADBInterrupt, (void*)this, NULL) != kIOReturnSuccess) {
+ if (PMUdriver->callPlatformFunction("registerForPMUInterrupts", true, (void*) (kPMUADBint | kPMUenvironmentInt), (void*)handleADBInterrupt, (void*)this, NULL) != kIOReturnSuccess) {
#ifdef VERBOSE_LOGS_ON
IOLog("IOPMUADBController::start registerForPMUInterrupts kPMUADBint fails\n");
#endif // VERBOSE_LOGS_ON
if (!requestMutexLock)
return false;
+ clamshellOpen = true;
+
// This happens last (while the most common place is the begin) because
// trhe superclass may need the services of the functions above.
if( !super::start(nub))
// And removes the interrupt handler:
if (PMUdriver != NULL)
- PMUdriver->callPlatformFunction("deRegisterClient", true, (void*)this, (void*)kPMUADBint, NULL, NULL);
+ PMUdriver->callPlatformFunction("deRegisterClient", true, (void*)this, (void*)(kPMUADBint | kPMUenvironmentInt), NULL, NULL);
}
// **********************************************************************************
// **********************************************************************************
// this is the interrupt handler for all ADB interrupts:
-//
+// A.W. Added code to check for clamshell status, and block all ADB traffic except
+// for POWER key scan code from default ADB keyboard or devices that connect
+// to that keyboard power button.
// **********************************************************************************
/* static */ void
if (myThis == NULL)
return;
+ if (interruptMask & kPMUenvironmentInt)
+ {
+ if (buffer)
+ {
+ if (*buffer & kClamshellClosedEventMask)
+ myThis->clamshellOpen = false;
+ else
+ myThis->clamshellOpen = true;
+ }
+ if ( !(interruptMask & kPMUautopoll))
+ {
+ return; //Nothing left to do
+ }
+ }
if ((interruptMask & kPMUautopoll) && (myThis->autopollOn))
- autopollHandler(client, buffer[0], length - 1, buffer + 1); // yes, call adb input handler
+ {
+ if (myThis->clamshellOpen)
+ {
+ autopollHandler(client, buffer[0], length - 1, buffer + 1); // yes, call adb input handler
+ }
+ else if ( (buffer[0] == 0x2c) && (buffer[1] == 0x7f) && (buffer[2] == 0x7f))
+ {
+ autopollHandler(client, buffer[0], length - 1, buffer + 1); // POWER down
+ }
+ else if ( (buffer[0] == 0x2c) && (buffer[1] == 0xff) && (buffer[2] == 0xff))
+ {
+ autopollHandler(client, buffer[0], length - 1, buffer + 1); // POWER up
+ }
+
+ }
else {
if (myThis->waitingForData != NULL) {
// Complets the adb transaction