blob: 098388c56f19221db28230883e816ccd5b0232ed [file] [log] [blame]
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2016
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
#ifndef _CPHEVDOSCH_H_
#define _CPHEVDOSCH_H_
//#include "cl1common.h"
#include "kal_general_types.h"
#define SCH_MAX_PILOTS 56
#define SCH_KEPT_PILOTS 20
#define SYS_MAX_ACTIVE_LIST_PILOTS 6 /* max number of pilot pn's in acitve list */
#define SYS_MAX_CANDIDATE_LIST_PILOTS 10 /* max number of pilot pn's in candidate list */
#define SYS_MAX_NEIGHBOR_LIST_PILOTS 56 /* max number of pilot pn's in neighbor list */
#define SYS_MAX_REMAINING_LIST_PILOTS 5 /* max number of pilots in remaining set */
#define SCH_MAX_PER_PILOT_PATHS 16
#define SCH_VERIF_NUM_PILOTS_FOUR 4
#define SCH_VERIF_NUM_PILOTS_ONE 1
#define SCH_ALWAYS_SRCH 1
#define SCH_NOT_ALWAYS_SRCH 0
#define SCH_MAX_USABLE_PATHS 42
#define SCH_MAX_PER_PILOT_USABLE_PATHS 7
#define SCH_USABLE_PATH_SPY_UPDATE_CNT 10
#define SCH_KEPT_PILOTS 20
#define SCH_PILOT_ENABLE 1
#define SCH_PILOT_DISABLE 0
#define SCH_PILOT_KEEP 1
#define SCH_PILOT_DONT_KEEP 0
#define SCH_PPM_SLOT_Q6 15625
/* #define SCH_STAT_TO_ECIO_Q29 23981*/
#define SCH_STAT_TO_ECIO_Q29 (31655*2) /*temp fix for pilot fluctuation, match shift 1 change */
#define SCH_MINUS8DBQ16 10387
#define SCH_MINUS11DBQ16 5206
#define SCH_MINUS12DBQ16 4135
#define SCH_MINUS14DBQ16 2609
#define SCH_MINUS14p5DBQ16 2325
#define SCH_MINUS15DBQ16 2072
#define SCH_MINUS18DBQ16 1038
#define SCH_MINUS21DBQ16 520
#define SCH_MAX_NUM_FINGERS 6
#define SCH_MIN_OFFSET_DIST_TC2 2
#define SCH_HALF_CHIP_TC2 1
#define SCH_ONE_CHIP_TC2 2
#define SCH_FINGER_ALLOC_CNT 3
/*Sch HW programming for SRDO_INBUF_CTL:BUFFCAPT: Period in half-slots before next buffer capture NOTE: the CAPLEN<= BUFFCAPT period
define ONLINE search mode values */
#define SCH_HW_PROG_ONL_INBUF_CTL_CAPT_PERIOD 7 /* Capture at (M+1) half slots intervals, i.e., 6.668ms */
/*Sch HW programming for SRDO_INBUF_CTL:BUFFCAPINT: Num of buffers captured before INTR is triggered
define ONLINE search mode values */
#define SCH_HW_PROG_ONL_INBUF_CTL_CAPTURES_PER_INTR 8 /* Interrupt to CP every N*(M+1) half slots, 53.3ms */
/*Sch HW programming for SRDO_INBUF_CTL:BUFFCAPT: Period in half-slots before next buffer capture NOTE: the CAPLEN<= BUFFCAPT period
define DFS search mode values */
#define SCH_HW_PROG_DFS_INBUF_CTL_CAPT_PERIOD 3 /* Capture at (M+1) half slots intervals, i.e., 3.334ms */
/*Sch HW programming for SRDO_INBUF_CTL:BUFFCAPINT: Num of buffers captured before INTR is triggered
define DFS search mode values */
#define SCH_HW_PROG_DFS_INBUF_CTL_CAPTURES_PER_INTR 2 /* Interrupt to CP every N*(M+1) half slots, 6.668ms */
/* Sch HW programming for SRDO_INBUF_CTL:ANTENNA_INIT_EN :-
Enable changing the source antenna (main OR diversity, based on the value in
SRDO_INBUF_CTL:ANTENNA_INIT ), in Antenna-toggle search mode
(SRDO_INBUF_CTL:ANT_MODE = 0x2/ 0x3)
NOTE: IMD requires last buffer to be captured as MAIN hence based on the
number of buffers captured, change the starting source accordingly
*/
#define SCH_HW_INBUF_CTL_ANTENNA_INIT_EN_USED 1
#define SCH_HW_INBUF_CTL_ANTENNA_INIT_EN_NOTUSED 0
#define SCH_HW_INBUF_CTL_ANTENNA_INIT_NOTUSED SCH_HW_PROG_INBUF_ANT_MODE_MAIN //Don't care value for SRDO_INBUF_CTL:ANTENNA_INIT field
#define RMC_SCH_LOGIQ_MAX_BUFFER_LENGTH 0x8C0 /*1024+96chip 2x*/
/* Sch HW programming for SRDO_INBUF_CTL:ANT_MODE :-
Define type to indicate input source antenna */
typedef enum
{
SCH_HW_PROG_INBUF_ANT_MODE_MAIN = 0,
SCH_HW_PROG_INBUF_ANT_MODE_DIV = 1,
SCH_HW_PROG_INBUF_ANT_MODE_ALTERNATE_PER_CAPT = 2, /* Alternate antenna after each capture NOTE: Multiple captures before search HW interrupt is triggered. Also each cpature can be multiple half-slots long */
SCH_HW_PROG_INBUF_ANT_MODE_ALTERNATE_PER_HFSLOT = 3, /* Alternate antenna after each half slot*/
}SchHwProgInBufAntModeT;
typedef enum
{
HW_RESET,
HW_PAUSE,
INIT_ACQ_PN_SRCH,
INIT_ACQ_ONLINE_PN_SRCH,
INIT_ACQ_VERIF_SRCH,
MINI_ACQ,
FAST_SEARCH,
ONLINE,
OFFSET_ADJ,
FAST_FULL_SEARCH,
SCH_MODE_UNUSED_1,
SCH_MODE_UNUSED_2,
DFS,
MEAS_6MS_SRCH,
MEAS_ONLINE_SCAN
} SchModeT;
typedef struct
{
kal_uint16 PilotPN; /* PilotPN 0 to 511 */
kal_int16 StartOffset; /* Start offset to search, Tc/2 (-1024,...,+1023.5 chips) */
} SchCfgPnListT;
typedef struct
{
kal_int8 NumPilots; /* Number of Pilots in the Active list */
kal_uint16 WinSize; /* Window Size */
SchCfgPnListT PnListQ[SYS_MAX_ACTIVE_LIST_PILOTS];
} SchCfgActListT;
typedef struct
{
kal_int8 NumPilots; /* Number of Pilots in the Candidate list */
kal_uint16 WinSize; /* Window Size */
SchCfgPnListT PnListQ[SYS_MAX_CANDIDATE_LIST_PILOTS];
} SchCfgCandListT;
typedef struct
{
kal_int8 NumPilots; /* Number of Pilots in the Neighbor list */
kal_uint16 WinSize[SYS_MAX_NEIGHBOR_LIST_PILOTS]; /* Window information */
SchCfgPnListT PnListQ[SYS_MAX_NEIGHBOR_LIST_PILOTS];
} SchCfgNeighListT;
typedef struct
{
kal_int8 NumPilots; /* Number of Pilots in the Remaining list */
kal_uint16 WinSize; /* Window Size */
SchCfgPnListT PnListQ[SYS_MAX_REMAINING_LIST_PILOTS];
} SchCfgRemListT;
typedef struct
{
kal_int16 ListNum; /* total search list number (A+C+N+R) */
SchCfgActListT Active;
SchCfgCandListT Candidate;
SchCfgNeighListT Neighbor;
SchCfgRemListT Remaining;
} SchListT;
typedef struct
{
kal_uint16 WinSize; /* Window Size */
kal_int16 WinOffset; /* Window Offset */
} WinT;
typedef struct
{
kal_uint16 PilotPN; /* PilotPN 0 to 511 */
kal_int16 Offset; /* Tc/2 resolution */
} AcqListQT;
typedef struct
{
kal_int16 ListNum;
AcqListQT PnListQ[SCH_VERIF_NUM_PILOTS_FOUR];
} SchAcqListT;
typedef struct
{
SchModeT SchMode;
kal_uint16 SchInitAcqNumHalfSlotBufCap;
kal_uint8 Antenna;
kal_bool antenna_init_en;
kal_uint32 antenna_init; //Not Valid as antenna_init_en is FALSE
kal_bool Div_only;
kal_uint16 SchInitAcqWinSizeTc;
kal_uint16 SchInitAcqWinOffsetTc;
kal_uint16 SchMiniAcqWinSizeIndex;
//intkal_bool bHwdPwrSavingDoPwrUp;//no this mode for 93
kal_bool SchStartDlyEn;
kal_uint32 SchStartDlyCnt;
SchListT SchList;
SchAcqListT SchAcqSrch;
} CphEvdoSchModeConfigStruct;
typedef struct
{
kal_uint16 Metric;
kal_uint16 PilotPN;
kal_int16 Offset; /* Offset in Tc/2 (-1024,...,+1023.5 chips) */
} SchSortQT;
typedef struct
{
kal_uint16 Count;
SchSortQT SortQ[SCH_MAX_PILOTS];
} SchSortT;
typedef struct
{
kal_uint16 Stat; /* Stat for path */
kal_int16 StatOffset; /* Stat Offset in Tc/2 (-1024,...,+1023.5 chips) */
kal_uint8 PathValid; /* Indicates if path is valid (passes thresh) */
kal_uint8 NumAvg; /* Number of times offset was found */
kal_uint8 Ant; /* Source antenna */
} SchPathQT;
typedef struct
{
kal_uint16 PilotPN; /* PilotPN 0 to 511 */
kal_int16 Offset; /* strongest offset found, Tc/2 (-1024,...,+1023.5 chips) */
kal_int16 StartOffset; /* Start offset to search, Tc/2 (-1024,...,+1023.5 chips) */
kal_uint16 MaxStat; /* Maximum statistic in the path buffer */
kal_uint16 PwrEst; /* Sum of usable path power */
#ifdef MTK_PLT_ON_PC
kal_int16 Strength_db; /* pilot strength in db */
#endif
kal_uint8 NumWinSearch; /* Number of times the pilot was searched */
kal_uint8 PilotFound; /* Indicates if the H/W found the pilot */
SchPathQT PathQ[SCH_MAX_PER_PILOT_PATHS];
} ListQT;
typedef struct
{
kal_int8 NumPilots; /* Number of Pilots in the Active list */
kal_uint16 WinSize; /* Window Size */
kal_uint8 MACIndex[SYS_MAX_ACTIVE_LIST_PILOTS]; /* MAC Index */
kal_int8 PcgId[SYS_MAX_ACTIVE_LIST_PILOTS];
kal_uint8 RABLength[SYS_MAX_ACTIVE_LIST_PILOTS];
kal_uint8 RABOffset[SYS_MAX_ACTIVE_LIST_PILOTS];
kal_uint8 RAChannelGain[SYS_MAX_ACTIVE_LIST_PILOTS];
kal_uint8 DRCCover[SYS_MAX_ACTIVE_LIST_PILOTS];
kal_uint8 DSC[SYS_MAX_ACTIVE_LIST_PILOTS]; /* oxff means NULL */
ListQT ListQ[SYS_MAX_ACTIVE_LIST_PILOTS];
} ActListT;
typedef struct
{
kal_int8 NumPilots; /* Number of Pilots in the Candidate list */
kal_uint16 WinSize; /* Window Size */
ListQT ListQ[SYS_MAX_CANDIDATE_LIST_PILOTS];
} CandListT;
typedef struct
{
kal_int8 NumPilots; /* Number of Pilots in the Neighbor list */
WinT Win[SYS_MAX_NEIGHBOR_LIST_PILOTS]; /* Window information */
ListQT ListQ[SYS_MAX_NEIGHBOR_LIST_PILOTS];
} NeighListT;
typedef struct
{
kal_int8 NumPilots; /* Number of Pilots in the Remaining list */
kal_uint16 WinSize; /* Window Size */
ListQT ListQ[SYS_MAX_REMAINING_LIST_PILOTS];
} RemListT;
typedef struct
{
kal_int16 PilotSeq;
kal_uint8 ConnSetupFlag;
kal_uint8 TcaFlag;
kal_int16 ListNum; /* total search list number (A+C+N+R) */
ActListT Active;
CandListT Candidate;
NeighListT Neighbor;
RemListT Remaining;
} RmcSchStatusT;
typedef struct
{
SchModeT SchMode;
SchSortQT *pSortQ; /**For store INIT_PN_SRCH result: SCH_KEPT_PILOTS.*/
RmcSchStatusT *pSchStatus; /**For store other search result.*/
} CphEvdoSchResultReadStruct;
typedef struct
{
kal_int8 ImdAdcI; /* IMD ADC I samples */
kal_int8 ImdAdcQ; /* IMD ADC Q samples */
} RmcSchLogIQComplexSampleT;
typedef struct
{
kal_int8 tbd;
}CphEvdoSchTestIqDumpAdsStruct;
void CphEvdoSchInit();
void CphEvdoPauseConfig(kal_uint8 PauseBit);
void CphEvdoSchModeConfig(CphEvdoSchModeConfigStruct *ads_ptr);
void CphEvdoSchResultRead(CphEvdoSchResultReadStruct *ads_ptr);
void CphEvdoSchLogIqRead(RmcSchLogIQComplexSampleT *ads_ptr);
#if 0 /**Just used for debug.*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
kal_bool CphEvdoSchReadSchDone(void);
#ifdef MTK_PLT_ON_PC_IT
void CphEvdoSchWriteSchDone(kal_bool SchDone);
#endif
#endif