Lines Matching refs:substream
36 #define trace_hw_mask_param(substream, type, index, prev, curr) argument
37 #define trace_hw_interval_param(substream, type, index, prev, curr) argument
64 static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream,
66 static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream,
108 void snd_pcm_stream_lock(struct snd_pcm_substream *substream) in snd_pcm_stream_lock() argument
110 snd_pcm_group_lock(&substream->self_group, substream->pcm->nonatomic); in snd_pcm_stream_lock()
120 void snd_pcm_stream_unlock(struct snd_pcm_substream *substream) in snd_pcm_stream_unlock() argument
122 snd_pcm_group_unlock(&substream->self_group, substream->pcm->nonatomic); in snd_pcm_stream_unlock()
134 void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream) in snd_pcm_stream_lock_irq() argument
136 snd_pcm_group_lock_irq(&substream->self_group, in snd_pcm_stream_lock_irq()
137 substream->pcm->nonatomic); in snd_pcm_stream_lock_irq()
141 static void snd_pcm_stream_lock_nested(struct snd_pcm_substream *substream) in snd_pcm_stream_lock_nested() argument
143 struct snd_pcm_group *group = &substream->self_group; in snd_pcm_stream_lock_nested()
145 if (substream->pcm->nonatomic) in snd_pcm_stream_lock_nested()
157 void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream) in snd_pcm_stream_unlock_irq() argument
159 snd_pcm_group_unlock_irq(&substream->self_group, in snd_pcm_stream_unlock_irq()
160 substream->pcm->nonatomic); in snd_pcm_stream_unlock_irq()
164 unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream) in _snd_pcm_stream_lock_irqsave() argument
167 if (substream->pcm->nonatomic) in _snd_pcm_stream_lock_irqsave()
168 mutex_lock(&substream->self_group.mutex); in _snd_pcm_stream_lock_irqsave()
170 spin_lock_irqsave(&substream->self_group.lock, flags); in _snd_pcm_stream_lock_irqsave()
182 void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream, in snd_pcm_stream_unlock_irqrestore() argument
185 if (substream->pcm->nonatomic) in snd_pcm_stream_unlock_irqrestore()
186 mutex_unlock(&substream->self_group.mutex); in snd_pcm_stream_unlock_irqrestore()
188 spin_unlock_irqrestore(&substream->self_group.lock, flags); in snd_pcm_stream_unlock_irqrestore()
193 static int snd_pcm_ops_ioctl(struct snd_pcm_substream *substream, in snd_pcm_ops_ioctl() argument
196 if (substream->ops->ioctl) in snd_pcm_ops_ioctl()
197 return substream->ops->ioctl(substream, cmd, arg); in snd_pcm_ops_ioctl()
199 return snd_pcm_lib_ioctl(substream, cmd, arg); in snd_pcm_ops_ioctl()
202 int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info) in snd_pcm_info() argument
204 struct snd_pcm *pcm = substream->pcm; in snd_pcm_info()
205 struct snd_pcm_str *pstr = substream->pstr; in snd_pcm_info()
210 info->stream = substream->stream; in snd_pcm_info()
211 info->subdevice = substream->number; in snd_pcm_info()
218 strscpy(info->subname, substream->name, sizeof(info->subname)); in snd_pcm_info()
223 int snd_pcm_info_user(struct snd_pcm_substream *substream, in snd_pcm_info_user() argument
232 err = snd_pcm_info(substream, info); in snd_pcm_info_user()
244 static bool hw_support_mmap(struct snd_pcm_substream *substream) in hw_support_mmap() argument
248 if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_MMAP)) in hw_support_mmap()
251 if (substream->ops->mmap || substream->ops->page) in hw_support_mmap()
254 dmabuf = snd_pcm_get_dma_buf(substream); in hw_support_mmap()
256 dmabuf = &substream->dma_buffer; in hw_support_mmap()
271 static int constrain_mask_params(struct snd_pcm_substream *substream, in constrain_mask_params() argument
275 &substream->runtime->hw_constraints; in constrain_mask_params()
300 trace_hw_mask_param(substream, k, 0, &old_mask, m); in constrain_mask_params()
307 static int constrain_interval_params(struct snd_pcm_substream *substream, in constrain_interval_params() argument
311 &substream->runtime->hw_constraints; in constrain_interval_params()
336 trace_hw_interval_param(substream, k, 0, &old_interval, i); in constrain_interval_params()
343 static int constrain_params_by_rules(struct snd_pcm_substream *substream, in constrain_params_by_rules() argument
347 &substream->runtime->hw_constraints; in constrain_params_by_rules()
437 trace_hw_mask_param(substream, r->var, in constrain_params_by_rules()
442 trace_hw_interval_param(substream, r->var, in constrain_params_by_rules()
464 static int fixup_unreferenced_params(struct snd_pcm_substream *substream, in fixup_unreferenced_params() argument
489 err = snd_pcm_ops_ioctl(substream, in fixup_unreferenced_params()
498 params->info = substream->runtime->hw.info; in fixup_unreferenced_params()
501 if (!hw_support_mmap(substream)) in fixup_unreferenced_params()
509 int snd_pcm_hw_refine(struct snd_pcm_substream *substream, in snd_pcm_hw_refine() argument
523 err = constrain_mask_params(substream, params); in snd_pcm_hw_refine()
527 err = constrain_interval_params(substream, params); in snd_pcm_hw_refine()
531 err = constrain_params_by_rules(substream, params); in snd_pcm_hw_refine()
541 static int snd_pcm_hw_refine_user(struct snd_pcm_substream *substream, in snd_pcm_hw_refine_user() argument
551 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_refine_user()
555 err = fixup_unreferenced_params(substream, params); in snd_pcm_hw_refine_user()
581 static void snd_pcm_set_state(struct snd_pcm_substream *substream, in snd_pcm_set_state() argument
584 snd_pcm_stream_lock_irq(substream); in snd_pcm_set_state()
585 if (substream->runtime->status->state != SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_set_state()
586 substream->runtime->status->state = state; in snd_pcm_set_state()
587 snd_pcm_stream_unlock_irq(substream); in snd_pcm_set_state()
590 static inline void snd_pcm_timer_notify(struct snd_pcm_substream *substream, in snd_pcm_timer_notify() argument
594 if (substream->timer) in snd_pcm_timer_notify()
595 snd_timer_notify(substream->timer, event, in snd_pcm_timer_notify()
596 &substream->runtime->trigger_tstamp); in snd_pcm_timer_notify()
600 void snd_pcm_sync_stop(struct snd_pcm_substream *substream, bool sync_irq) in snd_pcm_sync_stop() argument
602 if (substream->runtime && substream->runtime->stop_operating) { in snd_pcm_sync_stop()
603 substream->runtime->stop_operating = false; in snd_pcm_sync_stop()
604 if (substream->ops && substream->ops->sync_stop) in snd_pcm_sync_stop()
605 substream->ops->sync_stop(substream); in snd_pcm_sync_stop()
606 else if (sync_irq && substream->pcm->card->sync_irq > 0) in snd_pcm_sync_stop()
607 synchronize_irq(substream->pcm->card->sync_irq); in snd_pcm_sync_stop()
675 static int snd_pcm_hw_params(struct snd_pcm_substream *substream, in snd_pcm_hw_params() argument
683 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_hw_params()
685 runtime = substream->runtime; in snd_pcm_hw_params()
686 snd_pcm_stream_lock_irq(substream); in snd_pcm_hw_params()
693 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_params()
696 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_params()
698 if (!substream->oss.oss) in snd_pcm_hw_params()
700 if (atomic_read(&substream->mmap_count)) in snd_pcm_hw_params()
703 snd_pcm_sync_stop(substream, true); in snd_pcm_hw_params()
706 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_params()
710 err = snd_pcm_hw_params_choose(substream, params); in snd_pcm_hw_params()
714 err = fixup_unreferenced_params(substream, params); in snd_pcm_hw_params()
718 if (substream->managed_buffer_alloc) { in snd_pcm_hw_params()
719 err = snd_pcm_lib_malloc_pages(substream, in snd_pcm_hw_params()
726 if (substream->ops->hw_params != NULL) { in snd_pcm_hw_params()
727 err = substream->ops->hw_params(substream, params); in snd_pcm_hw_params()
772 if (runtime->dma_area && !substream->ops->copy_user) { in snd_pcm_hw_params()
780 snd_pcm_timer_resolution_change(substream); in snd_pcm_hw_params()
781 snd_pcm_set_state(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_hw_params()
783 if (cpu_latency_qos_request_active(&substream->latency_pm_qos_req)) in snd_pcm_hw_params()
784 cpu_latency_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_hw_params()
787 cpu_latency_qos_add_request(&substream->latency_pm_qos_req, in snd_pcm_hw_params()
794 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); in snd_pcm_hw_params()
795 if (substream->ops->hw_free != NULL) in snd_pcm_hw_params()
796 substream->ops->hw_free(substream); in snd_pcm_hw_params()
797 if (substream->managed_buffer_alloc) in snd_pcm_hw_params()
798 snd_pcm_lib_free_pages(substream); in snd_pcm_hw_params()
802 static int snd_pcm_hw_params_user(struct snd_pcm_substream *substream, in snd_pcm_hw_params_user() argument
812 err = snd_pcm_hw_params(substream, params); in snd_pcm_hw_params_user()
823 static int do_hw_free(struct snd_pcm_substream *substream) in do_hw_free() argument
827 snd_pcm_sync_stop(substream, true); in do_hw_free()
828 if (substream->ops->hw_free) in do_hw_free()
829 result = substream->ops->hw_free(substream); in do_hw_free()
830 if (substream->managed_buffer_alloc) in do_hw_free()
831 snd_pcm_lib_free_pages(substream); in do_hw_free()
835 static int snd_pcm_hw_free(struct snd_pcm_substream *substream) in snd_pcm_hw_free() argument
840 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_hw_free()
842 runtime = substream->runtime; in snd_pcm_hw_free()
843 snd_pcm_stream_lock_irq(substream); in snd_pcm_hw_free()
849 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_free()
852 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_free()
853 if (atomic_read(&substream->mmap_count)) in snd_pcm_hw_free()
855 result = do_hw_free(substream); in snd_pcm_hw_free()
856 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); in snd_pcm_hw_free()
857 cpu_latency_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_hw_free()
861 static int snd_pcm_sw_params(struct snd_pcm_substream *substream, in snd_pcm_sw_params() argument
867 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_sw_params()
869 runtime = substream->runtime; in snd_pcm_sw_params()
870 snd_pcm_stream_lock_irq(substream); in snd_pcm_sw_params()
872 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sw_params()
875 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sw_params()
895 snd_pcm_stream_lock_irq(substream); in snd_pcm_sw_params()
906 if (snd_pcm_running(substream)) { in snd_pcm_sw_params()
907 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_sw_params()
909 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_sw_params()
910 err = snd_pcm_update_state(substream, runtime); in snd_pcm_sw_params()
912 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sw_params()
916 static int snd_pcm_sw_params_user(struct snd_pcm_substream *substream, in snd_pcm_sw_params_user() argument
923 err = snd_pcm_sw_params(substream, ¶ms); in snd_pcm_sw_params_user()
930 snd_pcm_calc_delay(struct snd_pcm_substream *substream) in snd_pcm_calc_delay() argument
934 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_calc_delay()
935 delay = snd_pcm_playback_hw_avail(substream->runtime); in snd_pcm_calc_delay()
937 delay = snd_pcm_capture_avail(substream->runtime); in snd_pcm_calc_delay()
938 return delay + substream->runtime->delay; in snd_pcm_calc_delay()
941 int snd_pcm_status64(struct snd_pcm_substream *substream, in snd_pcm_status64() argument
944 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_status64()
946 snd_pcm_stream_lock_irq(substream); in snd_pcm_status64()
970 if (snd_pcm_running(substream)) { in snd_pcm_status64()
971 snd_pcm_update_hw_ptr(substream); in snd_pcm_status64()
1005 status->avail = snd_pcm_avail(substream); in snd_pcm_status64()
1006 status->delay = snd_pcm_running(substream) ? in snd_pcm_status64()
1007 snd_pcm_calc_delay(substream) : 0; in snd_pcm_status64()
1013 snd_pcm_stream_unlock_irq(substream); in snd_pcm_status64()
1017 static int snd_pcm_status_user64(struct snd_pcm_substream *substream, in snd_pcm_status_user64() argument
1033 res = snd_pcm_status64(substream, &status); in snd_pcm_status_user64()
1041 static int snd_pcm_status_user32(struct snd_pcm_substream *substream, in snd_pcm_status_user32() argument
1059 res = snd_pcm_status64(substream, &status64); in snd_pcm_status_user32()
1090 static int snd_pcm_channel_info(struct snd_pcm_substream *substream, in snd_pcm_channel_info() argument
1097 runtime = substream->runtime; in snd_pcm_channel_info()
1098 snd_pcm_stream_lock_irq(substream); in snd_pcm_channel_info()
1100 snd_pcm_stream_unlock_irq(substream); in snd_pcm_channel_info()
1103 snd_pcm_stream_unlock_irq(substream); in snd_pcm_channel_info()
1108 return snd_pcm_ops_ioctl(substream, SNDRV_PCM_IOCTL1_CHANNEL_INFO, info); in snd_pcm_channel_info()
1111 static int snd_pcm_channel_info_user(struct snd_pcm_substream *substream, in snd_pcm_channel_info_user() argument
1119 res = snd_pcm_channel_info(substream, &info); in snd_pcm_channel_info_user()
1127 static void snd_pcm_trigger_tstamp(struct snd_pcm_substream *substream) in snd_pcm_trigger_tstamp() argument
1129 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_trigger_tstamp()
1132 if (runtime->trigger_master == substream) { in snd_pcm_trigger_tstamp()
1145 int (*pre_action)(struct snd_pcm_substream *substream,
1147 int (*do_action)(struct snd_pcm_substream *substream,
1149 void (*undo_action)(struct snd_pcm_substream *substream,
1151 void (*post_action)(struct snd_pcm_substream *substream,
1161 struct snd_pcm_substream *substream, in snd_pcm_action_group() argument
1169 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
1170 if (do_lock && s != substream) { in snd_pcm_action_group()
1181 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
1185 snd_pcm_group_for_each_entry(s1, substream) { in snd_pcm_action_group()
1195 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
1201 snd_pcm_group_for_each_entry(s1, substream) { in snd_pcm_action_group()
1202 if (s1 != substream) { in snd_pcm_action_group()
1219 struct snd_pcm_substream *substream, in snd_pcm_action_single() argument
1224 res = ops->pre_action(substream, state); in snd_pcm_action_single()
1227 res = ops->do_action(substream, state); in snd_pcm_action_single()
1229 ops->post_action(substream, state); in snd_pcm_action_single()
1231 ops->undo_action(substream, state); in snd_pcm_action_single()
1235 static void snd_pcm_group_assign(struct snd_pcm_substream *substream, in snd_pcm_group_assign() argument
1238 substream->group = new_group; in snd_pcm_group_assign()
1239 list_move(&substream->link_list, &new_group->substreams); in snd_pcm_group_assign()
1247 struct snd_pcm_substream *substream) in snd_pcm_group_unref() argument
1254 snd_pcm_group_unlock(group, substream->pcm->nonatomic); in snd_pcm_group_unref()
1264 snd_pcm_stream_group_ref(struct snd_pcm_substream *substream) in snd_pcm_stream_group_ref() argument
1266 bool nonatomic = substream->pcm->nonatomic; in snd_pcm_stream_group_ref()
1271 if (!snd_pcm_stream_linked(substream)) in snd_pcm_stream_group_ref()
1273 group = substream->group; in snd_pcm_stream_group_ref()
1283 snd_pcm_stream_unlock(substream); in snd_pcm_stream_group_ref()
1285 snd_pcm_stream_lock(substream); in snd_pcm_stream_group_ref()
1288 if (substream->group == group) in snd_pcm_stream_group_ref()
1291 snd_pcm_group_unref(group, substream); in snd_pcm_stream_group_ref()
1300 struct snd_pcm_substream *substream, in snd_pcm_action() argument
1306 group = snd_pcm_stream_group_ref(substream); in snd_pcm_action()
1308 res = snd_pcm_action_group(ops, substream, state, true); in snd_pcm_action()
1310 res = snd_pcm_action_single(ops, substream, state); in snd_pcm_action()
1311 snd_pcm_group_unref(group, substream); in snd_pcm_action()
1319 struct snd_pcm_substream *substream, in snd_pcm_action_lock_irq() argument
1324 snd_pcm_stream_lock_irq(substream); in snd_pcm_action_lock_irq()
1325 res = snd_pcm_action(ops, substream, state); in snd_pcm_action_lock_irq()
1326 snd_pcm_stream_unlock_irq(substream); in snd_pcm_action_lock_irq()
1333 struct snd_pcm_substream *substream, in snd_pcm_action_nonatomic() argument
1340 if (snd_pcm_stream_linked(substream)) in snd_pcm_action_nonatomic()
1341 res = snd_pcm_action_group(ops, substream, state, false); in snd_pcm_action_nonatomic()
1343 res = snd_pcm_action_single(ops, substream, state); in snd_pcm_action_nonatomic()
1351 static int snd_pcm_pre_start(struct snd_pcm_substream *substream, in snd_pcm_pre_start() argument
1354 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_start()
1357 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_pre_start()
1358 !snd_pcm_playback_data(substream)) in snd_pcm_pre_start()
1361 runtime->trigger_master = substream; in snd_pcm_pre_start()
1365 static int snd_pcm_do_start(struct snd_pcm_substream *substream, in snd_pcm_do_start() argument
1368 if (substream->runtime->trigger_master != substream) in snd_pcm_do_start()
1370 return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_START); in snd_pcm_do_start()
1373 static void snd_pcm_undo_start(struct snd_pcm_substream *substream, in snd_pcm_undo_start() argument
1376 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_start()
1377 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); in snd_pcm_undo_start()
1380 static void snd_pcm_post_start(struct snd_pcm_substream *substream, in snd_pcm_post_start() argument
1383 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_start()
1384 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_start()
1389 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_post_start()
1391 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_post_start()
1392 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSTART); in snd_pcm_post_start()
1409 int snd_pcm_start(struct snd_pcm_substream *substream) in snd_pcm_start() argument
1411 return snd_pcm_action(&snd_pcm_action_start, substream, in snd_pcm_start()
1416 static int snd_pcm_start_lock_irq(struct snd_pcm_substream *substream) in snd_pcm_start_lock_irq() argument
1418 return snd_pcm_action_lock_irq(&snd_pcm_action_start, substream, in snd_pcm_start_lock_irq()
1425 static int snd_pcm_pre_stop(struct snd_pcm_substream *substream, in snd_pcm_pre_stop() argument
1428 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_stop()
1431 runtime->trigger_master = substream; in snd_pcm_pre_stop()
1435 static int snd_pcm_do_stop(struct snd_pcm_substream *substream, in snd_pcm_do_stop() argument
1438 if (substream->runtime->trigger_master == substream && in snd_pcm_do_stop()
1439 snd_pcm_running(substream)) { in snd_pcm_do_stop()
1440 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); in snd_pcm_do_stop()
1441 substream->runtime->stop_operating = true; in snd_pcm_do_stop()
1446 static void snd_pcm_post_stop(struct snd_pcm_substream *substream, in snd_pcm_post_stop() argument
1449 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_stop()
1451 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_stop()
1453 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSTOP); in snd_pcm_post_stop()
1474 int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state) in snd_pcm_stop() argument
1476 return snd_pcm_action(&snd_pcm_action_stop, substream, state); in snd_pcm_stop()
1489 int snd_pcm_drain_done(struct snd_pcm_substream *substream) in snd_pcm_drain_done() argument
1491 return snd_pcm_action_single(&snd_pcm_action_stop, substream, in snd_pcm_drain_done()
1504 int snd_pcm_stop_xrun(struct snd_pcm_substream *substream) in snd_pcm_stop_xrun() argument
1508 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_stop_xrun()
1509 if (substream->runtime && snd_pcm_running(substream)) in snd_pcm_stop_xrun()
1510 __snd_pcm_xrun(substream); in snd_pcm_stop_xrun()
1511 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_stop_xrun()
1521 static int snd_pcm_pre_pause(struct snd_pcm_substream *substream, in snd_pcm_pre_pause() argument
1524 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_pause()
1532 runtime->trigger_master = substream; in snd_pcm_pre_pause()
1536 static int snd_pcm_do_pause(struct snd_pcm_substream *substream, in snd_pcm_do_pause() argument
1539 if (substream->runtime->trigger_master != substream) in snd_pcm_do_pause()
1544 snd_pcm_update_hw_ptr(substream); in snd_pcm_do_pause()
1549 substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000; in snd_pcm_do_pause()
1550 return substream->ops->trigger(substream, in snd_pcm_do_pause()
1556 static void snd_pcm_undo_pause(struct snd_pcm_substream *substream, in snd_pcm_undo_pause() argument
1559 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_pause()
1560 substream->ops->trigger(substream, in snd_pcm_undo_pause()
1566 static void snd_pcm_post_pause(struct snd_pcm_substream *substream, in snd_pcm_post_pause() argument
1569 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_pause()
1570 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_pause()
1573 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MPAUSE); in snd_pcm_post_pause()
1578 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MCONTINUE); in snd_pcm_post_pause()
1592 static int snd_pcm_pause(struct snd_pcm_substream *substream, bool push) in snd_pcm_pause() argument
1594 return snd_pcm_action(&snd_pcm_action_pause, substream, in snd_pcm_pause()
1598 static int snd_pcm_pause_lock_irq(struct snd_pcm_substream *substream, in snd_pcm_pause_lock_irq() argument
1601 return snd_pcm_action_lock_irq(&snd_pcm_action_pause, substream, in snd_pcm_pause_lock_irq()
1608 static int snd_pcm_pre_suspend(struct snd_pcm_substream *substream, in snd_pcm_pre_suspend() argument
1611 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_suspend()
1621 runtime->trigger_master = substream; in snd_pcm_pre_suspend()
1625 static int snd_pcm_do_suspend(struct snd_pcm_substream *substream, in snd_pcm_do_suspend() argument
1628 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_suspend()
1629 if (runtime->trigger_master != substream) in snd_pcm_do_suspend()
1631 if (! snd_pcm_running(substream)) in snd_pcm_do_suspend()
1633 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); in snd_pcm_do_suspend()
1638 static void snd_pcm_post_suspend(struct snd_pcm_substream *substream, in snd_pcm_post_suspend() argument
1641 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_suspend()
1642 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_suspend()
1645 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSUSPEND); in snd_pcm_post_suspend()
1664 static int snd_pcm_suspend(struct snd_pcm_substream *substream) in snd_pcm_suspend() argument
1669 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_suspend()
1670 err = snd_pcm_action(&snd_pcm_action_suspend, substream, in snd_pcm_suspend()
1672 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_suspend()
1686 struct snd_pcm_substream *substream; in snd_pcm_suspend_all() local
1692 for_each_pcm_substream(pcm, stream, substream) { in snd_pcm_suspend_all()
1694 if (!substream->runtime) in snd_pcm_suspend_all()
1701 if (!substream->ops) in snd_pcm_suspend_all()
1704 err = snd_pcm_suspend(substream); in snd_pcm_suspend_all()
1709 for_each_pcm_substream(pcm, stream, substream) in snd_pcm_suspend_all()
1710 snd_pcm_sync_stop(substream, false); in snd_pcm_suspend_all()
1718 static int snd_pcm_pre_resume(struct snd_pcm_substream *substream, in snd_pcm_pre_resume() argument
1721 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_resume()
1724 runtime->trigger_master = substream; in snd_pcm_pre_resume()
1728 static int snd_pcm_do_resume(struct snd_pcm_substream *substream, in snd_pcm_do_resume() argument
1731 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_resume()
1732 if (runtime->trigger_master != substream) in snd_pcm_do_resume()
1737 substream->stream != SNDRV_PCM_STREAM_PLAYBACK)) in snd_pcm_do_resume()
1739 return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_RESUME); in snd_pcm_do_resume()
1742 static void snd_pcm_undo_resume(struct snd_pcm_substream *substream, in snd_pcm_undo_resume() argument
1745 if (substream->runtime->trigger_master == substream && in snd_pcm_undo_resume()
1746 snd_pcm_running(substream)) in snd_pcm_undo_resume()
1747 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); in snd_pcm_undo_resume()
1750 static void snd_pcm_post_resume(struct snd_pcm_substream *substream, in snd_pcm_post_resume() argument
1753 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_resume()
1754 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_resume()
1756 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MRESUME); in snd_pcm_post_resume()
1766 static int snd_pcm_resume(struct snd_pcm_substream *substream) in snd_pcm_resume() argument
1768 return snd_pcm_action_lock_irq(&snd_pcm_action_resume, substream, in snd_pcm_resume()
1774 static int snd_pcm_resume(struct snd_pcm_substream *substream) in snd_pcm_resume() argument
1786 static int snd_pcm_xrun(struct snd_pcm_substream *substream) in snd_pcm_xrun() argument
1788 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xrun()
1791 snd_pcm_stream_lock_irq(substream); in snd_pcm_xrun()
1797 __snd_pcm_xrun(substream); in snd_pcm_xrun()
1803 snd_pcm_stream_unlock_irq(substream); in snd_pcm_xrun()
1811 static int snd_pcm_pre_reset(struct snd_pcm_substream *substream, in snd_pcm_pre_reset() argument
1814 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_reset()
1826 static int snd_pcm_do_reset(struct snd_pcm_substream *substream, in snd_pcm_do_reset() argument
1829 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_reset()
1830 int err = snd_pcm_ops_ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL); in snd_pcm_do_reset()
1841 static void snd_pcm_post_reset(struct snd_pcm_substream *substream, in snd_pcm_post_reset() argument
1844 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_reset()
1846 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_post_reset()
1848 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_post_reset()
1857 static int snd_pcm_reset(struct snd_pcm_substream *substream) in snd_pcm_reset() argument
1859 return snd_pcm_action_nonatomic(&snd_pcm_action_reset, substream, in snd_pcm_reset()
1867 static int snd_pcm_pre_prepare(struct snd_pcm_substream *substream, in snd_pcm_pre_prepare() argument
1870 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_prepare()
1876 if (snd_pcm_running(substream)) in snd_pcm_pre_prepare()
1878 substream->f_flags = f_flags; in snd_pcm_pre_prepare()
1882 static int snd_pcm_do_prepare(struct snd_pcm_substream *substream, in snd_pcm_do_prepare() argument
1886 snd_pcm_sync_stop(substream, true); in snd_pcm_do_prepare()
1887 err = substream->ops->prepare(substream); in snd_pcm_do_prepare()
1890 return snd_pcm_do_reset(substream, state); in snd_pcm_do_prepare()
1893 static void snd_pcm_post_prepare(struct snd_pcm_substream *substream, in snd_pcm_post_prepare() argument
1896 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_prepare()
1898 snd_pcm_set_state(substream, SNDRV_PCM_STATE_PREPARED); in snd_pcm_post_prepare()
1914 static int snd_pcm_prepare(struct snd_pcm_substream *substream, in snd_pcm_prepare() argument
1922 f_flags = substream->f_flags; in snd_pcm_prepare()
1924 snd_pcm_stream_lock_irq(substream); in snd_pcm_prepare()
1925 switch (substream->runtime->status->state) { in snd_pcm_prepare()
1927 snd_pcm_pause(substream, false); in snd_pcm_prepare()
1930 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_prepare()
1933 snd_pcm_stream_unlock_irq(substream); in snd_pcm_prepare()
1936 substream, in snd_pcm_prepare()
1945 static int snd_pcm_pre_drain_init(struct snd_pcm_substream *substream, in snd_pcm_pre_drain_init() argument
1948 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_drain_init()
1955 runtime->trigger_master = substream; in snd_pcm_pre_drain_init()
1959 static int snd_pcm_do_drain_init(struct snd_pcm_substream *substream, in snd_pcm_do_drain_init() argument
1962 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_drain_init()
1963 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_do_drain_init()
1967 if (! snd_pcm_playback_empty(substream)) { in snd_pcm_do_drain_init()
1968 snd_pcm_do_start(substream, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
1969 snd_pcm_post_start(substream, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
1990 snd_pcm_do_stop(substream, new_state); in snd_pcm_do_drain_init()
1991 snd_pcm_post_stop(substream, new_state); in snd_pcm_do_drain_init()
1996 runtime->trigger_master == substream && in snd_pcm_do_drain_init()
1998 return substream->ops->trigger(substream, in snd_pcm_do_drain_init()
2004 static void snd_pcm_post_drain_init(struct snd_pcm_substream *substream, in snd_pcm_post_drain_init() argument
2022 static int snd_pcm_drain(struct snd_pcm_substream *substream, in snd_pcm_drain() argument
2033 card = substream->pcm->card; in snd_pcm_drain()
2034 runtime = substream->runtime; in snd_pcm_drain()
2042 } else if (substream->f_flags & O_NONBLOCK) in snd_pcm_drain()
2045 snd_pcm_stream_lock_irq(substream); in snd_pcm_drain()
2048 snd_pcm_pause(substream, false); in snd_pcm_drain()
2051 result = snd_pcm_action(&snd_pcm_action_drain_init, substream, in snd_pcm_drain()
2070 group = snd_pcm_stream_group_ref(substream); in snd_pcm_drain()
2071 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_drain()
2080 snd_pcm_group_unref(group, substream); in snd_pcm_drain()
2086 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drain()
2099 snd_pcm_stream_lock_irq(substream); in snd_pcm_drain()
2100 group = snd_pcm_stream_group_ref(substream); in snd_pcm_drain()
2101 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_drain()
2107 snd_pcm_group_unref(group, substream); in snd_pcm_drain()
2114 if (substream->runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) in snd_pcm_drain()
2117 dev_dbg(substream->pcm->card->dev, in snd_pcm_drain()
2119 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_drain()
2127 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drain()
2137 static int snd_pcm_drop(struct snd_pcm_substream *substream) in snd_pcm_drop() argument
2142 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_drop()
2144 runtime = substream->runtime; in snd_pcm_drop()
2150 snd_pcm_stream_lock_irq(substream); in snd_pcm_drop()
2153 snd_pcm_pause(substream, false); in snd_pcm_drop()
2155 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_drop()
2157 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drop()
2184 static int snd_pcm_link(struct snd_pcm_substream *substream, int fd) in snd_pcm_link() argument
2190 bool nonatomic = substream->pcm->nonatomic; in snd_pcm_link()
2200 substream1 = pcm_file->substream; in snd_pcm_link()
2202 if (substream == substream1) { in snd_pcm_link()
2215 if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_link()
2216 substream->runtime->status->state != substream1->runtime->status->state || in snd_pcm_link()
2217 substream->pcm->nonatomic != substream1->pcm->nonatomic) { in snd_pcm_link()
2226 snd_pcm_stream_lock_irq(substream); in snd_pcm_link()
2227 if (!snd_pcm_stream_linked(substream)) { in snd_pcm_link()
2228 snd_pcm_group_assign(substream, group); in snd_pcm_link()
2231 target_group = substream->group; in snd_pcm_link()
2232 snd_pcm_stream_unlock_irq(substream); in snd_pcm_link()
2249 static void relink_to_local(struct snd_pcm_substream *substream) in relink_to_local() argument
2251 snd_pcm_stream_lock_nested(substream); in relink_to_local()
2252 snd_pcm_group_assign(substream, &substream->self_group); in relink_to_local()
2253 snd_pcm_stream_unlock(substream); in relink_to_local()
2256 static int snd_pcm_unlink(struct snd_pcm_substream *substream) in snd_pcm_unlink() argument
2259 bool nonatomic = substream->pcm->nonatomic; in snd_pcm_unlink()
2265 if (!snd_pcm_stream_linked(substream)) { in snd_pcm_unlink()
2270 group = substream->group; in snd_pcm_unlink()
2273 relink_to_local(substream); in snd_pcm_unlink()
2409 struct snd_pcm_substream *substream = rule->private; in snd_pcm_hw_rule_buffer_bytes_max() local
2411 t.max = substream->buffer_bytes_max; in snd_pcm_hw_rule_buffer_bytes_max()
2418 static int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream) in snd_pcm_hw_constraints_init() argument
2420 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_init()
2542 static int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) in snd_pcm_hw_constraints_complete() argument
2544 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_complete()
2553 if (hw_support_mmap(substream)) { in snd_pcm_hw_constraints_complete()
2600 snd_pcm_hw_rule_buffer_bytes_max, substream, in snd_pcm_hw_constraints_complete()
2626 static void pcm_release_private(struct snd_pcm_substream *substream) in pcm_release_private() argument
2628 if (snd_pcm_stream_linked(substream)) in pcm_release_private()
2629 snd_pcm_unlink(substream); in pcm_release_private()
2632 void snd_pcm_release_substream(struct snd_pcm_substream *substream) in snd_pcm_release_substream() argument
2634 substream->ref_count--; in snd_pcm_release_substream()
2635 if (substream->ref_count > 0) in snd_pcm_release_substream()
2638 snd_pcm_drop(substream); in snd_pcm_release_substream()
2639 if (substream->hw_opened) { in snd_pcm_release_substream()
2640 if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) in snd_pcm_release_substream()
2641 do_hw_free(substream); in snd_pcm_release_substream()
2642 substream->ops->close(substream); in snd_pcm_release_substream()
2643 substream->hw_opened = 0; in snd_pcm_release_substream()
2645 if (cpu_latency_qos_request_active(&substream->latency_pm_qos_req)) in snd_pcm_release_substream()
2646 cpu_latency_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_release_substream()
2647 if (substream->pcm_release) { in snd_pcm_release_substream()
2648 substream->pcm_release(substream); in snd_pcm_release_substream()
2649 substream->pcm_release = NULL; in snd_pcm_release_substream()
2651 snd_pcm_detach_substream(substream); in snd_pcm_release_substream()
2659 struct snd_pcm_substream *substream; in snd_pcm_open_substream() local
2662 err = snd_pcm_attach_substream(pcm, stream, file, &substream); in snd_pcm_open_substream()
2665 if (substream->ref_count > 1) { in snd_pcm_open_substream()
2666 *rsubstream = substream; in snd_pcm_open_substream()
2670 err = snd_pcm_hw_constraints_init(substream); in snd_pcm_open_substream()
2676 err = substream->ops->open(substream); in snd_pcm_open_substream()
2680 substream->hw_opened = 1; in snd_pcm_open_substream()
2682 err = snd_pcm_hw_constraints_complete(substream); in snd_pcm_open_substream()
2688 *rsubstream = substream; in snd_pcm_open_substream()
2692 snd_pcm_release_substream(substream); in snd_pcm_open_substream()
2702 struct snd_pcm_substream *substream; in snd_pcm_open_file() local
2705 err = snd_pcm_open_substream(pcm, stream, file, &substream); in snd_pcm_open_file()
2711 snd_pcm_release_substream(substream); in snd_pcm_open_file()
2714 pcm_file->substream = substream; in snd_pcm_open_file()
2715 if (substream->ref_count == 1) in snd_pcm_open_file()
2716 substream->pcm_release = pcm_release_private; in snd_pcm_open_file()
2810 struct snd_pcm_substream *substream; in snd_pcm_release() local
2814 substream = pcm_file->substream; in snd_pcm_release()
2815 if (snd_BUG_ON(!substream)) in snd_pcm_release()
2817 pcm = substream->pcm; in snd_pcm_release()
2823 snd_pcm_release_substream(substream); in snd_pcm_release()
2835 static int do_pcm_hwsync(struct snd_pcm_substream *substream) in do_pcm_hwsync() argument
2837 switch (substream->runtime->status->state) { in do_pcm_hwsync()
2839 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in do_pcm_hwsync()
2843 return snd_pcm_update_hw_ptr(substream); in do_pcm_hwsync()
2857 static snd_pcm_sframes_t forward_appl_ptr(struct snd_pcm_substream *substream, in forward_appl_ptr() argument
2861 struct snd_pcm_runtime *runtime = substream->runtime; in forward_appl_ptr()
2872 ret = pcm_lib_apply_appl_ptr(substream, appl_ptr); in forward_appl_ptr()
2877 static snd_pcm_sframes_t rewind_appl_ptr(struct snd_pcm_substream *substream, in rewind_appl_ptr() argument
2881 struct snd_pcm_runtime *runtime = substream->runtime; in rewind_appl_ptr()
2892 ret = pcm_lib_apply_appl_ptr(substream, appl_ptr); in rewind_appl_ptr()
2901 static snd_pcm_sframes_t snd_pcm_rewind(struct snd_pcm_substream *substream, in snd_pcm_rewind() argument
2909 snd_pcm_stream_lock_irq(substream); in snd_pcm_rewind()
2910 ret = do_pcm_hwsync(substream); in snd_pcm_rewind()
2912 ret = rewind_appl_ptr(substream, frames, in snd_pcm_rewind()
2913 snd_pcm_hw_avail(substream)); in snd_pcm_rewind()
2914 snd_pcm_stream_unlock_irq(substream); in snd_pcm_rewind()
2918 static snd_pcm_sframes_t snd_pcm_forward(struct snd_pcm_substream *substream, in snd_pcm_forward() argument
2926 snd_pcm_stream_lock_irq(substream); in snd_pcm_forward()
2927 ret = do_pcm_hwsync(substream); in snd_pcm_forward()
2929 ret = forward_appl_ptr(substream, frames, in snd_pcm_forward()
2930 snd_pcm_avail(substream)); in snd_pcm_forward()
2931 snd_pcm_stream_unlock_irq(substream); in snd_pcm_forward()
2935 static int snd_pcm_hwsync(struct snd_pcm_substream *substream) in snd_pcm_hwsync() argument
2939 snd_pcm_stream_lock_irq(substream); in snd_pcm_hwsync()
2940 err = do_pcm_hwsync(substream); in snd_pcm_hwsync()
2941 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hwsync()
2945 static int snd_pcm_delay(struct snd_pcm_substream *substream, in snd_pcm_delay() argument
2951 snd_pcm_stream_lock_irq(substream); in snd_pcm_delay()
2952 err = do_pcm_hwsync(substream); in snd_pcm_delay()
2954 n = snd_pcm_calc_delay(substream); in snd_pcm_delay()
2955 snd_pcm_stream_unlock_irq(substream); in snd_pcm_delay()
2961 static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream, in snd_pcm_sync_ptr() argument
2964 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_sync_ptr()
2978 err = snd_pcm_hwsync(substream); in snd_pcm_sync_ptr()
2982 snd_pcm_stream_lock_irq(substream); in snd_pcm_sync_ptr()
2984 err = pcm_lib_apply_appl_ptr(substream, in snd_pcm_sync_ptr()
2987 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sync_ptr()
3002 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sync_ptr()
3049 static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream, in snd_pcm_ioctl_sync_ptr_compat() argument
3052 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_ioctl_sync_ptr_compat()
3069 err = snd_pcm_hwsync(substream); in snd_pcm_ioctl_sync_ptr_compat()
3078 snd_pcm_stream_lock_irq(substream); in snd_pcm_ioctl_sync_ptr_compat()
3081 err = pcm_lib_apply_appl_ptr(substream, in snd_pcm_ioctl_sync_ptr_compat()
3084 snd_pcm_stream_unlock_irq(substream); in snd_pcm_ioctl_sync_ptr_compat()
3098 snd_pcm_stream_unlock_irq(substream); in snd_pcm_ioctl_sync_ptr_compat()
3114 static int snd_pcm_tstamp(struct snd_pcm_substream *substream, int __user *_arg) in snd_pcm_tstamp() argument
3116 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_tstamp()
3127 static int snd_pcm_xferi_frames_ioctl(struct snd_pcm_substream *substream, in snd_pcm_xferi_frames_ioctl() argument
3131 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xferi_frames_ioctl()
3140 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_xferi_frames_ioctl()
3141 result = snd_pcm_lib_write(substream, xferi.buf, xferi.frames); in snd_pcm_xferi_frames_ioctl()
3143 result = snd_pcm_lib_read(substream, xferi.buf, xferi.frames); in snd_pcm_xferi_frames_ioctl()
3149 static int snd_pcm_xfern_frames_ioctl(struct snd_pcm_substream *substream, in snd_pcm_xfern_frames_ioctl() argument
3153 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xfern_frames_ioctl()
3169 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_xfern_frames_ioctl()
3170 result = snd_pcm_lib_writev(substream, bufs, xfern.frames); in snd_pcm_xfern_frames_ioctl()
3172 result = snd_pcm_lib_readv(substream, bufs, xfern.frames); in snd_pcm_xfern_frames_ioctl()
3179 static int snd_pcm_rewind_ioctl(struct snd_pcm_substream *substream, in snd_pcm_rewind_ioctl() argument
3189 result = snd_pcm_rewind(substream, frames); in snd_pcm_rewind_ioctl()
3195 static int snd_pcm_forward_ioctl(struct snd_pcm_substream *substream, in snd_pcm_forward_ioctl() argument
3205 result = snd_pcm_forward(substream, frames); in snd_pcm_forward_ioctl()
3212 struct snd_pcm_substream *substream, in snd_pcm_common_ioctl() argument
3218 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_common_ioctl()
3221 res = snd_power_wait(substream->pcm->card); in snd_pcm_common_ioctl()
3229 return snd_pcm_info_user(substream, arg); in snd_pcm_common_ioctl()
3233 return snd_pcm_tstamp(substream, arg); in snd_pcm_common_ioctl()
3240 return snd_pcm_hw_refine_user(substream, arg); in snd_pcm_common_ioctl()
3242 return snd_pcm_hw_params_user(substream, arg); in snd_pcm_common_ioctl()
3244 return snd_pcm_hw_free(substream); in snd_pcm_common_ioctl()
3246 return snd_pcm_sw_params_user(substream, arg); in snd_pcm_common_ioctl()
3248 return snd_pcm_status_user32(substream, arg, false); in snd_pcm_common_ioctl()
3250 return snd_pcm_status_user32(substream, arg, true); in snd_pcm_common_ioctl()
3252 return snd_pcm_status_user64(substream, arg, false); in snd_pcm_common_ioctl()
3254 return snd_pcm_status_user64(substream, arg, true); in snd_pcm_common_ioctl()
3256 return snd_pcm_channel_info_user(substream, arg); in snd_pcm_common_ioctl()
3258 return snd_pcm_prepare(substream, file); in snd_pcm_common_ioctl()
3260 return snd_pcm_reset(substream); in snd_pcm_common_ioctl()
3262 return snd_pcm_start_lock_irq(substream); in snd_pcm_common_ioctl()
3264 return snd_pcm_link(substream, (int)(unsigned long) arg); in snd_pcm_common_ioctl()
3266 return snd_pcm_unlink(substream); in snd_pcm_common_ioctl()
3268 return snd_pcm_resume(substream); in snd_pcm_common_ioctl()
3270 return snd_pcm_xrun(substream); in snd_pcm_common_ioctl()
3272 return snd_pcm_hwsync(substream); in snd_pcm_common_ioctl()
3279 err = snd_pcm_delay(substream, &delay); in snd_pcm_common_ioctl()
3287 return snd_pcm_ioctl_sync_ptr_compat(substream, arg); in snd_pcm_common_ioctl()
3289 return snd_pcm_sync_ptr(substream, arg); in snd_pcm_common_ioctl()
3292 return snd_pcm_hw_refine_old_user(substream, arg); in snd_pcm_common_ioctl()
3294 return snd_pcm_hw_params_old_user(substream, arg); in snd_pcm_common_ioctl()
3297 return snd_pcm_drain(substream, file); in snd_pcm_common_ioctl()
3299 return snd_pcm_drop(substream); in snd_pcm_common_ioctl()
3301 return snd_pcm_pause_lock_irq(substream, (unsigned long)arg); in snd_pcm_common_ioctl()
3304 return snd_pcm_xferi_frames_ioctl(substream, arg); in snd_pcm_common_ioctl()
3307 return snd_pcm_xfern_frames_ioctl(substream, arg); in snd_pcm_common_ioctl()
3309 return snd_pcm_rewind_ioctl(substream, arg); in snd_pcm_common_ioctl()
3311 return snd_pcm_forward_ioctl(substream, arg); in snd_pcm_common_ioctl()
3313 pcm_dbg(substream->pcm, "unknown ioctl = 0x%x\n", cmd); in snd_pcm_common_ioctl()
3327 return snd_pcm_common_ioctl(file, pcm_file->substream, cmd, in snd_pcm_ioctl()
3341 int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, in snd_pcm_kernel_ioctl() argument
3351 if (substream->stream != SNDRV_PCM_STREAM_CAPTURE) in snd_pcm_kernel_ioctl()
3353 result = snd_pcm_forward(substream, *frames); in snd_pcm_kernel_ioctl()
3357 return snd_pcm_hw_params(substream, arg); in snd_pcm_kernel_ioctl()
3359 return snd_pcm_sw_params(substream, arg); in snd_pcm_kernel_ioctl()
3361 return snd_pcm_prepare(substream, NULL); in snd_pcm_kernel_ioctl()
3363 return snd_pcm_start_lock_irq(substream); in snd_pcm_kernel_ioctl()
3365 return snd_pcm_drain(substream, NULL); in snd_pcm_kernel_ioctl()
3367 return snd_pcm_drop(substream); in snd_pcm_kernel_ioctl()
3369 return snd_pcm_delay(substream, frames); in snd_pcm_kernel_ioctl()
3380 struct snd_pcm_substream *substream; in snd_pcm_read() local
3385 substream = pcm_file->substream; in snd_pcm_read()
3386 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_read()
3388 runtime = substream->runtime; in snd_pcm_read()
3394 result = snd_pcm_lib_read(substream, buf, count); in snd_pcm_read()
3404 struct snd_pcm_substream *substream; in snd_pcm_write() local
3409 substream = pcm_file->substream; in snd_pcm_write()
3410 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_write()
3412 runtime = substream->runtime; in snd_pcm_write()
3418 result = snd_pcm_lib_write(substream, buf, count); in snd_pcm_write()
3427 struct snd_pcm_substream *substream; in snd_pcm_readv() local
3435 substream = pcm_file->substream; in snd_pcm_readv()
3436 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_readv()
3438 runtime = substream->runtime; in snd_pcm_readv()
3453 result = snd_pcm_lib_readv(substream, bufs, frames); in snd_pcm_readv()
3463 struct snd_pcm_substream *substream; in snd_pcm_writev() local
3471 substream = pcm_file->substream; in snd_pcm_writev()
3472 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_writev()
3474 runtime = substream->runtime; in snd_pcm_writev()
3488 result = snd_pcm_lib_writev(substream, bufs, frames); in snd_pcm_writev()
3498 struct snd_pcm_substream *substream; in snd_pcm_poll() local
3505 substream = pcm_file->substream; in snd_pcm_poll()
3506 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_poll()
3510 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_poll()
3513 runtime = substream->runtime; in snd_pcm_poll()
3517 snd_pcm_stream_lock_irq(substream); in snd_pcm_poll()
3518 avail = snd_pcm_avail(substream); in snd_pcm_poll()
3527 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in snd_pcm_poll()
3537 snd_pcm_stream_unlock_irq(substream); in snd_pcm_poll()
3555 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_status_fault() local
3558 if (substream == NULL) in snd_pcm_mmap_status_fault()
3560 runtime = substream->runtime; in snd_pcm_mmap_status_fault()
3571 static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_status() argument
3581 area->vm_private_data = substream; in snd_pcm_mmap_status()
3591 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_control_fault() local
3594 if (substream == NULL) in snd_pcm_mmap_control_fault()
3596 runtime = substream->runtime; in snd_pcm_mmap_control_fault()
3607 static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_control() argument
3617 area->vm_private_data = substream; in snd_pcm_mmap_control()
3628 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_status_mmap_allowed()
3635 (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR)) in pcm_status_mmap_allowed()
3645 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_control_mmap_allowed()
3651 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR) in pcm_control_mmap_allowed()
3663 static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_status() argument
3668 static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_control() argument
3680 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_data_fault() local
3686 if (substream == NULL) in snd_pcm_mmap_data_fault()
3688 runtime = substream->runtime; in snd_pcm_mmap_data_fault()
3693 if (substream->ops->page) in snd_pcm_mmap_data_fault()
3694 page = substream->ops->page(substream, offset); in snd_pcm_mmap_data_fault()
3695 else if (!snd_pcm_get_dma_buf(substream)) in snd_pcm_mmap_data_fault()
3698 page = snd_sgbuf_get_page(snd_pcm_get_dma_buf(substream), offset); in snd_pcm_mmap_data_fault()
3729 int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream, in snd_pcm_lib_default_mmap() argument
3733 if (!substream->ops->page && in snd_pcm_lib_default_mmap()
3734 !snd_dma_buffer_mmap(snd_pcm_get_dma_buf(substream), area)) in snd_pcm_lib_default_mmap()
3755 int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, in snd_pcm_lib_mmap_iomem() argument
3758 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_mmap_iomem()
3769 int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_data() argument
3778 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_mmap_data()
3785 runtime = substream->runtime; in snd_pcm_mmap_data()
3802 area->vm_private_data = substream; in snd_pcm_mmap_data()
3803 if (substream->ops->mmap) in snd_pcm_mmap_data()
3804 err = substream->ops->mmap(substream, area); in snd_pcm_mmap_data()
3806 err = snd_pcm_lib_default_mmap(substream, area); in snd_pcm_mmap_data()
3808 atomic_inc(&substream->mmap_count); in snd_pcm_mmap_data()
3816 struct snd_pcm_substream *substream; in snd_pcm_mmap() local
3820 substream = pcm_file->substream; in snd_pcm_mmap()
3821 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_mmap()
3833 return snd_pcm_mmap_status(substream, file, area); in snd_pcm_mmap()
3841 return snd_pcm_mmap_control(substream, file, area); in snd_pcm_mmap()
3843 return snd_pcm_mmap_data(substream, file, area); in snd_pcm_mmap()
3851 struct snd_pcm_substream *substream; in snd_pcm_fasync() local
3855 substream = pcm_file->substream; in snd_pcm_fasync()
3856 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_fasync()
3858 runtime = substream->runtime; in snd_pcm_fasync()
3917 static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, in snd_pcm_hw_refine_old_user() argument
3934 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_refine_old_user()
3938 err = fixup_unreferenced_params(substream, params); in snd_pcm_hw_refine_old_user()
3952 static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, in snd_pcm_hw_params_old_user() argument
3970 err = snd_pcm_hw_params(substream, params); in snd_pcm_hw_params_old_user()
3993 struct snd_pcm_substream *substream = pcm_file->substream; in snd_pcm_get_unmapped_area() local
3994 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_get_unmapped_area()