dib0700_devices.c 141 KB

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