/* **************************************************** */ DMD_ERROR_t DMD_TCB_WriteRead(DMD_u8_t slvadr , DMD_u8_t adr , DMD_u8_t* wdata , DMD_u32_t wlen , DMD_u8_t* rdata , DMD_u32_t rlen , DMD_PARAMETER_t* param ) { DMD_ERROR_t ret = DMD_E_OK; //------ Set to bypass Mode //ret |= DMD_I2C_Write( DMD_BANK_T2_ , DMD_TCBSET , 0xe3 ); ret |= DMD_I2C_Write( DMD_BANK_T2_ , DMD_TCBCOM , 0x1 ); //Example. Customer can communicate Tuner directly. //#################################################################### #error "Pls. add I2C function here! you can refer to function in <MN_I2C.c>\n " //#################################################################### //------ bypass mode off ret |= DMD_I2C_Write( DMD_BANK_T2_ , DMD_TCBCOM , 0x0 );// need off everytime, after off, SoC can communicate with Demod return ret; }
/* **************************************************** */ DMD_u32_t DMD_con_i2c_test( DMD_PARAMETER *param ) { DMD_s8_t buf[20]; DMD_s8_t com[10]; DMD_s32_t slv,adr,data; DMD_s32_t exitFlag=0; DMD_u8_t rd,rdd[257]; int i; while(!exitFlag) { printf("I2C Test : (r/w/d) (slave) (address) [data]>"); fgets( buf , 20 , stdin ); sscanf(buf , "%s %x %x %x" , com , &slv , &adr , &data); switch( com[0] ) { case 'w': DMD_I2C_Write( (DMD_u8_t)slv ,(DMD_u8_t)adr ,(DMD_u8_t)data ); printf("Write: %02x %02x %02x\n",slv,adr,data); break; case 'r': DMD_I2C_Read( (DMD_u8_t) slv, (DMD_u8_t) adr,&rd); printf("Read: %02x %02x %02x\n",slv,adr,rd); break; case 'd': printf(" _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _a _b _c _d _e _f"); for( i=0;i<256;i++ ) { if( (i%16) == 0 ) { DMD_I2C_WriteRead( ( DMD_u8_t) slv , (DMD_u8_t) i , 0 , 0, rdd , 16 ); printf("\n0x%x_ : " , i/16 ); } printf("%02x ",rdd[i%16] ); } printf("\n"); break; case 'q': exitFlag = 1; break; } } return DMD_E_OK; }
HI_S32 MN88472_Connect(HI_U32 u32TunerPort,TUNER_ACC_QAM_PARAMS_S *pstChannel) { DMD_PARAMETER_t * pstParaMeter; HI_U8 enI2cChan; DMD_ERROR_t enRet; DMD_u32_t i2caddr; HI_TUNER_CHECKPOINTER( pstChannel); /* Check tuner port and init. */ if (u32TunerPort >= MAX_TUNER) { HI_ERR_TUNER("Bad u32TunerPort\n"); return HI_FAILURE; } pstParaMeter = g_stMN88472Demod + u32TunerPort; enI2cChan = g_stTunerOps[u32TunerPort].enI2cChannel; i2caddr = g_stTunerOps[u32TunerPort].u32DemodAddress; pstParaMeter->freq = pstChannel->u32Frequency; switch(g_stTunerOps[u32TunerPort].enSigType) { case HI_UNF_TUNER_SIG_TYPE_CAB: pstParaMeter->system = DMD_E_DVBC; break; case HI_UNF_TUNER_SIG_TYPE_DVB_T: pstParaMeter->system = DMD_E_DVBT; break; case HI_UNF_TUNER_SIG_TYPE_DVB_T2: pstParaMeter->system = DMD_E_DVBT2; break; default: HI_ERR_TUNER("Signal type not supported!\n"); return HI_FAILURE; } if (HI_UNF_TUNER_SIG_TYPE_CAB != g_stTunerOps[u32TunerPort].enSigType) { switch(pstChannel->unSRBW.u32BandWidth) { case 5000: pstParaMeter->bw = DMD_E_BW_5MHZ; break; case 6000: pstParaMeter->bw = DMD_E_BW_6MHZ; break; case 7000: pstParaMeter->bw = DMD_E_BW_7MHZ; break; case 8000: pstParaMeter->bw = DMD_E_BW_8MHZ; break; case 1700: pstParaMeter->bw = DMD_E_BW_1_7MHZ; break; default: return HI_FAILURE; } } #if 1 enRet = g_stTunerOps[u32TunerPort].set_tuner(u32TunerPort, enI2cChan, pstParaMeter->freq); if (HI_SUCCESS != enRet) { HI_ERR_TUNER("MN88472 set tuner not ok\n"); return enRet; } HI_ERR_TUNER("MN88472 set tuner ok\n"); #endif /*set ts interface to parallel or serial*/ if(DMD_TS_PARALLEL == pstParaMeter->tstype) { if (DMD_E_ERROR == DMD_I2C_Write(enI2cChan, DMD_BANK_1st + i2caddr, DMD_TSSET1, 0)) { return HI_FAILURE; } if (DMD_E_ERROR == DMD_I2C_Write(enI2cChan, DMD_BANK_2nd + i2caddr, DMD_FIFOSET, 0xE3)) { return HI_FAILURE; } } else { if (DMD_E_ERROR == DMD_I2C_Write(enI2cChan, DMD_BANK_1st + i2caddr, DMD_TSSET1, 1)) { return HI_FAILURE; } if (DMD_E_ERROR == DMD_I2C_Write(enI2cChan, DMD_BANK_2nd + i2caddr, DMD_FIFOSET, 0xE3)) { return HI_FAILURE; } } enRet = DMD_set_system(pstParaMeter); if (DMD_E_OK != enRet) { return HI_FAILURE; } DMD_device_post_tune(pstParaMeter); return HI_SUCCESS; }
MXL_STATUS MxLWare603_OEM_WriteRegister(UINT8 devId, UINT8 RegAddr, UINT8 RegData) { // OEM should implement I2C write protocol that complies with MxL603 I2C // format. // 8 bit Register Write Protocol: // +------+-+-----+-+-+----------+-+----------+-+-+ // |MASTER|S|SADDR|W| |RegAddr | |RegData(L)| |P| // +------+-+-----+-+-+----------+-+----------+-+-+ // |SLAVE | |A| |A| |A| | // +------+---------+-+----------+-+----------+-+-+ // Legends: SADDR (I2c slave address), S (Start condition), A (Ack), N(NACK), // P(Stop condition) MXL_STATUS status = MXL_FALSE; /* If OEM data is implemented, customer needs to use OEM data structure related operation Following code should be used as a reference. For more information refer to sections 2.5 & 2.6 of MxL603_mxLWare_API_UserGuide document. UINT8 i2cSlaveAddr; UINT8 i2c_bus; user_data_t * user_data = (user_data_t *) MxL603_OEM_DataPtr[devId]; if (user_data) { i2cSlaveAddr = user_data->i2c_address; // get device i2c address i2c_bus = user_data->i2c_bus; // get device i2c bus sem_up(user_data->sem); // up semaphore if needed // I2C Write operation status = USER_I2C_WRITE_FUNCTION(i2cSlaveAddr, i2c_bus, RegAddr, RegData); sem_down(user_data->sem); // down semaphore user_data->i2c_cnt++; // user statistics } */ /* If OEM data is not required, customer should treat devId as I2C slave Address */ //sony_i2c_CommonWriteOneRegister //sony_i2c_CommonWriteRegister //result = pTuner->pI2c->WriteOneRegister(pTuner->pI2c, pTuner->i2cAddress, 0x44, 0x07); // result = pTuner->pI2c->WriteRegister(pTuner->pI2c, pTuner->i2cAddress, 0x01, data, sizeof(data)); #if 1 //status = Mxl603_Write_With_CXD2837(devId, RegAddr, RegData); status = DMD_I2C_Write(devId,RegAddr,RegData); #else #ifndef CONFIG_EDA31924_31804_MN88436_MXL603 devId = devId; RegAddr = RegAddr; RegData = RegData; printf(" Tuner write in , devid[%x], regaddr[%x], data[%x] \n", devId, RegAddr,RegData); //status = DMD_TCB_WriteRead(devId, RegAddr, &RegData, 1, 0, 0); status = DMD_I2C_Write(devId,RegAddr,RegData); #else unsigned char buf[20]; if(DemMode==39) {//MN88436 // printf(" Tuner write in , devid[%x], regaddr[%x], data[%x] \n", devId, RegAddr,RegData); // status = DMD_MN88436_TCB_Write(0xc0,RegAddr, RegData); buf[0]=0x15; buf[1]=0x53; I2CWrite(0x18,buf,2); buf[0]=0x17; buf[1]=0x00; I2CWrite(0x18,buf,2); // buf[0] = 0x18; buf[1] = 0x20; buf[2] = 0xc0; buf[3] = RegAddr; buf[4] = RegData; status = I2CWrite(buf[0],&buf[1],4); if(status) status = MXL_TRUE; else status = MXL_FALSE; if(status) printf("MN88436 write Tuner err %x\n",devId); // DMD_MN88436_TCB_Read(UINT8 slvadr , UINT8 adr , UINT8 *data); } #endif #endif return status; }