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 inline void snd_pcm_timer_notify(struct snd_pcm_substream *substream, in snd_pcm_timer_notify() argument
505 if (substream->timer) in snd_pcm_timer_notify()
506 snd_timer_notify(substream->timer, event, in snd_pcm_timer_notify()
507 &substream->runtime->trigger_tstamp); in snd_pcm_timer_notify()
511 static int snd_pcm_hw_params(struct snd_pcm_substream *substream, in snd_pcm_hw_params() argument
519 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_hw_params()
521 runtime = substream->runtime; in snd_pcm_hw_params()
522 snd_pcm_stream_lock_irq(substream); in snd_pcm_hw_params()
529 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_params()
532 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_params()
534 if (!substream->oss.oss) in snd_pcm_hw_params()
536 if (atomic_read(&substream->mmap_count)) in snd_pcm_hw_params()
540 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_params()
544 err = snd_pcm_hw_params_choose(substream, params); in snd_pcm_hw_params()
548 if (substream->ops->hw_params != NULL) { in snd_pcm_hw_params()
549 err = substream->ops->hw_params(substream, params); in snd_pcm_hw_params()
593 snd_pcm_timer_resolution_change(substream); in snd_pcm_hw_params()
594 snd_pcm_set_state(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_hw_params()
596 if (pm_qos_request_active(&substream->latency_pm_qos_req)) in snd_pcm_hw_params()
597 pm_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_hw_params()
599 pm_qos_add_request(&substream->latency_pm_qos_req, in snd_pcm_hw_params()
606 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); in snd_pcm_hw_params()
607 if (substream->ops->hw_free != NULL) in snd_pcm_hw_params()
608 substream->ops->hw_free(substream); in snd_pcm_hw_params()
612 static int snd_pcm_hw_params_user(struct snd_pcm_substream *substream, in snd_pcm_hw_params_user() argument
622 err = snd_pcm_hw_params(substream, params); in snd_pcm_hw_params_user()
632 static int snd_pcm_hw_free(struct snd_pcm_substream *substream) in snd_pcm_hw_free() argument
637 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_hw_free()
639 runtime = substream->runtime; in snd_pcm_hw_free()
640 snd_pcm_stream_lock_irq(substream); in snd_pcm_hw_free()
646 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_free()
649 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_free()
650 if (atomic_read(&substream->mmap_count)) in snd_pcm_hw_free()
652 if (substream->ops->hw_free) in snd_pcm_hw_free()
653 result = substream->ops->hw_free(substream); in snd_pcm_hw_free()
654 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); in snd_pcm_hw_free()
655 pm_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_hw_free()
659 static int snd_pcm_sw_params(struct snd_pcm_substream *substream, in snd_pcm_sw_params() argument
665 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_sw_params()
667 runtime = substream->runtime; in snd_pcm_sw_params()
668 snd_pcm_stream_lock_irq(substream); in snd_pcm_sw_params()
670 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sw_params()
673 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sw_params()
693 snd_pcm_stream_lock_irq(substream); in snd_pcm_sw_params()
704 if (snd_pcm_running(substream)) { in snd_pcm_sw_params()
705 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_sw_params()
707 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_sw_params()
708 err = snd_pcm_update_state(substream, runtime); in snd_pcm_sw_params()
710 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sw_params()
714 static int snd_pcm_sw_params_user(struct snd_pcm_substream *substream, in snd_pcm_sw_params_user() argument
721 err = snd_pcm_sw_params(substream, &params); in snd_pcm_sw_params_user()
727 int snd_pcm_status(struct snd_pcm_substream *substream, in snd_pcm_status() argument
730 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_status()
732 snd_pcm_stream_lock_irq(substream); in snd_pcm_status()
755 if (snd_pcm_running(substream)) { in snd_pcm_status()
756 snd_pcm_update_hw_ptr(substream); in snd_pcm_status()
778 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_status()
798 snd_pcm_stream_unlock_irq(substream); in snd_pcm_status()
802 static int snd_pcm_status_user(struct snd_pcm_substream *substream, in snd_pcm_status_user() argument
818 res = snd_pcm_status(substream, &status); in snd_pcm_status_user()
826 static int snd_pcm_channel_info(struct snd_pcm_substream *substream, in snd_pcm_channel_info() argument
833 runtime = substream->runtime; in snd_pcm_channel_info()
834 snd_pcm_stream_lock_irq(substream); in snd_pcm_channel_info()
836 snd_pcm_stream_unlock_irq(substream); in snd_pcm_channel_info()
839 snd_pcm_stream_unlock_irq(substream); in snd_pcm_channel_info()
844 return substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_CHANNEL_INFO, info); in snd_pcm_channel_info()
847 static int snd_pcm_channel_info_user(struct snd_pcm_substream *substream, in snd_pcm_channel_info_user() argument
855 res = snd_pcm_channel_info(substream, &info); in snd_pcm_channel_info_user()
863 static void snd_pcm_trigger_tstamp(struct snd_pcm_substream *substream) in snd_pcm_trigger_tstamp() argument
865 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_trigger_tstamp()
868 if (runtime->trigger_master == substream) { in snd_pcm_trigger_tstamp()
879 int (*pre_action)(struct snd_pcm_substream *substream, int state);
880 int (*do_action)(struct snd_pcm_substream *substream, int state);
881 void (*undo_action)(struct snd_pcm_substream *substream, int state);
882 void (*post_action)(struct snd_pcm_substream *substream, int state);
891 struct snd_pcm_substream *substream, in snd_pcm_action_group() argument
898 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
899 if (do_lock && s != substream) { in snd_pcm_action_group()
910 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
914 snd_pcm_group_for_each_entry(s1, substream) { in snd_pcm_action_group()
924 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
930 snd_pcm_group_for_each_entry(s1, substream) { in snd_pcm_action_group()
931 if (s1 != substream) { in snd_pcm_action_group()
948 struct snd_pcm_substream *substream, in snd_pcm_action_single() argument
953 res = ops->pre_action(substream, state); in snd_pcm_action_single()
956 res = ops->do_action(substream, state); in snd_pcm_action_single()
958 ops->post_action(substream, state); in snd_pcm_action_single()
960 ops->undo_action(substream, state); in snd_pcm_action_single()
968 struct snd_pcm_substream *substream, in snd_pcm_action() argument
973 if (!snd_pcm_stream_linked(substream)) in snd_pcm_action()
974 return snd_pcm_action_single(ops, substream, state); in snd_pcm_action()
976 if (substream->pcm->nonatomic) { in snd_pcm_action()
977 if (!mutex_trylock(&substream->group->mutex)) { in snd_pcm_action()
978 mutex_unlock(&substream->self_group.mutex); in snd_pcm_action()
979 mutex_lock(&substream->group->mutex); in snd_pcm_action()
980 mutex_lock(&substream->self_group.mutex); in snd_pcm_action()
982 res = snd_pcm_action_group(ops, substream, state, 1); in snd_pcm_action()
983 mutex_unlock(&substream->group->mutex); in snd_pcm_action()
985 if (!spin_trylock(&substream->group->lock)) { in snd_pcm_action()
986 spin_unlock(&substream->self_group.lock); in snd_pcm_action()
987 spin_lock(&substream->group->lock); in snd_pcm_action()
988 spin_lock(&substream->self_group.lock); in snd_pcm_action()
990 res = snd_pcm_action_group(ops, substream, state, 1); in snd_pcm_action()
991 spin_unlock(&substream->group->lock); in snd_pcm_action()
1000 struct snd_pcm_substream *substream, in snd_pcm_action_lock_irq() argument
1005 snd_pcm_stream_lock_irq(substream); in snd_pcm_action_lock_irq()
1006 res = snd_pcm_action(ops, substream, state); in snd_pcm_action_lock_irq()
1007 snd_pcm_stream_unlock_irq(substream); in snd_pcm_action_lock_irq()
1014 struct snd_pcm_substream *substream, in snd_pcm_action_nonatomic() argument
1020 if (snd_pcm_stream_linked(substream)) in snd_pcm_action_nonatomic()
1021 res = snd_pcm_action_group(ops, substream, state, 0); in snd_pcm_action_nonatomic()
1023 res = snd_pcm_action_single(ops, substream, state); in snd_pcm_action_nonatomic()
1031 static int snd_pcm_pre_start(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_start() argument
1033 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_start()
1036 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_pre_start()
1037 !snd_pcm_playback_data(substream)) in snd_pcm_pre_start()
1040 runtime->trigger_master = substream; in snd_pcm_pre_start()
1044 static int snd_pcm_do_start(struct snd_pcm_substream *substream, int state) in snd_pcm_do_start() argument
1046 if (substream->runtime->trigger_master != substream) in snd_pcm_do_start()
1048 return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_START); in snd_pcm_do_start()
1051 static void snd_pcm_undo_start(struct snd_pcm_substream *substream, int state) in snd_pcm_undo_start() argument
1053 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_start()
1054 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); in snd_pcm_undo_start()
1057 static void snd_pcm_post_start(struct snd_pcm_substream *substream, int state) in snd_pcm_post_start() argument
1059 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_start()
1060 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_start()
1065 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_post_start()
1067 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_post_start()
1068 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSTART); in snd_pcm_post_start()
1084 int snd_pcm_start(struct snd_pcm_substream *substream) in snd_pcm_start() argument
1086 return snd_pcm_action(&snd_pcm_action_start, substream, in snd_pcm_start()
1093 static int snd_pcm_pre_stop(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_stop() argument
1095 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_stop()
1098 runtime->trigger_master = substream; in snd_pcm_pre_stop()
1102 static int snd_pcm_do_stop(struct snd_pcm_substream *substream, int state) in snd_pcm_do_stop() argument
1104 if (substream->runtime->trigger_master == substream && in snd_pcm_do_stop()
1105 snd_pcm_running(substream)) in snd_pcm_do_stop()
1106 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); in snd_pcm_do_stop()
1110 static void snd_pcm_post_stop(struct snd_pcm_substream *substream, int state) in snd_pcm_post_stop() argument
1112 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_stop()
1114 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_stop()
1116 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSTOP); in snd_pcm_post_stop()
1137 int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state) in snd_pcm_stop() argument
1139 return snd_pcm_action(&snd_pcm_action_stop, substream, state); in snd_pcm_stop()
1153 int snd_pcm_drain_done(struct snd_pcm_substream *substream) in snd_pcm_drain_done() argument
1155 return snd_pcm_action_single(&snd_pcm_action_stop, substream, in snd_pcm_drain_done()
1168 int snd_pcm_stop_xrun(struct snd_pcm_substream *substream) in snd_pcm_stop_xrun() argument
1173 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_stop_xrun()
1174 if (snd_pcm_running(substream)) in snd_pcm_stop_xrun()
1175 ret = snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); in snd_pcm_stop_xrun()
1176 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_stop_xrun()
1184 static int snd_pcm_pre_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_pre_pause() argument
1186 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_pause()
1194 runtime->trigger_master = substream; in snd_pcm_pre_pause()
1198 static int snd_pcm_do_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_do_pause() argument
1200 if (substream->runtime->trigger_master != substream) in snd_pcm_do_pause()
1205 snd_pcm_update_hw_ptr(substream); in snd_pcm_do_pause()
1210 substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000; in snd_pcm_do_pause()
1211 return substream->ops->trigger(substream, in snd_pcm_do_pause()
1216 static void snd_pcm_undo_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_undo_pause() argument
1218 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_pause()
1219 substream->ops->trigger(substream, in snd_pcm_undo_pause()
1224 static void snd_pcm_post_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_post_pause() argument
1226 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_pause()
1227 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_pause()
1230 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MPAUSE); in snd_pcm_post_pause()
1235 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MCONTINUE); in snd_pcm_post_pause()
1249 static int snd_pcm_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_pause() argument
1251 return snd_pcm_action(&snd_pcm_action_pause, substream, push); in snd_pcm_pause()
1257 static int snd_pcm_pre_suspend(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_suspend() argument
1259 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_suspend()
1262 runtime->trigger_master = substream; in snd_pcm_pre_suspend()
1266 static int snd_pcm_do_suspend(struct snd_pcm_substream *substream, int state) in snd_pcm_do_suspend() argument
1268 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_suspend()
1269 if (runtime->trigger_master != substream) in snd_pcm_do_suspend()
1271 if (! snd_pcm_running(substream)) in snd_pcm_do_suspend()
1273 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); in snd_pcm_do_suspend()
1277 static void snd_pcm_post_suspend(struct snd_pcm_substream *substream, int state) in snd_pcm_post_suspend() argument
1279 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_suspend()
1280 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_suspend()
1283 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSUSPEND); in snd_pcm_post_suspend()
1303 int snd_pcm_suspend(struct snd_pcm_substream *substream) in snd_pcm_suspend() argument
1308 if (! substream) in snd_pcm_suspend()
1311 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_suspend()
1312 err = snd_pcm_action(&snd_pcm_action_suspend, substream, 0); in snd_pcm_suspend()
1313 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_suspend()
1329 struct snd_pcm_substream *substream; in snd_pcm_suspend_all() local
1336 for (substream = pcm->streams[stream].substream; in snd_pcm_suspend_all()
1337 substream; substream = substream->next) { in snd_pcm_suspend_all()
1339 if (substream->runtime == NULL) in snd_pcm_suspend_all()
1341 err = snd_pcm_suspend(substream); in snd_pcm_suspend_all()
1353 static int snd_pcm_pre_resume(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_resume() argument
1355 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_resume()
1358 runtime->trigger_master = substream; in snd_pcm_pre_resume()
1362 static int snd_pcm_do_resume(struct snd_pcm_substream *substream, int state) in snd_pcm_do_resume() argument
1364 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_resume()
1365 if (runtime->trigger_master != substream) in snd_pcm_do_resume()
1370 substream->stream != SNDRV_PCM_STREAM_PLAYBACK)) in snd_pcm_do_resume()
1372 return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_RESUME); in snd_pcm_do_resume()
1375 static void snd_pcm_undo_resume(struct snd_pcm_substream *substream, int state) in snd_pcm_undo_resume() argument
1377 if (substream->runtime->trigger_master == substream && in snd_pcm_undo_resume()
1378 snd_pcm_running(substream)) in snd_pcm_undo_resume()
1379 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); in snd_pcm_undo_resume()
1382 static void snd_pcm_post_resume(struct snd_pcm_substream *substream, int state) in snd_pcm_post_resume() argument
1384 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_resume()
1385 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_resume()
1387 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MRESUME); in snd_pcm_post_resume()
1397 static int snd_pcm_resume(struct snd_pcm_substream *substream) in snd_pcm_resume() argument
1399 struct snd_card *card = substream->pcm->card; in snd_pcm_resume()
1404 res = snd_pcm_action_lock_irq(&snd_pcm_action_resume, substream, 0); in snd_pcm_resume()
1411 static int snd_pcm_resume(struct snd_pcm_substream *substream) in snd_pcm_resume() argument
1423 static int snd_pcm_xrun(struct snd_pcm_substream *substream) in snd_pcm_xrun() argument
1425 struct snd_card *card = substream->pcm->card; in snd_pcm_xrun()
1426 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xrun()
1436 snd_pcm_stream_lock_irq(substream); in snd_pcm_xrun()
1442 result = snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); in snd_pcm_xrun()
1447 snd_pcm_stream_unlock_irq(substream); in snd_pcm_xrun()
1456 static int snd_pcm_pre_reset(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_reset() argument
1458 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_reset()
1470 static int snd_pcm_do_reset(struct snd_pcm_substream *substream, int state) in snd_pcm_do_reset() argument
1472 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_reset()
1473 int err = substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL); in snd_pcm_do_reset()
1484 static void snd_pcm_post_reset(struct snd_pcm_substream *substream, int state) in snd_pcm_post_reset() argument
1486 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_reset()
1488 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_post_reset()
1490 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_post_reset()
1499 static int snd_pcm_reset(struct snd_pcm_substream *substream) in snd_pcm_reset() argument
1501 return snd_pcm_action_nonatomic(&snd_pcm_action_reset, substream, 0); in snd_pcm_reset()
1508 static int snd_pcm_pre_prepare(struct snd_pcm_substream *substream, in snd_pcm_pre_prepare() argument
1511 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_prepare()
1515 if (snd_pcm_running(substream)) in snd_pcm_pre_prepare()
1517 substream->f_flags = f_flags; in snd_pcm_pre_prepare()
1521 static int snd_pcm_do_prepare(struct snd_pcm_substream *substream, int state) in snd_pcm_do_prepare() argument
1524 err = substream->ops->prepare(substream); in snd_pcm_do_prepare()
1527 return snd_pcm_do_reset(substream, 0); in snd_pcm_do_prepare()
1530 static void snd_pcm_post_prepare(struct snd_pcm_substream *substream, int state) in snd_pcm_post_prepare() argument
1532 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_prepare()
1534 snd_pcm_set_state(substream, SNDRV_PCM_STATE_PREPARED); in snd_pcm_post_prepare()
1550 static int snd_pcm_prepare(struct snd_pcm_substream *substream, in snd_pcm_prepare() argument
1554 struct snd_card *card = substream->pcm->card; in snd_pcm_prepare()
1560 f_flags = substream->f_flags; in snd_pcm_prepare()
1565 substream, f_flags); in snd_pcm_prepare()
1574 static int snd_pcm_pre_drain_init(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_drain_init() argument
1576 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_drain_init()
1583 runtime->trigger_master = substream; in snd_pcm_pre_drain_init()
1587 static int snd_pcm_do_drain_init(struct snd_pcm_substream *substream, int state) in snd_pcm_do_drain_init() argument
1589 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_drain_init()
1590 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_do_drain_init()
1594 if (! snd_pcm_playback_empty(substream)) { in snd_pcm_do_drain_init()
1595 snd_pcm_do_start(substream, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
1596 snd_pcm_post_start(substream, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
1615 snd_pcm_do_stop(substream, new_state); in snd_pcm_do_drain_init()
1616 snd_pcm_post_stop(substream, new_state); in snd_pcm_do_drain_init()
1621 runtime->trigger_master == substream && in snd_pcm_do_drain_init()
1623 return substream->ops->trigger(substream, in snd_pcm_do_drain_init()
1629 static void snd_pcm_post_drain_init(struct snd_pcm_substream *substream, int state) in snd_pcm_post_drain_init() argument
1639 static int snd_pcm_drop(struct snd_pcm_substream *substream);
1648 static int snd_pcm_drain(struct snd_pcm_substream *substream, in snd_pcm_drain() argument
1658 card = substream->pcm->card; in snd_pcm_drain()
1659 runtime = substream->runtime; in snd_pcm_drain()
1676 } else if (substream->f_flags & O_NONBLOCK) in snd_pcm_drain()
1680 snd_pcm_stream_lock_irq(substream); in snd_pcm_drain()
1683 snd_pcm_pause(substream, 0); in snd_pcm_drain()
1686 result = snd_pcm_action(&snd_pcm_action_drain_init, substream, 0); in snd_pcm_drain()
1704 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_drain()
1717 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drain()
1733 snd_pcm_stream_lock_irq(substream); in snd_pcm_drain()
1740 if (substream->runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) in snd_pcm_drain()
1743 dev_dbg(substream->pcm->card->dev, in snd_pcm_drain()
1745 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_drain()
1753 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drain()
1765 static int snd_pcm_drop(struct snd_pcm_substream *substream) in snd_pcm_drop() argument
1770 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_drop()
1772 runtime = substream->runtime; in snd_pcm_drop()
1779 snd_pcm_stream_lock_irq(substream); in snd_pcm_drop()
1782 snd_pcm_pause(substream, 0); in snd_pcm_drop()
1784 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_drop()
1786 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drop()
1807 static int snd_pcm_link(struct snd_pcm_substream *substream, int fd) in snd_pcm_link() argument
1822 substream1 = pcm_file->substream; in snd_pcm_link()
1830 if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_link()
1831 substream->runtime->status->state != substream1->runtime->status->state || in snd_pcm_link()
1832 substream->pcm->nonatomic != substream1->pcm->nonatomic) { in snd_pcm_link()
1840 if (!snd_pcm_stream_linked(substream)) { in snd_pcm_link()
1841 substream->group = group; in snd_pcm_link()
1843 spin_lock_init(&substream->group->lock); in snd_pcm_link()
1844 mutex_init(&substream->group->mutex); in snd_pcm_link()
1845 INIT_LIST_HEAD(&substream->group->substreams); in snd_pcm_link()
1846 list_add_tail(&substream->link_list, &substream->group->substreams); in snd_pcm_link()
1847 substream->group->count = 1; in snd_pcm_link()
1849 list_add_tail(&substream1->link_list, &substream->group->substreams); in snd_pcm_link()
1850 substream->group->count++; in snd_pcm_link()
1851 substream1->group = substream->group; in snd_pcm_link()
1863 static void relink_to_local(struct snd_pcm_substream *substream) in relink_to_local() argument
1865 substream->group = &substream->self_group; in relink_to_local()
1866 INIT_LIST_HEAD(&substream->self_group.substreams); in relink_to_local()
1867 list_add_tail(&substream->link_list, &substream->self_group.substreams); in relink_to_local()
1870 static int snd_pcm_unlink(struct snd_pcm_substream *substream) in snd_pcm_unlink() argument
1877 if (!snd_pcm_stream_linked(substream)) { in snd_pcm_unlink()
1881 list_del(&substream->link_list); in snd_pcm_unlink()
1882 substream->group->count--; in snd_pcm_unlink()
1883 if (substream->group->count == 1) { /* detach the last stream, too */ in snd_pcm_unlink()
1884 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_unlink()
1888 kfree(substream->group); in snd_pcm_unlink()
1890 relink_to_local(substream); in snd_pcm_unlink()
2009 struct snd_pcm_substream *substream = rule->private; in snd_pcm_hw_rule_buffer_bytes_max() local
2011 t.max = substream->buffer_bytes_max; in snd_pcm_hw_rule_buffer_bytes_max()
2018 int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream) in snd_pcm_hw_constraints_init() argument
2020 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_init()
2142 int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) in snd_pcm_hw_constraints_complete() argument
2144 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_complete()
2153 if (hw_support_mmap(substream)) { in snd_pcm_hw_constraints_complete()
2199 snd_pcm_hw_rule_buffer_bytes_max, substream, in snd_pcm_hw_constraints_complete()
2225 static void pcm_release_private(struct snd_pcm_substream *substream) in pcm_release_private() argument
2227 snd_pcm_unlink(substream); in pcm_release_private()
2230 void snd_pcm_release_substream(struct snd_pcm_substream *substream) in snd_pcm_release_substream() argument
2232 substream->ref_count--; in snd_pcm_release_substream()
2233 if (substream->ref_count > 0) in snd_pcm_release_substream()
2236 snd_pcm_drop(substream); in snd_pcm_release_substream()
2237 if (substream->hw_opened) { in snd_pcm_release_substream()
2238 if (substream->ops->hw_free && in snd_pcm_release_substream()
2239 substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) in snd_pcm_release_substream()
2240 substream->ops->hw_free(substream); in snd_pcm_release_substream()
2241 substream->ops->close(substream); in snd_pcm_release_substream()
2242 substream->hw_opened = 0; in snd_pcm_release_substream()
2244 if (pm_qos_request_active(&substream->latency_pm_qos_req)) in snd_pcm_release_substream()
2245 pm_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_release_substream()
2246 if (substream->pcm_release) { in snd_pcm_release_substream()
2247 substream->pcm_release(substream); in snd_pcm_release_substream()
2248 substream->pcm_release = NULL; in snd_pcm_release_substream()
2250 snd_pcm_detach_substream(substream); in snd_pcm_release_substream()
2259 struct snd_pcm_substream *substream; in snd_pcm_open_substream() local
2262 err = snd_pcm_attach_substream(pcm, stream, file, &substream); in snd_pcm_open_substream()
2265 if (substream->ref_count > 1) { in snd_pcm_open_substream()
2266 *rsubstream = substream; in snd_pcm_open_substream()
2270 err = snd_pcm_hw_constraints_init(substream); in snd_pcm_open_substream()
2276 if ((err = substream->ops->open(substream)) < 0) in snd_pcm_open_substream()
2279 substream->hw_opened = 1; in snd_pcm_open_substream()
2281 err = snd_pcm_hw_constraints_complete(substream); in snd_pcm_open_substream()
2287 *rsubstream = substream; in snd_pcm_open_substream()
2291 snd_pcm_release_substream(substream); in snd_pcm_open_substream()
2302 struct snd_pcm_substream *substream; in snd_pcm_open_file() local
2305 err = snd_pcm_open_substream(pcm, stream, file, &substream); in snd_pcm_open_file()
2311 snd_pcm_release_substream(substream); in snd_pcm_open_file()
2314 pcm_file->substream = substream; in snd_pcm_open_file()
2315 if (substream->ref_count == 1) { in snd_pcm_open_file()
2316 substream->file = pcm_file; in snd_pcm_open_file()
2317 substream->pcm_release = pcm_release_private; in snd_pcm_open_file()
2412 struct snd_pcm_substream *substream; in snd_pcm_release() local
2416 substream = pcm_file->substream; in snd_pcm_release()
2417 if (snd_BUG_ON(!substream)) in snd_pcm_release()
2419 pcm = substream->pcm; in snd_pcm_release()
2421 snd_pcm_release_substream(substream); in snd_pcm_release()
2430 static snd_pcm_sframes_t snd_pcm_playback_rewind(struct snd_pcm_substream *substream, in snd_pcm_playback_rewind() argument
2433 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_playback_rewind()
2441 snd_pcm_stream_lock_irq(substream); in snd_pcm_playback_rewind()
2447 if (snd_pcm_update_hw_ptr(substream) >= 0) in snd_pcm_playback_rewind()
2474 snd_pcm_stream_unlock_irq(substream); in snd_pcm_playback_rewind()
2478 static snd_pcm_sframes_t snd_pcm_capture_rewind(struct snd_pcm_substream *substream, in snd_pcm_capture_rewind() argument
2481 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_capture_rewind()
2489 snd_pcm_stream_lock_irq(substream); in snd_pcm_capture_rewind()
2495 if (snd_pcm_update_hw_ptr(substream) >= 0) in snd_pcm_capture_rewind()
2522 snd_pcm_stream_unlock_irq(substream); in snd_pcm_capture_rewind()
2526 static snd_pcm_sframes_t snd_pcm_playback_forward(struct snd_pcm_substream *substream, in snd_pcm_playback_forward() argument
2529 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_playback_forward()
2537 snd_pcm_stream_lock_irq(substream); in snd_pcm_playback_forward()
2544 if (snd_pcm_update_hw_ptr(substream) >= 0) in snd_pcm_playback_forward()
2571 snd_pcm_stream_unlock_irq(substream); in snd_pcm_playback_forward()
2575 static snd_pcm_sframes_t snd_pcm_capture_forward(struct snd_pcm_substream *substream, in snd_pcm_capture_forward() argument
2578 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_capture_forward()
2586 snd_pcm_stream_lock_irq(substream); in snd_pcm_capture_forward()
2593 if (snd_pcm_update_hw_ptr(substream) >= 0) in snd_pcm_capture_forward()
2620 snd_pcm_stream_unlock_irq(substream); in snd_pcm_capture_forward()
2624 static int snd_pcm_hwsync(struct snd_pcm_substream *substream) in snd_pcm_hwsync() argument
2626 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hwsync()
2629 snd_pcm_stream_lock_irq(substream); in snd_pcm_hwsync()
2632 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in snd_pcm_hwsync()
2636 if ((err = snd_pcm_update_hw_ptr(substream)) < 0) in snd_pcm_hwsync()
2651 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hwsync()
2655 static int snd_pcm_delay(struct snd_pcm_substream *substream, in snd_pcm_delay() argument
2658 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_delay()
2662 snd_pcm_stream_lock_irq(substream); in snd_pcm_delay()
2665 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in snd_pcm_delay()
2669 if ((err = snd_pcm_update_hw_ptr(substream)) < 0) in snd_pcm_delay()
2675 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_delay()
2689 snd_pcm_stream_unlock_irq(substream); in snd_pcm_delay()
2696 static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream, in snd_pcm_sync_ptr() argument
2699 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_sync_ptr()
2713 err = snd_pcm_hwsync(substream); in snd_pcm_sync_ptr()
2717 snd_pcm_stream_lock_irq(substream); in snd_pcm_sync_ptr()
2730 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sync_ptr()
2736 static int snd_pcm_tstamp(struct snd_pcm_substream *substream, int __user *_arg) in snd_pcm_tstamp() argument
2738 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_tstamp()
2750 struct snd_pcm_substream *substream, in snd_pcm_common_ioctl1() argument
2757 return snd_pcm_info_user(substream, arg); in snd_pcm_common_ioctl1()
2761 return snd_pcm_tstamp(substream, arg); in snd_pcm_common_ioctl1()
2763 return snd_pcm_hw_refine_user(substream, arg); in snd_pcm_common_ioctl1()
2765 return snd_pcm_hw_params_user(substream, arg); in snd_pcm_common_ioctl1()
2767 return snd_pcm_hw_free(substream); in snd_pcm_common_ioctl1()
2769 return snd_pcm_sw_params_user(substream, arg); in snd_pcm_common_ioctl1()
2771 return snd_pcm_status_user(substream, arg, false); in snd_pcm_common_ioctl1()
2773 return snd_pcm_status_user(substream, arg, true); in snd_pcm_common_ioctl1()
2775 return snd_pcm_channel_info_user(substream, arg); in snd_pcm_common_ioctl1()
2777 return snd_pcm_prepare(substream, file); in snd_pcm_common_ioctl1()
2779 return snd_pcm_reset(substream); in snd_pcm_common_ioctl1()
2781 return snd_pcm_action_lock_irq(&snd_pcm_action_start, substream, SNDRV_PCM_STATE_RUNNING); in snd_pcm_common_ioctl1()
2783 return snd_pcm_link(substream, (int)(unsigned long) arg); in snd_pcm_common_ioctl1()
2785 return snd_pcm_unlink(substream); in snd_pcm_common_ioctl1()
2787 return snd_pcm_resume(substream); in snd_pcm_common_ioctl1()
2789 return snd_pcm_xrun(substream); in snd_pcm_common_ioctl1()
2791 return snd_pcm_hwsync(substream); in snd_pcm_common_ioctl1()
2793 return snd_pcm_delay(substream, arg); in snd_pcm_common_ioctl1()
2795 return snd_pcm_sync_ptr(substream, arg); in snd_pcm_common_ioctl1()
2798 return snd_pcm_hw_refine_old_user(substream, arg); in snd_pcm_common_ioctl1()
2800 return snd_pcm_hw_params_old_user(substream, arg); in snd_pcm_common_ioctl1()
2803 return snd_pcm_drain(substream, file); in snd_pcm_common_ioctl1()
2805 return snd_pcm_drop(substream); in snd_pcm_common_ioctl1()
2809 snd_pcm_stream_lock_irq(substream); in snd_pcm_common_ioctl1()
2810 res = snd_pcm_pause(substream, (int)(unsigned long)arg); in snd_pcm_common_ioctl1()
2811 snd_pcm_stream_unlock_irq(substream); in snd_pcm_common_ioctl1()
2815 pcm_dbg(substream->pcm, "unknown ioctl = 0x%x\n", cmd); in snd_pcm_common_ioctl1()
2820 struct snd_pcm_substream *substream, in snd_pcm_playback_ioctl1() argument
2823 if (snd_BUG_ON(!substream)) in snd_pcm_playback_ioctl1()
2825 if (snd_BUG_ON(substream->stream != SNDRV_PCM_STREAM_PLAYBACK)) in snd_pcm_playback_ioctl1()
2832 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_playback_ioctl1()
2840 result = snd_pcm_lib_write(substream, xferi.buf, xferi.frames); in snd_pcm_playback_ioctl1()
2848 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_playback_ioctl1()
2864 result = snd_pcm_lib_writev(substream, bufs, xfern.frames); in snd_pcm_playback_ioctl1()
2878 result = snd_pcm_playback_rewind(substream, frames); in snd_pcm_playback_ioctl1()
2891 result = snd_pcm_playback_forward(substream, frames); in snd_pcm_playback_ioctl1()
2896 return snd_pcm_common_ioctl1(file, substream, cmd, arg); in snd_pcm_playback_ioctl1()
2900 struct snd_pcm_substream *substream, in snd_pcm_capture_ioctl1() argument
2903 if (snd_BUG_ON(!substream)) in snd_pcm_capture_ioctl1()
2905 if (snd_BUG_ON(substream->stream != SNDRV_PCM_STREAM_CAPTURE)) in snd_pcm_capture_ioctl1()
2912 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_capture_ioctl1()
2920 result = snd_pcm_lib_read(substream, xferi.buf, xferi.frames); in snd_pcm_capture_ioctl1()
2928 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_capture_ioctl1()
2944 result = snd_pcm_lib_readv(substream, bufs, xfern.frames); in snd_pcm_capture_ioctl1()
2958 result = snd_pcm_capture_rewind(substream, frames); in snd_pcm_capture_ioctl1()
2971 result = snd_pcm_capture_forward(substream, frames); in snd_pcm_capture_ioctl1()
2976 return snd_pcm_common_ioctl1(file, substream, cmd, arg); in snd_pcm_capture_ioctl1()
2989 return snd_pcm_playback_ioctl1(file, pcm_file->substream, cmd, in snd_pcm_playback_ioctl()
3003 return snd_pcm_capture_ioctl1(file, pcm_file->substream, cmd, in snd_pcm_capture_ioctl()
3007 int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, in snd_pcm_kernel_ioctl() argument
3014 switch (substream->stream) { in snd_pcm_kernel_ioctl()
3016 result = snd_pcm_playback_ioctl1(NULL, substream, cmd, in snd_pcm_kernel_ioctl()
3020 result = snd_pcm_capture_ioctl1(NULL, substream, cmd, in snd_pcm_kernel_ioctl()
3037 struct snd_pcm_substream *substream; in snd_pcm_read() local
3042 substream = pcm_file->substream; in snd_pcm_read()
3043 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_read()
3045 runtime = substream->runtime; in snd_pcm_read()
3051 result = snd_pcm_lib_read(substream, buf, count); in snd_pcm_read()
3061 struct snd_pcm_substream *substream; in snd_pcm_write() local
3066 substream = pcm_file->substream; in snd_pcm_write()
3067 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_write()
3069 runtime = substream->runtime; in snd_pcm_write()
3075 result = snd_pcm_lib_write(substream, buf, count); in snd_pcm_write()
3084 struct snd_pcm_substream *substream; in snd_pcm_readv() local
3092 substream = pcm_file->substream; in snd_pcm_readv()
3093 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_readv()
3095 runtime = substream->runtime; in snd_pcm_readv()
3110 result = snd_pcm_lib_readv(substream, bufs, frames); in snd_pcm_readv()
3120 struct snd_pcm_substream *substream; in snd_pcm_writev() local
3128 substream = pcm_file->substream; in snd_pcm_writev()
3129 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_writev()
3131 runtime = substream->runtime; in snd_pcm_writev()
3145 result = snd_pcm_lib_writev(substream, bufs, frames); in snd_pcm_writev()
3155 struct snd_pcm_substream *substream; in snd_pcm_playback_poll() local
3162 substream = pcm_file->substream; in snd_pcm_playback_poll()
3163 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_playback_poll()
3165 runtime = substream->runtime; in snd_pcm_playback_poll()
3169 snd_pcm_stream_lock_irq(substream); in snd_pcm_playback_poll()
3187 snd_pcm_stream_unlock_irq(substream); in snd_pcm_playback_poll()
3194 struct snd_pcm_substream *substream; in snd_pcm_capture_poll() local
3201 substream = pcm_file->substream; in snd_pcm_capture_poll()
3202 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_capture_poll()
3204 runtime = substream->runtime; in snd_pcm_capture_poll()
3208 snd_pcm_stream_lock_irq(substream); in snd_pcm_capture_poll()
3230 snd_pcm_stream_unlock_irq(substream); in snd_pcm_capture_poll()
3249 struct snd_pcm_substream *substream = area->vm_private_data; in snd_pcm_mmap_status_fault() local
3252 if (substream == NULL) in snd_pcm_mmap_status_fault()
3254 runtime = substream->runtime; in snd_pcm_mmap_status_fault()
3265 static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_status() argument
3275 area->vm_private_data = substream; in snd_pcm_mmap_status()
3286 struct snd_pcm_substream *substream = area->vm_private_data; in snd_pcm_mmap_control_fault() local
3289 if (substream == NULL) in snd_pcm_mmap_control_fault()
3291 runtime = substream->runtime; in snd_pcm_mmap_control_fault()
3302 static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_control() argument
3312 area->vm_private_data = substream; in snd_pcm_mmap_control()
3320 static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_status() argument
3325 static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_control() argument
3333 snd_pcm_default_page_ops(struct snd_pcm_substream *substream, unsigned long ofs) in snd_pcm_default_page_ops() argument
3335 void *vaddr = substream->runtime->dma_area + ofs; in snd_pcm_default_page_ops()
3345 struct snd_pcm_substream *substream = area->vm_private_data; in snd_pcm_mmap_data_fault() local
3351 if (substream == NULL) in snd_pcm_mmap_data_fault()
3353 runtime = substream->runtime; in snd_pcm_mmap_data_fault()
3358 if (substream->ops->page) in snd_pcm_mmap_data_fault()
3359 page = substream->ops->page(substream, offset); in snd_pcm_mmap_data_fault()
3361 page = snd_pcm_default_page_ops(substream, offset); in snd_pcm_mmap_data_fault()
3392 int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream, in snd_pcm_lib_default_mmap() argument
3397 if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV_IRAM) { in snd_pcm_lib_default_mmap()
3400 substream->dma_buffer.addr >> PAGE_SHIFT, in snd_pcm_lib_default_mmap()
3405 if (!substream->ops->page && in snd_pcm_lib_default_mmap()
3406 substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) in snd_pcm_lib_default_mmap()
3407 return dma_mmap_coherent(substream->dma_buffer.dev.dev, in snd_pcm_lib_default_mmap()
3409 substream->runtime->dma_area, in snd_pcm_lib_default_mmap()
3410 substream->runtime->dma_addr, in snd_pcm_lib_default_mmap()
3432 int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, in snd_pcm_lib_mmap_iomem() argument
3435 struct snd_pcm_runtime *runtime = substream->runtime;; in snd_pcm_lib_mmap_iomem()
3447 int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_data() argument
3456 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_mmap_data()
3463 runtime = substream->runtime; in snd_pcm_mmap_data()
3480 area->vm_private_data = substream; in snd_pcm_mmap_data()
3481 if (substream->ops->mmap) in snd_pcm_mmap_data()
3482 err = substream->ops->mmap(substream, area); in snd_pcm_mmap_data()
3484 err = snd_pcm_lib_default_mmap(substream, area); in snd_pcm_mmap_data()
3486 atomic_inc(&substream->mmap_count); in snd_pcm_mmap_data()
3495 struct snd_pcm_substream *substream; in snd_pcm_mmap() local
3499 substream = pcm_file->substream; in snd_pcm_mmap()
3500 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_mmap()
3508 return snd_pcm_mmap_status(substream, file, area); in snd_pcm_mmap()
3512 return snd_pcm_mmap_control(substream, file, area); in snd_pcm_mmap()
3514 return snd_pcm_mmap_data(substream, file, area); in snd_pcm_mmap()
3522 struct snd_pcm_substream *substream; in snd_pcm_fasync() local
3526 substream = pcm_file->substream; in snd_pcm_fasync()
3527 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_fasync()
3529 runtime = substream->runtime; in snd_pcm_fasync()
3588 static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, in snd_pcm_hw_refine_old_user() argument
3605 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_refine_old_user()
3618 static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, in snd_pcm_hw_params_old_user() argument
3635 err = snd_pcm_hw_params(substream, params); in snd_pcm_hw_params_old_user()
3657 struct snd_pcm_substream *substream = pcm_file->substream; in snd_pcm_get_unmapped_area() local
3658 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_get_unmapped_area()