dib0700_devices.c 113 KB

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