budget-av.c 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636
  1. /*
  2. * budget-av.c: driver for the SAA7146 based Budget DVB cards
  3. * with analog video in
  4. *
  5. * Compiled from various sources by Michael Hunold <michael@mihu.de>
  6. *
  7. * CI interface support (c) 2004 Olivier Gournet <ogournet@anevia.com> &
  8. * Andrew de Quincey <adq_dvb@lidskialf.net>
  9. *
  10. * Copyright (C) 2002 Ralph Metzler <rjkm@metzlerbros.de>
  11. *
  12. * Copyright (C) 1999-2002 Ralph Metzler
  13. * & Marcus Metzler for convergence integrated media GmbH
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License
  17. * as published by the Free Software Foundation; either version 2
  18. * of the License, or (at your option) any later version.
  19. *
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program; if not, write to the Free Software
  29. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  30. * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
  31. *
  32. *
  33. * the project's page is at http://www.linuxtv.org/
  34. */
  35. #include "budget.h"
  36. #include "stv0299.h"
  37. #include "stb0899_drv.h"
  38. #include "stb0899_reg.h"
  39. #include "stb0899_cfg.h"
  40. #include "tda8261.h"
  41. #include "tda8261_cfg.h"
  42. #include "tda1002x.h"
  43. #include "tda1004x.h"
  44. #include "tua6100.h"
  45. #include "dvb-pll.h"
  46. #include <media/saa7146_vv.h>
  47. #include <linux/module.h>
  48. #include <linux/errno.h>
  49. #include <linux/slab.h>
  50. #include <linux/interrupt.h>
  51. #include <linux/input.h>
  52. #include <linux/spinlock.h>
  53. #include "dvb_ca_en50221.h"
  54. #define DEBICICAM 0x02420000
  55. #define SLOTSTATUS_NONE 1
  56. #define SLOTSTATUS_PRESENT 2
  57. #define SLOTSTATUS_RESET 4
  58. #define SLOTSTATUS_READY 8
  59. #define SLOTSTATUS_OCCUPIED (SLOTSTATUS_PRESENT|SLOTSTATUS_RESET|SLOTSTATUS_READY)
  60. DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
  61. struct budget_av {
  62. struct budget budget;
  63. struct video_device *vd;
  64. int cur_input;
  65. int has_saa7113;
  66. struct tasklet_struct ciintf_irq_tasklet;
  67. int slot_status;
  68. struct dvb_ca_en50221 ca;
  69. u8 reinitialise_demod:1;
  70. };
  71. static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot);
  72. /* GPIO Connections:
  73. * 0 - Vcc/Reset (Reset is controlled by capacitor). Resets the frontend *AS WELL*!
  74. * 1 - CI memory select 0=>IO memory, 1=>Attribute Memory
  75. * 2 - CI Card Enable (Active Low)
  76. * 3 - CI Card Detect
  77. */
  78. /****************************************************************************
  79. * INITIALIZATION
  80. ****************************************************************************/
  81. static u8 i2c_readreg(struct i2c_adapter *i2c, u8 id, u8 reg)
  82. {
  83. u8 mm1[] = { 0x00 };
  84. u8 mm2[] = { 0x00 };
  85. struct i2c_msg msgs[2];
  86. msgs[0].flags = 0;
  87. msgs[1].flags = I2C_M_RD;
  88. msgs[0].addr = msgs[1].addr = id / 2;
  89. mm1[0] = reg;
  90. msgs[0].len = 1;
  91. msgs[1].len = 1;
  92. msgs[0].buf = mm1;
  93. msgs[1].buf = mm2;
  94. i2c_transfer(i2c, msgs, 2);
  95. return mm2[0];
  96. }
  97. static int i2c_readregs(struct i2c_adapter *i2c, u8 id, u8 reg, u8 * buf, u8 len)
  98. {
  99. u8 mm1[] = { reg };
  100. struct i2c_msg msgs[2] = {
  101. {.addr = id / 2,.flags = 0,.buf = mm1,.len = 1},
  102. {.addr = id / 2,.flags = I2C_M_RD,.buf = buf,.len = len}
  103. };
  104. if (i2c_transfer(i2c, msgs, 2) != 2)
  105. return -EIO;
  106. return 0;
  107. }
  108. static int i2c_writereg(struct i2c_adapter *i2c, u8 id, u8 reg, u8 val)
  109. {
  110. u8 msg[2] = { reg, val };
  111. struct i2c_msg msgs;
  112. msgs.flags = 0;
  113. msgs.addr = id / 2;
  114. msgs.len = 2;
  115. msgs.buf = msg;
  116. return i2c_transfer(i2c, &msgs, 1);
  117. }
  118. static int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address)
  119. {
  120. struct budget_av *budget_av = (struct budget_av *) ca->data;
  121. int result;
  122. if (slot != 0)
  123. return -EINVAL;
  124. saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI);
  125. udelay(1);
  126. result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 0xfff, 1, 0, 1);
  127. if (result == -ETIMEDOUT) {
  128. ciintf_slot_shutdown(ca, slot);
  129. printk(KERN_INFO "budget-av: cam ejected 1\n");
  130. }
  131. return result;
  132. }
  133. static int ciintf_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address, u8 value)
  134. {
  135. struct budget_av *budget_av = (struct budget_av *) ca->data;
  136. int result;
  137. if (slot != 0)
  138. return -EINVAL;
  139. saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI);
  140. udelay(1);
  141. result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 0xfff, 1, value, 0, 1);
  142. if (result == -ETIMEDOUT) {
  143. ciintf_slot_shutdown(ca, slot);
  144. printk(KERN_INFO "budget-av: cam ejected 2\n");
  145. }
  146. return result;
  147. }
  148. static int ciintf_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address)
  149. {
  150. struct budget_av *budget_av = (struct budget_av *) ca->data;
  151. int result;
  152. if (slot != 0)
  153. return -EINVAL;
  154. saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
  155. udelay(1);
  156. result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 3, 1, 0, 0);
  157. if (result == -ETIMEDOUT) {
  158. ciintf_slot_shutdown(ca, slot);
  159. printk(KERN_INFO "budget-av: cam ejected 3\n");
  160. return -ETIMEDOUT;
  161. }
  162. return result;
  163. }
  164. static int ciintf_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address, u8 value)
  165. {
  166. struct budget_av *budget_av = (struct budget_av *) ca->data;
  167. int result;
  168. if (slot != 0)
  169. return -EINVAL;
  170. saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
  171. udelay(1);
  172. result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 3, 1, value, 0, 0);
  173. if (result == -ETIMEDOUT) {
  174. ciintf_slot_shutdown(ca, slot);
  175. printk(KERN_INFO "budget-av: cam ejected 5\n");
  176. }
  177. return result;
  178. }
  179. static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
  180. {
  181. struct budget_av *budget_av = (struct budget_av *) ca->data;
  182. struct saa7146_dev *saa = budget_av->budget.dev;
  183. if (slot != 0)
  184. return -EINVAL;
  185. dprintk(1, "ciintf_slot_reset\n");
  186. budget_av->slot_status = SLOTSTATUS_RESET;
  187. saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */
  188. saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */
  189. msleep(2);
  190. saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO); /* Vcc on */
  191. msleep(20); /* 20 ms Vcc settling time */
  192. saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO); /* enable card */
  193. ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
  194. msleep(20);
  195. /* reinitialise the frontend if necessary */
  196. if (budget_av->reinitialise_demod)
  197. dvb_frontend_reinitialise(budget_av->budget.dvb_frontend);
  198. return 0;
  199. }
  200. static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot)
  201. {
  202. struct budget_av *budget_av = (struct budget_av *) ca->data;
  203. struct saa7146_dev *saa = budget_av->budget.dev;
  204. if (slot != 0)
  205. return -EINVAL;
  206. dprintk(1, "ciintf_slot_shutdown\n");
  207. ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
  208. budget_av->slot_status = SLOTSTATUS_NONE;
  209. return 0;
  210. }
  211. static int ciintf_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot)
  212. {
  213. struct budget_av *budget_av = (struct budget_av *) ca->data;
  214. struct saa7146_dev *saa = budget_av->budget.dev;
  215. if (slot != 0)
  216. return -EINVAL;
  217. dprintk(1, "ciintf_slot_ts_enable: %d\n", budget_av->slot_status);
  218. ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTA);
  219. return 0;
  220. }
  221. static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open)
  222. {
  223. struct budget_av *budget_av = (struct budget_av *) ca->data;
  224. struct saa7146_dev *saa = budget_av->budget.dev;
  225. int result;
  226. if (slot != 0)
  227. return -EINVAL;
  228. /* test the card detect line - needs to be done carefully
  229. * since it never goes high for some CAMs on this interface (e.g. topuptv) */
  230. if (budget_av->slot_status == SLOTSTATUS_NONE) {
  231. saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
  232. udelay(1);
  233. if (saa7146_read(saa, PSR) & MASK_06) {
  234. if (budget_av->slot_status == SLOTSTATUS_NONE) {
  235. budget_av->slot_status = SLOTSTATUS_PRESENT;
  236. printk(KERN_INFO "budget-av: cam inserted A\n");
  237. }
  238. }
  239. saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
  240. }
  241. /* We also try and read from IO memory to work round the above detection bug. If
  242. * there is no CAM, we will get a timeout. Only done if there is no cam
  243. * present, since this test actually breaks some cams :(
  244. *
  245. * if the CI interface is not open, we also do the above test since we
  246. * don't care if the cam has problems - we'll be resetting it on open() anyway */
  247. if ((budget_av->slot_status == SLOTSTATUS_NONE) || (!open)) {
  248. saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
  249. result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, 0, 1, 0, 1);
  250. if ((result >= 0) && (budget_av->slot_status == SLOTSTATUS_NONE)) {
  251. budget_av->slot_status = SLOTSTATUS_PRESENT;
  252. printk(KERN_INFO "budget-av: cam inserted B\n");
  253. } else if (result < 0) {
  254. if (budget_av->slot_status != SLOTSTATUS_NONE) {
  255. ciintf_slot_shutdown(ca, slot);
  256. printk(KERN_INFO "budget-av: cam ejected 5\n");
  257. return 0;
  258. }
  259. }
  260. }
  261. /* read from attribute memory in reset/ready state to know when the CAM is ready */
  262. if (budget_av->slot_status == SLOTSTATUS_RESET) {
  263. result = ciintf_read_attribute_mem(ca, slot, 0);
  264. if (result == 0x1d) {
  265. budget_av->slot_status = SLOTSTATUS_READY;
  266. }
  267. }
  268. /* work out correct return code */
  269. if (budget_av->slot_status != SLOTSTATUS_NONE) {
  270. if (budget_av->slot_status & SLOTSTATUS_READY) {
  271. return DVB_CA_EN50221_POLL_CAM_PRESENT | DVB_CA_EN50221_POLL_CAM_READY;
  272. }
  273. return DVB_CA_EN50221_POLL_CAM_PRESENT;
  274. }
  275. return 0;
  276. }
  277. static int ciintf_init(struct budget_av *budget_av)
  278. {
  279. struct saa7146_dev *saa = budget_av->budget.dev;
  280. int result;
  281. memset(&budget_av->ca, 0, sizeof(struct dvb_ca_en50221));
  282. saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
  283. saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTLO);
  284. saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO);
  285. saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
  286. /* Enable DEBI pins */
  287. saa7146_write(saa, MC1, MASK_27 | MASK_11);
  288. /* register CI interface */
  289. budget_av->ca.owner = THIS_MODULE;
  290. budget_av->ca.read_attribute_mem = ciintf_read_attribute_mem;
  291. budget_av->ca.write_attribute_mem = ciintf_write_attribute_mem;
  292. budget_av->ca.read_cam_control = ciintf_read_cam_control;
  293. budget_av->ca.write_cam_control = ciintf_write_cam_control;
  294. budget_av->ca.slot_reset = ciintf_slot_reset;
  295. budget_av->ca.slot_shutdown = ciintf_slot_shutdown;
  296. budget_av->ca.slot_ts_enable = ciintf_slot_ts_enable;
  297. budget_av->ca.poll_slot_status = ciintf_poll_slot_status;
  298. budget_av->ca.data = budget_av;
  299. budget_av->budget.ci_present = 1;
  300. budget_av->slot_status = SLOTSTATUS_NONE;
  301. if ((result = dvb_ca_en50221_init(&budget_av->budget.dvb_adapter,
  302. &budget_av->ca, 0, 1)) != 0) {
  303. printk(KERN_ERR "budget-av: ci initialisation failed.\n");
  304. goto error;
  305. }
  306. printk(KERN_INFO "budget-av: ci interface initialised.\n");
  307. return 0;
  308. error:
  309. saa7146_write(saa, MC1, MASK_27);
  310. return result;
  311. }
  312. static void ciintf_deinit(struct budget_av *budget_av)
  313. {
  314. struct saa7146_dev *saa = budget_av->budget.dev;
  315. saa7146_setgpio(saa, 0, SAA7146_GPIO_INPUT);
  316. saa7146_setgpio(saa, 1, SAA7146_GPIO_INPUT);
  317. saa7146_setgpio(saa, 2, SAA7146_GPIO_INPUT);
  318. saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
  319. /* release the CA device */
  320. dvb_ca_en50221_release(&budget_av->ca);
  321. /* disable DEBI pins */
  322. saa7146_write(saa, MC1, MASK_27);
  323. }
  324. static const u8 saa7113_tab[] = {
  325. 0x01, 0x08,
  326. 0x02, 0xc0,
  327. 0x03, 0x33,
  328. 0x04, 0x00,
  329. 0x05, 0x00,
  330. 0x06, 0xeb,
  331. 0x07, 0xe0,
  332. 0x08, 0x28,
  333. 0x09, 0x00,
  334. 0x0a, 0x80,
  335. 0x0b, 0x47,
  336. 0x0c, 0x40,
  337. 0x0d, 0x00,
  338. 0x0e, 0x01,
  339. 0x0f, 0x44,
  340. 0x10, 0x08,
  341. 0x11, 0x0c,
  342. 0x12, 0x7b,
  343. 0x13, 0x00,
  344. 0x15, 0x00, 0x16, 0x00, 0x17, 0x00,
  345. 0x57, 0xff,
  346. 0x40, 0x82, 0x58, 0x00, 0x59, 0x54, 0x5a, 0x07,
  347. 0x5b, 0x83, 0x5e, 0x00,
  348. 0xff
  349. };
  350. static int saa7113_init(struct budget_av *budget_av)
  351. {
  352. struct budget *budget = &budget_av->budget;
  353. struct saa7146_dev *saa = budget->dev;
  354. const u8 *data = saa7113_tab;
  355. saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI);
  356. msleep(200);
  357. if (i2c_writereg(&budget->i2c_adap, 0x4a, 0x01, 0x08) != 1) {
  358. dprintk(1, "saa7113 not found on KNC card\n");
  359. return -ENODEV;
  360. }
  361. dprintk(1, "saa7113 detected and initializing\n");
  362. while (*data != 0xff) {
  363. i2c_writereg(&budget->i2c_adap, 0x4a, *data, *(data + 1));
  364. data += 2;
  365. }
  366. dprintk(1, "saa7113 status=%02x\n", i2c_readreg(&budget->i2c_adap, 0x4a, 0x1f));
  367. return 0;
  368. }
  369. static int saa7113_setinput(struct budget_av *budget_av, int input)
  370. {
  371. struct budget *budget = &budget_av->budget;
  372. if (1 != budget_av->has_saa7113)
  373. return -ENODEV;
  374. if (input == 1) {
  375. i2c_writereg(&budget->i2c_adap, 0x4a, 0x02, 0xc7);
  376. i2c_writereg(&budget->i2c_adap, 0x4a, 0x09, 0x80);
  377. } else if (input == 0) {
  378. i2c_writereg(&budget->i2c_adap, 0x4a, 0x02, 0xc0);
  379. i2c_writereg(&budget->i2c_adap, 0x4a, 0x09, 0x00);
  380. } else
  381. return -EINVAL;
  382. budget_av->cur_input = input;
  383. return 0;
  384. }
  385. static int philips_su1278_ty_ci_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio)
  386. {
  387. u8 aclk = 0;
  388. u8 bclk = 0;
  389. u8 m1;
  390. aclk = 0xb5;
  391. if (srate < 2000000)
  392. bclk = 0x86;
  393. else if (srate < 5000000)
  394. bclk = 0x89;
  395. else if (srate < 15000000)
  396. bclk = 0x8f;
  397. else if (srate < 45000000)
  398. bclk = 0x95;
  399. m1 = 0x14;
  400. if (srate < 4000000)
  401. m1 = 0x10;
  402. stv0299_writereg(fe, 0x13, aclk);
  403. stv0299_writereg(fe, 0x14, bclk);
  404. stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
  405. stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
  406. stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
  407. stv0299_writereg(fe, 0x0f, 0x80 | m1);
  408. return 0;
  409. }
  410. static int philips_su1278_ty_ci_tuner_set_params(struct dvb_frontend *fe,
  411. struct dvb_frontend_parameters *params)
  412. {
  413. u32 div;
  414. u8 buf[4];
  415. struct budget *budget = (struct budget *) fe->dvb->priv;
  416. struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
  417. if ((params->frequency < 950000) || (params->frequency > 2150000))
  418. return -EINVAL;
  419. div = (params->frequency + (125 - 1)) / 125; // round correctly
  420. buf[0] = (div >> 8) & 0x7f;
  421. buf[1] = div & 0xff;
  422. buf[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
  423. buf[3] = 0x20;
  424. if (params->u.qpsk.symbol_rate < 4000000)
  425. buf[3] |= 1;
  426. if (params->frequency < 1250000)
  427. buf[3] |= 0;
  428. else if (params->frequency < 1550000)
  429. buf[3] |= 0x40;
  430. else if (params->frequency < 2050000)
  431. buf[3] |= 0x80;
  432. else if (params->frequency < 2150000)
  433. buf[3] |= 0xC0;
  434. if (fe->ops.i2c_gate_ctrl)
  435. fe->ops.i2c_gate_ctrl(fe, 1);
  436. if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
  437. return -EIO;
  438. return 0;
  439. }
  440. static u8 typhoon_cinergy1200s_inittab[] = {
  441. 0x01, 0x15,
  442. 0x02, 0x30,
  443. 0x03, 0x00,
  444. 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
  445. 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
  446. 0x06, 0x40, /* DAC not used, set to high impendance mode */
  447. 0x07, 0x00, /* DAC LSB */
  448. 0x08, 0x40, /* DiSEqC off */
  449. 0x09, 0x00, /* FIFO */
  450. 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
  451. 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
  452. 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
  453. 0x10, 0x3f, // AGC2 0x3d
  454. 0x11, 0x84,
  455. 0x12, 0xb9,
  456. 0x15, 0xc9, // lock detector threshold
  457. 0x16, 0x00,
  458. 0x17, 0x00,
  459. 0x18, 0x00,
  460. 0x19, 0x00,
  461. 0x1a, 0x00,
  462. 0x1f, 0x50,
  463. 0x20, 0x00,
  464. 0x21, 0x00,
  465. 0x22, 0x00,
  466. 0x23, 0x00,
  467. 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
  468. 0x29, 0x1e, // 1/2 threshold
  469. 0x2a, 0x14, // 2/3 threshold
  470. 0x2b, 0x0f, // 3/4 threshold
  471. 0x2c, 0x09, // 5/6 threshold
  472. 0x2d, 0x05, // 7/8 threshold
  473. 0x2e, 0x01,
  474. 0x31, 0x1f, // test all FECs
  475. 0x32, 0x19, // viterbi and synchro search
  476. 0x33, 0xfc, // rs control
  477. 0x34, 0x93, // error control
  478. 0x0f, 0x92,
  479. 0xff, 0xff
  480. };
  481. static struct stv0299_config typhoon_config = {
  482. .demod_address = 0x68,
  483. .inittab = typhoon_cinergy1200s_inittab,
  484. .mclk = 88000000UL,
  485. .invert = 0,
  486. .skip_reinit = 0,
  487. .lock_output = STV0299_LOCKOUTPUT_1,
  488. .volt13_op0_op1 = STV0299_VOLT13_OP0,
  489. .min_delay_ms = 100,
  490. .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
  491. };
  492. static struct stv0299_config cinergy_1200s_config = {
  493. .demod_address = 0x68,
  494. .inittab = typhoon_cinergy1200s_inittab,
  495. .mclk = 88000000UL,
  496. .invert = 0,
  497. .skip_reinit = 0,
  498. .lock_output = STV0299_LOCKOUTPUT_0,
  499. .volt13_op0_op1 = STV0299_VOLT13_OP0,
  500. .min_delay_ms = 100,
  501. .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
  502. };
  503. static struct stv0299_config cinergy_1200s_1894_0010_config = {
  504. .demod_address = 0x68,
  505. .inittab = typhoon_cinergy1200s_inittab,
  506. .mclk = 88000000UL,
  507. .invert = 1,
  508. .skip_reinit = 0,
  509. .lock_output = STV0299_LOCKOUTPUT_1,
  510. .volt13_op0_op1 = STV0299_VOLT13_OP0,
  511. .min_delay_ms = 100,
  512. .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
  513. };
  514. static int philips_cu1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  515. {
  516. struct budget *budget = (struct budget *) fe->dvb->priv;
  517. u8 buf[6];
  518. struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) };
  519. int i;
  520. #define CU1216_IF 36125000
  521. #define TUNER_MUL 62500
  522. u32 div = (params->frequency + CU1216_IF + TUNER_MUL / 2) / TUNER_MUL;
  523. buf[0] = (div >> 8) & 0x7f;
  524. buf[1] = div & 0xff;
  525. buf[2] = 0xce;
  526. buf[3] = (params->frequency < 150000000 ? 0x01 :
  527. params->frequency < 445000000 ? 0x02 : 0x04);
  528. buf[4] = 0xde;
  529. buf[5] = 0x20;
  530. if (fe->ops.i2c_gate_ctrl)
  531. fe->ops.i2c_gate_ctrl(fe, 1);
  532. if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
  533. return -EIO;
  534. /* wait for the pll lock */
  535. msg.flags = I2C_M_RD;
  536. msg.len = 1;
  537. for (i = 0; i < 20; i++) {
  538. if (fe->ops.i2c_gate_ctrl)
  539. fe->ops.i2c_gate_ctrl(fe, 1);
  540. if (i2c_transfer(&budget->i2c_adap, &msg, 1) == 1 && (buf[0] & 0x40))
  541. break;
  542. msleep(10);
  543. }
  544. /* switch the charge pump to the lower current */
  545. msg.flags = 0;
  546. msg.len = 2;
  547. msg.buf = &buf[2];
  548. buf[2] &= ~0x40;
  549. if (fe->ops.i2c_gate_ctrl)
  550. fe->ops.i2c_gate_ctrl(fe, 1);
  551. if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
  552. return -EIO;
  553. return 0;
  554. }
  555. static struct tda1002x_config philips_cu1216_config = {
  556. .demod_address = 0x0c,
  557. .invert = 1,
  558. };
  559. static struct tda1002x_config philips_cu1216_config_altaddress = {
  560. .demod_address = 0x0d,
  561. .invert = 0,
  562. };
  563. static struct tda10023_config philips_cu1216_tda10023_config = {
  564. .demod_address = 0x0c,
  565. .invert = 1,
  566. };
  567. static int philips_tu1216_tuner_init(struct dvb_frontend *fe)
  568. {
  569. struct budget *budget = (struct budget *) fe->dvb->priv;
  570. static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
  571. struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
  572. // setup PLL configuration
  573. if (fe->ops.i2c_gate_ctrl)
  574. fe->ops.i2c_gate_ctrl(fe, 1);
  575. if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)
  576. return -EIO;
  577. msleep(1);
  578. return 0;
  579. }
  580. static int philips_tu1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  581. {
  582. struct budget *budget = (struct budget *) fe->dvb->priv;
  583. u8 tuner_buf[4];
  584. struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf,.len =
  585. sizeof(tuner_buf) };
  586. int tuner_frequency = 0;
  587. u8 band, cp, filter;
  588. // determine charge pump
  589. tuner_frequency = params->frequency + 36166000;
  590. if (tuner_frequency < 87000000)
  591. return -EINVAL;
  592. else if (tuner_frequency < 130000000)
  593. cp = 3;
  594. else if (tuner_frequency < 160000000)
  595. cp = 5;
  596. else if (tuner_frequency < 200000000)
  597. cp = 6;
  598. else if (tuner_frequency < 290000000)
  599. cp = 3;
  600. else if (tuner_frequency < 420000000)
  601. cp = 5;
  602. else if (tuner_frequency < 480000000)
  603. cp = 6;
  604. else if (tuner_frequency < 620000000)
  605. cp = 3;
  606. else if (tuner_frequency < 830000000)
  607. cp = 5;
  608. else if (tuner_frequency < 895000000)
  609. cp = 7;
  610. else
  611. return -EINVAL;
  612. // determine band
  613. if (params->frequency < 49000000)
  614. return -EINVAL;
  615. else if (params->frequency < 161000000)
  616. band = 1;
  617. else if (params->frequency < 444000000)
  618. band = 2;
  619. else if (params->frequency < 861000000)
  620. band = 4;
  621. else
  622. return -EINVAL;
  623. // setup PLL filter
  624. switch (params->u.ofdm.bandwidth) {
  625. case BANDWIDTH_6_MHZ:
  626. filter = 0;
  627. break;
  628. case BANDWIDTH_7_MHZ:
  629. filter = 0;
  630. break;
  631. case BANDWIDTH_8_MHZ:
  632. filter = 1;
  633. break;
  634. default:
  635. return -EINVAL;
  636. }
  637. // calculate divisor
  638. // ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
  639. tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
  640. // setup tuner buffer
  641. tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
  642. tuner_buf[1] = tuner_frequency & 0xff;
  643. tuner_buf[2] = 0xca;
  644. tuner_buf[3] = (cp << 5) | (filter << 3) | band;
  645. if (fe->ops.i2c_gate_ctrl)
  646. fe->ops.i2c_gate_ctrl(fe, 1);
  647. if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)
  648. return -EIO;
  649. msleep(1);
  650. return 0;
  651. }
  652. static int philips_tu1216_request_firmware(struct dvb_frontend *fe,
  653. const struct firmware **fw, char *name)
  654. {
  655. struct budget *budget = (struct budget *) fe->dvb->priv;
  656. return request_firmware(fw, name, &budget->dev->pci->dev);
  657. }
  658. static struct tda1004x_config philips_tu1216_config = {
  659. .demod_address = 0x8,
  660. .invert = 1,
  661. .invert_oclk = 1,
  662. .xtal_freq = TDA10046_XTAL_4M,
  663. .agc_config = TDA10046_AGC_DEFAULT,
  664. .if_freq = TDA10046_FREQ_3617,
  665. .request_firmware = philips_tu1216_request_firmware,
  666. };
  667. static u8 philips_sd1878_inittab[] = {
  668. 0x01, 0x15,
  669. 0x02, 0x30,
  670. 0x03, 0x00,
  671. 0x04, 0x7d,
  672. 0x05, 0x35,
  673. 0x06, 0x40,
  674. 0x07, 0x00,
  675. 0x08, 0x43,
  676. 0x09, 0x02,
  677. 0x0C, 0x51,
  678. 0x0D, 0x82,
  679. 0x0E, 0x23,
  680. 0x10, 0x3f,
  681. 0x11, 0x84,
  682. 0x12, 0xb9,
  683. 0x15, 0xc9,
  684. 0x16, 0x19,
  685. 0x17, 0x8c,
  686. 0x18, 0x59,
  687. 0x19, 0xf8,
  688. 0x1a, 0xfe,
  689. 0x1c, 0x7f,
  690. 0x1d, 0x00,
  691. 0x1e, 0x00,
  692. 0x1f, 0x50,
  693. 0x20, 0x00,
  694. 0x21, 0x00,
  695. 0x22, 0x00,
  696. 0x23, 0x00,
  697. 0x28, 0x00,
  698. 0x29, 0x28,
  699. 0x2a, 0x14,
  700. 0x2b, 0x0f,
  701. 0x2c, 0x09,
  702. 0x2d, 0x09,
  703. 0x31, 0x1f,
  704. 0x32, 0x19,
  705. 0x33, 0xfc,
  706. 0x34, 0x93,
  707. 0xff, 0xff
  708. };
  709. static int philips_sd1878_ci_set_symbol_rate(struct dvb_frontend *fe,
  710. u32 srate, u32 ratio)
  711. {
  712. u8 aclk = 0;
  713. u8 bclk = 0;
  714. u8 m1;
  715. aclk = 0xb5;
  716. if (srate < 2000000)
  717. bclk = 0x86;
  718. else if (srate < 5000000)
  719. bclk = 0x89;
  720. else if (srate < 15000000)
  721. bclk = 0x8f;
  722. else if (srate < 45000000)
  723. bclk = 0x95;
  724. m1 = 0x14;
  725. if (srate < 4000000)
  726. m1 = 0x10;
  727. stv0299_writereg(fe, 0x0e, 0x23);
  728. stv0299_writereg(fe, 0x0f, 0x94);
  729. stv0299_writereg(fe, 0x10, 0x39);
  730. stv0299_writereg(fe, 0x13, aclk);
  731. stv0299_writereg(fe, 0x14, bclk);
  732. stv0299_writereg(fe, 0x15, 0xc9);
  733. stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
  734. stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
  735. stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
  736. stv0299_writereg(fe, 0x0f, 0x80 | m1);
  737. return 0;
  738. }
  739. static struct stv0299_config philips_sd1878_config = {
  740. .demod_address = 0x68,
  741. .inittab = philips_sd1878_inittab,
  742. .mclk = 88000000UL,
  743. .invert = 0,
  744. .skip_reinit = 0,
  745. .lock_output = STV0299_LOCKOUTPUT_1,
  746. .volt13_op0_op1 = STV0299_VOLT13_OP0,
  747. .min_delay_ms = 100,
  748. .set_symbol_rate = philips_sd1878_ci_set_symbol_rate,
  749. };
  750. /* KNC1 DVB-S (STB0899) Inittab */
  751. static const struct stb0899_s1_reg knc1_stb0899_s1_init_1[] = {
  752. { STB0899_DEV_ID , 0x81 },
  753. { STB0899_DISCNTRL1 , 0x32 },
  754. { STB0899_DISCNTRL2 , 0x80 },
  755. { STB0899_DISRX_ST0 , 0x04 },
  756. { STB0899_DISRX_ST1 , 0x00 },
  757. { STB0899_DISPARITY , 0x00 },
  758. { STB0899_DISFIFO , 0x00 },
  759. { STB0899_DISSTATUS , 0x20 },
  760. { STB0899_DISF22 , 0x8c },
  761. { STB0899_DISF22RX , 0x9a },
  762. { STB0899_SYSREG , 0x0b },
  763. { STB0899_ACRPRESC , 0x11 },
  764. { STB0899_ACRDIV1 , 0x0a },
  765. { STB0899_ACRDIV2 , 0x05 },
  766. { STB0899_DACR1 , 0x00 },
  767. { STB0899_DACR2 , 0x00 },
  768. { STB0899_OUTCFG , 0x00 },
  769. { STB0899_MODECFG , 0x00 },
  770. { STB0899_IRQSTATUS_3 , 0x30 },
  771. { STB0899_IRQSTATUS_2 , 0x00 },
  772. { STB0899_IRQSTATUS_1 , 0x00 },
  773. { STB0899_IRQSTATUS_0 , 0x00 },
  774. { STB0899_IRQMSK_3 , 0xf3 },
  775. { STB0899_IRQMSK_2 , 0xfc },
  776. { STB0899_IRQMSK_1 , 0xff },
  777. { STB0899_IRQMSK_0 , 0xff },
  778. { STB0899_IRQCFG , 0x00 },
  779. { STB0899_I2CCFG , 0x88 },
  780. { STB0899_I2CRPT , 0x58 }, /* Repeater=8, Stop=disabled */
  781. { STB0899_IOPVALUE5 , 0x00 },
  782. { STB0899_IOPVALUE4 , 0x20 },
  783. { STB0899_IOPVALUE3 , 0xc9 },
  784. { STB0899_IOPVALUE2 , 0x90 },
  785. { STB0899_IOPVALUE1 , 0x40 },
  786. { STB0899_IOPVALUE0 , 0x00 },
  787. { STB0899_GPIO00CFG , 0x82 },
  788. { STB0899_GPIO01CFG , 0x82 },
  789. { STB0899_GPIO02CFG , 0x82 },
  790. { STB0899_GPIO03CFG , 0x82 },
  791. { STB0899_GPIO04CFG , 0x82 },
  792. { STB0899_GPIO05CFG , 0x82 },
  793. { STB0899_GPIO06CFG , 0x82 },
  794. { STB0899_GPIO07CFG , 0x82 },
  795. { STB0899_GPIO08CFG , 0x82 },
  796. { STB0899_GPIO09CFG , 0x82 },
  797. { STB0899_GPIO10CFG , 0x82 },
  798. { STB0899_GPIO11CFG , 0x82 },
  799. { STB0899_GPIO12CFG , 0x82 },
  800. { STB0899_GPIO13CFG , 0x82 },
  801. { STB0899_GPIO14CFG , 0x82 },
  802. { STB0899_GPIO15CFG , 0x82 },
  803. { STB0899_GPIO16CFG , 0x82 },
  804. { STB0899_GPIO17CFG , 0x82 },
  805. { STB0899_GPIO18CFG , 0x82 },
  806. { STB0899_GPIO19CFG , 0x82 },
  807. { STB0899_GPIO20CFG , 0x82 },
  808. { STB0899_SDATCFG , 0xb8 },
  809. { STB0899_SCLTCFG , 0xba },
  810. { STB0899_AGCRFCFG , 0x08 }, /* 0x1c */
  811. { STB0899_GPIO22 , 0x82 }, /* AGCBB2CFG */
  812. { STB0899_GPIO21 , 0x91 }, /* AGCBB1CFG */
  813. { STB0899_DIRCLKCFG , 0x82 },
  814. { STB0899_CLKOUT27CFG , 0x7e },
  815. { STB0899_STDBYCFG , 0x82 },
  816. { STB0899_CS0CFG , 0x82 },
  817. { STB0899_CS1CFG , 0x82 },
  818. { STB0899_DISEQCOCFG , 0x20 },
  819. { STB0899_GPIO32CFG , 0x82 },
  820. { STB0899_GPIO33CFG , 0x82 },
  821. { STB0899_GPIO34CFG , 0x82 },
  822. { STB0899_GPIO35CFG , 0x82 },
  823. { STB0899_GPIO36CFG , 0x82 },
  824. { STB0899_GPIO37CFG , 0x82 },
  825. { STB0899_GPIO38CFG , 0x82 },
  826. { STB0899_GPIO39CFG , 0x82 },
  827. { STB0899_NCOARSE , 0x15 }, /* 0x15 = 27 Mhz Clock, F/3 = 198MHz, F/6 = 99MHz */
  828. { STB0899_SYNTCTRL , 0x02 }, /* 0x00 = CLK from CLKI, 0x02 = CLK from XTALI */
  829. { STB0899_FILTCTRL , 0x00 },
  830. { STB0899_SYSCTRL , 0x00 },
  831. { STB0899_STOPCLK1 , 0x20 },
  832. { STB0899_STOPCLK2 , 0x00 },
  833. { STB0899_INTBUFSTATUS , 0x00 },
  834. { STB0899_INTBUFCTRL , 0x0a },
  835. { 0xffff , 0xff },
  836. };
  837. static const struct stb0899_s1_reg knc1_stb0899_s1_init_3[] = {
  838. { STB0899_DEMOD , 0x00 },
  839. { STB0899_RCOMPC , 0xc9 },
  840. { STB0899_AGC1CN , 0x41 },
  841. { STB0899_AGC1REF , 0x08 },
  842. { STB0899_RTC , 0x7a },
  843. { STB0899_TMGCFG , 0x4e },
  844. { STB0899_AGC2REF , 0x33 },
  845. { STB0899_TLSR , 0x84 },
  846. { STB0899_CFD , 0xee },
  847. { STB0899_ACLC , 0x87 },
  848. { STB0899_BCLC , 0x94 },
  849. { STB0899_EQON , 0x41 },
  850. { STB0899_LDT , 0xdd },
  851. { STB0899_LDT2 , 0xc9 },
  852. { STB0899_EQUALREF , 0xb4 },
  853. { STB0899_TMGRAMP , 0x10 },
  854. { STB0899_TMGTHD , 0x30 },
  855. { STB0899_IDCCOMP , 0xfb },
  856. { STB0899_QDCCOMP , 0x03 },
  857. { STB0899_POWERI , 0x3b },
  858. { STB0899_POWERQ , 0x3d },
  859. { STB0899_RCOMP , 0x81 },
  860. { STB0899_AGCIQIN , 0x80 },
  861. { STB0899_AGC2I1 , 0x04 },
  862. { STB0899_AGC2I2 , 0xf5 },
  863. { STB0899_TLIR , 0x25 },
  864. { STB0899_RTF , 0x80 },
  865. { STB0899_DSTATUS , 0x00 },
  866. { STB0899_LDI , 0xca },
  867. { STB0899_CFRM , 0xf1 },
  868. { STB0899_CFRL , 0xf3 },
  869. { STB0899_NIRM , 0x2a },
  870. { STB0899_NIRL , 0x05 },
  871. { STB0899_ISYMB , 0x17 },
  872. { STB0899_QSYMB , 0xfa },
  873. { STB0899_SFRH , 0x2f },
  874. { STB0899_SFRM , 0x68 },
  875. { STB0899_SFRL , 0x40 },
  876. { STB0899_SFRUPH , 0x2f },
  877. { STB0899_SFRUPM , 0x68 },
  878. { STB0899_SFRUPL , 0x40 },
  879. { STB0899_EQUAI1 , 0xfd },
  880. { STB0899_EQUAQ1 , 0x04 },
  881. { STB0899_EQUAI2 , 0x0f },
  882. { STB0899_EQUAQ2 , 0xff },
  883. { STB0899_EQUAI3 , 0xdf },
  884. { STB0899_EQUAQ3 , 0xfa },
  885. { STB0899_EQUAI4 , 0x37 },
  886. { STB0899_EQUAQ4 , 0x0d },
  887. { STB0899_EQUAI5 , 0xbd },
  888. { STB0899_EQUAQ5 , 0xf7 },
  889. { STB0899_DSTATUS2 , 0x00 },
  890. { STB0899_VSTATUS , 0x00 },
  891. { STB0899_VERROR , 0xff },
  892. { STB0899_IQSWAP , 0x2a },
  893. { STB0899_ECNT1M , 0x00 },
  894. { STB0899_ECNT1L , 0x00 },
  895. { STB0899_ECNT2M , 0x00 },
  896. { STB0899_ECNT2L , 0x00 },
  897. { STB0899_ECNT3M , 0x00 },
  898. { STB0899_ECNT3L , 0x00 },
  899. { STB0899_FECAUTO1 , 0x06 },
  900. { STB0899_FECM , 0x01 },
  901. { STB0899_VTH12 , 0xf0 },
  902. { STB0899_VTH23 , 0xa0 },
  903. { STB0899_VTH34 , 0x78 },
  904. { STB0899_VTH56 , 0x4e },
  905. { STB0899_VTH67 , 0x48 },
  906. { STB0899_VTH78 , 0x38 },
  907. { STB0899_PRVIT , 0xff },
  908. { STB0899_VITSYNC , 0x19 },
  909. { STB0899_RSULC , 0xb1 }, /* DVB = 0xb1, DSS = 0xa1 */
  910. { STB0899_TSULC , 0x42 },
  911. { STB0899_RSLLC , 0x40 },
  912. { STB0899_TSLPL , 0x12 },
  913. { STB0899_TSCFGH , 0x0c },
  914. { STB0899_TSCFGM , 0x00 },
  915. { STB0899_TSCFGL , 0x0c },
  916. { STB0899_TSOUT , 0x4d }, /* 0x0d for CAM */
  917. { STB0899_RSSYNCDEL , 0x00 },
  918. { STB0899_TSINHDELH , 0x02 },
  919. { STB0899_TSINHDELM , 0x00 },
  920. { STB0899_TSINHDELL , 0x00 },
  921. { STB0899_TSLLSTKM , 0x00 },
  922. { STB0899_TSLLSTKL , 0x00 },
  923. { STB0899_TSULSTKM , 0x00 },
  924. { STB0899_TSULSTKL , 0xab },
  925. { STB0899_PCKLENUL , 0x00 },
  926. { STB0899_PCKLENLL , 0xcc },
  927. { STB0899_RSPCKLEN , 0xcc },
  928. { STB0899_TSSTATUS , 0x80 },
  929. { STB0899_ERRCTRL1 , 0xb6 },
  930. { STB0899_ERRCTRL2 , 0x96 },
  931. { STB0899_ERRCTRL3 , 0x89 },
  932. { STB0899_DMONMSK1 , 0x27 },
  933. { STB0899_DMONMSK0 , 0x03 },
  934. { STB0899_DEMAPVIT , 0x5c },
  935. { STB0899_PLPARM , 0x1f },
  936. { STB0899_PDELCTRL , 0x48 },
  937. { STB0899_PDELCTRL2 , 0x00 },
  938. { STB0899_BBHCTRL1 , 0x00 },
  939. { STB0899_BBHCTRL2 , 0x00 },
  940. { STB0899_HYSTTHRESH , 0x77 },
  941. { STB0899_MATCSTM , 0x00 },
  942. { STB0899_MATCSTL , 0x00 },
  943. { STB0899_UPLCSTM , 0x00 },
  944. { STB0899_UPLCSTL , 0x00 },
  945. { STB0899_DFLCSTM , 0x00 },
  946. { STB0899_DFLCSTL , 0x00 },
  947. { STB0899_SYNCCST , 0x00 },
  948. { STB0899_SYNCDCSTM , 0x00 },
  949. { STB0899_SYNCDCSTL , 0x00 },
  950. { STB0899_ISI_ENTRY , 0x00 },
  951. { STB0899_ISI_BIT_EN , 0x00 },
  952. { STB0899_MATSTRM , 0x00 },
  953. { STB0899_MATSTRL , 0x00 },
  954. { STB0899_UPLSTRM , 0x00 },
  955. { STB0899_UPLSTRL , 0x00 },
  956. { STB0899_DFLSTRM , 0x00 },
  957. { STB0899_DFLSTRL , 0x00 },
  958. { STB0899_SYNCSTR , 0x00 },
  959. { STB0899_SYNCDSTRM , 0x00 },
  960. { STB0899_SYNCDSTRL , 0x00 },
  961. { STB0899_CFGPDELSTATUS1 , 0x10 },
  962. { STB0899_CFGPDELSTATUS2 , 0x00 },
  963. { STB0899_BBFERRORM , 0x00 },
  964. { STB0899_BBFERRORL , 0x00 },
  965. { STB0899_UPKTERRORM , 0x00 },
  966. { STB0899_UPKTERRORL , 0x00 },
  967. { 0xffff , 0xff },
  968. };
  969. /* STB0899 demodulator config for the KNC1 and clones */
  970. static struct stb0899_config knc1_dvbs2_config = {
  971. .init_dev = knc1_stb0899_s1_init_1,
  972. .init_s2_demod = stb0899_s2_init_2,
  973. .init_s1_demod = knc1_stb0899_s1_init_3,
  974. .init_s2_fec = stb0899_s2_init_4,
  975. .init_tst = stb0899_s1_init_5,
  976. .postproc = NULL,
  977. .demod_address = 0x68,
  978. // .ts_output_mode = STB0899_OUT_PARALLEL, /* types = SERIAL/PARALLEL */
  979. .block_sync_mode = STB0899_SYNC_FORCED, /* DSS, SYNC_FORCED/UNSYNCED */
  980. // .ts_pfbit_toggle = STB0899_MPEG_NORMAL, /* DirecTV, MPEG toggling seq */
  981. .xtal_freq = 27000000,
  982. .inversion = IQ_SWAP_OFF, /* 1 */
  983. .lo_clk = 76500000,
  984. .hi_clk = 90000000,
  985. .esno_ave = STB0899_DVBS2_ESNO_AVE,
  986. .esno_quant = STB0899_DVBS2_ESNO_QUANT,
  987. .avframes_coarse = STB0899_DVBS2_AVFRAMES_COARSE,
  988. .avframes_fine = STB0899_DVBS2_AVFRAMES_FINE,
  989. .miss_threshold = STB0899_DVBS2_MISS_THRESHOLD,
  990. .uwp_threshold_acq = STB0899_DVBS2_UWP_THRESHOLD_ACQ,
  991. .uwp_threshold_track = STB0899_DVBS2_UWP_THRESHOLD_TRACK,
  992. .uwp_threshold_sof = STB0899_DVBS2_UWP_THRESHOLD_SOF,
  993. .sof_search_timeout = STB0899_DVBS2_SOF_SEARCH_TIMEOUT,
  994. .btr_nco_bits = STB0899_DVBS2_BTR_NCO_BITS,
  995. .btr_gain_shift_offset = STB0899_DVBS2_BTR_GAIN_SHIFT_OFFSET,
  996. .crl_nco_bits = STB0899_DVBS2_CRL_NCO_BITS,
  997. .ldpc_max_iter = STB0899_DVBS2_LDPC_MAX_ITER,
  998. .tuner_get_frequency = tda8261_get_frequency,
  999. .tuner_set_frequency = tda8261_set_frequency,
  1000. .tuner_set_bandwidth = NULL,
  1001. .tuner_get_bandwidth = tda8261_get_bandwidth,
  1002. .tuner_set_rfsiggain = NULL
  1003. };
  1004. /*
  1005. * SD1878/SHA tuner config
  1006. * 1F, Single I/P, Horizontal mount, High Sensitivity
  1007. */
  1008. static const struct tda8261_config sd1878c_config = {
  1009. // .name = "SD1878/SHA",
  1010. .addr = 0x60,
  1011. .step_size = TDA8261_STEP_1000 /* kHz */
  1012. };
  1013. static u8 read_pwm(struct budget_av *budget_av)
  1014. {
  1015. u8 b = 0xff;
  1016. u8 pwm;
  1017. struct i2c_msg msg[] = { {.addr = 0x50,.flags = 0,.buf = &b,.len = 1},
  1018. {.addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1}
  1019. };
  1020. if ((i2c_transfer(&budget_av->budget.i2c_adap, msg, 2) != 2)
  1021. || (pwm == 0xff))
  1022. pwm = 0x48;
  1023. return pwm;
  1024. }
  1025. #define SUBID_DVBS_KNC1 0x0010
  1026. #define SUBID_DVBS_KNC1_PLUS 0x0011
  1027. #define SUBID_DVBS_TYPHOON 0x4f56
  1028. #define SUBID_DVBS_CINERGY1200 0x1154
  1029. #define SUBID_DVBS_CYNERGY1200N 0x1155
  1030. #define SUBID_DVBS_TV_STAR 0x0014
  1031. #define SUBID_DVBS_TV_STAR_PLUS_X4 0x0015
  1032. #define SUBID_DVBS_TV_STAR_CI 0x0016
  1033. #define SUBID_DVBS2_KNC1 0x0018
  1034. #define SUBID_DVBS2_KNC1_OEM 0x0019
  1035. #define SUBID_DVBS_EASYWATCH_1 0x001a
  1036. #define SUBID_DVBS_EASYWATCH_2 0x001b
  1037. #define SUBID_DVBS2_EASYWATCH 0x001d
  1038. #define SUBID_DVBS_EASYWATCH 0x001e
  1039. #define SUBID_DVBC_EASYWATCH 0x002a
  1040. #define SUBID_DVBC_EASYWATCH_MK3 0x002c
  1041. #define SUBID_DVBC_KNC1 0x0020
  1042. #define SUBID_DVBC_KNC1_PLUS 0x0021
  1043. #define SUBID_DVBC_KNC1_MK3 0x0022
  1044. #define SUBID_DVBC_KNC1_PLUS_MK3 0x0023
  1045. #define SUBID_DVBC_CINERGY1200 0x1156
  1046. #define SUBID_DVBC_CINERGY1200_MK3 0x1176
  1047. #define SUBID_DVBT_EASYWATCH 0x003a
  1048. #define SUBID_DVBT_KNC1_PLUS 0x0031
  1049. #define SUBID_DVBT_KNC1 0x0030
  1050. #define SUBID_DVBT_CINERGY1200 0x1157
  1051. static void frontend_init(struct budget_av *budget_av)
  1052. {
  1053. struct saa7146_dev * saa = budget_av->budget.dev;
  1054. struct dvb_frontend * fe = NULL;
  1055. /* Enable / PowerON Frontend */
  1056. saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
  1057. /* Wait for PowerON */
  1058. msleep(100);
  1059. /* additional setup necessary for the PLUS cards */
  1060. switch (saa->pci->subsystem_device) {
  1061. case SUBID_DVBS_KNC1_PLUS:
  1062. case SUBID_DVBC_KNC1_PLUS:
  1063. case SUBID_DVBT_KNC1_PLUS:
  1064. case SUBID_DVBC_EASYWATCH:
  1065. case SUBID_DVBC_KNC1_PLUS_MK3:
  1066. case SUBID_DVBS2_KNC1:
  1067. case SUBID_DVBS2_KNC1_OEM:
  1068. case SUBID_DVBS2_EASYWATCH:
  1069. saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTHI);
  1070. break;
  1071. }
  1072. switch (saa->pci->subsystem_device) {
  1073. case SUBID_DVBS_KNC1:
  1074. /*
  1075. * maybe that setting is needed for other dvb-s cards as well,
  1076. * but so far it has been only confirmed for this type
  1077. */
  1078. budget_av->reinitialise_demod = 1;
  1079. /* fall through */
  1080. case SUBID_DVBS_KNC1_PLUS:
  1081. case SUBID_DVBS_EASYWATCH_1:
  1082. if (saa->pci->subsystem_vendor == 0x1894) {
  1083. fe = dvb_attach(stv0299_attach, &cinergy_1200s_1894_0010_config,
  1084. &budget_av->budget.i2c_adap);
  1085. if (fe) {
  1086. dvb_attach(tua6100_attach, fe, 0x60, &budget_av->budget.i2c_adap);
  1087. }
  1088. } else {
  1089. fe = dvb_attach(stv0299_attach, &typhoon_config,
  1090. &budget_av->budget.i2c_adap);
  1091. if (fe) {
  1092. fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
  1093. }
  1094. }
  1095. break;
  1096. case SUBID_DVBS_TV_STAR:
  1097. case SUBID_DVBS_TV_STAR_PLUS_X4:
  1098. case SUBID_DVBS_TV_STAR_CI:
  1099. case SUBID_DVBS_CYNERGY1200N:
  1100. case SUBID_DVBS_EASYWATCH:
  1101. case SUBID_DVBS_EASYWATCH_2:
  1102. fe = dvb_attach(stv0299_attach, &philips_sd1878_config,
  1103. &budget_av->budget.i2c_adap);
  1104. if (fe) {
  1105. dvb_attach(dvb_pll_attach, fe, 0x60,
  1106. &budget_av->budget.i2c_adap,
  1107. DVB_PLL_PHILIPS_SD1878_TDA8261);
  1108. }
  1109. break;
  1110. case SUBID_DVBS_TYPHOON:
  1111. fe = dvb_attach(stv0299_attach, &typhoon_config,
  1112. &budget_av->budget.i2c_adap);
  1113. if (fe) {
  1114. fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
  1115. }
  1116. break;
  1117. case SUBID_DVBS2_KNC1:
  1118. case SUBID_DVBS2_KNC1_OEM:
  1119. case SUBID_DVBS2_EASYWATCH:
  1120. budget_av->reinitialise_demod = 1;
  1121. if ((fe = dvb_attach(stb0899_attach, &knc1_dvbs2_config, &budget_av->budget.i2c_adap)))
  1122. dvb_attach(tda8261_attach, fe, &sd1878c_config, &budget_av->budget.i2c_adap);
  1123. break;
  1124. case SUBID_DVBS_CINERGY1200:
  1125. fe = dvb_attach(stv0299_attach, &cinergy_1200s_config,
  1126. &budget_av->budget.i2c_adap);
  1127. if (fe) {
  1128. fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
  1129. }
  1130. break;
  1131. case SUBID_DVBC_KNC1:
  1132. case SUBID_DVBC_KNC1_PLUS:
  1133. case SUBID_DVBC_CINERGY1200:
  1134. case SUBID_DVBC_EASYWATCH:
  1135. budget_av->reinitialise_demod = 1;
  1136. budget_av->budget.dev->i2c_bitrate = SAA7146_I2C_BUS_BIT_RATE_240;
  1137. fe = dvb_attach(tda10021_attach, &philips_cu1216_config,
  1138. &budget_av->budget.i2c_adap,
  1139. read_pwm(budget_av));
  1140. if (fe == NULL)
  1141. fe = dvb_attach(tda10021_attach, &philips_cu1216_config_altaddress,
  1142. &budget_av->budget.i2c_adap,
  1143. read_pwm(budget_av));
  1144. if (fe) {
  1145. fe->ops.tuner_ops.set_params = philips_cu1216_tuner_set_params;
  1146. }
  1147. break;
  1148. case SUBID_DVBC_EASYWATCH_MK3:
  1149. case SUBID_DVBC_CINERGY1200_MK3:
  1150. case SUBID_DVBC_KNC1_MK3:
  1151. case SUBID_DVBC_KNC1_PLUS_MK3:
  1152. budget_av->reinitialise_demod = 1;
  1153. budget_av->budget.dev->i2c_bitrate = SAA7146_I2C_BUS_BIT_RATE_240;
  1154. fe = dvb_attach(tda10023_attach,
  1155. &philips_cu1216_tda10023_config,
  1156. &budget_av->budget.i2c_adap,
  1157. read_pwm(budget_av));
  1158. if (fe) {
  1159. fe->ops.tuner_ops.set_params = philips_cu1216_tuner_set_params;
  1160. }
  1161. break;
  1162. case SUBID_DVBT_EASYWATCH:
  1163. case SUBID_DVBT_KNC1:
  1164. case SUBID_DVBT_KNC1_PLUS:
  1165. case SUBID_DVBT_CINERGY1200:
  1166. budget_av->reinitialise_demod = 1;
  1167. fe = dvb_attach(tda10046_attach, &philips_tu1216_config,
  1168. &budget_av->budget.i2c_adap);
  1169. if (fe) {
  1170. fe->ops.tuner_ops.init = philips_tu1216_tuner_init;
  1171. fe->ops.tuner_ops.set_params = philips_tu1216_tuner_set_params;
  1172. }
  1173. break;
  1174. }
  1175. if (fe == NULL) {
  1176. printk(KERN_ERR "budget-av: A frontend driver was not found "
  1177. "for device [%04x:%04x] subsystem [%04x:%04x]\n",
  1178. saa->pci->vendor,
  1179. saa->pci->device,
  1180. saa->pci->subsystem_vendor,
  1181. saa->pci->subsystem_device);
  1182. return;
  1183. }
  1184. budget_av->budget.dvb_frontend = fe;
  1185. if (dvb_register_frontend(&budget_av->budget.dvb_adapter,
  1186. budget_av->budget.dvb_frontend)) {
  1187. printk(KERN_ERR "budget-av: Frontend registration failed!\n");
  1188. dvb_frontend_detach(budget_av->budget.dvb_frontend);
  1189. budget_av->budget.dvb_frontend = NULL;
  1190. }
  1191. }
  1192. static void budget_av_irq(struct saa7146_dev *dev, u32 * isr)
  1193. {
  1194. struct budget_av *budget_av = (struct budget_av *) dev->ext_priv;
  1195. dprintk(8, "dev: %p, budget_av: %p\n", dev, budget_av);
  1196. if (*isr & MASK_10)
  1197. ttpci_budget_irq10_handler(dev, isr);
  1198. }
  1199. static int budget_av_detach(struct saa7146_dev *dev)
  1200. {
  1201. struct budget_av *budget_av = (struct budget_av *) dev->ext_priv;
  1202. int err;
  1203. dprintk(2, "dev: %p\n", dev);
  1204. if (1 == budget_av->has_saa7113) {
  1205. saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTLO);
  1206. msleep(200);
  1207. saa7146_unregister_device(&budget_av->vd, dev);
  1208. saa7146_vv_release(dev);
  1209. }
  1210. if (budget_av->budget.ci_present)
  1211. ciintf_deinit(budget_av);
  1212. if (budget_av->budget.dvb_frontend != NULL) {
  1213. dvb_unregister_frontend(budget_av->budget.dvb_frontend);
  1214. dvb_frontend_detach(budget_av->budget.dvb_frontend);
  1215. }
  1216. err = ttpci_budget_deinit(&budget_av->budget);
  1217. kfree(budget_av);
  1218. return err;
  1219. }
  1220. #define KNC1_INPUTS 2
  1221. static struct v4l2_input knc1_inputs[KNC1_INPUTS] = {
  1222. { 0, "Composite", V4L2_INPUT_TYPE_TUNER, 1, 0,
  1223. V4L2_STD_PAL_BG | V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD },
  1224. { 1, "S-Video", V4L2_INPUT_TYPE_CAMERA, 2, 0,
  1225. V4L2_STD_PAL_BG | V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD },
  1226. };
  1227. static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i)
  1228. {
  1229. dprintk(1, "VIDIOC_ENUMINPUT %d.\n", i->index);
  1230. if (i->index >= KNC1_INPUTS)
  1231. return -EINVAL;
  1232. memcpy(i, &knc1_inputs[i->index], sizeof(struct v4l2_input));
  1233. return 0;
  1234. }
  1235. static int vidioc_g_input(struct file *file, void *fh, unsigned int *i)
  1236. {
  1237. struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
  1238. struct budget_av *budget_av = (struct budget_av *)dev->ext_priv;
  1239. *i = budget_av->cur_input;
  1240. dprintk(1, "VIDIOC_G_INPUT %d.\n", *i);
  1241. return 0;
  1242. }
  1243. static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
  1244. {
  1245. struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
  1246. struct budget_av *budget_av = (struct budget_av *)dev->ext_priv;
  1247. dprintk(1, "VIDIOC_S_INPUT %d.\n", input);
  1248. return saa7113_setinput(budget_av, input);
  1249. }
  1250. static struct saa7146_ext_vv vv_data;
  1251. static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data *info)
  1252. {
  1253. struct budget_av *budget_av;
  1254. u8 *mac;
  1255. int err;
  1256. dprintk(2, "dev: %p\n", dev);
  1257. if (!(budget_av = kzalloc(sizeof(struct budget_av), GFP_KERNEL)))
  1258. return -ENOMEM;
  1259. budget_av->has_saa7113 = 0;
  1260. budget_av->budget.ci_present = 0;
  1261. dev->ext_priv = budget_av;
  1262. err = ttpci_budget_init(&budget_av->budget, dev, info, THIS_MODULE,
  1263. adapter_nr);
  1264. if (err) {
  1265. kfree(budget_av);
  1266. return err;
  1267. }
  1268. /* knc1 initialization */
  1269. saa7146_write(dev, DD1_STREAM_B, 0x04000000);
  1270. saa7146_write(dev, DD1_INIT, 0x07000600);
  1271. saa7146_write(dev, MC2, MASK_09 | MASK_25 | MASK_10 | MASK_26);
  1272. if (saa7113_init(budget_av) == 0) {
  1273. budget_av->has_saa7113 = 1;
  1274. if (0 != saa7146_vv_init(dev, &vv_data)) {
  1275. /* fixme: proper cleanup here */
  1276. ERR(("cannot init vv subsystem.\n"));
  1277. return err;
  1278. }
  1279. vv_data.ops.vidioc_enum_input = vidioc_enum_input;
  1280. vv_data.ops.vidioc_g_input = vidioc_g_input;
  1281. vv_data.ops.vidioc_s_input = vidioc_s_input;
  1282. if ((err = saa7146_register_device(&budget_av->vd, dev, "knc1", VFL_TYPE_GRABBER))) {
  1283. /* fixme: proper cleanup here */
  1284. ERR(("cannot register capture v4l2 device.\n"));
  1285. saa7146_vv_release(dev);
  1286. return err;
  1287. }
  1288. /* beware: this modifies dev->vv ... */
  1289. saa7146_set_hps_source_and_sync(dev, SAA7146_HPS_SOURCE_PORT_A,
  1290. SAA7146_HPS_SYNC_PORT_A);
  1291. saa7113_setinput(budget_av, 0);
  1292. }
  1293. /* fixme: find some sane values here... */
  1294. saa7146_write(dev, PCI_BT_V1, 0x1c00101f);
  1295. mac = budget_av->budget.dvb_adapter.proposed_mac;
  1296. if (i2c_readregs(&budget_av->budget.i2c_adap, 0xa0, 0x30, mac, 6)) {
  1297. printk(KERN_ERR "KNC1-%d: Could not read MAC from KNC1 card\n",
  1298. budget_av->budget.dvb_adapter.num);
  1299. memset(mac, 0, 6);
  1300. } else {
  1301. printk(KERN_INFO "KNC1-%d: MAC addr = %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
  1302. budget_av->budget.dvb_adapter.num,
  1303. mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  1304. }
  1305. budget_av->budget.dvb_adapter.priv = budget_av;
  1306. frontend_init(budget_av);
  1307. ciintf_init(budget_av);
  1308. ttpci_budget_init_hooks(&budget_av->budget);
  1309. return 0;
  1310. }
  1311. static struct saa7146_standard standard[] = {
  1312. {.name = "PAL",.id = V4L2_STD_PAL,
  1313. .v_offset = 0x17,.v_field = 288,
  1314. .h_offset = 0x14,.h_pixels = 680,
  1315. .v_max_out = 576,.h_max_out = 768 },
  1316. {.name = "NTSC",.id = V4L2_STD_NTSC,
  1317. .v_offset = 0x16,.v_field = 240,
  1318. .h_offset = 0x06,.h_pixels = 708,
  1319. .v_max_out = 480,.h_max_out = 640, },
  1320. };
  1321. static struct saa7146_ext_vv vv_data = {
  1322. .inputs = 2,
  1323. .capabilities = 0, // perhaps later: V4L2_CAP_VBI_CAPTURE, but that need tweaking with the saa7113
  1324. .flags = 0,
  1325. .stds = &standard[0],
  1326. .num_stds = ARRAY_SIZE(standard),
  1327. };
  1328. static struct saa7146_extension budget_extension;
  1329. MAKE_BUDGET_INFO(knc1s, "KNC1 DVB-S", BUDGET_KNC1S);
  1330. MAKE_BUDGET_INFO(knc1s2,"KNC1 DVB-S2", BUDGET_KNC1S2);
  1331. MAKE_BUDGET_INFO(sates2,"Satelco EasyWatch DVB-S2", BUDGET_KNC1S2);
  1332. MAKE_BUDGET_INFO(knc1c, "KNC1 DVB-C", BUDGET_KNC1C);
  1333. MAKE_BUDGET_INFO(knc1t, "KNC1 DVB-T", BUDGET_KNC1T);
  1334. MAKE_BUDGET_INFO(kncxs, "KNC TV STAR DVB-S", BUDGET_TVSTAR);
  1335. MAKE_BUDGET_INFO(satewpls, "Satelco EasyWatch DVB-S light", BUDGET_TVSTAR);
  1336. MAKE_BUDGET_INFO(satewpls1, "Satelco EasyWatch DVB-S light", BUDGET_KNC1S);
  1337. MAKE_BUDGET_INFO(satewps, "Satelco EasyWatch DVB-S", BUDGET_KNC1S);
  1338. MAKE_BUDGET_INFO(satewplc, "Satelco EasyWatch DVB-C", BUDGET_KNC1CP);
  1339. MAKE_BUDGET_INFO(satewcmk3, "Satelco EasyWatch DVB-C MK3", BUDGET_KNC1C_MK3);
  1340. MAKE_BUDGET_INFO(satewt, "Satelco EasyWatch DVB-T", BUDGET_KNC1T);
  1341. MAKE_BUDGET_INFO(knc1sp, "KNC1 DVB-S Plus", BUDGET_KNC1SP);
  1342. MAKE_BUDGET_INFO(knc1spx4, "KNC1 DVB-S Plus X4", BUDGET_KNC1SP);
  1343. MAKE_BUDGET_INFO(knc1cp, "KNC1 DVB-C Plus", BUDGET_KNC1CP);
  1344. MAKE_BUDGET_INFO(knc1cmk3, "KNC1 DVB-C MK3", BUDGET_KNC1C_MK3);
  1345. MAKE_BUDGET_INFO(knc1cpmk3, "KNC1 DVB-C Plus MK3", BUDGET_KNC1CP_MK3);
  1346. MAKE_BUDGET_INFO(knc1tp, "KNC1 DVB-T Plus", BUDGET_KNC1TP);
  1347. MAKE_BUDGET_INFO(cin1200s, "TerraTec Cinergy 1200 DVB-S", BUDGET_CIN1200S);
  1348. MAKE_BUDGET_INFO(cin1200sn, "TerraTec Cinergy 1200 DVB-S", BUDGET_CIN1200S);
  1349. MAKE_BUDGET_INFO(cin1200c, "Terratec Cinergy 1200 DVB-C", BUDGET_CIN1200C);
  1350. MAKE_BUDGET_INFO(cin1200cmk3, "Terratec Cinergy 1200 DVB-C MK3", BUDGET_CIN1200C_MK3);
  1351. MAKE_BUDGET_INFO(cin1200t, "Terratec Cinergy 1200 DVB-T", BUDGET_CIN1200T);
  1352. static struct pci_device_id pci_tbl[] = {
  1353. MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x4f56),
  1354. MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x0010),
  1355. MAKE_EXTENSION_PCI(knc1s, 0x1894, 0x0010),
  1356. MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011),
  1357. MAKE_EXTENSION_PCI(knc1sp, 0x1894, 0x0011),
  1358. MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0014),
  1359. MAKE_EXTENSION_PCI(knc1spx4, 0x1894, 0x0015),
  1360. MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0016),
  1361. MAKE_EXTENSION_PCI(knc1s2, 0x1894, 0x0018),
  1362. MAKE_EXTENSION_PCI(knc1s2, 0x1894, 0x0019),
  1363. MAKE_EXTENSION_PCI(sates2, 0x1894, 0x001d),
  1364. MAKE_EXTENSION_PCI(satewpls, 0x1894, 0x001e),
  1365. MAKE_EXTENSION_PCI(satewpls1, 0x1894, 0x001a),
  1366. MAKE_EXTENSION_PCI(satewps, 0x1894, 0x001b),
  1367. MAKE_EXTENSION_PCI(satewplc, 0x1894, 0x002a),
  1368. MAKE_EXTENSION_PCI(satewcmk3, 0x1894, 0x002c),
  1369. MAKE_EXTENSION_PCI(satewt, 0x1894, 0x003a),
  1370. MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020),
  1371. MAKE_EXTENSION_PCI(knc1cp, 0x1894, 0x0021),
  1372. MAKE_EXTENSION_PCI(knc1cmk3, 0x1894, 0x0022),
  1373. MAKE_EXTENSION_PCI(knc1cpmk3, 0x1894, 0x0023),
  1374. MAKE_EXTENSION_PCI(knc1t, 0x1894, 0x0030),
  1375. MAKE_EXTENSION_PCI(knc1tp, 0x1894, 0x0031),
  1376. MAKE_EXTENSION_PCI(cin1200s, 0x153b, 0x1154),
  1377. MAKE_EXTENSION_PCI(cin1200sn, 0x153b, 0x1155),
  1378. MAKE_EXTENSION_PCI(cin1200c, 0x153b, 0x1156),
  1379. MAKE_EXTENSION_PCI(cin1200cmk3, 0x153b, 0x1176),
  1380. MAKE_EXTENSION_PCI(cin1200t, 0x153b, 0x1157),
  1381. {
  1382. .vendor = 0,
  1383. }
  1384. };
  1385. MODULE_DEVICE_TABLE(pci, pci_tbl);
  1386. static struct saa7146_extension budget_extension = {
  1387. .name = "budget_av",
  1388. .flags = SAA7146_USE_I2C_IRQ,
  1389. .pci_tbl = pci_tbl,
  1390. .module = THIS_MODULE,
  1391. .attach = budget_av_attach,
  1392. .detach = budget_av_detach,
  1393. .irq_mask = MASK_10,
  1394. .irq_func = budget_av_irq,
  1395. };
  1396. static int __init budget_av_init(void)
  1397. {
  1398. return saa7146_register_extension(&budget_extension);
  1399. }
  1400. static void __exit budget_av_exit(void)
  1401. {
  1402. saa7146_unregister_extension(&budget_extension);
  1403. }
  1404. module_init(budget_av_init);
  1405. module_exit(budget_av_exit);
  1406. MODULE_LICENSE("GPL");
  1407. MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, Michael Hunold, others");
  1408. MODULE_DESCRIPTION("driver for the SAA7146 based so-called "
  1409. "budget PCI DVB w/ analog input and CI-module (e.g. the KNC cards)");