📄 refddcproc.c
字号:
}
/****************************************************************************/
/* 0xf3 Capabilities request */
/* */
/* Return the DDC/CI capabilities string in 32-byte segments. */
/****************************************************************************/
static DDC_COMP ciCmdGetCap( pCI_MESSAGE pMsg, pCI_MESSAGE pRsp )
{
uint08 bCount;
uint16 reqOffset = ( pMsg -> text[0] << 8 ) | pMsg -> text[1];
dbmsg_trace( DBM_DDCCI, "ciCmdGetCap\r\n" );
if( 0 == reqOffset ) /* request for first segment */
capOffset = 0;
else if( reqOffset == ( capOffset + 32 )) /* request for next segment */
capOffset += 32;
else if( reqOffset == capLength ) /* end of string */
capOffset = capLength;
else /* unexpected */
capOffset = 0;
bCount = ( capOffset + 32 ) > capLength ? capLength - capOffset : 32;
pRsp -> dstAddr = 0x50; /* destination address */
pRsp -> srcAddr = 0x6e; /* source address */
pRsp -> length = 0x80 | ( bCount + 3 ); /* message length (code + text) */
pRsp -> code = CIREP_GETCAP; /* operation code */
pRsp -> text[0] = (uint08)( capOffset >> 8 );
pRsp -> text[1] = (uint08) capOffset;
memcpy( &pRsp -> text[2], &capString[ capOffset ], bCount ); /* copy */
pRsp -> text[bCount + 2] = _ckSum( pRsp, bCount + 6 ); /* checksum */
ddcciRspAvailable( TRUE ); /* response is available */
return DDC_PASS;
}
/****************************************************************************/
/* 0x07 Get timing report */
/* */
/* Report horizontal and vertical frequencies and sync polarities, when ap- */
/* propriate. */
/****************************************************************************/
static DDC_COMP ciCmdGetTim( pCI_MESSAGE pMsg, pCI_MESSAGE pRsp )
{
uint08 timStat = 0; /* timing status byte */
ALC_StatusStruct alcStat; /* autolock status */
DP_CONNECTOR conn; /* active connector */
uint16 hFreq;
uint16 vFreq;
dbmsg_trace( DBM_DDCCI, "ciCmdGetTim\r\n" );
/************************************************/
/* Ensure an external source is displayed; the */
/* setting is fetched from the current source. */
/************************************************/
if(( conn = datapath_GetActiveDisplay()) >= LAST_CONNECTOR )
return DDC_NOINPUT;
/************************************************/
/* Format response and set "available" flag. */
/************************************************/
if( VGA == conn ) /* get sync polarity for VGA connector */
{
ALC_GetStatus( &alcStat );
if( ALC_POSITIVE_POLARITY == alcStat.PortHsyncPolarity )
timStat |= 0x02; /* indicates positive hSync */
if( ALC_POSITIVE_POLARITY == alcStat.PortVsyncPolarity )
timStat |= 0x01; /* indicates positive vSync */
}
SRC_GetHorizontalFrequency( SRC_PORT1, &hFreq );
SRC_GetVerticalFrequency ( SRC_PORT1, &vFreq );
dbmsg_ftrace( DBM_DDCCI, "ciCmdGetTim: h=%d v=%d\r\n", hFreq, vFreq );
pRsp -> dstAddr = 0x50; /* destination address */
pRsp -> srcAddr = 0x6e; /* source address */
pRsp -> length = 0x06; /* message length (code + text) */
pRsp -> code = CIREP_GETTIMING; /* operation code */
pRsp -> text[0] = timStat; /* result code */
pRsp -> text[1] = (uint08)( hFreq >> 8 ); /* horizontal freq */
pRsp -> text[2] = (uint08) hFreq; /* horizontal freq */
pRsp -> text[3] = (uint08)( vFreq >> 8 ); /* vertical freq */
pRsp -> text[4] = (uint08) vFreq; /* vertical freq */
pRsp -> text[5] = _ckSum( pRsp, 9 ); /* checksum */
ddcciRspAvailable( TRUE ); /* response is available */
return DDC_PASS;
}
/****************************************************************************/
/* Application-dependent debug message callback. */
/****************************************************************************/
void ddc_dumpDebug( void )
{
size_t length; /* current debug string length */
uint32 priortime = 0; /* time stamp of prior message */
uint32 currtime; /* time stamp of current message */
uint32 dt; /* delta-time, microseconds */
char *p = dbuffer; /* pointer into debug message buffer */
if( NULL != dbuffer )
{
while( *p )
{
length = strlen( p ); /* length of message string */
memcpy( &currtime, p + length + 1, 4 ); /* time stamp */
dt = (( currtime - priortime ) * 60 + 500 ) / 1000; /* delta */
priortime = currtime; /* bump time */
if( dt < 100000 )
dbmsg_ftrace( DBM_DDCCI, "%5d: %s\r\n", dt, p );
else
dbmsg_ftrace( DBM_DDCCI, "-----: %s\r\n", p );
p += ( length + 1 + 4 ); /* bump past current record */
}
dbp = dbuffer; /* pointer to first available byte */
dbremain = DBSIZE; /* bytes remaining in debug buffer */
*dbuffer = 0; /* end-of-messages marker */
}
}
/****************************************************************************/
/* Application-dependent debug message callback. */
/****************************************************************************/
void _ddcCallback( char *msg )
{
uint32 ts; /* free-running timer */
size_t length; /* size, including \0 */
if( NULL != dbuffer )
{
ts = TMR_GetTBCVal(); /* free-running timer */
length = 1 + strlen( msg ); /* size, including \0 */
if( dbremain > ( length + 4 ))
{
dbremain -= ( length + 4 ); /* number of bytes remaining */
memcpy( dbp, msg, length ); /* copy to buffer */
dbp += length; /* bump pointer */
memcpy( dbp, &ts, 4 ); /* time stamp */
dbp += 4; /* bump pointer */
*dbp = 0; /* end-of-messages marker */
}
}
}
/****************************************************************************/
/* Calculate checksum */
/****************************************************************************/
static uint08 _ckSum( void *p, uint08 n )
{
uint08 *mp = (uint08*)p;
uint08 cksum = 0;
while( n-- )
cksum ^= *mp++;
return cksum;
}
/****************************************************************************/
/* Get a VCP parameter */
/* - Get the limits of the parameter by calling the limit function. */
/* - Normalize the parameter. */
/* */
/* In some situations a setting may be undefined: The setting for Hue when */
/* displaying an RGB source, for example. If such a situation leads to an */
/* invalid normalized value, a mid-range value is reported. */
/****************************************************************************/
static void _getVCP( uint16 *hostValue, LIMFUNC limit, GETFUNC get )
{
int16 min, max; /*min/max limits */
int16 hwValue;
int32 t; /* 32-bit temporary providing headroom */
(*limit)( &min, &max ); /* get limits */
(*get)( &hwValue ); /* get hardware value */
t = MAXNORM * (int32)( hwValue - min ) / (int32)( max - min + 1 );
*hostValue = (uint16)t; /* normalized value */
if( *hostValue >= MAXNORM ) /* validity check */
*hostValue = MAXNORM / 2;
}
/****************************************************************************/
/* Set a VCP parameter */
/* - Get the limits of the parameter by calling the limit function. */
/* - Denormalize the parameter. */
/* - Update the parameter. */
/* - Save a local copy, indicating the value has been changed by DDC/CI. */
/****************************************************************************/
static void _setVCP( int16 *upValue, uint16 hostValue, LIMFUNC limit, SETFUNC set )
{
int16 min, max; /*min/max limits */
int32 t = hostValue; /* 32-bit temporary providing headroom */
(*limit)( &min, &max ); /* get limits */
t = ( t * ( max - min + 1 )) / MAXNORM; /* denormalize */
if( PASS == (*set)( min + (int16)t )) /* apply setting */
*upValue = min + (int16)t; /* save local copy of setting */
}
/****************************************************************************/
/* Set all local values to the un-set state. */
/****************************************************************************/
static void _unSet( void )
{
int x; /* temp index */
CI_SETTINGS tset = { UNSET, UNSET, UNSET, UNSET, UNSET }; /* settings */
for( x = 0; x < NUM_CONNECTORS; x++ ) /* initialize settings to 'unset' */
ciSettings[ x ] = tset;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -