dib0700_devices.c 135 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965
  1. /* Linux driver for devices based on the DiBcom DiB0700 USB bridge
  2. *
  3. * This program is free software; you can redistribute it and/or modify it
  4. * under the terms of the GNU General Public License as published by the Free
  5. * Software Foundation, version 2.
  6. *
  7. * Copyright (C) 2005-9 DiBcom, SA et al
  8. */
  9. #include "dib0700.h"
  10. #include "dib3000mc.h"
  11. #include "dib7000m.h"
  12. #include "dib7000p.h"
  13. #include "dib8000.h"
  14. #include "dib9000.h"
  15. #include "mt2060.h"
  16. #include "mt2266.h"
  17. #include "tuner-xc2028.h"
  18. #include "xc5000.h"
  19. #include "xc4000.h"
  20. #include "s5h1411.h"
  21. #include "dib0070.h"
  22. #include "dib0090.h"
  23. #include "lgdt3305.h"
  24. #include "mxl5007t.h"
  25. static int force_lna_activation;
  26. module_param(force_lna_activation, int, 0644);
  27. MODULE_PARM_DESC(force_lna_activation, "force the activation of Low-Noise-Amplifyer(s) (LNA), "
  28. "if applicable for the device (default: 0=automatic/off).");
  29. struct dib0700_adapter_state {
  30. int (*set_param_save) (struct dvb_frontend *);
  31. const struct firmware *frontend_firmware;
  32. struct dib7000p_ops dib7000p_ops;
  33. struct dib8000_ops dib8000_ops;
  34. };
  35. /* Hauppauge Nova-T 500 (aka Bristol)
  36. * has a LNA on GPIO0 which is enabled by setting 1 */
  37. static struct mt2060_config bristol_mt2060_config[2] = {
  38. {
  39. .i2c_address = 0x60,
  40. .clock_out = 3,
  41. }, {
  42. .i2c_address = 0x61,
  43. }
  44. };
  45. static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
  46. .band_caps = BAND_VHF | BAND_UHF,
  47. .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
  48. .agc1_max = 42598,
  49. .agc1_min = 17694,
  50. .agc2_max = 45875,
  51. .agc2_min = 0,
  52. .agc1_pt1 = 0,
  53. .agc1_pt2 = 59,
  54. .agc1_slope1 = 0,
  55. .agc1_slope2 = 69,
  56. .agc2_pt1 = 0,
  57. .agc2_pt2 = 59,
  58. .agc2_slope1 = 111,
  59. .agc2_slope2 = 28,
  60. };
  61. static struct dib3000mc_config bristol_dib3000mc_config[2] = {
  62. { .agc = &bristol_dib3000p_mt2060_agc_config,
  63. .max_time = 0x196,
  64. .ln_adc_level = 0x1cc7,
  65. .output_mpeg2_in_188_bytes = 1,
  66. },
  67. { .agc = &bristol_dib3000p_mt2060_agc_config,
  68. .max_time = 0x196,
  69. .ln_adc_level = 0x1cc7,
  70. .output_mpeg2_in_188_bytes = 1,
  71. }
  72. };
  73. static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
  74. {
  75. struct dib0700_state *st = adap->dev->priv;
  76. if (adap->id == 0) {
  77. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
  78. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
  79. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
  80. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
  81. if (force_lna_activation)
  82. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  83. else
  84. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
  85. if (dib3000mc_i2c_enumeration(&adap->dev->i2c_adap, 2, DEFAULT_DIB3000P_I2C_ADDRESS, bristol_dib3000mc_config) != 0) {
  86. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
  87. return -ENODEV;
  88. }
  89. }
  90. st->mt2060_if1[adap->id] = 1220;
  91. return (adap->fe_adap[0].fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap,
  92. (10 + adap->id) << 1, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0;
  93. }
  94. static int eeprom_read(struct i2c_adapter *adap,u8 adrs,u8 *pval)
  95. {
  96. struct i2c_msg msg[2] = {
  97. { .addr = 0x50, .flags = 0, .buf = &adrs, .len = 1 },
  98. { .addr = 0x50, .flags = I2C_M_RD, .buf = pval, .len = 1 },
  99. };
  100. if (i2c_transfer(adap, msg, 2) != 2) return -EREMOTEIO;
  101. return 0;
  102. }
  103. static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
  104. {
  105. struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
  106. struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe_adap[0].fe, 1);
  107. s8 a;
  108. int if1=1220;
  109. if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
  110. adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_500_2)) {
  111. if (!eeprom_read(prim_i2c,0x59 + adap->id,&a)) if1=1220+a;
  112. }
  113. return dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c,
  114. &bristol_mt2060_config[adap->id], if1) == NULL ?
  115. -ENODEV : 0;
  116. }
  117. /* STK7700D: Pinnacle/Terratec/Hauppauge Dual DVB-T Diversity */
  118. /* MT226x */
  119. static struct dibx000_agc_config stk7700d_7000p_mt2266_agc_config[2] = {
  120. {
  121. BAND_UHF,
  122. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=1, P_agc_inv_pwm2=1,
  123. * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
  124. (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
  125. | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
  126. 1130,
  127. 21,
  128. 0,
  129. 118,
  130. 0,
  131. 3530,
  132. 1,
  133. 0,
  134. 65535,
  135. 33770,
  136. 65535,
  137. 23592,
  138. 0,
  139. 62,
  140. 255,
  141. 64,
  142. 64,
  143. 132,
  144. 192,
  145. 80,
  146. 80,
  147. 17,
  148. 27,
  149. 23,
  150. 51,
  151. 1,
  152. }, {
  153. BAND_VHF | BAND_LBAND,
  154. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=1, P_agc_inv_pwm2=1,
  155. * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
  156. (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
  157. | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
  158. 2372,
  159. 21,
  160. 0,
  161. 118,
  162. 0,
  163. 3530,
  164. 1,
  165. 0,
  166. 65535,
  167. 0,
  168. 65535,
  169. 23592,
  170. 0,
  171. 128,
  172. 128,
  173. 128,
  174. 0,
  175. 128,
  176. 253,
  177. 81,
  178. 0,
  179. 17,
  180. 27,
  181. 23,
  182. 51,
  183. 1,
  184. }
  185. };
  186. static struct dibx000_bandwidth_config stk7700d_mt2266_pll_config = {
  187. .internal = 60000,
  188. .sampling = 30000,
  189. .pll_prediv = 1,
  190. .pll_ratio = 8,
  191. .pll_range = 3,
  192. .pll_reset = 1,
  193. .pll_bypass = 0,
  194. .enable_refdiv = 0,
  195. .bypclk_div = 0,
  196. .IO_CLK_en_core = 1,
  197. .ADClkSrc = 1,
  198. .modulo = 2,
  199. .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
  200. .ifreq = 0,
  201. .timf = 20452225,
  202. };
  203. static struct dib7000p_config stk7700d_dib7000p_mt2266_config[] = {
  204. { .output_mpeg2_in_188_bytes = 1,
  205. .hostbus_diversity = 1,
  206. .tuner_is_baseband = 1,
  207. .agc_config_count = 2,
  208. .agc = stk7700d_7000p_mt2266_agc_config,
  209. .bw = &stk7700d_mt2266_pll_config,
  210. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  211. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  212. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  213. },
  214. { .output_mpeg2_in_188_bytes = 1,
  215. .hostbus_diversity = 1,
  216. .tuner_is_baseband = 1,
  217. .agc_config_count = 2,
  218. .agc = stk7700d_7000p_mt2266_agc_config,
  219. .bw = &stk7700d_mt2266_pll_config,
  220. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  221. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  222. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  223. }
  224. };
  225. static struct mt2266_config stk7700d_mt2266_config[2] = {
  226. { .i2c_address = 0x60
  227. },
  228. { .i2c_address = 0x60
  229. }
  230. };
  231. static int stk7700P2_frontend_attach(struct dvb_usb_adapter *adap)
  232. {
  233. struct dib0700_adapter_state *state = adap->priv;
  234. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  235. return -ENODEV;
  236. if (adap->id == 0) {
  237. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  238. msleep(10);
  239. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  240. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  241. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  242. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  243. msleep(10);
  244. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  245. msleep(10);
  246. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
  247. stk7700d_dib7000p_mt2266_config)
  248. != 0) {
  249. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
  250. dvb_detach(&state->dib7000p_ops);
  251. return -ENODEV;
  252. }
  253. }
  254. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
  255. 0x80 + (adap->id << 1),
  256. &stk7700d_dib7000p_mt2266_config[adap->id]);
  257. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  258. }
  259. static int stk7700d_frontend_attach(struct dvb_usb_adapter *adap)
  260. {
  261. struct dib0700_adapter_state *state = adap->priv;
  262. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  263. return -ENODEV;
  264. if (adap->id == 0) {
  265. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  266. msleep(10);
  267. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  268. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  269. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  270. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  271. msleep(10);
  272. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  273. msleep(10);
  274. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  275. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
  276. stk7700d_dib7000p_mt2266_config)
  277. != 0) {
  278. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
  279. dvb_detach(&state->dib7000p_ops);
  280. return -ENODEV;
  281. }
  282. }
  283. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
  284. 0x80 + (adap->id << 1),
  285. &stk7700d_dib7000p_mt2266_config[adap->id]);
  286. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  287. }
  288. static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap)
  289. {
  290. struct i2c_adapter *tun_i2c;
  291. struct dib0700_adapter_state *state = adap->priv;
  292. tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
  293. DIBX000_I2C_INTERFACE_TUNER, 1);
  294. return dvb_attach(mt2266_attach, adap->fe_adap[0].fe, tun_i2c,
  295. &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;
  296. }
  297. /* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */
  298. static struct dibx000_agc_config xc3028_agc_config = {
  299. .band_caps = BAND_VHF | BAND_UHF,
  300. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
  301. * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
  302. * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
  303. .setup = (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
  304. .inv_gain = 712,
  305. .time_stabiliz = 21,
  306. .alpha_level = 0,
  307. .thlock = 118,
  308. .wbd_inv = 0,
  309. .wbd_ref = 2867,
  310. .wbd_sel = 0,
  311. .wbd_alpha = 2,
  312. .agc1_max = 0,
  313. .agc1_min = 0,
  314. .agc2_max = 39718,
  315. .agc2_min = 9930,
  316. .agc1_pt1 = 0,
  317. .agc1_pt2 = 0,
  318. .agc1_pt3 = 0,
  319. .agc1_slope1 = 0,
  320. .agc1_slope2 = 0,
  321. .agc2_pt1 = 0,
  322. .agc2_pt2 = 128,
  323. .agc2_slope1 = 29,
  324. .agc2_slope2 = 29,
  325. .alpha_mant = 17,
  326. .alpha_exp = 27,
  327. .beta_mant = 23,
  328. .beta_exp = 51,
  329. .perform_agc_softsplit = 1,
  330. };
  331. /* PLL Configuration for COFDM BW_MHz = 8.00 with external clock = 30.00 */
  332. static struct dibx000_bandwidth_config xc3028_bw_config = {
  333. .internal = 60000,
  334. .sampling = 30000,
  335. .pll_prediv = 1,
  336. .pll_ratio = 8,
  337. .pll_range = 3,
  338. .pll_reset = 1,
  339. .pll_bypass = 0,
  340. .enable_refdiv = 0,
  341. .bypclk_div = 0,
  342. .IO_CLK_en_core = 1,
  343. .ADClkSrc = 1,
  344. .modulo = 0,
  345. .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
  346. .ifreq = (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
  347. .timf = 20452225,
  348. .xtal_hz = 30000000,
  349. };
  350. static struct dib7000p_config stk7700ph_dib7700_xc3028_config = {
  351. .output_mpeg2_in_188_bytes = 1,
  352. .tuner_is_baseband = 1,
  353. .agc_config_count = 1,
  354. .agc = &xc3028_agc_config,
  355. .bw = &xc3028_bw_config,
  356. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  357. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  358. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  359. };
  360. static int stk7700ph_xc3028_callback(void *ptr, int component,
  361. int command, int arg)
  362. {
  363. struct dvb_usb_adapter *adap = ptr;
  364. struct dib0700_adapter_state *state = adap->priv;
  365. switch (command) {
  366. case XC2028_TUNER_RESET:
  367. /* Send the tuner in then out of reset */
  368. state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
  369. msleep(10);
  370. state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  371. break;
  372. case XC2028_RESET_CLK:
  373. break;
  374. default:
  375. err("%s: unknown command %d, arg %d\n", __func__,
  376. command, arg);
  377. return -EINVAL;
  378. }
  379. return 0;
  380. }
  381. static struct xc2028_ctrl stk7700ph_xc3028_ctrl = {
  382. .fname = XC2028_DEFAULT_FIRMWARE,
  383. .max_len = 64,
  384. .demod = XC3028_FE_DIBCOM52,
  385. };
  386. static struct xc2028_config stk7700ph_xc3028_config = {
  387. .i2c_addr = 0x61,
  388. .ctrl = &stk7700ph_xc3028_ctrl,
  389. };
  390. static int stk7700ph_frontend_attach(struct dvb_usb_adapter *adap)
  391. {
  392. struct usb_device_descriptor *desc = &adap->dev->udev->descriptor;
  393. struct dib0700_adapter_state *state = adap->priv;
  394. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  395. return -ENODEV;
  396. if (desc->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
  397. desc->idProduct == cpu_to_le16(USB_PID_PINNACLE_EXPRESSCARD_320CX))
  398. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  399. else
  400. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  401. msleep(20);
  402. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  403. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  404. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  405. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  406. msleep(10);
  407. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  408. msleep(20);
  409. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  410. msleep(10);
  411. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
  412. &stk7700ph_dib7700_xc3028_config) != 0) {
  413. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
  414. __func__);
  415. dvb_detach(&state->dib7000p_ops);
  416. return -ENODEV;
  417. }
  418. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
  419. &stk7700ph_dib7700_xc3028_config);
  420. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  421. }
  422. static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
  423. {
  424. struct i2c_adapter *tun_i2c;
  425. struct dib0700_adapter_state *state = adap->priv;
  426. tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
  427. DIBX000_I2C_INTERFACE_TUNER, 1);
  428. stk7700ph_xc3028_config.i2c_adap = tun_i2c;
  429. /* FIXME: generalize & move to common area */
  430. adap->fe_adap[0].fe->callback = stk7700ph_xc3028_callback;
  431. return dvb_attach(xc2028_attach, adap->fe_adap[0].fe, &stk7700ph_xc3028_config)
  432. == NULL ? -ENODEV : 0;
  433. }
  434. #define DEFAULT_RC_INTERVAL 50
  435. static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
  436. /*
  437. * This function is used only when firmware is < 1.20 version. Newer
  438. * firmwares use bulk mode, with functions implemented at dib0700_core,
  439. * at dib0700_rc_urb_completion()
  440. */
  441. static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
  442. {
  443. u8 key[4];
  444. enum rc_type protocol;
  445. u32 scancode;
  446. u8 toggle;
  447. int i;
  448. struct dib0700_state *st = d->priv;
  449. if (st->fw_version >= 0x10200) {
  450. /* For 1.20 firmware , We need to keep the RC polling
  451. callback so we can reuse the input device setup in
  452. dvb-usb-remote.c. However, the actual work is being done
  453. in the bulk URB completion handler. */
  454. return 0;
  455. }
  456. i = dib0700_ctrl_rd(d, rc_request, 2, key, 4);
  457. if (i <= 0) {
  458. err("RC Query Failed");
  459. return -1;
  460. }
  461. /* losing half of KEY_0 events from Philipps rc5 remotes.. */
  462. if (key[0] == 0 && key[1] == 0 && key[2] == 0 && key[3] == 0)
  463. return 0;
  464. /* info("%d: %2X %2X %2X %2X",dvb_usb_dib0700_ir_proto,(int)key[3-2],(int)key[3-3],(int)key[3-1],(int)key[3]); */
  465. dib0700_rc_setup(d, NULL); /* reset ir sensor data to prevent false events */
  466. switch (d->props.rc.core.protocol) {
  467. case RC_BIT_NEC:
  468. /* NEC protocol sends repeat code as 0 0 0 FF */
  469. if ((key[3-2] == 0x00) && (key[3-3] == 0x00) &&
  470. (key[3] == 0xff)) {
  471. rc_repeat(d->rc_dev);
  472. return 0;
  473. }
  474. protocol = RC_TYPE_NEC;
  475. scancode = RC_SCANCODE_NEC(key[3-2], key[3-3]);
  476. toggle = 0;
  477. break;
  478. default:
  479. /* RC-5 protocol changes toggle bit on new keypress */
  480. protocol = RC_TYPE_RC5;
  481. scancode = RC_SCANCODE_RC5(key[3-2], key[3-3]);
  482. toggle = key[3-1];
  483. break;
  484. }
  485. rc_keydown(d->rc_dev, protocol, scancode, toggle);
  486. return 0;
  487. }
  488. /* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
  489. static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config = {
  490. BAND_UHF | BAND_VHF,
  491. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
  492. * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
  493. (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
  494. | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
  495. 712,
  496. 41,
  497. 0,
  498. 118,
  499. 0,
  500. 4095,
  501. 0,
  502. 0,
  503. 42598,
  504. 17694,
  505. 45875,
  506. 2621,
  507. 0,
  508. 76,
  509. 139,
  510. 52,
  511. 59,
  512. 107,
  513. 172,
  514. 57,
  515. 70,
  516. 21,
  517. 25,
  518. 28,
  519. 48,
  520. 1,
  521. { 0,
  522. 107,
  523. 51800,
  524. 24700
  525. },
  526. };
  527. static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config = {
  528. .band_caps = BAND_UHF | BAND_VHF,
  529. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
  530. * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
  531. .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
  532. .inv_gain = 712,
  533. .time_stabiliz = 41,
  534. .alpha_level = 0,
  535. .thlock = 118,
  536. .wbd_inv = 0,
  537. .wbd_ref = 4095,
  538. .wbd_sel = 0,
  539. .wbd_alpha = 0,
  540. .agc1_max = 42598,
  541. .agc1_min = 16384,
  542. .agc2_max = 42598,
  543. .agc2_min = 0,
  544. .agc1_pt1 = 0,
  545. .agc1_pt2 = 137,
  546. .agc1_pt3 = 255,
  547. .agc1_slope1 = 0,
  548. .agc1_slope2 = 255,
  549. .agc2_pt1 = 0,
  550. .agc2_pt2 = 0,
  551. .agc2_slope1 = 0,
  552. .agc2_slope2 = 41,
  553. .alpha_mant = 15,
  554. .alpha_exp = 25,
  555. .beta_mant = 28,
  556. .beta_exp = 48,
  557. .perform_agc_softsplit = 0,
  558. };
  559. static struct dibx000_bandwidth_config stk7700p_pll_config = {
  560. .internal = 60000,
  561. .sampling = 30000,
  562. .pll_prediv = 1,
  563. .pll_ratio = 8,
  564. .pll_range = 3,
  565. .pll_reset = 1,
  566. .pll_bypass = 0,
  567. .enable_refdiv = 0,
  568. .bypclk_div = 0,
  569. .IO_CLK_en_core = 1,
  570. .ADClkSrc = 1,
  571. .modulo = 0,
  572. .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
  573. .ifreq = 60258167,
  574. .timf = 20452225,
  575. .xtal_hz = 30000000,
  576. };
  577. static struct dib7000m_config stk7700p_dib7000m_config = {
  578. .dvbt_mode = 1,
  579. .output_mpeg2_in_188_bytes = 1,
  580. .quartz_direct = 1,
  581. .agc_config_count = 1,
  582. .agc = &stk7700p_7000m_mt2060_agc_config,
  583. .bw = &stk7700p_pll_config,
  584. .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
  585. .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
  586. .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
  587. };
  588. static struct dib7000p_config stk7700p_dib7000p_config = {
  589. .output_mpeg2_in_188_bytes = 1,
  590. .agc_config_count = 1,
  591. .agc = &stk7700p_7000p_mt2060_agc_config,
  592. .bw = &stk7700p_pll_config,
  593. .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
  594. .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
  595. .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
  596. };
  597. static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
  598. {
  599. struct dib0700_state *st = adap->dev->priv;
  600. struct dib0700_adapter_state *state = adap->priv;
  601. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  602. return -ENODEV;
  603. /* unless there is no real power management in DVB - we leave the device on GPIO6 */
  604. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  605. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(50);
  606. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
  607. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  608. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
  609. dib0700_ctrl_clock(adap->dev, 72, 1);
  610. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(100);
  611. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  612. st->mt2060_if1[0] = 1220;
  613. if (state->dib7000p_ops.dib7000pc_detection(&adap->dev->i2c_adap)) {
  614. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 18, &stk7700p_dib7000p_config);
  615. st->is_dib7000pc = 1;
  616. } else {
  617. memset(&state->dib7000p_ops, 0, sizeof(state->dib7000p_ops));
  618. adap->fe_adap[0].fe = dvb_attach(dib7000m_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000m_config);
  619. }
  620. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  621. }
  622. static struct mt2060_config stk7700p_mt2060_config = {
  623. 0x60
  624. };
  625. static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
  626. {
  627. struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
  628. struct dib0700_state *st = adap->dev->priv;
  629. struct i2c_adapter *tun_i2c;
  630. struct dib0700_adapter_state *state = adap->priv;
  631. s8 a;
  632. int if1=1220;
  633. if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
  634. adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_STICK)) {
  635. if (!eeprom_read(prim_i2c,0x58,&a)) if1=1220+a;
  636. }
  637. if (st->is_dib7000pc)
  638. tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
  639. else
  640. tun_i2c = dib7000m_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
  641. return dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c, &stk7700p_mt2060_config,
  642. if1) == NULL ? -ENODEV : 0;
  643. }
  644. /* DIB7070 generic */
  645. static struct dibx000_agc_config dib7070_agc_config = {
  646. .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
  647. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
  648. * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
  649. .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
  650. .inv_gain = 600,
  651. .time_stabiliz = 10,
  652. .alpha_level = 0,
  653. .thlock = 118,
  654. .wbd_inv = 0,
  655. .wbd_ref = 3530,
  656. .wbd_sel = 1,
  657. .wbd_alpha = 5,
  658. .agc1_max = 65535,
  659. .agc1_min = 0,
  660. .agc2_max = 65535,
  661. .agc2_min = 0,
  662. .agc1_pt1 = 0,
  663. .agc1_pt2 = 40,
  664. .agc1_pt3 = 183,
  665. .agc1_slope1 = 206,
  666. .agc1_slope2 = 255,
  667. .agc2_pt1 = 72,
  668. .agc2_pt2 = 152,
  669. .agc2_slope1 = 88,
  670. .agc2_slope2 = 90,
  671. .alpha_mant = 17,
  672. .alpha_exp = 27,
  673. .beta_mant = 23,
  674. .beta_exp = 51,
  675. .perform_agc_softsplit = 0,
  676. };
  677. static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
  678. {
  679. struct dvb_usb_adapter *adap = fe->dvb->priv;
  680. struct dib0700_adapter_state *state = adap->priv;
  681. deb_info("reset: %d", onoff);
  682. return state->dib7000p_ops.set_gpio(fe, 8, 0, !onoff);
  683. }
  684. static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
  685. {
  686. struct dvb_usb_adapter *adap = fe->dvb->priv;
  687. struct dib0700_adapter_state *state = adap->priv;
  688. deb_info("sleep: %d", onoff);
  689. return state->dib7000p_ops.set_gpio(fe, 9, 0, onoff);
  690. }
  691. static struct dib0070_config dib7070p_dib0070_config[2] = {
  692. {
  693. .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
  694. .reset = dib7070_tuner_reset,
  695. .sleep = dib7070_tuner_sleep,
  696. .clock_khz = 12000,
  697. .clock_pad_drive = 4,
  698. .charge_pump = 2,
  699. }, {
  700. .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
  701. .reset = dib7070_tuner_reset,
  702. .sleep = dib7070_tuner_sleep,
  703. .clock_khz = 12000,
  704. .charge_pump = 2,
  705. }
  706. };
  707. static struct dib0070_config dib7770p_dib0070_config = {
  708. .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
  709. .reset = dib7070_tuner_reset,
  710. .sleep = dib7070_tuner_sleep,
  711. .clock_khz = 12000,
  712. .clock_pad_drive = 0,
  713. .flip_chip = 1,
  714. .charge_pump = 2,
  715. };
  716. static int dib7070_set_param_override(struct dvb_frontend *fe)
  717. {
  718. struct dtv_frontend_properties *p = &fe->dtv_property_cache;
  719. struct dvb_usb_adapter *adap = fe->dvb->priv;
  720. struct dib0700_adapter_state *state = adap->priv;
  721. u16 offset;
  722. u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
  723. switch (band) {
  724. case BAND_VHF: offset = 950; break;
  725. case BAND_UHF:
  726. default: offset = 550; break;
  727. }
  728. deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
  729. state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
  730. return state->set_param_save(fe);
  731. }
  732. static int dib7770_set_param_override(struct dvb_frontend *fe)
  733. {
  734. struct dtv_frontend_properties *p = &fe->dtv_property_cache;
  735. struct dvb_usb_adapter *adap = fe->dvb->priv;
  736. struct dib0700_adapter_state *state = adap->priv;
  737. u16 offset;
  738. u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
  739. switch (band) {
  740. case BAND_VHF:
  741. state->dib7000p_ops.set_gpio(fe, 0, 0, 1);
  742. offset = 850;
  743. break;
  744. case BAND_UHF:
  745. default:
  746. state->dib7000p_ops.set_gpio(fe, 0, 0, 0);
  747. offset = 250;
  748. break;
  749. }
  750. deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
  751. state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
  752. return state->set_param_save(fe);
  753. }
  754. static int dib7770p_tuner_attach(struct dvb_usb_adapter *adap)
  755. {
  756. struct dib0700_adapter_state *st = adap->priv;
  757. struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
  758. DIBX000_I2C_INTERFACE_TUNER, 1);
  759. if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
  760. &dib7770p_dib0070_config) == NULL)
  761. return -ENODEV;
  762. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  763. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7770_set_param_override;
  764. return 0;
  765. }
  766. static int dib7070p_tuner_attach(struct dvb_usb_adapter *adap)
  767. {
  768. struct dib0700_adapter_state *st = adap->priv;
  769. struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
  770. if (adap->id == 0) {
  771. if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[0]) == NULL)
  772. return -ENODEV;
  773. } else {
  774. if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[1]) == NULL)
  775. return -ENODEV;
  776. }
  777. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  778. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7070_set_param_override;
  779. return 0;
  780. }
  781. static int stk7700p_pid_filter(struct dvb_usb_adapter *adapter, int index,
  782. u16 pid, int onoff)
  783. {
  784. struct dib0700_adapter_state *state = adapter->priv;
  785. struct dib0700_state *st = adapter->dev->priv;
  786. if (st->is_dib7000pc)
  787. return state->dib7000p_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
  788. return dib7000m_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
  789. }
  790. static int stk7700p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
  791. {
  792. struct dib0700_state *st = adapter->dev->priv;
  793. struct dib0700_adapter_state *state = adapter->priv;
  794. if (st->is_dib7000pc)
  795. return state->dib7000p_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
  796. return dib7000m_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
  797. }
  798. static int stk70x0p_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
  799. {
  800. struct dib0700_adapter_state *state = adapter->priv;
  801. return state->dib7000p_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
  802. }
  803. static int stk70x0p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
  804. {
  805. struct dib0700_adapter_state *state = adapter->priv;
  806. return state->dib7000p_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
  807. }
  808. static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
  809. .internal = 60000,
  810. .sampling = 15000,
  811. .pll_prediv = 1,
  812. .pll_ratio = 20,
  813. .pll_range = 3,
  814. .pll_reset = 1,
  815. .pll_bypass = 0,
  816. .enable_refdiv = 0,
  817. .bypclk_div = 0,
  818. .IO_CLK_en_core = 1,
  819. .ADClkSrc = 1,
  820. .modulo = 2,
  821. .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
  822. .ifreq = (0 << 25) | 0,
  823. .timf = 20452225,
  824. .xtal_hz = 12000000,
  825. };
  826. static struct dib7000p_config dib7070p_dib7000p_config = {
  827. .output_mpeg2_in_188_bytes = 1,
  828. .agc_config_count = 1,
  829. .agc = &dib7070_agc_config,
  830. .bw = &dib7070_bw_config_12_mhz,
  831. .tuner_is_baseband = 1,
  832. .spur_protect = 1,
  833. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  834. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  835. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  836. .hostbus_diversity = 1,
  837. };
  838. /* STK7070P */
  839. static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap)
  840. {
  841. struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
  842. struct dib0700_adapter_state *state = adap->priv;
  843. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  844. return -ENODEV;
  845. if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
  846. p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
  847. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  848. else
  849. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  850. msleep(10);
  851. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  852. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  853. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  854. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  855. dib0700_ctrl_clock(adap->dev, 72, 1);
  856. msleep(10);
  857. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  858. msleep(10);
  859. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  860. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
  861. &dib7070p_dib7000p_config) != 0) {
  862. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
  863. __func__);
  864. dvb_detach(&state->dib7000p_ops);
  865. return -ENODEV;
  866. }
  867. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
  868. &dib7070p_dib7000p_config);
  869. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  870. }
  871. /* STK7770P */
  872. static struct dib7000p_config dib7770p_dib7000p_config = {
  873. .output_mpeg2_in_188_bytes = 1,
  874. .agc_config_count = 1,
  875. .agc = &dib7070_agc_config,
  876. .bw = &dib7070_bw_config_12_mhz,
  877. .tuner_is_baseband = 1,
  878. .spur_protect = 1,
  879. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  880. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  881. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  882. .hostbus_diversity = 1,
  883. .enable_current_mirror = 1,
  884. .disable_sample_and_hold = 0,
  885. };
  886. static int stk7770p_frontend_attach(struct dvb_usb_adapter *adap)
  887. {
  888. struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
  889. struct dib0700_adapter_state *state = adap->priv;
  890. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  891. return -ENODEV;
  892. if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
  893. p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
  894. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  895. else
  896. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  897. msleep(10);
  898. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  899. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  900. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  901. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  902. dib0700_ctrl_clock(adap->dev, 72, 1);
  903. msleep(10);
  904. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  905. msleep(10);
  906. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  907. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
  908. &dib7770p_dib7000p_config) != 0) {
  909. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
  910. __func__);
  911. dvb_detach(&state->dib7000p_ops);
  912. return -ENODEV;
  913. }
  914. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
  915. &dib7770p_dib7000p_config);
  916. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  917. }
  918. /* DIB807x generic */
  919. static struct dibx000_agc_config dib807x_agc_config[2] = {
  920. {
  921. BAND_VHF,
  922. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
  923. * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
  924. * P_agc_inv_pwm2=0,P_agc_inh_dc_rv_est=0,
  925. * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
  926. * P_agc_write=0 */
  927. (0 << 15) | (0 << 14) | (7 << 11) | (0 << 10) | (0 << 9) |
  928. (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
  929. (0 << 0), /* setup*/
  930. 600, /* inv_gain*/
  931. 10, /* time_stabiliz*/
  932. 0, /* alpha_level*/
  933. 118, /* thlock*/
  934. 0, /* wbd_inv*/
  935. 3530, /* wbd_ref*/
  936. 1, /* wbd_sel*/
  937. 5, /* wbd_alpha*/
  938. 65535, /* agc1_max*/
  939. 0, /* agc1_min*/
  940. 65535, /* agc2_max*/
  941. 0, /* agc2_min*/
  942. 0, /* agc1_pt1*/
  943. 40, /* agc1_pt2*/
  944. 183, /* agc1_pt3*/
  945. 206, /* agc1_slope1*/
  946. 255, /* agc1_slope2*/
  947. 72, /* agc2_pt1*/
  948. 152, /* agc2_pt2*/
  949. 88, /* agc2_slope1*/
  950. 90, /* agc2_slope2*/
  951. 17, /* alpha_mant*/
  952. 27, /* alpha_exp*/
  953. 23, /* beta_mant*/
  954. 51, /* beta_exp*/
  955. 0, /* perform_agc_softsplit*/
  956. }, {
  957. BAND_UHF,
  958. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
  959. * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
  960. * P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
  961. * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
  962. * P_agc_write=0 */
  963. (0 << 15) | (0 << 14) | (1 << 11) | (0 << 10) | (0 << 9) |
  964. (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
  965. (0 << 0), /* setup */
  966. 600, /* inv_gain*/
  967. 10, /* time_stabiliz*/
  968. 0, /* alpha_level*/
  969. 118, /* thlock*/
  970. 0, /* wbd_inv*/
  971. 3530, /* wbd_ref*/
  972. 1, /* wbd_sel*/
  973. 5, /* wbd_alpha*/
  974. 65535, /* agc1_max*/
  975. 0, /* agc1_min*/
  976. 65535, /* agc2_max*/
  977. 0, /* agc2_min*/
  978. 0, /* agc1_pt1*/
  979. 40, /* agc1_pt2*/
  980. 183, /* agc1_pt3*/
  981. 206, /* agc1_slope1*/
  982. 255, /* agc1_slope2*/
  983. 72, /* agc2_pt1*/
  984. 152, /* agc2_pt2*/
  985. 88, /* agc2_slope1*/
  986. 90, /* agc2_slope2*/
  987. 17, /* alpha_mant*/
  988. 27, /* alpha_exp*/
  989. 23, /* beta_mant*/
  990. 51, /* beta_exp*/
  991. 0, /* perform_agc_softsplit*/
  992. }
  993. };
  994. static struct dibx000_bandwidth_config dib807x_bw_config_12_mhz = {
  995. .internal = 60000,
  996. .sampling = 15000,
  997. .pll_prediv = 1,
  998. .pll_ratio = 20,
  999. .pll_range = 3,
  1000. .pll_reset = 1,
  1001. .pll_bypass = 0,
  1002. .enable_refdiv = 0,
  1003. .bypclk_div = 0,
  1004. .IO_CLK_en_core = 1,
  1005. .ADClkSrc = 1,
  1006. .modulo = 2,
  1007. .sad_cfg = (3 << 14) | (1 << 12) | (599 << 0), /* sad_cfg: refsel, sel, freq_15k*/
  1008. .ifreq = (0 << 25) | 0, /* ifreq = 0.000000 MHz*/
  1009. .timf = 18179755,
  1010. .xtal_hz = 12000000,
  1011. };
  1012. static struct dib8000_config dib807x_dib8000_config[2] = {
  1013. {
  1014. .output_mpeg2_in_188_bytes = 1,
  1015. .agc_config_count = 2,
  1016. .agc = dib807x_agc_config,
  1017. .pll = &dib807x_bw_config_12_mhz,
  1018. .tuner_is_baseband = 1,
  1019. .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
  1020. .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
  1021. .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
  1022. .hostbus_diversity = 1,
  1023. .div_cfg = 1,
  1024. .agc_control = &dib0070_ctrl_agc_filter,
  1025. .output_mode = OUTMODE_MPEG2_FIFO,
  1026. .drives = 0x2d98,
  1027. }, {
  1028. .output_mpeg2_in_188_bytes = 1,
  1029. .agc_config_count = 2,
  1030. .agc = dib807x_agc_config,
  1031. .pll = &dib807x_bw_config_12_mhz,
  1032. .tuner_is_baseband = 1,
  1033. .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
  1034. .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
  1035. .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
  1036. .hostbus_diversity = 1,
  1037. .agc_control = &dib0070_ctrl_agc_filter,
  1038. .output_mode = OUTMODE_MPEG2_FIFO,
  1039. .drives = 0x2d98,
  1040. }
  1041. };
  1042. static int dib80xx_tuner_reset(struct dvb_frontend *fe, int onoff)
  1043. {
  1044. struct dvb_usb_adapter *adap = fe->dvb->priv;
  1045. struct dib0700_adapter_state *state = adap->priv;
  1046. return state->dib8000_ops.set_gpio(fe, 5, 0, !onoff);
  1047. }
  1048. static int dib80xx_tuner_sleep(struct dvb_frontend *fe, int onoff)
  1049. {
  1050. struct dvb_usb_adapter *adap = fe->dvb->priv;
  1051. struct dib0700_adapter_state *state = adap->priv;
  1052. return state->dib8000_ops.set_gpio(fe, 0, 0, onoff);
  1053. }
  1054. static const struct dib0070_wbd_gain_cfg dib8070_wbd_gain_cfg[] = {
  1055. { 240, 7},
  1056. { 0xffff, 6},
  1057. };
  1058. static struct dib0070_config dib807x_dib0070_config[2] = {
  1059. {
  1060. .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
  1061. .reset = dib80xx_tuner_reset,
  1062. .sleep = dib80xx_tuner_sleep,
  1063. .clock_khz = 12000,
  1064. .clock_pad_drive = 4,
  1065. .vga_filter = 1,
  1066. .force_crystal_mode = 1,
  1067. .enable_third_order_filter = 1,
  1068. .charge_pump = 0,
  1069. .wbd_gain = dib8070_wbd_gain_cfg,
  1070. .osc_buffer_state = 0,
  1071. .freq_offset_khz_uhf = -100,
  1072. .freq_offset_khz_vhf = -100,
  1073. }, {
  1074. .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
  1075. .reset = dib80xx_tuner_reset,
  1076. .sleep = dib80xx_tuner_sleep,
  1077. .clock_khz = 12000,
  1078. .clock_pad_drive = 2,
  1079. .vga_filter = 1,
  1080. .force_crystal_mode = 1,
  1081. .enable_third_order_filter = 1,
  1082. .charge_pump = 0,
  1083. .wbd_gain = dib8070_wbd_gain_cfg,
  1084. .osc_buffer_state = 0,
  1085. .freq_offset_khz_uhf = -25,
  1086. .freq_offset_khz_vhf = -25,
  1087. }
  1088. };
  1089. static int dib807x_set_param_override(struct dvb_frontend *fe)
  1090. {
  1091. struct dtv_frontend_properties *p = &fe->dtv_property_cache;
  1092. struct dvb_usb_adapter *adap = fe->dvb->priv;
  1093. struct dib0700_adapter_state *state = adap->priv;
  1094. u16 offset = dib0070_wbd_offset(fe);
  1095. u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
  1096. switch (band) {
  1097. case BAND_VHF:
  1098. offset += 750;
  1099. break;
  1100. case BAND_UHF: /* fall-thru wanted */
  1101. default:
  1102. offset += 250; break;
  1103. }
  1104. deb_info("WBD for DiB8000: %d\n", offset);
  1105. state->dib8000_ops.set_wbd_ref(fe, offset);
  1106. return state->set_param_save(fe);
  1107. }
  1108. static int dib807x_tuner_attach(struct dvb_usb_adapter *adap)
  1109. {
  1110. struct dib0700_adapter_state *st = adap->priv;
  1111. struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe,
  1112. DIBX000_I2C_INTERFACE_TUNER, 1);
  1113. if (adap->id == 0) {
  1114. if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
  1115. &dib807x_dib0070_config[0]) == NULL)
  1116. return -ENODEV;
  1117. } else {
  1118. if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
  1119. &dib807x_dib0070_config[1]) == NULL)
  1120. return -ENODEV;
  1121. }
  1122. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  1123. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib807x_set_param_override;
  1124. return 0;
  1125. }
  1126. static int stk80xx_pid_filter(struct dvb_usb_adapter *adapter, int index,
  1127. u16 pid, int onoff)
  1128. {
  1129. struct dib0700_adapter_state *state = adapter->priv;
  1130. return state->dib8000_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
  1131. }
  1132. static int stk80xx_pid_filter_ctrl(struct dvb_usb_adapter *adapter,
  1133. int onoff)
  1134. {
  1135. struct dib0700_adapter_state *state = adapter->priv;
  1136. return state->dib8000_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
  1137. }
  1138. /* STK807x */
  1139. static int stk807x_frontend_attach(struct dvb_usb_adapter *adap)
  1140. {
  1141. struct dib0700_adapter_state *state = adap->priv;
  1142. if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
  1143. return -ENODEV;
  1144. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  1145. msleep(10);
  1146. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  1147. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  1148. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  1149. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  1150. dib0700_ctrl_clock(adap->dev, 72, 1);
  1151. msleep(10);
  1152. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  1153. msleep(10);
  1154. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  1155. state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
  1156. 0x80, 0);
  1157. adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80,
  1158. &dib807x_dib8000_config[0]);
  1159. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  1160. }
  1161. /* STK807xPVR */
  1162. static int stk807xpvr_frontend_attach0(struct dvb_usb_adapter *adap)
  1163. {
  1164. struct dib0700_adapter_state *state = adap->priv;
  1165. if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
  1166. return -ENODEV;
  1167. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  1168. msleep(30);
  1169. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  1170. msleep(500);
  1171. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  1172. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  1173. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  1174. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  1175. dib0700_ctrl_clock(adap->dev, 72, 1);
  1176. msleep(10);
  1177. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  1178. msleep(10);
  1179. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  1180. /* initialize IC 0 */
  1181. state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x22, 0x80, 0);
  1182. adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80,
  1183. &dib807x_dib8000_config[0]);
  1184. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  1185. }
  1186. static int stk807xpvr_frontend_attach1(struct dvb_usb_adapter *adap)
  1187. {
  1188. struct dib0700_adapter_state *state = adap->priv;
  1189. if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
  1190. return -ENODEV;
  1191. /* initialize IC 1 */
  1192. state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x12, 0x82, 0);
  1193. adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x82,
  1194. &dib807x_dib8000_config[1]);
  1195. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  1196. }
  1197. /* STK8096GP */
  1198. static struct dibx000_agc_config dib8090_agc_config[2] = {
  1199. {
  1200. .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
  1201. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1,
  1202. * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
  1203. * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
  1204. .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
  1205. | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
  1206. .inv_gain = 787,
  1207. .time_stabiliz = 10,
  1208. .alpha_level = 0,
  1209. .thlock = 118,
  1210. .wbd_inv = 0,
  1211. .wbd_ref = 3530,
  1212. .wbd_sel = 1,
  1213. .wbd_alpha = 5,
  1214. .agc1_max = 65535,
  1215. .agc1_min = 0,
  1216. .agc2_max = 65535,
  1217. .agc2_min = 0,
  1218. .agc1_pt1 = 0,
  1219. .agc1_pt2 = 32,
  1220. .agc1_pt3 = 114,
  1221. .agc1_slope1 = 143,
  1222. .agc1_slope2 = 144,
  1223. .agc2_pt1 = 114,
  1224. .agc2_pt2 = 227,
  1225. .agc2_slope1 = 116,
  1226. .agc2_slope2 = 117,
  1227. .alpha_mant = 28,
  1228. .alpha_exp = 26,
  1229. .beta_mant = 31,
  1230. .beta_exp = 51,
  1231. .perform_agc_softsplit = 0,
  1232. },
  1233. {
  1234. .band_caps = BAND_CBAND,
  1235. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1,
  1236. * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
  1237. * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
  1238. .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
  1239. | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
  1240. .inv_gain = 787,
  1241. .time_stabiliz = 10,
  1242. .alpha_level = 0,
  1243. .thlock = 118,
  1244. .wbd_inv = 0,
  1245. .wbd_ref = 3530,
  1246. .wbd_sel = 1,
  1247. .wbd_alpha = 5,
  1248. .agc1_max = 0,
  1249. .agc1_min = 0,
  1250. .agc2_max = 65535,
  1251. .agc2_min = 0,
  1252. .agc1_pt1 = 0,
  1253. .agc1_pt2 = 32,
  1254. .agc1_pt3 = 114,
  1255. .agc1_slope1 = 143,
  1256. .agc1_slope2 = 144,
  1257. .agc2_pt1 = 114,
  1258. .agc2_pt2 = 227,
  1259. .agc2_slope1 = 116,
  1260. .agc2_slope2 = 117,
  1261. .alpha_mant = 28,
  1262. .alpha_exp = 26,
  1263. .beta_mant = 31,
  1264. .beta_exp = 51,
  1265. .perform_agc_softsplit = 0,
  1266. }
  1267. };
  1268. static struct dibx000_bandwidth_config dib8090_pll_config_12mhz = {
  1269. .internal = 54000,
  1270. .sampling = 13500,
  1271. .pll_prediv = 1,
  1272. .pll_ratio = 18,
  1273. .pll_range = 3,
  1274. .pll_reset = 1,
  1275. .pll_bypass = 0,
  1276. .enable_refdiv = 0,
  1277. .bypclk_div = 0,
  1278. .IO_CLK_en_core = 1,
  1279. .ADClkSrc = 1,
  1280. .modulo = 2,
  1281. .sad_cfg = (3 << 14) | (1 << 12) | (599 << 0),
  1282. .ifreq = (0 << 25) | 0,
  1283. .timf = 20199727,
  1284. .xtal_hz = 12000000,
  1285. };
  1286. static int dib8090_get_adc_power(struct dvb_frontend *fe)
  1287. {
  1288. struct dvb_usb_adapter *adap = fe->dvb->priv;
  1289. struct dib0700_adapter_state *state = adap->priv;
  1290. return state->dib8000_ops.get_adc_power(fe, 1);
  1291. }
  1292. static void dib8090_agc_control(struct dvb_frontend *fe, u8 restart)
  1293. {
  1294. deb_info("AGC control callback: %i\n", restart);
  1295. dib0090_dcc_freq(fe, restart);
  1296. if (restart == 0) /* before AGC startup */
  1297. dib0090_set_dc_servo(fe, 1);
  1298. }
  1299. static struct dib8000_config dib809x_dib8000_config[2] = {
  1300. {
  1301. .output_mpeg2_in_188_bytes = 1,
  1302. .agc_config_count = 2,
  1303. .agc = dib8090_agc_config,
  1304. .agc_control = dib8090_agc_control,
  1305. .pll = &dib8090_pll_config_12mhz,
  1306. .tuner_is_baseband = 1,
  1307. .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
  1308. .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
  1309. .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
  1310. .hostbus_diversity = 1,
  1311. .div_cfg = 0x31,
  1312. .output_mode = OUTMODE_MPEG2_FIFO,
  1313. .drives = 0x2d98,
  1314. .diversity_delay = 48,
  1315. .refclksel = 3,
  1316. }, {
  1317. .output_mpeg2_in_188_bytes = 1,
  1318. .agc_config_count = 2,
  1319. .agc = dib8090_agc_config,
  1320. .agc_control = dib8090_agc_control,
  1321. .pll = &dib8090_pll_config_12mhz,
  1322. .tuner_is_baseband = 1,
  1323. .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
  1324. .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
  1325. .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
  1326. .hostbus_diversity = 1,
  1327. .div_cfg = 0x31,
  1328. .output_mode = OUTMODE_DIVERSITY,
  1329. .drives = 0x2d08,
  1330. .diversity_delay = 1,
  1331. .refclksel = 3,
  1332. }
  1333. };
  1334. static struct dib0090_wbd_slope dib8090_wbd_table[] = {
  1335. /* max freq ; cold slope ; cold offset ; warm slope ; warm offset ; wbd gain */
  1336. { 120, 0, 500, 0, 500, 4 }, /* CBAND */
  1337. { 170, 0, 450, 0, 450, 4 }, /* CBAND */
  1338. { 380, 48, 373, 28, 259, 6 }, /* VHF */
  1339. { 860, 34, 700, 36, 616, 6 }, /* high UHF */
  1340. { 0xFFFF, 34, 700, 36, 616, 6 }, /* default */
  1341. };
  1342. static struct dib0090_config dib809x_dib0090_config = {
  1343. .io.pll_bypass = 1,
  1344. .io.pll_range = 1,
  1345. .io.pll_prediv = 1,
  1346. .io.pll_loopdiv = 20,
  1347. .io.adc_clock_ratio = 8,
  1348. .io.pll_int_loop_filt = 0,
  1349. .io.clock_khz = 12000,
  1350. .reset = dib80xx_tuner_reset,
  1351. .sleep = dib80xx_tuner_sleep,
  1352. .clkouttobamse = 1,
  1353. .analog_output = 1,
  1354. .i2c_address = DEFAULT_DIB0090_I2C_ADDRESS,
  1355. .use_pwm_agc = 1,
  1356. .clkoutdrive = 1,
  1357. .get_adc_power = dib8090_get_adc_power,
  1358. .freq_offset_khz_uhf = -63,
  1359. .freq_offset_khz_vhf = -143,
  1360. .wbd = dib8090_wbd_table,
  1361. .fref_clock_ratio = 6,
  1362. };
  1363. static u8 dib8090_compute_pll_parameters(struct dvb_frontend *fe)
  1364. {
  1365. u8 optimal_pll_ratio = 20;
  1366. u32 freq_adc, ratio, rest, max = 0;
  1367. u8 pll_ratio;
  1368. for (pll_ratio = 17; pll_ratio <= 20; pll_ratio++) {
  1369. freq_adc = 12 * pll_ratio * (1 << 8) / 16;
  1370. ratio = ((fe->dtv_property_cache.frequency / 1000) * (1 << 8) / 1000) / freq_adc;
  1371. rest = ((fe->dtv_property_cache.frequency / 1000) * (1 << 8) / 1000) - ratio * freq_adc;
  1372. if (rest > freq_adc / 2)
  1373. rest = freq_adc - rest;
  1374. deb_info("PLL ratio=%i rest=%i\n", pll_ratio, rest);
  1375. if ((rest > max) && (rest > 717)) {
  1376. optimal_pll_ratio = pll_ratio;
  1377. max = rest;
  1378. }
  1379. }
  1380. deb_info("optimal PLL ratio=%i\n", optimal_pll_ratio);
  1381. return optimal_pll_ratio;
  1382. }
  1383. static int dib8096_set_param_override(struct dvb_frontend *fe)
  1384. {
  1385. struct dvb_usb_adapter *adap = fe->dvb->priv;
  1386. struct dib0700_adapter_state *state = adap->priv;
  1387. u8 pll_ratio, band = BAND_OF_FREQUENCY(fe->dtv_property_cache.frequency / 1000);
  1388. u16 target, ltgain, rf_gain_limit;
  1389. u32 timf;
  1390. int ret = 0;
  1391. enum frontend_tune_state tune_state = CT_SHUTDOWN;
  1392. switch (band) {
  1393. default:
  1394. deb_info("Warning : Rf frequency (%iHz) is not in the supported range, using VHF switch ", fe->dtv_property_cache.frequency);
  1395. case BAND_VHF:
  1396. state->dib8000_ops.set_gpio(fe, 3, 0, 1);
  1397. break;
  1398. case BAND_UHF:
  1399. state->dib8000_ops.set_gpio(fe, 3, 0, 0);
  1400. break;
  1401. }
  1402. ret = state->set_param_save(fe);
  1403. if (ret < 0)
  1404. return ret;
  1405. if (fe->dtv_property_cache.bandwidth_hz != 6000000) {
  1406. deb_info("only 6MHz bandwidth is supported\n");
  1407. return -EINVAL;
  1408. }
  1409. /** Update PLL if needed ratio **/
  1410. state->dib8000_ops.update_pll(fe, &dib8090_pll_config_12mhz, fe->dtv_property_cache.bandwidth_hz / 1000, 0);
  1411. /** Get optimize PLL ratio to remove spurious **/
  1412. pll_ratio = dib8090_compute_pll_parameters(fe);
  1413. if (pll_ratio == 17)
  1414. timf = 21387946;
  1415. else if (pll_ratio == 18)
  1416. timf = 20199727;
  1417. else if (pll_ratio == 19)
  1418. timf = 19136583;
  1419. else
  1420. timf = 18179756;
  1421. /** Update ratio **/
  1422. state->dib8000_ops.update_pll(fe, &dib8090_pll_config_12mhz, fe->dtv_property_cache.bandwidth_hz / 1000, pll_ratio);
  1423. state->dib8000_ops.ctrl_timf(fe, DEMOD_TIMF_SET, timf);
  1424. if (band != BAND_CBAND) {
  1425. /* dib0090_get_wbd_target is returning any possible temperature compensated wbd-target */
  1426. target = (dib0090_get_wbd_target(fe) * 8 * 18 / 33 + 1) / 2;
  1427. state->dib8000_ops.set_wbd_ref(fe, target);
  1428. }
  1429. if (band == BAND_CBAND) {
  1430. deb_info("tuning in CBAND - soft-AGC startup\n");
  1431. dib0090_set_tune_state(fe, CT_AGC_START);
  1432. do {
  1433. ret = dib0090_gain_control(fe);
  1434. msleep(ret);
  1435. tune_state = dib0090_get_tune_state(fe);
  1436. if (tune_state == CT_AGC_STEP_0)
  1437. state->dib8000_ops.set_gpio(fe, 6, 0, 1);
  1438. else if (tune_state == CT_AGC_STEP_1) {
  1439. dib0090_get_current_gain(fe, NULL, NULL, &rf_gain_limit, &ltgain);
  1440. if (rf_gain_limit < 2000) /* activate the external attenuator in case of very high input power */
  1441. state->dib8000_ops.set_gpio(fe, 6, 0, 0);
  1442. }
  1443. } while (tune_state < CT_AGC_STOP);
  1444. deb_info("switching to PWM AGC\n");
  1445. dib0090_pwm_gain_reset(fe);
  1446. state->dib8000_ops.pwm_agc_reset(fe);
  1447. state->dib8000_ops.set_tune_state(fe, CT_DEMOD_START);
  1448. } else {
  1449. /* for everything else than CBAND we are using standard AGC */
  1450. deb_info("not tuning in CBAND - standard AGC startup\n");
  1451. dib0090_pwm_gain_reset(fe);
  1452. }
  1453. return 0;
  1454. }
  1455. static int dib809x_tuner_attach(struct dvb_usb_adapter *adap)
  1456. {
  1457. struct dib0700_adapter_state *st = adap->priv;
  1458. struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
  1459. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
  1460. return -ENODEV;
  1461. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  1462. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
  1463. return 0;
  1464. }
  1465. static int stk809x_frontend_attach(struct dvb_usb_adapter *adap)
  1466. {
  1467. struct dib0700_adapter_state *state = adap->priv;
  1468. if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
  1469. return -ENODEV;
  1470. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  1471. msleep(10);
  1472. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  1473. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  1474. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  1475. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  1476. dib0700_ctrl_clock(adap->dev, 72, 1);
  1477. msleep(10);
  1478. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  1479. msleep(10);
  1480. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  1481. state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 0x80, 0);
  1482. adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
  1483. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  1484. }
  1485. static int nim8096md_tuner_attach(struct dvb_usb_adapter *adap)
  1486. {
  1487. struct dib0700_adapter_state *st = adap->priv;
  1488. struct i2c_adapter *tun_i2c;
  1489. struct dvb_frontend *fe_slave = st->dib8000_ops.get_slave_frontend(adap->fe_adap[0].fe, 1);
  1490. if (fe_slave) {
  1491. tun_i2c = st->dib8000_ops.get_i2c_master(fe_slave, DIBX000_I2C_INTERFACE_TUNER, 1);
  1492. if (dvb_attach(dib0090_register, fe_slave, tun_i2c, &dib809x_dib0090_config) == NULL)
  1493. return -ENODEV;
  1494. fe_slave->dvb = adap->fe_adap[0].fe->dvb;
  1495. fe_slave->ops.tuner_ops.set_params = dib8096_set_param_override;
  1496. }
  1497. tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
  1498. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
  1499. return -ENODEV;
  1500. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  1501. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
  1502. return 0;
  1503. }
  1504. static int nim8096md_frontend_attach(struct dvb_usb_adapter *adap)
  1505. {
  1506. struct dvb_frontend *fe_slave;
  1507. struct dib0700_adapter_state *state = adap->priv;
  1508. if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
  1509. return -ENODEV;
  1510. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  1511. msleep(20);
  1512. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  1513. msleep(1000);
  1514. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  1515. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  1516. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  1517. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  1518. dib0700_ctrl_clock(adap->dev, 72, 1);
  1519. msleep(20);
  1520. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  1521. msleep(20);
  1522. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  1523. state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18, 0x80, 0);
  1524. adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
  1525. if (adap->fe_adap[0].fe == NULL)
  1526. return -ENODEV;
  1527. /* Needed to increment refcount */
  1528. if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
  1529. return -ENODEV;
  1530. fe_slave = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]);
  1531. state->dib8000_ops.set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
  1532. return fe_slave == NULL ? -ENODEV : 0;
  1533. }
  1534. /* TFE8096P */
  1535. static struct dibx000_agc_config dib8096p_agc_config[2] = {
  1536. {
  1537. .band_caps = BAND_UHF,
  1538. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
  1539. P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
  1540. P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
  1541. P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
  1542. P_agc_write=0 */
  1543. .setup = (0 << 15) | (0 << 14) | (5 << 11)
  1544. | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
  1545. | (0 << 4) | (5 << 1) | (0 << 0),
  1546. .inv_gain = 684,
  1547. .time_stabiliz = 10,
  1548. .alpha_level = 0,
  1549. .thlock = 118,
  1550. .wbd_inv = 0,
  1551. .wbd_ref = 1200,
  1552. .wbd_sel = 3,
  1553. .wbd_alpha = 5,
  1554. .agc1_max = 65535,
  1555. .agc1_min = 0,
  1556. .agc2_max = 32767,
  1557. .agc2_min = 0,
  1558. .agc1_pt1 = 0,
  1559. .agc1_pt2 = 0,
  1560. .agc1_pt3 = 105,
  1561. .agc1_slope1 = 0,
  1562. .agc1_slope2 = 156,
  1563. .agc2_pt1 = 105,
  1564. .agc2_pt2 = 255,
  1565. .agc2_slope1 = 54,
  1566. .agc2_slope2 = 0,
  1567. .alpha_mant = 28,
  1568. .alpha_exp = 26,
  1569. .beta_mant = 31,
  1570. .beta_exp = 51,
  1571. .perform_agc_softsplit = 0,
  1572. } , {
  1573. .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
  1574. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
  1575. P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
  1576. P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
  1577. P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
  1578. P_agc_write=0 */
  1579. .setup = (0 << 15) | (0 << 14) | (5 << 11)
  1580. | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
  1581. | (0 << 4) | (5 << 1) | (0 << 0),
  1582. .inv_gain = 732,
  1583. .time_stabiliz = 10,
  1584. .alpha_level = 0,
  1585. .thlock = 118,
  1586. .wbd_inv = 0,
  1587. .wbd_ref = 1200,
  1588. .wbd_sel = 3,
  1589. .wbd_alpha = 5,
  1590. .agc1_max = 65535,
  1591. .agc1_min = 0,
  1592. .agc2_max = 32767,
  1593. .agc2_min = 0,
  1594. .agc1_pt1 = 0,
  1595. .agc1_pt2 = 0,
  1596. .agc1_pt3 = 98,
  1597. .agc1_slope1 = 0,
  1598. .agc1_slope2 = 167,
  1599. .agc2_pt1 = 98,
  1600. .agc2_pt2 = 255,
  1601. .agc2_slope1 = 52,
  1602. .agc2_slope2 = 0,
  1603. .alpha_mant = 28,
  1604. .alpha_exp = 26,
  1605. .beta_mant = 31,
  1606. .beta_exp = 51,
  1607. .perform_agc_softsplit = 0,
  1608. }
  1609. };
  1610. static struct dibx000_bandwidth_config dib8096p_clock_config_12_mhz = {
  1611. .internal = 108000,
  1612. .sampling = 13500,
  1613. .pll_prediv = 1,
  1614. .pll_ratio = 9,
  1615. .pll_range = 1,
  1616. .pll_reset = 0,
  1617. .pll_bypass = 0,
  1618. .enable_refdiv = 0,
  1619. .bypclk_div = 0,
  1620. .IO_CLK_en_core = 0,
  1621. .ADClkSrc = 0,
  1622. .modulo = 2,
  1623. .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
  1624. .ifreq = (0 << 25) | 0,
  1625. .timf = 20199729,
  1626. .xtal_hz = 12000000,
  1627. };
  1628. static struct dib8000_config tfe8096p_dib8000_config = {
  1629. .output_mpeg2_in_188_bytes = 1,
  1630. .hostbus_diversity = 1,
  1631. .update_lna = NULL,
  1632. .agc_config_count = 2,
  1633. .agc = dib8096p_agc_config,
  1634. .pll = &dib8096p_clock_config_12_mhz,
  1635. .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
  1636. .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
  1637. .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
  1638. .agc_control = NULL,
  1639. .diversity_delay = 48,
  1640. .output_mode = OUTMODE_MPEG2_FIFO,
  1641. .enMpegOutput = 1,
  1642. };
  1643. static struct dib0090_wbd_slope dib8096p_wbd_table[] = {
  1644. { 380, 81, 850, 64, 540, 4},
  1645. { 860, 51, 866, 21, 375, 4},
  1646. {1700, 0, 250, 0, 100, 6},
  1647. {2600, 0, 250, 0, 100, 6},
  1648. { 0xFFFF, 0, 0, 0, 0, 0},
  1649. };
  1650. static struct dib0090_config tfe8096p_dib0090_config = {
  1651. .io.clock_khz = 12000,
  1652. .io.pll_bypass = 0,
  1653. .io.pll_range = 0,
  1654. .io.pll_prediv = 3,
  1655. .io.pll_loopdiv = 6,
  1656. .io.adc_clock_ratio = 0,
  1657. .io.pll_int_loop_filt = 0,
  1658. .freq_offset_khz_uhf = -143,
  1659. .freq_offset_khz_vhf = -143,
  1660. .get_adc_power = dib8090_get_adc_power,
  1661. .clkouttobamse = 1,
  1662. .analog_output = 0,
  1663. .wbd_vhf_offset = 0,
  1664. .wbd_cband_offset = 0,
  1665. .use_pwm_agc = 1,
  1666. .clkoutdrive = 0,
  1667. .fref_clock_ratio = 1,
  1668. .ls_cfg_pad_drv = 0,
  1669. .data_tx_drv = 0,
  1670. .low_if = NULL,
  1671. .in_soc = 1,
  1672. .force_cband_input = 0,
  1673. };
  1674. struct dibx090p_adc {
  1675. u32 freq; /* RF freq MHz */
  1676. u32 timf; /* New Timf */
  1677. u32 pll_loopdiv; /* New prediv */
  1678. u32 pll_prediv; /* New loopdiv */
  1679. };
  1680. struct dibx090p_best_adc {
  1681. u32 timf;
  1682. u32 pll_loopdiv;
  1683. u32 pll_prediv;
  1684. };
  1685. static int dib8096p_get_best_sampling(struct dvb_frontend *fe, struct dibx090p_best_adc *adc)
  1686. {
  1687. u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
  1688. u16 xtal = 12000;
  1689. u16 fcp_min = 1900; /* PLL, Minimum Frequency of phase comparator (KHz) */
  1690. u16 fcp_max = 20000; /* PLL, Maximum Frequency of phase comparator (KHz) */
  1691. u32 fmem_max = 140000; /* 140MHz max SDRAM freq */
  1692. u32 fdem_min = 66000;
  1693. u32 fcp = 0, fs = 0, fdem = 0, fmem = 0;
  1694. u32 harmonic_id = 0;
  1695. adc->timf = 0;
  1696. adc->pll_loopdiv = loopdiv;
  1697. adc->pll_prediv = prediv;
  1698. deb_info("bandwidth = %d", fe->dtv_property_cache.bandwidth_hz);
  1699. /* Find Min and Max prediv */
  1700. while ((xtal / max_prediv) >= fcp_min)
  1701. max_prediv++;
  1702. max_prediv--;
  1703. min_prediv = max_prediv;
  1704. while ((xtal / min_prediv) <= fcp_max) {
  1705. min_prediv--;
  1706. if (min_prediv == 1)
  1707. break;
  1708. }
  1709. deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
  1710. min_prediv = 1;
  1711. for (prediv = min_prediv; prediv < max_prediv; prediv++) {
  1712. fcp = xtal / prediv;
  1713. if (fcp > fcp_min && fcp < fcp_max) {
  1714. for (loopdiv = 1; loopdiv < 64; loopdiv++) {
  1715. fmem = ((xtal/prediv) * loopdiv);
  1716. fdem = fmem / 2;
  1717. fs = fdem / 4;
  1718. /* test min/max system restrictions */
  1719. if ((fdem >= fdem_min) && (fmem <= fmem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz / 1000)) {
  1720. spur = 0;
  1721. /* test fs harmonics positions */
  1722. for (harmonic_id = (fe->dtv_property_cache.frequency / (1000 * fs)); harmonic_id <= ((fe->dtv_property_cache.frequency / (1000 * fs)) + 1); harmonic_id++) {
  1723. if (((fs * harmonic_id) >= (fe->dtv_property_cache.frequency / 1000 - (fe->dtv_property_cache.bandwidth_hz / 2000))) && ((fs * harmonic_id) <= (fe->dtv_property_cache.frequency / 1000 + (fe->dtv_property_cache.bandwidth_hz / 2000)))) {
  1724. spur = 1;
  1725. break;
  1726. }
  1727. }
  1728. if (!spur) {
  1729. adc->pll_loopdiv = loopdiv;
  1730. adc->pll_prediv = prediv;
  1731. adc->timf = (4260880253U / fdem) * (1 << 8);
  1732. adc->timf += ((4260880253U % fdem) << 8) / fdem;
  1733. deb_info("RF %6d; BW %6d; Xtal %6d; Fmem %6d; Fdem %6d; Fs %6d; Prediv %2d; Loopdiv %2d; Timf %8d;", fe->dtv_property_cache.frequency, fe->dtv_property_cache.bandwidth_hz, xtal, fmem, fdem, fs, prediv, loopdiv, adc->timf);
  1734. break;
  1735. }
  1736. }
  1737. }
  1738. }
  1739. if (!spur)
  1740. break;
  1741. }
  1742. if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
  1743. return -EINVAL;
  1744. return 0;
  1745. }
  1746. static int dib8096p_agc_startup(struct dvb_frontend *fe)
  1747. {
  1748. struct dvb_usb_adapter *adap = fe->dvb->priv;
  1749. struct dib0700_adapter_state *state = adap->priv;
  1750. struct dibx000_bandwidth_config pll;
  1751. struct dibx090p_best_adc adc;
  1752. u16 target;
  1753. int ret;
  1754. ret = state->set_param_save(fe);
  1755. if (ret < 0)
  1756. return ret;
  1757. memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
  1758. dib0090_pwm_gain_reset(fe);
  1759. /* dib0090_get_wbd_target is returning any possible
  1760. temperature compensated wbd-target */
  1761. target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
  1762. state->dib8000_ops.set_wbd_ref(fe, target);
  1763. if (dib8096p_get_best_sampling(fe, &adc) == 0) {
  1764. pll.pll_ratio = adc.pll_loopdiv;
  1765. pll.pll_prediv = adc.pll_prediv;
  1766. dib0700_set_i2c_speed(adap->dev, 200);
  1767. state->dib8000_ops.update_pll(fe, &pll, fe->dtv_property_cache.bandwidth_hz / 1000, 0);
  1768. state->dib8000_ops.ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
  1769. dib0700_set_i2c_speed(adap->dev, 1000);
  1770. }
  1771. return 0;
  1772. }
  1773. static int tfe8096p_frontend_attach(struct dvb_usb_adapter *adap)
  1774. {
  1775. struct dib0700_state *st = adap->dev->priv;
  1776. u32 fw_version;
  1777. struct dib0700_adapter_state *state = adap->priv;
  1778. if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
  1779. return -ENODEV;
  1780. dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
  1781. if (fw_version >= 0x10200)
  1782. st->fw_use_new_i2c_api = 1;
  1783. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  1784. msleep(20);
  1785. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  1786. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  1787. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  1788. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  1789. dib0700_ctrl_clock(adap->dev, 72, 1);
  1790. msleep(20);
  1791. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  1792. msleep(20);
  1793. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  1794. state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80, 1);
  1795. adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap,
  1796. 0x80, &tfe8096p_dib8000_config);
  1797. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  1798. }
  1799. static int tfe8096p_tuner_attach(struct dvb_usb_adapter *adap)
  1800. {
  1801. struct dib0700_adapter_state *st = adap->priv;
  1802. struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_tuner(adap->fe_adap[0].fe);
  1803. tfe8096p_dib0090_config.reset = st->dib8000_ops.tuner_sleep;
  1804. tfe8096p_dib0090_config.sleep = st->dib8000_ops.tuner_sleep;
  1805. tfe8096p_dib0090_config.wbd = dib8096p_wbd_table;
  1806. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
  1807. &tfe8096p_dib0090_config) == NULL)
  1808. return -ENODEV;
  1809. st->dib8000_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  1810. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  1811. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096p_agc_startup;
  1812. return 0;
  1813. }
  1814. /* STK9090M */
  1815. static int dib90x0_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
  1816. {
  1817. return dib9000_fw_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
  1818. }
  1819. static int dib90x0_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
  1820. {
  1821. return dib9000_fw_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
  1822. }
  1823. static int dib90x0_tuner_reset(struct dvb_frontend *fe, int onoff)
  1824. {
  1825. return dib9000_set_gpio(fe, 5, 0, !onoff);
  1826. }
  1827. static int dib90x0_tuner_sleep(struct dvb_frontend *fe, int onoff)
  1828. {
  1829. return dib9000_set_gpio(fe, 0, 0, onoff);
  1830. }
  1831. static int dib01x0_pmu_update(struct i2c_adapter *i2c, u16 *data, u8 len)
  1832. {
  1833. u8 wb[4] = { 0xc >> 8, 0xc & 0xff, 0, 0 };
  1834. u8 rb[2];
  1835. struct i2c_msg msg[2] = {
  1836. {.addr = 0x1e >> 1, .flags = 0, .buf = wb, .len = 2},
  1837. {.addr = 0x1e >> 1, .flags = I2C_M_RD, .buf = rb, .len = 2},
  1838. };
  1839. u8 index_data;
  1840. dibx000_i2c_set_speed(i2c, 250);
  1841. if (i2c_transfer(i2c, msg, 2) != 2)
  1842. return -EIO;
  1843. switch (rb[0] << 8 | rb[1]) {
  1844. case 0:
  1845. deb_info("Found DiB0170 rev1: This version of DiB0170 is not supported any longer.\n");
  1846. return -EIO;
  1847. case 1:
  1848. deb_info("Found DiB0170 rev2");
  1849. break;
  1850. case 2:
  1851. deb_info("Found DiB0190 rev2");
  1852. break;
  1853. default:
  1854. deb_info("DiB01x0 not found");
  1855. return -EIO;
  1856. }
  1857. for (index_data = 0; index_data < len; index_data += 2) {
  1858. wb[2] = (data[index_data + 1] >> 8) & 0xff;
  1859. wb[3] = (data[index_data + 1]) & 0xff;
  1860. if (data[index_data] == 0) {
  1861. wb[0] = (data[index_data] >> 8) & 0xff;
  1862. wb[1] = (data[index_data]) & 0xff;
  1863. msg[0].len = 2;
  1864. if (i2c_transfer(i2c, msg, 2) != 2)
  1865. return -EIO;
  1866. wb[2] |= rb[0];
  1867. wb[3] |= rb[1] & ~(3 << 4);
  1868. }
  1869. wb[0] = (data[index_data] >> 8)&0xff;
  1870. wb[1] = (data[index_data])&0xff;
  1871. msg[0].len = 4;
  1872. if (i2c_transfer(i2c, &msg[0], 1) != 1)
  1873. return -EIO;
  1874. }
  1875. return 0;
  1876. }
  1877. static struct dib9000_config stk9090m_config = {
  1878. .output_mpeg2_in_188_bytes = 1,
  1879. .output_mode = OUTMODE_MPEG2_FIFO,
  1880. .vcxo_timer = 279620,
  1881. .timing_frequency = 20452225,
  1882. .demod_clock_khz = 60000,
  1883. .xtal_clock_khz = 30000,
  1884. .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
  1885. .subband = {
  1886. 2,
  1887. {
  1888. { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0008 } }, /* GPIO 3 to 1 for VHF */
  1889. { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0000 } }, /* GPIO 3 to 0 for UHF */
  1890. { 0 },
  1891. },
  1892. },
  1893. .gpio_function = {
  1894. { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
  1895. { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
  1896. },
  1897. };
  1898. static struct dib9000_config nim9090md_config[2] = {
  1899. {
  1900. .output_mpeg2_in_188_bytes = 1,
  1901. .output_mode = OUTMODE_MPEG2_FIFO,
  1902. .vcxo_timer = 279620,
  1903. .timing_frequency = 20452225,
  1904. .demod_clock_khz = 60000,
  1905. .xtal_clock_khz = 30000,
  1906. .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
  1907. }, {
  1908. .output_mpeg2_in_188_bytes = 1,
  1909. .output_mode = OUTMODE_DIVERSITY,
  1910. .vcxo_timer = 279620,
  1911. .timing_frequency = 20452225,
  1912. .demod_clock_khz = 60000,
  1913. .xtal_clock_khz = 30000,
  1914. .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
  1915. .subband = {
  1916. 2,
  1917. {
  1918. { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0006 } }, /* GPIO 1 and 2 to 1 for VHF */
  1919. { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0000 } }, /* GPIO 1 and 2 to 0 for UHF */
  1920. { 0 },
  1921. },
  1922. },
  1923. .gpio_function = {
  1924. { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
  1925. { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
  1926. },
  1927. }
  1928. };
  1929. static struct dib0090_config dib9090_dib0090_config = {
  1930. .io.pll_bypass = 0,
  1931. .io.pll_range = 1,
  1932. .io.pll_prediv = 1,
  1933. .io.pll_loopdiv = 8,
  1934. .io.adc_clock_ratio = 8,
  1935. .io.pll_int_loop_filt = 0,
  1936. .io.clock_khz = 30000,
  1937. .reset = dib90x0_tuner_reset,
  1938. .sleep = dib90x0_tuner_sleep,
  1939. .clkouttobamse = 0,
  1940. .analog_output = 0,
  1941. .use_pwm_agc = 0,
  1942. .clkoutdrive = 0,
  1943. .freq_offset_khz_uhf = 0,
  1944. .freq_offset_khz_vhf = 0,
  1945. };
  1946. static struct dib0090_config nim9090md_dib0090_config[2] = {
  1947. {
  1948. .io.pll_bypass = 0,
  1949. .io.pll_range = 1,
  1950. .io.pll_prediv = 1,
  1951. .io.pll_loopdiv = 8,
  1952. .io.adc_clock_ratio = 8,
  1953. .io.pll_int_loop_filt = 0,
  1954. .io.clock_khz = 30000,
  1955. .reset = dib90x0_tuner_reset,
  1956. .sleep = dib90x0_tuner_sleep,
  1957. .clkouttobamse = 1,
  1958. .analog_output = 0,
  1959. .use_pwm_agc = 0,
  1960. .clkoutdrive = 0,
  1961. .freq_offset_khz_uhf = 0,
  1962. .freq_offset_khz_vhf = 0,
  1963. }, {
  1964. .io.pll_bypass = 0,
  1965. .io.pll_range = 1,
  1966. .io.pll_prediv = 1,
  1967. .io.pll_loopdiv = 8,
  1968. .io.adc_clock_ratio = 8,
  1969. .io.pll_int_loop_filt = 0,
  1970. .io.clock_khz = 30000,
  1971. .reset = dib90x0_tuner_reset,
  1972. .sleep = dib90x0_tuner_sleep,
  1973. .clkouttobamse = 0,
  1974. .analog_output = 0,
  1975. .use_pwm_agc = 0,
  1976. .clkoutdrive = 0,
  1977. .freq_offset_khz_uhf = 0,
  1978. .freq_offset_khz_vhf = 0,
  1979. }
  1980. };
  1981. static int stk9090m_frontend_attach(struct dvb_usb_adapter *adap)
  1982. {
  1983. struct dib0700_adapter_state *state = adap->priv;
  1984. struct dib0700_state *st = adap->dev->priv;
  1985. u32 fw_version;
  1986. /* Make use of the new i2c functions from FW 1.20 */
  1987. dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
  1988. if (fw_version >= 0x10200)
  1989. st->fw_use_new_i2c_api = 1;
  1990. dib0700_set_i2c_speed(adap->dev, 340);
  1991. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  1992. msleep(20);
  1993. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  1994. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  1995. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  1996. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  1997. dib0700_ctrl_clock(adap->dev, 72, 1);
  1998. msleep(20);
  1999. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2000. msleep(20);
  2001. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2002. dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80);
  2003. if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
  2004. deb_info("%s: Upload failed. (file not found?)\n", __func__);
  2005. return -ENODEV;
  2006. } else {
  2007. deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
  2008. }
  2009. stk9090m_config.microcode_B_fe_size = state->frontend_firmware->size;
  2010. stk9090m_config.microcode_B_fe_buffer = state->frontend_firmware->data;
  2011. adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &stk9090m_config);
  2012. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2013. }
  2014. static int dib9090_tuner_attach(struct dvb_usb_adapter *adap)
  2015. {
  2016. struct dib0700_adapter_state *state = adap->priv;
  2017. struct i2c_adapter *i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
  2018. u16 data_dib190[10] = {
  2019. 1, 0x1374,
  2020. 2, 0x01a2,
  2021. 7, 0x0020,
  2022. 0, 0x00ef,
  2023. 8, 0x0486,
  2024. };
  2025. if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &dib9090_dib0090_config) == NULL)
  2026. return -ENODEV;
  2027. i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
  2028. if (dib01x0_pmu_update(i2c, data_dib190, 10) != 0)
  2029. return -ENODEV;
  2030. dib0700_set_i2c_speed(adap->dev, 1500);
  2031. if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
  2032. return -ENODEV;
  2033. release_firmware(state->frontend_firmware);
  2034. return 0;
  2035. }
  2036. static int nim9090md_frontend_attach(struct dvb_usb_adapter *adap)
  2037. {
  2038. struct dib0700_adapter_state *state = adap->priv;
  2039. struct dib0700_state *st = adap->dev->priv;
  2040. struct i2c_adapter *i2c;
  2041. struct dvb_frontend *fe_slave;
  2042. u32 fw_version;
  2043. /* Make use of the new i2c functions from FW 1.20 */
  2044. dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
  2045. if (fw_version >= 0x10200)
  2046. st->fw_use_new_i2c_api = 1;
  2047. dib0700_set_i2c_speed(adap->dev, 340);
  2048. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2049. msleep(20);
  2050. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2051. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2052. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2053. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2054. dib0700_ctrl_clock(adap->dev, 72, 1);
  2055. msleep(20);
  2056. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2057. msleep(20);
  2058. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2059. if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
  2060. deb_info("%s: Upload failed. (file not found?)\n", __func__);
  2061. return -EIO;
  2062. } else {
  2063. deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
  2064. }
  2065. nim9090md_config[0].microcode_B_fe_size = state->frontend_firmware->size;
  2066. nim9090md_config[0].microcode_B_fe_buffer = state->frontend_firmware->data;
  2067. nim9090md_config[1].microcode_B_fe_size = state->frontend_firmware->size;
  2068. nim9090md_config[1].microcode_B_fe_buffer = state->frontend_firmware->data;
  2069. dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, 0x80);
  2070. adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &nim9090md_config[0]);
  2071. if (adap->fe_adap[0].fe == NULL)
  2072. return -ENODEV;
  2073. i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_3_4, 0);
  2074. dib9000_i2c_enumeration(i2c, 1, 0x12, 0x82);
  2075. fe_slave = dvb_attach(dib9000_attach, i2c, 0x82, &nim9090md_config[1]);
  2076. dib9000_set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
  2077. return fe_slave == NULL ? -ENODEV : 0;
  2078. }
  2079. static int nim9090md_tuner_attach(struct dvb_usb_adapter *adap)
  2080. {
  2081. struct dib0700_adapter_state *state = adap->priv;
  2082. struct i2c_adapter *i2c;
  2083. struct dvb_frontend *fe_slave;
  2084. u16 data_dib190[10] = {
  2085. 1, 0x5374,
  2086. 2, 0x01ae,
  2087. 7, 0x0020,
  2088. 0, 0x00ef,
  2089. 8, 0x0406,
  2090. };
  2091. i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
  2092. if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &nim9090md_dib0090_config[0]) == NULL)
  2093. return -ENODEV;
  2094. i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
  2095. if (dib01x0_pmu_update(i2c, data_dib190, 10) < 0)
  2096. return -ENODEV;
  2097. dib0700_set_i2c_speed(adap->dev, 1500);
  2098. if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
  2099. return -ENODEV;
  2100. fe_slave = dib9000_get_slave_frontend(adap->fe_adap[0].fe, 1);
  2101. if (fe_slave != NULL) {
  2102. i2c = dib9000_get_component_bus_interface(adap->fe_adap[0].fe);
  2103. dib9000_set_i2c_adapter(fe_slave, i2c);
  2104. i2c = dib9000_get_tuner_interface(fe_slave);
  2105. if (dvb_attach(dib0090_fw_register, fe_slave, i2c, &nim9090md_dib0090_config[1]) == NULL)
  2106. return -ENODEV;
  2107. fe_slave->dvb = adap->fe_adap[0].fe->dvb;
  2108. dib9000_fw_set_component_bus_speed(adap->fe_adap[0].fe, 1500);
  2109. if (dib9000_firmware_post_pll_init(fe_slave) < 0)
  2110. return -ENODEV;
  2111. }
  2112. release_firmware(state->frontend_firmware);
  2113. return 0;
  2114. }
  2115. /* NIM7090 */
  2116. static int dib7090p_get_best_sampling(struct dvb_frontend *fe , struct dibx090p_best_adc *adc)
  2117. {
  2118. u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
  2119. u16 xtal = 12000;
  2120. u32 fcp_min = 1900; /* PLL Minimum Frequency comparator KHz */
  2121. u32 fcp_max = 20000; /* PLL Maximum Frequency comparator KHz */
  2122. u32 fdem_max = 76000;
  2123. u32 fdem_min = 69500;
  2124. u32 fcp = 0, fs = 0, fdem = 0;
  2125. u32 harmonic_id = 0;
  2126. adc->pll_loopdiv = loopdiv;
  2127. adc->pll_prediv = prediv;
  2128. adc->timf = 0;
  2129. deb_info("bandwidth = %d fdem_min =%d", fe->dtv_property_cache.bandwidth_hz, fdem_min);
  2130. /* Find Min and Max prediv */
  2131. while ((xtal/max_prediv) >= fcp_min)
  2132. max_prediv++;
  2133. max_prediv--;
  2134. min_prediv = max_prediv;
  2135. while ((xtal/min_prediv) <= fcp_max) {
  2136. min_prediv--;
  2137. if (min_prediv == 1)
  2138. break;
  2139. }
  2140. deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
  2141. min_prediv = 2;
  2142. for (prediv = min_prediv ; prediv < max_prediv; prediv++) {
  2143. fcp = xtal / prediv;
  2144. if (fcp > fcp_min && fcp < fcp_max) {
  2145. for (loopdiv = 1 ; loopdiv < 64 ; loopdiv++) {
  2146. fdem = ((xtal/prediv) * loopdiv);
  2147. fs = fdem / 4;
  2148. /* test min/max system restrictions */
  2149. if ((fdem >= fdem_min) && (fdem <= fdem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz/1000)) {
  2150. spur = 0;
  2151. /* test fs harmonics positions */
  2152. for (harmonic_id = (fe->dtv_property_cache.frequency / (1000*fs)) ; harmonic_id <= ((fe->dtv_property_cache.frequency / (1000*fs))+1) ; harmonic_id++) {
  2153. if (((fs*harmonic_id) >= ((fe->dtv_property_cache.frequency/1000) - (fe->dtv_property_cache.bandwidth_hz/2000))) && ((fs*harmonic_id) <= ((fe->dtv_property_cache.frequency/1000) + (fe->dtv_property_cache.bandwidth_hz/2000)))) {
  2154. spur = 1;
  2155. break;
  2156. }
  2157. }
  2158. if (!spur) {
  2159. adc->pll_loopdiv = loopdiv;
  2160. adc->pll_prediv = prediv;
  2161. adc->timf = 2396745143UL/fdem*(1 << 9);
  2162. adc->timf += ((2396745143UL%fdem) << 9)/fdem;
  2163. deb_info("loopdiv=%i prediv=%i timf=%i", loopdiv, prediv, adc->timf);
  2164. break;
  2165. }
  2166. }
  2167. }
  2168. }
  2169. if (!spur)
  2170. break;
  2171. }
  2172. if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
  2173. return -EINVAL;
  2174. else
  2175. return 0;
  2176. }
  2177. static int dib7090_agc_startup(struct dvb_frontend *fe)
  2178. {
  2179. struct dvb_usb_adapter *adap = fe->dvb->priv;
  2180. struct dib0700_adapter_state *state = adap->priv;
  2181. struct dibx000_bandwidth_config pll;
  2182. u16 target;
  2183. struct dibx090p_best_adc adc;
  2184. int ret;
  2185. ret = state->set_param_save(fe);
  2186. if (ret < 0)
  2187. return ret;
  2188. memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
  2189. dib0090_pwm_gain_reset(fe);
  2190. target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
  2191. state->dib7000p_ops.set_wbd_ref(fe, target);
  2192. if (dib7090p_get_best_sampling(fe, &adc) == 0) {
  2193. pll.pll_ratio = adc.pll_loopdiv;
  2194. pll.pll_prediv = adc.pll_prediv;
  2195. state->dib7000p_ops.update_pll(fe, &pll);
  2196. state->dib7000p_ops.ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
  2197. }
  2198. return 0;
  2199. }
  2200. static int dib7090_agc_restart(struct dvb_frontend *fe, u8 restart)
  2201. {
  2202. deb_info("AGC restart callback: %d", restart);
  2203. if (restart == 0) /* before AGC startup */
  2204. dib0090_set_dc_servo(fe, 1);
  2205. return 0;
  2206. }
  2207. static int tfe7790p_update_lna(struct dvb_frontend *fe, u16 agc_global)
  2208. {
  2209. struct dvb_usb_adapter *adap = fe->dvb->priv;
  2210. struct dib0700_adapter_state *state = adap->priv;
  2211. deb_info("update LNA: agc global=%i", agc_global);
  2212. if (agc_global < 25000) {
  2213. state->dib7000p_ops.set_gpio(fe, 8, 0, 0);
  2214. state->dib7000p_ops.set_agc1_min(fe, 0);
  2215. } else {
  2216. state->dib7000p_ops.set_gpio(fe, 8, 0, 1);
  2217. state->dib7000p_ops.set_agc1_min(fe, 32768);
  2218. }
  2219. return 0;
  2220. }
  2221. static struct dib0090_wbd_slope dib7090_wbd_table[] = {
  2222. { 380, 81, 850, 64, 540, 4},
  2223. { 860, 51, 866, 21, 375, 4},
  2224. {1700, 0, 250, 0, 100, 6},
  2225. {2600, 0, 250, 0, 100, 6},
  2226. { 0xFFFF, 0, 0, 0, 0, 0},
  2227. };
  2228. static struct dibx000_agc_config dib7090_agc_config[2] = {
  2229. {
  2230. .band_caps = BAND_UHF,
  2231. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
  2232. * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
  2233. .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
  2234. .inv_gain = 687,
  2235. .time_stabiliz = 10,
  2236. .alpha_level = 0,
  2237. .thlock = 118,
  2238. .wbd_inv = 0,
  2239. .wbd_ref = 1200,
  2240. .wbd_sel = 3,
  2241. .wbd_alpha = 5,
  2242. .agc1_max = 65535,
  2243. .agc1_min = 32768,
  2244. .agc2_max = 65535,
  2245. .agc2_min = 0,
  2246. .agc1_pt1 = 0,
  2247. .agc1_pt2 = 32,
  2248. .agc1_pt3 = 114,
  2249. .agc1_slope1 = 143,
  2250. .agc1_slope2 = 144,
  2251. .agc2_pt1 = 114,
  2252. .agc2_pt2 = 227,
  2253. .agc2_slope1 = 116,
  2254. .agc2_slope2 = 117,
  2255. .alpha_mant = 18,
  2256. .alpha_exp = 0,
  2257. .beta_mant = 20,
  2258. .beta_exp = 59,
  2259. .perform_agc_softsplit = 0,
  2260. } , {
  2261. .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
  2262. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
  2263. * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
  2264. .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
  2265. .inv_gain = 732,
  2266. .time_stabiliz = 10,
  2267. .alpha_level = 0,
  2268. .thlock = 118,
  2269. .wbd_inv = 0,
  2270. .wbd_ref = 1200,
  2271. .wbd_sel = 3,
  2272. .wbd_alpha = 5,
  2273. .agc1_max = 65535,
  2274. .agc1_min = 0,
  2275. .agc2_max = 65535,
  2276. .agc2_min = 0,
  2277. .agc1_pt1 = 0,
  2278. .agc1_pt2 = 0,
  2279. .agc1_pt3 = 98,
  2280. .agc1_slope1 = 0,
  2281. .agc1_slope2 = 167,
  2282. .agc2_pt1 = 98,
  2283. .agc2_pt2 = 255,
  2284. .agc2_slope1 = 104,
  2285. .agc2_slope2 = 0,
  2286. .alpha_mant = 18,
  2287. .alpha_exp = 0,
  2288. .beta_mant = 20,
  2289. .beta_exp = 59,
  2290. .perform_agc_softsplit = 0,
  2291. }
  2292. };
  2293. static struct dibx000_bandwidth_config dib7090_clock_config_12_mhz = {
  2294. .internal = 60000,
  2295. .sampling = 15000,
  2296. .pll_prediv = 1,
  2297. .pll_ratio = 5,
  2298. .pll_range = 0,
  2299. .pll_reset = 0,
  2300. .pll_bypass = 0,
  2301. .enable_refdiv = 0,
  2302. .bypclk_div = 0,
  2303. .IO_CLK_en_core = 1,
  2304. .ADClkSrc = 1,
  2305. .modulo = 2,
  2306. .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
  2307. .ifreq = (0 << 25) | 0,
  2308. .timf = 20452225,
  2309. .xtal_hz = 15000000,
  2310. };
  2311. static struct dib7000p_config nim7090_dib7000p_config = {
  2312. .output_mpeg2_in_188_bytes = 1,
  2313. .hostbus_diversity = 1,
  2314. .tuner_is_baseband = 1,
  2315. .update_lna = tfe7790p_update_lna, /* GPIO used is the same as TFE7790 */
  2316. .agc_config_count = 2,
  2317. .agc = dib7090_agc_config,
  2318. .bw = &dib7090_clock_config_12_mhz,
  2319. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2320. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2321. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2322. .pwm_freq_div = 0,
  2323. .agc_control = dib7090_agc_restart,
  2324. .spur_protect = 0,
  2325. .disable_sample_and_hold = 0,
  2326. .enable_current_mirror = 0,
  2327. .diversity_delay = 0,
  2328. .output_mode = OUTMODE_MPEG2_FIFO,
  2329. .enMpegOutput = 1,
  2330. };
  2331. static int tfe7090p_pvr_update_lna(struct dvb_frontend *fe, u16 agc_global)
  2332. {
  2333. struct dvb_usb_adapter *adap = fe->dvb->priv;
  2334. struct dib0700_adapter_state *state = adap->priv;
  2335. deb_info("TFE7090P-PVR update LNA: agc global=%i", agc_global);
  2336. if (agc_global < 25000) {
  2337. state->dib7000p_ops.set_gpio(fe, 5, 0, 0);
  2338. state->dib7000p_ops.set_agc1_min(fe, 0);
  2339. } else {
  2340. state->dib7000p_ops.set_gpio(fe, 5, 0, 1);
  2341. state->dib7000p_ops.set_agc1_min(fe, 32768);
  2342. }
  2343. return 0;
  2344. }
  2345. static struct dib7000p_config tfe7090pvr_dib7000p_config[2] = {
  2346. {
  2347. .output_mpeg2_in_188_bytes = 1,
  2348. .hostbus_diversity = 1,
  2349. .tuner_is_baseband = 1,
  2350. .update_lna = tfe7090p_pvr_update_lna,
  2351. .agc_config_count = 2,
  2352. .agc = dib7090_agc_config,
  2353. .bw = &dib7090_clock_config_12_mhz,
  2354. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2355. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2356. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2357. .pwm_freq_div = 0,
  2358. .agc_control = dib7090_agc_restart,
  2359. .spur_protect = 0,
  2360. .disable_sample_and_hold = 0,
  2361. .enable_current_mirror = 0,
  2362. .diversity_delay = 0,
  2363. .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
  2364. .default_i2c_addr = 0x90,
  2365. .enMpegOutput = 1,
  2366. }, {
  2367. .output_mpeg2_in_188_bytes = 1,
  2368. .hostbus_diversity = 1,
  2369. .tuner_is_baseband = 1,
  2370. .update_lna = tfe7090p_pvr_update_lna,
  2371. .agc_config_count = 2,
  2372. .agc = dib7090_agc_config,
  2373. .bw = &dib7090_clock_config_12_mhz,
  2374. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2375. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2376. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2377. .pwm_freq_div = 0,
  2378. .agc_control = dib7090_agc_restart,
  2379. .spur_protect = 0,
  2380. .disable_sample_and_hold = 0,
  2381. .enable_current_mirror = 0,
  2382. .diversity_delay = 0,
  2383. .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
  2384. .default_i2c_addr = 0x92,
  2385. .enMpegOutput = 0,
  2386. }
  2387. };
  2388. static struct dib0090_config nim7090_dib0090_config = {
  2389. .io.clock_khz = 12000,
  2390. .io.pll_bypass = 0,
  2391. .io.pll_range = 0,
  2392. .io.pll_prediv = 3,
  2393. .io.pll_loopdiv = 6,
  2394. .io.adc_clock_ratio = 0,
  2395. .io.pll_int_loop_filt = 0,
  2396. .freq_offset_khz_uhf = 0,
  2397. .freq_offset_khz_vhf = 0,
  2398. .clkouttobamse = 1,
  2399. .analog_output = 0,
  2400. .wbd_vhf_offset = 0,
  2401. .wbd_cband_offset = 0,
  2402. .use_pwm_agc = 1,
  2403. .clkoutdrive = 0,
  2404. .fref_clock_ratio = 0,
  2405. .wbd = dib7090_wbd_table,
  2406. .ls_cfg_pad_drv = 0,
  2407. .data_tx_drv = 0,
  2408. .low_if = NULL,
  2409. .in_soc = 1,
  2410. };
  2411. static struct dib7000p_config tfe7790p_dib7000p_config = {
  2412. .output_mpeg2_in_188_bytes = 1,
  2413. .hostbus_diversity = 1,
  2414. .tuner_is_baseband = 1,
  2415. .update_lna = tfe7790p_update_lna,
  2416. .agc_config_count = 2,
  2417. .agc = dib7090_agc_config,
  2418. .bw = &dib7090_clock_config_12_mhz,
  2419. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2420. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2421. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2422. .pwm_freq_div = 0,
  2423. .agc_control = dib7090_agc_restart,
  2424. .spur_protect = 0,
  2425. .disable_sample_and_hold = 0,
  2426. .enable_current_mirror = 0,
  2427. .diversity_delay = 0,
  2428. .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
  2429. .enMpegOutput = 1,
  2430. };
  2431. static struct dib0090_config tfe7790p_dib0090_config = {
  2432. .io.clock_khz = 12000,
  2433. .io.pll_bypass = 0,
  2434. .io.pll_range = 0,
  2435. .io.pll_prediv = 3,
  2436. .io.pll_loopdiv = 6,
  2437. .io.adc_clock_ratio = 0,
  2438. .io.pll_int_loop_filt = 0,
  2439. .freq_offset_khz_uhf = 0,
  2440. .freq_offset_khz_vhf = 0,
  2441. .clkouttobamse = 1,
  2442. .analog_output = 0,
  2443. .wbd_vhf_offset = 0,
  2444. .wbd_cband_offset = 0,
  2445. .use_pwm_agc = 1,
  2446. .clkoutdrive = 0,
  2447. .fref_clock_ratio = 0,
  2448. .wbd = dib7090_wbd_table,
  2449. .ls_cfg_pad_drv = 0,
  2450. .data_tx_drv = 0,
  2451. .low_if = NULL,
  2452. .in_soc = 1,
  2453. .force_cband_input = 0,
  2454. .is_dib7090e = 0,
  2455. .force_crystal_mode = 1,
  2456. };
  2457. static struct dib0090_config tfe7090pvr_dib0090_config[2] = {
  2458. {
  2459. .io.clock_khz = 12000,
  2460. .io.pll_bypass = 0,
  2461. .io.pll_range = 0,
  2462. .io.pll_prediv = 3,
  2463. .io.pll_loopdiv = 6,
  2464. .io.adc_clock_ratio = 0,
  2465. .io.pll_int_loop_filt = 0,
  2466. .freq_offset_khz_uhf = 50,
  2467. .freq_offset_khz_vhf = 70,
  2468. .clkouttobamse = 1,
  2469. .analog_output = 0,
  2470. .wbd_vhf_offset = 0,
  2471. .wbd_cband_offset = 0,
  2472. .use_pwm_agc = 1,
  2473. .clkoutdrive = 0,
  2474. .fref_clock_ratio = 0,
  2475. .wbd = dib7090_wbd_table,
  2476. .ls_cfg_pad_drv = 0,
  2477. .data_tx_drv = 0,
  2478. .low_if = NULL,
  2479. .in_soc = 1,
  2480. }, {
  2481. .io.clock_khz = 12000,
  2482. .io.pll_bypass = 0,
  2483. .io.pll_range = 0,
  2484. .io.pll_prediv = 3,
  2485. .io.pll_loopdiv = 6,
  2486. .io.adc_clock_ratio = 0,
  2487. .io.pll_int_loop_filt = 0,
  2488. .freq_offset_khz_uhf = -50,
  2489. .freq_offset_khz_vhf = -70,
  2490. .clkouttobamse = 1,
  2491. .analog_output = 0,
  2492. .wbd_vhf_offset = 0,
  2493. .wbd_cband_offset = 0,
  2494. .use_pwm_agc = 1,
  2495. .clkoutdrive = 0,
  2496. .fref_clock_ratio = 0,
  2497. .wbd = dib7090_wbd_table,
  2498. .ls_cfg_pad_drv = 0,
  2499. .data_tx_drv = 0,
  2500. .low_if = NULL,
  2501. .in_soc = 1,
  2502. }
  2503. };
  2504. static int nim7090_frontend_attach(struct dvb_usb_adapter *adap)
  2505. {
  2506. struct dib0700_adapter_state *state = adap->priv;
  2507. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2508. return -ENODEV;
  2509. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2510. msleep(20);
  2511. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2512. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2513. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2514. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2515. msleep(20);
  2516. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2517. msleep(20);
  2518. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2519. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, &nim7090_dib7000p_config) != 0) {
  2520. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
  2521. dvb_detach(&state->dib7000p_ops);
  2522. return -ENODEV;
  2523. }
  2524. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, &nim7090_dib7000p_config);
  2525. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2526. }
  2527. static int nim7090_tuner_attach(struct dvb_usb_adapter *adap)
  2528. {
  2529. struct dib0700_adapter_state *st = adap->priv;
  2530. struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
  2531. nim7090_dib0090_config.reset = st->dib7000p_ops.tuner_sleep,
  2532. nim7090_dib0090_config.sleep = st->dib7000p_ops.tuner_sleep,
  2533. nim7090_dib0090_config.get_adc_power = st->dib7000p_ops.get_adc_power;
  2534. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &nim7090_dib0090_config) == NULL)
  2535. return -ENODEV;
  2536. st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  2537. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  2538. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
  2539. return 0;
  2540. }
  2541. static int tfe7090pvr_frontend0_attach(struct dvb_usb_adapter *adap)
  2542. {
  2543. struct dib0700_state *st = adap->dev->priv;
  2544. struct dib0700_adapter_state *state = adap->priv;
  2545. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2546. return -ENODEV;
  2547. /* The TFE7090 requires the dib0700 to not be in master mode */
  2548. st->disable_streaming_master_mode = 1;
  2549. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2550. msleep(20);
  2551. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2552. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2553. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2554. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2555. msleep(20);
  2556. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2557. msleep(20);
  2558. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2559. /* initialize IC 0 */
  2560. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, &tfe7090pvr_dib7000p_config[0]) != 0) {
  2561. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
  2562. dvb_detach(&state->dib7000p_ops);
  2563. return -ENODEV;
  2564. }
  2565. dib0700_set_i2c_speed(adap->dev, 340);
  2566. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x90, &tfe7090pvr_dib7000p_config[0]);
  2567. if (adap->fe_adap[0].fe == NULL)
  2568. return -ENODEV;
  2569. state->dib7000p_ops.slave_reset(adap->fe_adap[0].fe);
  2570. return 0;
  2571. }
  2572. static int tfe7090pvr_frontend1_attach(struct dvb_usb_adapter *adap)
  2573. {
  2574. struct i2c_adapter *i2c;
  2575. struct dib0700_adapter_state *state = adap->priv;
  2576. if (adap->dev->adapter[0].fe_adap[0].fe == NULL) {
  2577. err("the master dib7090 has to be initialized first");
  2578. return -ENODEV; /* the master device has not been initialized */
  2579. }
  2580. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2581. return -ENODEV;
  2582. i2c = state->dib7000p_ops.get_i2c_master(adap->dev->adapter[0].fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_6_7, 1);
  2583. if (state->dib7000p_ops.i2c_enumeration(i2c, 1, 0x10, &tfe7090pvr_dib7000p_config[1]) != 0) {
  2584. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
  2585. dvb_detach(&state->dib7000p_ops);
  2586. return -ENODEV;
  2587. }
  2588. adap->fe_adap[0].fe = state->dib7000p_ops.init(i2c, 0x92, &tfe7090pvr_dib7000p_config[1]);
  2589. dib0700_set_i2c_speed(adap->dev, 200);
  2590. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2591. }
  2592. static int tfe7090pvr_tuner0_attach(struct dvb_usb_adapter *adap)
  2593. {
  2594. struct dib0700_adapter_state *st = adap->priv;
  2595. struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
  2596. tfe7090pvr_dib0090_config[0].reset = st->dib7000p_ops.tuner_sleep;
  2597. tfe7090pvr_dib0090_config[0].sleep = st->dib7000p_ops.tuner_sleep;
  2598. tfe7090pvr_dib0090_config[0].get_adc_power = st->dib7000p_ops.get_adc_power;
  2599. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[0]) == NULL)
  2600. return -ENODEV;
  2601. st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  2602. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  2603. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
  2604. return 0;
  2605. }
  2606. static int tfe7090pvr_tuner1_attach(struct dvb_usb_adapter *adap)
  2607. {
  2608. struct dib0700_adapter_state *st = adap->priv;
  2609. struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
  2610. tfe7090pvr_dib0090_config[1].reset = st->dib7000p_ops.tuner_sleep;
  2611. tfe7090pvr_dib0090_config[1].sleep = st->dib7000p_ops.tuner_sleep;
  2612. tfe7090pvr_dib0090_config[1].get_adc_power = st->dib7000p_ops.get_adc_power;
  2613. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[1]) == NULL)
  2614. return -ENODEV;
  2615. st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  2616. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  2617. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
  2618. return 0;
  2619. }
  2620. static int tfe7790p_frontend_attach(struct dvb_usb_adapter *adap)
  2621. {
  2622. struct dib0700_state *st = adap->dev->priv;
  2623. struct dib0700_adapter_state *state = adap->priv;
  2624. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2625. return -ENODEV;
  2626. /* The TFE7790P requires the dib0700 to not be in master mode */
  2627. st->disable_streaming_master_mode = 1;
  2628. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2629. msleep(20);
  2630. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2631. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2632. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2633. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2634. msleep(20);
  2635. dib0700_ctrl_clock(adap->dev, 72, 1);
  2636. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2637. msleep(20);
  2638. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2639. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap,
  2640. 1, 0x10, &tfe7790p_dib7000p_config) != 0) {
  2641. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
  2642. __func__);
  2643. dvb_detach(&state->dib7000p_ops);
  2644. return -ENODEV;
  2645. }
  2646. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
  2647. 0x80, &tfe7790p_dib7000p_config);
  2648. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2649. }
  2650. static int tfe7790p_tuner_attach(struct dvb_usb_adapter *adap)
  2651. {
  2652. struct dib0700_adapter_state *st = adap->priv;
  2653. struct i2c_adapter *tun_i2c =
  2654. st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
  2655. tfe7790p_dib0090_config.reset = st->dib7000p_ops.tuner_sleep;
  2656. tfe7790p_dib0090_config.sleep = st->dib7000p_ops.tuner_sleep;
  2657. tfe7790p_dib0090_config.get_adc_power = st->dib7000p_ops.get_adc_power;
  2658. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
  2659. &tfe7790p_dib0090_config) == NULL)
  2660. return -ENODEV;
  2661. st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  2662. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  2663. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
  2664. return 0;
  2665. }
  2666. /* STK7070PD */
  2667. static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
  2668. {
  2669. .output_mpeg2_in_188_bytes = 1,
  2670. .agc_config_count = 1,
  2671. .agc = &dib7070_agc_config,
  2672. .bw = &dib7070_bw_config_12_mhz,
  2673. .tuner_is_baseband = 1,
  2674. .spur_protect = 1,
  2675. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2676. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2677. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2678. .hostbus_diversity = 1,
  2679. }, {
  2680. .output_mpeg2_in_188_bytes = 1,
  2681. .agc_config_count = 1,
  2682. .agc = &dib7070_agc_config,
  2683. .bw = &dib7070_bw_config_12_mhz,
  2684. .tuner_is_baseband = 1,
  2685. .spur_protect = 1,
  2686. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2687. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2688. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2689. .hostbus_diversity = 1,
  2690. }
  2691. };
  2692. static void stk7070pd_init(struct dvb_usb_device *dev)
  2693. {
  2694. dib0700_set_gpio(dev, GPIO6, GPIO_OUT, 1);
  2695. msleep(10);
  2696. dib0700_set_gpio(dev, GPIO9, GPIO_OUT, 1);
  2697. dib0700_set_gpio(dev, GPIO4, GPIO_OUT, 1);
  2698. dib0700_set_gpio(dev, GPIO7, GPIO_OUT, 1);
  2699. dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 0);
  2700. dib0700_ctrl_clock(dev, 72, 1);
  2701. msleep(10);
  2702. dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 1);
  2703. }
  2704. static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
  2705. {
  2706. struct dib0700_adapter_state *state = adap->priv;
  2707. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2708. return -ENODEV;
  2709. stk7070pd_init(adap->dev);
  2710. msleep(10);
  2711. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2712. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
  2713. stk7070pd_dib7000p_config) != 0) {
  2714. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
  2715. __func__);
  2716. dvb_detach(&state->dib7000p_ops);
  2717. return -ENODEV;
  2718. }
  2719. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, &stk7070pd_dib7000p_config[0]);
  2720. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2721. }
  2722. static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
  2723. {
  2724. struct dib0700_adapter_state *state = adap->priv;
  2725. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2726. return -ENODEV;
  2727. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x82, &stk7070pd_dib7000p_config[1]);
  2728. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2729. }
  2730. static int novatd_read_status_override(struct dvb_frontend *fe,
  2731. enum fe_status *stat)
  2732. {
  2733. struct dvb_usb_adapter *adap = fe->dvb->priv;
  2734. struct dvb_usb_device *dev = adap->dev;
  2735. struct dib0700_state *state = dev->priv;
  2736. int ret;
  2737. ret = state->read_status(fe, stat);
  2738. if (!ret)
  2739. dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT,
  2740. !!(*stat & FE_HAS_LOCK));
  2741. return ret;
  2742. }
  2743. static int novatd_sleep_override(struct dvb_frontend* fe)
  2744. {
  2745. struct dvb_usb_adapter *adap = fe->dvb->priv;
  2746. struct dvb_usb_device *dev = adap->dev;
  2747. struct dib0700_state *state = dev->priv;
  2748. /* turn off LED */
  2749. dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT, 0);
  2750. return state->sleep(fe);
  2751. }
  2752. /**
  2753. * novatd_frontend_attach - Nova-TD specific attach
  2754. *
  2755. * Nova-TD has GPIO0, 1 and 2 for LEDs. So do not fiddle with them except for
  2756. * information purposes.
  2757. */
  2758. static int novatd_frontend_attach(struct dvb_usb_adapter *adap)
  2759. {
  2760. struct dvb_usb_device *dev = adap->dev;
  2761. struct dib0700_state *st = dev->priv;
  2762. struct dib0700_adapter_state *state = adap->priv;
  2763. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2764. return -ENODEV;
  2765. if (adap->id == 0) {
  2766. stk7070pd_init(dev);
  2767. /* turn the power LED on, the other two off (just in case) */
  2768. dib0700_set_gpio(dev, GPIO0, GPIO_OUT, 0);
  2769. dib0700_set_gpio(dev, GPIO1, GPIO_OUT, 0);
  2770. dib0700_set_gpio(dev, GPIO2, GPIO_OUT, 1);
  2771. if (state->dib7000p_ops.i2c_enumeration(&dev->i2c_adap, 2, 18,
  2772. stk7070pd_dib7000p_config) != 0) {
  2773. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
  2774. __func__);
  2775. dvb_detach(&state->dib7000p_ops);
  2776. return -ENODEV;
  2777. }
  2778. }
  2779. adap->fe_adap[0].fe = state->dib7000p_ops.init(&dev->i2c_adap,
  2780. adap->id == 0 ? 0x80 : 0x82,
  2781. &stk7070pd_dib7000p_config[adap->id]);
  2782. if (adap->fe_adap[0].fe == NULL)
  2783. return -ENODEV;
  2784. st->read_status = adap->fe_adap[0].fe->ops.read_status;
  2785. adap->fe_adap[0].fe->ops.read_status = novatd_read_status_override;
  2786. st->sleep = adap->fe_adap[0].fe->ops.sleep;
  2787. adap->fe_adap[0].fe->ops.sleep = novatd_sleep_override;
  2788. return 0;
  2789. }
  2790. /* S5H1411 */
  2791. static struct s5h1411_config pinnacle_801e_config = {
  2792. .output_mode = S5H1411_PARALLEL_OUTPUT,
  2793. .gpio = S5H1411_GPIO_OFF,
  2794. .mpeg_timing = S5H1411_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
  2795. .qam_if = S5H1411_IF_44000,
  2796. .vsb_if = S5H1411_IF_44000,
  2797. .inversion = S5H1411_INVERSION_OFF,
  2798. .status_mode = S5H1411_DEMODLOCKING
  2799. };
  2800. /* Pinnacle PCTV HD Pro 801e GPIOs map:
  2801. GPIO0 - currently unknown
  2802. GPIO1 - xc5000 tuner reset
  2803. GPIO2 - CX25843 sleep
  2804. GPIO3 - currently unknown
  2805. GPIO4 - currently unknown
  2806. GPIO6 - currently unknown
  2807. GPIO7 - currently unknown
  2808. GPIO9 - currently unknown
  2809. GPIO10 - CX25843 reset
  2810. */
  2811. static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap)
  2812. {
  2813. struct dib0700_state *st = adap->dev->priv;
  2814. /* Make use of the new i2c functions from FW 1.20 */
  2815. st->fw_use_new_i2c_api = 1;
  2816. /* The s5h1411 requires the dib0700 to not be in master mode */
  2817. st->disable_streaming_master_mode = 1;
  2818. /* All msleep values taken from Windows USB trace */
  2819. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
  2820. dib0700_set_gpio(adap->dev, GPIO3, GPIO_OUT, 0);
  2821. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2822. msleep(400);
  2823. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2824. msleep(60);
  2825. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2826. msleep(30);
  2827. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2828. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2829. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2830. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2831. dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 0);
  2832. msleep(30);
  2833. /* Put the CX25843 to sleep for now since we're in digital mode */
  2834. dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
  2835. /* GPIOs are initialized, do the attach */
  2836. adap->fe_adap[0].fe = dvb_attach(s5h1411_attach, &pinnacle_801e_config,
  2837. &adap->dev->i2c_adap);
  2838. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2839. }
  2840. static int dib0700_xc5000_tuner_callback(void *priv, int component,
  2841. int command, int arg)
  2842. {
  2843. struct dvb_usb_adapter *adap = priv;
  2844. if (command == XC5000_TUNER_RESET) {
  2845. /* Reset the tuner */
  2846. dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 0);
  2847. msleep(10);
  2848. dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 1);
  2849. msleep(10);
  2850. } else {
  2851. err("xc5000: unknown tuner callback command: %d\n", command);
  2852. return -EINVAL;
  2853. }
  2854. return 0;
  2855. }
  2856. static struct xc5000_config s5h1411_xc5000_tunerconfig = {
  2857. .i2c_address = 0x64,
  2858. .if_khz = 5380,
  2859. };
  2860. static int xc5000_tuner_attach(struct dvb_usb_adapter *adap)
  2861. {
  2862. /* FIXME: generalize & move to common area */
  2863. adap->fe_adap[0].fe->callback = dib0700_xc5000_tuner_callback;
  2864. return dvb_attach(xc5000_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap,
  2865. &s5h1411_xc5000_tunerconfig)
  2866. == NULL ? -ENODEV : 0;
  2867. }
  2868. static int dib0700_xc4000_tuner_callback(void *priv, int component,
  2869. int command, int arg)
  2870. {
  2871. struct dvb_usb_adapter *adap = priv;
  2872. struct dib0700_adapter_state *state = adap->priv;
  2873. if (command == XC4000_TUNER_RESET) {
  2874. /* Reset the tuner */
  2875. state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
  2876. msleep(10);
  2877. state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  2878. } else {
  2879. err("xc4000: unknown tuner callback command: %d\n", command);
  2880. return -EINVAL;
  2881. }
  2882. return 0;
  2883. }
  2884. static struct dibx000_agc_config stk7700p_7000p_xc4000_agc_config = {
  2885. .band_caps = BAND_UHF | BAND_VHF,
  2886. .setup = 0x64,
  2887. .inv_gain = 0x02c8,
  2888. .time_stabiliz = 0x15,
  2889. .alpha_level = 0x00,
  2890. .thlock = 0x76,
  2891. .wbd_inv = 0x01,
  2892. .wbd_ref = 0x0b33,
  2893. .wbd_sel = 0x00,
  2894. .wbd_alpha = 0x02,
  2895. .agc1_max = 0x00,
  2896. .agc1_min = 0x00,
  2897. .agc2_max = 0x9b26,
  2898. .agc2_min = 0x26ca,
  2899. .agc1_pt1 = 0x00,
  2900. .agc1_pt2 = 0x00,
  2901. .agc1_pt3 = 0x00,
  2902. .agc1_slope1 = 0x00,
  2903. .agc1_slope2 = 0x00,
  2904. .agc2_pt1 = 0x00,
  2905. .agc2_pt2 = 0x80,
  2906. .agc2_slope1 = 0x1d,
  2907. .agc2_slope2 = 0x1d,
  2908. .alpha_mant = 0x11,
  2909. .alpha_exp = 0x1b,
  2910. .beta_mant = 0x17,
  2911. .beta_exp = 0x33,
  2912. .perform_agc_softsplit = 0x00,
  2913. };
  2914. static struct dibx000_bandwidth_config stk7700p_xc4000_pll_config = {
  2915. .internal = 60000,
  2916. .sampling = 30000,
  2917. .pll_prediv = 1,
  2918. .pll_ratio = 8,
  2919. .pll_range = 3,
  2920. .pll_reset = 1,
  2921. .pll_bypass = 0,
  2922. .enable_refdiv = 0,
  2923. .bypclk_div = 0,
  2924. .IO_CLK_en_core = 1,
  2925. .ADClkSrc = 1,
  2926. .modulo = 0,
  2927. .sad_cfg = (3 << 14) | (1 << 12) | 524, /* sad_cfg: refsel, sel, freq_15k */
  2928. .ifreq = 39370534,
  2929. .timf = 20452225,
  2930. .xtal_hz = 30000000
  2931. };
  2932. /* FIXME: none of these inputs are validated yet */
  2933. static struct dib7000p_config pctv_340e_config = {
  2934. .output_mpeg2_in_188_bytes = 1,
  2935. .agc_config_count = 1,
  2936. .agc = &stk7700p_7000p_xc4000_agc_config,
  2937. .bw = &stk7700p_xc4000_pll_config,
  2938. .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
  2939. .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
  2940. .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
  2941. };
  2942. /* PCTV 340e GPIOs map:
  2943. dib0700:
  2944. GPIO2 - CX25843 sleep
  2945. GPIO3 - CS5340 reset
  2946. GPIO5 - IRD
  2947. GPIO6 - Power Supply
  2948. GPIO8 - LNA (1=off 0=on)
  2949. GPIO10 - CX25843 reset
  2950. dib7000:
  2951. GPIO8 - xc4000 reset
  2952. */
  2953. static int pctv340e_frontend_attach(struct dvb_usb_adapter *adap)
  2954. {
  2955. struct dib0700_state *st = adap->dev->priv;
  2956. struct dib0700_adapter_state *state = adap->priv;
  2957. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2958. return -ENODEV;
  2959. /* Power Supply on */
  2960. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  2961. msleep(50);
  2962. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2963. msleep(100); /* Allow power supply to settle before probing */
  2964. /* cx25843 reset */
  2965. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2966. msleep(1); /* cx25843 datasheet say 350us required */
  2967. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2968. /* LNA off for now */
  2969. dib0700_set_gpio(adap->dev, GPIO8, GPIO_OUT, 1);
  2970. /* Put the CX25843 to sleep for now since we're in digital mode */
  2971. dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
  2972. /* FIXME: not verified yet */
  2973. dib0700_ctrl_clock(adap->dev, 72, 1);
  2974. msleep(500);
  2975. if (state->dib7000p_ops.dib7000pc_detection(&adap->dev->i2c_adap) == 0) {
  2976. /* Demodulator not found for some reason? */
  2977. dvb_detach(&state->dib7000p_ops);
  2978. return -ENODEV;
  2979. }
  2980. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x12,
  2981. &pctv_340e_config);
  2982. st->is_dib7000pc = 1;
  2983. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2984. }
  2985. static struct xc4000_config dib7000p_xc4000_tunerconfig = {
  2986. .i2c_address = 0x61,
  2987. .default_pm = 1,
  2988. .dvb_amplitude = 0,
  2989. .set_smoothedcvbs = 0,
  2990. .if_khz = 5400
  2991. };
  2992. static int xc4000_tuner_attach(struct dvb_usb_adapter *adap)
  2993. {
  2994. struct i2c_adapter *tun_i2c;
  2995. struct dib0700_adapter_state *state = adap->priv;
  2996. /* The xc4000 is not on the main i2c bus */
  2997. tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
  2998. DIBX000_I2C_INTERFACE_TUNER, 1);
  2999. if (tun_i2c == NULL) {
  3000. printk(KERN_ERR "Could not reach tuner i2c bus\n");
  3001. return 0;
  3002. }
  3003. /* Setup the reset callback */
  3004. adap->fe_adap[0].fe->callback = dib0700_xc4000_tuner_callback;
  3005. return dvb_attach(xc4000_attach, adap->fe_adap[0].fe, tun_i2c,
  3006. &dib7000p_xc4000_tunerconfig)
  3007. == NULL ? -ENODEV : 0;
  3008. }
  3009. static struct lgdt3305_config hcw_lgdt3305_config = {
  3010. .i2c_addr = 0x0e,
  3011. .mpeg_mode = LGDT3305_MPEG_PARALLEL,
  3012. .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
  3013. .tpvalid_polarity = LGDT3305_TP_VALID_LOW,
  3014. .deny_i2c_rptr = 0,
  3015. .spectral_inversion = 1,
  3016. .qam_if_khz = 6000,
  3017. .vsb_if_khz = 6000,
  3018. .usref_8vsb = 0x0500,
  3019. };
  3020. static struct mxl5007t_config hcw_mxl5007t_config = {
  3021. .xtal_freq_hz = MxL_XTAL_25_MHZ,
  3022. .if_freq_hz = MxL_IF_6_MHZ,
  3023. .invert_if = 1,
  3024. };
  3025. /* TIGER-ATSC map:
  3026. GPIO0 - LNA_CTR (H: LNA power enabled, L: LNA power disabled)
  3027. GPIO1 - ANT_SEL (H: VPA, L: MCX)
  3028. GPIO4 - SCL2
  3029. GPIO6 - EN_TUNER
  3030. GPIO7 - SDA2
  3031. GPIO10 - DEM_RST
  3032. MXL is behind LG's i2c repeater. LG is on SCL2/SDA2 gpios on the DIB
  3033. */
  3034. static int lgdt3305_frontend_attach(struct dvb_usb_adapter *adap)
  3035. {
  3036. struct dib0700_state *st = adap->dev->priv;
  3037. /* Make use of the new i2c functions from FW 1.20 */
  3038. st->fw_use_new_i2c_api = 1;
  3039. st->disable_streaming_master_mode = 1;
  3040. /* fe power enable */
  3041. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  3042. msleep(30);
  3043. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  3044. msleep(30);
  3045. /* demod reset */
  3046. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  3047. msleep(30);
  3048. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  3049. msleep(30);
  3050. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  3051. msleep(30);
  3052. adap->fe_adap[0].fe = dvb_attach(lgdt3305_attach,
  3053. &hcw_lgdt3305_config,
  3054. &adap->dev->i2c_adap);
  3055. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  3056. }
  3057. static int mxl5007t_tuner_attach(struct dvb_usb_adapter *adap)
  3058. {
  3059. return dvb_attach(mxl5007t_attach, adap->fe_adap[0].fe,
  3060. &adap->dev->i2c_adap, 0x60,
  3061. &hcw_mxl5007t_config) == NULL ? -ENODEV : 0;
  3062. }
  3063. /* DVB-USB and USB stuff follows */
  3064. struct usb_device_id dib0700_usb_id_table[] = {
  3065. /* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
  3066. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) },
  3067. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
  3068. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
  3069. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
  3070. /* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
  3071. { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) },
  3072. { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) },
  3073. { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
  3074. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
  3075. /* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
  3076. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) },
  3077. { USB_DEVICE(USB_VID_TERRATEC,
  3078. USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
  3079. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
  3080. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) },
  3081. /* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) },
  3082. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) },
  3083. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) },
  3084. { USB_DEVICE(USB_VID_PINNACLE,
  3085. USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) },
  3086. { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500_PC) },
  3087. /* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) },
  3088. { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U7000) },
  3089. { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) },
  3090. { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000) },
  3091. { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100) },
  3092. /* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) },
  3093. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) },
  3094. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_USB_XE) },
  3095. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_EXPRESSCARD_320CX) },
  3096. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV72E) },
  3097. /* 30 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73E) },
  3098. { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_EC372S) },
  3099. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) },
  3100. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) },
  3101. { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) },
  3102. /* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) },
  3103. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_3) },
  3104. { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U8000) },
  3105. { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700PH) },
  3106. { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) },
  3107. /* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) },
  3108. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) },
  3109. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_EXPRESS) },
  3110. { USB_DEVICE(USB_VID_TERRATEC,
  3111. USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2) },
  3112. { USB_DEVICE(USB_VID_SONY, USB_PID_SONY_PLAYTV) },
  3113. /* 45 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_PD378S) },
  3114. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC) },
  3115. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC_B210) },
  3116. { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_MC770) },
  3117. { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT) },
  3118. /* 50 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_Dlx) },
  3119. { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_H) },
  3120. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T3) },
  3121. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T5) },
  3122. { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D) },
  3123. /* 55 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D_2) },
  3124. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73A) },
  3125. { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV73ESE) },
  3126. { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV282E) },
  3127. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7770P) },
  3128. /* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) },
  3129. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XPVR) },
  3130. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XP) },
  3131. { USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x000, 0x3f00) },
  3132. { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) },
  3133. /* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) },
  3134. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) },
  3135. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) },
  3136. { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DIVERSITY) },
  3137. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090M) },
  3138. /* 70 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM8096MD) },
  3139. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090MD) },
  3140. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM7090) },
  3141. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7090PVR) },
  3142. { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_AIRSTAR_TELESTICK_2) },
  3143. /* 75 */{ USB_DEVICE(USB_VID_MEDION, USB_PID_CREATIX_CTX1921) },
  3144. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E) },
  3145. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E_SE) },
  3146. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7790P) },
  3147. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE8096P) },
  3148. /* 80 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_2) },
  3149. { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E) },
  3150. { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E_SE) },
  3151. { 0 } /* Terminating entry */
  3152. };
  3153. MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
  3154. #define DIB0700_DEFAULT_DEVICE_PROPERTIES \
  3155. .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
  3156. .usb_ctrl = DEVICE_SPECIFIC, \
  3157. .firmware = "dvb-usb-dib0700-1.20.fw", \
  3158. .download_firmware = dib0700_download_firmware, \
  3159. .no_reconnect = 1, \
  3160. .size_of_priv = sizeof(struct dib0700_state), \
  3161. .i2c_algo = &dib0700_i2c_algo, \
  3162. .identify_state = dib0700_identify_state
  3163. #define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
  3164. .streaming_ctrl = dib0700_streaming_ctrl, \
  3165. .stream = { \
  3166. .type = USB_BULK, \
  3167. .count = 4, \
  3168. .endpoint = ep, \
  3169. .u = { \
  3170. .bulk = { \
  3171. .buffersize = 39480, \
  3172. } \
  3173. } \
  3174. }
  3175. #define DIB0700_NUM_FRONTENDS(n) \
  3176. .num_frontends = n, \
  3177. .size_of_priv = sizeof(struct dib0700_adapter_state)
  3178. struct dvb_usb_device_properties dib0700_devices[] = {
  3179. {
  3180. DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3181. .num_adapters = 1,
  3182. .adapter = {
  3183. {
  3184. DIB0700_NUM_FRONTENDS(1),
  3185. .fe = {{
  3186. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3187. .pid_filter_count = 32,
  3188. .pid_filter = stk7700p_pid_filter,
  3189. .pid_filter_ctrl = stk7700p_pid_filter_ctrl,
  3190. .frontend_attach = stk7700p_frontend_attach,
  3191. .tuner_attach = stk7700p_tuner_attach,
  3192. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3193. }},
  3194. },
  3195. },
  3196. .num_device_descs = 8,
  3197. .devices = {
  3198. { "DiBcom STK7700P reference design",
  3199. { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
  3200. { NULL },
  3201. },
  3202. { "Hauppauge Nova-T Stick",
  3203. { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
  3204. { NULL },
  3205. },
  3206. { "AVerMedia AVerTV DVB-T Volar",
  3207. { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
  3208. { NULL },
  3209. },
  3210. { "Compro Videomate U500",
  3211. { &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] },
  3212. { NULL },
  3213. },
  3214. { "Uniwill STK7700P based (Hama and others)",
  3215. { &dib0700_usb_id_table[7], NULL },
  3216. { NULL },
  3217. },
  3218. { "Leadtek Winfast DTV Dongle (STK7700P based)",
  3219. { &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] },
  3220. { NULL },
  3221. },
  3222. { "AVerMedia AVerTV DVB-T Express",
  3223. { &dib0700_usb_id_table[20] },
  3224. { NULL },
  3225. },
  3226. { "Gigabyte U7000",
  3227. { &dib0700_usb_id_table[21], NULL },
  3228. { NULL },
  3229. }
  3230. },
  3231. .rc.core = {
  3232. .rc_interval = DEFAULT_RC_INTERVAL,
  3233. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3234. .rc_query = dib0700_rc_query_old_firmware,
  3235. .allowed_protos = RC_BIT_RC5 |
  3236. RC_BIT_RC6_MCE |
  3237. RC_BIT_NEC,
  3238. .change_protocol = dib0700_change_protocol,
  3239. },
  3240. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3241. .num_adapters = 2,
  3242. .adapter = {
  3243. {
  3244. DIB0700_NUM_FRONTENDS(1),
  3245. .fe = {{
  3246. .frontend_attach = bristol_frontend_attach,
  3247. .tuner_attach = bristol_tuner_attach,
  3248. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3249. }},
  3250. }, {
  3251. DIB0700_NUM_FRONTENDS(1),
  3252. .fe = {{
  3253. .frontend_attach = bristol_frontend_attach,
  3254. .tuner_attach = bristol_tuner_attach,
  3255. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3256. }},
  3257. }
  3258. },
  3259. .num_device_descs = 1,
  3260. .devices = {
  3261. { "Hauppauge Nova-T 500 Dual DVB-T",
  3262. { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
  3263. { NULL },
  3264. },
  3265. },
  3266. .rc.core = {
  3267. .rc_interval = DEFAULT_RC_INTERVAL,
  3268. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3269. .rc_query = dib0700_rc_query_old_firmware,
  3270. .allowed_protos = RC_BIT_RC5 |
  3271. RC_BIT_RC6_MCE |
  3272. RC_BIT_NEC,
  3273. .change_protocol = dib0700_change_protocol,
  3274. },
  3275. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3276. .num_adapters = 2,
  3277. .adapter = {
  3278. {
  3279. DIB0700_NUM_FRONTENDS(1),
  3280. .fe = {{
  3281. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3282. .pid_filter_count = 32,
  3283. .pid_filter = stk70x0p_pid_filter,
  3284. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3285. .frontend_attach = stk7700d_frontend_attach,
  3286. .tuner_attach = stk7700d_tuner_attach,
  3287. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3288. }},
  3289. }, {
  3290. DIB0700_NUM_FRONTENDS(1),
  3291. .fe = {{
  3292. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3293. .pid_filter_count = 32,
  3294. .pid_filter = stk70x0p_pid_filter,
  3295. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3296. .frontend_attach = stk7700d_frontend_attach,
  3297. .tuner_attach = stk7700d_tuner_attach,
  3298. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3299. }},
  3300. }
  3301. },
  3302. .num_device_descs = 5,
  3303. .devices = {
  3304. { "Pinnacle PCTV 2000e",
  3305. { &dib0700_usb_id_table[11], NULL },
  3306. { NULL },
  3307. },
  3308. { "Terratec Cinergy DT XS Diversity",
  3309. { &dib0700_usb_id_table[12], NULL },
  3310. { NULL },
  3311. },
  3312. { "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
  3313. { &dib0700_usb_id_table[13], NULL },
  3314. { NULL },
  3315. },
  3316. { "DiBcom STK7700D reference design",
  3317. { &dib0700_usb_id_table[14], NULL },
  3318. { NULL },
  3319. },
  3320. { "YUAN High-Tech DiBcom STK7700D",
  3321. { &dib0700_usb_id_table[55], NULL },
  3322. { NULL },
  3323. },
  3324. },
  3325. .rc.core = {
  3326. .rc_interval = DEFAULT_RC_INTERVAL,
  3327. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3328. .rc_query = dib0700_rc_query_old_firmware,
  3329. .allowed_protos = RC_BIT_RC5 |
  3330. RC_BIT_RC6_MCE |
  3331. RC_BIT_NEC,
  3332. .change_protocol = dib0700_change_protocol,
  3333. },
  3334. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3335. .num_adapters = 1,
  3336. .adapter = {
  3337. {
  3338. DIB0700_NUM_FRONTENDS(1),
  3339. .fe = {{
  3340. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3341. .pid_filter_count = 32,
  3342. .pid_filter = stk70x0p_pid_filter,
  3343. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3344. .frontend_attach = stk7700P2_frontend_attach,
  3345. .tuner_attach = stk7700d_tuner_attach,
  3346. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3347. }},
  3348. },
  3349. },
  3350. .num_device_descs = 3,
  3351. .devices = {
  3352. { "ASUS My Cinema U3000 Mini DVBT Tuner",
  3353. { &dib0700_usb_id_table[23], NULL },
  3354. { NULL },
  3355. },
  3356. { "Yuan EC372S",
  3357. { &dib0700_usb_id_table[31], NULL },
  3358. { NULL },
  3359. },
  3360. { "Terratec Cinergy T Express",
  3361. { &dib0700_usb_id_table[42], NULL },
  3362. { NULL },
  3363. }
  3364. },
  3365. .rc.core = {
  3366. .rc_interval = DEFAULT_RC_INTERVAL,
  3367. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3368. .module_name = "dib0700",
  3369. .rc_query = dib0700_rc_query_old_firmware,
  3370. .allowed_protos = RC_BIT_RC5 |
  3371. RC_BIT_RC6_MCE |
  3372. RC_BIT_NEC,
  3373. .change_protocol = dib0700_change_protocol,
  3374. },
  3375. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3376. .num_adapters = 1,
  3377. .adapter = {
  3378. {
  3379. DIB0700_NUM_FRONTENDS(1),
  3380. .fe = {{
  3381. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3382. .pid_filter_count = 32,
  3383. .pid_filter = stk70x0p_pid_filter,
  3384. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3385. .frontend_attach = stk7070p_frontend_attach,
  3386. .tuner_attach = dib7070p_tuner_attach,
  3387. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3388. }},
  3389. },
  3390. },
  3391. .num_device_descs = 12,
  3392. .devices = {
  3393. { "DiBcom STK7070P reference design",
  3394. { &dib0700_usb_id_table[15], NULL },
  3395. { NULL },
  3396. },
  3397. { "Pinnacle PCTV DVB-T Flash Stick",
  3398. { &dib0700_usb_id_table[16], NULL },
  3399. { NULL },
  3400. },
  3401. { "Artec T14BR DVB-T",
  3402. { &dib0700_usb_id_table[22], NULL },
  3403. { NULL },
  3404. },
  3405. { "ASUS My Cinema U3100 Mini DVBT Tuner",
  3406. { &dib0700_usb_id_table[24], NULL },
  3407. { NULL },
  3408. },
  3409. { "Hauppauge Nova-T Stick",
  3410. { &dib0700_usb_id_table[25], NULL },
  3411. { NULL },
  3412. },
  3413. { "Hauppauge Nova-T MyTV.t",
  3414. { &dib0700_usb_id_table[26], NULL },
  3415. { NULL },
  3416. },
  3417. { "Pinnacle PCTV 72e",
  3418. { &dib0700_usb_id_table[29], NULL },
  3419. { NULL },
  3420. },
  3421. { "Pinnacle PCTV 73e",
  3422. { &dib0700_usb_id_table[30], NULL },
  3423. { NULL },
  3424. },
  3425. { "Elgato EyeTV DTT",
  3426. { &dib0700_usb_id_table[49], NULL },
  3427. { NULL },
  3428. },
  3429. { "Yuan PD378S",
  3430. { &dib0700_usb_id_table[45], NULL },
  3431. { NULL },
  3432. },
  3433. { "Elgato EyeTV Dtt Dlx PD378S",
  3434. { &dib0700_usb_id_table[50], NULL },
  3435. { NULL },
  3436. },
  3437. { "Elgato EyeTV DTT rev. 2",
  3438. { &dib0700_usb_id_table[80], NULL },
  3439. { NULL },
  3440. },
  3441. },
  3442. .rc.core = {
  3443. .rc_interval = DEFAULT_RC_INTERVAL,
  3444. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3445. .module_name = "dib0700",
  3446. .rc_query = dib0700_rc_query_old_firmware,
  3447. .allowed_protos = RC_BIT_RC5 |
  3448. RC_BIT_RC6_MCE |
  3449. RC_BIT_NEC,
  3450. .change_protocol = dib0700_change_protocol,
  3451. },
  3452. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3453. .num_adapters = 1,
  3454. .adapter = {
  3455. {
  3456. DIB0700_NUM_FRONTENDS(1),
  3457. .fe = {{
  3458. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3459. .pid_filter_count = 32,
  3460. .pid_filter = stk70x0p_pid_filter,
  3461. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3462. .frontend_attach = stk7070p_frontend_attach,
  3463. .tuner_attach = dib7070p_tuner_attach,
  3464. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3465. }},
  3466. },
  3467. },
  3468. .num_device_descs = 3,
  3469. .devices = {
  3470. { "Pinnacle PCTV 73A",
  3471. { &dib0700_usb_id_table[56], NULL },
  3472. { NULL },
  3473. },
  3474. { "Pinnacle PCTV 73e SE",
  3475. { &dib0700_usb_id_table[57], &dib0700_usb_id_table[65], NULL },
  3476. { NULL },
  3477. },
  3478. { "Pinnacle PCTV 282e",
  3479. { &dib0700_usb_id_table[58], &dib0700_usb_id_table[66], NULL },
  3480. { NULL },
  3481. },
  3482. },
  3483. .rc.core = {
  3484. .rc_interval = DEFAULT_RC_INTERVAL,
  3485. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3486. .module_name = "dib0700",
  3487. .rc_query = dib0700_rc_query_old_firmware,
  3488. .allowed_protos = RC_BIT_RC5 |
  3489. RC_BIT_RC6_MCE |
  3490. RC_BIT_NEC,
  3491. .change_protocol = dib0700_change_protocol,
  3492. },
  3493. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3494. .num_adapters = 2,
  3495. .adapter = {
  3496. {
  3497. DIB0700_NUM_FRONTENDS(1),
  3498. .fe = {{
  3499. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3500. .pid_filter_count = 32,
  3501. .pid_filter = stk70x0p_pid_filter,
  3502. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3503. .frontend_attach = novatd_frontend_attach,
  3504. .tuner_attach = dib7070p_tuner_attach,
  3505. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3506. }},
  3507. }, {
  3508. DIB0700_NUM_FRONTENDS(1),
  3509. .fe = {{
  3510. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3511. .pid_filter_count = 32,
  3512. .pid_filter = stk70x0p_pid_filter,
  3513. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3514. .frontend_attach = novatd_frontend_attach,
  3515. .tuner_attach = dib7070p_tuner_attach,
  3516. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3517. }},
  3518. }
  3519. },
  3520. .num_device_descs = 3,
  3521. .devices = {
  3522. { "Hauppauge Nova-TD Stick (52009)",
  3523. { &dib0700_usb_id_table[35], NULL },
  3524. { NULL },
  3525. },
  3526. { "PCTV 2002e",
  3527. { &dib0700_usb_id_table[81], NULL },
  3528. { NULL },
  3529. },
  3530. { "PCTV 2002e SE",
  3531. { &dib0700_usb_id_table[82], NULL },
  3532. { NULL },
  3533. },
  3534. },
  3535. .rc.core = {
  3536. .rc_interval = DEFAULT_RC_INTERVAL,
  3537. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3538. .module_name = "dib0700",
  3539. .rc_query = dib0700_rc_query_old_firmware,
  3540. .allowed_protos = RC_BIT_RC5 |
  3541. RC_BIT_RC6_MCE |
  3542. RC_BIT_NEC,
  3543. .change_protocol = dib0700_change_protocol,
  3544. },
  3545. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3546. .num_adapters = 2,
  3547. .adapter = {
  3548. {
  3549. DIB0700_NUM_FRONTENDS(1),
  3550. .fe = {{
  3551. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3552. .pid_filter_count = 32,
  3553. .pid_filter = stk70x0p_pid_filter,
  3554. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3555. .frontend_attach = stk7070pd_frontend_attach0,
  3556. .tuner_attach = dib7070p_tuner_attach,
  3557. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3558. }},
  3559. }, {
  3560. DIB0700_NUM_FRONTENDS(1),
  3561. .fe = {{
  3562. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3563. .pid_filter_count = 32,
  3564. .pid_filter = stk70x0p_pid_filter,
  3565. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3566. .frontend_attach = stk7070pd_frontend_attach1,
  3567. .tuner_attach = dib7070p_tuner_attach,
  3568. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3569. }},
  3570. }
  3571. },
  3572. .num_device_descs = 5,
  3573. .devices = {
  3574. { "DiBcom STK7070PD reference design",
  3575. { &dib0700_usb_id_table[17], NULL },
  3576. { NULL },
  3577. },
  3578. { "Pinnacle PCTV Dual DVB-T Diversity Stick",
  3579. { &dib0700_usb_id_table[18], NULL },
  3580. { NULL },
  3581. },
  3582. { "Hauppauge Nova-TD-500 (84xxx)",
  3583. { &dib0700_usb_id_table[36], NULL },
  3584. { NULL },
  3585. },
  3586. { "Terratec Cinergy DT USB XS Diversity/ T5",
  3587. { &dib0700_usb_id_table[43],
  3588. &dib0700_usb_id_table[53], NULL},
  3589. { NULL },
  3590. },
  3591. { "Sony PlayTV",
  3592. { &dib0700_usb_id_table[44], NULL },
  3593. { NULL },
  3594. },
  3595. },
  3596. .rc.core = {
  3597. .rc_interval = DEFAULT_RC_INTERVAL,
  3598. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3599. .module_name = "dib0700",
  3600. .rc_query = dib0700_rc_query_old_firmware,
  3601. .allowed_protos = RC_BIT_RC5 |
  3602. RC_BIT_RC6_MCE |
  3603. RC_BIT_NEC,
  3604. .change_protocol = dib0700_change_protocol,
  3605. },
  3606. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3607. .num_adapters = 2,
  3608. .adapter = {
  3609. {
  3610. DIB0700_NUM_FRONTENDS(1),
  3611. .fe = {{
  3612. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3613. .pid_filter_count = 32,
  3614. .pid_filter = stk70x0p_pid_filter,
  3615. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3616. .frontend_attach = stk7070pd_frontend_attach0,
  3617. .tuner_attach = dib7070p_tuner_attach,
  3618. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3619. }},
  3620. }, {
  3621. DIB0700_NUM_FRONTENDS(1),
  3622. .fe = {{
  3623. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3624. .pid_filter_count = 32,
  3625. .pid_filter = stk70x0p_pid_filter,
  3626. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3627. .frontend_attach = stk7070pd_frontend_attach1,
  3628. .tuner_attach = dib7070p_tuner_attach,
  3629. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3630. }},
  3631. }
  3632. },
  3633. .num_device_descs = 1,
  3634. .devices = {
  3635. { "Elgato EyeTV Diversity",
  3636. { &dib0700_usb_id_table[68], NULL },
  3637. { NULL },
  3638. },
  3639. },
  3640. .rc.core = {
  3641. .rc_interval = DEFAULT_RC_INTERVAL,
  3642. .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
  3643. .module_name = "dib0700",
  3644. .rc_query = dib0700_rc_query_old_firmware,
  3645. .allowed_protos = RC_BIT_RC5 |
  3646. RC_BIT_RC6_MCE |
  3647. RC_BIT_NEC,
  3648. .change_protocol = dib0700_change_protocol,
  3649. },
  3650. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3651. .num_adapters = 1,
  3652. .adapter = {
  3653. {
  3654. DIB0700_NUM_FRONTENDS(1),
  3655. .fe = {{
  3656. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3657. .pid_filter_count = 32,
  3658. .pid_filter = stk70x0p_pid_filter,
  3659. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3660. .frontend_attach = stk7700ph_frontend_attach,
  3661. .tuner_attach = stk7700ph_tuner_attach,
  3662. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3663. }},
  3664. },
  3665. },
  3666. .num_device_descs = 9,
  3667. .devices = {
  3668. { "Terratec Cinergy HT USB XE",
  3669. { &dib0700_usb_id_table[27], NULL },
  3670. { NULL },
  3671. },
  3672. { "Pinnacle Expresscard 320cx",
  3673. { &dib0700_usb_id_table[28], NULL },
  3674. { NULL },
  3675. },
  3676. { "Terratec Cinergy HT Express",
  3677. { &dib0700_usb_id_table[32], NULL },
  3678. { NULL },
  3679. },
  3680. { "Gigabyte U8000-RH",
  3681. { &dib0700_usb_id_table[37], NULL },
  3682. { NULL },
  3683. },
  3684. { "YUAN High-Tech STK7700PH",
  3685. { &dib0700_usb_id_table[38], NULL },
  3686. { NULL },
  3687. },
  3688. { "Asus My Cinema-U3000Hybrid",
  3689. { &dib0700_usb_id_table[39], NULL },
  3690. { NULL },
  3691. },
  3692. { "YUAN High-Tech MC770",
  3693. { &dib0700_usb_id_table[48], NULL },
  3694. { NULL },
  3695. },
  3696. { "Leadtek WinFast DTV Dongle H",
  3697. { &dib0700_usb_id_table[51], NULL },
  3698. { NULL },
  3699. },
  3700. { "YUAN High-Tech STK7700D",
  3701. { &dib0700_usb_id_table[54], NULL },
  3702. { NULL },
  3703. },
  3704. },
  3705. .rc.core = {
  3706. .rc_interval = DEFAULT_RC_INTERVAL,
  3707. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3708. .module_name = "dib0700",
  3709. .rc_query = dib0700_rc_query_old_firmware,
  3710. .allowed_protos = RC_BIT_RC5 |
  3711. RC_BIT_RC6_MCE |
  3712. RC_BIT_NEC,
  3713. .change_protocol = dib0700_change_protocol,
  3714. },
  3715. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3716. .num_adapters = 1,
  3717. .adapter = {
  3718. {
  3719. DIB0700_NUM_FRONTENDS(1),
  3720. .fe = {{
  3721. .frontend_attach = s5h1411_frontend_attach,
  3722. .tuner_attach = xc5000_tuner_attach,
  3723. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3724. }},
  3725. },
  3726. },
  3727. .num_device_descs = 2,
  3728. .devices = {
  3729. { "Pinnacle PCTV HD Pro USB Stick",
  3730. { &dib0700_usb_id_table[40], NULL },
  3731. { NULL },
  3732. },
  3733. { "Pinnacle PCTV HD USB Stick",
  3734. { &dib0700_usb_id_table[41], NULL },
  3735. { NULL },
  3736. },
  3737. },
  3738. .rc.core = {
  3739. .rc_interval = DEFAULT_RC_INTERVAL,
  3740. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3741. .module_name = "dib0700",
  3742. .rc_query = dib0700_rc_query_old_firmware,
  3743. .allowed_protos = RC_BIT_RC5 |
  3744. RC_BIT_RC6_MCE |
  3745. RC_BIT_NEC,
  3746. .change_protocol = dib0700_change_protocol,
  3747. },
  3748. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3749. .num_adapters = 1,
  3750. .adapter = {
  3751. {
  3752. DIB0700_NUM_FRONTENDS(1),
  3753. .fe = {{
  3754. .frontend_attach = lgdt3305_frontend_attach,
  3755. .tuner_attach = mxl5007t_tuner_attach,
  3756. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3757. }},
  3758. },
  3759. },
  3760. .num_device_descs = 2,
  3761. .devices = {
  3762. { "Hauppauge ATSC MiniCard (B200)",
  3763. { &dib0700_usb_id_table[46], NULL },
  3764. { NULL },
  3765. },
  3766. { "Hauppauge ATSC MiniCard (B210)",
  3767. { &dib0700_usb_id_table[47], NULL },
  3768. { NULL },
  3769. },
  3770. },
  3771. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3772. .num_adapters = 1,
  3773. .adapter = {
  3774. {
  3775. DIB0700_NUM_FRONTENDS(1),
  3776. .fe = {{
  3777. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3778. .pid_filter_count = 32,
  3779. .pid_filter = stk70x0p_pid_filter,
  3780. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3781. .frontend_attach = stk7770p_frontend_attach,
  3782. .tuner_attach = dib7770p_tuner_attach,
  3783. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3784. }},
  3785. },
  3786. },
  3787. .num_device_descs = 4,
  3788. .devices = {
  3789. { "DiBcom STK7770P reference design",
  3790. { &dib0700_usb_id_table[59], NULL },
  3791. { NULL },
  3792. },
  3793. { "Terratec Cinergy T USB XXS (HD)/ T3",
  3794. { &dib0700_usb_id_table[33],
  3795. &dib0700_usb_id_table[52],
  3796. &dib0700_usb_id_table[60], NULL},
  3797. { NULL },
  3798. },
  3799. { "TechniSat AirStar TeleStick 2",
  3800. { &dib0700_usb_id_table[74], NULL },
  3801. { NULL },
  3802. },
  3803. { "Medion CTX1921 DVB-T USB",
  3804. { &dib0700_usb_id_table[75], NULL },
  3805. { NULL },
  3806. },
  3807. },
  3808. .rc.core = {
  3809. .rc_interval = DEFAULT_RC_INTERVAL,
  3810. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3811. .module_name = "dib0700",
  3812. .rc_query = dib0700_rc_query_old_firmware,
  3813. .allowed_protos = RC_BIT_RC5 |
  3814. RC_BIT_RC6_MCE |
  3815. RC_BIT_NEC,
  3816. .change_protocol = dib0700_change_protocol,
  3817. },
  3818. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3819. .num_adapters = 1,
  3820. .adapter = {
  3821. {
  3822. DIB0700_NUM_FRONTENDS(1),
  3823. .fe = {{
  3824. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3825. .pid_filter_count = 32,
  3826. .pid_filter = stk80xx_pid_filter,
  3827. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  3828. .frontend_attach = stk807x_frontend_attach,
  3829. .tuner_attach = dib807x_tuner_attach,
  3830. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3831. }},
  3832. },
  3833. },
  3834. .num_device_descs = 3,
  3835. .devices = {
  3836. { "DiBcom STK807xP reference design",
  3837. { &dib0700_usb_id_table[62], NULL },
  3838. { NULL },
  3839. },
  3840. { "Prolink Pixelview SBTVD",
  3841. { &dib0700_usb_id_table[63], NULL },
  3842. { NULL },
  3843. },
  3844. { "EvolutePC TVWay+",
  3845. { &dib0700_usb_id_table[64], NULL },
  3846. { NULL },
  3847. },
  3848. },
  3849. .rc.core = {
  3850. .rc_interval = DEFAULT_RC_INTERVAL,
  3851. .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
  3852. .module_name = "dib0700",
  3853. .rc_query = dib0700_rc_query_old_firmware,
  3854. .allowed_protos = RC_BIT_RC5 |
  3855. RC_BIT_RC6_MCE |
  3856. RC_BIT_NEC,
  3857. .change_protocol = dib0700_change_protocol,
  3858. },
  3859. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3860. .num_adapters = 2,
  3861. .adapter = {
  3862. {
  3863. DIB0700_NUM_FRONTENDS(1),
  3864. .fe = {{
  3865. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3866. .pid_filter_count = 32,
  3867. .pid_filter = stk80xx_pid_filter,
  3868. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  3869. .frontend_attach = stk807xpvr_frontend_attach0,
  3870. .tuner_attach = dib807x_tuner_attach,
  3871. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3872. }},
  3873. },
  3874. {
  3875. DIB0700_NUM_FRONTENDS(1),
  3876. .fe = {{
  3877. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3878. .pid_filter_count = 32,
  3879. .pid_filter = stk80xx_pid_filter,
  3880. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  3881. .frontend_attach = stk807xpvr_frontend_attach1,
  3882. .tuner_attach = dib807x_tuner_attach,
  3883. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3884. }},
  3885. },
  3886. },
  3887. .num_device_descs = 1,
  3888. .devices = {
  3889. { "DiBcom STK807xPVR reference design",
  3890. { &dib0700_usb_id_table[61], NULL },
  3891. { NULL },
  3892. },
  3893. },
  3894. .rc.core = {
  3895. .rc_interval = DEFAULT_RC_INTERVAL,
  3896. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3897. .module_name = "dib0700",
  3898. .rc_query = dib0700_rc_query_old_firmware,
  3899. .allowed_protos = RC_BIT_RC5 |
  3900. RC_BIT_RC6_MCE |
  3901. RC_BIT_NEC,
  3902. .change_protocol = dib0700_change_protocol,
  3903. },
  3904. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3905. .num_adapters = 1,
  3906. .adapter = {
  3907. {
  3908. DIB0700_NUM_FRONTENDS(1),
  3909. .fe = {{
  3910. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  3911. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3912. .pid_filter_count = 32,
  3913. .pid_filter = stk80xx_pid_filter,
  3914. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  3915. .frontend_attach = stk809x_frontend_attach,
  3916. .tuner_attach = dib809x_tuner_attach,
  3917. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3918. }},
  3919. },
  3920. },
  3921. .num_device_descs = 1,
  3922. .devices = {
  3923. { "DiBcom STK8096GP reference design",
  3924. { &dib0700_usb_id_table[67], NULL },
  3925. { NULL },
  3926. },
  3927. },
  3928. .rc.core = {
  3929. .rc_interval = DEFAULT_RC_INTERVAL,
  3930. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3931. .module_name = "dib0700",
  3932. .rc_query = dib0700_rc_query_old_firmware,
  3933. .allowed_protos = RC_BIT_RC5 |
  3934. RC_BIT_RC6_MCE |
  3935. RC_BIT_NEC,
  3936. .change_protocol = dib0700_change_protocol,
  3937. },
  3938. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3939. .num_adapters = 1,
  3940. .adapter = {
  3941. {
  3942. DIB0700_NUM_FRONTENDS(1),
  3943. .fe = {{
  3944. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  3945. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3946. .pid_filter_count = 32,
  3947. .pid_filter = dib90x0_pid_filter,
  3948. .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
  3949. .frontend_attach = stk9090m_frontend_attach,
  3950. .tuner_attach = dib9090_tuner_attach,
  3951. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3952. }},
  3953. },
  3954. },
  3955. .num_device_descs = 1,
  3956. .devices = {
  3957. { "DiBcom STK9090M reference design",
  3958. { &dib0700_usb_id_table[69], NULL },
  3959. { NULL },
  3960. },
  3961. },
  3962. .rc.core = {
  3963. .rc_interval = DEFAULT_RC_INTERVAL,
  3964. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3965. .module_name = "dib0700",
  3966. .rc_query = dib0700_rc_query_old_firmware,
  3967. .allowed_protos = RC_BIT_RC5 |
  3968. RC_BIT_RC6_MCE |
  3969. RC_BIT_NEC,
  3970. .change_protocol = dib0700_change_protocol,
  3971. },
  3972. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3973. .num_adapters = 1,
  3974. .adapter = {
  3975. {
  3976. DIB0700_NUM_FRONTENDS(1),
  3977. .fe = {{
  3978. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  3979. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3980. .pid_filter_count = 32,
  3981. .pid_filter = stk80xx_pid_filter,
  3982. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  3983. .frontend_attach = nim8096md_frontend_attach,
  3984. .tuner_attach = nim8096md_tuner_attach,
  3985. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3986. }},
  3987. },
  3988. },
  3989. .num_device_descs = 1,
  3990. .devices = {
  3991. { "DiBcom NIM8096MD reference design",
  3992. { &dib0700_usb_id_table[70], NULL },
  3993. { NULL },
  3994. },
  3995. },
  3996. .rc.core = {
  3997. .rc_interval = DEFAULT_RC_INTERVAL,
  3998. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3999. .module_name = "dib0700",
  4000. .rc_query = dib0700_rc_query_old_firmware,
  4001. .allowed_protos = RC_BIT_RC5 |
  4002. RC_BIT_RC6_MCE |
  4003. RC_BIT_NEC,
  4004. .change_protocol = dib0700_change_protocol,
  4005. },
  4006. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4007. .num_adapters = 1,
  4008. .adapter = {
  4009. {
  4010. DIB0700_NUM_FRONTENDS(1),
  4011. .fe = {{
  4012. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4013. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4014. .pid_filter_count = 32,
  4015. .pid_filter = dib90x0_pid_filter,
  4016. .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
  4017. .frontend_attach = nim9090md_frontend_attach,
  4018. .tuner_attach = nim9090md_tuner_attach,
  4019. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4020. }},
  4021. },
  4022. },
  4023. .num_device_descs = 1,
  4024. .devices = {
  4025. { "DiBcom NIM9090MD reference design",
  4026. { &dib0700_usb_id_table[71], NULL },
  4027. { NULL },
  4028. },
  4029. },
  4030. .rc.core = {
  4031. .rc_interval = DEFAULT_RC_INTERVAL,
  4032. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4033. .module_name = "dib0700",
  4034. .rc_query = dib0700_rc_query_old_firmware,
  4035. .allowed_protos = RC_BIT_RC5 |
  4036. RC_BIT_RC6_MCE |
  4037. RC_BIT_NEC,
  4038. .change_protocol = dib0700_change_protocol,
  4039. },
  4040. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4041. .num_adapters = 1,
  4042. .adapter = {
  4043. {
  4044. DIB0700_NUM_FRONTENDS(1),
  4045. .fe = {{
  4046. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4047. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4048. .pid_filter_count = 32,
  4049. .pid_filter = stk70x0p_pid_filter,
  4050. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  4051. .frontend_attach = nim7090_frontend_attach,
  4052. .tuner_attach = nim7090_tuner_attach,
  4053. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4054. }},
  4055. },
  4056. },
  4057. .num_device_descs = 1,
  4058. .devices = {
  4059. { "DiBcom NIM7090 reference design",
  4060. { &dib0700_usb_id_table[72], NULL },
  4061. { NULL },
  4062. },
  4063. },
  4064. .rc.core = {
  4065. .rc_interval = DEFAULT_RC_INTERVAL,
  4066. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4067. .module_name = "dib0700",
  4068. .rc_query = dib0700_rc_query_old_firmware,
  4069. .allowed_protos = RC_BIT_RC5 |
  4070. RC_BIT_RC6_MCE |
  4071. RC_BIT_NEC,
  4072. .change_protocol = dib0700_change_protocol,
  4073. },
  4074. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4075. .num_adapters = 2,
  4076. .adapter = {
  4077. {
  4078. DIB0700_NUM_FRONTENDS(1),
  4079. .fe = {{
  4080. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4081. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4082. .pid_filter_count = 32,
  4083. .pid_filter = stk70x0p_pid_filter,
  4084. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  4085. .frontend_attach = tfe7090pvr_frontend0_attach,
  4086. .tuner_attach = tfe7090pvr_tuner0_attach,
  4087. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  4088. }},
  4089. },
  4090. {
  4091. DIB0700_NUM_FRONTENDS(1),
  4092. .fe = {{
  4093. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4094. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4095. .pid_filter_count = 32,
  4096. .pid_filter = stk70x0p_pid_filter,
  4097. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  4098. .frontend_attach = tfe7090pvr_frontend1_attach,
  4099. .tuner_attach = tfe7090pvr_tuner1_attach,
  4100. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4101. }},
  4102. },
  4103. },
  4104. .num_device_descs = 1,
  4105. .devices = {
  4106. { "DiBcom TFE7090PVR reference design",
  4107. { &dib0700_usb_id_table[73], NULL },
  4108. { NULL },
  4109. },
  4110. },
  4111. .rc.core = {
  4112. .rc_interval = DEFAULT_RC_INTERVAL,
  4113. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4114. .module_name = "dib0700",
  4115. .rc_query = dib0700_rc_query_old_firmware,
  4116. .allowed_protos = RC_BIT_RC5 |
  4117. RC_BIT_RC6_MCE |
  4118. RC_BIT_NEC,
  4119. .change_protocol = dib0700_change_protocol,
  4120. },
  4121. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4122. .num_adapters = 1,
  4123. .adapter = {
  4124. {
  4125. DIB0700_NUM_FRONTENDS(1),
  4126. .fe = {{
  4127. .frontend_attach = pctv340e_frontend_attach,
  4128. .tuner_attach = xc4000_tuner_attach,
  4129. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4130. }},
  4131. },
  4132. },
  4133. .num_device_descs = 2,
  4134. .devices = {
  4135. { "Pinnacle PCTV 340e HD Pro USB Stick",
  4136. { &dib0700_usb_id_table[76], NULL },
  4137. { NULL },
  4138. },
  4139. { "Pinnacle PCTV Hybrid Stick Solo",
  4140. { &dib0700_usb_id_table[77], NULL },
  4141. { NULL },
  4142. },
  4143. },
  4144. .rc.core = {
  4145. .rc_interval = DEFAULT_RC_INTERVAL,
  4146. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4147. .module_name = "dib0700",
  4148. .rc_query = dib0700_rc_query_old_firmware,
  4149. .allowed_protos = RC_BIT_RC5 |
  4150. RC_BIT_RC6_MCE |
  4151. RC_BIT_NEC,
  4152. .change_protocol = dib0700_change_protocol,
  4153. },
  4154. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4155. .num_adapters = 1,
  4156. .adapter = {
  4157. {
  4158. DIB0700_NUM_FRONTENDS(1),
  4159. .fe = {{
  4160. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4161. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4162. .pid_filter_count = 32,
  4163. .pid_filter = stk70x0p_pid_filter,
  4164. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  4165. .frontend_attach = tfe7790p_frontend_attach,
  4166. .tuner_attach = tfe7790p_tuner_attach,
  4167. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  4168. } },
  4169. },
  4170. },
  4171. .num_device_descs = 1,
  4172. .devices = {
  4173. { "DiBcom TFE7790P reference design",
  4174. { &dib0700_usb_id_table[78], NULL },
  4175. { NULL },
  4176. },
  4177. },
  4178. .rc.core = {
  4179. .rc_interval = DEFAULT_RC_INTERVAL,
  4180. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4181. .module_name = "dib0700",
  4182. .rc_query = dib0700_rc_query_old_firmware,
  4183. .allowed_protos = RC_BIT_RC5 |
  4184. RC_BIT_RC6_MCE |
  4185. RC_BIT_NEC,
  4186. .change_protocol = dib0700_change_protocol,
  4187. },
  4188. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4189. .num_adapters = 1,
  4190. .adapter = {
  4191. {
  4192. DIB0700_NUM_FRONTENDS(1),
  4193. .fe = {{
  4194. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4195. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4196. .pid_filter_count = 32,
  4197. .pid_filter = stk80xx_pid_filter,
  4198. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  4199. .frontend_attach = tfe8096p_frontend_attach,
  4200. .tuner_attach = tfe8096p_tuner_attach,
  4201. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4202. } },
  4203. },
  4204. },
  4205. .num_device_descs = 1,
  4206. .devices = {
  4207. { "DiBcom TFE8096P reference design",
  4208. { &dib0700_usb_id_table[79], NULL },
  4209. { NULL },
  4210. },
  4211. },
  4212. .rc.core = {
  4213. .rc_interval = DEFAULT_RC_INTERVAL,
  4214. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4215. .module_name = "dib0700",
  4216. .rc_query = dib0700_rc_query_old_firmware,
  4217. .allowed_protos = RC_BIT_RC5 |
  4218. RC_BIT_RC6_MCE |
  4219. RC_BIT_NEC,
  4220. .change_protocol = dib0700_change_protocol,
  4221. },
  4222. },
  4223. };
  4224. int dib0700_device_count = ARRAY_SIZE(dib0700_devices);