omap3530/shared/serialkeyb/serialkeyboard.cpp
changeset 115 0a9dcad6d856
parent 51 254b9435d75e
child 116 e7f4b52d2c87
equal deleted inserted replaced
114:cb014a8b6324 115:0a9dcad6d856
   321 
   321 
   322 private:
   322 private:
   323 	static void UartIsr( TAny* aParam );
   323 	static void UartIsr( TAny* aParam );
   324 	static void AddKeyDfc( TAny* aParam );
   324 	static void AddKeyDfc( TAny* aParam );
   325 	void AddKey( TUint aKey );
   325 	void AddKey( TUint aKey );
   326 	
   326 
   327 
   327 
   328 private:
   328 private:
   329 	enum TState
   329 	enum TState
   330 		{
   330 		{
   331 		ENormal,
   331 		ENormal,
   358 		{
   358 		{
   359 #ifdef USE_SYMBIAN_PRM
   359 #ifdef USE_SYMBIAN_PRM
   360 		// Register with the power resource manager
   360 		// Register with the power resource manager
   361 		_LIT( KName, "serkey" );
   361 		_LIT( KName, "serkey" );
   362 		r = PowerResourceManager::RegisterClient( iPrmClientId, KName );
   362 		r = PowerResourceManager::RegisterClient( iPrmClientId, KName );
   363 		__KTRACE_OPT(KBOOT,Kern::Printf("+TSerialKeyboardl::Create:PRM client ID=%x, err=%d", iPrmClientId, r));
   363 		__KTRACE_OPT(KEXTENSION,Kern::Printf("+TSerialKeyboardl::Create:PRM client ID=%x, err=%d", iPrmClientId, r));
   364 		if( r != KErrNone )
   364 		if( r != KErrNone )
   365 			{
   365 			{
   366 			return r;
   366 			return r;
   367 			}
   367 			}
   368 #endif
   368 #endif
   371 		Prcm::SetClockState(iUart.PrcmFunctionClk(), Prcm::EClkOn);
   371 		Prcm::SetClockState(iUart.PrcmFunctionClk(), Prcm::EClkOn);
   372 
   372 
   373  		r = Interrupt::Bind( iUart.InterruptId(), UartIsr, this );
   373  		r = Interrupt::Bind( iUart.InterruptId(), UartIsr, this );
   374 		if ( r < 0 )
   374 		if ( r < 0 )
   375  			{
   375  			{
   376  			Kern::Printf("TSerialKeyboard Bind r=%d", r);
   376  			__KTRACE_OPT(KBOOT,Kern::Printf("TSerialKeyboard Bind r=%d", r));
   377 			return r;
   377 			return r;
   378  			}
   378  			}
   379 
   379 
   380 		Kern::Printf("+TSerialKeyboard::Create bound to interrupt" );
   380 		__KTRACE_OPT(KEXTENSION,Kern::Printf("+TSerialKeyboard::Create bound to interrupt" ));
   381 
   381 
   382 #ifdef USE_SYMBIAN_PRM
   382 #ifdef USE_SYMBIAN_PRM
   383 		// Ask power resource manager to turn on clocks to the UART
   383 		// Ask power resource manager to turn on clocks to the UART
   384 		// (this could take some time but we're not in any hurry)
   384 		// (this could take some time but we're not in any hurry)
   385 		r = PowerResourceManager::ChangeResourceState( iPrmClientId, iUart.PrmFunctionClk(), Prcm::EClkOn );
   385 		r = PowerResourceManager::ChangeResourceState( iPrmClientId, iUart.PrmFunctionClk(), Prcm::EClkOn );
   405 	}
   405 	}
   406 
   406 
   407 void TSerialKeyboard::UartIsr( TAny* aParam )
   407 void TSerialKeyboard::UartIsr( TAny* aParam )
   408 	{
   408 	{
   409 	TSerialKeyboard* self = reinterpret_cast<TSerialKeyboard*>( aParam );
   409 	TSerialKeyboard* self = reinterpret_cast<TSerialKeyboard*>( aParam );
   410 	
   410 
   411 	const TUint iir = Omap3530Uart::IIR::iMem.Read( self->iUart );
   411 	const TUint iir = Omap3530Uart::IIR::iMem.Read( self->iUart );
   412 
   412 
   413 	if ( 0 == (iir bitand Omap3530Uart::IIR::IT_PENDING::KMask) )
   413 	if ( 0 == (iir bitand Omap3530Uart::IIR::IT_PENDING::KMask) )
   414 		{
   414 		{
   415 		const TUint pending = iir bitand Omap3530Uart::IIR::IT_TYPE::KFieldMask;
   415 		const TUint pending = iir bitand Omap3530Uart::IIR::IT_TYPE::KFieldMask;
   417 		// Although the TI datasheet descrivwed IT_TYPE as being an enumerated priority-decoded interrupt
   417 		// Although the TI datasheet descrivwed IT_TYPE as being an enumerated priority-decoded interrupt
   418 		// it appears to actually be a bitmask of active interrupt sources
   418 		// it appears to actually be a bitmask of active interrupt sources
   419 		if ( (pending bitand Omap3530Uart::IIR::IT_TYPE::ERHR) || (pending bitand Omap3530Uart::IIR::IT_TYPE::ERxLineStatus) )
   419 		if ( (pending bitand Omap3530Uart::IIR::IT_TYPE::ERHR) || (pending bitand Omap3530Uart::IIR::IT_TYPE::ERxLineStatus) )
   420 			{
   420 			{
   421 			TUint byte = self->iUart.Read();
   421 			TUint byte = self->iUart.Read();
   422 			
   422 
   423 			if( KMagicCrashValue == byte )
   423 			if( KMagicCrashValue == byte )
   424 				{
   424 				{
   425 				Kern::Fault( "SERKEY-FORCED", 0 );
   425 				Kern::Fault( "SERKEY-FORCED", 0 );
   426 				}
   426 				}
   427 			else
   427 			else
   465 		break;
   465 		break;
   466 
   466 
   467 	case EEscaping2:
   467 	case EEscaping2:
   468 		{
   468 		{
   469 		TInt index = self->iKey - KEscapeBase;
   469 		TInt index = self->iKey - KEscapeBase;
   470 		
   470 
   471 		if ( (index >= 0) && (index < KEscapeCount) )
   471 		if ( (index >= 0) && (index < KEscapeCount) )
   472 			{
   472 			{
   473 			self->AddKey( KEscapedScanCode[ index ] );
   473 			self->AddKey( KEscapedScanCode[ index ] );
   474 			}
   474 			}
   475 		else
   475 		else
   496 	const TBool func = ISFUNC(aKey);
   496 	const TBool func = ISFUNC(aKey);
   497 	const TUint8 stdKey = STDKEY(aKey);
   497 	const TUint8 stdKey = STDKEY(aKey);
   498 
   498 
   499 	TRawEvent e;
   499 	TRawEvent e;
   500 
   500 
   501 	
   501 
   502 	if ( func )
   502 	if ( func )
   503 		{
   503 		{
   504 		e.Set( TRawEvent::EKeyDown, EStdKeyRightFunc, 0 );
   504 		e.Set( TRawEvent::EKeyDown, EStdKeyRightFunc, 0 );
   505 		Kern::AddEvent( e );
   505 		Kern::AddEvent( e );
   506 		}
   506 		}
   507 	
   507 
   508 	if ( ctrl )
   508 	if ( ctrl )
   509 		{
   509 		{
   510 		e.Set( TRawEvent::EKeyDown, EStdKeyRightCtrl, 0 );
   510 		e.Set( TRawEvent::EKeyDown, EStdKeyRightCtrl, 0 );
   511 		Kern::AddEvent( e );
   511 		Kern::AddEvent( e );
   512 		}
   512 		}