pcm.c 32 KB

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