dib0700_devices.c 105 KB

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