dib0700_devices.c 100 KB

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