提交SMOD ATSC IMX APP版本 V122
This commit is contained in:
+743
@@ -0,0 +1,743 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/07/27
|
||||
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "sony_demod_dvbc.h"
|
||||
#include "sony_demod_dvbc_monitor.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Static Function Prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Configure the demodulator from Sleep to Active for DVB-C
|
||||
*/
|
||||
static sony_result_t SLtoAC(sony_demod_t * pDemod);
|
||||
/**
|
||||
@brief Configure the demodulator for tuner optimisations and bandwidth specific
|
||||
settings.
|
||||
*/
|
||||
static sony_result_t SLtoAC_BandSetting(sony_demod_t * pDemod);
|
||||
|
||||
/**
|
||||
@brief Configure the demodulator from Active DVB-C to Active to DVB-C. Used
|
||||
for changing channel parameters.
|
||||
*/
|
||||
static sony_result_t ACtoAC(sony_demod_t * pDemod);
|
||||
|
||||
/**
|
||||
@brief Configure the demodulator from Active DVB-C to Sleep.
|
||||
*/
|
||||
static sony_result_t ACtoSL(sony_demod_t * pDemod);
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
sony_result_t sony_demod_dvbc_Tune (sony_demod_t * pDemod, sony_dvbc_tune_param_t * pTuneParam)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbc_Tune");
|
||||
|
||||
if ((!pDemod) || (!pTuneParam)) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if ((pDemod->state == SONY_DEMOD_STATE_ACTIVE) && (pDemod->system == SONY_DTV_SYSTEM_DVBC)) {
|
||||
pDemod->bandwidth = pTuneParam->bandwidth;
|
||||
/* Demodulator Active and set to DVB-C mode */
|
||||
result = ACtoAC (pDemod);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
else if((pDemod->state == SONY_DEMOD_STATE_ACTIVE) && (pDemod->system != SONY_DTV_SYSTEM_DVBC)){
|
||||
/* Demodulator Active but not DVB-C mode */
|
||||
result = sony_demod_Sleep (pDemod);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
pDemod->system = SONY_DTV_SYSTEM_DVBC;
|
||||
pDemod->bandwidth = pTuneParam->bandwidth;
|
||||
|
||||
result = SLtoAC (pDemod);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
else if (pDemod->state == SONY_DEMOD_STATE_SLEEP) {
|
||||
/* Demodulator in Sleep mode */
|
||||
pDemod->system = SONY_DTV_SYSTEM_DVBC;
|
||||
pDemod->bandwidth = pTuneParam->bandwidth;
|
||||
|
||||
result = SLtoAC (pDemod);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
else {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
/* Update demodulator state */
|
||||
pDemod->state = SONY_DEMOD_STATE_ACTIVE;
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbc_Sleep (sony_demod_t * pDemod)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbc_Sleep");
|
||||
|
||||
if (!pDemod) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if ((pDemod->state != SONY_DEMOD_STATE_SLEEP) && (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 = ACtoSL (pDemod);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbc_CheckTSLock (sony_demod_t * pDemod,
|
||||
sony_demod_lock_result_t * pLock)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
uint8_t arLock = 0;
|
||||
uint8_t tsLock = 0;
|
||||
uint8_t unlockDetected = 0;
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbc_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_dvbc_monitor_SyncStat (pDemod, &arLock, &tsLock, &unlockDetected);
|
||||
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (pDemod->scanMode) {
|
||||
if (unlockDetected == 1) {
|
||||
*pLock = SONY_DEMOD_LOCK_RESULT_UNLOCKED;
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
}
|
||||
|
||||
if (arLock == 0) {
|
||||
*pLock = SONY_DEMOD_LOCK_RESULT_NOTDETECT;
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
*pLock = tsLock ? SONY_DEMOD_LOCK_RESULT_LOCKED : SONY_DEMOD_LOCK_RESULT_NOTDETECT;
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Static Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
static sony_result_t SLtoAC(sony_demod_t * pDemod)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("SLtoAC");
|
||||
|
||||
if (!pDemod) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Configure TS clock Mode and Frequency */
|
||||
result = sony_demod_SetTSClockModeAndFreq (pDemod, SONY_DTV_SYSTEM_DVBC);
|
||||
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);
|
||||
}
|
||||
|
||||
/* Set demod mode */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x17, 0x04) != 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);
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
/* TADC setting */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x4B, 0x74) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* TADC setting */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x49, 0x00) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* TADC setting */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x18, 0x00) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x11 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x11) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* BBAGC TARGET level setting
|
||||
* slave Bank Addr Bit default Value Name
|
||||
* ----------------------------------------------------------------------------------
|
||||
* <SLV-T> 11h 6Ah [7:0] 8'h50 8'h48 OREG_ITB_DAGC_TRGT[7:0]
|
||||
*/
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x6A, 0x48) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x10 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x10) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (pDemod->tunerOptimize == SONY_DEMOD_TUNER_OPTIMIZE_SONYSILICON) {
|
||||
/* ASCOT setting ON
|
||||
* slave Bank Addr Bit default Value Name
|
||||
* ----------------------------------------------------------------------------------
|
||||
* <SLV-T> 10h A5h [0] 8'h01 8'h01 OREG_ITB_GDEQ_EN
|
||||
*/
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xA5, 0x01) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* ASCOT setting OFF
|
||||
* slave Bank Addr Bit default Value Name
|
||||
* ----------------------------------------------------------------------------------
|
||||
* <SLV-T> 10h A5h [0] 8'h01 8'h00 OREG_ITB_GDEQ_EN
|
||||
*/
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xA5, 0x00) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x11 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x11) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
{
|
||||
/* DVB-C 24MHz Xtal setting
|
||||
* Slave Bank Addr Bit Default Value Name
|
||||
* ---------------------------------------------------------------------------------
|
||||
* <SLV-T> 11h 33h [7:0] 8'hC8 8'h00 OCTL_IFAGC_INITWAIT[7:0]
|
||||
* <SLV-T> 11h 34h [7:0] 8'h02 8'h03 OCTL_IFAGC_MINWAIT[7:0]
|
||||
* <SLV-T> 11h 35h [7:0] 8'h32 8'h3B OCTL_IFAGC_MAXWAIT[7:0]
|
||||
*/
|
||||
const uint8_t data[3] = { 0x00, 0x03, 0x3B };
|
||||
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x33, data, sizeof (data)) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x48 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x48) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* DVB-C 24MHz Xtal setting
|
||||
* slave Bank Addr Bit default Value Name
|
||||
* ----------------------------------------------------------------------------------
|
||||
* <SLV-T> 48h 2Ch [1] 8'h01 8'h03 OREG_SYNCLOCKUSE
|
||||
*/
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x2C, 0x03) != 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);
|
||||
}
|
||||
|
||||
/* TSIF setting
|
||||
* slave Bank Addr Bit default Value Name
|
||||
* ----------------------------------------------------------------------------------
|
||||
* <SLV-T> 00h CEh [0] 8'h01 8'h01 ONOPARITY
|
||||
* <SLV-T> 00h CFh [0] 8'h01 8'h01 ONOPARITY_MANUAL_ON
|
||||
*/
|
||||
{
|
||||
const uint8_t data[] = { 0x01, 0x01 };
|
||||
|
||||
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xCE, data, sizeof (data)) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set tuner and bandwidth specific settings */
|
||||
result = SLtoAC_BandSetting (pDemod);
|
||||
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, SAGC(Hi-Z), TSVALID, TSSYNC, TSCLK) */
|
||||
if (sony_i2c_SetRegisterBits (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x80, 0x08, 0x1F) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Disable HiZ Setting 2 */
|
||||
result = sony_demod_SetTSDataPinHiZ (pDemod, 0);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
static sony_result_t SLtoAC_BandSetting(sony_demod_t * pDemod)
|
||||
{
|
||||
SONY_TRACE_ENTER ("SLtoAC_BandSetting");
|
||||
|
||||
if (!pDemod) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x10 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x10) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
switch (pDemod->bandwidth) {
|
||||
case SONY_DTV_BW_8_MHZ:
|
||||
/*
|
||||
* Filter settings for Sony silicon tuners
|
||||
* slave bank addr bit default name
|
||||
* ------------------------------------------------------------------
|
||||
* <SLV-T> 10h A6h [7:0] 8'h1E OREG_ITB_COEF01[7:0]
|
||||
* <SLV-T> 10h A7h [7:0] 8'h1D OREG_ITB_COEF02[7:0]
|
||||
* <SLV-T> 10h A8h [7:0] 8'h29 OREG_ITB_COEF11[7:0]
|
||||
* <SLV-T> 10h A9h [7:0] 8'hC9 OREG_ITB_COEF12[7:0]
|
||||
* <SLV-T> 10h AAh [7:0] 8'h2A OREG_ITB_COEF21[7:0]
|
||||
* <SLV-T> 10h ABh [7:0] 8'hBA OREG_ITB_COEF22[7:0]
|
||||
* <SLV-T> 10h ACh [7:0] 8'h29 OREG_ITB_COEF31[7:0]
|
||||
* <SLV-T> 10h ADh [7:0] 8'hAD OREG_ITB_COEF32[7:0]
|
||||
* <SLV-T> 10h AEh [7:0] 8'h29 OREG_ITB_COEF41[7:0]
|
||||
* <SLV-T> 10h AFh [7:0] 8'hA4 OREG_ITB_COEF42[7:0]
|
||||
* <SLV-T> 10h B0h [7:0] 8'h29 OREG_ITB_COEF51[7:0]
|
||||
* <SLV-T> 10h B1h [7:0] 8'h9A OREG_ITB_COEF52[7:0]
|
||||
* <SLV-T> 10h B2h [7:0] 8'h28 OREG_ITB_COEF61[7:0]
|
||||
* <SLV-T> 10h B3h [7:0] 8'h9E OREG_ITB_COEF62[7:0]
|
||||
*/
|
||||
if (pDemod->tunerOptimize == SONY_DEMOD_TUNER_OPTIMIZE_SONYSILICON) {
|
||||
const uint8_t itbCoef[14] = {
|
||||
/* COEF01 COEF02 COEF11 COEF12 COEF21 COEF22 COEF31 COEF32 COEF41 COEF42 COEF51 COEF52 COEF61 COEF62 */
|
||||
0x29, 0x9A, 0x28, 0x9E, 0x2F, 0xB9, 0x27, 0xA5, 0x28, 0xA9, 0x2B, 0xB0, 0x08, 0xD6
|
||||
};
|
||||
|
||||
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xA6, itbCoef, 14) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
/*
|
||||
* <IF freq setting>
|
||||
* slave bank addr bit default value name
|
||||
* ---------------------------------------------------------------------------------
|
||||
* <SLV-T> 10h B6h [7:0] 8'h1F user defined OREG_DNCNV_LOFRQ_T[23:16]
|
||||
* <SLV-T> 10h B7h [7:0] 8'h38 user defined OREG_DNCNV_LOFRQ_T[15:8]
|
||||
* <SLV-T> 10h B8h [7:0] 8'h32 user defined OREG_DNCNV_LOFRQ_T[7:0]
|
||||
*/
|
||||
uint8_t data[3];
|
||||
data[0] = (uint8_t) ((pDemod->iffreqConfig.configDVBC_8 >> 16) & 0xFF);
|
||||
data[1] = (uint8_t) ((pDemod->iffreqConfig.configDVBC_8 >> 8) & 0xFF);
|
||||
data[2] = (uint8_t) (pDemod->iffreqConfig.configDVBC_8 & 0xFF);
|
||||
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xB6, data, sizeof (data)) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* IMR Filter Bandwidth setting
|
||||
* slave Bank Addr Bit default Value Name
|
||||
* ---------------------------------------------------------------------------------
|
||||
* <SLV-T> 11h A3h [4:0] 8'h00 8'h00 OREG_IMR_FORCE_CHANNEL_WIDTH,1'b0,OREG_IMR_CHANNEL_WIDTH[2:0]
|
||||
*/
|
||||
/* Set SLV-T Bank : 0x11 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x11) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xA3, 0x00) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
{
|
||||
/* The settings of Symbol rate search range
|
||||
* slave Bank Addr Bit default Value Name
|
||||
* ---------------------------------------------------------------------------------
|
||||
* <SLV-T> 40h 26h [3:0] 8'h09 tsrate1 OREG_TRIAL_SRATE0[11:8]
|
||||
* <SLV-T> 40h 27h [7:0] 8'h9A tsrate2 OREG_TRIAL_SRATE0[7:0]
|
||||
* <SLV-T> 40h 28h [3:0] 8'h00 tsrate3 OREG_TRIAL_SRATE1[11:8]
|
||||
* <SLV-T> 40h 29h [7:0] 8'hEE tsrate4 OREG_TRIAL_SRATE1[7:0]
|
||||
*/
|
||||
|
||||
const uint8_t symRate[4] = {
|
||||
/* tsrate1 tsrate2 tsrate3 tsrate4 */
|
||||
0x09, 0x9A, 0x00, 0xEE
|
||||
};
|
||||
|
||||
/* Set SLV-T Bank : 0x40 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x40) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x26, symRate, 4) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SONY_DTV_BW_7_MHZ:
|
||||
/*
|
||||
* Filter settings for Sony silicon tuners
|
||||
* slave bank addr bit default name
|
||||
* ------------------------------------------------------------------
|
||||
* <SLV-T> 10h A6h [7:0] 8'h1E OREG_ITB_COEF01[7:0]
|
||||
* <SLV-T> 10h A7h [7:0] 8'h1D OREG_ITB_COEF02[7:0]
|
||||
* <SLV-T> 10h A8h [7:0] 8'h29 OREG_ITB_COEF11[7:0]
|
||||
* <SLV-T> 10h A9h [7:0] 8'hC9 OREG_ITB_COEF12[7:0]
|
||||
* <SLV-T> 10h AAh [7:0] 8'h2A OREG_ITB_COEF21[7:0]
|
||||
* <SLV-T> 10h ABh [7:0] 8'hBA OREG_ITB_COEF22[7:0]
|
||||
* <SLV-T> 10h ACh [7:0] 8'h29 OREG_ITB_COEF31[7:0]
|
||||
* <SLV-T> 10h ADh [7:0] 8'hAD OREG_ITB_COEF32[7:0]
|
||||
* <SLV-T> 10h AEh [7:0] 8'h29 OREG_ITB_COEF41[7:0]
|
||||
* <SLV-T> 10h AFh [7:0] 8'hA4 OREG_ITB_COEF42[7:0]
|
||||
* <SLV-T> 10h B0h [7:0] 8'h29 OREG_ITB_COEF51[7:0]
|
||||
* <SLV-T> 10h B1h [7:0] 8'h9A OREG_ITB_COEF52[7:0]
|
||||
* <SLV-T> 10h B2h [7:0] 8'h28 OREG_ITB_COEF61[7:0]
|
||||
* <SLV-T> 10h B3h [7:0] 8'h9E OREG_ITB_COEF62[7:0]
|
||||
*/
|
||||
if (pDemod->tunerOptimize == SONY_DEMOD_TUNER_OPTIMIZE_SONYSILICON) {
|
||||
const uint8_t itbCoef[14] = {
|
||||
/* COEF01 COEF02 COEF11 COEF12 COEF21 COEF22 COEF31 COEF32 COEF41 COEF42 COEF51 COEF52 COEF61 COEF62 */
|
||||
0x29, 0x9A, 0x28, 0x9E, 0x2F, 0xB9, 0x27, 0xA5, 0x28, 0xA9, 0x2B, 0xB0, 0x08, 0xD6
|
||||
};
|
||||
|
||||
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xA6, itbCoef, 14) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
/*
|
||||
* <IF freq setting>
|
||||
* slave bank addr bit default value name
|
||||
* ---------------------------------------------------------------------------------
|
||||
* <SLV-T> 10h B6h [7:0] 8'h1F user defined OREG_DNCNV_LOFRQ_T[23:16]
|
||||
* <SLV-T> 10h B7h [7:0] 8'h38 user defined OREG_DNCNV_LOFRQ_T[15:8]
|
||||
* <SLV-T> 10h B8h [7:0] 8'h32 user defined OREG_DNCNV_LOFRQ_T[7:0]
|
||||
*/
|
||||
uint8_t data[3];
|
||||
data[0] = (uint8_t) ((pDemod->iffreqConfig.configDVBC_7 >> 16) & 0xFF);
|
||||
data[1] = (uint8_t) ((pDemod->iffreqConfig.configDVBC_7 >> 8) & 0xFF);
|
||||
data[2] = (uint8_t) (pDemod->iffreqConfig.configDVBC_7 & 0xFF);
|
||||
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xB6, data, sizeof (data)) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* IMR Filter Bandwidth setting
|
||||
* slave Bank Addr Bit default Value Name
|
||||
* ---------------------------------------------------------------------------------
|
||||
* <SLV-T> 11h A3h [4:0] 8'h00 8'h00 OREG_IMR_FORCE_CHANNEL_WIDTH,1'b0,OREG_IMR_CHANNEL_WIDTH[2:0]
|
||||
*/
|
||||
/* Set SLV-T Bank : 0x11 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x11) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xA3, 0x00) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
{
|
||||
/* The settings of Symbol rate search range
|
||||
* slave Bank Addr Bit default Value Name
|
||||
* ---------------------------------------------------------------------------------
|
||||
* <SLV-T> 40h 26h [3:0] 8'h09 tsrate1 OREG_TRIAL_SRATE0[11:8]
|
||||
* <SLV-T> 40h 27h [7:0] 8'h9A tsrate2 OREG_TRIAL_SRATE0[7:0]
|
||||
* <SLV-T> 40h 28h [3:0] 8'h00 tsrate3 OREG_TRIAL_SRATE1[11:8]
|
||||
* <SLV-T> 40h 29h [7:0] 8'hEE tsrate4 OREG_TRIAL_SRATE1[7:0]
|
||||
*/
|
||||
|
||||
const uint8_t symRate[4] = {
|
||||
/* tsrate1 tsrate2 tsrate3 tsrate4 */
|
||||
0x08, 0x66, 0x00, 0xEE
|
||||
};
|
||||
|
||||
/* Set SLV-T Bank : 0x40 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x40) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x26, symRate, 4) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SONY_DTV_BW_6_MHZ:
|
||||
/*
|
||||
* Filter settings for Sony silicon tuners
|
||||
* slave bank addr bit default name
|
||||
* ------------------------------------------------------------------
|
||||
* <SLV-T> 10h A6h [7:0] 8'h1E OREG_ITB_COEF01[7:0]
|
||||
* <SLV-T> 10h A7h [7:0] 8'h1D OREG_ITB_COEF02[7:0]
|
||||
* <SLV-T> 10h A8h [7:0] 8'h29 OREG_ITB_COEF11[7:0]
|
||||
* <SLV-T> 10h A9h [7:0] 8'hC9 OREG_ITB_COEF12[7:0]
|
||||
* <SLV-T> 10h AAh [7:0] 8'h2A OREG_ITB_COEF21[7:0]
|
||||
* <SLV-T> 10h ABh [7:0] 8'hBA OREG_ITB_COEF22[7:0]
|
||||
* <SLV-T> 10h ACh [7:0] 8'h29 OREG_ITB_COEF31[7:0]
|
||||
* <SLV-T> 10h ADh [7:0] 8'hAD OREG_ITB_COEF32[7:0]
|
||||
* <SLV-T> 10h AEh [7:0] 8'h29 OREG_ITB_COEF41[7:0]
|
||||
* <SLV-T> 10h AFh [7:0] 8'hA4 OREG_ITB_COEF42[7:0]
|
||||
* <SLV-T> 10h B0h [7:0] 8'h29 OREG_ITB_COEF51[7:0]
|
||||
* <SLV-T> 10h B1h [7:0] 8'h9A OREG_ITB_COEF52[7:0]
|
||||
* <SLV-T> 10h B2h [7:0] 8'h28 OREG_ITB_COEF61[7:0]
|
||||
* <SLV-T> 10h B3h [7:0] 8'h9E OREG_ITB_COEF62[7:0]
|
||||
*/
|
||||
if (pDemod->tunerOptimize == SONY_DEMOD_TUNER_OPTIMIZE_SONYSILICON) {
|
||||
const uint8_t itbCoef[14] = {
|
||||
/* COEF01 COEF02 COEF11 COEF12 COEF21 COEF22 COEF31 COEF32 COEF41 COEF42 COEF51 COEF52 COEF61 COEF62 */
|
||||
0x31, 0xA8, 0x29, 0x9B, 0x27, 0x9C, 0x28, 0x9E, 0x29, 0xA4, 0x29, 0xA2, 0x29, 0xA8
|
||||
};
|
||||
|
||||
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xA6, itbCoef, 14) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
/*
|
||||
* <IF freq setting>
|
||||
* slave bank addr bit default value name
|
||||
* ---------------------------------------------------------------------------------
|
||||
* <SLV-T> 10h B6h [7:0] 8'h1F user defined OREG_DNCNV_LOFRQ_T[23:16]
|
||||
* <SLV-T> 10h B7h [7:0] 8'h38 user defined OREG_DNCNV_LOFRQ_T[15:8]
|
||||
* <SLV-T> 10h B8h [7:0] 8'h32 user defined OREG_DNCNV_LOFRQ_T[7:0]
|
||||
*/
|
||||
uint8_t data[3];
|
||||
data[0] = (uint8_t) ((pDemod->iffreqConfig.configDVBC_6 >> 16) & 0xFF);
|
||||
data[1] = (uint8_t) ((pDemod->iffreqConfig.configDVBC_6 >> 8) & 0xFF);
|
||||
data[2] = (uint8_t) (pDemod->iffreqConfig.configDVBC_6 & 0xFF);
|
||||
|
||||
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xB6, data, sizeof (data)) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* IMR Filter Bandwidth setting
|
||||
* slave Bank Addr Bit default Value Name
|
||||
* ---------------------------------------------------------------------------------
|
||||
* <SLV-T> 11h A3h [4:0] 8'h00 8'h14 OREG_IMR_FORCE_CHANNEL_WIDTH,1'b0,OREG_IMR_CHANNEL_WIDTH[2:0]
|
||||
*/
|
||||
/* Set SLV-T Bank : 0x11 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x11) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xA3, 0x14) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
{
|
||||
/* The settings of Symbol rate search range
|
||||
* slave Bank Addr Bit default Value Name
|
||||
* ---------------------------------------------------------------------------------
|
||||
* <SLV-T> 40h 26h [3:0] 8'h09 tsrate1 OREG_TRIAL_SRATE0[11:8]
|
||||
* <SLV-T> 40h 27h [7:0] 8'h9A tsrate2 OREG_TRIAL_SRATE0[7:0]
|
||||
* <SLV-T> 40h 28h [3:0] 8'h00 tsrate3 OREG_TRIAL_SRATE1[11:8]
|
||||
* <SLV-T> 40h 29h [7:0] 8'hEE tsrate4 OREG_TRIAL_SRATE1[7:0]
|
||||
*/
|
||||
|
||||
const uint8_t symRate[4] = {
|
||||
/* tsrate1 tsrate2 tsrate3 tsrate4 */
|
||||
0x07, 0x33, 0x00, 0xEE
|
||||
};
|
||||
|
||||
/* Set SLV-T Bank : 0x40 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x40) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x26, symRate, 4) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
static sony_result_t ACtoAC(sony_demod_t * pDemod)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("ACtoAC");
|
||||
|
||||
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 tuner and bandwidth specific settings */
|
||||
result = SLtoAC_BandSetting (pDemod);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
static sony_result_t ACtoSL(sony_demod_t * pDemod)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
SONY_TRACE_ENTER ("ACtoSL");
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/* cancel DVB-C Demod parameter setting
|
||||
* slave Bank Addr Bit default Value Name
|
||||
* ---------------------------------------------------------------------------------
|
||||
* <SLV-T> 11h A3h [4:0] 8'h00 8'h00 OREG_IMR_FORCE_CHANNEL_WIDTH,1'b0,OREG_IMR_CHANNEL_WIDTH[2:0]
|
||||
* <SLV-T> 48h 2Ch [1] 8'h01 8'h01 OREG_SYNCLOCKUSE
|
||||
*/
|
||||
/* Set SLV-T Bank : 0x11 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x11) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xA3, 0x00) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x48 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x48) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x2C, 0x01) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
/* TADC 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);
|
||||
}
|
||||
|
||||
/* TADC setting */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x49, 0x33) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* TADC setting */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x4B, 0x21) != 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);
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/07/27
|
||||
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbc.h
|
||||
|
||||
This file provides the demodulator control interface specific to DVB-C.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SONY_DEMOD_DVBC_H
|
||||
#define SONY_DEMOD_DVBC_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_demod.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Structs
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief The tune parameters for a DVB-C signal
|
||||
*/
|
||||
typedef struct sony_dvbc_tune_param_t{
|
||||
uint32_t centerFreqKHz; /**< Center frequency in kHz of the DVB-C channel */
|
||||
|
||||
/**
|
||||
@brief Bandwidth of the DVB-C channel
|
||||
*/
|
||||
sony_dtv_bandwidth_t bandwidth;
|
||||
|
||||
}sony_dvbc_tune_param_t;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Enable acquisition on the demodulator for DVB-C channels.
|
||||
|
||||
Called from the integration layer ::sony_integ_dvbc_Tune API.
|
||||
|
||||
@param pDemod The demodulator instance
|
||||
@param pTuneParam The tune parameters.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc_Tune (sony_demod_t * pDemod, sony_dvbc_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_dvbc_Sleep (sony_demod_t * pDemod);
|
||||
|
||||
/**
|
||||
@brief Check DVB-C TS lock status.
|
||||
|
||||
@note This API is for checking lock status in tuning stage.
|
||||
After tuning (while receiving the signal),
|
||||
please use sony_demod_dvbc_monitor_SyncStat instead
|
||||
to check current lock status.
|
||||
|
||||
@param pDemod The demodulator instance
|
||||
@param pLock TS lock state
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc_CheckTSLock (sony_demod_t * pDemod,
|
||||
sony_demod_lock_result_t * pLock);
|
||||
|
||||
#endif /* SONY_DEMOD_DVBC_H */
|
||||
+4111
File diff suppressed because it is too large
Load Diff
+343
@@ -0,0 +1,343 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/07/27
|
||||
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbc2.h
|
||||
|
||||
This file provides the demodulator control interface specific to DVB-C2.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SONY_DEMOD_DVBC2_H
|
||||
#define SONY_DEMOD_DVBC2_H
|
||||
|
||||
#include "sony_common.h"
|
||||
#include "sony_dvbc2.h"
|
||||
#include "sony_demod.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Defines
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief The duration in ms between sequential demod lock checks in the scan sequence
|
||||
*/
|
||||
#define SONY_DEMOD_DVBC2_WAIT_DEMOD_LOCK_INTERVAL 10
|
||||
|
||||
/**
|
||||
@brief 2s timeout for demod lock in the scan sequence
|
||||
*/
|
||||
#define SONY_DEMOD_DVBC2_WAIT_DEMOD_LOCK 2000
|
||||
|
||||
/**
|
||||
@brief The duration in ms between sequential L1 data ready checks in the scan sequence
|
||||
*/
|
||||
#define SONY_DEMOD_DVBC2_WAIT_L1_DATA_INTERVAL 10
|
||||
|
||||
/**
|
||||
@brief 1s timeout for L1 data ready checks in the scan sequence
|
||||
*/
|
||||
#define SONY_DEMOD_DVBC2_WAIT_L1_DATA 1000
|
||||
|
||||
/**
|
||||
@brief The duration in ms between sequential Preset Ready checks in the tune sequence
|
||||
*/
|
||||
#define SONY_DEMOD_DVBC2_WAIT_PRESET_READY_INTERVAL 10
|
||||
|
||||
/**
|
||||
@brief 2s timeout for Preset Ready in the tune sequence
|
||||
*/
|
||||
#define SONY_DEMOD_DVBC2_WAIT_PRESET_READY 2000
|
||||
|
||||
/**
|
||||
@brief Number of bytes for a single preset
|
||||
*/
|
||||
#define SONY_DEMOD_DVBC2_PS_SIZE 23
|
||||
|
||||
/**
|
||||
@brief Number of bytes of data for each individual notch
|
||||
*/
|
||||
#define SONY_DEMOD_DVBC2_NUM_REGS_PER_NOTCH 5
|
||||
|
||||
#define SONY_DEMOD_DVBC2_FILTER1 0 /**< Co & Adjecsant channel Supression filter 1 */
|
||||
#define SONY_DEMOD_DVBC2_FILTER2 1 /**< Co & Adjecsant channel Supression filter 2 */
|
||||
#define SONY_DEMOD_DVBC2_FILTER3 2 /**< Co & Adjecsant channel Supression filter 3 */
|
||||
#define SONY_DEMOD_DVBC2_FILTER4 3 /**< Co & Adjecsant channel Supression filter 4 */
|
||||
|
||||
#define SONY_DVBC2_OFDM_CAR_MAX 3408 /**< Maximum number of OFDM carriers */
|
||||
#define SONY_DVBC2_OFDM_CAR_CENTER (SONY_DVBC2_OFDM_CAR_MAX/2) /**< Center point of OFDM carriers */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Enumerations
|
||||
------------------------------------------------------------------------------*/
|
||||
/** @brief DVB-C2 Get Tune Parameter Sequence states. */
|
||||
typedef enum {
|
||||
SONY_DEMOD_DVBC2_GET_TUNE_PARAMS_STAGE_1, /**< Calls ReleasePreset, DemodSetting1 : Requests RF tune */
|
||||
SONY_DEMOD_DVBC2_GET_TUNE_PARAMS_STAGE_2, /**< Calls CheckDemodLock : Requests Sleep */
|
||||
SONY_DEMOD_DVBC2_GET_TUNE_PARAMS_STAGE_3, /**< Calls Change1stTrial : Requests N/A */
|
||||
SONY_DEMOD_DVBC2_GET_TUNE_PARAMS_STAGE_4, /**< Calls CheckL1DataReady, GetDataSliceIDList, GetNotches, CalculateNextChannelFrequency : Requests Sleep */
|
||||
SONY_DEMOD_DVBC2_GET_TUNE_PARAMS_STAGE_5, /**< Calls SetNextDS : Requests N/A */
|
||||
SONY_DEMOD_DVBC2_GET_TUNE_PARAMS_STAGE_6, /**< Calls CheckL1DataReady, GetTuneParams : Requests Sleep, loops back to stage 5 for each DS */
|
||||
SONY_DEMOD_DVBC2_GET_TUNE_PARAMS_STAGE_7, /**< Calls N/A : Requests N/A. */
|
||||
SONY_DEMOD_DVBC2_GET_TUNE_PARAMS_FINALIZE /**< Calls N/A : Requests N/A */
|
||||
} sony_demod_dvbc2_get_tune_params_seq_state_t;
|
||||
|
||||
|
||||
/** @brief DVB-C2 Tune Sequence states. */
|
||||
typedef enum {
|
||||
SONY_DEMOD_DVBC2_TUNE_INITIALIZE = 0, /**< Calls ReleasePreset : Requests Tune RF */
|
||||
SONY_DEMOD_DVBC2_TUNE_NON_DSDS_STAGE_1, /**< Calls DemodSetting2 : Requests N/A */
|
||||
SONY_DEMOD_DVBC2_TUNE_DSDS_STAGE_1, /**< Calls DemodSetting3_1 : Requests N/A */
|
||||
SONY_DEMOD_DVBC2_TUNE_DSDS_STAGE_2, /**< Calls CheckPresetReady1_1 : Requests Sleep */
|
||||
SONY_DEMOD_DVBC2_TUNE_DSDS_STAGE_3, /**< Calls DemodSetting3_2 : Requests N/A */
|
||||
SONY_DEMOD_DVBC2_TUNE_DSDS_STAGE_4, /**< Calls CheckPresetReady1_2 : Requests Sleep */
|
||||
SONY_DEMOD_DVBC2_TUNE_DSDS_STAGE_5, /**< Calls Change1stTrial, CalculateCenterFrequency, DemodSetting4 : Requests N/A */
|
||||
SONY_DEMOD_DVBC2_TUNE_DSDS_STAGE_6, /**< Calls CheckPresetReady2 : Requests Sleep */
|
||||
SONY_DEMOD_DVBC2_TUNE_DSDS_STAGE_7, /**< Calls Change1stTrial, CalculatePresetValue : Requests Tune RF */
|
||||
SONY_DEMOD_DVBC2_TUNE_DSDS_STAGE_8, /**< Calls DemodPreset : Requests N/A */
|
||||
SONY_DEMOD_DVBC2_TUNE_WAIT_LOCK, /**< Calls CheckDemodLock [scan], CheckTSLock [tune] : Requests Sleep */
|
||||
SONY_DEMOD_DVBC2_TUNE_CHANGE_FIRST_TRIAL, /**< Calls Change1stTrial : Requests N/A */
|
||||
SONY_DEMOD_DVBC2_TUNE_FINALIZE /**< Calls N/A : Requests N/A */
|
||||
} sony_demod_dvbc2_tune_seq_state_t;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Structs
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief The tune parameters for a DVB-C2 signal
|
||||
*/
|
||||
typedef struct sony_dvbc2_tune_param_t {
|
||||
/**
|
||||
@brief For normal DS this is the absolute frequency of the specified DS.
|
||||
For Dependent Static DS this is the C2 system tuning frequency.
|
||||
*/
|
||||
uint32_t c2TuningFrequencyKHz;
|
||||
|
||||
/**
|
||||
@brief Bandwidth of the C2 channel
|
||||
*/
|
||||
sony_dtv_bandwidth_t bandwidth;
|
||||
|
||||
/**
|
||||
@brief The Data Slice ID to select in acquisition.
|
||||
*/
|
||||
uint8_t dataSliceId;
|
||||
|
||||
/**
|
||||
@brief The PLP ID to select in acquisition.
|
||||
*/
|
||||
uint8_t dataPLPId;
|
||||
|
||||
/**
|
||||
@brief Boolean value indicating if dependent Data Slice
|
||||
*/
|
||||
uint8_t isDependentStaticDS;
|
||||
|
||||
/**
|
||||
@brief The frequency that will be used to configure the tuner. This can
|
||||
be used in combination with a different frequency in c2TuningFrequencyKHz
|
||||
to compensate for IF offsets in the RF part. If set to 0 the
|
||||
c2TuningFrequencyKHz or internally calculated c2TuningFrequencyDSDSKHz
|
||||
will be used for the RF part.
|
||||
*/
|
||||
uint32_t rfTuningFrequencyKHz;
|
||||
} sony_dvbc2_tune_param_t;
|
||||
|
||||
/**
|
||||
@brief DVBC2 notch position in carriers
|
||||
*/
|
||||
typedef struct sony_demod_dvbc2_notch_data_t {
|
||||
uint32_t notchStart; /**< Notch start frequency (in carriers) relative to the whole spectrum */
|
||||
uint32_t notchEnd; /**< Notch end frequency (in carriers) relative to the whole spectrum */
|
||||
} sony_demod_dvbc2_notch_data_t;
|
||||
|
||||
/**
|
||||
@brief DVB-C2 Get Tune Params Sequence structure.
|
||||
*/
|
||||
typedef struct sony_demod_dvbc2_get_tune_params_seq_t {
|
||||
uint8_t running; /**< Sequencer running / complete flag. */
|
||||
sony_demod_dvbc2_get_tune_params_seq_state_t state; /**< Sequence state. Internal use only. */
|
||||
sony_result_t loopResult; /**< Result code for the last wait loop */
|
||||
sony_dvbc2_tune_param_t * tuneParams; /**< Pointer to tune parameter array */
|
||||
uint16_t tuneParamIndex; /**< Current index in the tuneParams array */
|
||||
uint32_t frequencyKHz; /**< Channel frequency */
|
||||
|
||||
/* Scan data storage */
|
||||
uint8_t ds[SONY_DVBC2_DS_MAX]; /**< DSLICE ID information */
|
||||
uint8_t numDs; /**< Number of dataslices */
|
||||
uint8_t currentDsIndex; /**< Current data slice index in the ds array */
|
||||
sony_demod_dvbc2_notch_data_t notch[SONY_DVBC2_NUM_NOTCH_MAX]; /**< Notch data */
|
||||
uint8_t numNotch; /**< Number of notches */
|
||||
uint32_t sf; /**< Start frequency */
|
||||
uint8_t gi; /**< Guard Interval */
|
||||
uint8_t bnw; /**< Notch width */
|
||||
uint16_t dx; /**< Carrier spacing */
|
||||
uint32_t nextChannelFrequency; /**< Next frequency for the scan to use instead of the specified step */
|
||||
uint32_t systemTuningFrequency; /**< System tuning frequency kHz */
|
||||
uint32_t minAccumulatedOverlap; /**< Minimum overlap of notch and DS, used to determine system tuning frequency */
|
||||
|
||||
/* state machine time related storage */
|
||||
uint32_t sleepTime; /**< Sleep duration requested from demod layer to integration */
|
||||
uint32_t currentTime; /**< Current time elapsed from sequence start */
|
||||
uint32_t loopStartTime; /**< Time that the current loop operation started */
|
||||
} sony_demod_dvbc2_get_tune_params_seq_t;
|
||||
|
||||
/**
|
||||
@brief DVB-C2 Tune Sequence structure.
|
||||
*/
|
||||
typedef struct sony_demod_dvbc2_tune_seq_t {
|
||||
/* These members are used by the integration layer */
|
||||
uint8_t running; /**< Sequencer running / complete flag. */
|
||||
uint8_t tuneRequired; /**< RF tune required flag */
|
||||
uint32_t rfFrequency; /**< Next RF frequency to be tuned to */
|
||||
sony_result_t lockResult; /**< Lock result from the wait TS lock function */
|
||||
uint32_t sleepTime; /**< Sleep duration requested from demod layer to integration */
|
||||
uint32_t currentTime; /**< Current time elapsed from sequence start */
|
||||
uint32_t loopStartTime; /**< Time that the current loop operation started */
|
||||
|
||||
/* Specified tune parameters */
|
||||
uint32_t tuneParamCenterFreq; /**< Center frequency parameter from tune params */
|
||||
sony_dtv_bandwidth_t bandwidth; /**< Bandwidth of RF to tune to */
|
||||
sony_dvbc2_tune_param_t * pTuneData; /**< C2 dependent tune parameters */
|
||||
|
||||
/* Tuning Algorithm */
|
||||
sony_demod_dvbc2_tune_seq_state_t state; /**< Sequence state. Internal use only. */
|
||||
uint8_t filterSelect; /**< Index of filter range to use */
|
||||
uint16_t casDagcTarget; /**< Target value of CAS DAGC */
|
||||
int16_t crcg2BnFreqOfst; /**< CRCG offset */
|
||||
uint8_t trcgNominalRate[5]; /**< TRL nominal rate */
|
||||
uint8_t ps[SONY_DEMOD_DVBC2_PS_SIZE]; /**< Preset data */
|
||||
uint32_t centerFreq; /**< Calculated center frequency demodulator parameter used for DSDS */
|
||||
uint32_t tunePosDSDS; /**< C2 Tune Position DSDS represented in carriers */
|
||||
} sony_demod_dvbc2_tune_seq_t;
|
||||
/*-----------------------------------------------------------------------------
|
||||
Functions
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@brief Initialize the sony_demod_dvbc2_get_tune_params_seq_t structure
|
||||
|
||||
@param pDemod The demod instance.
|
||||
@param pGetTuneParamsSeq Internal structure used to store scan parameters and result data.
|
||||
@param channelFrequencyKHz Centre frequency of the channel to detect tune parameters.
|
||||
@param pTuneParamArray Pointer to the first element of the tune parameter array.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_InitGetTuneParamsSeq (sony_demod_t * pDemod,
|
||||
sony_demod_dvbc2_get_tune_params_seq_t * pGetTuneParamsSeq,
|
||||
uint32_t channelFrequencyKHz,
|
||||
sony_dvbc2_tune_param_t * pTuneParamArray);
|
||||
|
||||
/**
|
||||
@brief Initialize the sony_demod_dvbc2_tune_seq_t structure
|
||||
|
||||
@param pDemod The demod instance.
|
||||
@param pTuneParams Tune parameters structure, populated by the calling application.
|
||||
@param pTuneSeq Internal structure used to store tune parameters and result data.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_InitTuneSeq (sony_demod_t * pDemod,
|
||||
sony_dvbc2_tune_param_t * pTuneParams,
|
||||
sony_demod_dvbc2_tune_seq_t * pTuneSeq);
|
||||
|
||||
/**
|
||||
@brief State machine based function used to step through the get tune parameters process
|
||||
at the specified centre frequency.
|
||||
|
||||
This function is cranked by the ::sony_integ_dvbc2_GetChannelTuneParameters function
|
||||
in sony_integ_dvbc2.c.
|
||||
|
||||
@param pDemod The demod instance.
|
||||
@param pGetTuneParamsSeq Internal structure used to store scan parameters and result data.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_GetTuneParamsSeq (sony_demod_t * pDemod,
|
||||
sony_demod_dvbc2_get_tune_params_seq_t * pGetTuneParamsSeq);
|
||||
|
||||
/**
|
||||
@brief State machine based function used to step through the tune process for a specified C2 channel.
|
||||
|
||||
This function is cranked by the ::sony_integ_dvbc2_Tune
|
||||
function in sony_integ_dvbc2.c.
|
||||
|
||||
@param pDemod The demod instance.
|
||||
@param pTuneSeq Internal structure used to store scan parameters and result data.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_TuneSeq (sony_demod_t * pDemod,
|
||||
sony_demod_dvbc2_tune_seq_t * pTuneSeq);
|
||||
|
||||
/**
|
||||
@brief Configures the demodulator for acquisition to DVB-C2 channels based on the parameters provided.
|
||||
|
||||
Called from ::sony_integ_dvbc2_Tune at various stages in the Tune sequence.
|
||||
|
||||
@param pDemod Instance of demod control struct
|
||||
@param pTuneParam Channel tune parameters
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_Tune (sony_demod_t * pDemod,
|
||||
sony_dvbc2_tune_param_t * pTuneParam);
|
||||
|
||||
/**
|
||||
@brief Put the demodulator into sleep mode, called from ::sony_integ_Sleep.
|
||||
|
||||
@param pDemod Instance of demod control struct
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_Sleep (sony_demod_t * pDemod);
|
||||
|
||||
/**
|
||||
@brief Check DVB-C2 demodulator lock status.
|
||||
|
||||
@note This API is for checking lock status in tuning stage.
|
||||
After tuning (while receiving the signal),
|
||||
please use sony_demod_dvbc2_monitor_SyncStat instead
|
||||
to check current lock status.
|
||||
|
||||
@param pDemod Instance of demod control struct
|
||||
@param pLock Demod lock state
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_CheckDemodLock (sony_demod_t * pDemod,
|
||||
sony_demod_lock_result_t * pLock);
|
||||
|
||||
/**
|
||||
@brief Check DVB-C2 TS lock status.
|
||||
|
||||
@note This API is for checking lock status in tuning stage.
|
||||
After tuning (while receiving the signal),
|
||||
please use sony_demod_dvbc2_monitor_SyncStat instead
|
||||
to check current lock status.
|
||||
|
||||
@param pDemod Instance of demod control struct
|
||||
@param pLock TS lock state
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_CheckTSLock (sony_demod_t * pDemod,
|
||||
sony_demod_lock_result_t * pLock);
|
||||
|
||||
/**
|
||||
@brief Set the PLP ID requested from the current data slice.
|
||||
|
||||
Called in DVB-C2 scan when current data slice contains multiple PLP,
|
||||
meaning RF re-tune is not required.
|
||||
|
||||
@param pDemod Instance of demod control struct
|
||||
@param plpId PLP ID.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_SetPlpId (sony_demod_t * pDemod, uint8_t plpId);
|
||||
|
||||
#endif /* SONY_DEMOD_DVBC2_H */
|
||||
+1984
File diff suppressed because it is too large
Load Diff
+270
@@ -0,0 +1,270 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/07/27
|
||||
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbc2_monitor.h
|
||||
|
||||
This file provides the DVB-C2 demodulator monitor interface.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SONY_DEMOD_DVBC2_MONITOR_H
|
||||
#define SONY_DEMOD_DVBC2_MONITOR_H
|
||||
|
||||
#include "sony_demod.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Monitor the IFAGC value of the C2 demodulator.
|
||||
|
||||
Actual dB gain dependent on attached tuner.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pIFAGC The IFAGC output register value. Range 0x000 - 0xFFF. Unitless.
|
||||
|
||||
@return SONY_RESULT_OK if pIFAGC is valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_monitor_IFAGCOut (sony_demod_t * pDemod,
|
||||
uint32_t * pIFAGC);
|
||||
|
||||
/**
|
||||
@brief Monitors the channel spectrum sense.
|
||||
|
||||
To ensure correct polarity detection
|
||||
please use the ::SONY_DEMOD_CONFIG_SPECTRUM_INV config option in
|
||||
::sony_demod_SetConfig to select the appropriate spectrum inversion
|
||||
for the tuner output.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pSense Indicates the spectrum sense.
|
||||
|
||||
@return SONY_RESULT_OK if successful and pSense is valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_monitor_SpectrumSense (sony_demod_t * pDemod,
|
||||
sony_demod_terr_cable_spectrum_sense_t * pSense);
|
||||
|
||||
/**
|
||||
@brief Monitors the detected carrier offset of the currently tuned channel, using
|
||||
the continual pilot (CP) estimation from the demodulator.
|
||||
|
||||
To get the estimated center frequency of the current channel:
|
||||
Freq_Est = Freq_Tune + pOffset;
|
||||
|
||||
This function will compensate for an inverting tuner architecture if the
|
||||
demodulator has been configured accordingly using ::SONY_DEMOD_CONFIG_SPECTRUM_INV
|
||||
config option for ::sony_demod_SetConfig.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pOffset The detected carrier offset in Hz.
|
||||
|
||||
@return SONY_RESULT_OK if pOffset is valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_monitor_CarrierOffset (sony_demod_t * pDemod,
|
||||
int32_t * pOffset);
|
||||
|
||||
/**
|
||||
@brief Monitor the SNR of the DVB-C2 demodulator, clipped to a
|
||||
maximum of 50dB.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pSNR The returned SNR in dB x 1000.
|
||||
|
||||
@return SONY_RESULT_OK if pSNR is valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_monitor_SNR (sony_demod_t * pDemod,
|
||||
int32_t * pSNR);
|
||||
|
||||
/**
|
||||
@brief Monitor the pre-LDPC BER. This provides the
|
||||
data PLP BER in multiple PLP case.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pBER The returned BER x 1e7.
|
||||
|
||||
@return SONY_RESULT_OK if the pBER is valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_monitor_PreLDPCBER (sony_demod_t * pDemod,
|
||||
uint32_t * pBER);
|
||||
|
||||
/**
|
||||
@brief Monitor the pre-BCH BER.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pBER The returned BER x 1e9.
|
||||
|
||||
@return SONY_RESULT_OK if pBER is valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_monitor_PreBCHBER (sony_demod_t * pDemod,
|
||||
uint32_t * pBER);
|
||||
|
||||
/**
|
||||
@brief Monitor the post BCH FER (FEC block error rate) parameters.
|
||||
|
||||
@param pDemod The demod instance.
|
||||
@param pFER The estimated FER x 1e6.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_monitor_PostBCHFER (sony_demod_t * pDemod,
|
||||
uint32_t * pFER);
|
||||
|
||||
/**
|
||||
@brief Monitor the Packet Error Number.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pPEN The returned Packet Error Number.
|
||||
|
||||
@return SONY_RESULT_OK if pPEN is valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_monitor_PacketErrorNumber (sony_demod_t * pDemod,
|
||||
uint32_t * pPEN);
|
||||
|
||||
/**
|
||||
@brief Monitors the synchronisation state of the C2 demodulator.
|
||||
|
||||
@note Note that early unlock condition should be used in tuning stage ONLY
|
||||
to detect that there are no desired signal in current frequency quickly.
|
||||
After tuning, early unlock condition should NOT be used to
|
||||
know current demodulator lock status.
|
||||
Especially, DVB-C2 early unlock condition does NOT change after tuning.
|
||||
(keeps the value decided in tuning stage.)
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pSyncStat The demodulator state.
|
||||
- 0: WAIT_GO, : Wait for process to start
|
||||
- 1: WAIT_AGC, : Wait for AGC lock
|
||||
- 2: WAIT_CCOD, : Wait for coarse frequency offset estimation
|
||||
- 3: WAIT_C2FS, : Wait for preamble symbol lock
|
||||
- 4: WAIT_L1SEQ, : Wait for L1 decode
|
||||
- 5: WAIT_DMD_OK, : Wait for demodulator lock
|
||||
- 6: DMD_OK : Demodulator locked
|
||||
@param pTSLockStat Indicates the TS lock condition.
|
||||
- 0: TS not locked.
|
||||
- 1: TS locked.
|
||||
@param pUnlockDetected Indicates an early unlock condition
|
||||
- 0: No early unlock.
|
||||
- 1: Early unlock detected.
|
||||
|
||||
@return SONY_RESULT_OK if pSyncStat, pTSLockStat is valid, otherwise an error is returned.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_monitor_SyncStat (sony_demod_t * pDemod,
|
||||
uint8_t * pSyncStat,
|
||||
uint8_t * pTSLockStat,
|
||||
uint8_t * pUnlockDetected);
|
||||
|
||||
/**
|
||||
@brief Monitor the demodulator *estimated* DVB-C2 TS (Transport Stream) rate.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pTSRateKbps The estimated TS rate in kbps.
|
||||
|
||||
@return SONY_RESULT_OK if pTSRateKbps is valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_monitor_TSRate (sony_demod_t * pDemod,
|
||||
uint32_t * pTSRateKbps);
|
||||
|
||||
/**
|
||||
@brief Monitor the DVB-C2 L1 signaling information.
|
||||
|
||||
L1 signaling information is available when TS is locked, or earlier in the
|
||||
acquisition sequence, after the P1 symbols have been decoded.
|
||||
In the case of being tuned to a Data Slice with a broadband notch
|
||||
then no L1 signaling is available.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param l1Data Pointer to receive the L1 signaling information.
|
||||
|
||||
@return SONY_RESULT_OK if the L1 Data is valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_monitor_L1Data (sony_demod_t * pDemod,
|
||||
sony_dvbc2_l1_t * l1Data);
|
||||
|
||||
/**
|
||||
@brief Monitor the DVB-C2 active PLP QAM.
|
||||
|
||||
For multiple PLP systems,
|
||||
then able to monitor both the data and common PLP.
|
||||
For single PLP systems, only able to monitor the data PLP.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param type The type of the PLP to monitor.
|
||||
@param pQAM To receive the PLP QAM information into.
|
||||
|
||||
@return SONY_RESULT_OK if pPLPInfo is valid, otherwise an error is returned.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_monitor_QAM (sony_demod_t * pDemod,
|
||||
sony_dvbc2_plp_type_t type,
|
||||
sony_dvbc2_constellation_t * pQAM);
|
||||
|
||||
/**
|
||||
@brief Monitor the DVB-C2 active PLP Code Length.
|
||||
|
||||
For multiple PLP systems,then able to monitor both the data and common PLP.
|
||||
For single PLP systems, only able to monitor the data PLP.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param type The type of the PLP to monitor.
|
||||
@param pCodeLength To receive the PLP code length information into.
|
||||
|
||||
@return SONY_RESULT_OK if pPLPInfo is valid, otherwise an error is returned.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_monitor_LDPCCodeLength (sony_demod_t * pDemod,
|
||||
sony_dvbc2_plp_type_t type,
|
||||
sony_dvbc2_ldpc_code_length_t * pCodeLength);
|
||||
|
||||
/**
|
||||
@brief Monitor the DVB-C2 active PLP Code Rate.
|
||||
|
||||
For multiple PLP systems, then able to monitor both the data and common PLP.
|
||||
For single PLP systems, only able to monitor the data PLP.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param type The type of the PLP to monitor.
|
||||
@param pCodeRate To receive the PLP code rate information into.
|
||||
|
||||
@return SONY_RESULT_OK if pPLPInfo is valid, otherwise an error is returned.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_monitor_CodeRate (sony_demod_t * pDemod,
|
||||
sony_dvbc2_plp_type_t type,
|
||||
sony_dvbc2_plp_code_rate_t * pCodeRate);
|
||||
|
||||
/**
|
||||
@brief Monitor the sampling frequency offset value.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pPPM The sampling frequency offset in ppm x 100.
|
||||
Range: +/- 220ppm.
|
||||
|
||||
@return SONY_RESULT_OK if pPPM is valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_monitor_SamplingOffset (sony_demod_t * pDemod,
|
||||
int32_t * pPPM);
|
||||
|
||||
/**
|
||||
@brief Monitor the DVB-C2 PER (Packet Error Rate).
|
||||
|
||||
@param pDemod The demod instance.
|
||||
@param pPER The estimated PER x 1e6.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_monitor_PER (sony_demod_t * pDemod,
|
||||
uint32_t * pPER);
|
||||
|
||||
/**
|
||||
@brief Monitor the Guard Interval of the current tuned channel.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pGI The guard interval.
|
||||
|
||||
@return SONY_RESULT_OK if successful and pGI valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc2_monitor_GI (sony_demod_t * pDemod,
|
||||
sony_dvbc2_l1_gi_t * pGI);
|
||||
|
||||
#endif /* SONY_DEMOD_DVBC2_MONITOR_H */
|
||||
+777
@@ -0,0 +1,777 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/08/01
|
||||
Modification ID : b30d76210d343216ea52b88e9b450c8fd5c0359f
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "sony_demod_dvbc_monitor.h"
|
||||
#include "sony_math.h"
|
||||
#include "sony_common.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Static Function Prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
/*
|
||||
@brief Confirms AR lock state for demodulator.
|
||||
*/
|
||||
static sony_result_t IsARLocked (sony_demod_t * pDemod);
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
sony_result_t sony_demod_dvbc_monitor_SyncStat (sony_demod_t * pDemod,
|
||||
uint8_t * pARLock,
|
||||
uint8_t * pTSLockStat,
|
||||
uint8_t * pUnlockDetected)
|
||||
{
|
||||
uint8_t rdata = 0x00;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbc_monitor_SyncStat");
|
||||
|
||||
if ((!pDemod) || (!pARLock) || (!pTSLockStat) || (!pUnlockDetected)) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Software state check */
|
||||
if (pDemod->state != SONY_DEMOD_STATE_ACTIVE) {
|
||||
/* This api is accepted in Active state only */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
if (pDemod->system != SONY_DTV_SYSTEM_DVBC) {
|
||||
/* Not DVB-C */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x40 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x40) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* slave Bank Addr Bit Name meaning
|
||||
* ---------------------------------------------------------------------------------
|
||||
* <SLV-T> 40h 88h [0] IREG_AR_LOCK 0:Unlock 1:Lock
|
||||
* <SLV-T> 40h 88h [1] IREG_AR_TIMEOUT 0:Checking, 1:DVB-C signal does not exist
|
||||
* <SLV-T> 40h 10h [5] IREG_TSIF_TS_LOCK 0:Unlock 1:Lock
|
||||
*/
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x88, &rdata, 1) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
*pARLock = (uint8_t) ((rdata & 0x01) ? 1 : 0);
|
||||
*pUnlockDetected = (uint8_t) ((rdata & 0x02) ? 1 : 0);
|
||||
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x10, &rdata, 1) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
*pTSLockStat = (uint8_t) ((rdata & 0x20) ? 1 : 0);
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbc_monitor_IFAGCOut (sony_demod_t * pDemod, uint32_t * pIFAGCOut)
|
||||
{
|
||||
uint8_t rdata[2];
|
||||
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbc_monitor_IFAGCOut");
|
||||
|
||||
if (!pDemod || !pIFAGCOut) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Software state check */
|
||||
if (pDemod->state != SONY_DEMOD_STATE_ACTIVE) {
|
||||
/* This api is accepted in Active state only */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
if (pDemod->system != SONY_DTV_SYSTEM_DVBC) {
|
||||
/* Not DVB-C */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x40 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x40) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* slave Bank Addr Bit Name
|
||||
* ------------------------------------------------------------
|
||||
* <SLV-T> 40h 49h [3:0] IIFAGC_OUT[11:8]
|
||||
* <SLV-T> 40h 4Ah [7:0] IIFAGC_OUT[7:0]
|
||||
*/
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x49, rdata, 2) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
*pIFAGCOut = (rdata[0] & 0x0F) << 8 | rdata[1];
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbc_monitor_QAM (sony_demod_t * pDemod, sony_dvbc_constellation_t * pQAM)
|
||||
{
|
||||
uint8_t rdata = 0x00;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbc_monitor_QAM");
|
||||
|
||||
if (!pDemod || !pQAM) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Software state check */
|
||||
if (pDemod->state != SONY_DEMOD_STATE_ACTIVE) {
|
||||
/* This api is accepted in Active state only */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
if (pDemod->system != SONY_DTV_SYSTEM_DVBC) {
|
||||
/* Not DVB-C */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
/* Freeze registers */
|
||||
if (SLVT_FreezeReg (pDemod) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* AR lock check */
|
||||
{
|
||||
sony_result_t result = IsARLocked (pDemod);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x40 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x40) != SONY_RESULT_OK) {
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* slave Bank Addr Bit Name
|
||||
* ------------------------------------------------------------
|
||||
* <SLV-T> 40h 19h [2:0] IREG_QAM_LEVEL[2:0]
|
||||
*/
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x19, &rdata, 1) != SONY_RESULT_OK) {
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
|
||||
*pQAM = (sony_dvbc_constellation_t) (rdata & 0x07);
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbc_monitor_SymbolRate (sony_demod_t * pDemod, uint32_t * pSymRate)
|
||||
{
|
||||
uint8_t rdata1[2];
|
||||
uint8_t rdata2[5];
|
||||
uint32_t trialsrate;
|
||||
int32_t tlfIntegral;
|
||||
uint32_t tsmDrate;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbc_monitor_SymbolRate");
|
||||
|
||||
if (!pDemod || !pSymRate) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Software state check */
|
||||
if (pDemod->state != SONY_DEMOD_STATE_ACTIVE) {
|
||||
/* This api is accepted in Active state only */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
if (pDemod->system != SONY_DTV_SYSTEM_DVBC) {
|
||||
/* Not DVB-C */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
/* Freeze registers */
|
||||
if (SLVT_FreezeReg (pDemod) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* AR lock check */
|
||||
{
|
||||
sony_result_t result = IsARLocked (pDemod);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x40 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x40) != SONY_RESULT_OK) {
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* slave Bank Addr Bit Name
|
||||
* ------------------------------------------------------------
|
||||
* <SLV-T> 40h 1Ah [3:0] IREG_TRIALSRATE[11:8]
|
||||
* <SLV-T> 40h 1Bh [7:0] IREG_TRIALSRATE[7:0]
|
||||
* <SLV-T> 40h 9Bh [7:0] IREG_TLFINTEGRAL[31:24]
|
||||
* <SLV-T> 40h 9Ch [7:0] IREG_TLFINTEGRAL[23:16]
|
||||
* <SLV-T> 40h 9Dh [7:0] IREG_TLFINTEGRAL[15:8]
|
||||
* <SLV-T> 40h 9Eh [7:0] IREG_TLFINTEGRAL[7:0]
|
||||
* <SLV-T> 40h 9Fh [1:0] IREG_TSMDRATE[1:0]
|
||||
*/
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x1A, rdata1, sizeof(rdata1)) != SONY_RESULT_OK) {
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Read IREG_TLFINTEGRAL and IREG_TSMDRATE */
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x9B, rdata2, sizeof(rdata2)) != SONY_RESULT_OK) {
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
|
||||
trialsrate = ((rdata1[0] & 0x0F) << 8) | rdata1[1];
|
||||
tlfIntegral = (int32_t)((rdata2[0] << 24) | (rdata2[1] << 16) | (rdata2[2] << 8) | rdata2[3]);
|
||||
tsmDrate = rdata2[4] & 0x03;
|
||||
|
||||
/*
|
||||
* Symbol rate[MSymbol/sec] = (IREG_TRIALSRATE + (IREG_TLFINTEGRAL / ( 2^(24 + IREG_TSMDRATE)))) * ick / 16384
|
||||
* (IREG_TLFINTEGRAL is 2's compliment, ick = 48)
|
||||
*
|
||||
* Symbol rate[Symbol/sec] = (IREG_TRIALSRATE + (IREG_TLFINTEGRAL / ( 2^(24 + IREG_TSMDRATE)))) * 48 / 2^14 * 10^6
|
||||
* = (IREG_TRIALSRATE + (IREG_TLFINTEGRAL / ( 2^(24 + IREG_TSMDRATE)))) * 3 * 5^6 / 2^4
|
||||
* = IREG_TRIALSRATE * 3 * 5^6 / 16 + IREG_TLFINTEGRAL * 3 * 5^6 / ( 2^(28 + IREG_TSMDRATE))
|
||||
*/
|
||||
/* Calculate IREG_TRIALSRATE * 3 * 5^6 / 16 */
|
||||
*pSymRate = (trialsrate * 46875 + 8) / 16;
|
||||
|
||||
/* Calculate IREG_TLFINTEGRAL * 3 * 5^6 / ( 2^(28 + IREG_TSMDRATE)) */
|
||||
{
|
||||
uint32_t div = 0;
|
||||
uint32_t Q = 0;
|
||||
uint32_t R = 0;
|
||||
|
||||
uint8_t isMinus = 0;
|
||||
|
||||
if (tlfIntegral < 0) {
|
||||
isMinus = 1;
|
||||
tlfIntegral *= -1;
|
||||
}
|
||||
|
||||
div = 65536; /* Divide by 2^16 first */
|
||||
|
||||
/* Divide in 2 steps to prevent overflow. */
|
||||
Q = tlfIntegral / div;
|
||||
R = tlfIntegral % div;
|
||||
|
||||
R *= 46875; /* 3 * 5^6 */
|
||||
Q = Q * 46875 + R / div;
|
||||
R = R % div;
|
||||
|
||||
if (R >= div/2) {
|
||||
Q += 1;
|
||||
}
|
||||
|
||||
/* Divide by 2^(12 + IREG_TSMDRATE) */
|
||||
Q = (Q + (1U << (11 + tsmDrate))) >> (12 + tsmDrate);
|
||||
|
||||
if (isMinus) {
|
||||
*pSymRate -= Q;
|
||||
} else {
|
||||
*pSymRate += Q;
|
||||
}
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbc_monitor_CarrierOffset (sony_demod_t * pDemod, int32_t * pOffset)
|
||||
{
|
||||
uint8_t rdata[2];
|
||||
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbc_monitor_CarrierOffset");
|
||||
|
||||
if (!pDemod || !pOffset) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Software state check */
|
||||
if (pDemod->state != SONY_DEMOD_STATE_ACTIVE) {
|
||||
/* This api is accepted in Active state only */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
if (pDemod->system != SONY_DTV_SYSTEM_DVBC) {
|
||||
/* Not DVB-C */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
/* Freeze registers */
|
||||
if (SLVT_FreezeReg (pDemod) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* AR lock check */
|
||||
{
|
||||
sony_result_t result = IsARLocked (pDemod);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x40 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x40) != SONY_RESULT_OK) {
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* slave Bank Addr Bit Name
|
||||
* ---------------------------------------------------------------
|
||||
* <SLV-T> 40h 15h [5:0] IREG_FREQ_OFFSET[13:8]
|
||||
* <SLV-T> 40h 16h [7:0] IREG_FREQ_OFFSET[7:0]
|
||||
*/
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x15, rdata, 2) != SONY_RESULT_OK) {
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
|
||||
/* 14bit signed value to 32bit signed value */
|
||||
*pOffset = sony_Convert2SComplement (((rdata[0] & 0x3F) << 8) | rdata[1], 14);
|
||||
|
||||
/* Carrier offset[KHz] = IREG_FREQ_OFFSET * ADC_Clock(KHz) / 16384
|
||||
*
|
||||
* ADC_Clock(KHz) = 48000
|
||||
*/
|
||||
*pOffset = *pOffset * 48000 / 16384;
|
||||
|
||||
/* Compensate for inverted spectrum. */
|
||||
{
|
||||
/* Inverted RF spectrum with non-inverting tuner architecture. */
|
||||
if (pDemod->confSense == SONY_DEMOD_TERR_CABLE_SPECTRUM_INV) {
|
||||
*pOffset *= -1;
|
||||
}
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbc_monitor_SpectrumSense (sony_demod_t * pDemod, sony_demod_terr_cable_spectrum_sense_t * pSense)
|
||||
{
|
||||
uint8_t rdata = 0x00;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbc_monitor_SpectrumSense");
|
||||
|
||||
if (!pDemod || !pSense) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Software state check */
|
||||
if (pDemod->state != SONY_DEMOD_STATE_ACTIVE) {
|
||||
/* This api is accepted in Active state only */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
if (pDemod->system != SONY_DTV_SYSTEM_DVBC) {
|
||||
/* Not DVB-C */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
/* Freeze registers */
|
||||
if (SLVT_FreezeReg (pDemod) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* AR lock check */
|
||||
{
|
||||
sony_result_t result = IsARLocked (pDemod);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x40 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x40) != SONY_RESULT_OK) {
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* slave Bank Addr Bit Name mean
|
||||
* ---------------------------------------------------------------------------------
|
||||
* <SLV-T> 40h 19h [7] IREG_DET_SPECTRUM_INV 0:Not inverted, 1:inverted
|
||||
*/
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x19, &rdata, 1) != SONY_RESULT_OK) {
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
|
||||
if (pDemod->confSense == SONY_DEMOD_TERR_CABLE_SPECTRUM_INV) {
|
||||
*pSense = (rdata & 0x80) ? SONY_DEMOD_TERR_CABLE_SPECTRUM_NORMAL : SONY_DEMOD_TERR_CABLE_SPECTRUM_INV;
|
||||
} else {
|
||||
*pSense = (rdata & 0x80) ? SONY_DEMOD_TERR_CABLE_SPECTRUM_INV : SONY_DEMOD_TERR_CABLE_SPECTRUM_NORMAL;
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbc_monitor_SNR (sony_demod_t * pDemod, int32_t * pSNR)
|
||||
{
|
||||
sony_dvbc_constellation_t qam = SONY_DVBC_CONSTELLATION_16QAM;
|
||||
uint16_t reg = 0x00;
|
||||
uint8_t rdata[2];
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbc_monitor_SNR");
|
||||
|
||||
if (!pDemod || !pSNR) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Software state check */
|
||||
if (pDemod->state != SONY_DEMOD_STATE_ACTIVE) {
|
||||
/* This api is accepted in Active state only */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
if (pDemod->system != SONY_DTV_SYSTEM_DVBC) {
|
||||
/* Not DVB-C */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
/* Freeze registers */
|
||||
if (SLVT_FreezeReg (pDemod) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* AR lock check */
|
||||
{
|
||||
result = IsARLocked (pDemod);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x40 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x40) != SONY_RESULT_OK) {
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* slave Bank Addr Bit Name
|
||||
* ------------------------------------------------------------
|
||||
* <SLV-T> 40h 19h [2:0] IREG_QAM_LEVEL[2:0]
|
||||
*/
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x19, &rdata[0], 1) != SONY_RESULT_OK) {
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
qam = (sony_dvbc_constellation_t) (rdata[0] & 0x07);
|
||||
|
||||
/* slave Bank Addr Bit Name
|
||||
* ------------------------------------------------------------
|
||||
* <SLV-T> 40h 4Ch [4:0] IREG_SNR_ESTIMATE[12:8]
|
||||
* <SLV-T> 40h 4Dh [7:0] IREG_SNR_ESTIMATE[7:0]
|
||||
*/
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x4C, rdata, 2) != SONY_RESULT_OK) {
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
SLVT_UnFreezeReg (pDemod);
|
||||
|
||||
reg = ((rdata[0] & 0x1F) << 8) | rdata[1];
|
||||
|
||||
if (reg == 0) {
|
||||
/* log function will return INF */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
|
||||
}
|
||||
|
||||
switch (qam) {
|
||||
case SONY_DVBC_CONSTELLATION_16QAM:
|
||||
case SONY_DVBC_CONSTELLATION_64QAM:
|
||||
case SONY_DVBC_CONSTELLATION_256QAM:
|
||||
/* IREG_SNR_ESTIMATE is clipped at a minimum of 126
|
||||
*
|
||||
* SNR(dB) = -9.50 * ln(IREG_SNR_ESTIMATE / (24320))
|
||||
*/
|
||||
if (reg < 126) {
|
||||
reg = 126;
|
||||
}
|
||||
|
||||
*pSNR = -95 * (int32_t) sony_math_log (reg) + 95941;
|
||||
break;
|
||||
case SONY_DVBC_CONSTELLATION_32QAM:
|
||||
case SONY_DVBC_CONSTELLATION_128QAM:
|
||||
/* IREG_SNR_ESTIMATE is clipped at a minimum of 69
|
||||
*
|
||||
* SNR(dB) = -8.75 * ln(IREG_SNR_ESTIMATE / (20800))
|
||||
*/
|
||||
if (reg < 69) {
|
||||
reg = 69;
|
||||
}
|
||||
|
||||
*pSNR = -88 * (int32_t) sony_math_log (reg) + 86999;
|
||||
break;
|
||||
default:
|
||||
/* Unknown value */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbc_monitor_PreRSBER (sony_demod_t * pDemod, uint32_t * pBER)
|
||||
{
|
||||
uint8_t rdata[3];
|
||||
uint32_t bitError = 0;
|
||||
uint32_t periodExp = 0;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbc_monitor_PreRSBER");
|
||||
|
||||
if (!pDemod || !pBER) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Software state check */
|
||||
if (pDemod->state != SONY_DEMOD_STATE_ACTIVE) {
|
||||
/* This api is accepted in Active state only */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
if (pDemod->system != SONY_DTV_SYSTEM_DVBC) {
|
||||
/* Not DVB-C */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x40 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x40) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
rdata[0] = rdata[1] = rdata[2] = 0;
|
||||
|
||||
/* slave Bank Addr Bit Name
|
||||
* ------------------------------------------------------------
|
||||
* <SLV-T> 40h 62h [7] IREG_BERN_VALID
|
||||
* <SLV-T> 40h 62h [5:0] IREG_BERN_BITECNT[21:16]
|
||||
* <SLV-T> 40h 63h [7:0] IREG_BERN_BITECNT[15:8]
|
||||
* <SLV-T> 40h 64h [7:0] IREG_BERN_BITECNT[7:0]
|
||||
*/
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x62, rdata, 3) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* Check IREG_BERN_VALID bit (bit 7) */
|
||||
if ((rdata[0] & 0x80) == 0) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE); /* Not ready... */
|
||||
}
|
||||
|
||||
bitError = ((rdata[0] & 0x3F) << 16) | (rdata[1] << 8) | rdata[2];
|
||||
|
||||
/* slave Bank Addr Bit default Name
|
||||
* -------------------------------------------------------------------------
|
||||
* <SLV-T> 40h 60h [4:0] 5'h0B OREG_BERN_PERIOD[4:0]
|
||||
*/
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x60, rdata, 1) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
periodExp = (rdata[0] & 0x1F);
|
||||
|
||||
if ((periodExp <= 11) && (bitError > (1U << periodExp) * 204 * 8)) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
|
||||
}
|
||||
|
||||
/*
|
||||
BER = bitError * 10000000 / (2^N * 204 * 8)
|
||||
= bitError * 312500 / (2^N * 51)
|
||||
= bitError * 250 * 1250 / (2^N * 51)
|
||||
(Divide in 2 steps to prevent overflow.)
|
||||
*/
|
||||
{
|
||||
uint32_t div = 0;
|
||||
uint32_t Q = 0;
|
||||
uint32_t R = 0;
|
||||
|
||||
if (periodExp <= 8) {
|
||||
div = (1U << periodExp) * 51;
|
||||
}
|
||||
else {
|
||||
div = (1U << 8) * 51;
|
||||
}
|
||||
|
||||
Q = (bitError * 250) / div;
|
||||
R = (bitError * 250) % div;
|
||||
|
||||
R *= 1250;
|
||||
Q = Q * 1250 + R / div;
|
||||
R = R % div;
|
||||
|
||||
if (periodExp > 8) {
|
||||
/* rounding */
|
||||
*pBER = (Q + (1 << (periodExp - 9))) >> (periodExp - 8);
|
||||
}
|
||||
else {
|
||||
/* rounding */
|
||||
if (R >= div/2) {
|
||||
*pBER = Q + 1;
|
||||
} else {
|
||||
*pBER = Q;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbc_monitor_PacketErrorNumber (sony_demod_t * pDemod, uint32_t * pPEN)
|
||||
{
|
||||
uint8_t rdata[3];
|
||||
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbc_monitor_PacketErrorNumber");
|
||||
|
||||
if (!pDemod || !pPEN) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Software state check */
|
||||
if (pDemod->state != SONY_DEMOD_STATE_ACTIVE) {
|
||||
/* This api is accepted in Active state only */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
if (pDemod->system != SONY_DTV_SYSTEM_DVBC) {
|
||||
/* Not DVB-C */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
/* Set SLV-T Bank : 0x40 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x40) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
/* slave Bank Addr Bit Name
|
||||
* ------------------------------------------------------------
|
||||
* <SLV-T> 40h EAh [7:0] IREG_BER_CWRJCTCNT[15:8]
|
||||
* <SLV-T> 40h EBh [7:0] IREG_BER_CWRJCTCNT[7:0]
|
||||
* <SLV-T> 40h ECh [0] IREG_BER_CWRJCTCNT_VALID
|
||||
*/
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xEA, rdata, 3) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (!(rdata[2] & 0x01)) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
|
||||
}
|
||||
|
||||
*pPEN = (rdata[0] << 8) | rdata[1];
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
|
||||
sony_result_t sony_demod_dvbc_monitor_PER (sony_demod_t * pDemod, uint32_t * pPER)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
uint32_t packetError = 0;
|
||||
uint32_t periodExp = 0;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_demod_dvbc_monitor_PER");
|
||||
|
||||
if (!pDemod || !pPER) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Software state check */
|
||||
if (pDemod->state != SONY_DEMOD_STATE_ACTIVE) {
|
||||
/* This api is accepted in Active state only */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
if (pDemod->system != SONY_DTV_SYSTEM_DVBC) {
|
||||
/* Not DVB-C */
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
/* slave Bank Addr Bit Name
|
||||
* ---------------------------------------------------------------------------------
|
||||
* <SLV-T> 40h 5Ch [4:0] OREG_PER_MES[4:0]
|
||||
* <SLV-T> 40h 5Dh [2] IREG_PER_VALID
|
||||
* <SLV-T> 40h 5Dh [1:0] IREG_PER_PKTERR[17:16]
|
||||
* <SLV-T> 40h 5Eh [7:0] IREG_PER_PKTERR[15:8]
|
||||
* <SLV-T> 40h 5Fh [7:0] IREG_PER_PKTERR[7:0]
|
||||
*
|
||||
* PER = IREG_PER_PKTERR / ( 2 ^ OREG_PER_MES )
|
||||
*/
|
||||
|
||||
{
|
||||
uint8_t rdata[4];
|
||||
|
||||
/* Set SLV-T Bank : 0x40 */
|
||||
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x40) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x5C, rdata, sizeof (rdata)) != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
|
||||
}
|
||||
|
||||
if ((rdata[1] & 0x04) == 0) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE); /* Not ready... */
|
||||
}
|
||||
|
||||
packetError = ((rdata[1] & 0x03) << 16) | (rdata[2] << 8) | rdata[3];
|
||||
periodExp = rdata[0] & 0x1F;
|
||||
}
|
||||
|
||||
if (packetError > (1U << periodExp)) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
|
||||
}
|
||||
|
||||
/*
|
||||
PER = packetError * 1000000 / 2^N
|
||||
= packetError * 5^6 / 2^(N-6) (If N > 6)
|
||||
|
||||
= packetError * 10^6 / 2^N (If N <= 6, packetError <= 2^6)
|
||||
|
||||
Max of packeError : 0x3FFFF
|
||||
*/
|
||||
if (periodExp == 0) {
|
||||
*pPER = packetError * 1000000;
|
||||
} else if (periodExp > 6) {
|
||||
*pPER = (packetError * 15625 + (1 << (periodExp - 7))) >> (periodExp - 6);
|
||||
} else {
|
||||
*pPER = (packetError * 1000000 + (1 << (periodExp - 1))) >> periodExp;
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Static functions
|
||||
------------------------------------------------------------------------------*/
|
||||
static sony_result_t IsARLocked (sony_demod_t * pDemod)
|
||||
{
|
||||
uint8_t ar = 0;
|
||||
uint8_t tslock = 0;
|
||||
uint8_t earlyUnlock = 0;
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
|
||||
SONY_TRACE_ENTER ("IsARLocked");
|
||||
|
||||
if (!pDemod) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbc_monitor_SyncStat (pDemod, &ar, &tslock,&earlyUnlock);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (ar != 1) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
}
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/07/27
|
||||
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_demod_dvbc_monitor.h
|
||||
|
||||
This file provides the DVB-C demodulator monitor interface.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SONY_DEMOD_DVBC_MONITOR_H
|
||||
#define SONY_DEMOD_DVBC_MONITOR_H
|
||||
|
||||
#include "sony_demod.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Acquisition state monitor.
|
||||
|
||||
@note Note that early unlock condition should be used in tuning stage ONLY
|
||||
to detect that there are no desired signal in current frequency quickly.
|
||||
After tuning, early unlock condition should NOT be used to
|
||||
know current demodulator lock status.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pARLock The demodulator lock state.
|
||||
- 0: AR not Locked,
|
||||
- 1: AR Locked,
|
||||
@param pTSLockStat Indicates the TS lock condition.
|
||||
- 0: TS not locked.
|
||||
- 1: TS locked.
|
||||
@param pUnlockDetected Indicates the early unlock condition, only valid
|
||||
when demodulator is set to DVB-C scan mode enabled.
|
||||
- 0: No early unlock.
|
||||
- 1: Early unlock.
|
||||
|
||||
@return SONY_RESULT_OK on success and pARLock, pTSLockStat and pUnlockDetected are valid.
|
||||
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc_monitor_SyncStat (sony_demod_t * pDemod,
|
||||
uint8_t * pARLock,
|
||||
uint8_t * pTSLockStat,
|
||||
uint8_t * pUnlockDetected);
|
||||
|
||||
/**
|
||||
@brief Monitor the IFAGC value.
|
||||
|
||||
The actual dB gain is dependent on the attached tuner.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pIFAGCOut Value of IFAGC output register value. Unitless.
|
||||
|
||||
@return SONY_RESULT_OK if successful and pIFAGCOut valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc_monitor_IFAGCOut (sony_demod_t * pDemod,
|
||||
uint32_t * pIFAGCOut);
|
||||
|
||||
/**
|
||||
@brief Monitor the constellation of the currently tuned channel.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pQAM The monitored constellation.
|
||||
|
||||
@return SONY_RESULT_OK if successful and pQAM valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc_monitor_QAM (sony_demod_t * pDemod,
|
||||
sony_dvbc_constellation_t * pQAM);
|
||||
|
||||
/**
|
||||
@brief Monitor the symbol rate of the currently tuned channel.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pSymRate Symbol rate (Symbol/sec).
|
||||
|
||||
@return SONY_RESULT_OK if successful and pSymRate valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc_monitor_SymbolRate (sony_demod_t * pDemod,
|
||||
uint32_t * pSymRate);
|
||||
|
||||
/**
|
||||
@brief Monitors the detected carrier offset of the currently tuned channel.
|
||||
|
||||
To get the estimated center frequency of the current channel:
|
||||
Freq_Est = Freq_Tune + pOffset;
|
||||
|
||||
This function will compensate for an inverting tuner architecture if the
|
||||
demodulator has been configured accordingly using ::SONY_DEMOD_CONFIG_SPECTRUM_INV
|
||||
config option for ::sony_demod_SetConfig.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pOffset Carrier offset value(kHz).
|
||||
|
||||
@return SONY_RESULT_OK if successful and pOffset valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc_monitor_CarrierOffset (sony_demod_t * pDemod,
|
||||
int32_t * pOffset);
|
||||
|
||||
/**
|
||||
@brief Monitors the channel spectrum sense.
|
||||
|
||||
To ensure correct polarity detection
|
||||
please use the ::SONY_DEMOD_CONFIG_SPECTRUM_INV config option in
|
||||
::sony_demod_SetConfig to select the appropriate spectrum inversion
|
||||
for the tuner output.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pSense Indicates the spectrum sense.
|
||||
|
||||
@return SONY_RESULT_OK if successful and pSense valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc_monitor_SpectrumSense (sony_demod_t * pDemod,
|
||||
sony_demod_terr_cable_spectrum_sense_t * pSense);
|
||||
|
||||
/**
|
||||
@brief Monitors the estimated SNR register value, clipped to a
|
||||
maximum of 50dB.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pSNR The estimated SNR value in dB x 1000.
|
||||
|
||||
@return SONY_RESULT_OK if successful and pSNR valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc_monitor_SNR (sony_demod_t * pDemod,
|
||||
int32_t * pSNR);
|
||||
|
||||
/**
|
||||
@brief Monitor the Pre-RS BER.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pBER BER value (Pre Reed-Solomon decoder) x 1e7.
|
||||
|
||||
@return SONY_RESULT_OK if successful and pBER valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc_monitor_PreRSBER (sony_demod_t * pDemod,
|
||||
uint32_t * pBER);
|
||||
|
||||
/**
|
||||
@brief Monitors the number RS (Reed-Solomon) errors detected by the
|
||||
RS decoder over 1 second. Also known as the code word reject count.
|
||||
|
||||
@param pDemod The demodulator instance.
|
||||
@param pPEN The number of RS errors detected over 1 second.
|
||||
|
||||
@return SONY_RESULT_OK if successful and pPEN valid.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc_monitor_PacketErrorNumber (sony_demod_t * pDemod,
|
||||
uint32_t * pPEN);
|
||||
|
||||
/**
|
||||
@brief Monitor the DVB-C PER (Packet Error Rate).
|
||||
|
||||
@param pDemod The demod instance.
|
||||
@param pPER The estimated PER x 1e6.
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_demod_dvbc_monitor_PER (sony_demod_t * pDemod,
|
||||
uint32_t * pPER);
|
||||
|
||||
#endif /* SONY_DEMOD_DVBC_MONITOR_H */
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2016/06/24
|
||||
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_dvbc.h
|
||||
|
||||
This file provides DVB-C related type definitions.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SONY_DVBC_H
|
||||
#define SONY_DVBC_H
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Enumerations
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief DVB-C constellation.
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_DVBC_CONSTELLATION_16QAM, /**< 16-QAM */
|
||||
SONY_DVBC_CONSTELLATION_32QAM, /**< 32-QAM */
|
||||
SONY_DVBC_CONSTELLATION_64QAM, /**< 64-QAM */
|
||||
SONY_DVBC_CONSTELLATION_128QAM, /**< 128-QAM */
|
||||
SONY_DVBC_CONSTELLATION_256QAM /**< 256-QAM */
|
||||
} sony_dvbc_constellation_t;
|
||||
|
||||
#endif /* SONY_DVBC_H */
|
||||
Executable
+187
@@ -0,0 +1,187 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2019 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2019/10/04
|
||||
Modification ID : ae1245fdaf66401838902e7214d8494b0f5e5a76
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_dvbc2.h
|
||||
|
||||
This file provides DVB-C2 related type definitions.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SONY_DVBC2_H
|
||||
#define SONY_DVBC2_H
|
||||
|
||||
#include "../sony_common.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Defines
|
||||
------------------------------------------------------------------------------*/
|
||||
#define SONY_DVBC2_DS_MAX 255 /**< Maximum number of Data Slices in DVB-C2 system */
|
||||
#define SONY_DVBC2_NUM_NOTCH_MAX 15 /**< Maximum number of notches for a C2 system */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Enumerations
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief The DVBC2 LDPC Code Length definition.
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_DVBC2_LDPC_SHORT = 0x00, /**< DVBC2 Short FECFRAME (16K). */
|
||||
SONY_DVBC2_LDPC_NORMAL = 0x01, /**< DVBC2 Normal FECFRAME (64K). */
|
||||
SONY_DVBC2_LDPC_UNKNOWN = 0xFF /**< DVBC2 Type Unknown. */
|
||||
} sony_dvbc2_ldpc_code_length_t;
|
||||
|
||||
/**
|
||||
@brief DVBC2 PLP code rate definition.
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_DVBC2_R_RSVD1 = 0x00, /**< Reserved. */
|
||||
SONY_DVBC2_R2_3 = 0x01, /**< DVBC2 2/3 code rate. */
|
||||
SONY_DVBC2_R3_4 = 0x02, /**< DVBC2 3/4 code rate. */
|
||||
SONY_DVBC2_R4_5 = 0x03, /**< DVBC2 4/5 code rate. */
|
||||
SONY_DVBC2_R5_6 = 0x04, /**< DVBC2 5/6 code rate. */
|
||||
SONY_DVBC2_R8_9 = 0x05, /**< DVBC2 8/9 code rate. */
|
||||
SONY_DVBC2_R9_10 = 0x06, /**< DVBC2 9/10 code rate. */
|
||||
SONY_DVBC2_R_RSVD2 = 0x07, /**< Reserved. */
|
||||
SONY_DVBC2_CR_UNKNOWN = 0xFF /**< UNKNOWN DVBC2 PLP code rate. */
|
||||
} sony_dvbc2_plp_code_rate_t;
|
||||
|
||||
/**
|
||||
@brief The DVBC2 Guard interval type definition.
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_DVBC2_GI_1_128 = 0x00, /**< DVBC2 1/128 guard interval*/
|
||||
SONY_DVBC2_GI_1_64 = 0x01, /**< DVBC2 1/64 guard interval*/
|
||||
SONY_DVBC2_GI_RSVD1 = 0x02, /**< Reserved. */
|
||||
SONY_DVBC2_GI_RSVD2 = 0x03, /**< Reserved. */
|
||||
SONY_DVBC2_GI_UNKNOWN = 0xFF /**< UNKNOWN guard interval*/
|
||||
} sony_dvbc2_l1_gi_t;
|
||||
|
||||
/**
|
||||
@brief The DVBC2 Data Slice Type.
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_DVBC2_DS_TYPE_1 = 0x00, /**< DVBC2 Data Slice Type 1 */
|
||||
SONY_DVBC2_DS_TYPE_2 = 0x01, /**< DVBC2 Data Slice Type 2*/
|
||||
SONY_DVBC2_DS_TYPE_UNKNOWN = 0xFF /**< UNKNOWN Data Slice Type */
|
||||
} sony_dvbc2_ds_type_t;
|
||||
|
||||
/**
|
||||
@brief DVBC2 types of PLP available.
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_DVBC2_PLP_COMMON, /**< DVBC2 Common PLP type. */
|
||||
SONY_DVBC2_PLP_GROUPED_DATA, /**< DVBC2 Grouped Data PLP type. */
|
||||
SONY_DVBC2_PLP_NORMAL_DATA, /**< DVBC2 Normal Data PLP type. */
|
||||
SONY_DVBC2_PLP_RESERVED /**< DVBC2 Reserved PLP type. */
|
||||
} sony_dvbc2_plp_type_t;
|
||||
|
||||
/**
|
||||
@brief DVB-C2 constellation.
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_DVBC2_CONSTELLATION_RSVD1 = 0x00, /**< Reserved Value */
|
||||
SONY_DVBC2_CONSTELLATION_16QAM = 0x01, /**< 16-QAM */
|
||||
SONY_DVBC2_CONSTELLATION_64QAM = 0x02, /**< 64-QAM */
|
||||
SONY_DVBC2_CONSTELLATION_256QAM = 0x03, /**< 256-QAM */
|
||||
SONY_DVBC2_CONSTELLATION_1024QAM = 0x04, /**< 1024-QAM */
|
||||
SONY_DVBC2_CONSTELLATION_4096QAM = 0x05, /**< 4096-QAM */
|
||||
SONY_DVBC2_CONSTELLATION_RSVD2 = 0x06, /**< Reserved Value */
|
||||
SONY_DVBC2_CONSTELLATION_RSVD3 = 0x07, /**< Reserved Value */
|
||||
SONY_DVBC2_CONSTELLATION_UNKNOWN = 0xFF /**< UNKNOWN constellation*/
|
||||
} sony_dvbc2_constellation_t;
|
||||
|
||||
/**
|
||||
@brief DVB-C2 time interleaved depth of the current data slice
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_DVBC2_DS_TI_DEPTH_NONE = 0x00, /**< DVBC2 no time interleaved depth */
|
||||
SONY_DVBC2_DS_TI_DEPTH_4_OFDM_SYM = 0x01, /**< DVBC2 4 OFDM symbols time interleaved depth */
|
||||
SONY_DVBC2_DS_TI_DEPTH_8_OFDM_SYM = 0x02, /**< DVBC2 8 OFDM symbols time interleaved depth */
|
||||
SONY_DVBC2_DS_TI_DEPTH_16_OFDM_SYM = 0x03 /**< DVBC2 16 OFDM symbols time interleaved depth */
|
||||
} sony_dvbc2_ds_ti_depth_t;
|
||||
|
||||
/**
|
||||
@brief DVB-C2 FEC header type
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_DVBC2_FEC_HEADER_TYPE_ROBUST = 0x00, /**< DVBC2 Robust FEC header*/
|
||||
SONY_DVBC2_FEC_HEADER_TYPE_HIGH_EFFICIENCY = 0x01 /**< DVBC2 High efficiency FEC header*/
|
||||
} sony_dvbc2_fec_header_type_t;
|
||||
|
||||
/**
|
||||
@brief DVB-C2 PLP payload type
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_DVBC2_PLP_PAYLOAD_TYPE_GFPS = 0x00, /**< DVBC2 GFPS PLP payload */
|
||||
SONY_DVBC2_PLP_PAYLOAD_TYPE_GCS = 0x01, /**< DVBC2 GCS PLP payload */
|
||||
SONY_DVBC2_PLP_PAYLOAD_TYPE_GSE = 0x02, /**< DVBC2 GSE PLP payload */
|
||||
SONY_DVBC2_PLP_PAYLOAD_TYPE_TS = 0x03, /**< DVBC2 TS PLP payload */
|
||||
SONY_DVBC2_PLP_PAYLOAD_TYPE_RESERVED = 0x04 /**< Reserved */
|
||||
} sony_dvbc2_plp_payload_type_t;
|
||||
|
||||
/**
|
||||
@brief DVB-C2 version definition.
|
||||
*/
|
||||
typedef enum {
|
||||
SONY_DVBC2_V121, /**< DVBC2 V1.2.1. */
|
||||
SONY_DVBC2_V131 /**< DVBC2 V1.3.1. */
|
||||
} sony_dvbc2_version_t;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Structs
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief L1 signaling notch data structure.
|
||||
*/
|
||||
typedef struct sony_dvbc2_l1_notch_data_t {
|
||||
uint16_t notchStart; /**< Notch start */
|
||||
uint16_t notchWidth; /**< Notch width */
|
||||
} sony_dvbc2_l1_notch_data_t;
|
||||
|
||||
/**
|
||||
@brief L1 signaling information structure definition.
|
||||
*/
|
||||
typedef struct sony_dvbc2_l1_t {
|
||||
uint16_t networkID; /**< The signal network ID. */
|
||||
uint16_t systemID; /**< The DVB-C2 system ID. */
|
||||
uint32_t startFrequency; /**< The start frequency of the signal in units of carriers. */
|
||||
uint16_t bandwidth; /**< The bandwidth of the signal in units of carriers. */
|
||||
sony_dvbc2_l1_gi_t gi; /**< Guard interval enumeration of the signal. */
|
||||
uint16_t frameLength; /**< The frame length. */
|
||||
uint8_t changeCntL1; /**< Change counter of L1 data. */
|
||||
uint8_t numDs; /**< The number of data slices available in current DVB_C2 signal. */
|
||||
uint8_t numNotchs; /**< The number of notches present in current DVB_C2 signal. */
|
||||
uint8_t dsID; /**< The ID of the currently tuned to Data Slice. */
|
||||
uint16_t dsTunePos; /**< The tuning offset of the currently tuned to Data Slice in units of (carriers/Dx) from the start frequency */
|
||||
int16_t dsOffsetOnLeft; /**< The left offset of the currently tuned to Data Slice. */
|
||||
int16_t dsOffsetOnRight; /**< The right offset of the currently tuned to Data Slice. */
|
||||
sony_dvbc2_ds_ti_depth_t dsTiDepth; /**< The time interleaved depth of the currently tuned to Data Slice.*/
|
||||
sony_dvbc2_ds_type_t dsType; /**< The type (1 or 2) of the currently tuned to Data Slice. */
|
||||
sony_dvbc2_fec_header_type_t fecHdrType; /**< The type of the FEC header. */
|
||||
uint8_t dsConstConf; /**< Indicates if the data slice configuration is fixed or variable */
|
||||
uint8_t dsLeftNotch; /**< Indicates the presence of a notch band to the left of the current data slice */
|
||||
uint8_t dsNumPLP; /**< The number of PLPs available (1 - 255) in the currently tuned to Data Slice. */
|
||||
uint8_t plpID; /**< The ID of the selected PLP in the currently tuned to Data Slice. */
|
||||
uint8_t isPlpBundled; /**< Flag to indicate if the selected PLP in the currently tuned to Data Slice is bundled. */
|
||||
sony_dvbc2_plp_type_t plpType; /**< The type of the currently selected PLP. */
|
||||
sony_dvbc2_plp_payload_type_t plpPayloadType; /**< The type of payload contained in the currently selected PLP. */
|
||||
uint8_t plpGroupID; /**< The group ID of the currently selected PLP. */
|
||||
uint16_t plpStart; /**< Indicates the position of the first complete XFEC frame of the associated in the current C2 frame */
|
||||
sony_dvbc2_ldpc_code_length_t plpFecType; /**< The FEC type of the currently selected PLP. */
|
||||
sony_dvbc2_constellation_t plpMod; /**< The modulation of the currently selected PLP */
|
||||
sony_dvbc2_plp_code_rate_t plpCod; /**< The code rate of the currently selected PLP */
|
||||
uint8_t psisiReproc; /**< Indicates whether or not PSI/SI reprocessing is performed or not */
|
||||
uint16_t transportID; /**< The Transport Stream ID of the selected stream. */
|
||||
uint16_t origNetworkID; /**< The original network ID. */
|
||||
uint8_t reservedTone; /**< Reserved Tone. */
|
||||
uint8_t ews; /**< Early warning system */
|
||||
sony_dvbc2_version_t c2Version; /**< C2 version */
|
||||
|
||||
/* Notch data */
|
||||
sony_dvbc2_l1_notch_data_t notches[SONY_DVBC2_NUM_NOTCH_MAX]; /**< Data detailing notch start and width */
|
||||
} sony_dvbc2_l1_t;
|
||||
#endif /* SONY_DVBC2_H */
|
||||
+308
@@ -0,0 +1,308 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/08/30
|
||||
Modification ID : 902dae58eb5249e028ccc5d7f60bb66cca9b43a9
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "sony_integ.h"
|
||||
#include "sony_integ_dvbc.h"
|
||||
#include "sony_demod.h"
|
||||
#include "sony_demod_dvbc.h"
|
||||
#include "sony_demod_dvbc_monitor.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
sony_result_t sony_integ_dvbc_Tune (sony_integ_t * pInteg,
|
||||
sony_dvbc_tune_param_t * pTuneParam)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_integ_dvbc_Tune");
|
||||
|
||||
if ((!pInteg) || (!pTuneParam) || (!pInteg->pDemod)) {
|
||||
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);
|
||||
}
|
||||
|
||||
/* Check bandwidth validity */
|
||||
if ((SONY_DTV_BW_6_MHZ != pTuneParam->bandwidth) &&
|
||||
(SONY_DTV_BW_7_MHZ != pTuneParam->bandwidth) &&
|
||||
(SONY_DTV_BW_8_MHZ != pTuneParam->bandwidth)) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
|
||||
}
|
||||
|
||||
/* Confirm Tune parameters */
|
||||
if (0 == pTuneParam->centerFreqKHz){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Tune the demodulator */
|
||||
result = sony_demod_dvbc_Tune (pInteg->pDemod, pTuneParam);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if ((pInteg->pTuner) && (pInteg->pTuner->TerrCableTune)) {
|
||||
/* Enable the I2C repeater */
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x01);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Tune the RF part */
|
||||
result = pInteg->pTuner->TerrCableTune (pInteg->pTuner, pTuneParam->centerFreqKHz, SONY_DTV_SYSTEM_DVBC, pTuneParam->bandwidth);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset the demod to enable acquisition */
|
||||
result = sony_demod_TuneEnd (pInteg->pDemod);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Wait for demodulator (TS) lock */
|
||||
result = sony_integ_dvbc_WaitTSLock (pInteg);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_integ_dvbc_Scan (sony_integ_t * pInteg,
|
||||
sony_integ_dvbc_scan_param_t * pScanParam,
|
||||
sony_integ_dvbc_scan_callback_t callBack)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
sony_integ_dvbc_scan_result_t scanResult;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_integ_dvbc_Scan");
|
||||
|
||||
if ((!pInteg) || (!pScanParam) || (!callBack) || (!pInteg->pDemod)) {
|
||||
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);
|
||||
}
|
||||
|
||||
/* Check bandwidth validity */
|
||||
if ((SONY_DTV_BW_6_MHZ != pScanParam->bandwidth) &&
|
||||
(SONY_DTV_BW_7_MHZ != pScanParam->bandwidth) &&
|
||||
(SONY_DTV_BW_8_MHZ != pScanParam->bandwidth)) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
|
||||
}
|
||||
|
||||
/* Ensure the scan parameters are valid. */
|
||||
if (pScanParam->endFrequencyKHz < pScanParam->startFrequencyKHz) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
if (pScanParam->stepFrequencyKHz == 0) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Set the start frequency */
|
||||
scanResult.centerFreqKHz = pScanParam->startFrequencyKHz;
|
||||
scanResult.tuneResult = SONY_RESULT_OK;
|
||||
scanResult.tuneParam.centerFreqKHz = pScanParam->startFrequencyKHz;
|
||||
scanResult.tuneParam.bandwidth = pScanParam->bandwidth;
|
||||
|
||||
/* Enable scan mode */
|
||||
result = sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_DVBC, 0x01);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Scan routine */
|
||||
while (scanResult.centerFreqKHz <= pScanParam->endFrequencyKHz) {
|
||||
scanResult.tuneParam.centerFreqKHz = scanResult.centerFreqKHz;
|
||||
scanResult.tuneResult = sony_integ_dvbc_Tune(pInteg, &scanResult.tuneParam);
|
||||
switch (scanResult.tuneResult) {
|
||||
case SONY_RESULT_OK:
|
||||
/* Channel found, callback to application */
|
||||
callBack (pInteg, &scanResult, pScanParam);
|
||||
break;
|
||||
|
||||
/* Intentional fall-through. */
|
||||
case SONY_RESULT_ERROR_UNLOCK:
|
||||
case SONY_RESULT_ERROR_TIMEOUT:
|
||||
/* Channel not found, callback to applicaiton for progress updates */
|
||||
callBack (pInteg, &scanResult, pScanParam);
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Serious error occurred -> cancel operation. */
|
||||
sony_demod_terr_cable_SetScanMode (pInteg->pDemod, SONY_DTV_SYSTEM_DVBC, 0x00);
|
||||
SONY_TRACE_RETURN (scanResult.tuneResult);
|
||||
}
|
||||
|
||||
scanResult.centerFreqKHz += pScanParam->stepFrequencyKHz;
|
||||
|
||||
/* Check cancellation. */
|
||||
result = sony_integ_CheckCancellation (pInteg);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_DVBC, 0x00);
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
|
||||
/* Clear scan mode */
|
||||
result = sony_demod_terr_cable_SetScanMode (pInteg->pDemod, SONY_DTV_SYSTEM_DVBC, 0x00);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_integ_dvbc_WaitTSLock (sony_integ_t * pInteg)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
sony_demod_lock_result_t lock = SONY_DEMOD_LOCK_RESULT_NOTDETECT;
|
||||
sony_stopwatch_t timer;
|
||||
uint8_t continueWait = 1;
|
||||
uint32_t elapsed = 0;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_integ_dvbc_WaitTSLock");
|
||||
|
||||
if ((!pInteg) || (!pInteg->pDemod)) {
|
||||
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);
|
||||
}
|
||||
|
||||
/* Wait for demod lock */
|
||||
result = sony_stopwatch_start (&timer);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
result = sony_stopwatch_elapsed(&timer, &elapsed);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (elapsed >= SONY_DVBC_WAIT_DEMOD_LOCK) {
|
||||
continueWait = 0;
|
||||
}
|
||||
|
||||
result = sony_demod_dvbc_CheckTSLock (pInteg->pDemod, &lock);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
switch (lock) {
|
||||
case SONY_DEMOD_LOCK_RESULT_LOCKED:
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
|
||||
case SONY_DEMOD_LOCK_RESULT_UNLOCKED:
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_UNLOCK);
|
||||
|
||||
default:
|
||||
/* continue waiting... */
|
||||
break;
|
||||
}
|
||||
|
||||
/* Check cancellation. */
|
||||
result = sony_integ_CheckCancellation (pInteg);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (continueWait) {
|
||||
result = sony_stopwatch_sleep (&timer, SONY_DVBC_WAIT_LOCK_INTERVAL);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = SONY_RESULT_ERROR_TIMEOUT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_integ_dvbc_monitor_RFLevel (sony_integ_t * pInteg, int32_t * pRFLeveldB)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_integ_dvbc_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_DVBC) {
|
||||
/* Not DVB-C*/
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
if (!pInteg->pTuner) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
|
||||
}
|
||||
|
||||
if (pInteg->pTuner->rfLevelFuncTerr == 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->rfLevelFuncTerr == SONY_TUNER_RFLEVEL_FUNC_CALCFROMAGC
|
||||
&& pInteg->pTuner->CalcRFLevelFromAGC) {
|
||||
uint32_t ifAgc;
|
||||
|
||||
result = sony_demod_dvbc_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);
|
||||
}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/07/27
|
||||
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_integ_dvbc.h
|
||||
|
||||
This file provides the integration layer interface for DVB-C specific
|
||||
demodulator functions.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SONY_INTEG_DVBC_H
|
||||
#define SONY_INTEG_DVBC_H
|
||||
|
||||
#include "sony_demod.h"
|
||||
#include "sony_integ.h"
|
||||
#include "sony_demod_dvbc.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Defines
|
||||
------------------------------------------------------------------------------*/
|
||||
#define SONY_DVBC_WAIT_DEMOD_LOCK 1000 /**< 1s timeout for wait demodulator lock */
|
||||
#define SONY_DVBC_WAIT_LOCK_INTERVAL 10 /**< 10ms interval for demodulator lock polls */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Structs
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief The parameters used for DVB-C scanning.
|
||||
*/
|
||||
typedef struct sony_integ_dvbc_scan_param_t {
|
||||
/**
|
||||
@brief The start frequency in kHz for scanning
|
||||
*/
|
||||
uint32_t startFrequencyKHz;
|
||||
|
||||
/**
|
||||
@brief The end frequency in kHz for scanning
|
||||
*/
|
||||
uint32_t endFrequencyKHz;
|
||||
|
||||
/**
|
||||
@brief The step frequency in kHz for scanning
|
||||
*/
|
||||
uint32_t stepFrequencyKHz;
|
||||
|
||||
/**
|
||||
@brief The bandwidth to use for tuning during the scan
|
||||
*/
|
||||
sony_dtv_bandwidth_t bandwidth;
|
||||
|
||||
} sony_integ_dvbc_scan_param_t;
|
||||
|
||||
/**
|
||||
@brief The structure used to return a channel located or progress update
|
||||
as part of a DVB-C scan.
|
||||
*/
|
||||
typedef struct sony_integ_dvbc_scan_result_t {
|
||||
/**
|
||||
@brief Indicates the current frequency just attempted for the scan. This would
|
||||
primarily be used to calculate scan progress from the scan parameters.
|
||||
*/
|
||||
uint32_t centerFreqKHz;
|
||||
|
||||
/**
|
||||
@brief Indicates if the tune result at the current frequency. SONY_RESULT_OK
|
||||
means that a channel is locked and the tuneParam structure contains
|
||||
the channel information.
|
||||
*/
|
||||
sony_result_t tuneResult;
|
||||
|
||||
/**
|
||||
@brief The tune params for located DVB-C channel.
|
||||
*/
|
||||
sony_dvbc_tune_param_t tuneParam;
|
||||
} sony_integ_dvbc_scan_result_t;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Function Pointers
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Callback function that is called for every attempted frequency during a DVB-C scan.
|
||||
|
||||
For successful channel results the function is called after TS lock
|
||||
is achieved.
|
||||
|
||||
@param pInteg The driver instance.
|
||||
@param pResult The current scan result.
|
||||
@param pScanParam The current scan parameters.
|
||||
*/
|
||||
typedef void (*sony_integ_dvbc_scan_callback_t) (sony_integ_t * pInteg,
|
||||
sony_integ_dvbc_scan_result_t * pResult,
|
||||
sony_integ_dvbc_scan_param_t * pScanParam);
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Performs acquisition to the channel.
|
||||
|
||||
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 pTuneParam The parameters required for the tune.
|
||||
|
||||
@return SONY_RESULT_OK if tuned successfully to the channel.
|
||||
*/
|
||||
sony_result_t sony_integ_dvbc_Tune (sony_integ_t * pInteg,
|
||||
sony_dvbc_tune_param_t * pTuneParam);
|
||||
|
||||
/**
|
||||
@brief Performs a scan over the spectrum specified.
|
||||
|
||||
Blocks the calling thread while scanning. Use ::sony_integ_Cancel to cancel
|
||||
the operation at any time.
|
||||
|
||||
@param pInteg The driver instance.
|
||||
@param pScanParam The scan parameters.
|
||||
@param callBack User registered call-back to receive scan progress information and
|
||||
notification of found channels. The call back is called for every attempted
|
||||
frequency during a scan.
|
||||
|
||||
@return SONY_RESULT_OK if scan completed successfully.
|
||||
|
||||
*/
|
||||
sony_result_t sony_integ_dvbc_Scan (sony_integ_t * pInteg,
|
||||
sony_integ_dvbc_scan_param_t * pScanParam,
|
||||
sony_integ_dvbc_scan_callback_t callBack);
|
||||
|
||||
/**
|
||||
@brief Polls the demodulator waiting for TS lock over a maximum of 1s at 10ms intervals
|
||||
|
||||
@param pInteg The driver instance
|
||||
|
||||
@return SONY_RESULT_OK if successful.
|
||||
*/
|
||||
sony_result_t sony_integ_dvbc_WaitTSLock (sony_integ_t * pInteg);
|
||||
|
||||
/**
|
||||
@brief RF level monitor function.
|
||||
|
||||
The RF Level monitor calculates an estimated RF level based on either the demodulator
|
||||
IFAGC level or 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.
|
||||
*/
|
||||
sony_result_t sony_integ_dvbc_monitor_RFLevel (sony_integ_t * pInteg, int32_t * pRFLeveldB);
|
||||
|
||||
#endif /* SONY_INTEG_DVBC_H */
|
||||
+578
@@ -0,0 +1,578 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/07/05
|
||||
Modification ID : c7c68d70868a4a9fb9e0f480d8b940e8a1e8f651
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "sony_integ.h"
|
||||
#include "sony_integ_dvbc2.h"
|
||||
#include "sony_demod.h"
|
||||
#include "sony_demod_dvbc2_monitor.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
sony_result_t sony_integ_dvbc2_Tune(sony_integ_t * pInteg,
|
||||
sony_dvbc2_tune_param_t * pTuneParam)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
sony_demod_dvbc2_tune_seq_t tuneSeq;
|
||||
sony_stopwatch_t timer;
|
||||
uint32_t sleepStartTime = 0;
|
||||
uint32_t elapsedTime = 0;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_integ_dvbc2_Tune");
|
||||
|
||||
if ((!pInteg) || (!pTuneParam) || (!pInteg->pDemod)) {
|
||||
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);
|
||||
}
|
||||
|
||||
/* Check bandwidth validity */
|
||||
if ((pTuneParam->bandwidth != SONY_DTV_BW_6_MHZ) && (pTuneParam->bandwidth != SONY_DTV_BW_8_MHZ)) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
|
||||
}
|
||||
|
||||
/* Confirm Tune parameters */
|
||||
if (pTuneParam->c2TuningFrequencyKHz == 0){
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Start stopwatch to measure total waiting time */
|
||||
result = sony_stopwatch_start (&timer);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbc2_InitTuneSeq (pInteg->pDemod, pTuneParam, &tuneSeq);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
while (tuneSeq.running) {
|
||||
if (tuneSeq.sleepTime == 0) {
|
||||
/* Set current total time before calling demod layer function. */
|
||||
/* This is timed from scan start */
|
||||
result = sony_stopwatch_elapsed(&timer, &tuneSeq.currentTime);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbc2_TuneSeq (pInteg->pDemod, &tuneSeq);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Check if RF tuning is invoked in demod layer. */
|
||||
if (tuneSeq.tuneRequired) {
|
||||
/* Enable I2C repeater for tuner comms */
|
||||
if ((pInteg->pTuner) && (pInteg->pTuner->TerrCableTune)) {
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x01);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = pInteg->pTuner->TerrCableTune (pInteg->pTuner, tuneSeq.rfFrequency, SONY_DTV_SYSTEM_DVBC2, pTuneParam->bandwidth);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
tuneSeq.tuneRequired = 0; /* FALSE */
|
||||
|
||||
/* Disable I2C repeater for tuner comms */
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x00);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tuneSeq.sleepTime > 0) {
|
||||
/* Sleep requested, store start time now */
|
||||
result = sony_stopwatch_elapsed(&timer, &sleepStartTime);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tuneSeq.sleepTime > 0) {
|
||||
/* This polling interval is not always same as interval in scan sequence.
|
||||
This interval affects interval for checking cancellation flag. */
|
||||
result = sony_stopwatch_sleep(&timer, SONY_DVBC2_CHECK_CANCEL_INTERVAL);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_stopwatch_elapsed(&timer, &elapsedTime);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (elapsedTime - sleepStartTime >= tuneSeq.sleepTime) {
|
||||
/* Finish sleep */
|
||||
tuneSeq.sleepTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Sanity check on overall wait time. */
|
||||
result = sony_stopwatch_elapsed(&timer, &elapsedTime);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (elapsedTime > SONY_DVBC2_MAX_TUNE_DURATION) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_TIMEOUT);
|
||||
}
|
||||
|
||||
/* Check cancellation. */
|
||||
result = sony_integ_CheckCancellation (pInteg);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
|
||||
result = tuneSeq.lockResult;
|
||||
|
||||
/* Deferred exit if tune failed */
|
||||
if (tuneSeq.lockResult != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (tuneSeq.lockResult);
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_integ_dvbc2_GetChannelTuneParameters (sony_integ_t * pInteg,
|
||||
uint32_t frequencyKHz,
|
||||
sony_dtv_bandwidth_t bandwidth,
|
||||
sony_dvbc2_tune_param_t * pTuneParamArray,
|
||||
uint16_t * pNumTuneParams,
|
||||
uint32_t * pNextChannelFrequencyKHz)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
sony_demod_dvbc2_get_tune_params_seq_t getTuneParamsSeq;
|
||||
sony_dvbc2_tune_param_t tuneParam;
|
||||
sony_stopwatch_t timer;
|
||||
uint32_t sleepStartTime = 0;
|
||||
uint32_t elapsedTime = 0;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_integ_dvbc2_GetChannelTuneParameters");
|
||||
|
||||
if ((!pInteg) || (!pInteg->pDemod) || (!pTuneParamArray) || (!pNumTuneParams) || (!pNextChannelFrequencyKHz)) {
|
||||
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);
|
||||
}
|
||||
|
||||
/* Check bandwidth validity */
|
||||
if ((bandwidth != SONY_DTV_BW_6_MHZ) && (bandwidth != SONY_DTV_BW_8_MHZ)) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
|
||||
}
|
||||
|
||||
/* Start stopwatch to measure total waiting time */
|
||||
result = sony_stopwatch_start (&timer);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Initialize the Get Tune Params structure */
|
||||
result = sony_demod_dvbc2_InitGetTuneParamsSeq (pInteg->pDemod, &getTuneParamsSeq, frequencyKHz, pTuneParamArray);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Set default values for return parameters */
|
||||
*pNumTuneParams = 0;
|
||||
/* Next channel frequency based on C2 system bandwidth */
|
||||
if (bandwidth == SONY_DTV_BW_8_MHZ) {
|
||||
*pNextChannelFrequencyKHz = frequencyKHz + 2000;
|
||||
}
|
||||
else if (bandwidth == SONY_DTV_BW_6_MHZ) {
|
||||
*pNextChannelFrequencyKHz = frequencyKHz + 1500;
|
||||
}
|
||||
else {
|
||||
SONY_TRACE_RETURN(SONY_RESULT_ERROR_NOSUPPORT);
|
||||
}
|
||||
|
||||
/* Set the tune center frequency to the current step for demod initialisation */
|
||||
tuneParam.c2TuningFrequencyKHz = frequencyKHz;
|
||||
tuneParam.bandwidth = bandwidth;
|
||||
tuneParam.dataPLPId = 0;
|
||||
tuneParam.dataSliceId = 0;
|
||||
tuneParam.isDependentStaticDS = 0;
|
||||
tuneParam.rfTuningFrequencyKHz = 0;
|
||||
|
||||
/* Enable acquisition on the demodulator. */
|
||||
result = sony_demod_dvbc2_Tune (pInteg->pDemod, &(tuneParam));
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if ((pInteg->pTuner) && (pInteg->pTuner->TerrCableTune)) {
|
||||
/* Enable I2C repeater for tuner comms */
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x01);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Perform RF tuning. */
|
||||
result = pInteg->pTuner->TerrCableTune (pInteg->pTuner, frequencyKHz, SONY_DTV_SYSTEM_DVBC2, bandwidth);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Disable I2C repeater for tuner comms */
|
||||
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x00);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
|
||||
/* Perform Soft reset to start acquisition */
|
||||
result = sony_demod_TuneEnd (pInteg->pDemod);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
while (getTuneParamsSeq.running) {
|
||||
if (getTuneParamsSeq.sleepTime == 0) {
|
||||
/* Set current total time before calling demod layer function. */
|
||||
/* This is timed from scan start */
|
||||
result = sony_stopwatch_elapsed(&timer, &getTuneParamsSeq.currentTime);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_demod_dvbc2_GetTuneParamsSeq (pInteg->pDemod, &getTuneParamsSeq);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (getTuneParamsSeq.sleepTime > 0) {
|
||||
/* Sleep requested, store start time now */
|
||||
result = sony_stopwatch_elapsed(&timer, &sleepStartTime);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getTuneParamsSeq.sleepTime > 0) {
|
||||
/* This polling interval is not always same as interval in scan sequence.
|
||||
This interval affects interval for checking cancellation flag. */
|
||||
result = sony_stopwatch_sleep(&timer, SONY_DVBC2_CHECK_CANCEL_INTERVAL);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
result = sony_stopwatch_elapsed(&timer, &elapsedTime);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (elapsedTime - sleepStartTime >= getTuneParamsSeq.sleepTime) {
|
||||
/* Finish sleep */
|
||||
getTuneParamsSeq.sleepTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Sanity check on overall wait time. */
|
||||
result = sony_stopwatch_elapsed(&timer, &elapsedTime);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (elapsedTime > SONY_DVBC2_MAX_TUNE_DURATION) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_TIMEOUT);
|
||||
}
|
||||
|
||||
/* Handle internal loop errors (unlock / timeout etc) */
|
||||
if (getTuneParamsSeq.loopResult != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (getTuneParamsSeq.loopResult);
|
||||
}
|
||||
|
||||
/* Check cancellation. */
|
||||
result = sony_integ_CheckCancellation (pInteg);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set tune parameter count */
|
||||
*pNumTuneParams = getTuneParamsSeq.tuneParamIndex;
|
||||
|
||||
if (*pNumTuneParams > 0) {
|
||||
/* Valid channel tune parameters found, return calculated next channel frequency */
|
||||
*pNextChannelFrequencyKHz = getTuneParamsSeq.nextChannelFrequency;
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_integ_dvbc2_Scan (sony_integ_t * pInteg,
|
||||
sony_integ_dvbc2_scan_param_t * pScanParam,
|
||||
sony_integ_dvbc2_scan_callback_t callBack)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
sony_integ_dvbc2_scan_result_t scanResult;
|
||||
sony_dvbc2_tune_param_t tuneParams[256];
|
||||
uint16_t numTuneParams;
|
||||
uint32_t nextChannelFrequencyKHz;
|
||||
uint32_t scanFreqKHz = 0;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_integ_dvbc2_Scan");
|
||||
|
||||
if ((!pInteg) || (!pScanParam) || (!callBack) || (!pInteg->pDemod)) {
|
||||
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);
|
||||
}
|
||||
|
||||
/* Ensure the scan parameters are valid. */
|
||||
if (pScanParam->endFrequencyKHz < pScanParam->startFrequencyKHz) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
|
||||
}
|
||||
|
||||
/* Check bandwidth validity */
|
||||
if ((pScanParam->bandwidth != SONY_DTV_BW_6_MHZ) && (pScanParam->bandwidth != SONY_DTV_BW_8_MHZ)) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
|
||||
}
|
||||
|
||||
/* Set scan mode enabled */
|
||||
result = sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_DVBC2, 0x01);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
/* Set starting frequecy for scan */
|
||||
scanFreqKHz = pScanParam->startFrequencyKHz;
|
||||
|
||||
while (scanFreqKHz <= pScanParam->endFrequencyKHz) {
|
||||
result = sony_integ_dvbc2_GetChannelTuneParameters (pInteg, scanFreqKHz, pScanParam->bandwidth, &tuneParams[0],
|
||||
&numTuneParams, &nextChannelFrequencyKHz);
|
||||
|
||||
if (result == SONY_RESULT_OK) {
|
||||
uint8_t tuneParamIndex = 0;
|
||||
uint8_t channelCount = 0;
|
||||
sony_result_t tuneResult;
|
||||
uint8_t currentDs = 0;
|
||||
uint8_t currentDsTuneSuccess = 0;
|
||||
|
||||
for (tuneParamIndex = 0 ; tuneParamIndex < numTuneParams ; tuneParamIndex++)
|
||||
{
|
||||
if ((currentDsTuneSuccess == 0) ||(tuneParams[tuneParamIndex].dataSliceId != currentDs)) {
|
||||
/* If this is the first acquisition for the tune parameter set, the data
|
||||
* slice has changed or the previous tune to this data slice failed, perform
|
||||
* a full tune. */
|
||||
tuneResult = sony_integ_dvbc2_Tune (pInteg, &tuneParams[tuneParamIndex]);
|
||||
if (tuneResult == SONY_RESULT_OK) {
|
||||
currentDsTuneSuccess = 1;
|
||||
} else {
|
||||
currentDsTuneSuccess = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Select a different PLP in the same data slice */
|
||||
tuneResult = sony_demod_dvbc2_SetPlpId (pInteg->pDemod, tuneParams[tuneParamIndex].dataPLPId);
|
||||
}
|
||||
|
||||
if (tuneResult == SONY_RESULT_OK) {
|
||||
/* Channel parameters are confirmed, provide channel callback */
|
||||
if (callBack) {
|
||||
scanResult.centerFreqKHz = tuneParams[tuneParamIndex].c2TuningFrequencyKHz;
|
||||
scanResult.tuneParam = tuneParams[tuneParamIndex];
|
||||
scanResult.tuneResult = SONY_RESULT_OK;
|
||||
callBack (pInteg, &scanResult, pScanParam);
|
||||
}
|
||||
|
||||
channelCount++;
|
||||
currentDs = tuneParams[tuneParamIndex].dataSliceId;
|
||||
}
|
||||
|
||||
/* Check cancellation. */
|
||||
tuneResult = sony_integ_CheckCancellation (pInteg);
|
||||
if (tuneResult != SONY_RESULT_OK) {
|
||||
sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_DVBC2, 0x00);
|
||||
SONY_TRACE_RETURN (tuneResult);
|
||||
}
|
||||
}
|
||||
|
||||
if (channelCount == 0) {
|
||||
/* Channel parameters were not successfully acquired to, provide progress callback */
|
||||
if (callBack) {
|
||||
scanResult.centerFreqKHz = scanFreqKHz;
|
||||
scanResult.tuneResult = SONY_RESULT_ERROR_UNLOCK;
|
||||
callBack (pInteg, &scanResult, pScanParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((result == SONY_RESULT_ERROR_UNLOCK) || (result == SONY_RESULT_ERROR_TIMEOUT)) {
|
||||
/* Provide progress callback */
|
||||
if (callBack) {
|
||||
scanResult.centerFreqKHz = scanFreqKHz;
|
||||
scanResult.tuneResult = result;
|
||||
callBack (pInteg, &scanResult, pScanParam);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Serious error */
|
||||
sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_DVBC2, 0x00);
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
scanFreqKHz = nextChannelFrequencyKHz;
|
||||
}
|
||||
|
||||
/* Clear scan mode */
|
||||
result = sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_DVBC2, 0x00);
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_integ_dvbc2_WaitTSLock (sony_integ_t * pInteg)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
sony_demod_lock_result_t lock = SONY_DEMOD_LOCK_RESULT_NOTDETECT;
|
||||
sony_stopwatch_t timer;
|
||||
uint8_t continueWait = 1;
|
||||
uint32_t elapsed = 0;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_integ_dvbc2_WaitTSLock");
|
||||
|
||||
if ((!pInteg) || (!pInteg->pDemod)) {
|
||||
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);
|
||||
}
|
||||
|
||||
/* Wait for TS lock */
|
||||
result = sony_stopwatch_start (&timer);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
result = sony_stopwatch_elapsed(&timer, &elapsed);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (elapsed >= SONY_DVBC2_WAIT_TS_LOCK) {
|
||||
continueWait = 0;
|
||||
}
|
||||
|
||||
result = sony_demod_dvbc2_CheckTSLock (pInteg->pDemod, &lock);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
switch (lock) {
|
||||
case SONY_DEMOD_LOCK_RESULT_LOCKED:
|
||||
SONY_TRACE_RETURN (SONY_RESULT_OK);
|
||||
|
||||
case SONY_DEMOD_LOCK_RESULT_UNLOCKED:
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_UNLOCK);
|
||||
|
||||
default:
|
||||
/* continue waiting... */
|
||||
break;
|
||||
}
|
||||
|
||||
/* Check cancellation. */
|
||||
result = sony_integ_CheckCancellation (pInteg);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
if (continueWait) {
|
||||
result = sony_stopwatch_sleep (&timer, SONY_DVBC2_WAIT_LOCK_INTERVAL);
|
||||
if (result != SONY_RESULT_OK) {
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = SONY_RESULT_ERROR_TIMEOUT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SONY_TRACE_RETURN (result);
|
||||
}
|
||||
|
||||
sony_result_t sony_integ_dvbc2_monitor_RFLevel (sony_integ_t * pInteg, int32_t * pRFLeveldB)
|
||||
{
|
||||
sony_result_t result = SONY_RESULT_OK;
|
||||
|
||||
SONY_TRACE_ENTER ("sony_integ_dvbc2_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_DVBC2) {
|
||||
/* Not DVB-C2*/
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
|
||||
}
|
||||
|
||||
if (!pInteg->pTuner) {
|
||||
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
|
||||
}
|
||||
|
||||
if (pInteg->pTuner->rfLevelFuncTerr == 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->rfLevelFuncTerr == SONY_TUNER_RFLEVEL_FUNC_CALCFROMAGC
|
||||
&& pInteg->pTuner->CalcRFLevelFromAGC) {
|
||||
uint32_t ifAgc;
|
||||
|
||||
result = sony_demod_dvbc2_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);
|
||||
}
|
||||
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
|
||||
|
||||
Last Updated : 2018/07/27
|
||||
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file sony_integ_dvbc2.h
|
||||
|
||||
This file provides the integration layer interface for DVB-C2 specific
|
||||
demodulator functions.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SONY_INTEG_DVBC2_H
|
||||
#define SONY_INTEG_DVBC2_H
|
||||
|
||||
#include "sony_demod.h"
|
||||
#include "sony_integ.h"
|
||||
#include "sony_demod_dvbc2.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Defines
|
||||
------------------------------------------------------------------------------*/
|
||||
#define SONY_DVBC2_WAIT_DEMOD_LOCK 2000 /**< 2s timeout for wait demodulator lock process */
|
||||
#define SONY_DVBC2_WAIT_TS_LOCK 2000 /**< 2s timeout for wait TS lock process */
|
||||
#define SONY_DVBC2_WAIT_LOCK_INTERVAL 10 /**< 10ms interval used in wait demodulator and TS lock functions */
|
||||
|
||||
/**
|
||||
@brief The duration in ms between cancellation checks in the sleep routine for
|
||||
the tune and scan sequences.
|
||||
*/
|
||||
#define SONY_DVBC2_CHECK_CANCEL_INTERVAL 10
|
||||
|
||||
/**
|
||||
@brief Maximum duration for a C2 scan routine before reporting an error. 20
|
||||
minutes.
|
||||
*/
|
||||
#define SONY_DVBC2_MAX_SCAN_DURATION 1200000
|
||||
|
||||
/**
|
||||
@brief Maximum duration for a C2 tune routine before reporting an error. 20
|
||||
seconds.
|
||||
*/
|
||||
#define SONY_DVBC2_MAX_TUNE_DURATION 20000
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Structs
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief The parameters used for DVB-C2 scanning.
|
||||
*/
|
||||
typedef struct sony_integ_dvbc2_scan_param_t {
|
||||
/**
|
||||
@brief The start frequency in kHz for scanning
|
||||
*/
|
||||
uint32_t startFrequencyKHz;
|
||||
|
||||
/**
|
||||
@brief The end frequency in kHz for scanning
|
||||
*/
|
||||
uint32_t endFrequencyKHz;
|
||||
|
||||
/**
|
||||
@brief The bandwidth to use for tuning during the scan
|
||||
*/
|
||||
sony_dtv_bandwidth_t bandwidth;
|
||||
} sony_integ_dvbc2_scan_param_t;
|
||||
|
||||
/**
|
||||
@brief The structure used to return a channel located or progress update
|
||||
as part of a DVB-C2 scan.
|
||||
*/
|
||||
typedef struct sony_integ_dvbc2_scan_result_t {
|
||||
/**
|
||||
@brief Indicates the current frequency just attempted for the scan. This would
|
||||
primarily be used to calculate scan progress from the scan parameters.
|
||||
*/
|
||||
uint32_t centerFreqKHz;
|
||||
|
||||
/**
|
||||
@brief Indicates if the tune result at the current frequency. SONY_RESULT_OK
|
||||
means that a channel is locked and the tuneParam structure contains
|
||||
the channel information.
|
||||
*/
|
||||
sony_result_t tuneResult;
|
||||
|
||||
/**
|
||||
@brief The tune params for located DVB-C2 channels.
|
||||
*/
|
||||
sony_dvbc2_tune_param_t tuneParam;
|
||||
} sony_integ_dvbc2_scan_result_t;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Function Pointers
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Callback function that is called for every attempted frequency during a DVB-C2 scan.
|
||||
|
||||
For successful channel results the function is called after demodulator
|
||||
lock but before TS lock is achieved.
|
||||
|
||||
NOTE: This function is invoked for each PLP in each data slice in the system.
|
||||
|
||||
@param pInteg The driver instance.
|
||||
@param pResult The current scan result.
|
||||
@param pScanParam The current scan parameters.
|
||||
|
||||
*/
|
||||
typedef void (*sony_integ_dvbc2_scan_callback_t) (sony_integ_t * pInteg,
|
||||
sony_integ_dvbc2_scan_result_t * pResult,
|
||||
sony_integ_dvbc2_scan_param_t * pScanParam);
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Functions
|
||||
------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@brief Performs acquisition to the channel.
|
||||
|
||||
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 pTuneParam The parameters required for the tune.
|
||||
|
||||
@return SONY_RESULT_OK if tuned successfully to the channel.
|
||||
*/
|
||||
sony_result_t sony_integ_dvbc2_Tune (sony_integ_t * pInteg,
|
||||
sony_dvbc2_tune_param_t * pTuneParam);
|
||||
|
||||
/**
|
||||
@brief Obtains a list of tune parameters for the provided channel frequency and bandwidth.
|
||||
|
||||
A new entry is used for each PLP and data slice combination.
|
||||
|
||||
Blocks the calling thread while scanning. Use ::sony_integ_Cancel to cancel
|
||||
the operation at any time.
|
||||
|
||||
@param pInteg The driver instance.
|
||||
@param frequencyKHz Centre frequency used to detect valid channels.
|
||||
@param bandwidth DVB-C2 bandwidth used to detect valid channels.
|
||||
@param pTuneParamArray List of unique channel tune parameters for the selected centre frequency.
|
||||
@param pNumTuneParams Number of tune parameters in pTuneParamArray.
|
||||
@param pNextChannelFrequencyKHz The centre frequency of the next valid channel location.
|
||||
|
||||
@return SONY_RESULT_OK if scan completed successfully.
|
||||
|
||||
*/
|
||||
sony_result_t sony_integ_dvbc2_GetChannelTuneParameters (sony_integ_t * pInteg,
|
||||
uint32_t frequencyKHz,
|
||||
sony_dtv_bandwidth_t bandwidth,
|
||||
sony_dvbc2_tune_param_t * pTuneParamArray,
|
||||
uint16_t * pNumTuneParams,
|
||||
uint32_t * pNextChannelFrequencyKHz);
|
||||
|
||||
/**
|
||||
@brief Performs a scan over the spectrum specified.
|
||||
|
||||
Blocks the calling thread while scanning. Use ::sony_integ_Cancel to cancel
|
||||
the operation at any time.
|
||||
|
||||
@param pInteg The driver instance.
|
||||
@param pScanParam The scan parameters.
|
||||
@param callBack User registered call-back to receive scan progress information and
|
||||
notification of found channels. The call back is called for every attempted
|
||||
C2 tuning frequency during a scan.
|
||||
|
||||
@return SONY_RESULT_OK if scan completed successfully.
|
||||
|
||||
*/
|
||||
sony_result_t sony_integ_dvbc2_Scan (sony_integ_t * pInteg,
|
||||
sony_integ_dvbc2_scan_param_t * pScanParam,
|
||||
sony_integ_dvbc2_scan_callback_t callBack);
|
||||
|
||||
/**
|
||||
@brief Polls the demodulator waiting for TS lock over a maximum of 2s at 10ms intervals.
|
||||
|
||||
@param pInteg The driver instance.
|
||||
|
||||
@return SONY_RESULT_OK if scan completed successfully.
|
||||
*/
|
||||
sony_result_t sony_integ_dvbc2_WaitTSLock (sony_integ_t * pInteg);
|
||||
|
||||
/**
|
||||
@brief RF level monitor function.
|
||||
|
||||
The RF Level monitor calculates an estimated RF level based on either the demodulator
|
||||
IFAGC level or 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.
|
||||
*/
|
||||
sony_result_t sony_integ_dvbc2_monitor_RFLevel (sony_integ_t * pInteg, int32_t * pRFLeveldB);
|
||||
|
||||
#endif /* SONY_INTEG_DVBC2_H */
|
||||
Reference in New Issue
Block a user