pcm.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  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. struct snd_pcm *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(struct snd_pcm *pcm);
  37. static int snd_pcm_dev_free(struct snd_device *device);
  38. static int snd_pcm_dev_register(struct snd_device *device);
  39. static int snd_pcm_dev_disconnect(struct snd_device *device);
  40. static int snd_pcm_dev_unregister(struct snd_device *device);
  41. static int snd_pcm_control_ioctl(struct snd_card *card,
  42. struct snd_ctl_file *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. struct snd_pcm_info __user *info;
  68. unsigned int device, subdevice;
  69. int stream;
  70. struct snd_pcm *pcm;
  71. struct snd_pcm_str *pstr;
  72. struct snd_pcm_substream *substream;
  73. info = (struct snd_pcm_info __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(int 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. return snd_pcm_access_names[access];
  196. }
  197. const char *snd_pcm_format_name(snd_pcm_format_t format)
  198. {
  199. return snd_pcm_format_names[format];
  200. }
  201. static const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat)
  202. {
  203. return snd_pcm_subformat_names[subformat];
  204. }
  205. static const char *snd_pcm_tstamp_mode_name(int mode)
  206. {
  207. snd_assert(mode <= SNDRV_PCM_TSTAMP_LAST, return NULL);
  208. return snd_pcm_tstamp_mode_names[mode];
  209. }
  210. static const char *snd_pcm_state_name(snd_pcm_state_t state)
  211. {
  212. return snd_pcm_state_names[state];
  213. }
  214. #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
  215. #include <linux/soundcard.h>
  216. static const char *snd_pcm_oss_format_name(int format)
  217. {
  218. switch (format) {
  219. case AFMT_MU_LAW:
  220. return "MU_LAW";
  221. case AFMT_A_LAW:
  222. return "A_LAW";
  223. case AFMT_IMA_ADPCM:
  224. return "IMA_ADPCM";
  225. case AFMT_U8:
  226. return "U8";
  227. case AFMT_S16_LE:
  228. return "S16_LE";
  229. case AFMT_S16_BE:
  230. return "S16_BE";
  231. case AFMT_S8:
  232. return "S8";
  233. case AFMT_U16_LE:
  234. return "U16_LE";
  235. case AFMT_U16_BE:
  236. return "U16_BE";
  237. case AFMT_MPEG:
  238. return "MPEG";
  239. default:
  240. return "unknown";
  241. }
  242. }
  243. #endif
  244. #ifdef CONFIG_PROC_FS
  245. static void snd_pcm_proc_info_read(struct snd_pcm_substream *substream,
  246. struct snd_info_buffer *buffer)
  247. {
  248. struct snd_pcm_info *info;
  249. int err;
  250. if (! substream)
  251. return;
  252. info = kmalloc(sizeof(*info), GFP_KERNEL);
  253. if (! info) {
  254. printk(KERN_DEBUG "snd_pcm_proc_info_read: cannot malloc\n");
  255. return;
  256. }
  257. err = snd_pcm_info(substream, info);
  258. if (err < 0) {
  259. snd_iprintf(buffer, "error %d\n", err);
  260. kfree(info);
  261. return;
  262. }
  263. snd_iprintf(buffer, "card: %d\n", info->card);
  264. snd_iprintf(buffer, "device: %d\n", info->device);
  265. snd_iprintf(buffer, "subdevice: %d\n", info->subdevice);
  266. snd_iprintf(buffer, "stream: %s\n", snd_pcm_stream_name(info->stream));
  267. snd_iprintf(buffer, "id: %s\n", info->id);
  268. snd_iprintf(buffer, "name: %s\n", info->name);
  269. snd_iprintf(buffer, "subname: %s\n", info->subname);
  270. snd_iprintf(buffer, "class: %d\n", info->dev_class);
  271. snd_iprintf(buffer, "subclass: %d\n", info->dev_subclass);
  272. snd_iprintf(buffer, "subdevices_count: %d\n", info->subdevices_count);
  273. snd_iprintf(buffer, "subdevices_avail: %d\n", info->subdevices_avail);
  274. kfree(info);
  275. }
  276. static void snd_pcm_stream_proc_info_read(struct snd_info_entry *entry,
  277. struct snd_info_buffer *buffer)
  278. {
  279. snd_pcm_proc_info_read(((struct snd_pcm_str *)entry->private_data)->substream,
  280. buffer);
  281. }
  282. static void snd_pcm_substream_proc_info_read(struct snd_info_entry *entry,
  283. struct snd_info_buffer *buffer)
  284. {
  285. snd_pcm_proc_info_read((struct snd_pcm_substream *)entry->private_data,
  286. buffer);
  287. }
  288. static void snd_pcm_substream_proc_hw_params_read(struct snd_info_entry *entry,
  289. struct snd_info_buffer *buffer)
  290. {
  291. struct snd_pcm_substream *substream = entry->private_data;
  292. struct snd_pcm_runtime *runtime = substream->runtime;
  293. if (!runtime) {
  294. snd_iprintf(buffer, "closed\n");
  295. return;
  296. }
  297. snd_pcm_stream_lock_irq(substream);
  298. if (runtime->status->state == SNDRV_PCM_STATE_OPEN) {
  299. snd_iprintf(buffer, "no setup\n");
  300. snd_pcm_stream_unlock_irq(substream);
  301. return;
  302. }
  303. snd_iprintf(buffer, "access: %s\n", snd_pcm_access_name(runtime->access));
  304. snd_iprintf(buffer, "format: %s\n", snd_pcm_format_name(runtime->format));
  305. snd_iprintf(buffer, "subformat: %s\n", snd_pcm_subformat_name(runtime->subformat));
  306. snd_iprintf(buffer, "channels: %u\n", runtime->channels);
  307. snd_iprintf(buffer, "rate: %u (%u/%u)\n", runtime->rate, runtime->rate_num, runtime->rate_den);
  308. snd_iprintf(buffer, "period_size: %lu\n", runtime->period_size);
  309. snd_iprintf(buffer, "buffer_size: %lu\n", runtime->buffer_size);
  310. snd_iprintf(buffer, "tick_time: %u\n", runtime->tick_time);
  311. #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
  312. if (substream->oss.oss) {
  313. snd_iprintf(buffer, "OSS format: %s\n", snd_pcm_oss_format_name(runtime->oss.format));
  314. snd_iprintf(buffer, "OSS channels: %u\n", runtime->oss.channels);
  315. snd_iprintf(buffer, "OSS rate: %u\n", runtime->oss.rate);
  316. snd_iprintf(buffer, "OSS period bytes: %lu\n", (unsigned long)runtime->oss.period_bytes);
  317. snd_iprintf(buffer, "OSS periods: %u\n", runtime->oss.periods);
  318. snd_iprintf(buffer, "OSS period frames: %lu\n", (unsigned long)runtime->oss.period_frames);
  319. }
  320. #endif
  321. snd_pcm_stream_unlock_irq(substream);
  322. }
  323. static void snd_pcm_substream_proc_sw_params_read(struct snd_info_entry *entry,
  324. struct snd_info_buffer *buffer)
  325. {
  326. struct snd_pcm_substream *substream = entry->private_data;
  327. struct snd_pcm_runtime *runtime = substream->runtime;
  328. if (!runtime) {
  329. snd_iprintf(buffer, "closed\n");
  330. return;
  331. }
  332. snd_pcm_stream_lock_irq(substream);
  333. if (runtime->status->state == SNDRV_PCM_STATE_OPEN) {
  334. snd_iprintf(buffer, "no setup\n");
  335. snd_pcm_stream_unlock_irq(substream);
  336. return;
  337. }
  338. snd_iprintf(buffer, "tstamp_mode: %s\n", snd_pcm_tstamp_mode_name(runtime->tstamp_mode));
  339. snd_iprintf(buffer, "period_step: %u\n", runtime->period_step);
  340. snd_iprintf(buffer, "sleep_min: %u\n", runtime->sleep_min);
  341. snd_iprintf(buffer, "avail_min: %lu\n", runtime->control->avail_min);
  342. snd_iprintf(buffer, "xfer_align: %lu\n", runtime->xfer_align);
  343. snd_iprintf(buffer, "start_threshold: %lu\n", runtime->start_threshold);
  344. snd_iprintf(buffer, "stop_threshold: %lu\n", runtime->stop_threshold);
  345. snd_iprintf(buffer, "silence_threshold: %lu\n", runtime->silence_threshold);
  346. snd_iprintf(buffer, "silence_size: %lu\n", runtime->silence_size);
  347. snd_iprintf(buffer, "boundary: %lu\n", runtime->boundary);
  348. snd_pcm_stream_unlock_irq(substream);
  349. }
  350. static void snd_pcm_substream_proc_status_read(struct snd_info_entry *entry,
  351. struct snd_info_buffer *buffer)
  352. {
  353. struct snd_pcm_substream *substream = entry->private_data;
  354. struct snd_pcm_runtime *runtime = substream->runtime;
  355. struct snd_pcm_status status;
  356. int err;
  357. if (!runtime) {
  358. snd_iprintf(buffer, "closed\n");
  359. return;
  360. }
  361. memset(&status, 0, sizeof(status));
  362. err = snd_pcm_status(substream, &status);
  363. if (err < 0) {
  364. snd_iprintf(buffer, "error %d\n", err);
  365. return;
  366. }
  367. snd_iprintf(buffer, "state: %s\n", snd_pcm_state_name(status.state));
  368. snd_iprintf(buffer, "trigger_time: %ld.%09ld\n",
  369. status.trigger_tstamp.tv_sec, status.trigger_tstamp.tv_nsec);
  370. snd_iprintf(buffer, "tstamp : %ld.%09ld\n",
  371. status.tstamp.tv_sec, status.tstamp.tv_nsec);
  372. snd_iprintf(buffer, "delay : %ld\n", status.delay);
  373. snd_iprintf(buffer, "avail : %ld\n", status.avail);
  374. snd_iprintf(buffer, "avail_max : %ld\n", status.avail_max);
  375. snd_iprintf(buffer, "-----\n");
  376. snd_iprintf(buffer, "hw_ptr : %ld\n", runtime->status->hw_ptr);
  377. snd_iprintf(buffer, "appl_ptr : %ld\n", runtime->control->appl_ptr);
  378. }
  379. #endif
  380. #ifdef CONFIG_SND_DEBUG
  381. static void snd_pcm_xrun_debug_read(struct snd_info_entry *entry,
  382. struct snd_info_buffer *buffer)
  383. {
  384. struct snd_pcm_str *pstr = entry->private_data;
  385. snd_iprintf(buffer, "%d\n", pstr->xrun_debug);
  386. }
  387. static void snd_pcm_xrun_debug_write(struct snd_info_entry *entry,
  388. struct snd_info_buffer *buffer)
  389. {
  390. struct snd_pcm_str *pstr = entry->private_data;
  391. char line[64];
  392. if (!snd_info_get_line(buffer, line, sizeof(line)))
  393. pstr->xrun_debug = simple_strtoul(line, NULL, 10);
  394. }
  395. #endif
  396. static int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr)
  397. {
  398. struct snd_pcm *pcm = pstr->pcm;
  399. struct snd_info_entry *entry;
  400. char name[16];
  401. sprintf(name, "pcm%i%c", pcm->device,
  402. pstr->stream == SNDRV_PCM_STREAM_PLAYBACK ? 'p' : 'c');
  403. if ((entry = snd_info_create_card_entry(pcm->card, name, pcm->card->proc_root)) == NULL)
  404. return -ENOMEM;
  405. entry->mode = S_IFDIR | S_IRUGO | S_IXUGO;
  406. if (snd_info_register(entry) < 0) {
  407. snd_info_free_entry(entry);
  408. return -ENOMEM;
  409. }
  410. pstr->proc_root = entry;
  411. if ((entry = snd_info_create_card_entry(pcm->card, "info", pstr->proc_root)) != NULL) {
  412. snd_info_set_text_ops(entry, pstr, 256, snd_pcm_stream_proc_info_read);
  413. if (snd_info_register(entry) < 0) {
  414. snd_info_free_entry(entry);
  415. entry = NULL;
  416. }
  417. }
  418. pstr->proc_info_entry = entry;
  419. #ifdef CONFIG_SND_DEBUG
  420. if ((entry = snd_info_create_card_entry(pcm->card, "xrun_debug",
  421. pstr->proc_root)) != NULL) {
  422. entry->c.text.read_size = 64;
  423. entry->c.text.read = snd_pcm_xrun_debug_read;
  424. entry->c.text.write_size = 64;
  425. entry->c.text.write = snd_pcm_xrun_debug_write;
  426. entry->mode |= S_IWUSR;
  427. entry->private_data = pstr;
  428. if (snd_info_register(entry) < 0) {
  429. snd_info_free_entry(entry);
  430. entry = NULL;
  431. }
  432. }
  433. pstr->proc_xrun_debug_entry = entry;
  434. #endif
  435. return 0;
  436. }
  437. static int snd_pcm_stream_proc_done(struct snd_pcm_str *pstr)
  438. {
  439. #ifdef CONFIG_SND_DEBUG
  440. if (pstr->proc_xrun_debug_entry) {
  441. snd_info_unregister(pstr->proc_xrun_debug_entry);
  442. pstr->proc_xrun_debug_entry = NULL;
  443. }
  444. #endif
  445. if (pstr->proc_info_entry) {
  446. snd_info_unregister(pstr->proc_info_entry);
  447. pstr->proc_info_entry = NULL;
  448. }
  449. if (pstr->proc_root) {
  450. snd_info_unregister(pstr->proc_root);
  451. pstr->proc_root = NULL;
  452. }
  453. return 0;
  454. }
  455. static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream)
  456. {
  457. struct snd_info_entry *entry;
  458. struct snd_card *card;
  459. char name[16];
  460. card = substream->pcm->card;
  461. sprintf(name, "sub%i", substream->number);
  462. if ((entry = snd_info_create_card_entry(card, name, substream->pstr->proc_root)) == NULL)
  463. return -ENOMEM;
  464. entry->mode = S_IFDIR | S_IRUGO | S_IXUGO;
  465. if (snd_info_register(entry) < 0) {
  466. snd_info_free_entry(entry);
  467. return -ENOMEM;
  468. }
  469. substream->proc_root = entry;
  470. if ((entry = snd_info_create_card_entry(card, "info", substream->proc_root)) != NULL) {
  471. snd_info_set_text_ops(entry, substream, 256, snd_pcm_substream_proc_info_read);
  472. if (snd_info_register(entry) < 0) {
  473. snd_info_free_entry(entry);
  474. entry = NULL;
  475. }
  476. }
  477. substream->proc_info_entry = entry;
  478. if ((entry = snd_info_create_card_entry(card, "hw_params", substream->proc_root)) != NULL) {
  479. snd_info_set_text_ops(entry, substream, 256, snd_pcm_substream_proc_hw_params_read);
  480. if (snd_info_register(entry) < 0) {
  481. snd_info_free_entry(entry);
  482. entry = NULL;
  483. }
  484. }
  485. substream->proc_hw_params_entry = entry;
  486. if ((entry = snd_info_create_card_entry(card, "sw_params", substream->proc_root)) != NULL) {
  487. snd_info_set_text_ops(entry, substream, 256, snd_pcm_substream_proc_sw_params_read);
  488. if (snd_info_register(entry) < 0) {
  489. snd_info_free_entry(entry);
  490. entry = NULL;
  491. }
  492. }
  493. substream->proc_sw_params_entry = entry;
  494. if ((entry = snd_info_create_card_entry(card, "status", substream->proc_root)) != NULL) {
  495. snd_info_set_text_ops(entry, substream, 256, snd_pcm_substream_proc_status_read);
  496. if (snd_info_register(entry) < 0) {
  497. snd_info_free_entry(entry);
  498. entry = NULL;
  499. }
  500. }
  501. substream->proc_status_entry = entry;
  502. return 0;
  503. }
  504. static int snd_pcm_substream_proc_done(struct snd_pcm_substream *substream)
  505. {
  506. if (substream->proc_info_entry) {
  507. snd_info_unregister(substream->proc_info_entry);
  508. substream->proc_info_entry = NULL;
  509. }
  510. if (substream->proc_hw_params_entry) {
  511. snd_info_unregister(substream->proc_hw_params_entry);
  512. substream->proc_hw_params_entry = NULL;
  513. }
  514. if (substream->proc_sw_params_entry) {
  515. snd_info_unregister(substream->proc_sw_params_entry);
  516. substream->proc_sw_params_entry = NULL;
  517. }
  518. if (substream->proc_status_entry) {
  519. snd_info_unregister(substream->proc_status_entry);
  520. substream->proc_status_entry = NULL;
  521. }
  522. if (substream->proc_root) {
  523. snd_info_unregister(substream->proc_root);
  524. substream->proc_root = NULL;
  525. }
  526. return 0;
  527. }
  528. /**
  529. * snd_pcm_new_stream - create a new PCM stream
  530. * @pcm: the pcm instance
  531. * @stream: the stream direction, SNDRV_PCM_STREAM_XXX
  532. * @substream_count: the number of substreams
  533. *
  534. * Creates a new stream for the pcm.
  535. * The corresponding stream on the pcm must have been empty before
  536. * calling this, i.e. zero must be given to the argument of
  537. * snd_pcm_new().
  538. *
  539. * Returns zero if successful, or a negative error code on failure.
  540. */
  541. int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
  542. {
  543. int idx, err;
  544. struct snd_pcm_str *pstr = &pcm->streams[stream];
  545. struct snd_pcm_substream *substream, *prev;
  546. #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
  547. init_MUTEX(&pstr->oss.setup_mutex);
  548. #endif
  549. pstr->stream = stream;
  550. pstr->pcm = pcm;
  551. pstr->substream_count = substream_count;
  552. pstr->reg = &snd_pcm_reg[stream];
  553. if (substream_count > 0) {
  554. err = snd_pcm_stream_proc_init(pstr);
  555. if (err < 0) {
  556. snd_printk(KERN_ERR "Error in snd_pcm_stream_proc_init\n");
  557. return err;
  558. }
  559. }
  560. prev = NULL;
  561. for (idx = 0, prev = NULL; idx < substream_count; idx++) {
  562. substream = kzalloc(sizeof(*substream), GFP_KERNEL);
  563. if (substream == NULL) {
  564. snd_printk(KERN_ERR "Cannot allocate PCM substream\n");
  565. return -ENOMEM;
  566. }
  567. substream->pcm = pcm;
  568. substream->pstr = pstr;
  569. substream->number = idx;
  570. substream->stream = stream;
  571. sprintf(substream->name, "subdevice #%i", idx);
  572. substream->buffer_bytes_max = UINT_MAX;
  573. if (prev == NULL)
  574. pstr->substream = substream;
  575. else
  576. prev->next = substream;
  577. err = snd_pcm_substream_proc_init(substream);
  578. if (err < 0) {
  579. snd_printk(KERN_ERR "Error in snd_pcm_stream_proc_init\n");
  580. kfree(substream);
  581. return err;
  582. }
  583. substream->group = &substream->self_group;
  584. spin_lock_init(&substream->self_group.lock);
  585. INIT_LIST_HEAD(&substream->self_group.substreams);
  586. list_add_tail(&substream->link_list, &substream->self_group.substreams);
  587. spin_lock_init(&substream->timer_lock);
  588. prev = substream;
  589. }
  590. return 0;
  591. }
  592. /**
  593. * snd_pcm_new - create a new PCM instance
  594. * @card: the card instance
  595. * @id: the id string
  596. * @device: the device index (zero based)
  597. * @playback_count: the number of substreams for playback
  598. * @capture_count: the number of substreams for capture
  599. * @rpcm: the pointer to store the new pcm instance
  600. *
  601. * Creates a new PCM instance.
  602. *
  603. * The pcm operators have to be set afterwards to the new instance
  604. * via snd_pcm_set_ops().
  605. *
  606. * Returns zero if successful, or a negative error code on failure.
  607. */
  608. int snd_pcm_new(struct snd_card *card, char *id, int device,
  609. int playback_count, int capture_count,
  610. struct snd_pcm ** rpcm)
  611. {
  612. struct snd_pcm *pcm;
  613. int err;
  614. static struct snd_device_ops ops = {
  615. .dev_free = snd_pcm_dev_free,
  616. .dev_register = snd_pcm_dev_register,
  617. .dev_disconnect = snd_pcm_dev_disconnect,
  618. .dev_unregister = snd_pcm_dev_unregister
  619. };
  620. snd_assert(rpcm != NULL, return -EINVAL);
  621. *rpcm = NULL;
  622. snd_assert(card != NULL, return -ENXIO);
  623. pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
  624. if (pcm == NULL) {
  625. snd_printk(KERN_ERR "Cannot allocate PCM\n");
  626. return -ENOMEM;
  627. }
  628. pcm->card = card;
  629. pcm->device = device;
  630. if (id)
  631. strlcpy(pcm->id, id, sizeof(pcm->id));
  632. if ((err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK, playback_count)) < 0) {
  633. snd_pcm_free(pcm);
  634. return err;
  635. }
  636. if ((err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_CAPTURE, capture_count)) < 0) {
  637. snd_pcm_free(pcm);
  638. return err;
  639. }
  640. init_MUTEX(&pcm->open_mutex);
  641. init_waitqueue_head(&pcm->open_wait);
  642. if ((err = snd_device_new(card, SNDRV_DEV_PCM, pcm, &ops)) < 0) {
  643. snd_pcm_free(pcm);
  644. return err;
  645. }
  646. *rpcm = pcm;
  647. return 0;
  648. }
  649. static void snd_pcm_free_stream(struct snd_pcm_str * pstr)
  650. {
  651. struct snd_pcm_substream *substream, *substream_next;
  652. #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
  653. struct snd_pcm_oss_setup *setup, *setupn;
  654. #endif
  655. substream = pstr->substream;
  656. while (substream) {
  657. substream_next = substream->next;
  658. snd_pcm_substream_proc_done(substream);
  659. kfree(substream);
  660. substream = substream_next;
  661. }
  662. snd_pcm_stream_proc_done(pstr);
  663. #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
  664. for (setup = pstr->oss.setup_list; setup; setup = setupn) {
  665. setupn = setup->next;
  666. kfree(setup->task_name);
  667. kfree(setup);
  668. }
  669. #endif
  670. }
  671. static int snd_pcm_free(struct snd_pcm *pcm)
  672. {
  673. snd_assert(pcm != NULL, return -ENXIO);
  674. if (pcm->private_free)
  675. pcm->private_free(pcm);
  676. snd_pcm_lib_preallocate_free_for_all(pcm);
  677. snd_pcm_free_stream(&pcm->streams[SNDRV_PCM_STREAM_PLAYBACK]);
  678. snd_pcm_free_stream(&pcm->streams[SNDRV_PCM_STREAM_CAPTURE]);
  679. kfree(pcm);
  680. return 0;
  681. }
  682. static int snd_pcm_dev_free(struct snd_device *device)
  683. {
  684. struct snd_pcm *pcm = device->device_data;
  685. return snd_pcm_free(pcm);
  686. }
  687. static void snd_pcm_tick_timer_func(unsigned long data)
  688. {
  689. struct snd_pcm_substream *substream = (struct snd_pcm_substream *) data;
  690. snd_pcm_tick_elapsed(substream);
  691. }
  692. int snd_pcm_open_substream(struct snd_pcm *pcm, int stream,
  693. struct snd_pcm_substream **rsubstream)
  694. {
  695. struct snd_pcm_str * pstr;
  696. struct snd_pcm_substream *substream;
  697. struct snd_pcm_runtime *runtime;
  698. struct snd_ctl_file *kctl;
  699. struct snd_card *card;
  700. struct list_head *list;
  701. int prefer_subdevice = -1;
  702. size_t size;
  703. snd_assert(rsubstream != NULL, return -EINVAL);
  704. *rsubstream = NULL;
  705. snd_assert(pcm != NULL, return -ENXIO);
  706. pstr = &pcm->streams[stream];
  707. if (pstr->substream == NULL)
  708. return -ENODEV;
  709. card = pcm->card;
  710. down_read(&card->controls_rwsem);
  711. list_for_each(list, &card->ctl_files) {
  712. kctl = snd_ctl_file(list);
  713. if (kctl->pid == current->pid) {
  714. prefer_subdevice = kctl->prefer_pcm_subdevice;
  715. break;
  716. }
  717. }
  718. up_read(&card->controls_rwsem);
  719. if (pstr->substream_count == 0)
  720. return -ENODEV;
  721. switch (stream) {
  722. case SNDRV_PCM_STREAM_PLAYBACK:
  723. if (pcm->info_flags & SNDRV_PCM_INFO_HALF_DUPLEX) {
  724. for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next) {
  725. if (SUBSTREAM_BUSY(substream))
  726. return -EAGAIN;
  727. }
  728. }
  729. break;
  730. case SNDRV_PCM_STREAM_CAPTURE:
  731. if (pcm->info_flags & SNDRV_PCM_INFO_HALF_DUPLEX) {
  732. for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) {
  733. if (SUBSTREAM_BUSY(substream))
  734. return -EAGAIN;
  735. }
  736. }
  737. break;
  738. default:
  739. return -EINVAL;
  740. }
  741. if (prefer_subdevice >= 0) {
  742. for (substream = pstr->substream; substream; substream = substream->next)
  743. if (!SUBSTREAM_BUSY(substream) && substream->number == prefer_subdevice)
  744. goto __ok;
  745. }
  746. for (substream = pstr->substream; substream; substream = substream->next)
  747. if (!SUBSTREAM_BUSY(substream))
  748. break;
  749. __ok:
  750. if (substream == NULL)
  751. return -EAGAIN;
  752. runtime = kzalloc(sizeof(*runtime), GFP_KERNEL);
  753. if (runtime == NULL)
  754. return -ENOMEM;
  755. size = PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status));
  756. runtime->status = snd_malloc_pages(size, GFP_KERNEL);
  757. if (runtime->status == NULL) {
  758. kfree(runtime);
  759. return -ENOMEM;
  760. }
  761. memset((void*)runtime->status, 0, size);
  762. size = PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control));
  763. runtime->control = snd_malloc_pages(size, GFP_KERNEL);
  764. if (runtime->control == NULL) {
  765. snd_free_pages((void*)runtime->status,
  766. PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status)));
  767. kfree(runtime);
  768. return -ENOMEM;
  769. }
  770. memset((void*)runtime->control, 0, size);
  771. init_waitqueue_head(&runtime->sleep);
  772. atomic_set(&runtime->mmap_count, 0);
  773. init_timer(&runtime->tick_timer);
  774. runtime->tick_timer.function = snd_pcm_tick_timer_func;
  775. runtime->tick_timer.data = (unsigned long) substream;
  776. runtime->status->state = SNDRV_PCM_STATE_OPEN;
  777. substream->runtime = runtime;
  778. substream->private_data = pcm->private_data;
  779. pstr->substream_opened++;
  780. *rsubstream = substream;
  781. return 0;
  782. }
  783. void snd_pcm_release_substream(struct snd_pcm_substream *substream)
  784. {
  785. struct snd_pcm_runtime *runtime;
  786. substream->file = NULL;
  787. runtime = substream->runtime;
  788. snd_assert(runtime != NULL, return);
  789. if (runtime->private_free != NULL)
  790. runtime->private_free(runtime);
  791. snd_free_pages((void*)runtime->status,
  792. PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status)));
  793. snd_free_pages((void*)runtime->control,
  794. PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control)));
  795. kfree(runtime->hw_constraints.rules);
  796. kfree(runtime);
  797. substream->runtime = NULL;
  798. substream->pstr->substream_opened--;
  799. }
  800. static int snd_pcm_dev_register(struct snd_device *device)
  801. {
  802. int idx, cidx, err;
  803. unsigned short minor;
  804. struct snd_pcm_substream *substream;
  805. struct list_head *list;
  806. char str[16];
  807. struct snd_pcm *pcm = device->device_data;
  808. snd_assert(pcm != NULL && device != NULL, return -ENXIO);
  809. down(&register_mutex);
  810. idx = (pcm->card->number * SNDRV_PCM_DEVICES) + pcm->device;
  811. if (snd_pcm_devices[idx]) {
  812. up(&register_mutex);
  813. return -EBUSY;
  814. }
  815. snd_pcm_devices[idx] = pcm;
  816. for (cidx = 0; cidx < 2; cidx++) {
  817. int devtype = -1;
  818. if (pcm->streams[cidx].substream == NULL)
  819. continue;
  820. switch (cidx) {
  821. case SNDRV_PCM_STREAM_PLAYBACK:
  822. sprintf(str, "pcmC%iD%ip", pcm->card->number, pcm->device);
  823. minor = SNDRV_MINOR_PCM_PLAYBACK + idx;
  824. devtype = SNDRV_DEVICE_TYPE_PCM_PLAYBACK;
  825. break;
  826. case SNDRV_PCM_STREAM_CAPTURE:
  827. sprintf(str, "pcmC%iD%ic", pcm->card->number, pcm->device);
  828. minor = SNDRV_MINOR_PCM_CAPTURE + idx;
  829. devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE;
  830. break;
  831. }
  832. if ((err = snd_register_device(devtype, pcm->card, pcm->device, pcm->streams[cidx].reg, str)) < 0) {
  833. snd_pcm_devices[idx] = NULL;
  834. up(&register_mutex);
  835. return err;
  836. }
  837. for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
  838. snd_pcm_timer_init(substream);
  839. }
  840. list_for_each(list, &snd_pcm_notify_list) {
  841. struct snd_pcm_notify *notify;
  842. notify = list_entry(list, struct snd_pcm_notify, list);
  843. notify->n_register(pcm);
  844. }
  845. up(&register_mutex);
  846. return 0;
  847. }
  848. static int snd_pcm_dev_disconnect(struct snd_device *device)
  849. {
  850. struct snd_pcm *pcm = device->device_data;
  851. struct list_head *list;
  852. struct snd_pcm_substream *substream;
  853. int idx, cidx;
  854. down(&register_mutex);
  855. idx = (pcm->card->number * SNDRV_PCM_DEVICES) + pcm->device;
  856. snd_pcm_devices[idx] = NULL;
  857. for (cidx = 0; cidx < 2; cidx++)
  858. for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
  859. if (substream->runtime)
  860. substream->runtime->status->state = SNDRV_PCM_STATE_DISCONNECTED;
  861. list_for_each(list, &snd_pcm_notify_list) {
  862. struct snd_pcm_notify *notify;
  863. notify = list_entry(list, struct snd_pcm_notify, list);
  864. notify->n_disconnect(pcm);
  865. }
  866. up(&register_mutex);
  867. return 0;
  868. }
  869. static int snd_pcm_dev_unregister(struct snd_device *device)
  870. {
  871. int idx, cidx, devtype;
  872. struct snd_pcm_substream *substream;
  873. struct list_head *list;
  874. struct snd_pcm *pcm = device->device_data;
  875. snd_assert(pcm != NULL, return -ENXIO);
  876. down(&register_mutex);
  877. idx = (pcm->card->number * SNDRV_PCM_DEVICES) + pcm->device;
  878. snd_pcm_devices[idx] = NULL;
  879. for (cidx = 0; cidx < 2; cidx++) {
  880. devtype = -1;
  881. switch (cidx) {
  882. case SNDRV_PCM_STREAM_PLAYBACK:
  883. devtype = SNDRV_DEVICE_TYPE_PCM_PLAYBACK;
  884. break;
  885. case SNDRV_PCM_STREAM_CAPTURE:
  886. devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE;
  887. break;
  888. }
  889. snd_unregister_device(devtype, pcm->card, pcm->device);
  890. for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
  891. snd_pcm_timer_done(substream);
  892. }
  893. list_for_each(list, &snd_pcm_notify_list) {
  894. struct snd_pcm_notify *notify;
  895. notify = list_entry(list, struct snd_pcm_notify, list);
  896. notify->n_unregister(pcm);
  897. }
  898. up(&register_mutex);
  899. return snd_pcm_free(pcm);
  900. }
  901. int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
  902. {
  903. int idx;
  904. snd_assert(notify != NULL && notify->n_register != NULL && notify->n_unregister != NULL, return -EINVAL);
  905. down(&register_mutex);
  906. if (nfree) {
  907. list_del(&notify->list);
  908. for (idx = 0; idx < SNDRV_CARDS * SNDRV_PCM_DEVICES; idx++) {
  909. if (snd_pcm_devices[idx] == NULL)
  910. continue;
  911. notify->n_unregister(snd_pcm_devices[idx]);
  912. }
  913. } else {
  914. list_add_tail(&notify->list, &snd_pcm_notify_list);
  915. for (idx = 0; idx < SNDRV_CARDS * SNDRV_PCM_DEVICES; idx++) {
  916. if (snd_pcm_devices[idx] == NULL)
  917. continue;
  918. notify->n_register(snd_pcm_devices[idx]);
  919. }
  920. }
  921. up(&register_mutex);
  922. return 0;
  923. }
  924. /*
  925. * Info interface
  926. */
  927. static void snd_pcm_proc_read(struct snd_info_entry *entry,
  928. struct snd_info_buffer *buffer)
  929. {
  930. int idx;
  931. struct snd_pcm *pcm;
  932. down(&register_mutex);
  933. for (idx = 0; idx < SNDRV_CARDS * SNDRV_PCM_DEVICES; idx++) {
  934. pcm = snd_pcm_devices[idx];
  935. if (pcm == NULL)
  936. continue;
  937. snd_iprintf(buffer, "%02i-%02i: %s : %s", idx / SNDRV_PCM_DEVICES,
  938. idx % SNDRV_PCM_DEVICES, pcm->id, pcm->name);
  939. if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream)
  940. snd_iprintf(buffer, " : playback %i",
  941. pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream_count);
  942. if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream)
  943. snd_iprintf(buffer, " : capture %i",
  944. pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream_count);
  945. snd_iprintf(buffer, "\n");
  946. }
  947. up(&register_mutex);
  948. }
  949. /*
  950. * ENTRY functions
  951. */
  952. static struct snd_info_entry *snd_pcm_proc_entry = NULL;
  953. static int __init alsa_pcm_init(void)
  954. {
  955. struct snd_info_entry *entry;
  956. snd_ctl_register_ioctl(snd_pcm_control_ioctl);
  957. snd_ctl_register_ioctl_compat(snd_pcm_control_ioctl);
  958. if ((entry = snd_info_create_module_entry(THIS_MODULE, "pcm", NULL)) != NULL) {
  959. snd_info_set_text_ops(entry, NULL, SNDRV_CARDS * SNDRV_PCM_DEVICES * 128,
  960. snd_pcm_proc_read);
  961. if (snd_info_register(entry) < 0) {
  962. snd_info_free_entry(entry);
  963. entry = NULL;
  964. }
  965. }
  966. snd_pcm_proc_entry = entry;
  967. return 0;
  968. }
  969. static void __exit alsa_pcm_exit(void)
  970. {
  971. snd_ctl_unregister_ioctl(snd_pcm_control_ioctl);
  972. snd_ctl_unregister_ioctl_compat(snd_pcm_control_ioctl);
  973. if (snd_pcm_proc_entry) {
  974. snd_info_unregister(snd_pcm_proc_entry);
  975. snd_pcm_proc_entry = NULL;
  976. }
  977. }
  978. module_init(alsa_pcm_init)
  979. module_exit(alsa_pcm_exit)
  980. EXPORT_SYMBOL(snd_pcm_devices);
  981. EXPORT_SYMBOL(snd_pcm_new);
  982. EXPORT_SYMBOL(snd_pcm_new_stream);
  983. EXPORT_SYMBOL(snd_pcm_notify);
  984. EXPORT_SYMBOL(snd_pcm_open_substream);
  985. EXPORT_SYMBOL(snd_pcm_release_substream);
  986. EXPORT_SYMBOL(snd_pcm_format_name);
  987. /* pcm_native.c */
  988. EXPORT_SYMBOL(snd_pcm_link_rwlock);
  989. #ifdef CONFIG_PM
  990. EXPORT_SYMBOL(snd_pcm_suspend);
  991. EXPORT_SYMBOL(snd_pcm_suspend_all);
  992. #endif
  993. EXPORT_SYMBOL(snd_pcm_kernel_playback_ioctl);
  994. EXPORT_SYMBOL(snd_pcm_kernel_capture_ioctl);
  995. EXPORT_SYMBOL(snd_pcm_kernel_ioctl);
  996. EXPORT_SYMBOL(snd_pcm_mmap_data);
  997. #if SNDRV_PCM_INFO_MMAP_IOMEM
  998. EXPORT_SYMBOL(snd_pcm_lib_mmap_iomem);
  999. #endif
  1000. /* pcm_misc.c */
  1001. EXPORT_SYMBOL(snd_pcm_format_signed);
  1002. EXPORT_SYMBOL(snd_pcm_format_unsigned);
  1003. EXPORT_SYMBOL(snd_pcm_format_linear);
  1004. EXPORT_SYMBOL(snd_pcm_format_little_endian);
  1005. EXPORT_SYMBOL(snd_pcm_format_big_endian);
  1006. EXPORT_SYMBOL(snd_pcm_format_width);
  1007. EXPORT_SYMBOL(snd_pcm_format_physical_width);
  1008. EXPORT_SYMBOL(snd_pcm_format_size);
  1009. EXPORT_SYMBOL(snd_pcm_format_silence_64);
  1010. EXPORT_SYMBOL(snd_pcm_format_set_silence);
  1011. EXPORT_SYMBOL(snd_pcm_build_linear_format);
  1012. EXPORT_SYMBOL(snd_pcm_limit_hw_rates);