dib0700_devices.c 141 KB

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