dib0700_devices.c 138 KB

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