budget-av.c 45 KB

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