budget-ci.c 44 KB

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