提交SMOD ATSC IMX APP版本 V122
This commit is contained in:
@@ -0,0 +1,655 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/07/27
|
||||
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod_dvbs_s2.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan.h"
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_Initialize(sony_demod_t * pDemod)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
sony_dvbs_s2_tune_param_t tuneParam;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_Initialize");
|
||||
|
||||
if (!pDemod){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
/* State check */
|
||||
if (pDemod->state != SONY_DEMOD_STATE_SLEEP){
|
||||
result = sony_demod_dvbs_s2_Sleep (pDemod);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN(result);
|
||||
}
|
||||
}
|
||||
|
||||
tuneParam.centerFreqKHz = 1000000;
|
||||
tuneParam.symbolRateKSps = 20000;
|
||||
tuneParam.system = SONY_DTV_SYSTEM_ANY;
|
||||
|
||||
result = sony_demod_dvbs_s2_Tune (pDemod, &tuneParam);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN(result);
|
||||
}
|
||||
|
||||
pDemod->dvbss2ScanMode = 0x01;
|
||||
|
||||
/* Set SLV-T Bank : 0x00 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OREG_ARC_CKACHGAUTO[0]
|
||||
* LS/HS auto selection : OFF
|
||||
*/
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x2B, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xAE */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAE) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OFSM_SRSON[0]
|
||||
* SR search : ON
|
||||
*/
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x24, 0x01) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OFSM_UNLOCKSEL_ARS[2:0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x2E, 0x05) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xA3 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA3) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xBD, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_PS_INIT (sony_demod_t * pDemod, uint8_t ocfr_csk)
|
||||
{
|
||||
uint8_t iqInv = 0;
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_PS_INIT");
|
||||
|
||||
if (!pDemod){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_SetSampleMode (pDemod, 1);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xA0 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OCFRL_CHSCANON[0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x56, 0x01) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OCFRL_CSK[2:0] (0x01 in normal case) */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x57, (ocfr_csk & 0x07)) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* Set SLV-T Bank : 0xAB */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAB) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OCFRL_CSBUFOFF[0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xF9, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_CheckIQInvert (pDemod, &iqInv);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN(result);
|
||||
}
|
||||
|
||||
if (iqInv){
|
||||
/* Set SLV-T Bank : 0xA0 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OTUIF_POLAR[0] */
|
||||
if (sony_i2c_SetRegisterBits (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xD7, 0x01, 0x01) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_PS_SET (sony_demod_t * pDemod,
|
||||
int32_t lowerOffsetKHz,
|
||||
int32_t upperOffsetKHz,
|
||||
uint32_t stepKHz,
|
||||
uint32_t ckaFreqKHz)
|
||||
{
|
||||
uint8_t data[6];
|
||||
int32_t startFreqKHz = 0;
|
||||
int32_t endFreqKHz = 0;
|
||||
uint32_t stepFreqKHz = 0;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_PS_SET");
|
||||
|
||||
if (!pDemod){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if (ckaFreqKHz == 0){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
startFreqKHz = (lowerOffsetKHz * 2048) / (int32_t)ckaFreqKHz; /* Floor */
|
||||
endFreqKHz = ((upperOffsetKHz * 2048) + ((int32_t)ckaFreqKHz - 1)) / (int32_t)ckaFreqKHz; /* Ceil */
|
||||
stepFreqKHz = ((stepKHz * 2048) + ( ckaFreqKHz - 1)) / ckaFreqKHz; /* Ceil */
|
||||
|
||||
data[0] = (uint8_t)(((uint32_t)startFreqKHz >> 8) & 0x07);
|
||||
data[1] = (uint8_t)(((uint32_t)startFreqKHz ) & 0xFF);
|
||||
data[2] = (uint8_t)(((uint32_t)endFreqKHz >> 8) & 0x07);
|
||||
data[3] = (uint8_t)(((uint32_t)endFreqKHz ) & 0xFF);
|
||||
data[4] = (uint8_t)(( stepFreqKHz >> 8) & 0x03);
|
||||
data[5] = (uint8_t)(( stepFreqKHz ) & 0xFF);
|
||||
|
||||
/* Set SLV-T Bank : 0xAB */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAB) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OCFRL_FSTART_CS[10:0]
|
||||
* OCFRL_FEND_CS[10:0]
|
||||
* OCFRL_FSTEP_CS[9:0]
|
||||
*/
|
||||
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xF1, data, 6) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_PS_START (sony_demod_t * pDemod)
|
||||
{
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_PS_START");
|
||||
|
||||
if (!pDemod){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xA0 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OCFRL_CHSCANST[0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x54, 0x01) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_PS_RACK (sony_demod_t * pDemod)
|
||||
{
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_PS_RACK");
|
||||
|
||||
if (!pDemod){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xA0 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OCFRL_CHSCANRACK[0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x55, 0x01) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_PS_FIN (sony_demod_t * pDemod)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
uint8_t iqInv = 0;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_PS_FIN");
|
||||
|
||||
if (!pDemod){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_SetSampleMode (pDemod, 0);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xA0 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OCFRL_CHSCANON[0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x56, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OCFRL_CSK[2:0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x57, 0x02) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* Set SLV-T Bank : 0xAB */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAB) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OCFRL_CSBUFOFF[0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xF9, 0x01) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_CheckIQInvert (pDemod, &iqInv);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN(result);
|
||||
}
|
||||
|
||||
if (iqInv){
|
||||
/* Set SLV-T Bank : 0xA0 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OTUIF_POLAR[0] */
|
||||
if (sony_i2c_SetRegisterBits (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xD7, 0x00, 0x01) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_CS_INIT (sony_demod_t * pDemod)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
uint8_t iqInv = 0;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_CS_INIT");
|
||||
|
||||
if (!pDemod){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xA0 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OCFRL_CHSCANON[0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x56, 0x01) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OCFRL_CSK[2:0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x57, 0x01) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_CheckIQInvert (pDemod, &iqInv);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN(result);
|
||||
}
|
||||
|
||||
if (iqInv){
|
||||
/* Set SLV-T Bank : 0xA0 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OTUIF_POLAR[0] */
|
||||
if (sony_i2c_SetRegisterBits (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xD7, 0x01, 0x01) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_CS_FIN (sony_demod_t * pDemod)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
uint8_t iqInv = 0;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_CS_FIN");
|
||||
|
||||
if (!pDemod){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xA0 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OCFRL_CHSCANON[0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x56, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OCFRL_CSK[2:0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x57, 0x02) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_CheckIQInvert (pDemod, &iqInv);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN(result);
|
||||
}
|
||||
|
||||
if (iqInv){
|
||||
/* Set SLV-T Bank : 0xA0 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OTUIF_POLAR[0] */
|
||||
if (sony_i2c_SetRegisterBits (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xD7, 0x00, 0x01) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_GetCSFIN (sony_demod_t * pDemod,
|
||||
uint8_t * pCSFIN)
|
||||
{
|
||||
uint8_t data = 0;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_GetCSFIN");
|
||||
|
||||
if ((!pDemod) || (!pCSFIN)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xA0 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* ICFRL_CSFIN[0] */
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x40, &data, 1) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (data & 0x01){
|
||||
*pCSFIN = 1;
|
||||
} else {
|
||||
*pCSFIN = 0;
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_GetCSRDEND (sony_demod_t * pDemod,
|
||||
uint8_t * pCSRDEND)
|
||||
{
|
||||
uint8_t data = 0;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_GetCSRDEND");
|
||||
|
||||
if ((!pDemod) || (!pCSRDEND)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xAB */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAB) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* ICFRL_CSRDEND[0] */
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x44, &data, 1) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (data & 0x01){
|
||||
*pCSRDEND = 1;
|
||||
} else {
|
||||
*pCSRDEND = 0;
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_GetCSINFO (sony_demod_t * pDemod,
|
||||
int32_t * pCSFREQ,
|
||||
uint32_t * pCSPOW)
|
||||
{
|
||||
uint8_t data[4];
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_GetCSINFO");
|
||||
|
||||
if ((!pDemod) || (!pCSFREQ) || (!pCSPOW)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xAB */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAB) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* ICFRL_CSFREQ[10:0]
|
||||
* ICFRL_CSPOW[11:0]
|
||||
*/
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x40, data, 4) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
*pCSFREQ = sony_Convert2SComplement(((uint32_t)(data[0] & 0x07) << 8) | (uint32_t)(data[1] & 0xFF), 11);
|
||||
*pCSPOW = ((uint32_t)(data[2] & 0x0F) << 8) | (uint32_t)(data[3] & 0xFF);
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_GetSRSFIN (sony_demod_t * pDemod,
|
||||
uint8_t * pSRSFIN)
|
||||
{
|
||||
uint8_t data = 0;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_GetSRSFIN");
|
||||
|
||||
if ((!pDemod) || (!pSRSFIN)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xAE */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAE) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* IFSM_SRSFIN_ARS[0] */
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x10, &data, 1) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (data & 0x01){
|
||||
*pSRSFIN = 1;
|
||||
} else {
|
||||
*pSRSFIN = 0;
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_CheckTRLLock (sony_demod_t * pDemod,
|
||||
uint8_t * pIsTRLLock)
|
||||
{
|
||||
uint8_t data = 0;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_CheckTRLLock");
|
||||
|
||||
if ((!pDemod) || (!pIsTRLLock)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xA0 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* ITRL_LOCK[0] */
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x10, &data, 1) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (data & 0x01){
|
||||
*pIsTRLLock = 1;
|
||||
} else {
|
||||
*pIsTRLLock = 0;
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_GetPSPow (sony_demod_t * pDemod,
|
||||
uint16_t * pPower)
|
||||
{
|
||||
uint8_t data[2] = {0, 0};
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_GetPSPow");
|
||||
|
||||
if ((!pDemod) || (!pPower)) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xA0 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* ICFRL_PSPOW[11:0] */
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x52, data, 2) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
*pPower = (uint16_t)(((uint32_t)(data[0] & 0x0F) << 8) | (uint32_t)(data[1] & 0xFF));
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_SetCFFine (sony_demod_t * pDemod,
|
||||
int32_t freqOffsetKHz)
|
||||
{
|
||||
uint8_t data[3];
|
||||
uint32_t regvalue = 0;
|
||||
uint8_t isNegative = 0;
|
||||
uint32_t tempQ = 0;
|
||||
uint32_t tempR = 0;
|
||||
uint32_t tempDiv = 0;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_SetCFFine");
|
||||
|
||||
if (!pDemod) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
freqOffsetKHz *= (-1);
|
||||
|
||||
if (freqOffsetKHz < 0){
|
||||
isNegative = 1;
|
||||
regvalue = (uint32_t)(freqOffsetKHz * (-1));
|
||||
} else {
|
||||
isNegative = 0;
|
||||
regvalue = (uint32_t)freqOffsetKHz;
|
||||
}
|
||||
|
||||
/*
|
||||
* regvalue = regvalue(21bit) * 2^20 / SONY_DEMOD_DVBS_S2_BLINDSCAN_CKAL
|
||||
* = ((regvalue(21bit) * 2^10) * 2^10) / SONY_DEMOD_DVBS_S2_BLINDSCAN_CKAL
|
||||
*/
|
||||
/* CKAL */
|
||||
tempDiv = 64000;
|
||||
|
||||
tempQ = (regvalue * 1024) / tempDiv;
|
||||
tempR = (regvalue * 1024) % tempDiv;
|
||||
|
||||
tempR *= 1024;
|
||||
tempQ = (tempQ * 1024) + (tempR / tempDiv);
|
||||
tempR = tempR % tempDiv;
|
||||
|
||||
if (tempR >= (tempDiv/2)){
|
||||
tempQ = tempQ + 1;
|
||||
} else {
|
||||
tempQ = tempQ;
|
||||
}
|
||||
|
||||
if (isNegative){
|
||||
if (tempQ > 0x100000) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_RANGE);
|
||||
}
|
||||
regvalue = (uint32_t)((int32_t)tempQ * (-1));
|
||||
} else {
|
||||
if (tempQ > 0xFFFFF) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_RANGE);
|
||||
}
|
||||
regvalue = tempQ;
|
||||
}
|
||||
|
||||
data[0] = (uint8_t)((regvalue >> 16) & 0x1F);
|
||||
data[1] = (uint8_t)((regvalue >> 8) & 0xFF);
|
||||
data[2] = (uint8_t)( regvalue & 0xFF);
|
||||
|
||||
/* Set SLV-T Bank : 0xA0 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OCFRL_CTRLVALINIT[20:0] */
|
||||
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xCA, data, 3) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_SetSampleMode (sony_demod_t * pDemod,
|
||||
uint8_t isHSMode)
|
||||
{
|
||||
uint8_t data = 0;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_SetSampleMode");
|
||||
|
||||
if (!pDemod){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if (isHSMode){
|
||||
data = 0x01;
|
||||
} else {
|
||||
data = 0x00;
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x00 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OREG_ARC_HSMODE[0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x24, data) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_SetSymbolRateRatio (sony_demod_t * pDemod,
|
||||
uint32_t ratioMin,
|
||||
uint32_t ratioMax)
|
||||
{
|
||||
uint8_t data[4];
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_SetSymbolRateRatio");
|
||||
|
||||
if (!pDemod){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if ((ratioMax > 0x03FF) || (ratioMin > 0x3FF)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
data[0] = (uint8_t)((ratioMax >> 8) & 0x03);
|
||||
data[1] = (uint8_t)( ratioMax & 0xFF);
|
||||
data[2] = (uint8_t)((ratioMin >> 8) & 0x03);
|
||||
data[3] = (uint8_t)( ratioMin & 0xFF);
|
||||
|
||||
/* Set SLV-T Bank : 0xAE */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAE) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
/* OFSM_RATIOMAX_ARS[9:0]
|
||||
* OFSM_RATIOMIN_ARS[9:0]
|
||||
*/
|
||||
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x28, data, 4) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,264 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/07/27
|
||||
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbs_s2_blindscan.h
|
||||
|
||||
This file provides functions to control demodulator for BlindScan/TuneSRS.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_H
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Initialize setting for starting BlindScan/TuneSRS
|
||||
|
||||
This function is used in this driver.
|
||||
User doesn't necessary to call it.
|
||||
|
||||
@param pDemod The driver instance.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_Initialize(sony_demod_t * pDemod);
|
||||
|
||||
/**
|
||||
@brief Initialize setting for power search.
|
||||
|
||||
This function is used in this driver.
|
||||
User doesn't necessary to call it.
|
||||
|
||||
@param pDemod The driver instance.
|
||||
@param ocfr_csk The register value of OCFR_CSK (1 - 7).
|
||||
In normal case, it should be 1.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_PS_INIT (sony_demod_t * pDemod, uint8_t ocfr_csk);
|
||||
|
||||
/**
|
||||
@brief Set parameters for power search.
|
||||
|
||||
This function is used in this driver.
|
||||
User doesn't necessary to call it.
|
||||
|
||||
@param pDemod The driver instance.
|
||||
@param lowerOffsetKHz lower offset frequency in KHz.
|
||||
@param upperOffsetKHz upper offset frequency in KHz.
|
||||
@param stepKHz step frequency in KHz.
|
||||
@param ckaFreqKHz CKA frequency in KHz.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_PS_SET (sony_demod_t * pDemod,
|
||||
int32_t lowerOffsetKHz,
|
||||
int32_t upperOffsetKHz,
|
||||
uint32_t stepKHz,
|
||||
uint32_t ckaFreqKHz);
|
||||
|
||||
/**
|
||||
@brief Start power search.
|
||||
|
||||
This function is used in this driver.
|
||||
User doesn't necessary to call it.
|
||||
|
||||
@param pDemod The driver instance.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_PS_START (sony_demod_t * pDemod);
|
||||
|
||||
/**
|
||||
@brief Set read ack.
|
||||
|
||||
This function is used in this driver.
|
||||
User doesn't necessary to call it.
|
||||
|
||||
@param pDemod The driver instance.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_PS_RACK (sony_demod_t * pDemod);
|
||||
|
||||
/**
|
||||
@brief Finalize settings for power search.
|
||||
|
||||
This function is used in this driver.
|
||||
User doesn't necessary to call it.
|
||||
|
||||
@param pDemod The driver instance.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_PS_FIN (sony_demod_t * pDemod);
|
||||
|
||||
/**
|
||||
@brief Initialize settings for coarse search.
|
||||
|
||||
This function is used in this driver.
|
||||
User doesn't necessary to call it.
|
||||
|
||||
@param pDemod The driver instance.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_CS_INIT (sony_demod_t * pDemod);
|
||||
|
||||
/**
|
||||
@brief Finalize settings for coarse search.
|
||||
|
||||
This function is used in this driver.
|
||||
User doesn't necessary to call it.
|
||||
|
||||
@param pDemod The driver instance.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_CS_FIN (sony_demod_t * pDemod);
|
||||
|
||||
/**
|
||||
@brief Get the finish flag for power data.
|
||||
|
||||
This function is used in this driver.
|
||||
User doesn't necessary to call it.
|
||||
|
||||
@param pDemod The driver instance.
|
||||
@param pCSFIN CSFIN flag (0: Not finished, 1: Finished)
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_GetCSFIN (sony_demod_t * pDemod,
|
||||
uint8_t * pCSFIN);
|
||||
|
||||
/**
|
||||
@brief Get the finish flag for power data in buffer.
|
||||
|
||||
This function is used in this driver.
|
||||
User doesn't necessary to call it.
|
||||
|
||||
@param pDemod The driver instance.
|
||||
@param pCSRDEND CSRDEND flag (0: Not ended, 1: Ended)
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_GetCSRDEND (sony_demod_t * pDemod,
|
||||
uint8_t * pCSRDEND);
|
||||
|
||||
/**
|
||||
@brief Get the frequency offset and power data.
|
||||
|
||||
This function is used in this driver.
|
||||
User doesn't necessary to call it.
|
||||
|
||||
@param pDemod The driver instance.
|
||||
@param pCSFREQ Frequency offset in KHz.
|
||||
@param pCSPOW Power value.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_GetCSINFO (sony_demod_t * pDemod,
|
||||
int32_t * pCSFREQ,
|
||||
uint32_t * pCSPOW);
|
||||
|
||||
/**
|
||||
@brief Get the flag indicate symbol rate search finished.
|
||||
|
||||
This function is used in this driver.
|
||||
User doesn't necessary to call it.
|
||||
|
||||
@param pDemod The driver instance.
|
||||
@param pSRSFIN The flag for symbol rate search finish.
|
||||
- 0 : Symbol rate search does not finished.
|
||||
- 1 : Symbol rate search finished.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_GetSRSFIN (sony_demod_t * pDemod,
|
||||
uint8_t * pSRSFIN);
|
||||
|
||||
/**
|
||||
@brief Get the TRL lock flag.
|
||||
|
||||
This function is used in this driver.
|
||||
User doesn't necessary to call it.
|
||||
|
||||
@param pDemod The driver instance.
|
||||
@param pIsTRLLock The TRL lock flag value.
|
||||
- 0 : TRL is not locked.
|
||||
- 1 : TRL is locked.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_CheckTRLLock (sony_demod_t * pDemod,
|
||||
uint8_t * pIsTRLLock);
|
||||
|
||||
/**
|
||||
@brief Get power data.
|
||||
|
||||
This function is used in this driver.
|
||||
User doesn't necessary to call it.
|
||||
|
||||
@param pDemod The driver instance.
|
||||
@param pPower Power value.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_GetPSPow (sony_demod_t * pDemod,
|
||||
uint16_t * pPower);
|
||||
|
||||
/**
|
||||
@brief Get frequency offset to measure power.
|
||||
|
||||
This function is used in this driver.
|
||||
User doesn't necessary to call it.
|
||||
|
||||
@param pDemod The driver instance.
|
||||
@param freqOffsetKHz Frequency offset in KHz.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_SetCFFine (sony_demod_t * pDemod,
|
||||
int32_t freqOffsetKHz);
|
||||
|
||||
/**
|
||||
@brief Set sampling rage mode.
|
||||
|
||||
This function is used in this driver.
|
||||
User doesn't necessary to call it.
|
||||
|
||||
@param pDemod The driver instance.
|
||||
@param isHSMode Sampling mode
|
||||
- 0 : LS mode
|
||||
- 1 : HS mode
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_SetSampleMode (sony_demod_t * pDemod,
|
||||
uint8_t isHSMode);
|
||||
|
||||
/**
|
||||
@brief Set sampling rage mode.
|
||||
|
||||
This function is used in this driver.
|
||||
User doesn't necessary to call it.
|
||||
|
||||
@param pDemod The driver instance.
|
||||
@param ratioMin Min symbol rate search ratio.
|
||||
@param ratioMax Max symbol rate search ratio.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_SetSymbolRateRatio (sony_demod_t * pDemod,
|
||||
uint32_t ratioMin,
|
||||
uint32_t ratioMax);
|
||||
|
||||
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,190 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/09/28
|
||||
Modification ID : 1ea04def104d657deb64f0d0b0cae6ef992a9dd8
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbs_s2_blindscan_algo.h
|
||||
|
||||
This file provides the algorithms for BlindScan/TuneSRS function.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_ALGO_H
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_ALGO_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Get candidate from power spectrum for multipath.
|
||||
|
||||
@param pStorage Storage instance.
|
||||
@param pPowerList Power spectrum data.
|
||||
@param clipStep Slicing step in dB x 100.
|
||||
@param minSymbolRateKSps Min symbol rate in KSps.
|
||||
@param maxSymbolRateKSps Max symbol rate in KSps.
|
||||
@param cferr Error frequency in KHz.
|
||||
@param pCandList Candidate list generated by this function.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_algo_GetCandidateMp (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pPowerList,
|
||||
uint32_t clipStep,
|
||||
uint32_t minSymbolRateKSps,
|
||||
uint32_t maxSymbolRateKSps,
|
||||
uint32_t cferr,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandList);
|
||||
|
||||
/**
|
||||
@brief Get candidate from power spectrum.
|
||||
|
||||
@param pStorage Storage instance.
|
||||
@param pPowerList Power spectrum data.
|
||||
@param clipStep Slicing step in dB x 100.
|
||||
@param minSymbolRateKSps Min symbol rate in KSps.
|
||||
@param maxSymbolRateKSps Max symbol rate in KSps.
|
||||
@param cferr Error frequency in KHz.
|
||||
@param pCandList Candidate list generated by this function.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_algo_GetCandidateNml (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pPowerList,
|
||||
uint32_t clipStep,
|
||||
uint32_t minSymbolRateKSps,
|
||||
uint32_t maxSymbolRateKSps,
|
||||
uint32_t cferr,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandList);
|
||||
|
||||
#ifdef SONY_DEMOD_SUPPORT_DVBS_S2_BLINDSCAN_VER2
|
||||
/**
|
||||
@brief Get candidate from power spectrum.
|
||||
|
||||
@param pStorage Storage instance.
|
||||
@param pPowerList Power spectrum data.
|
||||
@param minSymbolRateKSps Min symbol rate in KSps.
|
||||
@param maxSymbolRateKSps Max symbol rate in KSps.
|
||||
@param cferr Error frequency in KHz.
|
||||
@param edgeCount Count of edges used for edge filtering.
|
||||
@param overlapCount Count of overlaps used for edge filtering.
|
||||
@param threshold Power threshold used for edge filtering.
|
||||
@param pCandList Candidate list generated by this function.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_algo_GetCandidateEdge (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pPowerList,
|
||||
uint32_t minSymbolRateKSps,
|
||||
uint32_t maxSymbolRateKSps,
|
||||
uint32_t cferr,
|
||||
int32_t edgeCount,
|
||||
int32_t overlapCount,
|
||||
int32_t threshold,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandList);
|
||||
#endif
|
||||
|
||||
/**
|
||||
@brief Separate candidate for low symbol rate search
|
||||
|
||||
pCandList is updated by this function.
|
||||
|
||||
@param pStorage Storage instance.
|
||||
@param pCandList Candidate list.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_algo_SeparateCandidate (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandList);
|
||||
|
||||
/**
|
||||
@brief Reduce candidate which is out of range.
|
||||
|
||||
pCandList is updated by this function.
|
||||
|
||||
@param pStorage Storage instance.
|
||||
@param pCandList Candidate list.
|
||||
@param pChannelList Detected channel list.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_algo_ReduceCandidate (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandList,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pChannelList);
|
||||
|
||||
/**
|
||||
@brief Delete duplicated candidate
|
||||
|
||||
pCandList is updated by this function.
|
||||
|
||||
@param pStorage Storage instance.
|
||||
@param pCandList Candidate list.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_algo_DeleteDuplicate (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandList);
|
||||
|
||||
/**
|
||||
@brief Delete duplicated candidate
|
||||
|
||||
pCandList is updated by this function.
|
||||
|
||||
@param pStorage Storage instance.
|
||||
@param pCandList Candidate list.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_algo_DeleteDuplicate2 (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandList);
|
||||
|
||||
/**
|
||||
@brief Get non detected area from detected channel list.
|
||||
|
||||
@param pStorage Storage instance.
|
||||
@param minPowerFreqKHz Min frequency in KHz.
|
||||
@param maxPowerFreqKHz Max frequency in KHz.
|
||||
@param resolutionKHz Resolution in KHz.
|
||||
@param pChannelList Detected channel list.
|
||||
@param pBandList Not detected area list.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_algo_GetNonDetectedBand (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
uint32_t minPowerFreqKHz,
|
||||
uint32_t maxPowerFreqKHz,
|
||||
uint32_t resolutionKHz,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pChannelList,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pBandList);
|
||||
|
||||
/**
|
||||
@brief Sort candidate list by symbol rate.
|
||||
|
||||
@param pStorage Storage instance.
|
||||
@param pCandList Candidate list.
|
||||
@param baseSymbolRateKSps Sort base symbol rate in KSps.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_algo_SortBySymbolrate (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandList,
|
||||
uint32_t baseSymbolRateKSps);
|
||||
|
||||
/**
|
||||
@brief Sort candidate list by frequency.
|
||||
|
||||
@param pStorage Storage instance.
|
||||
@param pCandList Candidate list.
|
||||
@param baseFrequencyKHz Sort base frequency in KHz.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_algo_SortByFrequency (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandList,
|
||||
uint32_t baseFrequencyKHz);
|
||||
|
||||
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_ALGO_H */
|
||||
@@ -0,0 +1,98 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/09/28
|
||||
Modification ID : 1ea04def104d657deb64f0d0b0cae6ef992a9dd8
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbs_s2_blindscan_data.h
|
||||
|
||||
This file provides the definition of data used in BlindScan function.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_DATA_H
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_DATA_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_dtv.h"
|
||||
|
||||
/**
|
||||
@brief Power data
|
||||
*/
|
||||
typedef struct sony_demod_dvbs_s2_blindscan_power_t {
|
||||
struct sony_demod_dvbs_s2_blindscan_power_t * pNext;/**< Pointer of next item. */
|
||||
uint32_t freqKHz; /**< Frequency in KHz. */
|
||||
int32_t power; /**< Power data in dB x 100 */
|
||||
#ifdef SONY_DEMOD_SUPPORT_DVBS_S2_BLINDSCAN_VER2
|
||||
int32_t edge1; /**< Edge data1. */
|
||||
int32_t edge2; /**< Edge data2. */
|
||||
#endif
|
||||
} sony_demod_dvbs_s2_blindscan_power_t;
|
||||
|
||||
/**
|
||||
@brief Data used in BlindScan/TuneSRS sequence.
|
||||
*/
|
||||
typedef struct sony_demod_dvbs_s2_blindscan_data_t {
|
||||
struct sony_demod_dvbs_s2_blindscan_data_t * pNext; /**< The pointer of next item. */
|
||||
/**
|
||||
@brief Data type used in BlindScan/TuneSRS.
|
||||
|
||||
"union" is used to share memory between multiple purposes.
|
||||
*/
|
||||
union data_t {
|
||||
/**
|
||||
@brief Power data.
|
||||
*/
|
||||
struct power_t {
|
||||
uint32_t freqKHz; /**< Frequency in KHz. */
|
||||
int32_t power; /**< Power in dB x 100. */
|
||||
} power;
|
||||
|
||||
/**
|
||||
@brief Band information data.
|
||||
*/
|
||||
struct band_t {
|
||||
uint32_t minFreqKHz; /**< Min frequency in KHz. */
|
||||
uint32_t maxFreqKHz; /**< Max frequency in KHz. */
|
||||
} band;
|
||||
|
||||
/**
|
||||
@brief Candidate data.
|
||||
*/
|
||||
struct candidate_t {
|
||||
uint32_t centerFreqKHz; /**< Center frequency in KHz. */
|
||||
uint32_t symbolRateKSps; /**< Target symbol rate in KSps. */
|
||||
uint32_t minSymbolRateKSps; /**< Minimum symbol rate in range of candidate in KSps. */
|
||||
uint32_t maxSymbolRateKSps; /**< Maximum symbol rate in range of candidate in KSps. */
|
||||
} candidate;
|
||||
|
||||
/**
|
||||
@brief Channel data.
|
||||
*/
|
||||
struct channel_t {
|
||||
uint32_t centerFreqKHz; /**< Center frequency in KHz. */
|
||||
uint32_t symbolRateKSps; /**< Symbol rate in KSps. */
|
||||
sony_dtv_system_t system; /**< System. */
|
||||
} channelInfo;
|
||||
} data;
|
||||
} sony_demod_dvbs_s2_blindscan_data_t;
|
||||
|
||||
/**
|
||||
@brief Storage structure
|
||||
*/
|
||||
typedef struct {
|
||||
sony_demod_dvbs_s2_blindscan_power_t availablePowerList; /**< List of available power data. */
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pPowerArrayTop; /**< Top of power data array. */
|
||||
int32_t powerArrayLength; /**< Length of power data array. */
|
||||
|
||||
sony_demod_dvbs_s2_blindscan_data_t availableDataList; /**< List of available data. */
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pDataArrayTop; /**< Top of data array. */
|
||||
int32_t dataArrayLength; /**< Length of data array. */
|
||||
|
||||
int32_t currentUsedCount; /**< Current used data count. */
|
||||
int32_t maxUsedCount; /**< Max used data count. */
|
||||
int32_t currentUsedPowerCount; /**< Current used power data count. */
|
||||
int32_t maxUsedPowerCount; /**< Max used power data count. */
|
||||
} sony_demod_dvbs_s2_blindscan_data_storage_t;
|
||||
|
||||
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_DATA_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,179 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/09/28
|
||||
Modification ID : 1ea04def104d657deb64f0d0b0cae6ef992a9dd8
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbs_s2_blindscan_seq.h
|
||||
|
||||
This file provides definitions for BlindScan sequence function.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_SEQ_H
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_SEQ_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_utility.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_seq_common.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_bt.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_cs.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_fs.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_pm.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_ss.h"
|
||||
|
||||
/**
|
||||
@brief Definition of search range in MHz.
|
||||
|
||||
This value is affected to the array size in BlindScan sequence.
|
||||
Please set the value depend on users application.
|
||||
|
||||
Default value is 1220(MHz).
|
||||
It is 940MHz - 2160MHz. ( with some margin )
|
||||
*/
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_SEARCH_RANGE_MHZ 1220
|
||||
|
||||
/**
|
||||
@brief Definition of array size used in this driver.
|
||||
|
||||
The data size is depend on the input signal as follow.
|
||||
- Search range.
|
||||
- Power spectrum.
|
||||
- etc...
|
||||
|
||||
User can get the maximum used data size by sony_demod_dvbs_s2_blindscan_data_storage_t::maxUsedCount.
|
||||
If the driver returns SONY_RESULT_ERROR_OVERFLOW, please increase this value.
|
||||
*/
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_DATA_MAX 10000
|
||||
|
||||
/**
|
||||
@brief Definition of array size used in this driver.
|
||||
|
||||
This value is calculated by SONY_DEMOD_DVBS_S2_BLINDSCAN_SEARCH_RANGE_MHZ.
|
||||
So user doesn't need to change this value directly.
|
||||
*/
|
||||
#ifdef SONY_DEMOD_SUPPORT_DVBS_S2_BLINDSCAN_VER2
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_POWER_MAX ((SONY_DEMOD_DVBS_S2_BLINDSCAN_SEARCH_RANGE_MHZ + 45) * 3)
|
||||
#else
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_POWER_MAX ((SONY_DEMOD_DVBS_S2_BLINDSCAN_SEARCH_RANGE_MHZ + 45) * 2)
|
||||
#endif
|
||||
/**
|
||||
@brief state of BlindScan sequence
|
||||
*/
|
||||
typedef enum {
|
||||
BLINDSCAN_SEQ_STATE_START, /**< Start */
|
||||
BLINDSCAN_SEQ_STATE_SS1_FIN, /**< SS1 fin */
|
||||
BLINDSCAN_SEQ_STATE_STAGE1_FIN, /**< Stage1 fin */
|
||||
BLINDSCAN_SEQ_STATE_SS2_START, /**< SS2 start */
|
||||
BLINDSCAN_SEQ_STATE_SS2_FIN, /**< SS2 fin */
|
||||
BLINDSCAN_SEQ_STATE_FS2_START, /**< FS2 start */
|
||||
BLINDSCAN_SEQ_STATE_FS2_FIN, /**< FS2 fin */
|
||||
BLINDSCAN_SEQ_STATE_CS_PREPARING, /**< CS preparing */
|
||||
BLINDSCAN_SEQ_STATE_CS_TUNED, /**< CS tuned */
|
||||
BLINDSCAN_SEQ_STATE_CS_FIN, /**< CS fin */
|
||||
BLINDSCAN_SEQ_STATE_FS3_START, /**< FS3 start */
|
||||
BLINDSCAN_SEQ_STATE_FINISH, /**< Finish */
|
||||
BLINDSCAN_SEQ_STATE_UNKNOWN /**< Unknown */
|
||||
} sony_demod_dvbs_s2_blindscan_seq_state_t;
|
||||
|
||||
/**
|
||||
@brief Structure for scan sequence.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
@brief Common parameters used by each sub sequence
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t commonParams;
|
||||
|
||||
/**
|
||||
@brief Finish/Continue flag.
|
||||
|
||||
- 0: Finish the sequence.
|
||||
- 1: Continue the sequence.
|
||||
*/
|
||||
uint8_t isContinue;
|
||||
|
||||
sony_demod_dvbs_s2_blindscan_seq_state_t seqState; /**< State of BlindScan sequence. */
|
||||
sony_demod_dvbs_s2_blindscan_subseq_bt_t subseqBT; /**< Data for sub sequence BT. */
|
||||
sony_demod_dvbs_s2_blindscan_subseq_pm_t subseqPM; /**< Data for sub sequence PM. */
|
||||
sony_demod_dvbs_s2_blindscan_subseq_ss_t subseqSS; /**< Data for sub sequence SS. */
|
||||
sony_demod_dvbs_s2_blindscan_subseq_fs_t subseqFS; /**< Data for sub sequence FS. */
|
||||
sony_demod_dvbs_s2_blindscan_subseq_cs_t subseqCS; /**< Data for sub sequence CS. */
|
||||
|
||||
uint32_t minFreqKHz; /**< Min frequency in KHz which set by BlindScan API */
|
||||
uint32_t maxFreqKHz; /**< Max frequency in KHz which set by BlindScan API */
|
||||
uint32_t minSymbolRateKSps; /**< Min symbol rate in KSps which set by BlindScan API */
|
||||
uint32_t maxSymbolRateKSps; /**< Max symbol rate in KSps which set by BlindScan API */
|
||||
|
||||
uint32_t minPowerFreqKHz; /**< Min frequency in KHz which need for power spectrum */
|
||||
uint32_t maxPowerFreqKHz; /**< Max frequency in KHz which need for power spectrum */
|
||||
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pDetectedList; /**< Detected channel list */
|
||||
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pBandList; /**< Band list */
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pBandCurrent; /**< Current processing band data */
|
||||
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandList1; /**< Candidate list 1 */
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandList2; /**< Candidate list 2 */
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandCurrent; /**< The pointer of candidate */
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandLast; /**< The last pointer of candidate list */
|
||||
|
||||
uint32_t candCount; /**< Candidate total count for calculate progress */
|
||||
uint32_t candIndex; /**< Candidate current number for calculate progress */
|
||||
|
||||
/**
|
||||
@brief Power data for storage.
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_power_t powerArray[SONY_DEMOD_DVBS_S2_BLINDSCAN_POWER_MAX];
|
||||
/**
|
||||
@brief Data for storage.
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_data_t dataArray[SONY_DEMOD_DVBS_S2_BLINDSCAN_DATA_MAX];
|
||||
|
||||
} sony_demod_dvbs_s2_blindscan_seq_t;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Prepare to start BlindScan sequence.
|
||||
|
||||
@param pSeq The sequence instance.
|
||||
@param pDemod Demodulator instance.
|
||||
@param minFreqKHz Minimum frequency of the scan range in KHz.
|
||||
@param maxFreqKHz Maximum frequency of the scan range in KHz.
|
||||
@param minSymbolRateKSps Minimum symbol rate of the scan range in KSps.
|
||||
@param maxSymbolRateKSps Maximum symbol rate of the scan range in KSps.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_seq_Initialize (sony_demod_dvbs_s2_blindscan_seq_t * pSeq,
|
||||
sony_demod_t * pDemod,
|
||||
uint32_t minFreqKHz,
|
||||
uint32_t maxFreqKHz,
|
||||
uint32_t minSymbolRateKSps,
|
||||
uint32_t maxSymbolRateKSps);
|
||||
|
||||
/**
|
||||
@brief Execute one sequence for BlindScan.
|
||||
|
||||
@param pSeq The sequence instance.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_seq_Sequence (sony_demod_dvbs_s2_blindscan_seq_t * pSeq);
|
||||
|
||||
#ifdef SONY_DEMOD_SUPPORT_DVBS_S2_BLINDSCAN_VER2
|
||||
/**
|
||||
@brief Execute one sequence for BlindScan version2.
|
||||
|
||||
@param pSeq The sequence instance.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_version2_seq_Sequence (sony_demod_dvbs_s2_blindscan_seq_t * pSeq);
|
||||
#endif
|
||||
|
||||
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_SEQ_H */
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/07/27
|
||||
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbs_s2_blindscan_seq_common.h
|
||||
|
||||
This file provides commonly used definitions for BlindScan function.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_SEQ_COMMON_H
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_SEQ_COMMON_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
|
||||
/**
|
||||
@brief Detected channel information.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
@brief Detect channel flag.
|
||||
|
||||
If this is "1(Detect)", please check the other parameters in this struct.
|
||||
- 0: Not detect.
|
||||
- 1: Detect.
|
||||
*/
|
||||
uint8_t isDetect;
|
||||
/**
|
||||
@brief The system of the detected channel.
|
||||
|
||||
This is valid if isDetect == 1.
|
||||
*/
|
||||
sony_dtv_system_t system;
|
||||
|
||||
/**
|
||||
@brief The center frequency of the detected channel in KHz.
|
||||
|
||||
This is valid if isDetect == 1.
|
||||
*/
|
||||
uint32_t centerFreqKHz;
|
||||
|
||||
/**
|
||||
@brief The symbol rate of the detected channel in KSps.
|
||||
|
||||
This is valid if isDetect == 1.
|
||||
*/
|
||||
uint32_t symbolRateKSps;
|
||||
} sony_demod_dvbs_s2_blindscan_det_info_t;
|
||||
|
||||
/**
|
||||
@brief Tune request information.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
@brief Tune request flag.
|
||||
|
||||
If this is "1(Request)", driver request to tuning.
|
||||
- 0: Not detect.
|
||||
- 1: Detect.
|
||||
*/
|
||||
uint8_t isRequest;
|
||||
|
||||
/**
|
||||
@brief The frequency to tune in KHz.
|
||||
|
||||
This is valid if isRequest == 1.
|
||||
*/
|
||||
uint32_t frequencyKHz;
|
||||
|
||||
/**
|
||||
@brief The system to tune.
|
||||
|
||||
This is valid if isRequest == 1.
|
||||
*/
|
||||
sony_dtv_system_t system;
|
||||
|
||||
/**
|
||||
@brief The symbol rate to tune in KSps.
|
||||
|
||||
This is valid if isRequest == 1.
|
||||
*/
|
||||
uint32_t symbolRateKSps;
|
||||
|
||||
} sony_demod_dvbs_s2_blindscan_tune_req_t;
|
||||
|
||||
/**
|
||||
@brief The information for calculate AGC level.
|
||||
|
||||
This parameter used in driver internal.
|
||||
User doesn't need to access this structure.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t isRequest; /**< Calculate request flag. */
|
||||
uint32_t agcLevel; /**< AGC level get from demodulator. */
|
||||
int32_t agc_x100dB; /**< The result of calculation. */
|
||||
} sony_demod_dvbs_s2_blindscan_agc_info_t;
|
||||
|
||||
/**
|
||||
@brief Progress information for blind scan
|
||||
|
||||
This information is used only for BlindScan.
|
||||
(TuneSRS doesn't use this parameter)
|
||||
|
||||
User doesn't need to access this structure.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t progress; /**< Total progress in "%". */
|
||||
uint8_t majorMinProgress; /**< Current min range in "%". */
|
||||
uint8_t majorMaxProgress; /**< Current max range in "%". */
|
||||
uint8_t minorProgress; /**< Current sub progress in "%". */
|
||||
} sony_demod_dvbs_s2_blindscan_progress_t;
|
||||
|
||||
/**
|
||||
@brief The BlindScan sequence data
|
||||
*/
|
||||
typedef struct {
|
||||
sony_demod_t * pDemod; /**< Demod driver instance */
|
||||
uint32_t waitTime; /**< Wait time in ms */
|
||||
sony_demod_dvbs_s2_blindscan_det_info_t detInfo; /**< Detected channel information */
|
||||
sony_demod_dvbs_s2_blindscan_tune_req_t tuneReq; /**< Request to tune information */
|
||||
sony_demod_dvbs_s2_blindscan_agc_info_t agcInfo; /**< Request to calculate information */
|
||||
sony_demod_dvbs_s2_blindscan_data_storage_t storage; /**< Data storage */
|
||||
sony_demod_dvbs_s2_blindscan_progress_t progressInfo; /**< Progress information */
|
||||
uint32_t ckalFreqKHz; /**< CKAL in KHz */
|
||||
uint32_t ckahFreqKHz; /**< CKAH in KHz */
|
||||
} sony_demod_dvbs_s2_blindscan_seq_common_t;
|
||||
|
||||
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_SEQ_COMMON_H */
|
||||
+365
@@ -0,0 +1,365 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/09/28
|
||||
Modification ID : 1ea04def104d657deb64f0d0b0cae6ef992a9dd8
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod.h"
|
||||
#include "sony_demod_dvbs_s2.h"
|
||||
#include "sony_demod_dvbs_s2_monitor.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_bt.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_trace.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Static Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
static sony_result_t finish_ok (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq);
|
||||
static sony_result_t finish_ng (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_bt_Initialize (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq,
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_bt_Initialize");
|
||||
|
||||
if ((!pSeq) || (!pCommonParams)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
pSeq->isEnable = 0;
|
||||
pSeq->state = BT_STATE_INIT;
|
||||
pSeq->pCommonParams = pCommonParams;
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_bt_Start (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq,
|
||||
uint32_t centerFreqKHz,
|
||||
uint32_t candSymbolRateKSps,
|
||||
uint32_t minCandSymbolRateKSps,
|
||||
uint32_t maxCandSymbolRateKSps,
|
||||
uint32_t minSymbolRateKSps,
|
||||
uint32_t maxSymbolRateKSps)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_bt_Start");
|
||||
|
||||
if (!pSeq){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
pSeq->isEnable = 1;
|
||||
pSeq->state = BT_STATE_START;
|
||||
pSeq->centerFreqKHz = centerFreqKHz;
|
||||
pSeq->candSymbolRateKSps = candSymbolRateKSps;
|
||||
pSeq->minCandSymbolRateKSps = minCandSymbolRateKSps;
|
||||
pSeq->maxCandSymbolRateKSps = maxCandSymbolRateKSps;
|
||||
pSeq->minSymbolRateKSps = minSymbolRateKSps;
|
||||
pSeq->maxSymbolRateKSps = maxSymbolRateKSps;
|
||||
pSeq->isLocked = 0;
|
||||
|
||||
pSeq->pCommonParams->waitTime = 0;
|
||||
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_START (centerFreqKHz, candSymbolRateKSps, minCandSymbolRateKSps, maxCandSymbolRateKSps, minSymbolRateKSps, maxSymbolRateKSps);
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_bt_Sequence (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
uint8_t srsfin = 0;
|
||||
uint8_t trllock = 0;
|
||||
uint8_t tslock = 0;
|
||||
uint32_t elapsedTime = 0;
|
||||
uint32_t detSymbolRateSps = 0;
|
||||
uint32_t detSymbolRateKSps = 0;
|
||||
uint32_t ratioMax = 0;
|
||||
uint32_t ratioMin = 0;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_bt_Sequence");
|
||||
|
||||
if(!pSeq) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
switch(pSeq->state)
|
||||
{
|
||||
case BT_STATE_START:
|
||||
|
||||
if (pSeq->maxCandSymbolRateKSps < pSeq->minSymbolRateKSps){
|
||||
result = finish_ng (pSeq);
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT("NG(range)");
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (pSeq->maxCandSymbolRateKSps >= 20000){
|
||||
/* HS mode */
|
||||
result = sony_demod_dvbs_s2_blindscan_SetSampleMode (pSeq->pCommonParams->pDemod, 1);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
} else {
|
||||
/* LS mode */
|
||||
result = sony_demod_dvbs_s2_blindscan_SetSampleMode (pSeq->pCommonParams->pDemod, 0);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
|
||||
/* Clip 1 */
|
||||
if (pSeq->candSymbolRateKSps < pSeq->minSymbolRateKSps) {
|
||||
pSeq->candSymbolRateKSps = pSeq->minSymbolRateKSps;
|
||||
}
|
||||
if (pSeq->candSymbolRateKSps > pSeq->maxSymbolRateKSps){
|
||||
pSeq->candSymbolRateKSps = pSeq->maxSymbolRateKSps;
|
||||
}
|
||||
if (pSeq->minCandSymbolRateKSps < pSeq->minSymbolRateKSps) {
|
||||
pSeq->minCandSymbolRateKSps = pSeq->minSymbolRateKSps;
|
||||
}
|
||||
if (pSeq->minCandSymbolRateKSps > pSeq->maxSymbolRateKSps){
|
||||
pSeq->minCandSymbolRateKSps = pSeq->maxSymbolRateKSps;
|
||||
}
|
||||
if (pSeq->maxCandSymbolRateKSps < pSeq->minSymbolRateKSps) {
|
||||
pSeq->maxCandSymbolRateKSps = pSeq->minSymbolRateKSps;
|
||||
}
|
||||
if (pSeq->maxCandSymbolRateKSps > pSeq->maxSymbolRateKSps){
|
||||
pSeq->maxCandSymbolRateKSps = pSeq->maxSymbolRateKSps;
|
||||
}
|
||||
|
||||
/* Clip 2 */
|
||||
if (pSeq->maxCandSymbolRateKSps < pSeq->candSymbolRateKSps){
|
||||
pSeq->maxCandSymbolRateKSps = pSeq->candSymbolRateKSps;
|
||||
}
|
||||
if (pSeq->maxCandSymbolRateKSps > (pSeq->candSymbolRateKSps * 2)){
|
||||
pSeq->maxCandSymbolRateKSps = (pSeq->candSymbolRateKSps * 2);
|
||||
}
|
||||
if (pSeq->minCandSymbolRateKSps > pSeq->candSymbolRateKSps){
|
||||
pSeq->minCandSymbolRateKSps = pSeq->candSymbolRateKSps;
|
||||
}
|
||||
|
||||
/* Set target symbol rate */
|
||||
result = sony_demod_dvbs_s2_SetSymbolRate (pSeq->pCommonParams->pDemod, pSeq->candSymbolRateKSps);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if(pSeq->candSymbolRateKSps == 0){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
ratioMax = ((pSeq->maxCandSymbolRateKSps * 1024) / (pSeq->candSymbolRateKSps)) - 1024;
|
||||
ratioMin = ((pSeq->minCandSymbolRateKSps * 1024) / (pSeq->candSymbolRateKSps));
|
||||
|
||||
if (ratioMin >= 1024){
|
||||
ratioMin = 1023;
|
||||
}
|
||||
if (ratioMax >= 1024){
|
||||
ratioMax = 1023;
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_SetSymbolRateRatio (pSeq->pCommonParams->pDemod, ratioMin, ratioMax);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Tune */
|
||||
pSeq->pCommonParams->tuneReq.isRequest = 1;
|
||||
pSeq->pCommonParams->tuneReq.frequencyKHz = pSeq->centerFreqKHz;
|
||||
pSeq->pCommonParams->tuneReq.system = SONY_DTV_SYSTEM_DVBS;
|
||||
pSeq->pCommonParams->tuneReq.symbolRateKSps = pSeq->maxCandSymbolRateKSps;
|
||||
pSeq->pCommonParams->waitTime = 0;
|
||||
pSeq->state = BT_STATE_RF_TUNED;
|
||||
break;
|
||||
|
||||
case BT_STATE_RF_TUNED:
|
||||
result = sony_demod_SoftReset (pSeq->pCommonParams->pDemod);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
result = sony_stopwatch_start (&(pSeq->stopwatch));
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->pCommonParams->waitTime = 10;
|
||||
pSeq->state = BT_STATE_WAIT_SRSFIN;
|
||||
break;
|
||||
|
||||
case BT_STATE_WAIT_SRSFIN:
|
||||
result = sony_stopwatch_elapsed (&(pSeq->stopwatch), &elapsedTime);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
result = sony_demod_dvbs_s2_blindscan_GetSRSFIN (pSeq->pCommonParams->pDemod, &srsfin);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
if (srsfin){
|
||||
/* Check TRL lock */
|
||||
result = sony_demod_dvbs_s2_blindscan_CheckTRLLock (pSeq->pCommonParams->pDemod, &trllock);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
if (trllock){
|
||||
/* Symbol rate information */
|
||||
result = sony_demod_dvbs_s2_monitor_SymbolRate (pSeq->pCommonParams->pDemod, &detSymbolRateSps);
|
||||
switch(result)
|
||||
{
|
||||
case SONY_RESULT_OK:
|
||||
/* Set symbol rate */
|
||||
pSeq->detSymbolRateSps = detSymbolRateSps;
|
||||
break;
|
||||
|
||||
case SONY_RESULT_ERROR_HW_STATE:
|
||||
/* Not detect */
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT("NG(SR)");
|
||||
result = finish_ng (pSeq);
|
||||
SONY_TRACE_RETURN (result);
|
||||
|
||||
default:
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
detSymbolRateKSps = (detSymbolRateSps + 500) / 1000;
|
||||
pSeq->timeout = ((3600000 + (detSymbolRateKSps - 1)) / detSymbolRateKSps) + 150;
|
||||
result = sony_stopwatch_start (&(pSeq->stopwatch));
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->state = BT_STATE_WAIT_TSLOCK;
|
||||
pSeq->pCommonParams->waitTime = 10;
|
||||
} else {
|
||||
/* TRL unlock */
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT("NG(TRL unlock)");
|
||||
result = finish_ng (pSeq);
|
||||
}
|
||||
} else {
|
||||
if (elapsedTime > 10000){
|
||||
/* Timeout */
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT("NG(SRS timeout)");
|
||||
result = finish_ng (pSeq);
|
||||
} else {
|
||||
/* Continue */
|
||||
pSeq->pCommonParams->waitTime = 10;
|
||||
pSeq->state = BT_STATE_WAIT_SRSFIN;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case BT_STATE_WAIT_TSLOCK:
|
||||
result = sony_stopwatch_elapsed (&(pSeq->stopwatch), &elapsedTime);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
/* Monitor TSLock, CarrierOffset, System */
|
||||
result = sony_demod_dvbs_s2_monitor_ScanInfo (pSeq->pCommonParams->pDemod,
|
||||
&tslock,
|
||||
&(pSeq->detCarrierOffsetKHz),
|
||||
&(pSeq->detSystem));
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (tslock){
|
||||
/* Store system information */
|
||||
pSeq->pCommonParams->pDemod->system = pSeq->detSystem;
|
||||
|
||||
/* Success */
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT("OK");
|
||||
result = finish_ok (pSeq);
|
||||
SONY_TRACE_RETURN (result);
|
||||
} else {
|
||||
if (elapsedTime > pSeq->timeout){
|
||||
uint8_t plscLock = 0;
|
||||
uint8_t pilotOn = 0;
|
||||
/* Not detected channel */
|
||||
result = sony_demod_dvbs_s2_monitor_Pilot (pSeq->pCommonParams->pDemod, &plscLock, &pilotOn);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
if ((plscLock != 0) && (pilotOn == 0)) {
|
||||
/* Calculate timeout time for Pilot off signal */
|
||||
detSymbolRateKSps = (pSeq->detSymbolRateSps + 500) / 1000;
|
||||
pSeq->timeout = ((3600000 + (detSymbolRateKSps - 1)) / detSymbolRateKSps) + 150;
|
||||
/* Restart timer */
|
||||
result = sony_stopwatch_start (&(pSeq->stopwatch));
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->state = BT_STATE_WAIT_TSLOCK2;
|
||||
pSeq->pCommonParams->waitTime = 10;
|
||||
} else {
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT("NG( TS lock timeout)");
|
||||
result = finish_ng (pSeq);
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
} else {
|
||||
/* Continue to wait */
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case BT_STATE_WAIT_TSLOCK2:
|
||||
result = sony_stopwatch_elapsed (&(pSeq->stopwatch), &elapsedTime);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
/* Monitor TSLock, CarrierOffset, System */
|
||||
result = sony_demod_dvbs_s2_monitor_ScanInfo (pSeq->pCommonParams->pDemod,
|
||||
&tslock,
|
||||
&(pSeq->detCarrierOffsetKHz),
|
||||
&(pSeq->detSystem));
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
if (tslock){
|
||||
/* Store system information */
|
||||
pSeq->pCommonParams->pDemod->system = pSeq->detSystem;
|
||||
|
||||
/* Success */
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT("OK2");
|
||||
result = finish_ok (pSeq);
|
||||
SONY_TRACE_RETURN (result);
|
||||
} else {
|
||||
if (elapsedTime > pSeq->timeout){
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT("NG2( TS lock timeout)");
|
||||
result = finish_ng (pSeq);
|
||||
SONY_TRACE_RETURN (result);
|
||||
} else {
|
||||
/* Continue to wait */
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT("NG(SW state)");
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
static sony_result_t finish_ok (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq)
|
||||
{
|
||||
if(!pSeq) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
pSeq->isLocked = 1;
|
||||
pSeq->isEnable = 0;
|
||||
return SONY_RESULT_OK;
|
||||
}
|
||||
|
||||
static sony_result_t finish_ng (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq)
|
||||
{
|
||||
if(!pSeq) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
pSeq->isLocked = 0;
|
||||
pSeq->isEnable = 0;
|
||||
return SONY_RESULT_OK;
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbs_s2_blindscan_subseq_bt.h
|
||||
|
||||
This file provides BT sub sequence for TuneSRS/BlindScan APIs.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_BT_H
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_BT_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_dtv.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_seq_common.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
|
||||
/**
|
||||
@brief State of BT sub sequence
|
||||
*/
|
||||
typedef enum {
|
||||
BT_STATE_INIT, /**< Initialized */
|
||||
BT_STATE_START, /**< Started */
|
||||
BT_STATE_RF_TUNED, /**< RF tuned */
|
||||
BT_STATE_WAIT_SRSFIN, /**< Wait for SRS fin */
|
||||
BT_STATE_WAIT_TSLOCK, /**< Wait for TS lock */
|
||||
BT_STATE_WAIT_TSLOCK2, /**< Wait for TS lock (2nd) */
|
||||
BT_STATE_UNKNOWN /**< Unknown state */
|
||||
} sony_demod_dvbs_s2_blindscan_bt_state_t;
|
||||
|
||||
/**
|
||||
@brief Structure for BT sub sequence
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
@brief Pointer of common parameters used by each sub sequence
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams;
|
||||
|
||||
uint8_t isEnable; /**< Enable flag (0: disable, 1: enable) */
|
||||
sony_demod_dvbs_s2_blindscan_bt_state_t state; /**< State */
|
||||
sony_stopwatch_t stopwatch; /**< Stopwatch used in this sequence */
|
||||
uint32_t timeout; /**< Timeout time in ms. */
|
||||
|
||||
uint32_t centerFreqKHz; /**< Center frequency in KHz set by main sequence. */
|
||||
uint32_t candSymbolRateKSps; /**< Candidate symbol rate in KSps set by main sequence. */
|
||||
uint32_t minCandSymbolRateKSps; /**< Min symbol rate of candidate in KSps set by main sequence. */
|
||||
uint32_t maxCandSymbolRateKSps; /**< Max symbol rate of candidate in KSps set by main sequence. */
|
||||
uint32_t minSymbolRateKSps; /**< Min symbol rate of search range set by main sequence. */
|
||||
uint32_t maxSymbolRateKSps; /**< Max symbol rate of search range set by main sequence. */
|
||||
|
||||
/* Result of BT sequence. */
|
||||
uint8_t isLocked; /**< Lock flag (0 : Not TS locked, 1: TS locked) */
|
||||
uint32_t detSymbolRateSps; /**< Detected symbol rate in Sps. */
|
||||
int32_t detCarrierOffsetKHz; /**< Detected carrier offset frequency in KHz. */
|
||||
sony_dtv_system_t detSystem; /**< Detected system (DVB-S/S2) */
|
||||
|
||||
} sony_demod_dvbs_s2_blindscan_subseq_bt_t;
|
||||
|
||||
/**
|
||||
@brief Initialize BT sub sequence
|
||||
|
||||
@param pSeq Instance for BT sub sequence.
|
||||
@param pCommonParams Pointer of common parameters.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_bt_Initialize (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq,
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams);
|
||||
|
||||
/**
|
||||
@brief Start BT sub sequence
|
||||
|
||||
@param pSeq Instance for BT sub sequence.
|
||||
@param centerFreqKHz Center frequency in KHz.
|
||||
@param candSymbolRateKSps Candidate symbol rate in KSps.
|
||||
@param minCandSymbolRateKSps Min symbol rate of candidate in KSps.
|
||||
@param maxCandSymbolRateKSps Max symbol rate of candidate in KSps.
|
||||
@param minSymbolRateKSps Min symbol rate of search range.
|
||||
@param maxSymbolRateKSps Max symbol rate of search range.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_bt_Start (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq,
|
||||
uint32_t centerFreqKHz,
|
||||
uint32_t candSymbolRateKSps,
|
||||
uint32_t minCandSymbolRateKSps,
|
||||
uint32_t maxCandSymbolRateKSps,
|
||||
uint32_t minSymbolRateKSps,
|
||||
uint32_t maxSymbolRateKSps);
|
||||
|
||||
/**
|
||||
@brief Execute one sequence for BT sub sequence
|
||||
|
||||
@param pSeq Instance for BT sub sequence.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_bt_Sequence (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq);
|
||||
|
||||
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_BT_H */
|
||||
+286
@@ -0,0 +1,286 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_seq.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_pm.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_cs.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_trace.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Static Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
static sony_result_t get_step_cs (int32_t stepCount, int32_t * pValue);
|
||||
static sony_result_t finish_ok (sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq);
|
||||
static sony_result_t finish_ng (sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_cs_Initialize (sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq,
|
||||
sony_demod_dvbs_s2_blindscan_subseq_pm_t * pSeqPM,
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_cs_Initialize");
|
||||
|
||||
if ((!pSeq) || (!pSeqPM) || (!pCommonParams)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
pSeq->isEnable = 0;
|
||||
pSeq->state = CS_STATE_START;
|
||||
pSeq->pSeqPM = pSeqPM;
|
||||
pSeq->pCommonParams = pCommonParams;
|
||||
pSeq->freqOffsetKHz = 0;
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_cs_Start (sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq,
|
||||
int32_t freqOffsetKHz)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_cs_Start");
|
||||
|
||||
if (!pSeq){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_START (freqOffsetKHz);
|
||||
|
||||
pSeq->isEnable = 1;
|
||||
pSeq->state = CS_STATE_START;
|
||||
pSeq->freqOffsetKHz = freqOffsetKHz;
|
||||
pSeq->isExist = 0;
|
||||
pSeq->coarseSymbolRateKSps = 0;
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_cs_Sequence(sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
int32_t power = 0;
|
||||
int32_t stepFreqKHz = 0;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_cs_Sequence");
|
||||
|
||||
if(!pSeq) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
switch(pSeq->state)
|
||||
{
|
||||
case CS_STATE_START:
|
||||
result = sony_demod_dvbs_s2_blindscan_CS_INIT (pSeq->pCommonParams->pDemod);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->pCommonParams->waitTime = 0;
|
||||
pSeq->state = CS_STATE_PEAK_SEARCH_START;
|
||||
/* Set init value for index */
|
||||
pSeq->index = -5;
|
||||
break;
|
||||
|
||||
case CS_STATE_PEAK_SEARCH_START:
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (pSeq->pSeqPM, pSeq->freqOffsetKHz + ((int32_t)(pSeq->index) * 100));
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->state = CS_STATE_PEAK_SEARCHING;
|
||||
break;
|
||||
|
||||
case CS_STATE_PEAK_SEARCHING:
|
||||
/* Get result */
|
||||
power = (int32_t)(pSeq->pSeqPM->power);
|
||||
if ((pSeq->index == -5) || (pSeq->peakPower < power)){
|
||||
pSeq->peakPower = power;
|
||||
pSeq->peakFreqOfsKHz = (pSeq->index) * 100;
|
||||
}
|
||||
pSeq->index++;
|
||||
if(pSeq->index <= 5){
|
||||
/* Continue peak search */
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (pSeq->pSeqPM, pSeq->freqOffsetKHz + (pSeq->index * 100));
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
} else {
|
||||
/* Next stage */
|
||||
pSeq->state = CS_STATE_LOWER_SEARCHING;
|
||||
pSeq->index = 1;
|
||||
pSeq->isFin = 0;
|
||||
result = get_step_cs (pSeq->index, &stepFreqKHz);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->lowerFreqKHz = pSeq->freqOffsetKHz + (pSeq->peakFreqOfsKHz - stepFreqKHz);
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (pSeq->pSeqPM, pSeq->lowerFreqKHz);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CS_STATE_LOWER_SEARCHING:
|
||||
power = (int32_t)(pSeq->pSeqPM->power);
|
||||
if ((pSeq->peakPower * 100) > (power * 137)){
|
||||
/* Next stage */
|
||||
pSeq->state = CS_STATE_UPPER_SEARCHING;
|
||||
pSeq->index = 1;
|
||||
result = get_step_cs (pSeq->index, &stepFreqKHz);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->upperFreqKHz = pSeq->freqOffsetKHz + (pSeq->peakFreqOfsKHz + stepFreqKHz);
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (pSeq->pSeqPM, pSeq->upperFreqKHz);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
} else if ((power * 100) > (pSeq->peakPower * 150)){
|
||||
/* NG */
|
||||
pSeq->lowerFreqKHz = -1000; /* Invalid */
|
||||
result = finish_ng (pSeq);
|
||||
} else {
|
||||
pSeq->index++;
|
||||
if (pSeq->index < 27){
|
||||
/* Continue */
|
||||
result = get_step_cs (pSeq->index, &stepFreqKHz);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->lowerFreqKHz = pSeq->freqOffsetKHz + (pSeq->peakFreqOfsKHz - stepFreqKHz);
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (pSeq->pSeqPM, pSeq->lowerFreqKHz);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
} else {
|
||||
/* NG */
|
||||
pSeq->lowerFreqKHz = -1000; /* Invalid */
|
||||
result = finish_ng (pSeq);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CS_STATE_UPPER_SEARCHING:
|
||||
power = (int32_t)(pSeq->pSeqPM->power);
|
||||
if ((pSeq->peakPower * 100) > (power * 137)){
|
||||
/* OK */
|
||||
result = finish_ok (pSeq);
|
||||
} else if ((power * 100) > (pSeq->peakPower * 150)){
|
||||
/* NG */
|
||||
pSeq->upperFreqKHz = -1000; /* Invalid */
|
||||
result = finish_ng (pSeq);
|
||||
} else {
|
||||
pSeq->index++;
|
||||
if (pSeq->index < 27){
|
||||
/* Continue */
|
||||
result = get_step_cs (pSeq->index, &stepFreqKHz);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->upperFreqKHz = pSeq->freqOffsetKHz + (pSeq->peakFreqOfsKHz + stepFreqKHz);
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (pSeq->pSeqPM, pSeq->upperFreqKHz);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
} else {
|
||||
/* NG */
|
||||
pSeq->upperFreqKHz = -1000; /* Invalid */
|
||||
result = finish_ng (pSeq);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Static Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
static sony_result_t get_step_cs (int32_t stepCount, int32_t * pValue)
|
||||
{
|
||||
static const int32_t step_table[] = {
|
||||
0, /* 100(KHz) * 0 */
|
||||
100, /* 100(KHz) * 1 */
|
||||
200, /* 100(KHz) * 2 */
|
||||
300, /* 100(KHz) * 3 */
|
||||
400, /* 400(KHz) * (1.1^0) */
|
||||
440, /* 400(KHz) * (1.1^1) */
|
||||
484, /* 400(KHz) * (1.1^2) */
|
||||
532, /* 400(KHz) * (1.1^3) */
|
||||
586, /* 400(KHz) * (1.1^4) */
|
||||
644, /* 400(KHz) * (1.1^5) */
|
||||
709, /* 400(KHz) * (1.1^6) */
|
||||
779, /* 400(KHz) * (1.1^7) */
|
||||
857, /* 400(KHz) * (1.1^8) */
|
||||
943, /* 400(KHz) * (1.1^9) */
|
||||
1037, /* 400(KHz) * (1.1^10) */
|
||||
1141, /* 400(KHz) * (1.1^11) */
|
||||
1255, /* 400(KHz) * (1.1^12) */
|
||||
1381, /* 400(KHz) * (1.1^13) */
|
||||
1519, /* 400(KHz) * (1.1^14) */
|
||||
1671, /* 400(KHz) * (1.1^15) */
|
||||
1838, /* 400(KHz) * (1.1^16) */
|
||||
2022, /* 400(KHz) * (1.1^17) */
|
||||
2224, /* 400(KHz) * (1.1^18) */
|
||||
2446, /* 400(KHz) * (1.1^19) */
|
||||
2691, /* 400(KHz) * (1.1^20) */
|
||||
2960, /* 400(KHz) * (1.1^21) */
|
||||
3256, /* 400(KHz) * (1.1^22) */
|
||||
3582 /* 400(KHz) * (1.1^23) */
|
||||
};
|
||||
|
||||
SONY_TRACE_ENTER ("get_step_cs");
|
||||
|
||||
if ((!pValue) || (stepCount < 0) || (stepCount > 27)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
*pValue = step_table[stepCount];
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
static sony_result_t finish_ok (sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("finish_ok");
|
||||
if(!pSeq) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
if (pSeq->upperFreqKHz > pSeq->lowerFreqKHz){
|
||||
pSeq->coarseSymbolRateKSps = (uint32_t)(pSeq->upperFreqKHz - pSeq->lowerFreqKHz);
|
||||
pSeq->isExist = 1;
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_RESULT(pSeq->coarseSymbolRateKSps);
|
||||
} else {
|
||||
pSeq->coarseSymbolRateKSps = 0;
|
||||
pSeq->isExist = 0;
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_RESULT(1);
|
||||
}
|
||||
pSeq->isEnable = 0;
|
||||
result = sony_demod_dvbs_s2_blindscan_CS_FIN (pSeq->pCommonParams->pDemod);
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
static sony_result_t finish_ng (sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("finish_ng");
|
||||
if(!pSeq) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
pSeq->coarseSymbolRateKSps = 0;
|
||||
pSeq->isExist = 0;
|
||||
pSeq->isEnable = 0;
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_RESULT(0);
|
||||
result = sony_demod_dvbs_s2_blindscan_CS_FIN (pSeq->pCommonParams->pDemod);
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbs_s2_blindscan_subseq_cs.h
|
||||
|
||||
This file provides CS sub sequence for TuneSRS/BlindScan.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_CS_H
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_CS_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_pm.h"
|
||||
|
||||
/**
|
||||
@brief State of CS sub sequence
|
||||
*/
|
||||
typedef enum {
|
||||
CS_STATE_START, /**< Start */
|
||||
CS_STATE_PEAK_SEARCH_START, /**< Peak search start */
|
||||
CS_STATE_PEAK_SEARCHING, /**< Peak searching */
|
||||
CS_STATE_LOWER_SEARCHING, /**< Lower edge searching */
|
||||
CS_STATE_UPPER_SEARCHING, /**< Upper edge searching */
|
||||
CS_STATE_UNKNOWN /**< Unknown */
|
||||
} sony_demod_dvbs_s2_blindscan_cs_state_t;
|
||||
|
||||
/**
|
||||
@brief Structure for CS sub sequence
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
/**
|
||||
@brief Pointer of common parameters used by each sub sequence
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams;
|
||||
/**
|
||||
@brief Pointer of PM sub sequence instance
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_subseq_pm_t * pSeqPM;
|
||||
|
||||
uint8_t isEnable; /**< Enable flag (0: disable, 1: enable). */
|
||||
sony_demod_dvbs_s2_blindscan_cs_state_t state; /**< State. */
|
||||
uint32_t agcLevel; /**< AGC level from register. */
|
||||
int32_t agc_x100dB; /**< Calculated AGC (x 100dB) by tuner driver. */
|
||||
int8_t index; /**< Index for internal use. */
|
||||
int32_t peakPower; /**< Peak power. */
|
||||
int32_t peakFreqOfsKHz; /**< Peak frequency offset in KHz. */
|
||||
int32_t lowerFreqKHz; /**< Lower frequency in KHz. */
|
||||
int32_t upperFreqKHz; /**< Upper frequency in KHz. */
|
||||
uint8_t isFin; /**< Flags whether this sequence finished or not. */
|
||||
|
||||
int32_t freqOffsetKHz; /**< Frequency offset in KHz. */
|
||||
|
||||
uint8_t isExist; /**< Result of this CS sub sequence (0 : Signal is not exist, 1 : Signal is exist) */
|
||||
uint32_t coarseSymbolRateKSps; /**< Result of this CS sub sequence (Symbol rate in KSps) */
|
||||
|
||||
} sony_demod_dvbs_s2_blindscan_subseq_cs_t;
|
||||
|
||||
/**
|
||||
@brief Initialize CS sub sequence
|
||||
|
||||
@param pSeq Instance for CS sub sequence.
|
||||
@param pSeqPM Pointer of PM sub sequence instance.
|
||||
@param pCommonParams Pointer of common parameters.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_cs_Initialize (sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq,
|
||||
sony_demod_dvbs_s2_blindscan_subseq_pm_t * pSeqPM,
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams);
|
||||
|
||||
/**
|
||||
@brief Start CS sub sequence
|
||||
|
||||
@param pSeq Instance for CS sub sequence.
|
||||
@param freqOffsetKHz Frequency offset in KHz.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_cs_Start (sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq,
|
||||
int32_t freqOffsetKHz);
|
||||
|
||||
/**
|
||||
@brief Execute one sequence for CS sub sequence
|
||||
|
||||
@param pSeq Instance for CS sub sequence.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_cs_Sequence (sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq);
|
||||
|
||||
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_CS_H */
|
||||
+239
@@ -0,0 +1,239 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod_dvbs_s2_monitor.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_seq.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_fs.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_bt.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Static Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
static sony_result_t finish_ok (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq);
|
||||
static sony_result_t updateProgress (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_fs_Initialize (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq,
|
||||
sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeqBT,
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams)
|
||||
{
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_fs_Initialize");
|
||||
|
||||
if ((!pSeq) || (!pSeqBT) || (!pCommonParams)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
pSeq->isEnable = 0;
|
||||
pSeq->state = FS_STATE_START;
|
||||
pSeq->pSeqBT = pSeqBT;
|
||||
pSeq->pCommonParams = pCommonParams;
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_fs_Start (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandList,
|
||||
uint32_t minSymbolRateKSps,
|
||||
uint32_t maxSymbolRateKSps,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pChannelList)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCurrent = NULL;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_fs_Start");
|
||||
|
||||
if ((!pSeq) || (!pCandList) || (!pChannelList)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
pSeq->isEnable = 1;
|
||||
pSeq->state = FS_STATE_START;
|
||||
pSeq->pCandList = pCandList;
|
||||
pSeq->pCandCurrent = pSeq->pCandList->pNext;
|
||||
pSeq->pChannelList = pChannelList;
|
||||
pSeq->minSymbolRateKSps = minSymbolRateKSps;
|
||||
pSeq->maxSymbolRateKSps = maxSymbolRateKSps;
|
||||
|
||||
pSeq->candIndex = 1;
|
||||
pSeq->candCount = 1;
|
||||
pCurrent = pCandList->pNext;
|
||||
while(pCurrent){
|
||||
pSeq->candCount++;
|
||||
pCurrent = pCurrent->pNext;
|
||||
}
|
||||
result = updateProgress (pSeq);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
pSeq->pChannelLast = pChannelList;
|
||||
while(pSeq->pChannelLast->pNext){
|
||||
pSeq->pChannelLast = pSeq->pChannelLast->pNext;
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_fs_Sequence (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pTemp = NULL;
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pChannelCurrent = NULL;
|
||||
uint32_t candFreq = 0;
|
||||
uint32_t candSR = 0;
|
||||
uint32_t candMinSR = 0;
|
||||
uint32_t candMaxSR = 0;
|
||||
uint32_t channelFreq = 0;
|
||||
uint32_t channelSR = 0;
|
||||
uint8_t isTry = 0;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_fs_Sequence");
|
||||
|
||||
if(!pSeq) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
switch(pSeq->state)
|
||||
{
|
||||
case FS_STATE_START:
|
||||
result = updateProgress (pSeq);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
if (pSeq->pCandCurrent){
|
||||
/* Cand is exist */
|
||||
candFreq = pSeq->pCandCurrent->data.candidate.centerFreqKHz;
|
||||
candSR = pSeq->pCandCurrent->data.candidate.symbolRateKSps;
|
||||
candMinSR = pSeq->pCandCurrent->data.candidate.minSymbolRateKSps;
|
||||
candMaxSR = pSeq->pCandCurrent->data.candidate.maxSymbolRateKSps;
|
||||
|
||||
isTry = 1;
|
||||
if (candMaxSR > pSeq->minSymbolRateKSps){
|
||||
pChannelCurrent = pSeq->pChannelList->pNext;
|
||||
while(pChannelCurrent){
|
||||
channelFreq = pChannelCurrent->data.candidate.centerFreqKHz;
|
||||
channelSR = pChannelCurrent->data.candidate.symbolRateKSps;
|
||||
|
||||
if (((channelFreq - (channelSR/2)) <= candFreq) && (candFreq <= (channelFreq + (channelSR/2)))){
|
||||
/* duplicated */
|
||||
isTry = 0;
|
||||
break;
|
||||
}
|
||||
/* Next channel */
|
||||
pChannelCurrent = pChannelCurrent->pNext;
|
||||
}
|
||||
} else {
|
||||
isTry = 0;
|
||||
}
|
||||
|
||||
pSeq->candIndex++;
|
||||
pSeq->pCandCurrent = pSeq->pCandCurrent->pNext;
|
||||
|
||||
if ((isTry) && (candMaxSR > 1000)) {
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_bt_Start (pSeq->pSeqBT,
|
||||
candFreq,
|
||||
candSR,
|
||||
candMinSR,
|
||||
candMaxSR,
|
||||
pSeq->minSymbolRateKSps,
|
||||
pSeq->maxSymbolRateKSps);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->state = FS_STATE_WAIT_BTFIN;
|
||||
pSeq->pCommonParams->waitTime =0;
|
||||
}
|
||||
} else {
|
||||
/* Finish */
|
||||
result = finish_ok(pSeq);
|
||||
}
|
||||
break;
|
||||
|
||||
case FS_STATE_WAIT_BTFIN:
|
||||
/* Check result */
|
||||
if (pSeq->pSeqBT->isLocked){
|
||||
uint8_t isExist = 0;
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCurrent = pSeq->pChannelList->pNext;
|
||||
uint32_t detFrequencyKHz = (uint32_t)((int32_t)(pSeq->pCommonParams->tuneReq.frequencyKHz) + pSeq->pSeqBT->detCarrierOffsetKHz);
|
||||
uint32_t detSymbolRateKSps = (pSeq->pSeqBT->detSymbolRateSps + 500) / 1000;
|
||||
uint32_t chFrequencyKHz = 0;
|
||||
uint32_t chSymbolRateKSps = 0;
|
||||
|
||||
isExist = 0;
|
||||
while(pCurrent){
|
||||
|
||||
chFrequencyKHz = pCurrent->data.channelInfo.centerFreqKHz;
|
||||
chSymbolRateKSps = pCurrent->data.channelInfo.symbolRateKSps/2;
|
||||
|
||||
if ((detFrequencyKHz >= (chFrequencyKHz - chSymbolRateKSps)) &&
|
||||
(detFrequencyKHz <= (chFrequencyKHz + chSymbolRateKSps))){
|
||||
/* It is already detected channel */
|
||||
isExist = 1;
|
||||
break;
|
||||
}
|
||||
pCurrent = pCurrent->pNext;
|
||||
}
|
||||
|
||||
if (isExist == 0){
|
||||
|
||||
/* Detect signal */
|
||||
pSeq->pCommonParams->detInfo.isDetect = 1;
|
||||
pSeq->pCommonParams->detInfo.centerFreqKHz = detFrequencyKHz;
|
||||
pSeq->pCommonParams->detInfo.symbolRateKSps = detSymbolRateKSps;
|
||||
pSeq->pCommonParams->detInfo.system = pSeq->pSeqBT->detSystem;
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_AllocData (&(pSeq->pCommonParams->storage), &pTemp);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
pTemp->data.channelInfo.centerFreqKHz = pSeq->pCommonParams->detInfo.centerFreqKHz;
|
||||
pTemp->data.channelInfo.symbolRateKSps = pSeq->pCommonParams->detInfo.symbolRateKSps;
|
||||
pTemp->data.channelInfo.system = pSeq->pCommonParams->detInfo.system;
|
||||
|
||||
pSeq->pChannelLast->pNext = pTemp;
|
||||
pSeq->pChannelLast = pSeq->pChannelLast->pNext;
|
||||
}
|
||||
} else {
|
||||
/* Unlock */
|
||||
pSeq->pCommonParams->detInfo.isDetect = 0;
|
||||
}
|
||||
pSeq->state = FS_STATE_START;
|
||||
pSeq->pCommonParams->waitTime = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
static sony_result_t finish_ok (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq)
|
||||
{
|
||||
SONY_TRACE_ENTER ("finish_ok");
|
||||
if(!pSeq) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
pSeq->isEnable = 0;
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
static sony_result_t updateProgress (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq)
|
||||
{
|
||||
SONY_TRACE_ENTER ("updateProgress");
|
||||
if(!pSeq) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
if (pSeq->candIndex > pSeq->candCount){
|
||||
pSeq->candIndex = pSeq->candCount;
|
||||
}
|
||||
pSeq->pCommonParams->progressInfo.minorProgress = (uint8_t)((pSeq->candIndex * 100) / pSeq->candCount);
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/07/27
|
||||
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbs_s2_blindscan_subseq_fs.h
|
||||
|
||||
This file provides FS sub sequence for TuneSRS/BlindScan.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_FS_H
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_FS_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_bt.h"
|
||||
|
||||
/**
|
||||
@brief State of FS sub sequence
|
||||
*/
|
||||
typedef enum {
|
||||
FS_STATE_START, /**< Start */
|
||||
FS_STATE_WAIT_BTFIN, /**< Wait for BT fin */
|
||||
FS_STATE_FINISH, /**< Finish FS */
|
||||
FS_STATE_UNKNOWN /**< Unknown */
|
||||
} sony_demod_dvbs_s2_blindscan_fs_state_t;
|
||||
|
||||
/**
|
||||
@brief Structure for FS sub sequence
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
/**
|
||||
@brief Pointer of common parameters used by each sub sequence
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams;
|
||||
/**
|
||||
@brief Pointer of BT sub sequence instance
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeqBT;
|
||||
|
||||
uint8_t isEnable; /**< Enable flag (0: disable, 1: enable). */
|
||||
sony_demod_dvbs_s2_blindscan_fs_state_t state; /**< State. */
|
||||
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandList; /**< Candidate list */
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pChannelList; /**< Detected channel list */
|
||||
uint32_t minSymbolRateKSps; /**< Min symbol rate of search range in KSps */
|
||||
uint32_t maxSymbolRateKSps; /**< Max symbol rate of search range in KSps */
|
||||
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandCurrent; /**< Pointer of current candidate */
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pChannelLast; /**< The last pointer of detected channel list */
|
||||
uint32_t candFreq; /**< Frequency of candidate in KHz. */
|
||||
|
||||
uint32_t candCount; /**< Candidate number for calculate progress. */
|
||||
uint32_t candIndex; /**< Candidate index for calculate progress. */
|
||||
|
||||
} sony_demod_dvbs_s2_blindscan_subseq_fs_t;
|
||||
|
||||
/**
|
||||
@brief Initialize FS sub sequence
|
||||
|
||||
@param pSeq Instance for FS sub sequence.
|
||||
@param pSeqBT Pointer of BT sub sequence instance.
|
||||
@param pCommonParams Pointer of common parameters.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_fs_Initialize (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq,
|
||||
sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeqBT,
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams);
|
||||
|
||||
/**
|
||||
@brief Start CS sub sequence
|
||||
|
||||
@param pSeq Instance for FS sub sequence.
|
||||
@param pCandList Candidate list.
|
||||
@param minSymbolRateKSps Min symbol rate of search range in KSps.
|
||||
@param maxSymbolRateKSps Max symbol rate of search range in KSps.
|
||||
@param pChannelList Detected channel list.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_fs_Start (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandList,
|
||||
uint32_t minSymbolRateKSps,
|
||||
uint32_t maxSymbolRateKSps,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pChannelList);
|
||||
|
||||
/**
|
||||
@brief Execute one sequence for FS sub sequence
|
||||
|
||||
@param pSeq Instance for FS sub sequence.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_fs_Sequence (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq);
|
||||
|
||||
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_FS_H */
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_seq.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_trace.h"
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_pm_Initialize (sony_demod_dvbs_s2_blindscan_subseq_pm_t * pSeq,
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams)
|
||||
{
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_pm_Initialize");
|
||||
|
||||
if ((!pSeq) || (!pCommonParams)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
pSeq->isEnable = 0;
|
||||
pSeq->state = PM_STATE_START;
|
||||
pSeq->pCommonParams = pCommonParams;
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_pm_Start (sony_demod_dvbs_s2_blindscan_subseq_pm_t * pSeq,
|
||||
int32_t freqOffsetKHz)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_pm_Start");
|
||||
if(!pSeq) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
pSeq->isEnable = 1;
|
||||
pSeq->state = PM_STATE_START;
|
||||
pSeq->freqOffsetKHz = freqOffsetKHz;
|
||||
pSeq->power = 0;
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_pm_Sequence (sony_demod_dvbs_s2_blindscan_subseq_pm_t * pSeq)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
uint32_t elapsedTime = 0;
|
||||
uint8_t csfin = 0;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_pm_Sequence");
|
||||
|
||||
if(!pSeq) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
switch(pSeq->state)
|
||||
{
|
||||
case PM_STATE_START:
|
||||
result = sony_demod_dvbs_s2_blindscan_SetCFFine (pSeq->pCommonParams->pDemod, pSeq->freqOffsetKHz);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Scan start */
|
||||
result = sony_demod_dvbs_s2_blindscan_PS_START (pSeq->pCommonParams->pDemod);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
pSeq->state = PM_STATE_WAITING_CSFIN;
|
||||
pSeq->pCommonParams->waitTime = 0;
|
||||
result = sony_stopwatch_start (&pSeq->stopwatch);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
break;
|
||||
|
||||
case PM_STATE_WAITING_CSFIN:
|
||||
result = sony_stopwatch_elapsed (&pSeq->stopwatch, &elapsedTime);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_GetCSFIN (pSeq->pCommonParams->pDemod, &csfin);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (csfin){
|
||||
result = sony_demod_dvbs_s2_blindscan_GetPSPow (pSeq->pCommonParams->pDemod, &pSeq->power);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Scan ack */
|
||||
result = sony_demod_dvbs_s2_blindscan_PS_RACK (pSeq->pCommonParams->pDemod);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* End */
|
||||
pSeq->isEnable = 0;
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_PM_POWER (pSeq->freqOffsetKHz, pSeq->power);
|
||||
} else {
|
||||
if (elapsedTime >= 1000){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_TIMEOUT);
|
||||
} else {
|
||||
/* Continue to wait */
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbs_s2_blindscan_subseq_pm.h
|
||||
|
||||
This file provides PM sub sequence for TuneSRS/BlindScan.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_PM_H
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_PM_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
|
||||
/**
|
||||
@brief State of PM sub sequence
|
||||
*/
|
||||
typedef enum {
|
||||
PM_STATE_START, /**< Start */
|
||||
PM_STATE_WAITING_CSFIN, /**< Wait for CS fin */
|
||||
PM_STATE_UNKNOWN /**< Unknown */
|
||||
} sony_demod_dvbs_s2_blindscan_pm_state_t;
|
||||
|
||||
/**
|
||||
@brief Structure for PM sub sequence
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
/**
|
||||
@brief Pointer of common parameters used by each sub sequence
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams;
|
||||
|
||||
uint8_t isEnable; /**< Enable flag (0: disable, 1: enable). */
|
||||
sony_demod_dvbs_s2_blindscan_pm_state_t state; /**< State. */
|
||||
sony_stopwatch_t stopwatch; /**< Stopwatch for internal use. */
|
||||
|
||||
int32_t freqOffsetKHz; /**< Frequency offset in KHz. */
|
||||
uint16_t power; /**< Power value */
|
||||
|
||||
|
||||
} sony_demod_dvbs_s2_blindscan_subseq_pm_t;
|
||||
|
||||
/**
|
||||
@brief Initialize PM sub sequence
|
||||
|
||||
@param pSeq Instance for PM sub sequence.
|
||||
@param pCommonParams Pointer of common parameters.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_pm_Initialize (sony_demod_dvbs_s2_blindscan_subseq_pm_t * pSeq,
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams);
|
||||
|
||||
/**
|
||||
@brief Start PM sub sequence
|
||||
|
||||
@param pSeq Instance for PM sub sequence.
|
||||
@param freqOffsetKHz Frequency offset in KHz.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_pm_Start (sony_demod_dvbs_s2_blindscan_subseq_pm_t * pSeq,
|
||||
int32_t freqOffsetKHz);
|
||||
|
||||
/**
|
||||
@brief Execute one sequence for PM sub sequence
|
||||
|
||||
@param pSeq Instance for PM sub sequence.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_pm_Sequence (sony_demod_dvbs_s2_blindscan_subseq_pm_t * pSeq);
|
||||
|
||||
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_PM_H */
|
||||
+257
@@ -0,0 +1,257 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "sony_common.h"
|
||||
#include "sony_math.h"
|
||||
#include "sony_demod.h"
|
||||
#include "sony_demod_dvbs_s2.h"
|
||||
#include "sony_demod_dvbs_s2_monitor.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_utility.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_seq.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_ss_Initialize (sony_demod_dvbs_s2_blindscan_subseq_ss_t * pSeq,
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_ss_Initialize");
|
||||
|
||||
if ((!pSeq) || (!pCommonParams)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
pSeq->isEnable = 0;
|
||||
pSeq->state = SS_STATE_INIT;
|
||||
|
||||
pSeq->maxFreqKHz = 0;
|
||||
pSeq->minFreqKHz = 0;
|
||||
pSeq->stepFreqKHz = 0;
|
||||
pSeq->tunerStepFreqKHz = 0;
|
||||
|
||||
pSeq->pCommonParams = pCommonParams;
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_AllocPower (&(pSeq->pCommonParams->storage), &(pSeq->pPowerList));
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_ss_Start (sony_demod_dvbs_s2_blindscan_subseq_ss_t * pSeq,
|
||||
uint32_t minFreqKHz,
|
||||
uint32_t maxFreqKHz,
|
||||
uint32_t stepFreqKHz,
|
||||
uint32_t tunerStepFreqKHz,
|
||||
uint8_t powerSmooth)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_ss_Start");
|
||||
|
||||
if (!pSeq){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
pSeq->isEnable = 1;
|
||||
pSeq->state = SS_STATE_START;
|
||||
|
||||
pSeq->minFreqKHz = minFreqKHz;
|
||||
pSeq->maxFreqKHz = maxFreqKHz;
|
||||
pSeq->stepFreqKHz = stepFreqKHz;
|
||||
pSeq->tunerStepFreqKHz = tunerStepFreqKHz;
|
||||
|
||||
pSeq->pCommonParams->waitTime = 0;
|
||||
|
||||
pSeq->ocfr_csk = powerSmooth;
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_ClearPowerList (&(pSeq->pCommonParams->storage), pSeq->pPowerList);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->pPowerListLast = pSeq->pPowerList;
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_ss_Sequence(sony_demod_dvbs_s2_blindscan_subseq_ss_t * pSeq)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
uint8_t csfin = 0;
|
||||
uint8_t csrdend = 0;
|
||||
int32_t csfreq = 0;
|
||||
uint32_t cspow = 0;
|
||||
uint32_t elapsedTime = 0;
|
||||
int32_t offsetFreq = 0;
|
||||
uint32_t ckaFreqKHz = 0;
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pTempPower = NULL;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_ss_Sequence");
|
||||
|
||||
if(!pSeq) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
switch(pSeq->state)
|
||||
{
|
||||
case SS_STATE_START:
|
||||
result = sony_demod_dvbs_s2_blindscan_PS_INIT (pSeq->pCommonParams->pDemod, pSeq->ocfr_csk);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
offsetFreq = (int32_t)pSeq->tunerStepFreqKHz / 2;
|
||||
ckaFreqKHz = pSeq->pCommonParams->ckahFreqKHz;
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_PS_SET (pSeq->pCommonParams->pDemod,
|
||||
-offsetFreq,
|
||||
offsetFreq,
|
||||
pSeq->stepFreqKHz,
|
||||
ckaFreqKHz);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->currentFreqKHz = (uint32_t)((int32_t)pSeq->minFreqKHz + offsetFreq);
|
||||
pSeq->state = SS_STATE_RF_TUNING;
|
||||
pSeq->pCommonParams->waitTime = 0;
|
||||
break;
|
||||
|
||||
case SS_STATE_RF_TUNING:
|
||||
pSeq->pCommonParams->tuneReq.isRequest = 1;
|
||||
pSeq->pCommonParams->tuneReq.frequencyKHz = pSeq->currentFreqKHz;
|
||||
pSeq->pCommonParams->tuneReq.system = SONY_DTV_SYSTEM_DVBS;
|
||||
pSeq->pCommonParams->tuneReq.symbolRateKSps = 0;
|
||||
pSeq->pCommonParams->waitTime = 0;
|
||||
pSeq->state = SS_STATE_RF_TUNED;
|
||||
break;
|
||||
|
||||
case SS_STATE_RF_TUNED:
|
||||
result = sony_demod_dvbs_s2_monitor_IFAGCOut (pSeq->pCommonParams->pDemod, &(pSeq->agcLevel));
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->pCommonParams->agcInfo.isRequest = 1;
|
||||
pSeq->pCommonParams->agcInfo.agcLevel = pSeq->agcLevel;
|
||||
pSeq->pCommonParams->waitTime = 0;
|
||||
pSeq->state = SS_STATE_AGC_CALCULATED;
|
||||
break;
|
||||
|
||||
case SS_STATE_AGC_CALCULATED:
|
||||
pSeq->agc_x100dB = pSeq->pCommonParams->agcInfo.agc_x100dB;
|
||||
result = sony_demod_dvbs_s2_blindscan_PS_START (pSeq->pCommonParams->pDemod);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
result = sony_stopwatch_start (&pSeq->stopwatch);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->state = SS_STATE_WAIT_CSFIN;
|
||||
pSeq->pCommonParams->waitTime = 10;
|
||||
break;
|
||||
|
||||
|
||||
case SS_STATE_WAIT_CSFIN:
|
||||
result = sony_stopwatch_elapsed (&pSeq->stopwatch, &elapsedTime);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
result = sony_demod_dvbs_s2_blindscan_GetCSFIN (pSeq->pCommonParams->pDemod, &csfin);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
if (csfin){
|
||||
pSeq->state = SS_STATE_READ_CS;
|
||||
pSeq->pCommonParams->waitTime = 0;
|
||||
} else {
|
||||
if (elapsedTime > 10000){
|
||||
/* Timeout error */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_TIMEOUT);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SS_STATE_READ_CS:
|
||||
result = sony_demod_dvbs_s2_blindscan_GetCSRDEND(pSeq->pCommonParams->pDemod, &csrdend);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
if (csrdend){
|
||||
if ((pSeq->currentFreqKHz + (pSeq->tunerStepFreqKHz / 2)) < pSeq->maxFreqKHz){
|
||||
pSeq->currentFreqKHz += pSeq->tunerStepFreqKHz;
|
||||
pSeq->state = SS_STATE_RF_TUNING;
|
||||
pSeq->pCommonParams->waitTime = 0;
|
||||
/* Go to next loop */
|
||||
} else {
|
||||
pSeq->state = SS_STATE_END;
|
||||
pSeq->pCommonParams->waitTime = 0;
|
||||
}
|
||||
} else {
|
||||
ckaFreqKHz = pSeq->pCommonParams->ckahFreqKHz;
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_GetCSINFO (pSeq->pCommonParams->pDemod, &csfreq, &cspow);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Add to power list */
|
||||
result = sony_demod_dvbs_s2_blindscan_AllocPower (&(pSeq->pCommonParams->storage), &pTempPower);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Power data (frequency) */
|
||||
if (csfreq >= 0){
|
||||
pTempPower->freqKHz = (uint32_t)((int32_t)(pSeq->pCommonParams->tuneReq.frequencyKHz) + (((csfreq * (int32_t)ckaFreqKHz) + (int32_t)1024) / (int32_t)2048));
|
||||
} else {
|
||||
pTempPower->freqKHz = (uint32_t)((int32_t)(pSeq->pCommonParams->tuneReq.frequencyKHz) + (((csfreq * (int32_t)ckaFreqKHz) - (int32_t)1024) / (int32_t)2048));
|
||||
}
|
||||
|
||||
if (pTempPower->freqKHz > pSeq->maxFreqKHz){
|
||||
result = sony_demod_dvbs_s2_blindscan_FreePower (&(pSeq->pCommonParams->storage), pTempPower);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Power[dB] = 10 * log10 (CSPOW/2^14) - gain_db
|
||||
* Power[x100dB] = (1000 * log10 (CSPOW/2^14)) - gain_db_x100
|
||||
* = (1000 * (log10(CSPOW) - log10(2^14))) - gain_db_x100
|
||||
* = (10 * (log10(CSPOW) - 421)) - gain_db_x100
|
||||
*
|
||||
* log10() in this driver returns "result x 100".
|
||||
*/
|
||||
pTempPower->power = (int32_t)((sony_math_log10 (cspow) - 421) * 10) - pSeq->pCommonParams->agcInfo.agc_x100dB;
|
||||
|
||||
/* Add data to list */
|
||||
pSeq->pPowerListLast->pNext = pTempPower;
|
||||
pSeq->pPowerListLast = pSeq->pPowerListLast->pNext;
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_PS_RACK (pSeq->pCommonParams->pDemod);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SS_STATE_END:
|
||||
pSeq->isEnable = 0;
|
||||
result = sony_demod_dvbs_s2_blindscan_PS_FIN (pSeq->pCommonParams->pDemod);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->pCommonParams->waitTime = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbs_s2_blindscan_subseq_ss.h
|
||||
|
||||
This file provides SS sub sequence for TuneSRS/BlindScan.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_SS_H
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_SS_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_seq_common.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
|
||||
/**
|
||||
@brief State of SS sub sequence
|
||||
*/
|
||||
typedef enum {
|
||||
SS_STATE_INIT, /**< Initialized */
|
||||
SS_STATE_START, /**< Start */
|
||||
SS_STATE_RF_TUNING, /**< RF tuning */
|
||||
SS_STATE_RF_TUNED, /**< RF tuned */
|
||||
SS_STATE_AGC_CALCULATED, /**< AGC calculating */
|
||||
SS_STATE_WAIT_CSFIN, /**< Wait for CSFIN */
|
||||
SS_STATE_READ_CS, /**< Read CS data */
|
||||
SS_STATE_END, /**< End */
|
||||
SS_STATE_UNKNOWN /**< Unknown */
|
||||
} sony_demod_dvbs_s2_blindscan_ss_state_t;
|
||||
|
||||
/**
|
||||
@brief Structure for SS sub sequence
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
/**
|
||||
@brief Pointer of common parameters used by each sub sequence
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams;
|
||||
|
||||
uint8_t isEnable; /**< Enable flag (0: disable, 1: enable). */
|
||||
sony_demod_dvbs_s2_blindscan_ss_state_t state; /**< State. */
|
||||
sony_stopwatch_t stopwatch; /**< Stopwatch for internal use. */
|
||||
|
||||
uint32_t minFreqKHz; /**< Min frequency in KHz. */
|
||||
uint32_t maxFreqKHz; /**< Max frequency in KHz. */
|
||||
uint32_t stepFreqKHz; /**< Resolution in KHz. */
|
||||
uint32_t tunerStepFreqKHz; /**< RF step frequency in KHz. */
|
||||
|
||||
uint32_t currentFreqKHz; /**< Current frequency in KHz. */
|
||||
uint32_t agcLevel; /**< AGC level from register. */
|
||||
int32_t agc_x100dB; /**< AGC (x 100dB) calculated by tuner driver. */
|
||||
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pPowerList; /**< Power list. */
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pPowerListLast; /**< The last item of power list. */
|
||||
|
||||
uint8_t ocfr_csk; /**< The register value of OCFR_CSK (1 - 7). */
|
||||
} sony_demod_dvbs_s2_blindscan_subseq_ss_t;
|
||||
|
||||
/**
|
||||
@brief Initialize SS sub sequence
|
||||
|
||||
@param pSeq Instance for SS sub sequence.
|
||||
@param pCommonParams Pointer of common parameters.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_ss_Initialize (sony_demod_dvbs_s2_blindscan_subseq_ss_t * pSeq,
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams);
|
||||
|
||||
/**
|
||||
@brief Start SS sub sequence
|
||||
|
||||
@param pSeq Instance for SS sub sequence.
|
||||
@param minFreqKHz Min frequency in KHz.
|
||||
@param maxFreqKHz Max frequency in KHz.
|
||||
@param stepFreqKHz Resolution in KHz.
|
||||
@param tunerStepFreqKHz RF step frequency in KHz.
|
||||
@param powerSmooth power spectrum smoothing value.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_ss_Start (sony_demod_dvbs_s2_blindscan_subseq_ss_t * pSeq,
|
||||
uint32_t minFreqKHz,
|
||||
uint32_t maxFreqKHz,
|
||||
uint32_t stepFreqKHz,
|
||||
uint32_t tunerStepFreqKHz,
|
||||
uint8_t powerSmooth);
|
||||
|
||||
/**
|
||||
@brief Execute one sequence for SS sub sequence
|
||||
|
||||
@param pSeq Instance for SS sub sequence.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_ss_Sequence (sony_demod_dvbs_s2_blindscan_subseq_ss_t * pSeq);
|
||||
|
||||
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_SS_H */
|
||||
@@ -0,0 +1,119 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/09/28
|
||||
Modification ID : 1ea04def104d657deb64f0d0b0cae6ef992a9dd8
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbs_s2_blindscan_trace.h
|
||||
|
||||
This file provides trace functions definication.
|
||||
If you would like to use this trace functions for TuneSRS/BlindScan,
|
||||
please enable "SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_ENABLE" definition,
|
||||
and implement following functions.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_H
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
|
||||
#ifdef SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_ENABLE
|
||||
/**
|
||||
@brief Start trace function.
|
||||
|
||||
This function is called at the beginning of TuneSRS/BlindScan.
|
||||
If you have any process to do at this timing, please implement it in this function.
|
||||
(i.e. Open output file, etc...)
|
||||
*/
|
||||
void sony_demod_dvbs_s2_blindscan_trace_init (void);
|
||||
/**
|
||||
@brief Output power list.
|
||||
|
||||
@param name The event name.
|
||||
@param pList Power data list.
|
||||
*/
|
||||
void sony_demod_dvbs_s2_blindscan_trace_powerlist (char * name, sony_demod_dvbs_s2_blindscan_power_t * pList);
|
||||
/**
|
||||
@brief Output candidate list.
|
||||
|
||||
@param name The event name.
|
||||
@param pList Candidate data list.
|
||||
*/
|
||||
void sony_demod_dvbs_s2_blindscan_trace_candlist (char * name, sony_demod_dvbs_s2_blindscan_data_t * pList);
|
||||
/**
|
||||
@brief Start BT sub sequence.
|
||||
|
||||
@param freqKHz Frequency in KHz.
|
||||
@param candSR Candidate symbol rate in KSps.
|
||||
@param minCandSR Min candidate symbol rate in KSps.
|
||||
@param maxCandSR Max candidate symbol rate in KSps.
|
||||
@param minSR Min search range symbol rate in KSps.
|
||||
@param maxSR Max search range symbol rate in KSps.
|
||||
*/
|
||||
void sony_demod_dvbs_s2_blindscan_trace_bt_start (uint32_t freqKHz, uint32_t candSR, uint32_t minCandSR, uint32_t maxCandSR, uint32_t minSR, uint32_t maxSR);
|
||||
/**
|
||||
@brief Finish BT sub sequence.
|
||||
|
||||
@param eventName The result of that BT sub sequence.
|
||||
*/
|
||||
void sony_demod_dvbs_s2_blindscan_trace_bt_result (char * eventName);
|
||||
/**
|
||||
@brief RF tune for CS sub sequence.
|
||||
|
||||
@param freqKHz Frequency in KHz.
|
||||
*/
|
||||
void sony_demod_dvbs_s2_blindscan_trace_cs_tune (uint32_t freqKHz);
|
||||
/**
|
||||
@brief Start CS sub sequence.
|
||||
|
||||
@param offsetFreqKHz Frequency offset in KHz.
|
||||
*/
|
||||
void sony_demod_dvbs_s2_blindscan_trace_cs_start (int32_t offsetFreqKHz);
|
||||
/**
|
||||
@brief Finish CS sub sequence.
|
||||
|
||||
@param coarseSR Detected symbol rate in KSps.
|
||||
If symbol rate was not detected coarseSR is 0 or 1.
|
||||
*/
|
||||
void sony_demod_dvbs_s2_blindscan_trace_cs_result (uint32_t coarseSR);
|
||||
/**
|
||||
@brief PM sub sequence.
|
||||
|
||||
@param offsetFreqKHz Frequency offset in KHz.
|
||||
@param power Power value.
|
||||
*/
|
||||
void sony_demod_dvbs_s2_blindscan_trace_pm_power (int32_t offsetFreqKHz, int32_t power);
|
||||
/**
|
||||
@brief End trace function.
|
||||
|
||||
This function is called at the ending of TuneSRS/BlindScan.
|
||||
If you have any process to do at this timing, please implement it in this function.
|
||||
(i.e. Close output file, etc...)
|
||||
*/
|
||||
void sony_demod_dvbs_s2_blindscan_trace_fin (void);
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_INIT() sony_demod_dvbs_s2_blindscan_trace_init()
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_POWERLIST(A, B) sony_demod_dvbs_s2_blindscan_trace_powerlist(A, B)
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CANDLIST(A, B) sony_demod_dvbs_s2_blindscan_trace_candlist(A, B)
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_START(A, B, C, D, E, F) sony_demod_dvbs_s2_blindscan_trace_bt_start(A, B, C, D, E, F)
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT(A) sony_demod_dvbs_s2_blindscan_trace_bt_result(A)
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_TUNE(A) sony_demod_dvbs_s2_blindscan_trace_cs_tune(A)
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_START(A) sony_demod_dvbs_s2_blindscan_trace_cs_start(A)
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_RESULT(A) sony_demod_dvbs_s2_blindscan_trace_cs_result(A)
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_PM_POWER(A, B) sony_demod_dvbs_s2_blindscan_trace_pm_power(A, B)
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_FIN() sony_demod_dvbs_s2_blindscan_trace_fin()
|
||||
#else /* SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_ENABLE */
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_INIT()
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_POWERLIST(A, B)
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CANDLIST(A, B)
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_START(A, B, C, D, E, F)
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT(A)
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_TUNE(A)
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_START(A)
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_RESULT(A)
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_PM_POWER(A, B)
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_FIN()
|
||||
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_ENABLE */
|
||||
|
||||
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_H */
|
||||
+264
@@ -0,0 +1,264 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Static Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
static sony_result_t incrementMemCount (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage);
|
||||
static sony_result_t decrementMemCount (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage);
|
||||
static sony_result_t incrementPowCount (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage);
|
||||
static sony_result_t decrementPowCount (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_StorageInit (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pPowerArrayTop,
|
||||
int32_t powerArrayLength,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pDataArrayTop,
|
||||
int32_t dataArrayLength)
|
||||
{
|
||||
int32_t i = 0;
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pPowerCurrent = NULL;
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pDataCurrent = NULL;
|
||||
|
||||
if ((!pStorage) || (!pPowerArrayTop) || (powerArrayLength <= 0) || (!pDataArrayTop) || (dataArrayLength <= 0)){
|
||||
return SONY_RESULT_ERROR_ARG;
|
||||
}
|
||||
|
||||
pStorage->pPowerArrayTop = pPowerArrayTop;
|
||||
pStorage->powerArrayLength = powerArrayLength;
|
||||
pStorage->pDataArrayTop = pDataArrayTop;
|
||||
pStorage->dataArrayLength = dataArrayLength;
|
||||
|
||||
pPowerCurrent = &(pStorage->availablePowerList);
|
||||
for(i = 0; i < powerArrayLength; i++){
|
||||
pPowerCurrent->pNext = (pPowerArrayTop + i);
|
||||
pPowerCurrent = pPowerCurrent->pNext;
|
||||
}
|
||||
pPowerCurrent->pNext = NULL;
|
||||
pStorage->currentUsedPowerCount = 0;
|
||||
pStorage->maxUsedPowerCount = 0;
|
||||
|
||||
pDataCurrent = &(pStorage->availableDataList);
|
||||
for(i = 0; i < dataArrayLength; i++){
|
||||
pDataCurrent->pNext = (pDataArrayTop + i);
|
||||
pDataCurrent = pDataCurrent->pNext;
|
||||
}
|
||||
pDataCurrent->pNext = NULL;
|
||||
pStorage->currentUsedCount = 0;
|
||||
pStorage->maxUsedCount = 0;
|
||||
|
||||
return SONY_RESULT_OK;
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_AllocPower (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_power_t ** ppPower)
|
||||
{
|
||||
if((!pStorage) || (!ppPower)) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if(pStorage->availablePowerList.pNext != NULL){
|
||||
*ppPower = pStorage->availablePowerList.pNext;
|
||||
if((*ppPower)->pNext != NULL){
|
||||
pStorage->availablePowerList.pNext = (*ppPower)->pNext;
|
||||
} else {
|
||||
/* Alloc the last data. */
|
||||
pStorage->availablePowerList.pNext = NULL;
|
||||
}
|
||||
} else {
|
||||
/* Overflow. */
|
||||
return SONY_RESULT_ERROR_OVERFLOW;
|
||||
}
|
||||
(*ppPower)->pNext = NULL;
|
||||
return incrementPowCount (pStorage);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_FreePower (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pPower)
|
||||
{
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pTemp = NULL;
|
||||
|
||||
if((!pStorage) || (!pPower)) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if(pStorage->availablePowerList.pNext != NULL){
|
||||
pTemp = pStorage->availablePowerList.pNext;
|
||||
pStorage->availablePowerList.pNext = pPower;
|
||||
pPower->pNext = pTemp;
|
||||
} else {
|
||||
/* Data is empty. */
|
||||
pStorage->availablePowerList.pNext = pPower;
|
||||
pPower->pNext = NULL;
|
||||
}
|
||||
return decrementPowCount (pStorage);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_ClearPowerList (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pListTop)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pCurrent = NULL;
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pTemp = NULL;
|
||||
|
||||
if ((!pStorage) || (!pListTop)){
|
||||
return SONY_RESULT_ERROR_ARG;
|
||||
}
|
||||
|
||||
pCurrent = pListTop->pNext;
|
||||
|
||||
while (pCurrent){
|
||||
pTemp = pCurrent->pNext;
|
||||
result = sony_demod_dvbs_s2_blindscan_FreePower (pStorage, pCurrent);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pCurrent = pTemp;
|
||||
}
|
||||
|
||||
pListTop->pNext = NULL;
|
||||
|
||||
return SONY_RESULT_OK;
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_AllocData (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_data_t ** ppData)
|
||||
{
|
||||
if ((!pStorage) || (!ppData)){
|
||||
return SONY_RESULT_ERROR_ARG;
|
||||
}
|
||||
|
||||
if(pStorage->availableDataList.pNext){
|
||||
*ppData = pStorage->availableDataList.pNext;
|
||||
if((*ppData)->pNext){
|
||||
pStorage->availableDataList.pNext = (*ppData)->pNext;
|
||||
} else {
|
||||
/* Alloc the last data. */
|
||||
pStorage->availableDataList.pNext = NULL;
|
||||
}
|
||||
} else {
|
||||
/* Overflow. */
|
||||
return SONY_RESULT_ERROR_OVERFLOW;
|
||||
}
|
||||
(*ppData)->pNext = NULL;
|
||||
return incrementMemCount(pStorage);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_FreeData (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pData)
|
||||
{
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pTemp = NULL;
|
||||
|
||||
if ((!pStorage) || (!pData)){
|
||||
return SONY_RESULT_ERROR_OTHER;
|
||||
}
|
||||
|
||||
if(pStorage->availableDataList.pNext){
|
||||
pTemp = pStorage->availableDataList.pNext;
|
||||
pStorage->availableDataList.pNext = pData;
|
||||
pData->pNext = pTemp;
|
||||
} else {
|
||||
/* Data is empty. */
|
||||
pStorage->availableDataList.pNext = pData;
|
||||
pData->pNext = NULL;
|
||||
}
|
||||
return decrementMemCount(pStorage);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_ClearDataList (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pListTop)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCurrent = NULL;
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pTemp = NULL;
|
||||
|
||||
if ((!pStorage) || (!pListTop)){
|
||||
return SONY_RESULT_ERROR_ARG;
|
||||
}
|
||||
|
||||
pCurrent = pListTop->pNext;
|
||||
|
||||
while (pCurrent){
|
||||
pTemp = pCurrent->pNext;
|
||||
result = sony_demod_dvbs_s2_blindscan_FreeData (pStorage, pCurrent);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pCurrent = pTemp;
|
||||
}
|
||||
|
||||
pListTop->pNext = NULL;
|
||||
|
||||
return SONY_RESULT_OK;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Static Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
static sony_result_t incrementMemCount (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage)
|
||||
{
|
||||
if (!pStorage){
|
||||
return SONY_RESULT_ERROR_ARG;
|
||||
}
|
||||
pStorage->currentUsedCount++;
|
||||
if(pStorage->currentUsedCount <= 0){
|
||||
/* Error(Overflow) */
|
||||
return SONY_RESULT_ERROR_OVERFLOW;
|
||||
}
|
||||
if(pStorage->maxUsedCount < pStorage->currentUsedCount){
|
||||
pStorage->maxUsedCount = pStorage->currentUsedCount;
|
||||
}
|
||||
return SONY_RESULT_OK;
|
||||
}
|
||||
|
||||
static sony_result_t decrementMemCount (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage)
|
||||
{
|
||||
if (!pStorage){
|
||||
return SONY_RESULT_ERROR_ARG;
|
||||
}
|
||||
if(pStorage->currentUsedCount == 0){
|
||||
/* Error(Overflow) */
|
||||
return SONY_RESULT_ERROR_OVERFLOW;
|
||||
} else {
|
||||
pStorage->currentUsedCount--;
|
||||
}
|
||||
return SONY_RESULT_OK;
|
||||
}
|
||||
|
||||
static sony_result_t incrementPowCount (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage)
|
||||
{
|
||||
if (!pStorage){
|
||||
return SONY_RESULT_ERROR_ARG;
|
||||
}
|
||||
pStorage->currentUsedPowerCount++;
|
||||
if(pStorage->currentUsedPowerCount <= 0){
|
||||
/* Error(Overflow) */
|
||||
return SONY_RESULT_ERROR_OVERFLOW;
|
||||
}
|
||||
if(pStorage->maxUsedPowerCount < pStorage->currentUsedPowerCount){
|
||||
pStorage->maxUsedPowerCount = pStorage->currentUsedPowerCount;
|
||||
}
|
||||
return SONY_RESULT_OK;
|
||||
}
|
||||
|
||||
static sony_result_t decrementPowCount (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage)
|
||||
{
|
||||
if (!pStorage){
|
||||
return SONY_RESULT_ERROR_ARG;
|
||||
}
|
||||
if(pStorage->currentUsedPowerCount == 0){
|
||||
/* Error(Overflow) */
|
||||
return SONY_RESULT_ERROR_OVERFLOW;
|
||||
} else {
|
||||
pStorage->currentUsedPowerCount--;
|
||||
}
|
||||
return SONY_RESULT_OK;
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbs_s2_blindscan_utility.h
|
||||
|
||||
This file provides the functions for alloc/free data.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_UTILITY_H
|
||||
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_UTILITY_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_seq.h"
|
||||
|
||||
/**
|
||||
@brief Initialize storage instance.
|
||||
|
||||
@param pStorage Storage instance.
|
||||
@param pPowerArrayTop Pointer of array for power data.
|
||||
@param powerArrayLength Length of array for power data "pPowerArrayTop".
|
||||
@param pDataArrayTop Pointer of array for data.
|
||||
@param dataArrayLength Length of array for data "pDataArrayTop".
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_StorageInit (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pPowerArrayTop,
|
||||
int32_t powerArrayLength,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pDataArrayTop,
|
||||
int32_t dataArrayLength);
|
||||
|
||||
/**
|
||||
@brief Allocate power data.
|
||||
|
||||
@param pStorage Storage instance.
|
||||
@param ppPower Address of address for power data.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_AllocPower (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_power_t ** ppPower);
|
||||
|
||||
/**
|
||||
@brief Free power data.
|
||||
|
||||
@param pStorage Storage instance.
|
||||
@param pPower Address for power data.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_FreePower (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pPower);
|
||||
|
||||
/**
|
||||
@brief Clear power list.
|
||||
|
||||
@param pStorage Storage instance.
|
||||
@param pListTop Address for power list.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_ClearPowerList (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pListTop);
|
||||
|
||||
/**
|
||||
@brief Allocate data.
|
||||
|
||||
@param pStorage Storage instance.
|
||||
@param ppData Address of address for data.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_AllocData (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_data_t ** ppData);
|
||||
|
||||
/**
|
||||
@brief Free data.
|
||||
|
||||
@param pStorage Storage instance.
|
||||
@param pData Address for data.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_FreeData (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pData);
|
||||
|
||||
/**
|
||||
@brief Clear data list.
|
||||
|
||||
@param pStorage Storage instance.
|
||||
@param pListTop Address for data list.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_blindscan_ClearDataList (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pListTop);
|
||||
|
||||
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_UTILITY_H */
|
||||
@@ -0,0 +1,31 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbs_s2_tune_srs.h
|
||||
|
||||
This file provides demodulator setting for TuneSRS function.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DEMOD_DVBS_S2_TUNE_SRS_H
|
||||
#define SONY_DEMOD_DVBS_S2_TUNE_SRS_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Definitions
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@brief Frequency range for TuneSRS
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_DEMOD_DVBS_S2_TUNE_SRS_FREQ_RANGE_10MHz, /**< +/- 10MHz */
|
||||
SONY_DEMOD_DVBS_S2_TUNE_SRS_FREQ_RANGE_5MHz /**< +/- 5MHz */
|
||||
} sony_demod_dvbs_s2_tune_srs_freq_range_t;
|
||||
|
||||
#endif /* SONY_DEMOD_DVBS_S2_TUNE_SRS_H */
|
||||
@@ -0,0 +1,480 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod.h"
|
||||
#include "sony_demod_dvbs_s2.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_algo.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_bt.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_cs.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_fs.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_pm.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_ss.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_utility.h"
|
||||
#include "sony_demod_dvbs_s2_tune_srs.h"
|
||||
#include "sony_demod_dvbs_s2_tune_srs_seq.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_trace.h"
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_tune_srs_seq_Initialize (sony_demod_dvbs_s2_tune_srs_seq_t * pSeq,
|
||||
sony_demod_t * pDemod,
|
||||
uint32_t centerFreqKHz,
|
||||
sony_demod_dvbs_s2_tune_srs_freq_range_t freqRange)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_INIT();
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_tune_srs_seq_Initialize");
|
||||
|
||||
if ((!pSeq) || (!pDemod)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
switch(freqRange)
|
||||
{
|
||||
case SONY_DEMOD_DVBS_S2_TUNE_SRS_FREQ_RANGE_10MHz:
|
||||
pSeq->rangeFreqMHz = 10;
|
||||
break;
|
||||
|
||||
case SONY_DEMOD_DVBS_S2_TUNE_SRS_FREQ_RANGE_5MHz:
|
||||
pSeq->rangeFreqMHz = 5;
|
||||
break;
|
||||
|
||||
default:
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
pSeq->isContinue = 1;
|
||||
pSeq->isDetect = 0;
|
||||
pSeq->seqState = TUNE_SRS_SEQ_STATE_START;
|
||||
pSeq->centerFreqKHz = centerFreqKHz;
|
||||
pSeq->minFreqKHz = centerFreqKHz - ((pSeq->rangeFreqMHz) * 1000); /* Frequency capture range */
|
||||
pSeq->maxFreqKHz = centerFreqKHz + ((pSeq->rangeFreqMHz) * 1000); /* Frequency capture range */
|
||||
pSeq->minSymbolRateKSps = 1000; /* Symbol rate capture range (Fixed) */
|
||||
pSeq->maxSymbolRateKSps = 45000; /* Symbol rate capture range (Fixed) */
|
||||
|
||||
/*
|
||||
* 500KHz step search is for 1 - 20MSps range.
|
||||
*
|
||||
* Max(20MSps) * 1.35 / 2 = 13.5MSps -> 14MHz
|
||||
*/
|
||||
pSeq->powerMinFreqKHz1 = pSeq->minFreqKHz - 14000;
|
||||
pSeq->powerMaxFreqKHz1 = pSeq->maxFreqKHz + 14000;
|
||||
/*
|
||||
* 2000KHz step search is for 20 - 45MSps range.
|
||||
*
|
||||
* Max(45MSps) * 1.35 / 2 = 30.375MSps
|
||||
* 30.375MHz - 14MHz = 16.375MHz -> 20MHz
|
||||
*/
|
||||
pSeq->powerMinFreqKHz2 = pSeq->powerMaxFreqKHz1;
|
||||
pSeq->powerMaxFreqKHz2 = pSeq->powerMaxFreqKHz1 + 20000;
|
||||
pSeq->powerMinFreqKHz3 = pSeq->powerMinFreqKHz1 - 20000;
|
||||
pSeq->powerMaxFreqKHz3 = pSeq->powerMinFreqKHz1;
|
||||
|
||||
if ((pSeq->powerMaxFreqKHz2 - pSeq->powerMinFreqKHz3) < 72000){
|
||||
pSeq->powerMinFreqKHz1 = pSeq->powerMinFreqKHz3;
|
||||
pSeq->powerMaxFreqKHz1 = pSeq->powerMaxFreqKHz2;
|
||||
pSeq->powerMinFreqKHz2 = 0;
|
||||
pSeq->powerMaxFreqKHz2 = 0;
|
||||
pSeq->powerMinFreqKHz3 = 0;
|
||||
pSeq->powerMaxFreqKHz3 = 0;
|
||||
}
|
||||
|
||||
pSeq->commonParams.pDemod = pDemod;
|
||||
pSeq->commonParams.detInfo.isDetect = 0;
|
||||
pSeq->commonParams.tuneReq.isRequest = 0;
|
||||
pSeq->commonParams.agcInfo.isRequest = 0;
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
|
||||
pSeq->commonParams.ckalFreqKHz = 64000; /* CKAL */
|
||||
pSeq->commonParams.ckahFreqKHz = 96000; /* CKAH */
|
||||
|
||||
/* Initialize the data storage */
|
||||
result = sony_demod_dvbs_s2_blindscan_StorageInit (&(pSeq->commonParams.storage),
|
||||
pSeq->powerArray,
|
||||
sizeof(pSeq->powerArray)/sizeof(pSeq->powerArray[0]),
|
||||
pSeq->dataArray,
|
||||
sizeof(pSeq->dataArray)/sizeof(pSeq->dataArray[0]));
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Initialize demodulator to start BlindScan. */
|
||||
result = sony_demod_dvbs_s2_blindscan_Initialize(pSeq->commonParams.pDemod);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_bt_Initialize (&pSeq->subseqBT, &pSeq->commonParams);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Initialize (&pSeq->subseqPM, &pSeq->commonParams);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_ss_Initialize (&pSeq->subseqSS, &pSeq->commonParams);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_fs_Initialize (&pSeq->subseqFS, &pSeq->subseqBT, &pSeq->commonParams);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_cs_Initialize (&pSeq->subseqCS, &pSeq->subseqPM, &pSeq->commonParams);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_AllocData(&(pSeq->commonParams.storage), &(pSeq->pCandList1));
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->pCandLast1 = pSeq->pCandList1;
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_AllocData(&(pSeq->commonParams.storage), &(pSeq->pCandList2));
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->pCandLast2 = pSeq->pCandList2;
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_AllocPower(&(pSeq->commonParams.storage), &(pSeq->pPowerList));
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_AllocData(&(pSeq->commonParams.storage), &(pSeq->pDetectedList));
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_tune_srs_seq_Sequence (sony_demod_dvbs_s2_tune_srs_seq_t * pSeq)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_tune_srs_seq_Sequence");
|
||||
|
||||
if (!pSeq){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if (pSeq->subseqSS.isEnable){
|
||||
/* SS seq */
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_ss_Sequence (&pSeq->subseqSS);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
} else if (pSeq->subseqBT.isEnable){
|
||||
/* BT seq */
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_bt_Sequence (&pSeq->subseqBT);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
} else if (pSeq->subseqCS.isEnable){
|
||||
if (pSeq->subseqPM.isEnable){
|
||||
/* PM seq */
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Sequence(&pSeq->subseqPM);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
} else {
|
||||
/* CS seq */
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_cs_Sequence(&pSeq->subseqCS);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Main sequence */
|
||||
switch(pSeq->seqState)
|
||||
{
|
||||
case TUNE_SRS_SEQ_STATE_START:
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_ss_Start(&pSeq->subseqSS,
|
||||
pSeq->powerMinFreqKHz1,
|
||||
pSeq->powerMaxFreqKHz1,
|
||||
500,
|
||||
pSeq->powerMaxFreqKHz1 - pSeq->powerMinFreqKHz1,
|
||||
pSeq->commonParams.pDemod->dvbss2PowerSmooth);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
pSeq->seqState = TUNE_SRS_SEQ_STATE_SS1_FIN;
|
||||
break;
|
||||
|
||||
case TUNE_SRS_SEQ_STATE_SS1_FIN:
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_POWERLIST("1st", pSeq->subseqSS.pPowerList);
|
||||
result = sony_demod_dvbs_s2_blindscan_algo_GetCandidateNml (&(pSeq->commonParams.storage),
|
||||
pSeq->subseqSS.pPowerList,
|
||||
200,
|
||||
1000,
|
||||
5000,
|
||||
1000,
|
||||
pSeq->pCandList1);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_algo_SeparateCandidate (&(pSeq->commonParams.storage), pSeq->pCandList1);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_algo_DeleteDuplicate2 (&(pSeq->commonParams.storage), pSeq->pCandList1);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CANDLIST("1st(1-5)", pSeq->pCandList1);
|
||||
|
||||
/* Tune for coarse search */
|
||||
pSeq->commonParams.tuneReq.isRequest = 1;
|
||||
pSeq->commonParams.tuneReq.frequencyKHz = pSeq->centerFreqKHz;
|
||||
pSeq->commonParams.tuneReq.symbolRateKSps = 15000;
|
||||
pSeq->commonParams.tuneReq.system = SONY_DTV_SYSTEM_DVBS;
|
||||
|
||||
/* Set the top candidate */
|
||||
pSeq->pCandCurrent = pSeq->pCandList1->pNext;
|
||||
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
pSeq->seqState = TUNE_SRS_SEQ_STATE_RF_TUNED;
|
||||
break;
|
||||
|
||||
case TUNE_SRS_SEQ_STATE_RF_TUNED:
|
||||
if (pSeq->pCandCurrent){
|
||||
int32_t offsetFreqKHz = (int32_t)(pSeq->pCandCurrent->data.candidate.centerFreqKHz) - (int32_t)(pSeq->commonParams.tuneReq.frequencyKHz);
|
||||
if ((((int32_t)((pSeq->rangeFreqMHz * 1000) + 3000) * (-1)) <= offsetFreqKHz) && (offsetFreqKHz <= (int32_t)((pSeq->rangeFreqMHz * 1000) + 3000))){
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_TUNE (pSeq->commonParams.tuneReq.frequencyKHz);
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_cs_Start (&(pSeq->subseqCS), offsetFreqKHz);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
} else {
|
||||
pSeq->subseqCS.isExist = 0;
|
||||
}
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
pSeq->seqState = TUNE_SRS_SEQ_STATE_CS1_FIN;
|
||||
} else {
|
||||
result = sony_demod_dvbs_s2_blindscan_algo_DeleteDuplicate (&(pSeq->commonParams.storage), pSeq->pCandList2);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_ClearDataList (&(pSeq->commonParams.storage), pSeq->pCandList1);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
pSeq->pCandList1->pNext = pSeq->pCandList2->pNext;
|
||||
pSeq->pCandList2->pNext = NULL;
|
||||
|
||||
if (((pSeq->powerMaxFreqKHz2 - pSeq->powerMinFreqKHz2) == 0) || ((pSeq->powerMaxFreqKHz3 - pSeq->powerMinFreqKHz3) == 0)){
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
pSeq->seqState = TUNE_SRS_SEQ_STATE_CAND2;
|
||||
} else {
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
pSeq->seqState = TUNE_SRS_SEQ_STATE_CS1_FIN2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TUNE_SRS_SEQ_STATE_CS1_FIN:
|
||||
if (pSeq->subseqCS.isExist){
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pTemp = NULL;
|
||||
result = sony_demod_dvbs_s2_blindscan_AllocData (&(pSeq->commonParams.storage), &pTemp);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pTemp->data.candidate.centerFreqKHz = (uint32_t)((int32_t)pSeq->commonParams.tuneReq.frequencyKHz + pSeq->subseqCS.freqOffsetKHz);
|
||||
pTemp->data.candidate.symbolRateKSps = pSeq->subseqCS.coarseSymbolRateKSps;
|
||||
pTemp->data.candidate.minSymbolRateKSps = (pSeq->subseqCS.coarseSymbolRateKSps * 700) / 1000;
|
||||
pTemp->data.candidate.maxSymbolRateKSps = ((pSeq->subseqCS.coarseSymbolRateKSps * 1600) + 999) / 1000;
|
||||
pSeq->pCandLast2->pNext = pTemp;
|
||||
pSeq->pCandLast2 = pSeq->pCandLast2->pNext;
|
||||
}
|
||||
pSeq->pCandCurrent = pSeq->pCandCurrent->pNext;
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
pSeq->seqState = TUNE_SRS_SEQ_STATE_RF_TUNED;
|
||||
break;
|
||||
|
||||
case TUNE_SRS_SEQ_STATE_CS1_FIN2:
|
||||
/* Set SS1 data to list */
|
||||
pSeq->pPowerList->pNext = pSeq->subseqSS.pPowerList->pNext;
|
||||
pSeq->subseqSS.pPowerList->pNext = NULL;
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_ss_Start (&(pSeq->subseqSS),
|
||||
pSeq->powerMinFreqKHz2,
|
||||
pSeq->powerMaxFreqKHz2,
|
||||
2000,
|
||||
pSeq->powerMaxFreqKHz2 - pSeq->powerMinFreqKHz2,
|
||||
pSeq->commonParams.pDemod->dvbss2PowerSmooth);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
pSeq->seqState = TUNE_SRS_SEQ_STATE_SS2_FIN;
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
break;
|
||||
|
||||
case TUNE_SRS_SEQ_STATE_SS2_FIN:
|
||||
/* Set SS2 data to list */
|
||||
pSeq->pPowerLast = pSeq->pPowerList;
|
||||
while(pSeq->pPowerLast->pNext){
|
||||
pSeq->pPowerLast = pSeq->pPowerLast->pNext;
|
||||
}
|
||||
pSeq->pPowerLast->pNext = pSeq->subseqSS.pPowerList->pNext;
|
||||
pSeq->subseqSS.pPowerList->pNext = NULL;
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_ss_Start (&(pSeq->subseqSS),
|
||||
pSeq->powerMinFreqKHz3,
|
||||
pSeq->powerMaxFreqKHz3,
|
||||
2000,
|
||||
pSeq->powerMaxFreqKHz3 - pSeq->powerMinFreqKHz3,
|
||||
pSeq->commonParams.pDemod->dvbss2PowerSmooth);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
pSeq->seqState = TUNE_SRS_SEQ_STATE_SS3_FIN;
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
break;
|
||||
|
||||
case TUNE_SRS_SEQ_STATE_SS3_FIN:
|
||||
|
||||
/* Set SS3 data to list */
|
||||
pSeq->pPowerLast = pSeq->subseqSS.pPowerList;
|
||||
while(pSeq->pPowerLast->pNext){
|
||||
pSeq->pPowerLast = pSeq->pPowerLast->pNext;
|
||||
}
|
||||
pSeq->pPowerLast->pNext = pSeq->pPowerList->pNext;
|
||||
pSeq->pPowerList->pNext = pSeq->subseqSS.pPowerList->pNext;
|
||||
pSeq->seqState = TUNE_SRS_SEQ_STATE_CAND2;
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
break;
|
||||
|
||||
case TUNE_SRS_SEQ_STATE_CAND2:
|
||||
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CANDLIST("1st", pSeq->pCandList1);
|
||||
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_POWERLIST("2nd", pSeq->pPowerList);
|
||||
result = sony_demod_dvbs_s2_blindscan_algo_GetCandidateNml (&(pSeq->commonParams.storage),
|
||||
pSeq->pPowerList,
|
||||
100,
|
||||
20000,
|
||||
45000,
|
||||
4000,
|
||||
pSeq->pCandList2);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CANDLIST("2nd(20-45)", pSeq->pCandList2);
|
||||
|
||||
pSeq->pCandLast1 = pSeq->pCandList1;
|
||||
while(pSeq->pCandLast1->pNext){
|
||||
pSeq->pCandLast1 = pSeq->pCandLast1->pNext;
|
||||
}
|
||||
pSeq->pCandLast1->pNext = pSeq->pCandList2->pNext;
|
||||
pSeq->pCandList2->pNext = NULL;
|
||||
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_algo_GetCandidateNml (&(pSeq->commonParams.storage),
|
||||
pSeq->pPowerList,
|
||||
100,
|
||||
5000,
|
||||
20000,
|
||||
1000,
|
||||
pSeq->pCandList2);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CANDLIST("3rd(5-20)", pSeq->pCandList2);
|
||||
|
||||
while(pSeq->pCandLast1->pNext){
|
||||
pSeq->pCandLast1 = pSeq->pCandLast1->pNext;
|
||||
}
|
||||
pSeq->pCandLast1->pNext = pSeq->pCandList2->pNext;
|
||||
pSeq->pCandList2->pNext = NULL;
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_algo_SortByFrequency (&(pSeq->commonParams.storage),
|
||||
pSeq->pCandList1,
|
||||
pSeq->centerFreqKHz);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CANDLIST ("final", pSeq->pCandList1);
|
||||
|
||||
pSeq->pCandCurrent = pSeq->pCandList1->pNext;
|
||||
|
||||
pSeq->seqState = TUNE_SRS_SEQ_STATE_BT_START;
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
break;
|
||||
|
||||
case TUNE_SRS_SEQ_STATE_BT_START:
|
||||
if (pSeq->pCandCurrent){
|
||||
int32_t offsetFreqKHz = (int32_t)(pSeq->pCandCurrent->data.candidate.centerFreqKHz) - (int32_t)(pSeq->centerFreqKHz);
|
||||
/* Performing Blind Tune on the candidates that lie within (rangeFreqMHz +- 3MHz) of the specified tune-frequency. */
|
||||
if ((((int32_t)((pSeq->rangeFreqMHz * 1000) + 3000) * (-1)) <= offsetFreqKHz) && (offsetFreqKHz <= (int32_t)((pSeq->rangeFreqMHz * 1000) + 3000))){
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_bt_Start (&(pSeq->subseqBT),
|
||||
pSeq->pCandCurrent->data.candidate.centerFreqKHz,
|
||||
pSeq->pCandCurrent->data.candidate.symbolRateKSps,
|
||||
pSeq->pCandCurrent->data.candidate.minSymbolRateKSps,
|
||||
pSeq->pCandCurrent->data.candidate.maxSymbolRateKSps,
|
||||
pSeq->minSymbolRateKSps,
|
||||
pSeq->maxSymbolRateKSps);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->seqState = TUNE_SRS_SEQ_STATE_BT_END;
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
} else {
|
||||
/* Unlocked */
|
||||
pSeq->isContinue = 0;
|
||||
pSeq->isDetect = 0;
|
||||
}
|
||||
} else {
|
||||
/* Unlocked */
|
||||
pSeq->isContinue = 0;
|
||||
pSeq->isDetect = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case TUNE_SRS_SEQ_STATE_BT_END:
|
||||
if (pSeq->subseqBT.isLocked){
|
||||
/* Locked */
|
||||
pSeq->isContinue = 0;
|
||||
pSeq->tuneParam.centerFreqKHz = (uint32_t)((int32_t)(pSeq->commonParams.tuneReq.frequencyKHz) + pSeq->subseqBT.detCarrierOffsetKHz);
|
||||
pSeq->tuneParam.symbolRateKSps = (pSeq->subseqBT.detSymbolRateSps + 500) / 1000;
|
||||
pSeq->tuneParam.system = pSeq->subseqBT.detSystem;
|
||||
if ((pSeq->centerFreqKHz - (pSeq->rangeFreqMHz * 1000) - 100) <= (pSeq->tuneParam.centerFreqKHz) &&
|
||||
((pSeq->tuneParam.centerFreqKHz) <= pSeq->centerFreqKHz + (pSeq->rangeFreqMHz * 1000) + 100)) {
|
||||
/* Signal is in range. */
|
||||
pSeq->isDetect = 1;
|
||||
} else {
|
||||
/* Signal is out of range. */
|
||||
pSeq->isDetect = 0;
|
||||
}
|
||||
}
|
||||
pSeq->pCandCurrent = pSeq->pCandCurrent->pNext;
|
||||
pSeq->seqState = TUNE_SRS_SEQ_STATE_BT_START;
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbs_s2_tune_srs_seq.h
|
||||
|
||||
This file provides defines for TuneSRS sequence.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DEMOD_DVBS_S2_TUNE_SRS_SEQ_H
|
||||
#define SONY_DEMOD_DVBS_S2_TUNE_SRS_SEQ_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod.h"
|
||||
#include "sony_demod_dvbs_s2.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_utility.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_seq_common.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_bt.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_cs.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_fs.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_pm.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_ss.h"
|
||||
#include "sony_demod_dvbs_s2_tune_srs.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Definitions
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Definition of array size used for TuneSRS in this driver.
|
||||
|
||||
The user need not to change this value directly.
|
||||
*/
|
||||
#define SONY_DEMOD_DVBS_S2_TUNE_SRS_POWER_MAX 500
|
||||
|
||||
/**
|
||||
@brief Definition of array size used for TuneSRS in this driver.
|
||||
|
||||
The data size is depend on the input signal as follow.
|
||||
- Search range.
|
||||
- Power spectrum.
|
||||
- etc...
|
||||
|
||||
User can get the maximum used data size by sony_demod_dvbs_s2_blindscan_data_storage_t::maxUsedCount.
|
||||
If the driver returns SONY_RESULT_ERROR_OVERFLOW, please increase this value.
|
||||
*/
|
||||
#define SONY_DEMOD_DVBS_S2_TUNE_SRS_DATA_MAX 5000
|
||||
|
||||
/**
|
||||
@brief State for TuneSRS sequence.
|
||||
*/
|
||||
typedef enum {
|
||||
TUNE_SRS_SEQ_STATE_START, /**< Start */
|
||||
TUNE_SRS_SEQ_STATE_SS1_FIN, /**< SS1 fin */
|
||||
TUNE_SRS_SEQ_STATE_RF_TUNED, /**< RF tuned */
|
||||
TUNE_SRS_SEQ_STATE_CS1_FIN, /**< CS1 fin */
|
||||
TUNE_SRS_SEQ_STATE_CS1_FIN2, /**< CS1 fin2 */
|
||||
TUNE_SRS_SEQ_STATE_SS2_FIN, /**< SS2 fin */
|
||||
TUNE_SRS_SEQ_STATE_SS3_FIN, /**< SS3 fin */
|
||||
TUNE_SRS_SEQ_STATE_CAND2, /**< Cand2 */
|
||||
TUNE_SRS_SEQ_STATE_BT_START, /**< Start BT */
|
||||
TUNE_SRS_SEQ_STATE_BT_END /**< End BT */,
|
||||
TUNE_SRS_SEQ_STATE_FINISH, /**< Finish */
|
||||
TUNE_SRS_SEQ_STATE_UNKNOWN /**< Unknown */
|
||||
} sony_demod_dvbs_s2_tune_srs_seq_state_t;
|
||||
|
||||
/**
|
||||
@brief structure for scan sequence.
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
/**
|
||||
@brief Common parameters used by each sub sequence.
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t commonParams;
|
||||
|
||||
/**
|
||||
@brief Finish/Continue flag.
|
||||
|
||||
- 0: Finish the sequence.
|
||||
- 1: Continue the sequence.
|
||||
*/
|
||||
uint8_t isContinue;
|
||||
|
||||
/**
|
||||
@brief Signal detect flag.
|
||||
|
||||
After "isContinue == 0", please see this flag.
|
||||
If isDetect == 1, TuneSRS detected signal.
|
||||
If isDetect == 0, TuneSRS didn't detect signal.
|
||||
*/
|
||||
uint8_t isDetect;
|
||||
|
||||
/**
|
||||
@brief State of main sequence.
|
||||
*/
|
||||
uint32_t seqState;
|
||||
|
||||
sony_demod_dvbs_s2_blindscan_subseq_bt_t subseqBT; /**< Sub sequence for BT. */
|
||||
sony_demod_dvbs_s2_blindscan_subseq_pm_t subseqPM; /**< Sub sequence for PM. */
|
||||
sony_demod_dvbs_s2_blindscan_subseq_ss_t subseqSS; /**< Sub sequence for SS. */
|
||||
sony_demod_dvbs_s2_blindscan_subseq_fs_t subseqFS; /**< Sub sequence for FS. */
|
||||
sony_demod_dvbs_s2_blindscan_subseq_cs_t subseqCS; /**< Sub sequence for CS. */
|
||||
|
||||
uint32_t centerFreqKHz; /**< Center frequency in KHz from argument */
|
||||
uint32_t rangeFreqMHz; /**< Capture range in MHz from argument */
|
||||
uint32_t minFreqKHz; /**< Min freq calculated from centerFreqKHz and rangeFreqMHz */
|
||||
uint32_t maxFreqKHz; /**< Max freq calculated from centerFreqKHz and rangeFreqMHz */
|
||||
uint32_t minSymbolRateKSps; /**< Min symbol rate in KSps. (Fixed to 1000) */
|
||||
uint32_t maxSymbolRateKSps; /**< Max symbol rate in KSps. (Fixed to 45000) */
|
||||
|
||||
uint32_t powerMinFreqKHz1; /**< Min frequency for 1st power search in KHz. */
|
||||
uint32_t powerMaxFreqKHz1; /**< Max frequency for 1st power search in KHz. */
|
||||
uint32_t powerMinFreqKHz2; /**< Min frequency for 2nd power search in KHz. */
|
||||
uint32_t powerMaxFreqKHz2; /**< Max frequency for 2nd power search in KHz. */
|
||||
uint32_t powerMinFreqKHz3; /**< Min frequency for 3rd power search in KHz. */
|
||||
uint32_t powerMaxFreqKHz3; /**< Max frequency for 3rd power search in KHz. */
|
||||
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pDetectedList; /**< Detected list */
|
||||
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandList1; /**< Candidate list 1 */
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandLast1; /**< Last pointer of candidate list 1 */
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandCurrent; /**< Current pointer of candidate list 1 */
|
||||
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandList2; /**< Candidate list 2 */
|
||||
sony_demod_dvbs_s2_blindscan_data_t * pCandLast2; /**< Last pointer of candidate list 2 */
|
||||
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pPowerList; /**< Power list */
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pPowerLast; /**< Last pointer of power list */
|
||||
|
||||
/**
|
||||
@brief Power data for storage.
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_power_t powerArray[SONY_DEMOD_DVBS_S2_TUNE_SRS_POWER_MAX];
|
||||
/**
|
||||
@brief Data for storage.
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_data_t dataArray[SONY_DEMOD_DVBS_S2_TUNE_SRS_DATA_MAX];
|
||||
|
||||
/**
|
||||
@brief Instance for detected signal.
|
||||
*/
|
||||
sony_dvbs_s2_tune_param_t tuneParam;
|
||||
|
||||
} sony_demod_dvbs_s2_tune_srs_seq_t;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Prepare to start TuneSRS sequence.
|
||||
|
||||
@param pSeq The sequence instance.
|
||||
@param pDemod Demodulator instance.
|
||||
@param centerFreqKHz Center frequency in KHz.
|
||||
@param freqRange Frequency range.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_tune_srs_seq_Initialize (sony_demod_dvbs_s2_tune_srs_seq_t * pSeq,
|
||||
sony_demod_t * pDemod,
|
||||
uint32_t centerFreqKHz,
|
||||
sony_demod_dvbs_s2_tune_srs_freq_range_t freqRange);
|
||||
|
||||
/**
|
||||
@brief Execute one sequence for TuneSRS.
|
||||
|
||||
@param pSeq The sequence instance.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_tune_srs_seq_Sequence (sony_demod_dvbs_s2_tune_srs_seq_t * pSeq);
|
||||
|
||||
#endif /* SONY_DEMOD_DVBS_S2_TUNE_SRS_SEQ_H */
|
||||
+172
@@ -0,0 +1,172 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "sony_common.h"
|
||||
#include "sony_math.h"
|
||||
#include "sony_demod.h"
|
||||
#include "sony_demod_dvbs_s2.h"
|
||||
#include "sony_demod_dvbs_s2_monitor.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_utility.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_trace.h"
|
||||
#include "sony_demod_sat_device_ctrl_detect_cw_seq.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_pm.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Static Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
static int32_t calcPower(int32_t ifagcdb_x100, uint32_t power);
|
||||
static const uint32_t stepKHz = 500;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
sony_result_t sony_demod_sat_device_ctrl_detect_cw_seq_Initialize (sony_demod_sat_device_ctrl_detect_cw_seq_t * pSeq,
|
||||
sony_demod_t * pDemod,
|
||||
uint32_t freqKHz,
|
||||
uint32_t rangeKHz)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_INIT();
|
||||
SONY_TRACE_ENTER ("sony_demod_sat_device_ctrl_detect_cw_seq_Initialize");
|
||||
|
||||
if ((!pSeq) || (!pDemod)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
pSeq->isContinue = 1;
|
||||
pSeq->seqState = DETECT_CW_SEQ_STATE_START;
|
||||
pSeq->freqKHz = freqKHz;
|
||||
pSeq->rangeKHz = rangeKHz;
|
||||
pSeq->stepKHz = stepKHz;
|
||||
pSeq->currentOffsetFreqKHz = 0;
|
||||
pSeq->power = 0;
|
||||
|
||||
pSeq->commonParams.pDemod = pDemod;
|
||||
pSeq->commonParams.detInfo.isDetect = 0;
|
||||
pSeq->commonParams.tuneReq.isRequest = 0;
|
||||
pSeq->commonParams.agcInfo.isRequest = 0;
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
|
||||
pSeq->commonParams.ckalFreqKHz = 64000; /* CKAL */
|
||||
pSeq->commonParams.ckahFreqKHz = 96000; /* CKAH */
|
||||
|
||||
/* Initialize the data storage */
|
||||
result = sony_demod_dvbs_s2_blindscan_StorageInit (&(pSeq->commonParams.storage),
|
||||
pSeq->powerArray,
|
||||
sizeof(pSeq->powerArray)/sizeof(pSeq->powerArray[0]),
|
||||
pSeq->dataArray,
|
||||
sizeof(pSeq->dataArray)/sizeof(pSeq->dataArray[0]));
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN(result);
|
||||
}
|
||||
|
||||
/* Initialize demodulator to start BlindScan. */
|
||||
result = sony_demod_dvbs_s2_blindscan_Initialize(pSeq->commonParams.pDemod);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN(result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Initialize (&pSeq->subseqPM, &pSeq->commonParams);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN(result);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_sat_device_ctrl_detect_cw_seq_Sequence (sony_demod_sat_device_ctrl_detect_cw_seq_t * pSeq)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("sony_demod_sat_device_ctrl_detect_cw_seq_Sequence");
|
||||
|
||||
if (!pSeq){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if (pSeq->subseqPM.isEnable){
|
||||
/* PM seq */
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Sequence(&pSeq->subseqPM);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN(result);
|
||||
}
|
||||
} else {
|
||||
/* Main sequence */
|
||||
switch(pSeq->seqState)
|
||||
{
|
||||
case DETECT_CW_SEQ_STATE_START:
|
||||
pSeq->commonParams.tuneReq.isRequest = 1;
|
||||
pSeq->commonParams.tuneReq.frequencyKHz = pSeq->freqKHz;
|
||||
pSeq->commonParams.tuneReq.symbolRateKSps = 45000;
|
||||
pSeq->commonParams.tuneReq.system = SONY_DTV_SYSTEM_DVBS;
|
||||
pSeq->commonParams.waitTime = 50;
|
||||
pSeq->seqState = DETECT_CW_SEQ_STATE_AGC_ON;
|
||||
break;
|
||||
|
||||
case DETECT_CW_SEQ_STATE_AGC_ON:
|
||||
pSeq->commonParams.agcInfo.isRequest = 1;
|
||||
result = sony_demod_dvbs_s2_monitor_IFAGCOut(pSeq->commonParams.pDemod, &pSeq->commonParams.agcInfo.agcLevel);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
return result;
|
||||
}
|
||||
pSeq->seqState = DETECT_CW_SEQ_STATE2;
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
break;
|
||||
|
||||
case DETECT_CW_SEQ_STATE2:
|
||||
pSeq->offsetFreqKHz = (int32_t)pSeq->freqKHz - (int32_t)pSeq->commonParams.tuneReq.frequencyKHz;
|
||||
result = sony_demod_dvbs_s2_blindscan_CS_INIT(pSeq->commonParams.pDemod);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->currentOffsetFreqKHz = (-1) * pSeq->rangeKHz;
|
||||
pSeq->seqState = DETECT_CW_SEQ_STATE3;
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
break;
|
||||
|
||||
case DETECT_CW_SEQ_STATE3:
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (&pSeq->subseqPM, pSeq->offsetFreqKHz + pSeq->currentOffsetFreqKHz);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->seqState = DETECT_CW_SEQ_STATE4;
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
break;
|
||||
|
||||
case DETECT_CW_SEQ_STATE4:
|
||||
if(pSeq->power < (int32_t)pSeq->subseqPM.power){
|
||||
pSeq->power = (int32_t)pSeq->subseqPM.power;
|
||||
}
|
||||
pSeq->currentOffsetFreqKHz += (int32_t)pSeq->stepKHz;
|
||||
if(pSeq->currentOffsetFreqKHz < (int32_t)pSeq->rangeKHz){
|
||||
/* Next trial */
|
||||
pSeq->seqState = DETECT_CW_SEQ_STATE3;
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
} else {
|
||||
/* Reach to the end */
|
||||
pSeq->seqState = DETECT_CW_SEQ_STATE5;
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case DETECT_CW_SEQ_STATE5:
|
||||
pSeq->power = calcPower(pSeq->commonParams.agcInfo.agc_x100dB, (uint32_t)pSeq->power);
|
||||
pSeq->isContinue = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
static int32_t calcPower(int32_t ifagcdb_x100, uint32_t power)
|
||||
{
|
||||
return (int32_t)(((int32_t)sony_math_log10 (power) - 421) * 10) - ifagcdb_x100;
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_sat_device_ctrl_detect_cw_seq.h
|
||||
|
||||
This file provides definitions for DetectCW sequence function.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DEMOD_SAT_DEVICE_CTRL_DETECT_CW_SEQ_H
|
||||
#define SONY_DEMOD_SAT_DEVICE_CTRL_DETECT_CW_SEQ_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_utility.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_seq_common.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_pm.h"
|
||||
|
||||
/**
|
||||
@brief state of DetectCW sequence
|
||||
*/
|
||||
typedef enum {
|
||||
DETECT_CW_SEQ_STATE_START, /**< Start */
|
||||
DETECT_CW_SEQ_STATE_AGC_ON,
|
||||
DETECT_CW_SEQ_STATE2,
|
||||
DETECT_CW_SEQ_STATE3,
|
||||
DETECT_CW_SEQ_STATE4,
|
||||
DETECT_CW_SEQ_STATE5,
|
||||
DETECT_CW_STATE_UNKNOWN /**< Unknown */
|
||||
} sony_demod_sat_device_ctrl_detect_cw_seq_state_t;
|
||||
|
||||
/**
|
||||
@brief Structure for DetectCW sequence.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
@brief Common parameters used by each sub sequence
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t commonParams;
|
||||
|
||||
/**
|
||||
@brief Finish/Continue flag.
|
||||
|
||||
- 0: Finish the sequence.
|
||||
- 1: Continue the sequence.
|
||||
*/
|
||||
uint8_t isContinue;
|
||||
|
||||
sony_demod_sat_device_ctrl_detect_cw_seq_state_t seqState; /**< State of DetectCW sequence. */
|
||||
sony_demod_dvbs_s2_blindscan_subseq_pm_t subseqPM; /**< Data for sub sequence PM. */
|
||||
|
||||
uint32_t freqKHz; /**< Target frequency in KHz */
|
||||
uint32_t rangeKHz; /**< Range frequency in KHz */
|
||||
uint32_t stepKHz; /**< Step frequency in KHz */
|
||||
uint8_t isDetected; /**< The result of this API. */
|
||||
int32_t offsetFreqKHz; /**< Offset frequency in KHz. */
|
||||
int32_t currentOffsetFreqKHz; /**< Current offset frequency in KHz. */
|
||||
int32_t power; /**< Power */
|
||||
|
||||
/**
|
||||
@brief Power data for storage.
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_power_t powerArray[1];
|
||||
|
||||
/**
|
||||
@brief Data for storage.
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_data_t dataArray[1];
|
||||
|
||||
} sony_demod_sat_device_ctrl_detect_cw_seq_t;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Prepare to start DetectCW sequence.
|
||||
|
||||
@param pSeq The sequence instance.
|
||||
@param pDemod Demodulator instance.
|
||||
@param freqKHz Target frequency in KHz.
|
||||
@param rangeKHz The range for search in KHz. (500, 1000, ...)
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_sat_device_ctrl_detect_cw_seq_Initialize (sony_demod_sat_device_ctrl_detect_cw_seq_t * pSeq,
|
||||
sony_demod_t * pDemod,
|
||||
uint32_t freqKHz,
|
||||
uint32_t rangeKHz);
|
||||
|
||||
/**
|
||||
@brief Execute one sequence for DetectCW.
|
||||
|
||||
@param pSeq The sequence instance.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_sat_device_ctrl_detect_cw_seq_Sequence (sony_demod_sat_device_ctrl_detect_cw_seq_t * pSeq);
|
||||
|
||||
#endif /* SONY_DEMOD_SAT_DEVICE_CTRL_DETECT_CW_SEQ_H */
|
||||
+368
@@ -0,0 +1,368 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "sony_common.h"
|
||||
#include "sony_math.h"
|
||||
#include "sony_demod.h"
|
||||
#include "sony_demod_dvbs_s2.h"
|
||||
#include "sony_demod_dvbs_s2_monitor.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_ss.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_pm.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_utility.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_trace.h"
|
||||
#include "sony_demod_sat_device_ctrl_find1ub_seq.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Static Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
static int32_t calcPower(int32_t ifagcdb_x100, uint32_t power);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
sony_result_t sony_demod_sat_device_ctrl_find1ub_seq_Initialize (sony_demod_sat_device_ctrl_find1ub_seq_t * pSeq,
|
||||
sony_demod_t * pDemod,
|
||||
uint32_t minFreqKHz,
|
||||
uint32_t maxFreqKHz,
|
||||
uint8_t targetUB)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_INIT();
|
||||
SONY_TRACE_ENTER ("sony_demod_sat_device_ctrl_find1ub_seq_Initialize");
|
||||
|
||||
if ((!pSeq) || (!pDemod)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
pSeq->isContinue = 1;
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_START;
|
||||
pSeq->minFreqKHz = minFreqKHz;
|
||||
pSeq->maxFreqKHz = maxFreqKHz;
|
||||
pSeq->minPowerFreqKHz = minFreqKHz - 5000;
|
||||
pSeq->maxPowerFreqKHz = maxFreqKHz + 5000;
|
||||
pSeq->targetUB = targetUB;
|
||||
pSeq->commandReq = 0;
|
||||
|
||||
pSeq->commonParams.pDemod = pDemod;
|
||||
pSeq->commonParams.detInfo.isDetect = 0;
|
||||
pSeq->commonParams.tuneReq.isRequest = 0;
|
||||
pSeq->commonParams.agcInfo.isRequest = 0;
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
|
||||
pSeq->commonParams.ckalFreqKHz = 64000; /* CKAL */
|
||||
pSeq->commonParams.ckahFreqKHz = 96000; /* CKAH */
|
||||
|
||||
/* Initialize the data storage */
|
||||
result = sony_demod_dvbs_s2_blindscan_StorageInit (&(pSeq->commonParams.storage),
|
||||
pSeq->powerArray,
|
||||
sizeof(pSeq->powerArray)/sizeof(pSeq->powerArray[0]),
|
||||
pSeq->dataArray,
|
||||
sizeof(pSeq->dataArray)/sizeof(pSeq->dataArray[0]));
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN(result);
|
||||
}
|
||||
|
||||
/* Initialize demodulator to start BlindScan. */
|
||||
result = sony_demod_dvbs_s2_blindscan_Initialize(pSeq->commonParams.pDemod);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN(result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Initialize (&pSeq->subseqPM, &pSeq->commonParams);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN(result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_ss_Initialize (&pSeq->subseqSS, &pSeq->commonParams);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN(result);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_sat_device_ctrl_find1ub_seq_Sequence (sony_demod_sat_device_ctrl_find1ub_seq_t * pSeq)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
sony_demod_dvbs_s2_blindscan_power_t * pPower;
|
||||
SONY_TRACE_ENTER ("sony_demod_sat_device_ctrl_find1ub_seq_Sequence");
|
||||
|
||||
if (!pSeq){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if (pSeq->subseqSS.isEnable){
|
||||
/* SS seq */
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_ss_Sequence (&pSeq->subseqSS);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN(result);
|
||||
}
|
||||
} else if (pSeq->subseqPM.isEnable){
|
||||
/* PM seq */
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Sequence(&pSeq->subseqPM);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN(result);
|
||||
}
|
||||
} else {
|
||||
/* Main sequence */
|
||||
switch(pSeq->seqState)
|
||||
{
|
||||
case FIND1UB_SEQ_STATE_START:
|
||||
/* ODU_UbxSignal_ON */
|
||||
result = sony_singlecable_command_ODU_UbxSignal_ON (&pSeq->message, SONY_SINGLECABLE_ADDRESS_ALL_DEVICES);
|
||||
if (result != SONY_RESULT_OK) {return result;}
|
||||
pSeq->commandReq = 1;
|
||||
pSeq->commonParams.waitTime = SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_ODU_TX_WAIT;
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_SS_START;
|
||||
break;
|
||||
|
||||
case FIND1UB_SEQ_STATE_SS_START:
|
||||
/* Get power spectrum */
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_ss_Start(&pSeq->subseqSS,
|
||||
pSeq->minPowerFreqKHz,
|
||||
pSeq->maxPowerFreqKHz,
|
||||
500,
|
||||
20000,
|
||||
1);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN(result);
|
||||
}
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_SS_FIN;
|
||||
break;
|
||||
|
||||
case FIND1UB_SEQ_STATE_SS_FIN:
|
||||
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_POWERLIST("Power", pSeq->subseqSS.pPowerList);
|
||||
pPower = pSeq->subseqSS.pPowerList->pNext;
|
||||
pSeq->pmax_fn = 0;
|
||||
while(pPower){
|
||||
if(pPower->freqKHz > 0){
|
||||
/* Valid data */
|
||||
if((pSeq->pmax_fn == 0) || (pSeq->pmax_p1 < pPower->power)){
|
||||
pSeq->pmax_fn = pPower->freqKHz;
|
||||
pSeq->pmax_p1 = pPower->power;
|
||||
}
|
||||
}
|
||||
pPower = pPower->pNext;
|
||||
}
|
||||
pSeq->loopCount = 0;
|
||||
/* Fall through */
|
||||
case FIND1UB_SEQ_STATE_TRIAL1:
|
||||
pPower = pSeq->subseqSS.pPowerList->pNext;
|
||||
pSeq->pmax_fn = 0;
|
||||
pSeq->pmax_pn = 0;
|
||||
while(pPower){
|
||||
if(pPower->freqKHz > 0){
|
||||
/* Valid data */
|
||||
if((pSeq->pmax_fn == 0) || (pSeq->pmax_pn < pPower->power)){
|
||||
pSeq->pmax_fn = pPower->freqKHz;
|
||||
pSeq->pmax_pn = pPower->power;
|
||||
}
|
||||
}
|
||||
pPower = pPower->pNext;
|
||||
}
|
||||
/* ODU_UbxSignal_ON */
|
||||
result = sony_singlecable_command_ODU_UbxSignal_ON (&pSeq->message, SONY_SINGLECABLE_ADDRESS_ALL_DEVICES);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
return result;
|
||||
}
|
||||
pSeq->commandReq = 1;
|
||||
pSeq->commonParams.waitTime = SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_ODU_TX_WAIT;
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_TUNING_ON;
|
||||
break;
|
||||
|
||||
case FIND1UB_SEQ_STATE_TUNING_ON:
|
||||
pSeq->commonParams.tuneReq.isRequest = 1;
|
||||
pSeq->commonParams.tuneReq.frequencyKHz = pSeq->pmax_fn;
|
||||
pSeq->commonParams.tuneReq.symbolRateKSps = 45000;
|
||||
pSeq->commonParams.tuneReq.system = SONY_DTV_SYSTEM_DVBS;
|
||||
pSeq->commonParams.waitTime = 50;
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_AGC_ON;
|
||||
break;
|
||||
|
||||
case FIND1UB_SEQ_STATE_AGC_ON:
|
||||
pSeq->commonParams.agcInfo.isRequest = 1;
|
||||
result = sony_demod_dvbs_s2_monitor_IFAGCOut(pSeq->commonParams.pDemod, &pSeq->commonParams.agcInfo.agcLevel);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
return result;
|
||||
}
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_TRIAL2;
|
||||
break;
|
||||
|
||||
case FIND1UB_SEQ_STATE_TRIAL2:
|
||||
pSeq->offsetKHz = pSeq->pmax_fn - pSeq->commonParams.tuneReq.frequencyKHz;
|
||||
if((pSeq->offsetKHz < -2000) || (pSeq->offsetKHz > 2000)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
result = sony_demod_dvbs_s2_blindscan_CS_INIT(pSeq->commonParams.pDemod);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (&pSeq->subseqPM, pSeq->offsetKHz);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_TRIAL3;
|
||||
break;
|
||||
|
||||
case FIND1UB_SEQ_STATE_TRIAL3:
|
||||
pSeq->powerOn = pSeq->subseqPM.power;
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (&pSeq->subseqPM, pSeq->offsetKHz - 500);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_TRIAL4;
|
||||
break;
|
||||
|
||||
case FIND1UB_SEQ_STATE_TRIAL4:
|
||||
if(pSeq->powerOn < pSeq->subseqPM.power){
|
||||
pSeq->powerOn = pSeq->subseqPM.power;
|
||||
}
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (&pSeq->subseqPM, pSeq->offsetKHz + 500);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_TRIAL5;
|
||||
break;
|
||||
|
||||
case FIND1UB_SEQ_STATE_TRIAL5:
|
||||
if(pSeq->powerOn < pSeq->subseqPM.power){
|
||||
pSeq->powerOn = pSeq->subseqPM.power;
|
||||
}
|
||||
pSeq->powerOn = calcPower(pSeq->commonParams.agcInfo.agc_x100dB, (uint32_t)pSeq->powerOn);
|
||||
result = sony_singlecable_command_ODU_PowerOFF (&pSeq->message, SONY_SINGLECABLE_ADDRESS_ALL_DEVICES, pSeq->targetUB);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->commandReq = 1;
|
||||
pSeq->commonParams.waitTime = SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_ODU_TX_WAIT;
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_TUNING_OFF;
|
||||
break;
|
||||
|
||||
case FIND1UB_SEQ_STATE_TUNING_OFF:
|
||||
pSeq->commonParams.tuneReq.isRequest = 1;
|
||||
pSeq->commonParams.tuneReq.frequencyKHz = pSeq->pmax_fn;
|
||||
pSeq->commonParams.tuneReq.symbolRateKSps = 45000;
|
||||
pSeq->commonParams.tuneReq.system = SONY_DTV_SYSTEM_DVBS;
|
||||
pSeq->commonParams.waitTime = 50;
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_AGC_OFF;
|
||||
break;
|
||||
|
||||
case FIND1UB_SEQ_STATE_AGC_OFF:
|
||||
pSeq->commonParams.agcInfo.isRequest = 1;
|
||||
result = sony_demod_dvbs_s2_monitor_IFAGCOut(pSeq->commonParams.pDemod, &pSeq->commonParams.agcInfo.agcLevel);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
return result;
|
||||
}
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_TRIAL6;
|
||||
break;
|
||||
|
||||
case FIND1UB_SEQ_STATE_TRIAL6:
|
||||
pSeq->offsetKHz = pSeq->pmax_fn - pSeq->commonParams.tuneReq.frequencyKHz;
|
||||
if((pSeq->offsetKHz < -2000) || (pSeq->offsetKHz > 2000)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (&pSeq->subseqPM, pSeq->offsetKHz);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_TRIAL7;
|
||||
break;
|
||||
|
||||
case FIND1UB_SEQ_STATE_TRIAL7:
|
||||
pSeq->powerOff = pSeq->subseqPM.power;
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (&pSeq->subseqPM, pSeq->offsetKHz - 500);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_TRIAL8;
|
||||
break;
|
||||
|
||||
case FIND1UB_SEQ_STATE_TRIAL8:
|
||||
if(pSeq->powerOff < pSeq->subseqPM.power){
|
||||
pSeq->powerOff = pSeq->subseqPM.power;
|
||||
}
|
||||
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (&pSeq->subseqPM, pSeq->offsetKHz + 500);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_TRIAL9;
|
||||
break;
|
||||
|
||||
case FIND1UB_SEQ_STATE_TRIAL9:
|
||||
if(pSeq->powerOff < pSeq->subseqPM.power){
|
||||
pSeq->powerOff = pSeq->subseqPM.power;
|
||||
}
|
||||
pSeq->powerOff = calcPower(pSeq->commonParams.agcInfo.agc_x100dB, (uint32_t)pSeq->powerOff);
|
||||
if((pSeq->powerOn - pSeq->powerOff) > 1000){
|
||||
/* Detect user band frequency */
|
||||
pSeq->ubFreqKHz = pSeq->pmax_fn;
|
||||
|
||||
/* Go to Finish State. */
|
||||
pSeq->ubNumber = 1;
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_FINISH;
|
||||
} else {
|
||||
/* Remove the data in +/- 2MHz area as spurious signal. */
|
||||
pPower = pSeq->subseqSS.pPowerList->pNext;
|
||||
while(pPower){
|
||||
if((pPower->freqKHz > 0) && ((pSeq->pmax_fn - 2000) < (pPower->freqKHz)) && ((pPower->freqKHz) < (pSeq->pmax_fn + 2000))){
|
||||
pPower->freqKHz = 0;
|
||||
}
|
||||
pPower = pPower->pNext;
|
||||
}
|
||||
/* Continue check */
|
||||
if((pSeq->pmax_p1 - pSeq->pmax_pn) > 3000){
|
||||
pSeq->ubFreqKHz = 0;
|
||||
|
||||
/* Go to Finish State. */
|
||||
pSeq->ubNumber = 1;
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_FINISH;
|
||||
} else if(pSeq->loopCount++ > 30){
|
||||
pSeq->ubFreqKHz = 0;
|
||||
|
||||
/* Go to Finish State. */
|
||||
pSeq->ubNumber = 1;
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_FINISH;
|
||||
} else {
|
||||
/* Go to next trial */
|
||||
pSeq->seqState = FIND1UB_SEQ_STATE_TRIAL1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case FIND1UB_SEQ_STATE_FINISH:
|
||||
/* Turning OFF the Power of all User bands as they were turned ON during start of algorithm. */
|
||||
|
||||
result = sony_singlecable_command_ODU_PowerOFF (&pSeq->message,
|
||||
SONY_SINGLECABLE_ADDRESS_ALL_DEVICES,
|
||||
pSeq->ubNumber);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->commandReq = 1;
|
||||
|
||||
if (pSeq->ubNumber == 8) {
|
||||
/* Last user band so exit this algorithm too. */
|
||||
pSeq->isContinue = 0;
|
||||
}
|
||||
/* Increment to Turn OFF the next userband in next cycle. */
|
||||
pSeq->ubNumber ++;
|
||||
break;
|
||||
|
||||
default:
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
static int32_t calcPower(int32_t ifagcdb_x100, uint32_t power)
|
||||
{
|
||||
return (int32_t)(((int32_t)sony_math_log10 (power) - 421) * 10) - ifagcdb_x100;
|
||||
}
|
||||
+169
@@ -0,0 +1,169 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_sat_device_ctrl_find1ub_seq.h
|
||||
|
||||
This file provides definitions for Find1UB sequence function.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_SEQ_H
|
||||
#define SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_SEQ_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod.h"
|
||||
#include "sony_singlecable_command.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_data.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_utility.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_seq_common.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_pm.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_subseq_ss.h"
|
||||
|
||||
/**
|
||||
@brief Definition of search range in MHz.
|
||||
|
||||
This value is affected to the array size in Find1UB sequence.
|
||||
Please set the value depend on users application.
|
||||
|
||||
Default value is 1220(MHz).
|
||||
It is 940MHz - 2160MHz. ( with some margin )
|
||||
*/
|
||||
#define SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_SEARCH_RANGE_MHZ 1220
|
||||
|
||||
/**
|
||||
@brief Definition of array size used in this driver.
|
||||
|
||||
The data size is depend on the input signal as follow.
|
||||
- Search range.
|
||||
- Power spectrum.
|
||||
- etc...
|
||||
|
||||
User can get the maximum used data size by sony_demod_dvbs_s2_blindscan_data_storage_t::maxUsedCount.
|
||||
If the driver returns SONY_RESULT_ERROR_OVERFLOW, please increase this value.
|
||||
*/
|
||||
//#define SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_DATA_MAX 10000
|
||||
|
||||
/**
|
||||
@brief Definition of array size used in this driver.
|
||||
|
||||
This value is calculated by SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_SEARCH_RANGE_MHZ.
|
||||
So user doesn't need to change this value directly.
|
||||
*/
|
||||
#define SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_POWER_MAX ((SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_SEARCH_RANGE_MHZ + 45) * 2)
|
||||
|
||||
/**
|
||||
@brief Wait time in ms after sending ODU Single Cable commands.
|
||||
|
||||
This value depends on your Single Cable Switch.
|
||||
Please confirm it with your environment and change it accordingly.
|
||||
*/
|
||||
#define SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_ODU_TX_WAIT 300
|
||||
|
||||
/**
|
||||
@brief state of Find1UB sequence
|
||||
*/
|
||||
typedef enum {
|
||||
FIND1UB_SEQ_STATE_START, /**< Start */
|
||||
FIND1UB_SEQ_STATE_SS_START, /**< SS start */
|
||||
FIND1UB_SEQ_STATE_SS_FIN, /**< SS fin */
|
||||
FIND1UB_SEQ_STATE_TRIAL1, /**< Trial1 */
|
||||
FIND1UB_SEQ_STATE_TRIAL2, /**< Trial2 */
|
||||
FIND1UB_SEQ_STATE_TRIAL3, /**< Trial3 */
|
||||
FIND1UB_SEQ_STATE_TRIAL4, /**< Trial4 */
|
||||
FIND1UB_SEQ_STATE_TRIAL5, /**< Trial5 */
|
||||
FIND1UB_SEQ_STATE_TRIAL6, /**< Trial6 */
|
||||
FIND1UB_SEQ_STATE_TRIAL7, /**< Trial7 */
|
||||
FIND1UB_SEQ_STATE_TRIAL8, /**< Trial8 */
|
||||
FIND1UB_SEQ_STATE_TRIAL9, /**< Trial9 */
|
||||
FIND1UB_SEQ_STATE_FINISH, /**< Finish */
|
||||
FIND1UB_SEQ_STATE_TUNING_ON, /**< Tuning at UB on */
|
||||
FIND1UB_SEQ_STATE_TUNING_OFF, /**< Tuning at UB off */
|
||||
FIND1UB_SEQ_STATE_AGC_ON, /**< Getting AGC at UB on */
|
||||
FIND1UB_SEQ_STATE_AGC_OFF, /**< Getting AGC at UB off */
|
||||
FIND1UB_SEQ_STATE_UNKNOWN /**< Unknown */
|
||||
} sony_demod_sat_device_ctrl_find1ub_seq_state_t;
|
||||
|
||||
/**
|
||||
@brief Structure for find1ub sequence.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
@brief Common parameters used by each sub sequence
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_seq_common_t commonParams;
|
||||
|
||||
/**
|
||||
@brief Finish/Continue flag.
|
||||
|
||||
- 0: Finish the sequence.
|
||||
- 1: Continue the sequence.
|
||||
*/
|
||||
uint8_t isContinue;
|
||||
|
||||
sony_demod_sat_device_ctrl_find1ub_seq_state_t seqState; /**< State of Find1UB sequence. */
|
||||
sony_demod_dvbs_s2_blindscan_subseq_pm_t subseqPM; /**< Data for sub sequence PM. */
|
||||
sony_demod_dvbs_s2_blindscan_subseq_ss_t subseqSS; /**< Data for sub sequence SS. */
|
||||
|
||||
uint32_t minFreqKHz; /**< Min frequency in KHz which set by Find1UB API */
|
||||
uint32_t maxFreqKHz; /**< Max frequency in KHz which set by Find1UB API */
|
||||
|
||||
uint32_t minPowerFreqKHz; /**< Min frequency in KHz which need for power spectrum */
|
||||
uint32_t maxPowerFreqKHz; /**< Max frequency in KHz which need for power spectrum */
|
||||
|
||||
uint8_t commandReq; /**< Request to transmit command */
|
||||
sony_diseqc_message_t message; /**< Single cable command data */
|
||||
uint8_t targetUB; /**< Target user band to detect */
|
||||
uint32_t ubFreqKHz; /**< Frequency of target UB. If this is 0 at isContinue = 0, driver can't detect target UB. */
|
||||
int32_t pmax_p1; /**< Max power at the 1st trial */
|
||||
uint32_t pmax_fn; /**< Frequency of max power at Nth trial */
|
||||
int32_t pmax_pn; /**< Max power at the Nth trial */
|
||||
int32_t loopCount; /**< Loop count in the trial sequence */
|
||||
int32_t powerOn; /**< Power at UB on */
|
||||
int32_t powerOff; /**< Power at UB off */
|
||||
int32_t offsetKHz; /**< Offset frequency between "pmax_fn" and "tuned frequency" */
|
||||
uint8_t ubNumber; /**< UB Number. */
|
||||
|
||||
/**
|
||||
@brief Power data for storage.
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_power_t powerArray[SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_POWER_MAX];
|
||||
/**
|
||||
@brief Data for storage.
|
||||
*/
|
||||
sony_demod_dvbs_s2_blindscan_data_t dataArray[1];
|
||||
|
||||
} sony_demod_sat_device_ctrl_find1ub_seq_t;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Prepare to start Find1UB sequence.
|
||||
|
||||
@param pSeq The sequence instance.
|
||||
@param pDemod Demodulator instance.
|
||||
@param minFreqKHz Minimum frequency of the scan range in KHz.
|
||||
@param maxFreqKHz Maximum frequency of the scan range in KHz.
|
||||
@param targetUB Target user band which user want to find. (1-8)
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_sat_device_ctrl_find1ub_seq_Initialize (sony_demod_sat_device_ctrl_find1ub_seq_t * pSeq,
|
||||
sony_demod_t * pDemod,
|
||||
uint32_t minFreqKHz,
|
||||
uint32_t maxFreqKHz,
|
||||
uint8_t targetUB);
|
||||
|
||||
/**
|
||||
@brief Execute one sequence for Find1UB.
|
||||
|
||||
@param pSeq The sequence instance.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_sat_device_ctrl_find1ub_seq_Sequence (sony_demod_sat_device_ctrl_find1ub_seq_t * pSeq);
|
||||
|
||||
#endif /* SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_SEQ_H */
|
||||
@@ -0,0 +1,348 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2017-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/09/28
|
||||
Modification ID : 1ea04def104d657deb64f0d0b0cae6ef992a9dd8
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod.h"
|
||||
#include "sony_integ_dvbs_s2_blindscan.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_seq.h"
|
||||
#include "sony_demod_dvbs_s2_tune_srs_seq.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
sony_result_t sony_integ_dvbs_s2_TuneSRS (sony_integ_t * pInteg,
|
||||
sony_demod_dvbs_s2_tune_srs_seq_t * pSeq,
|
||||
sony_integ_dvbs_s2_tune_srs_param_t * pParam,
|
||||
sony_dvbs_s2_tune_param_t * pTuneParam)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
uint32_t elapsedTime = 0;
|
||||
sony_stopwatch_t stopwatch;
|
||||
SONY_TRACE_ENTER ("sony_integ_dvbs_s2_TuneSRS");
|
||||
|
||||
if ((!pInteg) || (!pInteg->pDemod) || (!pSeq) || (!pParam) || (!pTuneParam) ||
|
||||
(!pInteg->pTuner) || (!pInteg->pTuner->CalcRFLevelFromAGC) ||
|
||||
(!pInteg->pTuner->SatTune)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if ((pInteg->pDemod->state != SONY_DEMOD_STATE_SLEEP) &&
|
||||
(pInteg->pDemod->state != SONY_DEMOD_STATE_ACTIVE)){
|
||||
/* This api is accepted in Sleep and Active states only */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_tune_srs_seq_Initialize (pSeq,
|
||||
pInteg->pDemod,
|
||||
pParam->centerFreqKHz,
|
||||
pParam->freqRange);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
while(pSeq->isContinue){
|
||||
/* Check cancellation. */
|
||||
result = sony_integ_CheckCancellation (pInteg);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (pSeq->commonParams.waitTime == 0){
|
||||
/* Execute one sequence */
|
||||
result = sony_demod_dvbs_s2_tune_srs_seq_Sequence (pSeq);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Start stopwatch */
|
||||
result= sony_stopwatch_start (&stopwatch);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* AGC calculate is requested */
|
||||
if (pSeq->commonParams.agcInfo.isRequest){
|
||||
int32_t rfLevel;
|
||||
|
||||
/* Clear request flag. */
|
||||
pSeq->commonParams.agcInfo.isRequest = 0;
|
||||
|
||||
result = pInteg->pTuner->CalcRFLevelFromAGC (pInteg->pTuner,
|
||||
pSeq->commonParams.agcInfo.agcLevel,
|
||||
&rfLevel);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
pSeq->commonParams.agcInfo.agc_x100dB = -rfLevel; /* Gain value should be set. */
|
||||
}
|
||||
|
||||
/* Tune is requested */
|
||||
if (pSeq->commonParams.tuneReq.isRequest){
|
||||
uint32_t symbolRateKSps = pSeq->commonParams.tuneReq.symbolRateKSps;
|
||||
|
||||
/* Clear request flag. */
|
||||
pSeq->commonParams.tuneReq.isRequest = 0;
|
||||
|
||||
/* Symbol rate */
|
||||
if (symbolRateKSps == 0) {
|
||||
/* Symbol rate setting for power spectrum */
|
||||
symbolRateKSps = pInteg->pTuner->symbolRateKSpsForSpectrum;
|
||||
}
|
||||
|
||||
/* Enable the I2C repeater */
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x01);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
/* RF Tune */
|
||||
result = pInteg->pTuner->SatTune (pInteg->pTuner,
|
||||
pSeq->commonParams.tuneReq.frequencyKHz,
|
||||
pSeq->commonParams.tuneReq.system,
|
||||
symbolRateKSps);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
/* Set actual frequency to the driver. */
|
||||
pSeq->commonParams.tuneReq.frequencyKHz = pInteg->pTuner->frequencyKHz;
|
||||
/* Disable the I2C repeater */
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x00);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* waiting */
|
||||
result = sony_stopwatch_sleep (&stopwatch, SONY_INTEG_DVBS_S2_TUNE_SRS_POLLING_INTERVAL);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_stopwatch_elapsed (&stopwatch, &elapsedTime);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if(elapsedTime > pSeq->commonParams.waitTime){
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pSeq->isDetect){
|
||||
/* Tune successful. */
|
||||
pTuneParam->centerFreqKHz = pSeq->tuneParam.centerFreqKHz;
|
||||
pTuneParam->symbolRateKSps = pSeq->tuneParam.symbolRateKSps;
|
||||
pTuneParam->system = pSeq->tuneParam.system;
|
||||
|
||||
/* TS output enable */
|
||||
result = sony_demod_SetStreamOutput (pInteg->pDemod, 1);
|
||||
} else {
|
||||
result = SONY_RESULT_ERROR_UNLOCK;
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_integ_dvbs_s2_BlindScan (sony_integ_t * pInteg,
|
||||
sony_demod_dvbs_s2_blindscan_seq_t * pSeq,
|
||||
sony_integ_dvbs_s2_blindscan_param_t * pParam,
|
||||
sony_integ_dvbs_s2_blindscan_callback_t callback)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
uint32_t elapsedTime = 0;
|
||||
sony_stopwatch_t stopwatch;
|
||||
sony_integ_dvbs_s2_blindscan_result_t blindscanResult;
|
||||
|
||||
SONY_TRACE_ENTER("sony_integ_dvbs_s2_BlindScan");
|
||||
|
||||
if ((!pInteg) || (!pInteg->pDemod) || (!pSeq) || (!pParam) || (!callback) ||
|
||||
(!pInteg->pTuner) || (!pInteg->pTuner->CalcRFLevelFromAGC) ||
|
||||
(!pInteg->pTuner->SatTune) || (!pInteg->pTuner->Sleep)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if ((pInteg->pDemod->state != SONY_DEMOD_STATE_SLEEP) &&
|
||||
(pInteg->pDemod->state != SONY_DEMOD_STATE_ACTIVE)){
|
||||
/* This api is accepted in Sleep and Active states only */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_blindscan_seq_Initialize (pSeq,
|
||||
pInteg->pDemod,
|
||||
pParam->minFreqKHz,
|
||||
pParam->maxFreqKHz,
|
||||
pParam->minSymbolRateKSps,
|
||||
pParam->maxSymbolRateKSps);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
while(pSeq->isContinue){
|
||||
/* Check cancellation. */
|
||||
result = sony_integ_CheckCancellation (pInteg);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (pSeq->commonParams.waitTime == 0){
|
||||
/* Execute one sequence */
|
||||
#ifdef SONY_DEMOD_SUPPORT_DVBS_S2_BLINDSCAN_VER2
|
||||
if(pSeq->commonParams.pDemod->dvbss2BlindScanVersion == SONY_DEMOD_DVBSS2_BLINDSCAN_VERSION2) {
|
||||
result = sony_demod_dvbs_s2_blindscan_version2_seq_Sequence (pSeq);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
result = sony_demod_dvbs_s2_blindscan_seq_Sequence (pSeq);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
|
||||
/* Start stopwatch */
|
||||
result = sony_stopwatch_start (&stopwatch);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (pSeq->commonParams.agcInfo.isRequest){
|
||||
int32_t rfLevel;
|
||||
|
||||
/* Clear request flag. */
|
||||
pSeq->commonParams.agcInfo.isRequest = 0;
|
||||
|
||||
result = pInteg->pTuner->CalcRFLevelFromAGC (pInteg->pTuner,
|
||||
pSeq->commonParams.agcInfo.agcLevel,
|
||||
&rfLevel);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
pSeq->commonParams.agcInfo.agc_x100dB = -rfLevel; /* Gain value should be set. */
|
||||
}
|
||||
|
||||
if (pSeq->commonParams.tuneReq.isRequest){
|
||||
uint32_t symbolRateKSps = pSeq->commonParams.tuneReq.symbolRateKSps;
|
||||
|
||||
/* Clear request flag. */
|
||||
pSeq->commonParams.tuneReq.isRequest = 0;
|
||||
|
||||
/* Symbol rate */
|
||||
if (symbolRateKSps == 0) {
|
||||
/* Symbol rate setting for power spectrum */
|
||||
symbolRateKSps = pInteg->pTuner->symbolRateKSpsForSpectrum;
|
||||
}
|
||||
|
||||
/* Enable the I2C repeater */
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x01);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
/* RF Tune */
|
||||
result = pInteg->pTuner->SatTune (pInteg->pTuner,
|
||||
pSeq->commonParams.tuneReq.frequencyKHz,
|
||||
pSeq->commonParams.tuneReq.system,
|
||||
symbolRateKSps);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
pSeq->commonParams.tuneReq.frequencyKHz = pInteg->pTuner->frequencyKHz;
|
||||
/* Disable the I2C repeater */
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x00);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
|
||||
if (pSeq->commonParams.detInfo.isDetect){
|
||||
|
||||
/* Clear detect flag */
|
||||
pSeq->commonParams.detInfo.isDetect = 0;
|
||||
|
||||
/* Prepare callback information.(Detected channel) */
|
||||
blindscanResult.eventId = SONY_INTEG_DVBS_S2_BLINDSCAN_EVENT_DETECT;
|
||||
blindscanResult.tuneParam.system = pSeq->commonParams.detInfo.system;
|
||||
blindscanResult.tuneParam.centerFreqKHz = pSeq->commonParams.detInfo.centerFreqKHz;
|
||||
blindscanResult.tuneParam.symbolRateKSps = pSeq->commonParams.detInfo.symbolRateKSps;
|
||||
|
||||
/* TS output enable */
|
||||
result = sony_demod_SetStreamOutput (pInteg->pDemod, 1);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Callback */
|
||||
callback(pInteg, &blindscanResult);
|
||||
|
||||
/* TS output disable */
|
||||
result = sony_demod_SetStreamOutput (pInteg->pDemod, 0);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
/* Progress calculation */
|
||||
uint8_t progress = 0;
|
||||
uint8_t rangeMin = pSeq->commonParams.progressInfo.majorMinProgress;
|
||||
uint8_t rangeMax = pSeq->commonParams.progressInfo.majorMaxProgress;
|
||||
uint8_t minorProgress = pSeq->commonParams.progressInfo.minorProgress;
|
||||
progress = rangeMin + (((rangeMax - rangeMin) * minorProgress) / 100);
|
||||
|
||||
if (pSeq->commonParams.progressInfo.progress < progress){
|
||||
pSeq->commonParams.progressInfo.progress = progress;
|
||||
/* Prepare callback information.(Progress) */
|
||||
blindscanResult.eventId = SONY_INTEG_DVBS_S2_BLINDSCAN_EVENT_PROGRESS;
|
||||
blindscanResult.progress = progress;
|
||||
/* Callback */
|
||||
callback(pInteg, &blindscanResult);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
/* waiting */
|
||||
result = sony_stopwatch_sleep (&stopwatch, SONY_INTEG_DVBS_S2_BLINDSCAN_POLLING_INTERVAL);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_stopwatch_elapsed (&stopwatch, &elapsedTime);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if(elapsedTime > pSeq->commonParams.waitTime){
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x01);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = pInteg->pTuner->Sleep(pInteg->pTuner);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x00);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_Sleep (pSeq->commonParams.pDemod);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN(result);
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2017-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/09/28
|
||||
Modification ID : 1ea04def104d657deb64f0d0b0cae6ef992a9dd8
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_integ_dvbs_s2_blindscan.h
|
||||
|
||||
This file provides the integration layer interface for DVB-S/S2 blindscan
|
||||
related functions.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_INTEG_DVBS_S2_BLINDSCAN_H
|
||||
#define SONY_INTEG_DVBS_S2_BLINDSCAN_H
|
||||
|
||||
#include "sony_integ.h"
|
||||
#include "sony_demod_dvbs_s2.h"
|
||||
#include "sony_demod_dvbs_s2_blindscan_seq.h"
|
||||
#include "sony_demod_dvbs_s2_tune_srs.h"
|
||||
#include "sony_demod_dvbs_s2_tune_srs_seq.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Defines
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Polling interval for BlindScan sequence in ms.
|
||||
*/
|
||||
#define SONY_INTEG_DVBS_S2_BLINDSCAN_POLLING_INTERVAL 10
|
||||
|
||||
/**
|
||||
@brief Polling interval for TuneSRS sequence in ms.
|
||||
*/
|
||||
#define SONY_INTEG_DVBS_S2_TUNE_SRS_POLLING_INTERVAL 10
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Enums
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Definition of event id for callback from BlindScan.
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_INTEG_DVBS_S2_BLINDSCAN_EVENT_DETECT, /**< Detect channel. */
|
||||
SONY_INTEG_DVBS_S2_BLINDSCAN_EVENT_PROGRESS /**< Update progress. */
|
||||
} sony_integ_dvbs_s2_blindscan_event_id_t;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Structs
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief The TuneSRS functions parameters for a DVB-S/S2 signal.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
@brief Center frequency in KHz of the DVB-S/S2 channel.
|
||||
*/
|
||||
uint32_t centerFreqKHz;
|
||||
/**
|
||||
@brief Frequency range found by TuneSRS.
|
||||
*/
|
||||
sony_demod_dvbs_s2_tune_srs_freq_range_t freqRange;
|
||||
} sony_integ_dvbs_s2_tune_srs_param_t;
|
||||
|
||||
/**
|
||||
@brief Definition of the parameters for BlindScan.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
@brief Min frequency of scan range in KHz.
|
||||
|
||||
Please set the min frequency of channel which you would like to detect in KHz.
|
||||
(i.e. 950000)
|
||||
*/
|
||||
uint32_t minFreqKHz;
|
||||
/**
|
||||
@brief Max frequency of scan range.
|
||||
|
||||
Please set the min frequency of channel which you would like to detect in KHz.
|
||||
(i.e. 2150000)
|
||||
*/
|
||||
uint32_t maxFreqKHz;
|
||||
/**
|
||||
@brief Min symbol rate of scan range.
|
||||
|
||||
Please set the min symbol rate of channel which you would like to detect in KSps.
|
||||
(i.e. 1000)
|
||||
*/
|
||||
uint32_t minSymbolRateKSps;
|
||||
/**
|
||||
@brief Max symbol rate of scan range.
|
||||
|
||||
Please set the max symbol rate of channel which you would like to detect in KSps.
|
||||
(i.e. 45000)
|
||||
*/
|
||||
uint32_t maxSymbolRateKSps;
|
||||
} sony_integ_dvbs_s2_blindscan_param_t;
|
||||
|
||||
/**
|
||||
@brief Definition of the result of BlindScan.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
@brief The cause of callback.
|
||||
|
||||
When callback function was called, please check it first.
|
||||
*/
|
||||
sony_integ_dvbs_s2_blindscan_event_id_t eventId;
|
||||
/**
|
||||
@brief Detected channel information.
|
||||
|
||||
If "eventId == SONY_INTEG_DVBS_S2_BLINDSCAN_EVENT_DETECT", this value is valid.
|
||||
*/
|
||||
sony_dvbs_s2_tune_param_t tuneParam;
|
||||
/**
|
||||
@brief Progress.
|
||||
|
||||
If "eventId == SONY_INTEG_DVBS_S2_BLINDSCAN_EVENT_PROGRESS", this value is valid.
|
||||
The range of this value is 0 - 100 in percentage.
|
||||
*/
|
||||
uint8_t progress;
|
||||
}sony_integ_dvbs_s2_blindscan_result_t;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Function Pointers
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Callback function that is called for every attempted frequency during a DVB-S/S2
|
||||
scan. For successful channel results the function is called before TS lock
|
||||
is achieved.
|
||||
|
||||
@param pInteg The driver instance.
|
||||
@param pResult The current scan result.
|
||||
*/
|
||||
typedef void (*sony_integ_dvbs_s2_blindscan_callback_t) (sony_integ_t * pInteg,
|
||||
sony_integ_dvbs_s2_blindscan_result_t * pResult);
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@brief Tune SRS (Symbol Rate Search) performs a blind acquisition to the
|
||||
channel with wider range than ::sony_integ_dvbs_s2_Tune(). It captures
|
||||
an available signal having Symbol Rate of 1 to 45 MSps and centred
|
||||
within +/- 10 MHz of the RF frequency specified by the pParam struct.
|
||||
This enables acquisition to a DVB-S or DVB-S2 channel where the center
|
||||
frequency or symbol rate is not precisely known.
|
||||
|
||||
The located channel tune parameters are then written into the pTuneParam
|
||||
structure, which can subsequently be passed to ::sony_integ_dvbs_s2_Tune
|
||||
for quicker acquisition.
|
||||
|
||||
Blocks the calling thread until the TS has locked or has timed out.
|
||||
Use ::sony_integ_Cancel to cancel the operation at any time.
|
||||
|
||||
@param pInteg The driver instance.
|
||||
@param pSeq The sequence instance.
|
||||
@param pParam Parameter for TuneSRS.
|
||||
@param pTuneParam The detected channel information.
|
||||
|
||||
@return SONY_RESULT_OK if tuned successfully to the channel and pTuneParam is valid.
|
||||
*/
|
||||
sony_result_t sony_integ_dvbs_s2_TuneSRS (sony_integ_t * pInteg,
|
||||
sony_demod_dvbs_s2_tune_srs_seq_t * pSeq,
|
||||
sony_integ_dvbs_s2_tune_srs_param_t * pParam,
|
||||
sony_dvbs_s2_tune_param_t * pTuneParam);
|
||||
|
||||
/**
|
||||
@brief BlindScan searches channels within the frequency and symbol rate range set
|
||||
by pParam. The whole process is carried out in three steps. In the first step,
|
||||
it finds channels having Symbol Rate more than 20 MSps. In the second step, it
|
||||
finds channels having Symbol Rate between 5 to 20 MSps. In the third step, it
|
||||
finds channels having Symbol Rate between 1 to 5 MSps.
|
||||
|
||||
Callback function is called during each step at the following points.
|
||||
- Detected channel
|
||||
- Update progress
|
||||
The source of callback is determined by checking sony_integ_dvbs_s2_blindscan_result_t::eventId.
|
||||
Please see explanation in ::sony_integ_dvbs_s2_blindscan_result_t structure.
|
||||
|
||||
Blocks the calling thread until the BlindScan has finished.
|
||||
Use ::sony_integ_Cancel to cancel the operation at any time.
|
||||
|
||||
@param pInteg The integration part instance.
|
||||
@param pSeq The sequence instance.
|
||||
@param pParam Scan parameters.
|
||||
@param callback Callback function pointer.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_integ_dvbs_s2_BlindScan (sony_integ_t * pInteg,
|
||||
sony_demod_dvbs_s2_blindscan_seq_t * pSeq,
|
||||
sony_integ_dvbs_s2_blindscan_param_t * pParam,
|
||||
sony_integ_dvbs_s2_blindscan_callback_t callback);
|
||||
|
||||
#endif /* SONY_INTEG_DVBS_S2_BLINDSCAN_H */
|
||||
Executable
+333
@@ -0,0 +1,333 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/12/13
|
||||
Modification ID : e402a4dcb0e51a00c34b174334c082c1211eebf1
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "sony_integ_sat_device_ctrl_singlecable_auto_install.h"
|
||||
#include "sony_integ_sat_device_ctrl.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Static Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
static sony_result_t getCWPower (sony_integ_t * pInteg,
|
||||
sony_demod_sat_device_ctrl_detect_cw_seq_t * pSeq,
|
||||
uint32_t freqKHz,
|
||||
uint32_t rangeKHz,
|
||||
int32_t * pPower);
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
sony_result_t sony_integ_sat_device_ctrl_Find1UB (sony_integ_t * pInteg,
|
||||
sony_demod_sat_device_ctrl_find1ub_seq_t * pSeq,
|
||||
uint32_t minFreqKHz,
|
||||
uint32_t maxFreqKHz,
|
||||
uint8_t userbandId,
|
||||
uint32_t * pFreqKHz)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
uint32_t elapsedTime = 0;
|
||||
sony_stopwatch_t stopwatch;
|
||||
SONY_TRACE_ENTER ("sony_integ_sat_device_ctrl_Find1UB");
|
||||
|
||||
if ((!pInteg) || (!pInteg->pDemod) || (!pSeq) || (!pFreqKHz) ||
|
||||
(!pInteg->pTuner) || (!pInteg->pTuner->CalcRFLevelFromAGC) ||
|
||||
(!pInteg->pTuner->SatTune)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if ((pInteg->pDemod->state != SONY_DEMOD_STATE_SLEEP) && (pInteg->pDemod->state != SONY_DEMOD_STATE_ACTIVE)) {
|
||||
/* This api is accepted in Sleep and Active states only */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
if (pInteg->pDemod->isSinglecable){
|
||||
/* Current Demod/Tuner is configured for Single Cable but
|
||||
this API is accepted in non-Single Cable (Normal) mode only. */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
/* Enable satellite device control function */
|
||||
result = sony_integ_sat_device_ctrl_Enable (pInteg, 1);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_sat_device_ctrl_find1ub_seq_Initialize (pSeq, pInteg->pDemod, minFreqKHz, maxFreqKHz, userbandId);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
while(pSeq->isContinue){
|
||||
/* Check cancellation. */
|
||||
result = sony_integ_CheckCancellation (pInteg);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (pSeq->commonParams.waitTime == 0){
|
||||
/* Execute one sequence */
|
||||
result = sony_demod_sat_device_ctrl_find1ub_seq_Sequence (pSeq);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Start stopwatch */
|
||||
result = sony_stopwatch_start (&stopwatch);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Transmitting single cable command is requested */
|
||||
if (pSeq->commandReq){
|
||||
pSeq->commandReq = 0;
|
||||
|
||||
result = sony_integ_sat_device_ctrl_TransmitSinglecableCommand(pInteg, &pSeq->message);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
|
||||
/* AGC calculate is requested */
|
||||
if (pSeq->commonParams.agcInfo.isRequest){
|
||||
int32_t rfLevel;
|
||||
|
||||
/* Clear request flag. */
|
||||
pSeq->commonParams.agcInfo.isRequest = 0;
|
||||
|
||||
result = pInteg->pTuner->CalcRFLevelFromAGC (pInteg->pTuner,
|
||||
pSeq->commonParams.agcInfo.agcLevel,
|
||||
&rfLevel);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
pSeq->commonParams.agcInfo.agc_x100dB = -rfLevel; /* Gain value should be set. */
|
||||
}
|
||||
|
||||
/* Tune is requested */
|
||||
if (pSeq->commonParams.tuneReq.isRequest){
|
||||
|
||||
/* Clear request flag. */
|
||||
pSeq->commonParams.tuneReq.isRequest = 0;
|
||||
|
||||
/* Enable the I2C repeater */
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x01);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
/* RF Tune */
|
||||
result = pInteg->pTuner->SatTune (pInteg->pTuner,
|
||||
pSeq->commonParams.tuneReq.frequencyKHz,
|
||||
pSeq->commonParams.tuneReq.system,
|
||||
pSeq->commonParams.tuneReq.symbolRateKSps);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
/* Set actual frequency to the driver. */
|
||||
pSeq->commonParams.tuneReq.frequencyKHz = pInteg->pTuner->frequencyKHz;
|
||||
/* Disable the I2C repeater */
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x00);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* waiting */
|
||||
result = sony_stopwatch_sleep (&stopwatch, 10);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_stopwatch_elapsed (&stopwatch, &elapsedTime);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if(elapsedTime > pSeq->commonParams.waitTime){
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*pFreqKHz = pSeq->ubFreqKHz;
|
||||
|
||||
result = sony_integ_Sleep (pInteg);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_integ_sat_device_ctrl_DetectYesNo (sony_integ_t * pInteg,
|
||||
sony_demod_sat_device_ctrl_detect_cw_seq_t * pSeq,
|
||||
uint32_t ubFreqKHz,
|
||||
uint32_t noFreqOffsetKHz,
|
||||
uint32_t yesMarginFreqKHz,
|
||||
uint32_t noMarginFreqKHz,
|
||||
sony_integ_sat_device_ctrl_detect_yes_no_result_t * pResult)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
int32_t yesPower = 0;
|
||||
int32_t noPower = 0;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_integ_sat_device_ctrl_DetectYesNo");
|
||||
|
||||
if ((!pInteg) || (!pInteg->pDemod) || (!pSeq) || (!pResult)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if ((pInteg->pDemod->state != SONY_DEMOD_STATE_SLEEP) && (pInteg->pDemod->state != SONY_DEMOD_STATE_ACTIVE)) {
|
||||
/* This api is accepted in Sleep and Active states only */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
if (pInteg->pDemod->isSinglecable){
|
||||
/* Current Demod/Tuner is configured for Single Cable but
|
||||
this API is accepted in non-Single Cable (Normal) mode only. */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
result = getCWPower (pInteg, pSeq, ubFreqKHz, yesMarginFreqKHz, &yesPower);
|
||||
if(result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = getCWPower (pInteg, pSeq, ubFreqKHz + noFreqOffsetKHz, noMarginFreqKHz, &noPower);
|
||||
if(result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if(yesPower >= noPower + 1000){
|
||||
/* Return YES. */
|
||||
*pResult = SONY_INTEG_SAT_DEVICE_CTRL_DETECT_YES_NO_RESULT_YES;
|
||||
} else if(noPower >= yesPower + 1000) {
|
||||
/* Return NO. */
|
||||
*pResult = SONY_INTEG_SAT_DEVICE_CTRL_DETECT_YES_NO_RESULT_NO;
|
||||
} else {
|
||||
/* Return NOT Detected. */
|
||||
*pResult = SONY_INTEG_SAT_DEVICE_CTRL_DETECT_YES_NO_RESULT_NOTDETECT;
|
||||
}
|
||||
|
||||
result = sony_integ_Sleep (pInteg);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Static Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
static sony_result_t getCWPower (sony_integ_t * pInteg,
|
||||
sony_demod_sat_device_ctrl_detect_cw_seq_t * pSeq,
|
||||
uint32_t freqKHz,
|
||||
uint32_t rangeKHz,
|
||||
int32_t * pPower)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
uint32_t elapsedTime = 0;
|
||||
sony_stopwatch_t stopwatch;
|
||||
SONY_TRACE_ENTER ("getCWPower");
|
||||
|
||||
if ((!pInteg) || (!pInteg->pDemod) || (!pSeq) || (!pPower) ||
|
||||
(!pInteg->pTuner) || (!pInteg->pTuner->CalcRFLevelFromAGC)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
result = sony_demod_sat_device_ctrl_detect_cw_seq_Initialize (pSeq, pInteg->pDemod, freqKHz, rangeKHz);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
while(pSeq->isContinue){
|
||||
/* Check cancellation. */
|
||||
result = sony_integ_CheckCancellation (pInteg);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (pSeq->commonParams.waitTime == 0){
|
||||
/* Execute one sequence */
|
||||
result = sony_demod_sat_device_ctrl_detect_cw_seq_Sequence (pSeq);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Start stopwatch */
|
||||
result = sony_stopwatch_start (&stopwatch);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* AGC calculate is requested */
|
||||
if (pSeq->commonParams.agcInfo.isRequest){
|
||||
int32_t rfLevel;
|
||||
|
||||
/* Clear request flag. */
|
||||
pSeq->commonParams.agcInfo.isRequest = 0;
|
||||
|
||||
result = pInteg->pTuner->CalcRFLevelFromAGC (pInteg->pTuner,
|
||||
pSeq->commonParams.agcInfo.agcLevel,
|
||||
&rfLevel);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
pSeq->commonParams.agcInfo.agc_x100dB = -rfLevel; /* Gain value should be set. */
|
||||
}
|
||||
|
||||
/* Tune is requested */
|
||||
if (pSeq->commonParams.tuneReq.isRequest){
|
||||
|
||||
/* Clear request flag. */
|
||||
pSeq->commonParams.tuneReq.isRequest = 0;
|
||||
|
||||
if ((pInteg->pTuner) && (pInteg->pTuner->SatTune)) {
|
||||
/* Enable the I2C repeater */
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x01);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
/* RF Tune */
|
||||
result = pInteg->pTuner->SatTune (pInteg->pTuner,
|
||||
pSeq->commonParams.tuneReq.frequencyKHz,
|
||||
pSeq->commonParams.tuneReq.system,
|
||||
pSeq->commonParams.tuneReq.symbolRateKSps);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
/* Set actual frequency to the driver. */
|
||||
pSeq->commonParams.tuneReq.frequencyKHz = pInteg->pTuner->frequencyKHz;
|
||||
/* Disable the I2C repeater */
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x00);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* waiting */
|
||||
result = sony_stopwatch_sleep (&stopwatch, 10);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_stopwatch_elapsed (&stopwatch, &elapsedTime);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if(elapsedTime > pSeq->commonParams.waitTime){
|
||||
pSeq->commonParams.waitTime = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*pPower = pSeq->power;
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
Executable
+81
@@ -0,0 +1,81 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/12/13
|
||||
Modification ID : e402a4dcb0e51a00c34b174334c082c1211eebf1
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_integ_sat_device_ctrl_singlecable_auto_install.h
|
||||
|
||||
This file provide functions useful for single cable 1 (EN50494) automatic installation.
|
||||
This file located in blindscan folder because blind scanning technique is used.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_INTEG_SAT_DEVICE_CTRL_SINGLECABLE_AUTO_INSTALL_H
|
||||
#define SONY_INTEG_SAT_DEVICE_CTRL_SINGLECABLE_AUTO_INSTALL_H
|
||||
|
||||
#include "sony_integ.h"
|
||||
#include "sony_demod_sat_device_ctrl_find1ub_seq.h"
|
||||
#include "sony_demod_sat_device_ctrl_detect_cw_seq.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Structs
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Return codes for Detect YES/NO results.
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_INTEG_SAT_DEVICE_CTRL_DETECT_YES_NO_RESULT_YES, /**< Detected YES Signal for Detect YES/NO. */
|
||||
SONY_INTEG_SAT_DEVICE_CTRL_DETECT_YES_NO_RESULT_NO, /**< Detected NO Signal for Detect YES/NO. */
|
||||
SONY_INTEG_SAT_DEVICE_CTRL_DETECT_YES_NO_RESULT_NOTDETECT,/**< Could not detect any YES/NO signal. */
|
||||
} sony_integ_sat_device_ctrl_detect_yes_no_result_t;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Find one user band.
|
||||
|
||||
@note LNB controller and satellite device control function will be automatically enabled.
|
||||
|
||||
@param pInteg The integration part instance.
|
||||
@param pSeq The address of sequence instance.
|
||||
@param minFreqKHz The minimum frequency of search range in KHz.
|
||||
@param maxFreqKHz The maximum frequency of search range in KHz.
|
||||
@param userbandId The user band ID.(1-8)
|
||||
@param pFreqKHz The address of detected frequency in KHz.
|
||||
If this value is 0, driver can't detect target user band.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_integ_sat_device_ctrl_Find1UB (sony_integ_t * pInteg,
|
||||
sony_demod_sat_device_ctrl_find1ub_seq_t * pSeq,
|
||||
uint32_t minFreqKHz,
|
||||
uint32_t maxFreqKHz,
|
||||
uint8_t userbandId,
|
||||
uint32_t * pFreqKHz);
|
||||
|
||||
/**
|
||||
@brief Detect YES/NO answer from SCIF.
|
||||
|
||||
@note LNB controller and satellite device control function will be automatically enabled.
|
||||
|
||||
@param pInteg The integration part instance.
|
||||
@param pSeq The address of sequence instance.
|
||||
@param ubFreqKHz The frequency of the target user band in KHz.
|
||||
@param noFreqOffsetKHz The frequency offset for NO signal from the target user band in KHz. (20,000 is default)
|
||||
@param yesMarginFreqKHz The margin frequency for YES signal. (500 is default)
|
||||
@param noMarginFreqKHz The margin frequency for NO signal. (1000 is default)
|
||||
@param pResult The address of result for this API.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_integ_sat_device_ctrl_DetectYesNo (sony_integ_t * pInteg,
|
||||
sony_demod_sat_device_ctrl_detect_cw_seq_t * pSeq,
|
||||
uint32_t ubFreqKHz,
|
||||
uint32_t noFreqOffsetKHz,
|
||||
uint32_t yesMarginFreqKHz,
|
||||
uint32_t noMarginFreqKHz,
|
||||
sony_integ_sat_device_ctrl_detect_yes_no_result_t * pResult);
|
||||
|
||||
#endif /* SONY_INTEG_SAT_DEVICE_CTRL_SINGLECABLE_AUTO_INSTALL_H */
|
||||
+619
@@ -0,0 +1,619 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2019 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2019/06/28
|
||||
Modification ID : 4d12c6351929bcae29649d686be7d406fd4718c8
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "sony_dtv.h"
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod_dvbs_s2.h"
|
||||
#include "sony_demod_dvbs_s2_monitor.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Static Function Prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
static sony_result_t SLtoASX (sony_demod_t * pDemod,
|
||||
sony_dtv_system_t dtvSystem,
|
||||
uint32_t symbolRateKSps);
|
||||
|
||||
static sony_result_t ASXtoSL (sony_demod_t * pDemod);
|
||||
|
||||
static sony_result_t ASXtoASX (sony_demod_t * pDemod,
|
||||
uint32_t symbolRateKSps);
|
||||
|
||||
static sony_result_t TSRStoSL(sony_demod_t * pDemod);
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
sony_result_t sony_demod_dvbs_s2_Tune (sony_demod_t * pDemod,
|
||||
sony_dvbs_s2_tune_param_t * pTuneParam)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_Tune");
|
||||
|
||||
if ((!pDemod) || (!pTuneParam)) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if ((pTuneParam->system != SONY_DTV_SYSTEM_DVBS) &&
|
||||
(pTuneParam->system != SONY_DTV_SYSTEM_DVBS2) &&
|
||||
(pTuneParam->system != SONY_DTV_SYSTEM_ANY)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if (pDemod->state == SONY_DEMOD_STATE_ACTIVE) {
|
||||
/* Active */
|
||||
if (pDemod->dvbss2ScanMode > 0){
|
||||
/* Scan -> Sleep */
|
||||
result = TSRStoSL (pDemod);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
/* Sleep -> Active-S(X) */
|
||||
result = SLtoASX (pDemod, pTuneParam->system, pTuneParam->symbolRateKSps);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
} else if (pDemod->system == pTuneParam->system){
|
||||
/* Active-S(X) -> Active-S(X) */
|
||||
result = ASXtoASX (pDemod, pTuneParam->symbolRateKSps);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
} else {
|
||||
/* To Sleep */
|
||||
result = sony_demod_Sleep (pDemod);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
/* Sleep -> Active-S(X) */
|
||||
result = SLtoASX (pDemod, pTuneParam->system, pTuneParam->symbolRateKSps);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
} else if (pDemod->state == SONY_DEMOD_STATE_SLEEP){
|
||||
/* Sleep -> Active-S(X) */
|
||||
result = SLtoASX (pDemod, pTuneParam->system, pTuneParam->symbolRateKSps);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
} else {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
pDemod->state = SONY_DEMOD_STATE_ACTIVE;
|
||||
pDemod->system = pTuneParam->system;
|
||||
pDemod->dvbss2ScanMode = 0;
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_Sleep (sony_demod_t * pDemod)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_Sleep");
|
||||
|
||||
if (!pDemod) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if (pDemod->state == SONY_DEMOD_STATE_ACTIVE){
|
||||
if (pDemod->dvbss2ScanMode > 0){
|
||||
result = TSRStoSL (pDemod);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
} else if ((pDemod->system == SONY_DTV_SYSTEM_DVBS)
|
||||
|| (pDemod->system == SONY_DTV_SYSTEM_DVBS2) || (pDemod->system == SONY_DTV_SYSTEM_ANY)){
|
||||
/* Active-S(X) -> Sleep-S */
|
||||
result = ASXtoSL (pDemod);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
pDemod->state = SONY_DEMOD_STATE_SLEEP;
|
||||
} else if (pDemod->state == SONY_DEMOD_STATE_SLEEP){
|
||||
/* Do nothing. */
|
||||
} else {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
pDemod->dvbss2ScanMode = 0;
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_CheckTSLock (sony_demod_t * pDemod,
|
||||
sony_demod_lock_result_t * pLock)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
uint8_t isLock = 0;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_CheckTSLock");
|
||||
|
||||
if ((!pDemod) || (!pLock)) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if (pDemod->state != SONY_DEMOD_STATE_ACTIVE) {
|
||||
/* This api is accepted in Active state only */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_monitor_SyncStat(pDemod, &isLock);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if(isLock){
|
||||
*pLock = SONY_DEMOD_LOCK_RESULT_LOCKED;
|
||||
} else {
|
||||
*pLock = SONY_DEMOD_LOCK_RESULT_NOTDETECT;
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_CheckIQInvert (sony_demod_t * pDemod,
|
||||
uint8_t * pIsInvert)
|
||||
{
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_CheckIQInvert");
|
||||
|
||||
if ((!pDemod) || (!pIsInvert)) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if ((pDemod->state != SONY_DEMOD_STATE_ACTIVE) &&
|
||||
(pDemod->state != SONY_DEMOD_STATE_SLEEP)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
*pIsInvert = 0;
|
||||
if (pDemod->isSinglecable){
|
||||
if (pDemod->isSinglecableSpectrumInv){
|
||||
if (pDemod->satTunerIqSense == SONY_DEMOD_SAT_IQ_SENSE_NORMAL){
|
||||
*pIsInvert = 1;
|
||||
}
|
||||
} else {
|
||||
if (pDemod->satTunerIqSense == SONY_DEMOD_SAT_IQ_SENSE_INV){
|
||||
*pIsInvert = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (pDemod->satTunerIqSense == SONY_DEMOD_SAT_IQ_SENSE_INV){
|
||||
*pIsInvert = 1;
|
||||
}
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbs_s2_SetSymbolRate (sony_demod_t * pDemod,
|
||||
uint32_t symbolRateKSps)
|
||||
{
|
||||
uint32_t regValue = 0;
|
||||
uint8_t data[3] = {0, 0, 0};
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_SetSymbolRate");
|
||||
|
||||
if (!pDemod){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if ((pDemod->state != SONY_DEMOD_STATE_ACTIVE) &&
|
||||
(pDemod->state != SONY_DEMOD_STATE_SLEEP)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
/*
|
||||
* regValue = (symbolRateKSps * 2^14 / 1000) + 0.5
|
||||
* = ((symbolRateKSps * 2^14) + 500) / 1000
|
||||
* = ((symbolRateKSps * 16384) + 500) / 1000
|
||||
*/
|
||||
regValue = ((symbolRateKSps * 16384) + 500) / 1000;
|
||||
if ((regValue == 0) || (regValue > 0x0FFFFF)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_RANGE);
|
||||
}
|
||||
data[0] = (uint8_t)((regValue >> 16) & 0x0F);
|
||||
data[1] = (uint8_t)((regValue >> 8) & 0xFF);
|
||||
data[2] = (uint8_t)( regValue & 0xFF);
|
||||
|
||||
/* slave Bank Addr Bit Default Setting Signal name
|
||||
* ----------------------------------------------------------------------------------
|
||||
* <SLV-T> AEh 20h [3:0] 8'h07 8'h0x OSYMBOLRATE[19:16]
|
||||
* <SLV-T> AEh 21h [7:0] 8'h37 8'hxx OSYMBOLRATE[15:8]
|
||||
* <SLV-T> AEh 22h [7:0] 8'h0A 8'hxx OSYMBOLRATE[7:0]
|
||||
*/
|
||||
/* Set SLV-T Bank : 0xAE */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAE) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x20, data, 3) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Static Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
static sony_result_t SLtoASX (sony_demod_t * pDemod,
|
||||
sony_dtv_system_t dtvSystem,
|
||||
uint32_t symbolRateKSps)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
uint8_t data = 0;
|
||||
SONY_TRACE_ENTER ("SLtoASX");
|
||||
|
||||
if (!pDemod) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Configure TS clock Mode and Frequency. */
|
||||
/* NOTE: It is used for both DVB-S and S2 systems though only DVB-S is passed as a parameter. */
|
||||
result = sony_demod_SetTSClockModeAndFreq (pDemod, SONY_DTV_SYSTEM_DVBS);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Set demod mode */
|
||||
if(dtvSystem == SONY_DTV_SYSTEM_DVBS){
|
||||
data = 0x0A;
|
||||
} else if(dtvSystem == SONY_DTV_SYSTEM_DVBS2){
|
||||
data = 0x0B;
|
||||
} else if(dtvSystem == SONY_DTV_SYSTEM_ANY){
|
||||
data = 0x0B;
|
||||
} else {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Set SLV-X Bank : 0x00 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x00, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x17, data) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if ((dtvSystem == SONY_DTV_SYSTEM_DVBS) || (dtvSystem == SONY_DTV_SYSTEM_DVBS2)){
|
||||
/* DVB-S/S2 */
|
||||
data = 0x00;
|
||||
} else {
|
||||
/* ANY */
|
||||
data = 0x01;
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x00 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Enable S/S2 auto detection 1 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x2D, data) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Set TS/TLV mode */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xA9, 0x00) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Enable demod clock */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x2C, 0x01) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* SADC setting */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x28, 0x31) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* SADC setting */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x4B, 0x31) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* SADC setting */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x6A, 0x00) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* SADC setting */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x18, 0x00) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* DVB-S/S2 initial setting
|
||||
*
|
||||
* slave Bank Addr Bit Default Setting Signal name
|
||||
* --------------------------------------------------------------------------------
|
||||
* <SLV-T> 00h 20h [0] 8'h00 8'h01 OREG_RFAGC_SRST_OFF
|
||||
*/
|
||||
/* Set SLV-T Bank : 0x00 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x20, 0x01) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* DVB-S/S2 initial setting (only for CXD2856)
|
||||
*
|
||||
* slave Bank Addr Bit Default Setting Signal name
|
||||
* --------------------------------------------------------------------------------
|
||||
* <SLV-T> 18h E3h [1] 8'h00 8'h02 OREG_BBBYTESS_OLDMODE
|
||||
* <SLV-T> 18h E5h [3:0] 8'h0F 8'h04 OREG_BSYNCDEPTH[3:0]
|
||||
*/
|
||||
if (SONY_DEMOD_CHIP_ID_2856_FAMILY (pDemod->chipId)) {
|
||||
/* Set SLV-T Bank : 0x18 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x18) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xE3, 0x02) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xE5, 0x04) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
}
|
||||
|
||||
/* slave Bank Addr Bit Default Setting Signal name
|
||||
* --------------------------------------------------------------------------------
|
||||
* <SLV-T> A0h D7h [0] 8'h00 8'h00 OTUIF_POLAR
|
||||
*/
|
||||
/* Set SLV-T Bank : 0xA0 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* OTUIF_POLAR[0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xD7, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Set demod parameter */
|
||||
result = sony_demod_dvbs_s2_SetSymbolRate (pDemod, symbolRateKSps);
|
||||
if (result != SONY_RESULT_OK){SONY_TRACE_RETURN (result);}
|
||||
|
||||
/* Set SLV-T Bank : 0x00 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Disable HiZ Setting 1 (TAGC(Hi-Z), SAGC, TSVALID, TSSYNC, TSCLK) */
|
||||
if (sony_i2c_SetRegisterBits (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x80, 0x10, 0x1F) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Disable Hi-Z setting 2 */
|
||||
result = sony_demod_SetTSDataPinHiZ (pDemod, 0);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
static sony_result_t ASXtoSL (sony_demod_t * pDemod)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("ASXtoSL");
|
||||
|
||||
if (!pDemod) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Disable TS output */
|
||||
result = sony_demod_SetStreamOutput (pDemod, 0);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x00 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Enable Hi-Z setting 1 (TAGC, SAGC, TSVALID, TSSYNC, TSCLK) */
|
||||
if (sony_i2c_SetRegisterBits (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x80, 0x1F, 0x1F) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Enable Hi-Z setting 2 */
|
||||
result = sony_demod_SetTSDataPinHiZ (pDemod, 1);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* ---- */
|
||||
|
||||
/* Set SLV-X Bank : 0x00 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x00, 0x00) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* SADC setting */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x18, 0x01) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x00 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x00) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* SADC setting */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x6A, 0x11) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* SADC setting */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x4B, 0x21) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* SADC setting */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x28, 0x13) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Demodulator SW reset */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xFE, 0x01) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Disable demodulator clock */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x2C, 0x00) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Set tstlv mode to default */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xA9, 0x00) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Disable S/S2 auto detection */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x2D, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Set demodulator mode to default */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x17, 0x01) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
static sony_result_t ASXtoASX (sony_demod_t * pDemod, uint32_t symbolRateKSps)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("ASXtoASX");
|
||||
|
||||
if (!pDemod) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Disable TS output */
|
||||
result = sony_demod_SetStreamOutput (pDemod, 0);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* set demod parameter */
|
||||
result = sony_demod_dvbs_s2_SetSymbolRate(pDemod, symbolRateKSps);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
static sony_result_t TSRStoSL(sony_demod_t * pDemod)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("TSRStoSL");
|
||||
|
||||
if (!pDemod) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Disable TS output */
|
||||
result = sony_demod_SetStreamOutput (pDemod, 0);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x00 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* OREG_ARC_HSMODE[0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x24, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xAE */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAE) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* OFSM_SRSON[0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x24, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* OFSM_UNLOCKSEL_ARS[2:0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x2E, 0x06) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* OFSM_AUTOMODECHGON[0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x30, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x00 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* OREG_ARC_CKACHGAUTO[0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x2B, 0x01) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xA0 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* OCFRL_CHSCANON[0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x56, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xAB */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAB) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* OCFRL_CSBUFOFF[0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xF9, 0x01) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xA3 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA3) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xBD, 0x01) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
result = ASXtoSL (pDemod);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0xA0 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* OTUIF_POLAR[0] */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xD7, 0x00) != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/07/27
|
||||
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbs_s2.h
|
||||
|
||||
This file provides the demodulator control interface specific to DVB-S/S2.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DEMOD_DVBS_S2_H
|
||||
#define SONY_DEMOD_DVBS_S2_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Structs
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief The Tune parameters for a DVB-S/S2 signal.
|
||||
*/
|
||||
typedef struct {
|
||||
sony_dtv_system_t system; /**< System of the channel. */
|
||||
uint32_t centerFreqKHz; /**< Center frequency in kHz of the DVB-S/S2 channel. */
|
||||
uint32_t symbolRateKSps; /**< Symbol rate in kHz of the DVB-S/S2 channel. */
|
||||
} sony_dvbs_s2_tune_param_t;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@brief Enable acquisition on the demodulator for DVB-S/S2 channels.
|
||||
|
||||
Called from the integration layer ::sony_integ_dvbs_s2_Tune API.
|
||||
|
||||
@param pDemod The demodulator instance
|
||||
@param pTuneParam The tune parameters.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_Tune (sony_demod_t * pDemod,
|
||||
sony_dvbs_s2_tune_param_t * pTuneParam);
|
||||
|
||||
/**
|
||||
@brief Put the demodulator into ::SONY_DEMOD_STATE_SLEEP state.
|
||||
|
||||
Can be called from Active, Shutdown or Sleep states.
|
||||
Called from the integration layer ::sony_integ_Sleep API.
|
||||
|
||||
@param pDemod The demodulator instance
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_Sleep (sony_demod_t * pDemod);
|
||||
|
||||
/**
|
||||
@brief Check whether TS signal is locked or not locked.
|
||||
|
||||
@note This API is for checking lock status in tuning stage.
|
||||
After tuning (while receiving the signal),
|
||||
please use sony_demod_dvbs_s2_monitor_SyncStat instead
|
||||
to check current lock status.
|
||||
|
||||
@param pDemod The demodulator instance
|
||||
@param pLock Address of lock status.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_CheckTSLock (sony_demod_t * pDemod,
|
||||
sony_demod_lock_result_t * pLock);
|
||||
|
||||
/**
|
||||
@brief Get the I/Q polarity of device.
|
||||
|
||||
This API is called by driver internal.
|
||||
So user doesn't need to use it.
|
||||
|
||||
@param pDemod The demodulator instance
|
||||
@param pIsInvert Polarity of I/Q sense. (0: Not inverted. 1: Inverted)
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_CheckIQInvert (sony_demod_t * pDemod,
|
||||
uint8_t * pIsInvert);
|
||||
|
||||
/**
|
||||
@brief Configure demodulator setting to demodulate symbol rate.
|
||||
|
||||
@param pDemod The demodulator instance
|
||||
@param symbolRateKSps Symbol rate in KSps.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_SetSymbolRate (sony_demod_t * pDemod,
|
||||
uint32_t symbolRateKSps);
|
||||
|
||||
#endif /* SONY_DEMOD_DVBS_S2_H */
|
||||
+2672
File diff suppressed because it is too large
Load Diff
+266
@@ -0,0 +1,266 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2019 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2019/02/14
|
||||
Modification ID : 83dbabba2734697e67e3d44647acf57b272c2caf
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbs_s2_monitor.h
|
||||
|
||||
This file provides the DVB-S/S2 demodulator monitor interface.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DEMOD_DVBS_S2_MONITOR_H
|
||||
#define SONY_DEMOD_DVBS_S2_MONITOR_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@brief Monitors the synchronisation state of the DVB-S/S2 demodulator.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pTSLockStat Indicates the TS lock condition.
|
||||
- 0: TS not locked.
|
||||
- 1: TS locked.
|
||||
|
||||
@return SONY_RESULT_OK if pTSLockStat is valid, otherwise an error is returned.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_monitor_SyncStat (sony_demod_t * pDemod,
|
||||
uint8_t * pTSLockStat);
|
||||
|
||||
/**
|
||||
@brief Monitor the carrier offset of the currently tuned channel.
|
||||
|
||||
To get the estimated center frequency of the current channel:
|
||||
Fest = Ftune (KHz) + pOffset (KHz) ;
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pOffset The detected carrier offset in KHz.
|
||||
|
||||
@return SONY_RESULT_OK if pOffset is valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_monitor_CarrierOffset (sony_demod_t * pDemod,
|
||||
int32_t * pOffset);
|
||||
|
||||
/**
|
||||
@brief Monitor the IFAGC value of the DVB-S/S2 demodulator.
|
||||
|
||||
Actual dB gain dependent on attached tuner.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pIFAGC The IFAGC output register value. Range 0 - 0xFFF. Unitless.
|
||||
|
||||
@return SONY_RESULT_OK if pIFAGC is valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_monitor_IFAGCOut (sony_demod_t * pDemod,
|
||||
uint32_t * pIFAGC);
|
||||
|
||||
/**
|
||||
@brief Monitor the System which current receiving.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pSystem The system of current receiving signal.
|
||||
|
||||
@return SONY_RESULT_OK if pSystem is valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_monitor_System (sony_demod_t * pDemod,
|
||||
sony_dtv_system_t * pSystem);
|
||||
|
||||
/**
|
||||
@brief Monitor the symbol rate of the currently tuned channel in Sps (Symbols per Second).
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pSymbolRateSps The symbol rate in Sps (Symbols per Second).
|
||||
|
||||
@return SONY_RESULT_OK if pSymbolRateSps is valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_monitor_SymbolRate (sony_demod_t * pDemod,
|
||||
uint32_t * pSymbolRateSps);
|
||||
|
||||
/**
|
||||
@brief Monitors the I/Q sense used by the DVB-S/S2 demodulator.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pSense The detected I/Q sense.
|
||||
|
||||
@return SONY_RESULT_OK if successful and pSense is valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_monitor_IQSense (sony_demod_t * pDemod,
|
||||
sony_demod_sat_iq_sense_t * pSense);
|
||||
|
||||
/**
|
||||
@brief Monitor the CNR estimation made by the demodulator.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pCNR The returned CNR in dB x 1000.
|
||||
|
||||
@return SONY_RESULT_OK if pCNR is valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_monitor_CNR (sony_demod_t * pDemod,
|
||||
int32_t * pCNR);
|
||||
|
||||
/**
|
||||
@brief Monitor PER.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pPER The returned PER in 1e6.
|
||||
|
||||
@return SONY_RESULT_OK if pPER is valid, otherwise an error is returned.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_monitor_PER (sony_demod_t * pDemod,
|
||||
uint32_t * pPER);
|
||||
|
||||
/**
|
||||
@brief Monitor the DVB-S Code Rate.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pCodeRate Code rate.
|
||||
|
||||
@return SONY_RESULT_OK if pCodeRate is valid, otherwise an error is returned.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_monitor_CodeRate (sony_demod_t * pDemod,
|
||||
sony_dvbs_coderate_t * pCodeRate);
|
||||
|
||||
/**
|
||||
@brief Monitor pre Viterbi BER.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pBER The returned BER * 10^7.
|
||||
|
||||
@return SONY_RESULT_OK if pBER is valid, otherwise an error is returned.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_monitor_PreViterbiBER (sony_demod_t * pDemod,
|
||||
uint32_t * pBER);
|
||||
|
||||
/**
|
||||
@brief Monitor pre RS BER.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pBER The returned BER * 10^7.
|
||||
|
||||
@return SONY_RESULT_OK if pBER is valid, otherwise an error is returned.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_monitor_PreRSBER (sony_demod_t * pDemod,
|
||||
uint32_t * pBER);
|
||||
|
||||
/**
|
||||
@brief Monitor the DVB-S2 PLS code.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pPLSCode The returned PLS code. The IC does not support short frames,
|
||||
so sony_dvbs2_plscode_t::isShortFrame is always set to 0:normal.
|
||||
|
||||
@return SONY_RESULT_OK if pPLSCode is valid, otherwise an error is returned.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs2_monitor_PLSCode (sony_demod_t * pDemod,
|
||||
sony_dvbs2_plscode_t * pPLSCode);
|
||||
|
||||
/**
|
||||
@brief Monitor pre LDPC BER.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pBER The returned BER * 10^7.
|
||||
|
||||
@return SONY_RESULT_OK if pBER is valid, otherwise an error is returned.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs2_monitor_PreLDPCBER (sony_demod_t * pDemod,
|
||||
uint32_t * pBER);
|
||||
|
||||
/**
|
||||
@brief Monitor pre BCH BER.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pBER The returned BER * 10^9.
|
||||
|
||||
@return SONY_RESULT_OK if pBER is valid, otherwise an error is returned.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs2_monitor_PreBCHBER (sony_demod_t * pDemod,
|
||||
uint32_t * pBER);
|
||||
|
||||
/**
|
||||
@brief Monitor post BCH FER.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pFER The returned FER * 10^6.
|
||||
|
||||
@return SONY_RESULT_OK if pFER is valid, otherwise an error is returned.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs2_monitor_PostBCHFER (sony_demod_t * pDemod,
|
||||
uint32_t * pFER);
|
||||
|
||||
/**
|
||||
@brief Monitor DVB-S2 base-band Header (BBHEADER).
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pBBHeader The returned base-band Header (BBHEADER) information.
|
||||
|
||||
@return SONY_RESULT_OK if pBBHeader is valid, otherwise an error is returned.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs2_monitor_BBHeader (sony_demod_t * pDemod,
|
||||
sony_dvbs2_bbheader_t * pBBHeader);
|
||||
|
||||
/**
|
||||
@brief Monitor DVB-S/S2 scan information.
|
||||
|
||||
This API is called from BlindScan API.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pTSLock Indicates the TS lock condition.
|
||||
- 0: TS not locked.
|
||||
- 1: TS locked.
|
||||
@param pOffset Carrier offset frequency (KHz).
|
||||
- If pTSLock = 0, this value is invalid.
|
||||
Please refer to sony_demod_dvbs_s2_monitor_CarrierOffset.
|
||||
@param pSystem The system of current receiving signal.
|
||||
- If pTSLock = 0, this value is invalid.
|
||||
|
||||
@return SONY_RESULT_OK if all values are valid, otherwise an error is returned.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_monitor_ScanInfo (sony_demod_t * pDemod,
|
||||
uint8_t * pTSLock,
|
||||
int32_t * pOffset,
|
||||
sony_dtv_system_t * pSystem);
|
||||
|
||||
/**
|
||||
@brief Check pilot on/off
|
||||
|
||||
This API is called from BlindScan API.
|
||||
|
||||
@param pDemod The demodulator instance
|
||||
@param pPlscLock Address of PLSC lock status.
|
||||
@param pPilotOn Address of Pilot flag (0:Off, 1:On)
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_monitor_Pilot (sony_demod_t * pDemod,
|
||||
uint8_t * pPlscLock,
|
||||
uint8_t * pPilotOn);
|
||||
|
||||
/**
|
||||
@brief Monitor TS bit rate in Kbps.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pTSRateKbps The returned TS bit rate in Kbps.
|
||||
|
||||
@return SONY_RESULT_OK if successful and pTSRateKbps valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs_s2_monitor_TSRate (sony_demod_t * pDemod,
|
||||
uint32_t * pTSRateKbps);
|
||||
|
||||
/**
|
||||
@brief Monitor Rolloff parameter.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pRolloff The returned pRolloff.
|
||||
|
||||
@return SONY_RESULT_OK if pRolloff is valid, otherwise an error is returned.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbs2_monitor_Rolloff (sony_demod_t * pDemod,
|
||||
uint8_t * pRolloff);
|
||||
|
||||
#endif /* SONY_DEMOD_DVBS2_MONITOR_H */
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_dvbs.h
|
||||
|
||||
This file provides DVB-S related type definitions.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DVBS_H
|
||||
#define SONY_DVBS_H
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Enumerations
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief DVB-S code rate.
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_DVBS_CODERATE_1_2, /**< 1/2 */
|
||||
SONY_DVBS_CODERATE_2_3, /**< 2/3 */
|
||||
SONY_DVBS_CODERATE_3_4, /**< 3/4 */
|
||||
SONY_DVBS_CODERATE_5_6, /**< 5/6 */
|
||||
SONY_DVBS_CODERATE_7_8, /**< 7/8 */
|
||||
SONY_DVBS_CODERATE_INVALID /**< Invalid */
|
||||
} sony_dvbs_coderate_t;
|
||||
|
||||
/**
|
||||
@brief DVB-S modulation.
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_DVBS_MODULATION_QPSK, /**< QPSK */
|
||||
SONY_DVBS_MODULATION_INVALID /**< Invalid */
|
||||
} sony_dvbs_modulation_t;
|
||||
|
||||
#endif /* SONY_DVBS_H */
|
||||
Executable
+106
@@ -0,0 +1,106 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_dvbs2.h
|
||||
|
||||
This file provides DVB-S2 related type definitions.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_DVBS2_H
|
||||
#define SONY_DVBS2_H
|
||||
|
||||
#include "sony_common.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Enumerations
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief DVB-S2 code rate.
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_DVBS2_CODERATE_1_4, /**< 1/4 */
|
||||
SONY_DVBS2_CODERATE_1_3, /**< 1/3 */
|
||||
SONY_DVBS2_CODERATE_2_5, /**< 2/5 */
|
||||
SONY_DVBS2_CODERATE_1_2, /**< 1/2 */
|
||||
SONY_DVBS2_CODERATE_3_5, /**< 3/5 */
|
||||
SONY_DVBS2_CODERATE_2_3, /**< 2/3 */
|
||||
SONY_DVBS2_CODERATE_3_4, /**< 3/4 */
|
||||
SONY_DVBS2_CODERATE_4_5, /**< 4/5 */
|
||||
SONY_DVBS2_CODERATE_5_6, /**< 5/6 */
|
||||
SONY_DVBS2_CODERATE_8_9, /**< 8/9 */
|
||||
SONY_DVBS2_CODERATE_9_10, /**< 9/10 */
|
||||
SONY_DVBS2_CODERATE_RESERVED_29, /**< Reserved */
|
||||
SONY_DVBS2_CODERATE_RESERVED_30, /**< Reserved */
|
||||
SONY_DVBS2_CODERATE_RESERVED_31, /**< Reserved */
|
||||
SONY_DVBS2_CODERATE_INVALID /**< Invalid */
|
||||
} sony_dvbs2_coderate_t;
|
||||
|
||||
/**
|
||||
@brief DVB-S2 modulation.
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_DVBS2_MODULATION_QPSK, /**< QPSK */
|
||||
SONY_DVBS2_MODULATION_8PSK, /**< 8PSK */
|
||||
SONY_DVBS2_MODULATION_16APSK, /**< 16APSK */
|
||||
SONY_DVBS2_MODULATION_32APSK, /**< 32APSK */
|
||||
SONY_DVBS2_MODULATION_RESERVED_29, /**< Reserved */
|
||||
SONY_DVBS2_MODULATION_RESERVED_30, /**< Reserved */
|
||||
SONY_DVBS2_MODULATION_RESERVED_31, /**< Reserved */
|
||||
SONY_DVBS2_MODULATION_DUMMY_PLFRAME, /**< Dummy PL Frame */
|
||||
SONY_DVBS2_MODULATION_INVALID /**< Invalid */
|
||||
} sony_dvbs2_modulation_t;
|
||||
|
||||
/**
|
||||
@brief DVB-S2 Stream Input.
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_DVBS2_STREAM_GENERIC_PACKETIZED = 0x00, /**< Generic Packetized Stream Input. */
|
||||
SONY_DVBS2_STREAM_GENERIC_CONTINUOUS = 0x01, /**< Generic Continuous Stream Input. */
|
||||
SONY_DVBS2_STREAM_RESERVED = 0x02, /**< Reserved. */
|
||||
SONY_DVBS2_STREAM_TRANSPORT = 0x03 /**< Transport Stream Input. */
|
||||
} sony_dvbs2_stream_t;
|
||||
|
||||
/**
|
||||
@brief DVB-S2 Transmission Roll-off factor.
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_DVBS2_ROLLOFF_35 = 0x00, /**< Roll-off = 0.35. */
|
||||
SONY_DVBS2_ROLLOFF_25 = 0x01, /**< Roll-off = 0.25. */
|
||||
SONY_DVBS2_ROLLOFF_20 = 0x02, /**< Roll-off = 0.20. */
|
||||
SONY_DVBS2_ROLLOFF_RESERVED = 0x03 /**< Reserved. */
|
||||
} sony_dvbs2_rolloff_t;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Structs
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief DVB-S2 PLS code information.
|
||||
*/
|
||||
typedef struct {
|
||||
sony_dvbs2_modulation_t modulation; /**< Modulation. */
|
||||
sony_dvbs2_coderate_t codeRate; /**< Code rate. */
|
||||
uint8_t isShortFrame; /**< FEC Frame size (0:normal, 1:short). */
|
||||
uint8_t isPilotOn; /**< Pilot mode (0:Off, 1:On). */
|
||||
} sony_dvbs2_plscode_t;
|
||||
|
||||
/**
|
||||
@brief DVB-S2 base-band Header (BBHEADER) information.
|
||||
*/
|
||||
typedef struct {
|
||||
sony_dvbs2_stream_t streamInput; /**< Stream Input (Transport or Generic). */
|
||||
uint8_t isSingleInputStream; /**< Multiple Input Stream or Single Input Stream. */
|
||||
uint8_t isConstantCodingModulation; /**< Constant or Adaptive Coding and Modulation. */
|
||||
uint8_t issyIndicator; /**< Input Stream Synchronisation Indicator. */
|
||||
uint8_t nullPacketDeletion; /**< Null Packet Deletion active/not active. */
|
||||
sony_dvbs2_rolloff_t rollOff; /**< Transmission Roll-Off factor. */
|
||||
uint8_t inputStreamIdentifier; /**< Input Stream Identifier (only valid for MIS). */
|
||||
uint16_t userPacketLength; /**< User Packet Length in bits. */
|
||||
uint16_t dataFieldLength; /**< Data Field Length in bits. */
|
||||
uint8_t syncByte; /**< User Packet Sync Byte. */
|
||||
} sony_dvbs2_bbheader_t;
|
||||
|
||||
#endif /* SONY_DVBS2_H */
|
||||
+241
@@ -0,0 +1,241 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/07/05
|
||||
Modification ID : c7c68d70868a4a9fb9e0f480d8b940e8a1e8f651
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod.h"
|
||||
#include "sony_integ_dvbs_s2.h"
|
||||
#include "sony_demod_dvbs_s2_monitor.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
sony_result_t sony_integ_dvbs_s2_Tune (sony_integ_t * pInteg,
|
||||
sony_dvbs_s2_tune_param_t * pTuneParam)
|
||||
{
|
||||
sony_stopwatch_t stopwatch;
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
sony_dtv_system_t dtvSystem = SONY_DTV_SYSTEM_DVBS2;
|
||||
uint32_t elapsedTime = 0;
|
||||
uint8_t isContinue = 1;
|
||||
uint32_t timeout = 0;
|
||||
sony_demod_lock_result_t lockStatus = SONY_DEMOD_LOCK_RESULT_NOTDETECT;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_integ_dvbs_s2_Tune");
|
||||
|
||||
if ((!pInteg) || (!pInteg->pDemod) ||
|
||||
(!pTuneParam) || (pTuneParam->symbolRateKSps == 0)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if ((pInteg->pDemod->state != SONY_DEMOD_STATE_SLEEP) &&
|
||||
(pInteg->pDemod->state != SONY_DEMOD_STATE_ACTIVE)){
|
||||
/* This api is accepted in Sleep and Active states only */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_Tune (pInteg->pDemod, pTuneParam);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (pTuneParam->system == SONY_DTV_SYSTEM_ANY){
|
||||
dtvSystem = SONY_DTV_SYSTEM_DVBS;
|
||||
} else {
|
||||
dtvSystem = pTuneParam->system;
|
||||
}
|
||||
|
||||
if ((pInteg->pTuner) && (pInteg->pTuner->SatTune)) {
|
||||
/* Enable the I2C repeater */
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x01);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = pInteg->pTuner->SatTune (pInteg->pTuner,
|
||||
pTuneParam->centerFreqKHz,
|
||||
dtvSystem,
|
||||
pTuneParam->symbolRateKSps);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Disable the I2C repeater */
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x00);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
|
||||
result = sony_demod_TuneEnd(pInteg->pDemod);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_stopwatch_start (&stopwatch);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (pTuneParam->system == SONY_DTV_SYSTEM_ANY){
|
||||
timeout = ((3600000 + (pTuneParam->symbolRateKSps - 1)) / pTuneParam->symbolRateKSps) + 150;
|
||||
} else {
|
||||
timeout = ((3000000 + (pTuneParam->symbolRateKSps - 1)) / pTuneParam->symbolRateKSps) + 150;
|
||||
}
|
||||
|
||||
isContinue = 1;
|
||||
while (isContinue) {
|
||||
/* Check cancellation. */
|
||||
result = sony_integ_CheckCancellation (pInteg);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_stopwatch_elapsed (&stopwatch, &elapsedTime);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_CheckTSLock (pInteg->pDemod, &lockStatus);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (lockStatus == SONY_DEMOD_LOCK_RESULT_LOCKED) {
|
||||
/* Lock */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
if (elapsedTime > timeout) {
|
||||
isContinue = 0;
|
||||
} else {
|
||||
result = sony_stopwatch_sleep (&stopwatch, SONY_INTEG_DVBS_S2_TUNE_POLLING_INTERVAL);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
/* Additional wait sequence for pilot off signal */
|
||||
uint8_t plscLock = 0;
|
||||
uint8_t pilotOn = 0;
|
||||
result = sony_demod_dvbs_s2_monitor_Pilot (pInteg->pDemod, &plscLock, &pilotOn);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
if ((plscLock != 0) && (pilotOn == 0)) {
|
||||
result = sony_stopwatch_start (&stopwatch);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (pTuneParam->system == SONY_DTV_SYSTEM_ANY){
|
||||
timeout = ((3600000 + (pTuneParam->symbolRateKSps - 1)) / pTuneParam->symbolRateKSps) + 150;
|
||||
} else {
|
||||
timeout = ((3000000 + (pTuneParam->symbolRateKSps - 1)) / pTuneParam->symbolRateKSps) + 150;
|
||||
}
|
||||
|
||||
isContinue = 1;
|
||||
while (isContinue) {
|
||||
/* Check cancellation. */
|
||||
result = sony_integ_CheckCancellation (pInteg);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_stopwatch_elapsed (&stopwatch, &elapsedTime);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbs_s2_CheckTSLock (pInteg->pDemod, &lockStatus);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (lockStatus == SONY_DEMOD_LOCK_RESULT_LOCKED) {
|
||||
/* Lock */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
if (elapsedTime > timeout) {
|
||||
isContinue = 0;
|
||||
} else {
|
||||
result = sony_stopwatch_sleep (&stopwatch, SONY_INTEG_DVBS_S2_TUNE_POLLING_INTERVAL);
|
||||
if (result != SONY_RESULT_OK){
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_TIMEOUT);
|
||||
}
|
||||
|
||||
sony_result_t sony_integ_dvbs_s2_monitor_RFLevel (sony_integ_t * pInteg, int32_t * pRFLeveldB)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_integ_dvbs_s2_monitor_RFLevel");
|
||||
|
||||
if ((!pInteg) || (!pInteg->pDemod) || (!pRFLeveldB)) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if (pInteg->pDemod->state != SONY_DEMOD_STATE_ACTIVE) {
|
||||
/* This api is accepted in Active state only */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
if ((pInteg->pDemod->system != SONY_DTV_SYSTEM_DVBS) &&
|
||||
(pInteg->pDemod->system != SONY_DTV_SYSTEM_DVBS2) &&
|
||||
(pInteg->pDemod->system != SONY_DTV_SYSTEM_ANY)){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
if (!pInteg->pTuner) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
|
||||
}
|
||||
|
||||
if (pInteg->pTuner->rfLevelFuncSat == SONY_TUNER_RFLEVEL_FUNC_READ && pInteg->pTuner->ReadRFLevel) {
|
||||
/* Enable the I2C repeater */
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x01);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = pInteg->pTuner->ReadRFLevel (pInteg->pTuner, pRFLeveldB);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Disable the I2C repeater */
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x00);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
} else if (pInteg->pTuner->rfLevelFuncSat == SONY_TUNER_RFLEVEL_FUNC_CALCFROMAGC
|
||||
&& pInteg->pTuner->CalcRFLevelFromAGC) {
|
||||
uint32_t ifAgc;
|
||||
|
||||
result = sony_demod_dvbs_s2_monitor_IFAGCOut (pInteg->pDemod, &ifAgc);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = pInteg->pTuner->CalcRFLevelFromAGC (pInteg->pTuner, ifAgc, pRFLeveldB);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
} else {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
|
||||
}
|
||||
|
||||
/* dBm * 100 -> dBm * 1000 */
|
||||
*pRFLeveldB *= 10;
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/07/27
|
||||
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_integ_dvbs_s2.h
|
||||
|
||||
This file provides the integration layer interface for DVB-S/S2 specific
|
||||
demodulator functions.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#ifndef SONY_INTEG_DVBS_S2_H
|
||||
#define SONY_INTEG_DVBS_S2_H
|
||||
|
||||
#include "sony_integ.h"
|
||||
#include "sony_demod_dvbs_s2.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Defines
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Polling interval for Tune sequence in ms.
|
||||
*/
|
||||
#define SONY_INTEG_DVBS_S2_TUNE_POLLING_INTERVAL 10
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@brief Performs acquisition to the channel specified by the pTuneParam struct.
|
||||
|
||||
If the channel system is unknown set the pTuneParam.system to
|
||||
::SONY_DTV_SYSTEM_ANY to enable a blind acquisition.
|
||||
In this case the tuned system can be obtained by calling
|
||||
::sony_demod_dvbs_s2_monitor_System.
|
||||
|
||||
Blocks the calling thread until the TS has locked or has timed out.
|
||||
Use ::sony_integ_Cancel to cancel the operation at any time.
|
||||
|
||||
The frequency capture range depends on the target symbol rate and it
|
||||
is automatically handled by hardware.
|
||||
- Symbol Rate >= 20MSps : +/- 10MHz
|
||||
- Symbol Rate < 20MSps : Half of Symbol Rate.(i.e. 5MSps : +/- 2.5MHz)
|
||||
|
||||
However, if Symbol Rate is less than 20 MSps and signal condition is good,
|
||||
then frequency capture range is "equal to Symbol Rate". (i.e. 5MSps : +/- 5MHz)
|
||||
|
||||
@param pInteg The driver instance.
|
||||
@param pTuneParam The parameters required for the tune.
|
||||
|
||||
@return SONY_RESULT_OK if tuned successfully to the channel.
|
||||
*/
|
||||
sony_result_t sony_integ_dvbs_s2_Tune (sony_integ_t * pInteg,
|
||||
sony_dvbs_s2_tune_param_t * pTuneParam);
|
||||
|
||||
/**
|
||||
@brief RF level monitor function.
|
||||
|
||||
This function returns the estimated RF level based on either the demodulator IFAGC
|
||||
level or a tuner internal RSSI monitor. If any compensation for external hardware
|
||||
such as, LNA, attenuators is required, then the user should make adjustment in the
|
||||
corresponding function.
|
||||
|
||||
@param pInteg The driver instance
|
||||
@param pRFLeveldB The RF Level estimation in dB * 1000
|
||||
|
||||
@return SONY_RESULT_OK if successful and pRFLeveldB is valid.
|
||||
*/
|
||||
sony_result_t sony_integ_dvbs_s2_monitor_RFLevel (sony_integ_t * pInteg,
|
||||
int32_t * pRFLeveldB);
|
||||
|
||||
#endif /* SONY_INTEG_DVBS_S2_H */
|
||||
Reference in New Issue
Block a user