pcm.c 31 KB

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