12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741 |
- /*
- * Driver for the Conexant CX23885 PCIe bridge
- *
- * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *
- * GNU General Public License for more details.
- */
- #include "cx23885.h"
- #include <linux/module.h>
- #include <linux/init.h>
- #include <linux/device.h>
- #include <linux/fs.h>
- #include <linux/kthread.h>
- #include <linux/file.h>
- #include <linux/suspend.h>
- #include <media/v4l2-common.h>
- #include <media/dvb_ca_en50221.h>
- #include "s5h1409.h"
- #include "s5h1411.h"
- #include "mt2131.h"
- #include "tda8290.h"
- #include "tda18271.h"
- #include "lgdt330x.h"
- #include "xc4000.h"
- #include "xc5000.h"
- #include "max2165.h"
- #include "tda10048.h"
- #include "tuner-xc2028.h"
- #include "tuner-simple.h"
- #include "dib7000p.h"
- #include "dib0070.h"
- #include "dibx000_common.h"
- #include "zl10353.h"
- #include "stv0900.h"
- #include "stv0900_reg.h"
- #include "stv6110.h"
- #include "lnbh24.h"
- #include "cx24116.h"
- #include "cx24117.h"
- #include "cimax2.h"
- #include "lgs8gxx.h"
- #include "netup-eeprom.h"
- #include "netup-init.h"
- #include "lgdt3305.h"
- #include "atbm8830.h"
- #include "ts2020.h"
- #include "ds3000.h"
- #include "cx23885-f300.h"
- #include "altera-ci.h"
- #include "stv0367.h"
- #include "drxk.h"
- #include "mt2063.h"
- #include "stv090x.h"
- #include "stb6100.h"
- #include "stb6100_cfg.h"
- #include "tda10071.h"
- #include "a8293.h"
- #include "mb86a20s.h"
- #include "si2165.h"
- #include "si2168.h"
- #include "si2157.h"
- #include "sp2.h"
- #include "m88ds3103.h"
- #include "m88rs6000t.h"
- #include "lgdt3306a.h"
- static unsigned int debug;
- #define dprintk(level, fmt, arg...)\
- do { if (debug >= level)\
- printk(KERN_DEBUG pr_fmt("%s dvb: " fmt), \
- __func__, ##arg); \
- } while (0)
- /* ------------------------------------------------------------------ */
- static unsigned int alt_tuner;
- module_param(alt_tuner, int, 0644);
- MODULE_PARM_DESC(alt_tuner, "Enable alternate tuner configuration");
- DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
- /* ------------------------------------------------------------------ */
- static int queue_setup(struct vb2_queue *q,
- unsigned int *num_buffers, unsigned int *num_planes,
- unsigned int sizes[], struct device *alloc_devs[])
- {
- struct cx23885_tsport *port = q->drv_priv;
- port->ts_packet_size = 188 * 4;
- port->ts_packet_count = 32;
- *num_planes = 1;
- sizes[0] = port->ts_packet_size * port->ts_packet_count;
- *num_buffers = 32;
- return 0;
- }
- static int buffer_prepare(struct vb2_buffer *vb)
- {
- struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
- struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
- struct cx23885_buffer *buf =
- container_of(vbuf, struct cx23885_buffer, vb);
- return cx23885_buf_prepare(buf, port);
- }
- static void buffer_finish(struct vb2_buffer *vb)
- {
- struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
- struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
- struct cx23885_dev *dev = port->dev;
- struct cx23885_buffer *buf = container_of(vbuf,
- struct cx23885_buffer, vb);
- cx23885_free_buffer(dev, buf);
- }
- static void buffer_queue(struct vb2_buffer *vb)
- {
- struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
- struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
- struct cx23885_buffer *buf = container_of(vbuf,
- struct cx23885_buffer, vb);
- cx23885_buf_queue(port, buf);
- }
- static void cx23885_dvb_gate_ctrl(struct cx23885_tsport *port, int open)
- {
- struct vb2_dvb_frontends *f;
- struct vb2_dvb_frontend *fe;
- f = &port->frontends;
- if (f->gate <= 1) /* undefined or fe0 */
- fe = vb2_dvb_get_frontend(f, 1);
- else
- fe = vb2_dvb_get_frontend(f, f->gate);
- if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
- fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
- }
- static int cx23885_start_streaming(struct vb2_queue *q, unsigned int count)
- {
- struct cx23885_tsport *port = q->drv_priv;
- struct cx23885_dmaqueue *dmaq = &port->mpegq;
- struct cx23885_buffer *buf = list_entry(dmaq->active.next,
- struct cx23885_buffer, queue);
- cx23885_start_dma(port, dmaq, buf);
- return 0;
- }
- static void cx23885_stop_streaming(struct vb2_queue *q)
- {
- struct cx23885_tsport *port = q->drv_priv;
- cx23885_cancel_buffers(port);
- }
- static const struct vb2_ops dvb_qops = {
- .queue_setup = queue_setup,
- .buf_prepare = buffer_prepare,
- .buf_finish = buffer_finish,
- .buf_queue = buffer_queue,
- .wait_prepare = vb2_ops_wait_prepare,
- .wait_finish = vb2_ops_wait_finish,
- .start_streaming = cx23885_start_streaming,
- .stop_streaming = cx23885_stop_streaming,
- };
- static struct s5h1409_config hauppauge_generic_config = {
- .demod_address = 0x32 >> 1,
- .output_mode = S5H1409_SERIAL_OUTPUT,
- .gpio = S5H1409_GPIO_ON,
- .qam_if = 44000,
- .inversion = S5H1409_INVERSION_OFF,
- .status_mode = S5H1409_DEMODLOCKING,
- .mpeg_timing = S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
- };
- static struct tda10048_config hauppauge_hvr1200_config = {
- .demod_address = 0x10 >> 1,
- .output_mode = TDA10048_SERIAL_OUTPUT,
- .fwbulkwritelen = TDA10048_BULKWRITE_200,
- .inversion = TDA10048_INVERSION_ON,
- .dtv6_if_freq_khz = TDA10048_IF_3300,
- .dtv7_if_freq_khz = TDA10048_IF_3800,
- .dtv8_if_freq_khz = TDA10048_IF_4300,
- .clk_freq_khz = TDA10048_CLK_16000,
- };
- static struct tda10048_config hauppauge_hvr1210_config = {
- .demod_address = 0x10 >> 1,
- .output_mode = TDA10048_SERIAL_OUTPUT,
- .fwbulkwritelen = TDA10048_BULKWRITE_200,
- .inversion = TDA10048_INVERSION_ON,
- .dtv6_if_freq_khz = TDA10048_IF_3300,
- .dtv7_if_freq_khz = TDA10048_IF_3500,
- .dtv8_if_freq_khz = TDA10048_IF_4000,
- .clk_freq_khz = TDA10048_CLK_16000,
- };
- static struct s5h1409_config hauppauge_ezqam_config = {
- .demod_address = 0x32 >> 1,
- .output_mode = S5H1409_SERIAL_OUTPUT,
- .gpio = S5H1409_GPIO_OFF,
- .qam_if = 4000,
- .inversion = S5H1409_INVERSION_ON,
- .status_mode = S5H1409_DEMODLOCKING,
- .mpeg_timing = S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
- };
- static struct s5h1409_config hauppauge_hvr1800lp_config = {
- .demod_address = 0x32 >> 1,
- .output_mode = S5H1409_SERIAL_OUTPUT,
- .gpio = S5H1409_GPIO_OFF,
- .qam_if = 44000,
- .inversion = S5H1409_INVERSION_OFF,
- .status_mode = S5H1409_DEMODLOCKING,
- .mpeg_timing = S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
- };
- static struct s5h1409_config hauppauge_hvr1500_config = {
- .demod_address = 0x32 >> 1,
- .output_mode = S5H1409_SERIAL_OUTPUT,
- .gpio = S5H1409_GPIO_OFF,
- .inversion = S5H1409_INVERSION_OFF,
- .status_mode = S5H1409_DEMODLOCKING,
- .mpeg_timing = S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
- };
- static struct mt2131_config hauppauge_generic_tunerconfig = {
- 0x61
- };
- static struct lgdt330x_config fusionhdtv_5_express = {
- .demod_chip = LGDT3303,
- .serial_mpeg = 0x40,
- };
- static struct s5h1409_config hauppauge_hvr1500q_config = {
- .demod_address = 0x32 >> 1,
- .output_mode = S5H1409_SERIAL_OUTPUT,
- .gpio = S5H1409_GPIO_ON,
- .qam_if = 44000,
- .inversion = S5H1409_INVERSION_OFF,
- .status_mode = S5H1409_DEMODLOCKING,
- .mpeg_timing = S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
- };
- static struct s5h1409_config dvico_s5h1409_config = {
- .demod_address = 0x32 >> 1,
- .output_mode = S5H1409_SERIAL_OUTPUT,
- .gpio = S5H1409_GPIO_ON,
- .qam_if = 44000,
- .inversion = S5H1409_INVERSION_OFF,
- .status_mode = S5H1409_DEMODLOCKING,
- .mpeg_timing = S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
- };
- static struct s5h1411_config dvico_s5h1411_config = {
- .output_mode = S5H1411_SERIAL_OUTPUT,
- .gpio = S5H1411_GPIO_ON,
- .qam_if = S5H1411_IF_44000,
- .vsb_if = S5H1411_IF_44000,
- .inversion = S5H1411_INVERSION_OFF,
- .status_mode = S5H1411_DEMODLOCKING,
- .mpeg_timing = S5H1411_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
- };
- static struct s5h1411_config hcw_s5h1411_config = {
- .output_mode = S5H1411_SERIAL_OUTPUT,
- .gpio = S5H1411_GPIO_OFF,
- .vsb_if = S5H1411_IF_44000,
- .qam_if = S5H1411_IF_4000,
- .inversion = S5H1411_INVERSION_ON,
- .status_mode = S5H1411_DEMODLOCKING,
- .mpeg_timing = S5H1411_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
- };
- static struct xc5000_config hauppauge_hvr1500q_tunerconfig = {
- .i2c_address = 0x61,
- .if_khz = 5380,
- };
- static struct xc5000_config dvico_xc5000_tunerconfig = {
- .i2c_address = 0x64,
- .if_khz = 5380,
- };
- static struct tda829x_config tda829x_no_probe = {
- .probe_tuner = TDA829X_DONT_PROBE,
- };
- static struct tda18271_std_map hauppauge_tda18271_std_map = {
- .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3,
- .if_lvl = 6, .rfagc_top = 0x37 },
- .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
- .if_lvl = 6, .rfagc_top = 0x37 },
- };
- static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map = {
- .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
- .if_lvl = 1, .rfagc_top = 0x37, },
- .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
- .if_lvl = 1, .rfagc_top = 0x37, },
- .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
- .if_lvl = 1, .rfagc_top = 0x37, },
- };
- static struct tda18271_config hauppauge_tda18271_config = {
- .std_map = &hauppauge_tda18271_std_map,
- .gate = TDA18271_GATE_ANALOG,
- .output_opt = TDA18271_OUTPUT_LT_OFF,
- };
- static struct tda18271_config hauppauge_hvr1200_tuner_config = {
- .std_map = &hauppauge_hvr1200_tda18271_std_map,
- .gate = TDA18271_GATE_ANALOG,
- .output_opt = TDA18271_OUTPUT_LT_OFF,
- };
- static struct tda18271_config hauppauge_hvr1210_tuner_config = {
- .gate = TDA18271_GATE_DIGITAL,
- .output_opt = TDA18271_OUTPUT_LT_OFF,
- };
- static struct tda18271_config hauppauge_hvr4400_tuner_config = {
- .gate = TDA18271_GATE_DIGITAL,
- .output_opt = TDA18271_OUTPUT_LT_OFF,
- };
- static struct tda18271_std_map hauppauge_hvr127x_std_map = {
- .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
- .if_lvl = 1, .rfagc_top = 0x58 },
- .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
- .if_lvl = 1, .rfagc_top = 0x58 },
- };
- static struct tda18271_config hauppauge_hvr127x_config = {
- .std_map = &hauppauge_hvr127x_std_map,
- .output_opt = TDA18271_OUTPUT_LT_OFF,
- };
- static struct lgdt3305_config hauppauge_lgdt3305_config = {
- .i2c_addr = 0x0e,
- .mpeg_mode = LGDT3305_MPEG_SERIAL,
- .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
- .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
- .deny_i2c_rptr = 1,
- .spectral_inversion = 1,
- .qam_if_khz = 4000,
- .vsb_if_khz = 3250,
- };
- static struct dibx000_agc_config xc3028_agc_config = {
- BAND_VHF | BAND_UHF, /* band_caps */
- /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
- * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
- * 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
- */
- (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
- (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
- 712, /* inv_gain */
- 21, /* time_stabiliz */
- 0, /* alpha_level */
- 118, /* thlock */
- 0, /* wbd_inv */
- 2867, /* wbd_ref */
- 0, /* wbd_sel */
- 2, /* wbd_alpha */
- 0, /* agc1_max */
- 0, /* agc1_min */
- 39718, /* agc2_max */
- 9930, /* agc2_min */
- 0, /* agc1_pt1 */
- 0, /* agc1_pt2 */
- 0, /* agc1_pt3 */
- 0, /* agc1_slope1 */
- 0, /* agc1_slope2 */
- 0, /* agc2_pt1 */
- 128, /* agc2_pt2 */
- 29, /* agc2_slope1 */
- 29, /* agc2_slope2 */
- 17, /* alpha_mant */
- 27, /* alpha_exp */
- 23, /* beta_mant */
- 51, /* beta_exp */
- 1, /* perform_agc_softsplit */
- };
- /* PLL Configuration for COFDM BW_MHz = 8.000000
- * With external clock = 30.000000 */
- static struct dibx000_bandwidth_config xc3028_bw_config = {
- 60000, /* internal */
- 30000, /* sampling */
- 1, /* pll_cfg: prediv */
- 8, /* pll_cfg: ratio */
- 3, /* pll_cfg: range */
- 1, /* pll_cfg: reset */
- 0, /* pll_cfg: bypass */
- 0, /* misc: refdiv */
- 0, /* misc: bypclk_div */
- 1, /* misc: IO_CLK_en_core */
- 1, /* misc: ADClkSrc */
- 0, /* misc: modulo */
- (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
- (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
- 20452225, /* timf */
- 30000000 /* xtal_hz */
- };
- static struct dib7000p_config hauppauge_hvr1400_dib7000_config = {
- .output_mpeg2_in_188_bytes = 1,
- .hostbus_diversity = 1,
- .tuner_is_baseband = 0,
- .update_lna = NULL,
- .agc_config_count = 1,
- .agc = &xc3028_agc_config,
- .bw = &xc3028_bw_config,
- .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
- .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
- .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
- .pwm_freq_div = 0,
- .agc_control = NULL,
- .spur_protect = 0,
- .output_mode = OUTMODE_MPEG2_SERIAL,
- };
- static struct zl10353_config dvico_fusionhdtv_xc3028 = {
- .demod_address = 0x0f,
- .if2 = 45600,
- .no_tuner = 1,
- .disable_i2c_gate_ctrl = 1,
- };
- static struct stv0900_reg stv0900_ts_regs[] = {
- { R0900_TSGENERAL, 0x00 },
- { R0900_P1_TSSPEED, 0x40 },
- { R0900_P2_TSSPEED, 0x40 },
- { R0900_P1_TSCFGM, 0xc0 },
- { R0900_P2_TSCFGM, 0xc0 },
- { R0900_P1_TSCFGH, 0xe0 },
- { R0900_P2_TSCFGH, 0xe0 },
- { R0900_P1_TSCFGL, 0x20 },
- { R0900_P2_TSCFGL, 0x20 },
- { 0xffff, 0xff }, /* terminate */
- };
- static struct stv0900_config netup_stv0900_config = {
- .demod_address = 0x68,
- .demod_mode = 1, /* dual */
- .xtal = 8000000,
- .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
- .diseqc_mode = 2,/* 2/3 PWM */
- .ts_config_regs = stv0900_ts_regs,
- .tun1_maddress = 0,/* 0x60 */
- .tun2_maddress = 3,/* 0x63 */
- .tun1_adc = 1,/* 1 Vpp */
- .tun2_adc = 1,/* 1 Vpp */
- };
- static struct stv6110_config netup_stv6110_tunerconfig_a = {
- .i2c_address = 0x60,
- .mclk = 16000000,
- .clk_div = 1,
- .gain = 8, /* +16 dB - maximum gain */
- };
- static struct stv6110_config netup_stv6110_tunerconfig_b = {
- .i2c_address = 0x63,
- .mclk = 16000000,
- .clk_div = 1,
- .gain = 8, /* +16 dB - maximum gain */
- };
- static struct cx24116_config tbs_cx24116_config = {
- .demod_address = 0x55,
- };
- static struct cx24117_config tbs_cx24117_config = {
- .demod_address = 0x55,
- };
- static struct ds3000_config tevii_ds3000_config = {
- .demod_address = 0x68,
- };
- static struct ts2020_config tevii_ts2020_config = {
- .tuner_address = 0x60,
- .clk_out_div = 1,
- .frequency_div = 1146000,
- };
- static struct cx24116_config dvbworld_cx24116_config = {
- .demod_address = 0x05,
- };
- static struct lgs8gxx_config mygica_x8506_lgs8gl5_config = {
- .prod = LGS8GXX_PROD_LGS8GL5,
- .demod_address = 0x19,
- .serial_ts = 0,
- .ts_clk_pol = 1,
- .ts_clk_gated = 1,
- .if_clk_freq = 30400, /* 30.4 MHz */
- .if_freq = 5380, /* 5.38 MHz */
- .if_neg_center = 1,
- .ext_adc = 0,
- .adc_signed = 0,
- .if_neg_edge = 0,
- };
- static struct xc5000_config mygica_x8506_xc5000_config = {
- .i2c_address = 0x61,
- .if_khz = 5380,
- };
- static struct mb86a20s_config mygica_x8507_mb86a20s_config = {
- .demod_address = 0x10,
- };
- static struct xc5000_config mygica_x8507_xc5000_config = {
- .i2c_address = 0x61,
- .if_khz = 4000,
- };
- static struct stv090x_config prof_8000_stv090x_config = {
- .device = STV0903,
- .demod_mode = STV090x_SINGLE,
- .clk_mode = STV090x_CLK_EXT,
- .xtal = 27000000,
- .address = 0x6A,
- .ts1_mode = STV090x_TSMODE_PARALLEL_PUNCTURED,
- .repeater_level = STV090x_RPTLEVEL_64,
- .adc1_range = STV090x_ADC_2Vpp,
- .diseqc_envelope_mode = false,
- .tuner_get_frequency = stb6100_get_frequency,
- .tuner_set_frequency = stb6100_set_frequency,
- .tuner_set_bandwidth = stb6100_set_bandwidth,
- .tuner_get_bandwidth = stb6100_get_bandwidth,
- };
- static struct stb6100_config prof_8000_stb6100_config = {
- .tuner_address = 0x60,
- .refclock = 27000000,
- };
- static struct lgdt3306a_config hauppauge_quadHD_ATSC_a_config = {
- .i2c_addr = 0x59,
- .qam_if_khz = 4000,
- .vsb_if_khz = 3250,
- .deny_i2c_rptr = 1, /* Disabled */
- .spectral_inversion = 0, /* Disabled */
- .mpeg_mode = LGDT3306A_MPEG_SERIAL,
- .tpclk_edge = LGDT3306A_TPCLK_RISING_EDGE,
- .tpvalid_polarity = LGDT3306A_TP_VALID_HIGH,
- .xtalMHz = 25, /* 24 or 25 */
- };
- static struct lgdt3306a_config hauppauge_quadHD_ATSC_b_config = {
- .i2c_addr = 0x0e,
- .qam_if_khz = 4000,
- .vsb_if_khz = 3250,
- .deny_i2c_rptr = 1, /* Disabled */
- .spectral_inversion = 0, /* Disabled */
- .mpeg_mode = LGDT3306A_MPEG_SERIAL,
- .tpclk_edge = LGDT3306A_TPCLK_RISING_EDGE,
- .tpvalid_polarity = LGDT3306A_TP_VALID_HIGH,
- .xtalMHz = 25, /* 24 or 25 */
- };
- static int p8000_set_voltage(struct dvb_frontend *fe,
- enum fe_sec_voltage voltage)
- {
- struct cx23885_tsport *port = fe->dvb->priv;
- struct cx23885_dev *dev = port->dev;
- if (voltage == SEC_VOLTAGE_18)
- cx_write(MC417_RWD, 0x00001e00);
- else if (voltage == SEC_VOLTAGE_13)
- cx_write(MC417_RWD, 0x00001a00);
- else
- cx_write(MC417_RWD, 0x00001800);
- return 0;
- }
- static int dvbsky_t9580_set_voltage(struct dvb_frontend *fe,
- enum fe_sec_voltage voltage)
- {
- struct cx23885_tsport *port = fe->dvb->priv;
- struct cx23885_dev *dev = port->dev;
- cx23885_gpio_enable(dev, GPIO_0 | GPIO_1, 1);
- switch (voltage) {
- case SEC_VOLTAGE_13:
- cx23885_gpio_set(dev, GPIO_1);
- cx23885_gpio_clear(dev, GPIO_0);
- break;
- case SEC_VOLTAGE_18:
- cx23885_gpio_set(dev, GPIO_1);
- cx23885_gpio_set(dev, GPIO_0);
- break;
- case SEC_VOLTAGE_OFF:
- cx23885_gpio_clear(dev, GPIO_1);
- cx23885_gpio_clear(dev, GPIO_0);
- break;
- }
- /* call the frontend set_voltage function */
- port->fe_set_voltage(fe, voltage);
- return 0;
- }
- static int dvbsky_s952_portc_set_voltage(struct dvb_frontend *fe,
- enum fe_sec_voltage voltage)
- {
- struct cx23885_tsport *port = fe->dvb->priv;
- struct cx23885_dev *dev = port->dev;
- cx23885_gpio_enable(dev, GPIO_12 | GPIO_13, 1);
- switch (voltage) {
- case SEC_VOLTAGE_13:
- cx23885_gpio_set(dev, GPIO_13);
- cx23885_gpio_clear(dev, GPIO_12);
- break;
- case SEC_VOLTAGE_18:
- cx23885_gpio_set(dev, GPIO_13);
- cx23885_gpio_set(dev, GPIO_12);
- break;
- case SEC_VOLTAGE_OFF:
- cx23885_gpio_clear(dev, GPIO_13);
- cx23885_gpio_clear(dev, GPIO_12);
- break;
- }
- /* call the frontend set_voltage function */
- return port->fe_set_voltage(fe, voltage);
- }
- static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr,
- u8 data, int *mem)
- {
- /* MC417 */
- #define SP2_DATA 0x000000ff
- #define SP2_WR 0x00008000
- #define SP2_RD 0x00004000
- #define SP2_ACK 0x00001000
- #define SP2_ADHI 0x00000800
- #define SP2_ADLO 0x00000400
- #define SP2_CS1 0x00000200
- #define SP2_CS0 0x00000100
- #define SP2_EN_ALL 0x00001000
- #define SP2_CTRL_OFF (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
- struct cx23885_tsport *port = priv;
- struct cx23885_dev *dev = port->dev;
- int ret;
- int tmp = 0;
- unsigned long timeout;
- mutex_lock(&dev->gpio_lock);
- /* write addr */
- cx_write(MC417_OEN, SP2_EN_ALL);
- cx_write(MC417_RWD, SP2_CTRL_OFF |
- SP2_ADLO | (0xff & addr));
- cx_clear(MC417_RWD, SP2_ADLO);
- cx_write(MC417_RWD, SP2_CTRL_OFF |
- SP2_ADHI | (0xff & (addr >> 8)));
- cx_clear(MC417_RWD, SP2_ADHI);
- if (read)
- /* data in */
- cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA);
- else
- /* data out */
- cx_write(MC417_RWD, SP2_CTRL_OFF | data);
- /* chip select 0 */
- cx_clear(MC417_RWD, SP2_CS0);
- /* read/write */
- cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR);
- /* wait for a maximum of 1 msec */
- timeout = jiffies + msecs_to_jiffies(1);
- while (!time_after(jiffies, timeout)) {
- tmp = cx_read(MC417_RWD);
- if ((tmp & SP2_ACK) == 0)
- break;
- usleep_range(50, 100);
- }
- cx_set(MC417_RWD, SP2_CTRL_OFF);
- *mem = tmp & 0xff;
- mutex_unlock(&dev->gpio_lock);
- if (!read) {
- if (*mem < 0) {
- ret = -EREMOTEIO;
- goto err;
- }
- }
- return 0;
- err:
- return ret;
- }
- static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
- {
- struct dtv_frontend_properties *p = &fe->dtv_property_cache;
- struct cx23885_tsport *port = fe->dvb->priv;
- struct cx23885_dev *dev = port->dev;
- switch (dev->board) {
- case CX23885_BOARD_HAUPPAUGE_HVR1275:
- switch (p->modulation) {
- case VSB_8:
- cx23885_gpio_clear(dev, GPIO_5);
- break;
- case QAM_64:
- case QAM_256:
- default:
- cx23885_gpio_set(dev, GPIO_5);
- break;
- }
- break;
- case CX23885_BOARD_MYGICA_X8506:
- case CX23885_BOARD_MYGICA_X8507:
- case CX23885_BOARD_MAGICPRO_PROHDTVE2:
- /* Select Digital TV */
- cx23885_gpio_set(dev, GPIO_0);
- break;
- }
- /* Call the real set_frontend */
- if (port->set_frontend)
- return port->set_frontend(fe);
- return 0;
- }
- static void cx23885_set_frontend_hook(struct cx23885_tsport *port,
- struct dvb_frontend *fe)
- {
- port->set_frontend = fe->ops.set_frontend;
- fe->ops.set_frontend = cx23885_dvb_set_frontend;
- }
- static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config = {
- .prod = LGS8GXX_PROD_LGS8G75,
- .demod_address = 0x19,
- .serial_ts = 0,
- .ts_clk_pol = 1,
- .ts_clk_gated = 1,
- .if_clk_freq = 30400, /* 30.4 MHz */
- .if_freq = 6500, /* 6.50 MHz */
- .if_neg_center = 1,
- .ext_adc = 0,
- .adc_signed = 1,
- .adc_vpp = 2, /* 1.6 Vpp */
- .if_neg_edge = 1,
- };
- static struct xc5000_config magicpro_prohdtve2_xc5000_config = {
- .i2c_address = 0x61,
- .if_khz = 6500,
- };
- static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1 = {
- .prod = ATBM8830_PROD_8830,
- .demod_address = 0x44,
- .serial_ts = 0,
- .ts_sampling_edge = 1,
- .ts_clk_gated = 0,
- .osc_clk_freq = 30400, /* in kHz */
- .if_freq = 0, /* zero IF */
- .zif_swap_iq = 1,
- .agc_min = 0x2E,
- .agc_max = 0xFF,
- .agc_hold_loop = 0,
- };
- static struct max2165_config mygic_x8558pro_max2165_cfg1 = {
- .i2c_address = 0x60,
- .osc_clk = 20
- };
- static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2 = {
- .prod = ATBM8830_PROD_8830,
- .demod_address = 0x44,
- .serial_ts = 1,
- .ts_sampling_edge = 1,
- .ts_clk_gated = 0,
- .osc_clk_freq = 30400, /* in kHz */
- .if_freq = 0, /* zero IF */
- .zif_swap_iq = 1,
- .agc_min = 0x2E,
- .agc_max = 0xFF,
- .agc_hold_loop = 0,
- };
- static struct max2165_config mygic_x8558pro_max2165_cfg2 = {
- .i2c_address = 0x60,
- .osc_clk = 20
- };
- static struct stv0367_config netup_stv0367_config[] = {
- {
- .demod_address = 0x1c,
- .xtal = 27000000,
- .if_khz = 4500,
- .if_iq_mode = 0,
- .ts_mode = 1,
- .clk_pol = 0,
- }, {
- .demod_address = 0x1d,
- .xtal = 27000000,
- .if_khz = 4500,
- .if_iq_mode = 0,
- .ts_mode = 1,
- .clk_pol = 0,
- },
- };
- static struct xc5000_config netup_xc5000_config[] = {
- {
- .i2c_address = 0x61,
- .if_khz = 4500,
- }, {
- .i2c_address = 0x64,
- .if_khz = 4500,
- },
- };
- static struct drxk_config terratec_drxk_config[] = {
- {
- .adr = 0x29,
- .no_i2c_bridge = 1,
- }, {
- .adr = 0x2a,
- .no_i2c_bridge = 1,
- },
- };
- static struct mt2063_config terratec_mt2063_config[] = {
- {
- .tuner_address = 0x60,
- }, {
- .tuner_address = 0x67,
- },
- };
- static const struct tda10071_platform_data hauppauge_tda10071_pdata = {
- .clk = 40444000, /* 40.444 MHz */
- .i2c_wr_max = 64,
- .ts_mode = TDA10071_TS_SERIAL,
- .pll_multiplier = 20,
- .tuner_i2c_addr = 0x54,
- };
- static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config = {
- .i2c_addr = 0x68,
- .clock = 27000000,
- .i2c_wr_max = 33,
- .clock_out = 0,
- .ts_mode = M88DS3103_TS_PARALLEL,
- .ts_clk = 16000,
- .ts_clk_pol = 1,
- .lnb_en_pol = 1,
- .lnb_hv_pol = 0,
- .agc = 0x99,
- };
- static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config = {
- .i2c_addr = 0x68,
- .clock = 27000000,
- .i2c_wr_max = 33,
- .clock_out = 0,
- .ts_mode = M88DS3103_TS_CI,
- .ts_clk = 10000,
- .ts_clk_pol = 1,
- .lnb_en_pol = 1,
- .lnb_hv_pol = 0,
- .agc = 0x99,
- };
- static const struct m88ds3103_config hauppauge_hvr5525_m88ds3103_config = {
- .i2c_addr = 0x69,
- .clock = 27000000,
- .i2c_wr_max = 33,
- .ts_mode = M88DS3103_TS_PARALLEL,
- .ts_clk = 16000,
- .ts_clk_pol = 1,
- .agc = 0x99,
- };
- static struct lgdt3306a_config hauppauge_hvr1265k4_config = {
- .i2c_addr = 0x59,
- .qam_if_khz = 4000,
- .vsb_if_khz = 3250,
- .deny_i2c_rptr = 1, /* Disabled */
- .spectral_inversion = 0, /* Disabled */
- .mpeg_mode = LGDT3306A_MPEG_SERIAL,
- .tpclk_edge = LGDT3306A_TPCLK_RISING_EDGE,
- .tpvalid_polarity = LGDT3306A_TP_VALID_HIGH,
- .xtalMHz = 25, /* 24 or 25 */
- };
- static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
- {
- struct cx23885_dev *dev = (struct cx23885_dev *)device;
- unsigned long timeout = jiffies + msecs_to_jiffies(1);
- uint32_t mem = 0;
- mem = cx_read(MC417_RWD);
- if (read)
- cx_set(MC417_OEN, ALT_DATA);
- else {
- cx_clear(MC417_OEN, ALT_DATA);/* D0-D7 out */
- mem &= ~ALT_DATA;
- mem |= (data & ALT_DATA);
- }
- if (flag)
- mem |= ALT_AD_RG;
- else
- mem &= ~ALT_AD_RG;
- mem &= ~ALT_CS;
- if (read)
- mem = (mem & ~ALT_RD) | ALT_WR;
- else
- mem = (mem & ~ALT_WR) | ALT_RD;
- cx_write(MC417_RWD, mem); /* start RW cycle */
- for (;;) {
- mem = cx_read(MC417_RWD);
- if ((mem & ALT_RDY) == 0)
- break;
- if (time_after(jiffies, timeout))
- break;
- udelay(1);
- }
- cx_set(MC417_RWD, ALT_RD | ALT_WR | ALT_CS);
- if (read)
- return mem & ALT_DATA;
- return 0;
- };
- static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
- {
- struct dib7000p_ops *dib7000p_ops = fe->sec_priv;
- return dib7000p_ops->set_gpio(fe, 8, 0, !onoff);
- }
- static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
- {
- return 0;
- }
- static struct dib0070_config dib7070p_dib0070_config = {
- .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
- .reset = dib7070_tuner_reset,
- .sleep = dib7070_tuner_sleep,
- .clock_khz = 12000,
- .freq_offset_khz_vhf = 550,
- /* .flip_chip = 1, */
- };
- /* DIB7070 generic */
- static struct dibx000_agc_config dib7070_agc_config = {
- .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
- /*
- * 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, 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
- */
- .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
- (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
- .inv_gain = 600,
- .time_stabiliz = 10,
- .alpha_level = 0,
- .thlock = 118,
- .wbd_inv = 0,
- .wbd_ref = 3530,
- .wbd_sel = 1,
- .wbd_alpha = 5,
- .agc1_max = 65535,
- .agc1_min = 0,
- .agc2_max = 65535,
- .agc2_min = 0,
- .agc1_pt1 = 0,
- .agc1_pt2 = 40,
- .agc1_pt3 = 183,
- .agc1_slope1 = 206,
- .agc1_slope2 = 255,
- .agc2_pt1 = 72,
- .agc2_pt2 = 152,
- .agc2_slope1 = 88,
- .agc2_slope2 = 90,
- .alpha_mant = 17,
- .alpha_exp = 27,
- .beta_mant = 23,
- .beta_exp = 51,
- .perform_agc_softsplit = 0,
- };
- static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
- .internal = 60000,
- .sampling = 15000,
- .pll_prediv = 1,
- .pll_ratio = 20,
- .pll_range = 3,
- .pll_reset = 1,
- .pll_bypass = 0,
- .enable_refdiv = 0,
- .bypclk_div = 0,
- .IO_CLK_en_core = 1,
- .ADClkSrc = 1,
- .modulo = 2,
- /* refsel, sel, freq_15k */
- .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
- .ifreq = (0 << 25) | 0,
- .timf = 20452225,
- .xtal_hz = 12000000,
- };
- static struct dib7000p_config dib7070p_dib7000p_config = {
- /* .output_mode = OUTMODE_MPEG2_FIFO, */
- .output_mode = OUTMODE_MPEG2_SERIAL,
- /* .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, */
- .output_mpeg2_in_188_bytes = 1,
- .agc_config_count = 1,
- .agc = &dib7070_agc_config,
- .bw = &dib7070_bw_config_12_mhz,
- .tuner_is_baseband = 1,
- .spur_protect = 1,
- .gpio_dir = 0xfcef, /* DIB7000P_GPIO_DEFAULT_DIRECTIONS, */
- .gpio_val = 0x0110, /* DIB7000P_GPIO_DEFAULT_VALUES, */
- .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
- .hostbus_diversity = 1,
- };
- static int dvb_register_ci_mac(struct cx23885_tsport *port)
- {
- struct cx23885_dev *dev = port->dev;
- struct i2c_client *client_ci = NULL;
- struct vb2_dvb_frontend *fe0;
- fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
- if (!fe0)
- return -EINVAL;
- switch (dev->board) {
- case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: {
- static struct netup_card_info cinfo;
- netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo);
- memcpy(port->frontends.adapter.proposed_mac,
- cinfo.port[port->nr - 1].mac, 6);
- pr_info("NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
- port->nr, port->frontends.adapter.proposed_mac);
- netup_ci_init(port);
- return 0;
- }
- case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: {
- struct altera_ci_config netup_ci_cfg = {
- .dev = dev,/* magic number to identify*/
- .adapter = &port->frontends.adapter,/* for CI */
- .demux = &fe0->dvb.demux,/* for hw pid filter */
- .fpga_rw = netup_altera_fpga_rw,
- };
- altera_ci_init(&netup_ci_cfg, port->nr);
- return 0;
- }
- case CX23885_BOARD_TEVII_S470: {
- u8 eeprom[256]; /* 24C02 i2c eeprom */
- if (port->nr != 1)
- return 0;
- /* Read entire EEPROM */
- dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
- tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom));
- pr_info("TeVii S470 MAC= %pM\n", eeprom + 0xa0);
- memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6);
- return 0;
- }
- case CX23885_BOARD_DVBSKY_T9580:
- case CX23885_BOARD_DVBSKY_S950:
- case CX23885_BOARD_DVBSKY_S952:
- case CX23885_BOARD_DVBSKY_T982: {
- u8 eeprom[256]; /* 24C02 i2c eeprom */
- if (port->nr > 2)
- return 0;
- /* Read entire EEPROM */
- dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
- tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
- sizeof(eeprom));
- pr_info("%s port %d MAC address: %pM\n",
- cx23885_boards[dev->board].name, port->nr,
- eeprom + 0xc0 + (port->nr-1) * 8);
- memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 +
- (port->nr-1) * 8, 6);
- return 0;
- }
- case CX23885_BOARD_DVBSKY_S950C:
- case CX23885_BOARD_DVBSKY_T980C:
- case CX23885_BOARD_TT_CT2_4500_CI: {
- u8 eeprom[256]; /* 24C02 i2c eeprom */
- struct sp2_config sp2_config;
- struct i2c_board_info info;
- struct cx23885_i2c *i2c_bus = &dev->i2c_bus[0];
- /* attach CI */
- memset(&sp2_config, 0, sizeof(sp2_config));
- sp2_config.dvb_adap = &port->frontends.adapter;
- sp2_config.priv = port;
- sp2_config.ci_control = cx23885_sp2_ci_ctrl;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "sp2", I2C_NAME_SIZE);
- info.addr = 0x40;
- info.platform_data = &sp2_config;
- request_module(info.type);
- client_ci = i2c_new_device(&i2c_bus->i2c_adap, &info);
- if (client_ci == NULL || client_ci->dev.driver == NULL)
- return -ENODEV;
- if (!try_module_get(client_ci->dev.driver->owner)) {
- i2c_unregister_device(client_ci);
- return -ENODEV;
- }
- port->i2c_client_ci = client_ci;
- if (port->nr != 1)
- return 0;
- /* Read entire EEPROM */
- dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
- tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
- sizeof(eeprom));
- pr_info("%s MAC address: %pM\n",
- cx23885_boards[dev->board].name, eeprom + 0xc0);
- memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0, 6);
- return 0;
- }
- }
- return 0;
- }
- static int dvb_register(struct cx23885_tsport *port)
- {
- struct dib7000p_ops dib7000p_ops;
- struct cx23885_dev *dev = port->dev;
- struct cx23885_i2c *i2c_bus = NULL, *i2c_bus2 = NULL;
- struct vb2_dvb_frontend *fe0, *fe1 = NULL;
- struct si2168_config si2168_config;
- struct si2165_platform_data si2165_pdata;
- struct si2157_config si2157_config;
- struct ts2020_config ts2020_config;
- struct m88ds3103_platform_data m88ds3103_pdata;
- struct m88rs6000t_config m88rs6000t_config = {};
- struct a8293_platform_data a8293_pdata = {};
- struct i2c_board_info info;
- struct i2c_adapter *adapter;
- struct i2c_client *client_demod = NULL, *client_tuner = NULL;
- struct i2c_client *client_sec = NULL;
- int (*p_set_voltage)(struct dvb_frontend *fe,
- enum fe_sec_voltage voltage) = NULL;
- int mfe_shared = 0; /* bus not shared by default */
- int ret;
- /* Get the first frontend */
- fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
- if (!fe0)
- return -EINVAL;
- /* init struct vb2_dvb */
- fe0->dvb.name = dev->name;
- /* multi-frontend gate control is undefined or defaults to fe0 */
- port->frontends.gate = 0;
- /* Sets the gate control callback to be used by i2c command calls */
- port->gate_ctrl = cx23885_dvb_gate_ctrl;
- /* init frontend */
- switch (dev->board) {
- case CX23885_BOARD_HAUPPAUGE_HVR1250:
- i2c_bus = &dev->i2c_bus[0];
- fe0->dvb.frontend = dvb_attach(s5h1409_attach,
- &hauppauge_generic_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- dvb_attach(mt2131_attach, fe0->dvb.frontend,
- &i2c_bus->i2c_adap,
- &hauppauge_generic_tunerconfig, 0);
- break;
- case CX23885_BOARD_HAUPPAUGE_HVR1270:
- case CX23885_BOARD_HAUPPAUGE_HVR1275:
- i2c_bus = &dev->i2c_bus[0];
- fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
- &hauppauge_lgdt3305_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- dvb_attach(tda18271_attach, fe0->dvb.frontend,
- 0x60, &dev->i2c_bus[1].i2c_adap,
- &hauppauge_hvr127x_config);
- if (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1275)
- cx23885_set_frontend_hook(port, fe0->dvb.frontend);
- break;
- case CX23885_BOARD_HAUPPAUGE_HVR1255:
- case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
- i2c_bus = &dev->i2c_bus[0];
- fe0->dvb.frontend = dvb_attach(s5h1411_attach,
- &hcw_s5h1411_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- dvb_attach(tda18271_attach, fe0->dvb.frontend,
- 0x60, &dev->i2c_bus[1].i2c_adap,
- &hauppauge_tda18271_config);
- tda18271_attach(&dev->ts1.analog_fe,
- 0x60, &dev->i2c_bus[1].i2c_adap,
- &hauppauge_tda18271_config);
- break;
- case CX23885_BOARD_HAUPPAUGE_HVR1800:
- i2c_bus = &dev->i2c_bus[0];
- switch (alt_tuner) {
- case 1:
- fe0->dvb.frontend =
- dvb_attach(s5h1409_attach,
- &hauppauge_ezqam_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- dvb_attach(tda829x_attach, fe0->dvb.frontend,
- &dev->i2c_bus[1].i2c_adap, 0x42,
- &tda829x_no_probe);
- dvb_attach(tda18271_attach, fe0->dvb.frontend,
- 0x60, &dev->i2c_bus[1].i2c_adap,
- &hauppauge_tda18271_config);
- break;
- case 0:
- default:
- fe0->dvb.frontend =
- dvb_attach(s5h1409_attach,
- &hauppauge_generic_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- dvb_attach(mt2131_attach, fe0->dvb.frontend,
- &i2c_bus->i2c_adap,
- &hauppauge_generic_tunerconfig, 0);
- }
- break;
- case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
- i2c_bus = &dev->i2c_bus[0];
- fe0->dvb.frontend = dvb_attach(s5h1409_attach,
- &hauppauge_hvr1800lp_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- dvb_attach(mt2131_attach, fe0->dvb.frontend,
- &i2c_bus->i2c_adap,
- &hauppauge_generic_tunerconfig, 0);
- break;
- case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
- i2c_bus = &dev->i2c_bus[0];
- fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
- &fusionhdtv_5_express,
- 0x0e,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
- &i2c_bus->i2c_adap, 0x61,
- TUNER_LG_TDVS_H06XF);
- break;
- case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
- i2c_bus = &dev->i2c_bus[1];
- fe0->dvb.frontend = dvb_attach(s5h1409_attach,
- &hauppauge_hvr1500q_config,
- &dev->i2c_bus[0].i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- dvb_attach(xc5000_attach, fe0->dvb.frontend,
- &i2c_bus->i2c_adap,
- &hauppauge_hvr1500q_tunerconfig);
- break;
- case CX23885_BOARD_HAUPPAUGE_HVR1500:
- i2c_bus = &dev->i2c_bus[1];
- fe0->dvb.frontend = dvb_attach(s5h1409_attach,
- &hauppauge_hvr1500_config,
- &dev->i2c_bus[0].i2c_adap);
- if (fe0->dvb.frontend != NULL) {
- struct dvb_frontend *fe;
- struct xc2028_config cfg = {
- .i2c_adap = &i2c_bus->i2c_adap,
- .i2c_addr = 0x61,
- };
- static struct xc2028_ctrl ctl = {
- .fname = XC2028_DEFAULT_FIRMWARE,
- .max_len = 64,
- .demod = XC3028_FE_OREN538,
- };
- fe = dvb_attach(xc2028_attach,
- fe0->dvb.frontend, &cfg);
- if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
- fe->ops.tuner_ops.set_config(fe, &ctl);
- }
- break;
- case CX23885_BOARD_HAUPPAUGE_HVR1200:
- case CX23885_BOARD_HAUPPAUGE_HVR1700:
- i2c_bus = &dev->i2c_bus[0];
- fe0->dvb.frontend = dvb_attach(tda10048_attach,
- &hauppauge_hvr1200_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- dvb_attach(tda829x_attach, fe0->dvb.frontend,
- &dev->i2c_bus[1].i2c_adap, 0x42,
- &tda829x_no_probe);
- dvb_attach(tda18271_attach, fe0->dvb.frontend,
- 0x60, &dev->i2c_bus[1].i2c_adap,
- &hauppauge_hvr1200_tuner_config);
- break;
- case CX23885_BOARD_HAUPPAUGE_HVR1210:
- i2c_bus = &dev->i2c_bus[0];
- fe0->dvb.frontend = dvb_attach(tda10048_attach,
- &hauppauge_hvr1210_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend != NULL) {
- dvb_attach(tda18271_attach, fe0->dvb.frontend,
- 0x60, &dev->i2c_bus[1].i2c_adap,
- &hauppauge_hvr1210_tuner_config);
- }
- break;
- case CX23885_BOARD_HAUPPAUGE_HVR1400:
- i2c_bus = &dev->i2c_bus[0];
- if (!dvb_attach(dib7000p_attach, &dib7000p_ops))
- return -ENODEV;
- fe0->dvb.frontend = dib7000p_ops.init(&i2c_bus->i2c_adap,
- 0x12, &hauppauge_hvr1400_dib7000_config);
- if (fe0->dvb.frontend != NULL) {
- struct dvb_frontend *fe;
- struct xc2028_config cfg = {
- .i2c_adap = &dev->i2c_bus[1].i2c_adap,
- .i2c_addr = 0x64,
- };
- static struct xc2028_ctrl ctl = {
- .fname = XC3028L_DEFAULT_FIRMWARE,
- .max_len = 64,
- .demod = XC3028_FE_DIBCOM52,
- /* This is true for all demods with
- v36 firmware? */
- .type = XC2028_D2633,
- };
- fe = dvb_attach(xc2028_attach,
- fe0->dvb.frontend, &cfg);
- if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
- fe->ops.tuner_ops.set_config(fe, &ctl);
- }
- break;
- case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
- i2c_bus = &dev->i2c_bus[port->nr - 1];
- fe0->dvb.frontend = dvb_attach(s5h1409_attach,
- &dvico_s5h1409_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- fe0->dvb.frontend = dvb_attach(s5h1411_attach,
- &dvico_s5h1411_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend != NULL)
- dvb_attach(xc5000_attach, fe0->dvb.frontend,
- &i2c_bus->i2c_adap,
- &dvico_xc5000_tunerconfig);
- break;
- case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
- i2c_bus = &dev->i2c_bus[port->nr - 1];
- fe0->dvb.frontend = dvb_attach(zl10353_attach,
- &dvico_fusionhdtv_xc3028,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend != NULL) {
- struct dvb_frontend *fe;
- struct xc2028_config cfg = {
- .i2c_adap = &i2c_bus->i2c_adap,
- .i2c_addr = 0x61,
- };
- static struct xc2028_ctrl ctl = {
- .fname = XC2028_DEFAULT_FIRMWARE,
- .max_len = 64,
- .demod = XC3028_FE_ZARLINK456,
- };
- fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
- &cfg);
- if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
- fe->ops.tuner_ops.set_config(fe, &ctl);
- }
- break;
- }
- case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2: {
- i2c_bus = &dev->i2c_bus[port->nr - 1];
- /* cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); */
- /* cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); */
- if (!dvb_attach(dib7000p_attach, &dib7000p_ops))
- return -ENODEV;
- if (dib7000p_ops.i2c_enumeration(&i2c_bus->i2c_adap, 1, 0x12, &dib7070p_dib7000p_config) < 0) {
- pr_warn("Unable to enumerate dib7000p\n");
- return -ENODEV;
- }
- fe0->dvb.frontend = dib7000p_ops.init(&i2c_bus->i2c_adap, 0x80, &dib7070p_dib7000p_config);
- if (fe0->dvb.frontend != NULL) {
- struct i2c_adapter *tun_i2c;
- fe0->dvb.frontend->sec_priv = kmemdup(&dib7000p_ops, sizeof(dib7000p_ops), GFP_KERNEL);
- if (!fe0->dvb.frontend->sec_priv)
- return -ENOMEM;
- tun_i2c = dib7000p_ops.get_i2c_master(fe0->dvb.frontend, DIBX000_I2C_INTERFACE_TUNER, 1);
- if (!dvb_attach(dib0070_attach, fe0->dvb.frontend, tun_i2c, &dib7070p_dib0070_config))
- return -ENODEV;
- }
- break;
- }
- case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
- case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
- case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
- i2c_bus = &dev->i2c_bus[0];
- fe0->dvb.frontend = dvb_attach(zl10353_attach,
- &dvico_fusionhdtv_xc3028,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend != NULL) {
- struct dvb_frontend *fe;
- struct xc2028_config cfg = {
- .i2c_adap = &dev->i2c_bus[1].i2c_adap,
- .i2c_addr = 0x61,
- };
- static struct xc2028_ctrl ctl = {
- .fname = XC2028_DEFAULT_FIRMWARE,
- .max_len = 64,
- .demod = XC3028_FE_ZARLINK456,
- };
- fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
- &cfg);
- if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
- fe->ops.tuner_ops.set_config(fe, &ctl);
- }
- break;
- case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000:
- i2c_bus = &dev->i2c_bus[0];
- fe0->dvb.frontend = dvb_attach(zl10353_attach,
- &dvico_fusionhdtv_xc3028,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend != NULL) {
- struct dvb_frontend *fe;
- struct xc4000_config cfg = {
- .i2c_address = 0x61,
- .default_pm = 0,
- .dvb_amplitude = 134,
- .set_smoothedcvbs = 1,
- .if_khz = 4560
- };
- fe = dvb_attach(xc4000_attach, fe0->dvb.frontend,
- &dev->i2c_bus[1].i2c_adap, &cfg);
- if (!fe) {
- pr_err("%s/2: xc4000 attach failed\n",
- dev->name);
- goto frontend_detach;
- }
- }
- break;
- case CX23885_BOARD_TBS_6920:
- i2c_bus = &dev->i2c_bus[1];
- fe0->dvb.frontend = dvb_attach(cx24116_attach,
- &tbs_cx24116_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend != NULL)
- fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
- break;
- case CX23885_BOARD_TBS_6980:
- case CX23885_BOARD_TBS_6981:
- i2c_bus = &dev->i2c_bus[1];
- switch (port->nr) {
- /* PORT B */
- case 1:
- fe0->dvb.frontend = dvb_attach(cx24117_attach,
- &tbs_cx24117_config,
- &i2c_bus->i2c_adap);
- break;
- /* PORT C */
- case 2:
- fe0->dvb.frontend = dvb_attach(cx24117_attach,
- &tbs_cx24117_config,
- &i2c_bus->i2c_adap);
- break;
- }
- break;
- case CX23885_BOARD_TEVII_S470:
- i2c_bus = &dev->i2c_bus[1];
- fe0->dvb.frontend = dvb_attach(ds3000_attach,
- &tevii_ds3000_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend != NULL) {
- dvb_attach(ts2020_attach, fe0->dvb.frontend,
- &tevii_ts2020_config, &i2c_bus->i2c_adap);
- fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
- }
- break;
- case CX23885_BOARD_DVBWORLD_2005:
- i2c_bus = &dev->i2c_bus[1];
- fe0->dvb.frontend = dvb_attach(cx24116_attach,
- &dvbworld_cx24116_config,
- &i2c_bus->i2c_adap);
- break;
- case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
- i2c_bus = &dev->i2c_bus[0];
- switch (port->nr) {
- /* port B */
- case 1:
- fe0->dvb.frontend = dvb_attach(stv0900_attach,
- &netup_stv0900_config,
- &i2c_bus->i2c_adap, 0);
- if (fe0->dvb.frontend != NULL) {
- if (dvb_attach(stv6110_attach,
- fe0->dvb.frontend,
- &netup_stv6110_tunerconfig_a,
- &i2c_bus->i2c_adap)) {
- if (!dvb_attach(lnbh24_attach,
- fe0->dvb.frontend,
- &i2c_bus->i2c_adap,
- LNBH24_PCL | LNBH24_TTX,
- LNBH24_TEN, 0x09))
- pr_err("No LNBH24 found!\n");
- }
- }
- break;
- /* port C */
- case 2:
- fe0->dvb.frontend = dvb_attach(stv0900_attach,
- &netup_stv0900_config,
- &i2c_bus->i2c_adap, 1);
- if (fe0->dvb.frontend != NULL) {
- if (dvb_attach(stv6110_attach,
- fe0->dvb.frontend,
- &netup_stv6110_tunerconfig_b,
- &i2c_bus->i2c_adap)) {
- if (!dvb_attach(lnbh24_attach,
- fe0->dvb.frontend,
- &i2c_bus->i2c_adap,
- LNBH24_PCL | LNBH24_TTX,
- LNBH24_TEN, 0x0a))
- pr_err("No LNBH24 found!\n");
- }
- }
- break;
- }
- break;
- case CX23885_BOARD_MYGICA_X8506:
- i2c_bus = &dev->i2c_bus[0];
- i2c_bus2 = &dev->i2c_bus[1];
- fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
- &mygica_x8506_lgs8gl5_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- dvb_attach(xc5000_attach, fe0->dvb.frontend,
- &i2c_bus2->i2c_adap, &mygica_x8506_xc5000_config);
- cx23885_set_frontend_hook(port, fe0->dvb.frontend);
- break;
- case CX23885_BOARD_MYGICA_X8507:
- i2c_bus = &dev->i2c_bus[0];
- i2c_bus2 = &dev->i2c_bus[1];
- fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
- &mygica_x8507_mb86a20s_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- dvb_attach(xc5000_attach, fe0->dvb.frontend,
- &i2c_bus2->i2c_adap,
- &mygica_x8507_xc5000_config);
- cx23885_set_frontend_hook(port, fe0->dvb.frontend);
- break;
- case CX23885_BOARD_MAGICPRO_PROHDTVE2:
- i2c_bus = &dev->i2c_bus[0];
- i2c_bus2 = &dev->i2c_bus[1];
- fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
- &magicpro_prohdtve2_lgs8g75_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- dvb_attach(xc5000_attach, fe0->dvb.frontend,
- &i2c_bus2->i2c_adap,
- &magicpro_prohdtve2_xc5000_config);
- cx23885_set_frontend_hook(port, fe0->dvb.frontend);
- break;
- case CX23885_BOARD_HAUPPAUGE_HVR1850:
- i2c_bus = &dev->i2c_bus[0];
- fe0->dvb.frontend = dvb_attach(s5h1411_attach,
- &hcw_s5h1411_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- dvb_attach(tda18271_attach, fe0->dvb.frontend,
- 0x60, &dev->i2c_bus[0].i2c_adap,
- &hauppauge_tda18271_config);
- tda18271_attach(&dev->ts1.analog_fe,
- 0x60, &dev->i2c_bus[1].i2c_adap,
- &hauppauge_tda18271_config);
- break;
- case CX23885_BOARD_HAUPPAUGE_HVR1290:
- i2c_bus = &dev->i2c_bus[0];
- fe0->dvb.frontend = dvb_attach(s5h1411_attach,
- &hcw_s5h1411_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- dvb_attach(tda18271_attach, fe0->dvb.frontend,
- 0x60, &dev->i2c_bus[0].i2c_adap,
- &hauppauge_tda18271_config);
- break;
- case CX23885_BOARD_MYGICA_X8558PRO:
- switch (port->nr) {
- /* port B */
- case 1:
- i2c_bus = &dev->i2c_bus[0];
- fe0->dvb.frontend = dvb_attach(atbm8830_attach,
- &mygica_x8558pro_atbm8830_cfg1,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- dvb_attach(max2165_attach, fe0->dvb.frontend,
- &i2c_bus->i2c_adap,
- &mygic_x8558pro_max2165_cfg1);
- break;
- /* port C */
- case 2:
- i2c_bus = &dev->i2c_bus[1];
- fe0->dvb.frontend = dvb_attach(atbm8830_attach,
- &mygica_x8558pro_atbm8830_cfg2,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- dvb_attach(max2165_attach, fe0->dvb.frontend,
- &i2c_bus->i2c_adap,
- &mygic_x8558pro_max2165_cfg2);
- }
- break;
- case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
- if (port->nr > 2)
- return 0;
- i2c_bus = &dev->i2c_bus[0];
- mfe_shared = 1;/* MFE */
- port->frontends.gate = 0;/* not clear for me yet */
- /* ports B, C */
- /* MFE frontend 1 DVB-T */
- fe0->dvb.frontend = dvb_attach(stv0367ter_attach,
- &netup_stv0367_config[port->nr - 1],
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- if (NULL == dvb_attach(xc5000_attach, fe0->dvb.frontend,
- &i2c_bus->i2c_adap,
- &netup_xc5000_config[port->nr - 1]))
- goto frontend_detach;
- /* load xc5000 firmware */
- fe0->dvb.frontend->ops.tuner_ops.init(fe0->dvb.frontend);
- /* MFE frontend 2 */
- fe1 = vb2_dvb_get_frontend(&port->frontends, 2);
- if (fe1 == NULL)
- goto frontend_detach;
- /* DVB-C init */
- fe1->dvb.frontend = dvb_attach(stv0367cab_attach,
- &netup_stv0367_config[port->nr - 1],
- &i2c_bus->i2c_adap);
- if (fe1->dvb.frontend == NULL)
- break;
- fe1->dvb.frontend->id = 1;
- if (NULL == dvb_attach(xc5000_attach,
- fe1->dvb.frontend,
- &i2c_bus->i2c_adap,
- &netup_xc5000_config[port->nr - 1]))
- goto frontend_detach;
- break;
- case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
- i2c_bus = &dev->i2c_bus[0];
- i2c_bus2 = &dev->i2c_bus[1];
- switch (port->nr) {
- /* port b */
- case 1:
- fe0->dvb.frontend = dvb_attach(drxk_attach,
- &terratec_drxk_config[0],
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- if (!dvb_attach(mt2063_attach,
- fe0->dvb.frontend,
- &terratec_mt2063_config[0],
- &i2c_bus2->i2c_adap))
- goto frontend_detach;
- break;
- /* port c */
- case 2:
- fe0->dvb.frontend = dvb_attach(drxk_attach,
- &terratec_drxk_config[1],
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- if (!dvb_attach(mt2063_attach,
- fe0->dvb.frontend,
- &terratec_mt2063_config[1],
- &i2c_bus2->i2c_adap))
- goto frontend_detach;
- break;
- }
- break;
- case CX23885_BOARD_TEVII_S471:
- i2c_bus = &dev->i2c_bus[1];
- fe0->dvb.frontend = dvb_attach(ds3000_attach,
- &tevii_ds3000_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- dvb_attach(ts2020_attach, fe0->dvb.frontend,
- &tevii_ts2020_config, &i2c_bus->i2c_adap);
- break;
- case CX23885_BOARD_PROF_8000:
- i2c_bus = &dev->i2c_bus[0];
- fe0->dvb.frontend = dvb_attach(stv090x_attach,
- &prof_8000_stv090x_config,
- &i2c_bus->i2c_adap,
- STV090x_DEMODULATOR_0);
- if (fe0->dvb.frontend == NULL)
- break;
- if (!dvb_attach(stb6100_attach,
- fe0->dvb.frontend,
- &prof_8000_stb6100_config,
- &i2c_bus->i2c_adap))
- goto frontend_detach;
- fe0->dvb.frontend->ops.set_voltage = p8000_set_voltage;
- break;
- case CX23885_BOARD_HAUPPAUGE_HVR4400: {
- struct tda10071_platform_data tda10071_pdata = hauppauge_tda10071_pdata;
- struct a8293_platform_data a8293_pdata = {};
- i2c_bus = &dev->i2c_bus[0];
- i2c_bus2 = &dev->i2c_bus[1];
- switch (port->nr) {
- /* port b */
- case 1:
- /* attach demod + tuner combo */
- memset(&info, 0, sizeof(info));
- strlcpy(info.type, "tda10071_cx24118", I2C_NAME_SIZE);
- info.addr = 0x05;
- info.platform_data = &tda10071_pdata;
- request_module("tda10071");
- client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
- if (!client_demod || !client_demod->dev.driver)
- goto frontend_detach;
- if (!try_module_get(client_demod->dev.driver->owner)) {
- i2c_unregister_device(client_demod);
- goto frontend_detach;
- }
- fe0->dvb.frontend = tda10071_pdata.get_dvb_frontend(client_demod);
- port->i2c_client_demod = client_demod;
- /* attach SEC */
- a8293_pdata.dvb_frontend = fe0->dvb.frontend;
- memset(&info, 0, sizeof(info));
- strlcpy(info.type, "a8293", I2C_NAME_SIZE);
- info.addr = 0x0b;
- info.platform_data = &a8293_pdata;
- request_module("a8293");
- client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info);
- if (!client_sec || !client_sec->dev.driver)
- goto frontend_detach;
- if (!try_module_get(client_sec->dev.driver->owner)) {
- i2c_unregister_device(client_sec);
- goto frontend_detach;
- }
- port->i2c_client_sec = client_sec;
- break;
- /* port c */
- case 2:
- /* attach frontend */
- memset(&si2165_pdata, 0, sizeof(si2165_pdata));
- si2165_pdata.fe = &fe0->dvb.frontend;
- si2165_pdata.chip_mode = SI2165_MODE_PLL_XTAL;
- si2165_pdata.ref_freq_hz = 16000000;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "si2165", I2C_NAME_SIZE);
- info.addr = 0x64;
- info.platform_data = &si2165_pdata;
- request_module(info.type);
- client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
- if (client_demod == NULL ||
- client_demod->dev.driver == NULL)
- goto frontend_detach;
- if (!try_module_get(client_demod->dev.driver->owner)) {
- i2c_unregister_device(client_demod);
- goto frontend_detach;
- }
- port->i2c_client_demod = client_demod;
- if (fe0->dvb.frontend == NULL)
- break;
- fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
- if (!dvb_attach(tda18271_attach,
- fe0->dvb.frontend,
- 0x60, &i2c_bus2->i2c_adap,
- &hauppauge_hvr4400_tuner_config))
- goto frontend_detach;
- break;
- }
- break;
- }
- case CX23885_BOARD_HAUPPAUGE_STARBURST: {
- struct tda10071_platform_data tda10071_pdata = hauppauge_tda10071_pdata;
- struct a8293_platform_data a8293_pdata = {};
- i2c_bus = &dev->i2c_bus[0];
- /* attach demod + tuner combo */
- memset(&info, 0, sizeof(info));
- strlcpy(info.type, "tda10071_cx24118", I2C_NAME_SIZE);
- info.addr = 0x05;
- info.platform_data = &tda10071_pdata;
- request_module("tda10071");
- client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
- if (!client_demod || !client_demod->dev.driver)
- goto frontend_detach;
- if (!try_module_get(client_demod->dev.driver->owner)) {
- i2c_unregister_device(client_demod);
- goto frontend_detach;
- }
- fe0->dvb.frontend = tda10071_pdata.get_dvb_frontend(client_demod);
- port->i2c_client_demod = client_demod;
- /* attach SEC */
- a8293_pdata.dvb_frontend = fe0->dvb.frontend;
- memset(&info, 0, sizeof(info));
- strlcpy(info.type, "a8293", I2C_NAME_SIZE);
- info.addr = 0x0b;
- info.platform_data = &a8293_pdata;
- request_module("a8293");
- client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info);
- if (!client_sec || !client_sec->dev.driver)
- goto frontend_detach;
- if (!try_module_get(client_sec->dev.driver->owner)) {
- i2c_unregister_device(client_sec);
- goto frontend_detach;
- }
- port->i2c_client_sec = client_sec;
- break;
- }
- case CX23885_BOARD_DVBSKY_T9580:
- case CX23885_BOARD_DVBSKY_S950:
- i2c_bus = &dev->i2c_bus[0];
- i2c_bus2 = &dev->i2c_bus[1];
- switch (port->nr) {
- /* port b - satellite */
- case 1:
- /* attach frontend */
- fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
- &dvbsky_t9580_m88ds3103_config,
- &i2c_bus2->i2c_adap, &adapter);
- if (fe0->dvb.frontend == NULL)
- break;
- /* attach tuner */
- memset(&ts2020_config, 0, sizeof(ts2020_config));
- ts2020_config.fe = fe0->dvb.frontend;
- ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
- info.addr = 0x60;
- info.platform_data = &ts2020_config;
- request_module(info.type);
- client_tuner = i2c_new_device(adapter, &info);
- if (client_tuner == NULL ||
- client_tuner->dev.driver == NULL)
- goto frontend_detach;
- if (!try_module_get(client_tuner->dev.driver->owner)) {
- i2c_unregister_device(client_tuner);
- goto frontend_detach;
- }
- /* delegate signal strength measurement to tuner */
- fe0->dvb.frontend->ops.read_signal_strength =
- fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
- /*
- * for setting the voltage we need to set GPIOs on
- * the card.
- */
- port->fe_set_voltage =
- fe0->dvb.frontend->ops.set_voltage;
- fe0->dvb.frontend->ops.set_voltage =
- dvbsky_t9580_set_voltage;
- port->i2c_client_tuner = client_tuner;
- break;
- /* port c - terrestrial/cable */
- case 2:
- /* attach frontend */
- memset(&si2168_config, 0, sizeof(si2168_config));
- si2168_config.i2c_adapter = &adapter;
- si2168_config.fe = &fe0->dvb.frontend;
- si2168_config.ts_mode = SI2168_TS_SERIAL;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "si2168", I2C_NAME_SIZE);
- info.addr = 0x64;
- info.platform_data = &si2168_config;
- request_module(info.type);
- client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
- if (client_demod == NULL ||
- client_demod->dev.driver == NULL)
- goto frontend_detach;
- if (!try_module_get(client_demod->dev.driver->owner)) {
- i2c_unregister_device(client_demod);
- goto frontend_detach;
- }
- port->i2c_client_demod = client_demod;
- /* attach tuner */
- memset(&si2157_config, 0, sizeof(si2157_config));
- si2157_config.fe = fe0->dvb.frontend;
- si2157_config.if_port = 1;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "si2157", I2C_NAME_SIZE);
- info.addr = 0x60;
- info.platform_data = &si2157_config;
- request_module(info.type);
- client_tuner = i2c_new_device(adapter, &info);
- if (client_tuner == NULL ||
- client_tuner->dev.driver == NULL)
- goto frontend_detach;
- if (!try_module_get(client_tuner->dev.driver->owner)) {
- i2c_unregister_device(client_tuner);
- goto frontend_detach;
- }
- port->i2c_client_tuner = client_tuner;
- break;
- }
- break;
- case CX23885_BOARD_DVBSKY_T980C:
- case CX23885_BOARD_TT_CT2_4500_CI:
- i2c_bus = &dev->i2c_bus[0];
- i2c_bus2 = &dev->i2c_bus[1];
- /* attach frontend */
- memset(&si2168_config, 0, sizeof(si2168_config));
- si2168_config.i2c_adapter = &adapter;
- si2168_config.fe = &fe0->dvb.frontend;
- si2168_config.ts_mode = SI2168_TS_PARALLEL;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "si2168", I2C_NAME_SIZE);
- info.addr = 0x64;
- info.platform_data = &si2168_config;
- request_module(info.type);
- client_demod = i2c_new_device(&i2c_bus2->i2c_adap, &info);
- if (client_demod == NULL || client_demod->dev.driver == NULL)
- goto frontend_detach;
- if (!try_module_get(client_demod->dev.driver->owner)) {
- i2c_unregister_device(client_demod);
- goto frontend_detach;
- }
- port->i2c_client_demod = client_demod;
- /* attach tuner */
- memset(&si2157_config, 0, sizeof(si2157_config));
- si2157_config.fe = fe0->dvb.frontend;
- si2157_config.if_port = 1;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "si2157", I2C_NAME_SIZE);
- info.addr = 0x60;
- info.platform_data = &si2157_config;
- request_module(info.type);
- client_tuner = i2c_new_device(adapter, &info);
- if (client_tuner == NULL ||
- client_tuner->dev.driver == NULL)
- goto frontend_detach;
- if (!try_module_get(client_tuner->dev.driver->owner)) {
- i2c_unregister_device(client_tuner);
- goto frontend_detach;
- }
- port->i2c_client_tuner = client_tuner;
- break;
- case CX23885_BOARD_DVBSKY_S950C:
- i2c_bus = &dev->i2c_bus[0];
- i2c_bus2 = &dev->i2c_bus[1];
- /* attach frontend */
- fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
- &dvbsky_s950c_m88ds3103_config,
- &i2c_bus2->i2c_adap, &adapter);
- if (fe0->dvb.frontend == NULL)
- break;
- /* attach tuner */
- memset(&ts2020_config, 0, sizeof(ts2020_config));
- ts2020_config.fe = fe0->dvb.frontend;
- ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
- info.addr = 0x60;
- info.platform_data = &ts2020_config;
- request_module(info.type);
- client_tuner = i2c_new_device(adapter, &info);
- if (client_tuner == NULL || client_tuner->dev.driver == NULL)
- goto frontend_detach;
- if (!try_module_get(client_tuner->dev.driver->owner)) {
- i2c_unregister_device(client_tuner);
- goto frontend_detach;
- }
- /* delegate signal strength measurement to tuner */
- fe0->dvb.frontend->ops.read_signal_strength =
- fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
- port->i2c_client_tuner = client_tuner;
- break;
- case CX23885_BOARD_DVBSKY_S952:
- /* attach frontend */
- memset(&m88ds3103_pdata, 0, sizeof(m88ds3103_pdata));
- m88ds3103_pdata.clk = 27000000;
- m88ds3103_pdata.i2c_wr_max = 33;
- m88ds3103_pdata.agc = 0x99;
- m88ds3103_pdata.clk_out = M88DS3103_CLOCK_OUT_DISABLED;
- m88ds3103_pdata.lnb_en_pol = 1;
- switch (port->nr) {
- /* port b */
- case 1:
- i2c_bus = &dev->i2c_bus[1];
- m88ds3103_pdata.ts_mode = M88DS3103_TS_PARALLEL;
- m88ds3103_pdata.ts_clk = 16000;
- m88ds3103_pdata.ts_clk_pol = 1;
- p_set_voltage = dvbsky_t9580_set_voltage;
- break;
- /* port c */
- case 2:
- i2c_bus = &dev->i2c_bus[0];
- m88ds3103_pdata.ts_mode = M88DS3103_TS_SERIAL;
- m88ds3103_pdata.ts_clk = 96000;
- m88ds3103_pdata.ts_clk_pol = 0;
- p_set_voltage = dvbsky_s952_portc_set_voltage;
- break;
- default:
- return 0;
- }
- memset(&info, 0, sizeof(info));
- strlcpy(info.type, "m88ds3103", I2C_NAME_SIZE);
- info.addr = 0x68;
- info.platform_data = &m88ds3103_pdata;
- request_module(info.type);
- client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
- if (client_demod == NULL || client_demod->dev.driver == NULL)
- goto frontend_detach;
- if (!try_module_get(client_demod->dev.driver->owner)) {
- i2c_unregister_device(client_demod);
- goto frontend_detach;
- }
- port->i2c_client_demod = client_demod;
- adapter = m88ds3103_pdata.get_i2c_adapter(client_demod);
- fe0->dvb.frontend = m88ds3103_pdata.get_dvb_frontend(client_demod);
- /* attach tuner */
- memset(&ts2020_config, 0, sizeof(ts2020_config));
- ts2020_config.fe = fe0->dvb.frontend;
- ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
- info.addr = 0x60;
- info.platform_data = &ts2020_config;
- request_module(info.type);
- client_tuner = i2c_new_device(adapter, &info);
- if (client_tuner == NULL || client_tuner->dev.driver == NULL)
- goto frontend_detach;
- if (!try_module_get(client_tuner->dev.driver->owner)) {
- i2c_unregister_device(client_tuner);
- goto frontend_detach;
- }
- /* delegate signal strength measurement to tuner */
- fe0->dvb.frontend->ops.read_signal_strength =
- fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
- /*
- * for setting the voltage we need to set GPIOs on
- * the card.
- */
- port->fe_set_voltage =
- fe0->dvb.frontend->ops.set_voltage;
- fe0->dvb.frontend->ops.set_voltage = p_set_voltage;
- port->i2c_client_tuner = client_tuner;
- break;
- case CX23885_BOARD_DVBSKY_T982:
- memset(&si2168_config, 0, sizeof(si2168_config));
- switch (port->nr) {
- /* port b */
- case 1:
- i2c_bus = &dev->i2c_bus[1];
- si2168_config.ts_mode = SI2168_TS_PARALLEL;
- break;
- /* port c */
- case 2:
- i2c_bus = &dev->i2c_bus[0];
- si2168_config.ts_mode = SI2168_TS_SERIAL;
- break;
- }
- /* attach frontend */
- si2168_config.i2c_adapter = &adapter;
- si2168_config.fe = &fe0->dvb.frontend;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "si2168", I2C_NAME_SIZE);
- info.addr = 0x64;
- info.platform_data = &si2168_config;
- request_module(info.type);
- client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
- if (client_demod == NULL || client_demod->dev.driver == NULL)
- goto frontend_detach;
- if (!try_module_get(client_demod->dev.driver->owner)) {
- i2c_unregister_device(client_demod);
- goto frontend_detach;
- }
- port->i2c_client_demod = client_demod;
- /* attach tuner */
- memset(&si2157_config, 0, sizeof(si2157_config));
- si2157_config.fe = fe0->dvb.frontend;
- si2157_config.if_port = 1;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "si2157", I2C_NAME_SIZE);
- info.addr = 0x60;
- info.platform_data = &si2157_config;
- request_module(info.type);
- client_tuner = i2c_new_device(adapter, &info);
- if (client_tuner == NULL ||
- client_tuner->dev.driver == NULL)
- goto frontend_detach;
- if (!try_module_get(client_tuner->dev.driver->owner)) {
- i2c_unregister_device(client_tuner);
- goto frontend_detach;
- }
- port->i2c_client_tuner = client_tuner;
- break;
- case CX23885_BOARD_HAUPPAUGE_STARBURST2:
- case CX23885_BOARD_HAUPPAUGE_HVR5525:
- i2c_bus = &dev->i2c_bus[0];
- i2c_bus2 = &dev->i2c_bus[1];
- switch (port->nr) {
- /* port b - satellite */
- case 1:
- /* attach frontend */
- fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
- &hauppauge_hvr5525_m88ds3103_config,
- &i2c_bus->i2c_adap, &adapter);
- if (fe0->dvb.frontend == NULL)
- break;
- /* attach SEC */
- a8293_pdata.dvb_frontend = fe0->dvb.frontend;
- memset(&info, 0, sizeof(info));
- strlcpy(info.type, "a8293", I2C_NAME_SIZE);
- info.addr = 0x0b;
- info.platform_data = &a8293_pdata;
- request_module("a8293");
- client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info);
- if (!client_sec || !client_sec->dev.driver)
- goto frontend_detach;
- if (!try_module_get(client_sec->dev.driver->owner)) {
- i2c_unregister_device(client_sec);
- goto frontend_detach;
- }
- port->i2c_client_sec = client_sec;
- /* attach tuner */
- memset(&m88rs6000t_config, 0, sizeof(m88rs6000t_config));
- m88rs6000t_config.fe = fe0->dvb.frontend;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "m88rs6000t", I2C_NAME_SIZE);
- info.addr = 0x21;
- info.platform_data = &m88rs6000t_config;
- request_module("%s", info.type);
- client_tuner = i2c_new_device(adapter, &info);
- if (!client_tuner || !client_tuner->dev.driver)
- goto frontend_detach;
- if (!try_module_get(client_tuner->dev.driver->owner)) {
- i2c_unregister_device(client_tuner);
- goto frontend_detach;
- }
- port->i2c_client_tuner = client_tuner;
- /* delegate signal strength measurement to tuner */
- fe0->dvb.frontend->ops.read_signal_strength =
- fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
- break;
- /* port c - terrestrial/cable */
- case 2:
- /* attach frontend */
- memset(&si2168_config, 0, sizeof(si2168_config));
- si2168_config.i2c_adapter = &adapter;
- si2168_config.fe = &fe0->dvb.frontend;
- si2168_config.ts_mode = SI2168_TS_SERIAL;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "si2168", I2C_NAME_SIZE);
- info.addr = 0x64;
- info.platform_data = &si2168_config;
- request_module("%s", info.type);
- client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
- if (!client_demod || !client_demod->dev.driver)
- goto frontend_detach;
- if (!try_module_get(client_demod->dev.driver->owner)) {
- i2c_unregister_device(client_demod);
- goto frontend_detach;
- }
- port->i2c_client_demod = client_demod;
- /* attach tuner */
- memset(&si2157_config, 0, sizeof(si2157_config));
- si2157_config.fe = fe0->dvb.frontend;
- si2157_config.if_port = 1;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "si2157", I2C_NAME_SIZE);
- info.addr = 0x60;
- info.platform_data = &si2157_config;
- request_module("%s", info.type);
- client_tuner = i2c_new_device(&i2c_bus2->i2c_adap, &info);
- if (!client_tuner || !client_tuner->dev.driver) {
- module_put(client_demod->dev.driver->owner);
- i2c_unregister_device(client_demod);
- port->i2c_client_demod = NULL;
- goto frontend_detach;
- }
- if (!try_module_get(client_tuner->dev.driver->owner)) {
- i2c_unregister_device(client_tuner);
- module_put(client_demod->dev.driver->owner);
- i2c_unregister_device(client_demod);
- port->i2c_client_demod = NULL;
- goto frontend_detach;
- }
- port->i2c_client_tuner = client_tuner;
- break;
- }
- break;
- case CX23885_BOARD_HAUPPAUGE_QUADHD_DVB:
- case CX23885_BOARD_HAUPPAUGE_QUADHD_DVB_885:
- pr_info("%s(): board=%d port=%d\n", __func__,
- dev->board, port->nr);
- switch (port->nr) {
- /* port b - Terrestrial/cable */
- case 1:
- /* attach frontend */
- memset(&si2168_config, 0, sizeof(si2168_config));
- si2168_config.i2c_adapter = &adapter;
- si2168_config.fe = &fe0->dvb.frontend;
- si2168_config.ts_mode = SI2168_TS_SERIAL;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "si2168", I2C_NAME_SIZE);
- info.addr = 0x64;
- info.platform_data = &si2168_config;
- request_module("%s", info.type);
- client_demod = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info);
- if (!client_demod || !client_demod->dev.driver)
- goto frontend_detach;
- if (!try_module_get(client_demod->dev.driver->owner)) {
- i2c_unregister_device(client_demod);
- goto frontend_detach;
- }
- port->i2c_client_demod = client_demod;
- /* attach tuner */
- memset(&si2157_config, 0, sizeof(si2157_config));
- si2157_config.fe = fe0->dvb.frontend;
- si2157_config.if_port = 1;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "si2157", I2C_NAME_SIZE);
- info.addr = 0x60;
- info.platform_data = &si2157_config;
- request_module("%s", info.type);
- client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
- if (!client_tuner || !client_tuner->dev.driver) {
- module_put(client_demod->dev.driver->owner);
- i2c_unregister_device(client_demod);
- port->i2c_client_demod = NULL;
- goto frontend_detach;
- }
- if (!try_module_get(client_tuner->dev.driver->owner)) {
- i2c_unregister_device(client_tuner);
- module_put(client_demod->dev.driver->owner);
- i2c_unregister_device(client_demod);
- port->i2c_client_demod = NULL;
- goto frontend_detach;
- }
- port->i2c_client_tuner = client_tuner;
- break;
- /* port c - terrestrial/cable */
- case 2:
- /* attach frontend */
- memset(&si2168_config, 0, sizeof(si2168_config));
- si2168_config.i2c_adapter = &adapter;
- si2168_config.fe = &fe0->dvb.frontend;
- si2168_config.ts_mode = SI2168_TS_SERIAL;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "si2168", I2C_NAME_SIZE);
- info.addr = 0x66;
- info.platform_data = &si2168_config;
- request_module("%s", info.type);
- client_demod = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info);
- if (!client_demod || !client_demod->dev.driver)
- goto frontend_detach;
- if (!try_module_get(client_demod->dev.driver->owner)) {
- i2c_unregister_device(client_demod);
- goto frontend_detach;
- }
- port->i2c_client_demod = client_demod;
- /* attach tuner */
- memset(&si2157_config, 0, sizeof(si2157_config));
- si2157_config.fe = fe0->dvb.frontend;
- si2157_config.if_port = 1;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "si2157", I2C_NAME_SIZE);
- info.addr = 0x62;
- info.platform_data = &si2157_config;
- request_module("%s", info.type);
- client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
- if (!client_tuner || !client_tuner->dev.driver) {
- module_put(client_demod->dev.driver->owner);
- i2c_unregister_device(client_demod);
- port->i2c_client_demod = NULL;
- goto frontend_detach;
- }
- if (!try_module_get(client_tuner->dev.driver->owner)) {
- i2c_unregister_device(client_tuner);
- module_put(client_demod->dev.driver->owner);
- i2c_unregister_device(client_demod);
- port->i2c_client_demod = NULL;
- goto frontend_detach;
- }
- port->i2c_client_tuner = client_tuner;
- break;
- }
- break;
- case CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC:
- case CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC_885:
- pr_info("%s(): board=%d port=%d\n", __func__,
- dev->board, port->nr);
- switch (port->nr) {
- /* port b - Terrestrial/cable */
- case 1:
- /* attach frontend */
- i2c_bus = &dev->i2c_bus[0];
- fe0->dvb.frontend = dvb_attach(lgdt3306a_attach,
- &hauppauge_quadHD_ATSC_a_config, &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- /* attach tuner */
- memset(&si2157_config, 0, sizeof(si2157_config));
- si2157_config.fe = fe0->dvb.frontend;
- si2157_config.if_port = 1;
- si2157_config.inversion = 1;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "si2157", I2C_NAME_SIZE);
- info.addr = 0x60;
- info.platform_data = &si2157_config;
- request_module("%s", info.type);
- client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
- if (!client_tuner || !client_tuner->dev.driver) {
- module_put(client_demod->dev.driver->owner);
- i2c_unregister_device(client_demod);
- port->i2c_client_demod = NULL;
- goto frontend_detach;
- }
- if (!try_module_get(client_tuner->dev.driver->owner)) {
- i2c_unregister_device(client_tuner);
- module_put(client_demod->dev.driver->owner);
- i2c_unregister_device(client_demod);
- port->i2c_client_demod = NULL;
- goto frontend_detach;
- }
- port->i2c_client_tuner = client_tuner;
- break;
- /* port c - terrestrial/cable */
- case 2:
- /* attach frontend */
- i2c_bus = &dev->i2c_bus[0];
- fe0->dvb.frontend = dvb_attach(lgdt3306a_attach,
- &hauppauge_quadHD_ATSC_b_config, &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- /* attach tuner */
- memset(&si2157_config, 0, sizeof(si2157_config));
- si2157_config.fe = fe0->dvb.frontend;
- si2157_config.if_port = 1;
- si2157_config.inversion = 1;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "si2157", I2C_NAME_SIZE);
- info.addr = 0x62;
- info.platform_data = &si2157_config;
- request_module("%s", info.type);
- client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
- if (!client_tuner || !client_tuner->dev.driver) {
- module_put(client_demod->dev.driver->owner);
- i2c_unregister_device(client_demod);
- port->i2c_client_demod = NULL;
- goto frontend_detach;
- }
- if (!try_module_get(client_tuner->dev.driver->owner)) {
- i2c_unregister_device(client_tuner);
- module_put(client_demod->dev.driver->owner);
- i2c_unregister_device(client_demod);
- port->i2c_client_demod = NULL;
- goto frontend_detach;
- }
- port->i2c_client_tuner = client_tuner;
- break;
- }
- break;
- case CX23885_BOARD_HAUPPAUGE_HVR1265_K4:
- switch (port->nr) {
- /* port c - Terrestrial/cable */
- case 2:
- /* attach frontend */
- i2c_bus = &dev->i2c_bus[0];
- fe0->dvb.frontend = dvb_attach(lgdt3306a_attach,
- &hauppauge_hvr1265k4_config,
- &i2c_bus->i2c_adap);
- if (fe0->dvb.frontend == NULL)
- break;
- /* attach tuner */
- memset(&si2157_config, 0, sizeof(si2157_config));
- si2157_config.fe = fe0->dvb.frontend;
- si2157_config.if_port = 1;
- si2157_config.inversion = 1;
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "si2157", I2C_NAME_SIZE);
- info.addr = 0x60;
- info.platform_data = &si2157_config;
- request_module("%s", info.type);
- client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
- if (!client_tuner || !client_tuner->dev.driver)
- goto frontend_detach;
- if (!try_module_get(client_tuner->dev.driver->owner)) {
- i2c_unregister_device(client_tuner);
- client_tuner = NULL;
- goto frontend_detach;
- }
- port->i2c_client_tuner = client_tuner;
- break;
- }
- break;
- default:
- pr_info("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
- dev->name);
- break;
- }
- if ((NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend)) {
- pr_err("%s: frontend initialization failed\n",
- dev->name);
- goto frontend_detach;
- }
- /* define general-purpose callback pointer */
- fe0->dvb.frontend->callback = cx23885_tuner_callback;
- if (fe1)
- fe1->dvb.frontend->callback = cx23885_tuner_callback;
- #if 0
- /* Ensure all frontends negotiate bus access */
- fe0->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
- if (fe1)
- fe1->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
- #endif
- /* Put the tuner in standby to keep it quiet */
- call_all(dev, tuner, standby);
- if (fe0->dvb.frontend->ops.analog_ops.standby)
- fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
- /* register everything */
- ret = vb2_dvb_register_bus(&port->frontends, THIS_MODULE, port,
- &dev->pci->dev, NULL,
- adapter_nr, mfe_shared);
- if (ret)
- goto frontend_detach;
- ret = dvb_register_ci_mac(port);
- if (ret)
- goto frontend_detach;
- return 0;
- frontend_detach:
- /* remove I2C client for SEC */
- client_sec = port->i2c_client_sec;
- if (client_sec) {
- module_put(client_sec->dev.driver->owner);
- i2c_unregister_device(client_sec);
- port->i2c_client_sec = NULL;
- }
- /* remove I2C client for tuner */
- client_tuner = port->i2c_client_tuner;
- if (client_tuner) {
- module_put(client_tuner->dev.driver->owner);
- i2c_unregister_device(client_tuner);
- port->i2c_client_tuner = NULL;
- }
- /* remove I2C client for demodulator */
- client_demod = port->i2c_client_demod;
- if (client_demod) {
- module_put(client_demod->dev.driver->owner);
- i2c_unregister_device(client_demod);
- port->i2c_client_demod = NULL;
- }
- port->gate_ctrl = NULL;
- vb2_dvb_dealloc_frontends(&port->frontends);
- return -EINVAL;
- }
- int cx23885_dvb_register(struct cx23885_tsport *port)
- {
- struct vb2_dvb_frontend *fe0;
- struct cx23885_dev *dev = port->dev;
- int err, i;
- /* Here we need to allocate the correct number of frontends,
- * as reflected in the cards struct. The reality is that currently
- * no cx23885 boards support this - yet. But, if we don't modify this
- * code then the second frontend would never be allocated (later)
- * and fail with error before the attach in dvb_register().
- * Without these changes we risk an OOPS later. The changes here
- * are for safety, and should provide a good foundation for the
- * future addition of any multi-frontend cx23885 based boards.
- */
- pr_info("%s() allocating %d frontend(s)\n", __func__,
- port->num_frontends);
- for (i = 1; i <= port->num_frontends; i++) {
- struct vb2_queue *q;
- if (vb2_dvb_alloc_frontend(
- &port->frontends, i) == NULL) {
- pr_err("%s() failed to alloc\n", __func__);
- return -ENOMEM;
- }
- fe0 = vb2_dvb_get_frontend(&port->frontends, i);
- if (!fe0)
- return -EINVAL;
- dprintk(1, "%s\n", __func__);
- dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
- dev->board,
- dev->name,
- dev->pci_bus,
- dev->pci_slot);
- err = -ENODEV;
- /* dvb stuff */
- /* We have to init the queue for each frontend on a port. */
- pr_info("%s: cx23885 based dvb card\n", dev->name);
- q = &fe0->dvb.dvbq;
- q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ;
- q->gfp_flags = GFP_DMA32;
- q->min_buffers_needed = 2;
- q->drv_priv = port;
- q->buf_struct_size = sizeof(struct cx23885_buffer);
- q->ops = &dvb_qops;
- q->mem_ops = &vb2_dma_sg_memops;
- q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
- q->lock = &dev->lock;
- q->dev = &dev->pci->dev;
- err = vb2_queue_init(q);
- if (err < 0)
- return err;
- }
- err = dvb_register(port);
- if (err != 0)
- pr_err("%s() dvb_register failed err = %d\n",
- __func__, err);
- return err;
- }
- int cx23885_dvb_unregister(struct cx23885_tsport *port)
- {
- struct vb2_dvb_frontend *fe0;
- struct i2c_client *client;
- fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
- if (fe0 && fe0->dvb.frontend)
- vb2_dvb_unregister_bus(&port->frontends);
- /* remove I2C client for CI */
- client = port->i2c_client_ci;
- if (client) {
- module_put(client->dev.driver->owner);
- i2c_unregister_device(client);
- }
- /* remove I2C client for SEC */
- client = port->i2c_client_sec;
- if (client) {
- module_put(client->dev.driver->owner);
- i2c_unregister_device(client);
- }
- /* remove I2C client for tuner */
- client = port->i2c_client_tuner;
- if (client) {
- module_put(client->dev.driver->owner);
- i2c_unregister_device(client);
- }
- /* remove I2C client for demodulator */
- client = port->i2c_client_demod;
- if (client) {
- module_put(client->dev.driver->owner);
- i2c_unregister_device(client);
- }
- switch (port->dev->board) {
- case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
- netup_ci_exit(port);
- break;
- case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
- altera_ci_release(port->dev, port->nr);
- break;
- }
- port->gate_ctrl = NULL;
- return 0;
- }
|