Exemple #1
0
void
NvOdmAccelWaitInt(NvOdmAccelHandle    hDevice,
                          NvOdmAccelIntType  *IntType,
                          NvOdmAccelAxisType *IntMotionAxis,
                          NvOdmAccelAxisType *IntTapAxis)
{
    NvU32  temp;
    NV_ASSERT(NULL != hDevice);
    NV_ASSERT(NULL != IntType);
    NV_ASSERT(NULL != IntMotionAxis);
    NV_ASSERT(NULL != IntTapAxis);
    
    NvOdmOsSemaphoreWait( hDevice->SemaphoreForINT);
    
    NvAccelerometerGetInterruptSouce( hDevice , IntType, IntMotionAxis, IntTapAxis);
    //NvOdmOsDebugPrintf("Captured interrupt!!!\n");
    NvOdmAccelerometerGetParameter(hDevice, XLR_INTCONTROL2, &temp); 
    temp |= XLR_INTCONTROL2_CLR_INT;
    NvOdmAccelerometerSetParameter(hDevice, XLR_INTCONTROL2, temp);
    temp &= XLR_INTCONTROL2_CLR_INT_MASK;
    NvOdmAccelerometerSetParameter(hDevice, XLR_INTCONTROL2, temp);

    //This is a WAR for ADI340 to prevent I2C register from unstable state
    NvOdmAccelerometerGetParameter(hDevice, XLR_INTCONTROL, &temp);
    //NvOdmOsDebugPrintf("XLR_INTCONTROL is 0x%x\n", temp);
    NvOdmAccelerometerGetParameter(hDevice, XLR_THRESHG, &temp);
    //NvOdmOsDebugPrintf("XLR_THRESHG is 0x%x\n", temp);
    NvOdmAccelerometerGetParameter(hDevice, XLR_INTSOURCE, &temp);
    //NvOdmOsDebugPrintf("XLR_INTSOURCE is 0x%x\n", temp);
    return ;
}
/* 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;
}