pcm.c 32 KB

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