dib0700_devices.c 141 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155
  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. deb_info("%s: Upload failed. (file not found?)\n", __func__);
  2024. return -ENODEV;
  2025. } else {
  2026. deb_info("%s: firmware read %zu bytes.\n", __func__, state->frontend_firmware->size);
  2027. }
  2028. stk9090m_config.microcode_B_fe_size = state->frontend_firmware->size;
  2029. stk9090m_config.microcode_B_fe_buffer = state->frontend_firmware->data;
  2030. adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &stk9090m_config);
  2031. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2032. }
  2033. static int dib9090_tuner_attach(struct dvb_usb_adapter *adap)
  2034. {
  2035. struct dib0700_adapter_state *state = adap->priv;
  2036. struct i2c_adapter *i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
  2037. u16 data_dib190[10] = {
  2038. 1, 0x1374,
  2039. 2, 0x01a2,
  2040. 7, 0x0020,
  2041. 0, 0x00ef,
  2042. 8, 0x0486,
  2043. };
  2044. if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &dib9090_dib0090_config) == NULL)
  2045. return -ENODEV;
  2046. i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
  2047. if (dib01x0_pmu_update(i2c, data_dib190, 10) != 0)
  2048. return -ENODEV;
  2049. dib0700_set_i2c_speed(adap->dev, 1500);
  2050. if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
  2051. return -ENODEV;
  2052. release_firmware(state->frontend_firmware);
  2053. return 0;
  2054. }
  2055. static int nim9090md_frontend_attach(struct dvb_usb_adapter *adap)
  2056. {
  2057. struct dib0700_adapter_state *state = adap->priv;
  2058. struct dib0700_state *st = adap->dev->priv;
  2059. struct i2c_adapter *i2c;
  2060. struct dvb_frontend *fe_slave;
  2061. u32 fw_version;
  2062. /* Make use of the new i2c functions from FW 1.20 */
  2063. dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL);
  2064. if (fw_version >= 0x10200)
  2065. st->fw_use_new_i2c_api = 1;
  2066. dib0700_set_i2c_speed(adap->dev, 340);
  2067. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2068. msleep(20);
  2069. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2070. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2071. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2072. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2073. dib0700_ctrl_clock(adap->dev, 72, 1);
  2074. msleep(20);
  2075. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2076. msleep(20);
  2077. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2078. if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) {
  2079. deb_info("%s: Upload failed. (file not found?)\n", __func__);
  2080. return -EIO;
  2081. } else {
  2082. deb_info("%s: firmware read %zu bytes.\n", __func__, state->frontend_firmware->size);
  2083. }
  2084. nim9090md_config[0].microcode_B_fe_size = state->frontend_firmware->size;
  2085. nim9090md_config[0].microcode_B_fe_buffer = state->frontend_firmware->data;
  2086. nim9090md_config[1].microcode_B_fe_size = state->frontend_firmware->size;
  2087. nim9090md_config[1].microcode_B_fe_buffer = state->frontend_firmware->data;
  2088. dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, 0x80);
  2089. adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &nim9090md_config[0]);
  2090. if (adap->fe_adap[0].fe == NULL)
  2091. return -ENODEV;
  2092. i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_3_4, 0);
  2093. dib9000_i2c_enumeration(i2c, 1, 0x12, 0x82);
  2094. fe_slave = dvb_attach(dib9000_attach, i2c, 0x82, &nim9090md_config[1]);
  2095. dib9000_set_slave_frontend(adap->fe_adap[0].fe, fe_slave);
  2096. return fe_slave == NULL ? -ENODEV : 0;
  2097. }
  2098. static int nim9090md_tuner_attach(struct dvb_usb_adapter *adap)
  2099. {
  2100. struct dib0700_adapter_state *state = adap->priv;
  2101. struct i2c_adapter *i2c;
  2102. struct dvb_frontend *fe_slave;
  2103. u16 data_dib190[10] = {
  2104. 1, 0x5374,
  2105. 2, 0x01ae,
  2106. 7, 0x0020,
  2107. 0, 0x00ef,
  2108. 8, 0x0406,
  2109. };
  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 (dib01x0_pmu_update(i2c, data_dib190, 10) < 0)
  2115. return -ENODEV;
  2116. dib0700_set_i2c_speed(adap->dev, 1500);
  2117. if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0)
  2118. return -ENODEV;
  2119. fe_slave = dib9000_get_slave_frontend(adap->fe_adap[0].fe, 1);
  2120. if (fe_slave != NULL) {
  2121. i2c = dib9000_get_component_bus_interface(adap->fe_adap[0].fe);
  2122. dib9000_set_i2c_adapter(fe_slave, i2c);
  2123. i2c = dib9000_get_tuner_interface(fe_slave);
  2124. if (dvb_attach(dib0090_fw_register, fe_slave, i2c, &nim9090md_dib0090_config[1]) == NULL)
  2125. return -ENODEV;
  2126. fe_slave->dvb = adap->fe_adap[0].fe->dvb;
  2127. dib9000_fw_set_component_bus_speed(adap->fe_adap[0].fe, 1500);
  2128. if (dib9000_firmware_post_pll_init(fe_slave) < 0)
  2129. return -ENODEV;
  2130. }
  2131. release_firmware(state->frontend_firmware);
  2132. return 0;
  2133. }
  2134. /* NIM7090 */
  2135. static int dib7090p_get_best_sampling(struct dvb_frontend *fe , struct dibx090p_best_adc *adc)
  2136. {
  2137. u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1;
  2138. u16 xtal = 12000;
  2139. u32 fcp_min = 1900; /* PLL Minimum Frequency comparator KHz */
  2140. u32 fcp_max = 20000; /* PLL Maximum Frequency comparator KHz */
  2141. u32 fdem_max = 76000;
  2142. u32 fdem_min = 69500;
  2143. u32 fcp = 0, fs = 0, fdem = 0;
  2144. u32 harmonic_id = 0;
  2145. adc->pll_loopdiv = loopdiv;
  2146. adc->pll_prediv = prediv;
  2147. adc->timf = 0;
  2148. deb_info("bandwidth = %d fdem_min =%d", fe->dtv_property_cache.bandwidth_hz, fdem_min);
  2149. /* Find Min and Max prediv */
  2150. while ((xtal/max_prediv) >= fcp_min)
  2151. max_prediv++;
  2152. max_prediv--;
  2153. min_prediv = max_prediv;
  2154. while ((xtal/min_prediv) <= fcp_max) {
  2155. min_prediv--;
  2156. if (min_prediv == 1)
  2157. break;
  2158. }
  2159. deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv);
  2160. min_prediv = 2;
  2161. for (prediv = min_prediv ; prediv < max_prediv; prediv++) {
  2162. fcp = xtal / prediv;
  2163. if (fcp > fcp_min && fcp < fcp_max) {
  2164. for (loopdiv = 1 ; loopdiv < 64 ; loopdiv++) {
  2165. fdem = ((xtal/prediv) * loopdiv);
  2166. fs = fdem / 4;
  2167. /* test min/max system restrictions */
  2168. if ((fdem >= fdem_min) && (fdem <= fdem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz/1000)) {
  2169. spur = 0;
  2170. /* test fs harmonics positions */
  2171. for (harmonic_id = (fe->dtv_property_cache.frequency / (1000*fs)) ; harmonic_id <= ((fe->dtv_property_cache.frequency / (1000*fs))+1) ; harmonic_id++) {
  2172. 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)))) {
  2173. spur = 1;
  2174. break;
  2175. }
  2176. }
  2177. if (!spur) {
  2178. adc->pll_loopdiv = loopdiv;
  2179. adc->pll_prediv = prediv;
  2180. adc->timf = 2396745143UL/fdem*(1 << 9);
  2181. adc->timf += ((2396745143UL%fdem) << 9)/fdem;
  2182. deb_info("loopdiv=%i prediv=%i timf=%i", loopdiv, prediv, adc->timf);
  2183. break;
  2184. }
  2185. }
  2186. }
  2187. }
  2188. if (!spur)
  2189. break;
  2190. }
  2191. if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0)
  2192. return -EINVAL;
  2193. else
  2194. return 0;
  2195. }
  2196. static int dib7090_agc_startup(struct dvb_frontend *fe)
  2197. {
  2198. struct dvb_usb_adapter *adap = fe->dvb->priv;
  2199. struct dib0700_adapter_state *state = adap->priv;
  2200. struct dibx000_bandwidth_config pll;
  2201. u16 target;
  2202. struct dibx090p_best_adc adc;
  2203. int ret;
  2204. ret = state->set_param_save(fe);
  2205. if (ret < 0)
  2206. return ret;
  2207. memset(&pll, 0, sizeof(struct dibx000_bandwidth_config));
  2208. dib0090_pwm_gain_reset(fe);
  2209. target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2;
  2210. state->dib7000p_ops.set_wbd_ref(fe, target);
  2211. if (dib7090p_get_best_sampling(fe, &adc) == 0) {
  2212. pll.pll_ratio = adc.pll_loopdiv;
  2213. pll.pll_prediv = adc.pll_prediv;
  2214. state->dib7000p_ops.update_pll(fe, &pll);
  2215. state->dib7000p_ops.ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf);
  2216. }
  2217. return 0;
  2218. }
  2219. static int dib7090_agc_restart(struct dvb_frontend *fe, u8 restart)
  2220. {
  2221. deb_info("AGC restart callback: %d", restart);
  2222. if (restart == 0) /* before AGC startup */
  2223. dib0090_set_dc_servo(fe, 1);
  2224. return 0;
  2225. }
  2226. static int tfe7790p_update_lna(struct dvb_frontend *fe, u16 agc_global)
  2227. {
  2228. struct dvb_usb_adapter *adap = fe->dvb->priv;
  2229. struct dib0700_adapter_state *state = adap->priv;
  2230. deb_info("update LNA: agc global=%i", agc_global);
  2231. if (agc_global < 25000) {
  2232. state->dib7000p_ops.set_gpio(fe, 8, 0, 0);
  2233. state->dib7000p_ops.set_agc1_min(fe, 0);
  2234. } else {
  2235. state->dib7000p_ops.set_gpio(fe, 8, 0, 1);
  2236. state->dib7000p_ops.set_agc1_min(fe, 32768);
  2237. }
  2238. return 0;
  2239. }
  2240. static struct dib0090_wbd_slope dib7090_wbd_table[] = {
  2241. { 380, 81, 850, 64, 540, 4},
  2242. { 860, 51, 866, 21, 375, 4},
  2243. {1700, 0, 250, 0, 100, 6},
  2244. {2600, 0, 250, 0, 100, 6},
  2245. { 0xFFFF, 0, 0, 0, 0, 0},
  2246. };
  2247. static struct dibx000_agc_config dib7090_agc_config[2] = {
  2248. {
  2249. .band_caps = BAND_UHF,
  2250. /* 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,
  2251. * 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 */
  2252. .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
  2253. .inv_gain = 687,
  2254. .time_stabiliz = 10,
  2255. .alpha_level = 0,
  2256. .thlock = 118,
  2257. .wbd_inv = 0,
  2258. .wbd_ref = 1200,
  2259. .wbd_sel = 3,
  2260. .wbd_alpha = 5,
  2261. .agc1_max = 65535,
  2262. .agc1_min = 32768,
  2263. .agc2_max = 65535,
  2264. .agc2_min = 0,
  2265. .agc1_pt1 = 0,
  2266. .agc1_pt2 = 32,
  2267. .agc1_pt3 = 114,
  2268. .agc1_slope1 = 143,
  2269. .agc1_slope2 = 144,
  2270. .agc2_pt1 = 114,
  2271. .agc2_pt2 = 227,
  2272. .agc2_slope1 = 116,
  2273. .agc2_slope2 = 117,
  2274. .alpha_mant = 18,
  2275. .alpha_exp = 0,
  2276. .beta_mant = 20,
  2277. .beta_exp = 59,
  2278. .perform_agc_softsplit = 0,
  2279. } , {
  2280. .band_caps = BAND_FM | BAND_VHF | BAND_CBAND,
  2281. /* 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,
  2282. * 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 */
  2283. .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
  2284. .inv_gain = 732,
  2285. .time_stabiliz = 10,
  2286. .alpha_level = 0,
  2287. .thlock = 118,
  2288. .wbd_inv = 0,
  2289. .wbd_ref = 1200,
  2290. .wbd_sel = 3,
  2291. .wbd_alpha = 5,
  2292. .agc1_max = 65535,
  2293. .agc1_min = 0,
  2294. .agc2_max = 65535,
  2295. .agc2_min = 0,
  2296. .agc1_pt1 = 0,
  2297. .agc1_pt2 = 0,
  2298. .agc1_pt3 = 98,
  2299. .agc1_slope1 = 0,
  2300. .agc1_slope2 = 167,
  2301. .agc2_pt1 = 98,
  2302. .agc2_pt2 = 255,
  2303. .agc2_slope1 = 104,
  2304. .agc2_slope2 = 0,
  2305. .alpha_mant = 18,
  2306. .alpha_exp = 0,
  2307. .beta_mant = 20,
  2308. .beta_exp = 59,
  2309. .perform_agc_softsplit = 0,
  2310. }
  2311. };
  2312. static struct dibx000_bandwidth_config dib7090_clock_config_12_mhz = {
  2313. .internal = 60000,
  2314. .sampling = 15000,
  2315. .pll_prediv = 1,
  2316. .pll_ratio = 5,
  2317. .pll_range = 0,
  2318. .pll_reset = 0,
  2319. .pll_bypass = 0,
  2320. .enable_refdiv = 0,
  2321. .bypclk_div = 0,
  2322. .IO_CLK_en_core = 1,
  2323. .ADClkSrc = 1,
  2324. .modulo = 2,
  2325. .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
  2326. .ifreq = (0 << 25) | 0,
  2327. .timf = 20452225,
  2328. .xtal_hz = 15000000,
  2329. };
  2330. static struct dib7000p_config nim7090_dib7000p_config = {
  2331. .output_mpeg2_in_188_bytes = 1,
  2332. .hostbus_diversity = 1,
  2333. .tuner_is_baseband = 1,
  2334. .update_lna = tfe7790p_update_lna, /* GPIO used is the same as TFE7790 */
  2335. .agc_config_count = 2,
  2336. .agc = dib7090_agc_config,
  2337. .bw = &dib7090_clock_config_12_mhz,
  2338. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2339. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2340. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2341. .pwm_freq_div = 0,
  2342. .agc_control = dib7090_agc_restart,
  2343. .spur_protect = 0,
  2344. .disable_sample_and_hold = 0,
  2345. .enable_current_mirror = 0,
  2346. .diversity_delay = 0,
  2347. .output_mode = OUTMODE_MPEG2_FIFO,
  2348. .enMpegOutput = 1,
  2349. };
  2350. static int tfe7090p_pvr_update_lna(struct dvb_frontend *fe, u16 agc_global)
  2351. {
  2352. struct dvb_usb_adapter *adap = fe->dvb->priv;
  2353. struct dib0700_adapter_state *state = adap->priv;
  2354. deb_info("TFE7090P-PVR update LNA: agc global=%i", agc_global);
  2355. if (agc_global < 25000) {
  2356. state->dib7000p_ops.set_gpio(fe, 5, 0, 0);
  2357. state->dib7000p_ops.set_agc1_min(fe, 0);
  2358. } else {
  2359. state->dib7000p_ops.set_gpio(fe, 5, 0, 1);
  2360. state->dib7000p_ops.set_agc1_min(fe, 32768);
  2361. }
  2362. return 0;
  2363. }
  2364. static struct dib7000p_config tfe7090pvr_dib7000p_config[2] = {
  2365. {
  2366. .output_mpeg2_in_188_bytes = 1,
  2367. .hostbus_diversity = 1,
  2368. .tuner_is_baseband = 1,
  2369. .update_lna = tfe7090p_pvr_update_lna,
  2370. .agc_config_count = 2,
  2371. .agc = dib7090_agc_config,
  2372. .bw = &dib7090_clock_config_12_mhz,
  2373. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2374. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2375. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2376. .pwm_freq_div = 0,
  2377. .agc_control = dib7090_agc_restart,
  2378. .spur_protect = 0,
  2379. .disable_sample_and_hold = 0,
  2380. .enable_current_mirror = 0,
  2381. .diversity_delay = 0,
  2382. .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
  2383. .default_i2c_addr = 0x90,
  2384. .enMpegOutput = 1,
  2385. }, {
  2386. .output_mpeg2_in_188_bytes = 1,
  2387. .hostbus_diversity = 1,
  2388. .tuner_is_baseband = 1,
  2389. .update_lna = tfe7090p_pvr_update_lna,
  2390. .agc_config_count = 2,
  2391. .agc = dib7090_agc_config,
  2392. .bw = &dib7090_clock_config_12_mhz,
  2393. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2394. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2395. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2396. .pwm_freq_div = 0,
  2397. .agc_control = dib7090_agc_restart,
  2398. .spur_protect = 0,
  2399. .disable_sample_and_hold = 0,
  2400. .enable_current_mirror = 0,
  2401. .diversity_delay = 0,
  2402. .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
  2403. .default_i2c_addr = 0x92,
  2404. .enMpegOutput = 0,
  2405. }
  2406. };
  2407. static struct dib0090_config nim7090_dib0090_config = {
  2408. .io.clock_khz = 12000,
  2409. .io.pll_bypass = 0,
  2410. .io.pll_range = 0,
  2411. .io.pll_prediv = 3,
  2412. .io.pll_loopdiv = 6,
  2413. .io.adc_clock_ratio = 0,
  2414. .io.pll_int_loop_filt = 0,
  2415. .freq_offset_khz_uhf = 0,
  2416. .freq_offset_khz_vhf = 0,
  2417. .clkouttobamse = 1,
  2418. .analog_output = 0,
  2419. .wbd_vhf_offset = 0,
  2420. .wbd_cband_offset = 0,
  2421. .use_pwm_agc = 1,
  2422. .clkoutdrive = 0,
  2423. .fref_clock_ratio = 0,
  2424. .wbd = dib7090_wbd_table,
  2425. .ls_cfg_pad_drv = 0,
  2426. .data_tx_drv = 0,
  2427. .low_if = NULL,
  2428. .in_soc = 1,
  2429. };
  2430. static struct dib7000p_config tfe7790p_dib7000p_config = {
  2431. .output_mpeg2_in_188_bytes = 1,
  2432. .hostbus_diversity = 1,
  2433. .tuner_is_baseband = 1,
  2434. .update_lna = tfe7790p_update_lna,
  2435. .agc_config_count = 2,
  2436. .agc = dib7090_agc_config,
  2437. .bw = &dib7090_clock_config_12_mhz,
  2438. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2439. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2440. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2441. .pwm_freq_div = 0,
  2442. .agc_control = dib7090_agc_restart,
  2443. .spur_protect = 0,
  2444. .disable_sample_and_hold = 0,
  2445. .enable_current_mirror = 0,
  2446. .diversity_delay = 0,
  2447. .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
  2448. .enMpegOutput = 1,
  2449. };
  2450. static struct dib0090_config tfe7790p_dib0090_config = {
  2451. .io.clock_khz = 12000,
  2452. .io.pll_bypass = 0,
  2453. .io.pll_range = 0,
  2454. .io.pll_prediv = 3,
  2455. .io.pll_loopdiv = 6,
  2456. .io.adc_clock_ratio = 0,
  2457. .io.pll_int_loop_filt = 0,
  2458. .freq_offset_khz_uhf = 0,
  2459. .freq_offset_khz_vhf = 0,
  2460. .clkouttobamse = 1,
  2461. .analog_output = 0,
  2462. .wbd_vhf_offset = 0,
  2463. .wbd_cband_offset = 0,
  2464. .use_pwm_agc = 1,
  2465. .clkoutdrive = 0,
  2466. .fref_clock_ratio = 0,
  2467. .wbd = dib7090_wbd_table,
  2468. .ls_cfg_pad_drv = 0,
  2469. .data_tx_drv = 0,
  2470. .low_if = NULL,
  2471. .in_soc = 1,
  2472. .force_cband_input = 0,
  2473. .is_dib7090e = 0,
  2474. .force_crystal_mode = 1,
  2475. };
  2476. static struct dib0090_config tfe7090pvr_dib0090_config[2] = {
  2477. {
  2478. .io.clock_khz = 12000,
  2479. .io.pll_bypass = 0,
  2480. .io.pll_range = 0,
  2481. .io.pll_prediv = 3,
  2482. .io.pll_loopdiv = 6,
  2483. .io.adc_clock_ratio = 0,
  2484. .io.pll_int_loop_filt = 0,
  2485. .freq_offset_khz_uhf = 50,
  2486. .freq_offset_khz_vhf = 70,
  2487. .clkouttobamse = 1,
  2488. .analog_output = 0,
  2489. .wbd_vhf_offset = 0,
  2490. .wbd_cband_offset = 0,
  2491. .use_pwm_agc = 1,
  2492. .clkoutdrive = 0,
  2493. .fref_clock_ratio = 0,
  2494. .wbd = dib7090_wbd_table,
  2495. .ls_cfg_pad_drv = 0,
  2496. .data_tx_drv = 0,
  2497. .low_if = NULL,
  2498. .in_soc = 1,
  2499. }, {
  2500. .io.clock_khz = 12000,
  2501. .io.pll_bypass = 0,
  2502. .io.pll_range = 0,
  2503. .io.pll_prediv = 3,
  2504. .io.pll_loopdiv = 6,
  2505. .io.adc_clock_ratio = 0,
  2506. .io.pll_int_loop_filt = 0,
  2507. .freq_offset_khz_uhf = -50,
  2508. .freq_offset_khz_vhf = -70,
  2509. .clkouttobamse = 1,
  2510. .analog_output = 0,
  2511. .wbd_vhf_offset = 0,
  2512. .wbd_cband_offset = 0,
  2513. .use_pwm_agc = 1,
  2514. .clkoutdrive = 0,
  2515. .fref_clock_ratio = 0,
  2516. .wbd = dib7090_wbd_table,
  2517. .ls_cfg_pad_drv = 0,
  2518. .data_tx_drv = 0,
  2519. .low_if = NULL,
  2520. .in_soc = 1,
  2521. }
  2522. };
  2523. static int nim7090_frontend_attach(struct dvb_usb_adapter *adap)
  2524. {
  2525. struct dib0700_adapter_state *state = adap->priv;
  2526. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2527. return -ENODEV;
  2528. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2529. msleep(20);
  2530. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2531. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2532. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2533. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2534. msleep(20);
  2535. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2536. msleep(20);
  2537. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2538. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, &nim7090_dib7000p_config) != 0) {
  2539. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
  2540. dvb_detach(state->dib7000p_ops.set_wbd_ref);
  2541. return -ENODEV;
  2542. }
  2543. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, &nim7090_dib7000p_config);
  2544. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2545. }
  2546. static int nim7090_tuner_attach(struct dvb_usb_adapter *adap)
  2547. {
  2548. struct dib0700_adapter_state *st = adap->priv;
  2549. struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
  2550. nim7090_dib0090_config.reset = st->dib7000p_ops.tuner_sleep,
  2551. nim7090_dib0090_config.sleep = st->dib7000p_ops.tuner_sleep,
  2552. nim7090_dib0090_config.get_adc_power = st->dib7000p_ops.get_adc_power;
  2553. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &nim7090_dib0090_config) == NULL)
  2554. return -ENODEV;
  2555. st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  2556. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  2557. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
  2558. return 0;
  2559. }
  2560. static int tfe7090pvr_frontend0_attach(struct dvb_usb_adapter *adap)
  2561. {
  2562. struct dib0700_state *st = adap->dev->priv;
  2563. struct dib0700_adapter_state *state = adap->priv;
  2564. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2565. return -ENODEV;
  2566. /* The TFE7090 requires the dib0700 to not be in master mode */
  2567. st->disable_streaming_master_mode = 1;
  2568. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2569. msleep(20);
  2570. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2571. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2572. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2573. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2574. msleep(20);
  2575. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2576. msleep(20);
  2577. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2578. /* initialize IC 0 */
  2579. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, &tfe7090pvr_dib7000p_config[0]) != 0) {
  2580. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
  2581. dvb_detach(state->dib7000p_ops.set_wbd_ref);
  2582. return -ENODEV;
  2583. }
  2584. dib0700_set_i2c_speed(adap->dev, 340);
  2585. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x90, &tfe7090pvr_dib7000p_config[0]);
  2586. if (adap->fe_adap[0].fe == NULL)
  2587. return -ENODEV;
  2588. state->dib7000p_ops.slave_reset(adap->fe_adap[0].fe);
  2589. return 0;
  2590. }
  2591. static int tfe7090pvr_frontend1_attach(struct dvb_usb_adapter *adap)
  2592. {
  2593. struct i2c_adapter *i2c;
  2594. struct dib0700_adapter_state *state = adap->priv;
  2595. if (adap->dev->adapter[0].fe_adap[0].fe == NULL) {
  2596. err("the master dib7090 has to be initialized first");
  2597. return -ENODEV; /* the master device has not been initialized */
  2598. }
  2599. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2600. return -ENODEV;
  2601. i2c = state->dib7000p_ops.get_i2c_master(adap->dev->adapter[0].fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_6_7, 1);
  2602. if (state->dib7000p_ops.i2c_enumeration(i2c, 1, 0x10, &tfe7090pvr_dib7000p_config[1]) != 0) {
  2603. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__);
  2604. dvb_detach(state->dib7000p_ops.set_wbd_ref);
  2605. return -ENODEV;
  2606. }
  2607. adap->fe_adap[0].fe = state->dib7000p_ops.init(i2c, 0x92, &tfe7090pvr_dib7000p_config[1]);
  2608. dib0700_set_i2c_speed(adap->dev, 200);
  2609. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2610. }
  2611. static int tfe7090pvr_tuner0_attach(struct dvb_usb_adapter *adap)
  2612. {
  2613. struct dib0700_adapter_state *st = adap->priv;
  2614. struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
  2615. tfe7090pvr_dib0090_config[0].reset = st->dib7000p_ops.tuner_sleep;
  2616. tfe7090pvr_dib0090_config[0].sleep = st->dib7000p_ops.tuner_sleep;
  2617. tfe7090pvr_dib0090_config[0].get_adc_power = st->dib7000p_ops.get_adc_power;
  2618. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[0]) == NULL)
  2619. return -ENODEV;
  2620. st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  2621. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  2622. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
  2623. return 0;
  2624. }
  2625. static int tfe7090pvr_tuner1_attach(struct dvb_usb_adapter *adap)
  2626. {
  2627. struct dib0700_adapter_state *st = adap->priv;
  2628. struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
  2629. tfe7090pvr_dib0090_config[1].reset = st->dib7000p_ops.tuner_sleep;
  2630. tfe7090pvr_dib0090_config[1].sleep = st->dib7000p_ops.tuner_sleep;
  2631. tfe7090pvr_dib0090_config[1].get_adc_power = st->dib7000p_ops.get_adc_power;
  2632. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[1]) == NULL)
  2633. return -ENODEV;
  2634. st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  2635. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  2636. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
  2637. return 0;
  2638. }
  2639. static int tfe7790p_frontend_attach(struct dvb_usb_adapter *adap)
  2640. {
  2641. struct dib0700_state *st = adap->dev->priv;
  2642. struct dib0700_adapter_state *state = adap->priv;
  2643. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2644. return -ENODEV;
  2645. /* The TFE7790P requires the dib0700 to not be in master mode */
  2646. st->disable_streaming_master_mode = 1;
  2647. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2648. msleep(20);
  2649. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2650. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2651. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2652. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2653. msleep(20);
  2654. dib0700_ctrl_clock(adap->dev, 72, 1);
  2655. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2656. msleep(20);
  2657. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2658. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap,
  2659. 1, 0x10, &tfe7790p_dib7000p_config) != 0) {
  2660. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
  2661. __func__);
  2662. dvb_detach(state->dib7000p_ops.set_wbd_ref);
  2663. return -ENODEV;
  2664. }
  2665. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap,
  2666. 0x80, &tfe7790p_dib7000p_config);
  2667. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2668. }
  2669. static int tfe7790p_tuner_attach(struct dvb_usb_adapter *adap)
  2670. {
  2671. struct dib0700_adapter_state *st = adap->priv;
  2672. struct i2c_adapter *tun_i2c =
  2673. st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe);
  2674. tfe7790p_dib0090_config.reset = st->dib7000p_ops.tuner_sleep;
  2675. tfe7790p_dib0090_config.sleep = st->dib7000p_ops.tuner_sleep;
  2676. tfe7790p_dib0090_config.get_adc_power = st->dib7000p_ops.get_adc_power;
  2677. if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c,
  2678. &tfe7790p_dib0090_config) == NULL)
  2679. return -ENODEV;
  2680. st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  2681. st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
  2682. adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup;
  2683. return 0;
  2684. }
  2685. /* STK7070PD */
  2686. static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
  2687. {
  2688. .output_mpeg2_in_188_bytes = 1,
  2689. .agc_config_count = 1,
  2690. .agc = &dib7070_agc_config,
  2691. .bw = &dib7070_bw_config_12_mhz,
  2692. .tuner_is_baseband = 1,
  2693. .spur_protect = 1,
  2694. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2695. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2696. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2697. .hostbus_diversity = 1,
  2698. }, {
  2699. .output_mpeg2_in_188_bytes = 1,
  2700. .agc_config_count = 1,
  2701. .agc = &dib7070_agc_config,
  2702. .bw = &dib7070_bw_config_12_mhz,
  2703. .tuner_is_baseband = 1,
  2704. .spur_protect = 1,
  2705. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  2706. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  2707. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  2708. .hostbus_diversity = 1,
  2709. }
  2710. };
  2711. static void stk7070pd_init(struct dvb_usb_device *dev)
  2712. {
  2713. dib0700_set_gpio(dev, GPIO6, GPIO_OUT, 1);
  2714. msleep(10);
  2715. dib0700_set_gpio(dev, GPIO9, GPIO_OUT, 1);
  2716. dib0700_set_gpio(dev, GPIO4, GPIO_OUT, 1);
  2717. dib0700_set_gpio(dev, GPIO7, GPIO_OUT, 1);
  2718. dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 0);
  2719. dib0700_ctrl_clock(dev, 72, 1);
  2720. msleep(10);
  2721. dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 1);
  2722. }
  2723. static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap)
  2724. {
  2725. struct dib0700_adapter_state *state = adap->priv;
  2726. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2727. return -ENODEV;
  2728. stk7070pd_init(adap->dev);
  2729. msleep(10);
  2730. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2731. if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18,
  2732. stk7070pd_dib7000p_config) != 0) {
  2733. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
  2734. __func__);
  2735. dvb_detach(state->dib7000p_ops.set_wbd_ref);
  2736. return -ENODEV;
  2737. }
  2738. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, &stk7070pd_dib7000p_config[0]);
  2739. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2740. }
  2741. static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap)
  2742. {
  2743. struct dib0700_adapter_state *state = adap->priv;
  2744. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2745. return -ENODEV;
  2746. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x82, &stk7070pd_dib7000p_config[1]);
  2747. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2748. }
  2749. static int novatd_read_status_override(struct dvb_frontend *fe,
  2750. enum fe_status *stat)
  2751. {
  2752. struct dvb_usb_adapter *adap = fe->dvb->priv;
  2753. struct dvb_usb_device *dev = adap->dev;
  2754. struct dib0700_state *state = dev->priv;
  2755. int ret;
  2756. ret = state->read_status(fe, stat);
  2757. if (!ret)
  2758. dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT,
  2759. !!(*stat & FE_HAS_LOCK));
  2760. return ret;
  2761. }
  2762. static int novatd_sleep_override(struct dvb_frontend* fe)
  2763. {
  2764. struct dvb_usb_adapter *adap = fe->dvb->priv;
  2765. struct dvb_usb_device *dev = adap->dev;
  2766. struct dib0700_state *state = dev->priv;
  2767. /* turn off LED */
  2768. dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT, 0);
  2769. return state->sleep(fe);
  2770. }
  2771. /*
  2772. * novatd_frontend_attach - Nova-TD specific attach
  2773. *
  2774. * Nova-TD has GPIO0, 1 and 2 for LEDs. So do not fiddle with them except for
  2775. * information purposes.
  2776. */
  2777. static int novatd_frontend_attach(struct dvb_usb_adapter *adap)
  2778. {
  2779. struct dvb_usb_device *dev = adap->dev;
  2780. struct dib0700_state *st = dev->priv;
  2781. struct dib0700_adapter_state *state = adap->priv;
  2782. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2783. return -ENODEV;
  2784. if (adap->id == 0) {
  2785. stk7070pd_init(dev);
  2786. /* turn the power LED on, the other two off (just in case) */
  2787. dib0700_set_gpio(dev, GPIO0, GPIO_OUT, 0);
  2788. dib0700_set_gpio(dev, GPIO1, GPIO_OUT, 0);
  2789. dib0700_set_gpio(dev, GPIO2, GPIO_OUT, 1);
  2790. if (state->dib7000p_ops.i2c_enumeration(&dev->i2c_adap, 2, 18,
  2791. stk7070pd_dib7000p_config) != 0) {
  2792. err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n",
  2793. __func__);
  2794. dvb_detach(state->dib7000p_ops.set_wbd_ref);
  2795. return -ENODEV;
  2796. }
  2797. }
  2798. adap->fe_adap[0].fe = state->dib7000p_ops.init(&dev->i2c_adap,
  2799. adap->id == 0 ? 0x80 : 0x82,
  2800. &stk7070pd_dib7000p_config[adap->id]);
  2801. if (adap->fe_adap[0].fe == NULL)
  2802. return -ENODEV;
  2803. st->read_status = adap->fe_adap[0].fe->ops.read_status;
  2804. adap->fe_adap[0].fe->ops.read_status = novatd_read_status_override;
  2805. st->sleep = adap->fe_adap[0].fe->ops.sleep;
  2806. adap->fe_adap[0].fe->ops.sleep = novatd_sleep_override;
  2807. return 0;
  2808. }
  2809. /* S5H1411 */
  2810. static struct s5h1411_config pinnacle_801e_config = {
  2811. .output_mode = S5H1411_PARALLEL_OUTPUT,
  2812. .gpio = S5H1411_GPIO_OFF,
  2813. .mpeg_timing = S5H1411_MPEGTIMING_NONCONTINUOUS_NONINVERTING_CLOCK,
  2814. .qam_if = S5H1411_IF_44000,
  2815. .vsb_if = S5H1411_IF_44000,
  2816. .inversion = S5H1411_INVERSION_OFF,
  2817. .status_mode = S5H1411_DEMODLOCKING
  2818. };
  2819. /* Pinnacle PCTV HD Pro 801e GPIOs map:
  2820. GPIO0 - currently unknown
  2821. GPIO1 - xc5000 tuner reset
  2822. GPIO2 - CX25843 sleep
  2823. GPIO3 - currently unknown
  2824. GPIO4 - currently unknown
  2825. GPIO6 - currently unknown
  2826. GPIO7 - currently unknown
  2827. GPIO9 - currently unknown
  2828. GPIO10 - CX25843 reset
  2829. */
  2830. static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap)
  2831. {
  2832. struct dib0700_state *st = adap->dev->priv;
  2833. /* Make use of the new i2c functions from FW 1.20 */
  2834. st->fw_use_new_i2c_api = 1;
  2835. /* The s5h1411 requires the dib0700 to not be in master mode */
  2836. st->disable_streaming_master_mode = 1;
  2837. /* All msleep values taken from Windows USB trace */
  2838. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
  2839. dib0700_set_gpio(adap->dev, GPIO3, GPIO_OUT, 0);
  2840. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2841. msleep(400);
  2842. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2843. msleep(60);
  2844. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2845. msleep(30);
  2846. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  2847. dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
  2848. dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
  2849. dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
  2850. dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 0);
  2851. msleep(30);
  2852. /* Put the CX25843 to sleep for now since we're in digital mode */
  2853. dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
  2854. /* GPIOs are initialized, do the attach */
  2855. adap->fe_adap[0].fe = dvb_attach(s5h1411_attach, &pinnacle_801e_config,
  2856. &adap->dev->i2c_adap);
  2857. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  2858. }
  2859. static int dib0700_xc5000_tuner_callback(void *priv, int component,
  2860. int command, int arg)
  2861. {
  2862. struct dvb_usb_adapter *adap = priv;
  2863. if (command == XC5000_TUNER_RESET) {
  2864. /* Reset the tuner */
  2865. dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 0);
  2866. msleep(10);
  2867. dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 1);
  2868. msleep(10);
  2869. } else {
  2870. err("xc5000: unknown tuner callback command: %d\n", command);
  2871. return -EINVAL;
  2872. }
  2873. return 0;
  2874. }
  2875. static struct xc5000_config s5h1411_xc5000_tunerconfig = {
  2876. .i2c_address = 0x64,
  2877. .if_khz = 5380,
  2878. };
  2879. static int xc5000_tuner_attach(struct dvb_usb_adapter *adap)
  2880. {
  2881. /* FIXME: generalize & move to common area */
  2882. adap->fe_adap[0].fe->callback = dib0700_xc5000_tuner_callback;
  2883. return dvb_attach(xc5000_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap,
  2884. &s5h1411_xc5000_tunerconfig)
  2885. == NULL ? -ENODEV : 0;
  2886. }
  2887. static int dib0700_xc4000_tuner_callback(void *priv, int component,
  2888. int command, int arg)
  2889. {
  2890. struct dvb_usb_adapter *adap = priv;
  2891. struct dib0700_adapter_state *state = adap->priv;
  2892. if (command == XC4000_TUNER_RESET) {
  2893. /* Reset the tuner */
  2894. state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 0);
  2895. msleep(10);
  2896. state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1);
  2897. } else {
  2898. err("xc4000: unknown tuner callback command: %d\n", command);
  2899. return -EINVAL;
  2900. }
  2901. return 0;
  2902. }
  2903. static struct dibx000_agc_config stk7700p_7000p_xc4000_agc_config = {
  2904. .band_caps = BAND_UHF | BAND_VHF,
  2905. .setup = 0x64,
  2906. .inv_gain = 0x02c8,
  2907. .time_stabiliz = 0x15,
  2908. .alpha_level = 0x00,
  2909. .thlock = 0x76,
  2910. .wbd_inv = 0x01,
  2911. .wbd_ref = 0x0b33,
  2912. .wbd_sel = 0x00,
  2913. .wbd_alpha = 0x02,
  2914. .agc1_max = 0x00,
  2915. .agc1_min = 0x00,
  2916. .agc2_max = 0x9b26,
  2917. .agc2_min = 0x26ca,
  2918. .agc1_pt1 = 0x00,
  2919. .agc1_pt2 = 0x00,
  2920. .agc1_pt3 = 0x00,
  2921. .agc1_slope1 = 0x00,
  2922. .agc1_slope2 = 0x00,
  2923. .agc2_pt1 = 0x00,
  2924. .agc2_pt2 = 0x80,
  2925. .agc2_slope1 = 0x1d,
  2926. .agc2_slope2 = 0x1d,
  2927. .alpha_mant = 0x11,
  2928. .alpha_exp = 0x1b,
  2929. .beta_mant = 0x17,
  2930. .beta_exp = 0x33,
  2931. .perform_agc_softsplit = 0x00,
  2932. };
  2933. static struct dibx000_bandwidth_config stk7700p_xc4000_pll_config = {
  2934. .internal = 60000,
  2935. .sampling = 30000,
  2936. .pll_prediv = 1,
  2937. .pll_ratio = 8,
  2938. .pll_range = 3,
  2939. .pll_reset = 1,
  2940. .pll_bypass = 0,
  2941. .enable_refdiv = 0,
  2942. .bypclk_div = 0,
  2943. .IO_CLK_en_core = 1,
  2944. .ADClkSrc = 1,
  2945. .modulo = 0,
  2946. .sad_cfg = (3 << 14) | (1 << 12) | 524, /* sad_cfg: refsel, sel, freq_15k */
  2947. .ifreq = 39370534,
  2948. .timf = 20452225,
  2949. .xtal_hz = 30000000
  2950. };
  2951. /* FIXME: none of these inputs are validated yet */
  2952. static struct dib7000p_config pctv_340e_config = {
  2953. .output_mpeg2_in_188_bytes = 1,
  2954. .agc_config_count = 1,
  2955. .agc = &stk7700p_7000p_xc4000_agc_config,
  2956. .bw = &stk7700p_xc4000_pll_config,
  2957. .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
  2958. .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
  2959. .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
  2960. };
  2961. /* PCTV 340e GPIOs map:
  2962. dib0700:
  2963. GPIO2 - CX25843 sleep
  2964. GPIO3 - CS5340 reset
  2965. GPIO5 - IRD
  2966. GPIO6 - Power Supply
  2967. GPIO8 - LNA (1=off 0=on)
  2968. GPIO10 - CX25843 reset
  2969. dib7000:
  2970. GPIO8 - xc4000 reset
  2971. */
  2972. static int pctv340e_frontend_attach(struct dvb_usb_adapter *adap)
  2973. {
  2974. struct dib0700_state *st = adap->dev->priv;
  2975. struct dib0700_adapter_state *state = adap->priv;
  2976. if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
  2977. return -ENODEV;
  2978. /* Power Supply on */
  2979. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  2980. msleep(50);
  2981. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  2982. msleep(100); /* Allow power supply to settle before probing */
  2983. /* cx25843 reset */
  2984. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  2985. msleep(1); /* cx25843 datasheet say 350us required */
  2986. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  2987. /* LNA off for now */
  2988. dib0700_set_gpio(adap->dev, GPIO8, GPIO_OUT, 1);
  2989. /* Put the CX25843 to sleep for now since we're in digital mode */
  2990. dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);
  2991. /* FIXME: not verified yet */
  2992. dib0700_ctrl_clock(adap->dev, 72, 1);
  2993. msleep(500);
  2994. if (state->dib7000p_ops.dib7000pc_detection(&adap->dev->i2c_adap) == 0) {
  2995. /* Demodulator not found for some reason? */
  2996. dvb_detach(state->dib7000p_ops.set_wbd_ref);
  2997. return -ENODEV;
  2998. }
  2999. adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x12,
  3000. &pctv_340e_config);
  3001. st->is_dib7000pc = 1;
  3002. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  3003. }
  3004. static struct xc4000_config dib7000p_xc4000_tunerconfig = {
  3005. .i2c_address = 0x61,
  3006. .default_pm = 1,
  3007. .dvb_amplitude = 0,
  3008. .set_smoothedcvbs = 0,
  3009. .if_khz = 5400
  3010. };
  3011. static int xc4000_tuner_attach(struct dvb_usb_adapter *adap)
  3012. {
  3013. struct i2c_adapter *tun_i2c;
  3014. struct dib0700_adapter_state *state = adap->priv;
  3015. /* The xc4000 is not on the main i2c bus */
  3016. tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
  3017. DIBX000_I2C_INTERFACE_TUNER, 1);
  3018. if (tun_i2c == NULL) {
  3019. printk(KERN_ERR "Could not reach tuner i2c bus\n");
  3020. return 0;
  3021. }
  3022. /* Setup the reset callback */
  3023. adap->fe_adap[0].fe->callback = dib0700_xc4000_tuner_callback;
  3024. return dvb_attach(xc4000_attach, adap->fe_adap[0].fe, tun_i2c,
  3025. &dib7000p_xc4000_tunerconfig)
  3026. == NULL ? -ENODEV : 0;
  3027. }
  3028. static struct lgdt3305_config hcw_lgdt3305_config = {
  3029. .i2c_addr = 0x0e,
  3030. .mpeg_mode = LGDT3305_MPEG_PARALLEL,
  3031. .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
  3032. .tpvalid_polarity = LGDT3305_TP_VALID_LOW,
  3033. .deny_i2c_rptr = 0,
  3034. .spectral_inversion = 1,
  3035. .qam_if_khz = 6000,
  3036. .vsb_if_khz = 6000,
  3037. .usref_8vsb = 0x0500,
  3038. };
  3039. static struct mxl5007t_config hcw_mxl5007t_config = {
  3040. .xtal_freq_hz = MxL_XTAL_25_MHZ,
  3041. .if_freq_hz = MxL_IF_6_MHZ,
  3042. .invert_if = 1,
  3043. };
  3044. /* TIGER-ATSC map:
  3045. GPIO0 - LNA_CTR (H: LNA power enabled, L: LNA power disabled)
  3046. GPIO1 - ANT_SEL (H: VPA, L: MCX)
  3047. GPIO4 - SCL2
  3048. GPIO6 - EN_TUNER
  3049. GPIO7 - SDA2
  3050. GPIO10 - DEM_RST
  3051. MXL is behind LG's i2c repeater. LG is on SCL2/SDA2 gpios on the DIB
  3052. */
  3053. static int lgdt3305_frontend_attach(struct dvb_usb_adapter *adap)
  3054. {
  3055. struct dib0700_state *st = adap->dev->priv;
  3056. /* Make use of the new i2c functions from FW 1.20 */
  3057. st->fw_use_new_i2c_api = 1;
  3058. st->disable_streaming_master_mode = 1;
  3059. /* fe power enable */
  3060. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  3061. msleep(30);
  3062. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  3063. msleep(30);
  3064. /* demod reset */
  3065. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  3066. msleep(30);
  3067. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  3068. msleep(30);
  3069. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  3070. msleep(30);
  3071. adap->fe_adap[0].fe = dvb_attach(lgdt3305_attach,
  3072. &hcw_lgdt3305_config,
  3073. &adap->dev->i2c_adap);
  3074. return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
  3075. }
  3076. static int mxl5007t_tuner_attach(struct dvb_usb_adapter *adap)
  3077. {
  3078. return dvb_attach(mxl5007t_attach, adap->fe_adap[0].fe,
  3079. &adap->dev->i2c_adap, 0x60,
  3080. &hcw_mxl5007t_config) == NULL ? -ENODEV : 0;
  3081. }
  3082. static int xbox_one_attach(struct dvb_usb_adapter *adap)
  3083. {
  3084. struct dib0700_state *st = adap->dev->priv;
  3085. struct i2c_client *client_demod, *client_tuner;
  3086. struct dvb_usb_device *d = adap->dev;
  3087. struct mn88472_config mn88472_config = { };
  3088. struct tda18250_config tda18250_config;
  3089. struct i2c_board_info info;
  3090. st->fw_use_new_i2c_api = 1;
  3091. st->disable_streaming_master_mode = 1;
  3092. /* fe power enable */
  3093. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
  3094. msleep(30);
  3095. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
  3096. msleep(30);
  3097. /* demod reset */
  3098. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  3099. msleep(30);
  3100. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
  3101. msleep(30);
  3102. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
  3103. msleep(30);
  3104. /* attach demod */
  3105. mn88472_config.fe = &adap->fe_adap[0].fe;
  3106. mn88472_config.i2c_wr_max = 22;
  3107. mn88472_config.xtal = 20500000;
  3108. mn88472_config.ts_mode = PARALLEL_TS_MODE;
  3109. mn88472_config.ts_clock = FIXED_TS_CLOCK;
  3110. memset(&info, 0, sizeof(struct i2c_board_info));
  3111. strlcpy(info.type, "mn88472", I2C_NAME_SIZE);
  3112. info.addr = 0x18;
  3113. info.platform_data = &mn88472_config;
  3114. request_module(info.type);
  3115. client_demod = i2c_new_device(&d->i2c_adap, &info);
  3116. if (client_demod == NULL || client_demod->dev.driver == NULL)
  3117. goto fail_demod_device;
  3118. if (!try_module_get(client_demod->dev.driver->owner))
  3119. goto fail_demod_module;
  3120. st->i2c_client_demod = client_demod;
  3121. adap->fe_adap[0].fe = mn88472_config.get_dvb_frontend(client_demod);
  3122. /* attach tuner */
  3123. memset(&tda18250_config, 0, sizeof(tda18250_config));
  3124. tda18250_config.if_dvbt_6 = 3950;
  3125. tda18250_config.if_dvbt_7 = 4450;
  3126. tda18250_config.if_dvbt_8 = 4950;
  3127. tda18250_config.if_dvbc_6 = 4950;
  3128. tda18250_config.if_dvbc_8 = 4950;
  3129. tda18250_config.if_atsc = 4079;
  3130. tda18250_config.loopthrough = true;
  3131. tda18250_config.xtal_freq = TDA18250_XTAL_FREQ_27MHZ;
  3132. tda18250_config.fe = adap->fe_adap[0].fe;
  3133. memset(&info, 0, sizeof(struct i2c_board_info));
  3134. strlcpy(info.type, "tda18250", I2C_NAME_SIZE);
  3135. info.addr = 0x60;
  3136. info.platform_data = &tda18250_config;
  3137. request_module(info.type);
  3138. client_tuner = i2c_new_device(&adap->dev->i2c_adap, &info);
  3139. if (client_tuner == NULL || client_tuner->dev.driver == NULL)
  3140. goto fail_tuner_device;
  3141. if (!try_module_get(client_tuner->dev.driver->owner))
  3142. goto fail_tuner_module;
  3143. st->i2c_client_tuner = client_tuner;
  3144. return 0;
  3145. fail_tuner_module:
  3146. i2c_unregister_device(client_tuner);
  3147. fail_tuner_device:
  3148. module_put(client_demod->dev.driver->owner);
  3149. fail_demod_module:
  3150. i2c_unregister_device(client_demod);
  3151. fail_demod_device:
  3152. return -ENODEV;
  3153. }
  3154. /* DVB-USB and USB stuff follows */
  3155. struct usb_device_id dib0700_usb_id_table[] = {
  3156. /* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
  3157. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) },
  3158. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
  3159. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
  3160. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
  3161. /* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
  3162. { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) },
  3163. { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) },
  3164. { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
  3165. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
  3166. /* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
  3167. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) },
  3168. { USB_DEVICE(USB_VID_TERRATEC,
  3169. USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
  3170. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
  3171. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) },
  3172. /* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) },
  3173. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) },
  3174. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) },
  3175. { USB_DEVICE(USB_VID_PINNACLE,
  3176. USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) },
  3177. { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500_PC) },
  3178. /* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) },
  3179. { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U7000) },
  3180. { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) },
  3181. { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000) },
  3182. { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100) },
  3183. /* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) },
  3184. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) },
  3185. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_USB_XE) },
  3186. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_EXPRESSCARD_320CX) },
  3187. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV72E) },
  3188. /* 30 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73E) },
  3189. { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_EC372S) },
  3190. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) },
  3191. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) },
  3192. { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) },
  3193. /* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) },
  3194. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_3) },
  3195. { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U8000) },
  3196. { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700PH) },
  3197. { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) },
  3198. /* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) },
  3199. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) },
  3200. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_EXPRESS) },
  3201. { USB_DEVICE(USB_VID_TERRATEC,
  3202. USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2) },
  3203. { USB_DEVICE(USB_VID_SONY, USB_PID_SONY_PLAYTV) },
  3204. /* 45 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_PD378S) },
  3205. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC) },
  3206. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC_B210) },
  3207. { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_MC770) },
  3208. { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT) },
  3209. /* 50 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_Dlx) },
  3210. { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_H) },
  3211. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T3) },
  3212. { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T5) },
  3213. { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D) },
  3214. /* 55 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D_2) },
  3215. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73A) },
  3216. { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV73ESE) },
  3217. { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV282E) },
  3218. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7770P) },
  3219. /* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) },
  3220. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XPVR) },
  3221. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XP) },
  3222. { USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x000, 0x3f00) },
  3223. { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) },
  3224. /* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) },
  3225. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) },
  3226. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) },
  3227. { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DIVERSITY) },
  3228. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090M) },
  3229. /* 70 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM8096MD) },
  3230. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090MD) },
  3231. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM7090) },
  3232. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7090PVR) },
  3233. { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_AIRSTAR_TELESTICK_2) },
  3234. /* 75 */{ USB_DEVICE(USB_VID_MEDION, USB_PID_CREATIX_CTX1921) },
  3235. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E) },
  3236. { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E_SE) },
  3237. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7790P) },
  3238. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE8096P) },
  3239. /* 80 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_2) },
  3240. { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E) },
  3241. { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E_SE) },
  3242. { USB_DEVICE(USB_VID_PCTV, USB_PID_DIBCOM_STK8096PVR) },
  3243. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096PVR) },
  3244. /* 85 */{ USB_DEVICE(USB_VID_HAMA, USB_PID_HAMA_DVBT_HYBRID) },
  3245. { USB_DEVICE(USB_VID_MICROSOFT, USB_PID_XBOX_ONE_TUNER) },
  3246. { 0 } /* Terminating entry */
  3247. };
  3248. MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
  3249. #define DIB0700_DEFAULT_DEVICE_PROPERTIES \
  3250. .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
  3251. .usb_ctrl = DEVICE_SPECIFIC, \
  3252. .firmware = "dvb-usb-dib0700-1.20.fw", \
  3253. .download_firmware = dib0700_download_firmware, \
  3254. .no_reconnect = 1, \
  3255. .size_of_priv = sizeof(struct dib0700_state), \
  3256. .i2c_algo = &dib0700_i2c_algo, \
  3257. .identify_state = dib0700_identify_state
  3258. #define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
  3259. .streaming_ctrl = dib0700_streaming_ctrl, \
  3260. .stream = { \
  3261. .type = USB_BULK, \
  3262. .count = 4, \
  3263. .endpoint = ep, \
  3264. .u = { \
  3265. .bulk = { \
  3266. .buffersize = 39480, \
  3267. } \
  3268. } \
  3269. }
  3270. #define DIB0700_NUM_FRONTENDS(n) \
  3271. .num_frontends = n, \
  3272. .size_of_priv = sizeof(struct dib0700_adapter_state)
  3273. struct dvb_usb_device_properties dib0700_devices[] = {
  3274. {
  3275. DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3276. .num_adapters = 1,
  3277. .adapter = {
  3278. {
  3279. DIB0700_NUM_FRONTENDS(1),
  3280. .fe = {{
  3281. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3282. .pid_filter_count = 32,
  3283. .pid_filter = stk7700p_pid_filter,
  3284. .pid_filter_ctrl = stk7700p_pid_filter_ctrl,
  3285. .frontend_attach = stk7700p_frontend_attach,
  3286. .tuner_attach = stk7700p_tuner_attach,
  3287. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3288. }},
  3289. },
  3290. },
  3291. .num_device_descs = 8,
  3292. .devices = {
  3293. { "DiBcom STK7700P reference design",
  3294. { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
  3295. { NULL },
  3296. },
  3297. { "Hauppauge Nova-T Stick",
  3298. { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL },
  3299. { NULL },
  3300. },
  3301. { "AVerMedia AVerTV DVB-T Volar",
  3302. { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] },
  3303. { NULL },
  3304. },
  3305. { "Compro Videomate U500",
  3306. { &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] },
  3307. { NULL },
  3308. },
  3309. { "Uniwill STK7700P based (Hama and others)",
  3310. { &dib0700_usb_id_table[7], NULL },
  3311. { NULL },
  3312. },
  3313. { "Leadtek Winfast DTV Dongle (STK7700P based)",
  3314. { &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] },
  3315. { NULL },
  3316. },
  3317. { "AVerMedia AVerTV DVB-T Express",
  3318. { &dib0700_usb_id_table[20] },
  3319. { NULL },
  3320. },
  3321. { "Gigabyte U7000",
  3322. { &dib0700_usb_id_table[21], NULL },
  3323. { NULL },
  3324. }
  3325. },
  3326. .rc.core = {
  3327. .rc_interval = DEFAULT_RC_INTERVAL,
  3328. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3329. .rc_query = dib0700_rc_query_old_firmware,
  3330. .allowed_protos = RC_PROTO_BIT_RC5 |
  3331. RC_PROTO_BIT_RC6_MCE |
  3332. RC_PROTO_BIT_NEC,
  3333. .change_protocol = dib0700_change_protocol,
  3334. },
  3335. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3336. .num_adapters = 2,
  3337. .adapter = {
  3338. {
  3339. DIB0700_NUM_FRONTENDS(1),
  3340. .fe = {{
  3341. .frontend_attach = bristol_frontend_attach,
  3342. .tuner_attach = bristol_tuner_attach,
  3343. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3344. }},
  3345. }, {
  3346. DIB0700_NUM_FRONTENDS(1),
  3347. .fe = {{
  3348. .frontend_attach = bristol_frontend_attach,
  3349. .tuner_attach = bristol_tuner_attach,
  3350. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3351. }},
  3352. }
  3353. },
  3354. .num_device_descs = 1,
  3355. .devices = {
  3356. { "Hauppauge Nova-T 500 Dual DVB-T",
  3357. { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
  3358. { NULL },
  3359. },
  3360. },
  3361. .rc.core = {
  3362. .rc_interval = DEFAULT_RC_INTERVAL,
  3363. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3364. .rc_query = dib0700_rc_query_old_firmware,
  3365. .allowed_protos = RC_PROTO_BIT_RC5 |
  3366. RC_PROTO_BIT_RC6_MCE |
  3367. RC_PROTO_BIT_NEC,
  3368. .change_protocol = dib0700_change_protocol,
  3369. },
  3370. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3371. .num_adapters = 2,
  3372. .adapter = {
  3373. {
  3374. DIB0700_NUM_FRONTENDS(1),
  3375. .fe = {{
  3376. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3377. .pid_filter_count = 32,
  3378. .pid_filter = stk70x0p_pid_filter,
  3379. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3380. .frontend_attach = stk7700d_frontend_attach,
  3381. .tuner_attach = stk7700d_tuner_attach,
  3382. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3383. }},
  3384. }, {
  3385. DIB0700_NUM_FRONTENDS(1),
  3386. .fe = {{
  3387. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3388. .pid_filter_count = 32,
  3389. .pid_filter = stk70x0p_pid_filter,
  3390. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3391. .frontend_attach = stk7700d_frontend_attach,
  3392. .tuner_attach = stk7700d_tuner_attach,
  3393. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3394. }},
  3395. }
  3396. },
  3397. .num_device_descs = 5,
  3398. .devices = {
  3399. { "Pinnacle PCTV 2000e",
  3400. { &dib0700_usb_id_table[11], NULL },
  3401. { NULL },
  3402. },
  3403. { "Terratec Cinergy DT XS Diversity",
  3404. { &dib0700_usb_id_table[12], NULL },
  3405. { NULL },
  3406. },
  3407. { "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity",
  3408. { &dib0700_usb_id_table[13], NULL },
  3409. { NULL },
  3410. },
  3411. { "DiBcom STK7700D reference design",
  3412. { &dib0700_usb_id_table[14], NULL },
  3413. { NULL },
  3414. },
  3415. { "YUAN High-Tech DiBcom STK7700D",
  3416. { &dib0700_usb_id_table[55], NULL },
  3417. { NULL },
  3418. },
  3419. },
  3420. .rc.core = {
  3421. .rc_interval = DEFAULT_RC_INTERVAL,
  3422. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3423. .rc_query = dib0700_rc_query_old_firmware,
  3424. .allowed_protos = RC_PROTO_BIT_RC5 |
  3425. RC_PROTO_BIT_RC6_MCE |
  3426. RC_PROTO_BIT_NEC,
  3427. .change_protocol = dib0700_change_protocol,
  3428. },
  3429. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3430. .num_adapters = 1,
  3431. .adapter = {
  3432. {
  3433. DIB0700_NUM_FRONTENDS(1),
  3434. .fe = {{
  3435. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3436. .pid_filter_count = 32,
  3437. .pid_filter = stk70x0p_pid_filter,
  3438. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3439. .frontend_attach = stk7700P2_frontend_attach,
  3440. .tuner_attach = stk7700d_tuner_attach,
  3441. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3442. }},
  3443. },
  3444. },
  3445. .num_device_descs = 3,
  3446. .devices = {
  3447. { "ASUS My Cinema U3000 Mini DVBT Tuner",
  3448. { &dib0700_usb_id_table[23], NULL },
  3449. { NULL },
  3450. },
  3451. { "Yuan EC372S",
  3452. { &dib0700_usb_id_table[31], NULL },
  3453. { NULL },
  3454. },
  3455. { "Terratec Cinergy T Express",
  3456. { &dib0700_usb_id_table[42], NULL },
  3457. { NULL },
  3458. }
  3459. },
  3460. .rc.core = {
  3461. .rc_interval = DEFAULT_RC_INTERVAL,
  3462. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3463. .module_name = "dib0700",
  3464. .rc_query = dib0700_rc_query_old_firmware,
  3465. .allowed_protos = RC_PROTO_BIT_RC5 |
  3466. RC_PROTO_BIT_RC6_MCE |
  3467. RC_PROTO_BIT_NEC,
  3468. .change_protocol = dib0700_change_protocol,
  3469. },
  3470. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3471. .num_adapters = 1,
  3472. .adapter = {
  3473. {
  3474. DIB0700_NUM_FRONTENDS(1),
  3475. .fe = {{
  3476. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3477. .pid_filter_count = 32,
  3478. .pid_filter = stk70x0p_pid_filter,
  3479. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3480. .frontend_attach = stk7070p_frontend_attach,
  3481. .tuner_attach = dib7070p_tuner_attach,
  3482. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3483. }},
  3484. },
  3485. },
  3486. .num_device_descs = 12,
  3487. .devices = {
  3488. { "DiBcom STK7070P reference design",
  3489. { &dib0700_usb_id_table[15], NULL },
  3490. { NULL },
  3491. },
  3492. { "Pinnacle PCTV DVB-T Flash Stick",
  3493. { &dib0700_usb_id_table[16], NULL },
  3494. { NULL },
  3495. },
  3496. { "Artec T14BR DVB-T",
  3497. { &dib0700_usb_id_table[22], NULL },
  3498. { NULL },
  3499. },
  3500. { "ASUS My Cinema U3100 Mini DVBT Tuner",
  3501. { &dib0700_usb_id_table[24], NULL },
  3502. { NULL },
  3503. },
  3504. { "Hauppauge Nova-T Stick",
  3505. { &dib0700_usb_id_table[25], NULL },
  3506. { NULL },
  3507. },
  3508. { "Hauppauge Nova-T MyTV.t",
  3509. { &dib0700_usb_id_table[26], NULL },
  3510. { NULL },
  3511. },
  3512. { "Pinnacle PCTV 72e",
  3513. { &dib0700_usb_id_table[29], NULL },
  3514. { NULL },
  3515. },
  3516. { "Pinnacle PCTV 73e",
  3517. { &dib0700_usb_id_table[30], NULL },
  3518. { NULL },
  3519. },
  3520. { "Elgato EyeTV DTT",
  3521. { &dib0700_usb_id_table[49], NULL },
  3522. { NULL },
  3523. },
  3524. { "Yuan PD378S",
  3525. { &dib0700_usb_id_table[45], NULL },
  3526. { NULL },
  3527. },
  3528. { "Elgato EyeTV Dtt Dlx PD378S",
  3529. { &dib0700_usb_id_table[50], NULL },
  3530. { NULL },
  3531. },
  3532. { "Elgato EyeTV DTT rev. 2",
  3533. { &dib0700_usb_id_table[80], NULL },
  3534. { NULL },
  3535. },
  3536. },
  3537. .rc.core = {
  3538. .rc_interval = DEFAULT_RC_INTERVAL,
  3539. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3540. .module_name = "dib0700",
  3541. .rc_query = dib0700_rc_query_old_firmware,
  3542. .allowed_protos = RC_PROTO_BIT_RC5 |
  3543. RC_PROTO_BIT_RC6_MCE |
  3544. RC_PROTO_BIT_NEC,
  3545. .change_protocol = dib0700_change_protocol,
  3546. },
  3547. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3548. .num_adapters = 1,
  3549. .adapter = {
  3550. {
  3551. DIB0700_NUM_FRONTENDS(1),
  3552. .fe = {{
  3553. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3554. .pid_filter_count = 32,
  3555. .pid_filter = stk70x0p_pid_filter,
  3556. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3557. .frontend_attach = stk7070p_frontend_attach,
  3558. .tuner_attach = dib7070p_tuner_attach,
  3559. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3560. }},
  3561. },
  3562. },
  3563. .num_device_descs = 3,
  3564. .devices = {
  3565. { "Pinnacle PCTV 73A",
  3566. { &dib0700_usb_id_table[56], NULL },
  3567. { NULL },
  3568. },
  3569. { "Pinnacle PCTV 73e SE",
  3570. { &dib0700_usb_id_table[57], &dib0700_usb_id_table[65], NULL },
  3571. { NULL },
  3572. },
  3573. { "Pinnacle PCTV 282e",
  3574. { &dib0700_usb_id_table[58], &dib0700_usb_id_table[66], NULL },
  3575. { NULL },
  3576. },
  3577. },
  3578. .rc.core = {
  3579. .rc_interval = DEFAULT_RC_INTERVAL,
  3580. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3581. .module_name = "dib0700",
  3582. .rc_query = dib0700_rc_query_old_firmware,
  3583. .allowed_protos = RC_PROTO_BIT_RC5 |
  3584. RC_PROTO_BIT_RC6_MCE |
  3585. RC_PROTO_BIT_NEC,
  3586. .change_protocol = dib0700_change_protocol,
  3587. },
  3588. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3589. .num_adapters = 2,
  3590. .adapter = {
  3591. {
  3592. DIB0700_NUM_FRONTENDS(1),
  3593. .fe = {{
  3594. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3595. .pid_filter_count = 32,
  3596. .pid_filter = stk70x0p_pid_filter,
  3597. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3598. .frontend_attach = novatd_frontend_attach,
  3599. .tuner_attach = dib7070p_tuner_attach,
  3600. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3601. }},
  3602. }, {
  3603. DIB0700_NUM_FRONTENDS(1),
  3604. .fe = {{
  3605. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3606. .pid_filter_count = 32,
  3607. .pid_filter = stk70x0p_pid_filter,
  3608. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3609. .frontend_attach = novatd_frontend_attach,
  3610. .tuner_attach = dib7070p_tuner_attach,
  3611. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3612. }},
  3613. }
  3614. },
  3615. .num_device_descs = 3,
  3616. .devices = {
  3617. { "Hauppauge Nova-TD Stick (52009)",
  3618. { &dib0700_usb_id_table[35], NULL },
  3619. { NULL },
  3620. },
  3621. { "PCTV 2002e",
  3622. { &dib0700_usb_id_table[81], NULL },
  3623. { NULL },
  3624. },
  3625. { "PCTV 2002e SE",
  3626. { &dib0700_usb_id_table[82], NULL },
  3627. { NULL },
  3628. },
  3629. },
  3630. .rc.core = {
  3631. .rc_interval = DEFAULT_RC_INTERVAL,
  3632. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3633. .module_name = "dib0700",
  3634. .rc_query = dib0700_rc_query_old_firmware,
  3635. .allowed_protos = RC_PROTO_BIT_RC5 |
  3636. RC_PROTO_BIT_RC6_MCE |
  3637. RC_PROTO_BIT_NEC,
  3638. .change_protocol = dib0700_change_protocol,
  3639. },
  3640. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3641. .num_adapters = 2,
  3642. .adapter = {
  3643. {
  3644. DIB0700_NUM_FRONTENDS(1),
  3645. .fe = {{
  3646. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3647. .pid_filter_count = 32,
  3648. .pid_filter = stk70x0p_pid_filter,
  3649. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3650. .frontend_attach = stk7070pd_frontend_attach0,
  3651. .tuner_attach = dib7070p_tuner_attach,
  3652. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3653. }},
  3654. }, {
  3655. DIB0700_NUM_FRONTENDS(1),
  3656. .fe = {{
  3657. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3658. .pid_filter_count = 32,
  3659. .pid_filter = stk70x0p_pid_filter,
  3660. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3661. .frontend_attach = stk7070pd_frontend_attach1,
  3662. .tuner_attach = dib7070p_tuner_attach,
  3663. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3664. }},
  3665. }
  3666. },
  3667. .num_device_descs = 5,
  3668. .devices = {
  3669. { "DiBcom STK7070PD reference design",
  3670. { &dib0700_usb_id_table[17], NULL },
  3671. { NULL },
  3672. },
  3673. { "Pinnacle PCTV Dual DVB-T Diversity Stick",
  3674. { &dib0700_usb_id_table[18], NULL },
  3675. { NULL },
  3676. },
  3677. { "Hauppauge Nova-TD-500 (84xxx)",
  3678. { &dib0700_usb_id_table[36], NULL },
  3679. { NULL },
  3680. },
  3681. { "Terratec Cinergy DT USB XS Diversity/ T5",
  3682. { &dib0700_usb_id_table[43],
  3683. &dib0700_usb_id_table[53], NULL},
  3684. { NULL },
  3685. },
  3686. { "Sony PlayTV",
  3687. { &dib0700_usb_id_table[44], NULL },
  3688. { NULL },
  3689. },
  3690. },
  3691. .rc.core = {
  3692. .rc_interval = DEFAULT_RC_INTERVAL,
  3693. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3694. .module_name = "dib0700",
  3695. .rc_query = dib0700_rc_query_old_firmware,
  3696. .allowed_protos = RC_PROTO_BIT_RC5 |
  3697. RC_PROTO_BIT_RC6_MCE |
  3698. RC_PROTO_BIT_NEC,
  3699. .change_protocol = dib0700_change_protocol,
  3700. },
  3701. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3702. .num_adapters = 2,
  3703. .adapter = {
  3704. {
  3705. DIB0700_NUM_FRONTENDS(1),
  3706. .fe = {{
  3707. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3708. .pid_filter_count = 32,
  3709. .pid_filter = stk70x0p_pid_filter,
  3710. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3711. .frontend_attach = stk7070pd_frontend_attach0,
  3712. .tuner_attach = dib7070p_tuner_attach,
  3713. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3714. }},
  3715. }, {
  3716. DIB0700_NUM_FRONTENDS(1),
  3717. .fe = {{
  3718. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3719. .pid_filter_count = 32,
  3720. .pid_filter = stk70x0p_pid_filter,
  3721. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3722. .frontend_attach = stk7070pd_frontend_attach1,
  3723. .tuner_attach = dib7070p_tuner_attach,
  3724. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3725. }},
  3726. }
  3727. },
  3728. .num_device_descs = 1,
  3729. .devices = {
  3730. { "Elgato EyeTV Diversity",
  3731. { &dib0700_usb_id_table[68], NULL },
  3732. { NULL },
  3733. },
  3734. },
  3735. .rc.core = {
  3736. .rc_interval = DEFAULT_RC_INTERVAL,
  3737. .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
  3738. .module_name = "dib0700",
  3739. .rc_query = dib0700_rc_query_old_firmware,
  3740. .allowed_protos = RC_PROTO_BIT_RC5 |
  3741. RC_PROTO_BIT_RC6_MCE |
  3742. RC_PROTO_BIT_NEC,
  3743. .change_protocol = dib0700_change_protocol,
  3744. },
  3745. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3746. .num_adapters = 1,
  3747. .adapter = {
  3748. {
  3749. DIB0700_NUM_FRONTENDS(1),
  3750. .fe = {{
  3751. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3752. .pid_filter_count = 32,
  3753. .pid_filter = stk70x0p_pid_filter,
  3754. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3755. .frontend_attach = stk7700ph_frontend_attach,
  3756. .tuner_attach = stk7700ph_tuner_attach,
  3757. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3758. }},
  3759. },
  3760. },
  3761. .num_device_descs = 10,
  3762. .devices = {
  3763. { "Terratec Cinergy HT USB XE",
  3764. { &dib0700_usb_id_table[27], NULL },
  3765. { NULL },
  3766. },
  3767. { "Pinnacle Expresscard 320cx",
  3768. { &dib0700_usb_id_table[28], NULL },
  3769. { NULL },
  3770. },
  3771. { "Terratec Cinergy HT Express",
  3772. { &dib0700_usb_id_table[32], NULL },
  3773. { NULL },
  3774. },
  3775. { "Gigabyte U8000-RH",
  3776. { &dib0700_usb_id_table[37], NULL },
  3777. { NULL },
  3778. },
  3779. { "YUAN High-Tech STK7700PH",
  3780. { &dib0700_usb_id_table[38], NULL },
  3781. { NULL },
  3782. },
  3783. { "Asus My Cinema-U3000Hybrid",
  3784. { &dib0700_usb_id_table[39], NULL },
  3785. { NULL },
  3786. },
  3787. { "YUAN High-Tech MC770",
  3788. { &dib0700_usb_id_table[48], NULL },
  3789. { NULL },
  3790. },
  3791. { "Leadtek WinFast DTV Dongle H",
  3792. { &dib0700_usb_id_table[51], NULL },
  3793. { NULL },
  3794. },
  3795. { "YUAN High-Tech STK7700D",
  3796. { &dib0700_usb_id_table[54], NULL },
  3797. { NULL },
  3798. },
  3799. { "Hama DVB=T Hybrid USB Stick",
  3800. { &dib0700_usb_id_table[85], NULL },
  3801. { NULL },
  3802. },
  3803. },
  3804. .rc.core = {
  3805. .rc_interval = DEFAULT_RC_INTERVAL,
  3806. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3807. .module_name = "dib0700",
  3808. .rc_query = dib0700_rc_query_old_firmware,
  3809. .allowed_protos = RC_PROTO_BIT_RC5 |
  3810. RC_PROTO_BIT_RC6_MCE |
  3811. RC_PROTO_BIT_NEC,
  3812. .change_protocol = dib0700_change_protocol,
  3813. },
  3814. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3815. .num_adapters = 1,
  3816. .adapter = {
  3817. {
  3818. DIB0700_NUM_FRONTENDS(1),
  3819. .fe = {{
  3820. .frontend_attach = s5h1411_frontend_attach,
  3821. .tuner_attach = xc5000_tuner_attach,
  3822. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3823. }},
  3824. },
  3825. },
  3826. .num_device_descs = 2,
  3827. .devices = {
  3828. { "Pinnacle PCTV HD Pro USB Stick",
  3829. { &dib0700_usb_id_table[40], NULL },
  3830. { NULL },
  3831. },
  3832. { "Pinnacle PCTV HD USB Stick",
  3833. { &dib0700_usb_id_table[41], NULL },
  3834. { NULL },
  3835. },
  3836. },
  3837. .rc.core = {
  3838. .rc_interval = DEFAULT_RC_INTERVAL,
  3839. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3840. .module_name = "dib0700",
  3841. .rc_query = dib0700_rc_query_old_firmware,
  3842. .allowed_protos = RC_PROTO_BIT_RC5 |
  3843. RC_PROTO_BIT_RC6_MCE |
  3844. RC_PROTO_BIT_NEC,
  3845. .change_protocol = dib0700_change_protocol,
  3846. },
  3847. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3848. .num_adapters = 1,
  3849. .adapter = {
  3850. {
  3851. DIB0700_NUM_FRONTENDS(1),
  3852. .fe = {{
  3853. .frontend_attach = lgdt3305_frontend_attach,
  3854. .tuner_attach = mxl5007t_tuner_attach,
  3855. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3856. }},
  3857. },
  3858. },
  3859. .num_device_descs = 2,
  3860. .devices = {
  3861. { "Hauppauge ATSC MiniCard (B200)",
  3862. { &dib0700_usb_id_table[46], NULL },
  3863. { NULL },
  3864. },
  3865. { "Hauppauge ATSC MiniCard (B210)",
  3866. { &dib0700_usb_id_table[47], NULL },
  3867. { NULL },
  3868. },
  3869. },
  3870. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3871. .num_adapters = 1,
  3872. .adapter = {
  3873. {
  3874. DIB0700_NUM_FRONTENDS(1),
  3875. .fe = {{
  3876. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3877. .pid_filter_count = 32,
  3878. .pid_filter = stk70x0p_pid_filter,
  3879. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  3880. .frontend_attach = stk7770p_frontend_attach,
  3881. .tuner_attach = dib7770p_tuner_attach,
  3882. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3883. }},
  3884. },
  3885. },
  3886. .num_device_descs = 4,
  3887. .devices = {
  3888. { "DiBcom STK7770P reference design",
  3889. { &dib0700_usb_id_table[59], NULL },
  3890. { NULL },
  3891. },
  3892. { "Terratec Cinergy T USB XXS (HD)/ T3",
  3893. { &dib0700_usb_id_table[33],
  3894. &dib0700_usb_id_table[52],
  3895. &dib0700_usb_id_table[60], NULL},
  3896. { NULL },
  3897. },
  3898. { "TechniSat AirStar TeleStick 2",
  3899. { &dib0700_usb_id_table[74], NULL },
  3900. { NULL },
  3901. },
  3902. { "Medion CTX1921 DVB-T USB",
  3903. { &dib0700_usb_id_table[75], NULL },
  3904. { NULL },
  3905. },
  3906. },
  3907. .rc.core = {
  3908. .rc_interval = DEFAULT_RC_INTERVAL,
  3909. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3910. .module_name = "dib0700",
  3911. .rc_query = dib0700_rc_query_old_firmware,
  3912. .allowed_protos = RC_PROTO_BIT_RC5 |
  3913. RC_PROTO_BIT_RC6_MCE |
  3914. RC_PROTO_BIT_NEC,
  3915. .change_protocol = dib0700_change_protocol,
  3916. },
  3917. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3918. .num_adapters = 1,
  3919. .adapter = {
  3920. {
  3921. DIB0700_NUM_FRONTENDS(1),
  3922. .fe = {{
  3923. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3924. .pid_filter_count = 32,
  3925. .pid_filter = stk80xx_pid_filter,
  3926. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  3927. .frontend_attach = stk807x_frontend_attach,
  3928. .tuner_attach = dib807x_tuner_attach,
  3929. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3930. }},
  3931. },
  3932. },
  3933. .num_device_descs = 3,
  3934. .devices = {
  3935. { "DiBcom STK807xP reference design",
  3936. { &dib0700_usb_id_table[62], NULL },
  3937. { NULL },
  3938. },
  3939. { "Prolink Pixelview SBTVD",
  3940. { &dib0700_usb_id_table[63], NULL },
  3941. { NULL },
  3942. },
  3943. { "EvolutePC TVWay+",
  3944. { &dib0700_usb_id_table[64], NULL },
  3945. { NULL },
  3946. },
  3947. },
  3948. .rc.core = {
  3949. .rc_interval = DEFAULT_RC_INTERVAL,
  3950. .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
  3951. .module_name = "dib0700",
  3952. .rc_query = dib0700_rc_query_old_firmware,
  3953. .allowed_protos = RC_PROTO_BIT_RC5 |
  3954. RC_PROTO_BIT_RC6_MCE |
  3955. RC_PROTO_BIT_NEC,
  3956. .change_protocol = dib0700_change_protocol,
  3957. },
  3958. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  3959. .num_adapters = 2,
  3960. .adapter = {
  3961. {
  3962. DIB0700_NUM_FRONTENDS(1),
  3963. .fe = {{
  3964. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3965. .pid_filter_count = 32,
  3966. .pid_filter = stk80xx_pid_filter,
  3967. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  3968. .frontend_attach = stk807xpvr_frontend_attach0,
  3969. .tuner_attach = dib807x_tuner_attach,
  3970. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  3971. }},
  3972. },
  3973. {
  3974. DIB0700_NUM_FRONTENDS(1),
  3975. .fe = {{
  3976. .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  3977. .pid_filter_count = 32,
  3978. .pid_filter = stk80xx_pid_filter,
  3979. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  3980. .frontend_attach = stk807xpvr_frontend_attach1,
  3981. .tuner_attach = dib807x_tuner_attach,
  3982. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  3983. }},
  3984. },
  3985. },
  3986. .num_device_descs = 1,
  3987. .devices = {
  3988. { "DiBcom STK807xPVR reference design",
  3989. { &dib0700_usb_id_table[61], NULL },
  3990. { NULL },
  3991. },
  3992. },
  3993. .rc.core = {
  3994. .rc_interval = DEFAULT_RC_INTERVAL,
  3995. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  3996. .module_name = "dib0700",
  3997. .rc_query = dib0700_rc_query_old_firmware,
  3998. .allowed_protos = RC_PROTO_BIT_RC5 |
  3999. RC_PROTO_BIT_RC6_MCE |
  4000. RC_PROTO_BIT_NEC,
  4001. .change_protocol = dib0700_change_protocol,
  4002. },
  4003. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4004. .num_adapters = 1,
  4005. .adapter = {
  4006. {
  4007. DIB0700_NUM_FRONTENDS(1),
  4008. .fe = {{
  4009. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4010. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4011. .pid_filter_count = 32,
  4012. .pid_filter = stk80xx_pid_filter,
  4013. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  4014. .frontend_attach = stk809x_frontend_attach,
  4015. .tuner_attach = dib809x_tuner_attach,
  4016. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4017. }},
  4018. },
  4019. },
  4020. .num_device_descs = 1,
  4021. .devices = {
  4022. { "DiBcom STK8096GP reference design",
  4023. { &dib0700_usb_id_table[67], NULL },
  4024. { NULL },
  4025. },
  4026. },
  4027. .rc.core = {
  4028. .rc_interval = DEFAULT_RC_INTERVAL,
  4029. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4030. .module_name = "dib0700",
  4031. .rc_query = dib0700_rc_query_old_firmware,
  4032. .allowed_protos = RC_PROTO_BIT_RC5 |
  4033. RC_PROTO_BIT_RC6_MCE |
  4034. RC_PROTO_BIT_NEC,
  4035. .change_protocol = dib0700_change_protocol,
  4036. },
  4037. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4038. .num_adapters = 1,
  4039. .adapter = {
  4040. {
  4041. DIB0700_NUM_FRONTENDS(1),
  4042. .fe = {{
  4043. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4044. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4045. .pid_filter_count = 32,
  4046. .pid_filter = dib90x0_pid_filter,
  4047. .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
  4048. .frontend_attach = stk9090m_frontend_attach,
  4049. .tuner_attach = dib9090_tuner_attach,
  4050. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4051. }},
  4052. },
  4053. },
  4054. .num_device_descs = 1,
  4055. .devices = {
  4056. { "DiBcom STK9090M reference design",
  4057. { &dib0700_usb_id_table[69], NULL },
  4058. { NULL },
  4059. },
  4060. },
  4061. .rc.core = {
  4062. .rc_interval = DEFAULT_RC_INTERVAL,
  4063. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4064. .module_name = "dib0700",
  4065. .rc_query = dib0700_rc_query_old_firmware,
  4066. .allowed_protos = RC_PROTO_BIT_RC5 |
  4067. RC_PROTO_BIT_RC6_MCE |
  4068. RC_PROTO_BIT_NEC,
  4069. .change_protocol = dib0700_change_protocol,
  4070. },
  4071. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4072. .num_adapters = 1,
  4073. .adapter = {
  4074. {
  4075. DIB0700_NUM_FRONTENDS(1),
  4076. .fe = {{
  4077. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4078. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4079. .pid_filter_count = 32,
  4080. .pid_filter = stk80xx_pid_filter,
  4081. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  4082. .frontend_attach = nim8096md_frontend_attach,
  4083. .tuner_attach = nim8096md_tuner_attach,
  4084. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4085. }},
  4086. },
  4087. },
  4088. .num_device_descs = 1,
  4089. .devices = {
  4090. { "DiBcom NIM8096MD reference design",
  4091. { &dib0700_usb_id_table[70], NULL },
  4092. { NULL },
  4093. },
  4094. },
  4095. .rc.core = {
  4096. .rc_interval = DEFAULT_RC_INTERVAL,
  4097. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4098. .module_name = "dib0700",
  4099. .rc_query = dib0700_rc_query_old_firmware,
  4100. .allowed_protos = RC_PROTO_BIT_RC5 |
  4101. RC_PROTO_BIT_RC6_MCE |
  4102. RC_PROTO_BIT_NEC,
  4103. .change_protocol = dib0700_change_protocol,
  4104. },
  4105. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4106. .num_adapters = 1,
  4107. .adapter = {
  4108. {
  4109. DIB0700_NUM_FRONTENDS(1),
  4110. .fe = {{
  4111. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4112. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4113. .pid_filter_count = 32,
  4114. .pid_filter = dib90x0_pid_filter,
  4115. .pid_filter_ctrl = dib90x0_pid_filter_ctrl,
  4116. .frontend_attach = nim9090md_frontend_attach,
  4117. .tuner_attach = nim9090md_tuner_attach,
  4118. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4119. }},
  4120. },
  4121. },
  4122. .num_device_descs = 1,
  4123. .devices = {
  4124. { "DiBcom NIM9090MD reference design",
  4125. { &dib0700_usb_id_table[71], NULL },
  4126. { NULL },
  4127. },
  4128. },
  4129. .rc.core = {
  4130. .rc_interval = DEFAULT_RC_INTERVAL,
  4131. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4132. .module_name = "dib0700",
  4133. .rc_query = dib0700_rc_query_old_firmware,
  4134. .allowed_protos = RC_PROTO_BIT_RC5 |
  4135. RC_PROTO_BIT_RC6_MCE |
  4136. RC_PROTO_BIT_NEC,
  4137. .change_protocol = dib0700_change_protocol,
  4138. },
  4139. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4140. .num_adapters = 1,
  4141. .adapter = {
  4142. {
  4143. DIB0700_NUM_FRONTENDS(1),
  4144. .fe = {{
  4145. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4146. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4147. .pid_filter_count = 32,
  4148. .pid_filter = stk70x0p_pid_filter,
  4149. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  4150. .frontend_attach = nim7090_frontend_attach,
  4151. .tuner_attach = nim7090_tuner_attach,
  4152. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4153. }},
  4154. },
  4155. },
  4156. .num_device_descs = 1,
  4157. .devices = {
  4158. { "DiBcom NIM7090 reference design",
  4159. { &dib0700_usb_id_table[72], NULL },
  4160. { NULL },
  4161. },
  4162. },
  4163. .rc.core = {
  4164. .rc_interval = DEFAULT_RC_INTERVAL,
  4165. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4166. .module_name = "dib0700",
  4167. .rc_query = dib0700_rc_query_old_firmware,
  4168. .allowed_protos = RC_PROTO_BIT_RC5 |
  4169. RC_PROTO_BIT_RC6_MCE |
  4170. RC_PROTO_BIT_NEC,
  4171. .change_protocol = dib0700_change_protocol,
  4172. },
  4173. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4174. .num_adapters = 2,
  4175. .adapter = {
  4176. {
  4177. DIB0700_NUM_FRONTENDS(1),
  4178. .fe = {{
  4179. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4180. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4181. .pid_filter_count = 32,
  4182. .pid_filter = stk70x0p_pid_filter,
  4183. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  4184. .frontend_attach = tfe7090pvr_frontend0_attach,
  4185. .tuner_attach = tfe7090pvr_tuner0_attach,
  4186. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  4187. }},
  4188. },
  4189. {
  4190. DIB0700_NUM_FRONTENDS(1),
  4191. .fe = {{
  4192. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4193. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4194. .pid_filter_count = 32,
  4195. .pid_filter = stk70x0p_pid_filter,
  4196. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  4197. .frontend_attach = tfe7090pvr_frontend1_attach,
  4198. .tuner_attach = tfe7090pvr_tuner1_attach,
  4199. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4200. }},
  4201. },
  4202. },
  4203. .num_device_descs = 1,
  4204. .devices = {
  4205. { "DiBcom TFE7090PVR reference design",
  4206. { &dib0700_usb_id_table[73], NULL },
  4207. { NULL },
  4208. },
  4209. },
  4210. .rc.core = {
  4211. .rc_interval = DEFAULT_RC_INTERVAL,
  4212. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4213. .module_name = "dib0700",
  4214. .rc_query = dib0700_rc_query_old_firmware,
  4215. .allowed_protos = RC_PROTO_BIT_RC5 |
  4216. RC_PROTO_BIT_RC6_MCE |
  4217. RC_PROTO_BIT_NEC,
  4218. .change_protocol = dib0700_change_protocol,
  4219. },
  4220. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4221. .num_adapters = 1,
  4222. .adapter = {
  4223. {
  4224. DIB0700_NUM_FRONTENDS(1),
  4225. .fe = {{
  4226. .frontend_attach = pctv340e_frontend_attach,
  4227. .tuner_attach = xc4000_tuner_attach,
  4228. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4229. }},
  4230. },
  4231. },
  4232. .num_device_descs = 2,
  4233. .devices = {
  4234. { "Pinnacle PCTV 340e HD Pro USB Stick",
  4235. { &dib0700_usb_id_table[76], NULL },
  4236. { NULL },
  4237. },
  4238. { "Pinnacle PCTV Hybrid Stick Solo",
  4239. { &dib0700_usb_id_table[77], NULL },
  4240. { NULL },
  4241. },
  4242. },
  4243. .rc.core = {
  4244. .rc_interval = DEFAULT_RC_INTERVAL,
  4245. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4246. .module_name = "dib0700",
  4247. .rc_query = dib0700_rc_query_old_firmware,
  4248. .allowed_protos = RC_PROTO_BIT_RC5 |
  4249. RC_PROTO_BIT_RC6_MCE |
  4250. RC_PROTO_BIT_NEC,
  4251. .change_protocol = dib0700_change_protocol,
  4252. },
  4253. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4254. .num_adapters = 1,
  4255. .adapter = {
  4256. {
  4257. DIB0700_NUM_FRONTENDS(1),
  4258. .fe = {{
  4259. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4260. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4261. .pid_filter_count = 32,
  4262. .pid_filter = stk70x0p_pid_filter,
  4263. .pid_filter_ctrl = stk70x0p_pid_filter_ctrl,
  4264. .frontend_attach = tfe7790p_frontend_attach,
  4265. .tuner_attach = tfe7790p_tuner_attach,
  4266. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  4267. } },
  4268. },
  4269. },
  4270. .num_device_descs = 1,
  4271. .devices = {
  4272. { "DiBcom TFE7790P reference design",
  4273. { &dib0700_usb_id_table[78], NULL },
  4274. { NULL },
  4275. },
  4276. },
  4277. .rc.core = {
  4278. .rc_interval = DEFAULT_RC_INTERVAL,
  4279. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4280. .module_name = "dib0700",
  4281. .rc_query = dib0700_rc_query_old_firmware,
  4282. .allowed_protos = RC_PROTO_BIT_RC5 |
  4283. RC_PROTO_BIT_RC6_MCE |
  4284. RC_PROTO_BIT_NEC,
  4285. .change_protocol = dib0700_change_protocol,
  4286. },
  4287. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4288. .num_adapters = 1,
  4289. .adapter = {
  4290. {
  4291. DIB0700_NUM_FRONTENDS(1),
  4292. .fe = {{
  4293. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4294. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4295. .pid_filter_count = 32,
  4296. .pid_filter = stk80xx_pid_filter,
  4297. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  4298. .frontend_attach = tfe8096p_frontend_attach,
  4299. .tuner_attach = tfe8096p_tuner_attach,
  4300. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4301. } },
  4302. },
  4303. },
  4304. .num_device_descs = 1,
  4305. .devices = {
  4306. { "DiBcom TFE8096P reference design",
  4307. { &dib0700_usb_id_table[79], NULL },
  4308. { NULL },
  4309. },
  4310. },
  4311. .rc.core = {
  4312. .rc_interval = DEFAULT_RC_INTERVAL,
  4313. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4314. .module_name = "dib0700",
  4315. .rc_query = dib0700_rc_query_old_firmware,
  4316. .allowed_protos = RC_PROTO_BIT_RC5 |
  4317. RC_PROTO_BIT_RC6_MCE |
  4318. RC_PROTO_BIT_NEC,
  4319. .change_protocol = dib0700_change_protocol,
  4320. },
  4321. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4322. .num_adapters = 2,
  4323. .adapter = {
  4324. {
  4325. .num_frontends = 1,
  4326. .fe = {{
  4327. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4328. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4329. .pid_filter_count = 32,
  4330. .pid_filter = stk80xx_pid_filter,
  4331. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  4332. .frontend_attach = stk809x_frontend_attach,
  4333. .tuner_attach = dib809x_tuner_attach,
  4334. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  4335. } },
  4336. .size_of_priv =
  4337. sizeof(struct dib0700_adapter_state),
  4338. }, {
  4339. .num_frontends = 1,
  4340. .fe = { {
  4341. .caps = DVB_USB_ADAP_HAS_PID_FILTER |
  4342. DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  4343. .pid_filter_count = 32,
  4344. .pid_filter = stk80xx_pid_filter,
  4345. .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
  4346. .frontend_attach = stk809x_frontend1_attach,
  4347. .tuner_attach = dib809x_tuner_attach,
  4348. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  4349. } },
  4350. .size_of_priv =
  4351. sizeof(struct dib0700_adapter_state),
  4352. },
  4353. },
  4354. .num_device_descs = 1,
  4355. .devices = {
  4356. { "DiBcom STK8096-PVR reference design",
  4357. { &dib0700_usb_id_table[83],
  4358. &dib0700_usb_id_table[84], NULL},
  4359. { NULL },
  4360. },
  4361. },
  4362. .rc.core = {
  4363. .rc_interval = DEFAULT_RC_INTERVAL,
  4364. .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
  4365. .module_name = "dib0700",
  4366. .rc_query = dib0700_rc_query_old_firmware,
  4367. .allowed_protos = RC_PROTO_BIT_RC5 |
  4368. RC_PROTO_BIT_RC6_MCE |
  4369. RC_PROTO_BIT_NEC,
  4370. .change_protocol = dib0700_change_protocol,
  4371. },
  4372. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  4373. .num_adapters = 1,
  4374. .adapter = {
  4375. {
  4376. DIB0700_NUM_FRONTENDS(1),
  4377. .fe = {{
  4378. .frontend_attach = xbox_one_attach,
  4379. DIB0700_DEFAULT_STREAMING_CONFIG(0x82),
  4380. } },
  4381. },
  4382. },
  4383. .num_device_descs = 1,
  4384. .devices = {
  4385. { "Microsoft Xbox One Digital TV Tuner",
  4386. { &dib0700_usb_id_table[86], NULL },
  4387. { NULL },
  4388. },
  4389. },
  4390. },
  4391. };
  4392. int dib0700_device_count = ARRAY_SIZE(dib0700_devices);