Lines Matching refs:substream
63 static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream,
65 static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream,
97 void snd_pcm_stream_lock(struct snd_pcm_substream *substream) in snd_pcm_stream_lock() argument
99 if (substream->pcm->nonatomic) { in snd_pcm_stream_lock()
101 mutex_lock(&substream->self_group.mutex); in snd_pcm_stream_lock()
104 spin_lock(&substream->self_group.lock); in snd_pcm_stream_lock()
115 void snd_pcm_stream_unlock(struct snd_pcm_substream *substream) in snd_pcm_stream_unlock() argument
117 if (substream->pcm->nonatomic) { in snd_pcm_stream_unlock()
118 mutex_unlock(&substream->self_group.mutex); in snd_pcm_stream_unlock()
121 spin_unlock(&substream->self_group.lock); in snd_pcm_stream_unlock()
135 void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream) in snd_pcm_stream_lock_irq() argument
137 if (!substream->pcm->nonatomic) in snd_pcm_stream_lock_irq()
139 snd_pcm_stream_lock(substream); in snd_pcm_stream_lock_irq()
149 void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream) in snd_pcm_stream_unlock_irq() argument
151 snd_pcm_stream_unlock(substream); in snd_pcm_stream_unlock_irq()
152 if (!substream->pcm->nonatomic) in snd_pcm_stream_unlock_irq()
157 unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream) in _snd_pcm_stream_lock_irqsave() argument
160 if (!substream->pcm->nonatomic) in _snd_pcm_stream_lock_irqsave()
162 snd_pcm_stream_lock(substream); in _snd_pcm_stream_lock_irqsave()
174 void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream, in snd_pcm_stream_unlock_irqrestore() argument
177 snd_pcm_stream_unlock(substream); in snd_pcm_stream_unlock_irqrestore()
178 if (!substream->pcm->nonatomic) in snd_pcm_stream_unlock_irqrestore()
197 int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info) in snd_pcm_info() argument
200 struct snd_pcm *pcm = substream->pcm; in snd_pcm_info()
201 struct snd_pcm_str *pstr = substream->pstr; in snd_pcm_info()
206 info->stream = substream->stream; in snd_pcm_info()
207 info->subdevice = substream->number; in snd_pcm_info()
214 strlcpy(info->subname, substream->name, sizeof(info->subname)); in snd_pcm_info()
215 runtime = substream->runtime; in snd_pcm_info()
219 substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_INFO, info); in snd_pcm_info()
224 int snd_pcm_info_user(struct snd_pcm_substream *substream, in snd_pcm_info_user() argument
233 err = snd_pcm_info(substream, info); in snd_pcm_info_user()
242 static bool hw_support_mmap(struct snd_pcm_substream *substream) in hw_support_mmap() argument
244 if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_MMAP)) in hw_support_mmap()
250 if (!substream->ops->mmap && in hw_support_mmap()
251 substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) in hw_support_mmap()
280 int snd_pcm_hw_refine(struct snd_pcm_substream *substream, in snd_pcm_hw_refine() argument
287 struct snd_pcm_hw_constraints *constrs = &substream->runtime->hw_constraints; in snd_pcm_hw_refine()
433 hw = &substream->runtime->hw; in snd_pcm_hw_refine()
437 if (!hw_support_mmap(substream)) in snd_pcm_hw_refine()
446 changed = substream->ops->ioctl(substream, in snd_pcm_hw_refine()
458 static int snd_pcm_hw_refine_user(struct snd_pcm_substream *substream, in snd_pcm_hw_refine_user() argument
468 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_refine_user()
493 static void snd_pcm_set_state(struct snd_pcm_substream *substream, int state) in snd_pcm_set_state() argument
495 snd_pcm_stream_lock_irq(substream); in snd_pcm_set_state()
496 if (substream->runtime->status->state != SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_set_state()
497 substream->runtime->status->state = state; in snd_pcm_set_state()
498 snd_pcm_stream_unlock_irq(substream); in snd_pcm_set_state()
501 static int snd_pcm_hw_params(struct snd_pcm_substream *substream, in snd_pcm_hw_params() argument
509 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_hw_params()
511 runtime = substream->runtime; in snd_pcm_hw_params()
512 snd_pcm_stream_lock_irq(substream); in snd_pcm_hw_params()
519 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_params()
522 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_params()
524 if (!substream->oss.oss) in snd_pcm_hw_params()
526 if (atomic_read(&substream->mmap_count)) in snd_pcm_hw_params()
530 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_params()
534 err = snd_pcm_hw_params_choose(substream, params); in snd_pcm_hw_params()
538 if (substream->ops->hw_params != NULL) { in snd_pcm_hw_params()
539 err = substream->ops->hw_params(substream, params); in snd_pcm_hw_params()
583 snd_pcm_timer_resolution_change(substream); in snd_pcm_hw_params()
584 snd_pcm_set_state(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_hw_params()
586 if (pm_qos_request_active(&substream->latency_pm_qos_req)) in snd_pcm_hw_params()
587 pm_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_hw_params()
589 pm_qos_add_request(&substream->latency_pm_qos_req, in snd_pcm_hw_params()
596 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); in snd_pcm_hw_params()
597 if (substream->ops->hw_free != NULL) in snd_pcm_hw_params()
598 substream->ops->hw_free(substream); in snd_pcm_hw_params()
602 static int snd_pcm_hw_params_user(struct snd_pcm_substream *substream, in snd_pcm_hw_params_user() argument
612 err = snd_pcm_hw_params(substream, params); in snd_pcm_hw_params_user()
622 static int snd_pcm_hw_free(struct snd_pcm_substream *substream) in snd_pcm_hw_free() argument
627 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_hw_free()
629 runtime = substream->runtime; in snd_pcm_hw_free()
630 snd_pcm_stream_lock_irq(substream); in snd_pcm_hw_free()
636 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_free()
639 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_free()
640 if (atomic_read(&substream->mmap_count)) in snd_pcm_hw_free()
642 if (substream->ops->hw_free) in snd_pcm_hw_free()
643 result = substream->ops->hw_free(substream); in snd_pcm_hw_free()
644 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); in snd_pcm_hw_free()
645 pm_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_hw_free()
649 static int snd_pcm_sw_params(struct snd_pcm_substream *substream, in snd_pcm_sw_params() argument
655 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_sw_params()
657 runtime = substream->runtime; in snd_pcm_sw_params()
658 snd_pcm_stream_lock_irq(substream); in snd_pcm_sw_params()
660 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sw_params()
663 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sw_params()
682 snd_pcm_stream_lock_irq(substream); in snd_pcm_sw_params()
693 if (snd_pcm_running(substream)) { in snd_pcm_sw_params()
694 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_sw_params()
696 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_sw_params()
697 err = snd_pcm_update_state(substream, runtime); in snd_pcm_sw_params()
699 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sw_params()
703 static int snd_pcm_sw_params_user(struct snd_pcm_substream *substream, in snd_pcm_sw_params_user() argument
710 err = snd_pcm_sw_params(substream, ¶ms); in snd_pcm_sw_params_user()
716 int snd_pcm_status(struct snd_pcm_substream *substream, in snd_pcm_status() argument
719 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_status()
721 snd_pcm_stream_lock_irq(substream); in snd_pcm_status()
744 if (snd_pcm_running(substream)) { in snd_pcm_status()
745 snd_pcm_update_hw_ptr(substream); in snd_pcm_status()
767 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_status()
787 snd_pcm_stream_unlock_irq(substream); in snd_pcm_status()
791 static int snd_pcm_status_user(struct snd_pcm_substream *substream, in snd_pcm_status_user() argument
807 res = snd_pcm_status(substream, &status); in snd_pcm_status_user()
815 static int snd_pcm_channel_info(struct snd_pcm_substream *substream, in snd_pcm_channel_info() argument
822 runtime = substream->runtime; in snd_pcm_channel_info()
823 snd_pcm_stream_lock_irq(substream); in snd_pcm_channel_info()
825 snd_pcm_stream_unlock_irq(substream); in snd_pcm_channel_info()
828 snd_pcm_stream_unlock_irq(substream); in snd_pcm_channel_info()
833 return substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_CHANNEL_INFO, info); in snd_pcm_channel_info()
836 static int snd_pcm_channel_info_user(struct snd_pcm_substream *substream, in snd_pcm_channel_info_user() argument
844 res = snd_pcm_channel_info(substream, &info); in snd_pcm_channel_info_user()
852 static void snd_pcm_trigger_tstamp(struct snd_pcm_substream *substream) in snd_pcm_trigger_tstamp() argument
854 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_trigger_tstamp()
857 if (runtime->trigger_master == substream) { in snd_pcm_trigger_tstamp()
868 int (*pre_action)(struct snd_pcm_substream *substream, int state);
869 int (*do_action)(struct snd_pcm_substream *substream, int state);
870 void (*undo_action)(struct snd_pcm_substream *substream, int state);
871 void (*post_action)(struct snd_pcm_substream *substream, int state);
880 struct snd_pcm_substream *substream, in snd_pcm_action_group() argument
887 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
888 if (do_lock && s != substream) { in snd_pcm_action_group()
899 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
903 snd_pcm_group_for_each_entry(s1, substream) { in snd_pcm_action_group()
913 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
919 snd_pcm_group_for_each_entry(s1, substream) { in snd_pcm_action_group()
920 if (s1 != substream) { in snd_pcm_action_group()
937 struct snd_pcm_substream *substream, in snd_pcm_action_single() argument
942 res = ops->pre_action(substream, state); in snd_pcm_action_single()
945 res = ops->do_action(substream, state); in snd_pcm_action_single()
947 ops->post_action(substream, state); in snd_pcm_action_single()
949 ops->undo_action(substream, state); in snd_pcm_action_single()
957 struct snd_pcm_substream *substream, in snd_pcm_action() argument
962 if (!snd_pcm_stream_linked(substream)) in snd_pcm_action()
963 return snd_pcm_action_single(ops, substream, state); in snd_pcm_action()
965 if (substream->pcm->nonatomic) { in snd_pcm_action()
966 if (!mutex_trylock(&substream->group->mutex)) { in snd_pcm_action()
967 mutex_unlock(&substream->self_group.mutex); in snd_pcm_action()
968 mutex_lock(&substream->group->mutex); in snd_pcm_action()
969 mutex_lock(&substream->self_group.mutex); in snd_pcm_action()
971 res = snd_pcm_action_group(ops, substream, state, 1); in snd_pcm_action()
972 mutex_unlock(&substream->group->mutex); in snd_pcm_action()
974 if (!spin_trylock(&substream->group->lock)) { in snd_pcm_action()
975 spin_unlock(&substream->self_group.lock); in snd_pcm_action()
976 spin_lock(&substream->group->lock); in snd_pcm_action()
977 spin_lock(&substream->self_group.lock); in snd_pcm_action()
979 res = snd_pcm_action_group(ops, substream, state, 1); in snd_pcm_action()
980 spin_unlock(&substream->group->lock); in snd_pcm_action()
989 struct snd_pcm_substream *substream, in snd_pcm_action_lock_irq() argument
994 snd_pcm_stream_lock_irq(substream); in snd_pcm_action_lock_irq()
995 res = snd_pcm_action(ops, substream, state); in snd_pcm_action_lock_irq()
996 snd_pcm_stream_unlock_irq(substream); in snd_pcm_action_lock_irq()
1003 struct snd_pcm_substream *substream, in snd_pcm_action_nonatomic() argument
1009 if (snd_pcm_stream_linked(substream)) in snd_pcm_action_nonatomic()
1010 res = snd_pcm_action_group(ops, substream, state, 0); in snd_pcm_action_nonatomic()
1012 res = snd_pcm_action_single(ops, substream, state); in snd_pcm_action_nonatomic()
1020 static int snd_pcm_pre_start(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_start() argument
1022 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_start()
1025 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_pre_start()
1026 !snd_pcm_playback_data(substream)) in snd_pcm_pre_start()
1029 runtime->trigger_master = substream; in snd_pcm_pre_start()
1033 static int snd_pcm_do_start(struct snd_pcm_substream *substream, int state) in snd_pcm_do_start() argument
1035 if (substream->runtime->trigger_master != substream) in snd_pcm_do_start()
1037 return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_START); in snd_pcm_do_start()
1040 static void snd_pcm_undo_start(struct snd_pcm_substream *substream, int state) in snd_pcm_undo_start() argument
1042 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_start()
1043 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); in snd_pcm_undo_start()
1046 static void snd_pcm_post_start(struct snd_pcm_substream *substream, int state) in snd_pcm_post_start() argument
1048 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_start()
1049 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_start()
1054 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_post_start()
1056 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_post_start()
1057 if (substream->timer) in snd_pcm_post_start()
1058 snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MSTART, in snd_pcm_post_start()
1075 int snd_pcm_start(struct snd_pcm_substream *substream) in snd_pcm_start() argument
1077 return snd_pcm_action(&snd_pcm_action_start, substream, in snd_pcm_start()
1084 static int snd_pcm_pre_stop(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_stop() argument
1086 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_stop()
1089 runtime->trigger_master = substream; in snd_pcm_pre_stop()
1093 static int snd_pcm_do_stop(struct snd_pcm_substream *substream, int state) in snd_pcm_do_stop() argument
1095 if (substream->runtime->trigger_master == substream && in snd_pcm_do_stop()
1096 snd_pcm_running(substream)) in snd_pcm_do_stop()
1097 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); in snd_pcm_do_stop()
1101 static void snd_pcm_post_stop(struct snd_pcm_substream *substream, int state) in snd_pcm_post_stop() argument
1103 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_stop()
1105 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_stop()
1107 if (substream->timer) in snd_pcm_post_stop()
1108 snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MSTOP, in snd_pcm_post_stop()
1130 int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state) in snd_pcm_stop() argument
1132 return snd_pcm_action(&snd_pcm_action_stop, substream, state); in snd_pcm_stop()
1146 int snd_pcm_drain_done(struct snd_pcm_substream *substream) in snd_pcm_drain_done() argument
1148 return snd_pcm_action_single(&snd_pcm_action_stop, substream, in snd_pcm_drain_done()
1161 int snd_pcm_stop_xrun(struct snd_pcm_substream *substream) in snd_pcm_stop_xrun() argument
1166 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_stop_xrun()
1167 if (snd_pcm_running(substream)) in snd_pcm_stop_xrun()
1168 ret = snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); in snd_pcm_stop_xrun()
1169 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_stop_xrun()
1177 static int snd_pcm_pre_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_pre_pause() argument
1179 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_pause()
1187 runtime->trigger_master = substream; in snd_pcm_pre_pause()
1191 static int snd_pcm_do_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_do_pause() argument
1193 if (substream->runtime->trigger_master != substream) in snd_pcm_do_pause()
1198 snd_pcm_update_hw_ptr(substream); in snd_pcm_do_pause()
1203 substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000; in snd_pcm_do_pause()
1204 return substream->ops->trigger(substream, in snd_pcm_do_pause()
1209 static void snd_pcm_undo_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_undo_pause() argument
1211 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_pause()
1212 substream->ops->trigger(substream, in snd_pcm_undo_pause()
1217 static void snd_pcm_post_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_post_pause() argument
1219 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_pause()
1220 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_pause()
1223 if (substream->timer) in snd_pcm_post_pause()
1224 snd_timer_notify(substream->timer, in snd_pcm_post_pause()
1231 if (substream->timer) in snd_pcm_post_pause()
1232 snd_timer_notify(substream->timer, in snd_pcm_post_pause()
1248 static int snd_pcm_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_pause() argument
1250 return snd_pcm_action(&snd_pcm_action_pause, substream, push); in snd_pcm_pause()
1256 static int snd_pcm_pre_suspend(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_suspend() argument
1258 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_suspend()
1261 runtime->trigger_master = substream; in snd_pcm_pre_suspend()
1265 static int snd_pcm_do_suspend(struct snd_pcm_substream *substream, int state) in snd_pcm_do_suspend() argument
1267 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_suspend()
1268 if (runtime->trigger_master != substream) in snd_pcm_do_suspend()
1270 if (! snd_pcm_running(substream)) in snd_pcm_do_suspend()
1272 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); in snd_pcm_do_suspend()
1276 static void snd_pcm_post_suspend(struct snd_pcm_substream *substream, int state) in snd_pcm_post_suspend() argument
1278 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_suspend()
1279 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_suspend()
1282 if (substream->timer) in snd_pcm_post_suspend()
1283 snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MSUSPEND, in snd_pcm_post_suspend()
1304 int snd_pcm_suspend(struct snd_pcm_substream *substream) in snd_pcm_suspend() argument
1309 if (! substream) in snd_pcm_suspend()
1312 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_suspend()
1313 err = snd_pcm_action(&snd_pcm_action_suspend, substream, 0); in snd_pcm_suspend()
1314 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_suspend()
1330 struct snd_pcm_substream *substream; in snd_pcm_suspend_all() local
1337 for (substream = pcm->streams[stream].substream; in snd_pcm_suspend_all()
1338 substream; substream = substream->next) { in snd_pcm_suspend_all()
1340 if (substream->runtime == NULL) in snd_pcm_suspend_all()
1342 err = snd_pcm_suspend(substream); in snd_pcm_suspend_all()
1354 static int snd_pcm_pre_resume(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_resume() argument
1356 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_resume()
1359 runtime->trigger_master = substream; in snd_pcm_pre_resume()
1363 static int snd_pcm_do_resume(struct snd_pcm_substream *substream, int state) in snd_pcm_do_resume() argument
1365 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_resume()
1366 if (runtime->trigger_master != substream) in snd_pcm_do_resume()
1371 substream->stream != SNDRV_PCM_STREAM_PLAYBACK)) in snd_pcm_do_resume()
1373 return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_RESUME); in snd_pcm_do_resume()
1376 static void snd_pcm_undo_resume(struct snd_pcm_substream *substream, int state) in snd_pcm_undo_resume() argument
1378 if (substream->runtime->trigger_master == substream && in snd_pcm_undo_resume()
1379 snd_pcm_running(substream)) in snd_pcm_undo_resume()
1380 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); in snd_pcm_undo_resume()
1383 static void snd_pcm_post_resume(struct snd_pcm_substream *substream, int state) in snd_pcm_post_resume() argument
1385 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_resume()
1386 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_resume()
1388 if (substream->timer) in snd_pcm_post_resume()
1389 snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MRESUME, in snd_pcm_post_resume()
1400 static int snd_pcm_resume(struct snd_pcm_substream *substream) in snd_pcm_resume() argument
1402 struct snd_card *card = substream->pcm->card; in snd_pcm_resume()
1407 res = snd_pcm_action_lock_irq(&snd_pcm_action_resume, substream, 0); in snd_pcm_resume()
1414 static int snd_pcm_resume(struct snd_pcm_substream *substream) in snd_pcm_resume() argument
1426 static int snd_pcm_xrun(struct snd_pcm_substream *substream) in snd_pcm_xrun() argument
1428 struct snd_card *card = substream->pcm->card; in snd_pcm_xrun()
1429 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xrun()
1439 snd_pcm_stream_lock_irq(substream); in snd_pcm_xrun()
1445 result = snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); in snd_pcm_xrun()
1450 snd_pcm_stream_unlock_irq(substream); in snd_pcm_xrun()
1459 static int snd_pcm_pre_reset(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_reset() argument
1461 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_reset()
1473 static int snd_pcm_do_reset(struct snd_pcm_substream *substream, int state) in snd_pcm_do_reset() argument
1475 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_reset()
1476 int err = substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL); in snd_pcm_do_reset()
1487 static void snd_pcm_post_reset(struct snd_pcm_substream *substream, int state) in snd_pcm_post_reset() argument
1489 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_reset()
1491 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_post_reset()
1493 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_post_reset()
1502 static int snd_pcm_reset(struct snd_pcm_substream *substream) in snd_pcm_reset() argument
1504 return snd_pcm_action_nonatomic(&snd_pcm_action_reset, substream, 0); in snd_pcm_reset()
1511 static int snd_pcm_pre_prepare(struct snd_pcm_substream *substream, in snd_pcm_pre_prepare() argument
1514 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_prepare()
1518 if (snd_pcm_running(substream)) in snd_pcm_pre_prepare()
1520 substream->f_flags = f_flags; in snd_pcm_pre_prepare()
1524 static int snd_pcm_do_prepare(struct snd_pcm_substream *substream, int state) in snd_pcm_do_prepare() argument
1527 err = substream->ops->prepare(substream); in snd_pcm_do_prepare()
1530 return snd_pcm_do_reset(substream, 0); in snd_pcm_do_prepare()
1533 static void snd_pcm_post_prepare(struct snd_pcm_substream *substream, int state) in snd_pcm_post_prepare() argument
1535 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_prepare()
1537 snd_pcm_set_state(substream, SNDRV_PCM_STATE_PREPARED); in snd_pcm_post_prepare()
1553 static int snd_pcm_prepare(struct snd_pcm_substream *substream, in snd_pcm_prepare() argument
1557 struct snd_card *card = substream->pcm->card; in snd_pcm_prepare()
1563 f_flags = substream->f_flags; in snd_pcm_prepare()
1568 substream, f_flags); in snd_pcm_prepare()
1577 static int snd_pcm_pre_drain_init(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_drain_init() argument
1579 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_drain_init()
1586 runtime->trigger_master = substream; in snd_pcm_pre_drain_init()
1590 static int snd_pcm_do_drain_init(struct snd_pcm_substream *substream, int state) in snd_pcm_do_drain_init() argument
1592 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_drain_init()
1593 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_do_drain_init()
1597 if (! snd_pcm_playback_empty(substream)) { in snd_pcm_do_drain_init()
1598 snd_pcm_do_start(substream, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
1599 snd_pcm_post_start(substream, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
1618 snd_pcm_do_stop(substream, new_state); in snd_pcm_do_drain_init()
1619 snd_pcm_post_stop(substream, new_state); in snd_pcm_do_drain_init()
1624 runtime->trigger_master == substream && in snd_pcm_do_drain_init()
1626 return substream->ops->trigger(substream, in snd_pcm_do_drain_init()
1632 static void snd_pcm_post_drain_init(struct snd_pcm_substream *substream, int state) in snd_pcm_post_drain_init() argument
1642 static int snd_pcm_drop(struct snd_pcm_substream *substream);
1651 static int snd_pcm_drain(struct snd_pcm_substream *substream, in snd_pcm_drain() argument
1661 card = substream->pcm->card; in snd_pcm_drain()
1662 runtime = substream->runtime; in snd_pcm_drain()
1679 } else if (substream->f_flags & O_NONBLOCK) in snd_pcm_drain()
1683 snd_pcm_stream_lock_irq(substream); in snd_pcm_drain()
1686 snd_pcm_pause(substream, 0); in snd_pcm_drain()
1689 result = snd_pcm_action(&snd_pcm_action_drain_init, substream, 0); in snd_pcm_drain()
1707 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_drain()
1720 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drain()
1736 snd_pcm_stream_lock_irq(substream); in snd_pcm_drain()
1743 if (substream->runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) in snd_pcm_drain()
1746 dev_dbg(substream->pcm->card->dev, in snd_pcm_drain()
1748 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_drain()
1756 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drain()
1768 static int snd_pcm_drop(struct snd_pcm_substream *substream) in snd_pcm_drop() argument
1773 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_drop()
1775 runtime = substream->runtime; in snd_pcm_drop()
1782 snd_pcm_stream_lock_irq(substream); in snd_pcm_drop()
1785 snd_pcm_pause(substream, 0); in snd_pcm_drop()
1787 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_drop()
1789 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drop()
1810 static int snd_pcm_link(struct snd_pcm_substream *substream, int fd) in snd_pcm_link() argument
1825 substream1 = pcm_file->substream; in snd_pcm_link()
1833 if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_link()
1834 substream->runtime->status->state != substream1->runtime->status->state || in snd_pcm_link()
1835 substream->pcm->nonatomic != substream1->pcm->nonatomic) { in snd_pcm_link()
1843 if (!snd_pcm_stream_linked(substream)) { in snd_pcm_link()
1844 substream->group = group; in snd_pcm_link()
1846 spin_lock_init(&substream->group->lock); in snd_pcm_link()
1847 mutex_init(&substream->group->mutex); in snd_pcm_link()
1848 INIT_LIST_HEAD(&substream->group->substreams); in snd_pcm_link()
1849 list_add_tail(&substream->link_list, &substream->group->substreams); in snd_pcm_link()
1850 substream->group->count = 1; in snd_pcm_link()
1852 list_add_tail(&substream1->link_list, &substream->group->substreams); in snd_pcm_link()
1853 substream->group->count++; in snd_pcm_link()
1854 substream1->group = substream->group; in snd_pcm_link()
1866 static void relink_to_local(struct snd_pcm_substream *substream) in relink_to_local() argument
1868 substream->group = &substream->self_group; in relink_to_local()
1869 INIT_LIST_HEAD(&substream->self_group.substreams); in relink_to_local()
1870 list_add_tail(&substream->link_list, &substream->self_group.substreams); in relink_to_local()
1873 static int snd_pcm_unlink(struct snd_pcm_substream *substream) in snd_pcm_unlink() argument
1880 if (!snd_pcm_stream_linked(substream)) { in snd_pcm_unlink()
1884 list_del(&substream->link_list); in snd_pcm_unlink()
1885 substream->group->count--; in snd_pcm_unlink()
1886 if (substream->group->count == 1) { /* detach the last stream, too */ in snd_pcm_unlink()
1887 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_unlink()
1891 kfree(substream->group); in snd_pcm_unlink()
1893 relink_to_local(substream); in snd_pcm_unlink()
2012 struct snd_pcm_substream *substream = rule->private; in snd_pcm_hw_rule_buffer_bytes_max() local
2014 t.max = substream->buffer_bytes_max; in snd_pcm_hw_rule_buffer_bytes_max()
2021 int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream) in snd_pcm_hw_constraints_init() argument
2023 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_init()
2145 int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) in snd_pcm_hw_constraints_complete() argument
2147 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_complete()
2156 if (hw_support_mmap(substream)) { in snd_pcm_hw_constraints_complete()
2202 snd_pcm_hw_rule_buffer_bytes_max, substream, in snd_pcm_hw_constraints_complete()
2228 static void pcm_release_private(struct snd_pcm_substream *substream) in pcm_release_private() argument
2230 snd_pcm_unlink(substream); in pcm_release_private()
2233 void snd_pcm_release_substream(struct snd_pcm_substream *substream) in snd_pcm_release_substream() argument
2235 substream->ref_count--; in snd_pcm_release_substream()
2236 if (substream->ref_count > 0) in snd_pcm_release_substream()
2239 snd_pcm_drop(substream); in snd_pcm_release_substream()
2240 if (substream->hw_opened) { in snd_pcm_release_substream()
2241 if (substream->ops->hw_free != NULL) in snd_pcm_release_substream()
2242 substream->ops->hw_free(substream); in snd_pcm_release_substream()
2243 substream->ops->close(substream); in snd_pcm_release_substream()
2244 substream->hw_opened = 0; in snd_pcm_release_substream()
2246 if (pm_qos_request_active(&substream->latency_pm_qos_req)) in snd_pcm_release_substream()
2247 pm_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_release_substream()
2248 if (substream->pcm_release) { in snd_pcm_release_substream()
2249 substream->pcm_release(substream); in snd_pcm_release_substream()
2250 substream->pcm_release = NULL; in snd_pcm_release_substream()
2252 snd_pcm_detach_substream(substream); in snd_pcm_release_substream()
2261 struct snd_pcm_substream *substream; in snd_pcm_open_substream() local
2264 err = snd_pcm_attach_substream(pcm, stream, file, &substream); in snd_pcm_open_substream()
2267 if (substream->ref_count > 1) { in snd_pcm_open_substream()
2268 *rsubstream = substream; in snd_pcm_open_substream()
2272 err = snd_pcm_hw_constraints_init(substream); in snd_pcm_open_substream()
2278 if ((err = substream->ops->open(substream)) < 0) in snd_pcm_open_substream()
2281 substream->hw_opened = 1; in snd_pcm_open_substream()
2283 err = snd_pcm_hw_constraints_complete(substream); in snd_pcm_open_substream()
2289 *rsubstream = substream; in snd_pcm_open_substream()
2293 snd_pcm_release_substream(substream); in snd_pcm_open_substream()
2304 struct snd_pcm_substream *substream; in snd_pcm_open_file() local
2307 err = snd_pcm_open_substream(pcm, stream, file, &substream); in snd_pcm_open_file()
2313 snd_pcm_release_substream(substream); in snd_pcm_open_file()
2316 pcm_file->substream = substream; in snd_pcm_open_file()
2317 if (substream->ref_count == 1) { in snd_pcm_open_file()
2318 substream->file = pcm_file; in snd_pcm_open_file()
2319 substream->pcm_release = pcm_release_private; in snd_pcm_open_file()
2414 struct snd_pcm_substream *substream; in snd_pcm_release() local
2418 substream = pcm_file->substream; in snd_pcm_release()
2419 if (snd_BUG_ON(!substream)) in snd_pcm_release()
2421 pcm = substream->pcm; in snd_pcm_release()
2423 snd_pcm_release_substream(substream); in snd_pcm_release()
2432 static snd_pcm_sframes_t snd_pcm_playback_rewind(struct snd_pcm_substream *substream, in snd_pcm_playback_rewind() argument
2435 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_playback_rewind()
2443 snd_pcm_stream_lock_irq(substream); in snd_pcm_playback_rewind()
2449 if (snd_pcm_update_hw_ptr(substream) >= 0) in snd_pcm_playback_rewind()
2476 snd_pcm_stream_unlock_irq(substream); in snd_pcm_playback_rewind()
2480 static snd_pcm_sframes_t snd_pcm_capture_rewind(struct snd_pcm_substream *substream, in snd_pcm_capture_rewind() argument
2483 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_capture_rewind()
2491 snd_pcm_stream_lock_irq(substream); in snd_pcm_capture_rewind()
2497 if (snd_pcm_update_hw_ptr(substream) >= 0) in snd_pcm_capture_rewind()
2524 snd_pcm_stream_unlock_irq(substream); in snd_pcm_capture_rewind()
2528 static snd_pcm_sframes_t snd_pcm_playback_forward(struct snd_pcm_substream *substream, in snd_pcm_playback_forward() argument
2531 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_playback_forward()
2539 snd_pcm_stream_lock_irq(substream); in snd_pcm_playback_forward()
2546 if (snd_pcm_update_hw_ptr(substream) >= 0) in snd_pcm_playback_forward()
2573 snd_pcm_stream_unlock_irq(substream); in snd_pcm_playback_forward()
2577 static snd_pcm_sframes_t snd_pcm_capture_forward(struct snd_pcm_substream *substream, in snd_pcm_capture_forward() argument
2580 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_capture_forward()
2588 snd_pcm_stream_lock_irq(substream); in snd_pcm_capture_forward()
2595 if (snd_pcm_update_hw_ptr(substream) >= 0) in snd_pcm_capture_forward()
2622 snd_pcm_stream_unlock_irq(substream); in snd_pcm_capture_forward()
2626 static int snd_pcm_hwsync(struct snd_pcm_substream *substream) in snd_pcm_hwsync() argument
2628 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hwsync()
2631 snd_pcm_stream_lock_irq(substream); in snd_pcm_hwsync()
2634 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in snd_pcm_hwsync()
2638 if ((err = snd_pcm_update_hw_ptr(substream)) < 0) in snd_pcm_hwsync()
2653 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hwsync()
2657 static int snd_pcm_delay(struct snd_pcm_substream *substream, in snd_pcm_delay() argument
2660 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_delay()
2664 snd_pcm_stream_lock_irq(substream); in snd_pcm_delay()
2667 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in snd_pcm_delay()
2671 if ((err = snd_pcm_update_hw_ptr(substream)) < 0) in snd_pcm_delay()
2677 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_delay()
2691 snd_pcm_stream_unlock_irq(substream); in snd_pcm_delay()
2698 static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream, in snd_pcm_sync_ptr() argument
2701 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_sync_ptr()
2715 err = snd_pcm_hwsync(substream); in snd_pcm_sync_ptr()
2719 snd_pcm_stream_lock_irq(substream); in snd_pcm_sync_ptr()
2732 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sync_ptr()
2738 static int snd_pcm_tstamp(struct snd_pcm_substream *substream, int __user *_arg) in snd_pcm_tstamp() argument
2740 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_tstamp()
2752 struct snd_pcm_substream *substream, in snd_pcm_common_ioctl1() argument
2759 return snd_pcm_info_user(substream, arg); in snd_pcm_common_ioctl1()
2763 return snd_pcm_tstamp(substream, arg); in snd_pcm_common_ioctl1()
2765 return snd_pcm_hw_refine_user(substream, arg); in snd_pcm_common_ioctl1()
2767 return snd_pcm_hw_params_user(substream, arg); in snd_pcm_common_ioctl1()
2769 return snd_pcm_hw_free(substream); in snd_pcm_common_ioctl1()
2771 return snd_pcm_sw_params_user(substream, arg); in snd_pcm_common_ioctl1()
2773 return snd_pcm_status_user(substream, arg, false); in snd_pcm_common_ioctl1()
2775 return snd_pcm_status_user(substream, arg, true); in snd_pcm_common_ioctl1()
2777 return snd_pcm_channel_info_user(substream, arg); in snd_pcm_common_ioctl1()
2779 return snd_pcm_prepare(substream, file); in snd_pcm_common_ioctl1()
2781 return snd_pcm_reset(substream); in snd_pcm_common_ioctl1()
2783 return snd_pcm_action_lock_irq(&snd_pcm_action_start, substream, SNDRV_PCM_STATE_RUNNING); in snd_pcm_common_ioctl1()
2785 return snd_pcm_link(substream, (int)(unsigned long) arg); in snd_pcm_common_ioctl1()
2787 return snd_pcm_unlink(substream); in snd_pcm_common_ioctl1()
2789 return snd_pcm_resume(substream); in snd_pcm_common_ioctl1()
2791 return snd_pcm_xrun(substream); in snd_pcm_common_ioctl1()
2793 return snd_pcm_hwsync(substream); in snd_pcm_common_ioctl1()
2795 return snd_pcm_delay(substream, arg); in snd_pcm_common_ioctl1()
2797 return snd_pcm_sync_ptr(substream, arg); in snd_pcm_common_ioctl1()
2800 return snd_pcm_hw_refine_old_user(substream, arg); in snd_pcm_common_ioctl1()
2802 return snd_pcm_hw_params_old_user(substream, arg); in snd_pcm_common_ioctl1()
2805 return snd_pcm_drain(substream, file); in snd_pcm_common_ioctl1()
2807 return snd_pcm_drop(substream); in snd_pcm_common_ioctl1()
2811 snd_pcm_stream_lock_irq(substream); in snd_pcm_common_ioctl1()
2812 res = snd_pcm_pause(substream, (int)(unsigned long)arg); in snd_pcm_common_ioctl1()
2813 snd_pcm_stream_unlock_irq(substream); in snd_pcm_common_ioctl1()
2817 pcm_dbg(substream->pcm, "unknown ioctl = 0x%x\n", cmd); in snd_pcm_common_ioctl1()
2822 struct snd_pcm_substream *substream, in snd_pcm_playback_ioctl1() argument
2825 if (snd_BUG_ON(!substream)) in snd_pcm_playback_ioctl1()
2827 if (snd_BUG_ON(substream->stream != SNDRV_PCM_STREAM_PLAYBACK)) in snd_pcm_playback_ioctl1()
2834 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_playback_ioctl1()
2842 result = snd_pcm_lib_write(substream, xferi.buf, xferi.frames); in snd_pcm_playback_ioctl1()
2850 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_playback_ioctl1()
2866 result = snd_pcm_lib_writev(substream, bufs, xfern.frames); in snd_pcm_playback_ioctl1()
2880 result = snd_pcm_playback_rewind(substream, frames); in snd_pcm_playback_ioctl1()
2893 result = snd_pcm_playback_forward(substream, frames); in snd_pcm_playback_ioctl1()
2898 return snd_pcm_common_ioctl1(file, substream, cmd, arg); in snd_pcm_playback_ioctl1()
2902 struct snd_pcm_substream *substream, in snd_pcm_capture_ioctl1() argument
2905 if (snd_BUG_ON(!substream)) in snd_pcm_capture_ioctl1()
2907 if (snd_BUG_ON(substream->stream != SNDRV_PCM_STREAM_CAPTURE)) in snd_pcm_capture_ioctl1()
2914 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_capture_ioctl1()
2922 result = snd_pcm_lib_read(substream, xferi.buf, xferi.frames); in snd_pcm_capture_ioctl1()
2930 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_capture_ioctl1()
2946 result = snd_pcm_lib_readv(substream, bufs, xfern.frames); in snd_pcm_capture_ioctl1()
2960 result = snd_pcm_capture_rewind(substream, frames); in snd_pcm_capture_ioctl1()
2973 result = snd_pcm_capture_forward(substream, frames); in snd_pcm_capture_ioctl1()
2978 return snd_pcm_common_ioctl1(file, substream, cmd, arg); in snd_pcm_capture_ioctl1()
2991 return snd_pcm_playback_ioctl1(file, pcm_file->substream, cmd, in snd_pcm_playback_ioctl()
3005 return snd_pcm_capture_ioctl1(file, pcm_file->substream, cmd, in snd_pcm_capture_ioctl()
3009 int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, in snd_pcm_kernel_ioctl() argument
3016 switch (substream->stream) { in snd_pcm_kernel_ioctl()
3018 result = snd_pcm_playback_ioctl1(NULL, substream, cmd, in snd_pcm_kernel_ioctl()
3022 result = snd_pcm_capture_ioctl1(NULL, substream, cmd, in snd_pcm_kernel_ioctl()
3039 struct snd_pcm_substream *substream; in snd_pcm_read() local
3044 substream = pcm_file->substream; in snd_pcm_read()
3045 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_read()
3047 runtime = substream->runtime; in snd_pcm_read()
3053 result = snd_pcm_lib_read(substream, buf, count); in snd_pcm_read()
3063 struct snd_pcm_substream *substream; in snd_pcm_write() local
3068 substream = pcm_file->substream; in snd_pcm_write()
3069 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_write()
3071 runtime = substream->runtime; in snd_pcm_write()
3077 result = snd_pcm_lib_write(substream, buf, count); in snd_pcm_write()
3086 struct snd_pcm_substream *substream; in snd_pcm_readv() local
3094 substream = pcm_file->substream; in snd_pcm_readv()
3095 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_readv()
3097 runtime = substream->runtime; in snd_pcm_readv()
3112 result = snd_pcm_lib_readv(substream, bufs, frames); in snd_pcm_readv()
3122 struct snd_pcm_substream *substream; in snd_pcm_writev() local
3130 substream = pcm_file->substream; in snd_pcm_writev()
3131 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_writev()
3133 runtime = substream->runtime; in snd_pcm_writev()
3147 result = snd_pcm_lib_writev(substream, bufs, frames); in snd_pcm_writev()
3157 struct snd_pcm_substream *substream; in snd_pcm_playback_poll() local
3164 substream = pcm_file->substream; in snd_pcm_playback_poll()
3165 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_playback_poll()
3167 runtime = substream->runtime; in snd_pcm_playback_poll()
3171 snd_pcm_stream_lock_irq(substream); in snd_pcm_playback_poll()
3189 snd_pcm_stream_unlock_irq(substream); in snd_pcm_playback_poll()
3196 struct snd_pcm_substream *substream; in snd_pcm_capture_poll() local
3203 substream = pcm_file->substream; in snd_pcm_capture_poll()
3204 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_capture_poll()
3206 runtime = substream->runtime; in snd_pcm_capture_poll()
3210 snd_pcm_stream_lock_irq(substream); in snd_pcm_capture_poll()
3232 snd_pcm_stream_unlock_irq(substream); in snd_pcm_capture_poll()
3251 struct snd_pcm_substream *substream = area->vm_private_data; in snd_pcm_mmap_status_fault() local
3254 if (substream == NULL) in snd_pcm_mmap_status_fault()
3256 runtime = substream->runtime; in snd_pcm_mmap_status_fault()
3267 static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_status() argument
3277 area->vm_private_data = substream; in snd_pcm_mmap_status()
3288 struct snd_pcm_substream *substream = area->vm_private_data; in snd_pcm_mmap_control_fault() local
3291 if (substream == NULL) in snd_pcm_mmap_control_fault()
3293 runtime = substream->runtime; in snd_pcm_mmap_control_fault()
3304 static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_control() argument
3314 area->vm_private_data = substream; in snd_pcm_mmap_control()
3322 static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_status() argument
3327 static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_control() argument
3335 snd_pcm_default_page_ops(struct snd_pcm_substream *substream, unsigned long ofs) in snd_pcm_default_page_ops() argument
3337 void *vaddr = substream->runtime->dma_area + ofs; in snd_pcm_default_page_ops()
3347 struct snd_pcm_substream *substream = area->vm_private_data; in snd_pcm_mmap_data_fault() local
3353 if (substream == NULL) in snd_pcm_mmap_data_fault()
3355 runtime = substream->runtime; in snd_pcm_mmap_data_fault()
3360 if (substream->ops->page) in snd_pcm_mmap_data_fault()
3361 page = substream->ops->page(substream, offset); in snd_pcm_mmap_data_fault()
3363 page = snd_pcm_default_page_ops(substream, offset); in snd_pcm_mmap_data_fault()
3394 int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream, in snd_pcm_lib_default_mmap() argument
3399 if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV_IRAM) { in snd_pcm_lib_default_mmap()
3402 substream->dma_buffer.addr >> PAGE_SHIFT, in snd_pcm_lib_default_mmap()
3407 if (!substream->ops->page && in snd_pcm_lib_default_mmap()
3408 substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) in snd_pcm_lib_default_mmap()
3409 return dma_mmap_coherent(substream->dma_buffer.dev.dev, in snd_pcm_lib_default_mmap()
3411 substream->runtime->dma_area, in snd_pcm_lib_default_mmap()
3412 substream->runtime->dma_addr, in snd_pcm_lib_default_mmap()
3434 int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, in snd_pcm_lib_mmap_iomem() argument
3437 struct snd_pcm_runtime *runtime = substream->runtime;; in snd_pcm_lib_mmap_iomem()
3449 int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_data() argument
3458 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_mmap_data()
3465 runtime = substream->runtime; in snd_pcm_mmap_data()
3482 area->vm_private_data = substream; in snd_pcm_mmap_data()
3483 if (substream->ops->mmap) in snd_pcm_mmap_data()
3484 err = substream->ops->mmap(substream, area); in snd_pcm_mmap_data()
3486 err = snd_pcm_lib_default_mmap(substream, area); in snd_pcm_mmap_data()
3488 atomic_inc(&substream->mmap_count); in snd_pcm_mmap_data()
3497 struct snd_pcm_substream *substream; in snd_pcm_mmap() local
3501 substream = pcm_file->substream; in snd_pcm_mmap()
3502 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_mmap()
3510 return snd_pcm_mmap_status(substream, file, area); in snd_pcm_mmap()
3514 return snd_pcm_mmap_control(substream, file, area); in snd_pcm_mmap()
3516 return snd_pcm_mmap_data(substream, file, area); in snd_pcm_mmap()
3524 struct snd_pcm_substream *substream; in snd_pcm_fasync() local
3528 substream = pcm_file->substream; in snd_pcm_fasync()
3529 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_fasync()
3531 runtime = substream->runtime; in snd_pcm_fasync()
3590 static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, in snd_pcm_hw_refine_old_user() argument
3607 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_refine_old_user()
3620 static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, in snd_pcm_hw_params_old_user() argument
3637 err = snd_pcm_hw_params(substream, params); in snd_pcm_hw_params_old_user()
3659 struct snd_pcm_substream *substream = pcm_file->substream; in snd_pcm_get_unmapped_area() local
3660 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_get_unmapped_area()