budget-core.c 17 KB

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