📄 datapath.c
字号:
/* This function configures the datapath for a new external source */
/****************************************************************************/
int08 datapath_ConfigureForExternalSource( void )
{
SRC_SOURCE_CONFIG srcConfig;
int08 retval = FAIL;
switch( sourceDesc.connector )
{
case DVI:
retval = dvicontrol_FillSourceConfig( &sourceDesc, &srcConfig );
break;
case VGA:
retval = adccontrol_FillSourceConfig( &sourceDesc, &srcConfig );
break;
case COMPOSITE:
case SVIDEO:
case COMPONENT:
retval = deccontrol_FillSourceConfig( &sourceDesc, &srcConfig );
break;
}
if( retval != PASS )
{
dbmsg_ftrace( DBM_DPATH, "Datapath: FillSourceConfig failed on %s\r\n", datapathConnectorStringTable[sourceDesc.connector] );
return FAIL;
}
if( SRC_SetSourceConfiguration( sourceDesc.port, &srcConfig ) < PASS )
{
dbmsg_ftrace( DBM_DPATH, "Datapath: SRC_SetSourceConfig failed on %s\r\n", datapathConnectorStringTable[sourceDesc.connector] );
return FAIL;
}
DISP_SetChannelSource( SRC_PRIMARY, DISP_EXTERNAL_SOURCE );
sourceDesc.activeDisplay = DP_EXTERNAL;
dispfmt_ConfigureForSource( TRUE );
pictcont_ConfigureForExternalSource();
EE_PUTVAR( UserMachine.Projector.LastSource, sourceDesc.connector );
return PASS;
}
/****************************************************************************/
/* This function determines the connector search order */
/****************************************************************************/
void datapath_CycleConnector( BOOL force )
{
if( autoSourceSelect || force )
{
sourceDesc.connector = (sourceDesc.connector + 1) % LAST_CONNECTOR;
}
}
/****************************************************************************/
/* Starts the timer when entering a new state */
/****************************************************************************/
void datapath_ResetTimeInState( void )
{
stateStartTicks = TMR_GetTBCVal();
}
/****************************************************************************/
/* Returns time elapsed in the current state in milliseconds */
/****************************************************************************/
uint32 datapath_TimeElapsedInState( void )
{
uint32 ticks;
ticks = TMR_GetTBCVal();
if( stateStartTicks > ticks )
return (0xFFFFFFFF - stateStartTicks + 1 + ticks)/16666;
else
return (ticks - stateStartTicks)/16666;
}
/****************************************************************************/
/* Safely stops the current operations */
/****************************************************************************/
void datapath_StopCurrentOperation( void )
{
/* flag that the external source is not active */
sourceDesc.sourceActive = FALSE;
if( blankScreenEnabled )
{
blankScreenEnabled = FALSE; /* reset state of blank screen */
}
if( datapathState == TPG_DISPLAYED )
{
source_SetTestPattern( DPTPG_NONE, NULL ); /* disable TPG */
}
else
{
switch( sourceDesc.connector )
{
case DVI:
dvicontrol_StopCurrentOperation();
break;
case VGA:
adccontrol_StopCurrentOperation();
break;
case COMPOSITE:
case SVIDEO:
case COMPONENT:
deccontrol_StopCurrentOperation();
break;
}
}
}
/****************************************************************************/
/* Store off external source attributes that are overwritten by blank screen*/
/****************************************************************************/
void datapath_StoreSourceDesc( void )
{
savedDesc.inputFrameRate = sourceDesc.inputFrameRate;
savedDesc.inputHeight = sourceDesc.inputHeight;
savedDesc.inputWidth = sourceDesc.inputWidth;
savedDesc.nativeHeight = sourceDesc.nativeHeight;
savedDesc.nativeWidth = sourceDesc.nativeWidth;
}
/****************************************************************************/
/* Retried external source attributes that are overwritten by blank screen */
/****************************************************************************/
void datapath_RetrieveSourceDesc( void )
{
sourceDesc.inputFrameRate = savedDesc.inputFrameRate;
sourceDesc.inputHeight = savedDesc.inputHeight;
sourceDesc.inputWidth = savedDesc.inputWidth;
sourceDesc.nativeHeight = savedDesc.nativeHeight;
sourceDesc.nativeWidth = savedDesc.nativeWidth;
}
/****************************************************************************/
/* Enable/Set the Test Pattern Generator */
/* The state machine is in TPG_DISPLAYED state when the TPG is enabled */
/****************************************************************************/
int08 datapath_SetTestPattern( uint08 pattern )
{
if( pattern >= DPTPG_LIMIT )
return FAIL;
if( datapathState != TPG_DISPLAYED && pattern != DPTPG_NONE )
{
/***********/
/* turn on */
/***********/
sourceDesc.sourceActive = FALSE;
datapath_StopCurrentOperation();
datapath_GotoState( TPG_DISPLAYED );
/* setup TPG HW and configure */
if( source_SetTestPattern( pattern, &sourceDesc ) == PASS )
{
/* remove SFG/splash if it was enabled */
DISP_SetChannelSource( SRC_PRIMARY, DISP_EXTERNAL_SOURCE );
blankScreenEnabled = FALSE;
/* configure TPG for nominal settings */
sourceDesc.activeDisplay = DP_TESTPATTERN;
dispfmt_ConfigureForSource( FALSE );
pictcont_ConfigureForInternalSource();
return PASS;
}
return FAIL;
}
else if( datapathState == TPG_DISPLAYED && pattern != DPTPG_NONE )
{
/******************/
/* change pattern */
/******************/
/* change TPG HW */
if( source_SetTestPattern( pattern, &sourceDesc ) == PASS )
{
/* if blank has been enabled since TPG turned on, remove SFG/splash */
DISP_SetChannelSource( SRC_PRIMARY, DISP_EXTERNAL_SOURCE );
blankScreenEnabled = FALSE;
sourceDesc.activeDisplay = DP_TESTPATTERN;
dispfmt_ConfigureForSource( FALSE );
return PASS;
}
return FAIL;
}
else if( datapathState == TPG_DISPLAYED && pattern == DPTPG_NONE )
{
/************/
/* turn off */
/************/
source_SetTestPattern( DPTPG_NONE, NULL ); /* disable TPG */
/* setup SFG/splash for source search */
source_DisplaySFG( &sourceDesc );
dispfmt_ConfigureForSource( FALSE );
datapath_GotoState( BEGIN_SCAN ); /* restart source search */
return PASS;
}
/* do nothing if TPG is disabled and pattern == DPTPG_NONE */
return PASS;
}
/****************************************************************************/
/* AutoLock event callback -- translates AutoLock message into datapath msg */
/****************************************************************************/
void datapath_AlockEventHandler(ALC_AutoLockEventSourceEnum event_source, ALC_AutoLockEventEnum event)
{
uint16 msgID;
switch ( event )
{
case ALC_SOURCE_CHANGE_DETECTED: /* Generated when new sync signals are detected */
msgID = DPMSG_STATE_LOSTLOCK;
dbmsg_ftrace( DBM_DPATH, "Event: Source Change Detected on channel\r\n" );
break;
case ALC_SOURCE_DETECTED_STABLE: /* Generated when sync signals are considered stable. */
msgID = DPMSG_STATE_SYNCSDETECTED;
dbmsg_ftrace( DBM_DPATH, "Event: Source Stable Detected on channel\r\n" );
break;
case ALC_SOURCE_NO_SYNCS: /* Generated when no syncs are detected. */
msgID = DPMSG_STATE_LOSTLOCK;
dbmsg_ftrace( DBM_DPATH, "Event: Source No Syncs on channel\r\n" );
break;
case ALC_SOURCE_NO_VSYNCS: /* Generated when no VSYNC is detected. */
msgID = DPMSG_STATE_LOSTLOCK;
dbmsg_ftrace( DBM_DPATH, "Event: Source No Vsyncs on channel\r\n" );
break;
case ALC_SOURCE_NO_HSYNCS: /* Generated when no HSYNC is detected. */
msgID = DPMSG_STATE_LOSTLOCK;
dbmsg_ftrace( DBM_DPATH, "Event: Source No Hsyncs on channel\r\n" );
break;
case ALC_ASM_LOCKED: /* Generated when the alg declares the source locked. */
msgID = DPMSG_STATE_LOCKED;
dbmsg_ftrace( DBM_DPATH, "Event: ASM Locked on channel\r\n");
break;
case ALC_ASM_SYNCS_LOST: /* Generated when the sync mon func indicates a source change */
msgID = DPMSG_STATE_LOSTLOCK;
dbmsg_ftrace( DBM_DPATH, "Event: ASM Lock Lost on channel\r\n" );
break;
case ALC_ASM_REACQUIRE: /* Generated when the algorithm monitor indicates the source */
/* must be reacquired. */
msgID = DPMSG_STATE_REACQUIRE;
dbmsg_ftrace( DBM_DPATH, "Event: ASM Reaquire on channel\r\n" );
break;
case ALC_ASM_FAILED: /* Generated when the algorithm fails to lock to a source. When */
/* the algorithm fails, it will perform a best-guess set up of */
/* the ADC. If there is a change to the input sync signals, the */
/* algorithm will send the ALC_ASM_SYNC_LOST event and attempt */
/* to relock to the source. */
msgID = DPMSG_STATE_LOSTLOCK;
dbmsg_ftrace( DBM_DPATH, "Event: ASM Failed on channel\r\n" );
break;
case ALC_DSM_LOCKED: /* Generated when the algorithm declares the source locked. */
msgID = DPMSG_STATE_LOCKED;
dbmsg_ftrace( DBM_DPATH, "Event: DSM Locked on channel\r\n" );
break;
case ALC_DSM_SYNCS_LOST: /* Generated when the sync monitor function indicates a */
msgID = DPMSG_STATE_LOSTLOCK; /* source change. */
dbmsg_ftrace( DBM_DPATH, "Event: DSM Lock Lost on channel\r\n" );
break;
case ALC_DSM_REACQUIRE: /* Generated when the algorithm monitor indicates the source */
msgID = DPMSG_STATE_REACQUIRE; /* must be reacquired. */
dbmsg_ftrace( DBM_DPATH, "Event: DSM Reaquire on channel\r\n" );
break;
case ALC_DSM_FAILED: /* Generated when the algorithm fails to lock to a source. */
/* When the algorithm fails, it will remain in the current */
/* state until there is a change to the input sync signals. At */
/* this time, the DSM will issue the ALC_DSM_SYNC_LOST event */
/* and attempt to relock to the source. */
msgID = DPMSG_STATE_LOSTLOCK;
dbmsg_ftrace( DBM_DPATH, "Event: DSM Reaquire on channel\r\n");
break;
case ALC_I2C_DRIVER_TERMINAL_ERROR: /* Generated when the ADC driver sends up a terminal */
/* error from the I2C interface. */
msgID = DPMSG_STATE_LOSTLOCK;
dbmsg_ftrace( DBM_DPATH, "Event: I2C Terminal Error\r\n" );
break;
default:
dbmsg_ftrace( DBM_DPATH, "Event: Unknown event detected on channel\r\n" );
return;
}
/* This could be used to direct messages to the proper channel if PIP is available */
/* Since ddp2230 has only a single channel, this will be ignored */
switch ( event_source )
{
case ALC_PORT_EVENT: /* Source of event is port signal monitor */
case ALC_ASM_EVENT: /* Source of event is analog state machine */
case ALC_DSM_EVENT: /* Source of event is digital state machine */
break;
case ALC_MISC_EVENT: /* Miscellaneous event */
default:
break;
}
if( mbSend( datapathMbxID, msgID, -1, 0, FALSE, 0 ) != PASS )
{
/* send failed */
dbmsg_ftrace( DBM_DPATH, "Error: unable to send to AutoLock message to datapath task\r\n" );
}
}
/****************************************************************************/
/* AutoLock debug message callback */
/* This function traces non-fatal errors or conditions. */
/* This is useful during debug and integration. */
/****************************************************************************/
void datapath_AlockDebugTrace(const uint08* msg)
{
dbmsg_ftrace( DBM_DPATH, "ALC: %s", (char*)msg );
}
/****************************************************************************/
/* AutoLock State Machine callback -- used to display intermediate image */
/* before optimal phase is found */
/****************************************************************************/
BOOL datapath_AlockStateMachineCallback( ALC_ASMEnum statemachine )
{
switch( statemachine )
{
case ALC_PHASE_START:
/* block for up to a second waiting for the datapath to process */
mbSend( datapathMbxID, DPMSG_ALC_PHASESTART, 1000, 0, FALSE, 0 );
break;
case ALC_PHASE_END:
/* block for up to a second waiting for the datapath to process */
mbSend( datapathMbxID, DPMSG_ALC_PHASEEND, 1000, 0, FALSE, 0 );
break;
default:
break;
}
return TRUE; /* AutoLock requires this function to return TRUE */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -