budget-core.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. /*
  2. * budget-core.c: driver for the SAA7146 based Budget DVB cards
  3. *
  4. * Compiled from various sources by Michael Hunold <michael@mihu.de>
  5. *
  6. * Copyright (C) 2002 Ralph Metzler <rjkm@metzlerbros.de>
  7. *
  8. * Copyright (C) 1999-2002 Ralph Metzler
  9. * & Marcus Metzler for convergence integrated media GmbH
  10. *
  11. * 26feb2004 Support for FS Activy Card (Grundig tuner) by
  12. * Michael Dreher <michael@5dot1.de>,
  13. * Oliver Endriss <o.endriss@gmx.de>,
  14. * Andreas 'randy' Weinberger
  15. *
  16. * This program is free software; you can redistribute it and/or
  17. * modify it under the terms of the GNU General Public License
  18. * as published by the Free Software Foundation; either version 2
  19. * of the License, or (at your option) any later version.
  20. *
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * To obtain the license, point your browser to
  28. * http://www.gnu.org/copyleft/gpl.html
  29. *
  30. *
  31. * the project's page is at https://linuxtv.org
  32. */
  33. #include "budget.h"
  34. #include "ttpci-eeprom.h"
  35. #define TS_WIDTH (2 * TS_SIZE)
  36. #define TS_WIDTH_ACTIVY TS_SIZE
  37. #define TS_WIDTH_DVBC TS_SIZE
  38. #define TS_HEIGHT_MASK 0xf00
  39. #define TS_HEIGHT_MASK_ACTIVY 0xc00
  40. #define TS_HEIGHT_MASK_DVBC 0xe00
  41. #define TS_MIN_BUFSIZE_K 188
  42. #define TS_MAX_BUFSIZE_K 1410
  43. #define TS_MAX_BUFSIZE_K_ACTIVY 564
  44. #define TS_MAX_BUFSIZE_K_DVBC 1316
  45. #define BUFFER_WARNING_WAIT (30*HZ)
  46. int budget_debug;
  47. static int dma_buffer_size = TS_MIN_BUFSIZE_K;
  48. module_param_named(debug, budget_debug, int, 0644);
  49. module_param_named(bufsize, dma_buffer_size, int, 0444);
  50. MODULE_PARM_DESC(debug, "Turn on/off budget debugging (default:off).");
  51. MODULE_PARM_DESC(bufsize, "DMA buffer size in KB, default: 188, min: 188, max: 1410 (Activy: 564)");
  52. /****************************************************************************
  53. * TT budget / WinTV Nova
  54. ****************************************************************************/
  55. static int stop_ts_capture(struct budget *budget)
  56. {
  57. dprintk(2, "budget: %p\n", budget);
  58. saa7146_write(budget->dev, MC1, MASK_20); // DMA3 off
  59. SAA7146_IER_DISABLE(budget->dev, MASK_10);
  60. return 0;
  61. }
  62. static int start_ts_capture(struct budget *budget)
  63. {
  64. struct saa7146_dev *dev = budget->dev;
  65. dprintk(2, "budget: %p\n", budget);
  66. if (!budget->feeding || !budget->fe_synced)
  67. return 0;
  68. saa7146_write(dev, MC1, MASK_20); // DMA3 off
  69. memset(budget->grabbing, 0x00, budget->buffer_size);
  70. saa7146_write(dev, PCI_BT_V1, 0x001c0000 | (saa7146_read(dev, PCI_BT_V1) & ~0x001f0000));
  71. budget->ttbp = 0;
  72. /*
  73. * Signal path on the Activy:
  74. *
  75. * tuner -> SAA7146 port A -> SAA7146 BRS -> SAA7146 DMA3 -> memory
  76. *
  77. * Since the tuner feeds 204 bytes packets into the SAA7146,
  78. * DMA3 is configured to strip the trailing 16 FEC bytes:
  79. * Pitch: 188, NumBytes3: 188, NumLines3: 1024
  80. */
  81. switch(budget->card->type) {
  82. case BUDGET_FS_ACTIVY:
  83. saa7146_write(dev, DD1_INIT, 0x04000000);
  84. saa7146_write(dev, MC2, (MASK_09 | MASK_25));
  85. saa7146_write(dev, BRS_CTRL, 0x00000000);
  86. break;
  87. case BUDGET_PATCH:
  88. saa7146_write(dev, DD1_INIT, 0x00000200);
  89. saa7146_write(dev, MC2, (MASK_10 | MASK_26));
  90. saa7146_write(dev, BRS_CTRL, 0x60000000);
  91. break;
  92. case BUDGET_CIN1200C_MK3:
  93. case BUDGET_KNC1C_MK3:
  94. case BUDGET_KNC1C_TDA10024:
  95. case BUDGET_KNC1CP_MK3:
  96. if (budget->video_port == BUDGET_VIDEO_PORTA) {
  97. saa7146_write(dev, DD1_INIT, 0x06000200);
  98. saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
  99. saa7146_write(dev, BRS_CTRL, 0x00000000);
  100. } else {
  101. saa7146_write(dev, DD1_INIT, 0x00000600);
  102. saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
  103. saa7146_write(dev, BRS_CTRL, 0x60000000);
  104. }
  105. break;
  106. default:
  107. if (budget->video_port == BUDGET_VIDEO_PORTA) {
  108. saa7146_write(dev, DD1_INIT, 0x06000200);
  109. saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
  110. saa7146_write(dev, BRS_CTRL, 0x00000000);
  111. } else {
  112. saa7146_write(dev, DD1_INIT, 0x02000600);
  113. saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
  114. saa7146_write(dev, BRS_CTRL, 0x60000000);
  115. }
  116. }
  117. saa7146_write(dev, MC2, (MASK_08 | MASK_24));
  118. mdelay(10);
  119. saa7146_write(dev, BASE_ODD3, 0);
  120. if (budget->buffer_size > budget->buffer_height * budget->buffer_width) {
  121. // using odd/even buffers
  122. saa7146_write(dev, BASE_EVEN3, budget->buffer_height * budget->buffer_width);
  123. } else {
  124. // using a single buffer
  125. saa7146_write(dev, BASE_EVEN3, 0);
  126. }
  127. saa7146_write(dev, PROT_ADDR3, budget->buffer_size);
  128. saa7146_write(dev, BASE_PAGE3, budget->pt.dma | ME1 | 0x90);
  129. saa7146_write(dev, PITCH3, budget->buffer_width);
  130. saa7146_write(dev, NUM_LINE_BYTE3,
  131. (budget->buffer_height << 16) | budget->buffer_width);
  132. saa7146_write(dev, MC2, (MASK_04 | MASK_20));
  133. SAA7146_ISR_CLEAR(budget->dev, MASK_10); /* VPE */
  134. SAA7146_IER_ENABLE(budget->dev, MASK_10); /* VPE */
  135. saa7146_write(dev, MC1, (MASK_04 | MASK_20)); /* DMA3 on */
  136. return 0;
  137. }
  138. static int budget_read_fe_status(struct dvb_frontend *fe,
  139. enum fe_status *status)
  140. {
  141. struct budget *budget = (struct budget *) fe->dvb->priv;
  142. int synced;
  143. int ret;
  144. if (budget->read_fe_status)
  145. ret = budget->read_fe_status(fe, status);
  146. else
  147. ret = -EINVAL;
  148. if (!ret) {
  149. synced = (*status & FE_HAS_LOCK);
  150. if (synced != budget->fe_synced) {
  151. budget->fe_synced = synced;
  152. spin_lock(&budget->feedlock);
  153. if (synced)
  154. start_ts_capture(budget);
  155. else
  156. stop_ts_capture(budget);
  157. spin_unlock(&budget->feedlock);
  158. }
  159. }
  160. return ret;
  161. }
  162. static void vpeirq(unsigned long data)
  163. {
  164. struct budget *budget = (struct budget *) data;
  165. u8 *mem = (u8 *) (budget->grabbing);
  166. u32 olddma = budget->ttbp;
  167. u32 newdma = saa7146_read(budget->dev, PCI_VDP3);
  168. u32 count;
  169. /* Ensure streamed PCI data is synced to CPU */
  170. pci_dma_sync_sg_for_cpu(budget->dev->pci, budget->pt.slist, budget->pt.nents, PCI_DMA_FROMDEVICE);
  171. /* nearest lower position divisible by 188 */
  172. newdma -= newdma % 188;
  173. if (newdma >= budget->buffer_size)
  174. return;
  175. budget->ttbp = newdma;
  176. if (budget->feeding == 0 || newdma == olddma)
  177. return;
  178. if (newdma > olddma) { /* no wraparound, dump olddma..newdma */
  179. count = newdma - olddma;
  180. dvb_dmx_swfilter_packets(&budget->demux, mem + olddma, count / 188);
  181. } else { /* wraparound, dump olddma..buflen and 0..newdma */
  182. count = budget->buffer_size - olddma;
  183. dvb_dmx_swfilter_packets(&budget->demux, mem + olddma, count / 188);
  184. count += newdma;
  185. dvb_dmx_swfilter_packets(&budget->demux, mem, newdma / 188);
  186. }
  187. if (count > budget->buffer_warning_threshold)
  188. budget->buffer_warnings++;
  189. if (budget->buffer_warnings && time_after(jiffies, budget->buffer_warning_time)) {
  190. printk("%s %s: used %d times >80%% of buffer (%u bytes now)\n",
  191. budget->dev->name, __func__, budget->buffer_warnings, count);
  192. budget->buffer_warning_time = jiffies + BUFFER_WARNING_WAIT;
  193. budget->buffer_warnings = 0;
  194. }
  195. }
  196. static int ttpci_budget_debiread_nolock(struct budget *budget, u32 config,
  197. int addr, int count, int nobusyloop)
  198. {
  199. struct saa7146_dev *saa = budget->dev;
  200. int result;
  201. result = saa7146_wait_for_debi_done(saa, nobusyloop);
  202. if (result < 0)
  203. return result;
  204. saa7146_write(saa, DEBI_COMMAND, (count << 17) | 0x10000 | (addr & 0xffff));
  205. saa7146_write(saa, DEBI_CONFIG, config);
  206. saa7146_write(saa, DEBI_PAGE, 0);
  207. saa7146_write(saa, MC2, (2 << 16) | 2);
  208. result = saa7146_wait_for_debi_done(saa, nobusyloop);
  209. if (result < 0)
  210. return result;
  211. result = saa7146_read(saa, DEBI_AD);
  212. result &= (0xffffffffUL >> ((4 - count) * 8));
  213. return result;
  214. }
  215. int ttpci_budget_debiread(struct budget *budget, u32 config, int addr, int count,
  216. int uselocks, int nobusyloop)
  217. {
  218. if (count > 4 || count <= 0)
  219. return 0;
  220. if (uselocks) {
  221. unsigned long flags;
  222. int result;
  223. spin_lock_irqsave(&budget->debilock, flags);
  224. result = ttpci_budget_debiread_nolock(budget, config, addr,
  225. count, nobusyloop);
  226. spin_unlock_irqrestore(&budget->debilock, flags);
  227. return result;
  228. }
  229. return ttpci_budget_debiread_nolock(budget, config, addr,
  230. count, nobusyloop);
  231. }
  232. static int ttpci_budget_debiwrite_nolock(struct budget *budget, u32 config,
  233. int addr, int count, u32 value, int nobusyloop)
  234. {
  235. struct saa7146_dev *saa = budget->dev;
  236. int result;
  237. result = saa7146_wait_for_debi_done(saa, nobusyloop);
  238. if (result < 0)
  239. return result;
  240. saa7146_write(saa, DEBI_COMMAND, (count << 17) | 0x00000 | (addr & 0xffff));
  241. saa7146_write(saa, DEBI_CONFIG, config);
  242. saa7146_write(saa, DEBI_PAGE, 0);
  243. saa7146_write(saa, DEBI_AD, value);
  244. saa7146_write(saa, MC2, (2 << 16) | 2);
  245. result = saa7146_wait_for_debi_done(saa, nobusyloop);
  246. return result < 0 ? result : 0;
  247. }
  248. int ttpci_budget_debiwrite(struct budget *budget, u32 config, int addr,
  249. int count, u32 value, int uselocks, int nobusyloop)
  250. {
  251. if (count > 4 || count <= 0)
  252. return 0;
  253. if (uselocks) {
  254. unsigned long flags;
  255. int result;
  256. spin_lock_irqsave(&budget->debilock, flags);
  257. result = ttpci_budget_debiwrite_nolock(budget, config, addr,
  258. count, value, nobusyloop);
  259. spin_unlock_irqrestore(&budget->debilock, flags);
  260. return result;
  261. }
  262. return ttpci_budget_debiwrite_nolock(budget, config, addr,
  263. count, value, nobusyloop);
  264. }
  265. /****************************************************************************
  266. * DVB API SECTION
  267. ****************************************************************************/
  268. static int budget_start_feed(struct dvb_demux_feed *feed)
  269. {
  270. struct dvb_demux *demux = feed->demux;
  271. struct budget *budget = (struct budget *) demux->priv;
  272. int status = 0;
  273. dprintk(2, "budget: %p\n", budget);
  274. if (!demux->dmx.frontend)
  275. return -EINVAL;
  276. spin_lock(&budget->feedlock);
  277. feed->pusi_seen = false; /* have a clean section start */
  278. if (budget->feeding++ == 0)
  279. status = start_ts_capture(budget);
  280. spin_unlock(&budget->feedlock);
  281. return status;
  282. }
  283. static int budget_stop_feed(struct dvb_demux_feed *feed)
  284. {
  285. struct dvb_demux *demux = feed->demux;
  286. struct budget *budget = (struct budget *) demux->priv;
  287. int status = 0;
  288. dprintk(2, "budget: %p\n", budget);
  289. spin_lock(&budget->feedlock);
  290. if (--budget->feeding == 0)
  291. status = stop_ts_capture(budget);
  292. spin_unlock(&budget->feedlock);
  293. return status;
  294. }
  295. static int budget_register(struct budget *budget)
  296. {
  297. struct dvb_demux *dvbdemux = &budget->demux;
  298. int ret;
  299. dprintk(2, "budget: %p\n", budget);
  300. dvbdemux->priv = (void *) budget;
  301. dvbdemux->filternum = 256;
  302. dvbdemux->feednum = 256;
  303. dvbdemux->start_feed = budget_start_feed;
  304. dvbdemux->stop_feed = budget_stop_feed;
  305. dvbdemux->write_to_decoder = NULL;
  306. dvbdemux->dmx.capabilities = (DMX_TS_FILTERING | DMX_SECTION_FILTERING |
  307. DMX_MEMORY_BASED_FILTERING);
  308. dvb_dmx_init(&budget->demux);
  309. budget->dmxdev.filternum = 256;
  310. budget->dmxdev.demux = &dvbdemux->dmx;
  311. budget->dmxdev.capabilities = 0;
  312. dvb_dmxdev_init(&budget->dmxdev, &budget->dvb_adapter);
  313. budget->hw_frontend.source = DMX_FRONTEND_0;
  314. ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &budget->hw_frontend);
  315. if (ret < 0)
  316. return ret;
  317. budget->mem_frontend.source = DMX_MEMORY_FE;
  318. ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &budget->mem_frontend);
  319. if (ret < 0)
  320. return ret;
  321. ret = dvbdemux->dmx.connect_frontend(&dvbdemux->dmx, &budget->hw_frontend);
  322. if (ret < 0)
  323. return ret;
  324. dvb_net_init(&budget->dvb_adapter, &budget->dvb_net, &dvbdemux->dmx);
  325. return 0;
  326. }
  327. static void budget_unregister(struct budget *budget)
  328. {
  329. struct dvb_demux *dvbdemux = &budget->demux;
  330. dprintk(2, "budget: %p\n", budget);
  331. dvb_net_release(&budget->dvb_net);
  332. dvbdemux->dmx.close(&dvbdemux->dmx);
  333. dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &budget->hw_frontend);
  334. dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &budget->mem_frontend);
  335. dvb_dmxdev_release(&budget->dmxdev);
  336. dvb_dmx_release(&budget->demux);
  337. }
  338. int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev,
  339. struct saa7146_pci_extension_data *info,
  340. struct module *owner, short *adapter_nums)
  341. {
  342. int ret = 0;
  343. struct budget_info *bi = info->ext_priv;
  344. int max_bufsize;
  345. int height_mask;
  346. memset(budget, 0, sizeof(struct budget));
  347. dprintk(2, "dev: %p, budget: %p\n", dev, budget);
  348. budget->card = bi;
  349. budget->dev = (struct saa7146_dev *) dev;
  350. switch(budget->card->type) {
  351. case BUDGET_FS_ACTIVY:
  352. budget->buffer_width = TS_WIDTH_ACTIVY;
  353. max_bufsize = TS_MAX_BUFSIZE_K_ACTIVY;
  354. height_mask = TS_HEIGHT_MASK_ACTIVY;
  355. break;
  356. case BUDGET_KNC1C:
  357. case BUDGET_KNC1CP:
  358. case BUDGET_CIN1200C:
  359. case BUDGET_KNC1C_MK3:
  360. case BUDGET_KNC1C_TDA10024:
  361. case BUDGET_KNC1CP_MK3:
  362. case BUDGET_CIN1200C_MK3:
  363. budget->buffer_width = TS_WIDTH_DVBC;
  364. max_bufsize = TS_MAX_BUFSIZE_K_DVBC;
  365. height_mask = TS_HEIGHT_MASK_DVBC;
  366. break;
  367. default:
  368. budget->buffer_width = TS_WIDTH;
  369. max_bufsize = TS_MAX_BUFSIZE_K;
  370. height_mask = TS_HEIGHT_MASK;
  371. }
  372. if (dma_buffer_size < TS_MIN_BUFSIZE_K)
  373. dma_buffer_size = TS_MIN_BUFSIZE_K;
  374. else if (dma_buffer_size > max_bufsize)
  375. dma_buffer_size = max_bufsize;
  376. budget->buffer_height = dma_buffer_size * 1024 / budget->buffer_width;
  377. if (budget->buffer_height > 0xfff) {
  378. budget->buffer_height /= 2;
  379. budget->buffer_height &= height_mask;
  380. budget->buffer_size = 2 * budget->buffer_height * budget->buffer_width;
  381. } else {
  382. budget->buffer_height &= height_mask;
  383. budget->buffer_size = budget->buffer_height * budget->buffer_width;
  384. }
  385. budget->buffer_warning_threshold = budget->buffer_size * 80/100;
  386. budget->buffer_warnings = 0;
  387. budget->buffer_warning_time = jiffies;
  388. dprintk(2, "%s: buffer type = %s, width = %d, height = %d\n",
  389. budget->dev->name,
  390. budget->buffer_size > budget->buffer_width * budget->buffer_height ? "odd/even" : "single",
  391. budget->buffer_width, budget->buffer_height);
  392. printk("%s: dma buffer size %u\n", budget->dev->name, budget->buffer_size);
  393. ret = dvb_register_adapter(&budget->dvb_adapter, budget->card->name,
  394. owner, &budget->dev->pci->dev, adapter_nums);
  395. if (ret < 0)
  396. return ret;
  397. /* set dd1 stream a & b */
  398. saa7146_write(dev, DD1_STREAM_B, 0x00000000);
  399. saa7146_write(dev, MC2, (MASK_09 | MASK_25));
  400. saa7146_write(dev, MC2, (MASK_10 | MASK_26));
  401. saa7146_write(dev, DD1_INIT, 0x02000000);
  402. saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
  403. if (bi->type != BUDGET_FS_ACTIVY)
  404. budget->video_port = BUDGET_VIDEO_PORTB;
  405. else
  406. budget->video_port = BUDGET_VIDEO_PORTA;
  407. spin_lock_init(&budget->feedlock);
  408. spin_lock_init(&budget->debilock);
  409. /* the Siemens DVB needs this if you want to have the i2c chips
  410. get recognized before the main driver is loaded */
  411. if (bi->type != BUDGET_FS_ACTIVY)
  412. saa7146_write(dev, GPIO_CTRL, 0x500000); /* GPIO 3 = 1 */
  413. strlcpy(budget->i2c_adap.name, budget->card->name, sizeof(budget->i2c_adap.name));
  414. saa7146_i2c_adapter_prepare(dev, &budget->i2c_adap, SAA7146_I2C_BUS_BIT_RATE_120);
  415. strcpy(budget->i2c_adap.name, budget->card->name);
  416. if (i2c_add_adapter(&budget->i2c_adap) < 0) {
  417. ret = -ENOMEM;
  418. goto err_dvb_unregister;
  419. }
  420. ttpci_eeprom_parse_mac(&budget->i2c_adap, budget->dvb_adapter.proposed_mac);
  421. budget->grabbing = saa7146_vmalloc_build_pgtable(dev->pci, budget->buffer_size, &budget->pt);
  422. if (NULL == budget->grabbing) {
  423. ret = -ENOMEM;
  424. goto err_del_i2c;
  425. }
  426. saa7146_write(dev, PCI_BT_V1, 0x001c0000);
  427. /* upload all */
  428. saa7146_write(dev, GPIO_CTRL, 0x000000);
  429. tasklet_init(&budget->vpe_tasklet, vpeirq, (unsigned long) budget);
  430. /* frontend power on */
  431. if (bi->type != BUDGET_FS_ACTIVY)
  432. saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI);
  433. if ((ret = budget_register(budget)) == 0)
  434. return 0; /* Everything OK */
  435. /* An error occurred, cleanup resources */
  436. saa7146_vfree_destroy_pgtable(dev->pci, budget->grabbing, &budget->pt);
  437. err_del_i2c:
  438. i2c_del_adapter(&budget->i2c_adap);
  439. err_dvb_unregister:
  440. dvb_unregister_adapter(&budget->dvb_adapter);
  441. return ret;
  442. }
  443. void ttpci_budget_init_hooks(struct budget *budget)
  444. {
  445. if (budget->dvb_frontend && !budget->read_fe_status) {
  446. budget->read_fe_status = budget->dvb_frontend->ops.read_status;
  447. budget->dvb_frontend->ops.read_status = budget_read_fe_status;
  448. }
  449. }
  450. int ttpci_budget_deinit(struct budget *budget)
  451. {
  452. struct saa7146_dev *dev = budget->dev;
  453. dprintk(2, "budget: %p\n", budget);
  454. budget_unregister(budget);
  455. tasklet_kill(&budget->vpe_tasklet);
  456. saa7146_vfree_destroy_pgtable(dev->pci, budget->grabbing, &budget->pt);
  457. i2c_del_adapter(&budget->i2c_adap);
  458. dvb_unregister_adapter(&budget->dvb_adapter);
  459. return 0;
  460. }
  461. void ttpci_budget_irq10_handler(struct saa7146_dev *dev, u32 * isr)
  462. {
  463. struct budget *budget = (struct budget *) dev->ext_priv;
  464. dprintk(8, "dev: %p, budget: %p\n", dev, budget);
  465. if (*isr & MASK_10)
  466. tasklet_schedule(&budget->vpe_tasklet);
  467. }
  468. void ttpci_budget_set_video_port(struct saa7146_dev *dev, int video_port)
  469. {
  470. struct budget *budget = (struct budget *) dev->ext_priv;
  471. spin_lock(&budget->feedlock);
  472. budget->video_port = video_port;
  473. if (budget->feeding) {
  474. stop_ts_capture(budget);
  475. start_ts_capture(budget);
  476. }
  477. spin_unlock(&budget->feedlock);
  478. }
  479. EXPORT_SYMBOL_GPL(ttpci_budget_debiread);
  480. EXPORT_SYMBOL_GPL(ttpci_budget_debiwrite);
  481. EXPORT_SYMBOL_GPL(ttpci_budget_init);
  482. EXPORT_SYMBOL_GPL(ttpci_budget_init_hooks);
  483. EXPORT_SYMBOL_GPL(ttpci_budget_deinit);
  484. EXPORT_SYMBOL_GPL(ttpci_budget_irq10_handler);
  485. EXPORT_SYMBOL_GPL(ttpci_budget_set_video_port);
  486. EXPORT_SYMBOL_GPL(budget_debug);
  487. MODULE_LICENSE("GPL");