budget-ci.c 44 KB

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