Lines Matching full:pcm
3 * Digital Audio (PCM) abstract layer
16 #include <sound/pcm.h>
24 MODULE_DESCRIPTION("Midlevel PCM code for ALSA.");
33 static int snd_pcm_free(struct snd_pcm *pcm);
40 struct snd_pcm *pcm; in snd_pcm_get() local
42 list_for_each_entry(pcm, &snd_pcm_devices, list) { in snd_pcm_get()
43 if (pcm->card == card && pcm->device == device) in snd_pcm_get()
44 return pcm; in snd_pcm_get()
51 struct snd_pcm *pcm; in snd_pcm_next() local
53 list_for_each_entry(pcm, &snd_pcm_devices, list) { in snd_pcm_next()
54 if (pcm->card == card && pcm->device > device) in snd_pcm_next()
55 return pcm->device; in snd_pcm_next()
56 else if (pcm->card->number > card->number) in snd_pcm_next()
64 struct snd_pcm *pcm; in snd_pcm_add() local
69 list_for_each_entry(pcm, &snd_pcm_devices, list) { in snd_pcm_add()
70 if (pcm->card == newpcm->card && pcm->device == newpcm->device) in snd_pcm_add()
72 if (pcm->card->number > newpcm->card->number || in snd_pcm_add()
73 (pcm->card == newpcm->card && in snd_pcm_add()
74 pcm->device > newpcm->device)) { in snd_pcm_add()
75 list_add(&newpcm->list, pcm->list.prev); in snd_pcm_add()
105 struct snd_pcm *pcm; in snd_pcm_control_ioctl() local
120 pcm = snd_pcm_get(card, device); in snd_pcm_control_ioctl()
121 if (pcm == NULL) in snd_pcm_control_ioctl()
123 pstr = &pcm->streams[stream]; in snd_pcm_control_ioctl()
134 guard(mutex)(&pcm->open_mutex); in snd_pcm_control_ioctl()
207 * snd_pcm_format_name - Return a name string for the given PCM format
208 * @format: PCM format
378 guard(mutex)(&substream->pcm->open_mutex); in snd_pcm_substream_proc_hw_params_read()
413 guard(mutex)(&substream->pcm->open_mutex); in snd_pcm_substream_proc_sw_params_read()
441 guard(mutex)(&substream->pcm->open_mutex); in snd_pcm_substream_proc_status_read()
498 struct snd_pcm *pcm = pstr->pcm; in snd_pcm_stream_proc_init() local
502 sprintf(name, "pcm%i%c", pcm->device, in snd_pcm_stream_proc_init()
504 entry = snd_info_create_card_entry(pcm->card, name, in snd_pcm_stream_proc_init()
505 pcm->card->proc_root); in snd_pcm_stream_proc_init()
510 entry = snd_info_create_card_entry(pcm->card, "info", pstr->proc_root); in snd_pcm_stream_proc_init()
514 entry = snd_info_create_card_entry(pcm->card, "xrun_debug", in snd_pcm_stream_proc_init()
540 entry = snd_info_create_card_entry(substream->pcm->card, name, in create_substream_info_entry()
553 card = substream->pcm->card; in snd_pcm_substream_proc_init()
599 if (!pstr->pcm->no_device_suspend) in do_pcm_suspend()
600 snd_pcm_suspend_all(pstr->pcm); in do_pcm_suspend()
608 /* device type for PCM -- basically only for passing PM callbacks */
610 .name = "pcm",
615 * snd_pcm_new_stream - create a new PCM stream
616 * @pcm: the pcm instance
620 * Creates a new stream for the pcm.
621 * The corresponding stream on the pcm must have been empty before
627 int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count) in snd_pcm_new_stream() argument
630 struct snd_pcm_str *pstr = &pcm->streams[stream]; in snd_pcm_new_stream()
637 pstr->pcm = pcm; in snd_pcm_new_stream()
642 err = snd_device_alloc(&pstr->dev, pcm->card); in snd_pcm_new_stream()
645 dev_set_name(pstr->dev, "pcmC%iD%i%c", pcm->card->number, pcm->device, in snd_pcm_new_stream()
651 if (!pcm->internal) { in snd_pcm_new_stream()
654 pcm_err(pcm, "Error in snd_pcm_stream_proc_init\n"); in snd_pcm_new_stream()
663 substream->pcm = pcm; in snd_pcm_new_stream()
674 if (!pcm->internal) { in snd_pcm_new_stream()
677 pcm_err(pcm, in snd_pcm_new_stream()
701 struct snd_pcm *pcm; in _snd_pcm_new() local
716 pcm = kzalloc(sizeof(*pcm), GFP_KERNEL); in _snd_pcm_new()
717 if (!pcm) in _snd_pcm_new()
719 pcm->card = card; in _snd_pcm_new()
720 pcm->device = device; in _snd_pcm_new()
721 pcm->internal = internal; in _snd_pcm_new()
722 mutex_init(&pcm->open_mutex); in _snd_pcm_new()
723 init_waitqueue_head(&pcm->open_wait); in _snd_pcm_new()
724 INIT_LIST_HEAD(&pcm->list); in _snd_pcm_new()
726 strscpy(pcm->id, id, sizeof(pcm->id)); in _snd_pcm_new()
728 err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK, in _snd_pcm_new()
733 err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_CAPTURE, capture_count); in _snd_pcm_new()
737 err = snd_device_new(card, SNDRV_DEV_PCM, pcm, in _snd_pcm_new()
743 *rpcm = pcm; in _snd_pcm_new()
747 snd_pcm_free(pcm); in _snd_pcm_new()
752 * snd_pcm_new - create a new PCM instance
758 * @rpcm: the pointer to store the new pcm instance
760 * Creates a new PCM instance.
762 * The pcm operators have to be set afterwards to the new instance
776 * snd_pcm_new_internal - create a new internal PCM instance
782 * @rpcm: the pointer to store the new pcm instance
784 * Creates a new internal PCM instance with no userspace device or procfs
785 * entries. This is used by ASoC Back End PCMs in order to create a PCM that
790 * The pcm operators have to be set afterwards to the new instance
807 struct snd_card *card = pstr->pcm->card; in free_chmap()
844 #define pcm_call_notify(pcm, call) \ argument
848 _notify->call(pcm); \
851 #define pcm_call_notify(pcm, call) do {} while (0) argument
854 static int snd_pcm_free(struct snd_pcm *pcm) in snd_pcm_free() argument
856 if (!pcm) in snd_pcm_free()
858 if (!pcm->internal) in snd_pcm_free()
859 pcm_call_notify(pcm, n_unregister); in snd_pcm_free()
860 if (pcm->private_free) in snd_pcm_free()
861 pcm->private_free(pcm); in snd_pcm_free()
862 snd_pcm_lib_preallocate_free_for_all(pcm); in snd_pcm_free()
863 snd_pcm_free_stream(&pcm->streams[SNDRV_PCM_STREAM_PLAYBACK]); in snd_pcm_free()
864 snd_pcm_free_stream(&pcm->streams[SNDRV_PCM_STREAM_CAPTURE]); in snd_pcm_free()
865 kfree(pcm); in snd_pcm_free()
871 struct snd_pcm *pcm = device->device_data; in snd_pcm_dev_free() local
872 return snd_pcm_free(pcm); in snd_pcm_dev_free()
875 int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream, in snd_pcm_attach_substream() argument
886 if (snd_BUG_ON(!pcm || !rsubstream)) in snd_pcm_attach_substream()
892 pstr = &pcm->streams[stream]; in snd_pcm_attach_substream()
896 card = pcm->card; in snd_pcm_attach_substream()
899 if (pcm->info_flags & SNDRV_PCM_INFO_HALF_DUPLEX) { in snd_pcm_attach_substream()
902 for (substream = pcm->streams[opposite].substream; substream; in snd_pcm_attach_substream()
968 substream->private_data = pcm->private_data; in snd_pcm_attach_substream()
994 /* Avoid concurrent access to runtime via PCM timer interface */ in snd_pcm_detach_substream()
1013 struct snd_pcm *pcm = pstr->pcm; in pcm_class_show() local
1022 if (pcm->dev_class > SNDRV_PCM_CLASS_LAST) in pcm_class_show()
1025 str = strs[pcm->dev_class]; in pcm_class_show()
1048 struct snd_pcm *pcm; in snd_pcm_dev_register() local
1052 pcm = device->device_data; in snd_pcm_dev_register()
1055 err = snd_pcm_add(pcm); in snd_pcm_dev_register()
1060 if (pcm->streams[cidx].substream == NULL) in snd_pcm_dev_register()
1070 /* register pcm */ in snd_pcm_dev_register()
1071 err = snd_register_device(devtype, pcm->card, pcm->device, in snd_pcm_dev_register()
1072 &snd_pcm_f_ops[cidx], pcm, in snd_pcm_dev_register()
1073 pcm->streams[cidx].dev); in snd_pcm_dev_register()
1075 list_del_init(&pcm->list); in snd_pcm_dev_register()
1079 for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) in snd_pcm_dev_register()
1083 pcm_call_notify(pcm, n_register); in snd_pcm_dev_register()
1089 struct snd_pcm *pcm = device->device_data; in snd_pcm_dev_disconnect() local
1094 guard(mutex)(&pcm->open_mutex); in snd_pcm_dev_disconnect()
1095 wake_up(&pcm->open_wait); in snd_pcm_dev_disconnect()
1096 list_del_init(&pcm->list); in snd_pcm_dev_disconnect()
1098 for_each_pcm_substream(pcm, cidx, substream) { in snd_pcm_dev_disconnect()
1112 for_each_pcm_substream(pcm, cidx, substream) in snd_pcm_dev_disconnect()
1115 pcm_call_notify(pcm, n_disconnect); in snd_pcm_dev_disconnect()
1117 if (pcm->streams[cidx].dev) in snd_pcm_dev_disconnect()
1118 snd_unregister_device(pcm->streams[cidx].dev); in snd_pcm_dev_disconnect()
1119 free_chmap(&pcm->streams[cidx]); in snd_pcm_dev_disconnect()
1127 * @notify: PCM notify list
1131 * called for each registered PCM devices. This exists only for PCM OSS
1138 struct snd_pcm *pcm; in snd_pcm_notify() local
1148 list_for_each_entry(pcm, &snd_pcm_devices, list) in snd_pcm_notify()
1149 notify->n_unregister(pcm); in snd_pcm_notify()
1152 list_for_each_entry(pcm, &snd_pcm_devices, list) in snd_pcm_notify()
1153 notify->n_register(pcm); in snd_pcm_notify()
1168 struct snd_pcm *pcm; in snd_pcm_proc_read() local
1171 list_for_each_entry(pcm, &snd_pcm_devices, list) { in snd_pcm_proc_read()
1173 pcm->card->number, pcm->device, pcm->id, pcm->name); in snd_pcm_proc_read()
1174 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) in snd_pcm_proc_read()
1176 pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream_count); in snd_pcm_proc_read()
1177 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) in snd_pcm_proc_read()
1179 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream_count); in snd_pcm_proc_read()
1190 entry = snd_info_create_module_entry(THIS_MODULE, "pcm", NULL); in snd_pcm_proc_init()