dib0700_devices.c 138 KB

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