budget-av.c 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637
  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. * To obtain the license, point your browser to
  27. * http://www.gnu.org/copyleft/gpl.html
  28. *
  29. *
  30. * the project's page is at https://linuxtv.org
  31. */
  32. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  33. #include "budget.h"
  34. #include "stv0299.h"
  35. #include "stb0899_drv.h"
  36. #include "stb0899_reg.h"
  37. #include "stb0899_cfg.h"
  38. #include "tda8261.h"
  39. #include "tda8261_cfg.h"
  40. #include "tda1002x.h"
  41. #include "tda1004x.h"
  42. #include "tua6100.h"
  43. #include "dvb-pll.h"
  44. #include <media/drv-intf/saa7146_vv.h>
  45. #include <linux/module.h>
  46. #include <linux/errno.h>
  47. #include <linux/slab.h>
  48. #include <linux/interrupt.h>
  49. #include <linux/input.h>
  50. #include <linux/spinlock.h>
  51. #include <media/dvb_ca_en50221.h>
  52. #define DEBICICAM 0x02420000
  53. #define SLOTSTATUS_NONE 1
  54. #define SLOTSTATUS_PRESENT 2
  55. #define SLOTSTATUS_RESET 4
  56. #define SLOTSTATUS_READY 8
  57. #define SLOTSTATUS_OCCUPIED (SLOTSTATUS_PRESENT|SLOTSTATUS_RESET|SLOTSTATUS_READY)
  58. DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
  59. struct budget_av {
  60. struct budget budget;
  61. struct video_device vd;
  62. int cur_input;
  63. int has_saa7113;
  64. struct tasklet_struct ciintf_irq_tasklet;
  65. int slot_status;
  66. struct dvb_ca_en50221 ca;
  67. u8 reinitialise_demod:1;
  68. };
  69. static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot);
  70. /* GPIO Connections:
  71. * 0 - Vcc/Reset (Reset is controlled by capacitor). Resets the frontend *AS WELL*!
  72. * 1 - CI memory select 0=>IO memory, 1=>Attribute Memory
  73. * 2 - CI Card Enable (Active Low)
  74. * 3 - CI Card Detect
  75. */
  76. /****************************************************************************
  77. * INITIALIZATION
  78. ****************************************************************************/
  79. static u8 i2c_readreg(struct i2c_adapter *i2c, u8 id, u8 reg)
  80. {
  81. u8 mm1[] = { 0x00 };
  82. u8 mm2[] = { 0x00 };
  83. struct i2c_msg msgs[2];
  84. msgs[0].flags = 0;
  85. msgs[1].flags = I2C_M_RD;
  86. msgs[0].addr = msgs[1].addr = id / 2;
  87. mm1[0] = reg;
  88. msgs[0].len = 1;
  89. msgs[1].len = 1;
  90. msgs[0].buf = mm1;
  91. msgs[1].buf = mm2;
  92. i2c_transfer(i2c, msgs, 2);
  93. return mm2[0];
  94. }
  95. static int i2c_readregs(struct i2c_adapter *i2c, u8 id, u8 reg, u8 * buf, u8 len)
  96. {
  97. u8 mm1[] = { reg };
  98. struct i2c_msg msgs[2] = {
  99. {.addr = id / 2,.flags = 0,.buf = mm1,.len = 1},
  100. {.addr = id / 2,.flags = I2C_M_RD,.buf = buf,.len = len}
  101. };
  102. if (i2c_transfer(i2c, msgs, 2) != 2)
  103. return -EIO;
  104. return 0;
  105. }
  106. static int i2c_writereg(struct i2c_adapter *i2c, u8 id, u8 reg, u8 val)
  107. {
  108. u8 msg[2] = { reg, val };
  109. struct i2c_msg msgs;
  110. msgs.flags = 0;
  111. msgs.addr = id / 2;
  112. msgs.len = 2;
  113. msgs.buf = msg;
  114. return i2c_transfer(i2c, &msgs, 1);
  115. }
  116. static int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address)
  117. {
  118. struct budget_av *budget_av = (struct budget_av *) ca->data;
  119. int result;
  120. if (slot != 0)
  121. return -EINVAL;
  122. saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI);
  123. udelay(1);
  124. result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 0xfff, 1, 0, 1);
  125. if (result == -ETIMEDOUT) {
  126. ciintf_slot_shutdown(ca, slot);
  127. pr_info("cam ejected 1\n");
  128. }
  129. return result;
  130. }
  131. static int ciintf_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address, u8 value)
  132. {
  133. struct budget_av *budget_av = (struct budget_av *) ca->data;
  134. int result;
  135. if (slot != 0)
  136. return -EINVAL;
  137. saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI);
  138. udelay(1);
  139. result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 0xfff, 1, value, 0, 1);
  140. if (result == -ETIMEDOUT) {
  141. ciintf_slot_shutdown(ca, slot);
  142. pr_info("cam ejected 2\n");
  143. }
  144. return result;
  145. }
  146. static int ciintf_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address)
  147. {
  148. struct budget_av *budget_av = (struct budget_av *) ca->data;
  149. int result;
  150. if (slot != 0)
  151. return -EINVAL;
  152. saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
  153. udelay(1);
  154. result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 3, 1, 0, 0);
  155. if (result == -ETIMEDOUT) {
  156. ciintf_slot_shutdown(ca, slot);
  157. pr_info("cam ejected 3\n");
  158. return -ETIMEDOUT;
  159. }
  160. return result;
  161. }
  162. static int ciintf_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address, u8 value)
  163. {
  164. struct budget_av *budget_av = (struct budget_av *) ca->data;
  165. int result;
  166. if (slot != 0)
  167. return -EINVAL;
  168. saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
  169. udelay(1);
  170. result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 3, 1, value, 0, 0);
  171. if (result == -ETIMEDOUT) {
  172. ciintf_slot_shutdown(ca, slot);
  173. pr_info("cam ejected 5\n");
  174. }
  175. return result;
  176. }
  177. static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
  178. {
  179. struct budget_av *budget_av = (struct budget_av *) ca->data;
  180. struct saa7146_dev *saa = budget_av->budget.dev;
  181. if (slot != 0)
  182. return -EINVAL;
  183. dprintk(1, "ciintf_slot_reset\n");
  184. budget_av->slot_status = SLOTSTATUS_RESET;
  185. saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */
  186. saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */
  187. msleep(2);
  188. saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO); /* Vcc on */
  189. msleep(20); /* 20 ms Vcc settling time */
  190. saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO); /* enable card */
  191. ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
  192. msleep(20);
  193. /* reinitialise the frontend if necessary */
  194. if (budget_av->reinitialise_demod)
  195. dvb_frontend_reinitialise(budget_av->budget.dvb_frontend);
  196. return 0;
  197. }
  198. static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot)
  199. {
  200. struct budget_av *budget_av = (struct budget_av *) ca->data;
  201. struct saa7146_dev *saa = budget_av->budget.dev;
  202. if (slot != 0)
  203. return -EINVAL;
  204. dprintk(1, "ciintf_slot_shutdown\n");
  205. ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
  206. budget_av->slot_status = SLOTSTATUS_NONE;
  207. return 0;
  208. }
  209. static int ciintf_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot)
  210. {
  211. struct budget_av *budget_av = (struct budget_av *) ca->data;
  212. struct saa7146_dev *saa = budget_av->budget.dev;
  213. if (slot != 0)
  214. return -EINVAL;
  215. dprintk(1, "ciintf_slot_ts_enable: %d\n", budget_av->slot_status);
  216. ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTA);
  217. return 0;
  218. }
  219. static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open)
  220. {
  221. struct budget_av *budget_av = (struct budget_av *) ca->data;
  222. struct saa7146_dev *saa = budget_av->budget.dev;
  223. int result;
  224. if (slot != 0)
  225. return -EINVAL;
  226. /* test the card detect line - needs to be done carefully
  227. * since it never goes high for some CAMs on this interface (e.g. topuptv) */
  228. if (budget_av->slot_status == SLOTSTATUS_NONE) {
  229. saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
  230. udelay(1);
  231. if (saa7146_read(saa, PSR) & MASK_06) {
  232. if (budget_av->slot_status == SLOTSTATUS_NONE) {
  233. budget_av->slot_status = SLOTSTATUS_PRESENT;
  234. pr_info("cam inserted A\n");
  235. }
  236. }
  237. saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
  238. }
  239. /* We also try and read from IO memory to work round the above detection bug. If
  240. * there is no CAM, we will get a timeout. Only done if there is no cam
  241. * present, since this test actually breaks some cams :(
  242. *
  243. * if the CI interface is not open, we also do the above test since we
  244. * don't care if the cam has problems - we'll be resetting it on open() anyway */
  245. if ((budget_av->slot_status == SLOTSTATUS_NONE) || (!open)) {
  246. saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
  247. result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, 0, 1, 0, 1);
  248. if ((result >= 0) && (budget_av->slot_status == SLOTSTATUS_NONE)) {
  249. budget_av->slot_status = SLOTSTATUS_PRESENT;
  250. pr_info("cam inserted B\n");
  251. } else if (result < 0) {
  252. if (budget_av->slot_status != SLOTSTATUS_NONE) {
  253. ciintf_slot_shutdown(ca, slot);
  254. pr_info("cam ejected 5\n");
  255. return 0;
  256. }
  257. }
  258. }
  259. /* read from attribute memory in reset/ready state to know when the CAM is ready */
  260. if (budget_av->slot_status == SLOTSTATUS_RESET) {
  261. result = ciintf_read_attribute_mem(ca, slot, 0);
  262. if (result == 0x1d) {
  263. budget_av->slot_status = SLOTSTATUS_READY;
  264. }
  265. }
  266. /* work out correct return code */
  267. if (budget_av->slot_status != SLOTSTATUS_NONE) {
  268. if (budget_av->slot_status & SLOTSTATUS_READY) {
  269. return DVB_CA_EN50221_POLL_CAM_PRESENT | DVB_CA_EN50221_POLL_CAM_READY;
  270. }
  271. return DVB_CA_EN50221_POLL_CAM_PRESENT;
  272. }
  273. return 0;
  274. }
  275. static int ciintf_init(struct budget_av *budget_av)
  276. {
  277. struct saa7146_dev *saa = budget_av->budget.dev;
  278. int result;
  279. memset(&budget_av->ca, 0, sizeof(struct dvb_ca_en50221));
  280. saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
  281. saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTLO);
  282. saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO);
  283. saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
  284. /* Enable DEBI pins */
  285. saa7146_write(saa, MC1, MASK_27 | MASK_11);
  286. /* register CI interface */
  287. budget_av->ca.owner = THIS_MODULE;
  288. budget_av->ca.read_attribute_mem = ciintf_read_attribute_mem;
  289. budget_av->ca.write_attribute_mem = ciintf_write_attribute_mem;
  290. budget_av->ca.read_cam_control = ciintf_read_cam_control;
  291. budget_av->ca.write_cam_control = ciintf_write_cam_control;
  292. budget_av->ca.slot_reset = ciintf_slot_reset;
  293. budget_av->ca.slot_shutdown = ciintf_slot_shutdown;
  294. budget_av->ca.slot_ts_enable = ciintf_slot_ts_enable;
  295. budget_av->ca.poll_slot_status = ciintf_poll_slot_status;
  296. budget_av->ca.data = budget_av;
  297. budget_av->budget.ci_present = 1;
  298. budget_av->slot_status = SLOTSTATUS_NONE;
  299. if ((result = dvb_ca_en50221_init(&budget_av->budget.dvb_adapter,
  300. &budget_av->ca, 0, 1)) != 0) {
  301. pr_err("ci initialisation failed\n");
  302. goto error;
  303. }
  304. pr_info("ci interface initialised\n");
  305. return 0;
  306. error:
  307. saa7146_write(saa, MC1, MASK_27);
  308. return result;
  309. }
  310. static void ciintf_deinit(struct budget_av *budget_av)
  311. {
  312. struct saa7146_dev *saa = budget_av->budget.dev;
  313. saa7146_setgpio(saa, 0, SAA7146_GPIO_INPUT);
  314. saa7146_setgpio(saa, 1, SAA7146_GPIO_INPUT);
  315. saa7146_setgpio(saa, 2, SAA7146_GPIO_INPUT);
  316. saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
  317. /* release the CA device */
  318. dvb_ca_en50221_release(&budget_av->ca);
  319. /* disable DEBI pins */
  320. saa7146_write(saa, MC1, MASK_27);
  321. }
  322. static const u8 saa7113_tab[] = {
  323. 0x01, 0x08,
  324. 0x02, 0xc0,
  325. 0x03, 0x33,
  326. 0x04, 0x00,
  327. 0x05, 0x00,
  328. 0x06, 0xeb,
  329. 0x07, 0xe0,
  330. 0x08, 0x28,
  331. 0x09, 0x00,
  332. 0x0a, 0x80,
  333. 0x0b, 0x47,
  334. 0x0c, 0x40,
  335. 0x0d, 0x00,
  336. 0x0e, 0x01,
  337. 0x0f, 0x44,
  338. 0x10, 0x08,
  339. 0x11, 0x0c,
  340. 0x12, 0x7b,
  341. 0x13, 0x00,
  342. 0x15, 0x00, 0x16, 0x00, 0x17, 0x00,
  343. 0x57, 0xff,
  344. 0x40, 0x82, 0x58, 0x00, 0x59, 0x54, 0x5a, 0x07,
  345. 0x5b, 0x83, 0x5e, 0x00,
  346. 0xff
  347. };
  348. static int saa7113_init(struct budget_av *budget_av)
  349. {
  350. struct budget *budget = &budget_av->budget;
  351. struct saa7146_dev *saa = budget->dev;
  352. const u8 *data = saa7113_tab;
  353. saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI);
  354. msleep(200);
  355. if (i2c_writereg(&budget->i2c_adap, 0x4a, 0x01, 0x08) != 1) {
  356. dprintk(1, "saa7113 not found on KNC card\n");
  357. return -ENODEV;
  358. }
  359. dprintk(1, "saa7113 detected and initializing\n");
  360. while (*data != 0xff) {
  361. i2c_writereg(&budget->i2c_adap, 0x4a, *data, *(data + 1));
  362. data += 2;
  363. }
  364. dprintk(1, "saa7113 status=%02x\n", i2c_readreg(&budget->i2c_adap, 0x4a, 0x1f));
  365. return 0;
  366. }
  367. static int saa7113_setinput(struct budget_av *budget_av, int input)
  368. {
  369. struct budget *budget = &budget_av->budget;
  370. if (1 != budget_av->has_saa7113)
  371. return -ENODEV;
  372. if (input == 1) {
  373. i2c_writereg(&budget->i2c_adap, 0x4a, 0x02, 0xc7);
  374. i2c_writereg(&budget->i2c_adap, 0x4a, 0x09, 0x80);
  375. } else if (input == 0) {
  376. i2c_writereg(&budget->i2c_adap, 0x4a, 0x02, 0xc0);
  377. i2c_writereg(&budget->i2c_adap, 0x4a, 0x09, 0x00);
  378. } else
  379. return -EINVAL;
  380. budget_av->cur_input = input;
  381. return 0;
  382. }
  383. static int philips_su1278_ty_ci_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio)
  384. {
  385. u8 aclk = 0;
  386. u8 bclk = 0;
  387. u8 m1;
  388. aclk = 0xb5;
  389. if (srate < 2000000)
  390. bclk = 0x86;
  391. else if (srate < 5000000)
  392. bclk = 0x89;
  393. else if (srate < 15000000)
  394. bclk = 0x8f;
  395. else if (srate < 45000000)
  396. bclk = 0x95;
  397. m1 = 0x14;
  398. if (srate < 4000000)
  399. m1 = 0x10;
  400. stv0299_writereg(fe, 0x13, aclk);
  401. stv0299_writereg(fe, 0x14, bclk);
  402. stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
  403. stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
  404. stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
  405. stv0299_writereg(fe, 0x0f, 0x80 | m1);
  406. return 0;
  407. }
  408. static int philips_su1278_ty_ci_tuner_set_params(struct dvb_frontend *fe)
  409. {
  410. struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  411. u32 div;
  412. u8 buf[4];
  413. struct budget *budget = (struct budget *) fe->dvb->priv;
  414. struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
  415. if ((c->frequency < 950000) || (c->frequency > 2150000))
  416. return -EINVAL;
  417. div = (c->frequency + (125 - 1)) / 125; /* round correctly */
  418. buf[0] = (div >> 8) & 0x7f;
  419. buf[1] = div & 0xff;
  420. buf[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
  421. buf[3] = 0x20;
  422. if (c->symbol_rate < 4000000)
  423. buf[3] |= 1;
  424. if (c->frequency < 1250000)
  425. buf[3] |= 0;
  426. else if (c->frequency < 1550000)
  427. buf[3] |= 0x40;
  428. else if (c->frequency < 2050000)
  429. buf[3] |= 0x80;
  430. else if (c->frequency < 2150000)
  431. buf[3] |= 0xC0;
  432. if (fe->ops.i2c_gate_ctrl)
  433. fe->ops.i2c_gate_ctrl(fe, 1);
  434. if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
  435. return -EIO;
  436. return 0;
  437. }
  438. static u8 typhoon_cinergy1200s_inittab[] = {
  439. 0x01, 0x15,
  440. 0x02, 0x30,
  441. 0x03, 0x00,
  442. 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
  443. 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
  444. 0x06, 0x40, /* DAC not used, set to high impendance mode */
  445. 0x07, 0x00, /* DAC LSB */
  446. 0x08, 0x40, /* DiSEqC off */
  447. 0x09, 0x00, /* FIFO */
  448. 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
  449. 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
  450. 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
  451. 0x10, 0x3f, // AGC2 0x3d
  452. 0x11, 0x84,
  453. 0x12, 0xb9,
  454. 0x15, 0xc9, // lock detector threshold
  455. 0x16, 0x00,
  456. 0x17, 0x00,
  457. 0x18, 0x00,
  458. 0x19, 0x00,
  459. 0x1a, 0x00,
  460. 0x1f, 0x50,
  461. 0x20, 0x00,
  462. 0x21, 0x00,
  463. 0x22, 0x00,
  464. 0x23, 0x00,
  465. 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
  466. 0x29, 0x1e, // 1/2 threshold
  467. 0x2a, 0x14, // 2/3 threshold
  468. 0x2b, 0x0f, // 3/4 threshold
  469. 0x2c, 0x09, // 5/6 threshold
  470. 0x2d, 0x05, // 7/8 threshold
  471. 0x2e, 0x01,
  472. 0x31, 0x1f, // test all FECs
  473. 0x32, 0x19, // viterbi and synchro search
  474. 0x33, 0xfc, // rs control
  475. 0x34, 0x93, // error control
  476. 0x0f, 0x92,
  477. 0xff, 0xff
  478. };
  479. static const struct stv0299_config typhoon_config = {
  480. .demod_address = 0x68,
  481. .inittab = typhoon_cinergy1200s_inittab,
  482. .mclk = 88000000UL,
  483. .invert = 0,
  484. .skip_reinit = 0,
  485. .lock_output = STV0299_LOCKOUTPUT_1,
  486. .volt13_op0_op1 = STV0299_VOLT13_OP0,
  487. .min_delay_ms = 100,
  488. .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
  489. };
  490. static const struct stv0299_config cinergy_1200s_config = {
  491. .demod_address = 0x68,
  492. .inittab = typhoon_cinergy1200s_inittab,
  493. .mclk = 88000000UL,
  494. .invert = 0,
  495. .skip_reinit = 0,
  496. .lock_output = STV0299_LOCKOUTPUT_0,
  497. .volt13_op0_op1 = STV0299_VOLT13_OP0,
  498. .min_delay_ms = 100,
  499. .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
  500. };
  501. static const struct stv0299_config cinergy_1200s_1894_0010_config = {
  502. .demod_address = 0x68,
  503. .inittab = typhoon_cinergy1200s_inittab,
  504. .mclk = 88000000UL,
  505. .invert = 1,
  506. .skip_reinit = 0,
  507. .lock_output = STV0299_LOCKOUTPUT_1,
  508. .volt13_op0_op1 = STV0299_VOLT13_OP0,
  509. .min_delay_ms = 100,
  510. .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
  511. };
  512. static int philips_cu1216_tuner_set_params(struct dvb_frontend *fe)
  513. {
  514. struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  515. struct budget *budget = (struct budget *) fe->dvb->priv;
  516. u8 buf[6];
  517. struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) };
  518. int i;
  519. #define CU1216_IF 36125000
  520. #define TUNER_MUL 62500
  521. u32 div = (c->frequency + CU1216_IF + TUNER_MUL / 2) / TUNER_MUL;
  522. buf[0] = (div >> 8) & 0x7f;
  523. buf[1] = div & 0xff;
  524. buf[2] = 0xce;
  525. buf[3] = (c->frequency < 150000000 ? 0x01 :
  526. c->frequency < 445000000 ? 0x02 : 0x04);
  527. buf[4] = 0xde;
  528. buf[5] = 0x20;
  529. if (fe->ops.i2c_gate_ctrl)
  530. fe->ops.i2c_gate_ctrl(fe, 1);
  531. if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
  532. return -EIO;
  533. /* wait for the pll lock */
  534. msg.flags = I2C_M_RD;
  535. msg.len = 1;
  536. for (i = 0; i < 20; i++) {
  537. if (fe->ops.i2c_gate_ctrl)
  538. fe->ops.i2c_gate_ctrl(fe, 1);
  539. if (i2c_transfer(&budget->i2c_adap, &msg, 1) == 1 && (buf[0] & 0x40))
  540. break;
  541. msleep(10);
  542. }
  543. /* switch the charge pump to the lower current */
  544. msg.flags = 0;
  545. msg.len = 2;
  546. msg.buf = &buf[2];
  547. buf[2] &= ~0x40;
  548. if (fe->ops.i2c_gate_ctrl)
  549. fe->ops.i2c_gate_ctrl(fe, 1);
  550. if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
  551. return -EIO;
  552. return 0;
  553. }
  554. static struct tda1002x_config philips_cu1216_config = {
  555. .demod_address = 0x0c,
  556. .invert = 1,
  557. };
  558. static struct tda1002x_config philips_cu1216_config_altaddress = {
  559. .demod_address = 0x0d,
  560. .invert = 0,
  561. };
  562. static struct tda10023_config philips_cu1216_tda10023_config = {
  563. .demod_address = 0x0c,
  564. .invert = 1,
  565. };
  566. static int philips_tu1216_tuner_init(struct dvb_frontend *fe)
  567. {
  568. struct budget *budget = (struct budget *) fe->dvb->priv;
  569. static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
  570. struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
  571. // setup PLL configuration
  572. if (fe->ops.i2c_gate_ctrl)
  573. fe->ops.i2c_gate_ctrl(fe, 1);
  574. if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)
  575. return -EIO;
  576. msleep(1);
  577. return 0;
  578. }
  579. static int philips_tu1216_tuner_set_params(struct dvb_frontend *fe)
  580. {
  581. struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  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 = c->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 (c->frequency < 49000000)
  614. return -EINVAL;
  615. else if (c->frequency < 161000000)
  616. band = 1;
  617. else if (c->frequency < 444000000)
  618. band = 2;
  619. else if (c->frequency < 861000000)
  620. band = 4;
  621. else
  622. return -EINVAL;
  623. // setup PLL filter
  624. switch (c->bandwidth_hz) {
  625. case 6000000:
  626. filter = 0;
  627. break;
  628. case 7000000:
  629. filter = 0;
  630. break;
  631. case 8000000:
  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 = (((c->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 const 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_DISSTATUS , 0x20 },
  759. { STB0899_DISF22 , 0x8c },
  760. { STB0899_DISF22RX , 0x9a },
  761. { STB0899_SYSREG , 0x0b },
  762. { STB0899_ACRPRESC , 0x11 },
  763. { STB0899_ACRDIV1 , 0x0a },
  764. { STB0899_ACRDIV2 , 0x05 },
  765. { STB0899_DACR1 , 0x00 },
  766. { STB0899_DACR2 , 0x00 },
  767. { STB0899_OUTCFG , 0x00 },
  768. { STB0899_MODECFG , 0x00 },
  769. { STB0899_IRQSTATUS_3 , 0x30 },
  770. { STB0899_IRQSTATUS_2 , 0x00 },
  771. { STB0899_IRQSTATUS_1 , 0x00 },
  772. { STB0899_IRQSTATUS_0 , 0x00 },
  773. { STB0899_IRQMSK_3 , 0xf3 },
  774. { STB0899_IRQMSK_2 , 0xfc },
  775. { STB0899_IRQMSK_1 , 0xff },
  776. { STB0899_IRQMSK_0 , 0xff },
  777. { STB0899_IRQCFG , 0x00 },
  778. { STB0899_I2CCFG , 0x88 },
  779. { STB0899_I2CRPT , 0x58 }, /* Repeater=8, Stop=disabled */
  780. { STB0899_IOPVALUE5 , 0x00 },
  781. { STB0899_IOPVALUE4 , 0x20 },
  782. { STB0899_IOPVALUE3 , 0xc9 },
  783. { STB0899_IOPVALUE2 , 0x90 },
  784. { STB0899_IOPVALUE1 , 0x40 },
  785. { STB0899_IOPVALUE0 , 0x00 },
  786. { STB0899_GPIO00CFG , 0x82 },
  787. { STB0899_GPIO01CFG , 0x82 },
  788. { STB0899_GPIO02CFG , 0x82 },
  789. { STB0899_GPIO03CFG , 0x82 },
  790. { STB0899_GPIO04CFG , 0x82 },
  791. { STB0899_GPIO05CFG , 0x82 },
  792. { STB0899_GPIO06CFG , 0x82 },
  793. { STB0899_GPIO07CFG , 0x82 },
  794. { STB0899_GPIO08CFG , 0x82 },
  795. { STB0899_GPIO09CFG , 0x82 },
  796. { STB0899_GPIO10CFG , 0x82 },
  797. { STB0899_GPIO11CFG , 0x82 },
  798. { STB0899_GPIO12CFG , 0x82 },
  799. { STB0899_GPIO13CFG , 0x82 },
  800. { STB0899_GPIO14CFG , 0x82 },
  801. { STB0899_GPIO15CFG , 0x82 },
  802. { STB0899_GPIO16CFG , 0x82 },
  803. { STB0899_GPIO17CFG , 0x82 },
  804. { STB0899_GPIO18CFG , 0x82 },
  805. { STB0899_GPIO19CFG , 0x82 },
  806. { STB0899_GPIO20CFG , 0x82 },
  807. { STB0899_SDATCFG , 0xb8 },
  808. { STB0899_SCLTCFG , 0xba },
  809. { STB0899_AGCRFCFG , 0x08 }, /* 0x1c */
  810. { STB0899_GPIO22 , 0x82 }, /* AGCBB2CFG */
  811. { STB0899_GPIO21 , 0x91 }, /* AGCBB1CFG */
  812. { STB0899_DIRCLKCFG , 0x82 },
  813. { STB0899_CLKOUT27CFG , 0x7e },
  814. { STB0899_STDBYCFG , 0x82 },
  815. { STB0899_CS0CFG , 0x82 },
  816. { STB0899_CS1CFG , 0x82 },
  817. { STB0899_DISEQCOCFG , 0x20 },
  818. { STB0899_GPIO32CFG , 0x82 },
  819. { STB0899_GPIO33CFG , 0x82 },
  820. { STB0899_GPIO34CFG , 0x82 },
  821. { STB0899_GPIO35CFG , 0x82 },
  822. { STB0899_GPIO36CFG , 0x82 },
  823. { STB0899_GPIO37CFG , 0x82 },
  824. { STB0899_GPIO38CFG , 0x82 },
  825. { STB0899_GPIO39CFG , 0x82 },
  826. { STB0899_NCOARSE , 0x15 }, /* 0x15 = 27 Mhz Clock, F/3 = 198MHz, F/6 = 99MHz */
  827. { STB0899_SYNTCTRL , 0x02 }, /* 0x00 = CLK from CLKI, 0x02 = CLK from XTALI */
  828. { STB0899_FILTCTRL , 0x00 },
  829. { STB0899_SYSCTRL , 0x00 },
  830. { STB0899_STOPCLK1 , 0x20 },
  831. { STB0899_STOPCLK2 , 0x00 },
  832. { STB0899_INTBUFSTATUS , 0x00 },
  833. { STB0899_INTBUFCTRL , 0x0a },
  834. { 0xffff , 0xff },
  835. };
  836. static const struct stb0899_s1_reg knc1_stb0899_s1_init_3[] = {
  837. { STB0899_DEMOD , 0x00 },
  838. { STB0899_RCOMPC , 0xc9 },
  839. { STB0899_AGC1CN , 0x41 },
  840. { STB0899_AGC1REF , 0x08 },
  841. { STB0899_RTC , 0x7a },
  842. { STB0899_TMGCFG , 0x4e },
  843. { STB0899_AGC2REF , 0x33 },
  844. { STB0899_TLSR , 0x84 },
  845. { STB0899_CFD , 0xee },
  846. { STB0899_ACLC , 0x87 },
  847. { STB0899_BCLC , 0x94 },
  848. { STB0899_EQON , 0x41 },
  849. { STB0899_LDT , 0xdd },
  850. { STB0899_LDT2 , 0xc9 },
  851. { STB0899_EQUALREF , 0xb4 },
  852. { STB0899_TMGRAMP , 0x10 },
  853. { STB0899_TMGTHD , 0x30 },
  854. { STB0899_IDCCOMP , 0xfb },
  855. { STB0899_QDCCOMP , 0x03 },
  856. { STB0899_POWERI , 0x3b },
  857. { STB0899_POWERQ , 0x3d },
  858. { STB0899_RCOMP , 0x81 },
  859. { STB0899_AGCIQIN , 0x80 },
  860. { STB0899_AGC2I1 , 0x04 },
  861. { STB0899_AGC2I2 , 0xf5 },
  862. { STB0899_TLIR , 0x25 },
  863. { STB0899_RTF , 0x80 },
  864. { STB0899_DSTATUS , 0x00 },
  865. { STB0899_LDI , 0xca },
  866. { STB0899_CFRM , 0xf1 },
  867. { STB0899_CFRL , 0xf3 },
  868. { STB0899_NIRM , 0x2a },
  869. { STB0899_NIRL , 0x05 },
  870. { STB0899_ISYMB , 0x17 },
  871. { STB0899_QSYMB , 0xfa },
  872. { STB0899_SFRH , 0x2f },
  873. { STB0899_SFRM , 0x68 },
  874. { STB0899_SFRL , 0x40 },
  875. { STB0899_SFRUPH , 0x2f },
  876. { STB0899_SFRUPM , 0x68 },
  877. { STB0899_SFRUPL , 0x40 },
  878. { STB0899_EQUAI1 , 0xfd },
  879. { STB0899_EQUAQ1 , 0x04 },
  880. { STB0899_EQUAI2 , 0x0f },
  881. { STB0899_EQUAQ2 , 0xff },
  882. { STB0899_EQUAI3 , 0xdf },
  883. { STB0899_EQUAQ3 , 0xfa },
  884. { STB0899_EQUAI4 , 0x37 },
  885. { STB0899_EQUAQ4 , 0x0d },
  886. { STB0899_EQUAI5 , 0xbd },
  887. { STB0899_EQUAQ5 , 0xf7 },
  888. { STB0899_DSTATUS2 , 0x00 },
  889. { STB0899_VSTATUS , 0x00 },
  890. { STB0899_VERROR , 0xff },
  891. { STB0899_IQSWAP , 0x2a },
  892. { STB0899_ECNT1M , 0x00 },
  893. { STB0899_ECNT1L , 0x00 },
  894. { STB0899_ECNT2M , 0x00 },
  895. { STB0899_ECNT2L , 0x00 },
  896. { STB0899_ECNT3M , 0x00 },
  897. { STB0899_ECNT3L , 0x00 },
  898. { STB0899_FECAUTO1 , 0x06 },
  899. { STB0899_FECM , 0x01 },
  900. { STB0899_VTH12 , 0xf0 },
  901. { STB0899_VTH23 , 0xa0 },
  902. { STB0899_VTH34 , 0x78 },
  903. { STB0899_VTH56 , 0x4e },
  904. { STB0899_VTH67 , 0x48 },
  905. { STB0899_VTH78 , 0x38 },
  906. { STB0899_PRVIT , 0xff },
  907. { STB0899_VITSYNC , 0x19 },
  908. { STB0899_RSULC , 0xb1 }, /* DVB = 0xb1, DSS = 0xa1 */
  909. { STB0899_TSULC , 0x42 },
  910. { STB0899_RSLLC , 0x40 },
  911. { STB0899_TSLPL , 0x12 },
  912. { STB0899_TSCFGH , 0x0c },
  913. { STB0899_TSCFGM , 0x00 },
  914. { STB0899_TSCFGL , 0x0c },
  915. { STB0899_TSOUT , 0x4d }, /* 0x0d for CAM */
  916. { STB0899_RSSYNCDEL , 0x00 },
  917. { STB0899_TSINHDELH , 0x02 },
  918. { STB0899_TSINHDELM , 0x00 },
  919. { STB0899_TSINHDELL , 0x00 },
  920. { STB0899_TSLLSTKM , 0x00 },
  921. { STB0899_TSLLSTKL , 0x00 },
  922. { STB0899_TSULSTKM , 0x00 },
  923. { STB0899_TSULSTKL , 0xab },
  924. { STB0899_PCKLENUL , 0x00 },
  925. { STB0899_PCKLENLL , 0xcc },
  926. { STB0899_RSPCKLEN , 0xcc },
  927. { STB0899_TSSTATUS , 0x80 },
  928. { STB0899_ERRCTRL1 , 0xb6 },
  929. { STB0899_ERRCTRL2 , 0x96 },
  930. { STB0899_ERRCTRL3 , 0x89 },
  931. { STB0899_DMONMSK1 , 0x27 },
  932. { STB0899_DMONMSK0 , 0x03 },
  933. { STB0899_DEMAPVIT , 0x5c },
  934. { STB0899_PLPARM , 0x1f },
  935. { STB0899_PDELCTRL , 0x48 },
  936. { STB0899_PDELCTRL2 , 0x00 },
  937. { STB0899_BBHCTRL1 , 0x00 },
  938. { STB0899_BBHCTRL2 , 0x00 },
  939. { STB0899_HYSTTHRESH , 0x77 },
  940. { STB0899_MATCSTM , 0x00 },
  941. { STB0899_MATCSTL , 0x00 },
  942. { STB0899_UPLCSTM , 0x00 },
  943. { STB0899_UPLCSTL , 0x00 },
  944. { STB0899_DFLCSTM , 0x00 },
  945. { STB0899_DFLCSTL , 0x00 },
  946. { STB0899_SYNCCST , 0x00 },
  947. { STB0899_SYNCDCSTM , 0x00 },
  948. { STB0899_SYNCDCSTL , 0x00 },
  949. { STB0899_ISI_ENTRY , 0x00 },
  950. { STB0899_ISI_BIT_EN , 0x00 },
  951. { STB0899_MATSTRM , 0x00 },
  952. { STB0899_MATSTRL , 0x00 },
  953. { STB0899_UPLSTRM , 0x00 },
  954. { STB0899_UPLSTRL , 0x00 },
  955. { STB0899_DFLSTRM , 0x00 },
  956. { STB0899_DFLSTRL , 0x00 },
  957. { STB0899_SYNCSTR , 0x00 },
  958. { STB0899_SYNCDSTRM , 0x00 },
  959. { STB0899_SYNCDSTRL , 0x00 },
  960. { STB0899_CFGPDELSTATUS1 , 0x10 },
  961. { STB0899_CFGPDELSTATUS2 , 0x00 },
  962. { STB0899_BBFERRORM , 0x00 },
  963. { STB0899_BBFERRORL , 0x00 },
  964. { STB0899_UPKTERRORM , 0x00 },
  965. { STB0899_UPKTERRORL , 0x00 },
  966. { 0xffff , 0xff },
  967. };
  968. /* STB0899 demodulator config for the KNC1 and clones */
  969. static struct stb0899_config knc1_dvbs2_config = {
  970. .init_dev = knc1_stb0899_s1_init_1,
  971. .init_s2_demod = stb0899_s2_init_2,
  972. .init_s1_demod = knc1_stb0899_s1_init_3,
  973. .init_s2_fec = stb0899_s2_init_4,
  974. .init_tst = stb0899_s1_init_5,
  975. .postproc = NULL,
  976. .demod_address = 0x68,
  977. // .ts_output_mode = STB0899_OUT_PARALLEL, /* types = SERIAL/PARALLEL */
  978. .block_sync_mode = STB0899_SYNC_FORCED, /* DSS, SYNC_FORCED/UNSYNCED */
  979. // .ts_pfbit_toggle = STB0899_MPEG_NORMAL, /* DirecTV, MPEG toggling seq */
  980. .xtal_freq = 27000000,
  981. .inversion = IQ_SWAP_OFF,
  982. .lo_clk = 76500000,
  983. .hi_clk = 90000000,
  984. .esno_ave = STB0899_DVBS2_ESNO_AVE,
  985. .esno_quant = STB0899_DVBS2_ESNO_QUANT,
  986. .avframes_coarse = STB0899_DVBS2_AVFRAMES_COARSE,
  987. .avframes_fine = STB0899_DVBS2_AVFRAMES_FINE,
  988. .miss_threshold = STB0899_DVBS2_MISS_THRESHOLD,
  989. .uwp_threshold_acq = STB0899_DVBS2_UWP_THRESHOLD_ACQ,
  990. .uwp_threshold_track = STB0899_DVBS2_UWP_THRESHOLD_TRACK,
  991. .uwp_threshold_sof = STB0899_DVBS2_UWP_THRESHOLD_SOF,
  992. .sof_search_timeout = STB0899_DVBS2_SOF_SEARCH_TIMEOUT,
  993. .btr_nco_bits = STB0899_DVBS2_BTR_NCO_BITS,
  994. .btr_gain_shift_offset = STB0899_DVBS2_BTR_GAIN_SHIFT_OFFSET,
  995. .crl_nco_bits = STB0899_DVBS2_CRL_NCO_BITS,
  996. .ldpc_max_iter = STB0899_DVBS2_LDPC_MAX_ITER,
  997. .tuner_get_frequency = tda8261_get_frequency,
  998. .tuner_set_frequency = tda8261_set_frequency,
  999. .tuner_set_bandwidth = NULL,
  1000. .tuner_get_bandwidth = tda8261_get_bandwidth,
  1001. .tuner_set_rfsiggain = NULL
  1002. };
  1003. /*
  1004. * SD1878/SHA tuner config
  1005. * 1F, Single I/P, Horizontal mount, High Sensitivity
  1006. */
  1007. static const struct tda8261_config sd1878c_config = {
  1008. // .name = "SD1878/SHA",
  1009. .addr = 0x60,
  1010. .step_size = TDA8261_STEP_1000 /* kHz */
  1011. };
  1012. static u8 read_pwm(struct budget_av *budget_av)
  1013. {
  1014. u8 b = 0xff;
  1015. u8 pwm;
  1016. struct i2c_msg msg[] = { {.addr = 0x50,.flags = 0,.buf = &b,.len = 1},
  1017. {.addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1}
  1018. };
  1019. if ((i2c_transfer(&budget_av->budget.i2c_adap, msg, 2) != 2)
  1020. || (pwm == 0xff))
  1021. pwm = 0x48;
  1022. return pwm;
  1023. }
  1024. #define SUBID_DVBS_KNC1 0x0010
  1025. #define SUBID_DVBS_KNC1_PLUS 0x0011
  1026. #define SUBID_DVBS_TYPHOON 0x4f56
  1027. #define SUBID_DVBS_CINERGY1200 0x1154
  1028. #define SUBID_DVBS_CYNERGY1200N 0x1155
  1029. #define SUBID_DVBS_TV_STAR 0x0014
  1030. #define SUBID_DVBS_TV_STAR_PLUS_X4 0x0015
  1031. #define SUBID_DVBS_TV_STAR_CI 0x0016
  1032. #define SUBID_DVBS2_KNC1 0x0018
  1033. #define SUBID_DVBS2_KNC1_OEM 0x0019
  1034. #define SUBID_DVBS_EASYWATCH_1 0x001a
  1035. #define SUBID_DVBS_EASYWATCH_2 0x001b
  1036. #define SUBID_DVBS2_EASYWATCH 0x001d
  1037. #define SUBID_DVBS_EASYWATCH 0x001e
  1038. #define SUBID_DVBC_EASYWATCH 0x002a
  1039. #define SUBID_DVBC_EASYWATCH_MK3 0x002c
  1040. #define SUBID_DVBC_KNC1 0x0020
  1041. #define SUBID_DVBC_KNC1_PLUS 0x0021
  1042. #define SUBID_DVBC_KNC1_MK3 0x0022
  1043. #define SUBID_DVBC_KNC1_TDA10024 0x0028
  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_TDA10024:
  1152. case SUBID_DVBC_KNC1_PLUS_MK3:
  1153. budget_av->reinitialise_demod = 1;
  1154. budget_av->budget.dev->i2c_bitrate = SAA7146_I2C_BUS_BIT_RATE_240;
  1155. fe = dvb_attach(tda10023_attach,
  1156. &philips_cu1216_tda10023_config,
  1157. &budget_av->budget.i2c_adap,
  1158. read_pwm(budget_av));
  1159. if (fe) {
  1160. fe->ops.tuner_ops.set_params = philips_cu1216_tuner_set_params;
  1161. }
  1162. break;
  1163. case SUBID_DVBT_EASYWATCH:
  1164. case SUBID_DVBT_KNC1:
  1165. case SUBID_DVBT_KNC1_PLUS:
  1166. case SUBID_DVBT_CINERGY1200:
  1167. budget_av->reinitialise_demod = 1;
  1168. fe = dvb_attach(tda10046_attach, &philips_tu1216_config,
  1169. &budget_av->budget.i2c_adap);
  1170. if (fe) {
  1171. fe->ops.tuner_ops.init = philips_tu1216_tuner_init;
  1172. fe->ops.tuner_ops.set_params = philips_tu1216_tuner_set_params;
  1173. }
  1174. break;
  1175. }
  1176. if (fe == NULL) {
  1177. pr_err("A frontend driver was not found 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. pr_err("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. err = saa7146_vv_init(dev, &vv_data);
  1275. if (err != 0) {
  1276. /* fixme: proper cleanup here */
  1277. ERR("cannot init vv subsystem\n");
  1278. return err;
  1279. }
  1280. vv_data.vid_ops.vidioc_enum_input = vidioc_enum_input;
  1281. vv_data.vid_ops.vidioc_g_input = vidioc_g_input;
  1282. vv_data.vid_ops.vidioc_s_input = vidioc_s_input;
  1283. if ((err = saa7146_register_device(&budget_av->vd, dev, "knc1", VFL_TYPE_GRABBER))) {
  1284. /* fixme: proper cleanup here */
  1285. ERR("cannot register capture v4l2 device\n");
  1286. saa7146_vv_release(dev);
  1287. return err;
  1288. }
  1289. /* beware: this modifies dev->vv ... */
  1290. saa7146_set_hps_source_and_sync(dev, SAA7146_HPS_SOURCE_PORT_A,
  1291. SAA7146_HPS_SYNC_PORT_A);
  1292. saa7113_setinput(budget_av, 0);
  1293. }
  1294. /* fixme: find some sane values here... */
  1295. saa7146_write(dev, PCI_BT_V1, 0x1c00101f);
  1296. mac = budget_av->budget.dvb_adapter.proposed_mac;
  1297. if (i2c_readregs(&budget_av->budget.i2c_adap, 0xa0, 0x30, mac, 6)) {
  1298. pr_err("KNC1-%d: Could not read MAC from KNC1 card\n",
  1299. budget_av->budget.dvb_adapter.num);
  1300. eth_zero_addr(mac);
  1301. } else {
  1302. pr_info("KNC1-%d: MAC addr = %pM\n",
  1303. budget_av->budget.dvb_adapter.num, mac);
  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(knc1ctda10024, "KNC1 DVB-C TDA10024", BUDGET_KNC1C_TDA10024);
  1346. MAKE_BUDGET_INFO(knc1cpmk3, "KNC1 DVB-C Plus MK3", BUDGET_KNC1CP_MK3);
  1347. MAKE_BUDGET_INFO(knc1tp, "KNC1 DVB-T Plus", BUDGET_KNC1TP);
  1348. MAKE_BUDGET_INFO(cin1200s, "TerraTec Cinergy 1200 DVB-S", BUDGET_CIN1200S);
  1349. MAKE_BUDGET_INFO(cin1200sn, "TerraTec Cinergy 1200 DVB-S", BUDGET_CIN1200S);
  1350. MAKE_BUDGET_INFO(cin1200c, "Terratec Cinergy 1200 DVB-C", BUDGET_CIN1200C);
  1351. MAKE_BUDGET_INFO(cin1200cmk3, "Terratec Cinergy 1200 DVB-C MK3", BUDGET_CIN1200C_MK3);
  1352. MAKE_BUDGET_INFO(cin1200t, "Terratec Cinergy 1200 DVB-T", BUDGET_CIN1200T);
  1353. static const struct pci_device_id pci_tbl[] = {
  1354. MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x4f56),
  1355. MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x0010),
  1356. MAKE_EXTENSION_PCI(knc1s, 0x1894, 0x0010),
  1357. MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011),
  1358. MAKE_EXTENSION_PCI(knc1sp, 0x1894, 0x0011),
  1359. MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0014),
  1360. MAKE_EXTENSION_PCI(knc1spx4, 0x1894, 0x0015),
  1361. MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0016),
  1362. MAKE_EXTENSION_PCI(knc1s2, 0x1894, 0x0018),
  1363. MAKE_EXTENSION_PCI(knc1s2, 0x1894, 0x0019),
  1364. MAKE_EXTENSION_PCI(sates2, 0x1894, 0x001d),
  1365. MAKE_EXTENSION_PCI(satewpls, 0x1894, 0x001e),
  1366. MAKE_EXTENSION_PCI(satewpls1, 0x1894, 0x001a),
  1367. MAKE_EXTENSION_PCI(satewps, 0x1894, 0x001b),
  1368. MAKE_EXTENSION_PCI(satewplc, 0x1894, 0x002a),
  1369. MAKE_EXTENSION_PCI(satewcmk3, 0x1894, 0x002c),
  1370. MAKE_EXTENSION_PCI(satewt, 0x1894, 0x003a),
  1371. MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020),
  1372. MAKE_EXTENSION_PCI(knc1cp, 0x1894, 0x0021),
  1373. MAKE_EXTENSION_PCI(knc1cmk3, 0x1894, 0x0022),
  1374. MAKE_EXTENSION_PCI(knc1ctda10024, 0x1894, 0x0028),
  1375. MAKE_EXTENSION_PCI(knc1cpmk3, 0x1894, 0x0023),
  1376. MAKE_EXTENSION_PCI(knc1t, 0x1894, 0x0030),
  1377. MAKE_EXTENSION_PCI(knc1tp, 0x1894, 0x0031),
  1378. MAKE_EXTENSION_PCI(cin1200s, 0x153b, 0x1154),
  1379. MAKE_EXTENSION_PCI(cin1200sn, 0x153b, 0x1155),
  1380. MAKE_EXTENSION_PCI(cin1200c, 0x153b, 0x1156),
  1381. MAKE_EXTENSION_PCI(cin1200cmk3, 0x153b, 0x1176),
  1382. MAKE_EXTENSION_PCI(cin1200t, 0x153b, 0x1157),
  1383. {
  1384. .vendor = 0,
  1385. }
  1386. };
  1387. MODULE_DEVICE_TABLE(pci, pci_tbl);
  1388. static struct saa7146_extension budget_extension = {
  1389. .name = "budget_av",
  1390. .flags = SAA7146_USE_I2C_IRQ,
  1391. .pci_tbl = pci_tbl,
  1392. .module = THIS_MODULE,
  1393. .attach = budget_av_attach,
  1394. .detach = budget_av_detach,
  1395. .irq_mask = MASK_10,
  1396. .irq_func = budget_av_irq,
  1397. };
  1398. static int __init budget_av_init(void)
  1399. {
  1400. return saa7146_register_extension(&budget_extension);
  1401. }
  1402. static void __exit budget_av_exit(void)
  1403. {
  1404. saa7146_unregister_extension(&budget_extension);
  1405. }
  1406. module_init(budget_av_init);
  1407. module_exit(budget_av_exit);
  1408. MODULE_LICENSE("GPL");
  1409. MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, Michael Hunold, others");
  1410. MODULE_DESCRIPTION("driver for the SAA7146 based so-called budget PCI DVB w/ analog input and CI-module (e.g. the KNC cards)");