📄 dvi_hdmi.c.070605.int
字号:
#define B_RXSEN_MASK (1<<1)
#define B_HPD_MASK (1<<0)
#define REG_INT_MASK2 0x0A
#define B_PKT_AVI_MASK (1<<7)
#define B_PKT_ISRC_MASK (1<<6)
#define B_PKT_ACP_MASK (1<<5)
#define B_PKT_NULL_MASK (1<<4)
#define B_PKT_GEN_MASK (1<<3)
#define B_KSVLISTCHK_MASK (1<<2)
#define B_AUTH_DONE_MASK (1<<1)
#define B_AUTH_FAIL_MASK (1<<0)
#define REG_INT_MASK3 0x0B
#define B_AUDCTS_MASK (1<<5)
#define B_VSYNC_MASK (1<<4)
#define B_VIDSTABLE_MASK (1<<3)
#define B_PKT_MPG_MASK (1<<2)
#define B_PKT_SPD_MASK (1<<1)
#define B_PKT_AUD_MASK (1<<0)
#define REG_INT_CLR1 0x0C
#define B_CLR_PKTACP (1<<7)
#define B_CLR_PKTNULL (1<<6)
#define B_CLR_PKTGENERAL (1<<5)
#define B_CLR_KSVLISTCHK (1<<4)
#define B_CLR_AUTH_DONE (1<<3)
#define B_CLR_AUTH_FAIL (1<<2)
#define B_CLR_RXSENSE (1<<1)
#define B_CLR_HPD (1<<0)
#define REG_INT_CLR2 0x0D
#define B_CLR_VSYNC (1<<7)
#define B_CLR_VIDSTABLE (1<<6)
#define B_CLR_PKTMPG (1<<5)
#define B_CLR_PKTSPD (1<<4)
#define B_CLR_PKTAUD (1<<3)
#define B_CLR_PKTAVI (1<<2)
#define B_CLR_PKTISRC2 (1<<1)
#define B_CLR_PKTISRC1 (1<<0)
#define REG_SYS_STATUS 0x0E
// readonly
#define B_INT_ACTIVE (1<<7)
#define B_HPDETECT (1<<6)
#define B_RXSENDETECT (1<<5)
#define B_TXVIDSTABLE (1<<4)
// read/write
#define O_CTSINTSTEP 2
#define M_CTSINTSTEP (3<<2)
#define B_CLR_AUD_CTS (1<<1)
#define B_INTACTDONE (1<<0)
#define REG_BCAP 0x43
#define B_CAP_HDMI_REPEATER (1<<6)
#define B_CAP_KSV_FIFO_RDY (1<<5)
#define B_CAP_HDMI_FAST_MODE (1<<4)
#define B_CAP_HDCP_1p1 (1<<1)
#define B_CAP_FAST_REAUTH (1<<0)
#define REG_BSTAT 0x44
#define REG_BSTAT0 0x44
#define REG_BSTAT1 0x45
#define B_CAP_HDMI_MODE (1<<12)
#define B_CAP_DVI_MODE (0<<12)
#define B_MAX_CASCADE_EXCEEDED (1<<11)
#define M_REPEATER_DEPTH (0x7<<8)
#define O_REPEATER_DEPTH 8
#define B_DOWNSTREAM_OVER (1<<7)
#define M_DOWNSTREAM_COUNT 0x7F
#define REG_AUTH_STAT 0x46
#define B_AUTH_DONE (1<<7)
// Assure pDH parameter is initialized
#define CHECK_pDH(func) do { \
if (0) fprintf(stderr, "[HDMI] Call to " func "()\n"); \
if (pDH == NULL) { \
if (! manutest) fprintf(stderr, "[HDMI] Call to " func " with invalid DH structure!\n"); \
return RM_FATALINVALIDPOINTER; \
} \
} while (0)
// Check a certain pointer parameter, return error if NULL
#define CHECK_PTR(func, ptr) do { \
if ((ptr) == NULL) { \
if (! manutest) fprintf(stderr, "[HDMI] Call to " func " with invalid Data pointer!\n"); \
return RM_FATALINVALIDPOINTER; \
} \
} while (0)
//2007/01/02 added by jj_tseng@chipadvanced.com [CAT6611]
#define DH_Switch_6611BANK(pDH, bank) \
{\
DH_i2c_write((pDH)->pRUA, &((pDH)->i2c_tx), 0xF, (bank)&1);\
}
#define DH_Clear_cat6611INT(pDH) \
{\
RMuint8 reg0E_data ;\
DH_i2c_read((pDH)->pRUA,&((pDH)->i2c_tx), 0xE, ®0E_data ) ;\
reg0E_data |= 1 ;\
DH_i2c_write((pDH)->pRUA,&((pDH)->i2c_tx), 0xE, reg0E_data ) ;\
reg0E_data &= ~1 ;\
DH_i2c_write((pDH)->pRUA,&((pDH)->i2c_tx), 0xE, reg0E_data ) ;\
}
#define DH_Clear_cat6611DDCFIFO(pDH) \
{\
DH_i2c_write((pDH)->pRUA,&((pDH)->i2c_tx), 0x11, 0x01 ) ;\
DH_i2c_write((pDH)->pRUA,&((pDH)->i2c_tx), 0x15, 0x09 ) ;\
}
#define DH_Set_cat6611_AVMute(pDH) \
{\
err = DH_i2c_write(pDH->pRUA, &(pDH->i2c_tx), 0x0F, 0);\
err = DH_i2c_write(pDH->pRUA, &(pDH->i2c_tx), 0xC1, 1);\
err = DH_i2c_write(pDH->pRUA, &(pDH->i2c_tx), 0xC6, 3);\
}
#define DH_Clear_cat6611_AVMute(pDH) \
{\
err = DH_i2c_write(pDH->pRUA, &(pDH->i2c_tx), 0x0F, 0);\
err = DH_i2c_write(pDH->pRUA, &(pDH->i2c_tx), 0xC1, 0);\
err = DH_i2c_write(pDH->pRUA, &(pDH->i2c_tx), 0xC6, 3);\
}
#define DEBUG_DelaySec(n) {\
int i ;\
for( i = 0 ; i < n ; i++ )\
{\
RMDBGPRINT((ENABLE, "%d ",i)) ;\
RMMicroSecondSleep(1000*1000);\
}\
RMDBGPRINT((ENABLE, "\n")) ;\
}
//~jj_tseng@chipadvanced.com 2007/01/02
// 2007/01/04 added by jjtseng
static RMstatus DHAbortDDC_cat6611(struct DH_control *pDH);
static RMstatus DHEnableAVIInfoFrame_cat6611(struct DH_control *pDH, struct CEA861InfoFrame *pInfoFrame) ;
static RMstatus DHDisableAVIInfoFrame_cat6611(struct DH_control *pDH);
static RMstatus DHEnableAudioInfoFrame_cat6611(struct DH_control *pDH, struct CEA861InfoFrame *pInfoFrame);
static RMstatus DHDisableAudioInfoFrame_cat6611(struct DH_control *pDH);
static RMstatus DHSetAudioClock_cat6611(struct DH_control *pDH,RMuint32 PixelClock,RMuint32 SampleClock);
static RMstatus DHSetAudioFormat_siI9030(struct DH_control *pDH,struct DH_AudioFormat *pAudioFormat);
static RMstatus DHSetAudioFormat_siI9030(struct DH_control *pDH,struct DH_AudioFormat *pAudioFormat);
static RMstatus DHSetAudioFormat_cat6611(struct DH_control *pDH,struct DH_AudioFormat *pAudioFormat);
static RMstatus DHDump_cat6611reg(struct DH_control *pDH);
static RMstatus DHInitChip_cat6611(struct DH_control *pDH) ;
static RMstatus DHSoftReset_cat6611(struct DH_control *pDH) ;
static RMstatus DHSetAFE_cat6611(struct DH_control *pDH, RMbool bHighFreq) ;
static RMstatus DHFireAFE_cat6611(struct DH_control *pDH) ;
static RMstatus DHEnable_cat6611(struct DH_control *pDH);
static RMstatus DHEnableHDMIOutput_cat6611(struct DH_control *pDH, RMbool bHDMI) ;
static RMstatus DHDisable_cat6611(struct DH_control *pDH);
static RMstatus DHGetBKSV_cat6611(struct DH_control *pDH, RMuint8 *pBKSV);
static RMstatus DHGetBCaps_cat6611(struct DH_control *pDH, RMuint8 *pBCaps);
static RMstatus DHGetBStatus_cat6611(struct DH_control *pDH, RMuint16 *pBStatus);
static RMstatus DHDDCBlockReadSegment_cat6611(struct DH_control *pDH, RMuint8 i2cAddr, RMuint8 i2cSegmentPtr, RMuint32 RegAddr, RMuint8 *pData, RMuint32 NbBytes) ;
static RMstatus DHDDCBlockRead_cat6611(struct DH_control *pDH, RMuint8 i2cAddr, RMuint8 RegAddr, RMuint8 *pData, RMuint8 NbBytes) ;
static RMstatus DHAuthenticate_cat6611(struct DH_control *pDH);
static RMstatus DHEnableEncryption_cat6611(struct DH_control *pDH);
static RMstatus DHDisableEncryption_cat6611(struct DH_control *pDH);
static RMstatus DHVerifyIntegrity_cat6611(struct DH_control *pDH);
static RMstatus DHCheckHDMI_cat6611(struct DH_control *pDH, struct DH_HDMI_state *pHDMIState) ;
static RMstatus DHGetVr_cat6611(struct DH_control *pDH, RMuint8 *pVr) ;
static RMstatus DHFinishKSVList_cat6611(struct DH_control *pDH, RMbool bSuccess);
static RMstatus DHCheckHDMI_siI164(struct DH_control *pDH, struct DH_HDMI_state *pHDMIState) ;
static RMstatus DHCheckHDMI_cat6611( struct DH_control *pDH, struct DH_HDMI_state *pHDMIState);
//~jjtseng 2007/01/04
// 2007/03/08 added by jj_tseng@chipadvanced.com
static RMstatus DHSetIntMask_cat6611(struct DH_control *pDH) ;
//~jj_tseng@chipadvanced.com
static RMstatus DH_update_i2c(struct RUA *pRUA, struct DH_I2C *pi2c_dev)
{
RMstatus err;
if (pi2c_dev != pi2c_prev_dev) {
if (i2c_usage) return RM_PENDING; // new configuratio while old one still in use, try again later
i2c_usage = 1; // set I2C usage counter for new configuration
pi2c_prev_dev = pi2c_dev;
RMDBGLOG((DISABLE, "Set new i2c config, ModuleID 0x%08lX, dev W=0x%02X, R=0x%02X, Clk=%ld, Data=%ld\n",
pi2c_dev->I2C, pi2c_dev->dev.WrAddr, pi2c_dev->dev.RdAddr,
pi2c_dev->dev.PioClock, pi2c_dev->dev.PioData));
err = RUASetProperty(pRUA,
pi2c_dev->I2C,
RMI2CPropertyID_DeviceParams,
&(pi2c_dev->dev), sizeof(struct I2C_DeviceParams_type), 0);
if (RMFAILED(err)) {
RMDBGLOG((LOCALDBG, "Error setting RMI2CPropertyID_DeviceParams! Error %s\n", RMstatusToString(err)));
i2c_usage = 0;
return err;
}
} else {
i2c_usage++; // increase I2C usage counter for current configuration
}
return RM_OK;
}
#define DH_I2C_VERIFY_WRITE 0
static RMstatus DH_i2c_read(struct RUA *pRUA, struct DH_I2C *pi2c_dev, RMuint8 sub_address, RMuint8 *value)
{
struct I2C_QueryRMuint8_in_type i2c_param;
struct I2C_QueryRMuint8_out_type i2c_res;
RMstatus err;
RMuint32 r;
if (value == NULL) {
return RM_FATALINVALIDPOINTER;
}
r = MAX_I2C_ATTEMPTS;
do {
if (RMFAILED(err = DH_update_i2c(pRUA, pi2c_dev))) continue;
i2c_param.SubAddr = sub_address;
err = RUAExchangeProperty(pRUA, pi2c_dev->I2C, RMI2CPropertyID_QueryRMuint8, &i2c_param, sizeof(i2c_param), &i2c_res, sizeof(i2c_res));
i2c_usage--; // decrease usage counter for this I2C configuration
} while (--r && RMFAILED(err));
if (RMFAILED(err)) {
#if 1
RMDBGLOG((LOCALDBG, "Error setting RMI2CPropertyID_QueryRMuint8(0x%X:0x%02X) on I2C 0x%08lX GPIO %lu/%lu! %s\n",
pi2c_dev->dev.WrAddr, i2c_param.SubAddr,
pi2c_dev->I2C, pi2c_dev->dev.PioClock, pi2c_dev->dev.PioData,
RMstatusToString(err)));
RMDBGLOG((LOCALDBG,"pi2c_dev->dev.DelayUs = %d\n",pi2c_dev->dev.DelayUs)) ;
#else
fprintf(stderr, "Error setting RMI2CPropertyID_QueryRMuint8(0x%02x:0x%02X) on I2C 0x%08lX GPIO %d/%d! %s\n",
(RMint8)pi2c_dev->dev.WrAddr, (RMint8)i2c_param.SubAddr,
pi2c_dev->I2C, pi2c_dev->dev.PioClock, pi2c_dev->dev.PioData,
RMstatusToString(err));
fprintf(stderr,"pi2c_dev->dev.DelayUs = %ld\n",pi2c_dev->dev.DelayUs) ;
#endif
}
*value = i2c_res.Data;
return err;
}
static RMstatus DH_i2c_write(struct RUA *pRUA, struct DH_I2C *pi2c_dev, RMuint8 sub_address, RMuint8 value)
{
struct I2C_WriteRMuint8_type i2c_write;
RMstatus err;
RMuint32 r;
RMDBGLOG((DISABLE, "==== I2C Wr 0x%X:0x%02X 0x%02X ====\n", pi2c_dev->dev.WrAddr, sub_address, value));
r = MAX_I2C_ATTEMPTS;
do {
if (RMFAILED(err = DH_update_i2c(pRUA, pi2c_dev))) continue;
i2c_write.SubAddr = sub_address;
i2c_write.Data = value;
err = RUASetProperty(pRUA, pi2c_dev->I2C, RMI2CPropertyID_WriteRMuint8, &i2c_write, sizeof(i2c_write), 0);
i2c_usage--; // decrease usage counter for this I2C configuration
} while (--r && RMFAILED(err));
if (RMFAILED(err)) {
#if 1
RMDBGLOG((LOCALDBG, "Error setting RMI2CPropertyID_WriteRMuint8(0x%02X:0x%02X, 0x%02X) on I2C 0x%08lX GPIO %lu/%lu! %s\n",
pi2c_dev->dev.WrAddr, i2c_write.SubAddr, i2c_write.Data,
pi2c_dev->I2C, pi2c_dev->dev.PioClock, pi2c_dev->dev.PioData,
RMstatusToString(err)));
RMDBGLOG((LOCALDBG,"pi2c_dev->dev.DelayUs = %d\n",pi2c_dev->dev.DelayUs)) ;
#else
fprintf(stderr, "Error setting RMI2CPropertyID_WriteRMuint8(0x%02X:0x%02X, 0x%02X) on I2C 0x%08lX GPIO %u/%u! %s\n",
pi2c_dev->dev.WrAddr, i2c_write.SubAddr, i2c_write.Data,
pi2c_dev->I2C, pi2c_dev->dev.PioClock, pi2c_dev->dev.PioData,
RMstatusToString(err));
fprintf(stderr,"pi2c_dev->dev.DelayUs = %ld\n",pi2c_dev->dev.DelayUs) ;
#endif
}
#if DH_I2C_VERIFY_WRITE
DH_i2c_read(pRUA, pi2c_dev, sub_address, &i2c_write.Data);
if (i2c_write.Data != value) {
RMDBGLOG((LOCALDBG, "Error verifying 0x%02lX:0x%02lX, is 0x%02X instead of 0x%02X!\n",
pi2c_dev->dev.WrAddr, i2c_write.SubAddr, i2c_write.Data, value));
}
#endif // DH_I2C_VERIFY_WRITE
return err;
}
static RMstatus DH_i2c_read_data(struct RUA *pRUA, struct DH_I2C *pi2c_dev, RMuint8 sub_address, RMuint8 *data, RMuint32 data_size)
{
struct I2C_QueryData_in_type i2c_param;
struct I2C_QueryData_out_type i2c_res;
RMstatus err;
RMuint32 r;
if (data == NULL) {
return RM_FATALINVALIDPOINTER;
}
r = MAX_I2C_ATTEMPTS;
do {
if (RMFAILED(err = DH_update_i2c(pRUA, pi2c_dev))) continue;
i2c_param.UseSubAddr = TRUE;
i2c_param.SubAddr = sub_address;
i2c_param.DataSize = data_size;
err = RUAExchangeProperty(pRUA, pi2c_dev->I2C, RMI2CPropertyID_QueryData, &i2c_param, sizeof(i2c_param), &i2c_res, sizeof(i2c_res));
i2c_usage--; // decrease usage counter for this I2C configuration
} while (--r && RMFAILED(err));
if (RMFAILED(err)) {
RMDBGLOG((LOCALDBG, "Error setting RMI2CPropertyID_QueryData(0x%02X:0x%02X, 0x%02X) on I2C 0x%08lX GPIO %lu/%lu! %s\n",
pi2c_dev->dev.WrAddr, i2c_param.SubAddr, i2c_param.DataSize,
pi2c_dev->I2C, pi2c_dev->dev.PioClock, pi2c_dev->dev.PioData,
RMstatusToString(err)));
}
RMMemcpy(data, i2c_res.Data, data_size);
return err;
}
static RMstatus DH_i2c_read_data_segment(
struct RUA *pRUA,
struct DH_I2C *pi2c_dev,
RMuint8 sub_address,
RMuint8 *data,
RMuint32 data_size,
RMuint8 segment_ptr,
RMuint8 segment)
{
struct I2C_SelectSegment_type i2c_segment;
RMstatus err;
RMuint32 r;
if (data == NULL) {
return RM_FATALINVALIDPOINTER;
}
r = MAX_I2C_ATTEMPTS;
do {
if (RMFAILED(err = DH_update_i2c(pRUA, pi2c_dev))) continue;
i2c_segment.SegmentPtr = segment_ptr;
i2c_segment.Segment = segment;
err = RUASetProperty(pRUA, pi2c_dev->I2C, RMI2CPropertyID_SelectSegment, &i2c_segment, sizeof(i2c_segment), 0);
i2c_usage--; // decrease usage counter for this I2C configuration
} while (--r && RMFAILED(err));
if (RMFAILED(err)) {
RMDBGLOG((LOCALDBG, "%s: failed to set RMI2CPropertyID_SelectSegment(0x%02X:0x%02X, 0x%02X) on I2C 0x%08lX GPIO %lu/%lu! %s\n",
(segment > 0) ? "Error" : "Warning",
pi2c_dev->dev.WrAddr, i2c_segment.SegmentPtr, i2c_segment.Segment,
pi2c_dev->I2C, pi2c_dev->dev.PioClock, pi2c_dev->dev.PioData,
RMstatusToString(err)));
if (segment > 0) return err;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -