Lines Matching refs:substream
34 #define trace_hw_mask_param(substream, type, index, prev, curr) argument
35 #define trace_hw_interval_param(substream, type, index, prev, curr) argument
62 static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream,
64 static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream,
106 void snd_pcm_stream_lock(struct snd_pcm_substream *substream) in snd_pcm_stream_lock() argument
108 snd_pcm_group_lock(&substream->self_group, substream->pcm->nonatomic); in snd_pcm_stream_lock()
118 void snd_pcm_stream_unlock(struct snd_pcm_substream *substream) in snd_pcm_stream_unlock() argument
120 snd_pcm_group_unlock(&substream->self_group, substream->pcm->nonatomic); in snd_pcm_stream_unlock()
132 void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream) in snd_pcm_stream_lock_irq() argument
134 snd_pcm_group_lock_irq(&substream->self_group, in snd_pcm_stream_lock_irq()
135 substream->pcm->nonatomic); in snd_pcm_stream_lock_irq()
145 void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream) in snd_pcm_stream_unlock_irq() argument
147 snd_pcm_group_unlock_irq(&substream->self_group, in snd_pcm_stream_unlock_irq()
148 substream->pcm->nonatomic); in snd_pcm_stream_unlock_irq()
152 unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream) in _snd_pcm_stream_lock_irqsave() argument
155 if (substream->pcm->nonatomic) in _snd_pcm_stream_lock_irqsave()
156 mutex_lock(&substream->self_group.mutex); in _snd_pcm_stream_lock_irqsave()
158 spin_lock_irqsave(&substream->self_group.lock, flags); in _snd_pcm_stream_lock_irqsave()
170 void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream, in snd_pcm_stream_unlock_irqrestore() argument
173 if (substream->pcm->nonatomic) in snd_pcm_stream_unlock_irqrestore()
174 mutex_unlock(&substream->self_group.mutex); in snd_pcm_stream_unlock_irqrestore()
176 spin_unlock_irqrestore(&substream->self_group.lock, flags); in snd_pcm_stream_unlock_irqrestore()
180 int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info) in snd_pcm_info() argument
182 struct snd_pcm *pcm = substream->pcm; in snd_pcm_info()
183 struct snd_pcm_str *pstr = substream->pstr; in snd_pcm_info()
188 info->stream = substream->stream; in snd_pcm_info()
189 info->subdevice = substream->number; in snd_pcm_info()
196 strlcpy(info->subname, substream->name, sizeof(info->subname)); in snd_pcm_info()
201 int snd_pcm_info_user(struct snd_pcm_substream *substream, in snd_pcm_info_user() argument
210 err = snd_pcm_info(substream, info); in snd_pcm_info_user()
219 static bool hw_support_mmap(struct snd_pcm_substream *substream) in hw_support_mmap() argument
221 if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_MMAP)) in hw_support_mmap()
224 if (substream->ops->mmap || in hw_support_mmap()
225 substream->dma_buffer.dev.type != SNDRV_DMA_TYPE_DEV) in hw_support_mmap()
228 return dma_can_mmap(substream->dma_buffer.dev.dev); in hw_support_mmap()
231 static int constrain_mask_params(struct snd_pcm_substream *substream, in constrain_mask_params() argument
235 &substream->runtime->hw_constraints; in constrain_mask_params()
260 trace_hw_mask_param(substream, k, 0, &old_mask, m); in constrain_mask_params()
267 static int constrain_interval_params(struct snd_pcm_substream *substream, in constrain_interval_params() argument
271 &substream->runtime->hw_constraints; in constrain_interval_params()
296 trace_hw_interval_param(substream, k, 0, &old_interval, i); in constrain_interval_params()
303 static int constrain_params_by_rules(struct snd_pcm_substream *substream, in constrain_params_by_rules() argument
307 &substream->runtime->hw_constraints; in constrain_params_by_rules()
397 trace_hw_mask_param(substream, r->var, in constrain_params_by_rules()
402 trace_hw_interval_param(substream, r->var, in constrain_params_by_rules()
424 static int fixup_unreferenced_params(struct snd_pcm_substream *substream, in fixup_unreferenced_params() argument
449 err = substream->ops->ioctl(substream, in fixup_unreferenced_params()
457 params->info = substream->runtime->hw.info; in fixup_unreferenced_params()
460 if (!hw_support_mmap(substream)) in fixup_unreferenced_params()
468 int snd_pcm_hw_refine(struct snd_pcm_substream *substream, in snd_pcm_hw_refine() argument
482 err = constrain_mask_params(substream, params); in snd_pcm_hw_refine()
486 err = constrain_interval_params(substream, params); in snd_pcm_hw_refine()
490 err = constrain_params_by_rules(substream, params); in snd_pcm_hw_refine()
500 static int snd_pcm_hw_refine_user(struct snd_pcm_substream *substream, in snd_pcm_hw_refine_user() argument
510 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_refine_user()
514 err = fixup_unreferenced_params(substream, params); in snd_pcm_hw_refine_user()
540 static void snd_pcm_set_state(struct snd_pcm_substream *substream, int state) in snd_pcm_set_state() argument
542 snd_pcm_stream_lock_irq(substream); in snd_pcm_set_state()
543 if (substream->runtime->status->state != SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_set_state()
544 substream->runtime->status->state = state; in snd_pcm_set_state()
545 snd_pcm_stream_unlock_irq(substream); in snd_pcm_set_state()
548 static inline void snd_pcm_timer_notify(struct snd_pcm_substream *substream, in snd_pcm_timer_notify() argument
552 if (substream->timer) in snd_pcm_timer_notify()
553 snd_timer_notify(substream->timer, event, in snd_pcm_timer_notify()
554 &substream->runtime->trigger_tstamp); in snd_pcm_timer_notify()
622 static int snd_pcm_hw_params(struct snd_pcm_substream *substream, in snd_pcm_hw_params() argument
630 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_hw_params()
632 runtime = substream->runtime; in snd_pcm_hw_params()
633 snd_pcm_stream_lock_irq(substream); in snd_pcm_hw_params()
640 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_params()
643 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_params()
645 if (!substream->oss.oss) in snd_pcm_hw_params()
647 if (atomic_read(&substream->mmap_count)) in snd_pcm_hw_params()
651 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_params()
655 err = snd_pcm_hw_params_choose(substream, params); in snd_pcm_hw_params()
659 err = fixup_unreferenced_params(substream, params); in snd_pcm_hw_params()
663 if (substream->ops->hw_params != NULL) { in snd_pcm_hw_params()
664 err = substream->ops->hw_params(substream, params); in snd_pcm_hw_params()
708 snd_pcm_timer_resolution_change(substream); in snd_pcm_hw_params()
709 snd_pcm_set_state(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_hw_params()
711 if (pm_qos_request_active(&substream->latency_pm_qos_req)) in snd_pcm_hw_params()
712 pm_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_hw_params()
714 pm_qos_add_request(&substream->latency_pm_qos_req, in snd_pcm_hw_params()
721 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); in snd_pcm_hw_params()
722 if (substream->ops->hw_free != NULL) in snd_pcm_hw_params()
723 substream->ops->hw_free(substream); in snd_pcm_hw_params()
727 static int snd_pcm_hw_params_user(struct snd_pcm_substream *substream, in snd_pcm_hw_params_user() argument
737 err = snd_pcm_hw_params(substream, params); in snd_pcm_hw_params_user()
748 static int snd_pcm_hw_free(struct snd_pcm_substream *substream) in snd_pcm_hw_free() argument
753 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_hw_free()
755 runtime = substream->runtime; in snd_pcm_hw_free()
756 snd_pcm_stream_lock_irq(substream); in snd_pcm_hw_free()
762 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_free()
765 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_free()
766 if (atomic_read(&substream->mmap_count)) in snd_pcm_hw_free()
768 if (substream->ops->hw_free) in snd_pcm_hw_free()
769 result = substream->ops->hw_free(substream); in snd_pcm_hw_free()
770 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); in snd_pcm_hw_free()
771 pm_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_hw_free()
775 static int snd_pcm_sw_params(struct snd_pcm_substream *substream, in snd_pcm_sw_params() argument
781 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_sw_params()
783 runtime = substream->runtime; in snd_pcm_sw_params()
784 snd_pcm_stream_lock_irq(substream); in snd_pcm_sw_params()
786 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sw_params()
789 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sw_params()
809 snd_pcm_stream_lock_irq(substream); in snd_pcm_sw_params()
820 if (snd_pcm_running(substream)) { in snd_pcm_sw_params()
821 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_sw_params()
823 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_sw_params()
824 err = snd_pcm_update_state(substream, runtime); in snd_pcm_sw_params()
826 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sw_params()
830 static int snd_pcm_sw_params_user(struct snd_pcm_substream *substream, in snd_pcm_sw_params_user() argument
837 err = snd_pcm_sw_params(substream, ¶ms); in snd_pcm_sw_params_user()
844 snd_pcm_calc_delay(struct snd_pcm_substream *substream) in snd_pcm_calc_delay() argument
848 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_calc_delay()
849 delay = snd_pcm_playback_hw_avail(substream->runtime); in snd_pcm_calc_delay()
851 delay = snd_pcm_capture_avail(substream->runtime); in snd_pcm_calc_delay()
852 return delay + substream->runtime->delay; in snd_pcm_calc_delay()
855 int snd_pcm_status(struct snd_pcm_substream *substream, in snd_pcm_status() argument
858 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_status()
860 snd_pcm_stream_lock_irq(substream); in snd_pcm_status()
883 if (snd_pcm_running(substream)) { in snd_pcm_status()
884 snd_pcm_update_hw_ptr(substream); in snd_pcm_status()
906 status->avail = snd_pcm_avail(substream); in snd_pcm_status()
907 status->delay = snd_pcm_running(substream) ? in snd_pcm_status()
908 snd_pcm_calc_delay(substream) : 0; in snd_pcm_status()
914 snd_pcm_stream_unlock_irq(substream); in snd_pcm_status()
918 static int snd_pcm_status_user(struct snd_pcm_substream *substream, in snd_pcm_status_user() argument
934 res = snd_pcm_status(substream, &status); in snd_pcm_status_user()
942 static int snd_pcm_channel_info(struct snd_pcm_substream *substream, in snd_pcm_channel_info() argument
949 runtime = substream->runtime; in snd_pcm_channel_info()
950 snd_pcm_stream_lock_irq(substream); in snd_pcm_channel_info()
952 snd_pcm_stream_unlock_irq(substream); in snd_pcm_channel_info()
955 snd_pcm_stream_unlock_irq(substream); in snd_pcm_channel_info()
960 return substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_CHANNEL_INFO, info); in snd_pcm_channel_info()
963 static int snd_pcm_channel_info_user(struct snd_pcm_substream *substream, in snd_pcm_channel_info_user() argument
971 res = snd_pcm_channel_info(substream, &info); in snd_pcm_channel_info_user()
979 static void snd_pcm_trigger_tstamp(struct snd_pcm_substream *substream) in snd_pcm_trigger_tstamp() argument
981 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_trigger_tstamp()
984 if (runtime->trigger_master == substream) { in snd_pcm_trigger_tstamp()
995 int (*pre_action)(struct snd_pcm_substream *substream, int state);
996 int (*do_action)(struct snd_pcm_substream *substream, int state);
997 void (*undo_action)(struct snd_pcm_substream *substream, int state);
998 void (*post_action)(struct snd_pcm_substream *substream, int state);
1007 struct snd_pcm_substream *substream, in snd_pcm_action_group() argument
1014 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
1015 if (do_lock && s != substream) { in snd_pcm_action_group()
1026 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
1030 snd_pcm_group_for_each_entry(s1, substream) { in snd_pcm_action_group()
1040 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
1046 snd_pcm_group_for_each_entry(s1, substream) { in snd_pcm_action_group()
1047 if (s1 != substream) { in snd_pcm_action_group()
1064 struct snd_pcm_substream *substream, in snd_pcm_action_single() argument
1069 res = ops->pre_action(substream, state); in snd_pcm_action_single()
1072 res = ops->do_action(substream, state); in snd_pcm_action_single()
1074 ops->post_action(substream, state); in snd_pcm_action_single()
1076 ops->undo_action(substream, state); in snd_pcm_action_single()
1080 static void snd_pcm_group_assign(struct snd_pcm_substream *substream, in snd_pcm_group_assign() argument
1083 substream->group = new_group; in snd_pcm_group_assign()
1084 list_move(&substream->link_list, &new_group->substreams); in snd_pcm_group_assign()
1092 struct snd_pcm_substream *substream) in snd_pcm_group_unref() argument
1099 snd_pcm_group_unlock(group, substream->pcm->nonatomic); in snd_pcm_group_unref()
1109 snd_pcm_stream_group_ref(struct snd_pcm_substream *substream) in snd_pcm_stream_group_ref() argument
1111 bool nonatomic = substream->pcm->nonatomic; in snd_pcm_stream_group_ref()
1116 if (!snd_pcm_stream_linked(substream)) in snd_pcm_stream_group_ref()
1118 group = substream->group; in snd_pcm_stream_group_ref()
1128 snd_pcm_stream_unlock(substream); in snd_pcm_stream_group_ref()
1130 snd_pcm_stream_lock(substream); in snd_pcm_stream_group_ref()
1133 if (substream->group == group) in snd_pcm_stream_group_ref()
1136 snd_pcm_group_unref(group, substream); in snd_pcm_stream_group_ref()
1145 struct snd_pcm_substream *substream, in snd_pcm_action() argument
1151 group = snd_pcm_stream_group_ref(substream); in snd_pcm_action()
1153 res = snd_pcm_action_group(ops, substream, state, 1); in snd_pcm_action()
1155 res = snd_pcm_action_single(ops, substream, state); in snd_pcm_action()
1156 snd_pcm_group_unref(group, substream); in snd_pcm_action()
1164 struct snd_pcm_substream *substream, in snd_pcm_action_lock_irq() argument
1169 snd_pcm_stream_lock_irq(substream); in snd_pcm_action_lock_irq()
1170 res = snd_pcm_action(ops, substream, state); in snd_pcm_action_lock_irq()
1171 snd_pcm_stream_unlock_irq(substream); in snd_pcm_action_lock_irq()
1178 struct snd_pcm_substream *substream, in snd_pcm_action_nonatomic() argument
1185 if (snd_pcm_stream_linked(substream)) in snd_pcm_action_nonatomic()
1186 res = snd_pcm_action_group(ops, substream, state, 0); in snd_pcm_action_nonatomic()
1188 res = snd_pcm_action_single(ops, substream, state); in snd_pcm_action_nonatomic()
1196 static int snd_pcm_pre_start(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_start() argument
1198 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_start()
1201 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_pre_start()
1202 !snd_pcm_playback_data(substream)) in snd_pcm_pre_start()
1205 runtime->trigger_master = substream; in snd_pcm_pre_start()
1209 static int snd_pcm_do_start(struct snd_pcm_substream *substream, int state) in snd_pcm_do_start() argument
1211 if (substream->runtime->trigger_master != substream) in snd_pcm_do_start()
1213 return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_START); in snd_pcm_do_start()
1216 static void snd_pcm_undo_start(struct snd_pcm_substream *substream, int state) in snd_pcm_undo_start() argument
1218 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_start()
1219 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); in snd_pcm_undo_start()
1222 static void snd_pcm_post_start(struct snd_pcm_substream *substream, int state) in snd_pcm_post_start() argument
1224 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_start()
1225 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_start()
1230 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_post_start()
1232 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_post_start()
1233 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSTART); in snd_pcm_post_start()
1250 int snd_pcm_start(struct snd_pcm_substream *substream) in snd_pcm_start() argument
1252 return snd_pcm_action(&snd_pcm_action_start, substream, in snd_pcm_start()
1257 static int snd_pcm_start_lock_irq(struct snd_pcm_substream *substream) in snd_pcm_start_lock_irq() argument
1259 return snd_pcm_action_lock_irq(&snd_pcm_action_start, substream, in snd_pcm_start_lock_irq()
1266 static int snd_pcm_pre_stop(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_stop() argument
1268 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_stop()
1271 runtime->trigger_master = substream; in snd_pcm_pre_stop()
1275 static int snd_pcm_do_stop(struct snd_pcm_substream *substream, int state) in snd_pcm_do_stop() argument
1277 if (substream->runtime->trigger_master == substream && in snd_pcm_do_stop()
1278 snd_pcm_running(substream)) in snd_pcm_do_stop()
1279 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); in snd_pcm_do_stop()
1283 static void snd_pcm_post_stop(struct snd_pcm_substream *substream, int state) in snd_pcm_post_stop() argument
1285 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_stop()
1287 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_stop()
1289 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSTOP); in snd_pcm_post_stop()
1310 int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state) in snd_pcm_stop() argument
1312 return snd_pcm_action(&snd_pcm_action_stop, substream, state); in snd_pcm_stop()
1325 int snd_pcm_drain_done(struct snd_pcm_substream *substream) in snd_pcm_drain_done() argument
1327 return snd_pcm_action_single(&snd_pcm_action_stop, substream, in snd_pcm_drain_done()
1340 int snd_pcm_stop_xrun(struct snd_pcm_substream *substream) in snd_pcm_stop_xrun() argument
1344 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_stop_xrun()
1345 if (substream->runtime && snd_pcm_running(substream)) in snd_pcm_stop_xrun()
1346 __snd_pcm_xrun(substream); in snd_pcm_stop_xrun()
1347 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_stop_xrun()
1355 static int snd_pcm_pre_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_pre_pause() argument
1357 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_pause()
1365 runtime->trigger_master = substream; in snd_pcm_pre_pause()
1369 static int snd_pcm_do_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_do_pause() argument
1371 if (substream->runtime->trigger_master != substream) in snd_pcm_do_pause()
1376 snd_pcm_update_hw_ptr(substream); in snd_pcm_do_pause()
1381 substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000; in snd_pcm_do_pause()
1382 return substream->ops->trigger(substream, in snd_pcm_do_pause()
1387 static void snd_pcm_undo_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_undo_pause() argument
1389 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_pause()
1390 substream->ops->trigger(substream, in snd_pcm_undo_pause()
1395 static void snd_pcm_post_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_post_pause() argument
1397 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_pause()
1398 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_pause()
1401 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MPAUSE); in snd_pcm_post_pause()
1406 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MCONTINUE); in snd_pcm_post_pause()
1420 static int snd_pcm_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_pause() argument
1422 return snd_pcm_action(&snd_pcm_action_pause, substream, push); in snd_pcm_pause()
1428 static int snd_pcm_pre_suspend(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_suspend() argument
1430 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_suspend()
1440 runtime->trigger_master = substream; in snd_pcm_pre_suspend()
1444 static int snd_pcm_do_suspend(struct snd_pcm_substream *substream, int state) in snd_pcm_do_suspend() argument
1446 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_suspend()
1447 if (runtime->trigger_master != substream) in snd_pcm_do_suspend()
1449 if (! snd_pcm_running(substream)) in snd_pcm_do_suspend()
1451 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); in snd_pcm_do_suspend()
1455 static void snd_pcm_post_suspend(struct snd_pcm_substream *substream, int state) in snd_pcm_post_suspend() argument
1457 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_suspend()
1458 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_suspend()
1461 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSUSPEND); in snd_pcm_post_suspend()
1480 static int snd_pcm_suspend(struct snd_pcm_substream *substream) in snd_pcm_suspend() argument
1485 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_suspend()
1486 err = snd_pcm_action(&snd_pcm_action_suspend, substream, 0); in snd_pcm_suspend()
1487 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_suspend()
1501 struct snd_pcm_substream *substream; in snd_pcm_suspend_all() local
1508 for (substream = pcm->streams[stream].substream; in snd_pcm_suspend_all()
1509 substream; substream = substream->next) { in snd_pcm_suspend_all()
1511 if (substream->runtime == NULL) in snd_pcm_suspend_all()
1518 if (!substream->ops) in snd_pcm_suspend_all()
1521 err = snd_pcm_suspend(substream); in snd_pcm_suspend_all()
1532 static int snd_pcm_pre_resume(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_resume() argument
1534 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_resume()
1537 runtime->trigger_master = substream; in snd_pcm_pre_resume()
1541 static int snd_pcm_do_resume(struct snd_pcm_substream *substream, int state) in snd_pcm_do_resume() argument
1543 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_resume()
1544 if (runtime->trigger_master != substream) in snd_pcm_do_resume()
1549 substream->stream != SNDRV_PCM_STREAM_PLAYBACK)) in snd_pcm_do_resume()
1551 return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_RESUME); in snd_pcm_do_resume()
1554 static void snd_pcm_undo_resume(struct snd_pcm_substream *substream, int state) in snd_pcm_undo_resume() argument
1556 if (substream->runtime->trigger_master == substream && in snd_pcm_undo_resume()
1557 snd_pcm_running(substream)) in snd_pcm_undo_resume()
1558 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); in snd_pcm_undo_resume()
1561 static void snd_pcm_post_resume(struct snd_pcm_substream *substream, int state) in snd_pcm_post_resume() argument
1563 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_resume()
1564 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_resume()
1566 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MRESUME); in snd_pcm_post_resume()
1576 static int snd_pcm_resume(struct snd_pcm_substream *substream) in snd_pcm_resume() argument
1578 return snd_pcm_action_lock_irq(&snd_pcm_action_resume, substream, 0); in snd_pcm_resume()
1583 static int snd_pcm_resume(struct snd_pcm_substream *substream) in snd_pcm_resume() argument
1595 static int snd_pcm_xrun(struct snd_pcm_substream *substream) in snd_pcm_xrun() argument
1597 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xrun()
1600 snd_pcm_stream_lock_irq(substream); in snd_pcm_xrun()
1606 __snd_pcm_xrun(substream); in snd_pcm_xrun()
1612 snd_pcm_stream_unlock_irq(substream); in snd_pcm_xrun()
1619 static int snd_pcm_pre_reset(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_reset() argument
1621 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_reset()
1633 static int snd_pcm_do_reset(struct snd_pcm_substream *substream, int state) in snd_pcm_do_reset() argument
1635 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_reset()
1636 int err = substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL); in snd_pcm_do_reset()
1647 static void snd_pcm_post_reset(struct snd_pcm_substream *substream, int state) in snd_pcm_post_reset() argument
1649 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_reset()
1651 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_post_reset()
1653 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_post_reset()
1662 static int snd_pcm_reset(struct snd_pcm_substream *substream) in snd_pcm_reset() argument
1664 return snd_pcm_action_nonatomic(&snd_pcm_action_reset, substream, 0); in snd_pcm_reset()
1671 static int snd_pcm_pre_prepare(struct snd_pcm_substream *substream, in snd_pcm_pre_prepare() argument
1674 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_prepare()
1678 if (snd_pcm_running(substream)) in snd_pcm_pre_prepare()
1680 substream->f_flags = f_flags; in snd_pcm_pre_prepare()
1684 static int snd_pcm_do_prepare(struct snd_pcm_substream *substream, int state) in snd_pcm_do_prepare() argument
1687 err = substream->ops->prepare(substream); in snd_pcm_do_prepare()
1690 return snd_pcm_do_reset(substream, 0); in snd_pcm_do_prepare()
1693 static void snd_pcm_post_prepare(struct snd_pcm_substream *substream, int state) in snd_pcm_post_prepare() argument
1695 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_prepare()
1697 snd_pcm_set_state(substream, SNDRV_PCM_STATE_PREPARED); in snd_pcm_post_prepare()
1713 static int snd_pcm_prepare(struct snd_pcm_substream *substream, in snd_pcm_prepare() argument
1721 f_flags = substream->f_flags; in snd_pcm_prepare()
1723 snd_pcm_stream_lock_irq(substream); in snd_pcm_prepare()
1724 switch (substream->runtime->status->state) { in snd_pcm_prepare()
1726 snd_pcm_pause(substream, 0); in snd_pcm_prepare()
1729 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_prepare()
1732 snd_pcm_stream_unlock_irq(substream); in snd_pcm_prepare()
1735 substream, f_flags); in snd_pcm_prepare()
1742 static int snd_pcm_pre_drain_init(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_drain_init() argument
1744 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_drain_init()
1751 runtime->trigger_master = substream; in snd_pcm_pre_drain_init()
1755 static int snd_pcm_do_drain_init(struct snd_pcm_substream *substream, int state) in snd_pcm_do_drain_init() argument
1757 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_drain_init()
1758 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_do_drain_init()
1762 if (! snd_pcm_playback_empty(substream)) { in snd_pcm_do_drain_init()
1763 snd_pcm_do_start(substream, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
1764 snd_pcm_post_start(substream, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
1783 snd_pcm_do_stop(substream, new_state); in snd_pcm_do_drain_init()
1784 snd_pcm_post_stop(substream, new_state); in snd_pcm_do_drain_init()
1789 runtime->trigger_master == substream && in snd_pcm_do_drain_init()
1791 return substream->ops->trigger(substream, in snd_pcm_do_drain_init()
1797 static void snd_pcm_post_drain_init(struct snd_pcm_substream *substream, int state) in snd_pcm_post_drain_init() argument
1814 static int snd_pcm_drain(struct snd_pcm_substream *substream, in snd_pcm_drain() argument
1825 card = substream->pcm->card; in snd_pcm_drain()
1826 runtime = substream->runtime; in snd_pcm_drain()
1834 } else if (substream->f_flags & O_NONBLOCK) in snd_pcm_drain()
1837 snd_pcm_stream_lock_irq(substream); in snd_pcm_drain()
1840 snd_pcm_pause(substream, 0); in snd_pcm_drain()
1843 result = snd_pcm_action(&snd_pcm_action_drain_init, substream, 0); in snd_pcm_drain()
1861 group = snd_pcm_stream_group_ref(substream); in snd_pcm_drain()
1862 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_drain()
1871 snd_pcm_group_unref(group, substream); in snd_pcm_drain()
1877 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drain()
1890 snd_pcm_stream_lock_irq(substream); in snd_pcm_drain()
1891 group = snd_pcm_stream_group_ref(substream); in snd_pcm_drain()
1892 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_drain()
1898 snd_pcm_group_unref(group, substream); in snd_pcm_drain()
1905 if (substream->runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) in snd_pcm_drain()
1908 dev_dbg(substream->pcm->card->dev, in snd_pcm_drain()
1910 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_drain()
1918 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drain()
1928 static int snd_pcm_drop(struct snd_pcm_substream *substream) in snd_pcm_drop() argument
1933 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_drop()
1935 runtime = substream->runtime; in snd_pcm_drop()
1941 snd_pcm_stream_lock_irq(substream); in snd_pcm_drop()
1944 snd_pcm_pause(substream, 0); in snd_pcm_drop()
1946 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_drop()
1948 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drop()
1975 static int snd_pcm_link(struct snd_pcm_substream *substream, int fd) in snd_pcm_link() argument
1981 bool nonatomic = substream->pcm->nonatomic; in snd_pcm_link()
1991 substream1 = pcm_file->substream; in snd_pcm_link()
2000 if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_link()
2001 substream->runtime->status->state != substream1->runtime->status->state || in snd_pcm_link()
2002 substream->pcm->nonatomic != substream1->pcm->nonatomic) { in snd_pcm_link()
2011 snd_pcm_stream_lock_irq(substream); in snd_pcm_link()
2012 if (!snd_pcm_stream_linked(substream)) { in snd_pcm_link()
2013 snd_pcm_group_assign(substream, group); in snd_pcm_link()
2016 target_group = substream->group; in snd_pcm_link()
2017 snd_pcm_stream_unlock_irq(substream); in snd_pcm_link()
2034 static void relink_to_local(struct snd_pcm_substream *substream) in relink_to_local() argument
2036 snd_pcm_stream_lock(substream); in relink_to_local()
2037 snd_pcm_group_assign(substream, &substream->self_group); in relink_to_local()
2038 snd_pcm_stream_unlock(substream); in relink_to_local()
2041 static int snd_pcm_unlink(struct snd_pcm_substream *substream) in snd_pcm_unlink() argument
2044 bool nonatomic = substream->pcm->nonatomic; in snd_pcm_unlink()
2050 if (!snd_pcm_stream_linked(substream)) { in snd_pcm_unlink()
2055 group = substream->group; in snd_pcm_unlink()
2058 relink_to_local(substream); in snd_pcm_unlink()
2193 struct snd_pcm_substream *substream = rule->private; in snd_pcm_hw_rule_buffer_bytes_max() local
2195 t.max = substream->buffer_bytes_max; in snd_pcm_hw_rule_buffer_bytes_max()
2202 int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream) in snd_pcm_hw_constraints_init() argument
2204 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_init()
2326 int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) in snd_pcm_hw_constraints_complete() argument
2328 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_complete()
2337 if (hw_support_mmap(substream)) { in snd_pcm_hw_constraints_complete()
2383 snd_pcm_hw_rule_buffer_bytes_max, substream, in snd_pcm_hw_constraints_complete()
2409 static void pcm_release_private(struct snd_pcm_substream *substream) in pcm_release_private() argument
2411 if (snd_pcm_stream_linked(substream)) in pcm_release_private()
2412 snd_pcm_unlink(substream); in pcm_release_private()
2415 void snd_pcm_release_substream(struct snd_pcm_substream *substream) in snd_pcm_release_substream() argument
2417 substream->ref_count--; in snd_pcm_release_substream()
2418 if (substream->ref_count > 0) in snd_pcm_release_substream()
2421 snd_pcm_drop(substream); in snd_pcm_release_substream()
2422 if (substream->hw_opened) { in snd_pcm_release_substream()
2423 if (substream->ops->hw_free && in snd_pcm_release_substream()
2424 substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) in snd_pcm_release_substream()
2425 substream->ops->hw_free(substream); in snd_pcm_release_substream()
2426 substream->ops->close(substream); in snd_pcm_release_substream()
2427 substream->hw_opened = 0; in snd_pcm_release_substream()
2429 if (pm_qos_request_active(&substream->latency_pm_qos_req)) in snd_pcm_release_substream()
2430 pm_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_release_substream()
2431 if (substream->pcm_release) { in snd_pcm_release_substream()
2432 substream->pcm_release(substream); in snd_pcm_release_substream()
2433 substream->pcm_release = NULL; in snd_pcm_release_substream()
2435 snd_pcm_detach_substream(substream); in snd_pcm_release_substream()
2443 struct snd_pcm_substream *substream; in snd_pcm_open_substream() local
2446 err = snd_pcm_attach_substream(pcm, stream, file, &substream); in snd_pcm_open_substream()
2449 if (substream->ref_count > 1) { in snd_pcm_open_substream()
2450 *rsubstream = substream; in snd_pcm_open_substream()
2454 err = snd_pcm_hw_constraints_init(substream); in snd_pcm_open_substream()
2460 if ((err = substream->ops->open(substream)) < 0) in snd_pcm_open_substream()
2463 substream->hw_opened = 1; in snd_pcm_open_substream()
2465 err = snd_pcm_hw_constraints_complete(substream); in snd_pcm_open_substream()
2471 *rsubstream = substream; in snd_pcm_open_substream()
2475 snd_pcm_release_substream(substream); in snd_pcm_open_substream()
2485 struct snd_pcm_substream *substream; in snd_pcm_open_file() local
2488 err = snd_pcm_open_substream(pcm, stream, file, &substream); in snd_pcm_open_file()
2494 snd_pcm_release_substream(substream); in snd_pcm_open_file()
2497 pcm_file->substream = substream; in snd_pcm_open_file()
2498 if (substream->ref_count == 1) in snd_pcm_open_file()
2499 substream->pcm_release = pcm_release_private; in snd_pcm_open_file()
2593 struct snd_pcm_substream *substream; in snd_pcm_release() local
2597 substream = pcm_file->substream; in snd_pcm_release()
2598 if (snd_BUG_ON(!substream)) in snd_pcm_release()
2600 pcm = substream->pcm; in snd_pcm_release()
2602 snd_pcm_release_substream(substream); in snd_pcm_release()
2614 static int do_pcm_hwsync(struct snd_pcm_substream *substream) in do_pcm_hwsync() argument
2616 switch (substream->runtime->status->state) { in do_pcm_hwsync()
2618 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in do_pcm_hwsync()
2622 return snd_pcm_update_hw_ptr(substream); in do_pcm_hwsync()
2636 static snd_pcm_sframes_t forward_appl_ptr(struct snd_pcm_substream *substream, in forward_appl_ptr() argument
2640 struct snd_pcm_runtime *runtime = substream->runtime; in forward_appl_ptr()
2651 ret = pcm_lib_apply_appl_ptr(substream, appl_ptr); in forward_appl_ptr()
2656 static snd_pcm_sframes_t rewind_appl_ptr(struct snd_pcm_substream *substream, in rewind_appl_ptr() argument
2660 struct snd_pcm_runtime *runtime = substream->runtime; in rewind_appl_ptr()
2671 ret = pcm_lib_apply_appl_ptr(substream, appl_ptr); in rewind_appl_ptr()
2680 static snd_pcm_sframes_t snd_pcm_rewind(struct snd_pcm_substream *substream, in snd_pcm_rewind() argument
2688 snd_pcm_stream_lock_irq(substream); in snd_pcm_rewind()
2689 ret = do_pcm_hwsync(substream); in snd_pcm_rewind()
2691 ret = rewind_appl_ptr(substream, frames, in snd_pcm_rewind()
2692 snd_pcm_hw_avail(substream)); in snd_pcm_rewind()
2693 snd_pcm_stream_unlock_irq(substream); in snd_pcm_rewind()
2697 static snd_pcm_sframes_t snd_pcm_forward(struct snd_pcm_substream *substream, in snd_pcm_forward() argument
2705 snd_pcm_stream_lock_irq(substream); in snd_pcm_forward()
2706 ret = do_pcm_hwsync(substream); in snd_pcm_forward()
2708 ret = forward_appl_ptr(substream, frames, in snd_pcm_forward()
2709 snd_pcm_avail(substream)); in snd_pcm_forward()
2710 snd_pcm_stream_unlock_irq(substream); in snd_pcm_forward()
2714 static int snd_pcm_hwsync(struct snd_pcm_substream *substream) in snd_pcm_hwsync() argument
2718 snd_pcm_stream_lock_irq(substream); in snd_pcm_hwsync()
2719 err = do_pcm_hwsync(substream); in snd_pcm_hwsync()
2720 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hwsync()
2724 static int snd_pcm_delay(struct snd_pcm_substream *substream, in snd_pcm_delay() argument
2730 snd_pcm_stream_lock_irq(substream); in snd_pcm_delay()
2731 err = do_pcm_hwsync(substream); in snd_pcm_delay()
2733 n = snd_pcm_calc_delay(substream); in snd_pcm_delay()
2734 snd_pcm_stream_unlock_irq(substream); in snd_pcm_delay()
2740 static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream, in snd_pcm_sync_ptr() argument
2743 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_sync_ptr()
2757 err = snd_pcm_hwsync(substream); in snd_pcm_sync_ptr()
2761 snd_pcm_stream_lock_irq(substream); in snd_pcm_sync_ptr()
2763 err = pcm_lib_apply_appl_ptr(substream, in snd_pcm_sync_ptr()
2766 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sync_ptr()
2781 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sync_ptr()
2787 static int snd_pcm_tstamp(struct snd_pcm_substream *substream, int __user *_arg) in snd_pcm_tstamp() argument
2789 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_tstamp()
2800 static int snd_pcm_xferi_frames_ioctl(struct snd_pcm_substream *substream, in snd_pcm_xferi_frames_ioctl() argument
2804 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xferi_frames_ioctl()
2813 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_xferi_frames_ioctl()
2814 result = snd_pcm_lib_write(substream, xferi.buf, xferi.frames); in snd_pcm_xferi_frames_ioctl()
2816 result = snd_pcm_lib_read(substream, xferi.buf, xferi.frames); in snd_pcm_xferi_frames_ioctl()
2821 static int snd_pcm_xfern_frames_ioctl(struct snd_pcm_substream *substream, in snd_pcm_xfern_frames_ioctl() argument
2825 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xfern_frames_ioctl()
2841 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_xfern_frames_ioctl()
2842 result = snd_pcm_lib_writev(substream, bufs, xfern.frames); in snd_pcm_xfern_frames_ioctl()
2844 result = snd_pcm_lib_readv(substream, bufs, xfern.frames); in snd_pcm_xfern_frames_ioctl()
2850 static int snd_pcm_rewind_ioctl(struct snd_pcm_substream *substream, in snd_pcm_rewind_ioctl() argument
2860 result = snd_pcm_rewind(substream, frames); in snd_pcm_rewind_ioctl()
2865 static int snd_pcm_forward_ioctl(struct snd_pcm_substream *substream, in snd_pcm_forward_ioctl() argument
2875 result = snd_pcm_forward(substream, frames); in snd_pcm_forward_ioctl()
2881 struct snd_pcm_substream *substream, in snd_pcm_common_ioctl() argument
2887 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_common_ioctl()
2890 res = snd_power_wait(substream->pcm->card, SNDRV_CTL_POWER_D0); in snd_pcm_common_ioctl()
2898 return snd_pcm_info_user(substream, arg); in snd_pcm_common_ioctl()
2902 return snd_pcm_tstamp(substream, arg); in snd_pcm_common_ioctl()
2909 return snd_pcm_hw_refine_user(substream, arg); in snd_pcm_common_ioctl()
2911 return snd_pcm_hw_params_user(substream, arg); in snd_pcm_common_ioctl()
2913 return snd_pcm_hw_free(substream); in snd_pcm_common_ioctl()
2915 return snd_pcm_sw_params_user(substream, arg); in snd_pcm_common_ioctl()
2917 return snd_pcm_status_user(substream, arg, false); in snd_pcm_common_ioctl()
2919 return snd_pcm_status_user(substream, arg, true); in snd_pcm_common_ioctl()
2921 return snd_pcm_channel_info_user(substream, arg); in snd_pcm_common_ioctl()
2923 return snd_pcm_prepare(substream, file); in snd_pcm_common_ioctl()
2925 return snd_pcm_reset(substream); in snd_pcm_common_ioctl()
2927 return snd_pcm_start_lock_irq(substream); in snd_pcm_common_ioctl()
2929 return snd_pcm_link(substream, (int)(unsigned long) arg); in snd_pcm_common_ioctl()
2931 return snd_pcm_unlink(substream); in snd_pcm_common_ioctl()
2933 return snd_pcm_resume(substream); in snd_pcm_common_ioctl()
2935 return snd_pcm_xrun(substream); in snd_pcm_common_ioctl()
2937 return snd_pcm_hwsync(substream); in snd_pcm_common_ioctl()
2944 err = snd_pcm_delay(substream, &delay); in snd_pcm_common_ioctl()
2952 return snd_pcm_sync_ptr(substream, arg); in snd_pcm_common_ioctl()
2955 return snd_pcm_hw_refine_old_user(substream, arg); in snd_pcm_common_ioctl()
2957 return snd_pcm_hw_params_old_user(substream, arg); in snd_pcm_common_ioctl()
2960 return snd_pcm_drain(substream, file); in snd_pcm_common_ioctl()
2962 return snd_pcm_drop(substream); in snd_pcm_common_ioctl()
2965 substream, in snd_pcm_common_ioctl()
2969 return snd_pcm_xferi_frames_ioctl(substream, arg); in snd_pcm_common_ioctl()
2972 return snd_pcm_xfern_frames_ioctl(substream, arg); in snd_pcm_common_ioctl()
2974 return snd_pcm_rewind_ioctl(substream, arg); in snd_pcm_common_ioctl()
2976 return snd_pcm_forward_ioctl(substream, arg); in snd_pcm_common_ioctl()
2978 pcm_dbg(substream->pcm, "unknown ioctl = 0x%x\n", cmd); in snd_pcm_common_ioctl()
2992 return snd_pcm_common_ioctl(file, pcm_file->substream, cmd, in snd_pcm_ioctl()
3006 int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, in snd_pcm_kernel_ioctl() argument
3016 if (substream->stream != SNDRV_PCM_STREAM_CAPTURE) in snd_pcm_kernel_ioctl()
3018 result = snd_pcm_forward(substream, *frames); in snd_pcm_kernel_ioctl()
3022 return snd_pcm_hw_params(substream, arg); in snd_pcm_kernel_ioctl()
3024 return snd_pcm_sw_params(substream, arg); in snd_pcm_kernel_ioctl()
3026 return snd_pcm_prepare(substream, NULL); in snd_pcm_kernel_ioctl()
3028 return snd_pcm_start_lock_irq(substream); in snd_pcm_kernel_ioctl()
3030 return snd_pcm_drain(substream, NULL); in snd_pcm_kernel_ioctl()
3032 return snd_pcm_drop(substream); in snd_pcm_kernel_ioctl()
3034 return snd_pcm_delay(substream, frames); in snd_pcm_kernel_ioctl()
3045 struct snd_pcm_substream *substream; in snd_pcm_read() local
3050 substream = pcm_file->substream; in snd_pcm_read()
3051 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_read()
3053 runtime = substream->runtime; in snd_pcm_read()
3059 result = snd_pcm_lib_read(substream, buf, count); in snd_pcm_read()
3069 struct snd_pcm_substream *substream; in snd_pcm_write() local
3074 substream = pcm_file->substream; in snd_pcm_write()
3075 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_write()
3077 runtime = substream->runtime; in snd_pcm_write()
3083 result = snd_pcm_lib_write(substream, buf, count); in snd_pcm_write()
3092 struct snd_pcm_substream *substream; in snd_pcm_readv() local
3100 substream = pcm_file->substream; in snd_pcm_readv()
3101 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_readv()
3103 runtime = substream->runtime; in snd_pcm_readv()
3118 result = snd_pcm_lib_readv(substream, bufs, frames); in snd_pcm_readv()
3128 struct snd_pcm_substream *substream; in snd_pcm_writev() local
3136 substream = pcm_file->substream; in snd_pcm_writev()
3137 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_writev()
3139 runtime = substream->runtime; in snd_pcm_writev()
3153 result = snd_pcm_lib_writev(substream, bufs, frames); in snd_pcm_writev()
3163 struct snd_pcm_substream *substream; in snd_pcm_poll() local
3170 substream = pcm_file->substream; in snd_pcm_poll()
3171 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_poll()
3175 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_poll()
3178 runtime = substream->runtime; in snd_pcm_poll()
3182 snd_pcm_stream_lock_irq(substream); in snd_pcm_poll()
3183 avail = snd_pcm_avail(substream); in snd_pcm_poll()
3192 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in snd_pcm_poll()
3202 snd_pcm_stream_unlock_irq(substream); in snd_pcm_poll()
3220 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_status_fault() local
3223 if (substream == NULL) in snd_pcm_mmap_status_fault()
3225 runtime = substream->runtime; in snd_pcm_mmap_status_fault()
3236 static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_status() argument
3246 area->vm_private_data = substream; in snd_pcm_mmap_status()
3256 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_control_fault() local
3259 if (substream == NULL) in snd_pcm_mmap_control_fault()
3261 runtime = substream->runtime; in snd_pcm_mmap_control_fault()
3272 static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_control() argument
3282 area->vm_private_data = substream; in snd_pcm_mmap_control()
3296 (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR)) in pcm_status_mmap_allowed()
3309 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR) in pcm_control_mmap_allowed()
3321 static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_status() argument
3326 static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_control() argument
3334 snd_pcm_default_page_ops(struct snd_pcm_substream *substream, unsigned long ofs) in snd_pcm_default_page_ops() argument
3336 void *vaddr = substream->runtime->dma_area + ofs; in snd_pcm_default_page_ops()
3345 struct snd_pcm_substream *substream = vmf->vma->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 (IS_ENABLED(CONFIG_HAS_DMA) && !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()
3411 substream->runtime->dma_bytes); 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()
3446 int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_data() argument
3455 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_mmap_data()
3462 runtime = substream->runtime; in snd_pcm_mmap_data()
3479 area->vm_private_data = substream; in snd_pcm_mmap_data()
3480 if (substream->ops->mmap) in snd_pcm_mmap_data()
3481 err = substream->ops->mmap(substream, area); in snd_pcm_mmap_data()
3483 err = snd_pcm_lib_default_mmap(substream, area); in snd_pcm_mmap_data()
3485 atomic_inc(&substream->mmap_count); in snd_pcm_mmap_data()
3493 struct snd_pcm_substream *substream; in snd_pcm_mmap() local
3497 substream = pcm_file->substream; in snd_pcm_mmap()
3498 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_mmap()
3506 return snd_pcm_mmap_status(substream, file, area); in snd_pcm_mmap()
3510 return snd_pcm_mmap_control(substream, file, area); in snd_pcm_mmap()
3512 return snd_pcm_mmap_data(substream, file, area); in snd_pcm_mmap()
3520 struct snd_pcm_substream *substream; in snd_pcm_fasync() local
3524 substream = pcm_file->substream; in snd_pcm_fasync()
3525 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_fasync()
3527 runtime = substream->runtime; in snd_pcm_fasync()
3586 static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, in snd_pcm_hw_refine_old_user() argument
3603 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_refine_old_user()
3607 err = fixup_unreferenced_params(substream, params); in snd_pcm_hw_refine_old_user()
3621 static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, in snd_pcm_hw_params_old_user() argument
3639 err = snd_pcm_hw_params(substream, params); in snd_pcm_hw_params_old_user()
3662 struct snd_pcm_substream *substream = pcm_file->substream; in snd_pcm_get_unmapped_area() local
3663 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_get_unmapped_area()