dib0700_devices.c 137 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040
  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), if applicable for the device (default: 0=automatic/off).");
  28. struct dib0700_adapter_state {
  29. int (*set_param_save) (struct dvb_frontend *);
  30. const struct firmware *frontend_firmware;
  31. struct dib7000p_ops dib7000p_ops;
  32. struct dib8000_ops dib8000_ops;
  33. };
  34. /* Hauppauge Nova-T 500 (aka Bristol)
  35. * has a LNA on GPIO0 which is enabled by setting 1 */
  36. static struct mt2060_config bristol_mt2060_config[2] = {
  37. {
  38. .i2c_address = 0x60,
  39. .clock_out = 3,
  40. }, {
  41. .i2c_address = 0x61,
  42. }
  43. };
  44. static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
  45. .band_caps = BAND_VHF | BAND_UHF,
  46. .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
  47. .agc1_max = 42598,
  48. .agc1_min = 17694,
  49. .agc2_max = 45875,
  50. .agc2_min = 0,
  51. .agc1_pt1 = 0,
  52. .agc1_pt2 = 59,
  53. .agc1_slope1 = 0,
  54. .agc1_slope2 = 69,
  55. .agc2_pt1 = 0,
  56. .agc2_pt2 = 59,
  57. .agc2_slope1 = 111,
  58. .agc2_slope2 = 28,
  59. };
  60. static struct dib3000mc_config bristol_dib3000mc_config[2] = {
  61. { .agc = &bristol_dib3000p_mt2060_agc_config,
  62. .max_time = 0x196,
  63. .ln_adc_level = 0x1cc7,
  64. .output_mpeg2_in_188_bytes = 1,
  65. },
  66. { .agc = &bristol_dib3000p_mt2060_agc_config,
  67. .max_time = 0x196,
  68. .ln_adc_level = 0x1cc7,
  69. .output_mpeg2_in_188_bytes = 1,
  70. }
  71. };
  72. static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
  73. {
  74. struct dib0700_state *st = adap->dev->priv;
  75. if (adap->id == 0) {
  76. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
  77. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
  78. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
  79. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
  80. if (force_lna_activation)
  81. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  82. else
  83. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
  84. if (dib3000mc_i2c_enumeration(&adap->dev->i2c_adap, 2, DEFAULT_DIB3000P_I2C_ADDRESS, bristol_dib3000mc_config) != 0) {
  85. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
  86. return -ENODEV;
  87. }
  88. }
  89. st->mt2060_if1[adap->id] = 1220;
  90. return (adap->fe_adap[0].fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap,
  91. (10 + adap->id) << 1, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0;
  92. }
  93. static int eeprom_read(struct i2c_adapter *adap,u8 adrs,u8 *pval)
  94. {
  95. struct i2c_msg msg[2] = {
  96. { .addr = 0x50, .flags = 0, .buf = &adrs, .len = 1 },
  97. { .addr = 0x50, .flags = I2C_M_RD, .buf = pval, .len = 1 },
  98. };
  99. if (i2c_transfer(adap, msg, 2) != 2) return -EREMOTEIO;
  100. return 0;
  101. }
  102. static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
  103. {
  104. struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;
  105. struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe_adap[0].fe, 1);
  106. s8 a;
  107. int if1=1220;
  108. if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
  109. adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_500_2)) {
  110. if (!eeprom_read(prim_i2c,0x59 + adap->id,&a)) if1=1220+a;
  111. }
  112. return dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c,
  113. &bristol_mt2060_config[adap->id], if1) == NULL ?
  114. -ENODEV : 0;
  115. }
  116. /* STK7700D: Pinnacle/Terratec/Hauppauge Dual DVB-T Diversity */
  117. /* MT226x */
  118. static struct dibx000_agc_config stk7700d_7000p_mt2266_agc_config[2] = {
  119. {
  120. BAND_UHF,
  121. /* 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,
  122. * 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 */
  123. (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
  124. | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
  125. 1130,
  126. 21,
  127. 0,
  128. 118,
  129. 0,
  130. 3530,
  131. 1,
  132. 0,
  133. 65535,
  134. 33770,
  135. 65535,
  136. 23592,
  137. 0,
  138. 62,
  139. 255,
  140. 64,
  141. 64,
  142. 132,
  143. 192,
  144. 80,
  145. 80,
  146. 17,
  147. 27,
  148. 23,
  149. 51,
  150. 1,
  151. }, {
  152. BAND_VHF | BAND_LBAND,
  153. /* 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,
  154. * 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 */
  155. (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
  156. | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
  157. 2372,
  158. 21,
  159. 0,
  160. 118,
  161. 0,
  162. 3530,
  163. 1,
  164. 0,
  165. 65535,
  166. 0,
  167. 65535,
  168. 23592,
  169. 0,
  170. 128,
  171. 128,
  172. 128,
  173. 0,
  174. 128,
  175. 253,
  176. 81,
  177. 0,
  178. 17,
  179. 27,
  180. 23,
  181. 51,
  182. 1,
  183. }
  184. };
  185. static struct dibx000_bandwidth_config stk7700d_mt2266_pll_config = {
  186. .internal = 60000,
  187. .sampling = 30000,
  188. .pll_prediv = 1,
  189. .pll_ratio = 8,
  190. .pll_range = 3,
  191. .pll_reset = 1,
  192. .pll_bypass = 0,
  193. .enable_refdiv = 0,
  194. .bypclk_div = 0,
  195. .IO_CLK_en_core = 1,
  196. .ADClkSrc = 1,
  197. .modulo = 2,
  198. .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
  199. .ifreq = 0,
  200. .timf = 20452225,
  201. };
  202. static struct dib7000p_config stk7700d_dib7000p_mt2266_config[] = {
  203. { .output_mpeg2_in_188_bytes = 1,
  204. .hostbus_diversity = 1,
  205. .tuner_is_baseband = 1,
  206. .agc_config_count = 2,
  207. .agc = stk7700d_7000p_mt2266_agc_config,
  208. .bw = &stk7700d_mt2266_pll_config,
  209. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  210. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  211. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  212. },
  213. { .output_mpeg2_in_188_bytes = 1,
  214. .hostbus_diversity = 1,
  215. .tuner_is_baseband = 1,
  216. .agc_config_count = 2,
  217. .agc = stk7700d_7000p_mt2266_agc_config,
  218. .bw = &stk7700d_mt2266_pll_config,
  219. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  220. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  221. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  222. }
  223. };
  224. static struct mt2266_config stk7700d_mt2266_config[2] = {
  225. { .i2c_address = 0x60
  226. },
  227. { .i2c_address = 0x60
  228. }
  229. };
  230. static int stk7700P2_frontend_attach(struct dvb_usb_adapter *adap)
  231. {
  232. struct dib0700_adapter_state *state = adap->priv;
  233. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  234. return -ENODEV;
  235. if (adap->id == 0) {
  236. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  237. msleep(10);
  238. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  239. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  240. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  241. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  242. msleep(10);
  243. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  244. msleep(10);
  245. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
  246. stk7700d_dib7000p_mt2266_config)
  247. != 0) {
  248. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
  249. dvb_detach(&state->dib7000p_ops);
  250. return -ENODEV;
  251. }
  252. }
  253. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
  254. 0x80 + (adap->id << 1),
  255. &stk7700d_dib7000p_mt2266_config[adap->id]);
  256. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  257. }
  258. static int stk7700d_frontend_attach(struct dvb_usb_adapter *adap)
  259. {
  260. struct dib0700_adapter_state *state = adap->priv;
  261. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  262. return -ENODEV;
  263. if (adap->id == 0) {
  264. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  265. msleep(10);
  266. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  267. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  268. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  269. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  270. msleep(10);
  271. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  272. msleep(10);
  273. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  274. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
  275. stk7700d_dib7000p_mt2266_config)
  276. != 0) {
  277. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
  278. dvb_detach(&state->dib7000p_ops);
  279. return -ENODEV;
  280. }
  281. }
  282. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
  283. 0x80 + (adap->id << 1),
  284. &stk7700d_dib7000p_mt2266_config[adap->id]);
  285. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  286. }
  287. static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap)
  288. {
  289. struct i2c_adapter *tun_i2c;
  290. struct dib0700_adapter_state *state = adap->priv;
  291. tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
  292. DIBX000_I2C_INTERFACE_TUNER, 1);
  293. return dvb_attach(mt2266_attach, adap->fe_adap[0].fe, tun_i2c,
  294. &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;
  295. }
  296. /* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */
  297. static struct dibx000_agc_config xc3028_agc_config = {
  298. .band_caps = BAND_VHF | BAND_UHF,
  299. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
  300. * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
  301. * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
  302. .setup = (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
  303. .inv_gain = 712,
  304. .time_stabiliz = 21,
  305. .alpha_level = 0,
  306. .thlock = 118,
  307. .wbd_inv = 0,
  308. .wbd_ref = 2867,
  309. .wbd_sel = 0,
  310. .wbd_alpha = 2,
  311. .agc1_max = 0,
  312. .agc1_min = 0,
  313. .agc2_max = 39718,
  314. .agc2_min = 9930,
  315. .agc1_pt1 = 0,
  316. .agc1_pt2 = 0,
  317. .agc1_pt3 = 0,
  318. .agc1_slope1 = 0,
  319. .agc1_slope2 = 0,
  320. .agc2_pt1 = 0,
  321. .agc2_pt2 = 128,
  322. .agc2_slope1 = 29,
  323. .agc2_slope2 = 29,
  324. .alpha_mant = 17,
  325. .alpha_exp = 27,
  326. .beta_mant = 23,
  327. .beta_exp = 51,
  328. .perform_agc_softsplit = 1,
  329. };
  330. /* PLL Configuration for COFDM BW_MHz = 8.00 with external clock = 30.00 */
  331. static struct dibx000_bandwidth_config xc3028_bw_config = {
  332. .internal = 60000,
  333. .sampling = 30000,
  334. .pll_prediv = 1,
  335. .pll_ratio = 8,
  336. .pll_range = 3,
  337. .pll_reset = 1,
  338. .pll_bypass = 0,
  339. .enable_refdiv = 0,
  340. .bypclk_div = 0,
  341. .IO_CLK_en_core = 1,
  342. .ADClkSrc = 1,
  343. .modulo = 0,
  344. .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
  345. .ifreq = (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
  346. .timf = 20452225,
  347. .xtal_hz = 30000000,
  348. };
  349. static struct dib7000p_config stk7700ph_dib7700_xc3028_config = {
  350. .output_mpeg2_in_188_bytes = 1,
  351. .tuner_is_baseband = 1,
  352. .agc_config_count = 1,
  353. .agc = &xc3028_agc_config,
  354. .bw = &xc3028_bw_config,
  355. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  356. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  357. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  358. };
  359. static int stk7700ph_xc3028_callback(void *ptr, int component,
  360. int command, int arg)
  361. {
  362. struct dvb_usb_adapter *adap = ptr;
  363. struct dib0700_adapter_state *state = adap->priv;
  364. switch (command) {
  365. case XC2028_TUNER_RESET:
  366. /* Send the tuner in then out of reset */
  367. state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
  368. msleep(10);
  369. state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  370. break;
  371. case XC2028_RESET_CLK:
  372. break;
  373. default:
  374. err("%s: unknown command %d, arg %d\n", __func__,
  375. command, arg);
  376. return -EINVAL;
  377. }
  378. return 0;
  379. }
  380. static struct xc2028_ctrl stk7700ph_xc3028_ctrl = {
  381. .fname = XC2028_DEFAULT_FIRMWARE,
  382. .max_len = 64,
  383. .demod = XC3028_FE_DIBCOM52,
  384. };
  385. static struct xc2028_config stk7700ph_xc3028_config = {
  386. .i2c_addr = 0x61,
  387. .ctrl = &stk7700ph_xc3028_ctrl,
  388. };
  389. static int stk7700ph_frontend_attach(struct dvb_usb_adapter *adap)
  390. {
  391. struct usb_device_descriptor *desc = &adap->dev->udev->descriptor;
  392. struct dib0700_adapter_state *state = adap->priv;
  393. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  394. return -ENODEV;
  395. if (desc->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
  396. desc->idProduct == cpu_to_le16(USB_PID_PINNACLE_EXPRESSCARD_320CX))
  397. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  398. else
  399. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  400. msleep(20);
  401. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  402. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  403. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  404. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  405. msleep(10);
  406. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  407. msleep(20);
  408. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  409. msleep(10);
  410. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
  411. &stk7700ph_dib7700_xc3028_config) != 0) {
  412. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
  413. __func__);
  414. dvb_detach(&state->dib7000p_ops);
  415. return -ENODEV;
  416. }
  417. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
  418. &stk7700ph_dib7700_xc3028_config);
  419. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  420. }
  421. static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
  422. {
  423. struct i2c_adapter *tun_i2c;
  424. struct dib0700_adapter_state *state = adap->priv;
  425. tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
  426. DIBX000_I2C_INTERFACE_TUNER, 1);
  427. stk7700ph_xc3028_config.i2c_adap = tun_i2c;
  428. /* FIXME: generalize & move to common area */
  429. adap->fe_adap[0].fe->callback = stk7700ph_xc3028_callback;
  430. return dvb_attach(xc2028_attach, adap->fe_adap[0].fe, &stk7700ph_xc3028_config)
  431. == NULL ? -ENODEV : 0;
  432. }
  433. #define DEFAULT_RC_INTERVAL 50
  434. /*
  435. * This function is used only when firmware is < 1.20 version. Newer
  436. * firmwares use bulk mode, with functions implemented at dib0700_core,
  437. * at dib0700_rc_urb_completion()
  438. */
  439. static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
  440. {
  441. enum rc_type protocol;
  442. u32 scancode;
  443. u8 toggle;
  444. int i;
  445. struct dib0700_state *st = d->priv;
  446. if (st->fw_version >= 0x10200) {
  447. /* For 1.20 firmware , We need to keep the RC polling
  448. callback so we can reuse the input device setup in
  449. dvb-usb-remote.c. However, the actual work is being done
  450. in the bulk URB completion handler. */
  451. return 0;
  452. }
  453. st->buf[0] = REQUEST_POLL_RC;
  454. st->buf[1] = 0;
  455. i = dib0700_ctrl_rd(d, st->buf, 2, st->buf, 4);
  456. if (i <= 0) {
  457. err("RC Query Failed");
  458. return -EIO;
  459. }
  460. /* losing half of KEY_0 events from Philipps rc5 remotes.. */
  461. if (st->buf[0] == 0 && st->buf[1] == 0
  462. && st->buf[2] == 0 && st->buf[3] == 0)
  463. return 0;
  464. /* info("%d: %2X %2X %2X %2X",dvb_usb_dib0700_ir_proto,(int)st->buf[3 - 2],(int)st->buf[3 - 3],(int)st->buf[3 - 1],(int)st->buf[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 ((st->buf[3 - 2] == 0x00) && (st->buf[3 - 3] == 0x00) &&
  470. (st->buf[3] == 0xff)) {
  471. rc_repeat(d->rc_dev);
  472. return 0;
  473. }
  474. protocol = RC_TYPE_NEC;
  475. scancode = RC_SCANCODE_NEC(st->buf[3 - 2], st->buf[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(st->buf[3 - 2], st->buf[3 - 3]);
  482. toggle = st->buf[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 (adap->id == 0) {
  1460. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
  1461. return -ENODEV;
  1462. } else {
  1463. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
  1464. return -ENODEV;
  1465. }
  1466. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  1467. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
  1468. return 0;
  1469. }
  1470. static int stk809x_frontend_attach(struct dvb_usb_adapter *adap)
  1471. {
  1472. struct dib0700_adapter_state *state = adap->priv;
  1473. if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
  1474. return -ENODEV;
  1475. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  1476. msleep(10);
  1477. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  1478. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  1479. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  1480. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  1481. dib0700_ctrl_clock(adap->dev, 72, 1);
  1482. msleep(10);
  1483. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  1484. msleep(10);
  1485. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  1486. state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 0x80, 0);
  1487. adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
  1488. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  1489. }
  1490. static int stk809x_frontend1_attach(struct dvb_usb_adapter *adap)
  1491. {
  1492. struct dib0700_adapter_state *state = adap->priv;
  1493. if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
  1494. return -ENODEV;
  1495. state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x82, 0);
  1496. adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]);
  1497. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  1498. }
  1499. static int nim8096md_tuner_attach(struct dvb_usb_adapter *adap)
  1500. {
  1501. struct dib0700_adapter_state *st = adap->priv;
  1502. struct i2c_adapter *tun_i2c;
  1503. struct dvb_frontend *fe_slave = st->dib8000_ops.get_slave_frontend(adap->fe_adap[0].fe, 1);
  1504. if (fe_slave) {
  1505. tun_i2c = st->dib8000_ops.get_i2c_master(fe_slave, DIBX000_I2C_INTERFACE_TUNER, 1);
  1506. if (dvb_attach(dib0090_register, fe_slave, tun_i2c, &dib809x_dib0090_config) == NULL)
  1507. return -ENODEV;
  1508. fe_slave->dvb = adap->fe_adap[0].fe->dvb;
  1509. fe_slave->ops.tuner_ops.set_params = dib8096_set_param_override;
  1510. }
  1511. tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
  1512. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
  1513. return -ENODEV;
  1514. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  1515. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
  1516. return 0;
  1517. }
  1518. static int nim8096md_frontend_attach(struct dvb_usb_adapter *adap)
  1519. {
  1520. struct dvb_frontend *fe_slave;
  1521. struct dib0700_adapter_state *state = adap->priv;
  1522. if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
  1523. return -ENODEV;
  1524. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  1525. msleep(20);
  1526. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  1527. msleep(1000);
  1528. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  1529. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  1530. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  1531. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  1532. dib0700_ctrl_clock(adap->dev, 72, 1);
  1533. msleep(20);
  1534. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  1535. msleep(20);
  1536. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  1537. state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18, 0x80, 0);
  1538. adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
  1539. if (adap->fe_adap[0].fe == NULL)
  1540. return -ENODEV;
  1541. /* Needed to increment refcount */
  1542. if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
  1543. return -ENODEV;
  1544. fe_slave = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]);
  1545. state->dib8000_ops.set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
  1546. return fe_slave == NULL ? -ENODEV : 0;
  1547. }
  1548. /* TFE8096P */
  1549. static struct dibx000_agc_config dib8096p_agc_config[2] = {
  1550. {
  1551. .band_caps = BAND_UHF,
  1552. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
  1553. P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
  1554. P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
  1555. P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
  1556. P_agc_write=0 */
  1557. .setup = (0 << 15) | (0 << 14) | (5 << 11)
  1558. | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
  1559. | (0 << 4) | (5 << 1) | (0 << 0),
  1560. .inv_gain = 684,
  1561. .time_stabiliz = 10,
  1562. .alpha_level = 0,
  1563. .thlock = 118,
  1564. .wbd_inv = 0,
  1565. .wbd_ref = 1200,
  1566. .wbd_sel = 3,
  1567. .wbd_alpha = 5,
  1568. .agc1_max = 65535,
  1569. .agc1_min = 0,
  1570. .agc2_max = 32767,
  1571. .agc2_min = 0,
  1572. .agc1_pt1 = 0,
  1573. .agc1_pt2 = 0,
  1574. .agc1_pt3 = 105,
  1575. .agc1_slope1 = 0,
  1576. .agc1_slope2 = 156,
  1577. .agc2_pt1 = 105,
  1578. .agc2_pt2 = 255,
  1579. .agc2_slope1 = 54,
  1580. .agc2_slope2 = 0,
  1581. .alpha_mant = 28,
  1582. .alpha_exp = 26,
  1583. .beta_mant = 31,
  1584. .beta_exp = 51,
  1585. .perform_agc_softsplit = 0,
  1586. } , {
  1587. .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
  1588. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
  1589. P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
  1590. P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
  1591. P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
  1592. P_agc_write=0 */
  1593. .setup = (0 << 15) | (0 << 14) | (5 << 11)
  1594. | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5)
  1595. | (0 << 4) | (5 << 1) | (0 << 0),
  1596. .inv_gain = 732,
  1597. .time_stabiliz = 10,
  1598. .alpha_level = 0,
  1599. .thlock = 118,
  1600. .wbd_inv = 0,
  1601. .wbd_ref = 1200,
  1602. .wbd_sel = 3,
  1603. .wbd_alpha = 5,
  1604. .agc1_max = 65535,
  1605. .agc1_min = 0,
  1606. .agc2_max = 32767,
  1607. .agc2_min = 0,
  1608. .agc1_pt1 = 0,
  1609. .agc1_pt2 = 0,
  1610. .agc1_pt3 = 98,
  1611. .agc1_slope1 = 0,
  1612. .agc1_slope2 = 167,
  1613. .agc2_pt1 = 98,
  1614. .agc2_pt2 = 255,
  1615. .agc2_slope1 = 52,
  1616. .agc2_slope2 = 0,
  1617. .alpha_mant = 28,
  1618. .alpha_exp = 26,
  1619. .beta_mant = 31,
  1620. .beta_exp = 51,
  1621. .perform_agc_softsplit = 0,
  1622. }
  1623. };
  1624. static struct dibx000_bandwidth_config dib8096p_clock_config_12_mhz = {
  1625. .internal = 108000,
  1626. .sampling = 13500,
  1627. .pll_prediv = 1,
  1628. .pll_ratio = 9,
  1629. .pll_range = 1,
  1630. .pll_reset = 0,
  1631. .pll_bypass = 0,
  1632. .enable_refdiv = 0,
  1633. .bypclk_div = 0,
  1634. .IO_CLK_en_core = 0,
  1635. .ADClkSrc = 0,
  1636. .modulo = 2,
  1637. .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
  1638. .ifreq = (0 << 25) | 0,
  1639. .timf = 20199729,
  1640. .xtal_hz = 12000000,
  1641. };
  1642. static struct dib8000_config tfe8096p_dib8000_config = {
  1643. .output_mpeg2_in_188_bytes = 1,
  1644. .hostbus_diversity = 1,
  1645. .update_lna = NULL,
  1646. .agc_config_count = 2,
  1647. .agc = dib8096p_agc_config,
  1648. .pll = &dib8096p_clock_config_12_mhz,
  1649. .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
  1650. .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
  1651. .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
  1652. .agc_control = NULL,
  1653. .diversity_delay = 48,
  1654. .output_mode = OUTMODE_MPEG2_FIFO,
  1655. .enMpegOutput = 1,
  1656. };
  1657. static struct dib0090_wbd_slope dib8096p_wbd_table[] = {
  1658. { 380, 81, 850, 64, 540, 4},
  1659. { 860, 51, 866, 21, 375, 4},
  1660. {1700, 0, 250, 0, 100, 6},
  1661. {2600, 0, 250, 0, 100, 6},
  1662. { 0xFFFF, 0, 0, 0, 0, 0},
  1663. };
  1664. static struct dib0090_config tfe8096p_dib0090_config = {
  1665. .io.clock_khz = 12000,
  1666. .io.pll_bypass = 0,
  1667. .io.pll_range = 0,
  1668. .io.pll_prediv = 3,
  1669. .io.pll_loopdiv = 6,
  1670. .io.adc_clock_ratio = 0,
  1671. .io.pll_int_loop_filt = 0,
  1672. .freq_offset_khz_uhf = -143,
  1673. .freq_offset_khz_vhf = -143,
  1674. .get_adc_power = dib8090_get_adc_power,
  1675. .clkouttobamse = 1,
  1676. .analog_output = 0,
  1677. .wbd_vhf_offset = 0,
  1678. .wbd_cband_offset = 0,
  1679. .use_pwm_agc = 1,
  1680. .clkoutdrive = 0,
  1681. .fref_clock_ratio = 1,
  1682. .ls_cfg_pad_drv = 0,
  1683. .data_tx_drv = 0,
  1684. .low_if = NULL,
  1685. .in_soc = 1,
  1686. .force_cband_input = 0,
  1687. };
  1688. struct dibx090p_adc {
  1689. u32 freq; /* RF freq MHz */
  1690. u32 timf; /* New Timf */
  1691. u32 pll_loopdiv; /* New prediv */
  1692. u32 pll_prediv; /* New loopdiv */
  1693. };
  1694. struct dibx090p_best_adc {
  1695. u32 timf;
  1696. u32 pll_loopdiv;
  1697. u32 pll_prediv;
  1698. };
  1699. static int dib8096p_get_best_sampling(struct dvb_frontend *fe, struct dibx090p_best_adc *adc)
  1700. {
  1701. u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
  1702. u16 xtal = 12000;
  1703. u16 fcp_min = 1900; /* PLL, Minimum Frequency of phase comparator (KHz) */
  1704. u16 fcp_max = 20000; /* PLL, Maximum Frequency of phase comparator (KHz) */
  1705. u32 fmem_max = 140000; /* 140MHz max SDRAM freq */
  1706. u32 fdem_min = 66000;
  1707. u32 fcp = 0, fs = 0, fdem = 0, fmem = 0;
  1708. u32 harmonic_id = 0;
  1709. adc->timf = 0;
  1710. adc->pll_loopdiv = loopdiv;
  1711. adc->pll_prediv = prediv;
  1712. deb_info("bandwidth = %d", fe->dtv_property_cache.bandwidth_hz);
  1713. /* Find Min and Max prediv */
  1714. while ((xtal / max_prediv) >= fcp_min)
  1715. max_prediv++;
  1716. max_prediv--;
  1717. min_prediv = max_prediv;
  1718. while ((xtal / min_prediv) <= fcp_max) {
  1719. min_prediv--;
  1720. if (min_prediv == 1)
  1721. break;
  1722. }
  1723. deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
  1724. min_prediv = 1;
  1725. for (prediv = min_prediv; prediv < max_prediv; prediv++) {
  1726. fcp = xtal / prediv;
  1727. if (fcp > fcp_min && fcp < fcp_max) {
  1728. for (loopdiv = 1; loopdiv < 64; loopdiv++) {
  1729. fmem = ((xtal/prediv) * loopdiv);
  1730. fdem = fmem / 2;
  1731. fs = fdem / 4;
  1732. /* test min/max system restrictions */
  1733. if ((fdem >= fdem_min) && (fmem <= fmem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz / 1000)) {
  1734. spur = 0;
  1735. /* test fs harmonics positions */
  1736. for (harmonic_id = (fe->dtv_property_cache.frequency / (1000 * fs)); harmonic_id <= ((fe->dtv_property_cache.frequency / (1000 * fs)) + 1); harmonic_id++) {
  1737. 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)))) {
  1738. spur = 1;
  1739. break;
  1740. }
  1741. }
  1742. if (!spur) {
  1743. adc->pll_loopdiv = loopdiv;
  1744. adc->pll_prediv = prediv;
  1745. adc->timf = (4260880253U / fdem) * (1 << 8);
  1746. adc->timf += ((4260880253U % fdem) << 8) / fdem;
  1747. 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);
  1748. break;
  1749. }
  1750. }
  1751. }
  1752. }
  1753. if (!spur)
  1754. break;
  1755. }
  1756. if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
  1757. return -EINVAL;
  1758. return 0;
  1759. }
  1760. static int dib8096p_agc_startup(struct dvb_frontend *fe)
  1761. {
  1762. struct dvb_usb_adapter *adap = fe->dvb->priv;
  1763. struct dib0700_adapter_state *state = adap->priv;
  1764. struct dibx000_bandwidth_config pll;
  1765. struct dibx090p_best_adc adc;
  1766. u16 target;
  1767. int ret;
  1768. ret = state->set_param_save(fe);
  1769. if (ret < 0)
  1770. return ret;
  1771. memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
  1772. dib0090_pwm_gain_reset(fe);
  1773. /* dib0090_get_wbd_target is returning any possible
  1774. temperature compensated wbd-target */
  1775. target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
  1776. state->dib8000_ops.set_wbd_ref(fe, target);
  1777. if (dib8096p_get_best_sampling(fe, &adc) == 0) {
  1778. pll.pll_ratio = adc.pll_loopdiv;
  1779. pll.pll_prediv = adc.pll_prediv;
  1780. dib0700_set_i2c_speed(adap->dev, 200);
  1781. state->dib8000_ops.update_pll(fe, &pll, fe->dtv_property_cache.bandwidth_hz / 1000, 0);
  1782. state->dib8000_ops.ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
  1783. dib0700_set_i2c_speed(adap->dev, 1000);
  1784. }
  1785. return 0;
  1786. }
  1787. static int tfe8096p_frontend_attach(struct dvb_usb_adapter *adap)
  1788. {
  1789. struct dib0700_state *st = adap->dev->priv;
  1790. u32 fw_version;
  1791. struct dib0700_adapter_state *state = adap->priv;
  1792. if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
  1793. return -ENODEV;
  1794. dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
  1795. if (fw_version >= 0x10200)
  1796. st->fw_use_new_i2c_api = 1;
  1797. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  1798. msleep(20);
  1799. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  1800. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  1801. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  1802. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  1803. dib0700_ctrl_clock(adap->dev, 72, 1);
  1804. msleep(20);
  1805. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  1806. msleep(20);
  1807. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  1808. state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80, 1);
  1809. adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap,
  1810. 0x80, &tfe8096p_dib8000_config);
  1811. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  1812. }
  1813. static int tfe8096p_tuner_attach(struct dvb_usb_adapter *adap)
  1814. {
  1815. struct dib0700_adapter_state *st = adap->priv;
  1816. struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_tuner(adap->fe_adap[0].fe);
  1817. tfe8096p_dib0090_config.reset = st->dib8000_ops.tuner_sleep;
  1818. tfe8096p_dib0090_config.sleep = st->dib8000_ops.tuner_sleep;
  1819. tfe8096p_dib0090_config.wbd = dib8096p_wbd_table;
  1820. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
  1821. &tfe8096p_dib0090_config) == NULL)
  1822. return -ENODEV;
  1823. st->dib8000_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  1824. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  1825. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096p_agc_startup;
  1826. return 0;
  1827. }
  1828. /* STK9090M */
  1829. static int dib90x0_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
  1830. {
  1831. return dib9000_fw_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
  1832. }
  1833. static int dib90x0_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
  1834. {
  1835. return dib9000_fw_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
  1836. }
  1837. static int dib90x0_tuner_reset(struct dvb_frontend *fe, int onoff)
  1838. {
  1839. return dib9000_set_gpio(fe, 5, 0, !onoff);
  1840. }
  1841. static int dib90x0_tuner_sleep(struct dvb_frontend *fe, int onoff)
  1842. {
  1843. return dib9000_set_gpio(fe, 0, 0, onoff);
  1844. }
  1845. static int dib01x0_pmu_update(struct i2c_adapter *i2c, u16 *data, u8 len)
  1846. {
  1847. u8 wb[4] = { 0xc >> 8, 0xc & 0xff, 0, 0 };
  1848. u8 rb[2];
  1849. struct i2c_msg msg[2] = {
  1850. {.addr = 0x1e >> 1, .flags = 0, .buf = wb, .len = 2},
  1851. {.addr = 0x1e >> 1, .flags = I2C_M_RD, .buf = rb, .len = 2},
  1852. };
  1853. u8 index_data;
  1854. dibx000_i2c_set_speed(i2c, 250);
  1855. if (i2c_transfer(i2c, msg, 2) != 2)
  1856. return -EIO;
  1857. switch (rb[0] << 8 | rb[1]) {
  1858. case 0:
  1859. deb_info("Found DiB0170 rev1: This version of DiB0170 is not supported any longer.\n");
  1860. return -EIO;
  1861. case 1:
  1862. deb_info("Found DiB0170 rev2");
  1863. break;
  1864. case 2:
  1865. deb_info("Found DiB0190 rev2");
  1866. break;
  1867. default:
  1868. deb_info("DiB01x0 not found");
  1869. return -EIO;
  1870. }
  1871. for (index_data = 0; index_data < len; index_data += 2) {
  1872. wb[2] = (data[index_data + 1] >> 8) & 0xff;
  1873. wb[3] = (data[index_data + 1]) & 0xff;
  1874. if (data[index_data] == 0) {
  1875. wb[0] = (data[index_data] >> 8) & 0xff;
  1876. wb[1] = (data[index_data]) & 0xff;
  1877. msg[0].len = 2;
  1878. if (i2c_transfer(i2c, msg, 2) != 2)
  1879. return -EIO;
  1880. wb[2] |= rb[0];
  1881. wb[3] |= rb[1] & ~(3 << 4);
  1882. }
  1883. wb[0] = (data[index_data] >> 8)&0xff;
  1884. wb[1] = (data[index_data])&0xff;
  1885. msg[0].len = 4;
  1886. if (i2c_transfer(i2c, &msg[0], 1) != 1)
  1887. return -EIO;
  1888. }
  1889. return 0;
  1890. }
  1891. static struct dib9000_config stk9090m_config = {
  1892. .output_mpeg2_in_188_bytes = 1,
  1893. .output_mode = OUTMODE_MPEG2_FIFO,
  1894. .vcxo_timer = 279620,
  1895. .timing_frequency = 20452225,
  1896. .demod_clock_khz = 60000,
  1897. .xtal_clock_khz = 30000,
  1898. .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
  1899. .subband = {
  1900. 2,
  1901. {
  1902. { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0008 } }, /* GPIO 3 to 1 for VHF */
  1903. { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0000 } }, /* GPIO 3 to 0 for UHF */
  1904. { 0 },
  1905. },
  1906. },
  1907. .gpio_function = {
  1908. { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
  1909. { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
  1910. },
  1911. };
  1912. static struct dib9000_config nim9090md_config[2] = {
  1913. {
  1914. .output_mpeg2_in_188_bytes = 1,
  1915. .output_mode = OUTMODE_MPEG2_FIFO,
  1916. .vcxo_timer = 279620,
  1917. .timing_frequency = 20452225,
  1918. .demod_clock_khz = 60000,
  1919. .xtal_clock_khz = 30000,
  1920. .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
  1921. }, {
  1922. .output_mpeg2_in_188_bytes = 1,
  1923. .output_mode = OUTMODE_DIVERSITY,
  1924. .vcxo_timer = 279620,
  1925. .timing_frequency = 20452225,
  1926. .demod_clock_khz = 60000,
  1927. .xtal_clock_khz = 30000,
  1928. .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
  1929. .subband = {
  1930. 2,
  1931. {
  1932. { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0006 } }, /* GPIO 1 and 2 to 1 for VHF */
  1933. { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0000 } }, /* GPIO 1 and 2 to 0 for UHF */
  1934. { 0 },
  1935. },
  1936. },
  1937. .gpio_function = {
  1938. { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
  1939. { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
  1940. },
  1941. }
  1942. };
  1943. static struct dib0090_config dib9090_dib0090_config = {
  1944. .io.pll_bypass = 0,
  1945. .io.pll_range = 1,
  1946. .io.pll_prediv = 1,
  1947. .io.pll_loopdiv = 8,
  1948. .io.adc_clock_ratio = 8,
  1949. .io.pll_int_loop_filt = 0,
  1950. .io.clock_khz = 30000,
  1951. .reset = dib90x0_tuner_reset,
  1952. .sleep = dib90x0_tuner_sleep,
  1953. .clkouttobamse = 0,
  1954. .analog_output = 0,
  1955. .use_pwm_agc = 0,
  1956. .clkoutdrive = 0,
  1957. .freq_offset_khz_uhf = 0,
  1958. .freq_offset_khz_vhf = 0,
  1959. };
  1960. static struct dib0090_config nim9090md_dib0090_config[2] = {
  1961. {
  1962. .io.pll_bypass = 0,
  1963. .io.pll_range = 1,
  1964. .io.pll_prediv = 1,
  1965. .io.pll_loopdiv = 8,
  1966. .io.adc_clock_ratio = 8,
  1967. .io.pll_int_loop_filt = 0,
  1968. .io.clock_khz = 30000,
  1969. .reset = dib90x0_tuner_reset,
  1970. .sleep = dib90x0_tuner_sleep,
  1971. .clkouttobamse = 1,
  1972. .analog_output = 0,
  1973. .use_pwm_agc = 0,
  1974. .clkoutdrive = 0,
  1975. .freq_offset_khz_uhf = 0,
  1976. .freq_offset_khz_vhf = 0,
  1977. }, {
  1978. .io.pll_bypass = 0,
  1979. .io.pll_range = 1,
  1980. .io.pll_prediv = 1,
  1981. .io.pll_loopdiv = 8,
  1982. .io.adc_clock_ratio = 8,
  1983. .io.pll_int_loop_filt = 0,
  1984. .io.clock_khz = 30000,
  1985. .reset = dib90x0_tuner_reset,
  1986. .sleep = dib90x0_tuner_sleep,
  1987. .clkouttobamse = 0,
  1988. .analog_output = 0,
  1989. .use_pwm_agc = 0,
  1990. .clkoutdrive = 0,
  1991. .freq_offset_khz_uhf = 0,
  1992. .freq_offset_khz_vhf = 0,
  1993. }
  1994. };
  1995. static int stk9090m_frontend_attach(struct dvb_usb_adapter *adap)
  1996. {
  1997. struct dib0700_adapter_state *state = adap->priv;
  1998. struct dib0700_state *st = adap->dev->priv;
  1999. u32 fw_version;
  2000. /* Make use of the new i2c functions from FW 1.20 */
  2001. dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
  2002. if (fw_version >= 0x10200)
  2003. st->fw_use_new_i2c_api = 1;
  2004. dib0700_set_i2c_speed(adap->dev, 340);
  2005. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2006. msleep(20);
  2007. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2008. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2009. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2010. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2011. dib0700_ctrl_clock(adap->dev, 72, 1);
  2012. msleep(20);
  2013. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2014. msleep(20);
  2015. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2016. dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80);
  2017. if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
  2018. deb_info("%s: Upload failed. (file not found?)\n", __func__);
  2019. return -ENODEV;
  2020. } else {
  2021. deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
  2022. }
  2023. stk9090m_config.microcode_B_fe_size = state->frontend_firmware->size;
  2024. stk9090m_config.microcode_B_fe_buffer = state->frontend_firmware->data;
  2025. adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &stk9090m_config);
  2026. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2027. }
  2028. static int dib9090_tuner_attach(struct dvb_usb_adapter *adap)
  2029. {
  2030. struct dib0700_adapter_state *state = adap->priv;
  2031. struct i2c_adapter *i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
  2032. u16 data_dib190[10] = {
  2033. 1, 0x1374,
  2034. 2, 0x01a2,
  2035. 7, 0x0020,
  2036. 0, 0x00ef,
  2037. 8, 0x0486,
  2038. };
  2039. if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &dib9090_dib0090_config) == NULL)
  2040. return -ENODEV;
  2041. i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
  2042. if (dib01x0_pmu_update(i2c, data_dib190, 10) != 0)
  2043. return -ENODEV;
  2044. dib0700_set_i2c_speed(adap->dev, 1500);
  2045. if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
  2046. return -ENODEV;
  2047. release_firmware(state->frontend_firmware);
  2048. return 0;
  2049. }
  2050. static int nim9090md_frontend_attach(struct dvb_usb_adapter *adap)
  2051. {
  2052. struct dib0700_adapter_state *state = adap->priv;
  2053. struct dib0700_state *st = adap->dev->priv;
  2054. struct i2c_adapter *i2c;
  2055. struct dvb_frontend *fe_slave;
  2056. u32 fw_version;
  2057. /* Make use of the new i2c functions from FW 1.20 */
  2058. dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
  2059. if (fw_version >= 0x10200)
  2060. st->fw_use_new_i2c_api = 1;
  2061. dib0700_set_i2c_speed(adap->dev, 340);
  2062. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2063. msleep(20);
  2064. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2065. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2066. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2067. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2068. dib0700_ctrl_clock(adap->dev, 72, 1);
  2069. msleep(20);
  2070. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2071. msleep(20);
  2072. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2073. if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
  2074. deb_info("%s: Upload failed. (file not found?)\n", __func__);
  2075. return -EIO;
  2076. } else {
  2077. deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
  2078. }
  2079. nim9090md_config[0].microcode_B_fe_size = state->frontend_firmware->size;
  2080. nim9090md_config[0].microcode_B_fe_buffer = state->frontend_firmware->data;
  2081. nim9090md_config[1].microcode_B_fe_size = state->frontend_firmware->size;
  2082. nim9090md_config[1].microcode_B_fe_buffer = state->frontend_firmware->data;
  2083. dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, 0x80);
  2084. adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &nim9090md_config[0]);
  2085. if (adap->fe_adap[0].fe == NULL)
  2086. return -ENODEV;
  2087. i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_3_4, 0);
  2088. dib9000_i2c_enumeration(i2c, 1, 0x12, 0x82);
  2089. fe_slave = dvb_attach(dib9000_attach, i2c, 0x82, &nim9090md_config[1]);
  2090. dib9000_set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
  2091. return fe_slave == NULL ? -ENODEV : 0;
  2092. }
  2093. static int nim9090md_tuner_attach(struct dvb_usb_adapter *adap)
  2094. {
  2095. struct dib0700_adapter_state *state = adap->priv;
  2096. struct i2c_adapter *i2c;
  2097. struct dvb_frontend *fe_slave;
  2098. u16 data_dib190[10] = {
  2099. 1, 0x5374,
  2100. 2, 0x01ae,
  2101. 7, 0x0020,
  2102. 0, 0x00ef,
  2103. 8, 0x0406,
  2104. };
  2105. i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
  2106. if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &nim9090md_dib0090_config[0]) == NULL)
  2107. return -ENODEV;
  2108. i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
  2109. if (dib01x0_pmu_update(i2c, data_dib190, 10) < 0)
  2110. return -ENODEV;
  2111. dib0700_set_i2c_speed(adap->dev, 1500);
  2112. if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
  2113. return -ENODEV;
  2114. fe_slave = dib9000_get_slave_frontend(adap->fe_adap[0].fe, 1);
  2115. if (fe_slave != NULL) {
  2116. i2c = dib9000_get_component_bus_interface(adap->fe_adap[0].fe);
  2117. dib9000_set_i2c_adapter(fe_slave, i2c);
  2118. i2c = dib9000_get_tuner_interface(fe_slave);
  2119. if (dvb_attach(dib0090_fw_register, fe_slave, i2c, &nim9090md_dib0090_config[1]) == NULL)
  2120. return -ENODEV;
  2121. fe_slave->dvb = adap->fe_adap[0].fe->dvb;
  2122. dib9000_fw_set_component_bus_speed(adap->fe_adap[0].fe, 1500);
  2123. if (dib9000_firmware_post_pll_init(fe_slave) < 0)
  2124. return -ENODEV;
  2125. }
  2126. release_firmware(state->frontend_firmware);
  2127. return 0;
  2128. }
  2129. /* NIM7090 */
  2130. static int dib7090p_get_best_sampling(struct dvb_frontend *fe , struct dibx090p_best_adc *adc)
  2131. {
  2132. u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
  2133. u16 xtal = 12000;
  2134. u32 fcp_min = 1900; /* PLL Minimum Frequency comparator KHz */
  2135. u32 fcp_max = 20000; /* PLL Maximum Frequency comparator KHz */
  2136. u32 fdem_max = 76000;
  2137. u32 fdem_min = 69500;
  2138. u32 fcp = 0, fs = 0, fdem = 0;
  2139. u32 harmonic_id = 0;
  2140. adc->pll_loopdiv = loopdiv;
  2141. adc->pll_prediv = prediv;
  2142. adc->timf = 0;
  2143. deb_info("bandwidth = %d fdem_min =%d", fe->dtv_property_cache.bandwidth_hz, fdem_min);
  2144. /* Find Min and Max prediv */
  2145. while ((xtal/max_prediv) >= fcp_min)
  2146. max_prediv++;
  2147. max_prediv--;
  2148. min_prediv = max_prediv;
  2149. while ((xtal/min_prediv) <= fcp_max) {
  2150. min_prediv--;
  2151. if (min_prediv == 1)
  2152. break;
  2153. }
  2154. deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
  2155. min_prediv = 2;
  2156. for (prediv = min_prediv ; prediv < max_prediv; prediv++) {
  2157. fcp = xtal / prediv;
  2158. if (fcp > fcp_min && fcp < fcp_max) {
  2159. for (loopdiv = 1 ; loopdiv < 64 ; loopdiv++) {
  2160. fdem = ((xtal/prediv) * loopdiv);
  2161. fs = fdem / 4;
  2162. /* test min/max system restrictions */
  2163. if ((fdem >= fdem_min) && (fdem <= fdem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz/1000)) {
  2164. spur = 0;
  2165. /* test fs harmonics positions */
  2166. for (harmonic_id = (fe->dtv_property_cache.frequency / (1000*fs)) ; harmonic_id <= ((fe->dtv_property_cache.frequency / (1000*fs))+1) ; harmonic_id++) {
  2167. 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)))) {
  2168. spur = 1;
  2169. break;
  2170. }
  2171. }
  2172. if (!spur) {
  2173. adc->pll_loopdiv = loopdiv;
  2174. adc->pll_prediv = prediv;
  2175. adc->timf = 2396745143UL/fdem*(1 << 9);
  2176. adc->timf += ((2396745143UL%fdem) << 9)/fdem;
  2177. deb_info("loopdiv=%i prediv=%i timf=%i", loopdiv, prediv, adc->timf);
  2178. break;
  2179. }
  2180. }
  2181. }
  2182. }
  2183. if (!spur)
  2184. break;
  2185. }
  2186. if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
  2187. return -EINVAL;
  2188. else
  2189. return 0;
  2190. }
  2191. static int dib7090_agc_startup(struct dvb_frontend *fe)
  2192. {
  2193. struct dvb_usb_adapter *adap = fe->dvb->priv;
  2194. struct dib0700_adapter_state *state = adap->priv;
  2195. struct dibx000_bandwidth_config pll;
  2196. u16 target;
  2197. struct dibx090p_best_adc adc;
  2198. int ret;
  2199. ret = state->set_param_save(fe);
  2200. if (ret < 0)
  2201. return ret;
  2202. memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
  2203. dib0090_pwm_gain_reset(fe);
  2204. target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
  2205. state->dib7000p_ops.set_wbd_ref(fe, target);
  2206. if (dib7090p_get_best_sampling(fe, &adc) == 0) {
  2207. pll.pll_ratio = adc.pll_loopdiv;
  2208. pll.pll_prediv = adc.pll_prediv;
  2209. state->dib7000p_ops.update_pll(fe, &pll);
  2210. state->dib7000p_ops.ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
  2211. }
  2212. return 0;
  2213. }
  2214. static int dib7090_agc_restart(struct dvb_frontend *fe, u8 restart)
  2215. {
  2216. deb_info("AGC restart callback: %d", restart);
  2217. if (restart == 0) /* before AGC startup */
  2218. dib0090_set_dc_servo(fe, 1);
  2219. return 0;
  2220. }
  2221. static int tfe7790p_update_lna(struct dvb_frontend *fe, u16 agc_global)
  2222. {
  2223. struct dvb_usb_adapter *adap = fe->dvb->priv;
  2224. struct dib0700_adapter_state *state = adap->priv;
  2225. deb_info("update LNA: agc global=%i", agc_global);
  2226. if (agc_global < 25000) {
  2227. state->dib7000p_ops.set_gpio(fe, 8, 0, 0);
  2228. state->dib7000p_ops.set_agc1_min(fe, 0);
  2229. } else {
  2230. state->dib7000p_ops.set_gpio(fe, 8, 0, 1);
  2231. state->dib7000p_ops.set_agc1_min(fe, 32768);
  2232. }
  2233. return 0;
  2234. }
  2235. static struct dib0090_wbd_slope dib7090_wbd_table[] = {
  2236. { 380, 81, 850, 64, 540, 4},
  2237. { 860, 51, 866, 21, 375, 4},
  2238. {1700, 0, 250, 0, 100, 6},
  2239. {2600, 0, 250, 0, 100, 6},
  2240. { 0xFFFF, 0, 0, 0, 0, 0},
  2241. };
  2242. static struct dibx000_agc_config dib7090_agc_config[2] = {
  2243. {
  2244. .band_caps = BAND_UHF,
  2245. /* 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,
  2246. * 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 */
  2247. .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
  2248. .inv_gain = 687,
  2249. .time_stabiliz = 10,
  2250. .alpha_level = 0,
  2251. .thlock = 118,
  2252. .wbd_inv = 0,
  2253. .wbd_ref = 1200,
  2254. .wbd_sel = 3,
  2255. .wbd_alpha = 5,
  2256. .agc1_max = 65535,
  2257. .agc1_min = 32768,
  2258. .agc2_max = 65535,
  2259. .agc2_min = 0,
  2260. .agc1_pt1 = 0,
  2261. .agc1_pt2 = 32,
  2262. .agc1_pt3 = 114,
  2263. .agc1_slope1 = 143,
  2264. .agc1_slope2 = 144,
  2265. .agc2_pt1 = 114,
  2266. .agc2_pt2 = 227,
  2267. .agc2_slope1 = 116,
  2268. .agc2_slope2 = 117,
  2269. .alpha_mant = 18,
  2270. .alpha_exp = 0,
  2271. .beta_mant = 20,
  2272. .beta_exp = 59,
  2273. .perform_agc_softsplit = 0,
  2274. } , {
  2275. .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
  2276. /* 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,
  2277. * 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 */
  2278. .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
  2279. .inv_gain = 732,
  2280. .time_stabiliz = 10,
  2281. .alpha_level = 0,
  2282. .thlock = 118,
  2283. .wbd_inv = 0,
  2284. .wbd_ref = 1200,
  2285. .wbd_sel = 3,
  2286. .wbd_alpha = 5,
  2287. .agc1_max = 65535,
  2288. .agc1_min = 0,
  2289. .agc2_max = 65535,
  2290. .agc2_min = 0,
  2291. .agc1_pt1 = 0,
  2292. .agc1_pt2 = 0,
  2293. .agc1_pt3 = 98,
  2294. .agc1_slope1 = 0,
  2295. .agc1_slope2 = 167,
  2296. .agc2_pt1 = 98,
  2297. .agc2_pt2 = 255,
  2298. .agc2_slope1 = 104,
  2299. .agc2_slope2 = 0,
  2300. .alpha_mant = 18,
  2301. .alpha_exp = 0,
  2302. .beta_mant = 20,
  2303. .beta_exp = 59,
  2304. .perform_agc_softsplit = 0,
  2305. }
  2306. };
  2307. static struct dibx000_bandwidth_config dib7090_clock_config_12_mhz = {
  2308. .internal = 60000,
  2309. .sampling = 15000,
  2310. .pll_prediv = 1,
  2311. .pll_ratio = 5,
  2312. .pll_range = 0,
  2313. .pll_reset = 0,
  2314. .pll_bypass = 0,
  2315. .enable_refdiv = 0,
  2316. .bypclk_div = 0,
  2317. .IO_CLK_en_core = 1,
  2318. .ADClkSrc = 1,
  2319. .modulo = 2,
  2320. .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
  2321. .ifreq = (0 << 25) | 0,
  2322. .timf = 20452225,
  2323. .xtal_hz = 15000000,
  2324. };
  2325. static struct dib7000p_config nim7090_dib7000p_config = {
  2326. .output_mpeg2_in_188_bytes = 1,
  2327. .hostbus_diversity = 1,
  2328. .tuner_is_baseband = 1,
  2329. .update_lna = tfe7790p_update_lna, /* GPIO used is the same as TFE7790 */
  2330. .agc_config_count = 2,
  2331. .agc = dib7090_agc_config,
  2332. .bw = &dib7090_clock_config_12_mhz,
  2333. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2334. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2335. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2336. .pwm_freq_div = 0,
  2337. .agc_control = dib7090_agc_restart,
  2338. .spur_protect = 0,
  2339. .disable_sample_and_hold = 0,
  2340. .enable_current_mirror = 0,
  2341. .diversity_delay = 0,
  2342. .output_mode = OUTMODE_MPEG2_FIFO,
  2343. .enMpegOutput = 1,
  2344. };
  2345. static int tfe7090p_pvr_update_lna(struct dvb_frontend *fe, u16 agc_global)
  2346. {
  2347. struct dvb_usb_adapter *adap = fe->dvb->priv;
  2348. struct dib0700_adapter_state *state = adap->priv;
  2349. deb_info("TFE7090P-PVR update LNA: agc global=%i", agc_global);
  2350. if (agc_global < 25000) {
  2351. state->dib7000p_ops.set_gpio(fe, 5, 0, 0);
  2352. state->dib7000p_ops.set_agc1_min(fe, 0);
  2353. } else {
  2354. state->dib7000p_ops.set_gpio(fe, 5, 0, 1);
  2355. state->dib7000p_ops.set_agc1_min(fe, 32768);
  2356. }
  2357. return 0;
  2358. }
  2359. static struct dib7000p_config tfe7090pvr_dib7000p_config[2] = {
  2360. {
  2361. .output_mpeg2_in_188_bytes = 1,
  2362. .hostbus_diversity = 1,
  2363. .tuner_is_baseband = 1,
  2364. .update_lna = tfe7090p_pvr_update_lna,
  2365. .agc_config_count = 2,
  2366. .agc = dib7090_agc_config,
  2367. .bw = &dib7090_clock_config_12_mhz,
  2368. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2369. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2370. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2371. .pwm_freq_div = 0,
  2372. .agc_control = dib7090_agc_restart,
  2373. .spur_protect = 0,
  2374. .disable_sample_and_hold = 0,
  2375. .enable_current_mirror = 0,
  2376. .diversity_delay = 0,
  2377. .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
  2378. .default_i2c_addr = 0x90,
  2379. .enMpegOutput = 1,
  2380. }, {
  2381. .output_mpeg2_in_188_bytes = 1,
  2382. .hostbus_diversity = 1,
  2383. .tuner_is_baseband = 1,
  2384. .update_lna = tfe7090p_pvr_update_lna,
  2385. .agc_config_count = 2,
  2386. .agc = dib7090_agc_config,
  2387. .bw = &dib7090_clock_config_12_mhz,
  2388. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2389. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2390. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2391. .pwm_freq_div = 0,
  2392. .agc_control = dib7090_agc_restart,
  2393. .spur_protect = 0,
  2394. .disable_sample_and_hold = 0,
  2395. .enable_current_mirror = 0,
  2396. .diversity_delay = 0,
  2397. .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
  2398. .default_i2c_addr = 0x92,
  2399. .enMpegOutput = 0,
  2400. }
  2401. };
  2402. static struct dib0090_config nim7090_dib0090_config = {
  2403. .io.clock_khz = 12000,
  2404. .io.pll_bypass = 0,
  2405. .io.pll_range = 0,
  2406. .io.pll_prediv = 3,
  2407. .io.pll_loopdiv = 6,
  2408. .io.adc_clock_ratio = 0,
  2409. .io.pll_int_loop_filt = 0,
  2410. .freq_offset_khz_uhf = 0,
  2411. .freq_offset_khz_vhf = 0,
  2412. .clkouttobamse = 1,
  2413. .analog_output = 0,
  2414. .wbd_vhf_offset = 0,
  2415. .wbd_cband_offset = 0,
  2416. .use_pwm_agc = 1,
  2417. .clkoutdrive = 0,
  2418. .fref_clock_ratio = 0,
  2419. .wbd = dib7090_wbd_table,
  2420. .ls_cfg_pad_drv = 0,
  2421. .data_tx_drv = 0,
  2422. .low_if = NULL,
  2423. .in_soc = 1,
  2424. };
  2425. static struct dib7000p_config tfe7790p_dib7000p_config = {
  2426. .output_mpeg2_in_188_bytes = 1,
  2427. .hostbus_diversity = 1,
  2428. .tuner_is_baseband = 1,
  2429. .update_lna = tfe7790p_update_lna,
  2430. .agc_config_count = 2,
  2431. .agc = dib7090_agc_config,
  2432. .bw = &dib7090_clock_config_12_mhz,
  2433. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2434. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2435. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2436. .pwm_freq_div = 0,
  2437. .agc_control = dib7090_agc_restart,
  2438. .spur_protect = 0,
  2439. .disable_sample_and_hold = 0,
  2440. .enable_current_mirror = 0,
  2441. .diversity_delay = 0,
  2442. .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
  2443. .enMpegOutput = 1,
  2444. };
  2445. static struct dib0090_config tfe7790p_dib0090_config = {
  2446. .io.clock_khz = 12000,
  2447. .io.pll_bypass = 0,
  2448. .io.pll_range = 0,
  2449. .io.pll_prediv = 3,
  2450. .io.pll_loopdiv = 6,
  2451. .io.adc_clock_ratio = 0,
  2452. .io.pll_int_loop_filt = 0,
  2453. .freq_offset_khz_uhf = 0,
  2454. .freq_offset_khz_vhf = 0,
  2455. .clkouttobamse = 1,
  2456. .analog_output = 0,
  2457. .wbd_vhf_offset = 0,
  2458. .wbd_cband_offset = 0,
  2459. .use_pwm_agc = 1,
  2460. .clkoutdrive = 0,
  2461. .fref_clock_ratio = 0,
  2462. .wbd = dib7090_wbd_table,
  2463. .ls_cfg_pad_drv = 0,
  2464. .data_tx_drv = 0,
  2465. .low_if = NULL,
  2466. .in_soc = 1,
  2467. .force_cband_input = 0,
  2468. .is_dib7090e = 0,
  2469. .force_crystal_mode = 1,
  2470. };
  2471. static struct dib0090_config tfe7090pvr_dib0090_config[2] = {
  2472. {
  2473. .io.clock_khz = 12000,
  2474. .io.pll_bypass = 0,
  2475. .io.pll_range = 0,
  2476. .io.pll_prediv = 3,
  2477. .io.pll_loopdiv = 6,
  2478. .io.adc_clock_ratio = 0,
  2479. .io.pll_int_loop_filt = 0,
  2480. .freq_offset_khz_uhf = 50,
  2481. .freq_offset_khz_vhf = 70,
  2482. .clkouttobamse = 1,
  2483. .analog_output = 0,
  2484. .wbd_vhf_offset = 0,
  2485. .wbd_cband_offset = 0,
  2486. .use_pwm_agc = 1,
  2487. .clkoutdrive = 0,
  2488. .fref_clock_ratio = 0,
  2489. .wbd = dib7090_wbd_table,
  2490. .ls_cfg_pad_drv = 0,
  2491. .data_tx_drv = 0,
  2492. .low_if = NULL,
  2493. .in_soc = 1,
  2494. }, {
  2495. .io.clock_khz = 12000,
  2496. .io.pll_bypass = 0,
  2497. .io.pll_range = 0,
  2498. .io.pll_prediv = 3,
  2499. .io.pll_loopdiv = 6,
  2500. .io.adc_clock_ratio = 0,
  2501. .io.pll_int_loop_filt = 0,
  2502. .freq_offset_khz_uhf = -50,
  2503. .freq_offset_khz_vhf = -70,
  2504. .clkouttobamse = 1,
  2505. .analog_output = 0,
  2506. .wbd_vhf_offset = 0,
  2507. .wbd_cband_offset = 0,
  2508. .use_pwm_agc = 1,
  2509. .clkoutdrive = 0,
  2510. .fref_clock_ratio = 0,
  2511. .wbd = dib7090_wbd_table,
  2512. .ls_cfg_pad_drv = 0,
  2513. .data_tx_drv = 0,
  2514. .low_if = NULL,
  2515. .in_soc = 1,
  2516. }
  2517. };
  2518. static int nim7090_frontend_attach(struct dvb_usb_adapter *adap)
  2519. {
  2520. struct dib0700_adapter_state *state = adap->priv;
  2521. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2522. return -ENODEV;
  2523. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2524. msleep(20);
  2525. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2526. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2527. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2528. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2529. msleep(20);
  2530. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2531. msleep(20);
  2532. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2533. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, &nim7090_dib7000p_config) != 0) {
  2534. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
  2535. dvb_detach(&state->dib7000p_ops);
  2536. return -ENODEV;
  2537. }
  2538. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, &nim7090_dib7000p_config);
  2539. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2540. }
  2541. static int nim7090_tuner_attach(struct dvb_usb_adapter *adap)
  2542. {
  2543. struct dib0700_adapter_state *st = adap->priv;
  2544. struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
  2545. nim7090_dib0090_config.reset = st->dib7000p_ops.tuner_sleep,
  2546. nim7090_dib0090_config.sleep = st->dib7000p_ops.tuner_sleep,
  2547. nim7090_dib0090_config.get_adc_power = st->dib7000p_ops.get_adc_power;
  2548. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &nim7090_dib0090_config) == NULL)
  2549. return -ENODEV;
  2550. st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  2551. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  2552. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
  2553. return 0;
  2554. }
  2555. static int tfe7090pvr_frontend0_attach(struct dvb_usb_adapter *adap)
  2556. {
  2557. struct dib0700_state *st = adap->dev->priv;
  2558. struct dib0700_adapter_state *state = adap->priv;
  2559. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2560. return -ENODEV;
  2561. /* The TFE7090 requires the dib0700 to not be in master mode */
  2562. st->disable_streaming_master_mode = 1;
  2563. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2564. msleep(20);
  2565. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2566. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2567. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2568. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2569. msleep(20);
  2570. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2571. msleep(20);
  2572. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2573. /* initialize IC 0 */
  2574. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, &tfe7090pvr_dib7000p_config[0]) != 0) {
  2575. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
  2576. dvb_detach(&state->dib7000p_ops);
  2577. return -ENODEV;
  2578. }
  2579. dib0700_set_i2c_speed(adap->dev, 340);
  2580. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x90, &tfe7090pvr_dib7000p_config[0]);
  2581. if (adap->fe_adap[0].fe == NULL)
  2582. return -ENODEV;
  2583. state->dib7000p_ops.slave_reset(adap->fe_adap[0].fe);
  2584. return 0;
  2585. }
  2586. static int tfe7090pvr_frontend1_attach(struct dvb_usb_adapter *adap)
  2587. {
  2588. struct i2c_adapter *i2c;
  2589. struct dib0700_adapter_state *state = adap->priv;
  2590. if (adap->dev->adapter[0].fe_adap[0].fe == NULL) {
  2591. err("the master dib7090 has to be initialized first");
  2592. return -ENODEV; /* the master device has not been initialized */
  2593. }
  2594. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2595. return -ENODEV;
  2596. i2c = state->dib7000p_ops.get_i2c_master(adap->dev->adapter[0].fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_6_7, 1);
  2597. if (state->dib7000p_ops.i2c_enumeration(i2c, 1, 0x10, &tfe7090pvr_dib7000p_config[1]) != 0) {
  2598. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
  2599. dvb_detach(&state->dib7000p_ops);
  2600. return -ENODEV;
  2601. }
  2602. adap->fe_adap[0].fe = state->dib7000p_ops.init(i2c, 0x92, &tfe7090pvr_dib7000p_config[1]);
  2603. dib0700_set_i2c_speed(adap->dev, 200);
  2604. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2605. }
  2606. static int tfe7090pvr_tuner0_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[0].reset = st->dib7000p_ops.tuner_sleep;
  2611. tfe7090pvr_dib0090_config[0].sleep = st->dib7000p_ops.tuner_sleep;
  2612. tfe7090pvr_dib0090_config[0].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[0]) == 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 tfe7090pvr_tuner1_attach(struct dvb_usb_adapter *adap)
  2621. {
  2622. struct dib0700_adapter_state *st = adap->priv;
  2623. struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
  2624. tfe7090pvr_dib0090_config[1].reset = st->dib7000p_ops.tuner_sleep;
  2625. tfe7090pvr_dib0090_config[1].sleep = st->dib7000p_ops.tuner_sleep;
  2626. tfe7090pvr_dib0090_config[1].get_adc_power = st->dib7000p_ops.get_adc_power;
  2627. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[1]) == NULL)
  2628. return -ENODEV;
  2629. st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  2630. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  2631. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
  2632. return 0;
  2633. }
  2634. static int tfe7790p_frontend_attach(struct dvb_usb_adapter *adap)
  2635. {
  2636. struct dib0700_state *st = adap->dev->priv;
  2637. struct dib0700_adapter_state *state = adap->priv;
  2638. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2639. return -ENODEV;
  2640. /* The TFE7790P requires the dib0700 to not be in master mode */
  2641. st->disable_streaming_master_mode = 1;
  2642. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2643. msleep(20);
  2644. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2645. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2646. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2647. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2648. msleep(20);
  2649. dib0700_ctrl_clock(adap->dev, 72, 1);
  2650. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2651. msleep(20);
  2652. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2653. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap,
  2654. 1, 0x10, &tfe7790p_dib7000p_config) != 0) {
  2655. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
  2656. __func__);
  2657. dvb_detach(&state->dib7000p_ops);
  2658. return -ENODEV;
  2659. }
  2660. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
  2661. 0x80, &tfe7790p_dib7000p_config);
  2662. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2663. }
  2664. static int tfe7790p_tuner_attach(struct dvb_usb_adapter *adap)
  2665. {
  2666. struct dib0700_adapter_state *st = adap->priv;
  2667. struct i2c_adapter *tun_i2c =
  2668. st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
  2669. tfe7790p_dib0090_config.reset = st->dib7000p_ops.tuner_sleep;
  2670. tfe7790p_dib0090_config.sleep = st->dib7000p_ops.tuner_sleep;
  2671. tfe7790p_dib0090_config.get_adc_power = st->dib7000p_ops.get_adc_power;
  2672. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
  2673. &tfe7790p_dib0090_config) == NULL)
  2674. return -ENODEV;
  2675. st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  2676. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  2677. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
  2678. return 0;
  2679. }
  2680. /* STK7070PD */
  2681. static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
  2682. {
  2683. .output_mpeg2_in_188_bytes = 1,
  2684. .agc_config_count = 1,
  2685. .agc = &dib7070_agc_config,
  2686. .bw = &dib7070_bw_config_12_mhz,
  2687. .tuner_is_baseband = 1,
  2688. .spur_protect = 1,
  2689. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2690. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2691. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2692. .hostbus_diversity = 1,
  2693. }, {
  2694. .output_mpeg2_in_188_bytes = 1,
  2695. .agc_config_count = 1,
  2696. .agc = &dib7070_agc_config,
  2697. .bw = &dib7070_bw_config_12_mhz,
  2698. .tuner_is_baseband = 1,
  2699. .spur_protect = 1,
  2700. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2701. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2702. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2703. .hostbus_diversity = 1,
  2704. }
  2705. };
  2706. static void stk7070pd_init(struct dvb_usb_device *dev)
  2707. {
  2708. dib0700_set_gpio(dev, GPIO6, GPIO_OUT, 1);
  2709. msleep(10);
  2710. dib0700_set_gpio(dev, GPIO9, GPIO_OUT, 1);
  2711. dib0700_set_gpio(dev, GPIO4, GPIO_OUT, 1);
  2712. dib0700_set_gpio(dev, GPIO7, GPIO_OUT, 1);
  2713. dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 0);
  2714. dib0700_ctrl_clock(dev, 72, 1);
  2715. msleep(10);
  2716. dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 1);
  2717. }
  2718. static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
  2719. {
  2720. struct dib0700_adapter_state *state = adap->priv;
  2721. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2722. return -ENODEV;
  2723. stk7070pd_init(adap->dev);
  2724. msleep(10);
  2725. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2726. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
  2727. stk7070pd_dib7000p_config) != 0) {
  2728. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
  2729. __func__);
  2730. dvb_detach(&state->dib7000p_ops);
  2731. return -ENODEV;
  2732. }
  2733. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, &stk7070pd_dib7000p_config[0]);
  2734. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2735. }
  2736. static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
  2737. {
  2738. struct dib0700_adapter_state *state = adap->priv;
  2739. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2740. return -ENODEV;
  2741. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x82, &stk7070pd_dib7000p_config[1]);
  2742. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2743. }
  2744. static int novatd_read_status_override(struct dvb_frontend *fe,
  2745. enum fe_status *stat)
  2746. {
  2747. struct dvb_usb_adapter *adap = fe->dvb->priv;
  2748. struct dvb_usb_device *dev = adap->dev;
  2749. struct dib0700_state *state = dev->priv;
  2750. int ret;
  2751. ret = state->read_status(fe, stat);
  2752. if (!ret)
  2753. dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT,
  2754. !!(*stat & FE_HAS_LOCK));
  2755. return ret;
  2756. }
  2757. static int novatd_sleep_override(struct dvb_frontend* fe)
  2758. {
  2759. struct dvb_usb_adapter *adap = fe->dvb->priv;
  2760. struct dvb_usb_device *dev = adap->dev;
  2761. struct dib0700_state *state = dev->priv;
  2762. /* turn off LED */
  2763. dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT, 0);
  2764. return state->sleep(fe);
  2765. }
  2766. /**
  2767. * novatd_frontend_attach - Nova-TD specific attach
  2768. *
  2769. * Nova-TD has GPIO0, 1 and 2 for LEDs. So do not fiddle with them except for
  2770. * information purposes.
  2771. */
  2772. static int novatd_frontend_attach(struct dvb_usb_adapter *adap)
  2773. {
  2774. struct dvb_usb_device *dev = adap->dev;
  2775. struct dib0700_state *st = dev->priv;
  2776. struct dib0700_adapter_state *state = adap->priv;
  2777. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2778. return -ENODEV;
  2779. if (adap->id == 0) {
  2780. stk7070pd_init(dev);
  2781. /* turn the power LED on, the other two off (just in case) */
  2782. dib0700_set_gpio(dev, GPIO0, GPIO_OUT, 0);
  2783. dib0700_set_gpio(dev, GPIO1, GPIO_OUT, 0);
  2784. dib0700_set_gpio(dev, GPIO2, GPIO_OUT, 1);
  2785. if (state->dib7000p_ops.i2c_enumeration(&dev->i2c_adap, 2, 18,
  2786. stk7070pd_dib7000p_config) != 0) {
  2787. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
  2788. __func__);
  2789. dvb_detach(&state->dib7000p_ops);
  2790. return -ENODEV;
  2791. }
  2792. }
  2793. adap->fe_adap[0].fe = state->dib7000p_ops.init(&dev->i2c_adap,
  2794. adap->id == 0 ? 0x80 : 0x82,
  2795. &stk7070pd_dib7000p_config[adap->id]);
  2796. if (adap->fe_adap[0].fe == NULL)
  2797. return -ENODEV;
  2798. st->read_status = adap->fe_adap[0].fe->ops.read_status;
  2799. adap->fe_adap[0].fe->ops.read_status = novatd_read_status_override;
  2800. st->sleep = adap->fe_adap[0].fe->ops.sleep;
  2801. adap->fe_adap[0].fe->ops.sleep = novatd_sleep_override;
  2802. return 0;
  2803. }
  2804. /* S5H1411 */
  2805. static struct s5h1411_config pinnacle_801e_config = {
  2806. .output_mode = S5H1411_PARALLEL_OUTPUT,
  2807. .gpio = S5H1411_GPIO_OFF,
  2808. .mpeg_timing = S5H1411_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
  2809. .qam_if = S5H1411_IF_44000,
  2810. .vsb_if = S5H1411_IF_44000,
  2811. .inversion = S5H1411_INVERSION_OFF,
  2812. .status_mode = S5H1411_DEMODLOCKING
  2813. };
  2814. /* Pinnacle PCTV HD Pro 801e GPIOs map:
  2815. GPIO0 - currently unknown
  2816. GPIO1 - xc5000 tuner reset
  2817. GPIO2 - CX25843 sleep
  2818. GPIO3 - currently unknown
  2819. GPIO4 - currently unknown
  2820. GPIO6 - currently unknown
  2821. GPIO7 - currently unknown
  2822. GPIO9 - currently unknown
  2823. GPIO10 - CX25843 reset
  2824. */
  2825. static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap)
  2826. {
  2827. struct dib0700_state *st = adap->dev->priv;
  2828. /* Make use of the new i2c functions from FW 1.20 */
  2829. st->fw_use_new_i2c_api = 1;
  2830. /* The s5h1411 requires the dib0700 to not be in master mode */
  2831. st->disable_streaming_master_mode = 1;
  2832. /* All msleep values taken from Windows USB trace */
  2833. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
  2834. dib0700_set_gpio(adap->dev, GPIO3, GPIO_OUT, 0);
  2835. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2836. msleep(400);
  2837. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2838. msleep(60);
  2839. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2840. msleep(30);
  2841. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2842. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2843. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2844. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2845. dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 0);
  2846. msleep(30);
  2847. /* Put the CX25843 to sleep for now since we're in digital mode */
  2848. dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
  2849. /* GPIOs are initialized, do the attach */
  2850. adap->fe_adap[0].fe = dvb_attach(s5h1411_attach, &pinnacle_801e_config,
  2851. &adap->dev->i2c_adap);
  2852. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2853. }
  2854. static int dib0700_xc5000_tuner_callback(void *priv, int component,
  2855. int command, int arg)
  2856. {
  2857. struct dvb_usb_adapter *adap = priv;
  2858. if (command == XC5000_TUNER_RESET) {
  2859. /* Reset the tuner */
  2860. dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 0);
  2861. msleep(10);
  2862. dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 1);
  2863. msleep(10);
  2864. } else {
  2865. err("xc5000: unknown tuner callback command: %d\n", command);
  2866. return -EINVAL;
  2867. }
  2868. return 0;
  2869. }
  2870. static struct xc5000_config s5h1411_xc5000_tunerconfig = {
  2871. .i2c_address = 0x64,
  2872. .if_khz = 5380,
  2873. };
  2874. static int xc5000_tuner_attach(struct dvb_usb_adapter *adap)
  2875. {
  2876. /* FIXME: generalize & move to common area */
  2877. adap->fe_adap[0].fe->callback = dib0700_xc5000_tuner_callback;
  2878. return dvb_attach(xc5000_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap,
  2879. &s5h1411_xc5000_tunerconfig)
  2880. == NULL ? -ENODEV : 0;
  2881. }
  2882. static int dib0700_xc4000_tuner_callback(void *priv, int component,
  2883. int command, int arg)
  2884. {
  2885. struct dvb_usb_adapter *adap = priv;
  2886. struct dib0700_adapter_state *state = adap->priv;
  2887. if (command == XC4000_TUNER_RESET) {
  2888. /* Reset the tuner */
  2889. state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
  2890. msleep(10);
  2891. state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  2892. } else {
  2893. err("xc4000: unknown tuner callback command: %d\n", command);
  2894. return -EINVAL;
  2895. }
  2896. return 0;
  2897. }
  2898. static struct dibx000_agc_config stk7700p_7000p_xc4000_agc_config = {
  2899. .band_caps = BAND_UHF | BAND_VHF,
  2900. .setup = 0x64,
  2901. .inv_gain = 0x02c8,
  2902. .time_stabiliz = 0x15,
  2903. .alpha_level = 0x00,
  2904. .thlock = 0x76,
  2905. .wbd_inv = 0x01,
  2906. .wbd_ref = 0x0b33,
  2907. .wbd_sel = 0x00,
  2908. .wbd_alpha = 0x02,
  2909. .agc1_max = 0x00,
  2910. .agc1_min = 0x00,
  2911. .agc2_max = 0x9b26,
  2912. .agc2_min = 0x26ca,
  2913. .agc1_pt1 = 0x00,
  2914. .agc1_pt2 = 0x00,
  2915. .agc1_pt3 = 0x00,
  2916. .agc1_slope1 = 0x00,
  2917. .agc1_slope2 = 0x00,
  2918. .agc2_pt1 = 0x00,
  2919. .agc2_pt2 = 0x80,
  2920. .agc2_slope1 = 0x1d,
  2921. .agc2_slope2 = 0x1d,
  2922. .alpha_mant = 0x11,
  2923. .alpha_exp = 0x1b,
  2924. .beta_mant = 0x17,
  2925. .beta_exp = 0x33,
  2926. .perform_agc_softsplit = 0x00,
  2927. };
  2928. static struct dibx000_bandwidth_config stk7700p_xc4000_pll_config = {
  2929. .internal = 60000,
  2930. .sampling = 30000,
  2931. .pll_prediv = 1,
  2932. .pll_ratio = 8,
  2933. .pll_range = 3,
  2934. .pll_reset = 1,
  2935. .pll_bypass = 0,
  2936. .enable_refdiv = 0,
  2937. .bypclk_div = 0,
  2938. .IO_CLK_en_core = 1,
  2939. .ADClkSrc = 1,
  2940. .modulo = 0,
  2941. .sad_cfg = (3 << 14) | (1 << 12) | 524, /* sad_cfg: refsel, sel, freq_15k */
  2942. .ifreq = 39370534,
  2943. .timf = 20452225,
  2944. .xtal_hz = 30000000
  2945. };
  2946. /* FIXME: none of these inputs are validated yet */
  2947. static struct dib7000p_config pctv_340e_config = {
  2948. .output_mpeg2_in_188_bytes = 1,
  2949. .agc_config_count = 1,
  2950. .agc = &stk7700p_7000p_xc4000_agc_config,
  2951. .bw = &stk7700p_xc4000_pll_config,
  2952. .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
  2953. .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
  2954. .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
  2955. };
  2956. /* PCTV 340e GPIOs map:
  2957. dib0700:
  2958. GPIO2 - CX25843 sleep
  2959. GPIO3 - CS5340 reset
  2960. GPIO5 - IRD
  2961. GPIO6 - Power Supply
  2962. GPIO8 - LNA (1=off 0=on)
  2963. GPIO10 - CX25843 reset
  2964. dib7000:
  2965. GPIO8 - xc4000 reset
  2966. */
  2967. static int pctv340e_frontend_attach(struct dvb_usb_adapter *adap)
  2968. {
  2969. struct dib0700_state *st = adap->dev->priv;
  2970. struct dib0700_adapter_state *state = adap->priv;
  2971. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2972. return -ENODEV;
  2973. /* Power Supply on */
  2974. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  2975. msleep(50);
  2976. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2977. msleep(100); /* Allow power supply to settle before probing */
  2978. /* cx25843 reset */
  2979. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2980. msleep(1); /* cx25843 datasheet say 350us required */
  2981. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2982. /* LNA off for now */
  2983. dib0700_set_gpio(adap->dev, GPIO8, GPIO_OUT, 1);
  2984. /* Put the CX25843 to sleep for now since we're in digital mode */
  2985. dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
  2986. /* FIXME: not verified yet */
  2987. dib0700_ctrl_clock(adap->dev, 72, 1);
  2988. msleep(500);
  2989. if (state->dib7000p_ops.dib7000pc_detection(&adap->dev->i2c_adap) == 0) {
  2990. /* Demodulator not found for some reason? */
  2991. dvb_detach(&state->dib7000p_ops);
  2992. return -ENODEV;
  2993. }
  2994. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x12,
  2995. &pctv_340e_config);
  2996. st->is_dib7000pc = 1;
  2997. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2998. }
  2999. static struct xc4000_config dib7000p_xc4000_tunerconfig = {
  3000. .i2c_address = 0x61,
  3001. .default_pm = 1,
  3002. .dvb_amplitude = 0,
  3003. .set_smoothedcvbs = 0,
  3004. .if_khz = 5400
  3005. };
  3006. static int xc4000_tuner_attach(struct dvb_usb_adapter *adap)
  3007. {
  3008. struct i2c_adapter *tun_i2c;
  3009. struct dib0700_adapter_state *state = adap->priv;
  3010. /* The xc4000 is not on the main i2c bus */
  3011. tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
  3012. DIBX000_I2C_INTERFACE_TUNER, 1);
  3013. if (tun_i2c == NULL) {
  3014. printk(KERN_ERR "Could not reach tuner i2c bus\n");
  3015. return 0;
  3016. }
  3017. /* Setup the reset callback */
  3018. adap->fe_adap[0].fe->callback = dib0700_xc4000_tuner_callback;
  3019. return dvb_attach(xc4000_attach, adap->fe_adap[0].fe, tun_i2c,
  3020. &dib7000p_xc4000_tunerconfig)
  3021. == NULL ? -ENODEV : 0;
  3022. }
  3023. static struct lgdt3305_config hcw_lgdt3305_config = {
  3024. .i2c_addr = 0x0e,
  3025. .mpeg_mode = LGDT3305_MPEG_PARALLEL,
  3026. .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
  3027. .tpvalid_polarity = LGDT3305_TP_VALID_LOW,
  3028. .deny_i2c_rptr = 0,
  3029. .spectral_inversion = 1,
  3030. .qam_if_khz = 6000,
  3031. .vsb_if_khz = 6000,
  3032. .usref_8vsb = 0x0500,
  3033. };
  3034. static struct mxl5007t_config hcw_mxl5007t_config = {
  3035. .xtal_freq_hz = MxL_XTAL_25_MHZ,
  3036. .if_freq_hz = MxL_IF_6_MHZ,
  3037. .invert_if = 1,
  3038. };
  3039. /* TIGER-ATSC map:
  3040. GPIO0 - LNA_CTR (H: LNA power enabled, L: LNA power disabled)
  3041. GPIO1 - ANT_SEL (H: VPA, L: MCX)
  3042. GPIO4 - SCL2
  3043. GPIO6 - EN_TUNER
  3044. GPIO7 - SDA2
  3045. GPIO10 - DEM_RST
  3046. MXL is behind LG's i2c repeater. LG is on SCL2/SDA2 gpios on the DIB
  3047. */
  3048. static int lgdt3305_frontend_attach(struct dvb_usb_adapter *adap)
  3049. {
  3050. struct dib0700_state *st = adap->dev->priv;
  3051. /* Make use of the new i2c functions from FW 1.20 */
  3052. st->fw_use_new_i2c_api = 1;
  3053. st->disable_streaming_master_mode = 1;
  3054. /* fe power enable */
  3055. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  3056. msleep(30);
  3057. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  3058. msleep(30);
  3059. /* demod reset */
  3060. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  3061. msleep(30);
  3062. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  3063. msleep(30);
  3064. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  3065. msleep(30);
  3066. adap->fe_adap[0].fe = dvb_attach(lgdt3305_attach,
  3067. &hcw_lgdt3305_config,
  3068. &adap->dev->i2c_adap);
  3069. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  3070. }
  3071. static int mxl5007t_tuner_attach(struct dvb_usb_adapter *adap)
  3072. {
  3073. return dvb_attach(mxl5007t_attach, adap->fe_adap[0].fe,
  3074. &adap->dev->i2c_adap, 0x60,
  3075. &hcw_mxl5007t_config) == NULL ? -ENODEV : 0;
  3076. }
  3077. /* DVB-USB and USB stuff follows */
  3078. struct usb_device_id dib0700_usb_id_table[] = {
  3079. /* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
  3080. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) },
  3081. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
  3082. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
  3083. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
  3084. /* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
  3085. { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) },
  3086. { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) },
  3087. { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
  3088. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
  3089. /* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
  3090. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) },
  3091. { USB_DEVICE(USB_VID_TERRATEC,
  3092. USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
  3093. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
  3094. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) },
  3095. /* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) },
  3096. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) },
  3097. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) },
  3098. { USB_DEVICE(USB_VID_PINNACLE,
  3099. USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) },
  3100. { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500_PC) },
  3101. /* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) },
  3102. { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U7000) },
  3103. { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) },
  3104. { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000) },
  3105. { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100) },
  3106. /* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) },
  3107. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) },
  3108. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_USB_XE) },
  3109. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_EXPRESSCARD_320CX) },
  3110. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV72E) },
  3111. /* 30 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73E) },
  3112. { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_EC372S) },
  3113. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) },
  3114. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) },
  3115. { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) },
  3116. /* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) },
  3117. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_3) },
  3118. { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U8000) },
  3119. { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700PH) },
  3120. { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) },
  3121. /* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) },
  3122. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) },
  3123. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_EXPRESS) },
  3124. { USB_DEVICE(USB_VID_TERRATEC,
  3125. USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2) },
  3126. { USB_DEVICE(USB_VID_SONY, USB_PID_SONY_PLAYTV) },
  3127. /* 45 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_PD378S) },
  3128. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC) },
  3129. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC_B210) },
  3130. { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_MC770) },
  3131. { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT) },
  3132. /* 50 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_Dlx) },
  3133. { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_H) },
  3134. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T3) },
  3135. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T5) },
  3136. { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D) },
  3137. /* 55 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D_2) },
  3138. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73A) },
  3139. { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV73ESE) },
  3140. { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV282E) },
  3141. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7770P) },
  3142. /* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) },
  3143. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XPVR) },
  3144. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XP) },
  3145. { USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x000, 0x3f00) },
  3146. { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) },
  3147. /* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) },
  3148. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) },
  3149. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) },
  3150. { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DIVERSITY) },
  3151. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090M) },
  3152. /* 70 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM8096MD) },
  3153. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090MD) },
  3154. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM7090) },
  3155. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7090PVR) },
  3156. { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_AIRSTAR_TELESTICK_2) },
  3157. /* 75 */{ USB_DEVICE(USB_VID_MEDION, USB_PID_CREATIX_CTX1921) },
  3158. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E) },
  3159. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E_SE) },
  3160. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7790P) },
  3161. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE8096P) },
  3162. /* 80 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_2) },
  3163. { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E) },
  3164. { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E_SE) },
  3165. { USB_DEVICE(USB_VID_PCTV, USB_PID_DIBCOM_STK8096PVR) },
  3166. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096PVR) },
  3167. { 0 } /* Terminating entry */
  3168. };
  3169. MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
  3170. #define DIB0700_DEFAULT_DEVICE_PROPERTIES \
  3171. .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
  3172. .usb_ctrl = DEVICE_SPECIFIC, \
  3173. .firmware = "dvb-usb-dib0700-1.20.fw", \
  3174. .download_firmware = dib0700_download_firmware, \
  3175. .no_reconnect = 1, \
  3176. .size_of_priv = sizeof(struct dib0700_state), \
  3177. .i2c_algo = &dib0700_i2c_algo, \
  3178. .identify_state = dib0700_identify_state
  3179. #define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
  3180. .streaming_ctrl = dib0700_streaming_ctrl, \
  3181. .stream = { \
  3182. .type = USB_BULK, \
  3183. .count = 4, \
  3184. .endpoint = ep, \
  3185. .u = { \
  3186. .bulk = { \
  3187. .buffersize = 39480, \
  3188. } \
  3189. } \
  3190. }
  3191. #define DIB0700_NUM_FRONTENDS(n) \
  3192. .num_frontends = n, \
  3193. .size_of_priv = sizeof(struct dib0700_adapter_state)
  3194. struct dvb_usb_device_properties dib0700_devices[] = {
  3195. {
  3196. DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3197. .num_adapters = 1,
  3198. .adapter = {
  3199. {
  3200. DIB0700_NUM_FRONTENDS(1),
  3201. .fe = {{
  3202. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3203. .pid_filter_count = 32,
  3204. .pid_filter = stk7700p_pid_filter,
  3205. .pid_filter_ctrl = stk7700p_pid_filter_ctrl,
  3206. .frontend_attach = stk7700p_frontend_attach,
  3207. .tuner_attach = stk7700p_tuner_attach,
  3208. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3209. }},
  3210. },
  3211. },
  3212. .num_device_descs = 8,
  3213. .devices = {
  3214. { "DiBcom STK7700P reference design",
  3215. { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
  3216. { NULL },
  3217. },
  3218. { "Hauppauge Nova-T Stick",
  3219. { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
  3220. { NULL },
  3221. },
  3222. { "AVerMedia AVerTV DVB-T Volar",
  3223. { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
  3224. { NULL },
  3225. },
  3226. { "Compro Videomate U500",
  3227. { &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] },
  3228. { NULL },
  3229. },
  3230. { "Uniwill STK7700P based (Hama and others)",
  3231. { &dib0700_usb_id_table[7], NULL },
  3232. { NULL },
  3233. },
  3234. { "Leadtek Winfast DTV Dongle (STK7700P based)",
  3235. { &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] },
  3236. { NULL },
  3237. },
  3238. { "AVerMedia AVerTV DVB-T Express",
  3239. { &dib0700_usb_id_table[20] },
  3240. { NULL },
  3241. },
  3242. { "Gigabyte U7000",
  3243. { &dib0700_usb_id_table[21], NULL },
  3244. { NULL },
  3245. }
  3246. },
  3247. .rc.core = {
  3248. .rc_interval = DEFAULT_RC_INTERVAL,
  3249. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3250. .rc_query = dib0700_rc_query_old_firmware,
  3251. .allowed_protos = RC_BIT_RC5 |
  3252. RC_BIT_RC6_MCE |
  3253. RC_BIT_NEC,
  3254. .change_protocol = dib0700_change_protocol,
  3255. },
  3256. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3257. .num_adapters = 2,
  3258. .adapter = {
  3259. {
  3260. DIB0700_NUM_FRONTENDS(1),
  3261. .fe = {{
  3262. .frontend_attach = bristol_frontend_attach,
  3263. .tuner_attach = bristol_tuner_attach,
  3264. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3265. }},
  3266. }, {
  3267. DIB0700_NUM_FRONTENDS(1),
  3268. .fe = {{
  3269. .frontend_attach = bristol_frontend_attach,
  3270. .tuner_attach = bristol_tuner_attach,
  3271. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3272. }},
  3273. }
  3274. },
  3275. .num_device_descs = 1,
  3276. .devices = {
  3277. { "Hauppauge Nova-T 500 Dual DVB-T",
  3278. { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
  3279. { NULL },
  3280. },
  3281. },
  3282. .rc.core = {
  3283. .rc_interval = DEFAULT_RC_INTERVAL,
  3284. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3285. .rc_query = dib0700_rc_query_old_firmware,
  3286. .allowed_protos = RC_BIT_RC5 |
  3287. RC_BIT_RC6_MCE |
  3288. RC_BIT_NEC,
  3289. .change_protocol = dib0700_change_protocol,
  3290. },
  3291. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3292. .num_adapters = 2,
  3293. .adapter = {
  3294. {
  3295. DIB0700_NUM_FRONTENDS(1),
  3296. .fe = {{
  3297. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3298. .pid_filter_count = 32,
  3299. .pid_filter = stk70x0p_pid_filter,
  3300. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3301. .frontend_attach = stk7700d_frontend_attach,
  3302. .tuner_attach = stk7700d_tuner_attach,
  3303. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3304. }},
  3305. }, {
  3306. DIB0700_NUM_FRONTENDS(1),
  3307. .fe = {{
  3308. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3309. .pid_filter_count = 32,
  3310. .pid_filter = stk70x0p_pid_filter,
  3311. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3312. .frontend_attach = stk7700d_frontend_attach,
  3313. .tuner_attach = stk7700d_tuner_attach,
  3314. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3315. }},
  3316. }
  3317. },
  3318. .num_device_descs = 5,
  3319. .devices = {
  3320. { "Pinnacle PCTV 2000e",
  3321. { &dib0700_usb_id_table[11], NULL },
  3322. { NULL },
  3323. },
  3324. { "Terratec Cinergy DT XS Diversity",
  3325. { &dib0700_usb_id_table[12], NULL },
  3326. { NULL },
  3327. },
  3328. { "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
  3329. { &dib0700_usb_id_table[13], NULL },
  3330. { NULL },
  3331. },
  3332. { "DiBcom STK7700D reference design",
  3333. { &dib0700_usb_id_table[14], NULL },
  3334. { NULL },
  3335. },
  3336. { "YUAN High-Tech DiBcom STK7700D",
  3337. { &dib0700_usb_id_table[55], NULL },
  3338. { NULL },
  3339. },
  3340. },
  3341. .rc.core = {
  3342. .rc_interval = DEFAULT_RC_INTERVAL,
  3343. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3344. .rc_query = dib0700_rc_query_old_firmware,
  3345. .allowed_protos = RC_BIT_RC5 |
  3346. RC_BIT_RC6_MCE |
  3347. RC_BIT_NEC,
  3348. .change_protocol = dib0700_change_protocol,
  3349. },
  3350. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3351. .num_adapters = 1,
  3352. .adapter = {
  3353. {
  3354. DIB0700_NUM_FRONTENDS(1),
  3355. .fe = {{
  3356. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3357. .pid_filter_count = 32,
  3358. .pid_filter = stk70x0p_pid_filter,
  3359. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3360. .frontend_attach = stk7700P2_frontend_attach,
  3361. .tuner_attach = stk7700d_tuner_attach,
  3362. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3363. }},
  3364. },
  3365. },
  3366. .num_device_descs = 3,
  3367. .devices = {
  3368. { "ASUS My Cinema U3000 Mini DVBT Tuner",
  3369. { &dib0700_usb_id_table[23], NULL },
  3370. { NULL },
  3371. },
  3372. { "Yuan EC372S",
  3373. { &dib0700_usb_id_table[31], NULL },
  3374. { NULL },
  3375. },
  3376. { "Terratec Cinergy T Express",
  3377. { &dib0700_usb_id_table[42], NULL },
  3378. { NULL },
  3379. }
  3380. },
  3381. .rc.core = {
  3382. .rc_interval = DEFAULT_RC_INTERVAL,
  3383. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3384. .module_name = "dib0700",
  3385. .rc_query = dib0700_rc_query_old_firmware,
  3386. .allowed_protos = RC_BIT_RC5 |
  3387. RC_BIT_RC6_MCE |
  3388. RC_BIT_NEC,
  3389. .change_protocol = dib0700_change_protocol,
  3390. },
  3391. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3392. .num_adapters = 1,
  3393. .adapter = {
  3394. {
  3395. DIB0700_NUM_FRONTENDS(1),
  3396. .fe = {{
  3397. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3398. .pid_filter_count = 32,
  3399. .pid_filter = stk70x0p_pid_filter,
  3400. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3401. .frontend_attach = stk7070p_frontend_attach,
  3402. .tuner_attach = dib7070p_tuner_attach,
  3403. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3404. }},
  3405. },
  3406. },
  3407. .num_device_descs = 12,
  3408. .devices = {
  3409. { "DiBcom STK7070P reference design",
  3410. { &dib0700_usb_id_table[15], NULL },
  3411. { NULL },
  3412. },
  3413. { "Pinnacle PCTV DVB-T Flash Stick",
  3414. { &dib0700_usb_id_table[16], NULL },
  3415. { NULL },
  3416. },
  3417. { "Artec T14BR DVB-T",
  3418. { &dib0700_usb_id_table[22], NULL },
  3419. { NULL },
  3420. },
  3421. { "ASUS My Cinema U3100 Mini DVBT Tuner",
  3422. { &dib0700_usb_id_table[24], NULL },
  3423. { NULL },
  3424. },
  3425. { "Hauppauge Nova-T Stick",
  3426. { &dib0700_usb_id_table[25], NULL },
  3427. { NULL },
  3428. },
  3429. { "Hauppauge Nova-T MyTV.t",
  3430. { &dib0700_usb_id_table[26], NULL },
  3431. { NULL },
  3432. },
  3433. { "Pinnacle PCTV 72e",
  3434. { &dib0700_usb_id_table[29], NULL },
  3435. { NULL },
  3436. },
  3437. { "Pinnacle PCTV 73e",
  3438. { &dib0700_usb_id_table[30], NULL },
  3439. { NULL },
  3440. },
  3441. { "Elgato EyeTV DTT",
  3442. { &dib0700_usb_id_table[49], NULL },
  3443. { NULL },
  3444. },
  3445. { "Yuan PD378S",
  3446. { &dib0700_usb_id_table[45], NULL },
  3447. { NULL },
  3448. },
  3449. { "Elgato EyeTV Dtt Dlx PD378S",
  3450. { &dib0700_usb_id_table[50], NULL },
  3451. { NULL },
  3452. },
  3453. { "Elgato EyeTV DTT rev. 2",
  3454. { &dib0700_usb_id_table[80], NULL },
  3455. { NULL },
  3456. },
  3457. },
  3458. .rc.core = {
  3459. .rc_interval = DEFAULT_RC_INTERVAL,
  3460. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3461. .module_name = "dib0700",
  3462. .rc_query = dib0700_rc_query_old_firmware,
  3463. .allowed_protos = RC_BIT_RC5 |
  3464. RC_BIT_RC6_MCE |
  3465. RC_BIT_NEC,
  3466. .change_protocol = dib0700_change_protocol,
  3467. },
  3468. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3469. .num_adapters = 1,
  3470. .adapter = {
  3471. {
  3472. DIB0700_NUM_FRONTENDS(1),
  3473. .fe = {{
  3474. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3475. .pid_filter_count = 32,
  3476. .pid_filter = stk70x0p_pid_filter,
  3477. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3478. .frontend_attach = stk7070p_frontend_attach,
  3479. .tuner_attach = dib7070p_tuner_attach,
  3480. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3481. }},
  3482. },
  3483. },
  3484. .num_device_descs = 3,
  3485. .devices = {
  3486. { "Pinnacle PCTV 73A",
  3487. { &dib0700_usb_id_table[56], NULL },
  3488. { NULL },
  3489. },
  3490. { "Pinnacle PCTV 73e SE",
  3491. { &dib0700_usb_id_table[57], &dib0700_usb_id_table[65], NULL },
  3492. { NULL },
  3493. },
  3494. { "Pinnacle PCTV 282e",
  3495. { &dib0700_usb_id_table[58], &dib0700_usb_id_table[66], NULL },
  3496. { NULL },
  3497. },
  3498. },
  3499. .rc.core = {
  3500. .rc_interval = DEFAULT_RC_INTERVAL,
  3501. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3502. .module_name = "dib0700",
  3503. .rc_query = dib0700_rc_query_old_firmware,
  3504. .allowed_protos = RC_BIT_RC5 |
  3505. RC_BIT_RC6_MCE |
  3506. RC_BIT_NEC,
  3507. .change_protocol = dib0700_change_protocol,
  3508. },
  3509. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3510. .num_adapters = 2,
  3511. .adapter = {
  3512. {
  3513. DIB0700_NUM_FRONTENDS(1),
  3514. .fe = {{
  3515. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3516. .pid_filter_count = 32,
  3517. .pid_filter = stk70x0p_pid_filter,
  3518. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3519. .frontend_attach = novatd_frontend_attach,
  3520. .tuner_attach = dib7070p_tuner_attach,
  3521. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3522. }},
  3523. }, {
  3524. DIB0700_NUM_FRONTENDS(1),
  3525. .fe = {{
  3526. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3527. .pid_filter_count = 32,
  3528. .pid_filter = stk70x0p_pid_filter,
  3529. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3530. .frontend_attach = novatd_frontend_attach,
  3531. .tuner_attach = dib7070p_tuner_attach,
  3532. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3533. }},
  3534. }
  3535. },
  3536. .num_device_descs = 3,
  3537. .devices = {
  3538. { "Hauppauge Nova-TD Stick (52009)",
  3539. { &dib0700_usb_id_table[35], NULL },
  3540. { NULL },
  3541. },
  3542. { "PCTV 2002e",
  3543. { &dib0700_usb_id_table[81], NULL },
  3544. { NULL },
  3545. },
  3546. { "PCTV 2002e SE",
  3547. { &dib0700_usb_id_table[82], NULL },
  3548. { NULL },
  3549. },
  3550. },
  3551. .rc.core = {
  3552. .rc_interval = DEFAULT_RC_INTERVAL,
  3553. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3554. .module_name = "dib0700",
  3555. .rc_query = dib0700_rc_query_old_firmware,
  3556. .allowed_protos = RC_BIT_RC5 |
  3557. RC_BIT_RC6_MCE |
  3558. RC_BIT_NEC,
  3559. .change_protocol = dib0700_change_protocol,
  3560. },
  3561. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3562. .num_adapters = 2,
  3563. .adapter = {
  3564. {
  3565. DIB0700_NUM_FRONTENDS(1),
  3566. .fe = {{
  3567. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3568. .pid_filter_count = 32,
  3569. .pid_filter = stk70x0p_pid_filter,
  3570. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3571. .frontend_attach = stk7070pd_frontend_attach0,
  3572. .tuner_attach = dib7070p_tuner_attach,
  3573. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3574. }},
  3575. }, {
  3576. DIB0700_NUM_FRONTENDS(1),
  3577. .fe = {{
  3578. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3579. .pid_filter_count = 32,
  3580. .pid_filter = stk70x0p_pid_filter,
  3581. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3582. .frontend_attach = stk7070pd_frontend_attach1,
  3583. .tuner_attach = dib7070p_tuner_attach,
  3584. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3585. }},
  3586. }
  3587. },
  3588. .num_device_descs = 5,
  3589. .devices = {
  3590. { "DiBcom STK7070PD reference design",
  3591. { &dib0700_usb_id_table[17], NULL },
  3592. { NULL },
  3593. },
  3594. { "Pinnacle PCTV Dual DVB-T Diversity Stick",
  3595. { &dib0700_usb_id_table[18], NULL },
  3596. { NULL },
  3597. },
  3598. { "Hauppauge Nova-TD-500 (84xxx)",
  3599. { &dib0700_usb_id_table[36], NULL },
  3600. { NULL },
  3601. },
  3602. { "Terratec Cinergy DT USB XS Diversity/ T5",
  3603. { &dib0700_usb_id_table[43],
  3604. &dib0700_usb_id_table[53], NULL},
  3605. { NULL },
  3606. },
  3607. { "Sony PlayTV",
  3608. { &dib0700_usb_id_table[44], NULL },
  3609. { NULL },
  3610. },
  3611. },
  3612. .rc.core = {
  3613. .rc_interval = DEFAULT_RC_INTERVAL,
  3614. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3615. .module_name = "dib0700",
  3616. .rc_query = dib0700_rc_query_old_firmware,
  3617. .allowed_protos = RC_BIT_RC5 |
  3618. RC_BIT_RC6_MCE |
  3619. RC_BIT_NEC,
  3620. .change_protocol = dib0700_change_protocol,
  3621. },
  3622. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3623. .num_adapters = 2,
  3624. .adapter = {
  3625. {
  3626. DIB0700_NUM_FRONTENDS(1),
  3627. .fe = {{
  3628. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3629. .pid_filter_count = 32,
  3630. .pid_filter = stk70x0p_pid_filter,
  3631. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3632. .frontend_attach = stk7070pd_frontend_attach0,
  3633. .tuner_attach = dib7070p_tuner_attach,
  3634. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3635. }},
  3636. }, {
  3637. DIB0700_NUM_FRONTENDS(1),
  3638. .fe = {{
  3639. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3640. .pid_filter_count = 32,
  3641. .pid_filter = stk70x0p_pid_filter,
  3642. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3643. .frontend_attach = stk7070pd_frontend_attach1,
  3644. .tuner_attach = dib7070p_tuner_attach,
  3645. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3646. }},
  3647. }
  3648. },
  3649. .num_device_descs = 1,
  3650. .devices = {
  3651. { "Elgato EyeTV Diversity",
  3652. { &dib0700_usb_id_table[68], NULL },
  3653. { NULL },
  3654. },
  3655. },
  3656. .rc.core = {
  3657. .rc_interval = DEFAULT_RC_INTERVAL,
  3658. .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
  3659. .module_name = "dib0700",
  3660. .rc_query = dib0700_rc_query_old_firmware,
  3661. .allowed_protos = RC_BIT_RC5 |
  3662. RC_BIT_RC6_MCE |
  3663. RC_BIT_NEC,
  3664. .change_protocol = dib0700_change_protocol,
  3665. },
  3666. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3667. .num_adapters = 1,
  3668. .adapter = {
  3669. {
  3670. DIB0700_NUM_FRONTENDS(1),
  3671. .fe = {{
  3672. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3673. .pid_filter_count = 32,
  3674. .pid_filter = stk70x0p_pid_filter,
  3675. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3676. .frontend_attach = stk7700ph_frontend_attach,
  3677. .tuner_attach = stk7700ph_tuner_attach,
  3678. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3679. }},
  3680. },
  3681. },
  3682. .num_device_descs = 9,
  3683. .devices = {
  3684. { "Terratec Cinergy HT USB XE",
  3685. { &dib0700_usb_id_table[27], NULL },
  3686. { NULL },
  3687. },
  3688. { "Pinnacle Expresscard 320cx",
  3689. { &dib0700_usb_id_table[28], NULL },
  3690. { NULL },
  3691. },
  3692. { "Terratec Cinergy HT Express",
  3693. { &dib0700_usb_id_table[32], NULL },
  3694. { NULL },
  3695. },
  3696. { "Gigabyte U8000-RH",
  3697. { &dib0700_usb_id_table[37], NULL },
  3698. { NULL },
  3699. },
  3700. { "YUAN High-Tech STK7700PH",
  3701. { &dib0700_usb_id_table[38], NULL },
  3702. { NULL },
  3703. },
  3704. { "Asus My Cinema-U3000Hybrid",
  3705. { &dib0700_usb_id_table[39], NULL },
  3706. { NULL },
  3707. },
  3708. { "YUAN High-Tech MC770",
  3709. { &dib0700_usb_id_table[48], NULL },
  3710. { NULL },
  3711. },
  3712. { "Leadtek WinFast DTV Dongle H",
  3713. { &dib0700_usb_id_table[51], NULL },
  3714. { NULL },
  3715. },
  3716. { "YUAN High-Tech STK7700D",
  3717. { &dib0700_usb_id_table[54], NULL },
  3718. { NULL },
  3719. },
  3720. },
  3721. .rc.core = {
  3722. .rc_interval = DEFAULT_RC_INTERVAL,
  3723. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3724. .module_name = "dib0700",
  3725. .rc_query = dib0700_rc_query_old_firmware,
  3726. .allowed_protos = RC_BIT_RC5 |
  3727. RC_BIT_RC6_MCE |
  3728. RC_BIT_NEC,
  3729. .change_protocol = dib0700_change_protocol,
  3730. },
  3731. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3732. .num_adapters = 1,
  3733. .adapter = {
  3734. {
  3735. DIB0700_NUM_FRONTENDS(1),
  3736. .fe = {{
  3737. .frontend_attach = s5h1411_frontend_attach,
  3738. .tuner_attach = xc5000_tuner_attach,
  3739. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3740. }},
  3741. },
  3742. },
  3743. .num_device_descs = 2,
  3744. .devices = {
  3745. { "Pinnacle PCTV HD Pro USB Stick",
  3746. { &dib0700_usb_id_table[40], NULL },
  3747. { NULL },
  3748. },
  3749. { "Pinnacle PCTV HD USB Stick",
  3750. { &dib0700_usb_id_table[41], NULL },
  3751. { NULL },
  3752. },
  3753. },
  3754. .rc.core = {
  3755. .rc_interval = DEFAULT_RC_INTERVAL,
  3756. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3757. .module_name = "dib0700",
  3758. .rc_query = dib0700_rc_query_old_firmware,
  3759. .allowed_protos = RC_BIT_RC5 |
  3760. RC_BIT_RC6_MCE |
  3761. RC_BIT_NEC,
  3762. .change_protocol = dib0700_change_protocol,
  3763. },
  3764. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3765. .num_adapters = 1,
  3766. .adapter = {
  3767. {
  3768. DIB0700_NUM_FRONTENDS(1),
  3769. .fe = {{
  3770. .frontend_attach = lgdt3305_frontend_attach,
  3771. .tuner_attach = mxl5007t_tuner_attach,
  3772. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3773. }},
  3774. },
  3775. },
  3776. .num_device_descs = 2,
  3777. .devices = {
  3778. { "Hauppauge ATSC MiniCard (B200)",
  3779. { &dib0700_usb_id_table[46], NULL },
  3780. { NULL },
  3781. },
  3782. { "Hauppauge ATSC MiniCard (B210)",
  3783. { &dib0700_usb_id_table[47], NULL },
  3784. { NULL },
  3785. },
  3786. },
  3787. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3788. .num_adapters = 1,
  3789. .adapter = {
  3790. {
  3791. DIB0700_NUM_FRONTENDS(1),
  3792. .fe = {{
  3793. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3794. .pid_filter_count = 32,
  3795. .pid_filter = stk70x0p_pid_filter,
  3796. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3797. .frontend_attach = stk7770p_frontend_attach,
  3798. .tuner_attach = dib7770p_tuner_attach,
  3799. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3800. }},
  3801. },
  3802. },
  3803. .num_device_descs = 4,
  3804. .devices = {
  3805. { "DiBcom STK7770P reference design",
  3806. { &dib0700_usb_id_table[59], NULL },
  3807. { NULL },
  3808. },
  3809. { "Terratec Cinergy T USB XXS (HD)/ T3",
  3810. { &dib0700_usb_id_table[33],
  3811. &dib0700_usb_id_table[52],
  3812. &dib0700_usb_id_table[60], NULL},
  3813. { NULL },
  3814. },
  3815. { "TechniSat AirStar TeleStick 2",
  3816. { &dib0700_usb_id_table[74], NULL },
  3817. { NULL },
  3818. },
  3819. { "Medion CTX1921 DVB-T USB",
  3820. { &dib0700_usb_id_table[75], NULL },
  3821. { NULL },
  3822. },
  3823. },
  3824. .rc.core = {
  3825. .rc_interval = DEFAULT_RC_INTERVAL,
  3826. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3827. .module_name = "dib0700",
  3828. .rc_query = dib0700_rc_query_old_firmware,
  3829. .allowed_protos = RC_BIT_RC5 |
  3830. RC_BIT_RC6_MCE |
  3831. RC_BIT_NEC,
  3832. .change_protocol = dib0700_change_protocol,
  3833. },
  3834. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3835. .num_adapters = 1,
  3836. .adapter = {
  3837. {
  3838. DIB0700_NUM_FRONTENDS(1),
  3839. .fe = {{
  3840. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3841. .pid_filter_count = 32,
  3842. .pid_filter = stk80xx_pid_filter,
  3843. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  3844. .frontend_attach = stk807x_frontend_attach,
  3845. .tuner_attach = dib807x_tuner_attach,
  3846. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3847. }},
  3848. },
  3849. },
  3850. .num_device_descs = 3,
  3851. .devices = {
  3852. { "DiBcom STK807xP reference design",
  3853. { &dib0700_usb_id_table[62], NULL },
  3854. { NULL },
  3855. },
  3856. { "Prolink Pixelview SBTVD",
  3857. { &dib0700_usb_id_table[63], NULL },
  3858. { NULL },
  3859. },
  3860. { "EvolutePC TVWay+",
  3861. { &dib0700_usb_id_table[64], NULL },
  3862. { NULL },
  3863. },
  3864. },
  3865. .rc.core = {
  3866. .rc_interval = DEFAULT_RC_INTERVAL,
  3867. .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
  3868. .module_name = "dib0700",
  3869. .rc_query = dib0700_rc_query_old_firmware,
  3870. .allowed_protos = RC_BIT_RC5 |
  3871. RC_BIT_RC6_MCE |
  3872. RC_BIT_NEC,
  3873. .change_protocol = dib0700_change_protocol,
  3874. },
  3875. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3876. .num_adapters = 2,
  3877. .adapter = {
  3878. {
  3879. DIB0700_NUM_FRONTENDS(1),
  3880. .fe = {{
  3881. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3882. .pid_filter_count = 32,
  3883. .pid_filter = stk80xx_pid_filter,
  3884. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  3885. .frontend_attach = stk807xpvr_frontend_attach0,
  3886. .tuner_attach = dib807x_tuner_attach,
  3887. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3888. }},
  3889. },
  3890. {
  3891. DIB0700_NUM_FRONTENDS(1),
  3892. .fe = {{
  3893. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3894. .pid_filter_count = 32,
  3895. .pid_filter = stk80xx_pid_filter,
  3896. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  3897. .frontend_attach = stk807xpvr_frontend_attach1,
  3898. .tuner_attach = dib807x_tuner_attach,
  3899. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3900. }},
  3901. },
  3902. },
  3903. .num_device_descs = 1,
  3904. .devices = {
  3905. { "DiBcom STK807xPVR reference design",
  3906. { &dib0700_usb_id_table[61], NULL },
  3907. { NULL },
  3908. },
  3909. },
  3910. .rc.core = {
  3911. .rc_interval = DEFAULT_RC_INTERVAL,
  3912. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3913. .module_name = "dib0700",
  3914. .rc_query = dib0700_rc_query_old_firmware,
  3915. .allowed_protos = RC_BIT_RC5 |
  3916. RC_BIT_RC6_MCE |
  3917. RC_BIT_NEC,
  3918. .change_protocol = dib0700_change_protocol,
  3919. },
  3920. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3921. .num_adapters = 1,
  3922. .adapter = {
  3923. {
  3924. DIB0700_NUM_FRONTENDS(1),
  3925. .fe = {{
  3926. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  3927. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3928. .pid_filter_count = 32,
  3929. .pid_filter = stk80xx_pid_filter,
  3930. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  3931. .frontend_attach = stk809x_frontend_attach,
  3932. .tuner_attach = dib809x_tuner_attach,
  3933. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3934. }},
  3935. },
  3936. },
  3937. .num_device_descs = 1,
  3938. .devices = {
  3939. { "DiBcom STK8096GP reference design",
  3940. { &dib0700_usb_id_table[67], NULL },
  3941. { NULL },
  3942. },
  3943. },
  3944. .rc.core = {
  3945. .rc_interval = DEFAULT_RC_INTERVAL,
  3946. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3947. .module_name = "dib0700",
  3948. .rc_query = dib0700_rc_query_old_firmware,
  3949. .allowed_protos = RC_BIT_RC5 |
  3950. RC_BIT_RC6_MCE |
  3951. RC_BIT_NEC,
  3952. .change_protocol = dib0700_change_protocol,
  3953. },
  3954. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3955. .num_adapters = 1,
  3956. .adapter = {
  3957. {
  3958. DIB0700_NUM_FRONTENDS(1),
  3959. .fe = {{
  3960. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  3961. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3962. .pid_filter_count = 32,
  3963. .pid_filter = dib90x0_pid_filter,
  3964. .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
  3965. .frontend_attach = stk9090m_frontend_attach,
  3966. .tuner_attach = dib9090_tuner_attach,
  3967. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3968. }},
  3969. },
  3970. },
  3971. .num_device_descs = 1,
  3972. .devices = {
  3973. { "DiBcom STK9090M reference design",
  3974. { &dib0700_usb_id_table[69], NULL },
  3975. { NULL },
  3976. },
  3977. },
  3978. .rc.core = {
  3979. .rc_interval = DEFAULT_RC_INTERVAL,
  3980. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3981. .module_name = "dib0700",
  3982. .rc_query = dib0700_rc_query_old_firmware,
  3983. .allowed_protos = RC_BIT_RC5 |
  3984. RC_BIT_RC6_MCE |
  3985. RC_BIT_NEC,
  3986. .change_protocol = dib0700_change_protocol,
  3987. },
  3988. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3989. .num_adapters = 1,
  3990. .adapter = {
  3991. {
  3992. DIB0700_NUM_FRONTENDS(1),
  3993. .fe = {{
  3994. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  3995. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3996. .pid_filter_count = 32,
  3997. .pid_filter = stk80xx_pid_filter,
  3998. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  3999. .frontend_attach = nim8096md_frontend_attach,
  4000. .tuner_attach = nim8096md_tuner_attach,
  4001. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4002. }},
  4003. },
  4004. },
  4005. .num_device_descs = 1,
  4006. .devices = {
  4007. { "DiBcom NIM8096MD reference design",
  4008. { &dib0700_usb_id_table[70], NULL },
  4009. { NULL },
  4010. },
  4011. },
  4012. .rc.core = {
  4013. .rc_interval = DEFAULT_RC_INTERVAL,
  4014. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4015. .module_name = "dib0700",
  4016. .rc_query = dib0700_rc_query_old_firmware,
  4017. .allowed_protos = RC_BIT_RC5 |
  4018. RC_BIT_RC6_MCE |
  4019. RC_BIT_NEC,
  4020. .change_protocol = dib0700_change_protocol,
  4021. },
  4022. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4023. .num_adapters = 1,
  4024. .adapter = {
  4025. {
  4026. DIB0700_NUM_FRONTENDS(1),
  4027. .fe = {{
  4028. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4029. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4030. .pid_filter_count = 32,
  4031. .pid_filter = dib90x0_pid_filter,
  4032. .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
  4033. .frontend_attach = nim9090md_frontend_attach,
  4034. .tuner_attach = nim9090md_tuner_attach,
  4035. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4036. }},
  4037. },
  4038. },
  4039. .num_device_descs = 1,
  4040. .devices = {
  4041. { "DiBcom NIM9090MD reference design",
  4042. { &dib0700_usb_id_table[71], NULL },
  4043. { NULL },
  4044. },
  4045. },
  4046. .rc.core = {
  4047. .rc_interval = DEFAULT_RC_INTERVAL,
  4048. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4049. .module_name = "dib0700",
  4050. .rc_query = dib0700_rc_query_old_firmware,
  4051. .allowed_protos = RC_BIT_RC5 |
  4052. RC_BIT_RC6_MCE |
  4053. RC_BIT_NEC,
  4054. .change_protocol = dib0700_change_protocol,
  4055. },
  4056. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4057. .num_adapters = 1,
  4058. .adapter = {
  4059. {
  4060. DIB0700_NUM_FRONTENDS(1),
  4061. .fe = {{
  4062. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4063. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4064. .pid_filter_count = 32,
  4065. .pid_filter = stk70x0p_pid_filter,
  4066. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  4067. .frontend_attach = nim7090_frontend_attach,
  4068. .tuner_attach = nim7090_tuner_attach,
  4069. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4070. }},
  4071. },
  4072. },
  4073. .num_device_descs = 1,
  4074. .devices = {
  4075. { "DiBcom NIM7090 reference design",
  4076. { &dib0700_usb_id_table[72], NULL },
  4077. { NULL },
  4078. },
  4079. },
  4080. .rc.core = {
  4081. .rc_interval = DEFAULT_RC_INTERVAL,
  4082. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4083. .module_name = "dib0700",
  4084. .rc_query = dib0700_rc_query_old_firmware,
  4085. .allowed_protos = RC_BIT_RC5 |
  4086. RC_BIT_RC6_MCE |
  4087. RC_BIT_NEC,
  4088. .change_protocol = dib0700_change_protocol,
  4089. },
  4090. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4091. .num_adapters = 2,
  4092. .adapter = {
  4093. {
  4094. DIB0700_NUM_FRONTENDS(1),
  4095. .fe = {{
  4096. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4097. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4098. .pid_filter_count = 32,
  4099. .pid_filter = stk70x0p_pid_filter,
  4100. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  4101. .frontend_attach = tfe7090pvr_frontend0_attach,
  4102. .tuner_attach = tfe7090pvr_tuner0_attach,
  4103. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  4104. }},
  4105. },
  4106. {
  4107. DIB0700_NUM_FRONTENDS(1),
  4108. .fe = {{
  4109. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4110. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4111. .pid_filter_count = 32,
  4112. .pid_filter = stk70x0p_pid_filter,
  4113. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  4114. .frontend_attach = tfe7090pvr_frontend1_attach,
  4115. .tuner_attach = tfe7090pvr_tuner1_attach,
  4116. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4117. }},
  4118. },
  4119. },
  4120. .num_device_descs = 1,
  4121. .devices = {
  4122. { "DiBcom TFE7090PVR reference design",
  4123. { &dib0700_usb_id_table[73], NULL },
  4124. { NULL },
  4125. },
  4126. },
  4127. .rc.core = {
  4128. .rc_interval = DEFAULT_RC_INTERVAL,
  4129. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4130. .module_name = "dib0700",
  4131. .rc_query = dib0700_rc_query_old_firmware,
  4132. .allowed_protos = RC_BIT_RC5 |
  4133. RC_BIT_RC6_MCE |
  4134. RC_BIT_NEC,
  4135. .change_protocol = dib0700_change_protocol,
  4136. },
  4137. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4138. .num_adapters = 1,
  4139. .adapter = {
  4140. {
  4141. DIB0700_NUM_FRONTENDS(1),
  4142. .fe = {{
  4143. .frontend_attach = pctv340e_frontend_attach,
  4144. .tuner_attach = xc4000_tuner_attach,
  4145. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4146. }},
  4147. },
  4148. },
  4149. .num_device_descs = 2,
  4150. .devices = {
  4151. { "Pinnacle PCTV 340e HD Pro USB Stick",
  4152. { &dib0700_usb_id_table[76], NULL },
  4153. { NULL },
  4154. },
  4155. { "Pinnacle PCTV Hybrid Stick Solo",
  4156. { &dib0700_usb_id_table[77], NULL },
  4157. { NULL },
  4158. },
  4159. },
  4160. .rc.core = {
  4161. .rc_interval = DEFAULT_RC_INTERVAL,
  4162. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4163. .module_name = "dib0700",
  4164. .rc_query = dib0700_rc_query_old_firmware,
  4165. .allowed_protos = RC_BIT_RC5 |
  4166. RC_BIT_RC6_MCE |
  4167. RC_BIT_NEC,
  4168. .change_protocol = dib0700_change_protocol,
  4169. },
  4170. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4171. .num_adapters = 1,
  4172. .adapter = {
  4173. {
  4174. DIB0700_NUM_FRONTENDS(1),
  4175. .fe = {{
  4176. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4177. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4178. .pid_filter_count = 32,
  4179. .pid_filter = stk70x0p_pid_filter,
  4180. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  4181. .frontend_attach = tfe7790p_frontend_attach,
  4182. .tuner_attach = tfe7790p_tuner_attach,
  4183. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  4184. } },
  4185. },
  4186. },
  4187. .num_device_descs = 1,
  4188. .devices = {
  4189. { "DiBcom TFE7790P reference design",
  4190. { &dib0700_usb_id_table[78], NULL },
  4191. { NULL },
  4192. },
  4193. },
  4194. .rc.core = {
  4195. .rc_interval = DEFAULT_RC_INTERVAL,
  4196. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4197. .module_name = "dib0700",
  4198. .rc_query = dib0700_rc_query_old_firmware,
  4199. .allowed_protos = RC_BIT_RC5 |
  4200. RC_BIT_RC6_MCE |
  4201. RC_BIT_NEC,
  4202. .change_protocol = dib0700_change_protocol,
  4203. },
  4204. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4205. .num_adapters = 1,
  4206. .adapter = {
  4207. {
  4208. DIB0700_NUM_FRONTENDS(1),
  4209. .fe = {{
  4210. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4211. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4212. .pid_filter_count = 32,
  4213. .pid_filter = stk80xx_pid_filter,
  4214. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  4215. .frontend_attach = tfe8096p_frontend_attach,
  4216. .tuner_attach = tfe8096p_tuner_attach,
  4217. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4218. } },
  4219. },
  4220. },
  4221. .num_device_descs = 1,
  4222. .devices = {
  4223. { "DiBcom TFE8096P reference design",
  4224. { &dib0700_usb_id_table[79], NULL },
  4225. { NULL },
  4226. },
  4227. },
  4228. .rc.core = {
  4229. .rc_interval = DEFAULT_RC_INTERVAL,
  4230. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4231. .module_name = "dib0700",
  4232. .rc_query = dib0700_rc_query_old_firmware,
  4233. .allowed_protos = RC_BIT_RC5 |
  4234. RC_BIT_RC6_MCE |
  4235. RC_BIT_NEC,
  4236. .change_protocol = dib0700_change_protocol,
  4237. },
  4238. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4239. .num_adapters = 2,
  4240. .adapter = {
  4241. {
  4242. .num_frontends = 1,
  4243. .fe = {{
  4244. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4245. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4246. .pid_filter_count = 32,
  4247. .pid_filter = stk80xx_pid_filter,
  4248. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  4249. .frontend_attach = stk809x_frontend_attach,
  4250. .tuner_attach = dib809x_tuner_attach,
  4251. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4252. } },
  4253. .size_of_priv =
  4254. sizeof(struct dib0700_adapter_state),
  4255. }, {
  4256. .num_frontends = 1,
  4257. .fe = { {
  4258. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4259. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4260. .pid_filter_count = 32,
  4261. .pid_filter = stk80xx_pid_filter,
  4262. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  4263. .frontend_attach = stk809x_frontend1_attach,
  4264. .tuner_attach = dib809x_tuner_attach,
  4265. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  4266. } },
  4267. .size_of_priv =
  4268. sizeof(struct dib0700_adapter_state),
  4269. },
  4270. },
  4271. .num_device_descs = 1,
  4272. .devices = {
  4273. { "DiBcom STK8096-PVR reference design",
  4274. { &dib0700_usb_id_table[83],
  4275. &dib0700_usb_id_table[84], NULL},
  4276. { NULL },
  4277. },
  4278. },
  4279. .rc.core = {
  4280. .rc_interval = DEFAULT_RC_INTERVAL,
  4281. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4282. .module_name = "dib0700",
  4283. .rc_query = dib0700_rc_query_old_firmware,
  4284. .allowed_protos = RC_BIT_RC5 |
  4285. RC_BIT_RC6_MCE |
  4286. RC_BIT_NEC,
  4287. .change_protocol = dib0700_change_protocol,
  4288. },
  4289. },
  4290. };
  4291. int dib0700_device_count = ARRAY_SIZE(dib0700_devices);