pcm.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127
  1. /*
  2. * Digital Audio (PCM) abstract layer
  3. * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
  4. *
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. */
  21. #include <sound/driver.h>
  22. #include <linux/init.h>
  23. #include <linux/slab.h>
  24. #include <linux/time.h>
  25. #include <linux/mutex.h>
  26. #include <sound/core.h>
  27. #include <sound/minors.h>
  28. #include <sound/pcm.h>
  29. #include <sound/control.h>
  30. #include <sound/info.h>
  31. MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, Abramo Bagnara <abramo@alsa-project.org>");
  32. MODULE_DESCRIPTION("Midlevel PCM code for ALSA.");
  33. MODULE_LICENSE("GPL");
  34. static LIST_HEAD(snd_pcm_devices);
  35. static LIST_HEAD(snd_pcm_notify_list);
  36. static DEFINE_MUTEX(register_mutex);
  37. static int snd_pcm_free(struct snd_pcm *pcm);
  38. static int snd_pcm_dev_free(struct snd_device *device);
  39. static int snd_pcm_dev_register(struct snd_device *device);
  40. static int snd_pcm_dev_disconnect(struct snd_device *device);
  41. static struct snd_pcm *snd_pcm_search(struct snd_card *card, int device)
  42. {
  43. struct snd_pcm *pcm;
  44. list_for_each_entry(pcm, &snd_pcm_devices, list) {
  45. if (pcm->card == card && pcm->device == device)
  46. return pcm;
  47. }
  48. return NULL;
  49. }
  50. static int snd_pcm_control_ioctl(struct snd_card *card,
  51. struct snd_ctl_file *control,
  52. unsigned int cmd, unsigned long arg)
  53. {
  54. switch (cmd) {
  55. case SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE:
  56. {
  57. int device;
  58. if (get_user(device, (int __user *)arg))
  59. return -EFAULT;
  60. mutex_lock(&register_mutex);
  61. device = device < 0 ? 0 : device + 1;
  62. while (device < SNDRV_PCM_DEVICES) {
  63. if (snd_pcm_search(card, device))
  64. break;
  65. device++;
  66. }
  67. if (device == SNDRV_PCM_DEVICES)
  68. device = -1;
  69. mutex_unlock(&register_mutex);
  70. if (put_user(device, (int __user *)arg))
  71. return -EFAULT;
  72. return 0;
  73. }
  74. case SNDRV_CTL_IOCTL_PCM_INFO:
  75. {
  76. struct snd_pcm_info __user *info;
  77. unsigned int device, subdevice;
  78. int stream;
  79. struct snd_pcm *pcm;
  80. struct snd_pcm_str *pstr;
  81. struct snd_pcm_substream *substream;
  82. int err;
  83. info = (struct snd_pcm_info __user *)arg;
  84. if (get_user(device, &info->device))
  85. return -EFAULT;
  86. if (get_user(stream, &info->stream))
  87. return -EFAULT;
  88. if (stream < 0 || stream > 1)
  89. return -EINVAL;
  90. if (get_user(subdevice, &info->subdevice))
  91. return -EFAULT;
  92. mutex_lock(&register_mutex);
  93. pcm = snd_pcm_search(card, device);
  94. if (pcm == NULL) {
  95. err = -ENXIO;
  96. goto _error;
  97. }
  98. pstr = &pcm->streams[stream];
  99. if (pstr->substream_count == 0) {
  100. err = -ENOENT;
  101. goto _error;
  102. }
  103. if (subdevice >= pstr->substream_count) {
  104. err = -ENXIO;
  105. goto _error;
  106. }
  107. for (substream = pstr->substream; substream;
  108. substream = substream->next)
  109. if (substream->number == (int)subdevice)
  110. break;
  111. if (substream == NULL) {
  112. err = -ENXIO;
  113. goto _error;
  114. }
  115. err = snd_pcm_info_user(substream, info);
  116. _error:
  117. mutex_unlock(&register_mutex);
  118. return err;
  119. }
  120. case SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE:
  121. {
  122. int val;
  123. if (get_user(val, (int __user *)arg))
  124. return -EFAULT;
  125. control->prefer_pcm_subdevice = val;
  126. return 0;
  127. }
  128. }
  129. return -ENOIOCTLCMD;
  130. }
  131. #ifdef CONFIG_SND_VERBOSE_PROCFS
  132. #define STATE(v) [SNDRV_PCM_STATE_##v] = #v
  133. #define STREAM(v) [SNDRV_PCM_STREAM_##v] = #v
  134. #define READY(v) [SNDRV_PCM_READY_##v] = #v
  135. #define XRUN(v) [SNDRV_PCM_XRUN_##v] = #v
  136. #define SILENCE(v) [SNDRV_PCM_SILENCE_##v] = #v
  137. #define TSTAMP(v) [SNDRV_PCM_TSTAMP_##v] = #v
  138. #define ACCESS(v) [SNDRV_PCM_ACCESS_##v] = #v
  139. #define START(v) [SNDRV_PCM_START_##v] = #v
  140. #define FORMAT(v) [SNDRV_PCM_FORMAT_##v] = #v
  141. #define SUBFORMAT(v) [SNDRV_PCM_SUBFORMAT_##v] = #v
  142. static char *snd_pcm_format_names[] = {
  143. FORMAT(S8),
  144. FORMAT(U8),
  145. FORMAT(S16_LE),
  146. FORMAT(S16_BE),
  147. FORMAT(U16_LE),
  148. FORMAT(U16_BE),
  149. FORMAT(S24_LE),
  150. FORMAT(S24_BE),
  151. FORMAT(U24_LE),
  152. FORMAT(U24_BE),
  153. FORMAT(S32_LE),
  154. FORMAT(S32_BE),
  155. FORMAT(U32_LE),
  156. FORMAT(U32_BE),
  157. FORMAT(FLOAT_LE),
  158. FORMAT(FLOAT_BE),
  159. FORMAT(FLOAT64_LE),
  160. FORMAT(FLOAT64_BE),
  161. FORMAT(IEC958_SUBFRAME_LE),
  162. FORMAT(IEC958_SUBFRAME_BE),
  163. FORMAT(MU_LAW),
  164. FORMAT(A_LAW),
  165. FORMAT(IMA_ADPCM),
  166. FORMAT(MPEG),
  167. FORMAT(GSM),
  168. FORMAT(SPECIAL),
  169. FORMAT(S24_3LE),
  170. FORMAT(S24_3BE),
  171. FORMAT(U24_3LE),
  172. FORMAT(U24_3BE),
  173. FORMAT(S20_3LE),
  174. FORMAT(S20_3BE),
  175. FORMAT(U20_3LE),
  176. FORMAT(U20_3BE),
  177. FORMAT(S18_3LE),
  178. FORMAT(S18_3BE),
  179. FORMAT(U18_3LE),
  180. FORMAT(U18_3BE),
  181. };
  182. static const char *snd_pcm_format_name(snd_pcm_format_t format)
  183. {
  184. return snd_pcm_format_names[format];
  185. }
  186. static char *snd_pcm_stream_names[] = {
  187. STREAM(PLAYBACK),
  188. STREAM(CAPTURE),
  189. };
  190. static char *snd_pcm_state_names[] = {
  191. STATE(OPEN),
  192. STATE(SETUP),
  193. STATE(PREPARED),
  194. STATE(RUNNING),
  195. STATE(XRUN),
  196. STATE(DRAINING),
  197. STATE(PAUSED),
  198. STATE(SUSPENDED),
  199. };
  200. static char *snd_pcm_access_names[] = {
  201. ACCESS(MMAP_INTERLEAVED),
  202. ACCESS(MMAP_NONINTERLEAVED),
  203. ACCESS(MMAP_COMPLEX),
  204. ACCESS(RW_INTERLEAVED),
  205. ACCESS(RW_NONINTERLEAVED),
  206. };
  207. static char *snd_pcm_subformat_names[] = {
  208. SUBFORMAT(STD),
  209. };
  210. static char *snd_pcm_tstamp_mode_names[] = {
  211. TSTAMP(NONE),
  212. TSTAMP(MMAP),
  213. };
  214. static const char *snd_pcm_stream_name(int stream)
  215. {
  216. snd_assert(stream <= SNDRV_PCM_STREAM_LAST, return NULL);
  217. return snd_pcm_stream_names[stream];
  218. }
  219. static const char *snd_pcm_access_name(snd_pcm_access_t access)
  220. {
  221. return snd_pcm_access_names[access];
  222. }
  223. static const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat)
  224. {
  225. return snd_pcm_subformat_names[subformat];
  226. }
  227. static const char *snd_pcm_tstamp_mode_name(int mode)
  228. {
  229. snd_assert(mode <= SNDRV_PCM_TSTAMP_LAST, return NULL);
  230. return snd_pcm_tstamp_mode_names[mode];
  231. }
  232. static const char *snd_pcm_state_name(snd_pcm_state_t state)
  233. {
  234. return snd_pcm_state_names[state];
  235. }
  236. #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
  237. #include <linux/soundcard.h>
  238. static const char *snd_pcm_oss_format_name(int format)
  239. {
  240. switch (format) {
  241. case AFMT_MU_LAW:
  242. return "MU_LAW";
  243. case AFMT_A_LAW:
  244. return "A_LAW";
  245. case AFMT_IMA_ADPCM:
  246. return "IMA_ADPCM";
  247. case AFMT_U8:
  248. return "U8";
  249. case AFMT_S16_LE:
  250. return "S16_LE";
  251. case AFMT_S16_BE:
  252. return "S16_BE";
  253. case AFMT_S8:
  254. return "S8";
  255. case AFMT_U16_LE:
  256. return "U16_LE";
  257. case AFMT_U16_BE:
  258. return "U16_BE";
  259. case AFMT_MPEG:
  260. return "MPEG";
  261. default:
  262. return "unknown";
  263. }
  264. }
  265. #endif
  266. static void snd_pcm_proc_info_read(struct snd_pcm_substream *substream,
  267. struct snd_info_buffer *buffer)
  268. {
  269. struct snd_pcm_info *info;
  270. int err;
  271. if (! substream)
  272. return;
  273. info = kmalloc(sizeof(*info), GFP_KERNEL);
  274. if (! info) {
  275. printk(KERN_DEBUG "snd_pcm_proc_info_read: cannot malloc\n");
  276. return;
  277. }
  278. err = snd_pcm_info(substream, info);
  279. if (err < 0) {
  280. snd_iprintf(buffer, "error %d\n", err);
  281. kfree(info);
  282. return;
  283. }
  284. snd_iprintf(buffer, "card: %d\n", info->card);
  285. snd_iprintf(buffer, "device: %d\n", info->device);
  286. snd_iprintf(buffer, "subdevice: %d\n", info->subdevice);
  287. snd_iprintf(buffer, "stream: %s\n", snd_pcm_stream_name(info->stream));
  288. snd_iprintf(buffer, "id: %s\n", info->id);
  289. snd_iprintf(buffer, "name: %s\n", info->name);
  290. snd_iprintf(buffer, "subname: %s\n", info->subname);
  291. snd_iprintf(buffer, "class: %d\n", info->dev_class);
  292. snd_iprintf(buffer, "subclass: %d\n", info->dev_subclass);
  293. snd_iprintf(buffer, "subdevices_count: %d\n", info->subdevices_count);
  294. snd_iprintf(buffer, "subdevices_avail: %d\n", info->subdevices_avail);
  295. kfree(info);
  296. }
  297. static void snd_pcm_stream_proc_info_read(struct snd_info_entry *entry,
  298. struct snd_info_buffer *buffer)
  299. {
  300. snd_pcm_proc_info_read(((struct snd_pcm_str *)entry->private_data)->substream,
  301. buffer);
  302. }
  303. static void snd_pcm_substream_proc_info_read(struct snd_info_entry *entry,
  304. struct snd_info_buffer *buffer)
  305. {
  306. snd_pcm_proc_info_read((struct snd_pcm_substream *)entry->private_data,
  307. buffer);
  308. }
  309. static void snd_pcm_substream_proc_hw_params_read(struct snd_info_entry *entry,
  310. struct snd_info_buffer *buffer)
  311. {
  312. struct snd_pcm_substream *substream = entry->private_data;
  313. struct snd_pcm_runtime *runtime = substream->runtime;
  314. if (!runtime) {
  315. snd_iprintf(buffer, "closed\n");
  316. return;
  317. }
  318. if (runtime->status->state == SNDRV_PCM_STATE_OPEN) {
  319. snd_iprintf(buffer, "no setup\n");
  320. return;
  321. }
  322. snd_iprintf(buffer, "access: %s\n", snd_pcm_access_name(runtime->access));
  323. snd_iprintf(buffer, "format: %s\n", snd_pcm_format_name(runtime->format));
  324. snd_iprintf(buffer, "subformat: %s\n", snd_pcm_subformat_name(runtime->subformat));
  325. snd_iprintf(buffer, "channels: %u\n", runtime->channels);
  326. snd_iprintf(buffer, "rate: %u (%u/%u)\n", runtime->rate, runtime->rate_num, runtime->rate_den);
  327. snd_iprintf(buffer, "period_size: %lu\n", runtime->period_size);
  328. snd_iprintf(buffer, "buffer_size: %lu\n", runtime->buffer_size);
  329. snd_iprintf(buffer, "tick_time: %u\n", runtime->tick_time);
  330. #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
  331. if (substream->oss.oss) {
  332. snd_iprintf(buffer, "OSS format: %s\n", snd_pcm_oss_format_name(runtime->oss.format));
  333. snd_iprintf(buffer, "OSS channels: %u\n", runtime->oss.channels);
  334. snd_iprintf(buffer, "OSS rate: %u\n", runtime->oss.rate);
  335. snd_iprintf(buffer, "OSS period bytes: %lu\n", (unsigned long)runtime->oss.period_bytes);
  336. snd_iprintf(buffer, "OSS periods: %u\n", runtime->oss.periods);
  337. snd_iprintf(buffer, "OSS period frames: %lu\n", (unsigned long)runtime->oss.period_frames);
  338. }
  339. #endif
  340. }
  341. static void snd_pcm_substream_proc_sw_params_read(struct snd_info_entry *entry,
  342. struct snd_info_buffer *buffer)
  343. {
  344. struct snd_pcm_substream *substream = entry->private_data;
  345. struct snd_pcm_runtime *runtime = substream->runtime;
  346. if (!runtime) {
  347. snd_iprintf(buffer, "closed\n");
  348. return;
  349. }
  350. if (runtime->status->state == SNDRV_PCM_STATE_OPEN) {
  351. snd_iprintf(buffer, "no setup\n");
  352. return;
  353. }
  354. snd_iprintf(buffer, "tstamp_mode: %s\n", snd_pcm_tstamp_mode_name(runtime->tstamp_mode));
  355. snd_iprintf(buffer, "period_step: %u\n", runtime->period_step);
  356. snd_iprintf(buffer, "sleep_min: %u\n", runtime->sleep_min);
  357. snd_iprintf(buffer, "avail_min: %lu\n", runtime->control->avail_min);
  358. snd_iprintf(buffer, "xfer_align: %lu\n", runtime->xfer_align);
  359. snd_iprintf(buffer, "start_threshold: %lu\n", runtime->start_threshold);
  360. snd_iprintf(buffer, "stop_threshold: %lu\n", runtime->stop_threshold);
  361. snd_iprintf(buffer, "silence_threshold: %lu\n", runtime->silence_threshold);
  362. snd_iprintf(buffer, "silence_size: %lu\n", runtime->silence_size);
  363. snd_iprintf(buffer, "boundary: %lu\n", runtime->boundary);
  364. }
  365. static void snd_pcm_substream_proc_status_read(struct snd_info_entry *entry,
  366. struct snd_info_buffer *buffer)
  367. {
  368. struct snd_pcm_substream *substream = entry->private_data;
  369. struct snd_pcm_runtime *runtime = substream->runtime;
  370. struct snd_pcm_status status;
  371. int err;
  372. if (!runtime) {
  373. snd_iprintf(buffer, "closed\n");
  374. return;
  375. }
  376. memset(&status, 0, sizeof(status));
  377. err = snd_pcm_status(substream, &status);
  378. if (err < 0) {
  379. snd_iprintf(buffer, "error %d\n", err);
  380. return;
  381. }
  382. snd_iprintf(buffer, "state: %s\n", snd_pcm_state_name(status.state));
  383. snd_iprintf(buffer, "trigger_time: %ld.%09ld\n",
  384. status.trigger_tstamp.tv_sec, status.trigger_tstamp.tv_nsec);
  385. snd_iprintf(buffer, "tstamp : %ld.%09ld\n",
  386. status.tstamp.tv_sec, status.tstamp.tv_nsec);
  387. snd_iprintf(buffer, "delay : %ld\n", status.delay);
  388. snd_iprintf(buffer, "avail : %ld\n", status.avail);
  389. snd_iprintf(buffer, "avail_max : %ld\n", status.avail_max);
  390. snd_iprintf(buffer, "-----\n");
  391. snd_iprintf(buffer, "hw_ptr : %ld\n", runtime->status->hw_ptr);
  392. snd_iprintf(buffer, "appl_ptr : %ld\n", runtime->control->appl_ptr);
  393. }
  394. #ifdef CONFIG_SND_PCM_XRUN_DEBUG
  395. static void snd_pcm_xrun_debug_read(struct snd_info_entry *entry,
  396. struct snd_info_buffer *buffer)
  397. {
  398. struct snd_pcm_str *pstr = entry->private_data;
  399. snd_iprintf(buffer, "%d\n", pstr->xrun_debug);
  400. }
  401. static void snd_pcm_xrun_debug_write(struct snd_info_entry *entry,
  402. struct snd_info_buffer *buffer)
  403. {
  404. struct snd_pcm_str *pstr = entry->private_data;
  405. char line[64];
  406. if (!snd_info_get_line(buffer, line, sizeof(line)))
  407. pstr->xrun_debug = simple_strtoul(line, NULL, 10);
  408. }
  409. #endif
  410. static int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr)
  411. {
  412. struct snd_pcm *pcm = pstr->pcm;
  413. struct snd_info_entry *entry;
  414. char name[16];
  415. sprintf(name, "pcm%i%c", pcm->device,
  416. pstr->stream == SNDRV_PCM_STREAM_PLAYBACK ? 'p' : 'c');
  417. if ((entry = snd_info_create_card_entry(pcm->card, name, pcm->card->proc_root)) == NULL)
  418. return -ENOMEM;
  419. entry->mode = S_IFDIR | S_IRUGO | S_IXUGO;
  420. if (snd_info_register(entry) < 0) {
  421. snd_info_free_entry(entry);
  422. return -ENOMEM;
  423. }
  424. pstr->proc_root = entry;
  425. if ((entry = snd_info_create_card_entry(pcm->card, "info", pstr->proc_root)) != NULL) {
  426. snd_info_set_text_ops(entry, pstr, snd_pcm_stream_proc_info_read);
  427. if (snd_info_register(entry) < 0) {
  428. snd_info_free_entry(entry);
  429. entry = NULL;
  430. }
  431. }
  432. pstr->proc_info_entry = entry;
  433. #ifdef CONFIG_SND_PCM_XRUN_DEBUG
  434. if ((entry = snd_info_create_card_entry(pcm->card, "xrun_debug",
  435. pstr->proc_root)) != NULL) {
  436. entry->c.text.read = snd_pcm_xrun_debug_read;
  437. entry->c.text.write = snd_pcm_xrun_debug_write;
  438. entry->mode |= S_IWUSR;
  439. entry->private_data = pstr;
  440. if (snd_info_register(entry) < 0) {
  441. snd_info_free_entry(entry);
  442. entry = NULL;
  443. }
  444. }
  445. pstr->proc_xrun_debug_entry = entry;
  446. #endif
  447. return 0;
  448. }
  449. static int snd_pcm_stream_proc_done(struct snd_pcm_str *pstr)
  450. {
  451. #ifdef CONFIG_SND_PCM_XRUN_DEBUG
  452. snd_info_free_entry(pstr->proc_xrun_debug_entry);
  453. pstr->proc_xrun_debug_entry = NULL;
  454. #endif
  455. snd_info_free_entry(pstr->proc_info_entry);
  456. pstr->proc_info_entry = NULL;
  457. snd_info_free_entry(pstr->proc_root);
  458. pstr->proc_root = NULL;
  459. return 0;
  460. }
  461. static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream)
  462. {
  463. struct snd_info_entry *entry;
  464. struct snd_card *card;
  465. char name[16];
  466. card = substream->pcm->card;
  467. sprintf(name, "sub%i", substream->number);
  468. if ((entry = snd_info_create_card_entry(card, name, substream->pstr->proc_root)) == NULL)
  469. return -ENOMEM;
  470. entry->mode = S_IFDIR | S_IRUGO | S_IXUGO;
  471. if (snd_info_register(entry) < 0) {
  472. snd_info_free_entry(entry);
  473. return -ENOMEM;
  474. }
  475. substream->proc_root = entry;
  476. if ((entry = snd_info_create_card_entry(card, "info", substream->proc_root)) != NULL) {
  477. snd_info_set_text_ops(entry, substream,
  478. snd_pcm_substream_proc_info_read);
  479. if (snd_info_register(entry) < 0) {
  480. snd_info_free_entry(entry);
  481. entry = NULL;
  482. }
  483. }
  484. substream->proc_info_entry = entry;
  485. if ((entry = snd_info_create_card_entry(card, "hw_params", substream->proc_root)) != NULL) {
  486. snd_info_set_text_ops(entry, substream,
  487. snd_pcm_substream_proc_hw_params_read);
  488. if (snd_info_register(entry) < 0) {
  489. snd_info_free_entry(entry);
  490. entry = NULL;
  491. }
  492. }
  493. substream->proc_hw_params_entry = entry;
  494. if ((entry = snd_info_create_card_entry(card, "sw_params", substream->proc_root)) != NULL) {
  495. snd_info_set_text_ops(entry, substream,
  496. snd_pcm_substream_proc_sw_params_read);
  497. if (snd_info_register(entry) < 0) {
  498. snd_info_free_entry(entry);
  499. entry = NULL;
  500. }
  501. }
  502. substream->proc_sw_params_entry = entry;
  503. if ((entry = snd_info_create_card_entry(card, "status", substream->proc_root)) != NULL) {
  504. snd_info_set_text_ops(entry, substream,
  505. snd_pcm_substream_proc_status_read);
  506. if (snd_info_register(entry) < 0) {
  507. snd_info_free_entry(entry);
  508. entry = NULL;
  509. }
  510. }
  511. substream->proc_status_entry = entry;
  512. return 0;
  513. }
  514. static int snd_pcm_substream_proc_done(struct snd_pcm_substream *substream)
  515. {
  516. snd_info_free_entry(substream->proc_info_entry);
  517. substream->proc_info_entry = NULL;
  518. snd_info_free_entry(substream->proc_hw_params_entry);
  519. substream->proc_hw_params_entry = NULL;
  520. snd_info_free_entry(substream->proc_sw_params_entry);
  521. substream->proc_sw_params_entry = NULL;
  522. snd_info_free_entry(substream->proc_status_entry);
  523. substream->proc_status_entry = NULL;
  524. snd_info_free_entry(substream->proc_root);
  525. substream->proc_root = NULL;
  526. return 0;
  527. }
  528. #else /* !CONFIG_SND_VERBOSE_PROCFS */
  529. static inline int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr) { return 0; }
  530. static inline int snd_pcm_stream_proc_done(struct snd_pcm_str *pstr) { return 0; }
  531. static inline int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream) { return 0; }
  532. static inline int snd_pcm_substream_proc_done(struct snd_pcm_substream *substream) { return 0; }
  533. #endif /* CONFIG_SND_VERBOSE_PROCFS */
  534. /**
  535. * snd_pcm_new_stream - create a new PCM stream
  536. * @pcm: the pcm instance
  537. * @stream: the stream direction, SNDRV_PCM_STREAM_XXX
  538. * @substream_count: the number of substreams
  539. *
  540. * Creates a new stream for the pcm.
  541. * The corresponding stream on the pcm must have been empty before
  542. * calling this, i.e. zero must be given to the argument of
  543. * snd_pcm_new().
  544. *
  545. * Returns zero if successful, or a negative error code on failure.
  546. */
  547. int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
  548. {
  549. int idx, err;
  550. struct snd_pcm_str *pstr = &pcm->streams[stream];
  551. struct snd_pcm_substream *substream, *prev;
  552. #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
  553. mutex_init(&pstr->oss.setup_mutex);
  554. #endif
  555. pstr->stream = stream;
  556. pstr->pcm = pcm;
  557. pstr->substream_count = substream_count;
  558. if (substream_count > 0) {
  559. err = snd_pcm_stream_proc_init(pstr);
  560. if (err < 0) {
  561. snd_printk(KERN_ERR "Error in snd_pcm_stream_proc_init\n");
  562. return err;
  563. }
  564. }
  565. prev = NULL;
  566. for (idx = 0, prev = NULL; idx < substream_count; idx++) {
  567. substream = kzalloc(sizeof(*substream), GFP_KERNEL);
  568. if (substream == NULL) {
  569. snd_printk(KERN_ERR "Cannot allocate PCM substream\n");
  570. return -ENOMEM;
  571. }
  572. substream->pcm = pcm;
  573. substream->pstr = pstr;
  574. substream->number = idx;
  575. substream->stream = stream;
  576. sprintf(substream->name, "subdevice #%i", idx);
  577. snprintf(substream->latency_id, sizeof(substream->latency_id),
  578. "ALSA-PCM%d-%d%c%d", pcm->card->number, pcm->device,
  579. (stream ? 'c' : 'p'), idx);
  580. substream->buffer_bytes_max = UINT_MAX;
  581. if (prev == NULL)
  582. pstr->substream = substream;
  583. else
  584. prev->next = substream;
  585. err = snd_pcm_substream_proc_init(substream);
  586. if (err < 0) {
  587. snd_printk(KERN_ERR "Error in snd_pcm_stream_proc_init\n");
  588. if (prev == NULL)
  589. pstr->substream = NULL;
  590. else
  591. prev->next = NULL;
  592. kfree(substream);
  593. return err;
  594. }
  595. substream->group = &substream->self_group;
  596. spin_lock_init(&substream->self_group.lock);
  597. INIT_LIST_HEAD(&substream->self_group.substreams);
  598. list_add_tail(&substream->link_list, &substream->self_group.substreams);
  599. spin_lock_init(&substream->timer_lock);
  600. atomic_set(&substream->mmap_count, 0);
  601. prev = substream;
  602. }
  603. return 0;
  604. }
  605. EXPORT_SYMBOL(snd_pcm_new_stream);
  606. /**
  607. * snd_pcm_new - create a new PCM instance
  608. * @card: the card instance
  609. * @id: the id string
  610. * @device: the device index (zero based)
  611. * @playback_count: the number of substreams for playback
  612. * @capture_count: the number of substreams for capture
  613. * @rpcm: the pointer to store the new pcm instance
  614. *
  615. * Creates a new PCM instance.
  616. *
  617. * The pcm operators have to be set afterwards to the new instance
  618. * via snd_pcm_set_ops().
  619. *
  620. * Returns zero if successful, or a negative error code on failure.
  621. */
  622. int snd_pcm_new(struct snd_card *card, char *id, int device,
  623. int playback_count, int capture_count,
  624. struct snd_pcm ** rpcm)
  625. {
  626. struct snd_pcm *pcm;
  627. int err;
  628. static struct snd_device_ops ops = {
  629. .dev_free = snd_pcm_dev_free,
  630. .dev_register = snd_pcm_dev_register,
  631. .dev_disconnect = snd_pcm_dev_disconnect,
  632. };
  633. snd_assert(rpcm != NULL, return -EINVAL);
  634. *rpcm = NULL;
  635. snd_assert(card != NULL, return -ENXIO);
  636. pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
  637. if (pcm == NULL) {
  638. snd_printk(KERN_ERR "Cannot allocate PCM\n");
  639. return -ENOMEM;
  640. }
  641. pcm->card = card;
  642. pcm->device = device;
  643. if (id)
  644. strlcpy(pcm->id, id, sizeof(pcm->id));
  645. if ((err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK, playback_count)) < 0) {
  646. snd_pcm_free(pcm);
  647. return err;
  648. }
  649. if ((err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_CAPTURE, capture_count)) < 0) {
  650. snd_pcm_free(pcm);
  651. return err;
  652. }
  653. mutex_init(&pcm->open_mutex);
  654. init_waitqueue_head(&pcm->open_wait);
  655. if ((err = snd_device_new(card, SNDRV_DEV_PCM, pcm, &ops)) < 0) {
  656. snd_pcm_free(pcm);
  657. return err;
  658. }
  659. *rpcm = pcm;
  660. return 0;
  661. }
  662. EXPORT_SYMBOL(snd_pcm_new);
  663. static void snd_pcm_free_stream(struct snd_pcm_str * pstr)
  664. {
  665. struct snd_pcm_substream *substream, *substream_next;
  666. #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
  667. struct snd_pcm_oss_setup *setup, *setupn;
  668. #endif
  669. substream = pstr->substream;
  670. while (substream) {
  671. substream_next = substream->next;
  672. snd_pcm_timer_done(substream);
  673. snd_pcm_substream_proc_done(substream);
  674. kfree(substream);
  675. substream = substream_next;
  676. }
  677. snd_pcm_stream_proc_done(pstr);
  678. #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
  679. for (setup = pstr->oss.setup_list; setup; setup = setupn) {
  680. setupn = setup->next;
  681. kfree(setup->task_name);
  682. kfree(setup);
  683. }
  684. #endif
  685. }
  686. static int snd_pcm_free(struct snd_pcm *pcm)
  687. {
  688. struct snd_pcm_notify *notify;
  689. snd_assert(pcm != NULL, return -ENXIO);
  690. list_for_each_entry(notify, &snd_pcm_notify_list, list) {
  691. notify->n_unregister(pcm);
  692. }
  693. if (pcm->private_free)
  694. pcm->private_free(pcm);
  695. snd_pcm_lib_preallocate_free_for_all(pcm);
  696. snd_pcm_free_stream(&pcm->streams[SNDRV_PCM_STREAM_PLAYBACK]);
  697. snd_pcm_free_stream(&pcm->streams[SNDRV_PCM_STREAM_CAPTURE]);
  698. kfree(pcm);
  699. return 0;
  700. }
  701. static int snd_pcm_dev_free(struct snd_device *device)
  702. {
  703. struct snd_pcm *pcm = device->device_data;
  704. return snd_pcm_free(pcm);
  705. }
  706. static void snd_pcm_tick_timer_func(unsigned long data)
  707. {
  708. struct snd_pcm_substream *substream = (struct snd_pcm_substream *) data;
  709. snd_pcm_tick_elapsed(substream);
  710. }
  711. int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
  712. struct file *file,
  713. struct snd_pcm_substream **rsubstream)
  714. {
  715. struct snd_pcm_str * pstr;
  716. struct snd_pcm_substream *substream;
  717. struct snd_pcm_runtime *runtime;
  718. struct snd_ctl_file *kctl;
  719. struct snd_card *card;
  720. int prefer_subdevice = -1;
  721. size_t size;
  722. snd_assert(rsubstream != NULL, return -EINVAL);
  723. *rsubstream = NULL;
  724. snd_assert(pcm != NULL, return -ENXIO);
  725. pstr = &pcm->streams[stream];
  726. if (pstr->substream == NULL || pstr->substream_count == 0)
  727. return -ENODEV;
  728. card = pcm->card;
  729. down_read(&card->controls_rwsem);
  730. list_for_each_entry(kctl, &card->ctl_files, list) {
  731. if (kctl->pid == current->pid) {
  732. prefer_subdevice = kctl->prefer_pcm_subdevice;
  733. if (prefer_subdevice != -1)
  734. break;
  735. }
  736. }
  737. up_read(&card->controls_rwsem);
  738. switch (stream) {
  739. case SNDRV_PCM_STREAM_PLAYBACK:
  740. if (pcm->info_flags & SNDRV_PCM_INFO_HALF_DUPLEX) {
  741. for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next) {
  742. if (SUBSTREAM_BUSY(substream))
  743. return -EAGAIN;
  744. }
  745. }
  746. break;
  747. case SNDRV_PCM_STREAM_CAPTURE:
  748. if (pcm->info_flags & SNDRV_PCM_INFO_HALF_DUPLEX) {
  749. for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) {
  750. if (SUBSTREAM_BUSY(substream))
  751. return -EAGAIN;
  752. }
  753. }
  754. break;
  755. default:
  756. return -EINVAL;
  757. }
  758. if (file->f_flags & O_APPEND) {
  759. if (prefer_subdevice < 0) {
  760. if (pstr->substream_count > 1)
  761. return -EINVAL; /* must be unique */
  762. substream = pstr->substream;
  763. } else {
  764. for (substream = pstr->substream; substream;
  765. substream = substream->next)
  766. if (substream->number == prefer_subdevice)
  767. break;
  768. }
  769. if (! substream)
  770. return -ENODEV;
  771. if (! SUBSTREAM_BUSY(substream))
  772. return -EBADFD;
  773. substream->ref_count++;
  774. *rsubstream = substream;
  775. return 0;
  776. }
  777. if (prefer_subdevice >= 0) {
  778. for (substream = pstr->substream; substream; substream = substream->next)
  779. if (!SUBSTREAM_BUSY(substream) && substream->number == prefer_subdevice)
  780. goto __ok;
  781. }
  782. for (substream = pstr->substream; substream; substream = substream->next)
  783. if (!SUBSTREAM_BUSY(substream))
  784. break;
  785. __ok:
  786. if (substream == NULL)
  787. return -EAGAIN;
  788. runtime = kzalloc(sizeof(*runtime), GFP_KERNEL);
  789. if (runtime == NULL)
  790. return -ENOMEM;
  791. size = PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status));
  792. runtime->status = snd_malloc_pages(size, GFP_KERNEL);
  793. if (runtime->status == NULL) {
  794. kfree(runtime);
  795. return -ENOMEM;
  796. }
  797. memset((void*)runtime->status, 0, size);
  798. size = PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control));
  799. runtime->control = snd_malloc_pages(size, GFP_KERNEL);
  800. if (runtime->control == NULL) {
  801. snd_free_pages((void*)runtime->status,
  802. PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status)));
  803. kfree(runtime);
  804. return -ENOMEM;
  805. }
  806. memset((void*)runtime->control, 0, size);
  807. init_waitqueue_head(&runtime->sleep);
  808. init_timer(&runtime->tick_timer);
  809. runtime->tick_timer.function = snd_pcm_tick_timer_func;
  810. runtime->tick_timer.data = (unsigned long) substream;
  811. runtime->status->state = SNDRV_PCM_STATE_OPEN;
  812. substream->runtime = runtime;
  813. substream->private_data = pcm->private_data;
  814. substream->ref_count = 1;
  815. substream->f_flags = file->f_flags;
  816. pstr->substream_opened++;
  817. *rsubstream = substream;
  818. return 0;
  819. }
  820. void snd_pcm_detach_substream(struct snd_pcm_substream *substream)
  821. {
  822. struct snd_pcm_runtime *runtime;
  823. runtime = substream->runtime;
  824. snd_assert(runtime != NULL, return);
  825. if (runtime->private_free != NULL)
  826. runtime->private_free(runtime);
  827. snd_free_pages((void*)runtime->status,
  828. PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status)));
  829. snd_free_pages((void*)runtime->control,
  830. PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control)));
  831. kfree(runtime->hw_constraints.rules);
  832. kfree(runtime);
  833. substream->runtime = NULL;
  834. substream->pstr->substream_opened--;
  835. }
  836. static ssize_t show_pcm_class(struct device *dev,
  837. struct device_attribute *attr, char *buf)
  838. {
  839. struct snd_pcm *pcm;
  840. const char *str;
  841. static const char *strs[SNDRV_PCM_CLASS_LAST + 1] = {
  842. [SNDRV_PCM_CLASS_GENERIC] = "generic",
  843. [SNDRV_PCM_CLASS_MULTI] = "multi",
  844. [SNDRV_PCM_CLASS_MODEM] = "modem",
  845. [SNDRV_PCM_CLASS_DIGITIZER] = "digitizer",
  846. };
  847. if (! (pcm = dev_get_drvdata(dev)) ||
  848. pcm->dev_class > SNDRV_PCM_CLASS_LAST)
  849. str = "none";
  850. else
  851. str = strs[pcm->dev_class];
  852. return snprintf(buf, PAGE_SIZE, "%s\n", str);
  853. }
  854. static struct device_attribute pcm_attrs =
  855. __ATTR(pcm_class, S_IRUGO, show_pcm_class, NULL);
  856. static int snd_pcm_dev_register(struct snd_device *device)
  857. {
  858. int cidx, err;
  859. struct snd_pcm_substream *substream;
  860. struct snd_pcm_notify *notify;
  861. char str[16];
  862. struct snd_pcm *pcm = device->device_data;
  863. struct device *dev;
  864. snd_assert(pcm != NULL && device != NULL, return -ENXIO);
  865. mutex_lock(&register_mutex);
  866. if (snd_pcm_search(pcm->card, pcm->device)) {
  867. mutex_unlock(&register_mutex);
  868. return -EBUSY;
  869. }
  870. list_add_tail(&pcm->list, &snd_pcm_devices);
  871. for (cidx = 0; cidx < 2; cidx++) {
  872. int devtype = -1;
  873. if (pcm->streams[cidx].substream == NULL)
  874. continue;
  875. switch (cidx) {
  876. case SNDRV_PCM_STREAM_PLAYBACK:
  877. sprintf(str, "pcmC%iD%ip", pcm->card->number, pcm->device);
  878. devtype = SNDRV_DEVICE_TYPE_PCM_PLAYBACK;
  879. break;
  880. case SNDRV_PCM_STREAM_CAPTURE:
  881. sprintf(str, "pcmC%iD%ic", pcm->card->number, pcm->device);
  882. devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE;
  883. break;
  884. }
  885. /* device pointer to use, pcm->dev takes precedence if
  886. * it is assigned, otherwise fall back to card's device
  887. * if possible */
  888. dev = pcm->dev;
  889. if (!dev)
  890. dev = snd_card_get_device_link(pcm->card);
  891. /* register pcm */
  892. err = snd_register_device_for_dev(devtype, pcm->card,
  893. pcm->device,
  894. &snd_pcm_f_ops[cidx],
  895. pcm, str, dev);
  896. if (err < 0) {
  897. list_del(&pcm->list);
  898. mutex_unlock(&register_mutex);
  899. return err;
  900. }
  901. snd_add_device_sysfs_file(devtype, pcm->card, pcm->device,
  902. &pcm_attrs);
  903. for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
  904. snd_pcm_timer_init(substream);
  905. }
  906. list_for_each_entry(notify, &snd_pcm_notify_list, list)
  907. notify->n_register(pcm);
  908. mutex_unlock(&register_mutex);
  909. return 0;
  910. }
  911. static int snd_pcm_dev_disconnect(struct snd_device *device)
  912. {
  913. struct snd_pcm *pcm = device->device_data;
  914. struct snd_pcm_notify *notify;
  915. struct snd_pcm_substream *substream;
  916. int cidx, devtype;
  917. mutex_lock(&register_mutex);
  918. if (list_empty(&pcm->list))
  919. goto unlock;
  920. list_del_init(&pcm->list);
  921. for (cidx = 0; cidx < 2; cidx++)
  922. for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
  923. if (substream->runtime)
  924. substream->runtime->status->state = SNDRV_PCM_STATE_DISCONNECTED;
  925. list_for_each_entry(notify, &snd_pcm_notify_list, list) {
  926. notify->n_disconnect(pcm);
  927. }
  928. for (cidx = 0; cidx < 2; cidx++) {
  929. devtype = -1;
  930. switch (cidx) {
  931. case SNDRV_PCM_STREAM_PLAYBACK:
  932. devtype = SNDRV_DEVICE_TYPE_PCM_PLAYBACK;
  933. break;
  934. case SNDRV_PCM_STREAM_CAPTURE:
  935. devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE;
  936. break;
  937. }
  938. snd_unregister_device(devtype, pcm->card, pcm->device);
  939. }
  940. unlock:
  941. mutex_unlock(&register_mutex);
  942. return 0;
  943. }
  944. int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
  945. {
  946. struct snd_pcm *pcm;
  947. snd_assert(notify != NULL &&
  948. notify->n_register != NULL &&
  949. notify->n_unregister != NULL &&
  950. notify->n_disconnect, return -EINVAL);
  951. mutex_lock(&register_mutex);
  952. if (nfree) {
  953. list_del(&notify->list);
  954. list_for_each_entry(pcm, &snd_pcm_devices, list)
  955. notify->n_unregister(pcm);
  956. } else {
  957. list_add_tail(&notify->list, &snd_pcm_notify_list);
  958. list_for_each_entry(pcm, &snd_pcm_devices, list)
  959. notify->n_register(pcm);
  960. }
  961. mutex_unlock(&register_mutex);
  962. return 0;
  963. }
  964. EXPORT_SYMBOL(snd_pcm_notify);
  965. #ifdef CONFIG_PROC_FS
  966. /*
  967. * Info interface
  968. */
  969. static void snd_pcm_proc_read(struct snd_info_entry *entry,
  970. struct snd_info_buffer *buffer)
  971. {
  972. struct snd_pcm *pcm;
  973. mutex_lock(&register_mutex);
  974. list_for_each_entry(pcm, &snd_pcm_devices, list) {
  975. snd_iprintf(buffer, "%02i-%02i: %s : %s",
  976. pcm->card->number, pcm->device, pcm->id, pcm->name);
  977. if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream)
  978. snd_iprintf(buffer, " : playback %i",
  979. pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream_count);
  980. if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream)
  981. snd_iprintf(buffer, " : capture %i",
  982. pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream_count);
  983. snd_iprintf(buffer, "\n");
  984. }
  985. mutex_unlock(&register_mutex);
  986. }
  987. static struct snd_info_entry *snd_pcm_proc_entry;
  988. static void snd_pcm_proc_init(void)
  989. {
  990. struct snd_info_entry *entry;
  991. if ((entry = snd_info_create_module_entry(THIS_MODULE, "pcm", NULL)) != NULL) {
  992. snd_info_set_text_ops(entry, NULL, snd_pcm_proc_read);
  993. if (snd_info_register(entry) < 0) {
  994. snd_info_free_entry(entry);
  995. entry = NULL;
  996. }
  997. }
  998. snd_pcm_proc_entry = entry;
  999. }
  1000. static void snd_pcm_proc_done(void)
  1001. {
  1002. snd_info_free_entry(snd_pcm_proc_entry);
  1003. }
  1004. #else /* !CONFIG_PROC_FS */
  1005. #define snd_pcm_proc_init()
  1006. #define snd_pcm_proc_done()
  1007. #endif /* CONFIG_PROC_FS */
  1008. /*
  1009. * ENTRY functions
  1010. */
  1011. static int __init alsa_pcm_init(void)
  1012. {
  1013. snd_ctl_register_ioctl(snd_pcm_control_ioctl);
  1014. snd_ctl_register_ioctl_compat(snd_pcm_control_ioctl);
  1015. snd_pcm_proc_init();
  1016. return 0;
  1017. }
  1018. static void __exit alsa_pcm_exit(void)
  1019. {
  1020. snd_ctl_unregister_ioctl(snd_pcm_control_ioctl);
  1021. snd_ctl_unregister_ioctl_compat(snd_pcm_control_ioctl);
  1022. snd_pcm_proc_done();
  1023. }
  1024. module_init(alsa_pcm_init)
  1025. module_exit(alsa_pcm_exit)