123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481 |
- /*****************************************************************************
- Copyright(c) 2013 FCI Inc. All Rights Reserved
- File name : fc8300_es2_tun.c
- Description : source of FC8300 tuner driver
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- History :
- ----------------------------------------------------------------------
- 0p1 -> initial driver
- 0p2 -> VCO Currunt Setting Add
- 1p2 -> 20130826
- 1p0 -> 20130730
- 1p1 -> 20130812
- 1p4 -> 20130821
- 1p5 -> 20130826
- 1p6 -> 20130827
- 1p7 -> 20130830
- 1p8 -> 20130902
- 2p1 -> 20130911
- 2p5 -> 20131108
- *******************************************************************************/
- #include "fci_types.h"
- #include "fci_oal.h"
- #include "fci_tun.h"
- #include "fci_hal.h"
- #include "fc8300_regs.h"
- #include "fc8300_es2_tun.h"
- #define DRIVER_VERSION 0x25 /* Driver M2_V2p5*/
- #define RFADC_Count 3
- #define Cal_Repeat 1
- #define FC8300_XTAL_FREQ BBM_XTAL_FREQ
- #define FC8300_BAND_WIDTH BBM_BAND_WIDTH
- static enum BROADCAST_TYPE broadcast_type = ISDBT_13SEG;
- static u8 catv_status;
- static u8 broad_check;
- /* RF_Driver */
- static u32 thread_freq[4] = {707143, 707143, 707143, 707143};
- static u32 bc_type[4] = {0, 0, 0, 0};
- static u8 device_set;
- static u8 thread_set;
- static u8 thread_check;
- static u8 fc_cal_value[4] = {0, 0, 0, 0};
- static u8 status_1seg[4] = {0, 0, 0, 0};
- static s8 status_13seg[4] = {0, 0, 0, 0};
- static HANDLE t_handle;
- static DEVICEID t_devid[4] = {DIV_MASTER, DIV_SLAVE0, DIV_SLAVE1, DIV_SLAVE2};
- static s32 fc8300_write(HANDLE handle, DEVICEID devid, u8 addr, u8 data)
- {
- s32 res;
- res = tuner_i2c_write(handle, devid, addr, 1, &data, 1);
- return res;
- }
- static s32 fc8300_read(HANDLE handle, DEVICEID devid, u8 addr, u8 *data)
- {
- s32 res;
- res = tuner_i2c_read(handle, devid, addr, 1, data, 1);
- return res;
- }
- #if 0
- static s32 fc8300_bb_write(HANDLE handle, DEVICEID devid, u16 addr, u8 data)
- {
- s32 res;
- res = bbm_write(handle, devid, addr, data);
- return res;
- }
- static s32 fc8300_bb_read(HANDLE handle, DEVICEID devid, u16 addr, u8 *data)
- {
- s32 res;
- res = bbm_read(handle, devid, addr, data);
- return res;
- }
- #endif
- #ifdef BBM_ES_CURRENT
- static u32 KbdFunc()
- {
- s32 res = BBM_OK;
- s32 i = 0;
- u8 up_low_limit = 182;
- u8 up_high_limit = 217;
- u8 down_low_limit = 177;
- u8 down_high_limit = 212;
- u8 rssi_buf[4] = {0, 0, 0, 0};
- u8 min = 0;
- u8 max = 0;
- u8 check_thread;
- u8 rssi_buff[4][5] = {
- {0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0}
- };
- u8 lna_temp;
- u8 atten_temp;
- u8 filter_temp;
- u8 lna_set = 0x44;
- u8 lna_set1 = 0x44;
- u8 lna_set2 = 0x46;
- u8 lna_set3 = 0x47;
- while (thread_set) {
- fc8300_read(t_handle, t_devid[0], 0xfa, &check_thread);
- if (check_thread != 0) {
- fc8300_write(t_handle, t_devid[0], 0xfa, 0xee);
- thread_set = 0;
- _endthread();
- }
- if ((device_set & 0x01) == 1) {
- if (bc_type[0] == ISDBT_13SEG) {
- lna_set = 0x46;
- fc8300_read(t_handle, t_devid[0], 0xeb,
- &rssi_buff[0][0]);
- fc8300_read(t_handle, t_devid[0], 0xeb,
- &rssi_buff[0][1]);
- fc8300_read(t_handle, t_devid[0], 0xeb,
- &rssi_buff[0][2]);
- fc8300_read(t_handle, t_devid[0], 0xeb,
- &rssi_buff[0][3]);
- fc8300_read(t_handle, t_devid[0], 0xeb,
- &rssi_buff[0][4]);
- for (i = 0; i < 4; i++) {
- if (rssi_buff[0][max] >
- rssi_buff[0][i+1])
- max = i + 1;
- }
- for (i = 0; i < 4; i++) {
- if (rssi_buff[0][min] <
- rssi_buff[0][i+1])
- min = i + 1;
- }
- rssi_buff[0][min] = 0;
- rssi_buff[0][max] = 0;
- rssi_buf[0] = (rssi_buff[0][0] +
- rssi_buff[0][1] +
- rssi_buff[0][2] +
- rssi_buff[0][3] +
- rssi_buff[0][4]) / 3;
- /*status_13seg[0] 1 => Buff ON*/
- /*status_13seg[0] 0 => Buff OFF*/
- if (thread_freq[0] >= 647143) {
- if (status_13seg[0] == 0) {
- if (rssi_buf[0] > up_low_limit
- && rssi_buf[0] <
- down_high_limit) {
- fc8300_write(
- t_handle,
- t_devid[0],
- 0x03, 0x00);
- status_13seg[0]
- = 1;
- }
- } else if (status_13seg[0] == 1) {
- if (rssi_buf[0] <
- down_low_limit ||
- rssi_buf[0] >
- up_high_limit) {
- fc8300_write(
- t_handle,
- t_devid[0],
- 0x03, 0x04);
- status_13seg[0]
- = 0;
- }
- }
- } else if (thread_freq[0] < 647143 &&
- status_13seg[0] == 1) {
- fc8300_write(t_handle, t_devid[0],
- 0x03, 0x04);
- status_13seg[0] = 0;
- }
- }
- if (bc_type[0] == ISDBT_1SEG) {
- if (thread_freq[0] < 590000)
- lna_set = lna_set3;
- else
- lna_set = lna_set2;
- }
- fc8300_read(t_handle, t_devid[0], 0x95, &lna_temp);
- fc8300_read(t_handle, t_devid[0], 0x96, &atten_temp);
- fc8300_read(t_handle, t_devid[0], 0xd2, &filter_temp);
- lna_temp = lna_temp & 0x0f;
- atten_temp = atten_temp & 0x0f;
- if (filter_temp >= 9) {
- if (status_1seg[0] == 0) {
- fc8300_write(t_handle, t_devid[0],
- 0x15, 0x44);
- status_1seg[0] = 1;
- }
- } else if (filter_temp < 9) {
- if ((atten_temp >= 1) || (lna_temp >= 1)) {
- if (status_1seg[0] == 1) {
- fc8300_write(t_handle,
- t_devid[0],
- 0x15, lna_set);
- status_1seg[0] = 0;
- }
- } else {
- if (status_1seg[0] == 0) {
- fc8300_write(t_handle,
- t_devid[0], 0x15, 0x44);
- status_1seg[0] = 1;
- }
- }
- }
- /*
- if (lna_temp >= 1) {
- if ((filter_temp < 9) && (status_15[0] != 1)) {
- fc8300_write(t_handle, t_devid[0],
- 0x15, lna_set);
- status_15[0] = 1;
- } else if ((filter_temp >= 9) &&
- (status_15[0] != 2)) {
- fc8300_write(t_handle, t_devid[0],
- 0x15, 0x41);
- status_15[0] = 2;
- }
- }
- */
- }
- if ((device_set & 0x02) == 2) {
- if (bc_type[1] == ISDBT_13SEG) {
- lna_set = 0x46;
- fc8300_read(t_handle, t_devid[1], 0xeb,
- &rssi_buff[1][0]);
- fc8300_read(t_handle, t_devid[1], 0xeb,
- &rssi_buff[1][1]);
- fc8300_read(t_handle, t_devid[1], 0xeb,
- &rssi_buff[1][2]);
- fc8300_read(t_handle, t_devid[1], 0xeb,
- &rssi_buff[1][3]);
- fc8300_read(t_handle, t_devid[1], 0xeb,
- &rssi_buff[1][4]);
- for (i = 0; i < 4; i++) {
- if (rssi_buff[1][max] >
- rssi_buff[1][i+1])
- max = i + 1;
- }
- for (i = 0; i < 4; i++) {
- if (rssi_buff[1][min] <
- rssi_buff[1][i+1])
- min = i + 1;
- }
- rssi_buff[1][min] = 0;
- rssi_buff[1][max] = 0;
- rssi_buf[1] = (rssi_buff[1][0] +
- rssi_buff[1][1] +
- rssi_buff[1][2] +
- rssi_buff[1][3] +
- rssi_buff[1][4]) / 3;
- /*status_13seg[1] 1 => Buff ON*/
- /*status_13seg[1] 0 => Buff OFF*/
- if (thread_freq[1] >= 647143) {
- if (status_13seg[1] == 0) {
- if (rssi_buf[1] >
- up_low_limit &&
- rssi_buf[1] <
- down_high_limit) {
- fc8300_write(
- t_handle,
- t_devid[1],
- 0x03, 0x00);
- status_13seg[1] = 1;
- }
- } else if (status_13seg[1] == 1) {
- if (rssi_buf[1] <
- down_low_limit ||
- rssi_buf[1] >
- up_high_limit) {
- fc8300_write(t_handle,
- t_devid[1],
- 0x03, 0x04);
- status_13seg[1] = 0;
- }
- }
- } else if (thread_freq[1] < 647143 &&
- status_13seg[1] == 1) {
- fc8300_write(t_handle, t_devid[1],
- 0x03, 0x04);
- status_13seg[1] = 0;
- }
- }
- if (bc_type[1] == ISDBT_1SEG) {
- if (thread_freq[1] < 590000)
- lna_set = lna_set3;
- else
- lna_set = lna_set1;
- }
- fc8300_read(t_handle, t_devid[1], 0x95, &lna_temp);
- fc8300_read(t_handle, t_devid[1], 0x96, &atten_temp);
- fc8300_read(t_handle, t_devid[1], 0xd2, &filter_temp);
- lna_temp = lna_temp & 0x0f;
- atten_temp = atten_temp & 0x0f;
- if (filter_temp >= 9) {
- if (status_1seg[1] == 0) {
- fc8300_write(t_handle, t_devid[1],
- 0x15, 0x44);
- status_1seg[1] = 1;
- }
- } else if (filter_temp < 9) {
- if ((atten_temp >= 1) || (lna_temp >= 1)) {
- if (status_1seg[1] == 1) {
- fc8300_write(t_handle,
- t_devid[1],
- 0x15, lna_set);
- status_1seg[1] = 0;
- }
- } else {
- if (status_1seg[1] == 0) {
- fc8300_write(t_handle,
- t_devid[1],
- 0x15, 0x44);
- status_1seg[1] = 1;
- }
- }
- }
- }
- if ((device_set & 0x04) == 4) {
- if (bc_type[2] == ISDBT_13SEG) {
- lna_set = 0x46;
- fc8300_read(t_handle, t_devid[2], 0xeb,
- &rssi_buff[2][0]);
- fc8300_read(t_handle, t_devid[2], 0xeb,
- &rssi_buff[2][1]);
- fc8300_read(t_handle, t_devid[2], 0xeb,
- &rssi_buff[2][2]);
- fc8300_read(t_handle, t_devid[2], 0xeb,
- &rssi_buff[2][3]);
- fc8300_read(t_handle, t_devid[2], 0xeb,
- &rssi_buff[2][4]);
- for (i = 0; i < 4; i++) {
- if (rssi_buff[2][max] >
- rssi_buff[2][i+1])
- max = i + 1;
- }
- for (i = 0; i < 4; i++) {
- if (rssi_buff[2][min] <
- rssi_buff[2][i+1])
- min = i + 1;
- }
- rssi_buff[2][min] = 0;
- rssi_buff[2][max] = 0;
- rssi_buf[2] = (rssi_buff[2][0] +
- rssi_buff[2][1] +
- rssi_buff[2][2] +
- rssi_buff[2][3] +
- rssi_buff[2][4]) / 3;
- /*status_13seg[2] 1 => Buff ON*/
- /*status_13seg[2] 0 => Buff OFF*/
- if (thread_freq[2] >= 647143) {
- if (status_13seg[2] == 0) {
- if (rssi_buf[2] > up_low_limit
- && rssi_buf[2] <
- down_high_limit) {
- fc8300_write(
- t_handle,
- t_devid[2],
- 0x03, 0x00);
- status_13seg[2]
- = 1;
- }
- } else if (status_13seg[2] == 1) {
- if (rssi_buf[2] <
- down_low_limit ||
- rssi_buf[2] >
- up_high_limit) {
- fc8300_write(
- t_handle,
- t_devid[2],
- 0x03, 0x04);
- status_13seg[2]
- = 0;
- }
- }
- } else if (thread_freq[2] < 647143 &&
- status_13seg[2] == 1) {
- fc8300_write(t_handle, t_devid[2],
- 0x03, 0x04);
- status_13seg[2] = 0;
- }
- }
- if (bc_type[2] == ISDBT_1SEG) {
- if (thread_freq[2] < 590000)
- lna_set = lna_set3;
- else
- lna_set = lna_set1;
- }
- fc8300_read(t_handle, t_devid[2], 0x95, &lna_temp);
- fc8300_read(t_handle, t_devid[2], 0x96, &atten_temp);
- fc8300_read(t_handle, t_devid[2], 0xd2, &filter_temp);
- lna_temp = lna_temp & 0x0f;
- atten_temp = atten_temp & 0x0f;
- if (filter_temp >= 9) {
- if (status_1seg[2] == 0) {
- fc8300_write(t_handle, t_devid[2],
- 0x15, 0x44);
- status_1seg[2] = 1;
- }
- } else if (filter_temp < 9) {
- if ((atten_temp >= 1) || (lna_temp >= 1)) {
- if (status_1seg[2] == 1) {
- fc8300_write(t_handle,
- t_devid[2], 0x15,
- lna_set);
- status_1seg[2] = 0;
- }
- } else {
- if (status_1seg[2] == 0) {
- fc8300_write(t_handle,
- t_devid[2],
- 0x15, 0x44);
- status_1seg[2] = 1;
- }
- }
- }
- }
- if ((device_set & 0x08) == 8) {
- if (bc_type[3] == ISDBT_13SEG) {
- lna_set = 0x46;
- fc8300_read(t_handle, t_devid[3], 0xeb,
- &rssi_buff[3][0]);
- fc8300_read(t_handle, t_devid[3], 0xeb,
- &rssi_buff[3][1]);
- fc8300_read(t_handle, t_devid[3], 0xeb,
- &rssi_buff[3][2]);
- fc8300_read(t_handle, t_devid[3], 0xeb,
- &rssi_buff[3][3]);
- fc8300_read(t_handle, t_devid[3], 0xeb,
- &rssi_buff[3][4]);
- for (i = 0; i < 4; i++) {
- if (rssi_buff[3][max] >
- rssi_buff[3][i+1])
- max = i + 1;
- }
- for (i = 0; i < 4; i++) {
- if (rssi_buff[3][min] <
- rssi_buff[3][i+1])
- min = i + 1;
- }
- rssi_buff[3][min] = 0;
- rssi_buff[3][max] = 0;
- rssi_buf[3] = (rssi_buff[3][0] +
- rssi_buff[3][1] +
- rssi_buff[3][2] +
- rssi_buff[3][3] +
- rssi_buff[3][4]) / 3;
- /*status_13seg[3] 1 => Buff ON*/
- /*status_13seg[3] 0 => Buff OFF*/
- if (thread_freq[3] >= 647143) {
- if (status_13seg[3] == 0) {
- if (rssi_buf[3] > up_low_limit
- && rssi_buf[3] <
- down_high_limit) {
- fc8300_write(
- t_handle,
- t_devid[3],
- 0x03, 0x00);
- status_13seg[3]
- = 1;
- }
- } else if (status_13seg[3] == 1) {
- if (rssi_buf[3] <
- down_low_limit ||
- rssi_buf[3] >
- up_high_limit) {
- fc8300_write(
- t_handle,
- t_devid[3],
- 0x03, 0x04);
- status_13seg[3]
- = 0;
- }
- }
- } else if (thread_freq[3] < 647143 &&
- status_13seg[3] == 1) {
- fc8300_write(t_handle, t_devid[3],
- 0x03, 0x04);
- status_13seg[3] = 0;
- }
- }
- if (bc_type[3] == ISDBT_1SEG) {
- if (thread_freq[3] < 590000)
- lna_set = lna_set3;
- else
- lna_set = lna_set1;
- }
- fc8300_read(t_handle, t_devid[3], 0x95, &lna_temp);
- fc8300_read(t_handle, t_devid[3], 0x96, &atten_temp);
- fc8300_read(t_handle, t_devid[3], 0xd2, &filter_temp);
- lna_temp = lna_temp & 0x0f;
- atten_temp = atten_temp & 0x0f;
- if (filter_temp >= 9) {
- if (status_1seg[3] == 0) {
- fc8300_write(t_handle, t_devid[3],
- 0x15, 0x44);
- status_1seg[3] = 1;
- }
- } else if (filter_temp < 9) {
- if ((atten_temp >= 1) || (lna_temp >= 1)) {
- if (status_1seg[3] == 1) {
- fc8300_write(t_handle,
- t_devid[3], 0x15,
- lna_set);
- status_1seg[3] = 0;
- }
- } else {
- if (status_1seg[3] == 0) {
- fc8300_write(t_handle,
- t_devid[3],
- 0x15, 0x44);
- status_1seg[3] = 1;
- }
- }
- }
- }
- msWait(300);
- }
- fc8300_write(t_handle, t_devid[0], 0xfa, 0xcc);
- _endthread();
- return BBM_OK;
- }
- #endif
- static u8 tf_cal(HANDLE handle, DEVICEID devid)
- {
- u8 rfadc[RFADC_Count];
- u32 rfadc_avg = 0;
- u8 max_cb_code[Cal_Repeat] = {0};
- u8 max_rfadc[Cal_Repeat] = {0};
- u8 cal_temp;
- u32 x, i, j;
- for (x = 0; x < Cal_Repeat; x++) {
- for (i = 3; i < 12; i++) {
- cal_temp = (16 + i);
- fc8300_write(handle, devid, 0x1c, cal_temp);
- rfadc_avg = 0;
- for (j = 0; j < RFADC_Count; j++) {
- fc8300_read(handle, devid, 0xf5, &rfadc[j]);
- rfadc_avg = rfadc_avg + rfadc[j];
- }
- rfadc_avg = rfadc_avg / RFADC_Count;
- if (max_rfadc[x] < rfadc_avg) {
- max_rfadc[x] = (u8)rfadc_avg;
- max_cb_code[x] = (16 + i);
- }
- }
- }
- return max_cb_code[0];
- }
- static s32 fc8300_tuner_set_pll(HANDLE handle, DEVICEID devid, u32 freq,
- u32 offset)
- {
- u8 data_0x51, data_0x57, lo_select, lo_div;
- u32 f_diff, f_diff_shifted, n_val, k_val;
- u32 f_vco, f_comp, f_lo_kHz;
- u32 f_vco_max = 6200000;
- u8 lo_divide_ratio[8] = {8, 12, 16, 24, 32, 48, 64, 96};
- u32 r_val;
- u8 pre_shift_bits = 4;
- u8 lock_detect = 0;
- u8 i;
- f_lo_kHz = freq;
- for (lo_select = 0; lo_select < 7; lo_select++)
- if (f_vco_max < f_lo_kHz * lo_divide_ratio[lo_select + 1])
- break;
- lo_div = lo_divide_ratio[lo_select];
- f_vco = f_lo_kHz * lo_div;
- r_val = 1;
- f_comp = FC8300_XTAL_FREQ / r_val;
- n_val = f_vco / f_comp;
- f_diff = f_vco - f_comp * n_val;
- f_diff_shifted = f_diff << (20 - pre_shift_bits);
- k_val = f_diff_shifted / (f_comp >> pre_shift_bits);
- k_val = k_val | 1;
- data_0x57 = ((n_val >> 3) & 0x20);
- data_0x57 += (r_val == 1) ? 0 : 0x10;
- data_0x57 += (k_val >> 16);
- data_0x51 = 0x00;
- data_0x51 += (lo_select * 2) + 1;
- fc8300_write(handle, devid, 0x7C, 0x00);
- fc8300_write(handle, devid, 0x7E, 0x00);
- fc8300_write(handle, devid, 0x7F, 0x00);
- fc8300_write(handle, devid, 0x80, 0x00);
- fc8300_write(handle, devid, 0x81, 0x00);
- fc8300_write(handle, devid, 0x15, 0x77);
- fc8300_write(handle, devid, 0x91, 0xA8);
- fc8300_write(handle, devid, 0x70, 0x63);
- fc8300_write(handle, devid, 0x6a, 0x00);
- fc8300_write(handle, devid, 0x51, data_0x51);
- fc8300_write(handle, devid, 0x57, data_0x57);
- fc8300_write(handle, devid, 0x58, (u8) ((k_val >> 8) & 0xFF));
- fc8300_write(handle, devid, 0x5a, (u8) n_val);
- fc8300_write(handle, devid, 0x59, (u8) ((k_val) & 0xFF));
- fc8300_write(handle, devid, 0x50, 0xe3);
- fc8300_write(handle, devid, 0x50, 0xff);
- for (i = 1; i < 15; i++) {
- fc8300_read(handle, devid, 0x64, &lock_detect);
- if ((lock_detect & 0x01) == 1) {
- fc8300_read(handle, devid, 0x65, &lock_detect);
- fc8300_write(handle, devid, 0x6d, (lock_detect | 0x0f));
- fc8300_write(handle, devid, 0x6f, (lock_detect | 0x0f) +
- 0x10);
- fc8300_write(handle, devid, 0x70, 0x40);
- fc8300_write(handle, devid, 0x6a, 0x10);
- break;
- }
- msWait(2);
- }
- for (i = 1; i < 15; i++) {
- fc8300_read(handle, devid, 0x76, &lock_detect);
- if (lock_detect == 0x20) {
- fc8300_write(handle, devid, 0x5a, (u8) n_val);
- fc8300_write(handle, devid, 0x50, 0xe3);
- fc8300_write(handle, devid, 0x50, 0xff);
- break;
- }
- msWait(2);
- }
- if (broadcast_type == ISDBT_CATV_13SEG) {
- fc8300_write(handle, devid, 0x91, 0xa8);
- fc8300_write(handle, devid, 0x15, 0x47);
- fc8300_write(handle, devid, 0x19, 0x46);
- } else {
- fc8300_write(handle, devid, 0x91, 0x78);
- fc8300_write(handle, devid, 0x15, 0x46);
- }
- fc8300_write(handle, devid, 0x7C, 0x30);
- fc8300_write(handle, devid, 0x7E, 0x05);
- fc8300_write(handle, devid, 0x7F, 0x0A);
- fc8300_write(handle, devid, 0x80, 0x3F);
- fc8300_write(handle, devid, 0x81, 0x3F);
- return BBM_OK;
- }
- s32 fc8300_es2_vhf(HANDLE handle, DEVICEID devid)
- {
- u8 i = 0;
- u8 filter_cal_60 = 0;
- u8 temp = 0;
- filter_cal_60 = FC8300_XTAL_FREQ * 72 / 30000;
- fc8300_write(handle, devid, 0x00, 0x00);
- fc8300_write(handle, devid, 0x02, 0x03);
- fc8300_write(handle, devid, 0x03, 0x00);
- fc8300_write(handle, devid, 0x08, 0xe5);
- fc8300_write(handle, devid, 0x1c, 0x00);
- fc8300_write(handle, devid, 0x1d, 0x00);
- fc8300_write(handle, devid, 0x21, 0x20);
- fc8300_write(handle, devid, 0x24, 0x98);
- fc8300_write(handle, devid, 0x5f, 0x40);
- fc8300_write(handle, devid, 0x3f, 0x01);
- fc8300_write(handle, devid, 0x41, filter_cal_60);
- fc8300_write(handle, devid, 0x3f, 0x00);
- fc8300_write(handle, devid, 0x3c, 0xff);
- fc8300_write(handle, devid, 0x3d, 0xff);
- fc8300_write(handle, devid, 0x70, 0x5f);
- fc8300_write(handle, devid, 0x04, 0x10);
- fc8300_write(handle, devid, 0xed, 0xcc);
- fc8300_write(handle, devid, 0x82, 0x88);
- fc8300_write(handle, devid, 0x7c, 0x01);
- fc8300_write(handle, devid, 0x84, 0x0f);
- fc8300_write(handle, devid, 0x85, 0x0a);
- fc8300_write(handle, devid, 0x86, 0x1f);
- fc8300_write(handle, devid, 0x87, 0x0f);
- fc8300_write(handle, devid, 0x88, 0x0f);
- fc8300_write(handle, devid, 0x89, 0x0b);
- fc8300_write(handle, devid, 0x8a, 0x15);
- fc8300_write(handle, devid, 0x8b, 0x0b);
- fc8300_write(handle, devid, 0x78, 0x30);
- fc8300_write(handle, devid, 0x7e, 0x05);
- fc8300_write(handle, devid, 0x7f, 0x0a);
- fc8300_write(handle, devid, 0xb2, 0x00);
- fc8300_write(handle, devid, 0xb3, 0x0c);
- fc8300_write(handle, devid, 0xb4, 0x00);
- fc8300_write(handle, devid, 0xb5, 0x0a);
- fc8300_write(handle, devid, 0xb6, 0x00);
- fc8300_write(handle, devid, 0xb7, 0x0a);
- fc8300_write(handle, devid, 0xb8, 0x00);
- fc8300_write(handle, devid, 0xb9, 0x0a);
- fc8300_write(handle, devid, 0xba, 0x00);
- fc8300_write(handle, devid, 0xbb, 0x0a);
- fc8300_write(handle, devid, 0xbc, 0x00);
- fc8300_write(handle, devid, 0xbd, 0x0a);
- fc8300_write(handle, devid, 0xbe, 0x00);
- fc8300_write(handle, devid, 0xbf, 0x0a);
- fc8300_write(handle, devid, 0xc0, 0x0a);
- fc8300_write(handle, devid, 0xc1, 0x00);
- fc8300_write(handle, devid, 0xc2, 0x13);
- fc8300_write(handle, devid, 0xc3, 0x00);
- fc8300_write(handle, devid, 0xf1, 0x53);
- fc8300_write(handle, devid, 0xd3, 0x00);
- fc8300_write(handle, devid, 0xd4, 0x02);
- fc8300_write(handle, devid, 0xd5, 0x04);
- fc8300_write(handle, devid, 0xd6, 0x14);
- fc8300_write(handle, devid, 0xd7, 0x34);
- fc8300_write(handle, devid, 0xd8, 0x36);
- fc8300_write(handle, devid, 0xd9, 0x38);
- fc8300_write(handle, devid, 0xda, 0x78);
- fc8300_write(handle, devid, 0xdb, 0xb8);
- fc8300_write(handle, devid, 0xdc, 0xf8);
- fc8300_write(handle, devid, 0xdd, 0xf8);
- fc8300_write(handle, devid, 0x33, 0x88);
- fc8300_write(handle, devid, 0x34, 0x86);
- fc8300_write(handle, devid, 0x37, 0x64);
- fc8300_write(handle, devid, 0x38, 0x44);
- fc8300_write(handle, devid, 0x39, 0x02);
- fc8300_write(handle, devid, 0x3e, 0xab);
- fc8300_write(handle, devid, 0x13, 0x07);
- fc8300_write(handle, devid, 0x15, 0x47);
- fc8300_write(handle, devid, 0x84, 0x0f);
- fc8300_write(handle, devid, 0x85, 0x0a);
- fc8300_write(handle, devid, 0x86, 0x3f);
- fc8300_write(handle, devid, 0x87, 0x2f);
- fc8300_write(handle, devid, 0x8f, 0xb6);
- fc8300_write(handle, devid, 0x90, 0xb2);
- fc8300_write(handle, devid, 0x91, 0xa8);
- fc8300_write(handle, devid, 0x16, 0x42);
- fc8300_write(handle, devid, 0x17, 0x42);
- fc8300_write(handle, devid, 0x1a, 0x42);
- fc8300_write(handle, devid, 0x1f, 0x77);
- fc8300_write(handle, devid, 0x20, 0x42);
- fc8300_write(handle, devid, 0xe9, 0x79);
- fc8300_write(handle, devid, 0xef, 0xb7);
- for (i = 0; i < 30 ; i++) {
- msWait(1);
- fc8300_read(handle, devid, 0x43, &temp);
- if (((temp >> 4) & 0x01) == 1)
- break;
- }
- fc8300_write(handle, devid, 0x5f, 0x00);
- fc8300_write(handle, devid, 0x78, 0xf0);
- msWait(5);
- fc8300_write(handle, devid, 0x78, 0x30);
- fc8300_write(handle, devid, 0xfb, FC8300_BAND_WIDTH);
- fc8300_write(handle, devid, 0xfc, broadcast_type);
- fc8300_write(handle, devid, 0xfd, (u8)(FC8300_XTAL_FREQ / 1000));
- fc8300_write(handle, devid, 0xfe, DRIVER_VERSION);
- if (FC8300_XTAL_FREQ < 20000)
- fc8300_write(handle, devid, 0xF3, 0x55);
- else if (FC8300_XTAL_FREQ > 20000)
- fc8300_write(handle, devid, 0xF3, 0x54);
- /* PLL AGC All Broadcast */
- fc8300_write(handle, devid, 0xF4, 0xFF);
- fc8300_write(handle, devid, 0xB5, 0x0A);
- fc8300_write(handle, devid, 0xB7, 0x0A);
- fc8300_write(handle, devid, 0xB9, 0x0A);
- fc8300_write(handle, devid, 0xBB, 0x0A);
- fc8300_write(handle, devid, 0x50, 0xff);
- fc8300_write(handle, devid, 0x5f, 0x00);
- fc8300_write(handle, devid, 0x6a, 0x00);
- fc8300_write(handle, devid, 0x6b, 0x99);
- fc8300_write(handle, devid, 0x6c, 0x99);
- fc8300_write(handle, devid, 0x6e, 0x03);
- fc8300_write(handle, devid, 0x73, 0x66);
- fc8300_write(handle, devid, 0x74, 0x66);
- fc8300_write(handle, devid, 0x75, 0x30);
- fc8300_write(handle, devid, 0xfa, 0xff);
- return BBM_OK;
- }
- s32 fc8300_es2_uhf(HANDLE handle, DEVICEID devid)
- {
- u8 i = 0;
- u8 filter_cal_60 = 0;
- u8 temp = 0;
- filter_cal_60 = FC8300_XTAL_FREQ * 72 / 30000;;
- fc8300_write(handle, devid, 0x00, 0x00);
- fc8300_write(handle, devid, 0x02, 0x01);
- fc8300_write(handle, devid, 0x03, 0x04);
- fc8300_write(handle, devid, 0x08, 0xe5);
- fc8300_write(handle, devid, 0x1d, 0x10);
- fc8300_write(handle, devid, 0x21, 0x30);
- fc8300_write(handle, devid, 0x24, 0x98);
- fc8300_write(handle, devid, 0x5f, 0x40);
- fc8300_write(handle, devid, 0x3f, 0x01);
- fc8300_write(handle, devid, 0x41, filter_cal_60);
- fc8300_write(handle, devid, 0x3f, 0x00);
- fc8300_write(handle, devid, 0x3c, 0xff);
- fc8300_write(handle, devid, 0x3d, 0xff);
- fc8300_write(handle, devid, 0x54, 0x80);
- fc8300_write(handle, devid, 0x70, 0x5f);
- fc8300_write(handle, devid, 0x04, 0x10);
- fc8300_write(handle, devid, 0xed, 0xcc);
- fc8300_write(handle, devid, 0x82, 0x88);
- fc8300_write(handle, devid, 0x7c, 0x01);
- fc8300_write(handle, devid, 0x88, 0x0f);
- fc8300_write(handle, devid, 0x89, 0x0b);
- fc8300_write(handle, devid, 0x8a, 0x15);
- fc8300_write(handle, devid, 0x8b, 0x0b);
- fc8300_write(handle, devid, 0x78, 0x30);
- fc8300_write(handle, devid, 0x7e, 0x05);
- fc8300_write(handle, devid, 0x7f, 0x0a);
- fc8300_write(handle, devid, 0xb2, 0x00);
- fc8300_write(handle, devid, 0xb3, 0x0c);
- fc8300_write(handle, devid, 0xb4, 0x00);
- fc8300_write(handle, devid, 0xb5, 0x0a);
- fc8300_write(handle, devid, 0xb6, 0x00);
- fc8300_write(handle, devid, 0xb7, 0x0a);
- fc8300_write(handle, devid, 0xb8, 0x00);
- fc8300_write(handle, devid, 0xb9, 0x0a);
- fc8300_write(handle, devid, 0xba, 0x00);
- fc8300_write(handle, devid, 0xbb, 0x0a);
- fc8300_write(handle, devid, 0xbc, 0x00);
- fc8300_write(handle, devid, 0xbd, 0x0a);
- fc8300_write(handle, devid, 0xbe, 0x00);
- fc8300_write(handle, devid, 0xbf, 0x0a);
- fc8300_write(handle, devid, 0xc0, 0x0a);
- fc8300_write(handle, devid, 0xc1, 0x00);
- fc8300_write(handle, devid, 0xc2, 0x13);
- fc8300_write(handle, devid, 0xc3, 0x00);
- fc8300_write(handle, devid, 0xf1, 0x53);
- fc8300_write(handle, devid, 0xd3, 0x00);
- fc8300_write(handle, devid, 0xd4, 0x02);
- fc8300_write(handle, devid, 0xd5, 0x04);
- fc8300_write(handle, devid, 0xd6, 0x14);
- fc8300_write(handle, devid, 0xd7, 0x34);
- fc8300_write(handle, devid, 0xd8, 0x36);
- fc8300_write(handle, devid, 0xd9, 0x38);
- fc8300_write(handle, devid, 0xda, 0x78);
- fc8300_write(handle, devid, 0xdb, 0xb8);
- fc8300_write(handle, devid, 0xdc, 0xf8);
- fc8300_write(handle, devid, 0xdd, 0xf8);
- fc8300_write(handle, devid, 0x91, 0xa8);
- fc8300_write(handle, devid, 0x33, 0x88);
- fc8300_write(handle, devid, 0x34, 0x86);
- fc8300_write(handle, devid, 0x37, 0x65);
- fc8300_write(handle, devid, 0x38, 0x55);
- fc8300_write(handle, devid, 0x39, 0x02);
- fc8300_write(handle, devid, 0x3e, 0xab);
- fc8300_write(handle, devid, 0x13, 0x07);
- fc8300_write(handle, devid, 0x15, 0x47);
- fc8300_write(handle, devid, 0x84, 0x0f);
- fc8300_write(handle, devid, 0x85, 0x0a);
- fc8300_write(handle, devid, 0x86, 0x3f);
- fc8300_write(handle, devid, 0x87, 0x2f);
- fc8300_write(handle, devid, 0x8f, 0xb6);
- fc8300_write(handle, devid, 0x90, 0xb2);
- fc8300_write(handle, devid, 0xe9, 0x79);
- fc8300_write(handle, devid, 0xef, 0xb7);
- for (i = 0; i < 30 ; i++) {
- msWait(1);
- fc8300_read(handle, devid, 0x43, &temp);
- if (((temp >> 4) & 0x01) == 1)
- break;
- }
- fc8300_write(handle, devid, 0x5f, 0x00);
- fc8300_write(handle, devid, 0x78, 0xf0);
- msWait(5);
- fc8300_write(handle, devid, 0x78, 0x30);
- if (FC8300_XTAL_FREQ == 19200)
- fc8300_write(handle, devid, 0x53, 0x16);
- else
- fc8300_write(handle, devid, 0x53, 0x1a);
- fc8300_write(handle, devid, 0xfb, FC8300_BAND_WIDTH);
- fc8300_write(handle, devid, 0xfc, broadcast_type);
- fc8300_write(handle, devid, 0xfd, (u8)(FC8300_XTAL_FREQ / 1000));
- fc8300_write(handle, devid, 0xfe, DRIVER_VERSION);
- if (FC8300_XTAL_FREQ < 20000)
- fc8300_write(handle, devid, 0xF3, 0x55);
- else if (FC8300_XTAL_FREQ > 20000)
- fc8300_write(handle, devid, 0xF3, 0x54);
- /* PLL AGC All Broadcast */
- fc8300_write(handle, devid, 0xF4, 0xFF);
- fc8300_write(handle, devid, 0xB5, 0x0A);
- fc8300_write(handle, devid, 0xB7, 0x0A);
- fc8300_write(handle, devid, 0xB9, 0x0A);
- fc8300_write(handle, devid, 0xBB, 0x0A);
- fc8300_write(handle, devid, 0x50, 0xff);
- fc8300_write(handle, devid, 0x5f, 0x00);
- fc8300_write(handle, devid, 0x6a, 0x00);
- fc8300_write(handle, devid, 0x6b, 0x99);
- fc8300_write(handle, devid, 0x6c, 0x99);
- fc8300_write(handle, devid, 0x6e, 0x03);
- fc8300_write(handle, devid, 0x73, 0x66);
- fc8300_write(handle, devid, 0x74, 0x66);
- fc8300_write(handle, devid, 0x75, 0x30);
- fc8300_write(handle, devid, 0xfa, 0x20);
- fc8300_tuner_set_pll(handle, DIV_MASTER, 545143, 0);
- fc8300_write(handle, devid, 0x1e, 0x10);
- fc8300_write(handle, devid, 0x1f, 0xf2);
- fc8300_write(handle, devid, 0x78, 0x06);
- fc8300_write(handle, devid, 0x04, 0x12);
- fc8300_write(handle, devid, 0x8d, 0x08);
- fc8300_write(handle, devid, 0x8e, 0x13);
- fc8300_write(handle, devid, 0x13, 0x07);
- fc8300_write(handle, devid, 0x22, 0x01);
- fc8300_write(handle, devid, 0x24, 0x11);
- fc8300_write(handle, devid, 0x23, 0x17);
- if (broad_check == 1) { /* BROADCAST Control */
- if ((device_set & 0x01) == 1)
- fc_cal_value[0] = (tf_cal(handle, DIV_MASTER) -
- 7);
- if ((device_set & 0x02) == 2)
- fc_cal_value[1] = (tf_cal(handle, DIV_SLAVE0) -
- 7);
- if ((device_set & 0x04) == 4)
- fc_cal_value[2] = (tf_cal(handle, DIV_SLAVE1) -
- 7);
- if ((device_set & 0x08) == 8)
- fc_cal_value[3] = (tf_cal(handle, DIV_SLAVE2) -
- 7);
- } else if (broad_check == 0) { /* Single Control */
- fc_cal_value[0] = (tf_cal(handle, devid) - 7);
- }
- fc8300_write(handle, devid, 0x1e, 0x00);
- fc8300_write(handle, devid, 0x1f, 0x72);
- fc8300_write(handle, devid, 0x78, 0x30);
- fc8300_write(handle, devid, 0x04, 0x10);
- fc8300_write(handle, devid, 0x22, 0x00);
- fc8300_write(handle, devid, 0xfa, 0xff);
- return BBM_OK;
- }
- s32 fc8300_es2_tuner_init(HANDLE handle, DEVICEID devid,
- enum BROADCAST_TYPE broadcast)
- {
- u8 temp;
- u8 filter_cal_09;
- u8 filter_cal_18;
- u8 filter_cal_60;
- s32 i, cal_temp;
- broadcast_type = broadcast;
- device_set = 0;
- if (devid == DIV_BROADCAST)
- broad_check = 1;
- else
- broad_check = 0;
- #if defined(BBM_4_DIVERSITY)
- fc8300_read(handle, DIV_SLAVE2, 0x01, &temp);
- if (temp == 0xaa) {
- device_set = device_set + 8;
- bc_type[3] = broadcast_type;
- }
- fc8300_read(handle, DIV_SLAVE1, 0x01, &temp);
- if (temp == 0xaa) {
- device_set = device_set + 4;
- bc_type[2] = broadcast_type;
- }
- fc8300_read(handle, DIV_SLAVE0, 0x01, &temp);
- if (temp == 0xaa) {
- device_set = device_set + 2;
- bc_type[1] = broadcast_type;
- }
- #elif defined(BBM_2_DIVERSITY)
- fc8300_read(handle, DIV_SLAVE0, 0x01, &temp);
- if (temp == 0xaa) {
- device_set = device_set + 2;
- bc_type[1] = broadcast_type;
- }
- #endif /* #if defined(BBM_4_DIVERSITY) */
- fc8300_read(handle, DIV_MASTER, 0x01, &temp);
- if (temp == 0xaa) {
- device_set = device_set + 1;
- bc_type[0] = broadcast_type;
- }
- /*
- * ISDBT_1SEG = 0 ==> 0.9
- * ISDBTMM_1SEG = 1 ==> 0.9
- * ISDBTSB_1SEG = 2 ==> 0.9
- * ISDBTSB_3SEG = 3 ==> 1.8
- * ISDBT_13SEG = 4 ==> 6 / 7 / 8
- * ISDBTMM_13SEG = 5 ==> 6 / 7 / 8
- * CATV ==> 6 / 7 / 8
- */
- if (FC8300_XTAL_FREQ < 32000) {
- cal_temp = FC8300_XTAL_FREQ * 72 / 9000;
- filter_cal_09 = (u8) cal_temp;
- } else {
- filter_cal_09 = 0x5f;
- }
- cal_temp = FC8300_XTAL_FREQ * 72 / 18000;
- filter_cal_18 = (u8) cal_temp;
- #if (BBM_BAND_WIDTH == 6)
- cal_temp = FC8300_XTAL_FREQ * 72 / 30000;
- #elif (BBM_BAND_WIDTH == 7)
- cal_temp = FC8300_XTAL_FREQ * 72 / 35000;
- #else /* BBM_BAND_WIDTH == 8 */
- cal_temp = FC8300_XTAL_FREQ * 72 / 40000;
- #endif /* #if (BBM_BAND_WIDTH == 6) */
- filter_cal_60 = (u8) cal_temp;
- if (broadcast_type == ISDBT_1SEG) {
- fc8300_write(handle, devid, 0x00, 0x00);
- fc8300_write(handle, devid, 0x02, 0x01);
- fc8300_write(handle, devid, 0x03, 0x04);
- fc8300_write(handle, devid, 0x08, 0xe5);
- fc8300_write(handle, devid, 0x1d, 0x10);
- fc8300_write(handle, devid, 0x21, 0x30);
- fc8300_write(handle, devid, 0x24, 0x98);
- fc8300_write(handle, devid, 0x5f, 0x40);
- if (FC8300_XTAL_FREQ < 32000) {
- fc8300_write(handle, devid, 0x3f, 0x01);
- fc8300_write(handle, devid, 0x41, filter_cal_09);
- fc8300_write(handle, devid, 0x3f, 0x00);
- } else {
- fc8300_write(handle, devid, 0x3f, 0x02);
- fc8300_write(handle, devid, 0x42, filter_cal_09);
- }
- fc8300_write(handle, devid, 0x3c, 0xff);
- fc8300_write(handle, devid, 0x3d, 0xff);
- fc8300_write(handle, devid, 0x54, 0x80);
- fc8300_write(handle, devid, 0x70, 0x5f);
- fc8300_write(handle, devid, 0x04, 0x10);
- fc8300_write(handle, devid, 0xed, 0xcc);
- fc8300_write(handle, devid, 0x82, 0x88);
- fc8300_write(handle, devid, 0x7c, 0x01);
- fc8300_write(handle, devid, 0x84, 0x1a);
- fc8300_write(handle, devid, 0x85, 0x0f);
- fc8300_write(handle, devid, 0x86, 0x1f);
- fc8300_write(handle, devid, 0x87, 0x0f);
- fc8300_write(handle, devid, 0x88, 0x0f);
- fc8300_write(handle, devid, 0x89, 0x0b);
- fc8300_write(handle, devid, 0x8a, 0x15);
- fc8300_write(handle, devid, 0x8b, 0x0b);
- fc8300_write(handle, devid, 0x78, 0x30);
- fc8300_write(handle, devid, 0x7e, 0x05);
- fc8300_write(handle, devid, 0x7f, 0x0a);
- fc8300_write(handle, devid, 0xb2, 0x00);
- fc8300_write(handle, devid, 0xb3, 0x0c);
- fc8300_write(handle, devid, 0xb4, 0x00);
- fc8300_write(handle, devid, 0xb5, 0x0a);
- fc8300_write(handle, devid, 0xb6, 0x00);
- fc8300_write(handle, devid, 0xb7, 0x0a);
- fc8300_write(handle, devid, 0xb8, 0x00);
- fc8300_write(handle, devid, 0xb9, 0x0a);
- fc8300_write(handle, devid, 0xba, 0x00);
- fc8300_write(handle, devid, 0xbb, 0x0a);
- fc8300_write(handle, devid, 0xbc, 0x00);
- fc8300_write(handle, devid, 0xbd, 0x0a);
- fc8300_write(handle, devid, 0xbe, 0x00);
- fc8300_write(handle, devid, 0xbf, 0x0a);
- fc8300_write(handle, devid, 0xc0, 0x0a);
- fc8300_write(handle, devid, 0xc1, 0x00);
- fc8300_write(handle, devid, 0xc2, 0x13);
- fc8300_write(handle, devid, 0xc3, 0x00);
- fc8300_write(handle, devid, 0xf1, 0x53);
- fc8300_write(handle, devid, 0xd3, 0x00);
- fc8300_write(handle, devid, 0xd4, 0x02);
- fc8300_write(handle, devid, 0xd5, 0x04);
- fc8300_write(handle, devid, 0xd6, 0x14);
- fc8300_write(handle, devid, 0xd7, 0x34);
- fc8300_write(handle, devid, 0xd8, 0x36);
- fc8300_write(handle, devid, 0xd9, 0x38);
- fc8300_write(handle, devid, 0xda, 0x78);
- fc8300_write(handle, devid, 0xdb, 0xb8);
- fc8300_write(handle, devid, 0xdc, 0xf8);
- fc8300_write(handle, devid, 0xdd, 0xf8);
- fc8300_write(handle, devid, 0x91, 0x68);
- fc8300_write(handle, devid, 0x19, 0x21);
- fc8300_write(handle, devid, 0x1f, 0x72);
- fc8300_write(handle, devid, 0x20, 0x22);
- fc8300_write(handle, devid, 0x33, 0x83);
- fc8300_write(handle, devid, 0x34, 0x44);
- fc8300_write(handle, devid, 0x37, 0x65);
- fc8300_write(handle, devid, 0x38, 0x55);
- fc8300_write(handle, devid, 0x39, 0x02);
- fc8300_write(handle, devid, 0x3e, 0xab);
- fc8300_write(handle, devid, 0x3c, 0xaa);
- fc8300_write(handle, devid, 0x3d, 0xaa);
- fc8300_write(handle, devid, 0x13, 0x07);
- fc8300_write(handle, devid, 0x84, 0x14);
- fc8300_write(handle, devid, 0x85, 0x0f);
- fc8300_write(handle, devid, 0x86, 0x3f);
- fc8300_write(handle, devid, 0x87, 0x2f);
- fc8300_write(handle, devid, 0x8f, 0xb6);
- fc8300_write(handle, devid, 0x90, 0xb2);
- fc8300_write(handle, devid, 0xe9, 0x79);
- fc8300_write(handle, devid, 0xef, 0xb7);
- for (i = 0; i < 30 ; i++) {
- msWait(1);
- fc8300_read(handle, devid, 0x43, &temp);
- if (((temp >> 4) & 0x01) == 1)
- break;
- }
- fc8300_write(handle, devid, 0x5f, 0x00);
- fc8300_write(handle, devid, 0x78, 0xf0);
- msWait(5);
- fc8300_write(handle, devid, 0x78, 0x30);
- if (FC8300_XTAL_FREQ == 19200)
- fc8300_write(handle, devid, 0x53, 0x16);
- else
- fc8300_write(handle, devid, 0x53, 0x1a);
- } else if (broadcast_type == ISDBTMM_1SEG) {
- fc8300_write(handle, devid, 0x00, 0x00);
- fc8300_write(handle, devid, 0x02, 0x03);
- fc8300_write(handle, devid, 0x03, 0x00);
- fc8300_write(handle, devid, 0x08, 0xe5);
- fc8300_write(handle, devid, 0x1c, 0x00);
- fc8300_write(handle, devid, 0x1d, 0x00);
- fc8300_write(handle, devid, 0x21, 0x20);
- fc8300_write(handle, devid, 0x24, 0x98);
- fc8300_write(handle, devid, 0x5f, 0x40);
- if (FC8300_XTAL_FREQ < 32000) {
- fc8300_write(handle, devid, 0x3f, 0x01);
- fc8300_write(handle, devid, 0x41, filter_cal_09);
- fc8300_write(handle, devid, 0x3f, 0x00);
- } else {
- fc8300_write(handle, devid, 0x3f, 0x02);
- fc8300_write(handle, devid, 0x42, filter_cal_09);
- }
- fc8300_write(handle, devid, 0x3c, 0xff);
- fc8300_write(handle, devid, 0x3d, 0xff);
- fc8300_write(handle, devid, 0x70, 0x5f);
- fc8300_write(handle, devid, 0x04, 0x10);
- fc8300_write(handle, devid, 0xed, 0xcc);
- fc8300_write(handle, devid, 0x82, 0x88);
- fc8300_write(handle, devid, 0x7c, 0x01);
- fc8300_write(handle, devid, 0x84, 0x1a);
- fc8300_write(handle, devid, 0x85, 0x0f);
- fc8300_write(handle, devid, 0x86, 0x1f);
- fc8300_write(handle, devid, 0x87, 0x0f);
- fc8300_write(handle, devid, 0x88, 0x0f);
- fc8300_write(handle, devid, 0x89, 0x0b);
- fc8300_write(handle, devid, 0x8a, 0x15);
- fc8300_write(handle, devid, 0x8b, 0x0b);
- fc8300_write(handle, devid, 0x78, 0x30);
- fc8300_write(handle, devid, 0x7e, 0x05);
- fc8300_write(handle, devid, 0x7f, 0x0a);
- fc8300_write(handle, devid, 0xb2, 0x00);
- fc8300_write(handle, devid, 0xb3, 0x0c);
- fc8300_write(handle, devid, 0xb4, 0x00);
- fc8300_write(handle, devid, 0xb5, 0x0a);
- fc8300_write(handle, devid, 0xb6, 0x00);
- fc8300_write(handle, devid, 0xb7, 0x0a);
- fc8300_write(handle, devid, 0xb8, 0x00);
- fc8300_write(handle, devid, 0xb9, 0x0a);
- fc8300_write(handle, devid, 0xba, 0x00);
- fc8300_write(handle, devid, 0xbb, 0x0a);
- fc8300_write(handle, devid, 0xbc, 0x00);
- fc8300_write(handle, devid, 0xbd, 0x0a);
- fc8300_write(handle, devid, 0xbe, 0x00);
- fc8300_write(handle, devid, 0xbf, 0x0a);
- fc8300_write(handle, devid, 0xc0, 0x0a);
- fc8300_write(handle, devid, 0xc1, 0x00);
- fc8300_write(handle, devid, 0xc2, 0x13);
- fc8300_write(handle, devid, 0xc3, 0x00);
- fc8300_write(handle, devid, 0xf1, 0x53);
- fc8300_write(handle, devid, 0xd3, 0x00);
- fc8300_write(handle, devid, 0xd4, 0x02);
- fc8300_write(handle, devid, 0xd5, 0x04);
- fc8300_write(handle, devid, 0xd6, 0x14);
- fc8300_write(handle, devid, 0xd7, 0x34);
- fc8300_write(handle, devid, 0xd8, 0x36);
- fc8300_write(handle, devid, 0xd9, 0x38);
- fc8300_write(handle, devid, 0xda, 0x78);
- fc8300_write(handle, devid, 0xdb, 0xb8);
- fc8300_write(handle, devid, 0xdc, 0xf8);
- fc8300_write(handle, devid, 0xdd, 0xf8);
- fc8300_write(handle, devid, 0x33, 0x88);
- fc8300_write(handle, devid, 0x34, 0x86);
- fc8300_write(handle, devid, 0x37, 0x64);
- fc8300_write(handle, devid, 0x38, 0x44);
- fc8300_write(handle, devid, 0x39, 0x02);
- fc8300_write(handle, devid, 0x3e, 0xab);
- fc8300_write(handle, devid, 0x13, 0x07);
- fc8300_write(handle, devid, 0x15, 0x46);
- fc8300_write(handle, devid, 0x84, 0x14);
- fc8300_write(handle, devid, 0x85, 0x0f);
- fc8300_write(handle, devid, 0x86, 0x3f);
- fc8300_write(handle, devid, 0x87, 0x2f);
- fc8300_write(handle, devid, 0x8f, 0xb6);
- fc8300_write(handle, devid, 0x90, 0xb2);
- fc8300_write(handle, devid, 0x91, 0x68);
- fc8300_write(handle, devid, 0x16, 0x42);
- fc8300_write(handle, devid, 0x17, 0x42);
- fc8300_write(handle, devid, 0x1a, 0x42);
- fc8300_write(handle, devid, 0x1f, 0x77);
- fc8300_write(handle, devid, 0x20, 0x42);
- fc8300_write(handle, devid, 0xe9, 0x79);
- fc8300_write(handle, devid, 0xef, 0xb7);
- for (i = 0; i < 30 ; i++) {
- msWait(1);
- fc8300_read(handle, devid, 0x43, &temp);
- if (((temp >> 4) & 0x01) == 1)
- break;
- }
- fc8300_write(handle, devid, 0x5f, 0x00);
- fc8300_write(handle, devid, 0x78, 0xf0);
- msWait(5);
- fc8300_write(handle, devid, 0x78, 0x30);
- } else if (broadcast_type == ISDBTSB_1SEG) {
- fc8300_write(handle, devid, 0x00, 0x00);
- fc8300_write(handle, devid, 0x02, 0x05);
- fc8300_write(handle, devid, 0x03, 0x04);
- fc8300_write(handle, devid, 0x08, 0x21);
- fc8300_write(handle, devid, 0x1d, 0x00);
- fc8300_write(handle, devid, 0x21, 0x10);
- fc8300_write(handle, devid, 0x24, 0x98);
- fc8300_write(handle, devid, 0x5f, 0x40);
- if (FC8300_XTAL_FREQ < 32000) {
- fc8300_write(handle, devid, 0x3f, 0x01);
- fc8300_write(handle, devid, 0x41, filter_cal_09);
- fc8300_write(handle, devid, 0x3f, 0x00);
- } else {
- fc8300_write(handle, devid, 0x3f, 0x02);
- fc8300_write(handle, devid, 0x42, filter_cal_09);
- }
- for (i = 0; i < 5 ; i++) {
- msWait(10);
- fc8300_read(handle, devid, 0x43, &temp);
- if (((temp >> 4) & 0x01) == 1)
- break;
- }
- fc8300_write(handle, devid, 0x3c, 0xff);
- fc8300_write(handle, devid, 0x3d, 0xff);
- fc8300_write(handle, devid, 0x70, 0x5f);
- fc8300_write(handle, devid, 0x04, 0x10);
- fc8300_write(handle, devid, 0xed, 0xcc);
- fc8300_write(handle, devid, 0x82, 0x88);
- fc8300_write(handle, devid, 0x7c, 0x01);
- fc8300_write(handle, devid, 0x84, 0x1a);
- fc8300_write(handle, devid, 0x85, 0x0f);
- fc8300_write(handle, devid, 0x86, 0x1f);
- fc8300_write(handle, devid, 0x87, 0x0f);
- fc8300_write(handle, devid, 0x88, 0x0f);
- fc8300_write(handle, devid, 0x89, 0x0b);
- fc8300_write(handle, devid, 0x8a, 0x15);
- fc8300_write(handle, devid, 0x8b, 0x0b);
- fc8300_write(handle, devid, 0x78, 0x30);
- fc8300_write(handle, devid, 0x7e, 0x05);
- fc8300_write(handle, devid, 0x7f, 0x0a);
- fc8300_write(handle, devid, 0xb2, 0x00);
- fc8300_write(handle, devid, 0xb3, 0x0c);
- fc8300_write(handle, devid, 0xb4, 0x00);
- fc8300_write(handle, devid, 0xb5, 0x0a);
- fc8300_write(handle, devid, 0xb6, 0x00);
- fc8300_write(handle, devid, 0xb7, 0x0a);
- fc8300_write(handle, devid, 0xb8, 0x00);
- fc8300_write(handle, devid, 0xb9, 0x0a);
- fc8300_write(handle, devid, 0xba, 0x00);
- fc8300_write(handle, devid, 0xbb, 0x0a);
- fc8300_write(handle, devid, 0xbc, 0x00);
- fc8300_write(handle, devid, 0xbd, 0x0a);
- fc8300_write(handle, devid, 0xbe, 0x00);
- fc8300_write(handle, devid, 0xbf, 0x0a);
- fc8300_write(handle, devid, 0xc0, 0x0a);
- fc8300_write(handle, devid, 0xc1, 0x00);
- fc8300_write(handle, devid, 0xc2, 0x13);
- fc8300_write(handle, devid, 0xc3, 0x00);
- fc8300_write(handle, devid, 0xf1, 0x53);
- fc8300_write(handle, devid, 0xd3, 0x00);
- fc8300_write(handle, devid, 0xd4, 0x02);
- fc8300_write(handle, devid, 0xd5, 0x04);
- fc8300_write(handle, devid, 0xd6, 0x14);
- fc8300_write(handle, devid, 0xd7, 0x34);
- fc8300_write(handle, devid, 0xd8, 0x36);
- fc8300_write(handle, devid, 0xd9, 0x38);
- fc8300_write(handle, devid, 0xda, 0x78);
- fc8300_write(handle, devid, 0xdb, 0xb8);
- fc8300_write(handle, devid, 0xdc, 0xf8);
- fc8300_write(handle, devid, 0xdd, 0xf8);
- fc8300_write(handle, devid, 0x33, 0x88);
- fc8300_write(handle, devid, 0x34, 0x86);
- fc8300_write(handle, devid, 0x37, 0x64);
- fc8300_write(handle, devid, 0x38, 0x44);
- fc8300_write(handle, devid, 0x39, 0x02);
- fc8300_write(handle, devid, 0x3e, 0xab);
- fc8300_write(handle, devid, 0x13, 0x07);
- fc8300_write(handle, devid, 0x15, 0x46);
- fc8300_write(handle, devid, 0x84, 0x14);
- fc8300_write(handle, devid, 0x85, 0x0f);
- fc8300_write(handle, devid, 0x86, 0x3f);
- fc8300_write(handle, devid, 0x87, 0x2f);
- fc8300_write(handle, devid, 0x8f, 0xb6);
- fc8300_write(handle, devid, 0x90, 0xb2);
- fc8300_write(handle, devid, 0x91, 0x68);
- fc8300_write(handle, devid, 0x16, 0x42);
- fc8300_write(handle, devid, 0x17, 0x42);
- fc8300_write(handle, devid, 0x1a, 0x42);
- fc8300_write(handle, devid, 0x1f, 0x77);
- fc8300_write(handle, devid, 0x20, 0x42);
- fc8300_write(handle, devid, 0xe9, 0x79);
- fc8300_write(handle, devid, 0xef, 0xb7);
- fc8300_write(handle, devid, 0x5f, 0x00);
- fc8300_write(handle, devid, 0x78, 0xf0);
- msWait(5);
- fc8300_write(handle, devid, 0x78, 0x30);
- } else if (broadcast_type == ISDBTSB_3SEG) {
- fc8300_write(handle, devid, 0x00, 0x00);
- fc8300_write(handle, devid, 0x02, 0x05);
- fc8300_write(handle, devid, 0x03, 0x04);
- fc8300_write(handle, devid, 0x08, 0x21);
- fc8300_write(handle, devid, 0x1d, 0x00);
- fc8300_write(handle, devid, 0x21, 0x10);
- fc8300_write(handle, devid, 0x24, 0x98);
- fc8300_write(handle, devid, 0x5f, 0x40);
- fc8300_write(handle, devid, 0x3f, 0x01);
- fc8300_write(handle, devid, 0x41, filter_cal_18);
- fc8300_write(handle, devid, 0x3f, 0x00);
- fc8300_write(handle, devid, 0x3c, 0xff);
- fc8300_write(handle, devid, 0x3d, 0xff);
- fc8300_write(handle, devid, 0x70, 0x5f);
- fc8300_write(handle, devid, 0x04, 0x10);
- fc8300_write(handle, devid, 0xed, 0xcc);
- fc8300_write(handle, devid, 0x82, 0x88);
- fc8300_write(handle, devid, 0x7c, 0x01);
- fc8300_write(handle, devid, 0x84, 0x1a);
- fc8300_write(handle, devid, 0x85, 0x0f);
- fc8300_write(handle, devid, 0x86, 0x1f);
- fc8300_write(handle, devid, 0x87, 0x0f);
- fc8300_write(handle, devid, 0x88, 0x0f);
- fc8300_write(handle, devid, 0x89, 0x0b);
- fc8300_write(handle, devid, 0x8a, 0x15);
- fc8300_write(handle, devid, 0x8b, 0x0b);
- fc8300_write(handle, devid, 0x78, 0x30);
- fc8300_write(handle, devid, 0x7e, 0x05);
- fc8300_write(handle, devid, 0x7f, 0x0a);
- fc8300_write(handle, devid, 0xb2, 0x00);
- fc8300_write(handle, devid, 0xb3, 0x0c);
- fc8300_write(handle, devid, 0xb4, 0x00);
- fc8300_write(handle, devid, 0xb5, 0x0a);
- fc8300_write(handle, devid, 0xb6, 0x00);
- fc8300_write(handle, devid, 0xb7, 0x0a);
- fc8300_write(handle, devid, 0xb8, 0x00);
- fc8300_write(handle, devid, 0xb9, 0x0a);
- fc8300_write(handle, devid, 0xba, 0x00);
- fc8300_write(handle, devid, 0xbb, 0x0a);
- fc8300_write(handle, devid, 0xbc, 0x00);
- fc8300_write(handle, devid, 0xbd, 0x0a);
- fc8300_write(handle, devid, 0xbe, 0x00);
- fc8300_write(handle, devid, 0xbf, 0x0a);
- fc8300_write(handle, devid, 0xc0, 0x0a);
- fc8300_write(handle, devid, 0xc1, 0x00);
- fc8300_write(handle, devid, 0xc2, 0x13);
- fc8300_write(handle, devid, 0xc3, 0x00);
- fc8300_write(handle, devid, 0xf1, 0x53);
- fc8300_write(handle, devid, 0xd3, 0x00);
- fc8300_write(handle, devid, 0xd4, 0x02);
- fc8300_write(handle, devid, 0xd5, 0x04);
- fc8300_write(handle, devid, 0xd6, 0x14);
- fc8300_write(handle, devid, 0xd7, 0x34);
- fc8300_write(handle, devid, 0xd8, 0x36);
- fc8300_write(handle, devid, 0xd9, 0x38);
- fc8300_write(handle, devid, 0xda, 0x78);
- fc8300_write(handle, devid, 0xdb, 0xb8);
- fc8300_write(handle, devid, 0xdc, 0xf8);
- fc8300_write(handle, devid, 0xdd, 0xf8);
- fc8300_write(handle, devid, 0x33, 0x88);
- fc8300_write(handle, devid, 0x34, 0x86);
- fc8300_write(handle, devid, 0x37, 0x64);
- fc8300_write(handle, devid, 0x38, 0x44);
- fc8300_write(handle, devid, 0x39, 0x02);
- fc8300_write(handle, devid, 0x3e, 0xab);
- fc8300_write(handle, devid, 0x13, 0x07);
- fc8300_write(handle, devid, 0x15, 0x46);
- fc8300_write(handle, devid, 0x84, 0x14);
- fc8300_write(handle, devid, 0x85, 0x0f);
- fc8300_write(handle, devid, 0x86, 0x3f);
- fc8300_write(handle, devid, 0x87, 0x2f);
- fc8300_write(handle, devid, 0x8f, 0xb6);
- fc8300_write(handle, devid, 0x90, 0xb2);
- fc8300_write(handle, devid, 0x91, 0x68);
- fc8300_write(handle, devid, 0x16, 0x42);
- fc8300_write(handle, devid, 0x17, 0x42);
- fc8300_write(handle, devid, 0x1a, 0x42);
- fc8300_write(handle, devid, 0x1f, 0x77);
- fc8300_write(handle, devid, 0x20, 0x42);
- fc8300_write(handle, devid, 0xe9, 0x79);
- fc8300_write(handle, devid, 0xef, 0xb7);
- for (i = 0; i < 30 ; i++) {
- msWait(1);
- fc8300_read(handle, devid, 0x43, &temp);
- if (((temp >> 4) & 0x01) == 1)
- break;
- }
- fc8300_write(handle, devid, 0x5f, 0x00);
- fc8300_write(handle, devid, 0x78, 0xf0);
- msWait(5);
- fc8300_write(handle, devid, 0x78, 0x30);
- } else if (broadcast_type == ISDBT_13SEG) {
- fc8300_write(handle, devid, 0x00, 0x00);
- fc8300_write(handle, devid, 0x02, 0x01);
- fc8300_write(handle, devid, 0x03, 0x04);
- fc8300_write(handle, devid, 0x08, 0xe5);
- fc8300_write(handle, devid, 0x1d, 0x10);
- fc8300_write(handle, devid, 0x21, 0x30);
- fc8300_write(handle, devid, 0x24, 0x98);
- fc8300_write(handle, devid, 0x5f, 0x40);
- fc8300_write(handle, devid, 0x3f, 0x01);
- fc8300_write(handle, devid, 0x41, filter_cal_60);
- fc8300_write(handle, devid, 0x3f, 0x00);
- fc8300_write(handle, devid, 0x3c, 0xff);
- fc8300_write(handle, devid, 0x3d, 0xff);
- fc8300_write(handle, devid, 0x54, 0x80);
- fc8300_write(handle, devid, 0x70, 0x5f);
- fc8300_write(handle, devid, 0x04, 0x10);
- fc8300_write(handle, devid, 0xed, 0xcc);
- fc8300_write(handle, devid, 0x82, 0x88);
- fc8300_write(handle, devid, 0x7c, 0x01);
- fc8300_write(handle, devid, 0x88, 0x0f);
- fc8300_write(handle, devid, 0x89, 0x0b);
- fc8300_write(handle, devid, 0x8a, 0x15);
- fc8300_write(handle, devid, 0x8b, 0x0b);
- fc8300_write(handle, devid, 0x78, 0x30);
- fc8300_write(handle, devid, 0x7e, 0x05);
- fc8300_write(handle, devid, 0x7f, 0x0a);
- fc8300_write(handle, devid, 0xb2, 0x00);
- fc8300_write(handle, devid, 0xb3, 0x0c);
- fc8300_write(handle, devid, 0xb4, 0x00);
- fc8300_write(handle, devid, 0xb5, 0x0a);
- fc8300_write(handle, devid, 0xb6, 0x00);
- fc8300_write(handle, devid, 0xb7, 0x0a);
- fc8300_write(handle, devid, 0xb8, 0x00);
- fc8300_write(handle, devid, 0xb9, 0x0a);
- fc8300_write(handle, devid, 0xba, 0x00);
- fc8300_write(handle, devid, 0xbb, 0x0a);
- fc8300_write(handle, devid, 0xbc, 0x00);
- fc8300_write(handle, devid, 0xbd, 0x0a);
- fc8300_write(handle, devid, 0xbe, 0x00);
- fc8300_write(handle, devid, 0xbf, 0x0a);
- fc8300_write(handle, devid, 0xc0, 0x0a);
- fc8300_write(handle, devid, 0xc1, 0x00);
- fc8300_write(handle, devid, 0xc2, 0x13);
- fc8300_write(handle, devid, 0xc3, 0x00);
- fc8300_write(handle, devid, 0xf1, 0x53);
- fc8300_write(handle, devid, 0xd3, 0x00);
- fc8300_write(handle, devid, 0xd4, 0x02);
- fc8300_write(handle, devid, 0xd5, 0x04);
- fc8300_write(handle, devid, 0xd6, 0x14);
- fc8300_write(handle, devid, 0xd7, 0x34);
- fc8300_write(handle, devid, 0xd8, 0x36);
- fc8300_write(handle, devid, 0xd9, 0x38);
- fc8300_write(handle, devid, 0xda, 0x78);
- fc8300_write(handle, devid, 0xdb, 0xb8);
- fc8300_write(handle, devid, 0xdc, 0xf8);
- fc8300_write(handle, devid, 0xdd, 0xf8);
- fc8300_write(handle, devid, 0x91, 0x78);
- fc8300_write(handle, devid, 0x33, 0x88);
- fc8300_write(handle, devid, 0x34, 0x86);
- fc8300_write(handle, devid, 0x37, 0x65);
- fc8300_write(handle, devid, 0x38, 0x55);
- fc8300_write(handle, devid, 0x39, 0x02);
- fc8300_write(handle, devid, 0x3e, 0xab);
- fc8300_write(handle, devid, 0x13, 0x07);
- fc8300_write(handle, devid, 0x15, 0x46);
- fc8300_write(handle, devid, 0x84, 0x14);
- fc8300_write(handle, devid, 0x85, 0x0f);
- fc8300_write(handle, devid, 0x86, 0x3f);
- fc8300_write(handle, devid, 0x87, 0x2f);
- fc8300_write(handle, devid, 0x8f, 0xb6);
- fc8300_write(handle, devid, 0x90, 0xb2);
- fc8300_write(handle, devid, 0xe9, 0x79);
- fc8300_write(handle, devid, 0xef, 0xb7);
- for (i = 0; i < 30 ; i++) {
- msWait(1);
- fc8300_read(handle, devid, 0x43, &temp);
- if (((temp >> 4) & 0x01) == 1)
- break;
- }
- fc8300_write(handle, devid, 0x5f, 0x00);
- fc8300_write(handle, devid, 0x78, 0xf0);
- msWait(5);
- fc8300_write(handle, devid, 0x78, 0x30);
- if (FC8300_XTAL_FREQ == 19200)
- fc8300_write(handle, devid, 0x53, 0x16);
- else
- fc8300_write(handle, devid, 0x53, 0x1a);
- } else if (broadcast_type == ISDBTMM_13SEG) {
- fc8300_write(handle, devid, 0x00, 0x00);
- fc8300_write(handle, devid, 0x02, 0x03);
- fc8300_write(handle, devid, 0x03, 0x00);
- fc8300_write(handle, devid, 0x08, 0xe5);
- fc8300_write(handle, devid, 0x1c, 0x00);
- fc8300_write(handle, devid, 0x1d, 0x00);
- fc8300_write(handle, devid, 0x21, 0x20);
- fc8300_write(handle, devid, 0x24, 0x98);
- fc8300_write(handle, devid, 0x5f, 0x40);
- fc8300_write(handle, devid, 0x3f, 0x01);
- fc8300_write(handle, devid, 0x41, filter_cal_60);
- fc8300_write(handle, devid, 0x3f, 0x00);
- fc8300_write(handle, devid, 0x3c, 0xff);
- fc8300_write(handle, devid, 0x3d, 0xff);
- fc8300_write(handle, devid, 0x70, 0x5f);
- fc8300_write(handle, devid, 0x04, 0x10);
- fc8300_write(handle, devid, 0xed, 0xcc);
- fc8300_write(handle, devid, 0x82, 0x88);
- fc8300_write(handle, devid, 0x7c, 0x01);
- fc8300_write(handle, devid, 0x84, 0x1a);
- fc8300_write(handle, devid, 0x85, 0x0f);
- fc8300_write(handle, devid, 0x86, 0x1f);
- fc8300_write(handle, devid, 0x87, 0x0f);
- fc8300_write(handle, devid, 0x88, 0x0f);
- fc8300_write(handle, devid, 0x89, 0x0b);
- fc8300_write(handle, devid, 0x8a, 0x15);
- fc8300_write(handle, devid, 0x8b, 0x0b);
- fc8300_write(handle, devid, 0x78, 0x30);
- fc8300_write(handle, devid, 0x7e, 0x05);
- fc8300_write(handle, devid, 0x7f, 0x0a);
- fc8300_write(handle, devid, 0xb2, 0x00);
- fc8300_write(handle, devid, 0xb3, 0x0c);
- fc8300_write(handle, devid, 0xb4, 0x00);
- fc8300_write(handle, devid, 0xb5, 0x0a);
- fc8300_write(handle, devid, 0xb6, 0x00);
- fc8300_write(handle, devid, 0xb7, 0x0a);
- fc8300_write(handle, devid, 0xb8, 0x00);
- fc8300_write(handle, devid, 0xb9, 0x0a);
- fc8300_write(handle, devid, 0xba, 0x00);
- fc8300_write(handle, devid, 0xbb, 0x0a);
- fc8300_write(handle, devid, 0xbc, 0x00);
- fc8300_write(handle, devid, 0xbd, 0x0a);
- fc8300_write(handle, devid, 0xbe, 0x00);
- fc8300_write(handle, devid, 0xbf, 0x0a);
- fc8300_write(handle, devid, 0xc0, 0x0a);
- fc8300_write(handle, devid, 0xc1, 0x00);
- fc8300_write(handle, devid, 0xc2, 0x13);
- fc8300_write(handle, devid, 0xc3, 0x00);
- fc8300_write(handle, devid, 0xf1, 0x53);
- fc8300_write(handle, devid, 0xd3, 0x00);
- fc8300_write(handle, devid, 0xd4, 0x02);
- fc8300_write(handle, devid, 0xd5, 0x04);
- fc8300_write(handle, devid, 0xd6, 0x14);
- fc8300_write(handle, devid, 0xd7, 0x34);
- fc8300_write(handle, devid, 0xd8, 0x36);
- fc8300_write(handle, devid, 0xd9, 0x38);
- fc8300_write(handle, devid, 0xda, 0x78);
- fc8300_write(handle, devid, 0xdb, 0xb8);
- fc8300_write(handle, devid, 0xdc, 0xf8);
- fc8300_write(handle, devid, 0xdd, 0xf8);
- fc8300_write(handle, devid, 0x33, 0x88);
- fc8300_write(handle, devid, 0x34, 0x86);
- fc8300_write(handle, devid, 0x37, 0x64);
- fc8300_write(handle, devid, 0x38, 0x44);
- fc8300_write(handle, devid, 0x39, 0x02);
- fc8300_write(handle, devid, 0x3e, 0xab);
- fc8300_write(handle, devid, 0x13, 0x07);
- fc8300_write(handle, devid, 0x15, 0x46);
- fc8300_write(handle, devid, 0x84, 0x14);
- fc8300_write(handle, devid, 0x85, 0x0f);
- fc8300_write(handle, devid, 0x86, 0x3f);
- fc8300_write(handle, devid, 0x87, 0x2f);
- fc8300_write(handle, devid, 0x8f, 0xb6);
- fc8300_write(handle, devid, 0x90, 0xb2);
- fc8300_write(handle, devid, 0x91, 0x68);
- fc8300_write(handle, devid, 0x16, 0x42);
- fc8300_write(handle, devid, 0x17, 0x42);
- fc8300_write(handle, devid, 0x1a, 0x42);
- fc8300_write(handle, devid, 0x1f, 0x77);
- fc8300_write(handle, devid, 0x20, 0x42);
- fc8300_write(handle, devid, 0xe9, 0x79);
- fc8300_write(handle, devid, 0xef, 0xb7);
- for (i = 0; i < 30 ; i++) {
- msWait(1);
- fc8300_read(handle, devid, 0x43, &temp);
- if (((temp >> 4) & 0x01) == 1)
- break;
- }
- fc8300_write(handle, devid, 0x5f, 0x00);
- fc8300_write(handle, devid, 0x78, 0xf0);
- msWait(5);
- fc8300_write(handle, devid, 0x78, 0x30);
- }
- fc8300_write(handle, devid, 0xfb, FC8300_BAND_WIDTH);
- fc8300_write(handle, devid, 0xfc, broadcast_type);
- fc8300_write(handle, devid, 0xfd, (u8)(FC8300_XTAL_FREQ / 1000));
- fc8300_write(handle, devid, 0xfe, DRIVER_VERSION);
- /* PLL AGC All Broadcast */
- if (FC8300_XTAL_FREQ < 20000)
- fc8300_write(handle, devid, 0xF3, 0x55);
- else if (FC8300_XTAL_FREQ > 20000)
- fc8300_write(handle, devid, 0xF3, 0x54);
- fc8300_write(handle, devid, 0xF4, 0xFF);
- fc8300_write(handle, devid, 0xB5, 0x0A);
- fc8300_write(handle, devid, 0xB7, 0x0A);
- fc8300_write(handle, devid, 0xB9, 0x0A);
- fc8300_write(handle, devid, 0xBB, 0x0A);
- fc8300_write(handle, devid, 0x50, 0xff);
- fc8300_write(handle, devid, 0x5f, 0x00);
- fc8300_write(handle, devid, 0x6a, 0x00);
- fc8300_write(handle, devid, 0x6b, 0x99);
- fc8300_write(handle, devid, 0x6c, 0x99);
- fc8300_write(handle, devid, 0x6e, 0x03);
- fc8300_write(handle, devid, 0x73, 0x66);
- fc8300_write(handle, devid, 0x74, 0x66);
- fc8300_write(handle, devid, 0x75, 0x30);
- if ((broadcast_type == ISDBT_13SEG) || (broadcast_type == ISDBT_1SEG)) {
- fc8300_write(handle, devid, 0xfa, 0x20);
- fc8300_es2_set_freq(handle, devid, 545143);
- fc8300_write(handle, devid, 0x1e, 0x10);
- fc8300_write(handle, devid, 0x1f, 0xf2);
- fc8300_write(handle, devid, 0x78, 0x06);
- fc8300_write(handle, devid, 0x04, 0x12);
- fc8300_write(handle, devid, 0x8d, 0x08);
- fc8300_write(handle, devid, 0x8e, 0x13);
- fc8300_write(handle, devid, 0x13, 0x07);
- fc8300_write(handle, devid, 0x22, 0x01);
- fc8300_write(handle, devid, 0x24, 0x11);
- fc8300_write(handle, devid, 0x23, 0x17);
- if (broad_check == 1) { /* BROADCAST Control */
- if ((device_set & 0x01) == 1)
- fc_cal_value[0] = (tf_cal(handle, DIV_MASTER) -
- 7);
- if ((device_set & 0x02) == 2)
- fc_cal_value[1] = (tf_cal(handle, DIV_SLAVE0) -
- 7);
- if ((device_set & 0x04) == 4)
- fc_cal_value[2] = (tf_cal(handle, DIV_SLAVE1) -
- 7);
- if ((device_set & 0x08) == 8)
- fc_cal_value[3] = (tf_cal(handle, DIV_SLAVE2) -
- 7);
- } else if (broad_check == 0) { /* Single Control */
- fc_cal_value[0] = (tf_cal(handle, devid) - 7);
- }
- fc8300_write(handle, devid, 0x1e, 0x00);
- fc8300_write(handle, devid, 0x1f, 0x72);
- fc8300_write(handle, devid, 0x78, 0x30);
- fc8300_write(handle, devid, 0x04, 0x10);
- fc8300_write(handle, devid, 0x22, 0x00);
- fc8300_write(handle, devid, 0xfa, 0x00);
- }
- return BBM_OK;
- }
- static u32 tunning_mode_0[57][5] = {
- {473143, 0x7d, 0x21, 0x33, 0x1b},
- {479143, 0x7d, 0x77, 0x31, 0x1b},
- {485143, 0x7b, 0x44, 0x31, 0x1a},
- {491143, 0x7b, 0x44, 0x31, 0x1a},
- {497143, 0x7b, 0x44, 0x31, 0x19},
- {503143, 0x7b, 0x44, 0x31, 0x19},
- {509143, 0x7b, 0x44, 0x31, 0x19},
- {515143, 0x7b, 0x44, 0x31, 0x18},
- {521143, 0x7c, 0x44, 0x31, 0x18},
- {527143, 0x7c, 0x44, 0x31, 0x18},
- {533143, 0x7c, 0x44, 0x31, 0x17},
- {539143, 0x7c, 0x44, 0x31, 0x17},
- {545143, 0x7c, 0x44, 0x31, 0x17},
- {551143, 0x7c, 0x44, 0x31, 0x17},
- {557143, 0x7c, 0x44, 0x31, 0x16},
- {563143, 0x7c, 0x44, 0x31, 0x16},
- {569143, 0x7c, 0x44, 0x31, 0x16},
- {575143, 0x7e, 0x44, 0x31, 0x16},
- {581143, 0x7d, 0x44, 0x31, 0x15},
- {587143, 0x7d, 0x44, 0x31, 0x15},
- {593143, 0x7e, 0x44, 0x21, 0x15},
- {599143, 0x7e, 0x44, 0x21, 0x15},
- {605143, 0x7d, 0x44, 0x21, 0x14},
- {611143, 0x7d, 0x44, 0x21, 0x14},
- {617143, 0x7d, 0x44, 0x21, 0x14},
- {623143, 0x7e, 0x44, 0x21, 0x14},
- {629143, 0x7d, 0x44, 0x21, 0x14},
- {635143, 0x80, 0x44, 0x21, 0x13},
- {641143, 0x80, 0x44, 0x21, 0x13},
- {647143, 0x7d, 0x32, 0x21, 0x13},
- {653143, 0x7e, 0x32, 0x21, 0x13},
- {659143, 0x7d, 0x32, 0x21, 0x13},
- {665143, 0x7d, 0x32, 0x21, 0x13},
- {671143, 0x7c, 0x32, 0x21, 0x12},
- {677143, 0x7c, 0x32, 0x21, 0x12},
- {683143, 0x7c, 0x32, 0x21, 0x12},
- {689143, 0x7c, 0x32, 0x21, 0x12},
- {695143, 0x7c, 0x32, 0x21, 0x12},
- {701143, 0x7c, 0x32, 0x21, 0x12},
- {707143, 0x7b, 0x32, 0x21, 0x11},
- {713143, 0x7a, 0x32, 0x21, 0x11},
- {719143, 0x7a, 0x32, 0x21, 0x11},
- {725143, 0x7a, 0x32, 0x21, 0x11},
- {731143, 0x7a, 0x32, 0x21, 0x11},
- {737143, 0x7a, 0x32, 0x21, 0x11},
- {741143, 0x7a, 0x32, 0x21, 0x11},
- {747143, 0x7a, 0x32, 0x21, 0x11},
- {753143, 0x7a, 0x32, 0x21, 0x11},
- {759143, 0x7a, 0x32, 0x21, 0x11},
- {765143, 0x7a, 0x32, 0x21, 0x11},
- {772143, 0x7a, 0x32, 0x21, 0x11},
- {778143, 0x7a, 0x32, 0x21, 0x11},
- {785143, 0x7a, 0x32, 0x21, 0x11},
- {791143, 0x7a, 0x32, 0x21, 0x11},
- {797143, 0x7a, 0x32, 0x21, 0x11},
- {803143, 0x7a, 0x32, 0x21, 0x11},
- {809143, 0x7a, 0x32, 0x21, 0x11}
- };
- static u32 tunning_mode_1[8][7] = {
- {210429, 0x7c, 0x53, 0x42, 0x07, 0x22, 0x1b},
- {216000, 0x7b, 0x52, 0x42, 0x07, 0x22, 0x1b},
- {219000, 0x7b, 0x53, 0x42, 0x07, 0x22, 0x1b},
- {219429, 0x7b, 0x53, 0x42, 0x07, 0x22, 0x1b},
- {219857, 0x7a, 0x53, 0x42, 0x07, 0x22, 0x1b},
- {220714, 0x7a, 0x53, 0x31, 0x04, 0x22, 0x1b},
- {221143, 0x7a, 0x53, 0x31, 0x04, 0x22, 0x1b},
- {221571, 0x7a, 0x53, 0x31, 0x04, 0x22, 0x1b}
- };
- static u32 tunning_mode_4[57][7] = { /* ISDBT 13SEG*/
- {473143, 0x79, 0x77, 0x46, 0x07, 0x22, 0x1b},
- {479143, 0x79, 0x77, 0x46, 0x07, 0x22, 0x1b},
- {485143, 0x79, 0x77, 0x46, 0x07, 0x22, 0x1a},
- {491143, 0x7a, 0x77, 0x46, 0x07, 0x22, 0x1a},
- {497143, 0x7a, 0x77, 0x46, 0x07, 0x22, 0x19},
- {503143, 0x77, 0x77, 0x46, 0x04, 0x22, 0x19},
- {509143, 0x77, 0x77, 0x46, 0x04, 0x22, 0x19},
- {515143, 0x77, 0x77, 0x46, 0x04, 0x22, 0x18},
- {521143, 0x77, 0x77, 0x46, 0x04, 0x22, 0x18},
- {527143, 0x77, 0x77, 0x46, 0x04, 0x22, 0x18},
- {533143, 0x77, 0x77, 0x46, 0x04, 0x22, 0x17},
- {539143, 0x78, 0x77, 0x46, 0x04, 0x22, 0x17},
- {545143, 0x77, 0x77, 0x46, 0x04, 0x22, 0x17},
- {551143, 0x79, 0x77, 0x46, 0x04, 0x22, 0x17},
- {557143, 0x77, 0x77, 0x46, 0x04, 0x22, 0x16},
- {563143, 0x77, 0x77, 0x46, 0x04, 0x22, 0x16},
- {569143, 0x78, 0x77, 0x46, 0x04, 0x22, 0x16},
- {575143, 0x79, 0x77, 0x46, 0x04, 0x22, 0x16},
- {581143, 0x79, 0x77, 0x46, 0x04, 0x22, 0x15},
- {587143, 0x79, 0x77, 0x46, 0x04, 0x22, 0x15},
- {593143, 0x79, 0x77, 0x46, 0x04, 0x22, 0x15},
- {599143, 0x79, 0x77, 0x46, 0x04, 0x22, 0x15},
- {605143, 0x7a, 0x77, 0x46, 0x04, 0x22, 0x14},
- {611143, 0x7a, 0x77, 0x46, 0x04, 0x22, 0x14},
- {617143, 0x7b, 0x77, 0x46, 0x04, 0x22, 0x14},
- {623143, 0x7a, 0x77, 0x46, 0x04, 0x22, 0x14},
- {629143, 0x7a, 0x77, 0x46, 0x04, 0x22, 0x14},
- {635143, 0x7a, 0x77, 0x46, 0x04, 0x22, 0x13},
- {641143, 0x7a, 0x77, 0x46, 0x04, 0x22, 0x13},
- {647143, 0x7a, 0x77, 0x46, 0x04, 0x22, 0x13},
- {653143, 0x7a, 0x77, 0x46, 0x04, 0x22, 0x13},
- {659143, 0x7a, 0x77, 0x46, 0x04, 0x22, 0x13},
- {665143, 0x7c, 0x77, 0x46, 0x07, 0x22, 0x13},
- {671143, 0x7c, 0x77, 0x46, 0x07, 0x22, 0x12},
- {677143, 0x7c, 0x77, 0x46, 0x07, 0x22, 0x12},
- {683143, 0x7c, 0x77, 0x46, 0x07, 0x22, 0x12},
- {689143, 0x7c, 0x77, 0x46, 0x07, 0x22, 0x12},
- {695143, 0x7c, 0x77, 0x46, 0x07, 0x22, 0x12},
- {701143, 0x7b, 0x77, 0x46, 0x07, 0x22, 0x12},
- {707143, 0x7a, 0x77, 0x46, 0x07, 0x22, 0x11},
- {713143, 0x7a, 0x77, 0x46, 0x07, 0x22, 0x11},
- {719143, 0x7a, 0x77, 0x46, 0x07, 0x22, 0x11},
- {725143, 0x7a, 0x77, 0x46, 0x07, 0x22, 0x11},
- {731143, 0x7a, 0x77, 0x46, 0x07, 0x22, 0x11},
- {737143, 0x7a, 0x77, 0x46, 0x07, 0x22, 0x11},
- {741143, 0x7a, 0x77, 0x66, 0x07, 0x22, 0x11},
- {747143, 0x7a, 0x77, 0x66, 0x07, 0x22, 0x11},
- {753143, 0x7a, 0x77, 0x66, 0x07, 0x22, 0x11},
- {759143, 0x7a, 0x77, 0x66, 0x07, 0x22, 0x11},
- {765143, 0x7a, 0x77, 0x46, 0x07, 0x22, 0x11},
- {772143, 0x7a, 0x77, 0x46, 0x07, 0x22, 0x11},
- {778143, 0x7a, 0x77, 0x46, 0x07, 0x22, 0x11},
- {785143, 0x7a, 0x77, 0x46, 0x07, 0x22, 0x11},
- {791143, 0x7a, 0x77, 0x46, 0x07, 0x22, 0x10},
- {797143, 0x7a, 0x77, 0x46, 0x07, 0x22, 0x10},
- {803143, 0x7a, 0x77, 0x46, 0x07, 0x22, 0x10},
- {809143, 0x7a, 0x77, 0x46, 0x07, 0x22, 0x10}
- };
- static u32 tunning_mode_5[40][7] = {
- {210429, 0x75, 0x54, 0x46, 0x07, 0x22, 0x1b},
- {216000, 0x73, 0x52, 0x46, 0x07, 0x22, 0x1b}
- };
- static u32 tf_offset[2][13] = {
- {473000, 485000, 497000, 515000, 533000, 557000, 581000, 605000,
- 635000, 671000, 707000, 755000, 811000},
- {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0}
- };
- s32 fc8300_es2_set_freq(HANDLE handle, DEVICEID devid, u32 freq)
- {
- u8 i;
- u8 broad_check_set = 0;
- u8 offset = 0;
- u8 bc_type_freq = 0;
- u8 tf_cal_set = 0;
- u8 over_freq = 0;
- t_handle = handle;
- if (devid == DIV_MASTER) { /* Single Control */
- bc_type_freq = bc_type[0];
- t_devid[0] = devid;
- thread_freq[0] = freq;
- } else if (devid == DIV_SLAVE0) { /* Single Control */
- bc_type_freq = bc_type[1];
- t_devid[1] = devid;
- thread_freq[1] = freq;
- } else if (devid == DIV_SLAVE1) { /* Single Control */
- bc_type_freq = bc_type[2];
- t_devid[2] = devid;
- thread_freq[2] = freq;
- } else if (devid == DIV_SLAVE2) { /* Single Control */
- bc_type_freq = bc_type[3];
- t_devid[3] = devid;
- thread_freq[3] = freq;
- } else if (devid == DIV_BROADCAST) { /* BROADCAST Control */
- broad_check_set = 1;
- bc_type_freq = bc_type[0];
- t_devid[0] = DIV_MASTER;
- t_devid[1] = DIV_SLAVE0;
- t_devid[2] = DIV_SLAVE1;
- t_devid[3] = DIV_SLAVE2;
- thread_freq[0] = freq;
- thread_freq[1] = freq;
- thread_freq[2] = freq;
- thread_freq[3] = freq;
- }
- if (bc_type_freq == ISDBT_CATV_13SEG) { /* mode 6*/
- fc8300_write(handle, devid, 0xfa, 0xff);
- if (213143 >= freq) {
- if (catv_status == 0) {
- catv_status = 1;
- fc8300_es2_vhf(handle, devid);
- msWait(1000);
- bc_type_freq = ISDBTMM_13SEG;
- } else if (catv_status == 1) {
- bc_type_freq = ISDBTMM_13SEG;
- } else if (catv_status == 2) {
- catv_status = 1;
- fc8300_es2_vhf(handle, devid);
- msWait(1000);
- }
- } else if (213143 < freq) {
- if (catv_status == 0) {
- catv_status = 2;
- fc8300_es2_uhf(handle, devid);
- msWait(1000);
- bc_type_freq = ISDBT_13SEG;
- } else if (catv_status == 2) {
- bc_type_freq = ISDBT_13SEG;
- } else if (catv_status == 1) {
- catv_status = 1;
- fc8300_es2_uhf(handle, devid);
- msWait(1000);
- }
- }
- }
- if (bc_type_freq == ISDBT_1SEG) { /* mode 0 */
- for (i = 0; i < 57; i++) {
- if (((tunning_mode_0[i][0] + 3000) > freq) &&
- ((tunning_mode_0[i][0] - 3000) <= freq)) {
- fc8300_write(handle, devid, 0xe9,
- tunning_mode_0[i][1]);
- fc8300_write(handle, devid, 0xef,
- tunning_mode_0[i][2]);
- fc8300_write(handle, devid, 0x19,
- tunning_mode_0[i][3]);
- fc8300_write(handle, devid, 0x1c,
- tunning_mode_0[i][4]);
- over_freq = 1;
- break;
- }
- }
- if (over_freq == 0) {
- fc8300_write(handle, devid, 0xe9,
- tunning_mode_0[56][1]);
- fc8300_write(handle, devid, 0xef,
- tunning_mode_0[56][2]);
- fc8300_write(handle, devid, 0x19,
- tunning_mode_0[56][3]);
- fc8300_write(handle, devid, 0x1c,
- tunning_mode_0[56][4]);
- }
- } else if (bc_type_freq == ISDBTMM_1SEG) { /* mode 1 */
- for (i = 0; i < 8; i++) {
- if (((tunning_mode_1[i][0] + 200) > freq) &&
- ((tunning_mode_1[i][0] - 200) <= freq)) {
- fc8300_write(handle, devid, 0xe9,
- tunning_mode_1[i][1]);
- fc8300_write(handle, devid, 0xef,
- tunning_mode_1[i][2]);
- fc8300_write(handle, devid, 0x19,
- tunning_mode_1[i][3]);
- fc8300_write(handle, devid, 0x1f,
- tunning_mode_1[i][4]);
- fc8300_write(handle, devid, 0x20,
- tunning_mode_1[i][5]);
- over_freq = 1;
- break;
- }
- }
- if (over_freq == 0) {
- fc8300_write(handle, devid, 0xe9,
- tunning_mode_1[7][1]);
- fc8300_write(handle, devid, 0xef,
- tunning_mode_1[7][2]);
- fc8300_write(handle, devid, 0x19,
- tunning_mode_1[7][3]);
- fc8300_write(handle, devid, 0x1f,
- tunning_mode_1[7][4]);
- fc8300_write(handle, devid, 0x20,
- tunning_mode_1[7][5]);
- }
- } else if (bc_type_freq == ISDBT_13SEG) { /* mode 4*/
- for (i = 0; i < 57; i++) {
- if (((tunning_mode_4[i][0] + 3000) > freq) &&
- ((tunning_mode_4[i][0] - 3000) <= freq)) {
- fc8300_write(handle, devid, 0xe9,
- tunning_mode_4[i][1]);
- fc8300_write(handle, devid, 0xef,
- tunning_mode_4[i][2]);
- fc8300_write(handle, devid, 0x19,
- tunning_mode_4[i][3]);
- fc8300_write(handle, devid, 0x1f,
- tunning_mode_4[i][4]);
- fc8300_write(handle, devid, 0x20,
- tunning_mode_4[i][5]);
- fc8300_write(handle, devid, 0x1c,
- tunning_mode_4[i][6]);
- over_freq = 1;
- break;
- }
- }
- if (over_freq == 0) {
- fc8300_write(handle, devid, 0xe9,
- tunning_mode_4[56][1]);
- fc8300_write(handle, devid, 0xef,
- tunning_mode_4[56][2]);
- fc8300_write(handle, devid, 0x19,
- tunning_mode_4[56][3]);
- fc8300_write(handle, devid, 0x1f,
- tunning_mode_4[56][4]);
- fc8300_write(handle, devid, 0x20,
- tunning_mode_4[56][5]);
- fc8300_write(handle, devid, 0x1c,
- tunning_mode_4[56][6]);
- }
- } else if (bc_type_freq == ISDBTMM_13SEG) { /* mode 5*/
- for (i = 0; i < 40; i++) {
- if (((tunning_mode_5[i][0] + 1500) > freq) &&
- ((tunning_mode_5[i][0] - 1500) <= freq)) {
- fc8300_write(handle, devid, 0xe9,
- tunning_mode_5[i][1]);
- fc8300_write(handle, devid, 0xef,
- tunning_mode_5[i][2]);
- fc8300_write(handle, devid, 0x19,
- tunning_mode_5[i][3]);
- fc8300_write(handle, devid, 0x1f,
- tunning_mode_5[i][4]);
- fc8300_write(handle, devid, 0x20,
- tunning_mode_5[i][5]);
- over_freq = 1;
- break;
- }
- }
- if (over_freq == 0) {
- fc8300_write(handle, devid, 0xe9,
- tunning_mode_5[39][1]);
- fc8300_write(handle, devid, 0xef,
- tunning_mode_5[39][2]);
- fc8300_write(handle, devid, 0x19,
- tunning_mode_5[39][3]);
- fc8300_write(handle, devid, 0x1f,
- tunning_mode_5[39][4]);
- fc8300_write(handle, devid, 0x20,
- tunning_mode_5[39][5]);
- }
- }
- if (broad_check_set == 0) { /* Single Control */
- if (fc_cal_value[0] != 0) {
- for (i = 0; i < 12; i++) {
- if ((tf_offset[0][i] < freq) &&
- (tf_offset[0][i+1] >= freq)) {
- tf_cal_set = fc_cal_value[0] +
- tf_offset[1][i];
- if (tf_cal_set < 0x10)
- tf_cal_set = 0x10;
- else if (tf_cal_set > 0x1f)
- tf_cal_set = 0x1f;
- fc8300_write(handle, devid, 0x1c,
- tf_cal_set);
- break;
- }
- }
- }
- fc8300_tuner_set_pll(handle, devid, freq, offset);
- } else if (broad_check_set == 1) { /* BROADCAST Control */
- if (fc_cal_value[0] != 0) {
- for (i = 0; i < 12; i++) {
- if ((tf_offset[0][i] < freq) &&
- (tf_offset[0][i+1] >= freq)) {
- tf_cal_set = fc_cal_value[0] +
- tf_offset[1][i];
- if (tf_cal_set < 0x10)
- tf_cal_set = 0x10;
- else if (tf_cal_set > 0x1f)
- tf_cal_set = 0x1f;
- fc8300_write(handle, DIV_MASTER, 0x1c,
- tf_cal_set);
- break;
- }
- }
- }
- if (fc_cal_value[1] != 0) {
- for (i = 0; i < 12; i++) {
- if ((tf_offset[0][i] < freq) &&
- (tf_offset[0][i+1] >= freq)) {
- tf_cal_set = fc_cal_value[1] +
- tf_offset[1][i];
- if (tf_cal_set < 0x10)
- tf_cal_set = 0x10;
- else if (tf_cal_set > 0x1f)
- tf_cal_set = 0x1f;
- fc8300_write(handle, DIV_SLAVE0, 0x1c,
- tf_cal_set);
- break;
- }
- }
- }
- if (fc_cal_value[2] != 0) {
- for (i = 0; i < 12; i++) {
- if ((tf_offset[0][i] < freq) &&
- (tf_offset[0][i+1] >= freq)) {
- tf_cal_set = fc_cal_value[2] +
- tf_offset[1][i];
- if (tf_cal_set < 0x10)
- tf_cal_set = 0x10;
- else if (tf_cal_set > 0x1f)
- tf_cal_set = 0x1f;
- fc8300_write(handle, DIV_SLAVE1, 0x1c,
- tf_cal_set);
- break;
- }
- }
- }
- if (fc_cal_value[3] != 0) {
- for (i = 0; i < 12; i++) {
- if ((tf_offset[0][i] < freq) &&
- (tf_offset[0][i+1] >= freq)) {
- tf_cal_set = fc_cal_value[3] +
- tf_offset[1][i];
- if (tf_cal_set < 0x10)
- tf_cal_set = 0x10;
- else if (tf_cal_set > 0x1f)
- tf_cal_set = 0x1f;
- fc8300_write(handle, DIV_SLAVE2, 0x1c,
- tf_cal_set);
- break;
- }
- }
- }
- if ((device_set & 0x01) == 1)
- fc8300_tuner_set_pll(handle, DIV_MASTER, freq, offset);
- if ((device_set & 0x02) == 2)
- fc8300_tuner_set_pll(handle, DIV_SLAVE0, freq, offset);
- if ((device_set & 0x04) == 4)
- fc8300_tuner_set_pll(handle, DIV_SLAVE1, freq, offset);
- if ((device_set & 0x08) == 8)
- fc8300_tuner_set_pll(handle, DIV_SLAVE2, freq, offset);
- }
- if (bc_type_freq == ISDBT_CATV_13SEG)
- fc8300_write(handle, devid, 0x91, 0xa8);
- else if (bc_type_freq != ISDBT_13SEG)
- fc8300_write(handle, devid, 0x91, 0x68);
- fc8300_read(handle, devid, 0xfa, &thread_check);
- if (thread_check == 0 && thread_set == 0) {
- #ifdef BBM_ES_CURRENT
- _beginthread(KbdFunc , 0, NULL); /* Thread Go */
- #endif
- thread_set = 1;
- } else if (thread_check == 0 && thread_set == 1) {
- status_1seg[0] = 0;
- status_1seg[1] = 0;
- status_1seg[2] = 0;
- status_1seg[3] = 0;
- status_13seg[0] = 0;
- status_13seg[1] = 0;
- status_13seg[2] = 0;
- status_13seg[3] = 0;
- } else if (thread_check != 0) { /* Thread Stop */
- thread_set = 0;
- }
- if (catv_status == 1 || catv_status == 2)
- bc_type_freq = ISDBT_CATV_13SEG;
- return BBM_OK;
- }
- s32 fc8300_es2_get_rssi(HANDLE handle, DEVICEID devid, s32 *rssi)
- {
- u8 reg_value = 0;
- s32 rssi_value = 0;
- fc8300_read(handle, devid, 0xeb, ®_value);
- rssi_value = reg_value - 256;
- *rssi = rssi_value;
- return BBM_OK;
- }
- s32 fc8300_es2_tuner_deinit(HANDLE handle, DEVICEID devid)
- {
- thread_set = 0;
- msWait(1000);
- return BBM_OK;
- }
|