提交SMOD ATSC IMX APP版本 V122

This commit is contained in:
2026-07-16 14:35:59 +08:00
commit 7601c270d5
485 changed files with 255032 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
VPATH += $(ROOT_DIR)/app/sonytuner/source/atsc
C_SOURCE += sony_demod_atsc_monitor.c
C_SOURCE += sony_demod_atsc.c
C_SOURCE += sony_integ_atsc.c
C_SOURCE += sony_integ_atsc3.c
+19
View File
@@ -0,0 +1,19 @@
/*------------------------------------------------------------------------------
Copyright 2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/05
Modification ID : c7c68d70868a4a9fb9e0f480d8b940e8a1e8f651
------------------------------------------------------------------------------*/
/**
@file sony_atsc.h
This file provides ATSC related type definitions.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_ATSC_H
#define SONY_ATSC_H
#include "../sony_common.h"
#endif /* SONY_ATSC_H */
+528
View File
@@ -0,0 +1,528 @@
/*------------------------------------------------------------------------------
Copyright 2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/09/28
Modification ID : 1ea04def104d657deb64f0d0b0cae6ef992a9dd8
------------------------------------------------------------------------------*/
/**
@file sony_atsc3.h
This file provides ATSC 3.0 related type definitions.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_ATSC3_H
#define SONY_ATSC3_H
#include "../sony_common.h"
/*------------------------------------------------------------------------------
Defines
------------------------------------------------------------------------------*/
#define SONY_ATSC3_NUM_PLP_MAX 64 /**< Max number of PLPs */
/*------------------------------------------------------------------------------
Enumerations
------------------------------------------------------------------------------*/
/**
@brief System bandwidth signaled in bootstrap.
*/
typedef enum {
SONY_ATSC3_SYSTEM_BW_6_MHZ, /**< 6MHz */
SONY_ATSC3_SYSTEM_BW_7_MHZ, /**< 7MHz */
SONY_ATSC3_SYSTEM_BW_8_MHZ, /**< 8MHz */
SONY_ATSC3_SYSTEM_BW_OVER_8_MHZ /**< Greater than 8 MHz */
} sony_atsc3_system_bw_t;
/**
@brief Preamble pilot pattern signaled in bootstrap.
*/
typedef enum {
SONY_ATSC3_PREAMBLE_PILOT_3, /**< Dx = 3 */
SONY_ATSC3_PREAMBLE_PILOT_4, /**< Dx = 4 */
SONY_ATSC3_PREAMBLE_PILOT_6, /**< Dx = 6 */
SONY_ATSC3_PREAMBLE_PILOT_8, /**< Dx = 8 */
SONY_ATSC3_PREAMBLE_PILOT_12, /**< Dx = 12 */
SONY_ATSC3_PREAMBLE_PILOT_16, /**< Dx = 16 */
SONY_ATSC3_PREAMBLE_PILOT_24, /**< Dx = 24 */
SONY_ATSC3_PREAMBLE_PILOT_32, /**< Dx = 32 */
} sony_atsc3_preamble_pilot_t;
/**
@brief L1-Basic fec type signaled in bootstrap.
*/
typedef enum {
SONY_ATSC3_L1B_FEC_TYPE_MODE1, /**< Mode 1 */
SONY_ATSC3_L1B_FEC_TYPE_MODE2, /**< Mode 2 */
SONY_ATSC3_L1B_FEC_TYPE_MODE3, /**< Mode 3 */
SONY_ATSC3_L1B_FEC_TYPE_MODE4, /**< Mode 4 */
SONY_ATSC3_L1B_FEC_TYPE_MODE5, /**< Mode 5 */
SONY_ATSC3_L1B_FEC_TYPE_MODE6, /**< Mode 6 */
SONY_ATSC3_L1B_FEC_TYPE_MODE7, /**< Mode 7 */
SONY_ATSC3_L1B_FEC_TYPE_RESERVED /**< Reserved */
} sony_atsc3_l1b_fec_type_t;
/**
@brief Presence or absence of timing information, and precision indicator signaled in L1-Basic.
*/
typedef enum {
SONY_ATSC3_TIME_INFO_FLAG_NONE, /**< Time information is not included */
SONY_ATSC3_TIME_INFO_FLAG_MS, /**< ms precision */
SONY_ATSC3_TIME_INFO_FLAG_US, /**< us precision */
SONY_ATSC3_TIME_INFO_FLAG_NS /**< ns precision */
} sony_atsc3_time_info_flag_t;
/**
@brief PAPR (Peak to Average Power Ratio) reduction indicator signaled in L1-Basic.
*/
typedef enum {
SONY_ATSC3_PAPR_NONE, /**< No PAPR reduction used */
SONY_ATSC3_PAPR_TR, /**< Tone reservation only */
SONY_ATSC3_PAPR_ACE, /**< ACE (Active Constellation Extension) only */
SONY_ATSC3_PAPR_TR_ACE /**< Both TR and ACE */
} sony_atsc3_papr_t;
/**
@brief L1-Detail fec type signaled in L1-Basic.
*/
typedef enum {
SONY_ATSC3_L1D_FEC_TYPE_MODE1, /**< Mode 1 */
SONY_ATSC3_L1D_FEC_TYPE_MODE2, /**< Mode 2 */
SONY_ATSC3_L1D_FEC_TYPE_MODE3, /**< Mode 3 */
SONY_ATSC3_L1D_FEC_TYPE_MODE4, /**< Mode 4 */
SONY_ATSC3_L1D_FEC_TYPE_MODE5, /**< Mode 5 */
SONY_ATSC3_L1D_FEC_TYPE_MODE6, /**< Mode 6 */
SONY_ATSC3_L1D_FEC_TYPE_MODE7, /**< Mode 7 */
SONY_ATSC3_L1D_FEC_TYPE_RESERVED /**< Reserved */
} sony_atsc3_l1d_fec_type_t;
/**
@brief MISO (Multiple Input Single Output) option used in L1-Basic and L1-Detail.
*/
typedef enum {
SONY_ATSC3_MISO_NONE, /**< No MISO */
SONY_ATSC3_MISO_64, /**< MISO with 64 coefficients */
SONY_ATSC3_MISO_256, /**< MISO with 256 coefficients */
SONY_ATSC3_MISO_RESERVED /**< Reserved */
} sony_atsc3_miso_t;
/**
@brief FFT size indicator used in L1-Basic and L1-Detail.
*/
typedef enum {
SONY_ATSC3_FFT_SIZE_8K, /**< 8K */
SONY_ATSC3_FFT_SIZE_16K, /**< 16K */
SONY_ATSC3_FFT_SIZE_32K, /**< 32K */
SONY_ATSC3_FFT_SIZE_RESERVED /**< Reserved */
} sony_atsc3_fft_size_t;
/**
@brief Guard interval indicator used in L1-Basic and L1-Detail.
*/
typedef enum {
SONY_ATSC3_GI_RESERVED_0, /**< Reserved */
SONY_ATSC3_GI_1_192, /**< 1/192 */
SONY_ATSC3_GI_2_384, /**< 2/384 */
SONY_ATSC3_GI_3_512, /**< 3/512 */
SONY_ATSC3_GI_4_768, /**< 4/768 */
SONY_ATSC3_GI_5_1024, /**< 5/1024 */
SONY_ATSC3_GI_6_1536, /**< 6/1536 */
SONY_ATSC3_GI_7_2048, /**< 7/2048 */
SONY_ATSC3_GI_8_2432, /**< 8/2432 */
SONY_ATSC3_GI_9_3072, /**< 9/3072 */
SONY_ATSC3_GI_10_3648, /**< 10/3648 */
SONY_ATSC3_GI_11_4096, /**< 11/4096 */
SONY_ATSC3_GI_12_4864, /**< 12/4864 */
SONY_ATSC3_GI_RESERVED_13, /**< Reserved */
SONY_ATSC3_GI_RESERVED_14, /**< Reserved */
SONY_ATSC3_GI_RESERVED_15 /**< Reserved */
} sony_atsc3_gi_t;
/**
@brief Scattered pilot pattern indicator signaled in L1-Detail.
*/
typedef enum {
SONY_ATSC3_SP_3_2, /**< SP3_2 for SISO, MP3_2 for MISO */
SONY_ATSC3_SP_3_4, /**< SP3_4 for SISO, MP3_4 for MISO */
SONY_ATSC3_SP_4_2, /**< SP4_2 for SISO, MP4_2 for MISO */
SONY_ATSC3_SP_4_4, /**< SP4_4 for SISO, MP4_4 for MISO */
SONY_ATSC3_SP_6_2, /**< SP6_2 for SISO, MP6_2 for MISO */
SONY_ATSC3_SP_6_4, /**< SP6_4 for SISO, MP6_4 for MISO */
SONY_ATSC3_SP_8_2, /**< SP8_2 for SISO, MP8_2 for MISO */
SONY_ATSC3_SP_8_4, /**< SP8_4 for SISO, MP8_4 for MISO */
SONY_ATSC3_SP_12_2, /**< SP12_2 for SISO, MP12_2 for MISO */
SONY_ATSC3_SP_12_4, /**< SP12_4 for SISO, MP12_4 for MISO */
SONY_ATSC3_SP_16_2, /**< SP16_2 for SISO, MP16_2 for MISO */
SONY_ATSC3_SP_16_4, /**< SP16_4 for SISO, MP16_4 for MISO */
SONY_ATSC3_SP_24_2, /**< SP24_2 for SISO, MP24_2 for MISO */
SONY_ATSC3_SP_24_4, /**< SP24_4 for SISO, MP24_4 for MISO */
SONY_ATSC3_SP_32_2, /**< SP32_2 for SISO, MP32_2 for MISO */
SONY_ATSC3_SP_32_4, /**< SP32_4 for SISO, MP32_4 for MISO */
SONY_ATSC3_SP_RESERVED_16, /**< Reserved */
SONY_ATSC3_SP_RESERVED_17, /**< Reserved */
SONY_ATSC3_SP_RESERVED_18, /**< Reserved */
SONY_ATSC3_SP_RESERVED_19, /**< Reserved */
SONY_ATSC3_SP_RESERVED_20, /**< Reserved */
SONY_ATSC3_SP_RESERVED_21, /**< Reserved */
SONY_ATSC3_SP_RESERVED_22, /**< Reserved */
SONY_ATSC3_SP_RESERVED_23 /**< Reserved */
} sony_atsc3_sp_t;
/**
@brief PLP FEC type definition signaled in L1-Detail.
*/
typedef enum {
SONY_ATSC3_PLP_FEC_BCH_LDPC_16K, /**< BCH + 16K LDPC */
SONY_ATSC3_PLP_FEC_BCH_LDPC_64K, /**< BCH + 64K LDPC */
SONY_ATSC3_PLP_FEC_CRC_LDPC_16K, /**< CRC + 16K LDPC */
SONY_ATSC3_PLP_FEC_CRC_LDPC_64K, /**< CRC + 64K LDPC */
SONY_ATSC3_PLP_FEC_LDPC_16K, /**< 16K LDPC only */
SONY_ATSC3_PLP_FEC_LDPC_64K, /**< 64K LDPC only */
SONY_ATSC3_PLP_FEC_RESERVED_6, /**< Reserved */
SONY_ATSC3_PLP_FEC_RESERVED_7, /**< Reserved */
SONY_ATSC3_PLP_FEC_RESERVED_8, /**< Reserved */
SONY_ATSC3_PLP_FEC_RESERVED_9, /**< Reserved */
SONY_ATSC3_PLP_FEC_RESERVED_10, /**< Reserved */
SONY_ATSC3_PLP_FEC_RESERVED_11, /**< Reserved */
SONY_ATSC3_PLP_FEC_RESERVED_12, /**< Reserved */
SONY_ATSC3_PLP_FEC_RESERVED_13, /**< Reserved */
SONY_ATSC3_PLP_FEC_RESERVED_14, /**< Reserved */
SONY_ATSC3_PLP_FEC_RESERVED_15 /**< Reserved */
} sony_atsc3_plp_fec_t;
/**
@brief PLP modulation signaled in L1-Detail.
*/
typedef enum {
SONY_ATSC3_PLP_MOD_QPSK, /**< QPSK */
SONY_ATSC3_PLP_MOD_16QAM, /**< 16QAM-NUC */
SONY_ATSC3_PLP_MOD_64QAM, /**< 64QAM-NUC */
SONY_ATSC3_PLP_MOD_256QAM, /**< 256QAM-NUC */
SONY_ATSC3_PLP_MOD_1024QAM, /**< 1024QAM-NUC */
SONY_ATSC3_PLP_MOD_4096QAM, /**< 4096QAM-NUC */
SONY_ATSC3_PLP_MOD_RESERVED_6, /**< Reserved */
SONY_ATSC3_PLP_MOD_RESERVED_7, /**< Reserved */
SONY_ATSC3_PLP_MOD_RESERVED_8, /**< Reserved */
SONY_ATSC3_PLP_MOD_RESERVED_9, /**< Reserved */
SONY_ATSC3_PLP_MOD_RESERVED_10, /**< Reserved */
SONY_ATSC3_PLP_MOD_RESERVED_11, /**< Reserved */
SONY_ATSC3_PLP_MOD_RESERVED_12, /**< Reserved */
SONY_ATSC3_PLP_MOD_RESERVED_13, /**< Reserved */
SONY_ATSC3_PLP_MOD_RESERVED_14, /**< Reserved */
SONY_ATSC3_PLP_MOD_RESERVED_15 /**< Reserved */
} sony_atsc3_plp_mod_t;
/**
@brief PLP code rate signaled in L1-Detail.
*/
typedef enum {
SONY_ATSC3_PLP_COD_2_15, /**< 2/15 */
SONY_ATSC3_PLP_COD_3_15, /**< 3/15 */
SONY_ATSC3_PLP_COD_4_15, /**< 4/15 */
SONY_ATSC3_PLP_COD_5_15, /**< 5/15 */
SONY_ATSC3_PLP_COD_6_15, /**< 6/15 */
SONY_ATSC3_PLP_COD_7_15, /**< 7/15 */
SONY_ATSC3_PLP_COD_8_15, /**< 8/15 */
SONY_ATSC3_PLP_COD_9_15, /**< 9/15 */
SONY_ATSC3_PLP_COD_10_15, /**< 10/15 */
SONY_ATSC3_PLP_COD_11_15, /**< 11/15 */
SONY_ATSC3_PLP_COD_12_15, /**< 12/15 */
SONY_ATSC3_PLP_COD_13_15, /**< 13/15 */
SONY_ATSC3_PLP_COD_RESERVED_12, /**< Reserved */
SONY_ATSC3_PLP_COD_RESERVED_13, /**< Reserved */
SONY_ATSC3_PLP_COD_RESERVED_14, /**< Reserved */
SONY_ATSC3_PLP_COD_RESERVED_15 /**< Reserved */
} sony_atsc3_plp_cod_t;
/**
@brief PLP time interleaving mode signaled in L1-Detail.
*/
typedef enum {
SONY_ATSC3_PLP_TI_NONE, /**< No time interleaving mode */
SONY_ATSC3_PLP_TI_CTI, /**< Convolutional time interleaving */
SONY_ATSC3_PLP_TI_HTI, /**< Hybrid time interleaving */
SONY_ATSC3_PLP_TI_RESERVED /**< Reserved */
} sony_atsc3_plp_ti_t;
/**
@brief PLP channel bonding format signaled in L1-Detail.
*/
typedef enum {
SONY_ATSC3_PLP_CH_BOND_FMT_PLAIN, /**< Plain channel bonding */
SONY_ATSC3_PLP_CH_BOND_FMT_SNR, /**< SNR averaged channel bonding */
SONY_ATSC3_PLP_CH_BOND_FMT_RESERVED_2, /**< Reserved */
SONY_ATSC3_PLP_CH_BOND_FMT_RESERVED_3 /**< Reserved */
} sony_atsc3_plp_ch_bond_fmt_t;
/**
@brief Number of rows used in the CTI signaled in L1-Detail.
*/
typedef enum {
SONY_ATSC3_PLP_CTI_DEPTH_512, /**< 512 */
SONY_ATSC3_PLP_CTI_DEPTH_724, /**< 724 */
SONY_ATSC3_PLP_CTI_DEPTH_887_1254, /**< 887 (non-extended interleaving) or 1254 (extended interleaving) */
SONY_ATSC3_PLP_CTI_DEPTH_1024_1448, /**< 1024 (non-extended interleaving) or 1448 (extended interleaving) */
SONY_ATSC3_PLP_CTI_DEPTH_RESERVED_4, /**< Reserved */
SONY_ATSC3_PLP_CTI_DEPTH_RESERVED_5, /**< Reserved */
SONY_ATSC3_PLP_CTI_DEPTH_RESERVED_6, /**< Reserved */
SONY_ATSC3_PLP_CTI_DEPTH_RESERVED_7 /**< Reserved */
} sony_atsc3_plp_cti_depth_t;
/**
@brief Enhanced PLP's injection level signaled in L1-Detail.
*/
typedef enum {
SONY_ATSC3_PLP_LDM_INJ_LEVEL_0_0, /**< 0.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_0_5, /**< 0.5 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_1_0, /**< 1.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_1_5, /**< 1.5 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_2_0, /**< 2.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_2_5, /**< 2.5 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_3_0, /**< 3.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_3_5, /**< 3.5 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_4_0, /**< 4.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_4_5, /**< 4.5 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_5_0, /**< 5.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_6_0, /**< 6.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_7_0, /**< 7.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_8_0, /**< 8.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_9_0, /**< 9.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_10_0, /**< 10.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_11_0, /**< 11.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_12_0, /**< 12.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_13_0, /**< 13.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_14_0, /**< 14.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_15_0, /**< 15.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_16_0, /**< 16.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_17_0, /**< 17.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_18_0, /**< 18.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_19_0, /**< 19.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_20_0, /**< 20.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_21_0, /**< 21.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_22_0, /**< 22.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_23_0, /**< 23.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_24_0, /**< 24.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_25_0, /**< 25.0 dB */
SONY_ATSC3_PLP_LDM_INJ_LEVEL_RESERVED, /**< Reserved */
} sony_atsc3_plp_ldm_inj_level_t;
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief ATSC 3.0 bootstrap information.
*/
typedef struct sony_atsc3_bootstrap_t {
uint8_t bw_diff; /**< If 1, system bandwidth setting is different from signal. */
sony_atsc3_system_bw_t system_bw; /**< Signal system bandwidth. */
uint8_t ea_wake_up; /**< Emergency alert wake up field. (2bit) */
} sony_atsc3_bootstrap_t;
/**
@brief ATSC 3.0 parameters estimated by demodulator.
@note Several parameters can be found in bootstrap, L1 too.
But note that they may NOT be latest L1 data received by demod.
These parameters are currently used by demodulator circuit.
*/
typedef struct sony_atsc3_ofdm_t {
sony_atsc3_system_bw_t system_bw; /**< System bandwidth. (6 or 7 or 8) */
uint8_t bs_num_symbol; /**< Number of bootstrap symbol - 1 */
uint8_t num_subframe; /**< Number of subframe - 1 */
sony_atsc3_l1b_fec_type_t l1b_fec_type; /**< L1-Basic fec type */
sony_atsc3_papr_t papr; /**< PAPR reduction */
uint8_t pb_num_symbol; /**< Number of preamble symbol - 1 */
sony_atsc3_fft_size_t pb_fft_size; /**< Preamble FFT size */
sony_atsc3_preamble_pilot_t pb_pilot; /**< Preamble pilot pattern */
uint8_t pb_reduced_carriers; /**< Cred_coeff indicator for preamble (0 - 4) */
sony_atsc3_gi_t pb_gi; /**< Preamble guard interval */
sony_atsc3_fft_size_t sf0_fft_size; /**< Subframe #0 FFT size */
sony_atsc3_sp_t sf0_sp; /**< Subframe #0 scattered pilot pattern */
uint8_t sf0_reduced_carriers;/**< Cred_coeff indicator for subframe #0 (0 - 4) */
sony_atsc3_gi_t sf0_gi; /**< Subframe #0 guard interval */
uint8_t sf0_sp_boost; /**< Subframe #0 scattered pilot boost (0 - 4) */
uint8_t sf0_sbs_first; /**< Subframe #0 subframe boundary symbol first flag */
uint8_t sf0_sbs_last; /**< Subframe #0 subframe boundary symbol last flag */
uint16_t sf0_num_ofdm_symbol; /**< Subframe #0 number of data payload OFDM symbols - 1 */
} sony_atsc3_ofdm_t;
/**
@brief ATSC 3.0 L1-Basic information.
*/
typedef struct sony_atsc3_l1basic_t {
/* System and Frame Parameters */
uint8_t version; /**< L1-Basic structure version. (currently 0) */
uint8_t mimo_sp_enc; /**< MIMO pilot encoding scheme (0 or 1) */
uint8_t lls_flg; /**< Presence or absence of Low Level Signaling (LLS) */
sony_atsc3_time_info_flag_t time_info_flg; /**< Presence or absence, and precision of timing information */
uint8_t return_ch_flg; /**< Dedicated return channel (DRC) is present or not */
sony_atsc3_papr_t papr; /**< PAPR reduction */
uint8_t frame_length_mode; /**< Frame is time-aligned (0) or symbol-aligned (1) */
/* Valid if frame_length_mode == 0 (time-aligned frame) */
uint16_t frame_length; /**< Frame length (5ms unit) */
uint16_t excess_smp_per_sym; /**< Additional number of excess samples included in the guard interval */
/* Valid if frame_length_mode == 1 (symbol-aligned frame) */
uint16_t time_offset; /**< Number of sample periods */
uint8_t additional_smp; /**< Number of additional samples at the end of frames */
/* endif */
uint8_t num_subframe; /**< Number of subframe - 1 */
/* Parameters for L1-Detail */
uint8_t pb_num_symbol; /**< Number of preamble symbol - 1 */
uint8_t pb_reduced_carriers; /**< Cred_coeff indicator for preamble (0 - 4) */
uint8_t l1d_content_tag; /**< Incremented if L1-Detail content is modified */
uint16_t l1d_size; /**< L1-Detail information size (byte) */
sony_atsc3_l1d_fec_type_t l1d_fec_type; /**< L1-Detail fec type */
uint8_t l1d_add_parity_mode; /**< L1-Detail Additional parity mode (0 - 2) */
uint32_t l1d_total_cells; /**< The total size (specified in OFDM cells) of L1-Detail signaling */
/* Parameters for First Subframe */
uint8_t sf0_mimo; /**< Subframe #0 MIMO or not */
sony_atsc3_miso_t sf0_miso; /**< Subframe #0 MISO option */
sony_atsc3_fft_size_t sf0_fft_size; /**< Subframe #0 FFT size */
uint8_t sf0_reduced_carriers;/**< Cred_coeff indicator for subframe #0 (0 - 4) */
sony_atsc3_gi_t sf0_gi; /**< Subframe #0 guard interval */
uint16_t sf0_num_ofdm_symbol; /**< Subframe #0 number of data payload OFDM symbols - 1 */
sony_atsc3_sp_t sf0_sp; /**< Subframe #0 scattered pilot pattern */
uint8_t sf0_sp_boost; /**< Subframe #0 scattered pilot boost (0 - 4) */
uint8_t sf0_sbs_first; /**< Subframe #0 subframe boundary symbol first flag */
uint8_t sf0_sbs_last; /**< Subframe #0 subframe boundary symbol last flag */
/* Miscellaneous Parameters */
uint8_t reserved[6]; /**< Reserved for future use */
} sony_atsc3_l1basic_t;
/**
@brief ATSC 3.0 L1-Detail information raw data.
*/
typedef struct sony_atsc3_l1detail_raw_t {
uint16_t size; /**< L1-Detail information size (byte) */
uint8_t data[8191]; /**< Raw data buffer */
} sony_atsc3_l1detail_raw_t;
/**
@brief ATSC 3.0 L1-Detail common information.
*/
typedef struct sony_atsc3_l1detail_common_t {
uint8_t version; /**< L1-Detail structure version */
uint8_t num_rf; /**< Number of other frequencies in channel bonding (0 or 1) */
uint16_t bonded_bsid; /**< BSID of separate RF channel (valid if num_rf == 1) */
/* Valid if time_info_flg (sony_atsc3_l1base_t) != NONE */
uint32_t time_sec; /**< Time information (sec) */
uint16_t time_msec; /**< Time information (msec) */
/* Valid if time_info_flg (sony_atsc3_l1base_t) == US or NS */
uint16_t time_usec; /**< Time information (usec) */
/* Valid if time_info_flg (sony_atsc3_l1base_t) == NS */
uint16_t time_nsec; /**< Time information (nsec) */
uint16_t bsid; /**< BSID of the current channel */
uint16_t reserved_bitlen; /**< Size of reserved data (bit) */
} sony_atsc3_l1detail_common_t;
/**
@brief ATSC 3.0 L1-Detail subframe specific information.
*/
typedef struct sony_atsc3_l1detail_subframe_t {
uint8_t index; /**< Subframe index */
uint8_t mimo; /**< MIMO or not */
sony_atsc3_miso_t miso; /**< MISO option */
sony_atsc3_fft_size_t fft_size; /**< FFT size */
uint8_t reduced_carriers; /**< Cred_coeff indicator (0 - 4) */
sony_atsc3_gi_t gi; /**< Guard interval */
uint16_t num_ofdm_symbol; /**< Number of data payload OFDM symbols - 1 */
sony_atsc3_sp_t sp; /**< Scattered pilot pattern */
uint8_t sp_boost; /**< Scattered pilot boost (0 - 4) */
uint8_t sbs_first; /**< Subframe boundary symbol first flag */
uint8_t sbs_last; /**< Subframe boundary symbol last flag */
/* Valid if num_subframe (sony_atsc3_l1base_t) > 0 */
uint8_t subframe_mux; /**< Time-division multiplexed or concatenated in time */
uint8_t freq_interleaver; /**< Frequency interleaver is enabled or not */
/* Valid if sbs_first || sbs_last */
uint16_t sbs_null_cells; /**< Number of null cells */
uint8_t num_plp; /**< Number of PLPs in the current subframe */
} sony_atsc3_l1detail_subframe_t;
/**
@brief ATSC 3.0 L1-Detail PLP specific information.
*/
typedef struct sony_atsc3_l1detail_plp_t {
uint8_t id; /**< PIP ID (0 - 63) assigned uniquely in each RF channel */
uint8_t lls_flg; /**< Current PLP contains LLS information or not */
uint8_t layer; /**< Layer index of current PLP (0 (Core Layer) or 1 (Enhanced Layer)) */
uint32_t start; /**< First data cell index */
uint32_t size; /**< Number of data cells allocated to the current PLP */
uint8_t scrambler_type; /**< Choice of scrambler (only 0 in current version) */
sony_atsc3_plp_fec_t fec_type; /**< PLP FEC method */
sony_atsc3_plp_mod_t mod; /**< PLP modulation */
sony_atsc3_plp_cod_t cod; /**< PLP code rate */
sony_atsc3_plp_ti_t ti_mode; /**< PLP time interleaving mode */
/* Valid if ti_mode == SONY_ATSC3_PLP_TI_NONE */
uint16_t fec_block_start; /**< Start position of the first FEC Block */
/* Valid if ti_mode == SONY_ATSC3_PLP_TI_CTI */
uint32_t cti_fec_block_start; /**< Position for CTI. (See spec) */
/* Valid if num_rf (sony_atsc3_l1detail_common_t) > 0 */
uint8_t num_ch_bonded; /**< Number of other frequencies in channel bonding for this PLP (0 or 1)*/
/* Valid if num_ch_bonded > 0 */
sony_atsc3_plp_ch_bond_fmt_t ch_bonding_format; /**< Channel bonding format for the current PLP */
uint8_t bonded_rf_id_0; /**< Bonded RF ID #0 */
uint8_t bonded_rf_id_1; /**< Bonded RF ID #1 */
/* Valid if mimo (sony_atsc3_l1detail_subframe_t) == 1 */
uint8_t mimo_stream_combine; /**< Stream combining option is used or not */
uint8_t mimo_iq_interleave; /**< IQ polarization interleaving option is used or not */
uint8_t mimo_ph; /**< Phase hopping option is used nor not */
/* Valid if layer (sony_atsc3_l1detail_plp_t) == 0 */
uint8_t plp_type; /**< Current PLP is non-dispersed (0) or dispersed (1) */
/* Valid if plp_type == 1 */
uint16_t num_subslice; /**< Number of subslice - 1 (1 - 16383) */
uint32_t subslice_interval; /**< Subslice interval (data cell unit) */
/* Valid if ti_mode == SONY_ATSC3_PLP_TI_CTI or
(ti_mode == SONY_ATSC3_PLP_TI_HTI and mod == SONY_ATSC3_PLP_MOD_QPSK) */
uint8_t ti_ext_interleave; /**< Extended interleaving is used or not */
/* Valid if ti_mode == SONY_ATSC3_PLP_TI_CTI */
sony_atsc3_plp_cti_depth_t cti_depth; /**< Number of rows used in the Convolutional Time Interleaver */
uint16_t cti_start_row; /**< Position of the interleaver selector at the start of the subframe*/
/* Valid if ti_mode == SONY_ATSC3_PLP_TI_HTI */
uint8_t hti_inter_subframe; /**< HTI is used or not in this subframe */
uint8_t hti_num_ti_blocks; /**< Number of TI blocks - 1 (0 - 15) */
uint16_t hti_num_fec_block_max; /**< Maximum number of FEC Blocks - 1 */
uint16_t hti_num_fec_block[16]; /**< Number of FEC Blocks - 1 */
uint8_t hti_cell_interleave; /**< Cell Interleaver is used or not */
/* Valid if layer (sony_atsc3_l1detail_plp_t) != 0 */
sony_atsc3_plp_ldm_inj_level_t ldm_inj_level; /**< Enhanced PLP's injection level */
} sony_atsc3_l1detail_plp_t;
/**
@brief Minimum required PLP information got by ::sony_demod_atsc3_monitor_PLPList.
*/
typedef struct sony_atsc3_plp_list_entry_t {
uint8_t id; /**< PIP ID (0 - 63) assigned uniquely in each RF channel */
uint8_t lls_flg; /**< PLP contains LLS information or not */
uint8_t layer; /**< Layer index of current PLP (0 (Core Layer) or 1 (Enhanced Layer)) */
uint8_t chbond; /**< The PLP is channel bonded or not */
} sony_atsc3_plp_list_entry_t;
typedef struct sony_atsc3_plp_list_t {
uint8_t plpnum;
sony_atsc3_plp_list_entry_t plplist[SONY_ATSC3_NUM_PLP_MAX];
uint8_t actual_tun_plpnum;
} sony_atsc3_plp_list;
/**
@brief Quick PLP parameter monitor values for ::sony_demod_atsc3_monitor_FecModCod.
*/
typedef struct sony_atsc3_plp_fecmodcod_t {
uint8_t valid; /**< This PLP is valid or not */
sony_atsc3_plp_fec_t fec_type; /**< PLP FEC method */
sony_atsc3_plp_mod_t mod; /**< PLP modulation */
sony_atsc3_plp_cod_t cod; /**< PLP code rate */
} sony_atsc3_plp_fecmodcod_t;
#endif /* SONY_ATSC3_H */
+31
View File
@@ -0,0 +1,31 @@
/*------------------------------------------------------------------------------
Copyright 2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/09/28
Modification ID : 1ea04def104d657deb64f0d0b0cae6ef992a9dd8
------------------------------------------------------------------------------*/
/**
@file sony_atsc3_chbond.h
This file provides ATSC 3.0 channel bonding related type definitions.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_ATSC3_CHBOND_H
#define SONY_ATSC3_CHBOND_H
#include "../sony_common.h"
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief ATSC 3.0 channel bonding related information in L1-Detail.
*/
typedef struct sony_atsc3_chbond_l1detail_t {
uint8_t num_rf; /**< Number of other frequencies in channel bonding (0 or 1) */
uint16_t bonded_bsid; /**< BSID of separate RF channel (valid if num_rf == 1) */
uint16_t bsid; /**< BSID of the current channel (valid if num_rf == 1) */
} sony_atsc3_chbond_l1detail_t;
#endif /* SONY_ATSC3_CHBOND_H */
+913
View File
@@ -0,0 +1,913 @@
/*------------------------------------------------------------------------------
Copyright 2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/12/13
Modification ID : e402a4dcb0e51a00c34b174334c082c1211eebf1
------------------------------------------------------------------------------*/
#include "sony_demod_atsc.h"
#include "sony_demod_atsc_monitor.h"
#include <stdio.h>
/*------------------------------------------------------------------------------
Definitions
------------------------------------------------------------------------------*/
/* Wait time */
#define WAITCOMMANDRESPONSE_POLL_INTERVAL_MS (10) /**< Wait Response Polling Interval (in ms). */
#define WAITCPUIDLE_TIMEOUT_MS (1000) /**< Wait for CPU idle (in ms). */
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief Command data for ATSC demodulator core.
*/
typedef struct
{
uint8_t data[6]; /**< Command Parameters */
} sony_demod_atsc_cmd_t;
/*------------------------------------------------------------------------------
Static Function Prototypes
------------------------------------------------------------------------------*/
/**
@brief Configure the demodulator from Sleep to Active for ATSC.
*/
static sony_result_t SLtoAA(sony_demod_t * pDemod);
/**
@brief Configure the demodulator from Active ATSC to Active ATSC. Used
for changing channel parameters.
*/
static sony_result_t AAtoAA(sony_demod_t * pDemod);
/**
@brief Configure the demodulator from Active ATSC to Sleep.
*/
static sony_result_t AAtoSL(sony_demod_t * pDemod);
/**
@brief Send Command to ATSC demodulator.
*/
static sony_result_t sendCommand (sony_demod_t *pDemod,
const sony_demod_atsc_cmd_t *pCmd);
/**
@brief Get Response Data from ATSC demodulator.
*/
static sony_result_t readResponse (sony_demod_t *pDemod,
sony_demod_atsc_cmd_t *pResp,
uint8_t cmdId);
/**
@brief Demodulation Abort function.
*/
static sony_result_t demodAbort (sony_demod_t * pDemod);
/**
@brief Continuous writing function.
*/
static sony_result_t slaveRWriteMultiRegisters (sony_demod_t * pDemod,
uint8_t bank,
uint8_t registerAddress,
const uint8_t* pData,
uint8_t size);
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
sony_result_t sony_demod_atsc_Tune (sony_demod_t * pDemod,
sony_atsc_tune_param_t * pTuneParam)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_demod_atsc_Tune");
if ((!pDemod) || (!pTuneParam)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if ((pDemod->state == SONY_DEMOD_STATE_ACTIVE) && (pDemod->system == SONY_DTV_SYSTEM_ATSC)) {
/* Demodulator Active and set to ATSC mode */
result = AAtoAA(pDemod);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
} else if ((pDemod->state == SONY_DEMOD_STATE_ACTIVE) && (pDemod->system != SONY_DTV_SYSTEM_ATSC)) {
/* Demodulator Active but not ATSC mode */
result = sony_demod_Sleep(pDemod);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
pDemod->system = SONY_DTV_SYSTEM_ATSC;
pDemod->bandwidth = SONY_DTV_BW_6_MHZ;
result = SLtoAA (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_ATSC;
pDemod->bandwidth = SONY_DTV_BW_6_MHZ;
result = SLtoAA (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 (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc_TuneEnd (sony_demod_t * pDemod)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_demod_atsc_TuneEnd");
if (!pDemod) {
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);
}
if (pDemod->system != SONY_DTV_SYSTEM_ATSC) {
/* Not ATSC */
SONY_TRACE_RETURN(SONY_RESULT_ERROR_SW_STATE);
}
result = sony_demod_atsc_SoftReset(pDemod);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Enable TS output */
result = sony_demod_SetStreamOutput (pDemod, 1);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
printf("demod enable ts output \n");
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc_SoftReset (sony_demod_t * pDemod)
{
sony_result_t result = SONY_RESULT_OK;
sony_demod_atsc_cmd_t cmd;
SONY_TRACE_ENTER ("sony_demod_atsc_SoftReset");
if (!pDemod) {
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);
}
if (pDemod->system != SONY_DTV_SYSTEM_ATSC) {
/* Not ATSC */
SONY_TRACE_RETURN(SONY_RESULT_ERROR_SW_STATE);
}
/* Abort Demodulation */
result = demodAbort (pDemod);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Start FAT Command
* byte0:COMMANDID_STARTFAT 0xB3
* byte1:Demod Mode
* :8VSB (0x10)
* :64QAM (0x11)
* :256QAM (0x12)
* :AUTO (0x16)
* byte2:Signal Check OFF
* :SIGNALCHK_ON (0x00)
* :SIGNALCHK_OFF (0x04)
* byte3:Reserved(0x00)
* byte4:Reserved(0x00)
* byte5:Reserved(0x00)
*/
cmd.data[0] = 0xB3;
cmd.data[1] = 0x10; /* 8VSB Mode */
if (pDemod->atscAutoSignalCheckOff) {
cmd.data[2] = 0x04; /* During Scanning Signal Check Off */
}
else {
cmd.data[2] = 0x00; /* During Scanning Signal Check On */
}
cmd.data[3] = 0;
cmd.data[4] = 0;
cmd.data[5] = 0;
/* Send Command */
result = sendCommand (pDemod, &cmd);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Get Response */
result = readResponse (pDemod, &cmd, 0xB3);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Update Current Internal CPU State */
pDemod->atscCPUState = SONY_DEMOD_ATSC_CPU_STATE_BUSY;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc_Sleep (sony_demod_t * pDemod)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_demod_atsc_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 = AAtoSL (pDemod);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc_CheckDemodLock (sony_demod_t * pDemod,
sony_demod_lock_result_t * pLock)
{
sony_result_t result = SONY_RESULT_OK;
uint8_t vqlock = 0;
uint8_t tslock = 0;
uint8_t agclock = 0;
uint8_t unlockDetected = 0;
SONY_TRACE_ENTER ("sony_demod_atsc_CheckDemodLock");
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);
}
*pLock = SONY_DEMOD_LOCK_RESULT_NOTDETECT;
result = sony_demod_atsc_monitor_SyncStat (pDemod, &vqlock, &agclock, &tslock, &unlockDetected);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
if (pDemod->atscUnlockDetection) {
if (unlockDetected) {
*pLock = SONY_DEMOD_LOCK_RESULT_UNLOCKED;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
} else {
/* the result of unlockDetect should be ignored */
unlockDetected = 0;
}
if (vqlock) {
*pLock = SONY_DEMOD_LOCK_RESULT_LOCKED;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc_CheckTSLock (sony_demod_t * pDemod,
sony_demod_lock_result_t * pLock)
{
sony_result_t result = SONY_RESULT_OK;
uint8_t vqlock = 0;
uint8_t tslock = 0;
uint8_t agclock = 0;
uint8_t unlockDetected = 0;
SONY_TRACE_ENTER ("sony_demod_atsc_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);
}
*pLock = SONY_DEMOD_LOCK_RESULT_NOTDETECT;
result = sony_demod_atsc_monitor_SyncStat (pDemod, &vqlock, &agclock, &tslock, &unlockDetected);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
//PR_TUN("dbg_pr vqlock=%d, agclock=%d, tslock=%d, unlockDetected=%d\n",vqlock, agclock, tslock, unlockDetected);
if (tslock) {
*pLock = SONY_DEMOD_LOCK_RESULT_LOCKED;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
if (pDemod->atscUnlockDetection) {
if (unlockDetected) {
*pLock = SONY_DEMOD_LOCK_RESULT_UNLOCKED;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
} else {
/* the result of unlockDetect should be ignored */
unlockDetected = 0;
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc_SlaveRWriteRegister (sony_demod_t * pDemod,
uint8_t bank,
uint8_t registerAddress,
uint8_t value,
uint8_t bitMask)
{
sony_result_t result = SONY_RESULT_OK;
sony_demod_atsc_cmd_t cmd;
SONY_TRACE_ENTER ("sony_demod_atsc_SlaveRWriteRegister");
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 or Active state only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
if (pDemod->atscCPUState != SONY_DEMOD_ATSC_CPU_STATE_IDLE) {
/* This api is accepted in CPU Idle State */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* Write Register Command
* byte0:COMMANDID_WRITE_REG 0xC5
* byte1:Bank
* byte2:SubAddress
* byte3:Write Data
* byte4:Mask
* byte5:Reserved(0x00)
*/
cmd.data[0] = 0xC5;
cmd.data[1] = bank;
cmd.data[2] = registerAddress;
cmd.data[3] = value;
cmd.data[4] = bitMask;
cmd.data[5] = 0;
/* Send Command */
result = sendCommand(pDemod, &cmd);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Get Response */
result = readResponse(pDemod, &cmd, 0xC5);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
SONY_TRACE_RETURN (result);
}
sony_result_t sony_demod_atsc_SlaveRReadRegister (sony_demod_t * pDemod,
uint8_t bank,
uint8_t registerAddress,
uint8_t * pValue)
{
sony_result_t result = SONY_RESULT_OK;
sony_demod_atsc_cmd_t cmd;
SONY_TRACE_ENTER ("sony_demod_atsc_SlaveRReadRegister");
if (!pDemod || !pValue) {
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 or Active state only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
if (pDemod->atscCPUState != SONY_DEMOD_ATSC_CPU_STATE_IDLE) {
/* This api is accepted in CPU Idle State */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/*
* Read Register Command
* byte0:COMMANDID_READ_REG 0xC6
* byte1:Bank
* byte2:SubAddress
* byte3:Reserved(0x00)
* byte4:Reserved(0x00)
* byte5:Reserved(0x00)
*/
cmd.data[0] = 0xC6;
cmd.data[1] = bank;
cmd.data[2] = registerAddress;
cmd.data[3] = 0;
cmd.data[4] = 0;
cmd.data[5] = 0;
/* Send Command */
result = sendCommand (pDemod, &cmd);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Get Response */
result = readResponse (pDemod, &cmd, 0xC6);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
*pValue = cmd.data[1];
SONY_TRACE_RETURN (result);
}
/*------------------------------------------------------------------------------
Static Functions
------------------------------------------------------------------------------*/
static sony_result_t SLtoAA(sony_demod_t * pDemod)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("SLtoAA");
if (!pDemod) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Configure TS clock Mode and Frequency */
result = sony_demod_SetTSClockModeAndFreq (pDemod, SONY_DTV_SYSTEM_ATSC);
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, 0x0F) != 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);
}
result = demodAbort (pDemod);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* IF Frequency Setting */
{
uint8_t data[4];
data[0] = (uint8_t) ( pDemod->iffreqConfig.configATSC & 0xFF);
data[1] = (uint8_t) ((pDemod->iffreqConfig.configATSC >> 8) & 0xFF);
data[2] = (uint8_t) ((pDemod->iffreqConfig.configATSC >> 16) & 0xFF);
data[3] = (uint8_t) ((pDemod->iffreqConfig.configATSC >> 24) & 0xFF);
/*
* slave Bank Addr Bit Default Value Name
* ----------------------------------------------------------------------------------
* <SLV-R> A3h A1h [7:0] 8'h4F user define vsb_DRPSPA_LOENGEN_EXT_FIXED_FREQ[7:0]
* <SLV-R> A3h A2h [7:0] 8'hC2 user define vsb_DRPSPA_LOENGEN_EXT_FIXED_FREQ[15:8]
* <SLV-R> A3h A3h [7:0] 8'hF6 user define vsb_DRPSPA_LOENGEN_EXT_FIXED_FREQ[23:16]
* <SLV-R> A3h A4h [7:0] 8'h24 user define vsb_DRPSPA_LOENGEN_EXT_FIXED_FREQ[31:24]
*/
result = slaveRWriteMultiRegisters (pDemod, 0xA3, 0xA1, data, sizeof(data));
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
}
/* ASCOT Setting */
if (pDemod->tunerOptimize == SONY_DEMOD_TUNER_OPTIMIZE_SONYSILICON) {
/* ASCOT setting ON
* slave Bank Addr Bit Default Value Name
* ---------------------------------------------------------------------------------
* <SLV-R> A0h 13h [1:0] 8'h03 8'h03 vsb_gdeq_on
*/
result = sony_demod_atsc_SlaveRWriteRegister (pDemod, 0xA0, 0x13, 0x03, 0x03);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
} else {
/* ASCOT setting OFF
* slave Bank Addr Bit Default Value Name
* ----------------------------------------------------------------------------------
* <SLV-R> A0h 13h [1:0] 8'h03 8'h00 vsb_gdeq_on
*/
result = sony_demod_atsc_SlaveRWriteRegister (pDemod, 0xA0, 0x13, 0x00, 0x03);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
}
if (pDemod->tunerOptimize == SONY_DEMOD_TUNER_OPTIMIZE_SONYSILICON) {
/* Filter Setting
* slave Bank Addr Bit Default Value Name
* --------------------------------------------------------------------------------
* <SLV-R> 06h A0h [7:0] 8'h31 8'h31 OHI_GDEQ_COEF01
* <SLV-R> 06h A1h [7:0] 8'hA5 8'hA5 OHI_GDEQ_COEF02
* <SLV-R> 06h A2h [7:0] 8'h2E 8'h2E OHI_GDEQ_COEF11
* <SLV-R> 06h A3h [7:0] 8'h9F 8'h9F OHI_GDEQ_COEF12
* <SLV-R> 06h A4h [7:0] 8'h2B 8'h2B OHI_GDEQ_COEF21
* <SLV-R> 06h A5h [7:0] 8'h99 8'h99 OHI_GDEQ_COEF22
* <SLV-R> 06h A6h [7:0] 8'h00 8'h00 OHI_GDEQ_COEF31
* <SLV-R> 06h A7h [7:0] 8'hCD 8'hCD OHI_GDEQ_COEF32
* <SLV-R> 06h A8h [7:0] 8'h00 8'h00 OHI_GDEQ_COEF41
* <SLV-R> 06h A9h [7:0] 8'hCD 8'hCD OHI_GDEQ_COEF42
* <SLV-R> 06h AAh [7:0] 8'h00 8'h00 OHI_GDEQ_COEF51
* <SLV-R> 06h ABh [7:0] 8'h00 8'h00 OHI_GDEQ_COEF52
* <SLV-R> 06h ACh [7:0] 8'h2B 8'h2B OHI_GDEQ_COEF61
* <SLV-R> 06h ADh [7:0] 8'h9D 8'h9D OHI_GDEQ_COEF62
*/
const uint8_t data[] = { 0x31, 0xA5, 0x2E, 0x9F, 0x2B, 0x99, 0x00, 0xCD, 0x00, 0xCD, 0x00, 0x00, 0x2B, 0x9D };
result = slaveRWriteMultiRegisters (pDemod, 0x06, 0xA0, data, sizeof(data));
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
}
/* ATSC1.0 initial setting */
{
uint8_t noSignalThresh[3];
uint8_t signalThresh[3];
/*
* slave Bank Addr Bit Default Value Name
* -----------------------------------------------------------------------
* <SLV-R> A0h 6Fh [7:0] 8'h37 8'h61 dagca_no_signal_thresh[7:0]
* <SLV-R> A0h 70h [7:0] 8'h2e 8'hFB dagca_no_signal_thresh[15:8]
* <SLV-R> A0h 71h [7:0] 8'h66 8'h7F dagca_no_signal_thresh[23:16]
* <SLV-R> 09h 80h [7:0] 8'hAE 8'h61 OHI_DAGCA_NOSIG_THRESH[7:0]
* <SLV-R> 09h 81h [7:0] 8'h37 8'hFB OHI_DAGCA_NOSIG_THRESH[15:8]
* <SLV-R> 09h 82h [7:0] 8'h61 8'h7F OHI_DAGCA_NOSIG_THRESH[23:16]
* <SLV-R> A0h 73h [7:0] 8'hFC 8'h26 dagca_signal_thresh[7:0]
* <SLV-R> A0h 74h [7:0] 8'hA2 8'h49 dagca_signal_thresh[15:8]
* <SLV-R> A0h 75h [7:0] 8'h5C 8'h7C dagca_signal_thresh[23:16]
* <SLV-R> 09h 83h [7:0] 8'hAE 8'h26 OHI_DAGCA_SIG_THRESH[7:0]
* <SLV-R> 09h 84h [7:0] 8'h27 8'h49 OHI_DAGCA_SIG_THRESH[15:8]
* <SLV-R> 09h 85h [7:0] 8'h61 8'h7C OHI_DAGCA_SIG_THRESH[23:16]
* <SLV-R> 06h 71h [2:0] 8'h00 8'h05 OHI_CONST_SEL[2:0]
*/
noSignalThresh[0] = (uint8_t)(pDemod->atscNoSignalThresh & 0xFF);
noSignalThresh[1] = (uint8_t)((pDemod->atscNoSignalThresh >> 8) & 0xFF);
noSignalThresh[2] = (uint8_t)((pDemod->atscNoSignalThresh >> 16) & 0xFF);
signalThresh[0] = (uint8_t)(pDemod->atscSignalThresh & 0xFF);
signalThresh[1] = (uint8_t)((pDemod->atscSignalThresh >> 8) & 0xFF);
signalThresh[2] = (uint8_t)((pDemod->atscSignalThresh >> 16) & 0xFF);
result = slaveRWriteMultiRegisters (pDemod, 0xA0, 0x6F, noSignalThresh, sizeof(noSignalThresh));
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
result = slaveRWriteMultiRegisters (pDemod, 0x09, 0x80, noSignalThresh, sizeof(noSignalThresh));
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
result = slaveRWriteMultiRegisters (pDemod, 0xA0, 0x73, signalThresh, sizeof(signalThresh));
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
result = slaveRWriteMultiRegisters (pDemod, 0x09, 0x83, signalThresh, sizeof(signalThresh));
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
result = sony_demod_atsc_SlaveRWriteRegister (pDemod, 0x06, 0x71, 0x05, 0x07);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
}
/* Spectrum Inversion Setting
* RF signal spectrum | tuner spectrum sense | Setting
* | (pDemod->confSense) | (from Demod View)
* -------------------+--------------------------+---------
* Normal | not same as RF(Normal) | 1B (Normal)
* Invert | not same as RF(Normal) | 0B (Invert)
* Normal | same as RF(Invert) | 0B (Invert)
* Invert | same as RF(Invert) | 1B (Normal)
* slave Bank Addr Bit Default Value Name
*------------------------------------------------------------------------------------------
* <SLV-R> A3h A0h [4] 8'h1B 8'h** vsb_DRPSPA_LOENGEN_POSSHIFT
*/
if (pDemod->rfSpectrumSense == pDemod->confSense){
result = sony_demod_atsc_SlaveRWriteRegister (pDemod, 0xA3, 0xA0, 0x10, 0x10);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
} else {
result = sony_demod_atsc_SlaveRWriteRegister (pDemod, 0xA3, 0xA0, 0x00, 0x10);
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 AAtoAA(sony_demod_t * pDemod)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("AAtoAA");
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);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
static sony_result_t AAtoSL(sony_demod_t * pDemod)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("AAtoSL");
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);
}
result = demodAbort (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);
}
/* Cancel ATSC1 setting
* slave Bank Addr Bit Default Value Name
* ----------------------------------------------------------------------------------
* <SLV-T> 00h D3h [0] 8'h00 8'h00 OTSRATECTRLOFF
*/
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xD3, 0x00) != 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);
}
/* 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);
}
/* 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);
}
static sony_result_t sendCommand (sony_demod_t *pDemod, const sony_demod_atsc_cmd_t *pCmd)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sendCommand");
if ((!pDemod) || (!pDemod->pI2c) || (!pCmd)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Write data to 0x0A register */
result = pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVR, 0x0A, pCmd->data, sizeof(pCmd->data));
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SONY_TRACE_RETURN (result);
}
static sony_result_t readResponse (sony_demod_t *pDemod, sony_demod_atsc_cmd_t *pResp, uint8_t cmdId)
{
sony_result_t result = SONY_RESULT_OK;
uint32_t waitTime = 0;
SONY_TRACE_ENTER ("readResponse");
if ((!pDemod) || (!pDemod->pI2c) || (!pResp)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
for (;;) {
/* Read data to 0x0A register */
result = pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVR, 0x0A, pResp->data, sizeof(pResp->data));
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (pResp->data[0] == 0x00) {
/* Waiting... */
SONY_SLEEP (WAITCOMMANDRESPONSE_POLL_INTERVAL_MS);
waitTime += WAITCOMMANDRESPONSE_POLL_INTERVAL_MS;
}
else {
if (pResp->data[5] == cmdId) {
break;
}
else {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
}
if (waitTime >= WAITCPUIDLE_TIMEOUT_MS) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_TIMEOUT);
}
}
/* Check Response Status */
if ((pResp->data[0] & 0x3F) == 0x30) {
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
else {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_OTHER);
}
}
static sony_result_t slaveRWriteMultiRegisters (sony_demod_t * pDemod,
uint8_t bank,
uint8_t registerAddress,
const uint8_t* pData,
uint8_t size)
{
uint8_t wtimes = 0;
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("slaveRWriteMultiRegisters");
if (!pDemod || !pData ) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
for (wtimes = 0; wtimes < size; wtimes++) {
result = sony_demod_atsc_SlaveRWriteRegister (pDemod, bank, registerAddress + wtimes, *(pData + wtimes), 0xFF);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
static sony_result_t demodAbort (sony_demod_t * pDemod)
{
if (!pDemod){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
SONY_TRACE_ENTER ("demodAbort");
/* Set SLV-R Bank : 0x01 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVR, 0x00, 0x01) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Abort Current Demodulation
* slave Bank Addr Bit Value Name
* -------------------------------------------------------------------------------------
* <SLV-R> 01h 48h [0] 1'b1 OCPUWAKEUP
*/
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVR, 0x48, 0x01) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Update Current Internal CPU State */
pDemod->atscCPUState = SONY_DEMOD_ATSC_CPU_STATE_IDLE;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
+139
View File
@@ -0,0 +1,139 @@
/*------------------------------------------------------------------------------
Copyright 2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/27
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
------------------------------------------------------------------------------*/
/**
@file sony_demod_atsc.h
This file provides the demodulator control interface specific to ATSC.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_ATSC_H
#define SONY_DEMOD_ATSC_H
#include "../sony_common.h"
#include "../sony_demod.h"
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief The tune parameters for a ATSC signal
*/
typedef struct sony_atsc_tune_param_t {
/**
@brief Center frequency in kHz of the ATSC channel.
*/
uint32_t centerFreqKHz;
} sony_atsc_tune_param_t;
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Enable acquisition on the demodulator for ATSC channels.
Called from the integration layer ::sony_integ_atsc_Tune API.
@param pDemod The demodulator instance
@param pTuneParam The tune parameters.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc_Tune (sony_demod_t * pDemod,
sony_atsc_tune_param_t * pTuneParam);
/**
@brief Completes the demodulator ATSC acquisition setup.
Must be called after system specific demod and RF tunes.
Called from the integration layer ::sony_integ_atsc_Tune API.
@param pDemod The demodulator instance.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc_TuneEnd (sony_demod_t * pDemod);
/**
@brief Soft reset the demodulator for ATSC.
The soft reset will begin the devices acquisition process.
Called from ::sony_demod_SoftReset API.
@param pDemod The demod instance.
@return SONY_RESULT_OK if successfully reset.
*/
sony_result_t sony_demod_atsc_SoftReset (sony_demod_t * pDemod);
/**
@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_atsc_Sleep (sony_demod_t * pDemod);
/**
@brief Check ATSC demodulator lock status.
@param pDemod The demodulator instance
@param pLock Demod lock state
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc_CheckDemodLock (sony_demod_t * pDemod,
sony_demod_lock_result_t * pLock);
/**
@brief Check ATSC TS lock status.
@param pDemod The demodulator instance
@param pLock TS lock state
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc_CheckTSLock (sony_demod_t * pDemod,
sony_demod_lock_result_t * pLock);
/**
@brief Write 1-byte data to the demodulator register with SLV-R I2C channel.
@param pDemod The demodulator instance.
@param bank The bank number of the target demodulator registers.
@param registerAddress The register address of the target demodulator register.
@param value The value to write into demodulator register contents.
@param bitMask The mask to apply with the value.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc_SlaveRWriteRegister (sony_demod_t * pDemod,
uint8_t bank,
uint8_t registerAddress,
uint8_t value,
uint8_t bitMask);
/**
@brief Read 1-byte data from the demodulator register with SLV-R I2C channel.
@param pDemod The demodulator instance.
@param bank The bank number of the target demodulator registers.
@param registerAddress The register address of the target demodulator register.
@param pValue The buffer to store the demodulator register contents into.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc_SlaveRReadRegister (sony_demod_t * pDemod,
uint8_t bank,
uint8_t registerAddress,
uint8_t * pValue);
#endif /* SONY_DEMOD_ATSC_H */
Binary file not shown.
File diff suppressed because it is too large Load Diff
+244
View File
@@ -0,0 +1,244 @@
/*------------------------------------------------------------------------------
Copyright 2018-2019 Sony Semiconductor Solutions Corporation
Last Updated : 2019/10/04
Modification ID : ae1245fdaf66401838902e7214d8494b0f5e5a76
------------------------------------------------------------------------------*/
/**
@file sony_demod_atsc3.h
This file provides the demodulator control interface specific to ATSC 3.0.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_ATSC3_H
#define SONY_DEMOD_ATSC3_H
#include "../sony_common.h"
#include "../sony_demod.h"
#ifdef SONY_DEMOD_SUPPORT_ATSC3_CHBOND
#include "sony_demod_atsc3_chbond.h"
#endif
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief The tune parameters for a ATSC 3.0 signal
*/
typedef struct sony_atsc3_tune_param_t {
/**
@brief Center frequency in kHz of the ATSC 3.0 channel.
*/
uint32_t centerFreqKHz;
/**
@brief Bandwidth of the ATSC 3.0 channel.
*/
sony_dtv_bandwidth_t bandwidth;
/**
@brief Number of valid PLP ID in plpID[].
*/
uint8_t plpIDNum;
/**
@brief PLP IDs to select in acquisition.
*/
uint8_t plpID[4];
#ifdef SONY_DEMOD_SUPPORT_ATSC3_CHBOND
/**
@brief PLP bonding option for each PLPs.
Used only then the demod is configured as ATSC 3.0 channel bonding main/sub IC.
For main IC, the user should arrange PLP IDs on following constraints.
* plpBond[0] must be SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE or SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_FROM_MAIN
* SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_FROM_SUB PLP cannot be located prior to
SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE or SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_FROM_MAIN PLPs
on plpID[] and plpBond[].
For example, following is invalid.
plpBond[0] = SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE
plpBond[1] = SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE
plpBond[2] = SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_FROM_SUB
plpBond[3] = SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_FROM_MAIN
The user should change PLP ID selection order like as follows.
plpBond[0] = SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE
plpBond[1] = SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE
plpBond[2] = SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_FROM_MAIN
plpBond[3] = SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_FROM_SUB
*/
sony_demod_atsc3_chbond_plp_bond_t plpBond[4];
#endif
} sony_atsc3_tune_param_t;
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Enable acquisition on the demodulator for ATSC 3.0 channels. Called from
the integration layer ::sony_integ_atsc3_Tune API.
@param pDemod The demodulator instance
@param pTuneParam The tune parameters.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc3_Tune (sony_demod_t * pDemod,
sony_atsc3_tune_param_t * pTuneParam);
/**
@brief Enable acquisition on the demodulator for ATSC 3.0 channels in EAS mode.
Called from the integration layer ::sony_integ_atsc3_EASTune API.
@param pDemod The demodulator instance
@param pTuneParam The tune parameters.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc3_EASTune (sony_demod_t * pDemod,
sony_atsc3_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_atsc3_Sleep (sony_demod_t * pDemod);
/**
@brief Completes the demodulator acquisition setup only the case for ATSC 3.0 EAS tune.
Must be called after system specific demod and RF tunes.
Called from the integration layer ::sony_integ_atsc3_EASTune API.
@param pDemod The demodulator instance
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc3_EASTuneEnd (sony_demod_t * pDemod);
/**
@brief Check ATSC 3.0 demodulator lock status.
@note This API is for checking lock status in tuning stage.
After tuning (while receiving the signal),
please use sony_demod_atsc3_monitor_SyncStat instead
to check current lock status.
@param pDemod The demodulator instance
@param pLock Demod lock state
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc3_CheckDemodLock (sony_demod_t * pDemod,
sony_demod_lock_result_t * pLock);
/**
@brief Check ATSC 3.0 ALP lock status.
@note This API is for checking lock status in tuning stage.
After tuning (while receiving the signal),
please use sony_demod_atsc3_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_atsc3_CheckALPLock (sony_demod_t * pDemod,
sony_demod_lock_result_t * pLock,
uint8_t *p_syncState,
uint8_t *p_alpLockAll);
/**
@brief Setup the PLP configuration of the demodulator.
@param pDemod The demodulator instance.
@param plpIDNum Number of valid PLP ID in plpID[]. (1 - 4)
@param plpID The pointer of PLP ID 4 length array to set.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc3_SetPLPConfig (sony_demod_t * pDemod,
uint8_t plpIDNum,
uint8_t plpID[4]);
/**
@brief Clear BER, SNR history data for averaged BER, SNR, SQI monitors.
@note This function may be useful if the user would like to calculate
averaged BER, SNR, SQI without using old BER, SNR data.
Please check document and example code for recommended setting and sequence.
@param pDemod The demodulator instance
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc3_ClearBERSNRHistory (sony_demod_t * pDemod);
/**
@brief Clear GPIO EAS latch data for GPIO EAS latch mode.
Clear GPIO EAS latch data.
Please check ::SONY_DEMOD_CONFIG_ATSC3_GPIO_EAS_PN_STATE
and ::SONY_DEMOD_CONFIG_ATSC3_GPIO_EAS_PN_TRANS too.
To output EAS state from GPIO, please check ::sony_demod_GPIOSetConfig.
@param pDemod The demodulator instance
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc3_ClearGPIOEASLatch (sony_demod_t * pDemod);
/**
@brief Spectrum inversion and continuous wave auto detection.
@note Auto spectrum inversion and CW detection are enabled/disabled by ::sony_demod_SetConfig.
(::SONY_DEMOD_CONFIG_ATSC3_AUTO_SPECTRUM_INV, ::SONY_DEMOD_CONFIG_ATSC3_CW_DETECTION)
@param pDemod The demodulator instance
@param pContinueWait Lock wait flag (When this flag = 1, continue waiting Lock)
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc3_AutoDetectSeq_UnlockCase (sony_demod_t * pDemod, uint8_t * pContinueWait);
/**
@brief Setup continuous wave tracking.
@note This API has effect only when CW detection is enabled by ::sony_demod_SetConfig.
(::SONY_DEMOD_CONFIG_ATSC3_CW_DETECTION)
@param pDemod The demodulator instance
@param pCompleted CW Tracking setting completed flag (When this flag = 1, CW tracking setting is completed)
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc3_AutoDetectSeq_SetCWTracking (sony_demod_t * pDemod, uint8_t * pCompleted);
/**
@brief Initialize spectrum inversion and continuous wave auto detection related registers.
@param pDemod The demodulator instance
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc3_AutoDetectSeq_Init (sony_demod_t * pDemod);
#endif /* SONY_DEMOD_ATSC3_H */
Binary file not shown.
+539
View File
@@ -0,0 +1,539 @@
/*------------------------------------------------------------------------------
Copyright 2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/12/13
Modification ID : e402a4dcb0e51a00c34b174334c082c1211eebf1
------------------------------------------------------------------------------*/
#include "sony_demod_atsc3_chbond.h"
#include "sony_demod_atsc3_monitor.h"
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
sony_result_t sony_demod_atsc3_chbond_Enable (sony_demod_t * pDemod,
uint8_t enable)
{
SONY_TRACE_ENTER ("sony_demod_atsc3_chbond_Enable");
if (!pDemod) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if ((pDemod->chbondConfig != SONY_DEMOD_CHBOND_CONFIG_ATSC3_MAIN)
&& (pDemod->chbondConfig != SONY_DEMOD_CHBOND_CONFIG_ATSC3_SUB)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
if (pDemod->chbondConfig == SONY_DEMOD_CHBOND_CONFIG_ATSC3_MAIN) {
/* 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);
}
/*
* slave Bank Addr Bit Default Value Name
* --------------------------------------------------------------------------------
* <SLV-X> 00h C1h [2:0] 8'h00 8'h0x OREG_STREAMIN_EN
*
* Bit[0]: Stream input0 Bit[1]: Stream input1 Bit[2]: Stream input2
* 1: Stream input enble 0:Stream input disable
*/
/* Set Stream Input */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0xC1, enable ? pDemod->chbondStreamIn : 0x00) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
}
/* Set SLV-T Bank : 0x03 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x03) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/*
* slave Bank Addr Bit Default Value Name
* ---------------------------------------------------------------------------------------
* <SLV-T> 03h B2h [0] 8'h00 8'hxx OREG_BCHBOND0_ON
* <SLV-T> 03h B3h [0] 8'h00 8'hxx OREG_BCHBOND1_ON
* <SLV-T> 03h B4h [0] 8'h00 8'hxx OREG_BCHBOND2_ON
* <SLV-T> 03h B5h [0] 8'h00 8'hxx OREG_BCHBOND3_ON
* <SLV-T> 03h B6h [0] 8'h01 8'hxx OREG_ATSC30_CHBOND_MAIN_FLAG
*/
if (enable) {
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xB6, pDemod->chbondConfig == SONY_DEMOD_CHBOND_CONFIG_ATSC3_SUB ? 0x00 : 0x01) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
} else {
uint8_t data[] = {0x00, 0x00, 0x00, 0x00, 0x01};
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xB2, data, 5) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
}
/* Set SLV-T Bank : 0x93 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x93) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/*
* slave Bank Addr Bit Default Value Name
* ---------------------------------------------------------------------------------------
* <SLV-T> 93h F4h [7:0] 8'h23 8'h03 OREG_DCG_CGON[7:0]
*/
if (pDemod->chbondConfig == SONY_DEMOD_CHBOND_CONFIG_ATSC3_MAIN) {
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xF4, enable ? 0x03 : 0x23) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
}
/*
* slave Bank Addr Bit Default Value Name
* ---------------------------------------------------------------------------------------
* <SLV-T> 93h 85h [0] 8'h01 8'h00 OREG_PLP_ID_AUTO
*/
/*if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x85, enable ? 0x00 : 0x01) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}*/
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc3_chbond_SetPLPConfig (sony_demod_t * pDemod,
uint8_t plpIDNum,
uint8_t plpID[4],
sony_demod_atsc3_chbond_plp_bond_t plpBond[4])
{
int i = 0;
uint8_t data[4];
SONY_TRACE_ENTER ("sony_demod_atsc3_chbond_SetPLPConfig");
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);
}
if ((pDemod->chbondConfig != SONY_DEMOD_CHBOND_CONFIG_ATSC3_MAIN) && (pDemod->chbondConfig != SONY_DEMOD_CHBOND_CONFIG_ATSC3_SUB)) {
/* For ATSC 3.0 channel bonding only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* plpIDNum range check */
if ((plpIDNum == 0) || (plpIDNum > 4)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* PLP ID range check */
for (i = 0; i < plpIDNum; i++) {
if (plpID[i] > 0x3F) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
}
if (pDemod->chbondConfig == SONY_DEMOD_CHBOND_CONFIG_ATSC3_MAIN) {
/* Main IC */
/* OREGD_PLP_ID_0_VALID should be 1 */
if ((plpBond[0] != SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE) &&
(plpBond[0] != SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_FROM_MAIN)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
for (i = 1; i < plpIDNum; i++) {
switch (plpBond[i]) {
case SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE:
case SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_FROM_MAIN:
/* (OREGD_PLP_ID_X_VALID = 0) PLP should NOT be located prior to (OREGD_PLP_ID_X_VALID = 1) PLP */
if (plpBond[i - 1] == SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_FROM_SUB) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
break;
case SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_FROM_SUB:
break;
default:
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
}
} else {
/* Sub IC */
for (i = 0; i < plpIDNum; i++) {
switch (plpBond[i]) {
case SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE:
case SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_FROM_SUB:
break;
case SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_FROM_MAIN:
default:
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
}
}
/* Set SLV-T Bank : 0x93 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x93) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* slave Bank Addr Bit default Value Name
* ----------------------------------------------------------------------------------
* <SLV-T> 93h 80h [7:0] 8'h00 8'hxx OREGD_PLP_ID_0_VALID,OREGD_PLP_ID_0_CHBVALID,OREGD_PLP_ID_0[5:0]
* <SLV-T> 93h 81h [7:0] 8'h00 8'hxx OREGD_PLP_ID_1_VALID,OREGD_PLP_ID_1_CHBVALID,OREGD_PLP_ID_1[5:0]
* <SLV-T> 93h 82h [7:0] 8'h00 8'hxx OREGD_PLP_ID_2_VALID,OREGD_PLP_ID_2_CHBVALID,OREGD_PLP_ID_2[5:0]
* <SLV-T> 93h 83h [7:0] 8'h00 8'hxx OREGD_PLP_ID_3_VALID,OREGD_PLP_ID_3_CHBVALID,OREGD_PLP_ID_3[5:0]
* <SLV-T> 93h 85h [0] 8'h01 8'h00 OREG_PLP_ID_AUTO
*/
for (i = 0; i < 4; i++) {
if (i < plpIDNum) {
if (pDemod->chbondConfig == SONY_DEMOD_CHBOND_CONFIG_ATSC3_MAIN) {
data[i] = plpID[i] | (plpBond[i] == SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_FROM_SUB ? 0x40 : 0xC0);
} else {
data[i] = plpID[i] | 0x80;
}
} else {
data[i] = 0;
}
}
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x80, data, sizeof (data)) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OREG_PLP_ID_AUTO should be 0 in channel bonding */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x85, 0x00) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set SLV-T Bank : 0x03 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x03) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* slave Bank Addr Bit Default Value Name
* ----------------------------------------------------------------------------------
* <SLV-T> 03h B2h [0] 8'h00 8'hxx OREG_BCHBOND0_ON
* <SLV-T> 03h B3h [0] 8'h00 8'hxx OREG_BCHBOND1_ON
* <SLV-T> 03h B4h [0] 8'h00 8'hxx OREG_BCHBOND2_ON
* <SLV-T> 03h B5h [0] 8'h00 8'hxx OREG_BCHBOND3_ON
*/
for (i = 0; i < 4; i++) {
if ((i < plpIDNum) && (plpBond[i] == SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE)) {
data[i] = 0x01;
} else {
data[i] = 0x00;
}
}
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xB2, data, sizeof (data)) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set SLV-T Bank : 0x93 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x93) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Make IPLPINFO_RDY low for changing PLP without re-tuning case
*
* slave Bank Addr Bit default Value Name
* ----------------------------------------------------------------------------------
* <SLV-T> 93h 9Ch [0] 1'b0 1'b1 OREGD_PLPINFO_UPD
*/
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x9C, 0x01) != SONY_RESULT_OK) {
SONY_TRACE_RETURN(SONY_RESULT_ERROR_I2C);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc3_chbond_monitor_BondStat (sony_demod_t * pDemod,
uint8_t bondLockStat[4],
uint8_t * pBondLockAll,
uint8_t * pBondUnlockDetected)
{
uint8_t data;
int i;
SONY_TRACE_ENTER ("sony_demod_atsc3_chbond_monitor_BondStat");
if ((!pDemod) || (!bondLockStat) || (!pBondLockAll) || (!pBondUnlockDetected)) {
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_ATSC3) || (pDemod->chbondConfig != SONY_DEMOD_CHBOND_CONFIG_ATSC3_MAIN)) {
/* Only for ATSC 3.0 channel bonding main */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
*pBondUnlockDetected = 0;
/* Set SLV-T Bank : 0x9D */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x9D) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* slave Bank Addr Bit Name Meaning
* ----------------------------------------------------------------------------------
* <SLV-T> 9Dh 10h [0] ICHB_UNEXP_SP_OVERFLOW 0:Keep polling, 1:UnlockCallback
* <SLV-T> 9Dh 13h [4] ICHB_UNEXP_SHORTPKT_S 0:Keep polling, 1:UnlockCallback
* <SLV-T> 9Dh B0h [4] ICHB_LOCK_AND
* <SLV-T> 9Dh B0h [3] ICHB_LOCK_3
* <SLV-T> 9Dh B0h [2] ICHB_LOCK_2
* <SLV-T> 9Dh B0h [1] ICHB_LOCK_1
* <SLV-T> 9Dh B0h [0] ICHB_LOCK_0
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x10, &data, 1) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (data & 0x01) {
*pBondUnlockDetected = 1;
}
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x13, &data, 1) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (data & 0x10) {
*pBondUnlockDetected = 1;
}
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xB0, &data, 1) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
for (i = 0; i < 4; i++) {
bondLockStat[i] = (data >> i) & 0x01;
}
*pBondLockAll = data >> 4 & 0x01;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc3_chbond_monitor_SelectedPLPValid (sony_demod_t * pDemod,
sony_demod_atsc3_chbond_plp_valid_t plpValid[4])
{
sony_result_t result;
int i, j;
uint8_t plpIdValid[4];
uint8_t chBondValid[4];
uint8_t chBondOn[4];
uint8_t selectedPlpId[4];
uint8_t data[5];
const int plpConfigCheckTable[8][2] = {
/* Main */ /* Sub */ /* PLP_VALID CHB_VALID BCHBOND_ON */
{SONY_DEMOD_ATSC3_CHBOND_PLP_VALID_UNUSED, SONY_DEMOD_ATSC3_CHBOND_PLP_VALID_UNUSED}, /* 0 0 0 */
{/* Invalid Setting */ -1, /* Invalid Setting */ -1 }, /* 0 0 1 */
{SONY_DEMOD_ATSC3_CHBOND_PLP_VALID_FROM_SUB, /* Invalid Setting */ -1 }, /* 0 1 0 */
{/* Invalid Setting */ -1, /* Invalid Setting */ -1 }, /* 0 1 1 */
{/* Invalid Setting */ -1, SONY_DEMOD_ATSC3_CHBOND_PLP_VALID_OK }, /* 1 0 0 */
{/* Invalid Setting */ -1, SONY_DEMOD_ATSC3_CHBOND_PLP_VALID_OK }, /* 1 0 1 */
{SONY_DEMOD_ATSC3_CHBOND_PLP_VALID_OK, /* Invalid Setting */ -1 }, /* 1 1 0 */
{SONY_DEMOD_ATSC3_CHBOND_PLP_VALID_OK, /* Invalid Setting */ -1 } /* 1 1 1 */
};
SONY_TRACE_ENTER ("sony_demod_atsc3_chbond_monitor_SelectedPLPValid");
if ((!pDemod) || (!plpValid)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if ((pDemod->system != SONY_DTV_SYSTEM_ATSC3) ||
((pDemod->chbondConfig != SONY_DEMOD_CHBOND_CONFIG_ATSC3_MAIN) &&
(pDemod->chbondConfig != SONY_DEMOD_CHBOND_CONFIG_ATSC3_SUB))) {
/* Not ATSC 3.0 or channel boding is not enabled */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Set SLV-T Bank : 0x93 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x93) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/*
* slave Bank Addr Bit Signal name
* --------------------------------------------------------------
* <SLV-T> 93h 10h [1] IL1D_OK
* <SLV-T> 93h 9Dh [0] IPLPINFO_RDY
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x10, data, 1) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (!(data[0] & 0x02)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x9D, data, 1) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (!(data[0] & 0x01)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* slave Bank Addr Bit default Value Name
* ----------------------------------------------------------------------------------
* <SLV-T> 93h 80h [7:0] 8'h00 8'hxx OREGD_PLP_ID_0_VALID,OREGD_PLP_ID_0_CHBVALID,OREGD_PLP_ID_0[5:0]
* <SLV-T> 93h 81h [7:0] 8'h00 8'hxx OREGD_PLP_ID_1_VALID,OREGD_PLP_ID_1_CHBVALID,OREGD_PLP_ID_1[5:0]
* <SLV-T> 93h 82h [7:0] 8'h00 8'hxx OREGD_PLP_ID_2_VALID,OREGD_PLP_ID_2_CHBVALID,OREGD_PLP_ID_2[5:0]
* <SLV-T> 93h 83h [7:0] 8'h00 8'hxx OREGD_PLP_ID_3_VALID,OREGD_PLP_ID_3_CHBVALID,OREGD_PLP_ID_3[5:0]
* <SLV-T> 93h 84h [0] IPLP_SEL_ERR
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x80, data, 5) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
for (i = 0; i < 4; i++) {
plpIdValid[i] = (data[i] >> 7) & 0x01;
chBondValid[i] = (data[i] >> 6) & 0x01;
selectedPlpId[i] = data[i] & 0x3F;
}
/* Set SLV-T Bank : 0x03 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x03) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* slave Bank Addr Bit default Value Name
* ----------------------------------------------------------------------------------
* <SLV-T> 03h B2h [0] 8'h00 8'hxx OREG_BCHBOND0_ON
* <SLV-T> 03h B3h [0] 8'h00 8'hxx OREG_BCHBOND1_ON
* <SLV-T> 03h B4h [0] 8'h00 8'hxx OREG_BCHBOND2_ON
* <SLV-T> 03h B5h [0] 8'h00 8'hxx OREG_BCHBOND3_ON
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xB2, chBondOn, 4) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
for (i = 0; i < 4; i++) {
uint8_t index = (plpIdValid[i] << 2) + (chBondValid[i] << 1) + (chBondOn[i] & 0x01);
uint8_t isSub = pDemod->chbondConfig == SONY_DEMOD_CHBOND_CONFIG_ATSC3_MAIN ? 0 : 1;
if (plpConfigCheckTable[index][isSub] == -1) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_OTHER);
} else {
plpValid[i] = (sony_demod_atsc3_chbond_plp_valid_t)plpConfigCheckTable[index][isSub];
}
}
if (data[4] & 0x01) {
/* PLP IDs are invalid */
for (i = 0; i < 4; i++) {
if (plpValid[i] == SONY_DEMOD_ATSC3_CHBOND_PLP_VALID_OK) {
plpValid[i] = SONY_DEMOD_ATSC3_CHBOND_PLP_VALID_ERR_ID;
}
}
} else {
/* PLP IDs are valid */
sony_atsc3_plp_list_entry_t plpList[SONY_ATSC3_NUM_PLP_MAX];
uint8_t numPLP;
/* Check that channel bonding configurations for each PLP are correct or not */
result = sony_demod_atsc3_monitor_PLPList (pDemod, plpList, &numPLP);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
for (i = 0; i < 4; i++) {
if (plpValid[i] == SONY_DEMOD_ATSC3_CHBOND_PLP_VALID_OK) {
for (j = 0; j < numPLP; j++) {
if (selectedPlpId[i] == plpList[j].id) {
if ((chBondOn[i] & 0x01) != plpList[j].chbond) {
plpValid[i] = SONY_DEMOD_ATSC3_CHBOND_PLP_VALID_ERR_BONDCONF;
}
break;
}
}
}
}
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc3_chbond_monitor_L1Detail (sony_demod_t * pDemod,
sony_atsc3_chbond_l1detail_t * pL1Detail)
{
uint8_t data[5];
SONY_TRACE_ENTER ("sony_demod_atsc3_chbond_monitor_L1Detail");
if ((!pDemod) || (!pL1Detail)) {
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_ATSC3) {
/* Not ATSC 3.0 */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Freeze registers */
if (SLVT_FreezeReg (pDemod) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set SLV-T Bank : 0x93 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x93) != SONY_RESULT_OK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN(SONY_RESULT_ERROR_I2C);
}
/*
* slave Bank Addr Bit Signal name
* --------------------------------------------------------------
* <SLV-T> 93h 10h [1] IL1D_OK
* <SLV-T> 93h 9Dh [0] IPLPINFO_RDY
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x10, data, 1) != SONY_RESULT_OK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (!(data[0] & 0x02)) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x9D, data, 1) != SONY_RESULT_OK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (!(data[0] & 0x01)) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/*
* slave Bank Addr Bit Name
* --------------------------------------------------------
* <SLV-T> 93h C0h [2:0] IL1D_NUM_RF[2:0]
* <SLV-T> 93h C1h [7:0] IL1D_BONDED_BSID[15:8]
* <SLV-T> 93h C2h [7:0] IL1D_BONDED_BSID[7:0]
* <SLV-T> 93h C3h [7:0] IL1D_BSID[15:8]
* <SLV-T> 93h C4h [7:0] IL1D_BSID[7:0]
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xC0, data, 5) != SONY_RESULT_OK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SLVT_UnFreezeReg (pDemod);
pL1Detail->num_rf = data[0] & 0x07;
if (pL1Detail->num_rf == 0) {
pL1Detail->bonded_bsid = 0;
pL1Detail->bsid = 0;
} else {
pL1Detail->bonded_bsid = (data[1] << 8) | data[2];
pL1Detail->bsid = (data[3] << 8) | data[4];
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
+130
View File
@@ -0,0 +1,130 @@
/*------------------------------------------------------------------------------
Copyright 2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/09/28
Modification ID : 1ea04def104d657deb64f0d0b0cae6ef992a9dd8
------------------------------------------------------------------------------*/
/**
@file sony_demod_atsc3_chbond.h
This file provides the demodulator control and monitor interface for ATSC 3.0 channel bonding.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_ATSC3_CHBOND_H
#define SONY_DEMOD_ATSC3_CHBOND_H
#include "../sony_demod.h"
#include "sony_atsc3_chbond.h"
/*------------------------------------------------------------------------------
Enumurations
------------------------------------------------------------------------------*/
/**
@brief PLP channel bonding configuration.
*/
typedef enum {
SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE, /**< PLP bonding enable */
SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_FROM_MAIN, /**< PLP bonding disable (from main only) */
SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_FROM_SUB /**< PLP bonding disable (from sub only) */
} sony_demod_atsc3_chbond_plp_bond_t;
/**
@brief PLP channel bonding configuration check status.
*/
typedef enum {
SONY_DEMOD_ATSC3_CHBOND_PLP_VALID_UNUSED, /**< The PLP ID is not used */
SONY_DEMOD_ATSC3_CHBOND_PLP_VALID_FROM_SUB, /**< The PLP is configured as input from sub IC */
SONY_DEMOD_ATSC3_CHBOND_PLP_VALID_ERR_ID, /**< One or more PLP IDs are not found */
SONY_DEMOD_ATSC3_CHBOND_PLP_VALID_ERR_BONDCONF, /**< PLP bond configuration is incorrect */
SONY_DEMOD_ATSC3_CHBOND_PLP_VALID_OK /**< PLP ID configuration is no problem */
} sony_demod_atsc3_chbond_plp_valid_t;
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Enable/disable ATSC 3.0 channel bonding function.
This API is called internally to enable/disable channel bonding.
@param pDemod The demodulator instance
@param enable Enable/disable setting.
- 0: Disable
- 1: Enable
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc3_chbond_Enable (sony_demod_t * pDemod,
uint8_t enable);
/**
@brief Setup the PLP configuration of the demodulator for channel bonding case.
@param pDemod The demodulator instance.
@param plpIDNum Number of valid PLP ID in plpID[]. (1 - 4)
@param plpID The pointer of PLP ID 4 length array to set.
@param plpBond The pointer of PLP bond option 4 length array to set.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc3_chbond_SetPLPConfig (sony_demod_t * pDemod,
uint8_t plpIDNum,
uint8_t plpID[4],
sony_demod_atsc3_chbond_plp_bond_t plpBond[4]);
/**
@brief Monitors the synchronisation state of the ATSC 3.0 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 basically.
@param pDemod The demodulator instance.
@param bondLockStat Pointer of 4 length array to store ALP lock status for each PLPs.
- 0: Bonding not locked.
- 1: Bonding locked.
@param pBondLockAll Indicates all selected valid PLPs by ::sony_demod_atsc3_chbond_SetPLPConfig are bonding locked or not.
- 0: Not all PLPs are locked.
- 1: All PLPs are locked.
@param pBondUnlockDetected Indicates the channel bonding unlock is detected.
- 0: No unlock.
- 1: Unlock detected.
@return SONY_RESULT_OK if pSyncStat, pTSLockStat is valid, otherwise an error is returned.
*/
sony_result_t sony_demod_atsc3_chbond_monitor_BondStat (sony_demod_t * pDemod,
uint8_t bondLockStat[4],
uint8_t * pBondLockAll,
uint8_t * pBondUnlockDetected);
/**
@brief Monitor the selected 4 PLPs are valid or not.
This API can check that the wrong channel bonding setting for each PLPs.
For example, the PLP is "channel bonded" but tuned as normal PLP.
Note that the tune APIs can finish successfully even if such wrong setting was done.
@param pDemod The demodulator instance.
@param plpValid Pointer of 4 length array to store PLP valid information for each PLPs.
See ::sony_demod_atsc3_chbond_plp_valid_t definition.
@return SONY_RESULT_OK if successful.
SONY_RESULT_ERROR_HW_STATE if all 4 PLPs are invalid.
*/
sony_result_t sony_demod_atsc3_chbond_monitor_SelectedPLPValid (sony_demod_t * pDemod,
sony_demod_atsc3_chbond_plp_valid_t plpValid[4]);
/**
@brief Get channel bonding related information in L1-Detail.
@param pDemod The demodulator instance.
@param pL1Detail Pointer to receive the channel bonding related L1-Detail information.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc3_chbond_monitor_L1Detail (sony_demod_t * pDemod,
sony_atsc3_chbond_l1detail_t * pL1Detail);
#endif /* SONY_DEMOD_ATSC3_CHBOND_H */
Binary file not shown.
File diff suppressed because it is too large Load Diff
+416
View File
@@ -0,0 +1,416 @@
/*------------------------------------------------------------------------------
Copyright 2018-2020 Sony Semiconductor Solutions Corporation
Last Updated : 2020/11/25
Modification ID : f08108eb7355363ac9e3ef592cba6f75731a51b6
------------------------------------------------------------------------------*/
/**
@file sony_demod_atsc3_monitor.h
This file provides the ATSC 3.0 demodulator monitor interface.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_ATSC3_MONITOR_H
#define SONY_DEMOD_ATSC3_MONITOR_H
#include "../sony_demod.h"
#include "sony_atsc3.h"
/*------------------------------------------------------------------------------
Defines
------------------------------------------------------------------------------*/
#define SONY_DEMOD_ATSC3_MONITOR_PRELDPCBER_INVALID 0xFFFFFFFF /**< BER value if the BER value is invalid */
#define SONY_DEMOD_ATSC3_MONITOR_PREBCHBER_INVALID 0xFFFFFFFF /**< BER value if the BER value is invalid */
#define SONY_DEMOD_ATSC3_MONITOR_POSTBCHFER_INVALID 0xFFFFFFFF /**< FER value if the FER value is invalid */
#define SONY_DEMOD_ATSC3_MONITOR_ALPHEADERLENGTHERROR_INVALID 0xFF /**< ALP header length error value is invalid. */
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Monitors the synchronisation state of the ATSC 3.0 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 basically.
@param pDemod The demodulator instance.
@param pSyncStat The demodulator state.
- 0: WAIT_GO,
- 1: WAIT_AGC,
- 2: WAIT_BSDET,
- 3: WAIT_L1Basic,
- 4: WAIT_L1Detail,
- 5: WAIT_DMD_OK,
- 6: DMD_OK
@param alpLockStat Pointer of 4 length array to store ALP lock status for each PLPs.
- 0: ALP not locked.
- 1: ALP locked.
@param pALPLockAll Indicates all selected PLPs by ::sony_demod_atsc3_SetPLPConfig are locked or not.
- 0: Not all PLPs are locked.
- 1: All PLPs are locked.
@param pUnlockDetected Indicates the early unlock condition.
- 0: No early unlock.
- 1: Early unlock.
@return SONY_RESULT_OK if pSyncStat, pTSLockStat is valid, otherwise an error is returned.
*/
sony_result_t sony_demod_atsc3_monitor_SyncStat (sony_demod_t * pDemod,
uint8_t * pSyncStat,
uint8_t alpLockStat[4],
uint8_t * pALPLockAll,
uint8_t * pUnlockDetected);
/**
@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 The detected carrier offset in Hz.
@return SONY_RESULT_OK if pOffset is valid.
*/
sony_result_t sony_demod_atsc3_monitor_CarrierOffset (sony_demod_t * pDemod,
int32_t * pOffset);
/**
@brief Monitor the IFAGC value of the ATSC 3.0 demodulator.
Actual dB gain dependent on attached tuner.
@param pDemod The demodulator instance.
@param pIFAGC The IFAGC output register value. Range 0 - 0xFFF. Unitless.
@return SONY_RESULT_OK if pIFAGC is valid.
*/
sony_result_t sony_demod_atsc3_monitor_IFAGCOut (sony_demod_t * pDemod,
uint32_t * pIFAGC);
/**
@brief Monitor the Bootstrap data.
@param pDemod The demodulator instance.
@param pBootstrap The bootstrap data monitored.
@return SONY_RESULT_OK if successful and pBootstrap is valid.
*/
sony_result_t sony_demod_atsc3_monitor_Bootstrap (sony_demod_t * pDemod,
sony_atsc3_bootstrap_t * pBootstrap);
/**
@brief Monitor the demodulator information on the active channel.
These parameters are basically come from L1, but currently used by demodulator circuit.
@param pDemod The demodulator instance.
@param pOfdm Pointer to receive the tuning information.
@return SONY_RESULT_OK if the pPresetInfo is valid.
*/
sony_result_t sony_demod_atsc3_monitor_OFDM (sony_demod_t * pDemod,
sony_atsc3_ofdm_t * pOfdm);
/**
@brief Monitor the L1-Basic information.
@param pDemod The demodulator instance.
@param pL1Basic Pointer to receive the L1-Basic information.
@return SONY_RESULT_OK if the pL1Basic is valid.
*/
sony_result_t sony_demod_atsc3_monitor_L1Basic (sony_demod_t * pDemod,
sony_atsc3_l1basic_t * pL1Basic);
/**
@brief Monitor the L1-Basic and L1-Detail raw information.
This API read both L1-Basic and L1-Detail at the same time
because several L1-Detail members depend on L1-Basic information.
Note that this API may read many data by I2C. (depend on L1-Detail)
L1-Detail information read by this API is "raw" data.
To format it, please use sony_demod_atsc3_monitor_L1Detail_convert.
@param pDemod The demodulator instance.
@param pL1Basic Pointer to receive the L1-Basic information.
@param pL1Detail Pointer to receive the L1-Detail information raw data.
@return SONY_RESULT_OK if the pPresetInfo is valid.
*/
sony_result_t sony_demod_atsc3_monitor_L1Detail_raw (sony_demod_t * pDemod,
sony_atsc3_l1basic_t * pL1Basic,
sony_atsc3_l1detail_raw_t * pL1Detail);
/**
@brief Format L1-Detail information.
This API do not read new L1-Basic, L1-Detail information from the demod,
simply format L1-Detail raw information to structs,
sony_atsc3_l1detail_common_t, sony_atsc3_l1detail_subframe_t, sony_atsc3_l1detail_plp_t.
Note that if the specified PLP mapped to multiple subframes,
this API shows firstly found information related to the PLP.
@param pDemod The demodulator instance.
@param pL1Basic Pointer to receive the L1-Basic information.
@param pL1Detail Pointer to receive the L1-Detail information raw data.
@param plpID Target PLP ID to be read.
@param pL1DetailCommon Formatted L1-Detail information. (common part)
@param pL1DetailSubframe Formatted L1-Detail information. (subframe dependent part)
@param pL1DetailPlp Formatted L1-Detail information. (PLP dependent part)
@return SONY_RESULT_OK if the pPresetInfo is valid.
*/
sony_result_t sony_demod_atsc3_monitor_L1Detail_convert (sony_demod_t * pDemod,
sony_atsc3_l1basic_t * pL1Basic,
sony_atsc3_l1detail_raw_t * pL1Detail,
uint8_t plpID,
sony_atsc3_l1detail_common_t * pL1DetailCommon,
sony_atsc3_l1detail_subframe_t * pL1DetailSubframe,
sony_atsc3_l1detail_plp_t * pL1DetailPlp);
/**
@brief Monitor the PLP list in current RF channel.
@param pDemod The demodulator instance.
@param plpList Pointer to an array of sony_atsc3_plp_list_entry_t
that can receive the list of PLPs carried. (max length is 64)
This parameter can be NULL. If so, number of PLP is only returned.
@param pNumPLPs The number of PLPs.
@return SONY_RESULT_OK if the pPLPList and pNumPLPs are valid.
*/
sony_result_t sony_demod_atsc3_monitor_PLPList (sony_demod_t * pDemod,
sony_atsc3_plp_list_entry_t plpList[SONY_ATSC3_NUM_PLP_MAX],
uint8_t * pNumPLPs);
/**
@brief Monitor the PLP error indicator.
A PLP error is indicated
when one of the selected PLP was not found in the channel.
@param pDemod The demodulator instance.
@param pPLPError The error indicated.
- 0: No data PLP error.
- 1: Data PLP error detected.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc3_monitor_PLPError (sony_demod_t * pDemod,
uint8_t * pPLPError);
/**
@brief Monitor the selected 4 PLPs are valid or not.
The demodulator can correct PLP ID for single PLP case.
If so, even if specified PLP ID is not correct, tune API can be success.
This function checks such case too.
This function is used internally in common.
@param pDemod The demodulator instance.
@param plpValid Pointer of 4 length array to store PLP valid information for each PLPs.
- 0: Selected PLP is invalid.
- 1: Selected PLP is valid.
@return SONY_RESULT_OK if successful.
SONY_RESULT_ERROR_HW_STATE if all 4 PLPs are invalid.
*/
sony_result_t sony_demod_atsc3_monitor_SelectedPLPValid (sony_demod_t * pDemod,
uint8_t plpValid[4]);
/**
@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_atsc3_monitor_SpectrumSense (sony_demod_t * pDemod,
sony_demod_terr_cable_spectrum_sense_t * pSense);
/**
@brief Monitor the SNR estimation made by the demodulator.
Clipped to a maximum of 40dB.
@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_atsc3_monitor_SNR (sony_demod_t * pDemod,
int32_t * pSNR);
/**
@brief Monitor the pre-LDPC BER.
This provides the BER for each (max 4) PLPs.
If plpID[N] is not specified in tune API,
ber[N] will become SONY_DEMOD_ATSC3_MONITOR_PRELDPCBER_INVALID.
@param pDemod The demodulator instance.
@param ber Pointer of 4 length array to store each PLP BER. BER x 1e7 value are returned.
@return SONY_RESULT_OK if the pBER is valid.
*/
sony_result_t sony_demod_atsc3_monitor_PreLDPCBER (sony_demod_t * pDemod,
uint32_t ber[4]);
/**
@brief Monitor the pre-BCH BER.
This provides the BER for each (max 4) PLPs.
If plpID[N] is not specified in tune API,
ber[N] will become SONY_DEMOD_ATSC3_MONITOR_PREBCHBER_INVALID.
Note that BER is supported depend on the PLP's FEC type.
- SONY_ATSC3_PLP_FEC_BCH_LDPC_16K : Supported
- SONY_ATSC3_PLP_FEC_BCH_LDPC_64K : Supported
- SONY_ATSC3_PLP_FEC_CRS_LDPC_16K : NOT supported
- SONY_ATSC3_PLP_FEC_CRS_LDPC_64K : NOT supported
- SONY_ATSC3_PLP_FEC_LDPC_16K : NOT supported
- SONY_ATSC3_PLP_FEC_LDPC_64K : NOT supported
If "NOT supported" cases, ber[N] will become SONY_DEMOD_ATSC3_MONITOR_PREBCHBER_INVALID.
@param pDemod The demodulator instance.
@param ber Pointer of 4 length array to store each PLP BER. BER x 1e9 value are returned.
@return SONY_RESULT_OK if pBER is valid.
*/
sony_result_t sony_demod_atsc3_monitor_PreBCHBER (sony_demod_t * pDemod,
uint32_t ber[4]);
/**
@brief Monitor the post BCH FER (FEC block error rate) parameters.
This provides the FER for each (max 4) PLPs.
If plpID[N] is not specified in tune API,
fer[N] will become SONY_DEMOD_ATSC3_MONITOR_POSTBCHFER_INVALID.
Regardless of PLP FEC type, this API can return estimated FER value.
@param pDemod The demod instance.
@param fer Pointer of 4 length array to store each PLP FER. FER x 1e6 value are returned.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc3_monitor_PostBCHFER (sony_demod_t * pDemod,
uint32_t fer[4]);
/**
@brief Monitor the Baseband Packet Error Number in 1 sec.
This provides the Packet Error Number for each (max 4) PLPs.
If plpID[N] is not specified in tune API,
pen[N] will become 0.
@param pDemod The demodulator instance.
@param pen Pointer of 4 length array to store each PLP Packet Error Number.
@return SONY_RESULT_OK if pPEN is valid.
*/
sony_result_t sony_demod_atsc3_monitor_BBPacketErrorNumber (sony_demod_t * pDemod,
uint32_t pen[4]);
/**
@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_atsc3_monitor_SamplingOffset (sony_demod_t * pDemod,
int32_t * pPPM);
/**
@brief Monitor the FEC type, Modulation, Code rate parameter for currently selected PLPs.
@param pDemod The demodulator instance.
@param fecmodcod Pointer of 4 length array to store each PLP parameters.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_atsc3_monitor_FecModCod (sony_demod_t * pDemod,
sony_atsc3_plp_fecmodcod_t fecmodcod[4]);
/**
@brief Monitor the ALP header length format error for each PLPs.
This provides the ALP header length error status for each (max 4) PLPs.
If plpID[N] is not specified in tune API,
errorStandard[N] and errorKorean[N] will become
SONY_DEMOD_ATSC3_MONITOR_ALPHEADERLENGTHERROR_INVALID (0xFF).
If FER > 0 for the PLP, ALP header length error monitor cannot return correct value.
Then errorStadard[N] and errorKorean[N] become
SONY_DEMOD_ATSC3_MONITOR_ALPHEADERLENGTHERROR_INVALID (0xFF).
@param pDemod The demodulator instance.
@param errorStandard Pointer of 4 length array to store each PLP ALP header length error status in standard mode.
@param errorKorean Pointer of 4 length array to store each PLP ALP header length error status in Korean mode.
@return SONY_RESULT_OK if errorStadard and errorKorean are valid.
*/
sony_result_t sony_demod_atsc3_monitor_ALPHeaderLengthError (sony_demod_t * pDemod,
uint8_t errorStandard[4],
uint8_t errorKorean[4]);
/**
@brief Monitor the averaged pre-BCH BER.
This provides the BER for each (max 4) PLPs.
If plpID[N] is not specified in tune API,
ber[N] will become SONY_DEMOD_ATSC3_MONITOR_PREBCHBER_INVALID.
Note that BER is supported depend on the PLP's FEC type.
- SONY_ATSC3_PLP_FEC_BCH_LDPC_16K : Supported
- SONY_ATSC3_PLP_FEC_BCH_LDPC_64K : Supported
- SONY_ATSC3_PLP_FEC_CRS_LDPC_16K : NOT supported
- SONY_ATSC3_PLP_FEC_CRS_LDPC_64K : NOT supported
- SONY_ATSC3_PLP_FEC_LDPC_16K : NOT supported
- SONY_ATSC3_PLP_FEC_LDPC_64K : NOT supported
If "NOT supported" cases, ber[N] will become SONY_DEMOD_ATSC3_MONITOR_PREBCHBER_INVALID.
@param pDemod The demodulator instance.
@param ber Pointer to array for storing each PLP BER. BER x 1e9 value are returned.
@return SONY_RESULT_OK if pBER is valid.
*/
sony_result_t sony_demod_atsc3_monitor_AveragedPreBCHBER (sony_demod_t * pDemod,
uint32_t ber[4]);
/**
@brief Monitor the estimated averaged SNR value.
Clipped to a maximum of 40dB.
@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_atsc3_monitor_AveragedSNR (sony_demod_t * pDemod,
int32_t * pSNR);
#endif /* SONY_DEMOD_ATSC3_MONITOR_H */
Binary file not shown.
+991
View File
@@ -0,0 +1,991 @@
/*------------------------------------------------------------------------------
Copyright 2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/12/13
Modification ID : e402a4dcb0e51a00c34b174334c082c1211eebf1
------------------------------------------------------------------------------*/
#include "sony_demod_atsc_monitor.h"
#include "../sony_math.h"
#include <string.h>
#include <stdlib.h>
/*------------------------------------------------------------------------------
Static Function Prototypes
------------------------------------------------------------------------------*/
static sony_result_t checkVQLock (sony_demod_t * pDemod);
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
sony_result_t sony_demod_atsc_monitor_SyncStat (sony_demod_t * pDemod,
uint8_t * pVQLockStat,
uint8_t * pAGCLockStat,
uint8_t * pTSLockStat,
uint8_t * pUnlockDetected)
{
SONY_TRACE_ENTER ("sony_demod_atsc_monitor_SyncStat");
if ((!pDemod) || (!pVQLockStat) || (!pAGCLockStat) || (!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_ATSC) {
/* Not ATSC */
SONY_TRACE_RETURN(SONY_RESULT_ERROR_SW_STATE);
}
{
uint8_t data;
/* Set SLV-M Bank : 0x0F */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x00, 0x0F) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* TS lock flag
* slave Bank Addr Bit Name Meaning
* -----------------------------------------------------------------------
* <SLV-M> 0Fh 11h [0] TSLOCK 0:UNLOCK, 1:LOCK
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x11, &data, 1) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
*pTSLockStat = (uint8_t)(data & 0x01);
/* Set SLV-M Bank : 0x09 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x00, 0x09) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* AGC lock flag / Early Unlock Flag
* slave Bank Addr Bit Name Meaning
* -----------------------------------------------------------------------
* <SLV-M> 09h 62h [4] DAGCA_LOCK 0:UNLOCK, 1:LOCK
* <SLV-M> 09h 62h [6] ISIGNAL_PRESENCE 0:not present, 1:present
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x62, &data, 1) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
*pAGCLockStat = (uint8_t)((data & 0x10) ? 1 : 0);
*pUnlockDetected = (uint8_t)((data & 0x40) ? 0 : 1);
/* Set SLV-M Bank : 0x0D */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x00, 0x0D) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* DMD lock flag
* slave Bank Addr Bit Name Meaning
* -----------------------------------------------------------------------
* <SLV-M> 0Dh 86h [0] VQLOCK 0:UNLOCK, 1:LOCK
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x86, &data, 1) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
*pVQLockStat = (uint8_t)(data & 0x01);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc_monitor_IFAGCOut (sony_demod_t * pDemod,
uint32_t * pIFAGCOut)
{
SONY_TRACE_ENTER ("sony_demod_atsc_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_ATSC) {
/* Not ATSC */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Set SLV-M Bank : 0x09 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x00, 0x09) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* IFAGC Output
* slave Bank Addr Bit Name
* ------------------------------------------------------------
* <SLV-M> 09h 63h [7:0] DAGCA_IFMON[7:0]
* <SLV-M> 09h 64h [5:0] DAGCA_IFMON[13:8]
*/
{
uint8_t data[2];
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x63, data, 2) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
*pIFAGCOut = ((uint32_t)(data[1] & 0x3F) << 8) | data[0];
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc_monitor_CarrierOffset (sony_demod_t * pDemod,
int32_t * pOffset)
{
SONY_TRACE_ENTER ("sony_demod_atsc_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_ATSC) {
/* Not ATSC */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* VQ Lock Check */
if (checkVQLock (pDemod) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* Set SLV-M Bank : 0x06 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x00, 0x06) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
{
uint8_t data[3];
int32_t freqError[2];
uint32_t ctlVal = 0;
/* slave Bank Addr Bit Name
* ------------------------------------------------------------
* <SLV-M> 06h F8h [7:0] dpt_lfacc[7:0]
* <SLV-M> 06h F9h [7:0] dpt_lfacc[15:8]
* <SLV-M> 06h FAh [3:0] dpt_lfacc[19:16]
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0xF8, data, 3) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
ctlVal = ((uint32_t)(data[2] & 0x0F) << 16) | ((uint32_t)data[1] << 8) | data[0];
freqError[0] = sony_Convert2SComplement (ctlVal, 20); /* dpt_lfacc values reported in two's complement format */
/* 8VSB:Frequency Error[0] [Hz] = dpt_lfacc * (2^-22) * 10.762238 * 10^6
* = dpt_lfacc * 2.565917492
* = dpt_lfacc * 1155 / 450
*/
freqError[0] *= 1155;
/* Set SLV-M Bank : 0x07 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x00, 0x07) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* slave Bank Addr Bit Name
* ------------------------------------------------------------
* <SLV-M> 07h 30h [7:0] dpt_ext_lfacc[7:0]
* <SLV-M> 07h 31h [7:0] dpt_ext_lfacc[15:8]
* <SLV-M> 07h 32h [3:0] dpt_ext_lfacc[19:16]
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x30, data, 3) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
ctlVal = ((uint32_t)(data[2] & 0x0F) << 16) | ((uint32_t)data[1] << 8) | data[0];
freqError[1] = sony_Convert2SComplement (ctlVal, 20); /* dpt_ext_lfacc values reported in two's complement format */
/* Frequency Error[1] [Hz] = dpt_ext_lfacc * (2^-23) * 48 * 10^6
* = dpt_ext_lfacc * 5.7220458984375
* = dpt_ext_lfacc * 3125 / 546
*/
freqError[1] *= 3125;
if ((freqError[0] + freqError[1]) >= 0) {
*pOffset = - ((freqError[0] + freqError[1] + 273) / 546);
} else {
*pOffset = - ((freqError[0] + freqError[1] - 273) / 546);
}
/* Compensate for inverted spectrum. */
if (pDemod->rfSpectrumSense == SONY_DEMOD_TERR_CABLE_SPECTRUM_INV) {
*pOffset *= -1;
}
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc_monitor_PreRSBER (sony_demod_t * pDemod,
uint32_t * pBER)
{
SONY_TRACE_ENTER ("sony_demod_atsc_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_ATSC) {
/* Not ATSC */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* VQ Lock Check */
if (checkVQLock (pDemod) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* Set SLV-M Bank : 0x0D */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x00, 0x0D) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
{
uint8_t data[3];
uint32_t bitError = 0;
uint32_t blocks = 0;
uint16_t bitPerBlock = 0;
uint8_t ecntEn = 0;
uint8_t overFlow = 1;
/* Before RS BER Monitor
* slave Bank Addr Bit Name
* ------------------------------------------------------------
* <SLV-M> 0Dh 90h [7:0] RSERRA_BIERR[7:0]
* <SLV-M> 0Dh 91h [7:0] RSERRA_BIERR[15:8]
* <SLV-M> 0Dh 92h [4:0] RSERRA_BIERR[20:16]
* <SLV-M> 0Dh 92h [5] RSERRA_ECNTEN
* <SLV-M> 0Dh 92h [6] RSERRA_OVF
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x90, data, 3) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
ecntEn = (uint8_t)((data[2] & 0x20) ? 1 : 0);
overFlow = (uint8_t)((data[2] & 0x40) ? 1 : 0);
bitError =((uint32_t)(data[2] & 0x1F) << 16) | ((uint32_t)(data[1] & 0xFF) << 8) | data[0];
if (overFlow){
*pBER = 10000000;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
if(!ecntEn){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* Set SLV-M Bank : 0x0D */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x00, 0x0D) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* 8VSB: 1 Block = 207 Symbol * 8 Bit/Symbol */
bitPerBlock = 207 * 8;
/* 8VSB Measurement Block Length
* slave Bank Addr Bit Name
* ------------------------------------------------------------
* <SLV-M> 0Dh 9Ah [7:0] IRSERRA_BKLEN[7:0]
* <SLV-M> 0Dh 9Bh [7:0] IRSERRA_BKLEN[15:8]
* <SLV-M> 0Dh 9Ch [7:0] IRSERRA_BKLEN[23:16]
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x9A, data, 3) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
blocks = ((uint32_t)(data[2] & 0xFF) << 16) | ((uint32_t)(data[1] & 0xFF) << 8) | data[0] ;
/* Check value of the blocks is valid */
if ((blocks == 0) || (blocks < (bitError / bitPerBlock))){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* Case value of the blocks is not so large */
if (blocks < 0xFFFFF){
/*
* BER = bitError * 10000000 / (blocks * bitPerBlock)
* = bitError * 1000 * 5 * 5 * 5 * 10 /(blocks * (bitPerBlock / 8))
* (Divide in 5 steps to prevent overflow.)
*/
uint32_t Q = 0;
uint32_t R = 0;
uint32_t Div = blocks * (bitPerBlock / 8);
Q = (bitError * 1000) / Div;
R = (bitError * 1000) % Div;
R *= 5;
Q = (Q * 5) + (R / Div);
R = R % Div;
R *= 5;
Q = (Q * 5) + (R / Div);
R = R % Div;
R *= 5;
Q = (Q * 5) + (R / Div);
R = R % Div;
R *= 10;
Q = (Q * 10) + (R / Div);
R = R % Div;
/* rounding */
if (R <= (Div/2)) {
*pBER = Q;
}
else {
*pBER = Q + 1;
}
}
else {
/*
* BER = bitError * 10000000 / (blocks * bitPerBlock)
* = bitError * 625 * 5 * 5 * 5 /((blocks * (bitPerBlock / 8)) / 16)
* (Divide in 4 steps to prevent overflow.)
*/
uint32_t Q = 0;
uint32_t R = 0;
uint32_t Div = (blocks * (bitPerBlock / 8)) / 16;
Q = (bitError * 625) / Div;
R = (bitError * 625) % Div;
R *= 5;
Q = (Q * 5) + (R / Div);
R = R % Div;
R *= 5;
Q = (Q * 5) + (R / Div);
R = R % Div;
R *= 5;
Q = (Q * 5) + (R / Div);
R = R % Div;
/* rounding */
if (R <= (Div/2)) {
*pBER = Q;
}
else {
*pBER = Q + 1;
}
}
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc_monitor_PreRSSER (sony_demod_t * pDemod,
uint32_t * pSER)
{
SONY_TRACE_ENTER ("sony_demod_atsc_monitor_PreRSSER");
if ((!pDemod) || (!pSER)) {
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_ATSC) {
/* Not ATSC */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* VQ Lock Check */
if (checkVQLock (pDemod) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* Set SLV-M Bank : 0x0D */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x00, 0x0D) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
{
uint8_t data[3];
uint32_t symbolError = 0;
uint32_t symbolPerBlock = 0;
uint32_t blocks = 0;
uint8_t ecntEn = 0;
uint8_t overFlow = 1;
/* Before RS SER Monitor
* slave Bank Addr Bit Name
* ------------------------------------------------------------
* <SLV-M> 0Dh 93h [7:0] RSERRA_SYERR[7:0]
* <SLV-M> 0Dh 94h [7:0] RSERRA_SYERR[15:8]
* <SLV-M> 0Dh 95h [1:0] RSERRA_SYERR[17:16]
* <SLV-M> 0Dh 95h [2] RSERRA_ECNTEN
* <SLV-M> 0Dh 95h [3] RSERRA_OVF
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x93, data, 3) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
ecntEn = (uint8_t) ((data[2] & 0x04) ? 1 : 0);
overFlow = (uint8_t) ((data[2] & 0x08) ? 1 : 0);
symbolError = ((uint32_t)(data[2] & 0x03) << 16) | ((uint32_t)(data[1] & 0xFF) << 8) | data[0];
if (overFlow){
*pSER = 10000000;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
if (!ecntEn){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* 8VSB: 1 Block = 207 Symbol */
symbolPerBlock = 207;
/* 8VSB Measurement Block Length
* slave Bank Addr Bit Name
* ------------------------------------------------------------
* <SLV-M> 0Dh 9Ah [7:0] IRSERRA_BKLEN[7:0]
* <SLV-M> 0Dh 9Bh [7:0] IRSERRA_BKLEN[15:8]
* <SLV-M> 0Dh 9Ch [7:0] IRSERRA_BKLEN[23:16]
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x9A, data, 3) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
blocks = ((uint32_t)(data[2] & 0xFF) << 16) | ((uint32_t)(data[1] & 0xFF) << 8) | data[0];
/* Check value of the blocks is valid */
if ((blocks == 0) || (blocks < (symbolError / symbolPerBlock))){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* Case value of the blocks is not so large */
if (blocks < 0xFFFFF){
/*
* SER = symbolError * 10000000 / (blocks * symbolPerBlock)
* = symbolError * 10000 * 10 * 10 * 10 / (blocks * symbolPerBlock)
* (Divide in 4 steps to prevent overflow.)
*/
uint32_t Q = 0;
uint32_t R = 0;
uint32_t Div = blocks * symbolPerBlock;
Q = (symbolError * 10000) / Div;
R = (symbolError * 10000) % Div;
R *= 10;
Q = (Q * 10) + (R / Div);
R = R % Div;
R *= 10;
Q = (Q * 10) + (R / Div);
R = R % Div;
R *= 10;
Q = (Q * 10) + (R / Div);
R = R % Div;
/* rounding */
if (R <= (Div/2)) {
*pSER = Q;
}
else {
*pSER = Q + 1;
}
}
else {
/*
* SER = symbolError * 10000000 / (blocks * symbolPerBlock)
* = symbolError * 10000 * 5 * 5 * 5 / (blocks * symbolPerBlock / 8)
* (Divide in 4 steps to prevent overflow.)
*/
uint32_t Q = 0;
uint32_t R = 0;
uint32_t Div = (blocks * symbolPerBlock) / 8;
Q = (symbolError * 10000) / Div;
R = (symbolError * 10000) % Div;
R *= 5;
Q = (Q * 5) + (R / Div);
R = R % Div;
R *= 5;
Q = (Q * 5) + (R / Div);
R = R % Div;
R *= 5;
Q = (Q * 5) + (R / Div);
R = R % Div;
/* rounding */
if (R <= (Div/2)) {
*pSER = Q;
}
else {
*pSER = Q + 1;
}
}
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc_monitor_PostRSWER (sony_demod_t * pDemod,
uint32_t * pWER)
{
SONY_TRACE_ENTER ("sony_demod_atsc_monitor_PostRSWER");
if ((!pDemod) || (!pWER)) {
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_ATSC) {
/* Not ATSC */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* VQ Lock Check */
if (checkVQLock (pDemod) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* Set SLV-M Bank : 0x0D */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x00, 0x0D) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
{
uint8_t data[3];
uint32_t wordError = 0;
uint32_t blocks = 0;
uint8_t ecntEn = 0;
uint8_t overFlow = 1;
/* After RS WER Monitor
* slave Bank Addr Bit Name
* ------------------------------------------------------------
* <SLV-M> 0Dh 96h [7:0] RSERRA_BKERR[7:0]
* <SLV-M> 0Dh 97h [5:0] RSERRA_BKERR[13:8]
* <SLV-M> 0Dh 97h [6] RSERRA_ECNTEN
* <SLV-M> 0Dh 97h [7] RSERRA_OVF
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x96, data, 2) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
ecntEn = (uint8_t)((data[1] & 0x40) ? 1 : 0);
overFlow = (uint8_t)((data[1] & 0x80) ? 1 : 0);
wordError = ((uint32_t)(data[1] & 0x3F) << 8) | data[0];
if (overFlow){
*pWER = 1000000;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
if (!ecntEn){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* 8VSB Measurement Block Length
* slave Bank Addr Bit Name
* ------------------------------------------------------------
* <SLV-M> 0Dh 9Ah [7:0] IRSERRA_BKLEN[7:0]
* <SLV-M> 0Dh 9Bh [7:0] IRSERRA_BKLEN[15:8]
* <SLV-M> 0Dh 9Ch [7:0] IRSERRA_BKLEN[23:16]
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x9A, data, 3) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
blocks = ((uint32_t)(data[2] & 0xFF) << 16) | ((uint32_t)(data[1] & 0xFF) << 8) | data[0];
/* Check value of the blocks is valid */
if (( blocks == 0) || (blocks < wordError)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* Case value of the blocks is not so large */
if (blocks < 0xFFF ){
*pWER = wordError * 1000000 / blocks; /* wordError must be smaller than blocks, then this calcuation will not be overflow */
}
else {
/*
* WER = wordError * 1000000 / blocks
* = wordError * 100000 * 10 / blocks
* (Divide in 2 steps to prevent overflow.)
*/
{
uint32_t Q = 0;
uint32_t R = 0;
uint32_t Div = blocks;
Q = (wordError * 100000) / Div;
R = (wordError * 100000) % Div;
R *= 10;
Q = (Q * 10) + (R / Div);
R = R % Div;
/* rounding */
if (R <= (Div/2)) {
*pWER = Q;
}
else {
*pWER = Q + 1;
}
}
}
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc_monitor_PacketError (sony_demod_t * pDemod,
uint8_t * pPacketErrorDetected)
{
uint8_t data = 0;
SONY_TRACE_ENTER ("sony_demod_atsc_monitor_PacketError");
if ((!pDemod) || (!pPacketErrorDetected)) {
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_ATSC) {
/* Not ATSC */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* VQ Lock Check */
if (checkVQLock (pDemod) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* Set SLV-M Bank : 0x0D */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x00, 0x0D) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Packet Error Monitor
* slave Bank Addr Bit Name
* ------------------------------------------------------------
* <SLV-M> 0Dh 82h [0] IERR
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x82, &data, 1) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
*pPacketErrorDetected = (uint8_t)((data & 0x01) ? 1 : 0);
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc_monitor_SNR (sony_demod_t * pDemod,
int32_t * pSNR)
{
uint8_t data[3];
uint32_t dcl_avgerr_fine;
SONY_TRACE_ENTER ("sony_demod_atsc_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_ATSC) {
/* Not ATSC */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* VQ Lock Check */
if (checkVQLock (pDemod) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* Set SLV-M Bank : 0x0D */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x00, 0x0D) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* SNR Monitor
* slave Bank Addr Bit Name
* -------------------------------------------------
* <SLV-M> 0Dh 70h [7:0] dcl_avgerr_fine[7:0]
* <SLV-M> 0Dh 71h [7:0] dcl_avgerr_fine[15:8]
* <SLV-M> 0Dh 72h [6:0] dcl_avgerr_fine[22:16]
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x70, data, 3) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
dcl_avgerr_fine = ((uint32_t)(data[2] & 0x7F) << 16) | ((uint32_t)(data[1] & 0xFF) << 8) | data[0];
/* sony_log10 returns log10(x) * 100
* 8VSB: SNR[mdB] = 1000 * 10(log10( 21*8*8 / (dcl_avgerr_fine * 2^-13) ))
* = 10000 * log10( 21*2^19 / dcl_avgerr_fine )
* = 10000 * ( log10(21) + 19log10(2) -log10(dcl_avgerr_fine))
* = 70418 - 100 * sony_log10(dcl_avgerr_fine)
*/
*pSNR = (int32_t)(70418 - (100 * sony_math_log10(dcl_avgerr_fine)));
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc_monitor_SamplingOffset (sony_demod_t * pDemod,
int32_t * pPPM)
{
uint8_t data[6];
uint32_t dtrLfaccHigh;
uint32_t dtrLfaccLow;
int32_t dtrlfacc;
SONY_TRACE_ENTER ("sony_demod_atsc_monitor_SamplingOffset");
if ((!pDemod) || (!pPPM)) {
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_ATSC) {
/* Not ATSC */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* VQ Lock Check */
if (checkVQLock (pDemod) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* Set SLV-M Bank : 0x06 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x00, 0x06) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Symbol Rate
* slave Bank Addr Bit Name
* -------------------------------------------------
* <SLV-M> 06h 17h [7:0] dtr_lfacc[7:0]
* <SLV-M> 06h 18h [7:0] dtr_lfacc[15:8]
* <SLV-M> 06h 19h [7:0] dtr_lfacc[23:16]
* <SLV-M> 06h 1Ah [7:0] dtr_lfacc[31:24]
* <SLV-M> 06h 1Bh [7:0] dtr_lfacc[39:32]
* <SLV-M> 06h 1Ch [3:0] dtr_lfacc[43:40]
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x17, data, 6) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
dtrLfaccLow = ((uint32_t)(data[3] & 0xFF) << 24) | ((uint32_t)(data[2] & 0xFF) << 16) | ((uint32_t)(data[1] & 0xFF) << 8) | data[0];
dtrLfaccHigh = ((uint32_t)(data[5] & 0x0F) << 8) | data[4];
/* Symbol Rate Detector Result can be calculated with the following formula.
* Detected SymbolRate[sps] = 48 / 2 / {2 * {dtr_lfacc/(2^43) + 1}} * 10^6
* =(4800 * 10^4 * 2^41) / (dtr_lfacc + 2^43)
* 18bit Shift
* ->(4800 * 10^4 * 2^23) / (dtr_lfacc/2^18 + 2^25)
*/
/* Round off LSB 18 bit and 2's Complement */
dtrlfacc = sony_Convert2SComplement (((dtrLfaccHigh & 0xFFF) << 14) | (dtrLfaccLow >> 18), 26);
if (dtrlfacc < 0){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
{
uint32_t Q = 0;
uint32_t R = 0;
uint32_t Div = 0;
int32_t symbolRateOffset = 0;
int8_t flgNegative = 1;
/* 8VSB: Detected SymbolRate[sps] = (4800 * 10^4 * 2^23) / (dtr_lfacc/2^18 + 2^25)
* = (4800 * 10000 * 64) * 64 * 64 * 32 / (dtr_lfacc/2^18 + 0x2000000)
* (Divide in 4 steps to prevent overflow.)
*/
Div = ((uint32_t)dtrlfacc + 0x2000000);
Q = (4800U * 10000U * 64U) / Div;
R = (4800U * 10000U * 64U) % Div;
R *= 64;
Q = (Q * 64) + (R / Div);
R = R % Div;
R *= 64;
Q = (Q * 64) + (R / Div);
R = R % Div;
R *= 32;
Q = (Q * 32) + (R / Div);
R = R % Div;
/* rounding and comparing with the standard symbol rate
* 8VSB: SymbolRateOffset[sps] = (10.762238 * 10^6 - Detected Symbol Rate)
*/
if (R <= (Div/2)) {
symbolRateOffset = (int32_t)(10762238 - Q);
}
else {
symbolRateOffset = (int32_t)(10762238 - (Q + 1));
}
/* Negative Value Check */
if (symbolRateOffset < 0) {
flgNegative = -1;
symbolRateOffset *= flgNegative;
}
/* SamplingOffset[ppm] = Symbol Rate Offset / 10.762238
* SamplingOffset * 100 = Symbol Rate Offset * 100 / 10.762238
* = Symbol Rate Offset * 10^8 / 10762238
* = Symbol Rate Offset * 500 * 500 * 200 / (10762238 / 2)
* (Divide in 4 steps to prevent overflow.)
*/
Div = 5381119;
Q = (uint32_t)symbolRateOffset / Div;
R = (uint32_t)symbolRateOffset % Div;
R *= 500;
Q = (Q * 500) + (R / Div);
R = R % Div;
R *= 500;
Q = (Q * 500) + (R / Div);
R = R % Div;
R *= 200;
Q = (Q * 200) + (R / Div);
R = R % Div;
if (R <= (Div/2)) {
*pPPM = flgNegative * (int32_t) Q;
} else {
*pPPM = flgNegative * (int32_t)(Q + 1);
}
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc_monitor_SignalLevelData_ForUnlockOptimization (sony_demod_t * pDemod,
uint32_t * pSignalLevelData)
{
uint8_t data[3];
SONY_TRACE_ENTER ("sony_demod_atsc_monitor_SignalLevelData_ForUnlockOptimization");
if ((!pDemod) || (!pSignalLevelData)) {
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_ATSC) {
/* Not ATSC */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Set SLV-M Bank : 0x09 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x00, 0x09) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* IFAGC Output
* slave Bank Addr Bit Name
* ---------------------------------------------------------------
* <SLV-M> 09h 68h [7:0] IDAGCA_IFLFACC[7:0]
* <SLV-M> 09h 69h [7:0] IDAGCA_IFLFACC[15:8]
* <SLV-M> 09h 6Ah [3:0] IDAGCA_IFLFACC[23:16]
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x68, data, 3) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
*pSignalLevelData = ((uint32_t) (data[2] & 0xFF) << 16) | ((uint32_t) (data[1] & 0xFF) << 8) | data[0];
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_atsc_monitor_InternalDigitalAGCOut (sony_demod_t * pDemod,
uint32_t * pDigitalAGCOut)
{
uint8_t data[3];
SONY_TRACE_ENTER ("sony_demod_atsc_monitor_InternalDigitalAGCOut");
if ((!pDemod) || (!pDigitalAGCOut)) {
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_ATSC) {
/* Not ATSC */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Set SLV-M Bank : 0x08 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x00, 0x08) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Baseband AGC Control Value Monitor
* slave Bank Addr Bit Name
* ---------------------------------------------------------------
* <SLV-M> 08h 1Bh [7:0] IDBAGCA_GAIN[7:0]
* <SLV-M> 08h 1Ch [7:0] IDBAGCA_GAIN[15:8]
* <SLV-M> 08h 1Dh [3:0] IDBAGCA_GAIN[19:16]
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x1B, data, 3) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
*pDigitalAGCOut = ((data[2] & 0x0F) << 16) | (data[1] << 8) | data[0];
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
/*------------------------------------------------------------------------------
Static Functions
------------------------------------------------------------------------------*/
static sony_result_t checkVQLock (sony_demod_t * pDemod)
{
uint8_t data = 0x00;
SONY_TRACE_ENTER ("checkVQLock");
if (!pDemod) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Set SLV-M Bank : 0x0D */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x00, 0x0D) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* DMD lock flag
* slave Bank Addr Bit Name Meaning
* -----------------------------------------------------------------------
* <SLV-M> 0Dh 86h [0] VQLOCK 0:UNLOCK, 1:LOCK
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVM, 0x86, &data, 1) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (data & 0x01) {
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
else {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
}
+173
View File
@@ -0,0 +1,173 @@
/*------------------------------------------------------------------------------
Copyright 2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/27
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
------------------------------------------------------------------------------*/
/**
@file sony_demod_atsc_monitor.h
This file provides the ATSC demodulator monitor interface.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_ATSC_MONITOR_H
#define SONY_DEMOD_ATSC_MONITOR_H
#include "../sony_demod.h"
/**
@brief Sync state monitor.
@param pDemod The demodulator instance.
@param pVQLockStat The demodulator lock condition.
- 0: DMD not locked.
- 1: DMD locked.
@param pAGCLockStat Indicates the AGC lock condition.
- 0: AGC not locked.
- 1: AGC locked.
@param pTSLockStat Indicates the TS lock condition.
- 0: TS not locked.
- 1: TS locked.
@param pUnlockDetected Indicates the early unlock condition.
- 0: No early unlock.
- 1: Early unlock.
@return SONY_RESULT_OK if successful and pVQLockStat, pAGCLockStat,
pTSLockStat, pUnlockDetected are valid.
*/
sony_result_t sony_demod_atsc_monitor_SyncStat (sony_demod_t * pDemod,
uint8_t * pVQLockStat,
uint8_t * pAGCLockStat,
uint8_t * pTSLockStat,
uint8_t * pUnlockDetected);
/**
@brief Monitor the IFAGC value.
Actual dB gain dependent on attached tuner.
@param pDemod The demodulator instance.
@param pIFAGCOut The IFAGC output register value. Range 0x000 - 0x3FFF. Unitless.
@return SONY_RESULT_OK if successful and pIFAGCOut valid.
*/
sony_result_t sony_demod_atsc_monitor_IFAGCOut (sony_demod_t * pDemod,
uint32_t * pIFAGCOut);
/**
@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 (Hz).
@return SONY_RESULT_OK if successful and pOffset valid.
*/
sony_result_t sony_demod_atsc_monitor_CarrierOffset (sony_demod_t * pDemod,
int32_t * pOffset);
/**
@brief Monitor the Pre-RS BER.
@param pDemod The demodulator instance.
@param pBER Bit Error Rate value (Pre Reed-Solomon decoder) x 1e7.
@return SONY_RESULT_OK if successful and pBER valid.
*/
sony_result_t sony_demod_atsc_monitor_PreRSBER (sony_demod_t * pDemod,
uint32_t * pBER);
/**
@brief Monitor the Pre-RS SER (Symbol Error Rate).
@param pDemod The demodulator instance.
@param pSER Symbol Error Rate value (Pre Reed-Solomon decoder) x 1e7.
@return SONY_RESULT_OK if successful and pSER valid.
*/
sony_result_t sony_demod_atsc_monitor_PreRSSER (sony_demod_t * pDemod,
uint32_t * pSER);
/**
@brief Monitor the Post-RS WER (Word Error Rate).
@param pDemod The demodulator instance.
@param pWER Word Error Rate value (Post Reed-Solomon decoder) x 1e6.
@return SONY_RESULT_OK if successful and pWER valid.
*/
sony_result_t sony_demod_atsc_monitor_PostRSWER (sony_demod_t * pDemod,
uint32_t * pWER);
/**
@brief Monitor the Packet Error Detection.
This value will freeze when the packet error detected.
Another read transaction will refresh the value.
@param pDemod The demodulator instance.
@param pPacketErrorDetected The Packet Error Presence.
- 0: Packet Error absence.
- 1: Packet Error presence.
@return SONY_RESULT_OK if successful and pPacketErrorDetected valid.
*/
sony_result_t sony_demod_atsc_monitor_PacketError (sony_demod_t * pDemod,
uint8_t * pPacketErrorDetected);
/**
@brief Monitors the estimated SNR value.
@param pDemod The demodulator instance.
@param pSNR The estimated SNR in dBx1000.
@return SONY_RESULT_OK if successful and pSNR is valid.
*/
sony_result_t sony_demod_atsc_monitor_SNR (sony_demod_t * pDemod,
int32_t * pSNR);
/**
@brief Monitor the sampling frequency offset value.
@param pDemod The demodulator instance.
@param pPPM The sampling frequency offset in ppm x 100.
@return SONY_RESULT_OK if successful and pPPM is valid.
*/
sony_result_t sony_demod_atsc_monitor_SamplingOffset (sony_demod_t * pDemod,
int32_t * pPPM);
/**
@brief Monitor the signal level data to be used for ::SONY_DEMOD_CONFIG_ATSC_NO_SIGNAL_THRESH and
SONY_DEMOD_CONFIG_ATSC_SIGNAL_THRESH config option for ::sony_demod_SetConfig.
This function should not be used in the normal sequence,
but in the optimization sequence for early unlock detection.
@param pDemod The demodulator instance.
@param pSignalLevelData Indicates the Signal Level data for unlock optimization. Unitless.
@return SONY_RESULT_OK if successful and pSignalLevelData is valid.
*/
sony_result_t sony_demod_atsc_monitor_SignalLevelData_ForUnlockOptimization (sony_demod_t * pDemod,
uint32_t * pSignalLevelData);
/**
@brief Monitor the value of the Internal Digital AGC output.
@param pDemod The demodulator instance.
@param pDigitalAGCOut The value of the Internal Digital AGC output. (0x00000 - 0x7FFFF)
@return SONY_RESULT_OK if pDigitalAGCOut is valid.
*/
sony_result_t sony_demod_atsc_monitor_InternalDigitalAGCOut (sony_demod_t * pDemod,
uint32_t * pDigitalAGCOut);
#endif /* SONY_DEMOD_ATSC_MONITOR_H */
Binary file not shown.
+386
View File
@@ -0,0 +1,386 @@
/*------------------------------------------------------------------------------
Copyright 2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/08/30
Modification ID : 902dae58eb5249e028ccc5d7f60bb66cca9b43a9
------------------------------------------------------------------------------*/
#include "sony_integ_atsc.h"
#include "sony_demod_atsc_monitor.h"
#include <stdio.h>
/*------------------------------------------------------------------------------
Static Function Prototypes
------------------------------------------------------------------------------*/
/**
@brief Waits for demodulator lock, polling ::sony_demod_atsc_monitor_SyncStat
at 10ms intervals. Called as part of the Tune process.
*/
static sony_result_t atsc_WaitVQLock (sony_integ_t * pInteg);
#define PR_DTUN printf
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
sony_result_t sony_integ_atsc_Tune (sony_integ_t * pInteg,
sony_atsc_tune_param_t * pTuneParam)
{
sony_result_t result;
SONY_TRACE_ENTER ("sony_integ_atsc_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);
}
//PR_TUN("dbg_pr [%s,%d] freq=%d\n",__FUNCTION__,__LINE__,pTuneParam->centerFreqKHz);
/* Tune the demodulator */
result = sony_demod_atsc_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);
}
PR_DTUN("dbg_pr [%s,%d] sony_demod_I2cRepeaterEnable 1\n",__FUNCTION__,__LINE__);
/* Tune the RF part */
result = pInteg->pTuner->TerrCableTune (pInteg->pTuner, pTuneParam->centerFreqKHz, SONY_DTV_SYSTEM_ATSC, SONY_DTV_BW_6_MHZ);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
PR_DTUN("dbg_pr [%s,%d] TerrCableTune \n",__FUNCTION__,__LINE__);
/* Disable the I2C repeater */
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x00);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
PR_DTUN("dbg_pr [%s,%d] sony_demod_I2cRepeaterEnable 0\n",__FUNCTION__,__LINE__);
}
result = sony_demod_atsc_TuneEnd(pInteg->pDemod);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
PR_DTUN("dbg_pr [%s,%d] sony_demod_atsc_TuneEnd ,scanmode=%d \n",__FUNCTION__,__LINE__,pInteg->pDemod->scanMode);
if (!pInteg->pDemod->scanMode) {
result = sony_integ_atsc_WaitTSLock(pInteg);
if (result != SONY_RESULT_OK) {
PR_DTUN("dbg_pr [%s,%d] result=%d\n",__FUNCTION__,__LINE__,result); // 5
SONY_TRACE_RETURN (result);
}
} else {
result = atsc_WaitVQLock(pInteg);
if (result != SONY_RESULT_OK) {
PR_DTUN("dbg_pr [%s,%d] \n",__FUNCTION__,__LINE__);
SONY_TRACE_RETURN (result);
}
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_integ_atsc_Scan (sony_integ_t * pInteg,
sony_integ_atsc_scan_param_t * pScanParam,
sony_integ_atsc_scan_callback_t callBack)
{
sony_result_t result = SONY_RESULT_OK;
sony_integ_atsc_scan_result_t scanResult;
SONY_TRACE_ENTER ("sony_integ_atsc_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);
}
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;
/* Set scan mode enabled */
result = sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_ATSC, 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_atsc_Tune(pInteg, &scanResult.tuneParam);
switch (scanResult.tuneResult) {
/* Channel found, callback to application */
case SONY_RESULT_OK:
callBack (pInteg, &scanResult, pScanParam);
break;
case SONY_RESULT_ERROR_UNLOCK:
case SONY_RESULT_ERROR_TIMEOUT:
/* Channel not found, callback to application for progress updates */
callBack (pInteg, &scanResult, pScanParam);
break;
default:
/* Serious error occurred -> cancel operation. */
sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_ATSC, 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_ATSC, 0x00);
SONY_TRACE_RETURN (result);
}
}
/* Clear scan mode */
result = sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_ATSC, 0x00);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
SONY_TRACE_RETURN (result);
}
sony_result_t sony_integ_atsc_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;
/*uint32_t waitTimeOut = 0;*/
SONY_TRACE_ENTER ("sony_integ_atsc_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_ATSC_WAIT_TS_LOCK) {
continueWait = 0;
}
result = sony_demod_atsc_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_ATSC_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_atsc_monitor_RFLevel (sony_integ_t * pInteg,
int32_t * pRFLeveldB)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_integ_atsc_WaitTSLock");
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_ATSC) {
/* Not ATSC */
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_atsc_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);
}
/*------------------------------------------------------------------------------
Static Functions
------------------------------------------------------------------------------*/
static sony_result_t atsc_WaitVQLock (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;
uint32_t waitTimeOut = 0;
SONY_TRACE_ENTER ("atsc_WaitVQLock");
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);
}
waitTimeOut = SONY_ATSC_WAIT_DEMOD_LOCK;
/* 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 >= waitTimeOut) {
continueWait = 0;
}
result = sony_demod_atsc_CheckDemodLock (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_ATSC_WAIT_LOCK_INTERVAL);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
}
else {
result = SONY_RESULT_ERROR_TIMEOUT;
break;
}
}
SONY_TRACE_RETURN (result);
}
+159
View File
@@ -0,0 +1,159 @@
/*------------------------------------------------------------------------------
Copyright 2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/27
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
------------------------------------------------------------------------------*/
/**
@file sony_integ_atsc.h
This file provides the integration layer interface for ATSC
specific demodulator functions.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_INTEG_ATSC_H
#define SONY_INTEG_ATSC_H
#include "../sony_integ.h"
#include "sony_demod_atsc.h"
/*------------------------------------------------------------------------------
Defines
------------------------------------------------------------------------------*/
#define SONY_ATSC_WAIT_DEMOD_LOCK 1200 /**< 1.2s timeout for wait demodulator lock process for ATSC channels */
#define SONY_ATSC_WAIT_TS_LOCK 1200 /**< 1.2s timeout for wait TS lock process for ATSC channels */
#define SONY_ATSC_WAIT_LOCK_INTERVAL 10 /**< 10ms polling interval for demodulator and TS lock functions */
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief The parameters used for ATSC scanning.
*/
typedef struct sony_integ_atsc_scan_param_t {
/**
@brief The start frequency in kHz for scanning. Ensure that this is
aligned with the channel raster.
*/
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;
} sony_integ_atsc_scan_param_t;
/**
@brief The structure used to return a channel located or progress update
as part of a ATSC or combined scan.
*/
typedef struct sony_integ_atsc_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 has been locked
and one of the tuneParam structures contain the channel information.
*/
sony_result_t tuneResult;
/**
@brief The tune params for a located ATSC channel.
*/
sony_atsc_tune_param_t tuneParam;
} sony_integ_atsc_scan_result_t;
/*------------------------------------------------------------------------------
Function Pointers
------------------------------------------------------------------------------*/
/**
@brief Callback function that is called for every attempted frequency during a scan.
For successful channel results the function is called after
demodulator lock but before TS lock is achieved (ATSC : VQ Lock).
@param pInteg The driver instance.
@param pResult The current scan result.
@param pScanParam The current scan parameters.
*/
typedef void (*sony_integ_atsc_scan_callback_t) (sony_integ_t * pInteg,
sony_integ_atsc_scan_result_t * pResult,
sony_integ_atsc_scan_param_t * pScanParam);
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Performs acquisition to a ATSC 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_atsc_Tune (sony_integ_t * pInteg,
sony_atsc_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_atsc_Scan (sony_integ_t * pInteg,
sony_integ_atsc_scan_param_t * pScanParam,
sony_integ_atsc_scan_callback_t callBack);
/**
@brief Polls the demodulator waiting for TS lock at 10ms intervals up to the
demodulation mode dependent timeout.
@param pInteg The driver instance
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_integ_atsc_WaitTSLock (sony_integ_t * pInteg);
/**
@brief This function returns the estimated RF level based on either the demodulator IFAGC
level or a tuner internal RSSI monitor.
If any compensation for external hardware
such as, LNA, attenuators is required, then the user should make adjustment in the
corresponding function.
@param pInteg The driver instance
@param pRFLeveldB The RF Level estimation in dB * 1000
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_integ_atsc_monitor_RFLevel (sony_integ_t * pInteg,
int32_t * pRFLeveldB);
#endif /* SONY_INTEG_ATSC_H */
Binary file not shown.
+756
View File
@@ -0,0 +1,756 @@
/*------------------------------------------------------------------------------
Copyright 2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/12/13
Modification ID : e402a4dcb0e51a00c34b174334c082c1211eebf1
------------------------------------------------------------------------------*/
#include "../sony_integ.h"
#include "sony_integ_atsc3.h"
#include "../sony_demod.h"
#include "sony_demod_atsc3_monitor.h"
static sony_result_t atsc3_WaitDemodLock (sony_integ_t * pInteg);
static sony_result_t atsc3_WaitCWTracking (sony_integ_t * pInteg);
//#define TUN_PR printf
#define TUN_PR(...)
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
sony_result_t sony_integ_atsc3_Tune (sony_integ_t * pInteg,
sony_atsc3_tune_param_t * pTuneParam)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_integ_atsc3_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_7_MHZ) &&
(pTuneParam->bandwidth != SONY_DTV_BW_8_MHZ)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
}
result = sony_demod_atsc3_AutoDetectSeq_Init (pInteg->pDemod);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Configure for manual PLP selection. */
#ifdef SONY_DEMOD_SUPPORT_ATSC3_CHBOND
if ((pInteg->pDemod->chbondConfig == SONY_DEMOD_CHBOND_CONFIG_ATSC3_MAIN)
|| (pInteg->pDemod->chbondConfig == SONY_DEMOD_CHBOND_CONFIG_ATSC3_SUB)) {
/* PLP configuration for channel bonding case */
result = sony_demod_atsc3_chbond_SetPLPConfig (pInteg->pDemod, pTuneParam->plpIDNum, pTuneParam->plpID, pTuneParam->plpBond);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
} else
#endif /* SONY_DEMOD_SUPPORT_ATSC3_CHBOND */
{
result = sony_demod_atsc3_SetPLPConfig (pInteg->pDemod, pTuneParam->plpIDNum, pTuneParam->plpID);
TUN_PR("[%s,%d] sony_demod_atsc3_SetPLPConfig result=%d\n",__FUNCTION__,__LINE__,result);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
}
/* Tune the demodulator */
result = sony_demod_atsc3_Tune (pInteg->pDemod, pTuneParam);
TUN_PR("[%s,%d] tune demod result=%d\n",__FUNCTION__,__LINE__,result);
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);
TUN_PR("[%s,%d] Enable the I2C repeater result=%d\n",__FUNCTION__,__LINE__,result);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Tune the RF part */
result = pInteg->pTuner->TerrCableTune (pInteg->pTuner, pTuneParam->centerFreqKHz, SONY_DTV_SYSTEM_ATSC3, pTuneParam->bandwidth);
TUN_PR("[%s,%d] Tune the RF part result=%d\n",__FUNCTION__,__LINE__,result);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Disable the I2C repeater */
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x00);
printf("[%s,%d] Tune the RF part result=%d\n",__FUNCTION__,__LINE__,result);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
}
/* Reset the demod to enable acquisition */
result = sony_demod_TuneEnd (pInteg->pDemod);
TUN_PR("[%s,%d] demod tunend. result=%d\n",__FUNCTION__,__LINE__,result);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
result = atsc3_WaitDemodLock (pInteg);
TUN_PR("[%s,%d] wait demod lock . result=%d\n",__FUNCTION__,__LINE__,result);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
result = atsc3_WaitCWTracking (pInteg);
TUN_PR("[%s,%d] wait CW tracking . result=%d pInteg->pDemod->scanMode=%d\n",__FUNCTION__,__LINE__,result,pInteg->pDemod->scanMode);
if ((result != SONY_RESULT_OK) && (result != SONY_RESULT_ERROR_TIMEOUT)) {
/* Even if timeout error occurred and failed to configure CW tracking,
should continue without error. Demodulator may lock target ALPs after that. */
SONY_TRACE_RETURN (result);
}
//------------------------------------------
if (!pInteg->pDemod->scanMode) {
result = sony_integ_atsc3_WaitALPLock (pInteg);
TUN_PR("[%s,%d] wait alp lock . result=%d\n",__FUNCTION__,__LINE__,result);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
}
TUN_PR("[%s,%d]\n",__FUNCTION__,__LINE__);
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_integ_atsc3_EASTune (sony_integ_t * pInteg,
sony_atsc3_tune_param_t * pTuneParam)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_integ_atsc3_EASTune");
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_7_MHZ) &&
(pTuneParam->bandwidth != SONY_DTV_BW_8_MHZ)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
}
result = sony_demod_atsc3_AutoDetectSeq_Init (pInteg->pDemod);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Tune the demodulator */
result = sony_demod_atsc3_EASTune (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_ATSC3, 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_atsc3_EASTuneEnd (pInteg->pDemod);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
result = atsc3_WaitDemodLock (pInteg);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
result = atsc3_WaitCWTracking (pInteg);
if ((result != SONY_RESULT_OK) && (result != SONY_RESULT_ERROR_TIMEOUT)) {
/* Even if timeout error occurred and failed to configure CW tracking,
should continue without error. Demodulator may lock target ALPs after that. */
SONY_TRACE_RETURN (result);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_integ_atsc3_Scan (sony_integ_t * pInteg,
sony_integ_atsc3_scan_param_t * pScanParam,
sony_integ_atsc3_scan_callback_t callBack)
{
sony_result_t result = SONY_RESULT_OK;
sony_integ_atsc3_scan_result_t scanResult;
SONY_TRACE_ENTER ("sony_integ_atsc3_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);
}
if (pScanParam->stepFrequencyKHz == 0) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Check bandwidth validity */
if ((pScanParam->bandwidth != SONY_DTV_BW_6_MHZ) && (pScanParam->bandwidth != SONY_DTV_BW_7_MHZ) &&
(pScanParam->bandwidth != SONY_DTV_BW_8_MHZ)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
}
/* Set the start frequency and other parameters. */
scanResult.centerFreqKHz = pScanParam->startFrequencyKHz;
scanResult.tuneResult = SONY_RESULT_OK;
scanResult.tuneParam.centerFreqKHz = pScanParam->startFrequencyKHz;
scanResult.tuneParam.bandwidth = pScanParam->bandwidth;
scanResult.tuneParam.plpIDNum = 1;
scanResult.tuneParam.plpID[0] = 0;
scanResult.tuneParam.plpID[1] = 0;
scanResult.tuneParam.plpID[2] = 0;
scanResult.tuneParam.plpID[3] = 0;
#ifdef SONY_DEMOD_SUPPORT_ATSC3_CHBOND
scanResult.tuneParam.plpBond[0] = SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE;
scanResult.tuneParam.plpBond[1] = SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE;
scanResult.tuneParam.plpBond[2] = SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE;
scanResult.tuneParam.plpBond[3] = SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE;
#endif
/* Set scan mode enabled */
result = sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_ATSC3, 0x01);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
while (scanResult.centerFreqKHz <= pScanParam->endFrequencyKHz) {
scanResult.tuneParam.centerFreqKHz = scanResult.centerFreqKHz;
scanResult.tuneResult = sony_integ_atsc3_Tune(pInteg, &scanResult.tuneParam);
switch (scanResult.tuneResult) {
case SONY_RESULT_OK:
/* Channel found, callback to application */
callBack (pInteg, &scanResult, pScanParam);
printf("sony_integ_atsc3_Tune SONY_RESULT_OK\n");
break;
case SONY_RESULT_ERROR_UNLOCK:
case SONY_RESULT_ERROR_TIMEOUT:
/* Channel not found, callback to application for progress updates */
callBack (pInteg, &scanResult, pScanParam);
printf("sony_integ_atsc3_Tune SONY_RESULT_ERROR %d\n\n", scanResult.tuneResult);
break;
default:
/* Serious error occurred -> cancel operation. */
sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_ATSC3, 0x00);
SONY_TRACE_RETURN (scanResult.tuneResult);
}
scanResult.centerFreqKHz += pScanParam->stepFrequencyKHz;
/* Check cancellation. */
result = sony_integ_CheckCancellation (pInteg);
if (result != SONY_RESULT_OK) {
printf("sony_integ_CheckCancellation SONY_RESULT_ERR %d\n", result);
sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_ATSC3, 0x00);
SONY_TRACE_RETURN (result);
}
}
/* Clear scan mode */
result = sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_ATSC3, 0x00);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_integ_atsc3_Scan_plpnum (sony_integ_t * pInteg,
sony_integ_atsc3_scan_param_t * pScanParam,
sony_integ_atsc3_scan_callback_t callBack,
uint8_t plpnum, uint8_t plpid0,uint8_t plpid1,
uint8_t plpid2,uint8_t plpid3)
{
sony_result_t result = SONY_RESULT_OK;
sony_integ_atsc3_scan_result_t scanResult;
SONY_TRACE_ENTER ("sony_integ_atsc3_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);
}
if (pScanParam->stepFrequencyKHz == 0) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Check bandwidth validity */
if ((pScanParam->bandwidth != SONY_DTV_BW_6_MHZ) && (pScanParam->bandwidth != SONY_DTV_BW_7_MHZ) &&
(pScanParam->bandwidth != SONY_DTV_BW_8_MHZ)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
}
/* Set the start frequency and other parameters. */
scanResult.centerFreqKHz = pScanParam->startFrequencyKHz;
scanResult.tuneResult = SONY_RESULT_OK;
scanResult.tuneParam.centerFreqKHz = pScanParam->startFrequencyKHz;
scanResult.tuneParam.bandwidth = pScanParam->bandwidth;
scanResult.tuneParam.plpIDNum = plpnum;
scanResult.tuneParam.plpID[0] = plpid0;
scanResult.tuneParam.plpID[1] = plpid1;
scanResult.tuneParam.plpID[2] = plpid2;
scanResult.tuneParam.plpID[3] = plpid3;
#ifdef SONY_DEMOD_SUPPORT_ATSC3_CHBOND
scanResult.tuneParam.plpBond[0] = SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE;
scanResult.tuneParam.plpBond[1] = SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE;
scanResult.tuneParam.plpBond[2] = SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE;
scanResult.tuneParam.plpBond[3] = SONY_DEMOD_ATSC3_CHBOND_PLP_BOND_ENABLE;
#endif
/* Set scan mode enabled */
result = sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_ATSC3, 0x01);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
printf ("enable scan ok\n");
while (scanResult.centerFreqKHz <= pScanParam->endFrequencyKHz) {
scanResult.tuneParam.centerFreqKHz = scanResult.centerFreqKHz;
printf(" scanResult.centerFreqKHz=%d, plpnum=%d \n",scanResult.centerFreqKHz,
scanResult.tuneParam.plpIDNum);
scanResult.tuneResult = sony_integ_atsc3_Tune(pInteg, &scanResult.tuneParam);
switch (scanResult.tuneResult) {
case SONY_RESULT_OK:
printf("scanResult :centerFreqKHz=%d, plpnum=%d %d,%d,%d,%d\n",scanResult.centerFreqKHz,
scanResult.tuneParam.plpIDNum,
scanResult.tuneParam.plpID[0],
scanResult.tuneParam.plpID[1],
scanResult.tuneParam.plpID[2],
scanResult.tuneParam.plpID[3]);
/* Channel found, callback to application */
callBack (pInteg, &scanResult, pScanParam);
printf("callBack done\n");
break;
case SONY_RESULT_ERROR_UNLOCK:
case SONY_RESULT_ERROR_TIMEOUT:
/* Channel not found, callback to application for progress updates */
callBack (pInteg, &scanResult, pScanParam);
break;
default:
/* Serious error occurred -> cancel operation. */
sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_ATSC3, 0x00);
SONY_TRACE_RETURN (scanResult.tuneResult);
}
scanResult.centerFreqKHz += pScanParam->stepFrequencyKHz;
/* Check cancellation. */
result = sony_integ_CheckCancellation (pInteg);
printf ("result=%d\n", result);
if (result != SONY_RESULT_OK) {
sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_ATSC3, 0x00);
SONY_TRACE_RETURN (result);
}
}
printf ("disable scan\n");
/* Clear scan mode */
result = sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_ATSC3, 0x00);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_integ_atsc3_SwitchPLP (sony_integ_t * pInteg,
uint8_t plpIDNum,
uint8_t plpID[4])
{
sony_result_t result;
SONY_TRACE_ENTER ("sony_integ_atsc3_SwitchPLP");
if ((!pInteg) || (!pInteg->pDemod) || (plpIDNum > 4)) {
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_ATSC3) {
/* Not ATSC 3.0 */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
if (pInteg->pDemod->atsc3EasState == SONY_DEMOD_ATSC3_EAS_STATE_EAS) {
/* In EAS mode, ALP is not output */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
#ifdef SONY_DEMOD_SUPPORT_ATSC3_CHBOND
if ((pInteg->pDemod->chbondConfig == SONY_DEMOD_CHBOND_CONFIG_ATSC3_MAIN)
|| (pInteg->pDemod->chbondConfig == SONY_DEMOD_CHBOND_CONFIG_ATSC3_SUB)) {
/* Unavailable for channel bonding */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
#endif /* SONY_DEMOD_SUPPORT_ATSC3_CHBOND */
result = sony_demod_atsc3_SetPLPConfig (pInteg->pDemod, plpIDNum, plpID);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
result = sony_integ_atsc3_WaitALPLock (pInteg);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_integ_atsc3_WaitALPLock (sony_integ_t * pInteg)
{
sony_result_t result = SONY_RESULT_OK;
sony_stopwatch_t timer;
uint8_t continueWait = 1;
uint32_t elapsed = 0;
sony_demod_lock_result_t lock;
uint8_t sync_status = 0;
uint8_t alp_lock_all = 0;
SONY_TRACE_ENTER ("sony_integ_atsc3_WaitALPLock");
if ((!pInteg) || (!pInteg->pDemod)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
TUN_PR("[%s,%d] \n",__FUNCTION__,__LINE__);
TUN_PR("[%s,%d] pInteg->pDemod->state=%d \n",__FUNCTION__,__LINE__,pInteg->pDemod->state );
if (pInteg->pDemod->state != SONY_DEMOD_STATE_ACTIVE) {
/* This api is accepted in Active state only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
result = sony_stopwatch_start (&timer);
TUN_PR("[%s,%d] sony_stopwatch_start result=%d\n",__FUNCTION__,__LINE__,result);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
int count=0;
for (;;) {
count++;
result = sony_stopwatch_elapsed(&timer, &elapsed);
TUN_PR("[%s,%d] (cnt=%d elapsed=%d) sony_stopwatch_elapsed result=%d\n",__FUNCTION__,__LINE__,count,elapsed,result);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Check for timeout condition */
if (elapsed >= SONY_ATSC3_WAIT_ALP_LOCK) {
continueWait = 0;
}
result = sony_demod_atsc3_CheckALPLock (pInteg->pDemod, &lock, &sync_status, &alp_lock_all);
TUN_PR("[%s,%d] sony_demod_atsc3_CheckALPLock result=%d\n",__FUNCTION__,__LINE__,result);
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;
}
TUN_PR("[%s,%d] lock=%d\n\n",__FUNCTION__,__LINE__,lock);
/* Check cancellation. */
result = sony_integ_CheckCancellation (pInteg);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
if (continueWait) {
result = sony_stopwatch_sleep (&timer, SONY_ATSC3_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_atsc3_monitor_RFLevel (sony_integ_t * pInteg,
int32_t * pRFLeveldB)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_integ_atsc3_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_ATSC3) {
/* Not ATSC 3.0 */
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_atsc3_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);
}
/*------------------------------------------------------------------------------
Static Functions
------------------------------------------------------------------------------*/
static sony_result_t atsc3_WaitDemodLock (sony_integ_t * pInteg)
{
sony_result_t result = SONY_RESULT_OK;
sony_demod_lock_result_t lock = SONY_DEMOD_LOCK_RESULT_NOTDETECT;
uint16_t timeout = 0;
sony_stopwatch_t timer;
uint8_t continueWait = 1;
uint32_t elapsed = 0;
SONY_TRACE_ENTER ("atsc3_WaitDemodLock");
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);
}
timeout = SONY_ATSC3_WAIT_DEMOD_LOCK;
for (;;) {
result = sony_stopwatch_elapsed (&timer, &elapsed);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
if (elapsed >= timeout) {
continueWait = 0;
}
result = sony_demod_atsc3_CheckDemodLock (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:
result = sony_demod_atsc3_AutoDetectSeq_UnlockCase (pInteg->pDemod, &continueWait);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
if (!continueWait) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_UNLOCK);
}
/* continue waiting... */
break;
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_ATSC3_WAIT_LOCK_INTERVAL);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
} else {
result = SONY_RESULT_ERROR_TIMEOUT;
break;
}
}
SONY_TRACE_RETURN (result);
}
static sony_result_t atsc3_WaitCWTracking (sony_integ_t * pInteg)
{
sony_result_t result = SONY_RESULT_OK;
uint16_t timeout = 0;
sony_stopwatch_t timer;
uint8_t completed = 1;
uint8_t continueWait = 1;
uint32_t elapsed = 0;
SONY_TRACE_ENTER ("atsc3_WaitCWTracking");
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 CW Tracking Completion */
result = sony_stopwatch_start (&timer);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
timeout = SONY_ATSC3_WAIT_CW_TRACKING_TIMEOUT;
for (;;) {
result = sony_stopwatch_elapsed (&timer, &elapsed);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
if (elapsed >= timeout) {
continueWait = 0;
}
result = sony_demod_atsc3_AutoDetectSeq_SetCWTracking (pInteg->pDemod, &completed);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
if (completed) {
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
/* Check cancellation. */
result = sony_integ_CheckCancellation (pInteg);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
if (continueWait) {
result = sony_stopwatch_sleep (&timer, SONY_ATSC3_WAIT_LOCK_INTERVAL);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
} else {
result = SONY_RESULT_ERROR_TIMEOUT;
break;
}
}
SONY_TRACE_RETURN (result);
}
+207
View File
@@ -0,0 +1,207 @@
/*------------------------------------------------------------------------------
Copyright 2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/08/30
Modification ID : 902dae58eb5249e028ccc5d7f60bb66cca9b43a9
------------------------------------------------------------------------------*/
/**
@file sony_integ_atsc3.h
This file provides the integration layer interface for ATSC 3.0
specific demodulator functions.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_INTEG_ATSC3_H
#define SONY_INTEG_ATSC3_H
#include "../sony_demod.h"
#include "../sony_integ.h"
#include "sony_demod_atsc3.h"
/*------------------------------------------------------------------------------
Defines
------------------------------------------------------------------------------*/
#define SONY_ATSC3_WAIT_DEMOD_LOCK 3500 /**< 3.5s timeout for wait demodulator lock process for ATSC 3.0 channels */
#define SONY_ATSC3_WAIT_ALP_LOCK 5000//4000 //1500 /**< 1.5s timeout for wait ALP lock process for ATSC 3.0 channels */
#define SONY_ATSC3_WAIT_CW_TRACKING_TIMEOUT 300 /**< 300msec timeout for wait CW Tracking Completion */
#define SONY_ATSC3_WAIT_LOCK_INTERVAL 10 /**< 10ms polling interval for demodulator, ALP lock and CW Tracking functions */
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief The parameters used for ATSC 3.0 scanning.
*/
typedef struct sony_integ_atsc3_scan_param_t {
/**
@brief The start frequency in kHz for scanning.
Ensure that this is aligned with the channel raster.
*/
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_atsc3_scan_param_t;
/**
@brief The structure used to return a channel located or progress update
as part of a ATSC 3.0 scan.
*/
typedef struct sony_integ_atsc3_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 has been locked.
*/
sony_result_t tuneResult;
/**
@brief The tune params for a located ATSC 3.0 channel.
Note that plpIDNum and plpID[] are temporary value.
*/
sony_atsc3_tune_param_t tuneParam;
} sony_integ_atsc3_scan_result_t;
/*------------------------------------------------------------------------------
Function Pointers
------------------------------------------------------------------------------*/
/**
@brief Callback function that is called for every attempted frequency during a scan.
For successful channel results the function is called after
demodulator lock but before ALP lock is achieved.
@param pInteg The driver instance.
@param pResult The current scan result.
@param pScanParam The current scan parameters.
*/
typedef void (*sony_integ_atsc3_scan_callback_t) (sony_integ_t * pInteg,
sony_integ_atsc3_scan_result_t * pResult,
sony_integ_atsc3_scan_param_t * pScanParam);
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Performs acquisition to a ATSC 3.0 channel.
Blocks the calling thread until the ALP 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_atsc3_Tune (sony_integ_t * pInteg,
sony_atsc3_tune_param_t * pTuneParam);
/**
@brief Performs acquisition to a ATSC 3.0 channel in EAS mode.
EAS (Emergency Alert System) mode is used for waiting EAS flags, without ALP stream output.
PLP related settings in ::sony_atsc3_tune_param_t are ignored.
Several monitor APIs (SNR, BER, FER, L1 information ...) cannot work in EAS mode.
Blocks the calling thread until the Demod 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_atsc3_EASTune (sony_integ_t * pInteg,
sony_atsc3_tune_param_t * pTuneParam);
/**
@brief Performs a scan over the spectrum specified.
Perform a ATSC 3.0 system scan for ATSC 3.0 channels.
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_atsc3_Scan (sony_integ_t * pInteg,
sony_integ_atsc3_scan_param_t * pScanParam,
sony_integ_atsc3_scan_callback_t callBack);
sony_result_t sony_integ_atsc3_Scan_plpnum (sony_integ_t * pInteg,
sony_integ_atsc3_scan_param_t * pScanParam,
sony_integ_atsc3_scan_callback_t callBack,
uint8_t plpnum, uint8_t plpid0,uint8_t plpid1,
uint8_t plpid2,uint8_t plpid3);
/**
@brief Change the PLP on currently tuned channel.
Change the PLP configuration of the demodulator and wait completion (ALP lock).
@param pInteg The driver instance
@param plpIDNum Number of valid PLP ID in plpID[]. (1 - 4)
@param plpID The pointer of PLP ID 4 length array to set.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_integ_atsc3_SwitchPLP (sony_integ_t * pInteg,
uint8_t plpIDNum,
uint8_t plpID[4]);
/**
@brief Polls the demodulator waiting for ALP lock at 10ms intervals.
@param pInteg The driver instance
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_integ_atsc3_WaitALPLock (sony_integ_t * pInteg);
/**
@brief This function returns the estimated RF level based on either the demodulator IFAGC
level or a tuner internal RSSI monitor.
If any compensation for external hardware
such as, LNA, attenuators is required, then the user should make adjustment in the
corresponding function.
@param pInteg The driver instance
@param pRFLeveldB The RF Level estimation in dB * 1000
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_integ_atsc3_monitor_RFLevel (sony_integ_t * pInteg,
int32_t * pRFLeveldB);
#endif /* SONY_INTEG_ATSC3_H */
Binary file not shown.
+743
View File
@@ -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
View File
@@ -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 */
File diff suppressed because it is too large Load Diff
+343
View File
@@ -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 */
File diff suppressed because it is too large Load Diff
+270
View File
@@ -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
View File
@@ -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
View File
@@ -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 */
+31
View File
@@ -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 */
+187
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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 */
@@ -0,0 +1,655 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/27
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
------------------------------------------------------------------------------*/
#include "sony_common.h"
#include "sony_demod_dvbs_s2.h"
#include "sony_demod_dvbs_s2_blindscan.h"
sony_result_t sony_demod_dvbs_s2_blindscan_Initialize(sony_demod_t * pDemod)
{
sony_result_t result = SONY_RESULT_OK;
sony_dvbs_s2_tune_param_t tuneParam;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_Initialize");
if (!pDemod){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* State check */
if (pDemod->state != SONY_DEMOD_STATE_SLEEP){
result = sony_demod_dvbs_s2_Sleep (pDemod);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN(result);
}
}
tuneParam.centerFreqKHz = 1000000;
tuneParam.symbolRateKSps = 20000;
tuneParam.system = SONY_DTV_SYSTEM_ANY;
result = sony_demod_dvbs_s2_Tune (pDemod, &tuneParam);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN(result);
}
pDemod->dvbss2ScanMode = 0x01;
/* Set SLV-T Bank : 0x00 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OREG_ARC_CKACHGAUTO[0]
* LS/HS auto selection : OFF
*/
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x2B, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set SLV-T Bank : 0xAE */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAE) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OFSM_SRSON[0]
* SR search : ON
*/
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x24, 0x01) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OFSM_UNLOCKSEL_ARS[2:0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x2E, 0x05) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set SLV-T Bank : 0xA3 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA3) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xBD, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SONY_TRACE_RETURN (result);
}
sony_result_t sony_demod_dvbs_s2_blindscan_PS_INIT (sony_demod_t * pDemod, uint8_t ocfr_csk)
{
uint8_t iqInv = 0;
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_PS_INIT");
if (!pDemod){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
result = sony_demod_dvbs_s2_blindscan_SetSampleMode (pDemod, 1);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Set SLV-T Bank : 0xA0 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OCFRL_CHSCANON[0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x56, 0x01) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OCFRL_CSK[2:0] (0x01 in normal case) */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x57, (ocfr_csk & 0x07)) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set SLV-T Bank : 0xAB */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAB) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OCFRL_CSBUFOFF[0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xF9, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
result = sony_demod_dvbs_s2_CheckIQInvert (pDemod, &iqInv);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN(result);
}
if (iqInv){
/* Set SLV-T Bank : 0xA0 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OTUIF_POLAR[0] */
if (sony_i2c_SetRegisterBits (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xD7, 0x01, 0x01) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
}
SONY_TRACE_RETURN (result);
}
sony_result_t sony_demod_dvbs_s2_blindscan_PS_SET (sony_demod_t * pDemod,
int32_t lowerOffsetKHz,
int32_t upperOffsetKHz,
uint32_t stepKHz,
uint32_t ckaFreqKHz)
{
uint8_t data[6];
int32_t startFreqKHz = 0;
int32_t endFreqKHz = 0;
uint32_t stepFreqKHz = 0;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_PS_SET");
if (!pDemod){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if (ckaFreqKHz == 0){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
startFreqKHz = (lowerOffsetKHz * 2048) / (int32_t)ckaFreqKHz; /* Floor */
endFreqKHz = ((upperOffsetKHz * 2048) + ((int32_t)ckaFreqKHz - 1)) / (int32_t)ckaFreqKHz; /* Ceil */
stepFreqKHz = ((stepKHz * 2048) + ( ckaFreqKHz - 1)) / ckaFreqKHz; /* Ceil */
data[0] = (uint8_t)(((uint32_t)startFreqKHz >> 8) & 0x07);
data[1] = (uint8_t)(((uint32_t)startFreqKHz ) & 0xFF);
data[2] = (uint8_t)(((uint32_t)endFreqKHz >> 8) & 0x07);
data[3] = (uint8_t)(((uint32_t)endFreqKHz ) & 0xFF);
data[4] = (uint8_t)(( stepFreqKHz >> 8) & 0x03);
data[5] = (uint8_t)(( stepFreqKHz ) & 0xFF);
/* Set SLV-T Bank : 0xAB */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAB) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OCFRL_FSTART_CS[10:0]
* OCFRL_FEND_CS[10:0]
* OCFRL_FSTEP_CS[9:0]
*/
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xF1, data, 6) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_dvbs_s2_blindscan_PS_START (sony_demod_t * pDemod)
{
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_PS_START");
if (!pDemod){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Set SLV-T Bank : 0xA0 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OCFRL_CHSCANST[0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x54, 0x01) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_dvbs_s2_blindscan_PS_RACK (sony_demod_t * pDemod)
{
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_PS_RACK");
if (!pDemod){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Set SLV-T Bank : 0xA0 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OCFRL_CHSCANRACK[0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x55, 0x01) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_dvbs_s2_blindscan_PS_FIN (sony_demod_t * pDemod)
{
sony_result_t result = SONY_RESULT_OK;
uint8_t iqInv = 0;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_PS_FIN");
if (!pDemod){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
result = sony_demod_dvbs_s2_blindscan_SetSampleMode (pDemod, 0);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Set SLV-T Bank : 0xA0 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OCFRL_CHSCANON[0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x56, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OCFRL_CSK[2:0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x57, 0x02) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set SLV-T Bank : 0xAB */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAB) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OCFRL_CSBUFOFF[0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xF9, 0x01) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
result = sony_demod_dvbs_s2_CheckIQInvert (pDemod, &iqInv);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN(result);
}
if (iqInv){
/* Set SLV-T Bank : 0xA0 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OTUIF_POLAR[0] */
if (sony_i2c_SetRegisterBits (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xD7, 0x00, 0x01) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_dvbs_s2_blindscan_CS_INIT (sony_demod_t * pDemod)
{
sony_result_t result = SONY_RESULT_OK;
uint8_t iqInv = 0;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_CS_INIT");
if (!pDemod){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Set SLV-T Bank : 0xA0 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OCFRL_CHSCANON[0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x56, 0x01) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OCFRL_CSK[2:0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x57, 0x01) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
result = sony_demod_dvbs_s2_CheckIQInvert (pDemod, &iqInv);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN(result);
}
if (iqInv){
/* Set SLV-T Bank : 0xA0 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OTUIF_POLAR[0] */
if (sony_i2c_SetRegisterBits (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xD7, 0x01, 0x01) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_dvbs_s2_blindscan_CS_FIN (sony_demod_t * pDemod)
{
sony_result_t result = SONY_RESULT_OK;
uint8_t iqInv = 0;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_CS_FIN");
if (!pDemod){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Set SLV-T Bank : 0xA0 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OCFRL_CHSCANON[0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x56, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OCFRL_CSK[2:0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x57, 0x02) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
result = sony_demod_dvbs_s2_CheckIQInvert (pDemod, &iqInv);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN(result);
}
if (iqInv){
/* Set SLV-T Bank : 0xA0 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OTUIF_POLAR[0] */
if (sony_i2c_SetRegisterBits (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xD7, 0x00, 0x01) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_dvbs_s2_blindscan_GetCSFIN (sony_demod_t * pDemod,
uint8_t * pCSFIN)
{
uint8_t data = 0;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_GetCSFIN");
if ((!pDemod) || (!pCSFIN)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Set SLV-T Bank : 0xA0 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* ICFRL_CSFIN[0] */
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x40, &data, 1) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (data & 0x01){
*pCSFIN = 1;
} else {
*pCSFIN = 0;
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_dvbs_s2_blindscan_GetCSRDEND (sony_demod_t * pDemod,
uint8_t * pCSRDEND)
{
uint8_t data = 0;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_GetCSRDEND");
if ((!pDemod) || (!pCSRDEND)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Set SLV-T Bank : 0xAB */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAB) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* ICFRL_CSRDEND[0] */
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x44, &data, 1) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (data & 0x01){
*pCSRDEND = 1;
} else {
*pCSRDEND = 0;
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_dvbs_s2_blindscan_GetCSINFO (sony_demod_t * pDemod,
int32_t * pCSFREQ,
uint32_t * pCSPOW)
{
uint8_t data[4];
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_GetCSINFO");
if ((!pDemod) || (!pCSFREQ) || (!pCSPOW)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Set SLV-T Bank : 0xAB */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAB) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* ICFRL_CSFREQ[10:0]
* ICFRL_CSPOW[11:0]
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x40, data, 4) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
*pCSFREQ = sony_Convert2SComplement(((uint32_t)(data[0] & 0x07) << 8) | (uint32_t)(data[1] & 0xFF), 11);
*pCSPOW = ((uint32_t)(data[2] & 0x0F) << 8) | (uint32_t)(data[3] & 0xFF);
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_dvbs_s2_blindscan_GetSRSFIN (sony_demod_t * pDemod,
uint8_t * pSRSFIN)
{
uint8_t data = 0;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_GetSRSFIN");
if ((!pDemod) || (!pSRSFIN)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Set SLV-T Bank : 0xAE */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAE) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* IFSM_SRSFIN_ARS[0] */
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x10, &data, 1) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (data & 0x01){
*pSRSFIN = 1;
} else {
*pSRSFIN = 0;
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_dvbs_s2_blindscan_CheckTRLLock (sony_demod_t * pDemod,
uint8_t * pIsTRLLock)
{
uint8_t data = 0;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_CheckTRLLock");
if ((!pDemod) || (!pIsTRLLock)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Set SLV-T Bank : 0xA0 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* ITRL_LOCK[0] */
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x10, &data, 1) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (data & 0x01){
*pIsTRLLock = 1;
} else {
*pIsTRLLock = 0;
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_dvbs_s2_blindscan_GetPSPow (sony_demod_t * pDemod,
uint16_t * pPower)
{
uint8_t data[2] = {0, 0};
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_GetPSPow");
if ((!pDemod) || (!pPower)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Set SLV-T Bank : 0xA0 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* ICFRL_PSPOW[11:0] */
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x52, data, 2) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
*pPower = (uint16_t)(((uint32_t)(data[0] & 0x0F) << 8) | (uint32_t)(data[1] & 0xFF));
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_dvbs_s2_blindscan_SetCFFine (sony_demod_t * pDemod,
int32_t freqOffsetKHz)
{
uint8_t data[3];
uint32_t regvalue = 0;
uint8_t isNegative = 0;
uint32_t tempQ = 0;
uint32_t tempR = 0;
uint32_t tempDiv = 0;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_SetCFFine");
if (!pDemod) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
freqOffsetKHz *= (-1);
if (freqOffsetKHz < 0){
isNegative = 1;
regvalue = (uint32_t)(freqOffsetKHz * (-1));
} else {
isNegative = 0;
regvalue = (uint32_t)freqOffsetKHz;
}
/*
* regvalue = regvalue(21bit) * 2^20 / SONY_DEMOD_DVBS_S2_BLINDSCAN_CKAL
* = ((regvalue(21bit) * 2^10) * 2^10) / SONY_DEMOD_DVBS_S2_BLINDSCAN_CKAL
*/
/* CKAL */
tempDiv = 64000;
tempQ = (regvalue * 1024) / tempDiv;
tempR = (regvalue * 1024) % tempDiv;
tempR *= 1024;
tempQ = (tempQ * 1024) + (tempR / tempDiv);
tempR = tempR % tempDiv;
if (tempR >= (tempDiv/2)){
tempQ = tempQ + 1;
} else {
tempQ = tempQ;
}
if (isNegative){
if (tempQ > 0x100000) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_RANGE);
}
regvalue = (uint32_t)((int32_t)tempQ * (-1));
} else {
if (tempQ > 0xFFFFF) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_RANGE);
}
regvalue = tempQ;
}
data[0] = (uint8_t)((regvalue >> 16) & 0x1F);
data[1] = (uint8_t)((regvalue >> 8) & 0xFF);
data[2] = (uint8_t)( regvalue & 0xFF);
/* Set SLV-T Bank : 0xA0 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OCFRL_CTRLVALINIT[20:0] */
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xCA, data, 3) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_dvbs_s2_blindscan_SetSampleMode (sony_demod_t * pDemod,
uint8_t isHSMode)
{
uint8_t data = 0;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_SetSampleMode");
if (!pDemod){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if (isHSMode){
data = 0x01;
} else {
data = 0x00;
}
/* Set SLV-T Bank : 0x00 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OREG_ARC_HSMODE[0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x24, data) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_dvbs_s2_blindscan_SetSymbolRateRatio (sony_demod_t * pDemod,
uint32_t ratioMin,
uint32_t ratioMax)
{
uint8_t data[4];
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_SetSymbolRateRatio");
if (!pDemod){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if ((ratioMax > 0x03FF) || (ratioMin > 0x3FF)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
data[0] = (uint8_t)((ratioMax >> 8) & 0x03);
data[1] = (uint8_t)( ratioMax & 0xFF);
data[2] = (uint8_t)((ratioMin >> 8) & 0x03);
data[3] = (uint8_t)( ratioMin & 0xFF);
/* Set SLV-T Bank : 0xAE */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAE) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OFSM_RATIOMAX_ARS[9:0]
* OFSM_RATIOMIN_ARS[9:0]
*/
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x28, data, 4) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
@@ -0,0 +1,264 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/27
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbs_s2_blindscan.h
This file provides functions to control demodulator for BlindScan/TuneSRS.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_H
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_H
#include "sony_common.h"
#include "sony_demod.h"
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Initialize setting for starting BlindScan/TuneSRS
This function is used in this driver.
User doesn't necessary to call it.
@param pDemod The driver instance.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_Initialize(sony_demod_t * pDemod);
/**
@brief Initialize setting for power search.
This function is used in this driver.
User doesn't necessary to call it.
@param pDemod The driver instance.
@param ocfr_csk The register value of OCFR_CSK (1 - 7).
In normal case, it should be 1.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_PS_INIT (sony_demod_t * pDemod, uint8_t ocfr_csk);
/**
@brief Set parameters for power search.
This function is used in this driver.
User doesn't necessary to call it.
@param pDemod The driver instance.
@param lowerOffsetKHz lower offset frequency in KHz.
@param upperOffsetKHz upper offset frequency in KHz.
@param stepKHz step frequency in KHz.
@param ckaFreqKHz CKA frequency in KHz.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_PS_SET (sony_demod_t * pDemod,
int32_t lowerOffsetKHz,
int32_t upperOffsetKHz,
uint32_t stepKHz,
uint32_t ckaFreqKHz);
/**
@brief Start power search.
This function is used in this driver.
User doesn't necessary to call it.
@param pDemod The driver instance.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_PS_START (sony_demod_t * pDemod);
/**
@brief Set read ack.
This function is used in this driver.
User doesn't necessary to call it.
@param pDemod The driver instance.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_PS_RACK (sony_demod_t * pDemod);
/**
@brief Finalize settings for power search.
This function is used in this driver.
User doesn't necessary to call it.
@param pDemod The driver instance.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_PS_FIN (sony_demod_t * pDemod);
/**
@brief Initialize settings for coarse search.
This function is used in this driver.
User doesn't necessary to call it.
@param pDemod The driver instance.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_CS_INIT (sony_demod_t * pDemod);
/**
@brief Finalize settings for coarse search.
This function is used in this driver.
User doesn't necessary to call it.
@param pDemod The driver instance.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_CS_FIN (sony_demod_t * pDemod);
/**
@brief Get the finish flag for power data.
This function is used in this driver.
User doesn't necessary to call it.
@param pDemod The driver instance.
@param pCSFIN CSFIN flag (0: Not finished, 1: Finished)
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_GetCSFIN (sony_demod_t * pDemod,
uint8_t * pCSFIN);
/**
@brief Get the finish flag for power data in buffer.
This function is used in this driver.
User doesn't necessary to call it.
@param pDemod The driver instance.
@param pCSRDEND CSRDEND flag (0: Not ended, 1: Ended)
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_GetCSRDEND (sony_demod_t * pDemod,
uint8_t * pCSRDEND);
/**
@brief Get the frequency offset and power data.
This function is used in this driver.
User doesn't necessary to call it.
@param pDemod The driver instance.
@param pCSFREQ Frequency offset in KHz.
@param pCSPOW Power value.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_GetCSINFO (sony_demod_t * pDemod,
int32_t * pCSFREQ,
uint32_t * pCSPOW);
/**
@brief Get the flag indicate symbol rate search finished.
This function is used in this driver.
User doesn't necessary to call it.
@param pDemod The driver instance.
@param pSRSFIN The flag for symbol rate search finish.
- 0 : Symbol rate search does not finished.
- 1 : Symbol rate search finished.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_GetSRSFIN (sony_demod_t * pDemod,
uint8_t * pSRSFIN);
/**
@brief Get the TRL lock flag.
This function is used in this driver.
User doesn't necessary to call it.
@param pDemod The driver instance.
@param pIsTRLLock The TRL lock flag value.
- 0 : TRL is not locked.
- 1 : TRL is locked.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_CheckTRLLock (sony_demod_t * pDemod,
uint8_t * pIsTRLLock);
/**
@brief Get power data.
This function is used in this driver.
User doesn't necessary to call it.
@param pDemod The driver instance.
@param pPower Power value.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_GetPSPow (sony_demod_t * pDemod,
uint16_t * pPower);
/**
@brief Get frequency offset to measure power.
This function is used in this driver.
User doesn't necessary to call it.
@param pDemod The driver instance.
@param freqOffsetKHz Frequency offset in KHz.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_SetCFFine (sony_demod_t * pDemod,
int32_t freqOffsetKHz);
/**
@brief Set sampling rage mode.
This function is used in this driver.
User doesn't necessary to call it.
@param pDemod The driver instance.
@param isHSMode Sampling mode
- 0 : LS mode
- 1 : HS mode
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_SetSampleMode (sony_demod_t * pDemod,
uint8_t isHSMode);
/**
@brief Set sampling rage mode.
This function is used in this driver.
User doesn't necessary to call it.
@param pDemod The driver instance.
@param ratioMin Min symbol rate search ratio.
@param ratioMax Max symbol rate search ratio.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_SetSymbolRateRatio (sony_demod_t * pDemod,
uint32_t ratioMin,
uint32_t ratioMax);
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_H */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,190 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/09/28
Modification ID : 1ea04def104d657deb64f0d0b0cae6ef992a9dd8
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbs_s2_blindscan_algo.h
This file provides the algorithms for BlindScan/TuneSRS function.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_ALGO_H
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_ALGO_H
#include "sony_common.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
/*----------------------------------------------------------------------------
Functions
----------------------------------------------------------------------------*/
/**
@brief Get candidate from power spectrum for multipath.
@param pStorage Storage instance.
@param pPowerList Power spectrum data.
@param clipStep Slicing step in dB x 100.
@param minSymbolRateKSps Min symbol rate in KSps.
@param maxSymbolRateKSps Max symbol rate in KSps.
@param cferr Error frequency in KHz.
@param pCandList Candidate list generated by this function.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_algo_GetCandidateMp (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_power_t * pPowerList,
uint32_t clipStep,
uint32_t minSymbolRateKSps,
uint32_t maxSymbolRateKSps,
uint32_t cferr,
sony_demod_dvbs_s2_blindscan_data_t * pCandList);
/**
@brief Get candidate from power spectrum.
@param pStorage Storage instance.
@param pPowerList Power spectrum data.
@param clipStep Slicing step in dB x 100.
@param minSymbolRateKSps Min symbol rate in KSps.
@param maxSymbolRateKSps Max symbol rate in KSps.
@param cferr Error frequency in KHz.
@param pCandList Candidate list generated by this function.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_algo_GetCandidateNml (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_power_t * pPowerList,
uint32_t clipStep,
uint32_t minSymbolRateKSps,
uint32_t maxSymbolRateKSps,
uint32_t cferr,
sony_demod_dvbs_s2_blindscan_data_t * pCandList);
#ifdef SONY_DEMOD_SUPPORT_DVBS_S2_BLINDSCAN_VER2
/**
@brief Get candidate from power spectrum.
@param pStorage Storage instance.
@param pPowerList Power spectrum data.
@param minSymbolRateKSps Min symbol rate in KSps.
@param maxSymbolRateKSps Max symbol rate in KSps.
@param cferr Error frequency in KHz.
@param edgeCount Count of edges used for edge filtering.
@param overlapCount Count of overlaps used for edge filtering.
@param threshold Power threshold used for edge filtering.
@param pCandList Candidate list generated by this function.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_algo_GetCandidateEdge (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_power_t * pPowerList,
uint32_t minSymbolRateKSps,
uint32_t maxSymbolRateKSps,
uint32_t cferr,
int32_t edgeCount,
int32_t overlapCount,
int32_t threshold,
sony_demod_dvbs_s2_blindscan_data_t * pCandList);
#endif
/**
@brief Separate candidate for low symbol rate search
pCandList is updated by this function.
@param pStorage Storage instance.
@param pCandList Candidate list.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_algo_SeparateCandidate (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_data_t * pCandList);
/**
@brief Reduce candidate which is out of range.
pCandList is updated by this function.
@param pStorage Storage instance.
@param pCandList Candidate list.
@param pChannelList Detected channel list.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_algo_ReduceCandidate (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_data_t * pCandList,
sony_demod_dvbs_s2_blindscan_data_t * pChannelList);
/**
@brief Delete duplicated candidate
pCandList is updated by this function.
@param pStorage Storage instance.
@param pCandList Candidate list.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_algo_DeleteDuplicate (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_data_t * pCandList);
/**
@brief Delete duplicated candidate
pCandList is updated by this function.
@param pStorage Storage instance.
@param pCandList Candidate list.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_algo_DeleteDuplicate2 (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_data_t * pCandList);
/**
@brief Get non detected area from detected channel list.
@param pStorage Storage instance.
@param minPowerFreqKHz Min frequency in KHz.
@param maxPowerFreqKHz Max frequency in KHz.
@param resolutionKHz Resolution in KHz.
@param pChannelList Detected channel list.
@param pBandList Not detected area list.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_algo_GetNonDetectedBand (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
uint32_t minPowerFreqKHz,
uint32_t maxPowerFreqKHz,
uint32_t resolutionKHz,
sony_demod_dvbs_s2_blindscan_data_t * pChannelList,
sony_demod_dvbs_s2_blindscan_data_t * pBandList);
/**
@brief Sort candidate list by symbol rate.
@param pStorage Storage instance.
@param pCandList Candidate list.
@param baseSymbolRateKSps Sort base symbol rate in KSps.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_algo_SortBySymbolrate (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_data_t * pCandList,
uint32_t baseSymbolRateKSps);
/**
@brief Sort candidate list by frequency.
@param pStorage Storage instance.
@param pCandList Candidate list.
@param baseFrequencyKHz Sort base frequency in KHz.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_algo_SortByFrequency (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_data_t * pCandList,
uint32_t baseFrequencyKHz);
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_ALGO_H */
@@ -0,0 +1,98 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/09/28
Modification ID : 1ea04def104d657deb64f0d0b0cae6ef992a9dd8
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbs_s2_blindscan_data.h
This file provides the definition of data used in BlindScan function.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_DATA_H
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_DATA_H
#include "sony_common.h"
#include "sony_dtv.h"
/**
@brief Power data
*/
typedef struct sony_demod_dvbs_s2_blindscan_power_t {
struct sony_demod_dvbs_s2_blindscan_power_t * pNext;/**< Pointer of next item. */
uint32_t freqKHz; /**< Frequency in KHz. */
int32_t power; /**< Power data in dB x 100 */
#ifdef SONY_DEMOD_SUPPORT_DVBS_S2_BLINDSCAN_VER2
int32_t edge1; /**< Edge data1. */
int32_t edge2; /**< Edge data2. */
#endif
} sony_demod_dvbs_s2_blindscan_power_t;
/**
@brief Data used in BlindScan/TuneSRS sequence.
*/
typedef struct sony_demod_dvbs_s2_blindscan_data_t {
struct sony_demod_dvbs_s2_blindscan_data_t * pNext; /**< The pointer of next item. */
/**
@brief Data type used in BlindScan/TuneSRS.
"union" is used to share memory between multiple purposes.
*/
union data_t {
/**
@brief Power data.
*/
struct power_t {
uint32_t freqKHz; /**< Frequency in KHz. */
int32_t power; /**< Power in dB x 100. */
} power;
/**
@brief Band information data.
*/
struct band_t {
uint32_t minFreqKHz; /**< Min frequency in KHz. */
uint32_t maxFreqKHz; /**< Max frequency in KHz. */
} band;
/**
@brief Candidate data.
*/
struct candidate_t {
uint32_t centerFreqKHz; /**< Center frequency in KHz. */
uint32_t symbolRateKSps; /**< Target symbol rate in KSps. */
uint32_t minSymbolRateKSps; /**< Minimum symbol rate in range of candidate in KSps. */
uint32_t maxSymbolRateKSps; /**< Maximum symbol rate in range of candidate in KSps. */
} candidate;
/**
@brief Channel data.
*/
struct channel_t {
uint32_t centerFreqKHz; /**< Center frequency in KHz. */
uint32_t symbolRateKSps; /**< Symbol rate in KSps. */
sony_dtv_system_t system; /**< System. */
} channelInfo;
} data;
} sony_demod_dvbs_s2_blindscan_data_t;
/**
@brief Storage structure
*/
typedef struct {
sony_demod_dvbs_s2_blindscan_power_t availablePowerList; /**< List of available power data. */
sony_demod_dvbs_s2_blindscan_power_t * pPowerArrayTop; /**< Top of power data array. */
int32_t powerArrayLength; /**< Length of power data array. */
sony_demod_dvbs_s2_blindscan_data_t availableDataList; /**< List of available data. */
sony_demod_dvbs_s2_blindscan_data_t * pDataArrayTop; /**< Top of data array. */
int32_t dataArrayLength; /**< Length of data array. */
int32_t currentUsedCount; /**< Current used data count. */
int32_t maxUsedCount; /**< Max used data count. */
int32_t currentUsedPowerCount; /**< Current used power data count. */
int32_t maxUsedPowerCount; /**< Max used power data count. */
} sony_demod_dvbs_s2_blindscan_data_storage_t;
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_DATA_H */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,179 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/09/28
Modification ID : 1ea04def104d657deb64f0d0b0cae6ef992a9dd8
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbs_s2_blindscan_seq.h
This file provides definitions for BlindScan sequence function.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_SEQ_H
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_SEQ_H
#include "sony_common.h"
#include "sony_demod.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
#include "sony_demod_dvbs_s2_blindscan_utility.h"
#include "sony_demod_dvbs_s2_blindscan_seq_common.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_bt.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_cs.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_fs.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_pm.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_ss.h"
/**
@brief Definition of search range in MHz.
This value is affected to the array size in BlindScan sequence.
Please set the value depend on users application.
Default value is 1220(MHz).
It is 940MHz - 2160MHz. ( with some margin )
*/
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_SEARCH_RANGE_MHZ 1220
/**
@brief Definition of array size used in this driver.
The data size is depend on the input signal as follow.
- Search range.
- Power spectrum.
- etc...
User can get the maximum used data size by sony_demod_dvbs_s2_blindscan_data_storage_t::maxUsedCount.
If the driver returns SONY_RESULT_ERROR_OVERFLOW, please increase this value.
*/
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_DATA_MAX 10000
/**
@brief Definition of array size used in this driver.
This value is calculated by SONY_DEMOD_DVBS_S2_BLINDSCAN_SEARCH_RANGE_MHZ.
So user doesn't need to change this value directly.
*/
#ifdef SONY_DEMOD_SUPPORT_DVBS_S2_BLINDSCAN_VER2
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_POWER_MAX ((SONY_DEMOD_DVBS_S2_BLINDSCAN_SEARCH_RANGE_MHZ + 45) * 3)
#else
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_POWER_MAX ((SONY_DEMOD_DVBS_S2_BLINDSCAN_SEARCH_RANGE_MHZ + 45) * 2)
#endif
/**
@brief state of BlindScan sequence
*/
typedef enum {
BLINDSCAN_SEQ_STATE_START, /**< Start */
BLINDSCAN_SEQ_STATE_SS1_FIN, /**< SS1 fin */
BLINDSCAN_SEQ_STATE_STAGE1_FIN, /**< Stage1 fin */
BLINDSCAN_SEQ_STATE_SS2_START, /**< SS2 start */
BLINDSCAN_SEQ_STATE_SS2_FIN, /**< SS2 fin */
BLINDSCAN_SEQ_STATE_FS2_START, /**< FS2 start */
BLINDSCAN_SEQ_STATE_FS2_FIN, /**< FS2 fin */
BLINDSCAN_SEQ_STATE_CS_PREPARING, /**< CS preparing */
BLINDSCAN_SEQ_STATE_CS_TUNED, /**< CS tuned */
BLINDSCAN_SEQ_STATE_CS_FIN, /**< CS fin */
BLINDSCAN_SEQ_STATE_FS3_START, /**< FS3 start */
BLINDSCAN_SEQ_STATE_FINISH, /**< Finish */
BLINDSCAN_SEQ_STATE_UNKNOWN /**< Unknown */
} sony_demod_dvbs_s2_blindscan_seq_state_t;
/**
@brief Structure for scan sequence.
*/
typedef struct {
/**
@brief Common parameters used by each sub sequence
*/
sony_demod_dvbs_s2_blindscan_seq_common_t commonParams;
/**
@brief Finish/Continue flag.
- 0: Finish the sequence.
- 1: Continue the sequence.
*/
uint8_t isContinue;
sony_demod_dvbs_s2_blindscan_seq_state_t seqState; /**< State of BlindScan sequence. */
sony_demod_dvbs_s2_blindscan_subseq_bt_t subseqBT; /**< Data for sub sequence BT. */
sony_demod_dvbs_s2_blindscan_subseq_pm_t subseqPM; /**< Data for sub sequence PM. */
sony_demod_dvbs_s2_blindscan_subseq_ss_t subseqSS; /**< Data for sub sequence SS. */
sony_demod_dvbs_s2_blindscan_subseq_fs_t subseqFS; /**< Data for sub sequence FS. */
sony_demod_dvbs_s2_blindscan_subseq_cs_t subseqCS; /**< Data for sub sequence CS. */
uint32_t minFreqKHz; /**< Min frequency in KHz which set by BlindScan API */
uint32_t maxFreqKHz; /**< Max frequency in KHz which set by BlindScan API */
uint32_t minSymbolRateKSps; /**< Min symbol rate in KSps which set by BlindScan API */
uint32_t maxSymbolRateKSps; /**< Max symbol rate in KSps which set by BlindScan API */
uint32_t minPowerFreqKHz; /**< Min frequency in KHz which need for power spectrum */
uint32_t maxPowerFreqKHz; /**< Max frequency in KHz which need for power spectrum */
sony_demod_dvbs_s2_blindscan_data_t * pDetectedList; /**< Detected channel list */
sony_demod_dvbs_s2_blindscan_data_t * pBandList; /**< Band list */
sony_demod_dvbs_s2_blindscan_data_t * pBandCurrent; /**< Current processing band data */
sony_demod_dvbs_s2_blindscan_data_t * pCandList1; /**< Candidate list 1 */
sony_demod_dvbs_s2_blindscan_data_t * pCandList2; /**< Candidate list 2 */
sony_demod_dvbs_s2_blindscan_data_t * pCandCurrent; /**< The pointer of candidate */
sony_demod_dvbs_s2_blindscan_data_t * pCandLast; /**< The last pointer of candidate list */
uint32_t candCount; /**< Candidate total count for calculate progress */
uint32_t candIndex; /**< Candidate current number for calculate progress */
/**
@brief Power data for storage.
*/
sony_demod_dvbs_s2_blindscan_power_t powerArray[SONY_DEMOD_DVBS_S2_BLINDSCAN_POWER_MAX];
/**
@brief Data for storage.
*/
sony_demod_dvbs_s2_blindscan_data_t dataArray[SONY_DEMOD_DVBS_S2_BLINDSCAN_DATA_MAX];
} sony_demod_dvbs_s2_blindscan_seq_t;
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Prepare to start BlindScan sequence.
@param pSeq The sequence instance.
@param pDemod Demodulator instance.
@param minFreqKHz Minimum frequency of the scan range in KHz.
@param maxFreqKHz Maximum frequency of the scan range in KHz.
@param minSymbolRateKSps Minimum symbol rate of the scan range in KSps.
@param maxSymbolRateKSps Maximum symbol rate of the scan range in KSps.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_seq_Initialize (sony_demod_dvbs_s2_blindscan_seq_t * pSeq,
sony_demod_t * pDemod,
uint32_t minFreqKHz,
uint32_t maxFreqKHz,
uint32_t minSymbolRateKSps,
uint32_t maxSymbolRateKSps);
/**
@brief Execute one sequence for BlindScan.
@param pSeq The sequence instance.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_seq_Sequence (sony_demod_dvbs_s2_blindscan_seq_t * pSeq);
#ifdef SONY_DEMOD_SUPPORT_DVBS_S2_BLINDSCAN_VER2
/**
@brief Execute one sequence for BlindScan version2.
@param pSeq The sequence instance.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_version2_seq_Sequence (sony_demod_dvbs_s2_blindscan_seq_t * pSeq);
#endif
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_SEQ_H */
@@ -0,0 +1,132 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/27
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbs_s2_blindscan_seq_common.h
This file provides commonly used definitions for BlindScan function.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_SEQ_COMMON_H
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_SEQ_COMMON_H
#include "sony_common.h"
#include "sony_demod.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
/**
@brief Detected channel information.
*/
typedef struct {
/**
@brief Detect channel flag.
If this is "1(Detect)", please check the other parameters in this struct.
- 0: Not detect.
- 1: Detect.
*/
uint8_t isDetect;
/**
@brief The system of the detected channel.
This is valid if isDetect == 1.
*/
sony_dtv_system_t system;
/**
@brief The center frequency of the detected channel in KHz.
This is valid if isDetect == 1.
*/
uint32_t centerFreqKHz;
/**
@brief The symbol rate of the detected channel in KSps.
This is valid if isDetect == 1.
*/
uint32_t symbolRateKSps;
} sony_demod_dvbs_s2_blindscan_det_info_t;
/**
@brief Tune request information.
*/
typedef struct {
/**
@brief Tune request flag.
If this is "1(Request)", driver request to tuning.
- 0: Not detect.
- 1: Detect.
*/
uint8_t isRequest;
/**
@brief The frequency to tune in KHz.
This is valid if isRequest == 1.
*/
uint32_t frequencyKHz;
/**
@brief The system to tune.
This is valid if isRequest == 1.
*/
sony_dtv_system_t system;
/**
@brief The symbol rate to tune in KSps.
This is valid if isRequest == 1.
*/
uint32_t symbolRateKSps;
} sony_demod_dvbs_s2_blindscan_tune_req_t;
/**
@brief The information for calculate AGC level.
This parameter used in driver internal.
User doesn't need to access this structure.
*/
typedef struct {
uint8_t isRequest; /**< Calculate request flag. */
uint32_t agcLevel; /**< AGC level get from demodulator. */
int32_t agc_x100dB; /**< The result of calculation. */
} sony_demod_dvbs_s2_blindscan_agc_info_t;
/**
@brief Progress information for blind scan
This information is used only for BlindScan.
(TuneSRS doesn't use this parameter)
User doesn't need to access this structure.
*/
typedef struct {
uint8_t progress; /**< Total progress in "%". */
uint8_t majorMinProgress; /**< Current min range in "%". */
uint8_t majorMaxProgress; /**< Current max range in "%". */
uint8_t minorProgress; /**< Current sub progress in "%". */
} sony_demod_dvbs_s2_blindscan_progress_t;
/**
@brief The BlindScan sequence data
*/
typedef struct {
sony_demod_t * pDemod; /**< Demod driver instance */
uint32_t waitTime; /**< Wait time in ms */
sony_demod_dvbs_s2_blindscan_det_info_t detInfo; /**< Detected channel information */
sony_demod_dvbs_s2_blindscan_tune_req_t tuneReq; /**< Request to tune information */
sony_demod_dvbs_s2_blindscan_agc_info_t agcInfo; /**< Request to calculate information */
sony_demod_dvbs_s2_blindscan_data_storage_t storage; /**< Data storage */
sony_demod_dvbs_s2_blindscan_progress_t progressInfo; /**< Progress information */
uint32_t ckalFreqKHz; /**< CKAL in KHz */
uint32_t ckahFreqKHz; /**< CKAH in KHz */
} sony_demod_dvbs_s2_blindscan_seq_common_t;
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_SEQ_COMMON_H */
@@ -0,0 +1,365 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/09/28
Modification ID : 1ea04def104d657deb64f0d0b0cae6ef992a9dd8
------------------------------------------------------------------------------*/
#include "sony_common.h"
#include "sony_demod.h"
#include "sony_demod_dvbs_s2.h"
#include "sony_demod_dvbs_s2_monitor.h"
#include "sony_demod_dvbs_s2_blindscan.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_bt.h"
#include "sony_demod_dvbs_s2_blindscan_trace.h"
/*----------------------------------------------------------------------------
Static Functions
----------------------------------------------------------------------------*/
static sony_result_t finish_ok (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq);
static sony_result_t finish_ng (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq);
/*----------------------------------------------------------------------------
Functions
----------------------------------------------------------------------------*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_bt_Initialize (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq,
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_bt_Initialize");
if ((!pSeq) || (!pCommonParams)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
pSeq->isEnable = 0;
pSeq->state = BT_STATE_INIT;
pSeq->pCommonParams = pCommonParams;
SONY_TRACE_RETURN (result);
}
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_bt_Start (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq,
uint32_t centerFreqKHz,
uint32_t candSymbolRateKSps,
uint32_t minCandSymbolRateKSps,
uint32_t maxCandSymbolRateKSps,
uint32_t minSymbolRateKSps,
uint32_t maxSymbolRateKSps)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_bt_Start");
if (!pSeq){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
pSeq->isEnable = 1;
pSeq->state = BT_STATE_START;
pSeq->centerFreqKHz = centerFreqKHz;
pSeq->candSymbolRateKSps = candSymbolRateKSps;
pSeq->minCandSymbolRateKSps = minCandSymbolRateKSps;
pSeq->maxCandSymbolRateKSps = maxCandSymbolRateKSps;
pSeq->minSymbolRateKSps = minSymbolRateKSps;
pSeq->maxSymbolRateKSps = maxSymbolRateKSps;
pSeq->isLocked = 0;
pSeq->pCommonParams->waitTime = 0;
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_START (centerFreqKHz, candSymbolRateKSps, minCandSymbolRateKSps, maxCandSymbolRateKSps, minSymbolRateKSps, maxSymbolRateKSps);
SONY_TRACE_RETURN (result);
}
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_bt_Sequence (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq)
{
sony_result_t result = SONY_RESULT_OK;
uint8_t srsfin = 0;
uint8_t trllock = 0;
uint8_t tslock = 0;
uint32_t elapsedTime = 0;
uint32_t detSymbolRateSps = 0;
uint32_t detSymbolRateKSps = 0;
uint32_t ratioMax = 0;
uint32_t ratioMin = 0;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_bt_Sequence");
if(!pSeq) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
switch(pSeq->state)
{
case BT_STATE_START:
if (pSeq->maxCandSymbolRateKSps < pSeq->minSymbolRateKSps){
result = finish_ng (pSeq);
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT("NG(range)");
SONY_TRACE_RETURN (result);
}
if (pSeq->maxCandSymbolRateKSps >= 20000){
/* HS mode */
result = sony_demod_dvbs_s2_blindscan_SetSampleMode (pSeq->pCommonParams->pDemod, 1);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
} else {
/* LS mode */
result = sony_demod_dvbs_s2_blindscan_SetSampleMode (pSeq->pCommonParams->pDemod, 0);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
}
/* Clip 1 */
if (pSeq->candSymbolRateKSps < pSeq->minSymbolRateKSps) {
pSeq->candSymbolRateKSps = pSeq->minSymbolRateKSps;
}
if (pSeq->candSymbolRateKSps > pSeq->maxSymbolRateKSps){
pSeq->candSymbolRateKSps = pSeq->maxSymbolRateKSps;
}
if (pSeq->minCandSymbolRateKSps < pSeq->minSymbolRateKSps) {
pSeq->minCandSymbolRateKSps = pSeq->minSymbolRateKSps;
}
if (pSeq->minCandSymbolRateKSps > pSeq->maxSymbolRateKSps){
pSeq->minCandSymbolRateKSps = pSeq->maxSymbolRateKSps;
}
if (pSeq->maxCandSymbolRateKSps < pSeq->minSymbolRateKSps) {
pSeq->maxCandSymbolRateKSps = pSeq->minSymbolRateKSps;
}
if (pSeq->maxCandSymbolRateKSps > pSeq->maxSymbolRateKSps){
pSeq->maxCandSymbolRateKSps = pSeq->maxSymbolRateKSps;
}
/* Clip 2 */
if (pSeq->maxCandSymbolRateKSps < pSeq->candSymbolRateKSps){
pSeq->maxCandSymbolRateKSps = pSeq->candSymbolRateKSps;
}
if (pSeq->maxCandSymbolRateKSps > (pSeq->candSymbolRateKSps * 2)){
pSeq->maxCandSymbolRateKSps = (pSeq->candSymbolRateKSps * 2);
}
if (pSeq->minCandSymbolRateKSps > pSeq->candSymbolRateKSps){
pSeq->minCandSymbolRateKSps = pSeq->candSymbolRateKSps;
}
/* Set target symbol rate */
result = sony_demod_dvbs_s2_SetSymbolRate (pSeq->pCommonParams->pDemod, pSeq->candSymbolRateKSps);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if(pSeq->candSymbolRateKSps == 0){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
ratioMax = ((pSeq->maxCandSymbolRateKSps * 1024) / (pSeq->candSymbolRateKSps)) - 1024;
ratioMin = ((pSeq->minCandSymbolRateKSps * 1024) / (pSeq->candSymbolRateKSps));
if (ratioMin >= 1024){
ratioMin = 1023;
}
if (ratioMax >= 1024){
ratioMax = 1023;
}
result = sony_demod_dvbs_s2_blindscan_SetSymbolRateRatio (pSeq->pCommonParams->pDemod, ratioMin, ratioMax);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Tune */
pSeq->pCommonParams->tuneReq.isRequest = 1;
pSeq->pCommonParams->tuneReq.frequencyKHz = pSeq->centerFreqKHz;
pSeq->pCommonParams->tuneReq.system = SONY_DTV_SYSTEM_DVBS;
pSeq->pCommonParams->tuneReq.symbolRateKSps = pSeq->maxCandSymbolRateKSps;
pSeq->pCommonParams->waitTime = 0;
pSeq->state = BT_STATE_RF_TUNED;
break;
case BT_STATE_RF_TUNED:
result = sony_demod_SoftReset (pSeq->pCommonParams->pDemod);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_stopwatch_start (&(pSeq->stopwatch));
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->pCommonParams->waitTime = 10;
pSeq->state = BT_STATE_WAIT_SRSFIN;
break;
case BT_STATE_WAIT_SRSFIN:
result = sony_stopwatch_elapsed (&(pSeq->stopwatch), &elapsedTime);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_dvbs_s2_blindscan_GetSRSFIN (pSeq->pCommonParams->pDemod, &srsfin);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if (srsfin){
/* Check TRL lock */
result = sony_demod_dvbs_s2_blindscan_CheckTRLLock (pSeq->pCommonParams->pDemod, &trllock);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if (trllock){
/* Symbol rate information */
result = sony_demod_dvbs_s2_monitor_SymbolRate (pSeq->pCommonParams->pDemod, &detSymbolRateSps);
switch(result)
{
case SONY_RESULT_OK:
/* Set symbol rate */
pSeq->detSymbolRateSps = detSymbolRateSps;
break;
case SONY_RESULT_ERROR_HW_STATE:
/* Not detect */
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT("NG(SR)");
result = finish_ng (pSeq);
SONY_TRACE_RETURN (result);
default:
SONY_TRACE_RETURN (result);
}
detSymbolRateKSps = (detSymbolRateSps + 500) / 1000;
pSeq->timeout = ((3600000 + (detSymbolRateKSps - 1)) / detSymbolRateKSps) + 150;
result = sony_stopwatch_start (&(pSeq->stopwatch));
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->state = BT_STATE_WAIT_TSLOCK;
pSeq->pCommonParams->waitTime = 10;
} else {
/* TRL unlock */
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT("NG(TRL unlock)");
result = finish_ng (pSeq);
}
} else {
if (elapsedTime > 10000){
/* Timeout */
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT("NG(SRS timeout)");
result = finish_ng (pSeq);
} else {
/* Continue */
pSeq->pCommonParams->waitTime = 10;
pSeq->state = BT_STATE_WAIT_SRSFIN;
}
}
break;
case BT_STATE_WAIT_TSLOCK:
result = sony_stopwatch_elapsed (&(pSeq->stopwatch), &elapsedTime);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Monitor TSLock, CarrierOffset, System */
result = sony_demod_dvbs_s2_monitor_ScanInfo (pSeq->pCommonParams->pDemod,
&tslock,
&(pSeq->detCarrierOffsetKHz),
&(pSeq->detSystem));
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if (tslock){
/* Store system information */
pSeq->pCommonParams->pDemod->system = pSeq->detSystem;
/* Success */
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT("OK");
result = finish_ok (pSeq);
SONY_TRACE_RETURN (result);
} else {
if (elapsedTime > pSeq->timeout){
uint8_t plscLock = 0;
uint8_t pilotOn = 0;
/* Not detected channel */
result = sony_demod_dvbs_s2_monitor_Pilot (pSeq->pCommonParams->pDemod, &plscLock, &pilotOn);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if ((plscLock != 0) && (pilotOn == 0)) {
/* Calculate timeout time for Pilot off signal */
detSymbolRateKSps = (pSeq->detSymbolRateSps + 500) / 1000;
pSeq->timeout = ((3600000 + (detSymbolRateKSps - 1)) / detSymbolRateKSps) + 150;
/* Restart timer */
result = sony_stopwatch_start (&(pSeq->stopwatch));
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->state = BT_STATE_WAIT_TSLOCK2;
pSeq->pCommonParams->waitTime = 10;
} else {
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT("NG( TS lock timeout)");
result = finish_ng (pSeq);
SONY_TRACE_RETURN (result);
}
} else {
/* Continue to wait */
}
}
break;
case BT_STATE_WAIT_TSLOCK2:
result = sony_stopwatch_elapsed (&(pSeq->stopwatch), &elapsedTime);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Monitor TSLock, CarrierOffset, System */
result = sony_demod_dvbs_s2_monitor_ScanInfo (pSeq->pCommonParams->pDemod,
&tslock,
&(pSeq->detCarrierOffsetKHz),
&(pSeq->detSystem));
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if (tslock){
/* Store system information */
pSeq->pCommonParams->pDemod->system = pSeq->detSystem;
/* Success */
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT("OK2");
result = finish_ok (pSeq);
SONY_TRACE_RETURN (result);
} else {
if (elapsedTime > pSeq->timeout){
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT("NG2( TS lock timeout)");
result = finish_ng (pSeq);
SONY_TRACE_RETURN (result);
} else {
/* Continue to wait */
}
}
break;
default:
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT("NG(SW state)");
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
SONY_TRACE_RETURN (result);
}
static sony_result_t finish_ok (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq)
{
if(!pSeq) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
pSeq->isLocked = 1;
pSeq->isEnable = 0;
return SONY_RESULT_OK;
}
static sony_result_t finish_ng (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq)
{
if(!pSeq) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
pSeq->isLocked = 0;
pSeq->isEnable = 0;
return SONY_RESULT_OK;
}
@@ -0,0 +1,104 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbs_s2_blindscan_subseq_bt.h
This file provides BT sub sequence for TuneSRS/BlindScan APIs.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_BT_H
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_BT_H
#include "sony_common.h"
#include "sony_dtv.h"
#include "sony_demod_dvbs_s2_blindscan_seq_common.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
/**
@brief State of BT sub sequence
*/
typedef enum {
BT_STATE_INIT, /**< Initialized */
BT_STATE_START, /**< Started */
BT_STATE_RF_TUNED, /**< RF tuned */
BT_STATE_WAIT_SRSFIN, /**< Wait for SRS fin */
BT_STATE_WAIT_TSLOCK, /**< Wait for TS lock */
BT_STATE_WAIT_TSLOCK2, /**< Wait for TS lock (2nd) */
BT_STATE_UNKNOWN /**< Unknown state */
} sony_demod_dvbs_s2_blindscan_bt_state_t;
/**
@brief Structure for BT sub sequence
*/
typedef struct {
/**
@brief Pointer of common parameters used by each sub sequence
*/
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams;
uint8_t isEnable; /**< Enable flag (0: disable, 1: enable) */
sony_demod_dvbs_s2_blindscan_bt_state_t state; /**< State */
sony_stopwatch_t stopwatch; /**< Stopwatch used in this sequence */
uint32_t timeout; /**< Timeout time in ms. */
uint32_t centerFreqKHz; /**< Center frequency in KHz set by main sequence. */
uint32_t candSymbolRateKSps; /**< Candidate symbol rate in KSps set by main sequence. */
uint32_t minCandSymbolRateKSps; /**< Min symbol rate of candidate in KSps set by main sequence. */
uint32_t maxCandSymbolRateKSps; /**< Max symbol rate of candidate in KSps set by main sequence. */
uint32_t minSymbolRateKSps; /**< Min symbol rate of search range set by main sequence. */
uint32_t maxSymbolRateKSps; /**< Max symbol rate of search range set by main sequence. */
/* Result of BT sequence. */
uint8_t isLocked; /**< Lock flag (0 : Not TS locked, 1: TS locked) */
uint32_t detSymbolRateSps; /**< Detected symbol rate in Sps. */
int32_t detCarrierOffsetKHz; /**< Detected carrier offset frequency in KHz. */
sony_dtv_system_t detSystem; /**< Detected system (DVB-S/S2) */
} sony_demod_dvbs_s2_blindscan_subseq_bt_t;
/**
@brief Initialize BT sub sequence
@param pSeq Instance for BT sub sequence.
@param pCommonParams Pointer of common parameters.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_bt_Initialize (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq,
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams);
/**
@brief Start BT sub sequence
@param pSeq Instance for BT sub sequence.
@param centerFreqKHz Center frequency in KHz.
@param candSymbolRateKSps Candidate symbol rate in KSps.
@param minCandSymbolRateKSps Min symbol rate of candidate in KSps.
@param maxCandSymbolRateKSps Max symbol rate of candidate in KSps.
@param minSymbolRateKSps Min symbol rate of search range.
@param maxSymbolRateKSps Max symbol rate of search range.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_bt_Start (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq,
uint32_t centerFreqKHz,
uint32_t candSymbolRateKSps,
uint32_t minCandSymbolRateKSps,
uint32_t maxCandSymbolRateKSps,
uint32_t minSymbolRateKSps,
uint32_t maxSymbolRateKSps);
/**
@brief Execute one sequence for BT sub sequence
@param pSeq Instance for BT sub sequence.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_bt_Sequence (sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeq);
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_BT_H */
@@ -0,0 +1,286 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
#include "sony_common.h"
#include "sony_demod_dvbs_s2_blindscan.h"
#include "sony_demod_dvbs_s2_blindscan_seq.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_pm.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_cs.h"
#include "sony_demod_dvbs_s2_blindscan_trace.h"
/*----------------------------------------------------------------------------
Static Functions
----------------------------------------------------------------------------*/
static sony_result_t get_step_cs (int32_t stepCount, int32_t * pValue);
static sony_result_t finish_ok (sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq);
static sony_result_t finish_ng (sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq);
/*----------------------------------------------------------------------------
Functions
----------------------------------------------------------------------------*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_cs_Initialize (sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq,
sony_demod_dvbs_s2_blindscan_subseq_pm_t * pSeqPM,
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_cs_Initialize");
if ((!pSeq) || (!pSeqPM) || (!pCommonParams)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
pSeq->isEnable = 0;
pSeq->state = CS_STATE_START;
pSeq->pSeqPM = pSeqPM;
pSeq->pCommonParams = pCommonParams;
pSeq->freqOffsetKHz = 0;
SONY_TRACE_RETURN (result);
}
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_cs_Start (sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq,
int32_t freqOffsetKHz)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_cs_Start");
if (!pSeq){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_START (freqOffsetKHz);
pSeq->isEnable = 1;
pSeq->state = CS_STATE_START;
pSeq->freqOffsetKHz = freqOffsetKHz;
pSeq->isExist = 0;
pSeq->coarseSymbolRateKSps = 0;
SONY_TRACE_RETURN (result);
}
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_cs_Sequence(sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq)
{
sony_result_t result = SONY_RESULT_OK;
int32_t power = 0;
int32_t stepFreqKHz = 0;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_cs_Sequence");
if(!pSeq) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
switch(pSeq->state)
{
case CS_STATE_START:
result = sony_demod_dvbs_s2_blindscan_CS_INIT (pSeq->pCommonParams->pDemod);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->pCommonParams->waitTime = 0;
pSeq->state = CS_STATE_PEAK_SEARCH_START;
/* Set init value for index */
pSeq->index = -5;
break;
case CS_STATE_PEAK_SEARCH_START:
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (pSeq->pSeqPM, pSeq->freqOffsetKHz + ((int32_t)(pSeq->index) * 100));
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->state = CS_STATE_PEAK_SEARCHING;
break;
case CS_STATE_PEAK_SEARCHING:
/* Get result */
power = (int32_t)(pSeq->pSeqPM->power);
if ((pSeq->index == -5) || (pSeq->peakPower < power)){
pSeq->peakPower = power;
pSeq->peakFreqOfsKHz = (pSeq->index) * 100;
}
pSeq->index++;
if(pSeq->index <= 5){
/* Continue peak search */
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (pSeq->pSeqPM, pSeq->freqOffsetKHz + (pSeq->index * 100));
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
} else {
/* Next stage */
pSeq->state = CS_STATE_LOWER_SEARCHING;
pSeq->index = 1;
pSeq->isFin = 0;
result = get_step_cs (pSeq->index, &stepFreqKHz);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->lowerFreqKHz = pSeq->freqOffsetKHz + (pSeq->peakFreqOfsKHz - stepFreqKHz);
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (pSeq->pSeqPM, pSeq->lowerFreqKHz);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
}
break;
case CS_STATE_LOWER_SEARCHING:
power = (int32_t)(pSeq->pSeqPM->power);
if ((pSeq->peakPower * 100) > (power * 137)){
/* Next stage */
pSeq->state = CS_STATE_UPPER_SEARCHING;
pSeq->index = 1;
result = get_step_cs (pSeq->index, &stepFreqKHz);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->upperFreqKHz = pSeq->freqOffsetKHz + (pSeq->peakFreqOfsKHz + stepFreqKHz);
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (pSeq->pSeqPM, pSeq->upperFreqKHz);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
} else if ((power * 100) > (pSeq->peakPower * 150)){
/* NG */
pSeq->lowerFreqKHz = -1000; /* Invalid */
result = finish_ng (pSeq);
} else {
pSeq->index++;
if (pSeq->index < 27){
/* Continue */
result = get_step_cs (pSeq->index, &stepFreqKHz);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->lowerFreqKHz = pSeq->freqOffsetKHz + (pSeq->peakFreqOfsKHz - stepFreqKHz);
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (pSeq->pSeqPM, pSeq->lowerFreqKHz);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
} else {
/* NG */
pSeq->lowerFreqKHz = -1000; /* Invalid */
result = finish_ng (pSeq);
}
}
break;
case CS_STATE_UPPER_SEARCHING:
power = (int32_t)(pSeq->pSeqPM->power);
if ((pSeq->peakPower * 100) > (power * 137)){
/* OK */
result = finish_ok (pSeq);
} else if ((power * 100) > (pSeq->peakPower * 150)){
/* NG */
pSeq->upperFreqKHz = -1000; /* Invalid */
result = finish_ng (pSeq);
} else {
pSeq->index++;
if (pSeq->index < 27){
/* Continue */
result = get_step_cs (pSeq->index, &stepFreqKHz);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->upperFreqKHz = pSeq->freqOffsetKHz + (pSeq->peakFreqOfsKHz + stepFreqKHz);
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (pSeq->pSeqPM, pSeq->upperFreqKHz);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
} else {
/* NG */
pSeq->upperFreqKHz = -1000; /* Invalid */
result = finish_ng (pSeq);
}
}
break;
default:
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
SONY_TRACE_RETURN (result);
}
/*----------------------------------------------------------------------------
Static Functions
----------------------------------------------------------------------------*/
static sony_result_t get_step_cs (int32_t stepCount, int32_t * pValue)
{
static const int32_t step_table[] = {
0, /* 100(KHz) * 0 */
100, /* 100(KHz) * 1 */
200, /* 100(KHz) * 2 */
300, /* 100(KHz) * 3 */
400, /* 400(KHz) * (1.1^0) */
440, /* 400(KHz) * (1.1^1) */
484, /* 400(KHz) * (1.1^2) */
532, /* 400(KHz) * (1.1^3) */
586, /* 400(KHz) * (1.1^4) */
644, /* 400(KHz) * (1.1^5) */
709, /* 400(KHz) * (1.1^6) */
779, /* 400(KHz) * (1.1^7) */
857, /* 400(KHz) * (1.1^8) */
943, /* 400(KHz) * (1.1^9) */
1037, /* 400(KHz) * (1.1^10) */
1141, /* 400(KHz) * (1.1^11) */
1255, /* 400(KHz) * (1.1^12) */
1381, /* 400(KHz) * (1.1^13) */
1519, /* 400(KHz) * (1.1^14) */
1671, /* 400(KHz) * (1.1^15) */
1838, /* 400(KHz) * (1.1^16) */
2022, /* 400(KHz) * (1.1^17) */
2224, /* 400(KHz) * (1.1^18) */
2446, /* 400(KHz) * (1.1^19) */
2691, /* 400(KHz) * (1.1^20) */
2960, /* 400(KHz) * (1.1^21) */
3256, /* 400(KHz) * (1.1^22) */
3582 /* 400(KHz) * (1.1^23) */
};
SONY_TRACE_ENTER ("get_step_cs");
if ((!pValue) || (stepCount < 0) || (stepCount > 27)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
*pValue = step_table[stepCount];
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
static sony_result_t finish_ok (sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("finish_ok");
if(!pSeq) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if (pSeq->upperFreqKHz > pSeq->lowerFreqKHz){
pSeq->coarseSymbolRateKSps = (uint32_t)(pSeq->upperFreqKHz - pSeq->lowerFreqKHz);
pSeq->isExist = 1;
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_RESULT(pSeq->coarseSymbolRateKSps);
} else {
pSeq->coarseSymbolRateKSps = 0;
pSeq->isExist = 0;
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_RESULT(1);
}
pSeq->isEnable = 0;
result = sony_demod_dvbs_s2_blindscan_CS_FIN (pSeq->pCommonParams->pDemod);
SONY_TRACE_RETURN (result);
}
static sony_result_t finish_ng (sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("finish_ng");
if(!pSeq) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
pSeq->coarseSymbolRateKSps = 0;
pSeq->isExist = 0;
pSeq->isEnable = 0;
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_RESULT(0);
result = sony_demod_dvbs_s2_blindscan_CS_FIN (pSeq->pCommonParams->pDemod);
SONY_TRACE_RETURN (result);
}
@@ -0,0 +1,97 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbs_s2_blindscan_subseq_cs.h
This file provides CS sub sequence for TuneSRS/BlindScan.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_CS_H
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_CS_H
#include "sony_common.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_pm.h"
/**
@brief State of CS sub sequence
*/
typedef enum {
CS_STATE_START, /**< Start */
CS_STATE_PEAK_SEARCH_START, /**< Peak search start */
CS_STATE_PEAK_SEARCHING, /**< Peak searching */
CS_STATE_LOWER_SEARCHING, /**< Lower edge searching */
CS_STATE_UPPER_SEARCHING, /**< Upper edge searching */
CS_STATE_UNKNOWN /**< Unknown */
} sony_demod_dvbs_s2_blindscan_cs_state_t;
/**
@brief Structure for CS sub sequence
*/
typedef struct {
/**
@brief Pointer of common parameters used by each sub sequence
*/
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams;
/**
@brief Pointer of PM sub sequence instance
*/
sony_demod_dvbs_s2_blindscan_subseq_pm_t * pSeqPM;
uint8_t isEnable; /**< Enable flag (0: disable, 1: enable). */
sony_demod_dvbs_s2_blindscan_cs_state_t state; /**< State. */
uint32_t agcLevel; /**< AGC level from register. */
int32_t agc_x100dB; /**< Calculated AGC (x 100dB) by tuner driver. */
int8_t index; /**< Index for internal use. */
int32_t peakPower; /**< Peak power. */
int32_t peakFreqOfsKHz; /**< Peak frequency offset in KHz. */
int32_t lowerFreqKHz; /**< Lower frequency in KHz. */
int32_t upperFreqKHz; /**< Upper frequency in KHz. */
uint8_t isFin; /**< Flags whether this sequence finished or not. */
int32_t freqOffsetKHz; /**< Frequency offset in KHz. */
uint8_t isExist; /**< Result of this CS sub sequence (0 : Signal is not exist, 1 : Signal is exist) */
uint32_t coarseSymbolRateKSps; /**< Result of this CS sub sequence (Symbol rate in KSps) */
} sony_demod_dvbs_s2_blindscan_subseq_cs_t;
/**
@brief Initialize CS sub sequence
@param pSeq Instance for CS sub sequence.
@param pSeqPM Pointer of PM sub sequence instance.
@param pCommonParams Pointer of common parameters.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_cs_Initialize (sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq,
sony_demod_dvbs_s2_blindscan_subseq_pm_t * pSeqPM,
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams);
/**
@brief Start CS sub sequence
@param pSeq Instance for CS sub sequence.
@param freqOffsetKHz Frequency offset in KHz.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_cs_Start (sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq,
int32_t freqOffsetKHz);
/**
@brief Execute one sequence for CS sub sequence
@param pSeq Instance for CS sub sequence.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_cs_Sequence (sony_demod_dvbs_s2_blindscan_subseq_cs_t * pSeq);
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_CS_H */
@@ -0,0 +1,239 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
#include "sony_common.h"
#include "sony_demod_dvbs_s2_monitor.h"
#include "sony_demod_dvbs_s2_blindscan.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
#include "sony_demod_dvbs_s2_blindscan_seq.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_fs.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_bt.h"
/*----------------------------------------------------------------------------
Static Functions
----------------------------------------------------------------------------*/
static sony_result_t finish_ok (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq);
static sony_result_t updateProgress (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq);
/*----------------------------------------------------------------------------
Functions
----------------------------------------------------------------------------*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_fs_Initialize (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq,
sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeqBT,
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams)
{
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_fs_Initialize");
if ((!pSeq) || (!pSeqBT) || (!pCommonParams)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
pSeq->isEnable = 0;
pSeq->state = FS_STATE_START;
pSeq->pSeqBT = pSeqBT;
pSeq->pCommonParams = pCommonParams;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_fs_Start (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq,
sony_demod_dvbs_s2_blindscan_data_t * pCandList,
uint32_t minSymbolRateKSps,
uint32_t maxSymbolRateKSps,
sony_demod_dvbs_s2_blindscan_data_t * pChannelList)
{
sony_result_t result = SONY_RESULT_OK;
sony_demod_dvbs_s2_blindscan_data_t * pCurrent = NULL;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_fs_Start");
if ((!pSeq) || (!pCandList) || (!pChannelList)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
pSeq->isEnable = 1;
pSeq->state = FS_STATE_START;
pSeq->pCandList = pCandList;
pSeq->pCandCurrent = pSeq->pCandList->pNext;
pSeq->pChannelList = pChannelList;
pSeq->minSymbolRateKSps = minSymbolRateKSps;
pSeq->maxSymbolRateKSps = maxSymbolRateKSps;
pSeq->candIndex = 1;
pSeq->candCount = 1;
pCurrent = pCandList->pNext;
while(pCurrent){
pSeq->candCount++;
pCurrent = pCurrent->pNext;
}
result = updateProgress (pSeq);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->pChannelLast = pChannelList;
while(pSeq->pChannelLast->pNext){
pSeq->pChannelLast = pSeq->pChannelLast->pNext;
}
SONY_TRACE_RETURN (result);
}
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_fs_Sequence (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq)
{
sony_result_t result = SONY_RESULT_OK;
sony_demod_dvbs_s2_blindscan_data_t * pTemp = NULL;
sony_demod_dvbs_s2_blindscan_data_t * pChannelCurrent = NULL;
uint32_t candFreq = 0;
uint32_t candSR = 0;
uint32_t candMinSR = 0;
uint32_t candMaxSR = 0;
uint32_t channelFreq = 0;
uint32_t channelSR = 0;
uint8_t isTry = 0;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_fs_Sequence");
if(!pSeq) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
switch(pSeq->state)
{
case FS_STATE_START:
result = updateProgress (pSeq);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if (pSeq->pCandCurrent){
/* Cand is exist */
candFreq = pSeq->pCandCurrent->data.candidate.centerFreqKHz;
candSR = pSeq->pCandCurrent->data.candidate.symbolRateKSps;
candMinSR = pSeq->pCandCurrent->data.candidate.minSymbolRateKSps;
candMaxSR = pSeq->pCandCurrent->data.candidate.maxSymbolRateKSps;
isTry = 1;
if (candMaxSR > pSeq->minSymbolRateKSps){
pChannelCurrent = pSeq->pChannelList->pNext;
while(pChannelCurrent){
channelFreq = pChannelCurrent->data.candidate.centerFreqKHz;
channelSR = pChannelCurrent->data.candidate.symbolRateKSps;
if (((channelFreq - (channelSR/2)) <= candFreq) && (candFreq <= (channelFreq + (channelSR/2)))){
/* duplicated */
isTry = 0;
break;
}
/* Next channel */
pChannelCurrent = pChannelCurrent->pNext;
}
} else {
isTry = 0;
}
pSeq->candIndex++;
pSeq->pCandCurrent = pSeq->pCandCurrent->pNext;
if ((isTry) && (candMaxSR > 1000)) {
result = sony_demod_dvbs_s2_blindscan_subseq_bt_Start (pSeq->pSeqBT,
candFreq,
candSR,
candMinSR,
candMaxSR,
pSeq->minSymbolRateKSps,
pSeq->maxSymbolRateKSps);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->state = FS_STATE_WAIT_BTFIN;
pSeq->pCommonParams->waitTime =0;
}
} else {
/* Finish */
result = finish_ok(pSeq);
}
break;
case FS_STATE_WAIT_BTFIN:
/* Check result */
if (pSeq->pSeqBT->isLocked){
uint8_t isExist = 0;
sony_demod_dvbs_s2_blindscan_data_t * pCurrent = pSeq->pChannelList->pNext;
uint32_t detFrequencyKHz = (uint32_t)((int32_t)(pSeq->pCommonParams->tuneReq.frequencyKHz) + pSeq->pSeqBT->detCarrierOffsetKHz);
uint32_t detSymbolRateKSps = (pSeq->pSeqBT->detSymbolRateSps + 500) / 1000;
uint32_t chFrequencyKHz = 0;
uint32_t chSymbolRateKSps = 0;
isExist = 0;
while(pCurrent){
chFrequencyKHz = pCurrent->data.channelInfo.centerFreqKHz;
chSymbolRateKSps = pCurrent->data.channelInfo.symbolRateKSps/2;
if ((detFrequencyKHz >= (chFrequencyKHz - chSymbolRateKSps)) &&
(detFrequencyKHz <= (chFrequencyKHz + chSymbolRateKSps))){
/* It is already detected channel */
isExist = 1;
break;
}
pCurrent = pCurrent->pNext;
}
if (isExist == 0){
/* Detect signal */
pSeq->pCommonParams->detInfo.isDetect = 1;
pSeq->pCommonParams->detInfo.centerFreqKHz = detFrequencyKHz;
pSeq->pCommonParams->detInfo.symbolRateKSps = detSymbolRateKSps;
pSeq->pCommonParams->detInfo.system = pSeq->pSeqBT->detSystem;
result = sony_demod_dvbs_s2_blindscan_AllocData (&(pSeq->pCommonParams->storage), &pTemp);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pTemp->data.channelInfo.centerFreqKHz = pSeq->pCommonParams->detInfo.centerFreqKHz;
pTemp->data.channelInfo.symbolRateKSps = pSeq->pCommonParams->detInfo.symbolRateKSps;
pTemp->data.channelInfo.system = pSeq->pCommonParams->detInfo.system;
pSeq->pChannelLast->pNext = pTemp;
pSeq->pChannelLast = pSeq->pChannelLast->pNext;
}
} else {
/* Unlock */
pSeq->pCommonParams->detInfo.isDetect = 0;
}
pSeq->state = FS_STATE_START;
pSeq->pCommonParams->waitTime = 0;
break;
default:
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
SONY_TRACE_RETURN (result);
}
static sony_result_t finish_ok (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq)
{
SONY_TRACE_ENTER ("finish_ok");
if(!pSeq) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
pSeq->isEnable = 0;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
static sony_result_t updateProgress (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq)
{
SONY_TRACE_ENTER ("updateProgress");
if(!pSeq) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if (pSeq->candIndex > pSeq->candCount){
pSeq->candIndex = pSeq->candCount;
}
pSeq->pCommonParams->progressInfo.minorProgress = (uint8_t)((pSeq->candIndex * 100) / pSeq->candCount);
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
@@ -0,0 +1,100 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/27
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbs_s2_blindscan_subseq_fs.h
This file provides FS sub sequence for TuneSRS/BlindScan.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_FS_H
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_FS_H
#include "sony_common.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_bt.h"
/**
@brief State of FS sub sequence
*/
typedef enum {
FS_STATE_START, /**< Start */
FS_STATE_WAIT_BTFIN, /**< Wait for BT fin */
FS_STATE_FINISH, /**< Finish FS */
FS_STATE_UNKNOWN /**< Unknown */
} sony_demod_dvbs_s2_blindscan_fs_state_t;
/**
@brief Structure for FS sub sequence
*/
typedef struct {
/**
@brief Pointer of common parameters used by each sub sequence
*/
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams;
/**
@brief Pointer of BT sub sequence instance
*/
sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeqBT;
uint8_t isEnable; /**< Enable flag (0: disable, 1: enable). */
sony_demod_dvbs_s2_blindscan_fs_state_t state; /**< State. */
sony_demod_dvbs_s2_blindscan_data_t * pCandList; /**< Candidate list */
sony_demod_dvbs_s2_blindscan_data_t * pChannelList; /**< Detected channel list */
uint32_t minSymbolRateKSps; /**< Min symbol rate of search range in KSps */
uint32_t maxSymbolRateKSps; /**< Max symbol rate of search range in KSps */
sony_demod_dvbs_s2_blindscan_data_t * pCandCurrent; /**< Pointer of current candidate */
sony_demod_dvbs_s2_blindscan_data_t * pChannelLast; /**< The last pointer of detected channel list */
uint32_t candFreq; /**< Frequency of candidate in KHz. */
uint32_t candCount; /**< Candidate number for calculate progress. */
uint32_t candIndex; /**< Candidate index for calculate progress. */
} sony_demod_dvbs_s2_blindscan_subseq_fs_t;
/**
@brief Initialize FS sub sequence
@param pSeq Instance for FS sub sequence.
@param pSeqBT Pointer of BT sub sequence instance.
@param pCommonParams Pointer of common parameters.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_fs_Initialize (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq,
sony_demod_dvbs_s2_blindscan_subseq_bt_t * pSeqBT,
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams);
/**
@brief Start CS sub sequence
@param pSeq Instance for FS sub sequence.
@param pCandList Candidate list.
@param minSymbolRateKSps Min symbol rate of search range in KSps.
@param maxSymbolRateKSps Max symbol rate of search range in KSps.
@param pChannelList Detected channel list.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_fs_Start (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq,
sony_demod_dvbs_s2_blindscan_data_t * pCandList,
uint32_t minSymbolRateKSps,
uint32_t maxSymbolRateKSps,
sony_demod_dvbs_s2_blindscan_data_t * pChannelList);
/**
@brief Execute one sequence for FS sub sequence
@param pSeq Instance for FS sub sequence.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_fs_Sequence (sony_demod_dvbs_s2_blindscan_subseq_fs_t * pSeq);
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_FS_H */
@@ -0,0 +1,117 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
#include "sony_common.h"
#include "sony_demod_dvbs_s2_blindscan.h"
#include "sony_demod_dvbs_s2_blindscan_seq.h"
#include "sony_demod_dvbs_s2_blindscan_trace.h"
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_pm_Initialize (sony_demod_dvbs_s2_blindscan_subseq_pm_t * pSeq,
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams)
{
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_pm_Initialize");
if ((!pSeq) || (!pCommonParams)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
pSeq->isEnable = 0;
pSeq->state = PM_STATE_START;
pSeq->pCommonParams = pCommonParams;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_pm_Start (sony_demod_dvbs_s2_blindscan_subseq_pm_t * pSeq,
int32_t freqOffsetKHz)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_pm_Start");
if(!pSeq) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
pSeq->isEnable = 1;
pSeq->state = PM_STATE_START;
pSeq->freqOffsetKHz = freqOffsetKHz;
pSeq->power = 0;
SONY_TRACE_RETURN (result);
}
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_pm_Sequence (sony_demod_dvbs_s2_blindscan_subseq_pm_t * pSeq)
{
sony_result_t result = SONY_RESULT_OK;
uint32_t elapsedTime = 0;
uint8_t csfin = 0;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_pm_Sequence");
if(!pSeq) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
switch(pSeq->state)
{
case PM_STATE_START:
result = sony_demod_dvbs_s2_blindscan_SetCFFine (pSeq->pCommonParams->pDemod, pSeq->freqOffsetKHz);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Scan start */
result = sony_demod_dvbs_s2_blindscan_PS_START (pSeq->pCommonParams->pDemod);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->state = PM_STATE_WAITING_CSFIN;
pSeq->pCommonParams->waitTime = 0;
result = sony_stopwatch_start (&pSeq->stopwatch);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
break;
case PM_STATE_WAITING_CSFIN:
result = sony_stopwatch_elapsed (&pSeq->stopwatch, &elapsedTime);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_dvbs_s2_blindscan_GetCSFIN (pSeq->pCommonParams->pDemod, &csfin);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if (csfin){
result = sony_demod_dvbs_s2_blindscan_GetPSPow (pSeq->pCommonParams->pDemod, &pSeq->power);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Scan ack */
result = sony_demod_dvbs_s2_blindscan_PS_RACK (pSeq->pCommonParams->pDemod);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* End */
pSeq->isEnable = 0;
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_PM_POWER (pSeq->freqOffsetKHz, pSeq->power);
} else {
if (elapsedTime >= 1000){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_TIMEOUT);
} else {
/* Continue to wait */
}
}
break;
default:
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
SONY_TRACE_RETURN (result);
}
@@ -0,0 +1,79 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbs_s2_blindscan_subseq_pm.h
This file provides PM sub sequence for TuneSRS/BlindScan.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_PM_H
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_PM_H
#include "sony_common.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
/**
@brief State of PM sub sequence
*/
typedef enum {
PM_STATE_START, /**< Start */
PM_STATE_WAITING_CSFIN, /**< Wait for CS fin */
PM_STATE_UNKNOWN /**< Unknown */
} sony_demod_dvbs_s2_blindscan_pm_state_t;
/**
@brief Structure for PM sub sequence
*/
typedef struct {
/**
@brief Pointer of common parameters used by each sub sequence
*/
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams;
uint8_t isEnable; /**< Enable flag (0: disable, 1: enable). */
sony_demod_dvbs_s2_blindscan_pm_state_t state; /**< State. */
sony_stopwatch_t stopwatch; /**< Stopwatch for internal use. */
int32_t freqOffsetKHz; /**< Frequency offset in KHz. */
uint16_t power; /**< Power value */
} sony_demod_dvbs_s2_blindscan_subseq_pm_t;
/**
@brief Initialize PM sub sequence
@param pSeq Instance for PM sub sequence.
@param pCommonParams Pointer of common parameters.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_pm_Initialize (sony_demod_dvbs_s2_blindscan_subseq_pm_t * pSeq,
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams);
/**
@brief Start PM sub sequence
@param pSeq Instance for PM sub sequence.
@param freqOffsetKHz Frequency offset in KHz.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_pm_Start (sony_demod_dvbs_s2_blindscan_subseq_pm_t * pSeq,
int32_t freqOffsetKHz);
/**
@brief Execute one sequence for PM sub sequence
@param pSeq Instance for PM sub sequence.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_pm_Sequence (sony_demod_dvbs_s2_blindscan_subseq_pm_t * pSeq);
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_PM_H */
@@ -0,0 +1,257 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
#include "sony_common.h"
#include "sony_math.h"
#include "sony_demod.h"
#include "sony_demod_dvbs_s2.h"
#include "sony_demod_dvbs_s2_monitor.h"
#include "sony_demod_dvbs_s2_blindscan.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
#include "sony_demod_dvbs_s2_blindscan_utility.h"
#include "sony_demod_dvbs_s2_blindscan_seq.h"
/*----------------------------------------------------------------------------
Functions
----------------------------------------------------------------------------*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_ss_Initialize (sony_demod_dvbs_s2_blindscan_subseq_ss_t * pSeq,
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_ss_Initialize");
if ((!pSeq) || (!pCommonParams)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
pSeq->isEnable = 0;
pSeq->state = SS_STATE_INIT;
pSeq->maxFreqKHz = 0;
pSeq->minFreqKHz = 0;
pSeq->stepFreqKHz = 0;
pSeq->tunerStepFreqKHz = 0;
pSeq->pCommonParams = pCommonParams;
result = sony_demod_dvbs_s2_blindscan_AllocPower (&(pSeq->pCommonParams->storage), &(pSeq->pPowerList));
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
SONY_TRACE_RETURN (result);
}
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_ss_Start (sony_demod_dvbs_s2_blindscan_subseq_ss_t * pSeq,
uint32_t minFreqKHz,
uint32_t maxFreqKHz,
uint32_t stepFreqKHz,
uint32_t tunerStepFreqKHz,
uint8_t powerSmooth)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_ss_Start");
if (!pSeq){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
pSeq->isEnable = 1;
pSeq->state = SS_STATE_START;
pSeq->minFreqKHz = minFreqKHz;
pSeq->maxFreqKHz = maxFreqKHz;
pSeq->stepFreqKHz = stepFreqKHz;
pSeq->tunerStepFreqKHz = tunerStepFreqKHz;
pSeq->pCommonParams->waitTime = 0;
pSeq->ocfr_csk = powerSmooth;
result = sony_demod_dvbs_s2_blindscan_ClearPowerList (&(pSeq->pCommonParams->storage), pSeq->pPowerList);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->pPowerListLast = pSeq->pPowerList;
SONY_TRACE_RETURN (result);
}
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_ss_Sequence(sony_demod_dvbs_s2_blindscan_subseq_ss_t * pSeq)
{
sony_result_t result = SONY_RESULT_OK;
uint8_t csfin = 0;
uint8_t csrdend = 0;
int32_t csfreq = 0;
uint32_t cspow = 0;
uint32_t elapsedTime = 0;
int32_t offsetFreq = 0;
uint32_t ckaFreqKHz = 0;
sony_demod_dvbs_s2_blindscan_power_t * pTempPower = NULL;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_blindscan_subseq_ss_Sequence");
if(!pSeq) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
switch(pSeq->state)
{
case SS_STATE_START:
result = sony_demod_dvbs_s2_blindscan_PS_INIT (pSeq->pCommonParams->pDemod, pSeq->ocfr_csk);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
offsetFreq = (int32_t)pSeq->tunerStepFreqKHz / 2;
ckaFreqKHz = pSeq->pCommonParams->ckahFreqKHz;
result = sony_demod_dvbs_s2_blindscan_PS_SET (pSeq->pCommonParams->pDemod,
-offsetFreq,
offsetFreq,
pSeq->stepFreqKHz,
ckaFreqKHz);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->currentFreqKHz = (uint32_t)((int32_t)pSeq->minFreqKHz + offsetFreq);
pSeq->state = SS_STATE_RF_TUNING;
pSeq->pCommonParams->waitTime = 0;
break;
case SS_STATE_RF_TUNING:
pSeq->pCommonParams->tuneReq.isRequest = 1;
pSeq->pCommonParams->tuneReq.frequencyKHz = pSeq->currentFreqKHz;
pSeq->pCommonParams->tuneReq.system = SONY_DTV_SYSTEM_DVBS;
pSeq->pCommonParams->tuneReq.symbolRateKSps = 0;
pSeq->pCommonParams->waitTime = 0;
pSeq->state = SS_STATE_RF_TUNED;
break;
case SS_STATE_RF_TUNED:
result = sony_demod_dvbs_s2_monitor_IFAGCOut (pSeq->pCommonParams->pDemod, &(pSeq->agcLevel));
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->pCommonParams->agcInfo.isRequest = 1;
pSeq->pCommonParams->agcInfo.agcLevel = pSeq->agcLevel;
pSeq->pCommonParams->waitTime = 0;
pSeq->state = SS_STATE_AGC_CALCULATED;
break;
case SS_STATE_AGC_CALCULATED:
pSeq->agc_x100dB = pSeq->pCommonParams->agcInfo.agc_x100dB;
result = sony_demod_dvbs_s2_blindscan_PS_START (pSeq->pCommonParams->pDemod);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_stopwatch_start (&pSeq->stopwatch);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->state = SS_STATE_WAIT_CSFIN;
pSeq->pCommonParams->waitTime = 10;
break;
case SS_STATE_WAIT_CSFIN:
result = sony_stopwatch_elapsed (&pSeq->stopwatch, &elapsedTime);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_dvbs_s2_blindscan_GetCSFIN (pSeq->pCommonParams->pDemod, &csfin);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if (csfin){
pSeq->state = SS_STATE_READ_CS;
pSeq->pCommonParams->waitTime = 0;
} else {
if (elapsedTime > 10000){
/* Timeout error */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_TIMEOUT);
}
}
break;
case SS_STATE_READ_CS:
result = sony_demod_dvbs_s2_blindscan_GetCSRDEND(pSeq->pCommonParams->pDemod, &csrdend);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if (csrdend){
if ((pSeq->currentFreqKHz + (pSeq->tunerStepFreqKHz / 2)) < pSeq->maxFreqKHz){
pSeq->currentFreqKHz += pSeq->tunerStepFreqKHz;
pSeq->state = SS_STATE_RF_TUNING;
pSeq->pCommonParams->waitTime = 0;
/* Go to next loop */
} else {
pSeq->state = SS_STATE_END;
pSeq->pCommonParams->waitTime = 0;
}
} else {
ckaFreqKHz = pSeq->pCommonParams->ckahFreqKHz;
result = sony_demod_dvbs_s2_blindscan_GetCSINFO (pSeq->pCommonParams->pDemod, &csfreq, &cspow);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Add to power list */
result = sony_demod_dvbs_s2_blindscan_AllocPower (&(pSeq->pCommonParams->storage), &pTempPower);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Power data (frequency) */
if (csfreq >= 0){
pTempPower->freqKHz = (uint32_t)((int32_t)(pSeq->pCommonParams->tuneReq.frequencyKHz) + (((csfreq * (int32_t)ckaFreqKHz) + (int32_t)1024) / (int32_t)2048));
} else {
pTempPower->freqKHz = (uint32_t)((int32_t)(pSeq->pCommonParams->tuneReq.frequencyKHz) + (((csfreq * (int32_t)ckaFreqKHz) - (int32_t)1024) / (int32_t)2048));
}
if (pTempPower->freqKHz > pSeq->maxFreqKHz){
result = sony_demod_dvbs_s2_blindscan_FreePower (&(pSeq->pCommonParams->storage), pTempPower);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
} else {
/*
* Power[dB] = 10 * log10 (CSPOW/2^14) - gain_db
* Power[x100dB] = (1000 * log10 (CSPOW/2^14)) - gain_db_x100
* = (1000 * (log10(CSPOW) - log10(2^14))) - gain_db_x100
* = (10 * (log10(CSPOW) - 421)) - gain_db_x100
*
* log10() in this driver returns "result x 100".
*/
pTempPower->power = (int32_t)((sony_math_log10 (cspow) - 421) * 10) - pSeq->pCommonParams->agcInfo.agc_x100dB;
/* Add data to list */
pSeq->pPowerListLast->pNext = pTempPower;
pSeq->pPowerListLast = pSeq->pPowerListLast->pNext;
}
result = sony_demod_dvbs_s2_blindscan_PS_RACK (pSeq->pCommonParams->pDemod);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
}
break;
case SS_STATE_END:
pSeq->isEnable = 0;
result = sony_demod_dvbs_s2_blindscan_PS_FIN (pSeq->pCommonParams->pDemod);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->pCommonParams->waitTime = 0;
break;
default:
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
SONY_TRACE_RETURN (result);
}
@@ -0,0 +1,103 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbs_s2_blindscan_subseq_ss.h
This file provides SS sub sequence for TuneSRS/BlindScan.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_SS_H
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_SS_H
#include "sony_common.h"
#include "sony_demod_dvbs_s2_blindscan_seq_common.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
/**
@brief State of SS sub sequence
*/
typedef enum {
SS_STATE_INIT, /**< Initialized */
SS_STATE_START, /**< Start */
SS_STATE_RF_TUNING, /**< RF tuning */
SS_STATE_RF_TUNED, /**< RF tuned */
SS_STATE_AGC_CALCULATED, /**< AGC calculating */
SS_STATE_WAIT_CSFIN, /**< Wait for CSFIN */
SS_STATE_READ_CS, /**< Read CS data */
SS_STATE_END, /**< End */
SS_STATE_UNKNOWN /**< Unknown */
} sony_demod_dvbs_s2_blindscan_ss_state_t;
/**
@brief Structure for SS sub sequence
*/
typedef struct {
/**
@brief Pointer of common parameters used by each sub sequence
*/
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams;
uint8_t isEnable; /**< Enable flag (0: disable, 1: enable). */
sony_demod_dvbs_s2_blindscan_ss_state_t state; /**< State. */
sony_stopwatch_t stopwatch; /**< Stopwatch for internal use. */
uint32_t minFreqKHz; /**< Min frequency in KHz. */
uint32_t maxFreqKHz; /**< Max frequency in KHz. */
uint32_t stepFreqKHz; /**< Resolution in KHz. */
uint32_t tunerStepFreqKHz; /**< RF step frequency in KHz. */
uint32_t currentFreqKHz; /**< Current frequency in KHz. */
uint32_t agcLevel; /**< AGC level from register. */
int32_t agc_x100dB; /**< AGC (x 100dB) calculated by tuner driver. */
sony_demod_dvbs_s2_blindscan_power_t * pPowerList; /**< Power list. */
sony_demod_dvbs_s2_blindscan_power_t * pPowerListLast; /**< The last item of power list. */
uint8_t ocfr_csk; /**< The register value of OCFR_CSK (1 - 7). */
} sony_demod_dvbs_s2_blindscan_subseq_ss_t;
/**
@brief Initialize SS sub sequence
@param pSeq Instance for SS sub sequence.
@param pCommonParams Pointer of common parameters.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_ss_Initialize (sony_demod_dvbs_s2_blindscan_subseq_ss_t * pSeq,
sony_demod_dvbs_s2_blindscan_seq_common_t * pCommonParams);
/**
@brief Start SS sub sequence
@param pSeq Instance for SS sub sequence.
@param minFreqKHz Min frequency in KHz.
@param maxFreqKHz Max frequency in KHz.
@param stepFreqKHz Resolution in KHz.
@param tunerStepFreqKHz RF step frequency in KHz.
@param powerSmooth power spectrum smoothing value.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_ss_Start (sony_demod_dvbs_s2_blindscan_subseq_ss_t * pSeq,
uint32_t minFreqKHz,
uint32_t maxFreqKHz,
uint32_t stepFreqKHz,
uint32_t tunerStepFreqKHz,
uint8_t powerSmooth);
/**
@brief Execute one sequence for SS sub sequence
@param pSeq Instance for SS sub sequence.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_subseq_ss_Sequence (sony_demod_dvbs_s2_blindscan_subseq_ss_t * pSeq);
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_SUBSEQ_SS_H */
@@ -0,0 +1,119 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/09/28
Modification ID : 1ea04def104d657deb64f0d0b0cae6ef992a9dd8
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbs_s2_blindscan_trace.h
This file provides trace functions definication.
If you would like to use this trace functions for TuneSRS/BlindScan,
please enable "SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_ENABLE" definition,
and implement following functions.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_H
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_H
#include "sony_common.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
#ifdef SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_ENABLE
/**
@brief Start trace function.
This function is called at the beginning of TuneSRS/BlindScan.
If you have any process to do at this timing, please implement it in this function.
(i.e. Open output file, etc...)
*/
void sony_demod_dvbs_s2_blindscan_trace_init (void);
/**
@brief Output power list.
@param name The event name.
@param pList Power data list.
*/
void sony_demod_dvbs_s2_blindscan_trace_powerlist (char * name, sony_demod_dvbs_s2_blindscan_power_t * pList);
/**
@brief Output candidate list.
@param name The event name.
@param pList Candidate data list.
*/
void sony_demod_dvbs_s2_blindscan_trace_candlist (char * name, sony_demod_dvbs_s2_blindscan_data_t * pList);
/**
@brief Start BT sub sequence.
@param freqKHz Frequency in KHz.
@param candSR Candidate symbol rate in KSps.
@param minCandSR Min candidate symbol rate in KSps.
@param maxCandSR Max candidate symbol rate in KSps.
@param minSR Min search range symbol rate in KSps.
@param maxSR Max search range symbol rate in KSps.
*/
void sony_demod_dvbs_s2_blindscan_trace_bt_start (uint32_t freqKHz, uint32_t candSR, uint32_t minCandSR, uint32_t maxCandSR, uint32_t minSR, uint32_t maxSR);
/**
@brief Finish BT sub sequence.
@param eventName The result of that BT sub sequence.
*/
void sony_demod_dvbs_s2_blindscan_trace_bt_result (char * eventName);
/**
@brief RF tune for CS sub sequence.
@param freqKHz Frequency in KHz.
*/
void sony_demod_dvbs_s2_blindscan_trace_cs_tune (uint32_t freqKHz);
/**
@brief Start CS sub sequence.
@param offsetFreqKHz Frequency offset in KHz.
*/
void sony_demod_dvbs_s2_blindscan_trace_cs_start (int32_t offsetFreqKHz);
/**
@brief Finish CS sub sequence.
@param coarseSR Detected symbol rate in KSps.
If symbol rate was not detected coarseSR is 0 or 1.
*/
void sony_demod_dvbs_s2_blindscan_trace_cs_result (uint32_t coarseSR);
/**
@brief PM sub sequence.
@param offsetFreqKHz Frequency offset in KHz.
@param power Power value.
*/
void sony_demod_dvbs_s2_blindscan_trace_pm_power (int32_t offsetFreqKHz, int32_t power);
/**
@brief End trace function.
This function is called at the ending of TuneSRS/BlindScan.
If you have any process to do at this timing, please implement it in this function.
(i.e. Close output file, etc...)
*/
void sony_demod_dvbs_s2_blindscan_trace_fin (void);
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_INIT() sony_demod_dvbs_s2_blindscan_trace_init()
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_POWERLIST(A, B) sony_demod_dvbs_s2_blindscan_trace_powerlist(A, B)
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CANDLIST(A, B) sony_demod_dvbs_s2_blindscan_trace_candlist(A, B)
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_START(A, B, C, D, E, F) sony_demod_dvbs_s2_blindscan_trace_bt_start(A, B, C, D, E, F)
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT(A) sony_demod_dvbs_s2_blindscan_trace_bt_result(A)
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_TUNE(A) sony_demod_dvbs_s2_blindscan_trace_cs_tune(A)
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_START(A) sony_demod_dvbs_s2_blindscan_trace_cs_start(A)
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_RESULT(A) sony_demod_dvbs_s2_blindscan_trace_cs_result(A)
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_PM_POWER(A, B) sony_demod_dvbs_s2_blindscan_trace_pm_power(A, B)
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_FIN() sony_demod_dvbs_s2_blindscan_trace_fin()
#else /* SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_ENABLE */
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_INIT()
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_POWERLIST(A, B)
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CANDLIST(A, B)
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_START(A, B, C, D, E, F)
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_BT_RESULT(A)
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_TUNE(A)
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_START(A)
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_RESULT(A)
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_PM_POWER(A, B)
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_FIN()
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_ENABLE */
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_H */
@@ -0,0 +1,264 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
#include "sony_common.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
/*----------------------------------------------------------------------------
Static Functions
----------------------------------------------------------------------------*/
static sony_result_t incrementMemCount (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage);
static sony_result_t decrementMemCount (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage);
static sony_result_t incrementPowCount (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage);
static sony_result_t decrementPowCount (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage);
/*----------------------------------------------------------------------------
Functions
----------------------------------------------------------------------------*/
sony_result_t sony_demod_dvbs_s2_blindscan_StorageInit (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_power_t * pPowerArrayTop,
int32_t powerArrayLength,
sony_demod_dvbs_s2_blindscan_data_t * pDataArrayTop,
int32_t dataArrayLength)
{
int32_t i = 0;
sony_demod_dvbs_s2_blindscan_power_t * pPowerCurrent = NULL;
sony_demod_dvbs_s2_blindscan_data_t * pDataCurrent = NULL;
if ((!pStorage) || (!pPowerArrayTop) || (powerArrayLength <= 0) || (!pDataArrayTop) || (dataArrayLength <= 0)){
return SONY_RESULT_ERROR_ARG;
}
pStorage->pPowerArrayTop = pPowerArrayTop;
pStorage->powerArrayLength = powerArrayLength;
pStorage->pDataArrayTop = pDataArrayTop;
pStorage->dataArrayLength = dataArrayLength;
pPowerCurrent = &(pStorage->availablePowerList);
for(i = 0; i < powerArrayLength; i++){
pPowerCurrent->pNext = (pPowerArrayTop + i);
pPowerCurrent = pPowerCurrent->pNext;
}
pPowerCurrent->pNext = NULL;
pStorage->currentUsedPowerCount = 0;
pStorage->maxUsedPowerCount = 0;
pDataCurrent = &(pStorage->availableDataList);
for(i = 0; i < dataArrayLength; i++){
pDataCurrent->pNext = (pDataArrayTop + i);
pDataCurrent = pDataCurrent->pNext;
}
pDataCurrent->pNext = NULL;
pStorage->currentUsedCount = 0;
pStorage->maxUsedCount = 0;
return SONY_RESULT_OK;
}
sony_result_t sony_demod_dvbs_s2_blindscan_AllocPower (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_power_t ** ppPower)
{
if((!pStorage) || (!ppPower)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if(pStorage->availablePowerList.pNext != NULL){
*ppPower = pStorage->availablePowerList.pNext;
if((*ppPower)->pNext != NULL){
pStorage->availablePowerList.pNext = (*ppPower)->pNext;
} else {
/* Alloc the last data. */
pStorage->availablePowerList.pNext = NULL;
}
} else {
/* Overflow. */
return SONY_RESULT_ERROR_OVERFLOW;
}
(*ppPower)->pNext = NULL;
return incrementPowCount (pStorage);
}
sony_result_t sony_demod_dvbs_s2_blindscan_FreePower (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_power_t * pPower)
{
sony_demod_dvbs_s2_blindscan_power_t * pTemp = NULL;
if((!pStorage) || (!pPower)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if(pStorage->availablePowerList.pNext != NULL){
pTemp = pStorage->availablePowerList.pNext;
pStorage->availablePowerList.pNext = pPower;
pPower->pNext = pTemp;
} else {
/* Data is empty. */
pStorage->availablePowerList.pNext = pPower;
pPower->pNext = NULL;
}
return decrementPowCount (pStorage);
}
sony_result_t sony_demod_dvbs_s2_blindscan_ClearPowerList (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_power_t * pListTop)
{
sony_result_t result = SONY_RESULT_OK;
sony_demod_dvbs_s2_blindscan_power_t * pCurrent = NULL;
sony_demod_dvbs_s2_blindscan_power_t * pTemp = NULL;
if ((!pStorage) || (!pListTop)){
return SONY_RESULT_ERROR_ARG;
}
pCurrent = pListTop->pNext;
while (pCurrent){
pTemp = pCurrent->pNext;
result = sony_demod_dvbs_s2_blindscan_FreePower (pStorage, pCurrent);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pCurrent = pTemp;
}
pListTop->pNext = NULL;
return SONY_RESULT_OK;
}
sony_result_t sony_demod_dvbs_s2_blindscan_AllocData (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_data_t ** ppData)
{
if ((!pStorage) || (!ppData)){
return SONY_RESULT_ERROR_ARG;
}
if(pStorage->availableDataList.pNext){
*ppData = pStorage->availableDataList.pNext;
if((*ppData)->pNext){
pStorage->availableDataList.pNext = (*ppData)->pNext;
} else {
/* Alloc the last data. */
pStorage->availableDataList.pNext = NULL;
}
} else {
/* Overflow. */
return SONY_RESULT_ERROR_OVERFLOW;
}
(*ppData)->pNext = NULL;
return incrementMemCount(pStorage);
}
sony_result_t sony_demod_dvbs_s2_blindscan_FreeData (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_data_t * pData)
{
sony_demod_dvbs_s2_blindscan_data_t * pTemp = NULL;
if ((!pStorage) || (!pData)){
return SONY_RESULT_ERROR_OTHER;
}
if(pStorage->availableDataList.pNext){
pTemp = pStorage->availableDataList.pNext;
pStorage->availableDataList.pNext = pData;
pData->pNext = pTemp;
} else {
/* Data is empty. */
pStorage->availableDataList.pNext = pData;
pData->pNext = NULL;
}
return decrementMemCount(pStorage);
}
sony_result_t sony_demod_dvbs_s2_blindscan_ClearDataList (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_data_t * pListTop)
{
sony_result_t result = SONY_RESULT_OK;
sony_demod_dvbs_s2_blindscan_data_t * pCurrent = NULL;
sony_demod_dvbs_s2_blindscan_data_t * pTemp = NULL;
if ((!pStorage) || (!pListTop)){
return SONY_RESULT_ERROR_ARG;
}
pCurrent = pListTop->pNext;
while (pCurrent){
pTemp = pCurrent->pNext;
result = sony_demod_dvbs_s2_blindscan_FreeData (pStorage, pCurrent);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pCurrent = pTemp;
}
pListTop->pNext = NULL;
return SONY_RESULT_OK;
}
/*----------------------------------------------------------------------------
Static Functions
----------------------------------------------------------------------------*/
static sony_result_t incrementMemCount (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage)
{
if (!pStorage){
return SONY_RESULT_ERROR_ARG;
}
pStorage->currentUsedCount++;
if(pStorage->currentUsedCount <= 0){
/* Error(Overflow) */
return SONY_RESULT_ERROR_OVERFLOW;
}
if(pStorage->maxUsedCount < pStorage->currentUsedCount){
pStorage->maxUsedCount = pStorage->currentUsedCount;
}
return SONY_RESULT_OK;
}
static sony_result_t decrementMemCount (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage)
{
if (!pStorage){
return SONY_RESULT_ERROR_ARG;
}
if(pStorage->currentUsedCount == 0){
/* Error(Overflow) */
return SONY_RESULT_ERROR_OVERFLOW;
} else {
pStorage->currentUsedCount--;
}
return SONY_RESULT_OK;
}
static sony_result_t incrementPowCount (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage)
{
if (!pStorage){
return SONY_RESULT_ERROR_ARG;
}
pStorage->currentUsedPowerCount++;
if(pStorage->currentUsedPowerCount <= 0){
/* Error(Overflow) */
return SONY_RESULT_ERROR_OVERFLOW;
}
if(pStorage->maxUsedPowerCount < pStorage->currentUsedPowerCount){
pStorage->maxUsedPowerCount = pStorage->currentUsedPowerCount;
}
return SONY_RESULT_OK;
}
static sony_result_t decrementPowCount (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage)
{
if (!pStorage){
return SONY_RESULT_ERROR_ARG;
}
if(pStorage->currentUsedPowerCount == 0){
/* Error(Overflow) */
return SONY_RESULT_ERROR_OVERFLOW;
} else {
pStorage->currentUsedPowerCount--;
}
return SONY_RESULT_OK;
}
@@ -0,0 +1,103 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbs_s2_blindscan_utility.h
This file provides the functions for alloc/free data.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBS_S2_BLINDSCAN_UTILITY_H
#define SONY_DEMOD_DVBS_S2_BLINDSCAN_UTILITY_H
#include "sony_common.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
#include "sony_demod_dvbs_s2_blindscan_seq.h"
/**
@brief Initialize storage instance.
@param pStorage Storage instance.
@param pPowerArrayTop Pointer of array for power data.
@param powerArrayLength Length of array for power data "pPowerArrayTop".
@param pDataArrayTop Pointer of array for data.
@param dataArrayLength Length of array for data "pDataArrayTop".
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_StorageInit (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_power_t * pPowerArrayTop,
int32_t powerArrayLength,
sony_demod_dvbs_s2_blindscan_data_t * pDataArrayTop,
int32_t dataArrayLength);
/**
@brief Allocate power data.
@param pStorage Storage instance.
@param ppPower Address of address for power data.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_AllocPower (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_power_t ** ppPower);
/**
@brief Free power data.
@param pStorage Storage instance.
@param pPower Address for power data.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_FreePower (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_power_t * pPower);
/**
@brief Clear power list.
@param pStorage Storage instance.
@param pListTop Address for power list.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_ClearPowerList (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_power_t * pListTop);
/**
@brief Allocate data.
@param pStorage Storage instance.
@param ppData Address of address for data.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_AllocData (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_data_t ** ppData);
/**
@brief Free data.
@param pStorage Storage instance.
@param pData Address for data.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_FreeData (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_data_t * pData);
/**
@brief Clear data list.
@param pStorage Storage instance.
@param pListTop Address for data list.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_blindscan_ClearDataList (sony_demod_dvbs_s2_blindscan_data_storage_t * pStorage,
sony_demod_dvbs_s2_blindscan_data_t * pListTop);
#endif /* SONY_DEMOD_DVBS_S2_BLINDSCAN_UTILITY_H */
@@ -0,0 +1,31 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbs_s2_tune_srs.h
This file provides demodulator setting for TuneSRS function.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBS_S2_TUNE_SRS_H
#define SONY_DEMOD_DVBS_S2_TUNE_SRS_H
#include "sony_common.h"
#include "sony_demod.h"
/*------------------------------------------------------------------------------
Definitions
------------------------------------------------------------------------------*/
/**
@brief Frequency range for TuneSRS
*/
typedef enum {
SONY_DEMOD_DVBS_S2_TUNE_SRS_FREQ_RANGE_10MHz, /**< +/- 10MHz */
SONY_DEMOD_DVBS_S2_TUNE_SRS_FREQ_RANGE_5MHz /**< +/- 5MHz */
} sony_demod_dvbs_s2_tune_srs_freq_range_t;
#endif /* SONY_DEMOD_DVBS_S2_TUNE_SRS_H */
@@ -0,0 +1,480 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
#include "sony_common.h"
#include "sony_demod.h"
#include "sony_demod_dvbs_s2.h"
#include "sony_demod_dvbs_s2_blindscan.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
#include "sony_demod_dvbs_s2_blindscan_algo.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_bt.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_cs.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_fs.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_pm.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_ss.h"
#include "sony_demod_dvbs_s2_blindscan_utility.h"
#include "sony_demod_dvbs_s2_tune_srs.h"
#include "sony_demod_dvbs_s2_tune_srs_seq.h"
#include "sony_demod_dvbs_s2_blindscan_trace.h"
sony_result_t sony_demod_dvbs_s2_tune_srs_seq_Initialize (sony_demod_dvbs_s2_tune_srs_seq_t * pSeq,
sony_demod_t * pDemod,
uint32_t centerFreqKHz,
sony_demod_dvbs_s2_tune_srs_freq_range_t freqRange)
{
sony_result_t result = SONY_RESULT_OK;
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_INIT();
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_tune_srs_seq_Initialize");
if ((!pSeq) || (!pDemod)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
switch(freqRange)
{
case SONY_DEMOD_DVBS_S2_TUNE_SRS_FREQ_RANGE_10MHz:
pSeq->rangeFreqMHz = 10;
break;
case SONY_DEMOD_DVBS_S2_TUNE_SRS_FREQ_RANGE_5MHz:
pSeq->rangeFreqMHz = 5;
break;
default:
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
pSeq->isContinue = 1;
pSeq->isDetect = 0;
pSeq->seqState = TUNE_SRS_SEQ_STATE_START;
pSeq->centerFreqKHz = centerFreqKHz;
pSeq->minFreqKHz = centerFreqKHz - ((pSeq->rangeFreqMHz) * 1000); /* Frequency capture range */
pSeq->maxFreqKHz = centerFreqKHz + ((pSeq->rangeFreqMHz) * 1000); /* Frequency capture range */
pSeq->minSymbolRateKSps = 1000; /* Symbol rate capture range (Fixed) */
pSeq->maxSymbolRateKSps = 45000; /* Symbol rate capture range (Fixed) */
/*
* 500KHz step search is for 1 - 20MSps range.
*
* Max(20MSps) * 1.35 / 2 = 13.5MSps -> 14MHz
*/
pSeq->powerMinFreqKHz1 = pSeq->minFreqKHz - 14000;
pSeq->powerMaxFreqKHz1 = pSeq->maxFreqKHz + 14000;
/*
* 2000KHz step search is for 20 - 45MSps range.
*
* Max(45MSps) * 1.35 / 2 = 30.375MSps
* 30.375MHz - 14MHz = 16.375MHz -> 20MHz
*/
pSeq->powerMinFreqKHz2 = pSeq->powerMaxFreqKHz1;
pSeq->powerMaxFreqKHz2 = pSeq->powerMaxFreqKHz1 + 20000;
pSeq->powerMinFreqKHz3 = pSeq->powerMinFreqKHz1 - 20000;
pSeq->powerMaxFreqKHz3 = pSeq->powerMinFreqKHz1;
if ((pSeq->powerMaxFreqKHz2 - pSeq->powerMinFreqKHz3) < 72000){
pSeq->powerMinFreqKHz1 = pSeq->powerMinFreqKHz3;
pSeq->powerMaxFreqKHz1 = pSeq->powerMaxFreqKHz2;
pSeq->powerMinFreqKHz2 = 0;
pSeq->powerMaxFreqKHz2 = 0;
pSeq->powerMinFreqKHz3 = 0;
pSeq->powerMaxFreqKHz3 = 0;
}
pSeq->commonParams.pDemod = pDemod;
pSeq->commonParams.detInfo.isDetect = 0;
pSeq->commonParams.tuneReq.isRequest = 0;
pSeq->commonParams.agcInfo.isRequest = 0;
pSeq->commonParams.waitTime = 0;
pSeq->commonParams.ckalFreqKHz = 64000; /* CKAL */
pSeq->commonParams.ckahFreqKHz = 96000; /* CKAH */
/* Initialize the data storage */
result = sony_demod_dvbs_s2_blindscan_StorageInit (&(pSeq->commonParams.storage),
pSeq->powerArray,
sizeof(pSeq->powerArray)/sizeof(pSeq->powerArray[0]),
pSeq->dataArray,
sizeof(pSeq->dataArray)/sizeof(pSeq->dataArray[0]));
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Initialize demodulator to start BlindScan. */
result = sony_demod_dvbs_s2_blindscan_Initialize(pSeq->commonParams.pDemod);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_dvbs_s2_blindscan_subseq_bt_Initialize (&pSeq->subseqBT, &pSeq->commonParams);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Initialize (&pSeq->subseqPM, &pSeq->commonParams);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_dvbs_s2_blindscan_subseq_ss_Initialize (&pSeq->subseqSS, &pSeq->commonParams);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_dvbs_s2_blindscan_subseq_fs_Initialize (&pSeq->subseqFS, &pSeq->subseqBT, &pSeq->commonParams);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_dvbs_s2_blindscan_subseq_cs_Initialize (&pSeq->subseqCS, &pSeq->subseqPM, &pSeq->commonParams);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_dvbs_s2_blindscan_AllocData(&(pSeq->commonParams.storage), &(pSeq->pCandList1));
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->pCandLast1 = pSeq->pCandList1;
result = sony_demod_dvbs_s2_blindscan_AllocData(&(pSeq->commonParams.storage), &(pSeq->pCandList2));
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->pCandLast2 = pSeq->pCandList2;
result = sony_demod_dvbs_s2_blindscan_AllocPower(&(pSeq->commonParams.storage), &(pSeq->pPowerList));
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_dvbs_s2_blindscan_AllocData(&(pSeq->commonParams.storage), &(pSeq->pDetectedList));
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_dvbs_s2_tune_srs_seq_Sequence (sony_demod_dvbs_s2_tune_srs_seq_t * pSeq)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_tune_srs_seq_Sequence");
if (!pSeq){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if (pSeq->subseqSS.isEnable){
/* SS seq */
result = sony_demod_dvbs_s2_blindscan_subseq_ss_Sequence (&pSeq->subseqSS);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
} else if (pSeq->subseqBT.isEnable){
/* BT seq */
result = sony_demod_dvbs_s2_blindscan_subseq_bt_Sequence (&pSeq->subseqBT);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
} else if (pSeq->subseqCS.isEnable){
if (pSeq->subseqPM.isEnable){
/* PM seq */
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Sequence(&pSeq->subseqPM);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
} else {
/* CS seq */
result = sony_demod_dvbs_s2_blindscan_subseq_cs_Sequence(&pSeq->subseqCS);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
}
} else {
/* Main sequence */
switch(pSeq->seqState)
{
case TUNE_SRS_SEQ_STATE_START:
result = sony_demod_dvbs_s2_blindscan_subseq_ss_Start(&pSeq->subseqSS,
pSeq->powerMinFreqKHz1,
pSeq->powerMaxFreqKHz1,
500,
pSeq->powerMaxFreqKHz1 - pSeq->powerMinFreqKHz1,
pSeq->commonParams.pDemod->dvbss2PowerSmooth);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->commonParams.waitTime = 0;
pSeq->seqState = TUNE_SRS_SEQ_STATE_SS1_FIN;
break;
case TUNE_SRS_SEQ_STATE_SS1_FIN:
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_POWERLIST("1st", pSeq->subseqSS.pPowerList);
result = sony_demod_dvbs_s2_blindscan_algo_GetCandidateNml (&(pSeq->commonParams.storage),
pSeq->subseqSS.pPowerList,
200,
1000,
5000,
1000,
pSeq->pCandList1);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_dvbs_s2_blindscan_algo_SeparateCandidate (&(pSeq->commonParams.storage), pSeq->pCandList1);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_dvbs_s2_blindscan_algo_DeleteDuplicate2 (&(pSeq->commonParams.storage), pSeq->pCandList1);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CANDLIST("1st(1-5)", pSeq->pCandList1);
/* Tune for coarse search */
pSeq->commonParams.tuneReq.isRequest = 1;
pSeq->commonParams.tuneReq.frequencyKHz = pSeq->centerFreqKHz;
pSeq->commonParams.tuneReq.symbolRateKSps = 15000;
pSeq->commonParams.tuneReq.system = SONY_DTV_SYSTEM_DVBS;
/* Set the top candidate */
pSeq->pCandCurrent = pSeq->pCandList1->pNext;
pSeq->commonParams.waitTime = 0;
pSeq->seqState = TUNE_SRS_SEQ_STATE_RF_TUNED;
break;
case TUNE_SRS_SEQ_STATE_RF_TUNED:
if (pSeq->pCandCurrent){
int32_t offsetFreqKHz = (int32_t)(pSeq->pCandCurrent->data.candidate.centerFreqKHz) - (int32_t)(pSeq->commonParams.tuneReq.frequencyKHz);
if ((((int32_t)((pSeq->rangeFreqMHz * 1000) + 3000) * (-1)) <= offsetFreqKHz) && (offsetFreqKHz <= (int32_t)((pSeq->rangeFreqMHz * 1000) + 3000))){
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CS_TUNE (pSeq->commonParams.tuneReq.frequencyKHz);
result = sony_demod_dvbs_s2_blindscan_subseq_cs_Start (&(pSeq->subseqCS), offsetFreqKHz);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
} else {
pSeq->subseqCS.isExist = 0;
}
pSeq->commonParams.waitTime = 0;
pSeq->seqState = TUNE_SRS_SEQ_STATE_CS1_FIN;
} else {
result = sony_demod_dvbs_s2_blindscan_algo_DeleteDuplicate (&(pSeq->commonParams.storage), pSeq->pCandList2);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_dvbs_s2_blindscan_ClearDataList (&(pSeq->commonParams.storage), pSeq->pCandList1);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->pCandList1->pNext = pSeq->pCandList2->pNext;
pSeq->pCandList2->pNext = NULL;
if (((pSeq->powerMaxFreqKHz2 - pSeq->powerMinFreqKHz2) == 0) || ((pSeq->powerMaxFreqKHz3 - pSeq->powerMinFreqKHz3) == 0)){
pSeq->commonParams.waitTime = 0;
pSeq->seqState = TUNE_SRS_SEQ_STATE_CAND2;
} else {
pSeq->commonParams.waitTime = 0;
pSeq->seqState = TUNE_SRS_SEQ_STATE_CS1_FIN2;
}
}
break;
case TUNE_SRS_SEQ_STATE_CS1_FIN:
if (pSeq->subseqCS.isExist){
sony_demod_dvbs_s2_blindscan_data_t * pTemp = NULL;
result = sony_demod_dvbs_s2_blindscan_AllocData (&(pSeq->commonParams.storage), &pTemp);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pTemp->data.candidate.centerFreqKHz = (uint32_t)((int32_t)pSeq->commonParams.tuneReq.frequencyKHz + pSeq->subseqCS.freqOffsetKHz);
pTemp->data.candidate.symbolRateKSps = pSeq->subseqCS.coarseSymbolRateKSps;
pTemp->data.candidate.minSymbolRateKSps = (pSeq->subseqCS.coarseSymbolRateKSps * 700) / 1000;
pTemp->data.candidate.maxSymbolRateKSps = ((pSeq->subseqCS.coarseSymbolRateKSps * 1600) + 999) / 1000;
pSeq->pCandLast2->pNext = pTemp;
pSeq->pCandLast2 = pSeq->pCandLast2->pNext;
}
pSeq->pCandCurrent = pSeq->pCandCurrent->pNext;
pSeq->commonParams.waitTime = 0;
pSeq->seqState = TUNE_SRS_SEQ_STATE_RF_TUNED;
break;
case TUNE_SRS_SEQ_STATE_CS1_FIN2:
/* Set SS1 data to list */
pSeq->pPowerList->pNext = pSeq->subseqSS.pPowerList->pNext;
pSeq->subseqSS.pPowerList->pNext = NULL;
result = sony_demod_dvbs_s2_blindscan_subseq_ss_Start (&(pSeq->subseqSS),
pSeq->powerMinFreqKHz2,
pSeq->powerMaxFreqKHz2,
2000,
pSeq->powerMaxFreqKHz2 - pSeq->powerMinFreqKHz2,
pSeq->commonParams.pDemod->dvbss2PowerSmooth);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->seqState = TUNE_SRS_SEQ_STATE_SS2_FIN;
pSeq->commonParams.waitTime = 0;
break;
case TUNE_SRS_SEQ_STATE_SS2_FIN:
/* Set SS2 data to list */
pSeq->pPowerLast = pSeq->pPowerList;
while(pSeq->pPowerLast->pNext){
pSeq->pPowerLast = pSeq->pPowerLast->pNext;
}
pSeq->pPowerLast->pNext = pSeq->subseqSS.pPowerList->pNext;
pSeq->subseqSS.pPowerList->pNext = NULL;
result = sony_demod_dvbs_s2_blindscan_subseq_ss_Start (&(pSeq->subseqSS),
pSeq->powerMinFreqKHz3,
pSeq->powerMaxFreqKHz3,
2000,
pSeq->powerMaxFreqKHz3 - pSeq->powerMinFreqKHz3,
pSeq->commonParams.pDemod->dvbss2PowerSmooth);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->seqState = TUNE_SRS_SEQ_STATE_SS3_FIN;
pSeq->commonParams.waitTime = 0;
break;
case TUNE_SRS_SEQ_STATE_SS3_FIN:
/* Set SS3 data to list */
pSeq->pPowerLast = pSeq->subseqSS.pPowerList;
while(pSeq->pPowerLast->pNext){
pSeq->pPowerLast = pSeq->pPowerLast->pNext;
}
pSeq->pPowerLast->pNext = pSeq->pPowerList->pNext;
pSeq->pPowerList->pNext = pSeq->subseqSS.pPowerList->pNext;
pSeq->seqState = TUNE_SRS_SEQ_STATE_CAND2;
pSeq->commonParams.waitTime = 0;
break;
case TUNE_SRS_SEQ_STATE_CAND2:
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CANDLIST("1st", pSeq->pCandList1);
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_POWERLIST("2nd", pSeq->pPowerList);
result = sony_demod_dvbs_s2_blindscan_algo_GetCandidateNml (&(pSeq->commonParams.storage),
pSeq->pPowerList,
100,
20000,
45000,
4000,
pSeq->pCandList2);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CANDLIST("2nd(20-45)", pSeq->pCandList2);
pSeq->pCandLast1 = pSeq->pCandList1;
while(pSeq->pCandLast1->pNext){
pSeq->pCandLast1 = pSeq->pCandLast1->pNext;
}
pSeq->pCandLast1->pNext = pSeq->pCandList2->pNext;
pSeq->pCandList2->pNext = NULL;
result = sony_demod_dvbs_s2_blindscan_algo_GetCandidateNml (&(pSeq->commonParams.storage),
pSeq->pPowerList,
100,
5000,
20000,
1000,
pSeq->pCandList2);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CANDLIST("3rd(5-20)", pSeq->pCandList2);
while(pSeq->pCandLast1->pNext){
pSeq->pCandLast1 = pSeq->pCandLast1->pNext;
}
pSeq->pCandLast1->pNext = pSeq->pCandList2->pNext;
pSeq->pCandList2->pNext = NULL;
result = sony_demod_dvbs_s2_blindscan_algo_SortByFrequency (&(pSeq->commonParams.storage),
pSeq->pCandList1,
pSeq->centerFreqKHz);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_CANDLIST ("final", pSeq->pCandList1);
pSeq->pCandCurrent = pSeq->pCandList1->pNext;
pSeq->seqState = TUNE_SRS_SEQ_STATE_BT_START;
pSeq->commonParams.waitTime = 0;
break;
case TUNE_SRS_SEQ_STATE_BT_START:
if (pSeq->pCandCurrent){
int32_t offsetFreqKHz = (int32_t)(pSeq->pCandCurrent->data.candidate.centerFreqKHz) - (int32_t)(pSeq->centerFreqKHz);
/* Performing Blind Tune on the candidates that lie within (rangeFreqMHz +- 3MHz) of the specified tune-frequency. */
if ((((int32_t)((pSeq->rangeFreqMHz * 1000) + 3000) * (-1)) <= offsetFreqKHz) && (offsetFreqKHz <= (int32_t)((pSeq->rangeFreqMHz * 1000) + 3000))){
result = sony_demod_dvbs_s2_blindscan_subseq_bt_Start (&(pSeq->subseqBT),
pSeq->pCandCurrent->data.candidate.centerFreqKHz,
pSeq->pCandCurrent->data.candidate.symbolRateKSps,
pSeq->pCandCurrent->data.candidate.minSymbolRateKSps,
pSeq->pCandCurrent->data.candidate.maxSymbolRateKSps,
pSeq->minSymbolRateKSps,
pSeq->maxSymbolRateKSps);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->seqState = TUNE_SRS_SEQ_STATE_BT_END;
pSeq->commonParams.waitTime = 0;
} else {
/* Unlocked */
pSeq->isContinue = 0;
pSeq->isDetect = 0;
}
} else {
/* Unlocked */
pSeq->isContinue = 0;
pSeq->isDetect = 0;
}
break;
case TUNE_SRS_SEQ_STATE_BT_END:
if (pSeq->subseqBT.isLocked){
/* Locked */
pSeq->isContinue = 0;
pSeq->tuneParam.centerFreqKHz = (uint32_t)((int32_t)(pSeq->commonParams.tuneReq.frequencyKHz) + pSeq->subseqBT.detCarrierOffsetKHz);
pSeq->tuneParam.symbolRateKSps = (pSeq->subseqBT.detSymbolRateSps + 500) / 1000;
pSeq->tuneParam.system = pSeq->subseqBT.detSystem;
if ((pSeq->centerFreqKHz - (pSeq->rangeFreqMHz * 1000) - 100) <= (pSeq->tuneParam.centerFreqKHz) &&
((pSeq->tuneParam.centerFreqKHz) <= pSeq->centerFreqKHz + (pSeq->rangeFreqMHz * 1000) + 100)) {
/* Signal is in range. */
pSeq->isDetect = 1;
} else {
/* Signal is out of range. */
pSeq->isDetect = 0;
}
}
pSeq->pCandCurrent = pSeq->pCandCurrent->pNext;
pSeq->seqState = TUNE_SRS_SEQ_STATE_BT_START;
pSeq->commonParams.waitTime = 0;
break;
default:
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
@@ -0,0 +1,177 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbs_s2_tune_srs_seq.h
This file provides defines for TuneSRS sequence.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBS_S2_TUNE_SRS_SEQ_H
#define SONY_DEMOD_DVBS_S2_TUNE_SRS_SEQ_H
#include "sony_common.h"
#include "sony_demod.h"
#include "sony_demod_dvbs_s2.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
#include "sony_demod_dvbs_s2_blindscan_utility.h"
#include "sony_demod_dvbs_s2_blindscan_seq_common.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_bt.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_cs.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_fs.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_pm.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_ss.h"
#include "sony_demod_dvbs_s2_tune_srs.h"
/*------------------------------------------------------------------------------
Definitions
------------------------------------------------------------------------------*/
/**
@brief Definition of array size used for TuneSRS in this driver.
The user need not to change this value directly.
*/
#define SONY_DEMOD_DVBS_S2_TUNE_SRS_POWER_MAX 500
/**
@brief Definition of array size used for TuneSRS in this driver.
The data size is depend on the input signal as follow.
- Search range.
- Power spectrum.
- etc...
User can get the maximum used data size by sony_demod_dvbs_s2_blindscan_data_storage_t::maxUsedCount.
If the driver returns SONY_RESULT_ERROR_OVERFLOW, please increase this value.
*/
#define SONY_DEMOD_DVBS_S2_TUNE_SRS_DATA_MAX 5000
/**
@brief State for TuneSRS sequence.
*/
typedef enum {
TUNE_SRS_SEQ_STATE_START, /**< Start */
TUNE_SRS_SEQ_STATE_SS1_FIN, /**< SS1 fin */
TUNE_SRS_SEQ_STATE_RF_TUNED, /**< RF tuned */
TUNE_SRS_SEQ_STATE_CS1_FIN, /**< CS1 fin */
TUNE_SRS_SEQ_STATE_CS1_FIN2, /**< CS1 fin2 */
TUNE_SRS_SEQ_STATE_SS2_FIN, /**< SS2 fin */
TUNE_SRS_SEQ_STATE_SS3_FIN, /**< SS3 fin */
TUNE_SRS_SEQ_STATE_CAND2, /**< Cand2 */
TUNE_SRS_SEQ_STATE_BT_START, /**< Start BT */
TUNE_SRS_SEQ_STATE_BT_END /**< End BT */,
TUNE_SRS_SEQ_STATE_FINISH, /**< Finish */
TUNE_SRS_SEQ_STATE_UNKNOWN /**< Unknown */
} sony_demod_dvbs_s2_tune_srs_seq_state_t;
/**
@brief structure for scan sequence.
*/
typedef struct {
/**
@brief Common parameters used by each sub sequence.
*/
sony_demod_dvbs_s2_blindscan_seq_common_t commonParams;
/**
@brief Finish/Continue flag.
- 0: Finish the sequence.
- 1: Continue the sequence.
*/
uint8_t isContinue;
/**
@brief Signal detect flag.
After "isContinue == 0", please see this flag.
If isDetect == 1, TuneSRS detected signal.
If isDetect == 0, TuneSRS didn't detect signal.
*/
uint8_t isDetect;
/**
@brief State of main sequence.
*/
uint32_t seqState;
sony_demod_dvbs_s2_blindscan_subseq_bt_t subseqBT; /**< Sub sequence for BT. */
sony_demod_dvbs_s2_blindscan_subseq_pm_t subseqPM; /**< Sub sequence for PM. */
sony_demod_dvbs_s2_blindscan_subseq_ss_t subseqSS; /**< Sub sequence for SS. */
sony_demod_dvbs_s2_blindscan_subseq_fs_t subseqFS; /**< Sub sequence for FS. */
sony_demod_dvbs_s2_blindscan_subseq_cs_t subseqCS; /**< Sub sequence for CS. */
uint32_t centerFreqKHz; /**< Center frequency in KHz from argument */
uint32_t rangeFreqMHz; /**< Capture range in MHz from argument */
uint32_t minFreqKHz; /**< Min freq calculated from centerFreqKHz and rangeFreqMHz */
uint32_t maxFreqKHz; /**< Max freq calculated from centerFreqKHz and rangeFreqMHz */
uint32_t minSymbolRateKSps; /**< Min symbol rate in KSps. (Fixed to 1000) */
uint32_t maxSymbolRateKSps; /**< Max symbol rate in KSps. (Fixed to 45000) */
uint32_t powerMinFreqKHz1; /**< Min frequency for 1st power search in KHz. */
uint32_t powerMaxFreqKHz1; /**< Max frequency for 1st power search in KHz. */
uint32_t powerMinFreqKHz2; /**< Min frequency for 2nd power search in KHz. */
uint32_t powerMaxFreqKHz2; /**< Max frequency for 2nd power search in KHz. */
uint32_t powerMinFreqKHz3; /**< Min frequency for 3rd power search in KHz. */
uint32_t powerMaxFreqKHz3; /**< Max frequency for 3rd power search in KHz. */
sony_demod_dvbs_s2_blindscan_data_t * pDetectedList; /**< Detected list */
sony_demod_dvbs_s2_blindscan_data_t * pCandList1; /**< Candidate list 1 */
sony_demod_dvbs_s2_blindscan_data_t * pCandLast1; /**< Last pointer of candidate list 1 */
sony_demod_dvbs_s2_blindscan_data_t * pCandCurrent; /**< Current pointer of candidate list 1 */
sony_demod_dvbs_s2_blindscan_data_t * pCandList2; /**< Candidate list 2 */
sony_demod_dvbs_s2_blindscan_data_t * pCandLast2; /**< Last pointer of candidate list 2 */
sony_demod_dvbs_s2_blindscan_power_t * pPowerList; /**< Power list */
sony_demod_dvbs_s2_blindscan_power_t * pPowerLast; /**< Last pointer of power list */
/**
@brief Power data for storage.
*/
sony_demod_dvbs_s2_blindscan_power_t powerArray[SONY_DEMOD_DVBS_S2_TUNE_SRS_POWER_MAX];
/**
@brief Data for storage.
*/
sony_demod_dvbs_s2_blindscan_data_t dataArray[SONY_DEMOD_DVBS_S2_TUNE_SRS_DATA_MAX];
/**
@brief Instance for detected signal.
*/
sony_dvbs_s2_tune_param_t tuneParam;
} sony_demod_dvbs_s2_tune_srs_seq_t;
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Prepare to start TuneSRS sequence.
@param pSeq The sequence instance.
@param pDemod Demodulator instance.
@param centerFreqKHz Center frequency in KHz.
@param freqRange Frequency range.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_tune_srs_seq_Initialize (sony_demod_dvbs_s2_tune_srs_seq_t * pSeq,
sony_demod_t * pDemod,
uint32_t centerFreqKHz,
sony_demod_dvbs_s2_tune_srs_freq_range_t freqRange);
/**
@brief Execute one sequence for TuneSRS.
@param pSeq The sequence instance.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_tune_srs_seq_Sequence (sony_demod_dvbs_s2_tune_srs_seq_t * pSeq);
#endif /* SONY_DEMOD_DVBS_S2_TUNE_SRS_SEQ_H */
@@ -0,0 +1,172 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
#include "sony_common.h"
#include "sony_math.h"
#include "sony_demod.h"
#include "sony_demod_dvbs_s2.h"
#include "sony_demod_dvbs_s2_monitor.h"
#include "sony_demod_dvbs_s2_blindscan.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
#include "sony_demod_dvbs_s2_blindscan_utility.h"
#include "sony_demod_dvbs_s2_blindscan_trace.h"
#include "sony_demod_sat_device_ctrl_detect_cw_seq.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_pm.h"
/*----------------------------------------------------------------------------
Static Functions
----------------------------------------------------------------------------*/
static int32_t calcPower(int32_t ifagcdb_x100, uint32_t power);
static const uint32_t stepKHz = 500;
/*----------------------------------------------------------------------------
Functions
----------------------------------------------------------------------------*/
sony_result_t sony_demod_sat_device_ctrl_detect_cw_seq_Initialize (sony_demod_sat_device_ctrl_detect_cw_seq_t * pSeq,
sony_demod_t * pDemod,
uint32_t freqKHz,
uint32_t rangeKHz)
{
sony_result_t result = SONY_RESULT_OK;
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_INIT();
SONY_TRACE_ENTER ("sony_demod_sat_device_ctrl_detect_cw_seq_Initialize");
if ((!pSeq) || (!pDemod)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
pSeq->isContinue = 1;
pSeq->seqState = DETECT_CW_SEQ_STATE_START;
pSeq->freqKHz = freqKHz;
pSeq->rangeKHz = rangeKHz;
pSeq->stepKHz = stepKHz;
pSeq->currentOffsetFreqKHz = 0;
pSeq->power = 0;
pSeq->commonParams.pDemod = pDemod;
pSeq->commonParams.detInfo.isDetect = 0;
pSeq->commonParams.tuneReq.isRequest = 0;
pSeq->commonParams.agcInfo.isRequest = 0;
pSeq->commonParams.waitTime = 0;
pSeq->commonParams.ckalFreqKHz = 64000; /* CKAL */
pSeq->commonParams.ckahFreqKHz = 96000; /* CKAH */
/* Initialize the data storage */
result = sony_demod_dvbs_s2_blindscan_StorageInit (&(pSeq->commonParams.storage),
pSeq->powerArray,
sizeof(pSeq->powerArray)/sizeof(pSeq->powerArray[0]),
pSeq->dataArray,
sizeof(pSeq->dataArray)/sizeof(pSeq->dataArray[0]));
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN(result);
}
/* Initialize demodulator to start BlindScan. */
result = sony_demod_dvbs_s2_blindscan_Initialize(pSeq->commonParams.pDemod);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN(result);
}
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Initialize (&pSeq->subseqPM, &pSeq->commonParams);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN(result);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_sat_device_ctrl_detect_cw_seq_Sequence (sony_demod_sat_device_ctrl_detect_cw_seq_t * pSeq)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_demod_sat_device_ctrl_detect_cw_seq_Sequence");
if (!pSeq){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if (pSeq->subseqPM.isEnable){
/* PM seq */
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Sequence(&pSeq->subseqPM);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN(result);
}
} else {
/* Main sequence */
switch(pSeq->seqState)
{
case DETECT_CW_SEQ_STATE_START:
pSeq->commonParams.tuneReq.isRequest = 1;
pSeq->commonParams.tuneReq.frequencyKHz = pSeq->freqKHz;
pSeq->commonParams.tuneReq.symbolRateKSps = 45000;
pSeq->commonParams.tuneReq.system = SONY_DTV_SYSTEM_DVBS;
pSeq->commonParams.waitTime = 50;
pSeq->seqState = DETECT_CW_SEQ_STATE_AGC_ON;
break;
case DETECT_CW_SEQ_STATE_AGC_ON:
pSeq->commonParams.agcInfo.isRequest = 1;
result = sony_demod_dvbs_s2_monitor_IFAGCOut(pSeq->commonParams.pDemod, &pSeq->commonParams.agcInfo.agcLevel);
if (result != SONY_RESULT_OK) {
return result;
}
pSeq->seqState = DETECT_CW_SEQ_STATE2;
pSeq->commonParams.waitTime = 0;
break;
case DETECT_CW_SEQ_STATE2:
pSeq->offsetFreqKHz = (int32_t)pSeq->freqKHz - (int32_t)pSeq->commonParams.tuneReq.frequencyKHz;
result = sony_demod_dvbs_s2_blindscan_CS_INIT(pSeq->commonParams.pDemod);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->currentOffsetFreqKHz = (-1) * pSeq->rangeKHz;
pSeq->seqState = DETECT_CW_SEQ_STATE3;
pSeq->commonParams.waitTime = 0;
break;
case DETECT_CW_SEQ_STATE3:
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (&pSeq->subseqPM, pSeq->offsetFreqKHz + pSeq->currentOffsetFreqKHz);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->seqState = DETECT_CW_SEQ_STATE4;
pSeq->commonParams.waitTime = 0;
break;
case DETECT_CW_SEQ_STATE4:
if(pSeq->power < (int32_t)pSeq->subseqPM.power){
pSeq->power = (int32_t)pSeq->subseqPM.power;
}
pSeq->currentOffsetFreqKHz += (int32_t)pSeq->stepKHz;
if(pSeq->currentOffsetFreqKHz < (int32_t)pSeq->rangeKHz){
/* Next trial */
pSeq->seqState = DETECT_CW_SEQ_STATE3;
pSeq->commonParams.waitTime = 0;
} else {
/* Reach to the end */
pSeq->seqState = DETECT_CW_SEQ_STATE5;
pSeq->commonParams.waitTime = 0;
}
break;
case DETECT_CW_SEQ_STATE5:
pSeq->power = calcPower(pSeq->commonParams.agcInfo.agc_x100dB, (uint32_t)pSeq->power);
pSeq->isContinue = 0;
break;
default:
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
}
SONY_TRACE_RETURN (result);
}
static int32_t calcPower(int32_t ifagcdb_x100, uint32_t power)
{
return (int32_t)(((int32_t)sony_math_log10 (power) - 421) * 10) - ifagcdb_x100;
}
@@ -0,0 +1,103 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
/**
@file sony_demod_sat_device_ctrl_detect_cw_seq.h
This file provides definitions for DetectCW sequence function.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_SAT_DEVICE_CTRL_DETECT_CW_SEQ_H
#define SONY_DEMOD_SAT_DEVICE_CTRL_DETECT_CW_SEQ_H
#include "sony_common.h"
#include "sony_demod.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
#include "sony_demod_dvbs_s2_blindscan_utility.h"
#include "sony_demod_dvbs_s2_blindscan_seq_common.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_pm.h"
/**
@brief state of DetectCW sequence
*/
typedef enum {
DETECT_CW_SEQ_STATE_START, /**< Start */
DETECT_CW_SEQ_STATE_AGC_ON,
DETECT_CW_SEQ_STATE2,
DETECT_CW_SEQ_STATE3,
DETECT_CW_SEQ_STATE4,
DETECT_CW_SEQ_STATE5,
DETECT_CW_STATE_UNKNOWN /**< Unknown */
} sony_demod_sat_device_ctrl_detect_cw_seq_state_t;
/**
@brief Structure for DetectCW sequence.
*/
typedef struct {
/**
@brief Common parameters used by each sub sequence
*/
sony_demod_dvbs_s2_blindscan_seq_common_t commonParams;
/**
@brief Finish/Continue flag.
- 0: Finish the sequence.
- 1: Continue the sequence.
*/
uint8_t isContinue;
sony_demod_sat_device_ctrl_detect_cw_seq_state_t seqState; /**< State of DetectCW sequence. */
sony_demod_dvbs_s2_blindscan_subseq_pm_t subseqPM; /**< Data for sub sequence PM. */
uint32_t freqKHz; /**< Target frequency in KHz */
uint32_t rangeKHz; /**< Range frequency in KHz */
uint32_t stepKHz; /**< Step frequency in KHz */
uint8_t isDetected; /**< The result of this API. */
int32_t offsetFreqKHz; /**< Offset frequency in KHz. */
int32_t currentOffsetFreqKHz; /**< Current offset frequency in KHz. */
int32_t power; /**< Power */
/**
@brief Power data for storage.
*/
sony_demod_dvbs_s2_blindscan_power_t powerArray[1];
/**
@brief Data for storage.
*/
sony_demod_dvbs_s2_blindscan_data_t dataArray[1];
} sony_demod_sat_device_ctrl_detect_cw_seq_t;
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Prepare to start DetectCW sequence.
@param pSeq The sequence instance.
@param pDemod Demodulator instance.
@param freqKHz Target frequency in KHz.
@param rangeKHz The range for search in KHz. (500, 1000, ...)
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_sat_device_ctrl_detect_cw_seq_Initialize (sony_demod_sat_device_ctrl_detect_cw_seq_t * pSeq,
sony_demod_t * pDemod,
uint32_t freqKHz,
uint32_t rangeKHz);
/**
@brief Execute one sequence for DetectCW.
@param pSeq The sequence instance.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_sat_device_ctrl_detect_cw_seq_Sequence (sony_demod_sat_device_ctrl_detect_cw_seq_t * pSeq);
#endif /* SONY_DEMOD_SAT_DEVICE_CTRL_DETECT_CW_SEQ_H */
@@ -0,0 +1,368 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
#include "sony_common.h"
#include "sony_math.h"
#include "sony_demod.h"
#include "sony_demod_dvbs_s2.h"
#include "sony_demod_dvbs_s2_monitor.h"
#include "sony_demod_dvbs_s2_blindscan.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_ss.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_pm.h"
#include "sony_demod_dvbs_s2_blindscan_utility.h"
#include "sony_demod_dvbs_s2_blindscan_trace.h"
#include "sony_demod_sat_device_ctrl_find1ub_seq.h"
/*----------------------------------------------------------------------------
Static Functions
----------------------------------------------------------------------------*/
static int32_t calcPower(int32_t ifagcdb_x100, uint32_t power);
/*----------------------------------------------------------------------------
Functions
----------------------------------------------------------------------------*/
sony_result_t sony_demod_sat_device_ctrl_find1ub_seq_Initialize (sony_demod_sat_device_ctrl_find1ub_seq_t * pSeq,
sony_demod_t * pDemod,
uint32_t minFreqKHz,
uint32_t maxFreqKHz,
uint8_t targetUB)
{
sony_result_t result = SONY_RESULT_OK;
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_INIT();
SONY_TRACE_ENTER ("sony_demod_sat_device_ctrl_find1ub_seq_Initialize");
if ((!pSeq) || (!pDemod)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
pSeq->isContinue = 1;
pSeq->seqState = FIND1UB_SEQ_STATE_START;
pSeq->minFreqKHz = minFreqKHz;
pSeq->maxFreqKHz = maxFreqKHz;
pSeq->minPowerFreqKHz = minFreqKHz - 5000;
pSeq->maxPowerFreqKHz = maxFreqKHz + 5000;
pSeq->targetUB = targetUB;
pSeq->commandReq = 0;
pSeq->commonParams.pDemod = pDemod;
pSeq->commonParams.detInfo.isDetect = 0;
pSeq->commonParams.tuneReq.isRequest = 0;
pSeq->commonParams.agcInfo.isRequest = 0;
pSeq->commonParams.waitTime = 0;
pSeq->commonParams.ckalFreqKHz = 64000; /* CKAL */
pSeq->commonParams.ckahFreqKHz = 96000; /* CKAH */
/* Initialize the data storage */
result = sony_demod_dvbs_s2_blindscan_StorageInit (&(pSeq->commonParams.storage),
pSeq->powerArray,
sizeof(pSeq->powerArray)/sizeof(pSeq->powerArray[0]),
pSeq->dataArray,
sizeof(pSeq->dataArray)/sizeof(pSeq->dataArray[0]));
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN(result);
}
/* Initialize demodulator to start BlindScan. */
result = sony_demod_dvbs_s2_blindscan_Initialize(pSeq->commonParams.pDemod);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN(result);
}
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Initialize (&pSeq->subseqPM, &pSeq->commonParams);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN(result);
}
result = sony_demod_dvbs_s2_blindscan_subseq_ss_Initialize (&pSeq->subseqSS, &pSeq->commonParams);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN(result);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_sat_device_ctrl_find1ub_seq_Sequence (sony_demod_sat_device_ctrl_find1ub_seq_t * pSeq)
{
sony_result_t result = SONY_RESULT_OK;
sony_demod_dvbs_s2_blindscan_power_t * pPower;
SONY_TRACE_ENTER ("sony_demod_sat_device_ctrl_find1ub_seq_Sequence");
if (!pSeq){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if (pSeq->subseqSS.isEnable){
/* SS seq */
result = sony_demod_dvbs_s2_blindscan_subseq_ss_Sequence (&pSeq->subseqSS);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN(result);
}
} else if (pSeq->subseqPM.isEnable){
/* PM seq */
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Sequence(&pSeq->subseqPM);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN(result);
}
} else {
/* Main sequence */
switch(pSeq->seqState)
{
case FIND1UB_SEQ_STATE_START:
/* ODU_UbxSignal_ON */
result = sony_singlecable_command_ODU_UbxSignal_ON (&pSeq->message, SONY_SINGLECABLE_ADDRESS_ALL_DEVICES);
if (result != SONY_RESULT_OK) {return result;}
pSeq->commandReq = 1;
pSeq->commonParams.waitTime = SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_ODU_TX_WAIT;
pSeq->seqState = FIND1UB_SEQ_STATE_SS_START;
break;
case FIND1UB_SEQ_STATE_SS_START:
/* Get power spectrum */
result = sony_demod_dvbs_s2_blindscan_subseq_ss_Start(&pSeq->subseqSS,
pSeq->minPowerFreqKHz,
pSeq->maxPowerFreqKHz,
500,
20000,
1);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN(result);
}
pSeq->commonParams.waitTime = 0;
pSeq->seqState = FIND1UB_SEQ_STATE_SS_FIN;
break;
case FIND1UB_SEQ_STATE_SS_FIN:
SONY_DEMOD_DVBS_S2_BLINDSCAN_TRACE_POWERLIST("Power", pSeq->subseqSS.pPowerList);
pPower = pSeq->subseqSS.pPowerList->pNext;
pSeq->pmax_fn = 0;
while(pPower){
if(pPower->freqKHz > 0){
/* Valid data */
if((pSeq->pmax_fn == 0) || (pSeq->pmax_p1 < pPower->power)){
pSeq->pmax_fn = pPower->freqKHz;
pSeq->pmax_p1 = pPower->power;
}
}
pPower = pPower->pNext;
}
pSeq->loopCount = 0;
/* Fall through */
case FIND1UB_SEQ_STATE_TRIAL1:
pPower = pSeq->subseqSS.pPowerList->pNext;
pSeq->pmax_fn = 0;
pSeq->pmax_pn = 0;
while(pPower){
if(pPower->freqKHz > 0){
/* Valid data */
if((pSeq->pmax_fn == 0) || (pSeq->pmax_pn < pPower->power)){
pSeq->pmax_fn = pPower->freqKHz;
pSeq->pmax_pn = pPower->power;
}
}
pPower = pPower->pNext;
}
/* ODU_UbxSignal_ON */
result = sony_singlecable_command_ODU_UbxSignal_ON (&pSeq->message, SONY_SINGLECABLE_ADDRESS_ALL_DEVICES);
if (result != SONY_RESULT_OK) {
return result;
}
pSeq->commandReq = 1;
pSeq->commonParams.waitTime = SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_ODU_TX_WAIT;
pSeq->seqState = FIND1UB_SEQ_STATE_TUNING_ON;
break;
case FIND1UB_SEQ_STATE_TUNING_ON:
pSeq->commonParams.tuneReq.isRequest = 1;
pSeq->commonParams.tuneReq.frequencyKHz = pSeq->pmax_fn;
pSeq->commonParams.tuneReq.symbolRateKSps = 45000;
pSeq->commonParams.tuneReq.system = SONY_DTV_SYSTEM_DVBS;
pSeq->commonParams.waitTime = 50;
pSeq->seqState = FIND1UB_SEQ_STATE_AGC_ON;
break;
case FIND1UB_SEQ_STATE_AGC_ON:
pSeq->commonParams.agcInfo.isRequest = 1;
result = sony_demod_dvbs_s2_monitor_IFAGCOut(pSeq->commonParams.pDemod, &pSeq->commonParams.agcInfo.agcLevel);
if (result != SONY_RESULT_OK) {
return result;
}
pSeq->seqState = FIND1UB_SEQ_STATE_TRIAL2;
break;
case FIND1UB_SEQ_STATE_TRIAL2:
pSeq->offsetKHz = pSeq->pmax_fn - pSeq->commonParams.tuneReq.frequencyKHz;
if((pSeq->offsetKHz < -2000) || (pSeq->offsetKHz > 2000)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
result = sony_demod_dvbs_s2_blindscan_CS_INIT(pSeq->commonParams.pDemod);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (&pSeq->subseqPM, pSeq->offsetKHz);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->seqState = FIND1UB_SEQ_STATE_TRIAL3;
break;
case FIND1UB_SEQ_STATE_TRIAL3:
pSeq->powerOn = pSeq->subseqPM.power;
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (&pSeq->subseqPM, pSeq->offsetKHz - 500);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->seqState = FIND1UB_SEQ_STATE_TRIAL4;
break;
case FIND1UB_SEQ_STATE_TRIAL4:
if(pSeq->powerOn < pSeq->subseqPM.power){
pSeq->powerOn = pSeq->subseqPM.power;
}
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (&pSeq->subseqPM, pSeq->offsetKHz + 500);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->seqState = FIND1UB_SEQ_STATE_TRIAL5;
break;
case FIND1UB_SEQ_STATE_TRIAL5:
if(pSeq->powerOn < pSeq->subseqPM.power){
pSeq->powerOn = pSeq->subseqPM.power;
}
pSeq->powerOn = calcPower(pSeq->commonParams.agcInfo.agc_x100dB, (uint32_t)pSeq->powerOn);
result = sony_singlecable_command_ODU_PowerOFF (&pSeq->message, SONY_SINGLECABLE_ADDRESS_ALL_DEVICES, pSeq->targetUB);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->commandReq = 1;
pSeq->commonParams.waitTime = SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_ODU_TX_WAIT;
pSeq->seqState = FIND1UB_SEQ_STATE_TUNING_OFF;
break;
case FIND1UB_SEQ_STATE_TUNING_OFF:
pSeq->commonParams.tuneReq.isRequest = 1;
pSeq->commonParams.tuneReq.frequencyKHz = pSeq->pmax_fn;
pSeq->commonParams.tuneReq.symbolRateKSps = 45000;
pSeq->commonParams.tuneReq.system = SONY_DTV_SYSTEM_DVBS;
pSeq->commonParams.waitTime = 50;
pSeq->seqState = FIND1UB_SEQ_STATE_AGC_OFF;
break;
case FIND1UB_SEQ_STATE_AGC_OFF:
pSeq->commonParams.agcInfo.isRequest = 1;
result = sony_demod_dvbs_s2_monitor_IFAGCOut(pSeq->commonParams.pDemod, &pSeq->commonParams.agcInfo.agcLevel);
if (result != SONY_RESULT_OK) {
return result;
}
pSeq->seqState = FIND1UB_SEQ_STATE_TRIAL6;
break;
case FIND1UB_SEQ_STATE_TRIAL6:
pSeq->offsetKHz = pSeq->pmax_fn - pSeq->commonParams.tuneReq.frequencyKHz;
if((pSeq->offsetKHz < -2000) || (pSeq->offsetKHz > 2000)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (&pSeq->subseqPM, pSeq->offsetKHz);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->seqState = FIND1UB_SEQ_STATE_TRIAL7;
break;
case FIND1UB_SEQ_STATE_TRIAL7:
pSeq->powerOff = pSeq->subseqPM.power;
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (&pSeq->subseqPM, pSeq->offsetKHz - 500);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->seqState = FIND1UB_SEQ_STATE_TRIAL8;
break;
case FIND1UB_SEQ_STATE_TRIAL8:
if(pSeq->powerOff < pSeq->subseqPM.power){
pSeq->powerOff = pSeq->subseqPM.power;
}
result = sony_demod_dvbs_s2_blindscan_subseq_pm_Start (&pSeq->subseqPM, pSeq->offsetKHz + 500);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->seqState = FIND1UB_SEQ_STATE_TRIAL9;
break;
case FIND1UB_SEQ_STATE_TRIAL9:
if(pSeq->powerOff < pSeq->subseqPM.power){
pSeq->powerOff = pSeq->subseqPM.power;
}
pSeq->powerOff = calcPower(pSeq->commonParams.agcInfo.agc_x100dB, (uint32_t)pSeq->powerOff);
if((pSeq->powerOn - pSeq->powerOff) > 1000){
/* Detect user band frequency */
pSeq->ubFreqKHz = pSeq->pmax_fn;
/* Go to Finish State. */
pSeq->ubNumber = 1;
pSeq->seqState = FIND1UB_SEQ_STATE_FINISH;
} else {
/* Remove the data in +/- 2MHz area as spurious signal. */
pPower = pSeq->subseqSS.pPowerList->pNext;
while(pPower){
if((pPower->freqKHz > 0) && ((pSeq->pmax_fn - 2000) < (pPower->freqKHz)) && ((pPower->freqKHz) < (pSeq->pmax_fn + 2000))){
pPower->freqKHz = 0;
}
pPower = pPower->pNext;
}
/* Continue check */
if((pSeq->pmax_p1 - pSeq->pmax_pn) > 3000){
pSeq->ubFreqKHz = 0;
/* Go to Finish State. */
pSeq->ubNumber = 1;
pSeq->seqState = FIND1UB_SEQ_STATE_FINISH;
} else if(pSeq->loopCount++ > 30){
pSeq->ubFreqKHz = 0;
/* Go to Finish State. */
pSeq->ubNumber = 1;
pSeq->seqState = FIND1UB_SEQ_STATE_FINISH;
} else {
/* Go to next trial */
pSeq->seqState = FIND1UB_SEQ_STATE_TRIAL1;
}
}
break;
case FIND1UB_SEQ_STATE_FINISH:
/* Turning OFF the Power of all User bands as they were turned ON during start of algorithm. */
result = sony_singlecable_command_ODU_PowerOFF (&pSeq->message,
SONY_SINGLECABLE_ADDRESS_ALL_DEVICES,
pSeq->ubNumber);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->commandReq = 1;
if (pSeq->ubNumber == 8) {
/* Last user band so exit this algorithm too. */
pSeq->isContinue = 0;
}
/* Increment to Turn OFF the next userband in next cycle. */
pSeq->ubNumber ++;
break;
default:
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
}
SONY_TRACE_RETURN (result);
}
static int32_t calcPower(int32_t ifagcdb_x100, uint32_t power)
{
return (int32_t)(((int32_t)sony_math_log10 (power) - 421) * 10) - ifagcdb_x100;
}
@@ -0,0 +1,169 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
/**
@file sony_demod_sat_device_ctrl_find1ub_seq.h
This file provides definitions for Find1UB sequence function.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_SEQ_H
#define SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_SEQ_H
#include "sony_common.h"
#include "sony_demod.h"
#include "sony_singlecable_command.h"
#include "sony_demod_dvbs_s2_blindscan_data.h"
#include "sony_demod_dvbs_s2_blindscan_utility.h"
#include "sony_demod_dvbs_s2_blindscan_seq_common.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_pm.h"
#include "sony_demod_dvbs_s2_blindscan_subseq_ss.h"
/**
@brief Definition of search range in MHz.
This value is affected to the array size in Find1UB sequence.
Please set the value depend on users application.
Default value is 1220(MHz).
It is 940MHz - 2160MHz. ( with some margin )
*/
#define SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_SEARCH_RANGE_MHZ 1220
/**
@brief Definition of array size used in this driver.
The data size is depend on the input signal as follow.
- Search range.
- Power spectrum.
- etc...
User can get the maximum used data size by sony_demod_dvbs_s2_blindscan_data_storage_t::maxUsedCount.
If the driver returns SONY_RESULT_ERROR_OVERFLOW, please increase this value.
*/
//#define SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_DATA_MAX 10000
/**
@brief Definition of array size used in this driver.
This value is calculated by SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_SEARCH_RANGE_MHZ.
So user doesn't need to change this value directly.
*/
#define SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_POWER_MAX ((SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_SEARCH_RANGE_MHZ + 45) * 2)
/**
@brief Wait time in ms after sending ODU Single Cable commands.
This value depends on your Single Cable Switch.
Please confirm it with your environment and change it accordingly.
*/
#define SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_ODU_TX_WAIT 300
/**
@brief state of Find1UB sequence
*/
typedef enum {
FIND1UB_SEQ_STATE_START, /**< Start */
FIND1UB_SEQ_STATE_SS_START, /**< SS start */
FIND1UB_SEQ_STATE_SS_FIN, /**< SS fin */
FIND1UB_SEQ_STATE_TRIAL1, /**< Trial1 */
FIND1UB_SEQ_STATE_TRIAL2, /**< Trial2 */
FIND1UB_SEQ_STATE_TRIAL3, /**< Trial3 */
FIND1UB_SEQ_STATE_TRIAL4, /**< Trial4 */
FIND1UB_SEQ_STATE_TRIAL5, /**< Trial5 */
FIND1UB_SEQ_STATE_TRIAL6, /**< Trial6 */
FIND1UB_SEQ_STATE_TRIAL7, /**< Trial7 */
FIND1UB_SEQ_STATE_TRIAL8, /**< Trial8 */
FIND1UB_SEQ_STATE_TRIAL9, /**< Trial9 */
FIND1UB_SEQ_STATE_FINISH, /**< Finish */
FIND1UB_SEQ_STATE_TUNING_ON, /**< Tuning at UB on */
FIND1UB_SEQ_STATE_TUNING_OFF, /**< Tuning at UB off */
FIND1UB_SEQ_STATE_AGC_ON, /**< Getting AGC at UB on */
FIND1UB_SEQ_STATE_AGC_OFF, /**< Getting AGC at UB off */
FIND1UB_SEQ_STATE_UNKNOWN /**< Unknown */
} sony_demod_sat_device_ctrl_find1ub_seq_state_t;
/**
@brief Structure for find1ub sequence.
*/
typedef struct {
/**
@brief Common parameters used by each sub sequence
*/
sony_demod_dvbs_s2_blindscan_seq_common_t commonParams;
/**
@brief Finish/Continue flag.
- 0: Finish the sequence.
- 1: Continue the sequence.
*/
uint8_t isContinue;
sony_demod_sat_device_ctrl_find1ub_seq_state_t seqState; /**< State of Find1UB sequence. */
sony_demod_dvbs_s2_blindscan_subseq_pm_t subseqPM; /**< Data for sub sequence PM. */
sony_demod_dvbs_s2_blindscan_subseq_ss_t subseqSS; /**< Data for sub sequence SS. */
uint32_t minFreqKHz; /**< Min frequency in KHz which set by Find1UB API */
uint32_t maxFreqKHz; /**< Max frequency in KHz which set by Find1UB API */
uint32_t minPowerFreqKHz; /**< Min frequency in KHz which need for power spectrum */
uint32_t maxPowerFreqKHz; /**< Max frequency in KHz which need for power spectrum */
uint8_t commandReq; /**< Request to transmit command */
sony_diseqc_message_t message; /**< Single cable command data */
uint8_t targetUB; /**< Target user band to detect */
uint32_t ubFreqKHz; /**< Frequency of target UB. If this is 0 at isContinue = 0, driver can't detect target UB. */
int32_t pmax_p1; /**< Max power at the 1st trial */
uint32_t pmax_fn; /**< Frequency of max power at Nth trial */
int32_t pmax_pn; /**< Max power at the Nth trial */
int32_t loopCount; /**< Loop count in the trial sequence */
int32_t powerOn; /**< Power at UB on */
int32_t powerOff; /**< Power at UB off */
int32_t offsetKHz; /**< Offset frequency between "pmax_fn" and "tuned frequency" */
uint8_t ubNumber; /**< UB Number. */
/**
@brief Power data for storage.
*/
sony_demod_dvbs_s2_blindscan_power_t powerArray[SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_POWER_MAX];
/**
@brief Data for storage.
*/
sony_demod_dvbs_s2_blindscan_data_t dataArray[1];
} sony_demod_sat_device_ctrl_find1ub_seq_t;
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Prepare to start Find1UB sequence.
@param pSeq The sequence instance.
@param pDemod Demodulator instance.
@param minFreqKHz Minimum frequency of the scan range in KHz.
@param maxFreqKHz Maximum frequency of the scan range in KHz.
@param targetUB Target user band which user want to find. (1-8)
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_sat_device_ctrl_find1ub_seq_Initialize (sony_demod_sat_device_ctrl_find1ub_seq_t * pSeq,
sony_demod_t * pDemod,
uint32_t minFreqKHz,
uint32_t maxFreqKHz,
uint8_t targetUB);
/**
@brief Execute one sequence for Find1UB.
@param pSeq The sequence instance.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_sat_device_ctrl_find1ub_seq_Sequence (sony_demod_sat_device_ctrl_find1ub_seq_t * pSeq);
#endif /* SONY_DEMOD_SAT_DEVICE_CTRL_FIND1UB_SEQ_H */
@@ -0,0 +1,348 @@
/*------------------------------------------------------------------------------
Copyright 2017-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/09/28
Modification ID : 1ea04def104d657deb64f0d0b0cae6ef992a9dd8
------------------------------------------------------------------------------*/
#include "sony_common.h"
#include "sony_demod.h"
#include "sony_integ_dvbs_s2_blindscan.h"
#include "sony_demod_dvbs_s2_blindscan.h"
#include "sony_demod_dvbs_s2_blindscan_seq.h"
#include "sony_demod_dvbs_s2_tune_srs_seq.h"
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
sony_result_t sony_integ_dvbs_s2_TuneSRS (sony_integ_t * pInteg,
sony_demod_dvbs_s2_tune_srs_seq_t * pSeq,
sony_integ_dvbs_s2_tune_srs_param_t * pParam,
sony_dvbs_s2_tune_param_t * pTuneParam)
{
sony_result_t result = SONY_RESULT_OK;
uint32_t elapsedTime = 0;
sony_stopwatch_t stopwatch;
SONY_TRACE_ENTER ("sony_integ_dvbs_s2_TuneSRS");
if ((!pInteg) || (!pInteg->pDemod) || (!pSeq) || (!pParam) || (!pTuneParam) ||
(!pInteg->pTuner) || (!pInteg->pTuner->CalcRFLevelFromAGC) ||
(!pInteg->pTuner->SatTune)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if ((pInteg->pDemod->state != SONY_DEMOD_STATE_SLEEP) &&
(pInteg->pDemod->state != SONY_DEMOD_STATE_ACTIVE)){
/* This api is accepted in Sleep and Active states only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
result = sony_demod_dvbs_s2_tune_srs_seq_Initialize (pSeq,
pInteg->pDemod,
pParam->centerFreqKHz,
pParam->freqRange);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
while(pSeq->isContinue){
/* Check cancellation. */
result = sony_integ_CheckCancellation (pInteg);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
if (pSeq->commonParams.waitTime == 0){
/* Execute one sequence */
result = sony_demod_dvbs_s2_tune_srs_seq_Sequence (pSeq);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Start stopwatch */
result= sony_stopwatch_start (&stopwatch);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* AGC calculate is requested */
if (pSeq->commonParams.agcInfo.isRequest){
int32_t rfLevel;
/* Clear request flag. */
pSeq->commonParams.agcInfo.isRequest = 0;
result = pInteg->pTuner->CalcRFLevelFromAGC (pInteg->pTuner,
pSeq->commonParams.agcInfo.agcLevel,
&rfLevel);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->commonParams.agcInfo.agc_x100dB = -rfLevel; /* Gain value should be set. */
}
/* Tune is requested */
if (pSeq->commonParams.tuneReq.isRequest){
uint32_t symbolRateKSps = pSeq->commonParams.tuneReq.symbolRateKSps;
/* Clear request flag. */
pSeq->commonParams.tuneReq.isRequest = 0;
/* Symbol rate */
if (symbolRateKSps == 0) {
/* Symbol rate setting for power spectrum */
symbolRateKSps = pInteg->pTuner->symbolRateKSpsForSpectrum;
}
/* Enable the I2C repeater */
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x01);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* RF Tune */
result = pInteg->pTuner->SatTune (pInteg->pTuner,
pSeq->commonParams.tuneReq.frequencyKHz,
pSeq->commonParams.tuneReq.system,
symbolRateKSps);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Set actual frequency to the driver. */
pSeq->commonParams.tuneReq.frequencyKHz = pInteg->pTuner->frequencyKHz;
/* Disable the I2C repeater */
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x00);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
}
} else {
/* waiting */
result = sony_stopwatch_sleep (&stopwatch, SONY_INTEG_DVBS_S2_TUNE_SRS_POLLING_INTERVAL);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_stopwatch_elapsed (&stopwatch, &elapsedTime);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if(elapsedTime > pSeq->commonParams.waitTime){
pSeq->commonParams.waitTime = 0;
}
}
}
if (pSeq->isDetect){
/* Tune successful. */
pTuneParam->centerFreqKHz = pSeq->tuneParam.centerFreqKHz;
pTuneParam->symbolRateKSps = pSeq->tuneParam.symbolRateKSps;
pTuneParam->system = pSeq->tuneParam.system;
/* TS output enable */
result = sony_demod_SetStreamOutput (pInteg->pDemod, 1);
} else {
result = SONY_RESULT_ERROR_UNLOCK;
}
SONY_TRACE_RETURN (result);
}
sony_result_t sony_integ_dvbs_s2_BlindScan (sony_integ_t * pInteg,
sony_demod_dvbs_s2_blindscan_seq_t * pSeq,
sony_integ_dvbs_s2_blindscan_param_t * pParam,
sony_integ_dvbs_s2_blindscan_callback_t callback)
{
sony_result_t result = SONY_RESULT_OK;
uint32_t elapsedTime = 0;
sony_stopwatch_t stopwatch;
sony_integ_dvbs_s2_blindscan_result_t blindscanResult;
SONY_TRACE_ENTER("sony_integ_dvbs_s2_BlindScan");
if ((!pInteg) || (!pInteg->pDemod) || (!pSeq) || (!pParam) || (!callback) ||
(!pInteg->pTuner) || (!pInteg->pTuner->CalcRFLevelFromAGC) ||
(!pInteg->pTuner->SatTune) || (!pInteg->pTuner->Sleep)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if ((pInteg->pDemod->state != SONY_DEMOD_STATE_SLEEP) &&
(pInteg->pDemod->state != SONY_DEMOD_STATE_ACTIVE)){
/* This api is accepted in Sleep and Active states only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
result = sony_demod_dvbs_s2_blindscan_seq_Initialize (pSeq,
pInteg->pDemod,
pParam->minFreqKHz,
pParam->maxFreqKHz,
pParam->minSymbolRateKSps,
pParam->maxSymbolRateKSps);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
while(pSeq->isContinue){
/* Check cancellation. */
result = sony_integ_CheckCancellation (pInteg);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
if (pSeq->commonParams.waitTime == 0){
/* Execute one sequence */
#ifdef SONY_DEMOD_SUPPORT_DVBS_S2_BLINDSCAN_VER2
if(pSeq->commonParams.pDemod->dvbss2BlindScanVersion == SONY_DEMOD_DVBSS2_BLINDSCAN_VERSION2) {
result = sony_demod_dvbs_s2_blindscan_version2_seq_Sequence (pSeq);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
} else
#endif
{
result = sony_demod_dvbs_s2_blindscan_seq_Sequence (pSeq);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
}
/* Start stopwatch */
result = sony_stopwatch_start (&stopwatch);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if (pSeq->commonParams.agcInfo.isRequest){
int32_t rfLevel;
/* Clear request flag. */
pSeq->commonParams.agcInfo.isRequest = 0;
result = pInteg->pTuner->CalcRFLevelFromAGC (pInteg->pTuner,
pSeq->commonParams.agcInfo.agcLevel,
&rfLevel);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->commonParams.agcInfo.agc_x100dB = -rfLevel; /* Gain value should be set. */
}
if (pSeq->commonParams.tuneReq.isRequest){
uint32_t symbolRateKSps = pSeq->commonParams.tuneReq.symbolRateKSps;
/* Clear request flag. */
pSeq->commonParams.tuneReq.isRequest = 0;
/* Symbol rate */
if (symbolRateKSps == 0) {
/* Symbol rate setting for power spectrum */
symbolRateKSps = pInteg->pTuner->symbolRateKSpsForSpectrum;
}
/* Enable the I2C repeater */
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x01);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* RF Tune */
result = pInteg->pTuner->SatTune (pInteg->pTuner,
pSeq->commonParams.tuneReq.frequencyKHz,
pSeq->commonParams.tuneReq.system,
symbolRateKSps);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->commonParams.tuneReq.frequencyKHz = pInteg->pTuner->frequencyKHz;
/* Disable the I2C repeater */
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x00);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
}
if (pSeq->commonParams.detInfo.isDetect){
/* Clear detect flag */
pSeq->commonParams.detInfo.isDetect = 0;
/* Prepare callback information.(Detected channel) */
blindscanResult.eventId = SONY_INTEG_DVBS_S2_BLINDSCAN_EVENT_DETECT;
blindscanResult.tuneParam.system = pSeq->commonParams.detInfo.system;
blindscanResult.tuneParam.centerFreqKHz = pSeq->commonParams.detInfo.centerFreqKHz;
blindscanResult.tuneParam.symbolRateKSps = pSeq->commonParams.detInfo.symbolRateKSps;
/* TS output enable */
result = sony_demod_SetStreamOutput (pInteg->pDemod, 1);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Callback */
callback(pInteg, &blindscanResult);
/* TS output disable */
result = sony_demod_SetStreamOutput (pInteg->pDemod, 0);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
}
{
/* Progress calculation */
uint8_t progress = 0;
uint8_t rangeMin = pSeq->commonParams.progressInfo.majorMinProgress;
uint8_t rangeMax = pSeq->commonParams.progressInfo.majorMaxProgress;
uint8_t minorProgress = pSeq->commonParams.progressInfo.minorProgress;
progress = rangeMin + (((rangeMax - rangeMin) * minorProgress) / 100);
if (pSeq->commonParams.progressInfo.progress < progress){
pSeq->commonParams.progressInfo.progress = progress;
/* Prepare callback information.(Progress) */
blindscanResult.eventId = SONY_INTEG_DVBS_S2_BLINDSCAN_EVENT_PROGRESS;
blindscanResult.progress = progress;
/* Callback */
callback(pInteg, &blindscanResult);
}
}
} else {
/* waiting */
result = sony_stopwatch_sleep (&stopwatch, SONY_INTEG_DVBS_S2_BLINDSCAN_POLLING_INTERVAL);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_stopwatch_elapsed (&stopwatch, &elapsedTime);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if(elapsedTime > pSeq->commonParams.waitTime){
pSeq->commonParams.waitTime = 0;
}
}
}
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x01);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = pInteg->pTuner->Sleep(pInteg->pTuner);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x00);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_dvbs_s2_Sleep (pSeq->commonParams.pDemod);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
SONY_TRACE_RETURN(result);
}
@@ -0,0 +1,196 @@
/*------------------------------------------------------------------------------
Copyright 2017-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/09/28
Modification ID : 1ea04def104d657deb64f0d0b0cae6ef992a9dd8
------------------------------------------------------------------------------*/
/**
@file sony_integ_dvbs_s2_blindscan.h
This file provides the integration layer interface for DVB-S/S2 blindscan
related functions.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_INTEG_DVBS_S2_BLINDSCAN_H
#define SONY_INTEG_DVBS_S2_BLINDSCAN_H
#include "sony_integ.h"
#include "sony_demod_dvbs_s2.h"
#include "sony_demod_dvbs_s2_blindscan_seq.h"
#include "sony_demod_dvbs_s2_tune_srs.h"
#include "sony_demod_dvbs_s2_tune_srs_seq.h"
/*------------------------------------------------------------------------------
Defines
------------------------------------------------------------------------------*/
/**
@brief Polling interval for BlindScan sequence in ms.
*/
#define SONY_INTEG_DVBS_S2_BLINDSCAN_POLLING_INTERVAL 10
/**
@brief Polling interval for TuneSRS sequence in ms.
*/
#define SONY_INTEG_DVBS_S2_TUNE_SRS_POLLING_INTERVAL 10
/*------------------------------------------------------------------------------
Enums
------------------------------------------------------------------------------*/
/**
@brief Definition of event id for callback from BlindScan.
*/
typedef enum {
SONY_INTEG_DVBS_S2_BLINDSCAN_EVENT_DETECT, /**< Detect channel. */
SONY_INTEG_DVBS_S2_BLINDSCAN_EVENT_PROGRESS /**< Update progress. */
} sony_integ_dvbs_s2_blindscan_event_id_t;
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief The TuneSRS functions parameters for a DVB-S/S2 signal.
*/
typedef struct {
/**
@brief Center frequency in KHz of the DVB-S/S2 channel.
*/
uint32_t centerFreqKHz;
/**
@brief Frequency range found by TuneSRS.
*/
sony_demod_dvbs_s2_tune_srs_freq_range_t freqRange;
} sony_integ_dvbs_s2_tune_srs_param_t;
/**
@brief Definition of the parameters for BlindScan.
*/
typedef struct {
/**
@brief Min frequency of scan range in KHz.
Please set the min frequency of channel which you would like to detect in KHz.
(i.e. 950000)
*/
uint32_t minFreqKHz;
/**
@brief Max frequency of scan range.
Please set the min frequency of channel which you would like to detect in KHz.
(i.e. 2150000)
*/
uint32_t maxFreqKHz;
/**
@brief Min symbol rate of scan range.
Please set the min symbol rate of channel which you would like to detect in KSps.
(i.e. 1000)
*/
uint32_t minSymbolRateKSps;
/**
@brief Max symbol rate of scan range.
Please set the max symbol rate of channel which you would like to detect in KSps.
(i.e. 45000)
*/
uint32_t maxSymbolRateKSps;
} sony_integ_dvbs_s2_blindscan_param_t;
/**
@brief Definition of the result of BlindScan.
*/
typedef struct {
/**
@brief The cause of callback.
When callback function was called, please check it first.
*/
sony_integ_dvbs_s2_blindscan_event_id_t eventId;
/**
@brief Detected channel information.
If "eventId == SONY_INTEG_DVBS_S2_BLINDSCAN_EVENT_DETECT", this value is valid.
*/
sony_dvbs_s2_tune_param_t tuneParam;
/**
@brief Progress.
If "eventId == SONY_INTEG_DVBS_S2_BLINDSCAN_EVENT_PROGRESS", this value is valid.
The range of this value is 0 - 100 in percentage.
*/
uint8_t progress;
}sony_integ_dvbs_s2_blindscan_result_t;
/*------------------------------------------------------------------------------
Function Pointers
------------------------------------------------------------------------------*/
/**
@brief Callback function that is called for every attempted frequency during a DVB-S/S2
scan. For successful channel results the function is called before TS lock
is achieved.
@param pInteg The driver instance.
@param pResult The current scan result.
*/
typedef void (*sony_integ_dvbs_s2_blindscan_callback_t) (sony_integ_t * pInteg,
sony_integ_dvbs_s2_blindscan_result_t * pResult);
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Tune SRS (Symbol Rate Search) performs a blind acquisition to the
channel with wider range than ::sony_integ_dvbs_s2_Tune(). It captures
an available signal having Symbol Rate of 1 to 45 MSps and centred
within +/- 10 MHz of the RF frequency specified by the pParam struct.
This enables acquisition to a DVB-S or DVB-S2 channel where the center
frequency or symbol rate is not precisely known.
The located channel tune parameters are then written into the pTuneParam
structure, which can subsequently be passed to ::sony_integ_dvbs_s2_Tune
for quicker acquisition.
Blocks the calling thread until the TS has locked or has timed out.
Use ::sony_integ_Cancel to cancel the operation at any time.
@param pInteg The driver instance.
@param pSeq The sequence instance.
@param pParam Parameter for TuneSRS.
@param pTuneParam The detected channel information.
@return SONY_RESULT_OK if tuned successfully to the channel and pTuneParam is valid.
*/
sony_result_t sony_integ_dvbs_s2_TuneSRS (sony_integ_t * pInteg,
sony_demod_dvbs_s2_tune_srs_seq_t * pSeq,
sony_integ_dvbs_s2_tune_srs_param_t * pParam,
sony_dvbs_s2_tune_param_t * pTuneParam);
/**
@brief BlindScan searches channels within the frequency and symbol rate range set
by pParam. The whole process is carried out in three steps. In the first step,
it finds channels having Symbol Rate more than 20 MSps. In the second step, it
finds channels having Symbol Rate between 5 to 20 MSps. In the third step, it
finds channels having Symbol Rate between 1 to 5 MSps.
Callback function is called during each step at the following points.
- Detected channel
- Update progress
The source of callback is determined by checking sony_integ_dvbs_s2_blindscan_result_t::eventId.
Please see explanation in ::sony_integ_dvbs_s2_blindscan_result_t structure.
Blocks the calling thread until the BlindScan has finished.
Use ::sony_integ_Cancel to cancel the operation at any time.
@param pInteg The integration part instance.
@param pSeq The sequence instance.
@param pParam Scan parameters.
@param callback Callback function pointer.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_integ_dvbs_s2_BlindScan (sony_integ_t * pInteg,
sony_demod_dvbs_s2_blindscan_seq_t * pSeq,
sony_integ_dvbs_s2_blindscan_param_t * pParam,
sony_integ_dvbs_s2_blindscan_callback_t callback);
#endif /* SONY_INTEG_DVBS_S2_BLINDSCAN_H */
@@ -0,0 +1,333 @@
/*------------------------------------------------------------------------------
Copyright 2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/12/13
Modification ID : e402a4dcb0e51a00c34b174334c082c1211eebf1
------------------------------------------------------------------------------*/
#include "sony_integ_sat_device_ctrl_singlecable_auto_install.h"
#include "sony_integ_sat_device_ctrl.h"
/*------------------------------------------------------------------------------
Static Functions
------------------------------------------------------------------------------*/
static sony_result_t getCWPower (sony_integ_t * pInteg,
sony_demod_sat_device_ctrl_detect_cw_seq_t * pSeq,
uint32_t freqKHz,
uint32_t rangeKHz,
int32_t * pPower);
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
sony_result_t sony_integ_sat_device_ctrl_Find1UB (sony_integ_t * pInteg,
sony_demod_sat_device_ctrl_find1ub_seq_t * pSeq,
uint32_t minFreqKHz,
uint32_t maxFreqKHz,
uint8_t userbandId,
uint32_t * pFreqKHz)
{
sony_result_t result = SONY_RESULT_OK;
uint32_t elapsedTime = 0;
sony_stopwatch_t stopwatch;
SONY_TRACE_ENTER ("sony_integ_sat_device_ctrl_Find1UB");
if ((!pInteg) || (!pInteg->pDemod) || (!pSeq) || (!pFreqKHz) ||
(!pInteg->pTuner) || (!pInteg->pTuner->CalcRFLevelFromAGC) ||
(!pInteg->pTuner->SatTune)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if ((pInteg->pDemod->state != SONY_DEMOD_STATE_SLEEP) && (pInteg->pDemod->state != SONY_DEMOD_STATE_ACTIVE)) {
/* This api is accepted in Sleep and Active states only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
if (pInteg->pDemod->isSinglecable){
/* Current Demod/Tuner is configured for Single Cable but
this API is accepted in non-Single Cable (Normal) mode only. */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Enable satellite device control function */
result = sony_integ_sat_device_ctrl_Enable (pInteg, 1);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_sat_device_ctrl_find1ub_seq_Initialize (pSeq, pInteg->pDemod, minFreqKHz, maxFreqKHz, userbandId);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
while(pSeq->isContinue){
/* Check cancellation. */
result = sony_integ_CheckCancellation (pInteg);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
if (pSeq->commonParams.waitTime == 0){
/* Execute one sequence */
result = sony_demod_sat_device_ctrl_find1ub_seq_Sequence (pSeq);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Start stopwatch */
result = sony_stopwatch_start (&stopwatch);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Transmitting single cable command is requested */
if (pSeq->commandReq){
pSeq->commandReq = 0;
result = sony_integ_sat_device_ctrl_TransmitSinglecableCommand(pInteg, &pSeq->message);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
}
/* AGC calculate is requested */
if (pSeq->commonParams.agcInfo.isRequest){
int32_t rfLevel;
/* Clear request flag. */
pSeq->commonParams.agcInfo.isRequest = 0;
result = pInteg->pTuner->CalcRFLevelFromAGC (pInteg->pTuner,
pSeq->commonParams.agcInfo.agcLevel,
&rfLevel);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->commonParams.agcInfo.agc_x100dB = -rfLevel; /* Gain value should be set. */
}
/* Tune is requested */
if (pSeq->commonParams.tuneReq.isRequest){
/* Clear request flag. */
pSeq->commonParams.tuneReq.isRequest = 0;
/* Enable the I2C repeater */
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x01);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* RF Tune */
result = pInteg->pTuner->SatTune (pInteg->pTuner,
pSeq->commonParams.tuneReq.frequencyKHz,
pSeq->commonParams.tuneReq.system,
pSeq->commonParams.tuneReq.symbolRateKSps);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Set actual frequency to the driver. */
pSeq->commonParams.tuneReq.frequencyKHz = pInteg->pTuner->frequencyKHz;
/* Disable the I2C repeater */
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x00);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
}
} else {
/* waiting */
result = sony_stopwatch_sleep (&stopwatch, 10);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_stopwatch_elapsed (&stopwatch, &elapsedTime);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if(elapsedTime > pSeq->commonParams.waitTime){
pSeq->commonParams.waitTime = 0;
}
}
}
*pFreqKHz = pSeq->ubFreqKHz;
result = sony_integ_Sleep (pInteg);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
SONY_TRACE_RETURN (result);
}
sony_result_t sony_integ_sat_device_ctrl_DetectYesNo (sony_integ_t * pInteg,
sony_demod_sat_device_ctrl_detect_cw_seq_t * pSeq,
uint32_t ubFreqKHz,
uint32_t noFreqOffsetKHz,
uint32_t yesMarginFreqKHz,
uint32_t noMarginFreqKHz,
sony_integ_sat_device_ctrl_detect_yes_no_result_t * pResult)
{
sony_result_t result = SONY_RESULT_OK;
int32_t yesPower = 0;
int32_t noPower = 0;
SONY_TRACE_ENTER ("sony_integ_sat_device_ctrl_DetectYesNo");
if ((!pInteg) || (!pInteg->pDemod) || (!pSeq) || (!pResult)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if ((pInteg->pDemod->state != SONY_DEMOD_STATE_SLEEP) && (pInteg->pDemod->state != SONY_DEMOD_STATE_ACTIVE)) {
/* This api is accepted in Sleep and Active states only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
if (pInteg->pDemod->isSinglecable){
/* Current Demod/Tuner is configured for Single Cable but
this API is accepted in non-Single Cable (Normal) mode only. */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
result = getCWPower (pInteg, pSeq, ubFreqKHz, yesMarginFreqKHz, &yesPower);
if(result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = getCWPower (pInteg, pSeq, ubFreqKHz + noFreqOffsetKHz, noMarginFreqKHz, &noPower);
if(result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if(yesPower >= noPower + 1000){
/* Return YES. */
*pResult = SONY_INTEG_SAT_DEVICE_CTRL_DETECT_YES_NO_RESULT_YES;
} else if(noPower >= yesPower + 1000) {
/* Return NO. */
*pResult = SONY_INTEG_SAT_DEVICE_CTRL_DETECT_YES_NO_RESULT_NO;
} else {
/* Return NOT Detected. */
*pResult = SONY_INTEG_SAT_DEVICE_CTRL_DETECT_YES_NO_RESULT_NOTDETECT;
}
result = sony_integ_Sleep (pInteg);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
SONY_TRACE_RETURN (result);
}
/*------------------------------------------------------------------------------
Static Functions
------------------------------------------------------------------------------*/
static sony_result_t getCWPower (sony_integ_t * pInteg,
sony_demod_sat_device_ctrl_detect_cw_seq_t * pSeq,
uint32_t freqKHz,
uint32_t rangeKHz,
int32_t * pPower)
{
sony_result_t result = SONY_RESULT_OK;
uint32_t elapsedTime = 0;
sony_stopwatch_t stopwatch;
SONY_TRACE_ENTER ("getCWPower");
if ((!pInteg) || (!pInteg->pDemod) || (!pSeq) || (!pPower) ||
(!pInteg->pTuner) || (!pInteg->pTuner->CalcRFLevelFromAGC)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
result = sony_demod_sat_device_ctrl_detect_cw_seq_Initialize (pSeq, pInteg->pDemod, freqKHz, rangeKHz);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
while(pSeq->isContinue){
/* Check cancellation. */
result = sony_integ_CheckCancellation (pInteg);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
if (pSeq->commonParams.waitTime == 0){
/* Execute one sequence */
result = sony_demod_sat_device_ctrl_detect_cw_seq_Sequence (pSeq);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Start stopwatch */
result = sony_stopwatch_start (&stopwatch);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* AGC calculate is requested */
if (pSeq->commonParams.agcInfo.isRequest){
int32_t rfLevel;
/* Clear request flag. */
pSeq->commonParams.agcInfo.isRequest = 0;
result = pInteg->pTuner->CalcRFLevelFromAGC (pInteg->pTuner,
pSeq->commonParams.agcInfo.agcLevel,
&rfLevel);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
pSeq->commonParams.agcInfo.agc_x100dB = -rfLevel; /* Gain value should be set. */
}
/* Tune is requested */
if (pSeq->commonParams.tuneReq.isRequest){
/* Clear request flag. */
pSeq->commonParams.tuneReq.isRequest = 0;
if ((pInteg->pTuner) && (pInteg->pTuner->SatTune)) {
/* Enable the I2C repeater */
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x01);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* RF Tune */
result = pInteg->pTuner->SatTune (pInteg->pTuner,
pSeq->commonParams.tuneReq.frequencyKHz,
pSeq->commonParams.tuneReq.system,
pSeq->commonParams.tuneReq.symbolRateKSps);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Set actual frequency to the driver. */
pSeq->commonParams.tuneReq.frequencyKHz = pInteg->pTuner->frequencyKHz;
/* Disable the I2C repeater */
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x00);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
}
}
} else {
/* waiting */
result = sony_stopwatch_sleep (&stopwatch, 10);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_stopwatch_elapsed (&stopwatch, &elapsedTime);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if(elapsedTime > pSeq->commonParams.waitTime){
pSeq->commonParams.waitTime = 0;
}
}
}
*pPower = pSeq->power;
SONY_TRACE_RETURN (result);
}
@@ -0,0 +1,81 @@
/*------------------------------------------------------------------------------
Copyright 2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/12/13
Modification ID : e402a4dcb0e51a00c34b174334c082c1211eebf1
------------------------------------------------------------------------------*/
/**
@file sony_integ_sat_device_ctrl_singlecable_auto_install.h
This file provide functions useful for single cable 1 (EN50494) automatic installation.
This file located in blindscan folder because blind scanning technique is used.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_INTEG_SAT_DEVICE_CTRL_SINGLECABLE_AUTO_INSTALL_H
#define SONY_INTEG_SAT_DEVICE_CTRL_SINGLECABLE_AUTO_INSTALL_H
#include "sony_integ.h"
#include "sony_demod_sat_device_ctrl_find1ub_seq.h"
#include "sony_demod_sat_device_ctrl_detect_cw_seq.h"
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief Return codes for Detect YES/NO results.
*/
typedef enum {
SONY_INTEG_SAT_DEVICE_CTRL_DETECT_YES_NO_RESULT_YES, /**< Detected YES Signal for Detect YES/NO. */
SONY_INTEG_SAT_DEVICE_CTRL_DETECT_YES_NO_RESULT_NO, /**< Detected NO Signal for Detect YES/NO. */
SONY_INTEG_SAT_DEVICE_CTRL_DETECT_YES_NO_RESULT_NOTDETECT,/**< Could not detect any YES/NO signal. */
} sony_integ_sat_device_ctrl_detect_yes_no_result_t;
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Find one user band.
@note LNB controller and satellite device control function will be automatically enabled.
@param pInteg The integration part instance.
@param pSeq The address of sequence instance.
@param minFreqKHz The minimum frequency of search range in KHz.
@param maxFreqKHz The maximum frequency of search range in KHz.
@param userbandId The user band ID.(1-8)
@param pFreqKHz The address of detected frequency in KHz.
If this value is 0, driver can't detect target user band.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_integ_sat_device_ctrl_Find1UB (sony_integ_t * pInteg,
sony_demod_sat_device_ctrl_find1ub_seq_t * pSeq,
uint32_t minFreqKHz,
uint32_t maxFreqKHz,
uint8_t userbandId,
uint32_t * pFreqKHz);
/**
@brief Detect YES/NO answer from SCIF.
@note LNB controller and satellite device control function will be automatically enabled.
@param pInteg The integration part instance.
@param pSeq The address of sequence instance.
@param ubFreqKHz The frequency of the target user band in KHz.
@param noFreqOffsetKHz The frequency offset for NO signal from the target user band in KHz. (20,000 is default)
@param yesMarginFreqKHz The margin frequency for YES signal. (500 is default)
@param noMarginFreqKHz The margin frequency for NO signal. (1000 is default)
@param pResult The address of result for this API.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_integ_sat_device_ctrl_DetectYesNo (sony_integ_t * pInteg,
sony_demod_sat_device_ctrl_detect_cw_seq_t * pSeq,
uint32_t ubFreqKHz,
uint32_t noFreqOffsetKHz,
uint32_t yesMarginFreqKHz,
uint32_t noMarginFreqKHz,
sony_integ_sat_device_ctrl_detect_yes_no_result_t * pResult);
#endif /* SONY_INTEG_SAT_DEVICE_CTRL_SINGLECABLE_AUTO_INSTALL_H */
+619
View File
@@ -0,0 +1,619 @@
/*------------------------------------------------------------------------------
Copyright 2016-2019 Sony Semiconductor Solutions Corporation
Last Updated : 2019/06/28
Modification ID : 4d12c6351929bcae29649d686be7d406fd4718c8
------------------------------------------------------------------------------*/
#include "sony_dtv.h"
#include "sony_common.h"
#include "sony_demod_dvbs_s2.h"
#include "sony_demod_dvbs_s2_monitor.h"
/*------------------------------------------------------------------------------
Static Function Prototypes
------------------------------------------------------------------------------*/
static sony_result_t SLtoASX (sony_demod_t * pDemod,
sony_dtv_system_t dtvSystem,
uint32_t symbolRateKSps);
static sony_result_t ASXtoSL (sony_demod_t * pDemod);
static sony_result_t ASXtoASX (sony_demod_t * pDemod,
uint32_t symbolRateKSps);
static sony_result_t TSRStoSL(sony_demod_t * pDemod);
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
sony_result_t sony_demod_dvbs_s2_Tune (sony_demod_t * pDemod,
sony_dvbs_s2_tune_param_t * pTuneParam)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_Tune");
if ((!pDemod) || (!pTuneParam)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if ((pTuneParam->system != SONY_DTV_SYSTEM_DVBS) &&
(pTuneParam->system != SONY_DTV_SYSTEM_DVBS2) &&
(pTuneParam->system != SONY_DTV_SYSTEM_ANY)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if (pDemod->state == SONY_DEMOD_STATE_ACTIVE) {
/* Active */
if (pDemod->dvbss2ScanMode > 0){
/* Scan -> Sleep */
result = TSRStoSL (pDemod);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Sleep -> Active-S(X) */
result = SLtoASX (pDemod, pTuneParam->system, pTuneParam->symbolRateKSps);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
} else if (pDemod->system == pTuneParam->system){
/* Active-S(X) -> Active-S(X) */
result = ASXtoASX (pDemod, pTuneParam->symbolRateKSps);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
} else {
/* To Sleep */
result = sony_demod_Sleep (pDemod);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Sleep -> Active-S(X) */
result = SLtoASX (pDemod, pTuneParam->system, pTuneParam->symbolRateKSps);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
}
} else if (pDemod->state == SONY_DEMOD_STATE_SLEEP){
/* Sleep -> Active-S(X) */
result = SLtoASX (pDemod, pTuneParam->system, pTuneParam->symbolRateKSps);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
} else {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
pDemod->state = SONY_DEMOD_STATE_ACTIVE;
pDemod->system = pTuneParam->system;
pDemod->dvbss2ScanMode = 0;
SONY_TRACE_RETURN (result);
}
sony_result_t sony_demod_dvbs_s2_Sleep (sony_demod_t * pDemod)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_Sleep");
if (!pDemod) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if (pDemod->state == SONY_DEMOD_STATE_ACTIVE){
if (pDemod->dvbss2ScanMode > 0){
result = TSRStoSL (pDemod);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
} else if ((pDemod->system == SONY_DTV_SYSTEM_DVBS)
|| (pDemod->system == SONY_DTV_SYSTEM_DVBS2) || (pDemod->system == SONY_DTV_SYSTEM_ANY)){
/* Active-S(X) -> Sleep-S */
result = ASXtoSL (pDemod);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
}
pDemod->state = SONY_DEMOD_STATE_SLEEP;
} else if (pDemod->state == SONY_DEMOD_STATE_SLEEP){
/* Do nothing. */
} else {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
pDemod->dvbss2ScanMode = 0;
SONY_TRACE_RETURN (result);
}
sony_result_t sony_demod_dvbs_s2_CheckTSLock (sony_demod_t * pDemod,
sony_demod_lock_result_t * pLock)
{
sony_result_t result = SONY_RESULT_OK;
uint8_t isLock = 0;
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_CheckTSLock");
if ((!pDemod) || (!pLock)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if (pDemod->state != SONY_DEMOD_STATE_ACTIVE) {
/* This api is accepted in Active state only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
result = sony_demod_dvbs_s2_monitor_SyncStat(pDemod, &isLock);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if(isLock){
*pLock = SONY_DEMOD_LOCK_RESULT_LOCKED;
} else {
*pLock = SONY_DEMOD_LOCK_RESULT_NOTDETECT;
}
SONY_TRACE_RETURN (result);
}
sony_result_t sony_demod_dvbs_s2_CheckIQInvert (sony_demod_t * pDemod,
uint8_t * pIsInvert)
{
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_CheckIQInvert");
if ((!pDemod) || (!pIsInvert)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if ((pDemod->state != SONY_DEMOD_STATE_ACTIVE) &&
(pDemod->state != SONY_DEMOD_STATE_SLEEP)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
*pIsInvert = 0;
if (pDemod->isSinglecable){
if (pDemod->isSinglecableSpectrumInv){
if (pDemod->satTunerIqSense == SONY_DEMOD_SAT_IQ_SENSE_NORMAL){
*pIsInvert = 1;
}
} else {
if (pDemod->satTunerIqSense == SONY_DEMOD_SAT_IQ_SENSE_INV){
*pIsInvert = 1;
}
}
} else {
if (pDemod->satTunerIqSense == SONY_DEMOD_SAT_IQ_SENSE_INV){
*pIsInvert = 1;
}
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_dvbs_s2_SetSymbolRate (sony_demod_t * pDemod,
uint32_t symbolRateKSps)
{
uint32_t regValue = 0;
uint8_t data[3] = {0, 0, 0};
SONY_TRACE_ENTER ("sony_demod_dvbs_s2_SetSymbolRate");
if (!pDemod){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if ((pDemod->state != SONY_DEMOD_STATE_ACTIVE) &&
(pDemod->state != SONY_DEMOD_STATE_SLEEP)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/*
* regValue = (symbolRateKSps * 2^14 / 1000) + 0.5
* = ((symbolRateKSps * 2^14) + 500) / 1000
* = ((symbolRateKSps * 16384) + 500) / 1000
*/
regValue = ((symbolRateKSps * 16384) + 500) / 1000;
if ((regValue == 0) || (regValue > 0x0FFFFF)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_RANGE);
}
data[0] = (uint8_t)((regValue >> 16) & 0x0F);
data[1] = (uint8_t)((regValue >> 8) & 0xFF);
data[2] = (uint8_t)( regValue & 0xFF);
/* slave Bank Addr Bit Default Setting Signal name
* ----------------------------------------------------------------------------------
* <SLV-T> AEh 20h [3:0] 8'h07 8'h0x OSYMBOLRATE[19:16]
* <SLV-T> AEh 21h [7:0] 8'h37 8'hxx OSYMBOLRATE[15:8]
* <SLV-T> AEh 22h [7:0] 8'h0A 8'hxx OSYMBOLRATE[7:0]
*/
/* Set SLV-T Bank : 0xAE */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAE) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x20, data, 3) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
/*------------------------------------------------------------------------------
Static Functions
------------------------------------------------------------------------------*/
static sony_result_t SLtoASX (sony_demod_t * pDemod,
sony_dtv_system_t dtvSystem,
uint32_t symbolRateKSps)
{
sony_result_t result = SONY_RESULT_OK;
uint8_t data = 0;
SONY_TRACE_ENTER ("SLtoASX");
if (!pDemod) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Configure TS clock Mode and Frequency. */
/* NOTE: It is used for both DVB-S and S2 systems though only DVB-S is passed as a parameter. */
result = sony_demod_SetTSClockModeAndFreq (pDemod, SONY_DTV_SYSTEM_DVBS);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Set demod mode */
if(dtvSystem == SONY_DTV_SYSTEM_DVBS){
data = 0x0A;
} else if(dtvSystem == SONY_DTV_SYSTEM_DVBS2){
data = 0x0B;
} else if(dtvSystem == SONY_DTV_SYSTEM_ANY){
data = 0x0B;
} else {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Set SLV-X Bank : 0x00 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x00, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x17, data) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if ((dtvSystem == SONY_DTV_SYSTEM_DVBS) || (dtvSystem == SONY_DTV_SYSTEM_DVBS2)){
/* DVB-S/S2 */
data = 0x00;
} else {
/* ANY */
data = 0x01;
}
/* Set SLV-T Bank : 0x00 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Enable S/S2 auto detection 1 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x2D, data) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set TS/TLV mode */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xA9, 0x00) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Enable demod clock */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x2C, 0x01) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* SADC setting */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x28, 0x31) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* SADC setting */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x4B, 0x31) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* SADC setting */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x6A, 0x00) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* SADC setting */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x18, 0x00) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* DVB-S/S2 initial setting
*
* slave Bank Addr Bit Default Setting Signal name
* --------------------------------------------------------------------------------
* <SLV-T> 00h 20h [0] 8'h00 8'h01 OREG_RFAGC_SRST_OFF
*/
/* Set SLV-T Bank : 0x00 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x20, 0x01) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* DVB-S/S2 initial setting (only for CXD2856)
*
* slave Bank Addr Bit Default Setting Signal name
* --------------------------------------------------------------------------------
* <SLV-T> 18h E3h [1] 8'h00 8'h02 OREG_BBBYTESS_OLDMODE
* <SLV-T> 18h E5h [3:0] 8'h0F 8'h04 OREG_BSYNCDEPTH[3:0]
*/
if (SONY_DEMOD_CHIP_ID_2856_FAMILY (pDemod->chipId)) {
/* Set SLV-T Bank : 0x18 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x18) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xE3, 0x02) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xE5, 0x04) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
}
/* slave Bank Addr Bit Default Setting Signal name
* --------------------------------------------------------------------------------
* <SLV-T> A0h D7h [0] 8'h00 8'h00 OTUIF_POLAR
*/
/* Set SLV-T Bank : 0xA0 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OTUIF_POLAR[0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xD7, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set demod parameter */
result = sony_demod_dvbs_s2_SetSymbolRate (pDemod, symbolRateKSps);
if (result != SONY_RESULT_OK){SONY_TRACE_RETURN (result);}
/* Set SLV-T Bank : 0x00 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Disable HiZ Setting 1 (TAGC(Hi-Z), SAGC, TSVALID, TSSYNC, TSCLK) */
if (sony_i2c_SetRegisterBits (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x80, 0x10, 0x1F) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Disable Hi-Z setting 2 */
result = sony_demod_SetTSDataPinHiZ (pDemod, 0);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
static sony_result_t ASXtoSL (sony_demod_t * pDemod)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("ASXtoSL");
if (!pDemod) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Disable TS output */
result = sony_demod_SetStreamOutput (pDemod, 0);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Set SLV-T Bank : 0x00 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Enable Hi-Z setting 1 (TAGC, SAGC, TSVALID, TSSYNC, TSCLK) */
if (sony_i2c_SetRegisterBits (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x80, 0x1F, 0x1F) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Enable Hi-Z setting 2 */
result = sony_demod_SetTSDataPinHiZ (pDemod, 1);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* ---- */
/* Set SLV-X Bank : 0x00 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x00, 0x00) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* SADC setting */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x18, 0x01) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set SLV-T Bank : 0x00 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x00) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* SADC setting */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x6A, 0x11) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* SADC setting */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x4B, 0x21) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* SADC setting */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x28, 0x13) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Demodulator SW reset */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xFE, 0x01) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Disable demodulator clock */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x2C, 0x00) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set tstlv mode to default */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xA9, 0x00) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Disable S/S2 auto detection */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x2D, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set demodulator mode to default */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x17, 0x01) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
static sony_result_t ASXtoASX (sony_demod_t * pDemod, uint32_t symbolRateKSps)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("ASXtoASX");
if (!pDemod) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Disable TS output */
result = sony_demod_SetStreamOutput (pDemod, 0);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* set demod parameter */
result = sony_demod_dvbs_s2_SetSymbolRate(pDemod, symbolRateKSps);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
static sony_result_t TSRStoSL(sony_demod_t * pDemod)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("TSRStoSL");
if (!pDemod) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Disable TS output */
result = sony_demod_SetStreamOutput (pDemod, 0);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Set SLV-T Bank : 0x00 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OREG_ARC_HSMODE[0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x24, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set SLV-T Bank : 0xAE */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAE) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OFSM_SRSON[0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x24, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OFSM_UNLOCKSEL_ARS[2:0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x2E, 0x06) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OFSM_AUTOMODECHGON[0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x30, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set SLV-T Bank : 0x00 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OREG_ARC_CKACHGAUTO[0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x2B, 0x01) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set SLV-T Bank : 0xA0 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OCFRL_CHSCANON[0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x56, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set SLV-T Bank : 0xAB */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xAB) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OCFRL_CSBUFOFF[0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xF9, 0x01) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set SLV-T Bank : 0xA3 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA3) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xBD, 0x01) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
result = ASXtoSL (pDemod);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Set SLV-T Bank : 0xA0 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0xA0) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* OTUIF_POLAR[0] */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xD7, 0x00) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
+101
View File
@@ -0,0 +1,101 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/27
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbs_s2.h
This file provides the demodulator control interface specific to DVB-S/S2.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBS_S2_H
#define SONY_DEMOD_DVBS_S2_H
#include "sony_common.h"
#include "sony_demod.h"
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief The Tune parameters for a DVB-S/S2 signal.
*/
typedef struct {
sony_dtv_system_t system; /**< System of the channel. */
uint32_t centerFreqKHz; /**< Center frequency in kHz of the DVB-S/S2 channel. */
uint32_t symbolRateKSps; /**< Symbol rate in kHz of the DVB-S/S2 channel. */
} sony_dvbs_s2_tune_param_t;
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Enable acquisition on the demodulator for DVB-S/S2 channels.
Called from the integration layer ::sony_integ_dvbs_s2_Tune API.
@param pDemod The demodulator instance
@param pTuneParam The tune parameters.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_Tune (sony_demod_t * pDemod,
sony_dvbs_s2_tune_param_t * pTuneParam);
/**
@brief Put the demodulator into ::SONY_DEMOD_STATE_SLEEP state.
Can be called from Active, Shutdown or Sleep states.
Called from the integration layer ::sony_integ_Sleep API.
@param pDemod The demodulator instance
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_Sleep (sony_demod_t * pDemod);
/**
@brief Check whether TS signal is locked or not locked.
@note This API is for checking lock status in tuning stage.
After tuning (while receiving the signal),
please use sony_demod_dvbs_s2_monitor_SyncStat instead
to check current lock status.
@param pDemod The demodulator instance
@param pLock Address of lock status.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_CheckTSLock (sony_demod_t * pDemod,
sony_demod_lock_result_t * pLock);
/**
@brief Get the I/Q polarity of device.
This API is called by driver internal.
So user doesn't need to use it.
@param pDemod The demodulator instance
@param pIsInvert Polarity of I/Q sense. (0: Not inverted. 1: Inverted)
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_CheckIQInvert (sony_demod_t * pDemod,
uint8_t * pIsInvert);
/**
@brief Configure demodulator setting to demodulate symbol rate.
@param pDemod The demodulator instance
@param symbolRateKSps Symbol rate in KSps.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_SetSymbolRate (sony_demod_t * pDemod,
uint32_t symbolRateKSps);
#endif /* SONY_DEMOD_DVBS_S2_H */
File diff suppressed because it is too large Load Diff
+266
View File
@@ -0,0 +1,266 @@
/*------------------------------------------------------------------------------
Copyright 2016-2019 Sony Semiconductor Solutions Corporation
Last Updated : 2019/02/14
Modification ID : 83dbabba2734697e67e3d44647acf57b272c2caf
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbs_s2_monitor.h
This file provides the DVB-S/S2 demodulator monitor interface.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBS_S2_MONITOR_H
#define SONY_DEMOD_DVBS_S2_MONITOR_H
#include "sony_common.h"
#include "sony_demod.h"
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Monitors the synchronisation state of the DVB-S/S2 demodulator.
@param pDemod The demodulator instance.
@param pTSLockStat Indicates the TS lock condition.
- 0: TS not locked.
- 1: TS locked.
@return SONY_RESULT_OK if pTSLockStat is valid, otherwise an error is returned.
*/
sony_result_t sony_demod_dvbs_s2_monitor_SyncStat (sony_demod_t * pDemod,
uint8_t * pTSLockStat);
/**
@brief Monitor the carrier offset of the currently tuned channel.
To get the estimated center frequency of the current channel:
Fest = Ftune (KHz) + pOffset (KHz) ;
@param pDemod The demodulator instance.
@param pOffset The detected carrier offset in KHz.
@return SONY_RESULT_OK if pOffset is valid.
*/
sony_result_t sony_demod_dvbs_s2_monitor_CarrierOffset (sony_demod_t * pDemod,
int32_t * pOffset);
/**
@brief Monitor the IFAGC value of the DVB-S/S2 demodulator.
Actual dB gain dependent on attached tuner.
@param pDemod The demodulator instance.
@param pIFAGC The IFAGC output register value. Range 0 - 0xFFF. Unitless.
@return SONY_RESULT_OK if pIFAGC is valid.
*/
sony_result_t sony_demod_dvbs_s2_monitor_IFAGCOut (sony_demod_t * pDemod,
uint32_t * pIFAGC);
/**
@brief Monitor the System which current receiving.
@param pDemod The demodulator instance.
@param pSystem The system of current receiving signal.
@return SONY_RESULT_OK if pSystem is valid.
*/
sony_result_t sony_demod_dvbs_s2_monitor_System (sony_demod_t * pDemod,
sony_dtv_system_t * pSystem);
/**
@brief Monitor the symbol rate of the currently tuned channel in Sps (Symbols per Second).
@param pDemod The demodulator instance.
@param pSymbolRateSps The symbol rate in Sps (Symbols per Second).
@return SONY_RESULT_OK if pSymbolRateSps is valid.
*/
sony_result_t sony_demod_dvbs_s2_monitor_SymbolRate (sony_demod_t * pDemod,
uint32_t * pSymbolRateSps);
/**
@brief Monitors the I/Q sense used by the DVB-S/S2 demodulator.
@param pDemod The demodulator instance.
@param pSense The detected I/Q sense.
@return SONY_RESULT_OK if successful and pSense is valid.
*/
sony_result_t sony_demod_dvbs_s2_monitor_IQSense (sony_demod_t * pDemod,
sony_demod_sat_iq_sense_t * pSense);
/**
@brief Monitor the CNR estimation made by the demodulator.
@param pDemod The demodulator instance.
@param pCNR The returned CNR in dB x 1000.
@return SONY_RESULT_OK if pCNR is valid.
*/
sony_result_t sony_demod_dvbs_s2_monitor_CNR (sony_demod_t * pDemod,
int32_t * pCNR);
/**
@brief Monitor PER.
@param pDemod The demodulator instance.
@param pPER The returned PER in 1e6.
@return SONY_RESULT_OK if pPER is valid, otherwise an error is returned.
*/
sony_result_t sony_demod_dvbs_s2_monitor_PER (sony_demod_t * pDemod,
uint32_t * pPER);
/**
@brief Monitor the DVB-S Code Rate.
@param pDemod The demodulator instance.
@param pCodeRate Code rate.
@return SONY_RESULT_OK if pCodeRate is valid, otherwise an error is returned.
*/
sony_result_t sony_demod_dvbs_monitor_CodeRate (sony_demod_t * pDemod,
sony_dvbs_coderate_t * pCodeRate);
/**
@brief Monitor pre Viterbi BER.
@param pDemod The demodulator instance.
@param pBER The returned BER * 10^7.
@return SONY_RESULT_OK if pBER is valid, otherwise an error is returned.
*/
sony_result_t sony_demod_dvbs_monitor_PreViterbiBER (sony_demod_t * pDemod,
uint32_t * pBER);
/**
@brief Monitor pre RS BER.
@param pDemod The demodulator instance.
@param pBER The returned BER * 10^7.
@return SONY_RESULT_OK if pBER is valid, otherwise an error is returned.
*/
sony_result_t sony_demod_dvbs_monitor_PreRSBER (sony_demod_t * pDemod,
uint32_t * pBER);
/**
@brief Monitor the DVB-S2 PLS code.
@param pDemod The demodulator instance.
@param pPLSCode The returned PLS code. The IC does not support short frames,
so sony_dvbs2_plscode_t::isShortFrame is always set to 0:normal.
@return SONY_RESULT_OK if pPLSCode is valid, otherwise an error is returned.
*/
sony_result_t sony_demod_dvbs2_monitor_PLSCode (sony_demod_t * pDemod,
sony_dvbs2_plscode_t * pPLSCode);
/**
@brief Monitor pre LDPC BER.
@param pDemod The demodulator instance.
@param pBER The returned BER * 10^7.
@return SONY_RESULT_OK if pBER is valid, otherwise an error is returned.
*/
sony_result_t sony_demod_dvbs2_monitor_PreLDPCBER (sony_demod_t * pDemod,
uint32_t * pBER);
/**
@brief Monitor pre BCH BER.
@param pDemod The demodulator instance.
@param pBER The returned BER * 10^9.
@return SONY_RESULT_OK if pBER is valid, otherwise an error is returned.
*/
sony_result_t sony_demod_dvbs2_monitor_PreBCHBER (sony_demod_t * pDemod,
uint32_t * pBER);
/**
@brief Monitor post BCH FER.
@param pDemod The demodulator instance.
@param pFER The returned FER * 10^6.
@return SONY_RESULT_OK if pFER is valid, otherwise an error is returned.
*/
sony_result_t sony_demod_dvbs2_monitor_PostBCHFER (sony_demod_t * pDemod,
uint32_t * pFER);
/**
@brief Monitor DVB-S2 base-band Header (BBHEADER).
@param pDemod The demodulator instance.
@param pBBHeader The returned base-band Header (BBHEADER) information.
@return SONY_RESULT_OK if pBBHeader is valid, otherwise an error is returned.
*/
sony_result_t sony_demod_dvbs2_monitor_BBHeader (sony_demod_t * pDemod,
sony_dvbs2_bbheader_t * pBBHeader);
/**
@brief Monitor DVB-S/S2 scan information.
This API is called from BlindScan API.
@param pDemod The demodulator instance.
@param pTSLock Indicates the TS lock condition.
- 0: TS not locked.
- 1: TS locked.
@param pOffset Carrier offset frequency (KHz).
- If pTSLock = 0, this value is invalid.
Please refer to sony_demod_dvbs_s2_monitor_CarrierOffset.
@param pSystem The system of current receiving signal.
- If pTSLock = 0, this value is invalid.
@return SONY_RESULT_OK if all values are valid, otherwise an error is returned.
*/
sony_result_t sony_demod_dvbs_s2_monitor_ScanInfo (sony_demod_t * pDemod,
uint8_t * pTSLock,
int32_t * pOffset,
sony_dtv_system_t * pSystem);
/**
@brief Check pilot on/off
This API is called from BlindScan API.
@param pDemod The demodulator instance
@param pPlscLock Address of PLSC lock status.
@param pPilotOn Address of Pilot flag (0:Off, 1:On)
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbs_s2_monitor_Pilot (sony_demod_t * pDemod,
uint8_t * pPlscLock,
uint8_t * pPilotOn);
/**
@brief Monitor TS bit rate in Kbps.
@param pDemod The demodulator instance.
@param pTSRateKbps The returned TS bit rate in Kbps.
@return SONY_RESULT_OK if successful and pTSRateKbps valid.
*/
sony_result_t sony_demod_dvbs_s2_monitor_TSRate (sony_demod_t * pDemod,
uint32_t * pTSRateKbps);
/**
@brief Monitor Rolloff parameter.
@param pDemod The demodulator instance.
@param pRolloff The returned pRolloff.
@return SONY_RESULT_OK if pRolloff is valid, otherwise an error is returned.
*/
sony_result_t sony_demod_dvbs2_monitor_Rolloff (sony_demod_t * pDemod,
uint8_t * pRolloff);
#endif /* SONY_DEMOD_DVBS2_MONITOR_H */
+39
View File
@@ -0,0 +1,39 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
/**
@file sony_dvbs.h
This file provides DVB-S related type definitions.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DVBS_H
#define SONY_DVBS_H
/*------------------------------------------------------------------------------
Enumerations
------------------------------------------------------------------------------*/
/**
@brief DVB-S code rate.
*/
typedef enum {
SONY_DVBS_CODERATE_1_2, /**< 1/2 */
SONY_DVBS_CODERATE_2_3, /**< 2/3 */
SONY_DVBS_CODERATE_3_4, /**< 3/4 */
SONY_DVBS_CODERATE_5_6, /**< 5/6 */
SONY_DVBS_CODERATE_7_8, /**< 7/8 */
SONY_DVBS_CODERATE_INVALID /**< Invalid */
} sony_dvbs_coderate_t;
/**
@brief DVB-S modulation.
*/
typedef enum {
SONY_DVBS_MODULATION_QPSK, /**< QPSK */
SONY_DVBS_MODULATION_INVALID /**< Invalid */
} sony_dvbs_modulation_t;
#endif /* SONY_DVBS_H */
+106
View File
@@ -0,0 +1,106 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
/**
@file sony_dvbs2.h
This file provides DVB-S2 related type definitions.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DVBS2_H
#define SONY_DVBS2_H
#include "sony_common.h"
/*------------------------------------------------------------------------------
Enumerations
------------------------------------------------------------------------------*/
/**
@brief DVB-S2 code rate.
*/
typedef enum {
SONY_DVBS2_CODERATE_1_4, /**< 1/4 */
SONY_DVBS2_CODERATE_1_3, /**< 1/3 */
SONY_DVBS2_CODERATE_2_5, /**< 2/5 */
SONY_DVBS2_CODERATE_1_2, /**< 1/2 */
SONY_DVBS2_CODERATE_3_5, /**< 3/5 */
SONY_DVBS2_CODERATE_2_3, /**< 2/3 */
SONY_DVBS2_CODERATE_3_4, /**< 3/4 */
SONY_DVBS2_CODERATE_4_5, /**< 4/5 */
SONY_DVBS2_CODERATE_5_6, /**< 5/6 */
SONY_DVBS2_CODERATE_8_9, /**< 8/9 */
SONY_DVBS2_CODERATE_9_10, /**< 9/10 */
SONY_DVBS2_CODERATE_RESERVED_29, /**< Reserved */
SONY_DVBS2_CODERATE_RESERVED_30, /**< Reserved */
SONY_DVBS2_CODERATE_RESERVED_31, /**< Reserved */
SONY_DVBS2_CODERATE_INVALID /**< Invalid */
} sony_dvbs2_coderate_t;
/**
@brief DVB-S2 modulation.
*/
typedef enum {
SONY_DVBS2_MODULATION_QPSK, /**< QPSK */
SONY_DVBS2_MODULATION_8PSK, /**< 8PSK */
SONY_DVBS2_MODULATION_16APSK, /**< 16APSK */
SONY_DVBS2_MODULATION_32APSK, /**< 32APSK */
SONY_DVBS2_MODULATION_RESERVED_29, /**< Reserved */
SONY_DVBS2_MODULATION_RESERVED_30, /**< Reserved */
SONY_DVBS2_MODULATION_RESERVED_31, /**< Reserved */
SONY_DVBS2_MODULATION_DUMMY_PLFRAME, /**< Dummy PL Frame */
SONY_DVBS2_MODULATION_INVALID /**< Invalid */
} sony_dvbs2_modulation_t;
/**
@brief DVB-S2 Stream Input.
*/
typedef enum {
SONY_DVBS2_STREAM_GENERIC_PACKETIZED = 0x00, /**< Generic Packetized Stream Input. */
SONY_DVBS2_STREAM_GENERIC_CONTINUOUS = 0x01, /**< Generic Continuous Stream Input. */
SONY_DVBS2_STREAM_RESERVED = 0x02, /**< Reserved. */
SONY_DVBS2_STREAM_TRANSPORT = 0x03 /**< Transport Stream Input. */
} sony_dvbs2_stream_t;
/**
@brief DVB-S2 Transmission Roll-off factor.
*/
typedef enum {
SONY_DVBS2_ROLLOFF_35 = 0x00, /**< Roll-off = 0.35. */
SONY_DVBS2_ROLLOFF_25 = 0x01, /**< Roll-off = 0.25. */
SONY_DVBS2_ROLLOFF_20 = 0x02, /**< Roll-off = 0.20. */
SONY_DVBS2_ROLLOFF_RESERVED = 0x03 /**< Reserved. */
} sony_dvbs2_rolloff_t;
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief DVB-S2 PLS code information.
*/
typedef struct {
sony_dvbs2_modulation_t modulation; /**< Modulation. */
sony_dvbs2_coderate_t codeRate; /**< Code rate. */
uint8_t isShortFrame; /**< FEC Frame size (0:normal, 1:short). */
uint8_t isPilotOn; /**< Pilot mode (0:Off, 1:On). */
} sony_dvbs2_plscode_t;
/**
@brief DVB-S2 base-band Header (BBHEADER) information.
*/
typedef struct {
sony_dvbs2_stream_t streamInput; /**< Stream Input (Transport or Generic). */
uint8_t isSingleInputStream; /**< Multiple Input Stream or Single Input Stream. */
uint8_t isConstantCodingModulation; /**< Constant or Adaptive Coding and Modulation. */
uint8_t issyIndicator; /**< Input Stream Synchronisation Indicator. */
uint8_t nullPacketDeletion; /**< Null Packet Deletion active/not active. */
sony_dvbs2_rolloff_t rollOff; /**< Transmission Roll-Off factor. */
uint8_t inputStreamIdentifier; /**< Input Stream Identifier (only valid for MIS). */
uint16_t userPacketLength; /**< User Packet Length in bits. */
uint16_t dataFieldLength; /**< Data Field Length in bits. */
uint8_t syncByte; /**< User Packet Sync Byte. */
} sony_dvbs2_bbheader_t;
#endif /* SONY_DVBS2_H */
+241
View File
@@ -0,0 +1,241 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/05
Modification ID : c7c68d70868a4a9fb9e0f480d8b940e8a1e8f651
------------------------------------------------------------------------------*/
#include "sony_common.h"
#include "sony_demod.h"
#include "sony_integ_dvbs_s2.h"
#include "sony_demod_dvbs_s2_monitor.h"
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
sony_result_t sony_integ_dvbs_s2_Tune (sony_integ_t * pInteg,
sony_dvbs_s2_tune_param_t * pTuneParam)
{
sony_stopwatch_t stopwatch;
sony_result_t result = SONY_RESULT_OK;
sony_dtv_system_t dtvSystem = SONY_DTV_SYSTEM_DVBS2;
uint32_t elapsedTime = 0;
uint8_t isContinue = 1;
uint32_t timeout = 0;
sony_demod_lock_result_t lockStatus = SONY_DEMOD_LOCK_RESULT_NOTDETECT;
SONY_TRACE_ENTER ("sony_integ_dvbs_s2_Tune");
if ((!pInteg) || (!pInteg->pDemod) ||
(!pTuneParam) || (pTuneParam->symbolRateKSps == 0)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if ((pInteg->pDemod->state != SONY_DEMOD_STATE_SLEEP) &&
(pInteg->pDemod->state != SONY_DEMOD_STATE_ACTIVE)){
/* This api is accepted in Sleep and Active states only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
result = sony_demod_dvbs_s2_Tune (pInteg->pDemod, pTuneParam);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if (pTuneParam->system == SONY_DTV_SYSTEM_ANY){
dtvSystem = SONY_DTV_SYSTEM_DVBS;
} else {
dtvSystem = pTuneParam->system;
}
if ((pInteg->pTuner) && (pInteg->pTuner->SatTune)) {
/* Enable the I2C repeater */
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x01);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = pInteg->pTuner->SatTune (pInteg->pTuner,
pTuneParam->centerFreqKHz,
dtvSystem,
pTuneParam->symbolRateKSps);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
/* Disable the I2C repeater */
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x00);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
}
result = sony_demod_TuneEnd(pInteg->pDemod);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_stopwatch_start (&stopwatch);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if (pTuneParam->system == SONY_DTV_SYSTEM_ANY){
timeout = ((3600000 + (pTuneParam->symbolRateKSps - 1)) / pTuneParam->symbolRateKSps) + 150;
} else {
timeout = ((3000000 + (pTuneParam->symbolRateKSps - 1)) / pTuneParam->symbolRateKSps) + 150;
}
isContinue = 1;
while (isContinue) {
/* Check cancellation. */
result = sony_integ_CheckCancellation (pInteg);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
result = sony_stopwatch_elapsed (&stopwatch, &elapsedTime);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_dvbs_s2_CheckTSLock (pInteg->pDemod, &lockStatus);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if (lockStatus == SONY_DEMOD_LOCK_RESULT_LOCKED) {
/* Lock */
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
if (elapsedTime > timeout) {
isContinue = 0;
} else {
result = sony_stopwatch_sleep (&stopwatch, SONY_INTEG_DVBS_S2_TUNE_POLLING_INTERVAL);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
}
}
{
/* Additional wait sequence for pilot off signal */
uint8_t plscLock = 0;
uint8_t pilotOn = 0;
result = sony_demod_dvbs_s2_monitor_Pilot (pInteg->pDemod, &plscLock, &pilotOn);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if ((plscLock != 0) && (pilotOn == 0)) {
result = sony_stopwatch_start (&stopwatch);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if (pTuneParam->system == SONY_DTV_SYSTEM_ANY){
timeout = ((3600000 + (pTuneParam->symbolRateKSps - 1)) / pTuneParam->symbolRateKSps) + 150;
} else {
timeout = ((3000000 + (pTuneParam->symbolRateKSps - 1)) / pTuneParam->symbolRateKSps) + 150;
}
isContinue = 1;
while (isContinue) {
/* Check cancellation. */
result = sony_integ_CheckCancellation (pInteg);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
result = sony_stopwatch_elapsed (&stopwatch, &elapsedTime);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
result = sony_demod_dvbs_s2_CheckTSLock (pInteg->pDemod, &lockStatus);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
if (lockStatus == SONY_DEMOD_LOCK_RESULT_LOCKED) {
/* Lock */
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
if (elapsedTime > timeout) {
isContinue = 0;
} else {
result = sony_stopwatch_sleep (&stopwatch, SONY_INTEG_DVBS_S2_TUNE_POLLING_INTERVAL);
if (result != SONY_RESULT_OK){
SONY_TRACE_RETURN (result);
}
}
}
}
}
SONY_TRACE_RETURN (SONY_RESULT_ERROR_TIMEOUT);
}
sony_result_t sony_integ_dvbs_s2_monitor_RFLevel (sony_integ_t * pInteg, int32_t * pRFLeveldB)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_integ_dvbs_s2_monitor_RFLevel");
if ((!pInteg) || (!pInteg->pDemod) || (!pRFLeveldB)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if (pInteg->pDemod->state != SONY_DEMOD_STATE_ACTIVE) {
/* This api is accepted in Active state only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
if ((pInteg->pDemod->system != SONY_DTV_SYSTEM_DVBS) &&
(pInteg->pDemod->system != SONY_DTV_SYSTEM_DVBS2) &&
(pInteg->pDemod->system != SONY_DTV_SYSTEM_ANY)){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
if (!pInteg->pTuner) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
}
if (pInteg->pTuner->rfLevelFuncSat == SONY_TUNER_RFLEVEL_FUNC_READ && pInteg->pTuner->ReadRFLevel) {
/* Enable the I2C repeater */
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x01);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
result = pInteg->pTuner->ReadRFLevel (pInteg->pTuner, pRFLeveldB);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Disable the I2C repeater */
result = sony_demod_I2cRepeaterEnable (pInteg->pDemod, 0x00);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
} else if (pInteg->pTuner->rfLevelFuncSat == SONY_TUNER_RFLEVEL_FUNC_CALCFROMAGC
&& pInteg->pTuner->CalcRFLevelFromAGC) {
uint32_t ifAgc;
result = sony_demod_dvbs_s2_monitor_IFAGCOut (pInteg->pDemod, &ifAgc);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
result = pInteg->pTuner->CalcRFLevelFromAGC (pInteg->pTuner, ifAgc, pRFLeveldB);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
} else {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
}
/* dBm * 100 -> dBm * 1000 */
*pRFLeveldB *= 10;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
+75
View File
@@ -0,0 +1,75 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/27
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
------------------------------------------------------------------------------*/
/**
@file sony_integ_dvbs_s2.h
This file provides the integration layer interface for DVB-S/S2 specific
demodulator functions.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_INTEG_DVBS_S2_H
#define SONY_INTEG_DVBS_S2_H
#include "sony_integ.h"
#include "sony_demod_dvbs_s2.h"
/*------------------------------------------------------------------------------
Defines
------------------------------------------------------------------------------*/
/**
@brief Polling interval for Tune sequence in ms.
*/
#define SONY_INTEG_DVBS_S2_TUNE_POLLING_INTERVAL 10
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Performs acquisition to the channel specified by the pTuneParam struct.
If the channel system is unknown set the pTuneParam.system to
::SONY_DTV_SYSTEM_ANY to enable a blind acquisition.
In this case the tuned system can be obtained by calling
::sony_demod_dvbs_s2_monitor_System.
Blocks the calling thread until the TS has locked or has timed out.
Use ::sony_integ_Cancel to cancel the operation at any time.
The frequency capture range depends on the target symbol rate and it
is automatically handled by hardware.
- Symbol Rate >= 20MSps : +/- 10MHz
- Symbol Rate < 20MSps : Half of Symbol Rate.(i.e. 5MSps : +/- 2.5MHz)
However, if Symbol Rate is less than 20 MSps and signal condition is good,
then frequency capture range is "equal to Symbol Rate". (i.e. 5MSps : +/- 5MHz)
@param pInteg The driver instance.
@param pTuneParam The parameters required for the tune.
@return SONY_RESULT_OK if tuned successfully to the channel.
*/
sony_result_t sony_integ_dvbs_s2_Tune (sony_integ_t * pInteg,
sony_dvbs_s2_tune_param_t * pTuneParam);
/**
@brief RF level monitor function.
This function returns the estimated RF level based on either the demodulator IFAGC
level or a tuner internal RSSI monitor. If any compensation for external hardware
such as, LNA, attenuators is required, then the user should make adjustment in the
corresponding function.
@param pInteg The driver instance
@param pRFLeveldB The RF Level estimation in dB * 1000
@return SONY_RESULT_OK if successful and pRFLeveldB is valid.
*/
sony_result_t sony_integ_dvbs_s2_monitor_RFLevel (sony_integ_t * pInteg,
int32_t * pRFLeveldB);
#endif /* SONY_INTEG_DVBS_S2_H */
File diff suppressed because it is too large Load Diff
+130
View File
@@ -0,0 +1,130 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/27
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbt.h
This file provides the demodulator control interface specific to DVB-T.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBT_H
#define SONY_DEMOD_DVBT_H
#include "sony_common.h"
#include "sony_demod.h"
/*------------------------------------------------------------------------------
Defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief The tune parameters for a DVB-T signal
*/
typedef struct sony_dvbt_tune_param_t{
uint32_t centerFreqKHz; /**< Center frequency in kHz of the DVB-T channel */
sony_dtv_bandwidth_t bandwidth; /**< Bandwidth of the DVB-T channel */
sony_dvbt_profile_t profile; /**< Indicates the HP/LP profile to be selected. */
}sony_dvbt_tune_param_t;
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Configure the DVBT profile for acquisition, Low Priority or High Priority.
@param pDemod The demodulator instance
@param profile The profile to use for DVB-T acquisition.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbt_SetProfile (sony_demod_t * pDemod,
sony_dvbt_profile_t profile);
/**
@brief Enable acquisition on the demodulator for DVB-T channels.
Called from the integration layer ::sony_integ_dvbt_Tune API.
@param pDemod The demodulator instance
@param pTuneParam The tune parameters.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbt_Tune (sony_demod_t * pDemod,
sony_dvbt_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_dvbt_Sleep (sony_demod_t * pDemod);
/**
@brief Check DVB-T demodulator lock status.
@note This API is for checking lock status in tuning stage.
After tuning (while receiving the signal),
please use sony_demod_dvbt_monitor_SyncStat instead
to check current lock status.
@param pDemod The demodulator instance
@param pLock Demod lock state
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbt_CheckDemodLock (sony_demod_t * pDemod,
sony_demod_lock_result_t * pLock);
/**
@brief Check DVB-T TS lock status.
@note This API is for checking lock status in tuning stage.
After tuning (while receiving the signal),
please use sony_demod_dvbt_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_dvbt_CheckTSLock (sony_demod_t * pDemod,
sony_demod_lock_result_t * pLock);
/**
@brief Check DVB-T Echo Optomisation requirement.
@param pDemod The demodulator instance
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbt_EchoOptimization (sony_demod_t * pDemod);
/**
@brief Clear BER, SNR history data for averaged BER, SNR, SQI monitors.
@note This function may be useful if the user would like to calculate
averaged BER, SNR, SQI without using old BER, SNR data.
Please check document and example code for recommended setting and sequence.
@param pDemod The demodulator instance
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbt_ClearBERSNRHistory (sony_demod_t * pDemod);
#endif /* SONY_DEMOD_DVBT_H */
File diff suppressed because it is too large Load Diff
+205
View File
@@ -0,0 +1,205 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/27
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbt2.h
This file provides the demodulator control interface specific to DVB-T2.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBT2_H
#define SONY_DEMOD_DVBT2_H
#include "sony_common.h"
#include "sony_demod.h"
/*------------------------------------------------------------------------------
Enumerations
------------------------------------------------------------------------------*/
/**
@brief DVBT2 specific tune information, stored in the tune param struct
result. This should be checked if a call to DVBT2 tune returns
SONY_RESULT_OK_CONFIRM.
*/
typedef enum {
/**
@brief Tune successful.
*/
SONY_DEMOD_DVBT2_TUNE_INFO_OK,
/**
@brief PLP provided in tune params is not available. The demodulator
will output the auto PLP in this case.
*/
SONY_DEMOD_DVBT2_TUNE_INFO_INVALID_PLP_ID
} sony_demod_dvbt2_tune_info_t;
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief The tune parameters for a DVB-T2 signal
*/
typedef struct sony_dvbt2_tune_param_t{
/**
@brief Center frequency in kHz of the DVB-T2 channel.
*/
uint32_t centerFreqKHz;
/**
@brief Bandwidth of the DVB-T2 channel.
*/
sony_dtv_bandwidth_t bandwidth;
/**
@brief The data PLP ID to select in acquisition.
*/
uint8_t dataPlpId;
/**
@brief The DVB-T2 profile to select in acquisition. Must be set to either
SONY_DVBT2_PROFILE_BASE or SONY_DVBT2_PROFILE_LITE. If the profile
is unknown use the blind tune API with the profile set to
SONY_DVBT2_PROFILE_ANY.
*/
sony_dvbt2_profile_t profile;
/**
@brief Specific tune information relating to DVB-T2 acquisition. If result
from Tune function is SONY_RESULT_OK_CONFIRM this result code
will provide more information on the tune process. Refer to
::sony_demod_dvbt2_tune_info_t for further details on the specific
codes.
*/
sony_demod_dvbt2_tune_info_t tuneInfo;
}sony_dvbt2_tune_param_t;
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Enable acquisition on the demodulator for DVB-T2 channels.
Called from the integration layer ::sony_integ_dvbt2_Tune API.
@param pDemod The demodulator instance
@param pTuneParam The tune parameters.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbt2_Tune (sony_demod_t * pDemod,
sony_dvbt2_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_dvbt2_Sleep (sony_demod_t * pDemod);
/**
@brief Check DVB-T2 demodulator lock status.
@note This API is for checking lock status in tuning stage.
After tuning (while receiving the signal),
please use sony_demod_dvbt2_monitor_SyncStat instead
to check current lock status.
@param pDemod The demodulator instance
@param pLock Demod lock state
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbt2_CheckDemodLock (sony_demod_t * pDemod,
sony_demod_lock_result_t * pLock);
/**
@brief Check DVB-T2 TS lock status.
@note This API is for checking lock status in tuning stage.
After tuning (while receiving the signal),
please use sony_demod_dvbt2_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_dvbt2_CheckTSLock (sony_demod_t * pDemod,
sony_demod_lock_result_t * pLock);
/**
@brief Setup the PLP configuration of the demodulator
Selecting both the device PLP operation (automatic/manual PLP select)
and the PLP to be selected in manual PLP mode.
@param pDemod The demodulator instance.
@param autoPLP The auto PLP setting.
- 0x00: The data PLP ID set by plpId will be output.
If the PLP with the ID is not found, then a PLP error is indicated
(::sony_demod_dvbt2_monitor_DataPLPError) but the
demod will still output the first found data PLP Id.
- 0x01: Fully automatic. The first PLP found during acquisition will be output.
@param plpId The PLP Id to set.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbt2_SetPLPConfig (sony_demod_t * pDemod,
uint8_t autoPLP,
uint8_t plpId);
/**
@brief Set the DVB-T2 profile and tune mode for acquisition.
Note: This API changes DVB-T2 early unlock detection time.
If SONY_DVBT2_PROFILE_LITE or SONY_DVBT2_PROFILE_ANY are specified,
early unlock detection time will be longer.
@param pDemod The demodulator instance.
@param profile The DVB-T2 profile option. SONY_DVBT2_PROFILE_BASE and
SONY_DVBT2_PROFILE_LITE will set the demodulator into fixed tune mode
without recovery. SONY_DVBT2_PROFILE_ANY will use auto detection
meaning the demodulator will acquire to the first valid frame
received, Base or Lite.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbt2_SetProfile (sony_demod_t * pDemod,
sony_dvbt2_profile_t profile);
/**
@brief Check DVB-T2 L1_Post valid status.
@param pDemod The demodulator instance
@param pL1PostValid L1 Post valid status
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbt2_CheckL1PostValid (sony_demod_t * pDemod,
uint8_t * pL1PostValid);
/**
@brief Clear BER, SNR history data for averaged BER, SNR, SQI monitors.
@note This function may be useful if the user would like to calculate
averaged BER, SNR, SQI without using old BER, SNR data.
Please check document and example code for recommended setting and sequence.
@param pDemod The demodulator instance
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbt2_ClearBERSNRHistory (sony_demod_t * pDemod);
#endif /* SONY_DEMOD_DVBT2_H */
File diff suppressed because it is too large Load Diff
+432
View File
@@ -0,0 +1,432 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/27
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbt2_monitor.h
This file provides the DVB-T2 demodulator monitor interface.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBT2_MONITOR_H
#define SONY_DEMOD_DVBT2_MONITOR_H
#include "sony_demod.h"
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Monitors the synchronisation state of the T2 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-T2 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,
- 1: WAIT_AGC,
- 2: WAIT_P1DET,
- 3: WAIT_L1PRE,
- 4: WAIT_L1POST,
- 5: WAIT_DMD_OK,
- 6: DMD_OK
@param pTSLockStat Indicates the TS lock condition.
- 0: TS not locked.
- 1: TS locked.
@param pUnlockDetected Indicates the early unlock condition.
- 0: No early unlock.
- 1: Early unlock.
@return SONY_RESULT_OK if pSyncStat, pTSLockStat is valid, otherwise an error is returned.
*/
sony_result_t sony_demod_dvbt2_monitor_SyncStat (sony_demod_t * pDemod,
uint8_t * pSyncStat,
uint8_t * pTSLockStat,
uint8_t * pUnlockDetected);
/**
@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_dvbt2_monitor_CarrierOffset (sony_demod_t * pDemod,
int32_t * pOffset);
/**
@brief Monitor the IFAGC value of the T2 demodulator.
Actual dB gain dependent on attached tuner.
@param pDemod The demodulator instance.
@param pIFAGC The IFAGC output register value. Range 0 - 0xFFF. Unitless.
@return SONY_RESULT_OK if pIFAGC is valid.
*/
sony_result_t sony_demod_dvbt2_monitor_IFAGCOut (sony_demod_t * pDemod,
uint32_t * pIFAGC);
/**
@brief Monitor the L1-pre signaling information.
L1-pre signaling information is available when TS is locked, and earlier in the
acquisition sequence, after the P1 symbols have been decoded.
@param pDemod The demodulator instance.
@param pL1Pre Pointer to receive the L1-pre signaling information.
@return SONY_RESULT_OK if the pL1Pre is valid.
*/
sony_result_t sony_demod_dvbt2_monitor_L1Pre (sony_demod_t * pDemod,
sony_dvbt2_l1pre_t * pL1Pre);
/**
@brief Monitor the T2 version in use.
The version is available from the L1-pre signaling information.
@param pDemod The demodulator instance.
@param pVersion Pointer to receive the version information.
@return SONY_RESULT_OK if the pVersion is valid.
*/
sony_result_t sony_demod_dvbt2_monitor_Version (sony_demod_t * pDemod,
sony_dvbt2_version_t * pVersion);
/**
@brief Monitor the tuning information on the active channel.
@param pDemod The demodulator instance.
@param pOfdm Pointer to receive the tuning information.
@return SONY_RESULT_OK if the pPresetInfo is valid.
*/
sony_result_t sony_demod_dvbt2_monitor_OFDM (sony_demod_t * pDemod,
sony_dvbt2_ofdm_t * pOfdm);
/**
@brief Monitor the data PLPs that the demodulator has detected.
If a single PLP service is in use, then numberPlps = 1
and the plpIds[0] shall contain the signalled PLP Id.
@param pDemod The demodulator instance.
@param pPLPIds Pointer to an array of at least 255 bytes in length
that can receive the list of data PLPs carried.
This parameter can be NULL. If so, number of data PLP is only returned.
@param pNumPLPs The number of data PLPs detected (signalled in L1-post).
@return SONY_RESULT_OK if the pPLPIds and pNumPLPs are valid.
*/
sony_result_t sony_demod_dvbt2_monitor_DataPLPs (sony_demod_t * pDemod,
uint8_t * pPLPIds,
uint8_t * pNumPLPs);
/**
@brief Monitor the active PLP information in L1-post signaling.
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 pPLPInfo The PLP structure to receive the PLP information into.
@return SONY_RESULT_OK if pPLPInfo is valid, otherwise an error is returned.
*/
sony_result_t sony_demod_dvbt2_monitor_ActivePLP (sony_demod_t * pDemod,
sony_dvbt2_plp_btype_t type,
sony_dvbt2_plp_t * pPLPInfo);
/**
@brief Monitor the data PLP error indicator.
A data PLP error is indicated
when the selected PLP was not found in the channel.
@param pDemod The demodulator instance.
@param pPLPError The error indicated.
- 0: No data PLP error.
- 1: Data PLP error detected.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbt2_monitor_DataPLPError (sony_demod_t * pDemod,
uint8_t * pPLPError);
/**
@brief Monitor the L1 change indicator.
@param pDemod The demodulator instance.
@param pL1Change Indicator of L1 change.
- 0: L1 has not changed.
- 1: L1 changed.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbt2_monitor_L1Change (sony_demod_t * pDemod,
uint8_t * pL1Change);
/**
@brief Monitors the basic L1-post data.
The device must have L1-post lock before calling,
if L1 post lock is not detected and error is returned.
@param pDemod The demodulator instance.
@param pL1Post The L1 post data monitored.
@return SONY_RESULT_OK if successful and pL1Post is valid.
*/
sony_result_t sony_demod_dvbt2_monitor_L1Post (sony_demod_t * pDemod,
sony_dvbt2_l1post_t * pL1Post);
/**
@brief Monitors the BBHEADER data.
The device must have TS lock before calling,
if TS lock is not detected and error is returned.
@param pDemod The demodulator instance.
@param type The type of the PLP to monitor.
@param pBBHeader The BBHEADER data monitored.
@return SONY_RESULT_OK if successful and pBBHeader is valid.
*/
sony_result_t sony_demod_dvbt2_monitor_BBHeader (sony_demod_t * pDemod,
sony_dvbt2_plp_btype_t type,
sony_dvbt2_bbheader_t * pBBHeader);
/**
@brief Monitor the in-band type B signaling TS (Transport Stream) rate.
Available V1.2.1 or later.
@param pDemod The demodulator instance.
@param type The type of the PLP to monitor.
@param pTSRateBps The TS rate of the PLP in bits/s.
@return SONY_RESULT_OK if pTSRateBps is valid.
*/
sony_result_t sony_demod_dvbt2_monitor_InBandBTSRate (sony_demod_t * pDemod,
sony_dvbt2_plp_btype_t type,
uint32_t * pTSRateBps);
/**
@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_dvbt2_monitor_SpectrumSense (sony_demod_t * pDemod,
sony_demod_terr_cable_spectrum_sense_t * pSense);
/**
@brief Monitor the SNR estimation made by the demodulator, clipped to a
maximum of 40dB.
@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_dvbt2_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_dvbt2_monitor_PreLDPCBER (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_dvbt2_monitor_PostBCHFER (sony_demod_t * pDemod,
uint32_t * pFER);
/**
@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_dvbt2_monitor_PreBCHBER (sony_demod_t * pDemod,
uint32_t * pBER);
/**
@brief Monitor the Packet Error Number. Also known as the code word reject count.
@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_dvbt2_monitor_PacketErrorNumber (sony_demod_t * pDemod,
uint32_t * pPEN);
/**
@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_dvbt2_monitor_SamplingOffset (sony_demod_t * pDemod,
int32_t * pPPM);
/**
@brief Monitor the demodulator *estimated* DVB-T2 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_dvbt2_monitor_TSRate (sony_demod_t * pDemod,
uint32_t * pTSRateKbps);
/**
@brief Monitor the DVB-T2 quality metric.
@param pDemod The demodulator instance.
@param pQuality The quality as a percentage (0-100).
@return SONY_RESULT_OK if successful and pQuality valid.
*/
sony_result_t sony_demod_dvbt2_monitor_Quality (sony_demod_t * pDemod,
uint8_t * pQuality);
/**
@brief Monitor the DVB-T2 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_dvbt2_monitor_PER (sony_demod_t * pDemod,
uint32_t * pPER);
/**
@brief Monitor the active PLP constellation.
The common PLP in the current
group can also be monitored if one exists.
@param pDemod The demodulator instance.
@param type The type of the PLP to monitor (data or common).
@param pQAM The PLP constellation.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbt2_monitor_QAM (sony_demod_t * pDemod,
sony_dvbt2_plp_btype_t type,
sony_dvbt2_plp_constell_t * pQAM);
/**
@brief Monitor the active PLP code rate.
The common PLP in the current
group can also be monitored if one exists.
@param pDemod The demodulator instance.
@param type The type of the PLP to monitor (data or common).
@param pCodeRate The PLP code rate.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbt2_monitor_CodeRate (sony_demod_t * pDemod,
sony_dvbt2_plp_btype_t type,
sony_dvbt2_plp_code_rate_t * pCodeRate);
/**
@brief Monitor the currently acquired DVB-T2 profile.
This will return SONY_RESULT_ERROR_HW_STATE if the register value is not valid.
@param pDemod The demod instance.
@param pProfile The profile of the DVB-T2 output from the demodulator.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbt2_monitor_Profile (sony_demod_t * pDemod,
sony_dvbt2_profile_t * pProfile);
/**
@brief Monitor the averaged 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_dvbt2_monitor_AveragedPreBCHBER (sony_demod_t * pDemod,
uint32_t * pBER);
/**
@brief Monitor the estimated averaged SNR value, clipped to a
maximum of 40dB.
@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_dvbt2_monitor_AveragedSNR (sony_demod_t * pDemod,
int32_t * pSNR);
/**
@brief Monitor the DVB-T2 quality metric using averaged BER and SNR.
@param pDemod The demodulator instance.
@param pQuality The quality as a percentage (0-100).
@return SONY_RESULT_OK if successful and pQuality valid.
*/
sony_result_t sony_demod_dvbt2_monitor_AveragedQuality (sony_demod_t * pDemod,
uint8_t * pQuality);
#endif /* SONY_DEMOD_DVBT2_MONITOR_H */
File diff suppressed because it is too large Load Diff
+254
View File
@@ -0,0 +1,254 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/27
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
------------------------------------------------------------------------------*/
/**
@file sony_demod_dvbt_monitor.h
This file provides the DVB-T demodulator monitor interface.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_DVBT_MONITOR_H
#define SONY_DEMOD_DVBT_MONITOR_H
#include "sony_demod.h"
#include "sony_dvbt.h"
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Sync 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 pSyncStat The demodulator state.
- 0: WAIT_AGC,
- 1: WAIT_MGD,
- 2: WAIT_FFCR,
- 3: WAIT_ARGD,
- 4: WAIT_TITP,
- 5: WAIT_TPS,
- 6: TPS_LOCK
@param pTSLockStat Indicates the TS lock condition.
- 0: TS not locked.
- 1: TS locked.
@param pUnlockDetected Indicates the early unlock condition.
- 0: No early unlock.
- 1: Early unlock.
@return SONY_RESULT_OK if successful and pSyncStat, pTSLockStat valid.
*/
sony_result_t sony_demod_dvbt_monitor_SyncStat (sony_demod_t * pDemod,
uint8_t * pSyncStat,
uint8_t * pTSLockStat,
uint8_t * pUnlockDetected);
/**
@brief Monitor the IFAGC value.
Actual dB gain dependent on attached tuner.
@param pDemod The demodulator instance.
@param pIFAGCOut The IFAGC output register value. Range 0x000 - 0xFFF. Unitless.
@return SONY_RESULT_OK if successful and pIFAGCOut valid.
*/
sony_result_t sony_demod_dvbt_monitor_IFAGCOut (sony_demod_t * pDemod,
uint32_t * pIFAGCOut);
/**
@brief Monitor the detected mode/guard (not TPS mode/guard).
@param pDemod The demodulator instance.
@param pMode Mode estimation result.
@param pGuard Guard interval estimation result.
@return SONY_RESULT_OK if successful and pMode, pGuard valid.
*/
sony_result_t sony_demod_dvbt_monitor_ModeGuard (sony_demod_t * pDemod,
sony_dvbt_mode_t * pMode,
sony_dvbt_guard_t * pGuard);
/**
@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 (Hz).
@return SONY_RESULT_OK if successful and pOffset valid.
*/
sony_result_t sony_demod_dvbt_monitor_CarrierOffset (sony_demod_t * pDemod,
int32_t * pOffset);
/**
@brief Monitor the Pre-Viterbi BER.
@param pDemod The demodulator instance.
@param pBER BER value (Pre Viterbi decoder) x 1e7.
@return SONY_RESULT_OK if successful and pBER valid.
*/
sony_result_t sony_demod_dvbt_monitor_PreViterbiBER (sony_demod_t * pDemod,
uint32_t * pBER);
/**
@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_dvbt_monitor_PreRSBER (sony_demod_t * pDemod,
uint32_t * pBER);
/**
@brief Monitor the TPS information.
@param pDemod The demodulator instance.
@param pInfo The TPS information.
@return SONY_RESULT_OK if successful and pInfo valid.
*/
sony_result_t sony_demod_dvbt_monitor_TPSInfo (sony_demod_t * pDemod,
sony_dvbt_tpsinfo_t * pInfo);
/**
@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_dvbt_monitor_PacketErrorNumber (sony_demod_t * pDemod,
uint32_t * pPEN);
/**
@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_dvbt_monitor_SpectrumSense (sony_demod_t * pDemod,
sony_demod_terr_cable_spectrum_sense_t * pSense);
/**
@brief Monitors the estimated SNR value, clipped to a
maximum of 40dB.
@param pDemod The demodulator instance.
@param pSNR The estimated SNR in dBx1000.
@return SONY_RESULT_OK if successful and pSNR is valid.
*/
sony_result_t sony_demod_dvbt_monitor_SNR (sony_demod_t * pDemod,
int32_t * pSNR);
/**
@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_dvbt_monitor_SamplingOffset (sony_demod_t * pDemod,
int32_t * pPPM);
/**
@brief Monitor the DVB-T quality metric. Based on Nordig SQI
equation.
@param pDemod The demodulator instance.
@param pQuality The quality as a percentage (0-100).
@return SONY_RESULT_OK if successful and pQuality valid.
*/
sony_result_t sony_demod_dvbt_monitor_Quality (sony_demod_t * pDemod,
uint8_t * pQuality);
/**
@brief Monitor the DVB-T PER (Packet Error Rate) parameters.
@param pDemod The demod instance.
@param pPER The estimated PER x 1e6.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_dvbt_monitor_PER (sony_demod_t * pDemod,
uint32_t * pPER);
/**
@brief Calculate the TS (Transport Stream) rate from TPS information.
@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_dvbt_monitor_TSRate (sony_demod_t * pDemod,
uint32_t * pTSRateKbps);
/**
@brief Monitor the averaged 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_dvbt_monitor_AveragedPreRSBER (sony_demod_t * pDemod,
uint32_t * pBER);
/**
@brief Monitor the estimated averaged SNR value, clipped to a
maximum of 40dB.
@param pDemod The demodulator instance.
@param pSNR The estimated SNR in dBx1000.
@return SONY_RESULT_OK if successful and pSNR is valid.
*/
sony_result_t sony_demod_dvbt_monitor_AveragedSNR (sony_demod_t * pDemod,
int32_t * pSNR);
/**
@brief Monitor the DVB-T quality metric using averaged BER and SNR.
Based on Nordig SQI equation.
@param pDemod The demodulator instance.
@param pQuality The quality as a percentage (0-100).
@return SONY_RESULT_OK if successful and pQuality valid.
*/
sony_result_t sony_demod_dvbt_monitor_AveragedQuality (sony_demod_t * pDemod,
uint8_t * pQuality);
#endif /* SONY_DEMOD_DVBT_MONITOR_H */
+102
View File
@@ -0,0 +1,102 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/06/24
Modification ID : 3b74e280b7ad8ce430b6a9419ac53e8f2e3737f9
------------------------------------------------------------------------------*/
/**
@file sony_dvbt.h
This file provides DVB-T related type definitions.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DVBT_H
#define SONY_DVBT_H
/*------------------------------------------------------------------------------
Enumerations
------------------------------------------------------------------------------*/
/**
@brief DVB-T constellation.
*/
typedef enum {
SONY_DVBT_CONSTELLATION_QPSK, /**< QPSK */
SONY_DVBT_CONSTELLATION_16QAM, /**< 16-QAM */
SONY_DVBT_CONSTELLATION_64QAM, /**< 64-QAM */
SONY_DVBT_CONSTELLATION_RESERVED_3 /**< Reserved. */
} sony_dvbt_constellation_t;
/**
@brief DVB-T hierarchy.
*/
typedef enum {
SONY_DVBT_HIERARCHY_NON, /**< Non-hierarchical service. */
SONY_DVBT_HIERARCHY_1, /**< a = 1. */
SONY_DVBT_HIERARCHY_2, /**< a = 2. */
SONY_DVBT_HIERARCHY_4 /**< a = 4. */
} sony_dvbt_hierarchy_t;
/**
@brief DVB-T code rate.
*/
typedef enum {
SONY_DVBT_CODERATE_1_2, /**< Code Rate : 1/2 */
SONY_DVBT_CODERATE_2_3, /**< Code Rate : 2/3 */
SONY_DVBT_CODERATE_3_4, /**< Code Rate : 3/4 */
SONY_DVBT_CODERATE_5_6, /**< Code Rate : 5/6 */
SONY_DVBT_CODERATE_7_8, /**< Code Rate : 7/8 */
SONY_DVBT_CODERATE_RESERVED_5, /**< Code Rate : Reserved */
SONY_DVBT_CODERATE_RESERVED_6, /**< Code Rate : Reserved */
SONY_DVBT_CODERATE_RESERVED_7 /**< Code Rate : Reserved */
} sony_dvbt_coderate_t;
/**
@brief DVB-T guard interval.
*/
typedef enum {
SONY_DVBT_GUARD_1_32, /**< Guard Interval : 1/32 */
SONY_DVBT_GUARD_1_16, /**< Guard Interval : 1/16 */
SONY_DVBT_GUARD_1_8, /**< Guard Interval : 1/8 */
SONY_DVBT_GUARD_1_4 /**< Guard Interval : 1/4 */
} sony_dvbt_guard_t;
/**
@brief DVB-T mode.
*/
typedef enum {
SONY_DVBT_MODE_2K, /**< 2k mode */
SONY_DVBT_MODE_8K, /**< 8k mode */
SONY_DVBT_MODE_RESERVED_2, /**< Mode Reserved 2 */
SONY_DVBT_MODE_RESERVED_3 /**< Mode Reserved 3 */
} sony_dvbt_mode_t;
/**
@brief DVB-T HP/LP profile.
*/
typedef enum {
SONY_DVBT_PROFILE_HP = 0, /**< High Priority */
SONY_DVBT_PROFILE_LP /**< Low Priority */
} sony_dvbt_profile_t;
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief The TPS information structure.
*/
typedef struct {
sony_dvbt_constellation_t constellation; /**< DVB-T constellation. */
sony_dvbt_hierarchy_t hierarchy; /**< DVB-T hierarchy. */
sony_dvbt_coderate_t rateHP; /**< The HP code rate. */
sony_dvbt_coderate_t rateLP; /**< The LP code rate. */
sony_dvbt_guard_t guard; /**< The guard interval. */
sony_dvbt_mode_t mode; /**< The mode. */
uint8_t fnum; /**< The f number. */
uint8_t lengthIndicator; /**< The Length indicator. */
uint16_t cellID; /**< The Cell ID. */
uint8_t reservedEven; /**< Reserved (Even). */
uint8_t reservedOdd; /**< Reserved (Odd). */
} sony_dvbt_tpsinfo_t;
#endif /* SONY_DVBT_H */
+734
View File
@@ -0,0 +1,734 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/27
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
------------------------------------------------------------------------------*/
/**
@file sony_dvbt2.h
This file provides DVB-T2 related type definitions.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DVBT2_H
#define SONY_DVBT2_H
/*------------------------------------------------------------------------------
Enumerations
------------------------------------------------------------------------------*/
/**
@brief Specifies the DVB-T2 profile for tuning functionality.
*/
typedef enum {
SONY_DVBT2_PROFILE_BASE, /**< Acquire to DVB-T2 base profile */
SONY_DVBT2_PROFILE_LITE, /**< Acquire to DVB-T2 lite profile */
SONY_DVBT2_PROFILE_ANY /**< Acquire to DVB-T2 base or lite profile (blind tune only) */
}sony_dvbt2_profile_t;
/**
@brief DVBT2 version definition.
*/
typedef enum {
SONY_DVBT2_V111, /**< DVBT2 V1.1.1. */
SONY_DVBT2_V121, /**< DVBT2 V1.2.1. */
SONY_DVBT2_V131 /**< DVBT2 V1.3.1. */
} sony_dvbt2_version_t;
/**
@brief DVBT2 S1 signaling definition.
*/
typedef enum {
SONY_DVBT2_S1_BASE_SISO = 0x00, /**< DVB-T2-Base SISO. */
SONY_DVBT2_S1_BASE_MISO = 0x01, /**< DVB-T2-Base MISO. */
SONY_DVBT2_S1_NON_DVBT2 = 0x02, /**< Non DVB-T2. */
SONY_DVBT2_S1_LITE_SISO = 0x03, /**< DVB-T2-Lite SISO. */
SONY_DVBT2_S1_LITE_MISO = 0x04, /**< DVB-T2-Lite MISO. */
SONY_DVBT2_S1_RSVD3 = 0x05, /**< Reserved. */
SONY_DVBT2_S1_RSVD4 = 0x06, /**< Reserved. */
SONY_DVBT2_S1_RSVD5 = 0x07, /**< Reserved. */
SONY_DVBT2_S1_UNKNOWN = 0xFF /**< Unknown. */
} sony_dvbt2_s1_t;
/**
@brief DVBT2-Base S2 Signalling definition.
Actual values are S2 >> 1.
*/
typedef enum {
SONY_DVBT2_BASE_S2_M2K_G_ANY = 0x00, /**< 2K mode with any guard. */
SONY_DVBT2_BASE_S2_M8K_G_DVBT = 0x01, /**< 8K mode with DVBT guard. */
SONY_DVBT2_BASE_S2_M4K_G_ANY = 0x02, /**< 4K mode with any guard. */
SONY_DVBT2_BASE_S2_M1K_G_ANY = 0x03, /**< 1K mode with any guard. */
SONY_DVBT2_BASE_S2_M16K_G_ANY = 0x04, /**< 16K mode with any guard. */
SONY_DVBT2_BASE_S2_M32K_G_DVBT = 0x05, /**< 32K mode with DVBT guard. */
SONY_DVBT2_BASE_S2_M8K_G_DVBT2 = 0x06, /**< 8K mode with DVBT2 guard. */
SONY_DVBT2_BASE_S2_M32K_G_DVBT2 = 0x07, /**< 32K mode with DVBT2 guard. */
SONY_DVBT2_BASE_S2_UNKNOWN = 0xFF /**< Unknown mode/guard. */
} sony_dvbt2_base_s2_t;
/**
@brief DVBT2-Lite S2 Signalling definition.
Actual values are S2 >> 1.
*/
typedef enum {
SONY_DVBT2_LITE_S2_M2K_G_ANY = 0x00, /**< 2K mode with any guard. */
SONY_DVBT2_LITE_S2_M8K_G_DVBT = 0x01, /**< 8K mode with DVBT guard. */
SONY_DVBT2_LITE_S2_M4K_G_ANY = 0x02, /**< 4K mode with any guard. */
SONY_DVBT2_LITE_S2_M16K_G_DVBT2 = 0x03, /**< 16K mode with DVBT2 guard. */
SONY_DVBT2_LITE_S2_M16K_G_DVBT = 0x04, /**< 16K mode with DVBT guard. */
SONY_DVBT2_LITE_S2_RSVD1 = 0x05, /**< Reserved. */
SONY_DVBT2_LITE_S2_M8K_G_DVBT2 = 0x06, /**< 8K mode with DVBT2 guard. */
SONY_DVBT2_LITE_S2_RSVD2 = 0x07, /**< Reserved. */
SONY_DVBT2_LITE_S2_UNKNOWN = 0xFF /**< Unknown mode/guard. */
} sony_dvbt2_lite_s2_t;
/**
@brief DVBT2 guard intervals.
Same encoding as used for L1-pre signaling Guard Interval.
*/
typedef enum {
SONY_DVBT2_G1_32 = 0x00, /**< Guard Interval : 1/32. */
SONY_DVBT2_G1_16 = 0x01, /**< Guard Interval : 1/16. */
SONY_DVBT2_G1_8 = 0x02, /**< Guard Interval : 1/8. */
SONY_DVBT2_G1_4 = 0x03, /**< Guard Interval : 1/4. */
SONY_DVBT2_G1_128 = 0x04, /**< Guard Interval : 1/128. */
SONY_DVBT2_G19_128 = 0x05, /**< Guard Interval : 19/128. */
SONY_DVBT2_G19_256 = 0x06, /**< Guard Interval : 19/256. */
SONY_DVBT2_G_RSVD1 = 0x07, /**< Reserved. */
SONY_DVBT2_G_UNKNOWN = 0xFF /**< Unknown. */
} sony_dvbt2_guard_t;
/**
@brief The DVBT2 FFT modes.
*/
typedef enum {
SONY_DVBT2_M2K = 0x00, /**< 2K mode. */
SONY_DVBT2_M8K = 0x01, /**< 8K mode. */
SONY_DVBT2_M4K = 0x02, /**< 4K mode. */
SONY_DVBT2_M1K = 0x03, /**< 1K mode. */
SONY_DVBT2_M16K = 0x04, /**< 16K mode. */
SONY_DVBT2_M32K = 0x05, /**< 32K mode. */
SONY_DVBT2_M_RSVD1 = 0x06, /**< Reserved. */
SONY_DVBT2_M_RSVD2 = 0x07 /**< Reserved. */
} sony_dvbt2_mode_t;
/**
@brief The DVBT2 bandwidth.
*/
typedef enum {
SONY_DVBT2_BW_8 = 0x00, /**< Bandwidth : 8MHz. */
SONY_DVBT2_BW_7 = 0x01, /**< Bandwidth : 7MHz. */
SONY_DVBT2_BW_6 = 0x02, /**< Bandwidth : 6MHz. */
SONY_DVBT2_BW_5 = 0x03, /**< Bandwidth : 5MHz. */
SONY_DVBT2_BW_10 = 0x04, /**< Bandwidth : 10MHz. Professional/Test Receivers Only */
SONY_DVBT2_BW_1_7 = 0x05, /**< Bandwidth : 1.7MHz. */
SONY_DVBT2_BW_RSVD1 = 0x06, /**< Reserved. */
SONY_DVBT2_BW_RSVD2 = 0x07, /**< Reserved. */
SONY_DVBT2_BW_RSVD3 = 0x08, /**< Reserved. */
SONY_DVBT2_BW_RSVD4 = 0x09, /**< Reserved. */
SONY_DVBT2_BW_RSVD5 = 0x0A, /**< Reserved. */
SONY_DVBT2_BW_RSVD6 = 0x0B, /**< Reserved. */
SONY_DVBT2_BW_RSVD7 = 0x0C, /**< Reserved. */
SONY_DVBT2_BW_RSVD8 = 0x0D, /**< Reserved. */
SONY_DVBT2_BW_RSVD9 = 0x0E, /**< Reserved. */
SONY_DVBT2_BW_RSVD10 = 0x0F, /**< Reserved. */
SONY_DVBT2_BW_UNKNOWN = 0xFF /**< Unknown Bandwidth. */
} sony_dvbt2_bw_t;
/**
@brief The DVBT2 current T2 super-frame stream type.
*/
typedef enum {
SONY_DVBT2_L1PRE_TYPE_TS = 0x00, /**< DVBT2 Streams : Transport Stream (TS) Only. */
SONY_DVBT2_L1PRE_TYPE_GS = 0x01, /**< DVBT2 Streams : Generic Streams (GS) Only. */
SONY_DVBT2_L1PRE_TYPE_TS_GS = 0x02, /**< DVBT2 Streams : Mixed GS and TS. */
SONY_DVBT2_L1PRE_TYPE_RESERVED = 0x03, /**< DVBT2 Streams : Reserved. */
SONY_DVBT2_L1PRE_TYPE_UNKNOWN = 0xFF /**< DVBT2 Stream s: Unknown. */
} sony_dvbt2_l1pre_type_t;
/**
@brief The DVBT2 L1-pre PAPR (Peak to Average Power Ratio) reduction indicator.
The mode used is dependent on the channel DVB-T2 version. Refer to
individual enumeration value comments for details.
*/
typedef enum {
/**
@brief DVBT2 PAPR reduction mode = 0x00
- DVB-T2 V1.1.1 : None
- DVB-T2 V1.2.1 and V1.3.1 : L1-ACE and TR on P2 Symbols
*/
SONY_DVBT2_PAPR_0 = 0x00,
/**
@brief DVBT2 PAPR reduction mode = 0x01
- DVB-T2 V1.1.1 : ACE
- DVB-T2 V1.2.1 and V1.3.1 : L1-ACE and ACE
*/
SONY_DVBT2_PAPR_1 = 0x01,
/**
@brief DVBT2 PAPR reduction mode = 0x02
- DVB-T2 V1.1.1 : TR
- DVB-T2 V1.2.1 and V1.3.1 : L1-ACE and TR
*/
SONY_DVBT2_PAPR_2 = 0x02,
/**
@brief DVBT2 PAP reduction mode = 0x03
- DVB-T2 V1.1.1 : TR and ACE
- DVB-T2 V1.2.1 and V1.3.1 : L1-ACE, ACE and TR
*/
SONY_DVBT2_PAPR_3 = 0x03,
SONY_DVBT2_PAPR_RSVD1 = 0x04, /**< Reseved. */
SONY_DVBT2_PAPR_RSVD2 = 0x05, /**< Reseved. */
SONY_DVBT2_PAPR_RSVD3 = 0x06, /**< Reseved. */
SONY_DVBT2_PAPR_RSVD4 = 0x07, /**< Reseved. */
SONY_DVBT2_PAPR_RSVD5 = 0x08, /**< Reseved. */
SONY_DVBT2_PAPR_RSVD6 = 0x09, /**< Reseved. */
SONY_DVBT2_PAPR_RSVD7 = 0x0A, /**< Reseved. */
SONY_DVBT2_PAPR_RSVD8 = 0x0B, /**< Reseved. */
SONY_DVBT2_PAPR_RSVD9 = 0x0C, /**< Reseved. */
SONY_DVBT2_PAPR_RSVD10 = 0x0D, /**< Reseved. */
SONY_DVBT2_PAPR_RSVD11 = 0x0E, /**< Reseved. */
SONY_DVBT2_PAPR_RSVD12 = 0x0F, /**< Reseved. */
SONY_DVBT2_PAPR_UNKNOWN = 0xFF /**< Unknown. */
} sony_dvbt2_papr_t;
/**
@brief The DVBT2 L1-post constellation/modulation.
*/
typedef enum {
SONY_DVBT2_L1POST_BPSK = 0x00, /**< DVBT2 L1-post uses BPSK. */
SONY_DVBT2_L1POST_QPSK = 0x01, /**< DVBT2 L1-post uses QPSK. */
SONY_DVBT2_L1POST_QAM16 = 0x02, /**< DVBT2 L1-post uses 16-QAM. */
SONY_DVBT2_L1POST_QAM64 = 0x03, /**< DVBT2 L1-post uses 64-QAM. */
SONY_DVBT2_L1POST_C_RSVD1 = 0x04, /**< Reserved */
SONY_DVBT2_L1POST_C_RSVD2 = 0x05, /**< Reserved */
SONY_DVBT2_L1POST_C_RSVD3 = 0x06, /**< Reserved */
SONY_DVBT2_L1POST_C_RSVD4 = 0x07, /**< Reserved */
SONY_DVBT2_L1POST_C_RSVD5 = 0x08, /**< Reserved */
SONY_DVBT2_L1POST_C_RSVD6 = 0x09, /**< Reserved */
SONY_DVBT2_L1POST_C_RSVD7 = 0x0A, /**< Reserved */
SONY_DVBT2_L1POST_C_RSVD8 = 0x0B, /**< Reserved */
SONY_DVBT2_L1POST_C_RSVD9 = 0x0C, /**< Reserved */
SONY_DVBT2_L1POST_C_RSVD10 = 0x0D, /**< Reserved */
SONY_DVBT2_L1POST_C_RSVD11 = 0x0E, /**< Reserved */
SONY_DVBT2_L1POST_C_RSVD12 = 0x0F, /**< Reserved */
SONY_DVBT2_L1POST_CONSTELL_UNKNOWN = 0xFF /**< Unknown. */
} sony_dvbt2_l1post_constell_t;
/**
@brief The DVBT2 L1-post code rate.
*/
typedef enum {
SONY_DVBT2_L1POST_R1_2 = 0x00, /**< DVBT2 L1-post uses 1/2 code rate. */
SONY_DVBT2_L1POST_R_RSVD1 = 0x01, /**< Reserved */
SONY_DVBT2_L1POST_R_RSVD2 = 0x02, /**< Reserved */
SONY_DVBT2_L1POST_R_RSVD3 = 0x03, /**< Reserved */
SONY_DVBT2_L1POST_R_UNKNOWN = 0xFF /**< Unknown. */
} sony_dvbt2_l1post_cr_t;
/**
@brief The L1-post FEC type.
*/
typedef enum {
SONY_DVBT2_L1POST_FEC_LDPC16K = 0x00, /**< DVBT2 L1-post uses 16K LDPC FEC. */
SONY_DVBT2_L1POST_FEC_RSVD1 = 0x01, /**< Reserved */
SONY_DVBT2_L1POST_FEC_RSVD2 = 0x02, /**< Reserved */
SONY_DVBT2_L1POST_FEC_RSVD3 = 0x03, /**< Reserved */
SONY_DVBT2_L1POST_FEC_UNKNOWN = 0xFF /**< Unknown. */
} sony_dvbt2_l1post_fec_type_t;
/**
@brief The L1-pre pilot pattern signaling.
*/
typedef enum {
SONY_DVBT2_PP1 = 0x00, /**< DVBT2 pilot pattern 1. */
SONY_DVBT2_PP2 = 0x01, /**< DVBT2 pilot pattern 2. */
SONY_DVBT2_PP3 = 0x02, /**< DVBT2 pilot pattern 3. */
SONY_DVBT2_PP4 = 0x03, /**< DVBT2 pilot pattern 4. */
SONY_DVBT2_PP5 = 0x04, /**< DVBT2 pilot pattern 5. */
SONY_DVBT2_PP6 = 0x05, /**< DVBT2 pilot pattern 6. */
SONY_DVBT2_PP7 = 0x06, /**< DVBT2 pilot pattern 7. */
SONY_DVBT2_PP8 = 0x07, /**< DVBT2 pilot pattern 8. */
SONY_DVBT2_PP_RSVD1 = 0x08, /**< Reserved */
SONY_DVBT2_PP_RSVD2 = 0x09, /**< Reserved */
SONY_DVBT2_PP_RSVD3 = 0x0A, /**< Reserved */
SONY_DVBT2_PP_RSVD4 = 0x0B, /**< Reserved */
SONY_DVBT2_PP_RSVD5 = 0x0C, /**< Reserved */
SONY_DVBT2_PP_RSVD6 = 0x0D, /**< Reserved */
SONY_DVBT2_PP_RSVD7 = 0x0E, /**< Reserved */
SONY_DVBT2_PP_RSVD8 = 0x0F, /**< Reserved */
SONY_DVBT2_PP_UNKNOWN = 0xFF /**< Unknown. */
} sony_dvbt2_pp_t;
/**
@brief DVBT2 PLP code rate definition.
*/
typedef enum {
SONY_DVBT2_R1_2 = 0x00, /**< Code rate : 1/2. */
SONY_DVBT2_R3_5 = 0x01, /**< Code rate : 3/5. */
SONY_DVBT2_R2_3 = 0x02, /**< Code rate : 2/3. */
SONY_DVBT2_R3_4 = 0x03, /**< Code rate : 3/4. */
SONY_DVBT2_R4_5 = 0x04, /**< Code rate : 4/5, DVB-T2-Base only. */
SONY_DVBT2_R5_6 = 0x05, /**< Code rate : 5/6, DVB-T2-Base only. */
SONY_DVBT2_R1_3 = 0x06, /**< Code rate : 1/3, DVB-T2-Lite only. */
SONY_DVBT2_R2_5 = 0x07, /**< Code rate : 2/5, DVB-T2-Lite only. */
SONY_DVBT2_PLP_CR_UNKNOWN = 0xFF /**< Unknown. */
} sony_dvbt2_plp_code_rate_t;
/**
@brief DVBT2 PLP constellation.
*/
typedef enum {
SONY_DVBT2_QPSK = 0x00, /**< QPSK. */
SONY_DVBT2_QAM16 = 0x01, /**< QAM16. */
SONY_DVBT2_QAM64 = 0x02, /**< QAM64. */
SONY_DVBT2_QAM256 = 0x03, /**< QAM256. */
SONY_DVBT2_CON_RSVD1 = 0x04, /**< Reserved */
SONY_DVBT2_CON_RSVD2 = 0x05, /**< Reserved */
SONY_DVBT2_CON_RSVD3 = 0x06, /**< Reserved */
SONY_DVBT2_CON_RSVD4 = 0x07, /**< Reserved */
SONY_DVBT2_CONSTELL_UNKNOWN = 0xFF /**< Unknown. */
} sony_dvbt2_plp_constell_t;
/**
@brief DVBT2 PLP type definition.
*/
typedef enum {
SONY_DVBT2_PLP_TYPE_COMMON = 0x00, /**< DVBT2 PLP Common Type. */
SONY_DVBT2_PLP_TYPE_DATA1 = 0x01, /**< DVBT2 PLP Data Type 1. */
SONY_DVBT2_PLP_TYPE_DATA2 = 0x02, /**< DVBT2 PLP Data Type 2. */
SONY_DVBT2_PLP_TYPE_RSVD1 = 0x03, /**< Reserved */
SONY_DVBT2_PLP_TYPE_RSVD2 = 0x04, /**< Reserved */
SONY_DVBT2_PLP_TYPE_RSVD3 = 0x05, /**< Reserved */
SONY_DVBT2_PLP_TYPE_RSVD4 = 0x06, /**< Reserved */
SONY_DVBT2_PLP_TYPE_RSVD5 = 0x07, /**< Reserved */
SONY_DVBT2_PLP_TYPE_UNKNOWN = 0xFF /**< DVBT2 PLP type UNKNOWN. */
} sony_dvbt2_plp_type_t;
/**
@brief DVBT2 PLP payload type definition.
*/
typedef enum {
SONY_DVBT2_PLP_PAYLOAD_GFPS = 0x00, /**< DVBT2 GFPS payload type. */
SONY_DVBT2_PLP_PAYLOAD_GCS = 0x01, /**< DVBT2 GCS payload type. */
SONY_DVBT2_PLP_PAYLOAD_GSE = 0x02, /**< DVBT2 GSE payload type. */
SONY_DVBT2_PLP_PAYLOAD_TS = 0x03, /**< DVBT2 TS payload type. */
SONY_DVBT2_PLP_PAYLOAD_RSVD1 = 0x04, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD2 = 0x05, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD3 = 0x06, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD4 = 0x07, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD5 = 0x08, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD6 = 0x09, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD7 = 0x0A, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD8 = 0x0B, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD9 = 0x0C, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD10 = 0x0D, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD11 = 0x0E, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD12 = 0x0F, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD13 = 0x10, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD14 = 0x11, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD15 = 0x12, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD16 = 0x13, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD17 = 0x14, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD18 = 0x15, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD19 = 0x16, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD20 = 0x17, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD21 = 0x18, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD22 = 0x19, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD23 = 0x1A, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD24 = 0x1B, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD25 = 0x1C, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD26 = 0x1D, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD27 = 0x1E, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_RSVD28 = 0x1F, /**< Reserved */
SONY_DVBT2_PLP_PAYLOAD_UNKNOWN = 0xFF /**< DVBT2 UNKNOWN payload type. */
} sony_dvbt2_plp_payload_t;
/**
@brief The DVBT2 FEC type definition.
*/
typedef enum {
SONY_DVBT2_FEC_LDPC_16K = 0x00, /**< LDPC 16K (Short FECFRAME). */
SONY_DVBT2_FEC_LDPC_64K = 0x01, /**< LDPC 64K (Long FECFRAME), DVB-T2-Base only. */
SONY_DVBT2_FEC_RSVD1 = 0x02, /**< Reserved. */
SONY_DVBT2_FEC_RSVD2 = 0x03, /**< Reserved. */
SONY_DVBT2_FEC_UNKNOWN = 0xFF /**< DVBT2 FEC Type Unknown. */
} sony_dvbt2_plp_fec_t;
/**
@brief DVB-T2 PLP input stream mode. (In L1-Post information, CRC-8 MODE field in BBHEADER)
*/
typedef enum {
SONY_DVBT2_PLP_MODE_NOTSPECIFIED = 0x00, /**< Not Specified. (Cannot get PLP_MODE from L1-Post) */
SONY_DVBT2_PLP_MODE_NM = 0x01, /**< Normal Mode. */
SONY_DVBT2_PLP_MODE_HEM = 0x02, /**< High Efficiency Mode. */
SONY_DVBT2_PLP_MODE_RESERVED = 0x03, /**< Reserved. */
SONY_DVBT2_PLP_MODE_UNKNOWN = 0xFF /**< Unknown. */
} sony_dvbt2_plp_mode_t;
/**
@brief DVBT2 basic types of PLP available.
*/
typedef enum {
SONY_DVBT2_PLP_COMMON, /**< DVBT2 basic PLP common type. */
SONY_DVBT2_PLP_DATA /**< DVBT2 basic PLP data type. */
} sony_dvbt2_plp_btype_t;
/**
@brief DVB-T2 TS/GS (Input Stream Format) bits definition. (MATYPE-1 field in BBHEADER)
*/
typedef enum {
SONY_DVBT2_STREAM_GENERIC_PACKETIZED = 0x00, /**< Generic Packetized Stream. */
SONY_DVBT2_STREAM_GENERIC_CONTINUOUS = 0x01, /**< Generic Continuous Stream. */
SONY_DVBT2_STREAM_GENERIC_ENCAPSULATED = 0x02, /**< Generic Encapsulated Stream. */
SONY_DVBT2_STREAM_TRANSPORT = 0x03, /**< Transport Stream. */
SONY_DVBT2_STREAM_UNKNOWN = 0xFF /**< Unknown. */
} sony_dvbt2_stream_t;
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief L1-pre signaling information structure definition.
*/
typedef struct sony_dvbt2_l1pre_t {
sony_dvbt2_l1pre_type_t type; /**< The stream type contained within the current T2 super-frame. */
uint8_t bwExt; /**< BW extension indicator (8K/16K/32K only). */
sony_dvbt2_s1_t s1; /**< S1 signaling. P1 S1. */
uint8_t s2; /**< S2 signaling. P1 S2. */
uint8_t mixed; /**< Mixed indicator; 0: Not mixed, 1: Mixed (from S2 field). */
sony_dvbt2_mode_t fftMode; /**< FFT mode. (from S2) */
uint8_t l1Rep; /**< L1 repeat enable flag. */
sony_dvbt2_guard_t gi; /**< The guard interval used for the current super-frame. */
sony_dvbt2_papr_t papr; /**< The PAPR indicator. */
sony_dvbt2_l1post_constell_t mod; /**< The L1-post modulation in this frame. */
sony_dvbt2_l1post_cr_t cr; /**< The L1-post code rate in this frame. */
sony_dvbt2_l1post_fec_type_t fec; /**< The L1-post FEC type. */
uint32_t l1PostSize; /**< Size of the L1-post in OFDM cells. */
uint32_t l1PostInfoSize; /**< L1-post info size = L1-post configurable+dynamic+extension. */
sony_dvbt2_pp_t pp; /**< The pilot pattern for the OFDM symbols in this frame. */
uint8_t txIdAvailability; /**< The TX Id. */
uint16_t cellId; /**< The T2 cell Id. */
uint16_t networkId; /**< The T2 network Id. */
uint16_t systemId; /**< T2 system Id. */
uint8_t numFrames; /**< Number of T2-frames per T2 super-frame. */
uint16_t numSymbols; /**< Number of OFDM symbols per T2-frame. */
uint8_t regen; /**< Regeneration count indicator. */
uint8_t postExt; /**< L1-post extensions enabled. */
uint8_t numRfFreqs; /**< The number of RF frequencies in use. */
uint8_t rfIdx; /**< The current RF index. */
sony_dvbt2_version_t t2Version; /**< The T2 Version */
uint8_t l1PostScrambled; /**< L1-Post scrambling enabled, DVB-T2 V1.3.1 or later only. */
uint8_t t2BaseLite; /**< Indicates if the DVB-T2-Base profile is compatible with DVB-T2-Lite. */
uint32_t crc32; /**< CRC-32 of L1-pre data. */
} sony_dvbt2_l1pre_t;
/**
@brief DVBT2 PLP information in L1-post signaling.
*/
typedef struct sony_dvbt2_plp_t {
/**
@brief The PLP ID.
*/
uint8_t id;
/**
@brief The type of the PLP.
*/
sony_dvbt2_plp_type_t type;
/**
@brief The payload carried by the PLP.
*/
sony_dvbt2_plp_payload_t payload;
/**
@brief TFS not supported, no meaning.
*/
uint8_t ff;
/**
@brief TFS not supported, no meaning.
*/
uint8_t firstRfIdx;
/**
@brief TFS not supported, no meaning.
*/
uint8_t firstFrmIdx;
/**
@brief The group of PLPs that this PLP belongs too.
*/
uint8_t groupId;
/**
@brief The constellation of this PLP.
*/
sony_dvbt2_plp_constell_t constell;
/**
@brief The code rate of this PLP.
*/
sony_dvbt2_plp_code_rate_t plpCr;
/**
@brief DVBT2 rotated constellation indicator.
*/
uint8_t rot;
/**
@brief The FEC type used on this PLP.
*/
sony_dvbt2_plp_fec_t fec;
/**
@brief Maximum number of PLP blocks.
*/
uint16_t numBlocksMax;
/**
@brief The T2 frame interval within the superframe of this PLP.
*/
uint8_t frmInt;
/**
@brief Time Interleaver length.
*/
uint8_t tilLen;
/**
@brief Time Interleaver type indicator.
*/
uint8_t tilType;
/**
@brief In-band A signaling indicator.
- 1 = enabled.
- 0 = disabled
*/
uint8_t inBandAFlag;
/* New fields from V1.2.1 */
/**
@brief In band B signaling indicator.
- 1 = enabled.
- 0 = disabled
*/
uint8_t inBandBFlag;
/**
@brief Reserved field. (RESERVED_1 11bit)
*/
uint16_t rsvd;
/**
@brief PLP input stream mode.
If T2 version is V1.1.1, this field will be 0. (Not Specified)
The user should get this information from BBHEADER information.
*/
sony_dvbt2_plp_mode_t plpMode;
/**
@brief This 1-bit field indicates whether the scheduling for the current PLP
varies from T2-frame to T2-frame or remains static.
*/
uint8_t staticFlag;
/**
@brief This 1-bit field indicates whether BBFRAME padding is used
other than for in-band signaling for the current PLP
*/
uint8_t staticPaddingFlag;
} sony_dvbt2_plp_t;
/**
@brief L1-post information excluding PLPs.
*/
typedef struct sony_dvbt2_l1post_t {
/**
@brief The number of sub-slices per T2 frame.
*/
uint16_t subSlicesPerFrame;
/**
@brief The number of PLPs in the current superframe.
Minimum value of 1.
*/
uint8_t numPLPs;
/**
@brief Number of auxiliary streams.
*/
uint8_t numAux;
/**
@brief Auxiliary stream config (Reserved for Future Use)
*/
uint8_t auxConfigRFU;
/**
@brief The RF index.
TFS only so not supported.
*/
uint8_t rfIdx;
/**
@brief The frequency in Hz whose index is rfIdx.
TFS only so not supported.
*/
uint32_t freq;
/**
@brief Indicates the type of FEF part. Undefined.
Only valid if S2 LSB is 1.
*/
uint8_t fefType;
/**
@brief The length of the FEF as part of the elementary
period.
Only valid if S2 LSB is 1.
*/
uint32_t fefLength;
/**
@brief The number of T2-frames between two FEF parts.
*/
uint8_t fefInterval;
} sony_dvbt2_l1post_t;
/**
@brief The DVB-T2 tuning information.
*/
typedef struct sony_dvbt2_ofdm_t {
/**
@brief The pre-amble mixed indicator (from the S2).
- 0: Not mixed.
- 1: Mixed.
*/
uint8_t mixed;
/**
@brief SISO/MISO indication.
- 0: SISO,
- 1: MISO.
*/
uint8_t isMiso;
/**
@brief The FFT mode of transmission (from the S2).
*/
sony_dvbt2_mode_t mode;
/**
@brief The guard interval used for the super-frame.
*/
sony_dvbt2_guard_t gi;
/**
@brief The pilot pattern for the OFDM symbols in this frame.
*/
sony_dvbt2_pp_t pp;
/**
@brief BW extension indicator (8K/16K/32K only).
*/
uint8_t bwExt;
/**
@brief The PAPR indicator.
*/
sony_dvbt2_papr_t papr;
/**
@brief Number of OFDM symbols per T2-frame.
*/
uint16_t numSymbols;
} sony_dvbt2_ofdm_t;
/**
@brief The DVB-T2 BBHEADER information.
*/
typedef struct sony_dvbt2_bbheader_t {
/**
@brief TS/GS (Input Stream Format) bits in MATYPE-1 field.
*/
sony_dvbt2_stream_t streamInput;
/**
@brief SIS/MIS (Single or Multiple Input Streams) bit in MATYPE-1 field.
- 1: single
- 0: multiple
*/
uint8_t isSingleInputStream;
/**
@brief CCM/ACM (Constant Coding and Modulation or Variable Coding and Modulation) bit in MATYPE-1 field.
- 1: CCM
- 0: ACM
*/
uint8_t isConstantCodingModulation;
/**
@brief ISSYI (Input Stream Synchronization Indicator) bit in MATYPE-1 field.
- 1: active
- 0: not-active
*/
uint8_t issyIndicator;
/**
@brief NPD (Null-packet deletion active/not active) bit in MATYPE-1 field.
- 1: active
- 0: not-active
*/
uint8_t nullPacketDeletion;
/**
@brief EXT bits in MATYPE-1 field.
*/
uint8_t ext;
/**
@brief Input Stream Identifier (ISI) in MATYPE-2 field. (only valid for MIS)
*/
uint8_t inputStreamIdentifier;
/**
@brief UPL (User Packet Length in bits) field. Valid only for NM mode.
*/
uint16_t userPacketLength;
/**
@brief DFL (Data Field Length in bits) field.
*/
uint16_t dataFieldLength;
/**
@brief SYNC (A copy of the User Packet Sync-byte) field. Valid only for NM mode.
*/
uint8_t syncByte;
/**
@brief ISSY (Input Stream Synchronization) field (3bytes). Valid only for HEM mode.
*/
uint32_t issy;
/**
@brief PLP input stream mode in CRC-8 MODE field.
*/
sony_dvbt2_plp_mode_t plpMode;
} sony_dvbt2_bbheader_t;
#endif /* SONY_DVBT2_H */
+558
View File
@@ -0,0 +1,558 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/08/30
Modification ID : 902dae58eb5249e028ccc5d7f60bb66cca9b43a9
------------------------------------------------------------------------------*/
#include "sony_integ.h"
#include "sony_integ_dvbt.h"
#include "sony_demod.h"
#include "sony_demod_dvbt_monitor.h"
/*------------------------------------------------------------------------------
Local Function Prototypes
------------------------------------------------------------------------------*/
/**
@brief Waits for demodulator lock, polling ::sony_demod_dvbt_monitor_SyncStat
at 10ms intervals. Called as part of the Tune process.
*/
static sony_result_t dvbt_WaitDemodLock (sony_integ_t * pInteg);
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
sony_result_t sony_integ_dvbt_Tune(sony_integ_t * pInteg,
sony_dvbt_tune_param_t * pTuneParam)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_integ_dvbt_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_5_MHZ) && (pTuneParam->bandwidth != SONY_DTV_BW_6_MHZ) &&
(pTuneParam->bandwidth != SONY_DTV_BW_7_MHZ) && (pTuneParam->bandwidth != SONY_DTV_BW_8_MHZ)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
}
/* Set DVB-T profile for acquisition */
result = sony_demod_dvbt_SetProfile(pInteg->pDemod, pTuneParam->profile);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Tune the demodulator */
result = sony_demod_dvbt_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_DVBT, 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 TS lock */
result = sony_integ_dvbt_WaitTSLock (pInteg);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
SONY_TRACE_RETURN (result);
}
sony_result_t sony_integ_dvbt_Scan(sony_integ_t * pInteg,
sony_integ_dvbt_scan_param_t * pScanParam,
sony_integ_dvbt_scan_callback_t callBack)
{
sony_result_t result = SONY_RESULT_OK;
sony_integ_dvbt_scan_result_t scanResult;
SONY_TRACE_ENTER ("sony_integ_dvbt_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);
}
if (pScanParam->stepFrequencyKHz == 0) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Check bandwidth validity */
if ((pScanParam->bandwidth != SONY_DTV_BW_5_MHZ) && (pScanParam->bandwidth != SONY_DTV_BW_6_MHZ) &&
(pScanParam->bandwidth != SONY_DTV_BW_7_MHZ) && (pScanParam->bandwidth != SONY_DTV_BW_8_MHZ)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
}
/* Set the start frequency */
scanResult.centerFreqKHz = pScanParam->startFrequencyKHz;
scanResult.tuneResult = SONY_RESULT_OK;
scanResult.dvbtTuneParam.centerFreqKHz = pScanParam->startFrequencyKHz;
scanResult.dvbtTuneParam.bandwidth = pScanParam->bandwidth;
scanResult.dvbtTuneParam.profile = SONY_DVBT_PROFILE_HP;
/* Set scan mode enabled */
result = sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_DVBT, 0x01);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Scan routine */
while (scanResult.centerFreqKHz <= pScanParam->endFrequencyKHz) {
scanResult.dvbtTuneParam.centerFreqKHz = scanResult.centerFreqKHz;
scanResult.tuneResult = sony_integ_dvbt_BlindTune(pInteg, scanResult.centerFreqKHz, pScanParam->bandwidth);
switch (scanResult.tuneResult) {
/* Channel found, callback to application */
case SONY_RESULT_OK:
callBack (pInteg, &scanResult, pScanParam);
break;
/* Intentional fall-through. */
case SONY_RESULT_ERROR_UNLOCK:
case SONY_RESULT_ERROR_TIMEOUT:
/* Channel not found, callback to application for progress updates */
callBack (pInteg, &scanResult, pScanParam);
break;
default:
/* Serious error occurred -> cancel operation. */
sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_DVBT, 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_DVBT, 0x00);
SONY_TRACE_RETURN (result);
}
}
/* Clear scan mode */
result = sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_DVBT, 0x00);
SONY_TRACE_RETURN (result);
}
sony_result_t sony_integ_dvbt_BlindTune(sony_integ_t * pInteg,
uint32_t centerFreqKHz,
sony_dtv_bandwidth_t bandwidth)
{
sony_result_t result = SONY_RESULT_OK;
sony_dvbt_tune_param_t tuneParam;
SONY_TRACE_ENTER ("sony_integ_dvbt_BlindTune");
if ((!pInteg) || (!pInteg->pDemod)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Confirm the demod is in a valid state to accept this API */
if ((pInteg->pDemod->state != SONY_DEMOD_STATE_SLEEP) && (pInteg->pDemod->state != SONY_DEMOD_STATE_ACTIVE)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Check bandwidth validity */
if ((bandwidth != SONY_DTV_BW_5_MHZ) && (bandwidth != SONY_DTV_BW_6_MHZ) &&
(bandwidth != SONY_DTV_BW_7_MHZ) && (bandwidth != SONY_DTV_BW_8_MHZ)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
}
/* Attempt DVB-T acquisition */
tuneParam.bandwidth = bandwidth;
tuneParam.centerFreqKHz = centerFreqKHz;
tuneParam.profile = SONY_DVBT_PROFILE_HP;
/* Set DVB-T profile to HP to allow detection of hierachical and non-hierachical modes */
result = sony_demod_dvbt_SetProfile(pInteg->pDemod, SONY_DVBT_PROFILE_HP);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Tune the demodulator */
result = sony_demod_dvbt_Tune (pInteg->pDemod, &tuneParam);
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, tuneParam.centerFreqKHz, SONY_DTV_SYSTEM_DVBT, tuneParam.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 lock */
result = dvbt_WaitDemodLock (pInteg);
SONY_TRACE_RETURN (result);
}
sony_result_t sony_integ_dvbt_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_dvbt_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_DVBT_WAIT_TS_LOCK) {
continueWait = 0;
}
result = sony_demod_dvbt_CheckTSLock (pInteg->pDemod, &lock);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Check Echo Optomization */
result = sony_demod_dvbt_EchoOptimization(pInteg->pDemod);
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_DVBT_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_dvbt_monitor_RFLevel (sony_integ_t * pInteg, int32_t * pRFLeveldB)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_integ_dvbt_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_DVBT) {
/* Not DVB-T */
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_dvbt_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);
}
sony_result_t sony_integ_dvbt_monitor_SSI (sony_integ_t * pInteg, uint8_t * pSSI)
{
int32_t rfLevel;
sony_dvbt_tpsinfo_t tps;
int32_t prel;
int32_t tempSSI = 0;
sony_result_t result = SONY_RESULT_OK;
static const int32_t pRefdBm1000[3][5] = {
/* 1/2, 2/3, 3/4, 5/6, 7/8, */
{-93000, -91000, -90000, -89000, -88000}, /* QPSK */
{-87000, -85000, -84000, -83000, -82000}, /* 16-QAM */
{-82000, -80000, -78000, -77000, -76000}, /* 64-QAM */
};
SONY_TRACE_ENTER ("sony_integ_dvbt_monitor_SSI");
if ((!pInteg) || (!pInteg->pDemod) || (!pSSI)) {
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_DVBT) {
/* Not DVB-T */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Get estimated RF Level */
result = sony_integ_dvbt_monitor_RFLevel (pInteg, &rfLevel);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Monitor TPS for Modulation / Code Rate */
result = sony_demod_dvbt_monitor_TPSInfo (pInteg->pDemod, &tps);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Ensure correct TPS values. */
if ((tps.constellation >= SONY_DVBT_CONSTELLATION_RESERVED_3) || (tps.rateHP >= SONY_DVBT_CODERATE_RESERVED_5)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_OTHER);
}
/* prel = prec - pref */
prel = rfLevel - pRefdBm1000[tps.constellation][tps.rateHP];
/* SSI (Signal Strength Indicator) is calculated from:
*
* if (prel < -15dB) SSI = 0
* if (-15dB <= prel < 0dB) SSI = (2/3) * (prel + 15)
* if (0dB <= prel < 20dB) SSI = (4 * prel) + 10
* if (20dB <= prel < 35dB) SSI = (2/3) * (prel - 20) + 90
* if (prel >= 35dB) SSI = 100
*/
if (prel < -15000) {
tempSSI = 0;
}
else if (prel < 0) {
/* Note : prel and 2/3 scaled by 10^3 so divide by 10^6 added */
tempSSI = ((2 * (prel + 15000)) + 1500) / 3000;
}
else if (prel < 20000) {
/* Note : prel scaled by 10^3 so divide by 10^3 added */
tempSSI = (((4 * prel) + 500) / 1000) + 10;
}
else if (prel < 35000) {
/* Note : prel and 2/3 scaled by 10^3 so divide by 10^6 added */
tempSSI = (((2 * (prel - 20000)) + 1500) / 3000) + 90;
}
else {
tempSSI = 100;
}
/* Clip value to 100% */
*pSSI = (tempSSI > 100)? 100 : (uint8_t)tempSSI;
SONY_TRACE_RETURN (result);
}
/*------------------------------------------------------------------------------
Static Functions
------------------------------------------------------------------------------*/
static sony_result_t dvbt_WaitDemodLock (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 ("dvbt_WaitDemodLock");
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_DVBT_WAIT_DEMOD_LOCK) {
continueWait = 0;
}
result = sony_demod_dvbt_CheckDemodLock (pInteg->pDemod, &lock);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Check Echo Optomization */
result = sony_demod_dvbt_EchoOptimization(pInteg->pDemod);
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_DVBT_WAIT_LOCK_INTERVAL);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
} else {
result = SONY_RESULT_ERROR_TIMEOUT;
break;
}
}
SONY_TRACE_RETURN (result);
}
+205
View File
@@ -0,0 +1,205 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/27
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
------------------------------------------------------------------------------*/
/**
@file sony_integ_dvbt.h
This file provides the integration layer interface for DVB-T
specific demodulator functions.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_INTEG_DVBT_H
#define SONY_INTEG_DVBT_H
#include "sony_demod.h"
#include "sony_integ.h"
#include "sony_demod_dvbt.h"
/*------------------------------------------------------------------------------
Defines
------------------------------------------------------------------------------*/
#define SONY_DVBT_WAIT_DEMOD_LOCK 1000 /**< 1s timeout for wait demodulator lock process for DVB-T channels */
#define SONY_DVBT_WAIT_TS_LOCK 1000 /**< 1s timeout for wait TS lock process for DVB-T channels */
#define SONY_DVBT_WAIT_LOCK_INTERVAL 10 /**< 10ms polling interval for demodulator and TS lock functions */
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief The parameters used for DVB-T scanning.
*/
typedef struct sony_integ_dvbt_scan_param_t{
/**
@brief The start frequency in kHz for scanning. Ensure that this is
aligned with the channel raster.
*/
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_dvbt_scan_param_t;
/**
@brief The structure used to return a channel located or progress update
as part of a DVB-T scan.
*/
typedef struct sony_integ_dvbt_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 has been locked and the tuneParam structure contains
the channel information.
*/
sony_result_t tuneResult;
/**
@brief The tune params for a located DVB-T channel.
*/
sony_dvbt_tune_param_t dvbtTuneParam;
}sony_integ_dvbt_scan_result_t;
/*------------------------------------------------------------------------------
Function Pointers
------------------------------------------------------------------------------*/
/**
@brief Callback function that is called for every attempted frequency during a scan.
For successful channel results the function is called after
demodulator lock but before TS lock is achieved (DVB-T : TPS Lock).
@param pInteg The driver instance.
@param pResult The current scan result.
@param pScanParam The current scan parameters.
*/
typedef void (*sony_integ_dvbt_scan_callback_t) (sony_integ_t * pInteg,
sony_integ_dvbt_scan_result_t * pResult,
sony_integ_dvbt_scan_param_t * pScanParam);
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Performs acquisition to a DVB-T 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.
@note For non-hierarchical modes, the profile should be set to
SONY_DVBT_PROFILE_HP. If SONY_DVBT_PROFILE_LP is requested, but the
detected signal mode is non-hierarchical, the transport stream
can be corrupted even if this API returns SONY_RESULT_OK.
@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_dvbt_Tune(sony_integ_t * pInteg,
sony_dvbt_tune_param_t * pTuneParam);
/**
@brief Attempts to acquire to the DVB-T channel at the center frequency provided.
SONY_DVBT_PROFILE_HP is used in performing the acquisition.
This function blocks the calling thread until the demod has locked or has
timed out. Use ::sony_integ_Cancel to cancel the operation at any time.
For TS lock please call the wait TS lock function
::sony_integ_dvbt_WaitTSLock.
@param pInteg The driver instance.
@param centerFreqKHz The center frequency of the channel to attempt acquisition on
@param bandwidth The bandwidth of the channel
@return SONY_RESULT_OK if tuned successfully to the channel.
*/
sony_result_t sony_integ_dvbt_BlindTune(sony_integ_t * pInteg,
uint32_t centerFreqKHz,
sony_dtv_bandwidth_t bandwidth);
/**
@brief Performs a scan over the spectrum specified.
Perform a DVB-T system scan for DVB-T channels.
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_dvbt_Scan(sony_integ_t * pInteg,
sony_integ_dvbt_scan_param_t * pScanParam,
sony_integ_dvbt_scan_callback_t callBack);
/**
@brief Polls the demodulator waiting for TS lock at 10ms intervals up to a time-out of 1s.
Called internally and usually after ::sony_demod_TuneEnd. The usage can be found
in ::sony_integ_dvbt_Tune.
@param pInteg The driver instance
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_integ_dvbt_WaitTSLock (sony_integ_t * pInteg);
/**
@brief RF level monitor function.
This function returns the estimated RF level based on either the demodulator IFAGC
level or a tuner internal RSSI monitor. If any compensation for external hardware
such as, LNA, attenuators is required, then the user should make adjustment in the
corresponding function.
@param pInteg The driver instance
@param pRFLeveldB The RF Level estimation in dB * 1000
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_integ_dvbt_monitor_RFLevel (sony_integ_t * pInteg, int32_t * pRFLeveldB);
/**
@brief DVB-T monitor for SSI (Signal Strength Indicator), based on the RF Level monitor value
::sony_integ_dvbt_monitor_RFLevel.
@note The RF Level monitor function should be optimised for your HW configuration before using
this monitor.
@param pInteg The driver instance
@param pSSI The Signal Strength Indicator value in %
@return SONY_RESULT_OK if successful
*/
sony_result_t sony_integ_dvbt_monitor_SSI (sony_integ_t * pInteg, uint8_t * pSSI);
#endif /* SONY_INTEG_DVBT_H */
+934
View File
@@ -0,0 +1,934 @@
/*------------------------------------------------------------------------------
Copyright 2016-2020 Sony Semiconductor Solutions Corporation
Last Updated : 2020/03/18
Modification ID : a9cb698cf8e0a7d7b31004474dfa6164268519f1
------------------------------------------------------------------------------*/
#include "sony_integ.h"
#include "sony_integ_dvbt2.h"
#include "sony_demod.h"
#include "sony_demod_dvbt2_monitor.h"
/*------------------------------------------------------------------------------
Local Function Prototypes
------------------------------------------------------------------------------*/
/**
@brief Waits for demodulator lock, polling ::sony_demod_dvbt2_monitor_SyncStat
at 10ms intervals. Called as part of the Tune process.
*/
static sony_result_t dvbt2_WaitDemodLock (sony_integ_t * pInteg, sony_dvbt2_profile_t profile);
/**
@brief Waits for L1 Post to be valid to ensure that subsequent calls to
L1 based monitors do not return HW State error. Polls
::sony_demod_dvbt2_CheckL1PostValid at 10ms intervals. Called as
part of the Tune, BlindTune and Scan processes.
*/
static sony_result_t dvbt2_WaitL1PostLock (sony_integ_t * pInteg);
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
sony_result_t sony_integ_dvbt2_Tune (sony_integ_t * pInteg,
sony_dvbt2_tune_param_t * pTuneParam)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_integ_dvbt2_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_1_7_MHZ) && (pTuneParam->bandwidth != SONY_DTV_BW_5_MHZ) &&
(pTuneParam->bandwidth != SONY_DTV_BW_6_MHZ) && (pTuneParam->bandwidth != SONY_DTV_BW_7_MHZ) &&
(pTuneParam->bandwidth != SONY_DTV_BW_8_MHZ)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
}
/* Check for valid profile selection */
if ((pTuneParam->profile != SONY_DVBT2_PROFILE_BASE) && (pTuneParam->profile != SONY_DVBT2_PROFILE_LITE)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Configure for manual PLP selection. */
result = sony_demod_dvbt2_SetPLPConfig (pInteg->pDemod, 0x00, pTuneParam->dataPlpId);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Configure the DVB-T2 profile without recovery */
result = sony_demod_dvbt2_SetProfile(pInteg->pDemod, pTuneParam->profile);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Tune the demodulator */
result = sony_demod_dvbt2_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_DVBT2, 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 lock */
result = dvbt2_WaitDemodLock (pInteg, pTuneParam->profile);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Wait for TS lock */
result = sony_integ_dvbt2_WaitTSLock (pInteg, pTuneParam->profile);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* In DVB-T2, L1 Post information may not immediately be valid after acquisition
* (L1POST_OK bit != 1). This wait loop handles such cases. This issue occurs
* only under clean signal lab conditions, and will therefore not extend acquistion
* time under normal conditions.
*/
result = dvbt2_WaitL1PostLock (pInteg);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Confirm correct PLP selection in acquisition */
{
uint8_t plpNotFound;
result = sony_demod_dvbt2_monitor_DataPLPError (pInteg->pDemod, &plpNotFound);
if (result == SONY_RESULT_ERROR_HW_STATE) {
/* Demod lock is lost causing monitor to fail, return UNLOCK instead of HW STATE */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_UNLOCK);
}
else if (result != SONY_RESULT_OK) {
/* Serious error, so return result */
SONY_TRACE_RETURN (result);
}
if (plpNotFound) {
result = SONY_RESULT_OK_CONFIRM;
pTuneParam->tuneInfo = SONY_DEMOD_DVBT2_TUNE_INFO_INVALID_PLP_ID;
}
else {
pTuneParam->tuneInfo = SONY_DEMOD_DVBT2_TUNE_INFO_OK;
}
}
SONY_TRACE_RETURN (result);
}
sony_result_t sony_integ_dvbt2_Scan (sony_integ_t * pInteg,
sony_integ_dvbt2_scan_param_t * pScanParam,
sony_integ_dvbt2_scan_callback_t callBack)
{
sony_result_t result = SONY_RESULT_OK;
sony_integ_dvbt2_scan_result_t scanResult;
SONY_TRACE_ENTER ("sony_integ_dvbt2_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);
}
if (pScanParam->stepFrequencyKHz == 0) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Check bandwidth validity */
if ((pScanParam->bandwidth != SONY_DTV_BW_1_7_MHZ) && (pScanParam->bandwidth != SONY_DTV_BW_5_MHZ) &&
(pScanParam->bandwidth != SONY_DTV_BW_6_MHZ) && (pScanParam->bandwidth != SONY_DTV_BW_7_MHZ) &&
(pScanParam->bandwidth != SONY_DTV_BW_8_MHZ)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
}
/* Set the start frequency */
scanResult.centerFreqKHz = pScanParam->startFrequencyKHz;
scanResult.tuneResult = SONY_RESULT_OK;
scanResult.dvbt2TuneParam.centerFreqKHz = pScanParam->startFrequencyKHz;
scanResult.dvbt2TuneParam.bandwidth = pScanParam->bandwidth;
scanResult.dvbt2TuneParam.dataPlpId = 0;
scanResult.dvbt2TuneParam.profile = SONY_DVBT2_PROFILE_BASE;
scanResult.dvbt2TuneParam.tuneInfo = SONY_DEMOD_DVBT2_TUNE_INFO_OK;
/* Set scan mode enabled */
result = sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_DVBT2, 0x01);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Scan routine */
while (scanResult.centerFreqKHz <= pScanParam->endFrequencyKHz) {
sony_dvbt2_profile_t profileFound = SONY_DVBT2_PROFILE_ANY;
uint8_t channelComplete = 0;
sony_dvbt2_profile_t blindTuneProfile = pScanParam->t2Profile;
scanResult.dvbt2TuneParam.centerFreqKHz = scanResult.centerFreqKHz;
while (!channelComplete) {
scanResult.tuneResult = sony_integ_dvbt2_BlindTune(pInteg, scanResult.centerFreqKHz, pScanParam->bandwidth, blindTuneProfile, &profileFound);
switch (scanResult.tuneResult) {
case SONY_RESULT_OK:
{
uint8_t numPLPs = 0;
uint8_t plpIds[255];
uint8_t mixed;
uint8_t i;
scanResult.dvbt2TuneParam.profile = profileFound;
result = sony_integ_dvbt2_Scan_PrepareDataPLPLoop(pInteg, plpIds, &numPLPs, &mixed);
if (result == SONY_RESULT_ERROR_HW_STATE) {
/* Callback to application for progress updates */
scanResult.tuneResult = SONY_RESULT_ERROR_UNLOCK;
callBack (pInteg, &scanResult, pScanParam);
/* Error in monitored data, ignore current channel */
channelComplete = 1;
}
else if (result != SONY_RESULT_OK) {
/* Serious error occurred -> cancel operation. */
sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_DVBT2, 0x00);
SONY_TRACE_RETURN (result);
}
else {
/* Set PLP ID in tune parameter structure and provide callback for first PLP */
scanResult.dvbt2TuneParam.dataPlpId = plpIds[0];
callBack (pInteg, &scanResult, pScanParam);
/* Callback for each subsequent PLP in current profile */
for (i = 1; i < numPLPs; i++) {
result = sony_integ_dvbt2_Scan_SwitchDataPLP(pInteg, mixed, plpIds[i], profileFound);
if (result != SONY_RESULT_OK) {
sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_DVBT2, 0x00);
SONY_TRACE_RETURN (result);
}
/* Set PLP ID in tune parameter structure and provide callback */
scanResult.dvbt2TuneParam.dataPlpId = plpIds[i];
callBack (pInteg, &scanResult, pScanParam);
}
/* If profile is ANY, check for mixed profile channels */
if (blindTuneProfile == SONY_DVBT2_PROFILE_ANY) {
/* Check for mixed profiles available */
if (mixed) {
/* Set Blind Tune parameters to DVB-T2 only and the other profile
* compared to that already located */
if (profileFound == SONY_DVBT2_PROFILE_BASE) {
blindTuneProfile = SONY_DVBT2_PROFILE_LITE;
}
else if (profileFound == SONY_DVBT2_PROFILE_LITE) {
blindTuneProfile = SONY_DVBT2_PROFILE_BASE;
}
else {
/* Serious error occurred -> cancel operation. */
sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_DVBT2, 0x00);
SONY_TRACE_RETURN (result);
}
}
else {
/* Channel is not mixed profile so continue to next frequency */
channelComplete = 1;
}
}
else {
/* Profile is fixed therefore this frequency is complete */
channelComplete = 1;
}
}
}
break;
/* Intentional fall-through. */
case SONY_RESULT_ERROR_UNLOCK:
case SONY_RESULT_ERROR_TIMEOUT:
/* Channel not found, callback to application for progress updates */
callBack (pInteg, &scanResult, pScanParam);
/* Go to next frequency */
channelComplete = 1;
break;
default:
{
/* Serious error occurred -> cancel operation. */
sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_DVBT2, 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_DVBT2, 0x00);
SONY_TRACE_RETURN (result);
}
}
/* Clear scan mode */
result = sony_demod_terr_cable_SetScanMode(pInteg->pDemod, SONY_DTV_SYSTEM_DVBT2, 0x00);
SONY_TRACE_RETURN (result);
}
sony_result_t sony_integ_dvbt2_Scan_PrepareDataPLPLoop (sony_integ_t * pInteg, uint8_t pPLPIds[], uint8_t *pNumPLPs, uint8_t *pMixed)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_integ_dvbt2_Scan_PrepareDataPLPLoop");
if ((!pInteg) || (!pPLPIds) || (!pNumPLPs) || (!pMixed)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if (pInteg->pDemod->state != SONY_DEMOD_STATE_ACTIVE) {
/* This api is accepted in Active states only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Obtain the T2 PLP list from Data PLP monitor */
result = sony_demod_dvbt2_monitor_DataPLPs (pInteg->pDemod, pPLPIds, pNumPLPs);
if (result == SONY_RESULT_OK) {
/* Check for mixed profile channels */
sony_dvbt2_ofdm_t ofdm;
result = sony_demod_dvbt2_monitor_OFDM (pInteg->pDemod, &ofdm);
if (result == SONY_RESULT_OK) {
*pMixed = ofdm.mixed;
}
}
SONY_TRACE_RETURN (result);
}
sony_result_t sony_integ_dvbt2_Scan_SwitchDataPLP (sony_integ_t * pInteg, uint8_t mixed, uint8_t plpId, sony_dvbt2_profile_t profile)
{
sony_result_t result = SONY_RESULT_OK;
uint16_t plpAcquisitionTime = 0;
sony_stopwatch_t timer;
SONY_TRACE_ENTER ("sony_integ_dvbt2_Scan_SwitchDataPLP");
if (!pInteg) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if (profile == SONY_DVBT2_PROFILE_ANY) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if (pInteg->pDemod->state != SONY_DEMOD_STATE_ACTIVE) {
/* This api is accepted in Active states only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
result = sony_demod_dvbt2_SetPLPConfig (pInteg->pDemod, 0x00, plpId);
if (result != SONY_RESULT_OK) {
/* Serious error occurred -> cancel operation. */
SONY_TRACE_RETURN (result);
}
if ((profile == SONY_DVBT2_PROFILE_BASE) && (mixed)) {
plpAcquisitionTime = 510;
}
else if ((profile == SONY_DVBT2_PROFILE_LITE) && (mixed)) {
plpAcquisitionTime = 1260;
}
else {
plpAcquisitionTime = 260;
}
/* Start stopwatch to measure PLP acquisition time */
result = sony_stopwatch_start (&timer);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
for (;;) {
uint32_t elapsed;
/* Check cancellation. */
result = sony_integ_CheckCancellation (pInteg);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
result = sony_stopwatch_elapsed(&timer, &elapsed);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
if (elapsed >= plpAcquisitionTime) {
break; /* finish waiting */
} else {
result = sony_stopwatch_sleep (&timer, SONY_DVBT2_WAIT_LOCK_INTERVAL);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
}
}
SONY_TRACE_RETURN (result);
}
sony_result_t sony_integ_dvbt2_BlindTune (sony_integ_t * pInteg,
uint32_t centerFreqKHz,
sony_dtv_bandwidth_t bandwidth,
sony_dvbt2_profile_t profile,
sony_dvbt2_profile_t * pProfileTuned)
{
sony_result_t result = SONY_RESULT_OK;
sony_dvbt2_tune_param_t tuneParam;
SONY_TRACE_ENTER ("sony_integ_dvbt2_BlindTune");
if ((!pInteg) || (!pInteg->pDemod) || (!pProfileTuned)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Confirm the demod is in a valid state to accept this API */
if ((pInteg->pDemod->state != SONY_DEMOD_STATE_SLEEP) && (pInteg->pDemod->state != SONY_DEMOD_STATE_ACTIVE)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Check bandwidth validity */
if ((bandwidth != SONY_DTV_BW_1_7_MHZ) && (bandwidth != SONY_DTV_BW_5_MHZ) &&
(bandwidth != SONY_DTV_BW_6_MHZ) && (bandwidth != SONY_DTV_BW_7_MHZ) &&
(bandwidth != SONY_DTV_BW_8_MHZ)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
}
/* Attempt DVB-T2 acquisition */
tuneParam.bandwidth = bandwidth;
tuneParam.centerFreqKHz = centerFreqKHz;
tuneParam.dataPlpId = 0; /* Not used in blind acquisition */
/* Configure for automatic PLP selection. */
result = sony_demod_dvbt2_SetPLPConfig (pInteg->pDemod, 0x01, 0x00);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Configure the DVB-T2 profile without recovery */
result = sony_demod_dvbt2_SetProfile(pInteg->pDemod, profile);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Tune the demodulator */
result = sony_demod_dvbt2_Tune (pInteg->pDemod, &tuneParam);
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, tuneParam.centerFreqKHz, SONY_DTV_SYSTEM_DVBT2, tuneParam.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 lock */
result = dvbt2_WaitDemodLock (pInteg, profile);
switch (result) {
case SONY_RESULT_OK:
/* In DVB-T2, L1 Post information may not immediately be valid after acquisition
* (L1POST_OK bit != 1). This wait loop handles such cases. This issue occurs
* only under clean signal lab conditions, and will therefore not extend acquistion
* time under normal conditions.
*/
result = dvbt2_WaitL1PostLock (pInteg);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
if (profile == SONY_DVBT2_PROFILE_ANY) {
/* Obtain the current profile if detection was automatic. */
result = sony_demod_dvbt2_monitor_Profile (pInteg->pDemod, pProfileTuned);
if (result == SONY_RESULT_ERROR_HW_STATE) {
/* Demod lock is lost causing monitor to fail, return UNLOCK instead of HW STATE */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_UNLOCK);
}
else if (result != SONY_RESULT_OK) {
/* Serious error, so return result */
SONY_TRACE_RETURN (result);
}
}
else {
/* Else, set the tuned profile to the input parameter */
*pProfileTuned = profile;
}
break;
/* Intentional fall-through */
case SONY_RESULT_ERROR_TIMEOUT:
case SONY_RESULT_ERROR_UNLOCK:
break;
default:
SONY_TRACE_RETURN(result);
}
SONY_TRACE_RETURN (result);
}
sony_result_t sony_integ_dvbt2_WaitTSLock (sony_integ_t * pInteg, sony_dvbt2_profile_t profile)
{
sony_result_t result = SONY_RESULT_OK;
sony_demod_lock_result_t lock = SONY_DEMOD_LOCK_RESULT_NOTDETECT;
uint16_t timeout = 0;
sony_stopwatch_t timer;
uint8_t continueWait = 1;
uint32_t elapsed = 0;
SONY_TRACE_ENTER ("sony_integ_dvbt2_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);
}
if (profile == SONY_DVBT2_PROFILE_BASE) {
timeout = SONY_DVBT2_BASE_WAIT_TS_LOCK;
}
else if (profile == SONY_DVBT2_PROFILE_LITE) {
timeout = SONY_DVBT2_LITE_WAIT_TS_LOCK;
}
else {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* 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 >= timeout) {
continueWait = 0;
}
result = sony_demod_dvbt2_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_DVBT2_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_dvbt2_monitor_RFLevel (sony_integ_t * pInteg, int32_t * pRFLeveldB)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_integ_dvbt2_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_DVBT2) {
/* Not DVB-T2*/
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_dvbt2_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);
}
sony_result_t sony_integ_dvbt2_monitor_SSI (sony_integ_t * pInteg, uint8_t * pSSI)
{
int32_t rfLevel;
sony_dvbt2_plp_constell_t qam;
sony_dvbt2_plp_code_rate_t codeRate;
int32_t prel;
int32_t tempSSI = 0;
sony_result_t result = SONY_RESULT_OK;
static const int32_t pRefdBm1000[4][8] = {
/* 1/2, 3/5, 2/3, 3/4, 4/5, 5/6, 1/3, 2/5 */
{-96000, -95000, -94000, -93000, -92000, -92000, -98000, -97000}, /* QPSK */
{-91000, -89000, -88000, -87000, -86000, -86000, -93000, -92000}, /* 16-QAM */
{-86000, -85000, -83000, -82000, -81000, -80000, -89000, -88000}, /* 64-QAM */
{-82000, -80000, -78000, -76000, -75000, -74000, -86000, -84000}, /* 256-QAM */
};
SONY_TRACE_ENTER ("sony_integ_dvbt2_monitor_SSI");
if ((!pInteg) || (!pInteg->pDemod) || (!pSSI)) {
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_DVBT2) {
/* Not DVB-T2*/
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Get estimated RF Level */
result = sony_integ_dvbt2_monitor_RFLevel (pInteg, &rfLevel);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Get PLP constellation */
result = sony_demod_dvbt2_monitor_QAM (pInteg->pDemod, SONY_DVBT2_PLP_DATA, &qam);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Get PLP code rate */
result = sony_demod_dvbt2_monitor_CodeRate (pInteg->pDemod, SONY_DVBT2_PLP_DATA, &codeRate);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Ensure correct plp info. */
if ((codeRate > SONY_DVBT2_R2_5) || (qam > SONY_DVBT2_QAM256)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_OTHER);
}
/* prel = prec - pref */
prel = rfLevel - pRefdBm1000[qam][codeRate];
/* SSI (Signal Strength Indicator) is calculated from:
*
* if (prel < -15dB) SSI = 0
* if (-15dB <= prel < 0dB) SSI = (2/3) * (prel + 15)
* if (0dB <= prel < 20dB) SSI = 4 * prel + 10
* if (20dB <= prel < 35dB) SSI = (2/3) * (prel - 20) + 90
* if (prel >= 35dB) SSI = 100
*/
if (prel < -15000) {
tempSSI = 0;
}
else if (prel < 0) {
/* Note : prel and 2/3 scaled by 10^3 so divide by 10^6 added */
tempSSI = ((2 * (prel + 15000)) + 1500) / 3000;
}
else if (prel < 20000) {
/* Note : prel scaled by 10^3 so divide by 10^3 added */
tempSSI = (((4 * prel) + 500) / 1000) + 10;
}
else if (prel < 35000) {
/* Note : prel and 2/3 scaled by 10^3 so divide by 10^6 added */
tempSSI = (((2 * (prel - 20000)) + 1500) / 3000) + 90;
}
else {
tempSSI = 100;
}
/* Clip value to 100% */
*pSSI = (tempSSI > 100)? 100 : (uint8_t)tempSSI;
SONY_TRACE_RETURN (result);
}
/*------------------------------------------------------------------------------
Local Functions
------------------------------------------------------------------------------*/
static sony_result_t dvbt2_WaitDemodLock (sony_integ_t * pInteg, sony_dvbt2_profile_t profile)
{
sony_result_t result = SONY_RESULT_OK;
sony_demod_lock_result_t lock = SONY_DEMOD_LOCK_RESULT_NOTDETECT;
uint16_t timeout = 0;
sony_stopwatch_t timer;
uint8_t continueWait = 1;
uint32_t elapsed = 0;
SONY_TRACE_ENTER ("dvbt2_WaitDemodLock");
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);
}
if (profile == SONY_DVBT2_PROFILE_BASE) {
timeout = SONY_DVBT2_BASE_WAIT_DEMOD_LOCK;
}
else if ((profile == SONY_DVBT2_PROFILE_LITE) || (profile == SONY_DVBT2_PROFILE_ANY)) {
timeout = SONY_DVBT2_LITE_WAIT_DEMOD_LOCK;
}
else {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* 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 >= timeout) {
continueWait = 0;
}
result = sony_demod_dvbt2_CheckDemodLock (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_DVBT2_WAIT_LOCK_INTERVAL);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
} else {
result = SONY_RESULT_ERROR_TIMEOUT;
break;
}
}
SONY_TRACE_RETURN (result);
}
static sony_result_t dvbt2_WaitL1PostLock (sony_integ_t * pInteg)
{
sony_result_t result = SONY_RESULT_OK;
sony_stopwatch_t timer;
uint8_t continueWait = 1;
uint32_t elapsed = 0;
uint8_t l1PostValid;
SONY_TRACE_ENTER ("dvbt2_WaitL1PostLock");
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);
}
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);
}
/* Check for timeout condition */
if (elapsed >= SONY_DVBT2_L1POST_TIMEOUT) {
continueWait = 0;
}
result = sony_demod_dvbt2_CheckL1PostValid (pInteg->pDemod, &l1PostValid);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* If L1 Post is valid, return from loop, else continue waiting */
if (l1PostValid) {
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
/* Check cancellation. */
result = sony_integ_CheckCancellation (pInteg);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
if (continueWait) {
result = sony_stopwatch_sleep (&timer, SONY_DVBT2_WAIT_LOCK_INTERVAL);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
}
else {
result = SONY_RESULT_ERROR_TIMEOUT;
break;
}
}
SONY_TRACE_RETURN (result);
}
+270
View File
@@ -0,0 +1,270 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/27
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
------------------------------------------------------------------------------*/
/**
@file sony_integ_dvbt2.h
This file provides the integration layer interface for DVB-T and DVB-T2
specific demodulator functions.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_INTEG_DVBT2_H
#define SONY_INTEG_DVBT2_H
#include "sony_demod.h"
#include "sony_integ.h"
#include "sony_demod_dvbt2.h"
/*------------------------------------------------------------------------------
Defines
------------------------------------------------------------------------------*/
#define SONY_DVBT2_BASE_WAIT_DEMOD_LOCK 3500 /**< 3.5s timeout for wait demodulator lock process for DVB-T2-Base channels */
#define SONY_DVBT2_BASE_WAIT_TS_LOCK 1500 /**< 1.5s timeout for wait TS lock process for DVB-T2-Base channels */
#define SONY_DVBT2_LITE_WAIT_DEMOD_LOCK 5000 /**< 5.0s timeout for wait demodulator lock process for DVB-T2-Lite channels */
#define SONY_DVBT2_LITE_WAIT_TS_LOCK 2300 /**< 2.3s timeout for wait TS lock process for DVB-T2-Lite channels */
#define SONY_DVBT2_WAIT_LOCK_INTERVAL 10 /**< 10ms polling interval for demodulator and TS lock functions */
#define SONY_DVBT2_L1POST_TIMEOUT 500 /**< 500ms timeout for L1Post Valid loop */
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief The parameters used for DVB-T2 scanning.
*/
typedef struct sony_integ_dvbt2_scan_param_t{
/**
@brief The start frequency in kHz for scanning. Ensure that this is
aligned with the channel raster.
*/
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;
/**
@brief The DVB-T2 profile to use for the blind tune. Use
::SONY_DVBT2_PROFILE_ANY for mixed or Base and Lite spectrums.
*/
sony_dvbt2_profile_t t2Profile;
}sony_integ_dvbt2_scan_param_t;
/**
@brief The structure used to return a channel located or progress update
as part of a DVB-T2 scan.
*/
typedef struct sony_integ_dvbt2_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 has been locked and one of the tuneParam structures
contain the channel information.
*/
sony_result_t tuneResult;
/**
@brief The tune params for a located DVB-T2 channel.
*/
sony_dvbt2_tune_param_t dvbt2TuneParam;
}sony_integ_dvbt2_scan_result_t;
/*------------------------------------------------------------------------------
Function Pointers
------------------------------------------------------------------------------*/
/**
@brief Callback function that is called for every attempted frequency during a scan.
For successful channel results the function is called after
demodulator lock but before TS lock is achieved (DVB-T2 : Demod Lock).
NOTE: for DVB-T2 this function is invoked for each PLP within the signal.
@param pInteg The driver instance.
@param pResult The current scan result.
@param pScanParam The current scan parameters.
*/
typedef void (*sony_integ_dvbt2_scan_callback_t) (sony_integ_t * pInteg,
sony_integ_dvbt2_scan_result_t * pResult,
sony_integ_dvbt2_scan_param_t * pScanParam);
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Performs acquisition to a DVB-T2 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.
During a tune the device will wait for a T2 P1 symbol in order to decode the
L1 pre signaling and then begin demodulation. If the data PLP ID
(::sony_dvbt2_tune_param_t::dataPlpId) or the associated common PLP is not
found in the channel, the device will always select the first found PLP and
output the associated TS. In this case, an indicator in the
::sony_dvbt2_tune_param_t::tuneInfo will be set.
Note: If SONY_DVBT2_PROFILE_LITE is set to pTuneParam->profile,
early unlock detection time and lock waiting timeout will be longer.
@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_dvbt2_Tune(sony_integ_t * pInteg,
sony_dvbt2_tune_param_t * pTuneParam);
/**
@brief Attempts to acquire to the DVB-T2 channel at the center frequency provided.
This function blocks the calling thread until the demod has locked or has
timed out. Use ::sony_integ_Cancel to cancel the operation at any time.
For TS lock please call the wait TS lock function
::sony_integ_dvbt2_WaitTSLock.
NOTE: For T2 the PLP selected will be the first found in the L1 pre signaling.
Use ::sony_demod_dvbt2_monitor_DataPLPs to obtain a full list of PLPs contained
in the T2 signal.
Note: For DVB-T2 the output selected if profile is set to ::SONY_DVBT2_PROFILE_ANY
will be determined by the first frame received.
Note: If SONY_DVBT2_PROFILE_LITE or SONY_DVBT2_PROFILE_ANY are used for profile argument,
early unlock detection time and lock waiting timeout will be longer.
@param pInteg The driver instance.
@param centerFreqKHz The center frequency of the channel to attempt acquisition on
@param bandwidth The bandwidth of the channel
@param profile The DVB-T2 profile to detect, use ::SONY_DVBT2_PROFILE_ANY to detect Base
or Lite.
@param pProfileTuned The DVB-T2 profile tuned by the blind tune.
@return SONY_RESULT_OK if tuned successfully to the channel.
*/
sony_result_t sony_integ_dvbt2_BlindTune(sony_integ_t * pInteg,
uint32_t centerFreqKHz,
sony_dtv_bandwidth_t bandwidth,
sony_dvbt2_profile_t profile,
sony_dvbt2_profile_t * pProfileTuned);
/**
@brief Performs a scan over the spectrum specified.
Perform a DVB-T2 system scan for DVB-T2 channels.
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_dvbt2_Scan(sony_integ_t * pInteg,
sony_integ_dvbt2_scan_param_t * pScanParam,
sony_integ_dvbt2_scan_callback_t callBack);
/**
@brief Collect a list of data PLPs that the demodulator has detected.
Called internally as part of each DVBT2 scan.
Collect a list of data PLPs that the demodulator has detected after a successful
DVBT2 tune acquisition. The detected data PLP IDs are stored in an array pointed
to by pPLPIds.
@param pInteg The driver instance.
@param pPLPIds Pointer to an array of at least 256 bytes in length
that can receive the list of data PLPs carried..
@param pNumPLPs The number of data PLPs detected (signlled in L1-post).
@param pMixed An indicator which indicates if the received DVBT2 system contains BASE and LITE components
@return SONY_RESULT_OK if completed successfully.
*/
sony_result_t sony_integ_dvbt2_Scan_PrepareDataPLPLoop(sony_integ_t * pInteg, uint8_t pPLPIds[], uint8_t *pNumPLPs, uint8_t *pMixed);
/**
@brief Set the device PLP operation to manual and the requested Data PLP ID.
Called internally and usually after ::sony_integ_dvbt2_Scan_PrepareDataPLPLoop
as part of each DVBT2 scan.
@param pInteg The driver instance.
@param mixed A flag to indicates the received DVBT2 system contains BASE and LITE components
@param plpId The PLD ID to set.
@param profile The DVB-T2 profile.
@return SONY_RESULT_OK if completed successfully.
*/
sony_result_t sony_integ_dvbt2_Scan_SwitchDataPLP(sony_integ_t * pInteg, uint8_t mixed, uint8_t plpId, sony_dvbt2_profile_t profile);
/**
@brief Polls the demodulator waiting for TS lock at 10ms intervals up to a profile dependent
timeout duration (DVB-T2_Base : 1.5s, DVB-T2-Lite : 2.3s).
SONY_DVBT2_PROFILE_ANY is invalid for this API.
@param pInteg The driver instance
@param profile The DVB-T2 profile (base or lite)
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_integ_dvbt2_WaitTSLock (sony_integ_t * pInteg, sony_dvbt2_profile_t profile);
/**
@brief RF level monitor function.
This function returns the estimated RF level based on either the demodulator IFAGC
level or a tuner internal RSSI monitor. If any compensation for external hardware
such as, LNA, attenuators is required, then the user should make adjustment in the
corresponding function.
@param pInteg The driver instance
@param pRFLeveldB The RF Level estimation in dB * 1000
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_integ_dvbt2_monitor_RFLevel (sony_integ_t * pInteg, int32_t * pRFLeveldB);
/**
@brief DVB-T2 monitor for SSI (Signal Strength Indicator), based on the RF Level monitor value
::sony_integ_dvbt_t2_monitor_RFLevel.
@note The RF Level monitor function should be optimised for your HW configuration before using
this monitor.
@param pInteg The driver instance
@param pSSI The Signal Strength Indicator value in %
@return SONY_RESULT_OK if successful
*/
sony_result_t sony_integ_dvbt2_monitor_SSI (sony_integ_t * pInteg, uint8_t * pSSI);
#endif /* SONY_INTEG_DVBT2_H */
+336
View File
@@ -0,0 +1,336 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/08/30
Modification ID : 902dae58eb5249e028ccc5d7f60bb66cca9b43a9
------------------------------------------------------------------------------*/
#include "sony_integ.h"
#include "sony_integ_dvbt_t2.h"
#include "sony_demod.h"
#include "sony_demod_dvbt_monitor.h"
#include "sony_demod_dvbt2_monitor.h"
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
sony_result_t sony_integ_dvbt_t2_Scan(sony_integ_t * pInteg,
sony_integ_dvbt_t2_scan_param_t * pScanParam,
sony_integ_dvbt_t2_scan_callback_t callBack)
{
sony_result_t result = SONY_RESULT_OK;
sony_integ_dvbt_t2_scan_result_t scanResult;
SONY_TRACE_ENTER ("sony_integ_dvbt_t2_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);
}
if (pScanParam->stepFrequencyKHz == 0) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Check bandwidth validity */
if ((pScanParam->bandwidth != SONY_DTV_BW_1_7_MHZ) && (pScanParam->bandwidth != SONY_DTV_BW_5_MHZ) &&
(pScanParam->bandwidth != SONY_DTV_BW_6_MHZ) && (pScanParam->bandwidth != SONY_DTV_BW_7_MHZ) &&
(pScanParam->bandwidth != SONY_DTV_BW_8_MHZ)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
}
/* Check for invalid combination of 1.7MHz scanning with DVB-T/ANY. */
if ((pScanParam->system != SONY_DTV_SYSTEM_DVBT2) && (pScanParam->bandwidth == SONY_DTV_BW_1_7_MHZ)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
}
/* Set the start frequency */
scanResult.centerFreqKHz = pScanParam->startFrequencyKHz;
scanResult.tuneResult = SONY_RESULT_OK;
scanResult.system = SONY_DTV_SYSTEM_DVBT;
scanResult.dvbtTuneParam.centerFreqKHz = pScanParam->startFrequencyKHz;
scanResult.dvbtTuneParam.bandwidth = pScanParam->bandwidth;
scanResult.dvbtTuneParam.profile = SONY_DVBT_PROFILE_HP;
scanResult.dvbt2TuneParam.centerFreqKHz = pScanParam->startFrequencyKHz;
scanResult.dvbt2TuneParam.bandwidth = pScanParam->bandwidth;
scanResult.dvbt2TuneParam.dataPlpId = 0;
scanResult.dvbt2TuneParam.profile = SONY_DVBT2_PROFILE_BASE;
scanResult.dvbt2TuneParam.tuneInfo = SONY_DEMOD_DVBT2_TUNE_INFO_OK;
/* Set scan mode enabled */
result = sony_demod_terr_cable_SetScanMode(pInteg->pDemod, pScanParam->system, 0x01);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
/* Scan routine */
while (scanResult.centerFreqKHz <= pScanParam->endFrequencyKHz) {
sony_dtv_system_t systemFound = SONY_DTV_SYSTEM_UNKNOWN;
sony_dvbt2_profile_t profileFound = SONY_DVBT2_PROFILE_ANY;
uint8_t channelComplete = 0;
sony_dtv_system_t blindTuneSystem = pScanParam->system;
sony_dvbt2_profile_t blindTuneProfile = pScanParam->t2Profile;
scanResult.dvbtTuneParam.centerFreqKHz = scanResult.centerFreqKHz;
scanResult.dvbt2TuneParam.centerFreqKHz = scanResult.centerFreqKHz;
while (!channelComplete) {
scanResult.tuneResult = sony_integ_dvbt_t2_BlindTune(pInteg, scanResult.centerFreqKHz, pScanParam->bandwidth, blindTuneSystem, blindTuneProfile, &systemFound, &profileFound);
switch (scanResult.tuneResult) {
case SONY_RESULT_OK:
scanResult.system = systemFound;
/* Channel found, callback to application */
if (systemFound == SONY_DTV_SYSTEM_DVBT){
callBack (pInteg, &scanResult, pScanParam);
/* DVB-T detected, set channel complete to move to next frequency */
channelComplete = 1;
}
else if (systemFound == SONY_DTV_SYSTEM_DVBT2) {
uint8_t numPLPs = 0;
uint8_t plpIds[255];
uint8_t mixed;
uint8_t i;
scanResult.dvbt2TuneParam.profile = profileFound;
result = sony_integ_dvbt2_Scan_PrepareDataPLPLoop(pInteg, plpIds, &numPLPs, &mixed);
if (result == SONY_RESULT_ERROR_HW_STATE) {
/* Callback to application for progress updates */
scanResult.system = SONY_DTV_SYSTEM_UNKNOWN;
scanResult.tuneResult = SONY_RESULT_ERROR_UNLOCK;
callBack (pInteg, &scanResult, pScanParam);
/* Error in monitored data, ignore current channel */
channelComplete = 1;
}
else if (result != SONY_RESULT_OK) {
/* Serious error occurred -> cancel operation. */
sony_demod_terr_cable_SetScanMode(pInteg->pDemod, pScanParam->system, 0x00);
SONY_TRACE_RETURN (result);
}
else {
/* Set PLP ID in tune parameter structure and provide callback for first PLP */
scanResult.dvbt2TuneParam.dataPlpId = plpIds[0];
callBack (pInteg, &scanResult, pScanParam);
/* Callback for each subsequent PLP in current profile */
for (i = 1; i < numPLPs; i++) {
result = sony_integ_dvbt2_Scan_SwitchDataPLP(pInteg, mixed, plpIds[i], profileFound);
if (result != SONY_RESULT_OK) {
sony_demod_terr_cable_SetScanMode(pInteg->pDemod, pScanParam->system, 0x00);
SONY_TRACE_RETURN (result);
}
/* Set PLP ID in tune parameter structure and provide callback */
scanResult.dvbt2TuneParam.dataPlpId = plpIds[i];
callBack (pInteg, &scanResult, pScanParam);
}
/* If profile is ANY, check for mixed profile channels */
if (blindTuneProfile == SONY_DVBT2_PROFILE_ANY) {
/* Check for mixed profiles available */
if (mixed) {
/* Set Blind Tune parameters to DVB-T2 only and the other profile
* compared to that already located */
blindTuneSystem = SONY_DTV_SYSTEM_DVBT2;
if (profileFound == SONY_DVBT2_PROFILE_BASE) {
blindTuneProfile = SONY_DVBT2_PROFILE_LITE;
}
else if (profileFound == SONY_DVBT2_PROFILE_LITE) {
blindTuneProfile = SONY_DVBT2_PROFILE_BASE;
}
else {
/* Serious error occurred -> cancel operation. */
sony_demod_terr_cable_SetScanMode(pInteg->pDemod, pScanParam->system, 0x00);
SONY_TRACE_RETURN (result);
}
}
else {
/* Channel is not mixed profile so continue to next frequency */
channelComplete = 1;
}
}
else {
/* Profile is fixed therefore this frequency is complete */
channelComplete = 1;
}
}
}
break;
/* Intentional fall-through. */
case SONY_RESULT_ERROR_UNLOCK:
case SONY_RESULT_ERROR_TIMEOUT:
/* Channel not found, callback to application for progress updates */
scanResult.system = SONY_DTV_SYSTEM_UNKNOWN;
callBack (pInteg, &scanResult, pScanParam);
/* Go to next frequency */
channelComplete = 1;
break;
default:
{
/* Serious error occurred -> cancel operation. */
sony_demod_terr_cable_SetScanMode(pInteg->pDemod, pScanParam->system, 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, pScanParam->system, 0x00);
SONY_TRACE_RETURN (result);
}
}
/* Clear scan mode */
result = sony_demod_terr_cable_SetScanMode(pInteg->pDemod, pScanParam->system, 0x00);
SONY_TRACE_RETURN (result);
}
sony_result_t sony_integ_dvbt_t2_BlindTune(sony_integ_t * pInteg,
uint32_t centerFreqKHz,
sony_dtv_bandwidth_t bandwidth,
sony_dtv_system_t system,
sony_dvbt2_profile_t profile,
sony_dtv_system_t * pSystemTuned,
sony_dvbt2_profile_t * pProfileTuned)
{
sony_result_t result = SONY_RESULT_OK;
uint8_t channelFound = 0;
sony_dtv_system_t tuneSystems[2] = {SONY_DTV_SYSTEM_UNKNOWN , SONY_DTV_SYSTEM_UNKNOWN};
uint8_t tuneIteration;
SONY_TRACE_ENTER ("sony_integ_dvbt_t2_BlindTune");
if ((!pInteg) || (!pInteg->pDemod) || (!pSystemTuned) || (!pProfileTuned)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Confirm the demod is in a valid state to accept this API */
if ((pInteg->pDemod->state != SONY_DEMOD_STATE_SLEEP) && (pInteg->pDemod->state != SONY_DEMOD_STATE_ACTIVE)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Check bandwidth validity */
if ((bandwidth != SONY_DTV_BW_1_7_MHZ) && (bandwidth != SONY_DTV_BW_5_MHZ) &&
(bandwidth != SONY_DTV_BW_6_MHZ) && (bandwidth != SONY_DTV_BW_7_MHZ) &&
(bandwidth != SONY_DTV_BW_8_MHZ)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
}
/* Check for invalid system parameter */
if ((system != SONY_DTV_SYSTEM_DVBT) && (system != SONY_DTV_SYSTEM_DVBT2) && (system != SONY_DTV_SYSTEM_ANY)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
}
/* Check for invalid combination of 1.7MHz tune */
if ((system != SONY_DTV_SYSTEM_DVBT2) && (bandwidth == SONY_DTV_BW_1_7_MHZ)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_NOSUPPORT);
}
if (system == SONY_DTV_SYSTEM_ANY) {
tuneSystems[0] = pInteg->pDemod->blindTuneDvbt2First? SONY_DTV_SYSTEM_DVBT2 : SONY_DTV_SYSTEM_DVBT;
tuneSystems[1] = pInteg->pDemod->blindTuneDvbt2First? SONY_DTV_SYSTEM_DVBT : SONY_DTV_SYSTEM_DVBT2;
}
else {
tuneSystems[0] = system;
}
for (tuneIteration = 0; tuneIteration <=1; tuneIteration++) {
#ifdef SAME_TUNER_CONFIG_DVBT_T2
/* If SAME_TUNER_CONFIG_DVBT_T2 is defined the driver assumes
that the tuner configuration used for DVBT tuning is identical to
DVBT2, therefore the tuner does not need to be reconfigured. This will
help to reduce blindtune and therefore scan duration. This is only
valid if SONY_DTV_SYSTEM_ANY is used. */
/* Function pointer variable to store the pInteg->pTuner->TerrCableTune pointer temporary */
sony_result_t (*SavedTuneFunc) (struct sony_tuner_t *, uint32_t,
sony_dtv_system_t, sony_dtv_bandwidth_t) = NULL;
if (tuneIteration == 1)
{
SavedTuneFunc = pInteg->pTuner->TerrCableTune;
/* Set to NULL to signal sony_integ_dvbt_BlindTune or sony_integ_dvbt2_BlindTune
to use the same tuner configuration. */
pInteg->pTuner->TerrCableTune = NULL;
}
#endif
/* Attempt DVB-T acquisition */
if ((tuneSystems[tuneIteration] == SONY_DTV_SYSTEM_DVBT) && (!channelFound)) {
result = sony_integ_dvbt_BlindTune(pInteg, centerFreqKHz, bandwidth);
if (result == SONY_RESULT_OK) {
*pSystemTuned = SONY_DTV_SYSTEM_DVBT;
channelFound = 1;
}
}
/* Attempt DVB-T2 acquisition */
if ((tuneSystems[tuneIteration] == SONY_DTV_SYSTEM_DVBT2) && (!channelFound)) {
result = sony_integ_dvbt2_BlindTune(pInteg, centerFreqKHz, bandwidth, profile, pProfileTuned);
if (result == SONY_RESULT_OK) {
*pSystemTuned = SONY_DTV_SYSTEM_DVBT2;
channelFound = 1;
}
}
#ifdef SAME_TUNER_CONFIG_DVBT_T2
/* If SAME_TUNER_CONFIG_DVBT_T2 is defined
Restore Tune function pointer, if conditions are true.
*/
if ((tuneIteration == 1) && (SavedTuneFunc))
{
pInteg->pTuner->TerrCableTune = SavedTuneFunc;
}
#endif
}
SONY_TRACE_RETURN (result);
}
sony_result_t sony_integ_dvbt_t2_monitor_RFLevel (sony_integ_t * pInteg, int32_t * pRFLeveldB)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_integ_dvbt_t2_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_DVBT) {
result = sony_integ_dvbt_monitor_RFLevel (pInteg, pRFLeveldB);
}
else if (pInteg->pDemod->system == SONY_DTV_SYSTEM_DVBT2) {
result = sony_integ_dvbt2_monitor_RFLevel (pInteg, pRFLeveldB);
}
else {
/* Not DVB-T or DVB-T2*/
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
SONY_TRACE_RETURN (result);
}
+209
View File
@@ -0,0 +1,209 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/07/27
Modification ID : ff73ffebff57618d6a5aa6e2aa9eb009b86060d1
------------------------------------------------------------------------------*/
/**
@file sony_integ_dvbt_t2.h
This file provides the integration layer interface for DVB-T and DVB-T2
specific demodulator functions.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_INTEG_DVBT_T2_H
#define SONY_INTEG_DVBT_T2_H
#include "sony_demod.h"
#include "sony_integ.h"
#include "sony_integ_dvbt.h"
#include "sony_integ_dvbt2.h"
#include "sony_demod_dvbt.h"
#include "sony_demod_dvbt2.h"
/*------------------------------------------------------------------------------
Defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief The parameters used for DVB-T and DVB-T2 scanning.
*/
typedef struct sony_integ_dvbt_t2_scan_param_t{
/**
@brief The start frequency in kHz for scanning. Ensure that this is
aligned with the channel raster.
*/
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;
/**
@brief The system to attempt to blind tune to at each step. Use
::SONY_DTV_SYSTEM_ANY to run a multiple system scan (DVB-T and
DVB-T2).
*/
sony_dtv_system_t system;
/**
@brief The DVB-T2 profile to use for the blind tune. Use
::SONY_DVBT2_PROFILE_ANY for mixed or Base and Lite spectrums.
*/
sony_dvbt2_profile_t t2Profile;
}sony_integ_dvbt_t2_scan_param_t;
/**
@brief The structure used to return a channel located or progress update
as part of a DVB-T / DVB-T2 or combined scan.
*/
typedef struct sony_integ_dvbt_t2_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 has been locked and one of the tuneParam structures
contain the channel information.
*/
sony_result_t tuneResult;
/**
@brief The system of the channel detected by the scan. This should be used to determine
which of the following tune param structs are valid.
*/
sony_dtv_system_t system;
/**
@brief The tune params for a located DVB-T channel.
*/
sony_dvbt_tune_param_t dvbtTuneParam;
/**
@brief The tune params for a located DVB-T2 channel.
*/
sony_dvbt2_tune_param_t dvbt2TuneParam;
}sony_integ_dvbt_t2_scan_result_t;
/*------------------------------------------------------------------------------
Function Pointers
------------------------------------------------------------------------------*/
/**
@brief Callback function that is called for every attempted frequency during a scan.
For successful channel results the function is called after
demodulator lock but before TS lock is achieved (DVB-T : TPS Lock,
DVB-T2 : Demod Lock).
NOTE: for DVB-T2 this function is invoked for each PLP within the signal.
@param pInteg The driver instance.
@param pResult The current scan result.
@param pScanParam The current scan parameters.
*/
typedef void (*sony_integ_dvbt_t2_scan_callback_t) (sony_integ_t * pInteg,
sony_integ_dvbt_t2_scan_result_t * pResult,
sony_integ_dvbt_t2_scan_param_t * pScanParam);
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Attempts to acquire to the channel at the center frequency provided.
The system can be specified directly or set to ::SONY_DTV_SYSTEM_ANY to allow
tuning to DVB-T or DVB-T2 for unknown cases.
This function blocks the calling thread until the demod has locked or has
timed out. Use ::sony_integ_Cancel to cancel the operation at any time.
For TS lock please call the wait TS lock function
::sony_integ_dvbt_WaitTSLock or ::sony_integ_dvbt2_WaitTSLock.
NOTE: For T2 the PLP selected will be the first found in the L1 pre signaling.
Use ::sony_demod_dvbt2_monitor_DataPLPs to obtain a full list of PLPs contained
in the T2 signal.
Note: For DVB-T2 the output selected if profile is set to ::SONY_DVBT2_PROFILE_ANY
will be determined by the first frame received.
Note: If SONY_DVBT2_PROFILE_LITE or SONY_DVBT2_PROFILE_ANY are used for profile argument,
DVB-T2 early unlock detection time and lock waiting timeout will be longer.
@param pInteg The driver instance.
@param centerFreqKHz The center frequency of the channel to attempt acquisition on
@param bandwidth The bandwidth of the channel
@param system The system to attempt to tune to, use ::SONY_DTV_SYSTEM_ANY to attempt
both DVB-T and DVB-T2
@param profile The DVB-T2 profile to detect, use ::SONY_DVBT2_PROFILE_ANY to detect Base
or Lite.
@param pSystemTuned The system of the channel located by the blind tune.
@param pProfileTuned The DVB-T2 profile tuned by the blind tune.
@return SONY_RESULT_OK if tuned successfully to the channel.
*/
sony_result_t sony_integ_dvbt_t2_BlindTune(sony_integ_t * pInteg,
uint32_t centerFreqKHz,
sony_dtv_bandwidth_t bandwidth,
sony_dtv_system_t system,
sony_dvbt2_profile_t profile,
sony_dtv_system_t * pSystemTuned,
sony_dvbt2_profile_t * pProfileTuned);
/**
@brief Performs a scan over the spectrum specified.
The scan can perform a multiple system scan for DVB-T and DVB-T2 channels by
setting the ::sony_integ_dvbt_t2_scan_param_t::system to ::SONY_DTV_SYSTEM_ANY
and setting the.
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_dvbt_t2_Scan(sony_integ_t * pInteg,
sony_integ_dvbt_t2_scan_param_t * pScanParam,
sony_integ_dvbt_t2_scan_callback_t callBack);
/**
@brief RF level monitor function.
This function returns the estimated RF level based on either the demodulator IFAGC
level or a tuner internal RSSI monitor. If any compensation for external hardware
such as, LNA, attenuators is required, then the user should make adjustment in the
corresponding function.
@param pInteg The driver instance
@param pRFLeveldB The RF Level estimation in dB * 1000
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_integ_dvbt_t2_monitor_RFLevel (sony_integ_t * pInteg, int32_t * pRFLeveldB);
#endif /* SONY_INTEG_DVBT_T2_H */
+703
View File
@@ -0,0 +1,703 @@
/*------------------------------------------------------------------------------
Copyright 2016-2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/08/30
Modification ID : 902dae58eb5249e028ccc5d7f60bb66cca9b43a9
------------------------------------------------------------------------------*/
#include "sony_demod_isdbc.h"
#include "sony_demod_isdbc_monitor.h"
#ifdef SONY_DEMOD_SUPPORT_ISDBC_CHBOND
#include "sony_demod_isdbc_chbond.h"
#endif
/*------------------------------------------------------------------------------
Static Function Prototypes
------------------------------------------------------------------------------*/
/**
@brief Set TSMF output format, TSID(Relative TS number) and network ID
*/
static sony_result_t SetTSMFSetting (sony_demod_t * pDemod,
sony_demod_isdbc_tsmf_mode_t tsmfMode,
sony_isdbc_tsid_type_t tsidType,
uint16_t tsid,
uint16_t networkId);
/**
@brief Configure the demodulator from Sleep to Active for ISDB-C
*/
static sony_result_t SLtoAIC (sony_demod_t * pDemod);
/**
@brief Configure the demodulator from Active ISDB-C to Active to ISDB-C. Used
for changing channel parameters.
*/
static sony_result_t AICtoAIC (sony_demod_t * pDemod);
/**
@brief Configure the demodulator from Active ISDB-C to Sleep.
*/
static sony_result_t AICtoSL (sony_demod_t * pDemod);
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
sony_result_t sony_demod_isdbc_Tune (sony_demod_t * pDemod, sony_isdbc_tune_param_t * pTuneParam)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_demod_isdbc_Tune");
if ((!pDemod) || (!pTuneParam)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if ((pDemod->state == SONY_DEMOD_STATE_ACTIVE) && (pDemod->system == SONY_DTV_SYSTEM_ISDBC)) {
pDemod->bandwidth = SONY_DTV_BW_6_MHZ;
/* Demodulator Active and set to ISDB-C mode */
result = SetTSMFSetting(pDemod, pTuneParam->tsmfMode, pTuneParam->tsidType, pTuneParam->tsid, pTuneParam->networkId);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
result = AICtoAIC (pDemod);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
}
else if((pDemod->state == SONY_DEMOD_STATE_ACTIVE) && (pDemod->system != SONY_DTV_SYSTEM_ISDBC)){
/* Demodulator Active but not ISDB-C mode */
result = sony_demod_Sleep (pDemod);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
pDemod->system = SONY_DTV_SYSTEM_ISDBC;
pDemod->bandwidth = SONY_DTV_BW_6_MHZ;
result = SetTSMFSetting(pDemod, pTuneParam->tsmfMode, pTuneParam->tsidType, pTuneParam->tsid, pTuneParam->networkId);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
result = SLtoAIC (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_ISDBC;
pDemod->bandwidth = SONY_DTV_BW_6_MHZ;
result = SetTSMFSetting(pDemod, pTuneParam->tsmfMode, pTuneParam->tsidType, pTuneParam->tsid, pTuneParam->networkId);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
result = SLtoAIC (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_isdbc_Sleep (sony_demod_t * pDemod)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("sony_demod_isdbc_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 = AICtoSL (pDemod);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
SONY_TRACE_RETURN (result);
}
sony_result_t sony_demod_isdbc_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_isdbc_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_isdbc_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 SetTSMFSetting (sony_demod_t * pDemod,
sony_demod_isdbc_tsmf_mode_t tsmfMode,
sony_isdbc_tsid_type_t tsidType,
uint16_t tsid,
uint16_t networkId)
{
uint8_t mode = 0;
uint8_t data[4];
SONY_TRACE_ENTER ("SetTSMFSetting");
if (!pDemod) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if ((tsidType == SONY_ISDBC_TSID_TYPE_RELATIVE_TS_NUMBER) && (tsid > 0x0F || tsid == 0)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Set SLV-T Bank : 0x49 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x49) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* TSMF mode setting
*
* slave Bank Addr Bit default Value Name
* ----------------------------------------------------------------------------------
* <SLV-T> 49h 36h [4:1] 8'h13 8'h13 OREG_TSMF_MODE[1:0],OREG_TSMF_HEADER_PID_CHG_DISABLE,OREG_TSMF_VALID_TSMF_CTRL
*
* OREG_TSMF_MODE[1:0] : 0:Single TS mode,1:Multiple TS mode,2:Auto-detect
*/
mode = ((uint8_t)tsmfMode) << 3;
if (sony_i2c_SetRegisterBits (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x36, mode, 0x18) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (tsidType == SONY_ISDBC_TSID_TYPE_TSID) {
/*
* slave Bank Addr Bit default Value Name
* ----------------------------------------------------------------------------------
* <SLV-T> 49h 37h [4:0] 8'h10 8'h00 OREG_TSMF_RELATIVE_TS_NUM_ON,OREG_TSMF_RELATIVE_TS_NUM[3:0]
* <SLV-T> 49h 32h [7:0] 8'h00 8'hxx OREG_TSMF_TS_ID[15:8]
* <SLV-T> 49h 33h [7:0] 8'h00 8'hxx OREG_TSMF_TS_ID[7:0]
* <SLV-T> 49h 34h [7:0] 8'h00 8'hxx OREG_TSMF_ORIG_NETWORK_ID[15:8]
* <SLV-T> 49h 35h [7:0] 8'h00 8'hxx OREG_TSMF_ORIG_NETWORK_ID[7:0]
*
* OREG_TSMF_TS_ID[15:0] : the TS ID of the desired TS
* OREG_TSMF_ORIG_NETWORK_ID[15:0] : the Original network ID of the desired TS
*/
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x37, 0x00) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
data[0] = (uint8_t)((tsid >> 8) & 0xFF);
data[1] = (uint8_t)(tsid & 0xFF);
data[2] = (uint8_t)((networkId >> 8) & 0xFF);
data[3] = (uint8_t)(networkId & 0xFF);
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x32, data, 4) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
} else {
/*
* slave Bank Addr Bit default Value Name
* ----------------------------------------------------------------------------------
* <SLV-T> 49h 37h [4:0] 8'h10 8'h1x OREG_TSMF_RELATIVE_TS_NUM_ON,OREG_TSMF_RELATIVE_TS_NUM[3:0]
*
* OREG_TSMF_RELATIVE_TS_NUM[3:0] : the Relative TS number(1~15) of the desired TS
*/
data[0] = 0x10 | (uint8_t)(tsid & 0x0F);
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x37, data[0]) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
static sony_result_t SLtoAIC (sony_demod_t * pDemod)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("SLtoAIC");
if (!pDemod) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
#ifdef SONY_DEMOD_SUPPORT_ISDBC_CHBOND
if (pDemod->chbondConfig == SONY_DEMOD_CHBOND_CONFIG_ISDBC) {
result = sony_demod_isdbc_chbond_Enable (pDemod, 1);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
if ((pDemod->isdbcChBondOutput == SONY_DEMOD_OUTPUT_ISDBC_CHBOND_TS) || (pDemod->isdbcChBondOutput == SONY_DEMOD_OUTPUT_ISDBC_CHBOND_TS_TLV_AUTO)) {
/* Configure TS clock Mode and Frequency */
result = sony_demod_SetTSClockModeAndFreq (pDemod, SONY_DTV_SYSTEM_ISDBC);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
}
#ifdef SONY_DEMOD_SUPPORT_TLV
if ((pDemod->isdbcChBondOutput == SONY_DEMOD_OUTPUT_ISDBC_CHBOND_TLV) || (pDemod->isdbcChBondOutput == SONY_DEMOD_OUTPUT_ISDBC_CHBOND_TS_TLV_AUTO)) {
/* Configure TLV clock Mode and Frequency. */
result = sony_demod_SetTLVClockModeAndFreq (pDemod, SONY_DTV_SYSTEM_ISDBC);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
}
#endif
} else
#endif
{
/* Configure TS clock Mode and Frequency */
result = sony_demod_SetTSClockModeAndFreq (pDemod, SONY_DTV_SYSTEM_ISDBC);
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, 0x09) != 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 */
{
uint8_t data = 0;
if ((pDemod->chbondConfig == SONY_DEMOD_CHBOND_CONFIG_ISDBC) && (pDemod->isdbcChBondOutput == SONY_DEMOD_OUTPUT_ISDBC_CHBOND_TLV)) {
data = 0x01;
} else {
data = 0x00;
}
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xA9, data) != 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);
}
{
/* ISDB-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);
}
/* ISDB-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 SLV-T Bank : 0x10 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x10) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set tuner and bandwidth specific settings */
/*
* 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.configISDBC_6 >> 16) & 0xFF);
data[1] = (uint8_t) ((pDemod->iffreqConfig.configISDBC_6 >> 8) & 0xFF);
data[2] = (uint8_t) (pDemod->iffreqConfig.configISDBC_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 14h [4:0] 8'h1F 8'14 OREG_QAM_ENABLE[4:0]
* <SLV-T> 40h 1Eh [7] 8'h00 8'h80 OREG_DISCRETE_SEARCH
* <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, 0x08, 0x07, 0x08
};
/* 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->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x14, 0x14) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x1E, 0x80) != 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);
}
}
/* 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 AICtoAIC(sony_demod_t * pDemod)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("AICtoAIC");
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);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
static sony_result_t AICtoSL(sony_demod_t * pDemod)
{
sony_result_t result = SONY_RESULT_OK;
SONY_TRACE_ENTER ("AICtoSL");
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 ISDB-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
* <SLV-T> 40h 14h [4:0] 8'h1F 8'h1F OREG_QAM_ENABLE[4:0]
* <SLV-T> 40h 1Eh [7] 8'h00 8'h00 OREG_DISCRETE_SEARCH
*/
/* 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-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->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x14, 0x1F) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x1E, 0x00) != 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);
}
#ifdef SONY_DEMOD_SUPPORT_ISDBC_CHBOND
if (pDemod->chbondConfig == SONY_DEMOD_CHBOND_CONFIG_ISDBC) {
result = sony_demod_isdbc_chbond_Enable (pDemod, 0);
if (result != SONY_RESULT_OK) {
SONY_TRACE_RETURN (result);
}
}
#endif
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
+106
View File
@@ -0,0 +1,106 @@
/*------------------------------------------------------------------------------
Copyright 2016 Sony Semiconductor Solutions Corporation
Last Updated : 2016/08/01
Modification ID : b30d76210d343216ea52b88e9b450c8fd5c0359f
------------------------------------------------------------------------------*/
/**
@file sony_demod_isdbc.h
This file provides the demodulator control interface specific to ISDB-C.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_ISDBC_H
#define SONY_DEMOD_ISDBC_H
#include "../sony_common.h"
#include "../sony_demod.h"
#include "sony_isdbc.h"
/*------------------------------------------------------------------------------
Enumerations
------------------------------------------------------------------------------*/
/**
@brief TSMF output format.
*/
typedef enum {
/**
@brief Treat the input stream as not containing multiple TS. Pass through mode.
*/
SONY_DEMOD_ISDBC_TSMF_MODE_SINGLE,
/**
@brief Treat the input stream as containing multiple TS. Output slot of the
selected ID, other slots will be replaced to NULL.
*/
SONY_DEMOD_ISDBC_TSMF_MODE_MULTIPLE,
/**
@brief Automatically select between the single mode and multiple mode.
After meeting the following two conditions once, output format will be change
Multiple mdoe.
- TSMF header synchronization is locked.
- CRC check is OK
*/
SONY_DEMOD_ISDBC_TSMF_MODE_AUTO
} sony_demod_isdbc_tsmf_mode_t;
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief The tune parameters for a ISDB-C signal
*/
typedef struct sony_isdbc_tune_param_t {
uint32_t centerFreqKHz; /**< Center frequency in kHz of the ISDB-C channel */
sony_demod_isdbc_tsmf_mode_t tsmfMode; /**< TSMF output format */
/**
@brief This parameter is used to tsId indicates whether TSID or relative TS number.
If Relative TS number is selected networkId will be ignored.
*/
sony_isdbc_tsid_type_t tsidType;
uint16_t tsid; /**< TSID */
uint16_t networkId; /**< Network ID */
} sony_isdbc_tune_param_t;
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Enable acquisition on the demodulator for ISDB-C channels. Called from
the integration layer ::sony_integ_isdbc_Tune API.
@param pDemod The demodulator instance
@param pTuneParam The tune parameters.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_isdbc_Tune (sony_demod_t * pDemod, sony_isdbc_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_isdbc_Sleep (sony_demod_t * pDemod);
/**
@brief Check ISDB-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_isdbc_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_isdbc_CheckTSLock (sony_demod_t * pDemod,
sony_demod_lock_result_t * pLock);
#endif /* SONY_DEMOD_ISDBC_H */
+794
View File
@@ -0,0 +1,794 @@
/*------------------------------------------------------------------------------
Copyright 2018-2019 Sony Semiconductor Solutions Corporation
Last Updated : 2019/10/04
Modification ID : ae1245fdaf66401838902e7214d8494b0f5e5a76
------------------------------------------------------------------------------*/
#include <string.h>
#include <stdlib.h>
#include "sony_demod_isdbc_chbond.h"
#include "sony_demod_isdbc_monitor.h"
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
sony_result_t sony_demod_isdbc_chbond_Enable (sony_demod_t * pDemod,
uint8_t enable)
{
uint8_t enableStreamIn = 0;
SONY_TRACE_ENTER ("sony_demod_isdbc_chbond_Enable");
if (!pDemod) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Set SLV-X Bank : 0x00 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0x00, 0x00) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/*
* slave Bank Addr Bit default Value Name
* --------------------------------------------------------------------------------
* <SLV-X> 00h C1h [2:0] 8'h00 8'h0x OREG_STREAMIN_EN
*
* Bit[0]: Stream input0 Bit[1]: Stream input1 Bit[2]: Stream input2
* 1: Stream input enble 0:Stream input disable
*/
if (enable) {
enableStreamIn = pDemod->chbondStreamIn;
}
/* Set Stream Input */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVX, 0xC1, enableStreamIn) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* Set SLV-T Bank : 0x03 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x03) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (enable) {
uint8_t data[2] = {0x01, 0x09};
/* Channel Bonding initial setting */
/* slave Bank Addr Bit default Value Name
* ----------------------------------------------------------------------------------
* <SLV-T> 03h 17h [0] 8'h00 8'h01 OREG_SEL_FRAMEVALID
* <SLV-T> 03h 18h [3] 8'h01 8'h09 OREG_IGNORE_STREAMTYPE
*/
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x17, data, 2) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
}
/* Bonding mode setting */
/*
* slave Bank Addr Bit default Value Name meaning
* --------------------------------------------------------------------------------
* <SLV-T> 03h b1h [0] 8'h00 8'h0x OREG_XCHBOND_ON 0: Channel Bonding Off 1: Channel Bonding On
*/
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xB1, enable) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* TLV output setting (CXD2878 family)
* slave Bank Addr Bit default Value Name
* ---------------------------------------------------------------------------------
* <SLV-T> 01h E8h [0] 8'h00 8'h01 OTLV_WFMT_TIMER_OFF
*/
/* Set SLV-T Bank : 0x01 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x01) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xE8, 0x01) != SONY_RESULT_OK){
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_isdbc_chbond_SetTSMFConfig (sony_demod_t * pDemod,
sony_isdbc_tsid_type_t tsidType,
uint16_t tsid,
uint16_t networkId)
{
uint8_t data[4];
SONY_TRACE_ENTER ("sony_demod_isdbc_chbond_SetTSMFConfig");
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);
}
if (pDemod->chbondConfig != SONY_DEMOD_CHBOND_CONFIG_ISDBC) {
/* For ISDB-C channel bonding only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
if ((tsidType == SONY_ISDBC_TSID_TYPE_RELATIVE_TS_NUMBER) && (tsid > 0x0F || tsid == 0)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
/* Set SLV-T Bank : 0x03 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x03) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (tsidType == SONY_ISDBC_TSID_TYPE_TSID) {
/*
* slave Bank Addr Bit default Value Name
* ----------------------------------------------------------------------------------
* <SLV-T> 03h 10h [7:0] 8'h00 8'hxx OREG_TSMF_TS_ID[15:8]
* <SLV-T> 03h 11h [7:0] 8'h00 8'hxx OREG_TSMF_TS_ID[7:0]
* <SLV-T> 03h 12h [7:0] 8'h00 8'hxx OREG_TSMF_ORIG_NETWORK_ID[15:8]
* <SLV-T> 03h 13h [7:0] 8'h00 8'hxx OREG_TSMF_ORIG_NETWORK_ID[7:0]
*
* OREG_TSMF_TS_ID[15:0] : the TS ID of the desired TS
* OREG_TSMF_ORIG_NETWORK_ID[15:0] : the Original network ID of the desired TS
*/
data[0] = (uint8_t)((tsid >> 8) & 0xFF);
data[1] = (uint8_t)(tsid & 0xFF);
data[2] = (uint8_t)((networkId >> 8) & 0xFF);
data[3] = (uint8_t)(networkId & 0xFF);
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x10, data, 4) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/*
* slave Bank Addr Bit default Value Name
* ----------------------------------------------------------------------------------
* <SLV-T> 03h 3fh [4:0] 8'h00 8'h00 OREG_TSMF_RELATIVE_TS_NUM_ON0,OREG_TSMF_RELATIVE_TS_NUM0[3:0] from Ext0
* <SLV-T> 03h 56h [4:0] 8'h00 8'h00 OREG_TSMF_RELATIVE_TS_NUM_ON1,OREG_TSMF_RELATIVE_TS_NUM1[3:0] from Ext1
* <SLV-T> 03h 57h [4:0] 8'h00 8'h00 OREG_TSMF_RELATIVE_TS_NUM_ON2,OREG_TSMF_RELATIVE_TS_NUM2[3:0] from Ext2
* <SLV-T> 03h 58h [4:0] 8'h00 8'h00 OREG_TSMF_RELATIVE_TS_NUM_ON3,OREG_TSMF_RELATIVE_TS_NUM3[3:0] from internal dmd
*
* OREG_TSMF_RELATIVE_TS_NUMx[3:0] : the Relative TS number(1~15) of the desired TS
* OREG_TSMF_RELATIVE_TS_NUM_ONx :
* 0: TS select by the TS ID and the original network ID,
* 1: TS select by the relative TS number
*/
data[0] = data[1] = data[2] = data[3] = 0x00;
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x3F, data[0]) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x56, &data[1], 3) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
} else {
/*
* slave Bank Addr Bit default Value Name
* ----------------------------------------------------------------------------------
* <SLV-T> 03h 3fh [4:0] 8'h00 8'h1x OREG_TSMF_RELATIVE_TS_NUM_ON0,OREG_TSMF_RELATIVE_TS_NUM0[3:0] from Ext0
* <SLV-T> 03h 56h [4:0] 8'h00 8'h1x OREG_TSMF_RELATIVE_TS_NUM_ON1,OREG_TSMF_RELATIVE_TS_NUM1[3:0] from Ext1
* <SLV-T> 03h 57h [4:0] 8'h00 8'h1x OREG_TSMF_RELATIVE_TS_NUM_ON2,OREG_TSMF_RELATIVE_TS_NUM2[3:0] from Ext2
* <SLV-T> 03h 58h [4:0] 8'h00 8'h1x OREG_TSMF_RELATIVE_TS_NUM_ON3,OREG_TSMF_RELATIVE_TS_NUM3[3:0] from internal dmd
*
* OREG_TSMF_RELATIVE_TS_NUMx[3:0] : the Relative TS number(1~15) of the desired TS
* OREG_TSMF_RELATIVE_TS_NUM_ONx :
* 0: TS select by the TS ID and the original network ID,
* 1: TS select by the relative TS number
*/
data[0] = data[1] = data[2] = data[3] = 0x10 | (uint8_t)(tsid & 0x0F);
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x3F, data[0]) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (pDemod->pI2c->WriteRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x56, &data[1], 3) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_isdbc_chbond_SoftReset (sony_demod_t * pDemod)
{
SONY_TRACE_ENTER ("sony_demod_isdbc_chbond_SoftReset");
if (!pDemod) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if ((pDemod->state != SONY_DEMOD_STATE_ACTIVE) && (pDemod->state != SONY_DEMOD_STATE_SLEEP)) {
/* This api is accepted in Sleep and Active states only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
if (pDemod->chbondConfig != SONY_DEMOD_CHBOND_CONFIG_ISDBC) {
/* For ISDB-C channel bonding only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* 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);
}
/*
* slave Bank Addr Bit default Value Name
* --------------------------------------------------------------------------------
* <SLV-T> 00h FAh [0] 8'h00 8'h01 OREG_SRST_LCHBOND
*/
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0xFA, 0x01) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_isdbc_chbond_monitor_BondStat (sony_demod_t * pDemod,
sony_demod_isdbc_chbond_state_t * pState)
{
uint8_t data;
SONY_TRACE_ENTER ("sony_demod_isdbc_chbond_monitor_BondStat");
if ((!pDemod) || (!pState)) {
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_ISDBC) || (pDemod->chbondConfig != SONY_DEMOD_CHBOND_CONFIG_ISDBC)) {
/* Not ISDB-C or channel boding is not enabled */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Set SLV-T Bank : 0x03 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x03) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/*
* slave Bank Addr Bit Name meaning
* -------------------------------------------------------------------------------------------------------------------------------
* <SLV-T> 03h 20h [6] IREG_BONDOK 0: Bonding NG 1: Bonding OK
* <SLV-T> 03h 20h [4] IREG_GROUPID_CHK 0: different values or no valid carrier 1: same values
* <SLV-T> 03h 20h [3] IREG_STREAMTYPE_CHK 0: different values or no valid carrier 1: same values
* <SLV-T> 03h 20h [1] IREG_NUMCARRIERS_CHK 0: different values or no valid carrier 1: same values
* <SLV-T> 03h 20h [0] IREG_CARRSEQ_CHK 0: duplication or no valid carrier 1: no duplication
* <SLV-T> 03h 20h [2] IREG_CAL_NUMCARRIERS_CHK 0: different values or no valid carrier 1: same values
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x20, &data, 1) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
pState->bondOK = (data >> 6) & 0x01;
pState->groupIDCheck = (data >> 4) & 0x01;
pState->streamTypeCheck = (data >> 3) & 0x01;
pState->numCarriersCheck = (data >> 1) & 0x01;
pState->carrierSeqCheck = data & 0x01;
pState->calcNumCarriersCheck = (data >> 2) & 0x01;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_isdbc_chbond_monitor_BondStat_hold (sony_demod_t * pDemod,
sony_demod_isdbc_chbond_state_t * pState)
{
uint8_t data;
SONY_TRACE_ENTER ("sony_demod_isdbc_chbond_monitor_BondStat_hold");
if ((!pDemod) || (!pState)) {
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_ISDBC) && (pDemod->chbondConfig) != SONY_DEMOD_CHBOND_CONFIG_ISDBC) {
/* Not ISDB-C and Channel Boding is not enable */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Set SLV-T Bank : 0x03 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x03) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/*
* slave Bank Addr Bit Name meaning
* ----------------------------------------------------------------------------------------------------------------------------------
* <SLV-T> 03h 22h [6] IREG_BOND_NG_HLD 0: Bonding OK 1: Bonding NG
* <SLV-T> 03h 22h [4] IREG_GROUPID_NG_HLD 0: same values 1: different values or no valid carrier
* <SLV-T> 03h 22h [3] IREG_STREAMTYPE_NG_HLD 0: same values 1: different values or no valid carrier
* <SLV-T> 03h 22h [1] IREG_NUMCARR_NG_HLD 0: same values 1: different values or no valid carrier
* <SLV-T> 03h 22h [0] IREG_CARRIER_SEQ_NG_HLD 0: no duplication 1: duplication or no valid carrier
* <SLV-T> 03h 22h [2] IREG_CAL_NUMCARRIERS_NG_HLD 0: same values 1: different values or no valid carrier
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x22, &data, 1) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
data ^= 0x7F;
pState->bondOK = ((data >> 6) & 0x01);
pState->groupIDCheck = ((data >> 4) & 0x01);
pState->streamTypeCheck = ((data >> 3) & 0x01);
pState->numCarriersCheck = ((data >> 1) & 0x01);
pState->carrierSeqCheck = (data & 0x01);
pState->calcNumCarriersCheck = ((data >> 2) & 0x01);
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_isdbc_chbond_ClearBondStat (sony_demod_t * pDemod)
{
SONY_TRACE_ENTER ("sony_demod_isdbc_chbond_ClearBondStat");
if (!pDemod) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if (pDemod->chbondConfig != SONY_DEMOD_CHBOND_CONFIG_ISDBC) {
/* For ISDB-C channel bonding only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Set SLV-T Bank : 0x03 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x03) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/*
* slave Bank Addr Bit default Value Name
* -----------------------------------------------------------------------------------------------
* <SLV-T> 03h 1bh [0] 1'b0 1'b1 OREG_CLR_BONDMON
*/
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x1B, 0x01) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_isdbc_chbond_monitor_TLVConvError (sony_demod_t * pDemod,
uint8_t * pError)
{
sony_result_t result = SONY_RESULT_OK;
uint8_t data;
sony_demod_isdbc_chbond_state_t chbondState;
SONY_TRACE_ENTER ("sony_demod_isdbc_chbond_monitor_TLVConvError");
if ((!pDemod) || (!pError)) {
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_ISDBC) && (pDemod->chbondConfig) != SONY_DEMOD_CHBOND_CONFIG_ISDBC) {
/* Not ISDB-C and Channel Boding is not enable */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Freeze registers */
if (SLVT_FreezeReg (pDemod) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
result = sony_demod_isdbc_chbond_monitor_BondStat (pDemod, &chbondState);
if (result != SONY_RESULT_OK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (result);
}
if (!chbondState.bondOK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* Set SLV-T Bank : 0x03 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x03) != SONY_RESULT_OK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/*
* slave Bank Addr Bit default Value Name meaning
* -------------------------------------------------------------------------------------------------------------------------------
* <SLV-T> 03h 16h [0] 1'b1 1'bx OREG_VAR_TLV_EN 0: TS or Fixed length TLV, 1: Variable length TLV
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x16, &data, 1) != SONY_RESULT_OK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (!(data & 0x01)) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/*
* slave Bank Addr Bit Name meaning
* -----------------------------------------------------------------------------------------------
* <SLV-T> 03h 24h [4] IREG_TLVERR_ALL_HLD 0: No TLV error 1: TLV error
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x24, &data, 1) != SONY_RESULT_OK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SLVT_UnFreezeReg (pDemod);
*pError = (data >> 4) & 0x01;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_isdbc_chbond_ClearTLVConvError (sony_demod_t * pDemod)
{
SONY_TRACE_ENTER ("sony_demod_isdbc_chbond_ClearTLVConvError");
if (!pDemod) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if (pDemod->chbondConfig != SONY_DEMOD_CHBOND_CONFIG_ISDBC) {
/* For ISDB-C channel bonding only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Set SLV-T Bank : 0x03 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x03) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/*
* slave Bank Addr Bit default Value Name
* -----------------------------------------------------------------------------------------------
* <SLV-T> 03h 19h [0] 1'b0 1'b1 OREG_TLVCHK_RST
*/
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x19, 0x01) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_isdbc_chbond_monitor_CarrierDelay (sony_demod_t * pDemod,
uint32_t * pDelay)
{
uint8_t data[3];
SONY_TRACE_ENTER ("sony_demod_isdbc_chbond_monitor_CarrierDelay");
if ((!pDemod) || (!pDelay)) {
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_ISDBC) && (pDemod->chbondConfig) != SONY_DEMOD_CHBOND_CONFIG_ISDBC) {
/* Not ISDB-C and Channel Boding is not enable */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Set SLV-T Bank : 0x03 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x03) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/*
* slave Bank Addr Bit Name
* -----------------------------------------------------------------------------------------------
* <SLV-T> 03h 1dh [7:0] IREG_MON_VALID,2'd0,IREG_FDELAY[20:16]
* <SLV-T> 03h 1eh [7:0] IREG_FDELAY[15:8]
* <SLV-T> 03h 1fh [7:0] IREG_FDELAY[7:0]
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x1D, data, 3) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
if (!(data[0] & 0x80)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
*pDelay = ((data[0] & 0x1F) << 16) | (data[1] << 8) | data[2];
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_isdbc_chbond_monitor_EWSChange (sony_demod_t * pDemod,
uint8_t * pEWSChange)
{
sony_result_t result = SONY_RESULT_OK;
uint8_t data;
sony_demod_isdbc_chbond_state_t chbondState;
SONY_TRACE_ENTER ("sony_demod_isdbc_chbond_monitor_EWSChange");
if ((!pDemod) || (!pEWSChange)) {
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_ISDBC) && (pDemod->chbondConfig) != SONY_DEMOD_CHBOND_CONFIG_ISDBC) {
/* Not ISDB-C and Channel Boding is not enable */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Freeze registers */
if (SLVT_FreezeReg (pDemod) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
result = sony_demod_isdbc_chbond_monitor_BondStat (pDemod, &chbondState);
if (result != SONY_RESULT_OK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (result);
}
if (!chbondState.bondOK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* Set SLV-T Bank : 0x03 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x03) != SONY_RESULT_OK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/*
* slave Bank Addr Bit Name meaning
* -----------------------------------------------------------------------------------------------
* <SLV-T> 03h 52h [4] IREG_EWS0 from Ext0
* <SLV-T> 03h 52h [5] IREG_EWS1 from Ext1
* <SLV-T> 03h 52h [6] IREG_EWS2 from Ext2
* <SLV-T> 03h 52h [7] IREG_EWS3 from internal dmd
* IREG_EWSX 0:Emergancy boot control is not detected. 1:Emergancy boot control is detected
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x52, &data, 1) != SONY_RESULT_OK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SLVT_UnFreezeReg (pDemod);
*pEWSChange = (data >> 4) & 0x0F;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_isdbc_chbond_ClearEWSChange (sony_demod_t * pDemod)
{
SONY_TRACE_ENTER ("sony_demod_isdbc_chbond_ClearEWSChange");
if (!pDemod) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if (pDemod->chbondConfig != SONY_DEMOD_CHBOND_CONFIG_ISDBC) {
/* For ISDB-C channel bonding only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Set SLV-T Bank : 0x03 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x03) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/*
* slave Bank Addr Bit default Value Name
* -----------------------------------------------------------------------------------------------
* <SLV-T> 03h 53h [0] 1'b0 1'b1 OREG_CLR_EWS
*/
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x53, 0x01) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_isdbc_chbond_monitor_VersionChange (sony_demod_t * pDemod,
uint8_t * pVersionChange)
{
sony_result_t result = SONY_RESULT_OK;
uint8_t data;
sony_demod_isdbc_chbond_state_t chbondState;
SONY_TRACE_ENTER ("sony_demod_isdbc_chbond_monitor_VersionChange");
if ((!pDemod) || (!pVersionChange)) {
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_ISDBC) && (pDemod->chbondConfig) != SONY_DEMOD_CHBOND_CONFIG_ISDBC) {
/* Not ISDB-C and Channel Boding is not enable */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Freeze registers */
if (SLVT_FreezeReg (pDemod) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
result = sony_demod_isdbc_chbond_monitor_BondStat (pDemod, &chbondState);
if (result != SONY_RESULT_OK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (result);
}
if (!chbondState.bondOK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* Set SLV-T Bank : 0x03 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x03) != SONY_RESULT_OK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/*
* slave Bank Addr Bit Name meaning
* -----------------------------------------------------------------------------------------------
* <SLV-T> 03h 52h [0] IREG_VERNUMCHG0 from Ext0
* <SLV-T> 03h 52h [1] IREG_VERNUMCHG1 from Ext1
* <SLV-T> 03h 52h [2] IREG_VERNUMCHG2 from Ext2
* <SLV-T> 03h 52h [3] IREG_VERNUMCHG3 from internal dmd
* IREG_VERNUMCHGx 0:TSMF version number change is not detected. 1:TSMF version number change is detected
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x52, &data, 1) != SONY_RESULT_OK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SLVT_UnFreezeReg (pDemod);
*pVersionChange = data & 0x0F;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_isdbc_chbond_ClearVersionChange (sony_demod_t * pDemod)
{
SONY_TRACE_ENTER ("sony_demod_isdbc_chbond_ClearVersionChange");
if (!pDemod) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
if (pDemod->chbondConfig != SONY_DEMOD_CHBOND_CONFIG_ISDBC) {
/* For ISDB-C channel bonding only */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Set SLV-T Bank : 0x03 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x03) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/*
* slave Bank Addr Bit default Value Name
* -----------------------------------------------------------------------------------------------
* <SLV-T> 03h 54h [0] 1'b0 1'b1 OREG_CLR_VERNUMCHG
*/
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x54, 0x01) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_isdbc_chbond_monitor_StreamType (sony_demod_t * pDemod,
sony_isdbc_chbond_stream_type_t * pStreamType)
{
sony_result_t result = SONY_RESULT_OK;
sony_demod_isdbc_chbond_state_t chbondState;
uint8_t data;
SONY_TRACE_ENTER ("sony_demod_isdbc_chbond_monitor_StreamType");
if ((!pDemod) || (!pStreamType)){
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_ISDBC) && (pDemod->chbondConfig) != SONY_DEMOD_CHBOND_CONFIG_ISDBC) {
/* Not ISDB-C and Channel Boding is not enable */
SONY_TRACE_RETURN (SONY_RESULT_ERROR_SW_STATE);
}
/* Freeze registers */
if (SLVT_FreezeReg (pDemod) != SONY_RESULT_OK) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
result = sony_demod_isdbc_chbond_monitor_BondStat (pDemod, &chbondState);
if (result != SONY_RESULT_OK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (result);
}
if (!chbondState.bondOK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_HW_STATE);
}
/* Set SLV-T Bank : 0x03 */
if (pDemod->pI2c->WriteOneRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x00, 0x03) != SONY_RESULT_OK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
/* slave Bank Addr Bit Name meaning
* ---------------------------------------------------------------------------------------------------------------------------------------
* <SLV-T> 03h 25h [6] IREG_STREAMTYPE 0:TS output, 1:TLV output
*/
if (pDemod->pI2c->ReadRegister (pDemod->pI2c, pDemod->i2cAddressSLVT, 0x25, &data, 1) != SONY_RESULT_OK) {
SLVT_UnFreezeReg (pDemod);
SONY_TRACE_RETURN (SONY_RESULT_ERROR_I2C);
}
SLVT_UnFreezeReg (pDemod);
if (data & 0x40) {
*pStreamType = SONY_ISDBC_CHBOND_STREAM_TYPE_TLV;
} else {
*pStreamType = SONY_ISDBC_CHBOND_STREAM_TYPE_TS_NONE;
}
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
sony_result_t sony_demod_isdbc_chbond_monitor_TSMFHeaderExt (sony_demod_t * pDemod,
sony_isdbc_tsmf_header_t * pTSMFHeader,
sony_isdbc_chbond_tsmf_header_ext_t * pTSMFHeaderExt)
{
int i;
SONY_TRACE_ENTER ("sony_demod_isdbc_chbond_monitor_TSMFHeaderExt");
if ((!pDemod) || (!pTSMFHeader) || (!pTSMFHeaderExt)) {
SONY_TRACE_RETURN (SONY_RESULT_ERROR_ARG);
}
memcpy(&pTSMFHeaderExt->aceewData[0], &pTSMFHeader->privateData[0], 26);
for (i = 0; i < 8; i++) {
pTSMFHeaderExt->streamType[i] = (sony_isdbc_chbond_stream_type_t)((pTSMFHeader->privateData[26] >> (7 - i)) & 0x01);
}
for (i = 0; i < 7; i++) {
pTSMFHeaderExt->streamType[i + 8] = (sony_isdbc_chbond_stream_type_t)((pTSMFHeader->privateData[27] >> (7 - i)) & 0x01);
}
pTSMFHeaderExt->groupID = pTSMFHeader->privateData[28];
pTSMFHeaderExt->numCarriers = pTSMFHeader->privateData[29];
pTSMFHeaderExt->carrierSequence = pTSMFHeader->privateData[30];
pTSMFHeaderExt->numFrames = (pTSMFHeader->privateData[31] >> 4) & 0x0F;
pTSMFHeaderExt->framePosition = pTSMFHeader->privateData[31] & 0x0F;
SONY_TRACE_RETURN (SONY_RESULT_OK);
}
+223
View File
@@ -0,0 +1,223 @@
/*------------------------------------------------------------------------------
Copyright 2018 Sony Semiconductor Solutions Corporation
Last Updated : 2018/12/13
Modification ID : e402a4dcb0e51a00c34b174334c082c1211eebf1
------------------------------------------------------------------------------*/
/**
@file sony_demod_isdbc_chbond.h
This file provides the demodulator control and monitor interface for ISDB-C channel bonding.
*/
/*----------------------------------------------------------------------------*/
#ifndef SONY_DEMOD_ISDBC_CHBOND_H
#define SONY_DEMOD_ISDBC_CHBOND_H
#include "../sony_demod.h"
#include "sony_isdbc_chbond.h"
#include "sony_isdbc.h"
/*------------------------------------------------------------------------------
Structs
------------------------------------------------------------------------------*/
/**
@brief Channel bonding state.
@note For each members, 1 is set if each check is OK.
*/
typedef struct {
uint8_t bondOK; /**< Bonding OK or not */
uint8_t groupIDCheck; /**< Group ID values are same or not */
uint8_t streamTypeCheck; /**< Stream type values are same or not */
uint8_t numCarriersCheck; /**< Number of carriers values are same or not */
uint8_t carrierSeqCheck; /**< Carrier sequence value check is OK or not */
uint8_t calcNumCarriersCheck; /**< Number of valid input carriers are OK or not */
} sony_demod_isdbc_chbond_state_t;
/*------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------*/
/**
@brief Enable/disable ISDB-C channel bonding function.
This API is called internally to enable/disable channel bonding.
Note that ISDB-C channel bonding function is available on CXD2878 family only.
@param pDemod The demodulator instance
@param enable Enable/disable setting.
- 0: Disable
- 1: Enable
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_isdbc_chbond_Enable (sony_demod_t * pDemod,
uint8_t enable);
/**
@brief TSMF TS selection after channel bonding.
@param pDemod The demodulator instance
@param tsidType Absolute TSID or relative TS number selection
@param tsid TSID or relative TS number
@param networkId Network ID. Ignored if relative TS number is selected.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_isdbc_chbond_SetTSMFConfig (sony_demod_t * pDemod,
sony_isdbc_tsid_type_t tsidType,
uint16_t tsid,
uint16_t networkId);
/**
@brief Soft reset the ISDB-C channel bonding function.
@param pDemod The demod instance.
@return SONY_RESULT_OK if successfully reset.
*/
sony_result_t sony_demod_isdbc_chbond_SoftReset (sony_demod_t * pDemod);
/**
@brief Channel bonding status monitor (instant)
@param pDemod The demodulator instance
@param pState Channel bonding state
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_isdbc_chbond_monitor_BondStat (sony_demod_t * pDemod,
sony_demod_isdbc_chbond_state_t * pState);
/**
@brief Channel bonding status monitor (hold type)
@note This API is used to know some bonding error occurred or not in long time region.
If a error is detected, member of sony_demod_isdbc_chbond_state_t become 0.
::sony_demod_isdbc_chbond_ClearBondStat can be used to clear error state.
@param pDemod The demodulator instance
@param pState Channel bonding state
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_isdbc_chbond_monitor_BondStat_hold (sony_demod_t * pDemod,
sony_demod_isdbc_chbond_state_t * pState);
/**
@brief Clear the channel bonding status monitor (hold type).
@param pDemod The demodulator instance.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_isdbc_chbond_ClearBondStat (sony_demod_t * pDemod);
/**
@brief TLV conversion error monitor. (hold type)
@param pDemod The demodulator instance.
@param pError If 1, TLV conversion error is detected.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_isdbc_chbond_monitor_TLVConvError (sony_demod_t * pDemod,
uint8_t * pError);
/**
@brief Clear the TLV conversion error monitor.
@param pDemod The demodulator instance.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_isdbc_chbond_ClearTLVConvError (sony_demod_t * pDemod);
/**
@brief Carrier delay monitor.
@param pDemod The demodulator instance.
@param pDelay Delay between valid input carriers. Please divide by 96 to convert us unit.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_isdbc_chbond_monitor_CarrierDelay (sony_demod_t * pDemod,
uint32_t * pDelay);
/**
@brief Emergency Warning Broadcasting System(EWS) detection monitor. (hold type)
@param pDemod The demodulator instance.
@param pEWSChange EWS change detection flag.
Bit[0] : Stream from external demod 0
Bit[1] : Stream from external demod 1
Bit[2] : Stream from external demod 2
Bit[3] : Stream from internal demod
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_isdbc_chbond_monitor_EWSChange (sony_demod_t * pDemod,
uint8_t * pEWSChange);
/**
@brief Clear the EWS detection flag.
@param pDemod The demodulator instance.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_isdbc_chbond_ClearEWSChange (sony_demod_t * pDemod);
/**
@brief TSMF version number change monitor. (hold type)
@param pDemod The demodulator instance.
@param pVersionChange TSMF version change detection flag.
Bit[0] : Stream from external demod 0
Bit[1] : Stream from external demod 1
Bit[2] : Stream from external demod 2
Bit[3] : Stream from internal demod
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_isdbc_chbond_monitor_VersionChange (sony_demod_t * pDemod,
uint8_t * pVersionChange);
/**
@brief Clear the TSMF version change detection flag.
@param pDemod The demodulator instance.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_isdbc_chbond_ClearVersionChange (sony_demod_t * pDemod);
/**
@brief Stream type (TLV or TS) monitor.
@param pDemod The demodulator instance.
@param pStreamType Stream type.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_isdbc_chbond_monitor_StreamType (sony_demod_t * pDemod,
sony_isdbc_chbond_stream_type_t * pStreamType);
/**
@brief TSMF header extension information monitor.
@note This API only convert "private data" in sony_isdbc_tsmf_header_t struct.
::sony_demod_isdbc_monitor_TSMFHeader should be called before this API
to get sony_isdbc_tsmf_header_t data.
@param pDemod The demodulator instance.
@param pTSMFHeader TSMF header information got by ::sony_demod_isdbc_monitor_TSMFHeader.
@param pTSMFHeaderExt Converted TSMF header extension information for channel bonding case.
@return SONY_RESULT_OK if successful.
*/
sony_result_t sony_demod_isdbc_chbond_monitor_TSMFHeaderExt (sony_demod_t * pDemod,
sony_isdbc_tsmf_header_t * pTSMFHeader,
sony_isdbc_chbond_tsmf_header_ext_t * pTSMFHeaderExt);
#endif /* SONY_DEMOD_ISDBC_CHBOND_H */
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More