budget-ci.c 44 KB

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