Lines Matching refs:substream
48 #define trace_hw_mask_param(substream, type, index, prev, curr) argument
49 #define trace_hw_interval_param(substream, type, index, prev, curr) argument
76 static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream,
78 static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream,
106 static unsigned long __snd_pcm_stream_lock_mode(struct snd_pcm_substream *substream, in __snd_pcm_stream_lock_mode() argument
110 if (substream->pcm->nonatomic) { in __snd_pcm_stream_lock_mode()
112 mutex_lock(&substream->self_group.mutex); in __snd_pcm_stream_lock_mode()
125 spin_lock(&substream->self_group.lock); in __snd_pcm_stream_lock_mode()
130 static void __snd_pcm_stream_unlock_mode(struct snd_pcm_substream *substream, in __snd_pcm_stream_unlock_mode() argument
133 if (substream->pcm->nonatomic) { in __snd_pcm_stream_unlock_mode()
134 mutex_unlock(&substream->self_group.mutex); in __snd_pcm_stream_unlock_mode()
137 spin_unlock(&substream->self_group.lock); in __snd_pcm_stream_unlock_mode()
161 void snd_pcm_stream_lock(struct snd_pcm_substream *substream) in snd_pcm_stream_lock() argument
163 __snd_pcm_stream_lock_mode(substream, PCM_LOCK_DEFAULT); in snd_pcm_stream_lock()
173 void snd_pcm_stream_unlock(struct snd_pcm_substream *substream) in snd_pcm_stream_unlock() argument
175 __snd_pcm_stream_unlock_mode(substream, PCM_LOCK_DEFAULT, 0); in snd_pcm_stream_unlock()
187 void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream) in snd_pcm_stream_lock_irq() argument
189 __snd_pcm_stream_lock_mode(substream, PCM_LOCK_IRQ); in snd_pcm_stream_lock_irq()
199 void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream) in snd_pcm_stream_unlock_irq() argument
201 __snd_pcm_stream_unlock_mode(substream, PCM_LOCK_IRQ, 0); in snd_pcm_stream_unlock_irq()
205 unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream) in _snd_pcm_stream_lock_irqsave() argument
207 return __snd_pcm_stream_lock_mode(substream, PCM_LOCK_IRQSAVE); in _snd_pcm_stream_lock_irqsave()
218 void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream, in snd_pcm_stream_unlock_irqrestore() argument
221 __snd_pcm_stream_unlock_mode(substream, PCM_LOCK_IRQSAVE, flags); in snd_pcm_stream_unlock_irqrestore()
225 int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info) in snd_pcm_info() argument
227 struct snd_pcm *pcm = substream->pcm; in snd_pcm_info()
228 struct snd_pcm_str *pstr = substream->pstr; in snd_pcm_info()
233 info->stream = substream->stream; in snd_pcm_info()
234 info->subdevice = substream->number; in snd_pcm_info()
241 strlcpy(info->subname, substream->name, sizeof(info->subname)); in snd_pcm_info()
246 int snd_pcm_info_user(struct snd_pcm_substream *substream, in snd_pcm_info_user() argument
255 err = snd_pcm_info(substream, info); in snd_pcm_info_user()
264 static bool hw_support_mmap(struct snd_pcm_substream *substream) in hw_support_mmap() argument
266 if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_MMAP)) in hw_support_mmap()
270 if (!substream->ops->mmap && in hw_support_mmap()
271 substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) in hw_support_mmap()
277 static int constrain_mask_params(struct snd_pcm_substream *substream, in constrain_mask_params() argument
281 &substream->runtime->hw_constraints; in constrain_mask_params()
306 trace_hw_mask_param(substream, k, 0, &old_mask, m); in constrain_mask_params()
313 static int constrain_interval_params(struct snd_pcm_substream *substream, in constrain_interval_params() argument
317 &substream->runtime->hw_constraints; in constrain_interval_params()
342 trace_hw_interval_param(substream, k, 0, &old_interval, i); in constrain_interval_params()
349 static int constrain_params_by_rules(struct snd_pcm_substream *substream, in constrain_params_by_rules() argument
353 &substream->runtime->hw_constraints; in constrain_params_by_rules()
443 trace_hw_mask_param(substream, r->var, in constrain_params_by_rules()
448 trace_hw_interval_param(substream, r->var, in constrain_params_by_rules()
470 static int fixup_unreferenced_params(struct snd_pcm_substream *substream, in fixup_unreferenced_params() argument
495 err = substream->ops->ioctl(substream, in fixup_unreferenced_params()
503 params->info = substream->runtime->hw.info; in fixup_unreferenced_params()
506 if (!hw_support_mmap(substream)) in fixup_unreferenced_params()
514 int snd_pcm_hw_refine(struct snd_pcm_substream *substream, in snd_pcm_hw_refine() argument
528 err = constrain_mask_params(substream, params); in snd_pcm_hw_refine()
532 err = constrain_interval_params(substream, params); in snd_pcm_hw_refine()
536 err = constrain_params_by_rules(substream, params); in snd_pcm_hw_refine()
546 static int snd_pcm_hw_refine_user(struct snd_pcm_substream *substream, in snd_pcm_hw_refine_user() argument
556 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_refine_user()
560 err = fixup_unreferenced_params(substream, params); in snd_pcm_hw_refine_user()
586 static void snd_pcm_set_state(struct snd_pcm_substream *substream, int state) in snd_pcm_set_state() argument
588 snd_pcm_stream_lock_irq(substream); in snd_pcm_set_state()
589 if (substream->runtime->status->state != SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_set_state()
590 substream->runtime->status->state = state; in snd_pcm_set_state()
591 snd_pcm_stream_unlock_irq(substream); in snd_pcm_set_state()
594 static inline void snd_pcm_timer_notify(struct snd_pcm_substream *substream, in snd_pcm_timer_notify() argument
598 if (substream->timer) in snd_pcm_timer_notify()
599 snd_timer_notify(substream->timer, event, in snd_pcm_timer_notify()
600 &substream->runtime->trigger_tstamp); in snd_pcm_timer_notify()
668 static int snd_pcm_hw_params(struct snd_pcm_substream *substream, in snd_pcm_hw_params() argument
676 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_hw_params()
678 runtime = substream->runtime; in snd_pcm_hw_params()
679 snd_pcm_stream_lock_irq(substream); in snd_pcm_hw_params()
686 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_params()
689 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_params()
691 if (!substream->oss.oss) in snd_pcm_hw_params()
693 if (atomic_read(&substream->mmap_count)) in snd_pcm_hw_params()
697 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_params()
701 err = snd_pcm_hw_params_choose(substream, params); in snd_pcm_hw_params()
705 err = fixup_unreferenced_params(substream, params); in snd_pcm_hw_params()
709 if (substream->ops->hw_params != NULL) { in snd_pcm_hw_params()
710 err = substream->ops->hw_params(substream, params); in snd_pcm_hw_params()
754 snd_pcm_timer_resolution_change(substream); in snd_pcm_hw_params()
755 snd_pcm_set_state(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_hw_params()
757 if (pm_qos_request_active(&substream->latency_pm_qos_req)) in snd_pcm_hw_params()
758 pm_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_hw_params()
760 pm_qos_add_request(&substream->latency_pm_qos_req, in snd_pcm_hw_params()
767 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); in snd_pcm_hw_params()
768 if (substream->ops->hw_free != NULL) in snd_pcm_hw_params()
769 substream->ops->hw_free(substream); in snd_pcm_hw_params()
773 static int snd_pcm_hw_params_user(struct snd_pcm_substream *substream, in snd_pcm_hw_params_user() argument
783 err = snd_pcm_hw_params(substream, params); in snd_pcm_hw_params_user()
794 static int snd_pcm_hw_free(struct snd_pcm_substream *substream) in snd_pcm_hw_free() argument
799 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_hw_free()
801 runtime = substream->runtime; in snd_pcm_hw_free()
802 snd_pcm_stream_lock_irq(substream); in snd_pcm_hw_free()
808 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_free()
811 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_free()
812 if (atomic_read(&substream->mmap_count)) in snd_pcm_hw_free()
814 if (substream->ops->hw_free) in snd_pcm_hw_free()
815 result = substream->ops->hw_free(substream); in snd_pcm_hw_free()
816 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); in snd_pcm_hw_free()
817 pm_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_hw_free()
821 static int snd_pcm_sw_params(struct snd_pcm_substream *substream, in snd_pcm_sw_params() argument
827 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_sw_params()
829 runtime = substream->runtime; in snd_pcm_sw_params()
830 snd_pcm_stream_lock_irq(substream); in snd_pcm_sw_params()
832 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sw_params()
835 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sw_params()
855 snd_pcm_stream_lock_irq(substream); in snd_pcm_sw_params()
866 if (snd_pcm_running(substream)) { in snd_pcm_sw_params()
867 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_sw_params()
869 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_sw_params()
870 err = snd_pcm_update_state(substream, runtime); in snd_pcm_sw_params()
872 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sw_params()
876 static int snd_pcm_sw_params_user(struct snd_pcm_substream *substream, in snd_pcm_sw_params_user() argument
883 err = snd_pcm_sw_params(substream, ¶ms); in snd_pcm_sw_params_user()
890 snd_pcm_calc_delay(struct snd_pcm_substream *substream) in snd_pcm_calc_delay() argument
894 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_calc_delay()
895 delay = snd_pcm_playback_hw_avail(substream->runtime); in snd_pcm_calc_delay()
897 delay = snd_pcm_capture_avail(substream->runtime); in snd_pcm_calc_delay()
898 return delay + substream->runtime->delay; in snd_pcm_calc_delay()
901 int snd_pcm_status(struct snd_pcm_substream *substream, in snd_pcm_status() argument
904 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_status()
906 snd_pcm_stream_lock_irq(substream); in snd_pcm_status()
929 if (snd_pcm_running(substream)) { in snd_pcm_status()
930 snd_pcm_update_hw_ptr(substream); in snd_pcm_status()
952 status->avail = snd_pcm_avail(substream); in snd_pcm_status()
953 status->delay = snd_pcm_running(substream) ? in snd_pcm_status()
954 snd_pcm_calc_delay(substream) : 0; in snd_pcm_status()
960 snd_pcm_stream_unlock_irq(substream); in snd_pcm_status()
964 static int snd_pcm_status_user(struct snd_pcm_substream *substream, in snd_pcm_status_user() argument
980 res = snd_pcm_status(substream, &status); in snd_pcm_status_user()
988 static int snd_pcm_channel_info(struct snd_pcm_substream *substream, in snd_pcm_channel_info() argument
995 runtime = substream->runtime; in snd_pcm_channel_info()
996 snd_pcm_stream_lock_irq(substream); in snd_pcm_channel_info()
998 snd_pcm_stream_unlock_irq(substream); in snd_pcm_channel_info()
1001 snd_pcm_stream_unlock_irq(substream); in snd_pcm_channel_info()
1006 return substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_CHANNEL_INFO, info); in snd_pcm_channel_info()
1009 static int snd_pcm_channel_info_user(struct snd_pcm_substream *substream, in snd_pcm_channel_info_user() argument
1017 res = snd_pcm_channel_info(substream, &info); in snd_pcm_channel_info_user()
1025 static void snd_pcm_trigger_tstamp(struct snd_pcm_substream *substream) in snd_pcm_trigger_tstamp() argument
1027 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_trigger_tstamp()
1030 if (runtime->trigger_master == substream) { in snd_pcm_trigger_tstamp()
1041 int (*pre_action)(struct snd_pcm_substream *substream, int state);
1042 int (*do_action)(struct snd_pcm_substream *substream, int state);
1043 void (*undo_action)(struct snd_pcm_substream *substream, int state);
1044 void (*post_action)(struct snd_pcm_substream *substream, int state);
1053 struct snd_pcm_substream *substream, in snd_pcm_action_group() argument
1060 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
1061 if (do_lock && s != substream) { in snd_pcm_action_group()
1072 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
1076 snd_pcm_group_for_each_entry(s1, substream) { in snd_pcm_action_group()
1086 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
1092 snd_pcm_group_for_each_entry(s1, substream) { in snd_pcm_action_group()
1093 if (s1 != substream) { in snd_pcm_action_group()
1110 struct snd_pcm_substream *substream, in snd_pcm_action_single() argument
1115 res = ops->pre_action(substream, state); in snd_pcm_action_single()
1118 res = ops->do_action(substream, state); in snd_pcm_action_single()
1120 ops->post_action(substream, state); in snd_pcm_action_single()
1122 ops->undo_action(substream, state); in snd_pcm_action_single()
1130 struct snd_pcm_substream *substream, in snd_pcm_action() argument
1135 if (!snd_pcm_stream_linked(substream)) in snd_pcm_action()
1136 return snd_pcm_action_single(ops, substream, state); in snd_pcm_action()
1138 if (substream->pcm->nonatomic) { in snd_pcm_action()
1139 if (!mutex_trylock(&substream->group->mutex)) { in snd_pcm_action()
1140 mutex_unlock(&substream->self_group.mutex); in snd_pcm_action()
1141 mutex_lock(&substream->group->mutex); in snd_pcm_action()
1142 mutex_lock(&substream->self_group.mutex); in snd_pcm_action()
1144 res = snd_pcm_action_group(ops, substream, state, 1); in snd_pcm_action()
1145 mutex_unlock(&substream->group->mutex); in snd_pcm_action()
1147 if (!spin_trylock(&substream->group->lock)) { in snd_pcm_action()
1148 spin_unlock(&substream->self_group.lock); in snd_pcm_action()
1149 spin_lock(&substream->group->lock); in snd_pcm_action()
1150 spin_lock(&substream->self_group.lock); in snd_pcm_action()
1152 res = snd_pcm_action_group(ops, substream, state, 1); in snd_pcm_action()
1153 spin_unlock(&substream->group->lock); in snd_pcm_action()
1162 struct snd_pcm_substream *substream, in snd_pcm_action_lock_irq() argument
1167 snd_pcm_stream_lock_irq(substream); in snd_pcm_action_lock_irq()
1168 res = snd_pcm_action(ops, substream, state); in snd_pcm_action_lock_irq()
1169 snd_pcm_stream_unlock_irq(substream); in snd_pcm_action_lock_irq()
1176 struct snd_pcm_substream *substream, in snd_pcm_action_nonatomic() argument
1182 if (snd_pcm_stream_linked(substream)) in snd_pcm_action_nonatomic()
1183 res = snd_pcm_action_group(ops, substream, state, 0); in snd_pcm_action_nonatomic()
1185 res = snd_pcm_action_single(ops, substream, state); in snd_pcm_action_nonatomic()
1193 static int snd_pcm_pre_start(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_start() argument
1195 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_start()
1198 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_pre_start()
1199 !snd_pcm_playback_data(substream)) in snd_pcm_pre_start()
1202 runtime->trigger_master = substream; in snd_pcm_pre_start()
1206 static int snd_pcm_do_start(struct snd_pcm_substream *substream, int state) in snd_pcm_do_start() argument
1208 if (substream->runtime->trigger_master != substream) in snd_pcm_do_start()
1210 return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_START); in snd_pcm_do_start()
1213 static void snd_pcm_undo_start(struct snd_pcm_substream *substream, int state) in snd_pcm_undo_start() argument
1215 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_start()
1216 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); in snd_pcm_undo_start()
1219 static void snd_pcm_post_start(struct snd_pcm_substream *substream, int state) in snd_pcm_post_start() argument
1221 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_start()
1222 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_start()
1227 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_post_start()
1229 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_post_start()
1230 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSTART); in snd_pcm_post_start()
1247 int snd_pcm_start(struct snd_pcm_substream *substream) in snd_pcm_start() argument
1249 return snd_pcm_action(&snd_pcm_action_start, substream, in snd_pcm_start()
1254 static int snd_pcm_start_lock_irq(struct snd_pcm_substream *substream) in snd_pcm_start_lock_irq() argument
1256 return snd_pcm_action_lock_irq(&snd_pcm_action_start, substream, in snd_pcm_start_lock_irq()
1263 static int snd_pcm_pre_stop(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_stop() argument
1265 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_stop()
1268 runtime->trigger_master = substream; in snd_pcm_pre_stop()
1272 static int snd_pcm_do_stop(struct snd_pcm_substream *substream, int state) in snd_pcm_do_stop() argument
1274 if (substream->runtime->trigger_master == substream && in snd_pcm_do_stop()
1275 snd_pcm_running(substream)) in snd_pcm_do_stop()
1276 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); in snd_pcm_do_stop()
1280 static void snd_pcm_post_stop(struct snd_pcm_substream *substream, int state) in snd_pcm_post_stop() argument
1282 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_stop()
1284 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_stop()
1286 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSTOP); in snd_pcm_post_stop()
1307 int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state) in snd_pcm_stop() argument
1309 return snd_pcm_action(&snd_pcm_action_stop, substream, state); in snd_pcm_stop()
1322 int snd_pcm_drain_done(struct snd_pcm_substream *substream) in snd_pcm_drain_done() argument
1324 return snd_pcm_action_single(&snd_pcm_action_stop, substream, in snd_pcm_drain_done()
1337 int snd_pcm_stop_xrun(struct snd_pcm_substream *substream) in snd_pcm_stop_xrun() argument
1341 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_stop_xrun()
1342 if (substream->runtime && snd_pcm_running(substream)) in snd_pcm_stop_xrun()
1343 __snd_pcm_xrun(substream); in snd_pcm_stop_xrun()
1344 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_stop_xrun()
1352 static int snd_pcm_pre_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_pre_pause() argument
1354 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_pause()
1362 runtime->trigger_master = substream; in snd_pcm_pre_pause()
1366 static int snd_pcm_do_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_do_pause() argument
1368 if (substream->runtime->trigger_master != substream) in snd_pcm_do_pause()
1373 snd_pcm_update_hw_ptr(substream); in snd_pcm_do_pause()
1378 substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000; in snd_pcm_do_pause()
1379 return substream->ops->trigger(substream, in snd_pcm_do_pause()
1384 static void snd_pcm_undo_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_undo_pause() argument
1386 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_pause()
1387 substream->ops->trigger(substream, in snd_pcm_undo_pause()
1392 static void snd_pcm_post_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_post_pause() argument
1394 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_pause()
1395 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_pause()
1398 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MPAUSE); in snd_pcm_post_pause()
1403 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MCONTINUE); in snd_pcm_post_pause()
1417 static int snd_pcm_pause(struct snd_pcm_substream *substream, int push) in snd_pcm_pause() argument
1419 return snd_pcm_action(&snd_pcm_action_pause, substream, push); in snd_pcm_pause()
1425 static int snd_pcm_pre_suspend(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_suspend() argument
1427 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_suspend()
1430 runtime->trigger_master = substream; in snd_pcm_pre_suspend()
1434 static int snd_pcm_do_suspend(struct snd_pcm_substream *substream, int state) in snd_pcm_do_suspend() argument
1436 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_suspend()
1437 if (runtime->trigger_master != substream) in snd_pcm_do_suspend()
1439 if (! snd_pcm_running(substream)) in snd_pcm_do_suspend()
1441 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); in snd_pcm_do_suspend()
1445 static void snd_pcm_post_suspend(struct snd_pcm_substream *substream, int state) in snd_pcm_post_suspend() argument
1447 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_suspend()
1448 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_suspend()
1451 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSUSPEND); in snd_pcm_post_suspend()
1471 int snd_pcm_suspend(struct snd_pcm_substream *substream) in snd_pcm_suspend() argument
1476 if (! substream) in snd_pcm_suspend()
1479 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_suspend()
1480 err = snd_pcm_action(&snd_pcm_action_suspend, substream, 0); in snd_pcm_suspend()
1481 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_suspend()
1496 struct snd_pcm_substream *substream; in snd_pcm_suspend_all() local
1503 for (substream = pcm->streams[stream].substream; in snd_pcm_suspend_all()
1504 substream; substream = substream->next) { in snd_pcm_suspend_all()
1506 if (substream->runtime == NULL) in snd_pcm_suspend_all()
1508 err = snd_pcm_suspend(substream); in snd_pcm_suspend_all()
1519 static int snd_pcm_pre_resume(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_resume() argument
1521 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_resume()
1524 runtime->trigger_master = substream; in snd_pcm_pre_resume()
1528 static int snd_pcm_do_resume(struct snd_pcm_substream *substream, int state) in snd_pcm_do_resume() argument
1530 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_resume()
1531 if (runtime->trigger_master != substream) in snd_pcm_do_resume()
1536 substream->stream != SNDRV_PCM_STREAM_PLAYBACK)) in snd_pcm_do_resume()
1538 return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_RESUME); in snd_pcm_do_resume()
1541 static void snd_pcm_undo_resume(struct snd_pcm_substream *substream, int state) in snd_pcm_undo_resume() argument
1543 if (substream->runtime->trigger_master == substream && in snd_pcm_undo_resume()
1544 snd_pcm_running(substream)) in snd_pcm_undo_resume()
1545 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); in snd_pcm_undo_resume()
1548 static void snd_pcm_post_resume(struct snd_pcm_substream *substream, int state) in snd_pcm_post_resume() argument
1550 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_resume()
1551 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_resume()
1553 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MRESUME); in snd_pcm_post_resume()
1563 static int snd_pcm_resume(struct snd_pcm_substream *substream) in snd_pcm_resume() argument
1565 return snd_pcm_action_lock_irq(&snd_pcm_action_resume, substream, 0); in snd_pcm_resume()
1570 static int snd_pcm_resume(struct snd_pcm_substream *substream) in snd_pcm_resume() argument
1582 static int snd_pcm_xrun(struct snd_pcm_substream *substream) in snd_pcm_xrun() argument
1584 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xrun()
1587 snd_pcm_stream_lock_irq(substream); in snd_pcm_xrun()
1593 __snd_pcm_xrun(substream); in snd_pcm_xrun()
1599 snd_pcm_stream_unlock_irq(substream); in snd_pcm_xrun()
1606 static int snd_pcm_pre_reset(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_reset() argument
1608 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_reset()
1620 static int snd_pcm_do_reset(struct snd_pcm_substream *substream, int state) in snd_pcm_do_reset() argument
1622 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_reset()
1623 int err = substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL); in snd_pcm_do_reset()
1634 static void snd_pcm_post_reset(struct snd_pcm_substream *substream, int state) in snd_pcm_post_reset() argument
1636 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_reset()
1638 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_post_reset()
1640 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_post_reset()
1649 static int snd_pcm_reset(struct snd_pcm_substream *substream) in snd_pcm_reset() argument
1651 return snd_pcm_action_nonatomic(&snd_pcm_action_reset, substream, 0); in snd_pcm_reset()
1658 static int snd_pcm_pre_prepare(struct snd_pcm_substream *substream, in snd_pcm_pre_prepare() argument
1661 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_prepare()
1665 if (snd_pcm_running(substream)) in snd_pcm_pre_prepare()
1667 substream->f_flags = f_flags; in snd_pcm_pre_prepare()
1671 static int snd_pcm_do_prepare(struct snd_pcm_substream *substream, int state) in snd_pcm_do_prepare() argument
1674 err = substream->ops->prepare(substream); in snd_pcm_do_prepare()
1677 return snd_pcm_do_reset(substream, 0); in snd_pcm_do_prepare()
1680 static void snd_pcm_post_prepare(struct snd_pcm_substream *substream, int state) in snd_pcm_post_prepare() argument
1682 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_prepare()
1684 snd_pcm_set_state(substream, SNDRV_PCM_STATE_PREPARED); in snd_pcm_post_prepare()
1700 static int snd_pcm_prepare(struct snd_pcm_substream *substream, in snd_pcm_prepare() argument
1708 f_flags = substream->f_flags; in snd_pcm_prepare()
1710 snd_pcm_stream_lock_irq(substream); in snd_pcm_prepare()
1711 switch (substream->runtime->status->state) { in snd_pcm_prepare()
1713 snd_pcm_pause(substream, 0); in snd_pcm_prepare()
1716 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_prepare()
1719 snd_pcm_stream_unlock_irq(substream); in snd_pcm_prepare()
1722 substream, f_flags); in snd_pcm_prepare()
1729 static int snd_pcm_pre_drain_init(struct snd_pcm_substream *substream, int state) in snd_pcm_pre_drain_init() argument
1731 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_drain_init()
1738 runtime->trigger_master = substream; in snd_pcm_pre_drain_init()
1742 static int snd_pcm_do_drain_init(struct snd_pcm_substream *substream, int state) in snd_pcm_do_drain_init() argument
1744 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_drain_init()
1745 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_do_drain_init()
1749 if (! snd_pcm_playback_empty(substream)) { in snd_pcm_do_drain_init()
1750 snd_pcm_do_start(substream, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
1751 snd_pcm_post_start(substream, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
1770 snd_pcm_do_stop(substream, new_state); in snd_pcm_do_drain_init()
1771 snd_pcm_post_stop(substream, new_state); in snd_pcm_do_drain_init()
1776 runtime->trigger_master == substream && in snd_pcm_do_drain_init()
1778 return substream->ops->trigger(substream, in snd_pcm_do_drain_init()
1784 static void snd_pcm_post_drain_init(struct snd_pcm_substream *substream, int state) in snd_pcm_post_drain_init() argument
1794 static int snd_pcm_drop(struct snd_pcm_substream *substream);
1803 static int snd_pcm_drain(struct snd_pcm_substream *substream, in snd_pcm_drain() argument
1813 card = substream->pcm->card; in snd_pcm_drain()
1814 runtime = substream->runtime; in snd_pcm_drain()
1822 } else if (substream->f_flags & O_NONBLOCK) in snd_pcm_drain()
1826 snd_pcm_stream_lock_irq(substream); in snd_pcm_drain()
1829 snd_pcm_pause(substream, 0); in snd_pcm_drain()
1832 result = snd_pcm_action(&snd_pcm_action_drain_init, substream, 0); in snd_pcm_drain()
1850 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_drain()
1863 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drain()
1877 snd_pcm_stream_lock_irq(substream); in snd_pcm_drain()
1884 if (substream->runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) in snd_pcm_drain()
1887 dev_dbg(substream->pcm->card->dev, in snd_pcm_drain()
1889 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_drain()
1897 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drain()
1908 static int snd_pcm_drop(struct snd_pcm_substream *substream) in snd_pcm_drop() argument
1913 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_drop()
1915 runtime = substream->runtime; in snd_pcm_drop()
1921 snd_pcm_stream_lock_irq(substream); in snd_pcm_drop()
1924 snd_pcm_pause(substream, 0); in snd_pcm_drop()
1926 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_drop()
1928 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drop()
1949 static int snd_pcm_link(struct snd_pcm_substream *substream, int fd) in snd_pcm_link() argument
1964 substream1 = pcm_file->substream; in snd_pcm_link()
1972 if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_link()
1973 substream->runtime->status->state != substream1->runtime->status->state || in snd_pcm_link()
1974 substream->pcm->nonatomic != substream1->pcm->nonatomic) { in snd_pcm_link()
1982 if (!snd_pcm_stream_linked(substream)) { in snd_pcm_link()
1983 substream->group = group; in snd_pcm_link()
1985 spin_lock_init(&substream->group->lock); in snd_pcm_link()
1986 mutex_init(&substream->group->mutex); in snd_pcm_link()
1987 INIT_LIST_HEAD(&substream->group->substreams); in snd_pcm_link()
1988 list_add_tail(&substream->link_list, &substream->group->substreams); in snd_pcm_link()
1989 substream->group->count = 1; in snd_pcm_link()
1991 list_add_tail(&substream1->link_list, &substream->group->substreams); in snd_pcm_link()
1992 substream->group->count++; in snd_pcm_link()
1993 substream1->group = substream->group; in snd_pcm_link()
2005 static void relink_to_local(struct snd_pcm_substream *substream) in relink_to_local() argument
2007 substream->group = &substream->self_group; in relink_to_local()
2008 INIT_LIST_HEAD(&substream->self_group.substreams); in relink_to_local()
2009 list_add_tail(&substream->link_list, &substream->self_group.substreams); in relink_to_local()
2012 static int snd_pcm_unlink(struct snd_pcm_substream *substream) in snd_pcm_unlink() argument
2019 if (!snd_pcm_stream_linked(substream)) { in snd_pcm_unlink()
2023 list_del(&substream->link_list); in snd_pcm_unlink()
2024 substream->group->count--; in snd_pcm_unlink()
2025 if (substream->group->count == 1) { /* detach the last stream, too */ in snd_pcm_unlink()
2026 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_unlink()
2030 kfree(substream->group); in snd_pcm_unlink()
2032 relink_to_local(substream); in snd_pcm_unlink()
2154 struct snd_pcm_substream *substream = rule->private; in snd_pcm_hw_rule_buffer_bytes_max() local
2156 t.max = substream->buffer_bytes_max; in snd_pcm_hw_rule_buffer_bytes_max()
2163 int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream) in snd_pcm_hw_constraints_init() argument
2165 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_init()
2287 int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) in snd_pcm_hw_constraints_complete() argument
2289 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_complete()
2298 if (hw_support_mmap(substream)) { in snd_pcm_hw_constraints_complete()
2344 snd_pcm_hw_rule_buffer_bytes_max, substream, in snd_pcm_hw_constraints_complete()
2370 static void pcm_release_private(struct snd_pcm_substream *substream) in pcm_release_private() argument
2372 snd_pcm_unlink(substream); in pcm_release_private()
2375 void snd_pcm_release_substream(struct snd_pcm_substream *substream) in snd_pcm_release_substream() argument
2377 substream->ref_count--; in snd_pcm_release_substream()
2378 if (substream->ref_count > 0) in snd_pcm_release_substream()
2381 snd_pcm_drop(substream); in snd_pcm_release_substream()
2382 if (substream->hw_opened) { in snd_pcm_release_substream()
2383 if (substream->ops->hw_free && in snd_pcm_release_substream()
2384 substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) in snd_pcm_release_substream()
2385 substream->ops->hw_free(substream); in snd_pcm_release_substream()
2386 substream->ops->close(substream); in snd_pcm_release_substream()
2387 substream->hw_opened = 0; in snd_pcm_release_substream()
2389 if (pm_qos_request_active(&substream->latency_pm_qos_req)) in snd_pcm_release_substream()
2390 pm_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_release_substream()
2391 if (substream->pcm_release) { in snd_pcm_release_substream()
2392 substream->pcm_release(substream); in snd_pcm_release_substream()
2393 substream->pcm_release = NULL; in snd_pcm_release_substream()
2395 snd_pcm_detach_substream(substream); in snd_pcm_release_substream()
2403 struct snd_pcm_substream *substream; in snd_pcm_open_substream() local
2406 err = snd_pcm_attach_substream(pcm, stream, file, &substream); in snd_pcm_open_substream()
2409 if (substream->ref_count > 1) { in snd_pcm_open_substream()
2410 *rsubstream = substream; in snd_pcm_open_substream()
2414 err = snd_pcm_hw_constraints_init(substream); in snd_pcm_open_substream()
2420 if ((err = substream->ops->open(substream)) < 0) in snd_pcm_open_substream()
2423 substream->hw_opened = 1; in snd_pcm_open_substream()
2425 err = snd_pcm_hw_constraints_complete(substream); in snd_pcm_open_substream()
2431 *rsubstream = substream; in snd_pcm_open_substream()
2435 snd_pcm_release_substream(substream); in snd_pcm_open_substream()
2445 struct snd_pcm_substream *substream; in snd_pcm_open_file() local
2448 err = snd_pcm_open_substream(pcm, stream, file, &substream); in snd_pcm_open_file()
2454 snd_pcm_release_substream(substream); in snd_pcm_open_file()
2457 pcm_file->substream = substream; in snd_pcm_open_file()
2458 if (substream->ref_count == 1) { in snd_pcm_open_file()
2459 substream->file = pcm_file; in snd_pcm_open_file()
2460 substream->pcm_release = pcm_release_private; in snd_pcm_open_file()
2555 struct snd_pcm_substream *substream; in snd_pcm_release() local
2559 substream = pcm_file->substream; in snd_pcm_release()
2560 if (snd_BUG_ON(!substream)) in snd_pcm_release()
2562 pcm = substream->pcm; in snd_pcm_release()
2564 snd_pcm_release_substream(substream); in snd_pcm_release()
2576 static int do_pcm_hwsync(struct snd_pcm_substream *substream) in do_pcm_hwsync() argument
2578 switch (substream->runtime->status->state) { in do_pcm_hwsync()
2580 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in do_pcm_hwsync()
2584 return snd_pcm_update_hw_ptr(substream); in do_pcm_hwsync()
2598 static snd_pcm_sframes_t forward_appl_ptr(struct snd_pcm_substream *substream, in forward_appl_ptr() argument
2602 struct snd_pcm_runtime *runtime = substream->runtime; in forward_appl_ptr()
2613 ret = pcm_lib_apply_appl_ptr(substream, appl_ptr); in forward_appl_ptr()
2618 static snd_pcm_sframes_t rewind_appl_ptr(struct snd_pcm_substream *substream, in rewind_appl_ptr() argument
2622 struct snd_pcm_runtime *runtime = substream->runtime; in rewind_appl_ptr()
2633 ret = pcm_lib_apply_appl_ptr(substream, appl_ptr); in rewind_appl_ptr()
2642 static snd_pcm_sframes_t snd_pcm_rewind(struct snd_pcm_substream *substream, in snd_pcm_rewind() argument
2650 snd_pcm_stream_lock_irq(substream); in snd_pcm_rewind()
2651 ret = do_pcm_hwsync(substream); in snd_pcm_rewind()
2653 ret = rewind_appl_ptr(substream, frames, in snd_pcm_rewind()
2654 snd_pcm_hw_avail(substream)); in snd_pcm_rewind()
2655 snd_pcm_stream_unlock_irq(substream); in snd_pcm_rewind()
2659 static snd_pcm_sframes_t snd_pcm_forward(struct snd_pcm_substream *substream, in snd_pcm_forward() argument
2667 snd_pcm_stream_lock_irq(substream); in snd_pcm_forward()
2668 ret = do_pcm_hwsync(substream); in snd_pcm_forward()
2670 ret = forward_appl_ptr(substream, frames, in snd_pcm_forward()
2671 snd_pcm_avail(substream)); in snd_pcm_forward()
2672 snd_pcm_stream_unlock_irq(substream); in snd_pcm_forward()
2676 static int snd_pcm_hwsync(struct snd_pcm_substream *substream) in snd_pcm_hwsync() argument
2680 snd_pcm_stream_lock_irq(substream); in snd_pcm_hwsync()
2681 err = do_pcm_hwsync(substream); in snd_pcm_hwsync()
2682 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hwsync()
2686 static int snd_pcm_delay(struct snd_pcm_substream *substream, in snd_pcm_delay() argument
2692 snd_pcm_stream_lock_irq(substream); in snd_pcm_delay()
2693 err = do_pcm_hwsync(substream); in snd_pcm_delay()
2695 n = snd_pcm_calc_delay(substream); in snd_pcm_delay()
2696 snd_pcm_stream_unlock_irq(substream); in snd_pcm_delay()
2702 static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream, in snd_pcm_sync_ptr() argument
2705 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_sync_ptr()
2719 err = snd_pcm_hwsync(substream); in snd_pcm_sync_ptr()
2723 snd_pcm_stream_lock_irq(substream); in snd_pcm_sync_ptr()
2725 err = pcm_lib_apply_appl_ptr(substream, in snd_pcm_sync_ptr()
2728 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sync_ptr()
2743 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sync_ptr()
2749 static int snd_pcm_tstamp(struct snd_pcm_substream *substream, int __user *_arg) in snd_pcm_tstamp() argument
2751 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_tstamp()
2762 static int snd_pcm_xferi_frames_ioctl(struct snd_pcm_substream *substream, in snd_pcm_xferi_frames_ioctl() argument
2766 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xferi_frames_ioctl()
2775 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_xferi_frames_ioctl()
2776 result = snd_pcm_lib_write(substream, xferi.buf, xferi.frames); in snd_pcm_xferi_frames_ioctl()
2778 result = snd_pcm_lib_read(substream, xferi.buf, xferi.frames); in snd_pcm_xferi_frames_ioctl()
2783 static int snd_pcm_xfern_frames_ioctl(struct snd_pcm_substream *substream, in snd_pcm_xfern_frames_ioctl() argument
2787 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xfern_frames_ioctl()
2803 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_xfern_frames_ioctl()
2804 result = snd_pcm_lib_writev(substream, bufs, xfern.frames); in snd_pcm_xfern_frames_ioctl()
2806 result = snd_pcm_lib_readv(substream, bufs, xfern.frames); in snd_pcm_xfern_frames_ioctl()
2812 static int snd_pcm_rewind_ioctl(struct snd_pcm_substream *substream, in snd_pcm_rewind_ioctl() argument
2822 result = snd_pcm_rewind(substream, frames); in snd_pcm_rewind_ioctl()
2827 static int snd_pcm_forward_ioctl(struct snd_pcm_substream *substream, in snd_pcm_forward_ioctl() argument
2837 result = snd_pcm_forward(substream, frames); in snd_pcm_forward_ioctl()
2843 struct snd_pcm_substream *substream, in snd_pcm_common_ioctl() argument
2849 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_common_ioctl()
2852 res = snd_power_wait(substream->pcm->card, SNDRV_CTL_POWER_D0); in snd_pcm_common_ioctl()
2860 return snd_pcm_info_user(substream, arg); in snd_pcm_common_ioctl()
2864 return snd_pcm_tstamp(substream, arg); in snd_pcm_common_ioctl()
2871 return snd_pcm_hw_refine_user(substream, arg); in snd_pcm_common_ioctl()
2873 return snd_pcm_hw_params_user(substream, arg); in snd_pcm_common_ioctl()
2875 return snd_pcm_hw_free(substream); in snd_pcm_common_ioctl()
2877 return snd_pcm_sw_params_user(substream, arg); in snd_pcm_common_ioctl()
2879 return snd_pcm_status_user(substream, arg, false); in snd_pcm_common_ioctl()
2881 return snd_pcm_status_user(substream, arg, true); in snd_pcm_common_ioctl()
2883 return snd_pcm_channel_info_user(substream, arg); in snd_pcm_common_ioctl()
2885 return snd_pcm_prepare(substream, file); in snd_pcm_common_ioctl()
2887 return snd_pcm_reset(substream); in snd_pcm_common_ioctl()
2889 return snd_pcm_start_lock_irq(substream); in snd_pcm_common_ioctl()
2891 return snd_pcm_link(substream, (int)(unsigned long) arg); in snd_pcm_common_ioctl()
2893 return snd_pcm_unlink(substream); in snd_pcm_common_ioctl()
2895 return snd_pcm_resume(substream); in snd_pcm_common_ioctl()
2897 return snd_pcm_xrun(substream); in snd_pcm_common_ioctl()
2899 return snd_pcm_hwsync(substream); in snd_pcm_common_ioctl()
2906 err = snd_pcm_delay(substream, &delay); in snd_pcm_common_ioctl()
2914 return snd_pcm_sync_ptr(substream, arg); in snd_pcm_common_ioctl()
2917 return snd_pcm_hw_refine_old_user(substream, arg); in snd_pcm_common_ioctl()
2919 return snd_pcm_hw_params_old_user(substream, arg); in snd_pcm_common_ioctl()
2922 return snd_pcm_drain(substream, file); in snd_pcm_common_ioctl()
2924 return snd_pcm_drop(substream); in snd_pcm_common_ioctl()
2927 substream, in snd_pcm_common_ioctl()
2931 return snd_pcm_xferi_frames_ioctl(substream, arg); in snd_pcm_common_ioctl()
2934 return snd_pcm_xfern_frames_ioctl(substream, arg); in snd_pcm_common_ioctl()
2936 return snd_pcm_rewind_ioctl(substream, arg); in snd_pcm_common_ioctl()
2938 return snd_pcm_forward_ioctl(substream, arg); in snd_pcm_common_ioctl()
2940 pcm_dbg(substream->pcm, "unknown ioctl = 0x%x\n", cmd); in snd_pcm_common_ioctl()
2954 return snd_pcm_common_ioctl(file, pcm_file->substream, cmd, in snd_pcm_ioctl()
2968 int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, in snd_pcm_kernel_ioctl() argument
2978 if (substream->stream != SNDRV_PCM_STREAM_CAPTURE) in snd_pcm_kernel_ioctl()
2980 result = snd_pcm_forward(substream, *frames); in snd_pcm_kernel_ioctl()
2984 return snd_pcm_hw_params(substream, arg); in snd_pcm_kernel_ioctl()
2986 return snd_pcm_sw_params(substream, arg); in snd_pcm_kernel_ioctl()
2988 return snd_pcm_prepare(substream, NULL); in snd_pcm_kernel_ioctl()
2990 return snd_pcm_start_lock_irq(substream); in snd_pcm_kernel_ioctl()
2992 return snd_pcm_drain(substream, NULL); in snd_pcm_kernel_ioctl()
2994 return snd_pcm_drop(substream); in snd_pcm_kernel_ioctl()
2996 return snd_pcm_delay(substream, frames); in snd_pcm_kernel_ioctl()
3007 struct snd_pcm_substream *substream; in snd_pcm_read() local
3012 substream = pcm_file->substream; in snd_pcm_read()
3013 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_read()
3015 runtime = substream->runtime; in snd_pcm_read()
3021 result = snd_pcm_lib_read(substream, buf, count); in snd_pcm_read()
3031 struct snd_pcm_substream *substream; in snd_pcm_write() local
3036 substream = pcm_file->substream; in snd_pcm_write()
3037 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_write()
3039 runtime = substream->runtime; in snd_pcm_write()
3045 result = snd_pcm_lib_write(substream, buf, count); in snd_pcm_write()
3054 struct snd_pcm_substream *substream; in snd_pcm_readv() local
3062 substream = pcm_file->substream; in snd_pcm_readv()
3063 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_readv()
3065 runtime = substream->runtime; in snd_pcm_readv()
3080 result = snd_pcm_lib_readv(substream, bufs, frames); in snd_pcm_readv()
3090 struct snd_pcm_substream *substream; in snd_pcm_writev() local
3098 substream = pcm_file->substream; in snd_pcm_writev()
3099 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_writev()
3101 runtime = substream->runtime; in snd_pcm_writev()
3115 result = snd_pcm_lib_writev(substream, bufs, frames); in snd_pcm_writev()
3125 struct snd_pcm_substream *substream; in snd_pcm_poll() local
3132 substream = pcm_file->substream; in snd_pcm_poll()
3133 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_poll()
3137 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_poll()
3140 runtime = substream->runtime; in snd_pcm_poll()
3144 snd_pcm_stream_lock_irq(substream); in snd_pcm_poll()
3145 avail = snd_pcm_avail(substream); in snd_pcm_poll()
3154 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in snd_pcm_poll()
3164 snd_pcm_stream_unlock_irq(substream); in snd_pcm_poll()
3182 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_status_fault() local
3185 if (substream == NULL) in snd_pcm_mmap_status_fault()
3187 runtime = substream->runtime; in snd_pcm_mmap_status_fault()
3198 static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_status() argument
3208 area->vm_private_data = substream; in snd_pcm_mmap_status()
3218 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_control_fault() local
3221 if (substream == NULL) in snd_pcm_mmap_control_fault()
3223 runtime = substream->runtime; in snd_pcm_mmap_control_fault()
3234 static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_control() argument
3244 area->vm_private_data = substream; in snd_pcm_mmap_control()
3258 (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR)) in pcm_status_mmap_allowed()
3271 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR) in pcm_control_mmap_allowed()
3283 static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_status() argument
3288 static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_control() argument
3296 snd_pcm_default_page_ops(struct snd_pcm_substream *substream, unsigned long ofs) in snd_pcm_default_page_ops() argument
3298 void *vaddr = substream->runtime->dma_area + ofs; in snd_pcm_default_page_ops()
3307 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_data_fault() local
3313 if (substream == NULL) in snd_pcm_mmap_data_fault()
3315 runtime = substream->runtime; in snd_pcm_mmap_data_fault()
3320 if (substream->ops->page) in snd_pcm_mmap_data_fault()
3321 page = substream->ops->page(substream, offset); in snd_pcm_mmap_data_fault()
3323 page = snd_pcm_default_page_ops(substream, offset); in snd_pcm_mmap_data_fault()
3354 int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream, in snd_pcm_lib_default_mmap() argument
3359 if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV_IRAM) { in snd_pcm_lib_default_mmap()
3362 substream->dma_buffer.addr >> PAGE_SHIFT, in snd_pcm_lib_default_mmap()
3367 if (IS_ENABLED(CONFIG_HAS_DMA) && !substream->ops->page && in snd_pcm_lib_default_mmap()
3368 substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) in snd_pcm_lib_default_mmap()
3369 return dma_mmap_coherent(substream->dma_buffer.dev.dev, in snd_pcm_lib_default_mmap()
3371 substream->runtime->dma_area, in snd_pcm_lib_default_mmap()
3372 substream->runtime->dma_addr, in snd_pcm_lib_default_mmap()
3373 substream->runtime->dma_bytes); in snd_pcm_lib_default_mmap()
3394 int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, in snd_pcm_lib_mmap_iomem() argument
3397 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_mmap_iomem()
3408 int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_data() argument
3417 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_mmap_data()
3424 runtime = substream->runtime; in snd_pcm_mmap_data()
3441 area->vm_private_data = substream; in snd_pcm_mmap_data()
3442 if (substream->ops->mmap) in snd_pcm_mmap_data()
3443 err = substream->ops->mmap(substream, area); in snd_pcm_mmap_data()
3445 err = snd_pcm_lib_default_mmap(substream, area); in snd_pcm_mmap_data()
3447 atomic_inc(&substream->mmap_count); in snd_pcm_mmap_data()
3455 struct snd_pcm_substream *substream; in snd_pcm_mmap() local
3459 substream = pcm_file->substream; in snd_pcm_mmap()
3460 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_mmap()
3468 return snd_pcm_mmap_status(substream, file, area); in snd_pcm_mmap()
3472 return snd_pcm_mmap_control(substream, file, area); in snd_pcm_mmap()
3474 return snd_pcm_mmap_data(substream, file, area); in snd_pcm_mmap()
3482 struct snd_pcm_substream *substream; in snd_pcm_fasync() local
3486 substream = pcm_file->substream; in snd_pcm_fasync()
3487 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_fasync()
3489 runtime = substream->runtime; in snd_pcm_fasync()
3548 static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, in snd_pcm_hw_refine_old_user() argument
3565 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_refine_old_user()
3569 err = fixup_unreferenced_params(substream, params); in snd_pcm_hw_refine_old_user()
3583 static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, in snd_pcm_hw_params_old_user() argument
3601 err = snd_pcm_hw_params(substream, params); in snd_pcm_hw_params_old_user()
3624 struct snd_pcm_substream *substream = pcm_file->substream; in snd_pcm_get_unmapped_area() local
3625 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_get_unmapped_area()