1875 lines
80 KiB
C
Executable File
1875 lines
80 KiB
C
Executable File
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <pthread.h>
|
|
#include <string.h>
|
|
#include <fcntl.h>
|
|
#include <pthread.h> /* mux- */
|
|
#include <unistd.h> /* -System V */
|
|
#include <stropts.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <pthread.h>
|
|
#include <unistd.h>
|
|
#include <sys/ioctl.h>
|
|
#include <linux/types.h>
|
|
#include <linux/i2c.h>
|
|
#include <linux/i2c-dev.h>
|
|
|
|
#include "../inc/config.h"
|
|
#include "../inc/isys_com.h"
|
|
#include "../inc/type.h"
|
|
#include "../inc/lcd_task.h"
|
|
#include "sony_i2c.h"
|
|
#include "sony_cxd6801gl.h"
|
|
#include "sony_app_glue.h"
|
|
#include "sony_common.h"
|
|
#include "sony_example_common.h"
|
|
#include "atsc/sony_integ_atsc3.h"
|
|
#include "atsc/sony_demod_atsc3_monitor.h"
|
|
#include "atsc/sony_demod_atsc.h"
|
|
#include "tuner/terr_cable_ascot3/sony_tuner_ascot3.h"
|
|
#include "tuner/terr_cable_sat_freia/sony_tuner_freia.h"
|
|
#include "sony_demod.h"
|
|
#include "isdb_terr/sony_integ_isdbt.h"
|
|
#include "isdb_terr/sony_demod_isdbt_monitor.h"
|
|
#include "sony_demod_driver_version.h"
|
|
#include "atsc/sony_demod_atsc_monitor.h"
|
|
#include "atsc/sony_integ_atsc.h"
|
|
#include "stdio.h"
|
|
#include "atsc/sony_atsc3.h"
|
|
#include "atsc/sony_demod_atsc3_monitor.h"
|
|
#include "../inc/isys_config.h"
|
|
|
|
|
|
extern u8 g_tun_plpnum;
|
|
extern sony_atsc3_plp_list plpinfos;
|
|
extern pthread_mutex_t mux_i2c_tuner;
|
|
extern int fd_i2c_tuner;
|
|
static sony_driver_instance_t atsc_driver;
|
|
|
|
extern void update_tune_info(void);
|
|
|
|
static u8 conv_sony_pilot_dx_array[]={
|
|
3,4,6,8,12,16,24,32
|
|
};
|
|
|
|
// Global variable to store detected tuner type
|
|
static tuner_chip_type_t g_detected_tuner_type = TUNER_TYPE_UNKNOWN;
|
|
|
|
/**
|
|
* @brief Auto-detect tuner chip type by probing demod I2C addresses
|
|
* @param pI2c Initialized I2C interface
|
|
* @return Detected tuner chip type
|
|
*/
|
|
static tuner_chip_type_t detect_tuner_chip_type(sony_i2c_t *pI2c)
|
|
{
|
|
uint8_t test_data = 0;
|
|
sony_result_t result;
|
|
|
|
printf("\n===========Auto detecting tuner chip type===========\n");
|
|
|
|
if (!pI2c) {
|
|
printf(">>> ERROR: I2C interface is NULL!\n");
|
|
return TUNER_TYPE_UNKNOWN;
|
|
}
|
|
|
|
// Try CXD6821 (FREIA) first - demod I2C address 0xC8
|
|
// SLVX address = SLVT + 4 = 0xC8 + 4 = 0xCC
|
|
printf("Trying TUN FREIA with demod I2C addr 0xC8 (SLVX=0xCC)...\n");
|
|
result = pI2c->ReadRegister(pI2c, 0xCC, 0x00, &test_data, 1);
|
|
if (result == SONY_RESULT_OK) {
|
|
printf(">>> Detected FREIA tuner - demod I2C=0xC8\n");
|
|
return TUNER_TYPE_CXD6821;
|
|
}
|
|
|
|
// Try CXD6801 (ASCOT3) - demod I2C address 0xD8
|
|
// SLVX address = SLVT + 4 = 0xD8 + 4 = 0xDC
|
|
printf("Trying TUN ASCOT3 with demod I2C addr 0xD8 (SLVX=0xDC)...\n");
|
|
result = pI2c->ReadRegister(pI2c, 0xDC, 0x00, &test_data, 1);
|
|
if (result == SONY_RESULT_OK) {
|
|
printf(">>> Detected ASCOT3 tuner - demod I2C=0xD8\n");
|
|
return TUNER_TYPE_CXD6801;
|
|
}
|
|
|
|
printf(">>> ERROR: No tuner chip detected!\n");
|
|
return TUNER_TYPE_UNKNOWN;
|
|
}
|
|
|
|
/**
|
|
* @brief Get demod I2C address based on tuner type
|
|
* @param type Tuner chip type
|
|
* @return Demod I2C address (SLVT)
|
|
*/
|
|
static uint8_t get_demod_i2c_addr(tuner_chip_type_t type)
|
|
{
|
|
switch(type) {
|
|
case TUNER_TYPE_CXD6821:
|
|
return 0xC8;
|
|
case TUNER_TYPE_CXD6801:
|
|
return 0xD8;
|
|
default:
|
|
return 0xD8; // Default to CXD6801
|
|
}
|
|
}
|
|
|
|
sony_result_t sony_InitializeDriver(sony_driver_instance_t *pDriver, uint8_t enableLNBC)
|
|
{
|
|
sony_result_t result = SONY_RESULT_OK;
|
|
sony_demod_create_param_t createParam;
|
|
uint8_t enableTuner = 1;
|
|
|
|
if (!pDriver) {
|
|
return SONY_RESULT_ERROR_ARG;
|
|
}
|
|
|
|
/* Add I2C initialization code for target environment */
|
|
i2c_drv_imx_init(&pDriver->i2c);
|
|
printf("I2C driver initialized\n");
|
|
|
|
/* Auto-detect tuner chip type if not already detected */
|
|
if (g_detected_tuner_type == TUNER_TYPE_UNKNOWN) {
|
|
g_detected_tuner_type = detect_tuner_chip_type(&pDriver->i2c);
|
|
if (g_detected_tuner_type == TUNER_TYPE_UNKNOWN) {
|
|
printf("ERROR: Failed to detect tuner chip type!\n");
|
|
return SONY_RESULT_ERROR_NOSUPPORT;
|
|
}
|
|
}
|
|
|
|
/* Set demod I2C address based on detected tuner type */
|
|
createParam.xtalFreq = SONY_DEMOD_XTAL_24000KHz; /* 24MHz Xtal */
|
|
createParam.i2cAddressSLVT = get_demod_i2c_addr(g_detected_tuner_type);
|
|
createParam.tunerI2cConfig = SONY_DEMOD_TUNER_I2C_CONFIG_REPEATER; /* I2C repeater is used */
|
|
createParam.atscCoreDisable = 0; /* ATSC 1.0 core enable */
|
|
|
|
printf("Using demod I2C address: 0x%02X\n", createParam.i2cAddressSLVT);
|
|
|
|
/* Create tuner driver based on detected chip type */
|
|
if (g_detected_tuner_type == TUNER_TYPE_CXD6821) {
|
|
/* CXD6821: Use Sony FREIA (ASCOT4) tuner */
|
|
printf("Creating FREIA tuner driver for 6821...\n");
|
|
result = sony_tuner_freia_Create(&pDriver->tuner, 0xC0, &pDriver->i2c,
|
|
SONY_ASCOT3_CONFIG_IFAGCSEL_ALL1 | SONY_ASCOT3_CONFIG_REFOUT_600mVpp | SONY_ASCOT3_CONFIG_LOOPFILTER_INTERNAL,
|
|
&pDriver->freia);
|
|
if (result != SONY_RESULT_OK) {
|
|
printf("sony_tuner_freia_Create failed. (%s)\n", Common_Result[result]);
|
|
return result;
|
|
}
|
|
printf("FREIA tuner driver created successfully\n");
|
|
}
|
|
else if (g_detected_tuner_type == TUNER_TYPE_CXD6801) {
|
|
/* CXD6801: Use Sony ASCOT3 tuner */
|
|
printf("Creating ASCOT3 tuner driver for 6801...\n");
|
|
result = sony_tuner_ascot3_Create(&pDriver->tuner, SONY_ASCOT3_XTAL_24000KHz, 0xC0,
|
|
&pDriver->i2c, SONY_ASCOT3_CONFIG_IFAGCSEL_ALL2 | SONY_ASCOT3_CONFIG_REFOUT_600mVpp,
|
|
&pDriver->ascot3);
|
|
if (result != SONY_RESULT_OK) {
|
|
printf("sony_tuner_ascot3_Create failed. (%s)\n", Common_Result[result]);
|
|
return result;
|
|
}
|
|
pDriver->ascot3.xosc_cap_set = 0x28; /* For optimization */
|
|
printf("ASCOT3 tuner driver created successfully\n");
|
|
}
|
|
else {
|
|
printf("ERROR: Unknown tuner type!\n");
|
|
//return SONY_RESULT_ERROR_NOSUPPORT;
|
|
/* CXD6821: Use Sony FREIA (ASCOT4) tuner */
|
|
printf("still try 6821...\n");
|
|
result = sony_tuner_freia_Create(&pDriver->tuner, 0xC0, &pDriver->i2c,
|
|
SONY_ASCOT3_CONFIG_IFAGCSEL_ALL1 | SONY_ASCOT3_CONFIG_REFOUT_600mVpp | SONY_ASCOT3_CONFIG_LOOPFILTER_INTERNAL,
|
|
&pDriver->freia);
|
|
if (result != SONY_RESULT_OK) {
|
|
printf("sony_tuner_freia_Create failed. (%s)\n", Common_Result[result]);
|
|
return result;
|
|
}
|
|
printf("FREIA tuner driver created successfully\n");
|
|
}
|
|
|
|
/* Construct sony_integ_t and sony_demod_t instances */
|
|
/* If the driver need not to control tuner, NULL can be used. */
|
|
/* If the driver need not to control LNBC, NULL can be used. */
|
|
result = sony_integ_Create (&pDriver->integ, &pDriver->demod, &createParam,
|
|
&pDriver->i2c, (enableTuner ? &pDriver->tuner : NULL));
|
|
if (result != SONY_RESULT_OK) {
|
|
printf ("sony_integ_Create failed. (%s)\n", Common_Result[result]);
|
|
return result;
|
|
}
|
|
//printf("sony_integ_Create success\n\n");
|
|
|
|
/*
|
|
* Initialize devices. (demod, tuner, LNBC)
|
|
* Following this call the driver will be in SONY_DEMOD_STATE_SLEEP state.
|
|
* From here you can call any Sleep or Tune APIs.
|
|
* Note : Initialize API should only be called once at the start of the driver creation.
|
|
* Subsequent calls to any of the Tune API's do not require re-initialize.
|
|
*/
|
|
result = sony_integ_Initialize (&pDriver->integ);
|
|
if (result != SONY_RESULT_OK) {
|
|
printf ("sony_integ_Initialize failed. (%s)\n", Common_Result[result]);
|
|
return result;
|
|
}
|
|
printf("sony_integ_Initialize success\n\n");
|
|
|
|
return result;
|
|
}
|
|
/*****************************************************************************
|
|
* Function : sony_cxd6801_tslock_atsc3p0
|
|
* Description :
|
|
* Input : sony_demod_t * p_demod
|
|
uint8_t *p_tslock_state
|
|
uint8_t *p_sync_state
|
|
u8* p_alp_lock_all
|
|
u8* p_plperr 0:all PLPs are founded, 1:not found
|
|
* Output : None
|
|
* Return :
|
|
* Others :
|
|
* Record
|
|
* 1.Date : 20230713
|
|
* Author : Shu.Wang
|
|
* Modification: Created function
|
|
|
|
*****************************************************************************/
|
|
int sony_cxd6801_tslock_atsc3p0(sony_demod_t * p_demod,
|
|
uint8_t *p_tslock_state,
|
|
uint8_t *p_sync_state,
|
|
u8* p_alp_lock_all,
|
|
u8* p_plperr)
|
|
{
|
|
sony_result_t result = 0;
|
|
const char *lock_str[] = {"No", "Yes"};
|
|
const char *unlock_str[] = {"Not Detected", "Detected"};
|
|
uint8_t syncState = 0;
|
|
uint8_t alpLockState[4] = {0};
|
|
uint8_t alpLockAll = 0;
|
|
uint8_t alpUnlockDetected = 0;
|
|
sony_demod_lock_result_t lock = 0;
|
|
int tslock = -1;
|
|
|
|
|
|
result = sony_demod_atsc3_CheckALPLock(p_demod, &lock, p_sync_state,p_alp_lock_all);
|
|
if(lock == SONY_DEMOD_LOCK_RESULT_LOCKED)
|
|
tslock = 1;
|
|
else{
|
|
tslock = 0;
|
|
}
|
|
|
|
*p_tslock_state = tslock;
|
|
return (tslock);
|
|
}
|
|
|
|
|
|
/*****************************************************************************
|
|
* Function : sony_cxd6801_tslock
|
|
* Description : ATSC1.0
|
|
* Input : sony_demod_t * p_demod
|
|
uint8_t *p_tslock_state
|
|
* Output : None
|
|
* Return :
|
|
* Others :
|
|
* Record
|
|
* 1.Date : 20230612
|
|
* Author : Shu.Wang
|
|
* Modification: Created function
|
|
|
|
*****************************************************************************/
|
|
int sony_cxd6801_tslock(sony_demod_t * p_demod, uint8_t *p_tslock_state)
|
|
{
|
|
sony_result_t result = 0;
|
|
uint8_t vqLockState = 0;
|
|
uint8_t agcLockState = 0;
|
|
uint8_t tsLockState = 0;
|
|
uint8_t unlockDetected = 0;
|
|
|
|
result = sony_demod_atsc_monitor_SyncStat (p_demod, &vqLockState, &agcLockState, &tsLockState, &unlockDetected);
|
|
|
|
*p_tslock_state = tsLockState;
|
|
return result;
|
|
}
|
|
int sony_cxd6801_tuner_rssi(sony_integ_t * pInteg, int32_t* p_rflevel)
|
|
{
|
|
int32_t rfLevel = 0;
|
|
sony_result_t result = 0;
|
|
|
|
result = sony_integ_atsc_monitor_RFLevel (pInteg, &rfLevel);
|
|
if (result != SONY_RESULT_OK) {
|
|
rfLevel = -999999;
|
|
}
|
|
|
|
*p_rflevel = (rfLevel/1000); // dBm
|
|
return result;
|
|
|
|
}
|
|
int sony_cxd6801_tuner_rssi_atsc3p0(sony_integ_t * pInteg, int32_t* p_rflevel)
|
|
{
|
|
sony_result_t result = 0;
|
|
int32_t rfLevel = 0;
|
|
|
|
result = sony_integ_atsc3_monitor_RFLevel (pInteg, &rfLevel);
|
|
if (result != SONY_RESULT_OK) {
|
|
rfLevel = -999999;
|
|
}
|
|
|
|
*p_rflevel = (rfLevel/1000); // dBm
|
|
return result;
|
|
}
|
|
|
|
int sony_cxd6801_snr(sony_demod_t * p_demod, int32_t *p_snr)
|
|
{
|
|
int32_t snr;
|
|
sony_result_t result = 0;
|
|
|
|
result = sony_demod_atsc_monitor_SNR(p_demod, &snr);
|
|
if (result != SONY_RESULT_OK) {
|
|
*p_snr = 0;
|
|
}
|
|
*p_snr = snr/1000;
|
|
return result;
|
|
}
|
|
|
|
int sony_cxd6801_snr_atsc3p0(sony_demod_t * p_demod, int32_t *p_snr)
|
|
{
|
|
int32_t snr = 0;
|
|
sony_result_t result = 0;
|
|
result = sony_demod_atsc3_monitor_SNR (p_demod, &snr);
|
|
if (result == SONY_RESULT_OK) {
|
|
//printf (" SNR | SNR | %d x 10^-3 dB\n", snr);
|
|
}
|
|
else {
|
|
//printf (" SNR | Error | %s\n", Common_Result[result]);
|
|
}
|
|
snr = snr/1000;
|
|
*p_snr = snr;
|
|
return (snr);
|
|
|
|
}
|
|
|
|
|
|
|
|
int sony_cxd6801gl_status_update(sony_driver_instance_t *p_driver)
|
|
{
|
|
S_TUNER_INFO tuner_info;
|
|
sony_cxd6801_tuner_rssi(&p_driver->integ, &tuner_info.rssi_db_tuner);
|
|
sony_cxd6801_snr(&p_driver->demod, &tuner_info.snr);
|
|
sony_cxd6801_tslock(&p_driver->demod, (uint8_t*)&tuner_info.locked);
|
|
return 0;
|
|
}
|
|
|
|
|
|
#if 1
|
|
S_TUN_INFO g_tun_info={0};
|
|
S_TUN_INFO g_tun_info_bkp={0};
|
|
|
|
int usr_pr_l1b_info(sony_atsc3_l1basic_t *pl1b_info)
|
|
{
|
|
const char *time_str[] = {"none", "ms", "us", "ns"};
|
|
const char *miso_str[] = {"No MISO", "MISO with 64", "MISO with 256", "Reserved"};
|
|
const char *mode_str[] = {"Mode 1", "Mode 2", "Mode 3", "Mode 4", "Mode 5", "Mode 6", "Mode 7"};
|
|
const char *papr_str[] = {"NONE", "TR", "ACE", "TR_ACE"};
|
|
const char *fft_str[] = {"8k", "16k", "32k"};
|
|
const char *gi_str[] = {"Reserved", "1/192", "2/384", "3/512", "4/768", "5/1024", "6/1536", "7/2048", "8/2432", "9/3072", "10/3648", "11/4096", "12/4864"};
|
|
const char *sp_str[] = {"SP3_2", "SP3_4", "SP4_2", "SP4_4", "SP6_2", "SP6_4", "SP8_2", "SP8_4", "SP12_2", "SP12_4", "SP16_2", "SP16_4", "SP24_2", "SP24_4", "SP32_2", "SP32_4"};
|
|
|
|
if(!pl1b_info)
|
|
return -1;
|
|
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
printf (" L1-Basic | L1B version | %u\n", pl1b_info->version);
|
|
printf (" | MIMO SP enc | %u\n", pl1b_info->mimo_sp_enc);
|
|
printf (" | LLS | %u\n", pl1b_info->lls_flg);
|
|
printf (" | Timing info | %s\n", time_str[pl1b_info->time_info_flg]);
|
|
printf (" | DRC | %u\n", pl1b_info->return_ch_flg);
|
|
printf (" | PAPR | %s\n", papr_str[pl1b_info->papr]);
|
|
printf (" | Frame Len mode | %u\n", pl1b_info->frame_length_mode);
|
|
if (pl1b_info->frame_length_mode == 0) {
|
|
printf (" | Frame Length | %u\n", pl1b_info->frame_length);
|
|
printf (" | EXCESS SMP/SYM | %u\n", pl1b_info->excess_smp_per_sym);
|
|
} else {
|
|
printf (" | Time offset | %u\n", pl1b_info->time_offset);
|
|
printf (" | Additional SMP | %u\n", pl1b_info->additional_smp);
|
|
}
|
|
printf (" | Subframe | %u\n", pl1b_info->num_subframe);
|
|
printf (" | PB Symbol | %u\n", pl1b_info->pb_num_symbol);
|
|
printf (" | PB Cred_coeff | %u\n", pl1b_info->pb_reduced_carriers);
|
|
printf (" | L1D Content Tag | %u\n", pl1b_info->l1d_content_tag);
|
|
|
|
printf (" | L1D Size | %u\n", pl1b_info->l1d_size);
|
|
printf (" | L1D FEC type | %s\n", mode_str[pl1b_info->l1d_fec_type]);
|
|
printf (" | L1D ADD Parity | %u\n", pl1b_info->l1d_add_parity_mode);
|
|
printf (" | SF0 MIMO | %u\n", pl1b_info->sf0_mimo);
|
|
printf (" | SF0 MISO | %s\n", miso_str[pl1b_info->sf0_miso]);
|
|
printf (" | SF0 FFT size | %s\n", fft_str[pl1b_info->sf0_fft_size]);
|
|
printf (" | SF0 Cred_coeff | %u\n", pl1b_info->sf0_reduced_carriers);
|
|
printf (" | SF0 GI | %s\n", gi_str[pl1b_info->sf0_gi]);
|
|
printf (" | SF0 OFDM Symbol | %u\n", pl1b_info->sf0_num_ofdm_symbol);
|
|
printf (" | SF0 SP | %s\n", sp_str[pl1b_info->sf0_sp]);
|
|
printf (" | SF0 SP boost | %u\n", pl1b_info->sf0_sp_boost);
|
|
printf (" | SF0 sbs first | %u\n", pl1b_info->sf0_sbs_first);
|
|
printf (" | SF0 sbs last | %u\n", pl1b_info->sf0_sbs_last);
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
return 0;
|
|
}
|
|
|
|
|
|
int usr_pr_bootstrap_info(sony_atsc3_bootstrap_t *pbootsrap)
|
|
{
|
|
const char *bw_str[] = {"6MHz", "7MHz", "8MHz"};
|
|
|
|
printf (" Bootstrap | BW diff | %u\n", pbootsrap->bw_diff);
|
|
printf (" | BW | %s\n", bw_str[pbootsrap->system_bw]);
|
|
printf (" | EA wakeup | %u\n", pbootsrap->ea_wake_up);
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
}
|
|
|
|
int usr_pr_l1d_info(S_USR_L1D_INFO *pl1d_info, uint8 sub_idx)
|
|
{
|
|
int i,j;
|
|
sony_atsc3_l1detail_common_t *pl1DCommon =&pl1d_info->l1DCommon;
|
|
sony_atsc3_l1detail_subframe_t *pl1DSubframe=&pl1d_info->l1DSubframe[sub_idx];
|
|
sony_atsc3_l1detail_plp_t *pl1DPlp =&pl1d_info->l1DPlp[sub_idx][0];
|
|
|
|
printf (" L1-Detail Comm | L1D version | %u\n", pl1DCommon->version);
|
|
printf (" | Num RF | %u\n", pl1DCommon->num_rf);
|
|
printf (" | BSID | %u\n", pl1DCommon->bonded_bsid);
|
|
printf (" | Time Sec | %u\n", pl1DCommon->time_sec);
|
|
printf (" | Time mSec | %u\n", pl1DCommon->time_msec);
|
|
printf (" | Time uSec | %u\n", pl1DCommon->time_usec);
|
|
printf (" | Frame Len mode | %u\n", pl1DCommon->time_nsec);
|
|
printf (" | BSID (Cur CH) | %u\n", pl1DCommon->bsid);
|
|
printf (" | Res bit len | %u\n", pl1DCommon->reserved_bitlen);
|
|
printf (" | | \n");
|
|
printf (" L1-Detail Subframe %d | Index | %u\n",sub_idx, pl1DSubframe->index);
|
|
printf (" | MIMO | %u\n", pl1DSubframe->mimo);
|
|
printf (" | MISO | %u\n", pl1DSubframe->miso);
|
|
printf (" | FFT Size | %u\n", pl1DSubframe->fft_size);
|
|
printf (" | Reduced Carriers| %u\n", pl1DSubframe->reduced_carriers);
|
|
printf (" | Guard Interval | %u\n", pl1DSubframe->gi);
|
|
printf (" | NUM OFDM SYMBOL | %u\n", pl1DSubframe->num_ofdm_symbol);
|
|
printf (" | SP | %u\n", pl1DSubframe->sp);
|
|
printf (" | SP BOOST | %u\n", pl1DSubframe->sp_boost);
|
|
printf (" | SBS first flg | %u\n", pl1DSubframe->sbs_first);
|
|
printf (" | SBS last flg | %u\n", pl1DSubframe->sbs_last);
|
|
printf (" | Subframe Mux | %u\n", pl1DSubframe->subframe_mux);
|
|
printf (" | Freq interleaver| %u\n", pl1DSubframe->freq_interleaver);
|
|
printf (" | SBS null cells | %u\n", pl1DSubframe->sbs_null_cells);
|
|
printf (" | Num PLP | %u\n", pl1DSubframe->num_plp);
|
|
printf (" | | \n");
|
|
|
|
for(i=0;i<pl1DSubframe->num_plp+1;i++)
|
|
{
|
|
pl1DPlp =&pl1d_info->l1DPlp[sub_idx][i];
|
|
printf ("-------------------------------------------------\n");
|
|
printf (" L1-Detail PLP-%d | ID | %u\n",i, pl1DPlp->id);
|
|
printf (" | LLS Flg | %u\n", pl1DPlp->lls_flg);
|
|
printf (" | Layer | %u\n", pl1DPlp->layer);
|
|
printf (" | Start | %u\n", pl1DPlp->start);
|
|
printf (" | Size | %u\n", pl1DPlp->size);
|
|
printf (" | Scramble Type | %u\n", pl1DPlp->scrambler_type);
|
|
printf (" | FEC TYPE | %u\n", pl1DPlp->fec_type);
|
|
printf (" | Modulation | %u\n", pl1DPlp->mod);
|
|
printf (" | Code Rate | %u\n", pl1DPlp->cod);
|
|
printf (" | Time Intlea Mode| %u\n", pl1DPlp->ti_mode);
|
|
printf (" | FEC block Start | %u\n", pl1DPlp->fec_block_start);
|
|
printf (" | CTI fec start | %u\n", pl1DPlp->cti_fec_block_start);
|
|
printf (" | Num Ch Bonded | %u\n", pl1DPlp->num_ch_bonded);
|
|
printf (" | ch bond format | %u\n", pl1DPlp->ch_bonding_format);
|
|
printf (" | bonded rf id 0 | %u\n", pl1DPlp->bonded_rf_id_0);
|
|
printf (" | bonded rf id 1 | %u\n", pl1DPlp->bonded_rf_id_1);
|
|
printf (" | mimo stream comb| %u\n", pl1DPlp->mimo_stream_combine);
|
|
printf (" | mimo iq intleav | %u\n", pl1DPlp->mimo_iq_interleave);
|
|
printf (" | mimo ph | %u\n", pl1DPlp->mimo_ph);
|
|
printf (" | plp type | %u\n", pl1DPlp->plp_type);
|
|
printf (" | num subslice | %u\n", pl1DPlp->num_subslice);
|
|
printf (" | subslice interval| %u\n", pl1DPlp->subslice_interval);
|
|
|
|
printf (" | ext interleave | %u\n", pl1DPlp->ti_ext_interleave);
|
|
printf (" | cti depth | %u\n", pl1DPlp->cti_depth);
|
|
printf (" | cti start row | %u\n", pl1DPlp->cti_start_row);
|
|
printf (" | hti inter subframe | %u\n", pl1DPlp->hti_inter_subframe);
|
|
printf (" | hti num ti blocks | %u\n", pl1DPlp->hti_num_ti_blocks);
|
|
printf (" | hti num fec blk max| %u\n", pl1DPlp->hti_num_fec_block_max);
|
|
for(j=0;j<pl1DPlp->hti_num_fec_block_max;j++){
|
|
printf (" | hti num fec blk %d | %u\n", i,pl1DPlp->hti_num_fec_block[i]);
|
|
}
|
|
printf (" | hti cell interleav | %u\n", pl1DPlp->hti_cell_interleave);
|
|
printf (" | ldm inj leavel | %u\n", pl1DPlp->ldm_inj_level);
|
|
}
|
|
printf ("-------------------------|--------------------|----------------- \n");
|
|
}
|
|
|
|
|
|
|
|
|
|
void usr_record_l1b_info_change_state(sony_atsc3_l1basic_t *p1, sony_atsc3_l1basic_t *p2)
|
|
{
|
|
printf("\n----l1b base info-----\r\n");
|
|
CMP_VALUE(p1->version, p2->version, "version");
|
|
CMP_VALUE(p1->mimo_sp_enc, p2->mimo_sp_enc, "mimo_sp_enc");
|
|
CMP_VALUE(p1->lls_flg, p2->lls_flg, "lls_flg");
|
|
CMP_VALUE(p1->time_info_flg, p2->time_info_flg, "time_info_flg");
|
|
CMP_VALUE(p1->return_ch_flg, p2->return_ch_flg, "return_ch_flg");
|
|
CMP_VALUE(p1->papr, p2->papr, "papr");
|
|
CMP_VALUE(p1->frame_length_mode, p2->frame_length_mode, "frame_length_mode");
|
|
CMP_VALUE(p1->excess_smp_per_sym, p2->excess_smp_per_sym, "excess_smp_per_sym");
|
|
CMP_VALUE(p1->time_offset, p2->time_offset, "time_offset");
|
|
CMP_VALUE(p1->additional_smp, p2->additional_smp, "additional_smp");
|
|
|
|
CMP_VALUE(p1->num_subframe, p2->num_subframe, "num_subframe");
|
|
CMP_VALUE(p1->pb_num_symbol, p2->pb_num_symbol, "pb_num_symbol");
|
|
CMP_VALUE(p1->pb_reduced_carriers, p2->pb_reduced_carriers, "pb_reduced_carriers");
|
|
CMP_VALUE(p1->l1d_content_tag, p2->l1d_content_tag, "l1d_content_tag");
|
|
CMP_VALUE(p1->l1d_size, p2->l1d_size, "l1d_size");
|
|
CMP_VALUE(p1->l1d_fec_type, p2->l1d_fec_type, "l1d_fec_type");
|
|
CMP_VALUE(p1->l1d_add_parity_mode, p2->l1d_add_parity_mode, "l1d_add_parity_mode");
|
|
CMP_VALUE(p1->sf0_mimo, p2->sf0_mimo, "sf0_mimo");
|
|
CMP_VALUE(p1->sf0_miso, p2->sf0_miso, "sf0_miso");
|
|
CMP_VALUE(p1->sf0_fft_size, p2->sf0_fft_size, "sf0_fft_size");
|
|
CMP_VALUE(p1->sf0_reduced_carriers, p2->sf0_reduced_carriers, "sf0_reduced_carriers");
|
|
CMP_VALUE(p1->sf0_gi, p2->sf0_gi, "sf0_gi");
|
|
CMP_VALUE(p1->sf0_num_ofdm_symbol, p2->sf0_num_ofdm_symbol, "sf0_num_ofdm_symbol");
|
|
CMP_VALUE(p1->sf0_sp, p2->sf0_sp, "sf0_sp");
|
|
CMP_VALUE(p1->sf0_sp_boost, p2->sf0_sp_boost, "sf0_sp_boost");
|
|
CMP_VALUE(p1->sf0_sbs_first, p2->sf0_sbs_first, "sf0_sbs_first");
|
|
CMP_VALUE(p1->sf0_sbs_last, p2->sf0_sbs_last, "sf0_sbs_last");
|
|
|
|
}
|
|
|
|
void usr_record_l1d_com_info_change_state(sony_atsc3_l1detail_common_t *p1, sony_atsc3_l1detail_common_t *p2)
|
|
{
|
|
printf("\n----l1d com info-----\r\n");
|
|
CMP_VALUE(p1->version, p2->version, "version");
|
|
CMP_VALUE(p1->num_rf, p2->num_rf, "num_rf");
|
|
CMP_VALUE(p1->bonded_bsid, p2->bonded_bsid, "bonded_bsid");
|
|
CMP_VALUE(p1->time_sec, p2->time_sec, "time_sec");
|
|
CMP_VALUE(p1->time_msec, p2->time_msec, "time_msec");
|
|
CMP_VALUE(p1->time_usec, p2->time_usec, "time_usec");
|
|
CMP_VALUE(p1->time_nsec, p2->time_nsec, "time_nsec");
|
|
CMP_VALUE(p1->bsid, p2->bsid, "bsid");
|
|
CMP_VALUE(p1->reserved_bitlen, p2->reserved_bitlen, "reserved_bitlen");
|
|
}
|
|
|
|
void usr_record_l1d_sub_info_change_state(sony_atsc3_l1detail_subframe_t *p1, sony_atsc3_l1detail_subframe_t *p2)
|
|
{
|
|
printf("\n----l1d subframe info-----\r\n");
|
|
CMP_VALUE(p1->index, p2->index, "index");
|
|
CMP_VALUE(p1->mimo, p2->mimo, "mimo");
|
|
CMP_VALUE(p1->miso, p2->miso, "miso");
|
|
CMP_VALUE(p1->fft_size, p2->fft_size, "fft_size");
|
|
CMP_VALUE(p1->reduced_carriers, p2->reduced_carriers, "reduced_carriers");
|
|
CMP_VALUE(p1->gi, p2->gi, "gi");
|
|
CMP_VALUE(p1->num_ofdm_symbol, p2->num_ofdm_symbol, "num_ofdm_symbol");
|
|
CMP_VALUE(p1->sp, p2->sp, "sp");
|
|
CMP_VALUE(p1->sp_boost, p2->sp_boost, "sp_boost");
|
|
|
|
CMP_VALUE(p1->sbs_first, p2->sbs_first, "sbs_first");
|
|
CMP_VALUE(p1->sbs_last, p2->sbs_last, "sbs_last");
|
|
CMP_VALUE(p1->subframe_mux, p2->subframe_mux, "subframe_mux");
|
|
CMP_VALUE(p1->freq_interleaver, p2->freq_interleaver, "freq_interleaver");
|
|
|
|
CMP_VALUE(p1->sbs_null_cells, p2->sbs_null_cells, "sbs_null_cells");
|
|
CMP_VALUE(p1->num_plp, p2->num_plp, "num_plp");
|
|
|
|
}
|
|
|
|
void usr_record_l1d_plp_info_change_state(sony_atsc3_l1detail_plp_t *p1, sony_atsc3_l1detail_plp_t *p2)
|
|
{
|
|
printf("\n----l1d plp info-----\r\n");
|
|
CMP_VALUE(p1->id, p2->id, "id");
|
|
CMP_VALUE(p1->lls_flg, p2->lls_flg, "lls_flg");
|
|
CMP_VALUE(p1->layer, p2->layer, "layer");
|
|
CMP_VALUE(p1->start, p2->start, "start");
|
|
CMP_VALUE(p1->size, p2->size, "size");
|
|
|
|
CMP_VALUE(p1->scrambler_type, p2->scrambler_type, "scrambler_type");
|
|
CMP_VALUE(p1->fec_type, p2->fec_type, "fec_type");
|
|
CMP_VALUE(p1->mod, p2->mod, "mod");
|
|
CMP_VALUE(p1->cod, p2->cod, "cod");
|
|
|
|
CMP_VALUE(p1->ti_mode, p2->ti_mode, "ti_mode");
|
|
CMP_VALUE(p1->fec_block_start, p2->fec_block_start, "fec_block_start");
|
|
|
|
CMP_VALUE(p1->cti_fec_block_start, p2->cti_fec_block_start, "cti_fec_block_start");
|
|
CMP_VALUE(p1->num_ch_bonded, p2->num_ch_bonded, "num_ch_bonded");
|
|
|
|
CMP_VALUE(p1->ch_bonding_format, p2->ch_bonding_format, "ch_bonding_format");
|
|
CMP_VALUE(p1->bonded_rf_id_0, p2->bonded_rf_id_0, "bonded_rf_id_0");
|
|
|
|
CMP_VALUE(p1->bonded_rf_id_1, p2->bonded_rf_id_1, "bonded_rf_id_1");
|
|
CMP_VALUE(p1->mimo_stream_combine, p2->mimo_stream_combine, "mimo_stream_combine");
|
|
CMP_VALUE(p1->mimo_iq_interleave, p2->mimo_iq_interleave, "mimo_iq_interleave");
|
|
CMP_VALUE(p1->mimo_ph, p2->mimo_ph, "mimo_ph");
|
|
|
|
CMP_VALUE(p1->plp_type, p2->plp_type, "plp_type");
|
|
CMP_VALUE(p1->num_subslice, p2->num_subslice, "num_subslice");
|
|
CMP_VALUE(p1->subslice_interval, p2->subslice_interval, "subslice_interval");
|
|
|
|
CMP_VALUE(p1->ti_ext_interleave, p2->ti_ext_interleave, "ti_ext_interleave");
|
|
CMP_VALUE(p1->cti_depth, p2->cti_depth, "cti_depth");
|
|
CMP_VALUE(p1->cti_start_row, p2->cti_start_row, "cti_start_row");
|
|
CMP_VALUE(p1->hti_inter_subframe, p2->hti_inter_subframe, "hti_inter_subframe");
|
|
|
|
CMP_VALUE(p1->hti_num_ti_blocks, p2->hti_num_ti_blocks, "hti_num_ti_blocks");
|
|
CMP_VALUE(p1->hti_num_ti_blocks, p2->hti_num_ti_blocks, "hti_num_ti_blocks");
|
|
CMP_VALUE(p1->hti_num_fec_block_max, p2->hti_num_fec_block_max, "hti_num_fec_block_max");
|
|
|
|
CMP_VALUE(p1->hti_cell_interleave, p2->hti_cell_interleave, "hti_cell_interleave");
|
|
CMP_VALUE(p1->ldm_inj_level, p2->ldm_inj_level, "ldm_inj_level");
|
|
|
|
CMP_VALUE(p1->hti_num_fec_block[0], p2->hti_num_fec_block[0], "hti_num_fec_block[0]");
|
|
CMP_VALUE(p1->hti_num_fec_block[1], p2->hti_num_fec_block[1], "hti_num_fec_block[1]");
|
|
CMP_VALUE(p1->hti_num_fec_block[2], p2->hti_num_fec_block[2], "hti_num_fec_block[2]");
|
|
CMP_VALUE(p1->hti_num_fec_block[3], p2->hti_num_fec_block[3], "hti_num_fec_block[3]");
|
|
CMP_VALUE(p1->hti_num_fec_block[4], p2->hti_num_fec_block[4], "hti_num_fec_block[4]");
|
|
CMP_VALUE(p1->hti_num_fec_block[5], p2->hti_num_fec_block[5], "hti_num_fec_block[5]");
|
|
CMP_VALUE(p1->hti_num_fec_block[6], p2->hti_num_fec_block[6], "hti_num_fec_block[6]");
|
|
CMP_VALUE(p1->hti_num_fec_block[7], p2->hti_num_fec_block[7], "hti_num_fec_block[7]");
|
|
CMP_VALUE(p1->hti_num_fec_block[8], p2->hti_num_fec_block[8], "hti_num_fec_block[8]");
|
|
CMP_VALUE(p1->hti_num_fec_block[9], p2->hti_num_fec_block[9], "hti_num_fec_block[9]");
|
|
CMP_VALUE(p1->hti_num_fec_block[10], p2->hti_num_fec_block[10], "hti_num_fec_block[10]");
|
|
CMP_VALUE(p1->hti_num_fec_block[11], p2->hti_num_fec_block[11], "hti_num_fec_block[11]");
|
|
CMP_VALUE(p1->hti_num_fec_block[12], p2->hti_num_fec_block[12], "hti_num_fec_block[12]");
|
|
CMP_VALUE(p1->hti_num_fec_block[13], p2->hti_num_fec_block[13], "hti_num_fec_block[13]");
|
|
CMP_VALUE(p1->hti_num_fec_block[14], p2->hti_num_fec_block[14], "hti_num_fec_block[14]");
|
|
CMP_VALUE(p1->hti_num_fec_block[15], p2->hti_num_fec_block[15], "hti_num_fec_block[15]");
|
|
}
|
|
|
|
int cmp_L1B_signaling_chg(sony_atsc3_l1basic_t *p_new_L1B, sony_atsc3_l1basic_t *p_old_L1B)
|
|
{
|
|
if(p_new_L1B->mimo_sp_enc != p_old_L1B->mimo_sp_enc){
|
|
printf("chg L1B_mimo_scattered_pilot_encoding\n");
|
|
return 1;
|
|
}
|
|
if(p_new_L1B->frame_length_mode != p_old_L1B->frame_length_mode){
|
|
printf("chg L1B_frame_length_mode\n");
|
|
return 1;
|
|
}
|
|
if(p_new_L1B->frame_length != p_old_L1B->frame_length){
|
|
printf("chg L1B_frame_length\n");
|
|
return 1;
|
|
}
|
|
if(p_new_L1B->num_subframe != p_old_L1B->num_subframe){
|
|
printf("chg L1B_num_subframes\n");
|
|
return 1;
|
|
}
|
|
if(p_new_L1B->pb_num_symbol != p_old_L1B->pb_num_symbol){
|
|
printf("chg L1B_preamble_num_symbols\n");
|
|
return 1;
|
|
}
|
|
if(p_new_L1B->pb_reduced_carriers != p_old_L1B->pb_reduced_carriers){
|
|
printf("chg L1B_preamble_reduced_carriers\n");
|
|
return 1;
|
|
}
|
|
if(p_new_L1B->l1d_fec_type != p_old_L1B->l1d_fec_type){
|
|
printf("chg L1B_L1_Detail_fec_type\n");
|
|
return 1;
|
|
}
|
|
if(p_new_L1B->sf0_mimo != p_old_L1B->sf0_mimo){
|
|
printf("chg L1B_first_sub_mimo\n");
|
|
return 1;
|
|
}
|
|
if(p_new_L1B->sf0_miso != p_old_L1B->sf0_miso){
|
|
printf("chg L1B_first_sub_miso\n");
|
|
return 1;
|
|
}
|
|
if(p_new_L1B->sf0_fft_size != p_old_L1B->sf0_fft_size){
|
|
printf("chg L1B_first_sub_fft_size\n");
|
|
return 1;
|
|
}
|
|
if(p_new_L1B->sf0_reduced_carriers != p_old_L1B->sf0_reduced_carriers){
|
|
printf("chg L1B_first_sub_reduced_carriers\n");
|
|
return 1;
|
|
}
|
|
if(p_new_L1B->sf0_gi != p_old_L1B->sf0_gi){
|
|
printf("chg L1B_first_sub_guard_interval\n");
|
|
return 1;
|
|
}
|
|
if(p_new_L1B->sf0_num_ofdm_symbol != p_old_L1B->sf0_num_ofdm_symbol){
|
|
printf("chg L1B_first_sub_num_ofdm_symbols\n");
|
|
return 1;
|
|
}
|
|
if(p_new_L1B->sf0_sp != p_old_L1B->sf0_sp){
|
|
printf("chg L1B_first_sub_scattered_pilot_pattern\n");
|
|
return 1;
|
|
}
|
|
if(p_new_L1B->sf0_sp_boost != p_old_L1B->sf0_sp_boost){
|
|
printf("chg L1B_first_sub_scattered_pilot_boost\n");
|
|
return 1;
|
|
}
|
|
if(p_new_L1B->sf0_sbs_first != p_old_L1B->sf0_sbs_first){
|
|
printf("chg L1B_first_sub_sbs_first\n");
|
|
return 1;
|
|
}
|
|
if(p_new_L1B->sf0_sbs_last != p_old_L1B->sf0_sbs_last){
|
|
printf("chg L1B_first_sub_sbs_last\n");
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
int cmp_L1D_signaling_chg(S_USR_L1D_INFO *p_new_L1D, S_USR_L1D_INFO *p_old_L1D, uint8_t sub_num)
|
|
{
|
|
int i, j;
|
|
|
|
for(i=0; i<sub_num; i++){
|
|
|
|
if(p_new_L1D->l1DSubframe[i].freq_interleaver != p_old_L1D->l1DSubframe[i].freq_interleaver){
|
|
printf("chg L1D_frequency_interleaver\n");
|
|
return 1;
|
|
}
|
|
if(p_new_L1D->l1DSubframe[i].sbs_null_cells != p_old_L1D->l1DSubframe[i].sbs_null_cells){
|
|
printf("chg L1D_sbs_null_cells\n");
|
|
return 1;
|
|
}
|
|
if(p_new_L1D->l1DSubframe[i].num_plp != p_old_L1D->l1DSubframe[i].num_plp){
|
|
printf("chg L1D_num_plp\n");
|
|
return 1;
|
|
}
|
|
|
|
for(j=0;j<4;j++){
|
|
if(p_new_L1D->l1DPlp[i][j].mod != p_old_L1D->l1DPlp[i][j].mod){
|
|
printf("chg L1D_plp_mod\n");
|
|
return 1;
|
|
}
|
|
|
|
if(p_new_L1D->l1DPlp[i][j].cod != p_old_L1D->l1DPlp[i][j].cod){
|
|
printf("chg L1D_plp_cod\n");
|
|
return 1;
|
|
}
|
|
|
|
if(p_new_L1D->l1DPlp[i][j].fec_type != p_old_L1D->l1DPlp[i][j].fec_type){
|
|
printf("chg L1D_plp_fec_type\n");
|
|
return 1;
|
|
}
|
|
|
|
if(p_new_L1D->l1DPlp[i][j].ti_mode != p_old_L1D->l1DPlp[i][j].ti_mode){
|
|
printf("chg L1D_plp_ti_mode\n");
|
|
return 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
int check_tun_info_chg(S_TUN_INFO *pbkp, S_TUN_INFO *pcur)
|
|
{
|
|
int ret=0;
|
|
int i;
|
|
|
|
//g_tun_info
|
|
if(cmp_L1B_signaling_chg(&g_tun_info.l1b, &g_tun_info.l1b)){
|
|
ret=1;
|
|
}
|
|
|
|
if(cmp_L1D_signaling_chg(&g_tun_info.l1d, &g_tun_info.l1d, g_tun_info.l1b.num_subframe)){
|
|
ret=1;
|
|
}
|
|
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int get_tun_plp_array_idx(int subframe_idx, int plp_idx)
|
|
{
|
|
int j;
|
|
int plp_arr_idx = 0;
|
|
|
|
plp_arr_idx = plp_idx;
|
|
for(int j=0;j<subframe_idx;j++){
|
|
plp_arr_idx += g_tun_info.l1d.l1DSubframe[j].num_plp+1;
|
|
}
|
|
return plp_arr_idx;
|
|
}
|
|
|
|
int usr_sony_tuner_l1b_l1d_update()
|
|
{
|
|
int i,j;
|
|
int ret=-1;
|
|
sony_result_t result = SONY_RESULT_OK;
|
|
sony_driver_instance_t *p_driver = &atsc_driver;
|
|
u8 subfrmidx;
|
|
u8 plpidx;
|
|
u8 plp_arr_idx;
|
|
|
|
if(1){
|
|
|
|
//printf ("\n ================= Monitor Tuner ===========================\n\n");
|
|
//printf ("-------------------------|-----------------|----------------- \n");
|
|
//printf (" MONITOR NAME | PARAMETER | VALUE \n");
|
|
//printf ("-------------------------|-----------------|----------------- \n");
|
|
|
|
uint8_t syncState = 0;
|
|
uint8_t alpLockState[4] = {0};
|
|
uint8_t alpLockAll = 0;
|
|
uint8_t alpUnlockDetected = 0;
|
|
|
|
|
|
if(1){//sony_demod_atsc3_monitor_SyncStat
|
|
const char *lock_str[] = {"No", "Yes"};
|
|
const char *unlock_str[] = {"Not Detected", "Detected"};
|
|
|
|
result = (sony_result_t)sony_demod_atsc3_monitor_SyncStat (&p_driver->demod, &syncState, &alpLockState[0], &alpLockAll, &alpUnlockDetected);
|
|
if (result == SONY_RESULT_OK) {
|
|
/*printf (" SyncStat | Sync Status | %u\n", syncState);
|
|
for (j = 0; j < 4; j++) {
|
|
uint8_t alpLock = alpLockState[j];
|
|
printf (" | ALP[%d] Lock | %s\n", j, lock_str[alpLock]);
|
|
}
|
|
printf (" | ALP Lock All | %s\n", lock_str[alpLockAll]);
|
|
printf (" | ALP Unlock | %s\n", unlock_str[alpUnlockDetected])*/
|
|
}
|
|
else {
|
|
printf (" SyncStat | Error | %s\n", Common_Result[result]);
|
|
}
|
|
//printf ("-------------------------|-----------------|----------------- \n");
|
|
}
|
|
|
|
if(alpLockAll==1)
|
|
{
|
|
sony_atsc3_l1detail_raw_t l1detail={0};
|
|
|
|
//bootstrap
|
|
result = sony_demod_atsc3_monitor_Bootstrap (&p_driver->demod, &g_tun_info.boots);
|
|
if (result == SONY_RESULT_OK) {
|
|
// usr_pr_bootstrap_info(&g_tun_info.boots);
|
|
}
|
|
else {
|
|
printf (" Bootstrap | Error | %s\n", Common_Result[result]);
|
|
}
|
|
|
|
//get preamble_pilot_dx
|
|
sony_atsc3_ofdm_t ofdm;
|
|
u8 preamble_pilot_dx;
|
|
result = sony_demod_atsc3_monitor_OFDM (&p_driver->demod, &ofdm);
|
|
|
|
g_tun_info.oth.preamble_pilot_dx = conv_sony_pilot_dx_array[ofdm.pb_pilot];
|
|
|
|
result = sony_demod_atsc3_monitor_L1Detail_raw(&p_driver->demod, &g_tun_info.l1b, &l1detail);
|
|
if(result==SONY_RESULT_OK){
|
|
//l1b
|
|
// usr_pr_l1b_info(&g_tun_info.l1b);
|
|
plp_arr_idx = plpinfos.plplist[0].id;
|
|
if(g_tun_info.l1b.num_subframe<2){
|
|
|
|
for(subfrmidx=0;subfrmidx<g_tun_info.l1b.num_subframe+1;subfrmidx++){
|
|
|
|
if(subfrmidx>0){
|
|
plp_arr_idx = get_tun_plp_array_idx(subfrmidx, 0);
|
|
}
|
|
|
|
sony_demod_atsc3_monitor_L1Detail_convert(&p_driver->demod, &g_tun_info.l1b, &l1detail, plp_arr_idx,
|
|
&g_tun_info.l1d.l1DCommon, &g_tun_info.l1d.l1DSubframe[subfrmidx], &g_tun_info.l1d.l1DPlp[subfrmidx][0]);
|
|
//printf(">subxi=%d plpnum=%d plpidxj=%d id=%d\n",subfrmidx,g_tun_info.l1d.l1DSubframe[subfrmidx].num_plp+1, 0, plpinfos.plplist[plp_arr_idx].id);
|
|
|
|
if(g_tun_info.l1d.l1DSubframe[subfrmidx].num_plp>=1 && g_tun_info.l1d.l1DSubframe[subfrmidx].num_plp<=3){
|
|
for(plpidx=1; plpidx<=g_tun_info.l1d.l1DSubframe[subfrmidx].num_plp; plpidx++){
|
|
plp_arr_idx = get_tun_plp_array_idx(subfrmidx, plpidx);
|
|
|
|
sony_demod_atsc3_monitor_L1Detail_convert(&p_driver->demod, &g_tun_info.l1b, &l1detail, plpinfos.plplist[plp_arr_idx].id,
|
|
&g_tun_info.l1d.l1DCommon, &g_tun_info.l1d.l1DSubframe[subfrmidx], &g_tun_info.l1d.l1DPlp[subfrmidx][plpidx]);
|
|
//printf(">subxi=%d plpnum=%d plpidxj=%d id=%d\n",subfrmidx,g_tun_info.l1d.l1DSubframe[subfrmidx].num_plp+1, plpidx, plpinfos.plplist[plp_arr_idx].id);
|
|
|
|
//printf(">subxi=%d plpnum=%d plpidxj=%d id=%02d lls_flg=%d bflg=%d\n",subfrmidx,g_tun_info.l1d.l1DSubframe[subfrmidx].num_plp+1,
|
|
// plpidx, plpinfos.plplist[plp_arr_idx].id, g_tun_info.l1d.l1DPlp[subfrmidx][plpidx].lls_flg, g_tun_info.l1b.lls_flg);
|
|
}
|
|
}
|
|
|
|
if(g_tun_info.l1d.l1DSubframe[subfrmidx].num_plp>3){
|
|
printf("num_plp over max_is_4, now=%d!\n",g_tun_info.l1d.l1DSubframe[subfrmidx].num_plp);
|
|
}
|
|
// usr_pr_l1d_info(&g_tun_info.l1d, subfrmidx);
|
|
}
|
|
}
|
|
else{
|
|
printf("num_subframe over max_is_2, now=%d!\n",g_tun_info.l1b.num_subframe);
|
|
}
|
|
}
|
|
else{
|
|
printf (" L1B-L1D | Error | %s\n", Common_Result[result]);
|
|
}
|
|
}
|
|
}
|
|
|
|
if(check_tun_info_chg(&g_tun_info_bkp, &g_tun_info)==1 || 0 /*PR04:SMOD no tun_ctl(atsc3 only)*/){
|
|
memcpy(&g_tun_info_bkp, &g_tun_info, sizeof(g_tun_info));
|
|
ret= 1;
|
|
}
|
|
|
|
//printf("<<<==========================================================\n\n\n");
|
|
return ret;
|
|
}
|
|
|
|
void usr_sony_cxd6801gl_state_monitor(sony_driver_instance_t *p_driver)
|
|
{
|
|
int i;
|
|
int j;
|
|
|
|
sony_result_t result = SONY_RESULT_OK;
|
|
|
|
#define MONITOR_LOOP_COUNT 1
|
|
|
|
/*----------------------------------------------------------------------------------
|
|
* Monitor the Channel
|
|
*------------------------------------------------------------------------------- */
|
|
printf("\n>>>\n");
|
|
printf ("------------------------------------------\n");
|
|
printf (" Monitor\n");
|
|
printf ("------------------------------------------\n");
|
|
|
|
|
|
static sony_atsc3_l1basic_t stc_l1basic={0};
|
|
|
|
static sony_atsc3_l1detail_common_t stc_l1DetailCommon={0};
|
|
static sony_atsc3_l1detail_subframe_t stc_l1DetailSubframe={0};
|
|
static sony_atsc3_l1detail_plp_t stc_l1DetailPlp={0};
|
|
|
|
static char l1d_first_flg=1;
|
|
|
|
if(1){
|
|
|
|
#if 1
|
|
printf ("\n Monitor Iteration : %u \n\n",i);
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
printf (" MONITOR NAME | PARAMETER | VALUE \n");
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
|
|
{//sony_demod_atsc3_monitor_SyncStat
|
|
const char *lock_str[] = {"No", "Yes"};
|
|
const char *unlock_str[] = {"Not Detected", "Detected"};
|
|
|
|
uint8_t syncState = 0;
|
|
uint8_t alpLockState[4] = {0};
|
|
uint8_t alpLockAll = 0;
|
|
uint8_t alpUnlockDetected = 0;
|
|
|
|
result = (sony_result_t)sony_demod_atsc3_monitor_SyncStat (&p_driver->demod, &syncState, &alpLockState[0], &alpLockAll, &alpUnlockDetected);
|
|
if (result == SONY_RESULT_OK) {
|
|
printf (" SyncStat | Sync Status | %u\n", syncState);
|
|
for (j = 0; j < 4; j++) {
|
|
uint8_t alpLock = alpLockState[j];
|
|
printf (" | ALP[%d] Lock | %s\n", j, lock_str[alpLock]);
|
|
}
|
|
printf (" | ALP Lock All | %s\n", lock_str[alpLockAll]);
|
|
printf (" | ALP Unlock | %s\n", unlock_str[alpUnlockDetected]);
|
|
}
|
|
else {
|
|
printf (" SyncStat | Error | %s\n", Common_Result[result]);
|
|
}
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
}
|
|
|
|
{//sony_demod_atsc3_monitor_IFAGCOut
|
|
uint32_t ifAGCOut = 0;
|
|
result = sony_demod_atsc3_monitor_IFAGCOut (&p_driver->demod, &ifAGCOut);
|
|
if (result == SONY_RESULT_OK) {
|
|
printf (" IFAGCOut | IF AGC | %u\n", ifAGCOut);
|
|
}
|
|
else {
|
|
printf (" IFAGCOut | Error | %s\n", Common_Result[result]);
|
|
}
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
}
|
|
|
|
{//sony_demod_atsc3_monitor_CarrierOffset
|
|
int32_t offset;
|
|
result = sony_demod_atsc3_monitor_CarrierOffset (&p_driver->demod, &offset);
|
|
if (result == SONY_RESULT_OK) {
|
|
printf (" CarrierOffset | Carrier Offset | %d Hz\n", offset);
|
|
}
|
|
else {
|
|
printf (" CarrierOffset | Error | %s\n", Common_Result[result]);
|
|
}
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
}
|
|
|
|
{//sony_demod_atsc3_monitor_SpectrumSense
|
|
const char *spectrumsense_str[2] = {"Normal", "Inverted"};
|
|
|
|
sony_demod_terr_cable_spectrum_sense_t sense;
|
|
result = sony_demod_atsc3_monitor_SpectrumSense (&p_driver->demod, &sense);
|
|
if (result == SONY_RESULT_OK) {
|
|
printf (" SpectrumSense | Spectrum Sense | %s\n", spectrumsense_str[sense]);
|
|
}
|
|
else {
|
|
printf (" SpectrumSense | Error | %s\n", Common_Result[result]);
|
|
}
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
}
|
|
|
|
{//sony_demod_atsc3_monitor_SamplingOffset
|
|
int32_t ppmOffset;
|
|
result = sony_demod_atsc3_monitor_SamplingOffset (&p_driver->demod, &ppmOffset);
|
|
if (result == SONY_RESULT_OK) {
|
|
printf (" SamplingOffset | PPM Offset | %d x 10^-2 ppm\n", ppmOffset);
|
|
}
|
|
else {
|
|
printf (" SamplingOffset | Error | %s\n", Common_Result[result]);
|
|
}
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
}
|
|
|
|
{//sony_demod_atsc3_monitor_SNR
|
|
int32_t snr;
|
|
result = sony_demod_atsc3_monitor_SNR (&p_driver->demod, &snr);
|
|
if (result == SONY_RESULT_OK) {
|
|
printf (" SNR | SNR | %d x 10^-3 dB\n", snr);
|
|
}
|
|
else {
|
|
printf (" SNR | Error | %s\n", Common_Result[result]);
|
|
}
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
}
|
|
|
|
{//sony_demod_atsc3_monitor_PreLDPCBER
|
|
uint32_t ber[4];
|
|
result = sony_demod_atsc3_monitor_PreLDPCBER (&p_driver->demod, &ber[0]);
|
|
if (result == SONY_RESULT_OK) {
|
|
printf (" PreLDPCBER | Pre-LDPC BER[0] | %u x 10^-7\n", ber[0]);
|
|
for(j = 1; j < 4; j++) {
|
|
if (ber[j] == SONY_DEMOD_ATSC3_MONITOR_PRELDPCBER_INVALID) {
|
|
printf (" | Pre-LDPC BER[%d] | Unused\n", j);
|
|
} else {
|
|
printf (" | Pre-LDPC BER[%d] | %u x 10^-7\n", j, ber[j]);
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
printf (" PreLDPCBER | Error | %s\n", Common_Result[result]);
|
|
}
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
}
|
|
|
|
{//sony_demod_atsc3_monitor_PreBCHBER
|
|
uint32_t ber[4];
|
|
result = sony_demod_atsc3_monitor_PreBCHBER (&p_driver->demod, &ber[0]);
|
|
if (result == SONY_RESULT_OK) {
|
|
printf (" PreBCHBER | Pre-BCH BER[0] | %u x 10^-9\n", ber[0]);
|
|
for(j = 1; j < 4; j++) {
|
|
if (ber[j] == SONY_DEMOD_ATSC3_MONITOR_PRELDPCBER_INVALID) {
|
|
printf (" | Pre-BCH BER[%d] | Unused\n", j);
|
|
} else {
|
|
printf (" | Pre-BCH BER[%d] | %u x 10^-9\n", j, ber[j]);
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
printf (" PreBCHBER | Error | %s\n", Common_Result[result]);
|
|
}
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
}
|
|
|
|
{//sony_demod_atsc3_monitor_PostBCHFER
|
|
uint32_t fer[4];
|
|
result = sony_demod_atsc3_monitor_PostBCHFER (&p_driver->demod, &fer[0]);
|
|
if (result == SONY_RESULT_OK) {
|
|
printf (" PostBCHFER | Post-BCH FER[0] | %u x 10^-6\n", fer[0]);
|
|
for(j = 1; j < 4; j++) {
|
|
if (fer[j] == SONY_DEMOD_ATSC3_MONITOR_POSTBCHFER_INVALID) {
|
|
printf (" | Post-BCH FER[%d] | Unused\n", j);
|
|
} else {
|
|
printf (" | Post-BCH FER[%d] | %u x 10^-6\n", j, fer[j]);
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
printf (" PostBCHFER | Error | %s\n", Common_Result[result]);
|
|
}
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
}
|
|
|
|
{//sony_demod_atsc3_monitor_BBPacketErrorNumber
|
|
uint32_t pen[4];
|
|
result = sony_demod_atsc3_monitor_BBPacketErrorNumber (&p_driver->demod, &pen[0]);
|
|
if (result == SONY_RESULT_OK) {
|
|
printf (" BBPacketErrorNumber | BBPacketError[0]| %u\n", pen[0]);
|
|
for(j = 1; j < 4; j++) {
|
|
printf (" | BBPacketError[%d]| %u\n", j, pen[j]);
|
|
}
|
|
}
|
|
else {
|
|
printf (" BBPacketErrorNumber | Error | %s\n", Common_Result[result]);
|
|
}
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
}
|
|
|
|
{//sony_demod_atsc3_monitor_Bootstrap
|
|
const char *bw_str[] = {"6MHz", "7MHz", "8MHz"};
|
|
|
|
sony_atsc3_bootstrap_t boot_strap;
|
|
result = sony_demod_atsc3_monitor_Bootstrap (&p_driver->demod, &boot_strap);
|
|
if (result == SONY_RESULT_OK) {
|
|
printf (" Bootstrap | BW diff | %u\n", boot_strap.bw_diff);
|
|
printf (" | BW | %s\n", bw_str[boot_strap.system_bw]);
|
|
printf (" | EA wakeup | %u\n", boot_strap.ea_wake_up);
|
|
}
|
|
else {
|
|
printf (" OFDM | Error | %s\n", Common_Result[result]);
|
|
}
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
}
|
|
|
|
{//sony_demod_atsc3_monitor_OFDM
|
|
const char *bw_str[] = {"6MHz", "7MHz", "8MHz"};
|
|
const char *mode_str[] = {"Mode 1", "Mode 2", "Mode 3", "Mode 4", "Mode 5", "Mode 6", "Mode 7"};
|
|
const char *papr_str[] = {"NONE", "TR", "ACE", "TR_ACE"};
|
|
const char *fft_str[] = {"8k", "16k", "32k"};
|
|
const char *gi_str[] = {"Reserved", "1/192", "2/384", "3/512", "4/768", "5/1024", "6/1536", "7/2048", "8/2432", "9/3072", "10/3648", "11/4096", "12/4864"};
|
|
const char *sp_str[] = {"SP3_2", "SP3_4", "SP4_2", "SP4_4", "SP6_2", "SP6_4", "SP8_2", "SP8_4", "SP12_2", "SP12_4", "SP16_2", "SP16_4", "SP24_2", "SP24_4", "SP32_2", "SP32_4"};
|
|
const char *pilot_str[] = {"Dx3", "Dx4", "Dx6", "Dx8", "Dx12", "Dx16", "Dx24", "Dx32"};
|
|
|
|
sony_atsc3_ofdm_t ofdm;
|
|
result = sony_demod_atsc3_monitor_OFDM (&p_driver->demod, &ofdm);
|
|
if (result == SONY_RESULT_OK) {
|
|
printf (" OFDM | BW | %s\n", bw_str[ofdm.system_bw]);
|
|
printf (" | BS Symbol | %u\n", ofdm.bs_num_symbol);
|
|
printf (" | Subframe | %u\n", ofdm.num_subframe);
|
|
printf (" | L1B FEC type | %s\n", mode_str[ofdm.l1b_fec_type]);
|
|
printf (" | PAPR | %s\n", papr_str[ofdm.papr]);
|
|
printf (" | PB Symbol | %u\n", ofdm.pb_num_symbol);
|
|
printf (" | PB FFT size | %s\n", fft_str[ofdm.pb_fft_size]);
|
|
printf (" | PB Pilot | %s\n", pilot_str[ofdm.pb_pilot]);
|
|
printf (" | PB Cred_coeff | %u\n", ofdm.pb_reduced_carriers);
|
|
printf (" | PB GI | %s\n", gi_str[ofdm.pb_gi]);
|
|
printf (" | SF0 FFT size | %s\n", fft_str[ofdm.sf0_fft_size]);
|
|
printf (" | SF0 SP | %s\n", sp_str[ofdm.sf0_sp]);
|
|
printf (" | SF0 Cred_coeff | %u\n", ofdm.sf0_reduced_carriers);
|
|
printf (" | SF0 GI | %s\n", gi_str[ofdm.sf0_gi]);
|
|
printf (" | SF0 SP boost | %u\n", ofdm.sf0_sp_boost);
|
|
printf (" | SF0 sbs first | %u\n", ofdm.sf0_sbs_first);
|
|
printf (" | SF0 sbs last | %u\n", ofdm.sf0_sbs_last);
|
|
printf (" | SF0 OFDM Symbol | %u\n", ofdm.sf0_num_ofdm_symbol);
|
|
}
|
|
else {
|
|
printf (" OFDM | Error | %s\n", Common_Result[result]);
|
|
}
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
}
|
|
#endif
|
|
|
|
{//sony_demod_atsc3_monitor_L1Basic
|
|
const char *time_str[] = {"none", "ms", "us", "ns"};
|
|
const char *miso_str[] = {"No MISO", "MISO with 64", "MISO with 256", "Reserved"};
|
|
const char *mode_str[] = {"Mode 1", "Mode 2", "Mode 3", "Mode 4", "Mode 5", "Mode 6", "Mode 7"};
|
|
const char *papr_str[] = {"NONE", "TR", "ACE", "TR_ACE"};
|
|
const char *fft_str[] = {"8k", "16k", "32k"};
|
|
const char *gi_str[] = {"Reserved", "1/192", "2/384", "3/512", "4/768", "5/1024", "6/1536", "7/2048", "8/2432", "9/3072", "10/3648", "11/4096", "12/4864"};
|
|
const char *sp_str[] = {"SP3_2", "SP3_4", "SP4_2", "SP4_4", "SP6_2", "SP6_4", "SP8_2", "SP8_4", "SP12_2", "SP12_4", "SP16_2", "SP16_4", "SP24_2", "SP24_4", "SP32_2", "SP32_4"};
|
|
|
|
|
|
sony_atsc3_l1basic_t l1basic;
|
|
|
|
|
|
result = sony_demod_atsc3_monitor_L1Basic (&p_driver->demod, &l1basic);
|
|
if (result == SONY_RESULT_OK) {
|
|
|
|
#if USR_PR_TUNER_INFO
|
|
|
|
printf (" L1-Basic | L1B version | %u\n", l1basic.version);
|
|
printf (" | MIMO SP enc | %u\n", l1basic.mimo_sp_enc);
|
|
printf (" | LLS | %u\n", l1basic.lls_flg);
|
|
printf (" | Timing info | %s\n", time_str[l1basic.time_info_flg]);
|
|
printf (" | DRC | %u\n", l1basic.return_ch_flg);
|
|
printf (" | PAPR | %s\n", papr_str[l1basic.papr]);
|
|
printf (" | Frame Len mode | %u\n", l1basic.frame_length_mode);
|
|
if (l1basic.frame_length_mode == 0) {
|
|
printf (" | Frame Length | %u\n", l1basic.frame_length);
|
|
printf (" | EXCESS SMP/SYM | %u\n", l1basic.excess_smp_per_sym);
|
|
} else {
|
|
printf (" | Time offset | %u\n", l1basic.time_offset);
|
|
printf (" | Additional SMP | %u\n", l1basic.additional_smp);
|
|
}
|
|
printf (" | Subframe | %u\n", l1basic.num_subframe);
|
|
printf (" | PB Symbol | %u\n", l1basic.pb_num_symbol);
|
|
printf (" | PB Cred_coeff | %u\n", l1basic.pb_reduced_carriers);
|
|
printf (" | L1D Content Tag | %u\n", l1basic.l1d_content_tag);
|
|
|
|
printf (" | L1D Size | %u\n", l1basic.l1d_size);
|
|
printf (" | L1D FEC type | %s\n", mode_str[l1basic.l1d_fec_type]);
|
|
printf (" | L1D ADD Parity | %u\n", l1basic.l1d_add_parity_mode);
|
|
printf (" | SF0 MIMO | %u\n", l1basic.sf0_mimo);
|
|
printf (" | SF0 MISO | %s\n", miso_str[l1basic.sf0_miso]);
|
|
printf (" | SF0 FFT size | %s\n", fft_str[l1basic.sf0_fft_size]);
|
|
printf (" | SF0 Cred_coeff | %u\n", l1basic.sf0_reduced_carriers);
|
|
printf (" | SF0 GI | %s\n", gi_str[l1basic.sf0_gi]);
|
|
printf (" | SF0 OFDM Symbol | %u\n", l1basic.sf0_num_ofdm_symbol);
|
|
printf (" | SF0 SP | %s\n", sp_str[l1basic.sf0_sp]);
|
|
printf (" | SF0 SP boost | %u\n", l1basic.sf0_sp_boost);
|
|
printf (" | SF0 sbs first | %u\n", l1basic.sf0_sbs_first);
|
|
printf (" | SF0 sbs last | %u\n", l1basic.sf0_sbs_last);
|
|
#endif//USR_PR_TUNER_INFO
|
|
}
|
|
else {
|
|
printf (" L1-Basic | Error | %s\n", Common_Result[result]);
|
|
}
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
}
|
|
|
|
{//sony_demod_atsc3_monitor_L1Detail_convert
|
|
const char *time_str[] = {"none", "ms", "us", "ns"};
|
|
const char *miso_str[] = {"No MISO", "MISO with 64", "MISO with 256", "Reserved"};
|
|
const char *mode_str[] = {"Mode 1", "Mode 2", "Mode 3", "Mode 4", "Mode 5", "Mode 6", "Mode 7"};
|
|
const char *papr_str[] = {"NONE", "TR", "ACE", "TR_ACE"};
|
|
const char *fft_str[] = {"8k", "16k", "32k"};
|
|
const char *gi_str[] = {"Reserved", "1/192", "2/384", "3/512", "4/768", "5/1024", "6/1536", "7/2048", "8/2432", "9/3072", "10/3648", "11/4096", "12/4864"};
|
|
const char *sp_str[] = {"SP3_2", "SP3_4", "SP4_2", "SP4_4", "SP6_2", "SP6_4", "SP8_2", "SP8_4", "SP12_2", "SP12_4", "SP16_2", "SP16_4", "SP24_2", "SP24_4", "SP32_2", "SP32_4"};
|
|
|
|
sony_atsc3_l1basic_t l1basic;
|
|
sony_atsc3_l1detail_raw_t l1detail;
|
|
|
|
result = sony_demod_atsc3_monitor_L1Detail_raw(&p_driver->demod, &l1basic, &l1detail);
|
|
|
|
uint8 usr_plp_id = 2;
|
|
|
|
sony_atsc3_l1detail_common_t l1DetailCommon;
|
|
sony_atsc3_l1detail_subframe_t l1DetailSubframe;
|
|
sony_atsc3_l1detail_plp_t l1DetailPlp;
|
|
sony_atsc3_bootstrap_t Bootstrap;
|
|
sony_demod_atsc3_monitor_Bootstrap(&p_driver->demod,&Bootstrap);
|
|
|
|
|
|
sony_demod_atsc3_monitor_L1Detail_convert(&p_driver->demod, &l1basic, &l1detail, usr_plp_id,
|
|
&l1DetailCommon, &l1DetailSubframe, &l1DetailPlp);
|
|
|
|
if (result == SONY_RESULT_OK) {
|
|
|
|
#if USR_PR_TUNER_INFO
|
|
printf (" L1-Detail Comm | L1D version | %u\n", l1DetailCommon.version);
|
|
printf (" | Num RF | %u\n", l1DetailCommon.num_rf);
|
|
printf (" | BSID | %u\n", l1DetailCommon.bonded_bsid);
|
|
printf (" | Time Sec | %u\n", l1DetailCommon.time_sec);
|
|
printf (" | Time mSec | %u\n", l1DetailCommon.time_msec);
|
|
printf (" | Time uSec | %u\n", l1DetailCommon.time_usec);
|
|
printf (" | Frame Len mode | %u\n", l1DetailCommon.time_nsec);
|
|
printf (" | BSID (Cur CH) | %u\n", l1DetailCommon.bsid);
|
|
printf (" | Res bit len | %u\n", l1DetailCommon.reserved_bitlen);
|
|
printf (" | | \n");
|
|
printf (" L1-Detail Subframe | Index | %u\n", l1DetailSubframe.index);
|
|
printf (" | MIMO | %u\n", l1DetailSubframe.mimo);
|
|
printf (" | MISO | %u\n", l1DetailSubframe.miso);
|
|
printf (" | FFT Size | %u\n", l1DetailSubframe.fft_size);
|
|
printf (" | Reduced Carriers| %u\n", l1DetailSubframe.reduced_carriers);
|
|
printf (" | Guard Interval | %u\n", l1DetailSubframe.gi);
|
|
printf (" | NUM OFDM SYMBOL | %u\n", l1DetailSubframe.num_ofdm_symbol);
|
|
printf (" | SP | %u\n", l1DetailSubframe.sp);
|
|
printf (" | SP BOOST | %u\n", l1DetailSubframe.sp_boost);
|
|
printf (" | SBS first flg | %u\n", l1DetailSubframe.sbs_first);
|
|
printf (" | SBS last flg | %u\n", l1DetailSubframe.sbs_last);
|
|
printf (" | Subframe Mux | %u\n", l1DetailSubframe.subframe_mux);
|
|
printf (" | Freq interleaver| %u\n", l1DetailSubframe.freq_interleaver);
|
|
printf (" | SBS null cells | %u\n", l1DetailSubframe.sbs_null_cells);
|
|
printf (" | Num PLP | %u\n", l1DetailSubframe.num_plp);
|
|
printf (" | | \n");
|
|
printf (" L1-Detail PLP | ID | %u\n", l1DetailPlp.id);
|
|
printf (" | LLS Flg | %u\n", l1DetailPlp.lls_flg);
|
|
printf (" | Layer | %u\n", l1DetailPlp.layer);
|
|
printf (" | Start | %u\n", l1DetailPlp.start);
|
|
printf (" | Size | %u\n", l1DetailPlp.size);
|
|
printf (" | Scramble Type | %u\n", l1DetailPlp.scrambler_type);
|
|
printf (" | FEC TYPE | %u\n", l1DetailPlp.fec_type);
|
|
printf (" | Modulation | %u\n", l1DetailPlp.mod);
|
|
printf (" | Code Rate | %u\n", l1DetailPlp.cod);
|
|
printf (" | Time Intlea Mode| %u\n", l1DetailPlp.ti_mode);
|
|
printf (" | FEC block Start | %u\n", l1DetailPlp.fec_block_start);
|
|
printf (" | CTI fec start | %u\n", l1DetailPlp.cti_fec_block_start);
|
|
printf (" | Num Ch Bonded | %u\n", l1DetailPlp.num_ch_bonded);
|
|
printf (" | ch bond format | %u\n", l1DetailPlp.ch_bonding_format);
|
|
printf (" | bonded rf id 0 | %u\n", l1DetailPlp.bonded_rf_id_0);
|
|
printf (" | bonded rf id 1 | %u\n", l1DetailPlp.bonded_rf_id_1);
|
|
printf (" | mimo stream comb| %u\n", l1DetailPlp.mimo_stream_combine);
|
|
printf (" | mimo iq intleav | %u\n", l1DetailPlp.mimo_iq_interleave);
|
|
printf (" | mimo ph | %u\n", l1DetailPlp.mimo_ph);
|
|
printf (" | plp type | %u\n", l1DetailPlp.plp_type);
|
|
printf (" | num subslice | %u\n", l1DetailPlp.num_subslice);
|
|
printf (" | subslice interval| %u\n", l1DetailPlp.subslice_interval);
|
|
|
|
|
|
|
|
printf (" | ext interleave | %u\n", l1DetailPlp.ti_ext_interleave);
|
|
printf (" | cti depth | %u\n", l1DetailPlp.cti_depth);
|
|
printf (" | cti start row | %u\n", l1DetailPlp.cti_start_row);
|
|
printf (" | hti inter subframe | %u\n", l1DetailPlp.hti_inter_subframe);
|
|
printf (" | hti num ti blocks | %u\n", l1DetailPlp.hti_num_ti_blocks);
|
|
printf (" | hti num fec blk max| %u\n", l1DetailPlp.hti_num_fec_block_max);
|
|
for(i=0;i<16;i++){
|
|
printf (" | hti num fec blk %d| %u\n", i,l1DetailPlp.hti_num_fec_block[i]);
|
|
}
|
|
printf (" | hti cell interleav | %u\n", l1DetailPlp.hti_cell_interleave);
|
|
printf (" | ldm inj leavel | %u\n", l1DetailPlp.ldm_inj_level);
|
|
#endif//USR_PR_TUNER_INFO
|
|
|
|
}
|
|
else {
|
|
printf (" L1-Detail | Error | %s\n", Common_Result[result]);
|
|
}
|
|
printf ("-------------------------|-----------------|----------------- \n");
|
|
}
|
|
|
|
|
|
|
|
printf("<<<\n\n\n");
|
|
|
|
//SONY_SLEEP (1000);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
void usr_sony_cxd6801gl_state_info(sony_driver_instance_t *p_driver)
|
|
{
|
|
usr_sony_cxd6801gl_state_monitor(p_driver);
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
static void atsc3ScanCallbackHandler (sony_integ_t * pInteg, sony_integ_atsc3_scan_result_t * pResult,
|
|
sony_integ_atsc3_scan_param_t * pScanParam)
|
|
{
|
|
sony_result_t result = SONY_RESULT_OK;
|
|
|
|
/*
|
|
* This function is provided as an example callback handler.
|
|
* It simply displays the channel information to the console.
|
|
* It also waits for TS lock as a scan callback is made after only
|
|
* demodulator lock is acheived. Depending on the system requirements you could
|
|
* use this function to monitor for detailed channel parameters (constellation,
|
|
* coderate, carrier offset, TS rate etc.).
|
|
*/
|
|
|
|
if (pResult->tuneResult == SONY_RESULT_OK) {
|
|
char * alpLock;
|
|
int32_t carrierOffset = 0;
|
|
int32_t snr = 0;
|
|
int32_t rfLevel = 0;
|
|
|
|
/* Callback contains channel information, so output channel information to table. */
|
|
result = sony_integ_atsc3_WaitALPLock (pInteg);
|
|
alpLock = (result == SONY_RESULT_OK) ? "Yes" : " No";
|
|
printf ("alpLock %s\n",alpLock);
|
|
|
|
/* Allow the monitors time to settle */
|
|
SONY_SLEEP (1000);
|
|
|
|
/* Get carrier offset to compensate frequency. */
|
|
result = sony_demod_atsc3_monitor_CarrierOffset (pInteg->pDemod, &carrierOffset);
|
|
if (result != SONY_RESULT_OK) {
|
|
carrierOffset = 0;
|
|
}
|
|
|
|
/* Hz to kHz */
|
|
if (carrierOffset > 0) {
|
|
carrierOffset += 500;
|
|
} else {
|
|
carrierOffset -= 500;
|
|
}
|
|
carrierOffset /= 1000;
|
|
|
|
result = sony_demod_atsc3_monitor_SNR (pInteg->pDemod, &snr);
|
|
if (result != SONY_RESULT_OK) {
|
|
snr = 0;
|
|
}
|
|
|
|
result = sony_integ_atsc3_monitor_RFLevel (pInteg, &rfLevel);
|
|
if (result != SONY_RESULT_OK) {
|
|
rfLevel = -999999;
|
|
}
|
|
|
|
printf (" | %6u | %s | %2u.%03u | %4d.%03u |\n",
|
|
pResult->tuneParam.centerFreqKHz + carrierOffset, /* Compensated frequency */
|
|
alpLock,
|
|
snr / 1000, snr % 1000,
|
|
-((-rfLevel) / 1000), (-rfLevel) % 1000); /* RF Level < 0 */
|
|
} else {
|
|
}
|
|
}
|
|
|
|
|
|
// 综合信号检测函数
|
|
typedef enum {
|
|
SIGNAL_STATUS_NO_SIGNAL = 0,
|
|
SIGNAL_STATUS_WEAK_SIGNAL = 1,
|
|
SIGNAL_STATUS_GOOD_SIGNAL = 2,
|
|
SIGNAL_STATUS_ERROR = -1
|
|
} signal_status_t;
|
|
|
|
signal_status_t usr_detect_signal_comprehensive(sony_demod_t *pDemod)
|
|
{
|
|
uint8_t vqlock, agclock, tslock, unlockDetected;
|
|
uint32_t ifAgc;
|
|
sony_result_t result;
|
|
int retry = 0;
|
|
|
|
printf("\n=== Comprehensive Signal Detection ===\n");
|
|
|
|
// 等待AGC稳定,最多等待300ms
|
|
for (retry = 0; retry < 3; retry++) {
|
|
usleep(100 * 1000); // 100ms
|
|
|
|
// 1. 检查ISIGNAL_PRESENCE和AGC lock
|
|
result = sony_demod_atsc_monitor_SyncStat(pDemod,
|
|
&vqlock,
|
|
&agclock,
|
|
&tslock,
|
|
&unlockDetected);
|
|
if (result != SONY_RESULT_OK) {
|
|
printf("Error reading sync stat\n");
|
|
return SIGNAL_STATUS_ERROR;
|
|
}
|
|
|
|
printf("Attempt %d: unlockDetected=%d, agclock=%d, vqlock=%d, tslock=%d\n",
|
|
retry + 1, unlockDetected, agclock, vqlock, tslock);
|
|
|
|
// 如果明确检测到无信号,立即返回
|
|
if (unlockDetected) {
|
|
printf("Result: NO SIGNAL (ISIGNAL_PRESENCE=0)\n");
|
|
return SIGNAL_STATUS_NO_SIGNAL;
|
|
}
|
|
|
|
// 如果AGC已锁定,继续检查信号强度
|
|
if (agclock) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
// 2. 读取IF AGC值评估信号强度
|
|
result = sony_demod_atsc_monitor_IFAGCOut(pDemod, &ifAgc);
|
|
if (result == SONY_RESULT_OK) {
|
|
printf("IF AGC: 0x%04X (%d)\n", ifAgc, ifAgc);
|
|
|
|
if (ifAgc >= 0x3800) {
|
|
printf("Result: NO SIGNAL or VERY WEAK (IF AGC too high)\n");
|
|
return SIGNAL_STATUS_NO_SIGNAL;
|
|
} else if (ifAgc >= 0x2800) {
|
|
printf("Result: WEAK SIGNAL (may not lock)\n");
|
|
return SIGNAL_STATUS_WEAK_SIGNAL;
|
|
} else {
|
|
printf("Result: GOOD SIGNAL\n");
|
|
return SIGNAL_STATUS_GOOD_SIGNAL;
|
|
}
|
|
}
|
|
|
|
// 3. 如果无法读取IF AGC,根据AGC lock状态判断
|
|
if (agclock) {
|
|
printf("Result: SIGNAL PRESENT (AGC locked)\n");
|
|
return SIGNAL_STATUS_GOOD_SIGNAL;
|
|
} else {
|
|
printf("Result: NO SIGNAL (AGC not locked after 300ms)\n");
|
|
return SIGNAL_STATUS_NO_SIGNAL;
|
|
}
|
|
}
|
|
|
|
|
|
int sonytuner_init(u32 freqMHz, u8 atsc_ver)
|
|
{
|
|
uint8 tune_state = 0;
|
|
int tslock = 0;
|
|
int i =0;
|
|
sony_result_t result;
|
|
struct timeval tuner_tv_start;
|
|
struct timeval tuner_tv_end;
|
|
static u8 stc_init_flg = 0;
|
|
static sony_atsc3_tune_param_t tuneParam3p0={0};
|
|
u8 tmp_actual_tun_plpnum = 0;
|
|
|
|
printf("\n==tuner init ready==\n\n");
|
|
printf ("RX tuner: ATSC%d.0 freq: %d MHz.\n", atsc_ver,freqMHz);
|
|
|
|
if(stc_init_flg==0){
|
|
result = sony_InitializeDriver(&atsc_driver, 0);
|
|
}
|
|
|
|
get_time(&tuner_tv_start);
|
|
|
|
if(atsc_ver==1) {
|
|
sony_atsc_tune_param_t tuneParam;
|
|
tuneParam.centerFreqKHz = freqMHz *1000; /* Channel center frequency in KHz */
|
|
result = sony_integ_atsc_Tune(&atsc_driver.integ, &tuneParam);
|
|
if(result != SONY_RESULT_OK) {
|
|
printf("atsc tune failed\n");
|
|
}
|
|
|
|
//usr_detect_signal_comprehensive(atsc_driver.integ.pDemod);
|
|
|
|
while(1){
|
|
if(tune_state==0) {
|
|
result = sony_cxd6801_tslock(&atsc_driver.demod, (u8*)&tslock);
|
|
if(result != SONY_RESULT_OK){
|
|
printf("Error : sony_integ_atsc_Tune failed [result=%d]\n",result);
|
|
tune_state=0;
|
|
}
|
|
else{
|
|
tune_state = 1;
|
|
printf("State : atsc1.0 tune success!\n");
|
|
return 0;
|
|
}
|
|
}
|
|
get_time(&tuner_tv_end);
|
|
if(tuner_tv_end.tv_sec > (tuner_tv_start.tv_sec+TUNER_LOCK_CHECK_WAIT_SEC))
|
|
return -1;
|
|
usleep(1000*1000);
|
|
}
|
|
|
|
}
|
|
else if(atsc_ver == 3) {
|
|
u8 sync_stat = 0;
|
|
u8 alp_lock_stat[4] = {0};
|
|
u8 alp_lock_all = 0;
|
|
u8 unlock_detected = 0;
|
|
u8 num_plps = 0;
|
|
u8 plpID[4] = {0};
|
|
u8 plp_lls[4] = {0};
|
|
u8 plp_lls_cnt= 0;
|
|
sony_result_t resultscan;
|
|
sony_atsc3_plp_list_entry_t plpList[SONY_ATSC3_NUM_PLP_MAX]={0};
|
|
sony_integ_atsc3_scan_param_t scan_param;
|
|
|
|
scan_param.bandwidth = SONY_DTV_BW_6_MHZ;
|
|
scan_param.startFrequencyKHz = (freqMHz*1000) ;
|
|
scan_param.endFrequencyKHz = (freqMHz*1000) ;
|
|
scan_param.stepFrequencyKHz = 6000;
|
|
|
|
|
|
if(stc_init_flg==0){
|
|
|
|
/* Configure TS output format
|
|
* When channel bonding is enable, it is necessary to set TS/TLV output to serial.
|
|
* And TS serial clock should be set to 128MHz.
|
|
*/
|
|
/* Set TS output to parallel. Please see sony_demod.h in detail. */
|
|
result = sony_demod_SetConfig (&atsc_driver.demod, SONY_DEMOD_CONFIG_PARALLEL_SEL, 1);
|
|
if (result != SONY_RESULT_OK) {
|
|
log_printf(LOG_ERR,I_USER_CFG,"(result = %s)\n", Common_Result[result]);
|
|
return -1;
|
|
}
|
|
else{
|
|
//printf(">>ok. Set TS output to parallel\n");
|
|
}
|
|
|
|
/* Set TS output clock to 96MHz. Please see sony_demod.h in detail. */
|
|
result = sony_demod_SetConfig (&atsc_driver.demod, SONY_DEMOD_CONFIG_TERR_CABLE_TS_SERIAL_CLK_FREQ, 1);
|
|
if (result != SONY_RESULT_OK) {
|
|
log_printf(LOG_ERR,I_USER_CFG,"(result = %s)\n", Common_Result[result]);
|
|
return -1;
|
|
}
|
|
|
|
/* Set demod output atsc3. */
|
|
result = sony_demod_SetConfig (&atsc_driver.demod, SONY_DEMOD_CONFIG_OUTPUT_ATSC3, 0);
|
|
if (result != SONY_RESULT_OK) {
|
|
log_printf(LOG_ERR,I_USER_CFG,"(result = %s)\n", Common_Result[result]);
|
|
return -1;
|
|
}
|
|
|
|
}
|
|
|
|
while(1)
|
|
{
|
|
|
|
if(tune_state==0) {
|
|
|
|
#if 1 //for scan plp_list
|
|
if(stc_init_flg==0){
|
|
|
|
resultscan = sony_integ_atsc3_Scan(&atsc_driver.integ,&scan_param,atsc3ScanCallbackHandler);
|
|
if (resultscan != SONY_RESULT_OK) {
|
|
printf(" 1.err, return integ_atsc3_Scan\n\n");
|
|
return -1;
|
|
}
|
|
else{
|
|
printf(" 1.ok, exc integ_atsc3_Scan\n\n");
|
|
}
|
|
|
|
|
|
resultscan = sony_demod_atsc3_monitor_SyncStat(&atsc_driver.demod,&sync_stat,alp_lock_stat,&alp_lock_all,&unlock_detected);
|
|
if (resultscan != SONY_RESULT_OK) {
|
|
printf(" 2.err, return demod_atsc3_monitor_SyncStat\n\n");
|
|
return -1;
|
|
}
|
|
else{
|
|
printf(" 2.ok, exc demod_atsc3_monitor_SyncStat\n\n");
|
|
|
|
printf(" [%s,%d] sync=%d, alpLockStat=[%d-%d-%d-%d], alpLockAll=%d, unlockDetected=%d result=%d\n\n",
|
|
__FUNCTION__,__LINE__,
|
|
sync_stat, alp_lock_stat[0],alp_lock_stat[1],alp_lock_stat[2],alp_lock_stat[3], alp_lock_all, unlock_detected,resultscan);
|
|
}
|
|
|
|
resultscan = sony_demod_atsc3_monitor_PLPList(&atsc_driver.demod, plpList, &num_plps);
|
|
if (resultscan != SONY_RESULT_OK) {
|
|
printf(" 3.err %d, return demod_atsc3_monitor_PLPList\n\n",resultscan);
|
|
return -1;
|
|
}
|
|
else{
|
|
printf(" 3.ok, exc demod_atsc3_monitor_PLPList\n\n");
|
|
plpinfos.actual_tun_plpnum = 0;
|
|
plpinfos.plpnum = num_plps;
|
|
g_tun_plpnum = plpinfos.plpnum;
|
|
tuneParam3p0.centerFreqKHz = freqMHz*1000; /* Channel center frequency in KHz */
|
|
tuneParam3p0.bandwidth = SONY_DTV_BW_6_MHZ; /* Channel bandwidth */
|
|
tuneParam3p0.plpIDNum = num_plps; /* Number of valid PLP ID */
|
|
for(i=0;i<4;i++){
|
|
plpinfos.plplist[i].id = plpList[i].id;
|
|
plpID[i]=plpList[i].id;
|
|
tuneParam3p0.plpID[i] = plpList[i].id;
|
|
|
|
/*if(plpList[i].lls_flg){
|
|
plpID[0] = i;
|
|
//plp_lls[0] = i;
|
|
}*/
|
|
}
|
|
|
|
printf(" nplp=%d [%d,%d,%d,%d], lls_flg @id%d, plp set success\n\n",num_plps,plpList[0].id,plpList[1].id,plpList[2].id,plpList[3].id,plpID[0]);
|
|
|
|
stc_init_flg=1;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
/*tuneParam3p0.centerFreqKHz = (freqMHz*1000);
|
|
tuneParam3p0.bandwidth = SONY_DTV_BW_6_MHZ;
|
|
tuneParam3p0.plpIDNum = 1;
|
|
tuneParam3p0.plpID[0] = 1;//0-Y, 1-N, 2-Y, 3-Y, 4-SEGMENT FAULT
|
|
tuneParam3p0.plpID[1] = 0;
|
|
tuneParam3p0.plpID[2] = 0;
|
|
tuneParam3p0.plpID[3] = 0;
|
|
printf("num=%d id=%d\n",tuneParam3p0.plpIDNum,tuneParam3p0.plpID[0]);
|
|
*/
|
|
RETRY_LESS_PLPNUM:
|
|
result = sony_integ_atsc3_Tune (&atsc_driver.integ, &tuneParam3p0);
|
|
if (result != SONY_RESULT_OK) {
|
|
printf (" 4.err.integ_atsc3_Tune failed. plpnum=%d (result = %s) \n\n\n", tuneParam3p0.plpIDNum, Common_Result[result]);
|
|
if(tuneParam3p0.plpIDNum>1){
|
|
sleep(1);
|
|
tuneParam3p0.plpIDNum--;
|
|
printf("retry plpnum%d init\n", tuneParam3p0.plpIDNum);
|
|
goto RETRY_LESS_PLPNUM;
|
|
}
|
|
else{
|
|
printf("failed, retry plpnum%d init\n", tuneParam3p0.plpIDNum);
|
|
clr_tun_done_flg();
|
|
stc_init_flg=0;
|
|
}
|
|
plpinfos.actual_tun_plpnum = 0;
|
|
return -1;
|
|
}
|
|
else{
|
|
tmp_actual_tun_plpnum = tuneParam3p0.plpIDNum;
|
|
plpinfos.actual_tun_plpnum = tmp_actual_tun_plpnum;
|
|
set_tun_done_flg();
|
|
printf(" 4.ok, return demod_atsc3_SetPLPConfig act_tun_num=%d\n", plpinfos.actual_tun_plpnum);
|
|
}
|
|
|
|
|
|
resultscan = sony_demod_atsc3_monitor_SyncStat(&atsc_driver.demod, &sync_stat,alp_lock_stat,&alp_lock_all,&unlock_detected);
|
|
if (resultscan != SONY_RESULT_OK) {
|
|
printf(" 5.err, return demod_atsc3_monitor_SyncStat\n\n");
|
|
stc_init_flg=0;
|
|
return -1;
|
|
}
|
|
else{
|
|
printf(" 5.ok, exc demod_atsc3_monitor_SyncStat\n\n");
|
|
printf(" 5.[%s,%d] sync=%d, alpLockStat=[%d-%d-%d-%d], alpLockAll=%d, unlockDetected=%d result=%d\n\n",
|
|
__FUNCTION__,__LINE__,
|
|
sync_stat, alp_lock_stat[0],alp_lock_stat[1],alp_lock_stat[2],alp_lock_stat[3], alp_lock_all, unlock_detected,resultscan);
|
|
|
|
memset(&plpinfos,0,sizeof(plpinfos));
|
|
plpinfos.actual_tun_plpnum = tmp_actual_tun_plpnum;
|
|
tune_state = 1;
|
|
//return 0;
|
|
}
|
|
|
|
resultscan = sony_demod_atsc3_monitor_PLPList(&atsc_driver.demod, plpList, &num_plps);
|
|
if (resultscan != SONY_RESULT_OK) {
|
|
printf(" 6.err, return demod_atsc3_monitor_PLPList\n\n");
|
|
tune_state = 1;
|
|
stc_init_flg=0;
|
|
return 0;
|
|
}
|
|
else{
|
|
printf(" 6.ok, exc demod_atsc3_monitor_PLPList\n\n");
|
|
|
|
|
|
plpinfos.plpnum = num_plps;
|
|
for(i=0;i<4;i++){
|
|
plpinfos.plplist[i].id = plpList[i].id;
|
|
}
|
|
|
|
printf(" 6.nplp=%d [%d,%d,%d,%d], lls_flg @id%d, plp set success\n\n",num_plps,plpList[0].id,plpList[1].id,plpList[2].id,plpList[3].id,plpID[0]);
|
|
|
|
tune_state = 1;
|
|
stc_init_flg=0;
|
|
return 0;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
get_time(&tuner_tv_end);
|
|
if(tuner_tv_end.tv_sec > (tuner_tv_start.tv_sec+TUNER_LOCK_CHECK_WAIT_SEC)){
|
|
if (resultscan != SONY_RESULT_OK){
|
|
log_printf(LOG_ERR,I_USER_CFG,"(result = %s) %d [%d,%d,%d,%d] \n", Common_Result[resultscan],
|
|
num_plps,
|
|
plpID[0],
|
|
plpID[1],
|
|
plpID[2],
|
|
plpID[3]);
|
|
}
|
|
stc_init_flg=0;
|
|
return -1;
|
|
}
|
|
usleep(1000*1000);
|
|
}
|
|
}
|
|
}
|
|
|
|
void tun_tuner_1plp_once()
|
|
{
|
|
sony_atsc3_tune_param_t tuneParam3p0={0};
|
|
|
|
if(get_tun_done_flg()==0){
|
|
|
|
printf(">> tun_tuner_1plp_once\n");
|
|
|
|
for(int i=0;i<4;i++){
|
|
tuneParam3p0.plpID[i] = plpinfos.plplist[i].id;
|
|
}
|
|
|
|
tuneParam3p0.centerFreqKHz = txfreq_to_hz(atsc_para.rf_para.rxfreq)*1000; /* Channel center frequency in KHz */
|
|
tuneParam3p0.bandwidth = SONY_DTV_BW_6_MHZ; /* Channel bandwidth */
|
|
tuneParam3p0.plpIDNum = 1; /* Number of valid PLP ID */
|
|
plpinfos.actual_tun_plpnum = 1;
|
|
|
|
int result = sony_integ_atsc3_Tune (&atsc_driver.integ, &tuneParam3p0);
|
|
if (result != SONY_RESULT_OK) {
|
|
printf (">> err.tun_tuner_1plp_once failed. (result = %s) \n", Common_Result[result]);
|
|
}
|
|
else{
|
|
//printf(" nplp=%d [%d,%d,%d,%d], lls_flg plp set success\n\n",plpinfos.plpnum,
|
|
// plpinfos.plplist[0].id,plpinfos.plplist[1].id,plpinfos.plplist[2].id,plpinfos.plplist[3].id);
|
|
//printf(" ok, return demod_atsc3_SetPLPConfig\n");
|
|
}
|
|
}
|
|
}
|
|
|
|
void usr_check_and_tun_tuner()
|
|
{
|
|
static sony_atsc3_tune_param_t tuneParam3p0={0};
|
|
int result;
|
|
//teset-------------------------------------
|
|
// plpinfos.plpnum=2;
|
|
|
|
|
|
if(get_tun_done_flg()==1){
|
|
if(g_tun_plpnum==plpinfos.plpnum){
|
|
return ;
|
|
}
|
|
}
|
|
|
|
printf("\n\n=====================usr_check_and_tun_tuner=last/check[%d/%d]===========================\n\n\n", g_tun_plpnum, plpinfos.plpnum);
|
|
|
|
g_tun_plpnum = plpinfos.plpnum;
|
|
|
|
for(int i=0;i<4;i++){
|
|
tuneParam3p0.plpID[i] = plpinfos.plplist[i].id;
|
|
}
|
|
|
|
tuneParam3p0.centerFreqKHz = txfreq_to_hz(atsc_para.rf_para.rxfreq)*1000; /* Channel center frequency in KHz */
|
|
tuneParam3p0.bandwidth = SONY_DTV_BW_6_MHZ; /* Channel bandwidth */
|
|
tuneParam3p0.plpIDNum = plpinfos.plpnum; /* Number of valid PLP ID */
|
|
|
|
printf("tun_cfg plpnum=%d id[%d %d %d %d]\n",
|
|
tuneParam3p0.plpIDNum,
|
|
tuneParam3p0.plpID[0],tuneParam3p0.plpID[1],tuneParam3p0.plpID[2],tuneParam3p0.plpID[3]
|
|
);
|
|
|
|
_RETRY_LESS_TUN:
|
|
|
|
result = sony_integ_atsc3_Tune (&atsc_driver.integ, &tuneParam3p0);
|
|
if (result != SONY_RESULT_OK) {
|
|
|
|
if(tuneParam3p0.plpIDNum>1){
|
|
sleep(1);
|
|
tuneParam3p0.plpIDNum--;
|
|
|
|
printf("retry plpnum%d init\n", tuneParam3p0.plpIDNum);
|
|
goto _RETRY_LESS_TUN;
|
|
}
|
|
else{
|
|
plpinfos.actual_tun_plpnum = 0;
|
|
printf("failed, retry plpnum%d init (result = %s)\n\n", tuneParam3p0.plpIDNum, Common_Result[result]);
|
|
clr_tun_done_flg();
|
|
}
|
|
}
|
|
else{
|
|
plpinfos.actual_tun_plpnum = tuneParam3p0.plpIDNum;
|
|
set_tun_done_flg();
|
|
|
|
printf(" ck_nplp=%d [%d,%d,%d,%d], lls_flg plp set success act_tun_num=%d\n\n",plpinfos.plpnum,
|
|
plpinfos.plplist[0].id,plpinfos.plplist[1].id,plpinfos.plplist[2].id,plpinfos.plplist[3].id, plpinfos.actual_tun_plpnum);
|
|
//printf(" ok, return demod_atsc3_SetPLPConfig\n");
|
|
}
|
|
}
|
|
|
|
int usr_update_atsc3_monitor_plpid(void)
|
|
{
|
|
int i;
|
|
uint8_t num_plps;
|
|
sony_result_t resultscan;
|
|
|
|
sony_atsc3_plp_list_entry_t plpList[SONY_ATSC3_NUM_PLP_MAX]={0};
|
|
|
|
resultscan = sony_demod_atsc3_monitor_PLPList(&atsc_driver.demod, plpList, &num_plps);
|
|
if (resultscan != SONY_RESULT_OK) {
|
|
return -1;
|
|
}
|
|
|
|
plpinfos.plpnum = num_plps;
|
|
|
|
for(i=0;i<4;i++){
|
|
plpinfos.plplist[i].id = plpList[i].id;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
int sonytuner_rssi(int *p_rssi, u8 atsc_ver)
|
|
{
|
|
if(atsc_ver==1)
|
|
sony_cxd6801_tuner_rssi(&atsc_driver.integ, p_rssi);
|
|
else
|
|
sony_cxd6801_tuner_rssi_atsc3p0(&atsc_driver.integ, p_rssi);
|
|
}
|
|
int sonytuner_snr(int *p_snr, u8 atsc_ver)
|
|
{
|
|
if(atsc_ver==1)
|
|
sony_cxd6801_snr(&atsc_driver.demod, p_snr);
|
|
else{
|
|
sony_cxd6801_snr_atsc3p0(&atsc_driver.demod, p_snr);
|
|
}
|
|
}
|
|
int sonytuner_tslock(uint8 *p_lock, u8 atsc_ver, u8 *p_sync_state, u8* p_alp_lock_all, u8* p_plperr)
|
|
{
|
|
if(p_lock==NULL || p_sync_state==NULL)
|
|
return -1;
|
|
|
|
if(atsc_ver==1)
|
|
sony_cxd6801_tslock(&atsc_driver.demod, p_lock);
|
|
else{
|
|
sony_cxd6801_tslock_atsc3p0(&atsc_driver.demod, p_lock, p_sync_state,p_alp_lock_all,p_plperr);
|
|
}
|
|
|
|
}
|
|
|
|
int sonytuner_plperr(u8* p_plperr)
|
|
{
|
|
sony_result_t result;
|
|
//p_plperr 0:all PLPs are founded, 1:not found
|
|
result = sony_demod_atsc3_monitor_PLPError(&atsc_driver.demod, p_plperr);
|
|
if(result!=SONY_RESULT_OK) {
|
|
*p_plperr = 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|