pcm.c 31 KB

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