budget-ci.c 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563
  1. /*
  2. * budget-ci.c: driver for the SAA7146 based Budget DVB cards
  3. *
  4. * Compiled from various sources by Michael Hunold <michael@mihu.de>
  5. *
  6. * msp430 IR support contributed by Jack Thomasson <jkt@Helius.COM>
  7. * partially based on the Siemens DVB driver by Ralph+Marcus Metzler
  8. *
  9. * CI interface support (c) 2004 Andrew de Quincey <adq_dvb@lidskialf.net>
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License
  13. * as published by the Free Software Foundation; either version 2
  14. * of the License, or (at your option) any later version.
  15. *
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  26. * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
  27. *
  28. *
  29. * the project's page is at http://www.linuxtv.org/dvb/
  30. */
  31. #include <linux/module.h>
  32. #include <linux/errno.h>
  33. #include <linux/slab.h>
  34. #include <linux/interrupt.h>
  35. #include <linux/input.h>
  36. #include <linux/spinlock.h>
  37. #include <media/ir-core.h>
  38. #include "budget.h"
  39. #include "dvb_ca_en50221.h"
  40. #include "stv0299.h"
  41. #include "stv0297.h"
  42. #include "tda1004x.h"
  43. #include "stb0899_drv.h"
  44. #include "stb0899_reg.h"
  45. #include "stb0899_cfg.h"
  46. #include "stb6100.h"
  47. #include "stb6100_cfg.h"
  48. #include "lnbp21.h"
  49. #include "bsbe1.h"
  50. #include "bsru6.h"
  51. #include "tda1002x.h"
  52. #include "tda827x.h"
  53. #define MODULE_NAME "budget_ci"
  54. /*
  55. * Regarding DEBIADDR_IR:
  56. * Some CI modules hang if random addresses are read.
  57. * Using address 0x4000 for the IR read means that we
  58. * use the same address as for CI version, which should
  59. * be a safe default.
  60. */
  61. #define DEBIADDR_IR 0x4000
  62. #define DEBIADDR_CICONTROL 0x0000
  63. #define DEBIADDR_CIVERSION 0x4000
  64. #define DEBIADDR_IO 0x1000
  65. #define DEBIADDR_ATTR 0x3000
  66. #define CICONTROL_RESET 0x01
  67. #define CICONTROL_ENABLETS 0x02
  68. #define CICONTROL_CAMDETECT 0x08
  69. #define DEBICICTL 0x00420000
  70. #define DEBICICAM 0x02420000
  71. #define SLOTSTATUS_NONE 1
  72. #define SLOTSTATUS_PRESENT 2
  73. #define SLOTSTATUS_RESET 4
  74. #define SLOTSTATUS_READY 8
  75. #define SLOTSTATUS_OCCUPIED (SLOTSTATUS_PRESENT|SLOTSTATUS_RESET|SLOTSTATUS_READY)
  76. /* RC5 device wildcard */
  77. #define IR_DEVICE_ANY 255
  78. static int rc5_device = -1;
  79. module_param(rc5_device, int, 0644);
  80. MODULE_PARM_DESC(rc5_device, "only IR commands to given RC5 device (device = 0 - 31, any device = 255, default: autodetect)");
  81. static int ir_debug;
  82. module_param(ir_debug, int, 0644);
  83. MODULE_PARM_DESC(ir_debug, "enable debugging information for IR decoding");
  84. DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
  85. struct budget_ci_ir {
  86. struct input_dev *dev;
  87. struct tasklet_struct msp430_irq_tasklet;
  88. char name[72]; /* 40 + 32 for (struct saa7146_dev).name */
  89. char phys[32];
  90. int rc5_device;
  91. u32 ir_key;
  92. bool have_command;
  93. };
  94. struct budget_ci {
  95. struct budget budget;
  96. struct tasklet_struct ciintf_irq_tasklet;
  97. int slot_status;
  98. int ci_irq;
  99. struct dvb_ca_en50221 ca;
  100. struct budget_ci_ir ir;
  101. u8 tuner_pll_address; /* used for philips_tdm1316l configs */
  102. };
  103. static void msp430_ir_interrupt(unsigned long data)
  104. {
  105. struct budget_ci *budget_ci = (struct budget_ci *) data;
  106. struct input_dev *dev = budget_ci->ir.dev;
  107. u32 command = ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8;
  108. /*
  109. * The msp430 chip can generate two different bytes, command and device
  110. *
  111. * type1: X1CCCCCC, C = command bits (0 - 63)
  112. * type2: X0TDDDDD, D = device bits (0 - 31), T = RC5 toggle bit
  113. *
  114. * Each signal from the remote control can generate one or more command
  115. * bytes and one or more device bytes. For the repeated bytes, the
  116. * highest bit (X) is set. The first command byte is always generated
  117. * before the first device byte. Other than that, no specific order
  118. * seems to apply. To make life interesting, bytes can also be lost.
  119. *
  120. * Only when we have a command and device byte, a keypress is
  121. * generated.
  122. */
  123. if (ir_debug)
  124. printk("budget_ci: received byte 0x%02x\n", command);
  125. /* Remove repeat bit, we use every command */
  126. command = command & 0x7f;
  127. /* Is this a RC5 command byte? */
  128. if (command & 0x40) {
  129. budget_ci->ir.have_command = true;
  130. budget_ci->ir.ir_key = command & 0x3f;
  131. return;
  132. }
  133. /* It's a RC5 device byte */
  134. if (!budget_ci->ir.have_command)
  135. return;
  136. budget_ci->ir.have_command = false;
  137. /* FIXME: We should generate complete scancodes with device info */
  138. if (budget_ci->ir.rc5_device != IR_DEVICE_ANY &&
  139. budget_ci->ir.rc5_device != (command & 0x1f))
  140. return;
  141. ir_keydown(dev, budget_ci->ir.ir_key, (command & 0x20) ? 1 : 0);
  142. }
  143. static int msp430_ir_init(struct budget_ci *budget_ci)
  144. {
  145. struct saa7146_dev *saa = budget_ci->budget.dev;
  146. struct input_dev *input_dev = budget_ci->ir.dev;
  147. int error;
  148. char *ir_codes = NULL;
  149. budget_ci->ir.dev = input_dev = input_allocate_device();
  150. if (!input_dev) {
  151. printk(KERN_ERR "budget_ci: IR interface initialisation failed\n");
  152. return -ENOMEM;
  153. }
  154. snprintf(budget_ci->ir.name, sizeof(budget_ci->ir.name),
  155. "Budget-CI dvb ir receiver %s", saa->name);
  156. snprintf(budget_ci->ir.phys, sizeof(budget_ci->ir.phys),
  157. "pci-%s/ir0", pci_name(saa->pci));
  158. input_dev->name = budget_ci->ir.name;
  159. input_dev->phys = budget_ci->ir.phys;
  160. input_dev->id.bustype = BUS_PCI;
  161. input_dev->id.version = 1;
  162. if (saa->pci->subsystem_vendor) {
  163. input_dev->id.vendor = saa->pci->subsystem_vendor;
  164. input_dev->id.product = saa->pci->subsystem_device;
  165. } else {
  166. input_dev->id.vendor = saa->pci->vendor;
  167. input_dev->id.product = saa->pci->device;
  168. }
  169. input_dev->dev.parent = &saa->pci->dev;
  170. if (rc5_device < 0)
  171. budget_ci->ir.rc5_device = IR_DEVICE_ANY;
  172. else
  173. budget_ci->ir.rc5_device = rc5_device;
  174. /* Select keymap and address */
  175. switch (budget_ci->budget.dev->pci->subsystem_device) {
  176. case 0x100c:
  177. case 0x100f:
  178. case 0x1011:
  179. case 0x1012:
  180. /* The hauppauge keymap is a superset of these remotes */
  181. ir_codes = RC_MAP_HAUPPAUGE_NEW;
  182. if (rc5_device < 0)
  183. budget_ci->ir.rc5_device = 0x1f;
  184. break;
  185. case 0x1010:
  186. case 0x1017:
  187. case 0x1019:
  188. case 0x101a:
  189. /* for the Technotrend 1500 bundled remote */
  190. ir_codes = RC_MAP_TT_1500;
  191. break;
  192. default:
  193. /* unknown remote */
  194. ir_codes = RC_MAP_BUDGET_CI_OLD;
  195. break;
  196. }
  197. error = ir_input_register(input_dev, ir_codes, NULL, MODULE_NAME);
  198. if (error) {
  199. printk(KERN_ERR "budget_ci: could not init driver for IR device (code %d)\n", error);
  200. return error;
  201. }
  202. /* note: these must be after input_register_device */
  203. input_dev->rep[REP_DELAY] = 400;
  204. input_dev->rep[REP_PERIOD] = 250;
  205. tasklet_init(&budget_ci->ir.msp430_irq_tasklet, msp430_ir_interrupt,
  206. (unsigned long) budget_ci);
  207. SAA7146_IER_ENABLE(saa, MASK_06);
  208. saa7146_setgpio(saa, 3, SAA7146_GPIO_IRQHI);
  209. return 0;
  210. }
  211. static void msp430_ir_deinit(struct budget_ci *budget_ci)
  212. {
  213. struct saa7146_dev *saa = budget_ci->budget.dev;
  214. struct input_dev *dev = budget_ci->ir.dev;
  215. SAA7146_IER_DISABLE(saa, MASK_06);
  216. saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
  217. tasklet_kill(&budget_ci->ir.msp430_irq_tasklet);
  218. ir_input_unregister(dev);
  219. }
  220. static int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address)
  221. {
  222. struct budget_ci *budget_ci = (struct budget_ci *) ca->data;
  223. if (slot != 0)
  224. return -EINVAL;
  225. return ttpci_budget_debiread(&budget_ci->budget, DEBICICAM,
  226. DEBIADDR_ATTR | (address & 0xfff), 1, 1, 0);
  227. }
  228. static int ciintf_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address, u8 value)
  229. {
  230. struct budget_ci *budget_ci = (struct budget_ci *) ca->data;
  231. if (slot != 0)
  232. return -EINVAL;
  233. return ttpci_budget_debiwrite(&budget_ci->budget, DEBICICAM,
  234. DEBIADDR_ATTR | (address & 0xfff), 1, value, 1, 0);
  235. }
  236. static int ciintf_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address)
  237. {
  238. struct budget_ci *budget_ci = (struct budget_ci *) ca->data;
  239. if (slot != 0)
  240. return -EINVAL;
  241. return ttpci_budget_debiread(&budget_ci->budget, DEBICICAM,
  242. DEBIADDR_IO | (address & 3), 1, 1, 0);
  243. }
  244. static int ciintf_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address, u8 value)
  245. {
  246. struct budget_ci *budget_ci = (struct budget_ci *) ca->data;
  247. if (slot != 0)
  248. return -EINVAL;
  249. return ttpci_budget_debiwrite(&budget_ci->budget, DEBICICAM,
  250. DEBIADDR_IO | (address & 3), 1, value, 1, 0);
  251. }
  252. static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
  253. {
  254. struct budget_ci *budget_ci = (struct budget_ci *) ca->data;
  255. struct saa7146_dev *saa = budget_ci->budget.dev;
  256. if (slot != 0)
  257. return -EINVAL;
  258. if (budget_ci->ci_irq) {
  259. // trigger on RISING edge during reset so we know when READY is re-asserted
  260. saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI);
  261. }
  262. budget_ci->slot_status = SLOTSTATUS_RESET;
  263. ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0);
  264. msleep(1);
  265. ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
  266. CICONTROL_RESET, 1, 0);
  267. saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTHI);
  268. ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
  269. return 0;
  270. }
  271. static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot)
  272. {
  273. struct budget_ci *budget_ci = (struct budget_ci *) ca->data;
  274. struct saa7146_dev *saa = budget_ci->budget.dev;
  275. if (slot != 0)
  276. return -EINVAL;
  277. saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTHI);
  278. ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
  279. return 0;
  280. }
  281. static int ciintf_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot)
  282. {
  283. struct budget_ci *budget_ci = (struct budget_ci *) ca->data;
  284. struct saa7146_dev *saa = budget_ci->budget.dev;
  285. int tmp;
  286. if (slot != 0)
  287. return -EINVAL;
  288. saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTLO);
  289. tmp = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0);
  290. ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
  291. tmp | CICONTROL_ENABLETS, 1, 0);
  292. ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTA);
  293. return 0;
  294. }
  295. static void ciintf_interrupt(unsigned long data)
  296. {
  297. struct budget_ci *budget_ci = (struct budget_ci *) data;
  298. struct saa7146_dev *saa = budget_ci->budget.dev;
  299. unsigned int flags;
  300. // ensure we don't get spurious IRQs during initialisation
  301. if (!budget_ci->budget.ci_present)
  302. return;
  303. // read the CAM status
  304. flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0);
  305. if (flags & CICONTROL_CAMDETECT) {
  306. // GPIO should be set to trigger on falling edge if a CAM is present
  307. saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQLO);
  308. if (budget_ci->slot_status & SLOTSTATUS_NONE) {
  309. // CAM insertion IRQ
  310. budget_ci->slot_status = SLOTSTATUS_PRESENT;
  311. dvb_ca_en50221_camchange_irq(&budget_ci->ca, 0,
  312. DVB_CA_EN50221_CAMCHANGE_INSERTED);
  313. } else if (budget_ci->slot_status & SLOTSTATUS_RESET) {
  314. // CAM ready (reset completed)
  315. budget_ci->slot_status = SLOTSTATUS_READY;
  316. dvb_ca_en50221_camready_irq(&budget_ci->ca, 0);
  317. } else if (budget_ci->slot_status & SLOTSTATUS_READY) {
  318. // FR/DA IRQ
  319. dvb_ca_en50221_frda_irq(&budget_ci->ca, 0);
  320. }
  321. } else {
  322. // trigger on rising edge if a CAM is not present - when a CAM is inserted, we
  323. // only want to get the IRQ when it sets READY. If we trigger on the falling edge,
  324. // the CAM might not actually be ready yet.
  325. saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI);
  326. // generate a CAM removal IRQ if we haven't already
  327. if (budget_ci->slot_status & SLOTSTATUS_OCCUPIED) {
  328. // CAM removal IRQ
  329. budget_ci->slot_status = SLOTSTATUS_NONE;
  330. dvb_ca_en50221_camchange_irq(&budget_ci->ca, 0,
  331. DVB_CA_EN50221_CAMCHANGE_REMOVED);
  332. }
  333. }
  334. }
  335. static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open)
  336. {
  337. struct budget_ci *budget_ci = (struct budget_ci *) ca->data;
  338. unsigned int flags;
  339. // ensure we don't get spurious IRQs during initialisation
  340. if (!budget_ci->budget.ci_present)
  341. return -EINVAL;
  342. // read the CAM status
  343. flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0);
  344. if (flags & CICONTROL_CAMDETECT) {
  345. // mark it as present if it wasn't before
  346. if (budget_ci->slot_status & SLOTSTATUS_NONE) {
  347. budget_ci->slot_status = SLOTSTATUS_PRESENT;
  348. }
  349. // during a RESET, we check if we can read from IO memory to see when CAM is ready
  350. if (budget_ci->slot_status & SLOTSTATUS_RESET) {
  351. if (ciintf_read_attribute_mem(ca, slot, 0) == 0x1d) {
  352. budget_ci->slot_status = SLOTSTATUS_READY;
  353. }
  354. }
  355. } else {
  356. budget_ci->slot_status = SLOTSTATUS_NONE;
  357. }
  358. if (budget_ci->slot_status != SLOTSTATUS_NONE) {
  359. if (budget_ci->slot_status & SLOTSTATUS_READY) {
  360. return DVB_CA_EN50221_POLL_CAM_PRESENT | DVB_CA_EN50221_POLL_CAM_READY;
  361. }
  362. return DVB_CA_EN50221_POLL_CAM_PRESENT;
  363. }
  364. return 0;
  365. }
  366. static int ciintf_init(struct budget_ci *budget_ci)
  367. {
  368. struct saa7146_dev *saa = budget_ci->budget.dev;
  369. int flags;
  370. int result;
  371. int ci_version;
  372. int ca_flags;
  373. memset(&budget_ci->ca, 0, sizeof(struct dvb_ca_en50221));
  374. // enable DEBI pins
  375. saa7146_write(saa, MC1, MASK_27 | MASK_11);
  376. // test if it is there
  377. ci_version = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CIVERSION, 1, 1, 0);
  378. if ((ci_version & 0xa0) != 0xa0) {
  379. result = -ENODEV;
  380. goto error;
  381. }
  382. // determine whether a CAM is present or not
  383. flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0);
  384. budget_ci->slot_status = SLOTSTATUS_NONE;
  385. if (flags & CICONTROL_CAMDETECT)
  386. budget_ci->slot_status = SLOTSTATUS_PRESENT;
  387. // version 0xa2 of the CI firmware doesn't generate interrupts
  388. if (ci_version == 0xa2) {
  389. ca_flags = 0;
  390. budget_ci->ci_irq = 0;
  391. } else {
  392. ca_flags = DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE |
  393. DVB_CA_EN50221_FLAG_IRQ_FR |
  394. DVB_CA_EN50221_FLAG_IRQ_DA;
  395. budget_ci->ci_irq = 1;
  396. }
  397. // register CI interface
  398. budget_ci->ca.owner = THIS_MODULE;
  399. budget_ci->ca.read_attribute_mem = ciintf_read_attribute_mem;
  400. budget_ci->ca.write_attribute_mem = ciintf_write_attribute_mem;
  401. budget_ci->ca.read_cam_control = ciintf_read_cam_control;
  402. budget_ci->ca.write_cam_control = ciintf_write_cam_control;
  403. budget_ci->ca.slot_reset = ciintf_slot_reset;
  404. budget_ci->ca.slot_shutdown = ciintf_slot_shutdown;
  405. budget_ci->ca.slot_ts_enable = ciintf_slot_ts_enable;
  406. budget_ci->ca.poll_slot_status = ciintf_poll_slot_status;
  407. budget_ci->ca.data = budget_ci;
  408. if ((result = dvb_ca_en50221_init(&budget_ci->budget.dvb_adapter,
  409. &budget_ci->ca,
  410. ca_flags, 1)) != 0) {
  411. printk("budget_ci: CI interface detected, but initialisation failed.\n");
  412. goto error;
  413. }
  414. // Setup CI slot IRQ
  415. if (budget_ci->ci_irq) {
  416. tasklet_init(&budget_ci->ciintf_irq_tasklet, ciintf_interrupt, (unsigned long) budget_ci);
  417. if (budget_ci->slot_status != SLOTSTATUS_NONE) {
  418. saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQLO);
  419. } else {
  420. saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI);
  421. }
  422. SAA7146_IER_ENABLE(saa, MASK_03);
  423. }
  424. // enable interface
  425. ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
  426. CICONTROL_RESET, 1, 0);
  427. // success!
  428. printk("budget_ci: CI interface initialised\n");
  429. budget_ci->budget.ci_present = 1;
  430. // forge a fake CI IRQ so the CAM state is setup correctly
  431. if (budget_ci->ci_irq) {
  432. flags = DVB_CA_EN50221_CAMCHANGE_REMOVED;
  433. if (budget_ci->slot_status != SLOTSTATUS_NONE)
  434. flags = DVB_CA_EN50221_CAMCHANGE_INSERTED;
  435. dvb_ca_en50221_camchange_irq(&budget_ci->ca, 0, flags);
  436. }
  437. return 0;
  438. error:
  439. saa7146_write(saa, MC1, MASK_27);
  440. return result;
  441. }
  442. static void ciintf_deinit(struct budget_ci *budget_ci)
  443. {
  444. struct saa7146_dev *saa = budget_ci->budget.dev;
  445. // disable CI interrupts
  446. if (budget_ci->ci_irq) {
  447. SAA7146_IER_DISABLE(saa, MASK_03);
  448. saa7146_setgpio(saa, 0, SAA7146_GPIO_INPUT);
  449. tasklet_kill(&budget_ci->ciintf_irq_tasklet);
  450. }
  451. // reset interface
  452. ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0);
  453. msleep(1);
  454. ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
  455. CICONTROL_RESET, 1, 0);
  456. // disable TS data stream to CI interface
  457. saa7146_setgpio(saa, 1, SAA7146_GPIO_INPUT);
  458. // release the CA device
  459. dvb_ca_en50221_release(&budget_ci->ca);
  460. // disable DEBI pins
  461. saa7146_write(saa, MC1, MASK_27);
  462. }
  463. static void budget_ci_irq(struct saa7146_dev *dev, u32 * isr)
  464. {
  465. struct budget_ci *budget_ci = (struct budget_ci *) dev->ext_priv;
  466. dprintk(8, "dev: %p, budget_ci: %p\n", dev, budget_ci);
  467. if (*isr & MASK_06)
  468. tasklet_schedule(&budget_ci->ir.msp430_irq_tasklet);
  469. if (*isr & MASK_10)
  470. ttpci_budget_irq10_handler(dev, isr);
  471. if ((*isr & MASK_03) && (budget_ci->budget.ci_present) && (budget_ci->ci_irq))
  472. tasklet_schedule(&budget_ci->ciintf_irq_tasklet);
  473. }
  474. static u8 philips_su1278_tt_inittab[] = {
  475. 0x01, 0x0f,
  476. 0x02, 0x30,
  477. 0x03, 0x00,
  478. 0x04, 0x5b,
  479. 0x05, 0x85,
  480. 0x06, 0x02,
  481. 0x07, 0x00,
  482. 0x08, 0x02,
  483. 0x09, 0x00,
  484. 0x0C, 0x01,
  485. 0x0D, 0x81,
  486. 0x0E, 0x44,
  487. 0x0f, 0x14,
  488. 0x10, 0x3c,
  489. 0x11, 0x84,
  490. 0x12, 0xda,
  491. 0x13, 0x97,
  492. 0x14, 0x95,
  493. 0x15, 0xc9,
  494. 0x16, 0x19,
  495. 0x17, 0x8c,
  496. 0x18, 0x59,
  497. 0x19, 0xf8,
  498. 0x1a, 0xfe,
  499. 0x1c, 0x7f,
  500. 0x1d, 0x00,
  501. 0x1e, 0x00,
  502. 0x1f, 0x50,
  503. 0x20, 0x00,
  504. 0x21, 0x00,
  505. 0x22, 0x00,
  506. 0x23, 0x00,
  507. 0x28, 0x00,
  508. 0x29, 0x28,
  509. 0x2a, 0x14,
  510. 0x2b, 0x0f,
  511. 0x2c, 0x09,
  512. 0x2d, 0x09,
  513. 0x31, 0x1f,
  514. 0x32, 0x19,
  515. 0x33, 0xfc,
  516. 0x34, 0x93,
  517. 0xff, 0xff
  518. };
  519. static int philips_su1278_tt_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio)
  520. {
  521. stv0299_writereg(fe, 0x0e, 0x44);
  522. if (srate >= 10000000) {
  523. stv0299_writereg(fe, 0x13, 0x97);
  524. stv0299_writereg(fe, 0x14, 0x95);
  525. stv0299_writereg(fe, 0x15, 0xc9);
  526. stv0299_writereg(fe, 0x17, 0x8c);
  527. stv0299_writereg(fe, 0x1a, 0xfe);
  528. stv0299_writereg(fe, 0x1c, 0x7f);
  529. stv0299_writereg(fe, 0x2d, 0x09);
  530. } else {
  531. stv0299_writereg(fe, 0x13, 0x99);
  532. stv0299_writereg(fe, 0x14, 0x8d);
  533. stv0299_writereg(fe, 0x15, 0xce);
  534. stv0299_writereg(fe, 0x17, 0x43);
  535. stv0299_writereg(fe, 0x1a, 0x1d);
  536. stv0299_writereg(fe, 0x1c, 0x12);
  537. stv0299_writereg(fe, 0x2d, 0x05);
  538. }
  539. stv0299_writereg(fe, 0x0e, 0x23);
  540. stv0299_writereg(fe, 0x0f, 0x94);
  541. stv0299_writereg(fe, 0x10, 0x39);
  542. stv0299_writereg(fe, 0x15, 0xc9);
  543. stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
  544. stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
  545. stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
  546. return 0;
  547. }
  548. static int philips_su1278_tt_tuner_set_params(struct dvb_frontend *fe,
  549. struct dvb_frontend_parameters *params)
  550. {
  551. struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
  552. u32 div;
  553. u8 buf[4];
  554. struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) };
  555. if ((params->frequency < 950000) || (params->frequency > 2150000))
  556. return -EINVAL;
  557. div = (params->frequency + (500 - 1)) / 500; // round correctly
  558. buf[0] = (div >> 8) & 0x7f;
  559. buf[1] = div & 0xff;
  560. buf[2] = 0x80 | ((div & 0x18000) >> 10) | 2;
  561. buf[3] = 0x20;
  562. if (params->u.qpsk.symbol_rate < 4000000)
  563. buf[3] |= 1;
  564. if (params->frequency < 1250000)
  565. buf[3] |= 0;
  566. else if (params->frequency < 1550000)
  567. buf[3] |= 0x40;
  568. else if (params->frequency < 2050000)
  569. buf[3] |= 0x80;
  570. else if (params->frequency < 2150000)
  571. buf[3] |= 0xC0;
  572. if (fe->ops.i2c_gate_ctrl)
  573. fe->ops.i2c_gate_ctrl(fe, 1);
  574. if (i2c_transfer(&budget_ci->budget.i2c_adap, &msg, 1) != 1)
  575. return -EIO;
  576. return 0;
  577. }
  578. static struct stv0299_config philips_su1278_tt_config = {
  579. .demod_address = 0x68,
  580. .inittab = philips_su1278_tt_inittab,
  581. .mclk = 64000000UL,
  582. .invert = 0,
  583. .skip_reinit = 1,
  584. .lock_output = STV0299_LOCKOUTPUT_1,
  585. .volt13_op0_op1 = STV0299_VOLT13_OP1,
  586. .min_delay_ms = 50,
  587. .set_symbol_rate = philips_su1278_tt_set_symbol_rate,
  588. };
  589. static int philips_tdm1316l_tuner_init(struct dvb_frontend *fe)
  590. {
  591. struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
  592. static u8 td1316_init[] = { 0x0b, 0xf5, 0x85, 0xab };
  593. static u8 disable_mc44BC374c[] = { 0x1d, 0x74, 0xa0, 0x68 };
  594. struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address,.flags = 0,.buf = td1316_init,.len =
  595. sizeof(td1316_init) };
  596. // setup PLL configuration
  597. if (fe->ops.i2c_gate_ctrl)
  598. fe->ops.i2c_gate_ctrl(fe, 1);
  599. if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1)
  600. return -EIO;
  601. msleep(1);
  602. // disable the mc44BC374c (do not check for errors)
  603. tuner_msg.addr = 0x65;
  604. tuner_msg.buf = disable_mc44BC374c;
  605. tuner_msg.len = sizeof(disable_mc44BC374c);
  606. if (fe->ops.i2c_gate_ctrl)
  607. fe->ops.i2c_gate_ctrl(fe, 1);
  608. if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1) {
  609. if (fe->ops.i2c_gate_ctrl)
  610. fe->ops.i2c_gate_ctrl(fe, 1);
  611. i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1);
  612. }
  613. return 0;
  614. }
  615. static int philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  616. {
  617. struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
  618. u8 tuner_buf[4];
  619. struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address,.flags = 0,.buf = tuner_buf,.len = sizeof(tuner_buf) };
  620. int tuner_frequency = 0;
  621. u8 band, cp, filter;
  622. // determine charge pump
  623. tuner_frequency = params->frequency + 36130000;
  624. if (tuner_frequency < 87000000)
  625. return -EINVAL;
  626. else if (tuner_frequency < 130000000)
  627. cp = 3;
  628. else if (tuner_frequency < 160000000)
  629. cp = 5;
  630. else if (tuner_frequency < 200000000)
  631. cp = 6;
  632. else if (tuner_frequency < 290000000)
  633. cp = 3;
  634. else if (tuner_frequency < 420000000)
  635. cp = 5;
  636. else if (tuner_frequency < 480000000)
  637. cp = 6;
  638. else if (tuner_frequency < 620000000)
  639. cp = 3;
  640. else if (tuner_frequency < 830000000)
  641. cp = 5;
  642. else if (tuner_frequency < 895000000)
  643. cp = 7;
  644. else
  645. return -EINVAL;
  646. // determine band
  647. if (params->frequency < 49000000)
  648. return -EINVAL;
  649. else if (params->frequency < 159000000)
  650. band = 1;
  651. else if (params->frequency < 444000000)
  652. band = 2;
  653. else if (params->frequency < 861000000)
  654. band = 4;
  655. else
  656. return -EINVAL;
  657. // setup PLL filter and TDA9889
  658. switch (params->u.ofdm.bandwidth) {
  659. case BANDWIDTH_6_MHZ:
  660. tda1004x_writereg(fe, 0x0C, 0x14);
  661. filter = 0;
  662. break;
  663. case BANDWIDTH_7_MHZ:
  664. tda1004x_writereg(fe, 0x0C, 0x80);
  665. filter = 0;
  666. break;
  667. case BANDWIDTH_8_MHZ:
  668. tda1004x_writereg(fe, 0x0C, 0x14);
  669. filter = 1;
  670. break;
  671. default:
  672. return -EINVAL;
  673. }
  674. // calculate divisor
  675. // ((36130000+((1000000/6)/2)) + Finput)/(1000000/6)
  676. tuner_frequency = (((params->frequency / 1000) * 6) + 217280) / 1000;
  677. // setup tuner buffer
  678. tuner_buf[0] = tuner_frequency >> 8;
  679. tuner_buf[1] = tuner_frequency & 0xff;
  680. tuner_buf[2] = 0xca;
  681. tuner_buf[3] = (cp << 5) | (filter << 3) | band;
  682. if (fe->ops.i2c_gate_ctrl)
  683. fe->ops.i2c_gate_ctrl(fe, 1);
  684. if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1)
  685. return -EIO;
  686. msleep(1);
  687. return 0;
  688. }
  689. static int philips_tdm1316l_request_firmware(struct dvb_frontend *fe,
  690. const struct firmware **fw, char *name)
  691. {
  692. struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
  693. return request_firmware(fw, name, &budget_ci->budget.dev->pci->dev);
  694. }
  695. static struct tda1004x_config philips_tdm1316l_config = {
  696. .demod_address = 0x8,
  697. .invert = 0,
  698. .invert_oclk = 0,
  699. .xtal_freq = TDA10046_XTAL_4M,
  700. .agc_config = TDA10046_AGC_DEFAULT,
  701. .if_freq = TDA10046_FREQ_3617,
  702. .request_firmware = philips_tdm1316l_request_firmware,
  703. };
  704. static struct tda1004x_config philips_tdm1316l_config_invert = {
  705. .demod_address = 0x8,
  706. .invert = 1,
  707. .invert_oclk = 0,
  708. .xtal_freq = TDA10046_XTAL_4M,
  709. .agc_config = TDA10046_AGC_DEFAULT,
  710. .if_freq = TDA10046_FREQ_3617,
  711. .request_firmware = philips_tdm1316l_request_firmware,
  712. };
  713. static int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  714. {
  715. struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
  716. u8 tuner_buf[5];
  717. struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address,
  718. .flags = 0,
  719. .buf = tuner_buf,
  720. .len = sizeof(tuner_buf) };
  721. int tuner_frequency = 0;
  722. u8 band, cp, filter;
  723. // determine charge pump
  724. tuner_frequency = params->frequency + 36125000;
  725. if (tuner_frequency < 87000000)
  726. return -EINVAL;
  727. else if (tuner_frequency < 130000000) {
  728. cp = 3;
  729. band = 1;
  730. } else if (tuner_frequency < 160000000) {
  731. cp = 5;
  732. band = 1;
  733. } else if (tuner_frequency < 200000000) {
  734. cp = 6;
  735. band = 1;
  736. } else if (tuner_frequency < 290000000) {
  737. cp = 3;
  738. band = 2;
  739. } else if (tuner_frequency < 420000000) {
  740. cp = 5;
  741. band = 2;
  742. } else if (tuner_frequency < 480000000) {
  743. cp = 6;
  744. band = 2;
  745. } else if (tuner_frequency < 620000000) {
  746. cp = 3;
  747. band = 4;
  748. } else if (tuner_frequency < 830000000) {
  749. cp = 5;
  750. band = 4;
  751. } else if (tuner_frequency < 895000000) {
  752. cp = 7;
  753. band = 4;
  754. } else
  755. return -EINVAL;
  756. // assume PLL filter should always be 8MHz for the moment.
  757. filter = 1;
  758. // calculate divisor
  759. tuner_frequency = (params->frequency + 36125000 + (62500/2)) / 62500;
  760. // setup tuner buffer
  761. tuner_buf[0] = tuner_frequency >> 8;
  762. tuner_buf[1] = tuner_frequency & 0xff;
  763. tuner_buf[2] = 0xc8;
  764. tuner_buf[3] = (cp << 5) | (filter << 3) | band;
  765. tuner_buf[4] = 0x80;
  766. if (fe->ops.i2c_gate_ctrl)
  767. fe->ops.i2c_gate_ctrl(fe, 1);
  768. if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1)
  769. return -EIO;
  770. msleep(50);
  771. if (fe->ops.i2c_gate_ctrl)
  772. fe->ops.i2c_gate_ctrl(fe, 1);
  773. if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1)
  774. return -EIO;
  775. msleep(1);
  776. return 0;
  777. }
  778. static u8 dvbc_philips_tdm1316l_inittab[] = {
  779. 0x80, 0x01,
  780. 0x80, 0x00,
  781. 0x81, 0x01,
  782. 0x81, 0x00,
  783. 0x00, 0x09,
  784. 0x01, 0x69,
  785. 0x03, 0x00,
  786. 0x04, 0x00,
  787. 0x07, 0x00,
  788. 0x08, 0x00,
  789. 0x20, 0x00,
  790. 0x21, 0x40,
  791. 0x22, 0x00,
  792. 0x23, 0x00,
  793. 0x24, 0x40,
  794. 0x25, 0x88,
  795. 0x30, 0xff,
  796. 0x31, 0x00,
  797. 0x32, 0xff,
  798. 0x33, 0x00,
  799. 0x34, 0x50,
  800. 0x35, 0x7f,
  801. 0x36, 0x00,
  802. 0x37, 0x20,
  803. 0x38, 0x00,
  804. 0x40, 0x1c,
  805. 0x41, 0xff,
  806. 0x42, 0x29,
  807. 0x43, 0x20,
  808. 0x44, 0xff,
  809. 0x45, 0x00,
  810. 0x46, 0x00,
  811. 0x49, 0x04,
  812. 0x4a, 0x00,
  813. 0x4b, 0x7b,
  814. 0x52, 0x30,
  815. 0x55, 0xae,
  816. 0x56, 0x47,
  817. 0x57, 0xe1,
  818. 0x58, 0x3a,
  819. 0x5a, 0x1e,
  820. 0x5b, 0x34,
  821. 0x60, 0x00,
  822. 0x63, 0x00,
  823. 0x64, 0x00,
  824. 0x65, 0x00,
  825. 0x66, 0x00,
  826. 0x67, 0x00,
  827. 0x68, 0x00,
  828. 0x69, 0x00,
  829. 0x6a, 0x02,
  830. 0x6b, 0x00,
  831. 0x70, 0xff,
  832. 0x71, 0x00,
  833. 0x72, 0x00,
  834. 0x73, 0x00,
  835. 0x74, 0x0c,
  836. 0x80, 0x00,
  837. 0x81, 0x00,
  838. 0x82, 0x00,
  839. 0x83, 0x00,
  840. 0x84, 0x04,
  841. 0x85, 0x80,
  842. 0x86, 0x24,
  843. 0x87, 0x78,
  844. 0x88, 0x10,
  845. 0x89, 0x00,
  846. 0x90, 0x01,
  847. 0x91, 0x01,
  848. 0xa0, 0x04,
  849. 0xa1, 0x00,
  850. 0xa2, 0x00,
  851. 0xb0, 0x91,
  852. 0xb1, 0x0b,
  853. 0xc0, 0x53,
  854. 0xc1, 0x70,
  855. 0xc2, 0x12,
  856. 0xd0, 0x00,
  857. 0xd1, 0x00,
  858. 0xd2, 0x00,
  859. 0xd3, 0x00,
  860. 0xd4, 0x00,
  861. 0xd5, 0x00,
  862. 0xde, 0x00,
  863. 0xdf, 0x00,
  864. 0x61, 0x38,
  865. 0x62, 0x0a,
  866. 0x53, 0x13,
  867. 0x59, 0x08,
  868. 0xff, 0xff,
  869. };
  870. static struct stv0297_config dvbc_philips_tdm1316l_config = {
  871. .demod_address = 0x1c,
  872. .inittab = dvbc_philips_tdm1316l_inittab,
  873. .invert = 0,
  874. .stop_during_read = 1,
  875. };
  876. static struct tda10023_config tda10023_config = {
  877. .demod_address = 0xc,
  878. .invert = 0,
  879. .xtal = 16000000,
  880. .pll_m = 11,
  881. .pll_p = 3,
  882. .pll_n = 1,
  883. .deltaf = 0xa511,
  884. };
  885. static struct tda827x_config tda827x_config = {
  886. .config = 0,
  887. };
  888. /* TT S2-3200 DVB-S (STB0899) Inittab */
  889. static const struct stb0899_s1_reg tt3200_stb0899_s1_init_1[] = {
  890. { STB0899_DEV_ID , 0x81 },
  891. { STB0899_DISCNTRL1 , 0x32 },
  892. { STB0899_DISCNTRL2 , 0x80 },
  893. { STB0899_DISRX_ST0 , 0x04 },
  894. { STB0899_DISRX_ST1 , 0x00 },
  895. { STB0899_DISPARITY , 0x00 },
  896. { STB0899_DISFIFO , 0x00 },
  897. { STB0899_DISSTATUS , 0x20 },
  898. { STB0899_DISF22 , 0x8c },
  899. { STB0899_DISF22RX , 0x9a },
  900. { STB0899_SYSREG , 0x0b },
  901. { STB0899_ACRPRESC , 0x11 },
  902. { STB0899_ACRDIV1 , 0x0a },
  903. { STB0899_ACRDIV2 , 0x05 },
  904. { STB0899_DACR1 , 0x00 },
  905. { STB0899_DACR2 , 0x00 },
  906. { STB0899_OUTCFG , 0x00 },
  907. { STB0899_MODECFG , 0x00 },
  908. { STB0899_IRQSTATUS_3 , 0x30 },
  909. { STB0899_IRQSTATUS_2 , 0x00 },
  910. { STB0899_IRQSTATUS_1 , 0x00 },
  911. { STB0899_IRQSTATUS_0 , 0x00 },
  912. { STB0899_IRQMSK_3 , 0xf3 },
  913. { STB0899_IRQMSK_2 , 0xfc },
  914. { STB0899_IRQMSK_1 , 0xff },
  915. { STB0899_IRQMSK_0 , 0xff },
  916. { STB0899_IRQCFG , 0x00 },
  917. { STB0899_I2CCFG , 0x88 },
  918. { STB0899_I2CRPT , 0x48 }, /* 12k Pullup, Repeater=16, Stop=disabled */
  919. { STB0899_IOPVALUE5 , 0x00 },
  920. { STB0899_IOPVALUE4 , 0x20 },
  921. { STB0899_IOPVALUE3 , 0xc9 },
  922. { STB0899_IOPVALUE2 , 0x90 },
  923. { STB0899_IOPVALUE1 , 0x40 },
  924. { STB0899_IOPVALUE0 , 0x00 },
  925. { STB0899_GPIO00CFG , 0x82 },
  926. { STB0899_GPIO01CFG , 0x82 },
  927. { STB0899_GPIO02CFG , 0x82 },
  928. { STB0899_GPIO03CFG , 0x82 },
  929. { STB0899_GPIO04CFG , 0x82 },
  930. { STB0899_GPIO05CFG , 0x82 },
  931. { STB0899_GPIO06CFG , 0x82 },
  932. { STB0899_GPIO07CFG , 0x82 },
  933. { STB0899_GPIO08CFG , 0x82 },
  934. { STB0899_GPIO09CFG , 0x82 },
  935. { STB0899_GPIO10CFG , 0x82 },
  936. { STB0899_GPIO11CFG , 0x82 },
  937. { STB0899_GPIO12CFG , 0x82 },
  938. { STB0899_GPIO13CFG , 0x82 },
  939. { STB0899_GPIO14CFG , 0x82 },
  940. { STB0899_GPIO15CFG , 0x82 },
  941. { STB0899_GPIO16CFG , 0x82 },
  942. { STB0899_GPIO17CFG , 0x82 },
  943. { STB0899_GPIO18CFG , 0x82 },
  944. { STB0899_GPIO19CFG , 0x82 },
  945. { STB0899_GPIO20CFG , 0x82 },
  946. { STB0899_SDATCFG , 0xb8 },
  947. { STB0899_SCLTCFG , 0xba },
  948. { STB0899_AGCRFCFG , 0x1c }, /* 0x11 */
  949. { STB0899_GPIO22 , 0x82 }, /* AGCBB2CFG */
  950. { STB0899_GPIO21 , 0x91 }, /* AGCBB1CFG */
  951. { STB0899_DIRCLKCFG , 0x82 },
  952. { STB0899_CLKOUT27CFG , 0x7e },
  953. { STB0899_STDBYCFG , 0x82 },
  954. { STB0899_CS0CFG , 0x82 },
  955. { STB0899_CS1CFG , 0x82 },
  956. { STB0899_DISEQCOCFG , 0x20 },
  957. { STB0899_GPIO32CFG , 0x82 },
  958. { STB0899_GPIO33CFG , 0x82 },
  959. { STB0899_GPIO34CFG , 0x82 },
  960. { STB0899_GPIO35CFG , 0x82 },
  961. { STB0899_GPIO36CFG , 0x82 },
  962. { STB0899_GPIO37CFG , 0x82 },
  963. { STB0899_GPIO38CFG , 0x82 },
  964. { STB0899_GPIO39CFG , 0x82 },
  965. { STB0899_NCOARSE , 0x15 }, /* 0x15 = 27 Mhz Clock, F/3 = 198MHz, F/6 = 99MHz */
  966. { STB0899_SYNTCTRL , 0x02 }, /* 0x00 = CLK from CLKI, 0x02 = CLK from XTALI */
  967. { STB0899_FILTCTRL , 0x00 },
  968. { STB0899_SYSCTRL , 0x00 },
  969. { STB0899_STOPCLK1 , 0x20 },
  970. { STB0899_STOPCLK2 , 0x00 },
  971. { STB0899_INTBUFSTATUS , 0x00 },
  972. { STB0899_INTBUFCTRL , 0x0a },
  973. { 0xffff , 0xff },
  974. };
  975. static const struct stb0899_s1_reg tt3200_stb0899_s1_init_3[] = {
  976. { STB0899_DEMOD , 0x00 },
  977. { STB0899_RCOMPC , 0xc9 },
  978. { STB0899_AGC1CN , 0x41 },
  979. { STB0899_AGC1REF , 0x10 },
  980. { STB0899_RTC , 0x7a },
  981. { STB0899_TMGCFG , 0x4e },
  982. { STB0899_AGC2REF , 0x34 },
  983. { STB0899_TLSR , 0x84 },
  984. { STB0899_CFD , 0xc7 },
  985. { STB0899_ACLC , 0x87 },
  986. { STB0899_BCLC , 0x94 },
  987. { STB0899_EQON , 0x41 },
  988. { STB0899_LDT , 0xdd },
  989. { STB0899_LDT2 , 0xc9 },
  990. { STB0899_EQUALREF , 0xb4 },
  991. { STB0899_TMGRAMP , 0x10 },
  992. { STB0899_TMGTHD , 0x30 },
  993. { STB0899_IDCCOMP , 0xfb },
  994. { STB0899_QDCCOMP , 0x03 },
  995. { STB0899_POWERI , 0x3b },
  996. { STB0899_POWERQ , 0x3d },
  997. { STB0899_RCOMP , 0x81 },
  998. { STB0899_AGCIQIN , 0x80 },
  999. { STB0899_AGC2I1 , 0x04 },
  1000. { STB0899_AGC2I2 , 0xf5 },
  1001. { STB0899_TLIR , 0x25 },
  1002. { STB0899_RTF , 0x80 },
  1003. { STB0899_DSTATUS , 0x00 },
  1004. { STB0899_LDI , 0xca },
  1005. { STB0899_CFRM , 0xf1 },
  1006. { STB0899_CFRL , 0xf3 },
  1007. { STB0899_NIRM , 0x2a },
  1008. { STB0899_NIRL , 0x05 },
  1009. { STB0899_ISYMB , 0x17 },
  1010. { STB0899_QSYMB , 0xfa },
  1011. { STB0899_SFRH , 0x2f },
  1012. { STB0899_SFRM , 0x68 },
  1013. { STB0899_SFRL , 0x40 },
  1014. { STB0899_SFRUPH , 0x2f },
  1015. { STB0899_SFRUPM , 0x68 },
  1016. { STB0899_SFRUPL , 0x40 },
  1017. { STB0899_EQUAI1 , 0xfd },
  1018. { STB0899_EQUAQ1 , 0x04 },
  1019. { STB0899_EQUAI2 , 0x0f },
  1020. { STB0899_EQUAQ2 , 0xff },
  1021. { STB0899_EQUAI3 , 0xdf },
  1022. { STB0899_EQUAQ3 , 0xfa },
  1023. { STB0899_EQUAI4 , 0x37 },
  1024. { STB0899_EQUAQ4 , 0x0d },
  1025. { STB0899_EQUAI5 , 0xbd },
  1026. { STB0899_EQUAQ5 , 0xf7 },
  1027. { STB0899_DSTATUS2 , 0x00 },
  1028. { STB0899_VSTATUS , 0x00 },
  1029. { STB0899_VERROR , 0xff },
  1030. { STB0899_IQSWAP , 0x2a },
  1031. { STB0899_ECNT1M , 0x00 },
  1032. { STB0899_ECNT1L , 0x00 },
  1033. { STB0899_ECNT2M , 0x00 },
  1034. { STB0899_ECNT2L , 0x00 },
  1035. { STB0899_ECNT3M , 0x00 },
  1036. { STB0899_ECNT3L , 0x00 },
  1037. { STB0899_FECAUTO1 , 0x06 },
  1038. { STB0899_FECM , 0x01 },
  1039. { STB0899_VTH12 , 0xf0 },
  1040. { STB0899_VTH23 , 0xa0 },
  1041. { STB0899_VTH34 , 0x78 },
  1042. { STB0899_VTH56 , 0x4e },
  1043. { STB0899_VTH67 , 0x48 },
  1044. { STB0899_VTH78 , 0x38 },
  1045. { STB0899_PRVIT , 0xff },
  1046. { STB0899_VITSYNC , 0x19 },
  1047. { STB0899_RSULC , 0xb1 }, /* DVB = 0xb1, DSS = 0xa1 */
  1048. { STB0899_TSULC , 0x42 },
  1049. { STB0899_RSLLC , 0x40 },
  1050. { STB0899_TSLPL , 0x12 },
  1051. { STB0899_TSCFGH , 0x0c },
  1052. { STB0899_TSCFGM , 0x00 },
  1053. { STB0899_TSCFGL , 0x0c },
  1054. { STB0899_TSOUT , 0x4d }, /* 0x0d for CAM */
  1055. { STB0899_RSSYNCDEL , 0x00 },
  1056. { STB0899_TSINHDELH , 0x02 },
  1057. { STB0899_TSINHDELM , 0x00 },
  1058. { STB0899_TSINHDELL , 0x00 },
  1059. { STB0899_TSLLSTKM , 0x00 },
  1060. { STB0899_TSLLSTKL , 0x00 },
  1061. { STB0899_TSULSTKM , 0x00 },
  1062. { STB0899_TSULSTKL , 0xab },
  1063. { STB0899_PCKLENUL , 0x00 },
  1064. { STB0899_PCKLENLL , 0xcc },
  1065. { STB0899_RSPCKLEN , 0xcc },
  1066. { STB0899_TSSTATUS , 0x80 },
  1067. { STB0899_ERRCTRL1 , 0xb6 },
  1068. { STB0899_ERRCTRL2 , 0x96 },
  1069. { STB0899_ERRCTRL3 , 0x89 },
  1070. { STB0899_DMONMSK1 , 0x27 },
  1071. { STB0899_DMONMSK0 , 0x03 },
  1072. { STB0899_DEMAPVIT , 0x5c },
  1073. { STB0899_PLPARM , 0x1f },
  1074. { STB0899_PDELCTRL , 0x48 },
  1075. { STB0899_PDELCTRL2 , 0x00 },
  1076. { STB0899_BBHCTRL1 , 0x00 },
  1077. { STB0899_BBHCTRL2 , 0x00 },
  1078. { STB0899_HYSTTHRESH , 0x77 },
  1079. { STB0899_MATCSTM , 0x00 },
  1080. { STB0899_MATCSTL , 0x00 },
  1081. { STB0899_UPLCSTM , 0x00 },
  1082. { STB0899_UPLCSTL , 0x00 },
  1083. { STB0899_DFLCSTM , 0x00 },
  1084. { STB0899_DFLCSTL , 0x00 },
  1085. { STB0899_SYNCCST , 0x00 },
  1086. { STB0899_SYNCDCSTM , 0x00 },
  1087. { STB0899_SYNCDCSTL , 0x00 },
  1088. { STB0899_ISI_ENTRY , 0x00 },
  1089. { STB0899_ISI_BIT_EN , 0x00 },
  1090. { STB0899_MATSTRM , 0x00 },
  1091. { STB0899_MATSTRL , 0x00 },
  1092. { STB0899_UPLSTRM , 0x00 },
  1093. { STB0899_UPLSTRL , 0x00 },
  1094. { STB0899_DFLSTRM , 0x00 },
  1095. { STB0899_DFLSTRL , 0x00 },
  1096. { STB0899_SYNCSTR , 0x00 },
  1097. { STB0899_SYNCDSTRM , 0x00 },
  1098. { STB0899_SYNCDSTRL , 0x00 },
  1099. { STB0899_CFGPDELSTATUS1 , 0x10 },
  1100. { STB0899_CFGPDELSTATUS2 , 0x00 },
  1101. { STB0899_BBFERRORM , 0x00 },
  1102. { STB0899_BBFERRORL , 0x00 },
  1103. { STB0899_UPKTERRORM , 0x00 },
  1104. { STB0899_UPKTERRORL , 0x00 },
  1105. { 0xffff , 0xff },
  1106. };
  1107. static struct stb0899_config tt3200_config = {
  1108. .init_dev = tt3200_stb0899_s1_init_1,
  1109. .init_s2_demod = stb0899_s2_init_2,
  1110. .init_s1_demod = tt3200_stb0899_s1_init_3,
  1111. .init_s2_fec = stb0899_s2_init_4,
  1112. .init_tst = stb0899_s1_init_5,
  1113. .postproc = NULL,
  1114. .demod_address = 0x68,
  1115. .xtal_freq = 27000000,
  1116. .inversion = IQ_SWAP_ON, /* 1 */
  1117. .lo_clk = 76500000,
  1118. .hi_clk = 99000000,
  1119. .esno_ave = STB0899_DVBS2_ESNO_AVE,
  1120. .esno_quant = STB0899_DVBS2_ESNO_QUANT,
  1121. .avframes_coarse = STB0899_DVBS2_AVFRAMES_COARSE,
  1122. .avframes_fine = STB0899_DVBS2_AVFRAMES_FINE,
  1123. .miss_threshold = STB0899_DVBS2_MISS_THRESHOLD,
  1124. .uwp_threshold_acq = STB0899_DVBS2_UWP_THRESHOLD_ACQ,
  1125. .uwp_threshold_track = STB0899_DVBS2_UWP_THRESHOLD_TRACK,
  1126. .uwp_threshold_sof = STB0899_DVBS2_UWP_THRESHOLD_SOF,
  1127. .sof_search_timeout = STB0899_DVBS2_SOF_SEARCH_TIMEOUT,
  1128. .btr_nco_bits = STB0899_DVBS2_BTR_NCO_BITS,
  1129. .btr_gain_shift_offset = STB0899_DVBS2_BTR_GAIN_SHIFT_OFFSET,
  1130. .crl_nco_bits = STB0899_DVBS2_CRL_NCO_BITS,
  1131. .ldpc_max_iter = STB0899_DVBS2_LDPC_MAX_ITER,
  1132. .tuner_get_frequency = stb6100_get_frequency,
  1133. .tuner_set_frequency = stb6100_set_frequency,
  1134. .tuner_set_bandwidth = stb6100_set_bandwidth,
  1135. .tuner_get_bandwidth = stb6100_get_bandwidth,
  1136. .tuner_set_rfsiggain = NULL
  1137. };
  1138. static struct stb6100_config tt3200_stb6100_config = {
  1139. .tuner_address = 0x60,
  1140. .refclock = 27000000,
  1141. };
  1142. static void frontend_init(struct budget_ci *budget_ci)
  1143. {
  1144. switch (budget_ci->budget.dev->pci->subsystem_device) {
  1145. case 0x100c: // Hauppauge/TT Nova-CI budget (stv0299/ALPS BSRU6(tsa5059))
  1146. budget_ci->budget.dvb_frontend =
  1147. dvb_attach(stv0299_attach, &alps_bsru6_config, &budget_ci->budget.i2c_adap);
  1148. if (budget_ci->budget.dvb_frontend) {
  1149. budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
  1150. budget_ci->budget.dvb_frontend->tuner_priv = &budget_ci->budget.i2c_adap;
  1151. break;
  1152. }
  1153. break;
  1154. case 0x100f: // Hauppauge/TT Nova-CI budget (stv0299b/Philips su1278(tsa5059))
  1155. budget_ci->budget.dvb_frontend =
  1156. dvb_attach(stv0299_attach, &philips_su1278_tt_config, &budget_ci->budget.i2c_adap);
  1157. if (budget_ci->budget.dvb_frontend) {
  1158. budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_su1278_tt_tuner_set_params;
  1159. break;
  1160. }
  1161. break;
  1162. case 0x1010: // TT DVB-C CI budget (stv0297/Philips tdm1316l(tda6651tt))
  1163. budget_ci->tuner_pll_address = 0x61;
  1164. budget_ci->budget.dvb_frontend =
  1165. dvb_attach(stv0297_attach, &dvbc_philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
  1166. if (budget_ci->budget.dvb_frontend) {
  1167. budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = dvbc_philips_tdm1316l_tuner_set_params;
  1168. break;
  1169. }
  1170. break;
  1171. case 0x1011: // Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889)
  1172. budget_ci->tuner_pll_address = 0x63;
  1173. budget_ci->budget.dvb_frontend =
  1174. dvb_attach(tda10045_attach, &philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
  1175. if (budget_ci->budget.dvb_frontend) {
  1176. budget_ci->budget.dvb_frontend->ops.tuner_ops.init = philips_tdm1316l_tuner_init;
  1177. budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params;
  1178. break;
  1179. }
  1180. break;
  1181. case 0x1012: // TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt))
  1182. budget_ci->tuner_pll_address = 0x60;
  1183. budget_ci->budget.dvb_frontend =
  1184. dvb_attach(tda10046_attach, &philips_tdm1316l_config_invert, &budget_ci->budget.i2c_adap);
  1185. if (budget_ci->budget.dvb_frontend) {
  1186. budget_ci->budget.dvb_frontend->ops.tuner_ops.init = philips_tdm1316l_tuner_init;
  1187. budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params;
  1188. break;
  1189. }
  1190. break;
  1191. case 0x1017: // TT S-1500 PCI
  1192. budget_ci->budget.dvb_frontend = dvb_attach(stv0299_attach, &alps_bsbe1_config, &budget_ci->budget.i2c_adap);
  1193. if (budget_ci->budget.dvb_frontend) {
  1194. budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = alps_bsbe1_tuner_set_params;
  1195. budget_ci->budget.dvb_frontend->tuner_priv = &budget_ci->budget.i2c_adap;
  1196. budget_ci->budget.dvb_frontend->ops.dishnetwork_send_legacy_command = NULL;
  1197. if (dvb_attach(lnbp21_attach, budget_ci->budget.dvb_frontend, &budget_ci->budget.i2c_adap, LNBP21_LLC, 0) == NULL) {
  1198. printk("%s: No LNBP21 found!\n", __func__);
  1199. dvb_frontend_detach(budget_ci->budget.dvb_frontend);
  1200. budget_ci->budget.dvb_frontend = NULL;
  1201. }
  1202. }
  1203. break;
  1204. case 0x101a: /* TT Budget-C-1501 (philips tda10023/philips tda8274A) */
  1205. budget_ci->budget.dvb_frontend = dvb_attach(tda10023_attach, &tda10023_config, &budget_ci->budget.i2c_adap, 0x48);
  1206. if (budget_ci->budget.dvb_frontend) {
  1207. if (dvb_attach(tda827x_attach, budget_ci->budget.dvb_frontend, 0x61, &budget_ci->budget.i2c_adap, &tda827x_config) == NULL) {
  1208. printk(KERN_ERR "%s: No tda827x found!\n", __func__);
  1209. dvb_frontend_detach(budget_ci->budget.dvb_frontend);
  1210. budget_ci->budget.dvb_frontend = NULL;
  1211. }
  1212. }
  1213. break;
  1214. case 0x1019: // TT S2-3200 PCI
  1215. /*
  1216. * NOTE! on some STB0899 versions, the internal PLL takes a longer time
  1217. * to settle, aka LOCK. On the older revisions of the chip, we don't see
  1218. * this, as a result on the newer chips the entire clock tree, will not
  1219. * be stable after a freshly POWER 'ed up situation.
  1220. * In this case, we should RESET the STB0899 (Active LOW) and wait for
  1221. * PLL stabilization.
  1222. *
  1223. * On the TT S2 3200 and clones, the STB0899 demodulator's RESETB is
  1224. * connected to the SAA7146 GPIO, GPIO2, Pin 142
  1225. */
  1226. /* Reset Demodulator */
  1227. saa7146_setgpio(budget_ci->budget.dev, 2, SAA7146_GPIO_OUTLO);
  1228. /* Wait for everything to die */
  1229. msleep(50);
  1230. /* Pull it up out of Reset state */
  1231. saa7146_setgpio(budget_ci->budget.dev, 2, SAA7146_GPIO_OUTHI);
  1232. /* Wait for PLL to stabilize */
  1233. msleep(250);
  1234. /*
  1235. * PLL state should be stable now. Ideally, we should check
  1236. * for PLL LOCK status. But well, never mind!
  1237. */
  1238. budget_ci->budget.dvb_frontend = dvb_attach(stb0899_attach, &tt3200_config, &budget_ci->budget.i2c_adap);
  1239. if (budget_ci->budget.dvb_frontend) {
  1240. if (dvb_attach(stb6100_attach, budget_ci->budget.dvb_frontend, &tt3200_stb6100_config, &budget_ci->budget.i2c_adap)) {
  1241. if (!dvb_attach(lnbp21_attach, budget_ci->budget.dvb_frontend, &budget_ci->budget.i2c_adap, 0, 0)) {
  1242. printk("%s: No LNBP21 found!\n", __func__);
  1243. dvb_frontend_detach(budget_ci->budget.dvb_frontend);
  1244. budget_ci->budget.dvb_frontend = NULL;
  1245. }
  1246. } else {
  1247. dvb_frontend_detach(budget_ci->budget.dvb_frontend);
  1248. budget_ci->budget.dvb_frontend = NULL;
  1249. }
  1250. }
  1251. break;
  1252. }
  1253. if (budget_ci->budget.dvb_frontend == NULL) {
  1254. printk("budget-ci: A frontend driver was not found for device [%04x:%04x] subsystem [%04x:%04x]\n",
  1255. budget_ci->budget.dev->pci->vendor,
  1256. budget_ci->budget.dev->pci->device,
  1257. budget_ci->budget.dev->pci->subsystem_vendor,
  1258. budget_ci->budget.dev->pci->subsystem_device);
  1259. } else {
  1260. if (dvb_register_frontend
  1261. (&budget_ci->budget.dvb_adapter, budget_ci->budget.dvb_frontend)) {
  1262. printk("budget-ci: Frontend registration failed!\n");
  1263. dvb_frontend_detach(budget_ci->budget.dvb_frontend);
  1264. budget_ci->budget.dvb_frontend = NULL;
  1265. }
  1266. }
  1267. }
  1268. static int budget_ci_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data *info)
  1269. {
  1270. struct budget_ci *budget_ci;
  1271. int err;
  1272. budget_ci = kzalloc(sizeof(struct budget_ci), GFP_KERNEL);
  1273. if (!budget_ci) {
  1274. err = -ENOMEM;
  1275. goto out1;
  1276. }
  1277. dprintk(2, "budget_ci: %p\n", budget_ci);
  1278. dev->ext_priv = budget_ci;
  1279. err = ttpci_budget_init(&budget_ci->budget, dev, info, THIS_MODULE,
  1280. adapter_nr);
  1281. if (err)
  1282. goto out2;
  1283. err = msp430_ir_init(budget_ci);
  1284. if (err)
  1285. goto out3;
  1286. ciintf_init(budget_ci);
  1287. budget_ci->budget.dvb_adapter.priv = budget_ci;
  1288. frontend_init(budget_ci);
  1289. ttpci_budget_init_hooks(&budget_ci->budget);
  1290. return 0;
  1291. out3:
  1292. ttpci_budget_deinit(&budget_ci->budget);
  1293. out2:
  1294. kfree(budget_ci);
  1295. out1:
  1296. return err;
  1297. }
  1298. static int budget_ci_detach(struct saa7146_dev *dev)
  1299. {
  1300. struct budget_ci *budget_ci = (struct budget_ci *) dev->ext_priv;
  1301. struct saa7146_dev *saa = budget_ci->budget.dev;
  1302. int err;
  1303. if (budget_ci->budget.ci_present)
  1304. ciintf_deinit(budget_ci);
  1305. msp430_ir_deinit(budget_ci);
  1306. if (budget_ci->budget.dvb_frontend) {
  1307. dvb_unregister_frontend(budget_ci->budget.dvb_frontend);
  1308. dvb_frontend_detach(budget_ci->budget.dvb_frontend);
  1309. }
  1310. err = ttpci_budget_deinit(&budget_ci->budget);
  1311. // disable frontend and CI interface
  1312. saa7146_setgpio(saa, 2, SAA7146_GPIO_INPUT);
  1313. kfree(budget_ci);
  1314. return err;
  1315. }
  1316. static struct saa7146_extension budget_extension;
  1317. MAKE_BUDGET_INFO(ttbs2, "TT-Budget/S-1500 PCI", BUDGET_TT);
  1318. MAKE_BUDGET_INFO(ttbci, "TT-Budget/WinTV-NOVA-CI PCI", BUDGET_TT_HW_DISEQC);
  1319. MAKE_BUDGET_INFO(ttbt2, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT);
  1320. MAKE_BUDGET_INFO(ttbtci, "TT-Budget-T-CI PCI", BUDGET_TT);
  1321. MAKE_BUDGET_INFO(ttbcci, "TT-Budget-C-CI PCI", BUDGET_TT);
  1322. MAKE_BUDGET_INFO(ttc1501, "TT-Budget C-1501 PCI", BUDGET_TT);
  1323. MAKE_BUDGET_INFO(tt3200, "TT-Budget S2-3200 PCI", BUDGET_TT);
  1324. static struct pci_device_id pci_tbl[] = {
  1325. MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100c),
  1326. MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100f),
  1327. MAKE_EXTENSION_PCI(ttbcci, 0x13c2, 0x1010),
  1328. MAKE_EXTENSION_PCI(ttbt2, 0x13c2, 0x1011),
  1329. MAKE_EXTENSION_PCI(ttbtci, 0x13c2, 0x1012),
  1330. MAKE_EXTENSION_PCI(ttbs2, 0x13c2, 0x1017),
  1331. MAKE_EXTENSION_PCI(ttc1501, 0x13c2, 0x101a),
  1332. MAKE_EXTENSION_PCI(tt3200, 0x13c2, 0x1019),
  1333. {
  1334. .vendor = 0,
  1335. }
  1336. };
  1337. MODULE_DEVICE_TABLE(pci, pci_tbl);
  1338. static struct saa7146_extension budget_extension = {
  1339. .name = "budget_ci dvb",
  1340. .flags = SAA7146_USE_I2C_IRQ,
  1341. .module = THIS_MODULE,
  1342. .pci_tbl = &pci_tbl[0],
  1343. .attach = budget_ci_attach,
  1344. .detach = budget_ci_detach,
  1345. .irq_mask = MASK_03 | MASK_06 | MASK_10,
  1346. .irq_func = budget_ci_irq,
  1347. };
  1348. static int __init budget_ci_init(void)
  1349. {
  1350. return saa7146_register_extension(&budget_extension);
  1351. }
  1352. static void __exit budget_ci_exit(void)
  1353. {
  1354. saa7146_unregister_extension(&budget_extension);
  1355. }
  1356. module_init(budget_ci_init);
  1357. module_exit(budget_ci_exit);
  1358. MODULE_LICENSE("GPL");
  1359. MODULE_AUTHOR("Michael Hunold, Jack Thomasson, Andrew de Quincey, others");
  1360. MODULE_DESCRIPTION("driver for the SAA7146 based so-called "
  1361. "budget PCI DVB cards w/ CI-module produced by "
  1362. "Siemens, Technotrend, Hauppauge");