dib0700_devices.c 128 KB

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