dib0700_devices.c 141 KB

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