cx88-core.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127
  1. /*
  2. *
  3. * device driver for Conexant 2388x based TV cards
  4. * driver core
  5. *
  6. * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
  7. *
  8. * (c) 2005-2006 Mauro Carvalho Chehab <mchehab@infradead.org>
  9. * - Multituner support
  10. * - video_ioctl2 conversion
  11. * - PAL/M fixes
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26. */
  27. #include <linux/init.h>
  28. #include <linux/list.h>
  29. #include <linux/module.h>
  30. #include <linux/kernel.h>
  31. #include <linux/slab.h>
  32. #include <linux/kmod.h>
  33. #include <linux/sound.h>
  34. #include <linux/interrupt.h>
  35. #include <linux/pci.h>
  36. #include <linux/delay.h>
  37. #include <linux/videodev2.h>
  38. #include <linux/mutex.h>
  39. #include "cx88.h"
  40. #include <media/v4l2-common.h>
  41. #include <media/v4l2-ioctl.h>
  42. MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards");
  43. MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
  44. MODULE_LICENSE("GPL");
  45. /* ------------------------------------------------------------------ */
  46. static unsigned int core_debug;
  47. module_param(core_debug,int,0644);
  48. MODULE_PARM_DESC(core_debug,"enable debug messages [core]");
  49. static unsigned int nicam;
  50. module_param(nicam,int,0644);
  51. MODULE_PARM_DESC(nicam,"tv audio is nicam");
  52. static unsigned int nocomb;
  53. module_param(nocomb,int,0644);
  54. MODULE_PARM_DESC(nocomb,"disable comb filter");
  55. #define dprintk(level,fmt, arg...) if (core_debug >= level) \
  56. printk(KERN_DEBUG "%s: " fmt, core->name , ## arg)
  57. static unsigned int cx88_devcount;
  58. static LIST_HEAD(cx88_devlist);
  59. static DEFINE_MUTEX(devlist);
  60. #define NO_SYNC_LINE (-1U)
  61. /* @lpi: lines per IRQ, or 0 to not generate irqs. Note: IRQ to be
  62. generated _after_ lpi lines are transferred. */
  63. static __le32* cx88_risc_field(__le32 *rp, struct scatterlist *sglist,
  64. unsigned int offset, u32 sync_line,
  65. unsigned int bpl, unsigned int padding,
  66. unsigned int lines, unsigned int lpi)
  67. {
  68. struct scatterlist *sg;
  69. unsigned int line,todo,sol;
  70. /* sync instruction */
  71. if (sync_line != NO_SYNC_LINE)
  72. *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line);
  73. /* scan lines */
  74. sg = sglist;
  75. for (line = 0; line < lines; line++) {
  76. while (offset && offset >= sg_dma_len(sg)) {
  77. offset -= sg_dma_len(sg);
  78. sg++;
  79. }
  80. if (lpi && line>0 && !(line % lpi))
  81. sol = RISC_SOL | RISC_IRQ1 | RISC_CNT_INC;
  82. else
  83. sol = RISC_SOL;
  84. if (bpl <= sg_dma_len(sg)-offset) {
  85. /* fits into current chunk */
  86. *(rp++)=cpu_to_le32(RISC_WRITE|sol|RISC_EOL|bpl);
  87. *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset);
  88. offset+=bpl;
  89. } else {
  90. /* scanline needs to be split */
  91. todo = bpl;
  92. *(rp++)=cpu_to_le32(RISC_WRITE|sol|
  93. (sg_dma_len(sg)-offset));
  94. *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset);
  95. todo -= (sg_dma_len(sg)-offset);
  96. offset = 0;
  97. sg++;
  98. while (todo > sg_dma_len(sg)) {
  99. *(rp++)=cpu_to_le32(RISC_WRITE|
  100. sg_dma_len(sg));
  101. *(rp++)=cpu_to_le32(sg_dma_address(sg));
  102. todo -= sg_dma_len(sg);
  103. sg++;
  104. }
  105. *(rp++)=cpu_to_le32(RISC_WRITE|RISC_EOL|todo);
  106. *(rp++)=cpu_to_le32(sg_dma_address(sg));
  107. offset += todo;
  108. }
  109. offset += padding;
  110. }
  111. return rp;
  112. }
  113. int cx88_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
  114. struct scatterlist *sglist,
  115. unsigned int top_offset, unsigned int bottom_offset,
  116. unsigned int bpl, unsigned int padding, unsigned int lines)
  117. {
  118. u32 instructions,fields;
  119. __le32 *rp;
  120. int rc;
  121. fields = 0;
  122. if (UNSET != top_offset)
  123. fields++;
  124. if (UNSET != bottom_offset)
  125. fields++;
  126. /* estimate risc mem: worst case is one write per page border +
  127. one write per scan line + syncs + jump (all 2 dwords). Padding
  128. can cause next bpl to start close to a page border. First DMA
  129. region may be smaller than PAGE_SIZE */
  130. instructions = fields * (1 + ((bpl + padding) * lines) / PAGE_SIZE + lines);
  131. instructions += 2;
  132. if ((rc = btcx_riscmem_alloc(pci,risc,instructions*8)) < 0)
  133. return rc;
  134. /* write risc instructions */
  135. rp = risc->cpu;
  136. if (UNSET != top_offset)
  137. rp = cx88_risc_field(rp, sglist, top_offset, 0,
  138. bpl, padding, lines, 0);
  139. if (UNSET != bottom_offset)
  140. rp = cx88_risc_field(rp, sglist, bottom_offset, 0x200,
  141. bpl, padding, lines, 0);
  142. /* save pointer to jmp instruction address */
  143. risc->jmp = rp;
  144. BUG_ON((risc->jmp - risc->cpu + 2) * sizeof (*risc->cpu) > risc->size);
  145. return 0;
  146. }
  147. int cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc,
  148. struct scatterlist *sglist, unsigned int bpl,
  149. unsigned int lines, unsigned int lpi)
  150. {
  151. u32 instructions;
  152. __le32 *rp;
  153. int rc;
  154. /* estimate risc mem: worst case is one write per page border +
  155. one write per scan line + syncs + jump (all 2 dwords). Here
  156. there is no padding and no sync. First DMA region may be smaller
  157. than PAGE_SIZE */
  158. instructions = 1 + (bpl * lines) / PAGE_SIZE + lines;
  159. instructions += 1;
  160. if ((rc = btcx_riscmem_alloc(pci,risc,instructions*8)) < 0)
  161. return rc;
  162. /* write risc instructions */
  163. rp = risc->cpu;
  164. rp = cx88_risc_field(rp, sglist, 0, NO_SYNC_LINE, bpl, 0, lines, lpi);
  165. /* save pointer to jmp instruction address */
  166. risc->jmp = rp;
  167. BUG_ON((risc->jmp - risc->cpu + 2) * sizeof (*risc->cpu) > risc->size);
  168. return 0;
  169. }
  170. int cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
  171. u32 reg, u32 mask, u32 value)
  172. {
  173. __le32 *rp;
  174. int rc;
  175. if ((rc = btcx_riscmem_alloc(pci, risc, 4*16)) < 0)
  176. return rc;
  177. /* write risc instructions */
  178. rp = risc->cpu;
  179. *(rp++) = cpu_to_le32(RISC_WRITECR | RISC_IRQ2 | RISC_IMM);
  180. *(rp++) = cpu_to_le32(reg);
  181. *(rp++) = cpu_to_le32(value);
  182. *(rp++) = cpu_to_le32(mask);
  183. *(rp++) = cpu_to_le32(RISC_JUMP);
  184. *(rp++) = cpu_to_le32(risc->dma);
  185. return 0;
  186. }
  187. void
  188. cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf)
  189. {
  190. struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
  191. BUG_ON(in_interrupt());
  192. videobuf_waiton(q, &buf->vb, 0, 0);
  193. videobuf_dma_unmap(q->dev, dma);
  194. videobuf_dma_free(dma);
  195. btcx_riscmem_free(to_pci_dev(q->dev), &buf->risc);
  196. buf->vb.state = VIDEOBUF_NEEDS_INIT;
  197. }
  198. /* ------------------------------------------------------------------ */
  199. /* our SRAM memory layout */
  200. /* we are going to put all thr risc programs into host memory, so we
  201. * can use the whole SDRAM for the DMA fifos. To simplify things, we
  202. * use a static memory layout. That surely will waste memory in case
  203. * we don't use all DMA channels at the same time (which will be the
  204. * case most of the time). But that still gives us enough FIFO space
  205. * to be able to deal with insane long pci latencies ...
  206. *
  207. * FIFO space allocations:
  208. * channel 21 (y video) - 10.0k
  209. * channel 22 (u video) - 2.0k
  210. * channel 23 (v video) - 2.0k
  211. * channel 24 (vbi) - 4.0k
  212. * channels 25+26 (audio) - 4.0k
  213. * channel 28 (mpeg) - 4.0k
  214. * channel 27 (audio rds)- 3.0k
  215. * TOTAL = 29.0k
  216. *
  217. * Every channel has 160 bytes control data (64 bytes instruction
  218. * queue and 6 CDT entries), which is close to 2k total.
  219. *
  220. * Address layout:
  221. * 0x0000 - 0x03ff CMDs / reserved
  222. * 0x0400 - 0x0bff instruction queues + CDs
  223. * 0x0c00 - FIFOs
  224. */
  225. const struct sram_channel const cx88_sram_channels[] = {
  226. [SRAM_CH21] = {
  227. .name = "video y / packed",
  228. .cmds_start = 0x180040,
  229. .ctrl_start = 0x180400,
  230. .cdt = 0x180400 + 64,
  231. .fifo_start = 0x180c00,
  232. .fifo_size = 0x002800,
  233. .ptr1_reg = MO_DMA21_PTR1,
  234. .ptr2_reg = MO_DMA21_PTR2,
  235. .cnt1_reg = MO_DMA21_CNT1,
  236. .cnt2_reg = MO_DMA21_CNT2,
  237. },
  238. [SRAM_CH22] = {
  239. .name = "video u",
  240. .cmds_start = 0x180080,
  241. .ctrl_start = 0x1804a0,
  242. .cdt = 0x1804a0 + 64,
  243. .fifo_start = 0x183400,
  244. .fifo_size = 0x000800,
  245. .ptr1_reg = MO_DMA22_PTR1,
  246. .ptr2_reg = MO_DMA22_PTR2,
  247. .cnt1_reg = MO_DMA22_CNT1,
  248. .cnt2_reg = MO_DMA22_CNT2,
  249. },
  250. [SRAM_CH23] = {
  251. .name = "video v",
  252. .cmds_start = 0x1800c0,
  253. .ctrl_start = 0x180540,
  254. .cdt = 0x180540 + 64,
  255. .fifo_start = 0x183c00,
  256. .fifo_size = 0x000800,
  257. .ptr1_reg = MO_DMA23_PTR1,
  258. .ptr2_reg = MO_DMA23_PTR2,
  259. .cnt1_reg = MO_DMA23_CNT1,
  260. .cnt2_reg = MO_DMA23_CNT2,
  261. },
  262. [SRAM_CH24] = {
  263. .name = "vbi",
  264. .cmds_start = 0x180100,
  265. .ctrl_start = 0x1805e0,
  266. .cdt = 0x1805e0 + 64,
  267. .fifo_start = 0x184400,
  268. .fifo_size = 0x001000,
  269. .ptr1_reg = MO_DMA24_PTR1,
  270. .ptr2_reg = MO_DMA24_PTR2,
  271. .cnt1_reg = MO_DMA24_CNT1,
  272. .cnt2_reg = MO_DMA24_CNT2,
  273. },
  274. [SRAM_CH25] = {
  275. .name = "audio from",
  276. .cmds_start = 0x180140,
  277. .ctrl_start = 0x180680,
  278. .cdt = 0x180680 + 64,
  279. .fifo_start = 0x185400,
  280. .fifo_size = 0x001000,
  281. .ptr1_reg = MO_DMA25_PTR1,
  282. .ptr2_reg = MO_DMA25_PTR2,
  283. .cnt1_reg = MO_DMA25_CNT1,
  284. .cnt2_reg = MO_DMA25_CNT2,
  285. },
  286. [SRAM_CH26] = {
  287. .name = "audio to",
  288. .cmds_start = 0x180180,
  289. .ctrl_start = 0x180720,
  290. .cdt = 0x180680 + 64, /* same as audio IN */
  291. .fifo_start = 0x185400, /* same as audio IN */
  292. .fifo_size = 0x001000, /* same as audio IN */
  293. .ptr1_reg = MO_DMA26_PTR1,
  294. .ptr2_reg = MO_DMA26_PTR2,
  295. .cnt1_reg = MO_DMA26_CNT1,
  296. .cnt2_reg = MO_DMA26_CNT2,
  297. },
  298. [SRAM_CH28] = {
  299. .name = "mpeg",
  300. .cmds_start = 0x180200,
  301. .ctrl_start = 0x1807C0,
  302. .cdt = 0x1807C0 + 64,
  303. .fifo_start = 0x186400,
  304. .fifo_size = 0x001000,
  305. .ptr1_reg = MO_DMA28_PTR1,
  306. .ptr2_reg = MO_DMA28_PTR2,
  307. .cnt1_reg = MO_DMA28_CNT1,
  308. .cnt2_reg = MO_DMA28_CNT2,
  309. },
  310. [SRAM_CH27] = {
  311. .name = "audio rds",
  312. .cmds_start = 0x1801C0,
  313. .ctrl_start = 0x180860,
  314. .cdt = 0x180860 + 64,
  315. .fifo_start = 0x187400,
  316. .fifo_size = 0x000C00,
  317. .ptr1_reg = MO_DMA27_PTR1,
  318. .ptr2_reg = MO_DMA27_PTR2,
  319. .cnt1_reg = MO_DMA27_CNT1,
  320. .cnt2_reg = MO_DMA27_CNT2,
  321. },
  322. };
  323. int cx88_sram_channel_setup(struct cx88_core *core,
  324. const struct sram_channel *ch,
  325. unsigned int bpl, u32 risc)
  326. {
  327. unsigned int i,lines;
  328. u32 cdt;
  329. bpl = (bpl + 7) & ~7; /* alignment */
  330. cdt = ch->cdt;
  331. lines = ch->fifo_size / bpl;
  332. if (lines > 6)
  333. lines = 6;
  334. BUG_ON(lines < 2);
  335. /* write CDT */
  336. for (i = 0; i < lines; i++)
  337. cx_write(cdt + 16*i, ch->fifo_start + bpl*i);
  338. /* write CMDS */
  339. cx_write(ch->cmds_start + 0, risc);
  340. cx_write(ch->cmds_start + 4, cdt);
  341. cx_write(ch->cmds_start + 8, (lines*16) >> 3);
  342. cx_write(ch->cmds_start + 12, ch->ctrl_start);
  343. cx_write(ch->cmds_start + 16, 64 >> 2);
  344. for (i = 20; i < 64; i += 4)
  345. cx_write(ch->cmds_start + i, 0);
  346. /* fill registers */
  347. cx_write(ch->ptr1_reg, ch->fifo_start);
  348. cx_write(ch->ptr2_reg, cdt);
  349. cx_write(ch->cnt1_reg, (bpl >> 3) -1);
  350. cx_write(ch->cnt2_reg, (lines*16) >> 3);
  351. dprintk(2,"sram setup %s: bpl=%d lines=%d\n", ch->name, bpl, lines);
  352. return 0;
  353. }
  354. /* ------------------------------------------------------------------ */
  355. /* debug helper code */
  356. static int cx88_risc_decode(u32 risc)
  357. {
  358. static const char * const instr[16] = {
  359. [ RISC_SYNC >> 28 ] = "sync",
  360. [ RISC_WRITE >> 28 ] = "write",
  361. [ RISC_WRITEC >> 28 ] = "writec",
  362. [ RISC_READ >> 28 ] = "read",
  363. [ RISC_READC >> 28 ] = "readc",
  364. [ RISC_JUMP >> 28 ] = "jump",
  365. [ RISC_SKIP >> 28 ] = "skip",
  366. [ RISC_WRITERM >> 28 ] = "writerm",
  367. [ RISC_WRITECM >> 28 ] = "writecm",
  368. [ RISC_WRITECR >> 28 ] = "writecr",
  369. };
  370. static int const incr[16] = {
  371. [ RISC_WRITE >> 28 ] = 2,
  372. [ RISC_JUMP >> 28 ] = 2,
  373. [ RISC_WRITERM >> 28 ] = 3,
  374. [ RISC_WRITECM >> 28 ] = 3,
  375. [ RISC_WRITECR >> 28 ] = 4,
  376. };
  377. static const char * const bits[] = {
  378. "12", "13", "14", "resync",
  379. "cnt0", "cnt1", "18", "19",
  380. "20", "21", "22", "23",
  381. "irq1", "irq2", "eol", "sol",
  382. };
  383. int i;
  384. printk("0x%08x [ %s", risc,
  385. instr[risc >> 28] ? instr[risc >> 28] : "INVALID");
  386. for (i = ARRAY_SIZE(bits)-1; i >= 0; i--)
  387. if (risc & (1 << (i + 12)))
  388. printk(" %s",bits[i]);
  389. printk(" count=%d ]\n", risc & 0xfff);
  390. return incr[risc >> 28] ? incr[risc >> 28] : 1;
  391. }
  392. void cx88_sram_channel_dump(struct cx88_core *core,
  393. const struct sram_channel *ch)
  394. {
  395. static const char * const name[] = {
  396. "initial risc",
  397. "cdt base",
  398. "cdt size",
  399. "iq base",
  400. "iq size",
  401. "risc pc",
  402. "iq wr ptr",
  403. "iq rd ptr",
  404. "cdt current",
  405. "pci target",
  406. "line / byte",
  407. };
  408. u32 risc;
  409. unsigned int i,j,n;
  410. printk("%s: %s - dma channel status dump\n",
  411. core->name,ch->name);
  412. for (i = 0; i < ARRAY_SIZE(name); i++)
  413. printk("%s: cmds: %-12s: 0x%08x\n",
  414. core->name,name[i],
  415. cx_read(ch->cmds_start + 4*i));
  416. for (n = 1, i = 0; i < 4; i++) {
  417. risc = cx_read(ch->cmds_start + 4 * (i+11));
  418. printk("%s: risc%d: ", core->name, i);
  419. if (--n)
  420. printk("0x%08x [ arg #%d ]\n", risc, n);
  421. else
  422. n = cx88_risc_decode(risc);
  423. }
  424. for (i = 0; i < 16; i += n) {
  425. risc = cx_read(ch->ctrl_start + 4 * i);
  426. printk("%s: iq %x: ", core->name, i);
  427. n = cx88_risc_decode(risc);
  428. for (j = 1; j < n; j++) {
  429. risc = cx_read(ch->ctrl_start + 4 * (i+j));
  430. printk("%s: iq %x: 0x%08x [ arg #%d ]\n",
  431. core->name, i+j, risc, j);
  432. }
  433. }
  434. printk("%s: fifo: 0x%08x -> 0x%x\n",
  435. core->name, ch->fifo_start, ch->fifo_start+ch->fifo_size);
  436. printk("%s: ctrl: 0x%08x -> 0x%x\n",
  437. core->name, ch->ctrl_start, ch->ctrl_start+6*16);
  438. printk("%s: ptr1_reg: 0x%08x\n",
  439. core->name,cx_read(ch->ptr1_reg));
  440. printk("%s: ptr2_reg: 0x%08x\n",
  441. core->name,cx_read(ch->ptr2_reg));
  442. printk("%s: cnt1_reg: 0x%08x\n",
  443. core->name,cx_read(ch->cnt1_reg));
  444. printk("%s: cnt2_reg: 0x%08x\n",
  445. core->name,cx_read(ch->cnt2_reg));
  446. }
  447. static const char *cx88_pci_irqs[32] = {
  448. "vid", "aud", "ts", "vip", "hst", "5", "6", "tm1",
  449. "src_dma", "dst_dma", "risc_rd_err", "risc_wr_err",
  450. "brdg_err", "src_dma_err", "dst_dma_err", "ipb_dma_err",
  451. "i2c", "i2c_rack", "ir_smp", "gpio0", "gpio1"
  452. };
  453. void cx88_print_irqbits(const char *name, const char *tag, const char *strings[],
  454. int len, u32 bits, u32 mask)
  455. {
  456. unsigned int i;
  457. printk(KERN_DEBUG "%s: %s [0x%x]", name, tag, bits);
  458. for (i = 0; i < len; i++) {
  459. if (!(bits & (1 << i)))
  460. continue;
  461. if (strings[i])
  462. printk(" %s", strings[i]);
  463. else
  464. printk(" %d", i);
  465. if (!(mask & (1 << i)))
  466. continue;
  467. printk("*");
  468. }
  469. printk("\n");
  470. }
  471. /* ------------------------------------------------------------------ */
  472. int cx88_core_irq(struct cx88_core *core, u32 status)
  473. {
  474. int handled = 0;
  475. if (status & PCI_INT_IR_SMPINT) {
  476. cx88_ir_irq(core);
  477. handled++;
  478. }
  479. if (!handled)
  480. cx88_print_irqbits(core->name, "irq pci",
  481. cx88_pci_irqs, ARRAY_SIZE(cx88_pci_irqs),
  482. status, core->pci_irqmask);
  483. return handled;
  484. }
  485. void cx88_wakeup(struct cx88_core *core,
  486. struct cx88_dmaqueue *q, u32 count)
  487. {
  488. struct cx88_buffer *buf;
  489. int bc;
  490. for (bc = 0;; bc++) {
  491. if (list_empty(&q->active))
  492. break;
  493. buf = list_entry(q->active.next,
  494. struct cx88_buffer, vb.queue);
  495. /* count comes from the hw and is is 16bit wide --
  496. * this trick handles wrap-arounds correctly for
  497. * up to 32767 buffers in flight... */
  498. if ((s16) (count - buf->count) < 0)
  499. break;
  500. do_gettimeofday(&buf->vb.ts);
  501. dprintk(2,"[%p/%d] wakeup reg=%d buf=%d\n",buf,buf->vb.i,
  502. count, buf->count);
  503. buf->vb.state = VIDEOBUF_DONE;
  504. list_del(&buf->vb.queue);
  505. wake_up(&buf->vb.done);
  506. }
  507. if (list_empty(&q->active)) {
  508. del_timer(&q->timeout);
  509. } else {
  510. mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
  511. }
  512. if (bc != 1)
  513. dprintk(2, "%s: %d buffers handled (should be 1)\n",
  514. __func__, bc);
  515. }
  516. void cx88_shutdown(struct cx88_core *core)
  517. {
  518. /* disable RISC controller + IRQs */
  519. cx_write(MO_DEV_CNTRL2, 0);
  520. /* stop dma transfers */
  521. cx_write(MO_VID_DMACNTRL, 0x0);
  522. cx_write(MO_AUD_DMACNTRL, 0x0);
  523. cx_write(MO_TS_DMACNTRL, 0x0);
  524. cx_write(MO_VIP_DMACNTRL, 0x0);
  525. cx_write(MO_GPHST_DMACNTRL, 0x0);
  526. /* stop interrupts */
  527. cx_write(MO_PCI_INTMSK, 0x0);
  528. cx_write(MO_VID_INTMSK, 0x0);
  529. cx_write(MO_AUD_INTMSK, 0x0);
  530. cx_write(MO_TS_INTMSK, 0x0);
  531. cx_write(MO_VIP_INTMSK, 0x0);
  532. cx_write(MO_GPHST_INTMSK, 0x0);
  533. /* stop capturing */
  534. cx_write(VID_CAPTURE_CONTROL, 0);
  535. }
  536. int cx88_reset(struct cx88_core *core)
  537. {
  538. dprintk(1,"%s\n",__func__);
  539. cx88_shutdown(core);
  540. /* clear irq status */
  541. cx_write(MO_VID_INTSTAT, 0xFFFFFFFF); // Clear PIV int
  542. cx_write(MO_PCI_INTSTAT, 0xFFFFFFFF); // Clear PCI int
  543. cx_write(MO_INT1_STAT, 0xFFFFFFFF); // Clear RISC int
  544. /* wait a bit */
  545. msleep(100);
  546. /* init sram */
  547. cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH21], 720*4, 0);
  548. cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH22], 128, 0);
  549. cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH23], 128, 0);
  550. cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH24], 128, 0);
  551. cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], 128, 0);
  552. cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], 128, 0);
  553. cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28], 188*4, 0);
  554. cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH27], 128, 0);
  555. /* misc init ... */
  556. cx_write(MO_INPUT_FORMAT, ((1 << 13) | // agc enable
  557. (1 << 12) | // agc gain
  558. (1 << 11) | // adaptibe agc
  559. (0 << 10) | // chroma agc
  560. (0 << 9) | // ckillen
  561. (7)));
  562. /* setup image format */
  563. cx_andor(MO_COLOR_CTRL, 0x4000, 0x4000);
  564. /* setup FIFO Thresholds */
  565. cx_write(MO_PDMA_STHRSH, 0x0807);
  566. cx_write(MO_PDMA_DTHRSH, 0x0807);
  567. /* fixes flashing of image */
  568. cx_write(MO_AGC_SYNC_TIP1, 0x0380000F);
  569. cx_write(MO_AGC_BACK_VBI, 0x00E00555);
  570. cx_write(MO_VID_INTSTAT, 0xFFFFFFFF); // Clear PIV int
  571. cx_write(MO_PCI_INTSTAT, 0xFFFFFFFF); // Clear PCI int
  572. cx_write(MO_INT1_STAT, 0xFFFFFFFF); // Clear RISC int
  573. /* Reset on-board parts */
  574. cx_write(MO_SRST_IO, 0);
  575. msleep(10);
  576. cx_write(MO_SRST_IO, 1);
  577. return 0;
  578. }
  579. /* ------------------------------------------------------------------ */
  580. static unsigned int inline norm_swidth(v4l2_std_id norm)
  581. {
  582. return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 754 : 922;
  583. }
  584. static unsigned int inline norm_hdelay(v4l2_std_id norm)
  585. {
  586. return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 135 : 186;
  587. }
  588. static unsigned int inline norm_vdelay(v4l2_std_id norm)
  589. {
  590. return (norm & V4L2_STD_625_50) ? 0x24 : 0x18;
  591. }
  592. static unsigned int inline norm_fsc8(v4l2_std_id norm)
  593. {
  594. if (norm & V4L2_STD_PAL_M)
  595. return 28604892; // 3.575611 MHz
  596. if (norm & (V4L2_STD_PAL_Nc))
  597. return 28656448; // 3.582056 MHz
  598. if (norm & V4L2_STD_NTSC) // All NTSC/M and variants
  599. return 28636360; // 3.57954545 MHz +/- 10 Hz
  600. /* SECAM have also different sub carrier for chroma,
  601. but step_db and step_dr, at cx88_set_tvnorm already handles that.
  602. The same FSC applies to PAL/BGDKIH, PAL/60, NTSC/4.43 and PAL/N
  603. */
  604. return 35468950; // 4.43361875 MHz +/- 5 Hz
  605. }
  606. static unsigned int inline norm_htotal(v4l2_std_id norm)
  607. {
  608. unsigned int fsc4=norm_fsc8(norm)/2;
  609. /* returns 4*FSC / vtotal / frames per seconds */
  610. return (norm & V4L2_STD_625_50) ?
  611. ((fsc4+312)/625+12)/25 :
  612. ((fsc4+262)/525*1001+15000)/30000;
  613. }
  614. static unsigned int inline norm_vbipack(v4l2_std_id norm)
  615. {
  616. return (norm & V4L2_STD_625_50) ? 511 : 400;
  617. }
  618. int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int height,
  619. enum v4l2_field field)
  620. {
  621. unsigned int swidth = norm_swidth(core->tvnorm);
  622. unsigned int sheight = norm_maxh(core->tvnorm);
  623. u32 value;
  624. dprintk(1,"set_scale: %dx%d [%s%s,%s]\n", width, height,
  625. V4L2_FIELD_HAS_TOP(field) ? "T" : "",
  626. V4L2_FIELD_HAS_BOTTOM(field) ? "B" : "",
  627. v4l2_norm_to_name(core->tvnorm));
  628. if (!V4L2_FIELD_HAS_BOTH(field))
  629. height *= 2;
  630. // recalc H delay and scale registers
  631. value = (width * norm_hdelay(core->tvnorm)) / swidth;
  632. value &= 0x3fe;
  633. cx_write(MO_HDELAY_EVEN, value);
  634. cx_write(MO_HDELAY_ODD, value);
  635. dprintk(1,"set_scale: hdelay 0x%04x (width %d)\n", value,swidth);
  636. value = (swidth * 4096 / width) - 4096;
  637. cx_write(MO_HSCALE_EVEN, value);
  638. cx_write(MO_HSCALE_ODD, value);
  639. dprintk(1,"set_scale: hscale 0x%04x\n", value);
  640. cx_write(MO_HACTIVE_EVEN, width);
  641. cx_write(MO_HACTIVE_ODD, width);
  642. dprintk(1,"set_scale: hactive 0x%04x\n", width);
  643. // recalc V scale Register (delay is constant)
  644. cx_write(MO_VDELAY_EVEN, norm_vdelay(core->tvnorm));
  645. cx_write(MO_VDELAY_ODD, norm_vdelay(core->tvnorm));
  646. dprintk(1,"set_scale: vdelay 0x%04x\n", norm_vdelay(core->tvnorm));
  647. value = (0x10000 - (sheight * 512 / height - 512)) & 0x1fff;
  648. cx_write(MO_VSCALE_EVEN, value);
  649. cx_write(MO_VSCALE_ODD, value);
  650. dprintk(1,"set_scale: vscale 0x%04x\n", value);
  651. cx_write(MO_VACTIVE_EVEN, sheight);
  652. cx_write(MO_VACTIVE_ODD, sheight);
  653. dprintk(1,"set_scale: vactive 0x%04x\n", sheight);
  654. // setup filters
  655. value = 0;
  656. value |= (1 << 19); // CFILT (default)
  657. if (core->tvnorm & V4L2_STD_SECAM) {
  658. value |= (1 << 15);
  659. value |= (1 << 16);
  660. }
  661. if (INPUT(core->input).type == CX88_VMUX_SVIDEO)
  662. value |= (1 << 13) | (1 << 5);
  663. if (V4L2_FIELD_INTERLACED == field)
  664. value |= (1 << 3); // VINT (interlaced vertical scaling)
  665. if (width < 385)
  666. value |= (1 << 0); // 3-tap interpolation
  667. if (width < 193)
  668. value |= (1 << 1); // 5-tap interpolation
  669. if (nocomb)
  670. value |= (3 << 5); // disable comb filter
  671. cx_andor(MO_FILTER_EVEN, 0x7ffc7f, value); /* preserve PEAKEN, PSEL */
  672. cx_andor(MO_FILTER_ODD, 0x7ffc7f, value);
  673. dprintk(1,"set_scale: filter 0x%04x\n", value);
  674. return 0;
  675. }
  676. static const u32 xtal = 28636363;
  677. static int set_pll(struct cx88_core *core, int prescale, u32 ofreq)
  678. {
  679. static const u32 pre[] = { 0, 0, 0, 3, 2, 1 };
  680. u64 pll;
  681. u32 reg;
  682. int i;
  683. if (prescale < 2)
  684. prescale = 2;
  685. if (prescale > 5)
  686. prescale = 5;
  687. pll = ofreq * 8 * prescale * (u64)(1 << 20);
  688. do_div(pll,xtal);
  689. reg = (pll & 0x3ffffff) | (pre[prescale] << 26);
  690. if (((reg >> 20) & 0x3f) < 14) {
  691. printk("%s/0: pll out of range\n",core->name);
  692. return -1;
  693. }
  694. dprintk(1,"set_pll: MO_PLL_REG 0x%08x [old=0x%08x,freq=%d]\n",
  695. reg, cx_read(MO_PLL_REG), ofreq);
  696. cx_write(MO_PLL_REG, reg);
  697. for (i = 0; i < 100; i++) {
  698. reg = cx_read(MO_DEVICE_STATUS);
  699. if (reg & (1<<2)) {
  700. dprintk(1,"pll locked [pre=%d,ofreq=%d]\n",
  701. prescale,ofreq);
  702. return 0;
  703. }
  704. dprintk(1,"pll not locked yet, waiting ...\n");
  705. msleep(10);
  706. }
  707. dprintk(1,"pll NOT locked [pre=%d,ofreq=%d]\n",prescale,ofreq);
  708. return -1;
  709. }
  710. int cx88_start_audio_dma(struct cx88_core *core)
  711. {
  712. /* constant 128 made buzz in analog Nicam-stereo for bigger fifo_size */
  713. int bpl = cx88_sram_channels[SRAM_CH25].fifo_size/4;
  714. int rds_bpl = cx88_sram_channels[SRAM_CH27].fifo_size/AUD_RDS_LINES;
  715. /* If downstream RISC is enabled, bail out; ALSA is managing DMA */
  716. if (cx_read(MO_AUD_DMACNTRL) & 0x10)
  717. return 0;
  718. /* setup fifo + format */
  719. cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], bpl, 0);
  720. cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], bpl, 0);
  721. cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH27],
  722. rds_bpl, 0);
  723. cx_write(MO_AUDD_LNGTH, bpl); /* fifo bpl size */
  724. cx_write(MO_AUDR_LNGTH, rds_bpl); /* fifo bpl size */
  725. /* enable Up, Down and Audio RDS fifo */
  726. cx_write(MO_AUD_DMACNTRL, 0x0007);
  727. return 0;
  728. }
  729. int cx88_stop_audio_dma(struct cx88_core *core)
  730. {
  731. /* If downstream RISC is enabled, bail out; ALSA is managing DMA */
  732. if (cx_read(MO_AUD_DMACNTRL) & 0x10)
  733. return 0;
  734. /* stop dma */
  735. cx_write(MO_AUD_DMACNTRL, 0x0000);
  736. return 0;
  737. }
  738. static int set_tvaudio(struct cx88_core *core)
  739. {
  740. v4l2_std_id norm = core->tvnorm;
  741. if (CX88_VMUX_TELEVISION != INPUT(core->input).type &&
  742. CX88_VMUX_CABLE != INPUT(core->input).type)
  743. return 0;
  744. if (V4L2_STD_PAL_BG & norm) {
  745. core->tvaudio = WW_BG;
  746. } else if (V4L2_STD_PAL_DK & norm) {
  747. core->tvaudio = WW_DK;
  748. } else if (V4L2_STD_PAL_I & norm) {
  749. core->tvaudio = WW_I;
  750. } else if (V4L2_STD_SECAM_L & norm) {
  751. core->tvaudio = WW_L;
  752. } else if ((V4L2_STD_SECAM_B | V4L2_STD_SECAM_G | V4L2_STD_SECAM_H) & norm) {
  753. core->tvaudio = WW_BG;
  754. } else if (V4L2_STD_SECAM_DK & norm) {
  755. core->tvaudio = WW_DK;
  756. } else if ((V4L2_STD_NTSC_M & norm) ||
  757. (V4L2_STD_PAL_M & norm)) {
  758. core->tvaudio = WW_BTSC;
  759. } else if (V4L2_STD_NTSC_M_JP & norm) {
  760. core->tvaudio = WW_EIAJ;
  761. } else {
  762. printk("%s/0: tvaudio support needs work for this tv norm [%s], sorry\n",
  763. core->name, v4l2_norm_to_name(core->tvnorm));
  764. core->tvaudio = WW_NONE;
  765. return 0;
  766. }
  767. cx_andor(MO_AFECFG_IO, 0x1f, 0x0);
  768. cx88_set_tvaudio(core);
  769. /* cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO); */
  770. /*
  771. This should be needed only on cx88-alsa. It seems that some cx88 chips have
  772. bugs and does require DMA enabled for it to work.
  773. */
  774. cx88_start_audio_dma(core);
  775. return 0;
  776. }
  777. int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm)
  778. {
  779. u32 fsc8;
  780. u32 adc_clock;
  781. u32 vdec_clock;
  782. u32 step_db,step_dr;
  783. u64 tmp64;
  784. u32 bdelay,agcdelay,htotal;
  785. u32 cxiformat, cxoformat;
  786. core->tvnorm = norm;
  787. fsc8 = norm_fsc8(norm);
  788. adc_clock = xtal;
  789. vdec_clock = fsc8;
  790. step_db = fsc8;
  791. step_dr = fsc8;
  792. if (norm & V4L2_STD_NTSC_M_JP) {
  793. cxiformat = VideoFormatNTSCJapan;
  794. cxoformat = 0x181f0008;
  795. } else if (norm & V4L2_STD_NTSC_443) {
  796. cxiformat = VideoFormatNTSC443;
  797. cxoformat = 0x181f0008;
  798. } else if (norm & V4L2_STD_PAL_M) {
  799. cxiformat = VideoFormatPALM;
  800. cxoformat = 0x1c1f0008;
  801. } else if (norm & V4L2_STD_PAL_N) {
  802. cxiformat = VideoFormatPALN;
  803. cxoformat = 0x1c1f0008;
  804. } else if (norm & V4L2_STD_PAL_Nc) {
  805. cxiformat = VideoFormatPALNC;
  806. cxoformat = 0x1c1f0008;
  807. } else if (norm & V4L2_STD_PAL_60) {
  808. cxiformat = VideoFormatPAL60;
  809. cxoformat = 0x181f0008;
  810. } else if (norm & V4L2_STD_NTSC) {
  811. cxiformat = VideoFormatNTSC;
  812. cxoformat = 0x181f0008;
  813. } else if (norm & V4L2_STD_SECAM) {
  814. step_db = 4250000 * 8;
  815. step_dr = 4406250 * 8;
  816. cxiformat = VideoFormatSECAM;
  817. cxoformat = 0x181f0008;
  818. } else { /* PAL */
  819. cxiformat = VideoFormatPAL;
  820. cxoformat = 0x181f0008;
  821. }
  822. dprintk(1,"set_tvnorm: \"%s\" fsc8=%d adc=%d vdec=%d db/dr=%d/%d\n",
  823. v4l2_norm_to_name(core->tvnorm), fsc8, adc_clock, vdec_clock,
  824. step_db, step_dr);
  825. set_pll(core,2,vdec_clock);
  826. dprintk(1,"set_tvnorm: MO_INPUT_FORMAT 0x%08x [old=0x%08x]\n",
  827. cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f);
  828. /* Chroma AGC must be disabled if SECAM is used, we enable it
  829. by default on PAL and NTSC */
  830. cx_andor(MO_INPUT_FORMAT, 0x40f,
  831. norm & V4L2_STD_SECAM ? cxiformat : cxiformat | 0x400);
  832. // FIXME: as-is from DScaler
  833. dprintk(1,"set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n",
  834. cxoformat, cx_read(MO_OUTPUT_FORMAT));
  835. cx_write(MO_OUTPUT_FORMAT, cxoformat);
  836. // MO_SCONV_REG = adc clock / video dec clock * 2^17
  837. tmp64 = adc_clock * (u64)(1 << 17);
  838. do_div(tmp64, vdec_clock);
  839. dprintk(1,"set_tvnorm: MO_SCONV_REG 0x%08x [old=0x%08x]\n",
  840. (u32)tmp64, cx_read(MO_SCONV_REG));
  841. cx_write(MO_SCONV_REG, (u32)tmp64);
  842. // MO_SUB_STEP = 8 * fsc / video dec clock * 2^22
  843. tmp64 = step_db * (u64)(1 << 22);
  844. do_div(tmp64, vdec_clock);
  845. dprintk(1,"set_tvnorm: MO_SUB_STEP 0x%08x [old=0x%08x]\n",
  846. (u32)tmp64, cx_read(MO_SUB_STEP));
  847. cx_write(MO_SUB_STEP, (u32)tmp64);
  848. // MO_SUB_STEP_DR = 8 * 4406250 / video dec clock * 2^22
  849. tmp64 = step_dr * (u64)(1 << 22);
  850. do_div(tmp64, vdec_clock);
  851. dprintk(1,"set_tvnorm: MO_SUB_STEP_DR 0x%08x [old=0x%08x]\n",
  852. (u32)tmp64, cx_read(MO_SUB_STEP_DR));
  853. cx_write(MO_SUB_STEP_DR, (u32)tmp64);
  854. // bdelay + agcdelay
  855. bdelay = vdec_clock * 65 / 20000000 + 21;
  856. agcdelay = vdec_clock * 68 / 20000000 + 15;
  857. dprintk(1,"set_tvnorm: MO_AGC_BURST 0x%08x [old=0x%08x,bdelay=%d,agcdelay=%d]\n",
  858. (bdelay << 8) | agcdelay, cx_read(MO_AGC_BURST), bdelay, agcdelay);
  859. cx_write(MO_AGC_BURST, (bdelay << 8) | agcdelay);
  860. // htotal
  861. tmp64 = norm_htotal(norm) * (u64)vdec_clock;
  862. do_div(tmp64, fsc8);
  863. htotal = (u32)tmp64;
  864. dprintk(1,"set_tvnorm: MO_HTOTAL 0x%08x [old=0x%08x,htotal=%d]\n",
  865. htotal, cx_read(MO_HTOTAL), (u32)tmp64);
  866. cx_andor(MO_HTOTAL, 0x07ff, htotal);
  867. // vbi stuff, set vbi offset to 10 (for 20 Clk*2 pixels), this makes
  868. // the effective vbi offset ~244 samples, the same as the Bt8x8
  869. cx_write(MO_VBI_PACKET, (10<<11) | norm_vbipack(norm));
  870. // this is needed as well to set all tvnorm parameter
  871. cx88_set_scale(core, 320, 240, V4L2_FIELD_INTERLACED);
  872. // audio
  873. set_tvaudio(core);
  874. // tell i2c chips
  875. call_all(core, core, s_std, norm);
  876. // done
  877. return 0;
  878. }
  879. /* ------------------------------------------------------------------ */
  880. struct video_device *cx88_vdev_init(struct cx88_core *core,
  881. struct pci_dev *pci,
  882. const struct video_device *template_,
  883. const char *type)
  884. {
  885. struct video_device *vfd;
  886. vfd = video_device_alloc();
  887. if (NULL == vfd)
  888. return NULL;
  889. *vfd = *template_;
  890. vfd->v4l2_dev = &core->v4l2_dev;
  891. vfd->parent = &pci->dev;
  892. vfd->release = video_device_release;
  893. snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
  894. core->name, type, core->board.name);
  895. return vfd;
  896. }
  897. struct cx88_core* cx88_core_get(struct pci_dev *pci)
  898. {
  899. struct cx88_core *core;
  900. mutex_lock(&devlist);
  901. list_for_each_entry(core, &cx88_devlist, devlist) {
  902. if (pci->bus->number != core->pci_bus)
  903. continue;
  904. if (PCI_SLOT(pci->devfn) != core->pci_slot)
  905. continue;
  906. if (0 != cx88_get_resources(core, pci)) {
  907. mutex_unlock(&devlist);
  908. return NULL;
  909. }
  910. atomic_inc(&core->refcount);
  911. mutex_unlock(&devlist);
  912. return core;
  913. }
  914. core = cx88_core_create(pci, cx88_devcount);
  915. if (NULL != core) {
  916. cx88_devcount++;
  917. list_add_tail(&core->devlist, &cx88_devlist);
  918. }
  919. mutex_unlock(&devlist);
  920. return core;
  921. }
  922. void cx88_core_put(struct cx88_core *core, struct pci_dev *pci)
  923. {
  924. release_mem_region(pci_resource_start(pci,0),
  925. pci_resource_len(pci,0));
  926. if (!atomic_dec_and_test(&core->refcount))
  927. return;
  928. mutex_lock(&devlist);
  929. cx88_ir_fini(core);
  930. if (0 == core->i2c_rc) {
  931. if (core->i2c_rtc)
  932. i2c_unregister_device(core->i2c_rtc);
  933. i2c_del_adapter(&core->i2c_adap);
  934. }
  935. list_del(&core->devlist);
  936. iounmap(core->lmmio);
  937. cx88_devcount--;
  938. mutex_unlock(&devlist);
  939. v4l2_device_unregister(&core->v4l2_dev);
  940. kfree(core);
  941. }
  942. /* ------------------------------------------------------------------ */
  943. EXPORT_SYMBOL(cx88_print_irqbits);
  944. EXPORT_SYMBOL(cx88_core_irq);
  945. EXPORT_SYMBOL(cx88_wakeup);
  946. EXPORT_SYMBOL(cx88_reset);
  947. EXPORT_SYMBOL(cx88_shutdown);
  948. EXPORT_SYMBOL(cx88_risc_buffer);
  949. EXPORT_SYMBOL(cx88_risc_databuffer);
  950. EXPORT_SYMBOL(cx88_risc_stopper);
  951. EXPORT_SYMBOL(cx88_free_buffer);
  952. EXPORT_SYMBOL(cx88_sram_channels);
  953. EXPORT_SYMBOL(cx88_sram_channel_setup);
  954. EXPORT_SYMBOL(cx88_sram_channel_dump);
  955. EXPORT_SYMBOL(cx88_set_tvnorm);
  956. EXPORT_SYMBOL(cx88_set_scale);
  957. EXPORT_SYMBOL(cx88_vdev_init);
  958. EXPORT_SYMBOL(cx88_core_get);
  959. EXPORT_SYMBOL(cx88_core_put);
  960. EXPORT_SYMBOL(cx88_ir_start);
  961. EXPORT_SYMBOL(cx88_ir_stop);
  962. /*
  963. * Local variables:
  964. * c-basic-offset: 8
  965. * End:
  966. * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off
  967. */