pcm.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  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->private_data = pstr;
  419. if (snd_info_register(entry) < 0) {
  420. snd_info_free_entry(entry);
  421. entry = NULL;
  422. }
  423. }
  424. pstr->proc_xrun_debug_entry = entry;
  425. #endif
  426. return 0;
  427. }
  428. static int snd_pcm_stream_proc_done(snd_pcm_str_t *pstr)
  429. {
  430. #ifdef CONFIG_SND_DEBUG
  431. if (pstr->proc_xrun_debug_entry) {
  432. snd_info_unregister(pstr->proc_xrun_debug_entry);
  433. pstr->proc_xrun_debug_entry = NULL;
  434. }
  435. #endif
  436. if (pstr->proc_info_entry) {
  437. snd_info_unregister(pstr->proc_info_entry);
  438. pstr->proc_info_entry = NULL;
  439. }
  440. if (pstr->proc_root) {
  441. snd_info_unregister(pstr->proc_root);
  442. pstr->proc_root = NULL;
  443. }
  444. return 0;
  445. }
  446. static int snd_pcm_substream_proc_init(snd_pcm_substream_t *substream)
  447. {
  448. snd_info_entry_t *entry;
  449. snd_card_t *card;
  450. char name[16];
  451. card = substream->pcm->card;
  452. sprintf(name, "sub%i", substream->number);
  453. if ((entry = snd_info_create_card_entry(card, name, substream->pstr->proc_root)) == NULL)
  454. return -ENOMEM;
  455. entry->mode = S_IFDIR | S_IRUGO | S_IXUGO;
  456. if (snd_info_register(entry) < 0) {
  457. snd_info_free_entry(entry);
  458. return -ENOMEM;
  459. }
  460. substream->proc_root = entry;
  461. if ((entry = snd_info_create_card_entry(card, "info", substream->proc_root)) != NULL) {
  462. snd_info_set_text_ops(entry, substream, 256, snd_pcm_substream_proc_info_read);
  463. if (snd_info_register(entry) < 0) {
  464. snd_info_free_entry(entry);
  465. entry = NULL;
  466. }
  467. }
  468. substream->proc_info_entry = entry;
  469. if ((entry = snd_info_create_card_entry(card, "hw_params", substream->proc_root)) != NULL) {
  470. snd_info_set_text_ops(entry, substream, 256, snd_pcm_substream_proc_hw_params_read);
  471. if (snd_info_register(entry) < 0) {
  472. snd_info_free_entry(entry);
  473. entry = NULL;
  474. }
  475. }
  476. substream->proc_hw_params_entry = entry;
  477. if ((entry = snd_info_create_card_entry(card, "sw_params", substream->proc_root)) != NULL) {
  478. snd_info_set_text_ops(entry, substream, 256, snd_pcm_substream_proc_sw_params_read);
  479. if (snd_info_register(entry) < 0) {
  480. snd_info_free_entry(entry);
  481. entry = NULL;
  482. }
  483. }
  484. substream->proc_sw_params_entry = entry;
  485. if ((entry = snd_info_create_card_entry(card, "status", substream->proc_root)) != NULL) {
  486. snd_info_set_text_ops(entry, substream, 256, snd_pcm_substream_proc_status_read);
  487. if (snd_info_register(entry) < 0) {
  488. snd_info_free_entry(entry);
  489. entry = NULL;
  490. }
  491. }
  492. substream->proc_status_entry = entry;
  493. return 0;
  494. }
  495. static int snd_pcm_substream_proc_done(snd_pcm_substream_t *substream)
  496. {
  497. if (substream->proc_info_entry) {
  498. snd_info_unregister(substream->proc_info_entry);
  499. substream->proc_info_entry = NULL;
  500. }
  501. if (substream->proc_hw_params_entry) {
  502. snd_info_unregister(substream->proc_hw_params_entry);
  503. substream->proc_hw_params_entry = NULL;
  504. }
  505. if (substream->proc_sw_params_entry) {
  506. snd_info_unregister(substream->proc_sw_params_entry);
  507. substream->proc_sw_params_entry = NULL;
  508. }
  509. if (substream->proc_status_entry) {
  510. snd_info_unregister(substream->proc_status_entry);
  511. substream->proc_status_entry = NULL;
  512. }
  513. if (substream->proc_root) {
  514. snd_info_unregister(substream->proc_root);
  515. substream->proc_root = NULL;
  516. }
  517. return 0;
  518. }
  519. /**
  520. * snd_pcm_new_stream - create a new PCM stream
  521. * @pcm: the pcm instance
  522. * @stream: the stream direction, SNDRV_PCM_STREAM_XXX
  523. * @substream_count: the number of substreams
  524. *
  525. * Creates a new stream for the pcm.
  526. * The corresponding stream on the pcm must have been empty before
  527. * calling this, i.e. zero must be given to the argument of
  528. * snd_pcm_new().
  529. *
  530. * Returns zero if successful, or a negative error code on failure.
  531. */
  532. int snd_pcm_new_stream(snd_pcm_t *pcm, int stream, int substream_count)
  533. {
  534. int idx, err;
  535. snd_pcm_str_t *pstr = &pcm->streams[stream];
  536. snd_pcm_substream_t *substream, *prev;
  537. #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
  538. init_MUTEX(&pstr->oss.setup_mutex);
  539. #endif
  540. pstr->stream = stream;
  541. pstr->pcm = pcm;
  542. pstr->substream_count = substream_count;
  543. pstr->reg = &snd_pcm_reg[stream];
  544. if (substream_count > 0) {
  545. err = snd_pcm_stream_proc_init(pstr);
  546. if (err < 0)
  547. return err;
  548. }
  549. prev = NULL;
  550. for (idx = 0, prev = NULL; idx < substream_count; idx++) {
  551. substream = kcalloc(1, sizeof(*substream), GFP_KERNEL);
  552. if (substream == NULL)
  553. return -ENOMEM;
  554. substream->pcm = pcm;
  555. substream->pstr = pstr;
  556. substream->number = idx;
  557. substream->stream = stream;
  558. sprintf(substream->name, "subdevice #%i", idx);
  559. substream->buffer_bytes_max = UINT_MAX;
  560. if (prev == NULL)
  561. pstr->substream = substream;
  562. else
  563. prev->next = substream;
  564. err = snd_pcm_substream_proc_init(substream);
  565. if (err < 0) {
  566. kfree(substream);
  567. return err;
  568. }
  569. substream->group = &substream->self_group;
  570. spin_lock_init(&substream->self_group.lock);
  571. INIT_LIST_HEAD(&substream->self_group.substreams);
  572. list_add_tail(&substream->link_list, &substream->self_group.substreams);
  573. spin_lock_init(&substream->timer_lock);
  574. prev = substream;
  575. }
  576. return 0;
  577. }
  578. /**
  579. * snd_pcm_new - create a new PCM instance
  580. * @card: the card instance
  581. * @id: the id string
  582. * @device: the device index (zero based)
  583. * @playback_count: the number of substreams for playback
  584. * @capture_count: the number of substreams for capture
  585. * @rpcm: the pointer to store the new pcm instance
  586. *
  587. * Creates a new PCM instance.
  588. *
  589. * The pcm operators have to be set afterwards to the new instance
  590. * via snd_pcm_set_ops().
  591. *
  592. * Returns zero if successful, or a negative error code on failure.
  593. */
  594. int snd_pcm_new(snd_card_t * card, char *id, int device,
  595. int playback_count, int capture_count,
  596. snd_pcm_t ** rpcm)
  597. {
  598. snd_pcm_t *pcm;
  599. int err;
  600. static snd_device_ops_t ops = {
  601. .dev_free = snd_pcm_dev_free,
  602. .dev_register = snd_pcm_dev_register,
  603. .dev_disconnect = snd_pcm_dev_disconnect,
  604. .dev_unregister = snd_pcm_dev_unregister
  605. };
  606. snd_assert(rpcm != NULL, return -EINVAL);
  607. *rpcm = NULL;
  608. snd_assert(card != NULL, return -ENXIO);
  609. pcm = kcalloc(1, sizeof(*pcm), GFP_KERNEL);
  610. if (pcm == NULL)
  611. return -ENOMEM;
  612. pcm->card = card;
  613. pcm->device = device;
  614. if (id) {
  615. strlcpy(pcm->id, id, sizeof(pcm->id));
  616. }
  617. if ((err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK, playback_count)) < 0) {
  618. snd_pcm_free(pcm);
  619. return err;
  620. }
  621. if ((err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_CAPTURE, capture_count)) < 0) {
  622. snd_pcm_free(pcm);
  623. return err;
  624. }
  625. init_MUTEX(&pcm->open_mutex);
  626. init_waitqueue_head(&pcm->open_wait);
  627. if ((err = snd_device_new(card, SNDRV_DEV_PCM, pcm, &ops)) < 0) {
  628. snd_pcm_free(pcm);
  629. return err;
  630. }
  631. *rpcm = pcm;
  632. return 0;
  633. }
  634. static void snd_pcm_free_stream(snd_pcm_str_t * pstr)
  635. {
  636. snd_pcm_substream_t *substream, *substream_next;
  637. #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
  638. snd_pcm_oss_setup_t *setup, *setupn;
  639. #endif
  640. substream = pstr->substream;
  641. while (substream) {
  642. substream_next = substream->next;
  643. snd_pcm_substream_proc_done(substream);
  644. kfree(substream);
  645. substream = substream_next;
  646. }
  647. snd_pcm_stream_proc_done(pstr);
  648. #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
  649. for (setup = pstr->oss.setup_list; setup; setup = setupn) {
  650. setupn = setup->next;
  651. kfree(setup->task_name);
  652. kfree(setup);
  653. }
  654. #endif
  655. }
  656. static int snd_pcm_free(snd_pcm_t *pcm)
  657. {
  658. snd_assert(pcm != NULL, return -ENXIO);
  659. if (pcm->private_free)
  660. pcm->private_free(pcm);
  661. snd_pcm_lib_preallocate_free_for_all(pcm);
  662. snd_pcm_free_stream(&pcm->streams[SNDRV_PCM_STREAM_PLAYBACK]);
  663. snd_pcm_free_stream(&pcm->streams[SNDRV_PCM_STREAM_CAPTURE]);
  664. kfree(pcm);
  665. return 0;
  666. }
  667. static int snd_pcm_dev_free(snd_device_t *device)
  668. {
  669. snd_pcm_t *pcm = device->device_data;
  670. return snd_pcm_free(pcm);
  671. }
  672. static void snd_pcm_tick_timer_func(unsigned long data)
  673. {
  674. snd_pcm_substream_t *substream = (snd_pcm_substream_t*) data;
  675. snd_pcm_tick_elapsed(substream);
  676. }
  677. int snd_pcm_open_substream(snd_pcm_t *pcm, int stream,
  678. snd_pcm_substream_t **rsubstream)
  679. {
  680. snd_pcm_str_t * pstr;
  681. snd_pcm_substream_t * substream;
  682. snd_pcm_runtime_t * runtime;
  683. snd_ctl_file_t *kctl;
  684. snd_card_t *card;
  685. struct list_head *list;
  686. int prefer_subdevice = -1;
  687. size_t size;
  688. snd_assert(rsubstream != NULL, return -EINVAL);
  689. *rsubstream = NULL;
  690. snd_assert(pcm != NULL, return -ENXIO);
  691. pstr = &pcm->streams[stream];
  692. if (pstr->substream == NULL)
  693. return -ENODEV;
  694. card = pcm->card;
  695. down_read(&card->controls_rwsem);
  696. list_for_each(list, &card->ctl_files) {
  697. kctl = snd_ctl_file(list);
  698. if (kctl->pid == current->pid) {
  699. prefer_subdevice = kctl->prefer_pcm_subdevice;
  700. break;
  701. }
  702. }
  703. up_read(&card->controls_rwsem);
  704. if (pstr->substream_count == 0)
  705. return -ENODEV;
  706. switch (stream) {
  707. case SNDRV_PCM_STREAM_PLAYBACK:
  708. if (pcm->info_flags & SNDRV_PCM_INFO_HALF_DUPLEX) {
  709. for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next) {
  710. if (SUBSTREAM_BUSY(substream))
  711. return -EAGAIN;
  712. }
  713. }
  714. break;
  715. case SNDRV_PCM_STREAM_CAPTURE:
  716. if (pcm->info_flags & SNDRV_PCM_INFO_HALF_DUPLEX) {
  717. for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) {
  718. if (SUBSTREAM_BUSY(substream))
  719. return -EAGAIN;
  720. }
  721. }
  722. break;
  723. default:
  724. return -EINVAL;
  725. }
  726. if (prefer_subdevice >= 0) {
  727. for (substream = pstr->substream; substream; substream = substream->next)
  728. if (!SUBSTREAM_BUSY(substream) && substream->number == prefer_subdevice)
  729. goto __ok;
  730. }
  731. for (substream = pstr->substream; substream; substream = substream->next)
  732. if (!SUBSTREAM_BUSY(substream))
  733. break;
  734. __ok:
  735. if (substream == NULL)
  736. return -EAGAIN;
  737. runtime = kcalloc(1, sizeof(*runtime), GFP_KERNEL);
  738. if (runtime == NULL)
  739. return -ENOMEM;
  740. size = PAGE_ALIGN(sizeof(snd_pcm_mmap_status_t));
  741. runtime->status = snd_malloc_pages(size, GFP_KERNEL);
  742. if (runtime->status == NULL) {
  743. kfree(runtime);
  744. return -ENOMEM;
  745. }
  746. memset((void*)runtime->status, 0, size);
  747. size = PAGE_ALIGN(sizeof(snd_pcm_mmap_control_t));
  748. runtime->control = snd_malloc_pages(size, GFP_KERNEL);
  749. if (runtime->control == NULL) {
  750. snd_free_pages((void*)runtime->status, PAGE_ALIGN(sizeof(snd_pcm_mmap_status_t)));
  751. kfree(runtime);
  752. return -ENOMEM;
  753. }
  754. memset((void*)runtime->control, 0, size);
  755. init_waitqueue_head(&runtime->sleep);
  756. atomic_set(&runtime->mmap_count, 0);
  757. init_timer(&runtime->tick_timer);
  758. runtime->tick_timer.function = snd_pcm_tick_timer_func;
  759. runtime->tick_timer.data = (unsigned long) substream;
  760. runtime->status->state = SNDRV_PCM_STATE_OPEN;
  761. substream->runtime = runtime;
  762. substream->private_data = pcm->private_data;
  763. pstr->substream_opened++;
  764. *rsubstream = substream;
  765. return 0;
  766. }
  767. void snd_pcm_release_substream(snd_pcm_substream_t *substream)
  768. {
  769. snd_pcm_runtime_t * runtime;
  770. substream->file = NULL;
  771. runtime = substream->runtime;
  772. snd_assert(runtime != NULL, return);
  773. if (runtime->private_free != NULL)
  774. runtime->private_free(runtime);
  775. snd_free_pages((void*)runtime->status, PAGE_ALIGN(sizeof(snd_pcm_mmap_status_t)));
  776. snd_free_pages((void*)runtime->control, PAGE_ALIGN(sizeof(snd_pcm_mmap_control_t)));
  777. kfree(runtime->hw_constraints.rules);
  778. kfree(runtime);
  779. substream->runtime = NULL;
  780. substream->pstr->substream_opened--;
  781. }
  782. static int snd_pcm_dev_register(snd_device_t *device)
  783. {
  784. int idx, cidx, err;
  785. unsigned short minor;
  786. snd_pcm_substream_t *substream;
  787. struct list_head *list;
  788. char str[16];
  789. snd_pcm_t *pcm = device->device_data;
  790. snd_assert(pcm != NULL && device != NULL, return -ENXIO);
  791. down(&register_mutex);
  792. idx = (pcm->card->number * SNDRV_PCM_DEVICES) + pcm->device;
  793. if (snd_pcm_devices[idx]) {
  794. up(&register_mutex);
  795. return -EBUSY;
  796. }
  797. snd_pcm_devices[idx] = pcm;
  798. for (cidx = 0; cidx < 2; cidx++) {
  799. int devtype = -1;
  800. if (pcm->streams[cidx].substream == NULL)
  801. continue;
  802. switch (cidx) {
  803. case SNDRV_PCM_STREAM_PLAYBACK:
  804. sprintf(str, "pcmC%iD%ip", pcm->card->number, pcm->device);
  805. minor = SNDRV_MINOR_PCM_PLAYBACK + idx;
  806. devtype = SNDRV_DEVICE_TYPE_PCM_PLAYBACK;
  807. break;
  808. case SNDRV_PCM_STREAM_CAPTURE:
  809. sprintf(str, "pcmC%iD%ic", pcm->card->number, pcm->device);
  810. minor = SNDRV_MINOR_PCM_CAPTURE + idx;
  811. devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE;
  812. break;
  813. }
  814. if ((err = snd_register_device(devtype, pcm->card, pcm->device, pcm->streams[cidx].reg, str)) < 0) {
  815. snd_pcm_devices[idx] = NULL;
  816. up(&register_mutex);
  817. return err;
  818. }
  819. for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
  820. snd_pcm_timer_init(substream);
  821. }
  822. list_for_each(list, &snd_pcm_notify_list) {
  823. snd_pcm_notify_t *notify;
  824. notify = list_entry(list, snd_pcm_notify_t, list);
  825. notify->n_register(pcm);
  826. }
  827. up(&register_mutex);
  828. return 0;
  829. }
  830. static int snd_pcm_dev_disconnect(snd_device_t *device)
  831. {
  832. snd_pcm_t *pcm = device->device_data;
  833. struct list_head *list;
  834. snd_pcm_substream_t *substream;
  835. int idx, cidx;
  836. down(&register_mutex);
  837. idx = (pcm->card->number * SNDRV_PCM_DEVICES) + pcm->device;
  838. snd_pcm_devices[idx] = NULL;
  839. for (cidx = 0; cidx < 2; cidx++)
  840. for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
  841. if (substream->runtime)
  842. substream->runtime->status->state = SNDRV_PCM_STATE_DISCONNECTED;
  843. list_for_each(list, &snd_pcm_notify_list) {
  844. snd_pcm_notify_t *notify;
  845. notify = list_entry(list, snd_pcm_notify_t, list);
  846. notify->n_disconnect(pcm);
  847. }
  848. up(&register_mutex);
  849. return 0;
  850. }
  851. static int snd_pcm_dev_unregister(snd_device_t *device)
  852. {
  853. int idx, cidx, devtype;
  854. snd_pcm_substream_t *substream;
  855. struct list_head *list;
  856. snd_pcm_t *pcm = device->device_data;
  857. snd_assert(pcm != NULL, return -ENXIO);
  858. down(&register_mutex);
  859. idx = (pcm->card->number * SNDRV_PCM_DEVICES) + pcm->device;
  860. snd_pcm_devices[idx] = NULL;
  861. for (cidx = 0; cidx < 2; cidx++) {
  862. devtype = -1;
  863. switch (cidx) {
  864. case SNDRV_PCM_STREAM_PLAYBACK:
  865. devtype = SNDRV_DEVICE_TYPE_PCM_PLAYBACK;
  866. break;
  867. case SNDRV_PCM_STREAM_CAPTURE:
  868. devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE;
  869. break;
  870. }
  871. snd_unregister_device(devtype, pcm->card, pcm->device);
  872. for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
  873. snd_pcm_timer_done(substream);
  874. }
  875. list_for_each(list, &snd_pcm_notify_list) {
  876. snd_pcm_notify_t *notify;
  877. notify = list_entry(list, snd_pcm_notify_t, list);
  878. notify->n_unregister(pcm);
  879. }
  880. up(&register_mutex);
  881. return snd_pcm_free(pcm);
  882. }
  883. int snd_pcm_notify(snd_pcm_notify_t *notify, int nfree)
  884. {
  885. int idx;
  886. snd_assert(notify != NULL && notify->n_register != NULL && notify->n_unregister != NULL, return -EINVAL);
  887. down(&register_mutex);
  888. if (nfree) {
  889. list_del(&notify->list);
  890. for (idx = 0; idx < SNDRV_CARDS * SNDRV_PCM_DEVICES; idx++) {
  891. if (snd_pcm_devices[idx] == NULL)
  892. continue;
  893. notify->n_unregister(snd_pcm_devices[idx]);
  894. }
  895. } else {
  896. list_add_tail(&notify->list, &snd_pcm_notify_list);
  897. for (idx = 0; idx < SNDRV_CARDS * SNDRV_PCM_DEVICES; idx++) {
  898. if (snd_pcm_devices[idx] == NULL)
  899. continue;
  900. notify->n_register(snd_pcm_devices[idx]);
  901. }
  902. }
  903. up(&register_mutex);
  904. return 0;
  905. }
  906. /*
  907. * Info interface
  908. */
  909. static void snd_pcm_proc_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer)
  910. {
  911. int idx;
  912. snd_pcm_t *pcm;
  913. down(&register_mutex);
  914. for (idx = 0; idx < SNDRV_CARDS * SNDRV_PCM_DEVICES; idx++) {
  915. pcm = snd_pcm_devices[idx];
  916. if (pcm == NULL)
  917. continue;
  918. snd_iprintf(buffer, "%02i-%02i: %s : %s", idx / SNDRV_PCM_DEVICES,
  919. idx % SNDRV_PCM_DEVICES, pcm->id, pcm->name);
  920. if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream)
  921. snd_iprintf(buffer, " : playback %i", pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream_count);
  922. if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream)
  923. snd_iprintf(buffer, " : capture %i", pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream_count);
  924. snd_iprintf(buffer, "\n");
  925. }
  926. up(&register_mutex);
  927. }
  928. /*
  929. * ENTRY functions
  930. */
  931. static snd_info_entry_t *snd_pcm_proc_entry = NULL;
  932. static int __init alsa_pcm_init(void)
  933. {
  934. snd_info_entry_t *entry;
  935. snd_ctl_register_ioctl(snd_pcm_control_ioctl);
  936. snd_ctl_register_ioctl_compat(snd_pcm_control_ioctl);
  937. if ((entry = snd_info_create_module_entry(THIS_MODULE, "pcm", NULL)) != NULL) {
  938. snd_info_set_text_ops(entry, NULL, SNDRV_CARDS * SNDRV_PCM_DEVICES * 128, snd_pcm_proc_read);
  939. if (snd_info_register(entry) < 0) {
  940. snd_info_free_entry(entry);
  941. entry = NULL;
  942. }
  943. }
  944. snd_pcm_proc_entry = entry;
  945. return 0;
  946. }
  947. static void __exit alsa_pcm_exit(void)
  948. {
  949. snd_ctl_unregister_ioctl(snd_pcm_control_ioctl);
  950. snd_ctl_unregister_ioctl_compat(snd_pcm_control_ioctl);
  951. if (snd_pcm_proc_entry) {
  952. snd_info_unregister(snd_pcm_proc_entry);
  953. snd_pcm_proc_entry = NULL;
  954. }
  955. }
  956. module_init(alsa_pcm_init)
  957. module_exit(alsa_pcm_exit)
  958. EXPORT_SYMBOL(snd_pcm_devices);
  959. EXPORT_SYMBOL(snd_pcm_new);
  960. EXPORT_SYMBOL(snd_pcm_new_stream);
  961. EXPORT_SYMBOL(snd_pcm_notify);
  962. EXPORT_SYMBOL(snd_pcm_open_substream);
  963. EXPORT_SYMBOL(snd_pcm_release_substream);
  964. EXPORT_SYMBOL(snd_pcm_format_name);
  965. /* pcm_native.c */
  966. EXPORT_SYMBOL(snd_pcm_link_rwlock);
  967. EXPORT_SYMBOL(snd_pcm_start);
  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_silence_64);
  988. EXPORT_SYMBOL(snd_pcm_format_set_silence);
  989. EXPORT_SYMBOL(snd_pcm_build_linear_format);
  990. EXPORT_SYMBOL(snd_pcm_limit_hw_rates);