db.c
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:120k
- #include <string.h>
- #include <assert.h>
- #include "flash.h"
- #include "db.h"
- #include "sipsi.h"
- #include "dmd.h"
- #include "eprom.h"
- #include "av.h"
- //added by yyj 2007.7.3
- #include "demand.h"
- //added by yyj 2007.7.16
- #include "gendef.h"
- KB_DBPrgAllInfo gPrgAllInfo;
- KB_DBE2PDATA gE2pData;
- static UINT8 gDtvCfgFlag[KB_DB_MAX_DTV];
- static UINT8 gRadCfgFlag[KB_DB_MAX_RAD];
- //added by whale 07/05/25
- static UINT8 gDataCfgFlag[KB_DB_MAX_DATA];
- static KB_DBMailNode gMailInfo[KB_DB_MAX_MAIL];
- //added by yyj 2007.6.27 start
- static UINT8 gVidDispMode;// 视频制式
- static UINT8 gVidAspectRatio;// 屏幕宽高比
- static UINT8 gConfigAudioVol; // 统一音量
- static UINT8 gConfigAudioTrack; // 统一声道
- static UINT8 gConfigAdultRank;// 成人级别
- static UINT8 gConfigMenuLan;//菜单语言
- static UINT8 gConfigMenuTran;// 菜单透明度
- //added by yyj 2007.6.27 end
- static UINT16 KD_GetFreeNumCfg(UINT8 nPrgType);
- static KB_DBRET KD_ResetMailInfo(void);
- static KB_DBRET KD_InitMail(void);
- static KB_DBRET KD_InitChnnlInfo(void);
- static KB_DBRET KD_InitDtvInfo(void);
- //added by whale 07/05/25
- static KB_DBRET KD_InitDataInfo(void);
- static KB_DBRET KD_InitRadInfo(void);
- static KB_DBRET KD_ResetNvodInfo(UINT8 bType);
- static KB_DBRET KD_InitNvodInfo(void);
- static KB_DBRET KD_InitCurPrgInfo(void);
- static KB_DBRET KD_InitCurPrgInfo(void);
- KB_DBRET KD_ResetCurPrgInfo(void);
- static KB_DBRET KD_ResetNetInfo(void);
- static KB_DBRET KD_InitNetInfo(void);
- static KB_DBRET KD_ResetSysparInfo(void);
- static KB_DBRET KD_InitSysparInfo(void);
- static KB_DBRET KD_ResetPwdInfo(void);
- static KB_DBRET KD_InitPwdInfo(void);
- static KB_DBRET KD_ResetSrchInfo(void);
- static KB_DBRET KD_InitSrchInfo(void);
- static KB_DBRET KD_ResetFavDtv(void);
- static KB_DBRET KD_InitFavDtv(void);
- static KB_DBRET KD_ResetFavRad(void);
- static KB_DBRET KD_InitFavRad(void);
- static KB_DBRET KD_ResetSerList(void);
- static KB_DBRET KD_InitSerList(void);
- static void KD_InitPrgConfig(void);
- //static KB_DBRET KD_InitPrgNum(void);
- //static KB_DBRET KD_GetPrgNum(void);
- static void quicksort(KB_DBPrgInfo *pbuf,int low,int high);
- static int quickpart(KB_DBPrgInfo *pbuf,int i,int j);
- static KB_DBRET KD_GetPrgConfig(void);
- //added by yyj 2007.6.15 start
- static KB_DBRET KD_InitPgmCurVol(void);
- static KB_DBRET KD_ResetPgmCurVol(void);
- //added by yyj 2007.6.15 end
- //added by yyj 2007.6.27 start
- static KB_DBRET KD_InitVideoDispMode(void);
- static KB_DBRET KD_ResetVideoDispMode(void);
- static KB_DBRET KD_InitVideoAspectRatio(void);
- static KB_DBRET KD_ResetVideoAspectRatio(void);
- static KB_DBRET KD_InitPgmCurTrack(void);
- static KB_DBRET KD_ResetPgmCurTrack(void);
- static KB_DBRET KD_InitAdultRank(void);
- static KB_DBRET KD_ResetAdultRank(void);
- static KB_DBRET KD_InitMenuLan(void);
- static KB_DBRET KD_ResetMenuLan(void);
- static KB_DBRET KD_InitMenuTran(void);
- static KB_DBRET KD_ResetMenuTran(void);
- //added by yyj 2007.6.27 end
- //added by yyj 2007.6.27
- #define KB_DB_DEFAULT_MENU_LAN CHINESE
- #define KB_DB_DEFAULT_MENU_TRAN LEVEL_3
- /////////////////////
- //added by yyj 2007.6.19
- static KB_DBRET KD_InitSTBInfo(void);
- static KB_DBRET KD_ResetSTBInfo(void);
- /////////////////////
- //added by yyj 2007.7.3
- //static KB_DBRET KD_ResetDemandInfo(void);
- KB_DBRET KB_DBInit(void)
- {
- KB_DBRET tRet;
- //UINT8 updateInfo[2];
- //moved by lsp 07/3/14
- printf("nKB_DBInit");
- if (KD_InitSysparInfo() != RET_OK)
- {
- printf("nKD_InitSysparInfo() != RET_OKn");//lsp 07/3/14
- tRet = KD_ResetSysparInfo();
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
- //lsp 07/3/14
- if (KB_FlashRead(KB_DB_SECTOR, 0, (UINT8*)&gPrgAllInfo, sizeof(KB_DBPrgAllInfo)) != RETOK)
- {
- return RET_FAIL;
- }
- else
- {
- if(gPrgAllInfo.gChnnlInfo.nTotal==0xFF)
- gPrgAllInfo.gChnnlInfo.nTotal=0;
- if(gPrgAllInfo.gDTVInfo.nTotal==0xFFFF)
- gPrgAllInfo.gDTVInfo.nTotal=0;
- if(gPrgAllInfo.gRADInfo.nTotal==0xFFFF)
- gPrgAllInfo.gRADInfo.nTotal=0;
- //added by whale 07/05/25 start
- if(gPrgAllInfo.gDATAInfo.nTotal==0xFFFF)
- gPrgAllInfo.gDATAInfo.nTotal=0;
- //added by whale 07/05/25 end
- }
- tRet = KD_GetPrgConfig();
- if (tRet != RET_OK)
- {
- return tRet;
- }
-
- if (KD_InitMail() != RET_OK)
- {
- tRet = KD_ResetMailInfo();
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
-
- if (KD_InitChnnlInfo() != RET_OK)
- {
- tRet = KB_DBResetChnnlInfo(BufferSave);
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
- else
- {
- if (KD_InitDtvInfo() != RET_OK)
- {
- tRet = KB_DBResetDtvInfo(FlashSave);
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
- if (KD_InitFavDtv() != RET_OK)
- {
- tRet = KD_ResetFavDtv();
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
-
- if (KD_InitRadInfo() != RET_OK)
- {
- tRet = KB_DBResetRadInfo(FlashSave);
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
- if (KD_InitFavRad() != RET_OK)
- {
- tRet = KD_ResetFavRad();
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
- //added by whale 07/05/25 start
- if (KD_InitDataInfo() != RET_OK)
- {
- tRet = KB_DBResetDataInfo(FlashSave);
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
- //added by whale 07/05/25 end
- if (KD_InitNvodInfo() != RET_OK)
- {
- tRet = KD_ResetNvodInfo(FlashSave);
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
-
- if (KD_InitCurPrgInfo() != RET_OK)
- {
- tRet = KD_ResetCurPrgInfo();
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
- }
-
- if (KD_InitNetInfo() != RET_OK)
- {
- tRet = KD_ResetNetInfo();
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
- //moved by lsp 07/3/14
- /* if (KD_InitSysparInfo() != RET_OK)
- {
- tRet = KD_ResetSysparInfo();
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }*/
- //lsp 07/3/14
-
- if (KD_InitPwdInfo() != RET_OK)
- {
- tRet = KD_ResetPwdInfo();
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
-
- if (KD_InitSrchInfo() != RET_OK)
- {
- tRet = KD_ResetSrchInfo();
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
- if (KD_InitSerList() != RET_OK)
- {
- tRet = KD_ResetSerList();
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
- //added by yyj 2007.6.15 start
- if (KD_InitPgmCurVol() != RET_OK)
- {
- tRet = KD_ResetPgmCurVol();
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
- //added by yyj 2007.6.15 end
- //added by yyj 2007.6.19 start
- if (KD_InitSTBInfo() != RET_OK)
- {
- tRet = KD_ResetSTBInfo();
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
- //added by yyj 2007.6.19 end
- //added by yyj 2007.6.27 start
- if (KD_InitVideoDispMode() != RET_OK)
- {
- tRet = KD_ResetVideoDispMode();
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
- if (KD_InitVideoAspectRatio() != RET_OK)
- {
- tRet = KD_ResetVideoAspectRatio();
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
- if (KD_InitPgmCurTrack() != RET_OK)
- {
- tRet = KD_ResetPgmCurTrack();
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
- if (KD_InitAdultRank() != RET_OK)
- {
- tRet = KD_ResetAdultRank();
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
- if (KD_InitMenuLan() != RET_OK)
- {
- tRet = KD_ResetMenuLan();
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
- if (KD_InitMenuTran() != RET_OK)
- {
- tRet = KD_ResetMenuTran();
- if (tRet != RET_OK)
- {
- return tRet;
- }
- }
- //added by yyj 2007.6.27 end
-
- KD_InitPrgConfig();
-
- return RET_OK;
- }
- static void quicksort(KB_DBPrgInfo *pbuf,int low,int high)
- {
- int i;
- if(low < high)
- {
- i = quickpart(pbuf,low,high);
- quicksort(pbuf,low,i-1);
- quicksort(pbuf,i+ 1,high);
- }
- }
- static int quickpart(KB_DBPrgInfo *pbuf,int i,int j)
- {
- KB_DBPrgInfo b;
-
- memcpy(&b,&pbuf[i],sizeof(KB_DBPrgInfo));
- while(i<j)
- {
- while(i<j && pbuf[j].SvcID >= b.SvcID)
- {
- j --;
- }
- if(i< j)
- memcpy(&pbuf[i++],&pbuf[j],sizeof(KB_DBPrgInfo));
-
- while(i<j && pbuf[i].SvcID <= b.SvcID)
- {
- i ++;
- }
- if(i<j)
- memcpy(&pbuf[j --],&pbuf[i],sizeof(KB_DBPrgInfo));
- }
-
- memcpy(&pbuf[i],&b,sizeof(KB_DBPrgInfo));
- return i;
- }
- KB_DBRET KB_DBSaveChlPatVer(UINT16 Freq,UINT8 patVer)
- {
- KB_DBRET ret = RET_FAIL;
- int i,find = 0;
-
- for(i = 0;i< gPrgAllInfo.gChnnlInfo.nTotal;i++)
- {
- if(Freq == gPrgAllInfo.gChnnlInfo.ChannelList[i].Freq)
- {
- find = 1;
- break;
- }
- }
-
- if(find == 1)
- {
- gPrgAllInfo.gChnnlInfo.ChannelList[i].PATVersion = patVer;
- ret = RET_OK;
- }
-
- return ret ;
- }
- KB_DBRET KB_DBSaveChlSdtVer(UINT16 Freq,UINT8 sdtVer)
- {
- KB_DBRET ret = RET_FAIL;
- int i,find = 0;
-
- for(i = 0;i< gPrgAllInfo.gChnnlInfo.nTotal;i++)
- {
- if(Freq == gPrgAllInfo.gChnnlInfo.ChannelList[i].Freq)
- {
- find = 1;
- break;
- }
- }
-
- if(find == 1)
- {
- gPrgAllInfo.gChnnlInfo.ChannelList[i].SDTVersion = sdtVer;
- ret = RET_OK;
- }
-
- return ret ;
- }
- KB_DBRET KB_DBSaveChlInfo(UINT8 addtype,UINT16 OrgNetID,UINT16 tsID,
- UINT16 Freq, UINT16 Symb,UINT8 QAM)
- {
- int i;
- for(i = 0;i< gPrgAllInfo.gChnnlInfo.nTotal;i++)
- {
- if(Freq == gPrgAllInfo.gChnnlInfo.ChannelList[i].Freq)
- {
- gPrgAllInfo.gChnnlInfo.ChannelList[i].TSID = tsID;
- gPrgAllInfo.gChnnlInfo.ChannelList[i].Freq = Freq;
- gPrgAllInfo.gChnnlInfo.ChannelList[i].Symb = Symb;
- gPrgAllInfo.gChnnlInfo.ChannelList[i].QAM = QAM;
- if(addtype == 0)
- {
- gPrgAllInfo.gChnnlInfo.ChannelList[i].NitAddType = addtype;
- }
- return RET_OK;
- }
- }
-
- if ( i >= KB_DB_MAX_CHANNEL_NUM )
- {
- return RET_FAIL;
- }
-
- gPrgAllInfo.gChnnlInfo.ChannelList[i].TSID = tsID;
- gPrgAllInfo.gChnnlInfo.ChannelList[i].OrgNetID = OrgNetID;
- gPrgAllInfo.gChnnlInfo.ChannelList[i].Freq = Freq;
- gPrgAllInfo.gChnnlInfo.ChannelList[i].Symb = Symb;
- gPrgAllInfo.gChnnlInfo.ChannelList[i].QAM = QAM;
- gPrgAllInfo.gChnnlInfo.ChannelList[i].NitAddType = addtype;
- gPrgAllInfo.gChnnlInfo.nTotal ++;
-
- return RET_OK;
- }
- KB_DBRET KD_GetNitInfo(unsigned char *o_pcNITName,
- UINT8 *NitVersion)
- {
- o_pcNITName = gE2pData.gNetInfo.NetworkName;
- *NitVersion = gE2pData.gNetInfo.NitVersion;
- return RET_OK;
- }
- KB_DBRET KB_DBSaveNitInfo(KB_DBNetInfo *ptNetworkInfo)
- {
-
- gE2pData.gNetInfo = *ptNetworkInfo;
-
- if (KB_E2PWrite(KB_NVM_NETWORK_INFO_ADDR, (UINT8 *)&gE2pData.gNetInfo, sizeof(KB_DBNetInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- UINT16 KB_DBGetPrgTotal(UINT8 nPrgType)
- {
- UINT16 ret = 0;
-
- if (nPrgType == DTVPRG)
- {
- ret = gPrgAllInfo.gDTVInfo.nTotal;
- }
- else if (nPrgType == RADIOPRG)
- {
- ret = gPrgAllInfo.gRADInfo.nTotal;
- }
- //added by whale 07/05/25 start
- else if (nPrgType == DATAPRG)
- {
- ret = gPrgAllInfo.gDATAInfo.nTotal;
- }
- //added by whale 07/05/25 end
- else
- {
- ret = 0;
- }
- if (ret == 65535)
- {
- ret = 0;
- }
- //--add by shriek gPrgAllInfo.gDATAInfo.nTotal=623669
- if(ret>=23669)
- ret = 0;
- //--end
- return ret;
- }
- UINT16 KB_DBGetFavPrgTotal(UINT8 nPrgType)
- {
- UINT16 ret = 0xffff;
- if(nPrgType != DTVPRG && nPrgType != RADIOPRG)
- {
- printf("nKB_DBGetFavPrgTotal::input PrgType(%d) error",
- nPrgType);
- return ret;
- }
-
- if (DTVPRG == nPrgType)
- {
- ret = gE2pData.gDTVFavInfo.nTotal;
- }
- else if (RADIOPRG == nPrgType)
- {
- ret = gE2pData.gRADFavInfo.nTotal;
- }
-
- return ret;
- }
- KB_DBRET KB_DBGetPrgInfo(UINT16 nPrgInx,
- UINT8 nPrgType,
- KB_DBPrgInfo *pPrgInfo,
- KB_DBChnnlInfo *pChnnlInfo,
- UINT8 *pTrack,
- UINT8 *pbVolume,
- UINT8 *pLockFlag)
- {
-
- UINT8 nConfigInfo = 0;
- UINT8 i;
- if((nPrgInx <0 ) || (nPrgInx >= KB_DBGetPrgTotal(nPrgType)))
- {
- return RET_FAIL;
- }
-
- if (nPrgType == DTVPRG)
- {
- memcpy(pPrgInfo,&gPrgAllInfo.gDTVInfo.PgmList[nPrgInx],sizeof(KB_DBPrgInfo));
-
- nConfigInfo = gE2pData.gDTVPrgCfgInfo[pPrgInfo->IndexOfConfigInfo].Lock_Track_Vol;
- }
- else if (nPrgType == RADIOPRG)
- {
- memcpy(pPrgInfo,&gPrgAllInfo.gRADInfo.PgmList[nPrgInx],sizeof(KB_DBPrgInfo));
-
- nConfigInfo = gE2pData.gRADPrgCfgInfo[pPrgInfo->IndexOfConfigInfo].Lock_Track_Vol;
- }
- //added by whale 07/05/25 start
- else if (nPrgType == DATAPRG)
- {
- memcpy(pPrgInfo,&gPrgAllInfo.gDATAInfo.PgmList[nPrgInx],sizeof(KB_DBPrgInfo));
-
- nConfigInfo = gE2pData.gDATAPrgCfgInfo[pPrgInfo->IndexOfConfigInfo].Lock_Track_Vol;
- }
- //added by whale 07/05/25 end
-
- *pLockFlag = (UINT8)((nConfigInfo >> 7) & 0x01);
- *pTrack = (UINT8)((nConfigInfo >> 5) & 0x03);
- *pbVolume = (UINT8)(nConfigInfo & 0x1F);
-
- for (i=0; i<gPrgAllInfo.gChnnlInfo.nTotal; i++)
- {
- if (nPrgType == DTVPRG)
- {
- if (gPrgAllInfo.gChnnlInfo.ChannelList[i].TSID
- == gPrgAllInfo.gDTVInfo.PgmList[nPrgInx].TSID)
- {
- break;
- }
- }
- else if (nPrgType == RADIOPRG)
- {
- if (gPrgAllInfo.gChnnlInfo.ChannelList[i].TSID
- == gPrgAllInfo.gRADInfo.PgmList[nPrgInx].TSID)
- {
- break;
- }
- }
- //added by whale 07/05/25 start
- else if (nPrgType == DATAPRG)
- {
- if (gPrgAllInfo.gChnnlInfo.ChannelList[i].TSID
- == gPrgAllInfo.gDATAInfo.PgmList[nPrgInx].TSID)
- {
- break;
- }
- }
- //added by whale 07/05/25 end
-
- }
- if (i < gPrgAllInfo.gChnnlInfo.nTotal)
- {
- memcpy(pChnnlInfo,
- &gPrgAllInfo.gChnnlInfo.ChannelList[i],
- sizeof(KB_DBChnnlInfo));
- }
- else
- {
- memset(pChnnlInfo,0,sizeof(KB_DBChnnlInfo));
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBGetAllPrgConfig(void)
- {
- UINT16 i, sum, indexofconfig;
- KB_DBPrgConfigNode *confignode;
-
- sum = gPrgAllInfo.gDTVInfo.nTotal;
- for (i = 0; i < sum; ++i)
- {
- indexofconfig = gPrgAllInfo.gDTVInfo.PgmList[i].IndexOfConfigInfo;
- confignode = &gE2pData.gDTVPrgCfgInfo[indexofconfig];
- if (confignode->Flag == CONFIG_USED + 1)
- {
- if (KB_E2PRead((UINT16)(KB_NVM_DTV_PGM_CFG_ADDR + indexofconfig * sizeof(KB_DBPrgConfigNode)),
- (UINT8 *)confignode, sizeof(KB_DBPrgConfigNode), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- }
- }
- sum = gPrgAllInfo.gRADInfo.nTotal;
- for (i = 0; i < sum; ++i)
- {
- indexofconfig = gPrgAllInfo.gRADInfo.PgmList[i].IndexOfConfigInfo;
- confignode = &gE2pData.gRADPrgCfgInfo[indexofconfig];
- if (confignode->Flag == CONFIG_USED + 1)
- {
- if (KB_E2PRead((UINT16)(KB_NVM_RAD_PGM_CFG_ADDR + indexofconfig * sizeof(KB_DBPrgConfigNode)),
- (UINT8 *)confignode, sizeof(KB_DBPrgConfigNode), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- }
- }
- //added by whale 07/05/25 start
- sum = gPrgAllInfo.gDATAInfo.nTotal;
- for (i = 0; i < sum; ++i)
- {
- indexofconfig = gPrgAllInfo.gDATAInfo.PgmList[i].IndexOfConfigInfo;
- confignode = &gE2pData.gDATAPrgCfgInfo[indexofconfig];
- if (confignode->Flag == CONFIG_USED + 1)
- {
- if (KB_E2PRead((UINT16)(KB_NVM_DATA_PGM_CFG_ADDR + indexofconfig * sizeof(KB_DBPrgConfigNode)),
- (UINT8 *)confignode, sizeof(KB_DBPrgConfigNode), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- }
- }
- //added by whale 07/05/25 end
-
- return RET_OK;
- }
- KB_DBRET KB_DBGetPrgConfig(UINT8 PrgType, UINT16 PrgNo)
- {
- UINT16 indexofconfig;
- UINT16 readstartaddress;
- UINT8 *confignode;
-
- if (PrgType == DTVPRG)
- {
- readstartaddress = KB_NVM_DTV_PGM_CFG_ADDR;
- indexofconfig = gPrgAllInfo.gDTVInfo.PgmList[PrgNo].IndexOfConfigInfo;
- confignode = (UINT8 *)&gE2pData.gDTVPrgCfgInfo[indexofconfig];
- }
- else if (PrgType == RADIOPRG)
- {
- readstartaddress = KB_NVM_RAD_PGM_CFG_ADDR;
- indexofconfig = gPrgAllInfo.gRADInfo.PgmList[PrgNo].IndexOfConfigInfo;
- confignode = (UINT8 *)&gE2pData.gRADPrgCfgInfo[indexofconfig];
- }
- //added by whale 07/05/25 start
- else if (PrgType == DATAPRG)
- {
- readstartaddress = KB_NVM_DATA_PGM_CFG_ADDR;
- indexofconfig = gPrgAllInfo.gDATAInfo.PgmList[PrgNo].IndexOfConfigInfo;
- confignode = (UINT8 *)&gE2pData.gDATAPrgCfgInfo[indexofconfig];
- }
- //added by whale 07/05/25 end
- if (KB_E2PRead((UINT16)(readstartaddress + indexofconfig * sizeof(KB_DBPrgConfigNode)),
- confignode, sizeof(KB_DBPrgConfigNode), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- return RET_OK;
- }
- UINT16 KB_DBGetSvcIDByNO(UINT8 prgType, UINT16 prgInx)
- {
- UINT16 service_id;
- switch (prgType)
- {
- case DTVPRG:
- service_id = gPrgAllInfo.gDTVInfo.PgmList[prgInx].SvcID;
- break;
- case RADIOPRG:
- service_id = gPrgAllInfo.gRADInfo.PgmList[prgInx].SvcID;
- break;
- //added by whale 07/05/25 start
- case DATAPRG:
- service_id = gPrgAllInfo.gDATAInfo.PgmList[prgInx].SvcID;
- break;
- //added by whale 07/05/25 end
- default:
- service_id = KB_DB_INVALID_PROGRAMNO;
- break;
- }
- return service_id;
- }
- UINT16 KD_GetPrgInxBySvcID(UINT8 PrgType, UINT16 ServiceID)
- {
- UINT16 i = 0, sum = 0;
-
- sum = KB_DBGetPrgTotal(PrgType);
- if (DTVPRG == PrgType)
- {
- for (i = 0; i < sum; ++i)
- {
- if (gPrgAllInfo.gDTVInfo.PgmList[i].SvcID == ServiceID)
- {
- return i;
- }
- }
- }
- else if (RADIOPRG== PrgType)
- {
- for (i = 0; i < sum; ++i)
- {
- if (gPrgAllInfo.gRADInfo.PgmList[i].SvcID == ServiceID)
- {
- return i;
- }
- }
- }
- //added by whale 07/05/25 start
- else if (DATAPRG== PrgType)
- {
- for (i = 0; i < sum; ++i)
- {
- if (gPrgAllInfo.gDATAInfo.PgmList[i].SvcID == ServiceID)
- {
- return i;
- }
- }
- }
- //added by whale 07/05/25 end
- else
- {
- return KB_DB_INVALID_PROGRAMNO;
- }
- return KB_DB_INVALID_PROGRAMNO;
-
- }
- KB_DBRET KB_DBGetFavPrgInfoByFavInx(UINT8 Favindex,
- UINT8 nPrgType,
- UINT16 *pwPrgInx,
- KB_DBPrgInfo *pPrgInfo,
- KB_DBChnnlInfo *pChnnlInfo,
- UINT8 *pTrack,
- UINT8 *pbVolume,
- UINT8 *pLockFlag)
- {
- if(pwPrgInx == NULL || pPrgInfo == NULL || pChnnlInfo == NULL
- || pTrack == NULL || pbVolume == NULL || pLockFlag == NULL)
- {
- return RET_FAIL;
- }
-
- if (nPrgType == DTVPRG)
- {
- *pwPrgInx = KD_GetPrgInxByTsidSvcID(nPrgType,
- gE2pData.gDTVFavInfo.FavList[Favindex].TsId,
- gE2pData.gDTVFavInfo.FavList[Favindex].SrvId);
- if (*pwPrgInx == KB_DB_INVALID_PROGRAMNO || KB_DBGetPrgInfo(*pwPrgInx, DTVPRG, pPrgInfo,
- pChnnlInfo, pTrack, pbVolume, pLockFlag) != RET_OK)
- {
- return RET_FAIL;
- }
- }
- else if (nPrgType == RADIOPRG)
- {
- *pwPrgInx = KD_GetPrgInxByTsidSvcID(nPrgType,
- gE2pData.gRADFavInfo.FavList[Favindex].TsId,
- gE2pData.gRADFavInfo.FavList[Favindex].SrvId);
- if (*pwPrgInx == KB_DB_INVALID_PROGRAMNO || KB_DBGetPrgInfo(*pwPrgInx, RADIOPRG, pPrgInfo,
- pChnnlInfo, pTrack, pbVolume, pLockFlag) != RET_OK)
- {
- return RET_FAIL;
- }
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBGetChlNoByModPara(UINT16 pFreq,UINT16 wSymb,
- UINT8 bQam,UINT8 *pbChannelNo)
- {
- UINT8 i;
-
- for (i = 0; i < gPrgAllInfo.gChnnlInfo.nTotal; ++i)
- {
- if (gPrgAllInfo.gChnnlInfo.ChannelList[i].Freq == pFreq
- && gPrgAllInfo.gChnnlInfo.ChannelList[i].Symb == wSymb
- && gPrgAllInfo.gChnnlInfo.ChannelList[i].QAM == bQam)
- {
- *pbChannelNo = i;
- return RET_OK;
- }
- }
-
- return RET_FAIL;
- }
- KB_DBRET KB_DBGetModParaByChlNo(UINT8 bChannelNo,UINT16 *pFre,
- UINT16 *pSymb,UINT8 *pQam)
-
- {
- *pFre = gPrgAllInfo.gChnnlInfo.ChannelList[bChannelNo].Freq;
- *pSymb = gPrgAllInfo.gChnnlInfo.ChannelList[bChannelNo].Symb;
- *pQam = gPrgAllInfo.gChnnlInfo.ChannelList[bChannelNo].QAM;
- return RET_OK;
- }
- KB_DBRET KB_DBGetSrchInfo(KB_DBSrchInfo *pSrchInfo)
- {
- *pSrchInfo = gE2pData.gSrchInfo;
- return RET_OK;
- }
- KB_DBRET KB_DBSaveSrchInfo(KB_DBSrchInfo *pSrchInfo)
- {
- gE2pData.gSrchInfo = *pSrchInfo;
-
- if (KB_E2PWrite(KB_NVM_SEARCH_INFO_ADDR, (UINT8 *)&gE2pData.gSrchInfo, sizeof(KB_DBSrchInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBGetCurPrgInfo(unsigned short *pPrgNO, unsigned char *pPrgType)
- {
- *pPrgNO = gE2pData.gCurPrgInfo.prgNO;
- *pPrgType = gE2pData.gCurPrgInfo.prgType;
- return RET_OK;
- }
- KB_DBRET KB_DBGetTsIDByFre(UINT16 *TsID,unsigned long Fre)
- {
- int i;
-
- if(TsID == NULL)
- {
- return RET_FAIL;
- }
-
- for(i = 0;i< gPrgAllInfo.gChnnlInfo.nTotal;i++)
- {
- if(gPrgAllInfo.gChnnlInfo.ChannelList[i].Freq == Fre)
- {
- *TsID = gPrgAllInfo.gChnnlInfo.ChannelList[i].TSID;
- return RET_OK;
- }
- }
-
- return RET_FAIL;
- }
- KB_DBRET KB_DBSaveCurPrgInfo(UINT16 nPrgNO, UINT8 nPrgType)
- {
-
- gE2pData.gCurPrgInfo.prgNO = nPrgNO;
- gE2pData.gCurPrgInfo.prgType= nPrgType;
-
- if(KB_E2PWrite(KB_NVM_CUR_PGM_ADDR, (UINT8 *)&gE2pData.gCurPrgInfo, sizeof(KB_DBCurPrgInd), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBSavePrgAVPara(UINT16 nPrgNO, UINT8 nPrgType,unsigned short nPcrPID,
- unsigned short nAudioPID,
- unsigned short nVideoPID)
- {
- unsigned short totalChannels;
-
- switch(nPrgType)
- {
- case RADIOPRG:
- totalChannels = KB_DBGetPrgTotal(nPrgType);
- if(nPrgNO > totalChannels || nPrgNO == 0)
- return RET_FAIL;
-
- gPrgAllInfo.gRADInfo.PgmList[nPrgNO - 1].AudioPID = nAudioPID;
- gPrgAllInfo.gRADInfo.PgmList[nPrgNO - 1].VideoPID = nVideoPID;
- gPrgAllInfo.gRADInfo.PgmList[nPrgNO - 1].PCRPID = nPcrPID;
-
- break;
- //added by whale 07/05/25 start
- case DATAPRG:
- totalChannels = KB_DBGetPrgTotal(nPrgType);
- if(nPrgNO > totalChannels || nPrgNO == 0)
- return RET_FAIL;
-
- gPrgAllInfo.gDATAInfo.PgmList[nPrgNO - 1].AudioPID = nAudioPID;
- gPrgAllInfo.gDATAInfo.PgmList[nPrgNO - 1].VideoPID = nVideoPID;
- gPrgAllInfo.gDATAInfo.PgmList[nPrgNO - 1].PCRPID = nPcrPID;
-
- break;
- //added by whale 07/05/25 end
- default:
- totalChannels = KB_DBGetPrgTotal(nPrgType);
- if(nPrgNO > totalChannels || nPrgNO == 0)
- return RET_FAIL;
-
- gPrgAllInfo.gDTVInfo.PgmList[nPrgNO - 1].AudioPID = nAudioPID;
- gPrgAllInfo.gDTVInfo.PgmList[nPrgNO - 1].VideoPID = nVideoPID;
- gPrgAllInfo.gDTVInfo.PgmList[nPrgNO - 1].PCRPID = nPcrPID;
-
- break;
- }
- return RET_OK;
- }
- KB_DBRET KB_DBChangePrgInfo(UINT16 nPrgInx, UINT8 nPrgType,
- KB_DBPrgInfo *pPrgInfo)
- {
-
- if (nPrgType == DTVPRG)
- {
- gPrgAllInfo.gDTVInfo.PgmList[nPrgInx] = *pPrgInfo;
-
- if (KB_FlashWrite(KB_DB_SECTOR, 0, (UINT8*)&gPrgAllInfo, sizeof(KB_DBPrgAllInfo)) != RETOK)
- {
- return RET_FAIL;
- }
- }
- else if (nPrgType == RADIOPRG)
- {
- gPrgAllInfo.gRADInfo.PgmList[nPrgInx] = *pPrgInfo;
-
- if (KB_FlashWrite(KB_DB_SECTOR, 0, (UINT8*)&gPrgAllInfo, sizeof(KB_DBPrgAllInfo)) != RETOK)
- {
- return RET_FAIL;
- }
- }
- //added by whale 07/05/25 start
- else if (nPrgType == DATAPRG)
- {
- gPrgAllInfo.gDATAInfo.PgmList[nPrgInx] = *pPrgInfo;
-
- if (KB_FlashWrite(KB_DB_SECTOR, 0, (UINT8*)&gPrgAllInfo, sizeof(KB_DBPrgAllInfo)) != RETOK)
- {
- return RET_FAIL;
- }
- }
- //added by whale 07/05/25 end
- return RET_OK;
- }
- static void KD_AddPrgToBuffer(UINT8 nPrgType, KB_DBPrgInfo *pPrgInfo)
- {
- UINT16 indexofconfig;
- KB_DBPrgConfigNode *ptConfigNode;
- KB_DBPrgInfo *ptPgmNode;
-
- if (nPrgType == DTVPRG)
- {
- ptPgmNode = &gPrgAllInfo.gDTVInfo.PgmList[gPrgAllInfo.gDTVInfo.nTotal];
-
- indexofconfig = KD_GetFreeNumCfg(DTVPRG);
-
- gDtvCfgFlag[indexofconfig] = 1;
- ptConfigNode = &gE2pData.gDTVPrgCfgInfo[indexofconfig];
-
- ++gPrgAllInfo.gDTVInfo.nTotal;
- }
- else if (nPrgType == RADIOPRG)
- {
- ptPgmNode = &gPrgAllInfo.gRADInfo.PgmList[gPrgAllInfo.gRADInfo.nTotal];
-
- indexofconfig = KD_GetFreeNumCfg(RADIOPRG);
- gRadCfgFlag[indexofconfig] = 1;
- ptConfigNode = &gE2pData.gRADPrgCfgInfo[indexofconfig];
-
- ++gPrgAllInfo.gRADInfo.nTotal;
- }
- //added by whale 07/05/25 start
- else if (nPrgType == DATAPRG)
- {
- ptPgmNode = &gPrgAllInfo.gDATAInfo.PgmList[gPrgAllInfo.gDATAInfo.nTotal];
-
- indexofconfig = KD_GetFreeNumCfg(DATAPRG);
- gDataCfgFlag[indexofconfig] = 1;
- ptConfigNode = &gE2pData.gRADPrgCfgInfo[indexofconfig];
-
- ++gPrgAllInfo.gDATAInfo.nTotal;
- }
- //added by whale 07/05/25 end
- ptConfigNode->Lock_Track_Vol = 0x14;
- ptConfigNode->Flag = CONFIG_USED;
- ptPgmNode->IndexOfConfigInfo = indexofconfig;
- }
- void KB_DBAddPrgInfo(KB_DBPrgNode *prginfo,UINT16 prgSum,
- unsigned short *addDtv, unsigned short *addMusic)
- {
- int i, j;
- UINT16 prgtotal,prgMax;
- int found = 0;
- int len = 0;
- UINT8 prgType;
- unsigned short addDtvprg = 0,addMusicprg = 0;
-
- KB_DBPrgInfo *prgInfoPos = NULL;
-
- for(i = 0; i < prgSum; i ++)
- {
- if(prginfo[i].PATVersion != KB_DB_UNKNOWN_VERSION
- && prginfo[i].PMTVersion != KB_DB_UNKNOWN_VERSION)
- {
- //预防没有SDT下发的情况Srv_name,Srv_type,bCAFlag的设置,但是按现在的流程是走不到的
- if(prginfo[i].SDTVersion == KB_DB_UNKNOWN_VERSION)
- {
- strcpy(prginfo[i].name, "未知节目名");
- prginfo[i].bCAFlag = 0;
- if((prginfo[i].Video_Pid != 0)
- && (prginfo[i].Audio_Pid != 0)
- && (prginfo[i].PCR_Pid != 0))
- {
- prginfo[i].service_type = 0x01;
- }
- else if(prginfo[i].Video_Pid == 0
- && prginfo[i].Audio_Pid != 0
- && prginfo[i].PCR_Pid != 0)
- {
- prginfo[i].service_type = 0x02;
- }
- else
- {
- prginfo[i].service_type = 0;
- }
- }
- //printf("-=prginfo[%d].service_type=0x%x=-n", i, prginfo[i].service_type);
- switch(prginfo[i].service_type)
- {
- case 0x01:
- case 0x02:
- //added by whale 07/05/25
- case 0x0C:
- if(prginfo[i].service_type == 0x01)
- {
- prgInfoPos = gPrgAllInfo.gDTVInfo.PgmList;
- prgMax = KB_DB_MAX_DTV;
- prgtotal = gPrgAllInfo.gDTVInfo.nTotal;
- prgType = DTVPRG;
- addDtvprg++;
- }
- else if(prginfo[i].service_type == 0x02)
- {
- prgInfoPos = gPrgAllInfo.gRADInfo.PgmList;
- prgMax = KB_DB_MAX_RAD;
- prgtotal = gPrgAllInfo.gRADInfo.nTotal;
- prgType = RADIOPRG;
- addMusicprg ++;
- }
- //added by whale 07/05/25 start
- else if(prginfo[i].service_type == 0x0C)
- {
- prgInfoPos = gPrgAllInfo.gDATAInfo.PgmList;
- prgMax = KB_DB_MAX_DATA;
- prgtotal = gPrgAllInfo.gDATAInfo.nTotal;
- prgType = DATAPRG;
- //printf("-=prgtotal=%d, prgType=%d=-n", prgtotal, prgType);
- }
- //added by whale 07/05/25 end
- if(prgInfoPos == NULL)
- {
- return;
- }
-
- if(prgtotal >= prgMax)
- {
- return;
- }
- for(j = 0; j < prgtotal; j++)
- {
- if( prgInfoPos[j].TSID == prginfo[i].TSID)
- {
- if(prgInfoPos[j].SvcID != prginfo[i].SerID)
- {
- continue;
- }
- prgInfoPos[j].AudioPID = prginfo[i].Audio_Pid;
- prgInfoPos[j].PCRPID = prginfo[i].PCR_Pid;
- prgInfoPos[j].VideoPID = prginfo[i].Video_Pid;
- prgInfoPos[j].ScrambleFlag = prginfo[i].bCAFlag;
- len = strlen(prginfo[i].name);
- if(len >= 20)
- {
- len = 18;
- }
- memset(prgInfoPos[j].Name,0,20);
- memcpy(prgInfoPos[j].Name,prginfo[i].name,len);
- prgInfoPos[j].Name[len] = ' ';
- prgInfoPos[j].Name[len + 1] = ' ';
- found = 1;
- break;
- }
- }
-
- if(found == 1)
- {
- found = 0;
- continue;
- }
-
- prgInfoPos[j].TSID = prginfo[i].TSID;
- prgInfoPos[j].PMTPID = prginfo[i].PMTPid;
- prgInfoPos[j].PMTVersion = prginfo[i].PMTVersion;
- prgInfoPos[j].SvcID = prginfo[i].SerID;
- prgInfoPos[j].VideoPID = prginfo[i].Video_Pid;
- prgInfoPos[j].AudioPID = prginfo[i].Audio_Pid;
- prgInfoPos[j].PCRPID= prginfo[i].PCR_Pid;
- prgInfoPos[j].ScrambleFlag = prginfo[i].bCAFlag;
-
- len = strlen(prginfo[i].name);
- if(len >= 18)
- {
- len = 18;
- }
-
- memset(prgInfoPos[j].Name,0,20);
- memcpy(prgInfoPos[j].Name,prginfo[i].name,len);
- prgInfoPos[j].Name[len] = ' ';
- prgInfoPos[j].Name[len + 1] = ' ';
- //IndexOfConfigInfo是 gPrgAllInfo中业务 与 gE2pData 联系的索引
- //仅在下面函数申请连接一次,并更新全局数组gDtvCfgFlag/gRadCfgFlag/gDataCfgFlag
- // 更新gPrgAllInfo中某业务类型的nTotal
- KD_AddPrgToBuffer(prgType,NULL);
-
- break;
- case 0x04:
- case 0x05:
- break;
- //masked by whale 07/05/25 start
- //case 0x0C:
- // break;
- //masked by whale 07/05/25 end
- }
- }
- }
-
- *addDtv = addDtvprg;
- *addMusic = addMusicprg;
- return;
- }
- KB_DBRET KB_DBSavePrgInfo(int saveType)
- {
- int i;
-
- if(saveType == 1)
- {
- //quicksort(gPrgAllInfo.gDTVInfo.PgmList,0,gPrgAllInfo.gDTVInfo.nTotal - 1);
- //quicksort(gPrgAllInfo.gRADInfo.PgmList,0,gPrgAllInfo.gRADInfo.nTotal - 1);
- //added by whale 07/05/25
- //quicksort(gPrgAllInfo.gDATAInfo.PgmList,0,gPrgAllInfo.gDATAInfo.nTotal - 1);
- //KB_DBSavePrgFavFlag(2,0,DTVPRG,NULL);
- //KB_DBSavePrgFavFlag(2,0,RADIOPRG,NULL);
- }
-
- KB_DBSaveToFlash();
- KB_DBFavPrgRefresh();
-
- for (i = 0; i < KB_DB_MAX_DTV; ++i)
- {
- if (gDtvCfgFlag[i] == 1)
- {
- if (KB_E2PWrite((UINT16)(KB_NVM_DTV_PGM_CFG_ADDR + i * sizeof(KB_DBPrgConfigNode)),
- (UINT8 *)&gE2pData.gDTVPrgCfgInfo[i],
- sizeof(KB_DBPrgConfigNode), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- }
- }
-
- for (i = 0; i < KB_DB_MAX_RAD; ++i)
- {
- if (gRadCfgFlag[i] == 1)
- {
- if (KB_E2PWrite((UINT16)(KB_NVM_RAD_PGM_CFG_ADDR + i * sizeof(KB_DBPrgConfigNode)),
- (UINT8 *)&gE2pData.gRADPrgCfgInfo[i],
- sizeof(KB_DBPrgConfigNode), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- }
- }
- //added by whale 07/05/25 start
- for (i = 0; i < KB_DB_MAX_DATA; ++i)
- {
- if (gDataCfgFlag[i] == 1)
- {
- if (KB_E2PWrite((UINT16)(KB_NVM_DATA_PGM_CFG_ADDR + i * sizeof(KB_DBPrgConfigNode)),
- (UINT8 *)&gE2pData.gDATAPrgCfgInfo[i],
- sizeof(KB_DBPrgConfigNode), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- }
- }
- //added by whale 07/05/25 end
- KD_InitPrgConfig();
-
- return RET_OK;
- }
- static BOOL KB_DBIsPrgExist(UINT8 PrgType,
- UINT16 TsId,
- UINT16 SrvId)
- {
- UINT16 i = 0;
- UINT16 max = 0;
- UINT16 total = 0;
- BOOL ret = FALSE;
- KB_DBPrgInfo *prgInfo;
-
- switch(PrgType)
- {
- case DTVPRG:
- total = gPrgAllInfo.gDTVInfo.nTotal;
- max = KB_DB_MAX_DTV;
- prgInfo = gPrgAllInfo.gDTVInfo.PgmList;
- break;
-
- case RADIOPRG:
- total = gPrgAllInfo.gRADInfo.nTotal;
- max = KB_DB_MAX_RAD;
- prgInfo = gPrgAllInfo.gRADInfo.PgmList;
- break;
- default:
- printf("nKB_DBCheckPrgByTsIdSrvId::PrgType(%d) not support",
- PrgType);
- return FALSE;
- }
-
- if ((NULL == prgInfo) || (0 == total) || (total > max))
- {
- printf("nKB_DBCheckPrgByTsIdSrvId::unknown error! prgInfo(0x%x), total(%d)",
- prgInfo, total);
- return FALSE;
- }
-
- for(i = 0;i<total;i++)
- {
- if (prgInfo[i].SvcID == SrvId
- && prgInfo[i].TSID == TsId)
- {
- ret = TRUE;
- break;
- }
- }
- return ret;
- }
- #if 0
- KB_DBRET KB_DBSavePrgFavFlag(UINT8 FavType,UINT16 nNumPrg, UINT8 nPrgType, UINT16 *pPrgToAdd)
- {
- int total = 0;
- UINT8 *favTotal = NULL,numprg;
- int i,j,writeLen = 0,writeLen2 = 0;
- KB_DBFavNode *favPrgNo = NULL;
- UINT16 addrFav;
- UINT8 *writeAddr = NULL;
- UINT8 *writeAddr2 = NULL;
- KB_DBPrgInfo programInfo;
- KB_DBChnnlInfo channelInfo;
- UINT8 track;
- UINT8 volume;
- UINT8 lockFlag;
-
- if((pPrgToAdd == NULL) && (FavType != 2))
- {
- return RET_FAIL;
- }
-
- if(nPrgType != DTVPRG && nPrgType != RADIOPRG)
- {
- return RET_FAIL;
- }
-
- switch(nPrgType)
- {
- case DTVPRG:
- total = KB_DB_MAX_FAV_DTV;
- favTotal = &gE2pData.gDTVFavInfo.nTotal;
- favPrgNo = gE2pData.gDTVFavInfo.FavList;
- addrFav = KB_NVM_FAV_DTV_ADDR;
- writeAddr = (UINT8 *)&gE2pData.gDTVFavInfo;
- writeLen = sizeof(KB_DBFavDtvInfo);
- writeAddr2 = (UINT8 *)&gE2pData.gDTVFavInfo;
- writeLen2 = sizeof(KB_DBFavDtvInfo);
- break;
-
- case RADIOPRG:
- total = KB_DB_MAX_FAV_RAD;
- favTotal = &gE2pData.gRADFavInfo.nTotal;
- favPrgNo = gE2pData.gRADFavInfo.FavList;
- addrFav = KB_NVM_FAV_RAD_ADDR;
- writeAddr = (UINT8*)&gE2pData.gRADFavInfo;
- writeLen = sizeof(KB_DBPrgConfigNode);
- writeAddr2 = (UINT8 *)&gE2pData.gRADFavInfo;
- writeLen2 = sizeof(KB_DBFavRadInfo);
- break;
- }
-
- switch(FavType)
- {
- case 0:
- *favTotal = 0;
- numprg = 1;
- for( i = 1; i<= nNumPrg;i++)
- {
- if((pPrgToAdd[i] == KB_DB_PGM_FAVORITE) && ( numprg < total))
- {
- if (KB_DBGetPrgInfo(i - 1, nPrgType, &programInfo, &channelInfo, &track, &volume, &lockFlag) == RET_OK)
- {
- favPrgNo[numprg].TsId = programInfo.TSID;
- favPrgNo[numprg].SrvId = programInfo.SvcID;
- *favTotal = numprg;
- numprg ++;
- }
- }
- }
- break;
-
- case 1:
- for( i = 1; i<= nNumPrg;i++)
- {
- {
- favPrgNo[i ] = pPrgToAdd[i];
- }
- }
- break;
- case 2:
- numprg = *favTotal;
- for(i = 1;i <= numprg ;)
- {
- if(KB_DBIsPrgExist(nPrgType, favPrgNo[i].TsId, favPrgNo[i].SrvId) == FALSE)
- {
- j = i;
- for(j = i;j < numprg - 1 ;j++)
- {
- favPrgNo[j] = favPrgNo[j + 1];
- }
- numprg --;
- }
- else
- {
- i++;
- }
- }
- *favTotal = numprg;
- break;
- default:
- break;
- }
-
- if(KB_E2PWrite(addrFav, writeAddr, writeLen, NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- #endif
- KB_DBRET KB_DBGetSysPara(KB_DBSysInfo *pSysPara)
- {
- *pSysPara = gE2pData.gSysPara;
- return RET_OK;
- }
- KB_DBRET KB_DBSaveSysPara(KB_DBSysInfo *pSysPara)
- {
-
- gE2pData.gSysPara = *pSysPara;
-
- if (KB_E2PWrite(KB_NVM_SYS_PARA_ADDR, (UINT8 *)&gE2pData.gSysPara, sizeof(KB_DBSysInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBGetPwdInfo(KB_DBPwdInfo *pPwdInfo)
- {
- *pPwdInfo = gE2pData.gPwdInfo;
-
- return RET_OK;
- }
- void KB_DBDelFavPrg(unsigned char type, UINT16 TsId, UINT16 SrvId)
- {
- UINT8 find = 0;
- UINT16 i = 0;
- UINT16 j = 0;
- UINT16 nTotalNo = 0;
-
- nTotalNo = KB_DBGetFavPrgTotal(type) ;
-
- if (DTVPRG == type)
- {
- if (nTotalNo == 0 || nTotalNo > KB_DB_MAX_FAV_DTV)
- {
- printf("nKB_DBDelFavPrg::dtv Total(%d) error", nTotalNo);
- return;
- }
-
- for(i = 0; i < nTotalNo; i++)
- {
- if(TsId == gE2pData.gDTVFavInfo.FavList[i].TsId
- && SrvId == gE2pData.gDTVFavInfo.FavList[i].SrvId)
- {
- find = 1;
- break;
- }
- }
-
- if (1 == find)
- {
- for(j = i; j < (nTotalNo - 1); j++)
- {
- memcpy(&gE2pData.gDTVFavInfo.FavList[j],
- &gE2pData.gDTVFavInfo.FavList[j+1],
- sizeof(KB_DBFavNode));
- }
- gE2pData.gDTVFavInfo.nTotal --;
-
- if(KB_E2PWrite(KB_NVM_FAV_DTV_ADDR, ( UINT8 *)&gE2pData.gDTVFavInfo, sizeof(KB_DBFavDtvInfo), NULL) != RETOK)
- {
- printf("nKB_DBDelFavPrg::KB_E2PWrite dtv fail");
- return ;
- }
-
- }
- else
- {
- printf("nKB_DBDelFavPrg::specified type(0x%x)-TsId(0x%x)-SrvId(0x%x) not found in gE2pData",
- type, TsId, SrvId);
- }
- return;
- }
- else if (RADIOPRG == type)
- {
- if (nTotalNo == 0 || nTotalNo > KB_DB_MAX_FAV_RAD)
- {
- printf("nKB_DBDelFavPrg::radio Total(%d) error", nTotalNo);
- return;
- }
-
- for(i = 0; i < nTotalNo;i++)
- {
- if(TsId == gE2pData.gRADFavInfo.FavList[i].TsId
- && SrvId == gE2pData.gRADFavInfo.FavList[i].SrvId)
- {
- find = 1;
- break;
- }
- }
-
- if(1 == find)
- {
- for(j = i; j < (nTotalNo - 1); j++)
- {
- memcpy(&gE2pData.gRADFavInfo.FavList[j],
- &gE2pData.gRADFavInfo.FavList[j+1],
- sizeof(KB_DBFavNode));
- }
- gE2pData.gRADFavInfo.nTotal -- ;
-
- if(KB_E2PWrite(KB_NVM_FAV_DTV_ADDR, ( UINT8 *)&gE2pData.gRADFavInfo, sizeof(KB_DBPrgConfigNode), NULL) != RETOK)
- {
- printf("nKB_DBDelFavPrg::KB_E2PWrite rad fail");
- return ;
- }
- }
- else
- {
- printf("nKB_DBDelFavPrg::specified type(0x%x)-TsId(0x%x)-SrvId(0x%x) not found in gE2pData",
- type, TsId, SrvId);
- }
- return;
- }
- else
- {
- printf("nKB_DBDelFavPrg::input type(%d) error", type);
- return;
- }
-
- return;
- }
- unsigned short KB_DBDelPrgInfo(unsigned char type,unsigned short nPrgInx)
- {
- int nPgmNo = nPrgInx,i;
- int total;
- KB_DBPrgInfo *tmpPrgInfo = NULL;
- UINT16 SerID;
-
- total = KB_DBGetPrgTotal(type);
-
- if(nPgmNo >= total || nPgmNo < 0)
- {
- return KB_DB_DTV_FAILURE;
- }
-
- if (DTVPRG == type)
- {
- tmpPrgInfo = gPrgAllInfo.gDTVInfo.PgmList;
- }
- else if (RADIOPRG == type)
- {
- tmpPrgInfo = gPrgAllInfo.gRADInfo.PgmList;
- }
- else
- {
- printf("nKB_DBDelPrgInfo::input PrgType(%d) error!", type);
- return KB_DB_DTV_FAILURE;
- }
- SerID = tmpPrgInfo[nPgmNo].SvcID;
- KB_DBDelFavPrg(type, tmpPrgInfo[nPgmNo].TSID, SerID);
-
- for(i = nPgmNo;i < total - 1; i++)
- {
- memcpy(&tmpPrgInfo[i],&tmpPrgInfo[i + 1],sizeof(KB_DBPrgInfo));
- }
-
- if (DTVPRG == type)
- {
- gPrgAllInfo.gDTVInfo.nTotal --;
- }
- else if (RADIOPRG == type)
- {
- gPrgAllInfo.gRADInfo.nTotal --;
- }
- return KB_DB_DTV_SUCCESS;
- }
- KB_DBRET KB_DBSavePwdInfo(KB_DBPwdInfo *pPwdInfo)
- {
- gE2pData.gPwdInfo = *pPwdInfo;
-
- if (KB_E2PWrite(KB_NVM_PASSWORD_ADDR, (UINT8* )&gE2pData.gPwdInfo, sizeof(KB_DBPwdInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBGetMailNum(UINT8 *pMailNum)
- {
- if(pMailNum == NULL)
- {
- return RET_FAIL;
- }
-
- *pMailNum = gE2pData.gMailInfo.nTotal;
- return RET_OK;
- }
- KB_DBRET KB_DBSaveNvodInfo(KB_SIRefSvcCell AddNvodInfo)
- {
- int total,i;
- total = gPrgAllInfo.gNVODInfo.nTotal;
-
- if(total >= KB_DB_MAX_NVOD)
- {
- return RET_FAIL;
- }
- //added by whale 07/03/28 for judging refsvcid repeat
- for (i=0; i<total; i++)
- {
- if (gPrgAllInfo.gNVODInfo.RefSvc[i].RefSvcId == AddNvodInfo.refScvId)
- {
- return RET_FAIL;
- }
- }
- //add end
- gPrgAllInfo.gNVODInfo.RefSvc[total].RefSvcId = AddNvodInfo.refScvId;
- strcpy((char*)gPrgAllInfo.gNVODInfo.RefSvc[total].RefSvcName,(char*)AddNvodInfo.refScvName);
- gPrgAllInfo.gNVODInfo.RefSvc[total].TsID = AddNvodInfo.TsID;
- gPrgAllInfo.gNVODInfo.RefSvc[total].ShiftNum = 0;
-
- for(i = 0;i< AddNvodInfo.shiftSvcNum;i++)
- {
- gPrgAllInfo.gNVODInfo.RefSvc[total].ShiftList[i].ServiceId =
- AddNvodInfo.shiftSvc[i].svcId;
- gPrgAllInfo.gNVODInfo.RefSvc[total].ShiftList[i].TSID=
- AddNvodInfo.shiftSvc[i].tsId;
- gPrgAllInfo.gNVODInfo.RefSvc[total].ShiftNum ++;
- }
- gPrgAllInfo.gNVODInfo.nTotal ++;
- return RET_OK;
- }
- /*KB_DBRET KD_GetNvodNum(UINT8 *pNvodNum)
- {
- *pNvodNum = gPrgAllInfo.gNVODInfo.nTotal;
- return RET_OK;
- }*/
- UINT8 KB_DBGetNvodNum(void)
- {
- return gPrgAllInfo.gNVODInfo.nTotal;
- }
- KB_DBRET KB_DBGetNvodInfo(KB_SIRefSvcCell * pRefSvcInfo, int * o_pNums)
- {
- int i,total,j;
-
- if((pRefSvcInfo == NULL ) || (o_pNums == NULL))
- {
- return RET_FAIL;
- }
-
- total = gPrgAllInfo.gNVODInfo.nTotal;
- * o_pNums = total;
-
- for(i = 0;i<total;i++)
- {
- pRefSvcInfo[i].refScvId = gPrgAllInfo.gNVODInfo.RefSvc[i].RefSvcId;
- strcpy((char*)pRefSvcInfo[i].refScvName,
- (char*)gPrgAllInfo.gNVODInfo.RefSvc[i].RefSvcName);
- pRefSvcInfo[i].TsID = gPrgAllInfo.gNVODInfo.RefSvc[i].TsID;
- pRefSvcInfo[i].shiftSvcNum = gPrgAllInfo.gNVODInfo.RefSvc[i].ShiftNum;
- KB_DBGetChnlInfoByTsID(pRefSvcInfo[i].TsID,
- &pRefSvcInfo[i].freq,&pRefSvcInfo[i].symb,(UINT8*)&pRefSvcInfo[i].qam);
-
- for( j = 0;j < gPrgAllInfo.gNVODInfo.RefSvc[i].ShiftNum;j++)
- {
- pRefSvcInfo[i].shiftSvc[j].svcId = gPrgAllInfo.gNVODInfo.RefSvc[i].ShiftList[j].ServiceId;
- pRefSvcInfo[i].shiftSvc[j].tsId = gPrgAllInfo.gNVODInfo.RefSvc[i].ShiftList[j].TSID;
- }
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBGetChnlInfoByTsID(UINT16 TSID,
- unsigned short *pFreq,unsigned short *pSymbl,unsigned char *pQam)
- {
- int i,find = 0;
-
- if( (pFreq == NULL) || (pSymbl == NULL) || (pQam == NULL))
- {
- return RET_FAIL;
- }
-
- for(i = 0;i< gPrgAllInfo.gChnnlInfo.nTotal;i++)
- {
- if(gPrgAllInfo.gChnnlInfo.ChannelList[i].TSID == TSID)
- {
- find = 1;
- break;
- }
- }
-
- if(find == 1)
- {
- *pFreq = gPrgAllInfo.gChnnlInfo.ChannelList[i].Freq;
- *pSymbl = gPrgAllInfo.gChnnlInfo.ChannelList[i].Symb;
- *pQam = gPrgAllInfo.gChnnlInfo.ChannelList[i].QAM;
- }
- else
- {
- *pFreq = 0;
- *pSymbl = 0;
- *pQam = 0;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBSaveToFlash()
- {
-
- if (KB_FlashWrite(KB_DB_SECTOR, 0, (UINT8*)&gPrgAllInfo, sizeof(KB_DBPrgAllInfo)) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- static UINT16 KD_GetFreeNumCfg(UINT8 nPrgType)
- {
- UINT16 i;
-
- switch(nPrgType)
- {
- case DTVPRG:
- for (i = 0; i < KB_DB_MAX_DTV; ++i)
- {
- if(gE2pData.gDTVPrgCfgInfo[i].Flag == CONFIG_NO_USED)
- {
- return i;
- }
- }
- break;
-
- case RADIOPRG:
- for (i = 0; i < KB_DB_MAX_RAD; ++i)
- {
- if(gE2pData.gRADPrgCfgInfo[i].Flag == CONFIG_NO_USED)
- {
- return i;
- }
- }
- break;
- //added by whale 07/05/25 start
- case DATAPRG:
- for (i = 0; i < KB_DB_MAX_DATA; ++i)
- {
- if(gE2pData.gDATAPrgCfgInfo[i].Flag == CONFIG_NO_USED)
- {
- return i;
- }
- }
- break;
- //added by whale 07/05/25 end
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBReset(void)
- {
- KB_DBRET tRet;
-
- gPrgAllInfo.gChnnlInfo.nTotal = 0;
- memset(&gPrgAllInfo.gChnnlInfo,0,sizeof(KB_DBDTVChnnlInfo));
- if (KB_DBResetDtvInfo(BufferSave) != RET_OK)
- {
- printf("n[DB]:KB_DBResetDtvInfo error");
- return RET_FAIL;
- }
-
- if (KD_ResetFavDtv() != RET_OK)
- {
- printf("n[DB]:KD_ResetFavDtv error");
- return RET_FAIL;
- }
-
- if (KB_DBResetRadInfo(BufferSave) != RET_OK)
- {
- printf("n[DB]:KB_DBResetRadInfo error");
- return RET_FAIL;
- }
-
- if (KD_ResetFavRad() != RET_OK)
- {
- printf("n[DB]:KD_ResetFavRad error");
- return RET_FAIL;
- }
- //added by whale 07/05/25 start
- if (KB_DBResetDataInfo(BufferSave) != RET_OK)
- {
- printf("n[DB]:KB_DBResetDataInfo error");
- return RET_FAIL;
- }
- //added by whale 07/05/25 end
- KD_ResetNvodInfo(BufferSave);
-
- tRet = KD_ResetCurPrgInfo();
- if (tRet != RET_OK)
- {
- printf("n[DB]:KD_ResetCurPrgInfo error");
- return tRet;
- }
- tRet = KD_ResetSysparInfo();
- if (tRet != RET_OK)
- {
- printf("n[DB]:KD_ResetSysparInfo error");
- return tRet;
- }
-
- tRet = KD_ResetPwdInfo();
- if (tRet != RET_OK)
- {
- printf("n[DB]:KD_ResetPwdInfo error");
- return tRet;
- }
-
-
- tRet = KD_ResetSrchInfo();
- if (tRet != RET_OK)
- {
- printf("n[DB]:KD_ResetSrchInfo error");
- return tRet;
- }
-
- tRet = KD_ResetMailInfo();
- if (tRet != RET_OK)
- {
- printf("n[DB]:KD_ResetMailInfo error");
- return tRet;
- }
-
- //added by yyj 2007.6.27 start
- tRet = KD_ResetVideoDispMode();
- if (tRet != RET_OK)
- {
- printf("n[DB]:KD_ResetVideoDispMode error");
- return tRet;
- }
- tRet = KD_ResetVideoAspectRatio();
- if (tRet != RET_OK)
- {
- printf("n[DB]:KD_ResetVideoAspectRatio error");
- return tRet;
- }
- tRet = KD_ResetPgmCurVol();
- if (tRet != RET_OK)
- {
- printf("n[DB]:KD_ResetPgmCurVol error");
- return tRet;
- }
- tRet = KD_ResetPgmCurTrack();
- if (tRet != RET_OK)
- {
- printf("n[DB]:KD_ResetPgmCurTrack error");
- return tRet;
- }
- tRet = KD_ResetAdultRank();
- if (tRet != RET_OK)
- {
- printf("n[DB]:KD_ResetAdultRank error");
- return tRet;
- }
- tRet = KD_ResetMenuLan();
- if (tRet != RET_OK)
- {
- printf("n[DB]:KD_ResetMenuLan error");
- return tRet;
- }
- tRet = KD_ResetMenuTran();
- if (tRet != RET_OK)
- {
- printf("n[DB]:KD_ResetMenuTran error");
- return tRet;
- }
- //added by yyj 2007.6.27 end
-
- //added by yyj 2007.7.3 start
- tRet = KD_ResetDemandInfo();
- if (tRet != RET_OK)
- {
- printf("n[DB]:KD_ResetDemandInfo error");
- return tRet;
- }
- //added by yyj 2007.7.3 end
- if (KB_FlashWrite(KB_DB_SECTOR, 0, (UINT8*)&gPrgAllInfo, sizeof(KB_DBPrgAllInfo)) != RETOK)
- {
- printf("n[DB]:KB_FlashWrite error");
- return RET_FAIL;
- }
- printf("n[DB]:Data base reset ok.");
- return RET_OK;
- }
- KB_DBRET KD_GetSvcList(KB_DBListInfo *pSvcList)
- {
- *pSvcList = gE2pData.stServiceListInfo;
-
- return RET_OK;
- }
- KB_DBRET KD_SaveSvcList(KB_DBListInfo *pSvcList)
- {
- gE2pData.stServiceListInfo = *pSvcList;
-
- if (KB_E2PWrite(KB_NVM_SERVICELIST_INFO_ADDR, (UINT8* )&gE2pData.stServiceListInfo, sizeof(KB_DBListInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_ResetMailInfo(void)
- {
- UINT8 i;
-
- gE2pData.gMailInfo.nTotal = 0;
-
- if (KB_E2PWrite(KB_NVM_MAIL_INDEX_ADDR, (UINT8 *)(&gE2pData.gMailInfo), sizeof(KB_DBMailIndex), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
-
- for (i = 0; i < KB_DB_MAX_MAIL; ++i)
- {
- gMailInfo[i].Flag = CONFIG_NO_USED;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBResetChnnlInfo(UINT8 bType)
- {
- gPrgAllInfo.gChnnlInfo.nTotal = 0;
- memset(&gPrgAllInfo.gChnnlInfo,0,sizeof(KB_DBDTVChnnlInfo));
- KD_ResetNvodInfo(BufferSave);
- return RET_OK;
- }
- static KB_DBRET KD_InitChnnlInfo()
- {
- if (gPrgAllInfo.gChnnlInfo.nTotal > KB_DB_MAX_CHANNEL_NUM)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_InitCurPrgInfo(void)
- {
- if (KB_E2PRead(KB_NVM_CUR_PGM_ADDR, (UINT8 *)&gE2pData.gCurPrgInfo, sizeof(KB_DBCurPrgInd), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_InitDtvInfo()
- {
- UINT16 i, sum;
-
- sum = gPrgAllInfo.gDTVInfo.nTotal;
- if (sum > KB_DB_MAX_DTV)
- {
- return RET_FAIL;
- }
-
- for (i = 0; i < sum; ++i)
- {
- gE2pData.gDTVPrgCfgInfo[i].Flag = CONFIG_USED + 1;
- }
-
- return RET_OK;
- }
- //added by whale 07/05/25 start
- static KB_DBRET KD_InitDataInfo(void)
- {
- UINT16 i, sum;
-
- sum = gPrgAllInfo.gDATAInfo.nTotal;
- if (sum > KB_DB_MAX_DATA)
- {
- return RET_FAIL;
- }
-
- for (i = 0; i < sum; ++i)
- {
- gE2pData.gDATAPrgCfgInfo[i].Flag = CONFIG_USED + 1;
- }
-
- return RET_OK;
- }
- //added by whale 07/05/25 end
- KB_DBRET KB_DBResetDtvInfo(UINT8 bType)
- {
- UINT16 i,len;
- UINT8 flag = CONFIG_NO_USED;
-
-
- len = gPrgAllInfo.gDTVInfo.nTotal ;
- if(len > KB_DB_MAX_DTV)
- {
- len = KB_DB_MAX_DTV;
- }
- gPrgAllInfo.gDTVInfo.nTotal = 0;
- for (i = 0; i < KB_DB_MAX_DTV; ++i)
- {
- if (gE2pData.gDTVPrgCfgInfo[i].Flag == CONFIG_USED
- || gE2pData.gDTVPrgCfgInfo[i].Flag == CONFIG_USED + 1)
- {
- gE2pData.gDTVPrgCfgInfo[i].Flag = CONFIG_NO_USED;
- if (KB_E2PWrite((UINT16)(KB_NVM_DTV_PGM_CFG_ADDR + i * sizeof(KB_DBPrgConfigNode)),
- (UINT8 *)&flag, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- }
- }
-
- if (bType == FlashSave)
- {
- if (KB_FlashWrite(KB_DB_SECTOR, 0, (UINT8*)&gPrgAllInfo, sizeof(KB_DBPrgAllInfo)) != RETOK)
- {
- return RET_FAIL;
- }
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBResetRadInfo(UINT8 bType)
- {
- UINT16 i,serID,len;
- UINT8 flag = CONFIG_NO_USED;
-
-
- len = gPrgAllInfo.gRADInfo.nTotal ;
- if(len > KB_DB_MAX_RAD)
- {
- len = KB_DB_MAX_RAD;
- }
- for(i = 0;i< len;i++)
- {
- serID = gPrgAllInfo.gRADInfo.PgmList[i].SvcID;
- }
- gPrgAllInfo.gRADInfo.nTotal = 0;
-
- for (i = 0; i < KB_DB_MAX_RAD; ++i)
- {
- if (gE2pData.gRADPrgCfgInfo[i].Flag == CONFIG_USED
- || gE2pData.gRADPrgCfgInfo[i].Flag == CONFIG_USED + 1)
- {
- gE2pData.gRADPrgCfgInfo[i].Flag = CONFIG_NO_USED;
-
- if (KB_E2PWrite((UINT16)(KB_NVM_RAD_PGM_CFG_ADDR + i * sizeof(KB_DBPrgConfigNode)),
- (UINT8 *)&flag, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- }
- }
-
- if (bType == FlashSave)
- {
- if (KB_FlashWrite(KB_DB_SECTOR, 0, (UINT8*)&gPrgAllInfo, sizeof(KB_DBPrgAllInfo)) != RETOK)
- {
- return RET_FAIL;
- }
- }
-
- return RET_OK;
- }
- //added by whale 07/05/25 start
- KB_DBRET KB_DBResetDataInfo(UINT8 bType)
- {
- UINT16 i,len;
- UINT8 flag = CONFIG_NO_USED;
-
-
- len = gPrgAllInfo.gDATAInfo.nTotal ;
- if(len > KB_DB_MAX_DATA)
- {
- len = KB_DB_MAX_DATA;
- }
- gPrgAllInfo.gDATAInfo.nTotal = 0;
- for (i = 0; i < KB_DB_MAX_DATA; ++i)
- {
- if (gE2pData.gDATAPrgCfgInfo[i].Flag == CONFIG_USED
- || gE2pData.gDATAPrgCfgInfo[i].Flag == CONFIG_USED + 1)
- {
- gE2pData.gDATAPrgCfgInfo[i].Flag = CONFIG_NO_USED;
- if (KB_E2PWrite((UINT16)(KB_NVM_DTV_PGM_CFG_ADDR + i * sizeof(KB_DBPrgConfigNode)),
- (UINT8 *)&flag, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- }
- }
-
- if (bType == FlashSave)
- {
- if (KB_FlashWrite(KB_DB_SECTOR, 0, (UINT8*)&gPrgAllInfo, sizeof(KB_DBPrgAllInfo)) != RETOK)
- {
- return RET_FAIL;
- }
- }
-
- return RET_OK;
- }
- //added by whale 07/05/25 end
- static KB_DBRET KD_ResetNvodInfo(UINT8 bType)
- {
- gPrgAllInfo.gNVODInfo.nTotal = 0;
- return RET_OK;
- }
- //added by whale 07/06/01 start
- void KB_DBClearAllProg (void)
- {
- KB_DBResetDtvInfo(BufferSave);
- KB_DBResetRadInfo(BufferSave);
- KB_DBResetDataInfo(BufferSave);
- KD_ResetNvodInfo(BufferSave);
- KB_DBResetChnnlInfo(BufferSave);
- KB_FlashErase(KB_DB_SECTOR);
- }
- //added by whale 07/06/01 end
- static KB_DBRET KD_InitNvodInfo(void)
- {
- UINT16 sum;
-
- sum = gPrgAllInfo.gNVODInfo.nTotal;
- if (sum > KB_DB_MAX_NVOD)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_InitSysparInfo(void)
- {
- if (KB_E2PRead(KB_NVM_SYS_PARA_ADDR, (UINT8 *)&gE2pData.gSysPara, sizeof(KB_DBSysInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- return RET_OK;
- }
- KB_DBRET KD_ResetCurPrgInfo(void)
- {
- gE2pData.gCurPrgInfo.prgNO = 1;
- gE2pData.gCurPrgInfo.prgType = DTVPRG;
-
- if (KB_E2PWrite(KB_NVM_CUR_PGM_ADDR, (UINT8 *)&gE2pData.gCurPrgInfo, sizeof(KB_DBCurPrgInd), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- else
-
- {
- return RET_OK;
- }
- }
- static KB_DBRET KD_ResetNetInfo(void)
- {
- gE2pData.gNetInfo.NetworkName[0] = ' ';
- gE2pData.gNetInfo.NitVersion = 0;
-
- if (KB_E2PWrite(KB_NVM_NETWORK_INFO_ADDR, (UINT8 *)&gE2pData.gNetInfo, sizeof(KB_DBNetInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- else
-
- {
- return RET_OK;
- }
- }
- static KB_DBRET KD_ResetPwdInfo(void)
- {
- gE2pData.gPwdInfo.PwdSwitch = PSW_OFF;
- strcpy((char *)gE2pData.gPwdInfo.Password, "8888");
-
- if (KB_E2PWrite(KB_NVM_PASSWORD_ADDR, (UINT8 *)&gE2pData.gPwdInfo, sizeof(KB_DBPwdInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
-
- return RET_OK;
- }
- static KB_DBRET KD_ResetSysparInfo(void)
- {
- gE2pData.gSysPara.ScreenFormat = KB_AV_ASPECT_RATIO_4TO3;
- gE2pData.gSysPara.Language = CHINESE;
- gE2pData.gSysPara.IPAddress[0] = 192;
- gE2pData.gSysPara.IPAddress[1] = 168;
- gE2pData.gSysPara.IPAddress[2] = 0;
- gE2pData.gSysPara.IPAddress[3] = 96;
- gE2pData.gSysPara.Mask[0] = 255;
- gE2pData.gSysPara.Mask[1] = 255;
- gE2pData.gSysPara.Mask[2] = 255;
- gE2pData.gSysPara.Mask[3] = 0;
- gE2pData.gSysPara.TimeZone = 8;
- gE2pData.gSysPara.timeDateUserOffset=0;//lsp 07/3/14
- gE2pData.gSysPara.ShutDownInfo = 0xff;
- gE2pData.gSysPara.SetUpInfo = 0xff;
-
- if (KB_E2PWrite(KB_NVM_SYS_PARA_ADDR, (UINT8 *)&gE2pData.gSysPara, sizeof(KB_DBSysInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- else
- {
- return RET_OK;
- }
- }
- static KB_DBRET KD_ResetFavRad(void)
- {
- gE2pData.gRADFavInfo.nTotal = 0;
-
-
- if (KB_E2PWrite(KB_NVM_FAV_RAD_ADDR, (UINT8 *)&gE2pData.gRADFavInfo, sizeof(KB_DBFavRadInfo), NULL) != RETOK)
- {
- printf("nKD_ResetFavRad::KB_E2PWrite fail");
- return RET_FAIL;
- }
- else
- {
- return RET_OK;
- }
- }
- static KB_DBRET KD_InitPwdInfo(void)
- {
- if (KB_E2PRead(KB_NVM_PASSWORD_ADDR, (UINT8 *)&gE2pData.gPwdInfo, sizeof(KB_DBPwdInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- return RET_OK;
- }
- static KB_DBRET KD_InitRadInfo()
- {
- UINT16 i, sum;
-
- sum = gPrgAllInfo.gRADInfo.nTotal;
- if (sum > KB_DB_MAX_RAD)
- {
- return RET_FAIL;
- }
-
- for (i = 0; i < sum; ++i)
- {
- gE2pData.gRADPrgCfgInfo[i].Flag = CONFIG_USED + 1;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_InitSrchInfo(void)
- {
- if (KB_E2PRead(KB_NVM_SEARCH_INFO_ADDR, (UINT8 *)&gE2pData.gSrchInfo, sizeof(KB_DBSrchInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- return RET_OK;
- }
- static KB_DBRET KD_ResetSrchInfo(void)
- {
-
- gE2pData.gSrchInfo.Frequency = 256 * 10;
- gE2pData.gSrchInfo.SymbolRate = 6875;
- gE2pData.gSrchInfo.QamType = QAM64;
- gE2pData.gSrchInfo.SearchNIT = 1;
-
-
- if (KB_E2PWrite(KB_NVM_SEARCH_INFO_ADDR, (UINT8 *)&gE2pData.gSrchInfo, sizeof(KB_DBSrchInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- else
- {
- return RET_OK;
- }
-
-
- }
- static KB_DBRET KD_ResetFavDtv(void)
- {
- gE2pData.gDTVFavInfo.nTotal = 0;
-
-
- if (KB_E2PWrite(KB_NVM_FAV_DTV_ADDR, (UINT8 *)&gE2pData.gDTVFavInfo, sizeof(KB_DBFavDtvInfo), NULL) != RETOK)
- {
- printf("nKD_ResetFavDtv::KB_E2PWrite fail");
- return RET_FAIL;
- }
- else
- {
- return RET_OK;
- }
- }
- static KB_DBRET KD_InitFavDtv(void)
- {
- if (KB_E2PRead(KB_NVM_FAV_DTV_ADDR, (UINT8 *)&gE2pData.gDTVFavInfo, sizeof(KB_DBFavDtvInfo), NULL) != RETOK)
- {
- printf("nKD_InitFavDtv::KB_E2PRead fail");
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_InitFavRad(void)
- {
- if (KB_E2PRead(KB_NVM_FAV_RAD_ADDR, (UINT8*)&gE2pData.gRADFavInfo, sizeof(KB_DBFavRadInfo), NULL) != RETOK)
- {
- printf("nKD_InitFavRad::KB_E2PRead fail");
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- static void KD_InitPrgConfig(void)
- {
- UINT16 i;
-
- for (i = 0; i < KB_DB_MAX_DTV; ++i)
- {
- gDtvCfgFlag[i] = 0;
- }
- for (i = 0; i < KB_DB_MAX_RAD; ++i)
- {
- gRadCfgFlag[i] = 0;
- }
- //added by whale 07/05/25 start
- for (i = 0; i < KB_DB_MAX_DATA; ++i)
- {
- gDataCfgFlag[i] = 0;
- }
- //added by whale 07/05/25 end
- }
- static KB_DBRET KD_InitNetInfo(void)
- {
- if (KB_E2PRead(KB_NVM_NETWORK_INFO_ADDR, (UINT8 *)&gE2pData.gNetInfo, sizeof(KB_DBNetInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_InitMail(void)
- {
- UINT8 i, bIndex;
-
- if (KB_E2PRead(KB_NVM_MAIL_INDEX_ADDR, (UINT8 *)&gE2pData.gMailInfo, sizeof(KB_DBMailIndex), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- for (i = 0; i < KB_DB_MAX_MAIL; ++i)
- {
- if (gMailInfo[i].Flag != CONFIG_USED
- && gMailInfo[i].Flag != CONFIG_NO_USED)
- {
- return RET_FAIL;
- }
- }
-
- for (i = 0; i < gE2pData.gMailInfo.nTotal; ++i)
- {
- bIndex = gE2pData.gMailInfo.MailIndexList[i].Index;
-
- if (gMailInfo[bIndex].Flag != CONFIG_USED)
- {
- return RET_FAIL;
- }
- }
- return RET_OK;
- }
- unsigned short KB_DBGetPrgAvInfoByPrgNo(UINT8 prgType,
- unsigned short nPrgNO,
- KB_DBPRGPID *pPrgPid)
- {
-
- if (prgType == DTVPRG)
- {
- pPrgPid->PCR_Pid = gPrgAllInfo.gDTVInfo.PgmList[nPrgNO-1].PCRPID;
- pPrgPid->Audio_Pid = gPrgAllInfo.gDTVInfo.PgmList[nPrgNO-1].AudioPID;
- pPrgPid->Video_Pid = gPrgAllInfo.gDTVInfo.PgmList[nPrgNO-1].VideoPID;
- }
- else if (prgType == RADIOPRG)
- {
- pPrgPid->PCR_Pid = gPrgAllInfo.gRADInfo.PgmList[nPrgNO-1].PCRPID;
- pPrgPid->Audio_Pid = gPrgAllInfo.gRADInfo.PgmList[nPrgNO-1].AudioPID;
- pPrgPid->Video_Pid = gPrgAllInfo.gRADInfo.PgmList[nPrgNO-1].VideoPID;
- }
- //added by whale 07/05/25 start
- else if (prgType == DATAPRG)
- {
- pPrgPid->PCR_Pid = gPrgAllInfo.gDATAInfo.PgmList[nPrgNO-1].PCRPID;
- pPrgPid->Audio_Pid = gPrgAllInfo.gDATAInfo.PgmList[nPrgNO-1].AudioPID;
- pPrgPid->Video_Pid = gPrgAllInfo.gDATAInfo.PgmList[nPrgNO-1].VideoPID;
- }
- //added by whale 07/05/25 end
- return KB_DB_DTV_SUCCESS;
- }
- static KB_DBRET KD_ResetSerList(void)
- {
- gE2pData.stServiceListInfo.DtvNum = 0;
- gE2pData.stServiceListInfo.RadNum = 0;
-
- if (KB_E2PWrite(KB_NVM_SERVICELIST_INFO_ADDR, (UINT8 *)&gE2pData.stServiceListInfo, sizeof(KB_DBListInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_InitSerList(void)
- {
- if (KB_E2PRead(KB_NVM_SERVICELIST_INFO_ADDR, (UINT8 *)&gE2pData.stServiceListInfo, sizeof(KB_DBListInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- INT32 KB_DBGetSvc2_TSID(INT32 nTsId, INT32 nPrgType,
- INT32 *pSvcID1, INT32 nCount1,
- INT32 *pSvcID2, INT32 nCount2)
- {
- UINT16 i = 0, sum = 0, j;
- KB_DBPrgInfo programInfo;
- KB_DBChnnlInfo channelInfo;
- UINT8 track;
- UINT8 volume;
- UINT8 lockFlag;
- INT32 nNumber;
-
- sum = KB_DBGetPrgTotal((UINT8)nPrgType);
- nNumber = 0;
- for (i = 0; i < sum; ++i)
- {
- if (KB_DBGetPrgInfo(i, (UINT8)nPrgType, &programInfo, &channelInfo, &track, &volume, &lockFlag) == RET_OK)
- {
- if (programInfo.TSID == nTsId)
- {
- for (j = 0; j < nCount2; j++)
- {
- if (programInfo.SvcID== *(pSvcID2 + j))
- {
- break;
- }
- }
-
- if (j >= nCount2)
- {
- *(pSvcID1 + nNumber) = programInfo.SvcID;
- nNumber ++;
-
- if (nNumber == nCount1)
- {
- break;
- }
- }
- }
- }
- }
-
- return nNumber;
- }
- KB_DBRET KD_GetNVOD_Svc(KB_SIRefSvcCell *refSvc)
- {
-
- UINT16 loop,i;
- for (loop=0;loop<gPrgAllInfo.gNVODInfo.nTotal;loop++)
- {
- if (gPrgAllInfo.gNVODInfo.RefSvc[loop].RefSvcId==refSvc->refScvId)
- {
- strcpy((char*)gPrgAllInfo.gNVODInfo.RefSvc[loop].RefSvcName,(char*)refSvc->refScvName);
- gPrgAllInfo.gNVODInfo.RefSvc[loop].TsID = refSvc->TsID;
- gPrgAllInfo.gNVODInfo.RefSvc[loop].ShiftNum = 0;
- for(i = 0;i< refSvc->shiftSvcNum;i++)
- {
- gPrgAllInfo.gNVODInfo.RefSvc[loop].ShiftList[i].ServiceId =
- refSvc->shiftSvc[i].svcId;
- gPrgAllInfo.gNVODInfo.RefSvc[loop].ShiftList[i].TSID=
- refSvc->shiftSvc[i].tsId;
- gPrgAllInfo.gNVODInfo.RefSvc[loop].ShiftNum ++;
- }
- return RET_OK;
- }
- }
-
- return RET_FAIL;
- }
- static KB_DBRET KD_GetPrgConfig(void)
- {
- UINT16 i, sum, indexofconfig;
- KB_DBPrgConfigNode *pConfignode;
-
- sum = gPrgAllInfo.gDTVInfo.nTotal;
- if (sum == 65535)
- {
- sum = 0;
- }
- for (i = 0; i < sum; ++i)
- {
- indexofconfig = gPrgAllInfo.gDTVInfo.PgmList[i].IndexOfConfigInfo;
- pConfignode = &gE2pData.gDTVPrgCfgInfo[indexofconfig];
- if (KB_E2PRead((UINT16)(KB_NVM_DTV_PGM_CFG_ADDR + indexofconfig * sizeof(KB_DBPrgConfigNode)),
- (UINT8 *)pConfignode, sizeof(KB_DBPrgConfigNode), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- }
- sum = gPrgAllInfo.gRADInfo.nTotal;
- if (sum == 65535)
- {
- sum = 0;
- }
- for (i = 0; i < sum; ++i)
- {
- indexofconfig = gPrgAllInfo.gRADInfo.PgmList[i].IndexOfConfigInfo;
- pConfignode = &gE2pData.gRADPrgCfgInfo[indexofconfig];
-
- if (KB_E2PRead((UINT16)(KB_NVM_RAD_PGM_CFG_ADDR + indexofconfig * sizeof(KB_DBPrgConfigNode)),
- (UINT8 *)pConfignode, sizeof(KB_DBPrgConfigNode), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- }
- //added by whale 07/05/25 start
- sum = gPrgAllInfo.gDATAInfo.nTotal;
- if (sum == 65535)
- {
- sum = 0;
- }
- for (i = 0; i < sum; ++i)
- {
- indexofconfig = gPrgAllInfo.gDATAInfo.PgmList[i].IndexOfConfigInfo;
- pConfignode = &gE2pData.gDATAPrgCfgInfo[indexofconfig];
-
- if (KB_E2PRead((UINT16)(KB_NVM_DATA_PGM_CFG_ADDR + indexofconfig * sizeof(KB_DBPrgConfigNode)),
- (UINT8 *)pConfignode, sizeof(KB_DBPrgConfigNode), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- }
- //added by whale 07/05/25 end
- return RET_OK;
- }
- unsigned short KB_DBGetChnlInfoByPrgNO(UINT8 prgType,
- unsigned short nPrgNO,
- unsigned long * pFrea,
- unsigned long * pSymb,
- unsigned char * pQam)
- {
- UINT16 i;
-
- for (i=0; i<gPrgAllInfo.gChnnlInfo.nTotal; i++)
- {
- if (prgType == DTVPRG)
- {
- if (gPrgAllInfo.gChnnlInfo.ChannelList[i].TSID
- == gPrgAllInfo.gDTVInfo.PgmList[nPrgNO-1].TSID)
- {
- break;
- }
- }
- else if (prgType == RADIOPRG)
- {
- if (gPrgAllInfo.gChnnlInfo.ChannelList[i].TSID
- == gPrgAllInfo.gRADInfo.PgmList[nPrgNO-1].TSID)
- {
- break;
- }
- }
- //added by whale 07/05/25 start
- else if (prgType == DATAPRG)
- {
- if (gPrgAllInfo.gChnnlInfo.ChannelList[i].TSID
- == gPrgAllInfo.gDATAInfo.PgmList[nPrgNO-1].TSID)
- {
- break;
- }
- }
- //added by whale 07/05/25 end
- }
-
- *pFrea = (unsigned long)gPrgAllInfo.gChnnlInfo.ChannelList[i].Freq* 100000;
- *pSymb = (unsigned long)gPrgAllInfo.gChnnlInfo.ChannelList[i].Symb* 1000;
- *pQam = (unsigned char)gPrgAllInfo.gChnnlInfo.ChannelList[i].QAM;
- return KB_DB_DTV_SUCCESS;
- }
- INT8 KD_GetNITVer(void)
- {
- UINT8 ver;
- UINT8 networkName[22];
- KB_DBRET ret;
-
- ret = KD_GetNitInfo(networkName,&ver);
- if(ret != RET_OK)
- {
- //ver = -1;
- return -1;
- }
- return ver;
- }
- unsigned short KB_DBGetPrgPMT(UINT8 prgType,
- unsigned short nPrgNO,
- unsigned short * pPmtPID,
- unsigned short * pSvcID)
- {
- KB_DBPrgInfo prgInfo;
- KB_DBChnnlInfo chnnlInfo;
- UINT8 bTrack;
- UINT8 bVolume;
- UINT8 bLockFlag;
- if (KB_DBGetPrgInfo(nPrgNO - 1, prgType, &prgInfo, &chnnlInfo, &bTrack, &bVolume, &bLockFlag) != RET_OK)
- return KB_DB_DTV_FAILURE;
- *pPmtPID = prgInfo.PMTPID;
- *pSvcID = prgInfo.SvcID;
- return KB_DB_DTV_SUCCESS;
- }
- unsigned char * KB_DBGetPrgName(UINT8 type,int nPrgNO)
- {
- static KB_DBPrgInfo prgInfo;
- KB_DBChnnlInfo chnnlInfo;
- UINT8 bTrack;
- UINT8 bVolume;
- UINT8 bLockFlag;
- KB_DBGetPrgInfo(nPrgNO - 1, type, &prgInfo, &chnnlInfo, &bTrack, &bVolume, &bLockFlag);
- return prgInfo.Name;
- }
- unsigned short KB_DBGetCAFlagByPrgNo(int type,unsigned short nPrgNO)
- {
- KB_DBPrgInfo prgInfo;
- KB_DBChnnlInfo chnnlInfo;
- UINT8 bTrack;
- UINT8 bVolume;
- UINT8 bLockFlag;
- KB_DBGetPrgInfo(nPrgNO - 1, type, &prgInfo, &chnnlInfo, &bTrack, &bVolume, &bLockFlag);
- return prgInfo.ScrambleFlag;
- }
- KB_DBRET KB_DBSaveCAFlagByPrgNo(int type,unsigned short nPrgNO,unsigned char i_bCAFlag)
- {
- if(((nPrgNO - 1) <0 ) || ((nPrgNO - 1) >= KB_DBGetPrgTotal(type)))
- {
- return RET_FAIL;
- }
-
- if (type == DTVPRG)
- {
- gPrgAllInfo.gDTVInfo.PgmList[nPrgNO - 1].ScrambleFlag = i_bCAFlag;
- }
- else if (type == RADIOPRG)
- {
- gPrgAllInfo.gRADInfo.PgmList[nPrgNO - 1].ScrambleFlag = i_bCAFlag;
- }
- return RET_OK;
- }
- unsigned char KB_DBGetPatVerByPrgNo(UINT8 prgType,unsigned short nPrgNO)
- {
- KB_DBPrgInfo prgInfo;
- KB_DBChnnlInfo chnnlInfo;
- UINT8 bTrack;
- UINT8 bVolume;
- UINT8 bLockFlag;
- KB_DBGetPrgInfo(nPrgNO - 1, prgType, &prgInfo, &chnnlInfo, &bTrack, &bVolume, &bLockFlag);
- return chnnlInfo.PATVersion;
- }
- unsigned char KB_DBGetPmtVerByPrgNo(UINT8 prgType,unsigned short nPrgNO)
- {
- KB_DBPrgInfo prgInfo;
- KB_DBChnnlInfo chnnlInfo;
- UINT8 bTrack;
- UINT8 bVolume;
- UINT8 bLockFlag;
- KB_DBGetPrgInfo(nPrgNO - 1, prgType, &prgInfo, &chnnlInfo, &bTrack, &bVolume, &bLockFlag);
- return prgInfo.PMTVersion;
- }
- unsigned char KB_DBGetSdtVer(UINT8 prgType,unsigned short nPrgNO)
- {
- KB_DBPrgInfo prgInfo;
- KB_DBChnnlInfo chnnlInfo;
- UINT8 bTrack;
- UINT8 bVolume;
- UINT8 bLockFlag;
- KB_DBGetPrgInfo(nPrgNO - 1, prgType, &prgInfo, &chnnlInfo, &bTrack, &bVolume, &bLockFlag);
- return chnnlInfo.SDTVersion;
- }
- char KB_DBGetPrgTrace(UINT8 bPrgType,unsigned short nPrgNO)
- {
- UINT16 nConfigInd;
- UINT8 nConfigInfo;
- UINT8 bTrack;
- if (bPrgType == DTVPRG)
- {
- nConfigInd = gPrgAllInfo.gDTVInfo.PgmList[nPrgNO-1].IndexOfConfigInfo;
- nConfigInfo = gE2pData.gDTVPrgCfgInfo[nConfigInd].Lock_Track_Vol;
- }
- else if (bPrgType == RADIOPRG)
- {
- nConfigInd = gPrgAllInfo.gRADInfo.PgmList[nPrgNO-1].IndexOfConfigInfo;
- nConfigInfo = gE2pData.gRADPrgCfgInfo[nConfigInd].Lock_Track_Vol;
- }
- //added by whale 07/05/25 start
- else if (bPrgType == DATAPRG)
- {
- nConfigInd = gPrgAllInfo.gDATAInfo.PgmList[nPrgNO-1].IndexOfConfigInfo;
- nConfigInfo = gE2pData.gDATAPrgCfgInfo[nConfigInd].Lock_Track_Vol;
- }
- //added by whale 07/05/25 end
-
- bTrack = ((nConfigInfo >> 5) & 0x03);
-
- return bTrack;
- }
- /* ---------------------------------
- * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
- * =================================
- * |锁 | 声道 | 音量 |
- * ---------------------------------*/
- KB_DBRET KB_DBSaveTrace(UINT8 bPrgType,unsigned short nPrgNO,UINT8 nTrack)
- {
- UINT16 indexofconfig;
- UINT8 nConfigInfo;
- UINT32 nAddress1, nAddress2, nOffset;
-
- if (bPrgType == DTVPRG)
- {
- indexofconfig = gPrgAllInfo.gDTVInfo.PgmList[nPrgNO-1].IndexOfConfigInfo;
-
- nConfigInfo = gE2pData.gDTVPrgCfgInfo[indexofconfig].Lock_Track_Vol;
-
- nConfigInfo &= 0x80;
- nConfigInfo |= (nTrack & 0x7f);
- gE2pData.gDTVPrgCfgInfo[indexofconfig].Lock_Track_Vol = nConfigInfo;
- nAddress1 = (UINT32)&(gE2pData.gDTVPrgCfgInfo[indexofconfig].Flag);
- nAddress2 = (UINT32)&(gE2pData.gDTVPrgCfgInfo[indexofconfig].Lock_Track_Vol);
- nOffset = nAddress2 - nAddress1;
- if (KB_E2PWrite((UINT16)(KB_NVM_DTV_PGM_CFG_ADDR + sizeof(KB_DBPrgConfigNode) * indexofconfig + (int)nOffset),
- (UINT8 *)&nConfigInfo, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- }
- else if (bPrgType == RADIOPRG)
- {
- indexofconfig = gPrgAllInfo.gRADInfo.PgmList[nPrgNO-1].IndexOfConfigInfo;
-
- nConfigInfo = gE2pData.gRADPrgCfgInfo[indexofconfig].Lock_Track_Vol;
-
- nConfigInfo &= 0x80;
- nConfigInfo |= (nTrack & 0x7f);
- gE2pData.gRADPrgCfgInfo[indexofconfig].Lock_Track_Vol = nConfigInfo;
- nAddress1 = (UINT32)&(gE2pData.gRADPrgCfgInfo[indexofconfig].Flag);
- nAddress2 = (UINT32)&(gE2pData.gRADPrgCfgInfo[indexofconfig].Lock_Track_Vol);
- nOffset = nAddress2 - nAddress1;
- if (KB_E2PWrite((UINT16)(KB_NVM_RAD_PGM_CFG_ADDR + indexofconfig * sizeof(KB_DBPrgConfigNode) + (int)nOffset),
- (UINT8 *)&nConfigInfo, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- }
- //added by whale 07/05/25 start
- else if (bPrgType == DATAPRG)
- {
- indexofconfig = gPrgAllInfo.gDATAInfo.PgmList[nPrgNO-1].IndexOfConfigInfo;
-
- nConfigInfo = gE2pData.gDATAPrgCfgInfo[indexofconfig].Lock_Track_Vol;
-
- nConfigInfo &= 0x80;
- nConfigInfo |= (nTrack & 0x7f);
- gE2pData.gDATAPrgCfgInfo[indexofconfig].Lock_Track_Vol = nConfigInfo;
- nAddress1 = (UINT32)&(gE2pData.gDATAPrgCfgInfo[indexofconfig].Flag);
- nAddress2 = (UINT32)&(gE2pData.gDATAPrgCfgInfo[indexofconfig].Lock_Track_Vol);
- nOffset = nAddress2 - nAddress1;
- if (KB_E2PWrite((UINT16)(KB_NVM_DATA_PGM_CFG_ADDR + indexofconfig * sizeof(KB_DBPrgConfigNode) + (int)nOffset),
- (UINT8 *)&nConfigInfo, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- }
- //added by whale 07/05/25 end
- return RET_OK;
- }
- KB_DBRET KB_DBSaveDemandInfo(UINT16 size, UINT8 *buff )
- {
-
- if(KB_E2PWrite(KB_NVM_DEMAND_INFO_ADDR, buff, size, NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBGetDemandInfo(UINT16 size, UINT8 *buff )
- {
-
- if(KB_E2PRead(KB_NVM_DEMAND_INFO_ADDR, buff, size, NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- unsigned char KB_DBGetVolumeByPrgNo(unsigned char *pVolume, unsigned char bType,
- unsigned short nPrgNO)
- {
- UINT16 nConfigInd;
- UINT8 nConfigInfo;
- UINT8 bVolume;
- if (bType == DTVPRG)
- {
- nConfigInd = gPrgAllInfo.gDTVInfo.PgmList[nPrgNO-1].IndexOfConfigInfo;
- nConfigInfo = gE2pData.gDTVPrgCfgInfo[nConfigInd].Lock_Track_Vol;
- }
- else if (bType == RADIOPRG)
- {
- nConfigInd = gPrgAllInfo.gRADInfo.PgmList[nPrgNO-1].IndexOfConfigInfo;
- nConfigInfo = gE2pData.gRADPrgCfgInfo[nConfigInd].Lock_Track_Vol;
- }
- //added by whale 07/05/25 start
- else if (bType == DATAPRG)
- {
- nConfigInd = gPrgAllInfo.gDATAInfo.PgmList[nPrgNO-1].IndexOfConfigInfo;
- nConfigInfo = gE2pData.gDATAPrgCfgInfo[nConfigInd].Lock_Track_Vol;
- }
- //added by whale 07/05/25 end
- bVolume = (nConfigInfo & 0x1F);
- *pVolume = bVolume;
- return bVolume;
- }
- KB_DBRET KB_DBSaveVolume(unsigned char nVolume, UINT8 bPrgType,unsigned short nPrgNO)
- {
- KB_DBPrgInfo prgInfo;
- KB_DBChnnlInfo chnnlInfo;
- UINT8 bTrack;
- UINT8 bVolume;
- UINT8 bLockFlag;
- UINT8 bTrackVolume;
- KB_DBGetPrgInfo(nPrgNO - 1, bPrgType, &prgInfo, &chnnlInfo, &bTrack, &bVolume, &bLockFlag);
- bTrackVolume = bTrack << 5 | nVolume;
- KB_DBSaveTrace(bPrgType,nPrgNO,bTrackVolume);
- return RET_OK;
- }
- unsigned char KB_DBGetZone(signed char *pTimeZone)
- {
- #if 1
- *pTimeZone=8;
- #else
- KB_DBSysInfo params;
- KB_DBGetSysPara(¶ms);
- if( (params.TimeZone > 12) || (params.TimeZone < -12) )
- return KB_DB_DTV_FAILURE;
- *pTimeZone = params.TimeZone;
- #endif
- return KB_DB_DTV_SUCCESS;
- }
- //lsp 07/3/14
- unsigned char KB_DBSaveZone(signed char pTimeZone)
- {
- KB_DBSysInfo params;
- KB_DBGetSysPara(¶ms);
- if( (params.TimeZone > 12) || (params.TimeZone < -12) )
- return KB_DB_DTV_FAILURE;
- params.TimeZone= pTimeZone;
- KB_DBSaveSysPara(¶ms);
- return KB_DB_DTV_SUCCESS;
- }
- UINT32 KB_DBGetTimeDateUserOffset(void)
- {
- KB_DBSysInfo params;
- KB_DBGetSysPara(¶ms);
- return params.timeDateUserOffset;
- }
- void KB_DBSaveTimeDateUserOffset(UINT32 tDUserOffset)
- {
- KB_DBSysInfo params;
- KB_DBGetSysPara(¶ms);
- params.timeDateUserOffset= tDUserOffset;
- KB_DBSaveSysPara(¶ms);
- }
- //end lsp 07/3/14
- unsigned char KB_DBGetLanguageFlag(void)
- {
- KB_DBSysInfo params;
- unsigned char type = 0;
- KB_DBGetSysPara(¶ms);
- if(params.Language >= 2)
- return type;
- return params.Language;
- }
- /*=============================================================
- 函数名称 : KB_DBSetLanguageFlag
- 功 能 : 设置语言类型标志
- 入 口 : nLanFlag---语言类型
- 出 口 : 无
- 返 回 : RET_OK---成功,RET_FAIL---失败
- =============================================================*/
- KB_DBRET KB_DBSaveLanguageFlag(UINT8 nLanFlag)
- {
- gE2pData.gSysPara.Language = nLanFlag;
-
- if (KB_E2PWrite(KB_NVM_SYS_PARA_ADDR, (UINT8 *)&gE2pData.gSysPara, sizeof(KB_DBSysInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- else
- {
- return RET_OK;
- }
- }
- void KB_DBSwitchProInfo(UINT8 nPrgType ,int oldnitem,int newnitem)
- {
- KB_DBPrgInfo tempPrg;
- if(nPrgType==DTVPRG)
- {
- tempPrg=gPrgAllInfo.gDTVInfo.PgmList[oldnitem];
- gPrgAllInfo.gDTVInfo.PgmList[oldnitem]=gPrgAllInfo.gDTVInfo.PgmList[newnitem];
- gPrgAllInfo.gDTVInfo.PgmList[newnitem]=tempPrg;
- }
- //modified by whale 07/05/25
- //else
- else if (nPrgType==RADIOPRG)
- {
- tempPrg= gPrgAllInfo.gRADInfo.PgmList[oldnitem];
- gPrgAllInfo.gRADInfo.PgmList[oldnitem]=gPrgAllInfo.gRADInfo.PgmList[newnitem];
- gPrgAllInfo.gRADInfo.PgmList[newnitem]=tempPrg;
- }
- }
- UINT16 KB_DBGetPrgNoByFavIndex(UINT8 nPrgType ,int FavIndex)
- {
- UINT16 uiRealPgmNo;
- KB_DBPrgInfo tPlayInfo;
- KB_DBChnnlInfo chnnlInfo;
- UINT8 bTrack, bVol, bLockFlag;
-
- KB_DBGetFavPrgInfoByFavInx(FavIndex , nPrgType, &uiRealPgmNo, &tPlayInfo, &chnnlInfo, &bTrack, &bVol, &bLockFlag);
- return uiRealPgmNo;
- }
- int KB_PrgSort(UINT8 Prgtype,UINT16 *changeState)
- {
- int total,i,find,tmpPos = -1;
- int okSort = 0;
- unsigned char *name = NULL;
- KB_DBPrgInfo tmpPrg,tmpPrg2;
- UINT16 sortstate[200 + 1],AfterSortState[200 + 1],AfterSort[ 201 ];
- int end = 0;
- KB_DBPrgInfo *changeInfo = NULL;
- int changeTotal;
-
- total = KB_DBGetPrgTotal(Prgtype);
- switch(Prgtype)
- {
- case DTVPRG:
- changeInfo = gPrgAllInfo.gDTVInfo.PgmList;
- changeTotal = gPrgAllInfo.gDTVInfo.nTotal;
- break;
- case RADIOPRG:
- changeInfo = gPrgAllInfo.gRADInfo.PgmList;
- changeTotal = gPrgAllInfo.gRADInfo.nTotal;
- break;
- //added by whale 07/05/25 start
- case DATAPRG:
- changeInfo = gPrgAllInfo.gDATAInfo.PgmList;
- changeTotal = gPrgAllInfo.gDATAInfo.nTotal;
- break;
- //added by whale 07/05/25 end
- default:
- return -1;
- }
-
- for( i = 0; i < total + 1;i ++ )
- {
- sortstate[i] = i ;
- AfterSort[i] = i ;
- AfterSortState[i] = 0;
- }
-
- while(okSort < total)
- {
- if(tmpPos != -1)
- {
- for(i = 1 ;i < total + 1;i++)
- {
- if(changeState[i] == tmpPos)
- {
- break;
- }
- }
-
- {
- memcpy(&tmpPrg2,&tmpPrg,sizeof(KB_DBPrgInfo));
- memcpy(&tmpPrg,&changeInfo[i - 1],sizeof(KB_DBPrgInfo));
- memcpy(&changeInfo[i - 1],&tmpPrg2,sizeof(KB_DBPrgInfo));
- AfterSort[i] = tmpPos;
- }
- AfterSortState[i] = 1;
- tmpPos = sortstate [ i ] ;
-
- for( i = 1 ; i< total + 1 ;i++)
- {
- if((AfterSortState[ i ] == 1) && (tmpPos == AfterSort[i] ))
- {
- tmpPos = -1;
- }
- }
- }
- else
- {
- end = 1;
- for(i = 1;i < total + 1;i++)
- {
- if(changeState[i] != AfterSort[i])
- {
- find = i;
- end = 0;
- break;
- }
- else
- {
- AfterSortState[i] = 1;
- }
- }
-
- if(end == 1)
- {
- okSort = total;
- }
- else
- {
- {
- memcpy(&tmpPrg,&changeInfo[find - 1],sizeof(KB_DBPrgInfo));
- memcpy(&changeInfo[find - 1],&changeInfo[changeState[find] - 1],sizeof(KB_DBPrgInfo));
- AfterSort[find] = changeState[find];
- }
- tmpPos = sortstate[find];
- AfterSortState[find] = 1;
- }
- }
- }
-
- for(i = 0;i< total;i++)
- {
- {
- name = changeInfo[i].Name;
- }
- }
- KB_DBSavePrgInfo(0);
-
- return 0;
- }
- /*KB_DBRET KB_DBSaveCurPrg(unsigned short nPrgNO, unsigned char nPrgType)
- {
-
- gE2pData.gCurPrgInfo.prgNO = nPrgNO - 1;
- gE2pData.gCurPrgInfo.prgType= nPrgType;
-
- if(KB_E2PWrite(KB_NVM_CUR_PGM_ADDR, (UINT8 *)&gE2pData.gCurPrgInfo, sizeof(KB_DBCurPrgInd), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
-
- }*/
- void KB_ReadBannerDispTime(char *bannerDispTime)
- {
- if (KB_E2PRead(KB_NVM_LAST_BANNER_DISPTIME_OFFSET, (UINT8 *)bannerDispTime, sizeof(char), NULL) != RETOK)
- {
- printf("===FAIL load_pos====n");
- }
- }
- void KB_SaveBannerDispTime(char *bannerDispTime)
- {
- if (KB_E2PWrite(KB_NVM_LAST_BANNER_DISPTIME_OFFSET, (UINT8 *)bannerDispTime, sizeof(char), NULL) != RETOK)
- {
- printf("===FAIL save_pos====n");
- }
- }
-
- //added by yyj start 2007.6.14
- KB_DBRET KB_DBSavePgmCurVol(UINT8 buff )
- {
- gConfigAudioVol=buff;
-
- if(KB_E2PWrite(KB_NVM_CONFIG_AUDIO_VOLUME_OFFSET, &buff, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBGetPgmCurVol(UINT8 *buff )
- {
- *buff=gConfigAudioVol;
-
- if(*buff>=KB_AV_MAX_VOLUME)
- {
- *buff=KB_AV_DEFAULT_VOLUME;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_InitPgmCurVol(void)
- {
- if (KB_E2PRead(KB_NVM_CONFIG_AUDIO_VOLUME_OFFSET, (UINT8 *)&gConfigAudioVol, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_ResetPgmCurVol(void)
- {
- gConfigAudioVol=KB_AV_DEFAULT_VOLUME;
-
- if (KB_E2PWrite(KB_NVM_CONFIG_AUDIO_VOLUME_OFFSET, (UINT8 *)&gConfigAudioVol, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- ///////////序列号////////////
- KB_DBRET KD_DBGetSerialNumInfo(UINT16 size, UINT8 *buff)
- {
-
- if (KB_E2PRead(KB_NVM_UPDATE_IN_SERIAL_NUM_OFFSET, buff, size, NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KD_DBSaveSerialNumInfo(UINT16 size, UINT8 *buff)
- {
-
- if (KB_E2PWrite(KB_NVM_UPDATE_IN_SERIAL_NUM_OFFSET, buff, size, NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- //////////////////////////////////
- //added by yyj end 2007.6.14
- //added by yyj start 2007.6.19
- //机顶盒信息
- KB_DBRET KB_DBSaveSTBInfo(KB_DBSTBInfo buff )
- {
- gE2pData.gSTBInfo=buff;
-
- if(KB_E2PWrite(KB_NVM_STB_INFO_ADDR, (UINT8 *)&buff, sizeof(KB_DBSTBInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBGetSTBInfo(KB_DBSTBInfo *buff )
- {
- *buff=gE2pData.gSTBInfo;
-
- return RET_OK;
- }
- static KB_DBRET KD_InitSTBInfo(void)
- {
- UINT8 str[]="------";
- UINT8 crc[] = "KBSTBINFO";
- if (KB_E2PRead(KB_NVM_STB_INFO_ADDR, (UINT8 *)&gE2pData.gSTBInfo, sizeof(KB_DBSTBInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- if (memcmp(gE2pData.gSTBInfo.CRC, crc, 10))
- {
- #if 1
- memcpy(gE2pData.gSTBInfo.CRC, crc, 10);
- memcpy(gE2pData.gSTBInfo.STB_Model, str, 20);
- memcpy(gE2pData.gSTBInfo.HW_Info, str, 20);
- strcpy((char *)gE2pData.gSTBInfo.HW_Vervion,"1.0.0");
- memcpy(gE2pData.gSTBInfo.SW_Info, str, 20);
- strcpy((char *)gE2pData.gSTBInfo.SW_Vervion,"1.0.0");
- memset(gE2pData.gSTBInfo.SW_Release_Time, 0xff, 20);
- strcpy((char *)gE2pData.gSTBInfo.CA_Version,"1.0.0");
- strcpy((char *)gE2pData.gSTBInfo.Manufacturer,"键桥通讯");
- if(KB_E2PWrite(KB_NVM_STB_INFO_ADDR, (UINT8 *)&gE2pData.gSTBInfo, sizeof(KB_DBSTBInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- #else
- return RET_FAIL;
- #endif
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_ResetSTBInfo(void)
- {
- UINT8 str[]="------";
- UINT8 crc[] = "KBSTBINFO";
- memcpy(gE2pData.gSTBInfo.CRC, crc, 10);
- memcpy(gE2pData.gSTBInfo.STB_Model, str, 20);
- memcpy(gE2pData.gSTBInfo.HW_Info, str, 20);
- strcpy((char *)gE2pData.gSTBInfo.HW_Vervion,"1.0.0");
- memcpy(gE2pData.gSTBInfo.SW_Info, str, 20);
- strcpy((char *)gE2pData.gSTBInfo.SW_Vervion,"1.0.0");
- memset(gE2pData.gSTBInfo.SW_Release_Time, 0xff, 20);
- strcpy((char *)gE2pData.gSTBInfo.CA_Version,"1.0.0");
- strcpy((char *)gE2pData.gSTBInfo.Manufacturer,"键桥通讯");
- if (KB_E2PWrite(KB_NVM_STB_INFO_ADDR, (UINT8 *)&gE2pData.gSTBInfo, sizeof(KB_DBSTBInfo), NULL) != RETOK)
- {
- return RET_FAIL;
- }
- return RET_OK;
- }
- //added by yyj end 2007.6.19
- //added by yyj 2007.6.27 start
- KB_DBRET KB_DBSaveVideoDispMode(UINT8 buff )
- {
- gVidDispMode=buff;
-
- if(KB_E2PWrite(KB_NVM_VIDEO_DISPLAY_MODE_OFFSET, &buff, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBGetVideoDispMode(UINT8 *buff )
- {
- *buff=gVidDispMode;
- printf("n[KB_DBGetVideoDispMode]:gVidDispMode=%d",gVidDispMode);
-
- if(*buff>=KB_AV_VIDEO_DISPLAY_MAX_TYPE)
- {
- *buff=KB_AV_DEFAULT_DISP_MODE;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_InitVideoDispMode(void)
- {
- if (KB_E2PRead(KB_NVM_VIDEO_DISPLAY_MODE_OFFSET, (UINT8 *)&gVidDispMode, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_ResetVideoDispMode(void)
- {
- gVidDispMode=KB_AV_DEFAULT_DISP_MODE;
-
- if (KB_E2PWrite(KB_NVM_VIDEO_DISPLAY_MODE_OFFSET, (UINT8 *)&gVidDispMode, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBSaveVideoAspectRatio(UINT8 buff )
- {
- gVidAspectRatio=buff;
-
- if(KB_E2PWrite(KB_NVM_VIDEO_ASPECT_RATIO_OFFSET, &buff, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBGetVideoAspectRatio(UINT8 *buff )
- {
- *buff=gVidAspectRatio;
-
- if(*buff>KB_AV_ASPECT_RATIO_16TO9)
- {
- *buff=KB_AV_DEFAULT_ASPECT_RATIO;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_InitVideoAspectRatio(void)
- {
- if (KB_E2PRead(KB_NVM_VIDEO_ASPECT_RATIO_OFFSET, (UINT8 *)&gVidAspectRatio, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_ResetVideoAspectRatio(void)
- {
- gVidAspectRatio=KB_AV_DEFAULT_ASPECT_RATIO;
-
- if (KB_E2PWrite(KB_NVM_VIDEO_ASPECT_RATIO_OFFSET, (UINT8 *)&gVidAspectRatio, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBSavePgmCurTrack(UINT8 buff )
- {
- gConfigAudioTrack=buff;
-
- if(KB_E2PWrite(KB_NVM_CONFIG_AUDIO_TRACK_OFFSET, &buff, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBGetPgmCurTrack(UINT8 *buff )
- {
- *buff=gConfigAudioTrack;
-
- if(*buff>STEREO_TRACK)
- {
- *buff=KB_AV_DEFAULT_TRACK;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_InitPgmCurTrack(void)
- {
- if (KB_E2PRead(KB_NVM_CONFIG_AUDIO_TRACK_OFFSET, (UINT8 *)&gConfigAudioTrack, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_ResetPgmCurTrack(void)
- {
- gConfigAudioTrack=KB_AV_DEFAULT_TRACK;
-
- if (KB_E2PWrite(KB_NVM_CONFIG_AUDIO_TRACK_OFFSET, (UINT8 *)&gConfigAudioTrack, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBSaveAdultRank(UINT8 buff )
- {
- gConfigAdultRank=buff;
-
- if(KB_E2PWrite(KB_NVM_CONFIG_ADULT_RANK_OFFSET, &buff, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBGetAdultRank(UINT8 *buff )
- {
- *buff=gConfigAdultRank;
-
- if(*buff>RANK_18)
- {
- *buff=KB_AV_DEFAULT_ADULT_RANK;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_InitAdultRank(void)
- {
- if (KB_E2PRead(KB_NVM_CONFIG_ADULT_RANK_OFFSET, (UINT8 *)&gConfigAdultRank, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_ResetAdultRank(void)
- {
- gConfigAdultRank=KB_AV_DEFAULT_ADULT_RANK;
-
- if (KB_E2PWrite(KB_NVM_CONFIG_ADULT_RANK_OFFSET, (UINT8 *)&gConfigAdultRank, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBSaveMenuLan(UINT8 buff )
- {
- gConfigMenuLan=buff;
-
- if(KB_E2PWrite(KB_NVM_CONFIG_MENU_LANG_OFFSET, &buff, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBGetMenuLan(UINT8 *buff )
- {
- *buff=gConfigMenuLan;
-
- if(*buff>=ENGLISH)
- {
- *buff=KB_DB_DEFAULT_MENU_LAN;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_InitMenuLan(void)
- {
- if (KB_E2PRead(KB_NVM_CONFIG_MENU_LANG_OFFSET, (UINT8 *)&gConfigMenuLan, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_ResetMenuLan(void)
- {
- gConfigMenuLan=KB_DB_DEFAULT_MENU_LAN;
-
- if (KB_E2PWrite(KB_NVM_CONFIG_MENU_LANG_OFFSET, (UINT8 *)&gConfigMenuLan, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBSaveMenuTran(UINT8 buff )
- {
- gConfigMenuTran=buff;
-
- if(KB_E2PWrite(KB_NVM_CONFIG_MENU_TRAN_OFFSET, &buff, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- KB_DBRET KB_DBGetMenuTran(UINT8 *buff )
- {
- *buff=gConfigMenuTran;
-
- if(*buff>=LEVEL_3)
- {
- *buff=KB_DB_DEFAULT_MENU_TRAN;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_InitMenuTran(void)
- {
- if (KB_E2PRead(KB_NVM_CONFIG_MENU_TRAN_OFFSET, (UINT8 *)&gConfigMenuTran, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- static KB_DBRET KD_ResetMenuTran(void)
- {
- gConfigMenuTran=KB_DB_DEFAULT_MENU_TRAN;
-
- if (KB_E2PWrite(KB_NVM_CONFIG_MENU_TRAN_OFFSET, (UINT8 *)&gConfigMenuTran, sizeof(UINT8), NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- //added by yyj 2007.6.27 end
-
- //added by yyj 2007.7.3 start
- KB_DBRET KD_ResetDemandInfo(void)
- {
- char head[9];
- //int nSize;
- KB_DBRET ret;
- //int *pnde;
- #if 0
- //先读取信息的总长度
- memset(head,0x00,9);
- ret=KB_DBGetDemandInfo(8,(UINT8 *)head);
- if(ret==RET_FAIL)
- return RET_FAIL;
- if(strncmp(head,EDHF_OPER_FLAG,4)!=0)
- return RET_OK;
- #endif
- KB_ClearAllDmdEnt();
- KB_ClearDataLink();
-
- //pnde=(int*)head;
- //nSize=*(pnde+1);
- //分配信息内存
- //debuf=(char*)KB_OSPMalloc(nSize);
- //if(NULL == debuf)
- //return RET_FAIL;
- //memset(debuf,0xFF,nSize);
- memset(head,0x00,9);
- if (KB_E2PWrite(KB_NVM_DEMAND_INFO_ADDR, (UINT8 *)head, 8, NULL) != RETOK)
- {
- return RET_FAIL;
- }
-
- return RET_OK;
- }
- //added by yyj 2007.7.3 end
- //added by yyj 2007.7.11 start
- KB_DBRET KB_DBSaveOtaPara(KB_DBOtaPara *buff)
- {
- UINT8 writeData[14];
- UINT32 i;
- for(i=0;i<14;i++) writeData[i]=0xFF;
- //printf("n[KB_DBSaveOtaPara]:freq=%ld, Symb=%ld, qam=%ld, pid=%ld",buff->freq, buff->Symb, buff->Qam, buff->PID);
-
- //频率的转换
- writeData[0]=(UINT8)((buff->freq>>24)&0x000000ff);
- writeData[1]=(UINT8)((buff->freq>>16)&0x000000ff);
- writeData[2]=(UINT8)((buff->freq>>8)&0x000000ff);
- writeData[3]=(UINT8)(buff->freq&0x000000ff);
- printf("nn--writeData[0]=%x",writeData[0]);
- printf("n--writeData[1]=%x",writeData[1]);
- printf("n--writeData[2]=%x",writeData[2]);
- printf("n--writeData[3]=%x",writeData[3]);
- //end
- //符号率的转换
- writeData[4]=(UINT8)((buff->Symb>>24)&0x000000ff);
- writeData[5]=(UINT8)((buff->Symb>>16)&0x000000ff);
- writeData[6]=(UINT8)((buff->Symb>>8)&0x000000ff);
- writeData[7]=(UINT8)(buff->Symb&0x000000ff);
- printf("nn--writeData[4]=%x",writeData[4]);
- printf("n--writeData[5]=%x",writeData[5]);
- printf("n--writeData[6]=%x",writeData[6]);
- printf("n--writeData[7]=%x",writeData[7]);
- //end
- writeData[8]=buff->Qam+3;
- writeData[9]=(buff->PID>>8)&0x000000ff;
- writeData[10]=buff->PID&0x000000ff;
- writeData[12]=0x01;
- writeData[13]=0x00;
- if(KB_E2PWrite(KB_NVM_UPDATE_BASE_ADDR, writeData, 14, NULL)!=Ret_OK)
- {
- printf("n Save OTA parameter error!");
- return RET_FAIL;
- }
- KB_OSPTaskDelay(500);
- #if 1
- {
- unsigned char flag[14];
- KB_E2PRead((UINT32)KB_NVM_UPDATE_BASE_ADDR, (UINT8 *)flag, (UINT32)14, NULL);
- printf("n 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x",flag[0],flag[1],flag[2],flag[3],flag[4],flag[5],flag[6],flag[7]);
- printf("n 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x",flag[8],flag[9],flag[10],flag[11],flag[12],flag[13]);
- }
- #endif
-
- return RET_OK;
- }
- unsigned short KB_DBGetPrgTsID(UINT8 type,int nPrgNO)
- {
- static KB_DBPrgInfo prgInfo;
- KB_DBChnnlInfo chnnlInfo;
- UINT8 bTrack;
- UINT8 bVolume;
- UINT8 bLockFlag;
- KB_DBGetPrgInfo(nPrgNO - 1, type, &prgInfo, &chnnlInfo, &bTrack, &bVolume, &bLockFlag);
- return prgInfo.TSID;
- }
- UINT16 KB_DBDelPrgInfoByTsidSrvid(UINT8 type,
- UINT16 Tsid,
- UINT16 SvcID)
- {
- int i = 0, j = 0;
- UINT16 total = 0;
- KB_DBPrgInfo *tmpPrgInfo = NULL;
- total = KB_DBGetPrgTotal(type);
- if (0 == total)
- {
- return KB_DB_DTV_FAILURE;
- }
- if (DTVPRG == type)
- {
- tmpPrgInfo = gPrgAllInfo.gDTVInfo.PgmList;
- }
- else if (RADIOPRG == type)
- {
- tmpPrgInfo = gPrgAllInfo.gRADInfo.PgmList;
- }
- else
- {
- printf("nKB_DBDelPrgInfo::input PrgType(%d) error!", type);
- return KB_DB_DTV_FAILURE;
- }
- for (j = 0; j < total; j++)
- {
- if (tmpPrgInfo[j].TSID == Tsid && tmpPrgInfo[j].SvcID == SvcID)
- {
- break;
- }
- }
- if (j >= total)
- {
- printf("nKB_DBDelPrgInfoByTsidSrvid::无匹配的srv");
- return KB_DB_DTV_FAILURE;
- }
- KB_DBDelFavPrg(type, Tsid, SvcID);
- for(i = j; i < total - 1; i++)
- {
- memcpy(&tmpPrgInfo[i], &tmpPrgInfo[i+1], sizeof(KB_DBPrgInfo));
- }
- if (DTVPRG == type)
- {
- gPrgAllInfo.gDTVInfo.nTotal--;
- }
- else if (RADIOPRG == type)
- {
- gPrgAllInfo.gRADInfo.nTotal--;
- }
- return KB_DB_DTV_SUCCESS;
- }
- UINT16 KD_GetPrgInxByTsidSvcID(UINT8 PrgType,
- UINT16 Tsid,
- UINT16 ServiceID)
- {
- UINT16 i = 0, sum = 0;
-
- sum = KB_DBGetPrgTotal(PrgType);
- if (0 == sum)
- {
- return KB_DB_INVALID_PROGRAMNO;
- }
- if (DTVPRG == PrgType)
- {
- for (i = 0; i < sum; ++i)
- {
- if (gPrgAllInfo.gDTVInfo.PgmList[i].SvcID == ServiceID
- && gPrgAllInfo.gDTVInfo.PgmList[i].TSID == Tsid)
- {
- return i;
- }
- }
- }
- else if (RADIOPRG== PrgType)
- {
- for (i = 0; i < sum; ++i)
- {
- if (gPrgAllInfo.gRADInfo.PgmList[i].SvcID == ServiceID
- && gPrgAllInfo.gRADInfo.PgmList[i].TSID == Tsid)
- {
- return i;
- }
- }
- }
- else if (DATAPRG== PrgType)
- {
- for (i = 0; i < sum; ++i)
- {
- if (gPrgAllInfo.gDATAInfo.PgmList[i].SvcID == ServiceID
- && gPrgAllInfo.gDATAInfo.PgmList[i].TSID == Tsid)
- {
- return i;
- }
- }
- }
- else
- {
- return KB_DB_INVALID_PROGRAMNO;
- }
- return KB_DB_INVALID_PROGRAMNO;
-
- }
- UINT8 KB_DBLockSrv(unsigned char type, UINT16 nPrgInx)
- {
- UINT16 total = 0xff;
- UINT16 IndexOfConfigInfo = 0xff;
-
- total = KB_DBGetPrgTotal(type);
-
- if(nPrgInx >= total || nPrgInx < 0)
- {
- printf("nKB_DBLockSrv::input nPrgInx(%d){total(%d)} error!",
- nPrgInx, total);
- return KB_DB_DTV_FAILURE;
- }
-
- if (DTVPRG == type)
- {
- IndexOfConfigInfo = gPrgAllInfo.gDTVInfo.PgmList[nPrgInx].IndexOfConfigInfo;
- gE2pData.gDTVPrgCfgInfo[IndexOfConfigInfo].Lock_Track_Vol |= 0x80;
- if (KB_E2PWrite((UINT16)(KB_NVM_DTV_PGM_CFG_ADDR + IndexOfConfigInfo * sizeof(KB_DBPrgConfigNode)),
- (UINT8 *)&gE2pData.gDTVPrgCfgInfo[IndexOfConfigInfo],
- sizeof(KB_DBPrgConfigNode), NULL) != RETOK)
- {
- printf("nKB_DBLockSrv::KB_E2PWrite gDTVPrgCfgInfo fail");
- return KB_DB_DTV_FAILURE;
- }
- }
- else if (RADIOPRG == type)
- {
- IndexOfConfigInfo = gPrgAllInfo.gRADInfo.PgmList[nPrgInx].IndexOfConfigInfo;
- gE2pData.gRADPrgCfgInfo[IndexOfConfigInfo].Lock_Track_Vol |= 0x80;
- if (KB_E2PWrite((UINT16)(KB_NVM_RAD_PGM_CFG_ADDR + IndexOfConfigInfo * sizeof(KB_DBPrgConfigNode)),
- (UINT8 *)&gE2pData.gRADPrgCfgInfo[IndexOfConfigInfo],
- sizeof(KB_DBPrgConfigNode), NULL) != RETOK)
- {
- printf("nKB_DBLockSrv::KB_E2PWrite gRADPrgCfgInfo fail");
- return KB_DB_DTV_FAILURE;
- }
- }
- else
- {
- printf("nKB_DBLockSrv::input PrgType(%d) error!", type);
- return KB_DB_DTV_FAILURE;
- }
-
- return KB_DB_DTV_SUCCESS;
- }
- UINT8 KB_DBUnlockSrv(unsigned char type, UINT16 nPrgInx)
- {
- UINT16 total = 0xff;
- UINT16 IndexOfConfigInfo = 0xff;
-
- total = KB_DBGetPrgTotal(type);
-
- if (nPrgInx >= total || nPrgInx < 0)
- {
- printf("nKB_DBUnlockSrv::input nPrgInx(%d){total(%d)} error!",
- nPrgInx, total);
- return KB_DB_DTV_FAILURE;
- }
-
- if (DTVPRG == type)
- {
- IndexOfConfigInfo = gPrgAllInfo.gDTVInfo.PgmList[nPrgInx].IndexOfConfigInfo;
- gE2pData.gDTVPrgCfgInfo[IndexOfConfigInfo].Lock_Track_Vol &= 0x7f;
- if (KB_E2PWrite((UINT16)(KB_NVM_DTV_PGM_CFG_ADDR + IndexOfConfigInfo * sizeof(KB_DBPrgConfigNode)),
- (UINT8 *)&gE2pData.gDTVPrgCfgInfo[IndexOfConfigInfo],
- sizeof(KB_DBPrgConfigNode), NULL) != RETOK)
- {
- printf("nKB_DBUnlockSrv::KB_E2PWrite gDTVPrgCfgInfo fail");
- return KB_DB_DTV_FAILURE;
- }
- }
- else if (RADIOPRG == type)
- {
- IndexOfConfigInfo = gPrgAllInfo.gRADInfo.PgmList[nPrgInx].IndexOfConfigInfo;
- gE2pData.gRADPrgCfgInfo[IndexOfConfigInfo].Lock_Track_Vol &= 0x7f;
- if (KB_E2PWrite((UINT16)(KB_NVM_RAD_PGM_CFG_ADDR + IndexOfConfigInfo * sizeof(KB_DBPrgConfigNode)),
- (UINT8 *)&gE2pData.gRADPrgCfgInfo[IndexOfConfigInfo],
- sizeof(KB_DBPrgConfigNode), NULL) != RETOK)
- {
- printf("nKB_DBUnlockSrv::KB_E2PWrite gRADPrgCfgInfo fail");
- return KB_DB_DTV_FAILURE;
- }
- }
- else
- {
- printf("nKB_DBUnlockSrv::input PrgType(%d) error!", type);
- return KB_DB_DTV_FAILURE;
- }
-
- return KB_DB_DTV_SUCCESS;
- }
- void KB_DBGetLockSrvInfo(UINT8 type,
- UINT16 *pNum,
- UINT16 PrgIndex[])
- {
- UINT8 LockFlag = 0xff;
- UINT16 loop = 0;
- UINT16 total = 0xffff;
- UINT16 IndexOfConfigInfo = 0xffff;
- if (NULL == pNum
- || NULL == PrgIndex
- || (DTVPRG != type && RADIOPRG != type))
- {
- printf("nKB_DBGetLockSrvInfo::input error. type(0x%x), pNum(0x%x), PrgIndex(0x%x)",
- type, pNum, PrgIndex);
- if (NULL != pNum)
- {
- *pNum = 0;
- }
-
- return;
- }
- //先初始被锁定的节目个数为0
- *pNum = 0;
-
- if (DTVPRG == type)
- {
- total = KB_DBGetPrgTotal(type);
-
- if (0 == total || total > KB_DB_MAX_DTV)
- {
- return;
- }
- for (loop = 0; loop < total; loop++)
- {
- IndexOfConfigInfo = gPrgAllInfo.gDTVInfo.PgmList[loop].IndexOfConfigInfo;
- if (IndexOfConfigInfo >= KB_DB_MAX_DTV)
- {
- printf("nKB_DBGetLockSrvInfo::Dtv IndexOfConfigInfo(0x%x) get error!",
- IndexOfConfigInfo);
- continue;
- }
-
- LockFlag = (gE2pData.gDTVPrgCfgInfo[IndexOfConfigInfo].Lock_Track_Vol & 0x80)>>7;
- //记录被锁定的节目个数和节目索引号
- if (1 == LockFlag)
- {
- PrgIndex[(*pNum)] = loop;
- (*pNum)++;
- }
- }
- }
- else if (RADIOPRG == type)
- {
- total = KB_DBGetPrgTotal(type);
-
- if (0 == total || total > KB_DB_MAX_RAD)
- {
- return;
- }
- for (loop = 0; loop < total; loop++)
- {
- IndexOfConfigInfo = gPrgAllInfo.gRADInfo.PgmList[loop].IndexOfConfigInfo;
- if (IndexOfConfigInfo >= KB_DB_MAX_RAD)
- {
- printf("nKB_DBGetLockSrvInfo::Rad IndexOfConfigInfo(0x%x) get error!",
- IndexOfConfigInfo);
- continue;
- }
-
- LockFlag = (gE2pData.gRADPrgCfgInfo[IndexOfConfigInfo].Lock_Track_Vol & 0x80)>>7;
- //记录被锁定的节目个数和节目索引号
- if (1 == LockFlag)
- {
- PrgIndex[(*pNum)] = loop;
- (*pNum)++;
- }
- }
- }
- else
- {
- printf("nKB_DBGetLockSrvInfo::input type(%d) error", type);
- return;
- }
- return;
- }
- BOOL KB_DBIsSrvLocked(UINT8 type, UINT16 nPrgInx)
- {
- UINT8 LockFlag = 0xff;
- UINT16 total = 0xffff;
- UINT16 IndexOfConfigInfo = 0xffff;
-
- if (DTVPRG == type)
- {
- total = KB_DBGetPrgTotal(type);
- if (nPrgInx >= total || nPrgInx >= KB_DB_MAX_DTV)
- {
- printf("nKB_DBIsSrvLocked::input Dtv nPrgInx(%d){total(%d)} error!",
- nPrgInx, total);
- return FALSE;
- }
-
- IndexOfConfigInfo = gPrgAllInfo.gDTVInfo.PgmList[nPrgInx].IndexOfConfigInfo;
- if (IndexOfConfigInfo >= KB_DB_MAX_DTV)
- {
- printf("nKB_DBIsSrvLocked::Dtv IndexOfConfigInfo(0x%x) get error!",
- IndexOfConfigInfo);
- return FALSE;
- }
- LockFlag = (gE2pData.gDTVPrgCfgInfo[IndexOfConfigInfo].Lock_Track_Vol & 0x80)>>7;
- if (1 == LockFlag)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- else if (RADIOPRG == type)
- {
- total = KB_DBGetPrgTotal(type);
- if (nPrgInx >= total || nPrgInx >= KB_DB_MAX_RAD)
- {
- printf("nKB_DBIsSrvLocked::input Rad nPrgInx(%d){total(%d)} error!",
- nPrgInx, total);
- return FALSE;
- }
-
- IndexOfConfigInfo = gPrgAllInfo.gRADInfo.PgmList[nPrgInx].IndexOfConfigInfo;
- if (IndexOfConfigInfo >= KB_DB_MAX_RAD)
- {
- printf("nKB_DBIsSrvLocked::Dtv IndexOfConfigInfo(0x%x) get error!",
- IndexOfConfigInfo);
- return FALSE;
- }
- LockFlag = (gE2pData.gRADPrgCfgInfo[IndexOfConfigInfo].Lock_Track_Vol & 0x80)>>7;
- if (1 == LockFlag)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- else
- {
- printf("nKB_DBIsSrvLocked::input type(%d) error", type);
- return FALSE;
- }
- }
- KB_DBRET KB_DBAddFavPrg(UINT8 type,
- UINT16 TsId,
- UINT16 SrvId)
- {
- UINT16 loop = 0;
- UINT16 total = 0;
-
- if (type != DTVPRG && type != RADIOPRG)
- {
- printf("nKB_DBAddFavPrg::input type(%d) error", type);
- return RET_FAIL;
- }
- if (TRUE != KB_DBIsPrgExist(type, TsId, SrvId))
- {
- printf("nKB_DBAddFavPrg::Prg type(%d)-TsId(%d)-SrvId(%d) not exist",
- type, TsId, SrvId);
- return RET_FAIL;
- }
- if (DTVPRG == type)
- {
- total = KB_DBGetFavPrgTotal(DTVPRG);
- if (total > KB_DB_MAX_FAV_DTV)
- {
- printf("nKB_DBAddFavPrg::dtv favor total(%d) exceeds max",
- total);
- return RET_FAIL;
- }
- for (loop = 0; loop < gE2pData.gDTVFavInfo.nTotal; loop++)
- {
- if (gE2pData.gDTVFavInfo.FavList[loop].TsId == TsId
- && gE2pData.gDTVFavInfo.FavList[loop].SrvId == SrvId)
- {
- printf("nKB_DBAddFavPrg::dtv favor Tsid(%d), SrvId(%d) repeat add!",
- TsId, SrvId);
- return RET_OK;
- }
- }
-
- gE2pData.gDTVFavInfo.FavList[total].TsId = TsId;
- gE2pData.gDTVFavInfo.FavList[total].SrvId = SrvId;
- gE2pData.gDTVFavInfo.nTotal++;
-
- if (KB_E2PWrite(KB_NVM_FAV_DTV_ADDR, (UINT8 *)&gE2pData.gDTVFavInfo, sizeof(KB_DBFavDtvInfo), NULL) != RETOK)
- {
- printf("nKB_DBAddFavPrg::KB_E2PWrite dtv fail");
- return RET_FAIL;
- }
- }
- else if (RADIOPRG == type)
- {
- total = KB_DBGetFavPrgTotal(RADIOPRG);
- if (total > KB_DB_MAX_FAV_RAD)
- {
- printf("nKB_DBAddFavPrg::radio favor total(%d) exceeds max",
- total);
- return RET_FAIL;
- }
- for (loop = 0; loop < gE2pData.gDTVFavInfo.nTotal; loop++)
- {
- if (gE2pData.gRADFavInfo.FavList[loop].TsId == TsId
- && gE2pData.gRADFavInfo.FavList[loop].SrvId == SrvId)
- {
- printf("nKB_DBAddFavPrg::radio favor Tsid(%d), SrvId(%d) repeat add!",
- TsId, SrvId);
- return RET_OK;
- }
- }
-
- gE2pData.gRADFavInfo.FavList[total].TsId = TsId;
- gE2pData.gRADFavInfo.FavList[total].SrvId = SrvId;
- gE2pData.gRADFavInfo.nTotal++;
-
- if (KB_E2PWrite(KB_NVM_FAV_RAD_ADDR, (UINT8 *)&gE2pData.gRADFavInfo, sizeof(KB_DBFavRadInfo), NULL) != RETOK)
- {
- printf("nKB_SystemSetUp::KB_E2PWrite radio fail");
- return RET_FAIL;
- }
- }
- return RET_OK;
- }
- void KB_DBFavPrgRefresh(void)
- {
- UINT8 i = 0;
- UINT8 j = 0;
- if (gE2pData.gDTVFavInfo.nTotal > KB_DB_MAX_FAV_DTV)
- {
- printf("nKB_DBFavPrgRefresh::dtv favor total(%d) exceeds max",
- gE2pData.gDTVFavInfo.nTotal);
- KD_ResetFavDtv();
- }
- else
- {
- for (i = 0; i < gE2pData.gDTVFavInfo.nTotal;)
- {
- if (TRUE != KB_DBIsPrgExist(DTVPRG,
- gE2pData.gDTVFavInfo.FavList[i].TsId,
- gE2pData.gDTVFavInfo.FavList[i].SrvId))
- {
- for (j = i; j < gE2pData.gDTVFavInfo.nTotal - 1 ;j++)
- {
- memcpy(&gE2pData.gDTVFavInfo.FavList[j],
- &gE2pData.gDTVFavInfo.FavList[j+1],
- sizeof(KB_DBFavNode));
- }
- gE2pData.gDTVFavInfo.nTotal--;
- }
- else
- {
- i++;
- }
- }
- }
- if (KB_E2PWrite(KB_NVM_FAV_DTV_ADDR, (UINT8 *)&gE2pData.gDTVFavInfo, sizeof(KB_DBFavDtvInfo), NULL) != RETOK)
- {
- printf("nKB_DBFavPrgRefresh::KB_E2PWrite dtv fail");
- }
- if (gE2pData.gRADFavInfo.nTotal > KB_DB_MAX_FAV_RAD)
- {
- printf("nKB_DBFavPrgRefresh::dtv favor total(%d) exceeds max",
- gE2pData.gRADFavInfo.nTotal);
- KD_ResetFavRad();
- }
- else
- {
- for (i = 0; i < gE2pData.gRADFavInfo.nTotal;)
- {
- if (TRUE != KB_DBIsPrgExist(RADIOPRG,
- gE2pData.gRADFavInfo.FavList[i].TsId,
- gE2pData.gRADFavInfo.FavList[i].SrvId))
- {
- for (j = i; j < gE2pData.gRADFavInfo.nTotal - 1 ;j++)
- {
- memcpy(&gE2pData.gRADFavInfo.FavList[j],
- &gE2pData.gRADFavInfo.FavList[j+1],
- sizeof(KB_DBFavNode));
- }
- gE2pData.gRADFavInfo.nTotal--;
- }
- else
- {
- i++;
- }
- }
- }
- if (KB_E2PWrite(KB_NVM_FAV_RAD_ADDR, (UINT8 *)&gE2pData.gRADFavInfo, sizeof(KB_DBFavRadInfo), NULL) != RETOK)
- {
- printf("nKB_DBFavPrgRefresh::KB_E2PWrite radio fail");
- }
- return;
- }
- void KB_DBGetFavPrgInfo(UINT8 type,
- UINT16 *pNum,
- UINT16 PrgIndex[])
- {
- UINT8 find = 0;
- UINT16 i = 0;
- UINT16 j = 0;
- if (NULL == pNum
- || NULL == PrgIndex
- || (DTVPRG != type && RADIOPRG != type))
- {
- printf("nKB_DBGetFavPrgInfo::input error. type(0x%x), pNum(0x%x), PrgIndex(0x%x)",
- type, pNum, PrgIndex);
-
- if (NULL != pNum)
- {
- *pNum = 0;
- }
-
- return;
- }
- //先初始喜爱的节目个数为0
- *pNum = 0;
- if (DTVPRG == type)
- {
- if (gE2pData.gDTVFavInfo.nTotal > KB_DB_MAX_FAV_DTV
- || 0 == gE2pData.gDTVFavInfo.nTotal)
- {
- printf("nKB_DBGetFavPrgInfo::gE2pData favor dtv total(%d) error.",
- gE2pData.gDTVFavInfo.nTotal);
- return;
- }
- if (gPrgAllInfo.gDTVInfo.nTotal > KB_DB_MAX_DTV)
- {
- printf("nKB_DBGetFavPrgInfo::gPrgAllInfo favor dtv total(%d) error.",
- gPrgAllInfo.gDTVInfo.nTotal);
- return;
- }
-
- for (i = 0; i < gE2pData.gDTVFavInfo.nTotal; )
- {
- find = 0;
- for (j = 0; j < gPrgAllInfo.gDTVInfo.nTotal; j++)
- {
- if (gPrgAllInfo.gDTVInfo.PgmList[j].TSID == gE2pData.gDTVFavInfo.FavList[i].TsId
- && gPrgAllInfo.gDTVInfo.PgmList[j].SvcID == gE2pData.gDTVFavInfo.FavList[i].SrvId)
- {
- PrgIndex[(*pNum)] = j;
- (*pNum)++;
- find = 1;
- break;
- }
- }
- //对gPrgAllInfo已经不存在的dtv fav的刷新处理
- if (0 == find)
- {
- for (j = i; j < gE2pData.gDTVFavInfo.nTotal - 1 ;j++)
- {
- memcpy(&gE2pData.gDTVFavInfo.FavList[j],
- &gE2pData.gDTVFavInfo.FavList[j+1],
- sizeof(KB_DBFavNode));
- }
- gE2pData.gDTVFavInfo.nTotal--;
-
- if (KB_E2PWrite(KB_NVM_FAV_DTV_ADDR, (UINT8 *)&gE2pData.gDTVFavInfo, sizeof(KB_DBFavDtvInfo), NULL) != RETOK)
- {
- printf("nKB_DBGetFavPrgInfo::KB_E2PWrite dtv fail");
- }
- }
- else
- {
- i++;
- }
- }
- }
- else if (RADIOPRG == type)
- {
- if (gE2pData.gRADFavInfo.nTotal > KB_DB_MAX_FAV_RAD
- || 0 == gE2pData.gRADFavInfo.nTotal)
- {
- printf("nKB_DBGetFavPrgInfo::gE2pData favor radio total(%d) error.",
- gE2pData.gRADFavInfo.nTotal);
- return;
- }
- if (gPrgAllInfo.gRADInfo.nTotal > KB_DB_MAX_RAD)
- {
- printf("nKB_DBGetFavPrgInfo::gPrgAllInfo favor radio total(%d) error.",
- gPrgAllInfo.gRADInfo.nTotal);
- return;
- }
- for (i = 0; i < gE2pData.gRADFavInfo.nTotal; )
- {
- find = 0;
- for (j = 0; j < gPrgAllInfo.gRADInfo.nTotal; j++)
- {
- if (gPrgAllInfo.gRADInfo.PgmList[j].TSID == gE2pData.gRADFavInfo.FavList[i].TsId
- && gPrgAllInfo.gRADInfo.PgmList[j].SvcID == gE2pData.gRADFavInfo.FavList[i].SrvId)
- {
- PrgIndex[(*pNum)] = j;
- (*pNum)++;
- find = 1;
- break;
- }
- }
- //对gPrgAllInfo已经不存在的radio fav的刷新处理
- if (0 == find)
- {
- for (j = i; j < gE2pData.gRADFavInfo.nTotal - 1 ;j++)
- {
- memcpy(&gE2pData.gRADFavInfo.FavList[j],
- &gE2pData.gRADFavInfo.FavList[j+1],
- sizeof(KB_DBFavNode));
- }
- gE2pData.gRADFavInfo.nTotal--;
- if (KB_E2PWrite(KB_NVM_FAV_RAD_ADDR, (UINT8 *)&gE2pData.gRADFavInfo, sizeof(KB_DBFavRadInfo), NULL) != RETOK)
- {
- printf("nKB_DBGetFavPrgInfo::KB_E2PWrite radio fail");
- }
- }
- else
- {
- i++;
- }
- }
- }
- else
- {
- printf("nKB_DBGetFavPrgInfo::input type(%d) error", type);
- return;
- }
-
- return;
- }
- void KB_DBGetFavPrgInfoInE2p(UINT8 type, void *pInfo)
- {
- if ((DTVPRG != type && RADIOPRG != type)
- || NULL == pInfo)
- {
- printf("nKB_DBGetFavPrgInfoInE2p::input error. type(%d), pInfo(0x%x)",
- type, pInfo);
- return;
- }
- if (DTVPRG == type)
- {
- memcpy(pInfo,
- &gE2pData.gDTVFavInfo,
- sizeof(KB_DBFavDtvInfo));
- }
- else if (RADIOPRG == type)
- {
- memcpy(pInfo,
- &gE2pData.gRADFavInfo,
- sizeof(KB_DBFavRadInfo));
- }
- else
- {
- printf("nKB_DBGetFavPrgInfoInE2p::input error. type(%d)",
- type);
- }
- return;
- }
- void KB_DBE2pCfgInfoRefresh(UINT8 nPrgType)
- {
- BOOL find = FALSE;
- UINT16 i = 0;
- UINT16 j = 0;
- switch(nPrgType)
- {
- case DTVPRG:
- {
- for (i = 0; i < KB_DB_MAX_DTV; ++i)
- {
- if (CONFIG_USED == gE2pData.gDTVPrgCfgInfo[i].Flag
- || (CONFIG_USED + 1) == gE2pData.gDTVPrgCfgInfo[i].Flag)
- {
- find = FALSE;
- for (j = 0; j < gPrgAllInfo.gDTVInfo.nTotal; j++)
- {
- if (i == gPrgAllInfo.gDTVInfo.PgmList[j].IndexOfConfigInfo)
- {
- find = TRUE;
- break;
- }
- }
- if (FALSE == find)
- {
- gE2pData.gDTVPrgCfgInfo[i].Flag = CONFIG_NO_USED;
- }
- }
- }
- }
- break;
-
- case RADIOPRG:
- {
- for (i = 0; i < KB_DB_MAX_RAD; ++i)
- {
- if (CONFIG_USED == gE2pData.gRADPrgCfgInfo[i].Flag
- || (CONFIG_USED + 1) == gE2pData.gRADPrgCfgInfo[i].Flag)
- {
- find = FALSE;
- for (j = 0; j < gPrgAllInfo.gRADInfo.nTotal; j++)
- {
- if (i == gPrgAllInfo.gRADInfo.PgmList[j].IndexOfConfigInfo)
- {
- find = TRUE;
- break;
- }
- }
- if (FALSE == find)
- {
- gE2pData.gRADPrgCfgInfo[i].Flag = CONFIG_NO_USED;
- }
- }
- }
- }
- break;
-
- case DATAPRG:
- {
- for (i = 0; i < KB_DB_MAX_DATA; ++i)
- {
- if (CONFIG_USED == gE2pData.gDATAPrgCfgInfo[i].Flag
- || (CONFIG_USED + 1) == gE2pData.gDATAPrgCfgInfo[i].Flag)
- {
- find = FALSE;
- for (j = 0; j < gPrgAllInfo.gDATAInfo.nTotal; j++)
- {
- if (i == gPrgAllInfo.gDATAInfo.PgmList[j].IndexOfConfigInfo)
- {
- find = TRUE;
- break;
- }
- }
- if (FALSE == find)
- {
- gE2pData.gRADPrgCfgInfo[i].Flag = CONFIG_NO_USED;
- }
- }
- }
- }
- break;
- default:
- printf("nKB_DBE2pCfgInfoRefresh::input PrgType(%d) error", nPrgType);
- break;
- }
- return;
- }