dib0700_devices.c 108 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031
  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 *, struct dvb_frontend_parameters *);
  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_TYPE_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, struct dvb_frontend_parameters *fep)
  668. {
  669. struct dvb_usb_adapter *adap = fe->dvb->priv;
  670. struct dib0700_adapter_state *state = adap->priv;
  671. u16 offset;
  672. u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
  673. switch (band) {
  674. case BAND_VHF: offset = 950; break;
  675. case BAND_UHF:
  676. default: offset = 550; break;
  677. }
  678. deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
  679. dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
  680. return state->set_param_save(fe, fep);
  681. }
  682. static int dib7770_set_param_override(struct dvb_frontend *fe,
  683. struct dvb_frontend_parameters *fep)
  684. {
  685. struct dvb_usb_adapter *adap = fe->dvb->priv;
  686. struct dib0700_adapter_state *state = adap->priv;
  687. u16 offset;
  688. u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
  689. switch (band) {
  690. case BAND_VHF:
  691. dib7000p_set_gpio(fe, 0, 0, 1);
  692. offset = 850;
  693. break;
  694. case BAND_UHF:
  695. default:
  696. dib7000p_set_gpio(fe, 0, 0, 0);
  697. offset = 250;
  698. break;
  699. }
  700. deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));
  701. dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
  702. return state->set_param_save(fe, fep);
  703. }
  704. static int dib7770p_tuner_attach(struct dvb_usb_adapter *adap)
  705. {
  706. struct dib0700_adapter_state *st = adap->priv;
  707. struct i2c_adapter *tun_i2c = dib7000p_get_i2c_master(adap->fe_adap[0].fe,
  708. DIBX000_I2C_INTERFACE_TUNER, 1);
  709. if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
  710. &dib7770p_dib0070_config) == NULL)
  711. return -ENODEV;
  712. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  713. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7770_set_param_override;
  714. return 0;
  715. }
  716. static int dib7070p_tuner_attach(struct dvb_usb_adapter *adap)
  717. {
  718. struct dib0700_adapter_state *st = adap->priv;
  719. struct i2c_adapter *tun_i2c = dib7000p_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
  720. if (adap->id == 0) {
  721. if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[0]) == NULL)
  722. return -ENODEV;
  723. } else {
  724. if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[1]) == NULL)
  725. return -ENODEV;
  726. }
  727. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  728. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7070_set_param_override;
  729. return 0;
  730. }
  731. static int stk7700p_pid_filter(struct dvb_usb_adapter *adapter, int index,
  732. u16 pid, int onoff)
  733. {
  734. struct dib0700_state *st = adapter->dev->priv;
  735. if (st->is_dib7000pc)
  736. return dib7000p_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
  737. return dib7000m_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
  738. }
  739. static int stk7700p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
  740. {
  741. struct dib0700_state *st = adapter->dev->priv;
  742. if (st->is_dib7000pc)
  743. return dib7000p_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
  744. return dib7000m_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
  745. }
  746. static int stk70x0p_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
  747. {
  748. return dib7000p_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
  749. }
  750. static int stk70x0p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
  751. {
  752. return dib7000p_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
  753. }
  754. static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
  755. 60000, 15000,
  756. 1, 20, 3, 1, 0,
  757. 0, 0, 1, 1, 2,
  758. (3 << 14) | (1 << 12) | (524 << 0),
  759. (0 << 25) | 0,
  760. 20452225,
  761. 12000000,
  762. };
  763. static struct dib7000p_config dib7070p_dib7000p_config = {
  764. .output_mpeg2_in_188_bytes = 1,
  765. .agc_config_count = 1,
  766. .agc = &dib7070_agc_config,
  767. .bw = &dib7070_bw_config_12_mhz,
  768. .tuner_is_baseband = 1,
  769. .spur_protect = 1,
  770. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  771. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  772. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  773. .hostbus_diversity = 1,
  774. };
  775. /* STK7070P */
  776. static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap)
  777. {
  778. struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
  779. if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
  780. p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
  781. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  782. else
  783. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  784. msleep(10);
  785. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  786. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  787. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  788. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  789. dib0700_ctrl_clock(adap->dev, 72, 1);
  790. msleep(10);
  791. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  792. msleep(10);
  793. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  794. if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
  795. &dib7070p_dib7000p_config) != 0) {
  796. err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
  797. __func__);
  798. return -ENODEV;
  799. }
  800. adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
  801. &dib7070p_dib7000p_config);
  802. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  803. }
  804. /* STK7770P */
  805. static struct dib7000p_config dib7770p_dib7000p_config = {
  806. .output_mpeg2_in_188_bytes = 1,
  807. .agc_config_count = 1,
  808. .agc = &dib7070_agc_config,
  809. .bw = &dib7070_bw_config_12_mhz,
  810. .tuner_is_baseband = 1,
  811. .spur_protect = 1,
  812. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  813. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  814. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  815. .hostbus_diversity = 1,
  816. .enable_current_mirror = 1,
  817. .disable_sample_and_hold = 0,
  818. };
  819. static int stk7770p_frontend_attach(struct dvb_usb_adapter *adap)
  820. {
  821. struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
  822. if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
  823. p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
  824. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  825. else
  826. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  827. msleep(10);
  828. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  829. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  830. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  831. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  832. dib0700_ctrl_clock(adap->dev, 72, 1);
  833. msleep(10);
  834. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  835. msleep(10);
  836. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  837. if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
  838. &dib7770p_dib7000p_config) != 0) {
  839. err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
  840. __func__);
  841. return -ENODEV;
  842. }
  843. adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
  844. &dib7770p_dib7000p_config);
  845. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  846. }
  847. /* DIB807x generic */
  848. static struct dibx000_agc_config dib807x_agc_config[2] = {
  849. {
  850. BAND_VHF,
  851. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
  852. * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
  853. * P_agc_inv_pwm2=0,P_agc_inh_dc_rv_est=0,
  854. * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
  855. * P_agc_write=0 */
  856. (0 << 15) | (0 << 14) | (7 << 11) | (0 << 10) | (0 << 9) |
  857. (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
  858. (0 << 0), /* setup*/
  859. 600, /* inv_gain*/
  860. 10, /* time_stabiliz*/
  861. 0, /* alpha_level*/
  862. 118, /* thlock*/
  863. 0, /* wbd_inv*/
  864. 3530, /* wbd_ref*/
  865. 1, /* wbd_sel*/
  866. 5, /* wbd_alpha*/
  867. 65535, /* agc1_max*/
  868. 0, /* agc1_min*/
  869. 65535, /* agc2_max*/
  870. 0, /* agc2_min*/
  871. 0, /* agc1_pt1*/
  872. 40, /* agc1_pt2*/
  873. 183, /* agc1_pt3*/
  874. 206, /* agc1_slope1*/
  875. 255, /* agc1_slope2*/
  876. 72, /* agc2_pt1*/
  877. 152, /* agc2_pt2*/
  878. 88, /* agc2_slope1*/
  879. 90, /* agc2_slope2*/
  880. 17, /* alpha_mant*/
  881. 27, /* alpha_exp*/
  882. 23, /* beta_mant*/
  883. 51, /* beta_exp*/
  884. 0, /* perform_agc_softsplit*/
  885. }, {
  886. BAND_UHF,
  887. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0,
  888. * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0,
  889. * P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
  890. * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5,
  891. * P_agc_write=0 */
  892. (0 << 15) | (0 << 14) | (1 << 11) | (0 << 10) | (0 << 9) |
  893. (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) |
  894. (0 << 0), /* setup */
  895. 600, /* inv_gain*/
  896. 10, /* time_stabiliz*/
  897. 0, /* alpha_level*/
  898. 118, /* thlock*/
  899. 0, /* wbd_inv*/
  900. 3530, /* wbd_ref*/
  901. 1, /* wbd_sel*/
  902. 5, /* wbd_alpha*/
  903. 65535, /* agc1_max*/
  904. 0, /* agc1_min*/
  905. 65535, /* agc2_max*/
  906. 0, /* agc2_min*/
  907. 0, /* agc1_pt1*/
  908. 40, /* agc1_pt2*/
  909. 183, /* agc1_pt3*/
  910. 206, /* agc1_slope1*/
  911. 255, /* agc1_slope2*/
  912. 72, /* agc2_pt1*/
  913. 152, /* agc2_pt2*/
  914. 88, /* agc2_slope1*/
  915. 90, /* agc2_slope2*/
  916. 17, /* alpha_mant*/
  917. 27, /* alpha_exp*/
  918. 23, /* beta_mant*/
  919. 51, /* beta_exp*/
  920. 0, /* perform_agc_softsplit*/
  921. }
  922. };
  923. static struct dibx000_bandwidth_config dib807x_bw_config_12_mhz = {
  924. 60000, 15000, /* internal, sampling*/
  925. 1, 20, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass*/
  926. 0, 0, 1, 1, 2, /* misc: refdiv, bypclk_div, IO_CLK_en_core,
  927. ADClkSrc, modulo */
  928. (3 << 14) | (1 << 12) | (599 << 0), /* sad_cfg: refsel, sel, freq_15k*/
  929. (0 << 25) | 0, /* ifreq = 0.000000 MHz*/
  930. 18179755, /* timf*/
  931. 12000000, /* xtal_hz*/
  932. };
  933. static struct dib8000_config dib807x_dib8000_config[2] = {
  934. {
  935. .output_mpeg2_in_188_bytes = 1,
  936. .agc_config_count = 2,
  937. .agc = dib807x_agc_config,
  938. .pll = &dib807x_bw_config_12_mhz,
  939. .tuner_is_baseband = 1,
  940. .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
  941. .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
  942. .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
  943. .hostbus_diversity = 1,
  944. .div_cfg = 1,
  945. .agc_control = &dib0070_ctrl_agc_filter,
  946. .output_mode = OUTMODE_MPEG2_FIFO,
  947. .drives = 0x2d98,
  948. }, {
  949. .output_mpeg2_in_188_bytes = 1,
  950. .agc_config_count = 2,
  951. .agc = dib807x_agc_config,
  952. .pll = &dib807x_bw_config_12_mhz,
  953. .tuner_is_baseband = 1,
  954. .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
  955. .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
  956. .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
  957. .hostbus_diversity = 1,
  958. .agc_control = &dib0070_ctrl_agc_filter,
  959. .output_mode = OUTMODE_MPEG2_FIFO,
  960. .drives = 0x2d98,
  961. }
  962. };
  963. static int dib80xx_tuner_reset(struct dvb_frontend *fe, int onoff)
  964. {
  965. return dib8000_set_gpio(fe, 5, 0, !onoff);
  966. }
  967. static int dib80xx_tuner_sleep(struct dvb_frontend *fe, int onoff)
  968. {
  969. return dib8000_set_gpio(fe, 0, 0, onoff);
  970. }
  971. static const struct dib0070_wbd_gain_cfg dib8070_wbd_gain_cfg[] = {
  972. { 240, 7},
  973. { 0xffff, 6},
  974. };
  975. static struct dib0070_config dib807x_dib0070_config[2] = {
  976. {
  977. .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
  978. .reset = dib80xx_tuner_reset,
  979. .sleep = dib80xx_tuner_sleep,
  980. .clock_khz = 12000,
  981. .clock_pad_drive = 4,
  982. .vga_filter = 1,
  983. .force_crystal_mode = 1,
  984. .enable_third_order_filter = 1,
  985. .charge_pump = 0,
  986. .wbd_gain = dib8070_wbd_gain_cfg,
  987. .osc_buffer_state = 0,
  988. .freq_offset_khz_uhf = -100,
  989. .freq_offset_khz_vhf = -100,
  990. }, {
  991. .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
  992. .reset = dib80xx_tuner_reset,
  993. .sleep = dib80xx_tuner_sleep,
  994. .clock_khz = 12000,
  995. .clock_pad_drive = 2,
  996. .vga_filter = 1,
  997. .force_crystal_mode = 1,
  998. .enable_third_order_filter = 1,
  999. .charge_pump = 0,
  1000. .wbd_gain = dib8070_wbd_gain_cfg,
  1001. .osc_buffer_state = 0,
  1002. .freq_offset_khz_uhf = -25,
  1003. .freq_offset_khz_vhf = -25,
  1004. }
  1005. };
  1006. static int dib807x_set_param_override(struct dvb_frontend *fe,
  1007. struct dvb_frontend_parameters *fep)
  1008. {
  1009. struct dvb_usb_adapter *adap = fe->dvb->priv;
  1010. struct dib0700_adapter_state *state = adap->priv;
  1011. u16 offset = dib0070_wbd_offset(fe);
  1012. u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
  1013. switch (band) {
  1014. case BAND_VHF:
  1015. offset += 750;
  1016. break;
  1017. case BAND_UHF: /* fall-thru wanted */
  1018. default:
  1019. offset += 250; break;
  1020. }
  1021. deb_info("WBD for DiB8000: %d\n", offset);
  1022. dib8000_set_wbd_ref(fe, offset);
  1023. return state->set_param_save(fe, fep);
  1024. }
  1025. static int dib807x_tuner_attach(struct dvb_usb_adapter *adap)
  1026. {
  1027. struct dib0700_adapter_state *st = adap->priv;
  1028. struct i2c_adapter *tun_i2c = dib8000_get_i2c_master(adap->fe_adap[0].fe,
  1029. DIBX000_I2C_INTERFACE_TUNER, 1);
  1030. if (adap->id == 0) {
  1031. if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
  1032. &dib807x_dib0070_config[0]) == NULL)
  1033. return -ENODEV;
  1034. } else {
  1035. if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
  1036. &dib807x_dib0070_config[1]) == NULL)
  1037. return -ENODEV;
  1038. }
  1039. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  1040. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib807x_set_param_override;
  1041. return 0;
  1042. }
  1043. static int stk80xx_pid_filter(struct dvb_usb_adapter *adapter, int index,
  1044. u16 pid, int onoff)
  1045. {
  1046. return dib8000_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
  1047. }
  1048. static int stk80xx_pid_filter_ctrl(struct dvb_usb_adapter *adapter,
  1049. int onoff)
  1050. {
  1051. return dib8000_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
  1052. }
  1053. /* STK807x */
  1054. static int stk807x_frontend_attach(struct dvb_usb_adapter *adap)
  1055. {
  1056. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  1057. msleep(10);
  1058. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  1059. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  1060. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  1061. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  1062. dib0700_ctrl_clock(adap->dev, 72, 1);
  1063. msleep(10);
  1064. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  1065. msleep(10);
  1066. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  1067. dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
  1068. 0x80);
  1069. adap->fe_adap[0].fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80,
  1070. &dib807x_dib8000_config[0]);
  1071. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  1072. }
  1073. /* STK807xPVR */
  1074. static int stk807xpvr_frontend_attach0(struct dvb_usb_adapter *adap)
  1075. {
  1076. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  1077. msleep(30);
  1078. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  1079. msleep(500);
  1080. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  1081. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  1082. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  1083. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  1084. dib0700_ctrl_clock(adap->dev, 72, 1);
  1085. msleep(10);
  1086. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  1087. msleep(10);
  1088. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  1089. /* initialize IC 0 */
  1090. dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x22, 0x80);
  1091. adap->fe_adap[0].fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80,
  1092. &dib807x_dib8000_config[0]);
  1093. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  1094. }
  1095. static int stk807xpvr_frontend_attach1(struct dvb_usb_adapter *adap)
  1096. {
  1097. /* initialize IC 1 */
  1098. dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x12, 0x82);
  1099. adap->fe_adap[0].fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x82,
  1100. &dib807x_dib8000_config[1]);
  1101. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  1102. }
  1103. /* STK8096GP */
  1104. struct dibx000_agc_config dib8090_agc_config[2] = {
  1105. {
  1106. BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
  1107. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1,
  1108. * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
  1109. * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
  1110. (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
  1111. | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
  1112. 787,
  1113. 10,
  1114. 0,
  1115. 118,
  1116. 0,
  1117. 3530,
  1118. 1,
  1119. 5,
  1120. 65535,
  1121. 0,
  1122. 65535,
  1123. 0,
  1124. 0,
  1125. 32,
  1126. 114,
  1127. 143,
  1128. 144,
  1129. 114,
  1130. 227,
  1131. 116,
  1132. 117,
  1133. 28,
  1134. 26,
  1135. 31,
  1136. 51,
  1137. 0,
  1138. },
  1139. {
  1140. BAND_CBAND,
  1141. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1,
  1142. * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
  1143. * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
  1144. (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
  1145. | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
  1146. 787,
  1147. 10,
  1148. 0,
  1149. 118,
  1150. 0,
  1151. 3530,
  1152. 1,
  1153. 5,
  1154. 0,
  1155. 0,
  1156. 65535,
  1157. 0,
  1158. 0,
  1159. 32,
  1160. 114,
  1161. 143,
  1162. 144,
  1163. 114,
  1164. 227,
  1165. 116,
  1166. 117,
  1167. 28,
  1168. 26,
  1169. 31,
  1170. 51,
  1171. 0,
  1172. }
  1173. };
  1174. static struct dibx000_bandwidth_config dib8090_pll_config_12mhz = {
  1175. 54000, 13500,
  1176. 1, 18, 3, 1, 0,
  1177. 0, 0, 1, 1, 2,
  1178. (3 << 14) | (1 << 12) | (599 << 0),
  1179. (0 << 25) | 0,
  1180. 20199727,
  1181. 12000000,
  1182. };
  1183. static int dib8090_get_adc_power(struct dvb_frontend *fe)
  1184. {
  1185. return dib8000_get_adc_power(fe, 1);
  1186. }
  1187. static struct dib8000_config dib809x_dib8000_config[2] = {
  1188. {
  1189. .output_mpeg2_in_188_bytes = 1,
  1190. .agc_config_count = 2,
  1191. .agc = dib8090_agc_config,
  1192. .agc_control = dib0090_dcc_freq,
  1193. .pll = &dib8090_pll_config_12mhz,
  1194. .tuner_is_baseband = 1,
  1195. .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
  1196. .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
  1197. .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
  1198. .hostbus_diversity = 1,
  1199. .div_cfg = 0x31,
  1200. .output_mode = OUTMODE_MPEG2_FIFO,
  1201. .drives = 0x2d98,
  1202. .diversity_delay = 48,
  1203. .refclksel = 3,
  1204. }, {
  1205. .output_mpeg2_in_188_bytes = 1,
  1206. .agc_config_count = 2,
  1207. .agc = dib8090_agc_config,
  1208. .agc_control = dib0090_dcc_freq,
  1209. .pll = &dib8090_pll_config_12mhz,
  1210. .tuner_is_baseband = 1,
  1211. .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
  1212. .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
  1213. .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
  1214. .hostbus_diversity = 1,
  1215. .div_cfg = 0x31,
  1216. .output_mode = OUTMODE_DIVERSITY,
  1217. .drives = 0x2d08,
  1218. .diversity_delay = 1,
  1219. .refclksel = 3,
  1220. }
  1221. };
  1222. static struct dib0090_wbd_slope dib8090_wbd_table[] = {
  1223. /* max freq ; cold slope ; cold offset ; warm slope ; warm offset ; wbd gain */
  1224. { 120, 0, 500, 0, 500, 4 }, /* CBAND */
  1225. { 170, 0, 450, 0, 450, 4 }, /* CBAND */
  1226. { 380, 48, 373, 28, 259, 6 }, /* VHF */
  1227. { 860, 34, 700, 36, 616, 6 }, /* high UHF */
  1228. { 0xFFFF, 34, 700, 36, 616, 6 }, /* default */
  1229. };
  1230. static struct dib0090_config dib809x_dib0090_config = {
  1231. .io.pll_bypass = 1,
  1232. .io.pll_range = 1,
  1233. .io.pll_prediv = 1,
  1234. .io.pll_loopdiv = 20,
  1235. .io.adc_clock_ratio = 8,
  1236. .io.pll_int_loop_filt = 0,
  1237. .io.clock_khz = 12000,
  1238. .reset = dib80xx_tuner_reset,
  1239. .sleep = dib80xx_tuner_sleep,
  1240. .clkouttobamse = 1,
  1241. .analog_output = 1,
  1242. .i2c_address = DEFAULT_DIB0090_I2C_ADDRESS,
  1243. .use_pwm_agc = 1,
  1244. .clkoutdrive = 1,
  1245. .get_adc_power = dib8090_get_adc_power,
  1246. .freq_offset_khz_uhf = -63,
  1247. .freq_offset_khz_vhf = -143,
  1248. .wbd = dib8090_wbd_table,
  1249. .fref_clock_ratio = 6,
  1250. };
  1251. static int dib8096_set_param_override(struct dvb_frontend *fe,
  1252. struct dvb_frontend_parameters *fep)
  1253. {
  1254. struct dvb_usb_adapter *adap = fe->dvb->priv;
  1255. struct dib0700_adapter_state *state = adap->priv;
  1256. u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
  1257. u16 target;
  1258. int ret = 0;
  1259. enum frontend_tune_state tune_state = CT_SHUTDOWN;
  1260. u16 ltgain, rf_gain_limit;
  1261. ret = state->set_param_save(fe, fep);
  1262. if (ret < 0)
  1263. return ret;
  1264. target = (dib0090_get_wbd_offset(fe) * 8 * 18 / 33 + 1) / 2;
  1265. dib8000_set_wbd_ref(fe, target);
  1266. if (band == BAND_CBAND) {
  1267. deb_info("tuning in CBAND - soft-AGC startup\n");
  1268. dib0090_set_tune_state(fe, CT_AGC_START);
  1269. do {
  1270. ret = dib0090_gain_control(fe);
  1271. msleep(ret);
  1272. tune_state = dib0090_get_tune_state(fe);
  1273. if (tune_state == CT_AGC_STEP_0)
  1274. dib8000_set_gpio(fe, 6, 0, 1);
  1275. else if (tune_state == CT_AGC_STEP_1) {
  1276. dib0090_get_current_gain(fe, NULL, NULL, &rf_gain_limit, &ltgain);
  1277. if (rf_gain_limit == 0)
  1278. dib8000_set_gpio(fe, 6, 0, 0);
  1279. }
  1280. } while (tune_state < CT_AGC_STOP);
  1281. dib0090_pwm_gain_reset(fe);
  1282. dib8000_pwm_agc_reset(fe);
  1283. dib8000_set_tune_state(fe, CT_DEMOD_START);
  1284. } else {
  1285. deb_info("not tuning in CBAND - standard AGC startup\n");
  1286. dib0090_pwm_gain_reset(fe);
  1287. }
  1288. return 0;
  1289. }
  1290. static int dib809x_tuner_attach(struct dvb_usb_adapter *adap)
  1291. {
  1292. struct dib0700_adapter_state *st = adap->priv;
  1293. struct i2c_adapter *tun_i2c = dib8000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
  1294. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
  1295. return -ENODEV;
  1296. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  1297. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
  1298. return 0;
  1299. }
  1300. static int stk809x_frontend_attach(struct dvb_usb_adapter *adap)
  1301. {
  1302. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  1303. msleep(10);
  1304. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  1305. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  1306. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  1307. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  1308. dib0700_ctrl_clock(adap->dev, 72, 1);
  1309. msleep(10);
  1310. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  1311. msleep(10);
  1312. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  1313. dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 0x80);
  1314. adap->fe_adap[0].fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
  1315. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  1316. }
  1317. static int nim8096md_tuner_attach(struct dvb_usb_adapter *adap)
  1318. {
  1319. struct dib0700_adapter_state *st = adap->priv;
  1320. struct i2c_adapter *tun_i2c;
  1321. struct dvb_frontend *fe_slave = dib8000_get_slave_frontend(adap->fe_adap[0].fe, 1);
  1322. if (fe_slave) {
  1323. tun_i2c = dib8000_get_i2c_master(fe_slave, DIBX000_I2C_INTERFACE_TUNER, 1);
  1324. if (dvb_attach(dib0090_register, fe_slave, tun_i2c, &dib809x_dib0090_config) == NULL)
  1325. return -ENODEV;
  1326. fe_slave->dvb = adap->fe_adap[0].fe->dvb;
  1327. fe_slave->ops.tuner_ops.set_params = dib8096_set_param_override;
  1328. }
  1329. tun_i2c = dib8000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
  1330. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
  1331. return -ENODEV;
  1332. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  1333. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
  1334. return 0;
  1335. }
  1336. static int nim8096md_frontend_attach(struct dvb_usb_adapter *adap)
  1337. {
  1338. struct dvb_frontend *fe_slave;
  1339. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  1340. msleep(20);
  1341. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  1342. msleep(1000);
  1343. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  1344. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  1345. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  1346. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  1347. dib0700_ctrl_clock(adap->dev, 72, 1);
  1348. msleep(20);
  1349. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  1350. msleep(20);
  1351. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  1352. dib8000_i2c_enumeration(&adap->dev->i2c_adap, 2, 18, 0x80);
  1353. adap->fe_adap[0].fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]);
  1354. if (adap->fe_adap[0].fe == NULL)
  1355. return -ENODEV;
  1356. fe_slave = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]);
  1357. dib8000_set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
  1358. return fe_slave == NULL ? -ENODEV : 0;
  1359. }
  1360. /* STK9090M */
  1361. static int dib90x0_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
  1362. {
  1363. return dib9000_fw_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff);
  1364. }
  1365. static int dib90x0_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
  1366. {
  1367. return dib9000_fw_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff);
  1368. }
  1369. static int dib90x0_tuner_reset(struct dvb_frontend *fe, int onoff)
  1370. {
  1371. return dib9000_set_gpio(fe, 5, 0, !onoff);
  1372. }
  1373. static int dib90x0_tuner_sleep(struct dvb_frontend *fe, int onoff)
  1374. {
  1375. return dib9000_set_gpio(fe, 0, 0, onoff);
  1376. }
  1377. static int dib01x0_pmu_update(struct i2c_adapter *i2c, u16 *data, u8 len)
  1378. {
  1379. u8 wb[4] = { 0xc >> 8, 0xc & 0xff, 0, 0 };
  1380. u8 rb[2];
  1381. struct i2c_msg msg[2] = {
  1382. {.addr = 0x1e >> 1, .flags = 0, .buf = wb, .len = 2},
  1383. {.addr = 0x1e >> 1, .flags = I2C_M_RD, .buf = rb, .len = 2},
  1384. };
  1385. u8 index_data;
  1386. dibx000_i2c_set_speed(i2c, 250);
  1387. if (i2c_transfer(i2c, msg, 2) != 2)
  1388. return -EIO;
  1389. switch (rb[0] << 8 | rb[1]) {
  1390. case 0:
  1391. deb_info("Found DiB0170 rev1: This version of DiB0170 is not supported any longer.\n");
  1392. return -EIO;
  1393. case 1:
  1394. deb_info("Found DiB0170 rev2");
  1395. break;
  1396. case 2:
  1397. deb_info("Found DiB0190 rev2");
  1398. break;
  1399. default:
  1400. deb_info("DiB01x0 not found");
  1401. return -EIO;
  1402. }
  1403. for (index_data = 0; index_data < len; index_data += 2) {
  1404. wb[2] = (data[index_data + 1] >> 8) & 0xff;
  1405. wb[3] = (data[index_data + 1]) & 0xff;
  1406. if (data[index_data] == 0) {
  1407. wb[0] = (data[index_data] >> 8) & 0xff;
  1408. wb[1] = (data[index_data]) & 0xff;
  1409. msg[0].len = 2;
  1410. if (i2c_transfer(i2c, msg, 2) != 2)
  1411. return -EIO;
  1412. wb[2] |= rb[0];
  1413. wb[3] |= rb[1] & ~(3 << 4);
  1414. }
  1415. wb[0] = (data[index_data] >> 8)&0xff;
  1416. wb[1] = (data[index_data])&0xff;
  1417. msg[0].len = 4;
  1418. if (i2c_transfer(i2c, &msg[0], 1) != 1)
  1419. return -EIO;
  1420. }
  1421. return 0;
  1422. }
  1423. static struct dib9000_config stk9090m_config = {
  1424. .output_mpeg2_in_188_bytes = 1,
  1425. .output_mode = OUTMODE_MPEG2_FIFO,
  1426. .vcxo_timer = 279620,
  1427. .timing_frequency = 20452225,
  1428. .demod_clock_khz = 60000,
  1429. .xtal_clock_khz = 30000,
  1430. .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
  1431. .subband = {
  1432. 2,
  1433. {
  1434. { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0008 } }, /* GPIO 3 to 1 for VHF */
  1435. { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0000 } }, /* GPIO 3 to 0 for UHF */
  1436. { 0 },
  1437. },
  1438. },
  1439. .gpio_function = {
  1440. { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
  1441. { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
  1442. },
  1443. };
  1444. static struct dib9000_config nim9090md_config[2] = {
  1445. {
  1446. .output_mpeg2_in_188_bytes = 1,
  1447. .output_mode = OUTMODE_MPEG2_FIFO,
  1448. .vcxo_timer = 279620,
  1449. .timing_frequency = 20452225,
  1450. .demod_clock_khz = 60000,
  1451. .xtal_clock_khz = 30000,
  1452. .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
  1453. }, {
  1454. .output_mpeg2_in_188_bytes = 1,
  1455. .output_mode = OUTMODE_DIVERSITY,
  1456. .vcxo_timer = 279620,
  1457. .timing_frequency = 20452225,
  1458. .demod_clock_khz = 60000,
  1459. .xtal_clock_khz = 30000,
  1460. .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0),
  1461. .subband = {
  1462. 2,
  1463. {
  1464. { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0006 } }, /* GPIO 1 and 2 to 1 for VHF */
  1465. { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0000 } }, /* GPIO 1 and 2 to 0 for UHF */
  1466. { 0 },
  1467. },
  1468. },
  1469. .gpio_function = {
  1470. { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 },
  1471. { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 },
  1472. },
  1473. }
  1474. };
  1475. static struct dib0090_config dib9090_dib0090_config = {
  1476. .io.pll_bypass = 0,
  1477. .io.pll_range = 1,
  1478. .io.pll_prediv = 1,
  1479. .io.pll_loopdiv = 8,
  1480. .io.adc_clock_ratio = 8,
  1481. .io.pll_int_loop_filt = 0,
  1482. .io.clock_khz = 30000,
  1483. .reset = dib90x0_tuner_reset,
  1484. .sleep = dib90x0_tuner_sleep,
  1485. .clkouttobamse = 0,
  1486. .analog_output = 0,
  1487. .use_pwm_agc = 0,
  1488. .clkoutdrive = 0,
  1489. .freq_offset_khz_uhf = 0,
  1490. .freq_offset_khz_vhf = 0,
  1491. };
  1492. static struct dib0090_config nim9090md_dib0090_config[2] = {
  1493. {
  1494. .io.pll_bypass = 0,
  1495. .io.pll_range = 1,
  1496. .io.pll_prediv = 1,
  1497. .io.pll_loopdiv = 8,
  1498. .io.adc_clock_ratio = 8,
  1499. .io.pll_int_loop_filt = 0,
  1500. .io.clock_khz = 30000,
  1501. .reset = dib90x0_tuner_reset,
  1502. .sleep = dib90x0_tuner_sleep,
  1503. .clkouttobamse = 1,
  1504. .analog_output = 0,
  1505. .use_pwm_agc = 0,
  1506. .clkoutdrive = 0,
  1507. .freq_offset_khz_uhf = 0,
  1508. .freq_offset_khz_vhf = 0,
  1509. }, {
  1510. .io.pll_bypass = 0,
  1511. .io.pll_range = 1,
  1512. .io.pll_prediv = 1,
  1513. .io.pll_loopdiv = 8,
  1514. .io.adc_clock_ratio = 8,
  1515. .io.pll_int_loop_filt = 0,
  1516. .io.clock_khz = 30000,
  1517. .reset = dib90x0_tuner_reset,
  1518. .sleep = dib90x0_tuner_sleep,
  1519. .clkouttobamse = 0,
  1520. .analog_output = 0,
  1521. .use_pwm_agc = 0,
  1522. .clkoutdrive = 0,
  1523. .freq_offset_khz_uhf = 0,
  1524. .freq_offset_khz_vhf = 0,
  1525. }
  1526. };
  1527. static int stk9090m_frontend_attach(struct dvb_usb_adapter *adap)
  1528. {
  1529. struct dib0700_adapter_state *state = adap->priv;
  1530. struct dib0700_state *st = adap->dev->priv;
  1531. u32 fw_version;
  1532. /* Make use of the new i2c functions from FW 1.20 */
  1533. dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
  1534. if (fw_version >= 0x10200)
  1535. st->fw_use_new_i2c_api = 1;
  1536. dib0700_set_i2c_speed(adap->dev, 340);
  1537. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  1538. msleep(20);
  1539. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  1540. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  1541. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  1542. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  1543. dib0700_ctrl_clock(adap->dev, 72, 1);
  1544. msleep(20);
  1545. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  1546. msleep(20);
  1547. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  1548. dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80);
  1549. if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
  1550. deb_info("%s: Upload failed. (file not found?)\n", __func__);
  1551. return -ENODEV;
  1552. } else {
  1553. deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
  1554. }
  1555. stk9090m_config.microcode_B_fe_size = state->frontend_firmware->size;
  1556. stk9090m_config.microcode_B_fe_buffer = state->frontend_firmware->data;
  1557. adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &stk9090m_config);
  1558. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  1559. }
  1560. static int dib9090_tuner_attach(struct dvb_usb_adapter *adap)
  1561. {
  1562. struct dib0700_adapter_state *state = adap->priv;
  1563. struct i2c_adapter *i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
  1564. u16 data_dib190[10] = {
  1565. 1, 0x1374,
  1566. 2, 0x01a2,
  1567. 7, 0x0020,
  1568. 0, 0x00ef,
  1569. 8, 0x0486,
  1570. };
  1571. if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &dib9090_dib0090_config) == NULL)
  1572. return -ENODEV;
  1573. i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
  1574. if (dib01x0_pmu_update(i2c, data_dib190, 10) != 0)
  1575. return -ENODEV;
  1576. dib0700_set_i2c_speed(adap->dev, 2000);
  1577. if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
  1578. return -ENODEV;
  1579. release_firmware(state->frontend_firmware);
  1580. return 0;
  1581. }
  1582. static int nim9090md_frontend_attach(struct dvb_usb_adapter *adap)
  1583. {
  1584. struct dib0700_adapter_state *state = adap->priv;
  1585. struct dib0700_state *st = adap->dev->priv;
  1586. struct i2c_adapter *i2c;
  1587. struct dvb_frontend *fe_slave;
  1588. u32 fw_version;
  1589. /* Make use of the new i2c functions from FW 1.20 */
  1590. dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
  1591. if (fw_version >= 0x10200)
  1592. st->fw_use_new_i2c_api = 1;
  1593. dib0700_set_i2c_speed(adap->dev, 340);
  1594. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  1595. msleep(20);
  1596. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  1597. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  1598. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  1599. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  1600. dib0700_ctrl_clock(adap->dev, 72, 1);
  1601. msleep(20);
  1602. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  1603. msleep(20);
  1604. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  1605. if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
  1606. deb_info("%s: Upload failed. (file not found?)\n", __func__);
  1607. return -EIO;
  1608. } else {
  1609. deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size);
  1610. }
  1611. nim9090md_config[0].microcode_B_fe_size = state->frontend_firmware->size;
  1612. nim9090md_config[0].microcode_B_fe_buffer = state->frontend_firmware->data;
  1613. nim9090md_config[1].microcode_B_fe_size = state->frontend_firmware->size;
  1614. nim9090md_config[1].microcode_B_fe_buffer = state->frontend_firmware->data;
  1615. dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, 0x80);
  1616. adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &nim9090md_config[0]);
  1617. if (adap->fe_adap[0].fe == NULL)
  1618. return -ENODEV;
  1619. i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_3_4, 0);
  1620. dib9000_i2c_enumeration(i2c, 1, 0x12, 0x82);
  1621. fe_slave = dvb_attach(dib9000_attach, i2c, 0x82, &nim9090md_config[1]);
  1622. dib9000_set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
  1623. return fe_slave == NULL ? -ENODEV : 0;
  1624. }
  1625. static int nim9090md_tuner_attach(struct dvb_usb_adapter *adap)
  1626. {
  1627. struct dib0700_adapter_state *state = adap->priv;
  1628. struct i2c_adapter *i2c;
  1629. struct dvb_frontend *fe_slave;
  1630. u16 data_dib190[10] = {
  1631. 1, 0x5374,
  1632. 2, 0x01ae,
  1633. 7, 0x0020,
  1634. 0, 0x00ef,
  1635. 8, 0x0406,
  1636. };
  1637. i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
  1638. if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &nim9090md_dib0090_config[0]) == NULL)
  1639. return -ENODEV;
  1640. i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
  1641. if (dib01x0_pmu_update(i2c, data_dib190, 10) < 0)
  1642. return -ENODEV;
  1643. dib0700_set_i2c_speed(adap->dev, 2000);
  1644. if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
  1645. return -ENODEV;
  1646. fe_slave = dib9000_get_slave_frontend(adap->fe_adap[0].fe, 1);
  1647. if (fe_slave != NULL) {
  1648. i2c = dib9000_get_component_bus_interface(adap->fe_adap[0].fe);
  1649. dib9000_set_i2c_adapter(fe_slave, i2c);
  1650. i2c = dib9000_get_tuner_interface(fe_slave);
  1651. if (dvb_attach(dib0090_fw_register, fe_slave, i2c, &nim9090md_dib0090_config[1]) == NULL)
  1652. return -ENODEV;
  1653. fe_slave->dvb = adap->fe_adap[0].fe->dvb;
  1654. dib9000_fw_set_component_bus_speed(adap->fe_adap[0].fe, 2000);
  1655. if (dib9000_firmware_post_pll_init(fe_slave) < 0)
  1656. return -ENODEV;
  1657. }
  1658. release_firmware(state->frontend_firmware);
  1659. return 0;
  1660. }
  1661. /* NIM7090 */
  1662. struct dib7090p_best_adc {
  1663. u32 timf;
  1664. u32 pll_loopdiv;
  1665. u32 pll_prediv;
  1666. };
  1667. static int dib7090p_get_best_sampling(struct dvb_frontend *fe , struct dib7090p_best_adc *adc)
  1668. {
  1669. u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
  1670. u16 xtal = 12000;
  1671. u32 fcp_min = 1900; /* PLL Minimum Frequency comparator KHz */
  1672. u32 fcp_max = 20000; /* PLL Maximum Frequency comparator KHz */
  1673. u32 fdem_max = 76000;
  1674. u32 fdem_min = 69500;
  1675. u32 fcp = 0, fs = 0, fdem = 0;
  1676. u32 harmonic_id = 0;
  1677. adc->pll_loopdiv = loopdiv;
  1678. adc->pll_prediv = prediv;
  1679. adc->timf = 0;
  1680. deb_info("bandwidth = %d fdem_min =%d", fe->dtv_property_cache.bandwidth_hz, fdem_min);
  1681. /* Find Min and Max prediv */
  1682. while ((xtal/max_prediv) >= fcp_min)
  1683. max_prediv++;
  1684. max_prediv--;
  1685. min_prediv = max_prediv;
  1686. while ((xtal/min_prediv) <= fcp_max) {
  1687. min_prediv--;
  1688. if (min_prediv == 1)
  1689. break;
  1690. }
  1691. deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
  1692. min_prediv = 2;
  1693. for (prediv = min_prediv ; prediv < max_prediv; prediv++) {
  1694. fcp = xtal / prediv;
  1695. if (fcp > fcp_min && fcp < fcp_max) {
  1696. for (loopdiv = 1 ; loopdiv < 64 ; loopdiv++) {
  1697. fdem = ((xtal/prediv) * loopdiv);
  1698. fs = fdem / 4;
  1699. /* test min/max system restrictions */
  1700. if ((fdem >= fdem_min) && (fdem <= fdem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz/1000)) {
  1701. spur = 0;
  1702. /* test fs harmonics positions */
  1703. for (harmonic_id = (fe->dtv_property_cache.frequency / (1000*fs)) ; harmonic_id <= ((fe->dtv_property_cache.frequency / (1000*fs))+1) ; harmonic_id++) {
  1704. 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)))) {
  1705. spur = 1;
  1706. break;
  1707. }
  1708. }
  1709. if (!spur) {
  1710. adc->pll_loopdiv = loopdiv;
  1711. adc->pll_prediv = prediv;
  1712. adc->timf = 2396745143UL/fdem*(1 << 9);
  1713. adc->timf += ((2396745143UL%fdem) << 9)/fdem;
  1714. deb_info("loopdiv=%i prediv=%i timf=%i", loopdiv, prediv, adc->timf);
  1715. break;
  1716. }
  1717. }
  1718. }
  1719. }
  1720. if (!spur)
  1721. break;
  1722. }
  1723. if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
  1724. return -EINVAL;
  1725. else
  1726. return 0;
  1727. }
  1728. static int dib7090_agc_startup(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
  1729. {
  1730. struct dvb_usb_adapter *adap = fe->dvb->priv;
  1731. struct dib0700_adapter_state *state = adap->priv;
  1732. struct dibx000_bandwidth_config pll;
  1733. u16 target;
  1734. struct dib7090p_best_adc adc;
  1735. int ret;
  1736. ret = state->set_param_save(fe, fep);
  1737. if (ret < 0)
  1738. return ret;
  1739. memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
  1740. dib0090_pwm_gain_reset(fe);
  1741. target = (dib0090_get_wbd_offset(fe) * 8 + 1) / 2;
  1742. dib7000p_set_wbd_ref(fe, target);
  1743. if (dib7090p_get_best_sampling(fe, &adc) == 0) {
  1744. pll.pll_ratio = adc.pll_loopdiv;
  1745. pll.pll_prediv = adc.pll_prediv;
  1746. dib7000p_update_pll(fe, &pll);
  1747. dib7000p_ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
  1748. }
  1749. return 0;
  1750. }
  1751. static struct dib0090_wbd_slope dib7090_wbd_table[] = {
  1752. { 380, 81, 850, 64, 540, 4},
  1753. { 860, 51, 866, 21, 375, 4},
  1754. {1700, 0, 250, 0, 100, 6},
  1755. {2600, 0, 250, 0, 100, 6},
  1756. { 0xFFFF, 0, 0, 0, 0, 0},
  1757. };
  1758. struct dibx000_agc_config dib7090_agc_config[2] = {
  1759. {
  1760. .band_caps = BAND_UHF,
  1761. /* 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,
  1762. * 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 */
  1763. .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
  1764. .inv_gain = 687,
  1765. .time_stabiliz = 10,
  1766. .alpha_level = 0,
  1767. .thlock = 118,
  1768. .wbd_inv = 0,
  1769. .wbd_ref = 1200,
  1770. .wbd_sel = 3,
  1771. .wbd_alpha = 5,
  1772. .agc1_max = 65535,
  1773. .agc1_min = 0,
  1774. .agc2_max = 65535,
  1775. .agc2_min = 0,
  1776. .agc1_pt1 = 0,
  1777. .agc1_pt2 = 32,
  1778. .agc1_pt3 = 114,
  1779. .agc1_slope1 = 143,
  1780. .agc1_slope2 = 144,
  1781. .agc2_pt1 = 114,
  1782. .agc2_pt2 = 227,
  1783. .agc2_slope1 = 116,
  1784. .agc2_slope2 = 117,
  1785. .alpha_mant = 18,
  1786. .alpha_exp = 0,
  1787. .beta_mant = 20,
  1788. .beta_exp = 59,
  1789. .perform_agc_softsplit = 0,
  1790. } , {
  1791. .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
  1792. /* 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,
  1793. * 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 */
  1794. .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
  1795. .inv_gain = 732,
  1796. .time_stabiliz = 10,
  1797. .alpha_level = 0,
  1798. .thlock = 118,
  1799. .wbd_inv = 0,
  1800. .wbd_ref = 1200,
  1801. .wbd_sel = 3,
  1802. .wbd_alpha = 5,
  1803. .agc1_max = 65535,
  1804. .agc1_min = 0,
  1805. .agc2_max = 65535,
  1806. .agc2_min = 0,
  1807. .agc1_pt1 = 0,
  1808. .agc1_pt2 = 0,
  1809. .agc1_pt3 = 98,
  1810. .agc1_slope1 = 0,
  1811. .agc1_slope2 = 167,
  1812. .agc2_pt1 = 98,
  1813. .agc2_pt2 = 255,
  1814. .agc2_slope1 = 104,
  1815. .agc2_slope2 = 0,
  1816. .alpha_mant = 18,
  1817. .alpha_exp = 0,
  1818. .beta_mant = 20,
  1819. .beta_exp = 59,
  1820. .perform_agc_softsplit = 0,
  1821. }
  1822. };
  1823. static struct dibx000_bandwidth_config dib7090_clock_config_12_mhz = {
  1824. 60000, 15000,
  1825. 1, 5, 0, 0, 0,
  1826. 0, 0, 1, 1, 2,
  1827. (3 << 14) | (1 << 12) | (524 << 0),
  1828. (0 << 25) | 0,
  1829. 20452225,
  1830. 15000000,
  1831. };
  1832. static struct dib7000p_config nim7090_dib7000p_config = {
  1833. .output_mpeg2_in_188_bytes = 1,
  1834. .hostbus_diversity = 1,
  1835. .tuner_is_baseband = 1,
  1836. .update_lna = NULL,
  1837. .agc_config_count = 2,
  1838. .agc = dib7090_agc_config,
  1839. .bw = &dib7090_clock_config_12_mhz,
  1840. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  1841. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  1842. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  1843. .pwm_freq_div = 0,
  1844. .agc_control = dib7090_agc_restart,
  1845. .spur_protect = 0,
  1846. .disable_sample_and_hold = 0,
  1847. .enable_current_mirror = 0,
  1848. .diversity_delay = 0,
  1849. .output_mode = OUTMODE_MPEG2_FIFO,
  1850. .enMpegOutput = 1,
  1851. };
  1852. static struct dib7000p_config tfe7090pvr_dib7000p_config[2] = {
  1853. {
  1854. .output_mpeg2_in_188_bytes = 1,
  1855. .hostbus_diversity = 1,
  1856. .tuner_is_baseband = 1,
  1857. .update_lna = NULL,
  1858. .agc_config_count = 2,
  1859. .agc = dib7090_agc_config,
  1860. .bw = &dib7090_clock_config_12_mhz,
  1861. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  1862. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  1863. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  1864. .pwm_freq_div = 0,
  1865. .agc_control = dib7090_agc_restart,
  1866. .spur_protect = 0,
  1867. .disable_sample_and_hold = 0,
  1868. .enable_current_mirror = 0,
  1869. .diversity_delay = 0,
  1870. .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
  1871. .default_i2c_addr = 0x90,
  1872. .enMpegOutput = 1,
  1873. }, {
  1874. .output_mpeg2_in_188_bytes = 1,
  1875. .hostbus_diversity = 1,
  1876. .tuner_is_baseband = 1,
  1877. .update_lna = NULL,
  1878. .agc_config_count = 2,
  1879. .agc = dib7090_agc_config,
  1880. .bw = &dib7090_clock_config_12_mhz,
  1881. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  1882. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  1883. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  1884. .pwm_freq_div = 0,
  1885. .agc_control = dib7090_agc_restart,
  1886. .spur_protect = 0,
  1887. .disable_sample_and_hold = 0,
  1888. .enable_current_mirror = 0,
  1889. .diversity_delay = 0,
  1890. .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
  1891. .default_i2c_addr = 0x92,
  1892. .enMpegOutput = 0,
  1893. }
  1894. };
  1895. static const struct dib0090_config nim7090_dib0090_config = {
  1896. .io.clock_khz = 12000,
  1897. .io.pll_bypass = 0,
  1898. .io.pll_range = 0,
  1899. .io.pll_prediv = 3,
  1900. .io.pll_loopdiv = 6,
  1901. .io.adc_clock_ratio = 0,
  1902. .io.pll_int_loop_filt = 0,
  1903. .reset = dib7090_tuner_sleep,
  1904. .sleep = dib7090_tuner_sleep,
  1905. .freq_offset_khz_uhf = 0,
  1906. .freq_offset_khz_vhf = 0,
  1907. .get_adc_power = dib7090_get_adc_power,
  1908. .clkouttobamse = 1,
  1909. .analog_output = 0,
  1910. .wbd_vhf_offset = 0,
  1911. .wbd_cband_offset = 0,
  1912. .use_pwm_agc = 1,
  1913. .clkoutdrive = 0,
  1914. .fref_clock_ratio = 0,
  1915. .wbd = dib7090_wbd_table,
  1916. .ls_cfg_pad_drv = 0,
  1917. .data_tx_drv = 0,
  1918. .low_if = NULL,
  1919. .in_soc = 1,
  1920. };
  1921. static const struct dib0090_config tfe7090pvr_dib0090_config[2] = {
  1922. {
  1923. .io.clock_khz = 12000,
  1924. .io.pll_bypass = 0,
  1925. .io.pll_range = 0,
  1926. .io.pll_prediv = 3,
  1927. .io.pll_loopdiv = 6,
  1928. .io.adc_clock_ratio = 0,
  1929. .io.pll_int_loop_filt = 0,
  1930. .reset = dib7090_tuner_sleep,
  1931. .sleep = dib7090_tuner_sleep,
  1932. .freq_offset_khz_uhf = 50,
  1933. .freq_offset_khz_vhf = 70,
  1934. .get_adc_power = dib7090_get_adc_power,
  1935. .clkouttobamse = 1,
  1936. .analog_output = 0,
  1937. .wbd_vhf_offset = 0,
  1938. .wbd_cband_offset = 0,
  1939. .use_pwm_agc = 1,
  1940. .clkoutdrive = 0,
  1941. .fref_clock_ratio = 0,
  1942. .wbd = dib7090_wbd_table,
  1943. .ls_cfg_pad_drv = 0,
  1944. .data_tx_drv = 0,
  1945. .low_if = NULL,
  1946. .in_soc = 1,
  1947. }, {
  1948. .io.clock_khz = 12000,
  1949. .io.pll_bypass = 0,
  1950. .io.pll_range = 0,
  1951. .io.pll_prediv = 3,
  1952. .io.pll_loopdiv = 6,
  1953. .io.adc_clock_ratio = 0,
  1954. .io.pll_int_loop_filt = 0,
  1955. .reset = dib7090_tuner_sleep,
  1956. .sleep = dib7090_tuner_sleep,
  1957. .freq_offset_khz_uhf = -50,
  1958. .freq_offset_khz_vhf = -70,
  1959. .get_adc_power = dib7090_get_adc_power,
  1960. .clkouttobamse = 1,
  1961. .analog_output = 0,
  1962. .wbd_vhf_offset = 0,
  1963. .wbd_cband_offset = 0,
  1964. .use_pwm_agc = 1,
  1965. .clkoutdrive = 0,
  1966. .fref_clock_ratio = 0,
  1967. .wbd = dib7090_wbd_table,
  1968. .ls_cfg_pad_drv = 0,
  1969. .data_tx_drv = 0,
  1970. .low_if = NULL,
  1971. .in_soc = 1,
  1972. }
  1973. };
  1974. static int nim7090_frontend_attach(struct dvb_usb_adapter *adap)
  1975. {
  1976. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  1977. msleep(20);
  1978. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  1979. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  1980. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  1981. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  1982. msleep(20);
  1983. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  1984. msleep(20);
  1985. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  1986. if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, &nim7090_dib7000p_config) != 0) {
  1987. err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__);
  1988. return -ENODEV;
  1989. }
  1990. adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &nim7090_dib7000p_config);
  1991. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  1992. }
  1993. static int nim7090_tuner_attach(struct dvb_usb_adapter *adap)
  1994. {
  1995. struct dib0700_adapter_state *st = adap->priv;
  1996. struct i2c_adapter *tun_i2c = dib7090_get_i2c_tuner(adap->fe_adap[0].fe);
  1997. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &nim7090_dib0090_config) == NULL)
  1998. return -ENODEV;
  1999. dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  2000. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  2001. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
  2002. return 0;
  2003. }
  2004. static int tfe7090pvr_frontend0_attach(struct dvb_usb_adapter *adap)
  2005. {
  2006. struct dib0700_state *st = adap->dev->priv;
  2007. /* The TFE7090 requires the dib0700 to not be in master mode */
  2008. st->disable_streaming_master_mode = 1;
  2009. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2010. msleep(20);
  2011. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2012. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2013. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2014. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2015. msleep(20);
  2016. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2017. msleep(20);
  2018. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2019. /* initialize IC 0 */
  2020. if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, &tfe7090pvr_dib7000p_config[0]) != 0) {
  2021. err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__);
  2022. return -ENODEV;
  2023. }
  2024. dib0700_set_i2c_speed(adap->dev, 340);
  2025. adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x90, &tfe7090pvr_dib7000p_config[0]);
  2026. if (adap->fe_adap[0].fe == NULL)
  2027. return -ENODEV;
  2028. dib7090_slave_reset(adap->fe_adap[0].fe);
  2029. return 0;
  2030. }
  2031. static int tfe7090pvr_frontend1_attach(struct dvb_usb_adapter *adap)
  2032. {
  2033. struct i2c_adapter *i2c;
  2034. if (adap->dev->adapter[0].fe_adap[0].fe == NULL) {
  2035. err("the master dib7090 has to be initialized first");
  2036. return -ENODEV; /* the master device has not been initialized */
  2037. }
  2038. i2c = dib7000p_get_i2c_master(adap->dev->adapter[0].fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_6_7, 1);
  2039. if (dib7000p_i2c_enumeration(i2c, 1, 0x10, &tfe7090pvr_dib7000p_config[1]) != 0) {
  2040. err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__);
  2041. return -ENODEV;
  2042. }
  2043. adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, i2c, 0x92, &tfe7090pvr_dib7000p_config[1]);
  2044. dib0700_set_i2c_speed(adap->dev, 200);
  2045. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2046. }
  2047. static int tfe7090pvr_tuner0_attach(struct dvb_usb_adapter *adap)
  2048. {
  2049. struct dib0700_adapter_state *st = adap->priv;
  2050. struct i2c_adapter *tun_i2c = dib7090_get_i2c_tuner(adap->fe_adap[0].fe);
  2051. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[0]) == NULL)
  2052. return -ENODEV;
  2053. dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  2054. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  2055. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
  2056. return 0;
  2057. }
  2058. static int tfe7090pvr_tuner1_attach(struct dvb_usb_adapter *adap)
  2059. {
  2060. struct dib0700_adapter_state *st = adap->priv;
  2061. struct i2c_adapter *tun_i2c = dib7090_get_i2c_tuner(adap->fe_adap[0].fe);
  2062. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[1]) == NULL)
  2063. return -ENODEV;
  2064. dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  2065. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  2066. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
  2067. return 0;
  2068. }
  2069. /* STK7070PD */
  2070. static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
  2071. {
  2072. .output_mpeg2_in_188_bytes = 1,
  2073. .agc_config_count = 1,
  2074. .agc = &dib7070_agc_config,
  2075. .bw = &dib7070_bw_config_12_mhz,
  2076. .tuner_is_baseband = 1,
  2077. .spur_protect = 1,
  2078. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2079. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2080. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2081. .hostbus_diversity = 1,
  2082. }, {
  2083. .output_mpeg2_in_188_bytes = 1,
  2084. .agc_config_count = 1,
  2085. .agc = &dib7070_agc_config,
  2086. .bw = &dib7070_bw_config_12_mhz,
  2087. .tuner_is_baseband = 1,
  2088. .spur_protect = 1,
  2089. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2090. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2091. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2092. .hostbus_diversity = 1,
  2093. }
  2094. };
  2095. static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
  2096. {
  2097. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2098. msleep(10);
  2099. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2100. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2101. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2102. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2103. dib0700_ctrl_clock(adap->dev, 72, 1);
  2104. msleep(10);
  2105. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2106. msleep(10);
  2107. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2108. if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
  2109. stk7070pd_dib7000p_config) != 0) {
  2110. err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n",
  2111. __func__);
  2112. return -ENODEV;
  2113. }
  2114. adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &stk7070pd_dib7000p_config[0]);
  2115. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2116. }
  2117. static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
  2118. {
  2119. adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x82, &stk7070pd_dib7000p_config[1]);
  2120. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2121. }
  2122. /* S5H1411 */
  2123. static struct s5h1411_config pinnacle_801e_config = {
  2124. .output_mode = S5H1411_PARALLEL_OUTPUT,
  2125. .gpio = S5H1411_GPIO_OFF,
  2126. .mpeg_timing = S5H1411_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
  2127. .qam_if = S5H1411_IF_44000,
  2128. .vsb_if = S5H1411_IF_44000,
  2129. .inversion = S5H1411_INVERSION_OFF,
  2130. .status_mode = S5H1411_DEMODLOCKING
  2131. };
  2132. /* Pinnacle PCTV HD Pro 801e GPIOs map:
  2133. GPIO0 - currently unknown
  2134. GPIO1 - xc5000 tuner reset
  2135. GPIO2 - CX25843 sleep
  2136. GPIO3 - currently unknown
  2137. GPIO4 - currently unknown
  2138. GPIO6 - currently unknown
  2139. GPIO7 - currently unknown
  2140. GPIO9 - currently unknown
  2141. GPIO10 - CX25843 reset
  2142. */
  2143. static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap)
  2144. {
  2145. struct dib0700_state *st = adap->dev->priv;
  2146. /* Make use of the new i2c functions from FW 1.20 */
  2147. st->fw_use_new_i2c_api = 1;
  2148. /* The s5h1411 requires the dib0700 to not be in master mode */
  2149. st->disable_streaming_master_mode = 1;
  2150. /* All msleep values taken from Windows USB trace */
  2151. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
  2152. dib0700_set_gpio(adap->dev, GPIO3, GPIO_OUT, 0);
  2153. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2154. msleep(400);
  2155. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2156. msleep(60);
  2157. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2158. msleep(30);
  2159. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2160. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2161. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2162. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2163. dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 0);
  2164. msleep(30);
  2165. /* Put the CX25843 to sleep for now since we're in digital mode */
  2166. dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
  2167. /* GPIOs are initialized, do the attach */
  2168. adap->fe_adap[0].fe = dvb_attach(s5h1411_attach, &pinnacle_801e_config,
  2169. &adap->dev->i2c_adap);
  2170. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2171. }
  2172. static int dib0700_xc5000_tuner_callback(void *priv, int component,
  2173. int command, int arg)
  2174. {
  2175. struct dvb_usb_adapter *adap = priv;
  2176. if (command == XC5000_TUNER_RESET) {
  2177. /* Reset the tuner */
  2178. dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 0);
  2179. msleep(10);
  2180. dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 1);
  2181. msleep(10);
  2182. } else {
  2183. err("xc5000: unknown tuner callback command: %d\n", command);
  2184. return -EINVAL;
  2185. }
  2186. return 0;
  2187. }
  2188. static struct xc5000_config s5h1411_xc5000_tunerconfig = {
  2189. .i2c_address = 0x64,
  2190. .if_khz = 5380,
  2191. };
  2192. static int xc5000_tuner_attach(struct dvb_usb_adapter *adap)
  2193. {
  2194. /* FIXME: generalize & move to common area */
  2195. adap->fe_adap[0].fe->callback = dib0700_xc5000_tuner_callback;
  2196. return dvb_attach(xc5000_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap,
  2197. &s5h1411_xc5000_tunerconfig)
  2198. == NULL ? -ENODEV : 0;
  2199. }
  2200. static int dib0700_xc4000_tuner_callback(void *priv, int component,
  2201. int command, int arg)
  2202. {
  2203. struct dvb_usb_adapter *adap = priv;
  2204. if (command == XC4000_TUNER_RESET) {
  2205. /* Reset the tuner */
  2206. dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
  2207. msleep(10);
  2208. dib7000p_set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  2209. } else {
  2210. err("xc4000: unknown tuner callback command: %d\n", command);
  2211. return -EINVAL;
  2212. }
  2213. return 0;
  2214. }
  2215. static struct dibx000_agc_config stk7700p_7000p_xc4000_agc_config = {
  2216. .band_caps = BAND_UHF | BAND_VHF,
  2217. .setup = 0x64,
  2218. .inv_gain = 0x02c8,
  2219. .time_stabiliz = 0x15,
  2220. .alpha_level = 0x00,
  2221. .thlock = 0x76,
  2222. .wbd_inv = 0x01,
  2223. .wbd_ref = 0x0b33,
  2224. .wbd_sel = 0x00,
  2225. .wbd_alpha = 0x02,
  2226. .agc1_max = 0x00,
  2227. .agc1_min = 0x00,
  2228. .agc2_max = 0x9b26,
  2229. .agc2_min = 0x26ca,
  2230. .agc1_pt1 = 0x00,
  2231. .agc1_pt2 = 0x00,
  2232. .agc1_pt3 = 0x00,
  2233. .agc1_slope1 = 0x00,
  2234. .agc1_slope2 = 0x00,
  2235. .agc2_pt1 = 0x00,
  2236. .agc2_pt2 = 0x80,
  2237. .agc2_slope1 = 0x1d,
  2238. .agc2_slope2 = 0x1d,
  2239. .alpha_mant = 0x11,
  2240. .alpha_exp = 0x1b,
  2241. .beta_mant = 0x17,
  2242. .beta_exp = 0x33,
  2243. .perform_agc_softsplit = 0x00,
  2244. };
  2245. static struct dibx000_bandwidth_config stk7700p_xc4000_pll_config = {
  2246. 60000, 30000, /* internal, sampling */
  2247. 1, 8, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass */
  2248. 0, 0, 1, 1, 0, /* misc: refdiv, bypclk_div, IO_CLK_en_core, */
  2249. /* ADClkSrc, modulo */
  2250. (3 << 14) | (1 << 12) | 524, /* sad_cfg: refsel, sel, freq_15k */
  2251. 39370534, /* ifreq */
  2252. 20452225, /* timf */
  2253. 30000000 /* xtal */
  2254. };
  2255. /* FIXME: none of these inputs are validated yet */
  2256. static struct dib7000p_config pctv_340e_config = {
  2257. .output_mpeg2_in_188_bytes = 1,
  2258. .agc_config_count = 1,
  2259. .agc = &stk7700p_7000p_xc4000_agc_config,
  2260. .bw = &stk7700p_xc4000_pll_config,
  2261. .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
  2262. .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
  2263. .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
  2264. };
  2265. /* PCTV 340e GPIOs map:
  2266. dib0700:
  2267. GPIO2 - CX25843 sleep
  2268. GPIO3 - CS5340 reset
  2269. GPIO5 - IRD
  2270. GPIO6 - Power Supply
  2271. GPIO8 - LNA (1=off 0=on)
  2272. GPIO10 - CX25843 reset
  2273. dib7000:
  2274. GPIO8 - xc4000 reset
  2275. */
  2276. static int pctv340e_frontend_attach(struct dvb_usb_adapter *adap)
  2277. {
  2278. struct dib0700_state *st = adap->dev->priv;
  2279. /* Power Supply on */
  2280. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  2281. msleep(50);
  2282. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2283. msleep(100); /* Allow power supply to settle before probing */
  2284. /* cx25843 reset */
  2285. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2286. msleep(1); /* cx25843 datasheet say 350us required */
  2287. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2288. /* LNA off for now */
  2289. dib0700_set_gpio(adap->dev, GPIO8, GPIO_OUT, 1);
  2290. /* Put the CX25843 to sleep for now since we're in digital mode */
  2291. dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
  2292. /* FIXME: not verified yet */
  2293. dib0700_ctrl_clock(adap->dev, 72, 1);
  2294. msleep(500);
  2295. if (dib7000pc_detection(&adap->dev->i2c_adap) == 0) {
  2296. /* Demodulator not found for some reason? */
  2297. return -ENODEV;
  2298. }
  2299. adap->fe_adap[0].fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x12,
  2300. &pctv_340e_config);
  2301. st->is_dib7000pc = 1;
  2302. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2303. }
  2304. static struct xc4000_config dib7000p_xc4000_tunerconfig = {
  2305. .i2c_address = 0x61,
  2306. .default_pm = 1,
  2307. .dvb_amplitude = 0,
  2308. .set_smoothedcvbs = 0,
  2309. .if_khz = 5400
  2310. };
  2311. static int xc4000_tuner_attach(struct dvb_usb_adapter *adap)
  2312. {
  2313. struct i2c_adapter *tun_i2c;
  2314. /* The xc4000 is not on the main i2c bus */
  2315. tun_i2c = dib7000p_get_i2c_master(adap->fe_adap[0].fe,
  2316. DIBX000_I2C_INTERFACE_TUNER, 1);
  2317. if (tun_i2c == NULL) {
  2318. printk(KERN_ERR "Could not reach tuner i2c bus\n");
  2319. return 0;
  2320. }
  2321. /* Setup the reset callback */
  2322. adap->fe_adap[0].fe->callback = dib0700_xc4000_tuner_callback;
  2323. return dvb_attach(xc4000_attach, adap->fe_adap[0].fe, tun_i2c,
  2324. &dib7000p_xc4000_tunerconfig)
  2325. == NULL ? -ENODEV : 0;
  2326. }
  2327. static struct lgdt3305_config hcw_lgdt3305_config = {
  2328. .i2c_addr = 0x0e,
  2329. .mpeg_mode = LGDT3305_MPEG_PARALLEL,
  2330. .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
  2331. .tpvalid_polarity = LGDT3305_TP_VALID_LOW,
  2332. .deny_i2c_rptr = 0,
  2333. .spectral_inversion = 1,
  2334. .qam_if_khz = 6000,
  2335. .vsb_if_khz = 6000,
  2336. .usref_8vsb = 0x0500,
  2337. };
  2338. static struct mxl5007t_config hcw_mxl5007t_config = {
  2339. .xtal_freq_hz = MxL_XTAL_25_MHZ,
  2340. .if_freq_hz = MxL_IF_6_MHZ,
  2341. .invert_if = 1,
  2342. };
  2343. /* TIGER-ATSC map:
  2344. GPIO0 - LNA_CTR (H: LNA power enabled, L: LNA power disabled)
  2345. GPIO1 - ANT_SEL (H: VPA, L: MCX)
  2346. GPIO4 - SCL2
  2347. GPIO6 - EN_TUNER
  2348. GPIO7 - SDA2
  2349. GPIO10 - DEM_RST
  2350. MXL is behind LG's i2c repeater. LG is on SCL2/SDA2 gpios on the DIB
  2351. */
  2352. static int lgdt3305_frontend_attach(struct dvb_usb_adapter *adap)
  2353. {
  2354. struct dib0700_state *st = adap->dev->priv;
  2355. /* Make use of the new i2c functions from FW 1.20 */
  2356. st->fw_use_new_i2c_api = 1;
  2357. st->disable_streaming_master_mode = 1;
  2358. /* fe power enable */
  2359. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  2360. msleep(30);
  2361. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2362. msleep(30);
  2363. /* demod reset */
  2364. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2365. msleep(30);
  2366. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2367. msleep(30);
  2368. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2369. msleep(30);
  2370. adap->fe_adap[0].fe = dvb_attach(lgdt3305_attach,
  2371. &hcw_lgdt3305_config,
  2372. &adap->dev->i2c_adap);
  2373. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2374. }
  2375. static int mxl5007t_tuner_attach(struct dvb_usb_adapter *adap)
  2376. {
  2377. return dvb_attach(mxl5007t_attach, adap->fe_adap[0].fe,
  2378. &adap->dev->i2c_adap, 0x60,
  2379. &hcw_mxl5007t_config) == NULL ? -ENODEV : 0;
  2380. }
  2381. /* DVB-USB and USB stuff follows */
  2382. struct usb_device_id dib0700_usb_id_table[] = {
  2383. /* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
  2384. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) },
  2385. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
  2386. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
  2387. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
  2388. /* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
  2389. { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) },
  2390. { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) },
  2391. { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
  2392. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
  2393. /* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
  2394. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) },
  2395. { USB_DEVICE(USB_VID_TERRATEC,
  2396. USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
  2397. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
  2398. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) },
  2399. /* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) },
  2400. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) },
  2401. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) },
  2402. { USB_DEVICE(USB_VID_PINNACLE,
  2403. USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) },
  2404. { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500_PC) },
  2405. /* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) },
  2406. { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U7000) },
  2407. { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) },
  2408. { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000) },
  2409. { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100) },
  2410. /* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) },
  2411. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) },
  2412. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_USB_XE) },
  2413. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_EXPRESSCARD_320CX) },
  2414. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV72E) },
  2415. /* 30 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73E) },
  2416. { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_EC372S) },
  2417. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) },
  2418. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) },
  2419. { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) },
  2420. /* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) },
  2421. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_3) },
  2422. { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U8000) },
  2423. { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700PH) },
  2424. { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) },
  2425. /* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) },
  2426. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) },
  2427. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_EXPRESS) },
  2428. { USB_DEVICE(USB_VID_TERRATEC,
  2429. USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2) },
  2430. { USB_DEVICE(USB_VID_SONY, USB_PID_SONY_PLAYTV) },
  2431. /* 45 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_PD378S) },
  2432. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC) },
  2433. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC_B210) },
  2434. { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_MC770) },
  2435. { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT) },
  2436. /* 50 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_Dlx) },
  2437. { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_H) },
  2438. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T3) },
  2439. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T5) },
  2440. { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D) },
  2441. /* 55 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D_2) },
  2442. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73A) },
  2443. { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV73ESE) },
  2444. { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV282E) },
  2445. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7770P) },
  2446. /* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) },
  2447. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XPVR) },
  2448. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XP) },
  2449. { USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x000, 0x3f00) },
  2450. { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) },
  2451. /* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) },
  2452. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) },
  2453. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) },
  2454. { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DIVERSITY) },
  2455. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090M) },
  2456. /* 70 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM8096MD) },
  2457. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090MD) },
  2458. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM7090) },
  2459. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7090PVR) },
  2460. { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_AIRSTAR_TELESTICK_2) },
  2461. /* 75 */{ USB_DEVICE(USB_VID_MEDION, USB_PID_CREATIX_CTX1921) },
  2462. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E) },
  2463. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E_SE) },
  2464. { 0 } /* Terminating entry */
  2465. };
  2466. MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
  2467. #define DIB0700_DEFAULT_DEVICE_PROPERTIES \
  2468. .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
  2469. .usb_ctrl = DEVICE_SPECIFIC, \
  2470. .firmware = "dvb-usb-dib0700-1.20.fw", \
  2471. .download_firmware = dib0700_download_firmware, \
  2472. .no_reconnect = 1, \
  2473. .size_of_priv = sizeof(struct dib0700_state), \
  2474. .i2c_algo = &dib0700_i2c_algo, \
  2475. .identify_state = dib0700_identify_state
  2476. #define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
  2477. .streaming_ctrl = dib0700_streaming_ctrl, \
  2478. .stream = { \
  2479. .type = USB_BULK, \
  2480. .count = 4, \
  2481. .endpoint = ep, \
  2482. .u = { \
  2483. .bulk = { \
  2484. .buffersize = 39480, \
  2485. } \
  2486. } \
  2487. }
  2488. struct dvb_usb_device_properties dib0700_devices[] = {
  2489. {
  2490. DIB0700_DEFAULT_DEVICE_PROPERTIES,
  2491. .num_adapters = 1,
  2492. .adapter = {
  2493. {
  2494. .num_frontends = 1,
  2495. .fe = {{
  2496. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  2497. .pid_filter_count = 32,
  2498. .pid_filter = stk7700p_pid_filter,
  2499. .pid_filter_ctrl = stk7700p_pid_filter_ctrl,
  2500. .frontend_attach = stk7700p_frontend_attach,
  2501. .tuner_attach = stk7700p_tuner_attach,
  2502. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  2503. }},
  2504. },
  2505. },
  2506. .num_device_descs = 8,
  2507. .devices = {
  2508. { "DiBcom STK7700P reference design",
  2509. { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
  2510. { NULL },
  2511. },
  2512. { "Hauppauge Nova-T Stick",
  2513. { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
  2514. { NULL },
  2515. },
  2516. { "AVerMedia AVerTV DVB-T Volar",
  2517. { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
  2518. { NULL },
  2519. },
  2520. { "Compro Videomate U500",
  2521. { &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] },
  2522. { NULL },
  2523. },
  2524. { "Uniwill STK7700P based (Hama and others)",
  2525. { &dib0700_usb_id_table[7], NULL },
  2526. { NULL },
  2527. },
  2528. { "Leadtek Winfast DTV Dongle (STK7700P based)",
  2529. { &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] },
  2530. { NULL },
  2531. },
  2532. { "AVerMedia AVerTV DVB-T Express",
  2533. { &dib0700_usb_id_table[20] },
  2534. { NULL },
  2535. },
  2536. { "Gigabyte U7000",
  2537. { &dib0700_usb_id_table[21], NULL },
  2538. { NULL },
  2539. }
  2540. },
  2541. .rc.core = {
  2542. .rc_interval = DEFAULT_RC_INTERVAL,
  2543. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  2544. .rc_query = dib0700_rc_query_old_firmware,
  2545. .allowed_protos = RC_TYPE_RC5 |
  2546. RC_TYPE_RC6 |
  2547. RC_TYPE_NEC,
  2548. .change_protocol = dib0700_change_protocol,
  2549. },
  2550. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  2551. .num_adapters = 2,
  2552. .adapter = {
  2553. {
  2554. .num_frontends = 1,
  2555. .fe = {{
  2556. .frontend_attach = bristol_frontend_attach,
  2557. .tuner_attach = bristol_tuner_attach,
  2558. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  2559. }},
  2560. }, {
  2561. .num_frontends = 1,
  2562. .fe = {{
  2563. .frontend_attach = bristol_frontend_attach,
  2564. .tuner_attach = bristol_tuner_attach,
  2565. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  2566. }},
  2567. }
  2568. },
  2569. .num_device_descs = 1,
  2570. .devices = {
  2571. { "Hauppauge Nova-T 500 Dual DVB-T",
  2572. { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
  2573. { NULL },
  2574. },
  2575. },
  2576. .rc.core = {
  2577. .rc_interval = DEFAULT_RC_INTERVAL,
  2578. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  2579. .rc_query = dib0700_rc_query_old_firmware,
  2580. .allowed_protos = RC_TYPE_RC5 |
  2581. RC_TYPE_RC6 |
  2582. RC_TYPE_NEC,
  2583. .change_protocol = dib0700_change_protocol,
  2584. },
  2585. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  2586. .num_adapters = 2,
  2587. .adapter = {
  2588. {
  2589. .num_frontends = 1,
  2590. .fe = {{
  2591. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  2592. .pid_filter_count = 32,
  2593. .pid_filter = stk70x0p_pid_filter,
  2594. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  2595. .frontend_attach = stk7700d_frontend_attach,
  2596. .tuner_attach = stk7700d_tuner_attach,
  2597. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  2598. }},
  2599. }, {
  2600. .num_frontends = 1,
  2601. .fe = {{
  2602. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  2603. .pid_filter_count = 32,
  2604. .pid_filter = stk70x0p_pid_filter,
  2605. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  2606. .frontend_attach = stk7700d_frontend_attach,
  2607. .tuner_attach = stk7700d_tuner_attach,
  2608. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  2609. }},
  2610. }
  2611. },
  2612. .num_device_descs = 5,
  2613. .devices = {
  2614. { "Pinnacle PCTV 2000e",
  2615. { &dib0700_usb_id_table[11], NULL },
  2616. { NULL },
  2617. },
  2618. { "Terratec Cinergy DT XS Diversity",
  2619. { &dib0700_usb_id_table[12], NULL },
  2620. { NULL },
  2621. },
  2622. { "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
  2623. { &dib0700_usb_id_table[13], NULL },
  2624. { NULL },
  2625. },
  2626. { "DiBcom STK7700D reference design",
  2627. { &dib0700_usb_id_table[14], NULL },
  2628. { NULL },
  2629. },
  2630. { "YUAN High-Tech DiBcom STK7700D",
  2631. { &dib0700_usb_id_table[55], NULL },
  2632. { NULL },
  2633. },
  2634. },
  2635. .rc.core = {
  2636. .rc_interval = DEFAULT_RC_INTERVAL,
  2637. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  2638. .rc_query = dib0700_rc_query_old_firmware,
  2639. .allowed_protos = RC_TYPE_RC5 |
  2640. RC_TYPE_RC6 |
  2641. RC_TYPE_NEC,
  2642. .change_protocol = dib0700_change_protocol,
  2643. },
  2644. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  2645. .num_adapters = 1,
  2646. .adapter = {
  2647. {
  2648. .num_frontends = 1,
  2649. .fe = {{
  2650. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  2651. .pid_filter_count = 32,
  2652. .pid_filter = stk70x0p_pid_filter,
  2653. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  2654. .frontend_attach = stk7700P2_frontend_attach,
  2655. .tuner_attach = stk7700d_tuner_attach,
  2656. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  2657. }},
  2658. },
  2659. },
  2660. .num_device_descs = 3,
  2661. .devices = {
  2662. { "ASUS My Cinema U3000 Mini DVBT Tuner",
  2663. { &dib0700_usb_id_table[23], NULL },
  2664. { NULL },
  2665. },
  2666. { "Yuan EC372S",
  2667. { &dib0700_usb_id_table[31], NULL },
  2668. { NULL },
  2669. },
  2670. { "Terratec Cinergy T Express",
  2671. { &dib0700_usb_id_table[42], NULL },
  2672. { NULL },
  2673. }
  2674. },
  2675. .rc.core = {
  2676. .rc_interval = DEFAULT_RC_INTERVAL,
  2677. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  2678. .module_name = "dib0700",
  2679. .rc_query = dib0700_rc_query_old_firmware,
  2680. .allowed_protos = RC_TYPE_RC5 |
  2681. RC_TYPE_RC6 |
  2682. RC_TYPE_NEC,
  2683. .change_protocol = dib0700_change_protocol,
  2684. },
  2685. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  2686. .num_adapters = 1,
  2687. .adapter = {
  2688. {
  2689. .num_frontends = 1,
  2690. .fe = {{
  2691. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  2692. .pid_filter_count = 32,
  2693. .pid_filter = stk70x0p_pid_filter,
  2694. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  2695. .frontend_attach = stk7070p_frontend_attach,
  2696. .tuner_attach = dib7070p_tuner_attach,
  2697. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  2698. }},
  2699. .size_of_priv = sizeof(struct dib0700_adapter_state),
  2700. },
  2701. },
  2702. .num_device_descs = 11,
  2703. .devices = {
  2704. { "DiBcom STK7070P reference design",
  2705. { &dib0700_usb_id_table[15], NULL },
  2706. { NULL },
  2707. },
  2708. { "Pinnacle PCTV DVB-T Flash Stick",
  2709. { &dib0700_usb_id_table[16], NULL },
  2710. { NULL },
  2711. },
  2712. { "Artec T14BR DVB-T",
  2713. { &dib0700_usb_id_table[22], NULL },
  2714. { NULL },
  2715. },
  2716. { "ASUS My Cinema U3100 Mini DVBT Tuner",
  2717. { &dib0700_usb_id_table[24], NULL },
  2718. { NULL },
  2719. },
  2720. { "Hauppauge Nova-T Stick",
  2721. { &dib0700_usb_id_table[25], NULL },
  2722. { NULL },
  2723. },
  2724. { "Hauppauge Nova-T MyTV.t",
  2725. { &dib0700_usb_id_table[26], NULL },
  2726. { NULL },
  2727. },
  2728. { "Pinnacle PCTV 72e",
  2729. { &dib0700_usb_id_table[29], NULL },
  2730. { NULL },
  2731. },
  2732. { "Pinnacle PCTV 73e",
  2733. { &dib0700_usb_id_table[30], NULL },
  2734. { NULL },
  2735. },
  2736. { "Elgato EyeTV DTT",
  2737. { &dib0700_usb_id_table[49], NULL },
  2738. { NULL },
  2739. },
  2740. { "Yuan PD378S",
  2741. { &dib0700_usb_id_table[45], NULL },
  2742. { NULL },
  2743. },
  2744. { "Elgato EyeTV Dtt Dlx PD378S",
  2745. { &dib0700_usb_id_table[50], NULL },
  2746. { NULL },
  2747. },
  2748. },
  2749. .rc.core = {
  2750. .rc_interval = DEFAULT_RC_INTERVAL,
  2751. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  2752. .module_name = "dib0700",
  2753. .rc_query = dib0700_rc_query_old_firmware,
  2754. .allowed_protos = RC_TYPE_RC5 |
  2755. RC_TYPE_RC6 |
  2756. RC_TYPE_NEC,
  2757. .change_protocol = dib0700_change_protocol,
  2758. },
  2759. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  2760. .num_adapters = 1,
  2761. .adapter = {
  2762. {
  2763. .num_frontends = 1,
  2764. .fe = {{
  2765. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  2766. .pid_filter_count = 32,
  2767. .pid_filter = stk70x0p_pid_filter,
  2768. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  2769. .frontend_attach = stk7070p_frontend_attach,
  2770. .tuner_attach = dib7070p_tuner_attach,
  2771. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  2772. }},
  2773. .size_of_priv = sizeof(struct dib0700_adapter_state),
  2774. },
  2775. },
  2776. .num_device_descs = 3,
  2777. .devices = {
  2778. { "Pinnacle PCTV 73A",
  2779. { &dib0700_usb_id_table[56], NULL },
  2780. { NULL },
  2781. },
  2782. { "Pinnacle PCTV 73e SE",
  2783. { &dib0700_usb_id_table[57], &dib0700_usb_id_table[65], NULL },
  2784. { NULL },
  2785. },
  2786. { "Pinnacle PCTV 282e",
  2787. { &dib0700_usb_id_table[58], &dib0700_usb_id_table[66], NULL },
  2788. { NULL },
  2789. },
  2790. },
  2791. .rc.core = {
  2792. .rc_interval = DEFAULT_RC_INTERVAL,
  2793. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  2794. .module_name = "dib0700",
  2795. .rc_query = dib0700_rc_query_old_firmware,
  2796. .allowed_protos = RC_TYPE_RC5 |
  2797. RC_TYPE_RC6 |
  2798. RC_TYPE_NEC,
  2799. .change_protocol = dib0700_change_protocol,
  2800. },
  2801. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  2802. .num_adapters = 2,
  2803. .adapter = {
  2804. {
  2805. .num_frontends = 1,
  2806. .fe = {{
  2807. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  2808. .pid_filter_count = 32,
  2809. .pid_filter = stk70x0p_pid_filter,
  2810. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  2811. .frontend_attach = stk7070pd_frontend_attach0,
  2812. .tuner_attach = dib7070p_tuner_attach,
  2813. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  2814. }},
  2815. .size_of_priv = sizeof(struct dib0700_adapter_state),
  2816. }, {
  2817. .num_frontends = 1,
  2818. .fe = {{
  2819. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  2820. .pid_filter_count = 32,
  2821. .pid_filter = stk70x0p_pid_filter,
  2822. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  2823. .frontend_attach = stk7070pd_frontend_attach1,
  2824. .tuner_attach = dib7070p_tuner_attach,
  2825. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  2826. }},
  2827. .size_of_priv = sizeof(struct dib0700_adapter_state),
  2828. }
  2829. },
  2830. .num_device_descs = 6,
  2831. .devices = {
  2832. { "DiBcom STK7070PD reference design",
  2833. { &dib0700_usb_id_table[17], NULL },
  2834. { NULL },
  2835. },
  2836. { "Pinnacle PCTV Dual DVB-T Diversity Stick",
  2837. { &dib0700_usb_id_table[18], NULL },
  2838. { NULL },
  2839. },
  2840. { "Hauppauge Nova-TD Stick (52009)",
  2841. { &dib0700_usb_id_table[35], NULL },
  2842. { NULL },
  2843. },
  2844. { "Hauppauge Nova-TD-500 (84xxx)",
  2845. { &dib0700_usb_id_table[36], NULL },
  2846. { NULL },
  2847. },
  2848. { "Terratec Cinergy DT USB XS Diversity/ T5",
  2849. { &dib0700_usb_id_table[43],
  2850. &dib0700_usb_id_table[53], NULL},
  2851. { NULL },
  2852. },
  2853. { "Sony PlayTV",
  2854. { &dib0700_usb_id_table[44], NULL },
  2855. { NULL },
  2856. },
  2857. },
  2858. .rc.core = {
  2859. .rc_interval = DEFAULT_RC_INTERVAL,
  2860. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  2861. .module_name = "dib0700",
  2862. .rc_query = dib0700_rc_query_old_firmware,
  2863. .allowed_protos = RC_TYPE_RC5 |
  2864. RC_TYPE_RC6 |
  2865. RC_TYPE_NEC,
  2866. .change_protocol = dib0700_change_protocol,
  2867. },
  2868. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  2869. .num_adapters = 2,
  2870. .adapter = {
  2871. {
  2872. .num_frontends = 1,
  2873. .fe = {{
  2874. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  2875. .pid_filter_count = 32,
  2876. .pid_filter = stk70x0p_pid_filter,
  2877. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  2878. .frontend_attach = stk7070pd_frontend_attach0,
  2879. .tuner_attach = dib7070p_tuner_attach,
  2880. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  2881. }},
  2882. .size_of_priv = sizeof(struct dib0700_adapter_state),
  2883. }, {
  2884. .num_frontends = 1,
  2885. .fe = {{
  2886. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  2887. .pid_filter_count = 32,
  2888. .pid_filter = stk70x0p_pid_filter,
  2889. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  2890. .frontend_attach = stk7070pd_frontend_attach1,
  2891. .tuner_attach = dib7070p_tuner_attach,
  2892. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  2893. }},
  2894. .size_of_priv = sizeof(struct dib0700_adapter_state),
  2895. }
  2896. },
  2897. .num_device_descs = 1,
  2898. .devices = {
  2899. { "Elgato EyeTV Diversity",
  2900. { &dib0700_usb_id_table[68], NULL },
  2901. { NULL },
  2902. },
  2903. },
  2904. .rc.core = {
  2905. .rc_interval = DEFAULT_RC_INTERVAL,
  2906. .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
  2907. .module_name = "dib0700",
  2908. .rc_query = dib0700_rc_query_old_firmware,
  2909. .allowed_protos = RC_TYPE_RC5 |
  2910. RC_TYPE_RC6 |
  2911. RC_TYPE_NEC,
  2912. .change_protocol = dib0700_change_protocol,
  2913. },
  2914. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  2915. .num_adapters = 1,
  2916. .adapter = {
  2917. {
  2918. .num_frontends = 1,
  2919. .fe = {{
  2920. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  2921. .pid_filter_count = 32,
  2922. .pid_filter = stk70x0p_pid_filter,
  2923. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  2924. .frontend_attach = stk7700ph_frontend_attach,
  2925. .tuner_attach = stk7700ph_tuner_attach,
  2926. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  2927. }},
  2928. .size_of_priv = sizeof(struct
  2929. dib0700_adapter_state),
  2930. },
  2931. },
  2932. .num_device_descs = 9,
  2933. .devices = {
  2934. { "Terratec Cinergy HT USB XE",
  2935. { &dib0700_usb_id_table[27], NULL },
  2936. { NULL },
  2937. },
  2938. { "Pinnacle Expresscard 320cx",
  2939. { &dib0700_usb_id_table[28], NULL },
  2940. { NULL },
  2941. },
  2942. { "Terratec Cinergy HT Express",
  2943. { &dib0700_usb_id_table[32], NULL },
  2944. { NULL },
  2945. },
  2946. { "Gigabyte U8000-RH",
  2947. { &dib0700_usb_id_table[37], NULL },
  2948. { NULL },
  2949. },
  2950. { "YUAN High-Tech STK7700PH",
  2951. { &dib0700_usb_id_table[38], NULL },
  2952. { NULL },
  2953. },
  2954. { "Asus My Cinema-U3000Hybrid",
  2955. { &dib0700_usb_id_table[39], NULL },
  2956. { NULL },
  2957. },
  2958. { "YUAN High-Tech MC770",
  2959. { &dib0700_usb_id_table[48], NULL },
  2960. { NULL },
  2961. },
  2962. { "Leadtek WinFast DTV Dongle H",
  2963. { &dib0700_usb_id_table[51], NULL },
  2964. { NULL },
  2965. },
  2966. { "YUAN High-Tech STK7700D",
  2967. { &dib0700_usb_id_table[54], NULL },
  2968. { NULL },
  2969. },
  2970. },
  2971. .rc.core = {
  2972. .rc_interval = DEFAULT_RC_INTERVAL,
  2973. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  2974. .module_name = "dib0700",
  2975. .rc_query = dib0700_rc_query_old_firmware,
  2976. .allowed_protos = RC_TYPE_RC5 |
  2977. RC_TYPE_RC6 |
  2978. RC_TYPE_NEC,
  2979. .change_protocol = dib0700_change_protocol,
  2980. },
  2981. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  2982. .num_adapters = 1,
  2983. .adapter = {
  2984. {
  2985. .num_frontends = 1,
  2986. .fe = {{
  2987. .frontend_attach = s5h1411_frontend_attach,
  2988. .tuner_attach = xc5000_tuner_attach,
  2989. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  2990. }},
  2991. .size_of_priv = sizeof(struct
  2992. dib0700_adapter_state),
  2993. },
  2994. },
  2995. .num_device_descs = 2,
  2996. .devices = {
  2997. { "Pinnacle PCTV HD Pro USB Stick",
  2998. { &dib0700_usb_id_table[40], NULL },
  2999. { NULL },
  3000. },
  3001. { "Pinnacle PCTV HD USB Stick",
  3002. { &dib0700_usb_id_table[41], NULL },
  3003. { NULL },
  3004. },
  3005. },
  3006. .rc.core = {
  3007. .rc_interval = DEFAULT_RC_INTERVAL,
  3008. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3009. .module_name = "dib0700",
  3010. .rc_query = dib0700_rc_query_old_firmware,
  3011. .allowed_protos = RC_TYPE_RC5 |
  3012. RC_TYPE_RC6 |
  3013. RC_TYPE_NEC,
  3014. .change_protocol = dib0700_change_protocol,
  3015. },
  3016. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3017. .num_adapters = 1,
  3018. .adapter = {
  3019. {
  3020. .num_frontends = 1,
  3021. .fe = {{
  3022. .frontend_attach = lgdt3305_frontend_attach,
  3023. .tuner_attach = mxl5007t_tuner_attach,
  3024. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3025. }},
  3026. .size_of_priv = sizeof(struct
  3027. dib0700_adapter_state),
  3028. },
  3029. },
  3030. .num_device_descs = 2,
  3031. .devices = {
  3032. { "Hauppauge ATSC MiniCard (B200)",
  3033. { &dib0700_usb_id_table[46], NULL },
  3034. { NULL },
  3035. },
  3036. { "Hauppauge ATSC MiniCard (B210)",
  3037. { &dib0700_usb_id_table[47], NULL },
  3038. { NULL },
  3039. },
  3040. },
  3041. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3042. .num_adapters = 1,
  3043. .adapter = {
  3044. {
  3045. .num_frontends = 1,
  3046. .fe = {{
  3047. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3048. .pid_filter_count = 32,
  3049. .pid_filter = stk70x0p_pid_filter,
  3050. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3051. .frontend_attach = stk7770p_frontend_attach,
  3052. .tuner_attach = dib7770p_tuner_attach,
  3053. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3054. }},
  3055. .size_of_priv =
  3056. sizeof(struct dib0700_adapter_state),
  3057. },
  3058. },
  3059. .num_device_descs = 4,
  3060. .devices = {
  3061. { "DiBcom STK7770P reference design",
  3062. { &dib0700_usb_id_table[59], NULL },
  3063. { NULL },
  3064. },
  3065. { "Terratec Cinergy T USB XXS (HD)/ T3",
  3066. { &dib0700_usb_id_table[33],
  3067. &dib0700_usb_id_table[52],
  3068. &dib0700_usb_id_table[60], NULL},
  3069. { NULL },
  3070. },
  3071. { "TechniSat AirStar TeleStick 2",
  3072. { &dib0700_usb_id_table[74], NULL },
  3073. { NULL },
  3074. },
  3075. { "Medion CTX1921 DVB-T USB",
  3076. { &dib0700_usb_id_table[75], NULL },
  3077. { NULL },
  3078. },
  3079. },
  3080. .rc.core = {
  3081. .rc_interval = DEFAULT_RC_INTERVAL,
  3082. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3083. .module_name = "dib0700",
  3084. .rc_query = dib0700_rc_query_old_firmware,
  3085. .allowed_protos = RC_TYPE_RC5 |
  3086. RC_TYPE_RC6 |
  3087. RC_TYPE_NEC,
  3088. .change_protocol = dib0700_change_protocol,
  3089. },
  3090. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3091. .num_adapters = 1,
  3092. .adapter = {
  3093. {
  3094. .num_frontends = 1,
  3095. .fe = {{
  3096. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3097. .pid_filter_count = 32,
  3098. .pid_filter = stk80xx_pid_filter,
  3099. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  3100. .frontend_attach = stk807x_frontend_attach,
  3101. .tuner_attach = dib807x_tuner_attach,
  3102. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3103. }},
  3104. .size_of_priv =
  3105. sizeof(struct dib0700_adapter_state),
  3106. },
  3107. },
  3108. .num_device_descs = 3,
  3109. .devices = {
  3110. { "DiBcom STK807xP reference design",
  3111. { &dib0700_usb_id_table[62], NULL },
  3112. { NULL },
  3113. },
  3114. { "Prolink Pixelview SBTVD",
  3115. { &dib0700_usb_id_table[63], NULL },
  3116. { NULL },
  3117. },
  3118. { "EvolutePC TVWay+",
  3119. { &dib0700_usb_id_table[64], NULL },
  3120. { NULL },
  3121. },
  3122. },
  3123. .rc.core = {
  3124. .rc_interval = DEFAULT_RC_INTERVAL,
  3125. .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
  3126. .module_name = "dib0700",
  3127. .rc_query = dib0700_rc_query_old_firmware,
  3128. .allowed_protos = RC_TYPE_RC5 |
  3129. RC_TYPE_RC6 |
  3130. RC_TYPE_NEC,
  3131. .change_protocol = dib0700_change_protocol,
  3132. },
  3133. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3134. .num_adapters = 2,
  3135. .adapter = {
  3136. {
  3137. .num_frontends = 1,
  3138. .fe = {{
  3139. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3140. .pid_filter_count = 32,
  3141. .pid_filter = stk80xx_pid_filter,
  3142. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  3143. .frontend_attach = stk807xpvr_frontend_attach0,
  3144. .tuner_attach = dib807x_tuner_attach,
  3145. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3146. }},
  3147. .size_of_priv =
  3148. sizeof(struct dib0700_adapter_state),
  3149. },
  3150. {
  3151. .num_frontends = 1,
  3152. .fe = {{
  3153. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3154. .pid_filter_count = 32,
  3155. .pid_filter = stk80xx_pid_filter,
  3156. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  3157. .frontend_attach = stk807xpvr_frontend_attach1,
  3158. .tuner_attach = dib807x_tuner_attach,
  3159. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3160. }},
  3161. .size_of_priv =
  3162. sizeof(struct dib0700_adapter_state),
  3163. },
  3164. },
  3165. .num_device_descs = 1,
  3166. .devices = {
  3167. { "DiBcom STK807xPVR reference design",
  3168. { &dib0700_usb_id_table[61], NULL },
  3169. { NULL },
  3170. },
  3171. },
  3172. .rc.core = {
  3173. .rc_interval = DEFAULT_RC_INTERVAL,
  3174. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3175. .module_name = "dib0700",
  3176. .rc_query = dib0700_rc_query_old_firmware,
  3177. .allowed_protos = RC_TYPE_RC5 |
  3178. RC_TYPE_RC6 |
  3179. RC_TYPE_NEC,
  3180. .change_protocol = dib0700_change_protocol,
  3181. },
  3182. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3183. .num_adapters = 1,
  3184. .adapter = {
  3185. {
  3186. .num_frontends = 1,
  3187. .fe = {{
  3188. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  3189. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3190. .pid_filter_count = 32,
  3191. .pid_filter = stk80xx_pid_filter,
  3192. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  3193. .frontend_attach = stk809x_frontend_attach,
  3194. .tuner_attach = dib809x_tuner_attach,
  3195. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3196. }},
  3197. .size_of_priv =
  3198. sizeof(struct dib0700_adapter_state),
  3199. },
  3200. },
  3201. .num_device_descs = 1,
  3202. .devices = {
  3203. { "DiBcom STK8096GP reference design",
  3204. { &dib0700_usb_id_table[67], NULL },
  3205. { NULL },
  3206. },
  3207. },
  3208. .rc.core = {
  3209. .rc_interval = DEFAULT_RC_INTERVAL,
  3210. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3211. .module_name = "dib0700",
  3212. .rc_query = dib0700_rc_query_old_firmware,
  3213. .allowed_protos = RC_TYPE_RC5 |
  3214. RC_TYPE_RC6 |
  3215. RC_TYPE_NEC,
  3216. .change_protocol = dib0700_change_protocol,
  3217. },
  3218. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3219. .num_adapters = 1,
  3220. .adapter = {
  3221. {
  3222. .num_frontends = 1,
  3223. .fe = {{
  3224. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  3225. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3226. .pid_filter_count = 32,
  3227. .pid_filter = dib90x0_pid_filter,
  3228. .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
  3229. .frontend_attach = stk9090m_frontend_attach,
  3230. .tuner_attach = dib9090_tuner_attach,
  3231. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3232. }},
  3233. .size_of_priv =
  3234. sizeof(struct dib0700_adapter_state),
  3235. },
  3236. },
  3237. .num_device_descs = 1,
  3238. .devices = {
  3239. { "DiBcom STK9090M reference design",
  3240. { &dib0700_usb_id_table[69], NULL },
  3241. { NULL },
  3242. },
  3243. },
  3244. .rc.core = {
  3245. .rc_interval = DEFAULT_RC_INTERVAL,
  3246. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3247. .module_name = "dib0700",
  3248. .rc_query = dib0700_rc_query_old_firmware,
  3249. .allowed_protos = RC_TYPE_RC5 |
  3250. RC_TYPE_RC6 |
  3251. RC_TYPE_NEC,
  3252. .change_protocol = dib0700_change_protocol,
  3253. },
  3254. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3255. .num_adapters = 1,
  3256. .adapter = {
  3257. {
  3258. .num_frontends = 1,
  3259. .fe = {{
  3260. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  3261. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3262. .pid_filter_count = 32,
  3263. .pid_filter = stk80xx_pid_filter,
  3264. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  3265. .frontend_attach = nim8096md_frontend_attach,
  3266. .tuner_attach = nim8096md_tuner_attach,
  3267. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3268. }},
  3269. .size_of_priv =
  3270. sizeof(struct dib0700_adapter_state),
  3271. },
  3272. },
  3273. .num_device_descs = 1,
  3274. .devices = {
  3275. { "DiBcom NIM8096MD reference design",
  3276. { &dib0700_usb_id_table[70], NULL },
  3277. { NULL },
  3278. },
  3279. },
  3280. .rc.core = {
  3281. .rc_interval = DEFAULT_RC_INTERVAL,
  3282. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3283. .module_name = "dib0700",
  3284. .rc_query = dib0700_rc_query_old_firmware,
  3285. .allowed_protos = RC_TYPE_RC5 |
  3286. RC_TYPE_RC6 |
  3287. RC_TYPE_NEC,
  3288. .change_protocol = dib0700_change_protocol,
  3289. },
  3290. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3291. .num_adapters = 1,
  3292. .adapter = {
  3293. {
  3294. .num_frontends = 1,
  3295. .fe = {{
  3296. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  3297. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3298. .pid_filter_count = 32,
  3299. .pid_filter = dib90x0_pid_filter,
  3300. .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
  3301. .frontend_attach = nim9090md_frontend_attach,
  3302. .tuner_attach = nim9090md_tuner_attach,
  3303. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3304. }},
  3305. .size_of_priv =
  3306. sizeof(struct dib0700_adapter_state),
  3307. },
  3308. },
  3309. .num_device_descs = 1,
  3310. .devices = {
  3311. { "DiBcom NIM9090MD reference design",
  3312. { &dib0700_usb_id_table[71], NULL },
  3313. { NULL },
  3314. },
  3315. },
  3316. .rc.core = {
  3317. .rc_interval = DEFAULT_RC_INTERVAL,
  3318. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3319. .module_name = "dib0700",
  3320. .rc_query = dib0700_rc_query_old_firmware,
  3321. .allowed_protos = RC_TYPE_RC5 |
  3322. RC_TYPE_RC6 |
  3323. RC_TYPE_NEC,
  3324. .change_protocol = dib0700_change_protocol,
  3325. },
  3326. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3327. .num_adapters = 1,
  3328. .adapter = {
  3329. {
  3330. .num_frontends = 1,
  3331. .fe = {{
  3332. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  3333. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3334. .pid_filter_count = 32,
  3335. .pid_filter = stk70x0p_pid_filter,
  3336. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3337. .frontend_attach = nim7090_frontend_attach,
  3338. .tuner_attach = nim7090_tuner_attach,
  3339. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3340. }},
  3341. .size_of_priv =
  3342. sizeof(struct dib0700_adapter_state),
  3343. },
  3344. },
  3345. .num_device_descs = 1,
  3346. .devices = {
  3347. { "DiBcom NIM7090 reference design",
  3348. { &dib0700_usb_id_table[72], NULL },
  3349. { NULL },
  3350. },
  3351. },
  3352. .rc.core = {
  3353. .rc_interval = DEFAULT_RC_INTERVAL,
  3354. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3355. .module_name = "dib0700",
  3356. .rc_query = dib0700_rc_query_old_firmware,
  3357. .allowed_protos = RC_TYPE_RC5 |
  3358. RC_TYPE_RC6 |
  3359. RC_TYPE_NEC,
  3360. .change_protocol = dib0700_change_protocol,
  3361. },
  3362. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3363. .num_adapters = 2,
  3364. .adapter = {
  3365. {
  3366. .num_frontends = 1,
  3367. .fe = {{
  3368. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  3369. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3370. .pid_filter_count = 32,
  3371. .pid_filter = stk70x0p_pid_filter,
  3372. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3373. .frontend_attach = tfe7090pvr_frontend0_attach,
  3374. .tuner_attach = tfe7090pvr_tuner0_attach,
  3375. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3376. }},
  3377. .size_of_priv =
  3378. sizeof(struct dib0700_adapter_state),
  3379. },
  3380. {
  3381. .num_frontends = 1,
  3382. .fe = {{
  3383. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  3384. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3385. .pid_filter_count = 32,
  3386. .pid_filter = stk70x0p_pid_filter,
  3387. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3388. .frontend_attach = tfe7090pvr_frontend1_attach,
  3389. .tuner_attach = tfe7090pvr_tuner1_attach,
  3390. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3391. }},
  3392. .size_of_priv =
  3393. sizeof(struct dib0700_adapter_state),
  3394. },
  3395. },
  3396. .num_device_descs = 1,
  3397. .devices = {
  3398. { "DiBcom TFE7090PVR reference design",
  3399. { &dib0700_usb_id_table[73], NULL },
  3400. { NULL },
  3401. },
  3402. },
  3403. .rc.core = {
  3404. .rc_interval = DEFAULT_RC_INTERVAL,
  3405. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3406. .module_name = "dib0700",
  3407. .rc_query = dib0700_rc_query_old_firmware,
  3408. .allowed_protos = RC_TYPE_RC5 |
  3409. RC_TYPE_RC6 |
  3410. RC_TYPE_NEC,
  3411. .change_protocol = dib0700_change_protocol,
  3412. },
  3413. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3414. .num_adapters = 1,
  3415. .adapter = {
  3416. {
  3417. .num_frontends = 1,
  3418. .fe = {{
  3419. .frontend_attach = pctv340e_frontend_attach,
  3420. .tuner_attach = xc4000_tuner_attach,
  3421. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3422. }},
  3423. .size_of_priv = sizeof(struct
  3424. dib0700_adapter_state),
  3425. },
  3426. },
  3427. .num_device_descs = 2,
  3428. .devices = {
  3429. { "Pinnacle PCTV 340e HD Pro USB Stick",
  3430. { &dib0700_usb_id_table[76], NULL },
  3431. { NULL },
  3432. },
  3433. { "Pinnacle PCTV Hybrid Stick Solo",
  3434. { &dib0700_usb_id_table[77], NULL },
  3435. { NULL },
  3436. },
  3437. },
  3438. .rc.core = {
  3439. .rc_interval = DEFAULT_RC_INTERVAL,
  3440. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3441. .module_name = "dib0700",
  3442. .rc_query = dib0700_rc_query_old_firmware,
  3443. .allowed_protos = RC_TYPE_RC5 |
  3444. RC_TYPE_RC6 |
  3445. RC_TYPE_NEC,
  3446. .change_protocol = dib0700_change_protocol,
  3447. },
  3448. },
  3449. };
  3450. int dib0700_device_count = ARRAY_SIZE(dib0700_devices);