accessoryservices/pluggeddisplay/pluggeddisplayengine/src/hdmicablestateconnected.cpp
branchRCL_3
changeset 12 4a5c47a50617
parent 0 4e1aa6a622a0
child 17 0b0048910c20
equal deleted inserted replaced
10:66ecddbca914 12:4a5c47a50617
    26 #include "hdmicablestatusfsm.h"
    26 #include "hdmicablestatusfsm.h"
    27 #include "hdmicablestateconnected.h"
    27 #include "hdmicablestateconnected.h"
    28 #include "tvoutconfigforhdmi.h"
    28 #include "tvoutconfigforhdmi.h"
    29 #include "edidhandler.h"
    29 #include "edidhandler.h"
    30 #include "trace.h"
    30 #include "trace.h"
       
    31 #include <centralrepository.h>
       
    32 #include <accessoriescrkeys.h>
       
    33 #include <tvoutconfig.h>
    31 
    34 
    32 
    35 
    33 
    36 
    34 
    37 
    35 // ======== LOCAL FUNCTIONS ========
    38 // ======== LOCAL FUNCTIONS ========
    75     if ( iTVOutConfigForSettingChanges )
    78     if ( iTVOutConfigForSettingChanges )
    76         {
    79         {
    77         iTVOutConfigForSettingChanges->Cancel();
    80         iTVOutConfigForSettingChanges->Cancel();
    78         delete iTVOutConfigForSettingChanges;
    81         delete iTVOutConfigForSettingChanges;
    79         }
    82         }
    80     }
    83     if ( iCRWatchForVOverScan )
    81 
    84         {
       
    85         iCRWatchForVOverScan->Cancel();
       
    86         delete iCRWatchForVOverScan;        
       
    87         }
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // From MCentralRepositoryObserver.
       
    92 // ---------------------------------------------------------------------------
       
    93 //
       
    94 void CHDMICableStateConnected::CentRepKeyChanged(
       
    95         TUid    aRepositoryId,
       
    96         TUint32 aId )
       
    97     {
       
    98     FUNC_LOG;
       
    99     if ( KCRUidTvoutSettings == aRepositoryId )
       
   100         {
       
   101         if ( KSettingsTvoutVerticalOverscan == aId  )
       
   102             {
       
   103             Input( EPDEIfCentralRepositoryWatch, EPDEIfCentralRepositoryWatchEventKeyChanged );
       
   104             }
       
   105         else
       
   106             {
       
   107             INFO_1("Unexpected CR key ID, aId 0x%x", aId );            
       
   108             }       
       
   109         }
       
   110     else
       
   111         {
       
   112         INFO_1("Unexpected Central Repository ID, aRepositoryId 0x%x", aRepositoryId);
       
   113         }
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // From MCentralRepositoryObserver.
       
   118 // ---------------------------------------------------------------------------
       
   119 //
       
   120 void CHDMICableStateConnected::CentRepGetKeyValueFailed(
       
   121         TUid    aRepositoryId,
       
   122         TUint32 aId,
       
   123         TInt    aError )
       
   124     {
       
   125     FUNC_LOG;
       
   126     // Make use of aError argument top get rid of compiler warning.
       
   127     TInt error( aError );
       
   128     if ( ( KCRUidTvoutSettings == aRepositoryId ) && ( KErrNone != error ) )
       
   129         {
       
   130         if ( KSettingsTvoutVerticalOverscan == aId  )
       
   131             {
       
   132             INFO_1(" Getting KSettingsTvoutVerticalOverscan from CR failed, aError %d", error );                                    
       
   133             }
       
   134         else
       
   135             {
       
   136             INFO_1("Unexpected CR key ID, aId 0x%x", aId );            
       
   137             }       
       
   138         }
       
   139     else
       
   140         {
       
   141         INFO_1("Unexpected Central Repository ID, aRepositoryId 0x%x", aRepositoryId);
       
   142         }    
       
   143     }
    82 
   144 
    83 // ---------------------------------------------------------------------------
   145 // ---------------------------------------------------------------------------
    84 // From MFSMState.
   146 // From MFSMState.
    85 // ---------------------------------------------------------------------------
   147 // ---------------------------------------------------------------------------
    86 //
   148 //
    87 void CHDMICableStateConnected::Enter( )
   149 void CHDMICableStateConnected::Enter( )
    88     {
   150     {
    89     FUNC_LOG;
   151     FUNC_LOG;
    90     TInt retVal( KErrNone );
   152     TInt retVal( KErrNone );
       
   153 	iOverScanSettingsChanged = EFalse;
    91     iCopyProtectListenFailCounter.iCount = 0;
   154     iCopyProtectListenFailCounter.iCount = 0;
    92     iTVOutConfigForCopyProtect->ResetLatestRecordedCopyProtectionStatus();
   155     iTVOutConfigForCopyProtect->ResetLatestRecordedCopyProtectionStatus();
    93     retVal = iEDIDHandler.FetchEDIDData();
   156     retVal = iEDIDHandler.FetchEDIDData();
    94     if ( KErrNone != retVal )
   157     if ( KErrNone != retVal )
    95         {
   158         {
   449                 iTVOutConfigForHDMI.Disable();            
   512                 iTVOutConfigForHDMI.Disable();            
   450                 }
   513                 }
   451             else
   514             else
   452                 {
   515                 {
   453                 iSubState = ESubStateConnected;
   516                 iSubState = ESubStateConnected;
   454                 TRAPD( err, iHDMICableStatusFSM.SettingsChangedL() );
   517 
   455                 if ( KErrNone != err )
   518 				if( !iOverScanSettingsChanged )
   456                     {
   519 					{
   457                     INFO_1( "iHDMICableStatusFSM.SettingsChangedL() failed, error code %i", err ); 
   520 	                TRAPD( err, iHDMICableStatusFSM.SettingsChangedL() );
   458                     }
   521 	                if ( KErrNone != err )
       
   522 	                    {
       
   523 	                    INFO_1( "iHDMICableStatusFSM.SettingsChangedL() failed, error code %i", err ); 
       
   524 	                    }
       
   525 					}
       
   526 				else
       
   527 					{
       
   528 					iOverScanSettingsChanged = EFalse;
       
   529 					}
   459                 ListenCopyProtectionStatusChanges();
   530                 ListenCopyProtectionStatusChanges();
   460                 iTVOutConfigForSettingChanges->ListenSettingsChanges();
   531                 iTVOutConfigForSettingChanges->ListenSettingsChanges();
       
   532 				iCRWatchForVOverScan->Watch();
   461                 }
   533                 }
   462             }
   534             }
   463         else if ( EIfTVOutConfigEventEnableFailed == aEvent )
   535         else if ( EIfTVOutConfigEventEnableFailed == aEvent )
   464             {
   536             {
   465             INFO( "Event: EIfTVOutConfigEventEnableFailed" );        
   537             INFO( "Event: EIfTVOutConfigEventEnableFailed" );        
   630             else
   702             else
   631                 {
   703                 {
   632                 iSubState = ESubStateConnected;
   704                 iSubState = ESubStateConnected;
   633                 ListenCopyProtectionStatusChanges();
   705                 ListenCopyProtectionStatusChanges();
   634                 iTVOutConfigForSettingChanges->ListenSettingsChanges();
   706                 iTVOutConfigForSettingChanges->ListenSettingsChanges();
       
   707 				iCRWatchForVOverScan->Watch();
   635                 }
   708                 }
   636             }
   709             }
   637         else if ( EPDEIfAccessoryControlEventConnectFailed == aEvent )
   710         else if ( EPDEIfAccessoryControlEventConnectFailed == aEvent )
   638             {
   711             {
   639             INFO( "Event: EPDEIfAccessoryControlEventConnectFailed" ); 
   712             INFO( "Event: EPDEIfAccessoryControlEventConnectFailed" ); 
   778                 INFO( "Event: EIfTVOutConfigEventCableDisconnected occurred while not listening" );
   851                 INFO( "Event: EIfTVOutConfigEventCableDisconnected occurred while not listening" );
   779                 // Stop listening Copy Protection status
   852                 // Stop listening Copy Protection status
   780                 iTVOutConfigForCopyProtect->Cancel();
   853                 iTVOutConfigForCopyProtect->Cancel();
   781                 // Stop listen setting changes
   854                 // Stop listen setting changes
   782                 iTVOutConfigForSettingChanges->Cancel();
   855                 iTVOutConfigForSettingChanges->Cancel();
       
   856 				iCRWatchForVOverScan->Cancel();
   783                 iSubState = ESubStateIdlingDisable;
   857                 iSubState = ESubStateIdlingDisable;
   784                 iTVOutConfigForHDMI.Disable();            
   858                 iTVOutConfigForHDMI.Disable();            
   785                 }
   859                 }
   786              }
   860              }
   787         else if ( EIfTVOutConfigEventCableDisconnected == aEvent )
   861         else if ( EIfTVOutConfigEventCableDisconnected == aEvent )
   790             iSubState = ESubStateIdlingDisable;
   864             iSubState = ESubStateIdlingDisable;
   791             // Stop listening Copy Protection status
   865             // Stop listening Copy Protection status
   792             iTVOutConfigForCopyProtect->Cancel();
   866             iTVOutConfigForCopyProtect->Cancel();
   793             // Stop listen setting changes
   867             // Stop listen setting changes
   794             iTVOutConfigForSettingChanges->Cancel();
   868             iTVOutConfigForSettingChanges->Cancel();
       
   869 			iCRWatchForVOverScan->Cancel();
   795             // Disable tv out
   870             // Disable tv out
   796             iTVOutConfigForHDMI.Disable();            
   871             iTVOutConfigForHDMI.Disable();            
   797             }
   872             }
   798         else if ( EIfTVOutConfigEventCableStatusListenFailed == aEvent )
   873         else if ( EIfTVOutConfigEventCableStatusListenFailed == aEvent )
   799             {
   874             {
   806                 iCableStatusListenFailCounter.iCounter = 0;
   881                 iCableStatusListenFailCounter.iCounter = 0;
   807                 // Stop listening Copy Protection status
   882                 // Stop listening Copy Protection status
   808                 iTVOutConfigForCopyProtect->Cancel();
   883                 iTVOutConfigForCopyProtect->Cancel();
   809                 // Stop listen setting changes
   884                 // Stop listen setting changes
   810                 iTVOutConfigForSettingChanges->Cancel();
   885                 iTVOutConfigForSettingChanges->Cancel();
       
   886 				iCRWatchForVOverScan->Cancel();
   811                 iTVOutConfigForHDMI.Disable();                       
   887                 iTVOutConfigForHDMI.Disable();                       
   812                 }
   888                 }
   813             else
   889             else
   814                 {
   890                 {
   815                 // Try once again
   891                 // Try once again
   819                     INFO( "Event: EIfTVOutConfigEventCableDisconnected occurred while not listening" );
   895                     INFO( "Event: EIfTVOutConfigEventCableDisconnected occurred while not listening" );
   820                     // Stop listening Copy Protection status
   896                     // Stop listening Copy Protection status
   821                     iTVOutConfigForCopyProtect->Cancel();
   897                     iTVOutConfigForCopyProtect->Cancel();
   822                     // Stop listen setting changes
   898                     // Stop listen setting changes
   823                     iTVOutConfigForSettingChanges->Cancel();
   899                     iTVOutConfigForSettingChanges->Cancel();
       
   900 					iCRWatchForVOverScan->Cancel();
   824                     iSubState = ESubStateIdlingDisable;
   901                     iSubState = ESubStateIdlingDisable;
   825                     iTVOutConfigForHDMI.Disable();            
   902                     iTVOutConfigForHDMI.Disable();            
   826                     }
   903                     }
   827                 }
   904                 }
   828             }
   905             }
   849                 iCopyProtectListenFailCounter.iCount = 0;
   926                 iCopyProtectListenFailCounter.iCount = 0;
   850                 // Stop listening cable status changes while disabling.
   927                 // Stop listening cable status changes while disabling.
   851                 iTVOutConfigForHDMI.Cancel();
   928                 iTVOutConfigForHDMI.Cancel();
   852                 // Stop listening Copy Protection status
   929                 // Stop listening Copy Protection status
   853                 iTVOutConfigForCopyProtect->Cancel();
   930                 iTVOutConfigForCopyProtect->Cancel();
       
   931 				iCRWatchForVOverScan->Cancel();
   854                 iSubState = ESubStateRejectingDisable;
   932                 iSubState = ESubStateRejectingDisable;
   855                 iTVOutConfigForHDMI.Disable();            
   933                 iTVOutConfigForHDMI.Disable();            
   856                 }
   934                 }
   857             }
   935             }
   858         else if ( EIfTVOutConfigEventSettingsChanged == aEvent )
   936         else if ( EIfTVOutConfigEventSettingsChanged == aEvent )
   860             INFO( "Event: EIfTVOutConfigEventSettingsChanged" );
   938             INFO( "Event: EIfTVOutConfigEventSettingsChanged" );
   861             // Stop listening cable connection status
   939             // Stop listening cable connection status
   862             iTVOutConfigForHDMI.Cancel();
   940             iTVOutConfigForHDMI.Cancel();
   863             // Stop listening Copy Protection status
   941             // Stop listening Copy Protection status
   864             iTVOutConfigForCopyProtect->Cancel();
   942             iTVOutConfigForCopyProtect->Cancel();
       
   943 			iCRWatchForVOverScan->Cancel();
   865             if ( iTVOutConfigForHDMI.GetTvOutConfig()->Enabled() )
   944             if ( iTVOutConfigForHDMI.GetTvOutConfig()->Enabled() )
   866                 {
   945                 {
   867                 iSubState = ESubStateResettingDisable;
   946                 iSubState = ESubStateResettingDisable;
   868                 iTVOutConfigForHDMI.Disable();
   947                 iTVOutConfigForHDMI.Disable();
   869                 }
   948                 }
   885             iSubState = ESubStateRejectingDisable;
   964             iSubState = ESubStateRejectingDisable;
   886             // Stop listening cable connection status
   965             // Stop listening cable connection status
   887             iTVOutConfigForHDMI.Cancel();
   966             iTVOutConfigForHDMI.Cancel();
   888             // Stop listening Copy Protection status
   967             // Stop listening Copy Protection status
   889             iTVOutConfigForCopyProtect->Cancel();
   968             iTVOutConfigForCopyProtect->Cancel();
       
   969 			iCRWatchForVOverScan->Cancel();
   890             iTVOutConfigForHDMI.Disable();            
   970             iTVOutConfigForHDMI.Disable();            
   891             }
   971             }
   892         else
   972         else
   893             {
   973             {
   894             INFO_1( "Unknown/unexpected Event Id: %i", aEvent );        
   974             INFO_1( "Unknown/unexpected Event Id: %i", aEvent );        
   895             }
   975             }
   896         break;
   976         break;
   897         }
   977         }
       
   978     case EPDEIfCentralRepositoryWatch:
       
   979         {       
       
   980         INFO( "Interface: EPDEIfCentralRepositoryWatch" );
       
   981         if ( EPDEIfCentralRepositoryWatchEventKeyChanged == aEvent )
       
   982             {
       
   983             INFO( "Event: EPDEIfCentralRepositoryWatchEventKeyChanged" );
       
   984 
       
   985 			// Get the available config
       
   986 			THdmiDviTimings curConfig;
       
   987 			
       
   988 			iTVOutConfigForHDMI.GetTvOutConfig()->GetConfig( curConfig );
       
   989 
       
   990 			if( (TTvSettings::EHDMI == curConfig.iConnector) && (!curConfig.iUnderscanEnabled) )
       
   991 				{					
       
   992 				// Clear the available config				
       
   993 				ClearAvailableTvOutConfig();
       
   994 
       
   995 				TInt retVal = iEDIDHandler.SetVideoParameters();
       
   996 				if ( KErrNone != retVal )
       
   997 					{
       
   998 					INFO( "Going to state <Rejected> since video parameter setting failed!" );		  
       
   999 					iTVOutConfigForSettingChanges->Cancel();
       
  1000 					iCRWatchForVOverScan->Cancel();
       
  1001 					iHDMICableStatusFSM.Transit( EHDMICableStateRejected ); 		
       
  1002 					}
       
  1003 				else
       
  1004 					{
       
  1005 					TFSMEventId event = iTVOutConfigForHDMI.ListenHDMICableStatusIfNoMissedEvents();
       
  1006 					if ( EIfTVOutConfigEventCableDisconnected == event )
       
  1007 						{
       
  1008 						INFO( "Retreating back to <Idle> since cable was disconnected while not listening!" );		  
       
  1009 						iTVOutConfigForSettingChanges->Cancel();
       
  1010 						iCRWatchForVOverScan->Cancel();
       
  1011 						iHDMICableStatusFSM.Transit( EHDMICableStateIdle ); 		
       
  1012 						}
       
  1013 					else
       
  1014 						{
       
  1015 						iOverScanSettingsChanged = ETrue;
       
  1016 						iSubState = ESubStateWaitForSettingsChanged;
       
  1017 						}
       
  1018 					}				
       
  1019 				}
       
  1020             }
       
  1021         else
       
  1022             {
       
  1023             INFO_1( "Unknown Event Id: %i", aEvent );        
       
  1024             }
       
  1025         break;
       
  1026         }       
   898     default:
  1027     default:
   899         {
  1028         {
   900         INFO_1( "Event received from unknown/unexpected interface Id: %i", aInterfaceId );        
  1029         INFO_1( "Event received from unknown/unexpected interface Id: %i", aInterfaceId );        
   901         break;
  1030         break;
   902         }
  1031         }
   936             iHDMICableStatusFSM.Transit( EHDMICableStateIdle );         
  1065             iHDMICableStatusFSM.Transit( EHDMICableStateIdle );         
   937             }
  1066             }
   938         else if ( EIfTVOutConfigEventSettingsChanged == aEvent )
  1067         else if ( EIfTVOutConfigEventSettingsChanged == aEvent )
   939             {
  1068             {
   940             INFO( "Event: EIfTVOutConfigEventSettingsChanged" );
  1069             INFO( "Event: EIfTVOutConfigEventSettingsChanged" );
   941             iSubState = ESubStateEnable;
  1070 			if( iOverScanSettingsChanged )
   942             iTVOutConfigForHDMI.Enable();
  1071 				{
       
  1072 	            if ( iTVOutConfigForHDMI.GetTvOutConfig()->Enabled() )
       
  1073 	                {
       
  1074 	                iSubState = ESubStateResettingDisable;
       
  1075 	                iTVOutConfigForHDMI.Disable();
       
  1076 	                }
       
  1077 	            else
       
  1078 	                {
       
  1079 	                iSubState = ESubStateResettingEnable;
       
  1080 	                iTVOutConfigForHDMI.Enable();                
       
  1081 	                }
       
  1082 				}
       
  1083 			else
       
  1084 				{
       
  1085 	            iSubState = ESubStateEnable;
       
  1086 	            iTVOutConfigForHDMI.Enable();
       
  1087 				}
   943             }
  1088             }
   944         else if ( EIfTVOutConfigEventSettingsChangesListenFailed == aEvent )
  1089         else if ( EIfTVOutConfigEventSettingsChangesListenFailed == aEvent )
   945             {
  1090             {
   946             INFO( "Event: EIfTVOutConfigEventSettingsChangesListenFailed" );
  1091             INFO( "Event: EIfTVOutConfigEventSettingsChangesListenFailed" );
   947             INFO( "Going to state <Rejected> since setting changes listening failed!" );        
  1092             INFO( "Going to state <Rejected> since setting changes listening failed!" );        
   960         }
  1105         }
   961     }
  1106     }
   962     }
  1107     }
   963 
  1108 
   964 // ---------------------------------------------------------------------------
  1109 // ---------------------------------------------------------------------------
       
  1110 // ClearAvailableConfig
       
  1111 // ---------------------------------------------------------------------------
       
  1112 //
       
  1113 void CHDMICableStateConnected::ClearAvailableTvOutConfig()
       
  1114     {
       
  1115     FUNC_LOG;
       
  1116     
       
  1117     if( iTVOutConfigForHDMI.GetTvOutConfig() )
       
  1118         {
       
  1119         RArray<THdmiDviTimings> HdmiSettingsArray;        
       
  1120     	RArray<TTvSettings> TvSettingsArray;       
       
  1121     
       
  1122         TInt err = iTVOutConfigForHDMI.GetTvOutConfig()->SetAvailableTvConfigList( TvSettingsArray, HdmiSettingsArray );
       
  1123         
       
  1124         HdmiSettingsArray.Close();
       
  1125     	TvSettingsArray.Close();
       
  1126         }              
       
  1127     }
       
  1128 
       
  1129 
       
  1130 // ---------------------------------------------------------------------------
   965 // ConstructL
  1131 // ConstructL
   966 // ---------------------------------------------------------------------------
  1132 // ---------------------------------------------------------------------------
   967 //
  1133 //
   968 void CHDMICableStateConnected::ConstructL()
  1134 void CHDMICableStateConnected::ConstructL()
   969     {
  1135     {
   970     FUNC_LOG;
  1136     FUNC_LOG;
       
  1137     // Create Central Repository Watchers
       
  1138     iCRWatchForVOverScan = CCentralRepositoryWatch::NewL(*this, KCRUidTvoutSettings, KSettingsTvoutVerticalOverscan );
       
  1139 	
   971     iTVOutConfigForCopyProtect = CTVOutConfigForHDMI::NewL( iHDMICableStatusFSM );
  1140     iTVOutConfigForCopyProtect = CTVOutConfigForHDMI::NewL( iHDMICableStatusFSM );
   972     iTVOutConfigForSettingChanges = CTVOutConfigForHDMI::NewL( iHDMICableStatusFSM );
  1141     iTVOutConfigForSettingChanges = CTVOutConfigForHDMI::NewL( iHDMICableStatusFSM );	
   973     }
  1142     }
   974 
  1143 
   975 
  1144 
   976 // ---------------------------------------------------------------------------
  1145 // ---------------------------------------------------------------------------
   977 //  C++ constructor
  1146 //  C++ constructor