static void DetectThreadFun(void* arg) { NvU32 value = 0; int tempHeadsetStatus = gHeadsetStatus; struct gpio_switch_data* data = (struct gpio_switch_data*)arg; while( !g_DetectThread_exit ) { NvOdmOsSemaphoreWaitTimeout( g_hDetectEventSema , gWaitTmes_msec); //detect mic status here , but no use now //just assign headphone status if( gHeadsetInsertStatus == HEADSET_STATUS_INSERT ) { tempHeadsetStatus = HEADSET_STATUS_INSERT; } else { tempHeadsetStatus = HEADSET_STATUS_REMOVE; } //check if status change if( tempHeadsetStatus != gHeadsetStatus ) { gHeadsetStatus = tempHeadsetStatus; switch_set_state(&data->sdev, gHeadsetStatus); } }//while( !g_micDetectThread_exit ) return; }
static int tegra_onetouch_thread(void *pdata) { struct tegra_onetouch_driver_data *onetouch = (struct tegra_onetouch_driver_data*)pdata; NvOdmOneTouchButtonInfo button = {0}; NvBool bKeepReadingSamples; NvU16 pressed_menu_button = NV_FALSE; NvU16 pressed_back_button = NV_FALSE; /* onetouch event thread should be frozen before suspend */ set_freezable_with_signal(); for (;;) { if (onetouch->bPollingMode) msleep(onetouch->pollingIntervalMS); else /* FIXME should have a timeout so, that we can exit thread */ if (!NvOdmOsSemaphoreWaitTimeout(onetouch->semaphore, NV_WAIT_INFINITE)) BUG(); bKeepReadingSamples = NV_TRUE; while (bKeepReadingSamples) { #if defined(CONFIG_MACH_STAR_SKT_REV_E) || defined(CONFIG_MACH_STAR_SKT_REV_F) NvOdmOsMutexLock(onetouch->hMutex); #endif if (!NvOdmOneTouchReadButton(onetouch->hOneTouchDevice, &button)) { pr_err("Couldn't read onetouch sample\n"); #if defined(CONFIG_MACH_STAR_SKT_REV_E) || defined(CONFIG_MACH_STAR_SKT_REV_F) NvOdmOneTouchDeviceClose(onetouch->hOneTouchDevice); NvOdmOneTouchDeviceOpen(&onetouch->hOneTouchDevice, &onetouch->semaphore); NvOdmOsMutexUnlock(onetouch->hMutex); break; #else bKeepReadingSamples = NV_FALSE; goto DoneWithSample; #endif } #if defined(CONFIG_MACH_STAR_SKT_REV_E) || defined(CONFIG_MACH_STAR_SKT_REV_F) NvOdmOsMutexUnlock(onetouch->hMutex); #endif if(button.menu == NV_TRUE && !pressed_menu_button) { input_report_key(onetouch->input_dev, KEY_MENU, 1); pressed_menu_button = NV_TRUE; } else if(button.menu == NV_FALSE && pressed_menu_button) { input_report_key(onetouch->input_dev, KEY_MENU, 0); pressed_menu_button = NV_FALSE; } if(button.back == NV_TRUE && !pressed_back_button) { input_report_key(onetouch->input_dev, KEY_BACK, 1); pressed_back_button = NV_TRUE; } else if (button.back == NV_FALSE && pressed_back_button) { input_report_key(onetouch->input_dev, KEY_BACK, 0); pressed_back_button = NV_FALSE; } #ifdef CONFIG_STAR_TOUCH_LED touchLED_enable(NV_TRUE); #endif input_mt_sync(onetouch->input_dev); input_sync(onetouch->input_dev); #if !defined(CONFIG_MACH_STAR_SKT_REV_E) && !defined(CONFIG_MACH_STAR_SKT_REV_F) DoneWithSample: #endif bKeepReadingSamples = NV_FALSE; if (!onetouch->bPollingMode && !NvOdmOneTouchHandleInterrupt(onetouch->hOneTouchDevice)) { /* Some more data to read keep going */ bKeepReadingSamples = NV_TRUE; } } } return 0; }
/* Gets the actual scan code for a key press */ NvBool NvOdmKeyboardGetKeyData(NvU32 *pKeyScanCode, NvU8 *pScanCodeFlags, NvU32 Timeout) { NvError NvStatus = NvError_Success; NvU32 OutCode, OutCodeBytes, i; NvU8 ScanCodeFlags; if (!pKeyScanCode || !pScanCodeFlags || s_KeyboardDeinit) { return NV_FALSE; } if (Timeout != 0) { /* Use the timeout value */ if (!NvOdmOsSemaphoreWaitTimeout(s_hKbcKeyScanRecvSema, Timeout)) return NV_FALSE; // timed out } else { /* wait till we receive a scan code from the EC */ NvOdmOsSemaphoreWait(s_hKbcKeyScanRecvSema); } // stop scanning if (s_KeyboardDeinit) return NV_FALSE; if (s_hEcEventRegistration) { NvStatus = NvEcGetEvent(s_hEcEventRegistration, &KbdEvent, sizeof(NvEcEvent)); if (NvStatus != NvError_Success) { NV_ASSERT(!"Could not receive scan code"); return NV_FALSE; } if (KbdEvent.NumPayloadBytes == 0) { NV_ASSERT(!"Received keyboard event with no scan codes"); return NV_FALSE; } // Pack scan code bytes from payload buffer into 32-bit dword OutCode = (NvU32)KbdEvent.Payload[0]; OutCodeBytes = 1; ScanCodeFlags = 0; if (KbdEvent.NumPayloadBytes == 1) NVODM_PRINTF(("EC Payload = 0x%x", KbdEvent.Payload[0])); else { for (i = 0; i < KbdEvent.NumPayloadBytes; i++) NVODM_PRINTF(("EC Payload = 0x%x", KbdEvent.Payload[i])); } for (i = 1; i < KbdEvent.NumPayloadBytes; i++) { if (KbdEvent.Payload[i-1] == SC1_PREFIX_E0) { // Temporary clear break flag just to check for extended shifts. // If detected, remove the entire extended shift sequence, as // it has no effect on SC1-to-VK translation NvU8 sc = KbdEvent.Payload[i] & (~SC1_BREAK_MASK); if ((sc == SC1_LSHIFT) || (sc == SC1_RSHIFT)) { OutCode = OutCode >> 8; OutCodeBytes--; continue; } else if (KbdEvent.Payload[i] == SC1_SCROLL) { // If extended ScrollLock = Ctrl+Break, detected store it, // set both make/break flags, and abort buffer packing, as // the following bytes are just the break part of sequence OutCode = (OutCode << 8) | ((NvU32)KbdEvent.Payload[i]); OutCodeBytes++; ScanCodeFlags = NV_ODM_SCAN_CODE_FLAG_MAKE | NV_ODM_SCAN_CODE_FLAG_BREAK; break; } }
/* Gets the actual scan code for a key press */ NvBool NvOdmCirGetKeyData(NvU8 showlog, NvU32 *pKeyScanCode, NvU8 *pRePeat, NvU32 Timeout) { NvError NvStatus = NvError_Success; NvU32 OutCode, i; NvU8 RepeatKey; if (!pKeyScanCode || !pRePeat || s_CirDeinit) { return NV_FALSE; } if (Timeout != 0) { /* Use the timeout value */ if (!NvOdmOsSemaphoreWaitTimeout(s_hCirKeyScanRecvSema, Timeout)) return NV_FALSE; // timed out } else { /* wait till we receive a scan code from the EC */ NvOdmOsSemaphoreWait(s_hCirKeyScanRecvSema); } //NvOsDebugPrintf("$$$$$$$ In kernel cir nvodm_cir.c !! get key data \n"); // stop scanning if (s_CirDeinit) return NV_FALSE; if (s_hEcEventRegistration) { NvStatus = NvEcGetEvent(s_hEcEventRegistration, &CirEvent, sizeof(NvEcEvent)); if (NvStatus != NvError_Success) { NV_ASSERT(!"Could not receive scan code"); return NV_FALSE; } if (CirEvent.NumPayloadBytes == 0) { NV_ASSERT(!"Received Cir event with no scan codes"); return NV_FALSE; } if(showlog){ for (i = 0; i < CirEvent.NumPayloadBytes; i++){ printk(KERN_INFO "EC Payload[%d]=0x%x\n",i,CirEvent.Payload[i]); } } RepeatKey = 0x0; /*default is new key input*/ if(CirEvent.Payload[1] == NV_ODM_CIR_SCAN_CODE_REPET){ RepeatKey = NV_ODM_CIR_SCAN_CODE_REPET; } OutCode = CirEvent.Payload[3]; /*Ir Command */ if(showlog) printk(KERN_INFO "nvec_cir OUT code: 0x%x,RepeatKey =%x\n", OutCode,RepeatKey ); *pRePeat = RepeatKey ; *pKeyScanCode = OutCode; return NV_TRUE; } return NV_FALSE; }