saa7134-alsa.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286
  1. /*
  2. * SAA713x ALSA support for V4L
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, version 2
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. *
  17. */
  18. #include <linux/init.h>
  19. #include <linux/slab.h>
  20. #include <linux/time.h>
  21. #include <linux/wait.h>
  22. #include <linux/module.h>
  23. #include <sound/core.h>
  24. #include <sound/control.h>
  25. #include <sound/pcm.h>
  26. #include <sound/pcm_params.h>
  27. #include <sound/initval.h>
  28. #include <linux/interrupt.h>
  29. #include <linux/vmalloc.h>
  30. #include "saa7134.h"
  31. #include "saa7134-reg.h"
  32. static unsigned int debug;
  33. module_param(debug, int, 0644);
  34. MODULE_PARM_DESC(debug,"enable debug messages [alsa]");
  35. /*
  36. * Configuration macros
  37. */
  38. /* defaults */
  39. #define MIXER_ADDR_UNSELECTED -1
  40. #define MIXER_ADDR_TVTUNER 0
  41. #define MIXER_ADDR_LINE1 1
  42. #define MIXER_ADDR_LINE2 2
  43. #define MIXER_ADDR_LAST 2
  44. static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
  45. static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
  46. static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 1};
  47. module_param_array(index, int, NULL, 0444);
  48. module_param_array(enable, int, NULL, 0444);
  49. MODULE_PARM_DESC(index, "Index value for SAA7134 capture interface(s).");
  50. MODULE_PARM_DESC(enable, "Enable (or not) the SAA7134 capture interface(s).");
  51. #define dprintk(fmt, arg...) if (debug) \
  52. printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ##arg)
  53. /*
  54. * Main chip structure
  55. */
  56. typedef struct snd_card_saa7134 {
  57. struct snd_card *card;
  58. spinlock_t mixer_lock;
  59. int mixer_volume[MIXER_ADDR_LAST+1][2];
  60. int capture_source_addr;
  61. int capture_source[2];
  62. struct snd_kcontrol *capture_ctl[MIXER_ADDR_LAST+1];
  63. struct pci_dev *pci;
  64. struct saa7134_dev *dev;
  65. unsigned long iobase;
  66. s16 irq;
  67. u16 mute_was_on;
  68. spinlock_t lock;
  69. } snd_card_saa7134_t;
  70. /*
  71. * PCM structure
  72. */
  73. typedef struct snd_card_saa7134_pcm {
  74. struct saa7134_dev *dev;
  75. spinlock_t lock;
  76. struct snd_pcm_substream *substream;
  77. } snd_card_saa7134_pcm_t;
  78. static struct snd_card *snd_saa7134_cards[SNDRV_CARDS];
  79. /*
  80. * saa7134 DMA audio stop
  81. *
  82. * Called when the capture device is released or the buffer overflows
  83. *
  84. * - Copied verbatim from saa7134-oss's dsp_dma_stop.
  85. *
  86. */
  87. static void saa7134_dma_stop(struct saa7134_dev *dev)
  88. {
  89. dev->dmasound.dma_blk = -1;
  90. dev->dmasound.dma_running = 0;
  91. saa7134_set_dmabits(dev);
  92. }
  93. /*
  94. * saa7134 DMA audio start
  95. *
  96. * Called when preparing the capture device for use
  97. *
  98. * - Copied verbatim from saa7134-oss's dsp_dma_start.
  99. *
  100. */
  101. static void saa7134_dma_start(struct saa7134_dev *dev)
  102. {
  103. dev->dmasound.dma_blk = 0;
  104. dev->dmasound.dma_running = 1;
  105. saa7134_set_dmabits(dev);
  106. }
  107. /*
  108. * saa7134 audio DMA IRQ handler
  109. *
  110. * Called whenever we get an SAA7134_IRQ_REPORT_DONE_RA3 interrupt
  111. * Handles shifting between the 2 buffers, manages the read counters,
  112. * and notifies ALSA when periods elapse
  113. *
  114. * - Mostly copied from saa7134-oss's saa7134_irq_oss_done.
  115. *
  116. */
  117. static void saa7134_irq_alsa_done(struct saa7134_dev *dev,
  118. unsigned long status)
  119. {
  120. int next_blk, reg = 0;
  121. spin_lock(&dev->slock);
  122. if (UNSET == dev->dmasound.dma_blk) {
  123. dprintk("irq: recording stopped\n");
  124. goto done;
  125. }
  126. if (0 != (status & 0x0f000000))
  127. dprintk("irq: lost %ld\n", (status >> 24) & 0x0f);
  128. if (0 == (status & 0x10000000)) {
  129. /* odd */
  130. if (0 == (dev->dmasound.dma_blk & 0x01))
  131. reg = SAA7134_RS_BA1(6);
  132. } else {
  133. /* even */
  134. if (1 == (dev->dmasound.dma_blk & 0x01))
  135. reg = SAA7134_RS_BA2(6);
  136. }
  137. if (0 == reg) {
  138. dprintk("irq: field oops [%s]\n",
  139. (status & 0x10000000) ? "even" : "odd");
  140. goto done;
  141. }
  142. if (dev->dmasound.read_count >= dev->dmasound.blksize * (dev->dmasound.blocks-2)) {
  143. dprintk("irq: overrun [full=%d/%d] - Blocks in %d\n",dev->dmasound.read_count,
  144. dev->dmasound.bufsize, dev->dmasound.blocks);
  145. spin_unlock(&dev->slock);
  146. snd_pcm_stream_lock(dev->dmasound.substream);
  147. snd_pcm_stop(dev->dmasound.substream,SNDRV_PCM_STATE_XRUN);
  148. snd_pcm_stream_unlock(dev->dmasound.substream);
  149. return;
  150. }
  151. /* next block addr */
  152. next_blk = (dev->dmasound.dma_blk + 2) % dev->dmasound.blocks;
  153. saa_writel(reg,next_blk * dev->dmasound.blksize);
  154. if (debug > 2)
  155. dprintk("irq: ok, %s, next_blk=%d, addr=%x, blocks=%u, size=%u, read=%u\n",
  156. (status & 0x10000000) ? "even" : "odd ", next_blk,
  157. next_blk * dev->dmasound.blksize, dev->dmasound.blocks, dev->dmasound.blksize, dev->dmasound.read_count);
  158. /* update status & wake waiting readers */
  159. dev->dmasound.dma_blk = (dev->dmasound.dma_blk + 1) % dev->dmasound.blocks;
  160. dev->dmasound.read_count += dev->dmasound.blksize;
  161. dev->dmasound.recording_on = reg;
  162. if (dev->dmasound.read_count >= snd_pcm_lib_period_bytes(dev->dmasound.substream)) {
  163. spin_unlock(&dev->slock);
  164. snd_pcm_period_elapsed(dev->dmasound.substream);
  165. spin_lock(&dev->slock);
  166. }
  167. done:
  168. spin_unlock(&dev->slock);
  169. }
  170. /*
  171. * IRQ request handler
  172. *
  173. * Runs along with saa7134's IRQ handler, discards anything that isn't
  174. * DMA sound
  175. *
  176. */
  177. static irqreturn_t saa7134_alsa_irq(int irq, void *dev_id)
  178. {
  179. struct saa7134_dmasound *dmasound = dev_id;
  180. struct saa7134_dev *dev = dmasound->priv_data;
  181. unsigned long report, status;
  182. int loop, handled = 0;
  183. for (loop = 0; loop < 10; loop++) {
  184. report = saa_readl(SAA7134_IRQ_REPORT);
  185. status = saa_readl(SAA7134_IRQ_STATUS);
  186. if (report & SAA7134_IRQ_REPORT_DONE_RA3) {
  187. handled = 1;
  188. saa_writel(SAA7134_IRQ_REPORT,
  189. SAA7134_IRQ_REPORT_DONE_RA3);
  190. saa7134_irq_alsa_done(dev, status);
  191. } else {
  192. goto out;
  193. }
  194. }
  195. if (loop == 10) {
  196. dprintk("error! looping IRQ!");
  197. }
  198. out:
  199. return IRQ_RETVAL(handled);
  200. }
  201. /*
  202. * ALSA capture trigger
  203. *
  204. * - One of the ALSA capture callbacks.
  205. *
  206. * Called whenever a capture is started or stopped. Must be defined,
  207. * but there's nothing we want to do here
  208. *
  209. */
  210. static int snd_card_saa7134_capture_trigger(struct snd_pcm_substream * substream,
  211. int cmd)
  212. {
  213. struct snd_pcm_runtime *runtime = substream->runtime;
  214. snd_card_saa7134_pcm_t *pcm = runtime->private_data;
  215. struct saa7134_dev *dev=pcm->dev;
  216. int err = 0;
  217. spin_lock(&dev->slock);
  218. if (cmd == SNDRV_PCM_TRIGGER_START) {
  219. /* start dma */
  220. saa7134_dma_start(dev);
  221. } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
  222. /* stop dma */
  223. saa7134_dma_stop(dev);
  224. } else {
  225. err = -EINVAL;
  226. }
  227. spin_unlock(&dev->slock);
  228. return err;
  229. }
  230. static int saa7134_alsa_dma_init(struct saa7134_dev *dev, int nr_pages)
  231. {
  232. struct saa7134_dmasound *dma = &dev->dmasound;
  233. struct page *pg;
  234. int i;
  235. dma->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT);
  236. if (NULL == dma->vaddr) {
  237. dprintk("vmalloc_32(%d pages) failed\n", nr_pages);
  238. return -ENOMEM;
  239. }
  240. dprintk("vmalloc is at addr 0x%08lx, size=%d\n",
  241. (unsigned long)dma->vaddr,
  242. nr_pages << PAGE_SHIFT);
  243. memset(dma->vaddr, 0, nr_pages << PAGE_SHIFT);
  244. dma->nr_pages = nr_pages;
  245. dma->sglist = vzalloc(dma->nr_pages * sizeof(*dma->sglist));
  246. if (NULL == dma->sglist)
  247. goto vzalloc_err;
  248. sg_init_table(dma->sglist, dma->nr_pages);
  249. for (i = 0; i < dma->nr_pages; i++) {
  250. pg = vmalloc_to_page(dma->vaddr + i * PAGE_SIZE);
  251. if (NULL == pg)
  252. goto vmalloc_to_page_err;
  253. sg_set_page(&dma->sglist[i], pg, PAGE_SIZE, 0);
  254. }
  255. return 0;
  256. vmalloc_to_page_err:
  257. vfree(dma->sglist);
  258. dma->sglist = NULL;
  259. vzalloc_err:
  260. vfree(dma->vaddr);
  261. dma->vaddr = NULL;
  262. return -ENOMEM;
  263. }
  264. static int saa7134_alsa_dma_map(struct saa7134_dev *dev)
  265. {
  266. struct saa7134_dmasound *dma = &dev->dmasound;
  267. dma->sglen = dma_map_sg(&dev->pci->dev, dma->sglist,
  268. dma->nr_pages, PCI_DMA_FROMDEVICE);
  269. if (0 == dma->sglen) {
  270. pr_warn("%s: saa7134_alsa_map_sg failed\n", __func__);
  271. return -ENOMEM;
  272. }
  273. return 0;
  274. }
  275. static int saa7134_alsa_dma_unmap(struct saa7134_dev *dev)
  276. {
  277. struct saa7134_dmasound *dma = &dev->dmasound;
  278. if (!dma->sglen)
  279. return 0;
  280. dma_unmap_sg(&dev->pci->dev, dma->sglist, dma->sglen, PCI_DMA_FROMDEVICE);
  281. dma->sglen = 0;
  282. return 0;
  283. }
  284. static int saa7134_alsa_dma_free(struct saa7134_dmasound *dma)
  285. {
  286. vfree(dma->sglist);
  287. dma->sglist = NULL;
  288. vfree(dma->vaddr);
  289. dma->vaddr = NULL;
  290. return 0;
  291. }
  292. /*
  293. * DMA buffer initialization
  294. *
  295. * Uses V4L functions to initialize the DMA. Shouldn't be necessary in
  296. * ALSA, but I was unable to use ALSA's own DMA, and had to force the
  297. * usage of V4L's
  298. *
  299. * - Copied verbatim from saa7134-oss.
  300. *
  301. */
  302. static int dsp_buffer_init(struct saa7134_dev *dev)
  303. {
  304. int err;
  305. BUG_ON(!dev->dmasound.bufsize);
  306. err = saa7134_alsa_dma_init(dev,
  307. (dev->dmasound.bufsize + PAGE_SIZE) >> PAGE_SHIFT);
  308. if (0 != err)
  309. return err;
  310. return 0;
  311. }
  312. /*
  313. * DMA buffer release
  314. *
  315. * Called after closing the device, during snd_card_saa7134_capture_close
  316. *
  317. */
  318. static int dsp_buffer_free(struct saa7134_dev *dev)
  319. {
  320. BUG_ON(!dev->dmasound.blksize);
  321. saa7134_alsa_dma_free(&dev->dmasound);
  322. dev->dmasound.blocks = 0;
  323. dev->dmasound.blksize = 0;
  324. dev->dmasound.bufsize = 0;
  325. return 0;
  326. }
  327. /*
  328. * Setting the capture source and updating the ALSA controls
  329. */
  330. static int snd_saa7134_capsrc_set(struct snd_kcontrol *kcontrol,
  331. int left, int right, bool force_notify)
  332. {
  333. snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol);
  334. int change = 0, addr = kcontrol->private_value;
  335. int active, old_addr;
  336. u32 anabar, xbarin;
  337. int analog_io, rate;
  338. struct saa7134_dev *dev;
  339. dev = chip->dev;
  340. spin_lock_irq(&chip->mixer_lock);
  341. active = left != 0 || right != 0;
  342. old_addr = chip->capture_source_addr;
  343. /* The active capture source cannot be deactivated */
  344. if (active) {
  345. change = old_addr != addr ||
  346. chip->capture_source[0] != left ||
  347. chip->capture_source[1] != right;
  348. chip->capture_source[0] = left;
  349. chip->capture_source[1] = right;
  350. chip->capture_source_addr = addr;
  351. dev->dmasound.input = addr;
  352. }
  353. spin_unlock_irq(&chip->mixer_lock);
  354. if (change) {
  355. switch (dev->pci->device) {
  356. case PCI_DEVICE_ID_PHILIPS_SAA7134:
  357. switch (addr) {
  358. case MIXER_ADDR_TVTUNER:
  359. saa_andorb(SAA7134_AUDIO_FORMAT_CTRL,
  360. 0xc0, 0xc0);
  361. saa_andorb(SAA7134_SIF_SAMPLE_FREQ,
  362. 0x03, 0x00);
  363. break;
  364. case MIXER_ADDR_LINE1:
  365. case MIXER_ADDR_LINE2:
  366. analog_io = (MIXER_ADDR_LINE1 == addr) ?
  367. 0x00 : 0x08;
  368. rate = (32000 == dev->dmasound.rate) ?
  369. 0x01 : 0x03;
  370. saa_andorb(SAA7134_ANALOG_IO_SELECT,
  371. 0x08, analog_io);
  372. saa_andorb(SAA7134_AUDIO_FORMAT_CTRL,
  373. 0xc0, 0x80);
  374. saa_andorb(SAA7134_SIF_SAMPLE_FREQ,
  375. 0x03, rate);
  376. break;
  377. }
  378. break;
  379. case PCI_DEVICE_ID_PHILIPS_SAA7133:
  380. case PCI_DEVICE_ID_PHILIPS_SAA7135:
  381. xbarin = 0x03; /* adc */
  382. anabar = 0;
  383. switch (addr) {
  384. case MIXER_ADDR_TVTUNER:
  385. xbarin = 0; /* Demodulator */
  386. anabar = 2; /* DACs */
  387. break;
  388. case MIXER_ADDR_LINE1:
  389. anabar = 0; /* aux1, aux1 */
  390. break;
  391. case MIXER_ADDR_LINE2:
  392. anabar = 9; /* aux2, aux2 */
  393. break;
  394. }
  395. /* output xbar always main channel */
  396. saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL1,
  397. 0xbbbb10);
  398. if (left || right) {
  399. /* We've got data, turn the input on */
  400. saa_dsp_writel(dev, SAA7133_DIGITAL_INPUT_XBAR1,
  401. xbarin);
  402. saa_writel(SAA7133_ANALOG_IO_SELECT, anabar);
  403. } else {
  404. saa_dsp_writel(dev, SAA7133_DIGITAL_INPUT_XBAR1,
  405. 0);
  406. saa_writel(SAA7133_ANALOG_IO_SELECT, 0);
  407. }
  408. break;
  409. }
  410. }
  411. if (change) {
  412. if (force_notify)
  413. snd_ctl_notify(chip->card,
  414. SNDRV_CTL_EVENT_MASK_VALUE,
  415. &chip->capture_ctl[addr]->id);
  416. if (old_addr != MIXER_ADDR_UNSELECTED && old_addr != addr)
  417. snd_ctl_notify(chip->card,
  418. SNDRV_CTL_EVENT_MASK_VALUE,
  419. &chip->capture_ctl[old_addr]->id);
  420. }
  421. return change;
  422. }
  423. /*
  424. * ALSA PCM preparation
  425. *
  426. * - One of the ALSA capture callbacks.
  427. *
  428. * Called right after the capture device is opened, this function configures
  429. * the buffer using the previously defined functions, allocates the memory,
  430. * sets up the hardware registers, and then starts the DMA. When this function
  431. * returns, the audio should be flowing.
  432. *
  433. */
  434. static int snd_card_saa7134_capture_prepare(struct snd_pcm_substream * substream)
  435. {
  436. struct snd_pcm_runtime *runtime = substream->runtime;
  437. int bswap, sign;
  438. u32 fmt, control;
  439. snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);
  440. struct saa7134_dev *dev;
  441. snd_card_saa7134_pcm_t *pcm = runtime->private_data;
  442. pcm->dev->dmasound.substream = substream;
  443. dev = saa7134->dev;
  444. if (snd_pcm_format_width(runtime->format) == 8)
  445. fmt = 0x00;
  446. else
  447. fmt = 0x01;
  448. if (snd_pcm_format_signed(runtime->format))
  449. sign = 1;
  450. else
  451. sign = 0;
  452. if (snd_pcm_format_big_endian(runtime->format))
  453. bswap = 1;
  454. else
  455. bswap = 0;
  456. switch (dev->pci->device) {
  457. case PCI_DEVICE_ID_PHILIPS_SAA7134:
  458. if (1 == runtime->channels)
  459. fmt |= (1 << 3);
  460. if (2 == runtime->channels)
  461. fmt |= (3 << 3);
  462. if (sign)
  463. fmt |= 0x04;
  464. fmt |= (MIXER_ADDR_TVTUNER == dev->dmasound.input) ? 0xc0 : 0x80;
  465. saa_writeb(SAA7134_NUM_SAMPLES0, ((dev->dmasound.blksize - 1) & 0x0000ff));
  466. saa_writeb(SAA7134_NUM_SAMPLES1, ((dev->dmasound.blksize - 1) & 0x00ff00) >> 8);
  467. saa_writeb(SAA7134_NUM_SAMPLES2, ((dev->dmasound.blksize - 1) & 0xff0000) >> 16);
  468. saa_writeb(SAA7134_AUDIO_FORMAT_CTRL, fmt);
  469. break;
  470. case PCI_DEVICE_ID_PHILIPS_SAA7133:
  471. case PCI_DEVICE_ID_PHILIPS_SAA7135:
  472. if (1 == runtime->channels)
  473. fmt |= (1 << 4);
  474. if (2 == runtime->channels)
  475. fmt |= (2 << 4);
  476. if (!sign)
  477. fmt |= 0x04;
  478. saa_writel(SAA7133_NUM_SAMPLES, dev->dmasound.blksize -1);
  479. saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210 | (fmt << 24));
  480. break;
  481. }
  482. dprintk("rec_start: afmt=%d ch=%d => fmt=0x%x swap=%c\n",
  483. runtime->format, runtime->channels, fmt,
  484. bswap ? 'b' : '-');
  485. /* dma: setup channel 6 (= AUDIO) */
  486. control = SAA7134_RS_CONTROL_BURST_16 |
  487. SAA7134_RS_CONTROL_ME |
  488. (dev->dmasound.pt.dma >> 12);
  489. if (bswap)
  490. control |= SAA7134_RS_CONTROL_BSWAP;
  491. saa_writel(SAA7134_RS_BA1(6),0);
  492. saa_writel(SAA7134_RS_BA2(6),dev->dmasound.blksize);
  493. saa_writel(SAA7134_RS_PITCH(6),0);
  494. saa_writel(SAA7134_RS_CONTROL(6),control);
  495. dev->dmasound.rate = runtime->rate;
  496. /* Setup and update the card/ALSA controls */
  497. snd_saa7134_capsrc_set(saa7134->capture_ctl[dev->dmasound.input], 1, 1,
  498. true);
  499. return 0;
  500. }
  501. /*
  502. * ALSA pointer fetching
  503. *
  504. * - One of the ALSA capture callbacks.
  505. *
  506. * Called whenever a period elapses, it must return the current hardware
  507. * position of the buffer.
  508. * Also resets the read counter used to prevent overruns
  509. *
  510. */
  511. static snd_pcm_uframes_t
  512. snd_card_saa7134_capture_pointer(struct snd_pcm_substream * substream)
  513. {
  514. struct snd_pcm_runtime *runtime = substream->runtime;
  515. snd_card_saa7134_pcm_t *pcm = runtime->private_data;
  516. struct saa7134_dev *dev=pcm->dev;
  517. if (dev->dmasound.read_count) {
  518. dev->dmasound.read_count -= snd_pcm_lib_period_bytes(substream);
  519. dev->dmasound.read_offset += snd_pcm_lib_period_bytes(substream);
  520. if (dev->dmasound.read_offset == dev->dmasound.bufsize)
  521. dev->dmasound.read_offset = 0;
  522. }
  523. return bytes_to_frames(runtime, dev->dmasound.read_offset);
  524. }
  525. /*
  526. * ALSA hardware capabilities definition
  527. *
  528. * Report only 32kHz for ALSA:
  529. *
  530. * - SAA7133/35 uses DDEP (DemDec Easy Programming mode), which works in 32kHz
  531. * only
  532. * - SAA7134 for TV mode uses DemDec mode (32kHz)
  533. * - Radio works in 32kHz only
  534. * - When recording 48kHz from Line1/Line2, switching of capture source to TV
  535. * means
  536. * switching to 32kHz without any frequency translation
  537. */
  538. static struct snd_pcm_hardware snd_card_saa7134_capture =
  539. {
  540. .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
  541. SNDRV_PCM_INFO_BLOCK_TRANSFER |
  542. SNDRV_PCM_INFO_MMAP_VALID),
  543. .formats = SNDRV_PCM_FMTBIT_S16_LE | \
  544. SNDRV_PCM_FMTBIT_S16_BE | \
  545. SNDRV_PCM_FMTBIT_S8 | \
  546. SNDRV_PCM_FMTBIT_U8 | \
  547. SNDRV_PCM_FMTBIT_U16_LE | \
  548. SNDRV_PCM_FMTBIT_U16_BE,
  549. .rates = SNDRV_PCM_RATE_32000,
  550. .rate_min = 32000,
  551. .rate_max = 32000,
  552. .channels_min = 1,
  553. .channels_max = 2,
  554. .buffer_bytes_max = (256*1024),
  555. .period_bytes_min = 64,
  556. .period_bytes_max = (256*1024),
  557. .periods_min = 4,
  558. .periods_max = 1024,
  559. };
  560. static void snd_card_saa7134_runtime_free(struct snd_pcm_runtime *runtime)
  561. {
  562. snd_card_saa7134_pcm_t *pcm = runtime->private_data;
  563. kfree(pcm);
  564. }
  565. /*
  566. * ALSA hardware params
  567. *
  568. * - One of the ALSA capture callbacks.
  569. *
  570. * Called on initialization, right before the PCM preparation
  571. *
  572. */
  573. static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream,
  574. struct snd_pcm_hw_params * hw_params)
  575. {
  576. snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);
  577. struct saa7134_dev *dev;
  578. unsigned int period_size, periods;
  579. int err;
  580. period_size = params_period_bytes(hw_params);
  581. periods = params_periods(hw_params);
  582. if (period_size < 0x100 || period_size > 0x10000)
  583. return -EINVAL;
  584. if (periods < 4)
  585. return -EINVAL;
  586. if (period_size * periods > 1024 * 1024)
  587. return -EINVAL;
  588. dev = saa7134->dev;
  589. if (dev->dmasound.blocks == periods &&
  590. dev->dmasound.blksize == period_size)
  591. return 0;
  592. /* release the old buffer */
  593. if (substream->runtime->dma_area) {
  594. saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
  595. saa7134_alsa_dma_unmap(dev);
  596. dsp_buffer_free(dev);
  597. substream->runtime->dma_area = NULL;
  598. }
  599. dev->dmasound.blocks = periods;
  600. dev->dmasound.blksize = period_size;
  601. dev->dmasound.bufsize = period_size * periods;
  602. err = dsp_buffer_init(dev);
  603. if (0 != err) {
  604. dev->dmasound.blocks = 0;
  605. dev->dmasound.blksize = 0;
  606. dev->dmasound.bufsize = 0;
  607. return err;
  608. }
  609. err = saa7134_alsa_dma_map(dev);
  610. if (err) {
  611. dsp_buffer_free(dev);
  612. return err;
  613. }
  614. err = saa7134_pgtable_alloc(dev->pci, &dev->dmasound.pt);
  615. if (err) {
  616. saa7134_alsa_dma_unmap(dev);
  617. dsp_buffer_free(dev);
  618. return err;
  619. }
  620. err = saa7134_pgtable_build(dev->pci, &dev->dmasound.pt,
  621. dev->dmasound.sglist, dev->dmasound.sglen, 0);
  622. if (err) {
  623. saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
  624. saa7134_alsa_dma_unmap(dev);
  625. dsp_buffer_free(dev);
  626. return err;
  627. }
  628. /* I should be able to use runtime->dma_addr in the control
  629. byte, but it doesn't work. So I allocate the DMA using the
  630. V4L functions, and force ALSA to use that as the DMA area */
  631. substream->runtime->dma_area = dev->dmasound.vaddr;
  632. substream->runtime->dma_bytes = dev->dmasound.bufsize;
  633. substream->runtime->dma_addr = 0;
  634. return 0;
  635. }
  636. /*
  637. * ALSA hardware release
  638. *
  639. * - One of the ALSA capture callbacks.
  640. *
  641. * Called after closing the device, but before snd_card_saa7134_capture_close
  642. * It stops the DMA audio and releases the buffers.
  643. *
  644. */
  645. static int snd_card_saa7134_hw_free(struct snd_pcm_substream * substream)
  646. {
  647. snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);
  648. struct saa7134_dev *dev;
  649. dev = saa7134->dev;
  650. if (substream->runtime->dma_area) {
  651. saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
  652. saa7134_alsa_dma_unmap(dev);
  653. dsp_buffer_free(dev);
  654. substream->runtime->dma_area = NULL;
  655. }
  656. return 0;
  657. }
  658. /*
  659. * ALSA capture finish
  660. *
  661. * - One of the ALSA capture callbacks.
  662. *
  663. * Called after closing the device.
  664. *
  665. */
  666. static int snd_card_saa7134_capture_close(struct snd_pcm_substream * substream)
  667. {
  668. snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);
  669. struct saa7134_dev *dev = saa7134->dev;
  670. if (saa7134->mute_was_on) {
  671. dev->ctl_mute = 1;
  672. saa7134_tvaudio_setmute(dev);
  673. }
  674. return 0;
  675. }
  676. /*
  677. * ALSA capture start
  678. *
  679. * - One of the ALSA capture callbacks.
  680. *
  681. * Called when opening the device. It creates and populates the PCM
  682. * structure
  683. *
  684. */
  685. static int snd_card_saa7134_capture_open(struct snd_pcm_substream * substream)
  686. {
  687. struct snd_pcm_runtime *runtime = substream->runtime;
  688. snd_card_saa7134_pcm_t *pcm;
  689. snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);
  690. struct saa7134_dev *dev;
  691. int amux, err;
  692. if (!saa7134) {
  693. printk(KERN_ERR "BUG: saa7134 can't find device struct."
  694. " Can't proceed with open\n");
  695. return -ENODEV;
  696. }
  697. dev = saa7134->dev;
  698. mutex_lock(&dev->dmasound.lock);
  699. dev->dmasound.read_count = 0;
  700. dev->dmasound.read_offset = 0;
  701. amux = dev->input->amux;
  702. if ((amux < 1) || (amux > 3))
  703. amux = 1;
  704. dev->dmasound.input = amux - 1;
  705. mutex_unlock(&dev->dmasound.lock);
  706. pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
  707. if (pcm == NULL)
  708. return -ENOMEM;
  709. pcm->dev=saa7134->dev;
  710. spin_lock_init(&pcm->lock);
  711. pcm->substream = substream;
  712. runtime->private_data = pcm;
  713. runtime->private_free = snd_card_saa7134_runtime_free;
  714. runtime->hw = snd_card_saa7134_capture;
  715. if (dev->ctl_mute != 0) {
  716. saa7134->mute_was_on = 1;
  717. dev->ctl_mute = 0;
  718. saa7134_tvaudio_setmute(dev);
  719. }
  720. err = snd_pcm_hw_constraint_integer(runtime,
  721. SNDRV_PCM_HW_PARAM_PERIODS);
  722. if (err < 0)
  723. return err;
  724. err = snd_pcm_hw_constraint_step(runtime, 0,
  725. SNDRV_PCM_HW_PARAM_PERIODS, 2);
  726. if (err < 0)
  727. return err;
  728. return 0;
  729. }
  730. /*
  731. * page callback (needed for mmap)
  732. */
  733. static struct page *snd_card_saa7134_page(struct snd_pcm_substream *substream,
  734. unsigned long offset)
  735. {
  736. void *pageptr = substream->runtime->dma_area + offset;
  737. return vmalloc_to_page(pageptr);
  738. }
  739. /*
  740. * ALSA capture callbacks definition
  741. */
  742. static struct snd_pcm_ops snd_card_saa7134_capture_ops = {
  743. .open = snd_card_saa7134_capture_open,
  744. .close = snd_card_saa7134_capture_close,
  745. .ioctl = snd_pcm_lib_ioctl,
  746. .hw_params = snd_card_saa7134_hw_params,
  747. .hw_free = snd_card_saa7134_hw_free,
  748. .prepare = snd_card_saa7134_capture_prepare,
  749. .trigger = snd_card_saa7134_capture_trigger,
  750. .pointer = snd_card_saa7134_capture_pointer,
  751. .page = snd_card_saa7134_page,
  752. };
  753. /*
  754. * ALSA PCM setup
  755. *
  756. * Called when initializing the board. Sets up the name and hooks up
  757. * the callbacks
  758. *
  759. */
  760. static int snd_card_saa7134_pcm(snd_card_saa7134_t *saa7134, int device)
  761. {
  762. struct snd_pcm *pcm;
  763. int err;
  764. if ((err = snd_pcm_new(saa7134->card, "SAA7134 PCM", device, 0, 1, &pcm)) < 0)
  765. return err;
  766. snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_card_saa7134_capture_ops);
  767. pcm->private_data = saa7134;
  768. pcm->info_flags = 0;
  769. strcpy(pcm->name, "SAA7134 PCM");
  770. return 0;
  771. }
  772. #define SAA713x_VOLUME(xname, xindex, addr) \
  773. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
  774. .info = snd_saa7134_volume_info, \
  775. .get = snd_saa7134_volume_get, .put = snd_saa7134_volume_put, \
  776. .private_value = addr }
  777. static int snd_saa7134_volume_info(struct snd_kcontrol * kcontrol,
  778. struct snd_ctl_elem_info * uinfo)
  779. {
  780. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  781. uinfo->count = 2;
  782. uinfo->value.integer.min = 0;
  783. uinfo->value.integer.max = 20;
  784. return 0;
  785. }
  786. static int snd_saa7134_volume_get(struct snd_kcontrol * kcontrol,
  787. struct snd_ctl_elem_value * ucontrol)
  788. {
  789. snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol);
  790. int addr = kcontrol->private_value;
  791. ucontrol->value.integer.value[0] = chip->mixer_volume[addr][0];
  792. ucontrol->value.integer.value[1] = chip->mixer_volume[addr][1];
  793. return 0;
  794. }
  795. static int snd_saa7134_volume_put(struct snd_kcontrol * kcontrol,
  796. struct snd_ctl_elem_value * ucontrol)
  797. {
  798. snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol);
  799. struct saa7134_dev *dev = chip->dev;
  800. int change, addr = kcontrol->private_value;
  801. int left, right;
  802. left = ucontrol->value.integer.value[0];
  803. if (left < 0)
  804. left = 0;
  805. if (left > 20)
  806. left = 20;
  807. right = ucontrol->value.integer.value[1];
  808. if (right < 0)
  809. right = 0;
  810. if (right > 20)
  811. right = 20;
  812. spin_lock_irq(&chip->mixer_lock);
  813. change = 0;
  814. if (chip->mixer_volume[addr][0] != left) {
  815. change = 1;
  816. right = left;
  817. }
  818. if (chip->mixer_volume[addr][1] != right) {
  819. change = 1;
  820. left = right;
  821. }
  822. if (change) {
  823. switch (dev->pci->device) {
  824. case PCI_DEVICE_ID_PHILIPS_SAA7134:
  825. switch (addr) {
  826. case MIXER_ADDR_TVTUNER:
  827. left = 20;
  828. break;
  829. case MIXER_ADDR_LINE1:
  830. saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x10,
  831. (left > 10) ? 0x00 : 0x10);
  832. break;
  833. case MIXER_ADDR_LINE2:
  834. saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x20,
  835. (left > 10) ? 0x00 : 0x20);
  836. break;
  837. }
  838. break;
  839. case PCI_DEVICE_ID_PHILIPS_SAA7133:
  840. case PCI_DEVICE_ID_PHILIPS_SAA7135:
  841. switch (addr) {
  842. case MIXER_ADDR_TVTUNER:
  843. left = 20;
  844. break;
  845. case MIXER_ADDR_LINE1:
  846. saa_andorb(0x0594, 0x10,
  847. (left > 10) ? 0x00 : 0x10);
  848. break;
  849. case MIXER_ADDR_LINE2:
  850. saa_andorb(0x0594, 0x20,
  851. (left > 10) ? 0x00 : 0x20);
  852. break;
  853. }
  854. break;
  855. }
  856. chip->mixer_volume[addr][0] = left;
  857. chip->mixer_volume[addr][1] = right;
  858. }
  859. spin_unlock_irq(&chip->mixer_lock);
  860. return change;
  861. }
  862. #define SAA713x_CAPSRC(xname, xindex, addr) \
  863. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
  864. .info = snd_saa7134_capsrc_info, \
  865. .get = snd_saa7134_capsrc_get, .put = snd_saa7134_capsrc_put, \
  866. .private_value = addr }
  867. static int snd_saa7134_capsrc_info(struct snd_kcontrol * kcontrol,
  868. struct snd_ctl_elem_info * uinfo)
  869. {
  870. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  871. uinfo->count = 2;
  872. uinfo->value.integer.min = 0;
  873. uinfo->value.integer.max = 1;
  874. return 0;
  875. }
  876. static int snd_saa7134_capsrc_get(struct snd_kcontrol * kcontrol,
  877. struct snd_ctl_elem_value * ucontrol)
  878. {
  879. snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol);
  880. int addr = kcontrol->private_value;
  881. spin_lock_irq(&chip->mixer_lock);
  882. if (chip->capture_source_addr == addr) {
  883. ucontrol->value.integer.value[0] = chip->capture_source[0];
  884. ucontrol->value.integer.value[1] = chip->capture_source[1];
  885. } else {
  886. ucontrol->value.integer.value[0] = 0;
  887. ucontrol->value.integer.value[1] = 0;
  888. }
  889. spin_unlock_irq(&chip->mixer_lock);
  890. return 0;
  891. }
  892. static int snd_saa7134_capsrc_put(struct snd_kcontrol * kcontrol,
  893. struct snd_ctl_elem_value * ucontrol)
  894. {
  895. int left, right;
  896. left = ucontrol->value.integer.value[0] & 1;
  897. right = ucontrol->value.integer.value[1] & 1;
  898. return snd_saa7134_capsrc_set(kcontrol, left, right, false);
  899. }
  900. static struct snd_kcontrol_new snd_saa7134_volume_controls[] = {
  901. SAA713x_VOLUME("Video Volume", 0, MIXER_ADDR_TVTUNER),
  902. SAA713x_VOLUME("Line Volume", 1, MIXER_ADDR_LINE1),
  903. SAA713x_VOLUME("Line Volume", 2, MIXER_ADDR_LINE2),
  904. };
  905. static struct snd_kcontrol_new snd_saa7134_capture_controls[] = {
  906. SAA713x_CAPSRC("Video Capture Switch", 0, MIXER_ADDR_TVTUNER),
  907. SAA713x_CAPSRC("Line Capture Switch", 1, MIXER_ADDR_LINE1),
  908. SAA713x_CAPSRC("Line Capture Switch", 2, MIXER_ADDR_LINE2),
  909. };
  910. /*
  911. * ALSA mixer setup
  912. *
  913. * Called when initializing the board. Sets up the name and hooks up
  914. * the callbacks
  915. *
  916. */
  917. static int snd_card_saa7134_new_mixer(snd_card_saa7134_t * chip)
  918. {
  919. struct snd_card *card = chip->card;
  920. struct snd_kcontrol *kcontrol;
  921. unsigned int idx;
  922. int err, addr;
  923. strcpy(card->mixername, "SAA7134 Mixer");
  924. for (idx = 0; idx < ARRAY_SIZE(snd_saa7134_volume_controls); idx++) {
  925. kcontrol = snd_ctl_new1(&snd_saa7134_volume_controls[idx],
  926. chip);
  927. err = snd_ctl_add(card, kcontrol);
  928. if (err < 0)
  929. return err;
  930. }
  931. for (idx = 0; idx < ARRAY_SIZE(snd_saa7134_capture_controls); idx++) {
  932. kcontrol = snd_ctl_new1(&snd_saa7134_capture_controls[idx],
  933. chip);
  934. addr = snd_saa7134_capture_controls[idx].private_value;
  935. chip->capture_ctl[addr] = kcontrol;
  936. err = snd_ctl_add(card, kcontrol);
  937. if (err < 0)
  938. return err;
  939. }
  940. chip->capture_source_addr = MIXER_ADDR_UNSELECTED;
  941. return 0;
  942. }
  943. static void snd_saa7134_free(struct snd_card * card)
  944. {
  945. snd_card_saa7134_t *chip = card->private_data;
  946. if (chip->dev->dmasound.priv_data == NULL)
  947. return;
  948. if (chip->irq >= 0)
  949. free_irq(chip->irq, &chip->dev->dmasound);
  950. chip->dev->dmasound.priv_data = NULL;
  951. }
  952. /*
  953. * ALSA initialization
  954. *
  955. * Called by the init routine, once for each saa7134 device present,
  956. * it creates the basic structures and registers the ALSA devices
  957. *
  958. */
  959. static int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum)
  960. {
  961. struct snd_card *card;
  962. snd_card_saa7134_t *chip;
  963. int err;
  964. if (devnum >= SNDRV_CARDS)
  965. return -ENODEV;
  966. if (!enable[devnum])
  967. return -ENODEV;
  968. err = snd_card_new(&dev->pci->dev, index[devnum], id[devnum],
  969. THIS_MODULE, sizeof(snd_card_saa7134_t), &card);
  970. if (err < 0)
  971. return err;
  972. strcpy(card->driver, "SAA7134");
  973. /* Card "creation" */
  974. card->private_free = snd_saa7134_free;
  975. chip = card->private_data;
  976. spin_lock_init(&chip->lock);
  977. spin_lock_init(&chip->mixer_lock);
  978. chip->dev = dev;
  979. chip->card = card;
  980. chip->pci = dev->pci;
  981. chip->iobase = pci_resource_start(dev->pci, 0);
  982. err = request_irq(dev->pci->irq, saa7134_alsa_irq,
  983. IRQF_SHARED, dev->name,
  984. (void*) &dev->dmasound);
  985. if (err < 0) {
  986. printk(KERN_ERR "%s: can't get IRQ %d for ALSA\n",
  987. dev->name, dev->pci->irq);
  988. goto __nodev;
  989. }
  990. chip->irq = dev->pci->irq;
  991. mutex_init(&dev->dmasound.lock);
  992. if ((err = snd_card_saa7134_new_mixer(chip)) < 0)
  993. goto __nodev;
  994. if ((err = snd_card_saa7134_pcm(chip, 0)) < 0)
  995. goto __nodev;
  996. /* End of "creation" */
  997. strcpy(card->shortname, "SAA7134");
  998. sprintf(card->longname, "%s at 0x%lx irq %d",
  999. chip->dev->name, chip->iobase, chip->irq);
  1000. printk(KERN_INFO "%s/alsa: %s registered as card %d\n",dev->name,card->longname,index[devnum]);
  1001. if ((err = snd_card_register(card)) == 0) {
  1002. snd_saa7134_cards[devnum] = card;
  1003. return 0;
  1004. }
  1005. __nodev:
  1006. snd_card_free(card);
  1007. return err;
  1008. }
  1009. static int alsa_device_init(struct saa7134_dev *dev)
  1010. {
  1011. dev->dmasound.priv_data = dev;
  1012. alsa_card_saa7134_create(dev,dev->nr);
  1013. return 1;
  1014. }
  1015. static int alsa_device_exit(struct saa7134_dev *dev)
  1016. {
  1017. snd_card_free(snd_saa7134_cards[dev->nr]);
  1018. snd_saa7134_cards[dev->nr] = NULL;
  1019. return 1;
  1020. }
  1021. /*
  1022. * Module initializer
  1023. *
  1024. * Loops through present saa7134 cards, and assigns an ALSA device
  1025. * to each one
  1026. *
  1027. */
  1028. static int saa7134_alsa_init(void)
  1029. {
  1030. struct saa7134_dev *dev = NULL;
  1031. struct list_head *list;
  1032. saa7134_dmasound_init = alsa_device_init;
  1033. saa7134_dmasound_exit = alsa_device_exit;
  1034. printk(KERN_INFO "saa7134 ALSA driver for DMA sound loaded\n");
  1035. list_for_each(list,&saa7134_devlist) {
  1036. dev = list_entry(list, struct saa7134_dev, devlist);
  1037. if (dev->pci->device == PCI_DEVICE_ID_PHILIPS_SAA7130)
  1038. printk(KERN_INFO "%s/alsa: %s doesn't support digital audio\n",
  1039. dev->name, saa7134_boards[dev->board].name);
  1040. else
  1041. alsa_device_init(dev);
  1042. }
  1043. if (dev == NULL)
  1044. printk(KERN_INFO "saa7134 ALSA: no saa7134 cards found\n");
  1045. return 0;
  1046. }
  1047. /*
  1048. * Module destructor
  1049. */
  1050. static void saa7134_alsa_exit(void)
  1051. {
  1052. int idx;
  1053. for (idx = 0; idx < SNDRV_CARDS; idx++) {
  1054. snd_card_free(snd_saa7134_cards[idx]);
  1055. }
  1056. saa7134_dmasound_init = NULL;
  1057. saa7134_dmasound_exit = NULL;
  1058. printk(KERN_INFO "saa7134 ALSA driver for DMA sound unloaded\n");
  1059. return;
  1060. }
  1061. /* We initialize this late, to make sure the sound system is up and running */
  1062. late_initcall(saa7134_alsa_init);
  1063. module_exit(saa7134_alsa_exit);
  1064. MODULE_LICENSE("GPL");
  1065. MODULE_AUTHOR("Ricardo Cerqueira");