dib0700_devices.c 104 KB

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