saa7134-alsa.c 30 KB

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